git: c4bac077581e - stable/14 - cxgbe(4): Add support for netmap offsets.

From: Navdeep Parhar <np_at_FreeBSD.org>
Date: Thu, 11 Jan 2024 05:33:43 UTC
The branch stable/14 has been updated by np:

URL: https://cgit.FreeBSD.org/src/commit/?id=c4bac077581ee38a3c64cd3a76cb9dd974dd749b

commit c4bac077581ee38a3c64cd3a76cb9dd974dd749b
Author:     Navdeep Parhar <np@FreeBSD.org>
AuthorDate: 2024-01-05 01:39:31 +0000
Commit:     Navdeep Parhar <np@FreeBSD.org>
CommitDate: 2024-01-11 05:22:31 +0000

    cxgbe(4): Add support for netmap offsets.
    
    PR:             253069
    Sponsored by:   Chelsio Communications
    
    (cherry picked from commit df8a58b17a1907ed3b4597475d1cb8eacc9636de)
---
 sys/dev/cxgbe/t4_netmap.c | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/sys/dev/cxgbe/t4_netmap.c b/sys/dev/cxgbe/t4_netmap.c
index 64fba4410364..0377f65acc3e 100644
--- a/sys/dev/cxgbe/t4_netmap.c
+++ b/sys/dev/cxgbe/t4_netmap.c
@@ -1003,7 +1003,7 @@ cxgbe_nm_tx(struct adapter *sc, struct sge_nm_txq *nm_txq,
 			usgl->cmd_nsge = htobe32(V_ULPTX_CMD(ULP_TX_SC_DSGL) |
 			    V_ULPTX_NSGE(1));
 			usgl->len0 = htobe32(slot->len);
-			usgl->addr0 = htobe64(ba);
+			usgl->addr0 = htobe64(ba + nm_get_offset(kring, slot));
 
 			slot->flags &= ~(NS_REPORT | NS_BUF_CHANGED);
 			cpl = (void *)(usgl + 1);
@@ -1269,7 +1269,7 @@ cxgbe_nm_attach(struct vi_info *vi)
 	bzero(&na, sizeof(na));
 
 	na.ifp = vi->ifp;
-	na.na_flags = NAF_BDG_MAYSLEEP;
+	na.na_flags = NAF_BDG_MAYSLEEP | NAF_OFFSETS;
 
 	/* Netmap doesn't know about the space reserved for the status page. */
 	na.num_tx_desc = vi->qsize_txq - sc->params.sge.spg_len / EQ_ESIZE;
@@ -1286,7 +1286,7 @@ cxgbe_nm_attach(struct vi_info *vi)
 	na.nm_register = cxgbe_netmap_reg;
 	na.num_tx_rings = vi->nnmtxq;
 	na.num_rx_rings = vi->nnmrxq;
-	na.rx_buf_maxsize = MAX_MTU;
+	na.rx_buf_maxsize = MAX_MTU + sc->params.sge.fl_pktshift;
 	netmap_attach(&na);	/* This adds IFCAP_NETMAP to if_capabilities */
 }
 
@@ -1368,6 +1368,14 @@ service_nm_rxq(struct sge_nm_rxq *nm_rxq)
 				handle_nm_sge_egr_update(sc, ifp, cpl);
 				break;
 			case CPL_RX_PKT:
+				/*
+				 * Note that the application must have netmap
+				 * offsets (NETMAP_REQ_OPT_OFFSETS) enabled on
+				 * the ring or its rx will not work correctly
+				 * when fl_pktshift > 0.
+				 */
+				nm_write_offset(kring, &ring->slot[fl_cidx],
+				    sc->params.sge.fl_pktshift);
 				ring->slot[fl_cidx].len = G_RSPD_LEN(lq) -
 				    sc->params.sge.fl_pktshift;
 				ring->slot[fl_cidx].flags = 0;