MCPcopy Create free account
hub / github.com/F-Stack/f-stack / mlx5_open_device

Function mlx5_open_device

dpdk/drivers/common/mlx5/linux/mlx5_common_os.c:778–821  ·  view source on GitHub ↗

* Function API to open IB device. * * @param cdev * Pointer to the mlx5 device. * @param classes * Chosen classes come from device arguments. * * @return * Pointer to ibv_context on success, NULL otherwise and rte_errno is set. */

Source from the content-addressed store, hash-verified

776 * Pointer to ibv_context on success, NULL otherwise and rte_errno is set.
777 */
778static struct ibv_context *
779mlx5_open_device(struct mlx5_common_device *cdev, uint32_t classes)
780{
781 struct ibv_device *ibv;
782 struct ibv_context *ctx = NULL;
783 int dbmap_env;
784
785 MLX5_ASSERT(cdev->config.device_fd == MLX5_ARG_UNSET);
786 if (classes & MLX5_CLASS_VDPA)
787 ibv = mlx5_vdpa_get_ibv_dev(cdev->dev);
788 else
789 ibv = mlx5_os_get_ibv_dev(cdev->dev);
790 if (!ibv)
791 return NULL;
792 DRV_LOG(INFO, "Dev information matches for device \"%s\".", ibv->name);
793 /*
794 * Configure environment variable "MLX5_BF_SHUT_UP" before the device
795 * creation. The rdma_core library checks the variable at device
796 * creation and stores the result internally.
797 */
798 dbmap_env = mlx5_config_doorbell_mapping_env(cdev->config.dbnc);
799 /* Try to open IB device with DV first, then usual Verbs. */
800 errno = 0;
801 ctx = mlx5_glue->dv_open_device(ibv);
802 if (ctx) {
803 cdev->config.devx = 1;
804 } else if (classes == MLX5_CLASS_ETH) {
805 /* The environment variable is still configured. */
806 ctx = mlx5_glue->open_device(ibv);
807 if (ctx == NULL)
808 goto error;
809 } else {
810 goto error;
811 }
812 /* The device is created, no need for environment. */
813 mlx5_restore_doorbell_mapping_env(dbmap_env);
814 return ctx;
815error:
816 rte_errno = errno ? errno : ENODEV;
817 /* The device creation is failed, no need for environment. */
818 mlx5_restore_doorbell_mapping_env(dbmap_env);
819 DRV_LOG(ERR, "Failed to open IB device \"%s\".", ibv->name);
820 return NULL;
821}
822
823/**
824 * Function API to import IB device.

Callers 1

mlx5_os_open_deviceFunction · 0.85

Calls 4

mlx5_vdpa_get_ibv_devFunction · 0.85
mlx5_os_get_ibv_devFunction · 0.85

Tested by

no test coverage detected