cxgbe(4): Add a tx_len16_to_desc helper.

No functional change.

MFC after:	1 week
Sponsored by:	Chelsio Communications
This commit is contained in:
np 2020-06-23 07:33:29 +00:00
parent 8617bf1892
commit ecd1738fec
3 changed files with 20 additions and 13 deletions

View File

@ -1347,4 +1347,12 @@ write_via_memwin(struct adapter *sc, int idx, uint32_t addr,
return (rw_via_memwin(sc, idx, addr, (void *)(uintptr_t)val, len, 1));
}
/* Number of len16 -> number of descriptors */
static inline int
tx_len16_to_desc(int len16)
{
return (howmany(len16, EQ_ESIZE / 16));
}
#endif

View File

@ -1375,7 +1375,7 @@ ktls_write_tcp_options(struct sge_txq *txq, void *dst, struct mbuf *m,
pktlen = m->m_len;
ctrl = sizeof(struct cpl_tx_pkt_core) + pktlen;
len16 = howmany(sizeof(struct fw_eth_tx_pkt_wr) + ctrl, 16);
ndesc = howmany(len16, EQ_ESIZE / 16);
ndesc = tx_len16_to_desc(len16);
MPASS(ndesc <= available);
/* Firmware work request header */
@ -1475,7 +1475,7 @@ ktls_write_tunnel_packet(struct sge_txq *txq, void *dst, struct mbuf *m,
pktlen = m->m_len + m_tls->m_len;
ctrl = sizeof(struct cpl_tx_pkt_core) + pktlen;
len16 = howmany(sizeof(struct fw_eth_tx_pkt_wr) + ctrl, 16);
ndesc = howmany(len16, EQ_ESIZE / 16);
ndesc = tx_len16_to_desc(len16);
MPASS(ndesc <= available);
/* Firmware work request header */
@ -2116,7 +2116,7 @@ ktls_write_tcp_fin(struct sge_txq *txq, void *dst, struct mbuf *m,
pktlen = m->m_len;
ctrl = sizeof(struct cpl_tx_pkt_core) + pktlen;
len16 = howmany(sizeof(struct fw_eth_tx_pkt_wr) + ctrl, 16);
ndesc = howmany(len16, EQ_ESIZE / 16);
ndesc = tx_len16_to_desc(len16);
MPASS(ndesc <= available);
/* Firmware work request header */

View File

@ -2708,7 +2708,7 @@ start_wrq_wr(struct sge_wrq *wrq, int len16, struct wrq_cookie *cookie)
void *w;
MPASS(len16 > 0);
ndesc = howmany(len16, EQ_ESIZE / 16);
ndesc = tx_len16_to_desc(len16);
MPASS(ndesc > 0 && ndesc <= SGE_MAX_WR_NDESC);
EQ_LOCK(eq);
@ -2920,10 +2920,9 @@ eth_tx(struct mp_ring *r, u_int cidx, u_int pidx)
M_ASSERTPKTHDR(m0);
MPASS(m0->m_nextpkt == NULL);
if (available < howmany(mbuf_len16(m0), EQ_ESIZE / 16)) {
MPASS(howmany(mbuf_len16(m0), EQ_ESIZE / 16) <= 64);
if (available < tx_len16_to_desc(mbuf_len16(m0))) {
available += reclaim_tx_descs(txq, 64);
if (available < howmany(mbuf_len16(m0), EQ_ESIZE / 16))
if (available < tx_len16_to_desc(mbuf_len16(m0)))
break; /* out of descriptors */
}
@ -4678,7 +4677,7 @@ write_txpkt_vm_wr(struct adapter *sc, struct sge_txq *txq,
ctrl = sizeof(struct cpl_tx_pkt_core);
if (needs_tso(m0))
ctrl += sizeof(struct cpl_tx_pkt_lso_core);
ndesc = howmany(len16, EQ_ESIZE / 16);
ndesc = tx_len16_to_desc(len16);
MPASS(ndesc <= available);
/* Firmware work request header */
@ -4789,7 +4788,7 @@ write_raw_wr(struct sge_txq *txq, void *wr, struct mbuf *m0, u_int available)
int len16, ndesc;
len16 = mbuf_len16(m0);
ndesc = howmany(len16, EQ_ESIZE / 16);
ndesc = tx_len16_to_desc(len16);
MPASS(ndesc <= available);
dst = wr;
@ -4842,7 +4841,7 @@ write_txpkt_wr(struct adapter *sc, struct sge_txq *txq,
sizeof(struct cpl_tx_pkt_core) + pktlen, 16);
nsegs = 0;
}
ndesc = howmany(len16, EQ_ESIZE / 16);
ndesc = tx_len16_to_desc(len16);
MPASS(ndesc <= available);
/* Firmware work request header */
@ -4948,7 +4947,7 @@ try_txpkts(struct mbuf *m, struct mbuf *n, struct txpkts *txp, u_int available)
l2 = txpkts0_len16(nsegs2);
}
txp->len16 = howmany(sizeof(struct fw_eth_tx_pkts_wr), 16) + l1 + l2;
needed = howmany(txp->len16, EQ_ESIZE / 16);
needed = tx_len16_to_desc(txp->len16);
if (needed > SGE_MAX_WR_NDESC || needed > available)
return (1);
@ -4985,7 +4984,7 @@ add_to_txpkts(struct mbuf *m, struct txpkts *txp, u_int available)
len16 = txpkts0_len16(nsegs);
else
len16 = txpkts1_len16();
needed = howmany(txp->len16 + len16, EQ_ESIZE / 16);
needed = tx_len16_to_desc(txp->len16 + len16);
if (needed > SGE_MAX_WR_NDESC || needed > available)
return (1);
@ -5026,7 +5025,7 @@ write_txpkts_wr(struct adapter *sc, struct sge_txq *txq,
MPASS(txp->len16 <= howmany(SGE_MAX_WR_LEN, 16));
MPASS(available > 0 && available < eq->sidx);
ndesc = howmany(txp->len16, EQ_ESIZE / 16);
ndesc = tx_len16_to_desc(txp->len16);
MPASS(ndesc <= available);
MPASS(wr == (void *)&eq->desc[eq->pidx]);