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 3/9] net/nfp: extract the function to allocate PF
Date: Mon, 21 Oct 2024 14:32:55 +0800 [thread overview]
Message-ID: <20241021063301.4146214-4-chaoyong.he@corigine.com> (raw)
In-Reply-To: <20241021063301.4146214-1-chaoyong.he@corigine.com>
From: Peng Zhang <peng.zhang@corigine.com>
Extract the helper function to allocate the PF representor port.
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>
---
.../net/nfp/flower/nfp_flower_representor.c | 58 ++++++++++++-------
1 file changed, 38 insertions(+), 20 deletions(-)
diff --git a/drivers/net/nfp/flower/nfp_flower_representor.c b/drivers/net/nfp/flower/nfp_flower_representor.c
index f76e780840..2045076b4b 100644
--- a/drivers/net/nfp/flower/nfp_flower_representor.c
+++ b/drivers/net/nfp/flower/nfp_flower_representor.c
@@ -873,6 +873,41 @@ nfp_flower_phy_repr_alloc(struct nfp_net_hw_priv *hw_priv,
return 0;
}
+static int
+nfp_flower_pf_repr_alloc(struct nfp_net_hw_priv *hw_priv,
+ struct nfp_flower_representor *flower_repr,
+ const char *pci_name)
+{
+ int ret;
+ struct nfp_pf_dev *pf_dev;
+
+ pf_dev = hw_priv->pf_dev;
+
+ /* Create a rte_eth_dev for PF vNIC representor */
+ flower_repr->repr_type = NFP_REPR_TYPE_PF;
+
+ /* PF vNIC reprs get a random MAC address */
+ rte_eth_random_addr(flower_repr->mac_addr.addr_bytes);
+
+ 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 */
+ ret = rte_eth_dev_create(&pf_dev->pci_dev->device, flower_repr->name,
+ sizeof(struct nfp_flower_representor),
+ NULL, NULL, nfp_flower_pf_repr_init, flower_repr);
+ if (ret != 0) {
+ PMD_INIT_LOG(ERR, "Failed to init the pf repr.");
+ return -EINVAL;
+ }
+
+ return 0;
+}
+
static int
nfp_flower_repr_alloc(struct nfp_app_fw_flower *app_fw_flower,
struct nfp_net_hw_priv *hw_priv)
@@ -898,31 +933,14 @@ nfp_flower_repr_alloc(struct nfp_app_fw_flower *app_fw_flower,
return ret;
}
- /* Create a rte_eth_dev for PF vNIC representor */
- flower_repr.repr_type = NFP_REPR_TYPE_PF;
- flower_repr.idx = 0;
-
- /* PF vNIC reprs get a random MAC address */
- rte_eth_random_addr(flower_repr.mac_addr.addr_bytes);
-
pci_dev = pf_dev->pci_dev;
pci_name = strchr(pci_dev->name, ':') + 1;
- 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 */
- 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);
+ ret = nfp_flower_pf_repr_alloc(hw_priv, &flower_repr, pci_name);
if (ret != 0) {
- PMD_INIT_LOG(ERR, "Failed to init the pf repr.");
- return -EINVAL;
+ PMD_INIT_LOG(ERR, "Could not alloc pf repr.");
+ return ret;
}
/* Create a rte_eth_dev for every phyport representor */
--
2.39.1
next prev parent reply other threads:[~2024-10-21 6:33 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-21 6:32 [PATCH 0/9] support multiple PF flower firmware Chaoyong He
2024-10-21 6:32 ` [PATCH 1/9] net/nfp: extract the function to allocate the PHY Chaoyong He
2024-10-21 6:32 ` [PATCH 2/9] net/nfp: extract the function to initialize the PF Chaoyong He
2024-10-21 6:32 ` Chaoyong He [this message]
2024-10-21 6:32 ` [PATCH 4/9] net/nfp: extract the function to allocate the VF Chaoyong He
2024-10-21 6:32 ` [PATCH 5/9] net/nfp: revise the number of PF representor port Chaoyong He
2024-10-21 6:32 ` [PATCH 6/9] net/nfp: initialize the representor port of the multiple PF Chaoyong He
2024-10-21 6:32 ` [PATCH 7/9] net/nfp: ignore useless message for " Chaoyong He
2024-10-21 6:33 ` [PATCH 8/9] net/nfp: add the new operations " Chaoyong He
2024-10-21 6:33 ` [PATCH 9/9] net/nfp: update the Tx and Rx function " Chaoyong He
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=20241021063301.4146214-4-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).