net/octeontx2: support 96xx A1 silicon revision
[dpdk.git] / drivers / net / mlx5 / mlx5_devx_cmds.c
index e8953bb..acfe1de 100644 (file)
@@ -576,3 +576,129 @@ mlx5_devx_cmd_modify_rq(struct mlx5_devx_obj *rq,
        }
        return ret;
 }
+
+/**
+ * Create TIR using DevX API.
+ *
+ * @param[in] ctx
+ *   ibv_context returned from mlx5dv_open_device.
+ * @param [in] tir_attr
+ *   Pointer to TIR attributes structure.
+ *
+ * @return
+ *   The DevX object created, NULL otherwise and rte_errno is set.
+ */
+struct mlx5_devx_obj *
+mlx5_devx_cmd_create_tir(struct ibv_context *ctx,
+                        struct mlx5_devx_tir_attr *tir_attr)
+{
+       uint32_t in[MLX5_ST_SZ_DW(create_tir_in)] = {0};
+       uint32_t out[MLX5_ST_SZ_DW(create_tir_out)] = {0};
+       void *tir_ctx, *outer, *inner;
+       struct mlx5_devx_obj *tir = NULL;
+       int i;
+
+       tir = rte_calloc(__func__, 1, sizeof(*tir), 0);
+       if (!tir) {
+               DRV_LOG(ERR, "Failed to allocate TIR data");
+               rte_errno = ENOMEM;
+               return NULL;
+       }
+       MLX5_SET(create_tir_in, in, opcode, MLX5_CMD_OP_CREATE_TIR);
+       tir_ctx = MLX5_ADDR_OF(create_tir_in, in, ctx);
+       MLX5_SET(tirc, tir_ctx, disp_type, tir_attr->disp_type);
+       MLX5_SET(tirc, tir_ctx, lro_timeout_period_usecs,
+                tir_attr->lro_timeout_period_usecs);
+       MLX5_SET(tirc, tir_ctx, lro_enable_mask, tir_attr->lro_enable_mask);
+       MLX5_SET(tirc, tir_ctx, lro_max_msg_sz, tir_attr->lro_max_msg_sz);
+       MLX5_SET(tirc, tir_ctx, inline_rqn, tir_attr->inline_rqn);
+       MLX5_SET(tirc, tir_ctx, rx_hash_symmetric, tir_attr->rx_hash_symmetric);
+       MLX5_SET(tirc, tir_ctx, tunneled_offload_en,
+                tir_attr->tunneled_offload_en);
+       MLX5_SET(tirc, tir_ctx, indirect_table, tir_attr->indirect_table);
+       MLX5_SET(tirc, tir_ctx, rx_hash_fn, tir_attr->rx_hash_fn);
+       MLX5_SET(tirc, tir_ctx, self_lb_block, tir_attr->self_lb_block);
+       MLX5_SET(tirc, tir_ctx, transport_domain, tir_attr->transport_domain);
+       for (i = 0; i < 10; i++) {
+               MLX5_SET(tirc, tir_ctx, rx_hash_toeplitz_key[i],
+                        tir_attr->rx_hash_toeplitz_key[i]);
+       }
+       outer = MLX5_ADDR_OF(tirc, tir_ctx, rx_hash_field_selector_outer);
+       MLX5_SET(rx_hash_field_select, outer, l3_prot_type,
+                tir_attr->rx_hash_field_selector_outer.l3_prot_type);
+       MLX5_SET(rx_hash_field_select, outer, l4_prot_type,
+                tir_attr->rx_hash_field_selector_outer.l4_prot_type);
+       MLX5_SET(rx_hash_field_select, outer, selected_fields,
+                tir_attr->rx_hash_field_selector_outer.selected_fields);
+       inner = MLX5_ADDR_OF(tirc, tir_ctx, rx_hash_field_selector_inner);
+       MLX5_SET(rx_hash_field_select, inner, l3_prot_type,
+                tir_attr->rx_hash_field_selector_inner.l3_prot_type);
+       MLX5_SET(rx_hash_field_select, inner, l4_prot_type,
+                tir_attr->rx_hash_field_selector_inner.l4_prot_type);
+       MLX5_SET(rx_hash_field_select, inner, selected_fields,
+                tir_attr->rx_hash_field_selector_inner.selected_fields);
+       tir->obj = mlx5_glue->devx_obj_create(ctx, in, sizeof(in),
+                                                  out, sizeof(out));
+       if (!tir->obj) {
+               DRV_LOG(ERR, "Failed to create TIR using DevX");
+               rte_errno = errno;
+               rte_free(tir);
+               return NULL;
+       }
+       tir->id = MLX5_GET(create_tir_out, out, tirn);
+       return tir;
+}
+
+/**
+ * Create RQT using DevX API.
+ *
+ * @param[in] ctx
+ *   ibv_context returned from mlx5dv_open_device.
+ * @param [in] rqt_attr
+ *   Pointer to RQT attributes structure.
+ *
+ * @return
+ *   The DevX object created, NULL otherwise and rte_errno is set.
+ */
+struct mlx5_devx_obj *
+mlx5_devx_cmd_create_rqt(struct ibv_context *ctx,
+                        struct mlx5_devx_rqt_attr *rqt_attr)
+{
+       uint32_t *in = NULL;
+       uint32_t inlen = MLX5_ST_SZ_BYTES(create_rqt_in) +
+                        rqt_attr->rqt_actual_size * sizeof(uint32_t);
+       uint32_t out[MLX5_ST_SZ_DW(create_rqt_out)] = {0};
+       void *rqt_ctx;
+       struct mlx5_devx_obj *rqt = NULL;
+       int i;
+
+       in = rte_calloc(__func__, 1, inlen, 0);
+       if (!in) {
+               DRV_LOG(ERR, "Failed to allocate RQT IN data");
+               rte_errno = ENOMEM;
+               return NULL;
+       }
+       rqt = rte_calloc(__func__, 1, sizeof(*rqt), 0);
+       if (!rqt) {
+               DRV_LOG(ERR, "Failed to allocate RQT data");
+               rte_errno = ENOMEM;
+               rte_free(in);
+               return NULL;
+       }
+       MLX5_SET(create_rqt_in, in, opcode, MLX5_CMD_OP_CREATE_RQT);
+       rqt_ctx = MLX5_ADDR_OF(create_rqt_in, in, rqt_context);
+       MLX5_SET(rqtc, rqt_ctx, rqt_max_size, rqt_attr->rqt_max_size);
+       MLX5_SET(rqtc, rqt_ctx, rqt_actual_size, rqt_attr->rqt_actual_size);
+       for (i = 0; i < rqt_attr->rqt_actual_size; i++)
+               MLX5_SET(rqtc, rqt_ctx, rq_num[i], rqt_attr->rq_list[i]);
+       rqt->obj = mlx5_glue->devx_obj_create(ctx, in, inlen, out, sizeof(out));
+       rte_free(in);
+       if (!rqt->obj) {
+               DRV_LOG(ERR, "Failed to create RQT using DevX");
+               rte_errno = errno;
+               rte_free(rqt);
+               return NULL;
+       }
+       rqt->id = MLX5_GET(create_rqt_out, out, rqtn);
+       return rqt;
+}