git: 823466bd5647 - main - dpaa: Add ContextA and ContextB to qman_fq_create

From: Justin Hibbits <jhibbits_at_FreeBSD.org>
Date: Fri, 18 Sep 2026 13:03:52 UTC
The branch main has been updated by jhibbits:

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

commit 823466bd56479d54ae482c77c311b2fa0855df2f
Author:     Justin Hibbits <jhibbits@FreeBSD.org>
AuthorDate: 2026-09-10 22:27:55 +0000
Commit:     Justin Hibbits <jhibbits@FreeBSD.org>
CommitDate: 2026-09-18 13:03:28 +0000

    dpaa: Add ContextA and ContextB to qman_fq_create
    
    The SEC QMan interface stores context in context_a and context_b, so add
    them to the frame queue creation.
---
 sys/dev/dpaa/dpaa_eth.c |  6 +++---
 sys/dev/dpaa/qman.c     | 17 ++++++++++++++++-
 sys/dev/dpaa/qman.h     | 27 ++++++++++++++++++++++++++-
 3 files changed, 45 insertions(+), 5 deletions(-)

diff --git a/sys/dev/dpaa/dpaa_eth.c b/sys/dev/dpaa/dpaa_eth.c
index 67e9da45b1d7..f17fc962539e 100644
--- a/sys/dev/dpaa/dpaa_eth.c
+++ b/sys/dev/dpaa/dpaa_eth.c
@@ -699,7 +699,7 @@ dpaa_eth_fq_rx_init(struct dpaa_eth_softc *sc)
 		}
 		fq = qman_fq_create(1, chan, DTSEC_RM_FQR_RX_WQ,
 		    /*force_fqid=*/true, base_fqid + i,
-		    false, false, true, false, 0, 0, 0, 1, 1);
+		    false, false, true, false, 0, 0, 0, 1, 1, 0, 0);
 		if (fq == NULL) {
 			device_printf(sc->sc_dev,
 			    "could not create RX FQ %d (fqid 0x%x)\n",
@@ -819,7 +819,7 @@ dpaa_eth_fq_tx_init(struct dpaa_eth_softc *sc)
 	/* TX Frame Queue */
 	fq = qman_fq_create(1, sc->sc_port_tx_qman_chan,
 	    DTSEC_RM_FQR_TX_WQ, false, 0, false, false, true, false, 0, 0, 0,
-	    0, 0);
+	    0, 0, 0, 0);
 	if (fq == NULL) {
 		device_printf(sc->sc_dev, "could not create default TX queue"
 		    "\n");
@@ -849,7 +849,7 @@ dpaa_eth_fq_tx_init(struct dpaa_eth_softc *sc)
 	/* TX Confirmation Frame Queue */
 	fq = qman_fq_create(1, sc->sc_rx_channel,
 	    DTSEC_RM_FQR_TX_CONF_WQ, false, 0, false, false, true, false, 0, 0,
-	    0, 0, 0);
+	    0, 0, 0, 0, 0);
 	if (fq == NULL) {
 		device_printf(sc->sc_dev, "could not create TX confirmation "
 		    "queue\n");
diff --git a/sys/dev/dpaa/qman.c b/sys/dev/dpaa/qman.c
index 9da6e45d3b49..9434da73494e 100644
--- a/sys/dev/dpaa/qman.c
+++ b/sys/dev/dpaa/qman.c
@@ -504,7 +504,8 @@ qman_fq_create(uint32_t fqids_num, int channel, uint8_t wq,
     bool hold_active, bool prefer_in_cache, bool congst_avoid_ena,
     void *congst_group, int8_t overhead_accounting_len,
     uint32_t tail_drop_threshold,
-    uint8_t annotation_cl, uint8_t data_cl)
+    uint8_t annotation_cl, uint8_t data_cl,
+    uint64_t context_a_opaque, uint32_t context_b_opaque)
 {
 	union qman_mc_command cmd;
 	struct qman_softc *sc;
@@ -567,6 +568,20 @@ qman_fq_create(uint32_t fqids_num, int channel, uint8_t wq,
 		cmd.init_fq.context_a = (excl << 56) | (cl << 48);
 		cmd.init_fq.fq_ctrl |= QM_FQCTRL_CTXASTASH;
 		cmd.init_fq.we_mask |= QCSP_INIT_FQ_WE_CONTEXT_A;
+	} else if (context_a_opaque != 0) {
+		/*
+		 * Opaque ContextA: caller (e.g. SEC in QI mode) needs the
+		 * FQ's ContextA read literally by the consumer.  CTXASTASH
+		 * stays off so QMan doesn't reinterpret it as stashing
+		 * config.
+		 */
+		cmd.init_fq.context_a = context_a_opaque;
+		cmd.init_fq.we_mask |= QCSP_INIT_FQ_WE_CONTEXT_A;
+	}
+
+	if (context_b_opaque != 0) {
+		cmd.init_fq.context_b = context_b_opaque;
+		cmd.init_fq.we_mask |= QCSP_INIT_FQ_WE_CONTEXT_B;
 	}
 
 	critical_enter();
diff --git a/sys/dev/dpaa/qman.h b/sys/dev/dpaa/qman.h
index b009760d6257..564a0a1d9cb4 100644
--- a/sys/dev/dpaa/qman.h
+++ b/sys/dev/dpaa/qman.h
@@ -249,6 +249,30 @@ void qman_set_sdest(uint16_t, int);
  * @param tail_drop_threshold		If not 0 - enable tail drop on this
  * 					FQR.
  *
+ * @param annotation_cl			Number of words of frame annotation to
+ * 					stash in cache.
+ *
+ * @param data_cl			Number of words of frame data to stash
+ * 					in cache.
+ *
+ * @param context_a_opaque		Raw 64-bit value written into the FQ's
+ *					ContextA field.  Used when the FQ's
+ *					consumer (e.g. SEC in QI mode) reads
+ *					ContextA as an opaque cookie — for SEC
+ *					this is the physical address of the
+ *					session preheader.  Mutually exclusive
+ *					with the hardware stashing config
+ *					driven by @annotation_cl / @data_cl:
+ *					if either stash count is non-zero,
+ *					this argument is ignored.  Pass 0 when
+ *					unused.
+ *
+ * @param context_b_opaque		Raw 32-bit value written into the FQ's
+ *					ContextB field.  For SEC in QI mode
+ *					this is the FQID of the FQ where
+ *					responses should be enqueued.  Pass 0
+ *					when unused.
+ *
  * @return				A handle to newly created FQR object.
  */
 struct qman_fq *qman_fq_create(uint32_t fqids_num, int channel,
@@ -256,7 +280,8 @@ struct qman_fq *qman_fq_create(uint32_t fqids_num, int channel,
     bool hold_active, bool prefer_in_cache, bool congst_avoid_ena,
     void *congst_group, int8_t overhead_accounting_len,
     uint32_t tail_drop_threshold,
-    uint8_t annotation_cl, uint8_t data_cl);
+    uint8_t annotation_cl, uint8_t data_cl,
+    uint64_t context_a_opaque, uint32_t context_b_opaque);
 
 /**
  * Free Frame Queue Range.