net/mlx5: implement Flow update API
cover net/mlx5: implement Flow update API
Add the implementation for the rte_flow_async_actions_update() API. Construct the new actions and replace them for the Flow handle. Old resources are freed during the rte_flow_pull() invocation.
Alexander Kozyrev (1):
net/mlx5: implement Flow update API
Erez Shitrit (3):
net/mlx5/hws: use the same function to check rule net/mlx5/hws: use union in the wqe-data struct net/mlx5/hws: support rule update after its creation
drivers/net/mlx5/hws/mlx5dr.h | 17 +++ drivers/net/mlx5/hws/mlx5dr_rule.c | 123 +++++++++++++----- drivers/net/mlx5/hws/mlx5dr_send.c | 2 +- drivers/net/mlx5/mlx5.h | 1 + drivers/net/mlx5/mlx5_flow.c | 56 +++++++++ drivers/net/mlx5/mlx5_flow.h | 13 ++ drivers/net/mlx5/mlx5_flow_hw.c | 194 ++++++++++++++++++++++++++--- 7 files changed, 362 insertions(+), 44 deletions(-)
Signature · 1 line
2.18.2
PATCH 1/4 net/mlx5/hws: use the same function to check rule
From: Erez Shitrit <[email protected]>
Before handling it for insert/delete
--- drivers/net/mlx5/hws/mlx5dr_rule.c | 38 +++++++++++++++--------------- 1 file changed, 19 insertions(+), 19 deletions(-)
drivers/net/mlx5/hws/mlx5dr_rule.c +19 -19
@@ -630,6 +630,23 @@ static int mlx5dr_rule_destroy_root(struct mlx5dr_rule *rule,return 0 ; } +static int mlx5dr_rule_enqueue_precheck (struct mlx5dr_context *ctx, +struct mlx5dr_rule_attr *attr) +{ +if (unlikely (!attr->user_data)) { + rte_errno =EINVAL ; +return rte_errno; + } + +/* Check if there is room in queue */ +if (unlikely (mlx5dr_send_engine_full (&ctx->send_queue[attr->queue_id]))) { + rte_errno =EBUSY ; +return rte_errno; + } + +return 0 ; +} + int mlx5dr_rule_create(struct mlx5dr_matcher *matcher, uint8_t mt_idx, const struct rte_flow_item items[],
@@ -644,16 +661,8 @@ int mlx5dr_rule_create(struct mlx5dr_matcher *matcher, rule_handle->matcher = matcher; ctx = matcher->tbl->ctx; -if (unlikely (!attr->user_data)) { - rte_errno =EINVAL ; +if (mlx5dr_rule_enqueue_precheck (ctx, attr))return -rte_errno; - } - -/* Check if there is room in queue */ -if (unlikely (mlx5dr_send_engine_full (&ctx->send_queue[attr->queue_id]))) { - rte_errno =EBUSY ; -return -rte_errno; - }assert (matcher->num_of_mt >= mt_idx);assert (matcher->num_of_at >= at_idx);
@@ -677,19 +686,10 @@ int mlx5dr_rule_create(struct mlx5dr_matcher *matcher,int mlx5dr_rule_destroy (struct mlx5dr_rule *rule,struct mlx5dr_rule_attr *attr) { -struct mlx5dr_context *ctx = rule->matcher->tbl->ctx;int ret; -if (unlikely (!attr->user_data)) { - rte_errno =EINVAL ; -return -rte_errno; - } - -/* Check if there is room in queue */ -if (unlikely (mlx5dr_send_engine_full (&ctx->send_queue[attr->queue_id]))) { - rte_errno =EBUSY ; +if (mlx5dr_rule_enqueue_precheck (rule->matcher->tbl->ctx, attr))return -rte_errno; - }if (unlikely (mlx5dr_table_is_root (rule->matcher->tbl))) ret =mlx5dr_rule_destroy_root (rule, attr);
Signature · 1 line
2.18.2
RE: [PATCH 1/4] net/mlx5/hws: use the same function to check rule
Quoted 11 lines
-----Original Message-----
From: Alexander Kozyrev <[email protected]>
Sent: Monday, June 12, 2023 11:06 PM
To: [email protected]
Cc: Raslan Darawsheh <[email protected]>; Matan Azrad <[email protected]>; Slava Ovsiienko <[email protected]>; Ori Kam <[email protected]>; Erez Shitrit <[email protected]>
Subject: [PATCH 1/4]net/mlx5/hws: use the same function to check rule
Quoted 7 lines
From: Erez Shitrit <[email protected]>
Before handling it for insert/delete
Signed-off-by Erez Shitrit <[email protected]>Reviewed-by Alex Vesker <[email protected]>---
Best,
Ori
PATCH 2/4 net/mlx5/hws: use union in the wqe-data struct
In reply to Alexander KozyrevFrom: Erez Shitrit <[email protected]>
To be clear about which field we are going to set.
--- drivers/net/mlx5/hws/mlx5dr_send.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/mlx5/hws/mlx5dr_send.c +1 -1
@@ -110,7 +110,7 @@ mlx5dr_send_wqe_set_tag(struct mlx5dr_wqe_gta_data_seg_ste *wqe_data,if (is_jumbo) {/* Clear previous possibly dirty control */ memset (wqe_data,0 ,MLX5DR_STE_CTRL_SZ ); -memcpy (wqe_data->action, tag->jumbo,MLX5DR_JUMBO_TAG_SZ ); +memcpy (wqe_data->jumbo, tag->jumbo,MLX5DR_JUMBO_TAG_SZ ); }else {/* Clear previous possibly dirty control and actions */ memset (wqe_data,0 ,MLX5DR_STE_CTRL_SZ +MLX5DR_ACTIONS_SZ );
Signature · 1 line
2.18.2
RE: [PATCH 2/4] net/mlx5/hws: use union in the wqe-data struct
Quoted 33 lines
-----Original Message-----
From: Alexander Kozyrev <[email protected]>
Sent: Monday, June 12, 2023 11:06 PMFrom: Erez Shitrit <[email protected]>
To be clear about which field we are going to set.
Signed-off-by Erez Shitrit <[email protected]>Reviewed-by Alex Vesker <[email protected]>--- drivers/net/mlx5/hws/mlx5dr_send.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/net/mlx5/hws/mlx5dr_send.c +1
-1@@ -110,7 +110,7 @@ mlx5dr_send_wqe_set_tag(structmlx5dr_wqe_gta_data_seg_ste *wqe_data, if (is_jumbo) {/* Clear previous possibly dirty control */ memset(wqe_data, 0, MLX5DR_STE_CTRL_SZ); -memcpy (wqe_data->action, tag->jumbo, MLX5DR_JUMBO_TAG_SZ); +memcpy (wqe_data->jumbo, tag->jumbo,MLX5DR_JUMBO_TAG_SZ );drivers/net/mlx5/hws/mlx5dr_send.c +0
-0}else {/* Clear previous possibly dirty control and actions */ memset(wqe_data, 0, MLX5DR_STE_CTRL_SZ +
Quoted 3 lines
MLX5DR_ACTIONS_SZ);
--
2.18.2
Best,
Ori
PATCH 3/4 net/mlx5/hws: support rule update after its creation
In reply to Alexander KozyrevFrom: Erez Shitrit <[email protected]>
Add the ability to change rule's actions after the rule already created. The new actions should be one of the action template list. That support is only for matcher that uses the optimization of using rule insertion by index (optimize_using_rule_idx)
--- drivers/net/mlx5/hws/mlx5dr.h | 17 ++++++ drivers/net/mlx5/hws/mlx5dr_rule.c | 85 ++++++++++++++++++++++++++---- 2 files changed, 93 insertions(+), 9 deletions(-)
drivers/net/mlx5/hws/mlx5dr.h +17 -0
@@ -365,6 +365,23 @@ int mlx5dr_rule_create(struct mlx5dr_matcher *matcher,int mlx5dr_rule_destroy (struct mlx5dr_rule *rule,struct mlx5dr_rule_attr *attr); +/* Enqueue update actions on an existing rule. +* +* @param[in, out] rule_handle +* A valid rule handle to update. +* @param[in] at_idx +* Action template index to update the actions with. +* @param[in] rule_actions +* Rule action to be executed on match. +* @param[in] attr +* Rule update attributes. +* @return zero on successful enqueue non zero otherwise. +*/ +int mlx5dr_rule_action_update (struct mlx5dr_rule *rule_handle, +uint8_t at_idx, +struct mlx5dr_rule_action rule_actions[], +struct mlx5dr_rule_attr *attr); +/* Create direct rule drop action. * * @param[in] ctx
drivers/net/mlx5/hws/mlx5dr_rule.c +76 -9
156 lines not on this page · raw message
Signature · 1 line
2.18.2
RE: [PATCH 3/4] net/mlx5/hws: support rule update after its creation
Quoted 8 lines
-----Original Message-----
From: Alexander Kozyrev <[email protected]>
Sent: Monday, June 12, 2023 11:06 PMFrom: Erez Shitrit <[email protected]>
Quoted 8 lines
Add the ability to change rule's actions after the rule already created. The new actions should be one of the action template list. That support is only for matcher that uses the optimization of using rule insertion by index (
optimize_using_rule_idx)Signed-off-by Erez Shitrit <[email protected]>Reviewed-by Alex Vesker <[email protected]>---
Best,
Ori
PATCH 4/4 net/mlx5: implement Flow update API
In reply to Alexander KozyrevAdd the implementation for the rte_flow_async_actions_update() API. Construct the new actions and replace them for the Flow handle. Old resources are freed during the rte_flow_pull() invocation.
--- drivers/net/mlx5/mlx5.h | 1 + drivers/net/mlx5/mlx5_flow.c | 56 +++++++++ drivers/net/mlx5/mlx5_flow.h | 13 +++ drivers/net/mlx5/mlx5_flow_hw.c | 194 +++++++++++++++++++++++++++++--- 4 files changed, 249 insertions(+), 15 deletions(-)
drivers/net/mlx5/mlx5.h +1 -0
@@ -385,6 +385,7 @@ struct mlx5_hw_q_job {struct rte_flow_item_ethdev port_spec;struct rte_flow_item_tag tag_spec; } __rte_packed; +struct rte_flow_hw *upd_flow;/* Flow with updated values. */ };/* HW steering job descriptor LIFO pool. */
drivers/net/mlx5/mlx5_flow.c +56 -0
74 lines not on this page · raw message
drivers/net/mlx5/mlx5_flow.h +13 -0
@@ -1173,6 +1173,7 @@ typedef uint32_t cnt_id_t;/* HWS flow struct. */ struct rte_flow_hw {uint32_t idx;/* Flow index from indexed pool. */ +uint32_t res_idx;/* Resource index from indexed pool. */ uint32_t fate_type;/* Fate action type. */ union {/* Jump action. */
@@ -1180,6 +1181,7 @@ struct rte_flow_hw {struct mlx5_hrxq *hrxq;/* TIR action. */ };struct rte_flow_template_table *table;/* The table flow allcated from. */ +uint8_t mt_idx;uint32_t age_idx;cnt_id_t cnt_id;uint32_t mtr_id;
@@ -1371,6 +1373,7 @@ struct rte_flow_template_table {/* Action templates bind to the table. */ struct mlx5_hw_action_template ats[MLX5_HW_TBL_MAX_ACTION_TEMPLATE ];struct mlx5_indexed_pool *flow;/* The table's flow ipool. */ +struct mlx5_indexed_pool *resource;/* The table's resource ipool. */ struct mlx5_flow_template_table_cfg cfg;uint32_t type;/* Flow table type RX/TX/FDB. */ uint8_t nb_item_templates;/* Item template number. */
@@ -1865,6 +1868,15 @@ typedef struct rte_flow *(*mlx5_flow_async_flow_create_by_index_t)uint8_t action_template_index, void *user_data, struct rte_flow_error *error); +typedef int (*mlx5_flow_async_flow_update_t ) + (struct rte_eth_dev *dev, +uint32_t queue, +const struct rte_flow_op_attr *attr, +struct rte_flow *flow, +const struct rte_flow_action actions[], +uint8_t action_template_index, +void *user_data, +struct rte_flow_error *error);typedef int (*mlx5_flow_async_flow_destroy_t ) (struct rte_eth_dev *dev, uint32_t queue,
@@ -1975,6 +1987,7 @@ struct mlx5_flow_driver_ops {mlx5_flow_table_destroy_t template_table_destroy;mlx5_flow_async_flow_create_t async_flow_create;mlx5_flow_async_flow_create_by_index_t async_flow_create_by_index; +mlx5_flow_async_flow_update_t async_flow_update;mlx5_flow_async_flow_destroy_t async_flow_destroy;mlx5_flow_pull_t pull;mlx5_flow_push_t push;
drivers/net/mlx5/mlx5_flow_hw.c +179 -15
360 lines not on this page · raw message
Signature · 1 line
2.18.2
Hi,
Quoted 31 lines
-----Original Message-----
From: Alexander Kozyrev <[email protected]>
Sent: Monday, June 12, 2023 11:06 PM
To: [email protected]
Cc: Raslan Darawsheh <[email protected]>; Matan Azrad <[email protected]>; Slava Ovsiienko <[email protected]>; Ori Kam <[email protected]>; Erez Shitrit <[email protected]>
Subject: [PATCH 0/4] net/mlx5: implement Flow update APIAdd the implementation for the
rte_flow_async_actions_update()API. Construct the new actions and replace them for the Flow handle. Old resources are freed during therte_flow_pull()invocation.Alexander Kozyrev (1):
net/mlx5: implement Flow update APIErez Shitrit (3):
net/mlx5/hws: use the same function to check rulenet/mlx5/hws: use union in the wqe-data structnet/mlx5/hws: support rule update after its creationdrivers/net/mlx5/hws/mlx5dr.h | 17 +++ drivers/net/mlx5/hws/mlx5dr_rule.c | 123 +++++++++++++----- drivers/net/mlx5/hws/mlx5dr_send.c | 2 +- drivers/net/mlx5/mlx5.h | 1 + drivers/net/mlx5/mlx5_flow.c | 56 +++++++++ drivers/net/mlx5/mlx5_flow.h | 13 ++ drivers/net/mlx5/mlx5_flow_hw.c | 194 ++++++++++++++++++++++++++- -- 7 files changed, 362 insertions(+), 44 deletions(-)
Quoted 2 lines
--
2.18.2
Series applied to next-net-mlx,
Kindest regards,
Raslan Darawsheh