Skip to content

Commit fd745f4

Browse files
Chris MiSaeed Mahameed
authored andcommitted
net/mlx5: E-switch, Create per vport table based on devlink encap mode
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: c796bb7 ("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>
1 parent 8ac04a2 commit fd745f4

4 files changed

Lines changed: 15 additions & 5 deletions

File tree

drivers/net/ethernet/mellanox/mlx5/core/en/tc/sample.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@
1414

1515
#define MLX5_ESW_VPORT_TBL_SIZE_SAMPLE (64 * 1024)
1616

17-
static const struct esw_vport_tbl_namespace mlx5_esw_vport_tbl_sample_ns = {
17+
static struct esw_vport_tbl_namespace mlx5_esw_vport_tbl_sample_ns = {
1818
.max_fte = MLX5_ESW_VPORT_TBL_SIZE_SAMPLE,
1919
.max_num_groups = 0, /* default num of groups */
20-
.flags = MLX5_FLOW_TABLE_TUNNEL_EN_REFORMAT | MLX5_FLOW_TABLE_TUNNEL_EN_DECAP,
20+
.flags = 0,
2121
};
2222

2323
struct mlx5e_tc_psample {

drivers/net/ethernet/mellanox/mlx5/core/esw/vporttbl.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ struct mlx5_vport_key {
1111
u16 prio;
1212
u16 vport;
1313
u16 vhca_id;
14-
const struct esw_vport_tbl_namespace *vport_ns;
14+
struct esw_vport_tbl_namespace *vport_ns;
1515
} __packed;
1616

1717
struct mlx5_vport_table {
@@ -21,6 +21,14 @@ struct mlx5_vport_table {
2121
struct mlx5_vport_key key;
2222
};
2323

24+
static void
25+
esw_vport_tbl_init(struct mlx5_eswitch *esw, struct esw_vport_tbl_namespace *ns)
26+
{
27+
if (esw->offloads.encap != DEVLINK_ESWITCH_ENCAP_MODE_NONE)
28+
ns->flags |= (MLX5_FLOW_TABLE_TUNNEL_EN_REFORMAT |
29+
MLX5_FLOW_TABLE_TUNNEL_EN_DECAP);
30+
}
31+
2432
static struct mlx5_flow_table *
2533
esw_vport_tbl_create(struct mlx5_eswitch *esw, struct mlx5_flow_namespace *ns,
2634
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
8088
u32 hkey;
8189

8290
mutex_lock(&esw->fdb_table.offloads.vports.lock);
91+
esw_vport_tbl_init(esw, attr->vport_ns);
8392
hkey = flow_attr_to_vport_key(esw, attr, &skey);
8493
e = esw_vport_tbl_lookup(esw, &skey, hkey);
8594
if (e) {
@@ -127,6 +136,7 @@ mlx5_esw_vporttbl_put(struct mlx5_eswitch *esw, struct mlx5_vport_tbl_attr *attr
127136
u32 hkey;
128137

129138
mutex_lock(&esw->fdb_table.offloads.vports.lock);
139+
esw_vport_tbl_init(esw, attr->vport_ns);
130140
hkey = flow_attr_to_vport_key(esw, attr, &key);
131141
e = esw_vport_tbl_lookup(esw, &key, hkey);
132142
if (!e || --e->num_rules)

drivers/net/ethernet/mellanox/mlx5/core/eswitch.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -674,7 +674,7 @@ struct mlx5_vport_tbl_attr {
674674
u32 chain;
675675
u16 prio;
676676
u16 vport;
677-
const struct esw_vport_tbl_namespace *vport_ns;
677+
struct esw_vport_tbl_namespace *vport_ns;
678678
};
679679

680680
struct mlx5_flow_table *

drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@
7373

7474
#define MLX5_ESW_FT_OFFLOADS_DROP_RULE (1)
7575

76-
static const struct esw_vport_tbl_namespace mlx5_esw_vport_tbl_mirror_ns = {
76+
static struct esw_vport_tbl_namespace mlx5_esw_vport_tbl_mirror_ns = {
7777
.max_fte = MLX5_ESW_VPORT_TBL_SIZE,
7878
.max_num_groups = MLX5_ESW_VPORT_TBL_NUM_GROUPS,
7979
.flags = 0,

0 commit comments

Comments
 (0)