DPDK patches and discussions
 help / color / mirror / Atom feed
From: Chaoyong He <chaoyong.he@corigine.com>
To: dev@dpdk.org
Cc: oss-drivers@corigine.com, Chaoyong He <chaoyong.he@corigine.com>,
	Long Wu <long.wu@corigine.com>,
	Peng Zhang <peng.zhang@corigine.com>
Subject: [PATCH v2 7/8] net/nfp: remove ethernet device data field
Date: Fri, 19 Apr 2024 13:23:48 +0800	[thread overview]
Message-ID: <20240419052349.1294696-8-chaoyong.he@corigine.com> (raw)
In-Reply-To: <20240419052349.1294696-1-chaoyong.he@corigine.com>

Remove the 'eth_dev' field in process shared data 'struct
nfp_net_hw', and modify the related logic.

Signed-off-by: Chaoyong He <chaoyong.he@corigine.com>
Reviewed-by: Long Wu <long.wu@corigine.com>
Reviewed-by: Peng Zhang <peng.zhang@corigine.com>
---
 drivers/net/nfp/flower/nfp_flower.c           | 16 ++--
 drivers/net/nfp/flower/nfp_flower.h           |  2 +
 drivers/net/nfp/flower/nfp_flower_ctrl.c      |  8 +-
 drivers/net/nfp/flower/nfp_flower_flow.c      | 16 ++--
 .../net/nfp/flower/nfp_flower_representor.c   | 76 +++++++++----------
 .../net/nfp/flower/nfp_flower_representor.h   |  1 -
 drivers/net/nfp/nfp_ethdev.c                  | 36 ++++-----
 drivers/net/nfp/nfp_net_common.h              |  3 -
 8 files changed, 78 insertions(+), 80 deletions(-)

diff --git a/drivers/net/nfp/flower/nfp_flower.c b/drivers/net/nfp/flower/nfp_flower.c
index 83249feedb..76e5d674f1 100644
--- a/drivers/net/nfp/flower/nfp_flower.c
+++ b/drivers/net/nfp/flower/nfp_flower.c
@@ -271,15 +271,15 @@ nfp_flower_init_ctrl_vnic(struct nfp_app_fw_flower *app_fw_flower,
 	}
 
 	/* Allocate memory for the eth_dev of the vNIC */
