Skip to content

Commit a04ea57

Browse files
Jiawen Wukuba-moo
authored andcommitted
net: libwx: fix device bus LAN ID
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: a34b3e6 ("net: txgbe: Store PCI info") Cc: stable@vger.kernel.org Signed-off-by: Jiawen Wu <jiawenwu@trustnetic.com> Reviewed-by: Simon Horman <horms@kernel.org> Link: https://patch.msgid.link/B60A670C1F52CB8E+20251104062321.40059-1-jiawenwu@trustnetic.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent b1d9154 commit a04ea57

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

drivers/net/ethernet/wangxun/libwx/wx_hw.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2427,7 +2427,8 @@ int wx_sw_init(struct wx *wx)
24272427
wx->oem_svid = pdev->subsystem_vendor;
24282428
wx->oem_ssid = pdev->subsystem_device;
24292429
wx->bus.device = PCI_SLOT(pdev->devfn);
2430-
wx->bus.func = PCI_FUNC(pdev->devfn);
2430+
wx->bus.func = FIELD_GET(WX_CFG_PORT_ST_LANID,
2431+
rd32(wx, WX_CFG_PORT_ST));
24312432

24322433
if (wx->oem_svid == PCI_VENDOR_ID_WANGXUN ||
24332434
pdev->is_virtfn) {

drivers/net/ethernet/wangxun/libwx/wx_type.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,8 @@
9797
#define WX_CFG_PORT_CTL_DRV_LOAD BIT(3)
9898
#define WX_CFG_PORT_CTL_QINQ BIT(2)
9999
#define WX_CFG_PORT_CTL_D_VLAN BIT(0) /* double vlan*/
100+
#define WX_CFG_PORT_ST 0x14404
101+
#define WX_CFG_PORT_ST_LANID GENMASK(9, 8)
100102
#define WX_CFG_TAG_TPID(_i) (0x14430 + ((_i) * 4))
101103
#define WX_CFG_PORT_CTL_NUM_VT_MASK GENMASK(13, 12) /* number of TVs */
102104

@@ -557,8 +559,6 @@ enum WX_MSCA_CMD_value {
557559
#define TXD_USE_COUNT(S) DIV_ROUND_UP((S), WX_MAX_DATA_PER_TXD)
558560
#define DESC_NEEDED (MAX_SKB_FRAGS + 4)
559561

560-
#define WX_CFG_PORT_ST 0x14404
561-
562562
/******************* Receive Descriptor bit definitions **********************/
563563
#define WX_RXD_STAT_DD BIT(0) /* Done */
564564
#define WX_RXD_STAT_EOP BIT(1) /* End of Packet */

0 commit comments

Comments
 (0)