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>
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 */
85 struct net_device
*net_dev
;
86 struct list_head br2684_devs
;
88 struct list_head brvccs
; /* one device <=> one vcc (before xmas) */
89 struct net_device_stats stats
;
94 * This lock should be held for writing any time the list of devices or
95 * their attached vcc's could be altered. It should be held for reading
96 * any time these are being queried. Note that we sometimes need to
97 * do read-locking under interrupt context, so write locking must block
98 * the current CPU's interrupts
100 static DEFINE_RWLOCK(devs_lock
);
102 static LIST_HEAD(br2684_devs
);
104 static inline struct br2684_dev
*BRPRIV(const struct net_device
*net_dev
)
106 return (struct br2684_dev
*) net_dev
->priv
;
109 static inline struct net_device
*list_entry_brdev(const struct list_head
*le
)
111 return list_entry(le
, struct br2684_dev
, br2684_devs
)->net_dev
;
114 static inline struct br2684_vcc
*BR2684_VCC(const struct atm_vcc
*atmvcc
)
116 return (struct br2684_vcc
*) (atmvcc
->user_back
);
119 static inline struct br2684_vcc
*list_entry_brvcc(const struct list_head
*le
)
121 return list_entry(le
, struct br2684_vcc
, brvccs
);
124 /* Caller should hold read_lock(&devs_lock) */
125 static struct net_device
*br2684_find_dev(const struct br2684_if_spec
*s
)
127 struct list_head
*lh
;
128 struct net_device
*net_dev
;
130 case BR2684_FIND_BYNUM
:
131 list_for_each(lh
, &br2684_devs
) {
132 net_dev
= list_entry_brdev(lh
);
133 if (BRPRIV(net_dev
)->number
== s
->spec
.devnum
)
137 case BR2684_FIND_BYIFNAME
:
138 list_for_each(lh
, &br2684_devs
) {
139 net_dev
= list_entry_brdev(lh
);
140 if (!strncmp(net_dev
->name
, s
->spec
.ifname
, IFNAMSIZ
))
149 * Send a packet out a particular vcc. Not to useful right now, but paves
150 * the way for multiple vcc's per itf. Returns true if we can send,
153 static int br2684_xmit_vcc(struct sk_buff
*skb
, struct br2684_dev
*brdev
,
154 struct br2684_vcc
*brvcc
)
156 struct atm_vcc
*atmvcc
;
157 #ifdef FASTER_VERSION
158 if (brvcc
->encaps
== e_llc
)
159 memcpy(skb_push(skb
, 8), llc_oui_pid_pad
, 8);
160 /* last 2 bytes of llc_oui_pid_pad are managed by header routines;
161 yes, you got it: 8 + 2 = sizeof(llc_oui_pid_pad)
164 int minheadroom
= (brvcc
->encaps
== e_llc
) ? 10 : 2;
165 if (skb_headroom(skb
) < minheadroom
) {
166 struct sk_buff
*skb2
= skb_realloc_headroom(skb
, minheadroom
);
167 brvcc
->copies_needed
++;
170 brvcc
->copies_failed
++;
175 skb_push(skb
, minheadroom
);
176 if (brvcc
->encaps
== e_llc
)
177 memcpy(skb
->data
, llc_oui_pid_pad
, 10);
179 memset(skb
->data
, 0, 2);
180 #endif /* FASTER_VERSION */
183 ATM_SKB(skb
)->vcc
= atmvcc
= brvcc
->atmvcc
;
184 DPRINTK("atm_skb(%p)->vcc(%p)->dev(%p)\n", skb
, atmvcc
, atmvcc
->dev
);
185 if (!atm_may_send(atmvcc
, skb
->truesize
)) {
186 /* we free this here for now, because we cannot know in a higher
187 layer whether the skb point it supplied wasn't freed yet.
193 atomic_add(skb
->truesize
, &sk_atm(atmvcc
)->sk_wmem_alloc
);
194 ATM_SKB(skb
)->atm_options
= atmvcc
->atm_options
;
195 brdev
->stats
.tx_packets
++;
196 brdev
->stats
.tx_bytes
+= skb
->len
;
197 atmvcc
->send(atmvcc
, skb
);
201 static inline struct br2684_vcc
*pick_outgoing_vcc(struct sk_buff
*skb
,
202 struct br2684_dev
*brdev
)
204 return list_empty(&brdev
->brvccs
) ? NULL
:
205 list_entry_brvcc(brdev
->brvccs
.next
); /* 1 vcc/dev right now */
208 static int br2684_start_xmit(struct sk_buff
*skb
, struct net_device
*dev
)
210 struct br2684_dev
*brdev
= BRPRIV(dev
);
211 struct br2684_vcc
*brvcc
;
213 DPRINTK("br2684_start_xmit, skb->dst=%p\n", skb
->dst
);
214 read_lock(&devs_lock
);
215 brvcc
= pick_outgoing_vcc(skb
, brdev
);
217 DPRINTK("no vcc attached to dev %s\n", dev
->name
);
218 brdev
->stats
.tx_errors
++;
219 brdev
->stats
.tx_carrier_errors
++;
220 /* netif_stop_queue(dev); */
222 read_unlock(&devs_lock
);
225 if (!br2684_xmit_vcc(skb
, brdev
, brvcc
)) {
227 * We should probably use netif_*_queue() here, but that
228 * involves added complication. We need to walk before
231 /* don't free here! this pointer might be no longer valid!
234 brdev
->stats
.tx_errors
++;
235 brdev
->stats
.tx_fifo_errors
++;
237 read_unlock(&devs_lock
);
241 static struct net_device_stats
*br2684_get_stats(struct net_device
*dev
)
243 DPRINTK("br2684_get_stats\n");
244 return &BRPRIV(dev
)->stats
;
247 #ifdef FASTER_VERSION
249 * These mirror eth_header and eth_header_cache. They are not usually
250 * exported for use in modules, so we grab them from net_device
251 * after ether_setup() is done with it. Bit of a hack.
253 static int (*my_eth_header
)(struct sk_buff
*, struct net_device
*,
254 unsigned short, void *, void *, unsigned);
255 static int (*my_eth_header_cache
)(struct neighbour
*, struct hh_cache
*);
258 br2684_header(struct sk_buff
*skb
, struct net_device
*dev
,
259 unsigned short type
, void *daddr
, void *saddr
, unsigned len
)
262 int t
= my_eth_header(skb
, dev
, type
, daddr
, saddr
, len
);
264 pad_before_eth
= (u16
*) skb_push(skb
, 2);
266 return dev
->hard_header_len
; /* or return 16; ? */
272 br2684_header_cache(struct neighbour
*neigh
, struct hh_cache
*hh
)
274 /* hh_data is 16 bytes long. if encaps is ether-llc we need 24, so
275 xmit will add the additional header part in that case */
276 u16
*pad_before_eth
= (u16
*)(hh
->hh_data
);
277 int t
= my_eth_header_cache(neigh
, hh
);
278 DPRINTK("br2684_header_cache, neigh=%p, hh_cache=%p\n", neigh
, hh
);
283 hh
->hh_len
= PADLEN
+ ETH_HLEN
;
289 * This is similar to eth_type_trans, which cannot be used because of
290 * our dev->hard_header_len
292 static inline __be16
br_type_trans(struct sk_buff
*skb
, struct net_device
*dev
)
298 if (is_multicast_ether_addr(eth
->h_dest
)) {
299 if (!compare_ether_addr(eth
->h_dest
, dev
->broadcast
))
300 skb
->pkt_type
= PACKET_BROADCAST
;
302 skb
->pkt_type
= PACKET_MULTICAST
;
305 else if (compare_ether_addr(eth
->h_dest
, dev
->dev_addr
))
306 skb
->pkt_type
= PACKET_OTHERHOST
;
308 if (ntohs(eth
->h_proto
) >= 1536)
314 * This is a magic hack to spot IPX packets. Older Novell breaks
315 * the protocol design and runs IPX over 802.3 without an 802.2 LLC
316 * layer. We look for FFFF which isn't a used 802.2 SSAP/DSAP. This
317 * won't work for fault tolerant netware but does for the rest.
319 if (*(unsigned short *) rawp
== 0xFFFF)
320 return htons(ETH_P_802_3
);
325 return htons(ETH_P_802_2
);
327 #endif /* FASTER_VERSION */
330 * We remember when the MAC gets set, so we don't override it later with
331 * the ESI of the ATM card of the first VC
333 static int (*my_eth_mac_addr
)(struct net_device
*, void *);
334 static int br2684_mac_addr(struct net_device
*dev
, void *p
)
336 int err
= my_eth_mac_addr(dev
, p
);
338 BRPRIV(dev
)->mac_was_set
= 1;
342 #ifdef CONFIG_ATM_BR2684_IPFILTER
343 /* this IOCTL is experimental. */
344 static int br2684_setfilt(struct atm_vcc
*atmvcc
, void __user
*arg
)
346 struct br2684_vcc
*brvcc
;
347 struct br2684_filter_set fs
;
349 if (copy_from_user(&fs
, arg
, sizeof fs
))
351 if (fs
.ifspec
.method
!= BR2684_FIND_BYNOTHING
) {
353 * This is really a per-vcc thing, but we can also search
356 struct br2684_dev
*brdev
;
357 read_lock(&devs_lock
);
358 brdev
= BRPRIV(br2684_find_dev(&fs
.ifspec
));
359 if (brdev
== NULL
|| list_empty(&brdev
->brvccs
) ||
360 brdev
->brvccs
.next
!= brdev
->brvccs
.prev
) /* >1 VCC */
363 brvcc
= list_entry_brvcc(brdev
->brvccs
.next
);
364 read_unlock(&devs_lock
);
368 brvcc
= BR2684_VCC(atmvcc
);
369 memcpy(&brvcc
->filter
, &fs
.filter
, sizeof(brvcc
->filter
));
373 /* Returns 1 if packet should be dropped */
375 packet_fails_filter(u16 type
, struct br2684_vcc
*brvcc
, struct sk_buff
*skb
)
377 if (brvcc
->filter
.netmask
== 0)
378 return 0; /* no filter in place */
379 if (type
== __constant_htons(ETH_P_IP
) &&
380 (((struct iphdr
*) (skb
->data
))->daddr
& brvcc
->filter
.
381 netmask
) == brvcc
->filter
.prefix
)
383 if (type
== __constant_htons(ETH_P_ARP
))
385 /* TODO: we should probably filter ARPs too.. don't want to have
386 * them returning values that don't make sense, or is that ok?
390 #endif /* CONFIG_ATM_BR2684_IPFILTER */
392 static void br2684_close_vcc(struct br2684_vcc
*brvcc
)
394 DPRINTK("removing VCC %p from dev %p\n", brvcc
, brvcc
->device
);
395 write_lock_irq(&devs_lock
);
396 list_del(&brvcc
->brvccs
);
397 write_unlock_irq(&devs_lock
);
398 brvcc
->atmvcc
->user_back
= NULL
; /* what about vcc->recvq ??? */
399 brvcc
->old_push(brvcc
->atmvcc
, NULL
); /* pass on the bad news */
401 module_put(THIS_MODULE
);
404 /* when AAL5 PDU comes in: */
405 static void br2684_push(struct atm_vcc
*atmvcc
, struct sk_buff
*skb
)
407 struct br2684_vcc
*brvcc
= BR2684_VCC(atmvcc
);
408 struct net_device
*net_dev
= brvcc
->device
;
409 struct br2684_dev
*brdev
= BRPRIV(net_dev
);
410 int plen
= sizeof(llc_oui_pid_pad
) + ETH_HLEN
;
412 DPRINTK("br2684_push\n");
414 if (unlikely(skb
== NULL
)) {
415 /* skb==NULL means VCC is being destroyed */
416 br2684_close_vcc(brvcc
);
417 if (list_empty(&brdev
->brvccs
)) {
418 read_lock(&devs_lock
);
419 list_del(&brdev
->br2684_devs
);
420 read_unlock(&devs_lock
);
421 unregister_netdev(net_dev
);
422 free_netdev(net_dev
);
428 atm_return(atmvcc
, skb
->truesize
);
429 DPRINTK("skb from brdev %p\n", brdev
);
430 if (brvcc
->encaps
== e_llc
) {
431 /* let us waste some time for checking the encapsulation.
432 Note, that only 7 char is checked so frames with a valid FCS
433 are also accepted (but FCS is not checked of course) */
434 if (memcmp(skb
->data
, llc_oui_pid_pad
, 7)) {
435 brdev
->stats
.rx_errors
++;
440 /* Strip FCS if present */
441 if (skb
->len
> 7 && skb
->data
[7] == 0x01)
442 __skb_trim(skb
, skb
->len
- 4);
444 plen
= PADLEN
+ ETH_HLEN
; /* pad, dstmac,srcmac, ethtype */
445 /* first 2 chars should be 0 */
446 if (*((u16
*) (skb
->data
)) != 0) {
447 brdev
->stats
.rx_errors
++;
452 if (skb
->len
< plen
) {
453 brdev
->stats
.rx_errors
++;
454 dev_kfree_skb(skb
); /* dev_ not needed? */
458 #ifdef FASTER_VERSION
459 /* FIXME: tcpdump shows that pointer to mac header is 2 bytes earlier,
460 than should be. What else should I set? */
462 skb
->mac
.raw
= ((char *) (skb
->data
)) - ETH_HLEN
;
463 skb
->pkt_type
= PACKET_HOST
;
464 #ifdef CONFIG_BR2684_FAST_TRANS
465 skb
->protocol
= ((u16
*) skb
->data
)[-1];
466 #else /* some protocols might require this: */
467 skb
->protocol
= br_type_trans(skb
, net_dev
);
468 #endif /* CONFIG_BR2684_FAST_TRANS */
470 skb_pull(skb
, plen
- ETH_HLEN
);
471 skb
->protocol
= eth_type_trans(skb
, net_dev
);
472 #endif /* FASTER_VERSION */
473 #ifdef CONFIG_ATM_BR2684_IPFILTER
474 if (unlikely(packet_fails_filter(skb
->protocol
, brvcc
, skb
))) {
475 brdev
->stats
.rx_dropped
++;
479 #endif /* CONFIG_ATM_BR2684_IPFILTER */
481 ATM_SKB(skb
)->vcc
= atmvcc
; /* needed ? */
482 DPRINTK("received packet's protocol: %x\n", ntohs(skb
->protocol
));
484 if (unlikely(!(net_dev
->flags
& IFF_UP
))) {
485 /* sigh, interface is down */
486 brdev
->stats
.rx_dropped
++;
490 brdev
->stats
.rx_packets
++;
491 brdev
->stats
.rx_bytes
+= skb
->len
;
492 memset(ATM_SKB(skb
), 0, sizeof(struct atm_skb_data
));
496 static int br2684_regvcc(struct atm_vcc
*atmvcc
, void __user
*arg
)
498 /* assign a vcc to a dev
499 Note: we do not have explicit unassign, but look at _push()
502 struct br2684_vcc
*brvcc
;
503 struct sk_buff_head copy
;
505 struct br2684_dev
*brdev
;
506 struct net_device
*net_dev
;
507 struct atm_backend_br2684 be
;
509 if (copy_from_user(&be
, arg
, sizeof be
))
511 brvcc
= kzalloc(sizeof(struct br2684_vcc
), GFP_KERNEL
);
514 write_lock_irq(&devs_lock
);
515 net_dev
= br2684_find_dev(&be
.ifspec
);
516 if (net_dev
== NULL
) {
518 "br2684: tried to attach to non-existant device\n");
522 brdev
= BRPRIV(net_dev
);
523 if (atmvcc
->push
== NULL
) {
527 if (!list_empty(&brdev
->brvccs
)) {
528 /* Only 1 VCC/dev right now */
532 if (be
.fcs_in
!= BR2684_FCSIN_NO
|| be
.fcs_out
!= BR2684_FCSOUT_NO
||
533 be
.fcs_auto
|| be
.has_vpiid
|| be
.send_padding
|| (be
.encaps
!=
534 BR2684_ENCAPS_VC
&& be
.encaps
!= BR2684_ENCAPS_LLC
) ||
539 DPRINTK("br2684_regvcc vcc=%p, encaps=%d, brvcc=%p\n", atmvcc
, be
.encaps
,
541 if (list_empty(&brdev
->brvccs
) && !brdev
->mac_was_set
) {
542 unsigned char *esi
= atmvcc
->dev
->esi
;
543 if (esi
[0] | esi
[1] | esi
[2] | esi
[3] | esi
[4] | esi
[5])
544 memcpy(net_dev
->dev_addr
, esi
, net_dev
->addr_len
);
546 net_dev
->dev_addr
[2] = 1;
548 list_add(&brvcc
->brvccs
, &brdev
->brvccs
);
549 write_unlock_irq(&devs_lock
);
550 brvcc
->device
= net_dev
;
551 brvcc
->atmvcc
= atmvcc
;
552 atmvcc
->user_back
= brvcc
;
553 brvcc
->encaps
= (enum br2684_encaps
) be
.encaps
;
554 brvcc
->old_push
= atmvcc
->push
;
556 atmvcc
->push
= br2684_push
;
557 skb_queue_head_init(©
);
558 skb_migrate(&sk_atm(atmvcc
)->sk_receive_queue
, ©
);
559 while ((skb
= skb_dequeue(©
)) != NULL
) {
560 BRPRIV(skb
->dev
)->stats
.rx_bytes
-= skb
->len
;
561 BRPRIV(skb
->dev
)->stats
.rx_packets
--;
562 br2684_push(atmvcc
, skb
);
564 __module_get(THIS_MODULE
);
567 write_unlock_irq(&devs_lock
);
572 static void br2684_setup(struct net_device
*netdev
)
574 struct br2684_dev
*brdev
= BRPRIV(netdev
);
577 brdev
->net_dev
= netdev
;
579 #ifdef FASTER_VERSION
580 my_eth_header
= netdev
->hard_header
;
581 netdev
->hard_header
= br2684_header
;
582 my_eth_header_cache
= netdev
->hard_header_cache
;
583 netdev
->hard_header_cache
= br2684_header_cache
;
584 netdev
->hard_header_len
= sizeof(llc_oui_pid_pad
) + ETH_HLEN
; /* 10 + 14 */
586 my_eth_mac_addr
= netdev
->set_mac_address
;
587 netdev
->set_mac_address
= br2684_mac_addr
;
588 netdev
->hard_start_xmit
= br2684_start_xmit
;
589 netdev
->get_stats
= br2684_get_stats
;
591 INIT_LIST_HEAD(&brdev
->brvccs
);
594 static int br2684_create(void __user
*arg
)
597 struct net_device
*netdev
;
598 struct br2684_dev
*brdev
;
599 struct atm_newif_br2684 ni
;
601 DPRINTK("br2684_create\n");
603 if (copy_from_user(&ni
, arg
, sizeof ni
)) {
606 if (ni
.media
!= BR2684_MEDIA_ETHERNET
|| ni
.mtu
!= 1500) {
610 netdev
= alloc_netdev(sizeof(struct br2684_dev
),
611 ni
.ifname
[0] ? ni
.ifname
: "nas%d",
616 brdev
= BRPRIV(netdev
);
618 DPRINTK("registered netdev %s\n", netdev
->name
);
619 /* open, stop, do_ioctl ? */
620 err
= register_netdev(netdev
);
622 printk(KERN_ERR
"br2684_create: register_netdev failed\n");
627 write_lock_irq(&devs_lock
);
628 brdev
->number
= list_empty(&br2684_devs
) ? 1 :
629 BRPRIV(list_entry_brdev(br2684_devs
.prev
))->number
+ 1;
630 list_add_tail(&brdev
->br2684_devs
, &br2684_devs
);
631 write_unlock_irq(&devs_lock
);
636 * This handles ioctls actually performed on our vcc - we must return
637 * -ENOIOCTLCMD for any unrecognized ioctl
639 static int br2684_ioctl(struct socket
*sock
, unsigned int cmd
,
642 struct atm_vcc
*atmvcc
= ATM_SD(sock
);
643 void __user
*argp
= (void __user
*)arg
;
648 case ATM_NEWBACKENDIF
: {
650 err
= get_user(b
, (atm_backend_t __user
*) argp
);
653 if (b
!= ATM_BACKEND_BR2684
)
655 if (!capable(CAP_NET_ADMIN
))
657 if (cmd
== ATM_SETBACKEND
)
658 return br2684_regvcc(atmvcc
, argp
);
660 return br2684_create(argp
);
662 #ifdef CONFIG_ATM_BR2684_IPFILTER
664 if (atmvcc
->push
!= br2684_push
)
666 if (!capable(CAP_NET_ADMIN
))
668 err
= br2684_setfilt(atmvcc
, argp
);
670 #endif /* CONFIG_ATM_BR2684_IPFILTER */
675 static struct atm_ioctl br2684_ioctl_ops
= {
676 .owner
= THIS_MODULE
,
677 .ioctl
= br2684_ioctl
,
681 #ifdef CONFIG_PROC_FS
682 static void *br2684_seq_start(struct seq_file
*seq
, loff_t
*pos
)
685 struct br2684_dev
*brd
;
687 read_lock(&devs_lock
);
689 list_for_each_entry(brd
, &br2684_devs
, br2684_devs
) {
697 static void *br2684_seq_next(struct seq_file
*seq
, void *v
, loff_t
*pos
)
699 struct br2684_dev
*brd
= v
;
703 brd
= list_entry(brd
->br2684_devs
.next
,
704 struct br2684_dev
, br2684_devs
);
705 return (&brd
->br2684_devs
!= &br2684_devs
) ? brd
: NULL
;
708 static void br2684_seq_stop(struct seq_file
*seq
, void *v
)
710 read_unlock(&devs_lock
);
713 static int br2684_seq_show(struct seq_file
*seq
, void *v
)
715 const struct br2684_dev
*brdev
= v
;
716 const struct net_device
*net_dev
= brdev
->net_dev
;
717 const struct br2684_vcc
*brvcc
;
719 seq_printf(seq
, "dev %.16s: num=%d, mac=%02X:%02X:"
720 "%02X:%02X:%02X:%02X (%s)\n", net_dev
->name
,
722 net_dev
->dev_addr
[0],
723 net_dev
->dev_addr
[1],
724 net_dev
->dev_addr
[2],
725 net_dev
->dev_addr
[3],
726 net_dev
->dev_addr
[4],
727 net_dev
->dev_addr
[5],
728 brdev
->mac_was_set
? "set" : "auto");
730 list_for_each_entry(brvcc
, &brdev
->brvccs
, brvccs
) {
731 seq_printf(seq
, " vcc %d.%d.%d: encaps=%s"
732 #ifndef FASTER_VERSION
733 ", failed copies %u/%u"
734 #endif /* FASTER_VERSION */
735 "\n", brvcc
->atmvcc
->dev
->number
,
736 brvcc
->atmvcc
->vpi
, brvcc
->atmvcc
->vci
,
737 (brvcc
->encaps
== e_llc
) ? "LLC" : "VC"
738 #ifndef FASTER_VERSION
739 , brvcc
->copies_failed
740 , brvcc
->copies_needed
741 #endif /* FASTER_VERSION */
743 #ifdef CONFIG_ATM_BR2684_IPFILTER
744 #define b1(var, byte) ((u8 *) &brvcc->filter.var)[byte]
745 #define bs(var) b1(var, 0), b1(var, 1), b1(var, 2), b1(var, 3)
746 if (brvcc
->filter
.netmask
!= 0)
747 seq_printf(seq
, " filter=%d.%d.%d.%d/"
749 bs(prefix
), bs(netmask
));
752 #endif /* CONFIG_ATM_BR2684_IPFILTER */
757 static struct seq_operations br2684_seq_ops
= {
758 .start
= br2684_seq_start
,
759 .next
= br2684_seq_next
,
760 .stop
= br2684_seq_stop
,
761 .show
= br2684_seq_show
,
764 static int br2684_proc_open(struct inode
*inode
, struct file
*file
)
766 return seq_open(file
, &br2684_seq_ops
);
769 static struct file_operations br2684_proc_ops
= {
770 .owner
= THIS_MODULE
,
771 .open
= br2684_proc_open
,
774 .release
= seq_release
,
777 extern struct proc_dir_entry
*atm_proc_root
; /* from proc.c */
780 static int __init
br2684_init(void)
782 #ifdef CONFIG_PROC_FS
783 struct proc_dir_entry
*p
;
784 if ((p
= create_proc_entry("br2684", 0, atm_proc_root
)) == NULL
)
786 p
->proc_fops
= &br2684_proc_ops
;
788 register_atm_ioctl(&br2684_ioctl_ops
);
792 static void __exit
br2684_exit(void)
794 struct net_device
*net_dev
;
795 struct br2684_dev
*brdev
;
796 struct br2684_vcc
*brvcc
;
797 deregister_atm_ioctl(&br2684_ioctl_ops
);
799 #ifdef CONFIG_PROC_FS
800 remove_proc_entry("br2684", atm_proc_root
);
803 while (!list_empty(&br2684_devs
)) {
804 net_dev
= list_entry_brdev(br2684_devs
.next
);
805 brdev
= BRPRIV(net_dev
);
806 while (!list_empty(&brdev
->brvccs
)) {
807 brvcc
= list_entry_brvcc(brdev
->brvccs
.next
);
808 br2684_close_vcc(brvcc
);
811 list_del(&brdev
->br2684_devs
);
812 unregister_netdev(net_dev
);
813 free_netdev(net_dev
);
817 module_init(br2684_init
);
818 module_exit(br2684_exit
);
820 MODULE_AUTHOR("Marcell GAL");
821 MODULE_DESCRIPTION("RFC2684 bridged protocols over ATM/AAL5");
822 MODULE_LICENSE("GPL");