]> git.droids-corp.org - dpdk.git/commitdiff
common/mlx5: share VF check function
authorMichael Baum <michaelba@nvidia.com>
Mon, 14 Feb 2022 09:35:01 +0000 (11:35 +0200)
committerRaslan Darawsheh <rasland@nvidia.com>
Mon, 21 Feb 2022 10:36:46 +0000 (11:36 +0100)
The check if device is VF work for Linux as same as Windows.
This patch removes it to the function implemented in the folder shared
between the operating systems, removing the duplication.

Signed-off-by: Michael Baum <michaelba@nvidia.com>
Acked-by: Matan Azrad <matan@nvidia.com>
drivers/common/mlx5/mlx5_common.h
drivers/common/mlx5/mlx5_common_pci.c
drivers/common/mlx5/version.map
drivers/net/mlx5/linux/mlx5_os.c
drivers/net/mlx5/windows/mlx5_os.c

index e8809844afadd2f9f7283050c152b7eff2c1873c..80f59c81fb18d6d0166ec63797e7d4b79ff3945a 100644 (file)
@@ -8,6 +8,7 @@
 #include <stdio.h>
 
 #include <rte_pci.h>
+#include <rte_bus_pci.h>
 #include <rte_debug.h>
 #include <rte_atomic.h>
 #include <rte_rwlock.h>
@@ -487,6 +488,20 @@ __rte_internal
 bool
 mlx5_dev_is_pci(const struct rte_device *dev);
 
+/**
+ * Test PCI device is a VF device.
+ *
+ * @param pci_dev
+ *   Pointer to PCI device.
+ *
+ * @return
+ *   - True on PCI device is a VF device.
+ *   - False otherwise.
+ */
+__rte_internal
+bool
+mlx5_dev_is_vf_pci(struct rte_pci_device *pci_dev);
+
 __rte_internal
 int
 mlx5_dev_mempool_subscribe(struct mlx5_common_device *cdev);
index 458630351cd168b08884c0dcb2590034eb413bd1..66626953f1971d41af71a807abe9213ac89139db 100644 (file)
@@ -107,6 +107,24 @@ mlx5_dev_is_pci(const struct rte_device *dev)
        return strcmp(dev->bus->name, "pci") == 0;
 }
 
+bool
+mlx5_dev_is_vf_pci(struct rte_pci_device *pci_dev)
+{
+       switch (pci_dev->id.device_id) {
+       case PCI_DEVICE_ID_MELLANOX_CONNECTX4VF:
+       case PCI_DEVICE_ID_MELLANOX_CONNECTX4LXVF:
+       case PCI_DEVICE_ID_MELLANOX_CONNECTX5VF:
+       case PCI_DEVICE_ID_MELLANOX_CONNECTX5EXVF:
+       case PCI_DEVICE_ID_MELLANOX_CONNECTX5BFVF:
+       case PCI_DEVICE_ID_MELLANOX_CONNECTX6VF:
+       case PCI_DEVICE_ID_MELLANOX_CONNECTXVF:
+               return true;
+       default:
+               break;
+       }
+       return false;
+}
+
 bool
 mlx5_dev_pci_match(const struct mlx5_class_driver *drv,
                   const struct rte_device *dev)
