common/mlx5: add DevX API to create ASO flow hit object
authorDekel Peled <dekelp@nvidia.com>
Sun, 1 Nov 2020 17:57:44 +0000 (17:57 +0000)
committerFerruh Yigit <ferruh.yigit@intel.com>
Tue, 3 Nov 2020 22:35:07 +0000 (23:35 +0100)
Add DevX API to create ASO flow hit object.

Signed-off-by: Dekel Peled <dekelp@nvidia.com>
Acked-by: Matan Azrad <matan@nvidia.com>
drivers/common/mlx5/mlx5_devx_cmds.c
drivers/common/mlx5/mlx5_devx_cmds.h
drivers/common/mlx5/mlx5_prm.h
drivers/common/mlx5/version.map

index e1ac62a..2efcdfe 100644 (file)
@@ -1998,3 +1998,48 @@ mlx5_devx_cmd_query_virtio_q_counters(struct mlx5_devx_obj *couners_obj,
                                        invalid_buffer);
        return ret;
 }
+
+/**
+ * Create general object of type FLOW_HIT_ASO using DevX API.
+ *
+ * @param[in] ctx
+ *   Context returned from mlx5 open_device() glue function.
+ * @param [in] pd
+ *   PD value to associate the FLOW_HIT_ASO object with.
+ *
+ * @return
+ *   The DevX object created, NULL otherwise and rte_errno is set.
+ */
+struct mlx5_devx_obj *
+mlx5_devx_cmd_create_flow_hit_aso_obj(void *ctx, uint32_t pd)
+{
+       uint32_t in[MLX5_ST_SZ_DW(create_flow_hit_aso_in)] = {0};
+       uint32_t out[MLX5_ST_SZ_DW(general_obj_out_cmd_hdr)] = {0};
+       struct mlx5_devx_obj *flow_hit_aso_obj = NULL;
+       void *ptr = NULL;
+
+       flow_hit_aso_obj = mlx5_malloc(MLX5_MEM_ZERO, sizeof(*flow_hit_aso_obj),
+                                      0, SOCKET_ID_ANY);
+       if (!flow_hit_aso_obj) {
+               DRV_LOG(ERR, "Failed to allocate FLOW_HIT_ASO object data");
+               rte_errno = ENOMEM;
+               return NULL;
+       }
+       ptr = MLX5_ADDR_OF(create_flow_hit_aso_in, in, hdr);
+       MLX5_SET(general_obj_in_cmd_hdr, ptr, opcode,
+                MLX5_CMD_OP_CREATE_GENERAL_OBJECT);
+       MLX5_SET(general_obj_in_cmd_hdr, ptr, obj_type,
+                MLX5_GENERAL_OBJ_TYPE_FLOW_HIT_ASO);
+       ptr = MLX5_ADDR_OF(create_flow_hit_aso_in, in, flow_hit_aso);
+       MLX5_SET(flow_hit_aso, ptr, access_pd, pd);
+       flow_hit_aso_obj->obj = mlx5_glue->devx_obj_create(ctx, in, sizeof(in),
+                                                          out, sizeof(out));
+       if (!flow_hit_aso_obj->obj) {
+               rte_errno = errno;
+               DRV_LOG(ERR, "Failed to create FLOW_HIT_ASO obj using DevX.");
+               mlx5_free(flow_hit_aso_obj);
+               return NULL;
+       }
+       flow_hit_aso_obj->id = MLX5_GET(general_obj_out_cmd_hdr, out, obj_id);
+       return flow_hit_aso_obj;
+}
index 7feaafa..e314209 100644 (file)
@@ -486,4 +486,8 @@ __rte_internal
 int mlx5_devx_cmd_query_virtio_q_counters(struct mlx5_devx_obj *couners_obj,
                                  struct mlx5_devx_virtio_q_couners_attr *attr);
 
+__rte_internal
+struct mlx5_devx_obj *mlx5_devx_cmd_create_flow_hit_aso_obj(void *ctx,
+                                                           uint32_t pd);
+
 #endif /* RTE_PMD_MLX5_DEVX_CMDS_H_ */
index d8437d1..ad6dc59 100644 (file)
@@ -2217,6 +2217,7 @@ enum {
        MLX5_GENERAL_OBJ_TYPE_VIRTQ = 0x000d,
        MLX5_GENERAL_OBJ_TYPE_VIRTIO_Q_COUNTERS = 0x001c,
        MLX5_GENERAL_OBJ_TYPE_FLEX_PARSE_GRAPH = 0x0022,
+       MLX5_GENERAL_OBJ_TYPE_FLOW_HIT_ASO = 0x0025,
 };
 
 struct mlx5_ifc_general_obj_in_cmd_hdr_bits {
@@ -2336,6 +2337,19 @@ struct mlx5_ifc_query_virtq_out_bits {
        struct mlx5_ifc_virtio_net_q_bits virtq;
 };
 
+struct mlx5_ifc_flow_hit_aso_bits {
+       u8 modify_field_select[0x40];
+       u8 reserved_at_40[0x48];
+       u8 access_pd[0x18];
+       u8 reserved_at_a0[0x160];
+       u8 flag[0x200];
+};
+
+struct mlx5_ifc_create_flow_hit_aso_in_bits {
+       struct mlx5_ifc_general_obj_in_cmd_hdr_bits hdr;
+       struct mlx5_ifc_flow_hit_aso_bits flow_hit_aso;
+};
+
 enum {
        MLX5_EVENT_TYPE_OBJECT_CHANGE = 0x27,
 };
index 884001c..ec8d96c 100644 (file)
@@ -21,6 +21,7 @@ INTERNAL {
        mlx5_devx_cmd_create_tis;
        mlx5_devx_cmd_create_virtio_q_counters;
        mlx5_devx_cmd_create_virtq;
+        mlx5_devx_cmd_create_flow_hit_aso_obj;
        mlx5_devx_cmd_destroy;
        mlx5_devx_cmd_flow_counter_alloc;
        mlx5_devx_cmd_flow_counter_query;