diff options
| -rw-r--r-- | net/atm/lec.c | 1407 |
1 files changed, 715 insertions, 692 deletions
diff --git a/net/atm/lec.c b/net/atm/lec.c index b4aa489849df..543960c86fa8 100644 --- a/net/atm/lec.c +++ b/net/atm/lec.c | |||
| @@ -1,7 +1,7 @@ | |||
| 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/kernel.h> | 7 | #include <linux/kernel.h> |
| @@ -38,7 +38,7 @@ | |||
| 38 | #include <linux/if_bridge.h> | 38 | #include <linux/if_bridge.h> |
| 39 | #include "../bridge/br_private.h" | 39 | #include "../bridge/br_private.h" |
| 40 | 40 | ||
| 41 | static unsigned char bridge_ula_lec[] = {0x01, 0x80, 0xc2, 0x00, 0x00}; | 41 | static unsigned char bridge_ula_lec[] = { 0x01, 0x80, 0xc2, 0x00, 0x00 }; |
| 42 | #endif | 42 | #endif |
| 43 | 43 | ||
| 44 | /* Modular too */ | 44 | /* Modular too */ |
| @@ -55,38 +55,41 @@ static unsigned char bridge_ula_lec[] = {0x01, 0x80, 0xc2, 0x00, 0x00}; | |||
| 55 | #define DPRINTK(format,args...) | 55 | #define DPRINTK(format,args...) |
| 56 | #endif | 56 | #endif |
| 57 | 57 | ||
| 58 | #define DUMP_PACKETS 0 /* 0 = None, | 58 | #define DUMP_PACKETS 0 /* |
| 59 | * 1 = 30 first bytes | 59 | * 0 = None, |
| 60 | * 2 = Whole packet | 60 | * 1 = 30 first bytes |
| 61 | */ | 61 | * 2 = Whole packet |
| 62 | */ | ||
| 62 | 63 | ||
| 63 | #define LEC_UNRES_QUE_LEN 8 /* number of tx packets to queue for a | 64 | #define LEC_UNRES_QUE_LEN 8 /* |
| 64 | single destination while waiting for SVC */ | 65 | * number of tx packets to queue for a |
| 66 | * single destination while waiting for SVC | ||
| 67 | */ | ||
| 65 | 68 | ||
| 66 | static int lec_open(struct net_device *dev); | 69 | static int lec_open(struct net_device *dev); |
| 67 | 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); |
| 68 | static int lec_close(struct net_device *dev); | 71 | static int lec_close(struct net_device *dev); |
| 69 | 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); |
| 70 | static void lec_init(struct net_device *dev); | 73 | static void lec_init(struct net_device *dev); |
| 71 | 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, |
| 72 | unsigned char *mac_addr); | 75 | unsigned char *mac_addr); |
| 73 | static int lec_arp_remove(struct lec_priv *priv, | 76 | static int lec_arp_remove(struct lec_priv *priv, |
| 74 | struct lec_arp_table *to_remove); | 77 | struct lec_arp_table *to_remove); |
| 75 | /* LANE2 functions */ | 78 | /* LANE2 functions */ |
| 76 | 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, |
| 77 | u8 *tlvs, u32 sizeoftlvs); | 80 | u8 *tlvs, u32 sizeoftlvs); |
| 78 | 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, |
| 79 | u8 **tlvs, u32 *sizeoftlvs); | 82 | u8 **tlvs, u32 *sizeoftlvs); |
| 80 | 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, |
| 81 | u8 *tlvs, u32 sizeoftlvs); | 84 | u8 *tlvs, u32 sizeoftlvs); |
| 82 | 85 | ||
| 83 | 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, |
| 84 | unsigned long permanent); | 87 | unsigned long permanent); |
| 85 | static void lec_arp_check_empties(struct lec_priv *priv, | 88 | static void lec_arp_check_empties(struct lec_priv *priv, |
| 86 | struct atm_vcc *vcc, struct sk_buff *skb); | 89 | struct atm_vcc *vcc, struct sk_buff *skb); |
| 87 | static void lec_arp_destroy(struct lec_priv *priv); | 90 | static void lec_arp_destroy(struct lec_priv *priv); |
| 88 | static void lec_arp_init(struct lec_priv *priv); | 91 | static void lec_arp_init(struct lec_priv *priv); |
| 89 | static struct atm_vcc* lec_arp_resolve(struct lec_priv *priv, | 92 | static struct atm_vcc *lec_arp_resolve(struct lec_priv *priv, |
| 90 | unsigned char *mac_to_find, | 93 | unsigned char *mac_to_find, |
| 91 | int is_rdesc, | 94 | int is_rdesc, |
| 92 | struct lec_arp_table **ret_entry); | 95 | struct lec_arp_table **ret_entry); |
| @@ -100,16 +103,17 @@ static void lec_set_flush_tran_id(struct lec_priv *priv, | |||
| 100 | unsigned long tran_id); | 103 | unsigned long tran_id); |
| 101 | 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, |
| 102 | struct atm_vcc *vcc, | 105 | struct atm_vcc *vcc, |
| 103 | void (*old_push)(struct atm_vcc *vcc, struct sk_buff *skb)); | 106 | void (*old_push) (struct atm_vcc *vcc, |
| 107 | struct sk_buff *skb)); | ||
| 104 | 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); |
| 105 | 109 | ||
| 106 | static struct lane2_ops lane2_ops = { | 110 | static struct lane2_ops lane2_ops = { |
| 107 | lane2_resolve, /* resolve, spec 3.1.3 */ | 111 | lane2_resolve, /* resolve, spec 3.1.3 */ |
| 108 | lane2_associate_req, /* associate_req, spec 3.1.4 */ | 112 | lane2_associate_req, /* associate_req, spec 3.1.4 */ |
| 109 | NULL /* associate indicator, spec 3.1.5 */ | 113 | NULL /* associate indicator, spec 3.1.5 */ |
| 110 | }; | 114 | }; |
| 111 | 115 | ||
| 112 | static unsigned char bus_mac[ETH_ALEN] = {0xff,0xff,0xff,0xff,0xff,0xff}; | 116 | static unsigned char bus_mac[ETH_ALEN] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; |
| 113 | 117 | ||
| 114 | /* Device structures */ | 118 | /* Device structures */ |
| 115 | static struct net_device *dev_lec[MAX_LEC_ITF]; | 119 | static struct net_device *dev_lec[MAX_LEC_ITF]; |
| @@ -117,36 +121,39 @@ static struct net_device *dev_lec[MAX_LEC_ITF]; | |||
| 117 | #if defined(CONFIG_BRIDGE) || defined(CONFIG_BRIDGE_MODULE) | 121 | #if defined(CONFIG_BRIDGE) || defined(CONFIG_BRIDGE_MODULE) |
| 118 | static void lec_handle_bridge(struct sk_buff *skb, struct net_device *dev) | 122 | static void lec_handle_bridge(struct sk_buff *skb, struct net_device *dev) |
| 119 | { | 123 | { |
| 120 | struct ethhdr *eth; | 124 | struct ethhdr *eth; |
| 121 | char *buff; | 125 | char *buff; |
| 122 | struct lec_priv *priv; | 126 | struct lec_priv *priv; |
| 123 | 127 | ||
| 124 | /* Check if this is a BPDU. If so, ask zeppelin to send | 128 | /* |
| 125 | * LE_TOPOLOGY_REQUEST with the same value of Topology Change bit | 129 | * Check if this is a BPDU. If so, ask zeppelin to send |
| 126 | * as the Config BPDU has */ | 130 | * LE_TOPOLOGY_REQUEST with the same value of Topology Change bit |
| 127 | eth = (struct ethhdr *)skb->data; | 131 | * as the Config BPDU has |
| 128 | buff = skb->data + skb->dev->hard_header_len; | 132 | */ |
| 129 | if (*buff++ == 0x42 && *buff++ == 0x42 && *buff++ == 0x03) { | 133 | eth = (struct ethhdr *)skb->data; |
| 134 | buff = skb->data + skb->dev->hard_header_len; | ||
| 135 | if (*buff++ == 0x42 && *buff++ == 0x42 && *buff++ == 0x03) { | ||
| 130 | struct sock *sk; | 136 | struct sock *sk; |
| 131 | struct sk_buff *skb2; | 137 | struct sk_buff *skb2; |
| 132 | struct atmlec_msg *mesg; | 138 | struct atmlec_msg *mesg; |
| 133 | 139 | ||
| 134 | skb2 = alloc_skb(sizeof(struct atmlec_msg), GFP_ATOMIC); | 140 | skb2 = alloc_skb(sizeof(struct atmlec_msg), GFP_ATOMIC); |
| 135 | if (skb2 == NULL) return; | 141 | if (skb2 == NULL) |
| 136 | skb2->len = sizeof(struct atmlec_msg); | 142 | return; |
| 137 | mesg = (struct atmlec_msg *)skb2->data; | 143 | skb2->len = sizeof(struct atmlec_msg); |
| 138 | mesg->type = l_topology_change; | 144 | mesg = (struct atmlec_msg *)skb2->data; |
| 139 | buff += 4; | 145 | mesg->type = l_topology_change; |
| 140 | mesg->content.normal.flag = *buff & 0x01; /* 0x01 is topology change */ | 146 | buff += 4; |
| 141 | 147 | mesg->content.normal.flag = *buff & 0x01; /* 0x01 is topology change */ | |
| 142 | priv = (struct lec_priv *)dev->priv; | 148 | |
| 143 | atm_force_charge(priv->lecd, skb2->truesize); | 149 | priv = (struct lec_priv *)dev->priv; |
| 150 | atm_force_charge(priv->lecd, skb2->truesize); | ||
| 144 | sk = sk_atm(priv->lecd); | 151 | sk = sk_atm(priv->lecd); |
| 145 | skb_queue_tail(&sk->sk_receive_queue, skb2); | 152 | skb_queue_tail(&sk->sk_receive_queue, skb2); |
| 146 | sk->sk_data_ready(sk, skb2->len); | 153 | sk->sk_data_ready(sk, skb2->len); |
| 147 | } | 154 | } |
| 148 | 155 | ||
| 149 | return; | 156 | return; |
| 150 | } | 157 | } |
| 151 | #endif /* defined(CONFIG_BRIDGE) || defined(CONFIG_BRIDGE_MODULE) */ | 158 | #endif /* defined(CONFIG_BRIDGE) || defined(CONFIG_BRIDGE_MODULE) */ |
| 152 | 159 | ||
| @@ -162,36 +169,35 @@ static void lec_handle_bridge(struct sk_buff *skb, struct net_device *dev) | |||
| 162 | #ifdef CONFIG_TR | 169 | #ifdef CONFIG_TR |
| 163 | static unsigned char *get_tr_dst(unsigned char *packet, unsigned char *rdesc) | 170 | static unsigned char *get_tr_dst(unsigned char *packet, unsigned char *rdesc) |
| 164 | { | 171 | { |
| 165 | struct trh_hdr *trh; | 172 | struct trh_hdr *trh; |
| 166 | int riflen, num_rdsc; | 173 | int riflen, num_rdsc; |
| 167 | 174 | ||
| 168 | trh = (struct trh_hdr *)packet; | 175 | trh = (struct trh_hdr *)packet; |
| 169 | if (trh->daddr[0] & (uint8_t)0x80) | 176 | if (trh->daddr[0] & (uint8_t) 0x80) |
| 170 | return bus_mac; /* multicast */ | 177 | return bus_mac; /* multicast */ |
| 171 | 178 | ||
| 172 | if (trh->saddr[0] & TR_RII) { | 179 | if (trh->saddr[0] & TR_RII) { |
| 173 | riflen = (ntohs(trh->rcf) & TR_RCF_LEN_MASK) >> 8; | 180 | riflen = (ntohs(trh->rcf) & TR_RCF_LEN_MASK) >> 8; |
| 174 | if ((ntohs(trh->rcf) >> 13) != 0) | 181 | if ((ntohs(trh->rcf) >> 13) != 0) |
| 175 | return bus_mac; /* ARE or STE */ | 182 | return bus_mac; /* ARE or STE */ |
| 176 | } | 183 | } else |
| 177 | else | 184 | return trh->daddr; /* not source routed */ |
| 178 | return trh->daddr; /* not source routed */ | 185 | |
| 179 | 186 | if (riflen < 6) | |
| 180 | if (riflen < 6) | 187 | return trh->daddr; /* last hop, source routed */ |
| 181 | return trh->daddr; /* last hop, source routed */ | 188 | |
| 182 | 189 | /* riflen is 6 or more, packet has more than one route descriptor */ | |
| 183 | /* riflen is 6 or more, packet has more than one route descriptor */ | 190 | num_rdsc = (riflen / 2) - 1; |
| 184 | num_rdsc = (riflen/2) - 1; | 191 | memset(rdesc, 0, ETH_ALEN); |
| 185 | memset(rdesc, 0, ETH_ALEN); | 192 | /* offset 4 comes from LAN destination field in LE control frames */ |
| 186 | /* offset 4 comes from LAN destination field in LE control frames */ | 193 | if (trh->rcf & htons((uint16_t) TR_RCF_DIR_BIT)) |
| 187 | if (trh->rcf & htons((uint16_t)TR_RCF_DIR_BIT)) | 194 | memcpy(&rdesc[4], &trh->rseg[num_rdsc - 2], sizeof(uint16_t)); |
| 188 | memcpy(&rdesc[4], &trh->rseg[num_rdsc-2], sizeof(uint16_t)); | 195 | else { |
| 189 | else { | 196 | memcpy(&rdesc[4], &trh->rseg[1], sizeof(uint16_t)); |
| 190 | memcpy(&rdesc[4], &trh->rseg[1], sizeof(uint16_t)); | 197 | rdesc[5] = ((ntohs(trh->rseg[0]) & 0x000f) | (rdesc[5] & 0xf0)); |
| 191 | rdesc[5] = ((ntohs(trh->rseg[0]) & 0x000f) | (rdesc[5] & 0xf0)); | 198 | } |
| 192 | } | ||
| 193 | 199 | ||
| 194 | return NULL; | 200 | return NULL; |
| 195 | } | 201 | } |
| 196 | #endif /* CONFIG_TR */ | 202 | #endif /* CONFIG_TR */ |
| 197 | 203 | ||
| @@ -204,15 +210,14 @@ static unsigned char *get_tr_dst(unsigned char *packet, unsigned char *rdesc) | |||
| 204 | * there is non-reboot way to recover if something goes wrong. | 210 | * there is non-reboot way to recover if something goes wrong. |
| 205 | */ | 211 | */ |
| 206 | 212 | ||
| 207 | static int | 213 | static int lec_open(struct net_device *dev) |
| 208 | lec_open(struct net_device *dev) | ||
| 209 | { | 214 | { |
| 210 | struct lec_priv *priv = (struct lec_priv *)dev->priv; | 215 | struct lec_priv *priv = (struct lec_priv *)dev->priv; |
| 211 | 216 | ||
| 212 | netif_start_queue(dev); | 217 | netif_start_queue(dev); |
| 213 | memset(&priv->stats,0,sizeof(struct net_device_stats)); | 218 | memset(&priv->stats, 0, sizeof(struct net_device_stats)); |
| 214 | 219 | ||
| 215 | return 0; | 220 | return 0; |
| 216 | } | 221 | } |
| 217 | 222 | ||
| 218 | static __inline__ void | 223 | static __inline__ void |
| @@ -231,160 +236,166 @@ lec_send(struct atm_vcc *vcc, struct sk_buff *skb, struct lec_priv *priv) | |||
| 231 | priv->stats.tx_bytes += skb->len; | 236 | priv->stats.tx_bytes += skb->len; |
| 232 | } | 237 | } |
| 233 | 238 | ||
| 234 | static void | 239 | static void lec_tx_timeout(struct net_device *dev) |
| 235 | lec_tx_timeout(struct net_device *dev) | ||
| 236 | { | 240 | { |
| 237 | printk(KERN_INFO "%s: tx timeout\n", dev->name); | 241 | printk(KERN_INFO "%s: tx timeout\n", dev->name); |
| 238 | dev->trans_start = jiffies; | 242 | dev->trans_start = jiffies; |
| 239 | netif_wake_queue(dev); | 243 | netif_wake_queue(dev); |
| 240 | } | 244 | } |
| 241 | 245 | ||
| 242 | static int | 246 | static int lec_start_xmit(struct sk_buff *skb, struct net_device *dev) |
| 243 | lec_start_xmit(struct sk_buff *skb, struct net_device *dev) | ||
| 244 | { | 247 | { |
| 245 | struct sk_buff *skb2; | 248 | struct sk_buff *skb2; |
| 246 | struct lec_priv *priv = (struct lec_priv *)dev->priv; | 249 | struct lec_priv *priv = (struct lec_priv *)dev->priv; |
| 247 | struct lecdatahdr_8023 *lec_h; | 250 | struct lecdatahdr_8023 *lec_h; |
| 248 | struct atm_vcc *vcc; | 251 | struct atm_vcc *vcc; |
| 249 | struct lec_arp_table *entry; | 252 | struct lec_arp_table *entry; |
| 250 | unsigned char *dst; | 253 | unsigned char *dst; |
| 251 | int min_frame_size; | 254 | int min_frame_size; |
| 252 | #ifdef CONFIG_TR | 255 | #ifdef CONFIG_TR |
| 253 | unsigned char rdesc[ETH_ALEN]; /* Token Ring route descriptor */ | 256 | unsigned char rdesc[ETH_ALEN]; /* Token Ring route descriptor */ |
| 254 | #endif | 257 | #endif |
| 255 | int is_rdesc; | 258 | int is_rdesc; |
| 256 | #if DUMP_PACKETS > 0 | 259 | #if DUMP_PACKETS > 0 |
| 257 | char buf[300]; | 260 | char buf[300]; |
| 258 | int i=0; | 261 | int i = 0; |
| 259 | #endif /* DUMP_PACKETS >0 */ | 262 | #endif /* DUMP_PACKETS >0 */ |
| 260 | 263 | ||
| 261 | DPRINTK("lec_start_xmit called\n"); | 264 | DPRINTK("lec_start_xmit called\n"); |
| 262 | if (!priv->lecd) { | 265 | if (!priv->lecd) { |
| 263 | printk("%s:No lecd attached\n",dev->name); | 266 | printk("%s:No lecd attached\n", dev->name); |
| 264 | priv->stats.tx_errors++; | 267 | priv->stats.tx_errors++; |
| 265 | netif_stop_queue(dev); | 268 | netif_stop_queue(dev); |
| 266 | return -EUNATCH; | 269 | return -EUNATCH; |
| 267 | } | 270 | } |
| 268 | 271 | ||
| 269 | DPRINTK("skbuff head:%lx data:%lx tail:%lx end:%lx\n", | 272 | DPRINTK("skbuff head:%lx data:%lx tail:%lx end:%lx\n", |
| 270 | (long)skb->head, (long)skb->data, (long)skb->tail, | 273 | (long)skb->head, (long)skb->data, (long)skb->tail, |
| 271 | (long)skb->end); | 274 | (long)skb->end); |
| 272 | #if defined(CONFIG_BRIDGE) || defined(CONFIG_BRIDGE_MODULE) | 275 | #if defined(CONFIG_BRIDGE) || defined(CONFIG_BRIDGE_MODULE) |
| 273 | if (memcmp(skb->data, bridge_ula_lec, sizeof(bridge_ula_lec)) == 0) | 276 | if (memcmp(skb->data, bridge_ula_lec, sizeof(bridge_ula_lec)) == 0) |
| 274 | lec_handle_bridge(skb, dev); | 277 | lec_handle_bridge(skb, dev); |
| 275 | #endif | 278 | #endif |
| 276 | 279 | ||
| 277 | /* Make sure we have room for lec_id */ | 280 | /* Make sure we have room for lec_id */ |
| 278 | if (skb_headroom(skb) < 2) { | 281 | if (skb_headroom(skb) < 2) { |
| 279 | 282 | ||
| 280 | DPRINTK("lec_start_xmit: reallocating skb\n"); | 283 | DPRINTK("lec_start_xmit: reallocating skb\n"); |
| 281 | skb2 = skb_realloc_headroom(skb, LEC_HEADER_LEN); | 284 | skb2 = skb_realloc_headroom(skb, LEC_HEADER_LEN); |
| 282 | kfree_skb(skb); | 285 | kfree_skb(skb); |
| 283 | if (skb2 == NULL) return 0; | 286 | if (skb2 == NULL) |
| 284 | skb = skb2; | 287 | return 0; |
| 285 | } | 288 | skb = skb2; |
| 286 | skb_push(skb, 2); | 289 | } |
| 290 | skb_push(skb, 2); | ||
| 287 | 291 | ||
| 288 | /* Put le header to place, works for TokenRing too */ | 292 | /* Put le header to place, works for TokenRing too */ |
| 289 | lec_h = (struct lecdatahdr_8023*)skb->data; | 293 | lec_h = (struct lecdatahdr_8023 *)skb->data; |
| 290 | lec_h->le_header = htons(priv->lecid); | 294 | lec_h->le_header = htons(priv->lecid); |
| 291 | 295 | ||
| 292 | #ifdef CONFIG_TR | 296 | #ifdef CONFIG_TR |
| 293 | /* Ugly. Use this to realign Token Ring packets for | 297 | /* |
| 294 | * e.g. PCA-200E driver. */ | 298 | * Ugly. Use this to realign Token Ring packets for |
| 295 | if (priv->is_trdev) { | 299 | * e.g. PCA-200E driver. |
| 296 | skb2 = skb_realloc_headroom(skb, LEC_HEADER_LEN); | 300 | */ |
| 297 | kfree_skb(skb); | 301 | if (priv->is_trdev) { |
| 298 | if (skb2 == NULL) return 0; | 302 | skb2 = skb_realloc_headroom(skb, LEC_HEADER_LEN); |
| 299 | skb = skb2; | 303 | kfree_skb(skb); |
| 300 | } | 304 | if (skb2 == NULL) |
| 305 | return 0; | ||
| 306 | skb = skb2; | ||
| 307 | } | ||
| 301 | #endif | 308 | #endif |
| 302 | 309 | ||
| 303 | #if DUMP_PACKETS > 0 | 310 | #if DUMP_PACKETS > 0 |
| 304 | printk("%s: send datalen:%ld lecid:%4.4x\n", dev->name, | 311 | printk("%s: send datalen:%ld lecid:%4.4x\n", dev->name, |
| 305 | skb->len, priv->lecid); | 312 | skb->len, priv->lecid); |
| 306 | #if DUMP_PACKETS >= 2 | 313 | #if DUMP_PACKETS >= 2 |
| 307 | for(i=0;i<skb->len && i <99;i++) { | 314 | for (i = 0; i < skb->len && i < 99; i++) { |
| 308 | sprintf(buf+i*3,"%2.2x ",0xff&skb->data[i]); | 315 | sprintf(buf + i * 3, "%2.2x ", 0xff & skb->data[i]); |
| 309 | } | 316 | } |
| 310 | #elif DUMP_PACKETS >= 1 | 317 | #elif DUMP_PACKETS >= 1 |
| 311 | for(i=0;i<skb->len && i < 30;i++) { | 318 | for (i = 0; i < skb->len && i < 30; i++) { |
| 312 | sprintf(buf+i*3,"%2.2x ", 0xff&skb->data[i]); | 319 | sprintf(buf + i * 3, "%2.2x ", 0xff & skb->data[i]); |
| 313 | } | 320 | } |
| 314 | #endif /* DUMP_PACKETS >= 1 */ | 321 | #endif /* DUMP_PACKETS >= 1 */ |
| 315 | if (i==skb->len) | 322 | if (i == skb->len) |
| 316 | printk("%s\n",buf); | 323 | printk("%s\n", buf); |
| 317 | else | 324 | else |
| 318 | printk("%s...\n",buf); | 325 | printk("%s...\n", buf); |
| 319 | #endif /* DUMP_PACKETS > 0 */ | 326 | #endif /* DUMP_PACKETS > 0 */ |
| 320 | 327 | ||
| 321 | /* Minimum ethernet-frame size */ | 328 | /* Minimum ethernet-frame size */ |
| 322 | #ifdef CONFIG_TR | 329 | #ifdef CONFIG_TR |
| 323 | if (priv->is_trdev) | 330 | if (priv->is_trdev) |
| 324 | min_frame_size = LEC_MINIMUM_8025_SIZE; | 331 | min_frame_size = LEC_MINIMUM_8025_SIZE; |
| 325 | else | 332 | else |
| 326 | #endif | 333 | #endif |
| 327 | min_frame_size = LEC_MINIMUM_8023_SIZE; | 334 | min_frame_size = LEC_MINIMUM_8023_SIZE; |
| 328 | if (skb->len < min_frame_size) { | 335 | if (skb->len < min_frame_size) { |
| 329 | if ((skb->len + skb_tailroom(skb)) < min_frame_size) { | 336 | if ((skb->len + skb_tailroom(skb)) < min_frame_size) { |
| 330 | skb2 = skb_copy_expand(skb, 0, | 337 | skb2 = skb_copy_expand(skb, 0, |
| 331 | min_frame_size - skb->truesize, GFP_ATOMIC); | 338 | min_frame_size - skb->truesize, |
| 332 | dev_kfree_skb(skb); | 339 | GFP_ATOMIC); |
| 333 | if (skb2 == NULL) { | 340 | dev_kfree_skb(skb); |
| 334 | priv->stats.tx_dropped++; | 341 | if (skb2 == NULL) { |
| 335 | return 0; | 342 | priv->stats.tx_dropped++; |
| 336 | } | 343 | return 0; |
| 337 | skb = skb2; | 344 | } |
| 338 | } | 345 | skb = skb2; |
| 346 | } | ||
| 339 | skb_put(skb, min_frame_size - skb->len); | 347 | skb_put(skb, min_frame_size - skb->len); |
| 340 | } | 348 | } |
| 341 | 349 | ||
| 342 | /* Send to right vcc */ | 350 | /* Send to right vcc */ |
| 343 | is_rdesc = 0; | 351 | is_rdesc = 0; |
| 344 | dst = lec_h->h_dest; | 352 | dst = lec_h->h_dest; |
| 345 | #ifdef CONFIG_TR | 353 | #ifdef CONFIG_TR |
| 346 | if (priv->is_trdev) { | 354 | if (priv->is_trdev) { |
| 347 | dst = get_tr_dst(skb->data+2, rdesc); | 355 | dst = get_tr_dst(skb->data + 2, rdesc); |
| 348 | if (dst == NULL) { | 356 | if (dst == NULL) { |
| 349 | dst = rdesc; | 357 | dst = rdesc; |
| 350 | is_rdesc = 1; | 358 | is_rdesc = 1; |
| 351 | } | 359 | } |
| 352 | } | 360 | } |
| 353 | #endif | 361 | #endif |
| 354 | entry = NULL; | 362 | entry = NULL; |
| 355 | vcc = lec_arp_resolve(priv, dst, is_rdesc, &entry); | 363 | vcc = lec_arp_resolve(priv, dst, is_rdesc, &entry); |
| 356 | DPRINTK("%s:vcc:%p vcc_flags:%x, entry:%p\n", dev->name, | 364 | DPRINTK("%s:vcc:%p vcc_flags:%x, entry:%p\n", dev->name, |
| 357 | vcc, vcc?vcc->flags:0, entry); | 365 | vcc, vcc ? vcc->flags : 0, entry); |
| 358 | if (!vcc || !test_bit(ATM_VF_READY,&vcc->flags)) { | 366 | if (!vcc || !test_bit(ATM_VF_READY, &vcc->flags)) { |
| 359 | if (entry && (entry->tx_wait.qlen < LEC_UNRES_QUE_LEN)) { | 367 | if (entry && (entry->tx_wait.qlen < LEC_UNRES_QUE_LEN)) { |
| 360 | DPRINTK("%s:lec_start_xmit: queuing packet, ", dev->name); | 368 | DPRINTK("%s:lec_start_xmit: queuing packet, ", |
| 361 | DPRINTK("MAC address 0x%02x:%02x:%02x:%02x:%02x:%02x\n", | 369 | dev->name); |
| 362 | lec_h->h_dest[0], lec_h->h_dest[1], lec_h->h_dest[2], | 370 | DPRINTK("MAC address 0x%02x:%02x:%02x:%02x:%02x:%02x\n", |
| 363 | lec_h->h_dest[3], lec_h->h_dest[4], lec_h->h_dest[5]); | 371 | lec_h->h_dest[0], lec_h->h_dest[1], |
| 364 | skb_queue_tail(&entry->tx_wait, skb); | 372 | lec_h->h_dest[2], lec_h->h_dest[3], |
| 365 | } else { | 373 | lec_h->h_dest[4], lec_h->h_dest[5]); |
| 366 | DPRINTK("%s:lec_start_xmit: tx queue full or no arp entry, dropping, ", dev->name); | 374 | skb_queue_tail(&entry->tx_wait, skb); |
| 367 | DPRINTK("MAC address 0x%02x:%02x:%02x:%02x:%02x:%02x\n", | 375 | } else { |
| 368 | lec_h->h_dest[0], lec_h->h_dest[1], lec_h->h_dest[2], | 376 | DPRINTK |
| 369 | lec_h->h_dest[3], lec_h->h_dest[4], lec_h->h_dest[5]); | 377 | ("%s:lec_start_xmit: tx queue full or no arp entry, dropping, ", |
| 370 | priv->stats.tx_dropped++; | 378 | dev->name); |
| 371 | dev_kfree_skb(skb); | 379 | DPRINTK("MAC address 0x%02x:%02x:%02x:%02x:%02x:%02x\n", |
| 372 | } | 380 | lec_h->h_dest[0], lec_h->h_dest[1], |
| 373 | return 0; | 381 | lec_h->h_dest[2], lec_h->h_dest[3], |
| 374 | } | 382 | lec_h->h_dest[4], lec_h->h_dest[5]); |
| 375 | 383 | priv->stats.tx_dropped++; | |
| 376 | #if DUMP_PACKETS > 0 | 384 | dev_kfree_skb(skb); |
| 377 | printk("%s:sending to vpi:%d vci:%d\n", dev->name, | 385 | } |
| 378 | vcc->vpi, vcc->vci); | 386 | return 0; |
| 387 | } | ||
| 388 | #if DUMP_PACKETS > 0 | ||
| 389 | printk("%s:sending to vpi:%d vci:%d\n", dev->name, vcc->vpi, vcc->vci); | ||
| 379 | #endif /* DUMP_PACKETS > 0 */ | 390 | #endif /* DUMP_PACKETS > 0 */ |
| 380 | 391 | ||
| 381 | while (entry && (skb2 = skb_dequeue(&entry->tx_wait))) { | 392 | while (entry && (skb2 = skb_dequeue(&entry->tx_wait))) { |
| 382 | DPRINTK("lec.c: emptying tx queue, "); | 393 | DPRINTK("lec.c: emptying tx queue, "); |
| 383 | DPRINTK("MAC address 0x%02x:%02x:%02x:%02x:%02x:%02x\n", | 394 | DPRINTK("MAC address 0x%02x:%02x:%02x:%02x:%02x:%02x\n", |
| 384 | lec_h->h_dest[0], lec_h->h_dest[1], lec_h->h_dest[2], | 395 | lec_h->h_dest[0], lec_h->h_dest[1], lec_h->h_dest[2], |
| 385 | lec_h->h_dest[3], lec_h->h_dest[4], lec_h->h_dest[5]); | 396 | lec_h->h_dest[3], lec_h->h_dest[4], lec_h->h_dest[5]); |
| 386 | lec_send(vcc, skb2, priv); | 397 | lec_send(vcc, skb2, priv); |
| 387 | } | 398 | } |
| 388 | 399 | ||
| 389 | lec_send(vcc, skb, priv); | 400 | lec_send(vcc, skb, priv); |
| 390 | 401 | ||
| @@ -405,209 +416,215 @@ lec_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
| 405 | } | 416 | } |
| 406 | 417 | ||
| 407 | dev->trans_start = jiffies; | 418 | dev->trans_start = jiffies; |
| 408 | return 0; | 419 | return 0; |
| 409 | } | 420 | } |
| 410 | 421 | ||
| 411 | /* The inverse routine to net_open(). */ | 422 | /* The inverse routine to net_open(). */ |
| 412 | static int | 423 | static int lec_close(struct net_device *dev) |
| 413 | lec_close(struct net_device *dev) | ||
| 414 | { | 424 | { |
| 415 | netif_stop_queue(dev); | 425 | netif_stop_queue(dev); |
| 416 | return 0; | 426 | return 0; |
| 417 | } | 427 | } |
| 418 | 428 | ||
| 419 | /* | 429 | /* |
| 420 | * Get the current statistics. | 430 | * Get the current statistics. |
| 421 | * This may be called with the card open or closed. | 431 | * This may be called with the card open or closed. |
| 422 | */ | 432 | */ |
| 423 | static struct net_device_stats * | 433 | static struct net_device_stats *lec_get_stats(struct net_device *dev) |
| 424 | lec_get_stats(struct net_device *dev) | ||
| 425 | { | 434 | { |
| 426 | return &((struct lec_priv *)dev->priv)->stats; | 435 | return &((struct lec_priv *)dev->priv)->stats; |
| 427 | } | 436 | } |
| 428 | 437 | ||
| 429 | static int | 438 | static int lec_atm_send(struct atm_vcc *vcc, struct sk_buff *skb) |
| 430 | lec_atm_send(struct atm_vcc *vcc, struct sk_buff *skb) | ||
| 431 | { | 439 | { |
| 432 | unsigned long flags; | 440 | unsigned long flags; |
| 433 | struct net_device *dev = (struct net_device*)vcc->proto_data; | 441 | struct net_device *dev = (struct net_device *)vcc->proto_data; |
| 434 | struct lec_priv *priv = (struct lec_priv*)dev->priv; | 442 | struct lec_priv *priv = (struct lec_priv *)dev->priv; |
| 435 | struct atmlec_msg *mesg; | 443 | struct atmlec_msg *mesg; |
| 436 | struct lec_arp_table *entry; | 444 | struct lec_arp_table *entry; |
| 437 | int i; | 445 | int i; |
| 438 | char *tmp; /* FIXME */ | 446 | char *tmp; /* FIXME */ |
| 439 | 447 | ||
| 440 | atomic_sub(skb->truesize, &sk_atm(vcc)->sk_wmem_alloc); | 448 | atomic_sub(skb->truesize, &sk_atm(vcc)->sk_wmem_alloc); |
| 441 | mesg = (struct atmlec_msg *)skb->data; | 449 | mesg = (struct atmlec_msg *)skb->data; |
| 442 | tmp = skb->data; | 450 | tmp = skb->data; |
| 443 | tmp += sizeof(struct atmlec_msg); | 451 | tmp += sizeof(struct atmlec_msg); |
| 444 | DPRINTK("%s: msg from zeppelin:%d\n", dev->name, mesg->type); | 452 | DPRINTK("%s: msg from zeppelin:%d\n", dev->name, mesg->type); |
| 445 | switch(mesg->type) { | 453 | switch (mesg->type) { |
| 446 | case l_set_mac_addr: | 454 | case l_set_mac_addr: |
| 447 | for (i=0;i<6;i++) { | 455 | for (i = 0; i < 6; i++) { |
| 448 | dev->dev_addr[i] = mesg->content.normal.mac_addr[i]; | 456 | dev->dev_addr[i] = mesg->content.normal.mac_addr[i]; |
| 449 | } | 457 | } |
| 450 | break; | 458 | break; |
| 451 | case l_del_mac_addr: | 459 | case l_del_mac_addr: |
| 452 | for(i=0;i<6;i++) { | 460 | for (i = 0; i < 6; i++) { |
| 453 | dev->dev_addr[i] = 0; | 461 | dev->dev_addr[i] = 0; |
| 454 | } | 462 | } |
| 455 | break; | 463 | break; |
| 456 | case l_addr_delete: | 464 | case l_addr_delete: |
| 457 | lec_addr_delete(priv, mesg->content.normal.atm_addr, | 465 | lec_addr_delete(priv, mesg->content.normal.atm_addr, |
| 458 | mesg->content.normal.flag); | 466 | mesg->content.normal.flag); |
| 459 | break; | 467 | break; |
| 460 | case l_topology_change: | 468 | case l_topology_change: |
| 461 | priv->topology_change = mesg->content.normal.flag; | 469 | priv->topology_change = mesg->content.normal.flag; |
| 462 | break; | 470 | break; |
| 463 | case l_flush_complete: | 471 | case l_flush_complete: |
| 464 | lec_flush_complete(priv, mesg->content.normal.flag); | 472 | lec_flush_complete(priv, mesg->content.normal.flag); |
| 465 | break; | 473 | break; |
| 466 | case l_narp_req: /* LANE2: see 7.1.35 in the lane2 spec */ | 474 | case l_narp_req: /* LANE2: see 7.1.35 in the lane2 spec */ |
| 467 | spin_lock_irqsave(&priv->lec_arp_lock, flags); | 475 | spin_lock_irqsave(&priv->lec_arp_lock, flags); |
| 468 | entry = lec_arp_find(priv, mesg->content.normal.mac_addr); | 476 | entry = lec_arp_find(priv, mesg->content.normal.mac_addr); |
| 469 | lec_arp_remove(priv, entry); | 477 | lec_arp_remove(priv, entry); |
| 470 | spin_unlock_irqrestore(&priv->lec_arp_lock, flags); | 478 | spin_unlock_irqrestore(&priv->lec_arp_lock, flags); |
| 471 | 479 | ||
| 472 | if (mesg->content.normal.no_source_le_narp) | 480 | if (mesg->content.normal.no_source_le_narp) |
| 473 | break; | 481 | break; |
| 474 | /* FALL THROUGH */ | 482 | /* FALL THROUGH */ |
| 475 | case l_arp_update: | 483 | case l_arp_update: |
| 476 | lec_arp_update(priv, mesg->content.normal.mac_addr, | 484 | lec_arp_update(priv, mesg->content.normal.mac_addr, |
| 477 | mesg->content.normal.atm_addr, | 485 | mesg->content.normal.atm_addr, |
| 478 | mesg->content.normal.flag, | 486 | mesg->content.normal.flag, |
| 479 | mesg->content.normal.targetless_le_arp); | 487 | mesg->content.normal.targetless_le_arp); |
| 480 | DPRINTK("lec: in l_arp_update\n"); | 488 | DPRINTK("lec: in l_arp_update\n"); |
| 481 | if (mesg->sizeoftlvs != 0) { /* LANE2 3.1.5 */ | 489 | if (mesg->sizeoftlvs != 0) { /* LANE2 3.1.5 */ |
| 482 | DPRINTK("lec: LANE2 3.1.5, got tlvs, size %d\n", mesg->sizeoftlvs); | 490 | DPRINTK("lec: LANE2 3.1.5, got tlvs, size %d\n", |
| 483 | lane2_associate_ind(dev, | 491 | mesg->sizeoftlvs); |
| 484 | mesg->content.normal.mac_addr, | 492 | lane2_associate_ind(dev, mesg->content.normal.mac_addr, |
| 485 | tmp, mesg->sizeoftlvs); | 493 | tmp, mesg->sizeoftlvs); |
| 486 | } | 494 | } |
| 487 | break; | 495 | break; |
| 488 | case l_config: | 496 | case l_config: |
| 489 | priv->maximum_unknown_frame_count = | 497 | priv->maximum_unknown_frame_count = |
| 490 | mesg->content.config.maximum_unknown_frame_count; | 498 | mesg->content.config.maximum_unknown_frame_count; |
| 491 | priv->max_unknown_frame_time = | 499 | priv->max_unknown_frame_time = |
| 492 | (mesg->content.config.max_unknown_frame_time*HZ); | 500 | (mesg->content.config.max_unknown_frame_time * HZ); |
| 493 | priv->max_retry_count = | 501 | priv->max_retry_count = mesg->content.config.max_retry_count; |
| 494 | mesg->content.config.max_retry_count; | 502 | priv->aging_time = (mesg->content.config.aging_time * HZ); |
| 495 | priv->aging_time = (mesg->content.config.aging_time*HZ); | 503 | priv->forward_delay_time = |
| 496 | priv->forward_delay_time = | 504 | (mesg->content.config.forward_delay_time * HZ); |
| 497 | (mesg->content.config.forward_delay_time*HZ); | 505 | priv->arp_response_time = |
| 498 | priv->arp_response_time = | 506 | (mesg->content.config.arp_response_time * HZ); |
| 499 | (mesg->content.config.arp_response_time*HZ); | 507 | priv->flush_timeout = (mesg->content.config.flush_timeout * HZ); |
| 500 | priv->flush_timeout = (mesg->content.config.flush_timeout*HZ); | 508 | priv->path_switching_delay = |
| 501 | priv->path_switching_delay = | 509 | (mesg->content.config.path_switching_delay * HZ); |
| 502 | (mesg->content.config.path_switching_delay*HZ); | 510 | priv->lane_version = mesg->content.config.lane_version; /* LANE2 */ |
| 503 | priv->lane_version = mesg->content.config.lane_version; /* LANE2 */ | ||
| 504 | priv->lane2_ops = NULL; | 511 | priv->lane2_ops = NULL; |
| 505 | if (priv->lane_version > 1) | 512 | if (priv->lane_version > 1) |
| 506 | priv->lane2_ops = &lane2_ops; | 513 | priv->lane2_ops = &lane2_ops; |
| 507 | if (dev->change_mtu(dev, mesg->content.config.mtu)) | 514 | if (dev->change_mtu(dev, mesg->content.config.mtu)) |
| 508 | printk("%s: change_mtu to %d failed\n", dev->name, | 515 | printk("%s: change_mtu to %d failed\n", dev->name, |
| 509 | mesg->content.config.mtu); | 516 | mesg->content.config.mtu); |
| 510 | priv->is_proxy = mesg->content.config.is_proxy; | 517 | priv->is_proxy = mesg->content.config.is_proxy; |
| 511 | break; | 518 | break; |
| 512 | case l_flush_tran_id: | 519 | case l_flush_tran_id: |
| 513 | lec_set_flush_tran_id(priv, mesg->content.normal.atm_addr, | 520 | lec_set_flush_tran_id(priv, mesg->content.normal.atm_addr, |
| 514 | mesg->content.normal.flag); | 521 | mesg->content.normal.flag); |
| 515 | break; | 522 | break; |
| 516 | case l_set_lecid: | 523 | case l_set_lecid: |
| 517 | priv->lecid=(unsigned short)(0xffff&mesg->content.normal.flag); | 524 | priv->lecid = |
| 518 | break; | 525 | (unsigned short)(0xffff & mesg->content.normal.flag); |
| 519 | case l_should_bridge: { | 526 | break; |
| 527 | case l_should_bridge: | ||
| 520 | #if defined(CONFIG_BRIDGE) || defined(CONFIG_BRIDGE_MODULE) | 528 | #if defined(CONFIG_BRIDGE) || defined(CONFIG_BRIDGE_MODULE) |
| 521 | struct net_bridge_fdb_entry *f; | 529 | { |
| 522 | 530 | struct net_bridge_fdb_entry *f; | |
| 523 | DPRINTK("%s: bridge zeppelin asks about 0x%02x:%02x:%02x:%02x:%02x:%02x\n", | 531 | |
| 524 | dev->name, | 532 | DPRINTK |
| 525 | mesg->content.proxy.mac_addr[0], mesg->content.proxy.mac_addr[1], | 533 | ("%s: bridge zeppelin asks about 0x%02x:%02x:%02x:%02x:%02x:%02x\n", |
| 526 | mesg->content.proxy.mac_addr[2], mesg->content.proxy.mac_addr[3], | 534 | dev->name, mesg->content.proxy.mac_addr[0], |
| 527 | mesg->content.proxy.mac_addr[4], mesg->content.proxy.mac_addr[5]); | 535 | mesg->content.proxy.mac_addr[1], |
| 528 | 536 | mesg->content.proxy.mac_addr[2], | |
| 529 | if (br_fdb_get_hook == NULL || dev->br_port == NULL) | 537 | mesg->content.proxy.mac_addr[3], |
| 530 | break; | 538 | mesg->content.proxy.mac_addr[4], |
| 531 | 539 | mesg->content.proxy.mac_addr[5]); | |
| 532 | f = br_fdb_get_hook(dev->br_port->br, mesg->content.proxy.mac_addr); | 540 | |
| 533 | if (f != NULL && | 541 | if (br_fdb_get_hook == NULL || dev->br_port == NULL) |
| 534 | f->dst->dev != dev && | 542 | break; |
| 535 | f->dst->state == BR_STATE_FORWARDING) { | 543 | |
| 536 | /* hit from bridge table, send LE_ARP_RESPONSE */ | 544 | f = br_fdb_get_hook(dev->br_port->br, |
| 537 | struct sk_buff *skb2; | 545 | mesg->content.proxy.mac_addr); |
| 538 | struct sock *sk; | 546 | if (f != NULL && f->dst->dev != dev |
| 539 | 547 | && f->dst->state == BR_STATE_FORWARDING) { | |
| 540 | DPRINTK("%s: entry found, responding to zeppelin\n", dev->name); | 548 | /* hit from bridge table, send LE_ARP_RESPONSE */ |
| 541 | skb2 = alloc_skb(sizeof(struct atmlec_msg), GFP_ATOMIC); | 549 | struct sk_buff *skb2; |
| 542 | if (skb2 == NULL) { | 550 | struct sock *sk; |
| 543 | br_fdb_put_hook(f); | 551 | |
| 544 | break; | 552 | DPRINTK |
| 545 | } | 553 | ("%s: entry found, responding to zeppelin\n", |
| 546 | skb2->len = sizeof(struct atmlec_msg); | 554 | dev->name); |
| 547 | memcpy(skb2->data, mesg, sizeof(struct atmlec_msg)); | 555 | skb2 = |
| 548 | atm_force_charge(priv->lecd, skb2->truesize); | 556 | alloc_skb(sizeof(struct atmlec_msg), |
| 549 | sk = sk_atm(priv->lecd); | 557 | GFP_ATOMIC); |
| 550 | skb_queue_tail(&sk->sk_receive_queue, skb2); | 558 | if (skb2 == NULL) { |
| 551 | sk->sk_data_ready(sk, skb2->len); | 559 | br_fdb_put_hook(f); |
| 552 | } | 560 | break; |
| 553 | if (f != NULL) br_fdb_put_hook(f); | 561 | } |
| 562 | skb2->len = sizeof(struct atmlec_msg); | ||
| 563 | memcpy(skb2->data, mesg, | ||
| 564 | sizeof(struct atmlec_msg)); | ||
| 565 | atm_force_charge(priv->lecd, skb2->truesize); | ||
| 566 | sk = sk_atm(priv->lecd); | ||
| 567 | skb_queue_tail(&sk->sk_receive_queue, skb2); | ||
| 568 | sk->sk_data_ready(sk, skb2->len); | ||
| 569 | } | ||
| 570 | if (f != NULL) | ||
| 571 | br_fdb_put_hook(f); | ||
| 572 | } | ||
| 554 | #endif /* defined(CONFIG_BRIDGE) || defined(CONFIG_BRIDGE_MODULE) */ | 573 | #endif /* defined(CONFIG_BRIDGE) || defined(CONFIG_BRIDGE_MODULE) */ |
| 555 | } | 574 | break; |
| 556 | break; | 575 | default: |
| 557 | default: | 576 | printk("%s: Unknown message type %d\n", dev->name, mesg->type); |
| 558 | printk("%s: Unknown message type %d\n", dev->name, mesg->type); | 577 | dev_kfree_skb(skb); |
| 559 | dev_kfree_skb(skb); | 578 | return -EINVAL; |
| 560 | return -EINVAL; | 579 | } |
| 561 | } | 580 | dev_kfree_skb(skb); |
| 562 | dev_kfree_skb(skb); | 581 | return 0; |
| 563 | return 0; | ||
| 564 | } | 582 | } |
| 565 | 583 | ||
| 566 | static void | 584 | static void lec_atm_close(struct atm_vcc *vcc) |
| 567 | lec_atm_close(struct atm_vcc *vcc) | ||
| 568 | { | 585 | { |
| 569 | struct sk_buff *skb; | 586 | struct sk_buff *skb; |
| 570 | struct net_device *dev = (struct net_device *)vcc->proto_data; | 587 | struct net_device *dev = (struct net_device *)vcc->proto_data; |
| 571 | struct lec_priv *priv = (struct lec_priv *)dev->priv; | 588 | struct lec_priv *priv = (struct lec_priv *)dev->priv; |
| 572 | 589 | ||
| 573 | priv->lecd = NULL; | 590 | priv->lecd = NULL; |
| 574 | /* Do something needful? */ | 591 | /* Do something needful? */ |
| 575 | 592 | ||
| 576 | netif_stop_queue(dev); | 593 | netif_stop_queue(dev); |
| 577 | lec_arp_destroy(priv); | 594 | lec_arp_destroy(priv); |
| 578 | 595 | ||
| 579 | if (skb_peek(&sk_atm(vcc)->sk_receive_queue)) | 596 | if (skb_peek(&sk_atm(vcc)->sk_receive_queue)) |
| 580 | printk("%s lec_atm_close: closing with messages pending\n", | 597 | printk("%s lec_atm_close: closing with messages pending\n", |
| 581 | dev->name); | 598 | dev->name); |
| 582 | while ((skb = skb_dequeue(&sk_atm(vcc)->sk_receive_queue)) != NULL) { | 599 | while ((skb = skb_dequeue(&sk_atm(vcc)->sk_receive_queue)) != NULL) { |
| 583 | atm_return(vcc, skb->truesize); | 600 | atm_return(vcc, skb->truesize); |
| 584 | dev_kfree_skb(skb); | 601 | dev_kfree_skb(skb); |
| 585 | } | 602 | } |
| 586 | 603 | ||
| 587 | printk("%s: Shut down!\n", dev->name); | 604 | printk("%s: Shut down!\n", dev->name); |
| 588 | module_put(THIS_MODULE); | 605 | module_put(THIS_MODULE); |
| 589 | } | 606 | } |
| 590 | 607 | ||
| 591 | static struct atmdev_ops lecdev_ops = { | 608 | static struct atmdev_ops lecdev_ops = { |
| 592 | .close = lec_atm_close, | 609 | .close = lec_atm_close, |
| 593 | .send = lec_atm_send | 610 | .send = lec_atm_send |
| 594 | }; | 611 | }; |
| 595 | 612 | ||
| 596 | static struct atm_dev lecatm_dev = { | 613 | static struct atm_dev lecatm_dev = { |
| 597 | .ops = &lecdev_ops, | 614 | .ops = &lecdev_ops, |
| 598 | .type = "lec", | 615 | .type = "lec", |
| 599 | .number = 999, /* dummy device number */ | 616 | .number = 999, /* dummy device number */ |
| 600 | .lock = SPIN_LOCK_UNLOCKED | 617 | .lock = SPIN_LOCK_UNLOCKED |
| 601 | }; | 618 | }; |
| 602 | 619 | ||
| 603 | /* | 620 | /* |
| 604 | * LANE2: new argument struct sk_buff *data contains | 621 | * LANE2: new argument struct sk_buff *data contains |
| 605 | * the LE_ARP based TLVs introduced in the LANE2 spec | 622 | * the LE_ARP based TLVs introduced in the LANE2 spec |
| 606 | */ | 623 | */ |
| 607 | static int | 624 | static int |
| 608 | send_to_lecd(struct lec_priv *priv, atmlec_msg_type type, | 625 | send_to_lecd(struct lec_priv *priv, atmlec_msg_type type, |
| 609 | unsigned char *mac_addr, unsigned char *atm_addr, | 626 | unsigned char *mac_addr, unsigned char *atm_addr, |
| 610 | struct sk_buff *data) | 627 | struct sk_buff *data) |
| 611 | { | 628 | { |
| 612 | struct sock *sk; | 629 | struct sock *sk; |
| 613 | struct sk_buff *skb; | 630 | struct sk_buff *skb; |
| @@ -621,154 +638,160 @@ send_to_lecd(struct lec_priv *priv, atmlec_msg_type type, | |||
| 621 | return -1; | 638 | return -1; |
| 622 | skb->len = sizeof(struct atmlec_msg); | 639 | skb->len = sizeof(struct atmlec_msg); |
| 623 | mesg = (struct atmlec_msg *)skb->data; | 640 | mesg = (struct atmlec_msg *)skb->data; |
| 624 | memset(mesg, 0, sizeof(struct atmlec_msg)); | 641 | memset(mesg, 0, sizeof(struct atmlec_msg)); |
| 625 | mesg->type = type; | 642 | mesg->type = type; |
| 626 | if (data != NULL) | 643 | if (data != NULL) |
| 627 | mesg->sizeoftlvs = data->len; | 644 | mesg->sizeoftlvs = data->len; |
| 628 | if (mac_addr) | 645 | if (mac_addr) |
| 629 | memcpy(&mesg->content.normal.mac_addr, mac_addr, ETH_ALEN); | 646 | memcpy(&mesg->content.normal.mac_addr, mac_addr, ETH_ALEN); |
| 630 | else | 647 | else |
| 631 | mesg->content.normal.targetless_le_arp = 1; | 648 | mesg->content.normal.targetless_le_arp = 1; |
| 632 | if (atm_addr) | 649 | if (atm_addr) |
| 633 | memcpy(&mesg->content.normal.atm_addr, atm_addr, ATM_ESA_LEN); | 650 | memcpy(&mesg->content.normal.atm_addr, atm_addr, ATM_ESA_LEN); |
| 634 | 651 | ||
| 635 | atm_force_charge(priv->lecd, skb->truesize); | 652 | atm_force_charge(priv->lecd, skb->truesize); |
| 636 | sk = sk_atm(priv->lecd); | 653 | sk = sk_atm(priv->lecd); |
| 637 | skb_queue_tail(&sk->sk_receive_queue, skb); | 654 | skb_queue_tail(&sk->sk_receive_queue, skb); |
| 638 | sk->sk_data_ready(sk, skb->len); | 655 | sk->sk_data_ready(sk, skb->len); |
| 639 | 656 | ||
| 640 | if (data != NULL) { | 657 | if (data != NULL) { |
| 641 | DPRINTK("lec: about to send %d bytes of data\n", data->len); | 658 | DPRINTK("lec: about to send %d bytes of data\n", data->len); |
| 642 | atm_force_charge(priv->lecd, data->truesize); | 659 | atm_force_charge(priv->lecd, data->truesize); |
| 643 | skb_queue_tail(&sk->sk_receive_queue, data); | 660 | skb_queue_tail(&sk->sk_receive_queue, data); |
| 644 | sk->sk_data_ready(sk, skb->len); | 661 | sk->sk_data_ready(sk, skb->len); |
| 645 | } | 662 | } |
| 646 | 663 | ||
| 647 | return 0; | 664 | return 0; |
| 648 | } | 665 | } |
| 649 | 666 | ||
| 650 | /* shamelessly stolen from drivers/net/net_init.c */ | 667 | /* shamelessly stolen from drivers/net/net_init.c */ |
| 651 | static int lec_change_mtu(struct net_device *dev, int new_mtu) | 668 | static int lec_change_mtu(struct net_device *dev, int new_mtu) |
| 652 | { | 669 | { |
| 653 | if ((new_mtu < 68) || (new_mtu > 18190)) | 670 | if ((new_mtu < 68) || (new_mtu > 18190)) |
| 654 | return -EINVAL; | 671 | return -EINVAL; |
| 655 | dev->mtu = new_mtu; | 672 | dev->mtu = new_mtu; |
| 656 | return 0; | 673 | return 0; |
| 657 | } | 674 | } |
| 658 | 675 | ||
| 659 | static void lec_set_multicast_list(struct net_device *dev) | 676 | static void lec_set_multicast_list(struct net_device *dev) |
| 660 | { | 677 | { |
| 661 | /* by default, all multicast frames arrive over the bus. | 678 | /* |
| 662 | * eventually support selective multicast service | 679 | * by default, all multicast frames arrive over the bus. |
| 663 | */ | 680 | * eventually support selective multicast service |
| 664 | return; | 681 | */ |
| 682 | return; | ||
| 665 | } | 683 | } |
| 666 | 684 | ||
| 667 | static void | 685 | static void lec_init(struct net_device *dev) |
| 668 | lec_init(struct net_device *dev) | ||
| 669 | { | 686 | { |
| 670 | dev->change_mtu = lec_change_mtu; | 687 | dev->change_mtu = lec_change_mtu; |
| 671 | dev->open = lec_open; | 688 | dev->open = lec_open; |
| 672 | dev->stop = lec_close; | 689 | dev->stop = lec_close; |
| 673 | dev->hard_start_xmit = lec_start_xmit; | 690 | dev->hard_start_xmit = lec_start_xmit; |
| 674 | dev->tx_timeout = lec_tx_timeout; | 691 | dev->tx_timeout = lec_tx_timeout; |
| 675 | 692 | ||
| 676 | dev->get_stats = lec_get_stats; | 693 | dev->get_stats = lec_get_stats; |
| 677 | dev->set_multicast_list = lec_set_multicast_list; | 694 | dev->set_multicast_list = lec_set_multicast_list; |
| 678 | dev->do_ioctl = NULL; | 695 | dev->do_ioctl = NULL; |
| 679 | printk("%s: Initialized!\n",dev->name); | 696 | printk("%s: Initialized!\n", dev->name); |
| 680 | return; | 697 | return; |
| 681 | } | 698 | } |
| 682 | 699 | ||
| 683 | static unsigned char lec_ctrl_magic[] = { | 700 | static unsigned char lec_ctrl_magic[] = { |
| 684 | 0xff, | 701 | 0xff, |
| 685 | 0x00, | 702 | 0x00, |
| 686 | 0x01, | 703 | 0x01, |
| 687 | 0x01 }; | 704 | 0x01 |
| 705 | }; | ||
| 688 | 706 | ||
| 689 | #define LEC_DATA_DIRECT_8023 2 | 707 | #define LEC_DATA_DIRECT_8023 2 |
| 690 | #define LEC_DATA_DIRECT_8025 3 | 708 | #define LEC_DATA_DIRECT_8025 3 |
| 691 | 709 | ||
| 692 | static int lec_is_data_direct(struct atm_vcc *vcc) | 710 | static int lec_is_data_direct(struct atm_vcc *vcc) |
| 693 | { | 711 | { |
| 694 | return ((vcc->sap.blli[0].l3.tr9577.snap[4] == LEC_DATA_DIRECT_8023) || | 712 | return ((vcc->sap.blli[0].l3.tr9577.snap[4] == LEC_DATA_DIRECT_8023) || |
| 695 | (vcc->sap.blli[0].l3.tr9577.snap[4] == LEC_DATA_DIRECT_8025)); | 713 | (vcc->sap.blli[0].l3.tr9577.snap[4] == LEC_DATA_DIRECT_8025)); |
| 696 | } | 714 | } |
| 697 | 715 | ||
| 698 | static void | 716 | static void lec_push(struct atm_vcc *vcc, struct sk_buff *skb) |
| 699 | lec_push(struct atm_vcc *vcc, struct sk_buff *skb) | ||
| 700 | { | 717 | { |
| 701 | unsigned long flags; | 718 | unsigned long flags; |
| 702 | struct net_device *dev = (struct net_device *)vcc->proto_data; | 719 | struct net_device *dev = (struct net_device *)vcc->proto_data; |
| 703 | struct lec_priv *priv = (struct lec_priv *)dev->priv; | 720 | struct lec_priv *priv = (struct lec_priv *)dev->priv; |
| 704 | 721 | ||
| 705 | #if DUMP_PACKETS >0 | 722 | #if DUMP_PACKETS >0 |
| 706 | int i=0; | 723 | int i = 0; |
| 707 | char buf[300]; | 724 | char buf[300]; |
| 708 | 725 | ||
| 709 | printk("%s: lec_push vcc vpi:%d vci:%d\n", dev->name, | 726 | printk("%s: lec_push vcc vpi:%d vci:%d\n", dev->name, |
| 710 | vcc->vpi, vcc->vci); | 727 | vcc->vpi, vcc->vci); |
| 711 | #endif | 728 | #endif |
| 712 | if (!skb) { | 729 | if (!skb) { |
| 713 | DPRINTK("%s: null skb\n",dev->name); | 730 | DPRINTK("%s: null skb\n", dev->name); |
| 714 | lec_vcc_close(priv, vcc); | 731 | lec_vcc_close(priv, vcc); |
| 715 | return; | 732 | return; |
| 716 | } | 733 | } |
| 717 | #if DUMP_PACKETS > 0 | 734 | #if DUMP_PACKETS > 0 |
| 718 | printk("%s: rcv datalen:%ld lecid:%4.4x\n", dev->name, | 735 | printk("%s: rcv datalen:%ld lecid:%4.4x\n", dev->name, |
| 719 | skb->len, priv->lecid); | 736 | skb->len, priv->lecid); |
| 720 | #if DUMP_PACKETS >= 2 | 737 | #if DUMP_PACKETS >= 2 |
| 721 | for(i=0;i<skb->len && i <99;i++) { | 738 | for (i = 0; i < skb->len && i < 99; i++) { |
| 722 | sprintf(buf+i*3,"%2.2x ",0xff&skb->data[i]); | 739 | sprintf(buf + i * 3, "%2.2x ", 0xff & skb->data[i]); |
| 723 | } | 740 | } |
| 724 | #elif DUMP_PACKETS >= 1 | 741 | #elif DUMP_PACKETS >= 1 |
| 725 | for(i=0;i<skb->len && i < 30;i++) { | 742 | for (i = 0; i < skb->len && i < 30; i++) { |
| 726 | sprintf(buf+i*3,"%2.2x ", 0xff&skb->data[i]); | 743 | sprintf(buf + i * 3, "%2.2x ", 0xff & skb->data[i]); |
| 727 | } | 744 | } |
| 728 | #endif /* DUMP_PACKETS >= 1 */ | 745 | #endif /* DUMP_PACKETS >= 1 */ |
| 729 | if (i==skb->len) | 746 | if (i == skb->len) |
| 730 | printk("%s\n",buf); | 747 | printk("%s\n", buf); |
| 731 | else | 748 | else |
| 732 | printk("%s...\n",buf); | 749 | printk("%s...\n", buf); |
| 733 | #endif /* DUMP_PACKETS > 0 */ | 750 | #endif /* DUMP_PACKETS > 0 */ |
| 734 | if (memcmp(skb->data, lec_ctrl_magic, 4) ==0) { /* Control frame, to daemon*/ | 751 | if (memcmp(skb->data, lec_ctrl_magic, 4) == 0) { /* Control frame, to daemon */ |
| 735 | struct sock *sk = sk_atm(vcc); | 752 | struct sock *sk = sk_atm(vcc); |
| 736 | 753 | ||
| 737 | DPRINTK("%s: To daemon\n",dev->name); | 754 | DPRINTK("%s: To daemon\n", dev->name); |
| 738 | skb_queue_tail(&sk->sk_receive_queue, skb); | 755 | skb_queue_tail(&sk->sk_receive_queue, skb); |
| 739 | sk->sk_data_ready(sk, skb->len); | 756 | sk->sk_data_ready(sk, skb->len); |
| 740 | } else { /* Data frame, queue to protocol handlers */ | 757 | } else { /* Data frame, queue to protocol handlers */ |
| 741 | struct lec_arp_table *entry; | 758 | struct lec_arp_table *entry; |
| 742 | unsigned char *src, *dst; | 759 | unsigned char *src, *dst; |
| 743 | 760 | ||
| 744 | atm_return(vcc,skb->truesize); | 761 | atm_return(vcc, skb->truesize); |
| 745 | if (*(uint16_t *)skb->data == htons(priv->lecid) || | 762 | if (*(uint16_t *) skb->data == htons(priv->lecid) || |
| 746 | !priv->lecd || | 763 | !priv->lecd || !(dev->flags & IFF_UP)) { |
| 747 | !(dev->flags & IFF_UP)) { | 764 | /* |
| 748 | /* Probably looping back, or if lecd is missing, | 765 | * Probably looping back, or if lecd is missing, |
| 749 | lecd has gone down */ | 766 | * lecd has gone down |
| 750 | DPRINTK("Ignoring frame...\n"); | 767 | */ |
| 751 | dev_kfree_skb(skb); | 768 | DPRINTK("Ignoring frame...\n"); |
| 752 | return; | 769 | dev_kfree_skb(skb); |
| 753 | } | 770 | return; |
| 771 | } | ||
| 754 | #ifdef CONFIG_TR | 772 | #ifdef CONFIG_TR |
| 755 | if (priv->is_trdev) | 773 | if (priv->is_trdev) |
| 756 | dst = ((struct lecdatahdr_8025 *) skb->data)->h_dest; | 774 | dst = ((struct lecdatahdr_8025 *)skb->data)->h_dest; |
| 757 | else | 775 | else |
| 758 | #endif | 776 | #endif |
| 759 | dst = ((struct lecdatahdr_8023 *) skb->data)->h_dest; | 777 | dst = ((struct lecdatahdr_8023 *)skb->data)->h_dest; |
| 760 | 778 | ||
| 761 | /* If this is a Data Direct VCC, and the VCC does not match | 779 | /* |
| 780 | * If this is a Data Direct VCC, and the VCC does not match | ||
| 762 | * the LE_ARP cache entry, delete the LE_ARP cache entry. | 781 | * the LE_ARP cache entry, delete the LE_ARP cache entry. |
| 763 | */ | 782 | */ |
| 764 | spin_lock_irqsave(&priv->lec_arp_lock, flags); | 783 | spin_lock_irqsave(&priv->lec_arp_lock, flags); |
| 765 | if (lec_is_data_direct(vcc)) { | 784 | if (lec_is_data_direct(vcc)) { |
| 766 | #ifdef CONFIG_TR | 785 | #ifdef CONFIG_TR |
| 767 | if (priv->is_trdev) | 786 | if (priv->is_trdev) |
| 768 | src = ((struct lecdatahdr_8025 *) skb->data)->h_source; | 787 | src = |
| 788 | ((struct lecdatahdr_8025 *)skb->data)-> | ||
| 789 | h_source; | ||
| 769 | else | 790 | else |
| 770 | #endif | 791 | #endif |
| 771 | src = ((struct lecdatahdr_8023 *) skb->data)->h_source; | 792 | src = |
| 793 | ((struct lecdatahdr_8023 *)skb->data)-> | ||
| 794 | h_source; | ||
| 772 | entry = lec_arp_find(priv, src); | 795 | entry = lec_arp_find(priv, src); |
| 773 | if (entry && entry->vcc != vcc) { | 796 | if (entry && entry->vcc != vcc) { |
| 774 | lec_arp_remove(priv, entry); | 797 | lec_arp_remove(priv, entry); |
| @@ -777,31 +800,31 @@ lec_push(struct atm_vcc *vcc, struct sk_buff *skb) | |||
| 777 | } | 800 | } |
| 778 | spin_unlock_irqrestore(&priv->lec_arp_lock, flags); | 801 | spin_unlock_irqrestore(&priv->lec_arp_lock, flags); |
| 779 | 802 | ||
| 780 | if (!(dst[0]&0x01) && /* Never filter Multi/Broadcast */ | 803 | if (!(dst[0] & 0x01) && /* Never filter Multi/Broadcast */ |
| 781 | !priv->is_proxy && /* Proxy wants all the packets */ | 804 | !priv->is_proxy && /* Proxy wants all the packets */ |
| 782 | memcmp(dst, dev->dev_addr, dev->addr_len)) { | 805 | memcmp(dst, dev->dev_addr, dev->addr_len)) { |
| 783 | dev_kfree_skb(skb); | 806 | dev_kfree_skb(skb); |
| 784 | return; | 807 | return; |
| 785 | } | 808 | } |
| 786 | if (priv->lec_arp_empty_ones) { | 809 | if (priv->lec_arp_empty_ones) { |
| 787 | lec_arp_check_empties(priv, vcc, skb); | 810 | lec_arp_check_empties(priv, vcc, skb); |
| 788 | } | 811 | } |
| 789 | skb->dev = dev; | 812 | skb->dev = dev; |
| 790 | skb_pull(skb, 2); /* skip lec_id */ | 813 | skb_pull(skb, 2); /* skip lec_id */ |
| 791 | #ifdef CONFIG_TR | 814 | #ifdef CONFIG_TR |
| 792 | if (priv->is_trdev) skb->protocol = tr_type_trans(skb, dev); | 815 | if (priv->is_trdev) |
| 793 | else | 816 | skb->protocol = tr_type_trans(skb, dev); |
| 817 | else | ||
| 794 | #endif | 818 | #endif |
| 795 | skb->protocol = eth_type_trans(skb, dev); | 819 | skb->protocol = eth_type_trans(skb, dev); |
| 796 | priv->stats.rx_packets++; | 820 | priv->stats.rx_packets++; |
| 797 | priv->stats.rx_bytes += skb->len; | 821 | priv->stats.rx_bytes += skb->len; |
| 798 | memset(ATM_SKB(skb), 0, sizeof(struct atm_skb_data)); | 822 | memset(ATM_SKB(skb), 0, sizeof(struct atm_skb_data)); |
| 799 | netif_rx(skb); | 823 | netif_rx(skb); |
| 800 | } | 824 | } |
| 801 | } | 825 | } |
| 802 | 826 | ||
| 803 | static void | 827 | static void lec_pop(struct atm_vcc *vcc, struct sk_buff *skb) |
| 804 | lec_pop(struct atm_vcc *vcc, struct sk_buff *skb) | ||
| 805 | { | 828 | { |
| 806 | struct lec_vcc_priv *vpriv = LEC_VCC_PRIV(vcc); | 829 | struct lec_vcc_priv *vpriv = LEC_VCC_PRIV(vcc); |
| 807 | struct net_device *dev = skb->dev; | 830 | struct net_device *dev = skb->dev; |
| @@ -820,123 +843,121 @@ lec_pop(struct atm_vcc *vcc, struct sk_buff *skb) | |||
| 820 | } | 843 | } |
| 821 | } | 844 | } |
| 822 | 845 | ||
| 823 | static int | 846 | static int lec_vcc_attach(struct atm_vcc *vcc, void __user *arg) |
| 824 | lec_vcc_attach(struct atm_vcc *vcc, void __user *arg) | ||
| 825 | { | 847 | { |
| 826 | struct lec_vcc_priv *vpriv; | 848 | struct lec_vcc_priv *vpriv; |
| 827 | int bytes_left; | 849 | int bytes_left; |
| 828 | struct atmlec_ioc ioc_data; | 850 | struct atmlec_ioc ioc_data; |
| 829 | 851 | ||
| 830 | /* Lecd must be up in this case */ | 852 | /* Lecd must be up in this case */ |
| 831 | bytes_left = copy_from_user(&ioc_data, arg, sizeof(struct atmlec_ioc)); | 853 | bytes_left = copy_from_user(&ioc_data, arg, sizeof(struct atmlec_ioc)); |
| 832 | if (bytes_left != 0) { | 854 | if (bytes_left != 0) { |
| 833 | printk("lec: lec_vcc_attach, copy from user failed for %d bytes\n", | 855 | printk |
| 834 | bytes_left); | 856 | ("lec: lec_vcc_attach, copy from user failed for %d bytes\n", |
| 835 | } | 857 | bytes_left); |
| 836 | if (ioc_data.dev_num < 0 || ioc_data.dev_num >= MAX_LEC_ITF || | 858 | } |
| 837 | !dev_lec[ioc_data.dev_num]) | 859 | if (ioc_data.dev_num < 0 || ioc_data.dev_num >= MAX_LEC_ITF || |
| 838 | return -EINVAL; | 860 | !dev_lec[ioc_data.dev_num]) |
| 861 | return -EINVAL; | ||
| 839 | if (!(vpriv = kmalloc(sizeof(struct lec_vcc_priv), GFP_KERNEL))) | 862 | if (!(vpriv = kmalloc(sizeof(struct lec_vcc_priv), GFP_KERNEL))) |
| 840 | return -ENOMEM; | 863 | return -ENOMEM; |
| 841 | vpriv->xoff = 0; | 864 | vpriv->xoff = 0; |
| 842 | vpriv->old_pop = vcc->pop; | 865 | vpriv->old_pop = vcc->pop; |
| 843 | vcc->user_back = vpriv; | 866 | vcc->user_back = vpriv; |
| 844 | vcc->pop = lec_pop; | 867 | vcc->pop = lec_pop; |
| 845 | lec_vcc_added(dev_lec[ioc_data.dev_num]->priv, | 868 | lec_vcc_added(dev_lec[ioc_data.dev_num]->priv, |
| 846 | &ioc_data, vcc, vcc->push); | 869 | &ioc_data, vcc, vcc->push); |
| 847 | vcc->proto_data = dev_lec[ioc_data.dev_num]; | 870 | vcc->proto_data = dev_lec[ioc_data.dev_num]; |
| 848 | vcc->push = lec_push; | 871 | vcc->push = lec_push; |
| 849 | return 0; | 872 | return 0; |
| 850 | } | 873 | } |
| 851 | 874 | ||
| 852 | static int | 875 | static int lec_mcast_attach(struct atm_vcc *vcc, int arg) |
| 853 | lec_mcast_attach(struct atm_vcc *vcc, int arg) | ||
| 854 | { | 876 | { |
| 855 | if (arg <0 || arg >= MAX_LEC_ITF || !dev_lec[arg]) | 877 | if (arg < 0 || arg >= MAX_LEC_ITF || !dev_lec[arg]) |
| 856 | return -EINVAL; | 878 | return -EINVAL; |
| 857 | vcc->proto_data = dev_lec[arg]; | 879 | vcc->proto_data = dev_lec[arg]; |
| 858 | return (lec_mcast_make((struct lec_priv*)dev_lec[arg]->priv, vcc)); | 880 | return (lec_mcast_make((struct lec_priv *)dev_lec[arg]->priv, vcc)); |
| 859 | } | 881 | } |
| 860 | 882 | ||
| 861 | /* Initialize device. */ | 883 | /* Initialize device. */ |
| 862 | static int | 884 | static int lecd_attach(struct atm_vcc *vcc, int arg) |
| 863 | lecd_attach(struct atm_vcc *vcc, int arg) | 885 | { |
| 864 | { | 886 | int i; |
| 865 | int i; | 887 | struct lec_priv *priv; |
| 866 | struct lec_priv *priv; | ||
| 867 | 888 | ||
| 868 | if (arg<0) | 889 | if (arg < 0) |
| 869 | i = 0; | 890 | i = 0; |
| 870 | else | 891 | else |
| 871 | i = arg; | 892 | i = arg; |
| 872 | #ifdef CONFIG_TR | 893 | #ifdef CONFIG_TR |
| 873 | if (arg >= MAX_LEC_ITF) | 894 | if (arg >= MAX_LEC_ITF) |
| 874 | return -EINVAL; | 895 | return -EINVAL; |
| 875 | #else /* Reserve the top NUM_TR_DEVS for TR */ | 896 | #else /* Reserve the top NUM_TR_DEVS for TR */ |
| 876 | if (arg >= (MAX_LEC_ITF-NUM_TR_DEVS)) | 897 | if (arg >= (MAX_LEC_ITF - NUM_TR_DEVS)) |
| 877 | return -EINVAL; | 898 | return -EINVAL; |
| 878 | #endif | 899 | #endif |
| 879 | if (!dev_lec[i]) { | 900 | if (!dev_lec[i]) { |
| 880 | int is_trdev, size; | 901 | int is_trdev, size; |
| 881 | 902 | ||
| 882 | is_trdev = 0; | 903 | is_trdev = 0; |
| 883 | if (i >= (MAX_LEC_ITF - NUM_TR_DEVS)) | 904 | if (i >= (MAX_LEC_ITF - NUM_TR_DEVS)) |
| 884 | is_trdev = 1; | 905 | is_trdev = 1; |
| 885 | 906 | ||
| 886 | size = sizeof(struct lec_priv); | 907 | size = sizeof(struct lec_priv); |
| 887 | #ifdef CONFIG_TR | 908 | #ifdef CONFIG_TR |
| 888 | if (is_trdev) | 909 | if (is_trdev) |
| 889 | dev_lec[i] = alloc_trdev(size); | 910 | dev_lec[i] = alloc_trdev(size); |
| 890 | else | 911 | else |
| 891 | #endif | 912 | #endif |
| 892 | dev_lec[i] = alloc_etherdev(size); | 913 | dev_lec[i] = alloc_etherdev(size); |
| 893 | if (!dev_lec[i]) | 914 | if (!dev_lec[i]) |
| 894 | return -ENOMEM; | 915 | return -ENOMEM; |
| 895 | snprintf(dev_lec[i]->name, IFNAMSIZ, "lec%d", i); | 916 | snprintf(dev_lec[i]->name, IFNAMSIZ, "lec%d", i); |
| 896 | if (register_netdev(dev_lec[i])) { | 917 | if (register_netdev(dev_lec[i])) { |
| 897 | free_netdev(dev_lec[i]); | 918 | free_netdev(dev_lec[i]); |
| 898 | return -EINVAL; | 919 | return -EINVAL; |
| 899 | } | 920 | } |
| 900 | 921 | ||
| 901 | priv = dev_lec[i]->priv; | 922 | priv = dev_lec[i]->priv; |
| 902 | priv->is_trdev = is_trdev; | 923 | priv->is_trdev = is_trdev; |
| 903 | lec_init(dev_lec[i]); | 924 | lec_init(dev_lec[i]); |
| 904 | } else { | 925 | } else { |
| 905 | priv = dev_lec[i]->priv; | 926 | priv = dev_lec[i]->priv; |
| 906 | if (priv->lecd) | 927 | if (priv->lecd) |
| 907 | return -EADDRINUSE; | 928 | return -EADDRINUSE; |
| 908 | } | 929 | } |
| 909 | lec_arp_init(priv); | 930 | lec_arp_init(priv); |
| 910 | priv->itfnum = i; /* LANE2 addition */ | 931 | priv->itfnum = i; /* LANE2 addition */ |
| 911 | priv->lecd = vcc; | 932 | priv->lecd = vcc; |
| 912 | vcc->dev = &lecatm_dev; | 933 | vcc->dev = &lecatm_dev; |
| 913 | vcc_insert_socket(sk_atm(vcc)); | 934 | vcc_insert_socket(sk_atm(vcc)); |
| 914 | 935 | ||
| 915 | vcc->proto_data = dev_lec[i]; | 936 | vcc->proto_data = dev_lec[i]; |
| 916 | set_bit(ATM_VF_META,&vcc->flags); | 937 | set_bit(ATM_VF_META, &vcc->flags); |
| 917 | set_bit(ATM_VF_READY,&vcc->flags); | 938 | set_bit(ATM_VF_READY, &vcc->flags); |
| 918 | 939 | ||
| 919 | /* Set default values to these variables */ | 940 | /* Set default values to these variables */ |
| 920 | priv->maximum_unknown_frame_count = 1; | 941 | priv->maximum_unknown_frame_count = 1; |
| 921 | priv->max_unknown_frame_time = (1*HZ); | 942 | priv->max_unknown_frame_time = (1 * HZ); |
| 922 | priv->vcc_timeout_period = (1200*HZ); | 943 | priv->vcc_timeout_period = (1200 * HZ); |
| 923 | priv->max_retry_count = 1; | 944 | priv->max_retry_count = 1; |
| 924 | priv->aging_time = (300*HZ); | 945 | priv->aging_time = (300 * HZ); |
| 925 | priv->forward_delay_time = (15*HZ); | 946 | priv->forward_delay_time = (15 * HZ); |
| 926 | priv->topology_change = 0; | 947 | priv->topology_change = 0; |
| 927 | priv->arp_response_time = (1*HZ); | 948 | priv->arp_response_time = (1 * HZ); |
| 928 | priv->flush_timeout = (4*HZ); | 949 | priv->flush_timeout = (4 * HZ); |
| 929 | priv->path_switching_delay = (6*HZ); | 950 | priv->path_switching_delay = (6 * HZ); |
| 930 | 951 | ||
| 931 | if (dev_lec[i]->flags & IFF_UP) { | 952 | if (dev_lec[i]->flags & IFF_UP) { |
| 932 | netif_start_queue(dev_lec[i]); | 953 | netif_start_queue(dev_lec[i]); |
| 933 | } | 954 | } |
| 934 | __module_get(THIS_MODULE); | 955 | __module_get(THIS_MODULE); |
| 935 | return i; | 956 | return i; |
| 936 | } | 957 | } |
| 937 | 958 | ||
| 938 | #ifdef CONFIG_PROC_FS | 959 | #ifdef CONFIG_PROC_FS |
| 939 | static char* lec_arp_get_status_string(unsigned char status) | 960 | static char *lec_arp_get_status_string(unsigned char status) |
| 940 | { | 961 | { |
| 941 | static char *lec_arp_status_string[] = { | 962 | static char *lec_arp_status_string[] = { |
| 942 | "ESI_UNKNOWN ", | 963 | "ESI_UNKNOWN ", |
| @@ -966,15 +987,14 @@ static void lec_info(struct seq_file *seq, struct lec_arp_table *entry) | |||
| 966 | if (entry->vcc) | 987 | if (entry->vcc) |
| 967 | seq_printf(seq, "%3d %3d ", entry->vcc->vpi, entry->vcc->vci); | 988 | seq_printf(seq, "%3d %3d ", entry->vcc->vpi, entry->vcc->vci); |
| 968 | else | 989 | else |
| 969 | seq_printf(seq, " "); | 990 | seq_printf(seq, " "); |
| 970 | if (entry->recv_vcc) { | 991 | if (entry->recv_vcc) { |
| 971 | seq_printf(seq, " %3d %3d", entry->recv_vcc->vpi, | 992 | seq_printf(seq, " %3d %3d", entry->recv_vcc->vpi, |
| 972 | entry->recv_vcc->vci); | 993 | entry->recv_vcc->vci); |
| 973 | } | 994 | } |
| 974 | seq_putc(seq, '\n'); | 995 | seq_putc(seq, '\n'); |
| 975 | } | 996 | } |
| 976 | 997 | ||
| 977 | |||
| 978 | struct lec_state { | 998 | struct lec_state { |
| 979 | unsigned long flags; | 999 | unsigned long flags; |
| 980 | struct lec_priv *locked; | 1000 | struct lec_priv *locked; |
| @@ -1005,7 +1025,7 @@ static void *lec_tbl_walk(struct lec_state *state, struct lec_arp_table *tbl, | |||
| 1005 | } | 1025 | } |
| 1006 | 1026 | ||
| 1007 | static void *lec_arp_walk(struct lec_state *state, loff_t *l, | 1027 | static void *lec_arp_walk(struct lec_state *state, loff_t *l, |
| 1008 | struct lec_priv *priv) | 1028 | struct lec_priv *priv) |
| 1009 | { | 1029 | { |
| 1010 | void *v = NULL; | 1030 | void *v = NULL; |
| 1011 | int p; | 1031 | int p; |
| @@ -1046,8 +1066,7 @@ static void *lec_priv_walk(struct lec_state *state, loff_t *l, | |||
| 1046 | state->locked = priv; | 1066 | state->locked = priv; |
| 1047 | spin_lock_irqsave(&priv->lec_arp_lock, state->flags); | 1067 | spin_lock_irqsave(&priv->lec_arp_lock, state->flags); |
| 1048 | } | 1068 | } |
| 1049 | if (!lec_arp_walk(state, l, priv) && | 1069 | if (!lec_arp_walk(state, l, priv) && !lec_misc_walk(state, l, priv)) { |
| 1050 | !lec_misc_walk(state, l, priv)) { | ||
| 1051 | spin_unlock_irqrestore(&priv->lec_arp_lock, state->flags); | 1070 | spin_unlock_irqrestore(&priv->lec_arp_lock, state->flags); |
| 1052 | state->locked = NULL; | 1071 | state->locked = NULL; |
| 1053 | /* Partial state reset for the next time we get called */ | 1072 | /* Partial state reset for the next time we get called */ |
| @@ -1081,7 +1100,7 @@ static void *lec_get_idx(struct lec_state *state, loff_t l) | |||
| 1081 | if (v) | 1100 | if (v) |
| 1082 | break; | 1101 | break; |
| 1083 | } | 1102 | } |
| 1084 | return v; | 1103 | return v; |
| 1085 | } | 1104 | } |
| 1086 | 1105 | ||
| 1087 | static void *lec_seq_start(struct seq_file *seq, loff_t *pos) | 1106 | static void *lec_seq_start(struct seq_file *seq, loff_t *pos) |
| @@ -1095,7 +1114,7 @@ static void *lec_seq_start(struct seq_file *seq, loff_t *pos) | |||
| 1095 | state->misc_table = 0; | 1114 | state->misc_table = 0; |
| 1096 | state->entry = (void *)1; | 1115 | state->entry = (void *)1; |
| 1097 | 1116 | ||
| 1098 | return *pos ? lec_get_idx(state, *pos) : (void*)1; | 1117 | return *pos ? lec_get_idx(state, *pos) : (void *)1; |
| 1099 | } | 1118 | } |
| 1100 | 1119 | ||
| 1101 | static void lec_seq_stop(struct seq_file *seq, void *v) | 1120 | static void lec_seq_stop(struct seq_file *seq, void *v) |
| @@ -1120,15 +1139,15 @@ static void *lec_seq_next(struct seq_file *seq, void *v, loff_t *pos) | |||
| 1120 | 1139 | ||
| 1121 | static int lec_seq_show(struct seq_file *seq, void *v) | 1140 | static int lec_seq_show(struct seq_file *seq, void *v) |
| 1122 | { | 1141 | { |
| 1123 | static char lec_banner[] = "Itf MAC ATM destination" | 1142 | static char lec_banner[] = "Itf MAC ATM destination" |
| 1124 | " Status Flags " | 1143 | " Status Flags " |
| 1125 | "VPI/VCI Recv VPI/VCI\n"; | 1144 | "VPI/VCI Recv VPI/VCI\n"; |
| 1126 | 1145 | ||
| 1127 | if (v == (void *)1) | 1146 | if (v == (void *)1) |
| 1128 | seq_puts(seq, lec_banner); | 1147 | seq_puts(seq, lec_banner); |
| 1129 | else { | 1148 | else { |
| 1130 | struct lec_state *state = seq->private; | 1149 | struct lec_state *state = seq->private; |
| 1131 | struct net_device *dev = state->dev; | 1150 | struct net_device *dev = state->dev; |
| 1132 | 1151 | ||
| 1133 | seq_printf(seq, "%s ", dev->name); | 1152 | seq_printf(seq, "%s ", dev->name); |
| 1134 | lec_info(seq, state->entry); | 1153 | lec_info(seq, state->entry); |
| @@ -1137,10 +1156,10 @@ static int lec_seq_show(struct seq_file *seq, void *v) | |||
| 1137 | } | 1156 | } |
| 1138 | 1157 | ||
| 1139 | static struct seq_operations lec_seq_ops = { | 1158 | static struct seq_operations lec_seq_ops = { |
| 1140 | .start = lec_seq_start, | 1159 | .start = lec_seq_start, |
| 1141 | .next = lec_seq_next, | 1160 | .next = lec_seq_next, |
| 1142 | .stop = lec_seq_stop, | 1161 | .stop = lec_seq_stop, |
| 1143 | .show = lec_seq_show, | 1162 | .show = lec_seq_show, |
| 1144 | }; | 1163 | }; |
| 1145 | 1164 | ||
| 1146 | static int lec_seq_open(struct inode *inode, struct file *file) | 1165 | static int lec_seq_open(struct inode *inode, struct file *file) |
| @@ -1174,11 +1193,11 @@ static int lec_seq_release(struct inode *inode, struct file *file) | |||
| 1174 | } | 1193 | } |
| 1175 | 1194 | ||
| 1176 | static struct file_operations lec_seq_fops = { | 1195 | static struct file_operations lec_seq_fops = { |
| 1177 | .owner = THIS_MODULE, | 1196 | .owner = THIS_MODULE, |
| 1178 | .open = lec_seq_open, | 1197 | .open = lec_seq_open, |
| 1179 | .read = seq_read, | 1198 | .read = seq_read, |
| 1180 | .llseek = seq_lseek, | 1199 | .llseek = seq_lseek, |
| 1181 | .release = lec_seq_release, | 1200 | .release = lec_seq_release, |
| 1182 | }; | 1201 | }; |
| 1183 | #endif | 1202 | #endif |
| 1184 | 1203 | ||
| @@ -1186,38 +1205,38 @@ static int lane_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg) | |||
| 1186 | { | 1205 | { |
| 1187 | struct atm_vcc *vcc = ATM_SD(sock); | 1206 | struct atm_vcc *vcc = ATM_SD(sock); |
| 1188 | int err = 0; | 1207 | int err = 0; |
| 1189 | 1208 | ||
| 1190 | switch (cmd) { | 1209 | switch (cmd) { |
| 1191 | case ATMLEC_CTRL: | 1210 | case ATMLEC_CTRL: |
| 1192 | case ATMLEC_MCAST: | 1211 | case ATMLEC_MCAST: |
| 1193 | case ATMLEC_DATA: | 1212 | case ATMLEC_DATA: |
| 1194 | if (!capable(CAP_NET_ADMIN)) | 1213 | if (!capable(CAP_NET_ADMIN)) |
| 1195 | return -EPERM; | 1214 | return -EPERM; |
| 1196 | break; | 1215 | break; |
| 1197 | default: | 1216 | default: |
| 1198 | return -ENOIOCTLCMD; | 1217 | return -ENOIOCTLCMD; |
| 1199 | } | 1218 | } |
| 1200 | 1219 | ||
| 1201 | switch (cmd) { | 1220 | switch (cmd) { |
| 1202 | case ATMLEC_CTRL: | 1221 | case ATMLEC_CTRL: |
| 1203 | err = lecd_attach(vcc, (int) arg); | 1222 | err = lecd_attach(vcc, (int)arg); |
| 1204 | if (err >= 0) | 1223 | if (err >= 0) |
| 1205 | sock->state = SS_CONNECTED; | 1224 | sock->state = SS_CONNECTED; |
| 1206 | break; | 1225 | break; |
| 1207 | case ATMLEC_MCAST: | 1226 | case ATMLEC_MCAST: |
| 1208 | err = lec_mcast_attach(vcc, (int) arg); | 1227 | err = lec_mcast_attach(vcc, (int)arg); |
| 1209 | break; | 1228 | break; |
| 1210 | case ATMLEC_DATA: | 1229 | case ATMLEC_DATA: |
| 1211 | err = lec_vcc_attach(vcc, (void __user *) arg); | 1230 | err = lec_vcc_attach(vcc, (void __user *)arg); |
| 1212 | break; | 1231 | break; |
| 1213 | } | 1232 | } |
| 1214 | 1233 | ||
| 1215 | return err; | 1234 | return err; |
| 1216 | } | 1235 | } |
| 1217 | 1236 | ||
| 1218 | static struct atm_ioctl lane_ioctl_ops = { | 1237 | static struct atm_ioctl lane_ioctl_ops = { |
| 1219 | .owner = THIS_MODULE, | 1238 | .owner = THIS_MODULE, |
| 1220 | .ioctl = lane_ioctl, | 1239 | .ioctl = lane_ioctl, |
| 1221 | }; | 1240 | }; |
| 1222 | 1241 | ||
| 1223 | static int __init lane_module_init(void) | 1242 | static int __init lane_module_init(void) |
| @@ -1231,29 +1250,29 @@ static int __init lane_module_init(void) | |||
| 1231 | #endif | 1250 | #endif |
| 1232 | 1251 | ||
| 1233 | register_atm_ioctl(&lane_ioctl_ops); | 1252 | register_atm_ioctl(&lane_ioctl_ops); |
| 1234 | printk("lec.c: " __DATE__ " " __TIME__ " initialized\n"); | 1253 | printk("lec.c: " __DATE__ " " __TIME__ " initialized\n"); |
| 1235 | return 0; | 1254 | return 0; |
| 1236 | } | 1255 | } |
| 1237 | 1256 | ||
| 1238 | static void __exit lane_module_cleanup(void) | 1257 | static void __exit lane_module_cleanup(void) |
| 1239 | { | 1258 | { |
| 1240 | int i; | 1259 | int i; |
| 1241 | struct lec_priv *priv; | 1260 | struct lec_priv *priv; |
| 1242 | 1261 | ||
| 1243 | remove_proc_entry("lec", atm_proc_root); | 1262 | remove_proc_entry("lec", atm_proc_root); |
| 1244 | 1263 | ||
| 1245 | deregister_atm_ioctl(&lane_ioctl_ops); | 1264 | deregister_atm_ioctl(&lane_ioctl_ops); |
| 1246 | 1265 | ||
| 1247 | for (i = 0; i < MAX_LEC_ITF; i++) { | 1266 | for (i = 0; i < MAX_LEC_ITF; i++) { |
| 1248 | if (dev_lec[i] != NULL) { | 1267 | if (dev_lec[i] != NULL) { |
| 1249 | priv = (struct lec_priv *)dev_lec[i]->priv; | 1268 | priv = (struct lec_priv *)dev_lec[i]->priv; |
| 1250 | unregister_netdev(dev_lec[i]); | 1269 | unregister_netdev(dev_lec[i]); |
| 1251 | free_netdev(dev_lec[i]); | 1270 | free_netdev(dev_lec[i]); |
| 1252 | dev_lec[i] = NULL; | 1271 | dev_lec[i] = NULL; |
| 1253 | } | 1272 | } |
| 1254 | } | 1273 | } |
| 1255 | 1274 | ||
| 1256 | return; | 1275 | return; |
| 1257 | } | 1276 | } |
| 1258 | 1277 | ||
| 1259 | module_init(lane_module_init); | 1278 | module_init(lane_module_init); |
| @@ -1267,34 +1286,34 @@ module_exit(lane_module_cleanup); | |||
| 1267 | * If dst_mac == NULL, targetless LE_ARP will be sent | 1286 | * If dst_mac == NULL, targetless LE_ARP will be sent |
| 1268 | */ | 1287 | */ |
| 1269 | static int lane2_resolve(struct net_device *dev, u8 *dst_mac, int force, | 1288 | static int lane2_resolve(struct net_device *dev, u8 *dst_mac, int force, |
| 1270 | u8 **tlvs, u32 *sizeoftlvs) | 1289 | u8 **tlvs, u32 *sizeoftlvs) |
| 1271 | { | 1290 | { |
| 1272 | unsigned long flags; | 1291 | unsigned long flags; |
| 1273 | struct lec_priv *priv = (struct lec_priv *)dev->priv; | 1292 | struct lec_priv *priv = (struct lec_priv *)dev->priv; |
| 1274 | struct lec_arp_table *table; | 1293 | struct lec_arp_table *table; |
| 1275 | struct sk_buff *skb; | 1294 | struct sk_buff *skb; |
| 1276 | int retval; | 1295 | int retval; |
| 1277 | 1296 | ||
| 1278 | if (force == 0) { | 1297 | if (force == 0) { |
| 1279 | spin_lock_irqsave(&priv->lec_arp_lock, flags); | 1298 | spin_lock_irqsave(&priv->lec_arp_lock, flags); |
| 1280 | table = lec_arp_find(priv, dst_mac); | 1299 | table = lec_arp_find(priv, dst_mac); |
| 1281 | spin_unlock_irqrestore(&priv->lec_arp_lock, flags); | 1300 | spin_unlock_irqrestore(&priv->lec_arp_lock, flags); |
| 1282 | if(table == NULL) | 1301 | if (table == NULL) |
| 1283 | return -1; | 1302 | return -1; |
| 1284 | 1303 | ||
| 1285 | *tlvs = kmalloc(table->sizeoftlvs, GFP_ATOMIC); | 1304 | *tlvs = kmalloc(table->sizeoftlvs, GFP_ATOMIC); |
| 1286 | if (*tlvs == NULL) | 1305 | if (*tlvs == NULL) |
| 1287 | return -1; | 1306 | return -1; |
| 1288 | 1307 | ||
| 1289 | memcpy(*tlvs, table->tlvs, table->sizeoftlvs); | 1308 | memcpy(*tlvs, table->tlvs, table->sizeoftlvs); |
| 1290 | *sizeoftlvs = table->sizeoftlvs; | 1309 | *sizeoftlvs = table->sizeoftlvs; |
| 1291 | 1310 | ||
| 1292 | return 0; | 1311 | return 0; |
| 1293 | } | 1312 | } |
| 1294 | 1313 | ||
| 1295 | if (sizeoftlvs == NULL) | 1314 | if (sizeoftlvs == NULL) |
| 1296 | retval = send_to_lecd(priv, l_arp_xmt, dst_mac, NULL, NULL); | 1315 | retval = send_to_lecd(priv, l_arp_xmt, dst_mac, NULL, NULL); |
| 1297 | 1316 | ||
| 1298 | else { | 1317 | else { |
| 1299 | skb = alloc_skb(*sizeoftlvs, GFP_ATOMIC); | 1318 | skb = alloc_skb(*sizeoftlvs, GFP_ATOMIC); |
| 1300 | if (skb == NULL) | 1319 | if (skb == NULL) |
| @@ -1303,9 +1322,8 @@ static int lane2_resolve(struct net_device *dev, u8 *dst_mac, int force, | |||
| 1303 | memcpy(skb->data, *tlvs, *sizeoftlvs); | 1322 | memcpy(skb->data, *tlvs, *sizeoftlvs); |
| 1304 | retval = send_to_lecd(priv, l_arp_xmt, dst_mac, NULL, skb); | 1323 | retval = send_to_lecd(priv, l_arp_xmt, dst_mac, NULL, skb); |
| 1305 | } | 1324 | } |
| 1306 | return retval; | 1325 | return retval; |
| 1307 | } | 1326 | } |
| 1308 | |||
| 1309 | 1327 | ||
| 1310 | /* | 1328 | /* |
| 1311 | * LANE2: 3.1.4, LE_ASSOCIATE.request | 1329 | * LANE2: 3.1.4, LE_ASSOCIATE.request |
| @@ -1314,80 +1332,85 @@ static int lane2_resolve(struct net_device *dev, u8 *dst_mac, int force, | |||
| 1314 | * Returns 1 for success, 0 for failure (out of memory) | 1332 | * Returns 1 for success, 0 for failure (out of memory) |
| 1315 | * | 1333 | * |
| 1316 | */ | 1334 | */ |
| 1317 | static int lane2_associate_req (struct net_device *dev, u8 *lan_dst, | 1335 | static int lane2_associate_req(struct net_device *dev, u8 *lan_dst, |
| 1318 | u8 *tlvs, u32 sizeoftlvs) | 1336 | u8 *tlvs, u32 sizeoftlvs) |
| 1319 | { | 1337 | { |
| 1320 | int retval; | 1338 | int retval; |
| 1321 | struct sk_buff *skb; | 1339 | struct sk_buff *skb; |
| 1322 | struct lec_priv *priv = (struct lec_priv*)dev->priv; | 1340 | struct lec_priv *priv = (struct lec_priv *)dev->priv; |
| 1323 | 1341 | ||
| 1324 | if (compare_ether_addr(lan_dst, dev->dev_addr)) | 1342 | if (compare_ether_addr(lan_dst, dev->dev_addr)) |
| 1325 | return (0); /* not our mac address */ | 1343 | return (0); /* not our mac address */ |
| 1326 | 1344 | ||
| 1327 | kfree(priv->tlvs); /* NULL if there was no previous association */ | 1345 | kfree(priv->tlvs); /* NULL if there was no previous association */ |
| 1328 | 1346 | ||
| 1329 | priv->tlvs = kmalloc(sizeoftlvs, GFP_KERNEL); | 1347 | priv->tlvs = kmalloc(sizeoftlvs, GFP_KERNEL); |
| 1330 | if (priv->tlvs == NULL) | 1348 | if (priv->tlvs == NULL) |
| 1331 | return (0); | 1349 | return (0); |
| 1332 | priv->sizeoftlvs = sizeoftlvs; | 1350 | priv->sizeoftlvs = sizeoftlvs; |
| 1333 | memcpy(priv->tlvs, tlvs, sizeoftlvs); | 1351 | memcpy(priv->tlvs, tlvs, sizeoftlvs); |
| 1334 | 1352 | ||
| 1335 | skb = alloc_skb(sizeoftlvs, GFP_ATOMIC); | 1353 | skb = alloc_skb(sizeoftlvs, GFP_ATOMIC); |
| 1336 | if (skb == NULL) | 1354 | if (skb == NULL) |
| 1337 | return 0; | 1355 | return 0; |
| 1338 | skb->len = sizeoftlvs; | 1356 | skb->len = sizeoftlvs; |
| 1339 | memcpy(skb->data, tlvs, sizeoftlvs); | 1357 | memcpy(skb->data, tlvs, sizeoftlvs); |
| 1340 | retval = send_to_lecd(priv, l_associate_req, NULL, NULL, skb); | 1358 | retval = send_to_lecd(priv, l_associate_req, NULL, NULL, skb); |
| 1341 | if (retval != 0) | 1359 | if (retval != 0) |
| 1342 | printk("lec.c: lane2_associate_req() failed\n"); | 1360 | printk("lec.c: lane2_associate_req() failed\n"); |
| 1343 | /* If the previous association has changed we must | 1361 | /* |
| 1344 | * somehow notify other LANE entities about the change | 1362 | * If the previous association has changed we must |
| 1345 | */ | 1363 | * somehow notify other LANE entities about the change |
| 1346 | return (1); | 1364 | */ |
| 1365 | return (1); | ||
| 1347 | } | 1366 | } |
| 1348 | 1367 | ||
| 1349 | /* | 1368 | /* |
| 1350 | * LANE2: 3.1.5, LE_ASSOCIATE.indication | 1369 | * LANE2: 3.1.5, LE_ASSOCIATE.indication |
| 1351 | * | 1370 | * |
| 1352 | */ | 1371 | */ |
| 1353 | static void lane2_associate_ind (struct net_device *dev, u8 *mac_addr, | 1372 | static void lane2_associate_ind(struct net_device *dev, u8 *mac_addr, |
| 1354 | u8 *tlvs, u32 sizeoftlvs) | 1373 | u8 *tlvs, u32 sizeoftlvs) |
| 1355 | { | 1374 | { |
| 1356 | #if 0 | 1375 | #if 0 |
| 1357 | int i = 0; | 1376 | int i = 0; |
| 1358 | #endif | 1377 | #endif |
| 1359 | struct lec_priv *priv = (struct lec_priv *)dev->priv; | 1378 | struct lec_priv *priv = (struct lec_priv *)dev->priv; |
| 1360 | #if 0 /* Why have the TLVs in LE_ARP entries since we do not use them? When you | 1379 | #if 0 /* |
| 1361 | uncomment this code, make sure the TLVs get freed when entry is killed */ | 1380 | * Why have the TLVs in LE_ARP entries |
| 1362 | struct lec_arp_table *entry = lec_arp_find(priv, mac_addr); | 1381 | * since we do not use them? When you |
| 1382 | * uncomment this code, make sure the | ||
| 1383 | * TLVs get freed when entry is killed | ||
| 1384 | */ | ||
| 1385 | struct lec_arp_table *entry = lec_arp_find(priv, mac_addr); | ||
| 1363 | 1386 | ||
| 1364 | if (entry == NULL) | 1387 | if (entry == NULL) |
| 1365 | return; /* should not happen */ | 1388 | return; /* should not happen */ |
| 1366 | 1389 | ||
| 1367 | kfree(entry->tlvs); | 1390 | kfree(entry->tlvs); |
| 1368 | 1391 | ||
| 1369 | entry->tlvs = kmalloc(sizeoftlvs, GFP_KERNEL); | 1392 | entry->tlvs = kmalloc(sizeoftlvs, GFP_KERNEL); |
| 1370 | if (entry->tlvs == NULL) | 1393 | if (entry->tlvs == NULL) |
| 1371 | return; | 1394 | return; |
| 1372 | 1395 | ||
| 1373 | entry->sizeoftlvs = sizeoftlvs; | 1396 | entry->sizeoftlvs = sizeoftlvs; |
| 1374 | memcpy(entry->tlvs, tlvs, sizeoftlvs); | 1397 | memcpy(entry->tlvs, tlvs, sizeoftlvs); |
| 1375 | #endif | 1398 | #endif |
| 1376 | #if 0 | 1399 | #if 0 |
| 1377 | printk("lec.c: lane2_associate_ind()\n"); | 1400 | printk("lec.c: lane2_associate_ind()\n"); |
| 1378 | printk("dump of tlvs, sizeoftlvs=%d\n", sizeoftlvs); | 1401 | printk("dump of tlvs, sizeoftlvs=%d\n", sizeoftlvs); |
| 1379 | while (i < sizeoftlvs) | 1402 | while (i < sizeoftlvs) |
| 1380 | printk("%02x ", tlvs[i++]); | 1403 | printk("%02x ", tlvs[i++]); |
| 1381 | 1404 | ||
| 1382 | printk("\n"); | 1405 | printk("\n"); |
| 1383 | #endif | 1406 | #endif |
| 1384 | 1407 | ||
| 1385 | /* tell MPOA about the TLVs we saw */ | 1408 | /* tell MPOA about the TLVs we saw */ |
| 1386 | if (priv->lane2_ops && priv->lane2_ops->associate_indicator) { | 1409 | if (priv->lane2_ops && priv->lane2_ops->associate_indicator) { |
| 1387 | priv->lane2_ops->associate_indicator(dev, mac_addr, | 1410 | priv->lane2_ops->associate_indicator(dev, mac_addr, |
| 1388 | tlvs, sizeoftlvs); | 1411 | tlvs, sizeoftlvs); |
| 1389 | } | 1412 | } |
| 1390 | return; | 1413 | return; |
| 1391 | } | 1414 | } |
| 1392 | 1415 | ||
| 1393 | /* | 1416 | /* |
