net/ixgbe: fix unexpected data in the xstats info

Message ID 20250610054225.988840-1-kaiwenx.deng@intel.com (mailing list archive)
State Accepted
Delegated to: Bruce Richardson
Headers
Series net/ixgbe: fix unexpected data in the xstats info |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/loongarch-compilation success Compilation OK
ci/loongarch-unit-testing success Unit Testing PASS
ci/Intel-compilation success Compilation OK
ci/github-robot: build success github build: passed
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-unit-amd64-testing success Testing PASS
ci/iol-abi-testing success Testing PASS
ci/iol-compile-arm64-testing pending Testing pending
ci/iol-compile-amd64-testing warning Testing issues
ci/aws-unit-testing success Unit Testing PASS
ci/iol-broadcom-Performance success Performance Testing PASS
ci/iol-sample-apps-testing success Testing PASS
ci/iol-unit-arm64-testing success Testing PASS

Commit Message

Kaiwen Deng June 10, 2025, 5:42 a.m. UTC
E610 device does not support MACsec.

This commit will excluding MACsec stats from the xstats info
display for E610 device.

Fixes: b35d309710fe ("net/ixgbe: add MACsec offload")
Cc: stable@dpdk.org

Signed-off-by: Kaiwen Deng <kaiwenx.deng@intel.com>
---
 drivers/net/intel/ixgbe/ixgbe_ethdev.c | 121 ++++++++++++++-----------
 1 file changed, 67 insertions(+), 54 deletions(-)
  

Comments

Bruce Richardson June 10, 2025, 11:12 a.m. UTC | #1
On Tue, Jun 10, 2025 at 01:42:25PM +0800, Kaiwen Deng wrote:
> E610 device does not support MACsec.
> 
> This commit will excluding MACsec stats from the xstats info
> display for E610 device.
> 
> Fixes: b35d309710fe ("net/ixgbe: add MACsec offload")
> Cc: stable@dpdk.org
> 

Since E610 wasn't around when the MACsec stats support was added, I think
a better commit to identify is '316637762a5f ("net/ixgbe/base: enable E610 device")'
since that is where we should have put in these workarounds originally.


> Signed-off-by: Kaiwen Deng <kaiwenx.deng@intel.com>
Acked-by: Bruce Richardson <bruce.richardson@intel.com>
  
Bruce Richardson June 10, 2025, 11:15 a.m. UTC | #2
On Tue, Jun 10, 2025 at 12:12:29PM +0100, Bruce Richardson wrote:
> On Tue, Jun 10, 2025 at 01:42:25PM +0800, Kaiwen Deng wrote:
> > E610 device does not support MACsec.
> > 
> > This commit will excluding MACsec stats from the xstats info
> > display for E610 device.
> > 
> > Fixes: b35d309710fe ("net/ixgbe: add MACsec offload")
> > Cc: stable@dpdk.org
> > 
> 
> Since E610 wasn't around when the MACsec stats support was added, I think
> a better commit to identify is '316637762a5f ("net/ixgbe/base: enable E610 device")'
> since that is where we should have put in these workarounds originally.
> 
> 
> > Signed-off-by: Kaiwen Deng <kaiwenx.deng@intel.com>
> Acked-by: Bruce Richardson <bruce.richardson@intel.com>
> 
>
Applied to dpdk-next-net-intel

Thanks,
/Bruce
  

Patch

diff --git a/drivers/net/intel/ixgbe/ixgbe_ethdev.c b/drivers/net/intel/ixgbe/ixgbe_ethdev.c
index 0fa4898aba..130a23cd9d 100644
--- a/drivers/net/intel/ixgbe/ixgbe_ethdev.c
+++ b/drivers/net/intel/ixgbe/ixgbe_ethdev.c
@@ -3354,38 +3354,40 @@  ixgbe_read_stats_registers(struct ixgbe_hw *hw,
 					IXGBE_FDIRFSTAT) >> 16) & 0xFFFF;
 	}
 	/* MACsec Stats registers */
