diff mbox series

[net-next,ct-offload,v2,06/13] net/mlx5: E-Switch, Introduce global tables

Message ID 1583676662-15180-7-git-send-email-paulb@mellanox.com
State Changes Requested
Delegated to: David Miller
Headers show
Series Introduce connection tracking offload | expand

Commit Message

Paul Blakey March 8, 2020, 2:10 p.m. UTC
Currently, flow tables are automatically connected according to their
<chain,prio,level> tuple.

Introduce global tables which are flow tables that are detached from the
eswitch chains processing, and will be connected by explicitly referencing
them from multiple chains.

Add this new table type, and allow connecting them by refenece.

Signed-off-by: Paul Blakey <paulb@mellanox.com>
Reviewed-by: Oz Shlomo <ozsh@mellanox.com>
---
 drivers/net/ethernet/mellanox/mlx5/core/eswitch.h  |  2 ++
 .../ethernet/mellanox/mlx5/core/eswitch_offloads.c | 23 ++++++++++++-----
 .../mellanox/mlx5/core/eswitch_offloads_chains.c   | 30 ++++++++++++++++++++++
 .../mellanox/mlx5/core/eswitch_offloads_chains.h   |  6 +++++
 4 files changed, 55 insertions(+), 6 deletions(-)

Comments

