net/mlx5: E-switch, Create per vport table based on devlink encap mode
authorChris Mi <cmi@nvidia.com>
Fri, 10 Mar 2023 09:06:48 +0000 (11:06 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 11 May 2023 14:03:25 +0000 (23:03 +0900)
[ Upstream commit fd745f4c0abe41ebb09d11bf622b054a0f3e7b49 ]

Currently when creating per vport table, create flags are hardcoded.
Devlink encap mode is set based on user input and HW capability.
Create per vport table based on devlink encap mode.

Fixes: c796bb7cd230 ("net/mlx5: E-switch, Generalize per vport table API")
Signed-off-by: Chris Mi <cmi@nvidia.com>
Reviewed-by: Roi Dayan <roid@nvidia.com>
Reviewed-by: Maor Dickman <maord@nvidia.com>
Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/net/ethernet/mellanox/mlx5/core/en/tc/sample.c
drivers/net/ethernet/mellanox/mlx5/core/esw/vporttbl.c
drivers/net/ethernet/mellanox/mlx5/core/eswitch.h
drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c

index f2c2c752bd1c345849d68245013feee7c3a4a2f9..c57b097275241ef4b266d3232feaab88d178f533 100644 (file)
 
 #define MLX5_ESW_VPORT_TBL_SIZE_SAMPLE (64 * 1024)
 
-static const struct esw_vport_tbl_namespace mlx5_esw_vport_tbl_sample_ns = {
+static struct esw_vport_tbl_namespace mlx5_esw_vport_tbl_sample_ns = {
        .max_fte = MLX5_ESW_VPORT_TBL_SIZE_SAMPLE,
        .max_num_groups = 0,    /* default num of groups */
-       .flags = MLX5_FLOW_TABLE_TUNNEL_EN_REFORMAT | MLX5_FLOW_TABLE_TUNNEL_EN_DECAP,
+       .flags = 0,
 };
 
 struct mlx5e_tc_psample {
index 9e72118f2e4c0cf4b4ea227b93aab40bbd407c19..749c3957a1280ab2c2f3b46ae97ebed7f96c8c1e 100644 (file)
@@ -11,7 +11,7 @@ struct mlx5_vport_key {
        u16 prio;
        u16 vport;
        u16 vhca_id;
-       const struct esw_vport_tbl_namespace *vport_ns;
+       struct esw_vport_tbl_namespace *vport_ns;
 } __packed;
 
 struct mlx5_vport_table {
@@ -21,6 +21,14 @@ struct mlx5_vport_table {
        struct mlx5_vport_key key;
 };
 
+static void
+esw_vport_tbl_init(struct mlx5_eswitch *esw, struct esw_vport_tbl_namespace *ns)
+{
+       if (esw->offloads.encap != DEVLINK_ESWITCH_ENCAP_MODE_NONE)
+               ns->flags |= (MLX5_FLOW_TABLE_TUNNEL_EN_REFORMAT |
+                             MLX5_FLOW_TABLE_TUNNEL_EN_DECAP);
+}
+
 static struct mlx5_flow_table *
 esw_vport_tbl_create(struct mlx5_eswitch *esw, struct mlx5_flow_namespace *ns,
                     const struct esw_vport_tbl_namespace *vport_ns)
@@ -80,6 +88,7 @@ mlx5_esw_vporttbl_get(struct mlx5_eswitch *esw, struct mlx5_vport_tbl_attr *attr
        u32 hkey;
 
        mutex_lock(&esw->fdb_table.offloads.vports.lock);
+       esw_vport_tbl_init(esw, attr->vport_ns);
        hkey = flow_attr_to_vport_key(esw, attr, &skey);
        e = esw_vport_tbl_lookup(esw, &skey, hkey);
        if (e) {
@@ -127,6 +136,7 @@ mlx5_esw_vporttbl_put(struct mlx5_eswitch *esw, struct mlx5_vport_tbl_attr *attr
        u32 hkey;
 
        mutex_lock(&esw->fdb_table.offloads.vports.lock);
+       esw_vport_tbl_init(esw, attr->vport_ns);
        hkey = flow_attr_to_vport_key(esw, attr, &key);
        e = esw_vport_tbl_lookup(esw, &key, hkey);
        if (!e || --e->num_rules)
index 5db76af35d3f537cf724bbb085cc16240e7dbd61..6e6e0864063f1e9879a8834c87fdad1f660c622f 100644 (file)
@@ -668,7 +668,7 @@ struct mlx5_vport_tbl_attr {
        u32 chain;
        u16 prio;
        u16 vport;
-       const struct esw_vport_tbl_namespace *vport_ns;
+       struct esw_vport_tbl_namespace *vport_ns;
 };
 
 struct mlx5_flow_table *
index 64e5b9f29206e156bb27fe66dd20b879fb746af0..ac8cf1b93e46a04229bf0171b92db3c209c83d67 100644 (file)
@@ -72,7 +72,7 @@
 
 #define MLX5_ESW_FT_OFFLOADS_DROP_RULE (1)
 
-static const struct esw_vport_tbl_namespace mlx5_esw_vport_tbl_mirror_ns = {
+static struct esw_vport_tbl_namespace mlx5_esw_vport_tbl_mirror_ns = {
        .max_fte = MLX5_ESW_VPORT_TBL_SIZE,
        .max_num_groups = MLX5_ESW_VPORT_TBL_NUM_GROUPS,
        .flags = 0,