Changeset View
Changeset View
Standalone View
Standalone View
sys/dev/bnxt/bnxt_txrx.c
Show First 20 Lines • Show All 258 Lines • ▼ Show 20 Lines | bnxt_isc_rxd_refill(void *sc, if_rxd_update_t iru) | ||||
uint16_t type; | uint16_t type; | ||||
uint16_t i; | uint16_t i; | ||||
uint16_t rxqid; | uint16_t rxqid; | ||||
uint16_t count, len; | uint16_t count, len; | ||||
uint32_t pidx; | uint32_t pidx; | ||||
uint8_t flid; | uint8_t flid; | ||||
uint64_t *paddrs; | uint64_t *paddrs; | ||||
caddr_t *vaddrs; | caddr_t *vaddrs; | ||||
qidx_t *frag_idxs; | |||||
rxqid = iru->iru_qsidx; | rxqid = iru->iru_qsidx; | ||||
count = iru->iru_count; | count = iru->iru_count; | ||||
len = iru->iru_buf_size; | len = iru->iru_buf_size; | ||||
pidx = iru->iru_pidx; | pidx = iru->iru_pidx; | ||||
flid = iru->iru_flidx; | flid = iru->iru_flidx; | ||||
vaddrs = iru->iru_vaddrs; | vaddrs = iru->iru_vaddrs; | ||||
paddrs = iru->iru_paddrs; | paddrs = iru->iru_paddrs; | ||||
frag_idxs = iru->iru_idxs; | |||||
erj: What's this new field for? Are other drivers supposed to use it for things? | |||||
Not Done Inline ActionsDriver really need this only when it can receive out-of-order completions, otherwise not needed. bhargava.marreddy_broadcom.com: Driver really need this only when it can receive out-of-order completions, otherwise not needed. | |||||
if (flid == 0) { | if (flid == 0) { | ||||
rx_ring = &softc->rx_rings[rxqid]; | rx_ring = &softc->rx_rings[rxqid]; | ||||
type = RX_PROD_PKT_BD_TYPE_RX_PROD_PKT; | type = RX_PROD_PKT_BD_TYPE_RX_PROD_PKT; | ||||
} | } | ||||
else { | else { | ||||
rx_ring = &softc->ag_rings[rxqid]; | rx_ring = &softc->ag_rings[rxqid]; | ||||
type = RX_PROD_AGG_BD_TYPE_RX_PROD_AGG; | type = RX_PROD_AGG_BD_TYPE_RX_PROD_AGG; | ||||
} | } | ||||
rxbd = (void *)rx_ring->vaddr; | rxbd = (void *)rx_ring->vaddr; | ||||
for (i=0; i<count; i++) { | for (i=0; i<count; i++) { | ||||
rxbd[pidx].flags_type = htole16(type); | rxbd[pidx].flags_type = htole16(type); | ||||
rxbd[pidx].len = htole16(len); | rxbd[pidx].len = htole16(len); | ||||
/* No need to byte-swap the opaque value */ | /* No need to byte-swap the opaque value */ | ||||
rxbd[pidx].opaque = ((rxqid & 0xff) << 24) | (flid << 16) | rxbd[pidx].opaque = (((rxqid & 0xff) << 24) | (flid << 16) | ||||
| pidx; | | (frag_idxs[i])); | ||||
rxbd[pidx].addr = htole64(paddrs[i]); | rxbd[pidx].addr = htole64(paddrs[i]); | ||||
if (++pidx == rx_ring->ring_size) | if (++pidx == rx_ring->ring_size) | ||||
pidx = 0; | pidx = 0; | ||||
} | } | ||||
return; | return; | ||||
} | } | ||||
static void | static void | ||||
Show All 24 Lines | |||||
} | } | ||||
static int | static int | ||||
bnxt_isc_rxd_available(void *sc, uint16_t rxqid, qidx_t idx, qidx_t budget) | bnxt_isc_rxd_available(void *sc, uint16_t rxqid, qidx_t idx, qidx_t budget) | ||||
{ | { | ||||
struct bnxt_softc *softc = (struct bnxt_softc *)sc; | struct bnxt_softc *softc = (struct bnxt_softc *)sc; | ||||
struct bnxt_cp_ring *cpr = &softc->rx_cp_rings[rxqid]; | struct bnxt_cp_ring *cpr = &softc->rx_cp_rings[rxqid]; | ||||
struct rx_pkt_cmpl *rcp; | struct rx_pkt_cmpl *rcp; | ||||
struct rx_tpa_start_cmpl *rtpa; | |||||
struct rx_tpa_end_cmpl *rtpae; | struct rx_tpa_end_cmpl *rtpae; | ||||
struct cmpl_base *cmp = (struct cmpl_base *)cpr->ring.vaddr; | struct cmpl_base *cmp = (struct cmpl_base *)cpr->ring.vaddr; | ||||
int avail = 0; | int avail = 0; | ||||
uint32_t cons = cpr->cons; | uint32_t cons = cpr->cons; | ||||
bool v_bit = cpr->v_bit; | bool v_bit = cpr->v_bit; | ||||
uint8_t ags; | uint8_t ags; | ||||
int i; | int i; | ||||
uint16_t type; | uint16_t type; | ||||
uint8_t agg_id; | |||||
for (;;) { | for (;;) { | ||||
NEXT_CP_CONS_V(&cpr->ring, cons, v_bit); | NEXT_CP_CONS_V(&cpr->ring, cons, v_bit); | ||||
CMPL_PREFETCH_NEXT(cpr, cons); | CMPL_PREFETCH_NEXT(cpr, cons); | ||||
if (!CMP_VALID(&cmp[cons], v_bit)) | if (!CMP_VALID(&cmp[cons], v_bit)) | ||||
goto cmpl_invalid; | goto cmpl_invalid; | ||||
Show All 33 Lines | case CMPL_BASE_TYPE_RX_TPA_END: | ||||
NEXT_CP_CONS_V(&cpr->ring, cons, v_bit); | NEXT_CP_CONS_V(&cpr->ring, cons, v_bit); | ||||
CMPL_PREFETCH_NEXT(cpr, cons); | CMPL_PREFETCH_NEXT(cpr, cons); | ||||
if (!CMP_VALID(&cmp[cons], v_bit)) | if (!CMP_VALID(&cmp[cons], v_bit)) | ||||
goto cmpl_invalid; | goto cmpl_invalid; | ||||
} | } | ||||
avail++; | avail++; | ||||
break; | break; | ||||
case CMPL_BASE_TYPE_RX_TPA_START: | case CMPL_BASE_TYPE_RX_TPA_START: | ||||
rtpa = (void *)&cmp[cons]; | |||||
agg_id = (rtpa->agg_id & | |||||
RX_TPA_START_CMPL_AGG_ID_MASK) >> | |||||
RX_TPA_START_CMPL_AGG_ID_SFT; | |||||
softc->tpa_start[agg_id].low = *rtpa; | |||||
NEXT_CP_CONS_V(&cpr->ring, cons, v_bit); | NEXT_CP_CONS_V(&cpr->ring, cons, v_bit); | ||||
CMPL_PREFETCH_NEXT(cpr, cons); | CMPL_PREFETCH_NEXT(cpr, cons); | ||||
if (!CMP_VALID(&cmp[cons], v_bit)) | if (!CMP_VALID(&cmp[cons], v_bit)) | ||||
goto cmpl_invalid; | goto cmpl_invalid; | ||||
softc->tpa_start[agg_id].high = | |||||
((struct rx_tpa_start_cmpl_hi *)cmp)[cons]; | |||||
break; | break; | ||||
case CMPL_BASE_TYPE_RX_AGG: | case CMPL_BASE_TYPE_RX_AGG: | ||||
break; | break; | ||||
default: | default: | ||||
device_printf(softc->dev, | device_printf(softc->dev, | ||||
"Unhandled completion type %d on RXQ %d\n", | "Unhandled completion type %d on RXQ %d\n", | ||||
type, rxqid); | type, rxqid); | ||||
▲ Show 20 Lines • Show All 133 Lines • ▼ Show 20 Lines | bnxt_pkt_get_tpa(struct bnxt_softc *softc, if_rxd_info_t ri, | ||||
uint32_t flags2; | uint32_t flags2; | ||||
uint8_t ags; | uint8_t ags; | ||||
uint8_t agg_id; | uint8_t agg_id; | ||||
int i; | int i; | ||||
/* Get the agg_id */ | /* Get the agg_id */ | ||||
agg_id = (agend->agg_id & RX_TPA_END_CMPL_AGG_ID_MASK) >> | agg_id = (agend->agg_id & RX_TPA_END_CMPL_AGG_ID_MASK) >> | ||||
RX_TPA_END_CMPL_AGG_ID_SFT; | RX_TPA_END_CMPL_AGG_ID_SFT; | ||||
tpas = &softc->tpa_start[agg_id]; | tpas = &(softc->rx_rings[ri->iri_qsidx].tpa_start[agg_id]); | ||||
/* Extract from the first 16-byte BD */ | /* Extract from the first 16-byte BD */ | ||||
if (le16toh(tpas->low.flags_type) & RX_TPA_START_CMPL_FLAGS_RSS_VALID) { | if (le16toh(tpas->low.flags_type) & RX_TPA_START_CMPL_FLAGS_RSS_VALID) { | ||||
ri->iri_flowid = le32toh(tpas->low.rss_hash); | ri->iri_flowid = le32toh(tpas->low.rss_hash); | ||||
bnxt_set_rsstype(ri, tpas->low.rss_hash_type); | bnxt_set_rsstype(ri, tpas->low.rss_hash_type); | ||||
} | } | ||||
else { | else { | ||||
ri->iri_rsstype = M_HASHTYPE_NONE; | ri->iri_rsstype = M_HASHTYPE_NONE; | ||||
} | } | ||||
ags = (agend->agg_bufs_v1 & RX_TPA_END_CMPL_AGG_BUFS_MASK) >> | ags = (agend->agg_bufs_v1 & RX_TPA_END_CMPL_AGG_BUFS_MASK) >> | ||||
RX_TPA_END_CMPL_AGG_BUFS_SFT; | RX_TPA_END_CMPL_AGG_BUFS_SFT; | ||||
ri->iri_nfrags = ags + 1; | ri->iri_nfrags = ags + 1; | ||||
/* No need to byte-swap the opaque value */ | /* No need to byte-swap the opaque value */ | ||||
ri->iri_frags[0].irf_flid = (tpas->low.opaque >> 16) & 0xff; | ri->iri_frags[0].irf_flid = ((tpas->low.opaque >> 16) & 0xff); | ||||
ri->iri_frags[0].irf_idx = tpas->low.opaque & 0xffff; | ri->iri_frags[0].irf_idx = (tpas->low.opaque & 0xffff); | ||||
ri->iri_frags[0].irf_len = le16toh(tpas->low.len); | ri->iri_frags[0].irf_len = le16toh(tpas->low.len); | ||||
ri->iri_len = le16toh(tpas->low.len); | ri->iri_len = le16toh(tpas->low.len); | ||||
/* Now the second 16-byte BD */ | /* Now the second 16-byte BD */ | ||||
NEXT_CP_CONS_V(&cpr->ring, cpr->cons, cpr->v_bit); | NEXT_CP_CONS_V(&cpr->ring, cpr->cons, cpr->v_bit); | ||||
ri->iri_cidx = RING_NEXT(&cpr->ring, ri->iri_cidx); | ri->iri_cidx = RING_NEXT(&cpr->ring, ri->iri_cidx); | ||||
agendh = &((struct rx_tpa_end_cmpl_hi *)cpr->ring.vaddr)[cpr->cons]; | agendh = &((struct rx_tpa_end_cmpl_hi *)cpr->ring.vaddr)[cpr->cons]; | ||||
Show All 19 Lines | bnxt_pkt_get_tpa(struct bnxt_softc *softc, if_rxd_info_t ri, | ||||
/* Now the ag ring stuff. */ | /* Now the ag ring stuff. */ | ||||
for (i=1; i < ri->iri_nfrags; i++) { | for (i=1; i < ri->iri_nfrags; i++) { | ||||
NEXT_CP_CONS_V(&cpr->ring, cpr->cons, cpr->v_bit); | NEXT_CP_CONS_V(&cpr->ring, cpr->cons, cpr->v_bit); | ||||
ri->iri_cidx = RING_NEXT(&cpr->ring, ri->iri_cidx); | ri->iri_cidx = RING_NEXT(&cpr->ring, ri->iri_cidx); | ||||
acp = &((struct rx_abuf_cmpl *)cpr->ring.vaddr)[cpr->cons]; | acp = &((struct rx_abuf_cmpl *)cpr->ring.vaddr)[cpr->cons]; | ||||
/* No need to byte-swap the opaque value */ | /* No need to byte-swap the opaque value */ | ||||
ri->iri_frags[i].irf_flid = (acp->opaque >> 16) & 0xff; | ri->iri_frags[i].irf_flid = ((acp->opaque >> 16) & 0xff); | ||||
ri->iri_frags[i].irf_idx = acp->opaque & 0xffff; | ri->iri_frags[i].irf_idx = (acp->opaque & 0xffff); | ||||
ri->iri_frags[i].irf_len = le16toh(acp->len); | ri->iri_frags[i].irf_len = le16toh(acp->len); | ||||
ri->iri_len += le16toh(acp->len); | ri->iri_len += le16toh(acp->len); | ||||
} | } | ||||
/* And finally, the empty BD at the end... */ | /* And finally, the empty BD at the end... */ | ||||
ri->iri_nfrags++; | ri->iri_nfrags++; | ||||
/* No need to byte-swap the opaque value */ | /* No need to byte-swap the opaque value */ | ||||
ri->iri_frags[i].irf_flid = (agend->opaque >> 16) % 0xff; | ri->iri_frags[i].irf_flid = ((agend->opaque >> 16) & 0xff); | ||||
ri->iri_frags[i].irf_idx = agend->opaque & 0xffff; | ri->iri_frags[i].irf_idx = (agend->opaque & 0xffff); | ||||
ri->iri_frags[i].irf_len = le16toh(agend->len); | ri->iri_frags[i].irf_len = le16toh(agend->len); | ||||
ri->iri_len += le16toh(agend->len); | ri->iri_len += le16toh(agend->len); | ||||
return 0; | return 0; | ||||
} | } | ||||
/* If we return anything but zero, iflib will assert... */ | /* If we return anything but zero, iflib will assert... */ | ||||
static int | static int | ||||
bnxt_isc_rxd_pkt_get(void *sc, if_rxd_info_t ri) | bnxt_isc_rxd_pkt_get(void *sc, if_rxd_info_t ri) | ||||
{ | { | ||||
struct bnxt_softc *softc = (struct bnxt_softc *)sc; | struct bnxt_softc *softc = (struct bnxt_softc *)sc; | ||||
struct bnxt_cp_ring *cpr = &softc->rx_cp_rings[ri->iri_qsidx]; | struct bnxt_cp_ring *cpr = &softc->rx_cp_rings[ri->iri_qsidx]; | ||||
struct cmpl_base *cmp_q = (struct cmpl_base *)cpr->ring.vaddr; | |||||
struct cmpl_base *cmp; | struct cmpl_base *cmp; | ||||
struct rx_tpa_start_cmpl *rtpa; | |||||
uint16_t flags_type; | uint16_t flags_type; | ||||
uint16_t type; | uint16_t type; | ||||
uint8_t agg_id; | |||||
for (;;) { | for (;;) { | ||||
NEXT_CP_CONS_V(&cpr->ring, cpr->cons, cpr->v_bit); | NEXT_CP_CONS_V(&cpr->ring, cpr->cons, cpr->v_bit); | ||||
ri->iri_cidx = RING_NEXT(&cpr->ring, ri->iri_cidx); | ri->iri_cidx = RING_NEXT(&cpr->ring, ri->iri_cidx); | ||||
CMPL_PREFETCH_NEXT(cpr, cpr->cons); | CMPL_PREFETCH_NEXT(cpr, cpr->cons); | ||||
cmp = &((struct cmpl_base *)cpr->ring.vaddr)[cpr->cons]; | cmp = &((struct cmpl_base *)cpr->ring.vaddr)[cpr->cons]; | ||||
flags_type = le16toh(cmp->type); | flags_type = le16toh(cmp->type); | ||||
type = flags_type & CMPL_BASE_TYPE_MASK; | type = flags_type & CMPL_BASE_TYPE_MASK; | ||||
switch (type) { | switch (type) { | ||||
case CMPL_BASE_TYPE_RX_L2: | case CMPL_BASE_TYPE_RX_L2: | ||||
return bnxt_pkt_get_l2(softc, ri, cpr, flags_type); | return bnxt_pkt_get_l2(softc, ri, cpr, flags_type); | ||||
case CMPL_BASE_TYPE_RX_TPA_END: | case CMPL_BASE_TYPE_RX_TPA_END: | ||||
return bnxt_pkt_get_tpa(softc, ri, cpr, flags_type); | return bnxt_pkt_get_tpa(softc, ri, cpr, flags_type); | ||||
case CMPL_BASE_TYPE_RX_TPA_START: | case CMPL_BASE_TYPE_RX_TPA_START: | ||||
rtpa = (void *)&cmp_q[cpr->cons]; | |||||
agg_id = (rtpa->agg_id & | |||||
RX_TPA_START_CMPL_AGG_ID_MASK) >> | |||||
RX_TPA_START_CMPL_AGG_ID_SFT; | |||||
softc->rx_rings[ri->iri_qsidx].tpa_start[agg_id].low = *rtpa; | |||||
NEXT_CP_CONS_V(&cpr->ring, cpr->cons, cpr->v_bit); | NEXT_CP_CONS_V(&cpr->ring, cpr->cons, cpr->v_bit); | ||||
ri->iri_cidx = RING_NEXT(&cpr->ring, ri->iri_cidx); | ri->iri_cidx = RING_NEXT(&cpr->ring, ri->iri_cidx); | ||||
CMPL_PREFETCH_NEXT(cpr, cpr->cons); | CMPL_PREFETCH_NEXT(cpr, cpr->cons); | ||||
softc->rx_rings[ri->iri_qsidx].tpa_start[agg_id].high = | |||||
((struct rx_tpa_start_cmpl_hi *)cmp_q)[cpr->cons]; | |||||
break; | break; | ||||
default: | default: | ||||
device_printf(softc->dev, | device_printf(softc->dev, | ||||
"Unhandled completion type %d on RXQ %d get\n", | "Unhandled completion type %d on RXQ %d get\n", | ||||
type, ri->iri_qsidx); | type, ri->iri_qsidx); | ||||
if (type & 1) { | if (type & 1) { | ||||
NEXT_CP_CONS_V(&cpr->ring, cpr->cons, | NEXT_CP_CONS_V(&cpr->ring, cpr->cons, | ||||
cpr->v_bit); | cpr->v_bit); | ||||
Show All 19 Lines |
What's this new field for? Are other drivers supposed to use it for things?