mlxsw: pci: Fix reset wait for SwitchX2
[cascardo/linux.git] / drivers / net / ethernet / mellanox / mlxsw / pci.c
index cb95f9a..912f71f 100644 (file)
@@ -1162,6 +1162,10 @@ mlxsw_pci_config_profile_swid_config(struct mlxsw_pci *mlxsw_pci,
 #define MLXSW_KVD_SINGLE_MIN_SIZE_ID 0x1002
 #define MLXSW_KVD_DOUBLE_MIN_SIZE_ID 0x1003
 #define MLXSW_MAX_VIRTUAL_ROUTERS_ID 0x2C01
+#define MLXSW_MAX_SYSTEM_PORT_ID 0x2502
+#define MLXSW_MAX_VLAN_GROUPS_ID 0x2906
+#define MLXSW_MAX_REGIONS_ID 0x2901
+#define MLXSW_MAX_RIF_ID 0x2C02
 #define MLXSW_RESOURCES_QUERY_MAX_QUERIES 100
 #define MLXSW_RESOURCES_PER_QUERY 32
 
@@ -1197,6 +1201,22 @@ static void mlxsw_pci_resources_query_parse(int id, u64 val,
                resources->max_virtual_routers = val;
                resources->max_virtual_routers_valid = 1;
                break;
+       case MLXSW_MAX_SYSTEM_PORT_ID:
+               resources->max_system_ports = val;
+               resources->max_system_ports_valid = 1;
+               break;
+       case MLXSW_MAX_VLAN_GROUPS_ID:
+               resources->max_vlan_groups = val;
+               resources->max_vlan_groups_valid = 1;
+               break;
+       case MLXSW_MAX_REGIONS_ID:
+               resources->max_regions = val;
+               resources->max_regions_valid = 1;
+               break;
+       case MLXSW_MAX_RIF_ID:
+               resources->max_rif = val;
+               resources->max_rif_valid = 1;
+               break;
        default:
                break;
        }
@@ -1818,11 +1838,17 @@ static const struct mlxsw_bus mlxsw_pci_bus = {
        .cmd_exec               = mlxsw_pci_cmd_exec,
 };
 
-static int mlxsw_pci_sw_reset(struct mlxsw_pci *mlxsw_pci)
+static int mlxsw_pci_sw_reset(struct mlxsw_pci *mlxsw_pci,
+                             const struct pci_device_id *id)
 {
        unsigned long end;
 
        mlxsw_pci_write32(mlxsw_pci, SW_RESET, MLXSW_PCI_SW_RESET_RST_BIT);
+       if (id->device == PCI_DEVICE_ID_MELLANOX_SWITCHX2) {
+               msleep(MLXSW_PCI_SW_RESET_TIMEOUT_MSECS);
+               return 0;
+       }
+
        wmb(); /* reset needs to be written before we read control register */
        end = jiffies + msecs_to_jiffies(MLXSW_PCI_SW_RESET_TIMEOUT_MSECS);
        do {
@@ -1889,7 +1915,7 @@ static int mlxsw_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
        mlxsw_pci->pdev = pdev;
        pci_set_drvdata(pdev, mlxsw_pci);
 
-       err = mlxsw_pci_sw_reset(mlxsw_pci);
+       err = mlxsw_pci_sw_reset(mlxsw_pci, id);
        if (err) {
                dev_err(&pdev->dev, "Software reset failed\n");
                goto err_sw_reset;