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 <michaelba@nvidia.com> Acked-by: Matan Azrad <matan@nvidia.com>
This commit is contained in:
parent
8f46481001
commit
c4c3e8afef
@ -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);
|
||||
|
@ -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)
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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) {
|
||||
|
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user