[v3,9/9] net/mlx5: add drop action to Direct Verbs E-Switch

Message ID 1555593367-144772-10-git-send-email-orika@mellanox.com
State Accepted, archived
Delegated to: Shahaf Shuler
Headers show
Series
  • net/mlx5: add Direct Verbs E-Switch support
Related show

Checks

Context Check Description
ci/Intel-compilation fail apply issues
ci/checkpatch warning coding style issues

Commit Message

Ori Kam April 18, 2019, 1:16 p.m.
This commit adds support for drop action when creating E-Switch flow
using DV.

Signed-off-by: Ori Kam <orika@mellanox.com>
Acked-by: Yongseok Koh <yskoh@mellanox.com>
---
 drivers/net/mlx5/mlx5.c         |  9 +++++++++
 drivers/net/mlx5/mlx5.h         |  1 +
 drivers/net/mlx5/mlx5_flow_dv.c | 22 ++++++++++++++--------
 drivers/net/mlx5/mlx5_glue.c    | 12 ++++++++++++
 drivers/net/mlx5/mlx5_glue.h    |  1 +
 5 files changed, 37 insertions(+), 8 deletions(-)

Comments

Yongseok Koh April 18, 2019, 1:23 p.m. | #1
> On Apr 18, 2019, at 6:16 AM, Ori Kam <orika@mellanox.com> wrote:
> 
> This commit adds support for drop action when creating E-Switch flow
> using DV.
> 
> Signed-off-by: Ori Kam <orika@mellanox.com>
> Acked-by: Yongseok Koh <yskoh@mellanox.com>
> ---
> drivers/net/mlx5/mlx5.c         |  9 +++++++++
> drivers/net/mlx5/mlx5.h         |  1 +
> drivers/net/mlx5/mlx5_flow_dv.c | 22 ++++++++++++++--------
> drivers/net/mlx5/mlx5_glue.c    | 12 ++++++++++++
> drivers/net/mlx5/mlx5_glue.h    |  1 +
> 5 files changed, 37 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c
> index ff24e1d..65c69af 100644
> --- a/drivers/net/mlx5/mlx5.c
> +++ b/drivers/net/mlx5/mlx5.c
> @@ -357,6 +357,7 @@ struct mlx5_dev_spawn_data {
> 			goto error;
> 		}
> 		sh->fdb_ns = ns;
> +		sh->esw_drop_action = mlx5_glue->dr_create_flow_action_drop();
> 	}
> #endif
> 	sh->dv_refcnt++;
> @@ -377,6 +378,10 @@ struct mlx5_dev_spawn_data {
> 		mlx5_glue->dr_destroy_ns(sh->fdb_ns);
> 		sh->fdb_ns = NULL;
> 	}
> +	if (sh->esw_drop_action) {
> +		mlx5_glue->destroy_flow_action(sh->esw_drop_action);
> +		sh->esw_drop_action = NULL;
> +	}
> 	return err;
> #else
> 	(void)priv;
> @@ -417,6 +422,10 @@ struct mlx5_dev_spawn_data {
> 		mlx5_glue->dr_destroy_ns(sh->fdb_ns);
> 		sh->fdb_ns = NULL;
> 	}
> +	if (sh->esw_drop_action) {
> +		mlx5_glue->destroy_flow_action(sh->esw_drop_action);
> +		sh->esw_drop_action = NULL;
> +	}
> #endif
> 	pthread_mutex_destroy(&sh->dv_mutex);
> #else
> diff --git a/drivers/net/mlx5/mlx5.h b/drivers/net/mlx5/mlx5.h
> index 907d5c3..443625e 100644
> --- a/drivers/net/mlx5/mlx5.h
> +++ b/drivers/net/mlx5/mlx5.h
> @@ -276,6 +276,7 @@ struct mlx5_ibv_shared {
> 	/* RX Direct Rules tables. */
> 	void *tx_ns; /* TX Direct Rules name space handle. */
> 	struct mlx5_flow_tbl_resource tx_tbl[MLX5_MAX_TABLES];
> +	void *esw_drop_action; /* Pointer to DR E-Switch drop action. */
> 	/* TX Direct Rules tables/ */
> 	LIST_HEAD(matchers, mlx5_flow_dv_matcher) matchers;
> 	LIST_HEAD(encap_decap, mlx5_flow_dv_encap_decap_resource) encaps_decaps;
> diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c
> index 5997182..4352d48 100644
> --- a/drivers/net/mlx5/mlx5_flow_dv.c
> +++ b/drivers/net/mlx5/mlx5_flow_dv.c
> @@ -4049,6 +4049,7 @@ struct field_modify_info modify_tcp[] = {
> {
> 	struct mlx5_flow_dv *dv;
> 	struct mlx5_flow *dev_flow;
> +	struct mlx5_priv *priv = dev->data->dev_private;
> 	int n;
> 	int err;
> 
> @@ -4056,15 +4057,20 @@ struct field_modify_info modify_tcp[] = {
> 		dv = &dev_flow->dv;
> 		n = dv->actions_n;
> 		if (flow->actions & MLX5_FLOW_ACTION_DROP) {
> -			dv->hrxq = mlx5_hrxq_drop_new(dev);
> -			if (!dv->hrxq) {
> -				rte_flow_error_set
> -					(error, errno,
> -					 RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL,
> -					 "cannot get drop hash queue");
> -				goto error;
> +			if (flow->transfer)
> +				dv->actions[n++] = priv->sh->esw_drop_action;
> +			else {

Please fix the coding style issue.
http://mails.dpdk.org/archives/test-report/2019-April/080992.html

> +				dv->hrxq = mlx5_hrxq_drop_new(dev);
> +				if (!dv->hrxq) {
> +					rte_flow_error_set
> +						(error, errno,
> +						 RTE_FLOW_ERROR_TYPE_UNSPECIFIED,
> +						 NULL,
> +						 "cannot get drop hash queue");
> +					goto error;
> +				}
> +				dv->actions[n++] = dv->hrxq->action;
> 			}
> -			dv->actions[n++] = dv->hrxq->action;
> 		} else if (flow->actions &
> 			   (MLX5_FLOW_ACTION_QUEUE | MLX5_FLOW_ACTION_RSS)) {
> 			struct mlx5_hrxq *hrxq;
> diff --git a/drivers/net/mlx5/mlx5_glue.c b/drivers/net/mlx5/mlx5_glue.c
> index 117190f..b32cd09c 100644
> --- a/drivers/net/mlx5/mlx5_glue.c
> +++ b/drivers/net/mlx5/mlx5_glue.c
> @@ -394,6 +394,16 @@
> }
> 
> static void *
> +mlx5_glue_dr_create_flow_action_drop(void)
> +{
> +#ifdef HAVE_MLX5DV_DR_ESWITCH
> +	return mlx5dv_dr_create_action_drop();
> +#else
> +	return NULL;
> +#endif
> +}
> +
> +static void *
> mlx5_glue_dr_create_flow_tbl(void *ns, uint32_t level)
> {
> #ifdef HAVE_MLX5DV_DR
> @@ -861,6 +871,8 @@
> 		mlx5_glue_dr_create_flow_action_dest_flow_tbl,
> 	.dr_create_flow_action_dest_vport =
> 		mlx5_glue_dr_create_flow_action_dest_vport,
> +	.dr_create_flow_action_drop =
> +		mlx5_glue_dr_create_flow_action_drop,
> 	.dr_create_flow_tbl = mlx5_glue_dr_create_flow_tbl,
> 	.dr_destroy_flow_tbl = mlx5_glue_dr_destroy_flow_tbl,
> 	.dr_create_ns = mlx5_glue_dr_create_ns,
> diff --git a/drivers/net/mlx5/mlx5_glue.h b/drivers/net/mlx5/mlx5_glue.h
> index 26f5cb3..1d06583 100644
> --- a/drivers/net/mlx5/mlx5_glue.h
> +++ b/drivers/net/mlx5/mlx5_glue.h
> @@ -147,6 +147,7 @@ struct mlx5_glue {
> 	struct ibv_cq *(*cq_ex_to_cq)(struct ibv_cq_ex *cq);
> 	void *(*dr_create_flow_action_dest_flow_tbl)(void *tbl);
> 	void *(*dr_create_flow_action_dest_vport)(void *ns, uint32_t vport);
> +	void *(*dr_create_flow_action_drop)();
> 	void *(*dr_create_flow_tbl)(void *ns, uint32_t level);
> 	int (*dr_destroy_flow_tbl)(void *tbl);
> 	void *(*dr_create_ns)(struct ibv_context *ctx,
> -- 
> 1.8.3.1
>
Ori Kam April 18, 2019, 1:47 p.m. | #2
Hi Shahaf,

Can you please fix it when you take it?

Thanks,
Ori

> -----Original Message-----
> From: Yongseok Koh
> Sent: Thursday, April 18, 2019 4:23 PM
> To: Ori Kam <orika@mellanox.com>
> Cc: Shahaf Shuler <shahafs@mellanox.com>; Matan Azrad
> <matan@mellanox.com>; Slava Ovsiienko <viacheslavo@mellanox.com>; Moti
> Haimovsky <motih@mellanox.com>; dev@dpdk.org
> Subject: Re: [PATCH v3 9/9] net/mlx5: add drop action to Direct Verbs E-Switch
> 
> > On Apr 18, 2019, at 6:16 AM, Ori Kam <orika@mellanox.com> wrote:
> >
> > This commit adds support for drop action when creating E-Switch flow
> > using DV.
> >
> > Signed-off-by: Ori Kam <orika@mellanox.com>
> > Acked-by: Yongseok Koh <yskoh@mellanox.com>
> > ---
> > drivers/net/mlx5/mlx5.c         |  9 +++++++++
> > drivers/net/mlx5/mlx5.h         |  1 +
> > drivers/net/mlx5/mlx5_flow_dv.c | 22 ++++++++++++++--------
> > drivers/net/mlx5/mlx5_glue.c    | 12 ++++++++++++
> > drivers/net/mlx5/mlx5_glue.h    |  1 +
> > 5 files changed, 37 insertions(+), 8 deletions(-)
> >
> > diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c
> > index ff24e1d..65c69af 100644
> > --- a/drivers/net/mlx5/mlx5.c
> > +++ b/drivers/net/mlx5/mlx5.c
> > @@ -357,6 +357,7 @@ struct mlx5_dev_spawn_data {
> > 			goto error;
> > 		}
> > 		sh->fdb_ns = ns;
> > +		sh->esw_drop_action = mlx5_glue-
> >dr_create_flow_action_drop();
> > 	}
> > #endif
> > 	sh->dv_refcnt++;
> > @@ -377,6 +378,10 @@ struct mlx5_dev_spawn_data {
> > 		mlx5_glue->dr_destroy_ns(sh->fdb_ns);
> > 		sh->fdb_ns = NULL;
> > 	}
> > +	if (sh->esw_drop_action) {
> > +		mlx5_glue->destroy_flow_action(sh->esw_drop_action);
> > +		sh->esw_drop_action = NULL;
> > +	}
> > 	return err;
> > #else
> > 	(void)priv;
> > @@ -417,6 +422,10 @@ struct mlx5_dev_spawn_data {
> > 		mlx5_glue->dr_destroy_ns(sh->fdb_ns);
> > 		sh->fdb_ns = NULL;
> > 	}
> > +	if (sh->esw_drop_action) {
> > +		mlx5_glue->destroy_flow_action(sh->esw_drop_action);
> > +		sh->esw_drop_action = NULL;
> > +	}
> > #endif
> > 	pthread_mutex_destroy(&sh->dv_mutex);
> > #else
> > diff --git a/drivers/net/mlx5/mlx5.h b/drivers/net/mlx5/mlx5.h
> > index 907d5c3..443625e 100644
> > --- a/drivers/net/mlx5/mlx5.h
> > +++ b/drivers/net/mlx5/mlx5.h
> > @@ -276,6 +276,7 @@ struct mlx5_ibv_shared {
> > 	/* RX Direct Rules tables. */
> > 	void *tx_ns; /* TX Direct Rules name space handle. */
> > 	struct mlx5_flow_tbl_resource tx_tbl[MLX5_MAX_TABLES];
> > +	void *esw_drop_action; /* Pointer to DR E-Switch drop action. */
> > 	/* TX Direct Rules tables/ */
> > 	LIST_HEAD(matchers, mlx5_flow_dv_matcher) matchers;
> > 	LIST_HEAD(encap_decap, mlx5_flow_dv_encap_decap_resource)
> encaps_decaps;
> > diff --git a/drivers/net/mlx5/mlx5_flow_dv.c
> b/drivers/net/mlx5/mlx5_flow_dv.c
> > index 5997182..4352d48 100644
> > --- a/drivers/net/mlx5/mlx5_flow_dv.c
> > +++ b/drivers/net/mlx5/mlx5_flow_dv.c
> > @@ -4049,6 +4049,7 @@ struct field_modify_info modify_tcp[] = {
> > {
> > 	struct mlx5_flow_dv *dv;
> > 	struct mlx5_flow *dev_flow;
> > +	struct mlx5_priv *priv = dev->data->dev_private;
> > 	int n;
> > 	int err;
> >
> > @@ -4056,15 +4057,20 @@ struct field_modify_info modify_tcp[] = {
> > 		dv = &dev_flow->dv;
> > 		n = dv->actions_n;
> > 		if (flow->actions & MLX5_FLOW_ACTION_DROP) {
> > -			dv->hrxq = mlx5_hrxq_drop_new(dev);
> > -			if (!dv->hrxq) {
> > -				rte_flow_error_set
> > -					(error, errno,
> > -
> RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL,
> > -					 "cannot get drop hash queue");
> > -				goto error;
> > +			if (flow->transfer)
> > +				dv->actions[n++] = priv->sh->esw_drop_action;
> > +			else {
> 
> Please fix the coding style issue.
> http://mails.dpdk.org/archives/test-report/2019-April/080992.html
> 
> > +				dv->hrxq = mlx5_hrxq_drop_new(dev);
> > +				if (!dv->hrxq) {
> > +					rte_flow_error_set
> > +						(error, errno,
> > +
> RTE_FLOW_ERROR_TYPE_UNSPECIFIED,
> > +						 NULL,
> > +						 "cannot get drop hash
> queue");
> > +					goto error;
> > +				}
> > +				dv->actions[n++] = dv->hrxq->action;
> > 			}
> > -			dv->actions[n++] = dv->hrxq->action;
> > 		} else if (flow->actions &
> > 			   (MLX5_FLOW_ACTION_QUEUE |
> MLX5_FLOW_ACTION_RSS)) {
> > 			struct mlx5_hrxq *hrxq;
> > diff --git a/drivers/net/mlx5/mlx5_glue.c b/drivers/net/mlx5/mlx5_glue.c
> > index 117190f..b32cd09c 100644
> > --- a/drivers/net/mlx5/mlx5_glue.c
> > +++ b/drivers/net/mlx5/mlx5_glue.c
> > @@ -394,6 +394,16 @@
> > }
> >
> > static void *
> > +mlx5_glue_dr_create_flow_action_drop(void)
> > +{
> > +#ifdef HAVE_MLX5DV_DR_ESWITCH
> > +	return mlx5dv_dr_create_action_drop();
> > +#else
> > +	return NULL;
> > +#endif
> > +}
> > +
> > +static void *
> > mlx5_glue_dr_create_flow_tbl(void *ns, uint32_t level)
> > {
> > #ifdef HAVE_MLX5DV_DR
> > @@ -861,6 +871,8 @@
> > 		mlx5_glue_dr_create_flow_action_dest_flow_tbl,
> > 	.dr_create_flow_action_dest_vport =
> > 		mlx5_glue_dr_create_flow_action_dest_vport,
> > +	.dr_create_flow_action_drop =
> > +		mlx5_glue_dr_create_flow_action_drop,
> > 	.dr_create_flow_tbl = mlx5_glue_dr_create_flow_tbl,
> > 	.dr_destroy_flow_tbl = mlx5_glue_dr_destroy_flow_tbl,
> > 	.dr_create_ns = mlx5_glue_dr_create_ns,
> > diff --git a/drivers/net/mlx5/mlx5_glue.h b/drivers/net/mlx5/mlx5_glue.h
> > index 26f5cb3..1d06583 100644
> > --- a/drivers/net/mlx5/mlx5_glue.h
> > +++ b/drivers/net/mlx5/mlx5_glue.h
> > @@ -147,6 +147,7 @@ struct mlx5_glue {
> > 	struct ibv_cq *(*cq_ex_to_cq)(struct ibv_cq_ex *cq);
> > 	void *(*dr_create_flow_action_dest_flow_tbl)(void *tbl);
> > 	void *(*dr_create_flow_action_dest_vport)(void *ns, uint32_t vport);
> > +	void *(*dr_create_flow_action_drop)();
> > 	void *(*dr_create_flow_tbl)(void *ns, uint32_t level);
> > 	int (*dr_destroy_flow_tbl)(void *tbl);
> > 	void *(*dr_create_ns)(struct ibv_context *ctx,
> > --
> > 1.8.3.1
> >
Shahaf Shuler April 18, 2019, 6:14 p.m. | #3
Thursday, April 18, 2019 4:48 PM, Ori Kam:
> Subject: RE: [PATCH v3 9/9] net/mlx5: add drop action to Direct Verbs E-
> Switch
> 
> Hi Shahaf,
> 
> Can you please fix it when you take it?

Yes took care.

> 
> Thanks,
> Ori
> 
> > -----Original Message-----
> > From: Yongseok Koh
> > Sent: Thursday, April 18, 2019 4:23 PM
> > To: Ori Kam <orika@mellanox.com>
> > Cc: Shahaf Shuler <shahafs@mellanox.com>; Matan Azrad
> > <matan@mellanox.com>; Slava Ovsiienko <viacheslavo@mellanox.com>;
> Moti
> > Haimovsky <motih@mellanox.com>; dev@dpdk.org
> > Subject: Re: [PATCH v3 9/9] net/mlx5: add drop action to Direct Verbs
> > E-Switch
> >
> > > On Apr 18, 2019, at 6:16 AM, Ori Kam <orika@mellanox.com> wrote:
> > >
> > > This commit adds support for drop action when creating E-Switch flow
> > > using DV.
> > >
> > > Signed-off-by: Ori Kam <orika@mellanox.com>
> > > Acked-by: Yongseok Koh <yskoh@mellanox.com>
> > > ---
> > > drivers/net/mlx5/mlx5.c         |  9 +++++++++
> > > drivers/net/mlx5/mlx5.h         |  1 +
> > > drivers/net/mlx5/mlx5_flow_dv.c | 22 ++++++++++++++--------
> > > drivers/net/mlx5/mlx5_glue.c    | 12 ++++++++++++
> > > drivers/net/mlx5/mlx5_glue.h    |  1 +
> > > 5 files changed, 37 insertions(+), 8 deletions(-)
> > >
> > > diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c index
> > > ff24e1d..65c69af 100644
> > > --- a/drivers/net/mlx5/mlx5.c
> > > +++ b/drivers/net/mlx5/mlx5.c
> > > @@ -357,6 +357,7 @@ struct mlx5_dev_spawn_data {
> > > 			goto error;
> > > 		}
> > > 		sh->fdb_ns = ns;
> > > +		sh->esw_drop_action = mlx5_glue-
> > >dr_create_flow_action_drop();
> > > 	}
> > > #endif
> > > 	sh->dv_refcnt++;
> > > @@ -377,6 +378,10 @@ struct mlx5_dev_spawn_data {
> > > 		mlx5_glue->dr_destroy_ns(sh->fdb_ns);
> > > 		sh->fdb_ns = NULL;
> > > 	}
> > > +	if (sh->esw_drop_action) {
> > > +		mlx5_glue->destroy_flow_action(sh->esw_drop_action);
> > > +		sh->esw_drop_action = NULL;
> > > +	}
> > > 	return err;
> > > #else
> > > 	(void)priv;
> > > @@ -417,6 +422,10 @@ struct mlx5_dev_spawn_data {
> > > 		mlx5_glue->dr_destroy_ns(sh->fdb_ns);
> > > 		sh->fdb_ns = NULL;
> > > 	}
> > > +	if (sh->esw_drop_action) {
> > > +		mlx5_glue->destroy_flow_action(sh->esw_drop_action);
> > > +		sh->esw_drop_action = NULL;
> > > +	}
> > > #endif
> > > 	pthread_mutex_destroy(&sh->dv_mutex);
> > > #else
> > > diff --git a/drivers/net/mlx5/mlx5.h b/drivers/net/mlx5/mlx5.h index
> > > 907d5c3..443625e 100644
> > > --- a/drivers/net/mlx5/mlx5.h
> > > +++ b/drivers/net/mlx5/mlx5.h
> > > @@ -276,6 +276,7 @@ struct mlx5_ibv_shared {
> > > 	/* RX Direct Rules tables. */
> > > 	void *tx_ns; /* TX Direct Rules name space handle. */
> > > 	struct mlx5_flow_tbl_resource tx_tbl[MLX5_MAX_TABLES];
> > > +	void *esw_drop_action; /* Pointer to DR E-Switch drop action. */
> > > 	/* TX Direct Rules tables/ */
> > > 	LIST_HEAD(matchers, mlx5_flow_dv_matcher) matchers;
> > > 	LIST_HEAD(encap_decap, mlx5_flow_dv_encap_decap_resource)
> > encaps_decaps;
> > > diff --git a/drivers/net/mlx5/mlx5_flow_dv.c
> > b/drivers/net/mlx5/mlx5_flow_dv.c
> > > index 5997182..4352d48 100644
> > > --- a/drivers/net/mlx5/mlx5_flow_dv.c
> > > +++ b/drivers/net/mlx5/mlx5_flow_dv.c
> > > @@ -4049,6 +4049,7 @@ struct field_modify_info modify_tcp[] = { {
> > > 	struct mlx5_flow_dv *dv;
> > > 	struct mlx5_flow *dev_flow;
> > > +	struct mlx5_priv *priv = dev->data->dev_private;
> > > 	int n;
> > > 	int err;
> > >
> > > @@ -4056,15 +4057,20 @@ struct field_modify_info modify_tcp[] = {
> > > 		dv = &dev_flow->dv;
> > > 		n = dv->actions_n;
> > > 		if (flow->actions & MLX5_FLOW_ACTION_DROP) {
> > > -			dv->hrxq = mlx5_hrxq_drop_new(dev);
> > > -			if (!dv->hrxq) {
> > > -				rte_flow_error_set
> > > -					(error, errno,
> > > -
> > RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL,
> > > -					 "cannot get drop hash queue");
> > > -				goto error;
> > > +			if (flow->transfer)
> > > +				dv->actions[n++] = priv->sh-
> >esw_drop_action;
> > > +			else {
> >
> > Please fix the coding style issue.
> > http://mails.dpdk.org/archives/test-report/2019-April/080992.html
> >
> > > +				dv->hrxq = mlx5_hrxq_drop_new(dev);
> > > +				if (!dv->hrxq) {
> > > +					rte_flow_error_set
> > > +						(error, errno,
> > > +
> > RTE_FLOW_ERROR_TYPE_UNSPECIFIED,
> > > +						 NULL,
> > > +						 "cannot get drop hash
> > queue");
> > > +					goto error;
> > > +				}
> > > +				dv->actions[n++] = dv->hrxq->action;
> > > 			}
> > > -			dv->actions[n++] = dv->hrxq->action;
> > > 		} else if (flow->actions &
> > > 			   (MLX5_FLOW_ACTION_QUEUE |
> > MLX5_FLOW_ACTION_RSS)) {
> > > 			struct mlx5_hrxq *hrxq;
> > > diff --git a/drivers/net/mlx5/mlx5_glue.c
> > > b/drivers/net/mlx5/mlx5_glue.c index 117190f..b32cd09c 100644
> > > --- a/drivers/net/mlx5/mlx5_glue.c
> > > +++ b/drivers/net/mlx5/mlx5_glue.c
> > > @@ -394,6 +394,16 @@
> > > }
> > >
> > > static void *
> > > +mlx5_glue_dr_create_flow_action_drop(void)
> > > +{
> > > +#ifdef HAVE_MLX5DV_DR_ESWITCH
> > > +	return mlx5dv_dr_create_action_drop(); #else
> > > +	return NULL;
> > > +#endif
> > > +}
> > > +
> > > +static void *
> > > mlx5_glue_dr_create_flow_tbl(void *ns, uint32_t level) { #ifdef
> > > HAVE_MLX5DV_DR @@ -861,6 +871,8 @@
> > > 		mlx5_glue_dr_create_flow_action_dest_flow_tbl,
> > > 	.dr_create_flow_action_dest_vport =
> > > 		mlx5_glue_dr_create_flow_action_dest_vport,
> > > +	.dr_create_flow_action_drop =
> > > +		mlx5_glue_dr_create_flow_action_drop,
> > > 	.dr_create_flow_tbl = mlx5_glue_dr_create_flow_tbl,
> > > 	.dr_destroy_flow_tbl = mlx5_glue_dr_destroy_flow_tbl,
> > > 	.dr_create_ns = mlx5_glue_dr_create_ns, diff --git
> > > a/drivers/net/mlx5/mlx5_glue.h b/drivers/net/mlx5/mlx5_glue.h index
> > > 26f5cb3..1d06583 100644
> > > --- a/drivers/net/mlx5/mlx5_glue.h
> > > +++ b/drivers/net/mlx5/mlx5_glue.h
> > > @@ -147,6 +147,7 @@ struct mlx5_glue {
> > > 	struct ibv_cq *(*cq_ex_to_cq)(struct ibv_cq_ex *cq);
> > > 	void *(*dr_create_flow_action_dest_flow_tbl)(void *tbl);
> > > 	void *(*dr_create_flow_action_dest_vport)(void *ns, uint32_t
> > > vport);
> > > +	void *(*dr_create_flow_action_drop)();
> > > 	void *(*dr_create_flow_tbl)(void *ns, uint32_t level);
> > > 	int (*dr_destroy_flow_tbl)(void *tbl);
> > > 	void *(*dr_create_ns)(struct ibv_context *ctx,
> > > --
> > > 1.8.3.1
> > >

Patch

diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c
index ff24e1d..65c69af 100644
--- a/drivers/net/mlx5/mlx5.c
+++ b/drivers/net/mlx5/mlx5.c
@@ -357,6 +357,7 @@  struct mlx5_dev_spawn_data {
 			goto error;
 		}
 		sh->fdb_ns = ns;
+		sh->esw_drop_action = mlx5_glue->dr_create_flow_action_drop();
 	}
 #endif
 	sh->dv_refcnt++;
@@ -377,6 +378,10 @@  struct mlx5_dev_spawn_data {
 		mlx5_glue->dr_destroy_ns(sh->fdb_ns);
 		sh->fdb_ns = NULL;
 	}
+	if (sh->esw_drop_action) {
+		mlx5_glue->destroy_flow_action(sh->esw_drop_action);
+		sh->esw_drop_action = NULL;
+	}
 	return err;
 #else
 	(void)priv;
@@ -417,6 +422,10 @@  struct mlx5_dev_spawn_data {
 		mlx5_glue->dr_destroy_ns(sh->fdb_ns);
 		sh->fdb_ns = NULL;
 	}
+	if (sh->esw_drop_action) {
+		mlx5_glue->destroy_flow_action(sh->esw_drop_action);
+		sh->esw_drop_action = NULL;
+	}
 #endif
 	pthread_mutex_destroy(&sh->dv_mutex);
 #else
diff --git a/drivers/net/mlx5/mlx5.h b/drivers/net/mlx5/mlx5.h
index 907d5c3..443625e 100644
--- a/drivers/net/mlx5/mlx5.h
+++ b/drivers/net/mlx5/mlx5.h
@@ -276,6 +276,7 @@  struct mlx5_ibv_shared {
 	/* RX Direct Rules tables. */
 	void *tx_ns; /* TX Direct Rules name space handle. */
 	struct mlx5_flow_tbl_resource tx_tbl[MLX5_MAX_TABLES];
+	void *esw_drop_action; /* Pointer to DR E-Switch drop action. */
 	/* TX Direct Rules tables/ */
 	LIST_HEAD(matchers, mlx5_flow_dv_matcher) matchers;
 	LIST_HEAD(encap_decap, mlx5_flow_dv_encap_decap_resource) encaps_decaps;
diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c
index 5997182..4352d48 100644
--- a/drivers/net/mlx5/mlx5_flow_dv.c
+++ b/drivers/net/mlx5/mlx5_flow_dv.c
@@ -4049,6 +4049,7 @@  struct field_modify_info modify_tcp[] = {
 {
 	struct mlx5_flow_dv *dv;
 	struct mlx5_flow *dev_flow;
+	struct mlx5_priv *priv = dev->data->dev_private;
 	int n;
 	int err;
 
@@ -4056,15 +4057,20 @@  struct field_modify_info modify_tcp[] = {
 		dv = &dev_flow->dv;
 		n = dv->actions_n;
 		if (flow->actions & MLX5_FLOW_ACTION_DROP) {
-			dv->hrxq = mlx5_hrxq_drop_new(dev);
-			if (!dv->hrxq) {
-				rte_flow_error_set
-					(error, errno,
-					 RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL,
-					 "cannot get drop hash queue");
-				goto error;
+			if (flow->transfer)
+				dv->actions[n++] = priv->sh->esw_drop_action;
+			else {
+				dv->hrxq = mlx5_hrxq_drop_new(dev);
+				if (!dv->hrxq) {
+					rte_flow_error_set
+						(error, errno,
+						 RTE_FLOW_ERROR_TYPE_UNSPECIFIED,
+						 NULL,
+						 "cannot get drop hash queue");
+					goto error;
+				}
+				dv->actions[n++] = dv->hrxq->action;
 			}
-			dv->actions[n++] = dv->hrxq->action;
 		} else if (flow->actions &
 			   (MLX5_FLOW_ACTION_QUEUE | MLX5_FLOW_ACTION_RSS)) {
 			struct mlx5_hrxq *hrxq;
diff --git a/drivers/net/mlx5/mlx5_glue.c b/drivers/net/mlx5/mlx5_glue.c
index 117190f..b32cd09c 100644
--- a/drivers/net/mlx5/mlx5_glue.c
+++ b/drivers/net/mlx5/mlx5_glue.c
@@ -394,6 +394,16 @@ 
 }
 
 static void *
+mlx5_glue_dr_create_flow_action_drop(void)
+{
+#ifdef HAVE_MLX5DV_DR_ESWITCH
+	return mlx5dv_dr_create_action_drop();
+#else
+	return NULL;
+#endif
+}
+
+static void *
 mlx5_glue_dr_create_flow_tbl(void *ns, uint32_t level)
 {
 #ifdef HAVE_MLX5DV_DR
@@ -861,6 +871,8 @@ 
 		mlx5_glue_dr_create_flow_action_dest_flow_tbl,
 	.dr_create_flow_action_dest_vport =
 		mlx5_glue_dr_create_flow_action_dest_vport,
+	.dr_create_flow_action_drop =
+		mlx5_glue_dr_create_flow_action_drop,
 	.dr_create_flow_tbl = mlx5_glue_dr_create_flow_tbl,
 	.dr_destroy_flow_tbl = mlx5_glue_dr_destroy_flow_tbl,
 	.dr_create_ns = mlx5_glue_dr_create_ns,
diff --git a/drivers/net/mlx5/mlx5_glue.h b/drivers/net/mlx5/mlx5_glue.h
index 26f5cb3..1d06583 100644
--- a/drivers/net/mlx5/mlx5_glue.h
+++ b/drivers/net/mlx5/mlx5_glue.h
@@ -147,6 +147,7 @@  struct mlx5_glue {
 	struct ibv_cq *(*cq_ex_to_cq)(struct ibv_cq_ex *cq);
 	void *(*dr_create_flow_action_dest_flow_tbl)(void *tbl);
 	void *(*dr_create_flow_action_dest_vport)(void *ns, uint32_t vport);
+	void *(*dr_create_flow_action_drop)();
 	void *(*dr_create_flow_tbl)(void *ns, uint32_t level);
 	int (*dr_destroy_flow_tbl)(void *tbl);
 	void *(*dr_create_ns)(struct ibv_context *ctx,