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/config.h>
9 #include <linux/init.h>
10 #include <linux/kernel.h>
11 #include <linux/list.h>
12 #include <linux/netdevice.h>
13 #include <linux/skbuff.h>
14 #include <linux/etherdevice.h>
15 #include <linux/rtnetlink.h>
17 #include <asm/uaccess.h>
19 #include <linux/atm.h>
20 #include <linux/atmdev.h>
21 #include <linux/seq_file.h>
23 #include <linux/atmbr2684.h>
29 * Define this to use a version of the code which interacts with the higher
30 * layers in a more intellegent way, by always reserving enough space for
31 * our header at the begining of the packet. However, there may still be
32 * some problems with programs like tcpdump. In 2.5 we'll sort out what
33 * we need to do to get this perfect. For now we just will copy the packet
34 * if we need space for the header
36 /* #define FASTER_VERSION */
39 #define DPRINTK(format, args...) printk(KERN_DEBUG "br2684: " format, ##args)
41 #define DPRINTK(format, args...)
45 static void skb_debug(const struct sk_buff *skb)
48 char buf[NUM2PRINT * 3 + 1]; /* 3 chars per byte */
50 for (i = 0; i < skb->len && i < NUM2PRINT; i++) {
51 sprintf(buf + i * 3, "%2.2x ", 0xff & skb->data[i]);
53 printk(KERN_DEBUG "br2684: skb: %s\n", buf);
56 #define skb_debug(skb) do {} while (0)
59 static unsigned char llc_oui_pid_pad[] =
60 { 0xAA, 0xAA, 0x03, 0x00, 0x80, 0xC2, 0x00, 0x07, 0x00, 0x00 };
64 e_vc = BR2684_ENCAPS_VC,
65 e_llc = BR2684_ENCAPS_LLC,
69 struct atm_vcc *atmvcc;
70 struct net_device *device;
71 /* keep old push,pop functions for chaining */
72 void (*old_push)(struct atm_vcc *vcc,struct sk_buff *skb);
73 /* void (*old_pop)(struct atm_vcc *vcc,struct sk_buff *skb); */
74 enum br2684_encaps encaps;
75 struct list_head brvccs;
76 #ifdef CONFIG_ATM_BR2684_IPFILTER
77 struct br2684_filter filter;
78 #endif /* CONFIG_ATM_BR2684_IPFILTER */
79 #ifndef FASTER_VERSION
80 unsigned copies_needed, copies_failed;
81 #endif /* FASTER_VERSION */
82 #if defined(CONFIG_MIPS_BRCM)
83 /* Protocol filter flag, currently only PPPoE.
84 When turned on, all non-PPPoE traffic will be dropped
91 struct net_device *net_dev;
92 struct list_head br2684_devs;
94 struct list_head brvccs; /* one device <=> one vcc (before xmas) */
95 struct net_device_stats stats;
99 #if defined(CONFIG_MIPS_BRCM)
100 #define MIN_PKT_SIZE 70
104 * This lock should be held for writing any time the list of devices or
105 * their attached vcc's could be altered. It should be held for reading
106 * any time these are being queried. Note that we sometimes need to
107 * do read-locking under interrupt context, so write locking must block
108 * the current CPU's interrupts
110 static rwlock_t devs_lock = RW_LOCK_UNLOCKED;
112 static LIST_HEAD(br2684_devs);
114 static inline struct br2684_dev *BRPRIV(const struct net_device *net_dev)
116 return (struct br2684_dev *) net_dev->priv;
119 static inline struct net_device *list_entry_brdev(const struct list_head *le)
121 return list_entry(le, struct br2684_dev, br2684_devs)->net_dev;
124 static inline struct br2684_vcc *BR2684_VCC(const struct atm_vcc *atmvcc)
126 return (struct br2684_vcc *) (atmvcc->user_back);
129 static inline struct br2684_vcc *list_entry_brvcc(const struct list_head *le)
131 return list_entry(le, struct br2684_vcc, brvccs);
134 /* Caller should hold read_lock(&devs_lock) */
135 static struct net_device *br2684_find_dev(const struct br2684_if_spec *s)
137 struct list_head *lh;
138 struct net_device *net_dev;
140 case BR2684_FIND_BYNUM:
141 list_for_each(lh, &br2684_devs) {
142 net_dev = list_entry_brdev(lh);
143 if (BRPRIV(net_dev)->number == s->spec.devnum)
147 case BR2684_FIND_BYIFNAME:
148 list_for_each(lh, &br2684_devs) {
149 net_dev = list_entry_brdev(lh);
150 if (!strncmp(net_dev->name, s->spec.ifname, IFNAMSIZ))
159 * Send a packet out a particular vcc. Not to useful right now, but paves
160 * the way for multiple vcc's per itf. Returns true if we can send,
163 static int br2684_xmit_vcc(struct sk_buff *skb, struct br2684_dev *brdev,
164 struct br2684_vcc *brvcc)
166 struct atm_vcc *atmvcc;
167 #ifdef FASTER_VERSION
168 if (brvcc->encaps == e_llc)
169 memcpy(skb_push(skb, 8), llc_oui_pid_pad, 8);
170 /* last 2 bytes of llc_oui_pid_pad are managed by header routines;
171 yes, you got it: 8 + 2 = sizeof(llc_oui_pid_pad)
174 int minheadroom = (brvcc->encaps == e_llc) ? 10 : 2;
175 if (skb_headroom(skb) < minheadroom) {
176 struct sk_buff *skb2 = skb_realloc_headroom(skb, minheadroom);
177 brvcc->copies_needed++;
180 brvcc->copies_failed++;
185 skb_push(skb, minheadroom);
186 if (brvcc->encaps == e_llc)
187 memcpy(skb->data, llc_oui_pid_pad, 10);
189 memset(skb->data, 0, 2);
190 #endif /* FASTER_VERSION */
192 #if defined(CONFIG_MIPS_BRCM)
193 if (skb->len < MIN_PKT_SIZE)
195 struct sk_buff *skb2=skb_copy_expand(skb, 0, MIN_PKT_SIZE - skb->len, GFP_ATOMIC);
198 brvcc->copies_failed++;
202 memset(skb->tail, 0, MIN_PKT_SIZE - skb->len);
203 skb_put(skb, MIN_PKT_SIZE - skb->len);
209 ATM_SKB(skb)->vcc = atmvcc = brvcc->atmvcc;
210 DPRINTK("atm_skb(%p)->vcc(%p)->dev(%p)\n", skb, atmvcc, atmvcc->dev);
211 if (!atm_may_send(atmvcc, skb->truesize)) {
212 /* we free this here for now, because we cannot know in a higher
213 layer whether the skb point it supplied wasn't freed yet.
219 atomic_add(skb->truesize, &atmvcc->sk->sk_wmem_alloc);
220 ATM_SKB(skb)->atm_options = atmvcc->atm_options;
221 brdev->stats.tx_packets++;
222 brdev->stats.tx_bytes += skb->len;
223 #if defined(CONFIG_MIPS_BRCM)
224 if (atmvcc->send(atmvcc, skb) != 0)
225 brdev->stats.tx_dropped++;
227 atmvcc->send(atmvcc, skb);
233 static inline struct br2684_vcc *pick_outgoing_vcc(struct sk_buff *skb,
234 struct br2684_dev *brdev)
236 return list_empty(&brdev->brvccs) ? NULL :
237 list_entry_brvcc(brdev->brvccs.next); /* 1 vcc/dev right now */
240 static int br2684_start_xmit(struct sk_buff *skb, struct net_device *dev)
242 struct br2684_dev *brdev = BRPRIV(dev);
243 struct br2684_vcc *brvcc;
245 DPRINTK("br2684_start_xmit, skb->dst=%p\n", skb->dst);
246 read_lock(&devs_lock);
247 brvcc = pick_outgoing_vcc(skb, brdev);
249 DPRINTK("no vcc attached to dev %s\n", dev->name);
250 brdev->stats.tx_errors++;
251 brdev->stats.tx_carrier_errors++;
252 /* netif_stop_queue(dev); */
254 read_unlock(&devs_lock);
258 #if defined(CONFIG_MIPS_BRCM)
259 if (brvcc->proto_filter & FILTER_PPPOE) {
260 if ((skb->protocol != htons(ETH_P_PPP_DISC)) && (skb->protocol != htons(ETH_P_PPP_SES))) {
261 DPRINTK("non-PPPOE packet dropped on TX dev %s\n", dev->name);
262 brdev->stats.tx_dropped++;
264 read_unlock(&devs_lock);
269 if (!br2684_xmit_vcc(skb, brdev, brvcc)) {
271 * We should probably use netif_*_queue() here, but that
272 * involves added complication. We need to walk before
275 /* don't free here! this pointer might be no longer valid!
278 brdev->stats.tx_errors++;
279 brdev->stats.tx_fifo_errors++;
281 read_unlock(&devs_lock);
285 static struct net_device_stats *br2684_get_stats(struct net_device *dev)
287 DPRINTK("br2684_get_stats\n");
288 return &BRPRIV(dev)->stats;
291 #ifdef FASTER_VERSION
293 * These mirror eth_header and eth_header_cache. They are not usually
294 * exported for use in modules, so we grab them from net_device
295 * after ether_setup() is done with it. Bit of a hack.
297 static int (*my_eth_header)(struct sk_buff *, struct net_device *,
298 unsigned short, void *, void *, unsigned);
299 static int (*my_eth_header_cache)(struct neighbour *, struct hh_cache *);
302 br2684_header(struct sk_buff *skb, struct net_device *dev,
303 unsigned short type, void *daddr, void *saddr, unsigned len)
306 int t = my_eth_header(skb, dev, type, daddr, saddr, len);
308 pad_before_eth = (u16 *) skb_push(skb, 2);
310 return dev->hard_header_len; /* or return 16; ? */
316 br2684_header_cache(struct neighbour *neigh, struct hh_cache *hh)
318 /* hh_data is 16 bytes long. if encaps is ether-llc we need 24, so
319 xmit will add the additional header part in that case */
320 u16 *pad_before_eth = (u16 *)(hh->hh_data);
321 int t = my_eth_header_cache(neigh, hh);
322 DPRINTK("br2684_header_cache, neigh=%p, hh_cache=%p\n", neigh, hh);
327 hh->hh_len = PADLEN + ETH_HLEN;
333 * This is similar to eth_type_trans, which cannot be used because of
334 * our dev->hard_header_len
336 static inline unsigned short br_type_trans(struct sk_buff *skb,
337 struct net_device *dev)
341 eth = skb->mac.ethernet;
343 if (*eth->h_dest & 1) {
344 if (memcmp(eth->h_dest, dev->broadcast, ETH_ALEN) == 0)
345 skb->pkt_type = PACKET_BROADCAST;
347 skb->pkt_type = PACKET_MULTICAST;
350 else if (memcmp(eth->h_dest, dev->dev_addr, ETH_ALEN))
351 skb->pkt_type = PACKET_OTHERHOST;
353 if (ntohs(eth->h_proto) >= 1536)
359 * This is a magic hack to spot IPX packets. Older Novell breaks
360 * the protocol design and runs IPX over 802.3 without an 802.2 LLC
361 * layer. We look for FFFF which isn't a used 802.2 SSAP/DSAP. This
362 * won't work for fault tolerant netware but does for the rest.
364 if (*(unsigned short *) rawp == 0xFFFF)
365 return htons(ETH_P_802_3);
370 return htons(ETH_P_802_2);
372 #endif /* FASTER_VERSION */
375 * We remember when the MAC gets set, so we don't override it later with
376 * the ESI of the ATM card of the first VC
378 static int (*my_eth_mac_addr)(struct net_device *, void *);
379 static int br2684_mac_addr(struct net_device *dev, void *p)
381 int err = my_eth_mac_addr(dev, p);
383 BRPRIV(dev)->mac_was_set = 1;
387 #ifdef CONFIG_ATM_BR2684_IPFILTER
388 /* this IOCTL is experimental. */
389 static int br2684_setfilt(struct atm_vcc *atmvcc, void __user *arg)
391 struct br2684_vcc *brvcc;
392 struct br2684_filter_set fs;
394 if (copy_from_user(&fs, arg, sizeof fs))
396 if (fs.ifspec.method != BR2684_FIND_BYNOTHING) {
398 * This is really a per-vcc thing, but we can also search
401 struct br2684_dev *brdev;
402 read_lock(&devs_lock);
403 brdev = BRPRIV(br2684_find_dev(&fs.ifspec));
404 if (brdev == NULL || list_empty(&brdev->brvccs) ||
405 brdev->brvccs.next != brdev->brvccs.prev) /* >1 VCC */
408 brvcc = list_entry_brvcc(brdev->brvccs.next);
409 read_unlock(&devs_lock);
413 brvcc = BR2684_VCC(atmvcc);
414 memcpy(&brvcc->filter, &fs.filter, sizeof(brvcc->filter));
418 /* Returns 1 if packet should be dropped */
420 packet_fails_filter(u16 type, struct br2684_vcc *brvcc, struct sk_buff *skb)
422 if (brvcc->filter.netmask == 0)
423 return 0; /* no filter in place */
424 if (type == __constant_htons(ETH_P_IP) &&
425 (((struct iphdr *) (skb->data))->daddr & brvcc->filter.
426 netmask) == brvcc->filter.prefix)
428 if (type == __constant_htons(ETH_P_ARP))
430 /* TODO: we should probably filter ARPs too.. don't want to have
431 * them returning values that don't make sense, or is that ok?
435 #endif /* CONFIG_ATM_BR2684_IPFILTER */
437 static void br2684_close_vcc(struct br2684_vcc *brvcc)
439 DPRINTK("removing VCC %p from dev %p\n", brvcc, brvcc->device);
440 write_lock_irq(&devs_lock);
441 list_del(&brvcc->brvccs);
442 write_unlock_irq(&devs_lock);
443 brvcc->atmvcc->user_back = NULL; /* what about vcc->recvq ??? */
444 brvcc->old_push(brvcc->atmvcc, NULL); /* pass on the bad news */
446 module_put(THIS_MODULE);
449 /* when AAL5 PDU comes in: */
450 static void br2684_push(struct atm_vcc *atmvcc, struct sk_buff *skb)
452 struct br2684_vcc *brvcc = BR2684_VCC(atmvcc);
453 struct net_device *net_dev = brvcc->device;
454 struct br2684_dev *brdev = BRPRIV(net_dev);
455 int plen = sizeof(llc_oui_pid_pad) + ETH_HLEN;
457 DPRINTK("br2684_push\n");
459 if (unlikely(skb == NULL)) {
460 /* skb==NULL means VCC is being destroyed */
461 br2684_close_vcc(brvcc);
462 if (list_empty(&brdev->brvccs)) {
463 read_lock(&devs_lock);
464 list_del(&brdev->br2684_devs);
465 read_unlock(&devs_lock);
466 unregister_netdev(net_dev);
467 free_netdev(net_dev);
471 #if defined(CONFIG_MIPS_BRCM)
472 //skb->__unused=FROM_WAN;
476 atm_return(atmvcc, skb->truesize);
477 DPRINTK("skb from brdev %p\n", brdev);
478 if (brvcc->encaps == e_llc) {
479 /* let us waste some time for checking the encapsulation.
480 Note, that only 7 char is checked so frames with a valid FCS
481 are also accepted (but FCS is not checked of course) */
482 if (memcmp(skb->data, llc_oui_pid_pad, 7)) {
483 brdev->stats.rx_errors++;
488 /* Strip FCS if present */
489 if (skb->len > 7 && skb->data[7] == 0x01)
490 __skb_trim(skb, skb->len - 4);
492 plen = PADLEN + ETH_HLEN; /* pad, dstmac,srcmac, ethtype */
493 /* first 2 chars should be 0 */
494 if (*((u16 *) (skb->data)) != 0) {
495 brdev->stats.rx_errors++;
500 if (skb->len < plen) {
501 brdev->stats.rx_errors++;
502 dev_kfree_skb(skb); /* dev_ not needed? */
506 #ifdef FASTER_VERSION
507 /* FIXME: tcpdump shows that pointer to mac header is 2 bytes earlier,
508 than should be. What else should I set? */
510 skb->mac.raw = ((char *) (skb->data)) - ETH_HLEN;
511 skb->pkt_type = PACKET_HOST;
512 #ifdef CONFIG_BR2684_FAST_TRANS
513 skb->protocol = ((u16 *) skb->data)[-1];
514 #else /* some protocols might require this: */
515 skb->protocol = br_type_trans(skb, net_dev);
516 #endif /* CONFIG_BR2684_FAST_TRANS */
518 skb_pull(skb, plen - ETH_HLEN);
519 skb->protocol = eth_type_trans(skb, net_dev);
520 #endif /* FASTER_VERSION */
521 #ifdef CONFIG_ATM_BR2684_IPFILTER
522 if (unlikely(packet_fails_filter(skb->protocol, brvcc, skb))) {
523 brdev->stats.rx_dropped++;
527 #endif /* CONFIG_ATM_BR2684_IPFILTER */
528 #if defined(CONFIG_MIPS_BRCM)
529 if (brvcc->proto_filter & FILTER_PPPOE) {
530 if ((skb->protocol != htons(ETH_P_PPP_DISC)) && (skb->protocol != htons(ETH_P_PPP_SES))) {
531 DPRINTK("non-PPPOE packet dropped on RX dev %s\n", net_dev->name);
532 brdev->stats.rx_dropped++;
539 ATM_SKB(skb)->vcc = atmvcc; /* needed ? */
540 DPRINTK("received packet's protocol: %x\n", ntohs(skb->protocol));
542 if (unlikely(!(net_dev->flags & IFF_UP))) {
543 /* sigh, interface is down */
544 brdev->stats.rx_dropped++;
548 brdev->stats.rx_packets++;
549 brdev->stats.rx_bytes += skb->len;
550 memset(ATM_SKB(skb), 0, sizeof(struct atm_skb_data));
554 static int br2684_regvcc(struct atm_vcc *atmvcc, void __user *arg)
556 /* assign a vcc to a dev
557 Note: we do not have explicit unassign, but look at _push()
560 struct br2684_vcc *brvcc;
561 struct sk_buff_head copy;
563 struct br2684_dev *brdev;
564 struct net_device *net_dev;
565 struct atm_backend_br2684 be;
567 if (copy_from_user(&be, arg, sizeof be))
569 brvcc = kmalloc(sizeof(struct br2684_vcc), GFP_KERNEL);
572 memset(brvcc, 0, sizeof(struct br2684_vcc));
573 write_lock_irq(&devs_lock);
574 net_dev = br2684_find_dev(&be.ifspec);
575 if (net_dev == NULL) {
577 "br2684: tried to attach to non-existant device\n");
581 brdev = BRPRIV(net_dev);
582 if (atmvcc->push == NULL) {
586 if (!list_empty(&brdev->brvccs)) {
587 /* Only 1 VCC/dev right now */
591 if (be.fcs_in != BR2684_FCSIN_NO || be.fcs_out != BR2684_FCSOUT_NO ||
592 be.fcs_auto || be.has_vpiid || be.send_padding || (be.encaps !=
593 BR2684_ENCAPS_VC && be.encaps != BR2684_ENCAPS_LLC) ||
598 DPRINTK("br2684_regvcc vcc=%p, encaps=%d, brvcc=%p\n", atmvcc, be.encaps,
600 if (list_empty(&brdev->brvccs) && !brdev->mac_was_set) {
601 unsigned char *esi = atmvcc->dev->esi;
602 if (esi[0] | esi[1] | esi[2] | esi[3] | esi[4] | esi[5])
603 memcpy(net_dev->dev_addr, esi, net_dev->addr_len);
605 net_dev->dev_addr[2] = 1;
607 list_add(&brvcc->brvccs, &brdev->brvccs);
608 write_unlock_irq(&devs_lock);
609 brvcc->device = net_dev;
610 brvcc->atmvcc = atmvcc;
611 atmvcc->user_back = brvcc;
612 brvcc->encaps = (enum br2684_encaps) be.encaps;
613 brvcc->old_push = atmvcc->push;
614 #if defined(CONFIG_MIPS_BRCM)
615 brvcc->proto_filter |= be.proto_filter;
618 atmvcc->push = br2684_push;
619 skb_queue_head_init(©);
620 skb_migrate(&atmvcc->sk->sk_receive_queue, ©);
621 while ((skb = skb_dequeue(©)) != NULL) {
622 BRPRIV(skb->dev)->stats.rx_bytes -= skb->len;
623 BRPRIV(skb->dev)->stats.rx_packets--;
624 br2684_push(atmvcc, skb);
626 __module_get(THIS_MODULE);
629 write_unlock_irq(&devs_lock);
634 static void br2684_setup(struct net_device *netdev)
636 struct br2684_dev *brdev = BRPRIV(netdev);
639 brdev->net_dev = netdev;
641 #ifdef FASTER_VERSION
642 my_eth_header = netdev->hard_header;
643 netdev->hard_header = br2684_header;
644 my_eth_header_cache = netdev->hard_header_cache;
645 netdev->hard_header_cache = br2684_header_cache;
646 netdev->hard_header_len = sizeof(llc_oui_pid_pad) + ETH_HLEN; /* 10 + 14 */
648 my_eth_mac_addr = netdev->set_mac_address;
649 netdev->set_mac_address = br2684_mac_addr;
650 netdev->hard_start_xmit = br2684_start_xmit;
651 netdev->get_stats = br2684_get_stats;
653 INIT_LIST_HEAD(&brdev->brvccs);
656 static int br2684_create(void __user *arg)
659 struct net_device *netdev;
660 struct br2684_dev *brdev;
661 struct atm_newif_br2684 ni;
663 DPRINTK("br2684_create\n");
665 if (copy_from_user(&ni, arg, sizeof ni)) {
668 if (ni.media != BR2684_MEDIA_ETHERNET || ni.mtu != 1500) {
672 netdev = alloc_netdev(sizeof(struct br2684_dev),
673 ni.ifname[0] ? ni.ifname : "nas%d",
678 brdev = BRPRIV(netdev);
680 DPRINTK("registered netdev %s\n", netdev->name);
681 /* open, stop, do_ioctl ? */
682 err = register_netdev(netdev);
684 printk(KERN_ERR "br2684_create: register_netdev failed\n");
689 write_lock_irq(&devs_lock);
690 brdev->number = list_empty(&br2684_devs) ? 1 :
691 BRPRIV(list_entry_brdev(br2684_devs.prev))->number + 1;
692 list_add_tail(&brdev->br2684_devs, &br2684_devs);
693 write_unlock_irq(&devs_lock);
698 * This handles ioctls actually performed on our vcc - we must return
699 * -ENOIOCTLCMD for any unrecognized ioctl
701 static int br2684_ioctl(struct socket *sock, unsigned int cmd,
704 struct atm_vcc *atmvcc = ATM_SD(sock);
705 void __user *argp = (void __user *)arg;
710 case ATM_NEWBACKENDIF: {
712 err = get_user(b, (atm_backend_t __user *) argp);
715 if (b != ATM_BACKEND_BR2684)
717 if (!capable(CAP_NET_ADMIN))
719 if (cmd == ATM_SETBACKEND)
720 return br2684_regvcc(atmvcc, argp);
722 return br2684_create(argp);
724 #ifdef CONFIG_ATM_BR2684_IPFILTER
726 if (atmvcc->push != br2684_push)
728 if (!capable(CAP_NET_ADMIN))
730 err = br2684_setfilt(atmvcc, argp);
732 #endif /* CONFIG_ATM_BR2684_IPFILTER */
737 static struct atm_ioctl br2684_ioctl_ops = {
738 .owner = THIS_MODULE,
739 .ioctl = br2684_ioctl,
743 #ifdef CONFIG_PROC_FS
744 static void *br2684_seq_start(struct seq_file *seq, loff_t *pos)
747 struct br2684_dev *brd;
749 read_lock(&devs_lock);
751 list_for_each_entry(brd, &br2684_devs, br2684_devs) {
759 static void *br2684_seq_next(struct seq_file *seq, void *v, loff_t *pos)
761 struct br2684_dev *brd = v;
765 brd = list_entry(brd->br2684_devs.next,
766 struct br2684_dev, br2684_devs);
767 return (&brd->br2684_devs != &br2684_devs) ? brd : NULL;
770 static void br2684_seq_stop(struct seq_file *seq, void *v)
772 read_unlock(&devs_lock);
775 static int br2684_seq_show(struct seq_file *seq, void *v)
777 const struct br2684_dev *brdev = v;
778 const struct net_device *net_dev = brdev->net_dev;
779 const struct br2684_vcc *brvcc;
781 seq_printf(seq, "dev %.16s: num=%d, mac=%02X:%02X:"
782 "%02X:%02X:%02X:%02X (%s)\n", net_dev->name,
784 net_dev->dev_addr[0],
785 net_dev->dev_addr[1],
786 net_dev->dev_addr[2],
787 net_dev->dev_addr[3],
788 net_dev->dev_addr[4],
789 net_dev->dev_addr[5],
790 brdev->mac_was_set ? "set" : "auto");
792 list_for_each_entry(brvcc, &brdev->brvccs, brvccs) {
793 seq_printf(seq, " vcc %d.%d.%d: encaps=%s"
794 #ifndef FASTER_VERSION
795 ", failed copies %u/%u"
796 #endif /* FASTER_VERSION */
797 "\n", brvcc->atmvcc->dev->number,
798 brvcc->atmvcc->vpi, brvcc->atmvcc->vci,
799 (brvcc->encaps == e_llc) ? "LLC" : "VC"
800 #ifndef FASTER_VERSION
801 , brvcc->copies_failed
802 , brvcc->copies_needed
803 #endif /* FASTER_VERSION */
805 #ifdef CONFIG_ATM_BR2684_IPFILTER
806 #define b1(var, byte) ((u8 *) &brvcc->filter.var)[byte]
807 #define bs(var) b1(var, 0), b1(var, 1), b1(var, 2), b1(var, 3)
808 if (brvcc->filter.netmask != 0)
809 seq_printf(seq, " filter=%d.%d.%d.%d/"
811 bs(prefix), bs(netmask));
814 #endif /* CONFIG_ATM_BR2684_IPFILTER */
819 static struct seq_operations br2684_seq_ops = {
820 .start = br2684_seq_start,
821 .next = br2684_seq_next,
822 .stop = br2684_seq_stop,
823 .show = br2684_seq_show,
826 static int br2684_proc_open(struct inode *inode, struct file *file)
828 return seq_open(file, &br2684_seq_ops);
831 static struct file_operations br2684_proc_ops = {
832 .owner = THIS_MODULE,
833 .open = br2684_proc_open,
836 .release = seq_release,
839 extern struct proc_dir_entry *atm_proc_root; /* from proc.c */
842 static int __init br2684_init(void)
844 #ifdef CONFIG_PROC_FS
845 struct proc_dir_entry *p;
846 if ((p = create_proc_entry("br2684", 0, atm_proc_root)) == NULL)
848 p->proc_fops = &br2684_proc_ops;
850 register_atm_ioctl(&br2684_ioctl_ops);
854 static void __exit br2684_exit(void)
856 struct net_device *net_dev;
857 struct br2684_dev *brdev;
858 struct br2684_vcc *brvcc;
859 deregister_atm_ioctl(&br2684_ioctl_ops);
861 #ifdef CONFIG_PROC_FS
862 remove_proc_entry("br2684", atm_proc_root);
865 while (!list_empty(&br2684_devs)) {
866 net_dev = list_entry_brdev(br2684_devs.next);
867 brdev = BRPRIV(net_dev);
868 while (!list_empty(&brdev->brvccs)) {
869 brvcc = list_entry_brvcc(brdev->brvccs.next);
870 br2684_close_vcc(brvcc);
873 list_del(&brdev->br2684_devs);
874 unregister_netdev(net_dev);
875 free_netdev(net_dev);
879 module_init(br2684_init);
880 module_exit(br2684_exit);
882 MODULE_AUTHOR("Marcell GAL");
883 MODULE_DESCRIPTION("RFC2684 bridged protocols over ATM/AAL5");
884 MODULE_LICENSE("GPL");