* [PATCH net] net: libwx: determine the device role without pci_dev::is_virtfn
@ 2026-12-02 9:44 Mengyuan Lou
2026-12-02 9:48 ` netdev-bot+sinfo
0 siblings, 1 reply; 2+ messages in thread
From: Mengyuan Lou @ 2026-12-02 9:44 UTC (permalink / raw)
To: netdev
Cc: jiawenwu, duanqiangwen, linglingzhang, andrew+netdev, davem,
edumazet, kuba, pabeni, Mengyuan Lou
libwx decides whether it drives a PF or a VF by checking
pci_dev::is_virtfn. Only pci_iov_scan_device() sets that flag, for a VF
that the local PCI core enumerated, so it stays clear when a VF is passed
through to a guest, which is how VFs are normally deployed. A VF that the
guest enumerated itself therefore takes the PF branch of every check in
libwx:
- wx_sw_init() reads WX_CFG_PORT_ST, the PF-only register that commit
694de316f607 ("net: libwx: fix VF illegal register access") records as
hanging the system when a VF reads it, and can call
wx_flash_read_dword() for a subsystem vendor that is not Wangxun.
- wx_intr_enable() writes WX_PX_IMC(0/1) instead of WX_VXIMC.
- wx_set_itr() and wx_set_coalesce() write WX_PX_ITR through
wx_write_eitr() instead of using wx_write_eitr_vf().
- wx_init_interrupt_scheme() runs the PF wx_set_num_queues() instead of
the wx->set_num_queues callback.
- wx_set_interrupt_capability() falls back to MSI or INTx instead of
returning the MSI-X error.
The VF drivers are separate modules with their own device IDs, so the
role is known at probe time. Record it in a wx field that the VF drivers
set before the hardware is touched, and check that field everywhere
instead of pci_dev::is_virtfn.
Commit 694de316f607 ("net: libwx: fix VF illegal register access") fixed
only the WX_CFG_PORT_ST read and kept the same check for it, so the hang
it describes stays reachable from a guest VF.
The issue was pointed out by the Sashiko review of the net-next series
that adds VF statistics; the code change is confined to the role check.
Fixes: 4ee8afb44aee ("net: txgbevf: add sw init pci info and reset hardware")
Fixes: 694de316f607 ("net: libwx: fix VF illegal register access")
Signed-off-by: Mengyuan Lou <mengyuanlou@net-swift.com>
---
drivers/net/ethernet/wangxun/libwx/wx_ethtool.c | 2 +-
drivers/net/ethernet/wangxun/libwx/wx_hw.c | 6 +++---
drivers/net/ethernet/wangxun/libwx/wx_lib.c | 6 +++---
drivers/net/ethernet/wangxun/libwx/wx_type.h | 6 ++++++
drivers/net/ethernet/wangxun/ngbevf/ngbevf_main.c | 1 +
drivers/net/ethernet/wangxun/txgbevf/txgbevf_main.c | 1 +
6 files changed, 15 insertions(+), 7 deletions(-)
diff --git a/drivers/net/ethernet/wangxun/libwx/wx_ethtool.c b/drivers/net/ethernet/wangxun/libwx/wx_ethtool.c
index 940d2e59876c7..c6175a57ace4b 100644
--- a/drivers/net/ethernet/wangxun/libwx/wx_ethtool.c
+++ b/drivers/net/ethernet/wangxun/libwx/wx_ethtool.c
@@ -489,7 +489,7 @@ int wx_set_coalesce(struct net_device *netdev,
else
/* rx only or mixed */
q_vector->itr = rx_itr_param;
- if (wx->pdev->is_virtfn)
+ if (wx->is_vf)
wx_write_eitr_vf(q_vector);
else
wx_write_eitr(q_vector);
diff --git a/drivers/net/ethernet/wangxun/libwx/wx_hw.c b/drivers/net/ethernet/wangxun/libwx/wx_hw.c
index 111aadf792089..c7226babe5823 100644
--- a/drivers/net/ethernet/wangxun/libwx/wx_hw.c
+++ b/drivers/net/ethernet/wangxun/libwx/wx_hw.c
@@ -125,7 +125,7 @@ void wx_intr_enable(struct wx *wx, u64 qmask)
{
u32 mask;
- if (wx->pdev->is_virtfn) {
+ if (wx->is_vf) {
wr32(wx, WX_VXIMC, qmask);
return;
}
@@ -2481,14 +2481,14 @@ int wx_sw_init(struct wx *wx)
wx->oem_svid = pdev->subsystem_vendor;
wx->oem_ssid = pdev->subsystem_device;
wx->bus.device = PCI_SLOT(pdev->devfn);
- if (pdev->is_virtfn)
+ if (wx->is_vf)
wx->bus.func = PCI_FUNC(pdev->devfn);
else
wx->bus.func = FIELD_GET(WX_CFG_PORT_ST_LANID,
rd32(wx, WX_CFG_PORT_ST));
if (wx->oem_svid == PCI_VENDOR_ID_WANGXUN ||
- pdev->is_virtfn) {
+ wx->is_vf) {
wx->subsystem_vendor_id = pdev->subsystem_vendor;
wx->subsystem_device_id = pdev->subsystem_device;
} else {
diff --git a/drivers/net/ethernet/wangxun/libwx/wx_lib.c b/drivers/net/ethernet/wangxun/libwx/wx_lib.c
index dcbf5811046e9..9da06c24e984b 100644
--- a/drivers/net/ethernet/wangxun/libwx/wx_lib.c
+++ b/drivers/net/ethernet/wangxun/libwx/wx_lib.c
@@ -1757,7 +1757,7 @@ static void wx_set_itr(struct wx_q_vector *q_vector)
/* save the algorithm value here */
q_vector->itr = new_itr;
- if (wx->pdev->is_virtfn)
+ if (wx->is_vf)
wx_write_eitr_vf(q_vector);
else
wx_write_eitr(q_vector);
@@ -2028,7 +2028,7 @@ static int wx_set_interrupt_capability(struct wx *wx)
/* We will try to get MSI-X interrupts first */
ret = wx_acquire_msix_vectors(wx);
- if (ret == 0 || (ret == -ENOMEM) || pdev->is_virtfn)
+ if (ret == 0 || (ret == -ENOMEM) || wx->is_vf)
return ret;
/* Disable VMDq support */
@@ -2378,7 +2378,7 @@ int wx_init_interrupt_scheme(struct wx *wx)
int ret;
/* Number of supported queues */
- if (wx->pdev->is_virtfn) {
+ if (wx->is_vf) {
if (wx->set_num_queues)
wx->set_num_queues(wx);
} else {
diff --git a/drivers/net/ethernet/wangxun/libwx/wx_type.h b/drivers/net/ethernet/wangxun/libwx/wx_type.h
index a7f3c48e9603c..6c9f7a21565eb 100644
--- a/drivers/net/ethernet/wangxun/libwx/wx_type.h
+++ b/drivers/net/ethernet/wangxun/libwx/wx_type.h
@@ -1303,6 +1303,12 @@ struct wx {
u8 __iomem *hw_addr;
u8 __iomem *b4_addr; /* vf only */
struct pci_dev *pdev;
+ /* Whether this instance drives a VF. The VF drivers set it before the
+ * hardware is touched: pci_dev::is_virtfn is only set for the VFs the
+ * host's SR-IOV implementation enumerates, so it stays clear for a VF
+ * probed inside a guest.
+ */
+ bool is_vf;
struct net_device *netdev;
struct wx_bus_info bus;
struct wx_mbx_info mbx;
diff --git a/drivers/net/ethernet/wangxun/ngbevf/ngbevf_main.c b/drivers/net/ethernet/wangxun/ngbevf/ngbevf_main.c
index d79cf8d8484f9..c21fe51a21e73 100644
--- a/drivers/net/ethernet/wangxun/ngbevf/ngbevf_main.c
+++ b/drivers/net/ethernet/wangxun/ngbevf/ngbevf_main.c
@@ -176,6 +176,7 @@ static int ngbevf_probe(struct pci_dev *pdev,
wx = netdev_priv(netdev);
wx->netdev = netdev;
wx->pdev = pdev;
+ wx->is_vf = true;
wx->msg_enable = netif_msg_init(-1, NETIF_MSG_DRV |
NETIF_MSG_PROBE | NETIF_MSG_LINK);
diff --git a/drivers/net/ethernet/wangxun/txgbevf/txgbevf_main.c b/drivers/net/ethernet/wangxun/txgbevf/txgbevf_main.c
index 8b16b900820aa..3118a00b57165 100644
--- a/drivers/net/ethernet/wangxun/txgbevf/txgbevf_main.c
+++ b/drivers/net/ethernet/wangxun/txgbevf/txgbevf_main.c
@@ -233,6 +233,7 @@ static int txgbevf_probe(struct pci_dev *pdev,
wx = netdev_priv(netdev);
wx->netdev = netdev;
wx->pdev = pdev;
+ wx->is_vf = true;
wx->msg_enable = netif_msg_init(-1, NETIF_MSG_DRV |
NETIF_MSG_PROBE | NETIF_MSG_LINK);
--
2.30.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH net] net: libwx: determine the device role without pci_dev::is_virtfn
2026-12-02 9:44 [PATCH net] net: libwx: determine the device role without pci_dev::is_virtfn Mengyuan Lou
@ 2026-12-02 9:48 ` netdev-bot+sinfo
0 siblings, 0 replies; 2+ messages in thread
From: netdev-bot+sinfo @ 2026-12-02 9:48 UTC (permalink / raw)
To: Mengyuan Lou
Cc: netdev, jiawenwu, duanqiangwen, linglingzhang, andrew+netdev,
davem, edumazet, kuba, pabeni
Hi!
This is an automated message. This series looks like a fix, but its
commit messages seem to be missing some information:
- Whether the issue was actually triggered, or is only theoretical
(e.g. found by LLM and not proven at runtime). If it was triggered
please include the symptoms, like the stack trace or kernel messages.
- What hardware the change was tested on. For driver fixes please
mention the device (and if relevant firmware version) used for
testing, or say that the change was not tested on real hardware.
Please do not repost the series just to address the above. Instead,
reply to this email with the missing information, so that reviewers
can take it into account.
*IMPORTANT*: If you do repost (for other reasons) - please include
the relevant info in the cover letter or commit messages.
--
The evaluation is done by an LLM so it may be wrong, if you think
that is the case please reply and explain.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-12-02 9:48 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-02 9:44 [PATCH net] net: libwx: determine the device role without pci_dev::is_virtfn Mengyuan Lou
2026-12-02 9:48 ` netdev-bot+sinfo
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox