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