DPDK patches and discussions
 help / color / mirror / Atom feed
From: Suanming Mou <suanmingm@nvidia.com>
To: "Jiawei(Jonny) Wang" <jiaweiw@nvidia.com>,
	Ori Kam <orika@nvidia.com>,
	"NBU-Contact-Thomas Monjalon (EXTERNAL)" <thomas@monjalon.net>
Cc: "dev@dpdk.org" <dev@dpdk.org>, Raslan Darawsheh <rasland@nvidia.com>
Subject: RE: [PATCH 1/3] net/mlx5: extend send to kernel action support
Date: Fri, 8 Sep 2023 09:35:03 +0000	[thread overview]
Message-ID: <SJ0PR12MB540549442C7DC6154055E20FC1EDA@SJ0PR12MB5405.namprd12.prod.outlook.com> (raw)
In-Reply-To: <20230908092100.38587-2-jiaweiw@nvidia.com>



> -----Original Message-----
> From: Jiawei(Jonny) Wang <jiaweiw@nvidia.com>
> Sent: Friday, September 8, 2023 5:21 PM
> To: Suanming Mou <suanmingm@nvidia.com>; Ori Kam <orika@nvidia.com>;
> NBU-Contact-Thomas Monjalon (EXTERNAL) <thomas@monjalon.net>
> Cc: dev@dpdk.org; Raslan Darawsheh <rasland@nvidia.com>
> Subject: [PATCH 1/3] net/mlx5: extend send to kernel action support
> 
> The send to kernel action was supported in NIC and FDB tables, Currently, the
> send to kernel action is created in NIC RX only.
> 
> With some TC rules (example: roce packets, redirects into rep ports) and DPDK
> RTE rules for the rest of the traffic. Then it needs the specific rule to re-route the
> packets into the kernel through the FDB table.
> 
> This patch adds the FDB and NIC-TX tables support for sending to the kernel
> action.
> 
> Signed-off-by: Jiawei Wang <jiaweiw@nvidia.com>
Acked-by: Suanming Mou <suanmingm@nvidia.com>
> ---
>  drivers/net/mlx5/linux/mlx5_os.c | 25 +++++++++++++++----------
>  drivers/net/mlx5/mlx5.h          |  4 +++-
>  drivers/net/mlx5/mlx5_flow.h     |  1 +
>  drivers/net/mlx5/mlx5_flow_dv.c  | 17 +++++++++++------
>  4 files changed, 30 insertions(+), 17 deletions(-)
> 
> diff --git a/drivers/net/mlx5/linux/mlx5_os.c b/drivers/net/mlx5/linux/mlx5_os.c
> index d8f1adfe3d..38572eb652 100644
> --- a/drivers/net/mlx5/linux/mlx5_os.c
> +++ b/drivers/net/mlx5/linux/mlx5_os.c
> @@ -675,6 +675,9 @@ void
>  mlx5_os_free_shared_dr(struct mlx5_priv *priv)  {
>  	struct mlx5_dev_ctx_shared *sh = priv->sh;
> +#ifdef HAVE_MLX5DV_DR
> +	int i;
> +#endif
> 
>  	MLX5_ASSERT(sh && sh->refcnt);
>  	if (sh->refcnt > 1)
> @@ -703,18 +706,20 @@ mlx5_os_free_shared_dr(struct mlx5_priv *priv)
>  		mlx5_glue->destroy_flow_action(sh->pop_vlan_action);
>  		sh->pop_vlan_action = NULL;
>  	}
> -	if (sh->send_to_kernel_action.action) {
> -		void *action = sh->send_to_kernel_action.action;
> +	for (i = 0; i < MLX5DR_TABLE_TYPE_MAX; i++) {
> +		if (sh->send_to_kernel_action[i].action) {
> +			void *action = sh->send_to_kernel_action[i].action;
> 
> -		mlx5_glue->destroy_flow_action(action);
> -		sh->send_to_kernel_action.action = NULL;
> -	}
> -	if (sh->send_to_kernel_action.tbl) {
> -		struct mlx5_flow_tbl_resource *tbl =
> -				sh->send_to_kernel_action.tbl;
> +			mlx5_glue->destroy_flow_action(action);
> +			sh->send_to_kernel_action[i].action = NULL;
> +		}
> +		if (sh->send_to_kernel_action[i].tbl) {
> +			struct mlx5_flow_tbl_resource *tbl =
> +					sh->send_to_kernel_action[i].tbl;
> 
> -		flow_dv_tbl_resource_release(sh, tbl);
> -		sh->send_to_kernel_action.tbl = NULL;
> +			flow_dv_tbl_resource_release(sh, tbl);
> +			sh->send_to_kernel_action[i].tbl = NULL;
> +		}
>  	}
>  #endif /* HAVE_MLX5DV_DR */
>  	if (sh->default_miss_action)
> diff --git a/drivers/net/mlx5/mlx5.h b/drivers/net/mlx5/mlx5.h index
> 3785103308..6960a07d40 100644
> --- a/drivers/net/mlx5/mlx5.h
> +++ b/drivers/net/mlx5/mlx5.h
> @@ -1432,7 +1432,9 @@ struct mlx5_dev_ctx_shared {
>  	/* Direct Rules tables for FDB, NIC TX+RX */
>  	void *dr_drop_action; /* Pointer to DR drop action, any domain. */
>  	void *pop_vlan_action; /* Pointer to DR pop VLAN action. */
> -	struct mlx5_send_to_kernel_action send_to_kernel_action;
> +#if defined(HAVE_IBV_FLOW_DV_SUPPORT)
> || !defined(HAVE_INFINIBAND_VERBS_H)
> +	struct mlx5_send_to_kernel_action
> +send_to_kernel_action[MLX5DR_TABLE_TYPE_MAX];
> +#endif
>  	struct mlx5_hlist *encaps_decaps; /* Encap/decap action hash list. */
>  	struct mlx5_hlist *modify_cmds;
>  	struct mlx5_hlist *tag_table;
> diff --git a/drivers/net/mlx5/mlx5_flow.h b/drivers/net/mlx5/mlx5_flow.h index
> 3a97975d69..6beac3902c 100644
> --- a/drivers/net/mlx5/mlx5_flow.h
> +++ b/drivers/net/mlx5/mlx5_flow.h
> @@ -331,6 +331,7 @@ enum mlx5_feature_name {
> 
>  #define MLX5_FLOW_FATE_ESWITCH_ACTIONS \
>  	(MLX5_FLOW_ACTION_DROP | MLX5_FLOW_ACTION_PORT_ID | \
> +	 MLX5_FLOW_ACTION_SEND_TO_KERNEL | \
>  	 MLX5_FLOW_ACTION_JUMP |
> MLX5_FLOW_ACTION_METER_WITH_TERMINATED_POLICY)
> 
>  #define MLX5_FLOW_MODIFY_HDR_ACTIONS
> (MLX5_FLOW_ACTION_SET_IPV4_SRC | \ diff --git
> a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c index
> a8dd9920e6..fe0814a2eb 100644
> --- a/drivers/net/mlx5/mlx5_flow_dv.c
> +++ b/drivers/net/mlx5/mlx5_flow_dv.c
> @@ -12724,17 +12724,22 @@ flow_dv_translate_action_sample(struct
> rte_eth_dev *dev,
> 
>  static void *
>  flow_dv_translate_action_send_to_kernel(struct rte_eth_dev *dev,
> +					const struct rte_flow_attr *attr,
>  					struct rte_flow_error *error)
>  {
>  	struct mlx5_flow_tbl_resource *tbl;
>  	struct mlx5_dev_ctx_shared *sh;
>  	uint32_t priority;
>  	void *action;
> +	int ft_type;
>  	int ret;
> 
>  	sh = MLX5_SH(dev);
> -	if (sh->send_to_kernel_action.action)
> -		return sh->send_to_kernel_action.action;
> +	ft_type = (attr->ingress) ? MLX5DR_TABLE_TYPE_NIC_RX :
> +		  ((attr->transfer) ? MLX5DR_TABLE_TYPE_FDB :
> +		  MLX5DR_TABLE_TYPE_NIC_TX);
> +	if (sh->send_to_kernel_action[ft_type].action)
> +		return sh->send_to_kernel_action[ft_type].action;
>  	priority = mlx5_get_send_to_kernel_priority(dev);
>  	if (priority == (uint32_t)-1) {
>  		rte_flow_error_set(error, ENOTSUP,
> @@ -12742,7 +12747,7 @@ flow_dv_translate_action_send_to_kernel(struct
> rte_eth_dev *dev,
>  				   "required priority is not available");
>  		return NULL;
>  	}
> -	tbl = flow_dv_tbl_resource_get(dev, 0, 0, 0, false, NULL, 0, 0, 0,
> +	tbl = flow_dv_tbl_resource_get(dev, 0, attr->egress, attr->transfer,
> +false, NULL, 0, 0, 0,
>  				       error);
>  	if (!tbl) {
>  		rte_flow_error_set(error, ENODATA,
> @@ -12759,8 +12764,8 @@ flow_dv_translate_action_send_to_kernel(struct
> rte_eth_dev *dev,
>  		goto err;
>  	}
>  	MLX5_ASSERT(action);
> -	sh->send_to_kernel_action.action = action;
> -	sh->send_to_kernel_action.tbl = tbl;
> +	sh->send_to_kernel_action[ft_type].action = action;
> +	sh->send_to_kernel_action[ft_type].tbl = tbl;
>  	return action;
>  err:
>  	flow_dv_tbl_resource_release(sh, tbl); @@ -14511,7 +14516,7 @@
> flow_dv_translate(struct rte_eth_dev *dev,
>  			break;
>  		case RTE_FLOW_ACTION_TYPE_SEND_TO_KERNEL:
>  			dev_flow->dv.actions[actions_n] =
> -				flow_dv_translate_action_send_to_kernel(dev,
> +				flow_dv_translate_action_send_to_kernel(dev,
> attr,
>  							error);
>  			if (!dev_flow->dv.actions[actions_n])
>  				return -rte_errno;
> --
> 2.18.1


  reply	other threads:[~2023-09-08  9:35 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-08  9:20 [PATCH 0/3] " Jiawei Wang
2023-09-08  9:20 ` [PATCH 1/3] " Jiawei Wang
2023-09-08  9:35   ` Suanming Mou [this message]
2023-09-18 12:52   ` Raslan Darawsheh
2023-09-08  9:20 ` [PATCH 2/3] net/mlx5: extend hws " Jiawei Wang
2023-09-08  9:35   ` Suanming Mou
2023-09-08  9:21 ` [PATCH 3/3] doc: adds the description for send to kernel Jiawei Wang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=SJ0PR12MB540549442C7DC6154055E20FC1EDA@SJ0PR12MB5405.namprd12.prod.outlook.com \
    --to=suanmingm@nvidia.com \
    --cc=dev@dpdk.org \
    --cc=jiaweiw@nvidia.com \
    --cc=orika@nvidia.com \
    --cc=rasland@nvidia.com \
    --cc=thomas@monjalon.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).