net/mlx5: reorganize main structures
PATCH v4 1/4 net/mlx5: reorganize main structures
Reorganize rte_flow_hw and rte_flow_nt2hws structures for better performance, and removed packed.
--- drivers/net/mlx5/mlx5_flow.h | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-)
drivers/net/mlx5/mlx5_flow.h +12 -14
@@ -1328,12 +1328,12 @@ struct rte_flow_nt2hws {struct rte_flow_hw_aux *flow_aux;/** Modify header pointer. */ struct mlx5_flow_dv_modify_hdr_resource *modify_hdr; +/** Chain NTA flows. */ +SLIST_ENTRY (rte_flow_hw) next;/** Encap/decap index. */ uint32_t rix_encap_decap;uint8_t chaned_flow; -/** Chain NTA flows. */ -SLIST_ENTRY (rte_flow_hw) next; -} __rte_packed; +};/** HWS flow struct. */ struct rte_flow_hw {
@@ -1345,6 +1345,12 @@ struct rte_flow_hw { };/** Application's private data passed to enqueued flow operation. */ void *user_data; +union { +/** Jump action. */ +struct mlx5_hw_jump_action *jump; +/** TIR action. */ +struct mlx5_hrxq *hrxq; + };/** Flow index from indexed pool. */ uint32_t idx;/** Resource index from indexed pool. */
@@ -1353,20 +1359,12 @@ struct rte_flow_hw {uint32_t rule_idx;/** Which flow fields (inline or in auxiliary struct) are used. */ uint32_t flags; +/** COUNT action index. */ +cnt_id_t cnt_id;/** Ongoing flow operation type. */ uint8_t operation_type;/** Index of pattern template this flow is based on. */ uint8_t mt_idx; - -/** COUNT action index. */ -cnt_id_t cnt_id; -union { -/** Jump action. */ -struct mlx5_hw_jump_action *jump; -/** TIR action. */ -struct mlx5_hrxq *hrxq; - }; -/** Equals true if it is non template rule. */ bool nt_rule;/**
@@ -1377,7 +1375,7 @@ struct rte_flow_hw {uint8_t padding[9 ];/** HWS layer data struct. */ uint8_t rule[]; -} __rte_packed; +};/** Auxiliary data fields that are updatable. */ struct rte_flow_hw_aux_fields {
Signature · 19 lines
2.25.1 From 662c1b56b66c3d50eb3ee9911bc35b63811ae0af Mon Sep 17 00:00:00 2001 From: Maayan Kashani <[email protected]> Date: Wed, 13 Mar 2024 08:45:19 +0200 Subject: [PATCH 2/4] net/mlx5: set modify header as shared action In current implementation, in non template mode, modify header action is not set as always shared. Align to HWS implementation, setting modify header action as always shared. Optimize mask initialization. Signed-off-by: Maayan Kashani <[email protected]> --- drivers/net/mlx5/mlx5_flow.h | 3 -- drivers/net/mlx5/mlx5_flow_dv.c | 10 ++-- drivers/net/mlx5/mlx5_flow_hw.c | 91 +++++++++++++++++++-------------- 3 files changed, 59 insertions(+), 45 deletions(-)
drivers/net/mlx5/mlx5_flow.h +0 -3
@@ -669,9 +669,6 @@ struct mlx5_flow_dv_modify_hdr_resource {struct mlx5_list_entry entry;void *action;/**< Modify header action object. */ uint32_t idx; -#ifdef HAVE_MLX5_HWS_SUPPORT -void *mh_dr_pattern;/**< Modify header DR pattern(HWS only). */ -#endif uint64_t flags;/**< Flags for RDMA API(HWS only). */ /* Key area for hash list matching: */ uint8_t ft_type;/**< Flow table type, Rx or Tx. */
drivers/net/mlx5/mlx5_flow_dv.c +6 -4
@@ -6219,9 +6219,7 @@ flow_modify_create_cb(void *tool_ctx, void *cb_ctx)uint32_t data_len = ref->actions_num *sizeof (ref->actions[0 ]); uint32_t key_len = sizeof(*ref) - offsetof(typeof(*ref), ft_type);uint32_t idx; -struct mlx5_tbl_multi_pattern_ctx *mpctx; -typeof (mpctx->mh) *mh_dr_pattern = ref->mh_dr_pattern;if (unlikely (!ipool)) { rte_flow_error_set(ctx->error, ENOMEM, RTE_FLOW_ERROR_TYPE_UNSPECIFIED,
@@ -6240,9 +6238,13 @@ flow_modify_create_cb(void *tool_ctx, void *cb_ctx) key_len + data_len);if (sh->config.dv_flow_en ==2 ) {#ifdef HAVE_MLX5_HWS_SUPPORT +struct mlx5dr_action_mh_pattern pattern = { + .sz = data_len, + .data = (__be64 *)ref->actions + }; entry->action =mlx5dr_action_create_modify_header (ctx->data2, - mh_dr_pattern->elements_num, - mh_dr_pattern->pattern,0 , ref->flags); +1 , + &pattern,0 , ref->flags);if (!entry->action) ret =-1 ;#else
drivers/net/mlx5/mlx5_flow_hw.c +53 -38
162 lines not on this page · raw message
Signature · 21 lines
2.25.1 From 3acb029275b5b606834fb07ac1b036e1645a309d Mon Sep 17 00:00:00 2001 From: Maayan Kashani <[email protected]> Date: Wed, 13 Mar 2024 22:59:03 +0200 Subject: [PATCH 3/4] net/mlx5: set encap as shared action In current implementation, in non template mode, encap action is not set as non shared(according to given masks). By masking the relevant fields, encap is now used as shared. decap remained unshared and cannot be shared according to current implementation. Optimize encap action mask initialization and fixed requested number of reformat actions to one. Signed-off-by: Maayan Kashani <[email protected]> --- drivers/net/mlx5/mlx5_flow_dv.c | 2 +- drivers/net/mlx5/mlx5_flow_hw.c | 119 +++++++++++++++++++++++--------- 2 files changed, 86 insertions(+), 35 deletions(-)
drivers/net/mlx5/mlx5_flow_dv.c +1 -1
@@ -4317,7 +4317,7 @@ flow_encap_decap_create_cb(void *tool_ctx, void *cb_ctx) hdr.data = ctx_resource->buf; resource->action =mlx5dr_action_create_reformat (ctx->data2, (enum mlx5dr_action_type )ctx_resource->reformat_type,1 , - &hdr,1 , ctx_resource->flags); + &hdr,0 , ctx_resource->flags);if (!resource->action) ret =-1 ;#else
drivers/net/mlx5/mlx5_flow_hw.c +85 -34
214 lines not on this page · raw message
Signature · 14 lines
2.25.1 From 5c134e8f32d33b2e347b822e7bf7c3e5fee7ec57 Mon Sep 17 00:00:00 2001 From: Maayan Kashani <[email protected]> Date: Thu, 14 Mar 2024 08:51:27 +0200 Subject: [PATCH 4/4] net/mlx5: clean up TODO comments review and cleanup unneeded TODO comments. Signed-off-by: Maayan Kashani <[email protected]> --- drivers/net/mlx5/mlx5_flow_hw.c | 32 +++++++++----------------------- 1 file changed, 9 insertions(+), 23 deletions(-)
drivers/net/mlx5/mlx5_flow_hw.c +9 -23
@@ -12390,7 +12390,6 @@ static int flow_hw_prepare(struct rte_eth_dev *dev,return rte_flow_error_set (error,ENOMEM ,RTE_FLOW_ERROR_TYPE_UNSPECIFIED ,NULL ,"cannot allocate flow aux memory" ); -/*TODO: consider if other allocation is needed for actions translate. */ return 0 ; }
@@ -12633,9 +12632,8 @@ flow_hw_translate_flow_actions(struct rte_eth_dev *dev, table_type =MLX5DR_TABLE_TYPE_NIC_TX ; else table_type =MLX5DR_TABLE_TYPE_NIC_RX ; -/* TODO: consider add flag if using only non template mode to reduce table struct size. */ +/* TODO: consider to reuse the workspace per thread. */ table =mlx5_malloc (MLX5_MEM_ZERO ,sizeof (*table),0 ,SOCKET_ID_ANY ); -/* TODO: consider sending only relevant fields to construct. */ if (!table)return rte_flow_error_set (error,ENOMEM ,RTE_FLOW_ERROR_TYPE_ACTION , actions,"Failed to allocate dummy table" );
@@ -12833,9 +12831,7 @@ flow_hw_allocate_actions(struct rte_eth_dev *dev, NULL, "fail to allocate actions"); } -/* TODO: remove dev if not used */ -static int flow_hw_apply(struct rte_eth_dev *dev __rte_unused, -const struct rte_flow_item items[], +static int flow_hw_apply (const struct rte_flow_item items[],struct mlx5dr_rule_action rule_actions[],struct rte_flow_hw *flow,struct rte_flow_error *error)
@@ -12901,16 +12897,7 @@ flow_hw_create_flow(struct rte_eth_dev *dev, enum mlx5_flow_type type, .group = attr->group, .priority = attr->priority, .rss_level = 0, -/* -* TODO: currently only mlx5_flow_lacp_miss rule is relevant: -* action type=(enum rte_flow_action_type) MLX5_RTE_FLOW_ACTION_TYPE_DEFAULT_MISS. -* I don't want to waist time going over all actions for this corner case. -* Needs to use another preparation code to update this action flags. -* if (action_type == (enum rte_flow_action_type) -* MLX5_RTE_FLOW_ACTION_TYPE_DEFAULT_MISS) -* act_flags |= MLX5_FLOW_ACTION_DEFAULT_MISS; -*/ - .act_flags = 0, /*TODO update*/ + .act_flags = action_flags, .tbl_type = 0, };
@@ -12958,11 +12945,6 @@ flow_hw_create_flow(struct rte_eth_dev *dev, enum mlx5_flow_type type,if (ret) goto error; -/* -* TODO: check regarding release: CT index is not saved per rule, -* the index is in the conf of given action. -*/ -/* * If the flow is external (from application) OR device is started, * OR mreg discover, then apply immediately.
@@ -12970,7 +12952,7 @@ flow_hw_create_flow(struct rte_eth_dev *dev, enum mlx5_flow_type type,if (external || dev->data->dev_started || (attr->group ==MLX5_FLOW_MREG_CP_TABLE_GROUP && attr->priority ==MLX5_FLOW_LOWEST_PRIO_INDICATOR )) { - ret =flow_hw_apply (dev, items, hw_act.rule_acts, *flow, error); + ret =flow_hw_apply (items, hw_act.rule_acts, *flow, error);if (ret) goto error; }
@@ -13012,7 +12994,7 @@ flow_hw_destroy(struct rte_eth_dev *dev, struct rte_flow_hw *flow)DRV_LOG (ERR ,"bwc rule destroy failed" ); } flow->operation_type =MLX5_FLOW_HW_FLOW_OP_TYPE_DESTROY ; -/* TODO: notice this function does not handle shared/static actions. */ +/* Notice this function does not handle shared/static actions. */ hw_cmpl_flow_update_or_destroy (dev, flow,0 ,NULL );/**
@@ -13108,6 +13090,10 @@ static uintptr_t flow_hw_list_create(struct rte_eth_dev *dev,uint64_t item_flags =flow_hw_matching_item_flags_get (items);uint64_t action_flags =flow_hw_action_flags_get (actions, error); +/* +* TODO: add a call to flow_hw_validate function once it exist. +* and update mlx5_flow_hw_drv_ops accordingly. +*/ if (action_flags &MLX5_FLOW_ACTION_RSS ) { const struct rte_flow_action_rss
Signature · 1 line
2.25.1
PATCH v2 22/34 net/mlx5: reorganize main structures
Reorganize rte_flow_hw and rte_flow_nt2hws structures for better performance, and removed packed.
--- drivers/net/mlx5/mlx5_flow.h | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-)
drivers/net/mlx5/mlx5_flow.h +12 -14
@@ -1328,12 +1328,12 @@ struct rte_flow_nt2hws {struct rte_flow_hw_aux *flow_aux;/** Modify header pointer. */ struct mlx5_flow_dv_modify_hdr_resource *modify_hdr; +/** Chain NTA flows. */ +SLIST_ENTRY (rte_flow_hw) next;/** Encap/decap index. */ uint32_t rix_encap_decap;uint8_t chaned_flow; -/** Chain NTA flows. */ -SLIST_ENTRY (rte_flow_hw) next; -} __rte_packed; +};/** HWS flow struct. */ struct rte_flow_hw {
@@ -1345,6 +1345,12 @@ struct rte_flow_hw { };/** Application's private data passed to enqueued flow operation. */ void *user_data; +union { +/** Jump action. */ +struct mlx5_hw_jump_action *jump; +/** TIR action. */ +struct mlx5_hrxq *hrxq; + };/** Flow index from indexed pool. */ uint32_t idx;/** Resource index from indexed pool. */
@@ -1353,20 +1359,12 @@ struct rte_flow_hw {uint32_t rule_idx;/** Which flow fields (inline or in auxiliary struct) are used. */ uint32_t flags; +/** COUNT action index. */ +cnt_id_t cnt_id;/** Ongoing flow operation type. */ uint8_t operation_type;/** Index of pattern template this flow is based on. */ uint8_t mt_idx; - -/** COUNT action index. */ -cnt_id_t cnt_id; -union { -/** Jump action. */ -struct mlx5_hw_jump_action *jump; -/** TIR action. */ -struct mlx5_hrxq *hrxq; - }; -/** Equals true if it is non template rule. */ bool nt_rule;/**
@@ -1377,7 +1375,7 @@ struct rte_flow_hw {uint8_t padding[9 ];/** HWS layer data struct. */ uint8_t rule[]; -} __rte_packed; +};/** Auxiliary data fields that are updatable. */ struct rte_flow_hw_aux_fields {
Signature · 1 line
2.25.1
PATCH v2 23/34 net/mlx5: set modify header as shared action
In current implementation, in non template mode,
modify header action is not set as always shared.
Align to HWS implementation, setting modify header action as always shared. Optimize mask initialization.
--- drivers/net/mlx5/mlx5_flow.h | 3 -- drivers/net/mlx5/mlx5_flow_dv.c | 10 ++-- drivers/net/mlx5/mlx5_flow_hw.c | 91 +++++++++++++++++++-------------- 3 files changed, 59 insertions(+), 45 deletions(-)
drivers/net/mlx5/mlx5_flow.h +0 -3
@@ -669,9 +669,6 @@ struct mlx5_flow_dv_modify_hdr_resource {struct mlx5_list_entry entry;void *action;/**< Modify header action object. */ uint32_t idx; -#ifdef HAVE_MLX5_HWS_SUPPORT -void *mh_dr_pattern;/**< Modify header DR pattern(HWS only). */ -#endif uint64_t flags;/**< Flags for RDMA API(HWS only). */ /* Key area for hash list matching: */ uint8_t ft_type;/**< Flow table type, Rx or Tx. */
drivers/net/mlx5/mlx5_flow_dv.c +6 -4
@@ -6219,9 +6219,7 @@ flow_modify_create_cb(void *tool_ctx, void *cb_ctx)uint32_t data_len = ref->actions_num *sizeof (ref->actions[0 ]); uint32_t key_len = sizeof(*ref) - offsetof(typeof(*ref), ft_type);uint32_t idx; -struct mlx5_tbl_multi_pattern_ctx *mpctx; -typeof (mpctx->mh) *mh_dr_pattern = ref->mh_dr_pattern;if (unlikely (!ipool)) { rte_flow_error_set(ctx->error, ENOMEM, RTE_FLOW_ERROR_TYPE_UNSPECIFIED,
@@ -6240,9 +6238,13 @@ flow_modify_create_cb(void *tool_ctx, void *cb_ctx) key_len + data_len);if (sh->config.dv_flow_en ==2 ) {#ifdef HAVE_MLX5_HWS_SUPPORT +struct mlx5dr_action_mh_pattern pattern = { + .sz = data_len, + .data = (__be64 *)ref->actions + }; entry->action =mlx5dr_action_create_modify_header (ctx->data2, - mh_dr_pattern->elements_num, - mh_dr_pattern->pattern,0 , ref->flags); +1 , + &pattern,0 , ref->flags);if (!entry->action) ret =-1 ;#else
drivers/net/mlx5/mlx5_flow_hw.c +53 -38
162 lines not on this page · raw message
Signature · 1 line
2.25.1
PATCH v2 24/34 net/mlx5: set encap as shared action
In reply to Maayan KashaniIn current implementation, in non template mode,
encap action is not set as non shared(according to given masks). By masking the relevant fields, encap is now used as shared. decap remained unshared and cannot be shared according to current implementation.
Optimize encap action mask initialization and fixed requested number of reformat actions to one.
--- drivers/net/mlx5/mlx5_flow_dv.c | 2 +- drivers/net/mlx5/mlx5_flow_hw.c | 119 +++++++++++++++++++++++--------- 2 files changed, 86 insertions(+), 35 deletions(-)
drivers/net/mlx5/mlx5_flow_dv.c +1 -1
@@ -4317,7 +4317,7 @@ flow_encap_decap_create_cb(void *tool_ctx, void *cb_ctx) hdr.data = ctx_resource->buf; resource->action =mlx5dr_action_create_reformat (ctx->data2, (enum mlx5dr_action_type )ctx_resource->reformat_type,1 , - &hdr,1 , ctx_resource->flags); + &hdr,0 , ctx_resource->flags);if (!resource->action) ret =-1 ;#else
drivers/net/mlx5/mlx5_flow_hw.c +85 -34
214 lines not on this page · raw message
Signature · 1 line
2.25.1
PATCH v2 25/34 net/mlx5: clean up TODO comments
In reply to Maayan Kashanireview and cleanup unneeded TODO comments.
--- drivers/net/mlx5/mlx5_flow_hw.c | 32 +++++++++----------------------- 1 file changed, 9 insertions(+), 23 deletions(-)
drivers/net/mlx5/mlx5_flow_hw.c +9 -23
@@ -12390,7 +12390,6 @@ static int flow_hw_prepare(struct rte_eth_dev *dev,return rte_flow_error_set (error,ENOMEM ,RTE_FLOW_ERROR_TYPE_UNSPECIFIED ,NULL ,"cannot allocate flow aux memory" ); -/*TODO: consider if other allocation is needed for actions translate. */ return 0 ; }
@@ -12633,9 +12632,8 @@ flow_hw_translate_flow_actions(struct rte_eth_dev *dev, table_type =MLX5DR_TABLE_TYPE_NIC_TX ; else table_type =MLX5DR_TABLE_TYPE_NIC_RX ; -/* TODO: consider add flag if using only non template mode to reduce table struct size. */ +/* TODO: consider to reuse the workspace per thread. */ table =mlx5_malloc (MLX5_MEM_ZERO ,sizeof (*table),0 ,SOCKET_ID_ANY ); -/* TODO: consider sending only relevant fields to construct. */ if (!table)return rte_flow_error_set (error,ENOMEM ,RTE_FLOW_ERROR_TYPE_ACTION , actions,"Failed to allocate dummy table" );
@@ -12833,9 +12831,7 @@ flow_hw_allocate_actions(struct rte_eth_dev *dev, NULL, "fail to allocate actions"); } -/* TODO: remove dev if not used */ -static int flow_hw_apply(struct rte_eth_dev *dev __rte_unused, -const struct rte_flow_item items[], +static int flow_hw_apply (const struct rte_flow_item items[],struct mlx5dr_rule_action rule_actions[],struct rte_flow_hw *flow,struct rte_flow_error *error)
@@ -12901,16 +12897,7 @@ flow_hw_create_flow(struct rte_eth_dev *dev, enum mlx5_flow_type type, .group = attr->group, .priority = attr->priority, .rss_level = 0, -/* -* TODO: currently only mlx5_flow_lacp_miss rule is relevant: -* action type=(enum rte_flow_action_type) MLX5_RTE_FLOW_ACTION_TYPE_DEFAULT_MISS. -* I don't want to waist time going over all actions for this corner case. -* Needs to use another preparation code to update this action flags. -* if (action_type == (enum rte_flow_action_type) -* MLX5_RTE_FLOW_ACTION_TYPE_DEFAULT_MISS) -* act_flags |= MLX5_FLOW_ACTION_DEFAULT_MISS; -*/ - .act_flags = 0, /*TODO update*/ + .act_flags = action_flags, .tbl_type = 0, };
@@ -12958,11 +12945,6 @@ flow_hw_create_flow(struct rte_eth_dev *dev, enum mlx5_flow_type type,if (ret) goto error; -/* -* TODO: check regarding release: CT index is not saved per rule, -* the index is in the conf of given action. -*/ -/* * If the flow is external (from application) OR device is started, * OR mreg discover, then apply immediately.
@@ -12970,7 +12952,7 @@ flow_hw_create_flow(struct rte_eth_dev *dev, enum mlx5_flow_type type,if (external || dev->data->dev_started || (attr->group ==MLX5_FLOW_MREG_CP_TABLE_GROUP && attr->priority ==MLX5_FLOW_LOWEST_PRIO_INDICATOR )) { - ret =flow_hw_apply (dev, items, hw_act.rule_acts, *flow, error); + ret =flow_hw_apply (items, hw_act.rule_acts, *flow, error);if (ret) goto error; }
@@ -13012,7 +12994,7 @@ flow_hw_destroy(struct rte_eth_dev *dev, struct rte_flow_hw *flow)DRV_LOG (ERR ,"bwc rule destroy failed" ); } flow->operation_type =MLX5_FLOW_HW_FLOW_OP_TYPE_DESTROY ; -/* TODO: notice this function does not handle shared/static actions. */ +/* Notice this function does not handle shared/static actions. */ hw_cmpl_flow_update_or_destroy (dev, flow,0 ,NULL );/**
@@ -13108,6 +13090,10 @@ static uintptr_t flow_hw_list_create(struct rte_eth_dev *dev,uint64_t item_flags =flow_hw_matching_item_flags_get (items);uint64_t action_flags =flow_hw_action_flags_get (actions, error); +/* +* TODO: add a call to flow_hw_validate function once it exist. +* and update mlx5_flow_hw_drv_ops accordingly. +*/ if (action_flags &MLX5_FLOW_ACTION_RSS ) { const struct rte_flow_action_rss
Signature · 1 line
2.25.1
PATCH v3 1/4 net/mlx5: reorganize main structures
In reply to Maayan KashaniReorganize rte_flow_hw and rte_flow_nt2hws structures for better performance, and removed packed.
--- drivers/net/mlx5/mlx5_flow.h | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-)
drivers/net/mlx5/mlx5_flow.h +12 -14
@@ -1328,12 +1328,12 @@ struct rte_flow_nt2hws {struct rte_flow_hw_aux *flow_aux;/** Modify header pointer. */ struct mlx5_flow_dv_modify_hdr_resource *modify_hdr; +/** Chain NTA flows. */ +SLIST_ENTRY (rte_flow_hw) next;/** Encap/decap index. */ uint32_t rix_encap_decap;uint8_t chaned_flow; -/** Chain NTA flows. */ -SLIST_ENTRY (rte_flow_hw) next; -} __rte_packed; +};/** HWS flow struct. */ struct rte_flow_hw {
@@ -1345,6 +1345,12 @@ struct rte_flow_hw { };/** Application's private data passed to enqueued flow operation. */ void *user_data; +union { +/** Jump action. */ +struct mlx5_hw_jump_action *jump; +/** TIR action. */ +struct mlx5_hrxq *hrxq; + };/** Flow index from indexed pool. */ uint32_t idx;/** Resource index from indexed pool. */
@@ -1353,20 +1359,12 @@ struct rte_flow_hw {uint32_t rule_idx;/** Which flow fields (inline or in auxiliary struct) are used. */ uint32_t flags; +/** COUNT action index. */ +cnt_id_t cnt_id;/** Ongoing flow operation type. */ uint8_t operation_type;/** Index of pattern template this flow is based on. */ uint8_t mt_idx; - -/** COUNT action index. */ -cnt_id_t cnt_id; -union { -/** Jump action. */ -struct mlx5_hw_jump_action *jump; -/** TIR action. */ -struct mlx5_hrxq *hrxq; - }; -/** Equals true if it is non template rule. */ bool nt_rule;/**
@@ -1377,7 +1375,7 @@ struct rte_flow_hw {uint8_t padding[9 ];/** HWS layer data struct. */ uint8_t rule[]; -} __rte_packed; +};/** Auxiliary data fields that are updatable. */ struct rte_flow_hw_aux_fields {
Signature · 1 line
2.25.1
PATCH v3 2/4 net/mlx5: set modify header as shared action
In current implementation, in non template mode,
modify header action is not set as always shared.
Align to HWS implementation, setting modify header action as always shared. Optimize mask initialization.
--- drivers/net/mlx5/mlx5_flow.h | 3 -- drivers/net/mlx5/mlx5_flow_dv.c | 10 ++-- drivers/net/mlx5/mlx5_flow_hw.c | 91 +++++++++++++++++++-------------- 3 files changed, 59 insertions(+), 45 deletions(-)
drivers/net/mlx5/mlx5_flow.h +0 -3
@@ -669,9 +669,6 @@ struct mlx5_flow_dv_modify_hdr_resource {struct mlx5_list_entry entry;void *action;/**< Modify header action object. */ uint32_t idx; -#ifdef HAVE_MLX5_HWS_SUPPORT -void *mh_dr_pattern;/**< Modify header DR pattern(HWS only). */ -#endif uint64_t flags;/**< Flags for RDMA API(HWS only). */ /* Key area for hash list matching: */ uint8_t ft_type;/**< Flow table type, Rx or Tx. */
drivers/net/mlx5/mlx5_flow_dv.c +6 -4
@@ -6219,9 +6219,7 @@ flow_modify_create_cb(void *tool_ctx, void *cb_ctx)uint32_t data_len = ref->actions_num *sizeof (ref->actions[0 ]); uint32_t key_len = sizeof(*ref) - offsetof(typeof(*ref), ft_type);uint32_t idx; -struct mlx5_tbl_multi_pattern_ctx *mpctx; -typeof (mpctx->mh) *mh_dr_pattern = ref->mh_dr_pattern;if (unlikely (!ipool)) { rte_flow_error_set(ctx->error, ENOMEM, RTE_FLOW_ERROR_TYPE_UNSPECIFIED,
@@ -6240,9 +6238,13 @@ flow_modify_create_cb(void *tool_ctx, void *cb_ctx) key_len + data_len);if (sh->config.dv_flow_en ==2 ) {#ifdef HAVE_MLX5_HWS_SUPPORT +struct mlx5dr_action_mh_pattern pattern = { + .sz = data_len, + .data = (__be64 *)ref->actions + }; entry->action =mlx5dr_action_create_modify_header (ctx->data2, - mh_dr_pattern->elements_num, - mh_dr_pattern->pattern,0 , ref->flags); +1 , + &pattern,0 , ref->flags);if (!entry->action) ret =-1 ;#else
drivers/net/mlx5/mlx5_flow_hw.c +53 -38
162 lines not on this page · raw message
Signature · 1 line
2.25.1
PATCH v3 3/4 net/mlx5: set encap as shared action
In reply to Maayan KashaniIn current implementation, in non template mode,
encap action is not set as non shared(according to given masks). By masking the relevant fields, encap is now used as shared. decap remained unshared and cannot be shared according to current implementation.
Optimize encap action mask initialization and fixed requested number of reformat actions to one.
--- drivers/net/mlx5/mlx5_flow_dv.c | 2 +- drivers/net/mlx5/mlx5_flow_hw.c | 119 +++++++++++++++++++++++--------- 2 files changed, 86 insertions(+), 35 deletions(-)
drivers/net/mlx5/mlx5_flow_dv.c +1 -1
@@ -4317,7 +4317,7 @@ flow_encap_decap_create_cb(void *tool_ctx, void *cb_ctx) hdr.data = ctx_resource->buf; resource->action =mlx5dr_action_create_reformat (ctx->data2, (enum mlx5dr_action_type )ctx_resource->reformat_type,1 , - &hdr,1 , ctx_resource->flags); + &hdr,0 , ctx_resource->flags);if (!resource->action) ret =-1 ;#else
drivers/net/mlx5/mlx5_flow_hw.c +85 -34
214 lines not on this page · raw message
Signature · 1 line
2.25.1
PATCH v3 4/4 net/mlx5: clean up TODO comments
In reply to Maayan Kashanireview and cleanup unneeded TODO comments.
--- drivers/net/mlx5/mlx5_flow_hw.c | 32 +++++++++----------------------- 1 file changed, 9 insertions(+), 23 deletions(-)
drivers/net/mlx5/mlx5_flow_hw.c +9 -23
@@ -12390,7 +12390,6 @@ static int flow_hw_prepare(struct rte_eth_dev *dev,return rte_flow_error_set (error,ENOMEM ,RTE_FLOW_ERROR_TYPE_UNSPECIFIED ,NULL ,"cannot allocate flow aux memory" ); -/*TODO: consider if other allocation is needed for actions translate. */ return 0 ; }
@@ -12633,9 +12632,8 @@ flow_hw_translate_flow_actions(struct rte_eth_dev *dev, table_type =MLX5DR_TABLE_TYPE_NIC_TX ; else table_type =MLX5DR_TABLE_TYPE_NIC_RX ; -/* TODO: consider add flag if using only non template mode to reduce table struct size. */ +/* TODO: consider to reuse the workspace per thread. */ table =mlx5_malloc (MLX5_MEM_ZERO ,sizeof (*table),0 ,SOCKET_ID_ANY ); -/* TODO: consider sending only relevant fields to construct. */ if (!table)return rte_flow_error_set (error,ENOMEM ,RTE_FLOW_ERROR_TYPE_ACTION , actions,"Failed to allocate dummy table" );
@@ -12833,9 +12831,7 @@ flow_hw_allocate_actions(struct rte_eth_dev *dev, NULL, "fail to allocate actions"); } -/* TODO: remove dev if not used */ -static int flow_hw_apply(struct rte_eth_dev *dev __rte_unused, -const struct rte_flow_item items[], +static int flow_hw_apply (const struct rte_flow_item items[],struct mlx5dr_rule_action rule_actions[],struct rte_flow_hw *flow,struct rte_flow_error *error)
@@ -12901,16 +12897,7 @@ flow_hw_create_flow(struct rte_eth_dev *dev, enum mlx5_flow_type type, .group = attr->group, .priority = attr->priority, .rss_level = 0, -/* -* TODO: currently only mlx5_flow_lacp_miss rule is relevant: -* action type=(enum rte_flow_action_type) MLX5_RTE_FLOW_ACTION_TYPE_DEFAULT_MISS. -* I don't want to waist time going over all actions for this corner case. -* Needs to use another preparation code to update this action flags. -* if (action_type == (enum rte_flow_action_type) -* MLX5_RTE_FLOW_ACTION_TYPE_DEFAULT_MISS) -* act_flags |= MLX5_FLOW_ACTION_DEFAULT_MISS; -*/ - .act_flags = 0, /*TODO update*/ + .act_flags = action_flags, .tbl_type = 0, };
@@ -12958,11 +12945,6 @@ flow_hw_create_flow(struct rte_eth_dev *dev, enum mlx5_flow_type type,if (ret) goto error; -/* -* TODO: check regarding release: CT index is not saved per rule, -* the index is in the conf of given action. -*/ -/* * If the flow is external (from application) OR device is started, * OR mreg discover, then apply immediately.
@@ -12970,7 +12952,7 @@ flow_hw_create_flow(struct rte_eth_dev *dev, enum mlx5_flow_type type,if (external || dev->data->dev_started || (attr->group ==MLX5_FLOW_MREG_CP_TABLE_GROUP && attr->priority ==MLX5_FLOW_LOWEST_PRIO_INDICATOR )) { - ret =flow_hw_apply (dev, items, hw_act.rule_acts, *flow, error); + ret =flow_hw_apply (items, hw_act.rule_acts, *flow, error);if (ret) goto error; }
@@ -13012,7 +12994,7 @@ flow_hw_destroy(struct rte_eth_dev *dev, struct rte_flow_hw *flow)DRV_LOG (ERR ,"bwc rule destroy failed" ); } flow->operation_type =MLX5_FLOW_HW_FLOW_OP_TYPE_DESTROY ; -/* TODO: notice this function does not handle shared/static actions. */ +/* Notice this function does not handle shared/static actions. */ hw_cmpl_flow_update_or_destroy (dev, flow,0 ,NULL );/**
@@ -13108,6 +13090,10 @@ static uintptr_t flow_hw_list_create(struct rte_eth_dev *dev,uint64_t item_flags =flow_hw_matching_item_flags_get (items);uint64_t action_flags =flow_hw_action_flags_get (actions, error); +/* +* TODO: add a call to flow_hw_validate function once it exist. +* and update mlx5_flow_hw_drv_ops accordingly. +*/ if (action_flags &MLX5_FLOW_ACTION_RSS ) { const struct rte_flow_action_rss
Signature · 1 line
2.25.1
v4 cover non template pmd code changes
In reply to Maayan KashaniCode changes applied after review.
Maayan Kashani (4):
net/mlx5: reorganize main structures
net/mlx5: set modify header as shared action
net/mlx5: set encap as shared action
net/mlx5: clean up TODO comments
drivers/net/mlx5/mlx5_flow.h | 29 ++-- drivers/net/mlx5/mlx5_flow_dv.c | 12 +- drivers/net/mlx5/mlx5_flow_hw.c | 234 +++++++++++++++++++------------- 3 files changed, 162 insertions(+), 113 deletions(-)
Signature · 1 line
2.21.0
PATCH v4 1/4 net/mlx5: reorganize main structures
Reorganize rte_flow_hw and rte_flow_nt2hws structures for better performance, and removed packed.
--- drivers/net/mlx5/mlx5_flow.h | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-)
drivers/net/mlx5/mlx5_flow.h +12 -14
@@ -1328,12 +1328,12 @@ struct rte_flow_nt2hws {struct rte_flow_hw_aux *flow_aux;/** Modify header pointer. */ struct mlx5_flow_dv_modify_hdr_resource *modify_hdr; +/** Chain NTA flows. */ +SLIST_ENTRY (rte_flow_hw) next;/** Encap/decap index. */ uint32_t rix_encap_decap;uint8_t chaned_flow; -/** Chain NTA flows. */ -SLIST_ENTRY (rte_flow_hw) next; -} __rte_packed; +};/** HWS flow struct. */ struct rte_flow_hw {
@@ -1345,6 +1345,12 @@ struct rte_flow_hw { };/** Application's private data passed to enqueued flow operation. */ void *user_data; +union { +/** Jump action. */ +struct mlx5_hw_jump_action *jump; +/** TIR action. */ +struct mlx5_hrxq *hrxq; + };/** Flow index from indexed pool. */ uint32_t idx;/** Resource index from indexed pool. */
@@ -1353,20 +1359,12 @@ struct rte_flow_hw {uint32_t rule_idx;/** Which flow fields (inline or in auxiliary struct) are used. */ uint32_t flags; +/** COUNT action index. */ +cnt_id_t cnt_id;/** Ongoing flow operation type. */ uint8_t operation_type;/** Index of pattern template this flow is based on. */ uint8_t mt_idx; - -/** COUNT action index. */ -cnt_id_t cnt_id; -union { -/** Jump action. */ -struct mlx5_hw_jump_action *jump; -/** TIR action. */ -struct mlx5_hrxq *hrxq; - }; -/** Equals true if it is non template rule. */ bool nt_rule;/**
@@ -1377,7 +1375,7 @@ struct rte_flow_hw {uint8_t padding[9 ];/** HWS layer data struct. */ uint8_t rule[]; -} __rte_packed; +};/** Auxiliary data fields that are updatable. */ struct rte_flow_hw_aux_fields {
Signature · 1 line
2.21.0
PATCH v4 2/4 net/mlx5: set modify header as shared action
In reply to Maayan KashaniIn current implementation, in non template mode,
modify header action is not set as always shared.
Align to HWS implementation, setting modify header action as always shared. Optimize mask initialization.
--- drivers/net/mlx5/mlx5_flow.h | 3 -- drivers/net/mlx5/mlx5_flow_dv.c | 10 ++-- drivers/net/mlx5/mlx5_flow_hw.c | 91 +++++++++++++++++++-------------- 3 files changed, 59 insertions(+), 45 deletions(-)
drivers/net/mlx5/mlx5_flow.h +0 -3
@@ -669,9 +669,6 @@ struct mlx5_flow_dv_modify_hdr_resource {struct mlx5_list_entry entry;void *action;/**< Modify header action object. */ uint32_t idx; -#ifdef HAVE_MLX5_HWS_SUPPORT -void *mh_dr_pattern;/**< Modify header DR pattern(HWS only). */ -#endif uint64_t flags;/**< Flags for RDMA API(HWS only). */ /* Key area for hash list matching: */ uint8_t ft_type;/**< Flow table type, Rx or Tx. */
drivers/net/mlx5/mlx5_flow_dv.c +6 -4
@@ -6219,9 +6219,7 @@ flow_modify_create_cb(void *tool_ctx, void *cb_ctx)uint32_t data_len = ref->actions_num *sizeof (ref->actions[0 ]); uint32_t key_len = sizeof(*ref) - offsetof(typeof(*ref), ft_type);uint32_t idx; -struct mlx5_tbl_multi_pattern_ctx *mpctx; -typeof (mpctx->mh) *mh_dr_pattern = ref->mh_dr_pattern;if (unlikely (!ipool)) { rte_flow_error_set(ctx->error, ENOMEM, RTE_FLOW_ERROR_TYPE_UNSPECIFIED,
@@ -6240,9 +6238,13 @@ flow_modify_create_cb(void *tool_ctx, void *cb_ctx) key_len + data_len);if (sh->config.dv_flow_en ==2 ) {#ifdef HAVE_MLX5_HWS_SUPPORT +struct mlx5dr_action_mh_pattern pattern = { + .sz = data_len, + .data = (__be64 *)ref->actions + }; entry->action =mlx5dr_action_create_modify_header (ctx->data2, - mh_dr_pattern->elements_num, - mh_dr_pattern->pattern,0 , ref->flags); +1 , + &pattern,0 , ref->flags);if (!entry->action) ret =-1 ;#else
drivers/net/mlx5/mlx5_flow_hw.c +53 -38
162 lines not on this page · raw message
Signature · 1 line
2.21.0
PATCH v4 3/4 net/mlx5: set encap as shared action
In reply to Maayan KashaniIn current implementation, in non template mode,
encap action is not set as non shared(according to given masks). By masking the relevant fields, encap is now used as shared. decap remained unshared and cannot be shared according to current implementation.
Optimize encap action mask initialization and fixed requested number of reformat actions to one.
--- drivers/net/mlx5/mlx5_flow_dv.c | 2 +- drivers/net/mlx5/mlx5_flow_hw.c | 119 +++++++++++++++++++++++--------- 2 files changed, 86 insertions(+), 35 deletions(-)
drivers/net/mlx5/mlx5_flow_dv.c +1 -1
@@ -4317,7 +4317,7 @@ flow_encap_decap_create_cb(void *tool_ctx, void *cb_ctx) hdr.data = ctx_resource->buf; resource->action =mlx5dr_action_create_reformat (ctx->data2, (enum mlx5dr_action_type )ctx_resource->reformat_type,1 , - &hdr,1 , ctx_resource->flags); + &hdr,0 , ctx_resource->flags);if (!resource->action) ret =-1 ;#else
drivers/net/mlx5/mlx5_flow_hw.c +85 -34
214 lines not on this page · raw message
Signature · 1 line
2.21.0
PATCH v4 4/4 net/mlx5: clean up TODO comments
In reply to Maayan Kashanireview and cleanup unneeded TODO comments.
--- drivers/net/mlx5/mlx5_flow_hw.c | 32 +++++++++----------------------- 1 file changed, 9 insertions(+), 23 deletions(-)
drivers/net/mlx5/mlx5_flow_hw.c +9 -23
@@ -12390,7 +12390,6 @@ static int flow_hw_prepare(struct rte_eth_dev *dev,return rte_flow_error_set (error,ENOMEM ,RTE_FLOW_ERROR_TYPE_UNSPECIFIED ,NULL ,"cannot allocate flow aux memory" ); -/*TODO: consider if other allocation is needed for actions translate. */ return 0 ; }
@@ -12633,9 +12632,8 @@ flow_hw_translate_flow_actions(struct rte_eth_dev *dev, table_type =MLX5DR_TABLE_TYPE_NIC_TX ; else table_type =MLX5DR_TABLE_TYPE_NIC_RX ; -/* TODO: consider add flag if using only non template mode to reduce table struct size. */ +/* TODO: consider to reuse the workspace per thread. */ table =mlx5_malloc (MLX5_MEM_ZERO ,sizeof (*table),0 ,SOCKET_ID_ANY ); -/* TODO: consider sending only relevant fields to construct. */ if (!table)return rte_flow_error_set (error,ENOMEM ,RTE_FLOW_ERROR_TYPE_ACTION , actions,"Failed to allocate dummy table" );
@@ -12833,9 +12831,7 @@ flow_hw_allocate_actions(struct rte_eth_dev *dev, NULL, "fail to allocate actions"); } -/* TODO: remove dev if not used */ -static int flow_hw_apply(struct rte_eth_dev *dev __rte_unused, -const struct rte_flow_item items[], +static int flow_hw_apply (const struct rte_flow_item items[],struct mlx5dr_rule_action rule_actions[],struct rte_flow_hw *flow,struct rte_flow_error *error)
@@ -12901,16 +12897,7 @@ flow_hw_create_flow(struct rte_eth_dev *dev, enum mlx5_flow_type type, .group = attr->group, .priority = attr->priority, .rss_level = 0, -/* -* TODO: currently only mlx5_flow_lacp_miss rule is relevant: -* action type=(enum rte_flow_action_type) MLX5_RTE_FLOW_ACTION_TYPE_DEFAULT_MISS. -* I don't want to waist time going over all actions for this corner case. -* Needs to use another preparation code to update this action flags. -* if (action_type == (enum rte_flow_action_type) -* MLX5_RTE_FLOW_ACTION_TYPE_DEFAULT_MISS) -* act_flags |= MLX5_FLOW_ACTION_DEFAULT_MISS; -*/ - .act_flags = 0, /*TODO update*/ + .act_flags = action_flags, .tbl_type = 0, };
@@ -12958,11 +12945,6 @@ flow_hw_create_flow(struct rte_eth_dev *dev, enum mlx5_flow_type type,if (ret) goto error; -/* -* TODO: check regarding release: CT index is not saved per rule, -* the index is in the conf of given action. -*/ -/* * If the flow is external (from application) OR device is started, * OR mreg discover, then apply immediately.
@@ -12970,7 +12952,7 @@ flow_hw_create_flow(struct rte_eth_dev *dev, enum mlx5_flow_type type,if (external || dev->data->dev_started || (attr->group ==MLX5_FLOW_MREG_CP_TABLE_GROUP && attr->priority ==MLX5_FLOW_LOWEST_PRIO_INDICATOR )) { - ret =flow_hw_apply (dev, items, hw_act.rule_acts, *flow, error); + ret =flow_hw_apply (items, hw_act.rule_acts, *flow, error);if (ret) goto error; }
@@ -13012,7 +12994,7 @@ flow_hw_destroy(struct rte_eth_dev *dev, struct rte_flow_hw *flow)DRV_LOG (ERR ,"bwc rule destroy failed" ); } flow->operation_type =MLX5_FLOW_HW_FLOW_OP_TYPE_DESTROY ; -/* TODO: notice this function does not handle shared/static actions. */ +/* Notice this function does not handle shared/static actions. */ hw_cmpl_flow_update_or_destroy (dev, flow,0 ,NULL );/**
@@ -13108,6 +13090,10 @@ static uintptr_t flow_hw_list_create(struct rte_eth_dev *dev,uint64_t item_flags =flow_hw_matching_item_flags_get (items);uint64_t action_flags =flow_hw_action_flags_get (actions, error); +/* +* TODO: add a call to flow_hw_validate function once it exist. +* and update mlx5_flow_hw_drv_ops accordingly. +*/ if (action_flags &MLX5_FLOW_ACTION_RSS ) { const struct rte_flow_action_rss
Signature · 1 line
2.21.0
Re: [PATCH v4 0/4] non template pmd code changes
In reply to Maayan KashaniHi,
From: Maayan Kashani <[email protected]>
Sent: Thursday, June 6, 2024 1:06 PM
To: [email protected]
Cc: Maayan Kashani; Dariusz Sosnowski; Raslan Darawsheh
Subject: [PATCH v4 0/4] non template pmd code changes
Code changes applied after review.
Maayan Kashani (4):
net/mlx5: reorganize main structures
net/mlx5: set modify header as shared action
net/mlx5: set encap as shared action
net/mlx5: clean up TODO comments
drivers/net/mlx5/mlx5_flow.h | 29 ++-- drivers/net/mlx5/mlx5_flow_dv.c | 12 +- drivers/net/mlx5/mlx5_flow_hw.c | 234 +++++++++++++++++++------------- 3 files changed, 162 insertions(+), 113 deletions(-)
Series applied to next-net-mlx,
Kindest regards,
Raslan Darawsheh