2 Experimental ethernet netdevice using ATM AAL5 as underlying carrier
3 (RFC1483 obsoleted by RFC2684) for Linux 2.4
4 Author: Marcell GAL, 2000, XDSL Ltd, Hungary
7 #include <linux/module.h>
8 #include <linux/init.h>
9 #include <linux/kernel.h>
10 #include <linux/list.h>
11 #include <linux/netdevice.h>
12 #include <linux/skbuff.h>
13 #include <linux/etherdevice.h>
14 #include <linux/rtnetlink.h>
16 #include <asm/uaccess.h>
18 #include <linux/atm.h>
19 #include <linux/atmdev.h>
20 #include <linux/capability.h>
21 #include <linux/seq_file.h>
23 #include <linux/atmbr2684.h>
28 * Define this to use a version of the code which interacts with the higher
29 * layers in a more intellegent way, by always reserving enough space for
30 * our header at the begining of the packet. However, there may still be
31 * some problems with programs like tcpdump. In 2.5 we'll sort out what
32 * we need to do to get this perfect. For now we just will copy the packet
33 * if we need space for the header
35 /* #define FASTER_VERSION */
38 static void skb_debug(const struct sk_buff
*skb
)
41 char buf
[NUM2PRINT
* 3 + 1]; /* 3 chars per byte */
43 for (i
= 0; i
< skb
->len
&& i
< NUM2PRINT
; i
++) {
44 sprintf(buf
+ i
* 3, "%2.2x ", 0xff & skb
->data
[i
]);
46 printk(KERN_DEBUG
"br2684: skb: %s\n", buf
);
49 #define skb_debug(skb) do {} while (0)
52 static unsigned char llc_oui_pid_pad
[] =
53 { 0xAA, 0xAA, 0x03, 0x00, 0x80, 0xC2, 0x00, 0x07, 0x00, 0x00 };
57 e_vc
= BR2684_ENCAPS_VC
,
58 e_llc
= BR2684_ENCAPS_LLC
,
62 struct atm_vcc
*atmvcc
;
63 struct net_device
*device
;
64 /* keep old push,pop functions for chaining */
65 void (*old_push
)(struct atm_vcc
*vcc
,struct sk_buff
*skb
);
66 /* void (*old_pop)(struct atm_vcc *vcc,struct sk_buff *skb); */
67 enum br2684_encaps encaps
;
68 struct list_head brvccs
;
69 #ifdef CONFIG_ATM_BR2684_IPFILTER
70 struct br2684_filter filter
;
71 #endif /* CONFIG_ATM_BR2684_IPFILTER */
72 #ifndef FASTER_VERSION
73 unsigned copies_needed
, copies_failed
;
74 #endif /* FASTER_VERSION */
78 struct net_device
*net_dev
;
79 struct list_head br2684_devs
;
81 struct list_head brvccs
; /* one device <=> one vcc (before xmas) */
82 struct net_device_stats stats
;
87 * This lock should be held for writing any time the list of devices or
88 * their attached vcc's could be altered. It should be held for reading
89 * any time these are being queried. Note that we sometimes need to
90 * do read-locking under interrupt context, so write locking must block
91 * the current CPU's interrupts
93 static DEFINE_RWLOCK(devs_lock
);
95 static LIST_HEAD(br2684_devs
);
97 static inline struct br2684_dev
*BRPRIV(const struct net_device
*net_dev
)
99 return (struct br2684_dev
*) net_dev
->priv
;
102 static inline struct net_device
*list_entry_brdev(const struct list_head
*le
)
104 return list_entry(le
, struct br2684_dev
, br2684_devs
)->net_dev
;
107 static inline struct br2684_vcc
*BR2684_VCC(const struct atm_vcc
*atmvcc
)
109 return (struct br2684_vcc
*) (atmvcc
->user_back
);
112 static inline struct br2684_vcc
*list_entry_brvcc(const struct list_head
*le
)
114 return list_entry(le
, struct br2684_vcc
, brvccs
);
117 /* Caller should hold read_lock(&devs_lock) */
118 static struct net_device
*br2684_find_dev(const struct br2684_if_spec
*s
)
120 struct list_head
*lh
;
121 struct net_device
*net_dev
;
123 case BR2684_FIND_BYNUM
:
124 list_for_each(lh
, &br2684_devs
) {
125 net_dev
= list_entry_brdev(lh
);
126 if (BRPRIV(net_dev
)->number
== s
->spec
.devnum
)
130 case BR2684_FIND_BYIFNAME
:
131 list_for_each(lh
, &br2684_devs
) {
132 net_dev
= list_entry_brdev(lh
);
133 if (!strncmp(net_dev
->name
, s
->spec
.ifname
, IFNAMSIZ
))
142 * Send a packet out a particular vcc. Not to useful right now, but paves
143 * the way for multiple vcc's per itf. Returns true if we can send,
146 static int br2684_xmit_vcc(struct sk_buff
*skb
, struct br2684_dev
*brdev
,
147 struct br2684_vcc
*brvcc
)
149 struct atm_vcc
*atmvcc
;
150 #ifdef FASTER_VERSION
151 if (brvcc
->encaps
== e_llc
)
152 memcpy(skb_push(skb
, 8), llc_oui_pid_pad
, 8);
153 /* last 2 bytes of llc_oui_pid_pad are managed by header routines;
154 yes, you got it: 8 + 2 = sizeof(llc_oui_pid_pad)
157 int minheadroom
= (brvcc
->encaps
== e_llc
) ? 10 : 2;
158 if (skb_headroom(skb
) < minheadroom
) {
159 struct sk_buff
*skb2
= skb_realloc_headroom(skb
, minheadroom
);
160 brvcc
->copies_needed
++;
163 brvcc
->copies_failed
++;
168 skb_push(skb
, minheadroom
);
169 if (brvcc
->encaps
== e_llc
)
170 skb_copy_to_linear_data(skb
, llc_oui_pid_pad
, 10);
172 memset(skb
->data
, 0, 2);
173 #endif /* FASTER_VERSION */
176 ATM_SKB(skb
)->vcc
= atmvcc
= brvcc
->atmvcc
;
177 pr_debug("atm_skb(%p)->vcc(%p)->dev(%p)\n", skb
, atmvcc
, atmvcc
->dev
);
178 if (!atm_may_send(atmvcc
, skb
->truesize
)) {
179 /* we free this here for now, because we cannot know in a higher
180 layer whether the skb point it supplied wasn't freed yet.
186 atomic_add(skb
->truesize
, &sk_atm(atmvcc
)->sk_wmem_alloc
);
187 ATM_SKB(skb
)->atm_options
= atmvcc
->atm_options
;
188 brdev
->stats
.tx_packets
++;
189 brdev
->stats
.tx_bytes
+= skb
->len
;
190 atmvcc
->send(atmvcc
, skb
);
194 static inline struct br2684_vcc
*pick_outgoing_vcc(struct sk_buff
*skb
,
195 struct br2684_dev
*brdev
)
197 return list_empty(&brdev
->brvccs
) ? NULL
:
198 list_entry_brvcc(brdev
->brvccs
.next
); /* 1 vcc/dev right now */
201 static int br2684_start_xmit(struct sk_buff
*skb
, struct net_device
*dev
)
203 struct br2684_dev
*brdev
= BRPRIV(dev
);
204 struct br2684_vcc
*brvcc
;
206 pr_debug("br2684_start_xmit, skb->dst=%p\n", skb
->dst
);
207 read_lock(&devs_lock
);
208 brvcc
= pick_outgoing_vcc(skb
, brdev
);
210 pr_debug("no vcc attached to dev %s\n", dev
->name
);
211 brdev
->stats
.tx_errors
++;
212 brdev
->stats
.tx_carrier_errors
++;
213 /* netif_stop_queue(dev); */
215 read_unlock(&devs_lock
);
218 if (!br2684_xmit_vcc(skb
, brdev
, brvcc
)) {
220 * We should probably use netif_*_queue() here, but that
221 * involves added complication. We need to walk before
224 /* don't free here! this pointer might be no longer valid!
227 brdev
->stats
.tx_errors
++;
228 brdev
->stats
.tx_fifo_errors
++;
230 read_unlock(&devs_lock
);
234 static struct net_device_stats
*br2684_get_stats(struct net_device
*dev
)
236 pr_debug("br2684_get_stats\n");
237 return &BRPRIV(dev
)->stats
;
240 #ifdef FASTER_VERSION
242 * These mirror eth_header and eth_header_cache. They are not usually
243 * exported for use in modules, so we grab them from net_device
244 * after ether_setup() is done with it. Bit of a hack.
246 static int (*my_eth_header
)(struct sk_buff
*, struct net_device
*,
247 unsigned short, void *, void *, unsigned);
248 static int (*my_eth_header_cache
)(struct neighbour
*, struct hh_cache
*);
251 br2684_header(struct sk_buff
*skb
, struct net_device
*dev
,
252 unsigned short type
, void *daddr
, void *saddr
, unsigned len
)
255 int t
= my_eth_header(skb
, dev
, type
, daddr
, saddr
, len
);
257 pad_before_eth
= (u16
*) skb_push(skb
, 2);
259 return dev
->hard_header_len
; /* or return 16; ? */
265 br2684_header_cache(struct neighbour
*neigh
, struct hh_cache
*hh
)
267 /* hh_data is 16 bytes long. if encaps is ether-llc we need 24, so
268 xmit will add the additional header part in that case */
269 u16
*pad_before_eth
= (u16
*)(hh
->hh_data
);
270 int t
= my_eth_header_cache(neigh
, hh
);
271 DPRINTK("br2684_header_cache, neigh=%p, hh_cache=%p\n", neigh
, hh
);
276 hh
->hh_len
= PADLEN
+ ETH_HLEN
;
282 * This is similar to eth_type_trans, which cannot be used because of
283 * our dev->hard_header_len
285 static inline __be16
br_type_trans(struct sk_buff
*skb
, struct net_device
*dev
)
291 if (is_multicast_ether_addr(eth
->h_dest
)) {
292 if (!compare_ether_addr(eth
->h_dest
, dev
->broadcast
))
293 skb
->pkt_type
= PACKET_BROADCAST
;
295 skb
->pkt_type
= PACKET_MULTICAST
;
298 else if (compare_ether_addr(eth
->h_dest
, dev
->dev_addr
))
299 skb
->pkt_type
= PACKET_OTHERHOST
;
301 if (ntohs(eth
->h_proto
) >= 1536)
307 * This is a magic hack to spot IPX packets. Older Novell breaks
308 * the protocol design and runs IPX over 802.3 without an 802.2 LLC
309 * layer. We look for FFFF which isn't a used 802.2 SSAP/DSAP. This
310 * won't work for fault tolerant netware but does for the rest.
312 if (*(unsigned short *) rawp
== 0xFFFF)
313 return htons(ETH_P_802_3
);
318 return htons(ETH_P_802_2
);
320 #endif /* FASTER_VERSION */
323 * We remember when the MAC gets set, so we don't override it later with
324 * the ESI of the ATM card of the first VC
326 static int (*my_eth_mac_addr
)(struct net_device
*, void *);
327 static int br2684_mac_addr(struct net_device
*dev
, void *p
)
329 int err
= my_eth_mac_addr(dev
, p
);
331 BRPRIV(dev
)->mac_was_set
= 1;
335 #ifdef CONFIG_ATM_BR2684_IPFILTER
336 /* this IOCTL is experimental. */
337 static int br2684_setfilt(struct atm_vcc
*atmvcc
, void __user
*arg
)
339 struct br2684_vcc
*brvcc
;
340 struct br2684_filter_set fs
;
342 if (copy_from_user(&fs
, arg
, sizeof fs
))
344 if (fs
.ifspec
.method
!= BR2684_FIND_BYNOTHING
) {
346 * This is really a per-vcc thing, but we can also search
349 struct br2684_dev
*brdev
;
350 read_lock(&devs_lock
);
351 brdev
= BRPRIV(br2684_find_dev(&fs
.ifspec
));
352 if (brdev
== NULL
|| list_empty(&brdev
->brvccs
) ||
353 brdev
->brvccs
.next
!= brdev
->brvccs
.prev
) /* >1 VCC */
356 brvcc
= list_entry_brvcc(brdev
->brvccs
.next
);
357 read_unlock(&devs_lock
);
361 brvcc
= BR2684_VCC(atmvcc
);
362 memcpy(&brvcc
->filter
, &fs
.filter
, sizeof(brvcc
->filter
));
366 /* Returns 1 if packet should be dropped */
368 packet_fails_filter(__be16 type
, struct br2684_vcc
*brvcc
, struct sk_buff
*skb
)
370 if (brvcc
->filter
.netmask
== 0)
371 return 0; /* no filter in place */
372 if (type
== htons(ETH_P_IP
) &&
373 (((struct iphdr
*) (skb
->data
))->daddr
& brvcc
->filter
.
374 netmask
) == brvcc
->filter
.prefix
)
376 if (type
== htons(ETH_P_ARP
))
378 /* TODO: we should probably filter ARPs too.. don't want to have
379 * them returning values that don't make sense, or is that ok?
383 #endif /* CONFIG_ATM_BR2684_IPFILTER */
385 static void br2684_close_vcc(struct br2684_vcc
*brvcc
)
387 pr_debug("removing VCC %p from dev %p\n", brvcc
, brvcc
->device
);
388 write_lock_irq(&devs_lock
);
389 list_del(&brvcc
->brvccs
);
390 write_unlock_irq(&devs_lock
);
391 brvcc
->atmvcc
->user_back
= NULL
; /* what about vcc->recvq ??? */
392 brvcc
->old_push(brvcc
->atmvcc
, NULL
); /* pass on the bad news */
394 module_put(THIS_MODULE
);
397 /* when AAL5 PDU comes in: */
398 static void br2684_push(struct atm_vcc
*atmvcc
, struct sk_buff
*skb
)
400 struct br2684_vcc
*brvcc
= BR2684_VCC(atmvcc
);
401 struct net_device
*net_dev
= brvcc
->device
;
402 struct br2684_dev
*brdev
= BRPRIV(net_dev
);
403 int plen
= sizeof(llc_oui_pid_pad
) + ETH_HLEN
;
405 pr_debug("br2684_push\n");
407 if (unlikely(skb
== NULL
)) {
408 /* skb==NULL means VCC is being destroyed */
409 br2684_close_vcc(brvcc
);
410 if (list_empty(&brdev
->brvccs
)) {
411 read_lock(&devs_lock
);
412 list_del(&brdev
->br2684_devs
);
413 read_unlock(&devs_lock
);
414 unregister_netdev(net_dev
);
415 free_netdev(net_dev
);
421 atm_return(atmvcc
, skb
->truesize
);
422 pr_debug("skb from brdev %p\n", brdev
);
423 if (brvcc
->encaps
== e_llc
) {
424 /* let us waste some time for checking the encapsulation.
425 Note, that only 7 char is checked so frames with a valid FCS
426 are also accepted (but FCS is not checked of course) */
427 if (memcmp(skb
->data
, llc_oui_pid_pad
, 7)) {
428 brdev
->stats
.rx_errors
++;
433 /* Strip FCS if present */
434 if (skb
->len
> 7 && skb
->data
[7] == 0x01)
435 __skb_trim(skb
, skb
->len
- 4);
437 plen
= PADLEN
+ ETH_HLEN
; /* pad, dstmac,srcmac, ethtype */
438 /* first 2 chars should be 0 */
439 if (*((u16
*) (skb
->data
)) != 0) {
440 brdev
->stats
.rx_errors
++;
445 if (skb
->len
< plen
) {
446 brdev
->stats
.rx_errors
++;
447 dev_kfree_skb(skb
); /* dev_ not needed? */
451 #ifdef FASTER_VERSION
452 /* FIXME: tcpdump shows that pointer to mac header is 2 bytes earlier,
453 than should be. What else should I set? */
455 skb_set_mac_header(skb
, -ETH_HLEN
);
456 skb
->pkt_type
= PACKET_HOST
;
457 skb
->protocol
= br_type_trans(skb
, net_dev
);
459 skb_pull(skb
, plen
- ETH_HLEN
);
460 skb
->protocol
= eth_type_trans(skb
, net_dev
);
461 #endif /* FASTER_VERSION */
462 #ifdef CONFIG_ATM_BR2684_IPFILTER
463 if (unlikely(packet_fails_filter(skb
->protocol
, brvcc
, skb
))) {
464 brdev
->stats
.rx_dropped
++;
468 #endif /* CONFIG_ATM_BR2684_IPFILTER */
470 ATM_SKB(skb
)->vcc
= atmvcc
; /* needed ? */
471 pr_debug("received packet's protocol: %x\n", ntohs(skb
->protocol
));
473 if (unlikely(!(net_dev
->flags
& IFF_UP
))) {
474 /* sigh, interface is down */
475 brdev
->stats
.rx_dropped
++;
479 brdev
->stats
.rx_packets
++;
480 brdev
->stats
.rx_bytes
+= skb
->len
;
481 memset(ATM_SKB(skb
), 0, sizeof(struct atm_skb_data
));
485 static int br2684_regvcc(struct atm_vcc
*atmvcc
, void __user
*arg
)
487 /* assign a vcc to a dev
488 Note: we do not have explicit unassign, but look at _push()
491 struct br2684_vcc
*brvcc
;
493 struct sk_buff_head
*rq
;
494 struct br2684_dev
*brdev
;
495 struct net_device
*net_dev
;
496 struct atm_backend_br2684 be
;
499 if (copy_from_user(&be
, arg
, sizeof be
))
501 brvcc
= kzalloc(sizeof(struct br2684_vcc
), GFP_KERNEL
);
504 write_lock_irq(&devs_lock
);
505 net_dev
= br2684_find_dev(&be
.ifspec
);
506 if (net_dev
== NULL
) {
508 "br2684: tried to attach to non-existant device\n");
512 brdev
= BRPRIV(net_dev
);
513 if (atmvcc
->push
== NULL
) {
517 if (!list_empty(&brdev
->brvccs
)) {
518 /* Only 1 VCC/dev right now */
522 if (be
.fcs_in
!= BR2684_FCSIN_NO
|| be
.fcs_out
!= BR2684_FCSOUT_NO
||
523 be
.fcs_auto
|| be
.has_vpiid
|| be
.send_padding
|| (be
.encaps
!=
524 BR2684_ENCAPS_VC
&& be
.encaps
!= BR2684_ENCAPS_LLC
) ||
529 pr_debug("br2684_regvcc vcc=%p, encaps=%d, brvcc=%p\n", atmvcc
, be
.encaps
,
531 if (list_empty(&brdev
->brvccs
) && !brdev
->mac_was_set
) {
532 unsigned char *esi
= atmvcc
->dev
->esi
;
533 if (esi
[0] | esi
[1] | esi
[2] | esi
[3] | esi
[4] | esi
[5])
534 memcpy(net_dev
->dev_addr
, esi
, net_dev
->addr_len
);
536 net_dev
->dev_addr
[2] = 1;
538 list_add(&brvcc
->brvccs
, &brdev
->brvccs
);
539 write_unlock_irq(&devs_lock
);
540 brvcc
->device
= net_dev
;
541 brvcc
->atmvcc
= atmvcc
;
542 atmvcc
->user_back
= brvcc
;
543 brvcc
->encaps
= (enum br2684_encaps
) be
.encaps
;
544 brvcc
->old_push
= atmvcc
->push
;
546 atmvcc
->push
= br2684_push
;
548 rq
= &sk_atm(atmvcc
)->sk_receive_queue
;
550 spin_lock_irqsave(&rq
->lock
, flags
);
551 if (skb_queue_empty(rq
)) {
554 /* NULL terminate the list. */
555 rq
->prev
->next
= NULL
;
558 rq
->prev
= rq
->next
= (struct sk_buff
*)rq
;
560 spin_unlock_irqrestore(&rq
->lock
, flags
);
563 struct sk_buff
*next
= skb
->next
;
565 skb
->next
= skb
->prev
= NULL
;
566 BRPRIV(skb
->dev
)->stats
.rx_bytes
-= skb
->len
;
567 BRPRIV(skb
->dev
)->stats
.rx_packets
--;
568 br2684_push(atmvcc
, skb
);
572 __module_get(THIS_MODULE
);
575 write_unlock_irq(&devs_lock
);
580 static void br2684_setup(struct net_device
*netdev
)
582 struct br2684_dev
*brdev
= BRPRIV(netdev
);
585 brdev
->net_dev
= netdev
;
587 #ifdef FASTER_VERSION
588 my_eth_header
= netdev
->hard_header
;
589 netdev
->hard_header
= br2684_header
;
590 my_eth_header_cache
= netdev
->hard_header_cache
;
591 netdev
->hard_header_cache
= br2684_header_cache
;
592 netdev
->hard_header_len
= sizeof(llc_oui_pid_pad
) + ETH_HLEN
; /* 10 + 14 */
594 my_eth_mac_addr
= netdev
->set_mac_address
;
595 netdev
->set_mac_address
= br2684_mac_addr
;
596 netdev
->hard_start_xmit
= br2684_start_xmit
;
597 netdev
->get_stats
= br2684_get_stats
;
599 INIT_LIST_HEAD(&brdev
->brvccs
);
602 static int br2684_create(void __user
*arg
)
605 struct net_device
*netdev
;
606 struct br2684_dev
*brdev
;
607 struct atm_newif_br2684 ni
;
609 pr_debug("br2684_create\n");
611 if (copy_from_user(&ni
, arg
, sizeof ni
)) {
614 if (ni
.media
!= BR2684_MEDIA_ETHERNET
|| ni
.mtu
!= 1500) {
618 netdev
= alloc_netdev(sizeof(struct br2684_dev
),
619 ni
.ifname
[0] ? ni
.ifname
: "nas%d",
624 brdev
= BRPRIV(netdev
);
626 pr_debug("registered netdev %s\n", netdev
->name
);
627 /* open, stop, do_ioctl ? */
628 err
= register_netdev(netdev
);
630 printk(KERN_ERR
"br2684_create: register_netdev failed\n");
635 write_lock_irq(&devs_lock
);
636 brdev
->number
= list_empty(&br2684_devs
) ? 1 :
637 BRPRIV(list_entry_brdev(br2684_devs
.prev
))->number
+ 1;
638 list_add_tail(&brdev
->br2684_devs
, &br2684_devs
);
639 write_unlock_irq(&devs_lock
);
644 * This handles ioctls actually performed on our vcc - we must return
645 * -ENOIOCTLCMD for any unrecognized ioctl
647 static int br2684_ioctl(struct socket
*sock
, unsigned int cmd
,
650 struct atm_vcc
*atmvcc
= ATM_SD(sock
);
651 void __user
*argp
= (void __user
*)arg
;
656 case ATM_NEWBACKENDIF
: {
658 err
= get_user(b
, (atm_backend_t __user
*) argp
);
661 if (b
!= ATM_BACKEND_BR2684
)
663 if (!capable(CAP_NET_ADMIN
))
665 if (cmd
== ATM_SETBACKEND
)
666 return br2684_regvcc(atmvcc
, argp
);
668 return br2684_create(argp
);
670 #ifdef CONFIG_ATM_BR2684_IPFILTER
672 if (atmvcc
->push
!= br2684_push
)
674 if (!capable(CAP_NET_ADMIN
))
676 err
= br2684_setfilt(atmvcc
, argp
);
678 #endif /* CONFIG_ATM_BR2684_IPFILTER */
683 static struct atm_ioctl br2684_ioctl_ops
= {
684 .owner
= THIS_MODULE
,
685 .ioctl
= br2684_ioctl
,
689 #ifdef CONFIG_PROC_FS
690 static void *br2684_seq_start(struct seq_file
*seq
, loff_t
*pos
)
692 read_lock(&devs_lock
);
693 return seq_list_start(&br2684_devs
, *pos
);
696 static void *br2684_seq_next(struct seq_file
*seq
, void *v
, loff_t
*pos
)
698 return seq_list_next(v
, &br2684_devs
, pos
);
701 static void br2684_seq_stop(struct seq_file
*seq
, void *v
)
703 read_unlock(&devs_lock
);
706 static int br2684_seq_show(struct seq_file
*seq
, void *v
)
708 const struct br2684_dev
*brdev
= list_entry(v
, struct br2684_dev
,
710 const struct net_device
*net_dev
= brdev
->net_dev
;
711 const struct br2684_vcc
*brvcc
;
712 DECLARE_MAC_BUF(mac
);
714 seq_printf(seq
, "dev %.16s: num=%d, mac=%s (%s)\n",
717 print_mac(mac
, net_dev
->dev_addr
),
718 brdev
->mac_was_set
? "set" : "auto");
720 list_for_each_entry(brvcc
, &brdev
->brvccs
, brvccs
) {
721 seq_printf(seq
, " vcc %d.%d.%d: encaps=%s"
722 #ifndef FASTER_VERSION
723 ", failed copies %u/%u"
724 #endif /* FASTER_VERSION */
725 "\n", brvcc
->atmvcc
->dev
->number
,
726 brvcc
->atmvcc
->vpi
, brvcc
->atmvcc
->vci
,
727 (brvcc
->encaps
== e_llc
) ? "LLC" : "VC"
728 #ifndef FASTER_VERSION
729 , brvcc
->copies_failed
730 , brvcc
->copies_needed
731 #endif /* FASTER_VERSION */
733 #ifdef CONFIG_ATM_BR2684_IPFILTER
734 #define b1(var, byte) ((u8 *) &brvcc->filter.var)[byte]
735 #define bs(var) b1(var, 0), b1(var, 1), b1(var, 2), b1(var, 3)
736 if (brvcc
->filter
.netmask
!= 0)
737 seq_printf(seq
, " filter=%d.%d.%d.%d/"
739 bs(prefix
), bs(netmask
));
742 #endif /* CONFIG_ATM_BR2684_IPFILTER */
747 static const struct seq_operations br2684_seq_ops
= {
748 .start
= br2684_seq_start
,
749 .next
= br2684_seq_next
,
750 .stop
= br2684_seq_stop
,
751 .show
= br2684_seq_show
,
754 static int br2684_proc_open(struct inode
*inode
, struct file
*file
)
756 return seq_open(file
, &br2684_seq_ops
);
759 static const struct file_operations br2684_proc_ops
= {
760 .owner
= THIS_MODULE
,
761 .open
= br2684_proc_open
,
764 .release
= seq_release
,
767 extern struct proc_dir_entry
*atm_proc_root
; /* from proc.c */
770 static int __init
br2684_init(void)
772 #ifdef CONFIG_PROC_FS
773 struct proc_dir_entry
*p
;
774 if ((p
= create_proc_entry("br2684", 0, atm_proc_root
)) == NULL
)
776 p
->proc_fops
= &br2684_proc_ops
;
778 register_atm_ioctl(&br2684_ioctl_ops
);
782 static void __exit
br2684_exit(void)
784 struct net_device
*net_dev
;
785 struct br2684_dev
*brdev
;
786 struct br2684_vcc
*brvcc
;
787 deregister_atm_ioctl(&br2684_ioctl_ops
);
789 #ifdef CONFIG_PROC_FS
790 remove_proc_entry("br2684", atm_proc_root
);
793 while (!list_empty(&br2684_devs
)) {
794 net_dev
= list_entry_brdev(br2684_devs
.next
);
795 brdev
= BRPRIV(net_dev
);
796 while (!list_empty(&brdev
->brvccs
)) {
797 brvcc
= list_entry_brvcc(brdev
->brvccs
.next
);
798 br2684_close_vcc(brvcc
);
801 list_del(&brdev
->br2684_devs
);
802 unregister_netdev(net_dev
);
803 free_netdev(net_dev
);
807 module_init(br2684_init
);
808 module_exit(br2684_exit
);
810 MODULE_AUTHOR("Marcell GAL");
811 MODULE_DESCRIPTION("RFC2684 bridged protocols over ATM/AAL5");
812 MODULE_LICENSE("GPL");