* [PATCH net] net: libwx: fix device bus LAN ID
@ 2025-11-04 6:23 Jiawen Wu
2025-11-05 9:58 ` Simon Horman
2025-11-06 2:10 ` patchwork-bot+netdevbpf
0 siblings, 2 replies; 5+ messages in thread
From: Jiawen Wu @ 2025-11-04 6:23 UTC (permalink / raw)
To: netdev, Andrew Lunn, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Simon Horman
Cc: Mengyuan Lou, Jiawen Wu, stable
The device bus LAN ID was obtained from PCI_FUNC(), but when a PF
port is passthrough to a virtual machine, the function number may not
match the actual port index on the device. This could cause the driver
to perform operations such as LAN reset on the wrong port.
Fix this by reading the LAN ID from port status register.
Fixes: a34b3e6ed8fb ("net: txgbe: Store PCI info")
Cc: stable@vger.kernel.org
Signed-off-by: Jiawen Wu <jiawenwu@trustnetic.com>
---
drivers/net/ethernet/wangxun/libwx/wx_hw.c | 3 ++-
drivers/net/ethernet/wangxun/libwx/wx_type.h | 4 ++--
2 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/drivers/net/ethernet/wangxun/libwx/wx_hw.c b/drivers/net/ethernet/wangxun/libwx/wx_hw.c
index 814164459707..58b8300e3d2c 100644
--- a/drivers/net/ethernet/wangxun/libwx/wx_hw.c
+++ b/drivers/net/ethernet/wangxun/libwx/wx_hw.c
@@ -2480,7 +2480,8 @@ 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);
- wx->bus.func = PCI_FUNC(pdev->devfn);
+ 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) {
diff --git a/drivers/net/ethernet/wangxun/libwx/wx_type.h b/drivers/net/ethernet/wangxun/libwx/wx_type.h
index d0cbcded1dd4..b1a6ef5709a9 100644
--- a/drivers/net/ethernet/wangxun/libwx/wx_type.h
+++ b/drivers/net/ethernet/wangxun/libwx/wx_type.h
@@ -102,6 +102,8 @@
#define WX_CFG_PORT_CTL_DRV_LOAD BIT(3)
#define WX_CFG_PORT_CTL_QINQ BIT(2)
#define WX_CFG_PORT_CTL_D_VLAN BIT(0) /* double vlan*/
+#define WX_CFG_PORT_ST 0x14404
+#define WX_CFG_PORT_ST_LANID GENMASK(9, 8)
#define WX_CFG_TAG_TPID(_i) (0x14430 + ((_i) * 4))
#define WX_CFG_PORT_CTL_NUM_VT_MASK GENMASK(13, 12) /* number of TVs */
@@ -564,8 +566,6 @@ enum WX_MSCA_CMD_value {
#define TXD_USE_COUNT(S) DIV_ROUND_UP((S), WX_MAX_DATA_PER_TXD)
#define DESC_NEEDED (MAX_SKB_FRAGS + 4)
-#define WX_CFG_PORT_ST 0x14404
-
/******************* Receive Descriptor bit definitions **********************/
#define WX_RXD_STAT_DD BIT(0) /* Done */
#define WX_RXD_STAT_EOP BIT(1) /* End of Packet */
--
2.48.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH net] net: libwx: fix device bus LAN ID
2025-11-04 6:23 [PATCH net] net: libwx: fix device bus LAN ID Jiawen Wu
@ 2025-11-05 9:58 ` Simon Horman
2025-11-05 10:05 ` Jiawen Wu
2025-11-06 2:10 ` patchwork-bot+netdevbpf
1 sibling, 1 reply; 5+ messages in thread
From: Simon Horman @ 2025-11-05 9:58 UTC (permalink / raw)
To: Jiawen Wu
Cc: netdev, Andrew Lunn, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Mengyuan Lou, stable
On Tue, Nov 04, 2025 at 02:23:21PM +0800, Jiawen Wu wrote:
> The device bus LAN ID was obtained from PCI_FUNC(), but when a PF
> port is passthrough to a virtual machine, the function number may not
> match the actual port index on the device. This could cause the driver
> to perform operations such as LAN reset on the wrong port.
>
> Fix this by reading the LAN ID from port status register.
>
> Fixes: a34b3e6ed8fb ("net: txgbe: Store PCI info")
> Cc: stable@vger.kernel.org
> Signed-off-by: Jiawen Wu <jiawenwu@trustnetic.com>
Hi Jiawen Wu,
I am wondering if these devises also support port swapping (maybe LAN
Function Select bit of FACTPS). And if so, does it need to be taken into
account here?
...
^ permalink raw reply [flat|nested] 5+ messages in thread
* RE: [PATCH net] net: libwx: fix device bus LAN ID
2025-11-05 9:58 ` Simon Horman
@ 2025-11-05 10:05 ` Jiawen Wu
2025-11-05 11:47 ` Simon Horman
0 siblings, 1 reply; 5+ messages in thread
From: Jiawen Wu @ 2025-11-05 10:05 UTC (permalink / raw)
To: 'Simon Horman'
Cc: netdev, 'Andrew Lunn', 'David S. Miller',
'Eric Dumazet', 'Jakub Kicinski',
'Paolo Abeni', 'Mengyuan Lou', stable
On Wed, Nov 5, 2025 5:59 PM, Simon Horman wrote:
> On Tue, Nov 04, 2025 at 02:23:21PM +0800, Jiawen Wu wrote:
> > The device bus LAN ID was obtained from PCI_FUNC(), but when a PF
> > port is passthrough to a virtual machine, the function number may not
> > match the actual port index on the device. This could cause the driver
> > to perform operations such as LAN reset on the wrong port.
> >
> > Fix this by reading the LAN ID from port status register.
> >
> > Fixes: a34b3e6ed8fb ("net: txgbe: Store PCI info")
> > Cc: stable@vger.kernel.org
> > Signed-off-by: Jiawen Wu <jiawenwu@trustnetic.com>
>
> Hi Jiawen Wu,
>
> I am wondering if these devises also support port swapping (maybe LAN
> Function Select bit of FACTPS). And if so, does it need to be taken into
> account here?
Does not support yet, thanks. :)
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH net] net: libwx: fix device bus LAN ID
2025-11-05 10:05 ` Jiawen Wu
@ 2025-11-05 11:47 ` Simon Horman
0 siblings, 0 replies; 5+ messages in thread
From: Simon Horman @ 2025-11-05 11:47 UTC (permalink / raw)
To: Jiawen Wu
Cc: netdev, 'Andrew Lunn', 'David S. Miller',
'Eric Dumazet', 'Jakub Kicinski',
'Paolo Abeni', 'Mengyuan Lou', stable
On Wed, Nov 05, 2025 at 06:05:29PM +0800, Jiawen Wu wrote:
> On Wed, Nov 5, 2025 5:59 PM, Simon Horman wrote:
> > On Tue, Nov 04, 2025 at 02:23:21PM +0800, Jiawen Wu wrote:
> > > The device bus LAN ID was obtained from PCI_FUNC(), but when a PF
> > > port is passthrough to a virtual machine, the function number may not
> > > match the actual port index on the device. This could cause the driver
> > > to perform operations such as LAN reset on the wrong port.
> > >
> > > Fix this by reading the LAN ID from port status register.
> > >
> > > Fixes: a34b3e6ed8fb ("net: txgbe: Store PCI info")
> > > Cc: stable@vger.kernel.org
> > > Signed-off-by: Jiawen Wu <jiawenwu@trustnetic.com>
> >
> > Hi Jiawen Wu,
> >
> > I am wondering if these devises also support port swapping (maybe LAN
> > Function Select bit of FACTPS). And if so, does it need to be taken into
> > account here?
>
> Does not support yet, thanks. :)
Thanks, in that case this patch looks good to me.
Reviewed-by: Simon Horman <horms@kernel.org>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH net] net: libwx: fix device bus LAN ID
2025-11-04 6:23 [PATCH net] net: libwx: fix device bus LAN ID Jiawen Wu
2025-11-05 9:58 ` Simon Horman
@ 2025-11-06 2:10 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 5+ messages in thread
From: patchwork-bot+netdevbpf @ 2025-11-06 2:10 UTC (permalink / raw)
To: Jiawen Wu
Cc: netdev, andrew+netdev, davem, edumazet, kuba, pabeni, horms,
mengyuanlou, stable
Hello:
This patch was applied to netdev/net.git (main)
by Jakub Kicinski <kuba@kernel.org>:
On Tue, 4 Nov 2025 14:23:21 +0800 you wrote:
> The device bus LAN ID was obtained from PCI_FUNC(), but when a PF
> port is passthrough to a virtual machine, the function number may not
> match the actual port index on the device. This could cause the driver
> to perform operations such as LAN reset on the wrong port.
>
> Fix this by reading the LAN ID from port status register.
>
> [...]
Here is the summary with links:
- [net] net: libwx: fix device bus LAN ID
https://git.kernel.org/netdev/net/c/a04ea57aae37
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2025-11-06 2:10 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-11-04 6:23 [PATCH net] net: libwx: fix device bus LAN ID Jiawen Wu
2025-11-05 9:58 ` Simon Horman
2025-11-05 10:05 ` Jiawen Wu
2025-11-05 11:47 ` Simon Horman
2025-11-06 2:10 ` patchwork-bot+netdevbpf
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).