svn commit: r358974 - stable/12/sys/dev/cxgbe

Navdeep Parhar np at FreeBSD.org
Sat Mar 14 01:03:50 UTC 2020


Author: np
Date: Sat Mar 14 01:03:48 2020
New Revision: 358974
URL: https://svnweb.freebsd.org/changeset/base/358974

Log:
  MFC r355580, r355673, and r357553.
  
  r355580:
  cxgbe(4): Use TX_PKTS2 work requests in netmap Tx if it's available.
  
  TX_PKTS2 is more efficient within the firmware and this improves netmap
  Tx by a few Mpps in some common scenarios.
  
  r355673:
  cxgbe(4): Never use hardware checksumming in netmap tx.
  
  r357553:
  cxgbe(4): Add a knob to allow netmap tx traffic to be checksummed by
  the hardware.
  
  hw.cxgbe.nm_txcsum=1
  
  Sponsored by:	Chelsio Communications

Modified:
  stable/12/sys/dev/cxgbe/adapter.h
  stable/12/sys/dev/cxgbe/t4_netmap.c
  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	Sat Mar 14 00:57:20 2020	(r358973)
+++ stable/12/sys/dev/cxgbe/adapter.h	Sat Mar 14 01:03:48 2020	(r358974)
@@ -724,6 +724,7 @@ struct sge_nm_txq {
 	u_int udb_qid;
 	u_int cntxt_id;
 	__be32 cpl_ctrl0;	/* for convenience */
+	__be32 op_pkd;		/* ditto */
 	u_int nid;		/* netmap ring # for this queue */
 
 	/* infrequently used items after this */

Modified: stable/12/sys/dev/cxgbe/t4_netmap.c
==============================================================================
--- stable/12/sys/dev/cxgbe/t4_netmap.c	Sat Mar 14 00:57:20 2020	(r358973)
+++ stable/12/sys/dev/cxgbe/t4_netmap.c	Sat Mar 14 01:03:48 2020	(r358974)
@@ -110,6 +110,16 @@ static int nm_split_rss = 0;
 SYSCTL_INT(_hw_cxgbe, OID_AUTO, nm_split_rss, CTLFLAG_RWTUN,
     &nm_split_rss, 0, "Split the netmap rx queues into two groups.");
 
+/*
+ * netmap(4) says "netmap does not use features such as checksum offloading, TCP
+ * segmentation offloading, encryption, VLAN encapsulation/decapsulation, etc."
+ * but this knob can be used to get the hardware to checksum all tx traffic
+ * anyway.
+ */
+static int nm_txcsum = 0;
+SYSCTL_INT(_hw_cxgbe, OID_AUTO, nm_txcsum, CTLFLAG_RWTUN,
+    &nm_txcsum, 0, "Enable transmit checksum offloading.");
+
 static int
 alloc_nm_rxq_hwq(struct vi_info *vi, struct sge_nm_rxq *nm_rxq, int cong)
 {
@@ -573,7 +583,10 @@ ndesc_to_npkt(const int n)
 }
 #define MAX_NPKT_IN_TYPE1_WR	(ndesc_to_npkt(SGE_MAX_WR_NDESC))
 
-/* Space (in descriptors) needed for a type1 WR that carries n packets */
+/*
+ * Space (in descriptors) needed for a type1 WR (TX_PKTS or TX_PKTS2) that
+ * carries n packets
+ */
 static inline int
 npkt_to_ndesc(const int n)
 {
@@ -583,7 +596,10 @@ npkt_to_ndesc(const int n)
 	return ((n + 2) / 2);
 }
 
-/* Space (in 16B units) needed for a type1 WR that carries n packets */
+/*
+ * Space (in 16B units) needed for a type1 WR (TX_PKTS or TX_PKTS2) that
+ * carries n packets
+ */
 static inline int
 npkt_to_len16(const int n)
 {
@@ -653,7 +669,7 @@ ring_nm_txq_db(struct adapter *sc, struct sge_nm_txq *
  */
 static void
 cxgbe_nm_tx(struct adapter *sc, struct sge_nm_txq *nm_txq,
-    struct netmap_kring *kring, int npkt, int npkt_remaining, int txcsum)
+    struct netmap_kring *kring, int npkt, int npkt_remaining)
 {
 	struct netmap_ring *ring = kring->ring;
 	struct netmap_slot *slot;
@@ -670,7 +686,7 @@ cxgbe_nm_tx(struct adapter *sc, struct sge_nm_txq *nm_
 		len = 0;
 
 		wr = (void *)&nm_txq->desc[nm_txq->pidx];
-		wr->op_pkd = htobe32(V_FW_WR_OP(FW_ETH_TX_PKTS_WR));
+		wr->op_pkd = nm_txq->op_pkd;
 		wr->equiq_to_len16 = htobe32(V_FW_WR_LEN16(npkt_to_len16(n)));
 		wr->npkt = n;
 		wr->r3 = 0;
@@ -685,16 +701,7 @@ cxgbe_nm_tx(struct adapter *sc, struct sge_nm_txq *nm_
 			cpl->ctrl0 = nm_txq->cpl_ctrl0;
 			cpl->pack = 0;
 			cpl->len = htobe16(slot->len);
-			/*
-			 * netmap(4) says "netmap does not use features such as
-			 * checksum offloading, TCP segmentation offloading,
-			 * encryption, VLAN encapsulation/decapsulation, etc."
-			 *
-			 * So the ncxl interfaces have tx hardware checksumming
-			 * disabled by default.  But you can override netmap by
-			 * enabling IFCAP_TXCSUM on the interface manully.
-			 */
-			cpl->ctrl1 = txcsum ? 0 :
+			cpl->ctrl1 = nm_txcsum ? 0 :
 			    htobe64(F_TXPKT_IPCSUM_DIS | F_TXPKT_L4CSUM_DIS);
 
 			usgl = (void *)(cpl + 1);
@@ -778,7 +785,8 @@ reclaim_nm_tx_desc(struct sge_nm_txq *nm_txq)
 	while (nm_txq->cidx != hw_cidx) {
 		wr = (void *)&nm_txq->desc[nm_txq->cidx];
 
-		MPASS(wr->op_pkd == htobe32(V_FW_WR_OP(FW_ETH_TX_PKTS_WR)));
+		MPASS(wr->op_pkd == htobe32(V_FW_WR_OP(FW_ETH_TX_PKTS_WR)) ||
+		    wr->op_pkd == htobe32(V_FW_WR_OP(FW_ETH_TX_PKTS2_WR)));
 		MPASS(wr->type == 1);
 		MPASS(wr->npkt > 0 && wr->npkt <= MAX_NPKT_IN_TYPE1_WR);
 
@@ -808,7 +816,7 @@ cxgbe_netmap_txsync(struct netmap_kring *kring, int fl
 	struct sge_nm_txq *nm_txq = &sc->sge.nm_txq[vi->first_nm_txq + kring->ring_id];
 	const u_int head = kring->rhead;
 	u_int reclaimed = 0;
-	int n, d, npkt_remaining, ndesc_remaining, txcsum;
+	int n, d, npkt_remaining, ndesc_remaining;
 
 	/*
 	 * Tx was at kring->nr_hwcur last time around and now we need to advance
@@ -819,7 +827,6 @@ cxgbe_netmap_txsync(struct netmap_kring *kring, int fl
 
 	npkt_remaining = head >= kring->nr_hwcur ? head - kring->nr_hwcur :
 	    kring->nkr_num_slots - kring->nr_hwcur + head;
-	txcsum = ifp->if_capenable & (IFCAP_TXCSUM | IFCAP_TXCSUM_IPV6);
 	while (npkt_remaining) {
 		reclaimed += reclaim_nm_tx_desc(nm_txq);
 		ndesc_remaining = contiguous_ndesc_available(nm_txq);
@@ -843,7 +850,7 @@ cxgbe_netmap_txsync(struct netmap_kring *kring, int fl
 
 		/* Send n packets and update nm_txq->pidx and kring->nr_hwcur */
 		npkt_remaining -= n;
-		cxgbe_nm_tx(sc, nm_txq, kring, n, npkt_remaining, txcsum);
+		cxgbe_nm_tx(sc, nm_txq, kring, n, npkt_remaining);
 	}
 	MPASS(npkt_remaining == 0);
 	MPASS(kring->nr_hwcur == head);

Modified: stable/12/sys/dev/cxgbe/t4_sge.c
==============================================================================
--- stable/12/sys/dev/cxgbe/t4_sge.c	Sat Mar 14 00:57:20 2020	(r358973)
+++ stable/12/sys/dev/cxgbe/t4_sge.c	Sat Mar 14 01:03:48 2020	(r358974)
@@ -3650,6 +3650,10 @@ alloc_nm_txq(struct vi_info *vi, struct sge_nm_txq *nm
 	nm_txq->cpl_ctrl0 = htobe32(V_TXPKT_OPCODE(CPL_TX_PKT) |
 	    V_TXPKT_INTF(pi->tx_chan) | V_TXPKT_PF(sc->pf) |
 	    V_TXPKT_VF(vi->vin) | V_TXPKT_VF_VLD(vi->vfvld));
+	if (sc->params.fw_vers >= FW_VERSION32(1, 24, 11, 0))
+		nm_txq->op_pkd = htobe32(V_FW_WR_OP(FW_ETH_TX_PKTS2_WR));
+	else
+		nm_txq->op_pkd = htobe32(V_FW_WR_OP(FW_ETH_TX_PKTS_WR));
 	nm_txq->cntxt_id = INVALID_NM_TXQ_CNTXT_ID;
 
 	snprintf(name, sizeof(name), "%d", idx);


More information about the svn-src-all mailing list