Marcelo Ricardo Leitner March 9, 2020, 10:40 p.m. UTC | #1
On Sun, Mar 08, 2020 at 04:10:55PM +0200, Paul Blakey wrote:
> --- a/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c
> +++ b/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c
> @@ -149,7 +149,12 @@ struct mlx5_flow_handle *
>  	if (flow_act.action & MLX5_FLOW_CONTEXT_ACTION_FWD_DEST) {
>  		struct mlx5_flow_table *ft;
>  
> -		if (attr->flags & MLX5_ESW_ATTR_FLAG_SLOW_PATH) {
> +		if (attr->dest_ft) {
> +			flow_act.flags |= FLOW_ACT_IGNORE_FLOW_LEVEL;
> +			dest[i].type = MLX5_FLOW_DESTINATION_TYPE_FLOW_TABLE;
> +			dest[i].ft = attr->dest_ft;
> +			i++;
> +		} else if (attr->flags & MLX5_ESW_ATTR_FLAG_SLOW_PATH) {
>  			flow_act.flags |= FLOW_ACT_IGNORE_FLOW_LEVEL;
>  			dest[i].type = MLX5_FLOW_DESTINATION_TYPE_FLOW_TABLE;
>  			dest[i].ft = mlx5_esw_chains_get_tc_end_ft(esw);
> @@ -202,8 +207,11 @@ struct mlx5_flow_handle *
>  	if (flow_act.action & MLX5_FLOW_CONTEXT_ACTION_MOD_HDR)
>  		flow_act.modify_hdr = attr->modify_hdr;
>  
> -	fdb = mlx5_esw_chains_get_table(esw, attr->chain, attr->prio,
> -					!!split);
> +	if (attr->chain || attr->prio)
> +		fdb = mlx5_esw_chains_get_table(esw, attr->chain, attr->prio,
> +						!!split);
> +	else
> +		fdb = attr->fdb;

I'm not sure how these/mlx5 patches are supposed to propagate to
net-next, but AFAICT here it conflicts with 
96e326878fa5 ("net/mlx5e: Eswitch, Use per vport tables for mirroring")

>  	if (IS_ERR(fdb)) {
>  		rule = ERR_CAST(fdb);
>  		goto err_esw_get;
Saeed Mahameed March 10, 2020, 1:54 a.m. UTC | #2
On Mon, 2020-03-09 at 19:40 -0300, Marcelo Ricardo Leitner wrote:
> On Sun, Mar 08, 2020 at 04:10:55PM +0200, Paul Blakey wrote:
> > --- a/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c
> > +++ b/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c
> > @@ -149,7 +149,12 @@ struct mlx5_flow_handle *
> >  	if (flow_act.action & MLX5_FLOW_CONTEXT_ACTION_FWD_DEST) {
> >  		struct mlx5_flow_table *ft;
> >  
> > -		if (attr->flags & MLX5_ESW_ATTR_FLAG_SLOW_PATH) {
> > +		if (attr->dest_ft) {
> > +			flow_act.flags |= FLOW_ACT_IGNORE_FLOW_LEVEL;
> > +			dest[i].type =
> > MLX5_FLOW_DESTINATION_TYPE_FLOW_TABLE;
> > +			dest[i].ft = attr->dest_ft;
> > +			i++;
> > +		} else if (attr->flags & MLX5_ESW_ATTR_FLAG_SLOW_PATH)
> > {
> >  			flow_act.flags |= FLOW_ACT_IGNORE_FLOW_LEVEL;
> >  			dest[i].type =
> > MLX5_FLOW_DESTINATION_TYPE_FLOW_TABLE;
> >  			dest[i].ft =
> > mlx5_esw_chains_get_tc_end_ft(esw);
> > @@ -202,8 +207,11 @@ struct mlx5_flow_handle *
> >  	if (flow_act.action & MLX5_FLOW_CONTEXT_ACTION_MOD_HDR)
> >  		flow_act.modify_hdr = attr->modify_hdr;
> >  
> > -	fdb = mlx5_esw_chains_get_table(esw, attr->chain, attr->prio,
> > -					!!split);
> > +	if (attr->chain || attr->prio)
> > +		fdb = mlx5_esw_chains_get_table(esw, attr->chain, attr-
> > >prio,
> > +						!!split);
> > +	else
> > +		fdb = attr->fdb;
> 
> I'm not sure how these/mlx5 patches are supposed to propagate to
> net-next, but AFAICT here it conflicts with 
> 96e326878fa5 ("net/mlx5e: Eswitch, Use per vport tables for
> mirroring")
> 

Paul, as we agreed, this should have been rebased on top
latest net-next + ct-offloads from
git://git.kernel.org/pub/scm/linux/kernel/git/saeed/linux.git

Pleas rebase V3 and once the review is done on this series, i will ask
Dave to pull 
ct-offloads from
git://git.kernel.org/pub/scm/linux/kernel/git/saeed/linux.git

which was already reviewed and acked on netdev mailing list.

Thanks,
Saeed.
Paul Blakey March 10, 2020, 7:54 a.m. UTC | #3
On 3/10/2020 3:54 AM, Saeed Mahameed wrote:
> On Mon, 2020-03-09 at 19:40 -0300, Marcelo Ricardo Leitner wrote:
>> On Sun, Mar 08, 2020 at 04:10:55PM +0200, Paul Blakey wrote:
>>> --- a/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c
>>> +++ b/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c
>>> @@ -149,7 +149,12 @@ struct mlx5_flow_handle *
>>>  	if (flow_act.action & MLX5_FLOW_CONTEXT_ACTION_FWD_DEST) {
>>>  		struct mlx5_flow_table *ft;
>>>  
>>> -		if (attr->flags & MLX5_ESW_ATTR_FLAG_SLOW_PATH) {
>>> +		if (attr->dest_ft) {
>>> +			flow_act.flags |= FLOW_ACT_IGNORE_FLOW_LEVEL;
>>> +			dest[i].type =
>>> MLX5_FLOW_DESTINATION_TYPE_FLOW_TABLE;
>>> +			dest[i].ft = attr->dest_ft;
>>> +			i++;
>>> +		} else if (attr->flags & MLX5_ESW_ATTR_FLAG_SLOW_PATH)
>>> {
>>>  			flow_act.flags |= FLOW_ACT_IGNORE_FLOW_LEVEL;
>>>  			dest[i].type =
>>> MLX5_FLOW_DESTINATION_TYPE_FLOW_TABLE;
>>>  			dest[i].ft =
>>> mlx5_esw_chains_get_tc_end_ft(esw);
>>> @@ -202,8 +207,11 @@ struct mlx5_flow_handle *
>>>  	if (flow_act.action & MLX5_FLOW_CONTEXT_ACTION_MOD_HDR)
>>>  		flow_act.modify_hdr = attr->modify_hdr;
>>>  
>>> -	fdb = mlx5_esw_chains_get_table(esw, attr->chain, attr->prio,
>>> -					!!split);
>>> +	if (attr->chain || attr->prio)
>>> +		fdb = mlx5_esw_chains_get_table(esw, attr->chain, attr-
>>>> prio,
>>> +						!!split);
>>> +	else
>>> +		fdb = attr->fdb;
>> I'm not sure how these/mlx5 patches are supposed to propagate to
>> net-next, but AFAICT here it conflicts with 
>> 96e326878fa5 ("net/mlx5e: Eswitch, Use per vport tables for
>> mirroring")
>>
> Paul, as we agreed, this should have been rebased on top
> latest net-next + ct-offloads from
> git://git.kernel.org/pub/scm/linux/kernel/git/saeed/linux.git
>
> Pleas rebase V3 and once the review is done on this series, i will ask
> Dave to pull 
> ct-offloads from
> git://git.kernel.org/pub/scm/linux/kernel/git/saeed/linux.git
>
> which was already reviewed and acked on netdev mailing list.
will do.
>
> Thanks,
> Saeed.
>
diff mbox series

Patch

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/eswitch.h b/drivers/net/ethernet/mellanox/mlx5/core/eswitch.h
index e7dd2ca..3f644c2 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/eswitch.h
+++ b/drivers/net/ethernet/mellanox/mlx5/core/eswitch.h
@@ -409,6 +409,8 @@  struct mlx5_esw_flow_attr {
 	u16	prio;
 	u32	dest_chain;
 	u32	flags;
+	struct mlx5_flow_table *fdb;
+	struct mlx5_flow_table *dest_ft;
 	struct mlx5e_tc_flow_parse_attr *parse_attr;
 };
 
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c b/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c
index e4bd53e..a867d7f 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c
@@ -149,7 +149,12 @@  struct mlx5_flow_handle *
 	if (flow_act.action & MLX5_FLOW_CONTEXT_ACTION_FWD_DEST) {
 		struct mlx5_flow_table *ft;
 
-		if (attr->flags & MLX5_ESW_ATTR_FLAG_SLOW_PATH) {
+		if (attr->dest_ft) {
+			flow_act.flags |= FLOW_ACT_IGNORE_FLOW_LEVEL;
+			dest[i].type = MLX5_FLOW_DESTINATION_TYPE_FLOW_TABLE;
+			dest[i].ft = attr->dest_ft;
+			i++;
+		} else if (attr->flags & MLX5_ESW_ATTR_FLAG_SLOW_PATH) {
 			flow_act.flags |= FLOW_ACT_IGNORE_FLOW_LEVEL;
 			dest[i].type = MLX5_FLOW_DESTINATION_TYPE_FLOW_TABLE;
 			dest[i].ft = mlx5_esw_chains_get_tc_end_ft(esw);
@@ -202,8 +207,11 @@  struct mlx5_flow_handle *
 	if (flow_act.action & MLX5_FLOW_CONTEXT_ACTION_MOD_HDR)
 		flow_act.modify_hdr = attr->modify_hdr;
 
-	fdb = mlx5_esw_chains_get_table(esw, attr->chain, attr->prio,
-					!!split);
+	if (attr->chain || attr->prio)
+		fdb = mlx5_esw_chains_get_table(esw, attr->chain, attr->prio,
+						!!split);
+	else
+		fdb = attr->fdb;
 	if (IS_ERR(fdb)) {
 		rule = ERR_CAST(fdb);
 		goto err_esw_get;
@@ -222,7 +230,9 @@  struct mlx5_flow_handle *
 	return rule;
 
 err_add_rule:
-	mlx5_esw_chains_put_table(esw, attr->chain, attr->prio, !!split);
+	if (attr->chain || attr->prio)
+		mlx5_esw_chains_put_table(esw, attr->chain, attr->prio,
+					  !!split);
 err_esw_get:
 	if (!(attr->flags & MLX5_ESW_ATTR_FLAG_SLOW_PATH) && attr->dest_chain)
 		mlx5_esw_chains_put_table(esw, attr->dest_chain, 1, 0);
@@ -316,8 +326,9 @@  struct mlx5_flow_handle *
 		mlx5_esw_chains_put_table(esw, attr->chain, attr->prio, 1);
 		mlx5_esw_chains_put_table(esw, attr->chain, attr->prio, 0);
 	} else {
-		mlx5_esw_chains_put_table(esw, attr->chain, attr->prio,
-					  !!split);
+		if (attr->chain || attr->prio)
+			mlx5_esw_chains_put_table(esw, attr->chain,
+						  attr->prio, !!split);
 		if (attr->dest_chain)
 			mlx5_esw_chains_put_table(esw, attr->dest_chain, 1, 0);
 	}
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads_chains.c b/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads_chains.c
index b139a97..bba0cec 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads_chains.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads_chains.c
@@ -716,6 +716,36 @@  struct mlx5_flow_table *
 	return tc_end_fdb(esw);
 }
 
+struct mlx5_flow_table *
+mlx5_esw_chains_create_global_table(struct mlx5_eswitch *esw)
+{
+	int chain, prio, level, err;
+
+	if (!fdb_ignore_flow_level_supported(esw)) {
+		err = -EOPNOTSUPP;
+
+		esw_warn(esw->dev,
+			 "Couldn't create global flow table, ignore_flow_level not supported.");
+		goto err_ignore;
+	}
+
+	chain = mlx5_esw_chains_get_chain_range(esw),
+	prio = mlx5_esw_chains_get_prio_range(esw);
+	level = mlx5_esw_chains_get_level_range(esw);
+
+	return mlx5_esw_chains_create_fdb_table(esw, chain, prio, level);
+
+err_ignore:
+	return ERR_PTR(err);
+}
+
+void
+mlx5_esw_chains_destroy_global_table(struct mlx5_eswitch *esw,
+				     struct mlx5_flow_table *ft)
+{
+	mlx5_esw_chains_destroy_fdb_table(esw, ft);
+}
+
 static int
 mlx5_esw_chains_init(struct mlx5_eswitch *esw)
 {
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads_chains.h b/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads_chains.h
index da45e49..01cbdf8 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads_chains.h
+++ b/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads_chains.h
@@ -23,6 +23,12 @@  struct mlx5_flow_table *
 struct mlx5_flow_table *
 mlx5_esw_chains_get_tc_end_ft(struct mlx5_eswitch *esw);
 
+struct mlx5_flow_table *
+mlx5_esw_chains_create_global_table(struct mlx5_eswitch *esw);
+void
+mlx5_esw_chains_destroy_global_table(struct mlx5_eswitch *esw,
+				     struct mlx5_flow_table *ft);
+
 int mlx5_esw_chains_create(struct mlx5_eswitch *esw);
 void mlx5_esw_chains_destroy(struct mlx5_eswitch *esw);