36 #include <linux/netdevice.h>
38 #include <linux/if_vlan.h>
40 #include <linux/module.h>
49 #define VLAN_NONE 0xfff
52 #define F_SYNC_WR (1 << 12)
93 static inline unsigned int arp_hash(
const u32 *
key,
int ifindex)
98 static inline unsigned int ipv6_hash(
const u32 *
key,
int ifindex)
100 u32 xor = key[0] ^ key[1] ^ key[2] ^ key[3];
105 static unsigned int addr_hash(
const u32 *
addr,
int addr_len,
int ifindex)
107 return addr_len == 4 ? arp_hash(addr, ifindex) :
108 ipv6_hash(addr, ifindex);
118 static int addreq(
const struct l2t_entry *e,
const u32 *addr)
121 return (e->
addr[0] ^ addr[0]) | (e->
addr[1] ^ addr[1]) |
122 (e->
addr[2] ^ addr[2]) | (e->
addr[3] ^ addr[3]);
123 return e->
addr[0] ^ addr[0];
130 neigh_release(e->
neigh);
196 "Unexpected L2T_WRITE_RPL status %u for entry %u\n",
201 if (tid & F_SYNC_WR) {
206 send_pending(adap, e);
210 spin_unlock(&e->
lock);
231 struct adapter *adap = netdev2adap(dev);
237 spin_lock_bh(&e->
lock);
240 spin_unlock_bh(&e->
lock);
245 spin_lock_bh(&e->
lock);
248 spin_unlock_bh(&e->
lock);
251 arpq_enqueue(e, skb);
252 spin_unlock_bh(&e->
lock);
256 spin_lock_bh(&e->
lock);
258 write_l2e(adap, e, 1);
259 spin_unlock_bh(&e->
lock);
306 static void t4_l2e_free(
struct l2t_entry *e)
310 spin_lock_bh(&e->
lock);
313 neigh_release(e->
neigh);
324 spin_unlock_bh(&e->
lock);
343 unsigned int nud_state;
346 if (neigh != e->
neigh)
347 neigh_replace(e, neigh);
356 spin_unlock(&e->
lock);
366 int addr_len = neigh->
tbl->key_len;
368 int ifidx = neigh->
dev->ifindex;
369 int hash = addr_hash(addr, addr_len, ifidx);
372 lport = netdev2pinfo(physdev)->tx_chan + 4;
374 lport = netdev2pinfo(physdev)->lport;
383 if (!addreq(e, addr) && e->
ifindex == ifidx &&
387 reuse_entry(e, neigh);
400 e->
v6 = addr_len == 16;
402 neigh_replace(e, neigh);
406 spin_unlock(&e->
lock);
443 int addr_len = neigh->
tbl->key_len;
445 int ifidx = neigh->
dev->ifindex;
446 int hash = addr_hash(addr, addr_len, ifidx);
450 if (!addreq(e, addr) && e->
ifindex == ifidx) {
454 spin_unlock(&e->
lock);
463 if (neigh != e->
neigh)
464 neigh_replace(e, neigh);
472 write_l2e(adap, e, 1);
478 write_l2e(adap, e, 0);
481 spin_unlock_bh(&e->
lock);
484 handle_failed_resolution(adap, arpq);
509 static inline void *l2t_get_idx(
struct seq_file *seq, loff_t
pos)
516 static void *l2t_seq_start(
struct seq_file *seq, loff_t *
pos)
521 static void *l2t_seq_next(
struct seq_file *seq,
void *
v, loff_t *pos)
523 v = l2t_get_idx(seq, *pos);
529 static void l2t_seq_stop(
struct seq_file *seq,
void *v)
533 static char l2e_state(
const struct l2t_entry *e)
546 static int l2t_seq_show(
struct seq_file *seq,
void *v)
550 "Ethernet address VLAN/P LP State Users Port\n");
555 spin_lock_bh(&e->
lock);
560 seq_printf(seq,
"%4u %-25s %17pM %4d %u %2u %c %5u %s\n",
565 spin_unlock_bh(&e->
lock);
571 .start = l2t_seq_start,
572 .next = l2t_seq_next,
573 .stop = l2t_seq_stop,
592 .open = l2t_seq_open,