Lines Matching +full:row +full:- +full:hold

1 /*-
2 * SPDX-License-Identifier: BSD-2-Clause
63 * the TOE and the sockets already hold references to the interfaces and the
76 rw_assert(&s->lock, RA_WLOCKED); in t4_find_or_alloc_sme()
77 for (e = &s->smtab[0], end = &s->smtab[s->smt_size]; e != end; ++e) { in t4_find_or_alloc_sme()
78 if (atomic_load_acq_int(&e->refcnt) == 0) { in t4_find_or_alloc_sme()
82 if (e->state == SMT_STATE_SWITCHING) { in t4_find_or_alloc_sme()
85 * re-use it? in t4_find_or_alloc_sme()
87 if (memcmp(e->smac, smac, ETHER_ADDR_LEN) == 0) in t4_find_or_alloc_sme()
99 e->state = SMT_STATE_UNUSED; in t4_find_or_alloc_sme()
101 atomic_add_int(&e->refcnt, 1); in t4_find_or_alloc_sme()
117 u8 row; in t4_write_sme() local
119 mtx_assert(&e->lock, MA_OWNED); in t4_write_sme()
121 MPASS(e->wrq != NULL); in t4_write_sme()
122 wrq = e->wrq; in t4_write_sme()
123 sc = wrq->adapter; in t4_write_sme()
124 MPASS(wrq->adapter != NULL); in t4_write_sme()
125 s = sc->smt; in t4_write_sme()
136 /* Each row contains an SMAC pair. in t4_write_sme()
137 * LSB selects the SMAC entry within a row in t4_write_sme()
139 row = (e->idx >> 1); in t4_write_sme()
140 if (e->idx & 1) { in t4_write_sme()
141 req->pfvf1 = 0x0; in t4_write_sme()
142 memcpy(req->src_mac1, e->smac, ETHER_ADDR_LEN); in t4_write_sme()
144 * at prev index from smt-tab. in t4_write_sme()
146 req->pfvf0 = 0x0; in t4_write_sme()
147 memcpy(req->src_mac0, s->smtab[e->idx - 1].smac, in t4_write_sme()
150 req->pfvf0 = 0x0; in t4_write_sme()
151 memcpy(req->src_mac0, e->smac, ETHER_ADDR_LEN); in t4_write_sme()
153 * at next index from smt-tab in t4_write_sme()
155 req->pfvf1 = 0x0; in t4_write_sme()
156 memcpy(req->src_mac1, s->smtab[e->idx + 1].smac, in t4_write_sme()
167 /* fill pfvf0/src_mac0 from smt-tab */ in t4_write_sme()
168 req->pfvf0 = 0x0; in t4_write_sme()
169 memcpy(req->src_mac0, s->smtab[e->idx].smac, ETHER_ADDR_LEN); in t4_write_sme()
170 row = e->idx; in t4_write_sme()
172 OPCODE_TID(req) = htonl(MK_OPCODE_TID(CPL_SMT_WRITE_REQ, e->idx | in t4_write_sme()
173 V_TID_QID(e->iqid))); in t4_write_sme()
174 req->params = htonl(V_SMTW_NORPL(0) | in t4_write_sme()
175 V_SMTW_IDX(row) | in t4_write_sme()
192 rw_wlock(&s->lock); in t4_smt_alloc_switching()
194 rw_wunlock(&s->lock); in t4_smt_alloc_switching()
208 if (atomic_load_acq_int(&e->refcnt) == 1) { in t4_smt_set_switching()
210 mtx_lock(&e->lock); in t4_smt_set_switching()
211 e->wrq = &sc->sge.ctrlq[0]; in t4_smt_set_switching()
212 e->iqid = sc->sge.fwq.abs_id; in t4_smt_set_switching()
213 e->pfvf = pfvf; in t4_smt_set_switching()
214 e->state = SMT_STATE_SWITCHING; in t4_smt_set_switching()
215 memcpy(e->smac, smac, ETHER_ADDR_LEN); in t4_smt_set_switching()
217 mtx_unlock(&e->lock); in t4_smt_set_switching()
235 s->smt_size = smt_size; in t4_init_smt()
236 rw_init(&s->lock, "SMT"); in t4_init_smt()
239 struct smt_entry *e = &s->smtab[i]; in t4_init_smt()
241 e->idx = i; in t4_init_smt()
242 e->state = SMT_STATE_UNUSED; in t4_init_smt()
243 mtx_init(&e->lock, "SMT_E", NULL, MTX_DEF); in t4_init_smt()
244 atomic_store_rel_int(&e->refcnt, 0); in t4_init_smt()
247 sc->smt = s; in t4_init_smt()
257 for (i = 0; i < s->smt_size; i++) in t4_free_smt()
258 mtx_destroy(&s->smtab[i].lock); in t4_free_smt()
259 rw_destroy(&s->lock); in t4_free_smt()
269 struct adapter *sc = iq->adapter; in do_smt_write_rpl()
274 if (__predict_false(rpl->status != CPL_ERR_NONE)) { in do_smt_write_rpl()
275 struct smt_entry *e = &sc->smt->smtab[smtidx]; in do_smt_write_rpl()
278 rpl->status, smtidx); in do_smt_write_rpl()
279 mtx_lock(&e->lock); in do_smt_write_rpl()
280 e->state = SMT_STATE_ERROR; in do_smt_write_rpl()
281 mtx_unlock(&e->lock); in do_smt_write_rpl()
291 switch (e->state) { in smt_state()
302 struct smt_data *smt = sc->smt; in sysctl_smt()
318 e = &smt->smtab[0]; in sysctl_smt()
319 for (i = 0; i < smt->smt_size; i++, e++) { in sysctl_smt()
320 mtx_lock(&e->lock); in sysctl_smt()
321 if (e->state == SMT_STATE_UNUSED) in sysctl_smt()
331 e->idx, e->smac[0], e->smac[1], e->smac[2], in sysctl_smt()
332 e->smac[3], e->smac[4], e->smac[5], in sysctl_smt()
333 smt_state(e), atomic_load_acq_int(&e->refcnt)); in sysctl_smt()
335 mtx_unlock(&e->lock); in sysctl_smt()