* Initialize all HW global of device context. * * @param cdev * Pointer to mlx5 device structure. * @param classes * Chosen classes come from user device arguments. * * @return * 0 on success, a negative errno value otherwise and rte_errno is set. */
| 690 | * 0 on success, a negative errno value otherwise and rte_errno is set. |
| 691 | */ |
| 692 | static int |
| 693 | mlx5_dev_hw_global_prepare(struct mlx5_common_device *cdev, uint32_t classes) |
| 694 | { |
| 695 | int ret; |
| 696 | |
| 697 | /* Create context device */ |
| 698 | ret = mlx5_os_open_device(cdev, classes); |
| 699 | if (ret < 0) |
| 700 | return ret; |
| 701 | /* |
| 702 | * When CTX is created by Verbs, query HCA attribute is unsupported. |
| 703 | * When CTX is imported, we cannot know if it is created by DevX or |
| 704 | * Verbs. So, we use query HCA attribute function to check it. |
| 705 | */ |
| 706 | if (cdev->config.devx || cdev->config.device_fd != MLX5_ARG_UNSET) { |
| 707 | /* Query HCA attributes. */ |
| 708 | ret = mlx5_devx_cmd_query_hca_attr(cdev->ctx, |
| 709 | &cdev->config.hca_attr); |
| 710 | if (ret) { |
| 711 | DRV_LOG(ERR, "Unable to read HCA caps in DevX mode."); |
| 712 | rte_errno = ENOTSUP; |
| 713 | goto error; |
| 714 | } |
| 715 | cdev->config.devx = 1; |
| 716 | } |
| 717 | DRV_LOG(DEBUG, "DevX is %ssupported.", cdev->config.devx ? "" : "NOT "); |
| 718 | /* Prepare Protection Domain object and extract its pdn. */ |
| 719 | ret = mlx5_os_pd_prepare(cdev); |
| 720 | if (ret) |
| 721 | goto error; |
| 722 | return 0; |
| 723 | error: |
| 724 | mlx5_dev_hw_global_release(cdev); |
| 725 | return ret; |
| 726 | } |
| 727 | |
| 728 | static void |
| 729 | mlx5_common_dev_release(struct mlx5_common_device *cdev) |
no test coverage detected