Lines Matching refs:e
67 static inline unsigned int vlan_prio(const struct l2t_entry *e) in vlan_prio() argument
69 return e->vlan >> 13; in vlan_prio()
72 static inline void l2t_hold(struct l2t_data *d, struct l2t_entry *e) in l2t_hold() argument
74 if (atomic_add_return(1, &e->refcnt) == 1) /* 0 -> 1 transition */ in l2t_hold()
120 static int addreq(const struct l2t_entry *e, const u32 *addr) in addreq() argument
122 if (e->v6) in addreq()
123 return (e->addr[0] ^ addr[0]) | (e->addr[1] ^ addr[1]) | in addreq()
124 (e->addr[2] ^ addr[2]) | (e->addr[3] ^ addr[3]); in addreq()
125 return e->addr[0] ^ addr[0]; in addreq()
128 static void neigh_replace(struct l2t_entry *e, struct neighbour *n) in neigh_replace() argument
131 if (e->neigh) in neigh_replace()
132 neigh_release(e->neigh); in neigh_replace()
133 e->neigh = n; in neigh_replace()
140 static int write_l2e(struct adapter *adap, struct l2t_entry *e, int sync) in write_l2e() argument
143 unsigned int l2t_idx = e->idx + d->l2t_start; in write_l2e()
157 req->params = htons(L2T_W_PORT_V(e->lport) | L2T_W_NOREPLY_V(!sync)); in write_l2e()
159 req->vlan = htons(e->vlan); in write_l2e()
160 if (e->neigh && !(e->neigh->dev->flags & IFF_LOOPBACK)) in write_l2e()
161 memcpy(e->dmac, e->neigh->ha, sizeof(e->dmac)); in write_l2e()
162 memcpy(req->dst_mac, e->dmac, sizeof(req->dst_mac)); in write_l2e()
167 if (sync && e->state != L2T_STATE_SWITCHING) in write_l2e()
168 e->state = L2T_STATE_SYNC_WRITE; in write_l2e()
176 static void send_pending(struct adapter *adap, struct l2t_entry *e) in send_pending() argument
178 while (e->arpq_head) { in send_pending()
179 struct sk_buff *skb = e->arpq_head; in send_pending()
181 e->arpq_head = skb->next; in send_pending()
185 e->arpq_tail = NULL; in send_pending()
207 struct l2t_entry *e = &d->l2tab[l2t_idx - d->l2t_start]; in do_l2t_write_rpl() local
209 spin_lock(&e->lock); in do_l2t_write_rpl()
210 if (e->state != L2T_STATE_SWITCHING) { in do_l2t_write_rpl()
211 send_pending(adap, e); in do_l2t_write_rpl()
212 e->state = (e->neigh->nud_state & NUD_STALE) ? in do_l2t_write_rpl()
215 spin_unlock(&e->lock); in do_l2t_write_rpl()
223 static inline void arpq_enqueue(struct l2t_entry *e, struct sk_buff *skb) in arpq_enqueue() argument
226 if (e->arpq_head) in arpq_enqueue()
227 e->arpq_tail->next = skb; in arpq_enqueue()
229 e->arpq_head = skb; in arpq_enqueue()
230 e->arpq_tail = skb; in arpq_enqueue()
234 struct l2t_entry *e) in cxgb4_l2t_send() argument
239 switch (e->state) { in cxgb4_l2t_send()
241 neigh_event_send(e->neigh, NULL); in cxgb4_l2t_send()
242 spin_lock_bh(&e->lock); in cxgb4_l2t_send()
243 if (e->state == L2T_STATE_STALE) in cxgb4_l2t_send()
244 e->state = L2T_STATE_VALID; in cxgb4_l2t_send()
245 spin_unlock_bh(&e->lock); in cxgb4_l2t_send()
250 spin_lock_bh(&e->lock); in cxgb4_l2t_send()
251 if (e->state != L2T_STATE_SYNC_WRITE && in cxgb4_l2t_send()
252 e->state != L2T_STATE_RESOLVING) { in cxgb4_l2t_send()
253 spin_unlock_bh(&e->lock); in cxgb4_l2t_send()
256 arpq_enqueue(e, skb); in cxgb4_l2t_send()
257 spin_unlock_bh(&e->lock); in cxgb4_l2t_send()
259 if (e->state == L2T_STATE_RESOLVING && in cxgb4_l2t_send()
260 !neigh_event_send(e->neigh, NULL)) { in cxgb4_l2t_send()
261 spin_lock_bh(&e->lock); in cxgb4_l2t_send()
262 if (e->state == L2T_STATE_RESOLVING && e->arpq_head) in cxgb4_l2t_send()
263 write_l2e(adap, e, 1); in cxgb4_l2t_send()
264 spin_unlock_bh(&e->lock); in cxgb4_l2t_send()
276 struct l2t_entry *end, *e, **p; in alloc_l2e() local
282 for (e = d->rover, end = &d->l2tab[d->l2t_size]; e != end; ++e) in alloc_l2e()
283 if (atomic_read(&e->refcnt) == 0) in alloc_l2e()
286 for (e = d->l2tab; atomic_read(&e->refcnt); ++e) in alloc_l2e()
289 d->rover = e + 1; in alloc_l2e()
296 if (e->state < L2T_STATE_SWITCHING) in alloc_l2e()
297 for (p = &d->l2tab[e->hash].first; *p; p = &(*p)->next) in alloc_l2e()
298 if (*p == e) { in alloc_l2e()
299 *p = e->next; in alloc_l2e()
300 e->next = NULL; in alloc_l2e()
304 e->state = L2T_STATE_UNUSED; in alloc_l2e()
305 return e; in alloc_l2e()
311 static void t4_l2e_free(struct l2t_entry *e) in t4_l2e_free() argument
315 spin_lock_bh(&e->lock); in t4_l2e_free()
316 if (atomic_read(&e->refcnt) == 0) { /* hasn't been recycled */ in t4_l2e_free()
317 if (e->neigh) { in t4_l2e_free()
318 neigh_release(e->neigh); in t4_l2e_free()
319 e->neigh = NULL; in t4_l2e_free()
321 while (e->arpq_head) { in t4_l2e_free()
322 struct sk_buff *skb = e->arpq_head; in t4_l2e_free()
324 e->arpq_head = skb->next; in t4_l2e_free()
327 e->arpq_tail = NULL; in t4_l2e_free()
329 spin_unlock_bh(&e->lock); in t4_l2e_free()
331 d = container_of(e, struct l2t_data, l2tab[e->idx]); in t4_l2e_free()
335 void cxgb4_l2t_release(struct l2t_entry *e) in cxgb4_l2t_release() argument
337 if (atomic_dec_and_test(&e->refcnt)) in cxgb4_l2t_release()
338 t4_l2e_free(e); in cxgb4_l2t_release()
346 static void reuse_entry(struct l2t_entry *e, struct neighbour *neigh) in reuse_entry() argument
350 spin_lock(&e->lock); /* avoid race with t4_l2t_free */ in reuse_entry()
351 if (neigh != e->neigh) in reuse_entry()
352 neigh_replace(e, neigh); in reuse_entry()
354 if (memcmp(e->dmac, neigh->ha, sizeof(e->dmac)) || in reuse_entry()
356 e->state = L2T_STATE_RESOLVING; in reuse_entry()
358 e->state = L2T_STATE_VALID; in reuse_entry()
360 e->state = L2T_STATE_STALE; in reuse_entry()
361 spin_unlock(&e->lock); in reuse_entry()
370 struct l2t_entry *e; in cxgb4_l2t_get() local
387 for (e = d->l2tab[hash].first; e; e = e->next) in cxgb4_l2t_get()
388 if (!addreq(e, addr) && e->ifindex == ifidx && in cxgb4_l2t_get()
389 e->vlan == vlan && e->lport == lport) { in cxgb4_l2t_get()
390 l2t_hold(d, e); in cxgb4_l2t_get()
391 if (atomic_read(&e->refcnt) == 1) in cxgb4_l2t_get()
392 reuse_entry(e, neigh); in cxgb4_l2t_get()
397 e = alloc_l2e(d); in cxgb4_l2t_get()
398 if (e) { in cxgb4_l2t_get()
399 spin_lock(&e->lock); /* avoid race with t4_l2t_free */ in cxgb4_l2t_get()
400 e->state = L2T_STATE_RESOLVING; in cxgb4_l2t_get()
402 memcpy(e->dmac, physdev->dev_addr, sizeof(e->dmac)); in cxgb4_l2t_get()
403 memcpy(e->addr, addr, addr_len); in cxgb4_l2t_get()
404 e->ifindex = ifidx; in cxgb4_l2t_get()
405 e->hash = hash; in cxgb4_l2t_get()
406 e->lport = lport; in cxgb4_l2t_get()
407 e->v6 = addr_len == 16; in cxgb4_l2t_get()
408 atomic_set(&e->refcnt, 1); in cxgb4_l2t_get()
409 neigh_replace(e, neigh); in cxgb4_l2t_get()
410 e->vlan = vlan; in cxgb4_l2t_get()
411 e->next = d->l2tab[hash].first; in cxgb4_l2t_get()
412 d->l2tab[hash].first = e; in cxgb4_l2t_get()
413 spin_unlock(&e->lock); in cxgb4_l2t_get()
417 return e; in cxgb4_l2t_get()
481 struct l2t_entry *e; in t4_l2t_update() local
490 for (e = d->l2tab[hash].first; e; e = e->next) in t4_l2t_update()
491 if (!addreq(e, addr) && e->ifindex == ifidx) { in t4_l2t_update()
492 spin_lock(&e->lock); in t4_l2t_update()
493 if (atomic_read(&e->refcnt)) in t4_l2t_update()
495 spin_unlock(&e->lock); in t4_l2t_update()
504 if (neigh != e->neigh) in t4_l2t_update()
505 neigh_replace(e, neigh); in t4_l2t_update()
507 if (e->state == L2T_STATE_RESOLVING) { in t4_l2t_update()
509 arpq = e->arpq_head; in t4_l2t_update()
510 e->arpq_head = e->arpq_tail = NULL; in t4_l2t_update()
512 e->arpq_head) { in t4_l2t_update()
513 write_l2e(adap, e, 1); in t4_l2t_update()
516 e->state = neigh->nud_state & NUD_CONNECTED ? in t4_l2t_update()
518 if (memcmp(e->dmac, neigh->ha, sizeof(e->dmac))) in t4_l2t_update()
519 write_l2e(adap, e, 0); in t4_l2t_update()
522 spin_unlock_bh(&e->lock); in t4_l2t_update()
534 struct l2t_entry *e; in t4_l2t_alloc_switching() local
537 e = alloc_l2e(d); in t4_l2t_alloc_switching()
538 if (e) { in t4_l2t_alloc_switching()
539 spin_lock(&e->lock); /* avoid race with t4_l2t_free */ in t4_l2t_alloc_switching()
540 e->state = L2T_STATE_SWITCHING; in t4_l2t_alloc_switching()
541 atomic_set(&e->refcnt, 1); in t4_l2t_alloc_switching()
542 spin_unlock(&e->lock); in t4_l2t_alloc_switching()
545 return e; in t4_l2t_alloc_switching()
551 int t4_l2t_set_switching(struct adapter *adap, struct l2t_entry *e, u16 vlan, in t4_l2t_set_switching() argument
554 e->vlan = vlan; in t4_l2t_set_switching()
555 e->lport = port; in t4_l2t_set_switching()
556 memcpy(e->dmac, eth_addr, ETH_ALEN); in t4_l2t_set_switching()
557 return write_l2e(adap, e, 0); in t4_l2t_set_switching()
616 static char l2e_state(const struct l2t_entry *e) in l2e_state() argument
618 switch (e->state) { in l2e_state()
622 case L2T_STATE_RESOLVING: return e->arpq_head ? 'A' : 'R'; in l2e_state()
637 struct l2t_entry *e = v; in l2t_seq_show() local
639 spin_lock_bh(&e->lock); in l2t_seq_show()
640 if (e->state == L2T_STATE_SWITCHING) in l2t_seq_show()
643 sprintf(ip, e->v6 ? "%pI6c" : "%pI4", e->addr); in l2t_seq_show()
645 e->idx + d->l2t_start, ip, e->dmac, in l2t_seq_show()
646 e->vlan & VLAN_VID_MASK, vlan_prio(e), e->lport, in l2t_seq_show()
647 l2e_state(e), atomic_read(&e->refcnt), in l2t_seq_show()
648 e->neigh ? e->neigh->dev->name : ""); in l2t_seq_show()
649 spin_unlock_bh(&e->lock); in l2t_seq_show()