Lines Matching refs:e
73 struct l2t_entry *end, *e, **p; in t4_alloc_l2e() local
82 for (e = d->rover, end = &d->l2tab[d->l2t_size]; e != end; ++e) in t4_alloc_l2e()
83 if (atomic_load_acq_int(&e->refcnt) == 0) in t4_alloc_l2e()
86 for (e = d->l2tab; atomic_load_acq_int(&e->refcnt); ++e) in t4_alloc_l2e()
89 d->rover = e + 1; in t4_alloc_l2e()
96 if (e->state < L2T_STATE_SWITCHING) { in t4_alloc_l2e()
97 for (p = &d->l2tab[e->hash].first; *p; p = &(*p)->next) { in t4_alloc_l2e()
98 if (*p == e) { in t4_alloc_l2e()
99 *p = e->next; in t4_alloc_l2e()
100 e->next = NULL; in t4_alloc_l2e()
106 e->state = L2T_STATE_UNUSED; in t4_alloc_l2e()
107 return (e); in t4_alloc_l2e()
113 struct l2t_entry *end, *e, **p; in find_or_alloc_l2e() local
116 for (e = &d->l2tab[0], end = &d->l2tab[d->l2t_size]; e != end; ++e) { in find_or_alloc_l2e()
117 if (atomic_load_acq_int(&e->refcnt) == 0) { in find_or_alloc_l2e()
119 first_free = e; in find_or_alloc_l2e()
120 } else if (e->state == L2T_STATE_SWITCHING && in find_or_alloc_l2e()
121 memcmp(e->dmac, dmac, ETHER_ADDR_LEN) == 0 && in find_or_alloc_l2e()
122 e->vlan == vlan && e->lport == port) in find_or_alloc_l2e()
123 return (e); /* Found existing entry that matches. */ in find_or_alloc_l2e()
133 e = first_free; in find_or_alloc_l2e()
134 if (e->state < L2T_STATE_SWITCHING) { in find_or_alloc_l2e()
135 for (p = &d->l2tab[e->hash].first; *p; p = &(*p)->next) { in find_or_alloc_l2e()
136 if (*p == e) { in find_or_alloc_l2e()
137 *p = e->next; in find_or_alloc_l2e()
138 e->next = NULL; in find_or_alloc_l2e()
143 e->state = L2T_STATE_UNUSED; in find_or_alloc_l2e()
144 return (e); in find_or_alloc_l2e()
148 mk_write_l2e(struct adapter *sc, struct l2t_entry *e, int sync, int reply, in mk_write_l2e() argument
155 idx = e->idx + sc->vres.l2t.start; in mk_write_l2e()
158 V_SYNC_WR(sync) | V_TID_QID(e->iqid))); in mk_write_l2e()
159 req->params = htons(V_L2T_W_PORT(e->lport) | V_L2T_W_NOREPLY(!reply)); in mk_write_l2e()
161 req->vlan = htons(e->vlan); in mk_write_l2e()
162 memcpy(req->dst_mac, e->dmac, sizeof(req->dst_mac)); in mk_write_l2e()
170 t4_write_l2e(struct l2t_entry *e, int sync) in t4_write_l2e() argument
177 mtx_assert(&e->lock, MA_OWNED); in t4_write_l2e()
178 MPASS(e->wrq != NULL); in t4_write_l2e()
180 wrq = e->wrq; in t4_write_l2e()
187 mk_write_l2e(sc, e, sync, sync, req); in t4_write_l2e()
191 if (sync && e->state != L2T_STATE_SWITCHING) in t4_write_l2e()
192 e->state = L2T_STATE_SYNC_WRITE; in t4_write_l2e()
215 struct l2t_entry *e; in t4_l2t_alloc_tls() local
227 e = &d->l2tab[i]; in t4_l2t_alloc_tls()
228 if (e->state != L2T_STATE_TLS) in t4_l2t_alloc_tls()
230 if (e->vlan == vlan && e->lport == port && in t4_l2t_alloc_tls()
231 e->wrq == (struct sge_wrq *)txq && in t4_l2t_alloc_tls()
232 memcmp(e->dmac, eth_addr, ETHER_ADDR_LEN) == 0) { in t4_l2t_alloc_tls()
233 if (atomic_fetchadd_int(&e->refcnt, 1) == 0) { in t4_l2t_alloc_tls()
240 KASSERT(e->refcnt > 0, in t4_l2t_alloc_tls()
243 return (e); in t4_l2t_alloc_tls()
257 e = t4_alloc_l2e(d); in t4_l2t_alloc_tls()
258 if (e == NULL) { in t4_l2t_alloc_tls()
260 return (e); in t4_l2t_alloc_tls()
264 e->state = L2T_STATE_TLS; in t4_l2t_alloc_tls()
265 e->vlan = vlan; in t4_l2t_alloc_tls()
266 e->lport = port; in t4_l2t_alloc_tls()
267 e->iqid = sc->sge.fwq.abs_id; in t4_l2t_alloc_tls()
268 e->wrq = (struct sge_wrq *)txq; in t4_l2t_alloc_tls()
269 memcpy(e->dmac, eth_addr, ETHER_ADDR_LEN); in t4_l2t_alloc_tls()
270 atomic_store_rel_int(&e->refcnt, 1); in t4_l2t_alloc_tls()
276 mk_write_l2e(sc, e, 1, 0, dst); in t4_l2t_alloc_tls()
278 return (e); in t4_l2t_alloc_tls()
291 struct l2t_entry *e; in t4_l2t_alloc_switching() local
296 e = NULL; in t4_l2t_alloc_switching()
298 e = find_or_alloc_l2e(d, vlan, port, eth_addr); in t4_l2t_alloc_switching()
299 if (e) { in t4_l2t_alloc_switching()
300 if (atomic_load_acq_int(&e->refcnt) == 0) { in t4_l2t_alloc_switching()
301 mtx_lock(&e->lock); /* avoid race with t4_l2t_free */ in t4_l2t_alloc_switching()
302 e->wrq = &sc->sge.ctrlq[0]; in t4_l2t_alloc_switching()
303 e->iqid = sc->sge.fwq.abs_id; in t4_l2t_alloc_switching()
304 e->state = L2T_STATE_SWITCHING; in t4_l2t_alloc_switching()
305 e->vlan = vlan; in t4_l2t_alloc_switching()
306 e->lport = port; in t4_l2t_alloc_switching()
307 memcpy(e->dmac, eth_addr, ETHER_ADDR_LEN); in t4_l2t_alloc_switching()
308 atomic_store_rel_int(&e->refcnt, 1); in t4_l2t_alloc_switching()
310 rc = t4_write_l2e(e, 0); in t4_l2t_alloc_switching()
311 mtx_unlock(&e->lock); in t4_l2t_alloc_switching()
313 e = NULL; in t4_l2t_alloc_switching()
315 MPASS(e->vlan == vlan); in t4_l2t_alloc_switching()
316 MPASS(e->lport == port); in t4_l2t_alloc_switching()
317 atomic_add_int(&e->refcnt, 1); in t4_l2t_alloc_switching()
321 return (e); in t4_l2t_alloc_switching()
346 struct l2t_entry *e = &d->l2tab[i]; in t4_init_l2t() local
348 e->idx = i; in t4_init_l2t()
349 e->state = L2T_STATE_UNUSED; in t4_init_l2t()
350 mtx_init(&e->lock, "L2T_E", NULL, MTX_DEF); in t4_init_l2t()
351 STAILQ_INIT(&e->wr_list); in t4_init_l2t()
352 atomic_store_rel_int(&e->refcnt, 0); in t4_init_l2t()
426 vlan_prio(const struct l2t_entry *e) in vlan_prio() argument
428 return e->vlan >> 13; in vlan_prio()
432 l2e_state(const struct l2t_entry *e) in l2e_state() argument
434 switch (e->state) { in l2e_state()
438 case L2T_STATE_RESOLVING: return STAILQ_EMPTY(&e->wr_list) ? 'R' : 'A'; in l2e_state()
450 struct l2t_entry *e; in sysctl_l2t() local
466 e = &l2t->l2tab[0]; in sysctl_l2t()
467 for (i = 0; i < l2t->l2t_size; i++, e++) { in sysctl_l2t()
468 mtx_lock(&e->lock); in sysctl_l2t()
469 if (e->state == L2T_STATE_UNUSED) in sysctl_l2t()
477 if (e->state >= L2T_STATE_SWITCHING) in sysctl_l2t()
480 inet_ntop(e->ipv6 ? AF_INET6 : AF_INET, &e->addr[0], in sysctl_l2t()
489 e->idx, ip, e->dmac[0], e->dmac[1], e->dmac[2], in sysctl_l2t()
490 e->dmac[3], e->dmac[4], e->dmac[5], in sysctl_l2t()
491 e->vlan & 0xfff, vlan_prio(e), e->lport, in sysctl_l2t()
492 l2e_state(e), atomic_load_acq_int(&e->refcnt), in sysctl_l2t()
493 e->ifp ? if_name(e->ifp) : "-"); in sysctl_l2t()
495 mtx_unlock(&e->lock); in sysctl_l2t()