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 13/23] net/nfp: get the first VF ID of the PF
Date: Wed, 19 Jun 2024 17:58:20 +0800 [thread overview]
Message-ID: <20240619095830.3479757-14-chaoyong.he@corigine.com> (raw)
In-Reply-To: <20240619095830.3479757-1-chaoyong.he@corigine.com>
From: Peng Zhang <peng.zhang@corigine.com>
In single PF case, all the VFs belong to the PF0, so the first VF ID
of the PF is always 0.
But in multiple PF case, VFs are shared by the PFs, and the first VF ID
of the PF is different, so it is necessary to get the right ID.
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 | 2 +-
drivers/net/nfp/flower/nfp_flower_cmsg.h | 1 +
drivers/net/nfp/flower/nfp_flower_ctrl.c | 7 +++++--
drivers/net/nfp/flower/nfp_flower_representor.c | 2 +-
drivers/net/nfp/nfp_ethdev.c | 1 +
drivers/net/nfp/nfp_net_common.h | 2 ++
6 files changed, 11 insertions(+), 4 deletions(-)
diff --git a/drivers/net/nfp/flower/nfp_flower.c b/drivers/net/nfp/flower/nfp_flower.c
index 87bd9dda2e..602f45d1dd 100644
--- a/drivers/net/nfp/flower/nfp_flower.c
+++ b/drivers/net/nfp/flower/nfp_flower.c
@@ -116,7 +116,7 @@ nfp_flower_get_repr(struct nfp_net_hw_priv *hw_priv,
port = NFP_FLOWER_CMSG_PORT_PHYS_PORT_NUM(port_id);
return app_fw_flower->phy_reprs[port];
case NFP_FLOWER_CMSG_PORT_TYPE_PCIE_PORT:
- port = NFP_FLOWER_CMSG_PORT_VNIC(port_id);
+ port = NFP_FLOWER_CMSG_PORT_VNIC_OFFSET(port_id, hw_priv->pf_dev->vf_base_id);
return app_fw_flower->vf_reprs[port];
default:
break;
diff --git a/drivers/net/nfp/flower/nfp_flower_cmsg.h b/drivers/net/nfp/flower/nfp_flower_cmsg.h
index bb03234035..93183153aa 100644
--- a/drivers/net/nfp/flower/nfp_flower_cmsg.h
+++ b/drivers/net/nfp/flower/nfp_flower_cmsg.h
@@ -422,6 +422,7 @@ enum nfp_flower_cmsg_port_vnic_type {
#define NFP_FLOWER_CMSG_PORT_PCI(x) (((x) >> 14) & 0x3) /* [14,15] */
#define NFP_FLOWER_CMSG_PORT_VNIC_TYPE(x) (((x) >> 12) & 0x3) /* [12,13] */
#define NFP_FLOWER_CMSG_PORT_VNIC(x) (((x) >> 6) & 0x3f) /* [6,11] */
+#define NFP_FLOWER_CMSG_PORT_VNIC_OFFSET(x, offset) (NFP_FLOWER_CMSG_PORT_VNIC(x) - (offset))
#define NFP_FLOWER_CMSG_PORT_PCIE_Q(x) ((x) & 0x3f) /* [0,5] */
#define NFP_FLOWER_CMSG_PORT_PHYS_PORT_NUM(x) ((x) & 0xff) /* [0,7] */
diff --git a/drivers/net/nfp/flower/nfp_flower_ctrl.c b/drivers/net/nfp/flower/nfp_flower_ctrl.c
index 01a680eb6d..a46b849d1b 100644
--- a/drivers/net/nfp/flower/nfp_flower_ctrl.c
+++ b/drivers/net/nfp/flower/nfp_flower_ctrl.c
@@ -419,6 +419,7 @@ nfp_flower_cmsg_port_mod_rx(struct nfp_net_hw_priv *hw_priv,
struct rte_mbuf *pkt_burst)
{
uint32_t port;
+ uint32_t index;
struct nfp_flower_representor *repr;
struct nfp_flower_cmsg_port_mod *msg;
struct nfp_app_fw_flower *app_fw_flower;
@@ -430,11 +431,13 @@ nfp_flower_cmsg_port_mod_rx(struct nfp_net_hw_priv *hw_priv,
switch (NFP_FLOWER_CMSG_PORT_TYPE(port)) {
case NFP_FLOWER_CMSG_PORT_TYPE_PHYS_PORT:
- repr = app_fw_flower->phy_reprs[NFP_FLOWER_CMSG_PORT_PHYS_PORT_NUM(port)];
+ index = NFP_FLOWER_CMSG_PORT_PHYS_PORT_NUM(port);
+ repr = app_fw_flower->phy_reprs[index];
break;
case NFP_FLOWER_CMSG_PORT_TYPE_PCIE_PORT:
+ index = NFP_FLOWER_CMSG_PORT_VNIC_OFFSET(port, hw_priv->pf_dev->vf_base_id);
if (NFP_FLOWER_CMSG_PORT_VNIC_TYPE(port) == NFP_FLOWER_CMSG_PORT_VNIC_TYPE_VF)
- repr = app_fw_flower->vf_reprs[NFP_FLOWER_CMSG_PORT_VNIC(port)];
+ repr = app_fw_flower->vf_reprs[index];
else
repr = app_fw_flower->pf_repr;
break;
diff --git a/drivers/net/nfp/flower/nfp_flower_representor.c b/drivers/net/nfp/flower/nfp_flower_representor.c
index 59dc5854b5..e6fef45ddd 100644
--- a/drivers/net/nfp/flower/nfp_flower_representor.c
+++ b/drivers/net/nfp/flower/nfp_flower_representor.c
@@ -877,7 +877,7 @@ nfp_flower_repr_alloc(struct nfp_app_fw_flower *app_fw_flower,
for (i = 0; i < app_fw_flower->num_vf_reprs; i++) {
flower_repr.repr_type = NFP_REPR_TYPE_VF;
flower_repr.port_id = nfp_get_pcie_port_id(pf_dev->cpp,
- NFP_FLOWER_CMSG_PORT_VNIC_TYPE_VF, i, 0);
+ NFP_FLOWER_CMSG_PORT_VNIC_TYPE_VF, i + pf_dev->vf_base_id, 0);
flower_repr.nfp_idx = 0;
flower_repr.vf_id = i;
diff --git a/drivers/net/nfp/nfp_ethdev.c b/drivers/net/nfp/nfp_ethdev.c
index e67ff3a0a0..482d23eb5c 100644
--- a/drivers/net/nfp/nfp_ethdev.c
+++ b/drivers/net/nfp/nfp_ethdev.c
@@ -1924,6 +1924,7 @@ nfp_pf_get_sriov_vf(struct nfp_pf_dev *pf_dev,
return -ERANGE;
}
+ pf_dev->vf_base_id = offset;
pf_dev->sriov_vf = sriov_vf;
return 0;
diff --git a/drivers/net/nfp/nfp_net_common.h b/drivers/net/nfp/nfp_net_common.h
index 7efd0161af..d3c70a21d4 100644
--- a/drivers/net/nfp/nfp_net_common.h
+++ b/drivers/net/nfp/nfp_net_common.h
@@ -147,6 +147,8 @@ struct nfp_pf_dev {
uint16_t sriov_vf;
uint8_t total_phyports;
+ /** Id of first VF that belongs to this PF */
+ uint8_t vf_base_id;
};
#define NFP_NET_FLOW_LIMIT 1024
--
2.39.1
next prev parent reply other threads:[~2024-06-19 10:00 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 ` [PATCH 08/23] net/nfp: export function ID get interface Chaoyong He
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 ` Chaoyong He [this message]
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-14-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).