From: Chaoyong He <chaoyong.he@corigine.com>
To: dev@dpdk.org
Cc: oss-drivers@corigine.com, Peng Zhang <peng.zhang@corigine.com>,
Chaoyong He <chaoyong.he@corigine.com>,
Long Wu <long.wu@corigine.com>
Subject: [PATCH 08/23] net/nfp: export function ID get interface
Date: Wed, 19 Jun 2024 17:58:15 +0800 [thread overview]
Message-ID: <20240619095830.3479757-9-chaoyong.he@corigine.com> (raw)
In-Reply-To: <20240619095830.3479757-1-chaoyong.he@corigine.com>
From: Peng Zhang <peng.zhang@corigine.com>
Export the function ID get interface, and adjust the logic
to make it also valid for the flower firmware with multi-PF.
Signed-off-by: Peng Zhang <peng.zhang@corigine.com>
Reviewed-by: Chaoyong He <chaoyong.he@corigine.com>
Reviewed-by: Long Wu <long.wu@corigine.com>
---
drivers/net/nfp/flower/nfp_flower.c | 11 +++++++++--
drivers/net/nfp/flower/nfp_flower_cmsg.c | 10 ++++++----
drivers/net/nfp/flower/nfp_flower_cmsg.h | 2 +-
drivers/net/nfp/flower/nfp_flower_representor.c | 14 ++++++++++----
drivers/net/nfp/nfp_ethdev.c | 10 ----------
drivers/net/nfp/nfp_net_common.c | 10 ++++++++++
drivers/net/nfp/nfp_net_common.h | 2 ++
7 files changed, 38 insertions(+), 21 deletions(-)
diff --git a/drivers/net/nfp/flower/nfp_flower.c b/drivers/net/nfp/flower/nfp_flower.c
index 5caaf9d745..70135574d4 100644
--- a/drivers/net/nfp/flower/nfp_flower.c
+++ b/drivers/net/nfp/flower/nfp_flower.c
@@ -647,14 +647,18 @@ nfp_init_app_fw_flower(struct nfp_net_hw_priv *hw_priv)
{
int ret;
int err;
+ uint8_t id;
uint64_t ext_features;
unsigned int numa_node;
struct nfp_net_hw *pf_hw;
struct nfp_net_hw *ctrl_hw;
+ char bar_name[RTE_ETH_NAME_MAX_LEN];
+ char ctrl_name[RTE_ETH_NAME_MAX_LEN];
struct nfp_app_fw_flower *app_fw_flower;
struct nfp_pf_dev *pf_dev = hw_priv->pf_dev;
numa_node = rte_socket_id();
+ id = nfp_function_id_get(pf_dev, 0);
/* Allocate memory for the Flower app */
app_fw_flower = rte_zmalloc_socket("nfp_app_fw_flower", sizeof(*app_fw_flower),
@@ -688,7 +692,8 @@ nfp_init_app_fw_flower(struct nfp_net_hw_priv *hw_priv)
}
/* Map the PF ctrl bar */
- pf_dev->ctrl_bar = nfp_rtsym_map(pf_dev->sym_tbl, "_pf0_net_bar0",
+ snprintf(bar_name, sizeof(bar_name), "_pf%u_net_bar0", id);
+ pf_dev->ctrl_bar = nfp_rtsym_map(pf_dev->sym_tbl, bar_name,
NFP_NET_CFG_BAR_SZ, &pf_dev->ctrl_area);
if (pf_dev->ctrl_bar == NULL) {
PMD_INIT_LOG(ERR, "Cloud not map the PF vNIC ctrl bar");
@@ -711,6 +716,7 @@ nfp_init_app_fw_flower(struct nfp_net_hw_priv *hw_priv)
/* Fill in the PF vNIC and populate app struct */
app_fw_flower->pf_hw = pf_hw;
pf_hw->super.ctrl_bar = pf_dev->ctrl_bar;
+ pf_hw->nfp_idx = pf_dev->nfp_eth_table->ports[id].index;
ret = nfp_flower_init_vnic_common(hw_priv, pf_hw, "pf_vnic");
if (ret != 0) {
@@ -725,7 +731,8 @@ nfp_init_app_fw_flower(struct nfp_net_hw_priv *hw_priv)
ctrl_hw = app_fw_flower->ctrl_hw;
/* Map the ctrl vNIC ctrl bar */
- ctrl_hw->super.ctrl_bar = nfp_rtsym_map(pf_dev->sym_tbl, "_pf0_net_ctrl_bar",
+ snprintf(ctrl_name, sizeof(ctrl_name), "_pf%u_net_ctrl_bar", id);
+ ctrl_hw->super.ctrl_bar = nfp_rtsym_map(pf_dev->sym_tbl, ctrl_name,
NFP_NET_CFG_BAR_SZ, &ctrl_hw->ctrl_area);
if (ctrl_hw->super.ctrl_bar == NULL) {
PMD_INIT_LOG(ERR, "Cloud not map the ctrl vNIC ctrl bar");
diff --git a/drivers/net/nfp/flower/nfp_flower_cmsg.c b/drivers/net/nfp/flower/nfp_flower_cmsg.c
index 2a0e9afe90..9a5b5f52b8 100644
--- a/drivers/net/nfp/flower/nfp_flower_cmsg.c
+++ b/drivers/net/nfp/flower/nfp_flower_cmsg.c
@@ -82,9 +82,10 @@ nfp_flower_cmsg_mac_repr_fill(struct rte_mbuf *m,
int
nfp_flower_cmsg_mac_repr(struct nfp_app_fw_flower *app_fw_flower,
- struct nfp_eth_table *nfp_eth_table)
+ struct nfp_pf_dev *pf_dev)
{
uint8_t i;
+ uint8_t id;
uint16_t cnt;
uint32_t nbi;
uint32_t nbi_port;
@@ -101,9 +102,10 @@ nfp_flower_cmsg_mac_repr(struct nfp_app_fw_flower *app_fw_flower,
/* Fill in the mac repr cmsg */
for (i = 0; i < app_fw_flower->num_phyport_reprs; i++) {
- nbi = nfp_eth_table->ports[i].nbi;
- nbi_port = nfp_eth_table->ports[i].base;
- phys_port = nfp_eth_table->ports[i].index;
+ id = nfp_function_id_get(pf_dev, i);
+ nbi = pf_dev->nfp_eth_table->ports[id].nbi;
+ nbi_port = pf_dev->nfp_eth_table->ports[id].base;
+ phys_port = pf_dev->nfp_eth_table->ports[id].index;
nfp_flower_cmsg_mac_repr_fill(mbuf, i, nbi, nbi_port, phys_port);
}
diff --git a/drivers/net/nfp/flower/nfp_flower_cmsg.h b/drivers/net/nfp/flower/nfp_flower_cmsg.h
index afaf733ef7..bb03234035 100644
--- a/drivers/net/nfp/flower/nfp_flower_cmsg.h
+++ b/drivers/net/nfp/flower/nfp_flower_cmsg.h
@@ -976,7 +976,7 @@ struct nfp_fl_act_mark {
};
int nfp_flower_cmsg_mac_repr(struct nfp_app_fw_flower *app_fw_flower,
- struct nfp_eth_table *nfp_eth_table);
+ struct nfp_pf_dev *pf_dev);
int nfp_flower_cmsg_repr_reify(struct nfp_app_fw_flower *app_fw_flower,
struct nfp_flower_representor *repr);
int nfp_flower_cmsg_port_mod(struct nfp_app_fw_flower *app_fw_flower,
diff --git a/drivers/net/nfp/flower/nfp_flower_representor.c b/drivers/net/nfp/flower/nfp_flower_representor.c
index 633e5d9eb6..1f34c4c263 100644
--- a/drivers/net/nfp/flower/nfp_flower_representor.c
+++ b/drivers/net/nfp/flower/nfp_flower_representor.c
@@ -790,6 +790,7 @@ nfp_flower_repr_alloc(struct nfp_app_fw_flower *app_fw_flower,
{
int i;
int ret;
+ uint8_t id;
const char *pci_name;
struct nfp_pf_dev *pf_dev;
struct rte_pci_device *pci_dev;
@@ -806,7 +807,7 @@ nfp_flower_repr_alloc(struct nfp_app_fw_flower *app_fw_flower,
repr_init.hw_priv = hw_priv;
/* Send a NFP_FLOWER_CMSG_TYPE_MAC_REPR cmsg to hardware */
- ret = nfp_flower_cmsg_mac_repr(app_fw_flower, nfp_eth_table);
+ ret = nfp_flower_cmsg_mac_repr(app_fw_flower, pf_dev);
if (ret != 0) {
PMD_INIT_LOG(ERR, "Cloud not send mac repr cmsgs");
return ret;
@@ -822,7 +823,11 @@ nfp_flower_repr_alloc(struct nfp_app_fw_flower *app_fw_flower,
pci_name = strchr(pci_dev->name, ':') + 1;
- snprintf(flower_repr.name, sizeof(flower_repr.name),
+ if (pf_dev->multi_pf.enabled)
+ snprintf(flower_repr.name, sizeof(flower_repr.name),
+ "%s_repr_pf%d", pci_name, pf_dev->multi_pf.function_id);
+ else
+ snprintf(flower_repr.name, sizeof(flower_repr.name),
"%s_repr_pf", pci_name);
/* Create a eth_dev for this representor */
@@ -836,7 +841,8 @@ nfp_flower_repr_alloc(struct nfp_app_fw_flower *app_fw_flower,
/* Create a rte_eth_dev for every phyport representor */
for (i = 0; i < app_fw_flower->num_phyport_reprs; i++) {
- eth_port = &nfp_eth_table->ports[i];
+ id = nfp_function_id_get(pf_dev, i);
+ eth_port = &nfp_eth_table->ports[id];
flower_repr.repr_type = NFP_REPR_TYPE_PHYS_PORT;
flower_repr.port_id = nfp_flower_get_phys_port_id(eth_port->index);
flower_repr.nfp_idx = eth_port->eth_index;
@@ -845,7 +851,7 @@ nfp_flower_repr_alloc(struct nfp_app_fw_flower *app_fw_flower,
/* Copy the real mac of the interface to the representor struct */
rte_ether_addr_copy(ð_port->mac_addr, &flower_repr.mac_addr);
snprintf(flower_repr.name, sizeof(flower_repr.name),
- "%s_repr_p%d", pci_name, i);
+ "%s_repr_p%d", pci_name, id);
/*
* Create a eth_dev for this representor.
diff --git a/drivers/net/nfp/nfp_ethdev.c b/drivers/net/nfp/nfp_ethdev.c
index 2c1300350c..469fa4602e 100644
--- a/drivers/net/nfp/nfp_ethdev.c
+++ b/drivers/net/nfp/nfp_ethdev.c
@@ -497,16 +497,6 @@ nfp_net_set_link_down(struct rte_eth_dev *dev)
return nfp_eth_set_configured(hw_priv->pf_dev->cpp, hw->nfp_idx, 0);
}
-static uint8_t
-nfp_function_id_get(const struct nfp_pf_dev *pf_dev,
- uint8_t phy_port)
-{
- if (pf_dev->multi_pf.enabled)
- return pf_dev->multi_pf.function_id;
-
- return phy_port;
-}
-
static void
nfp_net_beat_timer(void *arg)
{
diff --git a/drivers/net/nfp/nfp_net_common.c b/drivers/net/nfp/nfp_net_common.c
index d8b7045c3a..0bfe7a514c 100644
--- a/drivers/net/nfp/nfp_net_common.c
+++ b/drivers/net/nfp/nfp_net_common.c
@@ -2564,3 +2564,13 @@ nfp_net_get_port_num(struct nfp_pf_dev *pf_dev,
else
return nfp_eth_table->count;
}
+
+uint8_t
+nfp_function_id_get(const struct nfp_pf_dev *pf_dev,
+ uint8_t port_id)
+{
+ if (pf_dev->multi_pf.enabled)
+ return pf_dev->multi_pf.function_id;
+
+ return port_id;
+}
diff --git a/drivers/net/nfp/nfp_net_common.h b/drivers/net/nfp/nfp_net_common.h
index 4016652cf9..cbf96e5ab5 100644
--- a/drivers/net/nfp/nfp_net_common.h
+++ b/drivers/net/nfp/nfp_net_common.h
@@ -328,6 +328,8 @@ int nfp_net_txrwb_alloc(struct rte_eth_dev *eth_dev);
void nfp_net_txrwb_free(struct rte_eth_dev *eth_dev);
uint32_t nfp_net_get_port_num(struct nfp_pf_dev *pf_dev,
struct nfp_eth_table *nfp_eth_table);
+uint8_t nfp_function_id_get(const struct nfp_pf_dev *pf_dev,
+ uint8_t port_id);
#define NFP_PRIV_TO_APP_FW_NIC(app_fw_priv)\
((struct nfp_app_fw_nic *)app_fw_priv)
--
2.39.1
next prev parent reply other threads:[~2024-06-19 9:59 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-19 9:58 [PATCH 00/23] support flower firmware with multiple PF Chaoyong He
2024-06-19 9:58 ` [PATCH 01/23] net/nfp: fix dereference of null pointer Chaoyong He
2024-07-07 18:56 ` Ferruh Yigit
2024-07-08 1:35 ` Chaoyong He
2024-06-19 9:58 ` [PATCH 02/23] net/nfp: disable ctrl VNIC queues Chaoyong He
2024-06-19 9:58 ` [PATCH 03/23] net/nfp: fix dereference of null pointer Chaoyong He
2024-06-19 9:58 ` [PATCH 04/23] net/nfp: fix repeat disable the port Chaoyong He
2024-06-19 9:58 ` [PATCH 05/23] net/nfp: fix repeat set the speed configure Chaoyong He
2024-06-19 9:58 ` [PATCH 06/23] net/nfp: make the logic simpler by adding local variable Chaoyong He
2024-06-19 9:58 ` [PATCH 07/23] net/nfp: rename the variable name Chaoyong He
2024-06-19 9:58 ` Chaoyong He [this message]
2024-06-19 9:58 ` [PATCH 09/23] net/nfp: extract total phyports Chaoyong He
2024-06-19 9:58 ` [PATCH 10/23] net/nfp: extract the initialize helper function Chaoyong He
2024-06-19 9:58 ` [PATCH 11/23] net/nfp: get the VF configuration Chaoyong He
2024-06-19 9:58 ` [PATCH 12/23] net/nfp: refactor the logic of flower service Chaoyong He
2024-06-19 9:58 ` [PATCH 13/23] net/nfp: get the first VF ID of the PF Chaoyong He
2024-06-19 9:58 ` [PATCH 14/23] net/nfp: add the helper function to map rtsym with offset Chaoyong He
2024-06-19 9:58 ` [PATCH 15/23] net/nfp: add the VF table to record the VF information Chaoyong He
2024-06-19 9:58 ` [PATCH 16/23] net/nfp: support configuration of VF numbers Chaoyong He
2024-06-19 9:58 ` [PATCH 17/23] net/nfp: configure the VF queue Chaoyong He
2024-06-19 9:58 ` [PATCH 18/23] net/nfp: add check for numbers of VF representor port Chaoyong He
2024-06-19 9:58 ` [PATCH 19/23] net/nfp: add support of ring pop and push Chaoyong He
2024-06-19 9:58 ` [PATCH 20/23] net/nfp: add resource share mode of host context Chaoyong He
2024-06-19 9:58 ` [PATCH 21/23] net/nfp: add resource share mode of mask ID Chaoyong He
2024-06-19 9:58 ` [PATCH 22/23] net/nfp: add device active command for nsp service Chaoyong He
2024-06-19 9:58 ` [PATCH 23/23] net/nfp: add support of flower firmware with multiple PF Chaoyong He
2024-07-07 18:56 ` [PATCH 00/23] support " 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=20240619095830.3479757-9-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).