1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright 2020 Mellanox Technologies, Ltd
11 #include <rte_windows.h>
13 #include <mlx5_glue.h>
14 #include <mlx5_devx_cmds.h>
15 #include <mlx5_common.h>
17 #include "mlx5_defs.h"
19 #include "mlx5_autoconf.h"
22 * Get mlx5 device attributes.
25 * Pointer to device context.
28 * Pointer to mlx5 device attributes.
31 * 0 on success, non zero error number otherwise
34 mlx5_os_get_dev_attr(void *ctx, struct mlx5_dev_attr *device_attr)
36 struct mlx5_context *mlx5_ctx;
37 struct mlx5_hca_attr hca_attr;
44 mlx5_ctx = (struct mlx5_context *)ctx;
45 memset(device_attr, 0, sizeof(*device_attr));
46 err = mlx5_devx_cmd_query_hca_attr(mlx5_ctx, &hca_attr);
48 DRV_LOG(ERR, "Failed to get device hca_cap");
51 device_attr->max_cq = 1 << hca_attr.log_max_cq;
52 device_attr->max_qp = 1 << hca_attr.log_max_qp;
53 device_attr->max_qp_wr = 1 << hca_attr.log_max_qp_sz;
54 device_attr->max_cqe = 1 << hca_attr.log_max_cq_sz;
55 device_attr->max_mr = 1 << hca_attr.log_max_mrw_sz;
56 device_attr->max_pd = 1 << hca_attr.log_max_pd;
57 device_attr->max_srq = 1 << hca_attr.log_max_srq;
58 device_attr->max_srq_wr = 1 << hca_attr.log_max_srq_sz;
59 if (hca_attr.rss_ind_tbl_cap) {
60 device_attr->max_rwq_indirection_table_size =
61 1 << hca_attr.rss_ind_tbl_cap;
63 pv_iseg = mlx5_glue->query_hca_iseg(mlx5_ctx, &cb_iseg);
64 if (pv_iseg == NULL) {
65 DRV_LOG(ERR, "Failed to get device hca_iseg");
69 snprintf(device_attr->fw_ver, 64, "%x.%x.%04x",
70 MLX5_GET(initial_seg, pv_iseg, fw_rev_major),
71 MLX5_GET(initial_seg, pv_iseg, fw_rev_minor),
72 MLX5_GET(initial_seg, pv_iseg, fw_rev_subminor));