net/cnxk: restore MAC address table during port reset

Message ID 20250409061152.1096849-1-skori@marvell.com (mailing list archive)
State New
Delegated to: Jerin Jacob
Headers
Series net/cnxk: restore MAC address table during port reset |

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/intel-Testing success Testing PASS
ci/intel-Functional success Functional PASS
ci/github-robot: build success github build: passed
ci/iol-marvell-Functional success Functional Testing PASS
ci/iol-broadcom-Performance success Performance Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-unit-arm64-testing success Testing PASS
ci/iol-abi-testing success Testing PASS
ci/iol-compile-arm64-testing success Testing PASS
ci/iol-compile-amd64-testing success Testing PASS
ci/iol-unit-amd64-testing success Testing PASS
ci/iol-sample-apps-testing success Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-mellanox-Functional success Functional Testing PASS

Commit Message

Sunil Kumar Kori April 9, 2025, 6:11 a.m. UTC
From: Sunil Kumar Kori <skori@marvell.com>

When user requests to configure a device which is already in
configured state then first device gets resets to default and
then reconfigured with latest parameters.

While resetting the device, MAC address table is left stale which
causes entry update in later state.

Hence same is restoring during reset operation to avoid any error
due to further operation on MAC table.

Fixes: b75e0aca84b0 ("net/cnxk: add device configuration operation")
Cc: stable@dpdk.org

Signed-off-by: Sunil Kumar Kori <skori@marvell.com>
---
 drivers/net/cnxk/cnxk_ethdev.c | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)
  

Patch

diff --git a/drivers/net/cnxk/cnxk_ethdev.c b/drivers/net/cnxk/cnxk_ethdev.c
index 289ae96afa..7e77fcba45 100644
--- a/drivers/net/cnxk/cnxk_ethdev.c
+++ b/drivers/net/cnxk/cnxk_ethdev.c
@@ -1209,6 +1209,26 @@  nix_lso_fmt_setup(struct cnxk_eth_dev *dev)
 	return nix_lso_tun_fmt_update(dev);
 }
 
+static int
+nix_restore_mac_table(struct rte_eth_dev *eth_dev)
+{
+	struct cnxk_eth_dev *dev = cnxk_eth_pmd_priv(eth_dev);
+	struct rte_ether_addr *macs = NULL;
+	struct roc_nix *nix = &dev->nix;
+	int i, rc;
+
+	macs = eth_dev->data->mac_addrs;
+	for (i = 1; i < dev->dmac_filter_count; i++) {
+		rc = roc_nix_mac_addr_add(nix, macs[i].addr_bytes);
+		if (rc < 0) {
+			plt_err("Failed to restore mac addr table, rc=%d", rc);
+			return rc;
+		}
+	}
+
+	return 0;
+}
+
 int
 cnxk_nix_configure(struct rte_eth_dev *eth_dev)
 {
@@ -1507,6 +1527,10 @@  cnxk_nix_configure(struct rte_eth_dev *eth_dev)
 		rc = nix_restore_queue_cfg(eth_dev);
 		if (rc)
 			goto sec_release;
+
+		rc = nix_restore_mac_table(eth_dev);
+		if (rc)
+			goto sec_release;
 	}
 
 	/* Update the mac address */