-	macsec_stats->out_pkts_untagged += IXGBE_READ_REG(hw, IXGBE_LSECTXUT);
-	macsec_stats->out_pkts_encrypted +=
-		IXGBE_READ_REG(hw, IXGBE_LSECTXPKTE);
-	macsec_stats->out_pkts_protected +=
-		IXGBE_READ_REG(hw, IXGBE_LSECTXPKTP);
-	macsec_stats->out_octets_encrypted +=
-		IXGBE_READ_REG(hw, IXGBE_LSECTXOCTE);
-	macsec_stats->out_octets_protected +=
-		IXGBE_READ_REG(hw, IXGBE_LSECTXOCTP);
-	macsec_stats->in_pkts_untagged += IXGBE_READ_REG(hw, IXGBE_LSECRXUT);
-	macsec_stats->in_pkts_badtag += IXGBE_READ_REG(hw, IXGBE_LSECRXBAD);
-	macsec_stats->in_pkts_nosci += IXGBE_READ_REG(hw, IXGBE_LSECRXNOSCI);
-	macsec_stats->in_pkts_unknownsci +=
-		IXGBE_READ_REG(hw, IXGBE_LSECRXUNSCI);
-	macsec_stats->in_octets_decrypted +=
-		IXGBE_READ_REG(hw, IXGBE_LSECRXOCTD);
-	macsec_stats->in_octets_validated +=
-		IXGBE_READ_REG(hw, IXGBE_LSECRXOCTV);
-	macsec_stats->in_pkts_unchecked += IXGBE_READ_REG(hw, IXGBE_LSECRXUNCH);
-	macsec_stats->in_pkts_delayed += IXGBE_READ_REG(hw, IXGBE_LSECRXDELAY);
-	macsec_stats->in_pkts_late += IXGBE_READ_REG(hw, IXGBE_LSECRXLATE);
-	for (i = 0; i < 2; i++) {
-		macsec_stats->in_pkts_ok +=
-			IXGBE_READ_REG(hw, IXGBE_LSECRXOK(i));
-		macsec_stats->in_pkts_invalid +=
-			IXGBE_READ_REG(hw, IXGBE_LSECRXINV(i));
-		macsec_stats->in_pkts_notvalid +=
-			IXGBE_READ_REG(hw, IXGBE_LSECRXNV(i));
-	}
-	macsec_stats->in_pkts_unusedsa += IXGBE_READ_REG(hw, IXGBE_LSECRXUNSA);
-	macsec_stats->in_pkts_notusingsa +=
-		IXGBE_READ_REG(hw, IXGBE_LSECRXNUSA);
+	if (hw->mac.type != ixgbe_mac_E610) {
+		macsec_stats->out_pkts_untagged += IXGBE_READ_REG(hw, IXGBE_LSECTXUT);
+		macsec_stats->out_pkts_encrypted +=
+			IXGBE_READ_REG(hw, IXGBE_LSECTXPKTE);
+		macsec_stats->out_pkts_protected +=
+			IXGBE_READ_REG(hw, IXGBE_LSECTXPKTP);
+		macsec_stats->out_octets_encrypted +=
+			IXGBE_READ_REG(hw, IXGBE_LSECTXOCTE);
+		macsec_stats->out_octets_protected +=
+			IXGBE_READ_REG(hw, IXGBE_LSECTXOCTP);
+		macsec_stats->in_pkts_untagged += IXGBE_READ_REG(hw, IXGBE_LSECRXUT);
+		macsec_stats->in_pkts_badtag += IXGBE_READ_REG(hw, IXGBE_LSECRXBAD);
+		macsec_stats->in_pkts_nosci += IXGBE_READ_REG(hw, IXGBE_LSECRXNOSCI);
+		macsec_stats->in_pkts_unknownsci +=
+			IXGBE_READ_REG(hw, IXGBE_LSECRXUNSCI);
+		macsec_stats->in_octets_decrypted +=
+			IXGBE_READ_REG(hw, IXGBE_LSECRXOCTD);
+		macsec_stats->in_octets_validated +=
+			IXGBE_READ_REG(hw, IXGBE_LSECRXOCTV);
+		macsec_stats->in_pkts_unchecked += IXGBE_READ_REG(hw, IXGBE_LSECRXUNCH);
+		macsec_stats->in_pkts_delayed += IXGBE_READ_REG(hw, IXGBE_LSECRXDELAY);
+		macsec_stats->in_pkts_late += IXGBE_READ_REG(hw, IXGBE_LSECRXLATE);
+		for (i = 0; i < 2; i++) {
+			macsec_stats->in_pkts_ok +=
+				IXGBE_READ_REG(hw, IXGBE_LSECRXOK(i));
+			macsec_stats->in_pkts_invalid +=
+				IXGBE_READ_REG(hw, IXGBE_LSECRXINV(i));
+			macsec_stats->in_pkts_notvalid +=
+				IXGBE_READ_REG(hw, IXGBE_LSECRXNV(i));
+		}
+		macsec_stats->in_pkts_unusedsa += IXGBE_READ_REG(hw, IXGBE_LSECRXUNSA);
+		macsec_stats->in_pkts_notusingsa +=
+			IXGBE_READ_REG(hw, IXGBE_LSECRXNUSA);
+	}
 }
 
 /*
@@ -3478,15 +3480,19 @@  ixgbe_dev_stats_reset(struct rte_eth_dev *dev)
 	(IXGBE_NB_TXQ_PRIO_STATS * IXGBE_NB_TXQ_PRIO_VALUES))
 
 static unsigned
-ixgbe_xstats_calc_num(void)
+ixgbe_xstats_calc_num(struct rte_eth_dev *dev)
 {
+	struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	if (hw->mac.type == ixgbe_mac_E610)
+		return IXGBE_XSTATS_CALC_NUM - IXGBE_NB_MACSEC_STATS;
 	return IXGBE_XSTATS_CALC_NUM;
 }
 
-static int ixgbe_dev_xstats_get_names(__rte_unused struct rte_eth_dev *dev,
+static int ixgbe_dev_xstats_get_names(struct rte_eth_dev *dev,
 	struct rte_eth_xstat_name *xstats_names, __rte_unused unsigned int size)
 {
-	const unsigned cnt_stats = ixgbe_xstats_calc_num();
+	struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	const unsigned int cnt_stats = ixgbe_xstats_calc_num(dev);
 	unsigned stat, i, count;
 
 	if (xstats_names != NULL) {
@@ -3505,11 +3511,13 @@  static int ixgbe_dev_xstats_get_names(__rte_unused struct rte_eth_dev *dev,
 		}
 
 		/* MACsec Stats */
