diff options
Diffstat (limited to 'net/atm/lec.c')
| -rw-r--r-- | net/atm/lec.c | 3163 |
1 files changed, 1556 insertions, 1607 deletions
diff --git a/net/atm/lec.c b/net/atm/lec.c index c4fc722fef9a..66c57c1091a8 100644 --- a/net/atm/lec.c +++ b/net/atm/lec.c | |||
| @@ -1,10 +1,9 @@ | |||
| 1 | /* | 1 | /* |
| 2 | * lec.c: Lan Emulation driver | 2 | * lec.c: Lan Emulation driver |
| 3 | * Marko Kiiskila mkiiskila@yahoo.com | ||
| 4 | * | 3 | * |
| 4 | * Marko Kiiskila <mkiiskila@yahoo.com> | ||
| 5 | */ | 5 | */ |
| 6 | 6 | ||
| 7 | #include <linux/config.h> | ||
| 8 | #include <linux/kernel.h> | 7 | #include <linux/kernel.h> |
| 9 | #include <linux/bitops.h> | 8 | #include <linux/bitops.h> |
| 10 | #include <linux/capability.h> | 9 | #include <linux/capability.h> |
| @@ -39,7 +38,7 @@ | |||
| 39 | #include <linux/if_bridge.h> | 38 | #include <linux/if_bridge.h> |
| 40 | #include "../bridge/br_private.h" | 39 | #include "../bridge/br_private.h" |
| 41 | 40 | ||
| 42 | static unsigned char bridge_ula_lec[] = {0x01, 0x80, 0xc2, 0x00, 0x00}; | 41 | static unsigned char bridge_ula_lec[] = { 0x01, 0x80, 0xc2, 0x00, 0x00 }; |
| 43 | #endif | 42 | #endif |
| 44 | 43 | ||
| 45 | /* Modular too */ | 44 | /* Modular too */ |
| @@ -56,38 +55,41 @@ static unsigned char bridge_ula_lec[] = {0x01, 0x80, 0xc2, 0x00, 0x00}; | |||
| 56 | #define DPRINTK(format,args...) | 55 | #define DPRINTK(format,args...) |
| 57 | #endif | 56 | #endif |
| 58 | 57 | ||
| 59 | #define DUMP_PACKETS 0 /* 0 = None, | 58 | #define DUMP_PACKETS 0 /* |
| 60 | * 1 = 30 first bytes | 59 | * 0 = None, |
| 61 | * 2 = Whole packet | 60 | * 1 = 30 first bytes |
| 62 | */ | 61 | * 2 = Whole packet |
| 62 | */ | ||
| 63 | 63 | ||
| 64 | #define LEC_UNRES_QUE_LEN 8 /* number of tx packets to queue for a | 64 | #define LEC_UNRES_QUE_LEN 8 /* |
| 65 | single destination while waiting for SVC */ | 65 | * number of tx packets to queue for a |
| 66 | * single destination while waiting for SVC | ||
| 67 | */ | ||
| 66 | 68 | ||
| 67 | static int lec_open(struct net_device *dev); | 69 | static int lec_open(struct net_device *dev); |
| 68 | static int lec_start_xmit(struct sk_buff *skb, struct net_device *dev); | 70 | static int lec_start_xmit(struct sk_buff *skb, struct net_device *dev); |
| 69 | static int lec_close(struct net_device *dev); | 71 | static int lec_close(struct net_device *dev); |
| 70 | static struct net_device_stats *lec_get_stats(struct net_device *dev); | 72 | static struct net_device_stats *lec_get_stats(struct net_device *dev); |
| 71 | static void lec_init(struct net_device *dev); | 73 | static void lec_init(struct net_device *dev); |
| 72 | static struct lec_arp_table* lec_arp_find(struct lec_priv *priv, | 74 | static struct lec_arp_table *lec_arp_find(struct lec_priv *priv, |
| 73 | unsigned char *mac_addr); | 75 | unsigned char *mac_addr); |
| 74 | static int lec_arp_remove(struct lec_priv *priv, | 76 | static int lec_arp_remove(struct lec_priv *priv, |
| 75 | struct lec_arp_table *to_remove); | 77 | struct lec_arp_table *to_remove); |
| 76 | /* LANE2 functions */ | 78 | /* LANE2 functions */ |
| 77 | static void lane2_associate_ind (struct net_device *dev, u8 *mac_address, | 79 | static void lane2_associate_ind(struct net_device *dev, u8 *mac_address, |
| 78 | u8 *tlvs, u32 sizeoftlvs); | 80 | u8 *tlvs, u32 sizeoftlvs); |
| 79 | static int lane2_resolve(struct net_device *dev, u8 *dst_mac, int force, | 81 | static int lane2_resolve(struct net_device *dev, u8 *dst_mac, int force, |
| 80 | u8 **tlvs, u32 *sizeoftlvs); | 82 | u8 **tlvs, u32 *sizeoftlvs); |
| 81 | static int lane2_associate_req (struct net_device *dev, u8 *lan_dst, | 83 | static int lane2_associate_req(struct net_device *dev, u8 *lan_dst, |
| 82 | u8 *tlvs, u32 sizeoftlvs); | 84 | u8 *tlvs, u32 sizeoftlvs); |
| 83 | 85 | ||
| 84 | static int lec_addr_delete(struct lec_priv *priv, unsigned char *atm_addr, | 86 | static int lec_addr_delete(struct lec_priv *priv, unsigned char *atm_addr, |
| 85 | unsigned long permanent); | 87 | unsigned long permanent); |
| 86 | static void lec_arp_check_empties(struct lec_priv *priv, | 88 | static void lec_arp_check_empties(struct lec_priv *priv, |
| 87 | struct atm_vcc *vcc, struct sk_buff *skb); | 89 | struct atm_vcc *vcc, struct sk_buff *skb); |
| 88 | static void lec_arp_destroy(struct lec_priv *priv); | 90 | static void lec_arp_destroy(struct lec_priv *priv); |
| 89 | static void lec_arp_init(struct lec_priv *priv); | 91 | static void lec_arp_init(struct lec_priv *priv); |
| 90 | static struct atm_vcc* lec_arp_resolve(struct lec_priv *priv, | 92 | static struct atm_vcc *lec_arp_resolve(struct lec_priv *priv, |
| 91 | unsigned char *mac_to_find, | 93 | unsigned char *mac_to_find, |
| 92 | int is_rdesc, | 94 | int is_rdesc, |
| 93 | struct lec_arp_table **ret_entry); | 95 | struct lec_arp_table **ret_entry); |
| @@ -101,16 +103,30 @@ static void lec_set_flush_tran_id(struct lec_priv *priv, | |||
| 101 | unsigned long tran_id); | 103 | unsigned long tran_id); |
| 102 | static void lec_vcc_added(struct lec_priv *priv, struct atmlec_ioc *ioc_data, | 104 | static void lec_vcc_added(struct lec_priv *priv, struct atmlec_ioc *ioc_data, |
| 103 | struct atm_vcc *vcc, | 105 | struct atm_vcc *vcc, |
| 104 | void (*old_push)(struct atm_vcc *vcc, struct sk_buff *skb)); | 106 | void (*old_push) (struct atm_vcc *vcc, |
| 107 | struct sk_buff *skb)); | ||
| 105 | static void lec_vcc_close(struct lec_priv *priv, struct atm_vcc *vcc); | 108 | static void lec_vcc_close(struct lec_priv *priv, struct atm_vcc *vcc); |
| 106 | 109 | ||
| 110 | /* must be done under lec_arp_lock */ | ||
| 111 | static inline void lec_arp_hold(struct lec_arp_table *entry) | ||
| 112 | { | ||
| 113 | atomic_inc(&entry->usage); | ||
| 114 | } | ||
| 115 | |||
| 116 | static inline void lec_arp_put(struct lec_arp_table *entry) | ||
| 117 | { | ||
| 118 | if (atomic_dec_and_test(&entry->usage)) | ||
| 119 | kfree(entry); | ||
| 120 | } | ||
| 121 | |||
| 122 | |||
| 107 | static struct lane2_ops lane2_ops = { | 123 | static struct lane2_ops lane2_ops = { |
| 108 | lane2_resolve, /* resolve, spec 3.1.3 */ | 124 | lane2_resolve, /* resolve, spec 3.1.3 */ |
| 109 | lane2_associate_req, /* associate_req, spec 3.1.4 */ | 125 | lane2_associate_req, /* associate_req, spec 3.1.4 */ |
| 110 | NULL /* associate indicator, spec 3.1.5 */ | 126 | NULL /* associate indicator, spec 3.1.5 */ |
| 111 | }; | 127 | }; |
| 112 | 128 | ||
| 113 | static unsigned char bus_mac[ETH_ALEN] = {0xff,0xff,0xff,0xff,0xff,0xff}; | 129 | static unsigned char bus_mac[ETH_ALEN] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; |
| 114 | 130 | ||
| 115 | /* Device structures */ | 131 | /* Device structures */ |
| 116 | static struct net_device *dev_lec[MAX_LEC_ITF]; | 132 | static struct net_device *dev_lec[MAX_LEC_ITF]; |
| @@ -118,36 +134,39 @@ static struct net_device *dev_lec[MAX_LEC_ITF]; | |||
| 118 | #if defined(CONFIG_BRIDGE) || defined(CONFIG_BRIDGE_MODULE) | 134 | #if defined(CONFIG_BRIDGE) || defined(CONFIG_BRIDGE_MODULE) |
| 119 | static void lec_handle_bridge(struct sk_buff *skb, struct net_device *dev) | 135 | static void lec_handle_bridge(struct sk_buff *skb, struct net_device *dev) |
| 120 | { | 136 | { |
| 121 | struct ethhdr *eth; | 137 | struct ethhdr *eth; |
| 122 | char *buff; | 138 | char *buff; |
| 123 | struct lec_priv *priv; | 139 | struct lec_priv *priv; |
| 124 | 140 | ||
| 125 | /* Check if this is a BPDU. If so, ask zeppelin to send | 141 | /* |
| 126 | * LE_TOPOLOGY_REQUEST with the same value of Topology Change bit | 142 | * Check if this is a BPDU. If so, ask zeppelin to send |
| 127 | * as the Config BPDU has */ | 143 | * LE_TOPOLOGY_REQUEST with the same value of Topology Change bit |
| 128 | eth = (struct ethhdr *)skb->data; | 144 | * as the Config BPDU has |
| 129 | buff = skb->data + skb->dev->hard_header_len; | 145 | */ |
| 130 | if (*buff++ == 0x42 && *buff++ == 0x42 && *buff++ == 0x03) { | 146 | eth = (struct ethhdr *)skb->data; |
| 147 | buff = skb->data + skb->dev->hard_header_len; | ||
| 148 | if (*buff++ == 0x42 && *buff++ == 0x42 && *buff++ == 0x03) { | ||
| 131 | struct sock *sk; | 149 | struct sock *sk; |
| 132 | struct sk_buff *skb2; | 150 | struct sk_buff *skb2; |
| 133 | struct atmlec_msg *mesg; | 151 | struct atmlec_msg *mesg; |
| 134 | 152 | ||
| 135 | skb2 = alloc_skb(sizeof(struct atmlec_msg), GFP_ATOMIC); | 153 | skb2 = alloc_skb(sizeof(struct atmlec_msg), GFP_ATOMIC); |
| 136 | if (skb2 == NULL) return; | 154 | if (skb2 == NULL) |
| 137 | skb2->len = sizeof(struct atmlec_msg); | 155 | return; |
| 138 | mesg = (struct atmlec_msg *)skb2->data; | 156 | skb2->len = sizeof(struct atmlec_msg); |
| 139 | mesg->type = l_topology_change; | 157 | mesg = (struct atmlec_msg *)skb2->data; |
| 140 | buff += 4; | 158 | mesg->type = l_topology_change; |
| 141 | mesg->content.normal.flag = *buff & 0x01; /* 0x01 is topology change */ | 159 | buff += 4; |
| 142 | 160 | mesg->content.normal.flag = *buff & 0x01; /* 0x01 is topology change */ | |
| 143 | priv = (struct lec_priv *)dev->priv; | 161 | |
| 144 | atm_force_charge(priv->lecd, skb2->truesize); | 162 | priv = (struct lec_priv *)dev->priv; |
| 163 | atm_force_charge(priv->lecd, skb2->truesize); | ||
| 145 | sk = sk_atm(priv->lecd); | 164 | sk = sk_atm(priv->lecd); |
| 146 | skb_queue_tail(&sk->sk_receive_queue, skb2); | 165 | skb_queue_tail(&sk->sk_receive_queue, skb2); |
| 147 | sk->sk_data_ready(sk, skb2->len); | 166 | sk->sk_data_ready(sk, skb2->len); |
| 148 | } | 167 | } |
| 149 | 168 | ||
| 150 | return; | 169 | return; |
| 151 | } | 170 | } |
| 152 | #endif /* defined(CONFIG_BRIDGE) || defined(CONFIG_BRIDGE_MODULE) */ | 171 | #endif /* defined(CONFIG_BRIDGE) || defined(CONFIG_BRIDGE_MODULE) */ |
| 153 | 172 | ||
| @@ -163,36 +182,35 @@ static void lec_handle_bridge(struct sk_buff *skb, struct net_device *dev) | |||
| 163 | #ifdef CONFIG_TR | 182 | #ifdef CONFIG_TR |
| 164 | static unsigned char *get_tr_dst(unsigned char *packet, unsigned char *rdesc) | 183 | static unsigned char *get_tr_dst(unsigned char *packet, unsigned char *rdesc) |
| 165 | { | 184 | { |
| 166 | struct trh_hdr *trh; | 185 | struct trh_hdr *trh; |
| 167 | int riflen, num_rdsc; | 186 | int riflen, num_rdsc; |
| 168 | 187 | ||
| 169 | trh = (struct trh_hdr *)packet; | 188 | trh = (struct trh_hdr *)packet; |
| 170 | if (trh->daddr[0] & (uint8_t)0x80) | 189 | if (trh->daddr[0] & (uint8_t) 0x80) |
| 171 | return bus_mac; /* multicast */ | 190 | return bus_mac; /* multicast */ |
| 172 | 191 | ||
| 173 | if (trh->saddr[0] & TR_RII) { | 192 | if (trh->saddr[0] & TR_RII) { |
| 174 | riflen = (ntohs(trh->rcf) & TR_RCF_LEN_MASK) >> 8; | 193 | riflen = (ntohs(trh->rcf) & TR_RCF_LEN_MASK) >> 8; |
| 175 | if ((ntohs(trh->rcf) >> 13) != 0) | 194 | if ((ntohs(trh->rcf) >> 13) != 0) |
| 176 | return bus_mac; /* ARE or STE */ | 195 | return bus_mac; /* ARE or STE */ |
| 177 | } | 196 | } else |
| 178 | else | 197 | return trh->daddr; /* not source routed */ |
| 179 | return trh->daddr; /* not source routed */ | 198 | |
| 180 | 199 | if (riflen < 6) | |
| 181 | if (riflen < 6) | 200 | return trh->daddr; /* last hop, source routed */ |
| 182 | return trh->daddr; /* last hop, source routed */ | 201 | |
| 183 | 202 | /* riflen is 6 or more, packet has more than one route descriptor */ | |
| 184 | /* riflen is 6 or more, packet has more than one route descriptor */ | 203 | num_rdsc = (riflen / 2) - 1; |
| 185 | num_rdsc = (riflen/2) - 1; | 204 | memset(rdesc, 0, ETH_ALEN); |
| 186 | memset(rdesc, 0, ETH_ALEN); | 205 | /* offset 4 comes from LAN destination field in LE control frames */ |
| 187 | /* offset 4 comes from LAN destination field in LE control frames */ | 206 | if (trh->rcf & htons((uint16_t) TR_RCF_DIR_BIT)) |
| 188 | if (trh->rcf & htons((uint16_t)TR_RCF_DIR_BIT)) | 207 | memcpy(&rdesc[4], &trh->rseg[num_rdsc - 2], sizeof(uint16_t)); |
| 189 | memcpy(&rdesc[4], &trh->rseg[num_rdsc-2], sizeof(uint16_t)); | 208 | else { |
| 190 | else { | 209 | memcpy(&rdesc[4], &trh->rseg[1], sizeof(uint16_t)); |
| 191 | memcpy(&rdesc[4], &trh->rseg[1], sizeof(uint16_t)); | 210 | rdesc[5] = ((ntohs(trh->rseg[0]) & 0x000f) | (rdesc[5] & 0xf0)); |
| 192 | rdesc[5] = ((ntohs(trh->rseg[0]) & 0x000f) | (rdesc[5] & 0xf0)); | 211 | } |
| 193 | } | 212 | |
| 194 | 213 | return NULL; | |
| 195 | return NULL; | ||
| 196 | } | 214 | } |
| 197 | #endif /* CONFIG_TR */ | 215 | #endif /* CONFIG_TR */ |
| 198 | 216 | ||
| @@ -205,15 +223,14 @@ static unsigned char *get_tr_dst(unsigned char *packet, unsigned char *rdesc) | |||
| 205 | * there is non-reboot way to recover if something goes wrong. | 223 | * there is non-reboot way to recover if something goes wrong. |
| 206 | */ | 224 | */ |
| 207 | 225 | ||
| 208 | static int | 226 | static int lec_open(struct net_device *dev) |
| 209 | lec_open(struct net_device *dev) | ||
| 210 | { | 227 | { |
| 211 | struct lec_priv *priv = (struct lec_priv *)dev->priv; | 228 | struct lec_priv *priv = (struct lec_priv *)dev->priv; |
| 212 | 229 | ||
| 213 | netif_start_queue(dev); | 230 | netif_start_queue(dev); |
| 214 | memset(&priv->stats,0,sizeof(struct net_device_stats)); | 231 | memset(&priv->stats, 0, sizeof(struct net_device_stats)); |
| 215 | 232 | ||
| 216 | return 0; | 233 | return 0; |
| 217 | } | 234 | } |
| 218 | 235 | ||
| 219 | static __inline__ void | 236 | static __inline__ void |
| @@ -232,160 +249,166 @@ lec_send(struct atm_vcc *vcc, struct sk_buff *skb, struct lec_priv *priv) | |||
| 232 | priv->stats.tx_bytes += skb->len; | 249 | priv->stats.tx_bytes += skb->len; |
| 233 | } | 250 | } |
| 234 | 251 | ||
| 235 | static void | 252 | static void lec_tx_timeout(struct net_device *dev) |
| 236 | lec_tx_timeout(struct net_device *dev) | ||
| 237 | { | 253 | { |
| 238 | printk(KERN_INFO "%s: tx timeout\n", dev->name); | 254 | printk(KERN_INFO "%s: tx timeout\n", dev->name); |
| 239 | dev->trans_start = jiffies; | 255 | dev->trans_start = jiffies; |
| 240 | netif_wake_queue(dev); | 256 | netif_wake_queue(dev); |
| 241 | } | 257 | } |
| 242 | 258 | ||
| 243 | static int | 259 | static int lec_start_xmit(struct sk_buff *skb, struct net_device *dev) |
| 244 | lec_start_xmit(struct sk_buff *skb, struct net_device *dev) | ||
| 245 | { | 260 | { |
| 246 | struct sk_buff *skb2; | 261 | struct sk_buff *skb2; |
| 247 | struct lec_priv *priv = (struct lec_priv *)dev->priv; | 262 | struct lec_priv *priv = (struct lec_priv *)dev->priv; |
| 248 | struct lecdatahdr_8023 *lec_h; | 263 | struct lecdatahdr_8023 *lec_h; |
| 249 | struct atm_vcc *vcc; | 264 | struct atm_vcc *vcc; |
| 250 | struct lec_arp_table *entry; | 265 | struct lec_arp_table *entry; |
| 251 | unsigned char *dst; | 266 | unsigned char *dst; |
| 252 | int min_frame_size; | 267 | int min_frame_size; |
| 253 | #ifdef CONFIG_TR | 268 | #ifdef CONFIG_TR |
| 254 | unsigned char rdesc[ETH_ALEN]; /* Token Ring route descriptor */ | 269 | unsigned char rdesc[ETH_ALEN]; /* Token Ring route descriptor */ |
| 255 | #endif | 270 | #endif |
| 256 | int is_rdesc; | 271 | int is_rdesc; |
| 257 | #if DUMP_PACKETS > 0 | 272 | #if DUMP_PACKETS > 0 |
| 258 | char buf[300]; | 273 | char buf[300]; |
| 259 | int i=0; | 274 | int i = 0; |
| 260 | #endif /* DUMP_PACKETS >0 */ | 275 | #endif /* DUMP_PACKETS >0 */ |
| 261 | 276 | ||
| 262 | DPRINTK("lec_start_xmit called\n"); | 277 | DPRINTK("lec_start_xmit called\n"); |
| 263 | if (!priv->lecd) { | 278 | if (!priv->lecd) { |
| 264 | printk("%s:No lecd attached\n",dev->name); | 279 | printk("%s:No lecd attached\n", dev->name); |
| 265 | priv->stats.tx_errors++; | 280 | priv->stats.tx_errors++; |
| 266 | netif_stop_queue(dev); | 281 | netif_stop_queue(dev); |
| 267 | return -EUNATCH; | 282 | return -EUNATCH; |
| 268 | } | 283 | } |
| 269 | 284 | ||
| 270 | DPRINTK("skbuff head:%lx data:%lx tail:%lx end:%lx\n", | 285 | DPRINTK("skbuff head:%lx data:%lx tail:%lx end:%lx\n", |
| 271 | (long)skb->head, (long)skb->data, (long)skb->tail, | 286 | (long)skb->head, (long)skb->data, (long)skb->tail, |
| 272 | (long)skb->end); | 287 | (long)skb->end); |
| 273 | #if defined(CONFIG_BRIDGE) || defined(CONFIG_BRIDGE_MODULE) | 288 | #if defined(CONFIG_BRIDGE) || defined(CONFIG_BRIDGE_MODULE) |
| 274 | if (memcmp(skb->data, bridge_ula_lec, sizeof(bridge_ula_lec)) == 0) | 289 | if (memcmp(skb->data, bridge_ula_lec, sizeof(bridge_ula_lec)) == 0) |
| 275 | lec_handle_bridge(skb, dev); | 290 | lec_handle_bridge(skb, dev); |
| 276 | #endif | 291 | #endif |
| 277 | 292 | ||
| 278 | /* Make sure we have room for lec_id */ | 293 | /* Make sure we have room for lec_id */ |
| 279 | if (skb_headroom(skb) < 2) { | 294 | if (skb_headroom(skb) < 2) { |
| 280 | 295 | ||
| 281 | DPRINTK("lec_start_xmit: reallocating skb\n"); | 296 | DPRINTK("lec_start_xmit: reallocating skb\n"); |
| 282 | skb2 = skb_realloc_headroom(skb, LEC_HEADER_LEN); | 297 | skb2 = skb_realloc_headroom(skb, LEC_HEADER_LEN); |
| 283 | kfree_skb(skb); | 298 | kfree_skb(skb); |
| 284 | if (skb2 == NULL) return 0; | 299 | if (skb2 == NULL) |
| 285 | skb = skb2; | 300 | return 0; |
| 286 | } | 301 | skb = skb2; |
| 287 | skb_push(skb, 2); | 302 | } |
| 303 | skb_push(skb, 2); | ||
| 288 | 304 | ||
| 289 | /* Put le header to place, works for TokenRing too */ | 305 | /* Put le header to place, works for TokenRing too */ |
| 290 | lec_h = (struct lecdatahdr_8023*)skb->data; | 306 | lec_h = (struct lecdatahdr_8023 *)skb->data; |
| 291 | lec_h->le_header = htons(priv->lecid); | 307 | lec_h->le_header = htons(priv->lecid); |
| 292 | 308 | ||
| 293 | #ifdef CONFIG_TR | 309 | #ifdef CONFIG_TR |
| 294 | /* Ugly. Use this to realign Token Ring packets for | 310 | /* |
| 295 | * e.g. PCA-200E driver. */ | 311 | * Ugly. Use this to realign Token Ring packets for |
| 296 | if (priv->is_trdev) { | 312 | * e.g. PCA-200E driver. |
| 297 | skb2 = skb_realloc_headroom(skb, LEC_HEADER_LEN); | 313 | */ |
| 298 | kfree_skb(skb); | 314 | if (priv->is_trdev) { |
| 299 | if (skb2 == NULL) return 0; | 315 | skb2 = skb_realloc_headroom(skb, LEC_HEADER_LEN); |
| 300 | skb = skb2; | 316 | kfree_skb(skb); |
| 301 | } | 317 | if (skb2 == NULL) |
| 318 | return 0; | ||
| 319 | skb = skb2; | ||
| 320 | } | ||
| 302 | #endif | 321 | #endif |
| 303 | 322 | ||
| 304 | #if DUMP_PACKETS > 0 | 323 | #if DUMP_PACKETS > 0 |
| 305 | printk("%s: send datalen:%ld lecid:%4.4x\n", dev->name, | 324 | printk("%s: send datalen:%ld lecid:%4.4x\n", dev->name, |
| 306 | skb->len, priv->lecid); | 325 | skb->len, priv->lecid); |
| 307 | #if DUMP_PACKETS >= 2 | 326 | #if DUMP_PACKETS >= 2 |
| 308 | for(i=0;i<skb->len && i <99;i++) { | 327 | for (i = 0; i < skb->len && i < 99; i++) { |
| 309 | sprintf(buf+i*3,"%2.2x ",0xff&skb->data[i]); | 328 | sprintf(buf + i * 3, "%2.2x ", 0xff & skb->data[i]); |
| 310 | } | 329 | } |
| 311 | #elif DUMP_PACKETS >= 1 | 330 | #elif DUMP_PACKETS >= 1 |
| 312 | for(i=0;i<skb->len && i < 30;i++) { | 331 | for (i = 0; i < skb->len && i < 30; i++) { |
| 313 | sprintf(buf+i*3,"%2.2x ", 0xff&skb->data[i]); | 332 | sprintf(buf + i * 3, "%2.2x ", 0xff & skb->data[i]); |
| 314 | } | 333 | } |
| 315 | #endif /* DUMP_PACKETS >= 1 */ | 334 | #endif /* DUMP_PACKETS >= 1 */ |
| 316 | if (i==skb->len) | 335 | if (i == skb->len) |
| 317 | printk("%s\n",buf); | 336 | printk("%s\n", buf); |
| 318 | else | 337 | else |
| 319 | printk("%s...\n",buf); | 338 | printk("%s...\n", buf); |
| 320 | #endif /* DUMP_PACKETS > 0 */ | 339 | #endif /* DUMP_PACKETS > 0 */ |
| 321 | 340 | ||
| 322 | /* Minimum ethernet-frame size */ | 341 | /* Minimum ethernet-frame size */ |
| 323 | #ifdef CONFIG_TR | 342 | #ifdef CONFIG_TR |
| 324 | if (priv->is_trdev) | 343 | if (priv->is_trdev) |
| 325 | min_frame_size = LEC_MINIMUM_8025_SIZE; | 344 | min_frame_size = LEC_MINIMUM_8025_SIZE; |
| 326 | else | 345 | else |
| 327 | #endif | 346 | #endif |
| 328 | min_frame_size = LEC_MINIMUM_8023_SIZE; | 347 | min_frame_size = LEC_MINIMUM_8023_SIZE; |
| 329 | if (skb->len < min_frame_size) { | 348 | if (skb->len < min_frame_size) { |
| 330 | if ((skb->len + skb_tailroom(skb)) < min_frame_size) { | 349 | if ((skb->len + skb_tailroom(skb)) < min_frame_size) { |
| 331 | skb2 = skb_copy_expand(skb, 0, | 350 | skb2 = skb_copy_expand(skb, 0, |
| 332 | min_frame_size - skb->truesize, GFP_ATOMIC); | 351 | min_frame_size - skb->truesize, |
| 333 | dev_kfree_skb(skb); | 352 | GFP_ATOMIC); |
| 334 | if (skb2 == NULL) { | 353 | dev_kfree_skb(skb); |
| 335 | priv->stats.tx_dropped++; | 354 | if (skb2 == NULL) { |
| 336 | return 0; | 355 | priv->stats.tx_dropped++; |
| 337 | } | 356 | return 0; |
| 338 | skb = skb2; | 357 | } |
| 339 | } | 358 | skb = skb2; |
| 359 | } | ||
| 340 | skb_put(skb, min_frame_size - skb->len); | 360 | skb_put(skb, min_frame_size - skb->len); |
| 341 | } | 361 | } |
| 342 | 362 | ||
| 343 | /* Send to right vcc */ | 363 | /* Send to right vcc */ |
| 344 | is_rdesc = 0; | 364 | is_rdesc = 0; |
| 345 | dst = lec_h->h_dest; | 365 | dst = lec_h->h_dest; |
| 346 | #ifdef CONFIG_TR | 366 | #ifdef CONFIG_TR |
| 347 | if (priv->is_trdev) { | 367 | if (priv->is_trdev) { |
| 348 | dst = get_tr_dst(skb->data+2, rdesc); | 368 | dst = get_tr_dst(skb->data + 2, rdesc); |
| 349 | if (dst == NULL) { | 369 | if (dst == NULL) { |
| 350 | dst = rdesc; | 370 | dst = rdesc; |
| 351 | is_rdesc = 1; | 371 | is_rdesc = 1; |
| 352 | } | 372 | } |
| 353 | } | 373 | } |
| 354 | #endif | 374 | #endif |
| 355 | entry = NULL; | 375 | entry = NULL; |
| 356 | vcc = lec_arp_resolve(priv, dst, is_rdesc, &entry); | 376 | vcc = lec_arp_resolve(priv, dst, is_rdesc, &entry); |
| 357 | DPRINTK("%s:vcc:%p vcc_flags:%x, entry:%p\n", dev->name, | 377 | DPRINTK("%s:vcc:%p vcc_flags:%x, entry:%p\n", dev->name, |
| 358 | vcc, vcc?vcc->flags:0, entry); | 378 | vcc, vcc ? vcc->flags : 0, entry); |
| 359 | if (!vcc || !test_bit(ATM_VF_READY,&vcc->flags)) { | 379 | if (!vcc || !test_bit(ATM_VF_READY, &vcc->flags)) { |
| 360 | if (entry && (entry->tx_wait.qlen < LEC_UNRES_QUE_LEN)) { | 380 | if (entry && (entry->tx_wait.qlen < LEC_UNRES_QUE_LEN)) { |
| 361 | DPRINTK("%s:lec_start_xmit: queuing packet, ", dev->name); | 381 | DPRINTK("%s:lec_start_xmit: queuing packet, ", |
| 362 | DPRINTK("MAC address 0x%02x:%02x:%02x:%02x:%02x:%02x\n", | 382 | dev->name); |
| 363 | lec_h->h_dest[0], lec_h->h_dest[1], lec_h->h_dest[2], | 383 | DPRINTK("MAC address 0x%02x:%02x:%02x:%02x:%02x:%02x\n", |
| 364 | lec_h->h_dest[3], lec_h->h_dest[4], lec_h->h_dest[5]); | 384 | lec_h->h_dest[0], lec_h->h_dest[1], |
| 365 | skb_queue_tail(&entry->tx_wait, skb); | 385 | lec_h->h_dest[2], lec_h->h_dest[3], |
| 366 | } else { | 386 | lec_h->h_dest[4], lec_h->h_dest[5]); |
| 367 | DPRINTK("%s:lec_start_xmit: tx queue full or no arp entry, dropping, ", dev->name); | 387 | skb_queue_tail(&entry->tx_wait, skb); |
| 368 | DPRINTK("MAC address 0x%02x:%02x:%02x:%02x:%02x:%02x\n", | 388 | } else { |
| 369 | lec_h->h_dest[0], lec_h->h_dest[1], lec_h->h_dest[2], | 389 | DPRINTK |
| 370 | lec_h->h_dest[3], lec_h->h_dest[4], lec_h->h_dest[5]); | 390 | ("%s:lec_start_xmit: tx queue full or no arp entry, dropping, ", |
| 371 | priv->stats.tx_dropped++; | 391 | dev->name); |
| 372 | dev_kfree_skb(skb); | 392 | DPRINTK("MAC address 0x%02x:%02x:%02x:%02x:%02x:%02x\n", |
| 373 | } | 393 | lec_h->h_dest[0], lec_h->h_dest[1], |
| 374 | return 0; | 394 | lec_h->h_dest[2], lec_h->h_dest[3], |
| 375 | } | 395 | lec_h->h_dest[4], lec_h->h_dest[5]); |
| 376 | 396 | priv->stats.tx_dropped++; | |
| 377 | #if DUMP_PACKETS > 0 | 397 | dev_kfree_skb(skb); |
| 378 | printk("%s:sending to vpi:%d vci:%d\n", dev->name, | 398 | } |
| 379 | vcc->vpi, vcc->vci); | 399 | goto out; |
| 400 | } | ||
| 401 | #if DUMP_PACKETS > 0 | ||
| 402 | printk("%s:sending to vpi:%d vci:%d\n", dev->name, vcc->vpi, vcc->vci); | ||
| 380 | #endif /* DUMP_PACKETS > 0 */ | 403 | #endif /* DUMP_PACKETS > 0 */ |
| 381 | 404 | ||
| 382 | while (entry && (skb2 = skb_dequeue(&entry->tx_wait))) { | 405 | while (entry && (skb2 = skb_dequeue(&entry->tx_wait))) { |
| 383 | DPRINTK("lec.c: emptying tx queue, "); | 406 | DPRINTK("lec.c: emptying tx queue, "); |
| 384 | DPRINTK("MAC address 0x%02x:%02x:%02x:%02x:%02x:%02x\n", | 407 | DPRINTK("MAC address 0x%02x:%02x:%02x:%02x:%02x:%02x\n", |
| 385 | lec_h->h_dest[0], lec_h->h_dest[1], lec_h->h_dest[2], | 408 | lec_h->h_dest[0], lec_h->h_dest[1], lec_h->h_dest[2], |
| 386 | lec_h->h_dest[3], lec_h->h_dest[4], lec_h->h_dest[5]); | 409 | lec_h->h_dest[3], lec_h->h_dest[4], lec_h->h_dest[5]); |
| 387 | lec_send(vcc, skb2, priv); | 410 | lec_send(vcc, skb2, priv); |
| 388 | } | 411 | } |
| 389 | 412 | ||
| 390 | lec_send(vcc, skb, priv); | 413 | lec_send(vcc, skb, priv); |
| 391 | 414 | ||
| @@ -405,210 +428,219 @@ lec_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
| 405 | netif_wake_queue(dev); | 428 | netif_wake_queue(dev); |
| 406 | } | 429 | } |
| 407 | 430 | ||
| 431 | out: | ||
| 432 | if (entry) | ||
| 433 | lec_arp_put(entry); | ||
| 408 | dev->trans_start = jiffies; | 434 | dev->trans_start = jiffies; |
| 409 | return 0; | 435 | return 0; |
| 410 | } | 436 | } |
| 411 | 437 | ||
| 412 | /* The inverse routine to net_open(). */ | 438 | /* The inverse routine to net_open(). */ |
| 413 | static int | 439 | static int lec_close(struct net_device *dev) |
| 414 | lec_close(struct net_device *dev) | ||
| 415 | { | 440 | { |
| 416 | netif_stop_queue(dev); | 441 | netif_stop_queue(dev); |
| 417 | return 0; | 442 | return 0; |
| 418 | } | 443 | } |
| 419 | 444 | ||
| 420 | /* | 445 | /* |
| 421 | * Get the current statistics. | 446 | * Get the current statistics. |
| 422 | * This may be called with the card open or closed. | 447 | * This may be called with the card open or closed. |
| 423 | */ | 448 | */ |
| 424 | static struct net_device_stats * | 449 | static struct net_device_stats *lec_get_stats(struct net_device *dev) |
| 425 | lec_get_stats(struct net_device *dev) | ||
| 426 | { | 450 | { |
| 427 | return &((struct lec_priv *)dev->priv)->stats; | 451 | return &((struct lec_priv *)dev->priv)->stats; |
| 428 | } | 452 | } |
| 429 | 453 | ||
| 430 | static int | 454 | static int lec_atm_send(struct atm_vcc *vcc, struct sk_buff *skb) |
| 431 | lec_atm_send(struct atm_vcc *vcc, struct sk_buff *skb) | ||
| 432 | { | 455 | { |
| 433 | unsigned long flags; | 456 | unsigned long flags; |
| 434 | struct net_device *dev = (struct net_device*)vcc->proto_data; | 457 | struct net_device *dev = (struct net_device *)vcc->proto_data; |
| 435 | struct lec_priv *priv = (struct lec_priv*)dev->priv; | 458 | struct lec_priv *priv = (struct lec_priv *)dev->priv; |
| 436 | struct atmlec_msg *mesg; | 459 | struct atmlec_msg *mesg; |
| 437 | struct lec_arp_table *entry; | 460 | struct lec_arp_table *entry; |
| 438 | int i; | 461 | int i; |
| 439 | char *tmp; /* FIXME */ | 462 | char *tmp; /* FIXME */ |
| 440 | 463 | ||
| 441 | atomic_sub(skb->truesize, &sk_atm(vcc)->sk_wmem_alloc); | 464 | atomic_sub(skb->truesize, &sk_atm(vcc)->sk_wmem_alloc); |
| 442 | mesg = (struct atmlec_msg *)skb->data; | 465 | mesg = (struct atmlec_msg *)skb->data; |
| 443 | tmp = skb->data; | 466 | tmp = skb->data; |
| 444 | tmp += sizeof(struct atmlec_msg); | 467 | tmp += sizeof(struct atmlec_msg); |
| 445 | DPRINTK("%s: msg from zeppelin:%d\n", dev->name, mesg->type); | 468 | DPRINTK("%s: msg from zeppelin:%d\n", dev->name, mesg->type); |
| 446 | switch(mesg->type) { | 469 | switch (mesg->type) { |
| 447 | case l_set_mac_addr: | 470 | case l_set_mac_addr: |
| 448 | for (i=0;i<6;i++) { | 471 | for (i = 0; i < 6; i++) { |
| 449 | dev->dev_addr[i] = mesg->content.normal.mac_addr[i]; | 472 | dev->dev_addr[i] = mesg->content.normal.mac_addr[i]; |
| 450 | } | 473 | } |
| 451 | break; | 474 | break; |
| 452 | case l_del_mac_addr: | 475 | case l_del_mac_addr: |
| 453 | for(i=0;i<6;i++) { | 476 | for (i = 0; i < 6; i++) { |
| 454 | dev->dev_addr[i] = 0; | 477 | dev->dev_addr[i] = 0; |
| 455 | } | 478 | } |
| 456 | break; | 479 | break; |
| 457 | case l_addr_delete: | 480 | case l_addr_delete: |
| 458 | lec_addr_delete(priv, mesg->content.normal.atm_addr, | 481 | lec_addr_delete(priv, mesg->content.normal.atm_addr, |
| 459 | mesg->content.normal.flag); | 482 | mesg->content.normal.flag); |
| 460 | break; | 483 | break; |
| 461 | case l_topology_change: | 484 | case l_topology_change: |
| 462 | priv->topology_change = mesg->content.normal.flag; | 485 | priv->topology_change = mesg->content.normal.flag; |
| 463 | break; | 486 | break; |
| 464 | case l_flush_complete: | 487 | case l_flush_complete: |
| 465 | lec_flush_complete(priv, mesg->content.normal.flag); | 488 | lec_flush_complete(priv, mesg->content.normal.flag); |
| 466 | break; | 489 | break; |
| 467 | case l_narp_req: /* LANE2: see 7.1.35 in the lane2 spec */ | 490 | case l_narp_req: /* LANE2: see 7.1.35 in the lane2 spec */ |
| 468 | spin_lock_irqsave(&priv->lec_arp_lock, flags); | 491 | spin_lock_irqsave(&priv->lec_arp_lock, flags); |
| 469 | entry = lec_arp_find(priv, mesg->content.normal.mac_addr); | 492 | entry = lec_arp_find(priv, mesg->content.normal.mac_addr); |
| 470 | lec_arp_remove(priv, entry); | 493 | lec_arp_remove(priv, entry); |
| 471 | spin_unlock_irqrestore(&priv->lec_arp_lock, flags); | 494 | spin_unlock_irqrestore(&priv->lec_arp_lock, flags); |
| 472 | 495 | ||
| 473 | if (mesg->content.normal.no_source_le_narp) | 496 | if (mesg->content.normal.no_source_le_narp) |
| 474 | break; | 497 | break; |
| 475 | /* FALL THROUGH */ | 498 | /* FALL THROUGH */ |
| 476 | case l_arp_update: | 499 | case l_arp_update: |
| 477 | lec_arp_update(priv, mesg->content.normal.mac_addr, | 500 | lec_arp_update(priv, mesg->content.normal.mac_addr, |
| 478 | mesg->content.normal.atm_addr, | 501 | mesg->content.normal.atm_addr, |
| 479 | mesg->content.normal.flag, | 502 | mesg->content.normal.flag, |
| 480 | mesg->content.normal.targetless_le_arp); | 503 | mesg->content.normal.targetless_le_arp); |
| 481 | DPRINTK("lec: in l_arp_update\n"); | 504 | DPRINTK("lec: in l_arp_update\n"); |
| 482 | if (mesg->sizeoftlvs != 0) { /* LANE2 3.1.5 */ | 505 | if (mesg->sizeoftlvs != 0) { /* LANE2 3.1.5 */ |
| 483 | DPRINTK("lec: LANE2 3.1.5, got tlvs, size %d\n", mesg->sizeoftlvs); | 506 | DPRINTK("lec: LANE2 3.1.5, got tlvs, size %d\n", |
| 484 | lane2_associate_ind(dev, | 507 | mesg->sizeoftlvs); |
| 485 | mesg->content.normal.mac_addr, | 508 | lane2_associate_ind(dev, mesg->content.normal.mac_addr, |
| 486 | tmp, mesg->sizeoftlvs); | 509 | tmp, mesg->sizeoftlvs); |
| 487 | } | 510 | } |
| 488 | break; | 511 | break; |
| 489 | case l_config: | 512 | case l_config: |
| 490 | priv->maximum_unknown_frame_count = | 513 | priv->maximum_unknown_frame_count = |
| 491 | mesg->content.config.maximum_unknown_frame_count; | 514 | mesg->content.config.maximum_unknown_frame_count; |
| 492 | priv->max_unknown_frame_time = | 515 | priv->max_unknown_frame_time = |
| 493 | (mesg->content.config.max_unknown_frame_time*HZ); | 516 | (mesg->content.config.max_unknown_frame_time * HZ); |
| 494 | priv->max_retry_count = | 517 | priv->max_retry_count = mesg->content.config.max_retry_count; |
| 495 | mesg->content.config.max_retry_count; | 518 | priv->aging_time = (mesg->content.config.aging_time * HZ); |
| 496 | priv->aging_time = (mesg->content.config.aging_time*HZ); | 519 | priv->forward_delay_time = |
| 497 | priv->forward_delay_time = | 520 | (mesg->content.config.forward_delay_time * HZ); |
| 498 | (mesg->content.config.forward_delay_time*HZ); | 521 | priv->arp_response_time = |
| 499 | priv->arp_response_time = | 522 | (mesg->content.config.arp_response_time * HZ); |
| 500 | (mesg->content.config.arp_response_time*HZ); | 523 | priv->flush_timeout = (mesg->content.config.flush_timeout * HZ); |
| 501 | priv->flush_timeout = (mesg->content.config.flush_timeout*HZ); | 524 | priv->path_switching_delay = |
| 502 | priv->path_switching_delay = | 525 | (mesg->content.config.path_switching_delay * HZ); |
| 503 | (mesg->content.config.path_switching_delay*HZ); | 526 | priv->lane_version = mesg->content.config.lane_version; /* LANE2 */ |
| 504 | priv->lane_version = mesg->content.config.lane_version; /* LANE2 */ | ||
| 505 | priv->lane2_ops = NULL; | 527 | priv->lane2_ops = NULL; |
| 506 | if (priv->lane_version > 1) | 528 | if (priv->lane_version > 1) |
| 507 | priv->lane2_ops = &lane2_ops; | 529 | priv->lane2_ops = &lane2_ops; |
| 508 | if (dev->change_mtu(dev, mesg->content.config.mtu)) | 530 | if (dev->change_mtu(dev, mesg->content.config.mtu)) |
| 509 | printk("%s: change_mtu to %d failed\n", dev->name, | 531 | printk("%s: change_mtu to %d failed\n", dev->name, |
| 510 | mesg->content.config.mtu); | 532 | mesg->content.config.mtu); |
| 511 | priv->is_proxy = mesg->content.config.is_proxy; | 533 | priv->is_proxy = mesg->content.config.is_proxy; |
| 512 | break; | 534 | break; |
| 513 | case l_flush_tran_id: | 535 | case l_flush_tran_id: |
| 514 | lec_set_flush_tran_id(priv, mesg->content.normal.atm_addr, | 536 | lec_set_flush_tran_id(priv, mesg->content.normal.atm_addr, |
| 515 | mesg->content.normal.flag); | 537 | mesg->content.normal.flag); |
| 516 | break; | 538 | break; |
| 517 | case l_set_lecid: | 539 | case l_set_lecid: |
| 518 | priv->lecid=(unsigned short)(0xffff&mesg->content.normal.flag); | 540 | priv->lecid = |
| 519 | break; | 541 | (unsigned short)(0xffff & mesg->content.normal.flag); |
| 520 | case l_should_bridge: { | 542 | break; |
| 543 | case l_should_bridge: | ||
| 521 | #if defined(CONFIG_BRIDGE) || defined(CONFIG_BRIDGE_MODULE) | 544 | #if defined(CONFIG_BRIDGE) || defined(CONFIG_BRIDGE_MODULE) |
| 522 | struct net_bridge_fdb_entry *f; | 545 | { |
| 523 | 546 | struct net_bridge_fdb_entry *f; | |
| 524 | DPRINTK("%s: bridge zeppelin asks about 0x%02x:%02x:%02x:%02x:%02x:%02x\n", | 547 | |
| 525 | dev->name, | 548 | DPRINTK |
| 526 | mesg->content.proxy.mac_addr[0], mesg->content.proxy.mac_addr[1], | 549 | ("%s: bridge zeppelin asks about 0x%02x:%02x:%02x:%02x:%02x:%02x\n", |
| 527 | mesg->content.proxy.mac_addr[2], mesg->content.proxy.mac_addr[3], | 550 | dev->name, mesg->content.proxy.mac_addr[0], |
| 528 | mesg->content.proxy.mac_addr[4], mesg->content.proxy.mac_addr[5]); | 551 | mesg->content.proxy.mac_addr[1], |
| 529 | 552 | mesg->content.proxy.mac_addr[2], | |
| 530 | if (br_fdb_get_hook == NULL || dev->br_port == NULL) | 553 | mesg->content.proxy.mac_addr[3], |
| 531 | break; | 554 | mesg->content.proxy.mac_addr[4], |
| 532 | 555 | mesg->content.proxy.mac_addr[5]); | |
| 533 | f = br_fdb_get_hook(dev->br_port->br, mesg->content.proxy.mac_addr); | 556 | |
| 534 | if (f != NULL && | 557 | if (br_fdb_get_hook == NULL || dev->br_port == NULL) |
| 535 | f->dst->dev != dev && | 558 | break; |
| 536 | f->dst->state == BR_STATE_FORWARDING) { | 559 | |
| 537 | /* hit from bridge table, send LE_ARP_RESPONSE */ | 560 | f = br_fdb_get_hook(dev->br_port->br, |
| 538 | struct sk_buff *skb2; | 561 | mesg->content.proxy.mac_addr); |
| 539 | struct sock *sk; | 562 | if (f != NULL && f->dst->dev != dev |
| 540 | 563 | && f->dst->state == BR_STATE_FORWARDING) { | |
| 541 | DPRINTK("%s: entry found, responding to zeppelin\n", dev->name); | 564 | /* hit from bridge table, send LE_ARP_RESPONSE */ |
| 542 | skb2 = alloc_skb(sizeof(struct atmlec_msg), GFP_ATOMIC); | 565 | struct sk_buff *skb2; |
| 543 | if (skb2 == NULL) { | 566 | struct sock *sk; |
| 544 | br_fdb_put_hook(f); | 567 | |
| 545 | break; | 568 | DPRINTK |
| 546 | } | 569 | ("%s: entry found, responding to zeppelin\n", |
| 547 | skb2->len = sizeof(struct atmlec_msg); | 570 | dev->name); |
| 548 | memcpy(skb2->data, mesg, sizeof(struct atmlec_msg)); | 571 | skb2 = |
| 549 | atm_force_charge(priv->lecd, skb2->truesize); | 572 | alloc_skb(sizeof(struct atmlec_msg), |
| 550 | sk = sk_atm(priv->lecd); | 573 | GFP_ATOMIC); |
| 551 | skb_queue_tail(&sk->sk_receive_queue, skb2); | 574 | if (skb2 == NULL) { |
| 552 | sk->sk_data_ready(sk, skb2->len); | 575 | br_fdb_put_hook(f); |
| 553 | } | 576 | break; |
| 554 | if (f != NULL) br_fdb_put_hook(f); | 577 | } |
| 578 | skb2->len = sizeof(struct atmlec_msg); | ||
| 579 | memcpy(skb2->data, mesg, | ||
| 580 | sizeof(struct atmlec_msg)); | ||
| 581 | atm_force_charge(priv->lecd, skb2->truesize); | ||
| 582 | sk = sk_atm(priv->lecd); | ||
| 583 | skb_queue_tail(&sk->sk_receive_queue, skb2); | ||
| 584 | sk->sk_data_ready(sk, skb2->len); | ||
| 585 | } | ||
| 586 | if (f != NULL) | ||
| 587 | br_fdb_put_hook(f); | ||
| 588 | } | ||
| 555 | #endif /* defined(CONFIG_BRIDGE) || defined(CONFIG_BRIDGE_MODULE) */ | 589 | #endif /* defined(CONFIG_BRIDGE) || defined(CONFIG_BRIDGE_MODULE) */ |
| 556 | } | 590 | break; |
| 557 | break; | 591 | default: |
| 558 | default: | 592 | printk("%s: Unknown message type %d\n", dev->name, mesg->type); |
| 559 | printk("%s: Unknown message type %d\n", dev->name, mesg->type); | 593 | dev_kfree_skb(skb); |
| 560 | dev_kfree_skb(skb); | 594 | return -EINVAL; |
| 561 | return -EINVAL; | 595 | } |
| 562 | } | 596 | dev_kfree_skb(skb); |
| 563 | dev_kfree_skb(skb); | 597 | return 0; |
| 564 | return 0; | ||
| 565 | } | 598 | } |
| 566 | 599 | ||
| 567 | static void | 600 | static void lec_atm_close(struct atm_vcc *vcc) |
| 568 | lec_atm_close(struct atm_vcc *vcc) | ||
| 569 | { | 601 | { |
| 570 | struct sk_buff *skb; | 602 | struct sk_buff *skb; |
| 571 | struct net_device *dev = (struct net_device *)vcc->proto_data; | 603 | struct net_device *dev = (struct net_device *)vcc->proto_data; |
| 572 | struct lec_priv *priv = (struct lec_priv *)dev->priv; | 604 | struct lec_priv *priv = (struct lec_priv *)dev->priv; |
| 573 | 605 | ||
| 574 | priv->lecd = NULL; | 606 | priv->lecd = NULL; |
| 575 | /* Do something needful? */ | 607 | /* Do something needful? */ |
| 576 | 608 | ||
| 577 | netif_stop_queue(dev); | 609 | netif_stop_queue(dev); |
| 578 | lec_arp_destroy(priv); | 610 | lec_arp_destroy(priv); |
| 579 | 611 | ||
| 580 | if (skb_peek(&sk_atm(vcc)->sk_receive_queue)) | 612 | if (skb_peek(&sk_atm(vcc)->sk_receive_queue)) |
| 581 | printk("%s lec_atm_close: closing with messages pending\n", | 613 | printk("%s lec_atm_close: closing with messages pending\n", |
| 582 | dev->name); | 614 | dev->name); |
| 583 | while ((skb = skb_dequeue(&sk_atm(vcc)->sk_receive_queue)) != NULL) { | 615 | while ((skb = skb_dequeue(&sk_atm(vcc)->sk_receive_queue)) != NULL) { |
| 584 | atm_return(vcc, skb->truesize); | 616 | atm_return(vcc, skb->truesize); |
| 585 | dev_kfree_skb(skb); | 617 | dev_kfree_skb(skb); |
| 586 | } | 618 | } |
| 587 | 619 | ||
| 588 | printk("%s: Shut down!\n", dev->name); | 620 | printk("%s: Shut down!\n", dev->name); |
| 589 | module_put(THIS_MODULE); | 621 | module_put(THIS_MODULE); |
| 590 | } | 622 | } |
| 591 | 623 | ||
| 592 | static struct atmdev_ops lecdev_ops = { | 624 | static struct atmdev_ops lecdev_ops = { |
| 593 | .close = lec_atm_close, | 625 | .close = lec_atm_close, |
| 594 | .send = lec_atm_send | 626 | .send = lec_atm_send |
| 595 | }; | 627 | }; |
| 596 | 628 | ||
| 597 | static struct atm_dev lecatm_dev = { | 629 | static struct atm_dev lecatm_dev = { |
| 598 | .ops = &lecdev_ops, | 630 | .ops = &lecdev_ops, |
| 599 | .type = "lec", | 631 | .type = "lec", |
| 600 | .number = 999, /* dummy device number */ | 632 | .number = 999, /* dummy device number */ |
| 601 | .lock = SPIN_LOCK_UNLOCKED | 633 | .lock = SPIN_LOCK_UNLOCKED |
| 602 | }; | 634 | }; |
| 603 | 635 | ||
| 604 | /* | 636 | /* |
| 605 | * LANE2: new argument struct sk_buff *data contains | 637 | * LANE2: new argument struct sk_buff *data contains |
| 606 | * the LE_ARP based TLVs introduced in the LANE2 spec | 638 | * the LE_ARP based TLVs introduced in the LANE2 spec |
| 607 | */ | 639 | */ |
| 608 | static int | 640 | static int |
| 609 | send_to_lecd(struct lec_priv *priv, atmlec_msg_type type, | 641 | send_to_lecd(struct lec_priv *priv, atmlec_msg_type type, |
| 610 | unsigned char *mac_addr, unsigned char *atm_addr, | 642 | unsigned char *mac_addr, unsigned char *atm_addr, |
| 611 | struct sk_buff *data) | 643 | struct sk_buff *data) |
| 612 | { | 644 | { |
| 613 | struct sock *sk; | 645 | struct sock *sk; |
| 614 | struct sk_buff *skb; | 646 | struct sk_buff *skb; |
| @@ -622,187 +654,193 @@ send_to_lecd(struct lec_priv *priv, atmlec_msg_type type, | |||
| 622 | return -1; | 654 | return -1; |
| 623 | skb->len = sizeof(struct atmlec_msg); | 655 | skb->len = sizeof(struct atmlec_msg); |
| 624 | mesg = (struct atmlec_msg *)skb->data; | 656 | mesg = (struct atmlec_msg *)skb->data; |
| 625 | memset(mesg, 0, sizeof(struct atmlec_msg)); | 657 | memset(mesg, 0, sizeof(struct atmlec_msg)); |
| 626 | mesg->type = type; | 658 | mesg->type = type; |
| 627 | if (data != NULL) | 659 | if (data != NULL) |
| 628 | mesg->sizeoftlvs = data->len; | 660 | mesg->sizeoftlvs = data->len; |
| 629 | if (mac_addr) | 661 | if (mac_addr) |
| 630 | memcpy(&mesg->content.normal.mac_addr, mac_addr, ETH_ALEN); | 662 | memcpy(&mesg->content.normal.mac_addr, mac_addr, ETH_ALEN); |
| 631 | else | 663 | else |
| 632 | mesg->content.normal.targetless_le_arp = 1; | 664 | mesg->content.normal.targetless_le_arp = 1; |
| 633 | if (atm_addr) | 665 | if (atm_addr) |
| 634 | memcpy(&mesg->content.normal.atm_addr, atm_addr, ATM_ESA_LEN); | 666 | memcpy(&mesg->content.normal.atm_addr, atm_addr, ATM_ESA_LEN); |
| 635 | 667 | ||
| 636 | atm_force_charge(priv->lecd, skb->truesize); | 668 | atm_force_charge(priv->lecd, skb->truesize); |
| 637 | sk = sk_atm(priv->lecd); | 669 | sk = sk_atm(priv->lecd); |
| 638 | skb_queue_tail(&sk->sk_receive_queue, skb); | 670 | skb_queue_tail(&sk->sk_receive_queue, skb); |
| 639 | sk->sk_data_ready(sk, skb->len); | 671 | sk->sk_data_ready(sk, skb->len); |
| 640 | 672 | ||
| 641 | if (data != NULL) { | 673 | if (data != NULL) { |
| 642 | DPRINTK("lec: about to send %d bytes of data\n", data->len); | 674 | DPRINTK("lec: about to send %d bytes of data\n", data->len); |
| 643 | atm_force_charge(priv->lecd, data->truesize); | 675 | atm_force_charge(priv->lecd, data->truesize); |
| 644 | skb_queue_tail(&sk->sk_receive_queue, data); | 676 | skb_queue_tail(&sk->sk_receive_queue, data); |
| 645 | sk->sk_data_ready(sk, skb->len); | 677 | sk->sk_data_ready(sk, skb->len); |
| 646 | } | 678 | } |
| 647 | 679 | ||
| 648 | return 0; | 680 | return 0; |
| 649 | } | 681 | } |
| 650 | 682 | ||
| 651 | /* shamelessly stolen from drivers/net/net_init.c */ | 683 | /* shamelessly stolen from drivers/net/net_init.c */ |
| 652 | static int lec_change_mtu(struct net_device *dev, int new_mtu) | 684 | static int lec_change_mtu(struct net_device *dev, int new_mtu) |
| 653 | { | 685 | { |
| 654 | if ((new_mtu < 68) || (new_mtu > 18190)) | 686 | if ((new_mtu < 68) || (new_mtu > 18190)) |
| 655 | return -EINVAL; | 687 | return -EINVAL; |
| 656 | dev->mtu = new_mtu; | 688 | dev->mtu = new_mtu; |
| 657 | return 0; | 689 | return 0; |
| 658 | } | 690 | } |
| 659 | 691 | ||
| 660 | static void lec_set_multicast_list(struct net_device *dev) | 692 | static void lec_set_multicast_list(struct net_device *dev) |
| 661 | { | 693 | { |
| 662 | /* by default, all multicast frames arrive over the bus. | 694 | /* |
| 663 | * eventually support selective multicast service | 695 | * by default, all multicast frames arrive over the bus. |
| 664 | */ | 696 | * eventually support selective multicast service |
| 665 | return; | 697 | */ |
| 698 | return; | ||
| 666 | } | 699 | } |
| 667 | 700 | ||
| 668 | static void | 701 | static void lec_init(struct net_device *dev) |
| 669 | lec_init(struct net_device *dev) | ||
| 670 | { | 702 | { |
| 671 | dev->change_mtu = lec_change_mtu; | 703 | dev->change_mtu = lec_change_mtu; |
| 672 | dev->open = lec_open; | 704 | dev->open = lec_open; |
| 673 | dev->stop = lec_close; | 705 | dev->stop = lec_close; |
| 674 | dev->hard_start_xmit = lec_start_xmit; | 706 | dev->hard_start_xmit = lec_start_xmit; |
| 675 | dev->tx_timeout = lec_tx_timeout; | 707 | dev->tx_timeout = lec_tx_timeout; |
| 676 | 708 | ||
| 677 | dev->get_stats = lec_get_stats; | 709 | dev->get_stats = lec_get_stats; |
| 678 | dev->set_multicast_list = lec_set_multicast_list; | 710 | dev->set_multicast_list = lec_set_multicast_list; |
| 679 | dev->do_ioctl = NULL; | 711 | dev->do_ioctl = NULL; |
| 680 | printk("%s: Initialized!\n",dev->name); | 712 | printk("%s: Initialized!\n", dev->name); |
| 681 | return; | 713 | return; |
| 682 | } | 714 | } |
| 683 | 715 | ||
| 684 | static unsigned char lec_ctrl_magic[] = { | 716 | static unsigned char lec_ctrl_magic[] = { |
| 685 | 0xff, | 717 | 0xff, |
| 686 | 0x00, | 718 | 0x00, |
| 687 | 0x01, | 719 | 0x01, |
| 688 | 0x01 }; | 720 | 0x01 |
| 721 | }; | ||
| 689 | 722 | ||
| 690 | #define LEC_DATA_DIRECT_8023 2 | 723 | #define LEC_DATA_DIRECT_8023 2 |
| 691 | #define LEC_DATA_DIRECT_8025 3 | 724 | #define LEC_DATA_DIRECT_8025 3 |
| 692 | 725 | ||
| 693 | static int lec_is_data_direct(struct atm_vcc *vcc) | 726 | static int lec_is_data_direct(struct atm_vcc *vcc) |
| 694 | { | 727 | { |
| 695 | return ((vcc->sap.blli[0].l3.tr9577.snap[4] == LEC_DATA_DIRECT_8023) || | 728 | return ((vcc->sap.blli[0].l3.tr9577.snap[4] == LEC_DATA_DIRECT_8023) || |
| 696 | (vcc->sap.blli[0].l3.tr9577.snap[4] == LEC_DATA_DIRECT_8025)); | 729 | (vcc->sap.blli[0].l3.tr9577.snap[4] == LEC_DATA_DIRECT_8025)); |
| 697 | } | 730 | } |
| 698 | 731 | ||
| 699 | static void | 732 | static void lec_push(struct atm_vcc *vcc, struct sk_buff *skb) |
| 700 | lec_push(struct atm_vcc *vcc, struct sk_buff *skb) | ||
| 701 | { | 733 | { |
| 702 | unsigned long flags; | 734 | unsigned long flags; |
| 703 | struct net_device *dev = (struct net_device *)vcc->proto_data; | 735 | struct net_device *dev = (struct net_device *)vcc->proto_data; |
| 704 | struct lec_priv *priv = (struct lec_priv *)dev->priv; | 736 | struct lec_priv *priv = (struct lec_priv *)dev->priv; |
| 705 | 737 | ||
| 706 | #if DUMP_PACKETS >0 | 738 | #if DUMP_PACKETS >0 |
| 707 | int i=0; | 739 | int i = 0; |
| 708 | char buf[300]; | 740 | char buf[300]; |
| 709 | 741 | ||
| 710 | printk("%s: lec_push vcc vpi:%d vci:%d\n", dev->name, | 742 | printk("%s: lec_push vcc vpi:%d vci:%d\n", dev->name, |
| 711 | vcc->vpi, vcc->vci); | 743 | vcc->vpi, vcc->vci); |
| 712 | #endif | 744 | #endif |
| 713 | if (!skb) { | 745 | if (!skb) { |
| 714 | DPRINTK("%s: null skb\n",dev->name); | 746 | DPRINTK("%s: null skb\n", dev->name); |
| 715 | lec_vcc_close(priv, vcc); | 747 | lec_vcc_close(priv, vcc); |
| 716 | return; | 748 | return; |
| 717 | } | 749 | } |
| 718 | #if DUMP_PACKETS > 0 | 750 | #if DUMP_PACKETS > 0 |
| 719 | printk("%s: rcv datalen:%ld lecid:%4.4x\n", dev->name, | 751 | printk("%s: rcv datalen:%ld lecid:%4.4x\n", dev->name, |
| 720 | skb->len, priv->lecid); | 752 | skb->len, priv->lecid); |
| 721 | #if DUMP_PACKETS >= 2 | 753 | #if DUMP_PACKETS >= 2 |
| 722 | for(i=0;i<skb->len && i <99;i++) { | 754 | for (i = 0; i < skb->len && i < 99; i++) { |
| 723 | sprintf(buf+i*3,"%2.2x ",0xff&skb->data[i]); | 755 | sprintf(buf + i * 3, "%2.2x ", 0xff & skb->data[i]); |
| 724 | } | 756 | } |
| 725 | #elif DUMP_PACKETS >= 1 | 757 | #elif DUMP_PACKETS >= 1 |
| 726 | for(i=0;i<skb->len && i < 30;i++) { | 758 | for (i = 0; i < skb->len && i < 30; i++) { |
| 727 | sprintf(buf+i*3,"%2.2x ", 0xff&skb->data[i]); | 759 | sprintf(buf + i * 3, "%2.2x ", 0xff & skb->data[i]); |
| 728 | } | 760 | } |
| 729 | #endif /* DUMP_PACKETS >= 1 */ | 761 | #endif /* DUMP_PACKETS >= 1 */ |
| 730 | if (i==skb->len) | 762 | if (i == skb->len) |
| 731 | printk("%s\n",buf); | 763 | printk("%s\n", buf); |
| 732 | else | 764 | else |
| 733 | printk("%s...\n",buf); | 765 | printk("%s...\n", buf); |
| 734 | #endif /* DUMP_PACKETS > 0 */ | 766 | #endif /* DUMP_PACKETS > 0 */ |
| 735 | if (memcmp(skb->data, lec_ctrl_magic, 4) ==0) { /* Control frame, to daemon*/ | 767 | if (memcmp(skb->data, lec_ctrl_magic, 4) == 0) { /* Control frame, to daemon */ |
| 736 | struct sock *sk = sk_atm(vcc); | 768 | struct sock *sk = sk_atm(vcc); |
| 737 | 769 | ||
| 738 | DPRINTK("%s: To daemon\n",dev->name); | 770 | DPRINTK("%s: To daemon\n", dev->name); |
| 739 | skb_queue_tail(&sk->sk_receive_queue, skb); | 771 | skb_queue_tail(&sk->sk_receive_queue, skb); |
| 740 | sk->sk_data_ready(sk, skb->len); | 772 | sk->sk_data_ready(sk, skb->len); |
| 741 | } else { /* Data frame, queue to protocol handlers */ | 773 | } else { /* Data frame, queue to protocol handlers */ |
| 742 | struct lec_arp_table *entry; | 774 | struct lec_arp_table *entry; |
| 743 | unsigned char *src, *dst; | 775 | unsigned char *src, *dst; |
| 744 | 776 | ||
| 745 | atm_return(vcc,skb->truesize); | 777 | atm_return(vcc, skb->truesize); |
| 746 | if (*(uint16_t *)skb->data == htons(priv->lecid) || | 778 | if (*(uint16_t *) skb->data == htons(priv->lecid) || |
| 747 | !priv->lecd || | 779 | !priv->lecd || !(dev->flags & IFF_UP)) { |
| 748 | !(dev->flags & IFF_UP)) { | 780 | /* |
| 749 | /* Probably looping back, or if lecd is missing, | 781 | * Probably looping back, or if lecd is missing, |
| 750 | lecd has gone down */ | 782 | * lecd has gone down |
| 751 | DPRINTK("Ignoring frame...\n"); | 783 | */ |
| 752 | dev_kfree_skb(skb); | 784 | DPRINTK("Ignoring frame...\n"); |
| 753 | return; | 785 | dev_kfree_skb(skb); |
| 754 | } | 786 | return; |
| 787 | } | ||
| 755 | #ifdef CONFIG_TR | 788 | #ifdef CONFIG_TR |
| 756 | if (priv->is_trdev) | 789 | if (priv->is_trdev) |
| 757 | dst = ((struct lecdatahdr_8025 *) skb->data)->h_dest; | 790 | dst = ((struct lecdatahdr_8025 *)skb->data)->h_dest; |
| 758 | else | 791 | else |
| 759 | #endif | 792 | #endif |
| 760 | dst = ((struct lecdatahdr_8023 *) skb->data)->h_dest; | 793 | dst = ((struct lecdatahdr_8023 *)skb->data)->h_dest; |
| 761 | 794 | ||
| 762 | /* If this is a Data Direct VCC, and the VCC does not match | 795 | /* |
| 796 | * If this is a Data Direct VCC, and the VCC does not match | ||
| 763 | * the LE_ARP cache entry, delete the LE_ARP cache entry. | 797 | * the LE_ARP cache entry, delete the LE_ARP cache entry. |
| 764 | */ | 798 | */ |
| 765 | spin_lock_irqsave(&priv->lec_arp_lock, flags); | 799 | spin_lock_irqsave(&priv->lec_arp_lock, flags); |
| 766 | if (lec_is_data_direct(vcc)) { | 800 | if (lec_is_data_direct(vcc)) { |
| 767 | #ifdef CONFIG_TR | 801 | #ifdef CONFIG_TR |
| 768 | if (priv->is_trdev) | 802 | if (priv->is_trdev) |
| 769 | src = ((struct lecdatahdr_8025 *) skb->data)->h_source; | 803 | src = |
| 804 | ((struct lecdatahdr_8025 *)skb->data)-> | ||
| 805 | h_source; | ||
| 770 | else | 806 | else |
| 771 | #endif | 807 | #endif |
| 772 | src = ((struct lecdatahdr_8023 *) skb->data)->h_source; | 808 | src = |
| 809 | ((struct lecdatahdr_8023 *)skb->data)-> | ||
| 810 | h_source; | ||
| 773 | entry = lec_arp_find(priv, src); | 811 | entry = lec_arp_find(priv, src); |
| 774 | if (entry && entry->vcc != vcc) { | 812 | if (entry && entry->vcc != vcc) { |
| 775 | lec_arp_remove(priv, entry); | 813 | lec_arp_remove(priv, entry); |
| 776 | kfree(entry); | 814 | lec_arp_put(entry); |
| 777 | } | 815 | } |
| 778 | } | 816 | } |
| 779 | spin_unlock_irqrestore(&priv->lec_arp_lock, flags); | 817 | spin_unlock_irqrestore(&priv->lec_arp_lock, flags); |
| 780 | 818 | ||
| 781 | if (!(dst[0]&0x01) && /* Never filter Multi/Broadcast */ | 819 | if (!(dst[0] & 0x01) && /* Never filter Multi/Broadcast */ |
| 782 | !priv->is_proxy && /* Proxy wants all the packets */ | 820 | !priv->is_proxy && /* Proxy wants all the packets */ |
| 783 | memcmp(dst, dev->dev_addr, dev->addr_len)) { | 821 | memcmp(dst, dev->dev_addr, dev->addr_len)) { |
| 784 | dev_kfree_skb(skb); | 822 | dev_kfree_skb(skb); |
| 785 | return; | 823 | return; |
| 786 | } | 824 | } |
| 787 | if (priv->lec_arp_empty_ones) { | 825 | if (!hlist_empty(&priv->lec_arp_empty_ones)) { |
| 788 | lec_arp_check_empties(priv, vcc, skb); | 826 | lec_arp_check_empties(priv, vcc, skb); |
| 789 | } | 827 | } |
| 790 | skb->dev = dev; | 828 | skb->dev = dev; |
| 791 | skb_pull(skb, 2); /* skip lec_id */ | 829 | skb_pull(skb, 2); /* skip lec_id */ |
| 792 | #ifdef CONFIG_TR | 830 | #ifdef CONFIG_TR |
| 793 | if (priv->is_trdev) skb->protocol = tr_type_trans(skb, dev); | 831 | if (priv->is_trdev) |
| 794 | else | 832 | skb->protocol = tr_type_trans(skb, dev); |
| 833 | else | ||
| 795 | #endif | 834 | #endif |
| 796 | skb->protocol = eth_type_trans(skb, dev); | 835 | skb->protocol = eth_type_trans(skb, dev); |
| 797 | priv->stats.rx_packets++; | 836 | priv->stats.rx_packets++; |
| 798 | priv->stats.rx_bytes += skb->len; | 837 | priv->stats.rx_bytes += skb->len; |
| 799 | memset(ATM_SKB(skb), 0, sizeof(struct atm_skb_data)); | 838 | memset(ATM_SKB(skb), 0, sizeof(struct atm_skb_data)); |
| 800 | netif_rx(skb); | 839 | netif_rx(skb); |
| 801 | } | 840 | } |
| 802 | } | 841 | } |
| 803 | 842 | ||
| 804 | static void | 843 | static void lec_pop(struct atm_vcc *vcc, struct sk_buff *skb) |
| 805 | lec_pop(struct atm_vcc *vcc, struct sk_buff *skb) | ||
| 806 | { | 844 | { |
| 807 | struct lec_vcc_priv *vpriv = LEC_VCC_PRIV(vcc); | 845 | struct lec_vcc_priv *vpriv = LEC_VCC_PRIV(vcc); |
| 808 | struct net_device *dev = skb->dev; | 846 | struct net_device *dev = skb->dev; |
| @@ -821,123 +859,121 @@ lec_pop(struct atm_vcc *vcc, struct sk_buff *skb) | |||
| 821 | } | 859 | } |
| 822 | } | 860 | } |
| 823 | 861 | ||
| 824 | static int | 862 | static int lec_vcc_attach(struct atm_vcc *vcc, void __user *arg) |
| 825 | lec_vcc_attach(struct atm_vcc *vcc, void __user *arg) | ||
| 826 | { | 863 | { |
| 827 | struct lec_vcc_priv *vpriv; | 864 | struct lec_vcc_priv *vpriv; |
| 828 | int bytes_left; | 865 | int bytes_left; |
| 829 | struct atmlec_ioc ioc_data; | 866 | struct atmlec_ioc ioc_data; |
| 830 | 867 | ||
| 831 | /* Lecd must be up in this case */ | 868 | /* Lecd must be up in this case */ |
| 832 | bytes_left = copy_from_user(&ioc_data, arg, sizeof(struct atmlec_ioc)); | 869 | bytes_left = copy_from_user(&ioc_data, arg, sizeof(struct atmlec_ioc)); |
| 833 | if (bytes_left != 0) { | 870 | if (bytes_left != 0) { |
| 834 | printk("lec: lec_vcc_attach, copy from user failed for %d bytes\n", | 871 | printk |
| 835 | bytes_left); | 872 | ("lec: lec_vcc_attach, copy from user failed for %d bytes\n", |
| 836 | } | 873 | bytes_left); |
| 837 | if (ioc_data.dev_num < 0 || ioc_data.dev_num >= MAX_LEC_ITF || | 874 | } |
| 838 | !dev_lec[ioc_data.dev_num]) | 875 | if (ioc_data.dev_num < 0 || ioc_data.dev_num >= MAX_LEC_ITF || |
| 839 | return -EINVAL; | 876 | !dev_lec[ioc_data.dev_num]) |
| 877 | return -EINVAL; | ||
| 840 | if (!(vpriv = kmalloc(sizeof(struct lec_vcc_priv), GFP_KERNEL))) | 878 | if (!(vpriv = kmalloc(sizeof(struct lec_vcc_priv), GFP_KERNEL))) |
| 841 | return -ENOMEM; | 879 | return -ENOMEM; |
| 842 | vpriv->xoff = 0; | 880 | vpriv->xoff = 0; |
| 843 | vpriv->old_pop = vcc->pop; | 881 | vpriv->old_pop = vcc->pop; |
| 844 | vcc->user_back = vpriv; | 882 | vcc->user_back = vpriv; |
| 845 | vcc->pop = lec_pop; | 883 | vcc->pop = lec_pop; |
| 846 | lec_vcc_added(dev_lec[ioc_data.dev_num]->priv, | 884 | lec_vcc_added(dev_lec[ioc_data.dev_num]->priv, |
| 847 | &ioc_data, vcc, vcc->push); | 885 | &ioc_data, vcc, vcc->push); |
| 848 | vcc->proto_data = dev_lec[ioc_data.dev_num]; | 886 | vcc->proto_data = dev_lec[ioc_data.dev_num]; |
| 849 | vcc->push = lec_push; | 887 | vcc->push = lec_push; |
| 850 | return 0; | 888 | return 0; |
| 851 | } | 889 | } |
| 852 | 890 | ||
| 853 | static int | 891 | static int lec_mcast_attach(struct atm_vcc *vcc, int arg) |
| 854 | lec_mcast_attach(struct atm_vcc *vcc, int arg) | ||
| 855 | { | 892 | { |
| 856 | if (arg <0 || arg >= MAX_LEC_ITF || !dev_lec[arg]) | 893 | if (arg < 0 || arg >= MAX_LEC_ITF || !dev_lec[arg]) |
| 857 | return -EINVAL; | 894 | return -EINVAL; |
| 858 | vcc->proto_data = dev_lec[arg]; | 895 | vcc->proto_data = dev_lec[arg]; |
| 859 | return (lec_mcast_make((struct lec_priv*)dev_lec[arg]->priv, vcc)); | 896 | return (lec_mcast_make((struct lec_priv *)dev_lec[arg]->priv, vcc)); |
| 860 | } | 897 | } |
| 861 | 898 | ||
| 862 | /* Initialize device. */ | 899 | /* Initialize device. */ |
| 863 | static int | 900 | static int lecd_attach(struct atm_vcc *vcc, int arg) |
| 864 | lecd_attach(struct atm_vcc *vcc, int arg) | 901 | { |
| 865 | { | 902 | int i; |
| 866 | int i; | 903 | struct lec_priv *priv; |
| 867 | struct lec_priv *priv; | 904 | |
| 868 | 905 | if (arg < 0) | |
| 869 | if (arg<0) | 906 | i = 0; |
| 870 | i = 0; | 907 | else |
| 871 | else | 908 | i = arg; |
| 872 | i = arg; | ||
| 873 | #ifdef CONFIG_TR | 909 | #ifdef CONFIG_TR |
| 874 | if (arg >= MAX_LEC_ITF) | 910 | if (arg >= MAX_LEC_ITF) |
| 875 | return -EINVAL; | 911 | return -EINVAL; |
| 876 | #else /* Reserve the top NUM_TR_DEVS for TR */ | 912 | #else /* Reserve the top NUM_TR_DEVS for TR */ |
| 877 | if (arg >= (MAX_LEC_ITF-NUM_TR_DEVS)) | 913 | if (arg >= (MAX_LEC_ITF - NUM_TR_DEVS)) |
| 878 | return -EINVAL; | 914 | return -EINVAL; |
| 879 | #endif | 915 | #endif |
| 880 | if (!dev_lec[i]) { | 916 | if (!dev_lec[i]) { |
| 881 | int is_trdev, size; | 917 | int is_trdev, size; |
| 882 | 918 | ||
| 883 | is_trdev = 0; | 919 | is_trdev = 0; |
| 884 | if (i >= (MAX_LEC_ITF - NUM_TR_DEVS)) | 920 | if (i >= (MAX_LEC_ITF - NUM_TR_DEVS)) |
| 885 | is_trdev = 1; | 921 | is_trdev = 1; |
| 886 | 922 | ||
| 887 | size = sizeof(struct lec_priv); | 923 | size = sizeof(struct lec_priv); |
| 888 | #ifdef CONFIG_TR | 924 | #ifdef CONFIG_TR |
| 889 | if (is_trdev) | 925 | if (is_trdev) |
| 890 | dev_lec[i] = alloc_trdev(size); | 926 | dev_lec[i] = alloc_trdev(size); |
| 891 | else | 927 | else |
| 892 | #endif | 928 | #endif |
| 893 | dev_lec[i] = alloc_etherdev(size); | 929 | dev_lec[i] = alloc_etherdev(size); |
| 894 | if (!dev_lec[i]) | 930 | if (!dev_lec[i]) |
| 895 | return -ENOMEM; | 931 | return -ENOMEM; |
| 896 | snprintf(dev_lec[i]->name, IFNAMSIZ, "lec%d", i); | 932 | snprintf(dev_lec[i]->name, IFNAMSIZ, "lec%d", i); |
| 897 | if (register_netdev(dev_lec[i])) { | 933 | if (register_netdev(dev_lec[i])) { |
| 898 | free_netdev(dev_lec[i]); | 934 | free_netdev(dev_lec[i]); |
| 899 | return -EINVAL; | 935 | return -EINVAL; |
| 900 | } | 936 | } |
| 901 | 937 | ||
| 902 | priv = dev_lec[i]->priv; | 938 | priv = dev_lec[i]->priv; |
| 903 | priv->is_trdev = is_trdev; | 939 | priv->is_trdev = is_trdev; |
| 904 | lec_init(dev_lec[i]); | 940 | lec_init(dev_lec[i]); |
| 905 | } else { | 941 | } else { |
| 906 | priv = dev_lec[i]->priv; | 942 | priv = dev_lec[i]->priv; |
| 907 | if (priv->lecd) | 943 | if (priv->lecd) |
| 908 | return -EADDRINUSE; | 944 | return -EADDRINUSE; |
| 909 | } | 945 | } |
| 910 | lec_arp_init(priv); | 946 | lec_arp_init(priv); |
| 911 | priv->itfnum = i; /* LANE2 addition */ | 947 | priv->itfnum = i; /* LANE2 addition */ |
| 912 | priv->lecd = vcc; | 948 | priv->lecd = vcc; |
| 913 | vcc->dev = &lecatm_dev; | 949 | vcc->dev = &lecatm_dev; |
| 914 | vcc_insert_socket(sk_atm(vcc)); | 950 | vcc_insert_socket(sk_atm(vcc)); |
| 915 | 951 | ||
| 916 | vcc->proto_data = dev_lec[i]; | 952 | vcc->proto_data = dev_lec[i]; |
| 917 | set_bit(ATM_VF_META,&vcc->flags); | 953 | set_bit(ATM_VF_META, &vcc->flags); |
| 918 | set_bit(ATM_VF_READY,&vcc->flags); | 954 | set_bit(ATM_VF_READY, &vcc->flags); |
| 919 | 955 | ||
| 920 | /* Set default values to these variables */ | 956 | /* Set default values to these variables */ |
| 921 | priv->maximum_unknown_frame_count = 1; | 957 | priv->maximum_unknown_frame_count = 1; |
| 922 | priv->max_unknown_frame_time = (1*HZ); | 958 | priv->max_unknown_frame_time = (1 * HZ); |
| 923 | priv->vcc_timeout_period = (1200*HZ); | 959 | priv->vcc_timeout_period = (1200 * HZ); |
| 924 | priv->max_retry_count = 1; | 960 | priv->max_retry_count = 1; |
| 925 | priv->aging_time = (300*HZ); | 961 | priv->aging_time = (300 * HZ); |
| 926 | priv->forward_delay_time = (15*HZ); | 962 | priv->forward_delay_time = (15 * HZ); |
| 927 | priv->topology_change = 0; | 963 | priv->topology_change = 0; |
| 928 | priv->arp_response_time = (1*HZ); | 964 | priv->arp_response_time = (1 * HZ); |
| 929 | priv->flush_timeout = (4*HZ); | 965 | priv->flush_timeout = (4 * HZ); |
| 930 | priv->path_switching_delay = (6*HZ); | 966 | priv->path_switching_delay = (6 * HZ); |
| 931 | 967 | ||
| 932 | if (dev_lec[i]->flags & IFF_UP) { | 968 | if (dev_lec[i]->flags & IFF_UP) { |
| 933 | netif_start_queue(dev_lec[i]); | 969 | netif_start_queue(dev_lec[i]); |
| 934 | } | 970 | } |
| 935 | __module_get(THIS_MODULE); | 971 | __module_get(THIS_MODULE); |
| 936 | return i; | 972 | return i; |
| 937 | } | 973 | } |
| 938 | 974 | ||
| 939 | #ifdef CONFIG_PROC_FS | 975 | #ifdef CONFIG_PROC_FS |
| 940 | static char* lec_arp_get_status_string(unsigned char status) | 976 | static char *lec_arp_get_status_string(unsigned char status) |
| 941 | { | 977 | { |
| 942 | static char *lec_arp_status_string[] = { | 978 | static char *lec_arp_status_string[] = { |
| 943 | "ESI_UNKNOWN ", | 979 | "ESI_UNKNOWN ", |
| @@ -967,52 +1003,54 @@ static void lec_info(struct seq_file *seq, struct lec_arp_table *entry) | |||
| 967 | if (entry->vcc) | 1003 | if (entry->vcc) |
| 968 | seq_printf(seq, "%3d %3d ", entry->vcc->vpi, entry->vcc->vci); | 1004 | seq_printf(seq, "%3d %3d ", entry->vcc->vpi, entry->vcc->vci); |
| 969 | else | 1005 | else |
| 970 | seq_printf(seq, " "); | 1006 | seq_printf(seq, " "); |
| 971 | if (entry->recv_vcc) { | 1007 | if (entry->recv_vcc) { |
| 972 | seq_printf(seq, " %3d %3d", entry->recv_vcc->vpi, | 1008 | seq_printf(seq, " %3d %3d", entry->recv_vcc->vpi, |
| 973 | entry->recv_vcc->vci); | 1009 | entry->recv_vcc->vci); |
| 974 | } | 1010 | } |
| 975 | seq_putc(seq, '\n'); | 1011 | seq_putc(seq, '\n'); |
| 976 | } | 1012 | } |
| 977 | 1013 | ||
| 978 | |||
| 979 | struct lec_state { | 1014 | struct lec_state { |
| 980 | unsigned long flags; | 1015 | unsigned long flags; |
| 981 | struct lec_priv *locked; | 1016 | struct lec_priv *locked; |
| 982 | struct lec_arp_table *entry; | 1017 | struct hlist_node *node; |
| 983 | struct net_device *dev; | 1018 | struct net_device *dev; |
| 984 | int itf; | 1019 | int itf; |
| 985 | int arp_table; | 1020 | int arp_table; |
| 986 | int misc_table; | 1021 | int misc_table; |
| 987 | }; | 1022 | }; |
| 988 | 1023 | ||
| 989 | static void *lec_tbl_walk(struct lec_state *state, struct lec_arp_table *tbl, | 1024 | static void *lec_tbl_walk(struct lec_state *state, struct hlist_head *tbl, |
| 990 | loff_t *l) | 1025 | loff_t *l) |
| 991 | { | 1026 | { |
| 992 | struct lec_arp_table *e = state->entry; | 1027 | struct hlist_node *e = state->node; |
| 1028 | struct lec_arp_table *tmp; | ||
| 993 | 1029 | ||
| 994 | if (!e) | 1030 | if (!e) |
| 995 | e = tbl; | 1031 | e = tbl->first; |
| 996 | if (e == (void *)1) { | 1032 | if (e == (void *)1) { |
| 997 | e = tbl; | 1033 | e = tbl->first; |
| 998 | --*l; | 1034 | --*l; |
| 999 | } | 1035 | } |
| 1000 | for (; e; e = e->next) { | 1036 | |
| 1037 | hlist_for_each_entry_from(tmp, e, next) { | ||
| 1001 | if (--*l < 0) | 1038 | if (--*l < 0) |
| 1002 | break; | 1039 | break; |
| 1003 | } | 1040 | } |
| 1004 | state->entry = e; | 1041 | state->node = e; |
| 1042 | |||
| 1005 | return (*l < 0) ? state : NULL; | 1043 | return (*l < 0) ? state : NULL; |
| 1006 | } | 1044 | } |
| 1007 | 1045 | ||
| 1008 | static void *lec_arp_walk(struct lec_state *state, loff_t *l, | 1046 | static void *lec_arp_walk(struct lec_state *state, loff_t *l, |
| 1009 | struct lec_priv *priv) | 1047 | struct lec_priv *priv) |
| 1010 | { | 1048 | { |
| 1011 | void *v = NULL; | 1049 | void *v = NULL; |
| 1012 | int p; | 1050 | int p; |
| 1013 | 1051 | ||
| 1014 | for (p = state->arp_table; p < LEC_ARP_TABLE_SIZE; p++) { | 1052 | for (p = state->arp_table; p < LEC_ARP_TABLE_SIZE; p++) { |
| 1015 | v = lec_tbl_walk(state, priv->lec_arp_tables[p], l); | 1053 | v = lec_tbl_walk(state, &priv->lec_arp_tables[p], l); |
| 1016 | if (v) | 1054 | if (v) |
| 1017 | break; | 1055 | break; |
| 1018 | } | 1056 | } |
| @@ -1023,10 +1061,10 @@ static void *lec_arp_walk(struct lec_state *state, loff_t *l, | |||
| 1023 | static void *lec_misc_walk(struct lec_state *state, loff_t *l, | 1061 | static void *lec_misc_walk(struct lec_state *state, loff_t *l, |
| 1024 | struct lec_priv *priv) | 1062 | struct lec_priv *priv) |
| 1025 | { | 1063 | { |
| 1026 | struct lec_arp_table *lec_misc_tables[] = { | 1064 | struct hlist_head *lec_misc_tables[] = { |
| 1027 | priv->lec_arp_empty_ones, | 1065 | &priv->lec_arp_empty_ones, |
| 1028 | priv->lec_no_forward, | 1066 | &priv->lec_no_forward, |
| 1029 | priv->mcast_fwds | 1067 | &priv->mcast_fwds |
| 1030 | }; | 1068 | }; |
| 1031 | void *v = NULL; | 1069 | void *v = NULL; |
| 1032 | int q; | 1070 | int q; |
| @@ -1047,8 +1085,7 @@ static void *lec_priv_walk(struct lec_state *state, loff_t *l, | |||
| 1047 | state->locked = priv; | 1085 | state->locked = priv; |
| 1048 | spin_lock_irqsave(&priv->lec_arp_lock, state->flags); | 1086 | spin_lock_irqsave(&priv->lec_arp_lock, state->flags); |
| 1049 | } | 1087 | } |
| 1050 | if (!lec_arp_walk(state, l, priv) && | 1088 | if (!lec_arp_walk(state, l, priv) && !lec_misc_walk(state, l, priv)) { |
| 1051 | !lec_misc_walk(state, l, priv)) { | ||
| 1052 | spin_unlock_irqrestore(&priv->lec_arp_lock, state->flags); | 1089 | spin_unlock_irqrestore(&priv->lec_arp_lock, state->flags); |
| 1053 | state->locked = NULL; | 1090 | state->locked = NULL; |
| 1054 | /* Partial state reset for the next time we get called */ | 1091 | /* Partial state reset for the next time we get called */ |
| @@ -1082,7 +1119,7 @@ static void *lec_get_idx(struct lec_state *state, loff_t l) | |||
| 1082 | if (v) | 1119 | if (v) |
| 1083 | break; | 1120 | break; |
| 1084 | } | 1121 | } |
| 1085 | return v; | 1122 | return v; |
| 1086 | } | 1123 | } |
| 1087 | 1124 | ||
| 1088 | static void *lec_seq_start(struct seq_file *seq, loff_t *pos) | 1125 | static void *lec_seq_start(struct seq_file *seq, loff_t *pos) |
| @@ -1094,9 +1131,9 @@ static void *lec_seq_start(struct seq_file *seq, loff_t *pos) | |||
| 1094 | state->locked = NULL; | 1131 | state->locked = NULL; |
| 1095 | state->arp_table = 0; | 1132 | state->arp_table = 0; |
| 1096 | state->misc_table = 0; | 1133 | state->misc_table = 0; |
| 1097 | state->entry = (void *)1; | 1134 | state->node = (void *)1; |
| 1098 | 1135 | ||
| 1099 | return *pos ? lec_get_idx(state, *pos) : (void*)1; | 1136 | return *pos ? lec_get_idx(state, *pos) : (void *)1; |
| 1100 | } | 1137 | } |
| 1101 | 1138 | ||
| 1102 | static void lec_seq_stop(struct seq_file *seq, void *v) | 1139 | static void lec_seq_stop(struct seq_file *seq, void *v) |
| @@ -1121,27 +1158,28 @@ static void *lec_seq_next(struct seq_file *seq, void *v, loff_t *pos) | |||
| 1121 | 1158 | ||
| 1122 | static int lec_seq_show(struct seq_file *seq, void *v) | 1159 | static int lec_seq_show(struct seq_file *seq, void *v) |
| 1123 | { | 1160 | { |
| 1124 | static char lec_banner[] = "Itf MAC ATM destination" | 1161 | static char lec_banner[] = "Itf MAC ATM destination" |
| 1125 | " Status Flags " | 1162 | " Status Flags " |
| 1126 | "VPI/VCI Recv VPI/VCI\n"; | 1163 | "VPI/VCI Recv VPI/VCI\n"; |
| 1127 | 1164 | ||
| 1128 | if (v == (void *)1) | 1165 | if (v == (void *)1) |
| 1129 | seq_puts(seq, lec_banner); | 1166 | seq_puts(seq, lec_banner); |
| 1130 | else { | 1167 | else { |
| 1131 | struct lec_state *state = seq->private; | 1168 | struct lec_state *state = seq->private; |
| 1132 | struct net_device *dev = state->dev; | 1169 | struct net_device *dev = state->dev; |
| 1170 | struct lec_arp_table *entry = hlist_entry(state->node, struct lec_arp_table, next); | ||
| 1133 | 1171 | ||
| 1134 | seq_printf(seq, "%s ", dev->name); | 1172 | seq_printf(seq, "%s ", dev->name); |
| 1135 | lec_info(seq, state->entry); | 1173 | lec_info(seq, entry); |
| 1136 | } | 1174 | } |
| 1137 | return 0; | 1175 | return 0; |
| 1138 | } | 1176 | } |
| 1139 | 1177 | ||
| 1140 | static struct seq_operations lec_seq_ops = { | 1178 | static struct seq_operations lec_seq_ops = { |
| 1141 | .start = lec_seq_start, | 1179 | .start = lec_seq_start, |
| 1142 | .next = lec_seq_next, | 1180 | .next = lec_seq_next, |
| 1143 | .stop = lec_seq_stop, | 1181 | .stop = lec_seq_stop, |
| 1144 | .show = lec_seq_show, | 1182 | .show = lec_seq_show, |
| 1145 | }; | 1183 | }; |
| 1146 | 1184 | ||
| 1147 | static int lec_seq_open(struct inode *inode, struct file *file) | 1185 | static int lec_seq_open(struct inode *inode, struct file *file) |
| @@ -1175,11 +1213,11 @@ static int lec_seq_release(struct inode *inode, struct file *file) | |||
| 1175 | } | 1213 | } |
| 1176 | 1214 | ||
| 1177 | static struct file_operations lec_seq_fops = { | 1215 | static struct file_operations lec_seq_fops = { |
| 1178 | .owner = THIS_MODULE, | 1216 | .owner = THIS_MODULE, |
| 1179 | .open = lec_seq_open, | 1217 | .open = lec_seq_open, |
| 1180 | .read = seq_read, | 1218 | .read = seq_read, |
| 1181 | .llseek = seq_lseek, | 1219 | .llseek = seq_lseek, |
| 1182 | .release = lec_seq_release, | 1220 | .release = lec_seq_release, |
| 1183 | }; | 1221 | }; |
| 1184 | #endif | 1222 | #endif |
| 1185 | 1223 | ||
| @@ -1187,38 +1225,38 @@ static int lane_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg) | |||
| 1187 | { | 1225 | { |
| 1188 | struct atm_vcc *vcc = ATM_SD(sock); | 1226 | struct atm_vcc *vcc = ATM_SD(sock); |
| 1189 | int err = 0; | 1227 | int err = 0; |
| 1190 | 1228 | ||
| 1191 | switch (cmd) { | 1229 | switch (cmd) { |
| 1192 | case ATMLEC_CTRL: | 1230 | case ATMLEC_CTRL: |
| 1193 | case ATMLEC_MCAST: | 1231 | case ATMLEC_MCAST: |
| 1194 | case ATMLEC_DATA: | 1232 | case ATMLEC_DATA: |
| 1195 | if (!capable(CAP_NET_ADMIN)) | 1233 | if (!capable(CAP_NET_ADMIN)) |
| 1196 | return -EPERM; | 1234 | return -EPERM; |
| 1197 | break; | 1235 | break; |
| 1198 | default: | 1236 | default: |
| 1199 | return -ENOIOCTLCMD; | 1237 | return -ENOIOCTLCMD; |
| 1200 | } | 1238 | } |
| 1201 | 1239 | ||
| 1202 | switch (cmd) { | 1240 | switch (cmd) { |
| 1203 | case ATMLEC_CTRL: | 1241 | case ATMLEC_CTRL: |
| 1204 | err = lecd_attach(vcc, (int) arg); | 1242 | err = lecd_attach(vcc, (int)arg); |
| 1205 | if (err >= 0) | 1243 | if (err >= 0) |
| 1206 | sock->state = SS_CONNECTED; | 1244 | sock->state = SS_CONNECTED; |
| 1207 | break; | 1245 | break; |
| 1208 | case ATMLEC_MCAST: | 1246 | case ATMLEC_MCAST: |
| 1209 | err = lec_mcast_attach(vcc, (int) arg); | 1247 | err = lec_mcast_attach(vcc, (int)arg); |
| 1210 | break; | 1248 | break; |
| 1211 | case ATMLEC_DATA: | 1249 | case ATMLEC_DATA: |
| 1212 | err = lec_vcc_attach(vcc, (void __user *) arg); | 1250 | err = lec_vcc_attach(vcc, (void __user *)arg); |
| 1213 | break; | 1251 | break; |
| 1214 | } | 1252 | } |
| 1215 | 1253 | ||
| 1216 | return err; | 1254 | return err; |
| 1217 | } | 1255 | } |
| 1218 | 1256 | ||
| 1219 | static struct atm_ioctl lane_ioctl_ops = { | 1257 | static struct atm_ioctl lane_ioctl_ops = { |
| 1220 | .owner = THIS_MODULE, | 1258 | .owner = THIS_MODULE, |
| 1221 | .ioctl = lane_ioctl, | 1259 | .ioctl = lane_ioctl, |
| 1222 | }; | 1260 | }; |
| 1223 | 1261 | ||
| 1224 | static int __init lane_module_init(void) | 1262 | static int __init lane_module_init(void) |
| @@ -1232,29 +1270,29 @@ static int __init lane_module_init(void) | |||
| 1232 | #endif | 1270 | #endif |
| 1233 | 1271 | ||
| 1234 | register_atm_ioctl(&lane_ioctl_ops); | 1272 | register_atm_ioctl(&lane_ioctl_ops); |
| 1235 | printk("lec.c: " __DATE__ " " __TIME__ " initialized\n"); | 1273 | printk("lec.c: " __DATE__ " " __TIME__ " initialized\n"); |
| 1236 | return 0; | 1274 | return 0; |
| 1237 | } | 1275 | } |
| 1238 | 1276 | ||
| 1239 | static void __exit lane_module_cleanup(void) | 1277 | static void __exit lane_module_cleanup(void) |
| 1240 | { | 1278 | { |
| 1241 | int i; | 1279 | int i; |
| 1242 | struct lec_priv *priv; | 1280 | struct lec_priv *priv; |
| 1243 | 1281 | ||
| 1244 | remove_proc_entry("lec", atm_proc_root); | 1282 | remove_proc_entry("lec", atm_proc_root); |
| 1245 | 1283 | ||
| 1246 | deregister_atm_ioctl(&lane_ioctl_ops); | 1284 | deregister_atm_ioctl(&lane_ioctl_ops); |
| 1247 | 1285 | ||
| 1248 | for (i = 0; i < MAX_LEC_ITF; i++) { | 1286 | for (i = 0; i < MAX_LEC_ITF; i++) { |
| 1249 | if (dev_lec[i] != NULL) { | 1287 | if (dev_lec[i] != NULL) { |
| 1250 | priv = (struct lec_priv *)dev_lec[i]->priv; | 1288 | priv = (struct lec_priv *)dev_lec[i]->priv; |
| 1251 | unregister_netdev(dev_lec[i]); | 1289 | unregister_netdev(dev_lec[i]); |
| 1252 | free_netdev(dev_lec[i]); | 1290 | free_netdev(dev_lec[i]); |
| 1253 | dev_lec[i] = NULL; | 1291 | dev_lec[i] = NULL; |
| 1254 | } | 1292 | } |
| 1255 | } | 1293 | } |
| 1256 | 1294 | ||
| 1257 | return; | 1295 | return; |
| 1258 | } | 1296 | } |
| 1259 | 1297 | ||
| 1260 | module_init(lane_module_init); | 1298 | module_init(lane_module_init); |
| @@ -1268,34 +1306,34 @@ module_exit(lane_module_cleanup); | |||
| 1268 | * If dst_mac == NULL, targetless LE_ARP will be sent | 1306 | * If dst_mac == NULL, targetless LE_ARP will be sent |
| 1269 | */ | 1307 | */ |
| 1270 | static int lane2_resolve(struct net_device *dev, u8 *dst_mac, int force, | 1308 | static int lane2_resolve(struct net_device *dev, u8 *dst_mac, int force, |
| 1271 | u8 **tlvs, u32 *sizeoftlvs) | 1309 | u8 **tlvs, u32 *sizeoftlvs) |
| 1272 | { | 1310 | { |
| 1273 | unsigned long flags; | 1311 | unsigned long flags; |
| 1274 | struct lec_priv *priv = (struct lec_priv *)dev->priv; | 1312 | struct lec_priv *priv = (struct lec_priv *)dev->priv; |
| 1275 | struct lec_arp_table *table; | 1313 | struct lec_arp_table *table; |
| 1276 | struct sk_buff *skb; | 1314 | struct sk_buff *skb; |
| 1277 | int retval; | 1315 | int retval; |
| 1278 | 1316 | ||
| 1279 | if (force == 0) { | 1317 | if (force == 0) { |
| 1280 | spin_lock_irqsave(&priv->lec_arp_lock, flags); | 1318 | spin_lock_irqsave(&priv->lec_arp_lock, flags); |
| 1281 | table = lec_arp_find(priv, dst_mac); | 1319 | table = lec_arp_find(priv, dst_mac); |
| 1282 | spin_unlock_irqrestore(&priv->lec_arp_lock, flags); | 1320 | spin_unlock_irqrestore(&priv->lec_arp_lock, flags); |
| 1283 | if(table == NULL) | 1321 | if (table == NULL) |
| 1284 | return -1; | 1322 | return -1; |
| 1285 | 1323 | ||
| 1286 | *tlvs = kmalloc(table->sizeoftlvs, GFP_ATOMIC); | 1324 | *tlvs = kmalloc(table->sizeoftlvs, GFP_ATOMIC); |
| 1287 | if (*tlvs == NULL) | 1325 | if (*tlvs == NULL) |
| 1288 | return -1; | 1326 | return -1; |
| 1289 | 1327 | ||
| 1290 | memcpy(*tlvs, table->tlvs, table->sizeoftlvs); | 1328 | memcpy(*tlvs, table->tlvs, table->sizeoftlvs); |
| 1291 | *sizeoftlvs = table->sizeoftlvs; | 1329 | *sizeoftlvs = table->sizeoftlvs; |
| 1292 | 1330 | ||
| 1293 | return 0; | 1331 | return 0; |
| 1294 | } | 1332 | } |
| 1295 | 1333 | ||
| 1296 | if (sizeoftlvs == NULL) | 1334 | if (sizeoftlvs == NULL) |
| 1297 | retval = send_to_lecd(priv, l_arp_xmt, dst_mac, NULL, NULL); | 1335 | retval = send_to_lecd(priv, l_arp_xmt, dst_mac, NULL, NULL); |
| 1298 | 1336 | ||
| 1299 | else { | 1337 | else { |
| 1300 | skb = alloc_skb(*sizeoftlvs, GFP_ATOMIC); | 1338 | skb = alloc_skb(*sizeoftlvs, GFP_ATOMIC); |
| 1301 | if (skb == NULL) | 1339 | if (skb == NULL) |
| @@ -1304,9 +1342,8 @@ static int lane2_resolve(struct net_device *dev, u8 *dst_mac, int force, | |||
| 1304 | memcpy(skb->data, *tlvs, *sizeoftlvs); | 1342 | memcpy(skb->data, *tlvs, *sizeoftlvs); |
| 1305 | retval = send_to_lecd(priv, l_arp_xmt, dst_mac, NULL, skb); | 1343 | retval = send_to_lecd(priv, l_arp_xmt, dst_mac, NULL, skb); |
| 1306 | } | 1344 | } |
| 1307 | return retval; | 1345 | return retval; |
| 1308 | } | 1346 | } |
| 1309 | |||
| 1310 | 1347 | ||
| 1311 | /* | 1348 | /* |
| 1312 | * LANE2: 3.1.4, LE_ASSOCIATE.request | 1349 | * LANE2: 3.1.4, LE_ASSOCIATE.request |
| @@ -1315,80 +1352,85 @@ static int lane2_resolve(struct net_device *dev, u8 *dst_mac, int force, | |||
| 1315 | * Returns 1 for success, 0 for failure (out of memory) | 1352 | * Returns 1 for success, 0 for failure (out of memory) |
| 1316 | * | 1353 | * |
| 1317 | */ | 1354 | */ |
| 1318 | static int lane2_associate_req (struct net_device *dev, u8 *lan_dst, | 1355 | static int lane2_associate_req(struct net_device *dev, u8 *lan_dst, |
| 1319 | u8 *tlvs, u32 sizeoftlvs) | 1356 | u8 *tlvs, u32 sizeoftlvs) |
| 1320 | { | 1357 | { |
| 1321 | int retval; | 1358 | int retval; |
| 1322 | struct sk_buff *skb; | 1359 | struct sk_buff *skb; |
| 1323 | struct lec_priv *priv = (struct lec_priv*)dev->priv; | 1360 | struct lec_priv *priv = (struct lec_priv *)dev->priv; |
| 1324 | 1361 | ||
| 1325 | if (compare_ether_addr(lan_dst, dev->dev_addr)) | 1362 | if (compare_ether_addr(lan_dst, dev->dev_addr)) |
| 1326 | return (0); /* not our mac address */ | 1363 | return (0); /* not our mac address */ |
| 1327 | 1364 | ||
| 1328 | kfree(priv->tlvs); /* NULL if there was no previous association */ | 1365 | kfree(priv->tlvs); /* NULL if there was no previous association */ |
| 1329 | 1366 | ||
| 1330 | priv->tlvs = kmalloc(sizeoftlvs, GFP_KERNEL); | 1367 | priv->tlvs = kmalloc(sizeoftlvs, GFP_KERNEL); |
| 1331 | if (priv->tlvs == NULL) | 1368 | if (priv->tlvs == NULL) |
| 1332 | return (0); | 1369 | return (0); |
| 1333 | priv->sizeoftlvs = sizeoftlvs; | 1370 | priv->sizeoftlvs = sizeoftlvs; |
| 1334 | memcpy(priv->tlvs, tlvs, sizeoftlvs); | 1371 | memcpy(priv->tlvs, tlvs, sizeoftlvs); |
| 1335 | 1372 | ||
| 1336 | skb = alloc_skb(sizeoftlvs, GFP_ATOMIC); | 1373 | skb = alloc_skb(sizeoftlvs, GFP_ATOMIC); |
| 1337 | if (skb == NULL) | 1374 | if (skb == NULL) |
| 1338 | return 0; | 1375 | return 0; |
| 1339 | skb->len = sizeoftlvs; | 1376 | skb->len = sizeoftlvs; |
| 1340 | memcpy(skb->data, tlvs, sizeoftlvs); | 1377 | memcpy(skb->data, tlvs, sizeoftlvs); |
| 1341 | retval = send_to_lecd(priv, l_associate_req, NULL, NULL, skb); | 1378 | retval = send_to_lecd(priv, l_associate_req, NULL, NULL, skb); |
| 1342 | if (retval != 0) | 1379 | if (retval != 0) |
| 1343 | printk("lec.c: lane2_associate_req() failed\n"); | 1380 | printk("lec.c: lane2_associate_req() failed\n"); |
| 1344 | /* If the previous association has changed we must | 1381 | /* |
| 1345 | * somehow notify other LANE entities about the change | 1382 | * If the previous association has changed we must |
| 1346 | */ | 1383 | * somehow notify other LANE entities about the change |
| 1347 | return (1); | 1384 | */ |
| 1385 | return (1); | ||
| 1348 | } | 1386 | } |
| 1349 | 1387 | ||
| 1350 | /* | 1388 | /* |
| 1351 | * LANE2: 3.1.5, LE_ASSOCIATE.indication | 1389 | * LANE2: 3.1.5, LE_ASSOCIATE.indication |
| 1352 | * | 1390 | * |
| 1353 | */ | 1391 | */ |
| 1354 | static void lane2_associate_ind (struct net_device *dev, u8 *mac_addr, | 1392 | static void lane2_associate_ind(struct net_device *dev, u8 *mac_addr, |
| 1355 | u8 *tlvs, u32 sizeoftlvs) | 1393 | u8 *tlvs, u32 sizeoftlvs) |
| 1356 | { | 1394 | { |
| 1357 | #if 0 | 1395 | #if 0 |
| 1358 | int i = 0; | 1396 | int i = 0; |
| 1359 | #endif | 1397 | #endif |
| 1360 | struct lec_priv *priv = (struct lec_priv *)dev->priv; | 1398 | struct lec_priv *priv = (struct lec_priv *)dev->priv; |
| 1361 | #if 0 /* Why have the TLVs in LE_ARP entries since we do not use them? When you | 1399 | #if 0 /* |
| 1362 | uncomment this code, make sure the TLVs get freed when entry is killed */ | 1400 | * Why have the TLVs in LE_ARP entries |
| 1363 | struct lec_arp_table *entry = lec_arp_find(priv, mac_addr); | 1401 | * since we do not use them? When you |
| 1402 | * uncomment this code, make sure the | ||
| 1403 | * TLVs get freed when entry is killed | ||
| 1404 | */ | ||
| 1405 | struct lec_arp_table *entry = lec_arp_find(priv, mac_addr); | ||
| 1364 | 1406 | ||
| 1365 | if (entry == NULL) | 1407 | if (entry == NULL) |
| 1366 | return; /* should not happen */ | 1408 | return; /* should not happen */ |
| 1367 | 1409 | ||
| 1368 | kfree(entry->tlvs); | 1410 | kfree(entry->tlvs); |
| 1369 | 1411 | ||
| 1370 | entry->tlvs = kmalloc(sizeoftlvs, GFP_KERNEL); | 1412 | entry->tlvs = kmalloc(sizeoftlvs, GFP_KERNEL); |
| 1371 | if (entry->tlvs == NULL) | 1413 | if (entry->tlvs == NULL) |
| 1372 | return; | 1414 | return; |
| 1373 | 1415 | ||
| 1374 | entry->sizeoftlvs = sizeoftlvs; | 1416 | entry->sizeoftlvs = sizeoftlvs; |
| 1375 | memcpy(entry->tlvs, tlvs, sizeoftlvs); | 1417 | memcpy(entry->tlvs, tlvs, sizeoftlvs); |
| 1376 | #endif | 1418 | #endif |
| 1377 | #if 0 | 1419 | #if 0 |
| 1378 | printk("lec.c: lane2_associate_ind()\n"); | 1420 | printk("lec.c: lane2_associate_ind()\n"); |
| 1379 | printk("dump of tlvs, sizeoftlvs=%d\n", sizeoftlvs); | 1421 | printk("dump of tlvs, sizeoftlvs=%d\n", sizeoftlvs); |
| 1380 | while (i < sizeoftlvs) | 1422 | while (i < sizeoftlvs) |
| 1381 | printk("%02x ", tlvs[i++]); | 1423 | printk("%02x ", tlvs[i++]); |
| 1382 | 1424 | ||
| 1383 | printk("\n"); | 1425 | printk("\n"); |
| 1384 | #endif | 1426 | #endif |
| 1385 | 1427 | ||
| 1386 | /* tell MPOA about the TLVs we saw */ | 1428 | /* tell MPOA about the TLVs we saw */ |
| 1387 | if (priv->lane2_ops && priv->lane2_ops->associate_indicator) { | 1429 | if (priv->lane2_ops && priv->lane2_ops->associate_indicator) { |
| 1388 | priv->lane2_ops->associate_indicator(dev, mac_addr, | 1430 | priv->lane2_ops->associate_indicator(dev, mac_addr, |
| 1389 | tlvs, sizeoftlvs); | 1431 | tlvs, sizeoftlvs); |
| 1390 | } | 1432 | } |
| 1391 | return; | 1433 | return; |
| 1392 | } | 1434 | } |
| 1393 | 1435 | ||
| 1394 | /* | 1436 | /* |
| @@ -1396,7 +1438,6 @@ static void lane2_associate_ind (struct net_device *dev, u8 *mac_addr, | |||
| 1396 | * | 1438 | * |
| 1397 | * lec_arpc.c was added here when making | 1439 | * lec_arpc.c was added here when making |
| 1398 | * lane client modular. October 1997 | 1440 | * lane client modular. October 1997 |
| 1399 | * | ||
| 1400 | */ | 1441 | */ |
| 1401 | 1442 | ||
| 1402 | #include <linux/types.h> | 1443 | #include <linux/types.h> |
| @@ -1407,7 +1448,6 @@ static void lane2_associate_ind (struct net_device *dev, u8 *mac_addr, | |||
| 1407 | #include <linux/inetdevice.h> | 1448 | #include <linux/inetdevice.h> |
| 1408 | #include <net/route.h> | 1449 | #include <net/route.h> |
| 1409 | 1450 | ||
| 1410 | |||
| 1411 | #if 0 | 1451 | #if 0 |
| 1412 | #define DPRINTK(format,args...) | 1452 | #define DPRINTK(format,args...) |
| 1413 | /* | 1453 | /* |
| @@ -1418,7 +1458,7 @@ static void lane2_associate_ind (struct net_device *dev, u8 *mac_addr, | |||
| 1418 | 1458 | ||
| 1419 | #define LEC_ARP_REFRESH_INTERVAL (3*HZ) | 1459 | #define LEC_ARP_REFRESH_INTERVAL (3*HZ) |
| 1420 | 1460 | ||
| 1421 | static void lec_arp_check_expire(unsigned long data); | 1461 | static void lec_arp_check_expire(void *data); |
| 1422 | static void lec_arp_expire_arp(unsigned long data); | 1462 | static void lec_arp_expire_arp(unsigned long data); |
| 1423 | 1463 | ||
| 1424 | /* | 1464 | /* |
| @@ -1430,475 +1470,397 @@ static void lec_arp_expire_arp(unsigned long data); | |||
| 1430 | /* | 1470 | /* |
| 1431 | * Initialization of arp-cache | 1471 | * Initialization of arp-cache |
| 1432 | */ | 1472 | */ |
| 1433 | static void | 1473 | static void lec_arp_init(struct lec_priv *priv) |
| 1434 | lec_arp_init(struct lec_priv *priv) | ||
| 1435 | { | 1474 | { |
| 1436 | unsigned short i; | 1475 | unsigned short i; |
| 1437 | 1476 | ||
| 1438 | for (i = 0; i < LEC_ARP_TABLE_SIZE; i++) { | 1477 | for (i = 0; i < LEC_ARP_TABLE_SIZE; i++) { |
| 1439 | priv->lec_arp_tables[i] = NULL; | 1478 | INIT_HLIST_HEAD(&priv->lec_arp_tables[i]); |
| 1440 | } | 1479 | } |
| 1480 | INIT_HLIST_HEAD(&priv->lec_arp_empty_ones); | ||
| 1481 | INIT_HLIST_HEAD(&priv->lec_no_forward); | ||
| 1482 | INIT_HLIST_HEAD(&priv->mcast_fwds); | ||
| 1441 | spin_lock_init(&priv->lec_arp_lock); | 1483 | spin_lock_init(&priv->lec_arp_lock); |
| 1442 | init_timer(&priv->lec_arp_timer); | 1484 | INIT_WORK(&priv->lec_arp_work, lec_arp_check_expire, priv); |
| 1443 | priv->lec_arp_timer.expires = jiffies + LEC_ARP_REFRESH_INTERVAL; | 1485 | schedule_delayed_work(&priv->lec_arp_work, LEC_ARP_REFRESH_INTERVAL); |
| 1444 | priv->lec_arp_timer.data = (unsigned long)priv; | ||
| 1445 | priv->lec_arp_timer.function = lec_arp_check_expire; | ||
| 1446 | add_timer(&priv->lec_arp_timer); | ||
| 1447 | } | 1486 | } |
| 1448 | 1487 | ||
| 1449 | static void | 1488 | static void lec_arp_clear_vccs(struct lec_arp_table *entry) |
| 1450 | lec_arp_clear_vccs(struct lec_arp_table *entry) | ||
| 1451 | { | 1489 | { |
| 1452 | if (entry->vcc) { | 1490 | if (entry->vcc) { |
| 1453 | struct atm_vcc *vcc = entry->vcc; | 1491 | struct atm_vcc *vcc = entry->vcc; |
| 1454 | struct lec_vcc_priv *vpriv = LEC_VCC_PRIV(vcc); | 1492 | struct lec_vcc_priv *vpriv = LEC_VCC_PRIV(vcc); |
| 1455 | struct net_device *dev = (struct net_device*) vcc->proto_data; | 1493 | struct net_device *dev = (struct net_device *)vcc->proto_data; |
| 1456 | 1494 | ||
| 1457 | vcc->pop = vpriv->old_pop; | 1495 | vcc->pop = vpriv->old_pop; |
| 1458 | if (vpriv->xoff) | 1496 | if (vpriv->xoff) |
| 1459 | netif_wake_queue(dev); | 1497 | netif_wake_queue(dev); |
| 1460 | kfree(vpriv); | 1498 | kfree(vpriv); |
| 1461 | vcc->user_back = NULL; | 1499 | vcc->user_back = NULL; |
| 1462 | vcc->push = entry->old_push; | 1500 | vcc->push = entry->old_push; |
| 1463 | vcc_release_async(vcc, -EPIPE); | 1501 | vcc_release_async(vcc, -EPIPE); |
| 1464 | vcc = NULL; | 1502 | entry->vcc = NULL; |
| 1465 | } | 1503 | } |
| 1466 | if (entry->recv_vcc) { | 1504 | if (entry->recv_vcc) { |
| 1467 | entry->recv_vcc->push = entry->old_recv_push; | 1505 | entry->recv_vcc->push = entry->old_recv_push; |
| 1468 | vcc_release_async(entry->recv_vcc, -EPIPE); | 1506 | vcc_release_async(entry->recv_vcc, -EPIPE); |
| 1469 | entry->recv_vcc = NULL; | 1507 | entry->recv_vcc = NULL; |
| 1470 | } | 1508 | } |
| 1471 | } | 1509 | } |
| 1472 | 1510 | ||
| 1473 | /* | 1511 | /* |
| 1474 | * Insert entry to lec_arp_table | 1512 | * Insert entry to lec_arp_table |
| 1475 | * LANE2: Add to the end of the list to satisfy 8.1.13 | 1513 | * LANE2: Add to the end of the list to satisfy 8.1.13 |
| 1476 | */ | 1514 | */ |
| 1477 | static inline void | 1515 | static inline void |
| 1478 | lec_arp_add(struct lec_priv *priv, struct lec_arp_table *to_add) | 1516 | lec_arp_add(struct lec_priv *priv, struct lec_arp_table *entry) |
| 1479 | { | 1517 | { |
| 1480 | unsigned short place; | 1518 | struct hlist_head *tmp; |
| 1481 | struct lec_arp_table *tmp; | 1519 | |
| 1482 | 1520 | tmp = &priv->lec_arp_tables[HASH(entry->mac_addr[ETH_ALEN - 1])]; | |
| 1483 | place = HASH(to_add->mac_addr[ETH_ALEN-1]); | 1521 | hlist_add_head(&entry->next, tmp); |
| 1484 | tmp = priv->lec_arp_tables[place]; | 1522 | |
| 1485 | to_add->next = NULL; | 1523 | DPRINTK("LEC_ARP: Added entry:%2.2x %2.2x %2.2x %2.2x %2.2x %2.2x\n", |
| 1486 | if (tmp == NULL) | 1524 | 0xff & entry->mac_addr[0], 0xff & entry->mac_addr[1], |
| 1487 | priv->lec_arp_tables[place] = to_add; | 1525 | 0xff & entry->mac_addr[2], 0xff & entry->mac_addr[3], |
| 1488 | 1526 | 0xff & entry->mac_addr[4], 0xff & entry->mac_addr[5]); | |
| 1489 | else { /* add to the end */ | ||
| 1490 | while (tmp->next) | ||
| 1491 | tmp = tmp->next; | ||
| 1492 | tmp->next = to_add; | ||
| 1493 | } | ||
| 1494 | |||
| 1495 | DPRINTK("LEC_ARP: Added entry:%2.2x %2.2x %2.2x %2.2x %2.2x %2.2x\n", | ||
| 1496 | 0xff&to_add->mac_addr[0], 0xff&to_add->mac_addr[1], | ||
| 1497 | 0xff&to_add->mac_addr[2], 0xff&to_add->mac_addr[3], | ||
| 1498 | 0xff&to_add->mac_addr[4], 0xff&to_add->mac_addr[5]); | ||
| 1499 | } | 1527 | } |
| 1500 | 1528 | ||
| 1501 | /* | 1529 | /* |
| 1502 | * Remove entry from lec_arp_table | 1530 | * Remove entry from lec_arp_table |
| 1503 | */ | 1531 | */ |
| 1504 | static int | 1532 | static int |
| 1505 | lec_arp_remove(struct lec_priv *priv, | 1533 | lec_arp_remove(struct lec_priv *priv, struct lec_arp_table *to_remove) |
| 1506 | struct lec_arp_table *to_remove) | ||
| 1507 | { | 1534 | { |
| 1508 | unsigned short place; | 1535 | struct hlist_node *node; |
| 1509 | struct lec_arp_table *tmp; | 1536 | struct lec_arp_table *entry; |
| 1510 | int remove_vcc=1; | 1537 | int i, remove_vcc = 1; |
| 1511 | 1538 | ||
| 1512 | if (!to_remove) { | 1539 | if (!to_remove) { |
| 1513 | return -1; | 1540 | return -1; |
| 1514 | } | 1541 | } |
| 1515 | place = HASH(to_remove->mac_addr[ETH_ALEN-1]); | 1542 | |
| 1516 | tmp = priv->lec_arp_tables[place]; | 1543 | hlist_del(&to_remove->next); |
| 1517 | if (tmp == to_remove) { | 1544 | del_timer(&to_remove->timer); |
| 1518 | priv->lec_arp_tables[place] = tmp->next; | 1545 | |
| 1519 | } else { | 1546 | /* If this is the only MAC connected to this VCC, also tear down the VCC */ |
| 1520 | while(tmp && tmp->next != to_remove) { | 1547 | if (to_remove->status >= ESI_FLUSH_PENDING) { |
| 1521 | tmp = tmp->next; | 1548 | /* |
| 1522 | } | 1549 | * ESI_FLUSH_PENDING, ESI_FORWARD_DIRECT |
| 1523 | if (!tmp) {/* Entry was not found */ | 1550 | */ |
| 1524 | return -1; | 1551 | for (i = 0; i < LEC_ARP_TABLE_SIZE; i++) { |
| 1525 | } | 1552 | hlist_for_each_entry(entry, node, &priv->lec_arp_tables[i], next) { |
| 1526 | } | 1553 | if (memcmp(to_remove->atm_addr, |
| 1527 | tmp->next = to_remove->next; | 1554 | entry->atm_addr, ATM_ESA_LEN) == 0) { |
| 1528 | del_timer(&to_remove->timer); | 1555 | remove_vcc = 0; |
| 1529 | 1556 | break; | |
| 1530 | /* If this is the only MAC connected to this VCC, also tear down | 1557 | } |
| 1531 | the VCC */ | 1558 | } |
| 1532 | if (to_remove->status >= ESI_FLUSH_PENDING) { | 1559 | } |
| 1533 | /* | 1560 | if (remove_vcc) |
| 1534 | * ESI_FLUSH_PENDING, ESI_FORWARD_DIRECT | 1561 | lec_arp_clear_vccs(to_remove); |
| 1535 | */ | 1562 | } |
| 1536 | for(place = 0; place < LEC_ARP_TABLE_SIZE; place++) { | 1563 | skb_queue_purge(&to_remove->tx_wait); /* FIXME: good place for this? */ |
| 1537 | for(tmp = priv->lec_arp_tables[place]; tmp != NULL; tmp = tmp->next) { | 1564 | |
| 1538 | if (memcmp(tmp->atm_addr, to_remove->atm_addr, | 1565 | DPRINTK("LEC_ARP: Removed entry:%2.2x %2.2x %2.2x %2.2x %2.2x %2.2x\n", |
| 1539 | ATM_ESA_LEN)==0) { | 1566 | 0xff & to_remove->mac_addr[0], 0xff & to_remove->mac_addr[1], |
| 1540 | remove_vcc=0; | 1567 | 0xff & to_remove->mac_addr[2], 0xff & to_remove->mac_addr[3], |
| 1541 | break; | 1568 | 0xff & to_remove->mac_addr[4], 0xff & to_remove->mac_addr[5]); |
| 1542 | } | 1569 | return 0; |
| 1543 | } | ||
| 1544 | } | ||
| 1545 | if (remove_vcc) | ||
| 1546 | lec_arp_clear_vccs(to_remove); | ||
| 1547 | } | ||
| 1548 | skb_queue_purge(&to_remove->tx_wait); /* FIXME: good place for this? */ | ||
| 1549 | |||
| 1550 | DPRINTK("LEC_ARP: Removed entry:%2.2x %2.2x %2.2x %2.2x %2.2x %2.2x\n", | ||
| 1551 | 0xff&to_remove->mac_addr[0], 0xff&to_remove->mac_addr[1], | ||
| 1552 | 0xff&to_remove->mac_addr[2], 0xff&to_remove->mac_addr[3], | ||
| 1553 | 0xff&to_remove->mac_addr[4], 0xff&to_remove->mac_addr[5]); | ||
| 1554 | return 0; | ||
| 1555 | } | 1570 | } |
| 1556 | 1571 | ||
| 1557 | #if DEBUG_ARP_TABLE | 1572 | #if DEBUG_ARP_TABLE |
| 1558 | static char* | 1573 | static char *get_status_string(unsigned char st) |
| 1559 | get_status_string(unsigned char st) | ||
| 1560 | { | 1574 | { |
| 1561 | switch(st) { | 1575 | switch (st) { |
| 1562 | case ESI_UNKNOWN: | 1576 | case ESI_UNKNOWN: |
| 1563 | return "ESI_UNKNOWN"; | 1577 | return "ESI_UNKNOWN"; |
| 1564 | case ESI_ARP_PENDING: | 1578 | case ESI_ARP_PENDING: |
| 1565 | return "ESI_ARP_PENDING"; | 1579 | return "ESI_ARP_PENDING"; |
| 1566 | case ESI_VC_PENDING: | 1580 | case ESI_VC_PENDING: |
| 1567 | return "ESI_VC_PENDING"; | 1581 | return "ESI_VC_PENDING"; |
| 1568 | case ESI_FLUSH_PENDING: | 1582 | case ESI_FLUSH_PENDING: |
| 1569 | return "ESI_FLUSH_PENDING"; | 1583 | return "ESI_FLUSH_PENDING"; |
| 1570 | case ESI_FORWARD_DIRECT: | 1584 | case ESI_FORWARD_DIRECT: |
| 1571 | return "ESI_FORWARD_DIRECT"; | 1585 | return "ESI_FORWARD_DIRECT"; |
| 1572 | default: | 1586 | default: |
| 1573 | return "<UNKNOWN>"; | 1587 | return "<UNKNOWN>"; |
| 1574 | } | 1588 | } |
| 1575 | } | 1589 | } |
| 1576 | #endif | ||
| 1577 | 1590 | ||
| 1578 | static void | 1591 | static void dump_arp_table(struct lec_priv *priv) |
| 1579 | dump_arp_table(struct lec_priv *priv) | ||
| 1580 | { | 1592 | { |
| 1581 | #if DEBUG_ARP_TABLE | 1593 | struct hlist_node *node; |
| 1582 | int i,j, offset; | 1594 | struct lec_arp_table *rulla; |
| 1583 | struct lec_arp_table *rulla; | 1595 | char buf[256]; |
| 1584 | char buf[1024]; | 1596 | int i, j, offset; |
| 1585 | struct lec_arp_table **lec_arp_tables = | 1597 | |
| 1586 | (struct lec_arp_table **)priv->lec_arp_tables; | 1598 | printk("Dump %p:\n", priv); |
| 1587 | struct lec_arp_table *lec_arp_empty_ones = | 1599 | for (i = 0; i < LEC_ARP_TABLE_SIZE; i++) { |
| 1588 | (struct lec_arp_table *)priv->lec_arp_empty_ones; | 1600 | hlist_for_each_entry(rulla, node, &priv->lec_arp_tables[i], next) { |
| 1589 | struct lec_arp_table *lec_no_forward = | 1601 | offset = 0; |
| 1590 | (struct lec_arp_table *)priv->lec_no_forward; | 1602 | offset += sprintf(buf, "%d: %p\n", i, rulla); |
| 1591 | struct lec_arp_table *mcast_fwds = priv->mcast_fwds; | 1603 | offset += sprintf(buf + offset, "Mac:"); |
| 1592 | 1604 | for (j = 0; j < ETH_ALEN; j++) { | |
| 1593 | 1605 | offset += sprintf(buf + offset, | |
| 1594 | printk("Dump %p:\n",priv); | 1606 | "%2.2x ", |
| 1595 | for (i=0;i<LEC_ARP_TABLE_SIZE;i++) { | 1607 | rulla->mac_addr[j] & 0xff); |
| 1596 | rulla = lec_arp_tables[i]; | 1608 | } |
| 1597 | offset = 0; | 1609 | offset += sprintf(buf + offset, "Atm:"); |
| 1598 | offset += sprintf(buf,"%d: %p\n",i, rulla); | 1610 | for (j = 0; j < ATM_ESA_LEN; j++) { |
| 1599 | while (rulla) { | 1611 | offset += sprintf(buf + offset, |
| 1600 | offset += sprintf(buf+offset,"Mac:"); | 1612 | "%2.2x ", |
| 1601 | for(j=0;j<ETH_ALEN;j++) { | 1613 | rulla->atm_addr[j] & 0xff); |
| 1602 | offset+=sprintf(buf+offset, | 1614 | } |
| 1603 | "%2.2x ", | 1615 | offset += sprintf(buf + offset, |
| 1604 | rulla->mac_addr[j]&0xff); | 1616 | "Vcc vpi:%d vci:%d, Recv_vcc vpi:%d vci:%d Last_used:%lx, Timestamp:%lx, No_tries:%d ", |
| 1605 | } | 1617 | rulla->vcc ? rulla->vcc->vpi : 0, |
| 1606 | offset +=sprintf(buf+offset,"Atm:"); | 1618 | rulla->vcc ? rulla->vcc->vci : 0, |
| 1607 | for(j=0;j<ATM_ESA_LEN;j++) { | 1619 | rulla->recv_vcc ? rulla->recv_vcc-> |
| 1608 | offset+=sprintf(buf+offset, | 1620 | vpi : 0, |
| 1609 | "%2.2x ", | 1621 | rulla->recv_vcc ? rulla->recv_vcc-> |
| 1610 | rulla->atm_addr[j]&0xff); | 1622 | vci : 0, rulla->last_used, |
| 1611 | } | 1623 | rulla->timestamp, rulla->no_tries); |
| 1612 | offset+=sprintf(buf+offset, | 1624 | offset += |
| 1613 | "Vcc vpi:%d vci:%d, Recv_vcc vpi:%d vci:%d Last_used:%lx, Timestamp:%lx, No_tries:%d ", | 1625 | sprintf(buf + offset, |
| 1614 | rulla->vcc?rulla->vcc->vpi:0, | 1626 | "Flags:%x, Packets_flooded:%x, Status: %s ", |
| 1615 | rulla->vcc?rulla->vcc->vci:0, | 1627 | rulla->flags, rulla->packets_flooded, |
| 1616 | rulla->recv_vcc?rulla->recv_vcc->vpi:0, | 1628 | get_status_string(rulla->status)); |
| 1617 | rulla->recv_vcc?rulla->recv_vcc->vci:0, | 1629 | printk("%s\n", buf); |
| 1618 | rulla->last_used, | 1630 | } |
| 1619 | rulla->timestamp, rulla->no_tries); | 1631 | } |
| 1620 | offset+=sprintf(buf+offset, | 1632 | |
| 1621 | "Flags:%x, Packets_flooded:%x, Status: %s ", | 1633 | if (!hlist_empty(&priv->lec_no_forward)) |
| 1622 | rulla->flags, rulla->packets_flooded, | 1634 | printk("No forward\n"); |
| 1623 | get_status_string(rulla->status)); | 1635 | hlist_for_each_entry(rulla, node, &priv->lec_no_forward, next) { |
| 1624 | offset+=sprintf(buf+offset,"->%p\n",rulla->next); | 1636 | offset = 0; |
| 1625 | rulla = rulla->next; | 1637 | offset += sprintf(buf + offset, "Mac:"); |
| 1626 | } | 1638 | for (j = 0; j < ETH_ALEN; j++) { |
| 1627 | printk("%s",buf); | 1639 | offset += sprintf(buf + offset, "%2.2x ", |
| 1628 | } | 1640 | rulla->mac_addr[j] & 0xff); |
| 1629 | rulla = lec_no_forward; | 1641 | } |
| 1630 | if (rulla) | 1642 | offset += sprintf(buf + offset, "Atm:"); |
| 1631 | printk("No forward\n"); | 1643 | for (j = 0; j < ATM_ESA_LEN; j++) { |
| 1632 | while(rulla) { | 1644 | offset += sprintf(buf + offset, "%2.2x ", |
| 1633 | offset=0; | 1645 | rulla->atm_addr[j] & 0xff); |
| 1634 | offset += sprintf(buf+offset,"Mac:"); | 1646 | } |
| 1635 | for(j=0;j<ETH_ALEN;j++) { | 1647 | offset += sprintf(buf + offset, |
| 1636 | offset+=sprintf(buf+offset,"%2.2x ", | 1648 | "Vcc vpi:%d vci:%d, Recv_vcc vpi:%d vci:%d Last_used:%lx, Timestamp:%lx, No_tries:%d ", |
| 1637 | rulla->mac_addr[j]&0xff); | 1649 | rulla->vcc ? rulla->vcc->vpi : 0, |
| 1638 | } | 1650 | rulla->vcc ? rulla->vcc->vci : 0, |
| 1639 | offset +=sprintf(buf+offset,"Atm:"); | 1651 | rulla->recv_vcc ? rulla->recv_vcc->vpi : 0, |
| 1640 | for(j=0;j<ATM_ESA_LEN;j++) { | 1652 | rulla->recv_vcc ? rulla->recv_vcc->vci : 0, |
| 1641 | offset+=sprintf(buf+offset,"%2.2x ", | 1653 | rulla->last_used, |
| 1642 | rulla->atm_addr[j]&0xff); | 1654 | rulla->timestamp, rulla->no_tries); |
| 1643 | } | 1655 | offset += sprintf(buf + offset, |
| 1644 | offset+=sprintf(buf+offset, | 1656 | "Flags:%x, Packets_flooded:%x, Status: %s ", |
| 1645 | "Vcc vpi:%d vci:%d, Recv_vcc vpi:%d vci:%d Last_used:%lx, Timestamp:%lx, No_tries:%d ", | 1657 | rulla->flags, rulla->packets_flooded, |
| 1646 | rulla->vcc?rulla->vcc->vpi:0, | 1658 | get_status_string(rulla->status)); |
| 1647 | rulla->vcc?rulla->vcc->vci:0, | 1659 | printk("%s\n", buf); |
| 1648 | rulla->recv_vcc?rulla->recv_vcc->vpi:0, | 1660 | } |
| 1649 | rulla->recv_vcc?rulla->recv_vcc->vci:0, | 1661 | |
| 1650 | rulla->last_used, | 1662 | if (!hlist_empty(&priv->lec_arp_empty_ones)) |
| 1651 | rulla->timestamp, rulla->no_tries); | 1663 | printk("Empty ones\n"); |
| 1652 | offset+=sprintf(buf+offset, | 1664 | hlist_for_each_entry(rulla, node, &priv->lec_arp_empty_ones, next) { |
| 1653 | "Flags:%x, Packets_flooded:%x, Status: %s ", | 1665 | offset = 0; |
| 1654 | rulla->flags, rulla->packets_flooded, | 1666 | offset += sprintf(buf + offset, "Mac:"); |
| 1655 | get_status_string(rulla->status)); | 1667 | for (j = 0; j < ETH_ALEN; j++) { |
| 1656 | offset+=sprintf(buf+offset,"->%lx\n",(long)rulla->next); | 1668 | offset += sprintf(buf + offset, "%2.2x ", |
| 1657 | rulla = rulla->next; | 1669 | rulla->mac_addr[j] & 0xff); |
| 1658 | printk("%s",buf); | 1670 | } |
| 1659 | } | 1671 | offset += sprintf(buf + offset, "Atm:"); |
| 1660 | rulla = lec_arp_empty_ones; | 1672 | for (j = 0; j < ATM_ESA_LEN; j++) { |
| 1661 | if (rulla) | 1673 | offset += sprintf(buf + offset, "%2.2x ", |
| 1662 | printk("Empty ones\n"); | 1674 | rulla->atm_addr[j] & 0xff); |
| 1663 | while(rulla) { | 1675 | } |
| 1664 | offset=0; | 1676 | offset += sprintf(buf + offset, |
| 1665 | offset += sprintf(buf+offset,"Mac:"); | 1677 | "Vcc vpi:%d vci:%d, Recv_vcc vpi:%d vci:%d Last_used:%lx, Timestamp:%lx, No_tries:%d ", |
| 1666 | for(j=0;j<ETH_ALEN;j++) { | 1678 | rulla->vcc ? rulla->vcc->vpi : 0, |
| 1667 | offset+=sprintf(buf+offset,"%2.2x ", | 1679 | rulla->vcc ? rulla->vcc->vci : 0, |
| 1668 | rulla->mac_addr[j]&0xff); | 1680 | rulla->recv_vcc ? rulla->recv_vcc->vpi : 0, |
| 1669 | } | 1681 | rulla->recv_vcc ? rulla->recv_vcc->vci : 0, |
| 1670 | offset +=sprintf(buf+offset,"Atm:"); | 1682 | rulla->last_used, |
| 1671 | for(j=0;j<ATM_ESA_LEN;j++) { | 1683 | rulla->timestamp, rulla->no_tries); |
| 1672 | offset+=sprintf(buf+offset,"%2.2x ", | 1684 | offset += sprintf(buf + offset, |
| 1673 | rulla->atm_addr[j]&0xff); | 1685 | "Flags:%x, Packets_flooded:%x, Status: %s ", |
| 1674 | } | 1686 | rulla->flags, rulla->packets_flooded, |
| 1675 | offset+=sprintf(buf+offset, | 1687 | get_status_string(rulla->status)); |
| 1676 | "Vcc vpi:%d vci:%d, Recv_vcc vpi:%d vci:%d Last_used:%lx, Timestamp:%lx, No_tries:%d ", | 1688 | printk("%s", buf); |
| 1677 | rulla->vcc?rulla->vcc->vpi:0, | 1689 | } |
| 1678 | rulla->vcc?rulla->vcc->vci:0, | 1690 | |
| 1679 | rulla->recv_vcc?rulla->recv_vcc->vpi:0, | 1691 | if (!hlist_empty(&priv->mcast_fwds)) |
| 1680 | rulla->recv_vcc?rulla->recv_vcc->vci:0, | 1692 | printk("Multicast Forward VCCs\n"); |
| 1681 | rulla->last_used, | 1693 | hlist_for_each_entry(rulla, node, &priv->mcast_fwds, next) { |
| 1682 | rulla->timestamp, rulla->no_tries); | 1694 | offset = 0; |
| 1683 | offset+=sprintf(buf+offset, | 1695 | offset += sprintf(buf + offset, "Mac:"); |
| 1684 | "Flags:%x, Packets_flooded:%x, Status: %s ", | 1696 | for (j = 0; j < ETH_ALEN; j++) { |
| 1685 | rulla->flags, rulla->packets_flooded, | 1697 | offset += sprintf(buf + offset, "%2.2x ", |
| 1686 | get_status_string(rulla->status)); | 1698 | rulla->mac_addr[j] & 0xff); |
| 1687 | offset+=sprintf(buf+offset,"->%lx\n",(long)rulla->next); | 1699 | } |
| 1688 | rulla = rulla->next; | 1700 | offset += sprintf(buf + offset, "Atm:"); |
| 1689 | printk("%s",buf); | 1701 | for (j = 0; j < ATM_ESA_LEN; j++) { |
| 1690 | } | 1702 | offset += sprintf(buf + offset, "%2.2x ", |
| 1691 | 1703 | rulla->atm_addr[j] & 0xff); | |
| 1692 | rulla = mcast_fwds; | 1704 | } |
| 1693 | if (rulla) | 1705 | offset += sprintf(buf + offset, |
| 1694 | printk("Multicast Forward VCCs\n"); | 1706 | "Vcc vpi:%d vci:%d, Recv_vcc vpi:%d vci:%d Last_used:%lx, Timestamp:%lx, No_tries:%d ", |
| 1695 | while(rulla) { | 1707 | rulla->vcc ? rulla->vcc->vpi : 0, |
| 1696 | offset=0; | 1708 | rulla->vcc ? rulla->vcc->vci : 0, |
| 1697 | offset += sprintf(buf+offset,"Mac:"); | 1709 | rulla->recv_vcc ? rulla->recv_vcc->vpi : 0, |
| 1698 | for(j=0;j<ETH_ALEN;j++) { | 1710 | rulla->recv_vcc ? rulla->recv_vcc->vci : 0, |
| 1699 | offset+=sprintf(buf+offset,"%2.2x ", | 1711 | rulla->last_used, |
| 1700 | rulla->mac_addr[j]&0xff); | 1712 | rulla->timestamp, rulla->no_tries); |
| 1701 | } | 1713 | offset += sprintf(buf + offset, |
| 1702 | offset +=sprintf(buf+offset,"Atm:"); | 1714 | "Flags:%x, Packets_flooded:%x, Status: %s ", |
| 1703 | for(j=0;j<ATM_ESA_LEN;j++) { | 1715 | rulla->flags, rulla->packets_flooded, |
| 1704 | offset+=sprintf(buf+offset,"%2.2x ", | 1716 | get_status_string(rulla->status)); |
| 1705 | rulla->atm_addr[j]&0xff); | 1717 | printk("%s\n", buf); |
| 1706 | } | 1718 | } |
| 1707 | offset+=sprintf(buf+offset, | ||
| 1708 | "Vcc vpi:%d vci:%d, Recv_vcc vpi:%d vci:%d Last_used:%lx, Timestamp:%lx, No_tries:%d ", | ||
| 1709 | rulla->vcc?rulla->vcc->vpi:0, | ||
| 1710 | rulla->vcc?rulla->vcc->vci:0, | ||
| 1711 | rulla->recv_vcc?rulla->recv_vcc->vpi:0, | ||
| 1712 | rulla->recv_vcc?rulla->recv_vcc->vci:0, | ||
| 1713 | rulla->last_used, | ||
| 1714 | rulla->timestamp, rulla->no_tries); | ||
| 1715 | offset+=sprintf(buf+offset, | ||
| 1716 | "Flags:%x, Packets_flooded:%x, Status: %s ", | ||
| 1717 | rulla->flags, rulla->packets_flooded, | ||
| 1718 | get_status_string(rulla->status)); | ||
| 1719 | offset+=sprintf(buf+offset,"->%lx\n",(long)rulla->next); | ||
| 1720 | rulla = rulla->next; | ||
| 1721 | printk("%s",buf); | ||
| 1722 | } | ||
| 1723 | 1719 | ||
| 1724 | #endif | ||
| 1725 | } | 1720 | } |
| 1721 | #else | ||
| 1722 | #define dump_arp_table(priv) do { } while (0) | ||
| 1723 | #endif | ||
| 1726 | 1724 | ||
| 1727 | /* | 1725 | /* |
| 1728 | * Destruction of arp-cache | 1726 | * Destruction of arp-cache |
| 1729 | */ | 1727 | */ |
| 1730 | static void | 1728 | static void lec_arp_destroy(struct lec_priv *priv) |
| 1731 | lec_arp_destroy(struct lec_priv *priv) | ||
| 1732 | { | 1729 | { |
| 1733 | unsigned long flags; | 1730 | unsigned long flags; |
| 1734 | struct lec_arp_table *entry, *next; | 1731 | struct hlist_node *node, *next; |
| 1735 | int i; | 1732 | struct lec_arp_table *entry; |
| 1733 | int i; | ||
| 1734 | |||
| 1735 | cancel_rearming_delayed_work(&priv->lec_arp_work); | ||
| 1736 | 1736 | ||
| 1737 | del_timer_sync(&priv->lec_arp_timer); | 1737 | /* |
| 1738 | 1738 | * Remove all entries | |
| 1739 | /* | 1739 | */ |
| 1740 | * Remove all entries | ||
| 1741 | */ | ||
| 1742 | 1740 | ||
| 1743 | spin_lock_irqsave(&priv->lec_arp_lock, flags); | 1741 | spin_lock_irqsave(&priv->lec_arp_lock, flags); |
| 1744 | for (i = 0; i < LEC_ARP_TABLE_SIZE; i++) { | 1742 | for (i = 0; i < LEC_ARP_TABLE_SIZE; i++) { |
| 1745 | for(entry = priv->lec_arp_tables[i]; entry != NULL; entry=next) { | 1743 | hlist_for_each_entry_safe(entry, node, next, &priv->lec_arp_tables[i], next) { |
| 1746 | next = entry->next; | 1744 | lec_arp_remove(priv, entry); |
| 1747 | lec_arp_remove(priv, entry); | 1745 | lec_arp_put(entry); |
| 1748 | kfree(entry); | 1746 | } |
| 1749 | } | 1747 | INIT_HLIST_HEAD(&priv->lec_arp_tables[i]); |
| 1750 | } | 1748 | } |
| 1751 | entry = priv->lec_arp_empty_ones; | 1749 | |
| 1752 | while(entry) { | 1750 | hlist_for_each_entry_safe(entry, node, next, &priv->lec_arp_empty_ones, next) { |
| 1753 | next = entry->next; | 1751 | del_timer_sync(&entry->timer); |
| 1754 | del_timer_sync(&entry->timer); | 1752 | lec_arp_clear_vccs(entry); |
| 1755 | lec_arp_clear_vccs(entry); | 1753 | hlist_del(&entry->next); |
| 1756 | kfree(entry); | 1754 | lec_arp_put(entry); |
| 1757 | entry = next; | 1755 | } |
| 1758 | } | 1756 | INIT_HLIST_HEAD(&priv->lec_arp_empty_ones); |
| 1759 | priv->lec_arp_empty_ones = NULL; | 1757 | |
| 1760 | entry = priv->lec_no_forward; | 1758 | hlist_for_each_entry_safe(entry, node, next, &priv->lec_no_forward, next) { |
| 1761 | while(entry) { | 1759 | del_timer_sync(&entry->timer); |
| 1762 | next = entry->next; | 1760 | lec_arp_clear_vccs(entry); |
| 1763 | del_timer_sync(&entry->timer); | 1761 | hlist_del(&entry->next); |
| 1764 | lec_arp_clear_vccs(entry); | 1762 | lec_arp_put(entry); |
| 1765 | kfree(entry); | 1763 | } |
| 1766 | entry = next; | 1764 | INIT_HLIST_HEAD(&priv->lec_no_forward); |
| 1767 | } | 1765 | |
| 1768 | priv->lec_no_forward = NULL; | 1766 | hlist_for_each_entry_safe(entry, node, next, &priv->mcast_fwds, next) { |
| 1769 | entry = priv->mcast_fwds; | 1767 | /* No timer, LANEv2 7.1.20 and 2.3.5.3 */ |
| 1770 | while(entry) { | 1768 | lec_arp_clear_vccs(entry); |
| 1771 | next = entry->next; | 1769 | hlist_del(&entry->next); |
| 1772 | /* No timer, LANEv2 7.1.20 and 2.3.5.3 */ | 1770 | lec_arp_put(entry); |
| 1773 | lec_arp_clear_vccs(entry); | 1771 | } |
| 1774 | kfree(entry); | 1772 | INIT_HLIST_HEAD(&priv->mcast_fwds); |
| 1775 | entry = next; | 1773 | priv->mcast_vcc = NULL; |
| 1776 | } | ||
| 1777 | priv->mcast_fwds = NULL; | ||
| 1778 | priv->mcast_vcc = NULL; | ||
| 1779 | memset(priv->lec_arp_tables, 0, | ||
| 1780 | sizeof(struct lec_arp_table *) * LEC_ARP_TABLE_SIZE); | ||
| 1781 | spin_unlock_irqrestore(&priv->lec_arp_lock, flags); | 1774 | spin_unlock_irqrestore(&priv->lec_arp_lock, flags); |
| 1782 | } | 1775 | } |
| 1783 | 1776 | ||
| 1784 | |||
| 1785 | /* | 1777 | /* |
| 1786 | * Find entry by mac_address | 1778 | * Find entry by mac_address |
| 1787 | */ | 1779 | */ |
| 1788 | static struct lec_arp_table* | 1780 | static struct lec_arp_table *lec_arp_find(struct lec_priv *priv, |
| 1789 | lec_arp_find(struct lec_priv *priv, | 1781 | unsigned char *mac_addr) |
| 1790 | unsigned char *mac_addr) | ||
| 1791 | { | 1782 | { |
| 1792 | unsigned short place; | 1783 | struct hlist_node *node; |
| 1793 | struct lec_arp_table *to_return; | 1784 | struct hlist_head *head; |
| 1794 | 1785 | struct lec_arp_table *entry; | |
| 1795 | DPRINTK("LEC_ARP: lec_arp_find :%2.2x %2.2x %2.2x %2.2x %2.2x %2.2x\n", | 1786 | |
| 1796 | mac_addr[0]&0xff, mac_addr[1]&0xff, mac_addr[2]&0xff, | 1787 | DPRINTK("LEC_ARP: lec_arp_find :%2.2x %2.2x %2.2x %2.2x %2.2x %2.2x\n", |
| 1797 | mac_addr[3]&0xff, mac_addr[4]&0xff, mac_addr[5]&0xff); | 1788 | mac_addr[0] & 0xff, mac_addr[1] & 0xff, mac_addr[2] & 0xff, |
| 1798 | place = HASH(mac_addr[ETH_ALEN-1]); | 1789 | mac_addr[3] & 0xff, mac_addr[4] & 0xff, mac_addr[5] & 0xff); |
| 1799 | 1790 | ||
| 1800 | to_return = priv->lec_arp_tables[place]; | 1791 | head = &priv->lec_arp_tables[HASH(mac_addr[ETH_ALEN - 1])]; |
| 1801 | while(to_return) { | 1792 | hlist_for_each_entry(entry, node, head, next) { |
| 1802 | if (!compare_ether_addr(mac_addr, to_return->mac_addr)) { | 1793 | if (!compare_ether_addr(mac_addr, entry->mac_addr)) { |
| 1803 | return to_return; | 1794 | return entry; |
| 1804 | } | 1795 | } |
| 1805 | to_return = to_return->next; | 1796 | } |
| 1806 | } | 1797 | return NULL; |
| 1807 | return NULL; | ||
| 1808 | } | 1798 | } |
| 1809 | 1799 | ||
| 1810 | static struct lec_arp_table* | 1800 | static struct lec_arp_table *make_entry(struct lec_priv *priv, |
| 1811 | make_entry(struct lec_priv *priv, unsigned char *mac_addr) | 1801 | unsigned char *mac_addr) |
| 1812 | { | 1802 | { |
| 1813 | struct lec_arp_table *to_return; | 1803 | struct lec_arp_table *to_return; |
| 1814 | 1804 | ||
| 1815 | to_return = kmalloc(sizeof(struct lec_arp_table), GFP_ATOMIC); | 1805 | to_return = kzalloc(sizeof(struct lec_arp_table), GFP_ATOMIC); |
| 1816 | if (!to_return) { | 1806 | if (!to_return) { |
| 1817 | printk("LEC: Arp entry kmalloc failed\n"); | 1807 | printk("LEC: Arp entry kmalloc failed\n"); |
| 1818 | return NULL; | 1808 | return NULL; |
| 1819 | } | 1809 | } |
| 1820 | memset(to_return, 0, sizeof(struct lec_arp_table)); | 1810 | memcpy(to_return->mac_addr, mac_addr, ETH_ALEN); |
| 1821 | memcpy(to_return->mac_addr, mac_addr, ETH_ALEN); | 1811 | INIT_HLIST_NODE(&to_return->next); |
| 1822 | init_timer(&to_return->timer); | 1812 | init_timer(&to_return->timer); |
| 1823 | to_return->timer.function = lec_arp_expire_arp; | 1813 | to_return->timer.function = lec_arp_expire_arp; |
| 1824 | to_return->timer.data = (unsigned long) to_return; | 1814 | to_return->timer.data = (unsigned long)to_return; |
| 1825 | to_return->last_used = jiffies; | 1815 | to_return->last_used = jiffies; |
| 1826 | to_return->priv = priv; | 1816 | to_return->priv = priv; |
| 1827 | skb_queue_head_init(&to_return->tx_wait); | 1817 | skb_queue_head_init(&to_return->tx_wait); |
| 1828 | return to_return; | 1818 | atomic_set(&to_return->usage, 1); |
| 1819 | return to_return; | ||
| 1829 | } | 1820 | } |
| 1830 | 1821 | ||
| 1831 | /* | 1822 | /* Arp sent timer expired */ |
| 1832 | * | 1823 | static void lec_arp_expire_arp(unsigned long data) |
| 1833 | * Arp sent timer expired | ||
| 1834 | * | ||
| 1835 | */ | ||
| 1836 | static void | ||
| 1837 | lec_arp_expire_arp(unsigned long data) | ||
| 1838 | { | 1824 | { |
| 1839 | struct lec_arp_table *entry; | 1825 | struct lec_arp_table *entry; |
| 1840 | 1826 | ||
| 1841 | entry = (struct lec_arp_table *)data; | 1827 | entry = (struct lec_arp_table *)data; |
| 1842 | 1828 | ||
| 1843 | DPRINTK("lec_arp_expire_arp\n"); | 1829 | DPRINTK("lec_arp_expire_arp\n"); |
| 1844 | if (entry->status == ESI_ARP_PENDING) { | 1830 | if (entry->status == ESI_ARP_PENDING) { |
| 1845 | if (entry->no_tries <= entry->priv->max_retry_count) { | 1831 | if (entry->no_tries <= entry->priv->max_retry_count) { |
| 1846 | if (entry->is_rdesc) | 1832 | if (entry->is_rdesc) |
| 1847 | send_to_lecd(entry->priv, l_rdesc_arp_xmt, entry->mac_addr, NULL, NULL); | 1833 | send_to_lecd(entry->priv, l_rdesc_arp_xmt, |
| 1848 | else | 1834 | entry->mac_addr, NULL, NULL); |
| 1849 | send_to_lecd(entry->priv, l_arp_xmt, entry->mac_addr, NULL, NULL); | 1835 | else |
| 1850 | entry->no_tries++; | 1836 | send_to_lecd(entry->priv, l_arp_xmt, |
| 1851 | } | 1837 | entry->mac_addr, NULL, NULL); |
| 1852 | mod_timer(&entry->timer, jiffies + (1*HZ)); | 1838 | entry->no_tries++; |
| 1853 | } | 1839 | } |
| 1840 | mod_timer(&entry->timer, jiffies + (1 * HZ)); | ||
| 1841 | } | ||
| 1854 | } | 1842 | } |
| 1855 | 1843 | ||
| 1856 | /* | 1844 | /* Unknown/unused vcc expire, remove associated entry */ |
| 1857 | * | 1845 | static void lec_arp_expire_vcc(unsigned long data) |
| 1858 | * Unknown/unused vcc expire, remove associated entry | ||
| 1859 | * | ||
| 1860 | */ | ||
| 1861 | static void | ||
| 1862 | lec_arp_expire_vcc(unsigned long data) | ||
| 1863 | { | 1846 | { |
| 1864 | unsigned long flags; | 1847 | unsigned long flags; |
| 1865 | struct lec_arp_table *to_remove = (struct lec_arp_table*)data; | 1848 | struct lec_arp_table *to_remove = (struct lec_arp_table *)data; |
| 1866 | struct lec_priv *priv = (struct lec_priv *)to_remove->priv; | 1849 | struct lec_priv *priv = (struct lec_priv *)to_remove->priv; |
| 1867 | struct lec_arp_table *entry = NULL; | ||
| 1868 | 1850 | ||
| 1869 | del_timer(&to_remove->timer); | 1851 | del_timer(&to_remove->timer); |
| 1870 | 1852 | ||
| 1871 | DPRINTK("LEC_ARP %p %p: lec_arp_expire_vcc vpi:%d vci:%d\n", | 1853 | DPRINTK("LEC_ARP %p %p: lec_arp_expire_vcc vpi:%d vci:%d\n", |
| 1872 | to_remove, priv, | 1854 | to_remove, priv, |
| 1873 | to_remove->vcc?to_remove->recv_vcc->vpi:0, | 1855 | to_remove->vcc ? to_remove->recv_vcc->vpi : 0, |
| 1874 | to_remove->vcc?to_remove->recv_vcc->vci:0); | 1856 | to_remove->vcc ? to_remove->recv_vcc->vci : 0); |
| 1875 | DPRINTK("eo:%p nf:%p\n",priv->lec_arp_empty_ones,priv->lec_no_forward); | ||
| 1876 | 1857 | ||
| 1877 | spin_lock_irqsave(&priv->lec_arp_lock, flags); | 1858 | spin_lock_irqsave(&priv->lec_arp_lock, flags); |
| 1878 | if (to_remove == priv->lec_arp_empty_ones) | 1859 | hlist_del(&to_remove->next); |
| 1879 | priv->lec_arp_empty_ones = to_remove->next; | ||
| 1880 | else { | ||
| 1881 | entry = priv->lec_arp_empty_ones; | ||
| 1882 | while (entry && entry->next != to_remove) | ||
| 1883 | entry = entry->next; | ||
| 1884 | if (entry) | ||
| 1885 | entry->next = to_remove->next; | ||
| 1886 | } | ||
| 1887 | if (!entry) { | ||
| 1888 | if (to_remove == priv->lec_no_forward) { | ||
| 1889 | priv->lec_no_forward = to_remove->next; | ||
| 1890 | } else { | ||
| 1891 | entry = priv->lec_no_forward; | ||
| 1892 | while (entry && entry->next != to_remove) | ||
| 1893 | entry = entry->next; | ||
| 1894 | if (entry) | ||
| 1895 | entry->next = to_remove->next; | ||
| 1896 | } | ||
| 1897 | } | ||
| 1898 | spin_unlock_irqrestore(&priv->lec_arp_lock, flags); | 1860 | spin_unlock_irqrestore(&priv->lec_arp_lock, flags); |
| 1899 | 1861 | ||
| 1900 | lec_arp_clear_vccs(to_remove); | 1862 | lec_arp_clear_vccs(to_remove); |
| 1901 | kfree(to_remove); | 1863 | lec_arp_put(to_remove); |
| 1902 | } | 1864 | } |
| 1903 | 1865 | ||
| 1904 | /* | 1866 | /* |
| @@ -1917,158 +1879,171 @@ lec_arp_expire_vcc(unsigned long data) | |||
| 1917 | * to ESI_FORWARD_DIRECT. This causes the flush period to end | 1879 | * to ESI_FORWARD_DIRECT. This causes the flush period to end |
| 1918 | * regardless of the progress of the flush protocol. | 1880 | * regardless of the progress of the flush protocol. |
| 1919 | */ | 1881 | */ |
| 1920 | static void | 1882 | static void lec_arp_check_expire(void *data) |
| 1921 | lec_arp_check_expire(unsigned long data) | ||
| 1922 | { | 1883 | { |
| 1923 | unsigned long flags; | 1884 | unsigned long flags; |
| 1924 | struct lec_priv *priv = (struct lec_priv *)data; | 1885 | struct lec_priv *priv = data; |
| 1925 | struct lec_arp_table *entry, *next; | 1886 | struct hlist_node *node, *next; |
| 1926 | unsigned long now; | 1887 | struct lec_arp_table *entry; |
| 1927 | unsigned long time_to_check; | 1888 | unsigned long now; |
| 1928 | int i; | 1889 | unsigned long time_to_check; |
| 1929 | 1890 | int i; | |
| 1930 | DPRINTK("lec_arp_check_expire %p\n",priv); | 1891 | |
| 1931 | DPRINTK("expire: eo:%p nf:%p\n",priv->lec_arp_empty_ones, | 1892 | DPRINTK("lec_arp_check_expire %p\n", priv); |
| 1932 | priv->lec_no_forward); | ||
| 1933 | now = jiffies; | 1893 | now = jiffies; |
| 1894 | restart: | ||
| 1934 | spin_lock_irqsave(&priv->lec_arp_lock, flags); | 1895 | spin_lock_irqsave(&priv->lec_arp_lock, flags); |
| 1935 | for(i = 0; i < LEC_ARP_TABLE_SIZE; i++) { | 1896 | for (i = 0; i < LEC_ARP_TABLE_SIZE; i++) { |
| 1936 | for(entry = priv->lec_arp_tables[i]; entry != NULL; ) { | 1897 | hlist_for_each_entry_safe(entry, node, next, &priv->lec_arp_tables[i], next) { |
| 1937 | if ((entry->flags) & LEC_REMOTE_FLAG && | 1898 | if ((entry->flags) & LEC_REMOTE_FLAG && |
| 1938 | priv->topology_change) | 1899 | priv->topology_change) |
| 1939 | time_to_check = priv->forward_delay_time; | 1900 | time_to_check = priv->forward_delay_time; |
| 1940 | else | 1901 | else |
| 1941 | time_to_check = priv->aging_time; | 1902 | time_to_check = priv->aging_time; |
| 1942 | 1903 | ||
| 1943 | DPRINTK("About to expire: %lx - %lx > %lx\n", | 1904 | DPRINTK("About to expire: %lx - %lx > %lx\n", |
| 1944 | now,entry->last_used, time_to_check); | 1905 | now, entry->last_used, time_to_check); |
| 1945 | if( time_after(now, entry->last_used+ | 1906 | if (time_after(now, entry->last_used + time_to_check) |
| 1946 | time_to_check) && | 1907 | && !(entry->flags & LEC_PERMANENT_FLAG) |
| 1947 | !(entry->flags & LEC_PERMANENT_FLAG) && | 1908 | && !(entry->mac_addr[0] & 0x01)) { /* LANE2: 7.1.20 */ |
| 1948 | !(entry->mac_addr[0] & 0x01) ) { /* LANE2: 7.1.20 */ | ||
| 1949 | /* Remove entry */ | 1909 | /* Remove entry */ |
| 1950 | DPRINTK("LEC:Entry timed out\n"); | 1910 | DPRINTK("LEC:Entry timed out\n"); |
| 1951 | next = entry->next; | ||
| 1952 | lec_arp_remove(priv, entry); | 1911 | lec_arp_remove(priv, entry); |
| 1953 | kfree(entry); | 1912 | lec_arp_put(entry); |
| 1954 | entry = next; | ||
| 1955 | } else { | 1913 | } else { |
| 1956 | /* Something else */ | 1914 | /* Something else */ |
| 1957 | if ((entry->status == ESI_VC_PENDING || | 1915 | if ((entry->status == ESI_VC_PENDING || |
| 1958 | entry->status == ESI_ARP_PENDING) | 1916 | entry->status == ESI_ARP_PENDING) |
| 1959 | && time_after_eq(now, | 1917 | && time_after_eq(now, |
| 1960 | entry->timestamp + | 1918 | entry->timestamp + |
| 1961 | priv->max_unknown_frame_time)) { | 1919 | priv-> |
| 1920 | max_unknown_frame_time)) { | ||
| 1962 | entry->timestamp = jiffies; | 1921 | entry->timestamp = jiffies; |
| 1963 | entry->packets_flooded = 0; | 1922 | entry->packets_flooded = 0; |
| 1964 | if (entry->status == ESI_VC_PENDING) | 1923 | if (entry->status == ESI_VC_PENDING) |
| 1965 | send_to_lecd(priv, l_svc_setup, entry->mac_addr, entry->atm_addr, NULL); | 1924 | send_to_lecd(priv, l_svc_setup, |
| 1925 | entry->mac_addr, | ||
| 1926 | entry->atm_addr, | ||
| 1927 | NULL); | ||
| 1966 | } | 1928 | } |
| 1967 | if (entry->status == ESI_FLUSH_PENDING | 1929 | if (entry->status == ESI_FLUSH_PENDING |
| 1968 | && | 1930 | && |
| 1969 | time_after_eq(now, entry->timestamp+ | 1931 | time_after_eq(now, entry->timestamp + |
| 1970 | priv->path_switching_delay)) { | 1932 | priv->path_switching_delay)) { |
| 1971 | struct sk_buff *skb; | 1933 | struct sk_buff *skb; |
| 1934 | struct atm_vcc *vcc = entry->vcc; | ||
| 1972 | 1935 | ||
| 1936 | lec_arp_hold(entry); | ||
| 1937 | spin_unlock_irqrestore(&priv->lec_arp_lock, flags); | ||
| 1973 | while ((skb = skb_dequeue(&entry->tx_wait)) != NULL) | 1938 | while ((skb = skb_dequeue(&entry->tx_wait)) != NULL) |
| 1974 | lec_send(entry->vcc, skb, entry->priv); | 1939 | lec_send(vcc, skb, entry->priv); |
| 1975 | entry->last_used = jiffies; | 1940 | entry->last_used = jiffies; |
| 1976 | entry->status = | 1941 | entry->status = ESI_FORWARD_DIRECT; |
| 1977 | ESI_FORWARD_DIRECT; | 1942 | lec_arp_put(entry); |
| 1943 | goto restart; | ||
| 1978 | } | 1944 | } |
| 1979 | entry = entry->next; | ||
| 1980 | } | 1945 | } |
| 1981 | } | 1946 | } |
| 1982 | } | 1947 | } |
| 1983 | spin_unlock_irqrestore(&priv->lec_arp_lock, flags); | 1948 | spin_unlock_irqrestore(&priv->lec_arp_lock, flags); |
| 1984 | 1949 | ||
| 1985 | mod_timer(&priv->lec_arp_timer, jiffies + LEC_ARP_REFRESH_INTERVAL); | 1950 | schedule_delayed_work(&priv->lec_arp_work, LEC_ARP_REFRESH_INTERVAL); |
| 1986 | } | 1951 | } |
| 1952 | |||
| 1987 | /* | 1953 | /* |
| 1988 | * Try to find vcc where mac_address is attached. | 1954 | * Try to find vcc where mac_address is attached. |
| 1989 | * | 1955 | * |
| 1990 | */ | 1956 | */ |
| 1991 | static struct atm_vcc* | 1957 | static struct atm_vcc *lec_arp_resolve(struct lec_priv *priv, |
| 1992 | lec_arp_resolve(struct lec_priv *priv, unsigned char *mac_to_find, | 1958 | unsigned char *mac_to_find, int is_rdesc, |
| 1993 | int is_rdesc, struct lec_arp_table **ret_entry) | 1959 | struct lec_arp_table **ret_entry) |
| 1994 | { | 1960 | { |
| 1995 | unsigned long flags; | 1961 | unsigned long flags; |
| 1996 | struct lec_arp_table *entry; | 1962 | struct lec_arp_table *entry; |
| 1997 | struct atm_vcc *found; | 1963 | struct atm_vcc *found; |
| 1998 | 1964 | ||
| 1999 | if (mac_to_find[0] & 0x01) { | 1965 | if (mac_to_find[0] & 0x01) { |
| 2000 | switch (priv->lane_version) { | 1966 | switch (priv->lane_version) { |
| 2001 | case 1: | 1967 | case 1: |
| 2002 | return priv->mcast_vcc; | 1968 | return priv->mcast_vcc; |
| 2003 | break; | 1969 | break; |
| 2004 | case 2: /* LANE2 wants arp for multicast addresses */ | 1970 | case 2: /* LANE2 wants arp for multicast addresses */ |
| 2005 | if (!compare_ether_addr(mac_to_find, bus_mac)) | 1971 | if (!compare_ether_addr(mac_to_find, bus_mac)) |
| 2006 | return priv->mcast_vcc; | 1972 | return priv->mcast_vcc; |
| 2007 | break; | 1973 | break; |
| 2008 | default: | 1974 | default: |
| 2009 | break; | 1975 | break; |
| 2010 | } | 1976 | } |
| 2011 | } | 1977 | } |
| 2012 | 1978 | ||
| 2013 | spin_lock_irqsave(&priv->lec_arp_lock, flags); | 1979 | spin_lock_irqsave(&priv->lec_arp_lock, flags); |
| 2014 | entry = lec_arp_find(priv, mac_to_find); | 1980 | entry = lec_arp_find(priv, mac_to_find); |
| 2015 | 1981 | ||
| 2016 | if (entry) { | 1982 | if (entry) { |
| 2017 | if (entry->status == ESI_FORWARD_DIRECT) { | 1983 | if (entry->status == ESI_FORWARD_DIRECT) { |
| 2018 | /* Connection Ok */ | 1984 | /* Connection Ok */ |
| 2019 | entry->last_used = jiffies; | 1985 | entry->last_used = jiffies; |
| 2020 | *ret_entry = entry; | 1986 | lec_arp_hold(entry); |
| 2021 | found = entry->vcc; | 1987 | *ret_entry = entry; |
| 1988 | found = entry->vcc; | ||
| 2022 | goto out; | 1989 | goto out; |
| 2023 | } | 1990 | } |
| 2024 | /* If the LE_ARP cache entry is still pending, reset count to 0 | 1991 | /* |
| 1992 | * If the LE_ARP cache entry is still pending, reset count to 0 | ||
| 2025 | * so another LE_ARP request can be made for this frame. | 1993 | * so another LE_ARP request can be made for this frame. |
| 2026 | */ | 1994 | */ |
| 2027 | if (entry->status == ESI_ARP_PENDING) { | 1995 | if (entry->status == ESI_ARP_PENDING) { |
| 2028 | entry->no_tries = 0; | 1996 | entry->no_tries = 0; |
| 2029 | } | 1997 | } |
| 2030 | /* Data direct VC not yet set up, check to see if the unknown | 1998 | /* |
| 2031 | frame count is greater than the limit. If the limit has | 1999 | * Data direct VC not yet set up, check to see if the unknown |
| 2032 | not been reached, allow the caller to send packet to | 2000 | * frame count is greater than the limit. If the limit has |
| 2033 | BUS. */ | 2001 | * not been reached, allow the caller to send packet to |
| 2034 | if (entry->status != ESI_FLUSH_PENDING && | 2002 | * BUS. |
| 2035 | entry->packets_flooded<priv->maximum_unknown_frame_count) { | 2003 | */ |
| 2036 | entry->packets_flooded++; | 2004 | if (entry->status != ESI_FLUSH_PENDING && |
| 2037 | DPRINTK("LEC_ARP: Flooding..\n"); | 2005 | entry->packets_flooded < |
| 2038 | found = priv->mcast_vcc; | 2006 | priv->maximum_unknown_frame_count) { |
| 2007 | entry->packets_flooded++; | ||
| 2008 | DPRINTK("LEC_ARP: Flooding..\n"); | ||
| 2009 | found = priv->mcast_vcc; | ||
| 2039 | goto out; | 2010 | goto out; |
| 2040 | } | 2011 | } |
| 2041 | /* We got here because entry->status == ESI_FLUSH_PENDING | 2012 | /* |
| 2013 | * We got here because entry->status == ESI_FLUSH_PENDING | ||
| 2042 | * or BUS flood limit was reached for an entry which is | 2014 | * or BUS flood limit was reached for an entry which is |
| 2043 | * in ESI_ARP_PENDING or ESI_VC_PENDING state. | 2015 | * in ESI_ARP_PENDING or ESI_VC_PENDING state. |
| 2044 | */ | 2016 | */ |
| 2045 | *ret_entry = entry; | 2017 | lec_arp_hold(entry); |
| 2046 | DPRINTK("lec: entry->status %d entry->vcc %p\n", entry->status, entry->vcc); | 2018 | *ret_entry = entry; |
| 2047 | found = NULL; | 2019 | DPRINTK("lec: entry->status %d entry->vcc %p\n", entry->status, |
| 2048 | } else { | 2020 | entry->vcc); |
| 2049 | /* No matching entry was found */ | 2021 | found = NULL; |
| 2050 | entry = make_entry(priv, mac_to_find); | 2022 | } else { |
| 2051 | DPRINTK("LEC_ARP: Making entry\n"); | 2023 | /* No matching entry was found */ |
| 2052 | if (!entry) { | 2024 | entry = make_entry(priv, mac_to_find); |
| 2053 | found = priv->mcast_vcc; | 2025 | DPRINTK("LEC_ARP: Making entry\n"); |
| 2026 | if (!entry) { | ||
| 2027 | found = priv->mcast_vcc; | ||
| 2054 | goto out; | 2028 | goto out; |
| 2055 | } | 2029 | } |
| 2056 | lec_arp_add(priv, entry); | 2030 | lec_arp_add(priv, entry); |
| 2057 | /* We want arp-request(s) to be sent */ | 2031 | /* We want arp-request(s) to be sent */ |
| 2058 | entry->packets_flooded =1; | 2032 | entry->packets_flooded = 1; |
| 2059 | entry->status = ESI_ARP_PENDING; | 2033 | entry->status = ESI_ARP_PENDING; |
| 2060 | entry->no_tries = 1; | 2034 | entry->no_tries = 1; |
| 2061 | entry->last_used = entry->timestamp = jiffies; | 2035 | entry->last_used = entry->timestamp = jiffies; |
| 2062 | entry->is_rdesc = is_rdesc; | 2036 | entry->is_rdesc = is_rdesc; |
| 2063 | if (entry->is_rdesc) | 2037 | if (entry->is_rdesc) |
| 2064 | send_to_lecd(priv, l_rdesc_arp_xmt, mac_to_find, NULL, NULL); | 2038 | send_to_lecd(priv, l_rdesc_arp_xmt, mac_to_find, NULL, |
| 2065 | else | 2039 | NULL); |
| 2066 | send_to_lecd(priv, l_arp_xmt, mac_to_find, NULL, NULL); | 2040 | else |
| 2067 | entry->timer.expires = jiffies + (1*HZ); | 2041 | send_to_lecd(priv, l_arp_xmt, mac_to_find, NULL, NULL); |
| 2068 | entry->timer.function = lec_arp_expire_arp; | 2042 | entry->timer.expires = jiffies + (1 * HZ); |
| 2069 | add_timer(&entry->timer); | 2043 | entry->timer.function = lec_arp_expire_arp; |
| 2070 | found = priv->mcast_vcc; | 2044 | add_timer(&entry->timer); |
| 2071 | } | 2045 | found = priv->mcast_vcc; |
| 2046 | } | ||
| 2072 | 2047 | ||
| 2073 | out: | 2048 | out: |
| 2074 | spin_unlock_irqrestore(&priv->lec_arp_lock, flags); | 2049 | spin_unlock_irqrestore(&priv->lec_arp_lock, flags); |
| @@ -2076,30 +2051,30 @@ out: | |||
| 2076 | } | 2051 | } |
| 2077 | 2052 | ||
| 2078 | static int | 2053 | static int |
| 2079 | lec_addr_delete(struct lec_priv *priv, unsigned char *atm_addr, | 2054 | lec_addr_delete(struct lec_priv *priv, unsigned char *atm_addr, |
| 2080 | unsigned long permanent) | 2055 | unsigned long permanent) |
| 2081 | { | 2056 | { |
| 2082 | unsigned long flags; | 2057 | unsigned long flags; |
| 2083 | struct lec_arp_table *entry, *next; | 2058 | struct hlist_node *node, *next; |
| 2084 | int i; | 2059 | struct lec_arp_table *entry; |
| 2060 | int i; | ||
| 2085 | 2061 | ||
| 2086 | DPRINTK("lec_addr_delete\n"); | 2062 | DPRINTK("lec_addr_delete\n"); |
| 2087 | spin_lock_irqsave(&priv->lec_arp_lock, flags); | 2063 | spin_lock_irqsave(&priv->lec_arp_lock, flags); |
| 2088 | for(i = 0; i < LEC_ARP_TABLE_SIZE; i++) { | 2064 | for (i = 0; i < LEC_ARP_TABLE_SIZE; i++) { |
| 2089 | for(entry = priv->lec_arp_tables[i]; entry != NULL; entry = next) { | 2065 | hlist_for_each_entry_safe(entry, node, next, &priv->lec_arp_tables[i], next) { |
| 2090 | next = entry->next; | 2066 | if (!memcmp(atm_addr, entry->atm_addr, ATM_ESA_LEN) |
| 2091 | if (!memcmp(atm_addr, entry->atm_addr, ATM_ESA_LEN) | 2067 | && (permanent || |
| 2092 | && (permanent || | 2068 | !(entry->flags & LEC_PERMANENT_FLAG))) { |
| 2093 | !(entry->flags & LEC_PERMANENT_FLAG))) { | ||
| 2094 | lec_arp_remove(priv, entry); | 2069 | lec_arp_remove(priv, entry); |
| 2095 | kfree(entry); | 2070 | lec_arp_put(entry); |
| 2096 | } | 2071 | } |
| 2097 | spin_unlock_irqrestore(&priv->lec_arp_lock, flags); | 2072 | spin_unlock_irqrestore(&priv->lec_arp_lock, flags); |
| 2098 | return 0; | 2073 | return 0; |
| 2099 | } | 2074 | } |
| 2100 | } | 2075 | } |
| 2101 | spin_unlock_irqrestore(&priv->lec_arp_lock, flags); | 2076 | spin_unlock_irqrestore(&priv->lec_arp_lock, flags); |
| 2102 | return -1; | 2077 | return -1; |
| 2103 | } | 2078 | } |
| 2104 | 2079 | ||
| 2105 | /* | 2080 | /* |
| @@ -2107,109 +2082,98 @@ lec_addr_delete(struct lec_priv *priv, unsigned char *atm_addr, | |||
| 2107 | */ | 2082 | */ |
| 2108 | static void | 2083 | static void |
| 2109 | lec_arp_update(struct lec_priv *priv, unsigned char *mac_addr, | 2084 | lec_arp_update(struct lec_priv *priv, unsigned char *mac_addr, |
| 2110 | unsigned char *atm_addr, unsigned long remoteflag, | 2085 | unsigned char *atm_addr, unsigned long remoteflag, |
| 2111 | unsigned int targetless_le_arp) | 2086 | unsigned int targetless_le_arp) |
| 2112 | { | 2087 | { |
| 2113 | unsigned long flags; | 2088 | unsigned long flags; |
| 2114 | struct lec_arp_table *entry, *tmp; | 2089 | struct hlist_node *node, *next; |
| 2115 | int i; | 2090 | struct lec_arp_table *entry, *tmp; |
| 2091 | int i; | ||
| 2116 | 2092 | ||
| 2117 | DPRINTK("lec:%s", (targetless_le_arp) ? "targetless ": " "); | 2093 | DPRINTK("lec:%s", (targetless_le_arp) ? "targetless " : " "); |
| 2118 | DPRINTK("lec_arp_update mac:%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x\n", | 2094 | DPRINTK("lec_arp_update mac:%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x\n", |
| 2119 | mac_addr[0],mac_addr[1],mac_addr[2],mac_addr[3], | 2095 | mac_addr[0], mac_addr[1], mac_addr[2], mac_addr[3], |
| 2120 | mac_addr[4],mac_addr[5]); | 2096 | mac_addr[4], mac_addr[5]); |
| 2121 | 2097 | ||
| 2122 | spin_lock_irqsave(&priv->lec_arp_lock, flags); | 2098 | spin_lock_irqsave(&priv->lec_arp_lock, flags); |
| 2123 | entry = lec_arp_find(priv, mac_addr); | 2099 | entry = lec_arp_find(priv, mac_addr); |
| 2124 | if (entry == NULL && targetless_le_arp) | 2100 | if (entry == NULL && targetless_le_arp) |
| 2125 | goto out; /* LANE2: ignore targetless LE_ARPs for which | 2101 | goto out; /* |
| 2126 | * we have no entry in the cache. 7.1.30 | 2102 | * LANE2: ignore targetless LE_ARPs for which |
| 2127 | */ | 2103 | * we have no entry in the cache. 7.1.30 |
| 2128 | if (priv->lec_arp_empty_ones) { | 2104 | */ |
| 2129 | entry = priv->lec_arp_empty_ones; | 2105 | if (!hlist_empty(&priv->lec_arp_empty_ones)) { |
| 2130 | if (!memcmp(entry->atm_addr, atm_addr, ATM_ESA_LEN)) { | 2106 | hlist_for_each_entry_safe(entry, node, next, &priv->lec_arp_empty_ones, next) { |
| 2131 | priv->lec_arp_empty_ones = entry->next; | 2107 | if (memcmp(entry->atm_addr, atm_addr, ATM_ESA_LEN) == 0) { |
| 2132 | } else { | 2108 | hlist_del(&entry->next); |
| 2133 | while(entry->next && memcmp(entry->next->atm_addr, | 2109 | del_timer(&entry->timer); |
| 2134 | atm_addr, ATM_ESA_LEN)) | 2110 | tmp = lec_arp_find(priv, mac_addr); |
| 2135 | entry = entry->next; | 2111 | if (tmp) { |
| 2136 | if (entry->next) { | 2112 | del_timer(&tmp->timer); |
| 2137 | tmp = entry; | 2113 | tmp->status = ESI_FORWARD_DIRECT; |
| 2138 | entry = entry->next; | 2114 | memcpy(tmp->atm_addr, atm_addr, ATM_ESA_LEN); |
| 2139 | tmp->next = entry->next; | 2115 | tmp->vcc = entry->vcc; |
| 2140 | } else | 2116 | tmp->old_push = entry->old_push; |
| 2141 | entry = NULL; | 2117 | tmp->last_used = jiffies; |
| 2142 | 2118 | del_timer(&entry->timer); | |
| 2143 | } | 2119 | lec_arp_put(entry); |
| 2144 | if (entry) { | 2120 | entry = tmp; |
| 2145 | del_timer(&entry->timer); | 2121 | } else { |
| 2146 | tmp = lec_arp_find(priv, mac_addr); | 2122 | entry->status = ESI_FORWARD_DIRECT; |
| 2147 | if (tmp) { | 2123 | memcpy(entry->mac_addr, mac_addr, ETH_ALEN); |
| 2148 | del_timer(&tmp->timer); | 2124 | entry->last_used = jiffies; |
| 2149 | tmp->status = ESI_FORWARD_DIRECT; | 2125 | lec_arp_add(priv, entry); |
| 2150 | memcpy(tmp->atm_addr, atm_addr, ATM_ESA_LEN); | 2126 | } |
| 2151 | tmp->vcc = entry->vcc; | 2127 | if (remoteflag) |
| 2152 | tmp->old_push = entry->old_push; | 2128 | entry->flags |= LEC_REMOTE_FLAG; |
| 2153 | tmp->last_used = jiffies; | 2129 | else |
| 2154 | del_timer(&entry->timer); | 2130 | entry->flags &= ~LEC_REMOTE_FLAG; |
| 2155 | kfree(entry); | 2131 | DPRINTK("After update\n"); |
| 2156 | entry=tmp; | 2132 | dump_arp_table(priv); |
| 2157 | } else { | 2133 | goto out; |
| 2158 | entry->status = ESI_FORWARD_DIRECT; | 2134 | } |
| 2159 | memcpy(entry->mac_addr, mac_addr, ETH_ALEN); | 2135 | } |
| 2160 | entry->last_used = jiffies; | 2136 | } |
| 2161 | lec_arp_add(priv, entry); | 2137 | |
| 2162 | } | 2138 | entry = lec_arp_find(priv, mac_addr); |
| 2163 | if (remoteflag) | 2139 | if (!entry) { |
| 2164 | entry->flags|=LEC_REMOTE_FLAG; | 2140 | entry = make_entry(priv, mac_addr); |
| 2165 | else | 2141 | if (!entry) |
| 2166 | entry->flags&=~LEC_REMOTE_FLAG; | ||
| 2167 | DPRINTK("After update\n"); | ||
| 2168 | dump_arp_table(priv); | ||
| 2169 | goto out; | ||
| 2170 | } | ||
| 2171 | } | ||
| 2172 | entry = lec_arp_find(priv, mac_addr); | ||
| 2173 | if (!entry) { | ||
| 2174 | entry = make_entry(priv, mac_addr); | ||
| 2175 | if (!entry) | ||
| 2176 | goto out; | 2142 | goto out; |
| 2177 | entry->status = ESI_UNKNOWN; | 2143 | entry->status = ESI_UNKNOWN; |
| 2178 | lec_arp_add(priv, entry); | 2144 | lec_arp_add(priv, entry); |
| 2179 | /* Temporary, changes before end of function */ | 2145 | /* Temporary, changes before end of function */ |
| 2180 | } | 2146 | } |
| 2181 | memcpy(entry->atm_addr, atm_addr, ATM_ESA_LEN); | 2147 | memcpy(entry->atm_addr, atm_addr, ATM_ESA_LEN); |
| 2182 | del_timer(&entry->timer); | 2148 | del_timer(&entry->timer); |
| 2183 | for(i = 0; i < LEC_ARP_TABLE_SIZE; i++) { | 2149 | for (i = 0; i < LEC_ARP_TABLE_SIZE; i++) { |
| 2184 | for(tmp = priv->lec_arp_tables[i]; tmp; tmp=tmp->next) { | 2150 | hlist_for_each_entry(tmp, node, &priv->lec_arp_tables[i], next) { |
| 2185 | if (entry != tmp && | 2151 | if (entry != tmp && |
| 2186 | !memcmp(tmp->atm_addr, atm_addr, | 2152 | !memcmp(tmp->atm_addr, atm_addr, ATM_ESA_LEN)) { |
| 2187 | ATM_ESA_LEN)) { | 2153 | /* Vcc to this host exists */ |
| 2188 | /* Vcc to this host exists */ | 2154 | if (tmp->status > ESI_VC_PENDING) { |
| 2189 | if (tmp->status > ESI_VC_PENDING) { | 2155 | /* |
| 2190 | /* | 2156 | * ESI_FLUSH_PENDING, |
| 2191 | * ESI_FLUSH_PENDING, | 2157 | * ESI_FORWARD_DIRECT |
| 2192 | * ESI_FORWARD_DIRECT | 2158 | */ |
| 2193 | */ | 2159 | entry->vcc = tmp->vcc; |
| 2194 | entry->vcc = tmp->vcc; | 2160 | entry->old_push = tmp->old_push; |
| 2195 | entry->old_push=tmp->old_push; | 2161 | } |
| 2196 | } | 2162 | entry->status = tmp->status; |
| 2197 | entry->status=tmp->status; | 2163 | break; |
| 2198 | break; | 2164 | } |
| 2199 | } | 2165 | } |
| 2200 | } | 2166 | } |
| 2201 | } | 2167 | if (remoteflag) |
| 2202 | if (remoteflag) | 2168 | entry->flags |= LEC_REMOTE_FLAG; |
| 2203 | entry->flags|=LEC_REMOTE_FLAG; | 2169 | else |
| 2204 | else | 2170 | entry->flags &= ~LEC_REMOTE_FLAG; |
| 2205 | entry->flags&=~LEC_REMOTE_FLAG; | 2171 | if (entry->status == ESI_ARP_PENDING || entry->status == ESI_UNKNOWN) { |
| 2206 | if (entry->status == ESI_ARP_PENDING || | 2172 | entry->status = ESI_VC_PENDING; |
| 2207 | entry->status == ESI_UNKNOWN) { | 2173 | send_to_lecd(priv, l_svc_setup, entry->mac_addr, atm_addr, NULL); |
| 2208 | entry->status = ESI_VC_PENDING; | 2174 | } |
| 2209 | send_to_lecd(priv, l_svc_setup, entry->mac_addr, atm_addr, NULL); | 2175 | DPRINTK("After update2\n"); |
| 2210 | } | 2176 | dump_arp_table(priv); |
| 2211 | DPRINTK("After update2\n"); | ||
| 2212 | dump_arp_table(priv); | ||
| 2213 | out: | 2177 | out: |
| 2214 | spin_unlock_irqrestore(&priv->lec_arp_lock, flags); | 2178 | spin_unlock_irqrestore(&priv->lec_arp_lock, flags); |
| 2215 | } | 2179 | } |
| @@ -2219,299 +2183,299 @@ out: | |||
| 2219 | */ | 2183 | */ |
| 2220 | static void | 2184 | static void |
| 2221 | lec_vcc_added(struct lec_priv *priv, struct atmlec_ioc *ioc_data, | 2185 | lec_vcc_added(struct lec_priv *priv, struct atmlec_ioc *ioc_data, |
| 2222 | struct atm_vcc *vcc, | 2186 | struct atm_vcc *vcc, |
| 2223 | void (*old_push)(struct atm_vcc *vcc, struct sk_buff *skb)) | 2187 | void (*old_push) (struct atm_vcc *vcc, struct sk_buff *skb)) |
| 2224 | { | 2188 | { |
| 2225 | unsigned long flags; | 2189 | unsigned long flags; |
| 2226 | struct lec_arp_table *entry; | 2190 | struct hlist_node *node; |
| 2227 | int i, found_entry=0; | 2191 | struct lec_arp_table *entry; |
| 2192 | int i, found_entry = 0; | ||
| 2228 | 2193 | ||
| 2229 | spin_lock_irqsave(&priv->lec_arp_lock, flags); | 2194 | spin_lock_irqsave(&priv->lec_arp_lock, flags); |
| 2230 | if (ioc_data->receive == 2) { | 2195 | if (ioc_data->receive == 2) { |
| 2231 | /* Vcc for Multicast Forward. No timer, LANEv2 7.1.20 and 2.3.5.3 */ | 2196 | /* Vcc for Multicast Forward. No timer, LANEv2 7.1.20 and 2.3.5.3 */ |
| 2232 | 2197 | ||
| 2233 | DPRINTK("LEC_ARP: Attaching mcast forward\n"); | 2198 | DPRINTK("LEC_ARP: Attaching mcast forward\n"); |
| 2234 | #if 0 | 2199 | #if 0 |
| 2235 | entry = lec_arp_find(priv, bus_mac); | 2200 | entry = lec_arp_find(priv, bus_mac); |
| 2236 | if (!entry) { | 2201 | if (!entry) { |
| 2237 | printk("LEC_ARP: Multicast entry not found!\n"); | 2202 | printk("LEC_ARP: Multicast entry not found!\n"); |
| 2238 | goto out; | 2203 | goto out; |
| 2239 | } | 2204 | } |
| 2240 | memcpy(entry->atm_addr, ioc_data->atm_addr, ATM_ESA_LEN); | 2205 | memcpy(entry->atm_addr, ioc_data->atm_addr, ATM_ESA_LEN); |
| 2241 | entry->recv_vcc = vcc; | 2206 | entry->recv_vcc = vcc; |
| 2242 | entry->old_recv_push = old_push; | 2207 | entry->old_recv_push = old_push; |
| 2243 | #endif | 2208 | #endif |
| 2244 | entry = make_entry(priv, bus_mac); | 2209 | entry = make_entry(priv, bus_mac); |
| 2245 | if (entry == NULL) | 2210 | if (entry == NULL) |
| 2246 | goto out; | 2211 | goto out; |
| 2247 | del_timer(&entry->timer); | 2212 | del_timer(&entry->timer); |
| 2248 | memcpy(entry->atm_addr, ioc_data->atm_addr, ATM_ESA_LEN); | 2213 | memcpy(entry->atm_addr, ioc_data->atm_addr, ATM_ESA_LEN); |
| 2249 | entry->recv_vcc = vcc; | 2214 | entry->recv_vcc = vcc; |
| 2250 | entry->old_recv_push = old_push; | 2215 | entry->old_recv_push = old_push; |
| 2251 | entry->next = priv->mcast_fwds; | 2216 | hlist_add_head(&entry->next, &priv->mcast_fwds); |
| 2252 | priv->mcast_fwds = entry; | 2217 | goto out; |
| 2253 | goto out; | 2218 | } else if (ioc_data->receive == 1) { |
| 2254 | } else if (ioc_data->receive == 1) { | 2219 | /* |
| 2255 | /* Vcc which we don't want to make default vcc, attach it | 2220 | * Vcc which we don't want to make default vcc, |
| 2256 | anyway. */ | 2221 | * attach it anyway. |
| 2257 | 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", | 2222 | */ |
| 2258 | ioc_data->atm_addr[0],ioc_data->atm_addr[1], | 2223 | DPRINTK |
| 2259 | ioc_data->atm_addr[2],ioc_data->atm_addr[3], | 2224 | ("LEC_ARP:Attaching data direct, not default: " |
| 2260 | ioc_data->atm_addr[4],ioc_data->atm_addr[5], | 2225 | "%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", |
| 2261 | ioc_data->atm_addr[6],ioc_data->atm_addr[7], | 2226 | ioc_data->atm_addr[0], ioc_data->atm_addr[1], |
| 2262 | ioc_data->atm_addr[8],ioc_data->atm_addr[9], | 2227 | ioc_data->atm_addr[2], ioc_data->atm_addr[3], |
| 2263 | ioc_data->atm_addr[10],ioc_data->atm_addr[11], | 2228 | ioc_data->atm_addr[4], ioc_data->atm_addr[5], |
| 2264 | ioc_data->atm_addr[12],ioc_data->atm_addr[13], | 2229 | ioc_data->atm_addr[6], ioc_data->atm_addr[7], |
| 2265 | ioc_data->atm_addr[14],ioc_data->atm_addr[15], | 2230 | ioc_data->atm_addr[8], ioc_data->atm_addr[9], |
| 2266 | ioc_data->atm_addr[16],ioc_data->atm_addr[17], | 2231 | ioc_data->atm_addr[10], ioc_data->atm_addr[11], |
| 2267 | ioc_data->atm_addr[18],ioc_data->atm_addr[19]); | 2232 | ioc_data->atm_addr[12], ioc_data->atm_addr[13], |
| 2268 | entry = make_entry(priv, bus_mac); | 2233 | ioc_data->atm_addr[14], ioc_data->atm_addr[15], |
| 2269 | if (entry == NULL) | 2234 | ioc_data->atm_addr[16], ioc_data->atm_addr[17], |
| 2235 | ioc_data->atm_addr[18], ioc_data->atm_addr[19]); | ||
| 2236 | entry = make_entry(priv, bus_mac); | ||
| 2237 | if (entry == NULL) | ||
| 2270 | goto out; | 2238 | goto out; |
| 2271 | memcpy(entry->atm_addr, ioc_data->atm_addr, ATM_ESA_LEN); | 2239 | memcpy(entry->atm_addr, ioc_data->atm_addr, ATM_ESA_LEN); |
| 2272 | memset(entry->mac_addr, 0, ETH_ALEN); | 2240 | memset(entry->mac_addr, 0, ETH_ALEN); |
| 2273 | entry->recv_vcc = vcc; | 2241 | entry->recv_vcc = vcc; |
| 2274 | entry->old_recv_push = old_push; | 2242 | entry->old_recv_push = old_push; |
| 2275 | entry->status = ESI_UNKNOWN; | 2243 | entry->status = ESI_UNKNOWN; |
| 2276 | entry->timer.expires = jiffies + priv->vcc_timeout_period; | 2244 | entry->timer.expires = jiffies + priv->vcc_timeout_period; |
| 2277 | entry->timer.function = lec_arp_expire_vcc; | 2245 | entry->timer.function = lec_arp_expire_vcc; |
| 2278 | add_timer(&entry->timer); | 2246 | hlist_add_head(&entry->next, &priv->lec_no_forward); |
| 2279 | entry->next = priv->lec_no_forward; | 2247 | add_timer(&entry->timer); |
| 2280 | priv->lec_no_forward = entry; | ||
| 2281 | dump_arp_table(priv); | 2248 | dump_arp_table(priv); |
| 2282 | goto out; | 2249 | goto out; |
| 2283 | } | 2250 | } |
| 2284 | 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", | 2251 | DPRINTK |
| 2285 | ioc_data->atm_addr[0],ioc_data->atm_addr[1], | 2252 | ("LEC_ARP:Attaching data direct, default: " |
| 2286 | ioc_data->atm_addr[2],ioc_data->atm_addr[3], | 2253 | "%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", |
| 2287 | ioc_data->atm_addr[4],ioc_data->atm_addr[5], | 2254 | ioc_data->atm_addr[0], ioc_data->atm_addr[1], |
| 2288 | ioc_data->atm_addr[6],ioc_data->atm_addr[7], | 2255 | ioc_data->atm_addr[2], ioc_data->atm_addr[3], |
| 2289 | ioc_data->atm_addr[8],ioc_data->atm_addr[9], | 2256 | ioc_data->atm_addr[4], ioc_data->atm_addr[5], |
| 2290 | ioc_data->atm_addr[10],ioc_data->atm_addr[11], | 2257 | ioc_data->atm_addr[6], ioc_data->atm_addr[7], |
| 2291 | ioc_data->atm_addr[12],ioc_data->atm_addr[13], | 2258 | ioc_data->atm_addr[8], ioc_data->atm_addr[9], |
| 2292 | ioc_data->atm_addr[14],ioc_data->atm_addr[15], | 2259 | ioc_data->atm_addr[10], ioc_data->atm_addr[11], |
| 2293 | ioc_data->atm_addr[16],ioc_data->atm_addr[17], | 2260 | ioc_data->atm_addr[12], ioc_data->atm_addr[13], |
| 2294 | ioc_data->atm_addr[18],ioc_data->atm_addr[19]); | 2261 | ioc_data->atm_addr[14], ioc_data->atm_addr[15], |
| 2295 | for (i = 0; i < LEC_ARP_TABLE_SIZE; i++) { | 2262 | ioc_data->atm_addr[16], ioc_data->atm_addr[17], |
| 2296 | for (entry = priv->lec_arp_tables[i]; entry; entry=entry->next) { | 2263 | ioc_data->atm_addr[18], ioc_data->atm_addr[19]); |
| 2297 | if (memcmp(ioc_data->atm_addr, entry->atm_addr, | 2264 | for (i = 0; i < LEC_ARP_TABLE_SIZE; i++) { |
| 2298 | ATM_ESA_LEN)==0) { | 2265 | hlist_for_each_entry(entry, node, &priv->lec_arp_tables[i], next) { |
| 2299 | DPRINTK("LEC_ARP: Attaching data direct\n"); | 2266 | if (memcmp |
| 2300 | DPRINTK("Currently -> Vcc: %d, Rvcc:%d\n", | 2267 | (ioc_data->atm_addr, entry->atm_addr, |
| 2301 | entry->vcc?entry->vcc->vci:0, | 2268 | ATM_ESA_LEN) == 0) { |
| 2302 | entry->recv_vcc?entry->recv_vcc->vci:0); | 2269 | DPRINTK("LEC_ARP: Attaching data direct\n"); |
| 2303 | found_entry=1; | 2270 | DPRINTK("Currently -> Vcc: %d, Rvcc:%d\n", |
| 2304 | del_timer(&entry->timer); | 2271 | entry->vcc ? entry->vcc->vci : 0, |
| 2305 | entry->vcc = vcc; | 2272 | entry->recv_vcc ? entry->recv_vcc-> |
| 2306 | entry->old_push = old_push; | 2273 | vci : 0); |
| 2307 | if (entry->status == ESI_VC_PENDING) { | 2274 | found_entry = 1; |
| 2308 | if(priv->maximum_unknown_frame_count | 2275 | del_timer(&entry->timer); |
| 2309 | ==0) | 2276 | entry->vcc = vcc; |
| 2310 | entry->status = | 2277 | entry->old_push = old_push; |
| 2311 | ESI_FORWARD_DIRECT; | 2278 | if (entry->status == ESI_VC_PENDING) { |
| 2312 | else { | 2279 | if (priv->maximum_unknown_frame_count |
| 2313 | entry->timestamp = jiffies; | 2280 | == 0) |
| 2314 | entry->status = | 2281 | entry->status = |
| 2315 | ESI_FLUSH_PENDING; | 2282 | ESI_FORWARD_DIRECT; |
| 2283 | else { | ||
| 2284 | entry->timestamp = jiffies; | ||
| 2285 | entry->status = | ||
| 2286 | ESI_FLUSH_PENDING; | ||
| 2316 | #if 0 | 2287 | #if 0 |
| 2317 | send_to_lecd(priv,l_flush_xmt, | 2288 | send_to_lecd(priv, l_flush_xmt, |
| 2318 | NULL, | 2289 | NULL, |
| 2319 | entry->atm_addr, | 2290 | entry->atm_addr, |
| 2320 | NULL); | 2291 | NULL); |
| 2321 | #endif | 2292 | #endif |
| 2322 | } | 2293 | } |
| 2323 | } else { | 2294 | } else { |
| 2324 | /* They were forming a connection | 2295 | /* |
| 2325 | to us, and we to them. Our | 2296 | * They were forming a connection |
| 2326 | ATM address is numerically lower | 2297 | * to us, and we to them. Our |
| 2327 | than theirs, so we make connection | 2298 | * ATM address is numerically lower |
| 2328 | we formed into default VCC (8.1.11). | 2299 | * than theirs, so we make connection |
| 2329 | Connection they made gets torn | 2300 | * we formed into default VCC (8.1.11). |
| 2330 | down. This might confuse some | 2301 | * Connection they made gets torn |
| 2331 | clients. Can be changed if | 2302 | * down. This might confuse some |
| 2332 | someone reports trouble... */ | 2303 | * clients. Can be changed if |
| 2333 | ; | 2304 | * someone reports trouble... |
| 2334 | } | 2305 | */ |
| 2335 | } | 2306 | ; |
| 2336 | } | 2307 | } |
| 2337 | } | 2308 | } |
| 2338 | if (found_entry) { | 2309 | } |
| 2339 | DPRINTK("After vcc was added\n"); | 2310 | } |
| 2340 | dump_arp_table(priv); | 2311 | if (found_entry) { |
| 2312 | DPRINTK("After vcc was added\n"); | ||
| 2313 | dump_arp_table(priv); | ||
| 2341 | goto out; | 2314 | goto out; |
| 2342 | } | 2315 | } |
| 2343 | /* Not found, snatch address from first data packet that arrives from | 2316 | /* |
| 2344 | this vcc */ | 2317 | * Not found, snatch address from first data packet that arrives |
| 2345 | entry = make_entry(priv, bus_mac); | 2318 | * from this vcc |
| 2346 | if (!entry) | 2319 | */ |
| 2320 | entry = make_entry(priv, bus_mac); | ||
| 2321 | if (!entry) | ||
| 2347 | goto out; | 2322 | goto out; |
| 2348 | entry->vcc = vcc; | 2323 | entry->vcc = vcc; |
| 2349 | entry->old_push = old_push; | 2324 | entry->old_push = old_push; |
| 2350 | memcpy(entry->atm_addr, ioc_data->atm_addr, ATM_ESA_LEN); | 2325 | memcpy(entry->atm_addr, ioc_data->atm_addr, ATM_ESA_LEN); |
| 2351 | memset(entry->mac_addr, 0, ETH_ALEN); | 2326 | memset(entry->mac_addr, 0, ETH_ALEN); |
| 2352 | entry->status = ESI_UNKNOWN; | 2327 | entry->status = ESI_UNKNOWN; |
| 2353 | entry->next = priv->lec_arp_empty_ones; | 2328 | hlist_add_head(&entry->next, &priv->lec_arp_empty_ones); |
| 2354 | priv->lec_arp_empty_ones = entry; | 2329 | entry->timer.expires = jiffies + priv->vcc_timeout_period; |
| 2355 | entry->timer.expires = jiffies + priv->vcc_timeout_period; | 2330 | entry->timer.function = lec_arp_expire_vcc; |
| 2356 | entry->timer.function = lec_arp_expire_vcc; | 2331 | add_timer(&entry->timer); |
| 2357 | add_timer(&entry->timer); | 2332 | DPRINTK("After vcc was added\n"); |
| 2358 | DPRINTK("After vcc was added\n"); | ||
| 2359 | dump_arp_table(priv); | 2333 | dump_arp_table(priv); |
| 2360 | out: | 2334 | out: |
| 2361 | spin_unlock_irqrestore(&priv->lec_arp_lock, flags); | 2335 | spin_unlock_irqrestore(&priv->lec_arp_lock, flags); |
| 2362 | } | 2336 | } |
| 2363 | 2337 | ||
| 2364 | static void | 2338 | static void lec_flush_complete(struct lec_priv *priv, unsigned long tran_id) |
| 2365 | lec_flush_complete(struct lec_priv *priv, unsigned long tran_id) | ||
| 2366 | { | 2339 | { |
| 2367 | unsigned long flags; | 2340 | unsigned long flags; |
| 2368 | struct lec_arp_table *entry; | 2341 | struct hlist_node *node; |
| 2369 | int i; | 2342 | struct lec_arp_table *entry; |
| 2370 | 2343 | int i; | |
| 2371 | DPRINTK("LEC:lec_flush_complete %lx\n",tran_id); | 2344 | |
| 2345 | DPRINTK("LEC:lec_flush_complete %lx\n", tran_id); | ||
| 2346 | restart: | ||
| 2372 | spin_lock_irqsave(&priv->lec_arp_lock, flags); | 2347 | spin_lock_irqsave(&priv->lec_arp_lock, flags); |
| 2373 | for (i = 0; i < LEC_ARP_TABLE_SIZE; i++) { | 2348 | for (i = 0; i < LEC_ARP_TABLE_SIZE; i++) { |
| 2374 | for (entry = priv->lec_arp_tables[i]; entry; entry=entry->next) { | 2349 | hlist_for_each_entry(entry, node, &priv->lec_arp_tables[i], next) { |
| 2375 | if (entry->flush_tran_id == tran_id && | 2350 | if (entry->flush_tran_id == tran_id |
| 2376 | entry->status == ESI_FLUSH_PENDING) { | 2351 | && entry->status == ESI_FLUSH_PENDING) { |
| 2377 | struct sk_buff *skb; | 2352 | struct sk_buff *skb; |
| 2378 | 2353 | struct atm_vcc *vcc = entry->vcc; | |
| 2379 | while ((skb = skb_dequeue(&entry->tx_wait)) != NULL) | 2354 | |
| 2380 | lec_send(entry->vcc, skb, entry->priv); | 2355 | lec_arp_hold(entry); |
| 2381 | entry->status = ESI_FORWARD_DIRECT; | 2356 | spin_unlock_irqrestore(&priv->lec_arp_lock, flags); |
| 2382 | DPRINTK("LEC_ARP: Flushed\n"); | 2357 | while ((skb = skb_dequeue(&entry->tx_wait)) != NULL) |
| 2383 | } | 2358 | lec_send(vcc, skb, entry->priv); |
| 2384 | } | 2359 | entry->last_used = jiffies; |
| 2385 | } | 2360 | entry->status = ESI_FORWARD_DIRECT; |
| 2361 | lec_arp_put(entry); | ||
| 2362 | DPRINTK("LEC_ARP: Flushed\n"); | ||
| 2363 | goto restart; | ||
| 2364 | } | ||
| 2365 | } | ||
| 2366 | } | ||
| 2386 | spin_unlock_irqrestore(&priv->lec_arp_lock, flags); | 2367 | spin_unlock_irqrestore(&priv->lec_arp_lock, flags); |
| 2387 | dump_arp_table(priv); | 2368 | dump_arp_table(priv); |
| 2388 | } | 2369 | } |
| 2389 | 2370 | ||
| 2390 | static void | 2371 | static void |
| 2391 | lec_set_flush_tran_id(struct lec_priv *priv, | 2372 | lec_set_flush_tran_id(struct lec_priv *priv, |
| 2392 | unsigned char *atm_addr, unsigned long tran_id) | 2373 | unsigned char *atm_addr, unsigned long tran_id) |
| 2393 | { | 2374 | { |
| 2394 | unsigned long flags; | 2375 | unsigned long flags; |
| 2395 | struct lec_arp_table *entry; | 2376 | struct hlist_node *node; |
| 2396 | int i; | 2377 | struct lec_arp_table *entry; |
| 2378 | int i; | ||
| 2397 | 2379 | ||
| 2398 | spin_lock_irqsave(&priv->lec_arp_lock, flags); | 2380 | spin_lock_irqsave(&priv->lec_arp_lock, flags); |
| 2399 | for (i = 0; i < LEC_ARP_TABLE_SIZE; i++) | 2381 | for (i = 0; i < LEC_ARP_TABLE_SIZE; i++) |
| 2400 | for(entry = priv->lec_arp_tables[i]; entry; entry=entry->next) | 2382 | hlist_for_each_entry(entry, node, &priv->lec_arp_tables[i], next) { |
| 2401 | if (!memcmp(atm_addr, entry->atm_addr, ATM_ESA_LEN)) { | 2383 | if (!memcmp(atm_addr, entry->atm_addr, ATM_ESA_LEN)) { |
| 2402 | entry->flush_tran_id = tran_id; | 2384 | entry->flush_tran_id = tran_id; |
| 2403 | DPRINTK("Set flush transaction id to %lx for %p\n",tran_id,entry); | 2385 | DPRINTK("Set flush transaction id to %lx for %p\n", |
| 2404 | } | 2386 | tran_id, entry); |
| 2387 | } | ||
| 2388 | } | ||
| 2405 | spin_unlock_irqrestore(&priv->lec_arp_lock, flags); | 2389 | spin_unlock_irqrestore(&priv->lec_arp_lock, flags); |
| 2406 | } | 2390 | } |
| 2407 | 2391 | ||
| 2408 | static int | 2392 | static int lec_mcast_make(struct lec_priv *priv, struct atm_vcc *vcc) |
| 2409 | lec_mcast_make(struct lec_priv *priv, struct atm_vcc *vcc) | ||
| 2410 | { | 2393 | { |
| 2411 | unsigned long flags; | 2394 | unsigned long flags; |
| 2412 | unsigned char mac_addr[] = { | 2395 | unsigned char mac_addr[] = { |
| 2413 | 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; | 2396 | 0xff, 0xff, 0xff, 0xff, 0xff, 0xff |
| 2414 | struct lec_arp_table *to_add; | 2397 | }; |
| 2398 | struct lec_arp_table *to_add; | ||
| 2415 | struct lec_vcc_priv *vpriv; | 2399 | struct lec_vcc_priv *vpriv; |
| 2416 | int err = 0; | 2400 | int err = 0; |
| 2417 | 2401 | ||
| 2418 | if (!(vpriv = kmalloc(sizeof(struct lec_vcc_priv), GFP_KERNEL))) | 2402 | if (!(vpriv = kmalloc(sizeof(struct lec_vcc_priv), GFP_KERNEL))) |
| 2419 | return -ENOMEM; | 2403 | return -ENOMEM; |
| 2420 | vpriv->xoff = 0; | 2404 | vpriv->xoff = 0; |
| 2421 | vpriv->old_pop = vcc->pop; | 2405 | vpriv->old_pop = vcc->pop; |
| 2422 | vcc->user_back = vpriv; | 2406 | vcc->user_back = vpriv; |
| 2423 | vcc->pop = lec_pop; | 2407 | vcc->pop = lec_pop; |
| 2424 | spin_lock_irqsave(&priv->lec_arp_lock, flags); | 2408 | spin_lock_irqsave(&priv->lec_arp_lock, flags); |
| 2425 | to_add = make_entry(priv, mac_addr); | 2409 | to_add = make_entry(priv, mac_addr); |
| 2426 | if (!to_add) { | 2410 | if (!to_add) { |
| 2427 | vcc->pop = vpriv->old_pop; | 2411 | vcc->pop = vpriv->old_pop; |
| 2428 | kfree(vpriv); | 2412 | kfree(vpriv); |
| 2429 | err = -ENOMEM; | 2413 | err = -ENOMEM; |
| 2430 | goto out; | 2414 | goto out; |
| 2431 | } | 2415 | } |
| 2432 | memcpy(to_add->atm_addr, vcc->remote.sas_addr.prv, ATM_ESA_LEN); | 2416 | memcpy(to_add->atm_addr, vcc->remote.sas_addr.prv, ATM_ESA_LEN); |
| 2433 | to_add->status = ESI_FORWARD_DIRECT; | 2417 | to_add->status = ESI_FORWARD_DIRECT; |
| 2434 | to_add->flags |= LEC_PERMANENT_FLAG; | 2418 | to_add->flags |= LEC_PERMANENT_FLAG; |
| 2435 | to_add->vcc = vcc; | 2419 | to_add->vcc = vcc; |
| 2436 | to_add->old_push = vcc->push; | 2420 | to_add->old_push = vcc->push; |
| 2437 | vcc->push = lec_push; | 2421 | vcc->push = lec_push; |
| 2438 | priv->mcast_vcc = vcc; | 2422 | priv->mcast_vcc = vcc; |
| 2439 | lec_arp_add(priv, to_add); | 2423 | lec_arp_add(priv, to_add); |
| 2440 | out: | 2424 | out: |
| 2441 | spin_unlock_irqrestore(&priv->lec_arp_lock, flags); | 2425 | spin_unlock_irqrestore(&priv->lec_arp_lock, flags); |
| 2442 | return err; | 2426 | return err; |
| 2443 | } | 2427 | } |
| 2444 | 2428 | ||
| 2445 | static void | 2429 | static void lec_vcc_close(struct lec_priv *priv, struct atm_vcc *vcc) |
| 2446 | lec_vcc_close(struct lec_priv *priv, struct atm_vcc *vcc) | ||
| 2447 | { | 2430 | { |
| 2448 | unsigned long flags; | 2431 | unsigned long flags; |
| 2449 | struct lec_arp_table *entry, *next; | 2432 | struct hlist_node *node, *next; |
| 2450 | int i; | 2433 | struct lec_arp_table *entry; |
| 2434 | int i; | ||
| 2435 | |||
| 2436 | DPRINTK("LEC_ARP: lec_vcc_close vpi:%d vci:%d\n", vcc->vpi, vcc->vci); | ||
| 2437 | dump_arp_table(priv); | ||
| 2451 | 2438 | ||
| 2452 | DPRINTK("LEC_ARP: lec_vcc_close vpi:%d vci:%d\n",vcc->vpi,vcc->vci); | ||
| 2453 | dump_arp_table(priv); | ||
| 2454 | spin_lock_irqsave(&priv->lec_arp_lock, flags); | 2439 | spin_lock_irqsave(&priv->lec_arp_lock, flags); |
| 2455 | for(i=0;i<LEC_ARP_TABLE_SIZE;i++) { | 2440 | |
| 2456 | for(entry = priv->lec_arp_tables[i];entry; entry=next) { | 2441 | for (i = 0; i < LEC_ARP_TABLE_SIZE; i++) { |
| 2457 | next = entry->next; | 2442 | hlist_for_each_entry_safe(entry, node, next, &priv->lec_arp_tables[i], next) { |
| 2458 | if (vcc == entry->vcc) { | 2443 | if (vcc == entry->vcc) { |
| 2459 | lec_arp_remove(priv, entry); | 2444 | lec_arp_remove(priv, entry); |
| 2460 | kfree(entry); | 2445 | lec_arp_put(entry); |
| 2461 | if (priv->mcast_vcc == vcc) { | 2446 | if (priv->mcast_vcc == vcc) { |
| 2462 | priv->mcast_vcc = NULL; | 2447 | priv->mcast_vcc = NULL; |
| 2463 | } | 2448 | } |
| 2464 | } | 2449 | } |
| 2465 | } | 2450 | } |
| 2466 | } | 2451 | } |
| 2467 | 2452 | ||
| 2468 | entry = priv->lec_arp_empty_ones; | 2453 | hlist_for_each_entry_safe(entry, node, next, &priv->lec_arp_empty_ones, next) { |
| 2469 | priv->lec_arp_empty_ones = NULL; | 2454 | if (entry->vcc == vcc) { |
| 2470 | while (entry != NULL) { | 2455 | lec_arp_clear_vccs(entry); |
| 2471 | next = entry->next; | 2456 | del_timer(&entry->timer); |
| 2472 | if (entry->vcc == vcc) { /* leave it out from the list */ | 2457 | hlist_del(&entry->next); |
| 2473 | lec_arp_clear_vccs(entry); | 2458 | lec_arp_put(entry); |
| 2474 | del_timer(&entry->timer); | 2459 | } |
| 2475 | kfree(entry); | 2460 | } |
| 2476 | } | 2461 | |
| 2477 | else { /* put it back to the list */ | 2462 | hlist_for_each_entry_safe(entry, node, next, &priv->lec_no_forward, next) { |
| 2478 | entry->next = priv->lec_arp_empty_ones; | 2463 | if (entry->recv_vcc == vcc) { |
| 2479 | priv->lec_arp_empty_ones = entry; | 2464 | lec_arp_clear_vccs(entry); |
| 2480 | } | 2465 | del_timer(&entry->timer); |
| 2481 | entry = next; | 2466 | hlist_del(&entry->next); |
| 2482 | } | 2467 | lec_arp_put(entry); |
| 2483 | 2468 | } | |
| 2484 | entry = priv->lec_no_forward; | 2469 | } |
| 2485 | priv->lec_no_forward = NULL; | 2470 | |
| 2486 | while (entry != NULL) { | 2471 | hlist_for_each_entry_safe(entry, node, next, &priv->mcast_fwds, next) { |
| 2487 | next = entry->next; | 2472 | if (entry->recv_vcc == vcc) { |
| 2488 | if (entry->recv_vcc == vcc) { | 2473 | lec_arp_clear_vccs(entry); |
| 2489 | lec_arp_clear_vccs(entry); | 2474 | /* No timer, LANEv2 7.1.20 and 2.3.5.3 */ |
| 2490 | del_timer(&entry->timer); | 2475 | hlist_del(&entry->next); |
| 2491 | kfree(entry); | 2476 | lec_arp_put(entry); |
| 2492 | } | 2477 | } |
| 2493 | else { | 2478 | } |
| 2494 | entry->next = priv->lec_no_forward; | ||
| 2495 | priv->lec_no_forward = entry; | ||
| 2496 | } | ||
| 2497 | entry = next; | ||
| 2498 | } | ||
| 2499 | |||
| 2500 | entry = priv->mcast_fwds; | ||
| 2501 | priv->mcast_fwds = NULL; | ||
| 2502 | while (entry != NULL) { | ||
| 2503 | next = entry->next; | ||
| 2504 | if (entry->recv_vcc == vcc) { | ||
| 2505 | lec_arp_clear_vccs(entry); | ||
| 2506 | /* No timer, LANEv2 7.1.20 and 2.3.5.3 */ | ||
| 2507 | kfree(entry); | ||
| 2508 | } | ||
| 2509 | else { | ||
| 2510 | entry->next = priv->mcast_fwds; | ||
| 2511 | priv->mcast_fwds = entry; | ||
| 2512 | } | ||
| 2513 | entry = next; | ||
| 2514 | } | ||
| 2515 | 2479 | ||
| 2516 | spin_unlock_irqrestore(&priv->lec_arp_lock, flags); | 2480 | spin_unlock_irqrestore(&priv->lec_arp_lock, flags); |
| 2517 | dump_arp_table(priv); | 2481 | dump_arp_table(priv); |
| @@ -2519,57 +2483,42 @@ lec_vcc_close(struct lec_priv *priv, struct atm_vcc *vcc) | |||
| 2519 | 2483 | ||
| 2520 | static void | 2484 | static void |
| 2521 | lec_arp_check_empties(struct lec_priv *priv, | 2485 | lec_arp_check_empties(struct lec_priv *priv, |
| 2522 | struct atm_vcc *vcc, struct sk_buff *skb) | 2486 | struct atm_vcc *vcc, struct sk_buff *skb) |
| 2523 | { | 2487 | { |
| 2524 | unsigned long flags; | 2488 | unsigned long flags; |
| 2525 | struct lec_arp_table *entry, *prev; | 2489 | struct hlist_node *node, *next; |
| 2526 | struct lecdatahdr_8023 *hdr = (struct lecdatahdr_8023 *)skb->data; | 2490 | struct lec_arp_table *entry, *tmp; |
| 2527 | unsigned char *src; | 2491 | struct lecdatahdr_8023 *hdr = (struct lecdatahdr_8023 *)skb->data; |
| 2492 | unsigned char *src; | ||
| 2528 | #ifdef CONFIG_TR | 2493 | #ifdef CONFIG_TR |
| 2529 | struct lecdatahdr_8025 *tr_hdr = (struct lecdatahdr_8025 *)skb->data; | 2494 | struct lecdatahdr_8025 *tr_hdr = (struct lecdatahdr_8025 *)skb->data; |
| 2530 | 2495 | ||
| 2531 | if (priv->is_trdev) src = tr_hdr->h_source; | 2496 | if (priv->is_trdev) |
| 2532 | else | 2497 | src = tr_hdr->h_source; |
| 2498 | else | ||
| 2533 | #endif | 2499 | #endif |
| 2534 | src = hdr->h_source; | 2500 | src = hdr->h_source; |
| 2535 | 2501 | ||
| 2536 | spin_lock_irqsave(&priv->lec_arp_lock, flags); | 2502 | spin_lock_irqsave(&priv->lec_arp_lock, flags); |
| 2537 | entry = priv->lec_arp_empty_ones; | 2503 | hlist_for_each_entry_safe(entry, node, next, &priv->lec_arp_empty_ones, next) { |
| 2538 | if (vcc == entry->vcc) { | 2504 | if (vcc == entry->vcc) { |
| 2539 | del_timer(&entry->timer); | 2505 | del_timer(&entry->timer); |
| 2540 | memcpy(entry->mac_addr, src, ETH_ALEN); | 2506 | memcpy(entry->mac_addr, src, ETH_ALEN); |
| 2541 | entry->status = ESI_FORWARD_DIRECT; | 2507 | entry->status = ESI_FORWARD_DIRECT; |
| 2542 | entry->last_used = jiffies; | 2508 | entry->last_used = jiffies; |
| 2543 | priv->lec_arp_empty_ones = entry->next; | 2509 | /* We might have got an entry */ |
| 2544 | /* We might have got an entry */ | 2510 | if ((tmp = lec_arp_find(priv, src))) { |
| 2545 | if ((prev = lec_arp_find(priv,src))) { | 2511 | lec_arp_remove(priv, tmp); |
| 2546 | lec_arp_remove(priv, prev); | 2512 | lec_arp_put(tmp); |
| 2547 | kfree(prev); | 2513 | } |
| 2548 | } | 2514 | hlist_del(&entry->next); |
| 2549 | lec_arp_add(priv, entry); | 2515 | lec_arp_add(priv, entry); |
| 2550 | goto out; | 2516 | goto out; |
| 2551 | } | 2517 | } |
| 2552 | prev = entry; | 2518 | } |
| 2553 | entry = entry->next; | 2519 | DPRINTK("LEC_ARP: Arp_check_empties: entry not found!\n"); |
| 2554 | while (entry && entry->vcc != vcc) { | ||
| 2555 | prev= entry; | ||
| 2556 | entry = entry->next; | ||
| 2557 | } | ||
| 2558 | if (!entry) { | ||
| 2559 | DPRINTK("LEC_ARP: Arp_check_empties: entry not found!\n"); | ||
| 2560 | goto out; | ||
| 2561 | } | ||
| 2562 | del_timer(&entry->timer); | ||
| 2563 | memcpy(entry->mac_addr, src, ETH_ALEN); | ||
| 2564 | entry->status = ESI_FORWARD_DIRECT; | ||
| 2565 | entry->last_used = jiffies; | ||
| 2566 | prev->next = entry->next; | ||
| 2567 | if ((prev = lec_arp_find(priv, src))) { | ||
| 2568 | lec_arp_remove(priv, prev); | ||
| 2569 | kfree(prev); | ||
| 2570 | } | ||
| 2571 | lec_arp_add(priv, entry); | ||
| 2572 | out: | 2520 | out: |
| 2573 | spin_unlock_irqrestore(&priv->lec_arp_lock, flags); | 2521 | spin_unlock_irqrestore(&priv->lec_arp_lock, flags); |
| 2574 | } | 2522 | } |
| 2523 | |||
| 2575 | MODULE_LICENSE("GPL"); | 2524 | MODULE_LICENSE("GPL"); |
