Skip to contentSkip to conversation

DPAA driver changes

PATCH Superseded Gagandeep Singh 2 participants 33 messages Oct 28 – Nov 17

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover DPAA driver changes

- Adding OH port support.
- Updates in shared ethernet code.
- Congestion related code cleanup.

Gagandeep Singh (1):
drivers: add offline (O/H) port device support

Hemant Agrawal (1):
net/dpaa: support non fmX-macY type of shared Ethernet name

Jun Yang (1):
drivers: add DPAA cgrid cleanup support

 doc/api/doxy-api-index.md                |   1 +
 doc/guides/nics/dpaa.rst                 |  32 +
 drivers/bus/dpaa/base/fman/fman.c        |  19 +
 drivers/bus/dpaa/base/qbman/qman.c       |  61 ++
 drivers/bus/dpaa/bus_dpaa_driver.h       |   4 +-
 drivers/bus/dpaa/dpaa_bus.c              | 100 ++-
 drivers/bus/dpaa/dpaa_bus_base_symbols.c |   2 +
 drivers/bus/dpaa/include/fman.h          |   6 +-
 drivers/bus/dpaa/include/fsl_qman.h      |  28 +
 drivers/net/dpaa/dpaa_ethdev.c           | 176 ++++-
 drivers/net/dpaa/dpaa_ethdev.h           |   3 +
 drivers/net/dpaa/dpaa_flow.c             |   7 +-
 drivers/net/dpaa/dpaa_oldev.c            | 875 +++++++++++++++++++++++
 drivers/net/dpaa/meson.build             |  11 +-
 drivers/net/dpaa/rte_pmd_dpaa_oldev.h    | 158 ++++
 15 files changed, 1454 insertions(+), 29 deletions(-)
 create mode 100644 drivers/net/dpaa/dpaa_oldev.c
 create mode 100644 drivers/net/dpaa/rte_pmd_dpaa_oldev.h
Signature · 1 line
2.25.1
#1 lore raw

PATCH 1/3 drivers: add offline (O/H) port device support

Add support for the DPAA Offline/Host-command (O/H) port, allowing a single OL port to be used by a DPDK application. The feature is selected through the 'drv_oldev' bus device argument, and the associated back-half port is named through the 'drv_bh_port' device argument.

---
 doc/api/doxy-api-index.md                |   1 +
 doc/guides/nics/dpaa.rst                 |  27 +
 drivers/bus/dpaa/base/fman/fman.c        |  19 +
 drivers/bus/dpaa/bus_dpaa_driver.h       |   4 +-
 drivers/bus/dpaa/dpaa_bus.c              | 100 ++-
 drivers/bus/dpaa/dpaa_bus_base_symbols.c |   1 +
 drivers/bus/dpaa/include/fman.h          |   6 +-
 drivers/bus/dpaa/include/fsl_qman.h      |   1 +
 drivers/net/dpaa/dpaa_ethdev.h           |   3 +
 drivers/net/dpaa/dpaa_flow.c             |   7 +-
 drivers/net/dpaa/dpaa_oldev.c            | 875 +++++++++++++++++++++++
 drivers/net/dpaa/meson.build             |  11 +-
 drivers/net/dpaa/rte_pmd_dpaa_oldev.h    | 158 ++++
 13 files changed, 1197 insertions(+), 16 deletions(-)
 create mode 100644 drivers/net/dpaa/dpaa_oldev.c
 create mode 100644 drivers/net/dpaa/rte_pmd_dpaa_oldev.h
doc/api/doxy-api-index.md +1 -0
index 62390f7be3..0bd8e1bbf0 100644
@@ -53,6 +53,7 @@ The public API headers are grouped by topics:
   [cnxk_eventdev](@ref rte_pmd_cnxk_eventdev.h),
   [cnxk_mempool](@ref rte_pmd_cnxk_mempool.h),
   [dpaa](@ref rte_pmd_dpaa.h),
+  [dpaa_oldev](@ref rte_pmd_dpaa_oldev.h),
   [dpaa2](@ref rte_pmd_dpaa2.h),
   [mlx5](@ref rte_pmd_mlx5.h),
   [dpaa2_mempool](@ref rte_dpaa2_mempool.h),
doc/guides/nics/dpaa.rst +27 -0
index c6aab46828..667b8c113d 100644
@@ -276,6 +276,33 @@ Refer to the document :doc:`build_and_test` for details.
   and thus disabling hardware based packet handling at driver level,
   e.g. ``dpaa:fm1-mac3,recv_err_pkts=1``.
 
+``drv_bh_port``
+   Name of the back-half port associated with an offline (O/H) port device.
+   It is passed on the offline port device itself, which is named
+   ``oldev1``, e.g. ``-a dpaa_bus:oldev1,drv_bh_port=fm1-mac5``.
+
+The following bus-level device argument configures the DPAA bus itself and
+is passed through the EAL bus arguments. The bus name is ``dpaa_bus``:
+
+``drv_oldev`` (default disabled)
+   Enable the DPAA offline (O/H) port device,
+   e.g. ``-a bus=dpaa_bus,drv_oldev=1``.
+
+   Passing any ``-a`` argument for the DPAA bus switches the bus to
+   allowlist scan mode, so from that point on only the devices named with
+   ``-a`` are probed. Enabling the offline port therefore requires listing
+   the offline port itself and every Ethernet port the application needs,
+   for example::
+
+      -a bus=dpaa_bus,drv_oldev=1 \
+      -a dpaa_bus:oldev1,drv_bh_port=fm1-mac5 \
+      -a dpaa_bus:fm1-mac5 -a dpaa_bus:fm1-mac6
+
+   Omitting ``-a dpaa_bus:oldev1`` leaves the offline port unprobed even
+   though ``drv_oldev=1`` was given, and omitting an ``fmX-macY`` port
+   silently drops that port.
+
+
 FMAN Config
 -----------
 
drivers/bus/dpaa/base/fman/fman.c +19 -0
index 67f77265ca..223cd6958d 100644
@@ -205,6 +205,9 @@ static void fman_if_vsp_init(struct __fman_if *__if)
 	size_t lenp;
 	const uint8_t mac_idx[] = {-1, 0, 1, 2, 3, 4, 5, 6, 7, 0, 1};
 
