Commit fd745f4c authored by Chris Mi's avatar Chris Mi Committed by Saeed Mahameed

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: c796bb7c ("net/mlx5: E-switch, Generalize per vport table API")
Signed-off-by: default avatarChris Mi <cmi@nvidia.com>
Reviewed-by: default avatarRoi Dayan <roid@nvidia.com>
Reviewed-by: default avatarMaor Dickman <maord@nvidia.com>
Signed-off-by: default avatarSaeed Mahameed <saeedm@nvidia.com>
parent 8ac04a28
...@@ -14,10 +14,10 @@ ...@@ -14,10 +14,10 @@
#define MLX5_ESW_VPORT_TBL_SIZE_SAMPLE (64 * 1024) #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_fte = MLX5_ESW_VPORT_TBL_SIZE_SAMPLE,
.max_num_groups = 0, /* default num of groups */ .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 { struct mlx5e_tc_psample {
......
...@@ -11,7 +11,7 @@ struct mlx5_vport_key { ...@@ -11,7 +11,7 @@ struct mlx5_vport_key {
u16 prio; u16 prio;
u16 vport; u16 vport;
u16 vhca_id; u16 vhca_id;
const struct esw_vport_tbl_namespace *vport_ns; struct esw_vport_tbl_namespace *vport_ns;
} __packed; } __packed;
struct mlx5_vport_table { struct mlx5_vport_table {
...@@ -21,6 +21,14 @@ struct mlx5_vport_table { ...@@ -21,6 +21,14 @@ struct mlx5_vport_table {
struct mlx5_vport_key key; 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 * static struct mlx5_flow_table *
esw_vport_tbl_create(struct mlx5_eswitch *esw, struct mlx5_flow_namespace *ns, esw_vport_tbl_create(struct mlx5_eswitch *esw, struct mlx5_flow_namespace *ns,
const struct esw_vport_tbl_namespace *vport_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 ...@@ -80,6 +88,7 @@ mlx5_esw_vporttbl_get(struct mlx5_eswitch *esw, struct mlx5_vport_tbl_attr *attr
u32 hkey; u32 hkey;
mutex_lock(&esw->fdb_table.offloads.vports.lock); 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); hkey = flow_attr_to_vport_key(esw, attr, &skey);
e = esw_vport_tbl_lookup(esw, &skey, hkey); e = esw_vport_tbl_lookup(esw, &skey, hkey);
if (e) { if (e) {
...@@ -127,6 +136,7 @@ mlx5_esw_vporttbl_put(struct mlx5_eswitch *esw, struct mlx5_vport_tbl_attr *attr ...@@ -127,6 +136,7 @@ mlx5_esw_vporttbl_put(struct mlx5_eswitch *esw, struct mlx5_vport_tbl_attr *attr
u32 hkey; u32 hkey;
mutex_lock(&esw->fdb_table.offloads.vports.lock); 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); hkey = flow_attr_to_vport_key(esw, attr, &key);
e = esw_vport_tbl_lookup(esw, &key, hkey); e = esw_vport_tbl_lookup(esw, &key, hkey);
if (!e || --e->num_rules) if (!e || --e->num_rules)
......
...@@ -674,7 +674,7 @@ struct mlx5_vport_tbl_attr { ...@@ -674,7 +674,7 @@ struct mlx5_vport_tbl_attr {
u32 chain; u32 chain;
u16 prio; u16 prio;
u16 vport; u16 vport;
const struct esw_vport_tbl_namespace *vport_ns; struct esw_vport_tbl_namespace *vport_ns;
}; };
struct mlx5_flow_table * struct mlx5_flow_table *
......
...@@ -73,7 +73,7 @@ ...@@ -73,7 +73,7 @@
#define MLX5_ESW_FT_OFFLOADS_DROP_RULE (1) #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_fte = MLX5_ESW_VPORT_TBL_SIZE,
.max_num_groups = MLX5_ESW_VPORT_TBL_NUM_GROUPS, .max_num_groups = MLX5_ESW_VPORT_TBL_NUM_GROUPS,
.flags = 0, .flags = 0,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment