From c4c3e8afefa8b7e7bc19073f9a159d50c75c8770 Mon Sep 17 00:00:00 2001 From: Michael Baum Date: Mon, 14 Feb 2022 11:35:01 +0200 Subject: [PATCH] common/mlx5: share VF check function 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 Acked-by: Matan Azrad --- drivers/common/mlx5/mlx5_common.h | 15 +++++++++++++++ drivers/common/mlx5/mlx5_common_pci.c | 18 ++++++++++++++++++ drivers/common/mlx5/version.map | 1 + drivers/net/mlx5/linux/mlx5_os.c | 18 +----------------- drivers/net/mlx5/windows/mlx5_os.c | 16 +--------------- 5 files changed, 36 insertions(+), 32 deletions(-) diff --git a/drivers/common/mlx5/mlx5_common.h b/drivers/common/mlx5/mlx5_common.h index e8809844af..80f59c81fb 100644 --- a/drivers/common/mlx5/mlx5_common.h +++ b/drivers/common/mlx5/mlx5_common.h @@ -8,6 +8,7 @@ #include #include +#include #include #include #include @@ -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); diff --git a/drivers/common/mlx5/mlx5_common_pci.c b/drivers/common/mlx5/mlx5_common_pci.c index 458630351c..66626953f1 100644 --- a/drivers/common/mlx5/mlx5_common_pci.c +++ b/drivers/common/mlx5/mlx5_common_pci.c @@ -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) diff --git a/drivers/common/mlx5/version.map b/drivers/common/mlx5/version.map index 462b7cea5e..59ab434631 100644 --- a/drivers/common/mlx5/version.map +++ b/drivers/common/mlx5/version.map @@ -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; diff --git a/drivers/net/mlx5/linux/mlx5_os.c b/drivers/net/mlx5/linux/mlx5_os.c index 2616668149..d1bf89922e 100644 --- a/drivers/net/mlx5/linux/mlx5_os.c +++ b/drivers/net/mlx5/linux/mlx5_os.c @@ -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, ð_da); if (!list[i].eth_dev) { diff --git a/drivers/net/mlx5/windows/mlx5_os.c b/drivers/net/mlx5/windows/mlx5_os.c index 9d25dcfa40..cca99f3eea 100644 --- a/drivers/net/mlx5/windows/mlx5_os.c +++ b/drivers/net/mlx5/windows/mlx5_os.c @@ -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; -- 2.39.5