Loading net/atm/lec.c +715 −692 Original line number Diff line number Diff line /* * lec.c: Lan Emulation driver * Marko Kiiskila mkiiskila@yahoo.com * * Marko Kiiskila <mkiiskila@yahoo.com> */ #include <linux/kernel.h> Loading Loading @@ -55,13 +55,16 @@ static unsigned char bridge_ula_lec[] = {0x01, 0x80, 0xc2, 0x00, 0x00}; #define DPRINTK(format,args...) #endif #define DUMP_PACKETS 0 /* 0 = None, #define DUMP_PACKETS 0 /* * 0 = None, * 1 = 30 first bytes * 2 = Whole packet */ #define LEC_UNRES_QUE_LEN 8 /* number of tx packets to queue for a single destination while waiting for SVC */ #define LEC_UNRES_QUE_LEN 8 /* * number of tx packets to queue for a * single destination while waiting for SVC */ static int lec_open(struct net_device *dev); static int lec_start_xmit(struct sk_buff *skb, struct net_device *dev); Loading Loading @@ -100,7 +103,8 @@ static void lec_set_flush_tran_id(struct lec_priv *priv, unsigned long tran_id); static void lec_vcc_added(struct lec_priv *priv, struct atmlec_ioc *ioc_data, struct atm_vcc *vcc, void (*old_push)(struct atm_vcc *vcc, struct sk_buff *skb)); void (*old_push) (struct atm_vcc *vcc, struct sk_buff *skb)); static void lec_vcc_close(struct lec_priv *priv, struct atm_vcc *vcc); static struct lane2_ops lane2_ops = { Loading @@ -121,9 +125,11 @@ static void lec_handle_bridge(struct sk_buff *skb, struct net_device *dev) char *buff; struct lec_priv *priv; /* Check if this is a BPDU. If so, ask zeppelin to send /* * Check if this is a BPDU. If so, ask zeppelin to send * LE_TOPOLOGY_REQUEST with the same value of Topology Change bit * as the Config BPDU has */ * as the Config BPDU has */ eth = (struct ethhdr *)skb->data; buff = skb->data + skb->dev->hard_header_len; if (*buff++ == 0x42 && *buff++ == 0x42 && *buff++ == 0x03) { Loading @@ -132,7 +138,8 @@ static void lec_handle_bridge(struct sk_buff *skb, struct net_device *dev) struct atmlec_msg *mesg; skb2 = alloc_skb(sizeof(struct atmlec_msg), GFP_ATOMIC); if (skb2 == NULL) return; if (skb2 == NULL) return; skb2->len = sizeof(struct atmlec_msg); mesg = (struct atmlec_msg *)skb2->data; mesg->type = l_topology_change; Loading Loading @@ -173,8 +180,7 @@ static unsigned char *get_tr_dst(unsigned char *packet, unsigned char *rdesc) riflen = (ntohs(trh->rcf) & TR_RCF_LEN_MASK) >> 8; if ((ntohs(trh->rcf) >> 13) != 0) return bus_mac; /* ARE or STE */ } else } else return trh->daddr; /* not source routed */ if (riflen < 6) Loading Loading @@ -204,8 +210,7 @@ static unsigned char *get_tr_dst(unsigned char *packet, unsigned char *rdesc) * there is non-reboot way to recover if something goes wrong. */ static int lec_open(struct net_device *dev) static int lec_open(struct net_device *dev) { struct lec_priv *priv = (struct lec_priv *)dev->priv; Loading @@ -231,16 +236,14 @@ lec_send(struct atm_vcc *vcc, struct sk_buff *skb, struct lec_priv *priv) priv->stats.tx_bytes += skb->len; } static void lec_tx_timeout(struct net_device *dev) static void lec_tx_timeout(struct net_device *dev) { printk(KERN_INFO "%s: tx timeout\n", dev->name); dev->trans_start = jiffies; netif_wake_queue(dev); } static int lec_start_xmit(struct sk_buff *skb, struct net_device *dev) static int lec_start_xmit(struct sk_buff *skb, struct net_device *dev) { struct sk_buff *skb2; struct lec_priv *priv = (struct lec_priv *)dev->priv; Loading Loading @@ -280,7 +283,8 @@ lec_start_xmit(struct sk_buff *skb, struct net_device *dev) DPRINTK("lec_start_xmit: reallocating skb\n"); skb2 = skb_realloc_headroom(skb, LEC_HEADER_LEN); kfree_skb(skb); if (skb2 == NULL) return 0; if (skb2 == NULL) return 0; skb = skb2; } skb_push(skb, 2); Loading @@ -290,12 +294,15 @@ lec_start_xmit(struct sk_buff *skb, struct net_device *dev) lec_h->le_header = htons(priv->lecid); #ifdef CONFIG_TR /* Ugly. Use this to realign Token Ring packets for * e.g. PCA-200E driver. */ /* * Ugly. Use this to realign Token Ring packets for * e.g. PCA-200E driver. */ if (priv->is_trdev) { skb2 = skb_realloc_headroom(skb, LEC_HEADER_LEN); kfree_skb(skb); if (skb2 == NULL) return 0; if (skb2 == NULL) return 0; skb = skb2; } #endif Loading Loading @@ -328,7 +335,8 @@ lec_start_xmit(struct sk_buff *skb, struct net_device *dev) if (skb->len < min_frame_size) { if ((skb->len + skb_tailroom(skb)) < min_frame_size) { skb2 = skb_copy_expand(skb, 0, min_frame_size - skb->truesize, GFP_ATOMIC); min_frame_size - skb->truesize, GFP_ATOMIC); dev_kfree_skb(skb); if (skb2 == NULL) { priv->stats.tx_dropped++; Loading Loading @@ -357,25 +365,28 @@ lec_start_xmit(struct sk_buff *skb, struct net_device *dev) vcc, vcc ? vcc->flags : 0, entry); if (!vcc || !test_bit(ATM_VF_READY, &vcc->flags)) { if (entry && (entry->tx_wait.qlen < LEC_UNRES_QUE_LEN)) { DPRINTK("%s:lec_start_xmit: queuing packet, ", dev->name); DPRINTK("%s:lec_start_xmit: queuing packet, ", dev->name); DPRINTK("MAC address 0x%02x:%02x:%02x:%02x:%02x:%02x\n", lec_h->h_dest[0], lec_h->h_dest[1], lec_h->h_dest[2], lec_h->h_dest[3], lec_h->h_dest[4], lec_h->h_dest[5]); lec_h->h_dest[0], lec_h->h_dest[1], lec_h->h_dest[2], lec_h->h_dest[3], lec_h->h_dest[4], lec_h->h_dest[5]); skb_queue_tail(&entry->tx_wait, skb); } else { DPRINTK("%s:lec_start_xmit: tx queue full or no arp entry, dropping, ", dev->name); DPRINTK ("%s:lec_start_xmit: tx queue full or no arp entry, dropping, ", dev->name); DPRINTK("MAC address 0x%02x:%02x:%02x:%02x:%02x:%02x\n", lec_h->h_dest[0], lec_h->h_dest[1], lec_h->h_dest[2], lec_h->h_dest[3], lec_h->h_dest[4], lec_h->h_dest[5]); lec_h->h_dest[0], lec_h->h_dest[1], lec_h->h_dest[2], lec_h->h_dest[3], lec_h->h_dest[4], lec_h->h_dest[5]); priv->stats.tx_dropped++; dev_kfree_skb(skb); } return 0; } #if DUMP_PACKETS > 0 printk("%s:sending to vpi:%d vci:%d\n", dev->name, vcc->vpi, vcc->vci); printk("%s:sending to vpi:%d vci:%d\n", dev->name, vcc->vpi, vcc->vci); #endif /* DUMP_PACKETS > 0 */ while (entry && (skb2 = skb_dequeue(&entry->tx_wait))) { Loading Loading @@ -409,8 +420,7 @@ lec_start_xmit(struct sk_buff *skb, struct net_device *dev) } /* The inverse routine to net_open(). */ static int lec_close(struct net_device *dev) static int lec_close(struct net_device *dev) { netif_stop_queue(dev); return 0; Loading @@ -420,14 +430,12 @@ lec_close(struct net_device *dev) * Get the current statistics. * This may be called with the card open or closed. */ static struct net_device_stats * lec_get_stats(struct net_device *dev) static struct net_device_stats *lec_get_stats(struct net_device *dev) { return &((struct lec_priv *)dev->priv)->stats; } static int lec_atm_send(struct atm_vcc *vcc, struct sk_buff *skb) static int lec_atm_send(struct atm_vcc *vcc, struct sk_buff *skb) { unsigned long flags; struct net_device *dev = (struct net_device *)vcc->proto_data; Loading Loading @@ -479,9 +487,9 @@ lec_atm_send(struct atm_vcc *vcc, struct sk_buff *skb) mesg->content.normal.targetless_le_arp); DPRINTK("lec: in l_arp_update\n"); if (mesg->sizeoftlvs != 0) { /* LANE2 3.1.5 */ DPRINTK("lec: LANE2 3.1.5, got tlvs, size %d\n", mesg->sizeoftlvs); lane2_associate_ind(dev, mesg->content.normal.mac_addr, DPRINTK("lec: LANE2 3.1.5, got tlvs, size %d\n", mesg->sizeoftlvs); lane2_associate_ind(dev, mesg->content.normal.mac_addr, tmp, mesg->sizeoftlvs); } break; Loading @@ -490,8 +498,7 @@ lec_atm_send(struct atm_vcc *vcc, struct sk_buff *skb) mesg->content.config.maximum_unknown_frame_count; priv->max_unknown_frame_time = (mesg->content.config.max_unknown_frame_time * HZ); priv->max_retry_count = mesg->content.config.max_retry_count; priv->max_retry_count = mesg->content.config.max_retry_count; priv->aging_time = (mesg->content.config.aging_time * HZ); priv->forward_delay_time = (mesg->content.config.forward_delay_time * HZ); Loading @@ -514,45 +521,56 @@ lec_atm_send(struct atm_vcc *vcc, struct sk_buff *skb) mesg->content.normal.flag); break; case l_set_lecid: priv->lecid=(unsigned short)(0xffff&mesg->content.normal.flag); priv->lecid = (unsigned short)(0xffff & mesg->content.normal.flag); break; case l_should_bridge: { case l_should_bridge: #if defined(CONFIG_BRIDGE) || defined(CONFIG_BRIDGE_MODULE) { struct net_bridge_fdb_entry *f; DPRINTK("%s: bridge zeppelin asks about 0x%02x:%02x:%02x:%02x:%02x:%02x\n", dev->name, mesg->content.proxy.mac_addr[0], mesg->content.proxy.mac_addr[1], mesg->content.proxy.mac_addr[2], mesg->content.proxy.mac_addr[3], mesg->content.proxy.mac_addr[4], mesg->content.proxy.mac_addr[5]); DPRINTK ("%s: bridge zeppelin asks about 0x%02x:%02x:%02x:%02x:%02x:%02x\n", dev->name, mesg->content.proxy.mac_addr[0], mesg->content.proxy.mac_addr[1], mesg->content.proxy.mac_addr[2], mesg->content.proxy.mac_addr[3], mesg->content.proxy.mac_addr[4], mesg->content.proxy.mac_addr[5]); if (br_fdb_get_hook == NULL || dev->br_port == NULL) break; f = br_fdb_get_hook(dev->br_port->br, mesg->content.proxy.mac_addr); if (f != NULL && f->dst->dev != dev && f->dst->state == BR_STATE_FORWARDING) { f = br_fdb_get_hook(dev->br_port->br, mesg->content.proxy.mac_addr); if (f != NULL && f->dst->dev != dev && f->dst->state == BR_STATE_FORWARDING) { /* hit from bridge table, send LE_ARP_RESPONSE */ struct sk_buff *skb2; struct sock *sk; DPRINTK("%s: entry found, responding to zeppelin\n", dev->name); skb2 = alloc_skb(sizeof(struct atmlec_msg), GFP_ATOMIC); DPRINTK ("%s: entry found, responding to zeppelin\n", dev->name); skb2 = alloc_skb(sizeof(struct atmlec_msg), GFP_ATOMIC); if (skb2 == NULL) { br_fdb_put_hook(f); break; } skb2->len = sizeof(struct atmlec_msg); memcpy(skb2->data, mesg, sizeof(struct atmlec_msg)); memcpy(skb2->data, mesg, sizeof(struct atmlec_msg)); atm_force_charge(priv->lecd, skb2->truesize); sk = sk_atm(priv->lecd); skb_queue_tail(&sk->sk_receive_queue, skb2); sk->sk_data_ready(sk, skb2->len); } if (f != NULL) br_fdb_put_hook(f); #endif /* defined(CONFIG_BRIDGE) || defined(CONFIG_BRIDGE_MODULE) */ if (f != NULL) br_fdb_put_hook(f); } #endif /* defined(CONFIG_BRIDGE) || defined(CONFIG_BRIDGE_MODULE) */ break; default: printk("%s: Unknown message type %d\n", dev->name, mesg->type); Loading @@ -563,8 +581,7 @@ lec_atm_send(struct atm_vcc *vcc, struct sk_buff *skb) return 0; } static void lec_atm_close(struct atm_vcc *vcc) static void lec_atm_close(struct atm_vcc *vcc) { struct sk_buff *skb; struct net_device *dev = (struct net_device *)vcc->proto_data; Loading Loading @@ -658,14 +675,14 @@ static int lec_change_mtu(struct net_device *dev, int new_mtu) static void lec_set_multicast_list(struct net_device *dev) { /* by default, all multicast frames arrive over the bus. /* * by default, all multicast frames arrive over the bus. * eventually support selective multicast service */ return; } static void lec_init(struct net_device *dev) static void lec_init(struct net_device *dev) { dev->change_mtu = lec_change_mtu; dev->open = lec_open; Loading @@ -684,7 +701,8 @@ static unsigned char lec_ctrl_magic[] = { 0xff, 0x00, 0x01, 0x01 }; 0x01 }; #define LEC_DATA_DIRECT_8023 2 #define LEC_DATA_DIRECT_8025 3 Loading @@ -695,8 +713,7 @@ static int lec_is_data_direct(struct atm_vcc *vcc) (vcc->sap.blli[0].l3.tr9577.snap[4] == LEC_DATA_DIRECT_8025)); } static void lec_push(struct atm_vcc *vcc, struct sk_buff *skb) static void lec_push(struct atm_vcc *vcc, struct sk_buff *skb) { unsigned long flags; struct net_device *dev = (struct net_device *)vcc->proto_data; Loading Loading @@ -743,10 +760,11 @@ lec_push(struct atm_vcc *vcc, struct sk_buff *skb) atm_return(vcc, skb->truesize); if (*(uint16_t *) skb->data == htons(priv->lecid) || !priv->lecd || !(dev->flags & IFF_UP)) { /* Probably looping back, or if lecd is missing, lecd has gone down */ !priv->lecd || !(dev->flags & IFF_UP)) { /* * Probably looping back, or if lecd is missing, * lecd has gone down */ DPRINTK("Ignoring frame...\n"); dev_kfree_skb(skb); return; Loading @@ -758,17 +776,22 @@ lec_push(struct atm_vcc *vcc, struct sk_buff *skb) #endif dst = ((struct lecdatahdr_8023 *)skb->data)->h_dest; /* If this is a Data Direct VCC, and the VCC does not match /* * If this is a Data Direct VCC, and the VCC does not match * the LE_ARP cache entry, delete the LE_ARP cache entry. */ spin_lock_irqsave(&priv->lec_arp_lock, flags); if (lec_is_data_direct(vcc)) { #ifdef CONFIG_TR if (priv->is_trdev) src = ((struct lecdatahdr_8025 *) skb->data)->h_source; src = ((struct lecdatahdr_8025 *)skb->data)-> h_source; else #endif src = ((struct lecdatahdr_8023 *) skb->data)->h_source; src = ((struct lecdatahdr_8023 *)skb->data)-> h_source; entry = lec_arp_find(priv, src); if (entry && entry->vcc != vcc) { lec_arp_remove(priv, entry); Loading @@ -789,7 +812,8 @@ lec_push(struct atm_vcc *vcc, struct sk_buff *skb) skb->dev = dev; skb_pull(skb, 2); /* skip lec_id */ #ifdef CONFIG_TR if (priv->is_trdev) skb->protocol = tr_type_trans(skb, dev); if (priv->is_trdev) skb->protocol = tr_type_trans(skb, dev); else #endif skb->protocol = eth_type_trans(skb, dev); Loading @@ -800,8 +824,7 @@ lec_push(struct atm_vcc *vcc, struct sk_buff *skb) } } static void lec_pop(struct atm_vcc *vcc, struct sk_buff *skb) static void lec_pop(struct atm_vcc *vcc, struct sk_buff *skb) { struct lec_vcc_priv *vpriv = LEC_VCC_PRIV(vcc); struct net_device *dev = skb->dev; Loading @@ -820,8 +843,7 @@ lec_pop(struct atm_vcc *vcc, struct sk_buff *skb) } } static int lec_vcc_attach(struct atm_vcc *vcc, void __user *arg) static int lec_vcc_attach(struct atm_vcc *vcc, void __user *arg) { struct lec_vcc_priv *vpriv; int bytes_left; Loading @@ -830,7 +852,8 @@ lec_vcc_attach(struct atm_vcc *vcc, void __user *arg) /* Lecd must be up in this case */ bytes_left = copy_from_user(&ioc_data, arg, sizeof(struct atmlec_ioc)); if (bytes_left != 0) { printk("lec: lec_vcc_attach, copy from user failed for %d bytes\n", printk ("lec: lec_vcc_attach, copy from user failed for %d bytes\n", bytes_left); } if (ioc_data.dev_num < 0 || ioc_data.dev_num >= MAX_LEC_ITF || Loading @@ -849,8 +872,7 @@ lec_vcc_attach(struct atm_vcc *vcc, void __user *arg) return 0; } static int lec_mcast_attach(struct atm_vcc *vcc, int arg) static int lec_mcast_attach(struct atm_vcc *vcc, int arg) { if (arg < 0 || arg >= MAX_LEC_ITF || !dev_lec[arg]) return -EINVAL; Loading @@ -859,8 +881,7 @@ lec_mcast_attach(struct atm_vcc *vcc, int arg) } /* Initialize device. */ static int lecd_attach(struct atm_vcc *vcc, int arg) static int lecd_attach(struct atm_vcc *vcc, int arg) { int i; struct lec_priv *priv; Loading Loading @@ -974,7 +995,6 @@ static void lec_info(struct seq_file *seq, struct lec_arp_table *entry) seq_putc(seq, '\n'); } struct lec_state { unsigned long flags; struct lec_priv *locked; Loading Loading @@ -1046,8 +1066,7 @@ static void *lec_priv_walk(struct lec_state *state, loff_t *l, state->locked = priv; spin_lock_irqsave(&priv->lec_arp_lock, state->flags); } if (!lec_arp_walk(state, l, priv) && !lec_misc_walk(state, l, priv)) { if (!lec_arp_walk(state, l, priv) && !lec_misc_walk(state, l, priv)) { spin_unlock_irqrestore(&priv->lec_arp_lock, state->flags); state->locked = NULL; /* Partial state reset for the next time we get called */ Loading Loading @@ -1306,7 +1325,6 @@ static int lane2_resolve(struct net_device *dev, u8 *dst_mac, int force, return retval; } /* * LANE2: 3.1.4, LE_ASSOCIATE.request * Associate the *tlvs with the *lan_dst address. Loading Loading @@ -1340,7 +1358,8 @@ static int lane2_associate_req (struct net_device *dev, u8 *lan_dst, retval = send_to_lecd(priv, l_associate_req, NULL, NULL, skb); if (retval != 0) printk("lec.c: lane2_associate_req() failed\n"); /* If the previous association has changed we must /* * If the previous association has changed we must * somehow notify other LANE entities about the change */ return (1); Loading @@ -1357,8 +1376,12 @@ static void lane2_associate_ind (struct net_device *dev, u8 *mac_addr, int i = 0; #endif struct lec_priv *priv = (struct lec_priv *)dev->priv; #if 0 /* Why have the TLVs in LE_ARP entries since we do not use them? When you uncomment this code, make sure the TLVs get freed when entry is killed */ #if 0 /* * Why have the TLVs in LE_ARP entries * since we do not use them? When you * uncomment this code, make sure the * TLVs get freed when entry is killed */ struct lec_arp_table *entry = lec_arp_find(priv, mac_addr); if (entry == NULL) Loading Loading
net/atm/lec.c +715 −692 Original line number Diff line number Diff line /* * lec.c: Lan Emulation driver * Marko Kiiskila mkiiskila@yahoo.com * * Marko Kiiskila <mkiiskila@yahoo.com> */ #include <linux/kernel.h> Loading Loading @@ -55,13 +55,16 @@ static unsigned char bridge_ula_lec[] = {0x01, 0x80, 0xc2, 0x00, 0x00}; #define DPRINTK(format,args...) #endif #define DUMP_PACKETS 0 /* 0 = None, #define DUMP_PACKETS 0 /* * 0 = None, * 1 = 30 first bytes * 2 = Whole packet */ #define LEC_UNRES_QUE_LEN 8 /* number of tx packets to queue for a single destination while waiting for SVC */ #define LEC_UNRES_QUE_LEN 8 /* * number of tx packets to queue for a * single destination while waiting for SVC */ static int lec_open(struct net_device *dev); static int lec_start_xmit(struct sk_buff *skb, struct net_device *dev); Loading Loading @@ -100,7 +103,8 @@ static void lec_set_flush_tran_id(struct lec_priv *priv, unsigned long tran_id); static void lec_vcc_added(struct lec_priv *priv, struct atmlec_ioc *ioc_data, struct atm_vcc *vcc, void (*old_push)(struct atm_vcc *vcc, struct sk_buff *skb)); void (*old_push) (struct atm_vcc *vcc, struct sk_buff *skb)); static void lec_vcc_close(struct lec_priv *priv, struct atm_vcc *vcc); static struct lane2_ops lane2_ops = { Loading @@ -121,9 +125,11 @@ static void lec_handle_bridge(struct sk_buff *skb, struct net_device *dev) char *buff; struct lec_priv *priv; /* Check if this is a BPDU. If so, ask zeppelin to send /* * Check if this is a BPDU. If so, ask zeppelin to send * LE_TOPOLOGY_REQUEST with the same value of Topology Change bit * as the Config BPDU has */ * as the Config BPDU has */ eth = (struct ethhdr *)skb->data; buff = skb->data + skb->dev->hard_header_len; if (*buff++ == 0x42 && *buff++ == 0x42 && *buff++ == 0x03) { Loading @@ -132,7 +138,8 @@ static void lec_handle_bridge(struct sk_buff *skb, struct net_device *dev) struct atmlec_msg *mesg; skb2 = alloc_skb(sizeof(struct atmlec_msg), GFP_ATOMIC); if (skb2 == NULL) return; if (skb2 == NULL) return; skb2->len = sizeof(struct atmlec_msg); mesg = (struct atmlec_msg *)skb2->data; mesg->type = l_topology_change; Loading Loading @@ -173,8 +180,7 @@ static unsigned char *get_tr_dst(unsigned char *packet, unsigned char *rdesc) riflen = (ntohs(trh->rcf) & TR_RCF_LEN_MASK) >> 8; if ((ntohs(trh->rcf) >> 13) != 0) return bus_mac; /* ARE or STE */ } else } else return trh->daddr; /* not source routed */ if (riflen < 6) Loading Loading @@ -204,8 +210,7 @@ static unsigned char *get_tr_dst(unsigned char *packet, unsigned char *rdesc) * there is non-reboot way to recover if something goes wrong. */ static int lec_open(struct net_device *dev) static int lec_open(struct net_device *dev) { struct lec_priv *priv = (struct lec_priv *)dev->priv; Loading @@ -231,16 +236,14 @@ lec_send(struct atm_vcc *vcc, struct sk_buff *skb, struct lec_priv *priv) priv->stats.tx_bytes += skb->len; } static void lec_tx_timeout(struct net_device *dev) static void lec_tx_timeout(struct net_device *dev) { printk(KERN_INFO "%s: tx timeout\n", dev->name); dev->trans_start = jiffies; netif_wake_queue(dev); } static int lec_start_xmit(struct sk_buff *skb, struct net_device *dev) static int lec_start_xmit(struct sk_buff *skb, struct net_device *dev) { struct sk_buff *skb2; struct lec_priv *priv = (struct lec_priv *)dev->priv; Loading Loading @@ -280,7 +283,8 @@ lec_start_xmit(struct sk_buff *skb, struct net_device *dev) DPRINTK("lec_start_xmit: reallocating skb\n"); skb2 = skb_realloc_headroom(skb, LEC_HEADER_LEN); kfree_skb(skb); if (skb2 == NULL) return 0; if (skb2 == NULL) return 0; skb = skb2; } skb_push(skb, 2); Loading @@ -290,12 +294,15 @@ lec_start_xmit(struct sk_buff *skb, struct net_device *dev) lec_h->le_header = htons(priv->lecid); #ifdef CONFIG_TR /* Ugly. Use this to realign Token Ring packets for * e.g. PCA-200E driver. */ /* * Ugly. Use this to realign Token Ring packets for * e.g. PCA-200E driver. */ if (priv->is_trdev) { skb2 = skb_realloc_headroom(skb, LEC_HEADER_LEN); kfree_skb(skb); if (skb2 == NULL) return 0; if (skb2 == NULL) return 0; skb = skb2; } #endif Loading Loading @@ -328,7 +335,8 @@ lec_start_xmit(struct sk_buff *skb, struct net_device *dev) if (skb->len < min_frame_size) { if ((skb->len + skb_tailroom(skb)) < min_frame_size) { skb2 = skb_copy_expand(skb, 0, min_frame_size - skb->truesize, GFP_ATOMIC); min_frame_size - skb->truesize, GFP_ATOMIC); dev_kfree_skb(skb); if (skb2 == NULL) { priv->stats.tx_dropped++; Loading Loading @@ -357,25 +365,28 @@ lec_start_xmit(struct sk_buff *skb, struct net_device *dev) vcc, vcc ? vcc->flags : 0, entry); if (!vcc || !test_bit(ATM_VF_READY, &vcc->flags)) { if (entry && (entry->tx_wait.qlen < LEC_UNRES_QUE_LEN)) { DPRINTK("%s:lec_start_xmit: queuing packet, ", dev->name); DPRINTK("%s:lec_start_xmit: queuing packet, ", dev->name); DPRINTK("MAC address 0x%02x:%02x:%02x:%02x:%02x:%02x\n", lec_h->h_dest[0], lec_h->h_dest[1], lec_h->h_dest[2], lec_h->h_dest[3], lec_h->h_dest[4], lec_h->h_dest[5]); lec_h->h_dest[0], lec_h->h_dest[1], lec_h->h_dest[2], lec_h->h_dest[3], lec_h->h_dest[4], lec_h->h_dest[5]); skb_queue_tail(&entry->tx_wait, skb); } else { DPRINTK("%s:lec_start_xmit: tx queue full or no arp entry, dropping, ", dev->name); DPRINTK ("%s:lec_start_xmit: tx queue full or no arp entry, dropping, ", dev->name); DPRINTK("MAC address 0x%02x:%02x:%02x:%02x:%02x:%02x\n", lec_h->h_dest[0], lec_h->h_dest[1], lec_h->h_dest[2], lec_h->h_dest[3], lec_h->h_dest[4], lec_h->h_dest[5]); lec_h->h_dest[0], lec_h->h_dest[1], lec_h->h_dest[2], lec_h->h_dest[3], lec_h->h_dest[4], lec_h->h_dest[5]); priv->stats.tx_dropped++; dev_kfree_skb(skb); } return 0; } #if DUMP_PACKETS > 0 printk("%s:sending to vpi:%d vci:%d\n", dev->name, vcc->vpi, vcc->vci); printk("%s:sending to vpi:%d vci:%d\n", dev->name, vcc->vpi, vcc->vci); #endif /* DUMP_PACKETS > 0 */ while (entry && (skb2 = skb_dequeue(&entry->tx_wait))) { Loading Loading @@ -409,8 +420,7 @@ lec_start_xmit(struct sk_buff *skb, struct net_device *dev) } /* The inverse routine to net_open(). */ static int lec_close(struct net_device *dev) static int lec_close(struct net_device *dev) { netif_stop_queue(dev); return 0; Loading @@ -420,14 +430,12 @@ lec_close(struct net_device *dev) * Get the current statistics. * This may be called with the card open or closed. */ static struct net_device_stats * lec_get_stats(struct net_device *dev) static struct net_device_stats *lec_get_stats(struct net_device *dev) { return &((struct lec_priv *)dev->priv)->stats; } static int lec_atm_send(struct atm_vcc *vcc, struct sk_buff *skb) static int lec_atm_send(struct atm_vcc *vcc, struct sk_buff *skb) { unsigned long flags; struct net_device *dev = (struct net_device *)vcc->proto_data; Loading Loading @@ -479,9 +487,9 @@ lec_atm_send(struct atm_vcc *vcc, struct sk_buff *skb) mesg->content.normal.targetless_le_arp); DPRINTK("lec: in l_arp_update\n"); if (mesg->sizeoftlvs != 0) { /* LANE2 3.1.5 */ DPRINTK("lec: LANE2 3.1.5, got tlvs, size %d\n", mesg->sizeoftlvs); lane2_associate_ind(dev, mesg->content.normal.mac_addr, DPRINTK("lec: LANE2 3.1.5, got tlvs, size %d\n", mesg->sizeoftlvs); lane2_associate_ind(dev, mesg->content.normal.mac_addr, tmp, mesg->sizeoftlvs); } break; Loading @@ -490,8 +498,7 @@ lec_atm_send(struct atm_vcc *vcc, struct sk_buff *skb) mesg->content.config.maximum_unknown_frame_count; priv->max_unknown_frame_time = (mesg->content.config.max_unknown_frame_time * HZ); priv->max_retry_count = mesg->content.config.max_retry_count; priv->max_retry_count = mesg->content.config.max_retry_count; priv->aging_time = (mesg->content.config.aging_time * HZ); priv->forward_delay_time = (mesg->content.config.forward_delay_time * HZ); Loading @@ -514,45 +521,56 @@ lec_atm_send(struct atm_vcc *vcc, struct sk_buff *skb) mesg->content.normal.flag); break; case l_set_lecid: priv->lecid=(unsigned short)(0xffff&mesg->content.normal.flag); priv->lecid = (unsigned short)(0xffff & mesg->content.normal.flag); break; case l_should_bridge: { case l_should_bridge: #if defined(CONFIG_BRIDGE) || defined(CONFIG_BRIDGE_MODULE) { struct net_bridge_fdb_entry *f; DPRINTK("%s: bridge zeppelin asks about 0x%02x:%02x:%02x:%02x:%02x:%02x\n", dev->name, mesg->content.proxy.mac_addr[0], mesg->content.proxy.mac_addr[1], mesg->content.proxy.mac_addr[2], mesg->content.proxy.mac_addr[3], mesg->content.proxy.mac_addr[4], mesg->content.proxy.mac_addr[5]); DPRINTK ("%s: bridge zeppelin asks about 0x%02x:%02x:%02x:%02x:%02x:%02x\n", dev->name, mesg->content.proxy.mac_addr[0], mesg->content.proxy.mac_addr[1], mesg->content.proxy.mac_addr[2], mesg->content.proxy.mac_addr[3], mesg->content.proxy.mac_addr[4], mesg->content.proxy.mac_addr[5]); if (br_fdb_get_hook == NULL || dev->br_port == NULL) break; f = br_fdb_get_hook(dev->br_port->br, mesg->content.proxy.mac_addr); if (f != NULL && f->dst->dev != dev && f->dst->state == BR_STATE_FORWARDING) { f = br_fdb_get_hook(dev->br_port->br, mesg->content.proxy.mac_addr); if (f != NULL && f->dst->dev != dev && f->dst->state == BR_STATE_FORWARDING) { /* hit from bridge table, send LE_ARP_RESPONSE */ struct sk_buff *skb2; struct sock *sk; DPRINTK("%s: entry found, responding to zeppelin\n", dev->name); skb2 = alloc_skb(sizeof(struct atmlec_msg), GFP_ATOMIC); DPRINTK ("%s: entry found, responding to zeppelin\n", dev->name); skb2 = alloc_skb(sizeof(struct atmlec_msg), GFP_ATOMIC); if (skb2 == NULL) { br_fdb_put_hook(f); break; } skb2->len = sizeof(struct atmlec_msg); memcpy(skb2->data, mesg, sizeof(struct atmlec_msg)); memcpy(skb2->data, mesg, sizeof(struct atmlec_msg)); atm_force_charge(priv->lecd, skb2->truesize); sk = sk_atm(priv->lecd); skb_queue_tail(&sk->sk_receive_queue, skb2); sk->sk_data_ready(sk, skb2->len); } if (f != NULL) br_fdb_put_hook(f); #endif /* defined(CONFIG_BRIDGE) || defined(CONFIG_BRIDGE_MODULE) */ if (f != NULL) br_fdb_put_hook(f); } #endif /* defined(CONFIG_BRIDGE) || defined(CONFIG_BRIDGE_MODULE) */ break; default: printk("%s: Unknown message type %d\n", dev->name, mesg->type); Loading @@ -563,8 +581,7 @@ lec_atm_send(struct atm_vcc *vcc, struct sk_buff *skb) return 0; } static void lec_atm_close(struct atm_vcc *vcc) static void lec_atm_close(struct atm_vcc *vcc) { struct sk_buff *skb; struct net_device *dev = (struct net_device *)vcc->proto_data; Loading Loading @@ -658,14 +675,14 @@ static int lec_change_mtu(struct net_device *dev, int new_mtu) static void lec_set_multicast_list(struct net_device *dev) { /* by default, all multicast frames arrive over the bus. /* * by default, all multicast frames arrive over the bus. * eventually support selective multicast service */ return; } static void lec_init(struct net_device *dev) static void lec_init(struct net_device *dev) { dev->change_mtu = lec_change_mtu; dev->open = lec_open; Loading @@ -684,7 +701,8 @@ static unsigned char lec_ctrl_magic[] = { 0xff, 0x00, 0x01, 0x01 }; 0x01 }; #define LEC_DATA_DIRECT_8023 2 #define LEC_DATA_DIRECT_8025 3 Loading @@ -695,8 +713,7 @@ static int lec_is_data_direct(struct atm_vcc *vcc) (vcc->sap.blli[0].l3.tr9577.snap[4] == LEC_DATA_DIRECT_8025)); } static void lec_push(struct atm_vcc *vcc, struct sk_buff *skb) static void lec_push(struct atm_vcc *vcc, struct sk_buff *skb) { unsigned long flags; struct net_device *dev = (struct net_device *)vcc->proto_data; Loading Loading @@ -743,10 +760,11 @@ lec_push(struct atm_vcc *vcc, struct sk_buff *skb) atm_return(vcc, skb->truesize); if (*(uint16_t *) skb->data == htons(priv->lecid) || !priv->lecd || !(dev->flags & IFF_UP)) { /* Probably looping back, or if lecd is missing, lecd has gone down */ !priv->lecd || !(dev->flags & IFF_UP)) { /* * Probably looping back, or if lecd is missing, * lecd has gone down */ DPRINTK("Ignoring frame...\n"); dev_kfree_skb(skb); return; Loading @@ -758,17 +776,22 @@ lec_push(struct atm_vcc *vcc, struct sk_buff *skb) #endif dst = ((struct lecdatahdr_8023 *)skb->data)->h_dest; /* If this is a Data Direct VCC, and the VCC does not match /* * If this is a Data Direct VCC, and the VCC does not match * the LE_ARP cache entry, delete the LE_ARP cache entry. */ spin_lock_irqsave(&priv->lec_arp_lock, flags); if (lec_is_data_direct(vcc)) { #ifdef CONFIG_TR if (priv->is_trdev) src = ((struct lecdatahdr_8025 *) skb->data)->h_source; src = ((struct lecdatahdr_8025 *)skb->data)-> h_source; else #endif src = ((struct lecdatahdr_8023 *) skb->data)->h_source; src = ((struct lecdatahdr_8023 *)skb->data)-> h_source; entry = lec_arp_find(priv, src); if (entry && entry->vcc != vcc) { lec_arp_remove(priv, entry); Loading @@ -789,7 +812,8 @@ lec_push(struct atm_vcc *vcc, struct sk_buff *skb) skb->dev = dev; skb_pull(skb, 2); /* skip lec_id */ #ifdef CONFIG_TR if (priv->is_trdev) skb->protocol = tr_type_trans(skb, dev); if (priv->is_trdev) skb->protocol = tr_type_trans(skb, dev); else #endif skb->protocol = eth_type_trans(skb, dev); Loading @@ -800,8 +824,7 @@ lec_push(struct atm_vcc *vcc, struct sk_buff *skb) } } static void lec_pop(struct atm_vcc *vcc, struct sk_buff *skb) static void lec_pop(struct atm_vcc *vcc, struct sk_buff *skb) { struct lec_vcc_priv *vpriv = LEC_VCC_PRIV(vcc); struct net_device *dev = skb->dev; Loading @@ -820,8 +843,7 @@ lec_pop(struct atm_vcc *vcc, struct sk_buff *skb) } } static int lec_vcc_attach(struct atm_vcc *vcc, void __user *arg) static int lec_vcc_attach(struct atm_vcc *vcc, void __user *arg) { struct lec_vcc_priv *vpriv; int bytes_left; Loading @@ -830,7 +852,8 @@ lec_vcc_attach(struct atm_vcc *vcc, void __user *arg) /* Lecd must be up in this case */ bytes_left = copy_from_user(&ioc_data, arg, sizeof(struct atmlec_ioc)); if (bytes_left != 0) { printk("lec: lec_vcc_attach, copy from user failed for %d bytes\n", printk ("lec: lec_vcc_attach, copy from user failed for %d bytes\n", bytes_left); } if (ioc_data.dev_num < 0 || ioc_data.dev_num >= MAX_LEC_ITF || Loading @@ -849,8 +872,7 @@ lec_vcc_attach(struct atm_vcc *vcc, void __user *arg) return 0; } static int lec_mcast_attach(struct atm_vcc *vcc, int arg) static int lec_mcast_attach(struct atm_vcc *vcc, int arg) { if (arg < 0 || arg >= MAX_LEC_ITF || !dev_lec[arg]) return -EINVAL; Loading @@ -859,8 +881,7 @@ lec_mcast_attach(struct atm_vcc *vcc, int arg) } /* Initialize device. */ static int lecd_attach(struct atm_vcc *vcc, int arg) static int lecd_attach(struct atm_vcc *vcc, int arg) { int i; struct lec_priv *priv; Loading Loading @@ -974,7 +995,6 @@ static void lec_info(struct seq_file *seq, struct lec_arp_table *entry) seq_putc(seq, '\n'); } struct lec_state { unsigned long flags; struct lec_priv *locked; Loading Loading @@ -1046,8 +1066,7 @@ static void *lec_priv_walk(struct lec_state *state, loff_t *l, state->locked = priv; spin_lock_irqsave(&priv->lec_arp_lock, state->flags); } if (!lec_arp_walk(state, l, priv) && !lec_misc_walk(state, l, priv)) { if (!lec_arp_walk(state, l, priv) && !lec_misc_walk(state, l, priv)) { spin_unlock_irqrestore(&priv->lec_arp_lock, state->flags); state->locked = NULL; /* Partial state reset for the next time we get called */ Loading Loading @@ -1306,7 +1325,6 @@ static int lane2_resolve(struct net_device *dev, u8 *dst_mac, int force, return retval; } /* * LANE2: 3.1.4, LE_ASSOCIATE.request * Associate the *tlvs with the *lan_dst address. Loading Loading @@ -1340,7 +1358,8 @@ static int lane2_associate_req (struct net_device *dev, u8 *lan_dst, retval = send_to_lecd(priv, l_associate_req, NULL, NULL, skb); if (retval != 0) printk("lec.c: lane2_associate_req() failed\n"); /* If the previous association has changed we must /* * If the previous association has changed we must * somehow notify other LANE entities about the change */ return (1); Loading @@ -1357,8 +1376,12 @@ static void lane2_associate_ind (struct net_device *dev, u8 *mac_addr, int i = 0; #endif struct lec_priv *priv = (struct lec_priv *)dev->priv; #if 0 /* Why have the TLVs in LE_ARP entries since we do not use them? When you uncomment this code, make sure the TLVs get freed when entry is killed */ #if 0 /* * Why have the TLVs in LE_ARP entries * since we do not use them? When you * uncomment this code, make sure the * TLVs get freed when entry is killed */ struct lec_arp_table *entry = lec_arp_find(priv, mac_addr); if (entry == NULL) Loading