-		for (i = 0; i < IXGBE_NB_MACSEC_STATS; i++) {
-			strlcpy(xstats_names[count].name,
-				rte_ixgbe_macsec_strings[i].name,
-				sizeof(xstats_names[count].name));
-			count++;
+		if (hw->mac.type != ixgbe_mac_E610) {
+			for (i = 0; i < IXGBE_NB_MACSEC_STATS; i++) {
+				strlcpy(xstats_names[count].name,
+					rte_ixgbe_macsec_strings[i].name,
+					sizeof(xstats_names[count].name));
+				count++;
+			}
 		}
 
 		/* RX Priority Stats */
@@ -3544,7 +3552,8 @@  static int ixgbe_dev_xstats_get_names_by_id(
 	unsigned int limit)
 {
 	if (!ids) {
-		const unsigned int cnt_stats = ixgbe_xstats_calc_num();
+		struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+		const unsigned int cnt_stats = ixgbe_xstats_calc_num(dev);
 		unsigned int stat, i, count;
 
 		if (xstats_names != NULL) {
@@ -3563,11 +3572,13 @@  static int ixgbe_dev_xstats_get_names_by_id(
 			}
 
 			/* MACsec Stats */
-			for (i = 0; i < IXGBE_NB_MACSEC_STATS; i++) {
-				strlcpy(xstats_names[count].name,
-					rte_ixgbe_macsec_strings[i].name,
-					sizeof(xstats_names[count].name));
-				count++;
+			if (hw->mac.type != ixgbe_mac_E610) {
+				for (i = 0; i < IXGBE_NB_MACSEC_STATS; i++) {
+					strlcpy(xstats_names[count].name,
+						rte_ixgbe_macsec_strings[i].name,
+						sizeof(xstats_names[count].name));
+					count++;
+				}
 			}
 
 			/* RX Priority Stats */
@@ -3643,7 +3654,7 @@  ixgbe_dev_xstats_get(struct rte_eth_dev *dev, struct rte_eth_xstat *xstats,
 	uint64_t total_missed_rx, total_qbrc, total_qprc, total_qprdc;
 	unsigned i, stat, count = 0;
 
-	count = ixgbe_xstats_calc_num();
+	count = ixgbe_xstats_calc_num(dev);
 
 	if (n < count)
 		return count;
@@ -3672,11 +3683,13 @@  ixgbe_dev_xstats_get(struct rte_eth_dev *dev, struct rte_eth_xstat *xstats,
 	}
 
 	/* MACsec Stats */
-	for (i = 0; i < IXGBE_NB_MACSEC_STATS; i++) {
-		xstats[count].value = *(uint64_t *)(((char *)macsec_stats) +
-				rte_ixgbe_macsec_strings[i].offset);
-		xstats[count].id = count;
-		count++;
+	if (hw->mac.type != ixgbe_mac_E610) {
+		for (i = 0; i < IXGBE_NB_MACSEC_STATS; i++) {
+			xstats[count].value = *(uint64_t *)(((char *)macsec_stats) +
+					rte_ixgbe_macsec_strings[i].offset);
+			xstats[count].id = count;
+			count++;
+		}
 	}
 
 	/* RX Priority Stats */
@@ -3719,7 +3732,7 @@  ixgbe_dev_xstats_get_by_id(struct rte_eth_dev *dev, const uint64_t *ids,
 		uint64_t total_missed_rx, total_qbrc, total_qprc, total_qprdc;
 		unsigned int i, stat, count = 0;
 
-		count = ixgbe_xstats_calc_num();
+		count = ixgbe_xstats_calc_num(dev);
 
 		if (!ids && n < count)
 			return count;
@@ -3803,7 +3816,7 @@  ixgbe_dev_xstats_reset(struct rte_eth_dev *dev)
 			IXGBE_DEV_PRIVATE_TO_MACSEC_STATS(
 				dev->data->dev_private);
 
-	unsigned count = ixgbe_xstats_calc_num();
+	unsigned int count = ixgbe_xstats_calc_num(dev);
 
 	/* HW registers are cleared on read */
 	ixgbe_dev_xstats_get(dev, NULL, count);