> -----Original Message-----
> From: Jiawei(Jonny) Wang <jiaw...@nvidia.com>
> Sent: Friday, September 8, 2023 5:21 PM
> To: Suanming Mou <suanmi...@nvidia.com>; Ori Kam <or...@nvidia.com>;
> NBU-Contact-Thomas Monjalon (EXTERNAL) <tho...@monjalon.net>
> Cc: dev@dpdk.org; Raslan Darawsheh <rasl...@nvidia.com>
> Subject: [PATCH 2/3] net/mlx5: extend hws send to kernel action support
>
> The hws send to kernel action was supported in NIC and FDB tables, Currently,
> the send to kernel action is created in NIC RX only.
>
> This patch adds the FDB and NIC-TX tables support for sending to the kernel
> action for HWS.
>
> Signed-off-by: Jiawei Wang <jiaw...@nvidia.com>
Acked-by: Suanming Mou <suanmi...@nvidia.com>
> ---
> drivers/net/mlx5/mlx5.h | 2 +-
> drivers/net/mlx5/mlx5_flow_hw.c | 45 +++++++++++++++++++++++----------
> 2 files changed, 33 insertions(+), 14 deletions(-)
>
> diff --git a/drivers/net/mlx5/mlx5.h b/drivers/net/mlx5/mlx5.h index
> 6960a07d40..d49b81a360 100644
> --- a/drivers/net/mlx5/mlx5.h
> +++ b/drivers/net/mlx5/mlx5.h
> @@ -1858,7 +1858,7 @@ struct mlx5_priv {
> /* HW steering global tag action. */
> struct mlx5dr_action *hw_tag[2];
> /* HW steering global send to kernel action. */
> - struct mlx5dr_action *hw_send_to_kernel;
> + struct mlx5dr_action *hw_send_to_kernel[MLX5DR_TABLE_TYPE_MAX];
> /* HW steering create ongoing rte flow table list header. */
> LIST_HEAD(flow_hw_tbl_ongo, rte_flow_template_table)
> flow_hw_tbl_ongo;
> struct mlx5_indexed_pool *acts_ipool; /* Action data indexed pool. */
> diff --git a/drivers/net/mlx5/mlx5_flow_hw.c
> b/drivers/net/mlx5/mlx5_flow_hw.c index 92a5c92669..84d869a686 100644
> --- a/drivers/net/mlx5/mlx5_flow_hw.c
> +++ b/drivers/net/mlx5/mlx5_flow_hw.c
> @@ -1439,6 +1439,7 @@ __flow_hw_actions_translate(struct rte_eth_dev
> *dev,
> uint32_t ct_idx;
> int err;
> uint32_t target_grp = 0;
> + int table_type;
>
> flow_hw_modify_field_init(&mhdr, at);
> if (attr->transfer)
> @@ -1635,7 +1636,10 @@ __flow_hw_actions_translate(struct rte_eth_dev
> *dev,
> "Send to kernel action on root
> table is not supported in HW steering mode");
> }
> action_pos = at->actions_off[actions - at->actions];
> - acts->rule_acts[action_pos].action = priv-
> >hw_send_to_kernel;
> + table_type = attr->ingress ?
> MLX5DR_TABLE_TYPE_NIC_RX :
> + ((attr->egress) ?
> MLX5DR_TABLE_TYPE_NIC_TX :
> + MLX5DR_TABLE_TYPE_FDB);
> + acts->rule_acts[action_pos].action =
> +priv->hw_send_to_kernel[table_type];
> break;
> case RTE_FLOW_ACTION_TYPE_MODIFY_FIELD:
> err = flow_hw_modify_field_compile(dev, attr,
> action_start, @@ -4345,8 +4349,11 @@ mlx5_flow_hw_actions_validate(struct
> rte_eth_dev *dev,
> const struct rte_flow_action_count *count_mask = NULL;
> bool fixed_cnt = false;
> uint64_t action_flags = 0;
> - uint16_t i;
> bool actions_end = false;
> +#ifdef HAVE_MLX5DV_DR_ACTION_CREATE_DEST_ROOT_TABLE
> + int table_type;
> +#endif
> + uint16_t i;
> int ret;
>
> /* FDB actions are only valid to proxy port. */ @@ -4397,7 +4404,10
> @@ mlx5_flow_hw_actions_validate(struct rte_eth_dev *dev,
>
> RTE_FLOW_ERROR_TYPE_ACTION,
> action,
> "action not supported
> in guest port");
> - if (!priv->hw_send_to_kernel)
> + table_type = attr->ingress ?
> MLX5DR_TABLE_TYPE_NIC_RX :
> + ((attr->egress) ?
> MLX5DR_TABLE_TYPE_NIC_TX :
> + MLX5DR_TABLE_TYPE_FDB);
> + if (!priv->hw_send_to_kernel[table_type])
> return rte_flow_error_set(error, ENOTSUP,
>
> RTE_FLOW_ERROR_TYPE_ACTION,
> action,
> @@ -5955,13 +5965,19 @@ static void
> flow_hw_create_send_to_kernel_actions(struct mlx5_priv *priv __rte_unused)
> { #ifdef HAVE_MLX5DV_DR_ACTION_CREATE_DEST_ROOT_TABLE
> - priv->hw_send_to_kernel =
> - mlx5dr_action_create_dest_root(priv->dr_ctx,
> -
> MLX5_HW_LOWEST_PRIO_ROOT,
> -
> MLX5DR_ACTION_FLAG_HWS_RX);
> - if (!priv->hw_send_to_kernel) {
> - DRV_LOG(WARNING, "Unable to create HWS send to kernel
> action");
> - return;
> + int action_flag;
> + int i;
> +
> + for (i = MLX5DR_TABLE_TYPE_NIC_RX; i < MLX5DR_TABLE_TYPE_MAX;
> i++) {
> + action_flag = mlx5_hw_act_flag[1][i];
> + priv->hw_send_to_kernel[i] =
> + mlx5dr_action_create_dest_root(priv->dr_ctx,
> +
> MLX5_HW_LOWEST_PRIO_ROOT,
> + action_flag);
> + if (!priv->hw_send_to_kernel[i]) {
> + DRV_LOG(WARNING, "Unable to create HWS send to
> kernel action");
> + return;
> + }
> }
> #endif
> }
> @@ -5969,9 +5985,12 @@ flow_hw_create_send_to_kernel_actions(struct
> mlx5_priv *priv __rte_unused) static void
> flow_hw_destroy_send_to_kernel_action(struct mlx5_priv *priv) {
> - if (priv->hw_send_to_kernel) {
> - mlx5dr_action_destroy(priv->hw_send_to_kernel);
> - priv->hw_send_to_kernel = NULL;
> + int i;
> + for (i = MLX5DR_TABLE_TYPE_NIC_RX; i < MLX5DR_TABLE_TYPE_MAX;
> i++) {
> + if (priv->hw_send_to_kernel[i]) {
> + mlx5dr_action_destroy(priv->hw_send_to_kernel[i]);
> + priv->hw_send_to_kernel[i] = NULL;
> + }
> }
> }
>
> --
> 2.18.1