Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 25 Aug 2020 02:42:08 +0000 (UTC)
From:      Navdeep Parhar <np@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org
Subject:   svn commit: r364748 - stable/12/sys/dev/cxgbe
Message-ID:  <202008250242.07P2g8X4057888@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: np
Date: Tue Aug 25 02:42:07 2020
New Revision: 364748
URL: https://svnweb.freebsd.org/changeset/base/364748

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

Modified:
  stable/12/sys/dev/cxgbe/adapter.h
  stable/12/sys/dev/cxgbe/t4_sge.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/dev/cxgbe/adapter.h
==============================================================================
--- stable/12/sys/dev/cxgbe/adapter.h	Tue Aug 25 02:22:49 2020	(r364747)
+++ stable/12/sys/dev/cxgbe/adapter.h	Tue Aug 25 02:42:07 2020	(r364748)
@@ -1313,4 +1313,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: stable/12/sys/dev/cxgbe/t4_sge.c
==============================================================================
--- stable/12/sys/dev/cxgbe/t4_sge.c	Tue Aug 25 02:22:49 2020	(r364747)
+++ stable/12/sys/dev/cxgbe/t4_sge.c	Tue Aug 25 02:42:07 2020	(r364748)
@@ -2522,7 +2522,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);
@@ -2734,9 +2734,9 @@ eth_tx(struct mp_ring *r, u_int cidx, u_int pidx)
 		M_ASSERTPKTHDR(m0);
 		MPASS(m0->m_nextpkt == NULL);
 
-		if (available < SGE_MAX_WR_NDESC) {
+		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 */
 		}
 
@@ -4440,7 +4440,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 */
@@ -4551,7 +4551,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;
@@ -4603,7 +4603,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 */
@@ -4709,7 +4709,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);
 
@@ -4743,7 +4743,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);
 
@@ -4784,7 +4784,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]);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202008250242.07P2g8X4057888>