From 0cadedfc46abb38b6136130eb7c5ea19143e941a Mon Sep 17 00:00:00 2001 From: Navdeep Parhar Date: Tue, 23 Jun 2020 07:33:29 +0000 Subject: [PATCH] cxgbe(4): Add a tx_len16_to_desc helper. No functional change. MFC after: 1 week Sponsored by: Chelsio Communications --- sys/dev/cxgbe/adapter.h | 8 ++++++++ sys/dev/cxgbe/crypto/t4_kern_tls.c | 6 +++--- sys/dev/cxgbe/t4_sge.c | 19 +++++++++---------- 3 files changed, 20 insertions(+), 13 deletions(-) diff --git a/sys/dev/cxgbe/adapter.h b/sys/dev/cxgbe/adapter.h index c602f0747756..f8a370cd77e1 100644 --- a/sys/dev/cxgbe/adapter.h +++ b/sys/dev/cxgbe/adapter.h @@ -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 diff --git a/sys/dev/cxgbe/crypto/t4_kern_tls.c b/sys/dev/cxgbe/crypto/t4_kern_tls.c index 2ca368865daf..edb378e39aa4 100644 --- a/sys/dev/cxgbe/crypto/t4_kern_tls.c +++ b/sys/dev/cxgbe/crypto/t4_kern_tls.c @@ -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 */ diff --git a/sys/dev/cxgbe/t4_sge.c b/sys/dev/cxgbe/t4_sge.c index 54d5536f67ca..a3ac376aac6e 100644 --- a/sys/dev/cxgbe/t4_sge.c +++ b/sys/dev/cxgbe/t4_sge.c @@ -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]);