-	hw->eth_dev = rte_zmalloc("nfp_ctrl_vnic",
+	app_fw_flower->ctrl_ethdev = rte_zmalloc("nfp_ctrl_vnic",
 			sizeof(struct rte_eth_dev), RTE_CACHE_LINE_SIZE);
-	if (hw->eth_dev == NULL) {
+	if (app_fw_flower->ctrl_ethdev == NULL) {
 		PMD_INIT_LOG(ERR, "Could not allocate ctrl vnic");
 		return -ENOMEM;
 	}
 
 	/* Grab the pointer to the newly created rte_eth_dev here */
-	eth_dev = hw->eth_dev;
+	eth_dev = app_fw_flower->ctrl_ethdev;
 
 	/* Also allocate memory for the data part of the eth_dev */
 	eth_dev->data = rte_zmalloc("nfp_ctrl_vnic_data",
@@ -529,7 +529,7 @@ nfp_flower_cleanup_ctrl_vnic(struct nfp_app_fw_flower *app_fw_flower,
 	char ctrl_rxring_name[RTE_MEMZONE_NAMESIZE];
 
 	hw = app_fw_flower->ctrl_hw;
-	eth_dev = hw->eth_dev;
+	eth_dev = app_fw_flower->ctrl_ethdev;
 
 	pci_name = strchr(hw_priv->pf_dev->pci_dev->name, ':') + 1;
 
@@ -562,15 +562,17 @@ nfp_flower_cleanup_ctrl_vnic(struct nfp_app_fw_flower *app_fw_flower,
 }
 
 static int
-nfp_flower_start_ctrl_vnic(struct nfp_net_hw *net_hw)
+nfp_flower_start_ctrl_vnic(struct nfp_app_fw_flower *app_fw_flower)
 {
 	int ret;
 	uint32_t update;
 	uint32_t new_ctrl;
 	struct nfp_hw *hw;
 	struct rte_eth_dev *dev;
+	struct nfp_net_hw *net_hw;
 
-	dev = net_hw->eth_dev;
+	net_hw = app_fw_flower->ctrl_hw;
+	dev = app_fw_flower->ctrl_ethdev;
 	hw = &net_hw->super;
 
 	/* Disabling queues just in case... */
@@ -736,7 +738,7 @@ nfp_init_app_fw_flower(struct nfp_net_hw_priv *hw_priv)
 	}
 
 	/* Start the ctrl vNIC */
-	ret = nfp_flower_start_ctrl_vnic(app_fw_flower->ctrl_hw);
+	ret = nfp_flower_start_ctrl_vnic(app_fw_flower);
 	if (ret != 0) {
 		PMD_INIT_LOG(ERR, "Could not start flower ctrl vNIC");
 		goto ctrl_vnic_cleanup;
diff --git a/drivers/net/nfp/flower/nfp_flower.h b/drivers/net/nfp/flower/nfp_flower.h
index 5c2f338a20..ae80782df4 100644
--- a/drivers/net/nfp/flower/nfp_flower.h
+++ b/drivers/net/nfp/flower/nfp_flower.h
@@ -63,12 +63,14 @@ struct nfp_app_fw_flower {
 
 	/** Pointer to the PF vNIC */
 	struct nfp_net_hw *pf_hw;
+	struct rte_eth_dev *pf_ethdev;
 
 	/** Pointer to a mempool for the Ctrl vNIC */
 	struct rte_mempool *ctrl_pktmbuf_pool;
 
 	/** Pointer to the ctrl vNIC */
 	struct nfp_net_hw *ctrl_hw;
+	struct rte_eth_dev *ctrl_ethdev;
 
 	/** Ctrl vNIC Rx counter */
 	uint64_t ctrl_vnic_rx_count;
diff --git a/drivers/net/nfp/flower/nfp_flower_ctrl.c b/drivers/net/nfp/flower/nfp_flower_ctrl.c
index 4c2aeb9849..de6e419cac 100644
--- a/drivers/net/nfp/flower/nfp_flower_ctrl.c
+++ b/drivers/net/nfp/flower/nfp_flower_ctrl.c
@@ -153,12 +153,10 @@ nfp_flower_ctrl_vnic_nfd3_xmit(struct nfp_app_fw_flower *app_fw_flower,
 	uint32_t free_descs;
 	struct rte_mbuf **lmbuf;
 	struct nfp_net_txq *txq;
-	struct nfp_net_hw *ctrl_hw;
 	struct rte_eth_dev *ctrl_dev;
 	struct nfp_net_nfd3_tx_desc *txds;
 
-	ctrl_hw = app_fw_flower->ctrl_hw;
-	ctrl_dev = ctrl_hw->eth_dev;
+	ctrl_dev = app_fw_flower->ctrl_ethdev;
 
 	/* Flower ctrl vNIC only has a single tx queue */
 	txq = ctrl_dev->data->tx_queues[0];
@@ -232,7 +230,7 @@ nfp_flower_ctrl_vnic_nfdk_xmit(struct nfp_app_fw_flower *app_fw_flower,
 	struct rte_eth_dev *ctrl_dev;
 	struct nfp_net_nfdk_tx_desc *ktxds;
 
-	ctrl_dev = app_fw_flower->ctrl_hw->eth_dev;
+	ctrl_dev = app_fw_flower->ctrl_ethdev;
 
 	/* Flower ctrl vNIC only has a single tx queue */
 	txq = ctrl_dev->data->tx_queues[0];
@@ -511,7 +509,7 @@ nfp_flower_ctrl_vnic_process(struct nfp_app_fw_flower *app_fw_flower)
 	struct rte_eth_dev *ctrl_eth_dev;
 	struct rte_mbuf *pkts_burst[MAX_PKT_BURST];
 
-	ctrl_eth_dev = app_fw_flower->ctrl_hw->eth_dev;
+	ctrl_eth_dev = app_fw_flower->ctrl_ethdev;
 
 	/* Ctrl vNIC only has a single Rx queue */
 	rxq = ctrl_eth_dev->data->rx_queues[0];
diff --git a/drivers/net/nfp/flower/nfp_flower_flow.c b/drivers/net/nfp/flower/nfp_flower_flow.c
index 086cc8079a..8ff13923e5 100644
--- a/drivers/net/nfp/flower/nfp_flower_flow.c
+++ b/drivers/net/nfp/flower/nfp_flower_flow.c
@@ -3518,7 +3518,7 @@ nfp_flow_action_rss_add(struct nfp_flower_representor *representor,
 		struct nfp_fl_rss **rss_store)
 {
 	int ret;
-	struct nfp_net_hw *pf_hw;
+	struct rte_eth_dev *eth_dev;
 	struct rte_eth_rss_conf rss_conf;
 	struct nfp_fl_rss *rss_store_tmp;
 	const struct rte_flow_action_rss *rss;
@@ -3536,8 +3536,8 @@ nfp_flow_action_rss_add(struct nfp_flower_representor *representor,
 
 	rss_conf.rss_hf = 0;
 	rss_conf.rss_key = rss_key;
-	pf_hw = representor->app_fw_flower->pf_hw;
-	ret = nfp_net_rss_hash_conf_get(pf_hw->eth_dev, &rss_conf);
+	eth_dev = representor->app_fw_flower->pf_ethdev;
+	ret = nfp_net_rss_hash_conf_get(eth_dev, &rss_conf);
 	if (ret != 0) {
 		PMD_DRV_LOG(ERR, "Get RSS conf failed.");
 		return ret;
@@ -3563,7 +3563,7 @@ nfp_flow_action_rss_add(struct nfp_flower_representor *representor,
 		rss_store_tmp->key_len = rss->key_len;
 	}
 
-	ret = nfp_net_rss_hash_update(pf_hw->eth_dev, &rss_conf);
+	ret = nfp_net_rss_hash_update(eth_dev, &rss_conf);
 	if (ret != 0) {
 		PMD_DRV_LOG(ERR, "Update RSS conf failed.");
 		free(rss_store_tmp);
@@ -3580,7 +3580,7 @@ nfp_flow_action_rss_del(struct nfp_flower_representor *representor,
 		struct rte_flow *nfp_flow)
 {
 	int ret;
-	struct nfp_net_hw *pf_hw;
+	struct rte_eth_dev *eth_dev;
 	struct nfp_fl_rss *rss_store;
 	struct rte_eth_rss_conf rss_conf;
 	uint8_t rss_key[NFP_NET_CFG_RSS_KEY_SZ];
@@ -3590,8 +3590,8 @@ nfp_flow_action_rss_del(struct nfp_flower_representor *representor,
 
 	rss_conf.rss_hf = 0;
 	rss_conf.rss_key = rss_key;
-	pf_hw = representor->app_fw_flower->pf_hw;
-	ret = nfp_net_rss_hash_conf_get(pf_hw->eth_dev, &rss_conf);
+	eth_dev = representor->app_fw_flower->pf_ethdev;
+	ret = nfp_net_rss_hash_conf_get(eth_dev, &rss_conf);
 	if (ret != 0) {
 		PMD_DRV_LOG(ERR, "Get RSS conf failed.");
 		goto exit;
@@ -3612,7 +3612,7 @@ nfp_flow_action_rss_del(struct nfp_flower_representor *representor,
 		rss_conf.rss_key_len = 0;
 	}
 
-	ret = nfp_net_rss_hash_update(pf_hw->eth_dev, &rss_conf);
+	ret = nfp_net_rss_hash_update(eth_dev, &rss_conf);
 	if (ret != 0)
 		PMD_DRV_LOG(ERR, "Update RSS conf failed.");
 
diff --git a/drivers/net/nfp/flower/nfp_flower_representor.c b/drivers/net/nfp/flower/nfp_flower_representor.c
index 0e19723f57..60f02ad919 100644
--- a/drivers/net/nfp/flower/nfp_flower_representor.c
+++ b/drivers/net/nfp/flower/nfp_flower_representor.c
@@ -270,7 +270,6 @@ nfp_flower_repr_tx_burst(void *tx_queue,
 	uint16_t sent;
 	void *pf_tx_queue;
 	struct nfp_net_txq *txq;
-	struct nfp_net_hw *pf_hw;
 	struct rte_eth_dev *dev;
 	struct rte_eth_dev *repr_dev;
 	struct nfp_flower_representor *repr;
@@ -290,8 +289,7 @@ nfp_flower_repr_tx_burst(void *tx_queue,
 				tx_pkts[i], repr->port_id);
 
 	/* This points to the PF vNIC that owns this representor */
-	pf_hw = txq->hw;
-	dev = pf_hw->eth_dev;
+	dev = repr->app_fw_flower->pf_ethdev;
 
 	/* Only using Tx queue 0 for now. */
 	pf_tx_queue = dev->data->tx_queues[0];
@@ -306,10 +304,9 @@ nfp_flower_repr_tx_burst(void *tx_queue,
 }
 
 static void
-nfp_flower_repr_free_queue(struct nfp_flower_representor *repr)
+nfp_flower_repr_free_queue(struct rte_eth_dev *eth_dev)
 {
 	uint16_t i;
-	struct rte_eth_dev *eth_dev = repr->eth_dev;
 
 	for (i = 0; i < eth_dev->data->nb_tx_queues; i++)
 		rte_free(eth_dev->data->tx_queues[i]);
@@ -319,10 +316,8 @@ nfp_flower_repr_free_queue(struct nfp_flower_representor *repr)
 }
 
 static void
-nfp_flower_pf_repr_close_queue(struct nfp_flower_representor *repr)
+nfp_flower_pf_repr_close_queue(struct rte_eth_dev *eth_dev)
 {
-	struct rte_eth_dev *eth_dev = repr->eth_dev;
-
 	/*
 	 * We assume that the DPDK application is stopping all the
 	 * threads/queues before calling the device close function.
@@ -335,17 +330,18 @@ nfp_flower_pf_repr_close_queue(struct nfp_flower_representor *repr)
 }
 
 static void
-nfp_flower_repr_close_queue(struct nfp_flower_representor *repr)
+nfp_flower_repr_close_queue(struct rte_eth_dev *eth_dev,
+		enum nfp_repr_type repr_type)
 {
-	switch (repr->repr_type) {
+	switch (repr_type) {
 	case NFP_REPR_TYPE_PHYS_PORT:
-		nfp_flower_repr_free_queue(repr);
+		nfp_flower_repr_free_queue(eth_dev);
 		break;
 	case NFP_REPR_TYPE_PF:
-		nfp_flower_pf_repr_close_queue(repr);
+		nfp_flower_pf_repr_close_queue(eth_dev);
 		break;
 	case NFP_REPR_TYPE_VF:
-		nfp_flower_repr_free_queue(repr);
+		nfp_flower_repr_free_queue(eth_dev);
 		break;
 	default:
 		PMD_DRV_LOG(ERR, "Unsupported repr port type.");
@@ -384,18 +380,18 @@ nfp_flower_pf_repr_uninit(struct rte_eth_dev *eth_dev)
 }
 
 static void
-nfp_flower_repr_free(struct nfp_flower_representor *repr,
+nfp_flower_repr_free(struct rte_eth_dev *eth_dev,
 		enum nfp_repr_type repr_type)
 {
 	switch (repr_type) {
 	case NFP_REPR_TYPE_PHYS_PORT:
-		nfp_flower_repr_uninit(repr->eth_dev);
+		nfp_flower_repr_uninit(eth_dev);
 		break;
 	case NFP_REPR_TYPE_PF:
-		nfp_flower_pf_repr_uninit(repr->eth_dev);
+		nfp_flower_pf_repr_uninit(eth_dev);
 		break;
 	case NFP_REPR_TYPE_VF:
-		nfp_flower_repr_uninit(repr->eth_dev);
+		nfp_flower_repr_uninit(eth_dev);
 		break;
 	default:
 		PMD_DRV_LOG(ERR, "Unsupported repr port type.");
@@ -425,9 +421,8 @@ nfp_flower_repr_dev_close(struct rte_eth_dev *dev)
 	if (pf_dev->app_fw_id != NFP_APP_FW_FLOWER_NIC)
 		return -EINVAL;
 
-	nfp_flower_repr_close_queue(repr);
-
-	nfp_flower_repr_free(repr, repr->repr_type);
+	nfp_flower_repr_close_queue(dev, repr->repr_type);
+	nfp_flower_repr_free(dev, repr->repr_type);
 
 	for (i = 0; i < MAX_FLOWER_VFS; i++) {
 		if (app_fw_flower->vf_reprs[i] != NULL)
@@ -575,8 +570,7 @@ nfp_flower_pf_repr_init(struct rte_eth_dev *eth_dev,
 	rte_ether_addr_copy(&init_repr_data->mac_addr, eth_dev->data->mac_addrs);
 
 	repr->app_fw_flower->pf_repr = repr;
-	repr->app_fw_flower->pf_hw->eth_dev = eth_dev;
-	repr->eth_dev = eth_dev;
+	repr->app_fw_flower->pf_ethdev = eth_dev;
 
 	return 0;
 }
@@ -668,8 +662,6 @@ nfp_flower_repr_init(struct rte_eth_dev *eth_dev,
 		app_fw_flower->vf_reprs[index] = repr;
 	}
 
-	repr->eth_dev = eth_dev;
-
 	return 0;
 
 mac_cleanup:
@@ -684,28 +676,38 @@ static void
 nfp_flower_repr_free_all(struct nfp_app_fw_flower *app_fw_flower)
 {
 	uint32_t i;
+	struct rte_eth_dev *eth_dev;
 	struct nfp_flower_representor *repr;
 
 	for (i = 0; i < MAX_FLOWER_VFS; i++) {
 		repr = app_fw_flower->vf_reprs[i];
 		if (repr != NULL) {
-			nfp_flower_repr_free(repr, NFP_REPR_TYPE_VF);
-			app_fw_flower->vf_reprs[i] = NULL;
+			eth_dev = rte_eth_dev_get_by_name(repr->name);
+			if (eth_dev != NULL) {
+				nfp_flower_repr_free(eth_dev, NFP_REPR_TYPE_VF);
+				app_fw_flower->vf_reprs[i] = NULL;
+			}
 		}
 	}
 
 	for (i = 0; i < NFP_MAX_PHYPORTS; i++) {
 		repr = app_fw_flower->phy_reprs[i];
 		if (repr != NULL) {
-			nfp_flower_repr_free(repr, NFP_REPR_TYPE_PHYS_PORT);
-			app_fw_flower->phy_reprs[i] = NULL;
+			eth_dev = rte_eth_dev_get_by_name(repr->name);
+			if (eth_dev != NULL) {
+				nfp_flower_repr_free(eth_dev, NFP_REPR_TYPE_PHYS_PORT);
+				app_fw_flower->phy_reprs[i] = NULL;
+			}
 		}
 	}
 
 	repr = app_fw_flower->pf_repr;
 	if (repr != NULL) {
-		nfp_flower_repr_free(repr, NFP_REPR_TYPE_PF);
-		app_fw_flower->pf_repr = NULL;
+		eth_dev = rte_eth_dev_get_by_name(repr->name);
+		if (eth_dev != NULL) {
+			nfp_flower_repr_free(eth_dev, NFP_REPR_TYPE_PF);
+			app_fw_flower->pf_repr = NULL;
+		}
 	}
 }
 
@@ -719,7 +721,7 @@ nfp_flower_repr_priv_init(struct nfp_app_fw_flower *app_fw_flower,
 
 	repr = app_fw_flower->pf_repr;
 	if (repr != NULL) {
-		eth_dev = repr->eth_dev;
+		eth_dev = rte_eth_dev_get_by_name(repr->name);
 		if (eth_dev != NULL)
 			eth_dev->process_private = hw_priv;
 	}
@@ -727,7 +729,7 @@ nfp_flower_repr_priv_init(struct nfp_app_fw_flower *app_fw_flower,
 	for (i = 0; i < NFP_MAX_PHYPORTS; i++) {
 		repr = app_fw_flower->phy_reprs[i];
 		if (repr != NULL) {
-			eth_dev = repr->eth_dev;
+			eth_dev = rte_eth_dev_get_by_name(repr->name);
 			if (eth_dev != NULL)
 				eth_dev->process_private = hw_priv;
 		}
@@ -736,7 +738,7 @@ nfp_flower_repr_priv_init(struct nfp_app_fw_flower *app_fw_flower,
 	for (i = 0; i < MAX_FLOWER_VFS; i++) {
 		repr = app_fw_flower->vf_reprs[i];
 		if (repr != NULL) {
-			eth_dev = repr->eth_dev;
+			eth_dev = rte_eth_dev_get_by_name(repr->name);
 			if (eth_dev != NULL)
 				eth_dev->process_private = hw_priv;
 		}
@@ -750,7 +752,6 @@ nfp_flower_repr_alloc(struct nfp_app_fw_flower *app_fw_flower,
 	int i;
 	int ret;
 	const char *pci_name;
-	struct rte_eth_dev *eth_dev;
 	struct rte_pci_device *pci_dev;
 	struct nfp_eth_table *nfp_eth_table;
 	struct nfp_eth_table_port *eth_port;
@@ -760,7 +761,6 @@ nfp_flower_repr_alloc(struct nfp_app_fw_flower *app_fw_flower,
 	};
 
 	nfp_eth_table = hw_priv->pf_dev->nfp_eth_table;
-	eth_dev = app_fw_flower->ctrl_hw->eth_dev;
 
 	/* Send a NFP_FLOWER_CMSG_TYPE_MAC_REPR cmsg to hardware */
 	ret = nfp_flower_cmsg_mac_repr(app_fw_flower, nfp_eth_table);
@@ -783,7 +783,7 @@ nfp_flower_repr_alloc(struct nfp_app_fw_flower *app_fw_flower,
 			"%s_repr_pf", pci_name);
 
 	/* Create a eth_dev for this representor */
-	ret = rte_eth_dev_create(eth_dev->device, flower_repr.name,
+	ret = rte_eth_dev_create(&pci_dev->device, flower_repr.name,
 			sizeof(struct nfp_flower_representor),
 			NULL, NULL, nfp_flower_pf_repr_init, &flower_repr);
 	if (ret != 0) {
@@ -808,7 +808,7 @@ nfp_flower_repr_alloc(struct nfp_app_fw_flower *app_fw_flower,
 		 * Create a eth_dev for this representor.
 		 * This will also allocate private memory for the device.
 		 */
-		ret = rte_eth_dev_create(eth_dev->device, flower_repr.name,
+		ret = rte_eth_dev_create(&pci_dev->device, flower_repr.name,
 				sizeof(struct nfp_flower_representor),
 				NULL, NULL, nfp_flower_repr_init, &flower_repr);
 		if (ret != 0) {
@@ -837,7 +837,7 @@ nfp_flower_repr_alloc(struct nfp_app_fw_flower *app_fw_flower,
 				"%s_repr_vf%d", pci_name, i);
 
 		/* This will also allocate private memory for the device */
-		ret = rte_eth_dev_create(eth_dev->device, flower_repr.name,
+		ret = rte_eth_dev_create(&pci_dev->device, flower_repr.name,
 				sizeof(struct nfp_flower_representor),
 				NULL, NULL, nfp_flower_repr_init, &flower_repr);
 		if (ret != 0) {
diff --git a/drivers/net/nfp/flower/nfp_flower_representor.h b/drivers/net/nfp/flower/nfp_flower_representor.h
index 41965f6e0e..d539e53b23 100644
--- a/drivers/net/nfp/flower/nfp_flower_representor.h
+++ b/drivers/net/nfp/flower/nfp_flower_representor.h
@@ -20,7 +20,6 @@ struct nfp_flower_representor {
 	struct rte_ring *ring;
 	struct rte_eth_link link;
 	struct rte_eth_stats repr_stats;
-	struct rte_eth_dev *eth_dev;
 };
 
 int nfp_flower_repr_create(struct nfp_app_fw_flower *app_fw_flower,
diff --git a/drivers/net/nfp/nfp_ethdev.c b/drivers/net/nfp/nfp_ethdev.c
index 258b617eb2..d450c9472e 100644
--- a/drivers/net/nfp/nfp_ethdev.c
+++ b/drivers/net/nfp/nfp_ethdev.c
@@ -100,15 +100,14 @@ nfp_devargs_parse(struct nfp_devargs *nfp_devargs_param,
 
 static void
 nfp_net_pf_read_mac(struct nfp_app_fw_nic *app_fw_nic,
-		uint16_t port)
+		uint16_t port,
+		struct nfp_net_hw_priv *hw_priv)
 {
 	struct nfp_net_hw *hw;
-	struct nfp_net_hw_priv *hw_priv;
 	struct nfp_eth_table *nfp_eth_table;
 
 	/* Grab a pointer to the correct physical port */
 	hw = app_fw_nic->ports[port];
-	hw_priv = hw->eth_dev->process_private;
 
 	nfp_eth_table = hw_priv->pf_dev->nfp_eth_table;
 
@@ -582,17 +581,14 @@ nfp_net_uninit(struct rte_eth_dev *eth_dev)
 
 static void
 nfp_cleanup_port_app_fw_nic(struct nfp_pf_dev *pf_dev,
-		uint8_t id)
+		uint8_t id,
+		struct rte_eth_dev *eth_dev)
 {
-	struct rte_eth_dev *eth_dev;
 	struct nfp_app_fw_nic *app_fw_nic;
 
 	app_fw_nic = pf_dev->app_fw_priv;
 	if (app_fw_nic->ports[id] != NULL) {
-		eth_dev = app_fw_nic->ports[id]->eth_dev;
-		if (eth_dev != NULL)
-			nfp_net_uninit(eth_dev);
-
+		nfp_net_uninit(eth_dev);
 		app_fw_nic->ports[id] = NULL;
 	}
 }
@@ -691,7 +687,7 @@ nfp_net_close(struct rte_eth_dev *dev)
 	if (pf_dev->app_fw_id != NFP_APP_FW_CORE_NIC)
 		return -EINVAL;
 
-	nfp_cleanup_port_app_fw_nic(pf_dev, hw->idx);
+	nfp_cleanup_port_app_fw_nic(pf_dev, hw->idx, dev);
 
 	for (i = 0; i < app_fw_nic->total_phyports; i++) {
 		id = nfp_function_id_get(pf_dev, i);
@@ -971,7 +967,6 @@ nfp_net_init(struct rte_eth_dev *eth_dev)
 
 	net_hw->tx_bar = pf_dev->qc_bar + tx_base * NFP_QCP_QUEUE_ADDR_SZ;
 	net_hw->rx_bar = pf_dev->qc_bar + rx_base * NFP_QCP_QUEUE_ADDR_SZ;
-	eth_dev->data->dev_private = net_hw;
 
 	PMD_INIT_LOG(DEBUG, "ctrl_bar: %p, tx_bar: %p, rx_bar: %p",
 			hw->ctrl_bar, net_hw->tx_bar, net_hw->rx_bar);
@@ -1002,7 +997,7 @@ nfp_net_init(struct rte_eth_dev *eth_dev)
 			goto xstats_free;
 	}
 
-	nfp_net_pf_read_mac(app_fw_nic, port);
+	nfp_net_pf_read_mac(app_fw_nic, port, hw_priv);
 	nfp_write_mac(hw, &hw->mac_addr.addr_bytes[0]);
 
 	if (rte_is_valid_assigned_ether_addr(&hw->mac_addr) == 0) {
@@ -1580,7 +1575,6 @@ nfp_init_app_fw_nic(struct nfp_net_hw_priv *hw_priv)
 		/* Add this device to the PF's array of physical ports */
 		app_fw_nic->ports[id] = hw;
 
-		hw->eth_dev = eth_dev;
 		hw->idx = id;
 		hw->nfp_idx = nfp_eth_table->ports[id].index;
 
@@ -1605,12 +1599,18 @@ nfp_init_app_fw_nic(struct nfp_net_hw_priv *hw_priv)
 
 port_cleanup:
 	for (i = 0; i < app_fw_nic->total_phyports; i++) {
-		id = nfp_function_id_get(pf_dev, i);
-		hw = app_fw_nic->ports[id];
+		struct rte_eth_dev *eth_dev;
 
-		if (hw != NULL && hw->eth_dev != NULL) {
-			nfp_net_uninit(hw->eth_dev);
-			rte_eth_dev_release_port(hw->eth_dev);
+		if (pf_dev->multi_pf.enabled)
+			snprintf(port_name, sizeof(port_name), "%s",
+					pf_dev->pci_dev->device.name);
+		else
+			snprintf(port_name, sizeof(port_name), "%s_port%u",
+					pf_dev->pci_dev->device.name, i);
+		eth_dev = rte_eth_dev_get_by_name(port_name);
+		if (eth_dev != NULL) {
+			nfp_net_uninit(eth_dev);
+			rte_eth_dev_release_port(eth_dev);
 		}
 	}
 	nfp_cpp_area_release_free(pf_dev->ctrl_area);
diff --git a/drivers/net/nfp/nfp_net_common.h b/drivers/net/nfp/nfp_net_common.h
index 40f314af0a..a4eaed6433 100644
--- a/drivers/net/nfp/nfp_net_common.h
+++ b/drivers/net/nfp/nfp_net_common.h
@@ -167,9 +167,6 @@ struct nfp_net_hw {
 	/** The parent class */
 	struct nfp_hw super;
 
-	/** Backpointer to the eth_dev of this port */
-	struct rte_eth_dev *eth_dev;
-
 	/** TX pointer ring write back memzone */
 	const struct rte_memzone *txrwb_mz;
 
-- 
2.39.1


  parent reply	other threads:[~2024-04-19  5:25 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-19  3:12 [PATCH 0/8] refactor logic to support secondary process Chaoyong He
2024-04-19  3:12 ` [PATCH 1/8] net/nfp: fix resource leak of " Chaoyong He
2024-04-19  3:12 ` [PATCH 2/8] net/nfp: fix configuration BAR problem Chaoyong He
2024-04-19  3:12 ` [PATCH 3/8] net/nfp: adjust the data field of Rx/Tx queue Chaoyong He
2024-04-19  3:12 ` [PATCH 4/8] net/nfp: add the process private structure Chaoyong He
2024-04-19  3:12 ` [PATCH 5/8] net/nfp: move device info data field Chaoyong He
2024-04-19  3:12 ` [PATCH 6/8] net/nfp: unify CPP acquire method Chaoyong He
2024-04-19  3:12 ` [PATCH 7/8] net/nfp: remove ethernet device data field Chaoyong He
2024-04-19  3:12 ` [PATCH 8/8] net/nfp: unify port create and destroy interface Chaoyong He
2024-04-19  5:23 ` [PATCH 0/8] refactor logic to support secondary process Chaoyong He
2024-04-19  5:23   ` [PATCH v2 1/8] net/nfp: fix resource leak of " Chaoyong He
2024-04-19  5:23   ` [PATCH v2 2/8] net/nfp: fix configuration BAR problem Chaoyong He
2024-04-19  5:23   ` [PATCH v2 3/8] net/nfp: adjust the data field of Rx/Tx queue Chaoyong He
2024-04-19  5:23   ` [PATCH v2 4/8] net/nfp: add the process private structure Chaoyong He
2024-04-19  5:23   ` [PATCH v2 5/8] net/nfp: move device info data field Chaoyong He
2024-04-19  5:23   ` [PATCH v2 6/8] net/nfp: unify CPP acquire method Chaoyong He
2024-04-19  5:23   ` Chaoyong He [this message]
2024-04-19  5:23   ` [PATCH v2 8/8] net/nfp: unify port create and destroy interface Chaoyong He
2024-05-20 22:19   ` [PATCH 0/8] refactor logic to support secondary process Ferruh Yigit
2024-05-21  2:17     ` Chaoyong He
2024-05-21 11:09       ` Ferruh Yigit
2024-05-21 11:24         ` Chaoyong He
2024-05-21 12:54           ` Ferruh Yigit
2024-05-21 15:08   ` Ferruh Yigit

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240419052349.1294696-8-chaoyong.he@corigine.com \
    --to=chaoyong.he@corigine.com \
    --cc=dev@dpdk.org \
    --cc=long.wu@corigine.com \
    --cc=oss-drivers@corigine.com \
    --cc=peng.zhang@corigine.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).