PCI: Add ACS quirk for Wangxun NICs
authorMengyuan Lou <mengyuanlou@net-swift.com>
Tue, 7 Feb 2023 10:24:19 +0000 (18:24 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 11 Mar 2023 12:57:38 +0000 (13:57 +0100)
[ Upstream commit a2b9b123ccac913e9f9b80337d687a2fe786a634 ]

Wangxun has verified there is no peer-to-peer between functions for the
below selection of SFxxx, RP1000 and RP2000 NICS.  They may be
multi-function devices, but the hardware does not advertise ACS capability.

Add an ACS quirk for these devices so the functions can be in independent
IOMMU groups.

Link: https://lore.kernel.org/r/20230207102419.44326-1-mengyuanlou@net-swift.com
Signed-off-by: Mengyuan Lou <mengyuanlou@net-swift.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/pci/quirks.c
include/linux/pci_ids.h

index 305ff5bd1a20cc8c1b486229bc87eb3539423c14..643a3b292f0b628361c701deccd56e3f0bd5b612 100644 (file)
@@ -4823,6 +4823,26 @@ static int pci_quirk_brcm_acs(struct pci_dev *dev, u16 acs_flags)
                PCI_ACS_SV | PCI_ACS_RR | PCI_ACS_CR | PCI_ACS_UF);
 }
 
+/*
+ * Wangxun 10G/1G NICs have no ACS capability, and on multi-function
+ * devices, peer-to-peer transactions are not be used between the functions.
+ * So add an ACS quirk for below devices to isolate functions.
+ * SFxxx 1G NICs(em).
+ * RP1000/RP2000 10G NICs(sp).
+ */
+static int  pci_quirk_wangxun_nic_acs(struct pci_dev *dev, u16 acs_flags)
+{
+       switch (dev->device) {
+       case 0x0100 ... 0x010F:
+       case 0x1001:
+       case 0x2001:
+               return pci_acs_ctrl_enabled(acs_flags,
+                       PCI_ACS_SV | PCI_ACS_RR | PCI_ACS_CR | PCI_ACS_UF);
+       }
+
+       return false;
+}
+
 static const struct pci_dev_acs_enabled {
        u16 vendor;
        u16 device;
@@ -4968,6 +4988,8 @@ static const struct pci_dev_acs_enabled {
        { PCI_VENDOR_ID_NXP, 0x8d9b, pci_quirk_nxp_rp_acs },
        /* Zhaoxin Root/Downstream Ports */
        { PCI_VENDOR_ID_ZHAOXIN, PCI_ANY_ID, pci_quirk_zhaoxin_pcie_ports_acs },
+       /* Wangxun nics */
+       { PCI_VENDOR_ID_WANGXUN, PCI_ANY_ID, pci_quirk_wangxun_nic_acs },
        { 0 }
 };
 
index 04f44a4694a2e784fda6f9e6c734944dae0b975d..4853538bf15618907bc8f66407810c15e2edde47 100644 (file)
 #define PCI_DEVICE_ID_INTEL_VMD_9A0B   0x9a0b
 #define PCI_DEVICE_ID_INTEL_S21152BB   0xb152
 
+#define PCI_VENDOR_ID_WANGXUN          0x8088
+
 #define PCI_VENDOR_ID_SCALEMP          0x8686
 #define PCI_DEVICE_ID_SCALEMP_VSMP_CTL 0x1010