• Home
  • Raw
  • Download

Lines Matching refs:e

65 static inline unsigned int vlan_prio(const struct l2t_entry *e)  in vlan_prio()  argument
67 return e->vlan >> VLAN_PRIO_SHIFT; in vlan_prio()
70 static inline void l2t_hold(struct l2t_data *d, struct l2t_entry *e) in l2t_hold() argument
72 if (atomic_add_return(1, &e->refcnt) == 1) /* 0 -> 1 transition */ in l2t_hold()
118 static int addreq(const struct l2t_entry *e, const u32 *addr) in addreq() argument
120 if (e->v6) in addreq()
121 return (e->addr[0] ^ addr[0]) | (e->addr[1] ^ addr[1]) | in addreq()
122 (e->addr[2] ^ addr[2]) | (e->addr[3] ^ addr[3]); in addreq()
123 return e->addr[0] ^ addr[0]; in addreq()
126 static void neigh_replace(struct l2t_entry *e, struct neighbour *n) in neigh_replace() argument
129 if (e->neigh) in neigh_replace()
130 neigh_release(e->neigh); in neigh_replace()
131 e->neigh = n; in neigh_replace()
138 static int write_l2e(struct adapter *adap, struct l2t_entry *e, int sync) in write_l2e() argument
141 unsigned int l2t_idx = e->idx + d->l2t_start; in write_l2e()
155 req->params = htons(L2T_W_PORT_V(e->lport) | L2T_W_NOREPLY_V(!sync)); in write_l2e()
157 req->vlan = htons(e->vlan); in write_l2e()
158 if (e->neigh && !(e->neigh->dev->flags & IFF_LOOPBACK)) in write_l2e()
159 memcpy(e->dmac, e->neigh->ha, sizeof(e->dmac)); in write_l2e()
160 memcpy(req->dst_mac, e->dmac, sizeof(req->dst_mac)); in write_l2e()
164 if (sync && e->state != L2T_STATE_SWITCHING) in write_l2e()
165 e->state = L2T_STATE_SYNC_WRITE; in write_l2e()
173 static void send_pending(struct adapter *adap, struct l2t_entry *e) in send_pending() argument
177 while ((skb = __skb_dequeue(&e->arpq)) != NULL) in send_pending()
200 struct l2t_entry *e = &d->l2tab[l2t_idx - d->l2t_start]; in do_l2t_write_rpl() local
202 spin_lock(&e->lock); in do_l2t_write_rpl()
203 if (e->state != L2T_STATE_SWITCHING) { in do_l2t_write_rpl()
204 send_pending(adap, e); in do_l2t_write_rpl()
205 e->state = (e->neigh->nud_state & NUD_STALE) ? in do_l2t_write_rpl()
208 spin_unlock(&e->lock); in do_l2t_write_rpl()
216 static inline void arpq_enqueue(struct l2t_entry *e, struct sk_buff *skb) in arpq_enqueue() argument
218 __skb_queue_tail(&e->arpq, skb); in arpq_enqueue()
222 struct l2t_entry *e) in cxgb4_l2t_send() argument
227 switch (e->state) { in cxgb4_l2t_send()
229 neigh_event_send(e->neigh, NULL); in cxgb4_l2t_send()
230 spin_lock_bh(&e->lock); in cxgb4_l2t_send()
231 if (e->state == L2T_STATE_STALE) in cxgb4_l2t_send()
232 e->state = L2T_STATE_VALID; in cxgb4_l2t_send()
233 spin_unlock_bh(&e->lock); in cxgb4_l2t_send()
238 spin_lock_bh(&e->lock); in cxgb4_l2t_send()
239 if (e->state != L2T_STATE_SYNC_WRITE && in cxgb4_l2t_send()
240 e->state != L2T_STATE_RESOLVING) { in cxgb4_l2t_send()
241 spin_unlock_bh(&e->lock); in cxgb4_l2t_send()
244 arpq_enqueue(e, skb); in cxgb4_l2t_send()
245 spin_unlock_bh(&e->lock); in cxgb4_l2t_send()
247 if (e->state == L2T_STATE_RESOLVING && in cxgb4_l2t_send()
248 !neigh_event_send(e->neigh, NULL)) { in cxgb4_l2t_send()
249 spin_lock_bh(&e->lock); in cxgb4_l2t_send()
250 if (e->state == L2T_STATE_RESOLVING && in cxgb4_l2t_send()
251 !skb_queue_empty(&e->arpq)) in cxgb4_l2t_send()
252 write_l2e(adap, e, 1); in cxgb4_l2t_send()
253 spin_unlock_bh(&e->lock); in cxgb4_l2t_send()
265 struct l2t_entry *end, *e, **p; in alloc_l2e() local
271 for (e = d->rover, end = &d->l2tab[d->l2t_size]; e != end; ++e) in alloc_l2e()
272 if (atomic_read(&e->refcnt) == 0) in alloc_l2e()
275 for (e = d->l2tab; atomic_read(&e->refcnt); ++e) in alloc_l2e()
278 d->rover = e + 1; in alloc_l2e()
285 if (e->state < L2T_STATE_SWITCHING) in alloc_l2e()
286 for (p = &d->l2tab[e->hash].first; *p; p = &(*p)->next) in alloc_l2e()
287 if (*p == e) { in alloc_l2e()
288 *p = e->next; in alloc_l2e()
289 e->next = NULL; in alloc_l2e()
293 e->state = L2T_STATE_UNUSED; in alloc_l2e()
294 return e; in alloc_l2e()
300 struct l2t_entry *end, *e, **p; in find_or_alloc_l2e() local
303 for (e = &d->l2tab[0], end = &d->l2tab[d->l2t_size]; e != end; ++e) { in find_or_alloc_l2e()
304 if (atomic_read(&e->refcnt) == 0) { in find_or_alloc_l2e()
306 first_free = e; in find_or_alloc_l2e()
308 if (e->state == L2T_STATE_SWITCHING) { in find_or_alloc_l2e()
309 if (ether_addr_equal(e->dmac, dmac) && in find_or_alloc_l2e()
310 (e->vlan == vlan) && (e->lport == port)) in find_or_alloc_l2e()
317 e = first_free; in find_or_alloc_l2e()
327 if (e->state < L2T_STATE_SWITCHING) in find_or_alloc_l2e()
328 for (p = &d->l2tab[e->hash].first; *p; p = &(*p)->next) in find_or_alloc_l2e()
329 if (*p == e) { in find_or_alloc_l2e()
330 *p = e->next; in find_or_alloc_l2e()
331 e->next = NULL; in find_or_alloc_l2e()
334 e->state = L2T_STATE_UNUSED; in find_or_alloc_l2e()
337 return e; in find_or_alloc_l2e()
350 static void _t4_l2e_free(struct l2t_entry *e) in _t4_l2e_free() argument
355 if (atomic_read(&e->refcnt) == 0) { /* hasn't been recycled */ in _t4_l2e_free()
356 if (e->neigh) { in _t4_l2e_free()
357 neigh_release(e->neigh); in _t4_l2e_free()
358 e->neigh = NULL; in _t4_l2e_free()
360 while ((skb = __skb_dequeue(&e->arpq)) != NULL) in _t4_l2e_free()
364 d = container_of(e, struct l2t_data, l2tab[e->idx]); in _t4_l2e_free()
369 static void t4_l2e_free(struct l2t_entry *e) in t4_l2e_free() argument
374 spin_lock_bh(&e->lock); in t4_l2e_free()
375 if (atomic_read(&e->refcnt) == 0) { /* hasn't been recycled */ in t4_l2e_free()
376 if (e->neigh) { in t4_l2e_free()
377 neigh_release(e->neigh); in t4_l2e_free()
378 e->neigh = NULL; in t4_l2e_free()
380 while ((skb = __skb_dequeue(&e->arpq)) != NULL) in t4_l2e_free()
383 spin_unlock_bh(&e->lock); in t4_l2e_free()
385 d = container_of(e, struct l2t_data, l2tab[e->idx]); in t4_l2e_free()
389 void cxgb4_l2t_release(struct l2t_entry *e) in cxgb4_l2t_release() argument
391 if (atomic_dec_and_test(&e->refcnt)) in cxgb4_l2t_release()
392 t4_l2e_free(e); in cxgb4_l2t_release()
400 static void reuse_entry(struct l2t_entry *e, struct neighbour *neigh) in reuse_entry() argument
404 spin_lock(&e->lock); /* avoid race with t4_l2t_free */ in reuse_entry()
405 if (neigh != e->neigh) in reuse_entry()
406 neigh_replace(e, neigh); in reuse_entry()
408 if (memcmp(e->dmac, neigh->ha, sizeof(e->dmac)) || in reuse_entry()
410 e->state = L2T_STATE_RESOLVING; in reuse_entry()
412 e->state = L2T_STATE_VALID; in reuse_entry()
414 e->state = L2T_STATE_STALE; in reuse_entry()
415 spin_unlock(&e->lock); in reuse_entry()
424 struct l2t_entry *e; in cxgb4_l2t_get() local
441 for (e = d->l2tab[hash].first; e; e = e->next) in cxgb4_l2t_get()
442 if (!addreq(e, addr) && e->ifindex == ifidx && in cxgb4_l2t_get()
443 e->vlan == vlan && e->lport == lport) { in cxgb4_l2t_get()
444 l2t_hold(d, e); in cxgb4_l2t_get()
445 if (atomic_read(&e->refcnt) == 1) in cxgb4_l2t_get()
446 reuse_entry(e, neigh); in cxgb4_l2t_get()
451 e = alloc_l2e(d); in cxgb4_l2t_get()
452 if (e) { in cxgb4_l2t_get()
453 spin_lock(&e->lock); /* avoid race with t4_l2t_free */ in cxgb4_l2t_get()
454 e->state = L2T_STATE_RESOLVING; in cxgb4_l2t_get()
456 memcpy(e->dmac, physdev->dev_addr, sizeof(e->dmac)); in cxgb4_l2t_get()
457 memcpy(e->addr, addr, addr_len); in cxgb4_l2t_get()
458 e->ifindex = ifidx; in cxgb4_l2t_get()
459 e->hash = hash; in cxgb4_l2t_get()
460 e->lport = lport; in cxgb4_l2t_get()
461 e->v6 = addr_len == 16; in cxgb4_l2t_get()
462 atomic_set(&e->refcnt, 1); in cxgb4_l2t_get()
463 neigh_replace(e, neigh); in cxgb4_l2t_get()
464 e->vlan = vlan; in cxgb4_l2t_get()
465 e->next = d->l2tab[hash].first; in cxgb4_l2t_get()
466 d->l2tab[hash].first = e; in cxgb4_l2t_get()
467 spin_unlock(&e->lock); in cxgb4_l2t_get()
471 return e; in cxgb4_l2t_get()
514 static void handle_failed_resolution(struct adapter *adap, struct l2t_entry *e) in handle_failed_resolution() argument
518 while ((skb = __skb_dequeue(&e->arpq)) != NULL) { in handle_failed_resolution()
521 spin_unlock(&e->lock); in handle_failed_resolution()
526 spin_lock(&e->lock); in handle_failed_resolution()
536 struct l2t_entry *e; in t4_l2t_update() local
545 for (e = d->l2tab[hash].first; e; e = e->next) in t4_l2t_update()
546 if (!addreq(e, addr) && e->ifindex == ifidx) { in t4_l2t_update()
547 spin_lock(&e->lock); in t4_l2t_update()
548 if (atomic_read(&e->refcnt)) in t4_l2t_update()
550 spin_unlock(&e->lock); in t4_l2t_update()
559 if (neigh != e->neigh) in t4_l2t_update()
560 neigh_replace(e, neigh); in t4_l2t_update()
562 if (e->state == L2T_STATE_RESOLVING) { in t4_l2t_update()
564 arpq = &e->arpq; in t4_l2t_update()
566 !skb_queue_empty(&e->arpq)) { in t4_l2t_update()
567 write_l2e(adap, e, 1); in t4_l2t_update()
570 e->state = neigh->nud_state & NUD_CONNECTED ? in t4_l2t_update()
572 if (memcmp(e->dmac, neigh->ha, sizeof(e->dmac))) in t4_l2t_update()
573 write_l2e(adap, e, 0); in t4_l2t_update()
577 handle_failed_resolution(adap, e); in t4_l2t_update()
578 spin_unlock_bh(&e->lock); in t4_l2t_update()
589 struct l2t_entry *e; in t4_l2t_alloc_switching() local
593 e = find_or_alloc_l2e(d, vlan, port, eth_addr); in t4_l2t_alloc_switching()
594 if (e) { in t4_l2t_alloc_switching()
595 spin_lock(&e->lock); /* avoid race with t4_l2t_free */ in t4_l2t_alloc_switching()
596 if (!atomic_read(&e->refcnt)) { in t4_l2t_alloc_switching()
597 e->state = L2T_STATE_SWITCHING; in t4_l2t_alloc_switching()
598 e->vlan = vlan; in t4_l2t_alloc_switching()
599 e->lport = port; in t4_l2t_alloc_switching()
600 ether_addr_copy(e->dmac, eth_addr); in t4_l2t_alloc_switching()
601 atomic_set(&e->refcnt, 1); in t4_l2t_alloc_switching()
602 ret = write_l2e(adap, e, 0); in t4_l2t_alloc_switching()
604 _t4_l2e_free(e); in t4_l2t_alloc_switching()
605 spin_unlock(&e->lock); in t4_l2t_alloc_switching()
610 atomic_inc(&e->refcnt); in t4_l2t_alloc_switching()
613 spin_unlock(&e->lock); in t4_l2t_alloc_switching()
616 return e; in t4_l2t_alloc_switching()
693 static char l2e_state(const struct l2t_entry *e) in l2e_state() argument
695 switch (e->state) { in l2e_state()
700 return skb_queue_empty(&e->arpq) ? 'R' : 'A'; in l2e_state()
715 struct l2t_entry *e = v; in l2t_seq_show() local
717 spin_lock_bh(&e->lock); in l2t_seq_show()
718 if (e->state == L2T_STATE_SWITCHING) in l2t_seq_show()
721 sprintf(ip, e->v6 ? "%pI6c" : "%pI4", e->addr); in l2t_seq_show()
723 e->idx + d->l2t_start, ip, e->dmac, in l2t_seq_show()
724 e->vlan & VLAN_VID_MASK, vlan_prio(e), e->lport, in l2t_seq_show()
725 l2e_state(e), atomic_read(&e->refcnt), in l2t_seq_show()
726 e->neigh ? e->neigh->dev->name : ""); in l2t_seq_show()
727 spin_unlock_bh(&e->lock); in l2t_seq_show()