diff options
author | Chas Williams <chas@cmf.nrl.navy.mil> | 2006-09-29 17:11:47 -0700 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2006-09-29 17:11:47 -0700 |
commit | 1fa9961d631fcde21cc42678157129c6fae7fe6d (patch) | |
tree | c9cfa49762b2d0aa33d9fc2e309b3d088f8c51f7 /net | |
parent | d44f77466cfdc6f1d1e3870e176afedab7f46a42 (diff) |
[ATM]: [lec] indent, comment and whitespace cleanup [continued]
Signed-off-by: Chas Williams <chas@cmf.nrl.navy.mil>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net')
-rw-r--r-- | net/atm/lec.c | 1783 |
1 files changed, 899 insertions, 884 deletions
diff --git a/net/atm/lec.c b/net/atm/lec.c index 543960c86fa..d2b44e91bad 100644 --- a/net/atm/lec.c +++ b/net/atm/lec.c @@ -1418,7 +1418,6 @@ static void lane2_associate_ind(struct net_device *dev, u8 *mac_addr, * * lec_arpc.c was added here when making * lane client modular. October 1997 - * */ #include <linux/types.h> @@ -1429,7 +1428,6 @@ static void lane2_associate_ind(struct net_device *dev, u8 *mac_addr, #include <linux/inetdevice.h> #include <net/route.h> - #if 0 #define DPRINTK(format,args...) /* @@ -1452,296 +1450,294 @@ static void lec_arp_expire_arp(unsigned long data); /* * Initialization of arp-cache */ -static void -lec_arp_init(struct lec_priv *priv) +static void lec_arp_init(struct lec_priv *priv) { - unsigned short i; + unsigned short i; - for (i = 0; i < LEC_ARP_TABLE_SIZE; i++) { - priv->lec_arp_tables[i] = NULL; - } + for (i = 0; i < LEC_ARP_TABLE_SIZE; i++) { + priv->lec_arp_tables[i] = NULL; + } spin_lock_init(&priv->lec_arp_lock); - init_timer(&priv->lec_arp_timer); - priv->lec_arp_timer.expires = jiffies + LEC_ARP_REFRESH_INTERVAL; - priv->lec_arp_timer.data = (unsigned long)priv; - priv->lec_arp_timer.function = lec_arp_check_expire; - add_timer(&priv->lec_arp_timer); + init_timer(&priv->lec_arp_timer); + priv->lec_arp_timer.expires = jiffies + LEC_ARP_REFRESH_INTERVAL; + priv->lec_arp_timer.data = (unsigned long)priv; + priv->lec_arp_timer.function = lec_arp_check_expire; + add_timer(&priv->lec_arp_timer); } -static void -lec_arp_clear_vccs(struct lec_arp_table *entry) +static void lec_arp_clear_vccs(struct lec_arp_table *entry) { - if (entry->vcc) { + if (entry->vcc) { struct atm_vcc *vcc = entry->vcc; struct lec_vcc_priv *vpriv = LEC_VCC_PRIV(vcc); - struct net_device *dev = (struct net_device*) vcc->proto_data; + struct net_device *dev = (struct net_device *)vcc->proto_data; - vcc->pop = vpriv->old_pop; + vcc->pop = vpriv->old_pop; if (vpriv->xoff) netif_wake_queue(dev); kfree(vpriv); vcc->user_back = NULL; - vcc->push = entry->old_push; + vcc->push = entry->old_push; vcc_release_async(vcc, -EPIPE); - vcc = NULL; - } - if (entry->recv_vcc) { - entry->recv_vcc->push = entry->old_recv_push; + vcc = NULL; + } + if (entry->recv_vcc) { + entry->recv_vcc->push = entry->old_recv_push; vcc_release_async(entry->recv_vcc, -EPIPE); - entry->recv_vcc = NULL; - } + entry->recv_vcc = NULL; + } } /* * Insert entry to lec_arp_table * LANE2: Add to the end of the list to satisfy 8.1.13 */ -static inline void +static inline void lec_arp_add(struct lec_priv *priv, struct lec_arp_table *to_add) { - unsigned short place; - struct lec_arp_table *tmp; - - place = HASH(to_add->mac_addr[ETH_ALEN-1]); - tmp = priv->lec_arp_tables[place]; - to_add->next = NULL; - if (tmp == NULL) - priv->lec_arp_tables[place] = to_add; - - else { /* add to the end */ - while (tmp->next) - tmp = tmp->next; - tmp->next = to_add; - } - - DPRINTK("LEC_ARP: Added entry:%2.2x %2.2x %2.2x %2.2x %2.2x %2.2x\n", - 0xff&to_add->mac_addr[0], 0xff&to_add->mac_addr[1], - 0xff&to_add->mac_addr[2], 0xff&to_add->mac_addr[3], - 0xff&to_add->mac_addr[4], 0xff&to_add->mac_addr[5]); + unsigned short place; + struct lec_arp_table *tmp; + + place = HASH(to_add->mac_addr[ETH_ALEN - 1]); + tmp = priv->lec_arp_tables[place]; + to_add->next = NULL; + if (tmp == NULL) + priv->lec_arp_tables[place] = to_add; + + else { /* add to the end */ + while (tmp->next) + tmp = tmp->next; + tmp->next = to_add; + } + + DPRINTK("LEC_ARP: Added entry:%2.2x %2.2x %2.2x %2.2x %2.2x %2.2x\n", + 0xff & to_add->mac_addr[0], 0xff & to_add->mac_addr[1], + 0xff & to_add->mac_addr[2], 0xff & to_add->mac_addr[3], + 0xff & to_add->mac_addr[4], 0xff & to_add->mac_addr[5]); } /* * Remove entry from lec_arp_table */ -static int -lec_arp_remove(struct lec_priv *priv, - struct lec_arp_table *to_remove) +static int +lec_arp_remove(struct lec_priv *priv, struct lec_arp_table *to_remove) { - unsigned short place; - struct lec_arp_table *tmp; - int remove_vcc=1; - - if (!to_remove) { - return -1; - } - place = HASH(to_remove->mac_addr[ETH_ALEN-1]); - tmp = priv->lec_arp_tables[place]; - if (tmp == to_remove) { - priv->lec_arp_tables[place] = tmp->next; - } else { - while(tmp && tmp->next != to_remove) { - tmp = tmp->next; - } - if (!tmp) {/* Entry was not found */ - return -1; - } - } - tmp->next = to_remove->next; - del_timer(&to_remove->timer); - - /* If this is the only MAC connected to this VCC, also tear down - the VCC */ - if (to_remove->status >= ESI_FLUSH_PENDING) { - /* - * ESI_FLUSH_PENDING, ESI_FORWARD_DIRECT - */ - for(place = 0; place < LEC_ARP_TABLE_SIZE; place++) { - for(tmp = priv->lec_arp_tables[place]; tmp != NULL; tmp = tmp->next) { - if (memcmp(tmp->atm_addr, to_remove->atm_addr, - ATM_ESA_LEN)==0) { - remove_vcc=0; - break; - } - } - } - if (remove_vcc) - lec_arp_clear_vccs(to_remove); - } - skb_queue_purge(&to_remove->tx_wait); /* FIXME: good place for this? */ - - DPRINTK("LEC_ARP: Removed entry:%2.2x %2.2x %2.2x %2.2x %2.2x %2.2x\n", - 0xff&to_remove->mac_addr[0], 0xff&to_remove->mac_addr[1], - 0xff&to_remove->mac_addr[2], 0xff&to_remove->mac_addr[3], - 0xff&to_remove->mac_addr[4], 0xff&to_remove->mac_addr[5]); - return 0; + unsigned short place; + struct lec_arp_table *tmp; + int remove_vcc = 1; + + if (!to_remove) { + return -1; + } + place = HASH(to_remove->mac_addr[ETH_ALEN - 1]); + tmp = priv->lec_arp_tables[place]; + if (tmp == to_remove) { + priv->lec_arp_tables[place] = tmp->next; + } else { + while (tmp && tmp->next != to_remove) { + tmp = tmp->next; + } + if (!tmp) { /* Entry was not found */ + return -1; + } + } + tmp->next = to_remove->next; + del_timer(&to_remove->timer); + + /* If this is the only MAC connected to this VCC, also tear down + the VCC */ + if (to_remove->status >= ESI_FLUSH_PENDING) { + /* + * ESI_FLUSH_PENDING, ESI_FORWARD_DIRECT + */ + for (place = 0; place < LEC_ARP_TABLE_SIZE; place++) { + for (tmp = priv->lec_arp_tables[place]; tmp != NULL; + tmp = tmp->next) { + if (memcmp + (tmp->atm_addr, to_remove->atm_addr, + ATM_ESA_LEN) == 0) { + remove_vcc = 0; + break; + } + } + } + if (remove_vcc) + lec_arp_clear_vccs(to_remove); + } + skb_queue_purge(&to_remove->tx_wait); /* FIXME: good place for this? */ + + DPRINTK("LEC_ARP: Removed entry:%2.2x %2.2x %2.2x %2.2x %2.2x %2.2x\n", + 0xff & to_remove->mac_addr[0], 0xff & to_remove->mac_addr[1], + 0xff & to_remove->mac_addr[2], 0xff & to_remove->mac_addr[3], + 0xff & to_remove->mac_addr[4], 0xff & to_remove->mac_addr[5]); + return 0; } #if DEBUG_ARP_TABLE -static char* -get_status_string(unsigned char st) +static char *get_status_string(unsigned char st) { - switch(st) { - case ESI_UNKNOWN: - return "ESI_UNKNOWN"; - case ESI_ARP_PENDING: - return "ESI_ARP_PENDING"; - case ESI_VC_PENDING: - return "ESI_VC_PENDING"; - case ESI_FLUSH_PENDING: - return "ESI_FLUSH_PENDING"; - case ESI_FORWARD_DIRECT: - return "ESI_FORWARD_DIRECT"; - default: - return "<UNKNOWN>"; - } + switch (st) { + case ESI_UNKNOWN: + return "ESI_UNKNOWN"; + case ESI_ARP_PENDING: + return "ESI_ARP_PENDING"; + case ESI_VC_PENDING: + return "ESI_VC_PENDING"; + case ESI_FLUSH_PENDING: + return "ESI_FLUSH_PENDING"; + case ESI_FORWARD_DIRECT: + return "ESI_FORWARD_DIRECT"; + default: + return "<UNKNOWN>"; + } } #endif -static void -dump_arp_table(struct lec_priv *priv) +static void dump_arp_table(struct lec_priv *priv) { #if DEBUG_ARP_TABLE - int i,j, offset; - struct lec_arp_table *rulla; - char buf[1024]; - struct lec_arp_table **lec_arp_tables = - (struct lec_arp_table **)priv->lec_arp_tables; - struct lec_arp_table *lec_arp_empty_ones = - (struct lec_arp_table *)priv->lec_arp_empty_ones; - struct lec_arp_table *lec_no_forward = - (struct lec_arp_table *)priv->lec_no_forward; - struct lec_arp_table *mcast_fwds = priv->mcast_fwds; - - - printk("Dump %p:\n",priv); - for (i=0;i<LEC_ARP_TABLE_SIZE;i++) { - rulla = lec_arp_tables[i]; - offset = 0; - offset += sprintf(buf,"%d: %p\n",i, rulla); - while (rulla) { - offset += sprintf(buf+offset,"Mac:"); - for(j=0;j<ETH_ALEN;j++) { - offset+=sprintf(buf+offset, - "%2.2x ", - rulla->mac_addr[j]&0xff); - } - offset +=sprintf(buf+offset,"Atm:"); - for(j=0;j<ATM_ESA_LEN;j++) { - offset+=sprintf(buf+offset, - "%2.2x ", - rulla->atm_addr[j]&0xff); - } - offset+=sprintf(buf+offset, - "Vcc vpi:%d vci:%d, Recv_vcc vpi:%d vci:%d Last_used:%lx, Timestamp:%lx, No_tries:%d ", - rulla->vcc?rulla->vcc->vpi:0, - rulla->vcc?rulla->vcc->vci:0, - rulla->recv_vcc?rulla->recv_vcc->vpi:0, - rulla->recv_vcc?rulla->recv_vcc->vci:0, - rulla->last_used, - rulla->timestamp, rulla->no_tries); - offset+=sprintf(buf+offset, - "Flags:%x, Packets_flooded:%x, Status: %s ", - rulla->flags, rulla->packets_flooded, - get_status_string(rulla->status)); - offset+=sprintf(buf+offset,"->%p\n",rulla->next); - rulla = rulla->next; - } - printk("%s",buf); - } - rulla = lec_no_forward; - if (rulla) - printk("No forward\n"); - while(rulla) { - offset=0; - offset += sprintf(buf+offset,"Mac:"); - for(j=0;j<ETH_ALEN;j++) { - offset+=sprintf(buf+offset,"%2.2x ", - rulla->mac_addr[j]&0xff); - } - offset +=sprintf(buf+offset,"Atm:"); - for(j=0;j<ATM_ESA_LEN;j++) { - offset+=sprintf(buf+offset,"%2.2x ", - rulla->atm_addr[j]&0xff); - } - offset+=sprintf(buf+offset, - "Vcc vpi:%d vci:%d, Recv_vcc vpi:%d vci:%d Last_used:%lx, Timestamp:%lx, No_tries:%d ", - rulla->vcc?rulla->vcc->vpi:0, - rulla->vcc?rulla->vcc->vci:0, - rulla->recv_vcc?rulla->recv_vcc->vpi:0, - rulla->recv_vcc?rulla->recv_vcc->vci:0, - rulla->last_used, - rulla->timestamp, rulla->no_tries); - offset+=sprintf(buf+offset, - "Flags:%x, Packets_flooded:%x, Status: %s ", - rulla->flags, rulla->packets_flooded, - get_status_string(rulla->status)); - offset+=sprintf(buf+offset,"->%lx\n",(long)rulla->next); - rulla = rulla->next; - printk("%s",buf); - } - rulla = lec_arp_empty_ones; - if (rulla) - printk("Empty ones\n"); - while(rulla) { - offset=0; - offset += sprintf(buf+offset,"Mac:"); - for(j=0;j<ETH_ALEN;j++) { - offset+=sprintf(buf+offset,"%2.2x ", - rulla->mac_addr[j]&0xff); - } - offset +=sprintf(buf+offset,"Atm:"); - for(j=0;j<ATM_ESA_LEN;j++) { - offset+=sprintf(buf+offset,"%2.2x ", - rulla->atm_addr[j]&0xff); - } - offset+=sprintf(buf+offset, - "Vcc vpi:%d vci:%d, Recv_vcc vpi:%d vci:%d Last_used:%lx, Timestamp:%lx, No_tries:%d ", - rulla->vcc?rulla->vcc->vpi:0, - rulla->vcc?rulla->vcc->vci:0, - rulla->recv_vcc?rulla->recv_vcc->vpi:0, - rulla->recv_vcc?rulla->recv_vcc->vci:0, - rulla->last_used, - rulla->timestamp, rulla->no_tries); - offset+=sprintf(buf+offset, - "Flags:%x, Packets_flooded:%x, Status: %s ", - rulla->flags, rulla->packets_flooded, - get_status_string(rulla->status)); - offset+=sprintf(buf+offset,"->%lx\n",(long)rulla->next); - rulla = rulla->next; - printk("%s",buf); - } - - rulla = mcast_fwds; - if (rulla) - printk("Multicast Forward VCCs\n"); - while(rulla) { - offset=0; - offset += sprintf(buf+offset,"Mac:"); - for(j=0;j<ETH_ALEN;j++) { - offset+=sprintf(buf+offset,"%2.2x ", - rulla->mac_addr[j]&0xff); - } - offset +=sprintf(buf+offset,"Atm:"); - for(j=0;j<ATM_ESA_LEN;j++) { - offset+=sprintf(buf+offset,"%2.2x ", - rulla->atm_addr[j]&0xff); - } - offset+=sprintf(buf+offset, - "Vcc vpi:%d vci:%d, Recv_vcc vpi:%d vci:%d Last_used:%lx, Timestamp:%lx, No_tries:%d ", - rulla->vcc?rulla->vcc->vpi:0, - rulla->vcc?rulla->vcc->vci:0, - rulla->recv_vcc?rulla->recv_vcc->vpi:0, - rulla->recv_vcc?rulla->recv_vcc->vci:0, - rulla->last_used, - rulla->timestamp, rulla->no_tries); - offset+=sprintf(buf+offset, - "Flags:%x, Packets_flooded:%x, Status: %s ", - rulla->flags, rulla->packets_flooded, - get_status_string(rulla->status)); - offset+=sprintf(buf+offset,"->%lx\n",(long)rulla->next); - rulla = rulla->next; - printk("%s",buf); - } + int i, j, offset; + struct lec_arp_table *rulla; + char buf[1024]; + struct lec_arp_table **lec_arp_tables = + (struct lec_arp_table **)priv->lec_arp_tables; + struct lec_arp_table *lec_arp_empty_ones = + (struct lec_arp_table *)priv->lec_arp_empty_ones; + struct lec_arp_table *lec_no_forward = + (struct lec_arp_table *)priv->lec_no_forward; + struct lec_arp_table *mcast_fwds = priv->mcast_fwds; + + printk("Dump %p:\n", priv); + for (i = 0; i < LEC_ARP_TABLE_SIZE; i++) { + rulla = lec_arp_tables[i]; + offset = 0; + offset += sprintf(buf, "%d: %p\n", i, rulla); + while (rulla) { + offset += sprintf(buf + offset, "Mac:"); + for (j = 0; j < ETH_ALEN; j++) { + offset += sprintf(buf + offset, + "%2.2x ", + rulla->mac_addr[j] & 0xff); + } + offset += sprintf(buf + offset, "Atm:"); + for (j = 0; j < ATM_ESA_LEN; j++) { + offset += sprintf(buf + offset, + "%2.2x ", + rulla->atm_addr[j] & 0xff); + } + offset += sprintf(buf + offset, + "Vcc vpi:%d vci:%d, Recv_vcc vpi:%d vci:%d Last_used:%lx, Timestamp:%lx, No_tries:%d ", + rulla->vcc ? rulla->vcc->vpi : 0, + rulla->vcc ? rulla->vcc->vci : 0, + rulla->recv_vcc ? rulla->recv_vcc-> + vpi : 0, + rulla->recv_vcc ? rulla->recv_vcc-> + vci : 0, rulla->last_used, + rulla->timestamp, rulla->no_tries); + offset += + sprintf(buf + offset, + "Flags:%x, Packets_flooded:%x, Status: %s ", + rulla->flags, rulla->packets_flooded, + get_status_string(rulla->status)); + offset += sprintf(buf + offset, "->%p\n", rulla->next); + rulla = rulla->next; + } + printk("%s", buf); + } + rulla = lec_no_forward; + if (rulla) + printk("No forward\n"); + while (rulla) { + offset = 0; + offset += sprintf(buf + offset, "Mac:"); + for (j = 0; j < ETH_ALEN; j++) { + offset += sprintf(buf + offset, "%2.2x ", + rulla->mac_addr[j] & 0xff); + } + offset += sprintf(buf + offset, "Atm:"); + for (j = 0; j < ATM_ESA_LEN; j++) { + offset += sprintf(buf + offset, "%2.2x ", + rulla->atm_addr[j] & 0xff); + } + offset += sprintf(buf + offset, + "Vcc vpi:%d vci:%d, Recv_vcc vpi:%d vci:%d Last_used:%lx, Timestamp:%lx, No_tries:%d ", + rulla->vcc ? rulla->vcc->vpi : 0, + rulla->vcc ? rulla->vcc->vci : 0, + rulla->recv_vcc ? rulla->recv_vcc->vpi : 0, + rulla->recv_vcc ? rulla->recv_vcc->vci : 0, + rulla->last_used, + rulla->timestamp, rulla->no_tries); + offset += sprintf(buf + offset, + "Flags:%x, Packets_flooded:%x, Status: %s ", + rulla->flags, rulla->packets_flooded, + get_status_string(rulla->status)); + offset += sprintf(buf + offset, "->%lx\n", (long)rulla->next); + rulla = rulla->next; + printk("%s", buf); + } + rulla = lec_arp_empty_ones; + if (rulla) + printk("Empty ones\n"); + while (rulla) { + offset = 0; + offset += sprintf(buf + offset, "Mac:"); + for (j = 0; j < ETH_ALEN; j++) { + offset += sprintf(buf + offset, "%2.2x ", + rulla->mac_addr[j] & 0xff); + } + offset += sprintf(buf + offset, "Atm:"); + for (j = 0; j < ATM_ESA_LEN; j++) { + offset += sprintf(buf + offset, "%2.2x ", + rulla->atm_addr[j] & 0xff); + } + offset += sprintf(buf + offset, + "Vcc vpi:%d vci:%d, Recv_vcc vpi:%d vci:%d Last_used:%lx, Timestamp:%lx, No_tries:%d ", + rulla->vcc ? rulla->vcc->vpi : 0, + rulla->vcc ? rulla->vcc->vci : 0, + rulla->recv_vcc ? rulla->recv_vcc->vpi : 0, + rulla->recv_vcc ? rulla->recv_vcc->vci : 0, + rulla->last_used, + rulla->timestamp, rulla->no_tries); + offset += sprintf(buf + offset, + "Flags:%x, Packets_flooded:%x, Status: %s ", + rulla->flags, rulla->packets_flooded, + get_status_string(rulla->status)); + offset += sprintf(buf + offset, "->%lx\n", (long)rulla->next); + rulla = rulla->next; + printk("%s", buf); + } + + rulla = mcast_fwds; + if (rulla) + printk("Multicast Forward VCCs\n"); + while (rulla) { + offset = 0; + offset += sprintf(buf + offset, "Mac:"); + for (j = 0; j < ETH_ALEN; j++) { + offset += sprintf(buf + offset, "%2.2x ", + rulla->mac_addr[j] & 0xff); + } + offset += sprintf(buf + offset, "Atm:"); + for (j = 0; j < ATM_ESA_LEN; j++) { + offset += sprintf(buf + offset, "%2.2x ", + rulla->atm_addr[j] & 0xff); + } + offset += sprintf(buf + offset, + "Vcc vpi:%d vci:%d, Recv_vcc vpi:%d vci:%d Last_used:%lx, Timestamp:%lx, No_tries:%d ", + rulla->vcc ? rulla->vcc->vpi : 0, + rulla->vcc ? rulla->vcc->vci : 0, + rulla->recv_vcc ? rulla->recv_vcc->vpi : 0, + rulla->recv_vcc ? rulla->recv_vcc->vci : 0, + rulla->last_used, + rulla->timestamp, rulla->no_tries); + offset += sprintf(buf + offset, + "Flags:%x, Packets_flooded:%x, Status: %s ", + rulla->flags, rulla->packets_flooded, + get_status_string(rulla->status)); + offset += sprintf(buf + offset, "->%lx\n", (long)rulla->next); + rulla = rulla->next; + printk("%s", buf); + } #endif } @@ -1749,177 +1745,168 @@ dump_arp_table(struct lec_priv *priv) /* * Destruction of arp-cache */ -static void -lec_arp_destroy(struct lec_priv *priv) +static void lec_arp_destroy(struct lec_priv *priv) { unsigned long flags; - struct lec_arp_table *entry, *next; - int i; + struct lec_arp_table *entry, *next; + int i; + + del_timer_sync(&priv->lec_arp_timer); - del_timer_sync(&priv->lec_arp_timer); - - /* - * Remove all entries - */ + /* + * Remove all entries + */ spin_lock_irqsave(&priv->lec_arp_lock, flags); - for (i = 0; i < LEC_ARP_TABLE_SIZE; i++) { - for(entry = priv->lec_arp_tables[i]; entry != NULL; entry=next) { - next = entry->next; - lec_arp_remove(priv, entry); - kfree(entry); - } - } - entry = priv->lec_arp_empty_ones; - while(entry) { - next = entry->next; - del_timer_sync(&entry->timer); - lec_arp_clear_vccs(entry); - kfree(entry); - entry = next; - } - priv->lec_arp_empty_ones = NULL; - entry = priv->lec_no_forward; - while(entry) { - next = entry->next; - del_timer_sync(&entry->timer); - lec_arp_clear_vccs(entry); - kfree(entry); - entry = next; - } - priv->lec_no_forward = NULL; - entry = priv->mcast_fwds; - while(entry) { - next = entry->next; - /* No timer, LANEv2 7.1.20 and 2.3.5.3 */ - lec_arp_clear_vccs(entry); - kfree(entry); - entry = next; - } - priv->mcast_fwds = NULL; - priv->mcast_vcc = NULL; - memset(priv->lec_arp_tables, 0, - sizeof(struct lec_arp_table *) * LEC_ARP_TABLE_SIZE); + for (i = 0; i < LEC_ARP_TABLE_SIZE; i++) { + for (entry = priv->lec_arp_tables[i]; entry != NULL; + entry = next) { + next = entry->next; + lec_arp_remove(priv, entry); + kfree(entry); + } + } + entry = priv->lec_arp_empty_ones; + while (entry) { + next = entry->next; + del_timer_sync(&entry->timer); + lec_arp_clear_vccs(entry); + kfree(entry); + entry = next; + } + priv->lec_arp_empty_ones = NULL; + entry = priv->lec_no_forward; + while (entry) { + next = entry->next; + del_timer_sync(&entry->timer); + lec_arp_clear_vccs(entry); + kfree(entry); + entry = next; + } + priv->lec_no_forward = NULL; + entry = priv->mcast_fwds; + while (entry) { + next = entry->next; + /* No timer, LANEv2 7.1.20 and 2.3.5.3 */ + lec_arp_clear_vccs(entry); + kfree(entry); + entry = next; + } + priv->mcast_fwds = NULL; + priv->mcast_vcc = NULL; + memset(priv->lec_arp_tables, 0, + sizeof(struct lec_arp_table *) * LEC_ARP_TABLE_SIZE); spin_unlock_irqrestore(&priv->lec_arp_lock, flags); } - /* * Find entry by mac_address */ -static struct lec_arp_table* -lec_arp_find(struct lec_priv *priv, - unsigned char *mac_addr) +static struct lec_arp_table *lec_arp_find(struct lec_priv *priv, + unsigned char *mac_addr) { - unsigned short place; - struct lec_arp_table *to_return; - - DPRINTK("LEC_ARP: lec_arp_find :%2.2x %2.2x %2.2x %2.2x %2.2x %2.2x\n", - mac_addr[0]&0xff, mac_addr[1]&0xff, mac_addr[2]&0xff, - mac_addr[3]&0xff, mac_addr[4]&0xff, mac_addr[5]&0xff); - place = HASH(mac_addr[ETH_ALEN-1]); - - to_return = priv->lec_arp_tables[place]; - while(to_return) { - if (!compare_ether_addr(mac_addr, to_return->mac_addr)) { - return to_return; - } - to_return = to_return->next; - } - return NULL; + unsigned short place; + struct lec_arp_table *to_return; + + DPRINTK("LEC_ARP: lec_arp_find :%2.2x %2.2x %2.2x %2.2x %2.2x %2.2x\n", + mac_addr[0] & 0xff, mac_addr[1] & 0xff, mac_addr[2] & 0xff, + mac_addr[3] & 0xff, mac_addr[4] & 0xff, mac_addr[5] & 0xff); + place = HASH(mac_addr[ETH_ALEN - 1]); + + to_return = priv->lec_arp_tables[place]; + while (to_return) { + if (!compare_ether_addr(mac_addr, to_return->mac_addr)) { + return to_return; + } + to_return = to_return->next; + } + return NULL; } -static struct lec_arp_table* -make_entry(struct lec_priv *priv, unsigned char *mac_addr) +static struct lec_arp_table *make_entry(struct lec_priv *priv, + unsigned char *mac_addr) { - struct lec_arp_table *to_return; - - to_return = kzalloc(sizeof(struct lec_arp_table), GFP_ATOMIC); - if (!to_return) { - printk("LEC: Arp entry kmalloc failed\n"); - return NULL; - } - memcpy(to_return->mac_addr, mac_addr, ETH_ALEN); - init_timer(&to_return->timer); - to_return->timer.function = lec_arp_expire_arp; - to_return->timer.data = (unsigned long) to_return; - to_return->last_used = jiffies; - to_return->priv = priv; - skb_queue_head_init(&to_return->tx_wait); - return to_return; + struct lec_arp_table *to_return; + + to_return = kzalloc(sizeof(struct lec_arp_table), GFP_ATOMIC); + if (!to_return) { + printk("LEC: Arp entry kmalloc failed\n"); + return NULL; + } + memcpy(to_return->mac_addr, mac_addr, ETH_ALEN); + init_timer(&to_return->timer); + to_return->timer.function = lec_arp_expire_arp; + to_return->timer.data = (unsigned long)to_return; + to_return->last_used = jiffies; + to_return->priv = priv; + skb_queue_head_init(&to_return->tx_wait); + return to_return; } -/* - * - * Arp sent timer expired - * - */ -static void -lec_arp_expire_arp(unsigned long data) +/* Arp sent timer expired */ +static void lec_arp_expire_arp(unsigned long data) { - struct lec_arp_table *entry; - - entry = (struct lec_arp_table *)data; - - DPRINTK("lec_arp_expire_arp\n"); - if (entry->status == ESI_ARP_PENDING) { - if (entry->no_tries <= entry->priv->max_retry_count) { - if (entry->is_rdesc) - send_to_lecd(entry->priv, l_rdesc_arp_xmt, entry->mac_addr, NULL, NULL); - else - send_to_lecd(entry->priv, l_arp_xmt, entry->mac_addr, NULL, NULL); - entry->no_tries++; - } - mod_timer(&entry->timer, jiffies + (1*HZ)); - } + struct lec_arp_table *entry; + + entry = (struct lec_arp_table *)data; + + DPRINTK("lec_arp_expire_arp\n"); + if (entry->status == ESI_ARP_PENDING) { + if (entry->no_tries <= entry->priv->max_retry_count) { + if (entry->is_rdesc) + send_to_lecd(entry->priv, l_rdesc_arp_xmt, + entry->mac_addr, NULL, NULL); + else + send_to_lecd(entry->priv, l_arp_xmt, + entry->mac_addr, NULL, NULL); + entry->no_tries++; + } + mod_timer(&entry->timer, jiffies + (1 * HZ)); + } } -/* - * - * Unknown/unused vcc expire, remove associated entry - * - */ -static void -lec_arp_expire_vcc(unsigned long data) +/* Unknown/unused vcc expire, remove associated entry */ +static void lec_arp_expire_vcc(unsigned long data) { unsigned long flags; - struct lec_arp_table *to_remove = (struct lec_arp_table*)data; - struct lec_priv *priv = (struct lec_priv *)to_remove->priv; - struct lec_arp_table *entry = NULL; + struct lec_arp_table *to_remove = (struct lec_arp_table *)data; + struct lec_priv *priv = (struct lec_priv *)to_remove->priv; + struct lec_arp_table *entry = NULL; - del_timer(&to_remove->timer); + del_timer(&to_remove->timer); - DPRINTK("LEC_ARP %p %p: lec_arp_expire_vcc vpi:%d vci:%d\n", - to_remove, priv, - to_remove->vcc?to_remove->recv_vcc->vpi:0, - to_remove->vcc?to_remove->recv_vcc->vci:0); - DPRINTK("eo:%p nf:%p\n",priv->lec_arp_empty_ones,priv->lec_no_forward); + DPRINTK("LEC_ARP %p %p: lec_arp_expire_vcc vpi:%d vci:%d\n", + to_remove, priv, + to_remove->vcc ? to_remove->recv_vcc->vpi : 0, + to_remove->vcc ? to_remove->recv_vcc->vci : 0); + DPRINTK("eo:%p nf:%p\n", priv->lec_arp_empty_ones, + priv->lec_no_forward); spin_lock_irqsave(&priv->lec_arp_lock, flags); - if (to_remove == priv->lec_arp_empty_ones) - priv->lec_arp_empty_ones = to_remove->next; - else { - entry = priv->lec_arp_empty_ones; - while (entry && entry->next != to_remove) - entry = entry->next; - if (entry) - entry->next = to_remove->next; - } - if (!entry) { - if (to_remove == priv->lec_no_forward) { - priv->lec_no_forward = to_remove->next; - } else { - entry = priv->lec_no_forward; - while (entry && entry->next != to_remove) - entry = entry->next; - if (entry) - entry->next = to_remove->next; - } + if (to_remove == priv->lec_arp_empty_ones) + priv->lec_arp_empty_ones = to_remove->next; + else { + entry = priv->lec_arp_empty_ones; + while (entry && entry->next != to_remove) + entry = entry->next; + if (entry) + entry->next = to_remove->next; + } + if (!entry) { + if (to_remove == priv->lec_no_forward) { + priv->lec_no_forward = to_remove->next; + } else { + entry = priv->lec_no_forward; + while (entry && entry->next != to_remove) + entry = entry->next; + if (entry) + entry->next = to_remove->next; + } } spin_unlock_irqrestore(&priv->lec_arp_lock, flags); - lec_arp_clear_vccs(to_remove); - kfree(to_remove); + lec_arp_clear_vccs(to_remove); + kfree(to_remove); } /* @@ -1938,64 +1925,68 @@ lec_arp_expire_vcc(unsigned long data) * to ESI_FORWARD_DIRECT. This causes the flush period to end * regardless of the progress of the flush protocol. */ -static void -lec_arp_check_expire(unsigned long data) +static void lec_arp_check_expire(unsigned long data) { unsigned long flags; - struct lec_priv *priv = (struct lec_priv *)data; - struct lec_arp_table *entry, *next; - unsigned long now; - unsigned long time_to_check; - int i; - - DPRINTK("lec_arp_check_expire %p\n",priv); - DPRINTK("expire: eo:%p nf:%p\n",priv->lec_arp_empty_ones, - priv->lec_no_forward); + struct lec_priv *priv = (struct lec_priv *)data; + struct lec_arp_table *entry, *next; + unsigned long now; + unsigned long time_to_check; + int i; + + DPRINTK("lec_arp_check_expire %p\n", priv); + DPRINTK("expire: eo:%p nf:%p\n", priv->lec_arp_empty_ones, + priv->lec_no_forward); now = jiffies; spin_lock_irqsave(&priv->lec_arp_lock, flags); - for(i = 0; i < LEC_ARP_TABLE_SIZE; i++) { - for(entry = priv->lec_arp_tables[i]; entry != NULL; ) { - if ((entry->flags) & LEC_REMOTE_FLAG && + for (i = 0; i < LEC_ARP_TABLE_SIZE; i++) { + for (entry = priv->lec_arp_tables[i]; entry != NULL;) { + if ((entry->flags) & LEC_REMOTE_FLAG && priv->topology_change) time_to_check = priv->forward_delay_time; else time_to_check = priv->aging_time; DPRINTK("About to expire: %lx - %lx > %lx\n", - now,entry->last_used, time_to_check); - if( time_after(now, entry->last_used+ - time_to_check) && - !(entry->flags & LEC_PERMANENT_FLAG) && - !(entry->mac_addr[0] & 0x01) ) { /* LANE2: 7.1.20 */ + now, entry->last_used, time_to_check); + if (time_after(now, entry->last_used + time_to_check) + && !(entry->flags & LEC_PERMANENT_FLAG) + && !(entry->mac_addr[0] & 0x01)) { /* LANE2: 7.1.20 */ /* Remove entry */ DPRINTK("LEC:Entry timed out\n"); - next = entry->next; + next = entry->next; lec_arp_remove(priv, entry); kfree(entry); entry = next; } else { /* Something else */ if ((entry->status == ESI_VC_PENDING || - entry->status == ESI_ARP_PENDING) + entry->status == ESI_ARP_PENDING) && time_after_eq(now, - entry->timestamp + - priv->max_unknown_frame_time)) { + entry->timestamp + + priv-> + max_unknown_frame_time)) { entry->timestamp = jiffies; entry->packets_flooded = 0; if (entry->status == ESI_VC_PENDING) - send_to_lecd(priv, l_svc_setup, entry->mac_addr, entry->atm_addr, NULL); + send_to_lecd(priv, l_svc_setup, + entry->mac_addr, + entry->atm_addr, + NULL); } - if (entry->status == ESI_FLUSH_PENDING - && - time_after_eq(now, entry->timestamp+ - priv->path_switching_delay)) { + if (entry->status == ESI_FLUSH_PENDING + && + time_after_eq(now, entry->timestamp + + priv->path_switching_delay)) { struct sk_buff *skb; - while ((skb = skb_dequeue(&entry->tx_wait)) != NULL) - lec_send(entry->vcc, skb, entry->priv); + while ((skb = + skb_dequeue(&entry->tx_wait)) != + NULL) + lec_send(entry->vcc, skb, + entry->priv); entry->last_used = jiffies; - entry->status = - ESI_FORWARD_DIRECT; + entry->status = ESI_FORWARD_DIRECT; } entry = entry->next; } @@ -2003,93 +1994,101 @@ lec_arp_check_expire(unsigned long data) } spin_unlock_irqrestore(&priv->lec_arp_lock, flags); - mod_timer(&priv->lec_arp_timer, jiffies + LEC_ARP_REFRESH_INTERVAL); + mod_timer(&priv->lec_arp_timer, jiffies + LEC_ARP_REFRESH_INTERVAL); } + /* * Try to find vcc where mac_address is attached. * */ -static struct atm_vcc* -lec_arp_resolve(struct lec_priv *priv, unsigned char *mac_to_find, - int is_rdesc, struct lec_arp_table **ret_entry) +static struct atm_vcc *lec_arp_resolve(struct lec_priv *priv |