aboutsummaryrefslogtreecommitdiffstats
path: root/net/atm/lec.c
diff options
context:
space:
mode:
authorAndrea Bastoni <bastoni@cs.unc.edu>2010-05-30 19:16:45 -0400
committerAndrea Bastoni <bastoni@cs.unc.edu>2010-05-30 19:16:45 -0400
commitada47b5fe13d89735805b566185f4885f5a3f750 (patch)
tree644b88f8a71896307d71438e9b3af49126ffb22b /net/atm/lec.c
parent43e98717ad40a4ae64545b5ba047c7b86aa44f4f (diff)
parent3280f21d43ee541f97f8cda5792150d2dbec20d5 (diff)
Merge branch 'wip-2.6.34' into old-private-masterarchived-private-master
Diffstat (limited to 'net/atm/lec.c')
-rw-r--r--net/atm/lec.c610
1 files changed, 285 insertions, 325 deletions
diff --git a/net/atm/lec.c b/net/atm/lec.c
index b2d644560323..feeaf5718472 100644
--- a/net/atm/lec.c
+++ b/net/atm/lec.c
@@ -4,6 +4,9 @@
4 * Marko Kiiskila <mkiiskila@yahoo.com> 4 * Marko Kiiskila <mkiiskila@yahoo.com>
5 */ 5 */
6 6
7#define pr_fmt(fmt) KBUILD_MODNAME ":%s: " fmt, __func__
8
9#include <linux/slab.h>
7#include <linux/kernel.h> 10#include <linux/kernel.h>
8#include <linux/bitops.h> 11#include <linux/bitops.h>
9#include <linux/capability.h> 12#include <linux/capability.h>
@@ -16,7 +19,7 @@
16#include <linux/skbuff.h> 19#include <linux/skbuff.h>
17#include <linux/ip.h> 20#include <linux/ip.h>
18#include <asm/byteorder.h> 21#include <asm/byteorder.h>
19#include <asm/uaccess.h> 22#include <linux/uaccess.h>
20#include <net/arp.h> 23#include <net/arp.h>
21#include <net/dst.h> 24#include <net/dst.h>
22#include <linux/proc_fs.h> 25#include <linux/proc_fs.h>
@@ -62,7 +65,6 @@ static int lec_open(struct net_device *dev);
62static netdev_tx_t lec_start_xmit(struct sk_buff *skb, 65static netdev_tx_t lec_start_xmit(struct sk_buff *skb,
63 struct net_device *dev); 66 struct net_device *dev);
64static int lec_close(struct net_device *dev); 67static int lec_close(struct net_device *dev);
65static void lec_init(struct net_device *dev);
66static struct lec_arp_table *lec_arp_find(struct lec_priv *priv, 68static struct lec_arp_table *lec_arp_find(struct lec_priv *priv,
67 const unsigned char *mac_addr); 69 const unsigned char *mac_addr);
68static int lec_arp_remove(struct lec_priv *priv, 70static int lec_arp_remove(struct lec_priv *priv,
@@ -86,17 +88,19 @@ static struct atm_vcc *lec_arp_resolve(struct lec_priv *priv,
86 int is_rdesc, 88 int is_rdesc,
87 struct lec_arp_table **ret_entry); 89 struct lec_arp_table **ret_entry);
88static void lec_arp_update(struct lec_priv *priv, const unsigned char *mac_addr, 90static void lec_arp_update(struct lec_priv *priv, const unsigned char *mac_addr,
89 const unsigned char *atm_addr, unsigned long remoteflag, 91 const unsigned char *atm_addr,
92 unsigned long remoteflag,
90 unsigned int targetless_le_arp); 93 unsigned int targetless_le_arp);
91static void lec_flush_complete(struct lec_priv *priv, unsigned long tran_id); 94static void lec_flush_complete(struct lec_priv *priv, unsigned long tran_id);
92static int lec_mcast_make(struct lec_priv *priv, struct atm_vcc *vcc); 95static int lec_mcast_make(struct lec_priv *priv, struct atm_vcc *vcc);
93static void lec_set_flush_tran_id(struct lec_priv *priv, 96static void lec_set_flush_tran_id(struct lec_priv *priv,
94 const unsigned char *atm_addr, 97 const unsigned char *atm_addr,
95 unsigned long tran_id); 98 unsigned long tran_id);
96static void lec_vcc_added(struct lec_priv *priv, const struct atmlec_ioc *ioc_data, 99static void lec_vcc_added(struct lec_priv *priv,
100 const struct atmlec_ioc *ioc_data,
97 struct atm_vcc *vcc, 101 struct atm_vcc *vcc,
98 void (*old_push) (struct atm_vcc *vcc, 102 void (*old_push)(struct atm_vcc *vcc,
99 struct sk_buff *skb)); 103 struct sk_buff *skb));
100static void lec_vcc_close(struct lec_priv *priv, struct atm_vcc *vcc); 104static void lec_vcc_close(struct lec_priv *priv, struct atm_vcc *vcc);
101 105
102/* must be done under lec_arp_lock */ 106/* must be done under lec_arp_lock */
@@ -111,7 +115,6 @@ static inline void lec_arp_put(struct lec_arp_table *entry)
111 kfree(entry); 115 kfree(entry);
112} 116}
113 117
114
115static struct lane2_ops lane2_ops = { 118static struct lane2_ops lane2_ops = {
116 lane2_resolve, /* resolve, spec 3.1.3 */ 119 lane2_resolve, /* resolve, spec 3.1.3 */
117 lane2_associate_req, /* associate_req, spec 3.1.4 */ 120 lane2_associate_req, /* associate_req, spec 3.1.4 */
@@ -149,7 +152,8 @@ static void lec_handle_bridge(struct sk_buff *skb, struct net_device *dev)
149 mesg = (struct atmlec_msg *)skb2->data; 152 mesg = (struct atmlec_msg *)skb2->data;
150 mesg->type = l_topology_change; 153 mesg->type = l_topology_change;
151 buff += 4; 154 buff += 4;
152 mesg->content.normal.flag = *buff & 0x01; /* 0x01 is topology change */ 155 mesg->content.normal.flag = *buff & 0x01;
156 /* 0x01 is topology change */
153 157
154 priv = netdev_priv(dev); 158 priv = netdev_priv(dev);
155 atm_force_charge(priv->lecd, skb2->truesize); 159 atm_force_charge(priv->lecd, skb2->truesize);
@@ -243,7 +247,7 @@ lec_send(struct atm_vcc *vcc, struct sk_buff *skb)
243 247
244static void lec_tx_timeout(struct net_device *dev) 248static void lec_tx_timeout(struct net_device *dev)
245{ 249{
246 printk(KERN_INFO "%s: tx timeout\n", dev->name); 250 pr_info("%s\n", dev->name);
247 dev->trans_start = jiffies; 251 dev->trans_start = jiffies;
248 netif_wake_queue(dev); 252 netif_wake_queue(dev);
249} 253}
@@ -262,14 +266,10 @@ static netdev_tx_t lec_start_xmit(struct sk_buff *skb,
262 unsigned char rdesc[ETH_ALEN]; /* Token Ring route descriptor */ 266 unsigned char rdesc[ETH_ALEN]; /* Token Ring route descriptor */
263#endif 267#endif
264 int is_rdesc; 268 int is_rdesc;
265#if DUMP_PACKETS > 0
266 char buf[300];
267 int i = 0;
268#endif /* DUMP_PACKETS >0 */
269 269
270 pr_debug("lec_start_xmit called\n"); 270 pr_debug("called\n");
271 if (!priv->lecd) { 271 if (!priv->lecd) {
272 printk("%s:No lecd attached\n", dev->name); 272 pr_info("%s:No lecd attached\n", dev->name);
273 dev->stats.tx_errors++; 273 dev->stats.tx_errors++;
274 netif_stop_queue(dev); 274 netif_stop_queue(dev);
275 kfree_skb(skb); 275 kfree_skb(skb);
@@ -277,8 +277,8 @@ static netdev_tx_t lec_start_xmit(struct sk_buff *skb,
277 } 277 }
278 278
279 pr_debug("skbuff head:%lx data:%lx tail:%lx end:%lx\n", 279 pr_debug("skbuff head:%lx data:%lx tail:%lx end:%lx\n",
280 (long)skb->head, (long)skb->data, (long)skb_tail_pointer(skb), 280 (long)skb->head, (long)skb->data, (long)skb_tail_pointer(skb),
281 (long)skb_end_pointer(skb)); 281 (long)skb_end_pointer(skb));
282#if defined(CONFIG_BRIDGE) || defined(CONFIG_BRIDGE_MODULE) 282#if defined(CONFIG_BRIDGE) || defined(CONFIG_BRIDGE_MODULE)
283 if (memcmp(skb->data, bridge_ula_lec, sizeof(bridge_ula_lec)) == 0) 283 if (memcmp(skb->data, bridge_ula_lec, sizeof(bridge_ula_lec)) == 0)
284 lec_handle_bridge(skb, dev); 284 lec_handle_bridge(skb, dev);
@@ -286,8 +286,7 @@ static netdev_tx_t lec_start_xmit(struct sk_buff *skb,
286 286
287 /* Make sure we have room for lec_id */ 287 /* Make sure we have room for lec_id */
288 if (skb_headroom(skb) < 2) { 288 if (skb_headroom(skb) < 2) {
289 289 pr_debug("reallocating skb\n");
290 pr_debug("lec_start_xmit: reallocating skb\n");
291 skb2 = skb_realloc_headroom(skb, LEC_HEADER_LEN); 290 skb2 = skb_realloc_headroom(skb, LEC_HEADER_LEN);
292 kfree_skb(skb); 291 kfree_skb(skb);
293 if (skb2 == NULL) 292 if (skb2 == NULL)
@@ -314,23 +313,17 @@ static netdev_tx_t lec_start_xmit(struct sk_buff *skb,
314 } 313 }
315#endif 314#endif
316 315
317#if DUMP_PACKETS > 0
318 printk("%s: send datalen:%ld lecid:%4.4x\n", dev->name,
319 skb->len, priv->lecid);
320#if DUMP_PACKETS >= 2 316#if DUMP_PACKETS >= 2
321 for (i = 0; i < skb->len && i < 99; i++) { 317#define MAX_DUMP_SKB 99
322 sprintf(buf + i * 3, "%2.2x ", 0xff & skb->data[i]);
323 }
324#elif DUMP_PACKETS >= 1 318#elif DUMP_PACKETS >= 1
325 for (i = 0; i < skb->len && i < 30; i++) { 319#define MAX_DUMP_SKB 30
326 sprintf(buf + i * 3, "%2.2x ", 0xff & skb->data[i]); 320#endif
327 } 321#if DUMP_PACKETS >= 1
322 printk(KERN_DEBUG "%s: send datalen:%ld lecid:%4.4x\n",
323 dev->name, skb->len, priv->lecid);
324 print_hex_dump(KERN_DEBUG, "", DUMP_OFFSET, 16, 1,
325 skb->data, min(skb->len, MAX_DUMP_SKB), true);
328#endif /* DUMP_PACKETS >= 1 */ 326#endif /* DUMP_PACKETS >= 1 */
329 if (i == skb->len)
330 printk("%s\n", buf);
331 else
332 printk("%s...\n", buf);
333#endif /* DUMP_PACKETS > 0 */
334 327
335 /* Minimum ethernet-frame size */ 328 /* Minimum ethernet-frame size */
336#ifdef CONFIG_TR 329#ifdef CONFIG_TR
@@ -368,31 +361,28 @@ static netdev_tx_t lec_start_xmit(struct sk_buff *skb,
368#endif 361#endif
369 entry = NULL; 362 entry = NULL;
370 vcc = lec_arp_resolve(priv, dst, is_rdesc, &entry); 363 vcc = lec_arp_resolve(priv, dst, is_rdesc, &entry);
371 pr_debug("%s:vcc:%p vcc_flags:%lx, entry:%p\n", dev->name, 364 pr_debug("%s:vcc:%p vcc_flags:%lx, entry:%p\n",
372 vcc, vcc ? vcc->flags : 0, entry); 365 dev->name, vcc, vcc ? vcc->flags : 0, entry);
373 if (!vcc || !test_bit(ATM_VF_READY, &vcc->flags)) { 366 if (!vcc || !test_bit(ATM_VF_READY, &vcc->flags)) {
374 if (entry && (entry->tx_wait.qlen < LEC_UNRES_QUE_LEN)) { 367 if (entry && (entry->tx_wait.qlen < LEC_UNRES_QUE_LEN)) {
375 pr_debug("%s:lec_start_xmit: queuing packet, ", 368 pr_debug("%s:queuing packet, MAC address %pM\n",
376 dev->name); 369 dev->name, lec_h->h_dest);
377 pr_debug("MAC address %pM\n", lec_h->h_dest);
378 skb_queue_tail(&entry->tx_wait, skb); 370 skb_queue_tail(&entry->tx_wait, skb);
379 } else { 371 } else {
380 pr_debug 372 pr_debug("%s:tx queue full or no arp entry, dropping, MAC address: %pM\n",
381 ("%s:lec_start_xmit: tx queue full or no arp entry, dropping, ", 373 dev->name, lec_h->h_dest);
382 dev->name);
383 pr_debug("MAC address %pM\n", lec_h->h_dest);
384 dev->stats.tx_dropped++; 374 dev->stats.tx_dropped++;
385 dev_kfree_skb(skb); 375 dev_kfree_skb(skb);
386 } 376 }
387 goto out; 377 goto out;
388 } 378 }
389#if DUMP_PACKETS > 0 379#if DUMP_PACKETS > 0
390 printk("%s:sending to vpi:%d vci:%d\n", dev->name, vcc->vpi, vcc->vci); 380 printk(KERN_DEBUG "%s:sending to vpi:%d vci:%d\n",
381 dev->name, vcc->vpi, vcc->vci);
391#endif /* DUMP_PACKETS > 0 */ 382#endif /* DUMP_PACKETS > 0 */
392 383
393 while (entry && (skb2 = skb_dequeue(&entry->tx_wait))) { 384 while (entry && (skb2 = skb_dequeue(&entry->tx_wait))) {
394 pr_debug("lec.c: emptying tx queue, "); 385 pr_debug("emptying tx queue, MAC address %pM\n", lec_h->h_dest);
395 pr_debug("MAC address %pM\n", lec_h->h_dest);
396 lec_send(vcc, skb2); 386 lec_send(vcc, skb2);
397 } 387 }
398 388
@@ -445,14 +435,12 @@ static int lec_atm_send(struct atm_vcc *vcc, struct sk_buff *skb)
445 pr_debug("%s: msg from zeppelin:%d\n", dev->name, mesg->type); 435 pr_debug("%s: msg from zeppelin:%d\n", dev->name, mesg->type);
446 switch (mesg->type) { 436 switch (mesg->type) {
447 case l_set_mac_addr: 437 case l_set_mac_addr:
448 for (i = 0; i < 6; i++) { 438 for (i = 0; i < 6; i++)
449 dev->dev_addr[i] = mesg->content.normal.mac_addr[i]; 439 dev->dev_addr[i] = mesg->content.normal.mac_addr[i];
450 }
451 break; 440 break;
452 case l_del_mac_addr: 441 case l_del_mac_addr:
453 for (i = 0; i < 6; i++) { 442 for (i = 0; i < 6; i++)
454 dev->dev_addr[i] = 0; 443 dev->dev_addr[i] = 0;
455 }
456 break; 444 break;
457 case l_addr_delete: 445 case l_addr_delete:
458 lec_addr_delete(priv, mesg->content.normal.atm_addr, 446 lec_addr_delete(priv, mesg->content.normal.atm_addr,
@@ -478,10 +466,10 @@ static int lec_atm_send(struct atm_vcc *vcc, struct sk_buff *skb)
478 mesg->content.normal.atm_addr, 466 mesg->content.normal.atm_addr,
479 mesg->content.normal.flag, 467 mesg->content.normal.flag,
480 mesg->content.normal.targetless_le_arp); 468 mesg->content.normal.targetless_le_arp);
481 pr_debug("lec: in l_arp_update\n"); 469 pr_debug("in l_arp_update\n");
482 if (mesg->sizeoftlvs != 0) { /* LANE2 3.1.5 */ 470 if (mesg->sizeoftlvs != 0) { /* LANE2 3.1.5 */
483 pr_debug("lec: LANE2 3.1.5, got tlvs, size %d\n", 471 pr_debug("LANE2 3.1.5, got tlvs, size %d\n",
484 mesg->sizeoftlvs); 472 mesg->sizeoftlvs);
485 lane2_associate_ind(dev, mesg->content.normal.mac_addr, 473 lane2_associate_ind(dev, mesg->content.normal.mac_addr,
486 tmp, mesg->sizeoftlvs); 474 tmp, mesg->sizeoftlvs);
487 } 475 }
@@ -500,13 +488,14 @@ static int lec_atm_send(struct atm_vcc *vcc, struct sk_buff *skb)
500 priv->flush_timeout = (mesg->content.config.flush_timeout * HZ); 488 priv->flush_timeout = (mesg->content.config.flush_timeout * HZ);
501 priv->path_switching_delay = 489 priv->path_switching_delay =
502 (mesg->content.config.path_switching_delay * HZ); 490 (mesg->content.config.path_switching_delay * HZ);
503 priv->lane_version = mesg->content.config.lane_version; /* LANE2 */ 491 priv->lane_version = mesg->content.config.lane_version;
492 /* LANE2 */
504 priv->lane2_ops = NULL; 493 priv->lane2_ops = NULL;
505 if (priv->lane_version > 1) 494 if (priv->lane_version > 1)
506 priv->lane2_ops = &lane2_ops; 495 priv->lane2_ops = &lane2_ops;
507 if (dev_set_mtu(dev, mesg->content.config.mtu)) 496 if (dev_set_mtu(dev, mesg->content.config.mtu))
508 printk("%s: change_mtu to %d failed\n", dev->name, 497 pr_info("%s: change_mtu to %d failed\n",
509 mesg->content.config.mtu); 498 dev->name, mesg->content.config.mtu);
510 priv->is_proxy = mesg->content.config.is_proxy; 499 priv->is_proxy = mesg->content.config.is_proxy;
511 break; 500 break;
512 case l_flush_tran_id: 501 case l_flush_tran_id:
@@ -519,40 +508,35 @@ static int lec_atm_send(struct atm_vcc *vcc, struct sk_buff *skb)
519 break; 508 break;
520 case l_should_bridge: 509 case l_should_bridge:
521#if defined(CONFIG_BRIDGE) || defined(CONFIG_BRIDGE_MODULE) 510#if defined(CONFIG_BRIDGE) || defined(CONFIG_BRIDGE_MODULE)
522 { 511 {
523 pr_debug("%s: bridge zeppelin asks about %pM\n", 512 pr_debug("%s: bridge zeppelin asks about %pM\n",
524 dev->name, mesg->content.proxy.mac_addr); 513 dev->name, mesg->content.proxy.mac_addr);
525 514
526 if (br_fdb_test_addr_hook == NULL) 515 if (br_fdb_test_addr_hook == NULL)
527 break; 516 break;
528 517
529 if (br_fdb_test_addr_hook(dev, 518 if (br_fdb_test_addr_hook(dev, mesg->content.proxy.mac_addr)) {
530 mesg->content.proxy.mac_addr)) { 519 /* hit from bridge table, send LE_ARP_RESPONSE */
531 /* hit from bridge table, send LE_ARP_RESPONSE */ 520 struct sk_buff *skb2;
532 struct sk_buff *skb2; 521 struct sock *sk;
533 struct sock *sk; 522
534 523 pr_debug("%s: entry found, responding to zeppelin\n",
535 pr_debug 524 dev->name);
536 ("%s: entry found, responding to zeppelin\n", 525 skb2 = alloc_skb(sizeof(struct atmlec_msg), GFP_ATOMIC);
537 dev->name); 526 if (skb2 == NULL)
538 skb2 = 527 break;
539 alloc_skb(sizeof(struct atmlec_msg), 528 skb2->len = sizeof(struct atmlec_msg);
540 GFP_ATOMIC); 529 skb_copy_to_linear_data(skb2, mesg, sizeof(*mesg));
541 if (skb2 == NULL) 530 atm_force_charge(priv->lecd, skb2->truesize);
542 break; 531 sk = sk_atm(priv->lecd);
543 skb2->len = sizeof(struct atmlec_msg); 532 skb_queue_tail(&sk->sk_receive_queue, skb2);
544 skb_copy_to_linear_data(skb2, mesg, 533 sk->sk_data_ready(sk, skb2->len);
545 sizeof(*mesg));
546 atm_force_charge(priv->lecd, skb2->truesize);
547 sk = sk_atm(priv->lecd);
548 skb_queue_tail(&sk->sk_receive_queue, skb2);
549 sk->sk_data_ready(sk, skb2->len);
550 }
551 } 534 }
535 }
552#endif /* defined(CONFIG_BRIDGE) || defined(CONFIG_BRIDGE_MODULE) */ 536#endif /* defined(CONFIG_BRIDGE) || defined(CONFIG_BRIDGE_MODULE) */
553 break; 537 break;
554 default: 538 default:
555 printk("%s: Unknown message type %d\n", dev->name, mesg->type); 539 pr_info("%s: Unknown message type %d\n", dev->name, mesg->type);
556 dev_kfree_skb(skb); 540 dev_kfree_skb(skb);
557 return -EINVAL; 541 return -EINVAL;
558 } 542 }
@@ -573,14 +557,13 @@ static void lec_atm_close(struct atm_vcc *vcc)
573 lec_arp_destroy(priv); 557 lec_arp_destroy(priv);
574 558
575 if (skb_peek(&sk_atm(vcc)->sk_receive_queue)) 559 if (skb_peek(&sk_atm(vcc)->sk_receive_queue))
576 printk("%s lec_atm_close: closing with messages pending\n", 560 pr_info("%s closing with messages pending\n", dev->name);
577 dev->name); 561 while ((skb = skb_dequeue(&sk_atm(vcc)->sk_receive_queue))) {
578 while ((skb = skb_dequeue(&sk_atm(vcc)->sk_receive_queue)) != NULL) {
579 atm_return(vcc, skb->truesize); 562 atm_return(vcc, skb->truesize);
580 dev_kfree_skb(skb); 563 dev_kfree_skb(skb);
581 } 564 }
582 565
583 printk("%s: Shut down!\n", dev->name); 566 pr_info("%s: Shut down!\n", dev->name);
584 module_put(THIS_MODULE); 567 module_put(THIS_MODULE);
585} 568}
586 569
@@ -609,9 +592,8 @@ send_to_lecd(struct lec_priv *priv, atmlec_msg_type type,
609 struct sk_buff *skb; 592 struct sk_buff *skb;
610 struct atmlec_msg *mesg; 593 struct atmlec_msg *mesg;
611 594
612 if (!priv || !priv->lecd) { 595 if (!priv || !priv->lecd)
613 return -1; 596 return -1;
614 }
615 skb = alloc_skb(sizeof(struct atmlec_msg), GFP_ATOMIC); 597 skb = alloc_skb(sizeof(struct atmlec_msg), GFP_ATOMIC);
616 if (!skb) 598 if (!skb)
617 return -1; 599 return -1;
@@ -634,7 +616,7 @@ send_to_lecd(struct lec_priv *priv, atmlec_msg_type type,
634 sk->sk_data_ready(sk, skb->len); 616 sk->sk_data_ready(sk, skb->len);
635 617
636 if (data != NULL) { 618 if (data != NULL) {
637 pr_debug("lec: about to send %d bytes of data\n", data->len); 619 pr_debug("about to send %d bytes of data\n", data->len);
638 atm_force_charge(priv->lecd, data->truesize); 620 atm_force_charge(priv->lecd, data->truesize);
639 skb_queue_tail(&sk->sk_receive_queue, data); 621 skb_queue_tail(&sk->sk_receive_queue, data);
640 sk->sk_data_ready(sk, skb->len); 622 sk->sk_data_ready(sk, skb->len);
@@ -670,13 +652,6 @@ static const struct net_device_ops lec_netdev_ops = {
670 .ndo_set_multicast_list = lec_set_multicast_list, 652 .ndo_set_multicast_list = lec_set_multicast_list,
671}; 653};
672 654
673
674static void lec_init(struct net_device *dev)
675{
676 dev->netdev_ops = &lec_netdev_ops;
677 printk("%s: Initialized!\n", dev->name);
678}
679
680static const unsigned char lec_ctrl_magic[] = { 655static const unsigned char lec_ctrl_magic[] = {
681 0xff, 656 0xff,
682 0x00, 657 0x00,
@@ -699,36 +674,28 @@ static void lec_push(struct atm_vcc *vcc, struct sk_buff *skb)
699 struct net_device *dev = (struct net_device *)vcc->proto_data; 674 struct net_device *dev = (struct net_device *)vcc->proto_data;
700 struct lec_priv *priv = netdev_priv(dev); 675 struct lec_priv *priv = netdev_priv(dev);
701 676
702#if DUMP_PACKETS >0 677#if DUMP_PACKETS > 0
703 int i = 0; 678 printk(KERN_DEBUG "%s: vcc vpi:%d vci:%d\n",
704 char buf[300]; 679 dev->name, vcc->vpi, vcc->vci);
705
706 printk("%s: lec_push vcc vpi:%d vci:%d\n", dev->name,
707 vcc->vpi, vcc->vci);
708#endif 680#endif
709 if (!skb) { 681 if (!skb) {
710 pr_debug("%s: null skb\n", dev->name); 682 pr_debug("%s: null skb\n", dev->name);
711 lec_vcc_close(priv, vcc); 683 lec_vcc_close(priv, vcc);
712 return; 684 return;
713 } 685 }
714#if DUMP_PACKETS > 0
715 printk("%s: rcv datalen:%ld lecid:%4.4x\n", dev->name,
716 skb->len, priv->lecid);
717#if DUMP_PACKETS >= 2 686#if DUMP_PACKETS >= 2
718 for (i = 0; i < skb->len && i < 99; i++) { 687#define MAX_SKB_DUMP 99
719 sprintf(buf + i * 3, "%2.2x ", 0xff & skb->data[i]);
720 }
721#elif DUMP_PACKETS >= 1 688#elif DUMP_PACKETS >= 1
722 for (i = 0; i < skb->len && i < 30; i++) { 689#define MAX_SKB_DUMP 30
723 sprintf(buf + i * 3, "%2.2x ", 0xff & skb->data[i]); 690#endif
724 } 691#if DUMP_PACKETS > 0
725#endif /* DUMP_PACKETS >= 1 */ 692 printk(KERN_DEBUG "%s: rcv datalen:%ld lecid:%4.4x\n",
726 if (i == skb->len) 693 dev->name, skb->len, priv->lecid);
727 printk("%s\n", buf); 694 print_hex_dump(KERN_DEBUG, "", DUMP_OFFSET, 16, 1,
728 else 695 skb->data, min(MAX_SKB_DUMP, skb->len), true);
729 printk("%s...\n", buf);
730#endif /* DUMP_PACKETS > 0 */ 696#endif /* DUMP_PACKETS > 0 */
731 if (memcmp(skb->data, lec_ctrl_magic, 4) == 0) { /* Control frame, to daemon */ 697 if (memcmp(skb->data, lec_ctrl_magic, 4) == 0) {
698 /* Control frame, to daemon */
732 struct sock *sk = sk_atm(vcc); 699 struct sock *sk = sk_atm(vcc);
733 700
734 pr_debug("%s: To daemon\n", dev->name); 701 pr_debug("%s: To daemon\n", dev->name);
@@ -786,9 +753,8 @@ static void lec_push(struct atm_vcc *vcc, struct sk_buff *skb)
786 dev_kfree_skb(skb); 753 dev_kfree_skb(skb);
787 return; 754 return;
788 } 755 }
789 if (!hlist_empty(&priv->lec_arp_empty_ones)) { 756 if (!hlist_empty(&priv->lec_arp_empty_ones))
790 lec_arp_check_empties(priv, vcc, skb); 757 lec_arp_check_empties(priv, vcc, skb);
791 }
792 skb_pull(skb, 2); /* skip lec_id */ 758 skb_pull(skb, 2); /* skip lec_id */
793#ifdef CONFIG_TR 759#ifdef CONFIG_TR
794 if (priv->is_trdev) 760 if (priv->is_trdev)
@@ -809,7 +775,7 @@ static void lec_pop(struct atm_vcc *vcc, struct sk_buff *skb)
809 struct net_device *dev = skb->dev; 775 struct net_device *dev = skb->dev;
810 776
811 if (vpriv == NULL) { 777 if (vpriv == NULL) {
812 printk("lec_pop(): vpriv = NULL!?!?!?\n"); 778 pr_info("vpriv = NULL!?!?!?\n");
813 return; 779 return;
814 } 780 }
815 781
@@ -830,15 +796,13 @@ static int lec_vcc_attach(struct atm_vcc *vcc, void __user *arg)
830 796
831 /* Lecd must be up in this case */ 797 /* Lecd must be up in this case */
832 bytes_left = copy_from_user(&ioc_data, arg, sizeof(struct atmlec_ioc)); 798 bytes_left = copy_from_user(&ioc_data, arg, sizeof(struct atmlec_ioc));
833 if (bytes_left != 0) { 799 if (bytes_left != 0)
834 printk 800 pr_info("copy from user failed for %d bytes\n", bytes_left);
835 ("lec: lec_vcc_attach, copy from user failed for %d bytes\n",
836 bytes_left);
837 }
838 if (ioc_data.dev_num < 0 || ioc_data.dev_num >= MAX_LEC_ITF || 801 if (ioc_data.dev_num < 0 || ioc_data.dev_num >= MAX_LEC_ITF ||
839 !dev_lec[ioc_data.dev_num]) 802 !dev_lec[ioc_data.dev_num])
840 return -EINVAL; 803 return -EINVAL;
841 if (!(vpriv = kmalloc(sizeof(struct lec_vcc_priv), GFP_KERNEL))) 804 vpriv = kmalloc(sizeof(struct lec_vcc_priv), GFP_KERNEL);
805 if (!vpriv)
842 return -ENOMEM; 806 return -ENOMEM;
843 vpriv->xoff = 0; 807 vpriv->xoff = 0;
844 vpriv->old_pop = vcc->pop; 808 vpriv->old_pop = vcc->pop;
@@ -893,6 +857,7 @@ static int lecd_attach(struct atm_vcc *vcc, int arg)
893 dev_lec[i] = alloc_etherdev(size); 857 dev_lec[i] = alloc_etherdev(size);
894 if (!dev_lec[i]) 858 if (!dev_lec[i])
895 return -ENOMEM; 859 return -ENOMEM;
860 dev_lec[i]->netdev_ops = &lec_netdev_ops;
896 snprintf(dev_lec[i]->name, IFNAMSIZ, "lec%d", i); 861 snprintf(dev_lec[i]->name, IFNAMSIZ, "lec%d", i);
897 if (register_netdev(dev_lec[i])) { 862 if (register_netdev(dev_lec[i])) {
898 free_netdev(dev_lec[i]); 863 free_netdev(dev_lec[i]);
@@ -901,7 +866,6 @@ static int lecd_attach(struct atm_vcc *vcc, int arg)
901 866
902 priv = netdev_priv(dev_lec[i]); 867 priv = netdev_priv(dev_lec[i]);
903 priv->is_trdev = is_trdev; 868 priv->is_trdev = is_trdev;
904 lec_init(dev_lec[i]);
905 } else { 869 } else {
906 priv = netdev_priv(dev_lec[i]); 870 priv = netdev_priv(dev_lec[i]);
907 if (priv->lecd) 871 if (priv->lecd)
@@ -929,9 +893,8 @@ static int lecd_attach(struct atm_vcc *vcc, int arg)
929 priv->flush_timeout = (4 * HZ); 893 priv->flush_timeout = (4 * HZ);
930 priv->path_switching_delay = (6 * HZ); 894 priv->path_switching_delay = (6 * HZ);
931 895
932 if (dev_lec[i]->flags & IFF_UP) { 896 if (dev_lec[i]->flags & IFF_UP)
933 netif_start_queue(dev_lec[i]); 897 netif_start_queue(dev_lec[i]);
934 }
935 __module_get(THIS_MODULE); 898 __module_get(THIS_MODULE);
936 return i; 899 return i;
937} 900}
@@ -1133,7 +1096,9 @@ static int lec_seq_show(struct seq_file *seq, void *v)
1133 else { 1096 else {
1134 struct lec_state *state = seq->private; 1097 struct lec_state *state = seq->private;
1135 struct net_device *dev = state->dev; 1098 struct net_device *dev = state->dev;
1136 struct lec_arp_table *entry = hlist_entry(state->node, struct lec_arp_table, next); 1099 struct lec_arp_table *entry = hlist_entry(state->node,
1100 struct lec_arp_table,
1101 next);
1137 1102
1138 seq_printf(seq, "%s ", dev->name); 1103 seq_printf(seq, "%s ", dev->name);
1139 lec_info(seq, entry); 1104 lec_info(seq, entry);
@@ -1207,13 +1172,13 @@ static int __init lane_module_init(void)
1207 1172
1208 p = proc_create("lec", S_IRUGO, atm_proc_root, &lec_seq_fops); 1173 p = proc_create("lec", S_IRUGO, atm_proc_root, &lec_seq_fops);
1209 if (!p) { 1174 if (!p) {
1210 printk(KERN_ERR "Unable to initialize /proc/net/atm/lec\n"); 1175 pr_err("Unable to initialize /proc/net/atm/lec\n");
1211 return -ENOMEM; 1176 return -ENOMEM;
1212 } 1177 }
1213#endif 1178#endif
1214 1179
1215 register_atm_ioctl(&lane_ioctl_ops); 1180 register_atm_ioctl(&lane_ioctl_ops);
1216 printk("lec.c: " __DATE__ " " __TIME__ " initialized\n"); 1181 pr_info("lec.c: " __DATE__ " " __TIME__ " initialized\n");
1217 return 0; 1182 return 0;
1218} 1183}
1219 1184
@@ -1302,13 +1267,13 @@ static int lane2_associate_req(struct net_device *dev, const u8 *lan_dst,
1302 struct lec_priv *priv = netdev_priv(dev); 1267 struct lec_priv *priv = netdev_priv(dev);
1303 1268
1304 if (compare_ether_addr(lan_dst, dev->dev_addr)) 1269 if (compare_ether_addr(lan_dst, dev->dev_addr))
1305 return (0); /* not our mac address */ 1270 return 0; /* not our mac address */
1306 1271
1307 kfree(priv->tlvs); /* NULL if there was no previous association */ 1272 kfree(priv->tlvs); /* NULL if there was no previous association */
1308 1273
1309 priv->tlvs = kmemdup(tlvs, sizeoftlvs, GFP_KERNEL); 1274 priv->tlvs = kmemdup(tlvs, sizeoftlvs, GFP_KERNEL);
1310 if (priv->tlvs == NULL) 1275 if (priv->tlvs == NULL)
1311 return (0); 1276 return 0;
1312 priv->sizeoftlvs = sizeoftlvs; 1277 priv->sizeoftlvs = sizeoftlvs;
1313 1278
1314 skb = alloc_skb(sizeoftlvs, GFP_ATOMIC); 1279 skb = alloc_skb(sizeoftlvs, GFP_ATOMIC);
@@ -1318,12 +1283,12 @@ static int lane2_associate_req(struct net_device *dev, const u8 *lan_dst,
1318 skb_copy_to_linear_data(skb, tlvs, sizeoftlvs); 1283 skb_copy_to_linear_data(skb, tlvs, sizeoftlvs);
1319 retval = send_to_lecd(priv, l_associate_req, NULL, NULL, skb); 1284 retval = send_to_lecd(priv, l_associate_req, NULL, NULL, skb);
1320 if (retval != 0) 1285 if (retval != 0)
1321 printk("lec.c: lane2_associate_req() failed\n"); 1286 pr_info("lec.c: lane2_associate_req() failed\n");
1322 /* 1287 /*
1323 * If the previous association has changed we must 1288 * If the previous association has changed we must
1324 * somehow notify other LANE entities about the change 1289 * somehow notify other LANE entities about the change
1325 */ 1290 */
1326 return (1); 1291 return 1;
1327} 1292}
1328 1293
1329/* 1294/*
@@ -1356,12 +1321,12 @@ static void lane2_associate_ind(struct net_device *dev, const u8 *mac_addr,
1356 entry->sizeoftlvs = sizeoftlvs; 1321 entry->sizeoftlvs = sizeoftlvs;
1357#endif 1322#endif
1358#if 0 1323#if 0
1359 printk("lec.c: lane2_associate_ind()\n"); 1324 pr_info("\n");
1360 printk("dump of tlvs, sizeoftlvs=%d\n", sizeoftlvs); 1325 pr_info("dump of tlvs, sizeoftlvs=%d\n", sizeoftlvs);
1361 while (i < sizeoftlvs) 1326 while (i < sizeoftlvs)
1362 printk("%02x ", tlvs[i++]); 1327 pr_cont("%02x ", tlvs[i++]);
1363 1328
1364 printk("\n"); 1329 pr_cont("\n");
1365#endif 1330#endif
1366 1331
1367 /* tell MPOA about the TLVs we saw */ 1332 /* tell MPOA about the TLVs we saw */
@@ -1381,15 +1346,15 @@ static void lane2_associate_ind(struct net_device *dev, const u8 *mac_addr,
1381 1346
1382#include <linux/types.h> 1347#include <linux/types.h>
1383#include <linux/timer.h> 1348#include <linux/timer.h>
1384#include <asm/param.h> 1349#include <linux/param.h>
1385#include <asm/atomic.h> 1350#include <asm/atomic.h>
1386#include <linux/inetdevice.h> 1351#include <linux/inetdevice.h>
1387#include <net/route.h> 1352#include <net/route.h>
1388 1353
1389#if 0 1354#if 0
1390#define pr_debug(format,args...) 1355#define pr_debug(format, args...)
1391/* 1356/*
1392#define pr_debug printk 1357 #define pr_debug printk
1393*/ 1358*/
1394#endif 1359#endif
1395#define DEBUG_ARP_TABLE 0 1360#define DEBUG_ARP_TABLE 0
@@ -1403,7 +1368,7 @@ static void lec_arp_expire_arp(unsigned long data);
1403 * Arp table funcs 1368 * Arp table funcs
1404 */ 1369 */
1405 1370
1406#define HASH(ch) (ch & (LEC_ARP_TABLE_SIZE -1)) 1371#define HASH(ch) (ch & (LEC_ARP_TABLE_SIZE - 1))
1407 1372
1408/* 1373/*
1409 * Initialization of arp-cache 1374 * Initialization of arp-cache
@@ -1412,9 +1377,8 @@ static void lec_arp_init(struct lec_priv *priv)
1412{ 1377{
1413 unsigned short i; 1378 unsigned short i;
1414 1379
1415 for (i = 0; i < LEC_ARP_TABLE_SIZE; i++) { 1380 for (i = 0; i < LEC_ARP_TABLE_SIZE; i++)
1416 INIT_HLIST_HEAD(&priv->lec_arp_tables[i]); 1381 INIT_HLIST_HEAD(&priv->lec_arp_tables[i]);
1417 }
1418 INIT_HLIST_HEAD(&priv->lec_arp_empty_ones); 1382 INIT_HLIST_HEAD(&priv->lec_arp_empty_ones);
1419 INIT_HLIST_HEAD(&priv->lec_no_forward); 1383 INIT_HLIST_HEAD(&priv->lec_no_forward);
1420 INIT_HLIST_HEAD(&priv->mcast_fwds); 1384 INIT_HLIST_HEAD(&priv->mcast_fwds);
@@ -1458,10 +1422,7 @@ lec_arp_add(struct lec_priv *priv, struct lec_arp_table *entry)
1458 tmp = &priv->lec_arp_tables[HASH(entry->mac_addr[ETH_ALEN - 1])]; 1422 tmp = &priv->lec_arp_tables[HASH(entry->mac_addr[ETH_ALEN - 1])];
1459 hlist_add_head(&entry->next, tmp); 1423 hlist_add_head(&entry->next, tmp);
1460 1424
1461 pr_debug("LEC_ARP: Added entry:%2.2x %2.2x %2.2x %2.2x %2.2x %2.2x\n", 1425 pr_debug("Added entry:%pM\n", entry->mac_addr);
1462 0xff & entry->mac_addr[0], 0xff & entry->mac_addr[1],
1463 0xff & entry->mac_addr[2], 0xff & entry->mac_addr[3],
1464 0xff & entry->mac_addr[4], 0xff & entry->mac_addr[5]);
1465} 1426}
1466 1427
1467/* 1428/*
@@ -1474,20 +1435,23 @@ lec_arp_remove(struct lec_priv *priv, struct lec_arp_table *to_remove)
1474 struct lec_arp_table *entry; 1435 struct lec_arp_table *entry;
1475 int i, remove_vcc = 1; 1436 int i, remove_vcc = 1;
1476 1437
1477 if (!to_remove) { 1438 if (!to_remove)
1478 return -1; 1439 return -1;
1479 }
1480 1440
1481 hlist_del(&to_remove->next); 1441 hlist_del(&to_remove->next);
1482 del_timer(&to_remove->timer); 1442 del_timer(&to_remove->timer);
1483 1443
1484 /* If this is the only MAC connected to this VCC, also tear down the VCC */ 1444 /*
1445 * If this is the only MAC connected to this VCC,
1446 * also tear down the VCC
1447 */
1485 if (to_remove->status >= ESI_FLUSH_PENDING) { 1448 if (to_remove->status >= ESI_FLUSH_PENDING) {
1486 /* 1449 /*
1487 * ESI_FLUSH_PENDING, ESI_FORWARD_DIRECT 1450 * ESI_FLUSH_PENDING, ESI_FORWARD_DIRECT
1488 */ 1451 */
1489 for (i = 0; i < LEC_ARP_TABLE_SIZE; i++) { 1452 for (i = 0; i < LEC_ARP_TABLE_SIZE; i++) {
1490 hlist_for_each_entry(entry, node, &priv->lec_arp_tables[i], next) { 1453 hlist_for_each_entry(entry, node,
1454 &priv->lec_arp_tables[i], next) {
1491 if (memcmp(to_remove->atm_addr, 1455 if (memcmp(to_remove->atm_addr,
1492 entry->atm_addr, ATM_ESA_LEN) == 0) { 1456 entry->atm_addr, ATM_ESA_LEN) == 0) {
1493 remove_vcc = 0; 1457 remove_vcc = 0;
@@ -1500,10 +1464,7 @@ lec_arp_remove(struct lec_priv *priv, struct lec_arp_table *to_remove)
1500 } 1464 }
1501 skb_queue_purge(&to_remove->tx_wait); /* FIXME: good place for this? */ 1465 skb_queue_purge(&to_remove->tx_wait); /* FIXME: good place for this? */
1502 1466
1503 pr_debug("LEC_ARP: Removed entry:%2.2x %2.2x %2.2x %2.2x %2.2x %2.2x\n", 1467 pr_debug("Removed entry:%pM\n", to_remove->mac_addr);
1504 0xff & to_remove->mac_addr[0], 0xff & to_remove->mac_addr[1],
1505 0xff & to_remove->mac_addr[2], 0xff & to_remove->mac_addr[3],
1506 0xff & to_remove->mac_addr[4], 0xff & to_remove->mac_addr[5]);
1507 return 0; 1468 return 0;
1508} 1469}
1509 1470
@@ -1521,9 +1482,8 @@ static const char *get_status_string(unsigned char st)
1521 return "ESI_FLUSH_PENDING"; 1482 return "ESI_FLUSH_PENDING";
1522 case ESI_FORWARD_DIRECT: 1483 case ESI_FORWARD_DIRECT:
1523 return "ESI_FORWARD_DIRECT"; 1484 return "ESI_FORWARD_DIRECT";
1524 default:
1525 return "<UNKNOWN>";
1526 } 1485 }
1486 return "<UNKNOWN>";
1527} 1487}
1528 1488
1529static void dump_arp_table(struct lec_priv *priv) 1489static void dump_arp_table(struct lec_priv *priv)
@@ -1533,18 +1493,15 @@ static void dump_arp_table(struct lec_priv *priv)
1533 char buf[256]; 1493 char buf[256];
1534 int i, j, offset; 1494 int i, j, offset;
1535 1495
1536 printk("Dump %p:\n", priv); 1496 pr_info("Dump %p:\n", priv);
1537 for (i = 0; i < LEC_ARP_TABLE_SIZE; i++) { 1497 for (i = 0; i < LEC_ARP_TABLE_SIZE; i++) {
1538 hlist_for_each_entry(rulla, node, &priv->lec_arp_tables[i], next) { 1498 hlist_for_each_entry(rulla, node,
1499 &priv->lec_arp_tables[i], next) {
1539 offset = 0; 1500 offset = 0;
1540 offset += sprintf(buf, "%d: %p\n", i, rulla); 1501 offset += sprintf(buf, "%d: %p\n", i, rulla);
1541 offset += sprintf(buf + offset, "Mac:"); 1502 offset += sprintf(buf + offset, "Mac: %pM",
1542 for (j = 0; j < ETH_ALEN; j++) { 1503 rulla->mac_addr);
1543 offset += sprintf(buf + offset, 1504 offset += sprintf(buf + offset, " Atm:");
1544 "%2.2x ",
1545 rulla->mac_addr[j] & 0xff);
1546 }
1547 offset += sprintf(buf + offset, "Atm:");
1548 for (j = 0; j < ATM_ESA_LEN; j++) { 1505 for (j = 0; j < ATM_ESA_LEN; j++) {
1549 offset += sprintf(buf + offset, 1506 offset += sprintf(buf + offset,
1550 "%2.2x ", 1507 "%2.2x ",
@@ -1564,20 +1521,16 @@ static void dump_arp_table(struct lec_priv *priv)
1564 "Flags:%x, Packets_flooded:%x, Status: %s ", 1521 "Flags:%x, Packets_flooded:%x, Status: %s ",
1565 rulla->flags, rulla->packets_flooded, 1522 rulla->flags, rulla->packets_flooded,
1566 get_status_string(rulla->status)); 1523 get_status_string(rulla->status));
1567 printk("%s\n", buf); 1524 pr_info("%s\n", buf);
1568 } 1525 }
1569 } 1526 }
1570 1527
1571 if (!hlist_empty(&priv->lec_no_forward)) 1528 if (!hlist_empty(&priv->lec_no_forward))
1572 printk("No forward\n"); 1529 pr_info("No forward\n");
1573 hlist_for_each_entry(rulla, node, &priv->lec_no_forward, next) { 1530 hlist_for_each_entry(rulla, node, &priv->lec_no_forward, next) {
1574 offset = 0; 1531 offset = 0;
1575 offset += sprintf(buf + offset, "Mac:"); 1532 offset += sprintf(buf + offset, "Mac: %pM", rulla->mac_addr);
1576 for (j = 0; j < ETH_ALEN; j++) { 1533 offset += sprintf(buf + offset, " Atm:");
1577 offset += sprintf(buf + offset, "%2.2x ",
1578 rulla->mac_addr[j] & 0xff);
1579 }
1580 offset += sprintf(buf + offset, "Atm:");
1581 for (j = 0; j < ATM_ESA_LEN; j++) { 1534 for (j = 0; j < ATM_ESA_LEN; j++) {
1582 offset += sprintf(buf + offset, "%2.2x ", 1535 offset += sprintf(buf + offset, "%2.2x ",
1583 rulla->atm_addr[j] & 0xff); 1536 rulla->atm_addr[j] & 0xff);
@@ -1594,19 +1547,15 @@ static void dump_arp_table(struct lec_priv *priv)
1594 "Flags:%x, Packets_flooded:%x, Status: %s ", 1547 "Flags:%x, Packets_flooded:%x, Status: %s ",
1595 rulla->flags, rulla->packets_flooded, 1548 rulla->flags, rulla->packets_flooded,
1596 get_status_string(rulla->status)); 1549 get_status_string(rulla->status));
1597 printk("%s\n", buf); 1550 pr_info("%s\n", buf);
1598 } 1551 }
1599 1552
1600 if (!hlist_empty(&priv->lec_arp_empty_ones)) 1553 if (!hlist_empty(&priv->lec_arp_empty_ones))
1601 printk("Empty ones\n"); 1554 pr_info("Empty ones\n");
1602 hlist_for_each_entry(rulla, node, &priv->lec_arp_empty_ones, next) { 1555 hlist_for_each_entry(rulla, node, &priv->lec_arp_empty_ones, next) {
1603 offset = 0; 1556 offset = 0;
1604 offset += sprintf(buf + offset, "Mac:"); 1557 offset += sprintf(buf + offset, "Mac: %pM", rulla->mac_addr);
1605 for (j = 0; j < ETH_ALEN; j++) { 1558 offset += sprintf(buf + offset, " Atm:");
1606 offset += sprintf(buf + offset, "%2.2x ",
1607 rulla->mac_addr[j] & 0xff);
1608 }
1609 offset += sprintf(buf + offset, "Atm:");
1610 for (j = 0; j < ATM_ESA_LEN; j++) { 1559 for (j = 0; j < ATM_ESA_LEN; j++) {
1611 offset += sprintf(buf + offset, "%2.2x ", 1560 offset += sprintf(buf + offset, "%2.2x ",
1612 rulla->atm_addr[j] & 0xff); 1561 rulla->atm_addr[j] & 0xff);
@@ -1623,19 +1572,15 @@ static void dump_arp_table(struct lec_priv *priv)
1623 "Flags:%x, Packets_flooded:%x, Status: %s ", 1572 "Flags:%x, Packets_flooded:%x, Status: %s ",
1624 rulla->flags, rulla->packets_flooded, 1573 rulla->flags, rulla->packets_flooded,
1625 get_status_string(rulla->status)); 1574 get_status_string(rulla->status));
1626 printk("%s", buf); 1575 pr_info("%s", buf);
1627 } 1576 }
1628 1577
1629 if (!hlist_empty(&priv->mcast_fwds)) 1578 if (!hlist_empty(&priv->mcast_fwds))
1630 printk("Multicast Forward VCCs\n"); 1579 pr_info("Multicast Forward VCCs\n");
1631 hlist_for_each_entry(rulla, node, &priv->mcast_fwds, next) { 1580 hlist_for_each_entry(rulla, node, &priv->mcast_fwds, next) {
1632 offset = 0; 1581 offset = 0;
1633 offset += sprintf(buf + offset, "Mac:"); 1582 offset += sprintf(buf + offset, "Mac: %pM", rulla->mac_addr);
1634 for (j = 0; j < ETH_ALEN; j++) { 1583 offset += sprintf(buf + offset, " Atm:");
1635 offset += sprintf(buf + offset, "%2.2x ",
1636 rulla->mac_addr[j] & 0xff);
1637 }
1638 offset += sprintf(buf + offset, "Atm:");
1639 for (j = 0; j < ATM_ESA_LEN; j++) { 1584 for (j = 0; j < ATM_ESA_LEN; j++) {
1640 offset += sprintf(buf + offset, "%2.2x ", 1585 offset += sprintf(buf + offset, "%2.2x ",
1641 rulla->atm_addr[j] & 0xff); 1586 rulla->atm_addr[j] & 0xff);
@@ -1652,7 +1597,7 @@ static void dump_arp_table(struct lec_priv *priv)
1652 "Flags:%x, Packets_flooded:%x, Status: %s ", 1597 "Flags:%x, Packets_flooded:%x, Status: %s ",
1653 rulla->flags, rulla->packets_flooded, 1598 rulla->flags, rulla->packets_flooded,
1654 get_status_string(rulla->status)); 1599 get_status_string(rulla->status));
1655 printk("%s\n", buf); 1600 pr_info("%s\n", buf);
1656 } 1601 }
1657 1602
1658} 1603}
@@ -1678,14 +1623,16 @@ static void lec_arp_destroy(struct lec_priv *priv)
1678 1623
1679 spin_lock_irqsave(&priv->lec_arp_lock, flags); 1624 spin_lock_irqsave(&priv->lec_arp_lock, flags);
1680 for (i = 0; i < LEC_ARP_TABLE_SIZE; i++) { 1625 for (i = 0; i < LEC_ARP_TABLE_SIZE; i++) {
1681 hlist_for_each_entry_safe(entry, node, next, &priv->lec_arp_tables[i], next) { 1626 hlist_for_each_entry_safe(entry, node, next,
1627 &priv->lec_arp_tables[i], next) {
1682 lec_arp_remove(priv, entry); 1628 lec_arp_remove(priv, entry);
1683 lec_arp_put(entry); 1629 lec_arp_put(entry);
1684 } 1630 }
1685 INIT_HLIST_HEAD(&priv->lec_arp_tables[i]); 1631 INIT_HLIST_HEAD(&priv->lec_arp_tables[i]);
1686 } 1632 }
1687 1633
1688 hlist_for_each_entry_safe(entry, node, next, &priv->lec_arp_empty_ones, next) { 1634 hlist_for_each_entry_safe(entry, node, next,
1635 &priv->lec_arp_empty_ones, next) {
1689 del_timer_sync(&entry->timer); 1636 del_timer_sync(&entry->timer);
1690 lec_arp_clear_vccs(entry); 1637 lec_arp_clear_vccs(entry);
1691 hlist_del(&entry->next); 1638 hlist_del(&entry->next);
@@ -1693,7 +1640,8 @@ static void lec_arp_destroy(struct lec_priv *priv)
1693 } 1640 }
1694 INIT_HLIST_HEAD(&priv->lec_arp_empty_ones); 1641 INIT_HLIST_HEAD(&priv->lec_arp_empty_ones);
1695 1642
1696 hlist_for_each_entry_safe(entry, node, next, &priv->lec_no_forward, next) { 1643 hlist_for_each_entry_safe(entry, node, next,
1644 &priv->lec_no_forward, next) {
1697 del_timer_sync(&entry->timer); 1645 del_timer_sync(&entry->timer);
1698 lec_arp_clear_vccs(entry); 1646 lec_arp_clear_vccs(entry);
1699 hlist_del(&entry->next); 1647 hlist_del(&entry->next);
@@ -1722,15 +1670,12 @@ static struct lec_arp_table *lec_arp_find(struct lec_priv *priv,
1722 struct hlist_head *head; 1670 struct hlist_head *head;
1723 struct lec_arp_table *entry; 1671 struct lec_arp_table *entry;
1724 1672
1725 pr_debug("LEC_ARP: lec_arp_find :%2.2x %2.2x %2.2x %2.2x %2.2x %2.2x\n", 1673 pr_debug("%pM\n", mac_addr);
1726 mac_addr[0] & 0xff, mac_addr[1] & 0xff, mac_addr[2] & 0xff,
1727 mac_addr[3] & 0xff, mac_addr[4] & 0xff, mac_addr[5] & 0xff);
1728 1674
1729 head = &priv->lec_arp_tables[HASH(mac_addr[ETH_ALEN - 1])]; 1675 head = &priv->lec_arp_tables[HASH(mac_addr[ETH_ALEN - 1])];
1730 hlist_for_each_entry(entry, node, head, next) { 1676 hlist_for_each_entry(entry, node, head, next) {
1731 if (!compare_ether_addr(mac_addr, entry->mac_addr)) { 1677 if (!compare_ether_addr(mac_addr, entry->mac_addr))
1732 return entry; 1678 return entry;
1733 }
1734 } 1679 }
1735 return NULL; 1680 return NULL;
1736} 1681}
@@ -1742,7 +1687,7 @@ static struct lec_arp_table *make_entry(struct lec_priv *priv,
1742 1687
1743 to_return = kzalloc(sizeof(struct lec_arp_table), GFP_ATOMIC); 1688 to_return = kzalloc(sizeof(struct lec_arp_table), GFP_ATOMIC);
1744 if (!to_return) { 1689 if (!to_return) {
1745 printk("LEC: Arp entry kmalloc failed\n"); 1690 pr_info("LEC: Arp entry kmalloc failed\n");
1746 return NULL; 1691 return NULL;
1747 } 1692 }
1748 memcpy(to_return->mac_addr, mac_addr, ETH_ALEN); 1693 memcpy(to_return->mac_addr, mac_addr, ETH_ALEN);
@@ -1763,7 +1708,7 @@ static void lec_arp_expire_arp(unsigned long data)
1763 1708
1764 entry = (struct lec_arp_table *)data; 1709 entry = (struct lec_arp_table *)data;
1765 1710
1766 pr_debug("lec_arp_expire_arp\n"); 1711 pr_debug("\n");
1767 if (entry->status == ESI_ARP_PENDING) { 1712 if (entry->status == ESI_ARP_PENDING) {
1768 if (entry->no_tries <= entry->priv->max_retry_count) { 1713 if (entry->no_tries <= entry->priv->max_retry_count) {
1769 if (entry->is_rdesc) 1714 if (entry->is_rdesc)
@@ -1787,10 +1732,10 @@ static void lec_arp_expire_vcc(unsigned long data)
1787 1732
1788 del_timer(&to_remove->timer); 1733 del_timer(&to_remove->timer);
1789 1734
1790 pr_debug("LEC_ARP %p %p: lec_arp_expire_vcc vpi:%d vci:%d\n", 1735 pr_debug("%p %p: vpi:%d vci:%d\n",
1791 to_remove, priv, 1736 to_remove, priv,
1792 to_remove->vcc ? to_remove->recv_vcc->vpi : 0, 1737 to_remove->vcc ? to_remove->recv_vcc->vpi : 0,
1793 to_remove->vcc ? to_remove->recv_vcc->vci : 0); 1738 to_remove->vcc ? to_remove->recv_vcc->vci : 0);
1794 1739
1795 spin_lock_irqsave(&priv->lec_arp_lock, flags); 1740 spin_lock_irqsave(&priv->lec_arp_lock, flags);
1796 hlist_del(&to_remove->next); 1741 hlist_del(&to_remove->next);
@@ -1800,6 +1745,50 @@ static void lec_arp_expire_vcc(unsigned long data)
1800 lec_arp_put(to_remove); 1745 lec_arp_put(to_remove);
1801} 1746}
1802 1747
1748static bool __lec_arp_check_expire(struct lec_arp_table *entry,
1749 unsigned long now,
1750 struct lec_priv *priv)
1751{
1752 unsigned long time_to_check;
1753
1754 if ((entry->flags) & LEC_REMOTE_FLAG && priv->topology_change)
1755 time_to_check = priv->forward_delay_time;
1756 else
1757 time_to_check = priv->aging_time;
1758
1759 pr_debug("About to expire: %lx - %lx > %lx\n",
1760 now, entry->last_used, time_to_check);
1761 if (time_after(now, entry->last_used + time_to_check) &&
1762 !(entry->flags & LEC_PERMANENT_FLAG) &&
1763 !(entry->mac_addr[0] & 0x01)) { /* LANE2: 7.1.20 */
1764 /* Remove entry */
1765 pr_debug("Entry timed out\n");
1766 lec_arp_remove(priv, entry);
1767 lec_arp_put(entry);
1768 } else {
1769 /* Something else */
1770 if ((entry->status == ESI_VC_PENDING ||
1771 entry->status == ESI_ARP_PENDING) &&
1772 time_after_eq(now, entry->timestamp +
1773 priv->max_unknown_frame_time)) {
1774 entry->timestamp = jiffies;
1775 entry->packets_flooded = 0;
1776 if (entry->status == ESI_VC_PENDING)
1777 send_to_lecd(priv, l_svc_setup,
1778 entry->mac_addr,
1779 entry->atm_addr,
1780 NULL);
1781 }
1782 if (entry->status == ESI_FLUSH_PENDING &&
1783 time_after_eq(now, entry->timestamp +
1784 priv->path_switching_delay)) {
1785 lec_arp_hold(entry);
1786 return true;
1787 }
1788 }
1789
1790 return false;
1791}
1803/* 1792/*
1804 * Expire entries. 1793 * Expire entries.
1805 * 1. Re-set timer 1794 * 1. Re-set timer
@@ -1824,62 +1813,28 @@ static void lec_arp_check_expire(struct work_struct *work)
1824 struct hlist_node *node, *next; 1813 struct hlist_node *node, *next;
1825 struct lec_arp_table *entry; 1814 struct lec_arp_table *entry;
1826 unsigned long now; 1815 unsigned long now;
1827 unsigned long time_to_check;
1828 int i; 1816 int i;
1829 1817
1830 pr_debug("lec_arp_check_expire %p\n", priv); 1818 pr_debug("%p\n", priv);
1831 now = jiffies; 1819 now = jiffies;
1832restart: 1820restart:
1833 spin_lock_irqsave(&priv->lec_arp_lock, flags); 1821 spin_lock_irqsave(&priv->lec_arp_lock, flags);
1834 for (i = 0; i < LEC_ARP_TABLE_SIZE; i++) { 1822 for (i = 0; i < LEC_ARP_TABLE_SIZE; i++) {
1835 hlist_for_each_entry_safe(entry, node, next, &priv->lec_arp_tables[i], next) { 1823 hlist_for_each_entry_safe(entry, node, next,
1836 if ((entry->flags) & LEC_REMOTE_FLAG && 1824 &priv->lec_arp_tables[i], next) {
1837 priv->topology_change) 1825 if (__lec_arp_check_expire(entry, now, priv)) {
1838 time_to_check = priv->forward_delay_time; 1826 struct sk_buff *skb;
1839 else 1827 struct atm_vcc *vcc = entry->vcc;
1840 time_to_check = priv->aging_time; 1828
1841 1829 spin_unlock_irqrestore(&priv->lec_arp_lock,
1842 pr_debug("About to expire: %lx - %lx > %lx\n", 1830 flags);
1843 now, entry->last_used, time_to_check); 1831 while ((skb = skb_dequeue(&entry->tx_wait)))
1844 if (time_after(now, entry->last_used + time_to_check) 1832 lec_send(vcc, skb);
1845 && !(entry->flags & LEC_PERMANENT_FLAG) 1833 entry->last_used = jiffies;
1846 && !(entry->mac_addr[0] & 0x01)) { /* LANE2: 7.1.20 */ 1834 entry->status = ESI_FORWARD_DIRECT;
1847 /* Remove entry */
1848 pr_debug("LEC:Entry timed out\n");
1849 lec_arp_remove(priv, entry);
1850 lec_arp_put(entry); 1835 lec_arp_put(entry);
1851 } else { 1836
1852 /* Something else */ 1837 goto restart;
1853 if ((entry->status == ESI_VC_PENDING ||
1854 entry->status == ESI_ARP_PENDING)
1855 && time_after_eq(now,
1856 entry->timestamp +
1857 priv->
1858 max_unknown_frame_time)) {
1859 entry->timestamp = jiffies;
1860 entry->packets_flooded = 0;
1861 if (entry->status == ESI_VC_PENDING)
1862 send_to_lecd(priv, l_svc_setup,
1863 entry->mac_addr,
1864 entry->atm_addr,
1865 NULL);
1866 }
1867 if (entry->status == ESI_FLUSH_PENDING
1868 &&
1869 time_after_eq(now, entry->timestamp +
1870 priv->path_switching_delay)) {
1871 struct sk_buff *skb;
1872 struct atm_vcc *vcc = entry->vcc;
1873
1874 lec_arp_hold(entry);
1875 spin_unlock_irqrestore(&priv->lec_arp_lock, flags);
1876 while ((skb = skb_dequeue(&entry->tx_wait)) != NULL)
1877 lec_send(vcc, skb);
1878 entry->last_used = jiffies;
1879 entry->status = ESI_FORWARD_DIRECT;
1880 lec_arp_put(entry);
1881 goto restart;
1882 }
1883 } 1838 }
1884 } 1839 }
1885 } 1840 }
@@ -1893,7 +1848,8 @@ restart:
1893 * 1848 *
1894 */ 1849 */
1895static struct atm_vcc *lec_arp_resolve(struct lec_priv *priv, 1850static struct atm_vcc *lec_arp_resolve(struct lec_priv *priv,
1896 const unsigned char *mac_to_find, int is_rdesc, 1851 const unsigned char *mac_to_find,
1852 int is_rdesc,
1897 struct lec_arp_table **ret_entry) 1853 struct lec_arp_table **ret_entry)
1898{ 1854{
1899 unsigned long flags; 1855 unsigned long flags;
@@ -1929,9 +1885,8 @@ static struct atm_vcc *lec_arp_resolve(struct lec_priv *priv,
1929 * If the LE_ARP cache entry is still pending, reset count to 0 1885 * If the LE_ARP cache entry is still pending, reset count to 0
1930 * so another LE_ARP request can be made for this frame. 1886 * so another LE_ARP request can be made for this frame.
1931 */ 1887 */
1932 if (entry->status == ESI_ARP_PENDING) { 1888 if (entry->status == ESI_ARP_PENDING)
1933 entry->no_tries = 0; 1889 entry->no_tries = 0;
1934 }
1935 /* 1890 /*
1936 * Data direct VC not yet set up, check to see if the unknown 1891 * Data direct VC not yet set up, check to see if the unknown
1937 * frame count is greater than the limit. If the limit has 1892 * frame count is greater than the limit. If the limit has
@@ -1942,7 +1897,7 @@ static struct atm_vcc *lec_arp_resolve(struct lec_priv *priv,
1942 entry->packets_flooded < 1897 entry->packets_flooded <
1943 priv->maximum_unknown_frame_count) { 1898 priv->maximum_unknown_frame_count) {
1944 entry->packets_flooded++; 1899 entry->packets_flooded++;
1945 pr_debug("LEC_ARP: Flooding..\n"); 1900 pr_debug("Flooding..\n");
1946 found = priv->mcast_vcc; 1901 found = priv->mcast_vcc;
1947 goto out; 1902 goto out;
1948 } 1903 }
@@ -1953,13 +1908,13 @@ static struct atm_vcc *lec_arp_resolve(struct lec_priv *priv,
1953 */ 1908 */
1954 lec_arp_hold(entry); 1909 lec_arp_hold(entry);
1955 *ret_entry = entry; 1910 *ret_entry = entry;
1956 pr_debug("lec: entry->status %d entry->vcc %p\n", entry->status, 1911 pr_debug("entry->status %d entry->vcc %p\n", entry->status,
1957 entry->vcc); 1912 entry->vcc);
1958 found = NULL; 1913 found = NULL;
1959 } else { 1914 } else {
1960 /* No matching entry was found */ 1915 /* No matching entry was found */
1961 entry = make_entry(priv, mac_to_find); 1916 entry = make_entry(priv, mac_to_find);
1962 pr_debug("LEC_ARP: Making entry\n"); 1917 pr_debug("Making entry\n");
1963 if (!entry) { 1918 if (!entry) {
1964 found = priv->mcast_vcc; 1919 found = priv->mcast_vcc;
1965 goto out; 1920 goto out;
@@ -1996,13 +1951,14 @@ lec_addr_delete(struct lec_priv *priv, const unsigned char *atm_addr,
1996 struct lec_arp_table *entry; 1951 struct lec_arp_table *entry;
1997 int i; 1952 int i;
1998 1953
1999 pr_debug("lec_addr_delete\n"); 1954 pr_debug("\n");
2000 spin_lock_irqsave(&priv->lec_arp_lock, flags); 1955 spin_lock_irqsave(&priv->lec_arp_lock, flags);
2001 for (i = 0; i < LEC_ARP_TABLE_SIZE; i++) { 1956 for (i = 0; i < LEC_ARP_TABLE_SIZE; i++) {
2002 hlist_for_each_entry_safe(entry, node, next, &priv->lec_arp_tables[i], next) { 1957 hlist_for_each_entry_safe(entry, node, next,
2003 if (!memcmp(atm_addr, entry->atm_addr, ATM_ESA_LEN) 1958 &priv->lec_arp_tables[i], next) {
2004 && (permanent || 1959 if (!memcmp(atm_addr, entry->atm_addr, ATM_ESA_LEN) &&
2005 !(entry->flags & LEC_PERMANENT_FLAG))) { 1960 (permanent ||
1961 !(entry->flags & LEC_PERMANENT_FLAG))) {
2006 lec_arp_remove(priv, entry); 1962 lec_arp_remove(priv, entry);
2007 lec_arp_put(entry); 1963 lec_arp_put(entry);
2008 } 1964 }
@@ -2027,10 +1983,8 @@ lec_arp_update(struct lec_priv *priv, const unsigned char *mac_addr,
2027 struct lec_arp_table *entry, *tmp; 1983 struct lec_arp_table *entry, *tmp;
2028 int i; 1984 int i;
2029 1985
2030 pr_debug("lec:%s", (targetless_le_arp) ? "targetless " : " "); 1986 pr_debug("%smac:%pM\n",
2031 pr_debug("lec_arp_update mac:%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x\n", 1987 (targetless_le_arp) ? "targetless " : "", mac_addr);
2032 mac_addr[0], mac_addr[1], mac_addr[2], mac_addr[3],
2033 mac_addr[4], mac_addr[5]);
2034 1988
2035 spin_lock_irqsave(&priv->lec_arp_lock, flags); 1989 spin_lock_irqsave(&priv->lec_arp_lock, flags);
2036 entry = lec_arp_find(priv, mac_addr); 1990 entry = lec_arp_find(priv, mac_addr);
@@ -2040,7 +1994,8 @@ lec_arp_update(struct lec_priv *priv, const unsigned char *mac_addr,
2040 * we have no entry in the cache. 7.1.30 1994 * we have no entry in the cache. 7.1.30
2041 */ 1995 */
2042 if (!hlist_empty(&priv->lec_arp_empty_ones)) { 1996 if (!hlist_empty(&priv->lec_arp_empty_ones)) {
2043 hlist_for_each_entry_safe(entry, node, next, &priv->lec_arp_empty_ones, next) { 1997 hlist_for_each_entry_safe(entry, node, next,
1998 &priv->lec_arp_empty_ones, next) {
2044 if (memcmp(entry->atm_addr, atm_addr, ATM_ESA_LEN) == 0) { 1999 if (memcmp(entry->atm_addr, atm_addr, ATM_ESA_LEN) == 0) {
2045 hlist_del(&entry->next); 2000 hlist_del(&entry->next);
2046 del_timer(&entry->timer); 2001 del_timer(&entry->timer);
@@ -2084,7 +2039,8 @@ lec_arp_update(struct lec_priv *priv, const unsigned char *mac_addr,
2084 memcpy(entry->atm_addr, atm_addr, ATM_ESA_LEN); 2039 memcpy(entry->atm_addr, atm_addr, ATM_ESA_LEN);
2085 del_timer(&entry->timer); 2040 del_timer(&entry->timer);
2086 for (i = 0; i < LEC_ARP_TABLE_SIZE; i++) { 2041 for (i = 0; i < LEC_ARP_TABLE_SIZE; i++) {
2087 hlist_for_each_entry(tmp, node, &priv->lec_arp_tables[i], next) { 2042 hlist_for_each_entry(tmp, node,
2043 &priv->lec_arp_tables[i], next) {
2088 if (entry != tmp && 2044 if (entry != tmp &&
2089 !memcmp(tmp->atm_addr, atm_addr, ATM_ESA_LEN)) { 2045 !memcmp(tmp->atm_addr, atm_addr, ATM_ESA_LEN)) {
2090 /* Vcc to this host exists */ 2046 /* Vcc to this host exists */
@@ -2129,14 +2085,13 @@ lec_vcc_added(struct lec_priv *priv, const struct atmlec_ioc *ioc_data,
2129 int i, found_entry = 0; 2085 int i, found_entry = 0;
2130 2086
2131 spin_lock_irqsave(&priv->lec_arp_lock, flags); 2087 spin_lock_irqsave(&priv->lec_arp_lock, flags);
2088 /* Vcc for Multicast Forward. No timer, LANEv2 7.1.20 and 2.3.5.3 */
2132 if (ioc_data->receive == 2) { 2089 if (ioc_data->receive == 2) {
2133 /* Vcc for Multicast Forward. No timer, LANEv2 7.1.20 and 2.3.5.3 */
2134
2135 pr_debug("LEC_ARP: Attaching mcast forward\n"); 2090 pr_debug("LEC_ARP: Attaching mcast forward\n");
2136#if 0 2091#if 0
2137 entry = lec_arp_find(priv, bus_mac); 2092 entry = lec_arp_find(priv, bus_mac);
2138 if (!entry) { 2093 if (!entry) {
2139 printk("LEC_ARP: Multicast entry not found!\n"); 2094 pr_info("LEC_ARP: Multicast entry not found!\n");
2140 goto out; 2095 goto out;
2141 } 2096 }
2142 memcpy(entry->atm_addr, ioc_data->atm_addr, ATM_ESA_LEN); 2097 memcpy(entry->atm_addr, ioc_data->atm_addr, ATM_ESA_LEN);
@@ -2157,19 +2112,17 @@ lec_vcc_added(struct lec_priv *priv, const struct atmlec_ioc *ioc_data,
2157 * Vcc which we don't want to make default vcc, 2112 * Vcc which we don't want to make default vcc,
2158 * attach it anyway. 2113 * attach it anyway.
2159 */ 2114 */
2160 pr_debug 2115 pr_debug("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",
2161 ("LEC_ARP:Attaching data direct, not default: " 2116 ioc_data->atm_addr[0], ioc_data->atm_addr[1],
2162 "%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", 2117 ioc_data->atm_addr[2], ioc_data->atm_addr[3],
2163 ioc_data->atm_addr[0], ioc_data->atm_addr[1], 2118 ioc_data->atm_addr[4], ioc_data->atm_addr[5],
2164 ioc_data->atm_addr[2], ioc_data->atm_addr[3], 2119 ioc_data->atm_addr[6], ioc_data->atm_addr[7],
2165 ioc_data->atm_addr[4], ioc_data->atm_addr[5], 2120 ioc_data->atm_addr[8], ioc_data->atm_addr[9],
2166 ioc_data->atm_addr[6], ioc_data->atm_addr[7], 2121 ioc_data->atm_addr[10], ioc_data->atm_addr[11],
2167 ioc_data->atm_addr[8], ioc_data->atm_addr[9], 2122 ioc_data->atm_addr[12], ioc_data->atm_addr[13],
2168 ioc_data->atm_addr[10], ioc_data->atm_addr[11], 2123 ioc_data->atm_addr[14], ioc_data->atm_addr[15],
2169 ioc_data->atm_addr[12], ioc_data->atm_addr[13], 2124 ioc_data->atm_addr[16], ioc_data->atm_addr[17],
2170 ioc_data->atm_addr[14], ioc_data->atm_addr[15], 2125 ioc_data->atm_addr[18], ioc_data->atm_addr[19]);
2171 ioc_data->atm_addr[16], ioc_data->atm_addr[17],
2172 ioc_data->atm_addr[18], ioc_data->atm_addr[19]);
2173 entry = make_entry(priv, bus_mac); 2126 entry = make_entry(priv, bus_mac);
2174 if (entry == NULL) 2127 if (entry == NULL)
2175 goto out; 2128 goto out;
@@ -2185,29 +2138,28 @@ lec_vcc_added(struct lec_priv *priv, const struct atmlec_ioc *ioc_data,
2185 dump_arp_table(priv); 2138 dump_arp_table(priv);
2186 goto out; 2139 goto out;
2187 } 2140 }
2188 pr_debug 2141 pr_debug("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",
2189 ("LEC_ARP:Attaching data direct, default: " 2142 ioc_data->atm_addr[0], ioc_data->atm_addr[1],
2190 "%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", 2143 ioc_data->atm_addr[2], ioc_data->atm_addr[3],
2191 ioc_data->atm_addr[0], ioc_data->atm_addr[1], 2144 ioc_data->atm_addr[4], ioc_data->atm_addr[5],
2192 ioc_data->atm_addr[2], ioc_data->atm_addr[3], 2145 ioc_data->atm_addr[6], ioc_data->atm_addr[7],
2193 ioc_data->atm_addr[4], ioc_data->atm_addr[5], 2146 ioc_data->atm_addr[8], ioc_data->atm_addr[9],
2194 ioc_data->atm_addr[6], ioc_data->atm_addr[7], 2147 ioc_data->atm_addr[10], ioc_data->atm_addr[11],
2195 ioc_data->atm_addr[8], ioc_data->atm_addr[9], 2148 ioc_data->atm_addr[12], ioc_data->atm_addr[13],
2196 ioc_data->atm_addr[10], ioc_data->atm_addr[11], 2149 ioc_data->atm_addr[14], ioc_data->atm_addr[15],
2197 ioc_data->atm_addr[12], ioc_data->atm_addr[13], 2150 ioc_data->atm_addr[16], ioc_data->atm_addr[17],
2198 ioc_data->atm_addr[14], ioc_data->atm_addr[15], 2151 ioc_data->atm_addr[18], ioc_data->atm_addr[19]);
2199 ioc_data->atm_addr[16], ioc_data->atm_addr[17],
2200 ioc_data->atm_addr[18], ioc_data->atm_addr[19]);
2201 for (i = 0; i < LEC_ARP_TABLE_SIZE; i++) { 2152 for (i = 0; i < LEC_ARP_TABLE_SIZE; i++) {
2202 hlist_for_each_entry(entry, node, &priv->lec_arp_tables[i], next) { 2153 hlist_for_each_entry(entry, node,
2154 &priv->lec_arp_tables[i], next) {
2203 if (memcmp 2155 if (memcmp
2204 (ioc_data->atm_addr, entry->atm_addr, 2156 (ioc_data->atm_addr, entry->atm_addr,
2205 ATM_ESA_LEN) == 0) { 2157 ATM_ESA_LEN) == 0) {
2206 pr_debug("LEC_ARP: Attaching data direct\n"); 2158 pr_debug("LEC_ARP: Attaching data direct\n");
2207 pr_debug("Currently -> Vcc: %d, Rvcc:%d\n", 2159 pr_debug("Currently -> Vcc: %d, Rvcc:%d\n",
2208 entry->vcc ? entry->vcc->vci : 0, 2160 entry->vcc ? entry->vcc->vci : 0,
2209 entry->recv_vcc ? entry->recv_vcc-> 2161 entry->recv_vcc ? entry->recv_vcc->
2210 vci : 0); 2162 vci : 0);
2211 found_entry = 1; 2163 found_entry = 1;
2212 del_timer(&entry->timer); 2164 del_timer(&entry->timer);
2213 entry->vcc = vcc; 2165 entry->vcc = vcc;
@@ -2279,19 +2231,21 @@ static void lec_flush_complete(struct lec_priv *priv, unsigned long tran_id)
2279 struct lec_arp_table *entry; 2231 struct lec_arp_table *entry;
2280 int i; 2232 int i;
2281 2233
2282 pr_debug("LEC:lec_flush_complete %lx\n", tran_id); 2234 pr_debug("%lx\n", tran_id);
2283restart: 2235restart:
2284 spin_lock_irqsave(&priv->lec_arp_lock, flags); 2236 spin_lock_irqsave(&priv->lec_arp_lock, flags);
2285 for (i = 0; i < LEC_ARP_TABLE_SIZE; i++) { 2237 for (i = 0; i < LEC_ARP_TABLE_SIZE; i++) {
2286 hlist_for_each_entry(entry, node, &priv->lec_arp_tables[i], next) { 2238 hlist_for_each_entry(entry, node,
2287 if (entry->flush_tran_id == tran_id 2239 &priv->lec_arp_tables[i], next) {
2288 && entry->status == ESI_FLUSH_PENDING) { 2240 if (entry->flush_tran_id == tran_id &&
2241 entry->status == ESI_FLUSH_PENDING) {
2289 struct sk_buff *skb; 2242 struct sk_buff *skb;
2290 struct atm_vcc *vcc = entry->vcc; 2243 struct atm_vcc *vcc = entry->vcc;
2291 2244
2292 lec_arp_hold(entry); 2245 lec_arp_hold(entry);
2293 spin_unlock_irqrestore(&priv->lec_arp_lock, flags); 2246 spin_unlock_irqrestore(&priv->lec_arp_lock,
2294 while ((skb = skb_dequeue(&entry->tx_wait)) != NULL) 2247 flags);
2248 while ((skb = skb_dequeue(&entry->tx_wait)))
2295 lec_send(vcc, skb); 2249 lec_send(vcc, skb);
2296 entry->last_used = jiffies; 2250 entry->last_used = jiffies;
2297 entry->status = ESI_FORWARD_DIRECT; 2251 entry->status = ESI_FORWARD_DIRECT;
@@ -2316,11 +2270,12 @@ lec_set_flush_tran_id(struct lec_priv *priv,
2316 2270
2317 spin_lock_irqsave(&priv->lec_arp_lock, flags); 2271 spin_lock_irqsave(&priv->lec_arp_lock, flags);
2318 for (i = 0; i < LEC_ARP_TABLE_SIZE; i++) 2272 for (i = 0; i < LEC_ARP_TABLE_SIZE; i++)
2319 hlist_for_each_entry(entry, node, &priv->lec_arp_tables[i], next) { 2273 hlist_for_each_entry(entry, node,
2274 &priv->lec_arp_tables[i], next) {
2320 if (!memcmp(atm_addr, entry->atm_addr, ATM_ESA_LEN)) { 2275 if (!memcmp(atm_addr, entry->atm_addr, ATM_ESA_LEN)) {
2321 entry->flush_tran_id = tran_id; 2276 entry->flush_tran_id = tran_id;
2322 pr_debug("Set flush transaction id to %lx for %p\n", 2277 pr_debug("Set flush transaction id to %lx for %p\n",
2323 tran_id, entry); 2278 tran_id, entry);
2324 } 2279 }
2325 } 2280 }
2326 spin_unlock_irqrestore(&priv->lec_arp_lock, flags); 2281 spin_unlock_irqrestore(&priv->lec_arp_lock, flags);
@@ -2336,7 +2291,8 @@ static int lec_mcast_make(struct lec_priv *priv, struct atm_vcc *vcc)
2336 struct lec_vcc_priv *vpriv; 2291 struct lec_vcc_priv *vpriv;
2337 int err = 0; 2292 int err = 0;
2338 2293
2339 if (!(vpriv = kmalloc(sizeof(struct lec_vcc_priv), GFP_KERNEL))) 2294 vpriv = kmalloc(sizeof(struct lec_vcc_priv), GFP_KERNEL);
2295 if (!vpriv)
2340 return -ENOMEM; 2296 return -ENOMEM;
2341 vpriv->xoff = 0; 2297 vpriv->xoff = 0;
2342 vpriv->old_pop = vcc->pop; 2298 vpriv->old_pop = vcc->pop;
@@ -2376,18 +2332,19 @@ static void lec_vcc_close(struct lec_priv *priv, struct atm_vcc *vcc)
2376 spin_lock_irqsave(&priv->lec_arp_lock, flags); 2332 spin_lock_irqsave(&priv->lec_arp_lock, flags);
2377 2333
2378 for (i = 0; i < LEC_ARP_TABLE_SIZE; i++) { 2334 for (i = 0; i < LEC_ARP_TABLE_SIZE; i++) {
2379 hlist_for_each_entry_safe(entry, node, next, &priv->lec_arp_tables[i], next) { 2335 hlist_for_each_entry_safe(entry, node, next,
2336 &priv->lec_arp_tables[i], next) {
2380 if (vcc == entry->vcc) { 2337 if (vcc == entry->vcc) {
2381 lec_arp_remove(priv, entry); 2338 lec_arp_remove(priv, entry);
2382 lec_arp_put(entry); 2339 lec_arp_put(entry);
2383 if (priv->mcast_vcc == vcc) { 2340 if (priv->mcast_vcc == vcc)
2384 priv->mcast_vcc = NULL; 2341 priv->mcast_vcc = NULL;
2385 }
2386 } 2342 }
2387 } 2343 }
2388 } 2344 }
2389 2345
2390 hlist_for_each_entry_safe(entry, node, next, &priv->lec_arp_empty_ones, next) { 2346 hlist_for_each_entry_safe(entry, node, next,
2347 &priv->lec_arp_empty_ones, next) {
2391 if (entry->vcc == vcc) { 2348 if (entry->vcc == vcc) {
2392 lec_arp_clear_vccs(entry); 2349 lec_arp_clear_vccs(entry);
2393 del_timer(&entry->timer); 2350 del_timer(&entry->timer);
@@ -2396,7 +2353,8 @@ static void lec_vcc_close(struct lec_priv *priv, struct atm_vcc *vcc)
2396 } 2353 }
2397 } 2354 }
2398 2355
2399 hlist_for_each_entry_safe(entry, node, next, &priv->lec_no_forward, next) { 2356 hlist_for_each_entry_safe(entry, node, next,
2357 &priv->lec_no_forward, next) {
2400 if (entry->recv_vcc == vcc) { 2358 if (entry->recv_vcc == vcc) {
2401 lec_arp_clear_vccs(entry); 2359 lec_arp_clear_vccs(entry);
2402 del_timer(&entry->timer); 2360 del_timer(&entry->timer);
@@ -2437,14 +2395,16 @@ lec_arp_check_empties(struct lec_priv *priv,
2437 src = hdr->h_source; 2395 src = hdr->h_source;
2438 2396
2439 spin_lock_irqsave(&priv->lec_arp_lock, flags); 2397 spin_lock_irqsave(&priv->lec_arp_lock, flags);
2440 hlist_for_each_entry_safe(entry, node, next, &priv->lec_arp_empty_ones, next) { 2398 hlist_for_each_entry_safe(entry, node, next,
2399 &priv->lec_arp_empty_ones, next) {
2441 if (vcc == entry->vcc) { 2400 if (vcc == entry->vcc) {
2442 del_timer(&entry->timer); 2401 del_timer(&entry->timer);
2443 memcpy(entry->mac_addr, src, ETH_ALEN); 2402 memcpy(entry->mac_addr, src, ETH_ALEN);
2444 entry->status = ESI_FORWARD_DIRECT; 2403 entry->status = ESI_FORWARD_DIRECT;
2445 entry->last_used = jiffies; 2404 entry->last_used = jiffies;
2446 /* We might have got an entry */ 2405 /* We might have got an entry */
2447 if ((tmp = lec_arp_find(priv, src))) { 2406 tmp = lec_arp_find(priv, src);
2407 if (tmp) {
2448 lec_arp_remove(priv, tmp); 2408 lec_arp_remove(priv, tmp);
2449 lec_arp_put(tmp); 2409 lec_arp_put(tmp);
2450 } 2410 }