From: Atul Patel <atul.patel@intel.com>
To: bruce.richardson@intel.com, aman.deep.singh@intel.com
Cc: dev@dpdk.org, praveen.shetty@intel.com, atul.patel@intel.com,
dhananjay.shukla@intel.com
Subject: [PATCH] net/cpfl: fix VF ID calculation for vCPF
Date: Fri, 28 Aug 2026 02:52:16 +0530 [thread overview]
Message-ID: <20260827212216.765057-1-atul.patel@intel.com> (raw)
The VF ID was incorrectly set to only the PCI function number,
which fails when VFs span multiple PCI devices (device IDs > 0).
Calculate the VF ID as (device_id * 8) + function to correctly
map VFs across devices.
Fixes: f1ab44fb0ebf ("net/cpfl: add vCPF port info")
Signed-off-by: Praveen Shetty <praveen.shetty@intel.com>
Signed-off-by: Atul Patel <atul.patel@intel.com>
Signed-off-by: Dhananjay Shukla <dhananjay.shukla@intel.com>
---
drivers/net/intel/cpfl/cpfl_ethdev.c | 3 ++-
drivers/net/intel/cpfl/cpfl_ethdev.h | 10 ++++++++++
2 files changed, 12 insertions(+), 1 deletion(-)
diff --git a/drivers/net/intel/cpfl/cpfl_ethdev.c b/drivers/net/intel/cpfl/cpfl_ethdev.c
index 4315adb68c..01e1b57cc8 100644
--- a/drivers/net/intel/cpfl/cpfl_ethdev.c
+++ b/drivers/net/intel/cpfl/cpfl_ethdev.c
@@ -2839,7 +2839,8 @@ cpfl_dev_vport_init(struct rte_eth_dev *dev, void *init_params)
pci_dev = RTE_CLASS_TO_BUS_DEVICE(dev, *pci_dev);
vi.func_type = VCPF_CPCHNL2_FTYPE_LAN_VF;
vi.pf_id = CPFL_HOST0_CPF_ID;
- vi.vf_id = pci_dev->addr.function;
+ vi.vf_id = VCPF_VF_ID_FROM_PCI(pci_dev->addr.devid,
+ pci_dev->addr.function);
v_id.vport_id = cpfl_vport->base.vport_info.info.vport_id;
v_id.vport_type = cpfl_vport->base.vport_info.info.vport_type;
diff --git a/drivers/net/intel/cpfl/cpfl_ethdev.h b/drivers/net/intel/cpfl/cpfl_ethdev.h
index d41aa93191..97ec128128 100644
--- a/drivers/net/intel/cpfl/cpfl_ethdev.h
+++ b/drivers/net/intel/cpfl/cpfl_ethdev.h
@@ -103,6 +103,16 @@
((((type) & 0x3) << 14) + (((host_id) & 0x1) << 13) + \
(((pf_id) & 0x1) << 12) + ((vf_id) & 0xfff))
+/* Max VFs per PCI device (functions 0-7) */
+#define VCPF_VFS_PER_PCI_DEV 8
+
+/* Calculate VF ID from PCI device and function IDs.
+ * VFs span multiple PCI devices, e.g.:
+ * device 0: VF 0-7, device 1: VF 8-15, etc.
+ */
+#define VCPF_VF_ID_FROM_PCI(device_id, function) \
+ (((device_id) * VCPF_VFS_PER_PCI_DEV) + (function))
+
struct cpfl_vport_param {
struct cpfl_adapter_ext *adapter;
uint16_t devarg_id; /* arg id from user */
--
2.34.1
reply other threads:[~2026-08-28 4:45 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20260827212216.765057-1-atul.patel@intel.com \
--to=atul.patel@intel.com \
--cc=aman.deep.singh@intel.com \
--cc=bruce.richardson@intel.com \
--cc=dev@dpdk.org \
--cc=dhananjay.shukla@intel.com \
--cc=praveen.shetty@intel.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