diff mbox series

[mlx5-next,12/15] net/mlx5: E-Switch, Enable vport metadata matching if firmware supports it

Message ID 20190617192247.25107-13-saeedm@mellanox.com (mailing list archive)
State Superseded
Headers show
Series Mellanox, mlx5 vport metadata matching | expand

Commit Message

Saeed Mahameed June 17, 2019, 7:23 p.m. UTC
From: Jianbo Liu <jianbol@mellanox.com>

As the ingress ACL rules save vhca id and vport number to packet's
metadata REG_C_0, and the metadata matching for the rules in both fast
path and slow path are all added, enable this feature if supported.

Signed-off-by: Jianbo Liu <jianbol@mellanox.com>
Reviewed-by: Roi Dayan <roid@mellanox.com>
Reviewed-by: Mark Bloch <markb@mellanox.com>
Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
---
 .../ethernet/mellanox/mlx5/core/eswitch_offloads.c  | 13 +++++++++++++
 1 file changed, 13 insertions(+)

Comments

Parav Pandit June 18, 2019, 10:24 a.m. UTC | #1
> -----Original Message-----
> From: linux-rdma-owner@vger.kernel.org <linux-rdma-
> owner@vger.kernel.org> On Behalf Of Saeed Mahameed
> Sent: Tuesday, June 18, 2019 12:54 AM
> To: Saeed Mahameed <saeedm@mellanox.com>; Leon Romanovsky
> <leonro@mellanox.com>
> Cc: netdev@vger.kernel.org; linux-rdma@vger.kernel.org; Jianbo Liu
> <jianbol@mellanox.com>; Roi Dayan <roid@mellanox.com>; Mark Bloch
> <markb@mellanox.com>
> Subject: [PATCH mlx5-next 12/15] net/mlx5: E-Switch, Enable vport metadata
> matching if firmware supports it
> 
> From: Jianbo Liu <jianbol@mellanox.com>
> 
> As the ingress ACL rules save vhca id and vport number to packet's metadata
> REG_C_0, and the metadata matching for the rules in both fast path and slow
> path are all added, enable this feature if supported.
> 
> Signed-off-by: Jianbo Liu <jianbol@mellanox.com>
> Reviewed-by: Roi Dayan <roid@mellanox.com>
> Reviewed-by: Mark Bloch <markb@mellanox.com>
> Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
> ---
>  .../ethernet/mellanox/mlx5/core/eswitch_offloads.c  | 13 +++++++++++++
>  1 file changed, 13 insertions(+)
> 
> diff --git a/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c
> b/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c
> index 363517e29d4c..5124219a31de 100644
> --- a/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c
> +++ b/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c
> @@ -1906,12 +1906,25 @@ static int
> esw_vport_ingress_common_config(struct mlx5_eswitch *esw,
>  	return err;
>  }
> 
> +static int esw_check_vport_match_metadata_supported(struct mlx5_eswitch
> +*esw) {
> +	return (MLX5_CAP_ESW_FLOWTABLE(esw->dev,
> fdb_to_vport_reg_c_id) &
> +		MLX5_FDB_TO_VPORT_REG_C_0) &&
> +	       MLX5_CAP_ESW_FLOWTABLE(esw->dev, flow_source) &&
> +	       MLX5_CAP_ESW(esw->dev, esw_uplink_ingress_acl) &&
> +	       !mlx5_core_is_ecpf_esw_manager(esw->dev) &&
> +	       !mlx5_ecpf_vport_exists(esw->dev);
> +}
> +
struct mlx5_eswitch* should be const.
return type should be bool.
Leon Romanovsky June 18, 2019, 10:35 a.m. UTC | #2
On Tue, Jun 18, 2019 at 10:24:49AM +0000, Parav Pandit wrote:
>
>
> > -----Original Message-----
> > From: linux-rdma-owner@vger.kernel.org <linux-rdma-
> > owner@vger.kernel.org> On Behalf Of Saeed Mahameed
> > Sent: Tuesday, June 18, 2019 12:54 AM
> > To: Saeed Mahameed <saeedm@mellanox.com>; Leon Romanovsky
> > <leonro@mellanox.com>
> > Cc: netdev@vger.kernel.org; linux-rdma@vger.kernel.org; Jianbo Liu
> > <jianbol@mellanox.com>; Roi Dayan <roid@mellanox.com>; Mark Bloch
> > <markb@mellanox.com>
> > Subject: [PATCH mlx5-next 12/15] net/mlx5: E-Switch, Enable vport metadata
> > matching if firmware supports it
> >
> > From: Jianbo Liu <jianbol@mellanox.com>
> >
> > As the ingress ACL rules save vhca id and vport number to packet's metadata
> > REG_C_0, and the metadata matching for the rules in both fast path and slow
> > path are all added, enable this feature if supported.
> >
> > Signed-off-by: Jianbo Liu <jianbol@mellanox.com>
> > Reviewed-by: Roi Dayan <roid@mellanox.com>
> > Reviewed-by: Mark Bloch <markb@mellanox.com>
> > Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
> > ---
> >  .../ethernet/mellanox/mlx5/core/eswitch_offloads.c  | 13 +++++++++++++
> >  1 file changed, 13 insertions(+)
> >
> > diff --git a/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c
> > b/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c
> > index 363517e29d4c..5124219a31de 100644
> > --- a/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c
> > +++ b/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c
> > @@ -1906,12 +1906,25 @@ static int
> > esw_vport_ingress_common_config(struct mlx5_eswitch *esw,
> >  	return err;
> >  }
> >
> > +static int esw_check_vport_match_metadata_supported(struct mlx5_eswitch
> > +*esw) {
> > +	return (MLX5_CAP_ESW_FLOWTABLE(esw->dev,
> > fdb_to_vport_reg_c_id) &
> > +		MLX5_FDB_TO_VPORT_REG_C_0) &&
> > +	       MLX5_CAP_ESW_FLOWTABLE(esw->dev, flow_source) &&
> > +	       MLX5_CAP_ESW(esw->dev, esw_uplink_ingress_acl) &&
> > +	       !mlx5_core_is_ecpf_esw_manager(esw->dev) &&
> > +	       !mlx5_ecpf_vport_exists(esw->dev);
> > +}
> > +
> struct mlx5_eswitch* should be const.
> return type should be bool.

