#include "mlx5_common.h"
#include "mlx5_common_log.h"
+#include "mlx5_common_os.h"
#include "mlx5_glue.h"
#ifdef MLX5_GLUE
mlx5_glue = NULL;
}
+struct ibv_device *
+mlx5_os_get_ibv_device(struct rte_pci_addr *addr)
+{
+ int n;
+ struct ibv_device **ibv_list = mlx5_glue->get_device_list(&n);
+ struct ibv_device *ibv_match = NULL;
+
+ if (ibv_list == NULL) {
+ rte_errno = ENOSYS;
+ return NULL;
+ }
+ while (n-- > 0) {
+ struct rte_pci_addr paddr;
+
+ DRV_LOG(DEBUG, "Checking device \"%s\"..", ibv_list[n]->name);
+ if (mlx5_dev_to_pci_addr(ibv_list[n]->ibdev_path, &paddr) != 0)
+ continue;
+ if (rte_pci_addr_cmp(addr, &paddr) != 0)
+ continue;
+ ibv_match = ibv_list[n];
+ break;
+ }
+ if (ibv_match == NULL)
+ rte_errno = ENOENT;
+ mlx5_glue->free_device_list(ibv_list);
+ return ibv_match;
+}
{
free(addr);
}
+
+__rte_internal
+struct ibv_device *
+mlx5_os_get_ibv_device(struct rte_pci_addr *addr);
+
#endif /* RTE_PMD_MLX5_COMMON_OS_H_ */
#include "mlx5_prm.h"
#include "mlx5_devx_cmds.h"
+#include "mlx5_common_os.h"
/* Reported driver name. */
#define MLX5_PCI_DRIVER_NAME "mlx5_pci"
mlx5_os_alloc_pd;
mlx5_os_dealloc_pd;
mlx5_os_dereg_mr;
+ mlx5_os_get_ibv_device; # WINDOWS_NO_EXPORT
mlx5_os_reg_mr;
mlx5_os_umem_dereg;
mlx5_os_umem_reg;
return i;
}
-static struct ibv_device *
-mlx5_compress_get_ib_device_match(struct rte_pci_addr *addr)
-{
- int n;
- struct ibv_device **ibv_list = mlx5_glue->get_device_list(&n);
- struct ibv_device *ibv_match = NULL;
-
- if (ibv_list == NULL) {
- rte_errno = ENOSYS;
- return NULL;
- }
- while (n-- > 0) {
- struct rte_pci_addr paddr;
-
- DRV_LOG(DEBUG, "Checking device \"%s\"..", ibv_list[n]->name);
- if (mlx5_dev_to_pci_addr(ibv_list[n]->ibdev_path, &paddr) != 0)
- continue;
- if (rte_pci_addr_cmp(addr, &paddr) != 0)
- continue;
- ibv_match = ibv_list[n];
- break;
- }
- if (ibv_match == NULL)
- rte_errno = ENOENT;
- mlx5_glue->free_device_list(ibv_list);
- return ibv_match;
-}
-
static void
mlx5_compress_hw_global_release(struct mlx5_compress_priv *priv)
{
rte_errno = ENOTSUP;
return -rte_errno;
}
- ibv = mlx5_compress_get_ib_device_match(&pci_dev->addr);
+ ibv = mlx5_os_get_ibv_device(&pci_dev->addr);
if (ibv == NULL) {
DRV_LOG(ERR, "No matching IB device for PCI slot "
PCI_PRI_FMT ".", pci_dev->addr.domain,
#include <rte_regexdev_driver.h>
#include <mlx5_common_pci.h>
+#include <mlx5_common.h>
#include <mlx5_glue.h>
#include <mlx5_devx_cmds.h>
#include <mlx5_prm.h>
return 0;
}
-static struct ibv_device *
-mlx5_regex_get_ib_device_match(struct rte_pci_addr *addr)
-{
- int n;
- struct ibv_device **ibv_list = mlx5_glue->get_device_list(&n);
- struct ibv_device *ibv_match = NULL;
-
- if (!ibv_list) {
- rte_errno = ENOSYS;
- return NULL;
- }
- while (n-- > 0) {
- struct rte_pci_addr pci_addr;
-
- DRV_LOG(DEBUG, "Checking device \"%s\"..", ibv_list[n]->name);
- if (mlx5_dev_to_pci_addr(ibv_list[n]->ibdev_path, &pci_addr))
- continue;
- if (rte_pci_addr_cmp(addr, &pci_addr))
- continue;
- ibv_match = ibv_list[n];
- break;
- }
- if (!ibv_match)
- rte_errno = ENOENT;
- mlx5_glue->free_device_list(ibv_list);
- return ibv_match;
-}
static int
mlx5_regex_engines_status(struct ibv_context *ctx, int num_engines)
{
int ret;
uint32_t val;
- ibv = mlx5_regex_get_ib_device_match(&pci_dev->addr);
+ ibv = mlx5_os_get_ibv_device(&pci_dev->addr);
if (!ibv) {
DRV_LOG(ERR, "No matching IB device for PCI slot "
PCI_PRI_FMT ".", pci_dev->addr.domain,
.reset_stats = mlx5_vdpa_reset_stats,
};
-static struct ibv_device *
-mlx5_vdpa_get_ib_device_match(struct rte_pci_addr *addr)
-{
- int n;
- struct ibv_device **ibv_list = mlx5_glue->get_device_list(&n);
- struct ibv_device *ibv_match = NULL;
-
- if (!ibv_list) {
- rte_errno = ENOSYS;
- return NULL;
- }
- while (n-- > 0) {
- struct rte_pci_addr pci_addr;
-
- DRV_LOG(DEBUG, "Checking device \"%s\"..", ibv_list[n]->name);
- if (mlx5_dev_to_pci_addr(ibv_list[n]->ibdev_path, &pci_addr))
- continue;
- if (rte_pci_addr_cmp(addr, &pci_addr))
- continue;
- ibv_match = ibv_list[n];
- break;
- }
- if (!ibv_match)
- rte_errno = ENOENT;
- mlx5_glue->free_device_list(ibv_list);
- return ibv_match;
-}
-
/* Try to disable ROCE by Netlink\Devlink. */
static int
mlx5_vdpa_nl_roce_disable(const char *addr)
struct ibv_device *ibv_new;
for (r = MLX5_VDPA_MAX_RETRIES; r; r--) {
- ibv_new = mlx5_vdpa_get_ib_device_match(addr);
+ ibv_new = mlx5_os_get_ibv_device(addr);
if (ibv_new) {
*ibv = ibv_new;
return 0;
struct mlx5_hca_attr attr;
int ret;
- ibv = mlx5_vdpa_get_ib_device_match(&pci_dev->addr);
+ ibv = mlx5_os_get_ibv_device(&pci_dev->addr);
if (!ibv) {
DRV_LOG(ERR, "No matching IB device for PCI slot "
PCI_PRI_FMT ".", pci_dev->addr.domain,