DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] net/nfp: fix internal NFP port addressing
@ 2021-05-14  9:19 Heinrich Kuhn
  2021-05-14 11:58 ` Ferruh Yigit
  0 siblings, 1 reply; 2+ messages in thread
From: Heinrich Kuhn @ 2021-05-14  9:19 UTC (permalink / raw)
  To: dev; +Cc: Heinrich Kuhn, Simon Horman

Depending on the breakout mode of the physical ports the internal NFP
port number might differ from the actual physical port number. Prior to
this patch the physical port number was used when making configuration
changes to the physical ports (enable, admin up etc). After this change
the internal port number is now correctly used for configuration
changes.

Fixes: 5e15e799d ("net/nfp: create separate entity for PF device")

Signed-off-by: Heinrich Kuhn <heinrich.kuhn@netronome.com>
Signed-off-by: Simon Horman <simon.horman@netronome.com>
---
 drivers/net/nfp/nfp_net.c     | 38 +++++++++++++++++++++++------------
 drivers/net/nfp/nfp_net_pmd.h |  3 +++
 2 files changed, 28 insertions(+), 13 deletions(-)

diff --git a/drivers/net/nfp/nfp_net.c b/drivers/net/nfp/nfp_net.c
index 888324cd2..05370767b 100644
--- a/drivers/net/nfp/nfp_net.c
+++ b/drivers/net/nfp/nfp_net.c
@@ -769,10 +769,10 @@ nfp_net_start(struct rte_eth_dev *dev)
 	if (hw->is_phyport) {
 		if (rte_eal_process_type() == RTE_PROC_PRIMARY)
 			/* Configure the physical port up */
-			nfp_eth_set_configured(hw->cpp, hw->idx, 1);
+			nfp_eth_set_configured(hw->cpp, hw->nfp_idx, 1);
 		else
 			nfp_eth_set_configured(dev->process_private,
-					       hw->idx, 1);
+					       hw->nfp_idx, 1);
 	}
 
 	hw->ctrl = new_ctrl;
@@ -825,10 +825,10 @@ nfp_net_stop(struct rte_eth_dev *dev)
 	if (hw->is_phyport) {
 		if (rte_eal_process_type() == RTE_PROC_PRIMARY)
 			/* Configure the physical port down */
-			nfp_eth_set_configured(hw->cpp, hw->idx, 0);
+			nfp_eth_set_configured(hw->cpp, hw->nfp_idx, 0);
 		else
 			nfp_eth_set_configured(dev->process_private,
-					       hw->idx, 0);
+					       hw->nfp_idx, 0);
 	}
 
 	return 0;
@@ -849,10 +849,10 @@ nfp_net_set_link_up(struct rte_eth_dev *dev)
 
 	if (rte_eal_process_type() == RTE_PROC_PRIMARY)
 		/* Configure the physical port down */
-		return nfp_eth_set_configured(hw->cpp, hw->idx, 1);
+		return nfp_eth_set_configured(hw->cpp, hw->nfp_idx, 1);
 	else
 		return nfp_eth_set_configured(dev->process_private,
-					      hw->idx, 1);
+					      hw->nfp_idx, 1);
 }
 
 /* Set the link down. */
@@ -870,10 +870,10 @@ nfp_net_set_link_down(struct rte_eth_dev *dev)
 
 	if (rte_eal_process_type() == RTE_PROC_PRIMARY)
 		/* Configure the physical port down */
-		return nfp_eth_set_configured(hw->cpp, hw->idx, 0);
+		return nfp_eth_set_configured(hw->cpp, hw->nfp_idx, 0);
 	else
 		return nfp_eth_set_configured(dev->process_private,
-					      hw->idx, 0);
+					      hw->nfp_idx, 0);
 }
 
 /* Reset and stop device. The device can not be restarted. */
@@ -2806,15 +2806,15 @@ nfp_net_init(struct rte_eth_dev *eth_dev)
 			return -ENODEV;
 		}
 
-		/* This points to the specific port private data */
-		PMD_INIT_LOG(DEBUG, "Working with physical port number %d",
-				    port);
-
 		/* Use PF array of physical ports to get pointer to
 		 * this specific port
 		 */
 		hw = pf_dev->ports[port];
 
+		PMD_INIT_LOG(DEBUG, "Working with physical port number: %d, "
+				    "NFP internal port number: %d",
+				    port, hw->nfp_idx);
+
 	} else {
 		hw = NFP_NET_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private);
 	}
@@ -3493,9 +3493,17 @@ static int nfp_init_phyports(struct nfp_pf_dev *pf_dev)
 {
 	struct nfp_net_hw *hw;
 	struct rte_eth_dev *eth_dev;
+	struct nfp_eth_table *nfp_eth_table = NULL;
 	int ret = 0;
 	int i;
 
+	nfp_eth_table = nfp_eth_read_ports(pf_dev->cpp);
+	if (!nfp_eth_table) {
+		PMD_INIT_LOG(ERR, "Error reading NFP ethernet table");
+		ret = -EIO;
+		goto error;
+	}
+
 	/* Loop through all physical ports on PF */
 	for (i = 0; i < pf_dev->total_phyports; i++) {
 		const unsigned int numa_node = rte_socket_id();
@@ -3551,6 +3559,7 @@ static int nfp_init_phyports(struct nfp_pf_dev *pf_dev)
 		hw->cpp = pf_dev->cpp;
 		hw->eth_dev = eth_dev;
 		hw->idx = i;
+		hw->nfp_idx = nfp_eth_table->ports[i].index;
 		hw->is_phyport = true;
 
 nfp_net_init:
@@ -3569,7 +3578,8 @@ static int nfp_init_phyports(struct nfp_pf_dev *pf_dev)
 		rte_eth_dev_probing_finish(eth_dev);
 
 	} /* End loop, all ports on this PF */
-	return 0;
+	ret = 0;
+	goto eth_table_cleanup;
 
 port_cleanup:
 	for (i = 0; i < pf_dev->total_phyports; i++) {
@@ -3580,6 +3590,8 @@ static int nfp_init_phyports(struct nfp_pf_dev *pf_dev)
 			pf_dev->ports[i] = NULL;
 		}
 	}
+eth_table_cleanup:
+	free(nfp_eth_table);
 error:
 	return ret;
 }
diff --git a/drivers/net/nfp/nfp_net_pmd.h b/drivers/net/nfp/nfp_net_pmd.h
index 922d94001..b1303b13f 100644
--- a/drivers/net/nfp/nfp_net_pmd.h
+++ b/drivers/net/nfp/nfp_net_pmd.h
@@ -483,7 +483,10 @@ struct nfp_net_hw {
 	struct nfp_cpp_area *msix_area;
 
 	uint8_t *hw_queues;
+	/* Sequential physical port number */
 	uint8_t idx;
+	/* Internal port number as seen from NFP */
+	uint8_t nfp_idx;
 	bool	is_phyport;
 
 	union eth_table_entry *eth_table;
-- 
2.30.1 (Apple Git-130)


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [dpdk-dev] [PATCH] net/nfp: fix internal NFP port addressing
  2021-05-14  9:19 [dpdk-dev] [PATCH] net/nfp: fix internal NFP port addressing Heinrich Kuhn
@ 2021-05-14 11:58 ` Ferruh Yigit
  0 siblings, 0 replies; 2+ messages in thread
From: Ferruh Yigit @ 2021-05-14 11:58 UTC (permalink / raw)
  To: Heinrich Kuhn, dev; +Cc: Simon Horman

On 5/14/2021 10:19 AM, Heinrich Kuhn wrote:
> Depending on the breakout mode of the physical ports the internal NFP
> port number might differ from the actual physical port number. Prior to
> this patch the physical port number was used when making configuration
> changes to the physical ports (enable, admin up etc). After this change
> the internal port number is now correctly used for configuration
> changes.
> 
> Fixes: 5e15e799d ("net/nfp: create separate entity for PF device")
> 
> Signed-off-by: Heinrich Kuhn <heinrich.kuhn@netronome.com>
> Signed-off-by: Simon Horman <simon.horman@netronome.com>

Applied to dpdk-next-net/main, thanks.


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-05-14 11:58 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-14  9:19 [dpdk-dev] [PATCH] net/nfp: fix internal NFP port addressing Heinrich Kuhn
2021-05-14 11:58 ` Ferruh Yigit

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).