2 * lec.c: Lan Emulation driver
3 * Marko Kiiskila carnil@cs.tut.fi
7 #include <linux/config.h>
8 #include <linux/kernel.h>
9 #include <linux/bitops.h>
11 /* We are ethernet device */
12 #include <linux/if_ether.h>
13 #include <linux/netdevice.h>
14 #include <linux/etherdevice.h>
16 #include <linux/skbuff.h>
18 #include <asm/byteorder.h>
19 #include <asm/uaccess.h>
22 #include <linux/proc_fs.h>
23 #include <linux/spinlock.h>
24 #include <linux/proc_fs.h>
25 #include <linux/seq_file.h>
27 /* TokenRing if needed */
29 #include <linux/trdevice.h>
33 #include <linux/atmdev.h>
34 #include <linux/atmlec.h>
36 /* Proxy LEC knows about bridging */
37 #if defined(CONFIG_BRIDGE) || defined(CONFIG_BRIDGE_MODULE)
38 #include <linux/if_bridge.h>
39 #include "../bridge/br_private.h"
40 static unsigned char bridge_ula_lec[] = {0x01, 0x80, 0xc2, 0x00, 0x00};
42 extern struct net_bridge_fdb_entry *(*br_fdb_get_hook)(struct net_bridge *br,
44 extern void (*br_fdb_put_hook)(struct net_bridge_fdb_entry *ent);
48 #include <linux/module.h>
49 #include <linux/init.h>
53 #include "resources.h"
56 #define DPRINTK printk
58 #define DPRINTK(format,args...)
61 #define DUMP_PACKETS 0 /* 0 = None,
66 #define LEC_UNRES_QUE_LEN 8 /* number of tx packets to queue for a
67 single destination while waiting for SVC */
69 static int lec_open(struct net_device *dev);
70 static int lec_send_packet(struct sk_buff *skb, struct net_device *dev);
71 static int lec_close(struct net_device *dev);
72 static struct net_device_stats *lec_get_stats(struct net_device *dev);
73 static void lec_init(struct net_device *dev);
74 static inline struct lec_arp_table* lec_arp_find(struct lec_priv *priv,
75 unsigned char *mac_addr);
76 static inline int lec_arp_remove(struct lec_priv *priv,
77 struct lec_arp_table *to_remove);
79 static void lane2_associate_ind (struct net_device *dev, u8 *mac_address,
80 u8 *tlvs, u32 sizeoftlvs);
81 static int lane2_resolve(struct net_device *dev, u8 *dst_mac, int force,
82 u8 **tlvs, u32 *sizeoftlvs);
83 static int lane2_associate_req (struct net_device *dev, u8 *lan_dst,
84 u8 *tlvs, u32 sizeoftlvs);
86 static struct lane2_ops lane2_ops = {
87 lane2_resolve, /* resolve, spec 3.1.3 */
88 lane2_associate_req, /* associate_req, spec 3.1.4 */
89 NULL /* associate indicator, spec 3.1.5 */
92 static unsigned char bus_mac[ETH_ALEN] = {0xff,0xff,0xff,0xff,0xff,0xff};
94 /* Device structures */
95 static struct net_device *dev_lec[MAX_LEC_ITF];
97 /* This will be called from proc.c via function pointer */
98 struct net_device *get_dev_lec(int itf)
100 struct net_device *dev;
102 if (itf >= MAX_LEC_ITF)
112 #if defined(CONFIG_BRIDGE) || defined(CONFIG_BRIDGE_MODULE)
113 static void lec_handle_bridge(struct sk_buff *skb, struct net_device *dev)
117 struct lec_priv *priv;
119 /* Check if this is a BPDU. If so, ask zeppelin to send
120 * LE_TOPOLOGY_REQUEST with the same value of Topology Change bit
121 * as the Config BPDU has */
122 eth = (struct ethhdr *)skb->data;
123 buff = skb->data + skb->dev->hard_header_len;
124 if (*buff++ == 0x42 && *buff++ == 0x42 && *buff++ == 0x03) {
125 struct sk_buff *skb2;
126 struct atmlec_msg *mesg;
128 skb2 = alloc_skb(sizeof(struct atmlec_msg), GFP_ATOMIC);
129 if (skb2 == NULL) return;
130 skb2->len = sizeof(struct atmlec_msg);
131 mesg = (struct atmlec_msg *)skb2->data;
132 mesg->type = l_topology_change;
134 mesg->content.normal.flag = *buff & 0x01; /* 0x01 is topology change */
136 priv = (struct lec_priv *)dev->priv;
137 atm_force_charge(priv->lecd, skb2->truesize);
138 skb_queue_tail(&priv->lecd->sk->sk_receive_queue, skb2);
139 priv->lecd->sk->sk_data_ready(priv->lecd->sk, skb2->len);
144 #endif /* defined(CONFIG_BRIDGE) || defined(CONFIG_BRIDGE_MODULE) */
147 * Modelled after tr_type_trans
148 * All multicast and ARE or STE frames go to BUS.
149 * Non source routed frames go by destination address.
150 * Last hop source routed frames go by destination address.
151 * Not last hop source routed frames go by _next_ route descriptor.
152 * Returns pointer to destination MAC address or fills in rdesc
156 unsigned char *get_tr_dst(unsigned char *packet, unsigned char *rdesc)
159 int riflen, num_rdsc;
161 trh = (struct trh_hdr *)packet;
162 if (trh->daddr[0] & (uint8_t)0x80)
163 return bus_mac; /* multicast */
165 if (trh->saddr[0] & TR_RII) {
166 riflen = (ntohs(trh->rcf) & TR_RCF_LEN_MASK) >> 8;
167 if ((ntohs(trh->rcf) >> 13) != 0)
168 return bus_mac; /* ARE or STE */
171 return trh->daddr; /* not source routed */
174 return trh->daddr; /* last hop, source routed */
176 /* riflen is 6 or more, packet has more than one route descriptor */
177 num_rdsc = (riflen/2) - 1;
178 memset(rdesc, 0, ETH_ALEN);
179 /* offset 4 comes from LAN destination field in LE control frames */
180 if (trh->rcf & htons((uint16_t)TR_RCF_DIR_BIT))
181 memcpy(&rdesc[4], &trh->rseg[num_rdsc-2], sizeof(uint16_t));
183 memcpy(&rdesc[4], &trh->rseg[1], sizeof(uint16_t));
184 rdesc[5] = ((ntohs(trh->rseg[0]) & 0x000f) | (rdesc[5] & 0xf0));
189 #endif /* CONFIG_TR */
192 * Open/initialize the netdevice. This is called (in the current kernel)
193 * sometime after booting when the 'ifconfig' program is run.
195 * This routine should set everything up anew at each open, even
196 * registers that "should" only need to be set once at boot, so that
197 * there is non-reboot way to recover if something goes wrong.
201 lec_open(struct net_device *dev)
203 struct lec_priv *priv = (struct lec_priv *)dev->priv;
205 netif_start_queue(dev);
206 memset(&priv->stats,0,sizeof(struct net_device_stats));
211 static __inline__ void
212 lec_send(struct atm_vcc *vcc, struct sk_buff *skb, struct lec_priv *priv)
214 if (atm_may_send(vcc, skb->len)) {
215 atomic_add(skb->truesize, &vcc->sk->sk_wmem_alloc);
216 ATM_SKB(skb)->vcc = vcc;
217 ATM_SKB(skb)->atm_options = vcc->atm_options;
218 priv->stats.tx_packets++;
219 priv->stats.tx_bytes += skb->len;
222 priv->stats.tx_dropped++;
228 lec_send_packet(struct sk_buff *skb, struct net_device *dev)
230 struct sk_buff *skb2;
231 struct lec_priv *priv = (struct lec_priv *)dev->priv;
232 struct lecdatahdr_8023 *lec_h;
233 struct atm_vcc *send_vcc;
234 struct lec_arp_table *entry;
238 unsigned char rdesc[ETH_ALEN]; /* Token Ring route descriptor */
244 #endif /* DUMP_PACKETS >0 */
246 DPRINTK("Lec_send_packet called\n");
248 printk("%s:No lecd attached\n",dev->name);
249 priv->stats.tx_errors++;
250 netif_stop_queue(dev);
254 DPRINTK("skbuff head:%lx data:%lx tail:%lx end:%lx\n",
255 (long)skb->head, (long)skb->data, (long)skb->tail,
257 #if defined(CONFIG_BRIDGE) || defined(CONFIG_BRIDGE_MODULE)
258 if (memcmp(skb->data, bridge_ula_lec, sizeof(bridge_ula_lec)) == 0)
259 lec_handle_bridge(skb, dev);
262 /* Make sure we have room for lec_id */
263 if (skb_headroom(skb) < 2) {
265 DPRINTK("lec_send_packet: reallocating skb\n");
266 skb2 = skb_realloc_headroom(skb, LEC_HEADER_LEN);
268 if (skb2 == NULL) return 0;
273 /* Put le header to place, works for TokenRing too */
274 lec_h = (struct lecdatahdr_8023*)skb->data;
275 lec_h->le_header = htons(priv->lecid);
278 /* Ugly. Use this to realign Token Ring packets for
279 * e.g. PCA-200E driver. */
280 if (priv->is_trdev) {
281 skb2 = skb_realloc_headroom(skb, LEC_HEADER_LEN);
283 if (skb2 == NULL) return 0;
289 printk("%s: send datalen:%ld lecid:%4.4x\n", dev->name,
290 skb->len, priv->lecid);
291 #if DUMP_PACKETS >= 2
292 for(i=0;i<skb->len && i <99;i++) {
293 sprintf(buf+i*3,"%2.2x ",0xff&skb->data[i]);
295 #elif DUMP_PACKETS >= 1
296 for(i=0;i<skb->len && i < 30;i++) {
297 sprintf(buf+i*3,"%2.2x ", 0xff&skb->data[i]);
299 #endif /* DUMP_PACKETS >= 1 */
303 printk("%s...\n",buf);
304 #endif /* DUMP_PACKETS > 0 */
306 /* Minimum ethernet-frame size */
309 min_frame_size = LEC_MINIMUM_8025_SIZE;
312 min_frame_size = LEC_MINIMUM_8023_SIZE;
313 if (skb->len < min_frame_size) {
314 if ((skb->len + skb_tailroom(skb)) < min_frame_size) {
315 skb2 = skb_copy_expand(skb, 0,
316 min_frame_size - skb->truesize, GFP_ATOMIC);
319 priv->stats.tx_dropped++;
324 skb_put(skb, min_frame_size - skb->len);
327 /* Send to right vcc */
331 if (priv->is_trdev) {
332 dst = get_tr_dst(skb->data+2, rdesc);
340 send_vcc = lec_arp_resolve(priv, dst, is_rdesc, &entry);
341 DPRINTK("%s:send_vcc:%p vcc_flags:%x, entry:%p\n", dev->name,
342 send_vcc, send_vcc?send_vcc->flags:0, entry);
343 if (!send_vcc || !test_bit(ATM_VF_READY,&send_vcc->flags)) {
344 if (entry && (entry->tx_wait.qlen < LEC_UNRES_QUE_LEN)) {
345 DPRINTK("%s:lec_send_packet: queuing packet, ", dev->name);
346 DPRINTK("MAC address 0x%02x:%02x:%02x:%02x:%02x:%02x\n",
347 lec_h->h_dest[0], lec_h->h_dest[1], lec_h->h_dest[2],
348 lec_h->h_dest[3], lec_h->h_dest[4], lec_h->h_dest[5]);
349 skb_queue_tail(&entry->tx_wait, skb);
351 DPRINTK("%s:lec_send_packet: tx queue full or no arp entry, dropping, ", dev->name);
352 DPRINTK("MAC address 0x%02x:%02x:%02x:%02x:%02x:%02x\n",
353 lec_h->h_dest[0], lec_h->h_dest[1], lec_h->h_dest[2],
354 lec_h->h_dest[3], lec_h->h_dest[4], lec_h->h_dest[5]);
355 priv->stats.tx_dropped++;
362 printk("%s:sending to vpi:%d vci:%d\n", dev->name,
363 send_vcc->vpi, send_vcc->vci);
364 #endif /* DUMP_PACKETS > 0 */
366 while (entry && (skb2 = skb_dequeue(&entry->tx_wait))) {
367 DPRINTK("lec.c: emptying tx queue, ");
368 DPRINTK("MAC address 0x%02x:%02x:%02x:%02x:%02x:%02x\n",
369 lec_h->h_dest[0], lec_h->h_dest[1], lec_h->h_dest[2],
370 lec_h->h_dest[3], lec_h->h_dest[4], lec_h->h_dest[5]);
371 lec_send(send_vcc, skb2, priv);
374 lec_send(send_vcc, skb, priv);
377 /* Should we wait for card's device driver to notify us? */
383 /* The inverse routine to net_open(). */
385 lec_close(struct net_device *dev)
387 netif_stop_queue(dev);
392 * Get the current statistics.
393 * This may be called with the card open or closed.
395 static struct net_device_stats *
396 lec_get_stats(struct net_device *dev)
398 return &((struct lec_priv *)dev->priv)->stats;
402 lec_atm_send(struct atm_vcc *vcc, struct sk_buff *skb)
404 struct net_device *dev = (struct net_device*)vcc->proto_data;
405 struct lec_priv *priv = (struct lec_priv*)dev->priv;
406 struct atmlec_msg *mesg;
407 struct lec_arp_table *entry;
409 char *tmp; /* FIXME */
411 atomic_sub(skb->truesize, &vcc->sk->sk_wmem_alloc);
412 mesg = (struct atmlec_msg *)skb->data;
414 tmp += sizeof(struct atmlec_msg);
415 DPRINTK("%s: msg from zeppelin:%d\n", dev->name, mesg->type);
419 dev->dev_addr[i] = mesg->content.normal.mac_addr[i];
424 dev->dev_addr[i] = 0;
428 lec_addr_delete(priv, mesg->content.normal.atm_addr,
429 mesg->content.normal.flag);
431 case l_topology_change:
432 priv->topology_change = mesg->content.normal.flag;
434 case l_flush_complete:
435 lec_flush_complete(priv, mesg->content.normal.flag);
437 case l_narp_req: /* LANE2: see 7.1.35 in the lane2 spec */
438 entry = lec_arp_find(priv, mesg->content.normal.mac_addr);
439 lec_arp_remove(priv, entry);
441 if (mesg->content.normal.no_source_le_narp)
445 lec_arp_update(priv, mesg->content.normal.mac_addr,
446 mesg->content.normal.atm_addr,
447 mesg->content.normal.flag,
448 mesg->content.normal.targetless_le_arp);
449 DPRINTK("lec: in l_arp_update\n");
450 if (mesg->sizeoftlvs != 0) { /* LANE2 3.1.5 */
451 DPRINTK("lec: LANE2 3.1.5, got tlvs, size %d\n", mesg->sizeoftlvs);
452 lane2_associate_ind(dev,
453 mesg->content.normal.mac_addr,
454 tmp, mesg->sizeoftlvs);
458 priv->maximum_unknown_frame_count =
459 mesg->content.config.maximum_unknown_frame_count;
460 priv->max_unknown_frame_time =
461 (mesg->content.config.max_unknown_frame_time*HZ);
462 priv->max_retry_count =
463 mesg->content.config.max_retry_count;
464 priv->aging_time = (mesg->content.config.aging_time*HZ);
465 priv->forward_delay_time =
466 (mesg->content.config.forward_delay_time*HZ);
467 priv->arp_response_time =
468 (mesg->content.config.arp_response_time*HZ);
469 priv->flush_timeout = (mesg->content.config.flush_timeout*HZ);
470 priv->path_switching_delay =
471 (mesg->content.config.path_switching_delay*HZ);
472 priv->lane_version = mesg->content.config.lane_version; /* LANE2 */
473 priv->lane2_ops = NULL;
474 if (priv->lane_version > 1)
475 priv->lane2_ops = &lane2_ops;
476 if (dev->change_mtu(dev, mesg->content.config.mtu))
477 printk("%s: change_mtu to %d failed\n", dev->name,
478 mesg->content.config.mtu);
479 priv->is_proxy = mesg->content.config.is_proxy;
481 case l_flush_tran_id:
482 lec_set_flush_tran_id(priv, mesg->content.normal.atm_addr,
483 mesg->content.normal.flag);
486 priv->lecid=(unsigned short)(0xffff&mesg->content.normal.flag);
488 case l_should_bridge: {
489 #if defined(CONFIG_BRIDGE) || defined(CONFIG_BRIDGE_MODULE)
490 struct net_bridge_fdb_entry *f;
492 DPRINTK("%s: bridge zeppelin asks about 0x%02x:%02x:%02x:%02x:%02x:%02x\n",
494 mesg->content.proxy.mac_addr[0], mesg->content.proxy.mac_addr[1],
495 mesg->content.proxy.mac_addr[2], mesg->content.proxy.mac_addr[3],
496 mesg->content.proxy.mac_addr[4], mesg->content.proxy.mac_addr[5]);
498 if (br_fdb_get_hook == NULL || dev->br_port == NULL)
501 f = br_fdb_get_hook(dev->br_port->br, mesg->content.proxy.mac_addr);
503 f->dst->dev != dev &&
504 f->dst->state == BR_STATE_FORWARDING) {
505 /* hit from bridge table, send LE_ARP_RESPONSE */
506 struct sk_buff *skb2;
508 DPRINTK("%s: entry found, responding to zeppelin\n", dev->name);
509 skb2 = alloc_skb(sizeof(struct atmlec_msg), GFP_ATOMIC);
514 skb2->len = sizeof(struct atmlec_msg);
515 memcpy(skb2->data, mesg, sizeof(struct atmlec_msg));
516 atm_force_charge(priv->lecd, skb2->truesize);
517 skb_queue_tail(&priv->lecd->sk->sk_receive_queue, skb2);
518 priv->lecd->sk->sk_data_ready(priv->lecd->sk, skb2->len);
520 if (f != NULL) br_fdb_put_hook(f);
521 #endif /* defined(CONFIG_BRIDGE) || defined(CONFIG_BRIDGE_MODULE) */
525 printk("%s: Unknown message type %d\n", dev->name, mesg->type);
534 lec_atm_close(struct atm_vcc *vcc)
537 struct net_device *dev = (struct net_device *)vcc->proto_data;
538 struct lec_priv *priv = (struct lec_priv *)dev->priv;
541 /* Do something needful? */
543 netif_stop_queue(dev);
544 lec_arp_destroy(priv);
546 if (skb_peek(&vcc->sk->sk_receive_queue))
547 printk("%s lec_atm_close: closing with messages pending\n",
549 while ((skb = skb_dequeue(&vcc->sk->sk_receive_queue))) {
550 atm_return(vcc, skb->truesize);
554 printk("%s: Shut down!\n", dev->name);
555 module_put(THIS_MODULE);
558 static struct atmdev_ops lecdev_ops = {
559 .close = lec_atm_close,
563 static struct atm_dev lecatm_dev = {
566 .number = 999, /* dummy device number */
567 .lock = SPIN_LOCK_UNLOCKED
571 * LANE2: new argument struct sk_buff *data contains
572 * the LE_ARP based TLVs introduced in the LANE2 spec
575 send_to_lecd(struct lec_priv *priv, atmlec_msg_type type,
576 unsigned char *mac_addr, unsigned char *atm_addr,
577 struct sk_buff *data)
580 struct atmlec_msg *mesg;
582 if (!priv || !priv->lecd) {
585 skb = alloc_skb(sizeof(struct atmlec_msg), GFP_ATOMIC);
588 skb->len = sizeof(struct atmlec_msg);
589 mesg = (struct atmlec_msg *)skb->data;
590 memset(mesg, 0, sizeof(struct atmlec_msg));
593 mesg->sizeoftlvs = data->len;
595 memcpy(&mesg->content.normal.mac_addr, mac_addr, ETH_ALEN);
597 mesg->content.normal.targetless_le_arp = 1;
599 memcpy(&mesg->content.normal.atm_addr, atm_addr, ATM_ESA_LEN);
601 atm_force_charge(priv->lecd, skb->truesize);
602 skb_queue_tail(&priv->lecd->sk->sk_receive_queue, skb);
603 priv->lecd->sk->sk_data_ready(priv->lecd->sk, skb->len);
606 DPRINTK("lec: about to send %d bytes of data\n", data->len);
607 atm_force_charge(priv->lecd, data->truesize);
608 skb_queue_tail(&priv->lecd->sk->sk_receive_queue, data);
609 priv->lecd->sk->sk_data_ready(priv->lecd->sk, skb->len);
615 /* shamelessly stolen from drivers/net/net_init.c */
616 static int lec_change_mtu(struct net_device *dev, int new_mtu)
618 if ((new_mtu < 68) || (new_mtu > 18190))
624 static void lec_set_multicast_list(struct net_device *dev)
626 /* by default, all multicast frames arrive over the bus.
627 * eventually support selective multicast service
633 lec_init(struct net_device *dev)
635 dev->change_mtu = lec_change_mtu;
636 dev->open = lec_open;
637 dev->stop = lec_close;
638 dev->hard_start_xmit = lec_send_packet;
640 dev->get_stats = lec_get_stats;
641 dev->set_multicast_list = lec_set_multicast_list;
642 dev->do_ioctl = NULL;
643 printk("%s: Initialized!\n",dev->name);
647 static unsigned char lec_ctrl_magic[] = {
654 lec_push(struct atm_vcc *vcc, struct sk_buff *skb)
656 struct net_device *dev = (struct net_device *)vcc->proto_data;
657 struct lec_priv *priv = (struct lec_priv *)dev->priv;
663 printk("%s: lec_push vcc vpi:%d vci:%d\n", dev->name,
667 DPRINTK("%s: null skb\n",dev->name);
668 lec_vcc_close(priv, vcc);
672 printk("%s: rcv datalen:%ld lecid:%4.4x\n", dev->name,
673 skb->len, priv->lecid);
674 #if DUMP_PACKETS >= 2
675 for(i=0;i<skb->len && i <99;i++) {
676 sprintf(buf+i*3,"%2.2x ",0xff&skb->data[i]);
678 #elif DUMP_PACKETS >= 1
679 for(i=0;i<skb->len && i < 30;i++) {
680 sprintf(buf+i*3,"%2.2x ", 0xff&skb->data[i]);
682 #endif /* DUMP_PACKETS >= 1 */
686 printk("%s...\n",buf);
687 #endif /* DUMP_PACKETS > 0 */
688 if (memcmp(skb->data, lec_ctrl_magic, 4) ==0) { /* Control frame, to daemon*/
689 DPRINTK("%s: To daemon\n",dev->name);
690 skb_queue_tail(&vcc->sk->sk_receive_queue, skb);
691 vcc->sk->sk_data_ready(vcc->sk, skb->len);
692 } else { /* Data frame, queue to protocol handlers */
695 atm_return(vcc,skb->truesize);
696 if (*(uint16_t *)skb->data == htons(priv->lecid) ||
698 !(dev->flags & IFF_UP)) {
699 /* Probably looping back, or if lecd is missing,
700 lecd has gone down */
701 DPRINTK("Ignoring frame...\n");
706 if (priv->is_trdev) dst = ((struct lecdatahdr_8025 *)skb->data)->h_dest;
709 dst = ((struct lecdatahdr_8023 *)skb->data)->h_dest;
711 if (!(dst[0]&0x01) && /* Never filter Multi/Broadcast */
712 !priv->is_proxy && /* Proxy wants all the packets */
713 memcmp(dst, dev->dev_addr, dev->addr_len)) {
717 if (priv->lec_arp_empty_ones) {
718 lec_arp_check_empties(priv, vcc, skb);
721 skb_pull(skb, 2); /* skip lec_id */
723 if (priv->is_trdev) skb->protocol = tr_type_trans(skb, dev);
726 skb->protocol = eth_type_trans(skb, dev);
727 priv->stats.rx_packets++;
728 priv->stats.rx_bytes += skb->len;
729 memset(ATM_SKB(skb), 0, sizeof(struct atm_skb_data));
735 lec_vcc_attach(struct atm_vcc *vcc, void *arg)
738 struct atmlec_ioc ioc_data;
740 /* Lecd must be up in this case */
741 bytes_left = copy_from_user(&ioc_data, arg, sizeof(struct atmlec_ioc));
742 if (bytes_left != 0) {
743 printk("lec: lec_vcc_attach, copy from user failed for %d bytes\n",
746 if (ioc_data.dev_num < 0 || ioc_data.dev_num >= MAX_LEC_ITF ||
747 !dev_lec[ioc_data.dev_num])
749 lec_vcc_added(dev_lec[ioc_data.dev_num]->priv,
750 &ioc_data, vcc, vcc->push);
751 vcc->push = lec_push;
752 vcc->proto_data = dev_lec[ioc_data.dev_num];
757 lec_mcast_attach(struct atm_vcc *vcc, int arg)
759 if (arg <0 || arg >= MAX_LEC_ITF || !dev_lec[arg])
761 vcc->proto_data = dev_lec[arg];
762 return (lec_mcast_make((struct lec_priv*)dev_lec[arg]->priv, vcc));
765 /* Initialize device. */
767 lecd_attach(struct atm_vcc *vcc, int arg)
770 struct lec_priv *priv;
777 if (arg >= MAX_LEC_ITF)
779 #else /* Reserve the top NUM_TR_DEVS for TR */
780 if (arg >= (MAX_LEC_ITF-NUM_TR_DEVS))
787 if (i >= (MAX_LEC_ITF - NUM_TR_DEVS))
790 size = sizeof(struct lec_priv);
793 dev_lec[i] = alloc_trdev(size);
796 dev_lec[i] = alloc_etherdev(size);
799 snprintf(dev_lec[i]->name, IFNAMSIZ, "lec%d", i);
800 if (register_netdev(dev_lec[i])) {
801 free_netdev(dev_lec[i]);
805 priv = dev_lec[i]->priv;
806 priv->is_trdev = is_trdev;
807 lec_init(dev_lec[i]);
809 priv = dev_lec[i]->priv;
814 priv->itfnum = i; /* LANE2 addition */
816 vcc->dev = &lecatm_dev;
817 vcc_insert_socket(vcc->sk);
819 vcc->proto_data = dev_lec[i];
820 set_bit(ATM_VF_META,&vcc->flags);
821 set_bit(ATM_VF_READY,&vcc->flags);
823 /* Set default values to these variables */
824 priv->maximum_unknown_frame_count = 1;
825 priv->max_unknown_frame_time = (1*HZ);
826 priv->vcc_timeout_period = (1200*HZ);
827 priv->max_retry_count = 1;
828 priv->aging_time = (300*HZ);
829 priv->forward_delay_time = (15*HZ);
830 priv->topology_change = 0;
831 priv->arp_response_time = (1*HZ);
832 priv->flush_timeout = (4*HZ);
833 priv->path_switching_delay = (6*HZ);
835 if (dev_lec[i]->flags & IFF_UP) {
836 netif_start_queue(dev_lec[i]);
838 __module_get(THIS_MODULE);
842 #ifdef CONFIG_PROC_FS
843 static char* lec_arp_get_status_string(unsigned char status)
845 static char *lec_arp_status_string[] = {
850 "ESI_FLUSH_PENDING ",
854 if (status > ESI_FORWARD_DIRECT)
855 status = 3; /* ESI_UNDEFINED */
856 return lec_arp_status_string[status];
859 static void lec_info(struct seq_file *seq, struct lec_arp_table *entry)
863 for (i = 0; i < ETH_ALEN; i++)
864 seq_printf(seq, "%2.2x", entry->mac_addr[i] & 0xff);
865 seq_printf(seq, " ");
866 for (i = 0; i < ATM_ESA_LEN; i++)
867 seq_printf(seq, "%2.2x", entry->atm_addr[i] & 0xff);
868 seq_printf(seq, " %s %4.4x", lec_arp_get_status_string(entry->status),
869 entry->flags & 0xffff);
871 seq_printf(seq, "%3d %3d ", entry->vcc->vpi, entry->vcc->vci);
873 seq_printf(seq, " ");
874 if (entry->recv_vcc) {
875 seq_printf(seq, " %3d %3d", entry->recv_vcc->vpi,
876 entry->recv_vcc->vci);
884 struct lec_priv *locked;
885 struct lec_arp_table *entry;
886 struct net_device *dev;
892 static void *lec_tbl_walk(struct lec_state *state, struct lec_arp_table *tbl,
895 struct lec_arp_table *e = state->entry;
899 if (e == (void *)1) {
903 for (; e; e = e->next) {
908 return (*l < 0) ? state : NULL;
911 static void *lec_arp_walk(struct lec_state *state, loff_t *l,
912 struct lec_priv *priv)
917 for (p = state->arp_table; p < LEC_ARP_TABLE_SIZE; p++) {
918 v = lec_tbl_walk(state, priv->lec_arp_tables[p], l);
922 state->arp_table = p;
926 static void *lec_misc_walk(struct lec_state *state, loff_t *l,
927 struct lec_priv *priv)
929 struct lec_arp_table *lec_misc_tables[] = {
930 priv->lec_arp_empty_ones,
931 priv->lec_no_forward,
937 for (q = state->misc_table; q < ARRAY_SIZE(lec_misc_tables); q++) {
938 v = lec_tbl_walk(state, lec_misc_tables[q], l);
942 state->misc_table = q;
946 static void *lec_priv_walk(struct lec_state *state, loff_t *l,
947 struct lec_priv *priv)
949 if (!state->locked) {
950 state->locked = priv;
951 spin_lock_irqsave(&priv->lec_arp_lock, state->flags);
953 if (!lec_arp_walk(state, l, priv) &&
954 !lec_misc_walk(state, l, priv)) {
955 spin_unlock_irqrestore(&priv->lec_arp_lock, state->flags);
956 state->locked = NULL;
957 /* Partial state reset for the next time we get called */
958 state->arp_table = state->misc_table = 0;
960 return state->locked;
963 static void *lec_itf_walk(struct lec_state *state, loff_t *l)
965 struct net_device *dev;
968 dev = state->dev ? state->dev : dev_lec[state->itf];
969 v = (dev && dev->priv) ? lec_priv_walk(state, l, dev->priv) : NULL;
972 /* Partial state reset for the next time we get called */
979 static void *lec_get_idx(struct lec_state *state, loff_t l)
983 for (; state->itf < MAX_LEC_ITF; state->itf++) {
984 v = lec_itf_walk(state, &l);
991 static void *lec_seq_start(struct seq_file *seq, loff_t *pos)
993 struct lec_state *state = seq->private;
997 state->locked = NULL;
998 state->arp_table = 0;
999 state->misc_table = 0;
1000 state->entry = (void *)1;
1002 return *pos ? lec_get_idx(state, *pos) : (void*)1;
1005 static void lec_seq_stop(struct seq_file *seq, void *v)
1007 struct lec_state *state = seq->private;
1010 spin_unlock_irqrestore(&state->locked->lec_arp_lock,
1012 dev_put(state->dev);
1016 static void *lec_seq_next(struct seq_file *seq, void *v, loff_t *pos)
1018 struct lec_state *state = seq->private;
1020 v = lec_get_idx(state, 1);
1021 *pos += !!PTR_ERR(v);
1025 static int lec_seq_show(struct seq_file *seq, void *v)
1027 static char lec_banner[] = "Itf MAC ATM destination"
1029 "VPI/VCI Recv VPI/VCI\n";
1032 seq_puts(seq, lec_banner);
1034 struct lec_state *state = seq->private;
1035 struct net_device *dev = state->dev;
1037 seq_printf(seq, "%s ", dev->name);
1038 lec_info(seq, state->entry);
1043 static struct seq_operations lec_seq_ops = {
1044 .start = lec_seq_start,
1045 .next = lec_seq_next,
1046 .stop = lec_seq_stop,
1047 .show = lec_seq_show,
1050 static int lec_seq_open(struct inode *inode, struct file *file)
1052 struct lec_state *state;
1053 struct seq_file *seq;
1056 state = kmalloc(sizeof(*state), GFP_KERNEL);
1062 rc = seq_open(file, &lec_seq_ops);
1065 seq = file->private_data;
1066 seq->private = state;
1075 static int lec_seq_release(struct inode *inode, struct file *file)
1077 return seq_release_private(inode, file);
1080 static struct file_operations lec_seq_fops = {
1081 .owner = THIS_MODULE,
1082 .open = lec_seq_open,
1084 .llseek = seq_lseek,
1085 .release = lec_seq_release,
1089 static int lane_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
1091 struct atm_vcc *vcc = ATM_SD(sock);
1098 if (!capable(CAP_NET_ADMIN))
1102 return -ENOIOCTLCMD;
1107 err = lecd_attach(vcc, (int) arg);
1109 sock->state = SS_CONNECTED;
1112 err = lec_mcast_attach(vcc, (int) arg);
1115 err = lec_vcc_attach(vcc, (void *) arg);
1122 static struct atm_ioctl lane_ioctl_ops = {
1123 .owner = THIS_MODULE,
1124 .ioctl = lane_ioctl,
1127 static int __init lane_module_init(void)
1129 #ifdef CONFIG_PROC_FS
1130 struct proc_dir_entry *p;
1132 p = create_proc_entry("lec", S_IRUGO, atm_proc_root);
1134 p->proc_fops = &lec_seq_fops;
1137 register_atm_ioctl(&lane_ioctl_ops);
1138 printk("lec.c: " __DATE__ " " __TIME__ " initialized\n");
1142 static void __exit lane_module_cleanup(void)
1145 struct lec_priv *priv;
1147 remove_proc_entry("lec", atm_proc_root);
1149 deregister_atm_ioctl(&lane_ioctl_ops);
1151 for (i = 0; i < MAX_LEC_ITF; i++) {
1152 if (dev_lec[i] != NULL) {
1153 priv = (struct lec_priv *)dev_lec[i]->priv;
1154 unregister_netdev(dev_lec[i]);
1155 free_netdev(dev_lec[i]);
1163 module_init(lane_module_init);
1164 module_exit(lane_module_cleanup);
1167 * LANE2: 3.1.3, LE_RESOLVE.request
1168 * Non force allocates memory and fills in *tlvs, fills in *sizeoftlvs.
1169 * If sizeoftlvs == NULL the default TLVs associated with with this
1171 * If dst_mac == NULL, targetless LE_ARP will be sent
1173 static int lane2_resolve(struct net_device *dev, u8 *dst_mac, int force,
1174 u8 **tlvs, u32 *sizeoftlvs)
1176 struct lec_priv *priv = (struct lec_priv *)dev->priv;
1177 struct lec_arp_table *table;
1178 struct sk_buff *skb;
1182 table = lec_arp_find(priv, dst_mac);
1186 *tlvs = kmalloc(table->sizeoftlvs, GFP_KERNEL);
1190 memcpy(*tlvs, table->tlvs, table->sizeoftlvs);
1191 *sizeoftlvs = table->sizeoftlvs;
1196 if (sizeoftlvs == NULL)
1197 retval = send_to_lecd(priv, l_arp_xmt, dst_mac, NULL, NULL);
1200 skb = alloc_skb(*sizeoftlvs, GFP_ATOMIC);
1203 skb->len = *sizeoftlvs;
1204 memcpy(skb->data, *tlvs, *sizeoftlvs);
1205 retval = send_to_lecd(priv, l_arp_xmt, dst_mac, NULL, skb);
1212 * LANE2: 3.1.4, LE_ASSOCIATE.request
1213 * Associate the *tlvs with the *lan_dst address.
1214 * Will overwrite any previous association
1215 * Returns 1 for success, 0 for failure (out of memory)
1218 static int lane2_associate_req (struct net_device *dev, u8 *lan_dst,
1219 u8 *tlvs, u32 sizeoftlvs)
1222 struct sk_buff *skb;
1223 struct lec_priv *priv = (struct lec_priv*)dev->priv;
1225 if ( memcmp(lan_dst, dev->dev_addr, ETH_ALEN) != 0 )
1226 return (0); /* not our mac address */
1228 kfree(priv->tlvs); /* NULL if there was no previous association */
1230 priv->tlvs = kmalloc(sizeoftlvs, GFP_KERNEL);
1231 if (priv->tlvs == NULL)
1233 priv->sizeoftlvs = sizeoftlvs;
1234 memcpy(priv->tlvs, tlvs, sizeoftlvs);
1236 skb = alloc_skb(sizeoftlvs, GFP_ATOMIC);
1239 skb->len = sizeoftlvs;
1240 memcpy(skb->data, tlvs, sizeoftlvs);
1241 retval = send_to_lecd(priv, l_associate_req, NULL, NULL, skb);
1243 printk("lec.c: lane2_associate_req() failed\n");
1244 /* If the previous association has changed we must
1245 * somehow notify other LANE entities about the change
1251 * LANE2: 3.1.5, LE_ASSOCIATE.indication
1254 static void lane2_associate_ind (struct net_device *dev, u8 *mac_addr,
1255 u8 *tlvs, u32 sizeoftlvs)
1260 struct lec_priv *priv = (struct lec_priv *)dev->priv;
1261 #if 0 /* Why have the TLVs in LE_ARP entries since we do not use them? When you
1262 uncomment this code, make sure the TLVs get freed when entry is killed */
1263 struct lec_arp_table *entry = lec_arp_find(priv, mac_addr);
1266 return; /* should not happen */
1270 entry->tlvs = kmalloc(sizeoftlvs, GFP_KERNEL);
1271 if (entry->tlvs == NULL)
1274 entry->sizeoftlvs = sizeoftlvs;
1275 memcpy(entry->tlvs, tlvs, sizeoftlvs);
1278 printk("lec.c: lane2_associate_ind()\n");
1279 printk("dump of tlvs, sizeoftlvs=%d\n", sizeoftlvs);
1280 while (i < sizeoftlvs)
1281 printk("%02x ", tlvs[i++]);
1286 /* tell MPOA about the TLVs we saw */
1287 if (priv->lane2_ops && priv->lane2_ops->associate_indicator) {
1288 priv->lane2_ops->associate_indicator(dev, mac_addr,
1295 * Here starts what used to lec_arpc.c
1297 * lec_arpc.c was added here when making
1298 * lane client modular. October 1997
1302 #include <linux/types.h>
1303 #include <linux/sched.h>
1304 #include <linux/timer.h>
1305 #include <asm/param.h>
1306 #include <asm/atomic.h>
1307 #include <linux/inetdevice.h>
1308 #include <net/route.h>
1312 #define DPRINTK(format,args...)
1314 #define DPRINTK printk
1317 #define DEBUG_ARP_TABLE 0
1319 #define LEC_ARP_REFRESH_INTERVAL (3*HZ)
1321 static void lec_arp_check_expire(unsigned long data);
1322 static void lec_arp_expire_arp(unsigned long data);
1323 void dump_arp_table(struct lec_priv *priv);
1329 #define HASH(ch) (ch & (LEC_ARP_TABLE_SIZE -1))
1331 static __inline__ void
1332 lec_arp_get(struct lec_priv *priv)
1334 atomic_inc(&priv->lec_arp_users);
1337 static __inline__ void
1338 lec_arp_put(struct lec_priv *priv)
1340 atomic_dec(&priv->lec_arp_users);
1344 * Initialization of arp-cache
1347 lec_arp_init(struct lec_priv *priv)
1351 for (i=0;i<LEC_ARP_TABLE_SIZE;i++) {
1352 priv->lec_arp_tables[i] = NULL;
1354 spin_lock_init(&priv->lec_arp_lock);
1355 init_timer(&priv->lec_arp_timer);
1356 priv->lec_arp_timer.expires = jiffies+LEC_ARP_REFRESH_INTERVAL;
1357 priv->lec_arp_timer.data = (unsigned long)priv;
1358 priv->lec_arp_timer.function = lec_arp_check_expire;
1359 add_timer(&priv->lec_arp_timer);
1363 lec_arp_clear_vccs(struct lec_arp_table *entry)
1366 entry->vcc->push = entry->old_push;
1367 #if 0 /* August 6, 1998 */
1368 set_bit(ATM_VF_RELEASED,&entry->vcc->flags);
1369 clear_bit(ATM_VF_READY,&entry->vcc->flags);
1370 entry->vcc->push(entry->vcc, NULL);
1372 vcc_release_async(entry->vcc, -EPIPE);
1375 if (entry->recv_vcc) {
1376 entry->recv_vcc->push = entry->old_recv_push;
1378 set_bit(ATM_VF_RELEASED,&entry->recv_vcc->flags);
1379 clear_bit(ATM_VF_READY,&entry->recv_vcc->flags);
1380 entry->recv_vcc->push(entry->recv_vcc, NULL);
1382 vcc_release_async(entry->recv_vcc, -EPIPE);
1383 entry->recv_vcc = NULL;
1388 * Insert entry to lec_arp_table
1389 * LANE2: Add to the end of the list to satisfy 8.1.13
1392 lec_arp_add(struct lec_priv *priv, struct lec_arp_table *to_add)
1394 unsigned long flags;
1395 unsigned short place;
1396 struct lec_arp_table *tmp;
1398 spin_lock_irqsave(&priv->lec_arp_lock, flags);
1400 place = HASH(to_add->mac_addr[ETH_ALEN-1]);
1401 tmp = priv->lec_arp_tables[place];
1402 to_add->next = NULL;
1404 priv->lec_arp_tables[place] = to_add;
1406 else { /* add to the end */
1412 spin_unlock_irqrestore(&priv->lec_arp_lock, flags);
1414 DPRINTK("LEC_ARP: Added entry:%2.2x %2.2x %2.2x %2.2x %2.2x %2.2x\n",
1415 0xff&to_add->mac_addr[0], 0xff&to_add->mac_addr[1],
1416 0xff&to_add->mac_addr[2], 0xff&to_add->mac_addr[3],
1417 0xff&to_add->mac_addr[4], 0xff&to_add->mac_addr[5]);
1421 * Remove entry from lec_arp_table
1424 lec_arp_remove(struct lec_priv *priv,
1425 struct lec_arp_table *to_remove)
1427 unsigned long flags;
1428 unsigned short place;
1429 struct lec_arp_table *tmp;
1432 spin_lock_irqsave(&priv->lec_arp_lock, flags);
1435 spin_unlock_irqrestore(&priv->lec_arp_lock, flags);
1438 place = HASH(to_remove->mac_addr[ETH_ALEN-1]);
1439 tmp = priv->lec_arp_tables[place];
1440 if (tmp == to_remove) {
1441 priv->lec_arp_tables[place] = tmp->next;
1443 while(tmp && tmp->next != to_remove) {
1446 if (!tmp) {/* Entry was not found */
1447 spin_unlock_irqrestore(&priv->lec_arp_lock, flags);
1451 tmp->next = to_remove->next;
1452 del_timer(&to_remove->timer);
1454 /* If this is the only MAC connected to this VCC, also tear down
1456 if (to_remove->status >= ESI_FLUSH_PENDING) {
1458 * ESI_FLUSH_PENDING, ESI_FORWARD_DIRECT
1460 for(place=0;place<LEC_ARP_TABLE_SIZE;place++) {
1461 for(tmp = priv->lec_arp_tables[place]; tmp != NULL; tmp = tmp->next) {
1462 if (memcmp(tmp->atm_addr, to_remove->atm_addr,
1470 lec_arp_clear_vccs(to_remove);
1472 skb_queue_purge(&to_remove->tx_wait); /* FIXME: good place for this? */
1474 spin_unlock_irqrestore(&priv->lec_arp_lock, flags);
1476 DPRINTK("LEC_ARP: Removed entry:%2.2x %2.2x %2.2x %2.2x %2.2x %2.2x\n",
1477 0xff&to_remove->mac_addr[0], 0xff&to_remove->mac_addr[1],
1478 0xff&to_remove->mac_addr[2], 0xff&to_remove->mac_addr[3],
1479 0xff&to_remove->mac_addr[4], 0xff&to_remove->mac_addr[5]);
1485 get_status_string(unsigned char st)
1489 return "ESI_UNKNOWN";
1490 case ESI_ARP_PENDING:
1491 return "ESI_ARP_PENDING";
1492 case ESI_VC_PENDING:
1493 return "ESI_VC_PENDING";
1494 case ESI_FLUSH_PENDING:
1495 return "ESI_FLUSH_PENDING";
1496 case ESI_FORWARD_DIRECT:
1497 return "ESI_FORWARD_DIRECT";
1505 dump_arp_table(struct lec_priv *priv)
1509 struct lec_arp_table *rulla;
1511 struct lec_arp_table **lec_arp_tables =
1512 (struct lec_arp_table **)priv->lec_arp_tables;
1513 struct lec_arp_table *lec_arp_empty_ones =
1514 (struct lec_arp_table *)priv->lec_arp_empty_ones;
1515 struct lec_arp_table *lec_no_forward =
1516 (struct lec_arp_table *)priv->lec_no_forward;
1517 struct lec_arp_table *mcast_fwds = priv->mcast_fwds;
1520 printk("Dump %p:\n",priv);
1521 for (i=0;i<LEC_ARP_TABLE_SIZE;i++) {
1522 rulla = lec_arp_tables[i];
1524 offset += sprintf(buf,"%d: %p\n",i, rulla);
1526 offset += sprintf(buf+offset,"Mac:");
1527 for(j=0;j<ETH_ALEN;j++) {
1528 offset+=sprintf(buf+offset,
1530 rulla->mac_addr[j]&0xff);
1532 offset +=sprintf(buf+offset,"Atm:");
1533 for(j=0;j<ATM_ESA_LEN;j++) {
1534 offset+=sprintf(buf+offset,
1536 rulla->atm_addr[j]&0xff);
1538 offset+=sprintf(buf+offset,
1539 "Vcc vpi:%d vci:%d, Recv_vcc vpi:%d vci:%d Last_used:%lx, Timestamp:%lx, No_tries:%d ",
1540 rulla->vcc?rulla->vcc->vpi:0,
1541 rulla->vcc?rulla->vcc->vci:0,
1542 rulla->recv_vcc?rulla->recv_vcc->vpi:0,
1543 rulla->recv_vcc?rulla->recv_vcc->vci:0,
1545 rulla->timestamp, rulla->no_tries);
1546 offset+=sprintf(buf+offset,
1547 "Flags:%x, Packets_flooded:%x, Status: %s ",
1548 rulla->flags, rulla->packets_flooded,
1549 get_status_string(rulla->status));
1550 offset+=sprintf(buf+offset,"->%p\n",rulla->next);
1551 rulla = rulla->next;
1555 rulla = lec_no_forward;
1557 printk("No forward\n");
1560 offset += sprintf(buf+offset,"Mac:");
1561 for(j=0;j<ETH_ALEN;j++) {
1562 offset+=sprintf(buf+offset,"%2.2x ",
1563 rulla->mac_addr[j]&0xff);
1565 offset +=sprintf(buf+offset,"Atm:");
1566 for(j=0;j<ATM_ESA_LEN;j++) {
1567 offset+=sprintf(buf+offset,"%2.2x ",
1568 rulla->atm_addr[j]&0xff);
1570 offset+=sprintf(buf+offset,
1571 "Vcc vpi:%d vci:%d, Recv_vcc vpi:%d vci:%d Last_used:%lx, Timestamp:%lx, No_tries:%d ",
1572 rulla->vcc?rulla->vcc->vpi:0,
1573 rulla->vcc?rulla->vcc->vci:0,
1574 rulla->recv_vcc?rulla->recv_vcc->vpi:0,
1575 rulla->recv_vcc?rulla->recv_vcc->vci:0,
1577 rulla->timestamp, rulla->no_tries);
1578 offset+=sprintf(buf+offset,
1579 "Flags:%x, Packets_flooded:%x, Status: %s ",
1580 rulla->flags, rulla->packets_flooded,
1581 get_status_string(rulla->status));
1582 offset+=sprintf(buf+offset,"->%lx\n",(long)rulla->next);
1583 rulla = rulla->next;
1586 rulla = lec_arp_empty_ones;
1588 printk("Empty ones\n");
1591 offset += sprintf(buf+offset,"Mac:");
1592 for(j=0;j<ETH_ALEN;j++) {
1593 offset+=sprintf(buf+offset,"%2.2x ",
1594 rulla->mac_addr[j]&0xff);
1596 offset +=sprintf(buf+offset,"Atm:");
1597 for(j=0;j<ATM_ESA_LEN;j++) {
1598 offset+=sprintf(buf+offset,"%2.2x ",
1599 rulla->atm_addr[j]&0xff);
1601 offset+=sprintf(buf+offset,
1602 "Vcc vpi:%d vci:%d, Recv_vcc vpi:%d vci:%d Last_used:%lx, Timestamp:%lx, No_tries:%d ",
1603 rulla->vcc?rulla->vcc->vpi:0,
1604 rulla->vcc?rulla->vcc->vci:0,
1605 rulla->recv_vcc?rulla->recv_vcc->vpi:0,
1606 rulla->recv_vcc?rulla->recv_vcc->vci:0,
1608 rulla->timestamp, rulla->no_tries);
1609 offset+=sprintf(buf+offset,
1610 "Flags:%x, Packets_flooded:%x, Status: %s ",
1611 rulla->flags, rulla->packets_flooded,
1612 get_status_string(rulla->status));
1613 offset+=sprintf(buf+offset,"->%lx\n",(long)rulla->next);
1614 rulla = rulla->next;
1620 printk("Multicast Forward VCCs\n");
1623 offset += sprintf(buf+offset,"Mac:");
1624 for(j=0;j<ETH_ALEN;j++) {
1625 offset+=sprintf(buf+offset,"%2.2x ",
1626 rulla->mac_addr[j]&0xff);
1628 offset +=sprintf(buf+offset,"Atm:");
1629 for(j=0;j<ATM_ESA_LEN;j++) {
1630 offset+=sprintf(buf+offset,"%2.2x ",
1631 rulla->atm_addr[j]&0xff);
1633 offset+=sprintf(buf+offset,
1634 "Vcc vpi:%d vci:%d, Recv_vcc vpi:%d vci:%d Last_used:%lx, Timestamp:%lx, No_tries:%d ",
1635 rulla->vcc?rulla->vcc->vpi:0,
1636 rulla->vcc?rulla->vcc->vci:0,
1637 rulla->recv_vcc?rulla->recv_vcc->vpi:0,
1638 rulla->recv_vcc?rulla->recv_vcc->vci:0,
1640 rulla->timestamp, rulla->no_tries);
1641 offset+=sprintf(buf+offset,
1642 "Flags:%x, Packets_flooded:%x, Status: %s ",
1643 rulla->flags, rulla->packets_flooded,
1644 get_status_string(rulla->status));
1645 offset+=sprintf(buf+offset,"->%lx\n",(long)rulla->next);
1646 rulla = rulla->next;
1654 * Destruction of arp-cache
1657 lec_arp_destroy(struct lec_priv *priv)
1659 struct lec_arp_table *entry, *next;
1662 del_timer_sync(&priv->lec_arp_timer);
1665 * Remove all entries
1667 for (i=0;i<LEC_ARP_TABLE_SIZE;i++) {
1668 for(entry =priv->lec_arp_tables[i];entry != NULL; entry=next) {
1670 lec_arp_remove(priv, entry);
1674 entry = priv->lec_arp_empty_ones;
1677 del_timer_sync(&entry->timer);
1678 lec_arp_clear_vccs(entry);
1682 priv->lec_arp_empty_ones = NULL;
1683 entry = priv->lec_no_forward;
1686 del_timer_sync(&entry->timer);
1687 lec_arp_clear_vccs(entry);
1691 priv->lec_no_forward = NULL;
1692 entry = priv->mcast_fwds;
1695 /* No timer, LANEv2 7.1.20 and 2.3.5.3 */
1696 lec_arp_clear_vccs(entry);
1700 priv->mcast_fwds = NULL;
1701 priv->mcast_vcc = NULL;
1702 memset(priv->lec_arp_tables, 0,
1703 sizeof(struct lec_arp_table*)*LEC_ARP_TABLE_SIZE);
1708 * Find entry by mac_address
1710 static inline struct lec_arp_table*
1711 lec_arp_find(struct lec_priv *priv,
1712 unsigned char *mac_addr)
1714 unsigned short place;
1715 struct lec_arp_table *to_return;
1717 DPRINTK("LEC_ARP: lec_arp_find :%2.2x %2.2x %2.2x %2.2x %2.2x %2.2x\n",
1718 mac_addr[0]&0xff, mac_addr[1]&0xff, mac_addr[2]&0xff,
1719 mac_addr[3]&0xff, mac_addr[4]&0xff, mac_addr[5]&0xff);
1721 place = HASH(mac_addr[ETH_ALEN-1]);
1723 to_return = priv->lec_arp_tables[place];
1725 if (memcmp(mac_addr, to_return->mac_addr, ETH_ALEN) == 0) {
1729 to_return = to_return->next;
1735 static struct lec_arp_table*
1736 make_entry(struct lec_priv *priv, unsigned char *mac_addr)
1738 struct lec_arp_table *to_return;
1740 to_return=(struct lec_arp_table *)kmalloc(sizeof(struct lec_arp_table),
1743 printk("LEC: Arp entry kmalloc failed\n");
1746 memset(to_return,0,sizeof(struct lec_arp_table));
1747 memcpy(to_return->mac_addr, mac_addr, ETH_ALEN);
1748 init_timer(&to_return->timer);
1749 to_return->timer.function = lec_arp_expire_arp;
1750 to_return->timer.data = (unsigned long)to_return;
1751 to_return->last_used = jiffies;
1752 to_return->priv = priv;
1753 skb_queue_head_init(&to_return->tx_wait);
1759 * Arp sent timer expired
1763 lec_arp_expire_arp(unsigned long data)
1765 struct lec_arp_table *entry;
1767 entry = (struct lec_arp_table *)data;
1769 DPRINTK("lec_arp_expire_arp\n");
1770 if (entry->status == ESI_ARP_PENDING) {
1771 if (entry->no_tries <= entry->priv->max_retry_count) {
1772 if (entry->is_rdesc)
1773 send_to_lecd(entry->priv, l_rdesc_arp_xmt, entry->mac_addr, NULL, NULL);
1775 send_to_lecd(entry->priv, l_arp_xmt, entry->mac_addr, NULL, NULL);
1778 mod_timer(&entry->timer, jiffies + (1*HZ));
1784 * Unknown/unused vcc expire, remove associated entry
1788 lec_arp_expire_vcc(unsigned long data)
1790 struct lec_arp_table *to_remove = (struct lec_arp_table*)data;
1791 struct lec_priv *priv = (struct lec_priv *)to_remove->priv;
1792 struct lec_arp_table *entry = NULL;
1794 del_timer(&to_remove->timer);
1796 DPRINTK("LEC_ARP %p %p: lec_arp_expire_vcc vpi:%d vci:%d\n",
1798 to_remove->vcc?to_remove->recv_vcc->vpi:0,
1799 to_remove->vcc?to_remove->recv_vcc->vci:0);
1800 DPRINTK("eo:%p nf:%p\n",priv->lec_arp_empty_ones,priv->lec_no_forward);
1801 if (to_remove == priv->lec_arp_empty_ones)
1802 priv->lec_arp_empty_ones = to_remove->next;
1804 entry = priv->lec_arp_empty_ones;
1805 while (entry && entry->next != to_remove)
1806 entry = entry->next;
1808 entry->next = to_remove->next;
1811 if (to_remove == priv->lec_no_forward) {
1812 priv->lec_no_forward = to_remove->next;
1814 entry = priv->lec_no_forward;
1815 while (entry && entry->next != to_remove)
1816 entry = entry->next;
1818 entry->next = to_remove->next;
1821 lec_arp_clear_vccs(to_remove);
1828 * 2. For each entry, delete entries that have aged past the age limit.
1829 * 3. For each entry, depending on the status of the entry, perform
1830 * the following maintenance.
1831 * a. If status is ESI_VC_PENDING or ESI_ARP_PENDING then if the
1832 * tick_count is above the max_unknown_frame_time, clear
1833 * the tick_count to zero and clear the packets_flooded counter
1834 * to zero. This supports the packet rate limit per address
1835 * while flooding unknowns.
1836 * b. If the status is ESI_FLUSH_PENDING and the tick_count is greater
1837 * than or equal to the path_switching_delay, change the status
1838 * to ESI_FORWARD_DIRECT. This causes the flush period to end
1839 * regardless of the progress of the flush protocol.
1842 lec_arp_check_expire(unsigned long data)
1844 struct lec_priv *priv = (struct lec_priv *)data;
1845 struct lec_arp_table *entry, *next;
1847 unsigned long time_to_check;
1850 DPRINTK("lec_arp_check_expire %p,%d\n",priv,
1851 atomic_read(&priv->lec_arp_users));
1852 DPRINTK("expire: eo:%p nf:%p\n",priv->lec_arp_empty_ones,
1853 priv->lec_no_forward);
1854 if (!atomic_read(&priv->lec_arp_users)) {
1857 for(i=0;i<LEC_ARP_TABLE_SIZE;i++) {
1858 for(entry = priv->lec_arp_tables[i]; entry != NULL; ) {
1859 if ((entry->flags) & LEC_REMOTE_FLAG &&
1860 priv->topology_change)
1861 time_to_check=priv->forward_delay_time;
1863 time_to_check = priv->aging_time;
1865 DPRINTK("About to expire: %lx - %lx > %lx\n",
1866 now,entry->last_used, time_to_check);
1867 if( time_after(now, entry->last_used+
1869 !(entry->flags & LEC_PERMANENT_FLAG) &&
1870 !(entry->mac_addr[0] & 0x01) ) { /* LANE2: 7.1.20 */
1872 DPRINTK("LEC:Entry timed out\n");
1874 lec_arp_remove(priv, entry);
1878 /* Something else */
1879 if ((entry->status == ESI_VC_PENDING ||
1880 entry->status == ESI_ARP_PENDING)
1881 && time_after_eq(now,
1883 priv->max_unknown_frame_time)) {
1884 entry->timestamp = jiffies;
1885 entry->packets_flooded = 0;
1886 if (entry->status == ESI_VC_PENDING)
1887 send_to_lecd(priv, l_svc_setup, entry->mac_addr, entry->atm_addr, NULL);
1889 if (entry->status == ESI_FLUSH_PENDING
1891 time_after_eq(now, entry->timestamp+
1892 priv->path_switching_delay)) {
1893 struct sk_buff *skb;
1895 while ((skb = skb_dequeue(&entry->tx_wait)))
1896 lec_send(entry->vcc, skb, entry->priv);
1897 entry->last_used = jiffies;
1901 entry = entry->next;
1908 mod_timer(&priv->lec_arp_timer, jiffies + LEC_ARP_REFRESH_INTERVAL);
1911 * Try to find vcc where mac_address is attached.
1915 lec_arp_resolve(struct lec_priv *priv, unsigned char *mac_to_find, int is_rdesc,
1916 struct lec_arp_table **ret_entry)
1918 struct lec_arp_table *entry;
1920 if (mac_to_find[0]&0x01) {
1921 switch (priv->lane_version) {
1923 return priv->mcast_vcc;
1925 case 2: /* LANE2 wants arp for multicast addresses */
1926 if ( memcmp(mac_to_find, bus_mac, ETH_ALEN) == 0)
1927 return priv->mcast_vcc;
1934 entry = lec_arp_find(priv, mac_to_find);
1937 if (entry->status == ESI_FORWARD_DIRECT) {
1939 entry->last_used = jiffies;
1943 /* Data direct VC not yet set up, check to see if the unknown
1944 frame count is greater than the limit. If the limit has
1945 not been reached, allow the caller to send packet to
1947 if (entry->status != ESI_FLUSH_PENDING &&
1948 entry->packets_flooded<priv->maximum_unknown_frame_count) {
1949 entry->packets_flooded++;
1950 DPRINTK("LEC_ARP: Flooding..\n");
1951 return priv->mcast_vcc;
1953 /* We got here because entry->status == ESI_FLUSH_PENDING
1954 * or BUS flood limit was reached for an entry which is
1955 * in ESI_ARP_PENDING or ESI_VC_PENDING state.
1958 DPRINTK("lec: entry->status %d entry->vcc %p\n", entry->status, entry->vcc);
1961 /* No matching entry was found */
1962 entry = make_entry(priv, mac_to_find);
1963 DPRINTK("LEC_ARP: Making entry\n");
1965 return priv->mcast_vcc;
1967 lec_arp_add(priv, entry);
1968 /* We want arp-request(s) to be sent */
1969 entry->packets_flooded =1;
1970 entry->status = ESI_ARP_PENDING;
1971 entry->no_tries = 1;
1972 entry->last_used = entry->timestamp = jiffies;
1973 entry->is_rdesc = is_rdesc;
1974 if (entry->is_rdesc)
1975 send_to_lecd(priv, l_rdesc_arp_xmt, mac_to_find, NULL, NULL);
1977 send_to_lecd(priv, l_arp_xmt, mac_to_find, NULL, NULL);
1978 entry->timer.expires = jiffies + (1*HZ);
1979 entry->timer.function = lec_arp_expire_arp;
1980 add_timer(&entry->timer);
1981 return priv->mcast_vcc;
1986 lec_addr_delete(struct lec_priv *priv, unsigned char *atm_addr,
1987 unsigned long permanent)
1989 struct lec_arp_table *entry, *next;
1993 DPRINTK("lec_addr_delete\n");
1994 for(i=0;i<LEC_ARP_TABLE_SIZE;i++) {
1995 for(entry=priv->lec_arp_tables[i];entry != NULL; entry=next) {
1997 if (!memcmp(atm_addr, entry->atm_addr, ATM_ESA_LEN)
1999 !(entry->flags & LEC_PERMANENT_FLAG))) {
2000 lec_arp_remove(priv, entry);
2012 * Notifies: Response to arp_request (atm_addr != NULL)
2015 lec_arp_update(struct lec_priv *priv, unsigned char *mac_addr,
2016 unsigned char *atm_addr, unsigned long remoteflag,
2017 unsigned int targetless_le_arp)
2019 struct lec_arp_table *entry, *tmp;
2022 DPRINTK("lec:%s", (targetless_le_arp) ? "targetless ": " ");
2023 DPRINTK("lec_arp_update mac:%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x\n",
2024 mac_addr[0],mac_addr[1],mac_addr[2],mac_addr[3],
2025 mac_addr[4],mac_addr[5]);
2027 entry = lec_arp_find(priv, mac_addr);
2028 if (entry == NULL && targetless_le_arp)
2029 return; /* LANE2: ignore targetless LE_ARPs for which
2030 * we have no entry in the cache. 7.1.30
2033 if (priv->lec_arp_empty_ones) {
2034 entry = priv->lec_arp_empty_ones;
2035 if (!memcmp(entry->atm_addr, atm_addr, ATM_ESA_LEN)) {
2036 priv->lec_arp_empty_ones = entry->next;
2038 while(entry->next && memcmp(entry->next->atm_addr,
2039 atm_addr, ATM_ESA_LEN))
2040 entry = entry->next;
2043 entry = entry->next;
2044 tmp->next = entry->next;
2050 del_timer(&entry->timer);
2051 tmp = lec_arp_find(priv, mac_addr);
2053 del_timer(&tmp->timer);
2054 tmp->status = ESI_FORWARD_DIRECT;
2055 memcpy(tmp->atm_addr, atm_addr, ATM_ESA_LEN);
2056 tmp->vcc = entry->vcc;
2057 tmp->old_push = entry->old_push;
2058 tmp->last_used = jiffies;
2059 del_timer(&entry->timer);
2063 entry->status = ESI_FORWARD_DIRECT;
2064 memcpy(entry->mac_addr, mac_addr, ETH_ALEN);
2065 entry->last_used = jiffies;
2066 lec_arp_add(priv, entry);
2069 entry->flags|=LEC_REMOTE_FLAG;
2071 entry->flags&=~LEC_REMOTE_FLAG;
2073 DPRINTK("After update\n");
2074 dump_arp_table(priv);
2078 entry = lec_arp_find(priv, mac_addr);
2080 entry = make_entry(priv, mac_addr);
2085 entry->status = ESI_UNKNOWN;
2086 lec_arp_add(priv, entry);
2087 /* Temporary, changes before end of function */
2089 memcpy(entry->atm_addr, atm_addr, ATM_ESA_LEN);
2090 del_timer(&entry->timer);
2091 for(i=0;i<LEC_ARP_TABLE_SIZE;i++) {
2092 for(tmp=priv->lec_arp_tables[i];tmp;tmp=tmp->next) {
2094 !memcmp(tmp->atm_addr, atm_addr,
2096 /* Vcc to this host exists */
2097 if (tmp->status > ESI_VC_PENDING) {
2099 * ESI_FLUSH_PENDING,
2100 * ESI_FORWARD_DIRECT
2102 entry->vcc = tmp->vcc;
2103 entry->old_push=tmp->old_push;
2105 entry->status=tmp->status;
2111 entry->flags|=LEC_REMOTE_FLAG;
2113 entry->flags&=~LEC_REMOTE_FLAG;
2114 if (entry->status == ESI_ARP_PENDING ||
2115 entry->status == ESI_UNKNOWN) {
2116 entry->status = ESI_VC_PENDING;
2117 send_to_lecd(priv, l_svc_setup, entry->mac_addr, atm_addr, NULL);
2119 DPRINTK("After update2\n");
2120 dump_arp_table(priv);
2125 * Notifies: Vcc setup ready
2128 lec_vcc_added(struct lec_priv *priv, struct atmlec_ioc *ioc_data,
2129 struct atm_vcc *vcc,
2130 void (*old_push)(struct atm_vcc *vcc, struct sk_buff *skb))
2132 struct lec_arp_table *entry;
2133 int i, found_entry=0;
2136 if (ioc_data->receive == 2) {
2137 /* Vcc for Multicast Forward. No timer, LANEv2 7.1.20 and 2.3.5.3 */
2139 DPRINTK("LEC_ARP: Attaching mcast forward\n");
2141 entry = lec_arp_find(priv, bus_mac);
2143 printk("LEC_ARP: Multicast entry not found!\n");
2147 memcpy(entry->atm_addr, ioc_data->atm_addr, ATM_ESA_LEN);
2148 entry->recv_vcc = vcc;
2149 entry->old_recv_push = old_push;
2151 entry = make_entry(priv, bus_mac);
2152 if (entry == NULL) {
2156 del_timer(&entry->timer);
2157 memcpy(entry->atm_addr, ioc_data->atm_addr, ATM_ESA_LEN);
2158 entry->recv_vcc = vcc;
2159 entry->old_recv_push = old_push;
2160 entry->next = priv->mcast_fwds;
2161 priv->mcast_fwds = entry;
2164 } else if (ioc_data->receive == 1) {
2165 /* Vcc which we don't want to make default vcc, attach it
2167 DPRINTK("LEC_ARP:Attaching data direct, not default :%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x\n",
2168 ioc_data->atm_addr[0],ioc_data->atm_addr[1],
2169 ioc_data->atm_addr[2],ioc_data->atm_addr[3],
2170 ioc_data->atm_addr[4],ioc_data->atm_addr[5],
2171 ioc_data->atm_addr[6],ioc_data->atm_addr[7],
2172 ioc_data->atm_addr[8],ioc_data->atm_addr[9],
2173 ioc_data->atm_addr[10],ioc_data->atm_addr[11],
2174 ioc_data->atm_addr[12],ioc_data->atm_addr[13],
2175 ioc_data->atm_addr[14],ioc_data->atm_addr[15],
2176 ioc_data->atm_addr[16],ioc_data->atm_addr[17],
2177 ioc_data->atm_addr[18],ioc_data->atm_addr[19]);
2178 entry = make_entry(priv, bus_mac);
2179 if (entry == NULL) {
2183 memcpy(entry->atm_addr, ioc_data->atm_addr, ATM_ESA_LEN);
2184 memset(entry->mac_addr, 0, ETH_ALEN);
2185 entry->recv_vcc = vcc;
2186 entry->old_recv_push = old_push;
2187 entry->status = ESI_UNKNOWN;
2188 entry->timer.expires = jiffies + priv->vcc_timeout_period;
2189 entry->timer.function = lec_arp_expire_vcc;
2190 add_timer(&entry->timer);
2191 entry->next = priv->lec_no_forward;
2192 priv->lec_no_forward = entry;
2194 dump_arp_table(priv);
2197 DPRINTK("LEC_ARP:Attaching data direct, default:%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x\n",
2198 ioc_data->atm_addr[0],ioc_data->atm_addr[1],
2199 ioc_data->atm_addr[2],ioc_data->atm_addr[3],
2200 ioc_data->atm_addr[4],ioc_data->atm_addr[5],
2201 ioc_data->atm_addr[6],ioc_data->atm_addr[7],
2202 ioc_data->atm_addr[8],ioc_data->atm_addr[9],
2203 ioc_data->atm_addr[10],ioc_data->atm_addr[11],
2204 ioc_data->atm_addr[12],ioc_data->atm_addr[13],
2205 ioc_data->atm_addr[14],ioc_data->atm_addr[15],
2206 ioc_data->atm_addr[16],ioc_data->atm_addr[17],
2207 ioc_data->atm_addr[18],ioc_data->atm_addr[19]);
2208 for (i=0;i<LEC_ARP_TABLE_SIZE;i++) {
2209 for (entry = priv->lec_arp_tables[i];entry;entry=entry->next) {
2210 if (memcmp(ioc_data->atm_addr, entry->atm_addr,
2212 DPRINTK("LEC_ARP: Attaching data direct\n");
2213 DPRINTK("Currently -> Vcc: %d, Rvcc:%d\n",
2214 entry->vcc?entry->vcc->vci:0,
2215 entry->recv_vcc?entry->recv_vcc->vci:0);
2217 del_timer(&entry->timer);
2219 entry->old_push = old_push;
2220 if (entry->status == ESI_VC_PENDING) {
2221 if(priv->maximum_unknown_frame_count
2226 entry->timestamp = jiffies;
2230 send_to_lecd(priv,l_flush_xmt,
2237 /* They were forming a connection
2238 to us, and we to them. Our
2239 ATM address is numerically lower
2240 than theirs, so we make connection
2241 we formed into default VCC (8.1.11).
2242 Connection they made gets torn
2243 down. This might confuse some
2244 clients. Can be changed if
2245 someone reports trouble... */
2253 DPRINTK("After vcc was added\n");
2254 dump_arp_table(priv);
2257 /* Not found, snatch address from first data packet that arrives from
2259 entry = make_entry(priv, bus_mac);
2265 entry->old_push = old_push;
2266 memcpy(entry->atm_addr, ioc_data->atm_addr, ATM_ESA_LEN);
2267 memset(entry->mac_addr, 0, ETH_ALEN);
2268 entry->status = ESI_UNKNOWN;
2269 entry->next = priv->lec_arp_empty_ones;
2270 priv->lec_arp_empty_ones = entry;
2271 entry->timer.expires = jiffies + priv->vcc_timeout_period;
2272 entry->timer.function = lec_arp_expire_vcc;
2273 add_timer(&entry->timer);
2275 DPRINTK("After vcc was added\n");
2276 dump_arp_table(priv);
2280 lec_flush_complete(struct lec_priv *priv, unsigned long tran_id)
2282 struct lec_arp_table *entry;
2285 DPRINTK("LEC:lec_flush_complete %lx\n",tran_id);
2286 for (i=0;i<LEC_ARP_TABLE_SIZE;i++) {
2287 for (entry=priv->lec_arp_tables[i];entry;entry=entry->next) {
2288 if (entry->flush_tran_id == tran_id &&
2289 entry->status == ESI_FLUSH_PENDING) {
2290 struct sk_buff *skb;
2292 while ((skb = skb_dequeue(&entry->tx_wait)))
2293 lec_send(entry->vcc, skb, entry->priv);
2294 entry->status = ESI_FORWARD_DIRECT;
2295 DPRINTK("LEC_ARP: Flushed\n");
2299 dump_arp_table(priv);
2303 lec_set_flush_tran_id(struct lec_priv *priv,
2304 unsigned char *atm_addr, unsigned long tran_id)
2306 struct lec_arp_table *entry;
2309 for (i=0;i<LEC_ARP_TABLE_SIZE;i++)
2310 for(entry=priv->lec_arp_tables[i];entry;entry=entry->next)
2311 if (!memcmp(atm_addr, entry->atm_addr, ATM_ESA_LEN)) {
2312 entry->flush_tran_id = tran_id;
2313 DPRINTK("Set flush transaction id to %lx for %p\n",tran_id,entry);
2318 lec_mcast_make(struct lec_priv *priv, struct atm_vcc *vcc)
2320 unsigned char mac_addr[] = {
2321 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
2322 struct lec_arp_table *to_add;
2325 to_add = make_entry(priv, mac_addr);
2330 memcpy(to_add->atm_addr, vcc->remote.sas_addr.prv, ATM_ESA_LEN);
2331 to_add->status = ESI_FORWARD_DIRECT;
2332 to_add->flags |= LEC_PERMANENT_FLAG;
2334 to_add->old_push = vcc->push;
2335 vcc->push = lec_push;
2336 priv->mcast_vcc = vcc;
2337 lec_arp_add(priv, to_add);
2343 lec_vcc_close(struct lec_priv *priv, struct atm_vcc *vcc)
2345 struct lec_arp_table *entry, *next;
2348 DPRINTK("LEC_ARP: lec_vcc_close vpi:%d vci:%d\n",vcc->vpi,vcc->vci);
2349 dump_arp_table(priv);
2351 for(i=0;i<LEC_ARP_TABLE_SIZE;i++) {
2352 for(entry = priv->lec_arp_tables[i];entry; entry=next) {
2354 if (vcc == entry->vcc) {
2355 lec_arp_remove(priv, entry);
2357 if (priv->mcast_vcc == vcc) {
2358 priv->mcast_vcc = NULL;
2364 entry = priv->lec_arp_empty_ones;
2365 priv->lec_arp_empty_ones = NULL;
2366 while (entry != NULL) {
2368 if (entry->vcc == vcc) { /* leave it out from the list */
2369 lec_arp_clear_vccs(entry);
2370 del_timer(&entry->timer);
2373 else { /* put it back to the list */
2374 entry->next = priv->lec_arp_empty_ones;
2375 priv->lec_arp_empty_ones = entry;
2380 entry = priv->lec_no_forward;
2381 priv->lec_no_forward = NULL;
2382 while (entry != NULL) {
2384 if (entry->recv_vcc == vcc) {
2385 lec_arp_clear_vccs(entry);
2386 del_timer(&entry->timer);
2390 entry->next = priv->lec_no_forward;
2391 priv->lec_no_forward = entry;
2396 entry = priv->mcast_fwds;
2397 priv->mcast_fwds = NULL;
2398 while (entry != NULL) {
2400 if (entry->recv_vcc == vcc) {
2401 lec_arp_clear_vccs(entry);
2402 /* No timer, LANEv2 7.1.20 and 2.3.5.3 */
2406 entry->next = priv->mcast_fwds;
2407 priv->mcast_fwds = entry;
2413 dump_arp_table(priv);
2417 lec_arp_check_empties(struct lec_priv *priv,
2418 struct atm_vcc *vcc, struct sk_buff *skb)
2420 unsigned long flags;
2421 struct lec_arp_table *entry, *prev;
2422 struct lecdatahdr_8023 *hdr = (struct lecdatahdr_8023 *)skb->data;
2425 struct lecdatahdr_8025 *tr_hdr = (struct lecdatahdr_8025 *)skb->data;
2427 if (priv->is_trdev) src = tr_hdr->h_source;
2430 src = hdr->h_source;
2433 entry = priv->lec_arp_empty_ones;
2434 if (vcc == entry->vcc) {
2435 spin_lock_irqsave(&priv->lec_arp_lock, flags);
2436 del_timer(&entry->timer);
2437 memcpy(entry->mac_addr, src, ETH_ALEN);
2438 entry->status = ESI_FORWARD_DIRECT;
2439 entry->last_used = jiffies;
2440 priv->lec_arp_empty_ones = entry->next;
2441 spin_unlock_irqrestore(&priv->lec_arp_lock, flags);
2442 /* We might have got an entry */
2443 if ((prev=lec_arp_find(priv,src))) {
2444 lec_arp_remove(priv, prev);
2447 lec_arp_add(priv, entry);
2451 spin_lock_irqsave(&priv->lec_arp_lock, flags);
2453 entry = entry->next;
2454 while (entry && entry->vcc != vcc) {
2456 entry = entry->next;
2459 DPRINTK("LEC_ARP: Arp_check_empties: entry not found!\n");
2461 spin_unlock_irqrestore(&priv->lec_arp_lock, flags);
2464 del_timer(&entry->timer);
2465 memcpy(entry->mac_addr, src, ETH_ALEN);
2466 entry->status = ESI_FORWARD_DIRECT;
2467 entry->last_used = jiffies;
2468 prev->next = entry->next;
2469 spin_unlock_irqrestore(&priv->lec_arp_lock, flags);
2470 if ((prev = lec_arp_find(priv, src))) {
2471 lec_arp_remove(priv, prev);
2474 lec_arp_add(priv, entry);
2477 MODULE_LICENSE("GPL");