net/mlx5: add flex item support
Subsystems (2)
cover net/mlx5: add flex item support
Gregory Etelson (4):
common/mlx5: extend flex parser capabilities common/mlx5: fix flex parser DevX creation routine net/mlx5: add flex parser DevX object management net/mlx5: handle flex item in flows
Viacheslav Ovsiienko (5):
common/mlx5: refactor HCA attributes query net/mlx5: update eCPRI flex parser structures net/mlx5: add flex item API
net/mlx5: translate flex item configuration net/mlx5: translate flex item pattern into matcher
drivers/common/mlx5/mlx5_devx_cmds.c | 239 +++-- drivers/common/mlx5/mlx5_devx_cmds.h | 65 +- drivers/common/mlx5/mlx5_prm.h | 50 +- drivers/net/mlx5/linux/mlx5_os.c | 14 + drivers/net/mlx5/meson.build | 1 + drivers/net/mlx5/mlx5.c | 15 +- drivers/net/mlx5/mlx5.h | 79 +- drivers/net/mlx5/mlx5_flow.c | 49 + drivers/net/mlx5/mlx5_flow.h | 27 +- drivers/net/mlx5/mlx5_flow_dv.c | 127 ++- drivers/net/mlx5/mlx5_flow_flex.c | 1373 ++++++++++++++++++++++++++ 11 files changed, 1913 insertions(+), 126 deletions(-) create mode 100644 drivers/net/mlx5/mlx5_flow_flex.c
Signature · 1 line
2.33.1
PATCH 1/9 common/mlx5: refactor HCA attributes query
From: Viacheslav Ovsiienko <[email protected]>
There is the common part of code querying the HCA attributes from the device, and this part can be commoditized as dedicated routine.
--- drivers/common/mlx5/mlx5_devx_cmds.c | 173 +++++++++++---------------- 1 file changed, 73 insertions(+), 100 deletions(-)
drivers/common/mlx5/mlx5_devx_cmds.c +73 -100
@@ -13,6 +13,42 @@#include "mlx5_common_log.h" #include "mlx5_malloc.h" +static void * +mlx5_devx_get_hca_cap (void *ctx,uint32_t *in,uint32_t *out, +int *err,uint32_t flags) +{ +const size_t size_in =MLX5_ST_SZ_DW (query_hca_cap_in) *sizeof (int ); +const size_t size_out =MLX5_ST_SZ_DW (query_hca_cap_out) *sizeof (int ); +int status, syndrome, rc; + +if (err) + *err =0 ; +memset (in,0 , size_in); +memset (out,0 , size_out); +MLX5_SET (query_hca_cap_in, in, opcode,MLX5_CMD_OP_QUERY_HCA_CAP ); +MLX5_SET (query_hca_cap_in, in, op_mod, flags); + rc = mlx5_glue->devx_general_cmd (ctx, in, size_in, out, size_out); +if (rc) { +DRV_LOG (ERR , +"Failed to query devx HCA capabilities func %#02x" , + flags >>1 ); +if (err) + *err = rc >0 ? -rc : rc; +return NULL ; + } + status =MLX5_GET (query_hca_cap_out, out, status); + syndrome =MLX5_GET (query_hca_cap_out, out, syndrome); +if (status) { +DRV_LOG (ERR , +"Failed to query devx HCA capabilities func %#02x status %x, syndrome = %x" , + flags >>1 , status, syndrome); +if (err) + *err =-1 ; +return NULL ; + } +return MLX5_ADDR_OF (query_hca_cap_out, out, capability); +} +/** * Perform read access to the registers. Reads data from register * and writes ones to the specified buffer.
@@ -472,21 +508,15 @@ static voidmlx5_devx_cmd_query_hca_vdpa_attr (void *ctx, struct mlx5_hca_vdpa_attr *vdpa_attr) { -uint32_t in[MLX5_ST_SZ_DW (query_hca_cap_in)] = {0 }; -uint32_t out[MLX5_ST_SZ_DW (query_hca_cap_out)] = {0 }; -void *hcattr =MLX5_ADDR_OF (query_hca_cap_out, out, capability); -int status, syndrome, rc; +uint32_t in[MLX5_ST_SZ_DW (query_hca_cap_in)]; +uint32_t out[MLX5_ST_SZ_DW (query_hca_cap_out)]; +void *hcattr; -MLX5_SET (query_hca_cap_in, in, opcode,MLX5_CMD_OP_QUERY_HCA_CAP ); -MLX5_SET (query_hca_cap_in, in, op_mod, -MLX5_GET_HCA_CAP_OP_MOD_VDPA_EMULATION | -MLX5_HCA_CAP_OPMOD_GET_CUR ); - rc = mlx5_glue->devx_general_cmd (ctx, in,sizeof (in), out,sizeof (out)); - status =MLX5_GET (query_hca_cap_out, out, status); - syndrome =MLX5_GET (query_hca_cap_out, out, syndrome); -if (rc || status) { -RTE_LOG (DEBUG ,PMD ,"Failed to query devx VDPA capabilities," -" status %x, syndrome = %x" , status, syndrome); + hcattr =mlx5_devx_get_hca_cap (ctx, in, out,NULL , +MLX5_GET_HCA_CAP_OP_MOD_VDPA_EMULATION | +MLX5_HCA_CAP_OPMOD_GET_CUR ); +if (!hcattr) { +RTE_LOG (DEBUG ,PMD ,"Failed to query devx VDPA capabilities" ); vdpa_attr->valid =0 ; }else { vdpa_attr->valid =1 ;
@@ -741,27 +771,15 @@ mlx5_devx_cmd_query_hca_attr(void *ctx, {uint32_t in[MLX5_ST_SZ_DW (query_hca_cap_in)] = {0 };uint32_t out[MLX5_ST_SZ_DW (query_hca_cap_out)] = {0 }; -void *hcattr; -int status, syndrome, rc, i;uint64_t general_obj_types_supported =0 ; +void *hcattr; +int rc, i; -MLX5_SET (query_hca_cap_in, in, opcode,MLX5_CMD_OP_QUERY_HCA_CAP ); -MLX5_SET (query_hca_cap_in, in, op_mod, -MLX5_GET_HCA_CAP_OP_MOD_GENERAL_DEVICE | -MLX5_HCA_CAP_OPMOD_GET_CUR ); - - rc = mlx5_glue->devx_general_cmd (ctx, - in,sizeof (in), out,sizeof (out)); -if (rc) - goto error; - status =MLX5_GET (query_hca_cap_out, out, status); - syndrome =MLX5_GET (query_hca_cap_out, out, syndrome); -if (status) { -DRV_LOG (DEBUG ,"Failed to query devx HCA capabilities, " -"status %x, syndrome = %x" , status, syndrome); -return -1 ; - } - hcattr =MLX5_ADDR_OF (query_hca_cap_out, out, capability); + hcattr =mlx5_devx_get_hca_cap (ctx, in, out, &rc, +MLX5_GET_HCA_CAP_OP_MOD_GENERAL_DEVICE | +MLX5_HCA_CAP_OPMOD_GET_CUR ); +if (!hcattr) +return rc; attr->flow_counter_bulk_alloc_bitmap =MLX5_GET (cmd_hca_cap, hcattr, flow_counter_bulk_alloc); attr->flow_counters_dump = MLX5_GET(cmd_hca_cap, hcattr,
@@ -893,19 +911,13 @@ mlx5_devx_cmd_query_hca_attr(void *ctx, general_obj_types) & MLX5_GENERAL_OBJ_TYPES_CAP_CONN_TRACK_OFFLOAD);if (attr->qos.sup) { -MLX5_SET (query_hca_cap_in, in, op_mod, -MLX5_GET_HCA_CAP_OP_MOD_QOS_CAP | -MLX5_HCA_CAP_OPMOD_GET_CUR ); - rc = mlx5_glue->devx_general_cmd (ctx, in,sizeof (in), - out,sizeof (out)); -if (rc) - goto error; -if (status) { -DRV_LOG (DEBUG ,"Failed to query devx QOS capabilities," -" status %x, syndrome = %x" , status, syndrome); -return -1 ; + hcattr =mlx5_devx_get_hca_cap (ctx, in, out, &rc, +MLX5_GET_HCA_CAP_OP_MOD_QOS_CAP | +MLX5_HCA_CAP_OPMOD_GET_CUR ); +if (!hcattr) { +DRV_LOG (DEBUG ,"Failed to query devx QOS capabilities" ); +return rc; } - hcattr =MLX5_ADDR_OF (query_hca_cap_out, out, capability); attr->qos.flow_meter_old =MLX5_GET (qos_cap, hcattr, flow_meter_old); attr->qos.log_max_flow_meter =
@@ -934,27 +946,14 @@ mlx5_devx_cmd_query_hca_attr(void *ctx,mlx5_devx_cmd_query_hca_vdpa_attr (ctx, &attr->vdpa);if (!attr->eth_net_offloads)return 0 ; -/* Query Flow Sampler Capability From FLow Table Properties Layout. */ -memset (in,0 ,sizeof (in)); -memset (out,0 ,sizeof (out)); -MLX5_SET (query_hca_cap_in, in, opcode,MLX5_CMD_OP_QUERY_HCA_CAP ); -MLX5_SET (query_hca_cap_in, in, op_mod, -MLX5_GET_HCA_CAP_OP_MOD_NIC_FLOW_TABLE | -MLX5_HCA_CAP_OPMOD_GET_CUR ); - - rc = mlx5_glue->devx_general_cmd (ctx, in,sizeof (in), out,sizeof (out)); -if (rc) - goto error; - status =MLX5_GET (query_hca_cap_out, out, status); - syndrome =MLX5_GET (query_hca_cap_out, out, syndrome); -if (status) { -DRV_LOG (DEBUG ,"Failed to query devx HCA capabilities, " -"status %x, syndrome = %x" , status, syndrome); + hcattr =mlx5_devx_get_hca_cap (ctx, in, out, &rc, +MLX5_GET_HCA_CAP_OP_MOD_NIC_FLOW_TABLE | +MLX5_HCA_CAP_OPMOD_GET_CUR ); +if (!hcattr) { attr->log_max_ft_sampler_num =0 ; -return -1 ; +return rc; } - hcattr =MLX5_ADDR_OF (query_hca_cap_out, out, capability); attr->log_max_ft_sampler_num =MLX5_GET (flow_table_nic_cap, hcattr, flow_table_properties_nic_receive.log_max_ft_sampler_num);
@@ -969,27 +968,13 @@ mlx5_devx_cmd_query_hca_attr(void *ctx, (flow_table_nic_cap, hcattr, ft_field_support_2_nic_receive.outer_ipv4_ihl);/* Query HCA offloads for Ethernet protocol. */ -memset (in,0 ,sizeof (in)); -memset (out,0 ,sizeof (out)); -MLX5_SET (query_hca_cap_in, in, opcode,MLX5_CMD_OP_QUERY_HCA_CAP ); -MLX5_SET (query_hca_cap_in, in, op_mod, -MLX5_GET_HCA_CAP_OP_MOD_ETHERNET_OFFLOAD_CAPS | -MLX5_HCA_CAP_OPMOD_GET_CUR ); - - rc = mlx5_glue->devx_general_cmd (ctx, in,sizeof (in), out,sizeof (out)); -if (rc) { + hcattr =mlx5_devx_get_hca_cap (ctx, in, out, &rc, +MLX5_GET_HCA_CAP_OP_MOD_ETHERNET_OFFLOAD_CAPS | +MLX5_HCA_CAP_OPMOD_GET_CUR ); +if (!hcattr) { attr->eth_net_offloads =0 ; - goto error; +return rc; } - status =MLX5_GET (query_hca_cap_out, out, status); - syndrome =MLX5_GET (query_hca_cap_out, out, syndrome); -if (status) { -DRV_LOG (DEBUG ,"Failed to query devx HCA capabilities, " -"status %x, syndrome = %x" , status, syndrome); - attr->eth_net_offloads =0 ; -return -1 ; - } - hcattr =MLX5_ADDR_OF (query_hca_cap_out, out, capability); attr->wqe_vlan_insert =MLX5_GET (per_protocol_networking_offload_caps, hcattr, wqe_vlan_insert); attr->csum_cap = MLX5_GET(per_protocol_networking_offload_caps,
@@ -1044,26 +1029,14 @@ mlx5_devx_cmd_query_hca_attr(void *ctx, hcattr, rss_ind_tbl_cap);/* Query HCA attribute for ROCE. */ if (attr->roce) { -memset (in,0 ,sizeof (in)); -memset (out,0 ,sizeof (out)); -MLX5_SET (query_hca_cap_in, in, opcode, -MLX5_CMD_OP_QUERY_HCA_CAP ); -MLX5_SET (query_hca_cap_in, in, op_mod, -MLX5_GET_HCA_CAP_OP_MOD_ROCE | -MLX5_HCA_CAP_OPMOD_GET_CUR ); - rc = mlx5_glue->devx_general_cmd (ctx, in,sizeof (in), - out,sizeof (out)); -if (rc) - goto error; - status =MLX5_GET (query_hca_cap_out, out, status); - syndrome =MLX5_GET (query_hca_cap_out, out, syndrome); -if (status) { + hcattr =mlx5_devx_get_hca_cap (ctx, in, out, &rc, +MLX5_GET_HCA_CAP_OP_MOD_ROCE | +MLX5_HCA_CAP_OPMOD_GET_CUR ); +if (!hcattr) {DRV_LOG (DEBUG , -"Failed to query devx HCA ROCE capabilities, " -"status %x, syndrome = %x" , status, syndrome); -return -1 ; +"Failed to query devx HCA ROCE capabilities" ); +return rc; } - hcattr =MLX5_ADDR_OF (query_hca_cap_out, out, capability); attr->qp_ts_format =MLX5_GET (roce_caps, hcattr, qp_ts_format); } if (attr->eth_virt &&
Signature · 1 line
2.33.1
PATCH 2/9 common/mlx5: extend flex parser capabilities
In reply to Gregory EtelsonMLX5 PARSE_GRAPH_NODE is the main data structure used by the Flex Parser when a new parsing protocol is defined. While software creates PARSE_GRAPH_NODE object for a new protocol, it must verify that configuration parameters it uses comply with hardware limits.
The patch queries hardware PARSE_GRAPH_NODE capabilities and stores ones in PMD internal configuration structure:
- query capabilities from parse_graph_node attribute page
- query max_num_prog_sample_field capability from HCA page 2
--- drivers/common/mlx5/mlx5_devx_cmds.c | 57 ++++++++++++++++++++++++ drivers/common/mlx5/mlx5_devx_cmds.h | 65 +++++++++++++++++++++++++++- drivers/common/mlx5/mlx5_prm.h | 50 ++++++++++++++++++++- 3 files changed, 168 insertions(+), 4 deletions(-)
drivers/common/mlx5/mlx5_devx_cmds.c +57 -0
@@ -729,6 +729,53 @@ mlx5_devx_cmd_create_flex_parser(void *ctx,return parse_flex_obj; } +static int +mlx5_devx_cmd_query_hca_parse_graph_node_cap + (void *ctx,struct mlx5_hca_flex_attr *attr) +{ +uint32_t in[MLX5_ST_SZ_DW (query_hca_cap_in)]; +uint32_t out[MLX5_ST_SZ_DW (query_hca_cap_out)]; +void *hcattr; +int rc; + + hcattr =mlx5_devx_get_hca_cap (ctx, in, out, &rc, +MLX5_GET_HCA_CAP_OP_MOD_PARSE_GRAPH_NODE_CAP | +MLX5_HCA_CAP_OPMOD_GET_CUR ); +if (!hcattr) +return rc; + attr->node_in =MLX5_GET (parse_graph_node_cap, hcattr, node_in); + attr->node_out =MLX5_GET (parse_graph_node_cap, hcattr, node_out); + attr->header_length_mode =MLX5_GET (parse_graph_node_cap, hcattr, + header_length_mode); + attr->sample_offset_mode =MLX5_GET (parse_graph_node_cap, hcattr, + sample_offset_mode); + attr->max_num_arc_in =MLX5_GET (parse_graph_node_cap, hcattr, + max_num_arc_in); + attr->max_num_arc_out =MLX5_GET (parse_graph_node_cap, hcattr, + max_num_arc_out); + attr->max_num_sample =MLX5_GET (parse_graph_node_cap, hcattr, + max_num_sample); + attr->sample_id_in_out =MLX5_GET (parse_graph_node_cap, hcattr, + sample_id_in_out); + attr->max_base_header_length =MLX5_GET (parse_graph_node_cap, hcattr, + max_base_header_length); + attr->max_sample_base_offset =MLX5_GET (parse_graph_node_cap, hcattr, + max_sample_base_offset); + attr->max_next_header_offset =MLX5_GET (parse_graph_node_cap, hcattr, + max_next_header_offset); + attr->header_length_mask_width =MLX5_GET (parse_graph_node_cap, hcattr, + header_length_mask_width); +/* Get the max supported samples from HCA CAP 2 */ + hcattr =mlx5_devx_get_hca_cap (ctx, in, out, &rc, +MLX5_GET_HCA_CAP_OP_MOD_GENERAL_DEVICE_2 | +MLX5_HCA_CAP_OPMOD_GET_CUR ); +if (!hcattr) +return rc; + attr->max_num_prog_sample = +MLX5_GET (cmd_hca_cap_2, hcattr, max_num_prog_sample_field); +return 0 ; +} +static int mlx5_devx_query_pkt_integrity_match (void *hcattr) {
@@ -942,6 +989,16 @@ mlx5_devx_cmd_query_hca_attr(void *ctx, log_max_num_meter_aso); } } +/* +* Flex item support needs max_num_prog_sample_field +* from the Capabilities 2 table for PARSE_GRAPH_NODE +*/ +if (attr->parse_graph_flex_node) { + rc =mlx5_devx_cmd_query_hca_parse_graph_node_cap + (ctx, &attr->flex); +if (rc) +return -1 ; + }if (attr->vdpa.valid)mlx5_devx_cmd_query_hca_vdpa_attr (ctx, &attr->vdpa);if (!attr->eth_net_offloads)
drivers/common/mlx5/mlx5_devx_cmds.h +63 -2
89 lines not on this page · raw message
drivers/common/mlx5/mlx5_prm.h +48 -2
91 lines not on this page · raw message
Signature · 1 line
2.33.1
PATCH 3/9 common/mlx5: fix flex parser DevX creation routine
In reply to Gregory EtelsonAdd missing modify_field_select, next_header_field_size field values setting.
--- drivers/common/mlx5/mlx5_devx_cmds.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
drivers/common/mlx5/mlx5_devx_cmds.c +7 -2
@@ -620,10 +620,9 @@ mlx5_devx_cmd_query_parse_samples(struct mlx5_devx_obj *flex_obj,return ret; } -struct mlx5_devx_obj *mlx5_devx_cmd_create_flex_parser (void *ctx, -struct mlx5_devx_graph_node_attr *data) +struct mlx5_devx_graph_node_attr *data) {uint32_t in[MLX5_ST_SZ_DW (create_flex_parser_in)] = {0 };uint32_t out[MLX5_ST_SZ_DW (general_obj_out_cmd_hdr)] = {0 };
@@ -647,12 +646,18 @@ mlx5_devx_cmd_create_flex_parser(void *ctx, MLX5_GENERAL_OBJ_TYPE_FLEX_PARSE_GRAPH);MLX5_SET (parse_graph_flex, flex, header_length_mode, data->header_length_mode); +MLX5_SET64 (parse_graph_flex, flex, modify_field_select, + data->modify_field_select);MLX5_SET (parse_graph_flex, flex, header_length_base_value, data->header_length_base_value);MLX5_SET (parse_graph_flex, flex, header_length_field_offset, data->header_length_field_offset);MLX5_SET (parse_graph_flex, flex, header_length_field_shift, data->header_length_field_shift); +MLX5_SET (parse_graph_flex, flex, next_header_field_offset, + data->next_header_field_offset); +MLX5_SET (parse_graph_flex, flex, next_header_field_size, + data->next_header_field_size);MLX5_SET (parse_graph_flex, flex, header_length_field_mask, data->header_length_field_mask);for (i =0 ; i <MLX5_GRAPH_NODE_SAMPLE_NUM ; i++) {
Signature · 1 line
2.33.1
PATCH 4/9 net/mlx5: update eCPRI flex parser structures
In reply to Gregory EtelsonFrom: Viacheslav Ovsiienko <[email protected]>
To handle eCPRI protocol in the flows the mlx5 PMD engages flex parser hardware feature. While we were implementing eCPRI support we anticipated the flex parser usage extension, and all related variables were named accordingly, containing flex syllabus. Now we are preparing to introduce more common approach of flex item, in order to avoid naming conflicts and improve the code readability the eCPRI infrastructure related variables are renamed as preparation step.
Later, once we have the new flex item implemented, we could consider to refactor the eCPRI protocol support to move on common flex item basis.
--- drivers/net/mlx5/mlx5.c | 9 +++------ drivers/net/mlx5/mlx5.h | 12 +++--------- drivers/net/mlx5/mlx5_flow_dv.c | 2 +- 3 files changed, 7 insertions(+), 16 deletions(-)
drivers/net/mlx5/mlx5.c +3 -6
@@ -865,8 +865,7 @@ bool mlx5_flex_parser_ecpri_exist(struct rte_eth_dev *dev) {struct mlx5_priv *priv = dev->data->dev_private; -struct mlx5_flex_parser_profiles *prf = - &priv->sh->fp[MLX5_FLEX_PARSER_ECPRI_0 ]; +struct mlx5_ecpri_parser_profile *prf = &priv->sh->ecpri_parser;return !!prf->obj; }
@@ -885,8 +884,7 @@ int mlx5_flex_parser_ecpri_alloc(struct rte_eth_dev *dev) {struct mlx5_priv *priv = dev->data->dev_private; -struct mlx5_flex_parser_profiles *prf = - &priv->sh->fp[MLX5_FLEX_PARSER_ECPRI_0 ]; +struct mlx5_ecpri_parser_profile *prf = &priv->sh->ecpri_parser;struct mlx5_devx_graph_node_attr node = { .modify_field_select =0 , };
@@ -949,8 +947,7 @@ static void mlx5_flex_parser_ecpri_release(struct rte_eth_dev *dev) {struct mlx5_priv *priv = dev->data->dev_private; -struct mlx5_flex_parser_profiles *prf = - &priv->sh->fp[MLX5_FLEX_PARSER_ECPRI_0 ]; +struct mlx5_ecpri_parser_profile *prf = &priv->sh->ecpri_parser;if (prf->obj)mlx5_devx_cmd_destroy (prf->obj);
drivers/net/mlx5/mlx5.h +3 -9
@@ -1015,14 +1015,8 @@ struct mlx5_dev_txpp {uint64_t err_ts_future;/* Timestamp in the distant future. */ }; -/* Supported flex parser profile ID. */ -enum mlx5_flex_parser_profile_id { -MLX5_FLEX_PARSER_ECPRI_0 =0 , -MLX5_FLEX_PARSER_MAX =8 , -}; - -/* Sample ID information of flex parser structure. */ -struct mlx5_flex_parser_profiles { +/* Sample ID information of eCPRI flex parser structure. */ +struct mlx5_ecpri_parser_profile {uint32_t num;/* Actual number of samples. */ uint32_t ids[8 ];/* Sample IDs for this profile. */ uint8_t offset[8 ];/* Bytes offset of each parser. */
@@ -1167,7 +1161,7 @@ struct mlx5_dev_ctx_shared {struct mlx5_devx_obj *td;/* Transport domain. */ struct mlx5_lag lag;/* LAG attributes */ void *tx_uar;/* Tx/packet pacing shared UAR. */ -struct mlx5_flex_parser_profiles fp[MLX5_FLEX_PARSER_MAX ]; +struct mlx5_ecpri_parser_profile ecpri_parser;/* Flex parser profiles information. */ void *devx_rx_uar;/* DevX UAR for Rx. */ struct mlx5_aso_age_mng *aso_age_mng;
drivers/net/mlx5/mlx5_flow_dv.c +1 -1
@@ -9935,7 +9935,7 @@ flow_dv_translate_item_ecpri(struct rte_eth_dev *dev, void *matcher,*/ if (!ecpri_m->hdr.common.u32)return ; - samples = priv->sh->fp[MLX5_FLEX_PARSER_ECPRI_0 ].ids; + samples = priv->sh->ecpri_parser.ids;/* Need to take the whole DW as the mask to fill the entry. */ dw_m =MLX5_ADDR_OF (fte_match_set_misc4, misc4_m, prog_sample_field_value_0);
Signature · 1 line
2.33.1
PATCH 5/9 net/mlx5: add flex item API
In reply to Gregory EtelsonFrom: Viacheslav Ovsiienko <[email protected]>
This patch is a preparation step of implementing
flex item feature in driver and it provides:
- external entry point routines for flex item
creation/deletion
- flex item objects management over the ports.
The flex item object keeps information about the item created over the port - reference counter to track whether item is in use by some active flows and the pointer to underlying shared DevX object, providing all the data needed to translate the flow flex pattern into matcher fields according hardware configuration.
There is not too many flex items supposed to be created on the port, the design is optimized rather for flow insertion rate than memory savings.
--- drivers/net/mlx5/linux/mlx5_os.c | 4 + drivers/net/mlx5/meson.build | 1 + drivers/net/mlx5/mlx5.c | 2 +- drivers/net/mlx5/mlx5.h | 24 ++++ drivers/net/mlx5/mlx5_flow.c | 49 ++++++++ drivers/net/mlx5/mlx5_flow.h | 18 ++- drivers/net/mlx5/mlx5_flow_dv.c | 3 +- drivers/net/mlx5/mlx5_flow_flex.c | 189 ++++++++++++++++++++++++++++++ 8 files changed, 286 insertions(+), 4 deletions(-) create mode 100644 drivers/net/mlx5/mlx5_flow_flex.c
drivers/net/mlx5/linux/mlx5_os.c +4 -0
@@ -1682,6 +1682,8 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev, err =mlx5_alloc_shared_dr (priv);if (err) goto error; +if (mlx5_flex_item_port_init (eth_dev) <0 ) + goto error; }if (sh->devx && config->dv_flow_en && config->dest_tir) { priv->obj_ops = devx_obj_ops;
@@ -1810,6 +1812,8 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev,claim_zero (rte_eth_switch_domain_free (priv->domain_id));if (priv->hrxqs)mlx5_list_destroy (priv->hrxqs); +if (eth_dev && priv->flex_item_map) +mlx5_flex_item_port_cleanup (eth_dev);mlx5_free (priv);if (eth_dev !=NULL ) eth_dev->data->dev_private =NULL ;
drivers/net/mlx5/meson.build +1 -0
@@ -17,6 +17,7 @@ sources = files( 'mlx5_flow_meter.c', 'mlx5_flow_dv.c', 'mlx5_flow_aso.c', + 'mlx5_flow_flex.c', 'mlx5_mac.c', 'mlx5_rss.c', 'mlx5_rx.c',
drivers/net/mlx5/mlx5.c +1 -1
@@ -378,7 +378,6 @@ static const struct mlx5_indexed_pool_config mlx5_ipool_cfg[] = { }, }; -#define MLX5_FLOW_MIN_ID_POOL_SIZE 512#define MLX5_ID_GENERATION_ARRAY_FACTOR 16
@@ -1682,6 +1681,7 @@ mlx5_dev_close(struct rte_eth_dev *dev)mlx5_mp_os_req_stop_rxtx (dev);/* Free the eCPRI flex parser resource. */ mlx5_flex_parser_ecpri_release (dev); +mlx5_flex_item_port_cleanup (dev);if (priv->rxqs !=NULL ) {/* XXX race condition if mlx5_rx_burst() is still running. */ rte_delay_us_sleep (1000 );
drivers/net/mlx5/mlx5.h +24 -0
@@ -50,6 +50,9 @@#define MLX5_MAX_MODIFY_NUM 32#define MLX5_ROOT_TBL_MODIFY_NUM 16 +/* Maximal number of flex items created on the port.*/ +#define MLX5_PORT_FLEX_ITEM_NUM 4 +enum mlx5_ipool_index {#if defined(HAVE_IBV_FLOW_DV_SUPPORT ) || !defined(HAVE_INFINIBAND_VERBS_H )MLX5_IPOOL_DECAP_ENCAP =0 ,/* Pool for encap/decap resource. */
@@ -1098,6 +1101,12 @@ struct mlx5_lag {uint8_t affinity_mode;/* TIS or hash based affinity */ }; +/* Port flex item context. */ +struct mlx5_flex_item { +struct mlx5_flex_parser_devx *devx_fp;/* DevX flex parser object. */ +uint32_t refcnt;/* Atomically accessed refcnt by flows. */ +}; +/* * Shared Infiniband device context for Master/Representors * which belong to same IB device with multiple IB ports.
@@ -1420,6 +1429,10 @@ struct mlx5_priv {struct mlx5_devx_obj *q_counters;/* DevX queue counter object. */ uint32_t counter_set_id;/* Queue counter ID to set in DevX objects. */ uint32_t lag_affinity_idx;/* LAG mode queue 0 affinity starting. */ +rte_spinlock_t flex_item_sl;/* Flex item list spinlock. */ +struct mlx5_flex_item flex_item[MLX5_PORT_FLEX_ITEM_NUM ]; +/* Flex items have been created on the port. */ +uint32_t flex_item_map;/* Map of allocated flex item elements. */ };#define PORT_ID (priv) ((priv)->dev_data->port_id)
@@ -1799,4 +1812,15 @@ mlx5_get_supported_sw_parsing_offloads(const struct mlx5_hca_attr *attr);uint32_t mlx5_get_supported_tunneling_offloads (const struct mlx5_hca_attr *attr); +/* mlx5_flow_flex.c */ + +struct rte_flow_item_flex_handle * +flow_dv_item_create (struct rte_eth_dev *dev, +const struct rte_flow_item_flex_conf *conf, +struct rte_flow_error *error); +int flow_dv_item_release (struct rte_eth_dev *dev, +const struct rte_flow_item_flex_handle *flex_handle, +struct rte_flow_error *error); +int mlx5_flex_item_port_init (struct rte_eth_dev *dev); +void mlx5_flex_item_port_cleanup (struct rte_eth_dev *dev);#endif /* RTE_PMD_MLX5_H_ */
drivers/net/mlx5/mlx5_flow.c +49 -0
67 lines not on this page · raw message
drivers/net/mlx5/mlx5_flow.h +16 -2
@@ -1229,6 +1229,19 @@ typedef int (*mlx5_flow_create_def_policy_t) (struct rte_eth_dev *dev);typedef void (*mlx5_flow_destroy_def_policy_t ) (struct rte_eth_dev *dev); +typedef struct rte_flow_item_flex_handle *(*mlx5_flow_item_create_t ) + (struct rte_eth_dev *dev, +const struct rte_flow_item_flex_conf *conf, +struct rte_flow_error *error); +typedef int (*mlx5_flow_item_release_t ) + (struct rte_eth_dev *dev, +const struct rte_flow_item_flex_handle *handle, +struct rte_flow_error *error); +typedef int (*mlx5_flow_item_update_t ) + (struct rte_eth_dev *dev, +const struct rte_flow_item_flex_handle *handle, +const struct rte_flow_item_flex_conf *conf, +struct rte_flow_error *error);struct mlx5_flow_driver_ops {mlx5_flow_validate_t validate;
@@ -1263,6 +1276,9 @@ struct mlx5_flow_driver_ops {mlx5_flow_action_update_t action_update;mlx5_flow_action_query_t action_query;mlx5_flow_sync_domain_t sync_domain; +mlx5_flow_item_create_t item_create; +mlx5_flow_item_release_t item_release; +mlx5_flow_item_update_t item_update; };/* mlx5_flow.c */
@@ -1712,6 +1728,4 @@ const struct mlx5_flow_tunnel * mlx5_get_tof(const struct rte_flow_item *items, const struct rte_flow_action *actions, enum mlx5_tof_rule_type *rule_type); - -#endif /* RTE_PMD_MLX5_FLOW_H_ */
drivers/net/mlx5/mlx5_flow_dv.c +2 -1
@@ -17942,7 +17942,8 @@ const struct mlx5_flow_driver_ops mlx5_flow_dv_drv_ops = { .action_update = flow_dv_action_update, .action_query = flow_dv_action_query, .sync_domain = flow_dv_sync_domain, + .item_create = flow_dv_item_create, + .item_release = flow_dv_item_release, }; -#endif /* HAVE_IBV_FLOW_DV_SUPPORT */
drivers/net/mlx5/mlx5_flow_flex.c new file +189 -0
189 lines not on this page · raw message
Signature · 1 line
2.33.1
PATCH 6/9 net/mlx5: add flex parser DevX object management
In reply to Gregory EtelsonThe DevX flex parsers can be shared between representors within the same IB context. We should put the flex parser objects into the shared list and engage the standard mlx5_list_xxx API to manage ones.
--- drivers/net/mlx5/linux/mlx5_os.c | 10 +++ drivers/net/mlx5/mlx5.c | 4 + drivers/net/mlx5/mlx5.h | 20 +++++ drivers/net/mlx5/mlx5_flow_flex.c | 121 +++++++++++++++++++++++++++++- 4 files changed, 154 insertions(+), 1 deletion(-)
drivers/net/mlx5/linux/mlx5_os.c +10 -0
@@ -337,6 +337,16 @@ mlx5_alloc_shared_dr(struct mlx5_priv *priv) flow_dv_dest_array_clone_free_cb);if (!sh->dest_array_list) goto error; +/* Init shared flex parsers list, no need lcore_share */ +snprintf (s,sizeof (s),"%s_flex_parsers_list" , sh->ibdev_name); + sh->flex_parsers_dv =mlx5_list_create (s, sh, false, + mlx5_flex_parser_create_cb, + mlx5_flex_parser_match_cb, + mlx5_flex_parser_remove_cb, + mlx5_flex_parser_clone_cb, + mlx5_flex_parser_clone_free_cb); +if (!sh->flex_parsers_dv) + goto error;#endif #ifdef HAVE_MLX5DV_DR void *domain;
drivers/net/mlx5/mlx5.c +4 -0
@@ -1428,6 +1428,10 @@ mlx5_free_shared_dev_ctx(struct mlx5_dev_ctx_shared *sh)mlx5_flow_os_release_workspace (); }pthread_mutex_unlock (&mlx5_dev_ctx_list_mutex); +if (sh->flex_parsers_dv) { +mlx5_list_destroy (sh->flex_parsers_dv); + sh->flex_parsers_dv =NULL ; + }/* * Ensure there is no async event handler installed. * Only primary process handles async device events.
drivers/net/mlx5/mlx5.h +20 -0
@@ -1101,6 +1101,15 @@ struct mlx5_lag {uint8_t affinity_mode;/* TIS or hash based affinity */ }; +/* DevX flex parser context. */ +struct mlx5_flex_parser_devx { +struct mlx5_list_entry entry;/* List element at the beginning. */ +uint32_t num_samples; +void *devx_obj; +struct mlx5_devx_graph_node_attr devx_conf; +uint32_t sample_ids[MLX5_GRAPH_NODE_SAMPLE_NUM ]; +}; +/* Port flex item context. */ struct mlx5_flex_item {struct mlx5_flex_parser_devx *devx_fp;/* DevX flex parser object. */
@@ -1157,6 +1166,7 @@ struct mlx5_dev_ctx_shared {struct mlx5_list *push_vlan_action_list;/* Push VLAN actions. */ struct mlx5_list *sample_action_list;/* List of sample actions. */ struct mlx5_list *dest_array_list; +struct mlx5_list *flex_parsers_dv;/* Flex Item parsers. */ /* List of destination array actions. */ struct mlx5_flow_counter_mng cmng;/* Counters management structure. */ void *default_miss_action;/* Default miss action. */
@@ -1823,4 +1833,14 @@ int flow_dv_item_release(struct rte_eth_dev *dev, struct rte_flow_error *error);int mlx5_flex_item_port_init (struct rte_eth_dev *dev);void mlx5_flex_item_port_cleanup (struct rte_eth_dev *dev); +/* Flex parser list callbacks. */ +struct mlx5_list_entry *mlx5_flex_parser_create_cb (void *list_ctx,void *ctx); +int mlx5_flex_parser_match_cb (void *list_ctx, +struct mlx5_list_entry *iter,void *ctx); +void mlx5_flex_parser_remove_cb (void *list_ctx,struct mlx5_list_entry *entry); +struct mlx5_list_entry *mlx5_flex_parser_clone_cb (void *list_ctx, +struct mlx5_list_entry *entry, +void *ctx); +void mlx5_flex_parser_clone_free_cb (void *tool_ctx, +struct mlx5_list_entry *entry);#endif /* RTE_PMD_MLX5_H_ */
drivers/net/mlx5/mlx5_flow_flex.c +120 -1
156 lines not on this page · raw message
Signature · 1 line
2.33.1
PATCH 7/9 net/mlx5: translate flex item configuration
In reply to Gregory EtelsonFrom: Viacheslav Ovsiienko <[email protected]>
RTE Flow flex item configuration should be translated into actual hardware settings:
- translate header length and next protocol field samplings
- translate data field sampling, the similar fields with the same mode and matching related parameters are relocated and grouped to be covered with minimal amount of hardware sampling registers (each register can cover arbitrary neighbour 32 bits (aligned to byte boundary) in the packet and we can combine the fields with smaller lengths or segments of bigger fields)
- input and output links translation
- preparing data for parsing flex item pattern on flow creation
--- drivers/net/mlx5/mlx5.h | 15 + drivers/net/mlx5/mlx5_flow_flex.c | 844 +++++++++++++++++++++++++++++- 2 files changed, 858 insertions(+), 1 deletion(-)
drivers/net/mlx5/mlx5.h +15 -0
@@ -53,6 +53,9 @@/* Maximal number of flex items created on the port.*/ #define MLX5_PORT_FLEX_ITEM_NUM 4 +/* Maximal number of field/field parts to map into sample registers .*/ +#define MLX5_FLEX_ITEM_MAPPING_NUM 32 +enum mlx5_ipool_index {#if defined(HAVE_IBV_FLOW_DV_SUPPORT ) || !defined(HAVE_INFINIBAND_VERBS_H )MLX5_IPOOL_DECAP_ENCAP =0 ,/* Pool for encap/decap resource. */
@@ -1110,10 +1113,22 @@ struct mlx5_flex_parser_devx {uint32_t sample_ids[MLX5_GRAPH_NODE_SAMPLE_NUM ]; }; +/* Pattern field dscriptor - how to translate flex pattern into samples. */ +__extension__ +struct mlx5_flex_pattern_field { +uint16_t width:6 ; +uint16_t shift:5 ; +uint16_t reg_id:5 ; +}; +#define MLX5_INVALID_SAMPLE_REG_ID 0x1F +/* Port flex item context. */ struct mlx5_flex_item {struct mlx5_flex_parser_devx *devx_fp;/* DevX flex parser object. */ uint32_t refcnt;/* Atomically accessed refcnt by flows. */ +enum rte_flow_item_flex_tunnel_mode tunnel_mode;/* Tunnel mode. */ +uint32_t mapnum;/* Number of pattern translation entries. */ +struct mlx5_flex_pattern_field map[MLX5_FLEX_ITEM_MAPPING_NUM ]; };/*
drivers/net/mlx5/mlx5_flow_flex.c +843 -1
862 lines not on this page · raw message
Signature · 1 line
2.33.1
PATCH 8/9 net/mlx5: translate flex item pattern into matcher
In reply to Gregory EtelsonFrom: Viacheslav Ovsiienko <[email protected]>
The matcher is an steering engine entity that represents the flow pattern to hardware to match. It order to provide match on the flex item pattern the appropriate matcher fields should be configured with values and masks accordingly.
The flex item related matcher fields is an array of eight 32-bit fields to match with data captured by sample registers of configured flex parser. One packet field, presented in item pattern can be split between several sample registers, and multiple fields can be combined together into single sample register to optimize hardware resources usage (number os sample registers is limited), depending on field modes, widths and offsets. Actual mapping is complicated and controlled by special translation data, built by PMD on flex item creation.
--- drivers/net/mlx5/mlx5.h | 8 ++ drivers/net/mlx5/mlx5_flow_flex.c | 223 ++++++++++++++++++++++++++++++ 2 files changed, 231 insertions(+)
drivers/net/mlx5/mlx5.h +8 -0
@@ -1848,6 +1848,14 @@ int flow_dv_item_release(struct rte_eth_dev *dev, struct rte_flow_error *error);int mlx5_flex_item_port_init (struct rte_eth_dev *dev);void mlx5_flex_item_port_cleanup (struct rte_eth_dev *dev); +void mlx5_flex_flow_translate_item (struct rte_eth_dev *dev,void *matcher, +void *key,const struct rte_flow_item *item, +bool is_inner); +int mlx5_flex_acquire_index (struct rte_eth_dev *dev, +struct rte_flow_item_flex_handle *handle, +bool acquire); +int mlx5_flex_release_index (struct rte_eth_dev *dev,int index); +/* Flex parser list callbacks. */ struct mlx5_list_entry *mlx5_flex_parser_create_cb (void *list_ctx,void *ctx); int mlx5_flex_parser_match_cb(void *list_ctx,
drivers/net/mlx5/mlx5_flow_flex.c +223 -0
229 lines not on this page · raw message
Signature · 1 line
2.33.1
PATCH 9/9 net/mlx5: handle flex item in flows
In reply to Gregory EtelsonProvide flex item recognition, validation and translation in flow patterns. Track the flex item referencing.
--- drivers/net/mlx5/mlx5_flow.h | 9 ++- drivers/net/mlx5/mlx5_flow_dv.c | 124 ++++++++++++++++++++++++++++++++ 2 files changed, 132 insertions(+), 1 deletion(-)
drivers/net/mlx5/mlx5_flow.h +8 -1
@@ -176,6 +176,11 @@ enum mlx5_feature_name {/* Conntrack item. */ #define MLX5_FLOW_LAYER_ASO_CT (UINT64_C(1) << 35) +/* Flex item */ +#define MLX5_FLOW_ITEM_OUTER_FLEX (UINT64_C(1) << 36) +#define MLX5_FLOW_ITEM_INNER_FLEX (UINT64_C(1) << 37) +#define MLX5_FLOW_ITEM_FLEX_TUNNEL (UINT64_C(1) << 38) +/* Outer Masks. */ #define MLX5_FLOW_LAYER_OUTER_L3 \ (MLX5_FLOW_LAYER_OUTER_L3_IPV4 | MLX5_FLOW_LAYER_OUTER_L3_IPV6)
@@ -190,7 +195,8 @@ enum mlx5_feature_name { (MLX5_FLOW_LAYER_VXLAN |MLX5_FLOW_LAYER_VXLAN_GPE | \MLX5_FLOW_LAYER_GRE |MLX5_FLOW_LAYER_NVGRE |MLX5_FLOW_LAYER_MPLS | \MLX5_FLOW_LAYER_IPIP |MLX5_FLOW_LAYER_IPV6_ENCAP | \ -MLX5_FLOW_LAYER_GENEVE |MLX5_FLOW_LAYER_GTP ) +MLX5_FLOW_LAYER_GENEVE |MLX5_FLOW_LAYER_GTP | \ +MLX5_FLOW_ITEM_FLEX_TUNNEL ) /* Inner Masks. */#define MLX5_FLOW_LAYER_INNER_L3 \
@@ -689,6 +695,7 @@ struct mlx5_flow_handle { uint32_t is_meter_flow_id:1; /**< Indate if flow_id is for meter. */ uint32_t mark:1; /**< Metadate rxq mark flag. */ uint32_t fate_action:3; /**< Fate action type. */ +uint32_t flex_item;/**< referenced Flex Item bitmask. */ union {uint32_t rix_hrxq;/**< Hash Rx queue object index. */ uint32_t rix_jump;/**< Index to the jump action resource. */
drivers/net/mlx5/mlx5_flow_dv.c +124 -0
159 lines not on this page · raw message
Signature · 1 line
2.33.1
v2 cover net/mlx5: add flex item support
In reply to Gregory EtelsonGregory Etelson (4):
common/mlx5: extend flex parser capabilities common/mlx5: fix flex parser DevX creation routine net/mlx5: add flex parser DevX object management net/mlx5: handle flex item in flows
Viacheslav Ovsiienko (5):
common/mlx5: refactor HCA attributes query net/mlx5: update eCPRI flex parser structures net/mlx5: add flex item API
net/mlx5: translate flex item configuration net/mlx5: translate flex item pattern into matcher
drivers/common/mlx5/mlx5_devx_cmds.c | 239 +++-- drivers/common/mlx5/mlx5_devx_cmds.h | 65 +- drivers/common/mlx5/mlx5_prm.h | 50 +- drivers/net/mlx5/linux/mlx5_os.c | 14 + drivers/net/mlx5/meson.build | 1 + drivers/net/mlx5/mlx5.c | 15 +- drivers/net/mlx5/mlx5.h | 79 +- drivers/net/mlx5/mlx5_flow.c | 49 + drivers/net/mlx5/mlx5_flow.h | 27 +- drivers/net/mlx5/mlx5_flow_dv.c | 127 ++- drivers/net/mlx5/mlx5_flow_flex.c | 1373 ++++++++++++++++++++++++++ 11 files changed, 1913 insertions(+), 126 deletions(-) create mode 100644 drivers/net/mlx5/mlx5_flow_flex.c
Signature · 3 lines
v2: rebase to updated master-net-mlx. -- 2.33.1
PATCH v2 1/9 common/mlx5: refactor HCA attributes query
From: Viacheslav Ovsiienko <[email protected]>
There is the common part of code querying the HCA attributes from the device, and this part can be commoditized as dedicated routine.
--- drivers/common/mlx5/mlx5_devx_cmds.c | 173 +++++++++++---------------- 1 file changed, 73 insertions(+), 100 deletions(-)
drivers/common/mlx5/mlx5_devx_cmds.c +73 -100
@@ -13,6 +13,42 @@#include "mlx5_common_log.h" #include "mlx5_malloc.h" +static void * +mlx5_devx_get_hca_cap (void *ctx,uint32_t *in,uint32_t *out, +int *err,uint32_t flags) +{ +const size_t size_in =MLX5_ST_SZ_DW (query_hca_cap_in) *sizeof (int ); +const size_t size_out =MLX5_ST_SZ_DW (query_hca_cap_out) *sizeof (int ); +int status, syndrome, rc; + +if (err) + *err =0 ; +memset (in,0 , size_in); +memset (out,0 , size_out); +MLX5_SET (query_hca_cap_in, in, opcode,MLX5_CMD_OP_QUERY_HCA_CAP ); +MLX5_SET (query_hca_cap_in, in, op_mod, flags); + rc = mlx5_glue->devx_general_cmd (ctx, in, size_in, out, size_out); +if (rc) { +DRV_LOG (ERR , +"Failed to query devx HCA capabilities func %#02x" , + flags >>1 ); +if (err) + *err = rc >0 ? -rc : rc; +return NULL ; + } + status =MLX5_GET (query_hca_cap_out, out, status); + syndrome =MLX5_GET (query_hca_cap_out, out, syndrome); +if (status) { +DRV_LOG (ERR , +"Failed to query devx HCA capabilities func %#02x status %x, syndrome = %x" , + flags >>1 , status, syndrome); +if (err) + *err =-1 ; +return NULL ; + } +return MLX5_ADDR_OF (query_hca_cap_out, out, capability); +} +/** * Perform read access to the registers. Reads data from register * and writes ones to the specified buffer.
@@ -472,21 +508,15 @@ static voidmlx5_devx_cmd_query_hca_vdpa_attr (void *ctx, struct mlx5_hca_vdpa_attr *vdpa_attr) { -uint32_t in[MLX5_ST_SZ_DW (query_hca_cap_in)] = {0 }; -uint32_t out[MLX5_ST_SZ_DW (query_hca_cap_out)] = {0 }; -void *hcattr =MLX5_ADDR_OF (query_hca_cap_out, out, capability); -int status, syndrome, rc; +uint32_t in[MLX5_ST_SZ_DW (query_hca_cap_in)]; +uint32_t out[MLX5_ST_SZ_DW (query_hca_cap_out)]; +void *hcattr; -MLX5_SET (query_hca_cap_in, in, opcode,MLX5_CMD_OP_QUERY_HCA_CAP ); -MLX5_SET (query_hca_cap_in, in, op_mod, -MLX5_GET_HCA_CAP_OP_MOD_VDPA_EMULATION | -MLX5_HCA_CAP_OPMOD_GET_CUR ); - rc = mlx5_glue->devx_general_cmd (ctx, in,sizeof (in), out,sizeof (out)); - status =MLX5_GET (query_hca_cap_out, out, status); - syndrome =MLX5_GET (query_hca_cap_out, out, syndrome); -if (rc || status) { -RTE_LOG (DEBUG ,PMD ,"Failed to query devx VDPA capabilities," -" status %x, syndrome = %x" , status, syndrome); + hcattr =mlx5_devx_get_hca_cap (ctx, in, out,NULL , +MLX5_GET_HCA_CAP_OP_MOD_VDPA_EMULATION | +MLX5_HCA_CAP_OPMOD_GET_CUR ); +if (!hcattr) { +RTE_LOG (DEBUG ,PMD ,"Failed to query devx VDPA capabilities" ); vdpa_attr->valid =0 ; }else { vdpa_attr->valid =1 ;
@@ -741,27 +771,15 @@ mlx5_devx_cmd_query_hca_attr(void *ctx, {uint32_t in[MLX5_ST_SZ_DW (query_hca_cap_in)] = {0 };uint32_t out[MLX5_ST_SZ_DW (query_hca_cap_out)] = {0 }; -void *hcattr; -int status, syndrome, rc, i;uint64_t general_obj_types_supported =0 ; +void *hcattr; +int rc, i; -MLX5_SET (query_hca_cap_in, in, opcode,MLX5_CMD_OP_QUERY_HCA_CAP ); -MLX5_SET (query_hca_cap_in, in, op_mod, -MLX5_GET_HCA_CAP_OP_MOD_GENERAL_DEVICE | -MLX5_HCA_CAP_OPMOD_GET_CUR ); - - rc = mlx5_glue->devx_general_cmd (ctx, - in,sizeof (in), out,sizeof (out)); -if (rc) - goto error; - status =MLX5_GET (query_hca_cap_out, out, status); - syndrome =MLX5_GET (query_hca_cap_out, out, syndrome); -if (status) { -DRV_LOG (DEBUG ,"Failed to query devx HCA capabilities, " -"status %x, syndrome = %x" , status, syndrome); -return -1 ; - } - hcattr =MLX5_ADDR_OF (query_hca_cap_out, out, capability); + hcattr =mlx5_devx_get_hca_cap (ctx, in, out, &rc, +MLX5_GET_HCA_CAP_OP_MOD_GENERAL_DEVICE | +MLX5_HCA_CAP_OPMOD_GET_CUR ); +if (!hcattr) +return rc; attr->flow_counter_bulk_alloc_bitmap =MLX5_GET (cmd_hca_cap, hcattr, flow_counter_bulk_alloc); attr->flow_counters_dump = MLX5_GET(cmd_hca_cap, hcattr,
@@ -893,19 +911,13 @@ mlx5_devx_cmd_query_hca_attr(void *ctx, general_obj_types) & MLX5_GENERAL_OBJ_TYPES_CAP_CONN_TRACK_OFFLOAD);if (attr->qos.sup) { -MLX5_SET (query_hca_cap_in, in, op_mod, -MLX5_GET_HCA_CAP_OP_MOD_QOS_CAP | -MLX5_HCA_CAP_OPMOD_GET_CUR ); - rc = mlx5_glue->devx_general_cmd (ctx, in,sizeof (in), - out,sizeof (out)); -if (rc) - goto error; -if (status) { -DRV_LOG (DEBUG ,"Failed to query devx QOS capabilities," -" status %x, syndrome = %x" , status, syndrome); -return -1 ; + hcattr =mlx5_devx_get_hca_cap (ctx, in, out, &rc, +MLX5_GET_HCA_CAP_OP_MOD_QOS_CAP | +MLX5_HCA_CAP_OPMOD_GET_CUR ); +if (!hcattr) { +DRV_LOG (DEBUG ,"Failed to query devx QOS capabilities" ); +return rc; } - hcattr =MLX5_ADDR_OF (query_hca_cap_out, out, capability); attr->qos.flow_meter_old =MLX5_GET (qos_cap, hcattr, flow_meter_old); attr->qos.log_max_flow_meter =
@@ -934,27 +946,14 @@ mlx5_devx_cmd_query_hca_attr(void *ctx,mlx5_devx_cmd_query_hca_vdpa_attr (ctx, &attr->vdpa);if (!attr->eth_net_offloads)return 0 ; -/* Query Flow Sampler Capability From FLow Table Properties Layout. */ -memset (in,0 ,sizeof (in)); -memset (out,0 ,sizeof (out)); -MLX5_SET (query_hca_cap_in, in, opcode,MLX5_CMD_OP_QUERY_HCA_CAP ); -MLX5_SET (query_hca_cap_in, in, op_mod, -MLX5_GET_HCA_CAP_OP_MOD_NIC_FLOW_TABLE | -MLX5_HCA_CAP_OPMOD_GET_CUR ); - - rc = mlx5_glue->devx_general_cmd (ctx, in,sizeof (in), out,sizeof (out)); -if (rc) - goto error; - status =MLX5_GET (query_hca_cap_out, out, status); - syndrome =MLX5_GET (query_hca_cap_out, out, syndrome); -if (status) { -DRV_LOG (DEBUG ,"Failed to query devx HCA capabilities, " -"status %x, syndrome = %x" , status, syndrome); + hcattr =mlx5_devx_get_hca_cap (ctx, in, out, &rc, +MLX5_GET_HCA_CAP_OP_MOD_NIC_FLOW_TABLE | +MLX5_HCA_CAP_OPMOD_GET_CUR ); +if (!hcattr) { attr->log_max_ft_sampler_num =0 ; -return -1 ; +return rc; } - hcattr =MLX5_ADDR_OF (query_hca_cap_out, out, capability); attr->log_max_ft_sampler_num =MLX5_GET (flow_table_nic_cap, hcattr, flow_table_properties_nic_receive.log_max_ft_sampler_num);
@@ -969,27 +968,13 @@ mlx5_devx_cmd_query_hca_attr(void *ctx, (flow_table_nic_cap, hcattr, ft_field_support_2_nic_receive.outer_ipv4_ihl);/* Query HCA offloads for Ethernet protocol. */ -memset (in,0 ,sizeof (in)); -memset (out,0 ,sizeof (out)); -MLX5_SET (query_hca_cap_in, in, opcode,MLX5_CMD_OP_QUERY_HCA_CAP ); -MLX5_SET (query_hca_cap_in, in, op_mod, -MLX5_GET_HCA_CAP_OP_MOD_ETHERNET_OFFLOAD_CAPS | -MLX5_HCA_CAP_OPMOD_GET_CUR ); - - rc = mlx5_glue->devx_general_cmd (ctx, in,sizeof (in), out,sizeof (out)); -if (rc) { + hcattr =mlx5_devx_get_hca_cap (ctx, in, out, &rc, +MLX5_GET_HCA_CAP_OP_MOD_ETHERNET_OFFLOAD_CAPS | +MLX5_HCA_CAP_OPMOD_GET_CUR ); +if (!hcattr) { attr->eth_net_offloads =0 ; - goto error; +return rc; } - status =MLX5_GET (query_hca_cap_out, out, status); - syndrome =MLX5_GET (query_hca_cap_out, out, syndrome); -if (status) { -DRV_LOG (DEBUG ,"Failed to query devx HCA capabilities, " -"status %x, syndrome = %x" , status, syndrome); - attr->eth_net_offloads =0 ; -return -1 ; - } - hcattr =MLX5_ADDR_OF (query_hca_cap_out, out, capability); attr->wqe_vlan_insert =MLX5_GET (per_protocol_networking_offload_caps, hcattr, wqe_vlan_insert); attr->csum_cap = MLX5_GET(per_protocol_networking_offload_caps,
@@ -1044,26 +1029,14 @@ mlx5_devx_cmd_query_hca_attr(void *ctx, hcattr, rss_ind_tbl_cap);/* Query HCA attribute for ROCE. */ if (attr->roce) { -memset (in,0 ,sizeof (in)); -memset (out,0 ,sizeof (out)); -MLX5_SET (query_hca_cap_in, in, opcode, -MLX5_CMD_OP_QUERY_HCA_CAP ); -MLX5_SET (query_hca_cap_in, in, op_mod, -MLX5_GET_HCA_CAP_OP_MOD_ROCE | -MLX5_HCA_CAP_OPMOD_GET_CUR ); - rc = mlx5_glue->devx_general_cmd (ctx, in,sizeof (in), - out,sizeof (out)); -if (rc) - goto error; - status =MLX5_GET (query_hca_cap_out, out, status); - syndrome =MLX5_GET (query_hca_cap_out, out, syndrome); -if (status) { + hcattr =mlx5_devx_get_hca_cap (ctx, in, out, &rc, +MLX5_GET_HCA_CAP_OP_MOD_ROCE | +MLX5_HCA_CAP_OPMOD_GET_CUR ); +if (!hcattr) {DRV_LOG (DEBUG , -"Failed to query devx HCA ROCE capabilities, " -"status %x, syndrome = %x" , status, syndrome); -return -1 ; +"Failed to query devx HCA ROCE capabilities" ); +return rc; } - hcattr =MLX5_ADDR_OF (query_hca_cap_out, out, capability); attr->qp_ts_format =MLX5_GET (roce_caps, hcattr, qp_ts_format); } if (attr->eth_virt &&
Signature · 1 line
2.33.1
PATCH v2 2/9 common/mlx5: extend flex parser capabilities
In reply to Gregory EtelsonMLX5 PARSE_GRAPH_NODE is the main data structure used by the Flex Parser when a new parsing protocol is defined. While software creates PARSE_GRAPH_NODE object for a new protocol, it must verify that configuration parameters it uses comply with hardware limits.
The patch queries hardware PARSE_GRAPH_NODE capabilities and stores ones in PMD internal configuration structure:
- query capabilities from parse_graph_node attribute page
- query max_num_prog_sample_field capability from HCA page 2
--- drivers/common/mlx5/mlx5_devx_cmds.c | 57 ++++++++++++++++++++++++ drivers/common/mlx5/mlx5_devx_cmds.h | 65 +++++++++++++++++++++++++++- drivers/common/mlx5/mlx5_prm.h | 50 ++++++++++++++++++++- 3 files changed, 168 insertions(+), 4 deletions(-)
drivers/common/mlx5/mlx5_devx_cmds.c +57 -0
@@ -729,6 +729,53 @@ mlx5_devx_cmd_create_flex_parser(void *ctx,return parse_flex_obj; } +static int +mlx5_devx_cmd_query_hca_parse_graph_node_cap + (void *ctx,struct mlx5_hca_flex_attr *attr) +{ +uint32_t in[MLX5_ST_SZ_DW (query_hca_cap_in)]; +uint32_t out[MLX5_ST_SZ_DW (query_hca_cap_out)]; +void *hcattr; +int rc; + + hcattr =mlx5_devx_get_hca_cap (ctx, in, out, &rc, +MLX5_GET_HCA_CAP_OP_MOD_PARSE_GRAPH_NODE_CAP | +MLX5_HCA_CAP_OPMOD_GET_CUR ); +if (!hcattr) +return rc; + attr->node_in =MLX5_GET (parse_graph_node_cap, hcattr, node_in); + attr->node_out =MLX5_GET (parse_graph_node_cap, hcattr, node_out); + attr->header_length_mode =MLX5_GET (parse_graph_node_cap, hcattr, + header_length_mode); + attr->sample_offset_mode =MLX5_GET (parse_graph_node_cap, hcattr, + sample_offset_mode); + attr->max_num_arc_in =MLX5_GET (parse_graph_node_cap, hcattr, + max_num_arc_in); + attr->max_num_arc_out =MLX5_GET (parse_graph_node_cap, hcattr, + max_num_arc_out); + attr->max_num_sample =MLX5_GET (parse_graph_node_cap, hcattr, + max_num_sample); + attr->sample_id_in_out =MLX5_GET (parse_graph_node_cap, hcattr, + sample_id_in_out); + attr->max_base_header_length =MLX5_GET (parse_graph_node_cap, hcattr, + max_base_header_length); + attr->max_sample_base_offset =MLX5_GET (parse_graph_node_cap, hcattr, + max_sample_base_offset); + attr->max_next_header_offset =MLX5_GET (parse_graph_node_cap, hcattr, + max_next_header_offset); + attr->header_length_mask_width =MLX5_GET (parse_graph_node_cap, hcattr, + header_length_mask_width); +/* Get the max supported samples from HCA CAP 2 */ + hcattr =mlx5_devx_get_hca_cap (ctx, in, out, &rc, +MLX5_GET_HCA_CAP_OP_MOD_GENERAL_DEVICE_2 | +MLX5_HCA_CAP_OPMOD_GET_CUR ); +if (!hcattr) +return rc; + attr->max_num_prog_sample = +MLX5_GET (cmd_hca_cap_2, hcattr, max_num_prog_sample_field); +return 0 ; +} +static int mlx5_devx_query_pkt_integrity_match (void *hcattr) {
@@ -942,6 +989,16 @@ mlx5_devx_cmd_query_hca_attr(void *ctx, log_max_num_meter_aso); } } +/* +* Flex item support needs max_num_prog_sample_field +* from the Capabilities 2 table for PARSE_GRAPH_NODE +*/ +if (attr->parse_graph_flex_node) { + rc =mlx5_devx_cmd_query_hca_parse_graph_node_cap + (ctx, &attr->flex); +if (rc) +return -1 ; + }if (attr->vdpa.valid)mlx5_devx_cmd_query_hca_vdpa_attr (ctx, &attr->vdpa);if (!attr->eth_net_offloads)
drivers/common/mlx5/mlx5_devx_cmds.h +63 -2
89 lines not on this page · raw message
drivers/common/mlx5/mlx5_prm.h +48 -2
91 lines not on this page · raw message
Signature · 1 line
2.33.1
PATCH v2 3/9 common/mlx5: fix flex parser DevX creation routine
In reply to Gregory EtelsonAdd missing modify_field_select, next_header_field_size field values setting.
--- drivers/common/mlx5/mlx5_devx_cmds.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
drivers/common/mlx5/mlx5_devx_cmds.c +7 -2
@@ -620,10 +620,9 @@ mlx5_devx_cmd_query_parse_samples(struct mlx5_devx_obj *flex_obj,return ret; } -struct mlx5_devx_obj *mlx5_devx_cmd_create_flex_parser (void *ctx, -struct mlx5_devx_graph_node_attr *data) +struct mlx5_devx_graph_node_attr *data) {uint32_t in[MLX5_ST_SZ_DW (create_flex_parser_in)] = {0 };uint32_t out[MLX5_ST_SZ_DW (general_obj_out_cmd_hdr)] = {0 };
@@ -647,12 +646,18 @@ mlx5_devx_cmd_create_flex_parser(void *ctx, MLX5_GENERAL_OBJ_TYPE_FLEX_PARSE_GRAPH);MLX5_SET (parse_graph_flex, flex, header_length_mode, data->header_length_mode); +MLX5_SET64 (parse_graph_flex, flex, modify_field_select, + data->modify_field_select);MLX5_SET (parse_graph_flex, flex, header_length_base_value, data->header_length_base_value);MLX5_SET (parse_graph_flex, flex, header_length_field_offset, data->header_length_field_offset);MLX5_SET (parse_graph_flex, flex, header_length_field_shift, data->header_length_field_shift); +MLX5_SET (parse_graph_flex, flex, next_header_field_offset, + data->next_header_field_offset); +MLX5_SET (parse_graph_flex, flex, next_header_field_size, + data->next_header_field_size);MLX5_SET (parse_graph_flex, flex, header_length_field_mask, data->header_length_field_mask);for (i =0 ; i <MLX5_GRAPH_NODE_SAMPLE_NUM ; i++) {
Signature · 1 line
2.33.1
PATCH v2 4/9 net/mlx5: update eCPRI flex parser structures
In reply to Gregory EtelsonFrom: Viacheslav Ovsiienko <[email protected]>
To handle eCPRI protocol in the flows the mlx5 PMD engages flex parser hardware feature. While we were implementing eCPRI support we anticipated the flex parser usage extension, and all related variables were named accordingly, containing flex syllabus. Now we are preparing to introduce more common approach of flex item, in order to avoid naming conflicts and improve the code readability the eCPRI infrastructure related variables are renamed as preparation step.
Later, once we have the new flex item implemented, we could consider to refactor the eCPRI protocol support to move on common flex item basis.
--- drivers/net/mlx5/mlx5.c | 9 +++------ drivers/net/mlx5/mlx5.h | 12 +++--------- drivers/net/mlx5/mlx5_flow_dv.c | 2 +- 3 files changed, 7 insertions(+), 16 deletions(-)
drivers/net/mlx5/mlx5.c +3 -6
@@ -866,8 +866,7 @@ bool mlx5_flex_parser_ecpri_exist(struct rte_eth_dev *dev) {struct mlx5_priv *priv = dev->data->dev_private; -struct mlx5_flex_parser_profiles *prf = - &priv->sh->fp[MLX5_FLEX_PARSER_ECPRI_0 ]; +struct mlx5_ecpri_parser_profile *prf = &priv->sh->ecpri_parser;return !!prf->obj; }
@@ -886,8 +885,7 @@ int mlx5_flex_parser_ecpri_alloc(struct rte_eth_dev *dev) {struct mlx5_priv *priv = dev->data->dev_private; -struct mlx5_flex_parser_profiles *prf = - &priv->sh->fp[MLX5_FLEX_PARSER_ECPRI_0 ]; +struct mlx5_ecpri_parser_profile *prf = &priv->sh->ecpri_parser;struct mlx5_devx_graph_node_attr node = { .modify_field_select =0 , };
@@ -950,8 +948,7 @@ static void mlx5_flex_parser_ecpri_release(struct rte_eth_dev *dev) {struct mlx5_priv *priv = dev->data->dev_private; -struct mlx5_flex_parser_profiles *prf = - &priv->sh->fp[MLX5_FLEX_PARSER_ECPRI_0 ]; +struct mlx5_ecpri_parser_profile *prf = &priv->sh->ecpri_parser;if (prf->obj)mlx5_devx_cmd_destroy (prf->obj);
drivers/net/mlx5/mlx5.h +3 -9
@@ -1013,14 +1013,8 @@ struct mlx5_dev_txpp {uint64_t err_ts_future;/* Timestamp in the distant future. */ }; -/* Supported flex parser profile ID. */ -enum mlx5_flex_parser_profile_id { -MLX5_FLEX_PARSER_ECPRI_0 =0 , -MLX5_FLEX_PARSER_MAX =8 , -}; - -/* Sample ID information of flex parser structure. */ -struct mlx5_flex_parser_profiles { +/* Sample ID information of eCPRI flex parser structure. */ +struct mlx5_ecpri_parser_profile {uint32_t num;/* Actual number of samples. */ uint32_t ids[8 ];/* Sample IDs for this profile. */ uint8_t offset[8 ];/* Bytes offset of each parser. */
@@ -1169,7 +1163,7 @@ struct mlx5_dev_ctx_shared {struct mlx5_devx_obj *td;/* Transport domain. */ struct mlx5_lag lag;/* LAG attributes */ void *tx_uar;/* Tx/packet pacing shared UAR. */ -struct mlx5_flex_parser_profiles fp[MLX5_FLEX_PARSER_MAX ]; +struct mlx5_ecpri_parser_profile ecpri_parser;/* Flex parser profiles information. */ void *devx_rx_uar;/* DevX UAR for Rx. */ struct mlx5_aso_age_mng *aso_age_mng;
drivers/net/mlx5/mlx5_flow_dv.c +1 -1
@@ -9892,7 +9892,7 @@ flow_dv_translate_item_ecpri(struct rte_eth_dev *dev, void *matcher,*/ if (!ecpri_m->hdr.common.u32)return ; - samples = priv->sh->fp[MLX5_FLEX_PARSER_ECPRI_0 ].ids; + samples = priv->sh->ecpri_parser.ids;/* Need to take the whole DW as the mask to fill the entry. */ dw_m =MLX5_ADDR_OF (fte_match_set_misc4, misc4_m, prog_sample_field_value_0);
Signature · 1 line
2.33.1
PATCH v2 5/9 net/mlx5: add flex item API
In reply to Gregory EtelsonFrom: Viacheslav Ovsiienko <[email protected]>
This patch is a preparation step of implementing
flex item feature in driver and it provides:
- external entry point routines for flex item
creation/deletion
- flex item objects management over the ports.
The flex item object keeps information about the item created over the port - reference counter to track whether item is in use by some active flows and the pointer to underlying shared DevX object, providing all the data needed to translate the flow flex pattern into matcher fields according hardware configuration.
There is not too many flex items supposed to be created on the port, the design is optimized rather for flow insertion rate than memory savings.
--- drivers/net/mlx5/linux/mlx5_os.c | 4 + drivers/net/mlx5/meson.build | 1 + drivers/net/mlx5/mlx5.c | 2 +- drivers/net/mlx5/mlx5.h | 24 ++++ drivers/net/mlx5/mlx5_flow.c | 49 ++++++++ drivers/net/mlx5/mlx5_flow.h | 18 ++- drivers/net/mlx5/mlx5_flow_dv.c | 3 +- drivers/net/mlx5/mlx5_flow_flex.c | 189 ++++++++++++++++++++++++++++++ 8 files changed, 286 insertions(+), 4 deletions(-) create mode 100644 drivers/net/mlx5/mlx5_flow_flex.c
drivers/net/mlx5/linux/mlx5_os.c +4 -0
@@ -1687,6 +1687,8 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev, err =mlx5_alloc_shared_dr (priv);if (err) goto error; +if (mlx5_flex_item_port_init (eth_dev) <0 ) + goto error; }if (sh->devx && config->dv_flow_en && config->dest_tir) { priv->obj_ops = devx_obj_ops;
@@ -1823,6 +1825,8 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev,claim_zero (rte_eth_switch_domain_free (priv->domain_id));if (priv->hrxqs)mlx5_list_destroy (priv->hrxqs); +if (eth_dev && priv->flex_item_map) +mlx5_flex_item_port_cleanup (eth_dev);mlx5_free (priv);if (eth_dev !=NULL ) eth_dev->data->dev_private =NULL ;
drivers/net/mlx5/meson.build +1 -0
@@ -17,6 +17,7 @@ sources = files( 'mlx5_flow_meter.c', 'mlx5_flow_dv.c', 'mlx5_flow_aso.c', + 'mlx5_flow_flex.c', 'mlx5_mac.c', 'mlx5_rss.c', 'mlx5_rx.c',
drivers/net/mlx5/mlx5.c +1 -1
@@ -378,7 +378,6 @@ static const struct mlx5_indexed_pool_config mlx5_ipool_cfg[] = { }, }; -#define MLX5_FLOW_MIN_ID_POOL_SIZE 512#define MLX5_ID_GENERATION_ARRAY_FACTOR 16
@@ -1683,6 +1682,7 @@ mlx5_dev_close(struct rte_eth_dev *dev)mlx5_mp_os_req_stop_rxtx (dev);/* Free the eCPRI flex parser resource. */ mlx5_flex_parser_ecpri_release (dev); +mlx5_flex_item_port_cleanup (dev);if (priv->rxqs !=NULL ) {/* XXX race condition if mlx5_rx_burst() is still running. */ rte_delay_us_sleep (1000 );
drivers/net/mlx5/mlx5.h +24 -0
@@ -50,6 +50,9 @@#define MLX5_MAX_MODIFY_NUM 32#define MLX5_ROOT_TBL_MODIFY_NUM 16 +/* Maximal number of flex items created on the port.*/ +#define MLX5_PORT_FLEX_ITEM_NUM 4 +enum mlx5_ipool_index {#if defined(HAVE_IBV_FLOW_DV_SUPPORT ) || !defined(HAVE_INFINIBAND_VERBS_H )MLX5_IPOOL_DECAP_ENCAP =0 ,/* Pool for encap/decap resource. */
@@ -1096,6 +1099,12 @@ struct mlx5_lag {uint8_t affinity_mode;/* TIS or hash based affinity */ }; +/* Port flex item context. */ +struct mlx5_flex_item { +struct mlx5_flex_parser_devx *devx_fp;/* DevX flex parser object. */ +uint32_t refcnt;/* Atomically accessed refcnt by flows. */ +}; +/* * Shared Infiniband device context for Master/Representors * which belong to same IB device with multiple IB ports.
@@ -1425,6 +1434,10 @@ struct mlx5_priv {struct mlx5_devx_obj *q_counters;/* DevX queue counter object. */ uint32_t counter_set_id;/* Queue counter ID to set in DevX objects. */ uint32_t lag_affinity_idx;/* LAG mode queue 0 affinity starting. */ +rte_spinlock_t flex_item_sl;/* Flex item list spinlock. */ +struct mlx5_flex_item flex_item[MLX5_PORT_FLEX_ITEM_NUM ]; +/* Flex items have been created on the port. */ +uint32_t flex_item_map;/* Map of allocated flex item elements. */ };#define PORT_ID (priv) ((priv)->dev_data->port_id)
@@ -1804,4 +1817,15 @@ mlx5_get_supported_sw_parsing_offloads(const struct mlx5_hca_attr *attr);uint32_t mlx5_get_supported_tunneling_offloads (const struct mlx5_hca_attr *attr); +/* mlx5_flow_flex.c */ + +struct rte_flow_item_flex_handle * +flow_dv_item_create (struct rte_eth_dev *dev, +const struct rte_flow_item_flex_conf *conf, +struct rte_flow_error *error); +int flow_dv_item_release (struct rte_eth_dev *dev, +const struct rte_flow_item_flex_handle *flex_handle, +struct rte_flow_error *error); +int mlx5_flex_item_port_init (struct rte_eth_dev *dev); +void mlx5_flex_item_port_cleanup (struct rte_eth_dev *dev);#endif /* RTE_PMD_MLX5_H_ */
drivers/net/mlx5/mlx5_flow.c +49 -0
67 lines not on this page · raw message
drivers/net/mlx5/mlx5_flow.h +16 -2
@@ -1232,6 +1232,19 @@ typedef int (*mlx5_flow_create_def_policy_t) (struct rte_eth_dev *dev);typedef void (*mlx5_flow_destroy_def_policy_t ) (struct rte_eth_dev *dev); +typedef struct rte_flow_item_flex_handle *(*mlx5_flow_item_create_t ) + (struct rte_eth_dev *dev, +const struct rte_flow_item_flex_conf *conf, +struct rte_flow_error *error); +typedef int (*mlx5_flow_item_release_t ) + (struct rte_eth_dev *dev, +const struct rte_flow_item_flex_handle *handle, +struct rte_flow_error *error); +typedef int (*mlx5_flow_item_update_t ) + (struct rte_eth_dev *dev, +const struct rte_flow_item_flex_handle *handle, +const struct rte_flow_item_flex_conf *conf, +struct rte_flow_error *error);struct mlx5_flow_driver_ops {mlx5_flow_validate_t validate;
@@ -1266,6 +1279,9 @@ struct mlx5_flow_driver_ops {mlx5_flow_action_update_t action_update;mlx5_flow_action_query_t action_query;mlx5_flow_sync_domain_t sync_domain; +mlx5_flow_item_create_t item_create; +mlx5_flow_item_release_t item_release; +mlx5_flow_item_update_t item_update; };/* mlx5_flow.c */
@@ -1722,6 +1738,4 @@ const struct mlx5_flow_tunnel * mlx5_get_tof(const struct rte_flow_item *items, const struct rte_flow_action *actions, enum mlx5_tof_rule_type *rule_type); - -#endif /* RTE_PMD_MLX5_FLOW_H_ */
drivers/net/mlx5/mlx5_flow_dv.c +2 -1
@@ -17965,7 +17965,8 @@ const struct mlx5_flow_driver_ops mlx5_flow_dv_drv_ops = { .action_update = flow_dv_action_update, .action_query = flow_dv_action_query, .sync_domain = flow_dv_sync_domain, + .item_create = flow_dv_item_create, + .item_release = flow_dv_item_release, }; -#endif /* HAVE_IBV_FLOW_DV_SUPPORT */
drivers/net/mlx5/mlx5_flow_flex.c new file +189 -0
189 lines not on this page · raw message
Signature · 1 line
2.33.1
PATCH v2 6/9 net/mlx5: add flex parser DevX object management
In reply to Gregory EtelsonThe DevX flex parsers can be shared between representors within the same IB context. We should put the flex parser objects into the shared list and engage the standard mlx5_list_xxx API to manage ones.
--- drivers/net/mlx5/linux/mlx5_os.c | 10 +++ drivers/net/mlx5/mlx5.c | 4 + drivers/net/mlx5/mlx5.h | 20 +++++ drivers/net/mlx5/mlx5_flow_flex.c | 121 +++++++++++++++++++++++++++++- 4 files changed, 154 insertions(+), 1 deletion(-)
drivers/net/mlx5/linux/mlx5_os.c +10 -0
@@ -337,6 +337,16 @@ mlx5_alloc_shared_dr(struct mlx5_priv *priv) flow_dv_dest_array_clone_free_cb);if (!sh->dest_array_list) goto error; +/* Init shared flex parsers list, no need lcore_share */ +snprintf (s,sizeof (s),"%s_flex_parsers_list" , sh->ibdev_name); + sh->flex_parsers_dv =mlx5_list_create (s, sh, false, + mlx5_flex_parser_create_cb, + mlx5_flex_parser_match_cb, + mlx5_flex_parser_remove_cb, + mlx5_flex_parser_clone_cb, + mlx5_flex_parser_clone_free_cb); +if (!sh->flex_parsers_dv) + goto error;#endif #ifdef HAVE_MLX5DV_DR void *domain;
drivers/net/mlx5/mlx5.c +4 -0
@@ -1429,6 +1429,10 @@ mlx5_free_shared_dev_ctx(struct mlx5_dev_ctx_shared *sh)mlx5_flow_os_release_workspace (); }pthread_mutex_unlock (&mlx5_dev_ctx_list_mutex); +if (sh->flex_parsers_dv) { +mlx5_list_destroy (sh->flex_parsers_dv); + sh->flex_parsers_dv =NULL ; + }/* * Ensure there is no async event handler installed. * Only primary process handles async device events.
drivers/net/mlx5/mlx5.h +20 -0
@@ -1099,6 +1099,15 @@ struct mlx5_lag {uint8_t affinity_mode;/* TIS or hash based affinity */ }; +/* DevX flex parser context. */ +struct mlx5_flex_parser_devx { +struct mlx5_list_entry entry;/* List element at the beginning. */ +uint32_t num_samples; +void *devx_obj; +struct mlx5_devx_graph_node_attr devx_conf; +uint32_t sample_ids[MLX5_GRAPH_NODE_SAMPLE_NUM ]; +}; +/* Port flex item context. */ struct mlx5_flex_item {struct mlx5_flex_parser_devx *devx_fp;/* DevX flex parser object. */
@@ -1159,6 +1168,7 @@ struct mlx5_dev_ctx_shared {struct mlx5_list *push_vlan_action_list;/* Push VLAN actions. */ struct mlx5_list *sample_action_list;/* List of sample actions. */ struct mlx5_list *dest_array_list; +struct mlx5_list *flex_parsers_dv;/* Flex Item parsers. */ /* List of destination array actions. */ struct mlx5_flow_counter_mng cmng;/* Counters management structure. */ void *default_miss_action;/* Default miss action. */
@@ -1828,4 +1838,14 @@ int flow_dv_item_release(struct rte_eth_dev *dev, struct rte_flow_error *error);int mlx5_flex_item_port_init (struct rte_eth_dev *dev);void mlx5_flex_item_port_cleanup (struct rte_eth_dev *dev); +/* Flex parser list callbacks. */ +struct mlx5_list_entry *mlx5_flex_parser_create_cb (void *list_ctx,void *ctx); +int mlx5_flex_parser_match_cb (void *list_ctx, +struct mlx5_list_entry *iter,void *ctx); +void mlx5_flex_parser_remove_cb (void *list_ctx,struct mlx5_list_entry *entry); +struct mlx5_list_entry *mlx5_flex_parser_clone_cb (void *list_ctx, +struct mlx5_list_entry *entry, +void *ctx); +void mlx5_flex_parser_clone_free_cb (void *tool_ctx, +struct mlx5_list_entry *entry);#endif /* RTE_PMD_MLX5_H_ */
drivers/net/mlx5/mlx5_flow_flex.c +120 -1
156 lines not on this page · raw message
Signature · 1 line
2.33.1
PATCH v2 7/9 net/mlx5: translate flex item configuration
In reply to Gregory EtelsonFrom: Viacheslav Ovsiienko <[email protected]>
RTE Flow flex item configuration should be translated into actual hardware settings:
- translate header length and next protocol field samplings
- translate data field sampling, the similar fields with the same mode and matching related parameters are relocated and grouped to be covered with minimal amount of hardware sampling registers (each register can cover arbitrary neighbour 32 bits (aligned to byte boundary) in the packet and we can combine the fields with smaller lengths or segments of bigger fields)
- input and output links translation
- preparing data for parsing flex item pattern on flow creation
--- drivers/net/mlx5/mlx5.h | 15 + drivers/net/mlx5/mlx5_flow_flex.c | 844 +++++++++++++++++++++++++++++- 2 files changed, 858 insertions(+), 1 deletion(-)
drivers/net/mlx5/mlx5.h +15 -0
@@ -53,6 +53,9 @@/* Maximal number of flex items created on the port.*/ #define MLX5_PORT_FLEX_ITEM_NUM 4 +/* Maximal number of field/field parts to map into sample registers .*/ +#define MLX5_FLEX_ITEM_MAPPING_NUM 32 +enum mlx5_ipool_index {#if defined(HAVE_IBV_FLOW_DV_SUPPORT ) || !defined(HAVE_INFINIBAND_VERBS_H )MLX5_IPOOL_DECAP_ENCAP =0 ,/* Pool for encap/decap resource. */
@@ -1108,10 +1111,22 @@ struct mlx5_flex_parser_devx {uint32_t sample_ids[MLX5_GRAPH_NODE_SAMPLE_NUM ]; }; +/* Pattern field dscriptor - how to translate flex pattern into samples. */ +__extension__ +struct mlx5_flex_pattern_field { +uint16_t width:6 ; +uint16_t shift:5 ; +uint16_t reg_id:5 ; +}; +#define MLX5_INVALID_SAMPLE_REG_ID 0x1F +/* Port flex item context. */ struct mlx5_flex_item {struct mlx5_flex_parser_devx *devx_fp;/* DevX flex parser object. */ uint32_t refcnt;/* Atomically accessed refcnt by flows. */ +enum rte_flow_item_flex_tunnel_mode tunnel_mode;/* Tunnel mode. */ +uint32_t mapnum;/* Number of pattern translation entries. */ +struct mlx5_flex_pattern_field map[MLX5_FLEX_ITEM_MAPPING_NUM ]; };/*
drivers/net/mlx5/mlx5_flow_flex.c +843 -1
862 lines not on this page · raw message
Signature · 1 line
2.33.1
PATCH v2 8/9 net/mlx5: translate flex item pattern into matcher
In reply to Gregory EtelsonFrom: Viacheslav Ovsiienko <[email protected]>
The matcher is an steering engine entity that represents the flow pattern to hardware to match. It order to provide match on the flex item pattern the appropriate matcher fields should be configured with values and masks accordingly.
The flex item related matcher fields is an array of eight 32-bit fields to match with data captured by sample registers of configured flex parser. One packet field, presented in item pattern can be split between several sample registers, and multiple fields can be combined together into single sample register to optimize hardware resources usage (number os sample registers is limited), depending on field modes, widths and offsets. Actual mapping is complicated and controlled by special translation data, built by PMD on flex item creation.
--- drivers/net/mlx5/mlx5.h | 8 ++ drivers/net/mlx5/mlx5_flow_flex.c | 223 ++++++++++++++++++++++++++++++ 2 files changed, 231 insertions(+)
drivers/net/mlx5/mlx5.h +8 -0
@@ -1853,6 +1853,14 @@ int flow_dv_item_release(struct rte_eth_dev *dev, struct rte_flow_error *error);int mlx5_flex_item_port_init (struct rte_eth_dev *dev);void mlx5_flex_item_port_cleanup (struct rte_eth_dev *dev); +void mlx5_flex_flow_translate_item (struct rte_eth_dev *dev,void *matcher, +void *key,const struct rte_flow_item *item, +bool is_inner); +int mlx5_flex_acquire_index (struct rte_eth_dev *dev, +struct rte_flow_item_flex_handle *handle, +bool acquire); +int mlx5_flex_release_index (struct rte_eth_dev *dev,int index); +/* Flex parser list callbacks. */ struct mlx5_list_entry *mlx5_flex_parser_create_cb (void *list_ctx,void *ctx); int mlx5_flex_parser_match_cb(void *list_ctx,
drivers/net/mlx5/mlx5_flow_flex.c +223 -0
229 lines not on this page · raw message
Signature · 1 line
2.33.1
PATCH v2 9/9 net/mlx5: handle flex item in flows
In reply to Gregory EtelsonProvide flex item recognition, validation and translation in flow patterns. Track the flex item referencing.
--- drivers/net/mlx5/mlx5_flow.h | 9 ++- drivers/net/mlx5/mlx5_flow_dv.c | 124 ++++++++++++++++++++++++++++++++ 2 files changed, 132 insertions(+), 1 deletion(-)
drivers/net/mlx5/mlx5_flow.h +8 -1
@@ -179,6 +179,11 @@ enum mlx5_feature_name {/* Conntrack item. */ #define MLX5_FLOW_LAYER_ASO_CT (UINT64_C(1) << 36) +/* Flex item */ +#define MLX5_FLOW_ITEM_OUTER_FLEX (UINT64_C(1) << 36) +#define MLX5_FLOW_ITEM_INNER_FLEX (UINT64_C(1) << 37) +#define MLX5_FLOW_ITEM_FLEX_TUNNEL (UINT64_C(1) << 38) +/* Outer Masks. */ #define MLX5_FLOW_LAYER_OUTER_L3 \ (MLX5_FLOW_LAYER_OUTER_L3_IPV4 | MLX5_FLOW_LAYER_OUTER_L3_IPV6)
@@ -193,7 +198,8 @@ enum mlx5_feature_name { (MLX5_FLOW_LAYER_VXLAN |MLX5_FLOW_LAYER_VXLAN_GPE | \MLX5_FLOW_LAYER_GRE |MLX5_FLOW_LAYER_NVGRE |MLX5_FLOW_LAYER_MPLS | \MLX5_FLOW_LAYER_IPIP |MLX5_FLOW_LAYER_IPV6_ENCAP | \ -MLX5_FLOW_LAYER_GENEVE |MLX5_FLOW_LAYER_GTP ) +MLX5_FLOW_LAYER_GENEVE |MLX5_FLOW_LAYER_GTP | \ +MLX5_FLOW_ITEM_FLEX_TUNNEL ) /* Inner Masks. */#define MLX5_FLOW_LAYER_INNER_L3 \
@@ -692,6 +698,7 @@ struct mlx5_flow_handle { uint32_t is_meter_flow_id:1; /**< Indate if flow_id is for meter. */ uint32_t mark:1; /**< Metadate rxq mark flag. */ uint32_t fate_action:3; /**< Fate action type. */ +uint32_t flex_item;/**< referenced Flex Item bitmask. */ union {uint32_t rix_hrxq;/**< Hash Rx queue object index. */ uint32_t rix_jump;/**< Index to the jump action resource. */
drivers/net/mlx5/mlx5_flow_dv.c +124 -0
159 lines not on this page · raw message
Signature · 1 line
2.33.1
Hi,
Quoted 34 lines
-----Original Message-----
From: dev <[email protected]> On Behalf Of Gregory Etelson
Sent: Tuesday, November 2, 2021 10:54 AM
To: [email protected]; Gregory Etelson <[email protected]>; Slava Ovsiienko <[email protected]>
Cc: Matan Azrad <[email protected]>
Subject: [dpdk-dev] [PATCH v2 0/9] net/mlx5: add flex item supportGregory Etelson (4):
common/mlx5: extend flex parser capabilities common/mlx5: fix flex parser DevX creation routine net/mlx5: add flex parser DevX object management net/mlx5: handle flex item in flowsViacheslav Ovsiienko (5):
common/mlx5: refactor HCA attributes query net/mlx5: update eCPRI flex parser structures net/mlx5: add flex item API
net/mlx5: translate flex item configuration net/mlx5: translate flex item pattern into matcherdrivers/common/mlx5/mlx5_devx_cmds.c | 239 +++-- drivers/common/mlx5/mlx5_devx_cmds.h | 65 +- drivers/common/mlx5/mlx5_prm.h | 50 +- drivers/net/mlx5/linux/mlx5_os.c | 14 + drivers/net/mlx5/meson.build | 1 + drivers/net/mlx5/mlx5.c | 15 +- drivers/net/mlx5/mlx5.h | 79 +- drivers/net/mlx5/mlx5_flow.c | 49 + drivers/net/mlx5/mlx5_flow.h | 27 +- drivers/net/mlx5/mlx5_flow_dv.c | 127 ++- drivers/net/mlx5/mlx5_flow_flex.c | 1373 ++++++++++++++++++++++++++ 11 files changed, 1913 insertions(+), 126 deletions(-) create mode 100644
Quoted 6 lines
drivers/net/mlx5/mlx5_flow_flex.c--
v2: rebase to updated master-net-mlx.
--
2.33.1
Series applied to next-net-mlx,
Kindest regards,
Raslan Darawsheh
Quoted 6 lines · Gregory Etelson
Gregory Etelson (4):
common/mlx5: extend flex parser capabilities common/mlx5: fix flex parser DevX creation routine net/mlx5: add flex parser DevX object management net/mlx5: handle flex item in flows
Quoted 7 lines
Viacheslav Ovsiienko (5):
common/mlx5: refactor HCA attributes query net/mlx5: update eCPRI flex parser structures net/mlx5: add flex item API
net/mlx5: translate flex item configuration net/mlx5: translate flex item pattern into matcher
Hi Gregory,
Can you please check following doc error [1] and build error [2]:
[1]
$ ./devtools/check-doc-vs-code.sh
rte_flow doc out of sync for mlx5
item flex[2]
from ../lib/eal/x86/include/rte_rwlock.h:13,
from ../lib/eal/include/rte_fbarray.h:40,
from ../lib/eal/include/rte_memory.h:25,
from ../lib/eal/include/rte_malloc.h:17,
from ../drivers/net/mlx5/mlx5_flow_flex.c:4:../drivers/net/mlx5/mlx5_flow_flex.c: In function ‘mlx5_flex_flow_translate_item’:../drivers/net/mlx5/mlx5_flow_flex.c:240:37: error: ‘priv’ undeclared (first use in this function)
240 | MLX5_ASSERT(mlx5_flex_index(priv, tp) >= 0);
| ^~~~../lib/eal/include/rte_branch_prediction.h:38:45: note: in definition of macro ‘unlikely’
38 | #define unlikely(x) __builtin_expect(!!(x), 0)
| ^../lib/eal/include/rte_debug.h:47:25: note: in expansion of macro ‘RTE_VERIFY’
47 | #define RTE_ASSERT(exp) RTE_VERIFY(exp)
| ^~~~~~~~~~
../drivers/common/mlx5/mlx5_common.h:104:26: note: in expansion of macro ‘RTE_ASSERT’
104 | #define MLX5_ASSERT(exp) RTE_ASSERT(exp)
| ^~~~~~~~~~
../drivers/net/mlx5/mlx5_flow_flex.c:240:9: note: in expansion of macro ‘MLX5_ASSERT’
240 | MLX5_ASSERT(mlx5_flex_index(priv, tp) >= 0);
| ^~~~~~~~~~~../drivers/net/mlx5/mlx5_flow_flex.c:240:37: note: each undeclared identifier is reported only once for each function it appears in
240 | MLX5_ASSERT(mlx5_flex_index(priv, tp) >= 0);
| ^~~~../lib/eal/include/rte_branch_prediction.h:38:45: note: in definition of macro ‘unlikely’
38 | #define unlikely(x) __builtin_expect(!!(x), 0)
| ^../lib/eal/include/rte_debug.h:47:25: note: in expansion of macro ‘RTE_VERIFY’
47 | #define RTE_ASSERT(exp) RTE_VERIFY(exp)
| ^~~~~~~~~~
../drivers/common/mlx5/mlx5_common.h:104:26: note: in expansion of macro ‘RTE_ASSERT’
104 | #define MLX5_ASSERT(exp) RTE_ASSERT(exp)
| ^~~~~~~~~~
../drivers/net/mlx5/mlx5_flow_flex.c:240:9: note: in expansion of macro ‘MLX5_ASSERT’
240 | MLX5_ASSERT(mlx5_flex_index(priv, tp) >= 0);
| ^~~~~~~~~~~