From: Deli Zhang <deli.zhang21th@gmail.com>
To: michael.chan@broadcom.com
Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
Deli Zhang <deli.zhang21th@gmail.com>
Subject: [PATCH] bnxt_en: Add parameter disable_vf_bind
Date: Wed, 25 Jun 2025 13:30:05 +0800 [thread overview]
Message-ID: <20250625053005.79845-1-deli.zhang21th@gmail.com> (raw)
In virtualization, VF is usually not bound by native drivers, instead
should be passthrough to VM. Most PF and VF drivers provide separate
names, e.g. "igb" and "igbvf", so that the hypervisor can control
whether to use VF devices locally. The "bnxt_en" driver is a special
case, it can drive both PF and VF devices, so here add a parameter
"disable_vf_bind" to allow users to control.
Signed-off-by: Deli Zhang <deli.zhang21th@gmail.com>
---
drivers/net/ethernet/broadcom/bnxt/bnxt.c | 41 +++++++++++++++++++++--
1 file changed, 39 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
index 2cb3185c442c..89897182a71d 100644
--- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c
+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
@@ -88,6 +88,12 @@ MODULE_DESCRIPTION("Broadcom NetXtreme network driver");
#define BNXT_TX_PUSH_THRESH 164
+#ifdef CONFIG_BNXT_SRIOV
+static bool disable_vf_bind;
+module_param(disable_vf_bind, bool, 0);
+MODULE_PARM_DESC(disable_vf_bind, "Whether to disable binding to virtual functions (VFs)");
+#endif
+
/* indexed by enum board_idx */
static const struct {
char *name;
@@ -144,7 +150,12 @@ static const struct {
[NETXTREME_E_P7_VF] = { "Broadcom BCM5760X Virtual Function" },
};
-static const struct pci_device_id bnxt_pci_tbl[] = {
+/* The boundary between PF and VF devices in bnxt_pci_tbl */
+#ifdef CONFIG_BNXT_SRIOV
+#define FIRST_VF_DEV_ID 0x1606
+#endif
+
+static struct pci_device_id bnxt_pci_tbl[] = {
{ PCI_VDEVICE(BROADCOM, 0x1604), .driver_data = BCM5745x_NPAR },
{ PCI_VDEVICE(BROADCOM, 0x1605), .driver_data = BCM5745x_NPAR },
{ PCI_VDEVICE(BROADCOM, 0x1614), .driver_data = BCM57454 },
@@ -196,7 +207,7 @@ static const struct pci_device_id bnxt_pci_tbl[] = {
{ PCI_VDEVICE(BROADCOM, 0xd802), .driver_data = BCM58802 },
{ PCI_VDEVICE(BROADCOM, 0xd804), .driver_data = BCM58804 },
#ifdef CONFIG_BNXT_SRIOV
- { PCI_VDEVICE(BROADCOM, 0x1606), .driver_data = NETXTREME_E_VF },
+ { PCI_VDEVICE(BROADCOM, FIRST_VF_DEV_ID), .driver_data = NETXTREME_E_VF },
{ PCI_VDEVICE(BROADCOM, 0x1607), .driver_data = NETXTREME_E_VF_HV },
{ PCI_VDEVICE(BROADCOM, 0x1608), .driver_data = NETXTREME_E_VF_HV },
{ PCI_VDEVICE(BROADCOM, 0x1609), .driver_data = NETXTREME_E_VF },
@@ -17129,10 +17140,36 @@ static struct pci_driver bnxt_pci_driver = {
#endif
};
+#ifdef CONFIG_BNXT_SRIOV
+static void bnxt_vf_bind_init(void)
+{
+ s32 idx;
+
+ if (!disable_vf_bind)
+ return;
+
+ for (idx = 0; bnxt_pci_tbl[idx].device != 0; idx++) {
+ if (bnxt_pci_tbl[idx].device == FIRST_VF_DEV_ID) {
+ /* Truncate off VF devices */
+ memset(&bnxt_pci_tbl[idx], 0, sizeof(struct pci_device_id));
+ pr_info("%s: Disabled VF binding, id table offset %u",
+ DRV_MODULE_NAME, idx);
+ return;
+ }
+ }
+
+ /* Should not reach here! */
+ pr_crit("%s: Unknown VF dev id %u", DRV_MODULE_NAME, FIRST_VF_DEV_ID);
+}
+#endif
+
static int __init bnxt_init(void)
{
int err;
+#ifdef CONFIG_BNXT_SRIOV
+ bnxt_vf_bind_init();
+#endif
bnxt_debug_init();
err = pci_register_driver(&bnxt_pci_driver);
if (err) {
--
2.47.0
next reply other threads:[~2025-06-25 5:30 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-25 5:30 Deli Zhang [this message]
2025-06-25 13:42 ` [PATCH] bnxt_en: Add parameter disable_vf_bind Pavan Chebbi
2025-06-25 21:13 ` Jakub Kicinski
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=20250625053005.79845-1-deli.zhang21th@gmail.com \
--to=deli.zhang21th@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=michael.chan@broadcom.com \
--cc=netdev@vger.kernel.org \
/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).