Skip to contentSkip to conversation

net/dpaa2: features and fixes for NXP DPAA2 drivers

PATCH Superseded Prashant Gupta 6 participants 376 messages Sep 3 – Nov 20 4 messages not in the archive Page 1 of 5

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

cover net/dpaa2: features and fixes for NXP DPAA2 drivers

This series brings the NXP DPAA2 driver stack up to date with the functionality carried in the NXP internal tree, together with a number of bug fixes. It covers the crypto (dpaa2_sec), net, dma, mempool, event and bus/fslmc drivers.

Fixes first, then features, so the bug fixes can be picked independently of the larger reworks.

Bug fixes (patches 1-2, 7-11):
- crypto/dpaa2_sec: buffer overflow in GCM decrypt, and an FLE pool leak on the sec FD build failure path
- dpaa2 device double free on uninit
- integer overflow in the CCSR region mapping
- array-bounds warning in the dma dequeue path
- IOVA validation in the dma pre-populate helpers, which previously called rte_panic() on an unmapped address and now returns an error to the caller
- bus/fslmc: bus initialization deferred to probe

Crypto (patches 3-6):
- AES-GMAC support, AES-CTR ivsize range, a missing ECN capability, and support for configuration via environment variables

Flow and classification (patches 18-24, 35-37):
- MPLS and PPPoE distribution, meter and policing, flow drop action, a per-device default flow miss action, Rx hash identification by FLC, a minimum key size, an updated MC dpni QoS/flow-steering API, and a rework of the flow engine

Datapath and queue management (patches 12-17, 25-34, 38-45):
- dma context index ring enqueue optimization and a bypass memory-translation option
- Tx queue/channel mapping optimization, Tx confirmation rework, larger burst sizes, batched DQRR consumption, per-traffic-class Rx mempools and Rx CGIDs, parser restructuring plus tunnel and fragmented packet type parsing, PTP enhancements, xstats rework, and removal of the unused soft parser code

Please note two points that need reviewer input:

1. Patch 3 ("crypto/dpaa2_sec: support AES-GMAC") adds a new public enum value, RTE_CRYPTO_AEAD_AES_GMAC, to lib/cryptodev/rte_crypto_sym.h. It is appended at the end of enum rte_crypto_aead_algorithm so it is ABI compatible, but it is a cryptodev API addition rather than a driver-local change, so it needs cryptodev maintainer review. The series does not add a release notes entry for it; I am happy to add one, or to split that hunk into its own cryptodev patch, whichever is preferred.

2. Patch 10 ("bus/fslmc: defer bus initialization to probe") carries a
Fixes: tag but no Cc: [email protected], because it changes bus initialization ordering and is more invasive than a targeted fix. Please advise if it should still be marked for backport.

Testing:
- checkpatches.sh and check-git-log.sh are clean over all 45 patches
- build tested with the dpaa/dpaa2 driver set enabled, no new compiler warnings

The dpaa2 driver documentation is not updated in this series; the new features are not yet described in doc/guides. I plan to follow up with a documentation patch unless reviewers would rather see it folded in here.

Gagandeep Singh (20):
crypto/dpaa2_sec: fix buffer overflow in GCM decrypt crypto/dpaa2_sec: fix FLE pool leak on sec FD build failure crypto/dpaa2_sec: support AES-GMAC crypto/dpaa2_sec: increase ivsize range for AES-CTR crypto/dpaa2_sec: add missing ECN capability crypto/dpaa2_sec: add support for env variables
drivers: fix double free of dpaa2 device on uninit dma/dpaa2: validate IOVA in pre-populate helpers dma/dpaa2: optimize context index ring enqueue
drivers: add dpaa2 DMA bypass memory translation option net/dpaa2: set Tx confirmation on device init
drivers: optimize dpaa2 Tx queue and channel mapping net/dpaa2: support larger burst size
net/dpaa2: support MPLS and PPPoE flow distribution net/dpaa2: support meter and policing
net/dpaa2: support flow drop action
net/dpaa2: set default flow miss action per device net/dpaa2: identify Rx mbuf hash information by FLC net/dpaa2: enhance xstat implementation net/dpaa2: do not overwrite mbuf hash with drop priority

Hemant Agrawal (9):
net/dpaa2: fix integer overflow in CCSR region mapping net/dpaa2: add minimum key size support net/dpaa2: restructure dpaa2 parser processing net/dpaa2: parse tunnel and fragmented packet types net/dpaa2: remove unused soft parser Tx code net/dpaa2: update MC dpni QoS and flow steering API net/dpaa2: rework flow engine
bus/fslmc: reduce probe-time logging and MC traffic net/dpaa2: reject Rx queue deferred start

Jun Yang (14):
dma/dpaa2: fix array-bounds warning in dequeue path mempool/dpaa2: support ops index from primary in secondary net/dpaa2: remove unused soft parser driver
drivers: refresh dpaa2 MC and SoC version info
drivers: identify dpaa2 soft parser protocol
drivers: assign dpaa2 Rx CGID per traffic class
drivers: inherit dpaa2 rxq config for event queue net/dpaa2: rename Rx queue flags
drivers: rework dpaa2 Tx confirmation
net/dpaa2: ptp enhancements
net/dpaa2: support Rx mempool per traffic class
drivers: consume dpaa2 DQRR entries in batches
drivers: resolve dpaa2 endpoint in the net driver
drivers: align dpaa2 event port depths with hardware rings

Prashant Gupta (2):
bus/fslmc: defer bus initialization to probe net/dpaa2: read MC version from device private data

 drivers/bus/fslmc/bus_fslmc_driver.h          |   15 +-
 drivers/bus/fslmc/fslmc_bus.c                 |  185 +-
 drivers/bus/fslmc/fslmc_vfio.c                |  196 +-
 drivers/bus/fslmc/fslmc_vfio.h                |   30 +-
 drivers/bus/fslmc/portal/dpaa2_hw_dpio.c      |   83 +-
 drivers/bus/fslmc/portal/dpaa2_hw_dpio.h      |    7 -
 drivers/bus/fslmc/portal/dpaa2_hw_dprc.c      |   45 +-
 drivers/bus/fslmc/portal/dpaa2_hw_pvt.h       |    7 +-
 drivers/bus/fslmc/private.h                   |    3 +
 .../fslmc/qbman/include/fsl_qbman_portal.h    |   12 +-
 drivers/bus/fslmc/qbman/qbman_portal.c        |   78 +-
 drivers/bus/fslmc/qbman/qbman_portal.h        |   11 +-
 drivers/common/dpaax/rte_pmd_dpaax_qdma.h     |    4 +-
 drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c   |   50 +-
 drivers/crypto/dpaa2_sec/dpaa2_sec_priv.h     |   45 +-
 drivers/dma/dpaa2/dpaa2_qdma.c                |  162 +-
 drivers/dma/dpaa2/dpaa2_qdma.h                |    1 +
 drivers/event/dpaa2/dpaa2_eventdev.c          |   76 +-
 drivers/event/dpaa2/dpaa2_eventdev.h          |    4 +-
 drivers/mempool/dpaa2/dpaa2_hw_mempool.c      |   88 +-
 drivers/net/dpaa2/base/dpaa2_hw_dpni.c        |  546 --
 drivers/net/dpaa2/base/dpaa2_hw_dpni_annot.h  |    6 +-
 drivers/net/dpaa2/dpaa2_ethdev.c              | 2142 +++--
 drivers/net/dpaa2/dpaa2_ethdev.h              |  755 +-
 drivers/net/dpaa2/dpaa2_flow.c                | 6933 ++++++++++-------
 drivers/net/dpaa2/dpaa2_meter.c               |  588 ++
 drivers/net/dpaa2/dpaa2_parse_dump.h          |  374 -
 drivers/net/dpaa2/dpaa2_parser_decode.h       | 1539 ++++
 drivers/net/dpaa2/dpaa2_pmd_logs.h            |   67 +
 drivers/net/dpaa2/dpaa2_ptp.c                 |  176 +-
 drivers/net/dpaa2/dpaa2_recycle.c             |   37 +-
 drivers/net/dpaa2/dpaa2_rxtx.c                | 1903 ++---
 drivers/net/dpaa2/dpaa2_sparser.c             |  137 -
 drivers/net/dpaa2/dpaa2_sparser.h             |  202 -
 drivers/net/dpaa2/dpaa2_tm.c                  |   16 +-
 drivers/net/dpaa2/mc/dpni.c                   |  138 +-
 drivers/net/dpaa2/mc/fsl_dpni.h               |  390 +-
 drivers/net/dpaa2/mc/fsl_dpni_cmd.h           |   33 +-
 drivers/net/dpaa2/meson.build                 |    5 +-
 lib/cryptodev/rte_crypto_sym.h                |    2 +
 40 files changed, 10537 insertions(+), 6554 deletions(-)
 delete mode 100644 drivers/net/dpaa2/base/dpaa2_hw_dpni.c
 create mode 100644 drivers/net/dpaa2/dpaa2_meter.c
 delete mode 100644 drivers/net/dpaa2/dpaa2_parse_dump.h
 create mode 100644 drivers/net/dpaa2/dpaa2_parser_decode.h
 delete mode 100644 drivers/net/dpaa2/dpaa2_sparser.c
 delete mode 100644 drivers/net/dpaa2/dpaa2_sparser.h

base-commit: 9231dc7c072223628a81f5c755796d95230a5572

Signature · 1 line
2.43.0
#1 lore raw

PATCH 1/45 crypto/dpaa2_sec: fix buffer overflow in GCM decrypt

From: Gagandeep Singh <[email protected]>

In build_authenc_gcm_fd, when both AAD (auth_only_len > 0) and decrypt direction are active, the SGE layout occupies 8 entries plus 16 bytes of old_icv storage at index 8. The FLE pool buffer was only 256 bytes (8 x 32), causing old_icv to be written one entry past the end of the allocated buffer. The resulting virtual address was not mapped by the IOMMU, so DPAA2_VADDR_TO_IOVA returned 0 and the SEC engine received iova=0x00000000 as the ICV buffer address, triggering an SMMU translation fault (FSR=0x402 TF).

Additionally, the upfront bpid/IVP initialization only covered sge+3, leaving sge+4 (the input data SGE when AAD is present) without a valid bpid or IVP assignment.

Increase FLE_POOL_BUF_SIZE from 256 to 288 (9 x 32 bytes) to accommodate the full layout, and extend the bpid/IVP initialization to cover sge+4 in both branches of build_authenc_gcm_fd.

Fixes 13273250eec5 ("crypto/dpaa2_sec: support AES-GCM and CTR")
---
 drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c | 2 ++
 drivers/crypto/dpaa2_sec/dpaa2_sec_priv.h   | 2 +-
 2 files changed, 3 insertions(+), 1 deletion(-)
drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c +2 -0
index 3d980d096f..2a015a3d82 100644
@@ -569,6 +569,7 @@ build_authenc_gcm_fd(dpaa2_sec_session *sess,
 		DPAA2_SET_FLE_BPID(sge + 1, bpid);
 		DPAA2_SET_FLE_BPID(sge + 2, bpid);
 		DPAA2_SET_FLE_BPID(sge + 3, bpid);
+		DPAA2_SET_FLE_BPID(sge + 4, bpid);
 	} else {
 		DPAA2_SET_FD_IVP(fd);
 		DPAA2_SET_FLE_IVP(fle);
@@ -577,6 +578,7 @@ build_authenc_gcm_fd(dpaa2_sec_session *sess,
 		DPAA2_SET_FLE_IVP((sge + 1));
 		DPAA2_SET_FLE_IVP((sge + 2));
 		DPAA2_SET_FLE_IVP((sge + 3));
+		DPAA2_SET_FLE_IVP((sge + 4));
 	}
 
 	/* Save the shared descriptor */
drivers/crypto/dpaa2_sec/dpaa2_sec_priv.h +1 -1
index 755c8e9cc3..ff32f3d860 100644
@@ -17,7 +17,7 @@ extern uint8_t cryptodev_driver_id;
 
 /* FLE_POOL_NUM_BUFS is set as per the ipsec-secgw application */
 #define FLE_POOL_NUM_BUFS	32000
-#define FLE_POOL_BUF_SIZE	256
+#define FLE_POOL_BUF_SIZE	288
 #define FLE_POOL_CACHE_SIZE	512
 #define FLE_SG_MEM_SIZE(num)	(FLE_POOL_BUF_SIZE + ((num) * 32))
 
Signature · 1 line
2.43.0
#2 lore raw

PATCH 2/45 crypto/dpaa2_sec: fix FLE pool leak on sec FD build failure

In reply to Prashant Gupta

From: Gagandeep Singh <[email protected]>

When build_sec_fd fails at index loop inside the enqueue burst loops, the previously built FD entries (indices 0..loop-1) were never freed. The cleanup loop iterated in the wrong direction, starting at the failed index and going up to frames_to_send, which are entries that were never built. This caused silent FLE pool exhaustion, after which every subsequent build_sec_fd returned -ENOMEM, enqueue_burst returned 0 indefinitely, and the crypto-perf test hung.

Fix both dpaa2_sec_enqueue_burst and dpaa2_sec_enqueue_burst_ordered by clamping frames_to_send to loop + 1 and iterating from 0 to free all allocated FLE buffers including the failed entry.

Fixes 623326dded3a ("crypto/dpaa2_sec: introduce poll mode driver")
---
 drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c +6 -0
index 2a015a3d82..15152cc5a1 100644
@@ -1550,6 +1550,9 @@ dpaa2_sec_enqueue_burst(void *qp, struct rte_crypto_op **ops,
 			ret = build_sec_fd(*ops, &fd_arr[loop], bpid, dpaa2_qp);
 			if (ret) {
 				DPAA2_SEC_DP_DEBUG("FD build failed");
+				frames_to_send = loop + 1;
+				for (loop = 0; loop < frames_to_send; loop++)
+					free_fle(&fd_arr[loop], dpaa2_qp);
 				goto skip_tx;
 			}
 			ops++;
@@ -1909,6 +1912,9 @@ dpaa2_sec_enqueue_burst_ordered(void *qp, struct rte_crypto_op **ops,
 			ret = build_sec_fd(*ops, &fd_arr[loop], bpid, dpaa2_qp);
 			if (ret) {
 				DPAA2_SEC_DP_DEBUG("FD build failed");
+				frames_to_send = loop + 1;
+				for (loop = 0; loop < frames_to_send; loop++)
+					free_fle(&fd_arr[loop], dpaa2_qp);
 				goto skip_tx;
 			}
 			ops++;
Signature · 1 line
2.43.0
#3 lore raw

PATCH 3/45 crypto/dpaa2_sec: support AES-GMAC

In reply to Prashant Gupta

From: Gagandeep Singh <[email protected]>

Add AES-GMAC as a supported AEAD algorithm for IPsec protocol offload. AES-GMAC provides NULL encryption with GMAC authentication and maps to OP_PCL_IPSEC_AES_NULL_WITH_GMAC in the SEC protocol control word.

When AES_GMAC is specified as an AUTH (non-AEAD) algorithm, return -ENOTSUP with an informative message directing the user to the AEAD path.

Add RTE_CRYPTO_AEAD_AES_GMAC to the AEAD algorithm enum and expose the capability in dpaa2_sec_capabilities.

---
 drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c | 15 +++++++++-
 drivers/crypto/dpaa2_sec/dpaa2_sec_priv.h   | 33 ++++++++++++++++++++-
 lib/cryptodev/rte_crypto_sym.h              |  2 ++
 3 files changed, 48 insertions(+), 2 deletions(-)
drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c +14 -1
index 15152cc5a1..0e4e67aa07 100644
@@ -1,7 +1,7 @@
 /* SPDX-License-Identifier: BSD-3-Clause
  *
  *   Copyright (c) 2016 Freescale Semiconductor, Inc. All rights reserved.
- *   Copyright 2016-2025 NXP
+ *   Copyright 2016-2026 NXP
  *
  */
 
@@ -2975,6 +2975,13 @@ dpaa2_sec_ipsec_aead_init(struct rte_crypto_aead_xform *aead_xform,
 		aeaddata->algmode = OP_ALG_AAI_CCM;
 		session->aead_alg = RTE_CRYPTO_AEAD_AES_CCM;
 		break;
+	case RTE_CRYPTO_AEAD_AES_GMAC:
+		/**
+		 * AES-GMAC is an AEAD algo with NULL encryption and GMAC
+		 * authentication.
+		 */
+		aeaddata->algtype = OP_PCL_IPSEC_AES_NULL_WITH_GMAC;
+		break;
 	default:
 		DPAA2_SEC_ERR("Crypto: Undefined AEAD specified %u",
 			      aead_xform->algo);
@@ -3046,6 +3053,10 @@ dpaa2_sec_ipsec_proto_init(struct rte_crypto_cipher_xform *cipher_xform,
 		authdata->algtype = OP_PCL_IPSEC_HMAC_MD5_96;
 		authdata->algmode = OP_ALG_AAI_HMAC;
 		break;
+	case RTE_CRYPTO_AUTH_AES_GMAC:
+		DPAA2_SEC_ERR(
+			"AES_GMAC is supported as AEAD algo for IPSEC proto only");
+		return -ENOTSUP;
 	case RTE_CRYPTO_AUTH_SHA224_HMAC:
 		authdata->algmode = OP_ALG_AAI_HMAC;
 		if (session->digest_length == 6)
@@ -3217,6 +3228,7 @@ dpaa2_sec_set_ipsec_session(struct rte_cryptodev *dev,
 		case OP_PCL_IPSEC_AES_GCM8:
 		case OP_PCL_IPSEC_AES_GCM12:
 		case OP_PCL_IPSEC_AES_GCM16:
+		case OP_PCL_IPSEC_AES_NULL_WITH_GMAC:
 			memcpy(encap_pdb.gcm.salt,
 				(uint8_t *)&(ipsec_xform->salt), 4);
 			break;
@@ -3357,6 +3369,7 @@ dpaa2_sec_set_ipsec_session(struct rte_cryptodev *dev,
 		case OP_PCL_IPSEC_AES_GCM8:
 		case OP_PCL_IPSEC_AES_GCM12:
 		case OP_PCL_IPSEC_AES_GCM16:
+		case OP_PCL_IPSEC_AES_NULL_WITH_GMAC:
 			memcpy(decap_pdb.gcm.salt,
 				(uint8_t *)&(ipsec_xform->salt), 4);
 			break;
drivers/crypto/dpaa2_sec/dpaa2_sec_priv.h +32 -1
index ff32f3d860..1824cc4a60 100644
@@ -1,7 +1,7 @@
 /* SPDX-License-Identifier: BSD-3-Clause
  *
  *   Copyright (c) 2016 Freescale Semiconductor, Inc. All rights reserved.
- *   Copyright 2016,2020-2024 NXP
+ *   Copyright 2016,2020-2026 NXP
  *
  */
 
@@ -762,6 +762,37 @@ static const struct rte_cryptodev_capabilities dpaa2_sec_capabilities[] = {
 			}, }
 		}, }
 	},
+	{	/* AES GMAC (AEAD) */
+		.op = RTE_CRYPTO_OP_TYPE_SYMMETRIC,
+		{.sym = {
+			.xform_type = RTE_CRYPTO_SYM_XFORM_AEAD,
+			{.aead = {
+				.algo = RTE_CRYPTO_AEAD_AES_GMAC,
+				.block_size = 16,
+				.key_size = {
+					.min = 16,
+					.max = 32,
+					.increment = 8
+				},
+				.digest_size = {
+					.min = 16,
+					.max = 16,
+					.increment = 0
+				},
+				.aad_size = {
+					.min = 0,
+					.max = 65535,
+					.increment = 1
+				},
+				.iv_size = {
+					.min = 12,
+					.max = 16,
+					.increment = 4
+				}
+			}, }
+		}, }
+	},
+
 	RTE_CRYPTODEV_END_OF_CAPABILITIES_LIST()
 };
 
lib/cryptodev/rte_crypto_sym.h +2 -0
index 630fd153bd..f65db616a0 100644
@@ -508,6 +508,8 @@ enum rte_crypto_aead_algorithm {
 	/**< AES algorithm in NCA5 mode */
 	RTE_CRYPTO_AEAD_ZUC_NCA6,
 	/**< ZUC-256 algorithm in NCA6 mode */
+	RTE_CRYPTO_AEAD_AES_GMAC,
+	/**< AES algorithm in GMAC mode. */
 };
 
 /** Symmetric AEAD Operations */
Signature · 1 line
2.43.0
#4 lore raw

PATCH 4/45 crypto/dpaa2_sec: increase ivsize range for AES-CTR

In reply to Prashant Gupta

From: Gagandeep Singh <[email protected]>

Widen the AES-CTR IV size range from the fixed 16-byte value to [12, 16] with a 4-byte increment. This allows 96-bit IVs (the standard NIST SP 800-38A recommendation) in addition to 128-bit IVs, aligning with common usage and test-vector expectations.

The change applies to both dpaa2_sec_capabilities and dpaa2_pdcp_capabilities.

---
 drivers/crypto/dpaa2_sec/dpaa2_sec_priv.h | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/crypto/dpaa2_sec/dpaa2_sec_priv.h +4 -4
index 1824cc4a60..7e18e83858 100644
@@ -625,9 +625,9 @@ static const struct rte_cryptodev_capabilities dpaa2_sec_capabilities[] = {
 					.increment = 8
 				},
 				.iv_size = {
-					.min = 16,
+					.min = 12,
 					.max = 16,
-					.increment = 0
+					.increment = 4
 				},
 			}, }
 		}, }
@@ -855,9 +855,9 @@ static const struct rte_cryptodev_capabilities dpaa2_pdcp_capabilities[] = {
 					.increment = 8
 				},
 				.iv_size = {
-					.min = 16,
+					.min = 12,
 					.max = 16,
-					.increment = 0
+					.increment = 4
 				}
 			}, }
 		}, }
Signature · 1 line
2.43.0
#5 lore raw

PATCH 5/45 crypto/dpaa2_sec: add missing ECN capability

In reply to Prashant Gupta

From: Gagandeep Singh <[email protected]>

Set the .ecn = 1 flag in both tunnel-mode security capability entries to advertise that the driver supports ECN (Explicit Congestion Notification) copying during IPsec encap/decap.

---
 drivers/crypto/dpaa2_sec/dpaa2_sec_priv.h | 2 ++
 1 file changed, 2 insertions(+)
drivers/crypto/dpaa2_sec/dpaa2_sec_priv.h +2 -0
index 7e18e83858..16b8273a79 100644
@@ -1004,6 +1004,7 @@ static const struct rte_security_capability dpaa2_sec_security_cap[] = {
 				.copy_df = 1,
 				.copy_dscp = 1,
 				.dec_ttl = 1,
+				.ecn = 1,
 				.esn = 1,
 			},
 			.replay_win_sz_max = 1024
@@ -1023,6 +1024,7 @@ static const struct rte_security_capability dpaa2_sec_security_cap[] = {
 				.copy_df = 1,
 				.copy_dscp = 1,
 				.dec_ttl = 1,
+				.ecn = 1,
 				.esn = 1,
 			},
 			.replay_win_sz_max = 1024
Signature · 1 line
2.43.0
#6 lore raw

PATCH 6/45 crypto/dpaa2_sec: add support for env variables

In reply to Prashant Gupta

From: Gagandeep Singh <[email protected]>

Allow driver configuration via environment variables as a fallback when devargs are not provided. After processing devargs (or when devargs are absent), check DRIVER_STRICT_ORDER and DRIVER_DUMP_MODE environment variables to set en_loose_ordered and dpaa2_sec_dp_dump.

This lets users configure the driver without modifying EAL arguments, useful in environments where command-line access is restricted.

---
 drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c | 27 ++++++++++++++++++---
 1 file changed, 23 insertions(+), 4 deletions(-)
drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c +23 -4
index 0e4e67aa07..c54960820c 100644
@@ -4379,25 +4379,44 @@ check_devargs_handler(const char *key, const char *value,
 static void
 dpaa2_sec_get_devargs(struct rte_cryptodev *cryptodev, const char *key)
 {
+	struct dpaa2_sec_dev_private *internals;
 	struct rte_kvargs *kvlist;
 	struct rte_devargs *devargs;
+	int ret;
+	char *env;
+
+	internals = cryptodev->data->dev_private;
 
 	devargs = cryptodev->device->devargs;
 	if (!devargs)
-		return;
+		goto env_set;
 
 	kvlist = rte_kvargs_parse(devargs->args, NULL);
 	if (!kvlist)
-		return;
+		goto env_set;
 
 	if (!rte_kvargs_count(kvlist, key)) {
 		rte_kvargs_free(kvlist);
-		return;
+		goto env_set;
 	}
 
-	rte_kvargs_process(kvlist, key,
+	ret = rte_kvargs_process(kvlist, key,
 			check_devargs_handler, (void *)cryptodev);
 	rte_kvargs_free(kvlist);
+	if (!ret)
+		return;
+
+env_set:
+	env = getenv(DRIVER_STRICT_ORDER);
+	if (env)
+		internals->en_loose_ordered = !atoi(env);
+
+	env = getenv(DRIVER_DUMP_MODE);
+	if (env) {
+		dpaa2_sec_dp_dump = atoi(env);
+		if (dpaa2_sec_dp_dump > DPAA2_SEC_DP_FULL_DUMP)
+			dpaa2_sec_dp_dump = DPAA2_SEC_DP_FULL_DUMP;
+	}
 }
 
 static int
Signature · 1 line
2.43.0
#7 lore raw

PATCH 7/45 drivers: fix double free of dpaa2 device on uninit

In reply to Prashant Gupta

From: Gagandeep Singh <[email protected]>

dpaa2_dpdmai_dev_uninit() was called from dpaa2_qdma_close(), but rte_dma close may run without a matching device remove, so the uninitialization (which frees the qdma_dev allocation and the MC portal) could run twice or leak the MC portal.

Move dpaa2_dpdmai_dev_uninit() to dpaa2_qdma_remove(), which is the correct teardown counterpart of dpaa2_qdma_probe(). To reach the dmadev from the remove callback, store the rte_dma_dev pointer in struct rte_dpaa2_device at probe time and use it in remove, dropping the now-unused forward declaration.

Fixes 8caf8427f85a ("dma/dpaa2: introduce driver skeleton")
---
 drivers/bus/fslmc/bus_fslmc_driver.h | 1 +
 drivers/dma/dpaa2/dpaa2_qdma.c       | 9 ++++-----
 2 files changed, 5 insertions(+), 5 deletions(-)
drivers/bus/fslmc/bus_fslmc_driver.h +1 -0
index 44f81cf662..c64ef094d0 100644
@@ -102,6 +102,7 @@ struct rte_dpaa2_device {
 	char ep_name[RTE_DEV_NAME_MAX_LEN];
 	struct rte_intr_handle *intr_handle; /**< Interrupt handle */
 	char name[FSLMC_OBJECT_MAX_LEN];    /**< DPAA2 Object name*/
+	struct rte_dma_dev *dmadev;          /**< DMA device */
 };
 
 typedef int (*rte_dpaa2_obj_create_t)(int vdev_fd,
drivers/dma/dpaa2/dpaa2_qdma.c +4 -5
index f7d94bb799..4a95f2a1ab 100644
@@ -1455,9 +1455,6 @@ dpaa2_qdma_stop(struct rte_dma_dev *dev)
 	return 0;
 }
 
-static int
-dpaa2_dpdmai_dev_uninit(struct rte_dma_dev *dev);
-
 static int
 dpaa2_qdma_close(struct rte_dma_dev *dev)
 {
@@ -1508,8 +1505,6 @@ dpaa2_qdma_close(struct rte_dma_dev *dev)
 	/* Reset QDMA device structure */
 	qdma_dev->num_vqs = 0;
 
-	dpaa2_dpdmai_dev_uninit(dev);
-
 	return 0;
 }
 
@@ -1708,6 +1703,7 @@ dpaa2_qdma_probe(struct rte_dpaa2_driver *dpaa2_drv,
 		return -EINVAL;
 	}
 
+	dpaa2_dev->dmadev = dmadev;
 	dmadev->dev_ops = &dpaa2_qdma_ops;
 	dmadev->device = &dpaa2_dev->device;
 	dmadev->fp_obj->dev_private = dmadev->data->dev_private;
@@ -1731,10 +1727,13 @@ dpaa2_qdma_probe(struct rte_dpaa2_driver *dpaa2_drv,
 static int
 dpaa2_qdma_remove(struct rte_dpaa2_device *dpaa2_dev)
 {
+	struct rte_dma_dev *dmadev = dpaa2_dev->dmadev;
 	int ret;
 
 	DPAA2_QDMA_FUNC_TRACE();
 
+	dpaa2_dpdmai_dev_uninit(dmadev);
+
 	ret = rte_dma_pmd_release(dpaa2_dev->device.name);
 	if (ret)
 		DPAA2_QDMA_ERR("Device cleanup failed");
Signature · 1 line
2.43.0
#8 lore raw

Re: [PATCH 07/45] drivers: fix double free of dpaa2 device on uninit

Quoted 14 lines · Prashant Gupta

From: Gagandeep Singh <[email protected]>

dpaa2_dpdmai_dev_uninit() was called from dpaa2_qdma_close(), but rte_dma close may run without a matching device remove, so the uninitialization (which frees the qdma_dev allocation and the MC portal) could run twice or leak the MC portal.

Move dpaa2_dpdmai_dev_uninit() to dpaa2_qdma_remove(), which is the correct teardown counterpart of dpaa2_qdma_probe(). To reach the dmadev from the remove callback, store the rte_dma_dev pointer in struct rte_dpaa2_device at probe time and use it in remove, dropping the now-unused forward declaration.

Quoted 4 lines
Fixes 8caf8427f85a ("dma/dpaa2: introduce driver skeleton")

Nack.

I just cleaned this up so maybe it is probably a regression of my change. 868a3abd0ee5 ("dma/dpaa2: remove dmadev pointer from bus device")

Thank you.

Signature · 1 line
David Marchand
#9 lore raw

PATCH 8/45 net/dpaa2: fix integer overflow in CCSR region mapping

In reply to Prashant Gupta

From: Hemant Agrawal <[email protected]>

In lsx_ccsr_map_region, PAGE_SIZE is defined as sysconf(_SC_PAGESIZE) which may be negative on error. The value was used directly in size_t comparisons and passed to mmap, causing an integer overflow (Coverity CID 49765682).

Use sysconf() explicitly with a signed long, check for errors, and compute map_len separately with unsigned arithmetic before passing to mmap.

Coverity issue: 49765682

Fixes f023d059769f ("net/dpaa2: support recycle loopback port")
---
 drivers/net/dpaa2/dpaa2_recycle.c | 21 +++++++++++++++------
 1 file changed, 15 insertions(+), 6 deletions(-)
drivers/net/dpaa2/dpaa2_recycle.c +15 -6
index f78d12362e..80c20272ce 100644
@@ -176,6 +176,8 @@ static void *lsx_ccsr_map_region(uint64_t addr, size_t len)
 	void *tmp;
 	uint64_t start;
 	uint64_t offset;
+	long page_size;
+	size_t map_len;
 
 	fd = open("/dev/mem", O_RDWR);
 	if (fd < 0) {
@@ -183,20 +185,27 @@ static void *lsx_ccsr_map_region(uint64_t addr, size_t len)
 		return NULL;
 	}
 
+	page_size = sysconf(_SC_PAGESIZE);
+	if (page_size <= 0) {
+		close(fd);
+		return NULL;
+	}
 	start = addr & PAGE_MASK;
 	offset = addr - start;
 	len = len & PAGE_MASK;
-	if (len < (size_t)PAGE_SIZE)
-		len = PAGE_SIZE;
 
-	tmp = mmap(NULL, len, PROT_READ | PROT_WRITE, MAP_SHARED, fd, start);
+	map_len = len & ~(page_size - 1);
+	if (map_len < (size_t)page_size)
+		map_len = (size_t)page_size;
+
+	tmp = mmap(NULL, map_len, PROT_READ | PROT_WRITE, MAP_SHARED, fd, start);
 
 	close(fd);
 
-	if (tmp != MAP_FAILED)
-		return (uint8_t *)tmp + offset;
-	else
+	if (tmp == MAP_FAILED)
 		return NULL;
+
+	return (uint8_t *)tmp + offset;
 }
 
 static const uint8_t ls_sd1_prot_idx_map[] = {
Signature · 1 line
2.43.0
#10 lore raw

PATCH 9/45 dma/dpaa2: fix array-bounds warning in dequeue path

In reply to Prashant Gupta

From: Jun Yang <[email protected]>

In dpaa2_qdma_dq_fd, passing a local uint16_t variable directly as a pointer to qdma_cntx_idx_ring_eq caused a compiler array-bounds warning because the function takes a pointer to an element of the ring array.

Add a per-queue scratch buffer idxs[DPAA2_QDMA_MAX_DESC] to struct qdma_virt_queue and use idxs[0] instead of a local variable pointer. Also consolidate the fle_sdd pointer assignment for LONG and SG FD types to avoid code duplication.

Fixes 388e888dc082 ("dma/dpaa2: support short FD")
---
 drivers/dma/dpaa2/dpaa2_qdma.c | 26 +++++++++-----------------
 drivers/dma/dpaa2/dpaa2_qdma.h |  1 +
 2 files changed, 10 insertions(+), 17 deletions(-)
drivers/dma/dpaa2/dpaa2_qdma.c +9 -17
index 4a95f2a1ab..45d7a99805 100644
@@ -935,35 +935,27 @@ dpaa2_qdma_dq_fd(const struct qbman_fd *fd,
 	enum dpaa2_qdma_fd_type type;
 	int ret;
 	struct qdma_cntx_sg *cntx_sg;
-	struct qdma_cntx_fle_sdd *fle_sdd;
+	struct qdma_cntx_fle_sdd *fle_sdd = NULL;
 
 	att = dpaa2_qdma_fd_get_att(fd);
 	type = DPAA2_QDMA_FD_ATT_TYPE(att);
-	if (type == DPAA2_QDMA_FD_SHORT) {
-		idx = DPAA2_QDMA_FD_ATT_CNTX(att);
-		ret = qdma_cntx_idx_ring_eq(qdma_vq->ring_cntx_idx,
-				&idx, 1, free_space);
-		if (unlikely(ret != 1))
-			return -ENOSPC;
-
-		return 0;
-	}
-	if (type == DPAA2_QDMA_FD_LONG) {
-		idx = DPAA2_QDMA_FD_ATT_CNTX(att);
-		fle_sdd = (void *)(uintptr_t)DPAA2_GET_FD_FLC(fd);
+	if (type == DPAA2_QDMA_FD_LONG || type == DPAA2_QDMA_FD_SG) {
+		fle_sdd = (void *)DPAA2_GET_FD_FLC(fd);
 		qdma_vq->fle_elem[*fle_elem_nb] = fle_sdd;
 		(*fle_elem_nb)++;
+	}
+	if (type == DPAA2_QDMA_FD_SHORT ||
+		type == DPAA2_QDMA_FD_LONG) {
+		idx = DPAA2_QDMA_FD_ATT_CNTX(att);
+		qdma_vq->idxs[0] = idx;
 		ret = qdma_cntx_idx_ring_eq(qdma_vq->ring_cntx_idx,
-				&idx, 1, free_space);
+			qdma_vq->idxs, 1, free_space);
 		if (unlikely(ret != 1))
 			return -ENOSPC;
 
 		return 0;
 	}
 	if (type == DPAA2_QDMA_FD_SG) {
-		fle_sdd = (void *)(uintptr_t)DPAA2_GET_FD_FLC(fd);
-		qdma_vq->fle_elem[*fle_elem_nb] = fle_sdd;
-		(*fle_elem_nb)++;
 		cntx_sg = container_of(fle_sdd,
 				struct qdma_cntx_sg, fle_sdd);
 		ret = qdma_cntx_idx_ring_eq(qdma_vq->ring_cntx_idx,
drivers/dma/dpaa2/dpaa2_qdma.h +1 -0
index e2d2eb4fa8..98c64f7b45 100644
@@ -290,6 +290,7 @@ struct qdma_virt_queue {
 	struct qdma_cntx_idx_ring *ring_cntx_idx;
 
 	/**Used for silent enabled*/
+	uint16_t idxs[DPAA2_QDMA_MAX_DESC];
 	struct qdma_cntx_sg *cntx_sg[DPAA2_QDMA_MAX_DESC];
 	struct qdma_cntx_fle_sdd *cntx_fle_sdd[DPAA2_QDMA_MAX_DESC];
 	uint16_t silent_idx;
Signature · 1 line
2.43.0
#11 lore raw

PATCH 10/45 bus/fslmc: defer bus initialization to probe

In reply to Prashant Gupta

The fslmc bus initialization (register the sequence number mbuf dynfield, set up the VFIO group, DMA map the memory segments) needs the DPDK heap and the memory segment list in shared (hugepage) memory for multi-process sharing. But these are not available during the bus scan (EAL runs rte_bus_scan() before memzone, memory and malloc heap init), so it fails there.

Device discovery does not need it, and get_iommu_class() only checks sysfs paths to report the IOVA mode, so the init is not needed in scan. Move it back to probe.

Fixes cdefd2e980bd ("drivers/bus: initialize NXP bus specifics in scan")
---
 drivers/bus/fslmc/fslmc_bus.c | 92 +++++++++++++++++++----------------
 1 file changed, 51 insertions(+), 41 deletions(-)
drivers/bus/fslmc/fslmc_bus.c +51 -41
index 3626b12316..ee162b0ed8 100644
@@ -368,46 +368,6 @@ rte_fslmc_scan(void)
 	/* If debugging is enabled, device list is dumped to log output */
 	dump_device_list();
 
-	/* Bus initialization - only if devices were found */
-	if (!TAILQ_EMPTY(&rte_fslmc_bus.device_list)) {
-		static const struct rte_mbuf_dynfield dpaa2_seqn_dynfield_desc = {
-			.name = DPAA2_SEQN_DYNFIELD_NAME,
-			.size = sizeof(dpaa2_seqn_t),
-			.align = alignof(dpaa2_seqn_t),
-		};
-
-		dpaa2_seqn_dynfield_offset =
-			rte_mbuf_dynfield_register(&dpaa2_seqn_dynfield_desc);
-		if (dpaa2_seqn_dynfield_offset < 0) {
-			DPAA2_BUS_ERR("Failed to register mbuf field for dpaa sequence number");
-			return 0;
-		}
-
-		ret = fslmc_vfio_setup_group();
-		if (ret) {
-			DPAA2_BUS_ERR("Unable to setup VFIO %d", ret);
-			return 0;
-		}
-
-		/* Map existing segments as well as, in case of hotpluggable memory,
-		 * install callback handler.
-		 */
-		if (rte_eal_process_type() == RTE_PROC_PRIMARY) {
-			ret = fslmc_vfio_dmamap();
-			if (ret) {
-				DPAA2_BUS_ERR("Unable to DMA map existing VAs: (%d)", ret);
-				DPAA2_BUS_ERR("FSLMC VFIO Mapping failed");
-				return 0;
-			}
-		}
-
-		ret = fslmc_vfio_process_group();
-		if (ret) {
-			DPAA2_BUS_ERR("Unable to setup devices %d", ret);
-			return 0;
-		}
-	}
-
 	process_once = 1;
 
 	return 0;
@@ -423,6 +383,56 @@ rte_fslmc_scan(void)
 	return 0;
 }
 
+/* Bus initialization needs the DPDK heap and DMA mapping of the memory
+ * segments, which EAL only sets up after the bus scan, so it is done here.
+ */
+static int
+rte_fslmc_probe(struct rte_bus *bus)
+{
+	static const struct rte_mbuf_dynfield dpaa2_seqn_dynfield_desc = {
+		.name = DPAA2_SEQN_DYNFIELD_NAME,
+		.size = sizeof(dpaa2_seqn_t),
+		.align = alignof(dpaa2_seqn_t),
+	};
+	int ret;
+
+	if (TAILQ_EMPTY(&rte_fslmc_bus.device_list))
+		return 0;
+
+	dpaa2_seqn_dynfield_offset =
+		rte_mbuf_dynfield_register(&dpaa2_seqn_dynfield_desc);
+	if (dpaa2_seqn_dynfield_offset < 0) {
+		DPAA2_BUS_ERR("Failed to register mbuf field for dpaa sequence number");
+		return 0;
+	}
+
+	ret = fslmc_vfio_setup_group();
+	if (ret) {
+		DPAA2_BUS_ERR("Unable to setup VFIO %d", ret);
+		return 0;
+	}
+
+	/* Map existing segments as well as, in case of hotpluggable memory,
+	 * install callback handler.
+	 */
+	if (rte_eal_process_type() == RTE_PROC_PRIMARY) {
+		ret = fslmc_vfio_dmamap();
+		if (ret) {
+			DPAA2_BUS_ERR("Unable to DMA map existing VAs: (%d)", ret);
+			DPAA2_BUS_ERR("FSLMC VFIO Mapping failed");
+			return 0;
+		}
+	}
+
+	ret = fslmc_vfio_process_group();
+	if (ret) {
+		DPAA2_BUS_ERR("Unable to setup devices %d", ret);
+		return 0;
+	}
+
+	return rte_bus_generic_probe(bus);
+}
+
 static bool
 fslmc_bus_match(const struct rte_driver *drv, const struct rte_device *dev)
 {
@@ -544,7 +554,7 @@ fslmc_bus_unplug_device(struct rte_device *rte_dev)
 
 struct rte_bus rte_fslmc_bus = {
 	.scan = rte_fslmc_scan,
-	.probe = rte_bus_generic_probe,
+	.probe = rte_fslmc_probe,
 	.cleanup = rte_fslmc_close,
 	.parse = rte_fslmc_parse,
 	.dev_compare = fslmc_dev_compare,
Signature · 1 line
2.43.0
#12 lore raw

PATCH 11/45 dma/dpaa2: validate IOVA in pre-populate helpers

In reply to Prashant Gupta

From: Gagandeep Singh <[email protected]>

fle_sdd_pre_populate() and fle_sdd_sg_pre_populate() converted the SDD and SG entry virtual addresses to IOVA with DPAA2_VADDR_TO_IOVA(), which does not verify that the range is actually mapped in the IOMMU/SMMU. An unmapped buffer was silently programmed into the hardware descriptor, leading to an SMMU translation fault at transfer time that is hard to trace back to the missing mapping.

Use DPAA2_VADDR_TO_IOVA_AND_CHECK() for the SDD, source SG and destination SG buffers and report the offending address and size when the translation is missing, so the misconfiguration is caught early and clearly. Both helpers now return an error code which is propagated to the caller instead of continuing with an invalid descriptor.

---
 drivers/dma/dpaa2/dpaa2_qdma.c | 50 ++++++++++++++++++++++++++++------
 1 file changed, 41 insertions(+), 9 deletions(-)
drivers/dma/dpaa2/dpaa2_qdma.c +41 -9
index 45d7a99805..4ad72c5816 100644
@@ -180,14 +180,23 @@ dpaa2_qdma_multi_eq(struct qdma_virt_queue *qdma_vq)
 	return num_tx;
 }
 
-static void
+static int
 fle_sdd_pre_populate(struct qdma_cntx_fle_sdd *fle_sdd,
 	struct dpaa2_qdma_rbp *rbp, uint64_t src, uint64_t dest,
 	uint32_t fmt)
 {
 	struct qbman_fle *fle = fle_sdd->fle;
 	struct qdma_sdd *sdd = fle_sdd->sdd;
-	uint64_t sdd_iova = DPAA2_VADDR_TO_IOVA(sdd);
+	uint64_t sdd_iova, iova_size;
+
+	iova_size = sizeof(struct qdma_sdd) * DPAA2_QDMA_MAX_SDD;
+	sdd_iova = DPAA2_VADDR_TO_IOVA_AND_CHECK(sdd, iova_size);
+	if (sdd_iova == RTE_BAD_IOVA) {
+		DPAA2_QDMA_ERR("No IOMMU map for sdd(%p)(size=%" PRIx64 ")",
+			sdd, iova_size);
+
+		return -ENOMEM;
+	}
 
 	/* first frame list to source descriptor */
 	DPAA2_SET_FLE_ADDR(&fle[DPAA2_QDMA_SDD_FLE], sdd_iova);
@@ -256,6 +265,8 @@ fle_sdd_pre_populate(struct qdma_cntx_fle_sdd *fle_sdd,
 
 	/* Final bit: 1, for last frame list */
 	DPAA2_SET_FLE_FIN(&fle[DPAA2_QDMA_DST_FLE]);
+
+	return 0;
 }
 
 static void
@@ -283,22 +294,39 @@ sg_entry_pre_populate(struct qdma_cntx_sg *sg_cntx)
 	}
 }
 
-static void
+static int
 fle_sdd_sg_pre_populate(struct qdma_cntx_sg *sg_cntx,
 	struct qdma_virt_queue *qdma_vq)
 {
 	struct qdma_sg_entry *src_sge = sg_cntx->sg_src_entry;
 	struct qdma_sg_entry *dst_sge = sg_cntx->sg_dst_entry;
-	rte_iova_t src_sge_iova, dst_sge_iova;
+	rte_iova_t src_sge_iova, dst_sge_iova, iova_size;
 	struct dpaa2_qdma_rbp *rbp = &qdma_vq->rbp;
 
 	memset(sg_cntx, 0, sizeof(struct qdma_cntx_sg));
 
-	src_sge_iova = DPAA2_VADDR_TO_IOVA(src_sge);
-	dst_sge_iova = DPAA2_VADDR_TO_IOVA(dst_sge);
+	iova_size = RTE_DPAAX_QDMA_JOB_SUBMIT_MAX *
+		sizeof(struct qdma_sg_entry);
+
+	src_sge_iova = DPAA2_VADDR_TO_IOVA_AND_CHECK(src_sge, iova_size);
+	if (src_sge_iova == RTE_BAD_IOVA) {
+		DPAA2_QDMA_ERR("No IOMMU map for src_sge(%p)(size=%" PRIx64 ")",
+			src_sge, iova_size);
+
+		return -ENOMEM;
+	}
+
+	dst_sge_iova = DPAA2_VADDR_TO_IOVA_AND_CHECK(dst_sge, iova_size);
+	if (dst_sge_iova == RTE_BAD_IOVA) {
+		DPAA2_QDMA_ERR("No IOMMU map for dst_sge(%p)(size=%" PRIx64 ")",
+			dst_sge, iova_size);
+
+		return -ENOMEM;
+	}
 
 	sg_entry_pre_populate(sg_cntx);
-	fle_sdd_pre_populate(&sg_cntx->fle_sdd,
+
+	return fle_sdd_pre_populate(&sg_cntx->fle_sdd,
 		rbp, src_sge_iova, dst_sge_iova,
 		QBMAN_FLE_WORD4_FMT_SGE);
 }
@@ -669,7 +697,9 @@ dpaa2_qdma_copy_sg(void *dev_private,
 
 	if (qdma_vq->fle_pre_populate) {
 		if (unlikely(!fle[DPAA2_QDMA_SRC_FLE].length)) {
-			fle_sdd_sg_pre_populate(cntx_sg, qdma_vq);
+			ret = fle_sdd_sg_pre_populate(cntx_sg, qdma_vq);
+			if (ret)
+				return ret;
 			if (!qdma_dev->is_silent && cntx_sg && idx_addr) {
 				for (i = 0; i < nb_src; i++)
 					cntx_sg->cntx_idx[i] = idx_addr[i];
@@ -871,9 +901,11 @@ dpaa2_qdma_long_copy(struct qdma_virt_queue *qdma_vq,
 
 	if (qdma_vq->fle_pre_populate) {
 		if (unlikely(!fle[DPAA2_QDMA_SRC_FLE].length)) {
-			fle_sdd_pre_populate(fle_sdd,
+			ret = fle_sdd_pre_populate(fle_sdd,
 				&qdma_vq->rbp,
 				0, 0, QBMAN_FLE_WORD4_FMT_SBF);
+			if (ret)
+				return ret;
 		}
 
 		fle_post_populate(fle, src, dst, length);
Signature · 1 line
2.43.0
#13 lore raw

PATCH 12/45 dma/dpaa2: optimize context index ring enqueue

In reply to Prashant Gupta

From: Gagandeep Singh <[email protected]>

qdma_cntx_idx_ring_eq() copied the context indices into the ring one element at a time in a loop, updating the tail on every iteration.

Replace the per-element loop with rte_memcpy(), handling the ring wrap-around as at most two contiguous copies, and update the tail once. This reduces the per-burst overhead on the dequeue completion path.

---
 drivers/dma/dpaa2/dpaa2_qdma.c | 20 ++++++++++++++------
 1 file changed, 14 insertions(+), 6 deletions(-)
drivers/dma/dpaa2/dpaa2_qdma.c +14 -6
index 4ad72c5816..1e9ec463aa 100644
@@ -66,15 +66,23 @@ qdma_cntx_idx_ring_eq(struct qdma_cntx_idx_ring *ring,
 	const uint16_t *elem, uint16_t nb,
 	uint16_t *free_space)
 {
-	uint16_t i;
-
 	if (unlikely(nb > ring->free_space))
 		return 0;
 
-	for (i = 0; i < nb; i++) {
-		ring->cntx_idx_ring[ring->tail] = elem[i];
-		ring->tail = (ring->tail + 1) &
-			(DPAA2_QDMA_MAX_DESC - 1);
+	if ((ring->tail + nb) < DPAA2_QDMA_MAX_DESC) {
+		rte_memcpy(&ring->cntx_idx_ring[ring->tail],
+			elem, nb * sizeof(uint16_t));
+		ring->tail += nb;
+	} else {
+		rte_memcpy(&ring->cntx_idx_ring[ring->tail],
+			elem,
+			(DPAA2_QDMA_MAX_DESC - ring->tail) *
+			sizeof(uint16_t));
+		rte_memcpy(&ring->cntx_idx_ring[0],
+			&elem[DPAA2_QDMA_MAX_DESC - ring->tail],
+			(nb - DPAA2_QDMA_MAX_DESC + ring->tail) *
+			sizeof(uint16_t));
+		ring->tail = (ring->tail + nb) & (DPAA2_QDMA_MAX_DESC - 1);
 	}
 	ring->free_space -= nb;
 	ring->nb_in_ring += nb;
Signature · 1 line
2.43.0
#14 lore raw

PATCH 13/45 drivers: add dpaa2 DMA bypass memory translation option

In reply to Prashant Gupta

From: Gagandeep Singh <[email protected]>

Add RTE_DPAAX_QDMA_BMT_FLAG flag to allow callers to bypass memory translation (BMT) for DMA operations. This is needed for some PCIe scenarios where IOMMU translation should be skipped.

The flag is propagated to all SG entry and FD populate helpers via a new 'bmt' parameter, defaulting to DISABLE when the flag is not set.

---
 drivers/common/dpaax/rte_pmd_dpaax_qdma.h |  4 +-
 drivers/dma/dpaa2/dpaa2_qdma.c            | 59 ++++++++++-------------
 2 files changed, 29 insertions(+), 34 deletions(-)
drivers/common/dpaax/rte_pmd_dpaax_qdma.h +3 -1
index 8f2fc83f8d..6bd72b0b0e 100644
@@ -1,5 +1,5 @@
 /* SPDX-License-Identifier: BSD-3-Clause
- * Copyright 2021-2024 NXP
+ * Copyright 2021-2024, 2026 NXP
  */
 
 #ifndef RTE_PMD_DPAAX_QDMA_H
@@ -7,6 +7,8 @@
 
 #include <rte_compat.h>
 
+#define RTE_DPAAX_QDMA_BMT_FLAG RTE_BIT64(7)
+
 #define RTE_DPAAX_QDMA_COPY_IDX_OFFSET 8
 #define RTE_DPAAX_QDMA_SG_IDX_ADDR_ALIGN \
 	RTE_BIT64(RTE_DPAAX_QDMA_COPY_IDX_OFFSET)
drivers/dma/dpaa2/dpaa2_qdma.c +26 -33

146 lines not on this page · raw message

Signature · 1 line
2.43.0
#15 lore raw

PATCH 14/45 mempool/dpaa2: support ops index from primary in secondary

In reply to Prashant Gupta

From: Jun Yang <[email protected]>

Secondary processes call rte_dpaa2_mpool_get_ops_idx() but the ops index is registered only in the primary process. The secondary had no way to learn the index, causing it to use the initial sentinel value RTE_MEMPOOL_MAX_OPS_IDX and return an error.

Register an IPC action handler in the primary during pool creation. Secondary processes send DPAA2_POOL_OPS_IDX_REQ over the dpaa2_pool_mp_sync channel and receive the ops index back.

Also handle the case where rte_mp_action_register returns ENOTSUP (e.g. no secondary process support enabled at build time) by treating it as non-fatal, and improve the error message in rte_hw_mbuf_free_pool to include the pool name.

---
 drivers/mempool/dpaa2/dpaa2_hw_mempool.c | 88 +++++++++++++++++++++++-
 1 file changed, 85 insertions(+), 3 deletions(-)
drivers/mempool/dpaa2/dpaa2_hw_mempool.c +85 -3
index ee001d8ce0..f19b6c039a 100644
@@ -34,16 +34,90 @@
 
 #include <dpaax_iova_table.h>
 
+#define DPAA2_POOL_MP_SYNC "dpaa2_pool_mp_sync"
+#define DPAA2_POOL_OPS_IDX_REQ 0x100
+#define DPAA2_POOL_OPS_IDX_RSP 0x101
+
+static int s_dpaa2_pool_mp_msg_setup;
+
+struct dpaa2_pool_mp_msg {
+	uint16_t msg_type;
+	uint8_t msg_data[];
+};
+
 RTE_EXPORT_INTERNAL_SYMBOL(rte_dpaa2_bpid_info)
 struct dpaa2_bp_info *rte_dpaa2_bpid_info;
 static struct dpaa2_bp_list *h_bp_list;
 
 static int16_t s_dpaa2_pool_ops_idx = RTE_MEMPOOL_MAX_OPS_IDX;
 
+static int
+dpaa2_mbuf_pool_mp_primary(const struct rte_mp_msg *msg,
+	const void *peer)
+{
+	struct rte_mp_msg reply;
+	const struct dpaa2_pool_mp_msg *req_msg = (const void *)msg->param;
+	struct dpaa2_pool_mp_msg *rsp_msg = (void *)reply.param;
+
+	memset(&reply, 0, sizeof(reply));
+
+	switch (req_msg->msg_type) {
+	case DPAA2_POOL_OPS_IDX_REQ:
+		rsp_msg->msg_type = DPAA2_POOL_OPS_IDX_RSP;
+		rte_memcpy(rsp_msg->msg_data, &s_dpaa2_pool_ops_idx,
+			sizeof(s_dpaa2_pool_ops_idx));
+		break;
+	default:
+		DPAA2_MEMPOOL_ERR("%s received invalid request(%d)",
+			__func__, req_msg->msg_type);
+		return -ENOTSUP;
+	}
+
+	strlcpy(reply.name, DPAA2_POOL_MP_SYNC, sizeof(reply.name));
+	return rte_mp_reply(&reply, peer);
+}
+
 RTE_EXPORT_INTERNAL_SYMBOL(rte_dpaa2_mpool_get_ops_idx)
 int rte_dpaa2_mpool_get_ops_idx(void)
 {
-	return s_dpaa2_pool_ops_idx;
+	struct rte_mp_msg mp_req;
+	struct rte_mp_reply mp_reply;
+	struct timespec ts = {.tv_sec = 5, .tv_nsec = 0};
+	int ret = 0;
+	struct dpaa2_pool_mp_msg *req_msg = (void *)mp_req.param;
+	struct dpaa2_pool_mp_msg *rsp_msg;
+
+	if (rte_eal_process_type() == RTE_PROC_PRIMARY ||
+		s_dpaa2_pool_ops_idx != RTE_MEMPOOL_MAX_OPS_IDX)
+		return s_dpaa2_pool_ops_idx;
+
+	strlcpy(mp_req.name, DPAA2_POOL_MP_SYNC, sizeof(mp_req.name));
+	req_msg->msg_type = DPAA2_POOL_OPS_IDX_REQ;
+	memset(&mp_reply, 0, sizeof(struct rte_mp_reply));
+	ret = rte_mp_request_sync(&mp_req, &mp_reply, &ts);
+	if (ret) {
+		DPAA2_MEMPOOL_ERR("%s Failed to get response(%d)",
+			__func__, ret);
+		return ret;
+	}
+	if (!mp_reply.msgs) {
+		DPAA2_MEMPOOL_ERR("%s Failed to get response message",
+			__func__);
+		return -EINVAL;
+	}
+	rsp_msg = (void *)mp_reply.msgs;
+	if (rsp_msg->msg_type == DPAA2_POOL_OPS_IDX_RSP) {
+		rte_memcpy(&s_dpaa2_pool_ops_idx, rsp_msg->msg_data,
+			sizeof(s_dpaa2_pool_ops_idx));
+		ret = 0;
+	} else {
+		DPAA2_MEMPOOL_ERR("%s received invalid response(%d)",
+			__func__, rsp_msg->msg_type);
+		ret = -EINVAL;
+	}
+	free(mp_reply.msgs);
+
+	return ret;
 }
 
 static int
@@ -128,10 +202,18 @@ rte_hw_mbuf_create_pool(struct rte_mempool *mp)
 	if (s_dpaa2_pool_ops_idx == RTE_MEMPOOL_MAX_OPS_IDX) {
 		s_dpaa2_pool_ops_idx = mp->ops_index;
 	} else if (s_dpaa2_pool_ops_idx != mp->ops_index) {
-		DPAA2_MEMPOOL_ERR("Only single ops index only");
+		DPAA2_MEMPOOL_ERR("Single ops index only");
 		ret = -EINVAL;
 		goto err4;
 	}
+	if (rte_eal_process_type() == RTE_PROC_PRIMARY &&
+		!s_dpaa2_pool_mp_msg_setup) {
+		ret = rte_mp_action_register(DPAA2_POOL_MP_SYNC,
+			dpaa2_mbuf_pool_mp_primary);
+		if (ret && rte_errno != ENOTSUP)
+			return ret;
+		s_dpaa2_pool_mp_msg_setup = 1;
+	}
 
 	bp_list->next = h_bp_list;
 	bp_list->mp = mp;
@@ -172,7 +254,7 @@ rte_hw_mbuf_free_pool(struct rte_mempool *mp)
 	struct dpaa2_dpbp_dev *dpbp_node;
 
 	if (!mp->pool_data) {
-		DPAA2_MEMPOOL_ERR("Not a valid dpaa2 buffer pool");
+		DPAA2_MEMPOOL_ERR("Not a valid dpaa2 buffer pool %s", mp->name);
 		return;
 	}
 
Signature · 1 line
2.43.0
#16 lore raw

PATCH 15/45 net/dpaa2: set Tx confirmation on device init

In reply to Prashant Gupta

From: Gagandeep Singh <[email protected]>

Move TX confirmation mode setting from TXQ setup to device initialization because TXQ0 is not always set up by the user.

---
 drivers/net/dpaa2/dpaa2_ethdev.c | 40 ++++++++++++--------------------
 1 file changed, 15 insertions(+), 25 deletions(-)
drivers/net/dpaa2/dpaa2_ethdev.c +15 -25
index f211357919..c95704d4ca 100644
@@ -1153,7 +1153,6 @@ dpaa2_dev_tx_queue_setup(struct rte_eth_dev *dev,
 	struct dpni_queue tx_conf_cfg;
 	struct dpni_queue tx_flow_cfg;
 	uint8_t options = 0, flow_id;
-	uint8_t ceetm_ch_idx;
 	uint16_t channel_id;
 	struct dpni_queue_id qid;
 	uint32_t tc_id;
@@ -1174,30 +1173,6 @@ dpaa2_dev_tx_queue_setup(struct rte_eth_dev *dev,
 	memset(&tx_conf_cfg, 0, sizeof(struct dpni_queue));
 	memset(&tx_flow_cfg, 0, sizeof(struct dpni_queue));
 
-	if (!tx_queue_id) {
-		for (ceetm_ch_idx = 0;
-			ceetm_ch_idx <= (priv->num_channels - 1);
-			ceetm_ch_idx++) {
-			/*Set tx-conf and error configuration*/
-			if (priv->flags & DPAA2_TX_CONF_ENABLE) {
-				ret = dpni_set_tx_confirmation_mode(dpni,
-						CMD_PRI_LOW, priv->token,
-						ceetm_ch_idx,
-						DPNI_CONF_AFFINE);
-			} else {
-				ret = dpni_set_tx_confirmation_mode(dpni,
-						CMD_PRI_LOW, priv->token,
-						ceetm_ch_idx,
-						DPNI_CONF_DISABLE);
-			}
-			if (ret) {
-				DPAA2_PMD_ERR("Error(%d) in tx conf setting",
-					ret);
-				return ret;
-			}
-		}
-	}
-
 	tc_id = tx_queue_id % priv->num_tx_tc;
 	channel_id = (uint8_t)(tx_queue_id / priv->num_tx_tc) % priv->num_channels;
 	flow_id = 0;
@@ -3624,6 +3599,21 @@ dpaa2_dev_init(struct rte_eth_dev *eth_dev)
 		goto init_err;
 	}
 
+	for (i = 0; i < priv->num_channels; i++) {
+		/*Set tx-conf and error configuration*/
+		if (priv->flags & DPAA2_TX_CONF_ENABLE) {
+			ret = dpni_set_tx_confirmation_mode(dpni_dev,
+				CMD_PRI_LOW, priv->token, i, DPNI_CONF_AFFINE);
+		} else {
+			ret = dpni_set_tx_confirmation_mode(dpni_dev,
+				CMD_PRI_LOW, priv->token, i, DPNI_CONF_DISABLE);
+		}
+		if (ret) {
+			DPAA2_PMD_ERR("Error(%d) in tx conf setting", ret);
+			goto init_err;
+		}
+	}
+
 	/* Allocate memory for storing MAC addresses.
 	 * Table of mac_filter_entries size is allocated so that RTE ether lib
 	 * can add MAC entries when rte_eth_dev_mac_addr_add is called.
Signature · 1 line
2.43.0
#17 lore raw

PATCH 16/45 drivers: optimize dpaa2 Tx queue and channel mapping

In reply to Prashant Gupta

From: Gagandeep Singh <[email protected]>

Allocate TX queues based on dpni attribute and align the bounds check with the RX queue logic:
- compute nb_tx_queues from num_tx_tcs * num_queues (respecting DPNI_OPT_SINGLE_SENDER) and cap at MAX_TX_QUEUES (128)
- cap nb_rx_queues at MAX_RX_QUEUES (128)
- cap num_channels at DPAA2_MAX_CHANNELS
- assign tc_index/flow_id at queue-allocation time instead of at queue-setup time
- replace the open-coded (channel << 8 | tc) with DPNI_BUILD_PARAM(channel, tc) throughout tx_queue_setup
- initialize fqid to DPAA2_INVALID_FQ_ID and use it as the already-configured guard (replacing DPAA2_INVALID_FLOW_ID)
- add a per-device tx_channels[] array for channel mapping

---
 drivers/bus/fslmc/portal/dpaa2_hw_pvt.h |   1 +
 drivers/net/dpaa2/dpaa2_ethdev.c        | 112 ++++++++++++++----------
 drivers/net/dpaa2/dpaa2_ethdev.h        |   5 +-
 3 files changed, 70 insertions(+), 48 deletions(-)
drivers/bus/fslmc/portal/dpaa2_hw_pvt.h +1 -0
index ef65e7895a..f0bc9a3063 100644
@@ -82,6 +82,7 @@
 
 #define DPAA2_DPCI_MAX_QUEUES 2
 #define DPAA2_INVALID_FLOW_ID 0xffff
+#define DPAA2_INVALID_FQ_ID ((uint32_t)(-1))
 #define DPAA2_INVALID_CGID 0xff
 
 #define SEC_FLC_DHR_OUTBOUND	(-114)
drivers/net/dpaa2/dpaa2_ethdev.c +66 -46

212 lines not on this page · raw message

drivers/net/dpaa2/dpaa2_ethdev.h +3 -2
index 149954fb6b..0366315ec7 100644
@@ -28,7 +28,7 @@
 
 #define MAX_TCS			DPNI_MAX_TC
 #define MAX_RX_QUEUES		128
-#define MAX_TX_QUEUES		16
+#define MAX_TX_QUEUES		128
 #define MAX_DPNI		8
 #define DPAA2_MAX_CHANNELS	16
 
@@ -390,13 +390,14 @@ struct dpaa2_dev_priv {
 	int32_t hw_id;
 	int32_t qdid;
 	uint16_t token;
+	uint16_t tx_channels[DPAA2_MAX_CHANNELS];
 	uint8_t nb_tx_queues;
 	uint8_t nb_rx_queues;
 	uint32_t options;
 	void *rx_vq[MAX_RX_QUEUES];
 	void *tx_vq[MAX_TX_QUEUES];
 	struct dpaa2_bp_list *bp_list; /**<Attached buffer pool list */
-	void *tx_conf_vq[MAX_TX_QUEUES * DPAA2_MAX_CHANNELS];
+	void *tx_conf_vq[MAX_TX_QUEUES];
 	void *rx_err_vq;
 	uint32_t flags; /*dpaa2 config flags */
 	uint8_t max_mac_filters;
Signature · 1 line
2.43.0
#18 lore raw

PATCH 17/45 net/dpaa2: support larger burst size

In reply to Prashant Gupta

From: Gagandeep Singh <[email protected]>

Make burst size checks and MC command fields SoC-aware, enabling bursts larger than 64K on LX2160A with dpni version 8.7+.

The max_burst_size field in dpni_tx_shaping_cfg is widened to uint32_t and the MC command struct is updated to split the value across two 16-bit fields using the new DPNI_BURST_LO/HI macros.

---
 drivers/net/dpaa2/dpaa2_tm.c        | 16 +++++++++++-----
 drivers/net/dpaa2/mc/dpni.c         | 11 +++++++++--
 drivers/net/dpaa2/mc/fsl_dpni.h     |  8 ++++++--
 drivers/net/dpaa2/mc/fsl_dpni_cmd.h |  3 ++-
 4 files changed, 28 insertions(+), 10 deletions(-)
drivers/net/dpaa2/dpaa2_tm.c +11 -5
index 36e815c356..0e1b2c5b54 100644
@@ -1,5 +1,5 @@
 /* SPDX-License-Identifier: BSD-3-Clause
- * Copyright 2020-2024 NXP
+ * Copyright 2020-2026 NXP
  */
 
 #include <rte_ethdev.h>
@@ -10,14 +10,20 @@
 #include "dpaa2_pmd_logs.h"
 #include <dpaa2_hw_dpio.h>
 
-#define DPAA2_BURST_MAX	(64 * 1024)
-
 #define DPAA2_SHAPER_MIN_RATE 0
 #define DPAA2_SHAPER_MAX_RATE 107374182400ull
 #define DPAA2_WEIGHT_MAX 24701
 #define DPAA2_PKT_ADJUST_LEN_MIN 0
 #define DPAA2_PKT_ADJUST_LEN_MAX 0x7ff
 
+static inline uint32_t dpaa2_get_burst_max(struct dpaa2_dev_priv *priv)
+{
+	if (priv->dpni_ver_major == 8 && priv->dpni_ver_minor >= 7)
+		return (dpaa2_svr_family == SVR_LX2160A) ? 229375 : (64 * 1024);
+
+	return (64 * 1024);
+}
+
 int
 dpaa2_tm_init(struct rte_eth_dev *dev)
 {
@@ -283,7 +289,7 @@ dpaa2_shaper_profile_add(struct rte_eth_dev *dev, uint32_t shaper_profile_id,
 				RTE_TM_ERROR_TYPE_SHAPER_PROFILE_PEAK_RATE,
 				NULL, "committed rate is out of range\n");
 
-	if (params->committed.size > DPAA2_BURST_MAX)
+	if (params->committed.size > dpaa2_get_burst_max(priv))
 		return -rte_tm_error_set(error, EINVAL,
 				RTE_TM_ERROR_TYPE_SHAPER_PROFILE_PEAK_SIZE,
 				NULL, "committed size is out of range\n");
@@ -293,7 +299,7 @@ dpaa2_shaper_profile_add(struct rte_eth_dev *dev, uint32_t shaper_profile_id,
 				RTE_TM_ERROR_TYPE_SHAPER_PROFILE_PEAK_RATE,
 				NULL, "Peak rate is out of range\n");
 
-	if (params->peak.size > DPAA2_BURST_MAX)
+	if (params->peak.size > dpaa2_get_burst_max(priv))
 		return -rte_tm_error_set(error, EINVAL,
 				RTE_TM_ERROR_TYPE_SHAPER_PROFILE_PEAK_SIZE,
 				NULL, "Peak size is out of range\n");
drivers/net/dpaa2/mc/dpni.c +9 -2
index d0a9fefd31..17275b7195 100644
@@ -1106,6 +1106,7 @@ int dpni_set_tx_shaping(struct fsl_mc_io *mc_io,
 {
 	struct dpni_cmd_set_tx_shaping *cmd_params;
 	struct mc_command cmd = { 0 };
+	uint32_t tx_cr_burst, tx_er_burst;
 	int coupled, lni_shaper;
 	uint8_t channel_id;
 	uint16_t oal;
@@ -1115,10 +1116,16 @@ int dpni_set_tx_shaping(struct fsl_mc_io *mc_io,
 					  cmd_flags,
 					  token);
 	cmd_params = (struct dpni_cmd_set_tx_shaping *)cmd.params;
+	tx_cr_burst = tx_cr_shaper->max_burst_size;
+	tx_er_burst = tx_er_shaper->max_burst_size;
 	cmd_params->tx_cr_max_burst_size =
-		cpu_to_le16(tx_cr_shaper->max_burst_size);
+		cpu_to_le16(DPNI_BURST_LO(tx_cr_burst));
 	cmd_params->tx_er_max_burst_size =
-		cpu_to_le16(tx_er_shaper->max_burst_size);
+		cpu_to_le16(DPNI_BURST_LO(tx_er_burst));
+	cmd_params->tx_cr_max_burst_size_hi =
+		cpu_to_le16(DPNI_BURST_HI(tx_cr_burst));
+	cmd_params->tx_er_max_burst_size_hi =
+		cpu_to_le16(DPNI_BURST_HI(tx_er_burst));
 	cmd_params->tx_cr_rate_limit =
 		cpu_to_le32(tx_cr_shaper->rate_limit);
 	cmd_params->tx_er_rate_limit =
drivers/net/dpaa2/mc/fsl_dpni.h +6 -2
index 42d633eaf8..8913b408e7 100644
@@ -830,14 +830,18 @@ int dpni_get_link_state(struct fsl_mc_io *mc_io,
 			uint16_t token,
 			struct dpni_link_state *state);
 
+#define DPNI_BURST_LO(burst)	((burst) & GENMASK(15, 0))
+#define DPNI_BURST_HI(burst)	((burst) >> 16)
+
 /**
  * struct dpni_tx_shaping - Structure representing DPNI tx shaping configuration
  * @rate_limit:		Rate in Mbits/s
- * @max_burst_size:	Burst size in bytes (up to 64KB)
+ * @max_burst_size:	Burst size in bytes. Limits depend on the SoC (0x37FFF
+ *		for LX2160A, 0xF7FF for all others)
  */
 struct dpni_tx_shaping_cfg {
 	uint32_t rate_limit;
-	uint16_t max_burst_size;
+	uint32_t max_burst_size;
 };
 
 /**
drivers/net/dpaa2/mc/fsl_dpni_cmd.h +2 -1
index bb4939031b..6b396ca7cc 100644
@@ -394,7 +394,8 @@ struct dpni_rsp_get_link_state {
 struct dpni_cmd_set_tx_shaping {
 	uint16_t tx_cr_max_burst_size;
 	uint16_t tx_er_max_burst_size;
-	uint32_t pad;
+	uint16_t tx_cr_max_burst_size_hi;
+	uint16_t tx_er_max_burst_size_hi;
 	uint32_t tx_cr_rate_limit;
 	uint32_t tx_er_rate_limit;
 	/* from LSB: coupled:1, lni_shaper: 1*/
Signature · 1 line
2.43.0
#19 lore raw

PATCH 18/45 net/dpaa2: support MPLS and PPPoE flow distribution

In reply to Prashant Gupta

From: Gagandeep Singh <[email protected]>

Add rte_flow pattern support for MPLS and PPPoE items in the dpaa2 PMD flow engine.

For a pattern with no spec/mask, the frame is identified by its Frame Attribute Flag (FAF_MPLS_FRAM / FAF_PPPOE_PPP_FRAM) for both the QoS and flow steering tables. When a spec is present, the MPLS label (NH_FLD_MPLS_MPLSL_1) or the PPPoE session id (NH_FLD_PPPOE_SID) is added as a header extract rule for both tables.

---
 drivers/net/dpaa2/dpaa2_flow.c | 196 +++++++++++++++++++++++++++++++++
 1 file changed, 196 insertions(+)
drivers/net/dpaa2/dpaa2_flow.c +196 -0
index 2e44bff766..90e0b66258 100644
@@ -80,6 +80,8 @@ enum rte_flow_item_type dpaa2_hp_supported_pattern_type[] = {
 	RTE_FLOW_ITEM_TYPE_GTP,
 	RTE_FLOW_ITEM_TYPE_ESP,
 	RTE_FLOW_ITEM_TYPE_AH,
+	RTE_FLOW_ITEM_TYPE_MPLS,
+	RTE_FLOW_ITEM_TYPE_PPPOES,
 	RTE_FLOW_ITEM_TYPE_RAW
 };
 
@@ -180,8 +182,17 @@ static const struct rte_flow_item_gtp dpaa2_flow_item_gtp_mask = {
 	.teid = RTE_BE32(0xffffffff),
 };
 
+static const struct rte_flow_item_mpls dpaa2_flow_item_mpls_mask = {
+	.label_tc_s = { 0xff, 0xff, 0xff },
+};
+
+static const struct rte_flow_item_pppoe dpaa2_flow_item_pppoe_mask = {
+	.session_id = RTE_BE16(0xffff),
+};
+
 #endif
 
+
 #define DPAA2_FLOW_DUMP printf
 
 static inline void
@@ -1764,6 +1775,14 @@ dpaa2_flow_extract_support(const uint8_t *mask_src,
 		mask_support = (const char *)&dpaa2_flow_item_gtp_mask;
 		size = sizeof(struct rte_flow_item_gtp);
 		break;
+	case RTE_FLOW_ITEM_TYPE_MPLS:
+		mask_support = (const char *)&dpaa2_flow_item_mpls_mask;
+		size = sizeof(struct rte_flow_item_mpls);
+		break;
+	case RTE_FLOW_ITEM_TYPE_PPPOES:
+		mask_support = (const char *)&dpaa2_flow_item_pppoe_mask;
+		size = sizeof(struct rte_flow_item_pppoe);
+		break;
 	default:
 		return -EINVAL;
 	}
@@ -4041,6 +4060,163 @@ dpaa2_configure_flow_gtp(struct dpaa2_dev_flow *flow,
 	return 0;
 }
 
+static int
+dpaa2_configure_flow_mpls(struct dpaa2_dev_flow *flow,
+	struct rte_eth_dev *dev,
+	const struct rte_flow_attr *attr,
+	const struct rte_dpaa2_flow_item *dpaa2_pattern,
+	const struct rte_flow_action actions[] __rte_unused,
+	struct rte_flow_error *error __rte_unused,
+	int *device_configured)
+{
+	int ret, local_cfg = 0;
+	uint32_t group;
+	const struct rte_flow_item_mpls *spec, *mask;
+	struct dpaa2_dev_priv *priv = dev->data->dev_private;
+	const struct rte_flow_item *pattern =
+		&dpaa2_pattern->generic_item;
+
+	group = attr->group;
+
+	/* Parse pattern list to get the matching parameters */
+	spec = pattern->spec;
+	mask = pattern->mask ?
+		pattern->mask : &dpaa2_flow_item_mpls_mask;
+
+	/* Get traffic class index and flow id to be configured */
+	flow->tc_id = group;
+	flow->tc_index = attr->priority;
+
+	if (dpaa2_pattern->in_tunnel) {
+		DPAA2_PMD_ERR("Tunnel-MPLS distribution not support");
+		return -ENOTSUP;
+	}
+
+	if (!spec) {
+		ret = dpaa2_flow_identify_by_faf(priv, flow,
+				FAF_MPLS_FRAM, DPAA2_FLOW_QOS_TYPE,
+				group, &local_cfg);
+		if (ret)
+			return ret;
+
+		ret = dpaa2_flow_identify_by_faf(priv, flow,
+				FAF_MPLS_FRAM, DPAA2_FLOW_FS_TYPE,
+				group, &local_cfg);
+		if (ret)
+			return ret;
+
+		(*device_configured) |= local_cfg;
+		return 0;
+	}
+
+	ret = dpaa2_flow_extract_support((const uint8_t *)mask,
+		RTE_FLOW_ITEM_TYPE_MPLS);
+	if (ret) {
+		DPAA2_PMD_WARN("Extract field(s) of MPLS not support.");
+		return ret;
+	}
+
+	if (!mask->label_tc_s[0] && !mask->label_tc_s[1] &&
+		!mask->label_tc_s[2])
+		return 0;
+
+	ret = dpaa2_flow_add_hdr_extract_rule(flow, NET_PROT_MPLS,
+			NH_FLD_MPLS_MPLSL_1, spec->label_tc_s,
+			mask->label_tc_s, sizeof(mask->label_tc_s),
+			priv, group, &local_cfg, DPAA2_FLOW_QOS_TYPE);
+	if (ret)
+		return ret;
+
+	ret = dpaa2_flow_add_hdr_extract_rule(flow, NET_PROT_MPLS,
+			NH_FLD_MPLS_MPLSL_1, spec->label_tc_s,
+			mask->label_tc_s, sizeof(mask->label_tc_s),
+			priv, group, &local_cfg, DPAA2_FLOW_FS_TYPE);
+	if (ret)
+		return ret;
+
+	(*device_configured) |= local_cfg;
+
+	return 0;
+}
+
+static int
+dpaa2_configure_flow_pppoe(struct dpaa2_dev_flow *flow,
+	struct rte_eth_dev *dev,
+	const struct rte_flow_attr *attr,
+	const struct rte_dpaa2_flow_item *dpaa2_pattern,
+	const struct rte_flow_action actions[] __rte_unused,
+	struct rte_flow_error *error __rte_unused,
+	int *device_configured)
+{
+	int ret, local_cfg = 0;
+	uint32_t group;
+	const struct rte_flow_item_pppoe *spec, *mask;
+	struct dpaa2_dev_priv *priv = dev->data->dev_private;
+	const struct rte_flow_item *pattern =
+		&dpaa2_pattern->generic_item;
+
+	group = attr->group;
+
+	/* Parse pattern list to get the matching parameters */
+	spec = pattern->spec;
+	mask = pattern->mask ?
+		pattern->mask : &dpaa2_flow_item_pppoe_mask;
+
+	/* Get traffic class index and flow id to be configured */
+	flow->tc_id = group;
+	flow->tc_index = attr->priority;
+
+	if (dpaa2_pattern->in_tunnel) {
+		DPAA2_PMD_ERR("Tunnel-PPPoE distribution not support");
+		return -ENOTSUP;
+	}
+
+	if (!spec) {
+		ret = dpaa2_flow_identify_by_faf(priv, flow,
+				FAF_PPPOE_PPP_FRAM, DPAA2_FLOW_QOS_TYPE,
+				group, &local_cfg);
+		if (ret)
+			return ret;
+
+		ret = dpaa2_flow_identify_by_faf(priv, flow,
+				FAF_PPPOE_PPP_FRAM, DPAA2_FLOW_FS_TYPE,
+				group, &local_cfg);
+		if (ret)
+			return ret;
+
+		(*device_configured) |= local_cfg;
+		return 0;
+	}
+
+	ret = dpaa2_flow_extract_support((const uint8_t *)mask,
+		RTE_FLOW_ITEM_TYPE_PPPOES);
+	if (ret) {
+		DPAA2_PMD_WARN("Extract field(s) of PPPoE not support.");
+		return ret;
+	}
+
+	if (!mask->session_id)
+		return 0;
+
+	ret = dpaa2_flow_add_hdr_extract_rule(flow, NET_PROT_PPPOE,
+			NH_FLD_PPPOE_SID, &spec->session_id,
+			&mask->session_id, sizeof(rte_be16_t),
+			priv, group, &local_cfg, DPAA2_FLOW_QOS_TYPE);
+	if (ret)
+		return ret;
+
+	ret = dpaa2_flow_add_hdr_extract_rule(flow, NET_PROT_PPPOE,
+			NH_FLD_PPPOE_SID, &spec->session_id,
+			&mask->session_id, sizeof(rte_be16_t),
+			priv, group, &local_cfg, DPAA2_FLOW_FS_TYPE);
+	if (ret)
+		return ret;
+
+	(*device_configured) |= local_cfg;
+
+	return 0;
+}
+
 static int
 dpaa2_configure_flow_raw(struct dpaa2_dev_flow *flow,
 	struct rte_eth_dev *dev,
@@ -4712,6 +4888,26 @@ dpaa2_generic_flow_set(struct dpaa2_dev_flow *flow,
 				goto end_flow_set;
 			}
 			break;
+		case RTE_FLOW_ITEM_TYPE_MPLS:
+			ret = dpaa2_configure_flow_mpls(flow,
+					dev, attr, &dpaa2_pattern[i],
+					actions, error,
+					&is_keycfg_configured);
+			if (ret) {
+				DPAA2_PMD_ERR("MPLS flow config failed!");
+				goto end_flow_set;
+			}
+			break;
+		case RTE_FLOW_ITEM_TYPE_PPPOES:
+			ret = dpaa2_configure_flow_pppoe(flow,
+					dev, attr, &dpaa2_pattern[i],
+					actions, error,
+					&is_keycfg_configured);
+			if (ret) {
+				DPAA2_PMD_ERR("PPPoE flow config failed!");
+				goto end_flow_set;
+			}
+			break;
 		case RTE_FLOW_ITEM_TYPE_RAW:
 			ret = dpaa2_configure_flow_raw(flow, dev, attr,
 					&dpaa2_pattern[i],
Signature · 1 line
2.43.0
#20 lore raw

PATCH 19/45 net/dpaa2: support meter and policing

In reply to Prashant Gupta

From: Gagandeep Singh <[email protected]>

Add support for the traffic metering and policing (rte_mtr) API to the dpaa2 PMD. The implementation registers the rte_mtr operations through the ".mtr_ops_get" dev_ops hook and maintains software bookkeeping of meter profiles, policies and meter objects under a per-device spinlock.

Supported algorithms are trTCM RFC 2698 and trTCM RFC 4115 in both byte and packet modes. Meter policies support drop and pass-through actions on the red color.

---
 drivers/net/dpaa2/dpaa2_ethdev.c |   1 +
 drivers/net/dpaa2/dpaa2_ethdev.h |  29 ++
 drivers/net/dpaa2/dpaa2_meter.c  | 588 +++++++++++++++++++++++++++++++
 drivers/net/dpaa2/mc/fsl_dpni.h  |  23 +-
 drivers/net/dpaa2/meson.build    |   1 +
 5 files changed, 638 insertions(+), 4 deletions(-)
 create mode 100644 drivers/net/dpaa2/dpaa2_meter.c
drivers/net/dpaa2/dpaa2_ethdev.c +1 -0
index d79dfa7114..c8abab830f 100644
@@ -3322,6 +3322,7 @@ static struct eth_dev_ops dpaa2_ethdev_ops = {
 	.rxq_info_get	      = dpaa2_rxq_info_get,
 	.txq_info_get	      = dpaa2_txq_info_get,
 	.tm_ops_get	      = dpaa2_tm_ops_get,
+	.mtr_ops_get	      = dpaa2_mtr_ops_get,
 #if defined(RTE_LIBRTE_IEEE1588)
 	.timesync_enable      = dpaa2_timesync_enable,
 	.timesync_disable     = dpaa2_timesync_disable,
drivers/net/dpaa2/dpaa2_ethdev.h +29 -0
index 0366315ec7..c5aac65c28 100644
@@ -385,6 +385,30 @@ struct extract_s {
 	uint8_t *tc_extract_param[MAX_TCS];
 };
 
+struct dpaa2_dev_meter_profile {
+	LIST_ENTRY(dpaa2_dev_meter_profile) next;
+	uint32_t profile_id;
+	uint64_t cir;
+	uint64_t cbs;
+	uint64_t pir;
+	uint64_t pbs;
+	enum dpni_policer_mode mode;
+	enum dpni_policer_unit policer_unit;
+};
+
+struct dpaa2_dev_meter_policy {
+	LIST_ENTRY(dpaa2_dev_meter_policy) next;
+	uint32_t policy_id;
+	int red_drop;
+};
+
+struct dpaa2_dev_meter {
+	LIST_ENTRY(dpaa2_dev_meter) next;
+	uint32_t meter_id;
+	uint32_t profile_id;
+	uint32_t policy_id;
+};
+
 struct dpaa2_dev_priv {
 	void *hw;
 	int32_t hw_id;
@@ -412,6 +436,7 @@ struct dpaa2_dev_priv {
 	uint8_t en_loose_ordered;
 	uint8_t max_cgs;
 	uint8_t cgid_in_use[MAX_RX_QUEUES];
+	rte_spinlock_t meter_lock;
 
 	/* Current hash distribution size per RX TC, written by
 	 * dpaa2_setup_flow_dist_size() and read by reta_query / reta_update.
@@ -457,6 +482,9 @@ struct dpaa2_dev_priv {
 
 	struct dpaa2_dev_flow *curr;
 	LIST_HEAD(, dpaa2_dev_flow) flows;
+	LIST_HEAD(, dpaa2_dev_meter_profile) profiles;
+	LIST_HEAD(, dpaa2_dev_meter_policy) policies;
+	LIST_HEAD(, dpaa2_dev_meter) meters;
 	LIST_HEAD(nodes, dpaa2_tm_node) nodes;
 	LIST_HEAD(shaper_profiles, dpaa2_tm_shaper_profile) shaper_profiles;
 };
@@ -549,6 +577,7 @@ int dpaa2_timesync_read_tx_timestamp(struct rte_eth_dev *dev,
 
 int dpaa2_dev_recycle_config(struct rte_eth_dev *eth_dev);
 int dpaa2_dev_recycle_deconfig(struct rte_eth_dev *eth_dev);
+int dpaa2_mtr_ops_get(struct rte_eth_dev *dev, void *ops);
 int dpaa2_soft_parser_loaded(void);
 
 void
drivers/net/dpaa2/dpaa2_meter.c new file +588 -0

588 lines not on this page · raw message

drivers/net/dpaa2/mc/fsl_dpni.h +19 -4
index 8913b408e7..d227025e01 100644
@@ -1111,6 +1111,11 @@ int dpni_set_rx_tc_dist(struct fsl_mc_io *mc_io,
  */
 #define DPNI_POLICER_OPT_DISCARD_RED	0x00000002
 
+/**
+ * Do NOT reset counters generally for policer update
+ */
+#define DPNI_POLICER_OPT_DO_NOT_RESET_COUNTERS	0x00000004
+
 /**
  * enum dpni_policer_mode - selecting the policer mode
  * @DPNI_POLICER_MODE_NONE: Policer is disabled
@@ -1127,12 +1132,17 @@ enum dpni_policer_mode {
 
 /**
  * enum dpni_policer_unit - DPNI policer units
- * @DPNI_POLICER_UNIT_BYTES: bytes units
+ * @DPNI_POLICER_UNIT_BYTES_L3: bytes units (for each frame takes into account
+ * FD length - L3 offset)
  * @DPNI_POLICER_UNIT_FRAMES: frames units
+ * @DPNI_POLICER_UNIT_BYTES_L2_WITHOUT_FCS: bytes units (for each frame takes
+ * into account FD length - L2 offset, which means L2 size without the 4 bytes
+ * for the FCS)
  */
 enum dpni_policer_unit {
-	DPNI_POLICER_UNIT_BYTES = 0,
-	DPNI_POLICER_UNIT_FRAMES
+	DPNI_POLICER_UNIT_BYTES_L3 = 0,
+	DPNI_POLICER_UNIT_FRAMES,
+	DPNI_POLICER_UNIT_BYTES_L2_WITHOUT_FCS,
 };
 
 /**
@@ -1173,13 +1183,18 @@ struct dpni_rx_tc_policing_cfg {
 	uint32_t ebs;
 };
 
-
 int dpni_set_rx_tc_policing(struct fsl_mc_io *mc_io,
 			    uint32_t cmd_flags,
 			    uint16_t token,
 			    uint8_t tc_id,
 			    const struct dpni_rx_tc_policing_cfg *cfg);
 
+int dpni_set_rx_tc_policing_v1(struct fsl_mc_io *mc_io,
+			    uint32_t cmd_flags,
+			    uint16_t token,
+			    uint8_t tc_id,
+			    const struct dpni_rx_tc_policing_cfg *cfg);
+
 int dpni_get_rx_tc_policing(struct fsl_mc_io *mc_io,
 			    uint32_t cmd_flags,
 			    uint16_t token,
drivers/net/dpaa2/meson.build +1 -0
index 4094ea02ba..808dad8112 100644
@@ -11,6 +11,7 @@ sources = files(
         'base/dpaa2_hw_dpni.c',
         'base/dpaa2_tlu_hash.c',
         'dpaa2_tm.c',
+        'dpaa2_meter.c',
         'dpaa2_mux.c',
         'dpaa2_ethdev.c',
         'dpaa2_flow.c',
Signature · 1 line
2.43.0
#21 lore raw

PATCH 20/45 net/dpaa2: support flow drop action

In reply to Prashant Gupta

From: Gagandeep Singh <[email protected]>

Add support for the RTE_FLOW_ACTION_TYPE_DROP action in the dpaa2 flow engine. A flow rule with a drop action is programmed into the flow steering (FS) table with the DPNI_FS_OPT_DISCARD option so that matching frames are discarded by hardware.

The drop action is added to the supported action list, accepted during action verification, configured in the FS action path, handled in the generic flow-set action loop, and cleaned up in the flow destroy path.

---
 drivers/net/dpaa2/dpaa2_flow.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/net/dpaa2/dpaa2_flow.c +7 -1
index 90e0b66258..b2f1778de3 100644
@@ -97,7 +97,8 @@ enum rte_flow_action_type dpaa2_supported_action_type[] = {
 	RTE_FLOW_ACTION_TYPE_QUEUE,
 	RTE_FLOW_ACTION_TYPE_PORT_ID,
 	RTE_FLOW_ACTION_TYPE_REPRESENTED_PORT,
-	RTE_FLOW_ACTION_TYPE_RSS
+	RTE_FLOW_ACTION_TYPE_RSS,
+	RTE_FLOW_ACTION_TYPE_DROP
 };
 
 #ifndef __cplusplus
@@ -4421,6 +4422,7 @@ dpaa2_flow_verify_action(struct dpaa2_dev_priv *priv,
 			break;
 		case RTE_FLOW_ACTION_TYPE_PF:
 			/* Skip this action, have to add for vxlan */
+		case RTE_FLOW_ACTION_TYPE_DROP:
 			break;
 		case RTE_FLOW_ACTION_TYPE_END:
 			end_of_list = 1;
@@ -4468,6 +4470,8 @@ dpaa2_configure_flow_fs_action(struct dpaa2_dev_priv *priv,
 		flow->fs_action_cfg.redirect_obj_token =
 			dest_priv->token;
 		flow->fs_action_cfg.flow_id = dest_q->flow_id;
+	} else if (flow->action_type == RTE_FLOW_ACTION_TYPE_DROP) {
+		flow->fs_action_cfg.options = DPNI_FS_OPT_DISCARD;
 	}
 
 	return 0;
@@ -4945,6 +4949,7 @@ dpaa2_generic_flow_set(struct dpaa2_dev_flow *flow,
 		case RTE_FLOW_ACTION_TYPE_QUEUE:
 		case RTE_FLOW_ACTION_TYPE_REPRESENTED_PORT:
 		case RTE_FLOW_ACTION_TYPE_PORT_ID:
+		case RTE_FLOW_ACTION_TYPE_DROP:
 			ret = dpaa2_configure_flow_fs_action(priv, flow,
 							     &actions[j]);
 			if (ret)
@@ -5346,6 +5351,7 @@ dpaa2_flow_destroy(struct rte_eth_dev *dev, struct rte_flow *_flow,
 	case RTE_FLOW_ACTION_TYPE_QUEUE:
 	case RTE_FLOW_ACTION_TYPE_REPRESENTED_PORT:
 	case RTE_FLOW_ACTION_TYPE_PORT_ID:
+	case RTE_FLOW_ACTION_TYPE_DROP:
 		if (priv->num_rx_tc > 1) {
 			/* Remove entry from QoS table first */
 			ret = dpni_remove_qos_entry(dpni, CMD_PRI_LOW,
Signature · 1 line
2.43.0
#22 lore raw

PATCH 21/45 net/dpaa2: set default flow miss action per device

In reply to Prashant Gupta

From: Gagandeep Singh <[email protected]>

The flow steering miss flow id was a file-scope global configured only via the DPAA2_FLOW_CONTROL_MISS_FLOW environment variable and defaulted to 0. Replace it with a per-device default_flow computed at probe time as the lowest priority flow of the FS table, so that unmatched frames are directed there without depending on an environment variable.

---
 drivers/net/dpaa2/dpaa2_ethdev.c |  2 ++
 drivers/net/dpaa2/dpaa2_ethdev.h |  2 ++
 drivers/net/dpaa2/dpaa2_flow.c   | 14 +-------------
 3 files changed, 5 insertions(+), 13 deletions(-)
drivers/net/dpaa2/dpaa2_ethdev.c +2 -0
index c8abab830f..387a153036 100644
@@ -3545,6 +3545,8 @@ dpaa2_dev_init(struct rte_eth_dev *eth_dev)
 	priv->dist_queues = attr.num_queues;
 	priv->num_channels = attr.num_channels;
 	priv->channel_inuse = 0;
+	priv->default_flow = RTE_MIN(priv->fs_entries,
+		priv->dist_queues) - 1;
 	rte_spinlock_init(&priv->lpbk_qp_lock);
 
 	/* only if the custom CG is enabled */
drivers/net/dpaa2/dpaa2_ethdev.h +2 -0
index c5aac65c28..4501bd9e49 100644
@@ -437,6 +437,8 @@ struct dpaa2_dev_priv {
 	uint8_t max_cgs;
 	uint8_t cgid_in_use[MAX_RX_QUEUES];
 	rte_spinlock_t meter_lock;
+	/* Lowest priority FS flow id to receive flow steering miss frames. */
+	uint16_t default_flow;
 
 	/* Current hash distribution size per RX TC, written by
 	 * dpaa2_setup_flow_dist_size() and read by reta_query / reta_update.
drivers/net/dpaa2/dpaa2_flow.c +1 -13
index b2f1778de3..2e844121a8 100644
@@ -24,7 +24,6 @@
 #include <dpaa2_pmd_logs.h>
 
 static char *dpaa2_flow_control_log;
-static uint16_t dpaa2_flow_miss_flow_id; /* Default miss flow id is 0. */
 static int dpaa2_sp_loaded = -1;
 
 enum dpaa2_flow_entry_size {
@@ -4590,7 +4589,7 @@ dpaa2_configure_fs_rss_table(struct dpaa2_dev_priv *priv,
 		return 0;
 
 	tc_cfg.enable = true;
-	tc_cfg.fs_miss_flow_id = dpaa2_flow_miss_flow_id;
+	tc_cfg.fs_miss_flow_id = priv->default_flow;
 	ret = dpni_set_rx_fs_dist(dpni, CMD_PRI_LOW,
 			priv->token, &tc_cfg);
 	if (ret < 0) {
@@ -5224,17 +5223,6 @@ dpaa2_flow_create(struct rte_eth_dev *dev, const struct rte_flow_attr *attr,
 	dpaa2_flow_control_log =
 		getenv("DPAA2_FLOW_CONTROL_LOG");
 
-	if (getenv("DPAA2_FLOW_CONTROL_MISS_FLOW")) {
-		dpaa2_flow_miss_flow_id =
-			(uint16_t)atoi(getenv("DPAA2_FLOW_CONTROL_MISS_FLOW"));
-		if (dpaa2_flow_miss_flow_id >= priv->dist_queues) {
-			DPAA2_PMD_ERR("Missed flow ID %d >= dist size(%d)",
-				      dpaa2_flow_miss_flow_id,
-				      priv->dist_queues);
-			return NULL;
-		}
-	}
-
 	flow = rte_zmalloc(NULL, sizeof(struct dpaa2_dev_flow),
 			   RTE_CACHE_LINE_SIZE);
 	if (!flow) {
Signature · 1 line
2.43.0
#23 lore raw

PATCH 22/45 net/dpaa2: identify Rx mbuf hash information by FLC

In reply to Prashant Gupta

From: Gagandeep Singh <[email protected]>

For default RSS distribution, mbuf is marked with RTE_MBUF_F_RX_RSS_HASH and the hash value from the high word of FLC.

Configure the flow steering action with FLC enabled to align the stashing setting with the RSS configuration. The TC ID and flow ID are packed into the FLC for mbuf Rx scheduling. An Rx mbuf received from the FS table is marked with RTE_MBUF_F_RX_FDIR along with the TC and flow ID decoded from the FLC low word.

---
 drivers/net/dpaa2/dpaa2_ethdev.h | 12 +++++++++
 drivers/net/dpaa2/dpaa2_flow.c   | 42 ++++++++++++++++++++++++++++++++
 drivers/net/dpaa2/dpaa2_rxtx.c   | 18 ++++++++++++--
 3 files changed, 70 insertions(+), 2 deletions(-)
drivers/net/dpaa2/dpaa2_ethdev.h +12 -0
index 4501bd9e49..c693989998 100644
@@ -282,6 +282,18 @@ enum dpaa2_ecpri_fafe_type {
 /* ECPRI shares SP context with VXLAN*/
 #define DPAA2_ECPRI_MSG_OFFSET DPAA2_VXLAN_VNI_OFFSET
 
+#define DPAA2_FS_FLC_FS_MARK_OFFSET \
+	(DPAA2_FLC_DATA_STASHING + DPAA2_FLC_STASHING_MAX_BIT_SIZE)
+
+#define DPAA2_FS_FLC_TC_OFFSET \
+	(DPAA2_FS_FLC_FS_MARK_OFFSET + DPAA2_FLC_STASHING_MAX_BIT_SIZE)
+
+#define DPAA2_FS_FLC_TC_BIT_SIZE (sizeof(uint8_t) * 8)
+#define DPAA2_FS_FLC_TC_MASK ((1 << DPAA2_FS_FLC_TC_BIT_SIZE) - 1)
+
+#define DPAA2_FS_FLC_FLOW_OFFSET \
+	(DPAA2_FS_FLC_TC_OFFSET + DPAA2_FS_FLC_TC_BIT_SIZE)
+
 #define DPAA2_ECPRI_MAX_EXTRACT_NB 8
 
 struct ipv4_sd_addr_extract_rule {
drivers/net/dpaa2/dpaa2_flow.c +42 -0

61 lines not on this page · raw message

drivers/net/dpaa2/dpaa2_rxtx.c +16 -2
index c31d6556ad..7ba6a4563f 100644
@@ -58,6 +58,7 @@ dpaa2_dev_rx_parse_new(struct rte_mbuf *m, const struct qbman_fd *fd,
 	uint16_t frc = DPAA2_GET_FD_FRC_PARSE_SUM(fd);
 	struct dpaa2_annot_hdr *annotation =
 			(struct dpaa2_annot_hdr *)hw_annot_addr;
+	uint32_t flc_lo, tc, flow;
 
 	if (unlikely(dpaa2_print_parser_result))
 		dpaa2_print_parse_result(annotation);
@@ -118,8 +119,21 @@ dpaa2_dev_rx_parse_new(struct rte_mbuf *m, const struct qbman_fd *fd,
 	default:
 		m->packet_type = dpaa2_dev_rx_parse_slow(m, annotation);
 	}
-	m->hash.rss = fd->simple.flc_hi;
-	m->ol_flags |= RTE_MBUF_F_RX_RSS_HASH;
+	flc_lo = fd->simple.flc_lo;
+	if (flc_lo & (1 << DPAA2_FS_FLC_FS_MARK_OFFSET)) {
+		m->ol_flags |= RTE_MBUF_F_RX_FDIR;
+		tc = (flc_lo >> DPAA2_FS_FLC_TC_OFFSET) &
+			DPAA2_FS_FLC_TC_MASK;
+		flow = flc_lo >> DPAA2_FS_FLC_FLOW_OFFSET;
+		rte_mbuf_sched_set(m, flow, tc, 0);
+		DPAA2_PMD_DP_DEBUG("FS frame received from TC[%d]->flow%d",
+			tc, flow);
+	} else {
+		m->hash.rss = fd->simple.flc_hi;
+		m->ol_flags |= RTE_MBUF_F_RX_RSS_HASH;
+		DPAA2_PMD_DP_DEBUG("Hash frame received with RSS(%08x)",
+			m->hash.rss);
+	}
 
 	if (dpaa2_enable_ts[m->port]) {
 		*dpaa2_timestamp_dynfield(m) = annotation->word2;
Signature · 1 line
2.43.0
#24 lore raw

PATCH 23/45 net/dpaa2: add minimum key size support

In reply to Prashant Gupta

From: Hemant Agrawal <[email protected]>

The default size for a QoS key is 24 bytes. If the key size is smaller than the maximum, use the default (minimum) key size instead of always returning the maximum size (56 bytes). This allows smaller flow tables to be used when the extracted key fits within the default size.

---
 drivers/net/dpaa2/dpaa2_flow.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/net/dpaa2/dpaa2_flow.c +5 -3
index 45660df31a..2662c358e4 100644
@@ -26,8 +26,11 @@
 static char *dpaa2_flow_control_log;
 static int dpaa2_sp_loaded = -1;
 
+/* Default size of a key */
+#define DPNI_DEFAULT_KEY_SIZE 24
+
 enum dpaa2_flow_entry_size {
-	DPAA2_FLOW_ENTRY_MIN_SIZE = (DPNI_MAX_KEY_SIZE / 2),
+	DPAA2_FLOW_ENTRY_MIN_SIZE = DPNI_DEFAULT_KEY_SIZE,
 	DPAA2_FLOW_ENTRY_MAX_SIZE = DPNI_MAX_KEY_SIZE
 };
 
@@ -4532,8 +4535,7 @@ dpaa2_flow_entry_size(uint16_t key_max_size)
 	if (key_max_size > DPAA2_FLOW_ENTRY_MIN_SIZE)
 		return DPAA2_FLOW_ENTRY_MAX_SIZE;
 
-	/* Current MC only support fixed entry size(56)*/
-	return DPAA2_FLOW_ENTRY_MAX_SIZE;
+	return DPAA2_FLOW_ENTRY_MIN_SIZE;
 }
 
 static inline int
Signature · 1 line
2.43.0
#25 lore raw

PATCH 24/45 net/dpaa2: restructure dpaa2 parser processing

In reply to Prashant Gupta

From: Hemant Agrawal <[email protected]>

Move the parse-result decoding into a dedicated header so that the hardware parser fields are described in one place and shared between the flow code and the Rx path. No functional change is intended.

---
 drivers/net/dpaa2/dpaa2_ethdev.h        |  172 ++-
 drivers/net/dpaa2/dpaa2_parse_dump.h    |  374 ------
 drivers/net/dpaa2/dpaa2_parser_decode.h | 1539 +++++++++++++++++++++++
 drivers/net/dpaa2/dpaa2_pmd_logs.h      |   67 +
 drivers/net/dpaa2/dpaa2_rxtx.c          |  332 ++---
 5 files changed, 1906 insertions(+), 578 deletions(-)
 delete mode 100644 drivers/net/dpaa2/dpaa2_parse_dump.h
 create mode 100644 drivers/net/dpaa2/dpaa2_parser_decode.h
drivers/net/dpaa2/dpaa2_ethdev.h +113 -59
index c693989998..2f552f3e29 100644
@@ -21,6 +21,8 @@
 #include <mc/fsl_dpmac.h>
 
 #include "base/dpaa2_hw_dpni_annot.h"
+#include "dpaa2_parser_decode.h"
+
 
 #define DPAA2_MIN_RX_BUF_SIZE 512
 #define DPAA2_MAX_RX_PKT_LEN  10240 /*WRIOP support*/
@@ -101,6 +103,7 @@
 #define DPAA2_DATA_STASHING_OFF		RTE_BIT32(10)
 
 #define DPAAX_RX_ERROR_QUEUE_FLAG	RTE_BIT32(11)
+#define DPAA2_RX_PRINT_PSR_RESULT_FLAG RTE_BIT32(12)
 
 /* DPDMUX index for DPMAC */
 #define DPAA2_DPDMUX_DPMAC_IDX 0
@@ -124,31 +127,62 @@
 	RTE_ETH_RSS_PPPOE)
 
 /* LX2 FRC Parsed values (Little Endian) */
-#define DPAA2_PKT_TYPE_ETHER		0x0060
-#define DPAA2_PKT_TYPE_IPV4		0x0000
-#define DPAA2_PKT_TYPE_IPV6		0x0020
+#define DPAA2_PKT_TYPE_ETHER \
+	(DPAA2_PSR_SUMMARY_NONIP << DPAA2_PSR_SUMMARY_NON_IP_L2_BIT_SIZE)
+#define DPAA2_PKT_TYPE_IPV4 \
+	(DPAA2_PSR_SUMMARY_IPV4 << DPAA2_PSR_SUMMARY_L4_BIT_SIZE)
+#define DPAA2_PKT_TYPE_IPV6 \
+	(DPAA2_PSR_SUMMARY_IPV6 << DPAA2_PSR_SUMMARY_L4_BIT_SIZE)
+
+/**Tunnel*/
+#define DPAA2_PKT_TYPE_L3_EXT \
+	(DPAA2_PSR_SUMMARY_L4_EXT << DPAA2_PSR_SUMMARY_L4_EXT_L3_POS)
+#define DPAA2_PKT_TYPE_L3_EXT_IPV4 \
+	(DPAA2_PSR_SUMMARY_IPV4 << DPAA2_PSR_SUMMARY_L4_EXT_BIT_SIZE)
+#define DPAA2_PKT_TYPE_L3_EXT_IPV6 \
+	(DPAA2_PSR_SUMMARY_IPV6 << DPAA2_PSR_SUMMARY_L4_EXT_BIT_SIZE)
 #define DPAA2_PKT_TYPE_IPV4_EXT \
-			(0x0001 | DPAA2_PKT_TYPE_IPV4)
+	(DPAA2_PKT_TYPE_L3_EXT | DPAA2_PKT_TYPE_L3_EXT_IPV4)
 #define DPAA2_PKT_TYPE_IPV6_EXT \
-			(0x0001 | DPAA2_PKT_TYPE_IPV6)
+	(DPAA2_PKT_TYPE_L3_EXT | DPAA2_PKT_TYPE_L3_EXT_IPV6)
+#define DPAA2_PKT_TYPE_IPV4_EXT_GRE_IPV4 \
+	(DPAA2_PKT_TYPE_IPV4_EXT | DPAA2_PSR_SUMMARY_GRE_IPV4)
+#define DPAA2_PKT_TYPE_IPV4_EXT_GRE_IPV4_UDP_TCP \
+	(DPAA2_PKT_TYPE_IPV4_EXT | DPAA2_PSR_SUMMARY_GRE_IPV4_UDP_TCP)
+#define DPAA2_PKT_TYPE_IPV4_EXT_GRE_IPV6 \
+	(DPAA2_PKT_TYPE_IPV4_EXT | DPAA2_PSR_SUMMARY_GRE_IPV6)
+#define DPAA2_PKT_TYPE_IPV4_EXT_GRE_IPV6_UDP_TCP \
+	(DPAA2_PKT_TYPE_IPV4_EXT | DPAA2_PSR_SUMMARY_GRE_IPV6_UDP_TCP)
+#define DPAA2_PKT_TYPE_IPV6_EXT_GRE_IPV4 \
+	(DPAA2_PKT_TYPE_IPV6_EXT | DPAA2_PSR_SUMMARY_GRE_IPV4)
+#define DPAA2_PKT_TYPE_IPV6_EXT_GRE_IPV4_UDP_TCP \
+	(DPAA2_PKT_TYPE_IPV6_EXT | DPAA2_PSR_SUMMARY_GRE_IPV4_UDP_TCP)
+#define DPAA2_PKT_TYPE_IPV6_EXT_GRE_IPV6 \
+	(DPAA2_PKT_TYPE_IPV6_EXT | DPAA2_PSR_SUMMARY_GRE_IPV6)
+#define DPAA2_PKT_TYPE_IPV6_EXT_GRE_IPV6_UDP_TCP \
+	(DPAA2_PKT_TYPE_IPV6_EXT | DPAA2_PSR_SUMMARY_GRE_IPV6_UDP_TCP)
+
 #define DPAA2_PKT_TYPE_IPV4_TCP \
-			(0x000e | DPAA2_PKT_TYPE_IPV4)
+	(DPAA2_PSR_SUMMARY_TCP | DPAA2_PKT_TYPE_IPV4)
 #define DPAA2_PKT_TYPE_IPV6_TCP \
-			(0x000e | DPAA2_PKT_TYPE_IPV6)
+	(DPAA2_PSR_SUMMARY_TCP | DPAA2_PKT_TYPE_IPV6)
 #define DPAA2_PKT_TYPE_IPV4_UDP \
-			(0x0010 | DPAA2_PKT_TYPE_IPV4)
+	(DPAA2_PSR_SUMMARY_UDP | DPAA2_PKT_TYPE_IPV4)
 #define DPAA2_PKT_TYPE_IPV6_UDP \
-			(0x0010 | DPAA2_PKT_TYPE_IPV6)
-#define DPAA2_PKT_TYPE_IPV4_SCTP	\
-			(0x000f | DPAA2_PKT_TYPE_IPV4)
-#define DPAA2_PKT_TYPE_IPV6_SCTP	\
-			(0x000f | DPAA2_PKT_TYPE_IPV6)
+	(DPAA2_PSR_SUMMARY_UDP | DPAA2_PKT_TYPE_IPV6)
+#define DPAA2_PKT_TYPE_IPV4_SCTP \
+	(DPAA2_PSR_SUMMARY_SCTP | DPAA2_PKT_TYPE_IPV4)
+#define DPAA2_PKT_TYPE_IPV6_SCTP \
+	(DPAA2_PSR_SUMMARY_SCTP | DPAA2_PKT_TYPE_IPV6)
 #define DPAA2_PKT_TYPE_IPV4_ICMP \
-			(0x0003 | DPAA2_PKT_TYPE_IPV4_EXT)
+	(DPAA2_PSR_SUMMARY_ICMP | DPAA2_PKT_TYPE_IPV4)
 #define DPAA2_PKT_TYPE_IPV6_ICMP \
-			(0x0003 | DPAA2_PKT_TYPE_IPV6_EXT)
-#define DPAA2_PKT_TYPE_VLAN_1		0x0160
-#define DPAA2_PKT_TYPE_VLAN_2		0x0260
+	(DPAA2_PSR_SUMMARY_ICMP | DPAA2_PKT_TYPE_IPV6)
+
+#define DPAA2_PKT_TYPE_VLAN_1	0x0100
+#define DPAA2_PKT_TYPE_VLAN_2	0x0200
+#define DPAA2_PKT_TYPE_VLAN \
+	(DPAA2_PKT_TYPE_VLAN_1 | DPAA2_PKT_TYPE_VLAN_2)
 
 /* mac counters */
 #define DPAA2_MAC_NUM_STATS            (DPMAC_CNT_EGR_CONTROL_FRAME + 1)
@@ -173,17 +207,33 @@ struct sw_buf_free {
 	struct rte_mbuf *seg;
 };
 
-/* enable timestamp in mbuf*/
-extern bool dpaa2_enable_ts[];
-extern uint64_t dpaa2_timestamp_rx_dynflag;
-extern int dpaa2_timestamp_dynfield_offset;
-
 /* Externally defined */
 extern const struct rte_flow_ops dpaa2_flow_ops;
 
 extern const struct rte_tm_ops dpaa2_tm_ops;
 
-extern bool dpaa2_print_parser_result;
+struct dpaa2_dyn_rx_protocol_pos {
+	uint8_t l3_offset;
+	uint8_t l4_offset;
+	uint8_t l5_offset;
+	uint8_t rsv;
+};
+
+#define L3_OFFSET_OF_MBUF_DYN 0
+#define L4_OFFSET_OF_MBUF_DYN 1
+#define L5_OFFSET_OF_MBUF_DYN 2
+
+#define DPAA2_FS_FLC_FS_MARK_OFFSET \
+	(DPAA2_FLC_DATA_STASHING + DPAA2_FLC_STASHING_MAX_BIT_SIZE)
+
+#define DPAA2_FS_FLC_TC_OFFSET \
+	(DPAA2_FS_FLC_FS_MARK_OFFSET + DPAA2_FLC_STASHING_MAX_BIT_SIZE)
+
+#define DPAA2_FS_FLC_TC_BIT_SIZE (sizeof(uint8_t) * 8)
+#define DPAA2_FS_FLC_TC_MASK ((1 << DPAA2_FS_FLC_TC_BIT_SIZE) - 1)
+
+#define DPAA2_FS_FLC_FLOW_OFFSET \
+	(DPAA2_FS_FLC_TC_OFFSET + DPAA2_FS_FLC_TC_BIT_SIZE)
 
 #define DPAA2_FAPR_SIZE \
 	(sizeof(struct dpaa2_annot_hdr) - \
@@ -258,42 +308,6 @@ enum dpaa2_ecpri_fafe_type {
 #define DPAA2_PR_L5_OFF_OFFSET 31
 #define DPAA2_PR_NXTHDR_OFF_OFFSET 34
 
-/* Set by SP for vxlan distribution start*/
-#define DPAA2_VXLAN_IN_TCI_OFFSET 16
-
-#define DPAA2_VXLAN_IN_DADDR0_OFFSET 20
-#define DPAA2_VXLAN_IN_DADDR1_OFFSET 22
-#define DPAA2_VXLAN_IN_DADDR2_OFFSET 24
-#define DPAA2_VXLAN_IN_DADDR3_OFFSET 25
-#define DPAA2_VXLAN_IN_DADDR4_OFFSET 26
-#define DPAA2_VXLAN_IN_DADDR5_OFFSET 28
-
-#define DPAA2_VXLAN_IN_SADDR0_OFFSET 29
-#define DPAA2_VXLAN_IN_SADDR1_OFFSET 32
-#define DPAA2_VXLAN_IN_SADDR2_OFFSET 33
-#define DPAA2_VXLAN_IN_SADDR3_OFFSET 35
-#define DPAA2_VXLAN_IN_SADDR4_OFFSET 41
-#define DPAA2_VXLAN_IN_SADDR5_OFFSET 42
-
-#define DPAA2_VXLAN_VNI_OFFSET 43
-#define DPAA2_VXLAN_IN_TYPE_OFFSET 46
-/* Set by SP for vxlan distribution end*/
-
-/* ECPRI shares SP context with VXLAN*/
-#define DPAA2_ECPRI_MSG_OFFSET DPAA2_VXLAN_VNI_OFFSET
-
-#define DPAA2_FS_FLC_FS_MARK_OFFSET \
-	(DPAA2_FLC_DATA_STASHING + DPAA2_FLC_STASHING_MAX_BIT_SIZE)
-
-#define DPAA2_FS_FLC_TC_OFFSET \
-	(DPAA2_FS_FLC_FS_MARK_OFFSET + DPAA2_FLC_STASHING_MAX_BIT_SIZE)
-
-#define DPAA2_FS_FLC_TC_BIT_SIZE (sizeof(uint8_t) * 8)
-#define DPAA2_FS_FLC_TC_MASK ((1 << DPAA2_FS_FLC_TC_BIT_SIZE) - 1)
-
-#define DPAA2_FS_FLC_FLOW_OFFSET \
-	(DPAA2_FS_FLC_TC_OFFSET + DPAA2_FS_FLC_TC_BIT_SIZE)
-
 #define DPAA2_ECPRI_MAX_EXTRACT_NB 8
 
 struct ipv4_sd_addr_extract_rule {
@@ -436,6 +450,7 @@ struct dpaa2_dev_priv {
 	void *tx_conf_vq[MAX_TX_QUEUES];
 	void *rx_err_vq;
 	uint32_t flags; /*dpaa2 config flags */
+	int psr_dynfield_offset;
 	uint8_t max_mac_filters;
 	uint8_t max_vlan_filters;
 	uint8_t num_rx_tc;
@@ -475,6 +490,9 @@ struct dpaa2_dev_priv {
 	uint64_t rx_timestamp;
 	/*stores timestamp of last received tx confirmation packet on dev*/
 	uint64_t tx_timestamp;
+
+	int rx_ts_offset;
+	uint64_t rx_ts_flag;
 	/* stores pointer to next tx_conf queue that should be processed,
 	 * it corresponds to last packet transmitted
 	 */
@@ -483,6 +501,7 @@ struct dpaa2_dev_priv {
 	struct rte_eth_dev *eth_dev; /**< Pointer back to holding ethdev */
 	rte_spinlock_t lpbk_qp_lock;
 
+	bool sp_protocol;
 	uint8_t channel_inuse;
 	/* Rx-interrupt mode latched at the first dev_configure */
 	uint8_t intr_mode;
@@ -514,6 +533,41 @@ static inline int dpaa2_dev_cmp_dpni_ver(struct dpaa2_dev_priv *priv,
 	return priv->dpni_ver_major - ver_major;
 }
 
+static inline void
+dpaa2_dev_rx_print_parser_result(struct dpaa2_dev_priv *priv,
+	const struct qbman_fd *fd, const struct rte_mbuf *m)
+{
+	size_t fd_addr;
+	void *hw_annot_addr;
+
+	if (likely(!(priv->flags & DPAA2_RX_PRINT_PSR_RESULT_FLAG)))
+		return;
+
+	if (dpaa2_svr_family == SVR_LX2160A)
+		dpaa2_print_fd_frc(fd);
+
+	fd_addr = (size_t)DPAA2_IOVA_TO_VADDR(DPAA2_GET_FD_ADDR(fd));
+	hw_annot_addr = (void *)(fd_addr + DPAA2_FD_PTA_SIZE);
+	dpaa2_print_parse_result(hw_annot_addr, priv->sp_protocol);
+	if (m->ol_flags & RTE_MBUF_F_RX_FDIR) {
+		const struct rte_mbuf_sched *sched;
+		uint16_t i;
+		struct dpaa2_queue *rxq;
+
+		sched = &m->hash.sched;
+		for (i = 0; i < MAX_RX_QUEUES; i++) {
+			rxq = priv->rx_vq[i];
+			if (rxq->tc_index == sched->traffic_class &&
+				rxq->flow_id == sched->queue_id)
+				break;
+		}
+		DPAA2_PMD_DEBUG("Directed to TC%d-flow%d(rxq%d), color(%d)",
+			sched->traffic_class, sched->queue_id, i, sched->color);
+	} else if (m->ol_flags & RTE_MBUF_F_RX_RSS_HASH) {
+		DPAA2_PMD_DEBUG("Balanced with hash(0x%08x)", m->hash.rss);
+	}
+}
+
 int dpaa2_distset_to_dpkg_profile_cfg(uint64_t req_dist_set,
 				      struct dpkg_profile_cfg *kg_cfg);
 
drivers/net/dpaa2/dpaa2_parse_dump.h deleted +0 -374

374 lines not on this page · raw message

drivers/net/dpaa2/dpaa2_parser_decode.h new file +1539 -0

1,539 lines not on this page · raw message

drivers/net/dpaa2/dpaa2_pmd_logs.h +67 -0

77 lines not on this page · raw message

drivers/net/dpaa2/dpaa2_rxtx.c +187 -145

504 lines not on this page · raw message

Signature · 1 line
2.43.0
#26 lore raw

PATCH 25/45 net/dpaa2: parse tunnel and fragmented packet types

In reply to Prashant Gupta

From: Hemant Agrawal <[email protected]>

Extend the Rx parser to identify additional packet types decoded from the hardware parser summary: IPv4/IPv6 fragments, IPsec ESP, and GTP-U / GTP-C tunnels. The corresponding DPAA2_PKT_TYPE_* values are added and mapped to the matching RTE_PTYPE_* flags in the slow-path parser.

---
 drivers/net/dpaa2/dpaa2_ethdev.h | 16 ++++++++++++++++
 drivers/net/dpaa2/dpaa2_rxtx.c   | 32 ++++++++++++++++++++++++++++++++
 2 files changed, 48 insertions(+)
drivers/net/dpaa2/dpaa2_ethdev.h +16 -0
index 2f552f3e29..6c72b9012c 100644
@@ -162,6 +162,10 @@
 #define DPAA2_PKT_TYPE_IPV6_EXT_GRE_IPV6_UDP_TCP \
 	(DPAA2_PKT_TYPE_IPV6_EXT | DPAA2_PSR_SUMMARY_GRE_IPV6_UDP_TCP)
 
+#define DPAA2_PKT_TYPE_IPV4_FRAG \
+	(DPAA2_PSR_SUMMARY_IP_FRAG | DPAA2_PKT_TYPE_IPV4)
+#define DPAA2_PKT_TYPE_IPV6_FRAG \
+	(DPAA2_PSR_SUMMARY_IP_FRAG | DPAA2_PKT_TYPE_IPV6)
 #define DPAA2_PKT_TYPE_IPV4_TCP \
 	(DPAA2_PSR_SUMMARY_TCP | DPAA2_PKT_TYPE_IPV4)
 #define DPAA2_PKT_TYPE_IPV6_TCP \
@@ -178,6 +182,18 @@
 	(DPAA2_PSR_SUMMARY_ICMP | DPAA2_PKT_TYPE_IPV4)
 #define DPAA2_PKT_TYPE_IPV6_ICMP \
 	(DPAA2_PSR_SUMMARY_ICMP | DPAA2_PKT_TYPE_IPV6)
+#define DPAA2_PKT_TYPE_IPV4_ESP \
+	(DPAA2_PSR_SUMMARY_IPSEC_ESP | DPAA2_PKT_TYPE_IPV4)
+#define DPAA2_PKT_TYPE_IPV6_ESP \
+	(DPAA2_PSR_SUMMARY_IPSEC_ESP | DPAA2_PKT_TYPE_IPV6)
+#define DPAA2_PKT_TYPE_IPV4_GTPU \
+	(DPAA2_PSR_SUMMARY_GTPU | DPAA2_PKT_TYPE_IPV4)
+#define DPAA2_PKT_TYPE_IPV6_GTPU \
+	(DPAA2_PSR_SUMMARY_GTPU | DPAA2_PKT_TYPE_IPV6)
+#define DPAA2_PKT_TYPE_IPV4_GTPC \
+	(DPAA2_PSR_SUMMARY_GTPC | DPAA2_PKT_TYPE_IPV4)
+#define DPAA2_PKT_TYPE_IPV6_GTPC \
+	(DPAA2_PSR_SUMMARY_GTPC | DPAA2_PKT_TYPE_IPV6)
 
 #define DPAA2_PKT_TYPE_VLAN_1	0x0100
 #define DPAA2_PKT_TYPE_VLAN_2	0x0200
drivers/net/dpaa2/dpaa2_rxtx.c +32 -0
index 47c8cacdc4..26c84e7125 100644
@@ -153,6 +153,38 @@ dpaa2_dev_rx_parse_new(struct dpaa2_dev_priv *priv,
 		m->packet_type = RTE_PTYPE_L2_ETHER |
 			RTE_PTYPE_L3_IPV6;
 		break;
+	case DPAA2_PKT_TYPE_IPV4_FRAG:
+		m->packet_type = RTE_PTYPE_L2_ETHER |
+			RTE_PTYPE_L3_IPV4 | RTE_PTYPE_L4_FRAG;
+		break;
+	case DPAA2_PKT_TYPE_IPV6_FRAG:
+		m->packet_type = RTE_PTYPE_L2_ETHER |
+			RTE_PTYPE_L3_IPV6 | RTE_PTYPE_L4_FRAG;
+		break;
+	case DPAA2_PKT_TYPE_IPV4_ESP:
+		m->packet_type = RTE_PTYPE_L2_ETHER |
+			RTE_PTYPE_L3_IPV4 | RTE_PTYPE_TUNNEL_ESP;
+		break;
+	case DPAA2_PKT_TYPE_IPV6_ESP:
+		m->packet_type = RTE_PTYPE_L2_ETHER |
+			RTE_PTYPE_L3_IPV6 | RTE_PTYPE_TUNNEL_ESP;
+		break;
+	case DPAA2_PKT_TYPE_IPV4_GTPU:
+		m->packet_type = RTE_PTYPE_L2_ETHER |
+			RTE_PTYPE_L3_IPV4 | RTE_PTYPE_TUNNEL_GTPU;
+		break;
+	case DPAA2_PKT_TYPE_IPV6_GTPU:
+		m->packet_type = RTE_PTYPE_L2_ETHER |
+			RTE_PTYPE_L3_IPV6 | RTE_PTYPE_TUNNEL_GTPU;
+		break;
+	case DPAA2_PKT_TYPE_IPV4_GTPC:
+		m->packet_type = RTE_PTYPE_L2_ETHER |
+			RTE_PTYPE_L3_IPV4 | RTE_PTYPE_TUNNEL_GTPC;
+		break;
+	case DPAA2_PKT_TYPE_IPV6_GTPC:
+		m->packet_type = RTE_PTYPE_L2_ETHER |
+			RTE_PTYPE_L3_IPV6 | RTE_PTYPE_TUNNEL_GTPC;
+		break;
 	case DPAA2_PKT_TYPE_ETHER:
 		m->packet_type = RTE_PTYPE_L2_ETHER;
 		break;
Signature · 1 line
2.43.0
#27 lore raw

PATCH 26/45 net/dpaa2: remove unused soft parser driver

In reply to Prashant Gupta

From: Jun Yang <[email protected]>

Softparser only supports to be loaded before Linux starts.

---
 drivers/net/dpaa2/dpaa2_ethdev.c  |  28 -----
 drivers/net/dpaa2/dpaa2_recycle.c |   1 -
 drivers/net/dpaa2/dpaa2_sparser.c | 137 --------------------
 drivers/net/dpaa2/dpaa2_sparser.h | 202 ------------------------------
 drivers/net/dpaa2/meson.build     |   1 -
 5 files changed, 369 deletions(-)
 delete mode 100644 drivers/net/dpaa2/dpaa2_sparser.c
 delete mode 100644 drivers/net/dpaa2/dpaa2_sparser.h
drivers/net/dpaa2/dpaa2_ethdev.c +0 -28
index 387a153036..1df84e1316 100644
@@ -29,7 +29,6 @@
 #include <mc/fsl_dpmng.h>
 #include <mc/fsl_dpcon.h>
 #include "dpaa2_ethdev.h"
-#include "dpaa2_sparser.h"
 #include <fsl_qbman_debug.h>
 
 #define DRIVER_LOOPBACK_MODE "drv_loopback"
@@ -3738,33 +3737,6 @@ dpaa2_dev_init(struct rte_eth_dev *eth_dev)
 	}
 	eth_dev->data->mtu = RTE_ETHER_MTU;
 
-	/*TODO To enable soft parser support DPAA2 driver needs to integrate
-	 * with external entity to receive byte code for software sequence
-	 * and same will be offload to the H/W using MC interface.
-	 * Currently it is assumed that DPAA2 driver has byte code by some
-	 * mean and same if offloaded to H/W.
-	 */
-	if (getenv("DPAA2_ENABLE_SOFT_PARSER")) {
-		WRIOP_SS_INITIALIZER(priv);
-		ret = dpaa2_eth_load_wriop_soft_parser(priv, DPNI_SS_INGRESS);
-		if (ret < 0) {
-			DPAA2_PMD_ERR(" Error(%d) in loading softparser",
-				      ret);
-			goto init_err;
-		}
-
-		ret = dpaa2_eth_enable_wriop_soft_parser(priv,
-							 DPNI_SS_INGRESS);
-		if (ret < 0) {
-			DPAA2_PMD_ERR(" Error(%d) in enabling softparser",
-				      ret);
-			goto init_err;
-		}
-	}
-
-	ret = dpaa2_soft_parser_loaded();
-	if (ret > 0)
-		DPAA2_PMD_INFO("soft parser is loaded");
 	DPAA2_PMD_INFO("%s: netdev created, connected to %s",
 		eth_dev->data->name, dpaa2_dev->ep_name);
 
drivers/net/dpaa2/dpaa2_recycle.c +0 -1
index 80c20272ce..ed038c204b 100644
@@ -23,7 +23,6 @@
 #include <dpaa2_hw_dpio.h>
 #include <mc/fsl_dpmng.h>
 #include "dpaa2_ethdev.h"
-#include "dpaa2_sparser.h"
 #include <fsl_qbman_debug.h>
 
 #include <rte_io.h>
drivers/net/dpaa2/dpaa2_sparser.c deleted +0 -137

137 lines not on this page · raw message

drivers/net/dpaa2/dpaa2_sparser.h deleted +0 -202

202 lines not on this page · raw message

drivers/net/dpaa2/meson.build +0 -1
index 808dad8112..4f774f7c82 100644
@@ -17,7 +17,6 @@ sources = files(
         'dpaa2_flow.c',
         'dpaa2_recycle.c',
         'dpaa2_rxtx.c',
-        'dpaa2_sparser.c',
         'dpaa2_ptp.c',
         'mc/dprtc.c',
         'mc/dpkg.c',
Signature · 1 line
2.43.0
#28 lore raw

PATCH 27/45 drivers: refresh dpaa2 MC and SoC version info

In reply to Prashant Gupta

From: Jun Yang <[email protected]>

Fix MC revision typo to correct major to minor. Get MC/SoC rev info only once and save them in bus info as well as other information to reduce replicated variables.

---
 drivers/bus/fslmc/bus_fslmc_driver.h     |  11 +-
 drivers/bus/fslmc/fslmc_bus.c            |   2 +
 drivers/bus/fslmc/fslmc_vfio.c           | 200 ++++++++++++++++++-----
 drivers/bus/fslmc/fslmc_vfio.h           |  30 +++-
 drivers/bus/fslmc/portal/dpaa2_hw_dpio.c |  79 +--------
 drivers/bus/fslmc/portal/dpaa2_hw_dpio.h |   7 -
 drivers/bus/fslmc/private.h              |   3 +
 drivers/net/dpaa2/dpaa2_ethdev.c         |  18 +-
 drivers/net/dpaa2/dpaa2_ethdev.h         |   1 +
 drivers/net/dpaa2/dpaa2_rxtx.c           |  10 +-
 10 files changed, 225 insertions(+), 136 deletions(-)
drivers/bus/fslmc/bus_fslmc_driver.h +10 -1
index c64ef094d0..b4a5a86318 100644
@@ -1,6 +1,6 @@
 /* SPDX-License-Identifier: BSD-3-Clause
  *
- *   Copyright 2016,2021-2023 NXP
+ *   Copyright 2016,2021-2026 NXP
  *
  */
 
@@ -89,6 +89,14 @@ enum rte_dpaa2_dev_type {
 	DPAA2_DEVTYPE_MAX,
 };
 
+struct rte_fslmc_bus_info {
+	void *mem_pool;
+	int sp_protocol;
+	uint64_t mc_rev;
+	uint32_t svr;
+	uint32_t pvr;
+};
+
 /**
  * A structure describing a DPAA2 device.
  */
@@ -103,6 +111,7 @@ struct rte_dpaa2_device {
 	struct rte_intr_handle *intr_handle; /**< Interrupt handle */
 	char name[FSLMC_OBJECT_MAX_LEN];    /**< DPAA2 Object name*/
 	struct rte_dma_dev *dmadev;          /**< DMA device */
+	const struct rte_fslmc_bus_info *bus_info;
 };
 
 typedef int (*rte_dpaa2_obj_create_t)(int vdev_fd,
drivers/bus/fslmc/fslmc_bus.c +2 -0
index ee162b0ed8..2427421075 100644
@@ -29,6 +29,7 @@
 
 struct rte_bus rte_fslmc_bus;
 static int fslmc_bus_device_count[DPAA2_DEVTYPE_MAX];
+struct rte_fslmc_bus_info fslmc_bus_info;
 
 #define DPAA2_SEQN_DYNFIELD_NAME "dpaa2_seqn_dynfield"
 RTE_EXPORT_INTERNAL_SYMBOL(dpaa2_seqn_dynfield_offset)
@@ -199,6 +200,7 @@ scan_one_fslmc_device(char *dev_name)
 		goto cleanup;
 	}
 	dev->device.devargs = rte_bus_find_devargs(&rte_fslmc_bus, dev_name);
+	dev->bus_info = &fslmc_bus_info;
 
 	/* Update the device found into the device_count table */
 	fslmc_bus_device_count[dev->dev_type]++;
drivers/bus/fslmc/fslmc_vfio.c +162 -38

307 lines not on this page · raw message

drivers/bus/fslmc/fslmc_vfio.h +29 -1
index c995fd67b8..554123ffa6 100644
@@ -1,7 +1,7 @@
 /* SPDX-License-Identifier: BSD-3-Clause
  *
  *   Copyright (c) 2015-2016 Freescale Semiconductor, Inc. All rights reserved.
- *   Copyright 2016,2019-2023 NXP
+ *   Copyright 2016,2019-2026 NXP
  *
  */
 
@@ -9,6 +9,8 @@
 #define _FSLMC_VFIO_H_
 
 #include <rte_compat.h>
+#include <rte_vfio.h>
+#include <rte_interrupts.h>
 
 /* Pathname of FSL-MC devices directory. */
 #define SYSFS_FSL_MC_DEVICES	"/sys/bus/fsl-mc/devices"
@@ -44,6 +46,30 @@ struct fslmc_vfio_container {
 
 extern char *fslmc_container;
 
+extern uint32_t dpaa2_svr_family;
+extern uint32_t dpaa2_dqrr_size;
+extern uint32_t dpaa2_eqcr_size;
+extern uint32_t dpaa2_cluster_base;
+extern uint32_t dpaa2_cluster_size;
+
+#define DPAA2_SVR_MASK 0xffff0000
+
+#define SVR_LS1080A	0x87030000
+#define SVR_LS2080A	0x87010000
+#define SVR_LS2088A	0x87090000
+#define SVR_LX2160A	0x87360000
+
+#define MC_MAJOR_OFFSET 32
+#define MC_MINOR_OFFSET 16
+#define MC_MINOR_MASK ((((uint64_t)1) << (MC_MAJOR_OFFSET - MC_MINOR_OFFSET)) - 1)
+#define MC_REVISION_MASK ((((uint64_t)1) << MC_MINOR_OFFSET) - 1)
+#define RTE_FSL_MC_REV(major, minor, revision) \
+	((((uint64_t)(major)) << MC_MAJOR_OFFSET) + \
+	(((uint64_t)(minor)) << MC_MINOR_OFFSET) + (revision))
+#define RTE_FSL_MC_REV_MAJOR(rev) ((uint32_t)((rev) >> MC_MAJOR_OFFSET))
+#define RTE_FSL_MC_REV_MINOR(rev) ((uint32_t)(((rev) >> MC_MINOR_OFFSET) & MC_MINOR_MASK))
+#define RTE_FSL_MC_REV_REVISION(rev) ((uint32_t)((rev) & MC_REVISION_MASK))
+
 __rte_internal
 int rte_dpaa2_intr_enable(struct rte_intr_handle *intr_handle, int index);
 
@@ -60,4 +86,6 @@ int fslmc_vfio_close_group(void);
 char *fslmc_get_container(void);
 int fslmc_get_container_group(const char *group_name, int *gropuid);
 int fslmc_vfio_dmamap(void);
+int fslmc_vfio_core_cluster_sdest(uint32_t cpu_id);
+
 #endif /* _FSLMC_VFIO_H_ */
drivers/bus/fslmc/portal/dpaa2_hw_dpio.c +5 -74

119 lines not on this page · raw message

drivers/bus/fslmc/portal/dpaa2_hw_dpio.h +0 -7
index 7e2271cc35..2c559e5354 100644
@@ -35,13 +35,6 @@ RTE_DECLARE_PER_LCORE(struct dpaa2_io_portal_t, _dpaa2_io);
 #define DPAA2_PER_LCORE_DQRR_MBUF(i) \
 	RTE_PER_LCORE(_dpaa2_io).dpio_dev->dpaa2_held_bufs.mbuf[i]
 
-/* Variable to store DPAA2 DQRR size */
-extern uint8_t dpaa2_dqrr_size;
-/* Variable to store DPAA2 EQCR size */
-extern uint8_t dpaa2_eqcr_size;
-
-extern struct dpaa2_io_portal_t dpaa2_io_portal[RTE_MAX_LCORE];
-
 /* Affine a DPIO portal to current processing thread */
 __rte_internal
 int dpaa2_affine_qbman_swp(void);
drivers/bus/fslmc/private.h +3 -0
index 20a454c3fc..1c8a3e59e9 100644
@@ -11,4 +11,7 @@
 
 extern struct rte_bus rte_fslmc_bus;
 
+/* MC/SoC version and capability info, shared by the bus and VFIO code. */
+extern struct rte_fslmc_bus_info fslmc_bus_info;
+
 #endif /* BUS_FSLMC_PRIVATE_H */
drivers/net/dpaa2/dpaa2_ethdev.c +8 -10
index 1df84e1316..e6ce29b2ea 100644
@@ -329,24 +329,21 @@ dpaa2_fw_version_get(struct rte_eth_dev *dev,
 	char *fw_version, size_t fw_size)
 {
 	int ret;
+	uint32_t major, minor, rev;
+	struct dpaa2_dev_priv *priv = dev->data->dev_private;
 	struct fsl_mc_io *dpni = dev->process_private;
 	struct mc_soc_version mc_plat_info = {0};
-	struct mc_version mc_ver_info = {0};
 
 	PMD_INIT_FUNC_TRACE();
 
+	major = RTE_FSL_MC_REV_MAJOR(priv->mc_rev);
+	minor = RTE_FSL_MC_REV_MINOR(priv->mc_rev);
+	rev = RTE_FSL_MC_REV_REVISION(priv->mc_rev);
 	if (mc_get_soc_version(dpni, CMD_PRI_LOW, &mc_plat_info))
 		DPAA2_PMD_WARN("\tmc_get_soc_version failed");
 
-	if (mc_get_version(dpni, CMD_PRI_LOW, &mc_ver_info))
-		DPAA2_PMD_WARN("\tmc_get_version failed");
-
-	ret = snprintf(fw_version, fw_size,
-		       "%x-%d.%d.%d",
-		       mc_plat_info.svr,
-		       mc_ver_info.major,
-		       mc_ver_info.minor,
-		       mc_ver_info.revision);
+	ret = snprintf(fw_version, fw_size, "%x-%d.%d.%d",
+		mc_plat_info.svr, major, minor, rev);
 	if (ret < 0)
 		return -EINVAL;
 
@@ -3537,6 +3534,7 @@ dpaa2_dev_init(struct rte_eth_dev *eth_dev)
 		goto init_err;
 	}
 
+	priv->mc_rev = dpaa2_dev->bus_info->mc_rev;
 	priv->num_rx_tc = attr.num_rx_tcs;
 	priv->num_tx_tc = attr.num_tx_tcs;
 	priv->qos_entries = attr.qos_entries;
drivers/net/dpaa2/dpaa2_ethdev.h +1 -0
index 6c72b9012c..f1d1967cd1 100644
@@ -528,6 +528,7 @@ struct dpaa2_dev_priv {
 	uint32_t *cnt_idx_dma_mem;
 	uint64_t *cnt_values_dma_mem;
 	uint64_t cnt_idx_iova, cnt_values_iova;
+	uint64_t mc_rev;
 
 	struct dpaa2_dev_flow *curr;
 	LIST_HEAD(, dpaa2_dev_flow) flows;
drivers/net/dpaa2/dpaa2_rxtx.c +5 -5
index 26c84e7125..f417edf52b 100644
@@ -1123,9 +1123,9 @@ dpaa2_dev_rx_common(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts,
 	/* Function receive frames for a given device and VQ */
 	struct dpaa2_queue *dpaa2_q = queue;
 	struct qbman_result *dq_storage;
-	uint32_t fqid = dpaa2_q->fqid;
-	int ret, num_rx = 0, next_pull = nb_pkts, num_pulled;
-	uint8_t pending, status;
+	uint32_t fqid = dpaa2_q->fqid, next_pull = nb_pkts;
+	int ret;
+	uint8_t pending, status, num_rx = 0, num_pulled;
 	struct qbman_swp *swp;
 	const struct qbman_fd *fd;
 	struct qbman_pull_desc pulldesc;
@@ -1269,8 +1269,8 @@ uint16_t dpaa2_dev_tx_conf(void *queue)
 	struct dpaa2_queue *dpaa2_q = (struct dpaa2_queue *)queue;
 	struct qbman_result *dq_storage;
 	uint32_t fqid = dpaa2_q->fqid;
-	int ret, num_tx_conf = 0, num_pulled;
-	uint8_t pending, status;
+	int ret, num_tx_conf = 0;
+	uint8_t pending, status, num_pulled;
 	struct qbman_swp *swp;
 	const struct qbman_fd *fd;
 	struct qbman_pull_desc pulldesc;
Signature · 1 line
2.43.0
#29 lore raw

PATCH 28/45 drivers: identify dpaa2 soft parser protocol

In reply to Prashant Gupta

From: Jun Yang <[email protected]>

Identify if soft parser protocol firmware is loaded by checking firmware magic number.
Enable flow/parser of ECPRI, GENEVE, ROCEv2 and VXLAN's spec only with soft parser protocol firmware being loaded.

---
 drivers/bus/fslmc/fslmc_bus.c    |  91 +++++++++++++++++++++-
 drivers/net/dpaa2/dpaa2_ethdev.c |   2 +
 drivers/net/dpaa2/dpaa2_flow.c   | 129 ++++++++-----------------------
 drivers/net/dpaa2/dpaa2_rxtx.c   |  10 +++
 4 files changed, 134 insertions(+), 98 deletions(-)
drivers/bus/fslmc/fslmc_bus.c +90 -1
index 2427421075..c3415bc541 100644
@@ -1,6 +1,6 @@
 /* SPDX-License-Identifier: BSD-3-Clause
  *
- *   Copyright 2016,2018-2021 NXP
+ *   Copyright 2016,2018-2026 NXP
  *
  */
 
@@ -8,6 +8,7 @@
 #include <dirent.h>
 #include <stdalign.h>
 #include <stdbool.h>
+#include <sys/mman.h>
 
 #include <eal_export.h>
 #include <rte_log.h>
@@ -35,6 +36,93 @@ struct rte_fslmc_bus_info fslmc_bus_info;
 RTE_EXPORT_INTERNAL_SYMBOL(dpaa2_seqn_dynfield_offset)
 int dpaa2_seqn_dynfield_offset = -1;
 
+/** For LX2160A, LS2088A and LS1088A*/
+#define WRIOP_CCSR_BASE 0x8b80000
+#define WRIOP_CCSR_CTLU_OFFSET 0
+#define WRIOP_CCSR_CTLU_PARSER_OFFSET 0
+#define WRIOP_CCSR_CTLU_PARSER_INGRESS_OFFSET 0
+
+#define WRIOP_INGRESS_PARSER_PHY \
+	(WRIOP_CCSR_BASE + WRIOP_CCSR_CTLU_OFFSET + \
+	WRIOP_CCSR_CTLU_PARSER_OFFSET + \
+	WRIOP_CCSR_CTLU_PARSER_INGRESS_OFFSET)
+
+struct __rte_packed_begin dpaa2_parser_ccsr {
+	uint32_t psr_cfg;
+	uint32_t psr_idle;
+	uint32_t psr_pclm;
+	uint8_t psr_ver_min;
+	uint8_t psr_ver_maj;
+	uint8_t psr_id1_l;
+	uint8_t psr_id1_h;
+	uint32_t psr_rev2;
+	uint8_t rsv[0x2c];
+	uint8_t sp_ins[4032];
+} __rte_packed_end;
+
+#define SP_PROTOCOL_MAGIC_DATA 0xabcd
+#define SP_PROTOCOL_MAGIC_OFFSET 0x4
+
+/** Number of soft parser firmware bytes reported for debugging. */
+#define SP_PRINT_LEN 128
+/** Firmware bytes logged per debug line. */
+#define SP_DUMP_BYTES_PER_LINE 16
+
+static void
+fslmc_soft_parser_protocol_supported(void)
+{
+	int fd, i, pos = 0;
+	void *map_addr = NULL;
+	const struct dpaa2_parser_ccsr *parser_ccsr = NULL;
+	const uint16_t *magic_num;
+	char line[SP_DUMP_BYTES_PER_LINE * 3 + 1];
+
+	fd = open("/dev/mem", O_RDWR | O_SYNC);
+	if (fd < 0) {
+		DPAA2_BUS_ERR("open \"/dev/mem\" ERROR(%d)", fd);
+		goto exit;
+	}
+
+	map_addr = mmap(NULL, sizeof(struct dpaa2_parser_ccsr),
+		PROT_READ | PROT_WRITE, MAP_SHARED, fd,
+		WRIOP_INGRESS_PARSER_PHY);
+	parser_ccsr = map_addr;
+	if (!parser_ccsr) {
+		DPAA2_BUS_ERR("Map 0x%" PRIx64 "(size=0x%zx) failed",
+			(uint64_t)WRIOP_INGRESS_PARSER_PHY,
+			sizeof(struct dpaa2_parser_ccsr));
+		goto exit;
+	}
+
+	DPAA2_BUS_DEBUG("Soft ParserID:0x%02x%02x, Rev:maj(%02x), min(%02x)",
+		parser_ccsr->psr_id1_h, parser_ccsr->psr_id1_l,
+		parser_ccsr->psr_ver_maj, parser_ccsr->psr_ver_min);
+
+	magic_num = (const void *)&parser_ccsr->sp_ins[SP_PROTOCOL_MAGIC_OFFSET];
+	if (*magic_num == SP_PROTOCOL_MAGIC_DATA) {
+		fslmc_bus_info.sp_protocol = true;
+		DPAA2_BUS_INFO("Soft parser protocol support.");
+		DPAA2_BUS_DEBUG("First %d bytes of sp protocol firmware:",
+			SP_PRINT_LEN);
+		for (i = 0; i < SP_PRINT_LEN; i++) {
+			pos += snprintf(&line[pos], sizeof(line) - pos,
+				"%02x ", parser_ccsr->sp_ins[i]);
+			if ((i + 1) % SP_DUMP_BYTES_PER_LINE == 0) {
+				DPAA2_BUS_DEBUG("%s", line);
+				pos = 0;
+			}
+		}
+		if (pos)
+			DPAA2_BUS_DEBUG("%s", line);
+	}
+
+exit:
+	if (map_addr)
+		munmap(map_addr, sizeof(struct dpaa2_parser_ccsr));
+	if (fd >= 0)
+		close(fd);
+}
+
 RTE_EXPORT_INTERNAL_SYMBOL(rte_fslmc_get_device_count)
 uint32_t
 rte_fslmc_get_device_count(enum rte_dpaa2_dev_type device_type)
@@ -345,6 +433,7 @@ rte_fslmc_scan(void)
 		DPAA2_BUS_ERR("Unable to open VFIO group directory");
 		goto scan_fail;
 	}
+	fslmc_soft_parser_protocol_supported();
 
 	/* Scan the DPRC container object */
 	ret = scan_one_fslmc_device(group_name);
drivers/net/dpaa2/dpaa2_ethdev.c +2 -0
index e6ce29b2ea..fb1d01e209 100644
@@ -3735,6 +3735,8 @@ dpaa2_dev_init(struct rte_eth_dev *eth_dev)
 	}
 	eth_dev->data->mtu = RTE_ETHER_MTU;
 
+	priv->sp_protocol = dpaa2_dev->bus_info->sp_protocol;
+
 	DPAA2_PMD_INFO("%s: netdev created, connected to %s",
 		eth_dev->data->name, dpaa2_dev->ep_name);
 
drivers/net/dpaa2/dpaa2_flow.c +32 -97

219 lines not on this page · raw message

drivers/net/dpaa2/dpaa2_rxtx.c +10 -0
index f417edf52b..ccb4bbe7dc 100644
@@ -128,6 +128,16 @@ dpaa2_dev_rx_parse_new(struct dpaa2_dev_priv *priv,
 			ext_packet_type |= RTE_PTYPE_INNER_L3_IPV4;
 		}
 	}
+	if (priv->sp_protocol) {
+		if (frc_parse->fafe2) {
+			frc_parse->fafe2 = 0;
+			ext_packet_type |= RTE_PTYPE_TUNNEL_GENEVE;
+		}
+		if (frc_parse->sum_l.l4.fafe3) {
+			frc_parse->sum_l.l4.fafe3 = 0;
+			ext_packet_type |= RTE_PTYPE_INNER_L3_IPV4;
+		}
+	}
 	switch (frc) {
 	case DPAA2_PKT_TYPE_IPV4_UDP:
 		m->packet_type = RTE_PTYPE_L2_ETHER |
Signature · 1 line
2.43.0
#30 lore raw

PATCH 29/45 drivers: assign dpaa2 Rx CGID per traffic class

In reply to Prashant Gupta

From: Jun Yang <[email protected]>

RXQs in same TC should use same CGID for congestion set.

---
 drivers/bus/fslmc/portal/dpaa2_hw_pvt.h |   3 +-
 drivers/net/dpaa2/dpaa2_ethdev.c        | 252 ++++++++++++------------
 drivers/net/dpaa2/dpaa2_ethdev.h        |   3 +-
 3 files changed, 126 insertions(+), 132 deletions(-)
drivers/bus/fslmc/portal/dpaa2_hw_pvt.h +2 -1
index f0bc9a3063..12216750a8 100644
@@ -176,7 +176,6 @@ struct __rte_cache_aligned dpaa2_queue {
 	uint32_t fqid;		/*!< Unique ID of this queue */
 	uint16_t flow_id;	/*!< To be used by DPAA2 framework */
 	uint8_t tc_index;	/*!< traffic class identifier */
-	uint8_t cgid;		/*! < Congestion Group id for this queue */
 	uint64_t rx_pkts;
 	uint64_t tx_pkts;
 	uint64_t err_pkts;
@@ -186,6 +185,8 @@ struct __rte_cache_aligned dpaa2_queue {
 		/**Egress*/
 		struct qbman_result *cscn;
 	};
+	void *cfg;
+	uint8_t options;
 	struct rte_event ev;
 	dpaa2_queue_cb_dqrr_t *cb;
 	dpaa2_queue_cb_eqresp_free_t *cb_eqresp_free;
drivers/net/dpaa2/dpaa2_ethdev.c +122 -130

407 lines not on this page · raw message

drivers/net/dpaa2/dpaa2_ethdev.h +2 -1
index f1d1967cd1..3c611652b1 100644
@@ -478,7 +478,8 @@ struct dpaa2_dev_priv {
 	uint8_t en_ordered;
 	uint8_t en_loose_ordered;
 	uint8_t max_cgs;
-	uint8_t cgid_in_use[MAX_RX_QUEUES];
+	/** RXQs in same TC share same cgid.*/
+	uint8_t cgid_in_use[MAX_TCS];
 	rte_spinlock_t meter_lock;
 	/* Lowest priority FS flow id to receive flow steering miss frames. */
 	uint16_t default_flow;
Signature · 1 line
2.43.0
#31 lore raw

PATCH 30/45 drivers: inherit dpaa2 rxq config for event queue

In reply to Prashant Gupta

From: Jun Yang <[email protected]>

The configuration parameter in event queue attachment should use flc and cgid configured in rxq setup.

---
 drivers/bus/fslmc/portal/dpaa2_hw_pvt.h | 2 +-
 drivers/net/dpaa2/dpaa2_ethdev.c        | 3 ++-
 2 files changed, 3 insertions(+), 2 deletions(-)
drivers/bus/fslmc/portal/dpaa2_hw_pvt.h +1 -1
index 12216750a8..f87bf51d09 100644
@@ -1,7 +1,7 @@
 /* SPDX-License-Identifier: BSD-3-Clause
  *
  *   Copyright (c) 2016 Freescale Semiconductor, Inc. All rights reserved.
- *   Copyright 2016-2024 NXP
+ *   Copyright 2016-2025 NXP
  *
  */
 
drivers/net/dpaa2/dpaa2_ethdev.c +2 -1
index 0835296ee2..57c6e8e90b 100644
@@ -2815,11 +2815,12 @@ int dpaa2_eth_eventq_attach(const struct rte_eth_dev *dev,
 	struct dpaa2_dev_priv *eth_priv = dev->data->dev_private;
 	struct fsl_mc_io *dpni = (struct fsl_mc_io *)dev->process_private;
 	struct dpaa2_queue *dpaa2_ethq = eth_priv->rx_vq[eth_rx_queue_id];
-	uint8_t flow_id = dpaa2_ethq->flow_id;
+	uint8_t flow_id;
 	struct dpni_queue *cfg;
 	uint8_t options, priority;
 	int ret;
 
+	flow_id = dpaa2_ethq->flow_id;
 	cfg = dpaa2_ethq->cfg;
 
 	if (queue_conf->ev.sched_type == RTE_SCHED_TYPE_PARALLEL)
Signature · 1 line
2.43.0
#32 lore raw

PATCH 31/45 net/dpaa2: rename Rx queue flags

In reply to Prashant Gupta

From: Jun Yang <[email protected]>

Rename the Rx-side device flags to a consistent DPAA2_RX_*_FLAG naming:
DPAAX_RX_ERROR_QUEUE_FLAG becomes DPAA2_RX_ERROR_QUEUE_FLAG and DPAA2_DATA_STASHING_OFF becomes DPAA2_RX_DATA_STASHING_OFF_FLAG.

This is a mechanical rename with no functional change; it prepares the flag namespace for the Tx confirmation rework that follows.

---
 drivers/net/dpaa2/dpaa2_ethdev.c | 10 +++++-----
 drivers/net/dpaa2/dpaa2_ethdev.h |  4 ++--
 drivers/net/dpaa2/dpaa2_rxtx.c   |  4 ++--
 3 files changed, 9 insertions(+), 9 deletions(-)
drivers/net/dpaa2/dpaa2_ethdev.c +5 -5
index 57c6e8e90b..15a886b3e8 100644
@@ -547,7 +547,7 @@ dpaa2_alloc_rx_tx_queues(struct rte_eth_dev *dev)
 			goto fail;
 	}
 
-	if (priv->flags & DPAAX_RX_ERROR_QUEUE_FLAG) {
+	if (priv->flags & DPAA2_RX_ERROR_QUEUE_FLAG) {
 		priv->rx_err_vq = rte_zmalloc("dpni_rx_err",
 			sizeof(struct dpaa2_queue), 0);
 		if (!priv->rx_err_vq) {
@@ -1041,7 +1041,7 @@ dpaa2_dev_rx_queue_setup(struct rte_eth_dev *dev,
 		qopt |= DPNI_QUEUE_OPT_FLC;
 		cfg->flc.stash_control = true;
 		dpaa2_flc_stashing_clear_all(&cfg->flc.value);
-		if (priv->flags & DPAA2_DATA_STASHING_OFF) {
+		if (priv->flags & DPAA2_RX_DATA_STASHING_OFF_FLAG) {
 			dpaa2_flc_stashing_set(DPAA2_FLC_DATA_STASHING, 0,
 				&cfg->flc.value);
 			dpaa2_q->data_stashing_off = 1;
@@ -1499,7 +1499,7 @@ dpaa2_dev_start(struct rte_eth_dev *dev)
 		dpaa2_q->fqid = qid.fqid;
 	}
 
-	if (priv->flags & DPAAX_RX_ERROR_QUEUE_FLAG) {
+	if (priv->flags & DPAA2_RX_ERROR_QUEUE_FLAG) {
 		ret = dpni_get_queue(dpni, CMD_PRI_LOW, priv->token,
 				     DPNI_QUEUE_RX_ERR, 0, 0, &cfg, &qid);
 		if (ret) {
@@ -3462,7 +3462,7 @@ dpaa2_dev_init(struct rte_eth_dev *eth_dev)
 
 	if (dpaa2_get_devargs(dev->devargs, DRIVER_NO_DATA_STASHING) ||
 	    getenv("DPAA2_DATA_STASHING_OFF")) {
-		priv->flags |= DPAA2_DATA_STASHING_OFF;
+		priv->flags |= DPAA2_RX_DATA_STASHING_OFF_FLAG;
 		DPAA2_PMD_INFO("Data stashing disabled");
 	}
 
@@ -3592,7 +3592,7 @@ dpaa2_dev_init(struct rte_eth_dev *eth_dev)
 	}
 
 	if (dpaa2_get_devargs(dev->devargs, DRIVER_ERROR_QUEUE)) {
-		priv->flags |= DPAAX_RX_ERROR_QUEUE_FLAG;
+		priv->flags |= DPAA2_RX_ERROR_QUEUE_FLAG;
 		DPAA2_PMD_INFO("Enable error queue");
 	}
 
drivers/net/dpaa2/dpaa2_ethdev.h +2 -2
index 3c611652b1..28623dc37d 100644
@@ -100,9 +100,9 @@
 #define DPAA2_TX_DYNAMIC_CONF_ENABLE	RTE_BIT32(9)
 
 /* Disable data stashing (prefetch of packet data into CPU cache) */
-#define DPAA2_DATA_STASHING_OFF		RTE_BIT32(10)
+#define DPAA2_RX_DATA_STASHING_OFF_FLAG		RTE_BIT32(10)
 
-#define DPAAX_RX_ERROR_QUEUE_FLAG	RTE_BIT32(11)
+#define DPAA2_RX_ERROR_QUEUE_FLAG	RTE_BIT32(11)
 #define DPAA2_RX_PRINT_PSR_RESULT_FLAG RTE_BIT32(12)
 
 /* DPDMUX index for DPMAC */
drivers/net/dpaa2/dpaa2_rxtx.c +2 -2
index ccb4bbe7dc..a03e3fd8db 100644
@@ -870,7 +870,7 @@ dpaa2_dev_prefetch_rx_common(void *queue, struct rte_mbuf **bufs,
 
 	q_storage = dpaa2_q->q_storage[rte_lcore_id()];
 
-	if (unlikely(priv->flags & DPAAX_RX_ERROR_QUEUE_FLAG))
+	if (unlikely(priv->flags & DPAA2_RX_ERROR_QUEUE_FLAG))
 		dump_err_pkts(priv->rx_err_vq);
 
 	if (unlikely(!DPAA2_PER_LCORE_ETHRX_DPIO)) {
@@ -1142,7 +1142,7 @@ dpaa2_dev_rx_common(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts,
 	struct rte_eth_dev_data *eth_data = dpaa2_q->eth_data;
 	struct dpaa2_dev_priv *priv = eth_data->dev_private;
 
-	if (!by_channel && unlikely(priv->flags & DPAAX_RX_ERROR_QUEUE_FLAG))
+	if (!by_channel && unlikely(priv->flags & DPAA2_RX_ERROR_QUEUE_FLAG))
 		dump_err_pkts(priv->rx_err_vq);
 
 	if (by_channel) {
Signature · 1 line
2.43.0
#33 lore raw

PATCH 32/45 drivers: rework dpaa2 Tx confirmation

In reply to Prashant Gupta

From: Jun Yang <[email protected]>

Mbufs released by Tx confirmation may come from any mempool, so use the RTE mbuf free API instead of returning the buffers directly to the bman pool. The FD FLC field now carries the Tx mbuf pointer so that the confirmation callback can release it to either the platform pool or an external pool.

Absolute and dynamic Tx confirmation become independent settings, giving three Tx modes:

1) No confirmation (default). Suited to traffic that is mostly sent from the platform pool. For the few packets from other pools the driver allocates a platform buffer, copies the data and frees the original.
2) Absolute confirmation. Suited to traffic mostly sent from non platform pools. Every Tx packet raises a confirmation, configured at queue setup, and the callback frees the packet.
3) Dynamic confirmation. Confirmation is raised only for packets from non platform pools; the driver marks each packet accordingly at runtime. This suits a roughly even mix of platform and non platform buffers.

---
 drivers/bus/fslmc/portal/dpaa2_hw_pvt.h      |    1 +
 drivers/net/dpaa2/base/dpaa2_hw_dpni.c       |    2 +-
 drivers/net/dpaa2/base/dpaa2_hw_dpni_annot.h |    6 +-
 drivers/net/dpaa2/dpaa2_ethdev.c             |   63 +-
 drivers/net/dpaa2/dpaa2_ethdev.h             |   37 +-
 drivers/net/dpaa2/dpaa2_ptp.c                |    4 +-
 drivers/net/dpaa2/dpaa2_rxtx.c               | 1511 ++++++++----------
 7 files changed, 751 insertions(+), 873 deletions(-)
drivers/bus/fslmc/portal/dpaa2_hw_pvt.h +1 -0
index f87bf51d09..b3aad85d06 100644
@@ -198,6 +198,7 @@ struct __rte_cache_aligned dpaa2_queue {
 	uint16_t tm_sw_td;	/*!< TM software taildrop */
 	uint64_t offloads;
 	uint64_t lpbk_cntx;
+	int32_t ts_to_cnfd;
 	uint8_t data_stashing_off;
 	/* NAPI rx-interrupt: per-queue DPCON bound to this FQ at dev_start
 	 * (DEST_DPCON, static); the polling worker points the channel's CDAN at
drivers/net/dpaa2/base/dpaa2_hw_dpni.c +1 -1
index 26ad105c73..fee96b3529 100644
@@ -484,7 +484,7 @@ dpaa2_attach_bp_list(struct dpaa2_dev_priv *priv,
 	 */
 
 	/* ... rx buffer layout ... */
-	if (priv->flags & DPAA2_TX_DYNAMIC_CONF_ENABLE) {
+	if (priv->flags & DPAA2_TX_PREFETCH_DYNAMIC_CONF) {
 		int out_min_hdr_room, in_min_hdr_room;
 		/** Additional headroom layout for IPSec with TX configure
 		 * dynamic enabled.
drivers/net/dpaa2/base/dpaa2_hw_dpni_annot.h +5 -1
index a670098958..b06fa3f644 100644
@@ -1,7 +1,7 @@
 /* SPDX-License-Identifier: BSD-3-Clause
  *
  *   Copyright (c) 2016 Freescale Semiconductor, Inc. All rights reserved.
- *   Copyright 2016,2019,2022,2024 NXP
+ *   Copyright 2016,2019,2022,2024-2026 NXP
  *
  */
 
@@ -281,6 +281,10 @@ struct dpaa2_faead {
 /*UPD (Update prepended data)*/
 #define DPAA2_ANNOT_FAEAD_UPD		0x00000010
 
+#define DPAA2_TX_CONFIRM_ENABLE \
+	(DPAA2_ANNOT_FAEAD_A4V | DPAA2_ANNOT_FAEAD_EBDD | \
+	DPAA2_ANNOT_FAEAD_EBDDV)
+
 /* Debug frame, otherwise supposed to be discarded */
 #define DPAA2_ETH_FAS_DISC	      0x80000000
 /* MACSEC frame */
drivers/net/dpaa2/dpaa2_ethdev.c +37 -26

141 lines not on this page · raw message

drivers/net/dpaa2/dpaa2_ethdev.h +25 -12
index 28623dc37d..c6a8b4f595 100644
@@ -91,18 +91,14 @@
 
 #define DPAA2_TX_DPNI_LOOPBACK_MODE	RTE_BIT32(7)
 
-/* Tx confirmation enabled */
-#define DPAA2_TX_CONF_ENABLE	RTE_BIT32(8)
+#define DPAA2_TX_PREFETCH_DYNAMIC_CONF	RTE_BIT32(8)
 
-/* Tx dynamic confirmation enabled,
- * only valid with Tx confirmation enabled.
- */
-#define DPAA2_TX_DYNAMIC_CONF_ENABLE	RTE_BIT32(9)
+#define DPAA2_RX_ERROR_QUEUE_FLAG	RTE_BIT32(9)
+
+#define DPAA2_RX_DATA_STASHING_OFF_FLAG	RTE_BIT32(10)
 
-/* Disable data stashing (prefetch of packet data into CPU cache) */
-#define DPAA2_RX_DATA_STASHING_OFF_FLAG		RTE_BIT32(10)
+#define DPAA2_RX_SCHED_STRICT_ORDER_FLAG RTE_BIT32(11)
 
-#define DPAA2_RX_ERROR_QUEUE_FLAG	RTE_BIT32(11)
 #define DPAA2_RX_PRINT_PSR_RESULT_FLAG RTE_BIT32(12)
 
 /* DPDMUX index for DPMAC */
@@ -451,6 +447,12 @@ struct dpaa2_dev_meter {
 	uint32_t policy_id;
 };
 
+enum dpaa2_tx_conf_type {
+	DPAA2_TX_NO_CONF,
+	DPAA2_TX_ABSOLUTE_CONF,
+	DPAA2_TX_DYNAMIC_CONF
+};
+
 struct dpaa2_dev_priv {
 	void *hw;
 	int32_t hw_id;
@@ -466,6 +468,7 @@ struct dpaa2_dev_priv {
 	void *tx_conf_vq[MAX_TX_QUEUES];
 	void *rx_err_vq;
 	uint32_t flags; /*dpaa2 config flags */
+	enum dpaa2_tx_conf_type tx_conf_type;
 	int psr_dynfield_offset;
 	uint8_t max_mac_filters;
 	uint8_t max_vlan_filters;
@@ -510,10 +513,10 @@ struct dpaa2_dev_priv {
 
 	int rx_ts_offset;
 	uint64_t rx_ts_flag;
-	/* stores pointer to next tx_conf queue that should be processed,
+	/* stores next tx queue to be confirmed that should be processed,
 	 * it corresponds to last packet transmitted
 	 */
-	struct dpaa2_queue *next_tx_conf_queue;
+	struct dpaa2_queue *next_txq_to_cnf;
 
 	struct rte_eth_dev *eth_dev; /**< Pointer back to holding ethdev */
 	rte_spinlock_t lpbk_qp_lock;
@@ -531,6 +534,8 @@ struct dpaa2_dev_priv {
 	uint64_t cnt_idx_iova, cnt_values_iova;
 	uint64_t mc_rev;
 
+	struct rte_mempool *tx_sg_pool;
+
 	struct dpaa2_dev_flow *curr;
 	LIST_HEAD(, dpaa2_dev_flow) flows;
 	LIST_HEAD(, dpaa2_dev_meter_profile) profiles;
@@ -646,7 +651,7 @@ uint16_t dpaa2_dev_tx_multi_txq_ordered(void **queue,
 
 void dpaa2_dev_free_eqresp_buf(uint16_t eqresp_ci, struct dpaa2_queue *dpaa2_q);
 void dpaa2_flow_clean(struct rte_eth_dev *dev);
-uint16_t dpaa2_dev_tx_conf(void *queue)  __rte_unused;
+uint16_t dpaa2_dev_tx_conf(void *txq, int drain);
 
 int dpaa2_timesync_enable(struct rte_eth_dev *dev);
 int dpaa2_timesync_disable(struct rte_eth_dev *dev);
@@ -663,6 +668,14 @@ int dpaa2_timesync_read_tx_timestamp(struct rte_eth_dev *dev,
 
 int dpaa2_dev_recycle_config(struct rte_eth_dev *eth_dev);
 int dpaa2_dev_recycle_deconfig(struct rte_eth_dev *eth_dev);
+
+__rte_internal
+struct rte_mbuf *__rte_hot
+dpaa2_eth_fd_to_mbuf(struct dpaa2_dev_priv *priv, const struct qbman_fd *fd);
+__rte_internal
+struct rte_mbuf *__rte_hot
+dpaa2_eth_sg_fd_to_mbuf(struct dpaa2_dev_priv *priv, const struct qbman_fd *fd);
+
 int dpaa2_mtr_ops_get(struct rte_eth_dev *dev, void *ops);
 int dpaa2_soft_parser_loaded(void);
 
drivers/net/dpaa2/dpaa2_ptp.c +2 -2
index 751e558c73..c845291c68 100644
@@ -111,9 +111,9 @@ int dpaa2_timesync_read_tx_timestamp(struct rte_eth_dev *dev,
 {
 	struct dpaa2_dev_priv *priv = dev->data->dev_private;
 
-	if (priv->next_tx_conf_queue) {
+	if (priv->next_txq_to_cnf) {
 		while (!priv->tx_timestamp)
-			dpaa2_dev_tx_conf(priv->next_tx_conf_queue);
+			dpaa2_dev_tx_conf(priv->next_txq_to_cnf, false);
 	} else {
 		return -1;
 	}
drivers/net/dpaa2/dpaa2_rxtx.c +680 -831

1,784 lines not on this page · raw message

Signature · 1 line
2.43.0
#34 lore raw

PATCH 33/45 net/dpaa2: ptp enhancements

In reply to Prashant Gupta

From: Jun Yang <[email protected]>

1) Correct TX timestamp only for PTP sync packets.
2) Runtime configure TX timestamp offset by parsing current TX PTP packet format.

---
 drivers/net/dpaa2/dpaa2_ethdev.c |  92 ++--------------
 drivers/net/dpaa2/dpaa2_ethdev.h |  30 +++++-
 drivers/net/dpaa2/dpaa2_ptp.c    | 176 +++++++++++++++++++++++++------
 drivers/net/dpaa2/dpaa2_rxtx.c   |  77 +++++++++++++-
 4 files changed, 252 insertions(+), 123 deletions(-)
drivers/net/dpaa2/dpaa2_ethdev.c +6 -86
index 61b7ae138c..58b4cedee3 100644
@@ -72,11 +72,6 @@ static uint64_t dev_tx_offloads_sup =
 static uint64_t dev_tx_offloads_nodis =
 		RTE_ETH_TX_OFFLOAD_MULTI_SEGS;
 
-/* enable timestamp in mbuf */
-bool dpaa2_enable_ts[RTE_MAX_ETHPORTS];
-uint64_t dpaa2_timestamp_rx_dynflag;
-int dpaa2_timestamp_dynfield_offset = -1;
-
 bool dpaa2_print_parser_result;
 
 /* Rx descriptor limit when DPNI loads PFDRs in PEB */
@@ -730,9 +725,6 @@ dpaa2_eth_dev_configure(struct rte_eth_dev *dev)
 	int tx_l4_csum_offload = false;
 	int ret, tc_index;
 	uint32_t max_rx_pktlen;
-#if defined(RTE_LIBRTE_IEEE1588)
-	uint16_t ptp_correction_offset;
-#endif
 
 	PMD_INIT_FUNC_TRACE();
 
@@ -814,25 +806,15 @@ dpaa2_eth_dev_configure(struct rte_eth_dev *dev)
 		return ret;
 	}
 
-#if !defined(RTE_LIBRTE_IEEE1588)
-	if (rx_offloads & RTE_ETH_RX_OFFLOAD_TIMESTAMP)
-#endif
-	{
-		ret = rte_mbuf_dyn_rx_timestamp_register(
-				&dpaa2_timestamp_dynfield_offset,
-				&dpaa2_timestamp_rx_dynflag);
-		if (ret != 0) {
+	if (rx_offloads & RTE_ETH_RX_OFFLOAD_TIMESTAMP) {
+		ret = rte_mbuf_dyn_rx_timestamp_register(&priv->rx_ts_offset,
+			&priv->rx_ts_flag);
+		if (ret) {
 			DPAA2_PMD_ERR("Error to register timestamp field/flag");
-			return -rte_errno;
+			return ret;
 		}
-		dpaa2_enable_ts[dev->data->port_id] = true;
 	}
 
-#if defined(RTE_LIBRTE_IEEE1588)
-	/* By default setting ptp correction offset for Ethernet SYNC packets */
-	ptp_correction_offset = RTE_ETHER_HDR_LEN + 8;
-	rte_pmd_dpaa2_set_one_step_ts(dev->data->port_id, ptp_correction_offset, 0);
-#endif
 	if (tx_offloads & RTE_ETH_TX_OFFLOAD_IPV4_CKSUM)
 		tx_l3_csum_offload = true;
 
@@ -3315,8 +3297,6 @@ static struct eth_dev_ops dpaa2_ethdev_ops = {
 	.rxq_info_get	      = dpaa2_rxq_info_get,
 	.txq_info_get	      = dpaa2_txq_info_get,
 	.tm_ops_get	      = dpaa2_tm_ops_get,
-	.mtr_ops_get	      = dpaa2_mtr_ops_get,
-#if defined(RTE_LIBRTE_IEEE1588)
 	.timesync_enable      = dpaa2_timesync_enable,
 	.timesync_disable     = dpaa2_timesync_disable,
 	.timesync_read_time   = dpaa2_timesync_read_time,
@@ -3324,7 +3304,7 @@ static struct eth_dev_ops dpaa2_ethdev_ops = {
 	.timesync_adjust_time = dpaa2_timesync_adjust_time,
 	.timesync_read_rx_timestamp = dpaa2_timesync_read_rx_timestamp,
 	.timesync_read_tx_timestamp = dpaa2_timesync_read_tx_timestamp,
-#endif
+	.mtr_ops_get	      = dpaa2_mtr_ops_get,
 };
 
 /* Populate the mac address from physically available (u-boot/firmware) and/or
@@ -3589,11 +3569,6 @@ dpaa2_dev_init(struct rte_eth_dev *eth_dev)
 	priv->options = attr.options;
 	priv->max_mac_filters = attr.mac_filter_entries;
 	priv->max_vlan_filters = attr.vlan_filter_entries;
-	priv->flags = 0;
-#if defined(RTE_LIBRTE_IEEE1588)
-	DPAA2_PMD_INFO("DPDK IEEE1588 is enabled");
-	priv->flags |= DPAA2_TX_CONF_ENABLE;
-#endif
 	priv->tx_conf_type = DPAA2_TX_NO_CONF;
 
 	/* Used with ``fslmc:dpni.1,drv_tx_conf=1`` */
@@ -3803,61 +3778,6 @@ rte_pmd_dpaa2_ep_name(uint32_t eth_id)
 	return priv->ep_name;
 }
 
-#if defined(RTE_LIBRTE_IEEE1588)
-RTE_EXPORT_EXPERIMENTAL_SYMBOL(rte_pmd_dpaa2_get_one_step_ts, 24.11)
-int
-rte_pmd_dpaa2_get_one_step_ts(uint16_t port_id, bool mc_query)
-{
-	struct rte_eth_dev *dev = &rte_eth_devices[port_id];
-	struct dpaa2_dev_priv *priv = dev->data->dev_private;
-	struct fsl_mc_io *dpni = priv->eth_dev->process_private;
-	struct dpni_single_step_cfg ptp_cfg;
-	int err;
-
-	if (!mc_query)
-		return priv->ptp_correction_offset;
-
-	err = dpni_get_single_step_cfg(dpni, CMD_PRI_LOW, priv->token, &ptp_cfg);
-	if (err) {
-		DPAA2_PMD_ERR("Failed to retrieve onestep configuration");
-		return err;
-	}
-
-	if (!ptp_cfg.ptp_onestep_reg_base) {
-		DPAA2_PMD_ERR("1588 onestep reg not available");
-		return -1;
-	}
-
-	priv->ptp_correction_offset = ptp_cfg.offset;
-
-	return priv->ptp_correction_offset;
-}
-
-RTE_EXPORT_EXPERIMENTAL_SYMBOL(rte_pmd_dpaa2_set_one_step_ts, 24.11)
-int
-rte_pmd_dpaa2_set_one_step_ts(uint16_t port_id, uint16_t offset, uint8_t ch_update)
-{
-	struct rte_eth_dev *dev = &rte_eth_devices[port_id];
-	struct dpaa2_dev_priv *priv = dev->data->dev_private;
-	struct fsl_mc_io *dpni = dev->process_private;
-	struct dpni_single_step_cfg cfg;
-	int err;
-
-	cfg.en = 1;
-	cfg.ch_update = ch_update;
-	cfg.offset = offset;
-	cfg.peer_delay = 0;
-
-	err = dpni_set_single_step_cfg(dpni, CMD_PRI_LOW, priv->token, &cfg);
-	if (err)
-		return err;
-
-	priv->ptp_correction_offset = offset;
-
-	return 0;
-}
-#endif
-
 static int dpaa2_tx_sg_pool_init(void)
 {
 	char name[RTE_MEMZONE_NAMESIZE];
drivers/net/dpaa2/dpaa2_ethdev.h +27 -3
index c6a8b4f595..e7490b1e0c 100644
@@ -8,6 +8,7 @@
 #ifndef _DPAA2_ETHDEV_H
 #define _DPAA2_ETHDEV_H
 
+#include <rte_time.h>
 #include <rte_compat.h>
 #include <rte_event_eth_rx_adapter.h>
 #include <rte_pmd_dpaa2.h>
@@ -101,6 +102,11 @@
 
 #define DPAA2_RX_PRINT_PSR_RESULT_FLAG RTE_BIT32(12)
 
+#define DPAA2_IEEE1588_DEBUG_FLAG RTE_BIT32(13)
+
+#define DPAA2_IEEE1588_TX_TS_FLAG RTE_BIT32(14)
+#define DPAA2_IEEE1588_RX_TS_FLAG RTE_BIT32(15)
+
 /* DPDMUX index for DPMAC */
 #define DPAA2_DPDMUX_DPMAC_IDX 0
 
@@ -507,16 +513,16 @@ struct dpaa2_dev_priv {
 	uint64_t ss_iova;
 	uint64_t ss_param_iova;
 	/*stores timestamp of last received packet on dev*/
-	uint64_t rx_timestamp;
+	RTE_ATOMIC(uint64_t) rx_timestamp;
 	/*stores timestamp of last received tx confirmation packet on dev*/
-	uint64_t tx_timestamp;
+	RTE_ATOMIC(uint64_t) tx_timestamp;
 
 	int rx_ts_offset;
 	uint64_t rx_ts_flag;
 	/* stores next tx queue to be confirmed that should be processed,
 	 * it corresponds to last packet transmitted
 	 */
-	struct dpaa2_queue *next_txq_to_cnf;
+	RTE_ATOMIC(struct dpaa2_queue *) next_txq_to_cnf;
 
 	struct rte_eth_dev *eth_dev; /**< Pointer back to holding ethdev */
 	rte_spinlock_t lpbk_qp_lock;
@@ -591,6 +597,21 @@ dpaa2_dev_rx_print_parser_result(struct dpaa2_dev_priv *priv,
 	}
 }
 
+static inline void
+dpaa2_timestamp_debug(struct dpaa2_dev_priv *priv,
+	const char *prefix, uint64_t timestamp)
+{
+	struct timespec ts;
+
+	if (likely(!(priv->flags & DPAA2_IEEE1588_DEBUG_FLAG)))
+		return;
+
+	ts = rte_ns_to_timespec(timestamp);
+	DPAA2_PMD_DEBUG("DPAA2 TS DBG: %s: ns(%" PRIu64 ")->%" PRId64
+		" seconds/%" PRId64 " nanoseconds",
+		prefix, timestamp, (int64_t)ts.tv_sec, (int64_t)ts.tv_nsec);
+}
+
 int dpaa2_distset_to_dpkg_profile_cfg(uint64_t req_dist_set,
 				      struct dpkg_profile_cfg *kg_cfg);
 
@@ -653,6 +674,9 @@ void dpaa2_dev_free_eqresp_buf(uint16_t eqresp_ci, struct dpaa2_queue *dpaa2_q);
 void dpaa2_flow_clean(struct rte_eth_dev *dev);
 uint16_t dpaa2_dev_tx_conf(void *txq, int drain);
 
+void
+dpaa2_dev_tx_ptp_one_step_runtime(struct rte_eth_dev *dev,
+	struct rte_mbuf *buf, int *tstamp, int *set);
 int dpaa2_timesync_enable(struct rte_eth_dev *dev);
 int dpaa2_timesync_disable(struct rte_eth_dev *dev);
 int dpaa2_timesync_read_time(struct rte_eth_dev *dev,
drivers/net/dpaa2/dpaa2_ptp.c +145 -31

294 lines not on this page · raw message

drivers/net/dpaa2/dpaa2_rxtx.c +74 -3

173 lines not on this page · raw message

Signature · 1 line
2.43.0
#35 lore raw

PATCH 34/45 net/dpaa2: remove unused soft parser Tx code

In reply to Prashant Gupta

From: Hemant Agrawal <[email protected]>

Remove the soft parser related code from the Tx path. The soft parser can only be loaded before Linux boots, so this code was never reachable at runtime.

---
 drivers/net/dpaa2/dpaa2_rxtx.c | 10 ----------
 1 file changed, 10 deletions(-)
drivers/net/dpaa2/dpaa2_rxtx.c +0 -10
index eda88a7bed..5c6a77d2f8 100644
@@ -169,16 +169,6 @@ dpaa2_dev_rx_parse_new(struct dpaa2_dev_priv *priv,
 			ext_packet_type |= RTE_PTYPE_INNER_L3_IPV4;
 		}
 	}
-	if (priv->sp_protocol) {
-		if (frc_parse->fafe2) {
-			frc_parse->fafe2 = 0;
-			ext_packet_type |= RTE_PTYPE_TUNNEL_GENEVE;
-		}
-		if (frc_parse->sum_l.l4.fafe3) {
-			frc_parse->sum_l.l4.fafe3 = 0;
-			ext_packet_type |= RTE_PTYPE_INNER_L3_IPV4;
-		}
-	}
 	switch (frc) {
 	case DPAA2_PKT_TYPE_IPV4_UDP:
 		m->packet_type = RTE_PTYPE_L2_ETHER |
Signature · 1 line
2.43.0
#36 lore raw

PATCH 35/45 net/dpaa2: update MC dpni QoS and flow steering API

In reply to Prashant Gupta

From: Hemant Agrawal <[email protected]>

Update the MC firmware command interface for the QoS and flow steering (FS) tables ahead of the flow engine rework:

- Version the SET_QOS_TBL / ADD_FS_ENT commands and add dpni_set_qos_table_v2() and dpni_add_fs_entry_legacy() wrappers.
- Support a per-entry default flow id in the QoS table configuration.
- Replace the single redirect_obj_token in dpni_fs_action_cfg with a redir_tokens[] array plus num_tokens, and program it via the new ADD_FS_ENT command.
- Add the dpni dump-table structures.

The existing flow code is updated to populate the new redir_tokens[] field so behaviour is unchanged.

---
 drivers/net/dpaa2/dpaa2_flow.c      |   3 +-
 drivers/net/dpaa2/mc/dpni.c         | 127 ++++++++++++++++++++--------
 drivers/net/dpaa2/mc/fsl_dpni.h     | 100 ++++++++++++++++++++--
 drivers/net/dpaa2/mc/fsl_dpni_cmd.h |  30 ++++---
 4 files changed, 206 insertions(+), 54 deletions(-)
drivers/net/dpaa2/dpaa2_flow.c +2 -1
index cde2f5a9d3..c616857e98 100644
@@ -4444,7 +4444,8 @@ dpaa2_configure_flow_fs_action(struct dpaa2_dev_priv *priv,
 		dest_q = dest_priv->tx_vq[0];
 		flow->fs_action_cfg.options =
 			DPNI_FS_OPT_REDIRECT_TO_DPNI_TX;
-		flow->fs_action_cfg.redirect_obj_token =
+		flow->fs_action_cfg.num_tokens = 1;
+		flow->fs_action_cfg.redir_tokens[0] =
 			dest_priv->token;
 		flow->fs_action_cfg.flow_id = dest_q->flow_id;
 	} else if (flow->action_type == RTE_FLOW_ACTION_TYPE_DROP) {
drivers/net/dpaa2/mc/dpni.c +91 -36

179 lines not on this page · raw message

drivers/net/dpaa2/mc/fsl_dpni.h +94 -6

171 lines not on this page · raw message

drivers/net/dpaa2/mc/fsl_dpni_cmd.h +19 -11
index 6b396ca7cc..36e4aacc3a 100644
@@ -1,7 +1,7 @@
 /* SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0
  *
  * Copyright 2013-2016 Freescale Semiconductor Inc.
- * Copyright 2016-2025 NXP
+ * Copyright 2016-2026 NXP
  *
  */
 #ifndef _FSL_DPNI_CMD_H
@@ -20,6 +20,7 @@
 #define DPNI_CMD_VERSION_7			7
 #define DPNI_CMD_ID_OFFSET			4
 
+#define DPNI_CMD_VER(cmd_id) ((cmd_id) & ((1 << DPNI_CMD_ID_OFFSET) - 1))
 #define DPNI_CMD(id)	(((id) << DPNI_CMD_ID_OFFSET) | DPNI_CMD_BASE_VERSION)
 #define DPNI_CMD_V2(id)	(((id) << DPNI_CMD_ID_OFFSET) | DPNI_CMD_VERSION_2)
 #define DPNI_CMD_V3(id)	(((id) << DPNI_CMD_ID_OFFSET) | DPNI_CMD_VERSION_3)
@@ -77,13 +78,16 @@
 
 #define DPNI_CMDID_SET_RX_TC_DIST		DPNI_CMD_V4(0x235)
 
-#define DPNI_CMDID_SET_RX_TC_POLICING		DPNI_CMD(0x23E)
+#define DPNI_CMDID_SET_RX_TC_POLICING_V1	DPNI_CMD(0x23E)
+#define DPNI_CMDID_SET_RX_TC_POLICING		DPNI_CMD_V2(0x23E)
 
-#define DPNI_CMDID_SET_QOS_TBL			DPNI_CMD_V2(0x240)
+#define DPNI_CMDID_SET_QOS_TBL			DPNI_CMD_V3(0x240)
+#define DPNI_CMDID_SET_QOS_TBL_V2		DPNI_CMD_V2(0x240)
 #define DPNI_CMDID_ADD_QOS_ENT			DPNI_CMD_V2(0x241)
 #define DPNI_CMDID_REMOVE_QOS_ENT		DPNI_CMD(0x242)
 #define DPNI_CMDID_CLR_QOS_TBL			DPNI_CMD(0x243)
-#define DPNI_CMDID_ADD_FS_ENT			DPNI_CMD_V2(0x244)
+#define DPNI_CMDID_ADD_FS_ENT_LEGACY	DPNI_CMD_V2(0x244)
+#define DPNI_CMDID_ADD_FS_ENT			DPNI_CMD_V3(0x244)
 #define DPNI_CMDID_REMOVE_FS_ENT		DPNI_CMD(0x245)
 #define DPNI_CMDID_CLR_FS_ENT			DPNI_CMD(0x246)
 
@@ -584,19 +588,18 @@ struct dpni_cmd_set_queue {
 #define DPNI_DISCARD_ON_MISS_SIZE	1
 #define DPNI_KEEP_QOS_ENTRIES_SHIFT		1
 #define DPNI_KEEP_QOS_ENTRIES_SIZE		1
+#define DPNI_SET_DEFAULT_FLOW_ID_SHIFT  2
+#define DPNI_SET_DEFAULT_FLOW_ID_SIZE   1
 
 struct dpni_cmd_set_qos_table {
-	uint32_t pad;
+	uint16_t pad;
+	uint16_t default_flow_id;
 	uint8_t default_tc;
-	/* only the LSB */
-	uint8_t discard_on_miss;
+	uint8_t flags;
 	uint16_t pad1[21];
 	uint64_t key_cfg_iova;
 };
 
-#define DPNI_QOS_OPT_SET_TC_ONLY 0x0
-#define DPNI_QOS_OPT_SET_FLOW_ID 0x1
-
 struct dpni_cmd_add_qos_entry {
 	uint8_t flags;
 	uint8_t flow_id;
@@ -616,6 +619,10 @@ struct dpni_cmd_remove_qos_entry {
 	uint64_t mask_iova;
 };
 
+#ifndef DPNI_FS_REDIR_MAX_NUM
+#define DPNI_FS_REDIR_MAX_NUM 8
+#endif
+
 struct dpni_cmd_add_fs_entry {
 	uint16_t options;
 	uint8_t tc_id;
@@ -625,7 +632,8 @@ struct dpni_cmd_add_fs_entry {
 	uint64_t key_iova;
 	uint64_t mask_iova;
 	uint64_t flc;
-	uint16_t redir_token;
+	uint16_t redir_tokens[DPNI_FS_REDIR_MAX_NUM];
+	uint8_t token_num;
 };
 
 struct dpni_cmd_remove_fs_entry {
Signature · 1 line
2.43.0
#37 lore raw

PATCH 36/45 net/dpaa2: enhance xstat implementation

In reply to Prashant Gupta

From: Gagandeep Singh <[email protected]>

1) Adapt RTE xstat API to return proper length.
2) Alloc DMA buffer of mac xstat only once.
3) Get MAC counter via dpni only when this dpni is connected to DPMAC.
4) Get TC policer counter only when meter flow of TC is there.

---
 drivers/net/dpaa2/dpaa2_ethdev.c | 930 ++++++++++++++++++-------------
 drivers/net/dpaa2/dpaa2_ethdev.h |  12 +-
 drivers/net/dpaa2/mc/fsl_dpni.h  | 259 +++++++--
 3 files changed, 756 insertions(+), 445 deletions(-)
drivers/net/dpaa2/dpaa2_ethdev.c +534 -396
index 58b4cedee3..1836226706 100644
@@ -26,6 +26,7 @@
 #include <dpaa2_hw_pvt.h>
 #include <dpaa2_hw_mempool.h>
 #include <dpaa2_hw_dpio.h>
+#include <fsl_dprc.h>
 #include <mc/fsl_dpmng.h>
 #include <mc/fsl_dpcon.h>
 #include "dpaa2_ethdev.h"
@@ -108,116 +109,287 @@ dpaa2_dist_size_is_supported(uint16_t n)
 int dpaa2_valid_dev;
 struct rte_mempool *dpaa2_tx_sg_pool;
 
-struct rte_dpaa2_xstats_name_off {
-	char name[RTE_ETH_XSTATS_NAME_SIZE];
-	uint8_t page_id; /* dpni statistics page id */
-	uint8_t stats_id; /* stats id in the given page */
+struct dpaa2_xstats_seq {
+	struct dpni_statistics_page_0 pg0;
+	struct dpni_statistics_page_1 pg1;
+	struct dpni_statistics_page_2 pg2;
+	struct dpni_statistics_page_3 pg3;
+	struct dpni_statistics_page_4 pg4;
+	struct dpni_statistics_page_5 pg5[MAX_TCS];
+	struct dpni_statistics_page_6 pg6;
+	struct dpni_dpmac_counters mac_cnt;
 };
 
-static const struct rte_dpaa2_xstats_name_off dpaa2_xstats_strings[] = {
-	{"ingress_multicast_frames", 0, 2},
-	{"ingress_multicast_bytes", 0, 3},
-	{"ingress_broadcast_frames", 0, 4},
-	{"ingress_broadcast_bytes", 0, 5},
-	{"egress_multicast_frames", 1, 2},
-	{"egress_multicast_bytes", 1, 3},
-	{"egress_broadcast_frames", 1, 4},
-	{"egress_broadcast_bytes", 1, 5},
-	{"ingress_filtered_frames", 2, 0},
-	{"ingress_discarded_frames", 2, 1},
-	{"ingress_nobuffer_discards", 2, 2},
-	{"egress_discarded_frames", 2, 3},
-	{"egress_confirmed_frames", 2, 4},
-	{"cgr_reject_frames", 4, 0},
-	{"cgr_reject_bytes", 4, 1},
-	{"TC_0_policer_cnt_red", 5, 0},
-	{"TC_0_policer_cnt_yellow", 5, 1},
-	{"TC_0_policer_cnt_green", 5, 2},
-	{"TC_0_policer_cnt_re_red", 5, 3},
-	{"TC_0_policer_cnt_re_yellow", 5, 4},
-	{"TC_1_policer_cnt_red", 6, 0},
-	{"TC_1_policer_cnt_yellow", 6, 1},
-	{"TC_1_policer_cnt_green", 6, 2},
-	{"TC_1_policer_cnt_re_red", 6, 3},
-	{"TC_1_policer_cnt_re_yellow", 6, 4},
-	{"TC_2_policer_cnt_red", 7, 0},
-	{"TC_2_policer_cnt_yellow", 7, 1},
-	{"TC_2_policer_cnt_green", 7, 2},
-	{"TC_2_policer_cnt_re_red", 7, 3},
-	{"TC_2_policer_cnt_re_yellow", 7, 4},
-	{"TC_3_policer_cnt_red", 8, 0},
-	{"TC_3_policer_cnt_yellow", 8, 1},
-	{"TC_3_policer_cnt_green", 8, 2},
-	{"TC_3_policer_cnt_re_red", 8, 3},
-	{"TC_3_policer_cnt_re_yellow", 8, 4},
-	{"TC_4_policer_cnt_red", 9, 0},
-	{"TC_4_policer_cnt_yellow", 9, 1},
-	{"TC_4_policer_cnt_green", 9, 2},
-	{"TC_4_policer_cnt_re_red", 9, 3},
-	{"TC_4_policer_cnt_re_yellow", 9, 4},
-	{"TC_5_policer_cnt_red", 10, 0},
-	{"TC_5_policer_cnt_yellow", 10, 1},
-	{"TC_5_policer_cnt_green", 10, 2},
-	{"TC_5_policer_cnt_re_red", 10, 3},
-	{"TC_5_policer_cnt_re_yellow", 10, 4},
-	{"TC_6_policer_cnt_red", 11, 0},
-	{"TC_6_policer_cnt_yellow", 11, 1},
-	{"TC_6_policer_cnt_green", 11, 2},
-	{"TC_6_policer_cnt_re_red", 11, 3},
-	{"TC_6_policer_cnt_re_yellow", 11, 4},
-	{"TC_7_policer_cnt_red", 12, 0},
-	{"TC_7_policer_cnt_yellow", 12, 1},
-	{"TC_7_policer_cnt_green", 12, 2},
-	{"TC_7_policer_cnt_re_red", 12, 3},
-	{"TC_7_policer_cnt_re_yellow", 12, 4},
-	{"mac_rx_64 bytes", 0, 0},
-	{"mac_rx_65-127 bytes", 0, 0},
-	{"mac_rx_128-255 bytes", 0, 0},
-	{"mac_rx_256-511 bytes", 0, 0},
-	{"mac_rx_512-1023 bytes", 0, 0},
-	{"mac_rx_1024-1518 bytes", 0, 0},
-	{"mac_rx_1519-max bytes", 0, 0},
-	{"mac_rx_frags", 0, 0},
-	{"mac_rx_jabber", 0, 0},
-	{"mac_rx_frame discards", 0, 0},
-	{"mac_rx_align errors", 0, 0},
-	{"mac_tx_undersized", 0, 0},
-	{"mac_rx_oversized", 0, 0},
-	{"mac_rx_pause", 0, 0},
-	{"mac_tx_b-pause", 0, 0},
-	{"mac_rx_bytes", 0, 0},
-	{"mac_rx_m-cast", 0, 0},
-	{"mac_rx_b-cast", 0, 0},
-	{"mac_rx_all frames", 0, 0},
-	{"mac_rx_u-cast", 0, 0},
-	{"mac_rx_frame errors", 0, 0},
-	{"mac_tx_bytes", 0, 0},
-	{"mac_tx_m-cast", 0, 0},
-	{"mac_tx_b-cast", 0, 0},
-	{"mac_tx_u-cast", 0, 0},
-	{"mac_tx_frame errors", 0, 0},
-	{"mac_rx_frames ok", 0, 0},
-	{"mac_tx_frames ok", 0, 0},
-	{"mac_tx_64 bytes", 0, 0},
-	{"mac_tx_65-127 bytes", 0, 0},
-	{"mac_tx_128-255 bytes", 0, 0},
-	{"mac_tx_256-511 bytes", 0, 0},
-	{"mac_tx_512-1023 bytes", 0, 0},
-	{"mac_tx_1024-1518 bytes", 0, 0},
-	{"mac_tx_1519-max bytes", 0, 0},
-	{"mac_rx_all_bytes", 0, 0},
-	{"mac_rx_fcs_err", 0, 0},
-	{"mac_rx_vlan_frame", 0, 0},
-	{"mac_rx_undersized", 0, 0},
-	{"mac_rx_control_frame", 0, 0},
-	{"mac_rx_frame_discard_not_trunc", 0, 0},
-	{"mac_tx_all_bytes", 0, 0},
-	{"mac_tx_fcs_err", 0, 0},
-	{"mac_tx_vlan_frame", 0, 0},
-	{"mac_tx_all_frame", 0, 0},
-	{"mac_tx_control_frame", 0, 0},
+#define DPAA2_XSTAT_MAX_NUM \
+	(sizeof(struct dpaa2_xstats_seq) / sizeof(uint64_t))
+
+#define DPAA2_DPNI_XSTAT_MAX_NUM \
+	(offsetof(struct dpaa2_xstats_seq, mac_cnt) / sizeof(uint64_t))
+
+#define DPAA2_MAC_XSTAT_MAX_NUM DPAA2_MAC_NUM_STATS
+
+static_assert((DPAA2_DPNI_XSTAT_MAX_NUM + DPAA2_MAC_XSTAT_MAX_NUM) == DPAA2_XSTAT_MAX_NUM);
+
+#define DPAA2_DPNI_STAT_SET_PAGE_PARAM(param) \
+({ \
+	int ret = false; \
+	\
+	if ((id) >= this_offset && (id) < (this_offset + pg_size)) { \
+		_stat_id = (id) - this_offset; \
+		_param = param; \
+		_size = pg_size; \
+		ret = true; \
+	} \
+	ret; \
+})
+
+#define DPAA2_DPNI_STAT_PAGE_PARAM(pid) \
+({ \
+	uint64_t this_offset = offsetof(struct dpaa2_xstats_seq, pg##pid) / sizeof(uint64_t); \
+	uint64_t pg_size = sizeof(struct dpni_statistics_page_##pid) / sizeof(uint64_t); \
+	int ret; \
+	\
+	ret = DPAA2_DPNI_STAT_SET_PAGE_PARAM(0); \
+	if (!ret) \
+		_page++; \
+	ret; \
+})
+
+#define DPAA2_DPNI_STAT_POLICER_PAGE_PARAM() \
+({ \
+	int ret = false; \
+	uint8_t tc_id; \
+	uint64_t this_offset; \
+	uint64_t pg_size = sizeof(struct dpni_statistics_page_5) / sizeof(uint64_t); \
+	\
+	for (tc_id = 0; tc_id < MAX_TCS; tc_id++) { \
+		this_offset = offsetof(struct dpaa2_xstats_seq, pg5[tc_id]) / sizeof(uint64_t); \
+		ret = DPAA2_DPNI_STAT_SET_PAGE_PARAM(tc_id); \
+		if (ret) \
+			break; \
+	} \
+	if (!ret) \
+		_page++; \
+	ret; \
+})
+
+static inline int
+dpaa2_xstats_id_parse(uint32_t id, uint8_t *page,
+	uint8_t *stat_id, uint16_t *param, uint16_t *size)
+{
+	uint8_t _page = DPNI_INGRESS_STATISTICS_PAGE_ID, _stat_id = 0;
+	uint16_t _param = 0, _size = 0;
+
+	if (DPAA2_DPNI_STAT_PAGE_PARAM(0))
+		goto found_id;
+	if (DPAA2_DPNI_STAT_PAGE_PARAM(1))
+		goto found_id;
+	if (DPAA2_DPNI_STAT_PAGE_PARAM(2))
+		goto found_id;
+	if (DPAA2_DPNI_STAT_PAGE_PARAM(3))
+		goto found_id;
+	if (DPAA2_DPNI_STAT_PAGE_PARAM(4))
+		goto found_id;
+	if (DPAA2_DPNI_STAT_POLICER_PAGE_PARAM())
+		goto found_id;
+	if (DPAA2_DPNI_STAT_PAGE_PARAM(6))
+		goto found_id;
+
+	DPAA2_PMD_ERR("ID(%d) was not found in DPNI page statistics", id);
+	return -EINVAL;
+
+found_id:
+	if (page)
+		*page = _page;
+	if (stat_id)
+		*stat_id = _stat_id;
+	if (param)
+		*param = _param;
+	if (size)
+		*size = _size;
+
+	return 0;
+}
+
+/* The field name is used both as a designator and stringified, so it must
+ * appear twice. Only literal member names are ever passed in.
+ */
+#define DPAA2_XSTAT_STR_SET(pg, field) \
+	.pg.field = (uint64_t)RTE_STR(field)
+
+#define DPAA2_XSTAT_TC_STR_SET(pg, tc, field) \
+	.pg[tc].field = (uint64_t)("TC" RTE_STR(tc) "_" RTE_STR(field))
+
+#define MAC_STR(name) ("mac_" #name)
+#define MAC_STR_ADDR(name) ((size_t)MAC_STR(name))
+
+static const struct dpaa2_xstats_seq dpaa2_xstats_strings = {
+	DPAA2_XSTAT_STR_SET(pg0, ingress_all_frames),
+	DPAA2_XSTAT_STR_SET(pg0, ingress_all_bytes),
+	DPAA2_XSTAT_STR_SET(pg0, ingress_multicast_frames),
+	DPAA2_XSTAT_STR_SET(pg0, ingress_multicast_bytes),
+	DPAA2_XSTAT_STR_SET(pg0, ingress_broadcast_frames),
+	DPAA2_XSTAT_STR_SET(pg0, ingress_broadcast_bytes),
+
+	DPAA2_XSTAT_STR_SET(pg1, egress_all_frames),
+	DPAA2_XSTAT_STR_SET(pg1, egress_all_bytes),
+	DPAA2_XSTAT_STR_SET(pg1, egress_multicast_frames),
+	DPAA2_XSTAT_STR_SET(pg1, egress_multicast_bytes),
+	DPAA2_XSTAT_STR_SET(pg1, egress_broadcast_frames),
+	DPAA2_XSTAT_STR_SET(pg1, egress_broadcast_bytes),
+
+	DPAA2_XSTAT_STR_SET(pg2, ingress_filtered_frames),
+	DPAA2_XSTAT_STR_SET(pg2, ingress_discarded_frames),
+	DPAA2_XSTAT_STR_SET(pg2, ingress_nobuffer_discards),
+	DPAA2_XSTAT_STR_SET(pg2, egress_discarded_frames),
+	DPAA2_XSTAT_STR_SET(pg2, egress_confirmed_frames),
+
+	DPAA2_XSTAT_STR_SET(pg3, ceetm_dequeue_bytes),
+	DPAA2_XSTAT_STR_SET(pg3, ceetm_dequeue_frames),
+	DPAA2_XSTAT_STR_SET(pg3, ceetm_reject_bytes),
+	DPAA2_XSTAT_STR_SET(pg3, ceetm_reject_frames),
+
+	DPAA2_XSTAT_STR_SET(pg4, cgr_reject_frames),
+	DPAA2_XSTAT_STR_SET(pg4, cgr_reject_bytes),
+
+	DPAA2_XSTAT_TC_STR_SET(pg5, 0, policer_cnt_red),
+	DPAA2_XSTAT_TC_STR_SET(pg5, 0, policer_cnt_yellow),
+	DPAA2_XSTAT_TC_STR_SET(pg5, 0, policer_cnt_green),
+	DPAA2_XSTAT_TC_STR_SET(pg5, 0, policer_cnt_re_red),
+	DPAA2_XSTAT_TC_STR_SET(pg5, 0, policer_cnt_re_yellow),
+	DPAA2_XSTAT_TC_STR_SET(pg5, 1, policer_cnt_red),
+	DPAA2_XSTAT_TC_STR_SET(pg5, 1, policer_cnt_yellow),
+	DPAA2_XSTAT_TC_STR_SET(pg5, 1, policer_cnt_green),
+	DPAA2_XSTAT_TC_STR_SET(pg5, 1, policer_cnt_re_red),
+	DPAA2_XSTAT_TC_STR_SET(pg5, 1, policer_cnt_re_yellow),
+	DPAA2_XSTAT_TC_STR_SET(pg5, 2, policer_cnt_red),
+	DPAA2_XSTAT_TC_STR_SET(pg5, 2, policer_cnt_yellow),
+	DPAA2_XSTAT_TC_STR_SET(pg5, 2, policer_cnt_green),
+	DPAA2_XSTAT_TC_STR_SET(pg5, 2, policer_cnt_re_red),
+	DPAA2_XSTAT_TC_STR_SET(pg5, 2, policer_cnt_re_yellow),
+	DPAA2_XSTAT_TC_STR_SET(pg5, 3, policer_cnt_red),
+	DPAA2_XSTAT_TC_STR_SET(pg5, 3, policer_cnt_yellow),
+	DPAA2_XSTAT_TC_STR_SET(pg5, 3, policer_cnt_green),
+	DPAA2_XSTAT_TC_STR_SET(pg5, 3, policer_cnt_re_red),
+	DPAA2_XSTAT_TC_STR_SET(pg5, 3, policer_cnt_re_yellow),
+	DPAA2_XSTAT_TC_STR_SET(pg5, 4, policer_cnt_red),
+	DPAA2_XSTAT_TC_STR_SET(pg5, 4, policer_cnt_yellow),
+	DPAA2_XSTAT_TC_STR_SET(pg5, 4, policer_cnt_green),
+	DPAA2_XSTAT_TC_STR_SET(pg5, 4, policer_cnt_re_red),
+	DPAA2_XSTAT_TC_STR_SET(pg5, 4, policer_cnt_re_yellow),
+	DPAA2_XSTAT_TC_STR_SET(pg5, 5, policer_cnt_red),
+	DPAA2_XSTAT_TC_STR_SET(pg5, 5, policer_cnt_yellow),
+	DPAA2_XSTAT_TC_STR_SET(pg5, 5, policer_cnt_green),
+	DPAA2_XSTAT_TC_STR_SET(pg5, 5, policer_cnt_re_red),
+	DPAA2_XSTAT_TC_STR_SET(pg5, 5, policer_cnt_re_yellow),
+	DPAA2_XSTAT_TC_STR_SET(pg5, 6, policer_cnt_red),
+	DPAA2_XSTAT_TC_STR_SET(pg5, 6, policer_cnt_yellow),
+	DPAA2_XSTAT_TC_STR_SET(pg5, 6, policer_cnt_green),
+	DPAA2_XSTAT_TC_STR_SET(pg5, 6, policer_cnt_re_red),
+	DPAA2_XSTAT_TC_STR_SET(pg5, 6, policer_cnt_re_yellow),
+	DPAA2_XSTAT_TC_STR_SET(pg5, 7, policer_cnt_red),
+	DPAA2_XSTAT_TC_STR_SET(pg5, 7, policer_cnt_yellow),
+	DPAA2_XSTAT_TC_STR_SET(pg5, 7, policer_cnt_green),
+	DPAA2_XSTAT_TC_STR_SET(pg5, 7, policer_cnt_re_red),
+	DPAA2_XSTAT_TC_STR_SET(pg5, 7, policer_cnt_re_yellow),
+
+	DPAA2_XSTAT_STR_SET(pg6, tx_pending_frames_cnt),
+
+	.mac_cnt.rx_64_bytes		= MAC_STR_ADDR(rx_64_bytes),
+	.mac_cnt.rx_65_127_bytes	= MAC_STR_ADDR(rx_65_127_bytes),
+	.mac_cnt.rx_128_255_bytes	= MAC_STR_ADDR(rx_128_255_bytes),
+	.mac_cnt.rx_256_511_bytes	= MAC_STR_ADDR(rx_256_511_bytes),
+	.mac_cnt.rx_512_1023_bytes	= MAC_STR_ADDR(rx_512_1023_bytes),
+	.mac_cnt.rx_1024_1518_bytes	= MAC_STR_ADDR(rx_1024_1518_bytes),
+	.mac_cnt.rx_1519_max_bytes	= MAC_STR_ADDR(rx_1519_max_bytes),
+
+	.mac_cnt.rx_fragments		= MAC_STR_ADDR(rx_fragments),
+	.mac_cnt.rx_jabber			= MAC_STR_ADDR(rx_jabber),
+	.mac_cnt.rx_drop_fifo		= MAC_STR_ADDR(rx_drop_fifo),
+	.mac_cnt.rx_alignment_error	= MAC_STR_ADDR(rx_alignment_error),
+
+	.mac_cnt.tx_undersize_good	= MAC_STR_ADDR(tx_undersize_good),
+	.mac_cnt.rx_oversize_good	= MAC_STR_ADDR(rx_oversize_good),
+
+	.mac_cnt.rx_pause			= MAC_STR_ADDR(rx_pause),
+	.mac_cnt.tx_pause			= MAC_STR_ADDR(tx_pause),
+
+	.mac_cnt.rx_good_bytes		= MAC_STR_ADDR(rx_good_bytes),
+	.mac_cnt.rx_multicast		= MAC_STR_ADDR(rx_multicast),
+	.mac_cnt.rx_broadcast		= MAC_STR_ADDR(rx_broadcast),
+	.mac_cnt.rx_all_frames		= MAC_STR_ADDR(rx_all_frames),
+	.mac_cnt.rx_unicast			= MAC_STR_ADDR(rx_unicast),
+	.mac_cnt.rx_error			= MAC_STR_ADDR(rx_error),
+
+	.mac_cnt.tx_good_bytes		= MAC_STR_ADDR(tx_good_bytes),
+	.mac_cnt.tx_multicast		= MAC_STR_ADDR(tx_multicast),
+	.mac_cnt.tx_broadcast		= MAC_STR_ADDR(tx_broadcast),
+	.mac_cnt.tx_unicast			= MAC_STR_ADDR(tx_unicast),
+	.mac_cnt.tx_error			= MAC_STR_ADDR(tx_error),
+
+	.mac_cnt.rx_valid_frames	= MAC_STR_ADDR(rx_valid_frames),
+	.mac_cnt.tx_valid_frames	= MAC_STR_ADDR(tx_valid_frames),
+
+	.mac_cnt.tx_64_bytes		= MAC_STR_ADDR(tx_64_bytes),
+	.mac_cnt.tx_65_127_bytes	= MAC_STR_ADDR(tx_65_127_bytes),
+	.mac_cnt.tx_128_255_bytes	= MAC_STR_ADDR(tx_128_255_bytes),
+	.mac_cnt.tx_256_511_bytes	= MAC_STR_ADDR(tx_256_511_bytes),
+	.mac_cnt.tx_512_1023_bytes	= MAC_STR_ADDR(tx_512_1023_bytes),
+	.mac_cnt.tx_1024_1518_bytes	= MAC_STR_ADDR(tx_1024_1518_bytes),
+	.mac_cnt.tx_1519_max_bytes	= MAC_STR_ADDR(tx_1519_max_bytes),
+
+	.mac_cnt.rx_bytes_all		= MAC_STR_ADDR(rx_bytes_all),
+	.mac_cnt.rx_crc_error		= MAC_STR_ADDR(rx_crc_error),
+	.mac_cnt.rx_vlan			= MAC_STR_ADDR(rx_vlan),
+	.mac_cnt.rx_undersize_good	= MAC_STR_ADDR(rx_undersize_good),
+	.mac_cnt.rx_ctrl_non_pause	= MAC_STR_ADDR(rx_ctrl_non_pause),
+	.mac_cnt.rx_drop_full		= MAC_STR_ADDR(rx_drop_full),
+
+	.mac_cnt.tx_bytes_all		= MAC_STR_ADDR(tx_bytes_all),
+	.mac_cnt.tx_crc_error		= MAC_STR_ADDR(tx_crc_error),
+	.mac_cnt.tx_vlan			= MAC_STR_ADDR(tx_vlan),
+	.mac_cnt.tx_all_frames		= MAC_STR_ADDR(tx_all_frames),
+	.mac_cnt.tx_ctrl_non_pause	= MAC_STR_ADDR(tx_ctrl_non_pause),
+
+	.mac_cnt.rx_pfc_class[0]	= MAC_STR_ADDR(rx_pfc_class_0),
+	.mac_cnt.rx_pfc_class[1]	= MAC_STR_ADDR(rx_pfc_class_1),
+	.mac_cnt.rx_pfc_class[2]	= MAC_STR_ADDR(rx_pfc_class_2),
+	.mac_cnt.rx_pfc_class[3]	= MAC_STR_ADDR(rx_pfc_class_3),
+	.mac_cnt.rx_pfc_class[4]	= MAC_STR_ADDR(rx_pfc_class_4),
+	.mac_cnt.rx_pfc_class[5]	= MAC_STR_ADDR(rx_pfc_class_5),
+	.mac_cnt.rx_pfc_class[6]	= MAC_STR_ADDR(rx_pfc_class_6),
+	.mac_cnt.rx_pfc_class[7]	= MAC_STR_ADDR(rx_pfc_class_7),
+
+	.mac_cnt.tx_pfc_class[0]	= MAC_STR_ADDR(tx_pfc_class_0),
+	.mac_cnt.tx_pfc_class[1]	= MAC_STR_ADDR(tx_pfc_class_1),
+	.mac_cnt.tx_pfc_class[2]	= MAC_STR_ADDR(tx_pfc_class_2),
+	.mac_cnt.tx_pfc_class[3]	= MAC_STR_ADDR(tx_pfc_class_3),
+	.mac_cnt.tx_pfc_class[4]	= MAC_STR_ADDR(tx_pfc_class_4),
+	.mac_cnt.tx_pfc_class[5]	= MAC_STR_ADDR(tx_pfc_class_5),
+	.mac_cnt.tx_pfc_class[6]	= MAC_STR_ADDR(tx_pfc_class_6),
+	.mac_cnt.tx_pfc_class[7]	= MAC_STR_ADDR(tx_pfc_class_7)
+};
+
+#define DPAA2_DPNI_XSTAT_FIELD_ID(field) \
+	(offsetof(struct dpaa2_xstats_seq, field) / sizeof(uint64_t))
+
+static const struct rte_eth_stats dpaa2_stats_xstat_ids = {
+	.ipackets = DPAA2_DPNI_XSTAT_FIELD_ID(pg0.ingress_all_frames),
+	.opackets = DPAA2_DPNI_XSTAT_FIELD_ID(pg1.egress_all_frames),
+	.ibytes = DPAA2_DPNI_XSTAT_FIELD_ID(pg0.ingress_all_bytes),
+	.obytes = DPAA2_DPNI_XSTAT_FIELD_ID(pg1.egress_all_bytes),
+	.imissed = DPAA2_DPNI_XSTAT_FIELD_ID(pg2.ingress_filtered_frames),
+	.ierrors = DPAA2_DPNI_XSTAT_FIELD_ID(pg2.ingress_discarded_frames),
+	.oerrors = DPAA2_DPNI_XSTAT_FIELD_ID(pg2.egress_discarded_frames),
+	.rx_nombuf = DPAA2_DPNI_XSTAT_FIELD_ID(pg2.ingress_nobuffer_discards)
 };
 
+#define DPAA2_STATS_XSTATS_NUM \
+	(sizeof(dpaa2_stats_xstat_ids) / sizeof(uint64_t))
+
+#define DPAA2_MAC_XSTATS_START_ID DPAA2_DPNI_XSTAT_MAX_NUM
+
+
 static struct rte_dpaa2_driver rte_dpaa2_pmd;
 static int dpaa2_dev_link_update(struct rte_eth_dev *dev,
 				 int wait_to_complete);
@@ -1892,127 +2064,47 @@ dpaa2_dev_set_mac_addr(struct rte_eth_dev *dev,
 }
 
 static int
-dpaa2_dev_stats_get(struct rte_eth_dev *dev,
-	struct rte_eth_stats *stats, struct eth_queue_stats *qstats)
+dpaa2_dev_xstat_mac_setup_mem(struct rte_eth_dev *dev)
 {
 	struct dpaa2_dev_priv *priv = dev->data->dev_private;
-	struct fsl_mc_io *dpni = dev->process_private;
-	int32_t retcode;
-	uint8_t page0 = 0, page1 = 1, page2 = 2;
-	union dpni_statistics value;
-	int i;
-	struct dpaa2_queue *dpaa2_rxq, *dpaa2_txq;
-
-	memset(&value, 0, sizeof(union dpni_statistics));
-
-	PMD_INIT_FUNC_TRACE();
-
-	if (!dpni) {
-		DPAA2_PMD_ERR("dpni is NULL");
-		return -EINVAL;
-	}
-
-	if (!stats) {
-		DPAA2_PMD_ERR("stats is NULL");
-		return -EINVAL;
-	}
-
-	/*Get Counters from page_0*/
-	retcode = dpni_get_statistics(dpni, CMD_PRI_LOW, priv->token,
-				      page0, 0, &value);
-	if (retcode)
-		goto err;
-
-	stats->ipackets = value.page_0.ingress_all_frames;
-	stats->ibytes = value.page_0.ingress_all_bytes;
-
-	/*Get Counters from page_1*/
-	retcode = dpni_get_statistics(dpni, CMD_PRI_LOW, priv->token,
-				      page1, 0, &value);
-	if (retcode)
-		goto err;
-
-	stats->opackets = value.page_1.egress_all_frames;
-	stats->obytes = value.page_1.egress_all_bytes;
-
-	/*Get Counters from page_2*/
-	retcode = dpni_get_statistics(dpni, CMD_PRI_LOW, priv->token,
-				      page2, 0, &value);
-	if (retcode)
-		goto err;
-
-	/* Ingress drop frame count due to configured rules */
-	stats->ierrors = value.page_2.ingress_filtered_frames;
-	/* Ingress drop frame count due to error */
-	stats->ierrors += value.page_2.ingress_discarded_frames;
-
-	stats->oerrors = value.page_2.egress_discarded_frames;
-	stats->imissed = value.page_2.ingress_nobuffer_discards;
-
-	/* Fill in per queue stats */
-	if (qstats != NULL) {
-		for (i = 0; (i < RTE_ETHDEV_QUEUE_STAT_CNTRS) &&
-			(i < priv->nb_rx_queues || i < priv->nb_tx_queues); ++i) {
-			dpaa2_rxq = priv->rx_vq[i];
-			dpaa2_txq = priv->tx_vq[i];
-			if (dpaa2_rxq)
-				qstats->q_ipackets[i] = dpaa2_rxq->rx_pkts;
-			if (dpaa2_txq)
-				qstats->q_opackets[i] = dpaa2_txq->tx_pkts;
+	int ret = 0;
 
-			/* Byte counting is not implemented */
-			qstats->q_ibytes[i]   = 0;
-			qstats->q_obytes[i]   = 0;
+	if (!priv->cnt_idx_dma_mem) {
+		priv->cnt_idx_dma_mem = rte_zmalloc(NULL,
+			DPAA2_MAC_STATS_INDEX_DMA_SIZE, RTE_CACHE_LINE_SIZE);
+		if (!priv->cnt_idx_dma_mem) {
+			ret = -ENOMEM;
+			DPAA2_PMD_ERR("Failure to allocate memory for mac index");
+			goto out;
 		}
-	}
-
-	return 0;
-
-err:
-	DPAA2_PMD_ERR("Operation not completed:Error Code = %d", retcode);
-	return retcode;
-};
-
-void
-dpaa2_dev_mac_setup_stats(struct rte_eth_dev *dev)
-{
-	struct dpaa2_dev_priv *priv = dev->data->dev_private;
-	uint32_t *cnt_idx;
-	int i;
 
-	priv->cnt_idx_dma_mem = rte_malloc(NULL, DPAA2_MAC_STATS_INDEX_DMA_SIZE,
-					   RTE_CACHE_LINE_SIZE);
-	if (!priv->cnt_idx_dma_mem) {
-		DPAA2_PMD_ERR("Failure to allocate memory for mac index");
-		goto out;
+		priv->cnt_idx_iova = rte_mem_virt2iova(priv->cnt_idx_dma_mem);
+		if (priv->cnt_idx_iova == RTE_BAD_IOVA) {
+			ret = -ENOBUFS;
+			DPAA2_PMD_ERR("%s: No IOMMU map for count index dma mem(%p)",
+				__func__, priv->cnt_idx_dma_mem);
+			goto err_dma_map;
+		}
 	}
 
-	priv->cnt_values_dma_mem = rte_malloc(NULL, DPAA2_MAC_STATS_VALUE_DMA_SIZE,
-					      RTE_CACHE_LINE_SIZE);
 	if (!priv->cnt_values_dma_mem) {
-		DPAA2_PMD_ERR("Failure to allocate memory for mac values");
-		goto err_alloc_values;
-	}
-
-	cnt_idx = priv->cnt_idx_dma_mem;
-	for (i = 0; i < DPAA2_MAC_NUM_STATS; i++)
-		*cnt_idx++ = rte_cpu_to_le_32((uint32_t)i);
-
-	priv->cnt_idx_iova = rte_mem_virt2iova(priv->cnt_idx_dma_mem);
-	if (priv->cnt_idx_iova == RTE_BAD_IOVA) {
-		DPAA2_PMD_ERR("%s: No IOMMU map for count index dma mem(%p)",
-			__func__, priv->cnt_idx_dma_mem);
-		goto err_dma_map;
-	}
-
-	priv->cnt_values_iova = rte_mem_virt2iova(priv->cnt_values_dma_mem);
-	if (priv->cnt_values_iova == RTE_BAD_IOVA) {
-		DPAA2_PMD_ERR("%s: No IOMMU map for count values dma mem(%p)",
-			__func__, priv->cnt_values_dma_mem);
-		goto err_dma_map;
+		priv->cnt_values_dma_mem = rte_zmalloc(NULL,
+			DPAA2_MAC_STATS_VALUE_DMA_SIZE, RTE_CACHE_LINE_SIZE);
+		if (!priv->cnt_values_dma_mem) {
+			ret = -ENOMEM;
+			DPAA2_PMD_ERR("Failure to allocate memory for mac values");
+			goto err_alloc_values;
+		}
+		priv->cnt_values_iova = rte_mem_virt2iova(priv->cnt_values_dma_mem);
+		if (priv->cnt_values_iova == RTE_BAD_IOVA) {
+			ret = -ENOBUFS;
+			DPAA2_PMD_ERR("%s: No IOMMU map for count values dma mem(%p)",
+				__func__, priv->cnt_values_dma_mem);
+			goto err_dma_map;
+		}
 	}
 
-	return;
+	return 0;
 
 err_dma_map:
 	rte_free(priv->cnt_values_dma_mem);
@@ -2021,224 +2113,281 @@ dpaa2_dev_mac_setup_stats(struct rte_eth_dev *dev)
 out:
 	priv->cnt_idx_dma_mem = NULL;
 	priv->cnt_values_dma_mem = NULL;
+
+	return ret;
 }
 
-/*
- * dpaa2_dev_xstats_get(): Get counters of dpni and dpmac.
- * MAC (mac_*) counters are supported on MC version > 10.39.0
- * TC_x_policer_* counters are supported only when Policer is enable.
- */
 static int
-dpaa2_dev_xstats_get(struct rte_eth_dev *dev,
-	struct rte_eth_xstat *xstats, unsigned int n)
+dpaa2_dev_mac_xstats_avail(struct rte_eth_dev *dev)
 {
-	struct fsl_mc_io *dpni = (struct fsl_mc_io *)dev->process_private;
-	unsigned int i = 0, j = 0, num = RTE_DIM(dpaa2_xstats_strings);
 	struct dpaa2_dev_priv *priv = dev->data->dev_private;
-	union dpni_statistics value[13] = {};
-	struct dpni_rx_tc_policing_cfg cfg;
-	uint8_t page_id, stats_id;
-	uint64_t *cnt_values;
-	int32_t retcode;
-	int16_t tc;
-
-	if (n < num)
-		return num;
+	uint64_t rev_mac_support;
 
-	if (!xstats)
-		return 0;
 
-	/* Get Counters from page_0*/
-	retcode = dpni_get_statistics(dpni, CMD_PRI_LOW, priv->token,
-				      0, 0, &value[0]);
-	if (retcode)
-		goto err;
-
-	/* Get Counters from page_1*/
-	retcode = dpni_get_statistics(dpni, CMD_PRI_LOW, priv->token,
-				      1, 0, &value[1]);
-	if (retcode)
-		goto err;
-
-	/* Get Counters from page_2*/
-	retcode = dpni_get_statistics(dpni, CMD_PRI_LOW, priv->token,
-				      2, 0, &value[2]);
-	if (retcode)
-		goto err;
-
-	for (j = 0; j < priv->max_cgs; j++) {
-		if (!priv->cgid_in_use[j]) {
-			/* Get Counters from page_4*/
-			retcode = dpni_get_statistics(dpni, CMD_PRI_LOW,
-						      priv->token,
-						      4, 0, &value[4]);
-			if (retcode)
-				goto err;
-			break;
-		}
-	}
+	if (priv->ep_dev_type != DPAA2_MAC)
+		return false;
 
-	for (tc = 0; tc < priv->num_rx_tc; tc++) {
-		retcode = dpni_get_rx_tc_policing(dpni, CMD_PRI_LOW,
-						  priv->token, tc,
-						  &cfg);
-		if (retcode) {
-			DPAA2_PMD_ERR("Error to get the policer rule: %d", retcode);
-			goto err;
-		}
+	rev_mac_support = RTE_FSL_MC_REV(MC_VER_MAJOR, MC_VER_MINOR, 0);
+	if (priv->mc_rev >= rev_mac_support)
+		return true;
 
-		/* get policer stats if policer is enabled */
-		if (cfg.mode != 0) {
-			/* Get Counters from page_5*/
-			retcode = dpni_get_statistics(dpni, CMD_PRI_LOW,
-						      priv->token, 5, tc,
-						      &value[(tc + 5)]);
-			if (retcode)
-				goto err;
-		}
-	}
+	return false;
+}
 
-	while (i < (num - DPAA2_MAC_NUM_STATS)) {
-		xstats[i].id = i;
-		page_id = dpaa2_xstats_strings[i].page_id;
-		stats_id = dpaa2_xstats_strings[i].stats_id;
-		xstats[i].value = value[page_id].raw.counter[stats_id];
-		i++;
-	}
+static int
+dpaa2_dev_dpni_xstats_avail(struct rte_eth_dev *dev,
+	uint8_t page_id, uint16_t param)
+{
+	struct dpaa2_dev_priv *priv = dev->data->dev_private;
+	uint8_t tc, i;
 
-	if (priv->cnt_idx_dma_mem &&
-	    !dpni_get_mac_statistics(dpni, CMD_PRI_LOW, priv->token,
-				    priv->cnt_idx_iova,
-				    priv->cnt_values_iova,
-				    DPAA2_MAC_NUM_STATS)) {
-		cnt_values = priv->cnt_values_dma_mem;
-		while (i >= (num - DPAA2_MAC_NUM_STATS) && i < num) {
-			xstats[i].id = i;
-			xstats[i].value = rte_le_to_cpu_64(*cnt_values++);
-			i++;
+	if (page_id == DPNI_CGR_STATISTICS_PAGE_ID) {
+		for (i = 0; i < priv->max_cgs; i++) {
+			if (priv->cgid_in_use[i])
+				return true;
 		}
-		return i;
-	}
-
-	while (i >= (num - DPAA2_MAC_NUM_STATS) && i < num) {
-		xstats[i].id = i;
-		xstats[i].value = 0;
-		i++;
+	} else if (page_id == DPNI_POLICER_STATISTICS_PAGE_ID) {
+		tc = param;
+		if (tc < MAX_TCS)
+			return true;
+	} else {
+		return true;
 	}
 
-	return i;
-err:
-	DPAA2_PMD_ERR("Error in obtaining extended stats (%d)", retcode);
-	return retcode;
+	return false;
 }
 
 static int
-dpaa2_xstats_get_names(__rte_unused struct rte_eth_dev *dev,
-	struct rte_eth_xstat_name *xstats_names,
-	unsigned int limit)
+dpaa2_dev_xstats_get_names(struct rte_eth_dev *dev,
+	struct rte_eth_xstat_name *xstats_names, uint32_t limit)
 {
-	unsigned int i, stat_cnt = RTE_DIM(dpaa2_xstats_strings);
+	uint16_t i, stat_cnt;
+	uint64_t xstat_str[DPAA2_XSTAT_MAX_NUM];
+
+	stat_cnt = DPAA2_DPNI_XSTAT_MAX_NUM;
+	if (dpaa2_dev_mac_xstats_avail(dev))
+		stat_cnt += DPAA2_MAC_XSTAT_MAX_NUM;
+
+	if (!limit)
+		return stat_cnt;
 
 	if (limit < stat_cnt)
+		stat_cnt = limit;
+
+	if (!xstats_names)
 		return stat_cnt;
 
-	if (xstats_names != NULL)
-		for (i = 0; i < stat_cnt; i++)
-			strlcpy(xstats_names[i].name,
-				dpaa2_xstats_strings[i].name,
-				sizeof(xstats_names[i].name));
+	rte_memcpy(xstat_str, &dpaa2_xstats_strings, sizeof(xstat_str));
+
+	for (i = 0; i < stat_cnt; i++)
+		rte_strscpy(xstats_names[i].name, (char *)xstat_str[i], RTE_ETH_XSTATS_NAME_SIZE);
 
 	return stat_cnt;
 }
 
 static int
-dpaa2_xstats_get_by_id(struct rte_eth_dev *dev, const uint64_t *ids,
-	uint64_t *values, unsigned int n)
+dpaa2_dev_xstats_get_by_id(struct rte_eth_dev *dev, const uint64_t *ids,
+	uint64_t *values, uint32_t n)
 {
-	unsigned int i, stat_cnt = RTE_DIM(dpaa2_xstats_strings);
-	uint64_t values_copy[stat_cnt];
-	uint8_t page_id, stats_id;
-
-	if (!ids) {
-		struct dpaa2_dev_priv *priv = dev->data->dev_private;
-		struct fsl_mc_io *dpni = dev->process_private;
-		int32_t retcode;
-		union dpni_statistics value[5] = {};
-
-		if (n < stat_cnt)
-			return stat_cnt;
-
-		if (!values)
-			return 0;
+	uint16_t i, id, stat_cnt, mac_num = 0;
+	uint8_t page_id, stat_id;
+	uint16_t param;
+	struct dpaa2_dev_priv *priv = dev->data->dev_private;
+	struct fsl_mc_io *dpni = dev->process_private;
+	bool page_fetched[DPNI_MAX_STATISTICS_PAGE_ID][DPNI_STAT_MAX_PARAM];
+	/* Fetch required MAC counters in a single MC command. */
+	int retcode;
+	uint32_t *mac_idx;
+	uint64_t *mac_val[DPAA2_MAC_XSTAT_MAX_NUM];
 
-		/* Get Counters from page_0*/
-		retcode = dpni_get_statistics(dpni, CMD_PRI_LOW, priv->token,
-					      0, 0, &value[0]);
-		if (retcode)
-			return 0;
+	retcode = dpaa2_dev_xstat_mac_setup_mem(dev);
+	if (retcode) {
+		DPAA2_PMD_ERR("%s: Failed(%d) to setup %s's MAC statistics!",
+			__func__, retcode, dev->data->name);
+		return retcode;
+	}
+	mac_idx = priv->cnt_idx_dma_mem;
 
-		/* Get Counters from page_1*/
-		retcode = dpni_get_statistics(dpni, CMD_PRI_LOW, priv->token,
-					      1, 0, &value[1]);
-		if (retcode)
-			return 0;
+	stat_cnt = DPAA2_DPNI_XSTAT_MAX_NUM;
+	if (dpaa2_dev_mac_xstats_avail(dev))
+		stat_cnt += DPAA2_MAC_XSTAT_MAX_NUM;
 
-		/* Get Counters from page_2*/
-		retcode = dpni_get_statistics(dpni, CMD_PRI_LOW, priv->token,
-					      2, 0, &value[2]);
-		if (retcode)
-			return 0;
+	memset(page_fetched, 0, sizeof(page_fetched));
 
-		/* Get Counters from page_4*/
-		retcode = dpni_get_statistics(dpni, CMD_PRI_LOW, priv->token,
-					      4, 0, &value[4]);
+	for (i = 0; i < n; i++) {
+		if (ids && ids[i] >= stat_cnt) {
+			DPAA2_PMD_ERR("xstats id value isn't valid");
+			return -EINVAL;
+		}
+		id = ids ? ids[i] : i;
+		if (id >= DPAA2_MAC_XSTATS_START_ID) {
+			values[i] = 0;
+			if (dpaa2_dev_mac_xstats_avail(dev)) {
+				mac_idx[mac_num] = rte_cpu_to_le_32(id - DPAA2_MAC_XSTATS_START_ID);
+				mac_val[mac_num] = &values[i];
+				mac_num++;
+			}
+			continue;
+		}
+		page_id = 0;
+		stat_id = 0;
+		param = 0;
+		retcode = dpaa2_xstats_id_parse(id, &page_id, &stat_id, &param, NULL);
 		if (retcode)
-			return 0;
-
-		for (i = 0; i < stat_cnt; i++) {
-			page_id = dpaa2_xstats_strings[i].page_id;
-			stats_id = dpaa2_xstats_strings[i].stats_id;
-			values[i] = value[page_id].raw.counter[stats_id];
+			return retcode;
+		if (!dpaa2_dev_dpni_xstats_avail(dev, page_id, param)) {
+			values[i] = 0;
+			continue;
 		}
-		return stat_cnt;
+		if (page_fetched[page_id][param]) {
+			values[i] = priv->pg_xstats[page_id][param].raw.counter[stat_id];
+			continue;
+		}
+		/* Cache dpni page results: multiple xstats can share
+		 * the same (page_id, param), so only fetch each pair once.
+		 */
+		retcode = dpni_get_statistics(dpni, CMD_PRI_LOW,
+				priv->token, page_id, param,
+				&priv->pg_xstats[page_id][param]);
+		if (retcode) {
+			DPAA2_PMD_ERR("%s: Failed(%d) to get %s's statistcis of page%d!",
+				__func__, retcode, dev->data->name, page_id);
+			return retcode;
+		}
+		page_fetched[page_id][param] = true;
+		values[i] = priv->pg_xstats[page_id][param].raw.counter[stat_id];
 	}
 
-	dpaa2_xstats_get_by_id(dev, NULL, values_copy, stat_cnt);
-
-	for (i = 0; i < n; i++) {
-		if (ids[i] >= stat_cnt) {
-			DPAA2_PMD_ERR("xstats id value isn't valid");
-			return -EINVAL;
+	if (mac_num > 0) {
+		retcode = dpni_get_mac_statistics(dpni, CMD_PRI_LOW,
+			priv->token, priv->cnt_idx_iova,
+			priv->cnt_values_iova, mac_num);
+		if (retcode) {
+			DPAA2_PMD_ERR("%s: Failed(%d) to get %s's %d MAC statistics!",
+				__func__, retcode, dev->data->name, mac_num);
+			return retcode;
 		}
-		values[i] = values_copy[ids[i]];
+		for (i = 0; i < mac_num; i++)
+			*mac_val[i] = priv->cnt_values_dma_mem[i];
 	}
+
 	return n;
 }
 
 static int
-dpaa2_xstats_get_names_by_id(struct rte_eth_dev *dev,
-	const uint64_t *ids,
-	struct rte_eth_xstat_name *xstats_names,
-	unsigned int limit)
+dpaa2_dev_xstats_get_names_by_id(struct rte_eth_dev *dev,
+	const uint64_t *ids, struct rte_eth_xstat_name *xstats_names,
+	uint32_t limit)
 {
-	unsigned int i, stat_cnt = RTE_DIM(dpaa2_xstats_strings);
-	struct rte_eth_xstat_name xstats_names_copy[stat_cnt];
+	uint16_t i, stat_cnt;
+	uint64_t xstat_str[DPAA2_XSTAT_MAX_NUM];
+
+	stat_cnt = DPAA2_DPNI_XSTAT_MAX_NUM;
+	if (dpaa2_dev_mac_xstats_avail(dev))
+		stat_cnt += DPAA2_MAC_XSTAT_MAX_NUM;
 
 	if (!ids)
-		return dpaa2_xstats_get_names(dev, xstats_names, limit);
+		return dpaa2_dev_xstats_get_names(dev, xstats_names, limit);
 
-	dpaa2_xstats_get_names(dev, xstats_names_copy, limit);
+	rte_memcpy(xstat_str, &dpaa2_xstats_strings, sizeof(xstat_str));
 
 	for (i = 0; i < limit; i++) {
 		if (ids[i] >= stat_cnt) {
-			DPAA2_PMD_ERR("xstats id value isn't valid");
-			return -1;
+			DPAA2_PMD_ERR("xstats id[%d] value(%" PRIu64 ") >= max count(%d)",
+				i, ids[i], stat_cnt);
+			return -EINVAL;
 		}
-		strcpy(xstats_names[i].name, xstats_names_copy[ids[i]].name);
+		rte_strscpy(xstats_names[i].name,
+			(char *)xstat_str[ids[i]], RTE_ETH_XSTATS_NAME_SIZE);
 	}
 	return limit;
 }
 
+/*
+ * dpaa2_dev_xstats_get(): Get counters of dpni and dpmac.
+ * MAC (mac_*) counters are supported on MC version > 10.39.0
+ * TC_x_policer_* counters are supported only when Policer is enable.
+ */
+static int
+dpaa2_dev_xstats_get(struct rte_eth_dev *dev,
+	struct rte_eth_xstat *xstats, uint32_t n)
+{
+	int retcode;
+	uint32_t i;
+	uint64_t ids[DPAA2_XSTAT_MAX_NUM], vals[DPAA2_XSTAT_MAX_NUM];
+
+	if (!xstats || !n)
+		return 0;
+
+	if (n > DPAA2_XSTAT_MAX_NUM) {
+		DPAA2_PMD_WARN("%s: Expected xstat number(%d) > max(%zu)",
+			__func__, n, (size_t)DPAA2_XSTAT_MAX_NUM);
+		n = DPAA2_XSTAT_MAX_NUM;
+	}
+	for (i = 0; i < n; i++) {
+		ids[i] = i;
+		xstats[i].id = i;
+		xstats[i].value = 0;
+	}
+
+	retcode = dpaa2_dev_xstats_get_by_id(dev, ids, vals, n);
+	if (retcode < 0)
+		return retcode;
+
+	for (i = 0; i < (uint32_t)retcode; i++)
+		xstats[i].value = vals[i];
+
+	return retcode;
+}
+
+static int
+dpaa2_dev_stats_get(struct rte_eth_dev *dev,
+	struct rte_eth_stats *stats, struct eth_queue_stats *qstats)
+{
+	struct dpaa2_dev_priv *priv = dev->data->dev_private;
+	int32_t retcode;
+	uint16_t i, num;
+	uint64_t ids[DPAA2_STATS_XSTATS_NUM], counts[DPAA2_STATS_XSTATS_NUM] = {0};
+	struct dpaa2_queue *dpaa2_q;
+
+	PMD_INIT_FUNC_TRACE();
+
+	rte_memcpy(ids, &dpaa2_stats_xstat_ids, sizeof(dpaa2_stats_xstat_ids));
+	retcode = dpaa2_dev_xstats_get_by_id(dev, ids, counts, DPAA2_STATS_XSTATS_NUM);
+	if (retcode != RTE_DIM(ids)) {
+		DPAA2_PMD_ERR("%s: Failed to get xstats (%d)counters by %zu IDs",
+			__func__, retcode, (size_t)DPAA2_STATS_XSTATS_NUM);
+		if (retcode >= 0)
+			retcode = -EINVAL;
+		return retcode;
+	}
+
+	rte_memcpy(stats, counts, sizeof(struct rte_eth_stats));
+	stats->imissed += stats->ierrors + stats->rx_nombuf;
+
+	if (qstats) {
+		/* Fill in per queue stats */
+		num = RTE_MIN(priv->nb_rx_queues, RTE_ETHDEV_QUEUE_STAT_CNTRS);
+		for (i = 0; i < num; i++) {
+			dpaa2_q = priv->rx_vq[i];
+			qstats->q_ipackets[i] = dpaa2_q->rx_pkts;
+
+			/* Byte counting is not implemented */
+			qstats->q_ibytes[i] = 0;
+		}
+		num = RTE_MIN(priv->nb_tx_queues, RTE_ETHDEV_QUEUE_STAT_CNTRS);
+		for (i = 0; i < num; i++) {
+			dpaa2_q = priv->tx_vq[i];
+			qstats->q_opackets[i] = dpaa2_q->tx_pkts;
+
+			/* Byte counting is not implemented */
+			qstats->q_obytes[i] = 0;
+		}
+	}
+
+	return 0;
+}
+
 static int
 dpaa2_dev_stats_reset(struct rte_eth_dev *dev)
 {
@@ -2255,7 +2404,7 @@ dpaa2_dev_stats_reset(struct rte_eth_dev *dev)
 		return -EINVAL;
 	}
 
-	retcode =  dpni_reset_statistics(dpni, CMD_PRI_LOW, priv->token);
+	retcode = dpni_reset_statistics(dpni, CMD_PRI_LOW, priv->token);
 	if (retcode)
 		goto error;
 
@@ -3262,9 +3411,9 @@ static struct eth_dev_ops dpaa2_ethdev_ops = {
 	.link_update	   = dpaa2_dev_link_update,
 	.stats_get	       = dpaa2_dev_stats_get,
 	.xstats_get	       = dpaa2_dev_xstats_get,
-	.xstats_get_by_id     = dpaa2_xstats_get_by_id,
-	.xstats_get_names_by_id = dpaa2_xstats_get_names_by_id,
-	.xstats_get_names      = dpaa2_xstats_get_names,
+	.xstats_get_by_id     = dpaa2_dev_xstats_get_by_id,
+	.xstats_get_names_by_id = dpaa2_dev_xstats_get_names_by_id,
+	.xstats_get_names      = dpaa2_dev_xstats_get_names,
 	.stats_reset	   = dpaa2_dev_stats_reset,
 	.xstats_reset	      = dpaa2_dev_stats_reset,
 	.fw_version_get	   = dpaa2_fw_version_get,
@@ -3719,17 +3868,6 @@ dpaa2_dev_init(struct rte_eth_dev *eth_dev)
 
 	priv->speed_capa = dpaa2_dev_get_speed_capability(eth_dev);
 
-	/* mac_statistics supported on MC version > 10.39.0 */
-	{
-		struct mc_version mc_ver_info = {0};
-
-		if (!mc_get_version(dpni_dev, CMD_PRI_LOW, &mc_ver_info) &&
-		    mc_ver_info.major >= MC_VER_MAJOR &&
-		    mc_ver_info.minor >= MC_VER_MINOR &&
-		    mc_ver_info.revision > 0)
-			dpaa2_dev_mac_setup_stats(eth_dev);
-	}
-
 	return 0;
 init_err:
 	dpaa2_dev_close(eth_dev);
drivers/net/dpaa2/dpaa2_ethdev.h +8 -4
index e7490b1e0c..523c420c51 100644
@@ -203,7 +203,8 @@
 	(DPAA2_PKT_TYPE_VLAN_1 | DPAA2_PKT_TYPE_VLAN_2)
 
 /* mac counters */
-#define DPAA2_MAC_NUM_STATS            (DPMAC_CNT_EGR_CONTROL_FRAME + 1)
+#define DPAA2_MAC_NUM_STATS \
+	(sizeof(struct dpni_dpmac_counters) / sizeof(uint64_t))
 #define DPAA2_MAC_STATS_INDEX_DMA_SIZE (DPAA2_MAC_NUM_STATS * sizeof(uint32_t))
 #define DPAA2_MAC_STATS_VALUE_DMA_SIZE (DPAA2_MAC_NUM_STATS * sizeof(uint64_t))
 
@@ -540,6 +541,12 @@ struct dpaa2_dev_priv {
 	uint64_t cnt_idx_iova, cnt_values_iova;
 	uint64_t mc_rev;
 
+	/* Cache one dpni_statistics result per (page_id, param) pair to avoid
+	 * redundant MC commands when multiple xstats share the same page.
+	 * Put it in heap to avoid allocating multi-KB stack in runtime.
+	 */
+	union dpni_statistics pg_xstats[DPNI_MAX_STATISTICS_PAGE_ID][DPNI_STAT_MAX_PARAM];
+
 	struct rte_mempool *tx_sg_pool;
 
 	struct dpaa2_dev_flow *curr;
@@ -703,7 +710,4 @@ dpaa2_eth_sg_fd_to_mbuf(struct dpaa2_dev_priv *priv, const struct qbman_fd *fd);
 int dpaa2_mtr_ops_get(struct rte_eth_dev *dev, void *ops);
 int dpaa2_soft_parser_loaded(void);
 
-void
-dpaa2_dev_mac_setup_stats(struct rte_eth_dev *dev);
-
 #endif /* _DPAA2_ETHDEV_H */
drivers/net/dpaa2/mc/fsl_dpni.h +214 -45

273 lines not on this page · raw message

Signature · 1 line
2.43.0
#38 lore raw

PATCH 37/45 net/dpaa2: rework flow engine

In reply to Prashant Gupta

From: Hemant Agrawal <[email protected]>

Rework the dpaa2 flow engine so that flow rules are programmed through the updated QoS and flow steering (FS) table interface.

The distribution helpers in base/dpaa2_hw_dpni.c are removed and folded into the ethdev and flow code, which removes a layer of indirection and keeps the key extraction, RSS distribution and QoS/FS entry programming together in one place.

---
 drivers/net/dpaa2/base/dpaa2_hw_dpni.c |  546 --
 drivers/net/dpaa2/dpaa2_ethdev.c       |  457 +-
 drivers/net/dpaa2/dpaa2_ethdev.h       |  478 +-
 drivers/net/dpaa2/dpaa2_flow.c         | 6906 ++++++++++++++----------
 drivers/net/dpaa2/meson.build          |    3 +-
 5 files changed, 4719 insertions(+), 3671 deletions(-)
 delete mode 100644 drivers/net/dpaa2/base/dpaa2_hw_dpni.c
drivers/net/dpaa2/base/dpaa2_hw_dpni.c deleted +0 -546
deleted file mode 100644
index fee96b3529..0000000000
@@ -1,546 +0,0 @@
-/* SPDX-License-Identifier: BSD-3-Clause
- *
- *   Copyright (c) 2016 Freescale Semiconductor, Inc. All rights reserved.
- *   Copyright 2016-2021,2023-2025 NXP
- *
- */
-
-#include <time.h>
-#include <net/if.h>
-
-#include <eal_export.h>
-#include <rte_mbuf.h>
-#include <ethdev_driver.h>
-#include <rte_malloc.h>
-#include <rte_memcpy.h>
-#include <rte_string_fns.h>
-#include <rte_cycles.h>
-#include <rte_kvargs.h>
-#include <dev_driver.h>
-
-#include <dpaa2_pmd_logs.h>
-#include <dpaa2_hw_pvt.h>
-#include <dpaa2_hw_mempool.h>
-
-#include "../dpaa2_ethdev.h"
-
-int
-dpaa2_distset_to_dpkg_profile_cfg(
-		uint64_t req_dist_set,
-		struct dpkg_profile_cfg *kg_cfg);
-
-RTE_EXPORT_SYMBOL(rte_pmd_dpaa2_set_custom_hash)
-int
-rte_pmd_dpaa2_set_custom_hash(uint16_t port_id,
-	uint16_t offset, uint8_t size)
-{
-	struct rte_eth_dev *eth_dev = &rte_eth_devices[port_id];
-	struct dpaa2_dev_priv *priv = eth_dev->data->dev_private;
-	struct fsl_mc_io *dpni = priv->hw;
-	struct dpni_rx_tc_dist_cfg tc_cfg;
-	struct dpkg_profile_cfg kg_cfg;
-	void *p_params;
-	int ret, tc_index = 0;
-
-	if (!rte_eth_dev_is_valid_port(port_id)) {
-		DPAA2_PMD_WARN("Invalid port id %u", port_id);
-		return -EINVAL;
-	}
-
-	if (strcmp(eth_dev->device->driver->name,
-			RTE_STR(NET_DPAA2_PMD_DRIVER_NAME))) {
-		DPAA2_PMD_WARN("Not a valid dpaa2 port");
-		return -EINVAL;
-	}
-
-	p_params = rte_zmalloc(NULL,
-		DIST_PARAM_IOVA_SIZE, RTE_CACHE_LINE_SIZE);
-	if (!p_params) {
-		DPAA2_PMD_ERR("Unable to allocate flow-dist parameters");
-		return -ENOMEM;
-	}
-
-	memset(&kg_cfg, 0, sizeof(struct dpkg_profile_cfg));
-	kg_cfg.extracts[0].type = DPKG_EXTRACT_FROM_DATA;
-	kg_cfg.extracts[0].extract.from_data.offset = offset;
-	kg_cfg.extracts[0].extract.from_data.size = size;
-	kg_cfg.extracts[0].num_of_byte_masks = 0;
-	kg_cfg.num_extracts = 1;
-
-	ret = dpkg_prepare_key_cfg(&kg_cfg, p_params);
-	if (ret) {
-		DPAA2_PMD_ERR("Unable to prepare extract parameters");
-		rte_free(p_params);
-		return ret;
-	}
-
-	memset(&tc_cfg, 0, sizeof(struct dpni_rx_tc_dist_cfg));
-	tc_cfg.key_cfg_iova = DPAA2_VADDR_TO_IOVA_AND_CHECK(p_params,
-		DIST_PARAM_IOVA_SIZE);
-	if (tc_cfg.key_cfg_iova == RTE_BAD_IOVA) {
-		DPAA2_PMD_ERR("%s: No IOMMU map for key cfg(%p)",
-			__func__, p_params);
-		rte_free(p_params);
-		return -ENOBUFS;
-	}
-
-	tc_cfg.dist_size = eth_dev->data->nb_rx_queues;
-	tc_cfg.dist_mode = DPNI_DIST_MODE_HASH;
-
-	ret = dpni_set_rx_tc_dist(dpni, CMD_PRI_LOW, priv->token, tc_index,
-			&tc_cfg);
-	rte_free(p_params);
-	if (ret) {
-		DPAA2_PMD_ERR("Set RX TC dist failed(err=%d)", ret);
-		return ret;
-	}
-
-	return 0;
-}
-
-int
-dpaa2_setup_flow_dist(struct rte_eth_dev *eth_dev,
-	uint64_t req_dist_set, int tc_index)
-{
-	struct dpaa2_dev_priv *priv = eth_dev->data->dev_private;
-	int tc_dist_queues;
-
-	/* TC distribution size is set with dist_queues or
-	 * (nb_rx_queues - tc_index*dist_queues) in order of TC priority index.
-	 */
-	tc_dist_queues = eth_dev->data->nb_rx_queues -
-		tc_index * priv->dist_queues;
-	if (tc_dist_queues <= 0) {
-		DPAA2_PMD_INFO("No distribution on TC%d", tc_index);
-		return 0;
-	}
-
-	if (tc_dist_queues > priv->dist_queues)
-		tc_dist_queues = priv->dist_queues;
-
-	return dpaa2_setup_flow_dist_size(eth_dev, req_dist_set,
-					   tc_index, tc_dist_queues);
-}
-
-int
-dpaa2_setup_flow_dist_size(struct rte_eth_dev *eth_dev,
-	uint64_t req_dist_set, int tc_index, uint16_t dist_size)
-{
-	struct dpaa2_dev_priv *priv = eth_dev->data->dev_private;
-	struct fsl_mc_io *dpni = eth_dev->process_private;
-	struct dpni_rx_dist_cfg tc_cfg;
-	struct dpkg_profile_cfg kg_cfg;
-	void *p_params;
-	int ret;
-
-	if (dist_size == 0)
-		return 0;
-
-	p_params = rte_malloc(NULL,
-		DIST_PARAM_IOVA_SIZE, RTE_CACHE_LINE_SIZE);
-	if (!p_params) {
-		DPAA2_PMD_ERR("Unable to allocate flow-dist parameters");
-		return -ENOMEM;
-	}
-
-	memset(p_params, 0, DIST_PARAM_IOVA_SIZE);
-	memset(&tc_cfg, 0, sizeof(struct dpni_rx_dist_cfg));
-
-	ret = dpaa2_distset_to_dpkg_profile_cfg(req_dist_set, &kg_cfg);
-	if (ret) {
-		DPAA2_PMD_ERR("Given RSS Hash (%" PRIx64 ") not supported",
-			      req_dist_set);
-		rte_free(p_params);
-		return ret;
-	}
-
-	tc_cfg.key_cfg_iova = DPAA2_VADDR_TO_IOVA_AND_CHECK(p_params,
-		DIST_PARAM_IOVA_SIZE);
-	if (tc_cfg.key_cfg_iova == RTE_BAD_IOVA) {
-		DPAA2_PMD_ERR("%s: No IOMMU map for key cfg(%p)",
-			__func__, p_params);
-		rte_free(p_params);
-		return -ENOBUFS;
-	}
-
-	tc_cfg.dist_size = dist_size;
-	tc_cfg.enable = true;
-	tc_cfg.tc = tc_index;
-
-	ret = dpkg_prepare_key_cfg(&kg_cfg, p_params);
-	if (ret) {
-		DPAA2_PMD_ERR("Unable to prepare extract parameters");
-		rte_free(p_params);
-		return ret;
-	}
-
-	ret = dpni_set_rx_hash_dist(dpni, CMD_PRI_LOW, priv->token, &tc_cfg);
-	rte_free(p_params);
-	if (ret) {
-		DPAA2_PMD_ERR("RX Hash dist for failed(err=%d)", ret);
-		return ret;
-	}
-
-	if (tc_index < MAX_TCS)
-		priv->dist_size_cur[tc_index] = dist_size;
-
-	return 0;
-}
-
-int
-dpaa2_remove_flow_dist(struct rte_eth_dev *eth_dev,
-	uint8_t tc_index)
-{
-	struct dpaa2_dev_priv *priv = eth_dev->data->dev_private;
-	struct fsl_mc_io *dpni = priv->hw;
-	struct dpni_rx_dist_cfg tc_cfg;
-	struct dpkg_profile_cfg kg_cfg;
-	void *p_params;
-	int ret;
-
-	p_params = rte_malloc(NULL,
-		DIST_PARAM_IOVA_SIZE, RTE_CACHE_LINE_SIZE);
-	if (!p_params) {
-		DPAA2_PMD_ERR("Unable to allocate flow-dist parameters");
-		return -ENOMEM;
-	}
-
-	memset(&tc_cfg, 0, sizeof(struct dpni_rx_dist_cfg));
-	tc_cfg.dist_size = 0;
-	tc_cfg.key_cfg_iova = DPAA2_VADDR_TO_IOVA_AND_CHECK(p_params,
-		DIST_PARAM_IOVA_SIZE);
-	if (tc_cfg.key_cfg_iova == RTE_BAD_IOVA) {
-		DPAA2_PMD_ERR("%s: No IOMMU map for key cfg(%p)",
-			__func__, p_params);
-		rte_free(p_params);
-		return -ENOBUFS;
-	}
-
-	tc_cfg.enable = true;
-	tc_cfg.tc = tc_index;
-
-	memset(p_params, 0, DIST_PARAM_IOVA_SIZE);
-	kg_cfg.num_extracts = 0;
-	ret = dpkg_prepare_key_cfg(&kg_cfg, p_params);
-	if (ret) {
-		DPAA2_PMD_ERR("Unable to prepare extract parameters");
-		rte_free(p_params);
-		return ret;
-	}
-
-	ret = dpni_set_rx_hash_dist(dpni, CMD_PRI_LOW, priv->token,
-			&tc_cfg);
-	rte_free(p_params);
-	if (ret)
-		DPAA2_PMD_ERR("RX hash dist failed(err=%d)", ret);
-	return ret;
-}
-
-int
-dpaa2_distset_to_dpkg_profile_cfg(
-		uint64_t req_dist_set,
-		struct dpkg_profile_cfg *kg_cfg)
-{
-	uint32_t loop = 0, i = 0;
-	uint64_t dist_field = 0;
-	int l2_configured = 0, l3_configured = 0;
-	int l4_configured = 0;
-	int mpls_configured = 0;
-	int vlan_configured = 0;
-	int esp_configured = 0;
-	int ah_configured = 0;
-	int pppoe_configured = 0;
-
-	memset(kg_cfg, 0, sizeof(struct dpkg_profile_cfg));
-	while (req_dist_set) {
-		if (req_dist_set % 2 != 0) {
-			dist_field = 1ULL << loop;
-			switch (dist_field) {
-			case RTE_ETH_RSS_L2_PAYLOAD:
-			case RTE_ETH_RSS_ETH:
-				if (l2_configured)
-					break;
-				l2_configured = 1;
-
-				kg_cfg->extracts[i].extract.from_hdr.prot =
-					NET_PROT_ETH;
-				kg_cfg->extracts[i].extract.from_hdr.field =
-					NH_FLD_ETH_TYPE;
-				kg_cfg->extracts[i].type =
-					DPKG_EXTRACT_FROM_HDR;
-				kg_cfg->extracts[i].extract.from_hdr.type =
-					DPKG_FULL_FIELD;
-				i++;
-				break;
-
-			case RTE_ETH_RSS_PPPOE:
-				if (pppoe_configured)
-					break;
-				pppoe_configured = 1;
-
-				kg_cfg->extracts[i].extract.from_hdr.prot =
-					NET_PROT_PPPOE;
-				kg_cfg->extracts[i].extract.from_hdr.field =
-					NH_FLD_PPPOE_SID;
-				kg_cfg->extracts[i].type =
-					DPKG_EXTRACT_FROM_HDR;
-				kg_cfg->extracts[i].extract.from_hdr.type =
-					DPKG_FULL_FIELD;
-				i++;
-				break;
-
-			case RTE_ETH_RSS_ESP:
-				if (esp_configured)
-					break;
-				esp_configured = 1;
-
-				kg_cfg->extracts[i].extract.from_hdr.prot =
-					NET_PROT_IPSEC_ESP;
-				kg_cfg->extracts[i].extract.from_hdr.field =
-					NH_FLD_IPSEC_ESP_SPI;
-				kg_cfg->extracts[i].type =
-					DPKG_EXTRACT_FROM_HDR;
-				kg_cfg->extracts[i].extract.from_hdr.type =
-					DPKG_FULL_FIELD;
-				i++;
-				break;
-
-			case RTE_ETH_RSS_AH:
-				if (ah_configured)
-					break;
-				ah_configured = 1;
-
-				kg_cfg->extracts[i].extract.from_hdr.prot =
-					NET_PROT_IPSEC_AH;
-				kg_cfg->extracts[i].extract.from_hdr.field =
-					NH_FLD_IPSEC_AH_SPI;
-				kg_cfg->extracts[i].type =
-					DPKG_EXTRACT_FROM_HDR;
-				kg_cfg->extracts[i].extract.from_hdr.type =
-					DPKG_FULL_FIELD;
-				i++;
-				break;
-
-			case RTE_ETH_RSS_C_VLAN:
-			case RTE_ETH_RSS_S_VLAN:
-				if (vlan_configured)
-					break;
-				vlan_configured = 1;
-
-				kg_cfg->extracts[i].extract.from_hdr.prot =
-					NET_PROT_VLAN;
-				kg_cfg->extracts[i].extract.from_hdr.field =
-					NH_FLD_VLAN_TCI;
-				kg_cfg->extracts[i].type =
-					DPKG_EXTRACT_FROM_HDR;
-				kg_cfg->extracts[i].extract.from_hdr.type =
-					DPKG_FULL_FIELD;
-				i++;
-				break;
-
-			case RTE_ETH_RSS_MPLS:
-
-				if (mpls_configured)
-					break;
-				mpls_configured = 1;
-
-				kg_cfg->extracts[i].extract.from_hdr.prot =
-					NET_PROT_MPLS;
-				kg_cfg->extracts[i].extract.from_hdr.field =
-					NH_FLD_MPLS_MPLSL_1;
-				kg_cfg->extracts[i].type =
-					DPKG_EXTRACT_FROM_HDR;
-				kg_cfg->extracts[i].extract.from_hdr.type =
-					DPKG_FULL_FIELD;
-				i++;
-
-				kg_cfg->extracts[i].extract.from_hdr.prot =
-					NET_PROT_MPLS;
-				kg_cfg->extracts[i].extract.from_hdr.field =
-					NH_FLD_MPLS_MPLSL_2;
-				kg_cfg->extracts[i].type =
-					DPKG_EXTRACT_FROM_HDR;
-				kg_cfg->extracts[i].extract.from_hdr.type =
-					DPKG_FULL_FIELD;
-				i++;
-
-				kg_cfg->extracts[i].extract.from_hdr.prot =
-					NET_PROT_MPLS;
-				kg_cfg->extracts[i].extract.from_hdr.field =
-					NH_FLD_MPLS_MPLSL_N;
-				kg_cfg->extracts[i].type =
-					DPKG_EXTRACT_FROM_HDR;
-				kg_cfg->extracts[i].extract.from_hdr.type =
-					DPKG_FULL_FIELD;
-				i++;
-				break;
-
-			case RTE_ETH_RSS_IPV4:
-			case RTE_ETH_RSS_FRAG_IPV4:
-			case RTE_ETH_RSS_NONFRAG_IPV4_OTHER:
-			case RTE_ETH_RSS_IPV6:
-			case RTE_ETH_RSS_FRAG_IPV6:
-			case RTE_ETH_RSS_NONFRAG_IPV6_OTHER:
-			case RTE_ETH_RSS_IPV6_EX:
-
-				if (l3_configured)
-					break;
-				l3_configured = 1;
-
-				kg_cfg->extracts[i].extract.from_hdr.prot =
-					NET_PROT_IP;
-				kg_cfg->extracts[i].extract.from_hdr.field =
-					NH_FLD_IP_SRC;
-				kg_cfg->extracts[i].type =
-					DPKG_EXTRACT_FROM_HDR;
-				kg_cfg->extracts[i].extract.from_hdr.type =
-					DPKG_FULL_FIELD;
-				i++;
-
-				kg_cfg->extracts[i].extract.from_hdr.prot =
-					NET_PROT_IP;
-				kg_cfg->extracts[i].extract.from_hdr.field =
-					NH_FLD_IP_DST;
-				kg_cfg->extracts[i].type =
-					DPKG_EXTRACT_FROM_HDR;
-				kg_cfg->extracts[i].extract.from_hdr.type =
-					DPKG_FULL_FIELD;
-				i++;
-
-				kg_cfg->extracts[i].extract.from_hdr.prot =
-					NET_PROT_IP;
-				kg_cfg->extracts[i].extract.from_hdr.field =
-					NH_FLD_IP_PROTO;
-				kg_cfg->extracts[i].type =
-					DPKG_EXTRACT_FROM_HDR;
-				kg_cfg->extracts[i].extract.from_hdr.type =
-					DPKG_FULL_FIELD;
-				i++;
-			break;
-
-			case RTE_ETH_RSS_NONFRAG_IPV4_TCP:
-			case RTE_ETH_RSS_NONFRAG_IPV6_TCP:
-			case RTE_ETH_RSS_NONFRAG_IPV4_UDP:
-			case RTE_ETH_RSS_NONFRAG_IPV6_UDP:
-			case RTE_ETH_RSS_IPV6_TCP_EX:
-			case RTE_ETH_RSS_IPV6_UDP_EX:
-			case RTE_ETH_RSS_NONFRAG_IPV4_SCTP:
-			case RTE_ETH_RSS_NONFRAG_IPV6_SCTP:
-
-				if (l4_configured)
-					break;
-				l4_configured = 1;
-
-				kg_cfg->extracts[i].extract.from_hdr.prot =
-					NET_PROT_TCP;
-				kg_cfg->extracts[i].extract.from_hdr.field =
-					NH_FLD_TCP_PORT_SRC;
-				kg_cfg->extracts[i].type =
-					DPKG_EXTRACT_FROM_HDR;
-				kg_cfg->extracts[i].extract.from_hdr.type =
-					DPKG_FULL_FIELD;
-				i++;
-
-				kg_cfg->extracts[i].extract.from_hdr.prot =
-					NET_PROT_TCP;
-				kg_cfg->extracts[i].extract.from_hdr.field =
-					NH_FLD_TCP_PORT_DST;
-				kg_cfg->extracts[i].type =
-					DPKG_EXTRACT_FROM_HDR;
-				kg_cfg->extracts[i].extract.from_hdr.type =
-					DPKG_FULL_FIELD;
-				i++;
-				break;
-
-			default:
-				DPAA2_PMD_WARN(
-				      "unsupported flow dist option 0x%" PRIx64,
-					     dist_field);
-				return -EINVAL;
-			}
-		}
-		req_dist_set = req_dist_set >> 1;
-		loop++;
-	}
-	kg_cfg->num_extracts = i;
-	return 0;
-}
-
-int
-dpaa2_attach_bp_list(struct dpaa2_dev_priv *priv,
-	struct fsl_mc_io *dpni, void *blist)
-{
-	/* Function to attach a DPNI with a buffer pool list. Buffer pool list
-	 * handle is passed in blist.
-	 */
-	int32_t retcode;
-	struct dpni_pools_cfg bpool_cfg;
-	struct dpaa2_bp_list *bp_list = (struct dpaa2_bp_list *)blist;
-	struct dpni_buffer_layout layout;
-	int tot_size;
-
-	/* ... rx buffer layout .
-	 * Check alignment for buffer layouts first
-	 */
-
-	/* ... rx buffer layout ... */
-	if (priv->flags & DPAA2_TX_PREFETCH_DYNAMIC_CONF) {
-		int out_min_hdr_room, in_min_hdr_room;
-		/** Additional headroom layout for IPSec with TX configure
-		 * dynamic enabled.
-		 */
-		in_min_hdr_room = DPAA2_RX_MIN_FD_OFFSET +
-			DPAA2_SEC_SIMPLE_FD_IB_MIN;
-		out_min_hdr_room = DPAA2_DYN_TX_MIN_FD_OFFSET +
-			DPAA2_SEC_SIMPLE_FD_OB_MIN;
-		tot_size = RTE_MAX(in_min_hdr_room, out_min_hdr_room);
-		if (tot_size < RTE_PKTMBUF_HEADROOM)
-			tot_size = RTE_PKTMBUF_HEADROOM;
-	} else {
-		tot_size = RTE_PKTMBUF_HEADROOM;
-	}
-	tot_size = RTE_ALIGN_CEIL(tot_size, DPAA2_PACKET_LAYOUT_ALIGN);
-
-	memset(&layout, 0, sizeof(struct dpni_buffer_layout));
-	layout.options = DPNI_BUF_LAYOUT_OPT_DATA_HEAD_ROOM |
-			 DPNI_BUF_LAYOUT_OPT_FRAME_STATUS |
-			 DPNI_BUF_LAYOUT_OPT_PARSER_RESULT |
-			 DPNI_BUF_LAYOUT_OPT_DATA_ALIGN |
-			 DPNI_BUF_LAYOUT_OPT_TIMESTAMP |
-			 DPNI_BUF_LAYOUT_OPT_PRIVATE_DATA_SIZE;
-
-	layout.pass_timestamp = true;
-	layout.pass_frame_status = 1;
-	layout.private_data_size = DPAA2_FD_PTA_SIZE;
-	layout.pass_parser_result = 1;
-	layout.data_align = DPAA2_PACKET_LAYOUT_ALIGN;
-	layout.data_head_room = tot_size - DPAA2_FD_PTA_SIZE -
-				DPAA2_MBUF_HW_ANNOTATION;
-	retcode = dpni_set_buffer_layout(dpni, CMD_PRI_LOW, priv->token,
-					 DPNI_QUEUE_RX, &layout);
-	if (retcode) {
-		DPAA2_PMD_ERR("Error configuring buffer pool Rx layout (%d)",
-			     retcode);
-		return retcode;
-	}
-
-	/*Attach buffer pool to the network interface as described by the user*/
-	memset(&bpool_cfg, 0, sizeof(struct dpni_pools_cfg));
-	bpool_cfg.num_dpbp = 1;
-	bpool_cfg.pools[0].dpbp_id = bp_list->buf_pool.dpbp_node->dpbp_id;
-	bpool_cfg.pools[0].backup_pool = 0;
-	bpool_cfg.pools[0].buffer_size = RTE_ALIGN_CEIL(bp_list->buf_pool.size,
-						DPAA2_PACKET_LAYOUT_ALIGN);
-	bpool_cfg.pools[0].priority_mask = 0;
-
-	retcode = dpni_set_pools(dpni, CMD_PRI_LOW, priv->token, &bpool_cfg);
-	if (retcode != 0) {
-		DPAA2_PMD_ERR("Error configuring buffer pool on interface."
-			      " bpid = %d error code = %d",
-			      bpool_cfg.pools[0].dpbp_id, retcode);
-		return retcode;
-	}
-
-	priv->bp_list = bp_list;
-	return 0;
-}
drivers/net/dpaa2/dpaa2_ethdev.c +366 -91

588 lines not on this page · raw message

drivers/net/dpaa2/dpaa2_ethdev.h +321 -157

584 lines not on this page · raw message

drivers/net/dpaa2/dpaa2_flow.c +4031 -2875

1,282 lines not on this page · raw message

drivers/net/dpaa2/meson.build +1 -2
index 4f774f7c82..3f8bee9146 100644

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

Signature · 1 line
2.43.0

Part of the diff is not shown here. View the raw message.

#39 lore raw

PATCH 38/45 net/dpaa2: support Rx mempool per traffic class

In reply to Prashant Gupta

From: Jun Yang <[email protected]>

Support configuring RX mempool per TC.
This patch isolates mempools by traffic class to avoid individual TC's performance being impacted by lack of memory.

---
 drivers/net/dpaa2/dpaa2_ethdev.c | 115 ++++++++++++++++++++++++++++++-
 drivers/net/dpaa2/dpaa2_ethdev.h |   2 +-
 2 files changed, 115 insertions(+), 2 deletions(-)
drivers/net/dpaa2/dpaa2_ethdev.c +114 -1
index a7c9bb678e..a33d6c5db6 100644
@@ -565,6 +565,97 @@ dpaa2_update_flow_rss_dist(struct rte_eth_dev *eth_dev,
 	return ret;
 }
 
+static int
+dpaa2_attach_bp_list(struct dpaa2_dev_priv *priv,
+	struct fsl_mc_io *dpni, void *blist, uint8_t tc_id)
+{
+	/* Function to attach a DPNI with a buffer pool list. Buffer pool list
+	 * handle is passed in blist.
+	 */
+	int32_t retcode;
+	struct dpni_pools_cfg *bpool_cfg = &priv->pools_cfg;
+	struct dpaa2_bp_list *bp_list = blist;
+	struct dpni_buffer_layout layout;
+	int tot_size, out_min_hdr_room, in_min_hdr_room;
+	uint8_t bp_idx;
+	struct rte_mempool *mp = bp_list->mp;
+
+	if (priv->flow_profile.mempool[tc_id] != mp) {
+		if (!priv->flow_profile.mempool[tc_id]) {
+			bp_idx = bpool_cfg->num_dpbp;
+			bpool_cfg->num_dpbp++;
+			priv->flow_profile.bp_idx[tc_id] = bp_idx;
+		} else {
+			bp_idx = priv->flow_profile.bp_idx[tc_id];
+		}
+		priv->flow_profile.mempool[tc_id] = mp;
+	} else {
+		bp_idx = priv->flow_profile.bp_idx[tc_id];
+	}
+
+	/* ... rx buffer layout .
+	 * Check alignment for buffer layouts first
+	 */
+
+	/* ... rx buffer layout ... */
+	if (priv->tx_conf_type == DPAA2_TX_DYNAMIC_CONF) {
+		/** Additional headroom layout for IPSec with TX configure
+		 * dynamic enabled.
+		 */
+		in_min_hdr_room = DPAA2_RX_MIN_FD_OFFSET +
+			DPAA2_SEC_SIMPLE_FD_IB_MIN;
+		out_min_hdr_room = DPAA2_DYN_TX_MIN_FD_OFFSET +
+			DPAA2_SEC_SIMPLE_FD_OB_MIN;
+		tot_size = RTE_MAX(in_min_hdr_room, out_min_hdr_room);
+		if (tot_size < RTE_PKTMBUF_HEADROOM)
+			tot_size = RTE_PKTMBUF_HEADROOM;
+	} else {
+		tot_size = RTE_PKTMBUF_HEADROOM;
+	}
+	tot_size = RTE_ALIGN_CEIL(tot_size, DPAA2_PACKET_LAYOUT_ALIGN);
+
+	memset(&layout, 0, sizeof(struct dpni_buffer_layout));
+	layout.options = DPNI_BUF_LAYOUT_OPT_DATA_HEAD_ROOM |
+		DPNI_BUF_LAYOUT_OPT_FRAME_STATUS |
+		DPNI_BUF_LAYOUT_OPT_PARSER_RESULT |
+		DPNI_BUF_LAYOUT_OPT_DATA_ALIGN |
+		DPNI_BUF_LAYOUT_OPT_TIMESTAMP |
+		DPNI_BUF_LAYOUT_OPT_PRIVATE_DATA_SIZE;
+
+	layout.pass_timestamp = true;
+	layout.pass_frame_status = 1;
+	layout.private_data_size = DPAA2_FD_PTA_SIZE;
+	layout.pass_parser_result = 1;
+	layout.data_align = DPAA2_PACKET_LAYOUT_ALIGN;
+	layout.data_head_room = tot_size - DPAA2_FD_PTA_SIZE -
+		DPAA2_MBUF_HW_ANNOTATION;
+	retcode = dpni_set_buffer_layout(dpni, CMD_PRI_LOW, priv->token,
+			DPNI_QUEUE_RX, &layout);
+	if (retcode) {
+		DPAA2_PMD_ERR("Error configuring buffer pool Rx layout (%d)",
+			retcode);
+		return retcode;
+	}
+
+	/*Attach buffer pool to the network interface as described by the user*/
+	bpool_cfg->pools[bp_idx].dpbp_id = bp_list->buf_pool.dpbp_node->dpbp_id;
+	bpool_cfg->pools[bp_idx].backup_pool = 0;
+	bpool_cfg->pools[bp_idx].buffer_size = RTE_ALIGN_CEIL(bp_list->buf_pool.size,
+		DPAA2_PACKET_LAYOUT_ALIGN);
+	bpool_cfg->pools[bp_idx].priority_mask = tc_id;
+
+	retcode = dpni_set_pools(dpni, CMD_PRI_LOW, priv->token, bpool_cfg);
+	if (retcode) {
+		DPAA2_PMD_ERR("Error(%d) configuring pools[%d](id=%d) on %s.",
+			retcode, bp_idx, bpool_cfg->pools[bp_idx].dpbp_id,
+			priv->eth_dev->data->name);
+		return retcode;
+	}
+
+	priv->bp_list = bp_list;
+	return 0;
+}
+
 static int
 dpaa2_vlan_filter_set(struct rte_eth_dev *dev, uint16_t vlan_id, int on)
 {
@@ -1340,7 +1431,8 @@ dpaa2_dev_rx_queue_setup(struct rte_eth_dev *dev,
 	struct dpni_taildrop taildrop;
 	uint8_t qopt = 0;
 	uint16_t flow_id;
-	int ret;
+	uint32_t bpid;
+	int ret, ops_idx;
 
 	PMD_INIT_FUNC_TRACE();
 
@@ -1365,6 +1457,27 @@ dpaa2_dev_rx_queue_setup(struct rte_eth_dev *dev,
 		dev->data->rx_queues[rx_queue_id] = dpaa2_q;
 		return 0;
 	}
+
+	ops_idx = rte_dpaa2_mpool_get_ops_idx();
+	if (ops_idx != mb_pool->ops_index) {
+		DPAA2_PMD_ERR("MP(%s)'s ops index(%d) != %d",
+			mb_pool->name, mb_pool->ops_index, ops_idx);
+		return -EINVAL;
+	}
+
+	if (!priv->bp_list || priv->bp_list->mp != mb_pool) {
+		if (rte_eal_process_type() != RTE_PROC_PRIMARY) {
+			ret = rte_dpaa2_bpid_info_init(mb_pool);
+			if (ret)
+				return ret;
+		}
+		bpid = mempool_to_bpid(mb_pool);
+		ret = dpaa2_attach_bp_list(priv, dpni,
+				rte_dpaa2_bpid_info[bpid].bp_list,
+				dpaa2_q->tc_index);
+		if (ret)
+			return ret;
+	}
 	cfg = rte_zmalloc(NULL, sizeof(struct dpni_queue), 0);
 	if (!cfg)
 		return -ENOMEM;
drivers/net/dpaa2/dpaa2_ethdev.h +1 -1
index 5659abcd51..7d93b75be3 100644
@@ -404,7 +404,7 @@ struct dpaa2_dev_priv {
 	/** RXQs in same TC share same cgid.*/
 	uint8_t cgid_in_use[MAX_TCS];
 	rte_spinlock_t meter_lock;
-
+	struct dpni_pools_cfg pools_cfg;
 	/* Current hash distribution size per RX TC, written by
 	 * dpaa2_setup_flow_dist_size() and read by reta_query / reta_update.
 	 * Zero means "use default" (= nb_rx_queues clamped to dist_queues).
Signature · 1 line
2.43.0
#40 lore raw

PATCH 39/45 drivers: consume dpaa2 DQRR entries in batches

In reply to Prashant Gupta

From: Jun Yang <[email protected]>

Each DQRR entry consumed by the software portal costs a write to the cache-invalidate DCAP register. The DCAP register also supports a vector mode where a bitmap of DQRR indices is consumed with a single write, so accumulate the indices and flush the vector once half the ring is pending. A smaller threshold gives little benefit, and a threshold close to the ring size starves WRIOP of DQRR space.

Because entries are now released in batches, a caller that stops polling a portal must flush the pending vector explicitly. Pass a NULL dequeue result to qbman_swp_dqrr_consume() to do that when the eventdev dequeue finds the portal dry, when the net PMD finishes draining a portal, and when a portal is released back to the bus.

---
 drivers/bus/fslmc/portal/dpaa2_hw_dpio.c      |  4 ++
 .../fslmc/qbman/include/fsl_qbman_portal.h    |  5 +-
 drivers/bus/fslmc/qbman/qbman_portal.c        | 63 +++++++++++++++++--
 drivers/bus/fslmc/qbman/qbman_portal.h        | 11 +++-
 drivers/event/dpaa2/dpaa2_eventdev.c          |  4 ++
 drivers/net/dpaa2/dpaa2_ethdev.c              |  2 +
 6 files changed, 81 insertions(+), 8 deletions(-)
drivers/bus/fslmc/portal/dpaa2_hw_dpio.c +4 -0
index 20d1bb2a66..cfd9548fb0 100644
@@ -305,6 +305,10 @@ dpaa2_configure_stashing(struct dpaa2_dpio_dev *dpio_dev, int cpu_id, bool ethrx
 static void dpaa2_put_qbman_swp(struct dpaa2_dpio_dev *dpio_dev)
 {
 	if (dpio_dev) {
+		/* consume indices may still be pending in the portal's DQRR
+		 * consume vector; flush them before the portal is released.
+		 */
+		qbman_swp_dqrr_consume(dpio_dev->sw_portal, NULL);
 		/* rx-queue interrupts (net PMD) can arm a portal without the
 		 * event driver; tear it down unconditionally. Safe when never
 		 * armed: intr_deinit returns early if intr is not enabled.
drivers/bus/fslmc/qbman/include/fsl_qbman_portal.h +4 -1
index b9e7789766..73e57bcdc1 100644
@@ -451,7 +451,10 @@ void qbman_swp_prefetch_dqrr_next(struct qbman_swp *s);
  * qbman_swp_dqrr_consume() -  Consume DQRR entries previously returned from
  * qbman_swp_dqrr_next().
  * @s: the software portal object.
- * @dq: the DQRR entry to be consumed.
+ * @dq: the DQRR entry to be consumed, NULL to consume the entries accumulated
+ * so far. Entries are accumulated and consumed in batches, so a caller which
+ * stops polling the portal must call this with a NULL dq to release the
+ * entries it has already processed.
  */
 __rte_internal
 void qbman_swp_dqrr_consume(struct qbman_swp *s, const struct qbman_result *dq);
drivers/bus/fslmc/qbman/qbman_portal.c +57 -6

103 lines not on this page · raw message

drivers/bus/fslmc/qbman/qbman_portal.h +10 -1
index 1cf7918309..db74db5fe1 100644
@@ -1,7 +1,7 @@
 /* SPDX-License-Identifier: BSD-3-Clause
  *
  * Copyright (C) 2014-2016 Freescale Semiconductor, Inc.
- * Copyright 2018-2020 NXP
+ * Copyright 2018-2020, 2026 NXP
  *
  */
 
@@ -93,6 +93,15 @@ struct qbman_swp {
 		uint32_t valid_bit;
 		uint8_t dqrr_size;
 		int reset_bug;
+		/* Consume index vector: instead of writing DCAP once per
+		 * consumed entry, the indices are accumulated in ci_vector
+		 * and written with a single DCAP access once ci_count
+		 * reaches ci_flush_th.
+		 */
+		bool ci_vec_en;
+		uint8_t ci_count;
+		uint8_t ci_flush_th;
+		uint32_t ci_vector;
 	} dqrr;
 	struct {
 		uint32_t pi;
drivers/event/dpaa2/dpaa2_eventdev.c +4 -0
index 95d9154b11..5d32bd9fd6 100644
@@ -320,6 +320,10 @@ dpaa2_eventdev_dequeue_burst(void *port, struct rte_event ev[],
 	do {
 		dq = qbman_swp_dqrr_next(swp);
 		if (!dq) {
+			/* portal is dry: consume whatever is still pending in
+			 * the DQRR consume vector before leaving it idle.
+			 */
+			qbman_swp_dqrr_consume(swp, NULL);
 			if (!num_pkts && timeout_ticks) {
 				dpaa2_eventdev_dequeue_wait(timeout_ticks);
 				timeout_ticks = 0;
drivers/net/dpaa2/dpaa2_ethdev.c +2 -0
index a33d6c5db6..34f1e00b12 100644
@@ -3533,6 +3533,8 @@ dpaa2_napi_drain_portal(struct dpaa2_dpio_dev *dpio)
 
 	while ((dq = qbman_swp_dqrr_next(dpio->sw_portal)))
 		qbman_swp_dqrr_consume(dpio->sw_portal, dq);
+	/* flush the indices still pending in the DQRR consume vector */
+	qbman_swp_dqrr_consume(dpio->sw_portal, NULL);
 	qbman_swp_interrupt_clear_status(dpio->sw_portal, 0xffffffff);
 }
 
Signature · 1 line
2.43.0
#41 lore raw

PATCH 40/45 drivers: resolve dpaa2 endpoint in the net driver

In reply to Prashant Gupta

From: Jun Yang <[email protected]>

The DPRC object driver walked every device on the bus and, for each DPNI, issued dprc_get_connection() to find the object it is wired to. Two things are wrong with that. The bus keeps the result in struct rte_dpaa2_device even though only the net driver consumes it, and a failure to resolve one DPNI's endpoint aborted the creation of the whole container. The endpoint name was also formatted from endpoint2 outside the DPNI branch, so non-DPNI devices got a name built from uninitialised or stale data.

Move the lookup to dpaa2_dev_init(), which already knows it is dealing with a DPNI and can fail the probe of that one port. This also fills in priv->ep_dev_type, priv->ep_object_id and priv->ep_name, which the net driver reads for MAC-level operations, recycle/loopback configuration and rte_pmd_dpaa2_ep_name(), but which nothing assigned. dpsw endpoints are now recognised, and dpdmux/dpsw names carry the interface index because those endpoints are per-interface.

---
 drivers/bus/fslmc/bus_fslmc_driver.h     |  3 --
 drivers/bus/fslmc/portal/dpaa2_hw_dprc.c | 45 +++---------------
 drivers/net/dpaa2/dpaa2_ethdev.c         | 58 +++++++++++++++++++++++-
 drivers/net/dpaa2/dpaa2_recycle.c        | 15 +++---
 4 files changed, 70 insertions(+), 51 deletions(-)
drivers/bus/fslmc/bus_fslmc_driver.h +0 -3
index b4a5a86318..0d431fdd19 100644
@@ -104,10 +104,7 @@ struct rte_dpaa2_device {
 	struct rte_device device;           /**< Inherit core device */
 	enum rte_dpaa2_dev_type dev_type;   /**< Device Type */
 	uint16_t object_id;                 /**< DPAA2 Object ID */
-	enum rte_dpaa2_dev_type ep_dev_type;   /**< Endpoint Device Type */
 	struct dpaa2_dprc_dev *container;
-	uint16_t ep_object_id;                 /**< Endpoint DPAA2 Object ID */
-	char ep_name[RTE_DEV_NAME_MAX_LEN];
 	struct rte_intr_handle *intr_handle; /**< Interrupt handle */
 	char name[FSLMC_OBJECT_MAX_LEN];    /**< DPAA2 Object name*/
 	struct rte_dma_dev *dmadev;          /**< DMA device */
drivers/bus/fslmc/portal/dpaa2_hw_dprc.c +6 -39

58 lines not on this page · raw message

drivers/net/dpaa2/dpaa2_ethdev.c +57 -1

76 lines not on this page · raw message

drivers/net/dpaa2/dpaa2_recycle.c +7 -8
index ed038c204b..acf4a8b320 100644
@@ -628,18 +628,18 @@ dpaa2_dev_recycle_config(struct rte_eth_dev *eth_dev)
 		return 0;
 	}
 
-	if (dpaa2_dev->ep_dev_type == DPAA2_MAC) {
+	if (priv->ep_dev_type == DPAA2_MAC) {
 		/** For dpmac-dpni connection,
 		 * try setting serdes loopback as recycle device at first.
 		 */
 		if (dpaa2_svr_family == SVR_LS2088A) {
-			ret = ls_serdes_eth_lpbk(dpaa2_dev->ep_object_id, 1);
+			ret = ls_serdes_eth_lpbk(priv->ep_object_id, 1);
 			if (!ret) {
 				priv->flags |= DPAA2_TX_SERDES_LOOPBACK_MODE;
 				return 0;
 			}
 		} else if (dpaa2_svr_family == SVR_LX2160A) {
-			ret = lx_serdes_eth_lpbk(dpaa2_dev->ep_object_id, 1);
+			ret = lx_serdes_eth_lpbk(priv->ep_object_id, 1);
 			if (!ret) {
 				priv->flags |= DPAA2_TX_SERDES_LOOPBACK_MODE;
 				return 0;
@@ -668,8 +668,8 @@ dpaa2_dev_recycle_config(struct rte_eth_dev *eth_dev)
 		return 0;
 	}
 
-	if (dpaa2_dev->ep_dev_type == DPAA2_ETH &&
-		dpaa2_dev->object_id == dpaa2_dev->ep_object_id) {
+	if (priv->ep_dev_type == DPAA2_ETH &&
+		dpaa2_dev->object_id == priv->ep_object_id) {
 		priv->flags |= DPAA2_TX_DPNI_LOOPBACK_MODE;
 
 		return 0;
@@ -682,7 +682,6 @@ int
 dpaa2_dev_recycle_deconfig(struct rte_eth_dev *eth_dev)
 {
 	struct dpaa2_dev_priv *priv = eth_dev->data->dev_private;
-	struct rte_dpaa2_device *dpaa2_dev = RTE_CLASS_TO_BUS_DEVICE(eth_dev, *dpaa2_dev);
 	struct fsl_mc_io *dpni_dev = eth_dev->process_private;
 	struct dpni_port_cfg port_cfg;
 	int ret = 0;
@@ -692,7 +691,7 @@ dpaa2_dev_recycle_deconfig(struct rte_eth_dev *eth_dev)
 
 	if (priv->flags & DPAA2_TX_SERDES_LOOPBACK_MODE) {
 		if (dpaa2_svr_family == SVR_LS2088A) {
-			ret = ls_serdes_eth_lpbk(dpaa2_dev->ep_object_id, 0);
+			ret = ls_serdes_eth_lpbk(priv->ep_object_id, 0);
 			if (ret) {
 				DPAA2_PMD_WARN("Error(%d) to disable Serdes loopback",
 					ret);
@@ -700,7 +699,7 @@ dpaa2_dev_recycle_deconfig(struct rte_eth_dev *eth_dev)
 				priv->flags &= ~DPAA2_TX_SERDES_LOOPBACK_MODE;
 			}
 		} else if (dpaa2_svr_family == SVR_LX2160A) {
-			ret = lx_serdes_eth_lpbk(dpaa2_dev->ep_object_id, 0);
+			ret = lx_serdes_eth_lpbk(priv->ep_object_id, 0);
 			if (ret) {
 				DPAA2_PMD_WARN("Error(%d) to disable Serdes loopback",
 					ret);
Signature · 1 line
2.43.0
#42 lore raw

PATCH 41/45 drivers: align dpaa2 event port depths with hardware rings

In reply to Prashant Gupta

From: Jun Yang <[email protected]>

The event port dequeue and enqueue depths were fixed at 8. A dequeue drains the portal DQRR and an enqueue fills the EQCR, so the real limits are the sizes of those two rings, which differ per SoC and are known at run time. Report them instead, adding qbman_swp_portal_dqrr_size() to query the DQRR size (the EQCR size is already available as dpaa2_eqcr_size).

The Tx adapter enqueue helpers sized their on-stack mbuf arrays from the advertised enqueue depth, which no longer bounds the burst the adapter may hand them, so bound the copy by the array itself and transmit in chunks.

---
 .../fslmc/qbman/include/fsl_qbman_portal.h    |  7 ++
 drivers/bus/fslmc/qbman/qbman_portal.c        | 15 ++++
 drivers/event/dpaa2/dpaa2_eventdev.c          | 72 ++++++++++++-------
 drivers/event/dpaa2/dpaa2_eventdev.h          |  4 +-
 4 files changed, 69 insertions(+), 29 deletions(-)
drivers/bus/fslmc/qbman/include/fsl_qbman_portal.h +7 -0
index 73e57bcdc1..fb1c6046ae 100644
@@ -1222,6 +1222,13 @@ __rte_internal
 int qbman_swp_acquire(struct qbman_swp *s, uint16_t bpid, uint64_t *buffers,
 		      unsigned int num_buffers);
 
+/**
+ * qbman_swp_portal_dqrr_size() - Number of entries in a portal's DQRR.
+ * @p: the software portal object, NULL to query the SoC's DQRR size.
+ */
+__rte_internal
+uint32_t qbman_swp_portal_dqrr_size(struct qbman_swp *p);
+
 	/*****************/
 	/* FQ management */
 	/*****************/
drivers/bus/fslmc/qbman/qbman_portal.c +15 -0
index c95c62baa7..a5f92e27e7 100644
@@ -73,6 +73,11 @@ enum qbman_sdqcr_fc {
 static struct qbman_swp *portal_idx_map[MAX_QBMAN_PORTALS];
 
 uint32_t qman_version;
+/* DQRR size of the portals initialised so far. All portals of a SoC have the
+ * same size, so this doubles as the SoC's DQRR size for callers that have no
+ * portal at hand.
+ */
+static uint32_t dpaa2_portal_dqrr_size = 8;
 
 /* Internal Function declaration */
 static int
@@ -239,6 +244,15 @@ static int (*qbman_swp_release_ptr)(struct qbman_swp *s,
 			const uint64_t *buffers, unsigned int num_buffers)
 			= qbman_swp_release_direct;
 
+RTE_EXPORT_INTERNAL_SYMBOL(qbman_swp_portal_dqrr_size)
+uint32_t qbman_swp_portal_dqrr_size(struct qbman_swp *p)
+{
+	if (p != NULL)
+		return p->dqrr.dqrr_size;
+
+	return dpaa2_portal_dqrr_size;
+}
+
 /*********************************/
 /* Portal constructor/destructor */
 /*********************************/
@@ -298,6 +312,7 @@ struct qbman_swp *qbman_swp_init(const struct qbman_swp_desc *d)
 	 */
 	p->dqrr.ci_vec_en = true;
 	p->dqrr.ci_flush_th = p->dqrr.dqrr_size / 2;
+	dpaa2_portal_dqrr_size = p->dqrr.dqrr_size;
 
 	ret = qbman_swp_sys_init(&p->sys, d, p->dqrr.dqrr_size);
 	if (ret) {
drivers/event/dpaa2/dpaa2_eventdev.c +46 -26

110 lines not on this page · raw message

drivers/event/dpaa2/dpaa2_eventdev.h +1 -3
index 3883a26c91..a054dfdbd7 100644
@@ -1,5 +1,5 @@
 /* SPDX-License-Identifier: BSD-3-Clause
- * Copyright 2017 NXP
+ * Copyright 2017,2026 NXP
  */
 
 #ifndef __DPAA2_EVENTDEV_H__
@@ -22,8 +22,6 @@
 #define DPAA2_EVENT_MAX_QUEUE_FLOWS		2048
 #define DPAA2_EVENT_MAX_QUEUE_PRIORITY_LEVELS	8
 #define DPAA2_EVENT_MAX_EVENT_PRIORITY_LEVELS	0
-#define DPAA2_EVENT_MAX_PORT_DEQUEUE_DEPTH	8
-#define DPAA2_EVENT_MAX_PORT_ENQUEUE_DEPTH	8
 #define DPAA2_EVENT_MAX_NUM_EVENTS		(INT32_MAX - 1)
 
 #define DPAA2_EVENT_QUEUE_ATOMIC_FLOWS		2048
Signature · 1 line
2.43.0
#43 lore raw

PATCH 42/45 net/dpaa2: read MC version from device private data

In reply to Prashant Gupta

The flow engine reached back to the bus device to read the MC firmware version. The bus_info pointer behind it is only attached by the primary process, so a secondary process that creates a flow dereferences a pointer it never set up.

The version is already cached in priv->mc_rev at probe time and the rest of the driver reads it from there, so use that here too. This removes the last user of DPAA2_DEV_PRIV_TO_DPAA2_DEV(), so drop the macro.

---
 drivers/net/dpaa2/dpaa2_ethdev.h |  4 ---
 drivers/net/dpaa2/dpaa2_flow.c   | 59 ++++++++++----------------------
 2 files changed, 18 insertions(+), 45 deletions(-)
drivers/net/dpaa2/dpaa2_ethdev.h +0 -4
index 7d93b75be3..e02fa9a622 100644
@@ -43,10 +43,6 @@
 #define MAX_DPNI		8
 #define DPAA2_MAX_CHANNELS	16
 
-#define DPAA2_DEV_PRIV_TO_DPAA2_DEV(priv) \
-	container_of((((struct dpaa2_dev_priv *)priv)->eth_dev->device), \
-	struct rte_dpaa2_device, device)
-
 #define DPAA2_EXTRACT_PARAM_MAX_SIZE \
 	RTE_ALIGN(sizeof(struct dpni_ext_set_rx_tc_dist), 256)
 
drivers/net/dpaa2/dpaa2_flow.c +18 -41

212 lines not on this page · raw message

Signature · 1 line
2.43.0
#44 lore raw

PATCH 43/45 net/dpaa2: do not overwrite mbuf hash with drop priority

In reply to Prashant Gupta

From: Gagandeep Singh <[email protected]>

dpaa2_eth_fd_to_mbuf() wrote the frame descriptor's drop priority into mbuf->hash.sched.color unconditionally. hash.sched shares the union with hash.rss and hash.fdir, so this clobbered whatever the parse step had placed there. The scheduler color is only meaningful when the frame came out of a flow-steering table, and dpaa2_dev_rx_mbuf_sched_set() already sets the whole sched field (queue, traffic class and colour) in that case, so drop the unconditional write.

---
 drivers/net/dpaa2/dpaa2_rxtx.c | 1 -
 1 file changed, 1 deletion(-)
drivers/net/dpaa2/dpaa2_rxtx.c +0 -1
index 5c6a77d2f8..f2137bddd4 100644
@@ -495,7 +495,6 @@ dpaa2_eth_fd_to_mbuf(struct dpaa2_dev_priv *priv, const struct qbman_fd *fd)
 	mbuf->pkt_len = mbuf->data_len;
 	mbuf->port = priv->eth_dev->data->port_id;
 	mbuf->next = NULL;
-	mbuf->hash.sched.color = DPAA2_GET_FD_DROPP(fd);
 	rte_mbuf_refcnt_set(mbuf, 1);
 #ifdef RTE_LIBRTE_MEMPOOL_DEBUG
 	rte_mempool_check_cookies(rte_mempool_from_obj((void *)mbuf),
Signature · 1 line
2.43.0
#45 lore raw

PATCH 44/45 bus/fslmc: reduce probe-time logging and MC traffic

In reply to Prashant Gupta

From: Hemant Agrawal <[email protected]>

Every DMA map logged its virtual, IOVA and physical addresses at NOTICE. An application that maps many memory segments prints one such line per segment during initialisation, which drowns out messages the operator actually needs; the neighbouring mapping paths already use debug level.

fslmc_vfio_get_bus_info() also issued mc_get_soc_version() twice in a row into the same structure, so the second command only overwrote the first result with an identical one. Keep a single query.

---
 drivers/bus/fslmc/fslmc_vfio.c | 10 +---------
 1 file changed, 1 insertion(+), 9 deletions(-)
drivers/bus/fslmc/fslmc_vfio.c +1 -9
index 4eb8552696..5ccb457a75 100644
@@ -281,13 +281,6 @@ fslmc_vfio_get_bus_info(void *regs, struct rte_fslmc_bus_info *bus_info)
 		return ret;
 	}
 
-	memset(&mc_plat_info, 0, sizeof(struct mc_soc_version));
-	ret = mc_get_soc_version(&mc_io, CMD_PRI_LOW, &mc_plat_info);
-	if (ret) {
-		DPAA2_BUS_ERR("Unable to get SoC version err:%d", ret);
-		return ret;
-	}
-
 	for (i = 0; i < RTE_DIM(s_soc_type); i++) {
 		if ((mc_plat_info.svr & DPAA2_SVR_MASK) == s_soc_type[i].svr) {
 			dpaa2_svr_family = s_soc_type[i].svr;
@@ -1041,8 +1034,7 @@ fslmc_map_dma(uint64_t vaddr, rte_iova_t iovaddr, size_t len)
 			fslmc_mem_va2iova = RTE_BAD_IOVA;
 		TAILQ_INSERT_TAIL(&fslmc_memsegs, dmaseg, next);
 	}
-	DPAA2_BUS_LOG(NOTICE,
-		"%s(%zx): VA(%" PRIx64 "):IOVA(%" PRIx64 "):PHY(%" PRIx64 ")",
+	DPAA2_BUS_DEBUG("%s(%zx): VA(%" PRIx64 "):IOVA(%" PRIx64 "):PHY(%" PRIx64 ")",
 		is_io ? "DMA I/O map size" : "DMA MEM map size",
 		len, vaddr, iovaddr, phy);
 
Signature · 1 line
2.43.0
#46 lore raw

PATCH 45/45 net/dpaa2: reject Rx queue deferred start

In reply to Prashant Gupta

From: Hemant Agrawal <[email protected]>

The driver has no way to hold an Rx queue down while the port is started, and dpaa2_rxq_info_get() already reports rx_deferred_start as 0. The Tx side rejects the request; do the same for Rx instead of silently accepting a configuration that will not be honoured.

---
 drivers/net/dpaa2/dpaa2_ethdev.c | 7 +++++++
 1 file changed, 7 insertions(+)
drivers/net/dpaa2/dpaa2_ethdev.c +7 -0
index 7cd38ddce6..596806c18a 100644
@@ -1439,6 +1439,13 @@ dpaa2_dev_rx_queue_setup(struct rte_eth_dev *dev,
 	DPAA2_PMD_DEBUG("dev =%p, queue =%d, pool = %p, conf =%p",
 			dev, rx_queue_id, mb_pool, rx_conf);
 
+	/* Rx deferred start is not supported */
+	if (rx_conf->rx_deferred_start) {
+		DPAA2_PMD_ERR("%s: Rx deferred start not supported",
+			dev->data->name);
+		return -EINVAL;
+	}
+
 	total_nb_rx_desc += nb_rx_desc;
 	if (total_nb_rx_desc > MAX_NB_RX_DESC_IN_PEB &&
 	    (priv->options & DPNI_OPT_V1_PFDR_IN_PEB)) {
Signature · 1 line
2.43.0
#47 lore raw
In reply to Prashant Gupta
Quoted 4 lines · On Thu, 3 Sep 2026 19:23:08 +0530 Prashant Gupta <[email protected]>…

This series brings the NXP DPAA2 driver stack up to date with the functionality carried in the NXP internal tree, together with a number of bug fixes. It covers the crypto (dpaa2_sec), net, dma, mempool, event and bus/fslmc drivers.

Since it was big, ran AI review with Fable. It stopped after finding errors in the first 8 patches.

DPAA2 series review (bundle 2096), patches 1-8 of 45
Base: upstream main d55ccd4; all 45 patches apply cleanly with git am --3way.

Patch 3: crypto/dpaa2_sec: support AES-GMAC

Warning: The patch adds RTE_CRYPTO_AEAD_AES_GMAC to the public enum rte_crypto_aead_algorithm in lib/cryptodev/rte_crypto_sym.h but does not add it to crypto_aead_algorithm_strings[] in lib/cryptodev/rte_cryptodev.c, so rte_cryptodev_get_aead_algo_string() returns NULL for it and rte_cryptodev_get_aead_algo_enum("aes-gmac") fails, which also breaks test-crypto-perf/testpmd-style string selection. There is no entry in doc/guides/rel_notes/release_26_11.rst for the new public API value. The lib/cryptodev change should be its own patch ahead of the driver patch, with the string table and release note.

Warning: dpaa2_sec_capabilities[] (the same table returned by rte_cryptodev_info_get() via dpaa2_sec_dev_infos_get) now advertises AES-GMAC as a symmetric AEAD capability, but only the IPsec security path (dpaa2_sec_ipsec_aead_init) handles it; the plain-crypto dpaa2_sec_aead_init() falls into the default case and returns -ENOTSUP. An application that walks rte_cryptodev_sym_capability_get() will find AES-GMAC and then fail session creation. Either advertise it only through the security capability crypto_capabilities or add the plain AEAD path.

Patch 6: crypto/dpaa2_sec: add support for env variables

Error: The env fallback overrides devargs rather than acting as a fallback. dpaa2_sec_get_devargs() is called twice from dpaa2_sec_dev_init(), once per key:

	dpaa2_sec_get_devargs(cryptodev, DRIVER_DUMP_MODE);
	dpaa2_sec_get_devargs(cryptodev, DRIVER_STRICT_ORDER);

and the env_set: block reads both environment variables unconditionally:

	env = getenv(DRIVER_STRICT_ORDER);
	if (env)
		internals->en_loose_ordered = !atoi(env);

	env = getenv(DRIVER_DUMP_MODE);
	if (env) {
		dpaa2_sec_dp_dump = atoi(env);

With devargs "drv_dump_mode=2" and env drv_dump_mode=0, the first call sets dump mode 2 from devargs and returns; the second call finds no drv_strict_order key, jumps to env_set, and overwrites dpaa2_sec_dp_dump with 0 from the environment. The same happens in the other direction for en_loose_ordered. Read the env vars once after both devargs keys have been processed, and only for keys that were absent from devargs.

Warning: getenv() in a driver. Devargs already exist for both of these knobs; per-device runtime configuration belongs in devargs, and checkpatches flags getenv in drivers/ as a forbidden token. Lower-case names like "drv_strict_order" are also unusual for environment variables and easy to confuse with the devargs keys.

Patch 7: drivers: fix double free of dpaa2 device on uninit

Error: Moving dpaa2_dpdmai_dev_uninit() ahead of rte_dma_pmd_release() in dpaa2_qdma_remove() breaks both teardown orders.

	dpaa2_dpdmai_dev_uninit(dmadev);

	ret = rte_dma_pmd_release(dpaa2_dev->device.name);

(a) Application called rte_dma_close() before the device is removed (rte_dev_remove / hotplug unplug -> fslmc_bus_unplug_device -> drv->remove). rte_dma_close() -> dma_release() does memset(dev, 0, sizeof(struct rte_dma_dev)), so dpaa2_dev->dmadev points at a zeroed slot and dpaa2_dpdmai_dev_uninit() dereferences dev->data (NULL):

	struct dpaa2_dpdmai_dev *dpdmai_dev = dev->data->dev_private;

(b) Device removed without a prior close. uninit runs first, does rte_free(qdma_dev) and sets dpdmai_dev->qdma_dev = NULL. Then rte_dma_pmd_release() sees state READY, calls rte_dma_close() -> dpaa2_qdma_close(), which immediately returns:

	if (!qdma_dev)
		return 0;

so qdma_dev->vqs, the per-VQ fle_pool mempools, ring_cntx_idx and the Rx queue storage are never freed. Before this patch close ran uninit last, after freeing those. Suggested order in remove: if the dmadev is still READY call rte_dma_close() (or dpaa2_qdma_close()) first so the VQ resources are released, then dpdmai_close() the MC object and free qdma_dev, and only then rte_dma_pmd_release(); and guard uninit against a dmadev that has already been released.

Info: struct rte_dma_dev is used as a pointer member in bus_fslmc_driver.h without a forward declaration; adding "struct rte_dma_dev;" avoids an implicit file-scope tag declaration inside the struct.

Patch 8: net/dpaa2: fix integer overflow in CCSR region mapping

Warning: The fix is incomplete. page_size is validated, but the two lines immediately before still use the PAGE_MASK macro, which expands to ~(sysconf(_SC_PAGESIZE) - 1) and is the same unchecked signed value Coverity complained about:

	start = addr & PAGE_MASK;
	offset = addr - start;
	len = len & PAGE_MASK;

Compute a local mask from the validated page_size
(e.g. uint64_t page_mask = ~((uint64_t)page_size - 1)) and use it for start and len; the later "len & ~(page_size - 1)" is then redundant with the earlier "len = len & PAGE_MASK".

Review-Result: ERROR

#48 lore raw
In reply to Prashant Gupta
Quoted 7 lines · On Thu, 3 Sep 2026 19:23:08 +0530 Prashant Gupta <[email protected]>…

This series brings the NXP DPAA2 driver stack up to date with the functionality carried in the NXP internal tree, together with a number of bug fixes. It covers the crypto (dpaa2_sec), net, dma, mempool, event and bus/fslmc drivers.

Fixes first, then features, so the bug fixes can be picked independently of the larger reworks.

Another round of errors detected by Fable against 9-20.

DPAA2 series review (bundle 2096), patches 9-20 of 45
Base: upstream main d55ccd4; series applied with git am --3way.

Patch 9: dma/dpaa2: fix array-bounds warning in dequeue path

Warning: The warning this patch fixes does not exist at this point in the series. At patch 9, qdma_cntx_idx_ring_eq() is still the per-element loop:

	for (i = 0; i < nb; i++) {
		ring->cntx_idx_ring[ring->tail] = elem[i];

and passing &idx with nb == 1 indexes elem[0] only. The -Warray-bounds diagnostic comes from the rte_memcpy rewrite in patch 12, which forms &elem[DPAA2_QDMA_MAX_DESC - ring->tail] on a one-element object in the wrap-around branch. So this is not a fix for 388e888dc082 and should not carry Fixes:/Cc: stable; it belongs with patch 12.

The fix itself is heavy: DPAA2_QDMA_MAX_DESC is
((1 << 13) / 2) = 4096, so

	uint16_t idxs[DPAA2_QDMA_MAX_DESC];

adds 8 KB to every struct qdma_virt_queue and only idxs[0] is ever written. Handle the single-index case in ring_eq instead, e.g. compute first = RTE_MIN(nb, DPAA2_QDMA_MAX_DESC - ring->tail), copy first elements, and only touch elem + first when nb > first, which also gives the compiler a bound it can prove.

Patch 11: dma/dpaa2: validate IOVA in pre-populate helpers

Error: The new early returns leak the fle_pool element in non-silent mode. In dpaa2_qdma_copy_sg():

	ret = rte_mempool_get(qdma_vq->fle_pool,
		(void **)&cntx_sg);
	...
	ret = fle_sdd_sg_pre_populate(cntx_sg, qdma_vq);
	if (ret)
		return ret;

and in dpaa2_qdma_long_copy():

	ret = rte_mempool_get(qdma_vq->fle_pool,
		(void **)&fle_sdd);
	...
	ret = fle_sdd_pre_populate(fle_sdd,
		&qdma_vq->rbp,
		0, 0, QBMAN_FLE_WORD4_FMT_SBF);
	if (ret)
		return ret;

Neither path returns the context to the pool. Each failed enqueue permanently consumes one fle_pool element. Add rte_mempool_put() on the error path when !is_silent (the silent path uses the pre-allocated cntx_sg[]/cntx_fle_sdd[] arrays and needs no free).

Patch 13: drivers: add dpaa2 DMA bypass memory translation option

Error: RTE_DPAAX_QDMA_BMT_FLAG is only partially honoured.

(a) In the pre-populate SG path the flag is applied once, when the context is first initialised:

	if (unlikely(!fle[DPAA2_QDMA_SRC_FLE].length)) {
		ret = fle_sdd_sg_pre_populate(cntx_sg, qdma_vq,
			(flags & RTE_DPAAX_QDMA_BMT_FLAG) ?
			QDMA_SG_BMT_ENABLE : QDMA_SG_BMT_DISABLE);

sg_entry_post_populate() never writes ctrl.bmt, so every later job that picks this context out of fle_pool inherits whatever the first job asked for, regardless of its own flags.

(b) The long-FD path ignores the flag entirely. Neither fle_sdd_pre_populate() nor fle_populate() takes a bmt argument and nothing sets fle->word4.bmt, so on a vchan with using_short_fd == 0 (dpaa2_qdma_long_copy) the flag has no effect. The commit message says the flag is propagated to all FD populate helpers; it is not.

Warning: RTE_DPAAX_QDMA_BMT_FLAG is a new public API in an installed header (drivers/common/dpaax/meson.build lists rte_pmd_dpaax_qdma.h in headers) with no Doxygen comment, no mention in doc/guides/dmadevs/dpaa2.rst, and no release note. It also occupies bit 7, immediately below the RTE_DPAAX_QDMA index bits at 8+, and immediately above the generic RTE_DMA_OP_FLAG_* bits (0-3), so a future generic flag at bit 4-7 collides with it.

Patch 14: mempool/dpaa2: support ops index from primary in secondary

Error: rte_dpaa2_mpool_get_ops_idx() returns the wrong value on the first successful IPC round trip in a secondary:

	if (rsp_msg->msg_type == DPAA2_POOL_OPS_IDX_RSP) {
		rte_memcpy(&s_dpaa2_pool_ops_idx, rsp_msg->msg_data,
			sizeof(s_dpaa2_pool_ops_idx));
		ret = 0;
	} ...
	free(mp_reply.msgs);

	return ret;

It returns 0 instead of s_dpaa2_pool_ops_idx. Every caller compares the result against mb_pool->ops_index (dpaa2_sec enqueue, net Tx), so the first packet burst in a secondary process gets a false mismatch and takes the MAX_BPID path. Return s_dpaa2_pool_ops_idx on success.

Error: mp_req is an uninitialised stack struct:

	struct rte_mp_msg mp_req;
	...
	strlcpy(mp_req.name, DPAA2_POOL_MP_SYNC, sizeof(mp_req.name));
	req_msg->msg_type = DPAA2_POOL_OPS_IDX_REQ;
	...
	ret = rte_mp_request_sync(&mp_req, &mp_reply, &ts);

len_param and num_fds are never set. check_input() in eal_common_proc.c rejects negative or oversized values, and send_msg() attaches num_fds entries of fds[] as SCM_RIGHTS, so with stack garbage the request either fails outright or sends random descriptors. memset the request to zero and set mp_req.len_param = sizeof(struct dpaa2_pool_mp_msg) + sizeof(s_dpaa2_pool_ops_idx). The primary-side reply has the matching problem: reply is zeroed but reply.len_param stays 0 while param carries the ops index.

Error: Resource leak on the new failure path in
rte_hw_mbuf_create_pool():

	ret = rte_mp_action_register(DPAA2_POOL_MP_SYNC,
		dpaa2_mbuf_pool_mp_primary);
	if (ret && rte_errno != ENOTSUP)
		return ret;

At this point bp_list and bp_info are allocated, the dpbp is enabled and avail_dpbp is taken; every other failure in this function uses goto err4. Replace the return with goto err4. rte_mp_action_register() also returns -1 with the reason in rte_errno, so the caller sees a bare -1; return -rte_errno.

Warning: rte_memcpy() for a 2-byte copy on the IPC control path (both in the handler and in the requester); use memcpy().

Patch 16: drivers: optimize dpaa2 Tx queue and channel mapping

Error: The new capping logic is defeated by uint8_t truncation. priv->nb_rx_queues and priv->nb_tx_queues are uint8_t, and attr.num_rx_tcs, attr.num_tx_tcs and attr.num_queues are uint8_t:

	priv->nb_rx_queues = attr.num_rx_tcs * attr.num_queues;
	if (priv->nb_rx_queues > MAX_RX_QUEUES) {
	...
	priv->nb_tx_queues = attr.num_tx_tcs * attr.num_queues;
	if (priv->nb_tx_queues > MAX_TX_QUEUES) {

The product is computed as int and truncated to 8 bits on assignment before the comparison, so a DPNI with 8 TCs and 32 queues per TC (256) yields nb_rx_queues = nb_tx_queues = 0 and the "Too many" branch never fires. Compute into a uint32_t local, cap, then assign. The TX side is new in this patch (the old value was num_tx_tcs * num_channels, which cannot overflow); the RX side overflowed before too but is rewritten here.

Related: capping the total to 128 rather than the per-TC count makes tc_index = i / (128 / num_tx_tc) exceed num_tx_tc when num_tx_tc does not divide 128 (e.g. 3 TCs -> per_tc 42, i = 126, 127 map to TC 3). Cap num_queue_per_tc instead and derive the totals from that.

Error: The new early return in dpaa2_dev_rx_queue_setup() breaks Rx queue reconfiguration:

	if (dpaa2_q->fqid != DPAA2_INVALID_FQ_ID) {
		DPAA2_PMD_WARN("%s: RXQ[%d] has been setup",
			dev->data->name, rx_queue_id);
		dev->data->rx_queues[rx_queue_id] = dpaa2_q;
		return 0;
	}

dpaa2_dev_rx_queue_release() does not reset fqid to DPAA2_INVALID_FQ_ID, so the stop / reconfigure / rx_queue_setup sequence that rte_eth_rx_queue_setup() performs (release, then setup) hits this return and silently keeps the old mb_pool, nb_desc and offloads. Worse, release cleared the CGID (priv->cgid_in_use[cgid] = 0; dpaa2_q->cgid = DPAA2_INVALID_CGID) and the early return skips the block that allocates a new one and programs taildrop / congestion notification, so the queue runs without its drop configuration after any reconfigure. Either reset fqid in rx_queue_release, or drop the early return on the Rx side (the Tx side had the same pattern before this patch via DPAA2_INVALID_FLOW_ID, and tx_queue_release should be checked for the same reason).

Patch 17: net/dpaa2: support larger burst size

Warning: The version gate excludes newer major versions:

	if (priv->dpni_ver_major == 8 && priv->dpni_ver_minor >= 7)

A DPNI API 9.x would fall back to 64 KB. dpaa2_ethdev.h already has dpaa2_dev_cmp_dpni_ver(priv, major, minor); use dpaa2_dev_cmp_dpni_ver(priv, 8, 7) >= 0.

Warning: The new header comment and the code disagree on the non-LX2160A limit. fsl_dpni.h says:

	* @max_burst_size:	Burst size in bytes. Limits depend on the SoC
	*		(0x37FFF for LX2160A, 0xF7FF for all others)

but dpaa2_get_burst_max() returns (64 * 1024) = 0x10000 for "all others", which is above 0xF7FF. One of the two is wrong.

Patch 18: net/dpaa2: support MPLS and PPPoE flow distribution

Warning: doc/guides/nics/features/dpaa2.ini is not updated; the [rte_flow items] section needs mpls and pppoes entries for the new pattern support.

Patch 19: net/dpaa2: support meter and policing

Error: dpaa2_mtr_ops_get() re-initialises the lock on every call:

	int
	dpaa2_mtr_ops_get(struct rte_eth_dev *dev, void *ops)
	{
		struct dpaa2_dev_priv *priv = dev->data->dev_private;

		rte_spinlock_init(&priv->meter_lock);

rte_mtr_ops_get() in lib/ethdev/rte_mtr.c calls dev->dev_ops->mtr_ops_get() at the start of every rte_mtr_*() API call, so any concurrent rte_mtr call resets a spinlock that another thread may currently hold, and the list manipulation it protects is then unprotected. Initialise the lock once in dpaa2_dev_init() next to the LIST_HEAD fields.

Warning: dpaa2_mtr_profile_delete() and dpaa2_mtr_policy_delete() walk priv->meters and silently free every meter that references the profile/policy:

	if (meter->profile_id == profile_id) {
		...
		LIST_REMOVE(tmp, next);
		rte_free(tmp);

rte_mtr.h documents both operations as failing when at least one MTR object still uses the profile/policy. Return -EBUSY instead; otherwise the application keeps a meter id that no longer exists and any flow created with it (patch 37 wires meters into dpni_set_rx_tc_policing) is left pointing at a freed object.

Warning: No documentation for the new feature: nothing in doc/guides/nics/features/dpaa2.ini, doc/guides/nics/dpaa2.rst, or the 26.11 release notes. (The series as a whole adds nothing under doc/.)

Info: In dpaa2_mtr_profile_add():

	} else if (profile->packet_mode > DPNI_POLICER_UNIT_FRAMES) {
		dpaa2_profile->policer_unit =
			DPNI_POLICER_UNIT_BYTES_L2_WITHOUT_FCS;

rte_mtr_meter_profile.packet_mode is a 0/1 flag and DPNI_POLICER_UNIT_FRAMES is 1, so this branch is unreachable.

Info: s_err_msg is a single static buffer shared by every port and thread, and its address is handed to the caller via rte_mtr_error_set(); concurrent callers can see each other's message. dpaa2_mtr_policy_add() returns ENOMEM for "action not supported" (should be ENOTSUP), and dpaa2_mtr_profile_add() returns -ENOTSUP without filling in *error. struct dpaa2_dev_meter_policy's red_drop is an int holding a bool.

Review-Result: ERROR

#49 lore raw
In reply to Prashant Gupta
Quoted 7 lines · On Thu, 3 Sep 2026 19:23:08 +0530 Prashant Gupta <[email protected]>…

This series brings the NXP DPAA2 driver stack up to date with the functionality carried in the NXP internal tree, together with a number of bug fixes. It covers the crypto (dpaa2_sec), net, dma, mempool, event and bus/fslmc drivers.

Fixes first, then features, so the bug fixes can be picked independently of the larger reworks.

And the errors caught by Fable continue in Patch 21-32

DPAA2 series review (bundle 2096), patches 9-20 of 45
Base: upstream main d55ccd4; series applied with git am --3way.

Patch 9: dma/dpaa2: fix array-bounds warning in dequeue path

Warning: The warning this patch fixes does not exist at this point in the series. At patch 9, qdma_cntx_idx_ring_eq() is still the per-element loop:

	for (i = 0; i < nb; i++) {
		ring->cntx_idx_ring[ring->tail] = elem[i];

and passing &idx with nb == 1 indexes elem[0] only. The -Warray-bounds diagnostic comes from the rte_memcpy rewrite in patch 12, which forms &elem[DPAA2_QDMA_MAX_DESC - ring->tail] on a one-element object in the wrap-around branch. So this is not a fix for 388e888dc082 and should not carry Fixes:/Cc: stable; it belongs with patch 12.

The fix itself is heavy: DPAA2_QDMA_MAX_DESC is
((1 << 13) / 2) = 4096, so

	uint16_t idxs[DPAA2_QDMA_MAX_DESC];

adds 8 KB to every struct qdma_virt_queue and only idxs[0] is ever written. Handle the single-index case in ring_eq instead, e.g. compute first = RTE_MIN(nb, DPAA2_QDMA_MAX_DESC - ring->tail), copy first elements, and only touch elem + first when nb > first, which also gives the compiler a bound it can prove.

Patch 11: dma/dpaa2: validate IOVA in pre-populate helpers

Error: The new early returns leak the fle_pool element in non-silent mode. In dpaa2_qdma_copy_sg():

	ret = rte_mempool_get(qdma_vq->fle_pool,
		(void **)&cntx_sg);
	...
	ret = fle_sdd_sg_pre_populate(cntx_sg, qdma_vq);
	if (ret)
		return ret;

and in dpaa2_qdma_long_copy():

	ret = rte_mempool_get(qdma_vq->fle_pool,
		(void **)&fle_sdd);
	...
	ret = fle_sdd_pre_populate(fle_sdd,
		&qdma_vq->rbp,
		0, 0, QBMAN_FLE_WORD4_FMT_SBF);
	if (ret)
		return ret;

Neither path returns the context to the pool. Each failed enqueue permanently consumes one fle_pool element. Add rte_mempool_put() on the error path when !is_silent (the silent path uses the pre-allocated cntx_sg[]/cntx_fle_sdd[] arrays and needs no free).

Patch 13: drivers: add dpaa2 DMA bypass memory translation option

Error: RTE_DPAAX_QDMA_BMT_FLAG is only partially honoured.

(a) In the pre-populate SG path the flag is applied once, when the context is first initialised:

	if (unlikely(!fle[DPAA2_QDMA_SRC_FLE].length)) {
		ret = fle_sdd_sg_pre_populate(cntx_sg, qdma_vq,
			(flags & RTE_DPAAX_QDMA_BMT_FLAG) ?
			QDMA_SG_BMT_ENABLE : QDMA_SG_BMT_DISABLE);

sg_entry_post_populate() never writes ctrl.bmt, so every later job that picks this context out of fle_pool inherits whatever the first job asked for, regardless of its own flags.

(b) The long-FD path ignores the flag entirely. Neither fle_sdd_pre_populate() nor fle_populate() takes a bmt argument and nothing sets fle->word4.bmt, so on a vchan with using_short_fd == 0 (dpaa2_qdma_long_copy) the flag has no effect. The commit message says the flag is propagated to all FD populate helpers; it is not.

Warning: RTE_DPAAX_QDMA_BMT_FLAG is a new public API in an installed header (drivers/common/dpaax/meson.build lists rte_pmd_dpaax_qdma.h in headers) with no Doxygen comment, no mention in doc/guides/dmadevs/dpaa2.rst, and no release note. It also occupies bit 7, immediately below the RTE_DPAAX_QDMA index bits at 8+, and immediately above the generic RTE_DMA_OP_FLAG_* bits (0-3), so a future generic flag at bit 4-7 collides with it.

Patch 14: mempool/dpaa2: support ops index from primary in secondary

Error: rte_dpaa2_mpool_get_ops_idx() returns the wrong value on the first successful IPC round trip in a secondary:

	if (rsp_msg->msg_type == DPAA2_POOL_OPS_IDX_RSP) {
		rte_memcpy(&s_dpaa2_pool_ops_idx, rsp_msg->msg_data,
			sizeof(s_dpaa2_pool_ops_idx));
		ret = 0;
	} ...
	free(mp_reply.msgs);

	return ret;

It returns 0 instead of s_dpaa2_pool_ops_idx. Every caller compares the result against mb_pool->ops_index (dpaa2_sec enqueue, net Tx), so the first packet burst in a secondary process gets a false mismatch and takes the MAX_BPID path. Return s_dpaa2_pool_ops_idx on success.

Error: mp_req is an uninitialised stack struct:

	struct rte_mp_msg mp_req;
	...
	strlcpy(mp_req.name, DPAA2_POOL_MP_SYNC, sizeof(mp_req.name));
	req_msg->msg_type = DPAA2_POOL_OPS_IDX_REQ;
	...
	ret = rte_mp_request_sync(&mp_req, &mp_reply, &ts);

len_param and num_fds are never set. check_input() in eal_common_proc.c rejects negative or oversized values, and send_msg() attaches num_fds entries of fds[] as SCM_RIGHTS, so with stack garbage the request either fails outright or sends random descriptors. memset the request to zero and set mp_req.len_param = sizeof(struct dpaa2_pool_mp_msg) + sizeof(s_dpaa2_pool_ops_idx). The primary-side reply has the matching problem: reply is zeroed but reply.len_param stays 0 while param carries the ops index.

Error: Resource leak on the new failure path in
rte_hw_mbuf_create_pool():

	ret = rte_mp_action_register(DPAA2_POOL_MP_SYNC,
		dpaa2_mbuf_pool_mp_primary);
	if (ret && rte_errno != ENOTSUP)
		return ret;

At this point bp_list and bp_info are allocated, the dpbp is enabled and avail_dpbp is taken; every other failure in this function uses goto err4. Replace the return with goto err4. rte_mp_action_register() also returns -1 with the reason in rte_errno, so the caller sees a bare -1; return -rte_errno.

Warning: rte_memcpy() for a 2-byte copy on the IPC control path (both in the handler and in the requester); use memcpy().

Patch 16: drivers: optimize dpaa2 Tx queue and channel mapping

Error: The new capping logic is defeated by uint8_t truncation. priv->nb_rx_queues and priv->nb_tx_queues are uint8_t, and attr.num_rx_tcs, attr.num_tx_tcs and attr.num_queues are uint8_t:

	priv->nb_rx_queues = attr.num_rx_tcs * attr.num_queues;
	if (priv->nb_rx_queues > MAX_RX_QUEUES) {
	...
	priv->nb_tx_queues = attr.num_tx_tcs * attr.num_queues;
	if (priv->nb_tx_queues > MAX_TX_QUEUES) {

The product is computed as int and truncated to 8 bits on assignment before the comparison, so a DPNI with 8 TCs and 32 queues per TC (256) yields nb_rx_queues = nb_tx_queues = 0 and the "Too many" branch never fires. Compute into a uint32_t local, cap, then assign. The TX side is new in this patch (the old value was num_tx_tcs * num_channels, which cannot overflow); the RX side overflowed before too but is rewritten here.

Related: capping the total to 128 rather than the per-TC count makes tc_index = i / (128 / num_tx_tc) exceed num_tx_tc when num_tx_tc does not divide 128 (e.g. 3 TCs -> per_tc 42, i = 126, 127 map to TC 3). Cap num_queue_per_tc instead and derive the totals from that.

Error: The new early return in dpaa2_dev_rx_queue_setup() breaks Rx queue reconfiguration:

	if (dpaa2_q->fqid != DPAA2_INVALID_FQ_ID) {
		DPAA2_PMD_WARN("%s: RXQ[%d] has been setup",
			dev->data->name, rx_queue_id);
		dev->data->rx_queues[rx_queue_id] = dpaa2_q;
		return 0;
	}

dpaa2_dev_rx_queue_release() does not reset fqid to DPAA2_INVALID_FQ_ID, so the stop / reconfigure / rx_queue_setup sequence that rte_eth_rx_queue_setup() performs (release, then setup) hits this return and silently keeps the old mb_pool, nb_desc and offloads. Worse, release cleared the CGID (priv->cgid_in_use[cgid] = 0; dpaa2_q->cgid = DPAA2_INVALID_CGID) and the early return skips the block that allocates a new one and programs taildrop / congestion notification, so the queue runs without its drop configuration after any reconfigure. Either reset fqid in rx_queue_release, or drop the early return on the Rx side (the Tx side had the same pattern before this patch via DPAA2_INVALID_FLOW_ID, and tx_queue_release should be checked for the same reason).

Patch 17: net/dpaa2: support larger burst size

Warning: The version gate excludes newer major versions:

	if (priv->dpni_ver_major == 8 && priv->dpni_ver_minor >= 7)

A DPNI API 9.x would fall back to 64 KB. dpaa2_ethdev.h already has dpaa2_dev_cmp_dpni_ver(priv, major, minor); use dpaa2_dev_cmp_dpni_ver(priv, 8, 7) >= 0.

Warning: The new header comment and the code disagree on the non-LX2160A limit. fsl_dpni.h says:

	* @max_burst_size:	Burst size in bytes. Limits depend on the SoC
	*		(0x37FFF for LX2160A, 0xF7FF for all others)

but dpaa2_get_burst_max() returns (64 * 1024) = 0x10000 for "all others", which is above 0xF7FF. One of the two is wrong.

Patch 18: net/dpaa2: support MPLS and PPPoE flow distribution

Warning: doc/guides/nics/features/dpaa2.ini is not updated; the [rte_flow items] section needs mpls and pppoes entries for the new pattern support.

Patch 19: net/dpaa2: support meter and policing

Error: dpaa2_mtr_ops_get() re-initialises the lock on every call:

	int
	dpaa2_mtr_ops_get(struct rte_eth_dev *dev, void *ops)
	{
		struct dpaa2_dev_priv *priv = dev->data->dev_private;

		rte_spinlock_init(&priv->meter_lock);

rte_mtr_ops_get() in lib/ethdev/rte_mtr.c calls dev->dev_ops->mtr_ops_get() at the start of every rte_mtr_*() API call, so any concurrent rte_mtr call resets a spinlock that another thread may currently hold, and the list manipulation it protects is then unprotected. Initialise the lock once in dpaa2_dev_init() next to the LIST_HEAD fields.

Warning: dpaa2_mtr_profile_delete() and dpaa2_mtr_policy_delete() walk priv->meters and silently free every meter that references the profile/policy:

	if (meter->profile_id == profile_id) {
		...
		LIST_REMOVE(tmp, next);
		rte_free(tmp);

rte_mtr.h documents both operations as failing when at least one MTR object still uses the profile/policy. Return -EBUSY instead; otherwise the application keeps a meter id that no longer exists and any flow created with it (patch 37 wires meters into dpni_set_rx_tc_policing) is left pointing at a freed object.

Warning: No documentation for the new feature: nothing in doc/guides/nics/features/dpaa2.ini, doc/guides/nics/dpaa2.rst, or the 26.11 release notes. (The series as a whole adds nothing under doc/.)

Info: In dpaa2_mtr_profile_add():

	} else if (profile->packet_mode > DPNI_POLICER_UNIT_FRAMES) {
		dpaa2_profile->policer_unit =
			DPNI_POLICER_UNIT_BYTES_L2_WITHOUT_FCS;

rte_mtr_meter_profile.packet_mode is a 0/1 flag and DPNI_POLICER_UNIT_FRAMES is 1, so this branch is unreachable.

Info: s_err_msg is a single static buffer shared by every port and thread, and its address is handed to the caller via rte_mtr_error_set(); concurrent callers can see each other's message. dpaa2_mtr_policy_add() returns ENOMEM for "action not supported" (should be ENOTSUP), and dpaa2_mtr_profile_add() returns -ENOTSUP without filling in *error. struct dpaa2_dev_meter_policy's red_drop is an int holding a bool.

Review-Result: ERROR

#50 lore raw
In reply to Prashant Gupta
Quoted 4 lines · On Thu, 3 Sep 2026 19:23:08 +0530 Prashant Gupta <[email protected]>…

This series brings the NXP DPAA2 driver stack up to date with the functionality carried in the NXP internal tree, together with a number of bug fixes. It covers the crypto (dpaa2_sec), net, dma, mempool, event and bus/fslmc drivers.

Recommendation, break this up. There are too many errors to allow merging now. But if you break it up some of the chunks might be ok.
For example: send the bug fixes only as short series.

The problem is you are working away from upstream. That process will exhaust you because you end up fixing things in multiple places. For example: patch 24 removes a guard that 57b8ce0 added upstream in July

#51 lore raw
In reply to Prashant Gupta
Quoted 7 lines · On Thu, 3 Sep 2026 19:23:08 +0530 Prashant Gupta <[email protected]>…

This series brings the NXP DPAA2 driver stack up to date with the functionality carried in the NXP internal tree, together with a number of bug fixes. It covers the crypto (dpaa2_sec), net, dma, mempool, event and bus/fslmc drivers.

Fixes first, then features, so the bug fixes can be picked independently of the larger reworks.

AI found errors in last set:

DPAA2 series review (bundle 2096), patches 32-45 of 45
Base: upstream main d55ccd4; series applied with git am --3way. Findings for 32 supersede the partial entry in the 21-32 review.

Patch 32: drivers: rework dpaa2 Tx confirmation

Error: priv->tx_sg_pool is never assigned. The patch adds the field to struct dpaa2_dev_priv and reads it in dpaa2_dev_tx_mbuf_to_sg_fd():

	sg_mbuf = NULL;
	if (priv->tx_sg_pool)
		sg_mbuf = rte_pktmbuf_alloc(priv->tx_sg_pool);
	if (!sg_mbuf) {
		DPAA2_PMD_DP_DEBUG("No memory to allocate S/G table");
		return -ENOMEM;
	}

but dpaa2_tx_sg_pool_init() only sets the file-scope global dpaa2_tx_sg_pool, and a grep of the final tree finds no store to the priv member. priv is zero-allocated, so every multi-segment Tx whose head mbuf cannot host the SG table in its own headroom (any non-hw-pool head, any indirect head, or too little headroom) fails with -ENOMEM. The old code used dpaa2_tx_sg_pool directly.

Error: Per-packet failures free the application's mbuf and then report it as not sent. In dpaa2_dev_tx_mbuf_to_simple_fd():

	} else {
		copy_mbuf = dpaa2_dev_mbuf_copy_one_seg(mbuf, hw_mp);
		if (!copy_mbuf) {
			ret = -ENOMEM;
			goto quit;
		}
		DPAA2_MBUF_TO_CONTIG_FD(copy_mbuf, fd, mempool_to_bpid(hw_mp));
quit:
		rte_pktmbuf_free(mbuf);
	}

and in dpaa2_dev_tx():

	ret = dpaa2_dev_tx_mbuf_to_simple_fd(hw_mp, *bufs, &fd_arr[loop],
		dpaa2_q, priv->tx_conf_type, &dy_conf[loop], tstamp[loop]);
	...
	if (ret)
		goto send_n_return;

send_n_return enqueues fd_arr[0..loop-1] and returns that count, so the packet at index loop is excluded from the return value after the driver has already freed it; the application retries it and double-frees. The same happens in dpaa2_dev_tx_multi_txq_ordered() via send_frames. The cloned-mbuf branch just above it has the same shape: the indirect mbuf is re-initialised and freed before the copy is attempted. And dpaa2_dev_tx_no_conf_mbuf_to_sge() can return -ENOMEM part way through a chain after it has already replaced earlier segments, relinked prev->next, and decremented refcounts on segments with refcnt > 1; that mutated chain is then handed back to the application as unsent, and the sg_mbuf taken from tx_sg_pool in the caller is leaked. A per-packet failure must either drop the packet (free it, count it in err_pkts, continue) or leave it untouched and return short; doing both is a double free.

Error: The DQRR held-buffer bitmap update regresses a 64-bit shift:

	DPAA2_PER_LCORE_DQRR_HELD &= ~(1 << dqrr_index);

The line this replaces was ~(UINT64_C(1) << dqrr_index), and the other three sites in the file still use UINT64_C(1). dqrr_held is uint64_t and dqrr_index reaches 31 on LX2160A (DPAA2_LX2_DQRR_RING_SIZE is 32, and patch 41 raises the event port dequeue depth to that), so 1 << 31 is int, sign-extends, and the ~ clears bits 0..30 of the upper word as well.

Warning: New devargs drv_tx_dyn_conf and drv_tx_dyn_conf_pre are added and drv_tx_conf now means "absolute confirmation", but doc/guides/nics/dpaa2.rst, which documents drv_tx_conf, is untouched.

Warning: dpaa2_eth_fd_to_mbuf() and dpaa2_eth_sg_fd_to_mbuf() are annotated __rte_internal in dpaa2_ethdev.h. That attribute is for symbols exported with RTE_EXPORT_INTERNAL_SYMBOL; these are used only inside the net driver.

Info: dpaa2_dev_tx_conf() releases a head mbuf with refcnt > 1 by rte_mbuf_refcnt_update(m, -1) instead of rte_pktmbuf_free(m), so the tail segments of such a chain are never walked. rte_pktmbuf_free() handles each segment's refcount itself; the special case is not needed.

Patch 33: net/dpaa2: ptp enhancements

Error: Two exported experimental APIs are deleted without deprecation and without removing their declarations. The definitions of rte_pmd_dpaa2_set_one_step_ts() and rte_pmd_dpaa2_get_one_step_ts() (both RTE_EXPORT_EXPERIMENTAL_SYMBOL, 24.11) are removed from dpaa2_ethdev.c and not re-added anywhere; the prototypes remain in the installed header rte_pmd_dpaa2.h, so any consumer now fails at link time. Either keep the symbols (wrapping the new dpaa2_timesync_set_one_step()) or remove the prototypes and add a "Removed Items" release note.

Warning: getenv("DPAA2_IEEE1588_DEBUG_ENABLE") in dpaa2_timesync_enable(); use a devargs or log level.

Patch 35: net/dpaa2: update MC dpni QoS and flow steering API

Warning: The existing callers are switched to newer MC command versions with no version gate. DPNI_CMDID_ADD_FS_ENT becomes DPNI_CMD_V3, DPNI_CMDID_SET_QOS_TBL becomes DPNI_CMD_V3 and DPNI_CMDID_SET_RX_TC_POLICING becomes DPNI_CMD_V2, and the flow code at this point still calls dpni_add_fs_entry() and dpni_set_qos_table() unconditionally, so on an MC that predates those command versions every existing flow rule fails. The commit message says behaviour is unchanged. Patch 37 adds the priv->mc_rev gating (DPAA2_FLOW_FRM_REPLICATION_ACTION_MC_REV etc.); it belongs in this patch, next to the version bump.

Patch 36: net/dpaa2: enhance xstat implementation

Error: dpaa2_dev_xstats_get_by_id() does not bound the number of MAC counters it collects:

	uint64_t *mac_val[DPAA2_MAC_XSTAT_MAX_NUM];
	...
	for (i = 0; i < n; i++) {
		...
		if (id >= DPAA2_MAC_XSTATS_START_ID) {
			values[i] = 0;
			if (dpaa2_dev_mac_xstats_avail(dev)) {
				mac_idx[mac_num] = rte_cpu_to_le_32(id - DPAA2_MAC_XSTATS_START_ID);
				mac_val[mac_num] = &values[i];
				mac_num++;
			}

ids[] is application-supplied and may repeat an id, so n MAC ids overflow mac_val[] on the stack and the fixed-size cnt_idx_dma_mem / cnt_values_dma_mem buffers. Check mac_num < DPAA2_MAC_XSTAT_MAX_NUM before the stores.

Warning: dpaa2_dev_xstats_get_names() returns limit when limit is smaller than the count:

	if (limit < stat_cnt)
		stat_cnt = limit;

The eth_xstats_get_names_t contract is to return the number of available xstats when xstats_names is NULL or size is too small, so the caller can resize. Same in dpaa2_dev_xstats_get() when n is smaller than the count.

Warning: rte_memcpy() of the string-pointer table (dpaa2_xstats_strings) on the control path in both get_names functions; memcpy, or index the struct directly.

Patch 37: net/dpaa2: rework flow engine

Warning: The QoS/FS group-type machinery is unreachable upstream:

	#ifndef RTE_DPAA2_FLOW_GROUP_TYPE_GET
	#define RTE_DPAA2_FLOW_GROUP_TYPE_GET(group) \
		((void)(group), RTE_DPAA2_ONE_LEVEL_GROUP_FLOW)
	#endif

Nothing in the tree defines the real macros, so RTE_DPAA2_QOS_GROUP_FLOW / RTE_DPAA2_FS_GROUP_FLOW and every branch keyed on them in dpaa2_flow_create() are dead code kept alive for an out-of-tree header. Either define the encoding in rte_pmd_dpaa2.h and document it, or drop the group-type paths.

Warning: getenv("DPAA2_FLOW_CONTROL_LOG") is kept (now read on every rte_flow_create()); use the log level.

Warning: dpaa2_flow.c goes from 1 to 13 rte_memcpy() calls, all on the flow-create control path (e.g. rte_memcpy(&local_attr, attr, sizeof(struct rte_flow_attr))); use memcpy.

Warning: No doc/guides/nics/features/dpaa2.ini update for the new meter_mark action, and no dpaa2.rst description of the group encoding, meter flows, or the MC-version-dependent behaviour.

Patch 38: net/dpaa2: support Rx mempool per traffic class

Error: The pool-to-TC association is programmed with the TC index where the MC expects a bitmask:

	bpool_cfg->pools[bp_idx].priority_mask = tc_id;

fsl_dpni.h documents pools.priority as "Priority mask that indicates TC's used with this buffer. If set to 0x00 MC will assume value 0xff". With tc_id: TC0 gets mask 0 (= all TCs), TC1 gets 0x01 (= TC0), TC2 gets 0x02 (= TC1), and so on, so the isolation the commit describes does not happen and TC0's pool is shared by everyone. Use RTE_BIT32(tc_id).

Patch 39: drivers: consume dpaa2 DQRR entries in batches

Error: The consume vector cannot represent an LX2160A DQRR. The patch's own comment says the vector occupies DCAP bits 16..31, i.e. 16 index bits, and the code does:

	s->dqrr.ci_vector |= RTE_BIT32(idx + DQRR_DCAP_CI_VEC_OFFSET);

with ci_vector a uint32_t. DPAA2_LX2_DQRR_RING_SIZE is 32, so idx is 0..31 and idx + 16 is 16..47; for idx >= 16 that is a shift of 32 or more, undefined behaviour, and the entry is never consumed. Either the register is wider than the comment says, or vector mode must only be enabled when dqrr_size <= 16 (with the threshold derived accordingly).

Patch 42: net/dpaa2: read MC version from device private data

Info: This only replaces the DPAA2_DEV_PRIV_TO_DPAA2_DEV() accessor that patch 37 introduced five patches earlier; fold it into 37.

Patch 44: bus/fslmc: reduce probe-time logging and MC traffic

Info: The duplicated mc_get_soc_version() call this removes was added by patch 27 in the same series; fold it into 27.

Review-Result: ERROR

#52 lore raw

v2 cover NXP DPAA2 driver updates and fixes

In reply to Prashant Gupta

This series brings the NXP DPAA2 drivers (net, crypto, dma, event, mempool and the fslmc bus) up to date with the current internal tree. It carries bug fixes, a reworked flow engine, an extended parser, meter and policer support, PTP enhancements, and a number of performance improvements in the Rx/Tx and DQRR handling paths.

The series is based on commit c1a46b9d9243 and is intended for 26.11.

Changes in v2:

- Dropped the header-only patches; every remaining patch now contains the implementation together with its declarations.
- Addressed all findings reported by checkpatch; the series is clean against the current checkpatch.
- Removed the per-device Tx scatter/gather pool member that was never assigned, and used the existing global pool instead.
- Widened the DQRR held-mask shift to 64-bit to avoid undefined behaviour when the DQRR index exceeds 31.
- Bounded the MAC xstats collection loop by the size of the statistics array.
- Treated the traffic class priority mask as a bitmask rather than an index.
- Added a per-entry DQRR consume fallback for portals whose DQRR ring does not fit the vectored consume encoding.

Each of the review fixes above has been folded into the patch that introduced the code in question, so the series remains bisectable.

Build tested with gcc, clang and the aarch64 DPAA cross toolchain (werror enabled, no compiler warnings).

Gagandeep Singh (18):
crypto/dpaa2_sec: fix buffer overflow in GCM decrypt crypto/dpaa2_sec: fix FLE pool leak on sec FD build failure crypto/dpaa2_sec: support AES-GMAC crypto/dpaa2_sec: increase ivsize range for AES-CTR crypto/dpaa2_sec: add missing ECN capability crypto/dpaa2_sec: add support for env variables dma/dpaa2: validate IOVA in pre-populate helpers dma/dpaa2: optimize context index ring enqueue
drivers: add dpaa2 DMA bypass memory translation option net/dpaa2: set Tx confirmation on device init
drivers: optimize dpaa2 Tx queue and channel mapping net/dpaa2: support larger burst size
net/dpaa2: support MPLS and PPPoE flow distribution net/dpaa2: support meter and policing
net/dpaa2: support flow drop action
net/dpaa2: set default flow miss action per device net/dpaa2: identify Rx mbuf hash information by FLC net/dpaa2: enhance xstat implementation

Hemant Agrawal (17):
net/dpaa2: fix integer overflow in CCSR region mapping net/dpaa2: add minimum key size support net/dpaa2: restructure dpaa2 parser processing net/dpaa2: parse tunnel and fragmented packet types net/dpaa2: remove unused soft parser Tx code net/dpaa2: update MC dpni QoS and flow steering API net/dpaa2: rework flow engine
net/dpaa2: support GENEVE flow item
net/dpaa2: support flow meter and policer actions net/dpaa2: support flow table miss actions
drivers: consume dpaa2 DQRR entries in batches
drivers: resolve dpaa2 endpoint in the net driver
drivers: align dpaa2 event port depths with hardware rings net/dpaa2: read MC version from device private data net/dpaa2: do not overwrite mbuf hash with drop priority bus/fslmc: reduce probe-time logging and MC traffic net/dpaa2: reject Rx queue deferred start

Jun Yang (11):
dma/dpaa2: fix array-bounds warning in dequeue path mempool/dpaa2: support ops index from primary in secondary net/dpaa2: remove unused soft parser driver
drivers: refresh dpaa2 MC and SoC version info
drivers: identify dpaa2 soft parser protocol
drivers: assign dpaa2 Rx CGID per traffic class
drivers: inherit dpaa2 rxq config for event queue net/dpaa2: rename Rx queue flags
drivers: rework dpaa2 Tx confirmation
net/dpaa2: ptp enhancements
net/dpaa2: support Rx mempool per traffic class

Prashant Gupta (1):
bus/fslmc: defer bus initialization to probe

 doc/guides/rel_notes/release_26_11.rst        |    6 +
 drivers/bus/fslmc/bus_fslmc_driver.h          |   14 +-
 drivers/bus/fslmc/fslmc_bus.c                 |  177 +-
 drivers/bus/fslmc/fslmc_vfio.c                |  196 +-
 drivers/bus/fslmc/fslmc_vfio.h                |   30 +-
 drivers/bus/fslmc/portal/dpaa2_hw_dpio.c      |   83 +-
 drivers/bus/fslmc/portal/dpaa2_hw_dpio.h      |    7 -
 drivers/bus/fslmc/portal/dpaa2_hw_dprc.c      |   45 +-
 drivers/bus/fslmc/portal/dpaa2_hw_pvt.h       |    7 +-
 drivers/bus/fslmc/private.h                   |    3 +
 .../fslmc/qbman/include/fsl_qbman_portal.h    |   12 +-
 drivers/bus/fslmc/qbman/qbman_portal.c        |   83 +-
 drivers/bus/fslmc/qbman/qbman_portal.h        |   11 +-
 drivers/common/dpaax/rte_pmd_dpaax_qdma.h     |    4 +-
 drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c   |   98 +-
 drivers/crypto/dpaa2_sec/dpaa2_sec_priv.h     |   45 +-
 drivers/dma/dpaa2/dpaa2_qdma.c                |  155 +-
 drivers/dma/dpaa2/dpaa2_qdma.h                |    1 +
 drivers/event/dpaa2/dpaa2_eventdev.c          |   76 +-
 drivers/event/dpaa2/dpaa2_eventdev.h          |    4 +-
 drivers/mempool/dpaa2/dpaa2_hw_mempool.c      |   88 +-
 drivers/net/dpaa2/base/dpaa2_hw_dpni.c        |  546 --
 drivers/net/dpaa2/base/dpaa2_hw_dpni_annot.h  |    6 +-
 drivers/net/dpaa2/dpaa2_ethdev.c              | 2135 +++--
 drivers/net/dpaa2/dpaa2_ethdev.h              |  759 +-
 drivers/net/dpaa2/dpaa2_flow.c                | 6966 ++++++++++-------
 drivers/net/dpaa2/dpaa2_meter.c               |  588 ++
 drivers/net/dpaa2/dpaa2_parse_dump.h          |  374 -
 drivers/net/dpaa2/dpaa2_parser_decode.h       | 1545 ++++
 drivers/net/dpaa2/dpaa2_ptp.c                 |  161 +-
 drivers/net/dpaa2/dpaa2_recycle.c             |   37 +-
 drivers/net/dpaa2/dpaa2_rxtx.c                | 1902 ++---
 drivers/net/dpaa2/dpaa2_sparser.c             |  137 -
 drivers/net/dpaa2/dpaa2_sparser.h             |  202 -
 drivers/net/dpaa2/dpaa2_tm.c                  |   16 +-
 drivers/net/dpaa2/mc/dpni.c                   |  138 +-
 drivers/net/dpaa2/mc/fsl_dpni.h               |  390 +-
 drivers/net/dpaa2/mc/fsl_dpni_cmd.h           |   33 +-
 drivers/net/dpaa2/meson.build                 |    5 +-
 lib/cryptodev/rte_crypto_sym.h                |    2 +
 lib/cryptodev/rte_cryptodev.c                 |    1 +
 41 files changed, 10532 insertions(+), 6556 deletions(-)
 delete mode 100644 drivers/net/dpaa2/base/dpaa2_hw_dpni.c
 create mode 100644 drivers/net/dpaa2/dpaa2_meter.c
 delete mode 100644 drivers/net/dpaa2/dpaa2_parse_dump.h
 create mode 100644 drivers/net/dpaa2/dpaa2_parser_decode.h
 delete mode 100644 drivers/net/dpaa2/dpaa2_sparser.c
 delete mode 100644 drivers/net/dpaa2/dpaa2_sparser.h
Signature · 1 line
2.43.0
#53 lore raw

PATCH v2 1/47 crypto/dpaa2_sec: fix buffer overflow in GCM decrypt

From: Gagandeep Singh <[email protected]>

In build_authenc_gcm_fd, when both AAD (auth_only_len > 0) and decrypt direction are active, the SGE layout occupies 8 entries plus 16 bytes of old_icv storage at index 8. The FLE pool buffer was only 256 bytes (8 x 32), causing old_icv to be written one entry past the end of the allocated buffer. The resulting virtual address was not mapped by the IOMMU, so DPAA2_VADDR_TO_IOVA returned 0 and the SEC engine received iova=0x00000000 as the ICV buffer address, triggering an SMMU translation fault (FSR=0x402 TF).

Additionally, the upfront bpid/IVP initialization only covered sge+3, leaving sge+4 (the input data SGE when AAD is present) without a valid bpid or IVP assignment.

Increase FLE_POOL_BUF_SIZE from 256 to 288 (9 x 32 bytes) to accommodate the full layout, and extend the bpid/IVP initialization to cover sge+4 in both branches of build_authenc_gcm_fd.

Fixes 13273250eec5 ("crypto/dpaa2_sec: support AES-GCM and CTR")
---
 drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c | 38 ++++++++++++++++++++-
 drivers/crypto/dpaa2_sec/dpaa2_sec_priv.h   |  2 +-
 drivers/dma/dpaa2/dpaa2_qdma.c              | 12 +++++--
 drivers/net/dpaa2/dpaa2_flow.c              |  1 +
 4 files changed, 49 insertions(+), 4 deletions(-)
drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c +37 -1
index 3d980d096f..96c2e56ff5 100644
@@ -8,6 +8,9 @@
 #include <time.h>
 #include <net/if.h>
 #include <unistd.h>
+#include <errno.h>
+#include <limits.h>
+#include <stdlib.h>
 
 #include <eal_export.h>
 #include <rte_ip.h>
@@ -569,6 +572,7 @@ build_authenc_gcm_fd(dpaa2_sec_session *sess,
 		DPAA2_SET_FLE_BPID(sge + 1, bpid);
 		DPAA2_SET_FLE_BPID(sge + 2, bpid);
 		DPAA2_SET_FLE_BPID(sge + 3, bpid);
+		DPAA2_SET_FLE_BPID(sge + 4, bpid);
 	} else {
 		DPAA2_SET_FD_IVP(fd);
 		DPAA2_SET_FLE_IVP(fle);
@@ -577,6 +581,7 @@ build_authenc_gcm_fd(dpaa2_sec_session *sess,
 		DPAA2_SET_FLE_IVP((sge + 1));
 		DPAA2_SET_FLE_IVP((sge + 2));
 		DPAA2_SET_FLE_IVP((sge + 3));
+		DPAA2_SET_FLE_IVP((sge + 4));
 	}
 
 	/* Save the shared descriptor */
@@ -4332,17 +4337,48 @@ dpaa2_sec_uninit(const struct rte_cryptodev *dev)
 	return 0;
 }
 
+/* Parse a base-10 integer. Returns 0 on success and stores the result in
+ * *val, or a negative errno if the string is empty, malformed, or out of
+ * range. Unlike atoi() this detects errors instead of silently yielding 0.
+ */
+static int
+dpaa2_sec_parse_int(const char *str, long *val)
+{
+	char *endptr;
+	long tmp;
+
+	if (str == NULL || *str == '\0')
+		return -EINVAL;
+
+	errno = 0;
+	tmp = strtol(str, &endptr, 10);
+	if (errno != 0)
+		return -errno;
+	if (endptr == str || *endptr != '\0')
+		return -EINVAL;
+
+	*val = tmp;
+
+	return 0;
+}
+
 static int
 check_devargs_handler(const char *key, const char *value,
 		      void *opaque)
 {
 	struct rte_cryptodev *dev = (struct rte_cryptodev *)opaque;
 	struct dpaa2_sec_dev_private *priv = dev->data->dev_private;
+	long val;
 
 	if (!strcmp(key, "drv_strict_order")) {
 		priv->en_loose_ordered = false;
 	} else if (!strcmp(key, "drv_dump_mode")) {
-		dpaa2_sec_dp_dump = atoi(value);
+		if (dpaa2_sec_parse_int(value, &val)) {
+			DPAA2_SEC_WARN("Invalid %s value '%s', ignored",
+				key, value);
+			return -1;
+		}
+		dpaa2_sec_dp_dump = val;
 		if (dpaa2_sec_dp_dump > DPAA2_SEC_DP_FULL_DUMP) {
 			DPAA2_SEC_WARN("WARN: DPAA2_SEC_DP_DUMP_LEVEL is not "
 				      "supported, changing to FULL error"
drivers/crypto/dpaa2_sec/dpaa2_sec_priv.h +1 -1
index 755c8e9cc3..ff32f3d860 100644
@@ -17,7 +17,7 @@ extern uint8_t cryptodev_driver_id;
 
 /* FLE_POOL_NUM_BUFS is set as per the ipsec-secgw application */
 #define FLE_POOL_NUM_BUFS	32000
-#define FLE_POOL_BUF_SIZE	256
+#define FLE_POOL_BUF_SIZE	288
 #define FLE_POOL_CACHE_SIZE	512
 #define FLE_SG_MEM_SIZE(num)	(FLE_POOL_BUF_SIZE + ((num) * 32))
 
drivers/dma/dpaa2/dpaa2_qdma.c +10 -2
index f7d94bb799..004dacf677 100644
@@ -180,7 +180,7 @@ dpaa2_qdma_multi_eq(struct qdma_virt_queue *qdma_vq)
 	return num_tx;
 }
 
-static void
+static int
 fle_sdd_pre_populate(struct qdma_cntx_fle_sdd *fle_sdd,
 	struct dpaa2_qdma_rbp *rbp, uint64_t src, uint64_t dest,
 	uint32_t fmt)
@@ -256,6 +256,8 @@ fle_sdd_pre_populate(struct qdma_cntx_fle_sdd *fle_sdd,
 
 	/* Final bit: 1, for last frame list */
 	DPAA2_SET_FLE_FIN(&fle[DPAA2_QDMA_DST_FLE]);
+
+	return 0;
 }
 
 static void
@@ -871,9 +873,15 @@ dpaa2_qdma_long_copy(struct qdma_virt_queue *qdma_vq,
 
 	if (qdma_vq->fle_pre_populate) {
 		if (unlikely(!fle[DPAA2_QDMA_SRC_FLE].length)) {
-			fle_sdd_pre_populate(fle_sdd,
+			ret = fle_sdd_pre_populate(fle_sdd,
 				&qdma_vq->rbp,
 				0, 0, QBMAN_FLE_WORD4_FMT_SBF);
+			if (unlikely(ret)) {
+				if (!is_silent)
+					rte_mempool_put(qdma_vq->fle_pool,
+						fle_sdd);
+				return ret;
+			}
 		}
 
 		fle_post_populate(fle, src, dst, length);
drivers/net/dpaa2/dpaa2_flow.c +1 -0
index 2e44bff766..63c253ab3b 100644
@@ -3,6 +3,7 @@
  */
 
 #include <sys/queue.h>
+#include <rte_string_fns.h>
 #include <stdio.h>
 #include <errno.h>
 #include <stdint.h>
Signature · 1 line
2.43.0
#54 lore raw

PATCH v2 2/47 crypto/dpaa2_sec: fix FLE pool leak on sec FD build failure

In reply to Prashant Gupta

From: Gagandeep Singh <[email protected]>

When build_sec_fd fails at index loop inside the enqueue burst loops, the previously built FD entries (indices 0..loop-1) were never freed. The cleanup loop iterated in the wrong direction, starting at the failed index and going up to frames_to_send, which are entries that were never built. This caused silent FLE pool exhaustion, after which every subsequent build_sec_fd returned -ENOMEM, enqueue_burst returned 0 indefinitely, and the crypto-perf test hung.

Fix both dpaa2_sec_enqueue_burst and dpaa2_sec_enqueue_burst_ordered by clamping frames_to_send to loop + 1 and iterating from 0 to free all allocated FLE buffers including the failed entry.

Fixes 623326dded3a ("crypto/dpaa2_sec: introduce poll mode driver")
---
 drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c +6 -0
index 96c2e56ff5..e710b4fbd3 100644
@@ -1553,6 +1553,9 @@ dpaa2_sec_enqueue_burst(void *qp, struct rte_crypto_op **ops,
 			ret = build_sec_fd(*ops, &fd_arr[loop], bpid, dpaa2_qp);
 			if (ret) {
 				DPAA2_SEC_DP_DEBUG("FD build failed");
+				frames_to_send = loop + 1;
+				for (loop = 0; loop < frames_to_send; loop++)
+					free_fle(&fd_arr[loop], dpaa2_qp);
 				goto skip_tx;
 			}
 			ops++;
@@ -1912,6 +1915,9 @@ dpaa2_sec_enqueue_burst_ordered(void *qp, struct rte_crypto_op **ops,
 			ret = build_sec_fd(*ops, &fd_arr[loop], bpid, dpaa2_qp);
 			if (ret) {
 				DPAA2_SEC_DP_DEBUG("FD build failed");
+				frames_to_send = loop + 1;
+				for (loop = 0; loop < frames_to_send; loop++)
+					free_fle(&fd_arr[loop], dpaa2_qp);
 				goto skip_tx;
 			}
 			ops++;
Signature · 1 line
2.43.0
#55 lore raw

PATCH v2 3/47 crypto/dpaa2_sec: support AES-GMAC

In reply to Prashant Gupta

From: Gagandeep Singh <[email protected]>

Add AES-GMAC as a supported AEAD algorithm for IPsec protocol offload. AES-GMAC provides NULL encryption with GMAC authentication and maps to OP_PCL_IPSEC_AES_NULL_WITH_GMAC in the SEC protocol control word.

When AES_GMAC is specified as an AUTH (non-AEAD) algorithm, return -ENOTSUP with an informative message directing the user to the AEAD path.

Add RTE_CRYPTO_AEAD_AES_GMAC to the AEAD algorithm enum and expose the capability in dpaa2_sec_capabilities.

---
 doc/guides/rel_notes/release_26_11.rst      |  6 ++++
 drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c | 14 ++++++++-
 drivers/crypto/dpaa2_sec/dpaa2_sec_priv.h   | 33 ++++++++++++++++++++-
 lib/cryptodev/rte_crypto_sym.h              |  2 ++
 lib/cryptodev/rte_cryptodev.c               |  1 +
 5 files changed, 54 insertions(+), 2 deletions(-)
doc/guides/rel_notes/release_26_11.rst +6 -0
index 87c7e81bde..2eb5c4fe56 100644
@@ -55,6 +55,12 @@ New Features
      Also, make sure to start the actual text at the margin.
      =======================================================
 
+* **Added AES-GMAC AEAD algorithm.**
+
+  Added ``RTE_CRYPTO_AEAD_AES_GMAC`` to the AEAD algorithm enumeration, for
+  NULL encryption with GMAC authentication. The NXP dpaa2_sec PMD supports it
+  for IPsec protocol offload.
+
 
 Removed Items
 -------------
drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c +13 -1
index e710b4fbd3..16af02e758 100644
@@ -1,7 +1,7 @@
 /* SPDX-License-Identifier: BSD-3-Clause
  *
  *   Copyright (c) 2016 Freescale Semiconductor, Inc. All rights reserved.
- *   Copyright 2016-2025 NXP
+ *   Copyright 2016-2026 NXP
  *
  */
 
@@ -2978,6 +2978,13 @@ dpaa2_sec_ipsec_aead_init(struct rte_crypto_aead_xform *aead_xform,
 		aeaddata->algmode = OP_ALG_AAI_CCM;
 		session->aead_alg = RTE_CRYPTO_AEAD_AES_CCM;
 		break;
+	case RTE_CRYPTO_AEAD_AES_GMAC:
+		/**
+		 * AES-GMAC is an AEAD algo with NULL encryption and GMAC
+		 * authentication.
+		 */
+		aeaddata->algtype = OP_PCL_IPSEC_AES_NULL_WITH_GMAC;
+		break;
 	default:
 		DPAA2_SEC_ERR("Crypto: Undefined AEAD specified %u",
 			      aead_xform->algo);
@@ -3049,6 +3056,9 @@ dpaa2_sec_ipsec_proto_init(struct rte_crypto_cipher_xform *cipher_xform,
 		authdata->algtype = OP_PCL_IPSEC_HMAC_MD5_96;
 		authdata->algmode = OP_ALG_AAI_HMAC;
 		break;
+	case RTE_CRYPTO_AUTH_AES_GMAC:
+		DPAA2_SEC_ERR("AES_GMAC is supported as AEAD algo for IPSEC proto only");
+		return -ENOTSUP;
 	case RTE_CRYPTO_AUTH_SHA224_HMAC:
 		authdata->algmode = OP_ALG_AAI_HMAC;
 		if (session->digest_length == 6)
@@ -3220,6 +3230,7 @@ dpaa2_sec_set_ipsec_session(struct rte_cryptodev *dev,
 		case OP_PCL_IPSEC_AES_GCM8:
 		case OP_PCL_IPSEC_AES_GCM12:
 		case OP_PCL_IPSEC_AES_GCM16:
+		case OP_PCL_IPSEC_AES_NULL_WITH_GMAC:
 			memcpy(encap_pdb.gcm.salt,
 				(uint8_t *)&(ipsec_xform->salt), 4);
 			break;
@@ -3360,6 +3371,7 @@ dpaa2_sec_set_ipsec_session(struct rte_cryptodev *dev,
 		case OP_PCL_IPSEC_AES_GCM8:
 		case OP_PCL_IPSEC_AES_GCM12:
 		case OP_PCL_IPSEC_AES_GCM16:
+		case OP_PCL_IPSEC_AES_NULL_WITH_GMAC:
 			memcpy(decap_pdb.gcm.salt,
 				(uint8_t *)&(ipsec_xform->salt), 4);
 			break;
drivers/crypto/dpaa2_sec/dpaa2_sec_priv.h +32 -1
index ff32f3d860..1824cc4a60 100644
@@ -1,7 +1,7 @@
 /* SPDX-License-Identifier: BSD-3-Clause
  *
  *   Copyright (c) 2016 Freescale Semiconductor, Inc. All rights reserved.
- *   Copyright 2016,2020-2024 NXP
+ *   Copyright 2016,2020-2026 NXP
  *
  */
 
@@ -762,6 +762,37 @@ static const struct rte_cryptodev_capabilities dpaa2_sec_capabilities[] = {
 			}, }
 		}, }
 	},
+	{	/* AES GMAC (AEAD) */
+		.op = RTE_CRYPTO_OP_TYPE_SYMMETRIC,
+		{.sym = {
+			.xform_type = RTE_CRYPTO_SYM_XFORM_AEAD,
+			{.aead = {
+				.algo = RTE_CRYPTO_AEAD_AES_GMAC,
+				.block_size = 16,
+				.key_size = {
+					.min = 16,
+					.max = 32,
+					.increment = 8
+				},
+				.digest_size = {
+					.min = 16,
+					.max = 16,
+					.increment = 0
+				},
+				.aad_size = {
+					.min = 0,
+					.max = 65535,
+					.increment = 1
+				},
+				.iv_size = {
+					.min = 12,
+					.max = 16,
+					.increment = 4
+				}
+			}, }
+		}, }
+	},
+
 	RTE_CRYPTODEV_END_OF_CAPABILITIES_LIST()
 };
 
lib/cryptodev/rte_crypto_sym.h +2 -0
index 630fd153bd..f65db616a0 100644
@@ -508,6 +508,8 @@ enum rte_crypto_aead_algorithm {
 	/**< AES algorithm in NCA5 mode */
 	RTE_CRYPTO_AEAD_ZUC_NCA6,
 	/**< ZUC-256 algorithm in NCA6 mode */
+	RTE_CRYPTO_AEAD_AES_GMAC,
+	/**< AES algorithm in GMAC mode. */
 };
 
 /** Symmetric AEAD Operations */
lib/cryptodev/rte_cryptodev.c +1 -0
index 829a5d0846..fa78cd1f1f 100644
@@ -186,6 +186,7 @@ crypto_aead_algorithm_strings[] = {
 	[RTE_CRYPTO_AEAD_SNOW5G_NCA4] = "snow5g-nca4",
 	[RTE_CRYPTO_AEAD_AES_NCA5]    = "aes-nca5",
 	[RTE_CRYPTO_AEAD_ZUC_NCA6]    = "zuc-nca6",
+	[RTE_CRYPTO_AEAD_AES_GMAC]    = "aes-gmac",
 };
 
 
Signature · 1 line
2.43.0
#56 lore raw

RE: [EXTERNAL] [PATCH v2 03/47] crypto/dpaa2_sec: support AES-GMAC

Quoted 11 lines

From: Gagandeep Singh <[email protected]>

Add AES-GMAC as a supported AEAD algorithm for IPsec protocol offload. AES-GMAC provides NULL encryption with GMAC authentication and maps to OP_PCL_IPSEC_AES_NULL_WITH_GMAC in the SEC protocol control word.

When AES_GMAC is specified as an AUTH (non-AEAD) algorithm, return -ENOTSUP with an informative message directing the user to the AEAD path.

Quoted 5 lines

Add RTE_CRYPTO_AEAD_AES_GMAC to the AEAD algorithm enum and expose the capability in dpaa2_sec_capabilities.

AES-GMAC is considered as an auth algorithm, we need not make it as AEAD.
This was discussed earlier also and the idea of moving to AEAD was dropped.
These crypto patches should be coming as a separate series for crypto tree.
It seems these patches are resubmitted for https://patchwork.dpdk.org/project/dpdk/list/?series=38909
Better submit crypto patches separately.

Please remove my sign-off from this patch and consider supporting GMAC as auth algo.

Furthermore, the lib and PMD changes should be separate patch.

#57 lore raw

PATCH v2 4/47 crypto/dpaa2_sec: increase ivsize range for AES-CTR

In reply to Prashant Gupta

From: Gagandeep Singh <[email protected]>

Widen the AES-CTR IV size range from the fixed 16-byte value to [12, 16] with a 4-byte increment. This allows 96-bit IVs (the standard NIST SP 800-38A recommendation) in addition to 128-bit IVs, aligning with common usage and test-vector expectations.

The change applies to both dpaa2_sec_capabilities and dpaa2_pdcp_capabilities.

---
 drivers/crypto/dpaa2_sec/dpaa2_sec_priv.h | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/crypto/dpaa2_sec/dpaa2_sec_priv.h +4 -4
index 1824cc4a60..7e18e83858 100644
@@ -625,9 +625,9 @@ static const struct rte_cryptodev_capabilities dpaa2_sec_capabilities[] = {
 					.increment = 8
 				},
 				.iv_size = {
-					.min = 16,
+					.min = 12,
 					.max = 16,
-					.increment = 0
+					.increment = 4
 				},
 			}, }
 		}, }
@@ -855,9 +855,9 @@ static const struct rte_cryptodev_capabilities dpaa2_pdcp_capabilities[] = {
 					.increment = 8
 				},
 				.iv_size = {
-					.min = 16,
+					.min = 12,
 					.max = 16,
-					.increment = 0
+					.increment = 4
 				}
 			}, }
 		}, }
Signature · 1 line
2.43.0
#58 lore raw

PATCH v2 5/47 crypto/dpaa2_sec: add missing ECN capability

In reply to Prashant Gupta

From: Gagandeep Singh <[email protected]>

Set the .ecn = 1 flag in both tunnel-mode security capability entries to advertise that the driver supports ECN (Explicit Congestion Notification) copying during IPsec encap/decap.

---
 drivers/crypto/dpaa2_sec/dpaa2_sec_priv.h | 2 ++
 1 file changed, 2 insertions(+)
drivers/crypto/dpaa2_sec/dpaa2_sec_priv.h +2 -0
index 7e18e83858..16b8273a79 100644
@@ -1004,6 +1004,7 @@ static const struct rte_security_capability dpaa2_sec_security_cap[] = {
 				.copy_df = 1,
 				.copy_dscp = 1,
 				.dec_ttl = 1,
+				.ecn = 1,
 				.esn = 1,
 			},
 			.replay_win_sz_max = 1024
@@ -1023,6 +1024,7 @@ static const struct rte_security_capability dpaa2_sec_security_cap[] = {
 				.copy_df = 1,
 				.copy_dscp = 1,
 				.dec_ttl = 1,
+				.ecn = 1,
 				.esn = 1,
 			},
 			.replay_win_sz_max = 1024
Signature · 1 line
2.43.0
#59 lore raw

PATCH v2 6/47 crypto/dpaa2_sec: add support for env variables

In reply to Prashant Gupta

From: Gagandeep Singh <[email protected]>

Allow driver configuration via environment variables as a fallback when devargs are not provided. After processing devargs (or when devargs are absent), check DRIVER_STRICT_ORDER and DRIVER_DUMP_MODE environment variables to set en_loose_ordered and dpaa2_sec_dp_dump.

This lets users configure the driver without modifying EAL arguments, useful in environments where command-line access is restricted.

---
 drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c | 40 ++++++++++++++++++---
 1 file changed, 36 insertions(+), 4 deletions(-)
drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c +36 -4
index 16af02e758..1416c8dc67 100644
@@ -4412,25 +4412,57 @@ check_devargs_handler(const char *key, const char *value,
 static void
 dpaa2_sec_get_devargs(struct rte_cryptodev *cryptodev, const char *key)
 {
+	struct dpaa2_sec_dev_private *internals;
 	struct rte_kvargs *kvlist;
 	struct rte_devargs *devargs;
+	int ret;
+	char *env;
+	long val;
+
+	internals = cryptodev->data->dev_private;
 
 	devargs = cryptodev->device->devargs;
 	if (!devargs)
-		return;
+		goto env_set;
 
 	kvlist = rte_kvargs_parse(devargs->args, NULL);
 	if (!kvlist)
-		return;
+		goto env_set;
 
 	if (!rte_kvargs_count(kvlist, key)) {
 		rte_kvargs_free(kvlist);
-		return;
+		goto env_set;
 	}
 
-	rte_kvargs_process(kvlist, key,
+	ret = rte_kvargs_process(kvlist, key,
 			check_devargs_handler, (void *)cryptodev);
 	rte_kvargs_free(kvlist);
+	if (!ret)
+		return;
+
+env_set:
+	env = getenv(DRIVER_STRICT_ORDER);
+	if (env) {
+		if (dpaa2_sec_parse_int(env, &val))
+			DPAA2_SEC_WARN("Invalid %s value '%s', ignored",
+				DRIVER_STRICT_ORDER, env);
+		else
+			internals->en_loose_ordered = !val;
+	}
+
+	env = getenv(DRIVER_DUMP_MODE);
+	if (env) {
+		if (dpaa2_sec_parse_int(env, &val)) {
+			DPAA2_SEC_WARN("Invalid %s value '%s', ignored",
+				DRIVER_DUMP_MODE, env);
+		} else {
+			if (val > DPAA2_SEC_DP_FULL_DUMP)
+				val = DPAA2_SEC_DP_FULL_DUMP;
+			else if (val < DPAA2_SEC_DP_NO_DUMP)
+				val = DPAA2_SEC_DP_NO_DUMP;
+			dpaa2_sec_dp_dump = val;
+		}
+	}
 }
 
 static int
Signature · 1 line
2.43.0
#60 lore raw

RE: [EXTERNAL] [PATCH v2 06/47] crypto/dpaa2_sec: add support for env variables

Quoted 7 lines

From: Gagandeep Singh <[email protected]>

Allow driver configuration via environment variables as a fallback when devargs are not provided. After processing devargs (or when devargs are absent), check DRIVER_STRICT_ORDER and DRIVER_DUMP_MODE environment variables to set en_loose_ordered and dpaa2_sec_dp_dump.

Quoted 5 lines

This lets users configure the driver without modifying EAL arguments, useful in environments where command-line access is restricted.

---

These devargs without proper documentation cannot be accepted.

#61 lore raw

PATCH v2 7/47 net/dpaa2: fix integer overflow in CCSR region mapping

In reply to Prashant Gupta

From: Hemant Agrawal <[email protected]>

In lsx_ccsr_map_region, PAGE_SIZE is defined as sysconf(_SC_PAGESIZE) which may be negative on error. The value was used directly in size_t comparisons and passed to mmap, causing an integer overflow (Coverity CID 49765682).

Use sysconf() explicitly with a signed long, check for errors, and compute map_len separately with unsigned arithmetic before passing to mmap.

Coverity issue: 49765682

Fixes f023d059769f ("net/dpaa2: support recycle loopback port")
---
 drivers/net/dpaa2/dpaa2_recycle.c | 21 +++++++++++++++------
 1 file changed, 15 insertions(+), 6 deletions(-)
drivers/net/dpaa2/dpaa2_recycle.c +15 -6
index f78d12362e..80c20272ce 100644
@@ -176,6 +176,8 @@ static void *lsx_ccsr_map_region(uint64_t addr, size_t len)
 	void *tmp;
 	uint64_t start;
 	uint64_t offset;
+	long page_size;
+	size_t map_len;
 
 	fd = open("/dev/mem", O_RDWR);
 	if (fd < 0) {
@@ -183,20 +185,27 @@ static void *lsx_ccsr_map_region(uint64_t addr, size_t len)
 		return NULL;
 	}
 
+	page_size = sysconf(_SC_PAGESIZE);
+	if (page_size <= 0) {
+		close(fd);
+		return NULL;
+	}
 	start = addr & PAGE_MASK;
 	offset = addr - start;
 	len = len & PAGE_MASK;
-	if (len < (size_t)PAGE_SIZE)
-		len = PAGE_SIZE;
 
-	tmp = mmap(NULL, len, PROT_READ | PROT_WRITE, MAP_SHARED, fd, start);
+	map_len = len & ~(page_size - 1);
+	if (map_len < (size_t)page_size)
+		map_len = (size_t)page_size;
+
+	tmp = mmap(NULL, map_len, PROT_READ | PROT_WRITE, MAP_SHARED, fd, start);
 
 	close(fd);
 
-	if (tmp != MAP_FAILED)
-		return (uint8_t *)tmp + offset;
-	else
+	if (tmp == MAP_FAILED)
 		return NULL;
+
+	return (uint8_t *)tmp + offset;
 }
 
 static const uint8_t ls_sd1_prot_idx_map[] = {
Signature · 1 line
2.43.0
#62 lore raw

PATCH v2 8/47 dma/dpaa2: fix array-bounds warning in dequeue path

In reply to Prashant Gupta

From: Jun Yang <[email protected]>

In dpaa2_qdma_dq_fd, passing a local uint16_t variable directly as a pointer to qdma_cntx_idx_ring_eq caused a compiler array-bounds warning because the function takes a pointer to an element of the ring array.

Add a per-queue scratch buffer idxs[DPAA2_QDMA_MAX_DESC] to struct qdma_virt_queue and use idxs[0] instead of a local variable pointer. Also consolidate the fle_sdd pointer assignment for LONG and SG FD types to avoid code duplication.

Fixes 388e888dc082 ("dma/dpaa2: support short FD")
---
 drivers/dma/dpaa2/dpaa2_qdma.c | 24 ++++++++----------------
 drivers/dma/dpaa2/dpaa2_qdma.h |  1 +
 2 files changed, 9 insertions(+), 16 deletions(-)
drivers/dma/dpaa2/dpaa2_qdma.c +8 -16
index 004dacf677..6fd3530f0d 100644
@@ -943,35 +943,27 @@ dpaa2_qdma_dq_fd(const struct qbman_fd *fd,
 	enum dpaa2_qdma_fd_type type;
 	int ret;
 	struct qdma_cntx_sg *cntx_sg;
-	struct qdma_cntx_fle_sdd *fle_sdd;
+	struct qdma_cntx_fle_sdd *fle_sdd = NULL;
 
 	att = dpaa2_qdma_fd_get_att(fd);
 	type = DPAA2_QDMA_FD_ATT_TYPE(att);
-	if (type == DPAA2_QDMA_FD_SHORT) {
-		idx = DPAA2_QDMA_FD_ATT_CNTX(att);
-		ret = qdma_cntx_idx_ring_eq(qdma_vq->ring_cntx_idx,
-				&idx, 1, free_space);
-		if (unlikely(ret != 1))
-			return -ENOSPC;
-
-		return 0;
-	}
-	if (type == DPAA2_QDMA_FD_LONG) {
-		idx = DPAA2_QDMA_FD_ATT_CNTX(att);
+	if (type == DPAA2_QDMA_FD_LONG || type == DPAA2_QDMA_FD_SG) {
 		fle_sdd = (void *)(uintptr_t)DPAA2_GET_FD_FLC(fd);
 		qdma_vq->fle_elem[*fle_elem_nb] = fle_sdd;
 		(*fle_elem_nb)++;
+	}
+	if (type == DPAA2_QDMA_FD_SHORT ||
+		type == DPAA2_QDMA_FD_LONG) {
+		idx = DPAA2_QDMA_FD_ATT_CNTX(att);
+		qdma_vq->idxs[0] = idx;
 		ret = qdma_cntx_idx_ring_eq(qdma_vq->ring_cntx_idx,
-				&idx, 1, free_space);
+			qdma_vq->idxs, 1, free_space);
 		if (unlikely(ret != 1))
 			return -ENOSPC;
 
 		return 0;
 	}
 	if (type == DPAA2_QDMA_FD_SG) {
-		fle_sdd = (void *)(uintptr_t)DPAA2_GET_FD_FLC(fd);
-		qdma_vq->fle_elem[*fle_elem_nb] = fle_sdd;
-		(*fle_elem_nb)++;
 		cntx_sg = container_of(fle_sdd,
 				struct qdma_cntx_sg, fle_sdd);
 		ret = qdma_cntx_idx_ring_eq(qdma_vq->ring_cntx_idx,
drivers/dma/dpaa2/dpaa2_qdma.h +1 -0
index e2d2eb4fa8..98c64f7b45 100644
@@ -290,6 +290,7 @@ struct qdma_virt_queue {
 	struct qdma_cntx_idx_ring *ring_cntx_idx;
 
 	/**Used for silent enabled*/
+	uint16_t idxs[DPAA2_QDMA_MAX_DESC];
 	struct qdma_cntx_sg *cntx_sg[DPAA2_QDMA_MAX_DESC];
 	struct qdma_cntx_fle_sdd *cntx_fle_sdd[DPAA2_QDMA_MAX_DESC];
 	uint16_t silent_idx;
Signature · 1 line
2.43.0
#63 lore raw

PATCH v2 9/47 bus/fslmc: defer bus initialization to probe

In reply to Prashant Gupta

The fslmc bus initialization (register the sequence number mbuf dynfield, set up the VFIO group, DMA map the memory segments) needs the DPDK heap and the memory segment list in shared (hugepage) memory for multi-process sharing. But these are not available during the bus scan (EAL runs rte_bus_scan() before memzone, memory and malloc heap init), so it fails there.

Device discovery does not need it, and get_iommu_class() only checks sysfs paths to report the IOVA mode, so the init is not needed in scan. Move it back to probe.

Fixes cdefd2e980bd ("drivers/bus: initialize NXP bus specifics in scan")
---
 drivers/bus/fslmc/fslmc_bus.c | 92 +++++++++++++++++++----------------
 1 file changed, 51 insertions(+), 41 deletions(-)
drivers/bus/fslmc/fslmc_bus.c +51 -41
index 3626b12316..ee162b0ed8 100644
@@ -368,46 +368,6 @@ rte_fslmc_scan(void)
 	/* If debugging is enabled, device list is dumped to log output */
 	dump_device_list();
 
-	/* Bus initialization - only if devices were found */
-	if (!TAILQ_EMPTY(&rte_fslmc_bus.device_list)) {
-		static const struct rte_mbuf_dynfield dpaa2_seqn_dynfield_desc = {
-			.name = DPAA2_SEQN_DYNFIELD_NAME,
-			.size = sizeof(dpaa2_seqn_t),
-			.align = alignof(dpaa2_seqn_t),
-		};
-
-		dpaa2_seqn_dynfield_offset =
-			rte_mbuf_dynfield_register(&dpaa2_seqn_dynfield_desc);
-		if (dpaa2_seqn_dynfield_offset < 0) {
-			DPAA2_BUS_ERR("Failed to register mbuf field for dpaa sequence number");
-			return 0;
-		}
-
-		ret = fslmc_vfio_setup_group();
-		if (ret) {
-			DPAA2_BUS_ERR("Unable to setup VFIO %d", ret);
-			return 0;
-		}
-
-		/* Map existing segments as well as, in case of hotpluggable memory,
-		 * install callback handler.
-		 */
-		if (rte_eal_process_type() == RTE_PROC_PRIMARY) {
-			ret = fslmc_vfio_dmamap();
-			if (ret) {
-				DPAA2_BUS_ERR("Unable to DMA map existing VAs: (%d)", ret);
-				DPAA2_BUS_ERR("FSLMC VFIO Mapping failed");
-				return 0;
-			}
-		}
-
-		ret = fslmc_vfio_process_group();
-		if (ret) {
-			DPAA2_BUS_ERR("Unable to setup devices %d", ret);
-			return 0;
-		}
-	}
-
 	process_once = 1;
 
 	return 0;
@@ -423,6 +383,56 @@ rte_fslmc_scan(void)
 	return 0;
 }
 
+/* Bus initialization needs the DPDK heap and DMA mapping of the memory
+ * segments, which EAL only sets up after the bus scan, so it is done here.
+ */
+static int
+rte_fslmc_probe(struct rte_bus *bus)
+{
+	static const struct rte_mbuf_dynfield dpaa2_seqn_dynfield_desc = {
+		.name = DPAA2_SEQN_DYNFIELD_NAME,
+		.size = sizeof(dpaa2_seqn_t),
+		.align = alignof(dpaa2_seqn_t),
+	};
+	int ret;
+
+	if (TAILQ_EMPTY(&rte_fslmc_bus.device_list))
+		return 0;
+
+	dpaa2_seqn_dynfield_offset =
+		rte_mbuf_dynfield_register(&dpaa2_seqn_dynfield_desc);
+	if (dpaa2_seqn_dynfield_offset < 0) {
+		DPAA2_BUS_ERR("Failed to register mbuf field for dpaa sequence number");
+		return 0;
+	}
+
+	ret = fslmc_vfio_setup_group();
+	if (ret) {
+		DPAA2_BUS_ERR("Unable to setup VFIO %d", ret);
+		return 0;
+	}
+
+	/* Map existing segments as well as, in case of hotpluggable memory,
+	 * install callback handler.
+	 */
+	if (rte_eal_process_type() == RTE_PROC_PRIMARY) {
+		ret = fslmc_vfio_dmamap();
+		if (ret) {
+			DPAA2_BUS_ERR("Unable to DMA map existing VAs: (%d)", ret);
+			DPAA2_BUS_ERR("FSLMC VFIO Mapping failed");
+			return 0;
+		}
+	}
+
+	ret = fslmc_vfio_process_group();
+	if (ret) {
+		DPAA2_BUS_ERR("Unable to setup devices %d", ret);
+		return 0;
+	}
+
+	return rte_bus_generic_probe(bus);
+}
+
 static bool
 fslmc_bus_match(const struct rte_driver *drv, const struct rte_device *dev)
 {
@@ -544,7 +554,7 @@ fslmc_bus_unplug_device(struct rte_device *rte_dev)
 
 struct rte_bus rte_fslmc_bus = {
 	.scan = rte_fslmc_scan,
-	.probe = rte_bus_generic_probe,
+	.probe = rte_fslmc_probe,
 	.cleanup = rte_fslmc_close,
 	.parse = rte_fslmc_parse,
 	.dev_compare = fslmc_dev_compare,
Signature · 1 line
2.43.0
#64 lore raw

PATCH v2 10/47 dma/dpaa2: validate IOVA in pre-populate helpers

In reply to Prashant Gupta

From: Gagandeep Singh <[email protected]>

fle_sdd_pre_populate() and fle_sdd_sg_pre_populate() converted the SDD and SG entry virtual addresses to IOVA with DPAA2_VADDR_TO_IOVA(), which does not verify that the range is actually mapped in the IOMMU/SMMU. An unmapped buffer was silently programmed into the hardware descriptor, leading to an SMMU translation fault at transfer time that is hard to trace back to the missing mapping.

Use DPAA2_VADDR_TO_IOVA_AND_CHECK() for the SDD, source SG and destination SG buffers and rte_panic() with the offending address and size when the translation is missing, so the misconfiguration is caught early and clearly.

---
 drivers/dma/dpaa2/dpaa2_qdma.c | 42 ++++++++++++++++++++++++++++------
 1 file changed, 35 insertions(+), 7 deletions(-)
drivers/dma/dpaa2/dpaa2_qdma.c +35 -7
index 6fd3530f0d..8a180ab400 100644
@@ -187,7 +187,15 @@ fle_sdd_pre_populate(struct qdma_cntx_fle_sdd *fle_sdd,
 {
 	struct qbman_fle *fle = fle_sdd->fle;
 	struct qdma_sdd *sdd = fle_sdd->sdd;
-	uint64_t sdd_iova = DPAA2_VADDR_TO_IOVA(sdd);
+	uint64_t sdd_iova, iova_size;
+
+	iova_size = sizeof(struct qdma_sdd) * DPAA2_QDMA_MAX_SDD;
+	sdd_iova = DPAA2_VADDR_TO_IOVA_AND_CHECK(sdd, iova_size);
+	if (sdd_iova == RTE_BAD_IOVA) {
+		DPAA2_QDMA_ERR("No IOMMU map for sdd(%p)(size=%" PRIu64 ")",
+			sdd, iova_size);
+		return -ENOMEM;
+	}
 
 	/* first frame list to source descriptor */
 	DPAA2_SET_FLE_ADDR(&fle[DPAA2_QDMA_SDD_FLE], sdd_iova);
@@ -285,22 +293,36 @@ sg_entry_pre_populate(struct qdma_cntx_sg *sg_cntx)
 	}
 }
 
-static void
+static int
 fle_sdd_sg_pre_populate(struct qdma_cntx_sg *sg_cntx,
 	struct qdma_virt_queue *qdma_vq)
 {
 	struct qdma_sg_entry *src_sge = sg_cntx->sg_src_entry;
 	struct qdma_sg_entry *dst_sge = sg_cntx->sg_dst_entry;
-	rte_iova_t src_sge_iova, dst_sge_iova;
+	rte_iova_t src_sge_iova, dst_sge_iova, iova_size;
 	struct dpaa2_qdma_rbp *rbp = &qdma_vq->rbp;
 
 	memset(sg_cntx, 0, sizeof(struct qdma_cntx_sg));
 
-	src_sge_iova = DPAA2_VADDR_TO_IOVA(src_sge);
-	dst_sge_iova = DPAA2_VADDR_TO_IOVA(dst_sge);
+	iova_size = RTE_DPAAX_QDMA_JOB_SUBMIT_MAX *
+		sizeof(struct qdma_sg_entry);
+
+	src_sge_iova = DPAA2_VADDR_TO_IOVA_AND_CHECK(src_sge, iova_size);
+	if (src_sge_iova == RTE_BAD_IOVA) {
+		DPAA2_QDMA_ERR("No IOMMU map for src_sge(%p)(size=%" PRIu64 ")",
+			src_sge, (uint64_t)iova_size);
+		return -ENOMEM;
+	}
+
+	dst_sge_iova = DPAA2_VADDR_TO_IOVA_AND_CHECK(dst_sge, iova_size);
+	if (dst_sge_iova == RTE_BAD_IOVA) {
+		DPAA2_QDMA_ERR("No IOMMU map for dst_sge(%p)(size=%" PRIu64 ")",
+			dst_sge, (uint64_t)iova_size);
+		return -ENOMEM;
+	}
 
 	sg_entry_pre_populate(sg_cntx);
-	fle_sdd_pre_populate(&sg_cntx->fle_sdd,
+	return fle_sdd_pre_populate(&sg_cntx->fle_sdd,
 		rbp, src_sge_iova, dst_sge_iova,
 		QBMAN_FLE_WORD4_FMT_SGE);
 }
@@ -671,7 +693,13 @@ dpaa2_qdma_copy_sg(void *dev_private,
 
 	if (qdma_vq->fle_pre_populate) {
 		if (unlikely(!fle[DPAA2_QDMA_SRC_FLE].length)) {
-			fle_sdd_sg_pre_populate(cntx_sg, qdma_vq);
+			ret = fle_sdd_sg_pre_populate(cntx_sg, qdma_vq);
+			if (unlikely(ret)) {
+				if (!qdma_dev->is_silent)
+					rte_mempool_put(qdma_vq->fle_pool,
+						cntx_sg);
+				return ret;
+			}
 			if (!qdma_dev->is_silent && cntx_sg && idx_addr) {
 				for (i = 0; i < nb_src; i++)
 					cntx_sg->cntx_idx[i] = idx_addr[i];
Signature · 1 line
2.43.0
#65 lore raw

PATCH v2 11/47 dma/dpaa2: optimize context index ring enqueue

In reply to Prashant Gupta

From: Gagandeep Singh <[email protected]>

qdma_cntx_idx_ring_eq() copied the context indices into the ring one element at a time in a loop, updating the tail on every iteration.

Replace the per-element loop with rte_memcpy(), handling the ring wrap-around as at most two contiguous copies, and update the tail once. This reduces the per-burst overhead on the dequeue completion path.

---
 drivers/dma/dpaa2/dpaa2_qdma.c | 20 ++++++++++++++------
 1 file changed, 14 insertions(+), 6 deletions(-)
drivers/dma/dpaa2/dpaa2_qdma.c +14 -6
index 8a180ab400..277be37b41 100644
@@ -66,15 +66,23 @@ qdma_cntx_idx_ring_eq(struct qdma_cntx_idx_ring *ring,
 	const uint16_t *elem, uint16_t nb,
 	uint16_t *free_space)
 {
-	uint16_t i;
-
 	if (unlikely(nb > ring->free_space))
 		return 0;
 
-	for (i = 0; i < nb; i++) {
-		ring->cntx_idx_ring[ring->tail] = elem[i];
-		ring->tail = (ring->tail + 1) &
-			(DPAA2_QDMA_MAX_DESC - 1);
+	if ((ring->tail + nb) < DPAA2_QDMA_MAX_DESC) {
+		rte_memcpy(&ring->cntx_idx_ring[ring->tail],
+			elem, nb * sizeof(uint16_t));
+		ring->tail += nb;
+	} else {
+		rte_memcpy(&ring->cntx_idx_ring[ring->tail],
+			elem,
+			(DPAA2_QDMA_MAX_DESC - ring->tail) *
+			sizeof(uint16_t));
+		rte_memcpy(&ring->cntx_idx_ring[0],
+			&elem[DPAA2_QDMA_MAX_DESC - ring->tail],
+			(nb - DPAA2_QDMA_MAX_DESC + ring->tail) *
+			sizeof(uint16_t));
+		ring->tail = (ring->tail + nb) & (DPAA2_QDMA_MAX_DESC - 1);
 	}
 	ring->free_space -= nb;
 	ring->nb_in_ring += nb;
Signature · 1 line
2.43.0
#66 lore raw

PATCH v2 12/47 drivers: add dpaa2 DMA bypass memory translation option

In reply to Prashant Gupta

From: Gagandeep Singh <[email protected]>

Add RTE_DPAAX_QDMA_BMT_FLAG flag to allow callers to bypass memory translation (BMT) for DMA operations. This is needed for some PCIe scenarios where IOMMU translation should be skipped.

The flag is propagated to all SG entry and FD populate helpers via a new 'bmt' parameter, defaulting to DISABLE when the flag is not set.

---
 drivers/common/dpaax/rte_pmd_dpaax_qdma.h |  4 +-
 drivers/dma/dpaa2/dpaa2_qdma.c            | 59 ++++++++++-------------
 2 files changed, 29 insertions(+), 34 deletions(-)
drivers/common/dpaax/rte_pmd_dpaax_qdma.h +3 -1
index 8f2fc83f8d..6bd72b0b0e 100644
@@ -1,5 +1,5 @@
 /* SPDX-License-Identifier: BSD-3-Clause
- * Copyright 2021-2024 NXP
+ * Copyright 2021-2024, 2026 NXP
  */
 
 #ifndef RTE_PMD_DPAAX_QDMA_H
@@ -7,6 +7,8 @@
 
 #include <rte_compat.h>
 
+#define RTE_DPAAX_QDMA_BMT_FLAG RTE_BIT64(7)
+
 #define RTE_DPAAX_QDMA_COPY_IDX_OFFSET 8
 #define RTE_DPAAX_QDMA_SG_IDX_ADDR_ALIGN \
 	RTE_BIT64(RTE_DPAAX_QDMA_COPY_IDX_OFFSET)
drivers/dma/dpaa2/dpaa2_qdma.c +26 -33

146 lines not on this page · raw message

Signature · 1 line
2.43.0
#67 lore raw

PATCH v2 13/47 mempool/dpaa2: support ops index from primary in secondary

In reply to Prashant Gupta

From: Jun Yang <[email protected]>

Secondary processes call rte_dpaa2_mpool_get_ops_idx() but the ops index is registered only in the primary process. The secondary had no way to learn the index, causing it to use the initial sentinel value RTE_MEMPOOL_MAX_OPS_IDX and return an error.

Register an IPC action handler in the primary during pool creation. Secondary processes send DPAA2_POOL_OPS_IDX_REQ over the dpaa2_pool_mp_sync channel and receive the ops index back.

Also handle the case where rte_mp_action_register returns ENOTSUP (e.g. no secondary process support enabled at build time) by treating it as non-fatal, and improve the error message in rte_hw_mbuf_free_pool to include the pool name.

---
 drivers/mempool/dpaa2/dpaa2_hw_mempool.c | 88 +++++++++++++++++++++++-
 1 file changed, 85 insertions(+), 3 deletions(-)
drivers/mempool/dpaa2/dpaa2_hw_mempool.c +85 -3
index ee001d8ce0..f19b6c039a 100644
@@ -34,16 +34,90 @@
 
 #include <dpaax_iova_table.h>
 
+#define DPAA2_POOL_MP_SYNC "dpaa2_pool_mp_sync"
+#define DPAA2_POOL_OPS_IDX_REQ 0x100
+#define DPAA2_POOL_OPS_IDX_RSP 0x101
+
+static int s_dpaa2_pool_mp_msg_setup;
+
+struct dpaa2_pool_mp_msg {
+	uint16_t msg_type;
+	uint8_t msg_data[];
+};
+
 RTE_EXPORT_INTERNAL_SYMBOL(rte_dpaa2_bpid_info)
 struct dpaa2_bp_info *rte_dpaa2_bpid_info;
 static struct dpaa2_bp_list *h_bp_list;
 
 static int16_t s_dpaa2_pool_ops_idx = RTE_MEMPOOL_MAX_OPS_IDX;
 
+static int
+dpaa2_mbuf_pool_mp_primary(const struct rte_mp_msg *msg,
+	const void *peer)
+{
+	struct rte_mp_msg reply;
+	const struct dpaa2_pool_mp_msg *req_msg = (const void *)msg->param;
+	struct dpaa2_pool_mp_msg *rsp_msg = (void *)reply.param;
+
+	memset(&reply, 0, sizeof(reply));
+
+	switch (req_msg->msg_type) {
+	case DPAA2_POOL_OPS_IDX_REQ:
+		rsp_msg->msg_type = DPAA2_POOL_OPS_IDX_RSP;
+		rte_memcpy(rsp_msg->msg_data, &s_dpaa2_pool_ops_idx,
+			sizeof(s_dpaa2_pool_ops_idx));
+		break;
+	default:
+		DPAA2_MEMPOOL_ERR("%s received invalid request(%d)",
+			__func__, req_msg->msg_type);
+		return -ENOTSUP;
+	}
+
+	strlcpy(reply.name, DPAA2_POOL_MP_SYNC, sizeof(reply.name));
+	return rte_mp_reply(&reply, peer);
+}
+
 RTE_EXPORT_INTERNAL_SYMBOL(rte_dpaa2_mpool_get_ops_idx)
 int rte_dpaa2_mpool_get_ops_idx(void)
 {
-	return s_dpaa2_pool_ops_idx;
+	struct rte_mp_msg mp_req;
+	struct rte_mp_reply mp_reply;
+	struct timespec ts = {.tv_sec = 5, .tv_nsec = 0};
+	int ret = 0;
+	struct dpaa2_pool_mp_msg *req_msg = (void *)mp_req.param;
+	struct dpaa2_pool_mp_msg *rsp_msg;
+
+	if (rte_eal_process_type() == RTE_PROC_PRIMARY ||
+		s_dpaa2_pool_ops_idx != RTE_MEMPOOL_MAX_OPS_IDX)
+		return s_dpaa2_pool_ops_idx;
+
+	strlcpy(mp_req.name, DPAA2_POOL_MP_SYNC, sizeof(mp_req.name));
+	req_msg->msg_type = DPAA2_POOL_OPS_IDX_REQ;
+	memset(&mp_reply, 0, sizeof(struct rte_mp_reply));
+	ret = rte_mp_request_sync(&mp_req, &mp_reply, &ts);
+	if (ret) {
+		DPAA2_MEMPOOL_ERR("%s Failed to get response(%d)",
+			__func__, ret);
+		return ret;
+	}
+	if (!mp_reply.msgs) {
+		DPAA2_MEMPOOL_ERR("%s Failed to get response message",
+			__func__);
+		return -EINVAL;
+	}
+	rsp_msg = (void *)mp_reply.msgs;
+	if (rsp_msg->msg_type == DPAA2_POOL_OPS_IDX_RSP) {
+		rte_memcpy(&s_dpaa2_pool_ops_idx, rsp_msg->msg_data,
+			sizeof(s_dpaa2_pool_ops_idx));
+		ret = 0;
+	} else {
+		DPAA2_MEMPOOL_ERR("%s received invalid response(%d)",
+			__func__, rsp_msg->msg_type);
+		ret = -EINVAL;
+	}
+	free(mp_reply.msgs);
+
+	return ret;
 }
 
 static int
@@ -128,10 +202,18 @@ rte_hw_mbuf_create_pool(struct rte_mempool *mp)
 	if (s_dpaa2_pool_ops_idx == RTE_MEMPOOL_MAX_OPS_IDX) {
 		s_dpaa2_pool_ops_idx = mp->ops_index;
 	} else if (s_dpaa2_pool_ops_idx != mp->ops_index) {
-		DPAA2_MEMPOOL_ERR("Only single ops index only");
+		DPAA2_MEMPOOL_ERR("Single ops index only");
 		ret = -EINVAL;
 		goto err4;
 	}
+	if (rte_eal_process_type() == RTE_PROC_PRIMARY &&
+		!s_dpaa2_pool_mp_msg_setup) {
+		ret = rte_mp_action_register(DPAA2_POOL_MP_SYNC,
+			dpaa2_mbuf_pool_mp_primary);
+		if (ret && rte_errno != ENOTSUP)
+			return ret;
+		s_dpaa2_pool_mp_msg_setup = 1;
+	}
 
 	bp_list->next = h_bp_list;
 	bp_list->mp = mp;
@@ -172,7 +254,7 @@ rte_hw_mbuf_free_pool(struct rte_mempool *mp)
 	struct dpaa2_dpbp_dev *dpbp_node;
 
 	if (!mp->pool_data) {
-		DPAA2_MEMPOOL_ERR("Not a valid dpaa2 buffer pool");
+		DPAA2_MEMPOOL_ERR("Not a valid dpaa2 buffer pool %s", mp->name);
 		return;
 	}
 
Signature · 1 line
2.43.0
#68 lore raw

PATCH v2 14/47 net/dpaa2: set Tx confirmation on device init

In reply to Prashant Gupta

From: Gagandeep Singh <[email protected]>

Move TX confirmation mode setting from TXQ setup to device initialization because TXQ0 is not always set up by the user.

---
 drivers/net/dpaa2/dpaa2_ethdev.c | 40 ++++++++++++--------------------
 1 file changed, 15 insertions(+), 25 deletions(-)
drivers/net/dpaa2/dpaa2_ethdev.c +15 -25
index f211357919..c95704d4ca 100644
@@ -1153,7 +1153,6 @@ dpaa2_dev_tx_queue_setup(struct rte_eth_dev *dev,
 	struct dpni_queue tx_conf_cfg;
 	struct dpni_queue tx_flow_cfg;
 	uint8_t options = 0, flow_id;
-	uint8_t ceetm_ch_idx;
 	uint16_t channel_id;
 	struct dpni_queue_id qid;
 	uint32_t tc_id;
@@ -1174,30 +1173,6 @@ dpaa2_dev_tx_queue_setup(struct rte_eth_dev *dev,
 	memset(&tx_conf_cfg, 0, sizeof(struct dpni_queue));
 	memset(&tx_flow_cfg, 0, sizeof(struct dpni_queue));
 
-	if (!tx_queue_id) {
-		for (ceetm_ch_idx = 0;
-			ceetm_ch_idx <= (priv->num_channels - 1);
-			ceetm_ch_idx++) {
-			/*Set tx-conf and error configuration*/
-			if (priv->flags & DPAA2_TX_CONF_ENABLE) {
-				ret = dpni_set_tx_confirmation_mode(dpni,
-						CMD_PRI_LOW, priv->token,
-						ceetm_ch_idx,
-						DPNI_CONF_AFFINE);
-			} else {
-				ret = dpni_set_tx_confirmation_mode(dpni,
-						CMD_PRI_LOW, priv->token,
-						ceetm_ch_idx,
-						DPNI_CONF_DISABLE);
-			}
-			if (ret) {
-				DPAA2_PMD_ERR("Error(%d) in tx conf setting",
-					ret);
-				return ret;
-			}
-		}
-	}
-
 	tc_id = tx_queue_id % priv->num_tx_tc;
 	channel_id = (uint8_t)(tx_queue_id / priv->num_tx_tc) % priv->num_channels;
 	flow_id = 0;
@@ -3624,6 +3599,21 @@ dpaa2_dev_init(struct rte_eth_dev *eth_dev)
 		goto init_err;
 	}
 
+	for (i = 0; i < priv->num_channels; i++) {
+		/*Set tx-conf and error configuration*/
+		if (priv->flags & DPAA2_TX_CONF_ENABLE) {
+			ret = dpni_set_tx_confirmation_mode(dpni_dev,
+				CMD_PRI_LOW, priv->token, i, DPNI_CONF_AFFINE);
+		} else {
+			ret = dpni_set_tx_confirmation_mode(dpni_dev,
+				CMD_PRI_LOW, priv->token, i, DPNI_CONF_DISABLE);
+		}
+		if (ret) {
+			DPAA2_PMD_ERR("Error(%d) in tx conf setting", ret);
+			goto init_err;
+		}
+	}
+
 	/* Allocate memory for storing MAC addresses.
 	 * Table of mac_filter_entries size is allocated so that RTE ether lib
 	 * can add MAC entries when rte_eth_dev_mac_addr_add is called.
Signature · 1 line
2.43.0
#69 lore raw

PATCH v2 15/47 drivers: optimize dpaa2 Tx queue and channel mapping

In reply to Prashant Gupta

From: Gagandeep Singh <[email protected]>

Allocate TX queues based on dpni attribute and align the bounds check with the RX queue logic:
- compute nb_tx_queues from num_tx_tcs * num_queues (respecting DPNI_OPT_SINGLE_SENDER) and cap at MAX_TX_QUEUES (128)
- cap nb_rx_queues at MAX_RX_QUEUES (128)
- cap num_channels at DPAA2_MAX_CHANNELS
- assign tc_index/flow_id at queue-allocation time instead of at queue-setup time
- replace the open-coded (channel << 8 | tc) with DPNI_BUILD_PARAM(channel, tc) throughout tx_queue_setup
- initialize fqid to DPAA2_INVALID_FQ_ID and use it as the already-configured guard (replacing DPAA2_INVALID_FLOW_ID)
- add a per-device tx_channels[] array for channel mapping

---
 drivers/bus/fslmc/portal/dpaa2_hw_pvt.h |   1 +
 drivers/net/dpaa2/dpaa2_ethdev.c        | 112 ++++++++++++++----------
 drivers/net/dpaa2/dpaa2_ethdev.h        |   5 +-
 3 files changed, 70 insertions(+), 48 deletions(-)
drivers/bus/fslmc/portal/dpaa2_hw_pvt.h +1 -0
index ef65e7895a..f0bc9a3063 100644
@@ -82,6 +82,7 @@
 
 #define DPAA2_DPCI_MAX_QUEUES 2
 #define DPAA2_INVALID_FLOW_ID 0xffff
+#define DPAA2_INVALID_FQ_ID ((uint32_t)(-1))
 #define DPAA2_INVALID_CGID 0xff
 
 #define SEC_FLC_DHR_OUTBOUND	(-114)
drivers/net/dpaa2/dpaa2_ethdev.c +66 -46

212 lines not on this page · raw message

drivers/net/dpaa2/dpaa2_ethdev.h +3 -2
index 149954fb6b..0366315ec7 100644
@@ -28,7 +28,7 @@
 
 #define MAX_TCS			DPNI_MAX_TC
 #define MAX_RX_QUEUES		128
-#define MAX_TX_QUEUES		16
+#define MAX_TX_QUEUES		128
 #define MAX_DPNI		8
 #define DPAA2_MAX_CHANNELS	16
 
@@ -390,13 +390,14 @@ struct dpaa2_dev_priv {
 	int32_t hw_id;
 	int32_t qdid;
 	uint16_t token;
+	uint16_t tx_channels[DPAA2_MAX_CHANNELS];
 	uint8_t nb_tx_queues;
 	uint8_t nb_rx_queues;
 	uint32_t options;
 	void *rx_vq[MAX_RX_QUEUES];
 	void *tx_vq[MAX_TX_QUEUES];
 	struct dpaa2_bp_list *bp_list; /**<Attached buffer pool list */
-	void *tx_conf_vq[MAX_TX_QUEUES * DPAA2_MAX_CHANNELS];
+	void *tx_conf_vq[MAX_TX_QUEUES];
 	void *rx_err_vq;
 	uint32_t flags; /*dpaa2 config flags */
 	uint8_t max_mac_filters;
Signature · 1 line
2.43.0
#70 lore raw

PATCH v2 16/47 net/dpaa2: support larger burst size

In reply to Prashant Gupta

From: Gagandeep Singh <[email protected]>

Make burst size checks and MC command fields SoC-aware, enabling bursts larger than 64K on LX2160A with dpni version 8.7+.

The max_burst_size field in dpni_tx_shaping_cfg is widened to uint32_t and the MC command struct is updated to split the value across two 16-bit fields using the new DPNI_BURST_LO/HI macros.

---
 drivers/net/dpaa2/dpaa2_tm.c        | 16 +++++++++++-----
 drivers/net/dpaa2/mc/dpni.c         | 11 +++++++++--
 drivers/net/dpaa2/mc/fsl_dpni.h     |  8 ++++++--
 drivers/net/dpaa2/mc/fsl_dpni_cmd.h |  3 ++-
 4 files changed, 28 insertions(+), 10 deletions(-)
drivers/net/dpaa2/dpaa2_tm.c +11 -5
index 36e815c356..41b0f99a90 100644
@@ -1,5 +1,5 @@
 /* SPDX-License-Identifier: BSD-3-Clause
- * Copyright 2020-2024 NXP
+ * Copyright 2020-2026 NXP
  */
 
 #include <rte_ethdev.h>
@@ -10,14 +10,20 @@
 #include "dpaa2_pmd_logs.h"
 #include <dpaa2_hw_dpio.h>
 
-#define DPAA2_BURST_MAX	(64 * 1024)
-
 #define DPAA2_SHAPER_MIN_RATE 0
 #define DPAA2_SHAPER_MAX_RATE 107374182400ull
 #define DPAA2_WEIGHT_MAX 24701
 #define DPAA2_PKT_ADJUST_LEN_MIN 0
 #define DPAA2_PKT_ADJUST_LEN_MAX 0x7ff
 
+static inline uint32_t dpaa2_get_burst_max(struct dpaa2_dev_priv *priv)
+{
+	if (priv->dpni_ver_major == 8 && priv->dpni_ver_minor >= 7)
+		return (dpaa2_svr_family == SVR_LX2160A) ? 229375 : (64 * 1024);
+
+	return 64 * 1024;
+}
+
 int
 dpaa2_tm_init(struct rte_eth_dev *dev)
 {
@@ -283,7 +289,7 @@ dpaa2_shaper_profile_add(struct rte_eth_dev *dev, uint32_t shaper_profile_id,
 				RTE_TM_ERROR_TYPE_SHAPER_PROFILE_PEAK_RATE,
 				NULL, "committed rate is out of range\n");
 
-	if (params->committed.size > DPAA2_BURST_MAX)
+	if (params->committed.size > dpaa2_get_burst_max(priv))
 		return -rte_tm_error_set(error, EINVAL,
 				RTE_TM_ERROR_TYPE_SHAPER_PROFILE_PEAK_SIZE,
 				NULL, "committed size is out of range\n");
@@ -293,7 +299,7 @@ dpaa2_shaper_profile_add(struct rte_eth_dev *dev, uint32_t shaper_profile_id,
 				RTE_TM_ERROR_TYPE_SHAPER_PROFILE_PEAK_RATE,
 				NULL, "Peak rate is out of range\n");
 
-	if (params->peak.size > DPAA2_BURST_MAX)
+	if (params->peak.size > dpaa2_get_burst_max(priv))
 		return -rte_tm_error_set(error, EINVAL,
 				RTE_TM_ERROR_TYPE_SHAPER_PROFILE_PEAK_SIZE,
 				NULL, "Peak size is out of range\n");
drivers/net/dpaa2/mc/dpni.c +9 -2
index d0a9fefd31..17275b7195 100644
@@ -1106,6 +1106,7 @@ int dpni_set_tx_shaping(struct fsl_mc_io *mc_io,
 {
 	struct dpni_cmd_set_tx_shaping *cmd_params;
 	struct mc_command cmd = { 0 };
+	uint32_t tx_cr_burst, tx_er_burst;
 	int coupled, lni_shaper;
 	uint8_t channel_id;
 	uint16_t oal;
@@ -1115,10 +1116,16 @@ int dpni_set_tx_shaping(struct fsl_mc_io *mc_io,
 					  cmd_flags,
 					  token);
 	cmd_params = (struct dpni_cmd_set_tx_shaping *)cmd.params;
+	tx_cr_burst = tx_cr_shaper->max_burst_size;
+	tx_er_burst = tx_er_shaper->max_burst_size;
 	cmd_params->tx_cr_max_burst_size =
-		cpu_to_le16(tx_cr_shaper->max_burst_size);
+		cpu_to_le16(DPNI_BURST_LO(tx_cr_burst));
 	cmd_params->tx_er_max_burst_size =
-		cpu_to_le16(tx_er_shaper->max_burst_size);
+		cpu_to_le16(DPNI_BURST_LO(tx_er_burst));
+	cmd_params->tx_cr_max_burst_size_hi =
+		cpu_to_le16(DPNI_BURST_HI(tx_cr_burst));
+	cmd_params->tx_er_max_burst_size_hi =
+		cpu_to_le16(DPNI_BURST_HI(tx_er_burst));
 	cmd_params->tx_cr_rate_limit =
 		cpu_to_le32(tx_cr_shaper->rate_limit);
 	cmd_params->tx_er_rate_limit =
drivers/net/dpaa2/mc/fsl_dpni.h +6 -2
index 42d633eaf8..8913b408e7 100644
@@ -830,14 +830,18 @@ int dpni_get_link_state(struct fsl_mc_io *mc_io,
 			uint16_t token,
 			struct dpni_link_state *state);
 
+#define DPNI_BURST_LO(burst)	((burst) & GENMASK(15, 0))
+#define DPNI_BURST_HI(burst)	((burst) >> 16)
+
 /**
  * struct dpni_tx_shaping - Structure representing DPNI tx shaping configuration
  * @rate_limit:		Rate in Mbits/s
- * @max_burst_size:	Burst size in bytes (up to 64KB)
+ * @max_burst_size:	Burst size in bytes. Limits depend on the SoC (0x37FFF
+ *		for LX2160A, 0xF7FF for all others)
  */
 struct dpni_tx_shaping_cfg {
 	uint32_t rate_limit;
-	uint16_t max_burst_size;
+	uint32_t max_burst_size;
 };
 
 /**
drivers/net/dpaa2/mc/fsl_dpni_cmd.h +2 -1
index bb4939031b..6b396ca7cc 100644
@@ -394,7 +394,8 @@ struct dpni_rsp_get_link_state {
 struct dpni_cmd_set_tx_shaping {
 	uint16_t tx_cr_max_burst_size;
 	uint16_t tx_er_max_burst_size;
-	uint32_t pad;
+	uint16_t tx_cr_max_burst_size_hi;
+	uint16_t tx_er_max_burst_size_hi;
 	uint32_t tx_cr_rate_limit;
 	uint32_t tx_er_rate_limit;
 	/* from LSB: coupled:1, lni_shaper: 1*/
Signature · 1 line
2.43.0
#71 lore raw

PATCH v2 17/47 net/dpaa2: support MPLS and PPPoE flow distribution

In reply to Prashant Gupta

From: Gagandeep Singh <[email protected]>

Add rte_flow pattern support for MPLS and PPPoE items in the dpaa2 PMD flow engine.

For a pattern with no spec/mask, the frame is identified by its Frame Attribute Flag (FAF_MPLS_FRAM / FAF_PPPOE_PPP_FRAM) for both the QoS and flow steering tables. When a spec is present, the MPLS label (NH_FLD_MPLS_MPLSL_1) or the PPPoE session id (NH_FLD_PPPOE_SID) is added as a header extract rule for both tables.

---
 drivers/net/dpaa2/dpaa2_flow.c | 196 +++++++++++++++++++++++++++++++++
 1 file changed, 196 insertions(+)
drivers/net/dpaa2/dpaa2_flow.c +196 -0
index 63c253ab3b..b168a69ed5 100644
@@ -81,6 +81,8 @@ enum rte_flow_item_type dpaa2_hp_supported_pattern_type[] = {
 	RTE_FLOW_ITEM_TYPE_GTP,
 	RTE_FLOW_ITEM_TYPE_ESP,
 	RTE_FLOW_ITEM_TYPE_AH,
+	RTE_FLOW_ITEM_TYPE_MPLS,
+	RTE_FLOW_ITEM_TYPE_PPPOES,
 	RTE_FLOW_ITEM_TYPE_RAW
 };
 
@@ -181,8 +183,17 @@ static const struct rte_flow_item_gtp dpaa2_flow_item_gtp_mask = {
 	.teid = RTE_BE32(0xffffffff),
 };
 
+static const struct rte_flow_item_mpls dpaa2_flow_item_mpls_mask = {
+	.label_tc_s = { 0xff, 0xff, 0xff },
+};
+
+static const struct rte_flow_item_pppoe dpaa2_flow_item_pppoe_mask = {
+	.session_id = RTE_BE16(0xffff),
+};
+
 #endif
 
+
 #define DPAA2_FLOW_DUMP printf
 
 static inline void
@@ -1765,6 +1776,14 @@ dpaa2_flow_extract_support(const uint8_t *mask_src,
 		mask_support = (const char *)&dpaa2_flow_item_gtp_mask;
 		size = sizeof(struct rte_flow_item_gtp);
 		break;
+	case RTE_FLOW_ITEM_TYPE_MPLS:
+		mask_support = (const char *)&dpaa2_flow_item_mpls_mask;
+		size = sizeof(struct rte_flow_item_mpls);
+		break;
+	case RTE_FLOW_ITEM_TYPE_PPPOES:
+		mask_support = (const char *)&dpaa2_flow_item_pppoe_mask;
+		size = sizeof(struct rte_flow_item_pppoe);
+		break;
 	default:
 		return -EINVAL;
 	}
@@ -4042,6 +4061,163 @@ dpaa2_configure_flow_gtp(struct dpaa2_dev_flow *flow,
 	return 0;
 }
 
+static int
+dpaa2_configure_flow_mpls(struct dpaa2_dev_flow *flow,
+	struct rte_eth_dev *dev,
+	const struct rte_flow_attr *attr,
+	const struct rte_dpaa2_flow_item *dpaa2_pattern,
+	const struct rte_flow_action actions[] __rte_unused,
+	struct rte_flow_error *error __rte_unused,
+	int *device_configured)
+{
+	int ret, local_cfg = 0;
+	uint32_t group;
+	const struct rte_flow_item_mpls *spec, *mask;
+	struct dpaa2_dev_priv *priv = dev->data->dev_private;
+	const struct rte_flow_item *pattern =
+		&dpaa2_pattern->generic_item;
+
+	group = attr->group;
+
+	/* Parse pattern list to get the matching parameters */
+	spec = pattern->spec;
+	mask = pattern->mask ?
+		pattern->mask : &dpaa2_flow_item_mpls_mask;
+
+	/* Get traffic class index and flow id to be configured */
+	flow->tc_id = group;
+	flow->tc_index = attr->priority;
+
+	if (dpaa2_pattern->in_tunnel) {
+		DPAA2_PMD_ERR("Tunnel-MPLS distribution not support");
+		return -ENOTSUP;
+	}
+
+	if (!spec) {
+		ret = dpaa2_flow_identify_by_faf(priv, flow,
+				FAF_MPLS_FRAM, DPAA2_FLOW_QOS_TYPE,
+				group, &local_cfg);
+		if (ret)
+			return ret;
+
+		ret = dpaa2_flow_identify_by_faf(priv, flow,
+				FAF_MPLS_FRAM, DPAA2_FLOW_FS_TYPE,
+				group, &local_cfg);
+		if (ret)
+			return ret;
+
+		(*device_configured) |= local_cfg;
+		return 0;
+	}
+
+	ret = dpaa2_flow_extract_support((const uint8_t *)mask,
+		RTE_FLOW_ITEM_TYPE_MPLS);
+	if (ret) {
+		DPAA2_PMD_WARN("Extract field(s) of MPLS not support.");
+		return ret;
+	}
+
+	if (!mask->label_tc_s[0] && !mask->label_tc_s[1] &&
+		!mask->label_tc_s[2])
+		return 0;
+
+	ret = dpaa2_flow_add_hdr_extract_rule(flow, NET_PROT_MPLS,
+			NH_FLD_MPLS_MPLSL_1, spec->label_tc_s,
+			mask->label_tc_s, sizeof(mask->label_tc_s),
+			priv, group, &local_cfg, DPAA2_FLOW_QOS_TYPE);
+	if (ret)
+		return ret;
+
+	ret = dpaa2_flow_add_hdr_extract_rule(flow, NET_PROT_MPLS,
+			NH_FLD_MPLS_MPLSL_1, spec->label_tc_s,
+			mask->label_tc_s, sizeof(mask->label_tc_s),
+			priv, group, &local_cfg, DPAA2_FLOW_FS_TYPE);
+	if (ret)
+		return ret;
+
+	(*device_configured) |= local_cfg;
+
+	return 0;
+}
+
+static int
+dpaa2_configure_flow_pppoe(struct dpaa2_dev_flow *flow,
+	struct rte_eth_dev *dev,
+	const struct rte_flow_attr *attr,
+	const struct rte_dpaa2_flow_item *dpaa2_pattern,
+	const struct rte_flow_action actions[] __rte_unused,
+	struct rte_flow_error *error __rte_unused,
+	int *device_configured)
+{
+	int ret, local_cfg = 0;
+	uint32_t group;
+	const struct rte_flow_item_pppoe *spec, *mask;
+	struct dpaa2_dev_priv *priv = dev->data->dev_private;
+	const struct rte_flow_item *pattern =
+		&dpaa2_pattern->generic_item;
+
+	group = attr->group;
+
+	/* Parse pattern list to get the matching parameters */
+	spec = pattern->spec;
+	mask = pattern->mask ?
+		pattern->mask : &dpaa2_flow_item_pppoe_mask;
+
+	/* Get traffic class index and flow id to be configured */
+	flow->tc_id = group;
+	flow->tc_index = attr->priority;
+
+	if (dpaa2_pattern->in_tunnel) {
+		DPAA2_PMD_ERR("Tunnel-PPPoE distribution not support");
+		return -ENOTSUP;
+	}
+
+	if (!spec) {
+		ret = dpaa2_flow_identify_by_faf(priv, flow,
+				FAF_PPPOE_PPP_FRAM, DPAA2_FLOW_QOS_TYPE,
+				group, &local_cfg);
+		if (ret)
+			return ret;
+
+		ret = dpaa2_flow_identify_by_faf(priv, flow,
+				FAF_PPPOE_PPP_FRAM, DPAA2_FLOW_FS_TYPE,
+				group, &local_cfg);
+		if (ret)
+			return ret;
+
+		(*device_configured) |= local_cfg;
+		return 0;
+	}
+
+	ret = dpaa2_flow_extract_support((const uint8_t *)mask,
+		RTE_FLOW_ITEM_TYPE_PPPOES);
+	if (ret) {
+		DPAA2_PMD_WARN("Extract field(s) of PPPoE not support.");
+		return ret;
+	}
+
+	if (!mask->session_id)
+		return 0;
+
+	ret = dpaa2_flow_add_hdr_extract_rule(flow, NET_PROT_PPPOE,
+			NH_FLD_PPPOE_SID, &spec->session_id,
+			&mask->session_id, sizeof(rte_be16_t),
+			priv, group, &local_cfg, DPAA2_FLOW_QOS_TYPE);
+	if (ret)
+		return ret;
+
+	ret = dpaa2_flow_add_hdr_extract_rule(flow, NET_PROT_PPPOE,
+			NH_FLD_PPPOE_SID, &spec->session_id,
+			&mask->session_id, sizeof(rte_be16_t),
+			priv, group, &local_cfg, DPAA2_FLOW_FS_TYPE);
+	if (ret)
+		return ret;
+
+	(*device_configured) |= local_cfg;
+
+	return 0;
+}
+
 static int
 dpaa2_configure_flow_raw(struct dpaa2_dev_flow *flow,
 	struct rte_eth_dev *dev,
@@ -4713,6 +4889,26 @@ dpaa2_generic_flow_set(struct dpaa2_dev_flow *flow,
 				goto end_flow_set;
 			}
 			break;
+		case RTE_FLOW_ITEM_TYPE_MPLS:
+			ret = dpaa2_configure_flow_mpls(flow,
+					dev, attr, &dpaa2_pattern[i],
+					actions, error,
+					&is_keycfg_configured);
+			if (ret) {
+				DPAA2_PMD_ERR("MPLS flow config failed!");
+				goto end_flow_set;
+			}
+			break;
+		case RTE_FLOW_ITEM_TYPE_PPPOES:
+			ret = dpaa2_configure_flow_pppoe(flow,
+					dev, attr, &dpaa2_pattern[i],
+					actions, error,
+					&is_keycfg_configured);
+			if (ret) {
+				DPAA2_PMD_ERR("PPPoE flow config failed!");
+				goto end_flow_set;
+			}
+			break;
 		case RTE_FLOW_ITEM_TYPE_RAW:
 			ret = dpaa2_configure_flow_raw(flow, dev, attr,
 					&dpaa2_pattern[i],
Signature · 1 line
2.43.0
#72 lore raw

PATCH v2 18/47 net/dpaa2: support meter and policing

In reply to Prashant Gupta

From: Gagandeep Singh <[email protected]>

Add support for the traffic metering and policing (rte_mtr) API to the dpaa2 PMD. The implementation registers the rte_mtr operations through the ".mtr_ops_get" dev_ops hook and maintains software bookkeeping of meter profiles, policies and meter objects under a per-device spinlock.

Supported algorithms are trTCM RFC 2698 and trTCM RFC 4115 in both byte and packet modes. Meter policies support drop and pass-through actions on the red color.

---
 drivers/net/dpaa2/dpaa2_ethdev.c |   1 +
 drivers/net/dpaa2/dpaa2_ethdev.h |  29 ++
 drivers/net/dpaa2/dpaa2_meter.c  | 588 +++++++++++++++++++++++++++++++
 drivers/net/dpaa2/mc/fsl_dpni.h  |  23 +-
 drivers/net/dpaa2/meson.build    |   1 +
 5 files changed, 638 insertions(+), 4 deletions(-)
 create mode 100644 drivers/net/dpaa2/dpaa2_meter.c
drivers/net/dpaa2/dpaa2_ethdev.c +1 -0
index d79dfa7114..c8abab830f 100644
@@ -3322,6 +3322,7 @@ static struct eth_dev_ops dpaa2_ethdev_ops = {
 	.rxq_info_get	      = dpaa2_rxq_info_get,
 	.txq_info_get	      = dpaa2_txq_info_get,
 	.tm_ops_get	      = dpaa2_tm_ops_get,
+	.mtr_ops_get	      = dpaa2_mtr_ops_get,
 #if defined(RTE_LIBRTE_IEEE1588)
 	.timesync_enable      = dpaa2_timesync_enable,
 	.timesync_disable     = dpaa2_timesync_disable,
drivers/net/dpaa2/dpaa2_ethdev.h +29 -0
index 0366315ec7..c5aac65c28 100644
@@ -385,6 +385,30 @@ struct extract_s {
 	uint8_t *tc_extract_param[MAX_TCS];
 };
 
+struct dpaa2_dev_meter_profile {
+	LIST_ENTRY(dpaa2_dev_meter_profile) next;
+	uint32_t profile_id;
+	uint64_t cir;
+	uint64_t cbs;
+	uint64_t pir;
+	uint64_t pbs;
+	enum dpni_policer_mode mode;
+	enum dpni_policer_unit policer_unit;
+};
+
+struct dpaa2_dev_meter_policy {
+	LIST_ENTRY(dpaa2_dev_meter_policy) next;
+	uint32_t policy_id;
+	int red_drop;
+};
+
+struct dpaa2_dev_meter {
+	LIST_ENTRY(dpaa2_dev_meter) next;
+	uint32_t meter_id;
+	uint32_t profile_id;
+	uint32_t policy_id;
+};
+
 struct dpaa2_dev_priv {
 	void *hw;
 	int32_t hw_id;
@@ -412,6 +436,7 @@ struct dpaa2_dev_priv {
 	uint8_t en_loose_ordered;
 	uint8_t max_cgs;
 	uint8_t cgid_in_use[MAX_RX_QUEUES];
+	rte_spinlock_t meter_lock;
 
 	/* Current hash distribution size per RX TC, written by
 	 * dpaa2_setup_flow_dist_size() and read by reta_query / reta_update.
@@ -457,6 +482,9 @@ struct dpaa2_dev_priv {
 
 	struct dpaa2_dev_flow *curr;
 	LIST_HEAD(, dpaa2_dev_flow) flows;
+	LIST_HEAD(, dpaa2_dev_meter_profile) profiles;
+	LIST_HEAD(, dpaa2_dev_meter_policy) policies;
+	LIST_HEAD(, dpaa2_dev_meter) meters;
 	LIST_HEAD(nodes, dpaa2_tm_node) nodes;
 	LIST_HEAD(shaper_profiles, dpaa2_tm_shaper_profile) shaper_profiles;
 };
@@ -549,6 +577,7 @@ int dpaa2_timesync_read_tx_timestamp(struct rte_eth_dev *dev,
 
 int dpaa2_dev_recycle_config(struct rte_eth_dev *eth_dev);
 int dpaa2_dev_recycle_deconfig(struct rte_eth_dev *eth_dev);
+int dpaa2_mtr_ops_get(struct rte_eth_dev *dev, void *ops);
 int dpaa2_soft_parser_loaded(void);
 
 void
drivers/net/dpaa2/dpaa2_meter.c new file +588 -0

588 lines not on this page · raw message

drivers/net/dpaa2/mc/fsl_dpni.h +19 -4
index 8913b408e7..d227025e01 100644
@@ -1111,6 +1111,11 @@ int dpni_set_rx_tc_dist(struct fsl_mc_io *mc_io,
  */
 #define DPNI_POLICER_OPT_DISCARD_RED	0x00000002
 
+/**
+ * Do NOT reset counters generally for policer update
+ */
+#define DPNI_POLICER_OPT_DO_NOT_RESET_COUNTERS	0x00000004
+
 /**
  * enum dpni_policer_mode - selecting the policer mode
  * @DPNI_POLICER_MODE_NONE: Policer is disabled
@@ -1127,12 +1132,17 @@ enum dpni_policer_mode {
 
 /**
  * enum dpni_policer_unit - DPNI policer units
- * @DPNI_POLICER_UNIT_BYTES: bytes units
+ * @DPNI_POLICER_UNIT_BYTES_L3: bytes units (for each frame takes into account
+ * FD length - L3 offset)
  * @DPNI_POLICER_UNIT_FRAMES: frames units
+ * @DPNI_POLICER_UNIT_BYTES_L2_WITHOUT_FCS: bytes units (for each frame takes
+ * into account FD length - L2 offset, which means L2 size without the 4 bytes
+ * for the FCS)
  */
 enum dpni_policer_unit {
-	DPNI_POLICER_UNIT_BYTES = 0,
-	DPNI_POLICER_UNIT_FRAMES
+	DPNI_POLICER_UNIT_BYTES_L3 = 0,
+	DPNI_POLICER_UNIT_FRAMES,
+	DPNI_POLICER_UNIT_BYTES_L2_WITHOUT_FCS,
 };
 
 /**
@@ -1173,13 +1183,18 @@ struct dpni_rx_tc_policing_cfg {
 	uint32_t ebs;
 };
 
-
 int dpni_set_rx_tc_policing(struct fsl_mc_io *mc_io,
 			    uint32_t cmd_flags,
 			    uint16_t token,
 			    uint8_t tc_id,
 			    const struct dpni_rx_tc_policing_cfg *cfg);
 
+int dpni_set_rx_tc_policing_v1(struct fsl_mc_io *mc_io,
+			    uint32_t cmd_flags,
+			    uint16_t token,
+			    uint8_t tc_id,
+			    const struct dpni_rx_tc_policing_cfg *cfg);
+
 int dpni_get_rx_tc_policing(struct fsl_mc_io *mc_io,
 			    uint32_t cmd_flags,
 			    uint16_t token,
drivers/net/dpaa2/meson.build +1 -0
index 4094ea02ba..808dad8112 100644
@@ -11,6 +11,7 @@ sources = files(
         'base/dpaa2_hw_dpni.c',
         'base/dpaa2_tlu_hash.c',
         'dpaa2_tm.c',
+        'dpaa2_meter.c',
         'dpaa2_mux.c',
         'dpaa2_ethdev.c',
         'dpaa2_flow.c',
Signature · 1 line
2.43.0
#73 lore raw

PATCH v2 19/47 net/dpaa2: support flow drop action

In reply to Prashant Gupta

From: Gagandeep Singh <[email protected]>

Add support for the RTE_FLOW_ACTION_TYPE_DROP action in the dpaa2 flow engine. A flow rule with a drop action is programmed into the flow steering (FS) table with the DPNI_FS_OPT_DISCARD option so that matching frames are discarded by hardware.

The drop action is added to the supported action list, accepted during action verification, configured in the FS action path, handled in the generic flow-set action loop, and cleaned up in the flow destroy path.

---
 drivers/net/dpaa2/dpaa2_flow.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/net/dpaa2/dpaa2_flow.c +7 -1
index b168a69ed5..07ecdd0e7b 100644
@@ -98,7 +98,8 @@ enum rte_flow_action_type dpaa2_supported_action_type[] = {
 	RTE_FLOW_ACTION_TYPE_QUEUE,
 	RTE_FLOW_ACTION_TYPE_PORT_ID,
 	RTE_FLOW_ACTION_TYPE_REPRESENTED_PORT,
-	RTE_FLOW_ACTION_TYPE_RSS
+	RTE_FLOW_ACTION_TYPE_RSS,
+	RTE_FLOW_ACTION_TYPE_DROP
 };
 
 #ifndef __cplusplus
@@ -4422,6 +4423,7 @@ dpaa2_flow_verify_action(struct dpaa2_dev_priv *priv,
 			break;
 		case RTE_FLOW_ACTION_TYPE_PF:
 			/* Skip this action, have to add for vxlan */
+		case RTE_FLOW_ACTION_TYPE_DROP:
 			break;
 		case RTE_FLOW_ACTION_TYPE_END:
 			end_of_list = 1;
@@ -4469,6 +4471,8 @@ dpaa2_configure_flow_fs_action(struct dpaa2_dev_priv *priv,
 		flow->fs_action_cfg.redirect_obj_token =
 			dest_priv->token;
 		flow->fs_action_cfg.flow_id = dest_q->flow_id;
+	} else if (flow->action_type == RTE_FLOW_ACTION_TYPE_DROP) {
+		flow->fs_action_cfg.options = DPNI_FS_OPT_DISCARD;
 	}
 
 	return 0;
@@ -4946,6 +4950,7 @@ dpaa2_generic_flow_set(struct dpaa2_dev_flow *flow,
 		case RTE_FLOW_ACTION_TYPE_QUEUE:
 		case RTE_FLOW_ACTION_TYPE_REPRESENTED_PORT:
 		case RTE_FLOW_ACTION_TYPE_PORT_ID:
+		case RTE_FLOW_ACTION_TYPE_DROP:
 			ret = dpaa2_configure_flow_fs_action(priv, flow,
 							     &actions[j]);
 			if (ret)
@@ -5347,6 +5352,7 @@ dpaa2_flow_destroy(struct rte_eth_dev *dev, struct rte_flow *_flow,
 	case RTE_FLOW_ACTION_TYPE_QUEUE:
 	case RTE_FLOW_ACTION_TYPE_REPRESENTED_PORT:
 	case RTE_FLOW_ACTION_TYPE_PORT_ID:
+	case RTE_FLOW_ACTION_TYPE_DROP:
 		if (priv->num_rx_tc > 1) {
 			/* Remove entry from QoS table first */
 			ret = dpni_remove_qos_entry(dpni, CMD_PRI_LOW,
Signature · 1 line
2.43.0
#74 lore raw

PATCH v2 20/47 net/dpaa2: set default flow miss action per device

In reply to Prashant Gupta

From: Gagandeep Singh <[email protected]>

The flow steering miss flow id was a file-scope global configured only via the DPAA2_FLOW_CONTROL_MISS_FLOW environment variable and defaulted to 0. Replace it with a per-device default_flow computed at probe time as the lowest priority flow of the FS table, so that unmatched frames are directed there without depending on an environment variable.

---
 drivers/net/dpaa2/dpaa2_ethdev.c |  2 ++
 drivers/net/dpaa2/dpaa2_ethdev.h |  2 ++
 drivers/net/dpaa2/dpaa2_flow.c   | 14 +-------------
 3 files changed, 5 insertions(+), 13 deletions(-)
drivers/net/dpaa2/dpaa2_ethdev.c +2 -0
index c8abab830f..387a153036 100644
@@ -3545,6 +3545,8 @@ dpaa2_dev_init(struct rte_eth_dev *eth_dev)
 	priv->dist_queues = attr.num_queues;
 	priv->num_channels = attr.num_channels;
 	priv->channel_inuse = 0;
+	priv->default_flow = RTE_MIN(priv->fs_entries,
+		priv->dist_queues) - 1;
 	rte_spinlock_init(&priv->lpbk_qp_lock);
 
 	/* only if the custom CG is enabled */
drivers/net/dpaa2/dpaa2_ethdev.h +2 -0
index c5aac65c28..4501bd9e49 100644
@@ -437,6 +437,8 @@ struct dpaa2_dev_priv {
 	uint8_t max_cgs;
 	uint8_t cgid_in_use[MAX_RX_QUEUES];
 	rte_spinlock_t meter_lock;
+	/* Lowest priority FS flow id to receive flow steering miss frames. */
+	uint16_t default_flow;
 
 	/* Current hash distribution size per RX TC, written by
 	 * dpaa2_setup_flow_dist_size() and read by reta_query / reta_update.
drivers/net/dpaa2/dpaa2_flow.c +1 -13
index 07ecdd0e7b..750b93498b 100644
@@ -25,7 +25,6 @@
 #include <dpaa2_pmd_logs.h>
 
 static char *dpaa2_flow_control_log;
-static uint16_t dpaa2_flow_miss_flow_id; /* Default miss flow id is 0. */
 static int dpaa2_sp_loaded = -1;
 
 enum dpaa2_flow_entry_size {
@@ -4591,7 +4590,7 @@ dpaa2_configure_fs_rss_table(struct dpaa2_dev_priv *priv,
 		return 0;
 
 	tc_cfg.enable = true;
-	tc_cfg.fs_miss_flow_id = dpaa2_flow_miss_flow_id;
+	tc_cfg.fs_miss_flow_id = priv->default_flow;
 	ret = dpni_set_rx_fs_dist(dpni, CMD_PRI_LOW,
 			priv->token, &tc_cfg);
 	if (ret < 0) {
@@ -5225,17 +5224,6 @@ dpaa2_flow_create(struct rte_eth_dev *dev, const struct rte_flow_attr *attr,
 	dpaa2_flow_control_log =
 		getenv("DPAA2_FLOW_CONTROL_LOG");
 
-	if (getenv("DPAA2_FLOW_CONTROL_MISS_FLOW")) {
-		dpaa2_flow_miss_flow_id =
-			(uint16_t)atoi(getenv("DPAA2_FLOW_CONTROL_MISS_FLOW"));
-		if (dpaa2_flow_miss_flow_id >= priv->dist_queues) {
-			DPAA2_PMD_ERR("Missed flow ID %d >= dist size(%d)",
-				      dpaa2_flow_miss_flow_id,
-				      priv->dist_queues);
-			return NULL;
-		}
-	}
-
 	flow = rte_zmalloc(NULL, sizeof(struct dpaa2_dev_flow),
 			   RTE_CACHE_LINE_SIZE);
 	if (!flow) {
Signature · 1 line
2.43.0
#75 lore raw

PATCH v2 21/47 net/dpaa2: identify Rx mbuf hash information by FLC

In reply to Prashant Gupta

From: Gagandeep Singh <[email protected]>

For default RSS distribution, mbuf is marked with RTE_MBUF_F_RX_RSS_HASH and the hash value from the high word of FLC.

Configure the flow steering action with FLC enabled to align the stashing setting with the RSS configuration. The TC ID and flow ID are packed into the FLC for mbuf Rx scheduling. An Rx mbuf received from the FS table is marked with RTE_MBUF_F_RX_FDIR along with the TC and flow ID decoded from the FLC low word.

---
 drivers/net/dpaa2/dpaa2_ethdev.h | 12 +++++++++
 drivers/net/dpaa2/dpaa2_flow.c   | 42 ++++++++++++++++++++++++++++++++
 drivers/net/dpaa2/dpaa2_rxtx.c   | 18 ++++++++++++--
 3 files changed, 70 insertions(+), 2 deletions(-)
drivers/net/dpaa2/dpaa2_ethdev.h +12 -0
index 4501bd9e49..c693989998 100644
@@ -282,6 +282,18 @@ enum dpaa2_ecpri_fafe_type {
 /* ECPRI shares SP context with VXLAN*/
 #define DPAA2_ECPRI_MSG_OFFSET DPAA2_VXLAN_VNI_OFFSET
 
+#define DPAA2_FS_FLC_FS_MARK_OFFSET \
+	(DPAA2_FLC_DATA_STASHING + DPAA2_FLC_STASHING_MAX_BIT_SIZE)
+
+#define DPAA2_FS_FLC_TC_OFFSET \
+	(DPAA2_FS_FLC_FS_MARK_OFFSET + DPAA2_FLC_STASHING_MAX_BIT_SIZE)
+
+#define DPAA2_FS_FLC_TC_BIT_SIZE (sizeof(uint8_t) * 8)
+#define DPAA2_FS_FLC_TC_MASK ((1 << DPAA2_FS_FLC_TC_BIT_SIZE) - 1)
+
+#define DPAA2_FS_FLC_FLOW_OFFSET \
+	(DPAA2_FS_FLC_TC_OFFSET + DPAA2_FS_FLC_TC_BIT_SIZE)
+
 #define DPAA2_ECPRI_MAX_EXTRACT_NB 8
 
 struct ipv4_sd_addr_extract_rule {
drivers/net/dpaa2/dpaa2_flow.c +42 -0

61 lines not on this page · raw message

drivers/net/dpaa2/dpaa2_rxtx.c +16 -2
index c31d6556ad..7ba6a4563f 100644
@@ -58,6 +58,7 @@ dpaa2_dev_rx_parse_new(struct rte_mbuf *m, const struct qbman_fd *fd,
 	uint16_t frc = DPAA2_GET_FD_FRC_PARSE_SUM(fd);
 	struct dpaa2_annot_hdr *annotation =
 			(struct dpaa2_annot_hdr *)hw_annot_addr;
+	uint32_t flc_lo, tc, flow;
 
 	if (unlikely(dpaa2_print_parser_result))
 		dpaa2_print_parse_result(annotation);
@@ -118,8 +119,21 @@ dpaa2_dev_rx_parse_new(struct rte_mbuf *m, const struct qbman_fd *fd,
 	default:
 		m->packet_type = dpaa2_dev_rx_parse_slow(m, annotation);
 	}
-	m->hash.rss = fd->simple.flc_hi;
-	m->ol_flags |= RTE_MBUF_F_RX_RSS_HASH;
+	flc_lo = fd->simple.flc_lo;
+	if (flc_lo & (1 << DPAA2_FS_FLC_FS_MARK_OFFSET)) {
+		m->ol_flags |= RTE_MBUF_F_RX_FDIR;
+		tc = (flc_lo >> DPAA2_FS_FLC_TC_OFFSET) &
+			DPAA2_FS_FLC_TC_MASK;
+		flow = flc_lo >> DPAA2_FS_FLC_FLOW_OFFSET;
+		rte_mbuf_sched_set(m, flow, tc, 0);
+		DPAA2_PMD_DP_DEBUG("FS frame received from TC[%d]->flow%d",
+			tc, flow);
+	} else {
+		m->hash.rss = fd->simple.flc_hi;
+		m->ol_flags |= RTE_MBUF_F_RX_RSS_HASH;
+		DPAA2_PMD_DP_DEBUG("Hash frame received with RSS(%08x)",
+			m->hash.rss);
+	}
 
 	if (dpaa2_enable_ts[m->port]) {
 		*dpaa2_timestamp_dynfield(m) = annotation->word2;
Signature · 1 line
2.43.0
#76 lore raw

PATCH v2 22/47 net/dpaa2: add minimum key size support

In reply to Prashant Gupta

From: Hemant Agrawal <[email protected]>

The default size for a QoS key is 24 bytes. If the key size is smaller than the maximum, use the default (minimum) key size instead of always returning the maximum size (56 bytes). This allows smaller flow tables to be used when the extracted key fits within the default size.

---
 drivers/net/dpaa2/dpaa2_flow.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/net/dpaa2/dpaa2_flow.c +5 -3
index dfe1774d25..016a1e98b4 100644
@@ -27,8 +27,11 @@
 static char *dpaa2_flow_control_log;
 static int dpaa2_sp_loaded = -1;
 
+/* Default size of a key */
+#define DPNI_DEFAULT_KEY_SIZE 24
+
 enum dpaa2_flow_entry_size {
-	DPAA2_FLOW_ENTRY_MIN_SIZE = (DPNI_MAX_KEY_SIZE / 2),
+	DPAA2_FLOW_ENTRY_MIN_SIZE = DPNI_DEFAULT_KEY_SIZE,
 	DPAA2_FLOW_ENTRY_MAX_SIZE = DPNI_MAX_KEY_SIZE
 };
 
@@ -4533,8 +4536,7 @@ dpaa2_flow_entry_size(uint16_t key_max_size)
 	if (key_max_size > DPAA2_FLOW_ENTRY_MIN_SIZE)
 		return DPAA2_FLOW_ENTRY_MAX_SIZE;
 
-	/* Current MC only support fixed entry size(56)*/
-	return DPAA2_FLOW_ENTRY_MAX_SIZE;
+	return DPAA2_FLOW_ENTRY_MIN_SIZE;
 }
 
 static inline int
Signature · 1 line
2.43.0
#77 lore raw

PATCH v2 23/47 net/dpaa2: restructure dpaa2 parser processing

In reply to Prashant Gupta

From: Hemant Agrawal <[email protected]>

Move the parse-result decoding into a dedicated header so that the hardware parser fields are described in one place and shared between the flow code and the Rx path. No functional change is intended.

---
 drivers/net/dpaa2/dpaa2_ethdev.h        |  172 ++-
 drivers/net/dpaa2/dpaa2_parse_dump.h    |  374 ------
 drivers/net/dpaa2/dpaa2_parser_decode.h | 1545 +++++++++++++++++++++++
 drivers/net/dpaa2/dpaa2_rxtx.c          |  332 ++---
 4 files changed, 1845 insertions(+), 578 deletions(-)
 delete mode 100644 drivers/net/dpaa2/dpaa2_parse_dump.h
 create mode 100644 drivers/net/dpaa2/dpaa2_parser_decode.h
drivers/net/dpaa2/dpaa2_ethdev.h +113 -59
index c693989998..ddc1917b23 100644
@@ -21,6 +21,8 @@
 #include <mc/fsl_dpmac.h>
 
 #include "base/dpaa2_hw_dpni_annot.h"
+#include "dpaa2_parser_decode.h"
+
 
 #define DPAA2_MIN_RX_BUF_SIZE 512
 #define DPAA2_MAX_RX_PKT_LEN  10240 /*WRIOP support*/
@@ -101,6 +103,7 @@
 #define DPAA2_DATA_STASHING_OFF		RTE_BIT32(10)
 
 #define DPAAX_RX_ERROR_QUEUE_FLAG	RTE_BIT32(11)
+#define DPAA2_RX_PRINT_PSR_RESULT_FLAG RTE_BIT32(12)
 
 /* DPDMUX index for DPMAC */
 #define DPAA2_DPDMUX_DPMAC_IDX 0
@@ -124,31 +127,62 @@
 	RTE_ETH_RSS_PPPOE)
 
 /* LX2 FRC Parsed values (Little Endian) */
-#define DPAA2_PKT_TYPE_ETHER		0x0060
-#define DPAA2_PKT_TYPE_IPV4		0x0000
-#define DPAA2_PKT_TYPE_IPV6		0x0020
+#define DPAA2_PKT_TYPE_ETHER \
+	(DPAA2_PSR_SUMMARY_NONIP << DPAA2_PSR_SUMMARY_NON_IP_L2_BIT_SIZE)
+#define DPAA2_PKT_TYPE_IPV4 \
+	(DPAA2_PSR_SUMMARY_IPV4 << DPAA2_PSR_SUMMARY_L4_BIT_SIZE)
+#define DPAA2_PKT_TYPE_IPV6 \
+	(DPAA2_PSR_SUMMARY_IPV6 << DPAA2_PSR_SUMMARY_L4_BIT_SIZE)
+
+/**Tunnel*/
+#define DPAA2_PKT_TYPE_L3_EXT \
+	(DPAA2_PSR_SUMMARY_L4_EXT << DPAA2_PSR_SUMMARY_L4_EXT_L3_POS)
+#define DPAA2_PKT_TYPE_L3_EXT_IPV4 \
+	(DPAA2_PSR_SUMMARY_IPV4 << DPAA2_PSR_SUMMARY_L4_EXT_BIT_SIZE)
+#define DPAA2_PKT_TYPE_L3_EXT_IPV6 \
+	(DPAA2_PSR_SUMMARY_IPV6 << DPAA2_PSR_SUMMARY_L4_EXT_BIT_SIZE)
 #define DPAA2_PKT_TYPE_IPV4_EXT \
-			(0x0001 | DPAA2_PKT_TYPE_IPV4)
+	(DPAA2_PKT_TYPE_L3_EXT | DPAA2_PKT_TYPE_L3_EXT_IPV4)
 #define DPAA2_PKT_TYPE_IPV6_EXT \
-			(0x0001 | DPAA2_PKT_TYPE_IPV6)
+	(DPAA2_PKT_TYPE_L3_EXT | DPAA2_PKT_TYPE_L3_EXT_IPV6)
+#define DPAA2_PKT_TYPE_IPV4_EXT_GRE_IPV4 \
+	(DPAA2_PKT_TYPE_IPV4_EXT | DPAA2_PSR_SUMMARY_GRE_IPV4)
+#define DPAA2_PKT_TYPE_IPV4_EXT_GRE_IPV4_UDP_TCP \
+	(DPAA2_PKT_TYPE_IPV4_EXT | DPAA2_PSR_SUMMARY_GRE_IPV4_UDP_TCP)
+#define DPAA2_PKT_TYPE_IPV4_EXT_GRE_IPV6 \
+	(DPAA2_PKT_TYPE_IPV4_EXT | DPAA2_PSR_SUMMARY_GRE_IPV6)
+#define DPAA2_PKT_TYPE_IPV4_EXT_GRE_IPV6_UDP_TCP \
+	(DPAA2_PKT_TYPE_IPV4_EXT | DPAA2_PSR_SUMMARY_GRE_IPV6_UDP_TCP)
+#define DPAA2_PKT_TYPE_IPV6_EXT_GRE_IPV4 \
+	(DPAA2_PKT_TYPE_IPV6_EXT | DPAA2_PSR_SUMMARY_GRE_IPV4)
+#define DPAA2_PKT_TYPE_IPV6_EXT_GRE_IPV4_UDP_TCP \
+	(DPAA2_PKT_TYPE_IPV6_EXT | DPAA2_PSR_SUMMARY_GRE_IPV4_UDP_TCP)
+#define DPAA2_PKT_TYPE_IPV6_EXT_GRE_IPV6 \
+	(DPAA2_PKT_TYPE_IPV6_EXT | DPAA2_PSR_SUMMARY_GRE_IPV6)
+#define DPAA2_PKT_TYPE_IPV6_EXT_GRE_IPV6_UDP_TCP \
+	(DPAA2_PKT_TYPE_IPV6_EXT | DPAA2_PSR_SUMMARY_GRE_IPV6_UDP_TCP)
+
 #define DPAA2_PKT_TYPE_IPV4_TCP \
-			(0x000e | DPAA2_PKT_TYPE_IPV4)
+	(DPAA2_PSR_SUMMARY_TCP | DPAA2_PKT_TYPE_IPV4)
 #define DPAA2_PKT_TYPE_IPV6_TCP \
-			(0x000e | DPAA2_PKT_TYPE_IPV6)
+	(DPAA2_PSR_SUMMARY_TCP | DPAA2_PKT_TYPE_IPV6)
 #define DPAA2_PKT_TYPE_IPV4_UDP \
-			(0x0010 | DPAA2_PKT_TYPE_IPV4)
+	(DPAA2_PSR_SUMMARY_UDP | DPAA2_PKT_TYPE_IPV4)
 #define DPAA2_PKT_TYPE_IPV6_UDP \
-			(0x0010 | DPAA2_PKT_TYPE_IPV6)
-#define DPAA2_PKT_TYPE_IPV4_SCTP	\
-			(0x000f | DPAA2_PKT_TYPE_IPV4)
-#define DPAA2_PKT_TYPE_IPV6_SCTP	\
-			(0x000f | DPAA2_PKT_TYPE_IPV6)
+	(DPAA2_PSR_SUMMARY_UDP | DPAA2_PKT_TYPE_IPV6)
+#define DPAA2_PKT_TYPE_IPV4_SCTP \
+	(DPAA2_PSR_SUMMARY_SCTP | DPAA2_PKT_TYPE_IPV4)
+#define DPAA2_PKT_TYPE_IPV6_SCTP \
+	(DPAA2_PSR_SUMMARY_SCTP | DPAA2_PKT_TYPE_IPV6)
 #define DPAA2_PKT_TYPE_IPV4_ICMP \
-			(0x0003 | DPAA2_PKT_TYPE_IPV4_EXT)
+	(DPAA2_PSR_SUMMARY_ICMP | DPAA2_PKT_TYPE_IPV4)
 #define DPAA2_PKT_TYPE_IPV6_ICMP \
-			(0x0003 | DPAA2_PKT_TYPE_IPV6_EXT)
-#define DPAA2_PKT_TYPE_VLAN_1		0x0160
-#define DPAA2_PKT_TYPE_VLAN_2		0x0260
+	(DPAA2_PSR_SUMMARY_ICMP | DPAA2_PKT_TYPE_IPV6)
+
+#define DPAA2_PKT_TYPE_VLAN_1	0x0100
+#define DPAA2_PKT_TYPE_VLAN_2	0x0200
+#define DPAA2_PKT_TYPE_VLAN \
+	(DPAA2_PKT_TYPE_VLAN_1 | DPAA2_PKT_TYPE_VLAN_2)
 
 /* mac counters */
 #define DPAA2_MAC_NUM_STATS            (DPMAC_CNT_EGR_CONTROL_FRAME + 1)
@@ -173,17 +207,33 @@ struct sw_buf_free {
 	struct rte_mbuf *seg;
 };
 
-/* enable timestamp in mbuf*/
-extern bool dpaa2_enable_ts[];
-extern uint64_t dpaa2_timestamp_rx_dynflag;
-extern int dpaa2_timestamp_dynfield_offset;
-
 /* Externally defined */
 extern const struct rte_flow_ops dpaa2_flow_ops;
 
 extern const struct rte_tm_ops dpaa2_tm_ops;
 
-extern bool dpaa2_print_parser_result;
+struct dpaa2_dyn_rx_protocol_pos {
+	uint8_t l3_offset;
+	uint8_t l4_offset;
+	uint8_t l5_offset;
+	uint8_t rsv;
+};
+
+#define L3_OFFSET_OF_MBUF_DYN 0
+#define L4_OFFSET_OF_MBUF_DYN 1
+#define L5_OFFSET_OF_MBUF_DYN 2
+
+#define DPAA2_FS_FLC_FS_MARK_OFFSET \
+	(DPAA2_FLC_DATA_STASHING + DPAA2_FLC_STASHING_MAX_BIT_SIZE)
+
+#define DPAA2_FS_FLC_TC_OFFSET \
+	(DPAA2_FS_FLC_FS_MARK_OFFSET + DPAA2_FLC_STASHING_MAX_BIT_SIZE)
+
+#define DPAA2_FS_FLC_TC_BIT_SIZE (sizeof(uint8_t) * 8)
+#define DPAA2_FS_FLC_TC_MASK ((1 << DPAA2_FS_FLC_TC_BIT_SIZE) - 1)
+
+#define DPAA2_FS_FLC_FLOW_OFFSET \
+	(DPAA2_FS_FLC_TC_OFFSET + DPAA2_FS_FLC_TC_BIT_SIZE)
 
 #define DPAA2_FAPR_SIZE \
 	(sizeof(struct dpaa2_annot_hdr) - \
@@ -258,42 +308,6 @@ enum dpaa2_ecpri_fafe_type {
 #define DPAA2_PR_L5_OFF_OFFSET 31
 #define DPAA2_PR_NXTHDR_OFF_OFFSET 34
 
-/* Set by SP for vxlan distribution start*/
-#define DPAA2_VXLAN_IN_TCI_OFFSET 16
-
-#define DPAA2_VXLAN_IN_DADDR0_OFFSET 20
-#define DPAA2_VXLAN_IN_DADDR1_OFFSET 22
-#define DPAA2_VXLAN_IN_DADDR2_OFFSET 24
-#define DPAA2_VXLAN_IN_DADDR3_OFFSET 25
-#define DPAA2_VXLAN_IN_DADDR4_OFFSET 26
-#define DPAA2_VXLAN_IN_DADDR5_OFFSET 28
-
-#define DPAA2_VXLAN_IN_SADDR0_OFFSET 29
-#define DPAA2_VXLAN_IN_SADDR1_OFFSET 32
-#define DPAA2_VXLAN_IN_SADDR2_OFFSET 33
-#define DPAA2_VXLAN_IN_SADDR3_OFFSET 35
-#define DPAA2_VXLAN_IN_SADDR4_OFFSET 41
-#define DPAA2_VXLAN_IN_SADDR5_OFFSET 42
-
-#define DPAA2_VXLAN_VNI_OFFSET 43
-#define DPAA2_VXLAN_IN_TYPE_OFFSET 46
-/* Set by SP for vxlan distribution end*/
-
-/* ECPRI shares SP context with VXLAN*/
-#define DPAA2_ECPRI_MSG_OFFSET DPAA2_VXLAN_VNI_OFFSET
-
-#define DPAA2_FS_FLC_FS_MARK_OFFSET \
-	(DPAA2_FLC_DATA_STASHING + DPAA2_FLC_STASHING_MAX_BIT_SIZE)
-
-#define DPAA2_FS_FLC_TC_OFFSET \
-	(DPAA2_FS_FLC_FS_MARK_OFFSET + DPAA2_FLC_STASHING_MAX_BIT_SIZE)
-
-#define DPAA2_FS_FLC_TC_BIT_SIZE (sizeof(uint8_t) * 8)
-#define DPAA2_FS_FLC_TC_MASK ((1 << DPAA2_FS_FLC_TC_BIT_SIZE) - 1)
-
-#define DPAA2_FS_FLC_FLOW_OFFSET \
-	(DPAA2_FS_FLC_TC_OFFSET + DPAA2_FS_FLC_TC_BIT_SIZE)
-
 #define DPAA2_ECPRI_MAX_EXTRACT_NB 8
 
 struct ipv4_sd_addr_extract_rule {
@@ -436,6 +450,7 @@ struct dpaa2_dev_priv {
 	void *tx_conf_vq[MAX_TX_QUEUES];
 	void *rx_err_vq;
 	uint32_t flags; /*dpaa2 config flags */
+	int psr_dynfield_offset;
 	uint8_t max_mac_filters;
 	uint8_t max_vlan_filters;
 	uint8_t num_rx_tc;
@@ -475,6 +490,9 @@ struct dpaa2_dev_priv {
 	uint64_t rx_timestamp;
 	/*stores timestamp of last received tx confirmation packet on dev*/
 	uint64_t tx_timestamp;
+
+	int rx_ts_offset;
+	uint64_t rx_ts_flag;
 	/* stores pointer to next tx_conf queue that should be processed,
 	 * it corresponds to last packet transmitted
 	 */
@@ -483,6 +501,7 @@ struct dpaa2_dev_priv {
 	struct rte_eth_dev *eth_dev; /**< Pointer back to holding ethdev */
 	rte_spinlock_t lpbk_qp_lock;
 
+	bool sp_protocol;
 	uint8_t channel_inuse;
 	/* Rx-interrupt mode latched at the first dev_configure */
 	uint8_t intr_mode;
@@ -514,6 +533,41 @@ static inline int dpaa2_dev_cmp_dpni_ver(struct dpaa2_dev_priv *priv,
 	return priv->dpni_ver_major - ver_major;
 }
 
+static inline void
+dpaa2_dev_rx_print_parser_result(struct dpaa2_dev_priv *priv,
+	const struct qbman_fd *fd, const struct rte_mbuf *m)
+{
+	size_t fd_addr;
+	void *hw_annot_addr;
+
+	if (likely(!(priv->flags & DPAA2_RX_PRINT_PSR_RESULT_FLAG)))
+		return;
+
+	if (dpaa2_svr_family == SVR_LX2160A)
+		dpaa2_print_fd_frc(fd);
+
+	fd_addr = (size_t)DPAA2_IOVA_TO_VADDR(DPAA2_GET_FD_ADDR(fd));
+	hw_annot_addr = (void *)(fd_addr + DPAA2_FD_PTA_SIZE);
+	dpaa2_print_parse_result(hw_annot_addr, priv->sp_protocol);
+	if (m->ol_flags & RTE_MBUF_F_RX_FDIR) {
+		const struct rte_mbuf_sched *sched;
+		uint16_t i;
+		struct dpaa2_queue *rxq;
+
+		sched = &m->hash.sched;
+		for (i = 0; i < MAX_RX_QUEUES; i++) {
+			rxq = priv->rx_vq[i];
+			if (rxq->tc_index == sched->traffic_class &&
+				rxq->flow_id == sched->queue_id)
+				break;
+		}
+		fprintf(rte_log_get_stream(), "Directed to TC%d-flow%d(rxq%d), color(%d)\n",
+			sched->traffic_class, sched->queue_id, i, sched->color);
+	} else if (m->ol_flags & RTE_MBUF_F_RX_RSS_HASH) {
+		fprintf(rte_log_get_stream(), "Balanced with hash(0x%08x)\n", m->hash.rss);
+	}
+}
+
 int dpaa2_distset_to_dpkg_profile_cfg(uint64_t req_dist_set,
 				      struct dpkg_profile_cfg *kg_cfg);
 
drivers/net/dpaa2/dpaa2_parse_dump.h deleted +0 -374

374 lines not on this page · raw message

drivers/net/dpaa2/dpaa2_parser_decode.h new file +1545 -0

1,545 lines not on this page · raw message

drivers/net/dpaa2/dpaa2_rxtx.c +187 -145

504 lines not on this page · raw message

Signature · 1 line
2.43.0
#78 lore raw

PATCH v2 24/47 net/dpaa2: parse tunnel and fragmented packet types

In reply to Prashant Gupta

From: Hemant Agrawal <[email protected]>

Extend the Rx parser to identify additional packet types decoded from the hardware parser summary: IPv4/IPv6 fragments, IPsec ESP, and GTP-U / GTP-C tunnels. The corresponding DPAA2_PKT_TYPE_* values are added and mapped to the matching RTE_PTYPE_* flags in the slow-path parser.

---
 drivers/net/dpaa2/dpaa2_ethdev.h | 16 ++++++++++++++++
 drivers/net/dpaa2/dpaa2_rxtx.c   | 32 ++++++++++++++++++++++++++++++++
 2 files changed, 48 insertions(+)
drivers/net/dpaa2/dpaa2_ethdev.h +16 -0
index ddc1917b23..c298954265 100644
@@ -162,6 +162,10 @@
 #define DPAA2_PKT_TYPE_IPV6_EXT_GRE_IPV6_UDP_TCP \
 	(DPAA2_PKT_TYPE_IPV6_EXT | DPAA2_PSR_SUMMARY_GRE_IPV6_UDP_TCP)
 
+#define DPAA2_PKT_TYPE_IPV4_FRAG \
+	(DPAA2_PSR_SUMMARY_IP_FRAG | DPAA2_PKT_TYPE_IPV4)
+#define DPAA2_PKT_TYPE_IPV6_FRAG \
+	(DPAA2_PSR_SUMMARY_IP_FRAG | DPAA2_PKT_TYPE_IPV6)
 #define DPAA2_PKT_TYPE_IPV4_TCP \
 	(DPAA2_PSR_SUMMARY_TCP | DPAA2_PKT_TYPE_IPV4)
 #define DPAA2_PKT_TYPE_IPV6_TCP \
@@ -178,6 +182,18 @@
 	(DPAA2_PSR_SUMMARY_ICMP | DPAA2_PKT_TYPE_IPV4)
 #define DPAA2_PKT_TYPE_IPV6_ICMP \
 	(DPAA2_PSR_SUMMARY_ICMP | DPAA2_PKT_TYPE_IPV6)
+#define DPAA2_PKT_TYPE_IPV4_ESP \
+	(DPAA2_PSR_SUMMARY_IPSEC_ESP | DPAA2_PKT_TYPE_IPV4)
+#define DPAA2_PKT_TYPE_IPV6_ESP \
+	(DPAA2_PSR_SUMMARY_IPSEC_ESP | DPAA2_PKT_TYPE_IPV6)
+#define DPAA2_PKT_TYPE_IPV4_GTPU \
+	(DPAA2_PSR_SUMMARY_GTPU | DPAA2_PKT_TYPE_IPV4)
+#define DPAA2_PKT_TYPE_IPV6_GTPU \
+	(DPAA2_PSR_SUMMARY_GTPU | DPAA2_PKT_TYPE_IPV6)
+#define DPAA2_PKT_TYPE_IPV4_GTPC \
+	(DPAA2_PSR_SUMMARY_GTPC | DPAA2_PKT_TYPE_IPV4)
+#define DPAA2_PKT_TYPE_IPV6_GTPC \
+	(DPAA2_PSR_SUMMARY_GTPC | DPAA2_PKT_TYPE_IPV6)
 
 #define DPAA2_PKT_TYPE_VLAN_1	0x0100
 #define DPAA2_PKT_TYPE_VLAN_2	0x0200
drivers/net/dpaa2/dpaa2_rxtx.c +32 -0
index 47c8cacdc4..26c84e7125 100644
@@ -153,6 +153,38 @@ dpaa2_dev_rx_parse_new(struct dpaa2_dev_priv *priv,
 		m->packet_type = RTE_PTYPE_L2_ETHER |
 			RTE_PTYPE_L3_IPV6;
 		break;
+	case DPAA2_PKT_TYPE_IPV4_FRAG:
+		m->packet_type = RTE_PTYPE_L2_ETHER |
+			RTE_PTYPE_L3_IPV4 | RTE_PTYPE_L4_FRAG;
+		break;
+	case DPAA2_PKT_TYPE_IPV6_FRAG:
+		m->packet_type = RTE_PTYPE_L2_ETHER |
+			RTE_PTYPE_L3_IPV6 | RTE_PTYPE_L4_FRAG;
+		break;
+	case DPAA2_PKT_TYPE_IPV4_ESP:
+		m->packet_type = RTE_PTYPE_L2_ETHER |
+			RTE_PTYPE_L3_IPV4 | RTE_PTYPE_TUNNEL_ESP;
+		break;
+	case DPAA2_PKT_TYPE_IPV6_ESP:
+		m->packet_type = RTE_PTYPE_L2_ETHER |
+			RTE_PTYPE_L3_IPV6 | RTE_PTYPE_TUNNEL_ESP;
+		break;
+	case DPAA2_PKT_TYPE_IPV4_GTPU:
+		m->packet_type = RTE_PTYPE_L2_ETHER |
+			RTE_PTYPE_L3_IPV4 | RTE_PTYPE_TUNNEL_GTPU;
+		break;
+	case DPAA2_PKT_TYPE_IPV6_GTPU:
+		m->packet_type = RTE_PTYPE_L2_ETHER |
+			RTE_PTYPE_L3_IPV6 | RTE_PTYPE_TUNNEL_GTPU;
+		break;
+	case DPAA2_PKT_TYPE_IPV4_GTPC:
+		m->packet_type = RTE_PTYPE_L2_ETHER |
+			RTE_PTYPE_L3_IPV4 | RTE_PTYPE_TUNNEL_GTPC;
+		break;
+	case DPAA2_PKT_TYPE_IPV6_GTPC:
+		m->packet_type = RTE_PTYPE_L2_ETHER |
+			RTE_PTYPE_L3_IPV6 | RTE_PTYPE_TUNNEL_GTPC;
+		break;
 	case DPAA2_PKT_TYPE_ETHER:
 		m->packet_type = RTE_PTYPE_L2_ETHER;
 		break;
Signature · 1 line
2.43.0
#79 lore raw

PATCH v2 25/47 net/dpaa2: remove unused soft parser driver

In reply to Prashant Gupta

From: Jun Yang <[email protected]>

Softparser only supports to be loaded before Linux starts.

---
 drivers/net/dpaa2/dpaa2_ethdev.c  |  28 -----
 drivers/net/dpaa2/dpaa2_recycle.c |   1 -
 drivers/net/dpaa2/dpaa2_sparser.c | 137 --------------------
 drivers/net/dpaa2/dpaa2_sparser.h | 202 ------------------------------
 drivers/net/dpaa2/meson.build     |   1 -
 5 files changed, 369 deletions(-)
 delete mode 100644 drivers/net/dpaa2/dpaa2_sparser.c
 delete mode 100644 drivers/net/dpaa2/dpaa2_sparser.h
drivers/net/dpaa2/dpaa2_ethdev.c +0 -28
index 387a153036..1df84e1316 100644
@@ -29,7 +29,6 @@
 #include <mc/fsl_dpmng.h>
 #include <mc/fsl_dpcon.h>
 #include "dpaa2_ethdev.h"
-#include "dpaa2_sparser.h"
 #include <fsl_qbman_debug.h>
 
 #define DRIVER_LOOPBACK_MODE "drv_loopback"
@@ -3738,33 +3737,6 @@ dpaa2_dev_init(struct rte_eth_dev *eth_dev)
 	}
 	eth_dev->data->mtu = RTE_ETHER_MTU;
 
-	/*TODO To enable soft parser support DPAA2 driver needs to integrate
-	 * with external entity to receive byte code for software sequence
-	 * and same will be offload to the H/W using MC interface.
-	 * Currently it is assumed that DPAA2 driver has byte code by some
-	 * mean and same if offloaded to H/W.
-	 */
-	if (getenv("DPAA2_ENABLE_SOFT_PARSER")) {
-		WRIOP_SS_INITIALIZER(priv);
-		ret = dpaa2_eth_load_wriop_soft_parser(priv, DPNI_SS_INGRESS);
-		if (ret < 0) {
-			DPAA2_PMD_ERR(" Error(%d) in loading softparser",
-				      ret);
-			goto init_err;
-		}
-
-		ret = dpaa2_eth_enable_wriop_soft_parser(priv,
-							 DPNI_SS_INGRESS);
-		if (ret < 0) {
-			DPAA2_PMD_ERR(" Error(%d) in enabling softparser",
-				      ret);
-			goto init_err;
-		}
-	}
-
-	ret = dpaa2_soft_parser_loaded();
-	if (ret > 0)
-		DPAA2_PMD_INFO("soft parser is loaded");
 	DPAA2_PMD_INFO("%s: netdev created, connected to %s",
 		eth_dev->data->name, dpaa2_dev->ep_name);
 
drivers/net/dpaa2/dpaa2_recycle.c +0 -1
index 80c20272ce..ed038c204b 100644
@@ -23,7 +23,6 @@
 #include <dpaa2_hw_dpio.h>
 #include <mc/fsl_dpmng.h>
 #include "dpaa2_ethdev.h"
-#include "dpaa2_sparser.h"
 #include <fsl_qbman_debug.h>
 
 #include <rte_io.h>
drivers/net/dpaa2/dpaa2_sparser.c deleted +0 -137

137 lines not on this page · raw message

drivers/net/dpaa2/dpaa2_sparser.h deleted +0 -202

202 lines not on this page · raw message

drivers/net/dpaa2/meson.build +0 -1
index 808dad8112..4f774f7c82 100644
@@ -17,7 +17,6 @@ sources = files(
         'dpaa2_flow.c',
         'dpaa2_recycle.c',
         'dpaa2_rxtx.c',
-        'dpaa2_sparser.c',
         'dpaa2_ptp.c',
         'mc/dprtc.c',
         'mc/dpkg.c',
Signature · 1 line
2.43.0
#80 lore raw

PATCH v2 26/47 drivers: refresh dpaa2 MC and SoC version info

In reply to Prashant Gupta

From: Jun Yang <[email protected]>

Fix MC revision typo to correct major to minor. Get MC/SoC rev info only once and save them in bus info as well as other information to reduce replicated variables.

---
 drivers/bus/fslmc/bus_fslmc_driver.h     |  11 +-
 drivers/bus/fslmc/fslmc_bus.c            |   2 +
 drivers/bus/fslmc/fslmc_vfio.c           | 200 ++++++++++++++++++-----
 drivers/bus/fslmc/fslmc_vfio.h           |  30 +++-
 drivers/bus/fslmc/portal/dpaa2_hw_dpio.c |  79 +--------
 drivers/bus/fslmc/portal/dpaa2_hw_dpio.h |   7 -
 drivers/bus/fslmc/private.h              |   3 +
 drivers/net/dpaa2/dpaa2_ethdev.c         |  18 +-
 drivers/net/dpaa2/dpaa2_ethdev.h         |   1 +
 drivers/net/dpaa2/dpaa2_rxtx.c           |  10 +-
 10 files changed, 225 insertions(+), 136 deletions(-)
drivers/bus/fslmc/bus_fslmc_driver.h +10 -1
index 44f81cf662..3ba865e632 100644
@@ -1,6 +1,6 @@
 /* SPDX-License-Identifier: BSD-3-Clause
  *
- *   Copyright 2016,2021-2023 NXP
+ *   Copyright 2016,2021-2026 NXP
  *
  */
 
@@ -89,6 +89,14 @@ enum rte_dpaa2_dev_type {
 	DPAA2_DEVTYPE_MAX,
 };
 
+struct rte_fslmc_bus_info {
+	void *mem_pool;
+	int sp_protocol;
+	uint64_t mc_rev;
+	uint32_t svr;
+	uint32_t pvr;
+};
+
 /**
  * A structure describing a DPAA2 device.
  */
@@ -102,6 +110,7 @@ struct rte_dpaa2_device {
 	char ep_name[RTE_DEV_NAME_MAX_LEN];
 	struct rte_intr_handle *intr_handle; /**< Interrupt handle */
 	char name[FSLMC_OBJECT_MAX_LEN];    /**< DPAA2 Object name*/
+	const struct rte_fslmc_bus_info *bus_info;
 };
 
 typedef int (*rte_dpaa2_obj_create_t)(int vdev_fd,
drivers/bus/fslmc/fslmc_bus.c +2 -0
index ee162b0ed8..2427421075 100644
@@ -29,6 +29,7 @@
 
 struct rte_bus rte_fslmc_bus;
 static int fslmc_bus_device_count[DPAA2_DEVTYPE_MAX];
+struct rte_fslmc_bus_info fslmc_bus_info;
 
 #define DPAA2_SEQN_DYNFIELD_NAME "dpaa2_seqn_dynfield"
 RTE_EXPORT_INTERNAL_SYMBOL(dpaa2_seqn_dynfield_offset)
@@ -199,6 +200,7 @@ scan_one_fslmc_device(char *dev_name)
 		goto cleanup;
 	}
 	dev->device.devargs = rte_bus_find_devargs(&rte_fslmc_bus, dev_name);
+	dev->bus_info = &fslmc_bus_info;
 
 	/* Update the device found into the device_count table */
 	fslmc_bus_device_count[dev->dev_type]++;
drivers/bus/fslmc/fslmc_vfio.c +162 -38

307 lines not on this page · raw message

drivers/bus/fslmc/fslmc_vfio.h +29 -1
index c995fd67b8..554123ffa6 100644
@@ -1,7 +1,7 @@
 /* SPDX-License-Identifier: BSD-3-Clause
  *
  *   Copyright (c) 2015-2016 Freescale Semiconductor, Inc. All rights reserved.
- *   Copyright 2016,2019-2023 NXP
+ *   Copyright 2016,2019-2026 NXP
  *
  */
 
@@ -9,6 +9,8 @@
 #define _FSLMC_VFIO_H_
 
 #include <rte_compat.h>
+#include <rte_vfio.h>
+#include <rte_interrupts.h>
 
 /* Pathname of FSL-MC devices directory. */
 #define SYSFS_FSL_MC_DEVICES	"/sys/bus/fsl-mc/devices"
@@ -44,6 +46,30 @@ struct fslmc_vfio_container {
 
 extern char *fslmc_container;
 
+extern uint32_t dpaa2_svr_family;
+extern uint32_t dpaa2_dqrr_size;
+extern uint32_t dpaa2_eqcr_size;
+extern uint32_t dpaa2_cluster_base;
+extern uint32_t dpaa2_cluster_size;
+
+#define DPAA2_SVR_MASK 0xffff0000
+
+#define SVR_LS1080A	0x87030000
+#define SVR_LS2080A	0x87010000
+#define SVR_LS2088A	0x87090000
+#define SVR_LX2160A	0x87360000
+
+#define MC_MAJOR_OFFSET 32
+#define MC_MINOR_OFFSET 16
+#define MC_MINOR_MASK ((((uint64_t)1) << (MC_MAJOR_OFFSET - MC_MINOR_OFFSET)) - 1)
+#define MC_REVISION_MASK ((((uint64_t)1) << MC_MINOR_OFFSET) - 1)
+#define RTE_FSL_MC_REV(major, minor, revision) \
+	((((uint64_t)(major)) << MC_MAJOR_OFFSET) + \
+	(((uint64_t)(minor)) << MC_MINOR_OFFSET) + (revision))
+#define RTE_FSL_MC_REV_MAJOR(rev) ((uint32_t)((rev) >> MC_MAJOR_OFFSET))
+#define RTE_FSL_MC_REV_MINOR(rev) ((uint32_t)(((rev) >> MC_MINOR_OFFSET) & MC_MINOR_MASK))
+#define RTE_FSL_MC_REV_REVISION(rev) ((uint32_t)((rev) & MC_REVISION_MASK))
+
 __rte_internal
 int rte_dpaa2_intr_enable(struct rte_intr_handle *intr_handle, int index);
 
@@ -60,4 +86,6 @@ int fslmc_vfio_close_group(void);
 char *fslmc_get_container(void);
 int fslmc_get_container_group(const char *group_name, int *gropuid);
 int fslmc_vfio_dmamap(void);
+int fslmc_vfio_core_cluster_sdest(uint32_t cpu_id);
+
 #endif /* _FSLMC_VFIO_H_ */
drivers/bus/fslmc/portal/dpaa2_hw_dpio.c +5 -74

119 lines not on this page · raw message

drivers/bus/fslmc/portal/dpaa2_hw_dpio.h +0 -7
index 7e2271cc35..2c559e5354 100644
@@ -35,13 +35,6 @@ RTE_DECLARE_PER_LCORE(struct dpaa2_io_portal_t, _dpaa2_io);
 #define DPAA2_PER_LCORE_DQRR_MBUF(i) \
 	RTE_PER_LCORE(_dpaa2_io).dpio_dev->dpaa2_held_bufs.mbuf[i]
 
-/* Variable to store DPAA2 DQRR size */
-extern uint8_t dpaa2_dqrr_size;
-/* Variable to store DPAA2 EQCR size */
-extern uint8_t dpaa2_eqcr_size;
-
-extern struct dpaa2_io_portal_t dpaa2_io_portal[RTE_MAX_LCORE];
-
 /* Affine a DPIO portal to current processing thread */
 __rte_internal
 int dpaa2_affine_qbman_swp(void);
drivers/bus/fslmc/private.h +3 -0
index 20a454c3fc..1c8a3e59e9 100644
@@ -11,4 +11,7 @@
 
 extern struct rte_bus rte_fslmc_bus;
 
+/* MC/SoC version and capability info, shared by the bus and VFIO code. */
+extern struct rte_fslmc_bus_info fslmc_bus_info;
+
 #endif /* BUS_FSLMC_PRIVATE_H */
drivers/net/dpaa2/dpaa2_ethdev.c +8 -10
index 1df84e1316..e6ce29b2ea 100644
@@ -329,24 +329,21 @@ dpaa2_fw_version_get(struct rte_eth_dev *dev,
 	char *fw_version, size_t fw_size)
 {
 	int ret;
+	uint32_t major, minor, rev;
+	struct dpaa2_dev_priv *priv = dev->data->dev_private;
 	struct fsl_mc_io *dpni = dev->process_private;
 	struct mc_soc_version mc_plat_info = {0};
-	struct mc_version mc_ver_info = {0};
 
 	PMD_INIT_FUNC_TRACE();
 
+	major = RTE_FSL_MC_REV_MAJOR(priv->mc_rev);
+	minor = RTE_FSL_MC_REV_MINOR(priv->mc_rev);
+	rev = RTE_FSL_MC_REV_REVISION(priv->mc_rev);
 	if (mc_get_soc_version(dpni, CMD_PRI_LOW, &mc_plat_info))
 		DPAA2_PMD_WARN("\tmc_get_soc_version failed");
 
-	if (mc_get_version(dpni, CMD_PRI_LOW, &mc_ver_info))
-		DPAA2_PMD_WARN("\tmc_get_version failed");
-
-	ret = snprintf(fw_version, fw_size,
-		       "%x-%d.%d.%d",
-		       mc_plat_info.svr,
-		       mc_ver_info.major,
-		       mc_ver_info.minor,
-		       mc_ver_info.revision);
+	ret = snprintf(fw_version, fw_size, "%x-%d.%d.%d",
+		mc_plat_info.svr, major, minor, rev);
 	if (ret < 0)
 		return -EINVAL;
 
@@ -3537,6 +3534,7 @@ dpaa2_dev_init(struct rte_eth_dev *eth_dev)
 		goto init_err;
 	}
 
+	priv->mc_rev = dpaa2_dev->bus_info->mc_rev;
 	priv->num_rx_tc = attr.num_rx_tcs;
 	priv->num_tx_tc = attr.num_tx_tcs;
 	priv->qos_entries = attr.qos_entries;
drivers/net/dpaa2/dpaa2_ethdev.h +1 -0
index c298954265..9c52a6c248 100644
@@ -528,6 +528,7 @@ struct dpaa2_dev_priv {
 	uint32_t *cnt_idx_dma_mem;
 	uint64_t *cnt_values_dma_mem;
 	uint64_t cnt_idx_iova, cnt_values_iova;
+	uint64_t mc_rev;
 
 	struct dpaa2_dev_flow *curr;
 	LIST_HEAD(, dpaa2_dev_flow) flows;
drivers/net/dpaa2/dpaa2_rxtx.c +5 -5
index 26c84e7125..f417edf52b 100644
@@ -1123,9 +1123,9 @@ dpaa2_dev_rx_common(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts,
 	/* Function receive frames for a given device and VQ */
 	struct dpaa2_queue *dpaa2_q = queue;
 	struct qbman_result *dq_storage;
-	uint32_t fqid = dpaa2_q->fqid;
-	int ret, num_rx = 0, next_pull = nb_pkts, num_pulled;
-	uint8_t pending, status;
+	uint32_t fqid = dpaa2_q->fqid, next_pull = nb_pkts;
+	int ret;
+	uint8_t pending, status, num_rx = 0, num_pulled;
 	struct qbman_swp *swp;
 	const struct qbman_fd *fd;
 	struct qbman_pull_desc pulldesc;
@@ -1269,8 +1269,8 @@ uint16_t dpaa2_dev_tx_conf(void *queue)
 	struct dpaa2_queue *dpaa2_q = (struct dpaa2_queue *)queue;
 	struct qbman_result *dq_storage;
 	uint32_t fqid = dpaa2_q->fqid;
-	int ret, num_tx_conf = 0, num_pulled;
-	uint8_t pending, status;
+	int ret, num_tx_conf = 0;
+	uint8_t pending, status, num_pulled;
 	struct qbman_swp *swp;
 	const struct qbman_fd *fd;
 	struct qbman_pull_desc pulldesc;
Signature · 1 line
2.43.0
#81 lore raw

PATCH v2 27/47 drivers: identify dpaa2 soft parser protocol

In reply to Prashant Gupta

From: Jun Yang <[email protected]>

Identify if soft parser protocol firmware is loaded by checking firmware magic number.
Enable flow/parser of ECPRI, GENEVE, ROCEv2 and VXLAN's spec only with soft parser protocol firmware being loaded.

---
 drivers/bus/fslmc/fslmc_bus.c    |  83 +++++++++++++++++++-
 drivers/net/dpaa2/dpaa2_ethdev.c |   2 +
 drivers/net/dpaa2/dpaa2_flow.c   | 129 ++++++++-----------------------
 drivers/net/dpaa2/dpaa2_rxtx.c   |  10 +++
 4 files changed, 126 insertions(+), 98 deletions(-)
drivers/bus/fslmc/fslmc_bus.c +82 -1
index 2427421075..9742b0bfbf 100644
@@ -1,6 +1,6 @@
 /* SPDX-License-Identifier: BSD-3-Clause
  *
- *   Copyright 2016,2018-2021 NXP
+ *   Copyright 2016,2018-2026 NXP
  *
  */
 
@@ -8,6 +8,7 @@
 #include <dirent.h>
 #include <stdalign.h>
 #include <stdbool.h>
+#include <sys/mman.h>
 
 #include <eal_export.h>
 #include <rte_log.h>
@@ -35,6 +36,85 @@ struct rte_fslmc_bus_info fslmc_bus_info;
 RTE_EXPORT_INTERNAL_SYMBOL(dpaa2_seqn_dynfield_offset)
 int dpaa2_seqn_dynfield_offset = -1;
 
+/** For LX2160A, LS2088A and LS1088A*/
+#define WRIOP_CCSR_BASE 0x8b80000
+#define WRIOP_CCSR_CTLU_OFFSET 0
+#define WRIOP_CCSR_CTLU_PARSER_OFFSET 0
+#define WRIOP_CCSR_CTLU_PARSER_INGRESS_OFFSET 0
+
+#define WRIOP_INGRESS_PARSER_PHY \
+	(WRIOP_CCSR_BASE + WRIOP_CCSR_CTLU_OFFSET + \
+	WRIOP_CCSR_CTLU_PARSER_OFFSET + \
+	WRIOP_CCSR_CTLU_PARSER_INGRESS_OFFSET)
+
+struct __rte_packed_begin dpaa2_parser_ccsr {
+	uint32_t psr_cfg;
+	uint32_t psr_idle;
+	uint32_t psr_pclm;
+	uint8_t psr_ver_min;
+	uint8_t psr_ver_maj;
+	uint8_t psr_id1_l;
+	uint8_t psr_id1_h;
+	uint32_t psr_rev2;
+	uint8_t rsv[0x2c];
+	uint8_t sp_ins[4032];
+} __rte_packed_end;
+
+#define SP_PROTOCOL_MAGIC_DATA 0xabcd
+#define SP_PROTOCOL_MAGIC_OFFSET 0x4
+
+static void
+fslmc_soft_parser_protocol_supported(void)
+{
+	int fd, i;
+	void *map_addr = NULL;
+	const struct dpaa2_parser_ccsr *parser_ccsr = NULL;
+	const uint16_t *magic_num;
+
+	fd = open("/dev/mem", O_RDWR | O_SYNC);
+	if (fd < 0) {
+		DPAA2_BUS_ERR("open \"/dev/mem\" ERROR(%d)", fd);
+		goto exit;
+	}
+
+	map_addr = mmap(NULL, sizeof(struct dpaa2_parser_ccsr),
+		PROT_READ | PROT_WRITE, MAP_SHARED, fd,
+		WRIOP_INGRESS_PARSER_PHY);
+	parser_ccsr = map_addr;
+	if (!parser_ccsr) {
+		DPAA2_BUS_ERR("Map 0x%lx(size=0x%lx) failed",
+			(uint64_t)WRIOP_INGRESS_PARSER_PHY,
+			sizeof(struct dpaa2_parser_ccsr));
+		goto exit;
+	}
+
+	DPAA2_BUS_DEBUG("Soft ParserID:0x%02x%02x, Rev:maj(%02x), min(%02x)",
+		parser_ccsr->psr_id1_h, parser_ccsr->psr_id1_l,
+		parser_ccsr->psr_ver_maj, parser_ccsr->psr_ver_min);
+
+	magic_num = (const void *)&parser_ccsr->sp_ins[SP_PROTOCOL_MAGIC_OFFSET];
+	if (*magic_num == SP_PROTOCOL_MAGIC_DATA) {
+		#define SP_PRINT_LEN 128
+
+		fslmc_bus_info.sp_protocol = true;
+		DPAA2_BUS_INFO("Soft parser protocol support.");
+		fprintf(rte_log_get_stream(), "First %d bytes of sp protocol firmware:\r\n",
+			SP_PRINT_LEN);
+		for (i = 0; i < SP_PRINT_LEN; i++) {
+			fprintf(rte_log_get_stream(), "%02x ", parser_ccsr->sp_ins[i]);
+			if ((i + 1) % 16 == 0)
+				fprintf(rte_log_get_stream(), "\r\n");
+		}
+		fprintf(rte_log_get_stream(), "\r\n");
+	}
+
+exit:
+	if (map_addr)
+		munmap(map_addr, sizeof(struct dpaa2_parser_ccsr));
+	if (fd >= 0)
+		close(fd);
+}
+
 RTE_EXPORT_INTERNAL_SYMBOL(rte_fslmc_get_device_count)
 uint32_t
 rte_fslmc_get_device_count(enum rte_dpaa2_dev_type device_type)
@@ -345,6 +425,7 @@ rte_fslmc_scan(void)
 		DPAA2_BUS_ERR("Unable to open VFIO group directory");
 		goto scan_fail;
 	}
+	fslmc_soft_parser_protocol_supported();
 
 	/* Scan the DPRC container object */
 	ret = scan_one_fslmc_device(group_name);
drivers/net/dpaa2/dpaa2_ethdev.c +2 -0
index e6ce29b2ea..fb1d01e209 100644
@@ -3735,6 +3735,8 @@ dpaa2_dev_init(struct rte_eth_dev *eth_dev)
 	}
 	eth_dev->data->mtu = RTE_ETHER_MTU;
 
+	priv->sp_protocol = dpaa2_dev->bus_info->sp_protocol;
+
 	DPAA2_PMD_INFO("%s: netdev created, connected to %s",
 		eth_dev->data->name, dpaa2_dev->ep_name);
 
drivers/net/dpaa2/dpaa2_flow.c +32 -97

219 lines not on this page · raw message

drivers/net/dpaa2/dpaa2_rxtx.c +10 -0
index f417edf52b..ccb4bbe7dc 100644
@@ -128,6 +128,16 @@ dpaa2_dev_rx_parse_new(struct dpaa2_dev_priv *priv,
 			ext_packet_type |= RTE_PTYPE_INNER_L3_IPV4;
 		}
 	}
+	if (priv->sp_protocol) {
+		if (frc_parse->fafe2) {
+			frc_parse->fafe2 = 0;
+			ext_packet_type |= RTE_PTYPE_TUNNEL_GENEVE;
+		}
+		if (frc_parse->sum_l.l4.fafe3) {
+			frc_parse->sum_l.l4.fafe3 = 0;
+			ext_packet_type |= RTE_PTYPE_INNER_L3_IPV4;
+		}
+	}
 	switch (frc) {
 	case DPAA2_PKT_TYPE_IPV4_UDP:
 		m->packet_type = RTE_PTYPE_L2_ETHER |
Signature · 1 line
2.43.0
#82 lore raw

PATCH v2 28/47 drivers: assign dpaa2 Rx CGID per traffic class

In reply to Prashant Gupta

From: Jun Yang <[email protected]>

RXQs in same TC should use same CGID for congestion set.

---
 drivers/bus/fslmc/portal/dpaa2_hw_pvt.h |   3 +-
 drivers/net/dpaa2/dpaa2_ethdev.c        | 252 ++++++++++++------------
 drivers/net/dpaa2/dpaa2_ethdev.h        |   3 +-
 3 files changed, 126 insertions(+), 132 deletions(-)
drivers/bus/fslmc/portal/dpaa2_hw_pvt.h +2 -1
index f0bc9a3063..12216750a8 100644
@@ -176,7 +176,6 @@ struct __rte_cache_aligned dpaa2_queue {
 	uint32_t fqid;		/*!< Unique ID of this queue */
 	uint16_t flow_id;	/*!< To be used by DPAA2 framework */
 	uint8_t tc_index;	/*!< traffic class identifier */
-	uint8_t cgid;		/*! < Congestion Group id for this queue */
 	uint64_t rx_pkts;
 	uint64_t tx_pkts;
 	uint64_t err_pkts;
@@ -186,6 +185,8 @@ struct __rte_cache_aligned dpaa2_queue {
 		/**Egress*/
 		struct qbman_result *cscn;
 	};
+	void *cfg;
+	uint8_t options;
 	struct rte_event ev;
 	dpaa2_queue_cb_dqrr_t *cb;
 	dpaa2_queue_cb_eqresp_free_t *cb_eqresp_free;
drivers/net/dpaa2/dpaa2_ethdev.c +122 -130

407 lines not on this page · raw message

drivers/net/dpaa2/dpaa2_ethdev.h +2 -1
index 9c52a6c248..65c5378547 100644
@@ -478,7 +478,8 @@ struct dpaa2_dev_priv {
 	uint8_t en_ordered;
 	uint8_t en_loose_ordered;
 	uint8_t max_cgs;
-	uint8_t cgid_in_use[MAX_RX_QUEUES];
+	/** RXQs in same TC share same cgid.*/
+	uint8_t cgid_in_use[MAX_TCS];
 	rte_spinlock_t meter_lock;
 	/* Lowest priority FS flow id to receive flow steering miss frames. */
 	uint16_t default_flow;
Signature · 1 line
2.43.0
#83 lore raw

PATCH v2 29/47 drivers: inherit dpaa2 rxq config for event queue

In reply to Prashant Gupta

From: Jun Yang <[email protected]>

The configuration parameter in event queue attachment should use flc and cgid configured in rxq setup.

---
 drivers/bus/fslmc/portal/dpaa2_hw_pvt.h | 2 +-
 drivers/net/dpaa2/dpaa2_ethdev.c        | 3 ++-
 2 files changed, 3 insertions(+), 2 deletions(-)
drivers/bus/fslmc/portal/dpaa2_hw_pvt.h +1 -1
index 12216750a8..f87bf51d09 100644
@@ -1,7 +1,7 @@
 /* SPDX-License-Identifier: BSD-3-Clause
  *
  *   Copyright (c) 2016 Freescale Semiconductor, Inc. All rights reserved.
- *   Copyright 2016-2024 NXP
+ *   Copyright 2016-2025 NXP
  *
  */
 
drivers/net/dpaa2/dpaa2_ethdev.c +2 -1
index 0835296ee2..57c6e8e90b 100644
@@ -2815,11 +2815,12 @@ int dpaa2_eth_eventq_attach(const struct rte_eth_dev *dev,
 	struct dpaa2_dev_priv *eth_priv = dev->data->dev_private;
 	struct fsl_mc_io *dpni = (struct fsl_mc_io *)dev->process_private;
 	struct dpaa2_queue *dpaa2_ethq = eth_priv->rx_vq[eth_rx_queue_id];
-	uint8_t flow_id = dpaa2_ethq->flow_id;
+	uint8_t flow_id;
 	struct dpni_queue *cfg;
 	uint8_t options, priority;
 	int ret;
 
+	flow_id = dpaa2_ethq->flow_id;
 	cfg = dpaa2_ethq->cfg;
 
 	if (queue_conf->ev.sched_type == RTE_SCHED_TYPE_PARALLEL)
Signature · 1 line
2.43.0
#84 lore raw

PATCH v2 30/47 net/dpaa2: rename Rx queue flags

In reply to Prashant Gupta

From: Jun Yang <[email protected]>

Rename the Rx-side device flags to a consistent DPAA2_RX_*_FLAG naming:
DPAAX_RX_ERROR_QUEUE_FLAG becomes DPAA2_RX_ERROR_QUEUE_FLAG and DPAA2_DATA_STASHING_OFF becomes DPAA2_RX_DATA_STASHING_OFF_FLAG.

This is a mechanical rename with no functional change; it prepares the flag namespace for the Tx confirmation rework that follows.

---
 drivers/net/dpaa2/dpaa2_ethdev.c | 10 +++++-----
 drivers/net/dpaa2/dpaa2_ethdev.h |  4 ++--
 drivers/net/dpaa2/dpaa2_rxtx.c   |  4 ++--
 3 files changed, 9 insertions(+), 9 deletions(-)
drivers/net/dpaa2/dpaa2_ethdev.c +5 -5
index 57c6e8e90b..15a886b3e8 100644
@@ -547,7 +547,7 @@ dpaa2_alloc_rx_tx_queues(struct rte_eth_dev *dev)
 			goto fail;
 	}
 
-	if (priv->flags & DPAAX_RX_ERROR_QUEUE_FLAG) {
+	if (priv->flags & DPAA2_RX_ERROR_QUEUE_FLAG) {
 		priv->rx_err_vq = rte_zmalloc("dpni_rx_err",
 			sizeof(struct dpaa2_queue), 0);
 		if (!priv->rx_err_vq) {
@@ -1041,7 +1041,7 @@ dpaa2_dev_rx_queue_setup(struct rte_eth_dev *dev,
 		qopt |= DPNI_QUEUE_OPT_FLC;
 		cfg->flc.stash_control = true;
 		dpaa2_flc_stashing_clear_all(&cfg->flc.value);
-		if (priv->flags & DPAA2_DATA_STASHING_OFF) {
+		if (priv->flags & DPAA2_RX_DATA_STASHING_OFF_FLAG) {
 			dpaa2_flc_stashing_set(DPAA2_FLC_DATA_STASHING, 0,
 				&cfg->flc.value);
 			dpaa2_q->data_stashing_off = 1;
@@ -1499,7 +1499,7 @@ dpaa2_dev_start(struct rte_eth_dev *dev)
 		dpaa2_q->fqid = qid.fqid;
 	}
 
-	if (priv->flags & DPAAX_RX_ERROR_QUEUE_FLAG) {
+	if (priv->flags & DPAA2_RX_ERROR_QUEUE_FLAG) {
 		ret = dpni_get_queue(dpni, CMD_PRI_LOW, priv->token,
 				     DPNI_QUEUE_RX_ERR, 0, 0, &cfg, &qid);
 		if (ret) {
@@ -3462,7 +3462,7 @@ dpaa2_dev_init(struct rte_eth_dev *eth_dev)
 
 	if (dpaa2_get_devargs(dev->devargs, DRIVER_NO_DATA_STASHING) ||
 	    getenv("DPAA2_DATA_STASHING_OFF")) {
-		priv->flags |= DPAA2_DATA_STASHING_OFF;
+		priv->flags |= DPAA2_RX_DATA_STASHING_OFF_FLAG;
 		DPAA2_PMD_INFO("Data stashing disabled");
 	}
 
@@ -3592,7 +3592,7 @@ dpaa2_dev_init(struct rte_eth_dev *eth_dev)
 	}
 
 	if (dpaa2_get_devargs(dev->devargs, DRIVER_ERROR_QUEUE)) {
-		priv->flags |= DPAAX_RX_ERROR_QUEUE_FLAG;
+		priv->flags |= DPAA2_RX_ERROR_QUEUE_FLAG;
 		DPAA2_PMD_INFO("Enable error queue");
 	}
 
drivers/net/dpaa2/dpaa2_ethdev.h +2 -2
index 65c5378547..bdd8855023 100644
@@ -100,9 +100,9 @@
 #define DPAA2_TX_DYNAMIC_CONF_ENABLE	RTE_BIT32(9)
 
 /* Disable data stashing (prefetch of packet data into CPU cache) */
-#define DPAA2_DATA_STASHING_OFF		RTE_BIT32(10)
+#define DPAA2_RX_DATA_STASHING_OFF_FLAG		RTE_BIT32(10)
 
-#define DPAAX_RX_ERROR_QUEUE_FLAG	RTE_BIT32(11)
+#define DPAA2_RX_ERROR_QUEUE_FLAG	RTE_BIT32(11)
 #define DPAA2_RX_PRINT_PSR_RESULT_FLAG RTE_BIT32(12)
 
 /* DPDMUX index for DPMAC */
drivers/net/dpaa2/dpaa2_rxtx.c +2 -2
index ccb4bbe7dc..a03e3fd8db 100644
@@ -870,7 +870,7 @@ dpaa2_dev_prefetch_rx_common(void *queue, struct rte_mbuf **bufs,
 
 	q_storage = dpaa2_q->q_storage[rte_lcore_id()];
 
-	if (unlikely(priv->flags & DPAAX_RX_ERROR_QUEUE_FLAG))
+	if (unlikely(priv->flags & DPAA2_RX_ERROR_QUEUE_FLAG))
 		dump_err_pkts(priv->rx_err_vq);
 
 	if (unlikely(!DPAA2_PER_LCORE_ETHRX_DPIO)) {
@@ -1142,7 +1142,7 @@ dpaa2_dev_rx_common(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts,
 	struct rte_eth_dev_data *eth_data = dpaa2_q->eth_data;
 	struct dpaa2_dev_priv *priv = eth_data->dev_private;
 
-	if (!by_channel && unlikely(priv->flags & DPAAX_RX_ERROR_QUEUE_FLAG))
+	if (!by_channel && unlikely(priv->flags & DPAA2_RX_ERROR_QUEUE_FLAG))
 		dump_err_pkts(priv->rx_err_vq);
 
 	if (by_channel) {
Signature · 1 line
2.43.0
#85 lore raw

PATCH v2 31/47 drivers: rework dpaa2 Tx confirmation

In reply to Prashant Gupta

From: Jun Yang <[email protected]>

Mbufs released by Tx confirmation may come from any mempool, so use the RTE mbuf free API instead of returning the buffers directly to the bman pool. The FD FLC field now carries the Tx mbuf pointer so that the confirmation callback can release it to either the platform pool or an external pool.

Absolute and dynamic Tx confirmation become independent settings, giving three Tx modes:

1) No confirmation (default). Suited to traffic that is mostly sent from the platform pool. For the few packets from other pools the driver allocates a platform buffer, copies the data and frees the original.
2) Absolute confirmation. Suited to traffic mostly sent from non platform pools. Every Tx packet raises a confirmation, configured at queue setup, and the callback frees the packet.
3) Dynamic confirmation. Confirmation is raised only for packets from non platform pools; the driver marks each packet accordingly at runtime. This suits a roughly even mix of platform and non platform buffers.

---
 drivers/bus/fslmc/portal/dpaa2_hw_pvt.h      |    1 +
 drivers/net/dpaa2/base/dpaa2_hw_dpni.c       |    2 +-
 drivers/net/dpaa2/base/dpaa2_hw_dpni_annot.h |    6 +-
 drivers/net/dpaa2/dpaa2_ethdev.c             |   63 +-
 drivers/net/dpaa2/dpaa2_ethdev.h             |   39 +-
 drivers/net/dpaa2/dpaa2_ptp.c                |    4 +-
 drivers/net/dpaa2/dpaa2_rxtx.c               | 1501 ++++++++----------
 7 files changed, 742 insertions(+), 874 deletions(-)
drivers/bus/fslmc/portal/dpaa2_hw_pvt.h +1 -0
index f87bf51d09..b3aad85d06 100644
@@ -198,6 +198,7 @@ struct __rte_cache_aligned dpaa2_queue {
 	uint16_t tm_sw_td;	/*!< TM software taildrop */
 	uint64_t offloads;
 	uint64_t lpbk_cntx;
+	int32_t ts_to_cnfd;
 	uint8_t data_stashing_off;
 	/* NAPI rx-interrupt: per-queue DPCON bound to this FQ at dev_start
 	 * (DEST_DPCON, static); the polling worker points the channel's CDAN at
drivers/net/dpaa2/base/dpaa2_hw_dpni.c +1 -1
index 26ad105c73..fee96b3529 100644
@@ -484,7 +484,7 @@ dpaa2_attach_bp_list(struct dpaa2_dev_priv *priv,
 	 */
 
 	/* ... rx buffer layout ... */
-	if (priv->flags & DPAA2_TX_DYNAMIC_CONF_ENABLE) {
+	if (priv->flags & DPAA2_TX_PREFETCH_DYNAMIC_CONF) {
 		int out_min_hdr_room, in_min_hdr_room;
 		/** Additional headroom layout for IPSec with TX configure
 		 * dynamic enabled.
drivers/net/dpaa2/base/dpaa2_hw_dpni_annot.h +5 -1
index a670098958..b06fa3f644 100644
@@ -1,7 +1,7 @@
 /* SPDX-License-Identifier: BSD-3-Clause
  *
  *   Copyright (c) 2016 Freescale Semiconductor, Inc. All rights reserved.
- *   Copyright 2016,2019,2022,2024 NXP
+ *   Copyright 2016,2019,2022,2024-2026 NXP
  *
  */
 
@@ -281,6 +281,10 @@ struct dpaa2_faead {
 /*UPD (Update prepended data)*/
 #define DPAA2_ANNOT_FAEAD_UPD		0x00000010
 
+#define DPAA2_TX_CONFIRM_ENABLE \
+	(DPAA2_ANNOT_FAEAD_A4V | DPAA2_ANNOT_FAEAD_EBDD | \
+	DPAA2_ANNOT_FAEAD_EBDDV)
+
 /* Debug frame, otherwise supposed to be discarded */
 #define DPAA2_ETH_FAS_DISC	      0x80000000
 /* MACSEC frame */
drivers/net/dpaa2/dpaa2_ethdev.c +37 -26

141 lines not on this page · raw message

drivers/net/dpaa2/dpaa2_ethdev.h +25 -14
index bdd8855023..c9b7a8ae17 100644
@@ -91,18 +91,14 @@
 
 #define DPAA2_TX_DPNI_LOOPBACK_MODE	RTE_BIT32(7)
 
-/* Tx confirmation enabled */
-#define DPAA2_TX_CONF_ENABLE	RTE_BIT32(8)
+#define DPAA2_TX_PREFETCH_DYNAMIC_CONF	RTE_BIT32(8)
 
-/* Tx dynamic confirmation enabled,
- * only valid with Tx confirmation enabled.
- */
-#define DPAA2_TX_DYNAMIC_CONF_ENABLE	RTE_BIT32(9)
+#define DPAA2_RX_ERROR_QUEUE_FLAG	RTE_BIT32(9)
+
+#define DPAA2_RX_DATA_STASHING_OFF_FLAG	RTE_BIT32(10)
 
-/* Disable data stashing (prefetch of packet data into CPU cache) */
-#define DPAA2_RX_DATA_STASHING_OFF_FLAG		RTE_BIT32(10)
+#define DPAA2_RX_SCHED_STRICT_ORDER_FLAG RTE_BIT32(11)
 
-#define DPAA2_RX_ERROR_QUEUE_FLAG	RTE_BIT32(11)
 #define DPAA2_RX_PRINT_PSR_RESULT_FLAG RTE_BIT32(12)
 
 /* DPDMUX index for DPMAC */
@@ -451,6 +447,12 @@ struct dpaa2_dev_meter {
 	uint32_t policy_id;
 };
 
+enum dpaa2_tx_conf_type {
+	DPAA2_TX_NO_CONF,
+	DPAA2_TX_ABSOLUTE_CONF,
+	DPAA2_TX_DYNAMIC_CONF
+};
+
 struct dpaa2_dev_priv {
 	void *hw;
 	int32_t hw_id;
@@ -466,6 +468,7 @@ struct dpaa2_dev_priv {
 	void *tx_conf_vq[MAX_TX_QUEUES];
 	void *rx_err_vq;
 	uint32_t flags; /*dpaa2 config flags */
+	enum dpaa2_tx_conf_type tx_conf_type;
 	int psr_dynfield_offset;
 	uint8_t max_mac_filters;
 	uint8_t max_vlan_filters;
@@ -504,16 +507,16 @@ struct dpaa2_dev_priv {
 	uint64_t ss_iova;
 	uint64_t ss_param_iova;
 	/*stores timestamp of last received packet on dev*/
-	uint64_t rx_timestamp;
+	RTE_ATOMIC(uint64_t) rx_timestamp;
 	/*stores timestamp of last received tx confirmation packet on dev*/
-	uint64_t tx_timestamp;
+	RTE_ATOMIC(uint64_t) tx_timestamp;
 
 	int rx_ts_offset;
 	uint64_t rx_ts_flag;
-	/* stores pointer to next tx_conf queue that should be processed,
+	/* stores next tx queue to be confirmed that should be processed,
 	 * it corresponds to last packet transmitted
 	 */
-	struct dpaa2_queue *next_tx_conf_queue;
+	struct dpaa2_queue * RTE_ATOMIC(next_txq_to_cnf);
 
 	struct rte_eth_dev *eth_dev; /**< Pointer back to holding ethdev */
 	rte_spinlock_t lpbk_qp_lock;
@@ -646,7 +649,7 @@ uint16_t dpaa2_dev_tx_multi_txq_ordered(void **queue,
 
 void dpaa2_dev_free_eqresp_buf(uint16_t eqresp_ci, struct dpaa2_queue *dpaa2_q);
 void dpaa2_flow_clean(struct rte_eth_dev *dev);
-uint16_t dpaa2_dev_tx_conf(void *queue)  __rte_unused;
+uint16_t dpaa2_dev_tx_conf(void *txq, int drain);
 
 int dpaa2_timesync_enable(struct rte_eth_dev *dev);
 int dpaa2_timesync_disable(struct rte_eth_dev *dev);
@@ -663,6 +666,14 @@ int dpaa2_timesync_read_tx_timestamp(struct rte_eth_dev *dev,
 
 int dpaa2_dev_recycle_config(struct rte_eth_dev *eth_dev);
 int dpaa2_dev_recycle_deconfig(struct rte_eth_dev *eth_dev);
+
+__rte_internal
+struct rte_mbuf *__rte_hot
+dpaa2_eth_fd_to_mbuf(struct dpaa2_dev_priv *priv, const struct qbman_fd *fd);
+__rte_internal
+struct rte_mbuf *__rte_hot
+dpaa2_eth_sg_fd_to_mbuf(struct dpaa2_dev_priv *priv, const struct qbman_fd *fd);
+
 int dpaa2_mtr_ops_get(struct rte_eth_dev *dev, void *ops);
 int dpaa2_soft_parser_loaded(void);
 
drivers/net/dpaa2/dpaa2_ptp.c +2 -2
index 751e558c73..c845291c68 100644
@@ -111,9 +111,9 @@ int dpaa2_timesync_read_tx_timestamp(struct rte_eth_dev *dev,
 {
 	struct dpaa2_dev_priv *priv = dev->data->dev_private;
 
-	if (priv->next_tx_conf_queue) {
+	if (priv->next_txq_to_cnf) {
 		while (!priv->tx_timestamp)
-			dpaa2_dev_tx_conf(priv->next_tx_conf_queue);
+			dpaa2_dev_tx_conf(priv->next_txq_to_cnf, false);
 	} else {
 		return -1;
 	}
drivers/net/dpaa2/dpaa2_rxtx.c +671 -830

1,775 lines not on this page · raw message

Signature · 1 line
2.43.0
#86 lore raw

PATCH v2 32/47 net/dpaa2: ptp enhancements

In reply to Prashant Gupta

From: Jun Yang <[email protected]>

1) Correct TX timestamp only for PTP sync packets.
2) Runtime configure TX timestamp offset by parsing current TX PTP packet format.

---
 drivers/net/dpaa2/dpaa2_ethdev.c |  92 ++----------------
 drivers/net/dpaa2/dpaa2_ethdev.h |  26 +++++
 drivers/net/dpaa2/dpaa2_ptp.c    | 161 +++++++++++++++++++++++++------
 drivers/net/dpaa2/dpaa2_rxtx.c   |  78 ++++++++++++++-
 4 files changed, 239 insertions(+), 118 deletions(-)
drivers/net/dpaa2/dpaa2_ethdev.c +6 -86
index 61b7ae138c..58b4cedee3 100644
@@ -72,11 +72,6 @@ static uint64_t dev_tx_offloads_sup =
 static uint64_t dev_tx_offloads_nodis =
 		RTE_ETH_TX_OFFLOAD_MULTI_SEGS;
 
-/* enable timestamp in mbuf */
-bool dpaa2_enable_ts[RTE_MAX_ETHPORTS];
-uint64_t dpaa2_timestamp_rx_dynflag;
-int dpaa2_timestamp_dynfield_offset = -1;
-
 bool dpaa2_print_parser_result;
 
 /* Rx descriptor limit when DPNI loads PFDRs in PEB */
@@ -730,9 +725,6 @@ dpaa2_eth_dev_configure(struct rte_eth_dev *dev)
 	int tx_l4_csum_offload = false;
 	int ret, tc_index;
 	uint32_t max_rx_pktlen;
-#if defined(RTE_LIBRTE_IEEE1588)
-	uint16_t ptp_correction_offset;
-#endif
 
 	PMD_INIT_FUNC_TRACE();
 
@@ -814,25 +806,15 @@ dpaa2_eth_dev_configure(struct rte_eth_dev *dev)
 		return ret;
 	}
 
-#if !defined(RTE_LIBRTE_IEEE1588)
-	if (rx_offloads & RTE_ETH_RX_OFFLOAD_TIMESTAMP)
-#endif
-	{
-		ret = rte_mbuf_dyn_rx_timestamp_register(
-				&dpaa2_timestamp_dynfield_offset,
-				&dpaa2_timestamp_rx_dynflag);
-		if (ret != 0) {
+	if (rx_offloads & RTE_ETH_RX_OFFLOAD_TIMESTAMP) {
+		ret = rte_mbuf_dyn_rx_timestamp_register(&priv->rx_ts_offset,
+			&priv->rx_ts_flag);
+		if (ret) {
 			DPAA2_PMD_ERR("Error to register timestamp field/flag");
-			return -rte_errno;
+			return ret;
 		}
-		dpaa2_enable_ts[dev->data->port_id] = true;
 	}
 
-#if defined(RTE_LIBRTE_IEEE1588)
-	/* By default setting ptp correction offset for Ethernet SYNC packets */
-	ptp_correction_offset = RTE_ETHER_HDR_LEN + 8;
-	rte_pmd_dpaa2_set_one_step_ts(dev->data->port_id, ptp_correction_offset, 0);
-#endif
 	if (tx_offloads & RTE_ETH_TX_OFFLOAD_IPV4_CKSUM)
 		tx_l3_csum_offload = true;
 
@@ -3315,8 +3297,6 @@ static struct eth_dev_ops dpaa2_ethdev_ops = {
 	.rxq_info_get	      = dpaa2_rxq_info_get,
 	.txq_info_get	      = dpaa2_txq_info_get,
 	.tm_ops_get	      = dpaa2_tm_ops_get,
-	.mtr_ops_get	      = dpaa2_mtr_ops_get,
-#if defined(RTE_LIBRTE_IEEE1588)
 	.timesync_enable      = dpaa2_timesync_enable,
 	.timesync_disable     = dpaa2_timesync_disable,
 	.timesync_read_time   = dpaa2_timesync_read_time,
@@ -3324,7 +3304,7 @@ static struct eth_dev_ops dpaa2_ethdev_ops = {
 	.timesync_adjust_time = dpaa2_timesync_adjust_time,
 	.timesync_read_rx_timestamp = dpaa2_timesync_read_rx_timestamp,
 	.timesync_read_tx_timestamp = dpaa2_timesync_read_tx_timestamp,
-#endif
+	.mtr_ops_get	      = dpaa2_mtr_ops_get,
 };
 
 /* Populate the mac address from physically available (u-boot/firmware) and/or
@@ -3589,11 +3569,6 @@ dpaa2_dev_init(struct rte_eth_dev *eth_dev)
 	priv->options = attr.options;
 	priv->max_mac_filters = attr.mac_filter_entries;
 	priv->max_vlan_filters = attr.vlan_filter_entries;
-	priv->flags = 0;
-#if defined(RTE_LIBRTE_IEEE1588)
-	DPAA2_PMD_INFO("DPDK IEEE1588 is enabled");
-	priv->flags |= DPAA2_TX_CONF_ENABLE;
-#endif
 	priv->tx_conf_type = DPAA2_TX_NO_CONF;
 
 	/* Used with ``fslmc:dpni.1,drv_tx_conf=1`` */
@@ -3803,61 +3778,6 @@ rte_pmd_dpaa2_ep_name(uint32_t eth_id)
 	return priv->ep_name;
 }
 
-#if defined(RTE_LIBRTE_IEEE1588)
-RTE_EXPORT_EXPERIMENTAL_SYMBOL(rte_pmd_dpaa2_get_one_step_ts, 24.11)
-int
-rte_pmd_dpaa2_get_one_step_ts(uint16_t port_id, bool mc_query)
-{
-	struct rte_eth_dev *dev = &rte_eth_devices[port_id];
-	struct dpaa2_dev_priv *priv = dev->data->dev_private;
-	struct fsl_mc_io *dpni = priv->eth_dev->process_private;
-	struct dpni_single_step_cfg ptp_cfg;
-	int err;
-
-	if (!mc_query)
-		return priv->ptp_correction_offset;
-
-	err = dpni_get_single_step_cfg(dpni, CMD_PRI_LOW, priv->token, &ptp_cfg);
-	if (err) {
-		DPAA2_PMD_ERR("Failed to retrieve onestep configuration");
-		return err;
-	}
-
-	if (!ptp_cfg.ptp_onestep_reg_base) {
-		DPAA2_PMD_ERR("1588 onestep reg not available");
-		return -1;
-	}
-
-	priv->ptp_correction_offset = ptp_cfg.offset;
-
-	return priv->ptp_correction_offset;
-}
-
-RTE_EXPORT_EXPERIMENTAL_SYMBOL(rte_pmd_dpaa2_set_one_step_ts, 24.11)
-int
-rte_pmd_dpaa2_set_one_step_ts(uint16_t port_id, uint16_t offset, uint8_t ch_update)
-{
-	struct rte_eth_dev *dev = &rte_eth_devices[port_id];
-	struct dpaa2_dev_priv *priv = dev->data->dev_private;
-	struct fsl_mc_io *dpni = dev->process_private;
-	struct dpni_single_step_cfg cfg;
-	int err;
-
-	cfg.en = 1;
-	cfg.ch_update = ch_update;
-	cfg.offset = offset;
-	cfg.peer_delay = 0;
-
-	err = dpni_set_single_step_cfg(dpni, CMD_PRI_LOW, priv->token, &cfg);
-	if (err)
-		return err;
-
-	priv->ptp_correction_offset = offset;
-
-	return 0;
-}
-#endif
-
 static int dpaa2_tx_sg_pool_init(void)
 {
 	char name[RTE_MEMZONE_NAMESIZE];
drivers/net/dpaa2/dpaa2_ethdev.h +26 -0
index c9b7a8ae17..33195f0584 100644
@@ -8,6 +8,9 @@
 #ifndef _DPAA2_ETHDEV_H
 #define _DPAA2_ETHDEV_H
 
+#include <rte_time.h>
+#include <rte_log.h>
+#include <rte_string_fns.h>
 #include <rte_compat.h>
 #include <rte_event_eth_rx_adapter.h>
 #include <rte_pmd_dpaa2.h>
@@ -101,6 +104,11 @@
 
 #define DPAA2_RX_PRINT_PSR_RESULT_FLAG RTE_BIT32(12)
 
+#define DPAA2_IEEE1588_DEBUG_FLAG RTE_BIT32(13)
+
+#define DPAA2_IEEE1588_TX_TS_FLAG RTE_BIT32(14)
+#define DPAA2_IEEE1588_RX_TS_FLAG RTE_BIT32(15)
+
 /* DPDMUX index for DPMAC */
 #define DPAA2_DPDMUX_DPMAC_IDX 0
 
@@ -589,6 +597,21 @@ dpaa2_dev_rx_print_parser_result(struct dpaa2_dev_priv *priv,
 	}
 }
 
+static inline void
+dpaa2_timestamp_debug(struct dpaa2_dev_priv *priv,
+	const char *prefix, uint64_t timestamp)
+{
+	struct timespec ts;
+
+	if (likely(!(priv->flags & DPAA2_IEEE1588_DEBUG_FLAG)))
+		return;
+
+	ts = rte_ns_to_timespec(timestamp);
+	fprintf(rte_log_get_stream(),
+		"DPAA2 TS DBG: %s: ns(%" PRIu64 ")->%ld seconds/%ld nanoseconds\n",
+		prefix, timestamp, ts.tv_sec, ts.tv_nsec);
+}
+
 int dpaa2_distset_to_dpkg_profile_cfg(uint64_t req_dist_set,
 				      struct dpkg_profile_cfg *kg_cfg);
 
@@ -651,6 +674,9 @@ void dpaa2_dev_free_eqresp_buf(uint16_t eqresp_ci, struct dpaa2_queue *dpaa2_q);
 void dpaa2_flow_clean(struct rte_eth_dev *dev);
 uint16_t dpaa2_dev_tx_conf(void *txq, int drain);
 
+void
+dpaa2_dev_tx_ptp_one_step_runtime(struct rte_eth_dev *dev,
+	struct rte_mbuf *buf, int *tstamp, int *set);
 int dpaa2_timesync_enable(struct rte_eth_dev *dev);
 int dpaa2_timesync_disable(struct rte_eth_dev *dev);
 int dpaa2_timesync_read_time(struct rte_eth_dev *dev,
drivers/net/dpaa2/dpaa2_ptp.c +132 -29

281 lines not on this page · raw message

drivers/net/dpaa2/dpaa2_rxtx.c +75 -3

174 lines not on this page · raw message

Signature · 1 line
2.43.0
#87 lore raw

PATCH v2 33/47 net/dpaa2: remove unused soft parser Tx code

In reply to Prashant Gupta

From: Hemant Agrawal <[email protected]>

Remove the soft parser related code from the Tx path. The soft parser can only be loaded before Linux boots, so this code was never reachable at runtime.

---
 drivers/net/dpaa2/dpaa2_rxtx.c | 14 ++------------
 1 file changed, 2 insertions(+), 12 deletions(-)
drivers/net/dpaa2/dpaa2_rxtx.c +2 -12
index 5c46c0f6d2..6d17a4d160 100644
@@ -162,16 +162,6 @@ dpaa2_dev_rx_parse_new(struct dpaa2_dev_priv *priv,
 			ext_packet_type |= RTE_PTYPE_INNER_L3_IPV4;
 		}
 	}
-	if (priv->sp_protocol) {
-		if (frc_parse->fafe2) {
-			frc_parse->fafe2 = 0;
-			ext_packet_type |= RTE_PTYPE_TUNNEL_GENEVE;
-		}
-		if (frc_parse->sum_l.l4.fafe3) {
-			frc_parse->sum_l.l4.fafe3 = 0;
-			ext_packet_type |= RTE_PTYPE_INNER_L3_IPV4;
-		}
-	}
 	switch (frc) {
 	case DPAA2_PKT_TYPE_IPV4_UDP:
 		m->packet_type = RTE_PTYPE_L2_ETHER |
@@ -740,7 +730,7 @@ dpaa2_dev_tx_mbuf_to_sg_fd(struct rte_mempool *hw_mp,
 
 	if (mbuf->pool->ops_index == hw_mp->ops_index &&
 		RTE_MBUF_DIRECT(mbuf) &&
-		(mbuf->data_off > RTE_ALIGN(sg_size + offset, 8))) {
+		mbuf->data_off > RTE_ALIGN(sg_size + offset, 8)) {
 		sg_mbuf = mbuf;
 		mp = mbuf->pool;
 		if (need_conf) {
@@ -1563,7 +1553,7 @@ uint16_t dpaa2_dev_tx_conf(void *txq, int drain)
 			mp = mbufs[idx]->pool;
 		if (unlikely(rte_mbuf_refcnt_read(mbufs[idx]) > 1))
 			bulk_free = false;
-		if (bulk_free == true &&
+		if (bulk_free &&
 			!dpaa2_dev_is_mbuf_from_spec_pool(mp, mbufs[idx]))
 			bulk_free = false;
 		if (unlikely(mbufs[idx]->ol_flags & RTE_MBUF_F_TX_IEEE1588_TMST)) {
Signature · 1 line
2.43.0
#88 lore raw

PATCH v2 34/47 net/dpaa2: update MC dpni QoS and flow steering API

In reply to Prashant Gupta

From: Hemant Agrawal <[email protected]>

Update the MC firmware command interface for the QoS and flow steering (FS) tables ahead of the flow engine rework:

- Version the SET_QOS_TBL / ADD_FS_ENT commands and add dpni_set_qos_table_v2() and dpni_add_fs_entry_legacy() wrappers.
- Support a per-entry default flow id in the QoS table configuration.
- Replace the single redirect_obj_token in dpni_fs_action_cfg with a redir_tokens[] array plus num_tokens, and program it via the new ADD_FS_ENT command.
- Add the dpni dump-table structures.

The existing flow code is updated to populate the new redir_tokens[] field so behaviour is unchanged.

---
 drivers/net/dpaa2/dpaa2_flow.c      |   3 +-
 drivers/net/dpaa2/mc/dpni.c         | 127 ++++++++++++++++++++--------
 drivers/net/dpaa2/mc/fsl_dpni.h     | 100 ++++++++++++++++++++--
 drivers/net/dpaa2/mc/fsl_dpni_cmd.h |  30 ++++---
 4 files changed, 206 insertions(+), 54 deletions(-)
drivers/net/dpaa2/dpaa2_flow.c +2 -1
index 06ec1a2660..88a639ba89 100644
@@ -4445,7 +4445,8 @@ dpaa2_configure_flow_fs_action(struct dpaa2_dev_priv *priv,
 		dest_q = dest_priv->tx_vq[0];
 		flow->fs_action_cfg.options =
 			DPNI_FS_OPT_REDIRECT_TO_DPNI_TX;
-		flow->fs_action_cfg.redirect_obj_token =
+		flow->fs_action_cfg.num_tokens = 1;
+		flow->fs_action_cfg.redir_tokens[0] =
 			dest_priv->token;
 		flow->fs_action_cfg.flow_id = dest_q->flow_id;
 	} else if (flow->action_type == RTE_FLOW_ACTION_TYPE_DROP) {
drivers/net/dpaa2/mc/dpni.c +91 -36

179 lines not on this page · raw message

drivers/net/dpaa2/mc/fsl_dpni.h +94 -6

171 lines not on this page · raw message

drivers/net/dpaa2/mc/fsl_dpni_cmd.h +19 -11
index 6b396ca7cc..36e4aacc3a 100644
@@ -1,7 +1,7 @@
 /* SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0
  *
  * Copyright 2013-2016 Freescale Semiconductor Inc.
- * Copyright 2016-2025 NXP
+ * Copyright 2016-2026 NXP
  *
  */
 #ifndef _FSL_DPNI_CMD_H
@@ -20,6 +20,7 @@
 #define DPNI_CMD_VERSION_7			7
 #define DPNI_CMD_ID_OFFSET			4
 
+#define DPNI_CMD_VER(cmd_id) ((cmd_id) & ((1 << DPNI_CMD_ID_OFFSET) - 1))
 #define DPNI_CMD(id)	(((id) << DPNI_CMD_ID_OFFSET) | DPNI_CMD_BASE_VERSION)
 #define DPNI_CMD_V2(id)	(((id) << DPNI_CMD_ID_OFFSET) | DPNI_CMD_VERSION_2)
 #define DPNI_CMD_V3(id)	(((id) << DPNI_CMD_ID_OFFSET) | DPNI_CMD_VERSION_3)
@@ -77,13 +78,16 @@
 
 #define DPNI_CMDID_SET_RX_TC_DIST		DPNI_CMD_V4(0x235)
 
-#define DPNI_CMDID_SET_RX_TC_POLICING		DPNI_CMD(0x23E)
+#define DPNI_CMDID_SET_RX_TC_POLICING_V1	DPNI_CMD(0x23E)
+#define DPNI_CMDID_SET_RX_TC_POLICING		DPNI_CMD_V2(0x23E)
 
-#define DPNI_CMDID_SET_QOS_TBL			DPNI_CMD_V2(0x240)
+#define DPNI_CMDID_SET_QOS_TBL			DPNI_CMD_V3(0x240)
+#define DPNI_CMDID_SET_QOS_TBL_V2		DPNI_CMD_V2(0x240)
 #define DPNI_CMDID_ADD_QOS_ENT			DPNI_CMD_V2(0x241)
 #define DPNI_CMDID_REMOVE_QOS_ENT		DPNI_CMD(0x242)
 #define DPNI_CMDID_CLR_QOS_TBL			DPNI_CMD(0x243)
-#define DPNI_CMDID_ADD_FS_ENT			DPNI_CMD_V2(0x244)
+#define DPNI_CMDID_ADD_FS_ENT_LEGACY	DPNI_CMD_V2(0x244)
+#define DPNI_CMDID_ADD_FS_ENT			DPNI_CMD_V3(0x244)
 #define DPNI_CMDID_REMOVE_FS_ENT		DPNI_CMD(0x245)
 #define DPNI_CMDID_CLR_FS_ENT			DPNI_CMD(0x246)
 
@@ -584,19 +588,18 @@ struct dpni_cmd_set_queue {
 #define DPNI_DISCARD_ON_MISS_SIZE	1
 #define DPNI_KEEP_QOS_ENTRIES_SHIFT		1
 #define DPNI_KEEP_QOS_ENTRIES_SIZE		1
+#define DPNI_SET_DEFAULT_FLOW_ID_SHIFT  2
+#define DPNI_SET_DEFAULT_FLOW_ID_SIZE   1
 
 struct dpni_cmd_set_qos_table {
-	uint32_t pad;
+	uint16_t pad;
+	uint16_t default_flow_id;
 	uint8_t default_tc;
-	/* only the LSB */
-	uint8_t discard_on_miss;
+	uint8_t flags;
 	uint16_t pad1[21];
 	uint64_t key_cfg_iova;
 };
 
-#define DPNI_QOS_OPT_SET_TC_ONLY 0x0
-#define DPNI_QOS_OPT_SET_FLOW_ID 0x1
-
 struct dpni_cmd_add_qos_entry {
 	uint8_t flags;
 	uint8_t flow_id;
@@ -616,6 +619,10 @@ struct dpni_cmd_remove_qos_entry {
 	uint64_t mask_iova;
 };
 
+#ifndef DPNI_FS_REDIR_MAX_NUM
+#define DPNI_FS_REDIR_MAX_NUM 8
+#endif
+
 struct dpni_cmd_add_fs_entry {
 	uint16_t options;
 	uint8_t tc_id;
@@ -625,7 +632,8 @@ struct dpni_cmd_add_fs_entry {
 	uint64_t key_iova;
 	uint64_t mask_iova;
 	uint64_t flc;
-	uint16_t redir_token;
+	uint16_t redir_tokens[DPNI_FS_REDIR_MAX_NUM];
+	uint8_t token_num;
 };
 
 struct dpni_cmd_remove_fs_entry {
Signature · 1 line
2.43.0
#89 lore raw

PATCH v2 35/47 net/dpaa2: enhance xstat implementation

In reply to Prashant Gupta

From: Gagandeep Singh <[email protected]>

1) Adapt RTE xstat API to return proper length.
2) Alloc DMA buffer of mac xstat only once.
3) Get MAC counter via dpni only when this dpni is connected to DPMAC.
4) Get TC policer counter only when meter flow of TC is there.

---
 drivers/net/dpaa2/dpaa2_ethdev.c | 913 +++++++++++++++++--------------
 drivers/net/dpaa2/dpaa2_ethdev.h |  12 +-
 drivers/net/dpaa2/mc/fsl_dpni.h  | 259 +++++++--
 3 files changed, 738 insertions(+), 446 deletions(-)
drivers/net/dpaa2/dpaa2_ethdev.c +516 -397
index 58b4cedee3..5e2011b911 100644
@@ -26,6 +26,7 @@
 #include <dpaa2_hw_pvt.h>
 #include <dpaa2_hw_mempool.h>
 #include <dpaa2_hw_dpio.h>
+#include <fsl_dprc.h>
 #include <mc/fsl_dpmng.h>
 #include <mc/fsl_dpcon.h>
 #include "dpaa2_ethdev.h"
@@ -108,116 +109,268 @@ dpaa2_dist_size_is_supported(uint16_t n)
 int dpaa2_valid_dev;
 struct rte_mempool *dpaa2_tx_sg_pool;
 
-struct rte_dpaa2_xstats_name_off {
-	char name[RTE_ETH_XSTATS_NAME_SIZE];
-	uint8_t page_id; /* dpni statistics page id */
-	uint8_t stats_id; /* stats id in the given page */
+struct dpaa2_xstats_seq {
+	struct dpni_statistics_page_0 pg0;
+	struct dpni_statistics_page_1 pg1;
+	struct dpni_statistics_page_2 pg2;
+	struct dpni_statistics_page_3 pg3;
+	struct dpni_statistics_page_4 pg4;
+	struct dpni_statistics_page_5 pg5[MAX_TCS];
+	struct dpni_statistics_page_6 pg6;
+	struct dpni_dpmac_counters mac_cnt;
 };
 
-static const struct rte_dpaa2_xstats_name_off dpaa2_xstats_strings[] = {
-	{"ingress_multicast_frames", 0, 2},
-	{"ingress_multicast_bytes", 0, 3},
-	{"ingress_broadcast_frames", 0, 4},
-	{"ingress_broadcast_bytes", 0, 5},
-	{"egress_multicast_frames", 1, 2},
-	{"egress_multicast_bytes", 1, 3},
-	{"egress_broadcast_frames", 1, 4},
-	{"egress_broadcast_bytes", 1, 5},
-	{"ingress_filtered_frames", 2, 0},
-	{"ingress_discarded_frames", 2, 1},
-	{"ingress_nobuffer_discards", 2, 2},
-	{"egress_discarded_frames", 2, 3},
-	{"egress_confirmed_frames", 2, 4},
-	{"cgr_reject_frames", 4, 0},
-	{"cgr_reject_bytes", 4, 1},
-	{"TC_0_policer_cnt_red", 5, 0},
-	{"TC_0_policer_cnt_yellow", 5, 1},
-	{"TC_0_policer_cnt_green", 5, 2},
-	{"TC_0_policer_cnt_re_red", 5, 3},
-	{"TC_0_policer_cnt_re_yellow", 5, 4},
-	{"TC_1_policer_cnt_red", 6, 0},
-	{"TC_1_policer_cnt_yellow", 6, 1},
-	{"TC_1_policer_cnt_green", 6, 2},
-	{"TC_1_policer_cnt_re_red", 6, 3},
-	{"TC_1_policer_cnt_re_yellow", 6, 4},
-	{"TC_2_policer_cnt_red", 7, 0},
-	{"TC_2_policer_cnt_yellow", 7, 1},
-	{"TC_2_policer_cnt_green", 7, 2},
-	{"TC_2_policer_cnt_re_red", 7, 3},
-	{"TC_2_policer_cnt_re_yellow", 7, 4},
-	{"TC_3_policer_cnt_red", 8, 0},
-	{"TC_3_policer_cnt_yellow", 8, 1},
-	{"TC_3_policer_cnt_green", 8, 2},
-	{"TC_3_policer_cnt_re_red", 8, 3},
-	{"TC_3_policer_cnt_re_yellow", 8, 4},
-	{"TC_4_policer_cnt_red", 9, 0},
-	{"TC_4_policer_cnt_yellow", 9, 1},
-	{"TC_4_policer_cnt_green", 9, 2},
-	{"TC_4_policer_cnt_re_red", 9, 3},
-	{"TC_4_policer_cnt_re_yellow", 9, 4},
-	{"TC_5_policer_cnt_red", 10, 0},
-	{"TC_5_policer_cnt_yellow", 10, 1},
-	{"TC_5_policer_cnt_green", 10, 2},
-	{"TC_5_policer_cnt_re_red", 10, 3},
-	{"TC_5_policer_cnt_re_yellow", 10, 4},
-	{"TC_6_policer_cnt_red", 11, 0},
-	{"TC_6_policer_cnt_yellow", 11, 1},
-	{"TC_6_policer_cnt_green", 11, 2},
-	{"TC_6_policer_cnt_re_red", 11, 3},
-	{"TC_6_policer_cnt_re_yellow", 11, 4},
-	{"TC_7_policer_cnt_red", 12, 0},
-	{"TC_7_policer_cnt_yellow", 12, 1},
-	{"TC_7_policer_cnt_green", 12, 2},
-	{"TC_7_policer_cnt_re_red", 12, 3},
-	{"TC_7_policer_cnt_re_yellow", 12, 4},
-	{"mac_rx_64 bytes", 0, 0},
-	{"mac_rx_65-127 bytes", 0, 0},
-	{"mac_rx_128-255 bytes", 0, 0},
-	{"mac_rx_256-511 bytes", 0, 0},
-	{"mac_rx_512-1023 bytes", 0, 0},
-	{"mac_rx_1024-1518 bytes", 0, 0},
-	{"mac_rx_1519-max bytes", 0, 0},
-	{"mac_rx_frags", 0, 0},
-	{"mac_rx_jabber", 0, 0},
-	{"mac_rx_frame discards", 0, 0},
-	{"mac_rx_align errors", 0, 0},
-	{"mac_tx_undersized", 0, 0},
-	{"mac_rx_oversized", 0, 0},
-	{"mac_rx_pause", 0, 0},
-	{"mac_tx_b-pause", 0, 0},
-	{"mac_rx_bytes", 0, 0},
-	{"mac_rx_m-cast", 0, 0},
-	{"mac_rx_b-cast", 0, 0},
-	{"mac_rx_all frames", 0, 0},
-	{"mac_rx_u-cast", 0, 0},
-	{"mac_rx_frame errors", 0, 0},
-	{"mac_tx_bytes", 0, 0},
-	{"mac_tx_m-cast", 0, 0},
-	{"mac_tx_b-cast", 0, 0},
-	{"mac_tx_u-cast", 0, 0},
-	{"mac_tx_frame errors", 0, 0},
-	{"mac_rx_frames ok", 0, 0},
-	{"mac_tx_frames ok", 0, 0},
-	{"mac_tx_64 bytes", 0, 0},
-	{"mac_tx_65-127 bytes", 0, 0},
-	{"mac_tx_128-255 bytes", 0, 0},
-	{"mac_tx_256-511 bytes", 0, 0},
-	{"mac_tx_512-1023 bytes", 0, 0},
-	{"mac_tx_1024-1518 bytes", 0, 0},
-	{"mac_tx_1519-max bytes", 0, 0},
-	{"mac_rx_all_bytes", 0, 0},
-	{"mac_rx_fcs_err", 0, 0},
-	{"mac_rx_vlan_frame", 0, 0},
-	{"mac_rx_undersized", 0, 0},
-	{"mac_rx_control_frame", 0, 0},
-	{"mac_rx_frame_discard_not_trunc", 0, 0},
-	{"mac_tx_all_bytes", 0, 0},
-	{"mac_tx_fcs_err", 0, 0},
-	{"mac_tx_vlan_frame", 0, 0},
-	{"mac_tx_all_frame", 0, 0},
-	{"mac_tx_control_frame", 0, 0},
+#define DPAA2_XSTAT_MAX_NUM \
+	(sizeof(struct dpaa2_xstats_seq) / sizeof(uint64_t))
+
+#define DPAA2_DPNI_XSTAT_MAX_NUM \
+	(offsetof(struct dpaa2_xstats_seq, mac_cnt) / sizeof(uint64_t))
+
+#define DPAA2_MAC_XSTAT_MAX_NUM DPAA2_MAC_NUM_STATS
+
+static_assert((DPAA2_DPNI_XSTAT_MAX_NUM + DPAA2_MAC_XSTAT_MAX_NUM) ==
+	DPAA2_XSTAT_MAX_NUM, "DPNI and MAC xstats do not sum to total");
+
+#define DPAA2_DPNI_STAT_SET_PAGE_PARAM(param) \
+({ \
+	int ret = false; \
+	\
+	if ((id) >= this_offset && (id) < (this_offset + pg_size)) { \
+		_stat_id = (id) - this_offset; \
+		_param = param; \
+		_size = pg_size; \
+		ret = true; \
+	} \
+	ret; \
+})
+
+#define DPAA2_DPNI_STAT_PAGE_PARAM(pid) \
+({ \
+	uint64_t this_offset = offsetof(struct dpaa2_xstats_seq, pg##pid) / sizeof(uint64_t); \
+	uint64_t pg_size = sizeof(struct dpni_statistics_page_##pid) / sizeof(uint64_t); \
+	int ret; \
+	\
+	ret = DPAA2_DPNI_STAT_SET_PAGE_PARAM(0); \
+	if (!ret) \
+		_page++; \
+	ret; \
+})
+
+#define DPAA2_DPNI_STAT_POLICER_PAGE_PARAM() \
+({ \
+	int ret = false; \
+	uint8_t tc_id; \
+	uint64_t this_offset; \
+	uint64_t pg_size = sizeof(struct dpni_statistics_page_5) / sizeof(uint64_t); \
+	\
+	for (tc_id = 0; tc_id < MAX_TCS; tc_id++) { \
+		this_offset = offsetof(struct dpaa2_xstats_seq, pg5[tc_id]) / sizeof(uint64_t); \
+		ret = DPAA2_DPNI_STAT_SET_PAGE_PARAM(tc_id); \
+		if (ret) \
+			break; \
+	} \
+	if (!ret) \
+		_page++; \
+	ret; \
+})
+
+static inline int
+dpaa2_xstats_id_parse(uint32_t id, uint8_t *page,
+	uint8_t *stat_id, uint16_t *param, uint16_t *size)
+{
+	uint8_t _page = DPNI_INGRESS_STATISTICS_PAGE_ID, _stat_id = 0;
+	uint16_t _param = 0, _size = 0;
+
+	if (DPAA2_DPNI_STAT_PAGE_PARAM(0))
+		goto found_id;
+	if (DPAA2_DPNI_STAT_PAGE_PARAM(1))
+		goto found_id;
+	if (DPAA2_DPNI_STAT_PAGE_PARAM(2))
+		goto found_id;
+	if (DPAA2_DPNI_STAT_PAGE_PARAM(3))
+		goto found_id;
+	if (DPAA2_DPNI_STAT_PAGE_PARAM(4))
+		goto found_id;
+	if (DPAA2_DPNI_STAT_POLICER_PAGE_PARAM())
+		goto found_id;
+	if (DPAA2_DPNI_STAT_PAGE_PARAM(6))
+		goto found_id;
+
+	DPAA2_PMD_ERR("ID(%d) was not found in DPNI page statistics", id);
+	return -EINVAL;
+
+found_id:
+	if (page)
+		*page = _page;
+	if (stat_id)
+		*stat_id = _stat_id;
+	if (param)
+		*param = _param;
+	if (size)
+		*size = _size;
+
+	return 0;
+}
+
+#define DPAA2_XSTAT_ID(field) \
+	(offsetof(struct dpaa2_xstats_seq, field) / sizeof(uint64_t))
+
+#define DPAA2_XSTAT_STR_SET(pg, field) \
+	[DPAA2_XSTAT_ID(pg.field)] = RTE_STR(field)
+
+#define DPAA2_XSTAT_TC_STR_SET(pg, tc, field) \
+	[DPAA2_XSTAT_ID(pg[tc].field)] = "TC" RTE_STR(tc)"_" RTE_STR(field)
+
+#define DPAA2_XSTAT_TC_COLOR_STR_SET(pg, tc) \
+	DPAA2_XSTAT_TC_STR_SET(pg, tc, policer_cnt_red), \
+	DPAA2_XSTAT_TC_STR_SET(pg, tc, policer_cnt_yellow), \
+	DPAA2_XSTAT_TC_STR_SET(pg, tc, policer_cnt_green), \
+	DPAA2_XSTAT_TC_STR_SET(pg, tc, policer_cnt_re_red), \
+	DPAA2_XSTAT_TC_STR_SET(pg, tc, policer_cnt_re_yellow)
+
+#define DPAA2_MAC_XSTAT_STR_SET(name) \
+	[DPAA2_XSTAT_ID(mac_cnt.name)] = "mac_" RTE_STR(name)
+
+#define DPAA2_MAC_XSTAT_PFC_STR_SET(dir, tc) \
+	[DPAA2_XSTAT_ID(mac_cnt.dir##_pfc_class[tc])] = \
+		"mac_" RTE_STR(dir) "_pfc_class_" RTE_STR(tc)
+
+static const char * const
+dpaa2_xstats_strings[DPAA2_XSTAT_MAX_NUM] = {
+	DPAA2_XSTAT_STR_SET(pg0, ingress_all_frames),
+	DPAA2_XSTAT_STR_SET(pg0, ingress_all_bytes),
+	DPAA2_XSTAT_STR_SET(pg0, ingress_multicast_frames),
+	DPAA2_XSTAT_STR_SET(pg0, ingress_multicast_bytes),
+	DPAA2_XSTAT_STR_SET(pg0, ingress_broadcast_frames),
+	DPAA2_XSTAT_STR_SET(pg0, ingress_broadcast_bytes),
+
+	DPAA2_XSTAT_STR_SET(pg1, egress_all_frames),
+	DPAA2_XSTAT_STR_SET(pg1, egress_all_bytes),
+	DPAA2_XSTAT_STR_SET(pg1, egress_multicast_frames),
+	DPAA2_XSTAT_STR_SET(pg1, egress_multicast_bytes),
+	DPAA2_XSTAT_STR_SET(pg1, egress_broadcast_frames),
+	DPAA2_XSTAT_STR_SET(pg1, egress_broadcast_bytes),
+
+	DPAA2_XSTAT_STR_SET(pg2, ingress_filtered_frames),
+	DPAA2_XSTAT_STR_SET(pg2, ingress_discarded_frames),
+	DPAA2_XSTAT_STR_SET(pg2, ingress_nobuffer_discards),
+	DPAA2_XSTAT_STR_SET(pg2, egress_discarded_frames),
+	DPAA2_XSTAT_STR_SET(pg2, egress_confirmed_frames),
+
+	DPAA2_XSTAT_STR_SET(pg3, ceetm_dequeue_bytes),
+	DPAA2_XSTAT_STR_SET(pg3, ceetm_dequeue_frames),
+	DPAA2_XSTAT_STR_SET(pg3, ceetm_reject_bytes),
+	DPAA2_XSTAT_STR_SET(pg3, ceetm_reject_frames),
+
+	DPAA2_XSTAT_STR_SET(pg4, cgr_reject_frames),
+	DPAA2_XSTAT_STR_SET(pg4, cgr_reject_bytes),
+
+	DPAA2_XSTAT_TC_COLOR_STR_SET(pg5, 0),
+	DPAA2_XSTAT_TC_COLOR_STR_SET(pg5, 1),
+	DPAA2_XSTAT_TC_COLOR_STR_SET(pg5, 2),
+	DPAA2_XSTAT_TC_COLOR_STR_SET(pg5, 3),
+	DPAA2_XSTAT_TC_COLOR_STR_SET(pg5, 4),
+	DPAA2_XSTAT_TC_COLOR_STR_SET(pg5, 5),
+	DPAA2_XSTAT_TC_COLOR_STR_SET(pg5, 6),
+	DPAA2_XSTAT_TC_COLOR_STR_SET(pg5, 7),
+
+	DPAA2_XSTAT_STR_SET(pg6, tx_pending_frames_cnt),
+
+	DPAA2_MAC_XSTAT_STR_SET(rx_64_bytes),
+	DPAA2_MAC_XSTAT_STR_SET(rx_65_127_bytes),
+	DPAA2_MAC_XSTAT_STR_SET(rx_128_255_bytes),
+	DPAA2_MAC_XSTAT_STR_SET(rx_256_511_bytes),
+	DPAA2_MAC_XSTAT_STR_SET(rx_512_1023_bytes),
+	DPAA2_MAC_XSTAT_STR_SET(rx_1024_1518_bytes),
+	DPAA2_MAC_XSTAT_STR_SET(rx_1519_max_bytes),
+
+	DPAA2_MAC_XSTAT_STR_SET(rx_fragments),
+	DPAA2_MAC_XSTAT_STR_SET(rx_jabber),
+	DPAA2_MAC_XSTAT_STR_SET(rx_drop_fifo),
+	DPAA2_MAC_XSTAT_STR_SET(rx_alignment_error),
+
+	DPAA2_MAC_XSTAT_STR_SET(tx_undersize_good),
+	DPAA2_MAC_XSTAT_STR_SET(rx_oversize_good),
+
+	DPAA2_MAC_XSTAT_STR_SET(rx_pause),
+	DPAA2_MAC_XSTAT_STR_SET(tx_pause),
+
+	DPAA2_MAC_XSTAT_STR_SET(rx_good_bytes),
+	DPAA2_MAC_XSTAT_STR_SET(rx_multicast),
+	DPAA2_MAC_XSTAT_STR_SET(rx_broadcast),
+	DPAA2_MAC_XSTAT_STR_SET(rx_all_frames),
+	DPAA2_MAC_XSTAT_STR_SET(rx_unicast),
+	DPAA2_MAC_XSTAT_STR_SET(rx_error),
+
+	DPAA2_MAC_XSTAT_STR_SET(tx_good_bytes),
+	DPAA2_MAC_XSTAT_STR_SET(tx_multicast),
+	DPAA2_MAC_XSTAT_STR_SET(tx_broadcast),
+	DPAA2_MAC_XSTAT_STR_SET(tx_unicast),
+	DPAA2_MAC_XSTAT_STR_SET(tx_error),
+
+	DPAA2_MAC_XSTAT_STR_SET(rx_valid_frames),
+	DPAA2_MAC_XSTAT_STR_SET(tx_valid_frames),
+
+	DPAA2_MAC_XSTAT_STR_SET(tx_64_bytes),
+	DPAA2_MAC_XSTAT_STR_SET(tx_65_127_bytes),
+	DPAA2_MAC_XSTAT_STR_SET(tx_128_255_bytes),
+	DPAA2_MAC_XSTAT_STR_SET(tx_256_511_bytes),
+	DPAA2_MAC_XSTAT_STR_SET(tx_512_1023_bytes),
+	DPAA2_MAC_XSTAT_STR_SET(tx_1024_1518_bytes),
+	DPAA2_MAC_XSTAT_STR_SET(tx_1519_max_bytes),
+
+	DPAA2_MAC_XSTAT_STR_SET(rx_bytes_all),
+	DPAA2_MAC_XSTAT_STR_SET(rx_crc_error),
+	DPAA2_MAC_XSTAT_STR_SET(rx_vlan),
+	DPAA2_MAC_XSTAT_STR_SET(rx_undersize_good),
+	DPAA2_MAC_XSTAT_STR_SET(rx_ctrl_non_pause),
+	DPAA2_MAC_XSTAT_STR_SET(rx_drop_full),
+
+	DPAA2_MAC_XSTAT_STR_SET(tx_bytes_all),
+	DPAA2_MAC_XSTAT_STR_SET(tx_crc_error),
+	DPAA2_MAC_XSTAT_STR_SET(tx_vlan),
+	DPAA2_MAC_XSTAT_STR_SET(tx_all_frames),
+	DPAA2_MAC_XSTAT_STR_SET(tx_ctrl_non_pause),
+
+	DPAA2_MAC_XSTAT_PFC_STR_SET(rx, 0),
+	DPAA2_MAC_XSTAT_PFC_STR_SET(rx, 1),
+	DPAA2_MAC_XSTAT_PFC_STR_SET(rx, 2),
+	DPAA2_MAC_XSTAT_PFC_STR_SET(rx, 3),
+	DPAA2_MAC_XSTAT_PFC_STR_SET(rx, 4),
+	DPAA2_MAC_XSTAT_PFC_STR_SET(rx, 5),
+	DPAA2_MAC_XSTAT_PFC_STR_SET(rx, 6),
+	DPAA2_MAC_XSTAT_PFC_STR_SET(rx, 7),
+
+	DPAA2_MAC_XSTAT_PFC_STR_SET(tx, 0),
+	DPAA2_MAC_XSTAT_PFC_STR_SET(tx, 1),
+	DPAA2_MAC_XSTAT_PFC_STR_SET(tx, 2),
+	DPAA2_MAC_XSTAT_PFC_STR_SET(tx, 3),
+	DPAA2_MAC_XSTAT_PFC_STR_SET(tx, 4),
+	DPAA2_MAC_XSTAT_PFC_STR_SET(tx, 5),
+	DPAA2_MAC_XSTAT_PFC_STR_SET(tx, 6),
+	DPAA2_MAC_XSTAT_PFC_STR_SET(tx, 7)
 };
 
+#define DPAA2_DPNI_XSTAT_FIELD_ID(field) \
+	(offsetof(struct dpaa2_xstats_seq, field) / sizeof(uint64_t))
+
+static const struct rte_eth_stats dpaa2_stats_xstat_ids = {
+	.ipackets = DPAA2_DPNI_XSTAT_FIELD_ID(pg0.ingress_all_frames),
+	.opackets = DPAA2_DPNI_XSTAT_FIELD_ID(pg1.egress_all_frames),
+	.ibytes = DPAA2_DPNI_XSTAT_FIELD_ID(pg0.ingress_all_bytes),
+	.obytes = DPAA2_DPNI_XSTAT_FIELD_ID(pg1.egress_all_bytes),
+	.imissed = DPAA2_DPNI_XSTAT_FIELD_ID(pg2.ingress_filtered_frames),
+	.ierrors = DPAA2_DPNI_XSTAT_FIELD_ID(pg2.ingress_discarded_frames),
+	.oerrors = DPAA2_DPNI_XSTAT_FIELD_ID(pg2.egress_discarded_frames),
+	.rx_nombuf = DPAA2_DPNI_XSTAT_FIELD_ID(pg2.ingress_nobuffer_discards)
+};
+
+#define DPAA2_STATS_XSTATS_NUM \
+	(sizeof(dpaa2_stats_xstat_ids) / sizeof(uint64_t))
+
+#define DPAA2_MAC_XSTATS_START_ID DPAA2_DPNI_XSTAT_MAX_NUM
+
+
 static struct rte_dpaa2_driver rte_dpaa2_pmd;
 static int dpaa2_dev_link_update(struct rte_eth_dev *dev,
 				 int wait_to_complete);
@@ -1892,127 +2045,47 @@ dpaa2_dev_set_mac_addr(struct rte_eth_dev *dev,
 }
 
 static int
-dpaa2_dev_stats_get(struct rte_eth_dev *dev,
-	struct rte_eth_stats *stats, struct eth_queue_stats *qstats)
+dpaa2_dev_xstat_mac_setup_mem(struct rte_eth_dev *dev)
 {
 	struct dpaa2_dev_priv *priv = dev->data->dev_private;
-	struct fsl_mc_io *dpni = dev->process_private;
-	int32_t retcode;
-	uint8_t page0 = 0, page1 = 1, page2 = 2;
-	union dpni_statistics value;
-	int i;
-	struct dpaa2_queue *dpaa2_rxq, *dpaa2_txq;
-
-	memset(&value, 0, sizeof(union dpni_statistics));
-
-	PMD_INIT_FUNC_TRACE();
-
-	if (!dpni) {
-		DPAA2_PMD_ERR("dpni is NULL");
-		return -EINVAL;
-	}
-
-	if (!stats) {
-		DPAA2_PMD_ERR("stats is NULL");
-		return -EINVAL;
-	}
-
-	/*Get Counters from page_0*/
-	retcode = dpni_get_statistics(dpni, CMD_PRI_LOW, priv->token,
-				      page0, 0, &value);
-	if (retcode)
-		goto err;
-
-	stats->ipackets = value.page_0.ingress_all_frames;
-	stats->ibytes = value.page_0.ingress_all_bytes;
-
-	/*Get Counters from page_1*/
-	retcode = dpni_get_statistics(dpni, CMD_PRI_LOW, priv->token,
-				      page1, 0, &value);
-	if (retcode)
-		goto err;
-
-	stats->opackets = value.page_1.egress_all_frames;
-	stats->obytes = value.page_1.egress_all_bytes;
-
-	/*Get Counters from page_2*/
-	retcode = dpni_get_statistics(dpni, CMD_PRI_LOW, priv->token,
-				      page2, 0, &value);
-	if (retcode)
-		goto err;
-
-	/* Ingress drop frame count due to configured rules */
-	stats->ierrors = value.page_2.ingress_filtered_frames;
-	/* Ingress drop frame count due to error */
-	stats->ierrors += value.page_2.ingress_discarded_frames;
-
-	stats->oerrors = value.page_2.egress_discarded_frames;
-	stats->imissed = value.page_2.ingress_nobuffer_discards;
-
-	/* Fill in per queue stats */
-	if (qstats != NULL) {
-		for (i = 0; (i < RTE_ETHDEV_QUEUE_STAT_CNTRS) &&
-			(i < priv->nb_rx_queues || i < priv->nb_tx_queues); ++i) {
-			dpaa2_rxq = priv->rx_vq[i];
-			dpaa2_txq = priv->tx_vq[i];
-			if (dpaa2_rxq)
-				qstats->q_ipackets[i] = dpaa2_rxq->rx_pkts;
-			if (dpaa2_txq)
-				qstats->q_opackets[i] = dpaa2_txq->tx_pkts;
+	int ret = 0;
 
-			/* Byte counting is not implemented */
-			qstats->q_ibytes[i]   = 0;
-			qstats->q_obytes[i]   = 0;
+	if (!priv->cnt_idx_dma_mem) {
+		priv->cnt_idx_dma_mem = rte_zmalloc(NULL,
+			DPAA2_MAC_STATS_INDEX_DMA_SIZE, RTE_CACHE_LINE_SIZE);
+		if (!priv->cnt_idx_dma_mem) {
+			ret = -ENOMEM;
+			DPAA2_PMD_ERR("Failure to allocate memory for mac index");
+			goto out;
 		}
-	}
 
-	return 0;
-
-err:
-	DPAA2_PMD_ERR("Operation not completed:Error Code = %d", retcode);
-	return retcode;
-};
-
-void
-dpaa2_dev_mac_setup_stats(struct rte_eth_dev *dev)
-{
-	struct dpaa2_dev_priv *priv = dev->data->dev_private;
-	uint32_t *cnt_idx;
-	int i;
-
-	priv->cnt_idx_dma_mem = rte_malloc(NULL, DPAA2_MAC_STATS_INDEX_DMA_SIZE,
-					   RTE_CACHE_LINE_SIZE);
-	if (!priv->cnt_idx_dma_mem) {
-		DPAA2_PMD_ERR("Failure to allocate memory for mac index");
-		goto out;
+		priv->cnt_idx_iova = rte_mem_virt2iova(priv->cnt_idx_dma_mem);
+		if (priv->cnt_idx_iova == RTE_BAD_IOVA) {
+			ret = -ENOBUFS;
+			DPAA2_PMD_ERR("%s: No IOMMU map for count index dma mem(%p)",
+				__func__, priv->cnt_idx_dma_mem);
+			goto err_dma_map;
+		}
 	}
 
-	priv->cnt_values_dma_mem = rte_malloc(NULL, DPAA2_MAC_STATS_VALUE_DMA_SIZE,
-					      RTE_CACHE_LINE_SIZE);
 	if (!priv->cnt_values_dma_mem) {
-		DPAA2_PMD_ERR("Failure to allocate memory for mac values");
-		goto err_alloc_values;
-	}
-
-	cnt_idx = priv->cnt_idx_dma_mem;
-	for (i = 0; i < DPAA2_MAC_NUM_STATS; i++)
-		*cnt_idx++ = rte_cpu_to_le_32((uint32_t)i);
-
-	priv->cnt_idx_iova = rte_mem_virt2iova(priv->cnt_idx_dma_mem);
-	if (priv->cnt_idx_iova == RTE_BAD_IOVA) {
-		DPAA2_PMD_ERR("%s: No IOMMU map for count index dma mem(%p)",
-			__func__, priv->cnt_idx_dma_mem);
-		goto err_dma_map;
-	}
-
-	priv->cnt_values_iova = rte_mem_virt2iova(priv->cnt_values_dma_mem);
-	if (priv->cnt_values_iova == RTE_BAD_IOVA) {
-		DPAA2_PMD_ERR("%s: No IOMMU map for count values dma mem(%p)",
-			__func__, priv->cnt_values_dma_mem);
-		goto err_dma_map;
+		priv->cnt_values_dma_mem = rte_zmalloc(NULL,
+			DPAA2_MAC_STATS_VALUE_DMA_SIZE, RTE_CACHE_LINE_SIZE);
+		if (!priv->cnt_values_dma_mem) {
+			ret = -ENOMEM;
+			DPAA2_PMD_ERR("Failure to allocate memory for mac values");
+			goto err_alloc_values;
+		}
+		priv->cnt_values_iova = rte_mem_virt2iova(priv->cnt_values_dma_mem);
+		if (priv->cnt_values_iova == RTE_BAD_IOVA) {
+			ret = -ENOBUFS;
+			DPAA2_PMD_ERR("%s: No IOMMU map for count values dma mem(%p)",
+				__func__, priv->cnt_values_dma_mem);
+			goto err_dma_map;
+		}
 	}
 
-	return;
+	return 0;
 
 err_dma_map:
 	rte_free(priv->cnt_values_dma_mem);
@@ -2021,222 +2094,279 @@ dpaa2_dev_mac_setup_stats(struct rte_eth_dev *dev)
 out:
 	priv->cnt_idx_dma_mem = NULL;
 	priv->cnt_values_dma_mem = NULL;
+
+	return ret;
 }
 
-/*
- * dpaa2_dev_xstats_get(): Get counters of dpni and dpmac.
- * MAC (mac_*) counters are supported on MC version > 10.39.0
- * TC_x_policer_* counters are supported only when Policer is enable.
- */
 static int
-dpaa2_dev_xstats_get(struct rte_eth_dev *dev,
-	struct rte_eth_xstat *xstats, unsigned int n)
+dpaa2_dev_mac_xstats_avail(struct rte_eth_dev *dev)
 {
-	struct fsl_mc_io *dpni = (struct fsl_mc_io *)dev->process_private;
-	unsigned int i = 0, j = 0, num = RTE_DIM(dpaa2_xstats_strings);
 	struct dpaa2_dev_priv *priv = dev->data->dev_private;
-	union dpni_statistics value[13] = {};
-	struct dpni_rx_tc_policing_cfg cfg;
-	uint8_t page_id, stats_id;
-	uint64_t *cnt_values;
-	int32_t retcode;
-	int16_t tc;
-
-	if (n < num)
-		return num;
-
-	if (!xstats)
-		return 0;
-
-	/* Get Counters from page_0*/
-	retcode = dpni_get_statistics(dpni, CMD_PRI_LOW, priv->token,
-				      0, 0, &value[0]);
-	if (retcode)
-		goto err;
+	uint64_t rev_mac_support;
 
-	/* Get Counters from page_1*/
-	retcode = dpni_get_statistics(dpni, CMD_PRI_LOW, priv->token,
-				      1, 0, &value[1]);
-	if (retcode)
-		goto err;
-
-	/* Get Counters from page_2*/
-	retcode = dpni_get_statistics(dpni, CMD_PRI_LOW, priv->token,
-				      2, 0, &value[2]);
-	if (retcode)
-		goto err;
-
-	for (j = 0; j < priv->max_cgs; j++) {
-		if (!priv->cgid_in_use[j]) {
-			/* Get Counters from page_4*/
-			retcode = dpni_get_statistics(dpni, CMD_PRI_LOW,
-						      priv->token,
-						      4, 0, &value[4]);
-			if (retcode)
-				goto err;
-			break;
-		}
-	}
+	if (priv->ep_dev_type != DPAA2_MAC)
+		return false;
 
-	for (tc = 0; tc < priv->num_rx_tc; tc++) {
-		retcode = dpni_get_rx_tc_policing(dpni, CMD_PRI_LOW,
-						  priv->token, tc,
-						  &cfg);
-		if (retcode) {
-			DPAA2_PMD_ERR("Error to get the policer rule: %d", retcode);
-			goto err;
-		}
+	rev_mac_support = RTE_FSL_MC_REV(MC_VER_MAJOR, MC_VER_MINOR, 0);
+	if (priv->mc_rev >= rev_mac_support)
+		return true;
 
-		/* get policer stats if policer is enabled */
-		if (cfg.mode != 0) {
-			/* Get Counters from page_5*/
-			retcode = dpni_get_statistics(dpni, CMD_PRI_LOW,
-						      priv->token, 5, tc,
-						      &value[(tc + 5)]);
-			if (retcode)
-				goto err;
-		}
-	}
+	return false;
+}
 
-	while (i < (num - DPAA2_MAC_NUM_STATS)) {
-		xstats[i].id = i;
-		page_id = dpaa2_xstats_strings[i].page_id;
-		stats_id = dpaa2_xstats_strings[i].stats_id;
-		xstats[i].value = value[page_id].raw.counter[stats_id];
-		i++;
-	}
+static int
+dpaa2_dev_dpni_xstats_avail(struct rte_eth_dev *dev,
+	uint8_t page_id, uint16_t param)
+{
+	struct dpaa2_dev_priv *priv = dev->data->dev_private;
+	uint8_t tc, i;
 
-	if (priv->cnt_idx_dma_mem &&
-	    !dpni_get_mac_statistics(dpni, CMD_PRI_LOW, priv->token,
-				    priv->cnt_idx_iova,
-				    priv->cnt_values_iova,
-				    DPAA2_MAC_NUM_STATS)) {
-		cnt_values = priv->cnt_values_dma_mem;
-		while (i >= (num - DPAA2_MAC_NUM_STATS) && i < num) {
-			xstats[i].id = i;
-			xstats[i].value = rte_le_to_cpu_64(*cnt_values++);
-			i++;
+	if (page_id == DPNI_CGR_STATISTICS_PAGE_ID) {
+		for (i = 0; i < priv->max_cgs; i++) {
+			if (priv->cgid_in_use[i])
+				return true;
 		}
-		return i;
-	}
-
-	while (i >= (num - DPAA2_MAC_NUM_STATS) && i < num) {
-		xstats[i].id = i;
-		xstats[i].value = 0;
-		i++;
+	} else if (page_id == DPNI_POLICER_STATISTICS_PAGE_ID) {
+		tc = param;
+		if (tc < MAX_TCS)
+			return true;
+	} else {
+		return true;
 	}
 
-	return i;
-err:
-	DPAA2_PMD_ERR("Error in obtaining extended stats (%d)", retcode);
-	return retcode;
+	return false;
 }
 
 static int
-dpaa2_xstats_get_names(__rte_unused struct rte_eth_dev *dev,
-	struct rte_eth_xstat_name *xstats_names,
-	unsigned int limit)
+dpaa2_dev_xstats_get_names(struct rte_eth_dev *dev,
+	struct rte_eth_xstat_name *xstats_names, uint32_t limit)
 {
-	unsigned int i, stat_cnt = RTE_DIM(dpaa2_xstats_strings);
+	uint16_t i, stat_cnt;
+
+	stat_cnt = DPAA2_DPNI_XSTAT_MAX_NUM;
+	if (dpaa2_dev_mac_xstats_avail(dev))
+		stat_cnt += DPAA2_MAC_XSTAT_MAX_NUM;
+
+	if (!limit)
+		return stat_cnt;
 
 	if (limit < stat_cnt)
+		stat_cnt = limit;
+
+	if (!xstats_names)
 		return stat_cnt;
 
-	if (xstats_names != NULL)
-		for (i = 0; i < stat_cnt; i++)
-			strlcpy(xstats_names[i].name,
-				dpaa2_xstats_strings[i].name,
-				sizeof(xstats_names[i].name));
+	for (i = 0; i < stat_cnt; i++)
+		rte_strscpy(xstats_names[i].name, dpaa2_xstats_strings[i],
+			RTE_ETH_XSTATS_NAME_SIZE);
 
 	return stat_cnt;
 }
 
 static int
-dpaa2_xstats_get_by_id(struct rte_eth_dev *dev, const uint64_t *ids,
-	uint64_t *values, unsigned int n)
+dpaa2_dev_xstats_get_by_id(struct rte_eth_dev *dev, const uint64_t *ids,
+	uint64_t *values, uint32_t n)
 {
-	unsigned int i, stat_cnt = RTE_DIM(dpaa2_xstats_strings);
-	uint64_t values_copy[stat_cnt];
-	uint8_t page_id, stats_id;
+	uint16_t i, id, stat_cnt, mac_num = 0;
+	uint8_t page_id, stat_id;
+	uint16_t param;
+	struct dpaa2_dev_priv *priv = dev->data->dev_private;
+	struct fsl_mc_io *dpni = dev->process_private;
+	bool page_fetched[DPNI_MAX_STATISTICS_PAGE_ID][DPNI_STAT_MAX_PARAM];
+	/* Fetch required MAC counters in a single MC command. */
+	int retcode;
+	uint32_t *mac_idx;
+	uint64_t *mac_val[DPAA2_MAC_XSTAT_MAX_NUM];
 
-	if (!ids) {
-		struct dpaa2_dev_priv *priv = dev->data->dev_private;
-		struct fsl_mc_io *dpni = dev->process_private;
-		int32_t retcode;
-		union dpni_statistics value[5] = {};
+	retcode = dpaa2_dev_xstat_mac_setup_mem(dev);
+	if (retcode) {
+		DPAA2_PMD_ERR("%s: Failed(%d) to setup %s's MAC statistics!",
+			__func__, retcode, dev->data->name);
+		return retcode;
+	}
+	mac_idx = priv->cnt_idx_dma_mem;
 
-		if (n < stat_cnt)
-			return stat_cnt;
+	stat_cnt = DPAA2_DPNI_XSTAT_MAX_NUM;
+	if (dpaa2_dev_mac_xstats_avail(dev))
+		stat_cnt += DPAA2_MAC_XSTAT_MAX_NUM;
 
-		if (!values)
-			return 0;
+	memset(page_fetched, 0, sizeof(page_fetched));
 
-		/* Get Counters from page_0*/
-		retcode = dpni_get_statistics(dpni, CMD_PRI_LOW, priv->token,
-					      0, 0, &value[0]);
+	for (i = 0; i < n; i++) {
+		if (ids && ids[i] >= stat_cnt) {
+			DPAA2_PMD_ERR("xstats id value isn't valid");
+			return -EINVAL;
+		}
+		id = ids ? ids[i] : i;
+		if (id >= DPAA2_MAC_XSTATS_START_ID) {
+			values[i] = 0;
+			/* ids[] is supplied by the application and may repeat
+			 * the same MAC id, so bound the collection against the
+			 * mac_idx[]/mac_val[] and DMA buffer capacity.
+			 */
+			if (dpaa2_dev_mac_xstats_avail(dev) &&
+				mac_num < DPAA2_MAC_XSTAT_MAX_NUM) {
+				mac_idx[mac_num] = rte_cpu_to_le_32(id - DPAA2_MAC_XSTATS_START_ID);
+				mac_val[mac_num] = &values[i];
+				mac_num++;
+			}
+			continue;
+		}
+		page_id = 0;
+		stat_id = 0;
+		param = 0;
+		retcode = dpaa2_xstats_id_parse(id, &page_id, &stat_id, &param, NULL);
 		if (retcode)
-			return 0;
+			return retcode;
+		if (!dpaa2_dev_dpni_xstats_avail(dev, page_id, param)) {
+			values[i] = 0;
+			continue;
+		}
+		if (page_fetched[page_id][param]) {
+			values[i] = priv->pg_xstats[page_id][param].raw.counter[stat_id];
+			continue;
+		}
+		/* Cache dpni page results: multiple xstats can share
+		 * the same (page_id, param), so only fetch each pair once.
+		 */
+		retcode = dpni_get_statistics(dpni, CMD_PRI_LOW,
+				priv->token, page_id, param,
+				&priv->pg_xstats[page_id][param]);
+		if (retcode) {
+			DPAA2_PMD_ERR("%s: Failed(%d) to get %s's statistcis of page%d!",
+				__func__, retcode, dev->data->name, page_id);
+			return retcode;
+		}
+		page_fetched[page_id][param] = true;
+		values[i] = priv->pg_xstats[page_id][param].raw.counter[stat_id];
+	}
 
-		/* Get Counters from page_1*/
-		retcode = dpni_get_statistics(dpni, CMD_PRI_LOW, priv->token,
-					      1, 0, &value[1]);
-		if (retcode)
-			return 0;
+	if (mac_num > 0) {
+		retcode = dpni_get_mac_statistics(dpni, CMD_PRI_LOW,
+			priv->token, priv->cnt_idx_iova,
+			priv->cnt_values_iova, mac_num);
+		if (retcode) {
+			DPAA2_PMD_ERR("%s: Failed(%d) to get %s's %d MAC statistics!",
+				__func__, retcode, dev->data->name, mac_num);
+			return retcode;
+		}
+		for (i = 0; i < mac_num; i++)
+			*mac_val[i] = priv->cnt_values_dma_mem[i];
+	}
 
-		/* Get Counters from page_2*/
-		retcode = dpni_get_statistics(dpni, CMD_PRI_LOW, priv->token,
-					      2, 0, &value[2]);
-		if (retcode)
-			return 0;
+	return n;
+}
 
-		/* Get Counters from page_4*/
-		retcode = dpni_get_statistics(dpni, CMD_PRI_LOW, priv->token,
-					      4, 0, &value[4]);
-		if (retcode)
-			return 0;
+static int
+dpaa2_dev_xstats_get_names_by_id(struct rte_eth_dev *dev,
+	const uint64_t *ids, struct rte_eth_xstat_name *xstats_names,
+	uint32_t limit)
+{
+	uint16_t i, stat_cnt;
 
-		for (i = 0; i < stat_cnt; i++) {
-			page_id = dpaa2_xstats_strings[i].page_id;
-			stats_id = dpaa2_xstats_strings[i].stats_id;
-			values[i] = value[page_id].raw.counter[stats_id];
-		}
-		return stat_cnt;
-	}
+	stat_cnt = DPAA2_DPNI_XSTAT_MAX_NUM;
+	if (dpaa2_dev_mac_xstats_avail(dev))
+		stat_cnt += DPAA2_MAC_XSTAT_MAX_NUM;
 
-	dpaa2_xstats_get_by_id(dev, NULL, values_copy, stat_cnt);
+	if (!ids)
+		return dpaa2_dev_xstats_get_names(dev, xstats_names, limit);
 
-	for (i = 0; i < n; i++) {
+	for (i = 0; i < limit; i++) {
 		if (ids[i] >= stat_cnt) {
-			DPAA2_PMD_ERR("xstats id value isn't valid");
+			DPAA2_PMD_ERR("xstats id[%d] value(%" PRIu64 ") >= max count(%d)",
+				i, ids[i], stat_cnt);
 			return -EINVAL;
 		}
-		values[i] = values_copy[ids[i]];
+		rte_strscpy(xstats_names[i].name,
+			dpaa2_xstats_strings[ids[i]],
+			RTE_ETH_XSTATS_NAME_SIZE);
 	}
-	return n;
+	return limit;
 }
 
+/*
+ * dpaa2_dev_xstats_get(): Get counters of dpni and dpmac.
+ * MAC (mac_*) counters are supported on MC version > 10.39.0
+ * TC_x_policer_* counters are supported only when Policer is enable.
+ */
 static int
-dpaa2_xstats_get_names_by_id(struct rte_eth_dev *dev,
-	const uint64_t *ids,
-	struct rte_eth_xstat_name *xstats_names,
-	unsigned int limit)
+dpaa2_dev_xstats_get(struct rte_eth_dev *dev,
+	struct rte_eth_xstat *xstats, uint32_t n)
 {
-	unsigned int i, stat_cnt = RTE_DIM(dpaa2_xstats_strings);
-	struct rte_eth_xstat_name xstats_names_copy[stat_cnt];
+	int retcode;
+	uint32_t i;
+	uint64_t ids[DPAA2_XSTAT_MAX_NUM], vals[DPAA2_XSTAT_MAX_NUM];
 
-	if (!ids)
-		return dpaa2_xstats_get_names(dev, xstats_names, limit);
+	if (!xstats || !n)
+		return 0;
+
+	if (n > DPAA2_XSTAT_MAX_NUM) {
+		DPAA2_PMD_WARN("%s: Expected xstat number(%d) > max(%ld)",
+			__func__, n, DPAA2_XSTAT_MAX_NUM);
+		n = DPAA2_XSTAT_MAX_NUM;
+	}
+	for (i = 0; i < n; i++) {
+		ids[i] = i;
+		xstats[i].id = i;
+		xstats[i].value = 0;
+	}
 
-	dpaa2_xstats_get_names(dev, xstats_names_copy, limit);
+	retcode = dpaa2_dev_xstats_get_by_id(dev, ids, vals, n);
+	if (retcode < 0)
+		return retcode;
 
-	for (i = 0; i < limit; i++) {
-		if (ids[i] >= stat_cnt) {
-			DPAA2_PMD_ERR("xstats id value isn't valid");
-			return -1;
+	for (i = 0; i < (uint32_t)retcode; i++)
+		xstats[i].value = vals[i];
+
+	return retcode;
+}
+
+static int
+dpaa2_dev_stats_get(struct rte_eth_dev *dev,
+	struct rte_eth_stats *stats, struct eth_queue_stats *qstats)
+{
+	struct dpaa2_dev_priv *priv = dev->data->dev_private;
+	int32_t retcode;
+	uint16_t i, num;
+	uint64_t ids[DPAA2_STATS_XSTATS_NUM], counts[DPAA2_STATS_XSTATS_NUM] = {0};
+	struct dpaa2_queue *dpaa2_q;
+
+	PMD_INIT_FUNC_TRACE();
+
+	rte_memcpy(ids, &dpaa2_stats_xstat_ids, sizeof(dpaa2_stats_xstat_ids));
+	retcode = dpaa2_dev_xstats_get_by_id(dev, ids, counts, DPAA2_STATS_XSTATS_NUM);
+	if (retcode != RTE_DIM(ids)) {
+		DPAA2_PMD_ERR("%s: Failed to get xstats (%d)counters by %ld IDs",
+			__func__, retcode, DPAA2_STATS_XSTATS_NUM);
+		if (retcode >= 0)
+			retcode = -EINVAL;
+		return retcode;
+	}
+
+	rte_memcpy(stats, counts, sizeof(struct rte_eth_stats));
+	stats->imissed += stats->ierrors + stats->rx_nombuf;
+
+	if (qstats) {
+		/* Fill in per queue stats */
+		num = RTE_MIN(priv->nb_rx_queues, RTE_ETHDEV_QUEUE_STAT_CNTRS);
+		for (i = 0; i < num; i++) {
+			dpaa2_q = priv->rx_vq[i];
+			qstats->q_ipackets[i] = dpaa2_q->rx_pkts;
+
+			/* Byte counting is not implemented */
+			qstats->q_ibytes[i] = 0;
+		}
+		num = RTE_MIN(priv->nb_tx_queues, RTE_ETHDEV_QUEUE_STAT_CNTRS);
+		for (i = 0; i < num; i++) {
+			dpaa2_q = priv->tx_vq[i];
+			qstats->q_opackets[i] = dpaa2_q->tx_pkts;
+
+			/* Byte counting is not implemented */
+			qstats->q_obytes[i] = 0;
 		}
-		strcpy(xstats_names[i].name, xstats_names_copy[ids[i]].name);
 	}
-	return limit;
+
+	return 0;
 }
 
 static int
@@ -2255,7 +2385,7 @@ dpaa2_dev_stats_reset(struct rte_eth_dev *dev)
 		return -EINVAL;
 	}
 
-	retcode =  dpni_reset_statistics(dpni, CMD_PRI_LOW, priv->token);
+	retcode = dpni_reset_statistics(dpni, CMD_PRI_LOW, priv->token);
 	if (retcode)
 		goto error;
 
@@ -3262,9 +3392,9 @@ static struct eth_dev_ops dpaa2_ethdev_ops = {
 	.link_update	   = dpaa2_dev_link_update,
 	.stats_get	       = dpaa2_dev_stats_get,
 	.xstats_get	       = dpaa2_dev_xstats_get,
-	.xstats_get_by_id     = dpaa2_xstats_get_by_id,
-	.xstats_get_names_by_id = dpaa2_xstats_get_names_by_id,
-	.xstats_get_names      = dpaa2_xstats_get_names,
+	.xstats_get_by_id     = dpaa2_dev_xstats_get_by_id,
+	.xstats_get_names_by_id = dpaa2_dev_xstats_get_names_by_id,
+	.xstats_get_names      = dpaa2_dev_xstats_get_names,
 	.stats_reset	   = dpaa2_dev_stats_reset,
 	.xstats_reset	      = dpaa2_dev_stats_reset,
 	.fw_version_get	   = dpaa2_fw_version_get,
@@ -3719,17 +3849,6 @@ dpaa2_dev_init(struct rte_eth_dev *eth_dev)
 
 	priv->speed_capa = dpaa2_dev_get_speed_capability(eth_dev);
 
-	/* mac_statistics supported on MC version > 10.39.0 */
-	{
-		struct mc_version mc_ver_info = {0};
-
-		if (!mc_get_version(dpni_dev, CMD_PRI_LOW, &mc_ver_info) &&
-		    mc_ver_info.major >= MC_VER_MAJOR &&
-		    mc_ver_info.minor >= MC_VER_MINOR &&
-		    mc_ver_info.revision > 0)
-			dpaa2_dev_mac_setup_stats(eth_dev);
-	}
-
 	return 0;
 init_err:
 	dpaa2_dev_close(eth_dev);
drivers/net/dpaa2/dpaa2_ethdev.h +8 -4
index 33195f0584..a76e7f9287 100644
@@ -205,7 +205,8 @@
 	(DPAA2_PKT_TYPE_VLAN_1 | DPAA2_PKT_TYPE_VLAN_2)
 
 /* mac counters */
-#define DPAA2_MAC_NUM_STATS            (DPMAC_CNT_EGR_CONTROL_FRAME + 1)
+#define DPAA2_MAC_NUM_STATS \
+	(sizeof(struct dpni_dpmac_counters) / sizeof(uint64_t))
 #define DPAA2_MAC_STATS_INDEX_DMA_SIZE (DPAA2_MAC_NUM_STATS * sizeof(uint32_t))
 #define DPAA2_MAC_STATS_VALUE_DMA_SIZE (DPAA2_MAC_NUM_STATS * sizeof(uint64_t))
 
@@ -542,6 +543,12 @@ struct dpaa2_dev_priv {
 	uint64_t cnt_idx_iova, cnt_values_iova;
 	uint64_t mc_rev;
 
+	/* Cache one dpni_statistics result per (page_id, param) pair to avoid
+	 * redundant MC commands when multiple xstats share the same page.
+	 * Put it in heap to avoid allocating multi-KB stack in runtime.
+	 */
+	union dpni_statistics pg_xstats[DPNI_MAX_STATISTICS_PAGE_ID][DPNI_STAT_MAX_PARAM];
+
 	struct dpaa2_dev_flow *curr;
 	LIST_HEAD(, dpaa2_dev_flow) flows;
 	LIST_HEAD(, dpaa2_dev_meter_profile) profiles;
@@ -703,7 +710,4 @@ dpaa2_eth_sg_fd_to_mbuf(struct dpaa2_dev_priv *priv, const struct qbman_fd *fd);
 int dpaa2_mtr_ops_get(struct rte_eth_dev *dev, void *ops);
 int dpaa2_soft_parser_loaded(void);
 
-void
-dpaa2_dev_mac_setup_stats(struct rte_eth_dev *dev);
-
 #endif /* _DPAA2_ETHDEV_H */
drivers/net/dpaa2/mc/fsl_dpni.h +214 -45

273 lines not on this page · raw message

Signature · 1 line
2.43.0
#90 lore raw

PATCH v2 36/47 net/dpaa2: rework flow engine

In reply to Prashant Gupta

From: Hemant Agrawal <[email protected]>

Rework the dpaa2 flow engine so that flow rules are programmed through the updated QoS and flow steering (FS) table interface.

The distribution helpers in base/dpaa2_hw_dpni.c are removed and folded into the ethdev and flow code, which removes a layer of indirection and keeps the key extraction, RSS distribution and QoS/FS entry programming together in one place.

---
 drivers/net/dpaa2/base/dpaa2_hw_dpni.c |  546 --
 drivers/net/dpaa2/dpaa2_ethdev.c       |  399 +-
 drivers/net/dpaa2/dpaa2_ethdev.h       |  482 +-
 drivers/net/dpaa2/dpaa2_flow.c         | 6439 +++++++++++++-----------
 drivers/net/dpaa2/meson.build          |    3 +-
 5 files changed, 4119 insertions(+), 3750 deletions(-)
 delete mode 100644 drivers/net/dpaa2/base/dpaa2_hw_dpni.c
drivers/net/dpaa2/base/dpaa2_hw_dpni.c deleted +0 -546
deleted file mode 100644
index fee96b3529..0000000000
@@ -1,546 +0,0 @@
-/* SPDX-License-Identifier: BSD-3-Clause
- *
- *   Copyright (c) 2016 Freescale Semiconductor, Inc. All rights reserved.
- *   Copyright 2016-2021,2023-2025 NXP
- *
- */
-
-#include <time.h>
-#include <net/if.h>
-
-#include <eal_export.h>
-#include <rte_mbuf.h>
-#include <ethdev_driver.h>
-#include <rte_malloc.h>
-#include <rte_memcpy.h>
-#include <rte_string_fns.h>
-#include <rte_cycles.h>
-#include <rte_kvargs.h>
-#include <dev_driver.h>
-
-#include <dpaa2_pmd_logs.h>
-#include <dpaa2_hw_pvt.h>
-#include <dpaa2_hw_mempool.h>
-
-#include "../dpaa2_ethdev.h"
-
-int
-dpaa2_distset_to_dpkg_profile_cfg(
-		uint64_t req_dist_set,
-		struct dpkg_profile_cfg *kg_cfg);
-
-RTE_EXPORT_SYMBOL(rte_pmd_dpaa2_set_custom_hash)
-int
-rte_pmd_dpaa2_set_custom_hash(uint16_t port_id,
-	uint16_t offset, uint8_t size)
-{
-	struct rte_eth_dev *eth_dev = &rte_eth_devices[port_id];
-	struct dpaa2_dev_priv *priv = eth_dev->data->dev_private;
-	struct fsl_mc_io *dpni = priv->hw;
-	struct dpni_rx_tc_dist_cfg tc_cfg;
-	struct dpkg_profile_cfg kg_cfg;
-	void *p_params;
-	int ret, tc_index = 0;
-
-	if (!rte_eth_dev_is_valid_port(port_id)) {
-		DPAA2_PMD_WARN("Invalid port id %u", port_id);
-		return -EINVAL;
-	}
-
-	if (strcmp(eth_dev->device->driver->name,
-			RTE_STR(NET_DPAA2_PMD_DRIVER_NAME))) {
-		DPAA2_PMD_WARN("Not a valid dpaa2 port");
-		return -EINVAL;
-	}
-
-	p_params = rte_zmalloc(NULL,
-		DIST_PARAM_IOVA_SIZE, RTE_CACHE_LINE_SIZE);
-	if (!p_params) {
-		DPAA2_PMD_ERR("Unable to allocate flow-dist parameters");
-		return -ENOMEM;
-	}
-
-	memset(&kg_cfg, 0, sizeof(struct dpkg_profile_cfg));
-	kg_cfg.extracts[0].type = DPKG_EXTRACT_FROM_DATA;
-	kg_cfg.extracts[0].extract.from_data.offset = offset;
-	kg_cfg.extracts[0].extract.from_data.size = size;
-	kg_cfg.extracts[0].num_of_byte_masks = 0;
-	kg_cfg.num_extracts = 1;
-
-	ret = dpkg_prepare_key_cfg(&kg_cfg, p_params);
-	if (ret) {
-		DPAA2_PMD_ERR("Unable to prepare extract parameters");
-		rte_free(p_params);
-		return ret;
-	}
-
-	memset(&tc_cfg, 0, sizeof(struct dpni_rx_tc_dist_cfg));
-	tc_cfg.key_cfg_iova = DPAA2_VADDR_TO_IOVA_AND_CHECK(p_params,
-		DIST_PARAM_IOVA_SIZE);
-	if (tc_cfg.key_cfg_iova == RTE_BAD_IOVA) {
-		DPAA2_PMD_ERR("%s: No IOMMU map for key cfg(%p)",
-			__func__, p_params);
-		rte_free(p_params);
-		return -ENOBUFS;
-	}
-
-	tc_cfg.dist_size = eth_dev->data->nb_rx_queues;
-	tc_cfg.dist_mode = DPNI_DIST_MODE_HASH;
-
-	ret = dpni_set_rx_tc_dist(dpni, CMD_PRI_LOW, priv->token, tc_index,
-			&tc_cfg);
-	rte_free(p_params);
-	if (ret) {
-		DPAA2_PMD_ERR("Set RX TC dist failed(err=%d)", ret);
-		return ret;
-	}
-
-	return 0;
-}
-
-int
-dpaa2_setup_flow_dist(struct rte_eth_dev *eth_dev,
-	uint64_t req_dist_set, int tc_index)
-{
-	struct dpaa2_dev_priv *priv = eth_dev->data->dev_private;
-	int tc_dist_queues;
-
-	/* TC distribution size is set with dist_queues or
-	 * (nb_rx_queues - tc_index*dist_queues) in order of TC priority index.
-	 */
-	tc_dist_queues = eth_dev->data->nb_rx_queues -
-		tc_index * priv->dist_queues;
-	if (tc_dist_queues <= 0) {
-		DPAA2_PMD_INFO("No distribution on TC%d", tc_index);
-		return 0;
-	}
-
-	if (tc_dist_queues > priv->dist_queues)
-		tc_dist_queues = priv->dist_queues;
-
-	return dpaa2_setup_flow_dist_size(eth_dev, req_dist_set,
-					   tc_index, tc_dist_queues);
-}
-
-int
-dpaa2_setup_flow_dist_size(struct rte_eth_dev *eth_dev,
-	uint64_t req_dist_set, int tc_index, uint16_t dist_size)
-{
-	struct dpaa2_dev_priv *priv = eth_dev->data->dev_private;
-	struct fsl_mc_io *dpni = eth_dev->process_private;
-	struct dpni_rx_dist_cfg tc_cfg;
-	struct dpkg_profile_cfg kg_cfg;
-	void *p_params;
-	int ret;
-
-	if (dist_size == 0)
-		return 0;
-
-	p_params = rte_malloc(NULL,
-		DIST_PARAM_IOVA_SIZE, RTE_CACHE_LINE_SIZE);
-	if (!p_params) {
-		DPAA2_PMD_ERR("Unable to allocate flow-dist parameters");
-		return -ENOMEM;
-	}
-
-	memset(p_params, 0, DIST_PARAM_IOVA_SIZE);
-	memset(&tc_cfg, 0, sizeof(struct dpni_rx_dist_cfg));
-
-	ret = dpaa2_distset_to_dpkg_profile_cfg(req_dist_set, &kg_cfg);
-	if (ret) {
-		DPAA2_PMD_ERR("Given RSS Hash (%" PRIx64 ") not supported",
-			      req_dist_set);
-		rte_free(p_params);
-		return ret;
-	}
-
-	tc_cfg.key_cfg_iova = DPAA2_VADDR_TO_IOVA_AND_CHECK(p_params,
-		DIST_PARAM_IOVA_SIZE);
-	if (tc_cfg.key_cfg_iova == RTE_BAD_IOVA) {
-		DPAA2_PMD_ERR("%s: No IOMMU map for key cfg(%p)",
-			__func__, p_params);
-		rte_free(p_params);
-		return -ENOBUFS;
-	}
-
-	tc_cfg.dist_size = dist_size;
-	tc_cfg.enable = true;
-	tc_cfg.tc = tc_index;
-
-	ret = dpkg_prepare_key_cfg(&kg_cfg, p_params);
-	if (ret) {
-		DPAA2_PMD_ERR("Unable to prepare extract parameters");
-		rte_free(p_params);
-		return ret;
-	}
-
-	ret = dpni_set_rx_hash_dist(dpni, CMD_PRI_LOW, priv->token, &tc_cfg);
-	rte_free(p_params);
-	if (ret) {
-		DPAA2_PMD_ERR("RX Hash dist for failed(err=%d)", ret);
-		return ret;
-	}
-
-	if (tc_index < MAX_TCS)
-		priv->dist_size_cur[tc_index] = dist_size;
-
-	return 0;
-}
-
-int
-dpaa2_remove_flow_dist(struct rte_eth_dev *eth_dev,
-	uint8_t tc_index)
-{
-	struct dpaa2_dev_priv *priv = eth_dev->data->dev_private;
-	struct fsl_mc_io *dpni = priv->hw;
-	struct dpni_rx_dist_cfg tc_cfg;
-	struct dpkg_profile_cfg kg_cfg;
-	void *p_params;
-	int ret;
-
-	p_params = rte_malloc(NULL,
-		DIST_PARAM_IOVA_SIZE, RTE_CACHE_LINE_SIZE);
-	if (!p_params) {
-		DPAA2_PMD_ERR("Unable to allocate flow-dist parameters");
-		return -ENOMEM;
-	}
-
-	memset(&tc_cfg, 0, sizeof(struct dpni_rx_dist_cfg));
-	tc_cfg.dist_size = 0;
-	tc_cfg.key_cfg_iova = DPAA2_VADDR_TO_IOVA_AND_CHECK(p_params,
-		DIST_PARAM_IOVA_SIZE);
-	if (tc_cfg.key_cfg_iova == RTE_BAD_IOVA) {
-		DPAA2_PMD_ERR("%s: No IOMMU map for key cfg(%p)",
-			__func__, p_params);
-		rte_free(p_params);
-		return -ENOBUFS;
-	}
-
-	tc_cfg.enable = true;
-	tc_cfg.tc = tc_index;
-
-	memset(p_params, 0, DIST_PARAM_IOVA_SIZE);
-	kg_cfg.num_extracts = 0;
-	ret = dpkg_prepare_key_cfg(&kg_cfg, p_params);
-	if (ret) {
-		DPAA2_PMD_ERR("Unable to prepare extract parameters");
-		rte_free(p_params);
-		return ret;
-	}
-
-	ret = dpni_set_rx_hash_dist(dpni, CMD_PRI_LOW, priv->token,
-			&tc_cfg);
-	rte_free(p_params);
-	if (ret)
-		DPAA2_PMD_ERR("RX hash dist failed(err=%d)", ret);
-	return ret;
-}
-
-int
-dpaa2_distset_to_dpkg_profile_cfg(
-		uint64_t req_dist_set,
-		struct dpkg_profile_cfg *kg_cfg)
-{
-	uint32_t loop = 0, i = 0;
-	uint64_t dist_field = 0;
-	int l2_configured = 0, l3_configured = 0;
-	int l4_configured = 0;
-	int mpls_configured = 0;
-	int vlan_configured = 0;
-	int esp_configured = 0;
-	int ah_configured = 0;
-	int pppoe_configured = 0;
-
-	memset(kg_cfg, 0, sizeof(struct dpkg_profile_cfg));
-	while (req_dist_set) {
-		if (req_dist_set % 2 != 0) {
-			dist_field = 1ULL << loop;
-			switch (dist_field) {
-			case RTE_ETH_RSS_L2_PAYLOAD:
-			case RTE_ETH_RSS_ETH:
-				if (l2_configured)
-					break;
-				l2_configured = 1;
-
-				kg_cfg->extracts[i].extract.from_hdr.prot =
-					NET_PROT_ETH;
-				kg_cfg->extracts[i].extract.from_hdr.field =
-					NH_FLD_ETH_TYPE;
-				kg_cfg->extracts[i].type =
-					DPKG_EXTRACT_FROM_HDR;
-				kg_cfg->extracts[i].extract.from_hdr.type =
-					DPKG_FULL_FIELD;
-				i++;
-				break;
-
-			case RTE_ETH_RSS_PPPOE:
-				if (pppoe_configured)
-					break;
-				pppoe_configured = 1;
-
-				kg_cfg->extracts[i].extract.from_hdr.prot =
-					NET_PROT_PPPOE;
-				kg_cfg->extracts[i].extract.from_hdr.field =
-					NH_FLD_PPPOE_SID;
-				kg_cfg->extracts[i].type =
-					DPKG_EXTRACT_FROM_HDR;
-				kg_cfg->extracts[i].extract.from_hdr.type =
-					DPKG_FULL_FIELD;
-				i++;
-				break;
-
-			case RTE_ETH_RSS_ESP:
-				if (esp_configured)
-					break;
-				esp_configured = 1;
-
-				kg_cfg->extracts[i].extract.from_hdr.prot =
-					NET_PROT_IPSEC_ESP;
-				kg_cfg->extracts[i].extract.from_hdr.field =
-					NH_FLD_IPSEC_ESP_SPI;
-				kg_cfg->extracts[i].type =
-					DPKG_EXTRACT_FROM_HDR;
-				kg_cfg->extracts[i].extract.from_hdr.type =
-					DPKG_FULL_FIELD;
-				i++;
-				break;
-
-			case RTE_ETH_RSS_AH:
-				if (ah_configured)
-					break;
-				ah_configured = 1;
-
-				kg_cfg->extracts[i].extract.from_hdr.prot =
-					NET_PROT_IPSEC_AH;
-				kg_cfg->extracts[i].extract.from_hdr.field =
-					NH_FLD_IPSEC_AH_SPI;
-				kg_cfg->extracts[i].type =
-					DPKG_EXTRACT_FROM_HDR;
-				kg_cfg->extracts[i].extract.from_hdr.type =
-					DPKG_FULL_FIELD;
-				i++;
-				break;
-
-			case RTE_ETH_RSS_C_VLAN:
-			case RTE_ETH_RSS_S_VLAN:
-				if (vlan_configured)
-					break;
-				vlan_configured = 1;
-
-				kg_cfg->extracts[i].extract.from_hdr.prot =
-					NET_PROT_VLAN;
-				kg_cfg->extracts[i].extract.from_hdr.field =
-					NH_FLD_VLAN_TCI;
-				kg_cfg->extracts[i].type =
-					DPKG_EXTRACT_FROM_HDR;
-				kg_cfg->extracts[i].extract.from_hdr.type =
-					DPKG_FULL_FIELD;
-				i++;
-				break;
-
-			case RTE_ETH_RSS_MPLS:
-
-				if (mpls_configured)
-					break;
-				mpls_configured = 1;
-
-				kg_cfg->extracts[i].extract.from_hdr.prot =
-					NET_PROT_MPLS;
-				kg_cfg->extracts[i].extract.from_hdr.field =
-					NH_FLD_MPLS_MPLSL_1;
-				kg_cfg->extracts[i].type =
-					DPKG_EXTRACT_FROM_HDR;
-				kg_cfg->extracts[i].extract.from_hdr.type =
-					DPKG_FULL_FIELD;
-				i++;
-
-				kg_cfg->extracts[i].extract.from_hdr.prot =
-					NET_PROT_MPLS;
-				kg_cfg->extracts[i].extract.from_hdr.field =
-					NH_FLD_MPLS_MPLSL_2;
-				kg_cfg->extracts[i].type =
-					DPKG_EXTRACT_FROM_HDR;
-				kg_cfg->extracts[i].extract.from_hdr.type =
-					DPKG_FULL_FIELD;
-				i++;
-
-				kg_cfg->extracts[i].extract.from_hdr.prot =
-					NET_PROT_MPLS;
-				kg_cfg->extracts[i].extract.from_hdr.field =
-					NH_FLD_MPLS_MPLSL_N;
-				kg_cfg->extracts[i].type =
-					DPKG_EXTRACT_FROM_HDR;
-				kg_cfg->extracts[i].extract.from_hdr.type =
-					DPKG_FULL_FIELD;
-				i++;
-				break;
-
-			case RTE_ETH_RSS_IPV4:
-			case RTE_ETH_RSS_FRAG_IPV4:
-			case RTE_ETH_RSS_NONFRAG_IPV4_OTHER:
-			case RTE_ETH_RSS_IPV6:
-			case RTE_ETH_RSS_FRAG_IPV6:
-			case RTE_ETH_RSS_NONFRAG_IPV6_OTHER:
-			case RTE_ETH_RSS_IPV6_EX:
-
-				if (l3_configured)
-					break;
-				l3_configured = 1;
-
-				kg_cfg->extracts[i].extract.from_hdr.prot =
-					NET_PROT_IP;
-				kg_cfg->extracts[i].extract.from_hdr.field =
-					NH_FLD_IP_SRC;
-				kg_cfg->extracts[i].type =
-					DPKG_EXTRACT_FROM_HDR;
-				kg_cfg->extracts[i].extract.from_hdr.type =
-					DPKG_FULL_FIELD;
-				i++;
-
-				kg_cfg->extracts[i].extract.from_hdr.prot =
-					NET_PROT_IP;
-				kg_cfg->extracts[i].extract.from_hdr.field =
-					NH_FLD_IP_DST;
-				kg_cfg->extracts[i].type =
-					DPKG_EXTRACT_FROM_HDR;
-				kg_cfg->extracts[i].extract.from_hdr.type =
-					DPKG_FULL_FIELD;
-				i++;
-
-				kg_cfg->extracts[i].extract.from_hdr.prot =
-					NET_PROT_IP;
-				kg_cfg->extracts[i].extract.from_hdr.field =
-					NH_FLD_IP_PROTO;
-				kg_cfg->extracts[i].type =
-					DPKG_EXTRACT_FROM_HDR;
-				kg_cfg->extracts[i].extract.from_hdr.type =
-					DPKG_FULL_FIELD;
-				i++;
-			break;
-
-			case RTE_ETH_RSS_NONFRAG_IPV4_TCP:
-			case RTE_ETH_RSS_NONFRAG_IPV6_TCP:
-			case RTE_ETH_RSS_NONFRAG_IPV4_UDP:
-			case RTE_ETH_RSS_NONFRAG_IPV6_UDP:
-			case RTE_ETH_RSS_IPV6_TCP_EX:
-			case RTE_ETH_RSS_IPV6_UDP_EX:
-			case RTE_ETH_RSS_NONFRAG_IPV4_SCTP:
-			case RTE_ETH_RSS_NONFRAG_IPV6_SCTP:
-
-				if (l4_configured)
-					break;
-				l4_configured = 1;
-
-				kg_cfg->extracts[i].extract.from_hdr.prot =
-					NET_PROT_TCP;
-				kg_cfg->extracts[i].extract.from_hdr.field =
-					NH_FLD_TCP_PORT_SRC;
-				kg_cfg->extracts[i].type =
-					DPKG_EXTRACT_FROM_HDR;
-				kg_cfg->extracts[i].extract.from_hdr.type =
-					DPKG_FULL_FIELD;
-				i++;
-
-				kg_cfg->extracts[i].extract.from_hdr.prot =
-					NET_PROT_TCP;
-				kg_cfg->extracts[i].extract.from_hdr.field =
-					NH_FLD_TCP_PORT_DST;
-				kg_cfg->extracts[i].type =
-					DPKG_EXTRACT_FROM_HDR;
-				kg_cfg->extracts[i].extract.from_hdr.type =
-					DPKG_FULL_FIELD;
-				i++;
-				break;
-
-			default:
-				DPAA2_PMD_WARN(
-				      "unsupported flow dist option 0x%" PRIx64,
-					     dist_field);
-				return -EINVAL;
-			}
-		}
-		req_dist_set = req_dist_set >> 1;
-		loop++;
-	}
-	kg_cfg->num_extracts = i;
-	return 0;
-}
-
-int
-dpaa2_attach_bp_list(struct dpaa2_dev_priv *priv,
-	struct fsl_mc_io *dpni, void *blist)
-{
-	/* Function to attach a DPNI with a buffer pool list. Buffer pool list
-	 * handle is passed in blist.
-	 */
-	int32_t retcode;
-	struct dpni_pools_cfg bpool_cfg;
-	struct dpaa2_bp_list *bp_list = (struct dpaa2_bp_list *)blist;
-	struct dpni_buffer_layout layout;
-	int tot_size;
-
-	/* ... rx buffer layout .
-	 * Check alignment for buffer layouts first
-	 */
-
-	/* ... rx buffer layout ... */
-	if (priv->flags & DPAA2_TX_PREFETCH_DYNAMIC_CONF) {
-		int out_min_hdr_room, in_min_hdr_room;
-		/** Additional headroom layout for IPSec with TX configure
-		 * dynamic enabled.
-		 */
-		in_min_hdr_room = DPAA2_RX_MIN_FD_OFFSET +
-			DPAA2_SEC_SIMPLE_FD_IB_MIN;
-		out_min_hdr_room = DPAA2_DYN_TX_MIN_FD_OFFSET +
-			DPAA2_SEC_SIMPLE_FD_OB_MIN;
-		tot_size = RTE_MAX(in_min_hdr_room, out_min_hdr_room);
-		if (tot_size < RTE_PKTMBUF_HEADROOM)
-			tot_size = RTE_PKTMBUF_HEADROOM;
-	} else {
-		tot_size = RTE_PKTMBUF_HEADROOM;
-	}
-	tot_size = RTE_ALIGN_CEIL(tot_size, DPAA2_PACKET_LAYOUT_ALIGN);
-
-	memset(&layout, 0, sizeof(struct dpni_buffer_layout));
-	layout.options = DPNI_BUF_LAYOUT_OPT_DATA_HEAD_ROOM |
-			 DPNI_BUF_LAYOUT_OPT_FRAME_STATUS |
-			 DPNI_BUF_LAYOUT_OPT_PARSER_RESULT |
-			 DPNI_BUF_LAYOUT_OPT_DATA_ALIGN |
-			 DPNI_BUF_LAYOUT_OPT_TIMESTAMP |
-			 DPNI_BUF_LAYOUT_OPT_PRIVATE_DATA_SIZE;
-
-	layout.pass_timestamp = true;
-	layout.pass_frame_status = 1;
-	layout.private_data_size = DPAA2_FD_PTA_SIZE;
-	layout.pass_parser_result = 1;
-	layout.data_align = DPAA2_PACKET_LAYOUT_ALIGN;
-	layout.data_head_room = tot_size - DPAA2_FD_PTA_SIZE -
-				DPAA2_MBUF_HW_ANNOTATION;
-	retcode = dpni_set_buffer_layout(dpni, CMD_PRI_LOW, priv->token,
-					 DPNI_QUEUE_RX, &layout);
-	if (retcode) {
-		DPAA2_PMD_ERR("Error configuring buffer pool Rx layout (%d)",
-			     retcode);
-		return retcode;
-	}
-
-	/*Attach buffer pool to the network interface as described by the user*/
-	memset(&bpool_cfg, 0, sizeof(struct dpni_pools_cfg));
-	bpool_cfg.num_dpbp = 1;
-	bpool_cfg.pools[0].dpbp_id = bp_list->buf_pool.dpbp_node->dpbp_id;
-	bpool_cfg.pools[0].backup_pool = 0;
-	bpool_cfg.pools[0].buffer_size = RTE_ALIGN_CEIL(bp_list->buf_pool.size,
-						DPAA2_PACKET_LAYOUT_ALIGN);
-	bpool_cfg.pools[0].priority_mask = 0;
-
-	retcode = dpni_set_pools(dpni, CMD_PRI_LOW, priv->token, &bpool_cfg);
-	if (retcode != 0) {
-		DPAA2_PMD_ERR("Error configuring buffer pool on interface."
-			      " bpid = %d error code = %d",
-			      bpool_cfg.pools[0].dpbp_id, retcode);
-		return retcode;
-	}
-
-	priv->bp_list = bp_list;
-	return 0;
-}
drivers/net/dpaa2/dpaa2_ethdev.c +308 -91

530 lines not on this page · raw message

drivers/net/dpaa2/dpaa2_ethdev.h +325 -157

582 lines not on this page · raw message

drivers/net/dpaa2/dpaa2_flow.c +3485 -2954

1,342 lines not on this page · raw message

drivers/net/dpaa2/meson.build +1 -2
index 4f774f7c82..3f8bee9146 100644

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

Signature · 1 line
2.43.0

Part of the diff is not shown here. View the raw message.

#91 lore raw

PATCH v2 37/47 net/dpaa2: support GENEVE flow item

In reply to Prashant Gupta

From: Hemant Agrawal <[email protected]>

Add GENEVE flow item support to the dpaa2 flow engine. The GENEVE protocol and VNI fields are matched through the soft parser, so the item is only accepted when the soft parser is loaded.

---
 drivers/net/dpaa2/dpaa2_flow.c | 102 ++++++++++++++++++++++++++++++++-
 1 file changed, 101 insertions(+), 1 deletion(-)
drivers/net/dpaa2/dpaa2_flow.c +101 -1
index e52b796a64..f86e1c0acc 100644
@@ -140,7 +140,8 @@ enum rte_flow_item_type dpaa2_hp_supported_pattern_type[] = {
 
 static const
 enum rte_flow_item_type dpaa2_sp_supported_pattern_type[] = {
-	RTE_FLOW_ITEM_TYPE_ECPRI
+	RTE_FLOW_ITEM_TYPE_ECPRI,
+	RTE_FLOW_ITEM_TYPE_GENEVE
 };
 
 static const enum rte_flow_action_type dpaa2_supported_fs_action_type[] = {
@@ -248,6 +249,10 @@ static const struct rte_flow_item_vxlan dpaa2_flow_item_vxlan_mask = {
 	.vni = {0xff, 0xff, 0xff},
 };
 
+static const struct rte_flow_item_geneve dpaa2_flow_item_geneve_mask = {
+	.protocol = RTE_BE16(0xffff),
+	.vni = {0xff, 0xff, 0xff},
+};
 
 static const struct rte_flow_item_ecpri dpaa2_flow_item_ecpri_mask = {
 	.hdr.common.type = 0xff,
@@ -1573,6 +1578,10 @@ dpaa2_flow_extract_support(const uint8_t *mask_src,
 		mask_support = (const char *)&dpaa2_flow_item_gtp_mask;
 		size = sizeof(struct rte_flow_item_gtp);
 		break;
+	case RTE_FLOW_ITEM_TYPE_GENEVE:
+		mask_support = (const char *)&dpaa2_flow_item_geneve_mask;
+		size = sizeof(struct rte_flow_item_geneve);
+		break;
 	default:
 		return -EINVAL;
 	}
@@ -3371,6 +3380,89 @@ dpaa2_flow_raw_extract_rule_set(struct dpaa2_generic_flow *flow,
 	return 0;
 }
 
+static int
+dpaa2_flow_geneve_extract_rule_set(struct dpaa2_generic_flow *flow,
+	const struct rte_flow_attr *attr,
+	const struct rte_dpaa2_flow_item *dpaa2_pattern,
+	int *extract_cfg, enum dpaa2_flow_dist_type dist_type)
+{
+	int ret, local_cfg = 0;
+	uint32_t bit_offset;
+	const struct rte_flow_item_geneve *spec, *mask;
+	struct dpaa2_dev_priv *priv = flow->priv;
+	const struct rte_flow_item *pattern = &dpaa2_pattern->generic_item;
+	char hex_dump[DPAA2_FLOW_HDR_HEX_DUMP_SIZE];
+
+	if (!priv->sp_protocol) {
+		DPAA2_PMD_ERR("GENEVE flow is not supported without SP.");
+		return -ENOTSUP;
+	}
+
+	/* Parse pattern list to get the matching parameters */
+	spec = pattern->spec;
+	mask = pattern->mask ?
+		pattern->mask : &dpaa2_flow_item_geneve_mask;
+
+	if (dpaa2_pattern->in_tunnel) {
+		DPAA2_PMD_ERR("Tunnel-GENEVE distribution not support");
+		return -ENOTSUP;
+	}
+
+	ret = dpaa2_protocol_psr_bit_offset(&bit_offset,
+		DPAA2_PARSER_GENEVE_ID);
+	if (ret)
+		return ret;
+
+	ret = dpaa2_flow_identify_by_faf(priv, flow,
+		bit_offset, dist_type, attr->group, &local_cfg);
+	if (ret)
+		return ret;
+
+	if (!spec)
+		goto quit;
+
+	ret = dpaa2_flow_extract_support((const uint8_t *)mask,
+		RTE_FLOW_ITEM_TYPE_GENEVE);
+	if (ret) {
+		dpaa2_flow_hdr_hexdump(hex_dump, sizeof(hex_dump), (const uint8_t *)mask,
+			sizeof(struct rte_flow_item_geneve));
+		DPAA2_PMD_ERR("Extract GENEVE(%s) failed(%d)",
+			hex_dump, ret);
+
+		return ret;
+	}
+
+	if (mask->protocol && mask->protocol != 0xffff) {
+		DPAA2_PMD_ERR("Not support to extract geneve protocol.");
+		return -EINVAL;
+	}
+
+	if (mask->protocol) {
+		ret = dpaa2_flow_add_pr_extract_rule(flow,
+			DPAA2_GENEVE_PROTOCOL_OFFSET,
+			sizeof(mask->protocol), &spec->protocol,
+			&mask->protocol, priv, attr->group, &local_cfg,
+			dist_type);
+		if (ret)
+			return ret;
+	}
+
+	if (mask->vni[0] || mask->vni[1] || mask->vni[2]) {
+		ret = dpaa2_flow_add_pr_extract_rule(flow,
+			DPAA2_GENEVE_VNI_OFFSET,
+			sizeof(mask->vni), spec->vni,
+			mask->vni,
+			priv, attr->group, &local_cfg, dist_type);
+		if (ret)
+			return ret;
+	}
+
+quit:
+	if (extract_cfg)
+		(*extract_cfg) |= local_cfg;
+
+	return 0;
+}
 
 static inline int
 dpaa2_flow_verify_entry(struct dpaa2_dev_priv *priv,
@@ -4236,6 +4328,14 @@ dpaa2_flow_generic_extract_rule_set(struct dpaa2_generic_flow *flow,
 				goto end_extract_set;
 			}
 			break;
+		case RTE_FLOW_ITEM_TYPE_GENEVE:
+			ret = dpaa2_flow_geneve_extract_rule_set(flow, attr,
+				&dpaa2_pattern[i], &extract_cfg, dist_type);
+			if (ret) {
+				DPAA2_PMD_ERR("GENEVE flow config failed!");
+				goto end_extract_set;
+			}
+			break;
 		case RTE_FLOW_ITEM_TYPE_RAW:
 			ret = dpaa2_flow_raw_extract_rule_set(flow, attr,
 				&dpaa2_pattern[i], &extract_cfg, dist_type);
Signature · 1 line
2.43.0