]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
net: libwx: fix device bus LAN ID
authorJiawen Wu <jiawenwu@trustnetic.com>
Tue, 4 Nov 2025 06:23:21 +0000 (14:23 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 13 Nov 2025 20:34:36 +0000 (15:34 -0500)
commit a04ea57aae375bdda1cb57034d8bcbb351e1f973 upstream.

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>
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>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/net/ethernet/wangxun/libwx/wx_hw.c
drivers/net/ethernet/wangxun/libwx/wx_type.h

index e79220cb725b09329c9d1340189132f98cad8cbc..19b36d308d292b21fa67f81d97c66fecba68b242 100644 (file)
@@ -1943,7 +1943,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) {
                wx->subsystem_vendor_id = pdev->subsystem_vendor;
index 950cacaf095a926a2c0331e9fb60dd12052e6c58..627dcb0151c78e7cc749704c5975a8f36a48243e 100644 (file)
@@ -85,6 +85,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 */
 
@@ -451,8 +453,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 */