@@ -259,6 +259,8 @@ static int mlx4_init_context(struct verbs_device *v_device,
verbs_set_ctx_op(verbs_ctx, create_wq, mlx4_create_wq);
verbs_set_ctx_op(verbs_ctx, modify_wq, mlx4_modify_wq);
verbs_set_ctx_op(verbs_ctx, destroy_wq, mlx4_destroy_wq);
+ verbs_set_ctx_op(verbs_ctx, create_rwq_ind_table, mlx4_create_rwq_ind_table);
+ verbs_set_ctx_op(verbs_ctx, destroy_rwq_ind_table, mlx4_destroy_rwq_ind_table);
return 0;
@@ -411,5 +411,8 @@ struct ibv_wq *mlx4_create_wq(struct ibv_context *context,
struct ibv_wq_init_attr *attr);
int mlx4_modify_wq(struct ibv_wq *wq, struct ibv_wq_attr *attr);
int mlx4_destroy_wq(struct ibv_wq *wq);
+struct ibv_rwq_ind_table *mlx4_create_rwq_ind_table(struct ibv_context *context,
+ struct ibv_rwq_ind_table_init_attr *init_attr);
+int mlx4_destroy_rwq_ind_table(struct ibv_rwq_ind_table *rwq_ind_table);
#endif /* MLX4_H */
@@ -1441,3 +1441,58 @@ int mlx4_destroy_wq(struct ibv_wq *ibwq)
return 0;
}
+
+struct ibv_rwq_ind_table *mlx4_create_rwq_ind_table(struct ibv_context *context,
+ struct ibv_rwq_ind_table_init_attr *init_attr)
+{
+ struct ibv_create_rwq_ind_table *cmd;
+ struct ibv_create_rwq_ind_table_resp resp = {};
+ struct ibv_rwq_ind_table *ind_table;
+ uint32_t required_tbl_size;
+ unsigned int num_tbl_entries;
+ int cmd_size;
+ int err;
+
+ num_tbl_entries = 1 << init_attr->log_ind_tbl_size;
+ /* Data must be u64 aligned */
+ required_tbl_size =
+ (num_tbl_entries * sizeof(uint32_t)) < sizeof(uint64_t) ?
+ sizeof(uint64_t) : (num_tbl_entries * sizeof(uint32_t));
+
+ cmd_size = required_tbl_size + sizeof(*cmd);
+ cmd = calloc(1, cmd_size);
+ if (!cmd)
+ return NULL;
+
+ ind_table = calloc(1, sizeof(*ind_table));
+ if (!ind_table)
+ goto free_cmd;
+
+ err = ibv_cmd_create_rwq_ind_table(context, init_attr, ind_table, cmd,
+ cmd_size, cmd_size, &resp,
+ sizeof(resp), sizeof(resp));
+ if (err)
+ goto err;
+
+ free(cmd);
+ return ind_table;
+
+err:
+ free(ind_table);
+free_cmd:
+ free(cmd);
+ return NULL;
+}
+
+int mlx4_destroy_rwq_ind_table(struct ibv_rwq_ind_table *rwq_ind_table)
+{
+ int ret;
+
+ ret = ibv_cmd_destroy_rwq_ind_table(rwq_ind_table);
+
+ if (ret && !cleanup_on_fatal(ret))
+ return ret;
+
+ free(rwq_ind_table);
+ return 0;
+}