svn commit: r362532 - in head/sys/dev/cxgbe: . crypto

Navdeep Parhar np at FreeBSD.org
Tue Jun 23 07:33:30 UTC 2020


Author: np
Date: Tue Jun 23 07:33:29 2020
New Revision: 362532
URL: https://svnweb.freebsd.org/changeset/base/362532

Log:
  cxgbe(4): Add a tx_len16_to_desc helper.
  
  No functional change.
  
  MFC after:	1 week
  Sponsored by:	Chelsio Communications

Modified:
  head/sys/dev/cxgbe/adapter.h
  head/sys/dev/cxgbe/crypto/t4_kern_tls.c
  head/sys/dev/cxgbe/t4_sge.c

Modified: head/sys/dev/cxgbe/adapter.h
==============================================================================
--- head/sys/dev/cxgbe/adapter.h	Tue Jun 23 06:42:39 2020	(r362531)
+++ head/sys/dev/cxgbe/adapter.h	Tue Jun 23 07:33:29 2020	(r362532)
@@ -1347,4 +1347,12 @@ write_via_memwin(struct adapter *sc, int idx, uint32_t
 
 	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

Modified: head/sys/dev/cxgbe/crypto/t4_kern_tls.c
==============================================================================
--- head/sys/dev/cxgbe/crypto/t4_kern_tls.c	Tue Jun 23 06:42:39 2020	(r362531)
+++ head/sys/dev/cxgbe/crypto/t4_kern_tls.c	Tue Jun 23 07:33:29 2020	(r362532)
@@ -1375,7 +1375,7 @@ ktls_write_tcp_options(struct sge_txq *txq, void *dst,
 	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 *ds
 	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, str
 	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 */

Modified: head/sys/dev/cxgbe/t4_sge.c
==============================================================================
--- head/sys/dev/cxgbe/t4_sge.c	Tue Jun 23 06:42:39 2020	(r362531)
+++ head/sys/dev/cxgbe/t4_sge.c	Tue Jun 23 07:33:29 2020	(r362532)
@@ -2708,7 +2708,7 @@ start_wrq_wr(struct sge_wrq *wrq, int len16, struct wr
 	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 *
 	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 mbu
 	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 txpk
 		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_in
 		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 *tx
 	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]);


More information about the svn-src-head mailing list