index 462b7cea5e0e380377a2fa10633d92283c3d60ab..59ab434631e1aa0a27d6b12f5996bf9f82037db4 100644 (file)
@@ -13,6 +13,7 @@ INTERNAL {
        mlx5_common_verbs_dereg_mr; # WINDOWS_NO_EXPORT
 
        mlx5_dev_is_pci;
+       mlx5_dev_is_vf_pci;
        mlx5_dev_mempool_unregister;
        mlx5_dev_mempool_subscribe;
 
index 2616668149b00b1db9c85599649770d5bbbe0e56..d1bf89922ed480c17d43b034f14b407bbc28ad18 100644 (file)
@@ -2100,7 +2100,6 @@ mlx5_os_pci_probe_pf(struct mlx5_common_device *cdev,
        struct rte_pci_device *pci_dev = RTE_DEV_TO_PCI(cdev->dev);
        struct mlx5_dev_spawn_data *list = NULL;
        struct mlx5_dev_config dev_config;
-       unsigned int dev_config_vf;
        struct rte_eth_devargs eth_da = *req_eth_da;
        struct rte_pci_addr owner_pci = pci_dev->addr; /* Owner PF. */
        struct mlx5_bond_info bond_info;
@@ -2421,21 +2420,6 @@ mlx5_os_pci_probe_pf(struct mlx5_common_device *cdev,
         * (i.e. master first, then representors from lowest to highest ID).
         */
        qsort(list, ns, sizeof(*list), mlx5_dev_spawn_data_cmp);
-       /* Device specific configuration. */
-       switch (pci_dev->id.device_id) {
-       case PCI_DEVICE_ID_MELLANOX_CONNECTX4VF:
-       case PCI_DEVICE_ID_MELLANOX_CONNECTX4LXVF:
-       case PCI_DEVICE_ID_MELLANOX_CONNECTX5VF:
-       case PCI_DEVICE_ID_MELLANOX_CONNECTX5EXVF:
-       case PCI_DEVICE_ID_MELLANOX_CONNECTX5BFVF:
-       case PCI_DEVICE_ID_MELLANOX_CONNECTX6VF:
-       case PCI_DEVICE_ID_MELLANOX_CONNECTXVF:
-               dev_config_vf = 1;
-               break;
-       default:
-               dev_config_vf = 0;
-               break;
-       }
        if (eth_da.type != RTE_ETH_REPRESENTOR_NONE) {
                /* Set devargs default values. */
                if (eth_da.nb_mh_controllers == 0) {
@@ -2459,7 +2443,7 @@ mlx5_os_pci_probe_pf(struct mlx5_common_device *cdev,
 
                /* Default configuration. */
                mlx5_os_config_default(&dev_config, &cdev->config);
-               dev_config.vf = dev_config_vf;
+               dev_config.vf = mlx5_dev_is_vf_pci(pci_dev);
                list[i].eth_dev = mlx5_dev_spawn(cdev->dev, &list[i],
                                                 &dev_config, &eth_da);
                if (!list[i].eth_dev) {
index 9d25dcfa4050a4b873778fcc4deb4c27ab935564..cca99f3eea234efe6c018a6f81a393caacd55505 100644 (file)
@@ -926,6 +926,7 @@ mlx5_os_net_probe(struct mlx5_common_device *cdev)
                },
                .dv_flow_en = 1,
                .log_hp_size = MLX5_ARG_UNSET,
+               .vf = mlx5_dev_is_vf_pci(pci_dev),
        };
        int ret;
        uint32_t restore;
@@ -940,21 +941,6 @@ mlx5_os_net_probe(struct mlx5_common_device *cdev)
                        strerror(rte_errno));
                return -rte_errno;
        }
-       /* Device specific configuration. */
-       switch (pci_dev->id.device_id) {
-       case PCI_DEVICE_ID_MELLANOX_CONNECTX4VF:
-       case PCI_DEVICE_ID_MELLANOX_CONNECTX4LXVF:
-       case PCI_DEVICE_ID_MELLANOX_CONNECTX5VF:
-       case PCI_DEVICE_ID_MELLANOX_CONNECTX5EXVF:
-       case PCI_DEVICE_ID_MELLANOX_CONNECTX5BFVF:
-       case PCI_DEVICE_ID_MELLANOX_CONNECTX6VF:
-       case PCI_DEVICE_ID_MELLANOX_CONNECTXVF:
-               dev_config.vf = 1;
-               break;
-       default:
-               dev_config.vf = 0;
-               break;
-       }
        spawn.eth_dev = mlx5_dev_spawn(cdev->dev, &spawn, &dev_config);
        if (!spawn.eth_dev)
                return -rte_errno;