It is also completely indigestible and should be break into peaces to
make it readable.

Thanks
diff mbox series

Patch

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c b/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c
index 363517e29d4c..5124219a31de 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c
@@ -1906,12 +1906,25 @@  static int esw_vport_ingress_common_config(struct mlx5_eswitch *esw,
 	return err;
 }
 
+static int esw_check_vport_match_metadata_supported(struct mlx5_eswitch *esw)
+{
+	return (MLX5_CAP_ESW_FLOWTABLE(esw->dev, fdb_to_vport_reg_c_id) &
+		MLX5_FDB_TO_VPORT_REG_C_0) &&
+	       MLX5_CAP_ESW_FLOWTABLE(esw->dev, flow_source) &&
+	       MLX5_CAP_ESW(esw->dev, esw_uplink_ingress_acl) &&
+	       !mlx5_core_is_ecpf_esw_manager(esw->dev) &&
+	       !mlx5_ecpf_vport_exists(esw->dev);
+}
+
 static int esw_create_offloads_acl_tables(struct mlx5_eswitch *esw)
 {
 	struct mlx5_vport *vport;
 	int i, j;
 	int err;
 
+	if (esw_check_vport_match_metadata_supported(esw))
+		esw->flags |= MLX5_ESWITCH_VPORT_MATCH_METADATA;
+
 	mlx5_esw_for_all_vports(esw, i, vport) {
 		err = esw_vport_ingress_common_config(esw, vport);
 		if (err)