+	static_assert(RTE_DIM(mac_idx) == FMAN_MAX_MAC_IDX_NUM,
+		      "mac_idx[] out of sync with FMAN_MAX_MAC_IDX_NUM");
+
 	if (__if->__if.mac_idx <= 8) {
 		for_each_compatible_node(dev, NULL,
 			"fsl,fman-port-1g-rx-extended-args") {
@@ -544,6 +547,14 @@ fman_if_init(const struct device_node *dpa_node, int fd)
 		cell_idx_host = of_read_number(cell_idx,
 					       lenp / sizeof(phandle));
 
+		if (cell_idx_host >= FMAN_MAX_MAC_IDX_NUM) {
+			FMAN_ERR(-EINVAL,
+				 "%s: cell-index(%" PRIu64 ") >= max(%d)",
+				 oh_node->full_name, cell_idx_host,
+				 FMAN_MAX_MAC_IDX_NUM);
+			goto err;
+		}
+
 		__if->__if.mac_idx = cell_idx_host;
 	}
 
@@ -957,6 +968,14 @@ static int fman_if_init_onic(const struct device_node *dpa_node)
 	assert(lenp == sizeof(*cell_idx));
 
 	cell_idx_host = of_read_number(cell_idx, lenp / sizeof(phandle));
+
+	if (cell_idx_host >= FMAN_MAX_MAC_IDX_NUM) {
+		FMAN_ERR(-EINVAL, "%s: cell-index(%" PRIu64 ") >= max(%d)",
+			 tx_oh_node->full_name, cell_idx_host,
+			 FMAN_MAX_MAC_IDX_NUM);
+		goto err;
+	}
+
 	__if->__if.mac_idx = cell_idx_host;
 
 	fman_node = of_get_parent(fman_tx_oh_node);
drivers/bus/dpaa/bus_dpaa_driver.h +3 -1
index 4aed83f84d..323a6a7659 100644
@@ -69,11 +69,13 @@ struct rte_dpaa_driver;
 enum rte_dpaa_type {
 	FSL_DPAA_ETH = 1,
 	FSL_DPAA_CRYPTO,
-	FSL_DPAA_QDMA
+	FSL_DPAA_QDMA,
+	FSL_DPAA_OL
 };
 
 struct dpaa_device_id {
 	uint8_t fman_id; /**< Fman interface ID, for ETH type device */
+	uint8_t ol_id;	/**< OH interface ID, for OH type device */
 	uint8_t mac_id; /**< Fman MAC interface ID, for ETH type device */
 	uint16_t dev_id; /**< Device Identifier from DPDK */
 };
drivers/bus/dpaa/dpaa_bus.c +92 -8

168 lines not on this page · raw message

drivers/bus/dpaa/dpaa_bus_base_symbols.c +1 -0
index 0927e5fe2c..aaa9f9bec2 100644
@@ -52,6 +52,7 @@ RTE_EXPORT_INTERNAL_SYMBOL(bman_acquire)
 RTE_EXPORT_INTERNAL_SYMBOL(bman_query_free_buffers)
 RTE_EXPORT_INTERNAL_SYMBOL(bman_thread_irq)
 RTE_EXPORT_INTERNAL_SYMBOL(qman_alloc_fqid_range)
+RTE_EXPORT_INTERNAL_SYMBOL(qman_release_fqid_range)
 RTE_EXPORT_INTERNAL_SYMBOL(qman_reserve_fqid_range)
 RTE_EXPORT_INTERNAL_SYMBOL(qman_alloc_pool_range)
 RTE_EXPORT_INTERNAL_SYMBOL(qman_alloc_cgrid_range)
drivers/bus/dpaa/include/fman.h +5 -1
index f642faf3b3..030c85c284 100644
@@ -68,6 +68,11 @@
 #define FMAN_RTC_MAX_NUM_OF_PERIODIC_PULSES	4
 #define FMAN_RTC_MAX_NUM_OF_EXT_TRIGGERS	3
 
+/*
+ * Maximum number of MAC/offline port indexes.
+ */
+#define FMAN_MAX_MAC_IDX_NUM	11
+
 /* Represents the different flavour of network interface */
 enum fman_mac_type {
 	fman_offline_internal = 0,
@@ -475,7 +480,6 @@ struct __fman_if {
 	void *qmi_map;
 };
 
-#define MEMMAC_REG_OFFSET(reg) offsetof(struct memac_regs, reg)
 #define BMI_RX_REG_OFFSET(reg) offsetof(struct rx_bmi_regs, reg)
 #define BMI_TX_REG_OFFSET(reg) offsetof(struct tx_bmi_regs, reg)
 
drivers/bus/dpaa/include/fsl_qman.h +1 -0
index 59b41e17f0..b2674ce5d0 100644
@@ -1895,6 +1895,7 @@ static inline int qman_alloc_fqid(u32 *result)
  * This function can also be used to seed the allocator with ranges of FQIDs
  * that it can subsequently allocate from.
  */
+__rte_internal
 void qman_release_fqid_range(u32 fqid, unsigned int count);
 static inline void qman_release_fqid(u32 fqid)
 {
drivers/net/dpaa/dpaa_ethdev.h +3 -0
index 47c8e2b086..7e70bf2ad2 100644
@@ -114,6 +114,9 @@ enum {
 
 #define DPAA_DEFAULT_RXQ_VSP_ID		1
 
+/* Device argument to name the offline (O/H) port back-half port */
+#define DRIVER_OL_BH_PORT		"drv_bh_port"
+
 #define FMC_FILE "/tmp/fmc.bin"
 
 struct dpaa_if_vsp {
drivers/net/dpaa/dpaa_flow.c +6 -1
index f77f9f333b..6c519ec975 100644
@@ -32,9 +32,14 @@ return &scheme_params->param.key_ext_and_hash.extract_array[hdr_idx];
 	SCH_EXT_HDR(scheme_params, hdr_idx).extract_by_hdr_type.full_field
 
 /* FMAN mac indexes mappings (0 is unused, first 8 are for 1G, next for 10G
- * ports).
+ * ports). Indexed by fman_if.mac_idx, which the bus validates against
+ * FMAN_MAX_MAC_IDX_NUM when deriving it from the device tree.
  */
 static const uint8_t mac_idx[] = {-1, 0, 1, 2, 3, 4, 5, 6, 7, 0, 1};
+static_assert(RTE_DIM(mac_idx) == FMAN_MAX_MAC_IDX_NUM,
+	"mac_idx[] out of sync with FMAN_MAX_MAC_IDX_NUM");
+
+
 
 /* FM global info */
 struct dpaa_fm_info {
drivers/net/dpaa/dpaa_oldev.c new file +875 -0

875 lines not on this page · raw message

drivers/net/dpaa/meson.build +6 -5
index 8d4f69c596..3ec1091197 100644
@@ -1,5 +1,5 @@
 # SPDX-License-Identifier: BSD-3-Clause
-# Copyright 2018-2020 NXP
+# Copyright 2018-2020,2026 NXP
 
 if not is_linux
     build = false
@@ -9,12 +9,13 @@ deps += ['mempool_dpaa']
 
 sources = files(
         'dpaa_ethdev.c',
-        'fmlib/fm_lib.c',
-        'fmlib/fm_vsp.c',
         'dpaa_flow.c',
-        'dpaa_rxtx.c',
         'dpaa_fmc.c',
         'dpaa_ptp.c',
+        'dpaa_oldev.c',
+        'dpaa_rxtx.c',
+        'fmlib/fm_lib.c',
+        'fmlib/fm_vsp.c',
 )
 
 cflags += no_wvla_cflag
@@ -24,4 +25,4 @@ if cc.has_argument('-Wno-pointer-arith')
     cflags += '-Wno-pointer-arith'
 endif
 
-headers = files('rte_pmd_dpaa.h')
+headers = files('rte_pmd_dpaa.h', 'rte_pmd_dpaa_oldev.h')
drivers/net/dpaa/rte_pmd_dpaa_oldev.h new file +158 -0

158 lines not on this page · raw message

Signature · 1 line
2.25.1
#2 lore raw

PATCH 2/3 net/dpaa: support non fmX-macY type of shared Ethernet name

In reply to Gagandeep Singh

From: Hemant Agrawal <[email protected]>

A shared MAC interface needs the kernel netdev name to read the MTU, and that name is only the DPDK port name for fmX-macY style netdevs.

Look it up in sysfs under the platform device of the dpa-ethernet node the port was created from, and fall back to the port name.

---
 doc/guides/nics/dpaa.rst       |  5 +++
 drivers/net/dpaa/dpaa_ethdev.c | 59 +++++++++++++++++++++++++++++++++-
 2 files changed, 63 insertions(+), 1 deletion(-)
doc/guides/nics/dpaa.rst +5 -0
index 667b8c113d..14a14feb3c 100644
@@ -303,6 +303,11 @@ is passed through the EAL bus arguments. The bus name is ``dpaa_bus``:
    silently drops that port.
 
 
+* For a shared MAC interface the kernel network interface name is looked up
+  in sysfs from the device tree node the port was created from,
+  so a kernel interface that does not follow
+  the ``fmX-macY`` naming style is handled without extra configuration.
+
 FMAN Config
 -----------
 
drivers/net/dpaa/dpaa_ethdev.c +58 -1

83 lines not on this page · raw message

Signature · 1 line
2.25.1
#3 lore raw

PATCH 3/3 drivers: add DPAA cgrid cleanup support

In reply to Gagandeep Singh

From: Jun Yang <[email protected]>

A congestion group must have no member frame queues left when it is deleted, and its CGRID must be returned to the allocator once the group is gone. Neither was handled on the net/dpaa close and probe-failure paths.

This also changes probe behaviour: a qman_create_cgr() failure in dpaa_rx_queue_init() or dpaa_tx_queue_init() now fails the probe instead of continuing without tail drop on that queue. The probe error path deletes one CGR per initialised queue, and a CGR whose creation failed was never linked into the portal list.

---
 drivers/bus/dpaa/base/qbman/qman.c       |  61 ++++++++++++
 drivers/bus/dpaa/dpaa_bus_base_symbols.c |   1 +
 drivers/bus/dpaa/include/fsl_qman.h      |  27 ++++++
 drivers/net/dpaa/dpaa_ethdev.c           | 117 ++++++++++++++++++++---
 4 files changed, 194 insertions(+), 12 deletions(-)
drivers/bus/dpaa/base/qbman/qman.c +61 -0
index 3c056e4547..fa3387c6bd 100644
@@ -2993,3 +2993,64 @@ qman_shutdown_fq(struct qman_fq *fq)
 out:
 	return ret;
 }
+
+int qman_pending_fq_by_cgrid_range(u32 cgrid_start, u32 cgrid_num,
+	u32 start_fqid, u32 *fqid, u32 *cgrid)
+{
+	struct qman_fq fq = {
+		.fqid = start_fqid ? start_fqid : 1
+	};
+	struct qm_mcr_queryfq_np np;
+	struct qm_fqd fqd;
+	int err;
+
+	/*
+	 * Do not use the CGR byte count to decide whether to scan. An FQ is a
+	 * member of the group whenever it is scheduled with CGE set and a
+	 * matching cgid, whether or not it currently holds any frames, and the
+	 * group cannot be deleted while such a member exists. Skipping the
+	 * scan for an empty CGR would let an idle stale FQ survive and its
+	 * CGRID be released while still referenced. This runs from the device
+	 * close path only, so the scan cost is acceptable.
+	 *
+	 * The whole CGRID range of a port is matched in a single pass, so a
+	 * port with many congestion groups does not need one full FQID space
+	 * scan per group.
+	 */
+	DPAA_BUS_DEBUG("Scanning FQs for cgrid(0x%x..0x%x)",
+		cgrid_start, cgrid_start + cgrid_num - 1);
+
+	/* FQID space is 24 bits wide; stop before wrapping. */
+	for (; fq.fqid <= QMAN_MAX_FQID; fq.fqid++) {
+		err = qman_query_fq_np(&fq, &np);
+		if (err == -ERANGE) {
+			/*
+			 * FQID is not implemented on this device, so there is
+			 * nothing beyond it either.
+			 */
+			break;
+		} else if (err) {
+			DPAA_BUS_WARN("Failed(%d) to Query np FQ(fqid=0x%x)",
+				err, fq.fqid);
+			return err;
+		}
+		if ((np.state & QM_MCR_NP_STATE_MASK) != QM_MCR_NP_STATE_OOS) {
+			err = qman_query_fq(&fq, &fqd);
+			if (err) {
+				DPAA_BUS_WARN("Failed(%d) to Query FQ(fqid=0x%x)",
+					err, fq.fqid);
+			} else if ((fqd.fq_ctrl & QM_FQCTRL_CGE) &&
+				fqd.cgid >= cgrid_start &&
+				fqd.cgid < cgrid_start + cgrid_num) {
+				if (fqid)
+					*fqid = fq.fqid;
+				if (cgrid)
+					*cgrid = fqd.cgid;
+				return 0;
+			}
+		}
+	}
+	DPAA_BUS_DEBUG("No FQ left in cgrid(0x%x..0x%x)",
+		cgrid_start, cgrid_start + cgrid_num - 1);
+	return -ERANGE;
+}
drivers/bus/dpaa/dpaa_bus_base_symbols.c +1 -0
index aaa9f9bec2..4da43f293d 100644
@@ -57,6 +57,7 @@ RTE_EXPORT_INTERNAL_SYMBOL(qman_reserve_fqid_range)
 RTE_EXPORT_INTERNAL_SYMBOL(qman_alloc_pool_range)
 RTE_EXPORT_INTERNAL_SYMBOL(qman_alloc_cgrid_range)
 RTE_EXPORT_INTERNAL_SYMBOL(qman_release_cgrid_range)
+RTE_EXPORT_INTERNAL_SYMBOL(qman_pending_fq_by_cgrid_range)
 RTE_EXPORT_INTERNAL_SYMBOL(dpaa_intr_enable)
 RTE_EXPORT_INTERNAL_SYMBOL(dpaa_intr_disable)
 RTE_EXPORT_INTERNAL_SYMBOL(dpaa_get_ioctl_version_number)
drivers/bus/dpaa/include/fsl_qman.h +27 -0
index b2674ce5d0..6d76722275 100644
@@ -1284,6 +1284,9 @@ struct qman_cgr {
  */
 #define QMAN_FQRN_WAIT_MAX		10000000u
 
+/* Maximum FQID value: frame queue IDs are 24 bits wide. */
+#define QMAN_MAX_FQID			0x00FFFFFFu
+
 /* Flags to qman_create_fq() */
 #define QMAN_FQ_FLAG_NO_ENQUEUE      0x00000001 /* can't enqueue */
 #define QMAN_FQ_FLAG_NO_MODIFY       0x00000002 /* can only enqueue */
@@ -1916,6 +1919,30 @@ static inline int qman_shutdown_fq_by_fqid(u32 fqid)
 	return qman_shutdown_fq(&fq);
 }
 
+/**
+ * qman_pending_fq_by_cgrid_range - Find an FQ still attached to a CGR range.
+ *
+ * @cgrid_start: first congestion group id of the range to search for.
+ * @cgrid_num: number of consecutive congestion group ids in the range.
+ * @start_fqid: FQID to begin the scan from (0 or 1 means scan from the
+ *   start). A caller shutting down several stale FQs can pass the previously
+ *   returned FQID + 1 to resume the scan instead of restarting from the
+ *   beginning each time.
+ * @fqid: on success, holds the FQID that is still attached to the range.
+ * @cgrid: on success, holds the congestion group id that FQ belongs to.
+ *   May be NULL.
+ *
+ * Matching a whole range in one pass lets a caller with many congestion
+ * groups, such as a port releasing all of its Rx or Tx CGRs, avoid one full
+ * FQID space scan per group.
+ *
+ * Return 0 and set *fqid when a matching FQ is found, -ERANGE when none is
+ * left, or a negative error code on query failure.
+ */
+__rte_internal
+int qman_pending_fq_by_cgrid_range(u32 cgrid_start, u32 cgrid_num,
+		u32 start_fqid, u32 *fqid, u32 *cgrid);
+
 /**
  * qman_reserve_fqid_range - Reserve the specified range of frame queue IDs
  * @fqid: the base FQID of the range to deallocate
drivers/net/dpaa/dpaa_ethdev.c +105 -12

236 lines not on this page · raw message

Signature · 1 line
2.25.1
#4 lore raw
In reply to Gagandeep Singh
Quoted 30 lines · On Wed, 28 Oct 2026 14:25:14 +0530 Gagandeep Singh <[email protected]> wrote:

- Adding OH port support.
- Updates in shared ethernet code.
- Congestion related code cleanup.

Gagandeep Singh (1):
drivers: add offline (O/H) port device support

Hemant Agrawal (1):
net/dpaa: support non fmX-macY type of shared Ethernet name

Jun Yang (1):
drivers: add DPAA cgrid cleanup support

 doc/api/doxy-api-index.md                |   1 +
 doc/guides/nics/dpaa.rst                 |  32 +
 drivers/bus/dpaa/base/fman/fman.c        |  19 +
 drivers/bus/dpaa/base/qbman/qman.c       |  61 ++
 drivers/bus/dpaa/bus_dpaa_driver.h       |   4 +-
 drivers/bus/dpaa/dpaa_bus.c              | 100 ++-
 drivers/bus/dpaa/dpaa_bus_base_symbols.c |   2 +
 drivers/bus/dpaa/include/fman.h          |   6 +-
 drivers/bus/dpaa/include/fsl_qman.h      |  28 +
 drivers/net/dpaa/dpaa_ethdev.c           | 176 ++++-
 drivers/net/dpaa/dpaa_ethdev.h           |   3 +
 drivers/net/dpaa/dpaa_flow.c             |   7 +-
 drivers/net/dpaa/dpaa_oldev.c            | 875 +++++++++++++++++++++++
 drivers/net/dpaa/meson.build             |  11 +-
 drivers/net/dpaa/rte_pmd_dpaa_oldev.h    | 158 ++++
 15 files changed, 1454 insertions(+), 29 deletions(-)
 create mode 100644 drivers/net/dpaa/dpaa_oldev.c
Quoted 1 line

create

AI review found issues. The biggest one is carrying vendor private ioctl data structures in DPDK.

Review of [PATCH v1 0/3] DPAA offline port, shared MAC, cgrid cleanup

Series
------

The rte_pmd_dpaa_ol_* functions do not operate on a DPDK port. They take no port_id and only forward a caller-filled struct to an out-of-tree kernel driver through ioctl() on /dev/cdx_ctrl. That puts a vendor kernel ioctl ABI (GTP classification, "telecom application" flags) into an installed DPDK header under DPDK API/ABI rules. An application can issue these ioctls itself; this belongs in the vendor userspace library for that kernel module, not in DPDK. Please drop rte_pmd_dpaa_oldev.h and the four exported functions.

The drv_oldev bus argument is redundant. The offline port is only probed if "-a dpaa_bus:oldev1" is given anyway, so create the oldev1 device when its devargs exist and drop drv_oldev, the bus_str parsing, and the allowlist caveats in dpaa.rst:

	if (rte_bus_find_devargs(&rte_dpaa_bus, "oldev1") != NULL) {
		/* create oldev1 */
	}

No release notes for the new port type. dpaa.rst does not say the offline port needs the /dev/cdx_ctrl kernel driver or where to get it.

Patch 1/3 drivers: add offline (O/H) port device support
--------------------------------------------------------

Error

dpaa_oldev_init() never sets tx_queues[0].dpaa_intf, and the queue array comes from rte_zmalloc(), so it is NULL. dpaa_eth_queue_tx() starts with:

	struct dpaa_if *dpaa_intf = fq->dpaa_intf;
	...
	if (unlikely(dpaa_intf->ts_enable)) {

so the first Tx burst after dev_start dereferences NULL. Set it after the Tx FQ is initialised:

	ret = dpaa_ol_tx_queue_init(&dpaa_intf->tx_queues[0], 0);
	if (ret)
		goto free_rx;
	dpaa_intf->tx_queues[0].dpaa_intf = dpaa_intf;

Warning

rte_kvargs_count() only tests for presence, so "drv_oldev=0" enables the offline port. Moot if drv_oldev is removed as above; otherwise parse the value with rte_kvargs_process().

dev_close() shuts down the Rx/Tx FQs and returns their FQIDs to the allocator, but the kernel was given those FQIDs and the bpid through ASK_CTRL_SET_DPDK_INFO and is never told they are gone. The next qman_alloc_fqid() user can receive frames the kernel enqueues to a reused FQID. The kernel side needs a reset ioctl issued before the FQIDs are released.

The cell-index range checks in fman_if_init() and fman_if_init_onic() fix an out-of-bounds read of mac_idx[] and have nothing to do with the offline port. The commit message does not mention them, nor the MEMMAC_REG_OFFSET removal. Split the bounds checks into their own patch with:

	Fixes: a0edbb8a8e52 ("bus/dpaa: add OH port mode")
	Fixes: 7e5f49ae767d ("bus/dpaa: add ONIC port mode")
	Cc: [email protected]

drv_bh_port is required, but it is parsed on every dev_start() with a NULL key list, so a misspelled key is accepted at probe and the port only fails at start. Parse it once in dpaa_ol_probe() with a valid key list, store it in the private data, and fail probe if it is missing.

If rte_pmd_dpaa_oldev.h stays, the installed header defines DPA_ISC_*, DPDK_OLDEV_*, DPDK_CLASSIF_*, DPDK_TELECOM_* and struct dpa_* without an RTE_/rte_ prefix, and none of the structs or fields have Doxygen.

Info

dpaa_ol_rx_queue_setup() checks queue_idx against nb_rx_queues; ethdev already does that before calling the PMD.

open(ASK_PATH, O_RDWR) should use O_RDWR | O_CLOEXEC.

In dpaa_create_device_list(), use snprintf() rather than sprintf(), and drop the memset() after calloc() and the "int i = 0" initialiser.

rte_dpaa_bus_dev_build() gates the num_ethports messages on oldev_enabled; the condition that matters is dpaa_netcfg != NULL.

The dpaa_bus_parse_bus_args() comment refers to a previous environment-variable configuration that never existed upstream. The bh_port_name field comment says "for testing purpose" but the field is mandatory.

Patch 2/3 net/dpaa: support non fmX-macY type of shared Ethernet name
---------------------------------------------------------------------

Warning

Platform devices created from device-tree nodes without a reg property are named after the whole parent chain, which is why dpaa_bus.c uses "/sys/devices/platform/soc/soc:fsl,dpaa". A dpa-ethernet child of that node is not "ethernet@N" under /sys/bus/platform/devices, so

	node = strrchr(node_path, '/');
	...
	"/sys/bus/platform/devices/%s/net", node

misses and silently falls back to the port name, which is the case the patch is meant to fix. Match on the netdev's of_node instead:

	/* for each /sys/class/net/<if> */
	snprintf(path, sizeof(path), "/sys/class/net/%s/device/of_node",
		 ifname);
	if (realpath(path, resolved) != NULL &&
	    strcmp(resolved + strlen("/sys/firmware/devicetree/base"),
		   node_path) == 0)
		/* found */

Info

The new dpaa.rst bullet lands at the end of the bus devargs block; it belongs with the shared MAC description.

Patch 3/3 drivers: add DPAA cgrid cleanup support
-------------------------------------------------

Warning

This fixes a CGRID leak on close and a stale portal list entry on probe failure, but has no Fixes: tag or stable Cc:

Fixes 62f53995caaf ("net/dpaa: add frame count based tail drop with CGR")
Fixes 9124e65dd3eb ("net/dpaa: enable Tx queue taildrop")

On the probe error path the initialised Rx FQs (and Tx FQs on free_tx) were scheduled with QM_FQCTRL_CGE and their cgid, and are never shut down before

	for (loop = 0; loop < nb_rx_cgr; loop++)
		qman_delete_cgr(&dpaa_intf->cgr_rx[loop]);
	if (rx_cgrid_allocated)
		qman_release_cgrid_range(cgrid[0], num_rx_fqs);

That deletes CGRs that still have members, which the commit message says must not happen, and hands the CGRIDs to the next probe while live FQs reference them. Shut down the FQs initialised so far before deleting the CGRs.

dev_close() releases the CGRID range unconditionally, even when dpaa_cgr_stale_fq_cleanup() hit an FQ that would not shut down or qman_delete_cgr() failed. 1/3 deliberately leaks FQIDs in that case; do the same here and skip qman_release_cgrid_range() if any delete or shutdown failed.

dpaa_eth_dev_stop() and dpaa_eth_dev_close() never shut down the port's own Rx/Tx FQs, so the FQs dpaa_cgr_stale_fq_cleanup() finds at close are this port's live queues, not ones "not cleaned in previous program". The driver already holds their FQIDs. Shut them down directly before deleting the CGRs, drop the FQID space scan, and with it the new qman_pending_fq_by_cgrid_range() export:

	for (loop = 0; loop < dpaa_intf->nb_rx_queues; loop++)
		qman_shutdown_fq(&dpaa_intf->rx_queues[loop]);
	for (loop = 0; loop < MAX_DPAA_CORES; loop++)
		qman_shutdown_fq(&dpaa_intf->tx_queues[loop]);

The existing "Release congestion Groups after releasing FQIDs" comment is then true.

Info

cgrid is u32; use %u, not %d, in the DPAA_PMD_DEBUG/WARN calls.

#5 lore raw

Hi,

NXP Confidential

Quoted 49 lines

-----Original Message-----
From: Stephen Hemminger <[email protected]>
Sent: Wednesday, October 28, 2026 8:11 PM
To: Gagandeep Singh <[email protected]>
Cc: [email protected]; Hemant Agrawal <[email protected]>
Subject: Re: [PATCH v1 0/3] DPAA driver changes

Quoted 29 lines · On Wed, 28 Oct 2026 14:25:14 +0530 Gagandeep Singh <[email protected]> wrote:

- Adding OH port support.
- Updates in shared ethernet code.
- Congestion related code cleanup.

Gagandeep Singh (1):
drivers: add offline (O/H) port device support

Hemant Agrawal (1):
net/dpaa: support non fmX-macY type of shared Ethernet name

Jun Yang (1):
drivers: add DPAA cgrid cleanup support

 doc/api/doxy-api-index.md                |   1 +
 doc/guides/nics/dpaa.rst                 |  32 +
 drivers/bus/dpaa/base/fman/fman.c        |  19 +
 drivers/bus/dpaa/base/qbman/qman.c       |  61 ++
 drivers/bus/dpaa/bus_dpaa_driver.h       |   4 +-
 drivers/bus/dpaa/dpaa_bus.c              | 100 ++-
 drivers/bus/dpaa/dpaa_bus_base_symbols.c |   2 +
 drivers/bus/dpaa/include/fman.h          |   6 +-
 drivers/bus/dpaa/include/fsl_qman.h      |  28 +
 drivers/net/dpaa/dpaa_ethdev.c           | 176 ++++-
 drivers/net/dpaa/dpaa_ethdev.h           |   3 +
 drivers/net/dpaa/dpaa_flow.c             |   7 +-
 drivers/net/dpaa/dpaa_oldev.c            | 875 +++++++++++++++++++++++
 drivers/net/dpaa/meson.build             |  11 +-
 drivers/net/dpaa/rte_pmd_dpaa_oldev.h    | 158 ++++
 15 files changed, 1454 insertions(+), 29 deletions(-)  create mode
Quoted 1 line

100644 drivers/net/dpaa/dpaa_oldev.c create

AI review found issues. The biggest one is carrying vendor private ioctl data structures in DPDK.

Review of [PATCH v1 0/3] DPAA offline port, shared MAC, cgrid cleanup

Series
------

Quoted 8 lines

The rte_pmd_dpaa_ol_* functions do not operate on a DPDK port. They take no port_id and only forward a caller-filled struct to an out-of-tree kernel driver through ioctl() on /dev/cdx_ctrl. That puts a vendor kernel ioctl ABI (GTP classification, "telecom application"
flags) into an installed DPDK header under DPDK API/ABI rules. An application can issue these ioctls itself; this belongs in the vendor userspace library for that kernel module, not in DPDK. Please drop rte_pmd_dpaa_oldev.h and the four exported functions.

To clarify the design intent: the DPAA offline (OL) port is one half of a split-driver model. The other half is the ASK/CDX kernel module, which is part of the NXP SDK and is released together with this PMD. The OL port's Rx/Tx path runs entirely in DPDK via QMan FQs, but the classification policy deciding which GTP/IP traffic is steered to the DPDK fast path versus handled by the kernel module is configured through ASK/CDX, since that module owns the control-plane side of this split.

rte_pmd_dpaa_ol_set_classif_info(), _reset_classif_info(), _set_lgw_info(), and _reset_lgw_info() are the configuration contract for this specific, co-developed kernel module — not a generic ioctl-wrapping convenience API. The structs mirror the ASK/CDX kernel ABI by necessity, since that is the data being configured for this shared interface. So We'd like to keep these APIs in-tree as they are required for the OL port feature.

Quoted 156 lines

The drv_oldev bus argument is redundant. The offline port is only probed if "-a dpaa_bus:oldev1" is given anyway, so create the oldev1 device when its devargs exist and drop drv_oldev, the bus_str parsing, and the allowlist caveats in dpaa.rst:

      if (rte_bus_find_devargs(&rte_dpaa_bus, "oldev1") != NULL) {
              /* create oldev1 */
      }

No release notes for the new port type. dpaa.rst does not say the offline port needs the /dev/cdx_ctrl kernel driver or where to get it.

Patch 1/3 drivers: add offline (O/H) port device support
--------------------------------------------------------

Error

dpaa_oldev_init() never sets tx_queues[0].dpaa_intf, and the queue array comes from rte_zmalloc(), so it is NULL. dpaa_eth_queue_tx() starts with:

      struct dpaa_if *dpaa_intf = fq->dpaa_intf;
      ...
      if (unlikely(dpaa_intf->ts_enable)) {

so the first Tx burst after dev_start dereferences NULL. Set it after the Tx FQ is initialised:

      ret = dpaa_ol_tx_queue_init(&dpaa_intf->tx_queues[0], 0);
      if (ret)
              goto free_rx;
      dpaa_intf->tx_queues[0].dpaa_intf = dpaa_intf;

Warning

rte_kvargs_count() only tests for presence, so "drv_oldev=0" enables the offline port. Moot if drv_oldev is removed as above; otherwise parse the value with rte_kvargs_process().

dev_close() shuts down the Rx/Tx FQs and returns their FQIDs to the allocator, but the kernel was given those FQIDs and the bpid through ASK_CTRL_SET_DPDK_INFO and is never told they are gone. The next qman_alloc_fqid() user can receive frames the kernel enqueues to a reused FQID. The kernel side needs a reset ioctl issued before the FQIDs are released.

The cell-index range checks in fman_if_init() and fman_if_init_onic() fix an out-of- bounds read of mac_idx[] and have nothing to do with the offline port. The commit message does not mention them, nor the MEMMAC_REG_OFFSET removal. Split the bounds checks into their own patch
with:

Fixes a0edbb8a8e52 ("bus/dpaa: add OH port mode")
Fixes 7e5f49ae767d ("bus/dpaa: add ONIC port mode")

drv_bh_port is required, but it is parsed on every dev_start() with a NULL key list, so a misspelled key is accepted at probe and the port only fails at start. Parse it once in dpaa_ol_probe() with a valid key list, store it in the private data, and fail probe if it is missing.

If rte_pmd_dpaa_oldev.h stays, the installed header defines DPA_ISC_*, DPDK_OLDEV_*, DPDK_CLASSIF_*, DPDK_TELECOM_* and struct dpa_* without an RTE_/rte_ prefix, and none of the structs or fields have Doxygen.

Info

dpaa_ol_rx_queue_setup() checks queue_idx against nb_rx_queues; ethdev already does that before calling the PMD.

open(ASK_PATH, O_RDWR) should use O_RDWR | O_CLOEXEC.

In dpaa_create_device_list(), use snprintf() rather than sprintf(), and drop the memset() after calloc() and the "int i = 0" initialiser.

rte_dpaa_bus_dev_build() gates the num_ethports messages on oldev_enabled; the condition that matters is dpaa_netcfg != NULL.

The dpaa_bus_parse_bus_args() comment refers to a previous environment- variable configuration that never existed upstream. The bh_port_name field comment says "for testing purpose" but the field is mandatory.

Patch 2/3 net/dpaa: support non fmX-macY type of shared Ethernet name
---------------------------------------------------------------------

Warning

Platform devices created from device-tree nodes without a reg property are named after the whole parent chain, which is why dpaa_bus.c uses "/sys/devices/platform/soc/soc:fsl,dpaa". A dpa-ethernet child of that node is not "ethernet@N" under /sys/bus/platform/devices, so

      node = strrchr(node_path, '/');
      ...
      "/sys/bus/platform/devices/%s/net", node

misses and silently falls back to the port name, which is the case the patch is meant to fix. Match on the netdev's of_node instead:

      /* for each /sys/class/net/<if> */
      snprintf(path, sizeof(path), "/sys/class/net/%s/device/of_node",
               ifname);
      if (realpath(path, resolved) != NULL &&
          strcmp(resolved + strlen("/sys/firmware/devicetree/base"),
                 node_path) == 0)
              /* found */

Info

The new dpaa.rst bullet lands at the end of the bus devargs block; it belongs with the shared MAC description.

Patch 3/3 drivers: add DPAA cgrid cleanup support
-------------------------------------------------

Warning

This fixes a CGRID leak on close and a stale portal list entry on probe failure, but has no Fixes: tag or stable Cc:

Fixes 62f53995caaf ("net/dpaa: add frame count based tail drop with

CGR")

Fixes 9124e65dd3eb ("net/dpaa: enable Tx queue taildrop")

On the probe error path the initialised Rx FQs (and Tx FQs on free_tx) were scheduled with QM_FQCTRL_CGE and their cgid, and are never shut down before

      for (loop = 0; loop < nb_rx_cgr; loop++)
              qman_delete_cgr(&dpaa_intf->cgr_rx[loop]);
      if (rx_cgrid_allocated)
              qman_release_cgrid_range(cgrid[0], num_rx_fqs);

That deletes CGRs that still have members, which the commit message says must not happen, and hands the CGRIDs to the next probe while live FQs reference them. Shut down the FQs initialised so far before deleting the CGRs.

dev_close() releases the CGRID range unconditionally, even when dpaa_cgr_stale_fq_cleanup() hit an FQ that would not shut down or qman_delete_cgr() failed. 1/3 deliberately leaks FQIDs in that case; do the same here and skip qman_release_cgrid_range() if any delete or shutdown failed.

dpaa_eth_dev_stop() and dpaa_eth_dev_close() never shut down the port's own Rx/Tx FQs, so the FQs dpaa_cgr_stale_fq_cleanup() finds at close are this port's live queues, not ones "not cleaned in previous program". The driver already holds their FQIDs. Shut them down directly before deleting the CGRs, drop the FQID space scan, and with it the new
qman_pending_fq_by_cgrid_range() export:

      for (loop = 0; loop < dpaa_intf->nb_rx_queues; loop++)
              qman_shutdown_fq(&dpaa_intf->rx_queues[loop]);
      for (loop = 0; loop < MAX_DPAA_CORES; loop++)
              qman_shutdown_fq(&dpaa_intf->tx_queues[loop]);
Quoted 6 lines

The existing "Release congestion Groups after releasing FQIDs" comment is then true.

Info

cgrid is u32; use %u, not %d, in the DPAA_PMD_DEBUG/WARN calls.

All AI comments are handled in V2.

#6 lore raw

v2 cover DPAA driver changes

In reply to Gagandeep Singh

V2-changes:
- Fixed most of the AI comments.
- added new patch:
fix out-of-bounds read of mac_idx
- removed drv_oldev, updated comments and notes.
- fixes FQ shutdown
- removed unwanted checks, updated open, updated snprintf.
- updated commit messages.

V1:
- Adding OH port support.
- Updates in shared ethernet code.
- Congestion related code cleanup.

Gagandeep Singh (2):
bus/dpaa: fix out-of-bounds read of mac_idx array
drivers: add offline (O/H) port device support

Hemant Agrawal (1):
net/dpaa: support non fmX-macY type of shared Ethernet name

Jun Yang (1):
drivers: add DPAA cgrid cleanup support

 doc/api/doxy-api-index.md                |   1 +
 doc/guides/nics/dpaa.rst                 |  35 +
 drivers/bus/dpaa/base/fman/fman.c        |  19 +
 drivers/bus/dpaa/base/qbman/qman.c       |  61 ++
 drivers/bus/dpaa/bus_dpaa_driver.h       |   4 +-
 drivers/bus/dpaa/dpaa_bus.c              |  66 +-
 drivers/bus/dpaa/dpaa_bus_base_symbols.c |   2 +
 drivers/bus/dpaa/include/fman.h          |   6 +-
 drivers/bus/dpaa/include/fsl_qman.h      |  28 +
 drivers/net/dpaa/dpaa_ethdev.c           | 241 ++++++-
 drivers/net/dpaa/dpaa_ethdev.h           |   3 +
 drivers/net/dpaa/dpaa_flow.c             |   7 +-
 drivers/net/dpaa/dpaa_oldev.c            | 875 +++++++++++++++++++++++
 drivers/net/dpaa/meson.build             |  11 +-
 drivers/net/dpaa/rte_pmd_dpaa_oldev.h    | 188 +++++
 15 files changed, 1517 insertions(+), 30 deletions(-)
 create mode 100644 drivers/net/dpaa/dpaa_oldev.c
 create mode 100644 drivers/net/dpaa/rte_pmd_dpaa_oldev.h
Signature · 1 line
2.25.1
#7 lore raw

PATCH v2 1/4 bus/dpaa: fix out-of-bounds read of mac_idx array

fman_if_init() and fman_if_init_onic() read the devicetree 'cell-index' property and store it unchecked into __if->__if.mac_idx. This value is later used as an index into the fixed-size mac_idx[] lookup table in fman_if_vsp_init(), so a cell-index value greater than or equal to the number of entries in that table results in an out-of-bounds read.

Add an explicit upper-bound check (FMAN_MAX_MAC_IDX_NUM) in both fman_if_init() and fman_if_init_onic() before the mac_idx assignment, and a static_assert in fman_if_vsp_init() to keep mac_idx[] in sync with FMAN_MAX_MAC_IDX_NUM if it is ever resized.

Fixes a0edbb8a8e52 ("bus/dpaa: add OH port mode")
Fixes 7e5f49ae767d ("bus/dpaa: add ONIC port mode")
---
 drivers/bus/dpaa/base/fman/fman.c | 19 +++++++++++++++++++
 drivers/bus/dpaa/include/fman.h   |  5 +++++
 2 files changed, 24 insertions(+)
drivers/bus/dpaa/base/fman/fman.c +19 -0
index 67f77265ca..223cd6958d 100644
@@ -205,6 +205,9 @@ static void fman_if_vsp_init(struct __fman_if *__if)
 	size_t lenp;
 	const uint8_t mac_idx[] = {-1, 0, 1, 2, 3, 4, 5, 6, 7, 0, 1};
 
+	static_assert(RTE_DIM(mac_idx) == FMAN_MAX_MAC_IDX_NUM,
+		      "mac_idx[] out of sync with FMAN_MAX_MAC_IDX_NUM");
+
 	if (__if->__if.mac_idx <= 8) {
 		for_each_compatible_node(dev, NULL,
 			"fsl,fman-port-1g-rx-extended-args") {
@@ -544,6 +547,14 @@ fman_if_init(const struct device_node *dpa_node, int fd)
 		cell_idx_host = of_read_number(cell_idx,
 					       lenp / sizeof(phandle));
 
+		if (cell_idx_host >= FMAN_MAX_MAC_IDX_NUM) {
+			FMAN_ERR(-EINVAL,
+				 "%s: cell-index(%" PRIu64 ") >= max(%d)",
+				 oh_node->full_name, cell_idx_host,
+				 FMAN_MAX_MAC_IDX_NUM);
+			goto err;
+		}
+
 		__if->__if.mac_idx = cell_idx_host;
 	}
 
@@ -957,6 +968,14 @@ static int fman_if_init_onic(const struct device_node *dpa_node)
 	assert(lenp == sizeof(*cell_idx));
 
 	cell_idx_host = of_read_number(cell_idx, lenp / sizeof(phandle));
+
+	if (cell_idx_host >= FMAN_MAX_MAC_IDX_NUM) {
+		FMAN_ERR(-EINVAL, "%s: cell-index(%" PRIu64 ") >= max(%d)",
+			 tx_oh_node->full_name, cell_idx_host,
+			 FMAN_MAX_MAC_IDX_NUM);
+		goto err;
+	}
+
 	__if->__if.mac_idx = cell_idx_host;
 
 	fman_node = of_get_parent(fman_tx_oh_node);
drivers/bus/dpaa/include/fman.h +5 -0
index f642faf3b3..f499f9ebbf 100644
@@ -68,6 +68,11 @@
 #define FMAN_RTC_MAX_NUM_OF_PERIODIC_PULSES	4
 #define FMAN_RTC_MAX_NUM_OF_EXT_TRIGGERS	3
 
+/*
+ * Maximum number of MAC/offline port indexes.
+ */
+#define FMAN_MAX_MAC_IDX_NUM	11
+
 /* Represents the different flavour of network interface */
 enum fman_mac_type {
 	fman_offline_internal = 0,
Signature · 1 line
2.25.1
#8 lore raw

PATCH v2 2/4 drivers: add offline (O/H) port device support

In reply to Gagandeep Singh

Add support for the DPAA Offline/Host-command (O/H) port, allowing a single OL port to be used by a DPDK application. The feature is selected through the 'drv_oldev' bus device argument, and the associated back-half port is named through the 'drv_bh_port' device argument.

---
 doc/api/doxy-api-index.md                |   1 +
 doc/guides/nics/dpaa.rst                 |  31 +
 drivers/bus/dpaa/bus_dpaa_driver.h       |   4 +-
 drivers/bus/dpaa/dpaa_bus.c              |  66 +-
 drivers/bus/dpaa/dpaa_bus_base_symbols.c |   1 +
 drivers/bus/dpaa/include/fman.h          |   1 -
 drivers/bus/dpaa/include/fsl_qman.h      |   1 +
 drivers/net/dpaa/dpaa_ethdev.h           |   3 +
 drivers/net/dpaa/dpaa_flow.c             |   7 +-
 drivers/net/dpaa/dpaa_oldev.c            | 875 +++++++++++++++++++++++
 drivers/net/dpaa/meson.build             |  11 +-
 drivers/net/dpaa/rte_pmd_dpaa_oldev.h    | 188 +++++
 12 files changed, 1172 insertions(+), 17 deletions(-)
 create mode 100644 drivers/net/dpaa/dpaa_oldev.c
 create mode 100644 drivers/net/dpaa/rte_pmd_dpaa_oldev.h
doc/api/doxy-api-index.md +1 -0
index 62390f7be3..0bd8e1bbf0 100644
@@ -53,6 +53,7 @@ The public API headers are grouped by topics:
   [cnxk_eventdev](@ref rte_pmd_cnxk_eventdev.h),
   [cnxk_mempool](@ref rte_pmd_cnxk_mempool.h),
   [dpaa](@ref rte_pmd_dpaa.h),
+  [dpaa_oldev](@ref rte_pmd_dpaa_oldev.h),
   [dpaa2](@ref rte_pmd_dpaa2.h),
   [mlx5](@ref rte_pmd_mlx5.h),
   [dpaa2_mempool](@ref rte_dpaa2_mempool.h),
doc/guides/nics/dpaa.rst +31 -0
index c6aab46828..21f54bcd36 100644
@@ -276,6 +276,37 @@ Refer to the document :doc:`build_and_test` for details.
   and thus disabling hardware based packet handling at driver level,
   e.g. ``dpaa:fm1-mac3,recv_err_pkts=1``.
 
+``drv_bh_port``
+   Name of the back-half port associated with an offline (O/H) port device.
+   It is passed on the offline port device itself, which is named
+   ``oldev1``, e.g. ``-a dpaa_bus:oldev1,drv_bh_port=fm1-mac5``.
+
+The DPAA offline (O/H) port device is only created, and therefore only
+probed, when it is explicitly named on the EAL ``-a`` command line, e.g.::
+
+   -a dpaa_bus:oldev1,drv_bh_port=fm1-mac5
+
+Passing any ``-a`` argument for the DPAA bus switches the bus to allowlist
+scan mode, so from that point on only the devices named with ``-a`` are
+probed. Using the offline port therefore requires listing the offline port
+itself and every Ethernet port the application needs, for example::
+
+   -a dpaa_bus:oldev1,drv_bh_port=fm1-mac5 \
+   -a dpaa_bus:fm1-mac5 -a dpaa_bus:fm1-mac6
+
+Omitting an ``fmX-macY`` port in that case silently drops that port.
+
+The offline port requires the ``/dev/cdx_ctrl`` kernel control device to be
+present; it is provided by the NXP vendor ``cdx`` kernel driver, which is
+not part of this DPDK driver and must be obtained and loaded separately
+(see the NXP LSDK release matching the DPAA SoC family). The uplink
+classification and local-gateway (LGW) configuration exposed through that
+control device can be programmed by the application via the experimental
+``rte_pmd_dpaa_ol_set_classif_info()``, ``rte_pmd_dpaa_ol_reset_classif_info()``,
+``rte_pmd_dpaa_ol_set_lgw_info()`` and ``rte_pmd_dpaa_ol_reset_lgw_info()``
+APIs declared in ``rte_pmd_dpaa_oldev.h``.
+
+
 FMAN Config
 -----------
 
drivers/bus/dpaa/bus_dpaa_driver.h +3 -1
index 4aed83f84d..323a6a7659 100644
@@ -69,11 +69,13 @@ struct rte_dpaa_driver;
 enum rte_dpaa_type {
 	FSL_DPAA_ETH = 1,
 	FSL_DPAA_CRYPTO,
-	FSL_DPAA_QDMA
+	FSL_DPAA_QDMA,
+	FSL_DPAA_OL
 };
 
 struct dpaa_device_id {
 	uint8_t fman_id; /**< Fman interface ID, for ETH type device */
+	uint8_t ol_id;	/**< OH interface ID, for OH type device */
 	uint8_t mac_id; /**< Fman MAC interface ID, for ETH type device */
 	uint16_t dev_id; /**< Device Identifier from DPDK */
 };
drivers/bus/dpaa/dpaa_bus.c +57 -9

129 lines not on this page · raw message

drivers/bus/dpaa/dpaa_bus_base_symbols.c +1 -0
index 0927e5fe2c..aaa9f9bec2 100644
@@ -52,6 +52,7 @@ RTE_EXPORT_INTERNAL_SYMBOL(bman_acquire)
 RTE_EXPORT_INTERNAL_SYMBOL(bman_query_free_buffers)
 RTE_EXPORT_INTERNAL_SYMBOL(bman_thread_irq)
 RTE_EXPORT_INTERNAL_SYMBOL(qman_alloc_fqid_range)
+RTE_EXPORT_INTERNAL_SYMBOL(qman_release_fqid_range)
 RTE_EXPORT_INTERNAL_SYMBOL(qman_reserve_fqid_range)
 RTE_EXPORT_INTERNAL_SYMBOL(qman_alloc_pool_range)
 RTE_EXPORT_INTERNAL_SYMBOL(qman_alloc_cgrid_range)
drivers/bus/dpaa/include/fman.h +0 -1
index f499f9ebbf..030c85c284 100644
@@ -480,7 +480,6 @@ struct __fman_if {
 	void *qmi_map;
 };
 
-#define MEMMAC_REG_OFFSET(reg) offsetof(struct memac_regs, reg)
 #define BMI_RX_REG_OFFSET(reg) offsetof(struct rx_bmi_regs, reg)
 #define BMI_TX_REG_OFFSET(reg) offsetof(struct tx_bmi_regs, reg)
 
drivers/bus/dpaa/include/fsl_qman.h +1 -0
index 59b41e17f0..b2674ce5d0 100644
@@ -1895,6 +1895,7 @@ static inline int qman_alloc_fqid(u32 *result)
  * This function can also be used to seed the allocator with ranges of FQIDs
  * that it can subsequently allocate from.
  */
+__rte_internal
 void qman_release_fqid_range(u32 fqid, unsigned int count);
 static inline void qman_release_fqid(u32 fqid)
 {
drivers/net/dpaa/dpaa_ethdev.h +3 -0
index 47c8e2b086..7e70bf2ad2 100644
@@ -114,6 +114,9 @@ enum {
 
 #define DPAA_DEFAULT_RXQ_VSP_ID		1
 
+/* Device argument to name the offline (O/H) port back-half port */
+#define DRIVER_OL_BH_PORT		"drv_bh_port"
+
 #define FMC_FILE "/tmp/fmc.bin"
 
 struct dpaa_if_vsp {
drivers/net/dpaa/dpaa_flow.c +6 -1
index f77f9f333b..6c519ec975 100644
@@ -32,9 +32,14 @@ return &scheme_params->param.key_ext_and_hash.extract_array[hdr_idx];
 	SCH_EXT_HDR(scheme_params, hdr_idx).extract_by_hdr_type.full_field
 
 /* FMAN mac indexes mappings (0 is unused, first 8 are for 1G, next for 10G
- * ports).
+ * ports). Indexed by fman_if.mac_idx, which the bus validates against
+ * FMAN_MAX_MAC_IDX_NUM when deriving it from the device tree.
  */
 static const uint8_t mac_idx[] = {-1, 0, 1, 2, 3, 4, 5, 6, 7, 0, 1};
+static_assert(RTE_DIM(mac_idx) == FMAN_MAX_MAC_IDX_NUM,
+	"mac_idx[] out of sync with FMAN_MAX_MAC_IDX_NUM");
+
+
 
 /* FM global info */
 struct dpaa_fm_info {
drivers/net/dpaa/dpaa_oldev.c new file +875 -0

875 lines not on this page · raw message

drivers/net/dpaa/meson.build +6 -5
index 8d4f69c596..3ec1091197 100644
@@ -1,5 +1,5 @@
 # SPDX-License-Identifier: BSD-3-Clause
-# Copyright 2018-2020 NXP
+# Copyright 2018-2020,2026 NXP
 
 if not is_linux
     build = false
@@ -9,12 +9,13 @@ deps += ['mempool_dpaa']
 
 sources = files(
         'dpaa_ethdev.c',
-        'fmlib/fm_lib.c',
-        'fmlib/fm_vsp.c',
         'dpaa_flow.c',
-        'dpaa_rxtx.c',
         'dpaa_fmc.c',
         'dpaa_ptp.c',
+        'dpaa_oldev.c',
+        'dpaa_rxtx.c',
+        'fmlib/fm_lib.c',
+        'fmlib/fm_vsp.c',
 )
 
 cflags += no_wvla_cflag
@@ -24,4 +25,4 @@ if cc.has_argument('-Wno-pointer-arith')
     cflags += '-Wno-pointer-arith'
 endif
 
-headers = files('rte_pmd_dpaa.h')
+headers = files('rte_pmd_dpaa.h', 'rte_pmd_dpaa_oldev.h')
drivers/net/dpaa/rte_pmd_dpaa_oldev.h new file +188 -0

188 lines not on this page · raw message

Signature · 1 line
2.25.1
#9 lore raw

PATCH v2 3/4 net/dpaa: support non fmX-macY type of shared Ethernet name

In reply to Gagandeep Singh

From: Hemant Agrawal <[email protected]>

A shared MAC interface needs the kernel netdev name to read the MTU, and that name is only the DPDK port name for fmX-macY style netdevs.

Look it up in sysfs under the platform device of the dpa-ethernet node the port was created from, and fall back to the port name.

---
 doc/guides/nics/dpaa.rst       |  6 ++-
 drivers/net/dpaa/dpaa_ethdev.c | 68 +++++++++++++++++++++++++++++++++-
 2 files changed, 72 insertions(+), 2 deletions(-)
doc/guides/nics/dpaa.rst +5 -1
index 21f54bcd36..2094abf417 100644
@@ -276,6 +276,11 @@ Refer to the document :doc:`build_and_test` for details.
   and thus disabling hardware based packet handling at driver level,
   e.g. ``dpaa:fm1-mac3,recv_err_pkts=1``.
 
+* For a shared MAC interface the kernel network interface name is looked up
+  in sysfs from the device tree node the port was created from,
+  so a kernel interface that does not follow
+  the ``fmX-macY`` naming style is handled without extra configuration.
+
 ``drv_bh_port``
    Name of the back-half port associated with an offline (O/H) port device.
    It is passed on the offline port device itself, which is named
@@ -306,7 +311,6 @@ control device can be programmed by the application via the experimental
 ``rte_pmd_dpaa_ol_set_lgw_info()`` and ``rte_pmd_dpaa_ol_reset_lgw_info()``
 APIs declared in ``rte_pmd_dpaa_oldev.h``.
 
-
 FMAN Config
 -----------
 
drivers/net/dpaa/dpaa_ethdev.c +67 -1

98 lines not on this page · raw message

Signature · 1 line
2.25.1
#10 lore raw

PATCH v2 4/4 drivers: add DPAA cgrid cleanup support

In reply to Gagandeep Singh

From: Jun Yang <[email protected]>

A congestion group must have no member frame queues left when it is deleted, and its CGRID must be returned to the allocator once the group is gone. Neither was handled on the net/dpaa close and probe-failure paths.

This also changes probe behaviour: a qman_create_cgr() failure in dpaa_rx_queue_init() or dpaa_tx_queue_init() now fails the probe instead of continuing without tail drop on that queue. The probe error path deletes one CGR per initialised queue, and a CGR whose creation failed was never linked into the portal list.

Fixes 62f53995caaf ("net/dpaa: add frame count based tail drop with CGR")
Fixes 9124e65dd3eb ("net/dpaa: enable Tx queue taildrop")
---
 drivers/bus/dpaa/base/qbman/qman.c       |  61 ++++++++
 drivers/bus/dpaa/dpaa_bus_base_symbols.c |   1 +
 drivers/bus/dpaa/include/fsl_qman.h      |  27 ++++
 drivers/net/dpaa/dpaa_ethdev.c           | 173 +++++++++++++++++++++--
 4 files changed, 250 insertions(+), 12 deletions(-)
drivers/bus/dpaa/base/qbman/qman.c +61 -0
index 3c056e4547..fa3387c6bd 100644
@@ -2993,3 +2993,64 @@ qman_shutdown_fq(struct qman_fq *fq)
 out:
 	return ret;
 }
+
+int qman_pending_fq_by_cgrid_range(u32 cgrid_start, u32 cgrid_num,
+	u32 start_fqid, u32 *fqid, u32 *cgrid)
+{
+	struct qman_fq fq = {
+		.fqid = start_fqid ? start_fqid : 1
+	};
+	struct qm_mcr_queryfq_np np;
+	struct qm_fqd fqd;
+	int err;
+
+	/*
+	 * Do not use the CGR byte count to decide whether to scan. An FQ is a
+	 * member of the group whenever it is scheduled with CGE set and a
+	 * matching cgid, whether or not it currently holds any frames, and the
+	 * group cannot be deleted while such a member exists. Skipping the
+	 * scan for an empty CGR would let an idle stale FQ survive and its
+	 * CGRID be released while still referenced. This runs from the device
+	 * close path only, so the scan cost is acceptable.
+	 *
+	 * The whole CGRID range of a port is matched in a single pass, so a
+	 * port with many congestion groups does not need one full FQID space
+	 * scan per group.
+	 */
+	DPAA_BUS_DEBUG("Scanning FQs for cgrid(0x%x..0x%x)",
+		cgrid_start, cgrid_start + cgrid_num - 1);
+
+	/* FQID space is 24 bits wide; stop before wrapping. */
+	for (; fq.fqid <= QMAN_MAX_FQID; fq.fqid++) {
+		err = qman_query_fq_np(&fq, &np);
+		if (err == -ERANGE) {
+			/*
+			 * FQID is not implemented on this device, so there is
+			 * nothing beyond it either.
+			 */
+			break;
+		} else if (err) {
+			DPAA_BUS_WARN("Failed(%d) to Query np FQ(fqid=0x%x)",
+				err, fq.fqid);
+			return err;
+		}
+		if ((np.state & QM_MCR_NP_STATE_MASK) != QM_MCR_NP_STATE_OOS) {
+			err = qman_query_fq(&fq, &fqd);
+			if (err) {
+				DPAA_BUS_WARN("Failed(%d) to Query FQ(fqid=0x%x)",
+					err, fq.fqid);
+			} else if ((fqd.fq_ctrl & QM_FQCTRL_CGE) &&
+				fqd.cgid >= cgrid_start &&
+				fqd.cgid < cgrid_start + cgrid_num) {
+				if (fqid)
+					*fqid = fq.fqid;
+				if (cgrid)
+					*cgrid = fqd.cgid;
+				return 0;
+			}
+		}
+	}
+	DPAA_BUS_DEBUG("No FQ left in cgrid(0x%x..0x%x)",
+		cgrid_start, cgrid_start + cgrid_num - 1);
+	return -ERANGE;
+}
drivers/bus/dpaa/dpaa_bus_base_symbols.c +1 -0
index aaa9f9bec2..4da43f293d 100644
@@ -57,6 +57,7 @@ RTE_EXPORT_INTERNAL_SYMBOL(qman_reserve_fqid_range)
 RTE_EXPORT_INTERNAL_SYMBOL(qman_alloc_pool_range)
 RTE_EXPORT_INTERNAL_SYMBOL(qman_alloc_cgrid_range)
 RTE_EXPORT_INTERNAL_SYMBOL(qman_release_cgrid_range)
+RTE_EXPORT_INTERNAL_SYMBOL(qman_pending_fq_by_cgrid_range)
 RTE_EXPORT_INTERNAL_SYMBOL(dpaa_intr_enable)
 RTE_EXPORT_INTERNAL_SYMBOL(dpaa_intr_disable)
 RTE_EXPORT_INTERNAL_SYMBOL(dpaa_get_ioctl_version_number)
drivers/bus/dpaa/include/fsl_qman.h +27 -0
index b2674ce5d0..6d76722275 100644
@@ -1284,6 +1284,9 @@ struct qman_cgr {
  */
 #define QMAN_FQRN_WAIT_MAX		10000000u
 
+/* Maximum FQID value: frame queue IDs are 24 bits wide. */
+#define QMAN_MAX_FQID			0x00FFFFFFu
+
 /* Flags to qman_create_fq() */
 #define QMAN_FQ_FLAG_NO_ENQUEUE      0x00000001 /* can't enqueue */
 #define QMAN_FQ_FLAG_NO_MODIFY       0x00000002 /* can only enqueue */
@@ -1916,6 +1919,30 @@ static inline int qman_shutdown_fq_by_fqid(u32 fqid)
 	return qman_shutdown_fq(&fq);
 }
 
+/**
+ * qman_pending_fq_by_cgrid_range - Find an FQ still attached to a CGR range.
+ *
+ * @cgrid_start: first congestion group id of the range to search for.
+ * @cgrid_num: number of consecutive congestion group ids in the range.
+ * @start_fqid: FQID to begin the scan from (0 or 1 means scan from the
+ *   start). A caller shutting down several stale FQs can pass the previously
+ *   returned FQID + 1 to resume the scan instead of restarting from the
+ *   beginning each time.
+ * @fqid: on success, holds the FQID that is still attached to the range.
+ * @cgrid: on success, holds the congestion group id that FQ belongs to.
+ *   May be NULL.
+ *
+ * Matching a whole range in one pass lets a caller with many congestion
+ * groups, such as a port releasing all of its Rx or Tx CGRs, avoid one full
+ * FQID space scan per group.
+ *
+ * Return 0 and set *fqid when a matching FQ is found, -ERANGE when none is
+ * left, or a negative error code on query failure.
+ */
+__rte_internal
+int qman_pending_fq_by_cgrid_range(u32 cgrid_start, u32 cgrid_num,
+		u32 start_fqid, u32 *fqid, u32 *cgrid);
+
 /**
  * qman_reserve_fqid_range - Reserve the specified range of frame queue IDs
  * @fqid: the base FQID of the range to deallocate
drivers/net/dpaa/dpaa_ethdev.c +161 -12

294 lines not on this page · raw message

Signature · 1 line
2.25.1
#11 lore raw
In reply to Gagandeep Singh
Quoted 34 lines · On Fri, 30 Oct 2026 10:13:14 +0530 Gagandeep Singh <[email protected]> wrote:

V2-changes:
- Fixed most of the AI comments.
- added new patch:
fix out-of-bounds read of mac_idx
- removed drv_oldev, updated comments and notes.
- fixes FQ shutdown
- removed unwanted checks, updated open, updated snprintf.
- updated commit messages.

V1:
- Adding OH port support.
- Updates in shared ethernet code.
- Congestion related code cleanup.

Gagandeep Singh (2):
bus/dpaa: fix out-of-bounds read of mac_idx array
drivers: add offline (O/H) port device support

Hemant Agrawal (1):
net/dpaa: support non fmX-macY type of shared Ethernet name

Jun Yang (1):
drivers: add DPAA cgrid cleanup support

 doc/api/doxy-api-index.md                |   1 +
 doc/guides/nics/dpaa.rst                 |  35 +
 drivers/bus/dpaa/base/fman/fman.c        |  19 +
 drivers/bus/dpaa/base/qbman/qman.c       |  61 ++
 drivers/bus/dpaa/bus_dpaa_driver.h       |   4 +-
 drivers/bus/dpaa/dpaa_bus.c              |  66 +-
 drivers/bus/dpaa/dpaa_bus_base_symbols.c |   2 +
 drivers/bus/dpaa/include/fman.h          |   6 +-
 drivers/bus/dpaa/include/fsl_qman.h      |  28 +
 drivers/net/dpaa/dpaa_ethdev.c           | 241 ++++++-
Quoted 9 lines
 drivers/net/dpaa/dpaa_ethdev.h           |   3 +
 drivers/net/dpaa/dpaa_flow.c             |   7 +-
 drivers/net/dpaa/dpaa_oldev.c            | 875 +++++++++++++++++++++++
 drivers/net/dpaa/meson.build             |  11 +-
 drivers/net/dpaa/rte_pmd_dpaa_oldev.h    | 188 +++++
 15 files changed, 1517 insertions(+), 30 deletions(-)
 create mode 100644 drivers/net/dpaa/dpaa_oldev.c
 create mode 100644 drivers/net/dpaa/rte_pmd_dpaa_oldev.h

Manually run AI review still sees issues that need addessing

Review of [PATCH v2 0/4] DPAA offline port, shared MAC, cgrid cleanup

Applied to next-net for-main (3b51e2e2f0). Each commit builds with -Dwerror=true.

Series
------

The rte_pmd_dpaa_ol_* API is unchanged from v1 apart from renames and Doxygen. The four functions still take no port_id and only pass a caller-filled struct to ioctl() on the out-of-tree /dev/cdx_ctrl driver. The dpaa.rst text added in v2 confirms the API is configuration for that kernel module, not for the DPDK port. It belongs in the vendor userspace library for cdx. Please drop rte_pmd_dpaa_oldev.h and the exports.

There are still no release notes for the offline port.

Patch 2/4 drivers: add offline (O/H) port device support
--------------------------------------------------------

Warning

The commit message still says the port is "selected through the 'drv_oldev' bus device argument". v2 removed drv_oldev; the port is created when "-a dpaa_bus:oldev1" is given.

With only oldev1 present, dpaa_netcfg is NULL. v2 handles that in the two log statements but not in the debug dump:

	#ifdef RTE_LIBRTE_DPAA_DEBUG_DRIVER
		dump_netcfg(dpaa_netcfg, stdout);
	#endif

dump_netcfg() dereferences cfg_ptr->num_ethports unconditionally. Fold it into the existing check:

	if (dpaa_netcfg) {
	#ifdef RTE_LIBRTE_DPAA_DEBUG_DRIVER
		dump_netcfg(dpaa_netcfg, stdout);
	#endif
		DPAA_BUS_DEBUG("Number of ethernet devices = %d",
			     dpaa_netcfg->num_ethports);
	}

Not addressed from v1: dpaa_oldev_queues_release() returns both FQIDs to the allocator with qman_release_fqid(), but the kernel received them through ASK_CTRL_SET_DPDK_INFO and is never told they are gone. There is no reset ioctl for that. Until cdx provides one, do not release the two FQIDs on close.

Info

drv_bh_port is now checked against a key list, but it is still parsed in dev_start(). A missing drv_bh_port is only reported at start. Parse it once in dpaa_ol_probe() and fail probe if it is absent.

The static_assert and comment added to dpaa_flow.c, and the MEMMAC_REG_OFFSET removal in fman.h, are not part of the offline port. Move the dpaa_flow.c change to 1/4, and mention the fman.h removal in the commit message.

Patch 4/4 drivers: add DPAA cgrid cleanup support
-------------------------------------------------

Info

dev_close() runs dpaa_cgr_stale_fq_cleanup() before shutting down the port's own FQs. The scan therefore finds this port's live queues, logs each one as "still alive?", and shuts it down by FQID. The qman_shutdown_fq() loop that follows then only sees FQs that are already OOS. Shut down rx_queues[]/tx_queues[] first, then scan, so the scan only reports FQs left by a previous run.

#12 lore raw
In reply to Gagandeep Singh
Quoted 34 lines · On Fri, 30 Oct 2026 10:13:14 +0530 Gagandeep Singh <[email protected]> wrote:

V2-changes:
- Fixed most of the AI comments.
- added new patch:
fix out-of-bounds read of mac_idx
- removed drv_oldev, updated comments and notes.
- fixes FQ shutdown
- removed unwanted checks, updated open, updated snprintf.
- updated commit messages.

V1:
- Adding OH port support.
- Updates in shared ethernet code.
- Congestion related code cleanup.

Gagandeep Singh (2):
bus/dpaa: fix out-of-bounds read of mac_idx array
drivers: add offline (O/H) port device support

Hemant Agrawal (1):
net/dpaa: support non fmX-macY type of shared Ethernet name

Jun Yang (1):
drivers: add DPAA cgrid cleanup support

 doc/api/doxy-api-index.md                |   1 +
 doc/guides/nics/dpaa.rst                 |  35 +
 drivers/bus/dpaa/base/fman/fman.c        |  19 +
 drivers/bus/dpaa/base/qbman/qman.c       |  61 ++
 drivers/bus/dpaa/bus_dpaa_driver.h       |   4 +-
 drivers/bus/dpaa/dpaa_bus.c              |  66 +-
 drivers/bus/dpaa/dpaa_bus_base_symbols.c |   2 +
 drivers/bus/dpaa/include/fman.h          |   6 +-
 drivers/bus/dpaa/include/fsl_qman.h      |  28 +
 drivers/net/dpaa/dpaa_ethdev.c           | 241 ++++++-
Quoted 9 lines
 drivers/net/dpaa/dpaa_ethdev.h           |   3 +
 drivers/net/dpaa/dpaa_flow.c             |   7 +-
 drivers/net/dpaa/dpaa_oldev.c            | 875 +++++++++++++++++++++++
 drivers/net/dpaa/meson.build             |  11 +-
 drivers/net/dpaa/rte_pmd_dpaa_oldev.h    | 188 +++++
 15 files changed, 1517 insertions(+), 30 deletions(-)
 create mode 100644 drivers/net/dpaa/dpaa_oldev.c
 create mode 100644 drivers/net/dpaa/rte_pmd_dpaa_oldev.h

Review of [PATCH v2 0/4] DPAA offline port, shared MAC, cgrid cleanup

Applied to next-net for-main (3b51e2e2f0). Each commit builds with -Dwerror=true.

Series
------

The rte_pmd_dpaa_ol_* API is unchanged from v1 apart from renames and Doxygen. The four functions still take no port_id and only pass a caller-filled struct to ioctl() on the out-of-tree /dev/cdx_ctrl driver. The dpaa.rst text added in v2 confirms the API is configuration for that kernel module, not for the DPDK port. It belongs in the vendor userspace library for cdx. Please drop rte_pmd_dpaa_oldev.h and the exports.

There are still no release notes for the offline port.

Patch 2/4 drivers: add offline (O/H) port device support
--------------------------------------------------------

Warning

The commit message still says the port is "selected through the 'drv_oldev' bus device argument". v2 removed drv_oldev; the port is created when "-a dpaa_bus:oldev1" is given.

With only oldev1 present, dpaa_netcfg is NULL. v2 handles that in the two log statements but not in the debug dump:

	#ifdef RTE_LIBRTE_DPAA_DEBUG_DRIVER
		dump_netcfg(dpaa_netcfg, stdout);
	#endif

dump_netcfg() dereferences cfg_ptr->num_ethports unconditionally. Fold it into the existing check:

	if (dpaa_netcfg) {
	#ifdef RTE_LIBRTE_DPAA_DEBUG_DRIVER
		dump_netcfg(dpaa_netcfg, stdout);
	#endif
		DPAA_BUS_DEBUG("Number of ethernet devices = %d",
			     dpaa_netcfg->num_ethports);
	}

Not addressed from v1: dpaa_oldev_queues_release() returns both FQIDs to the allocator with qman_release_fqid(), but the kernel received them through ASK_CTRL_SET_DPDK_INFO and is never told they are gone. There is no reset ioctl for that. Until cdx provides one, do not release the two FQIDs on close.

Info

drv_bh_port is now checked against a key list, but it is still parsed in dev_start(). A missing drv_bh_port is only reported at start. Parse it once in dpaa_ol_probe() and fail probe if it is absent.

The static_assert and comment added to dpaa_flow.c, and the MEMMAC_REG_OFFSET removal in fman.h, are not part of the offline port. Move the dpaa_flow.c change to 1/4, and mention the fman.h removal in the commit message.

Patch 4/4 drivers: add DPAA cgrid cleanup support
-------------------------------------------------

Info

dev_close() runs dpaa_cgr_stale_fq_cleanup() before shutting down the port's own FQs. The scan therefore finds this port's live queues, logs each one as "still alive?", and shuts it down by FQID. The qman_shutdown_fq() loop that follows then only sees FQs that are already OOS. Shut down rx_queues[]/tx_queues[] first, then scan, so the scan only reports FQs left by a previous run.

#13 lore raw

Hi

NXP Confidential

Quoted 62 lines

-----Original Message-----
From: Stephen Hemminger <[email protected]>
Sent: Monday, November 2, 2026 6:53 PM
To: Gagandeep Singh <[email protected]>
Cc: [email protected]; Hemant Agrawal <[email protected]>
Subject: Re: [PATCH v2 0/4] DPAA driver changes

Quoted 40 lines · On Fri, 30 Oct 2026 10:13:14 +0530 Gagandeep Singh <[email protected]> wrote:

V2-changes:
- Fixed most of the AI comments.
- added new patch:
fix out-of-bounds read of mac_idx
- removed drv_oldev, updated comments and notes.
- fixes FQ shutdown
- removed unwanted checks, updated open, updated snprintf.
- updated commit messages.

V1:
- Adding OH port support.
- Updates in shared ethernet code.
- Congestion related code cleanup.

Gagandeep Singh (2):
bus/dpaa: fix out-of-bounds read of mac_idx array
drivers: add offline (O/H) port device support

Hemant Agrawal (1):
net/dpaa: support non fmX-macY type of shared Ethernet name

Jun Yang (1):
drivers: add DPAA cgrid cleanup support

 doc/api/doxy-api-index.md                |   1 +
 doc/guides/nics/dpaa.rst                 |  35 +
 drivers/bus/dpaa/base/fman/fman.c        |  19 +
 drivers/bus/dpaa/base/qbman/qman.c       |  61 ++
 drivers/bus/dpaa/bus_dpaa_driver.h       |   4 +-
 drivers/bus/dpaa/dpaa_bus.c              |  66 +-
 drivers/bus/dpaa/dpaa_bus_base_symbols.c |   2 +
 drivers/bus/dpaa/include/fman.h          |   6 +-
 drivers/bus/dpaa/include/fsl_qman.h      |  28 +
 drivers/net/dpaa/dpaa_ethdev.c           | 241 ++++++-
 drivers/net/dpaa/dpaa_ethdev.h           |   3 +
 drivers/net/dpaa/dpaa_flow.c             |   7 +-
 drivers/net/dpaa/dpaa_oldev.c            | 875 +++++++++++++++++++++++
 drivers/net/dpaa/meson.build             |  11 +-
 drivers/net/dpaa/rte_pmd_dpaa_oldev.h    | 188 +++++
 15 files changed, 1517 insertions(+), 30 deletions(-)  create mode
Quoted 3 lines

100644 drivers/net/dpaa/dpaa_oldev.c create mode 100644 drivers/net/dpaa/rte_pmd_dpaa_oldev.h

Review of [PATCH v2 0/4] DPAA offline port, shared MAC, cgrid cleanup

Applied to next-net for-main (3b51e2e2f0). Each commit builds with - Dwerror=true.

Series
------

Quoted 9 lines

The rte_pmd_dpaa_ol_* API is unchanged from v1 apart from renames and Doxygen. The four functions still take no port_id and only pass a caller-filled struct to ioctl() on the out-of-tree /dev/cdx_ctrl driver. The dpaa.rst text added in v2 confirms the API is configuration for that kernel module, not for the DPDK port. It belongs in the vendor userspace library for cdx. Please drop rte_pmd_dpaa_oldev.h and the exports.

There are still no release notes for the offline port.

In V3, we've updated the rte_pmd_dpaa_ol_* APIs to be port-based by requiring a port_id argument. Each call now resolves the corresponding rte_eth_dev and verifies it is a valid DPAA offline port before proceeding, preventing use on invalid or unrelated ports.

We also moved the control device handle (/dev/cdx_ctrl) from a process-wide global into the offline port's private data (dpaa_if::ol_fd). It is opened on first use and closed during dev_close(), ensuring its lifetime is tied to the port.

Also added the release notes in V3.

Quoted 57 lines

Patch 2/4 drivers: add offline (O/H) port device support
--------------------------------------------------------

Warning

The commit message still says the port is "selected through the 'drv_oldev' bus device argument". v2 removed drv_oldev; the port is created when "-a dpaa_bus:oldev1" is given.

With only oldev1 present, dpaa_netcfg is NULL. v2 handles that in the two log statements but not in the debug dump:

      #ifdef RTE_LIBRTE_DPAA_DEBUG_DRIVER
              dump_netcfg(dpaa_netcfg, stdout);
      #endif

dump_netcfg() dereferences cfg_ptr->num_ethports unconditionally. Fold it into the existing check:

      if (dpaa_netcfg) {
      #ifdef RTE_LIBRTE_DPAA_DEBUG_DRIVER
              dump_netcfg(dpaa_netcfg, stdout);
      #endif
              DPAA_BUS_DEBUG("Number of ethernet devices = %d",
                           dpaa_netcfg->num_ethports);
      }

Not addressed from v1: dpaa_oldev_queues_release() returns both FQIDs to the allocator with qman_release_fqid(), but the kernel received them through ASK_CTRL_SET_DPDK_INFO and is never told they are gone. There is no reset ioctl for that. Until cdx provides one, do not release the two FQIDs on close.

Info

drv_bh_port is now checked against a key list, but it is still parsed in dev_start(). A missing drv_bh_port is only reported at start. Parse it once in dpaa_ol_probe() and fail probe if it is absent.

The static_assert and comment added to dpaa_flow.c, and the MEMMAC_REG_OFFSET removal in fman.h, are not part of the offline port. Move the dpaa_flow.c change to 1/4, and mention the fman.h removal in the commit message.

Patch 4/4 drivers: add DPAA cgrid cleanup support
-------------------------------------------------

Info

dev_close() runs dpaa_cgr_stale_fq_cleanup() before shutting down the port's own FQs. The scan therefore finds this port's live queues, logs each one as "still alive?", and shuts it down by FQID. The
qman_shutdown_fq() loop that follows then only sees FQs that are already OOS. Shut down rx_queues[]/tx_queues[] first, then scan, so the scan only reports FQs left by a previous run.

#14 lore raw

v3 cover DPAA driver changes

In reply to Gagandeep Singh

V3-Changes:
- Updated rte_pmd_dpaa_oldev.h APIs as per DPDK compliance.
- Added missing release not for OH port support.
- Fixed dump_netcfg issue.
- Added an API to release FQID.
- moved the fman.h changes to first patch.

V2-changes:
- Fixed most of the AI comments.
- added new patch:
fix out-of-bounds read of mac_idx
- removed drv_oldev, updated comments and notes.
- fixes FQ shutdown
- removed unwanted checks, updated open, updated snprintf.
- updated commit messages.

V1:
- Adding OH port support.
- Updates in shared ethernet code.
- Congestion related code cleanup.

Gagandeep Singh (2):
bus/dpaa: fix out-of-bounds read of mac_idx array
drivers: add offline (O/H) port device support

Hemant Agrawal (1):
net/dpaa: support non fmX-macY type of shared Ethernet name

Jun Yang (1):
drivers: add DPAA cgrid cleanup support

 doc/api/doxy-api-index.md                |   1 +
 doc/guides/nics/dpaa.rst                 |  36 +
 doc/guides/rel_notes/release_26_11.rst   |  10 +
 drivers/bus/dpaa/base/fman/fman.c        |  19 +
 drivers/bus/dpaa/base/qbman/qman.c       |  61 ++
 drivers/bus/dpaa/bus_dpaa_driver.h       |   4 +-
 drivers/bus/dpaa/dpaa_bus.c              |  68 +-
 drivers/bus/dpaa/dpaa_bus_base_symbols.c |   2 +
 drivers/bus/dpaa/include/fman.h          |   6 +-
 drivers/bus/dpaa/include/fsl_qman.h      |  28 +
 drivers/net/dpaa/dpaa_ethdev.c           | 235 +++++-
 drivers/net/dpaa/dpaa_ethdev.h           |  12 +
 drivers/net/dpaa/dpaa_flow.c             |   5 +-
 drivers/net/dpaa/dpaa_oldev.c            | 938 +++++++++++++++++++++++
 drivers/net/dpaa/meson.build             |  11 +-
 drivers/net/dpaa/rte_pmd_dpaa_oldev.h    | 198 +++++
 16 files changed, 1603 insertions(+), 31 deletions(-)
 create mode 100644 drivers/net/dpaa/dpaa_oldev.c
 create mode 100644 drivers/net/dpaa/rte_pmd_dpaa_oldev.h
Signature · 1 line
2.25.1
#15 lore raw

PATCH v3 1/4 bus/dpaa: fix out-of-bounds read of mac_idx array

fman_if_init() and fman_if_init_onic() read the devicetree 'cell-index' property and store it unchecked into __if->__if.mac_idx. This value is later used as an index into the fixed-size mac_idx[] lookup table in fman_if_vsp_init(), so a cell-index value greater than or equal to the number of entries in that table results in an out-of-bounds read.

Add an explicit upper-bound check (FMAN_MAX_MAC_IDX_NUM) in both fman_if_init() and fman_if_init_onic() before the mac_idx assignment, and a static_assert in fman_if_vsp_init() to keep mac_idx[] in sync with FMAN_MAX_MAC_IDX_NUM if it is ever resized.

Also remove the unused MEMMAC_REG_OFFSET() macro from fman.h, which had no remaining callers.

Fixes a0edbb8a8e52 ("bus/dpaa: add OH port mode")
Fixes 7e5f49ae767d ("bus/dpaa: add ONIC port mode")
---
 drivers/bus/dpaa/base/fman/fman.c | 19 +++++++++++++++++++
 drivers/bus/dpaa/include/fman.h   |  6 +++++-
 drivers/net/dpaa/dpaa_flow.c      |  5 ++++-
 3 files changed, 28 insertions(+), 2 deletions(-)
drivers/bus/dpaa/base/fman/fman.c +19 -0
index 67f77265ca..223cd6958d 100644
@@ -205,6 +205,9 @@ static void fman_if_vsp_init(struct __fman_if *__if)
 	size_t lenp;
 	const uint8_t mac_idx[] = {-1, 0, 1, 2, 3, 4, 5, 6, 7, 0, 1};
 
+	static_assert(RTE_DIM(mac_idx) == FMAN_MAX_MAC_IDX_NUM,
+		      "mac_idx[] out of sync with FMAN_MAX_MAC_IDX_NUM");
+
 	if (__if->__if.mac_idx <= 8) {
 		for_each_compatible_node(dev, NULL,
 			"fsl,fman-port-1g-rx-extended-args") {
@@ -544,6 +547,14 @@ fman_if_init(const struct device_node *dpa_node, int fd)
 		cell_idx_host = of_read_number(cell_idx,
 					       lenp / sizeof(phandle));
 
+		if (cell_idx_host >= FMAN_MAX_MAC_IDX_NUM) {
+			FMAN_ERR(-EINVAL,
+				 "%s: cell-index(%" PRIu64 ") >= max(%d)",
+				 oh_node->full_name, cell_idx_host,
+				 FMAN_MAX_MAC_IDX_NUM);
+			goto err;
+		}
+
 		__if->__if.mac_idx = cell_idx_host;
 	}
 
@@ -957,6 +968,14 @@ static int fman_if_init_onic(const struct device_node *dpa_node)
 	assert(lenp == sizeof(*cell_idx));
 
 	cell_idx_host = of_read_number(cell_idx, lenp / sizeof(phandle));
+
+	if (cell_idx_host >= FMAN_MAX_MAC_IDX_NUM) {
+		FMAN_ERR(-EINVAL, "%s: cell-index(%" PRIu64 ") >= max(%d)",
+			 tx_oh_node->full_name, cell_idx_host,
+			 FMAN_MAX_MAC_IDX_NUM);
+		goto err;
+	}
+
 	__if->__if.mac_idx = cell_idx_host;
 
 	fman_node = of_get_parent(fman_tx_oh_node);
drivers/bus/dpaa/include/fman.h +5 -1
index f642faf3b3..030c85c284 100644
@@ -68,6 +68,11 @@
 #define FMAN_RTC_MAX_NUM_OF_PERIODIC_PULSES	4
 #define FMAN_RTC_MAX_NUM_OF_EXT_TRIGGERS	3
 
+/*
+ * Maximum number of MAC/offline port indexes.
+ */
+#define FMAN_MAX_MAC_IDX_NUM	11
+
 /* Represents the different flavour of network interface */
 enum fman_mac_type {
 	fman_offline_internal = 0,
@@ -475,7 +480,6 @@ struct __fman_if {
 	void *qmi_map;
 };
 
-#define MEMMAC_REG_OFFSET(reg) offsetof(struct memac_regs, reg)
 #define BMI_RX_REG_OFFSET(reg) offsetof(struct rx_bmi_regs, reg)
 #define BMI_TX_REG_OFFSET(reg) offsetof(struct tx_bmi_regs, reg)
 
drivers/net/dpaa/dpaa_flow.c +4 -1
index f77f9f333b..403e97ed2d 100644
@@ -32,9 +32,12 @@ return &scheme_params->param.key_ext_and_hash.extract_array[hdr_idx];
 	SCH_EXT_HDR(scheme_params, hdr_idx).extract_by_hdr_type.full_field
 
 /* FMAN mac indexes mappings (0 is unused, first 8 are for 1G, next for 10G
- * ports).
+ * ports). Indexed by fman_if.mac_idx, which the bus validates against
+ * FMAN_MAX_MAC_IDX_NUM when deriving it from the device tree.
  */
 static const uint8_t mac_idx[] = {-1, 0, 1, 2, 3, 4, 5, 6, 7, 0, 1};
+static_assert(RTE_DIM(mac_idx) == FMAN_MAX_MAC_IDX_NUM,
+	"mac_idx[] out of sync with FMAN_MAX_MAC_IDX_NUM");
 
 /* FM global info */
 struct dpaa_fm_info {
Signature · 1 line
2.25.1
#16 lore raw

PATCH v3 2/4 drivers: add offline (O/H) port device support

In reply to Gagandeep Singh

Add support for the DPAA Offline/Host-command (O/H) port, allowing a single OL port to be used by a DPDK application. The port is created by passing "-a dpaa_bus:oldev1" (plus any devargs) on the EAL command line, and the associated back-half port is named through the 'drv_bh_port' device argument.

---
 doc/api/doxy-api-index.md                |   1 +
 doc/guides/nics/dpaa.rst                 |  32 +
 doc/guides/rel_notes/release_26_11.rst   |  10 +
 drivers/bus/dpaa/bus_dpaa_driver.h       |   4 +-
 drivers/bus/dpaa/dpaa_bus.c              |  68 +-
 drivers/bus/dpaa/dpaa_bus_base_symbols.c |   1 +
 drivers/bus/dpaa/include/fsl_qman.h      |   1 +
 drivers/net/dpaa/dpaa_ethdev.h           |  12 +
 drivers/net/dpaa/dpaa_oldev.c            | 938 +++++++++++++++++++++++
 drivers/net/dpaa/meson.build             |  11 +-
 drivers/net/dpaa/rte_pmd_dpaa_oldev.h    | 198 +++++
 11 files changed, 1260 insertions(+), 16 deletions(-)
 create mode 100644 drivers/net/dpaa/dpaa_oldev.c
 create mode 100644 drivers/net/dpaa/rte_pmd_dpaa_oldev.h
doc/api/doxy-api-index.md +1 -0
index 62390f7be3..0bd8e1bbf0 100644
@@ -53,6 +53,7 @@ The public API headers are grouped by topics:
   [cnxk_eventdev](@ref rte_pmd_cnxk_eventdev.h),
   [cnxk_mempool](@ref rte_pmd_cnxk_mempool.h),
   [dpaa](@ref rte_pmd_dpaa.h),
+  [dpaa_oldev](@ref rte_pmd_dpaa_oldev.h),
   [dpaa2](@ref rte_pmd_dpaa2.h),
   [mlx5](@ref rte_pmd_mlx5.h),
   [dpaa2_mempool](@ref rte_dpaa2_mempool.h),
doc/guides/nics/dpaa.rst +32 -0
index c6aab46828..7658e6d454 100644
@@ -276,6 +276,38 @@ Refer to the document :doc:`build_and_test` for details.
   and thus disabling hardware based packet handling at driver level,
   e.g. ``dpaa:fm1-mac3,recv_err_pkts=1``.
 
+``drv_bh_port``
+   Name of the back-half port associated with an offline (O/H) port device.
+   It is passed on the offline port device itself, which is named
+   ``oldev1``, e.g. ``-a dpaa_bus:oldev1,drv_bh_port=fm1-mac5``.
+
+The DPAA offline (O/H) port device is only created, and therefore only
+probed, when it is explicitly named on the EAL ``-a`` command line, e.g.::
+
+   -a dpaa_bus:oldev1,drv_bh_port=fm1-mac5
+
+Passing any ``-a`` argument for the DPAA bus switches the bus to allowlist
+scan mode, so from that point on only the devices named with ``-a`` are
+probed. Using the offline port therefore requires listing the offline port
+itself and every Ethernet port the application needs, for example::
+
+   -a dpaa_bus:oldev1,drv_bh_port=fm1-mac5 \
+   -a dpaa_bus:fm1-mac5 -a dpaa_bus:fm1-mac6
+
+Omitting an ``fmX-macY`` port in that case silently drops that port.
+
+The offline port requires the ``/dev/cdx_ctrl`` kernel control device to be
+present; it is provided by the NXP vendor ``cdx`` kernel driver, which is
+not part of this DPDK driver and must be obtained and loaded separately
+(see the NXP LSDK release matching the DPAA SoC family). The uplink
+classification and local-gateway (LGW) configuration exposed through that
+control device can be programmed by the application, for the offline
+port identified by its ``port_id``, via the experimental
+``rte_pmd_dpaa_ol_set_classif_info()``, ``rte_pmd_dpaa_ol_reset_classif_info()``,
+``rte_pmd_dpaa_ol_set_lgw_info()`` and ``rte_pmd_dpaa_ol_reset_lgw_info()``
+APIs declared in ``rte_pmd_dpaa_oldev.h``.
+
+
 FMAN Config
 -----------
 
doc/guides/rel_notes/release_26_11.rst +10 -0
index 078f71a815..5a71c3c048 100644
@@ -207,6 +207,16 @@ New Features
   * Added Tx pause support for the ENETC4 VF via Rx congestion mode.
   * Added WRR Tx scheduler devarg (``enetc4_txq_wrr``) for ENETC4 VF ring weights.
 
+* **Added NXP DPAA offline (O/H) port support.**
+
+  Added a DPAA offline (O/H) port type that loops Rx/Tx frame queues through
+  the FMAN and exposes them as a DPDK port, with uplink classification and
+  LGW subnet configuration forwarded to the ASK/CDX kernel module via the
+  experimental ``rte_pmd_dpaa_ol_set_classif_info()``,
+  ``rte_pmd_dpaa_ol_reset_classif_info()``, ``rte_pmd_dpaa_ol_set_lgw_info()``
+  and ``rte_pmd_dpaa_ol_reset_lgw_info()`` APIs declared in
+  ``rte_pmd_dpaa_oldev.h``.
+
 * **Updated NXP DPAA drivers.**
 
   * Changed the default number of Rx queues in FMCLESS mode to the maximum
drivers/bus/dpaa/bus_dpaa_driver.h +3 -1
index 4aed83f84d..323a6a7659 100644
@@ -69,11 +69,13 @@ struct rte_dpaa_driver;
 enum rte_dpaa_type {
 	FSL_DPAA_ETH = 1,
 	FSL_DPAA_CRYPTO,
-	FSL_DPAA_QDMA
+	FSL_DPAA_QDMA,
+	FSL_DPAA_OL
 };
 
 struct dpaa_device_id {
 	uint8_t fman_id; /**< Fman interface ID, for ETH type device */
+	uint8_t ol_id;	/**< OH interface ID, for OH type device */
 	uint8_t mac_id; /**< Fman MAC interface ID, for ETH type device */
 	uint16_t dev_id; /**< Device Identifier from DPDK */
 };
drivers/bus/dpaa/dpaa_bus.c +58 -10

131 lines not on this page · raw message

drivers/bus/dpaa/dpaa_bus_base_symbols.c +1 -0
index 0927e5fe2c..aaa9f9bec2 100644
@@ -52,6 +52,7 @@ RTE_EXPORT_INTERNAL_SYMBOL(bman_acquire)
 RTE_EXPORT_INTERNAL_SYMBOL(bman_query_free_buffers)
 RTE_EXPORT_INTERNAL_SYMBOL(bman_thread_irq)
 RTE_EXPORT_INTERNAL_SYMBOL(qman_alloc_fqid_range)
+RTE_EXPORT_INTERNAL_SYMBOL(qman_release_fqid_range)
 RTE_EXPORT_INTERNAL_SYMBOL(qman_reserve_fqid_range)
 RTE_EXPORT_INTERNAL_SYMBOL(qman_alloc_pool_range)
 RTE_EXPORT_INTERNAL_SYMBOL(qman_alloc_cgrid_range)
drivers/bus/dpaa/include/fsl_qman.h +1 -0
index 59b41e17f0..b2674ce5d0 100644
@@ -1895,6 +1895,7 @@ static inline int qman_alloc_fqid(u32 *result)
  * This function can also be used to seed the allocator with ranges of FQIDs
  * that it can subsequently allocate from.
  */
+__rte_internal
 void qman_release_fqid_range(u32 fqid, unsigned int count);
 static inline void qman_release_fqid(u32 fqid)
 {
drivers/net/dpaa/dpaa_ethdev.h +12 -0
index 47c8e2b086..c3afc9d2ed 100644
@@ -114,6 +114,10 @@ enum {
 
 #define DPAA_DEFAULT_RXQ_VSP_ID		1
 
+/* Device argument to name the offline (O/H) port back-half port */
+#define DRIVER_OL_BH_PORT		"drv_bh_port"
+#define DPAA_OL_MAX_BH_PORT_NAME_LEN	12
+
 #define FMC_FILE "/tmp/fmc.bin"
 
 struct dpaa_if_vsp {
@@ -173,10 +177,18 @@ struct dpaa_if {
 	struct qman_fq *next_tx_conf_queue;
 
 	struct dpaa_if_vsp vsp[DPAA_VSP_PROFILE_MAX_NUM];
+
+	/* Control device fd, used by the offline port PMD only. */
+	int ol_fd;
+	/* Backhaul port name from the drv_bh_port devarg, used by the
+	 * offline port PMD only.
+	 */
+	char ol_bh_port_name[DPAA_OL_MAX_BH_PORT_NAME_LEN];
 };
 
 struct dpaa_if_stats {
 	/* Rx Statistics Counter */
+
 	uint64_t reoct;		/**<Rx Eth Octets Counter */
 	uint64_t roct;		/**<Rx Octet Counters */
 	uint64_t raln;		/**<Rx Alignment Error Counter */
drivers/net/dpaa/dpaa_oldev.c new file +938 -0

938 lines not on this page · raw message

drivers/net/dpaa/meson.build +6 -5
index 8d4f69c596..3ec1091197 100644
@@ -1,5 +1,5 @@
 # SPDX-License-Identifier: BSD-3-Clause
-# Copyright 2018-2020 NXP
+# Copyright 2018-2020,2026 NXP
 
 if not is_linux
     build = false
@@ -9,12 +9,13 @@ deps += ['mempool_dpaa']
 
 sources = files(
         'dpaa_ethdev.c',
-        'fmlib/fm_lib.c',
-        'fmlib/fm_vsp.c',
         'dpaa_flow.c',
-        'dpaa_rxtx.c',
         'dpaa_fmc.c',
         'dpaa_ptp.c',
+        'dpaa_oldev.c',
+        'dpaa_rxtx.c',
+        'fmlib/fm_lib.c',
+        'fmlib/fm_vsp.c',
 )
 
 cflags += no_wvla_cflag
@@ -24,4 +25,4 @@ if cc.has_argument('-Wno-pointer-arith')
     cflags += '-Wno-pointer-arith'
 endif
 
-headers = files('rte_pmd_dpaa.h')
+headers = files('rte_pmd_dpaa.h', 'rte_pmd_dpaa_oldev.h')
drivers/net/dpaa/rte_pmd_dpaa_oldev.h new file +198 -0

198 lines not on this page · raw message

Signature · 1 line
2.25.1
#17 lore raw

PATCH v3 3/4 net/dpaa: support non fmX-macY type of shared Ethernet name

In reply to Gagandeep Singh

From: Hemant Agrawal <[email protected]>

A shared MAC interface needs the kernel netdev name to read the MTU, and that name is only the DPDK port name for fmX-macY style netdevs.

Look it up in sysfs under the platform device of the dpa-ethernet node the port was created from, and fall back to the port name.

---
 doc/guides/nics/dpaa.rst       |  6 ++-
 drivers/net/dpaa/dpaa_ethdev.c | 68 +++++++++++++++++++++++++++++++++-
 2 files changed, 72 insertions(+), 2 deletions(-)
doc/guides/nics/dpaa.rst +5 -1
index 7658e6d454..d391c0607f 100644
@@ -276,6 +276,11 @@ Refer to the document :doc:`build_and_test` for details.
   and thus disabling hardware based packet handling at driver level,
   e.g. ``dpaa:fm1-mac3,recv_err_pkts=1``.
 
+* For a shared MAC interface the kernel network interface name is looked up
+  in sysfs from the device tree node the port was created from,
+  so a kernel interface that does not follow
+  the ``fmX-macY`` naming style is handled without extra configuration.
+
 ``drv_bh_port``
    Name of the back-half port associated with an offline (O/H) port device.
    It is passed on the offline port device itself, which is named
@@ -307,7 +312,6 @@ port identified by its ``port_id``, via the experimental
 ``rte_pmd_dpaa_ol_set_lgw_info()`` and ``rte_pmd_dpaa_ol_reset_lgw_info()``
 APIs declared in ``rte_pmd_dpaa_oldev.h``.
 
-
 FMAN Config
 -----------
 
drivers/net/dpaa/dpaa_ethdev.c +67 -1

98 lines not on this page · raw message

Signature · 1 line
2.25.1
#18 lore raw

PATCH v3 4/4 drivers: add DPAA cgrid cleanup support

In reply to Gagandeep Singh

From: Jun Yang <[email protected]>

A congestion group must have no member frame queues left when it is deleted, and its CGRID must be returned to the allocator once the group is gone. Neither was handled on the net/dpaa close and probe-failure paths.

This also changes probe behaviour: a qman_create_cgr() failure in dpaa_rx_queue_init() or dpaa_tx_queue_init() now fails the probe instead of continuing without tail drop on that queue. The probe error path deletes one CGR per initialised queue, and a CGR whose creation failed was never linked into the portal list.

Fixes 62f53995caaf ("net/dpaa: add frame count based tail drop with CGR")
Fixes 9124e65dd3eb ("net/dpaa: enable Tx queue taildrop")
---
 drivers/bus/dpaa/base/qbman/qman.c       |  61 +++++++++
 drivers/bus/dpaa/dpaa_bus_base_symbols.c |   1 +
 drivers/bus/dpaa/include/fsl_qman.h      |  27 ++++
 drivers/net/dpaa/dpaa_ethdev.c           | 167 +++++++++++++++++++++--
 4 files changed, 244 insertions(+), 12 deletions(-)
drivers/bus/dpaa/base/qbman/qman.c +61 -0
index 3c056e4547..fa3387c6bd 100644
@@ -2993,3 +2993,64 @@ qman_shutdown_fq(struct qman_fq *fq)
 out:
 	return ret;
 }
+
+int qman_pending_fq_by_cgrid_range(u32 cgrid_start, u32 cgrid_num,
+	u32 start_fqid, u32 *fqid, u32 *cgrid)
+{
+	struct qman_fq fq = {
+		.fqid = start_fqid ? start_fqid : 1
+	};
+	struct qm_mcr_queryfq_np np;
+	struct qm_fqd fqd;
+	int err;
+
+	/*
+	 * Do not use the CGR byte count to decide whether to scan. An FQ is a
+	 * member of the group whenever it is scheduled with CGE set and a
+	 * matching cgid, whether or not it currently holds any frames, and the
+	 * group cannot be deleted while such a member exists. Skipping the
+	 * scan for an empty CGR would let an idle stale FQ survive and its
+	 * CGRID be released while still referenced. This runs from the device
+	 * close path only, so the scan cost is acceptable.
+	 *
+	 * The whole CGRID range of a port is matched in a single pass, so a
+	 * port with many congestion groups does not need one full FQID space
+	 * scan per group.
+	 */
+	DPAA_BUS_DEBUG("Scanning FQs for cgrid(0x%x..0x%x)",
+		cgrid_start, cgrid_start + cgrid_num - 1);
+
+	/* FQID space is 24 bits wide; stop before wrapping. */
+	for (; fq.fqid <= QMAN_MAX_FQID; fq.fqid++) {
+		err = qman_query_fq_np(&fq, &np);
+		if (err == -ERANGE) {
+			/*
+			 * FQID is not implemented on this device, so there is
+			 * nothing beyond it either.
+			 */
+			break;
+		} else if (err) {
+			DPAA_BUS_WARN("Failed(%d) to Query np FQ(fqid=0x%x)",
+				err, fq.fqid);
+			return err;
+		}
+		if ((np.state & QM_MCR_NP_STATE_MASK) != QM_MCR_NP_STATE_OOS) {
+			err = qman_query_fq(&fq, &fqd);
+			if (err) {
+				DPAA_BUS_WARN("Failed(%d) to Query FQ(fqid=0x%x)",
+					err, fq.fqid);
+			} else if ((fqd.fq_ctrl & QM_FQCTRL_CGE) &&
+				fqd.cgid >= cgrid_start &&
+				fqd.cgid < cgrid_start + cgrid_num) {
+				if (fqid)
+					*fqid = fq.fqid;
+				if (cgrid)
+					*cgrid = fqd.cgid;
+				return 0;
+			}
+		}
+	}
+	DPAA_BUS_DEBUG("No FQ left in cgrid(0x%x..0x%x)",
+		cgrid_start, cgrid_start + cgrid_num - 1);
+	return -ERANGE;
+}
drivers/bus/dpaa/dpaa_bus_base_symbols.c +1 -0
index aaa9f9bec2..4da43f293d 100644
@@ -57,6 +57,7 @@ RTE_EXPORT_INTERNAL_SYMBOL(qman_reserve_fqid_range)
 RTE_EXPORT_INTERNAL_SYMBOL(qman_alloc_pool_range)
 RTE_EXPORT_INTERNAL_SYMBOL(qman_alloc_cgrid_range)
 RTE_EXPORT_INTERNAL_SYMBOL(qman_release_cgrid_range)
+RTE_EXPORT_INTERNAL_SYMBOL(qman_pending_fq_by_cgrid_range)
 RTE_EXPORT_INTERNAL_SYMBOL(dpaa_intr_enable)
 RTE_EXPORT_INTERNAL_SYMBOL(dpaa_intr_disable)
 RTE_EXPORT_INTERNAL_SYMBOL(dpaa_get_ioctl_version_number)
drivers/bus/dpaa/include/fsl_qman.h +27 -0
index b2674ce5d0..6d76722275 100644
@@ -1284,6 +1284,9 @@ struct qman_cgr {
  */
 #define QMAN_FQRN_WAIT_MAX		10000000u
 
+/* Maximum FQID value: frame queue IDs are 24 bits wide. */
+#define QMAN_MAX_FQID			0x00FFFFFFu
+
 /* Flags to qman_create_fq() */
 #define QMAN_FQ_FLAG_NO_ENQUEUE      0x00000001 /* can't enqueue */
 #define QMAN_FQ_FLAG_NO_MODIFY       0x00000002 /* can only enqueue */
@@ -1916,6 +1919,30 @@ static inline int qman_shutdown_fq_by_fqid(u32 fqid)
 	return qman_shutdown_fq(&fq);
 }
 
+/**
+ * qman_pending_fq_by_cgrid_range - Find an FQ still attached to a CGR range.
+ *
+ * @cgrid_start: first congestion group id of the range to search for.
+ * @cgrid_num: number of consecutive congestion group ids in the range.
+ * @start_fqid: FQID to begin the scan from (0 or 1 means scan from the
+ *   start). A caller shutting down several stale FQs can pass the previously
+ *   returned FQID + 1 to resume the scan instead of restarting from the
+ *   beginning each time.
+ * @fqid: on success, holds the FQID that is still attached to the range.
+ * @cgrid: on success, holds the congestion group id that FQ belongs to.
+ *   May be NULL.
+ *
+ * Matching a whole range in one pass lets a caller with many congestion
+ * groups, such as a port releasing all of its Rx or Tx CGRs, avoid one full
+ * FQID space scan per group.
+ *
+ * Return 0 and set *fqid when a matching FQ is found, -ERANGE when none is
+ * left, or a negative error code on query failure.
+ */
+__rte_internal
+int qman_pending_fq_by_cgrid_range(u32 cgrid_start, u32 cgrid_num,
+		u32 start_fqid, u32 *fqid, u32 *cgrid);
+
 /**
  * qman_reserve_fqid_range - Reserve the specified range of frame queue IDs
  * @fqid: the base FQID of the range to deallocate
drivers/net/dpaa/dpaa_ethdev.c +155 -12

288 lines not on this page · raw message

Signature · 1 line
2.25.1
#19 lore raw
In reply to Gagandeep Singh
Quoted 42 lines · On Tue, 3 Nov 2026 15:05:57 +0530 Gagandeep Singh <[email protected]> wrote:

V3-Changes:
- Updated rte_pmd_dpaa_oldev.h APIs as per DPDK compliance.
- Added missing release not for OH port support.
- Fixed dump_netcfg issue.
- Added an API to release FQID.
- moved the fman.h changes to first patch.

V2-changes:
- Fixed most of the AI comments.
- added new patch:
fix out-of-bounds read of mac_idx
- removed drv_oldev, updated comments and notes.
- fixes FQ shutdown
- removed unwanted checks, updated open, updated snprintf.
- updated commit messages.

V1:
- Adding OH port support.
- Updates in shared ethernet code.
- Congestion related code cleanup.

Gagandeep Singh (2):
bus/dpaa: fix out-of-bounds read of mac_idx array
drivers: add offline (O/H) port device support

Hemant Agrawal (1):
net/dpaa: support non fmX-macY type of shared Ethernet name

Jun Yang (1):
drivers: add DPAA cgrid cleanup support

 doc/api/doxy-api-index.md                |   1 +
 doc/guides/nics/dpaa.rst                 |  36 +
 doc/guides/rel_notes/release_26_11.rst   |  10 +
 drivers/bus/dpaa/base/fman/fman.c        |  19 +
 drivers/bus/dpaa/base/qbman/qman.c       |  61 ++
 drivers/bus/dpaa/bus_dpaa_driver.h       |   4 +-
 drivers/bus/dpaa/dpaa_bus.c              |  68 +-
 drivers/bus/dpaa/dpaa_bus_base_symbols.c |   2 +
 drivers/bus/dpaa/include/fman.h          |   6 +-
 drivers/bus/dpaa/include/fsl_qman.h      |  28 +
 drivers/net/dpaa/dpaa_ethdev.c           | 235 +++++-
Quoted 9 lines
 drivers/net/dpaa/dpaa_ethdev.h           |  12 +
 drivers/net/dpaa/dpaa_flow.c             |   5 +-
 drivers/net/dpaa/dpaa_oldev.c            | 938 +++++++++++++++++++++++
 drivers/net/dpaa/meson.build             |  11 +-
 drivers/net/dpaa/rte_pmd_dpaa_oldev.h    | 198 +++++
 16 files changed, 1603 insertions(+), 31 deletions(-)
 create mode 100644 drivers/net/dpaa/dpaa_oldev.c
 create mode 100644 drivers/net/dpaa/rte_pmd_dpaa_oldev.h

Still see AI reported errors

Review of [PATCH v3 0/4] DPAA offline port, shared MAC, cgrid cleanup

Applied to next-net for-main (3b51e2e2f0). Each commit builds with -Dwerror=true.

Series
------

The rte_pmd_dpaa_ol_* functions now take a port_id, but it is only used to look up which fd the ioctl goes to. The classification and LGW payloads carry nothing from the port, and the kernel module consumes them. My earlier objection stands: this is configuration API for the out-of-tree cdx driver and does not belong in DPDK.

Patch 2/4 drivers: add offline (O/H) port device support
--------------------------------------------------------

Error

dpaa_oldev_init() opens /dev/cdx_ctrl through check_fd() in dpaa_ol_tx_queue_init(). If a later step fails, for example the mac_addrs allocation, the free_rx path does not close the fd:

	free_rx:
		dpaa_oldev_queues_release(dpaa_intf);
		return ret;

dpaa_ol_probe() then calls rte_eth_dev_release_port(), which frees dev_private and ol_fd with it. Close it on the error path:

	free_rx:
		dpaa_oldev_queues_release(dpaa_intf);
		if (dpaa_intf->ol_fd >= 0) {
			close(dpaa_intf->ol_fd);
			dpaa_intf->ol_fd = -1;
		}
		return ret;

Warning

dpaa_oldev_queues_release() sends ASK_CTRL_RESET_DPDK_INFO and releases the FQIDs only if that succeeds. It does this even when ASK_CTRL_SET_DPDK_INFO was never issued: on the probe error path, and on close of a port that was never started. In those cases the kernel never had the FQIDs, so there is nothing to reset. If /dev/cdx_ctrl is missing, probe fails in dpaa_ol_tx_queue_init(), the reset fails with -ENODEV, and the Rx FQID allocated with QMAN_FQ_FLAG_DYNAMIC_FQID leaks on every attempt. Track whether the kernel holds the FQIDs:

	/* dpaa_ol_set_fq_info(), after ask_set_fq_info() succeeds */
	dpaa_intf->ol_fq_info_set = true;

	/* dpaa_oldev_queues_release() */
	release_fqids = true;
	if (dpaa_intf->ol_fq_info_set) {
		if (ask_reset_fq_info(dpaa_intf, &fq_info) != 0)
			release_fqids = false;
		else
			dpaa_intf->ol_fq_info_set = false;
	}

Info

v3 replaced the atomic ask_fd with a plain dpaa_intf->ol_fd, but kept the double-checked lock in check_fd(). The unlocked read of ol_fd now races with the locked write if control calls can be concurrent. If they cannot, the mutex is not needed. The fd is always opened during probe by dpaa_ol_tx_queue_init(), so open it once in dpaa_oldev_init() and drop fd_init_lock and the lazy open.

dpaa_ol_set_fq_info() copies bh_port_name with rte_memcpy(); this is control path, use memcpy().

The blank line added after "/* Rx Statistics Counter */" in struct dpaa_if_stats is unrelated.

#20 lore raw

Hi

NXP Confidential

Quoted 69 lines

-----Original Message-----
From: Stephen Hemminger <[email protected]>
Sent: Wednesday, November 4, 2026 4:59 PM
To: Gagandeep Singh <[email protected]>
Cc: [email protected]; Hemant Agrawal <[email protected]>
Subject: Re: [PATCH v3 0/4] DPAA driver changes

Quoted 48 lines · On Tue, 3 Nov 2026 15:05:57 +0530 Gagandeep Singh <[email protected]> wrote:

V3-Changes:
- Updated rte_pmd_dpaa_oldev.h APIs as per DPDK compliance.
- Added missing release not for OH port support.
- Fixed dump_netcfg issue.
- Added an API to release FQID.
- moved the fman.h changes to first patch.

V2-changes:
- Fixed most of the AI comments.
- added new patch:
fix out-of-bounds read of mac_idx
- removed drv_oldev, updated comments and notes.
- fixes FQ shutdown
- removed unwanted checks, updated open, updated snprintf.
- updated commit messages.

V1:
- Adding OH port support.
- Updates in shared ethernet code.
- Congestion related code cleanup.

Gagandeep Singh (2):
bus/dpaa: fix out-of-bounds read of mac_idx array
drivers: add offline (O/H) port device support

Hemant Agrawal (1):
net/dpaa: support non fmX-macY type of shared Ethernet name

Jun Yang (1):
drivers: add DPAA cgrid cleanup support

 doc/api/doxy-api-index.md                |   1 +
 doc/guides/nics/dpaa.rst                 |  36 +
 doc/guides/rel_notes/release_26_11.rst   |  10 +
 drivers/bus/dpaa/base/fman/fman.c        |  19 +
 drivers/bus/dpaa/base/qbman/qman.c       |  61 ++
 drivers/bus/dpaa/bus_dpaa_driver.h       |   4 +-
 drivers/bus/dpaa/dpaa_bus.c              |  68 +-
 drivers/bus/dpaa/dpaa_bus_base_symbols.c |   2 +
 drivers/bus/dpaa/include/fman.h          |   6 +-
 drivers/bus/dpaa/include/fsl_qman.h      |  28 +
 drivers/net/dpaa/dpaa_ethdev.c           | 235 +++++-
 drivers/net/dpaa/dpaa_ethdev.h           |  12 +
 drivers/net/dpaa/dpaa_flow.c             |   5 +-
 drivers/net/dpaa/dpaa_oldev.c            | 938 +++++++++++++++++++++++
 drivers/net/dpaa/meson.build             |  11 +-
 drivers/net/dpaa/rte_pmd_dpaa_oldev.h    | 198 +++++
 16 files changed, 1603 insertions(+), 31 deletions(-)  create mode
Quoted 3 lines

100644 drivers/net/dpaa/dpaa_oldev.c create mode 100644 drivers/net/dpaa/rte_pmd_dpaa_oldev.h

Still see AI reported errors

Review of [PATCH v3 0/4] DPAA offline port, shared MAC, cgrid cleanup

Applied to next-net for-main (3b51e2e2f0). Each commit builds with - Dwerror=true.

Quoted 9 lines

Series
------

The rte_pmd_dpaa_ol_* functions now take a port_id, but it is only used to look up which fd the ioctl goes to. The classification and LGW payloads carry nothing from the port, and the kernel module consumes them. My earlier objection
stands: this is configuration API for the out-of-tree cdx driver and does not belong in DPDK.

you're right that the new APIs don't interpret or act on their payloads in DPDK —
the structs are serialized and handed to the ASK/CDX kernel driver via ioctl,
and all the real logic (uplink classification, LGW subnet programming) lives in that out-of-tree module. No argument there.

The reason we think this still belongs with the offline-port driver rather than being left
entirely to the application is the "fd" and lifetime binding, not the payload semantics:

- The ioctl must go out on dpaa_if::ol_fd, which is private port state opened on first use and closed in dev_close(). There is no public DPDK handle to that fd today, and we don't want to add one — that would mean exposing a raw file descriptor as public API, which is worse than what we have.
- If this configuration path is pushed out of DPDK, the application needs its own separate way to resolve "which /dev/cdx_ctrl instance backhaul port corresponds to this oldev1 port", duplicating the resolution dpaa_ol_get_bh_port_name() already does at probe time. That logic only exists on the DPDK side.

Quoted 61 lines

Patch 2/4 drivers: add offline (O/H) port device support
--------------------------------------------------------

Error

dpaa_oldev_init() opens /dev/cdx_ctrl through check_fd() in dpaa_ol_tx_queue_init(). If a later step fails, for example the mac_addrs allocation, the free_rx path does not close the fd:

      free_rx:
              dpaa_oldev_queues_release(dpaa_intf);
              return ret;

dpaa_ol_probe() then calls rte_eth_dev_release_port(), which frees dev_private and ol_fd with it. Close it on the error path:

      free_rx:
              dpaa_oldev_queues_release(dpaa_intf);
              if (dpaa_intf->ol_fd >= 0) {
                      close(dpaa_intf->ol_fd);
                      dpaa_intf->ol_fd = -1;
              }
              return ret;

Warning

dpaa_oldev_queues_release() sends ASK_CTRL_RESET_DPDK_INFO and releases the FQIDs only if that succeeds. It does this even when ASK_CTRL_SET_DPDK_INFO was never issued: on the probe error path, and on close of a port that was never started. In those cases the kernel never had the FQIDs, so there is nothing to reset. If /dev/cdx_ctrl is missing, probe fails in dpaa_ol_tx_queue_init(), the reset fails with -ENODEV, and the Rx FQID allocated with QMAN_FQ_FLAG_DYNAMIC_FQID leaks on every attempt. Track whether the kernel holds the FQIDs:

      /* dpaa_ol_set_fq_info(), after ask_set_fq_info() succeeds */
      dpaa_intf->ol_fq_info_set = true;

      /* dpaa_oldev_queues_release() */
      release_fqids = true;
      if (dpaa_intf->ol_fq_info_set) {
              if (ask_reset_fq_info(dpaa_intf, &fq_info) != 0)
                      release_fqids = false;
              else
                      dpaa_intf->ol_fq_info_set = false;
      }

Info

v3 replaced the atomic ask_fd with a plain dpaa_intf->ol_fd, but kept the double- checked lock in check_fd(). The unlocked read of ol_fd now races with the locked write if control calls can be concurrent. If they cannot, the mutex is not needed. The fd is always opened during probe by dpaa_ol_tx_queue_init(), so open it once in dpaa_oldev_init() and drop fd_init_lock and the lazy open.

dpaa_ol_set_fq_info() copies bh_port_name with rte_memcpy(); this is control path, use memcpy().

The blank line added after "/* Rx Statistics Counter */" in struct dpaa_if_stats is unrelated.

#21 lore raw

v4 cover DPAA driver changes

In reply to Gagandeep Singh

V4-Changes:
- Fixed ol_fd leak issue.
- Fixed the FQID hold be kernel issue.
- removed the not required locks.
- fixed unwanted line and memcpy issue.
- We want to have rte_pmd_dpaa_ol_* functions, the reason we sent over the email.

V3-Changes:
- Updated rte_pmd_dpaa_oldev.h APIs as per DPDK compliance.
- Added missing release not for OH port support.
- Fixed dump_netcfg issue.
- Added an API to release FQID.
- moved the fman.h changes to first patch.

V2-changes:
- Fixed most of the AI comments.
- added new patch:
fix out-of-bounds read of mac_idx
- removed drv_oldev, updated comments and notes.
- fixes FQ shutdown
- removed unwanted checks, updated open, updated snprintf.
- updated commit messages.

V1:
- Adding OH port support.
- Updates in shared ethernet code.
- Congestion related code cleanup.

Gagandeep Singh (2):
bus/dpaa: fix out-of-bounds read of mac_idx array
drivers: add offline (O/H) port device support

Hemant Agrawal (1):
net/dpaa: support non fmX-macY type of shared Ethernet name

Jun Yang (1):
drivers: add DPAA cgrid cleanup support

 doc/api/doxy-api-index.md                |   1 +
 doc/guides/nics/dpaa.rst                 |  36 +
 doc/guides/rel_notes/release_26_11.rst   |  10 +
 drivers/bus/dpaa/base/fman/fman.c        |  19 +
 drivers/bus/dpaa/base/qbman/qman.c       |  61 ++
 drivers/bus/dpaa/bus_dpaa_driver.h       |   4 +-
 drivers/bus/dpaa/dpaa_bus.c              |  68 +-
 drivers/bus/dpaa/dpaa_bus_base_symbols.c |   2 +
 drivers/bus/dpaa/include/fman.h          |   6 +-
 drivers/bus/dpaa/include/fsl_qman.h      |  28 +
 drivers/net/dpaa/dpaa_ethdev.c           | 235 +++++-
 drivers/net/dpaa/dpaa_ethdev.h           |  12 +
 drivers/net/dpaa/dpaa_flow.c             |   5 +-
 drivers/net/dpaa/dpaa_oldev.c            | 936 +++++++++++++++++++++++
 drivers/net/dpaa/meson.build             |  11 +-
 drivers/net/dpaa/rte_pmd_dpaa_oldev.h    | 198 +++++
 16 files changed, 1601 insertions(+), 31 deletions(-)
 create mode 100644 drivers/net/dpaa/dpaa_oldev.c
 create mode 100644 drivers/net/dpaa/rte_pmd_dpaa_oldev.h
Signature · 1 line
2.25.1
#22 lore raw

PATCH v4 1/4 bus/dpaa: fix out-of-bounds read of mac_idx array

fman_if_init() and fman_if_init_onic() read the devicetree 'cell-index' property and store it unchecked into __if->__if.mac_idx. This value is later used as an index into the fixed-size mac_idx[] lookup table in fman_if_vsp_init(), so a cell-index value greater than or equal to the number of entries in that table results in an out-of-bounds read.

Add an explicit upper-bound check (FMAN_MAX_MAC_IDX_NUM) in both fman_if_init() and fman_if_init_onic() before the mac_idx assignment, and a static_assert in fman_if_vsp_init() to keep mac_idx[] in sync with FMAN_MAX_MAC_IDX_NUM if it is ever resized.

Also remove the unused MEMMAC_REG_OFFSET() macro from fman.h, which had no remaining callers.

Fixes a0edbb8a8e52 ("bus/dpaa: add OH port mode")
Fixes 7e5f49ae767d ("bus/dpaa: add ONIC port mode")
---
 drivers/bus/dpaa/base/fman/fman.c | 19 +++++++++++++++++++
 drivers/bus/dpaa/include/fman.h   |  6 +++++-
 drivers/net/dpaa/dpaa_flow.c      |  5 ++++-
 3 files changed, 28 insertions(+), 2 deletions(-)
drivers/bus/dpaa/base/fman/fman.c +19 -0
index 67f77265ca..223cd6958d 100644
@@ -205,6 +205,9 @@ static void fman_if_vsp_init(struct __fman_if *__if)
 	size_t lenp;
 	const uint8_t mac_idx[] = {-1, 0, 1, 2, 3, 4, 5, 6, 7, 0, 1};
 
+	static_assert(RTE_DIM(mac_idx) == FMAN_MAX_MAC_IDX_NUM,
+		      "mac_idx[] out of sync with FMAN_MAX_MAC_IDX_NUM");
+
 	if (__if->__if.mac_idx <= 8) {
 		for_each_compatible_node(dev, NULL,
 			"fsl,fman-port-1g-rx-extended-args") {
@@ -544,6 +547,14 @@ fman_if_init(const struct device_node *dpa_node, int fd)
 		cell_idx_host = of_read_number(cell_idx,
 					       lenp / sizeof(phandle));
 
+		if (cell_idx_host >= FMAN_MAX_MAC_IDX_NUM) {
+			FMAN_ERR(-EINVAL,
+				 "%s: cell-index(%" PRIu64 ") >= max(%d)",
+				 oh_node->full_name, cell_idx_host,
+				 FMAN_MAX_MAC_IDX_NUM);
+			goto err;
+		}
+
 		__if->__if.mac_idx = cell_idx_host;
 	}
 
@@ -957,6 +968,14 @@ static int fman_if_init_onic(const struct device_node *dpa_node)
 	assert(lenp == sizeof(*cell_idx));
 
 	cell_idx_host = of_read_number(cell_idx, lenp / sizeof(phandle));
+
+	if (cell_idx_host >= FMAN_MAX_MAC_IDX_NUM) {
+		FMAN_ERR(-EINVAL, "%s: cell-index(%" PRIu64 ") >= max(%d)",
+			 tx_oh_node->full_name, cell_idx_host,
+			 FMAN_MAX_MAC_IDX_NUM);
+		goto err;
+	}
+
 	__if->__if.mac_idx = cell_idx_host;
 
 	fman_node = of_get_parent(fman_tx_oh_node);
drivers/bus/dpaa/include/fman.h +5 -1
index f642faf3b3..030c85c284 100644
@@ -68,6 +68,11 @@
 #define FMAN_RTC_MAX_NUM_OF_PERIODIC_PULSES	4
 #define FMAN_RTC_MAX_NUM_OF_EXT_TRIGGERS	3
 
+/*
+ * Maximum number of MAC/offline port indexes.
+ */
+#define FMAN_MAX_MAC_IDX_NUM	11
+
 /* Represents the different flavour of network interface */
 enum fman_mac_type {
 	fman_offline_internal = 0,
@@ -475,7 +480,6 @@ struct __fman_if {
 	void *qmi_map;
 };
 
-#define MEMMAC_REG_OFFSET(reg) offsetof(struct memac_regs, reg)
 #define BMI_RX_REG_OFFSET(reg) offsetof(struct rx_bmi_regs, reg)
 #define BMI_TX_REG_OFFSET(reg) offsetof(struct tx_bmi_regs, reg)
 
drivers/net/dpaa/dpaa_flow.c +4 -1
index f77f9f333b..403e97ed2d 100644
@@ -32,9 +32,12 @@ return &scheme_params->param.key_ext_and_hash.extract_array[hdr_idx];
 	SCH_EXT_HDR(scheme_params, hdr_idx).extract_by_hdr_type.full_field
 
 /* FMAN mac indexes mappings (0 is unused, first 8 are for 1G, next for 10G
- * ports).
+ * ports). Indexed by fman_if.mac_idx, which the bus validates against
+ * FMAN_MAX_MAC_IDX_NUM when deriving it from the device tree.
  */
 static const uint8_t mac_idx[] = {-1, 0, 1, 2, 3, 4, 5, 6, 7, 0, 1};
+static_assert(RTE_DIM(mac_idx) == FMAN_MAX_MAC_IDX_NUM,
+	"mac_idx[] out of sync with FMAN_MAX_MAC_IDX_NUM");
 
 /* FM global info */
 struct dpaa_fm_info {
Signature · 1 line
2.25.1
#23 lore raw

PATCH v4 2/4 drivers: add offline (O/H) port device support

In reply to Gagandeep Singh

Add support for the DPAA Offline/Host-command (O/H) port, allowing a single OL port to be used by a DPDK application. The port is created by passing "-a dpaa_bus:oldev1" (plus any devargs) on the EAL command line, and the associated back-half port is named through the 'drv_bh_port' device argument.

---
 doc/api/doxy-api-index.md                |   1 +
 doc/guides/nics/dpaa.rst                 |  32 +
 doc/guides/rel_notes/release_26_11.rst   |  10 +
 drivers/bus/dpaa/bus_dpaa_driver.h       |   4 +-
 drivers/bus/dpaa/dpaa_bus.c              |  68 +-
 drivers/bus/dpaa/dpaa_bus_base_symbols.c |   1 +
 drivers/bus/dpaa/include/fsl_qman.h      |   1 +
 drivers/net/dpaa/dpaa_ethdev.h           |  12 +
 drivers/net/dpaa/dpaa_oldev.c            | 936 +++++++++++++++++++++++
 drivers/net/dpaa/meson.build             |  11 +-
 drivers/net/dpaa/rte_pmd_dpaa_oldev.h    | 198 +++++
 11 files changed, 1258 insertions(+), 16 deletions(-)
 create mode 100644 drivers/net/dpaa/dpaa_oldev.c
 create mode 100644 drivers/net/dpaa/rte_pmd_dpaa_oldev.h
doc/api/doxy-api-index.md +1 -0
index 62390f7be3..0bd8e1bbf0 100644
@@ -53,6 +53,7 @@ The public API headers are grouped by topics:
   [cnxk_eventdev](@ref rte_pmd_cnxk_eventdev.h),
   [cnxk_mempool](@ref rte_pmd_cnxk_mempool.h),
   [dpaa](@ref rte_pmd_dpaa.h),
+  [dpaa_oldev](@ref rte_pmd_dpaa_oldev.h),
   [dpaa2](@ref rte_pmd_dpaa2.h),
   [mlx5](@ref rte_pmd_mlx5.h),
   [dpaa2_mempool](@ref rte_dpaa2_mempool.h),
doc/guides/nics/dpaa.rst +32 -0
index c6aab46828..7658e6d454 100644
@@ -276,6 +276,38 @@ Refer to the document :doc:`build_and_test` for details.
   and thus disabling hardware based packet handling at driver level,
   e.g. ``dpaa:fm1-mac3,recv_err_pkts=1``.
 
+``drv_bh_port``
+   Name of the back-half port associated with an offline (O/H) port device.
+   It is passed on the offline port device itself, which is named
+   ``oldev1``, e.g. ``-a dpaa_bus:oldev1,drv_bh_port=fm1-mac5``.
+
+The DPAA offline (O/H) port device is only created, and therefore only
+probed, when it is explicitly named on the EAL ``-a`` command line, e.g.::
+
+   -a dpaa_bus:oldev1,drv_bh_port=fm1-mac5
+
+Passing any ``-a`` argument for the DPAA bus switches the bus to allowlist
+scan mode, so from that point on only the devices named with ``-a`` are
+probed. Using the offline port therefore requires listing the offline port
+itself and every Ethernet port the application needs, for example::
+
+   -a dpaa_bus:oldev1,drv_bh_port=fm1-mac5 \
+   -a dpaa_bus:fm1-mac5 -a dpaa_bus:fm1-mac6
+
+Omitting an ``fmX-macY`` port in that case silently drops that port.
+
+The offline port requires the ``/dev/cdx_ctrl`` kernel control device to be
+present; it is provided by the NXP vendor ``cdx`` kernel driver, which is
+not part of this DPDK driver and must be obtained and loaded separately
+(see the NXP LSDK release matching the DPAA SoC family). The uplink
+classification and local-gateway (LGW) configuration exposed through that
+control device can be programmed by the application, for the offline
+port identified by its ``port_id``, via the experimental
+``rte_pmd_dpaa_ol_set_classif_info()``, ``rte_pmd_dpaa_ol_reset_classif_info()``,
+``rte_pmd_dpaa_ol_set_lgw_info()`` and ``rte_pmd_dpaa_ol_reset_lgw_info()``
+APIs declared in ``rte_pmd_dpaa_oldev.h``.
+
+
 FMAN Config
 -----------
 
doc/guides/rel_notes/release_26_11.rst +10 -0
index e2b524ac0e..6c8ce83ce1 100644
@@ -210,6 +210,16 @@ New Features
   * Increased the maximum number of secondary unicast MAC addresses from 128 to up to 4096
     (depending on devlink configuration on the associated kernel netdevice).
 
+* **Added NXP DPAA offline (O/H) port support.**
+
+  Added a DPAA offline (O/H) port type that loops Rx/Tx frame queues through
+  the FMAN and exposes them as a DPDK port, with uplink classification and
+  LGW subnet configuration forwarded to the ASK/CDX kernel module via the
+  experimental ``rte_pmd_dpaa_ol_set_classif_info()``,
+  ``rte_pmd_dpaa_ol_reset_classif_info()``, ``rte_pmd_dpaa_ol_set_lgw_info()``
+  and ``rte_pmd_dpaa_ol_reset_lgw_info()`` APIs declared in
+  ``rte_pmd_dpaa_oldev.h``.
+
 * **Updated NXP DPAA drivers.**
 
   * Changed the default number of Rx queues in FMCLESS mode
drivers/bus/dpaa/bus_dpaa_driver.h +3 -1
index 4aed83f84d..323a6a7659 100644
@@ -69,11 +69,13 @@ struct rte_dpaa_driver;
 enum rte_dpaa_type {
 	FSL_DPAA_ETH = 1,
 	FSL_DPAA_CRYPTO,
-	FSL_DPAA_QDMA
+	FSL_DPAA_QDMA,
+	FSL_DPAA_OL
 };
 
 struct dpaa_device_id {
 	uint8_t fman_id; /**< Fman interface ID, for ETH type device */
+	uint8_t ol_id;	/**< OH interface ID, for OH type device */
 	uint8_t mac_id; /**< Fman MAC interface ID, for ETH type device */
 	uint16_t dev_id; /**< Device Identifier from DPDK */
 };
drivers/bus/dpaa/dpaa_bus.c +58 -10

131 lines not on this page · raw message

drivers/bus/dpaa/dpaa_bus_base_symbols.c +1 -0
index 0927e5fe2c..aaa9f9bec2 100644
@@ -52,6 +52,7 @@ RTE_EXPORT_INTERNAL_SYMBOL(bman_acquire)
 RTE_EXPORT_INTERNAL_SYMBOL(bman_query_free_buffers)
 RTE_EXPORT_INTERNAL_SYMBOL(bman_thread_irq)
 RTE_EXPORT_INTERNAL_SYMBOL(qman_alloc_fqid_range)
+RTE_EXPORT_INTERNAL_SYMBOL(qman_release_fqid_range)
 RTE_EXPORT_INTERNAL_SYMBOL(qman_reserve_fqid_range)
 RTE_EXPORT_INTERNAL_SYMBOL(qman_alloc_pool_range)
 RTE_EXPORT_INTERNAL_SYMBOL(qman_alloc_cgrid_range)
drivers/bus/dpaa/include/fsl_qman.h +1 -0
index 59b41e17f0..b2674ce5d0 100644
@@ -1895,6 +1895,7 @@ static inline int qman_alloc_fqid(u32 *result)
  * This function can also be used to seed the allocator with ranges of FQIDs
  * that it can subsequently allocate from.
  */
+__rte_internal
 void qman_release_fqid_range(u32 fqid, unsigned int count);
 static inline void qman_release_fqid(u32 fqid)
 {
drivers/net/dpaa/dpaa_ethdev.h +12 -0
index 47c8e2b086..c7f9184810 100644
@@ -114,6 +114,10 @@ enum {
 
 #define DPAA_DEFAULT_RXQ_VSP_ID		1
 
+/* Device argument to name the offline (O/H) port back-half port */
+#define DRIVER_OL_BH_PORT		"drv_bh_port"
+#define DPAA_OL_MAX_BH_PORT_NAME_LEN	12
+
 #define FMC_FILE "/tmp/fmc.bin"
 
 struct dpaa_if_vsp {
@@ -173,6 +177,14 @@ struct dpaa_if {
 	struct qman_fq *next_tx_conf_queue;
 
 	struct dpaa_if_vsp vsp[DPAA_VSP_PROFILE_MAX_NUM];
+
+	/* Control device fd, used by the offline port PMD only. */
+	int ol_fd;
+	/* Backhaul port name from the drv_bh_port devarg, used by the
+	 * offline port PMD only.
+	 */
+	char ol_bh_port_name[DPAA_OL_MAX_BH_PORT_NAME_LEN];
+	bool ol_fq_info_set;
 };
 
 struct dpaa_if_stats {
drivers/net/dpaa/dpaa_oldev.c new file +936 -0

936 lines not on this page · raw message

drivers/net/dpaa/meson.build +6 -5
index 8d4f69c596..3ec1091197 100644
@@ -1,5 +1,5 @@
 # SPDX-License-Identifier: BSD-3-Clause
-# Copyright 2018-2020 NXP
+# Copyright 2018-2020,2026 NXP
 
 if not is_linux
     build = false
@@ -9,12 +9,13 @@ deps += ['mempool_dpaa']
 
 sources = files(
         'dpaa_ethdev.c',
-        'fmlib/fm_lib.c',
-        'fmlib/fm_vsp.c',
         'dpaa_flow.c',
-        'dpaa_rxtx.c',
         'dpaa_fmc.c',
         'dpaa_ptp.c',
+        'dpaa_oldev.c',
+        'dpaa_rxtx.c',
+        'fmlib/fm_lib.c',
+        'fmlib/fm_vsp.c',
 )
 
 cflags += no_wvla_cflag
@@ -24,4 +25,4 @@ if cc.has_argument('-Wno-pointer-arith')
     cflags += '-Wno-pointer-arith'
 endif
 
-headers = files('rte_pmd_dpaa.h')
+headers = files('rte_pmd_dpaa.h', 'rte_pmd_dpaa_oldev.h')
drivers/net/dpaa/rte_pmd_dpaa_oldev.h new file +198 -0

198 lines not on this page · raw message

Signature · 1 line
2.25.1
#24 lore raw

PATCH v4 3/4 net/dpaa: support non fmX-macY type of shared Ethernet name

In reply to Gagandeep Singh

From: Hemant Agrawal <[email protected]>

A shared MAC interface needs the kernel netdev name to read the MTU, and that name is only the DPDK port name for fmX-macY style netdevs.

Look it up in sysfs under the platform device of the dpa-ethernet node the port was created from, and fall back to the port name.

---
 doc/guides/nics/dpaa.rst       |  6 ++-
 drivers/net/dpaa/dpaa_ethdev.c | 68 +++++++++++++++++++++++++++++++++-
 2 files changed, 72 insertions(+), 2 deletions(-)
doc/guides/nics/dpaa.rst +5 -1
index 7658e6d454..d391c0607f 100644
@@ -276,6 +276,11 @@ Refer to the document :doc:`build_and_test` for details.
   and thus disabling hardware based packet handling at driver level,
   e.g. ``dpaa:fm1-mac3,recv_err_pkts=1``.
 
+* For a shared MAC interface the kernel network interface name is looked up
+  in sysfs from the device tree node the port was created from,
+  so a kernel interface that does not follow
+  the ``fmX-macY`` naming style is handled without extra configuration.
+
 ``drv_bh_port``
    Name of the back-half port associated with an offline (O/H) port device.
    It is passed on the offline port device itself, which is named
@@ -307,7 +312,6 @@ port identified by its ``port_id``, via the experimental
 ``rte_pmd_dpaa_ol_set_lgw_info()`` and ``rte_pmd_dpaa_ol_reset_lgw_info()``
 APIs declared in ``rte_pmd_dpaa_oldev.h``.
 
-
 FMAN Config
 -----------
 
drivers/net/dpaa/dpaa_ethdev.c +67 -1

98 lines not on this page · raw message

Signature · 1 line
2.25.1
#25 lore raw

PATCH v4 4/4 drivers: add DPAA cgrid cleanup support

In reply to Gagandeep Singh

From: Jun Yang <[email protected]>

A congestion group must have no member frame queues left when it is deleted, and its CGRID must be returned to the allocator once the group is gone. Neither was handled on the net/dpaa close and probe-failure paths.

This also changes probe behaviour: a qman_create_cgr() failure in dpaa_rx_queue_init() or dpaa_tx_queue_init() now fails the probe instead of continuing without tail drop on that queue. The probe error path deletes one CGR per initialised queue, and a CGR whose creation failed was never linked into the portal list.

Fixes 62f53995caaf ("net/dpaa: add frame count based tail drop with CGR")
Fixes 9124e65dd3eb ("net/dpaa: enable Tx queue taildrop")
---
 drivers/bus/dpaa/base/qbman/qman.c       |  61 +++++++++
 drivers/bus/dpaa/dpaa_bus_base_symbols.c |   1 +
 drivers/bus/dpaa/include/fsl_qman.h      |  27 ++++
 drivers/net/dpaa/dpaa_ethdev.c           | 167 +++++++++++++++++++++--
 4 files changed, 244 insertions(+), 12 deletions(-)
drivers/bus/dpaa/base/qbman/qman.c +61 -0
index 3c056e4547..fa3387c6bd 100644
@@ -2993,3 +2993,64 @@ qman_shutdown_fq(struct qman_fq *fq)
 out:
 	return ret;
 }
+
+int qman_pending_fq_by_cgrid_range(u32 cgrid_start, u32 cgrid_num,
+	u32 start_fqid, u32 *fqid, u32 *cgrid)
+{
+	struct qman_fq fq = {
+		.fqid = start_fqid ? start_fqid : 1
+	};
+	struct qm_mcr_queryfq_np np;
+	struct qm_fqd fqd;
+	int err;
+
+	/*
+	 * Do not use the CGR byte count to decide whether to scan. An FQ is a
+	 * member of the group whenever it is scheduled with CGE set and a
+	 * matching cgid, whether or not it currently holds any frames, and the
+	 * group cannot be deleted while such a member exists. Skipping the
+	 * scan for an empty CGR would let an idle stale FQ survive and its
+	 * CGRID be released while still referenced. This runs from the device
+	 * close path only, so the scan cost is acceptable.
+	 *
+	 * The whole CGRID range of a port is matched in a single pass, so a
+	 * port with many congestion groups does not need one full FQID space
+	 * scan per group.
+	 */
+	DPAA_BUS_DEBUG("Scanning FQs for cgrid(0x%x..0x%x)",
+		cgrid_start, cgrid_start + cgrid_num - 1);
+
+	/* FQID space is 24 bits wide; stop before wrapping. */
+	for (; fq.fqid <= QMAN_MAX_FQID; fq.fqid++) {
+		err = qman_query_fq_np(&fq, &np);
+		if (err == -ERANGE) {
+			/*
+			 * FQID is not implemented on this device, so there is
+			 * nothing beyond it either.
+			 */
+			break;
+		} else if (err) {
+			DPAA_BUS_WARN("Failed(%d) to Query np FQ(fqid=0x%x)",
+				err, fq.fqid);
+			return err;
+		}
+		if ((np.state & QM_MCR_NP_STATE_MASK) != QM_MCR_NP_STATE_OOS) {
+			err = qman_query_fq(&fq, &fqd);
+			if (err) {
+				DPAA_BUS_WARN("Failed(%d) to Query FQ(fqid=0x%x)",
+					err, fq.fqid);
+			} else if ((fqd.fq_ctrl & QM_FQCTRL_CGE) &&
+				fqd.cgid >= cgrid_start &&
+				fqd.cgid < cgrid_start + cgrid_num) {
+				if (fqid)
+					*fqid = fq.fqid;
+				if (cgrid)
+					*cgrid = fqd.cgid;
+				return 0;
+			}
+		}
+	}
+	DPAA_BUS_DEBUG("No FQ left in cgrid(0x%x..0x%x)",
+		cgrid_start, cgrid_start + cgrid_num - 1);
+	return -ERANGE;
+}
drivers/bus/dpaa/dpaa_bus_base_symbols.c +1 -0
index aaa9f9bec2..4da43f293d 100644
@@ -57,6 +57,7 @@ RTE_EXPORT_INTERNAL_SYMBOL(qman_reserve_fqid_range)
 RTE_EXPORT_INTERNAL_SYMBOL(qman_alloc_pool_range)
 RTE_EXPORT_INTERNAL_SYMBOL(qman_alloc_cgrid_range)
 RTE_EXPORT_INTERNAL_SYMBOL(qman_release_cgrid_range)
+RTE_EXPORT_INTERNAL_SYMBOL(qman_pending_fq_by_cgrid_range)
 RTE_EXPORT_INTERNAL_SYMBOL(dpaa_intr_enable)
 RTE_EXPORT_INTERNAL_SYMBOL(dpaa_intr_disable)
 RTE_EXPORT_INTERNAL_SYMBOL(dpaa_get_ioctl_version_number)
drivers/bus/dpaa/include/fsl_qman.h +27 -0
index b2674ce5d0..6d76722275 100644
@@ -1284,6 +1284,9 @@ struct qman_cgr {
  */
 #define QMAN_FQRN_WAIT_MAX		10000000u
 
+/* Maximum FQID value: frame queue IDs are 24 bits wide. */
+#define QMAN_MAX_FQID			0x00FFFFFFu
+
 /* Flags to qman_create_fq() */
 #define QMAN_FQ_FLAG_NO_ENQUEUE      0x00000001 /* can't enqueue */
 #define QMAN_FQ_FLAG_NO_MODIFY       0x00000002 /* can only enqueue */
@@ -1916,6 +1919,30 @@ static inline int qman_shutdown_fq_by_fqid(u32 fqid)
 	return qman_shutdown_fq(&fq);
 }
 
+/**
+ * qman_pending_fq_by_cgrid_range - Find an FQ still attached to a CGR range.
+ *
+ * @cgrid_start: first congestion group id of the range to search for.
+ * @cgrid_num: number of consecutive congestion group ids in the range.
+ * @start_fqid: FQID to begin the scan from (0 or 1 means scan from the
+ *   start). A caller shutting down several stale FQs can pass the previously
+ *   returned FQID + 1 to resume the scan instead of restarting from the
+ *   beginning each time.
+ * @fqid: on success, holds the FQID that is still attached to the range.
+ * @cgrid: on success, holds the congestion group id that FQ belongs to.
+ *   May be NULL.
+ *
+ * Matching a whole range in one pass lets a caller with many congestion
+ * groups, such as a port releasing all of its Rx or Tx CGRs, avoid one full
+ * FQID space scan per group.
+ *
+ * Return 0 and set *fqid when a matching FQ is found, -ERANGE when none is
+ * left, or a negative error code on query failure.
+ */
+__rte_internal
+int qman_pending_fq_by_cgrid_range(u32 cgrid_start, u32 cgrid_num,
+		u32 start_fqid, u32 *fqid, u32 *cgrid);
+
 /**
  * qman_reserve_fqid_range - Reserve the specified range of frame queue IDs
  * @fqid: the base FQID of the range to deallocate
drivers/net/dpaa/dpaa_ethdev.c +155 -12

288 lines not on this page · raw message

Signature · 1 line
2.25.1
#26 lore raw
In reply to Gagandeep Singh
Quoted 7 lines · On Mon, 16 Nov 2026 11:55:08 +0530 Gagandeep Singh <[email protected]> wrote:

V4-Changes:
- Fixed ol_fd leak issue.
- Fixed the FQID hold be kernel issue.
- removed the not required locks.
- fixed unwanted line and memcpy issue.
- We want to have rte_pmd_dpaa_ol_* functions, the reason we sent over the email.

Still some findings from AI review

Subject: Re: [PATCH v4 0/4] DPAA offline port, shared MAC name, cgrid cleanup

Series applies to main and builds at every commit (bus/dpaa, mempool/dpaa, net/dpaa, -Dwerror=true). Patches 1 and 3 have no findings.

Patch 2/4 drivers: add offline (O/H) port device support
---------------------------------------------------------

Warning: FQ info set in dev_start but only reset in dev_close.

dpaa_ol_dev_start() sends ASK_CTRL_SET_DPDK_INFO on every start; dpaa_ol_dev_stop() only swaps the Tx burst. After stop the kernel keeps steering frames into the Rx FQ using buffers from the DPDK pool, and a stop/start cycle issues a second SET with no RESET in between. Pair them: reset in stop, set in start.

  static int dpaa_ol_reset_fq_info(struct dpaa_if *dpaa_intf)
  {
          struct ask_ctrl_dpdk_fq_info_s fq_info = { 0 };
          int ret;
          if (!dpaa_intf->ol_fq_info_set)
                  return 0;
          fq_info.tx_fq_id = dpaa_intf->tx_queues[0].fqid;
          fq_info.rx_fq_id = dpaa_intf->rx_queues[0].fqid;
          ret = ask_reset_fq_info(dpaa_intf, &fq_info);
          if (ret == 0)
                  dpaa_intf->ol_fq_info_set = false;
          return ret;

}

  static int dpaa_ol_dev_stop(struct rte_eth_dev *dev)
  {
          dev->tx_pkt_burst = dpaa_eth_tx_drop_all;
          return dpaa_ol_reset_fq_info(dev->data->dev_private);
  }

dpaa_oldev_queues_release() can then call the same helper.

Warning: received mbufs carry the wrong port id.

dpaa_eth_fd_to_mbuf() sets mbuf->port = dpaa_intf->ifid. ifid is never set for the offline port, so it stays 0 from rte_zmalloc(). The oldev sorts after all ETH devices on the bus, so port 0 is always some other port. Set it in dpaa_oldev_init():

  dpaa_intf->ifid = eth_dev->data->port_id;

Info: struct ask_ctrl_dpdk_fq_info_s is an ioctl ABI shared with an out-of-tree module, but it uses bool members, implicit padding and no version check. The public rte_pmd_dpaa_*_s structs are passed straight to the same ioctls, so their layout is now frozen by the CDX module rather than by DPDK. Consider fixed-width types and a version query at probe so a mismatched cdx module fails cleanly.

Patch 4/4 drivers: add DPAA cgrid cleanup support
-------------------------------------------------

Warning: stale FQ scan runs at close, after the CGRs have been in use for the whole run.

If a stale FQ from a previous run still references a CGRID handed out at probe, it is a member of this port's CGR from the moment qman_create_cgr() runs; its frames count against the tail-drop thresholds for the life of the port. Removing it at close is too late. Do the scan in dpaa_dev_init() right after qman_alloc_cgrid_range(), before any CGR is created:

  ret = qman_alloc_cgrid_range(&cgrid[0], num_rx_fqs, 1, 0);
  ...
  if (!dpaa_cgr_stale_fq_cleanup(eth_dev, cgrid[0],
                                 num_rx_fqs, "rx")) {
          ret = -EBUSY;
          goto free_rx;
  }

and the same for cgrid_tx. Close then only needs to shut down the port's own FQs.

Warning: dpaa_cgr_stale_fq_cleanup() returns true when max_loop is exhausted.

The comment says true means the range was fully scanned. If the loop runs out after cgrid_num * DPAA_CGR_STALE_FQ_MAX shutdowns, more stale FQs may remain, yet cgrid_ok stays true and the CGRIDs are released while still referenced. Fall out of the loop with false:

          start_fqid = fqid + 1;
  }
  DPAA_PMD_WARN("%s: stale %s FQ limit reached",
                dev->data->name, dir);

return false;

Info: qman_pending_fq_by_cgrid_range() walks every implemented FQID with up to two management commands each, and close runs it twice per port (Rx and Tx). With several ports this is a noticeable stall on shutdown. If the scan moves to probe as suggested, one combined pass over all of the port's CGRIDs (Rx and Tx are both known by then) would halve it.

#27 lore raw

v5 cover DPAA driver changes

In reply to Gagandeep Singh

V5-Changes:
- Added a reset FQ helper as per the AI suggestion
- Fixed the portid issue.
- Added explicit padding, uint8_t, size checks. The version ioctl is not avilable in CDX module as of now, so mismatch module will fails at probe only through existing ioctl errors.
- Fixed stale FQs run at close issue.
- Added a AI suggested warning.
- The scan moved to probe, close no longer scans. A single combined pass would need the Tx CGRIDs before the Rx CGRs are created and a scan that takes two ranges, which is too big for this series and saves only one scan per port at startup.

V4-Changes:
- Fixed ol_fd leak issue.
- Fixed the FQID hold be kernel issue.
- removed the not required locks.
- fixed unwanted line and memcpy issue.
- We want to have rte_pmd_dpaa_ol_* functions, the reason we sent over the email.

V3-Changes:
- Updated rte_pmd_dpaa_oldev.h APIs as per DPDK compliance.
- Added missing release not for OH port support.
- Fixed dump_netcfg issue.
- Added an API to release FQID.
- moved the fman.h changes to first patch.

V2-changes:
- Fixed most of the AI comments.
- added new patch:
fix out-of-bounds read of mac_idx
- removed drv_oldev, updated comments and notes.
- fixes FQ shutdown
- removed unwanted checks, updated open, updated snprintf.
- updated commit messages.

V1:
- Adding OH port support.
- Updates in shared ethernet code.
- Congestion related code cleanup.

Gagandeep Singh (2):
bus/dpaa: fix out-of-bounds read of mac_idx array
drivers: add offline (O/H) port device support

Hemant Agrawal (1):
net/dpaa: support non fmX-macY type of shared Ethernet name

Jun Yang (1):
drivers: add DPAA cgrid cleanup support

 doc/api/doxy-api-index.md                |   1 +
 doc/guides/nics/dpaa.rst                 |  36 +
 doc/guides/rel_notes/release_26_11.rst   |  10 +
 drivers/bus/dpaa/base/fman/fman.c        |  19 +
 drivers/bus/dpaa/base/qbman/qman.c       |  61 ++
 drivers/bus/dpaa/bus_dpaa_driver.h       |   4 +-
 drivers/bus/dpaa/dpaa_bus.c              |  68 +-
 drivers/bus/dpaa/dpaa_bus_base_symbols.c |   2 +
 drivers/bus/dpaa/include/fman.h          |   6 +-
 drivers/bus/dpaa/include/fsl_qman.h      |  28 +
 drivers/net/dpaa/dpaa_ethdev.c           | 234 +++++-
 drivers/net/dpaa/dpaa_ethdev.h           |  12 +
 drivers/net/dpaa/dpaa_flow.c             |   5 +-
 drivers/net/dpaa/dpaa_oldev.c            | 959 +++++++++++++++++++++++
 drivers/net/dpaa/meson.build             |  11 +-
 drivers/net/dpaa/rte_pmd_dpaa_oldev.h    | 198 +++++
 16 files changed, 1623 insertions(+), 31 deletions(-)
 create mode 100644 drivers/net/dpaa/dpaa_oldev.c
 create mode 100644 drivers/net/dpaa/rte_pmd_dpaa_oldev.h
Signature · 1 line
2.25.1
#28 lore raw

PATCH v5 1/4 bus/dpaa: fix out-of-bounds read of mac_idx array

fman_if_init() and fman_if_init_onic() read the devicetree 'cell-index' property and store it unchecked into __if->__if.mac_idx. This value is later used as an index into the fixed-size mac_idx[] lookup table in fman_if_vsp_init(), so a cell-index value greater than or equal to the number of entries in that table results in an out-of-bounds read.

Add an explicit upper-bound check (FMAN_MAX_MAC_IDX_NUM) in both fman_if_init() and fman_if_init_onic() before the mac_idx assignment, and a static_assert in fman_if_vsp_init() to keep mac_idx[] in sync with FMAN_MAX_MAC_IDX_NUM if it is ever resized.

Also remove the unused MEMMAC_REG_OFFSET() macro from fman.h, which had no remaining callers.

Fixes a0edbb8a8e52 ("bus/dpaa: add OH port mode")
Fixes 7e5f49ae767d ("bus/dpaa: add ONIC port mode")
---
 drivers/bus/dpaa/base/fman/fman.c | 19 +++++++++++++++++++
 drivers/bus/dpaa/include/fman.h   |  6 +++++-
 drivers/net/dpaa/dpaa_flow.c      |  5 ++++-
 3 files changed, 28 insertions(+), 2 deletions(-)
drivers/bus/dpaa/base/fman/fman.c +19 -0
index 67f77265ca..223cd6958d 100644
@@ -205,6 +205,9 @@ static void fman_if_vsp_init(struct __fman_if *__if)
 	size_t lenp;
 	const uint8_t mac_idx[] = {-1, 0, 1, 2, 3, 4, 5, 6, 7, 0, 1};
 
+	static_assert(RTE_DIM(mac_idx) == FMAN_MAX_MAC_IDX_NUM,
+		      "mac_idx[] out of sync with FMAN_MAX_MAC_IDX_NUM");
+
 	if (__if->__if.mac_idx <= 8) {
 		for_each_compatible_node(dev, NULL,
 			"fsl,fman-port-1g-rx-extended-args") {
@@ -544,6 +547,14 @@ fman_if_init(const struct device_node *dpa_node, int fd)
 		cell_idx_host = of_read_number(cell_idx,
 					       lenp / sizeof(phandle));
 
+		if (cell_idx_host >= FMAN_MAX_MAC_IDX_NUM) {
+			FMAN_ERR(-EINVAL,
+				 "%s: cell-index(%" PRIu64 ") >= max(%d)",
+				 oh_node->full_name, cell_idx_host,
+				 FMAN_MAX_MAC_IDX_NUM);
+			goto err;
+		}
+
 		__if->__if.mac_idx = cell_idx_host;
 	}
 
@@ -957,6 +968,14 @@ static int fman_if_init_onic(const struct device_node *dpa_node)
 	assert(lenp == sizeof(*cell_idx));
 
 	cell_idx_host = of_read_number(cell_idx, lenp / sizeof(phandle));
+
+	if (cell_idx_host >= FMAN_MAX_MAC_IDX_NUM) {
+		FMAN_ERR(-EINVAL, "%s: cell-index(%" PRIu64 ") >= max(%d)",
+			 tx_oh_node->full_name, cell_idx_host,
+			 FMAN_MAX_MAC_IDX_NUM);
+		goto err;
+	}
+
 	__if->__if.mac_idx = cell_idx_host;
 
 	fman_node = of_get_parent(fman_tx_oh_node);
drivers/bus/dpaa/include/fman.h +5 -1
index f642faf3b3..030c85c284 100644
@@ -68,6 +68,11 @@
 #define FMAN_RTC_MAX_NUM_OF_PERIODIC_PULSES	4
 #define FMAN_RTC_MAX_NUM_OF_EXT_TRIGGERS	3
 
+/*
+ * Maximum number of MAC/offline port indexes.
+ */
+#define FMAN_MAX_MAC_IDX_NUM	11
+
 /* Represents the different flavour of network interface */
 enum fman_mac_type {
 	fman_offline_internal = 0,
@@ -475,7 +480,6 @@ struct __fman_if {
 	void *qmi_map;
 };
 
-#define MEMMAC_REG_OFFSET(reg) offsetof(struct memac_regs, reg)
 #define BMI_RX_REG_OFFSET(reg) offsetof(struct rx_bmi_regs, reg)
 #define BMI_TX_REG_OFFSET(reg) offsetof(struct tx_bmi_regs, reg)
 
drivers/net/dpaa/dpaa_flow.c +4 -1
index f77f9f333b..403e97ed2d 100644
@@ -32,9 +32,12 @@ return &scheme_params->param.key_ext_and_hash.extract_array[hdr_idx];
 	SCH_EXT_HDR(scheme_params, hdr_idx).extract_by_hdr_type.full_field
 
 /* FMAN mac indexes mappings (0 is unused, first 8 are for 1G, next for 10G
- * ports).
+ * ports). Indexed by fman_if.mac_idx, which the bus validates against
+ * FMAN_MAX_MAC_IDX_NUM when deriving it from the device tree.
  */
 static const uint8_t mac_idx[] = {-1, 0, 1, 2, 3, 4, 5, 6, 7, 0, 1};
+static_assert(RTE_DIM(mac_idx) == FMAN_MAX_MAC_IDX_NUM,
+	"mac_idx[] out of sync with FMAN_MAX_MAC_IDX_NUM");
 
 /* FM global info */
 struct dpaa_fm_info {
Signature · 1 line
2.25.1
#29 lore raw

PATCH v5 2/4 drivers: add offline (O/H) port device support

In reply to Gagandeep Singh

Add support for the DPAA Offline/Host-command (O/H) port, allowing a single OL port to be used by a DPDK application. The port is created by passing "-a dpaa_bus:oldev1" (plus any devargs) on the EAL command line, and the associated back-half port is named through the 'drv_bh_port' device argument.

---
 doc/api/doxy-api-index.md                |   1 +
 doc/guides/nics/dpaa.rst                 |  32 +
 doc/guides/rel_notes/release_26_11.rst   |  10 +
 drivers/bus/dpaa/bus_dpaa_driver.h       |   4 +-
 drivers/bus/dpaa/dpaa_bus.c              |  68 +-
 drivers/bus/dpaa/dpaa_bus_base_symbols.c |   1 +
 drivers/bus/dpaa/include/fsl_qman.h      |   1 +
 drivers/net/dpaa/dpaa_ethdev.h           |  12 +
 drivers/net/dpaa/dpaa_oldev.c            | 959 +++++++++++++++++++++++
 drivers/net/dpaa/meson.build             |  11 +-
 drivers/net/dpaa/rte_pmd_dpaa_oldev.h    | 198 +++++
 11 files changed, 1281 insertions(+), 16 deletions(-)
 create mode 100644 drivers/net/dpaa/dpaa_oldev.c
 create mode 100644 drivers/net/dpaa/rte_pmd_dpaa_oldev.h
doc/api/doxy-api-index.md +1 -0
index 62390f7be3..0bd8e1bbf0 100644
@@ -53,6 +53,7 @@ The public API headers are grouped by topics:
   [cnxk_eventdev](@ref rte_pmd_cnxk_eventdev.h),
   [cnxk_mempool](@ref rte_pmd_cnxk_mempool.h),
   [dpaa](@ref rte_pmd_dpaa.h),
+  [dpaa_oldev](@ref rte_pmd_dpaa_oldev.h),
   [dpaa2](@ref rte_pmd_dpaa2.h),
   [mlx5](@ref rte_pmd_mlx5.h),
   [dpaa2_mempool](@ref rte_dpaa2_mempool.h),
doc/guides/nics/dpaa.rst +32 -0
index c6aab46828..7658e6d454 100644
@@ -276,6 +276,38 @@ Refer to the document :doc:`build_and_test` for details.
   and thus disabling hardware based packet handling at driver level,
   e.g. ``dpaa:fm1-mac3,recv_err_pkts=1``.
 
+``drv_bh_port``
+   Name of the back-half port associated with an offline (O/H) port device.
+   It is passed on the offline port device itself, which is named
+   ``oldev1``, e.g. ``-a dpaa_bus:oldev1,drv_bh_port=fm1-mac5``.
+
+The DPAA offline (O/H) port device is only created, and therefore only
+probed, when it is explicitly named on the EAL ``-a`` command line, e.g.::
+
+   -a dpaa_bus:oldev1,drv_bh_port=fm1-mac5
+
+Passing any ``-a`` argument for the DPAA bus switches the bus to allowlist
+scan mode, so from that point on only the devices named with ``-a`` are
+probed. Using the offline port therefore requires listing the offline port
+itself and every Ethernet port the application needs, for example::
+
+   -a dpaa_bus:oldev1,drv_bh_port=fm1-mac5 \
+   -a dpaa_bus:fm1-mac5 -a dpaa_bus:fm1-mac6
+
+Omitting an ``fmX-macY`` port in that case silently drops that port.
+
+The offline port requires the ``/dev/cdx_ctrl`` kernel control device to be
+present; it is provided by the NXP vendor ``cdx`` kernel driver, which is
+not part of this DPDK driver and must be obtained and loaded separately
+(see the NXP LSDK release matching the DPAA SoC family). The uplink
+classification and local-gateway (LGW) configuration exposed through that
+control device can be programmed by the application, for the offline
+port identified by its ``port_id``, via the experimental
+``rte_pmd_dpaa_ol_set_classif_info()``, ``rte_pmd_dpaa_ol_reset_classif_info()``,
+``rte_pmd_dpaa_ol_set_lgw_info()`` and ``rte_pmd_dpaa_ol_reset_lgw_info()``
+APIs declared in ``rte_pmd_dpaa_oldev.h``.
+
+
 FMAN Config
 -----------
 
doc/guides/rel_notes/release_26_11.rst +10 -0
index e2b524ac0e..6c8ce83ce1 100644
@@ -210,6 +210,16 @@ New Features
   * Increased the maximum number of secondary unicast MAC addresses from 128 to up to 4096
     (depending on devlink configuration on the associated kernel netdevice).
 
+* **Added NXP DPAA offline (O/H) port support.**
+
+  Added a DPAA offline (O/H) port type that loops Rx/Tx frame queues through
+  the FMAN and exposes them as a DPDK port, with uplink classification and
+  LGW subnet configuration forwarded to the ASK/CDX kernel module via the
+  experimental ``rte_pmd_dpaa_ol_set_classif_info()``,
+  ``rte_pmd_dpaa_ol_reset_classif_info()``, ``rte_pmd_dpaa_ol_set_lgw_info()``
+  and ``rte_pmd_dpaa_ol_reset_lgw_info()`` APIs declared in
+  ``rte_pmd_dpaa_oldev.h``.
+
 * **Updated NXP DPAA drivers.**
 
   * Changed the default number of Rx queues in FMCLESS mode
drivers/bus/dpaa/bus_dpaa_driver.h +3 -1
index 4aed83f84d..323a6a7659 100644
@@ -69,11 +69,13 @@ struct rte_dpaa_driver;
 enum rte_dpaa_type {
 	FSL_DPAA_ETH = 1,
 	FSL_DPAA_CRYPTO,
-	FSL_DPAA_QDMA
+	FSL_DPAA_QDMA,
+	FSL_DPAA_OL
 };
 
 struct dpaa_device_id {
 	uint8_t fman_id; /**< Fman interface ID, for ETH type device */
+	uint8_t ol_id;	/**< OH interface ID, for OH type device */
 	uint8_t mac_id; /**< Fman MAC interface ID, for ETH type device */
 	uint16_t dev_id; /**< Device Identifier from DPDK */
 };
drivers/bus/dpaa/dpaa_bus.c +58 -10

131 lines not on this page · raw message

drivers/bus/dpaa/dpaa_bus_base_symbols.c +1 -0
index 0927e5fe2c..aaa9f9bec2 100644
@@ -52,6 +52,7 @@ RTE_EXPORT_INTERNAL_SYMBOL(bman_acquire)
 RTE_EXPORT_INTERNAL_SYMBOL(bman_query_free_buffers)
 RTE_EXPORT_INTERNAL_SYMBOL(bman_thread_irq)
 RTE_EXPORT_INTERNAL_SYMBOL(qman_alloc_fqid_range)
+RTE_EXPORT_INTERNAL_SYMBOL(qman_release_fqid_range)
 RTE_EXPORT_INTERNAL_SYMBOL(qman_reserve_fqid_range)
 RTE_EXPORT_INTERNAL_SYMBOL(qman_alloc_pool_range)
 RTE_EXPORT_INTERNAL_SYMBOL(qman_alloc_cgrid_range)
drivers/bus/dpaa/include/fsl_qman.h +1 -0
index 59b41e17f0..b2674ce5d0 100644
@@ -1895,6 +1895,7 @@ static inline int qman_alloc_fqid(u32 *result)
  * This function can also be used to seed the allocator with ranges of FQIDs
  * that it can subsequently allocate from.
  */
+__rte_internal
 void qman_release_fqid_range(u32 fqid, unsigned int count);
 static inline void qman_release_fqid(u32 fqid)
 {
drivers/net/dpaa/dpaa_ethdev.h +12 -0
index 47c8e2b086..c7f9184810 100644
@@ -114,6 +114,10 @@ enum {
 
 #define DPAA_DEFAULT_RXQ_VSP_ID		1
 
+/* Device argument to name the offline (O/H) port back-half port */
+#define DRIVER_OL_BH_PORT		"drv_bh_port"
+#define DPAA_OL_MAX_BH_PORT_NAME_LEN	12
+
 #define FMC_FILE "/tmp/fmc.bin"
 
 struct dpaa_if_vsp {
@@ -173,6 +177,14 @@ struct dpaa_if {
 	struct qman_fq *next_tx_conf_queue;
 
 	struct dpaa_if_vsp vsp[DPAA_VSP_PROFILE_MAX_NUM];
+
+	/* Control device fd, used by the offline port PMD only. */
+	int ol_fd;
+	/* Backhaul port name from the drv_bh_port devarg, used by the
+	 * offline port PMD only.
+	 */
+	char ol_bh_port_name[DPAA_OL_MAX_BH_PORT_NAME_LEN];
+	bool ol_fq_info_set;
 };
 
 struct dpaa_if_stats {
drivers/net/dpaa/dpaa_oldev.c new file +959 -0

959 lines not on this page · raw message

drivers/net/dpaa/meson.build +6 -5
index 8d4f69c596..3ec1091197 100644
@@ -1,5 +1,5 @@
 # SPDX-License-Identifier: BSD-3-Clause
-# Copyright 2018-2020 NXP
+# Copyright 2018-2020,2026 NXP
 
 if not is_linux
     build = false
@@ -9,12 +9,13 @@ deps += ['mempool_dpaa']
 
 sources = files(
         'dpaa_ethdev.c',
-        'fmlib/fm_lib.c',
-        'fmlib/fm_vsp.c',
         'dpaa_flow.c',
-        'dpaa_rxtx.c',
         'dpaa_fmc.c',
         'dpaa_ptp.c',
+        'dpaa_oldev.c',
+        'dpaa_rxtx.c',
+        'fmlib/fm_lib.c',
+        'fmlib/fm_vsp.c',
 )
 
 cflags += no_wvla_cflag
@@ -24,4 +25,4 @@ if cc.has_argument('-Wno-pointer-arith')
     cflags += '-Wno-pointer-arith'
 endif
 
-headers = files('rte_pmd_dpaa.h')
+headers = files('rte_pmd_dpaa.h', 'rte_pmd_dpaa_oldev.h')
drivers/net/dpaa/rte_pmd_dpaa_oldev.h new file +198 -0

198 lines not on this page · raw message

Signature · 1 line
2.25.1
#30 lore raw

PATCH v5 3/4 net/dpaa: support non fmX-macY type of shared Ethernet name

In reply to Gagandeep Singh

From: Hemant Agrawal <[email protected]>

A shared MAC interface needs the kernel netdev name to read the MTU, and that name is only the DPDK port name for fmX-macY style netdevs.

Look it up in sysfs under the platform device of the dpa-ethernet node the port was created from, and fall back to the port name.

---
 doc/guides/nics/dpaa.rst       |  6 ++-
 drivers/net/dpaa/dpaa_ethdev.c | 68 +++++++++++++++++++++++++++++++++-
 2 files changed, 72 insertions(+), 2 deletions(-)
doc/guides/nics/dpaa.rst +5 -1
index 7658e6d454..d391c0607f 100644
@@ -276,6 +276,11 @@ Refer to the document :doc:`build_and_test` for details.
   and thus disabling hardware based packet handling at driver level,
   e.g. ``dpaa:fm1-mac3,recv_err_pkts=1``.
 
+* For a shared MAC interface the kernel network interface name is looked up
+  in sysfs from the device tree node the port was created from,
+  so a kernel interface that does not follow
+  the ``fmX-macY`` naming style is handled without extra configuration.
+
 ``drv_bh_port``
    Name of the back-half port associated with an offline (O/H) port device.
    It is passed on the offline port device itself, which is named
@@ -307,7 +312,6 @@ port identified by its ``port_id``, via the experimental
 ``rte_pmd_dpaa_ol_set_lgw_info()`` and ``rte_pmd_dpaa_ol_reset_lgw_info()``
 APIs declared in ``rte_pmd_dpaa_oldev.h``.
 
-
 FMAN Config
 -----------
 
drivers/net/dpaa/dpaa_ethdev.c +67 -1

98 lines not on this page · raw message

Signature · 1 line
2.25.1
#31 lore raw

PATCH v5 4/4 drivers: add DPAA cgrid cleanup support

In reply to Gagandeep Singh

From: Jun Yang <[email protected]>

A congestion group must have no member frame queues left when it is deleted, and its CGRID must be returned to the allocator once the group is gone. Neither was handled on the net/dpaa close and probe-failure paths.

This also changes probe behaviour: a qman_create_cgr() failure in dpaa_rx_queue_init() or dpaa_tx_queue_init() now fails the probe instead of continuing without tail drop on that queue. The probe error path deletes one CGR per initialised queue, and a CGR whose creation failed was never linked into the portal list.

Fixes 62f53995caaf ("net/dpaa: add frame count based tail drop with CGR")
Fixes 9124e65dd3eb ("net/dpaa: enable Tx queue taildrop")
---
 drivers/bus/dpaa/base/qbman/qman.c       |  61 +++++++++
 drivers/bus/dpaa/dpaa_bus_base_symbols.c |   1 +
 drivers/bus/dpaa/include/fsl_qman.h      |  27 ++++
 drivers/net/dpaa/dpaa_ethdev.c           | 166 +++++++++++++++++++++--
 4 files changed, 243 insertions(+), 12 deletions(-)
drivers/bus/dpaa/base/qbman/qman.c +61 -0
index 3c056e4547..7cb9ec8a7c 100644
@@ -2993,3 +2993,64 @@ qman_shutdown_fq(struct qman_fq *fq)
 out:
 	return ret;
 }
+
+int qman_pending_fq_by_cgrid_range(u32 cgrid_start, u32 cgrid_num,
+	u32 start_fqid, u32 *fqid, u32 *cgrid)
+{
+	struct qman_fq fq = {
+		.fqid = start_fqid ? start_fqid : 1
+	};
+	struct qm_mcr_queryfq_np np;
+	struct qm_fqd fqd;
+	int err;
+
+	/*
+	 * Do not use the CGR byte count to decide whether to scan. An FQ is a
+	 * member of the group whenever it is scheduled with CGE set and a
+	 * matching cgid, whether or not it currently holds any frames, and the
+	 * group cannot be deleted while such a member exists. Skipping the
+	 * scan for an empty CGR would let an idle stale FQ survive and its
+	 * CGRID be released while still referenced. This runs once per CGRID
+	 * range at device probe, so the scan cost is acceptable.
+	 *
+	 * The whole CGRID range of a port is matched in a single pass, so a
+	 * port with many congestion groups does not need one full FQID space
+	 * scan per group.
+	 */
+	DPAA_BUS_DEBUG("Scanning FQs for cgrid(0x%x..0x%x)",
+		cgrid_start, cgrid_start + cgrid_num - 1);
+
+	/* FQID space is 24 bits wide; stop before wrapping. */
+	for (; fq.fqid <= QMAN_MAX_FQID; fq.fqid++) {
+		err = qman_query_fq_np(&fq, &np);
+		if (err == -ERANGE) {
+			/*
+			 * FQID is not implemented on this device, so there is
+			 * nothing beyond it either.
+			 */
+			break;
+		} else if (err) {
+			DPAA_BUS_WARN("Failed(%d) to Query np FQ(fqid=0x%x)",
+				err, fq.fqid);
+			return err;
+		}
+		if ((np.state & QM_MCR_NP_STATE_MASK) != QM_MCR_NP_STATE_OOS) {
+			err = qman_query_fq(&fq, &fqd);
+			if (err) {
+				DPAA_BUS_WARN("Failed(%d) to Query FQ(fqid=0x%x)",
+					err, fq.fqid);
+			} else if ((fqd.fq_ctrl & QM_FQCTRL_CGE) &&
+				fqd.cgid >= cgrid_start &&
+				fqd.cgid < cgrid_start + cgrid_num) {
+				if (fqid)
+					*fqid = fq.fqid;
+				if (cgrid)
+					*cgrid = fqd.cgid;
+				return 0;
+			}
+		}
+	}
+	DPAA_BUS_DEBUG("No FQ left in cgrid(0x%x..0x%x)",
+		cgrid_start, cgrid_start + cgrid_num - 1);
+	return -ERANGE;
+}
drivers/bus/dpaa/dpaa_bus_base_symbols.c +1 -0
index aaa9f9bec2..4da43f293d 100644
@@ -57,6 +57,7 @@ RTE_EXPORT_INTERNAL_SYMBOL(qman_reserve_fqid_range)
 RTE_EXPORT_INTERNAL_SYMBOL(qman_alloc_pool_range)
 RTE_EXPORT_INTERNAL_SYMBOL(qman_alloc_cgrid_range)
 RTE_EXPORT_INTERNAL_SYMBOL(qman_release_cgrid_range)
+RTE_EXPORT_INTERNAL_SYMBOL(qman_pending_fq_by_cgrid_range)
 RTE_EXPORT_INTERNAL_SYMBOL(dpaa_intr_enable)
 RTE_EXPORT_INTERNAL_SYMBOL(dpaa_intr_disable)
 RTE_EXPORT_INTERNAL_SYMBOL(dpaa_get_ioctl_version_number)
drivers/bus/dpaa/include/fsl_qman.h +27 -0
index b2674ce5d0..73172391cd 100644
@@ -1284,6 +1284,9 @@ struct qman_cgr {
  */
 #define QMAN_FQRN_WAIT_MAX		10000000u
 
+/* Maximum FQID value: frame queue IDs are 24 bits wide. */
+#define QMAN_MAX_FQID			0x00FFFFFFu
+
 /* Flags to qman_create_fq() */
 #define QMAN_FQ_FLAG_NO_ENQUEUE      0x00000001 /* can't enqueue */
 #define QMAN_FQ_FLAG_NO_MODIFY       0x00000002 /* can only enqueue */
@@ -1916,6 +1919,30 @@ static inline int qman_shutdown_fq_by_fqid(u32 fqid)
 	return qman_shutdown_fq(&fq);
 }
 
+/**
+ * qman_pending_fq_by_cgrid_range - Find an FQ still attached to a CGR range.
+ *
+ * @cgrid_start: first congestion group id of the range to search for.
+ * @cgrid_num: number of consecutive congestion group ids in the range.
+ * @start_fqid: FQID to begin the scan from (0 or 1 means scan from the
+ *   start). A caller shutting down several stale FQs can pass the previously
+ *   returned FQID + 1 to resume the scan instead of restarting from the
+ *   beginning each time.
+ * @fqid: on success, holds the FQID that is still attached to the range.
+ * @cgrid: on success, holds the congestion group id that FQ belongs to.
+ *   May be NULL.
+ *
+ * Matching a whole range in one pass lets a caller with many congestion
+ * groups, such as a port checking all of its Rx or Tx CGRIDs, avoid one full
+ * FQID space scan per group.
+ *
+ * Return 0 and set *fqid when a matching FQ is found, -ERANGE when none is
+ * left, or a negative error code on query failure.
+ */
+__rte_internal
+int qman_pending_fq_by_cgrid_range(u32 cgrid_start, u32 cgrid_num,
+		u32 start_fqid, u32 *fqid, u32 *cgrid);
+
 /**
  * qman_reserve_fqid_range - Reserve the specified range of frame queue IDs
  * @fqid: the base FQID of the range to deallocate
drivers/net/dpaa/dpaa_ethdev.c +154 -12

287 lines not on this page · raw message

Signature · 1 line
2.25.1
#32 lore raw
In reply to Gagandeep Singh
Quoted 4 lines · On Tue, 17 Nov 2026 11:15:54 +0530 Gagandeep Singh <[email protected]> wrote:

V5-Changes:
- Added a reset FQ helper as per the AI suggestion
- Fixed the portid issue.
- Added explicit padding, uint8_t, size checks. The version ioctl is

Quoted 8 lines

not avilable in CDX module as of now, so mismatch module will fails at probe only through existing ioctl errors.
- Fixed stale FQs run at close issue.
- Added a AI suggested warning.
- The scan moved to probe, close no longer scans. A single combined pass would need the Tx CGRIDs before the Rx CGRs are created and a scan that takes two ranges, which is too big for this series and saves only one scan per port at startup.

Applied to next-net for 27.03