net/mlx5: fix validation for conntrack indirect action
PATCH 1/3 net/mlx5: fix validation for conntrack indirect action
From: Bing Zhao <[email protected]>
After rte_flow_shared_action_* API was replaced with rte_flow_action_handle_* API, one input parameter of the update interface was also changed. A generic pointer was used instead of the "const struct rte_flow_action *" pointer.
In the entrance of mlx5 PMD callback for update, the validation is called for all indirect actions. But for conntrack type, the pointer is no longer with rte_flow_action pointer type and it will cause an incorrect casting and error.
The content for updating should only be validated when needed. It should skip the validation in the entrance. Right now, the content was already added before updating the hardware by WQE. So the type of the indirect action should be checked before calling the action validate function.
When creating a new conntrack object, the validation is still needed since all the content will be used to update the hardware context.
--- drivers/net/mlx5/mlx5_flow.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-)
drivers/net/mlx5/mlx5_flow.c +11 -2
@@ -10753,9 +10753,18 @@ mlx5_action_handle_update(struct rte_eth_dev *dev,const struct mlx5_flow_driver_ops *fops =flow_get_drv_ops (flow_get_drv_type (dev, &attr));int ret; +uint32_t act_idx = (uint32_t )(uintptr_t )handle; +uint32_t type = act_idx >>MLX5_INDIRECT_ACTION_TYPE_OFFSET ; - ret =flow_drv_action_validate (dev,NULL , - (const struct rte_flow_action *)update, fops, error); +switch (type) { +case MLX5_INDIRECT_ACTION_TYPE_CT : + ret =0 ; +break ; +default : + ret =flow_drv_action_validate (dev,NULL , + (const struct rte_flow_action *)update, + fops, error); + }if (ret)return ret; return flow_drv_action_update(dev, handle, update, fops,
Signature · 1 line
2.18.2
PATCH 2/3 net/mlx5: fix handle validation for meter mark
Skip the METER_MARK validation for the indirect action update. The old synchronous indirect action update was left out during the METER_MARK implementation in favor of the async way. Allow the sync method of doing this with relaxed validation.
--- drivers/net/mlx5/mlx5_flow.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/mlx5/mlx5_flow.c +1 -0
@@ -10758,6 +10758,7 @@ mlx5_action_handle_update(struct rte_eth_dev *dev,switch (type) {case MLX5_INDIRECT_ACTION_TYPE_CT : +case MLX5_INDIRECT_ACTION_TYPE_METER_MARK : ret =0 ;break ;default :
Signature · 1 line
2.18.2
RE: [PATCH 2/3] net/mlx5: fix handle validation for meter mark
Hi,
Quoted 13 lines
-----Original Message-----
From: Alexander Kozyrev <[email protected]>
Sent: Tuesday, July 11, 2023 11:21 PM
To: [email protected]
Cc: [email protected]; Raslan Darawsheh <[email protected]>; Slava Ovsiienko <[email protected]>; Matan Azrad <[email protected]>
Subject: [PATCH 2/3] net/mlx5: fix handle validation for meter markSkip the
METER_MARKvalidation for the indirect action update. The old synchronous indirect action update was left out during theMETER_MARKimplementation in favor of the async way.
Allow the sync method of doing this with relaxed validation.
Quoted 4 lines
Fixes 48fbb0e93d06 ("net/mlx5: support flow meter mark indirect action withHWS")
Signed-off-by Alexander Kozyrev <[email protected]>
Thanks.
PATCH 3/3 app/testpmd: fix meter mark handle update
In reply to Alexander KozyrevThe indirect action handle update for the METER_MERK action was implemented only for the async RTE Flow API.
Allow updating the METER_MARK parameters via the old sync method.
--- app/test-pmd/config.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-)
app/test-pmd/config.c +16 -2
@@ -1943,6 +1943,7 @@ port_action_handle_update(portid_t port_id, uint32_t id,struct rte_flow_error error;struct rte_flow_action_handle *action_handle;struct port_indirect_action *pia; +struct rte_flow_update_meter_mark mtr_update;const void *update; action_handle =port_action_handle_get_by_id (port_id, id);
@@ -1956,6 +1957,17 @@ port_action_handle_update(portid_t port_id, uint32_t id,case RTE_FLOW_ACTION_TYPE_CONNTRACK : update = action->conf;break ; +case RTE_FLOW_ACTION_TYPE_METER_MARK : +rte_memcpy (&mtr_update.meter_mark, action->conf, +sizeof (struct rte_flow_action_meter_mark )); +if (mtr_update.meter_mark.profile) + mtr_update.profile_valid =1 ; +if (mtr_update.meter_mark.policy) + mtr_update.policy_valid =1 ; + mtr_update.color_mode_valid =1 ; + mtr_update.state_valid =1 ; + update = &mtr_update; +break ;default : update = action;break ;
@@ -3162,8 +3174,10 @@ port_queue_action_handle_update(portid_t port_id,case RTE_FLOW_ACTION_TYPE_METER_MARK :rte_memcpy (&mtr_update.meter_mark, action->conf,sizeof (struct rte_flow_action_meter_mark )); - mtr_update.profile_valid =1 ; - mtr_update.policy_valid =1 ; +if (mtr_update.meter_mark.profile) + mtr_update.profile_valid =1 ; +if (mtr_update.meter_mark.policy) + mtr_update.policy_valid =1 ; mtr_update.color_mode_valid =1 ; mtr_update.init_color_valid =1 ; mtr_update.state_valid =1 ;
Signature · 1 line
2.18.2
Re: [PATCH 3/3] app/testpmd: fix meter mark handle update
app/test-pmd/config.c port_action_handle_update(portid_t port_id, uint32_t id, · line 1962
Quoted 3 lines · On Tue, 11 Jul 2023 18:20:44 +0300 Alexander Kozyrev <[email protected]>…
app/test-pmd/config.c +3
-0+case RTE_FLOW_ACTION_TYPE_METER_MARK : +rte_memcpy (&mtr_update.meter_mark, action->conf, +sizeof (struct rte_flow_action_meter_mark ));
Why use rte_memcpy? memcpy of fixed size is faster. Also, more static checkers know what memcpy is.
RE: [PATCH 3/3] app/testpmd: fix meter mark handle update
Quoted 11 lines
On Tuesday, July 11, 2023 12:15 PM
Stephen Hemminger <[email protected]> wrote:app/test-pmd/config.c port_action_handle_update(portid_t port_id, uint32_t id, · line 1962
Quoted 3 lines · On Tue, 11 Jul 2023 18:20:44 +0300 Alexander Kozyrev <[email protected]>…
app/test-pmd/config.c +3
-0+case RTE_FLOW_ACTION_TYPE_METER_MARK : +rte_memcpy (&mtr_update.meter_mark, action->conf, +sizeof (struct rte_flow_action_meter_mark ));Why use
rte_memcpy? memcpy of fixed size is faster. Also, more static checkers know what memcpy is.
Ok, not a problem, switching to memcpy.
Hi,
Quoted 25 lines
-----Original Message-----
From: Alexander Kozyrev <[email protected]>
Sent: Tuesday, July 11, 2023 11:21 PM
To: [email protected]
Cc: [email protected]; Raslan Darawsheh <[email protected]>; Slava Ovsiienko <[email protected]>; Matan Azrad <[email protected]>; Bing Zhao <[email protected]>
Subject: [PATCH 1/3] net/mlx5: fix validation for conntrack indirect actionFrom: Bing Zhao <[email protected]>
After rte_flow_shared_action_* API was replaced with rte_flow_action_handle_* API, one input parameter of the update interface was also changed. A generic pointer was used instead of the "const struct
rte_flow_action*" pointer.In the entrance of mlx5 PMD callback for update, the validation is called for all indirect actions. But for conntrack type, the pointer is no longer with
rte_flow_actionpointer type and it will cause an incorrect casting and error.The content for updating should only be validated when needed. It should skip the validation in the entrance. Right now, the content was already added before updating the hardware by WQE. So the type of the indirect action should be checked before calling the action validate function.
Quoted 6 lines
When creating a new conntrack object, the validation is still needed since all the content will be used to update the hardware context.
Fixes 40327aab1491 ("ethdev: introduce indirect flow action")Signed-off-by Bing Zhao <[email protected]>
PATCH v2 1/3 net/mlx5: fix validation for conntrack indirect action
In reply to Alexander KozyrevFrom: Bing Zhao <[email protected]>
After rte_flow_shared_action_* API was replaced with rte_flow_action_handle_* API, one input parameter of the update interface was also changed. A generic pointer was used instead of the "const struct rte_flow_action *" pointer.
In the entrance of mlx5 PMD callback for update, the validation is called for all indirect actions. But for conntrack type, the pointer is no longer with rte_flow_action pointer type and it will cause an incorrect casting and error.
The content for updating should only be validated when needed. It should skip the validation in the entrance. Right now, the content was already added before updating the hardware by WQE. So the type of the indirect action should be checked before calling the action validate function.
When creating a new conntrack object, the validation is still needed since all the content will be used to update the hardware context.
--- drivers/net/mlx5/mlx5_flow.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-)
drivers/net/mlx5/mlx5_flow.c +11 -2
@@ -10753,9 +10753,18 @@ mlx5_action_handle_update(struct rte_eth_dev *dev,const struct mlx5_flow_driver_ops *fops =flow_get_drv_ops (flow_get_drv_type (dev, &attr));int ret; +uint32_t act_idx = (uint32_t )(uintptr_t )handle; +uint32_t type = act_idx >>MLX5_INDIRECT_ACTION_TYPE_OFFSET ; - ret =flow_drv_action_validate (dev,NULL , - (const struct rte_flow_action *)update, fops, error); +switch (type) { +case MLX5_INDIRECT_ACTION_TYPE_CT : + ret =0 ; +break ; +default : + ret =flow_drv_action_validate (dev,NULL , + (const struct rte_flow_action *)update, + fops, error); + }if (ret)return ret; return flow_drv_action_update(dev, handle, update, fops,
Signature · 1 line
2.18.2
PATCH v2 2/3 net/mlx5: fix handle validation for meter mark
Skip the METER_MARK validation for the indirect action update. The old synchronous indirect action update was left out during the METER_MARK implementation in favor of the async way. Allow the sync method of doing this with relaxed validation.
--- drivers/net/mlx5/mlx5_flow.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/mlx5/mlx5_flow.c +1 -0
@@ -10758,6 +10758,7 @@ mlx5_action_handle_update(struct rte_eth_dev *dev,switch (type) {case MLX5_INDIRECT_ACTION_TYPE_CT : +case MLX5_INDIRECT_ACTION_TYPE_METER_MARK : ret =0 ;break ;default :
Signature · 1 line
2.18.2
RE: [PATCH v2 2/3] net/mlx5: fix handle validation for meter mark
Quoted 31 lines
-----Original Message-----
From: Alexander Kozyrev <[email protected]>
Sent: Tuesday, July 18, 2023 4:32 PMSkip the
METER_MARKvalidation for the indirect action update. The old synchronous indirect action update was left out during theMETER_MARKimplementation in favor of the async way. Allow the sync method of doing this with relaxed validation.Fixes 48fbb0e93d06 ("net/mlx5: support flow meter mark indirect action withHWS")
Signed-off-by Alexander Kozyrev <[email protected]>--- drivers/net/mlx5/mlx5_flow.c | 1 + 1 file changed, 1 insertion(+)drivers/net/mlx5/mlx5_flow.c +1
-0@@ -10758,6 +10758,7 @@ mlx5_action_handle_update(struct rte_eth_dev *dev, switch (type) {case MLX5_INDIRECT_ACTION_TYPE_CT : +case MLX5_INDIRECT_ACTION_TYPE_METER_MARK : ret =0 ;break ;
Quoted 3 lines
default:
--
2.18.2
Best,
Ori
PATCH v2 3/3 app/testpmd: fix meter mark handle update
In reply to Alexander KozyrevThe indirect action handle update for the METER_MERK action was implemented only for the async RTE Flow API.
Allow updating the METER_MARK parameters via the old sync method.
--- app/test-pmd/config.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-)
app/test-pmd/config.c +16 -2
@@ -1943,6 +1943,7 @@ port_action_handle_update(portid_t port_id, uint32_t id,struct rte_flow_error error;struct rte_flow_action_handle *action_handle;struct port_indirect_action *pia; +struct rte_flow_update_meter_mark mtr_update;const void *update; action_handle =port_action_handle_get_by_id (port_id, id);
@@ -1956,6 +1957,17 @@ port_action_handle_update(portid_t port_id, uint32_t id,case RTE_FLOW_ACTION_TYPE_CONNTRACK : update = action->conf;break ; +case RTE_FLOW_ACTION_TYPE_METER_MARK : +memcpy (&mtr_update.meter_mark, action->conf, +sizeof (struct rte_flow_action_meter_mark )); +if (mtr_update.meter_mark.profile) + mtr_update.profile_valid =1 ; +if (mtr_update.meter_mark.policy) + mtr_update.policy_valid =1 ; + mtr_update.color_mode_valid =1 ; + mtr_update.state_valid =1 ; + update = &mtr_update; +break ;default : update = action;break ;
@@ -3162,8 +3174,10 @@ port_queue_action_handle_update(portid_t port_id,case RTE_FLOW_ACTION_TYPE_METER_MARK :rte_memcpy (&mtr_update.meter_mark, action->conf,sizeof (struct rte_flow_action_meter_mark )); - mtr_update.profile_valid =1 ; - mtr_update.policy_valid =1 ; +if (mtr_update.meter_mark.profile) + mtr_update.profile_valid =1 ; +if (mtr_update.meter_mark.policy) + mtr_update.policy_valid =1 ; mtr_update.color_mode_valid =1 ; mtr_update.init_color_valid =1 ; mtr_update.state_valid =1 ;
Signature · 1 line
2.18.2
RE: [PATCH v2 3/3] app/testpmd: fix meter mark handle update
Quoted 6 lines
-----Original Message-----
From: Alexander Kozyrev <[email protected]>
Sent: Tuesday, July 18, 2023 4:32 PM
Quoted 8 lines
The indirect action handle update for the
METER_MERKaction was implemented only for the async RTE Flow API.
Allow updating theMETER_MARKparameters via the old sync method.Fixes 9c4a0c1859a3 ("ethdev: add meter color mark flow action")Signed-off-by Alexander Kozyrev <[email protected]>---
Best,
Ori
Quoted 24 lines
-----Original Message-----
From: Alexander Kozyrev <[email protected]>
Sent: Tuesday, July 18, 2023 4:32 PMFrom: Bing Zhao <[email protected]>
After rte_flow_shared_action_* API was replaced with rte_flow_action_handle_* API, one input parameter of the update interface was also changed. A generic pointer was used instead of the "const struct
rte_flow_action*" pointer.In the entrance of mlx5 PMD callback for update, the validation is called for all indirect actions. But for conntrack type, the pointer is no longer with
rte_flow_actionpointer type and it will cause an incorrect casting and error.The content for updating should only be validated when needed. It should skip the validation in the entrance. Right now, the content was already added before updating the hardware by WQE. So the type of the indirect action should be checked before calling the action validate function.
Quoted 7 lines
When creating a new conntrack object, the validation is still needed since all the content will be used to update the hardware context.
Fixes 40327aab1491 ("ethdev: introduce indirect flow action")Signed-off-by Bing Zhao <[email protected]>---
Best,
Ori
Hi,
Quoted 25 lines
-----Original Message-----
From: Alexander Kozyrev <[email protected]>
Sent: Tuesday, July 18, 2023 4:32 PM
To: [email protected]
Cc: [email protected]; Raslan Darawsheh <[email protected]>; Slava Ovsiienko <[email protected]>; Matan Azrad <[email protected]>; [email protected]; Bing Zhao <[email protected]>
Subject: [PATCH v2 1/3] net/mlx5: fix validation for conntrack indirect actionFrom: Bing Zhao <[email protected]>
After rte_flow_shared_action_* API was replaced with rte_flow_action_handle_* API, one input parameter of the update interface was also changed. A generic pointer was used instead of the "const struct
rte_flow_action*" pointer.In the entrance of mlx5 PMD callback for update, the validation is called for all indirect actions. But for conntrack type, the pointer is no longer with
rte_flow_actionpointer type and it will cause an incorrect casting and error.The content for updating should only be validated when needed. It should skip the validation in the entrance. Right now, the content was already added before updating the hardware by WQE. So the type of the indirect action should be checked before calling the action validate function.
Quoted 6 lines
When creating a new conntrack object, the validation is still needed since all the content will be used to update the hardware context.
Fixes 40327aab1491 ("ethdev: introduce indirect flow action")Signed-off-by Bing Zhao <[email protected]>
Series applied to next-net-mlx,
Kindest regards,
Raslan Darawsheh