Skip to content

Commit 9b93ab9

Browse files
Gal PressmanSaeed Mahameed
authored andcommitted
net/mlx5: Separate ingress/egress namespaces for each vport
Each vport has its own root flow table for the ACL flow tables and root flow table is per namespace, therefore we should create a namespace for each vport. Fixes: efdc810 ("net/mlx5: Flow steering, Add vport ACL support") Signed-off-by: Gal Pressman <galp@mellanox.com> Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
1 parent 4484e29 commit 9b93ab9

4 files changed

Lines changed: 133 additions & 30 deletions

File tree

‎drivers/net/ethernet/mellanox/mlx5/core/eswitch.c‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -867,9 +867,10 @@ static int esw_vport_enable_egress_acl(struct mlx5_eswitch *esw,
867867
esw_debug(dev, "Create vport[%d] egress ACL log_max_size(%d)\n",
868868
vport->vport, MLX5_CAP_ESW_EGRESS_ACL(dev, log_max_ft_size));
869869

870-
root_ns = mlx5_get_flow_namespace(dev, MLX5_FLOW_NAMESPACE_ESW_EGRESS);
870+
root_ns = mlx5_get_flow_vport_acl_namespace(dev, MLX5_FLOW_NAMESPACE_ESW_EGRESS,
871+
vport->vport);
871872
if (!root_ns) {
872-
esw_warn(dev, "Failed to get E-Switch egress flow namespace\n");
873+
esw_warn(dev, "Failed to get E-Switch egress flow namespace for vport (%d)\n", vport->vport);
873874
return -EOPNOTSUPP;
874875
}
875876

@@ -984,9 +985,10 @@ static int esw_vport_enable_ingress_acl(struct mlx5_eswitch *esw,
984985
esw_debug(dev, "Create vport[%d] ingress ACL log_max_size(%d)\n",
985986
vport->vport, MLX5_CAP_ESW_INGRESS_ACL(dev, log_max_ft_size));
986987

987-
root_ns = mlx5_get_flow_namespace(dev, MLX5_FLOW_NAMESPACE_ESW_INGRESS);
988+
root_ns = mlx5_get_flow_vport_acl_namespace(dev, MLX5_FLOW_NAMESPACE_ESW_INGRESS,
989+
vport->vport);
988990
if (!root_ns) {
989-
esw_warn(dev, "Failed to get E-Switch ingress flow namespace\n");
991+
esw_warn(dev, "Failed to get E-Switch ingress flow namespace for vport (%d)\n", vport->vport);
990992
return -EOPNOTSUPP;
991993
}
992994

‎drivers/net/ethernet/mellanox/mlx5/core/fs_core.c‎

Lines changed: 121 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2014,16 +2014,6 @@ struct mlx5_flow_namespace *mlx5_get_flow_namespace(struct mlx5_core_dev *dev,
20142014
return &steering->fdb_root_ns->ns;
20152015
else
20162016
return NULL;
2017-
case MLX5_FLOW_NAMESPACE_ESW_EGRESS:
2018-
if (steering->esw_egress_root_ns)
2019-
return &steering->esw_egress_root_ns->ns;
2020-
else
2021-
return NULL;
2022-
case MLX5_FLOW_NAMESPACE_ESW_INGRESS:
2023-
if (steering->esw_ingress_root_ns)
2024-
return &steering->esw_ingress_root_ns->ns;
2025-
else
2026-
return NULL;
20272017
case MLX5_FLOW_NAMESPACE_SNIFFER_RX:
20282018
if (steering->sniffer_rx_root_ns)
20292019
return &steering->sniffer_rx_root_ns->ns;
@@ -2054,6 +2044,33 @@ struct mlx5_flow_namespace *mlx5_get_flow_namespace(struct mlx5_core_dev *dev,
20542044
}
20552045
EXPORT_SYMBOL(mlx5_get_flow_namespace);
20562046

2047+
struct mlx5_flow_namespace *mlx5_get_flow_vport_acl_namespace(struct mlx5_core_dev *dev,
2048+
enum mlx5_flow_namespace_type type,
2049+
int vport)
2050+
{
2051+
struct mlx5_flow_steering *steering = dev->priv.steering;
2052+
2053+
if (!steering || vport >= MLX5_TOTAL_VPORTS(dev))
2054+
return NULL;
2055+
2056+
switch (type) {
2057+
case MLX5_FLOW_NAMESPACE_ESW_EGRESS:
2058+
if (steering->esw_egress_root_ns &&
2059+
steering->esw_egress_root_ns[vport])
2060+
return &steering->esw_egress_root_ns[vport]->ns;
2061+
else
2062+
return NULL;
2063+
case MLX5_FLOW_NAMESPACE_ESW_INGRESS:
2064+
if (steering->esw_ingress_root_ns &&
2065+
steering->esw_ingress_root_ns[vport])
2066+
return &steering->esw_ingress_root_ns[vport]->ns;
2067+
else
2068+
return NULL;
2069+
default:
2070+
return NULL;
2071+
}
2072+
}
2073+
20572074
static struct fs_prio *fs_create_prio(struct mlx5_flow_namespace *ns,
20582075
unsigned int prio, int num_levels)
20592076
{
@@ -2331,13 +2348,41 @@ static void cleanup_root_ns(struct mlx5_flow_root_namespace *root_ns)
23312348
clean_tree(&root_ns->ns.node);
23322349
}
23332350

2351+
static void cleanup_egress_acls_root_ns(struct mlx5_core_dev *dev)
2352+
{
2353+
struct mlx5_flow_steering *steering = dev->priv.steering;
2354+
int i;
2355+
2356+
if (!steering->esw_egress_root_ns)
2357+
return;
2358+
2359+
for (i = 0; i < MLX5_TOTAL_VPORTS(dev); i++)
2360+
cleanup_root_ns(steering->esw_egress_root_ns[i]);
2361+
2362+
kfree(steering->esw_egress_root_ns);
2363+
}
2364+
2365+
static void cleanup_ingress_acls_root_ns(struct mlx5_core_dev *dev)
2366+
{
2367+
struct mlx5_flow_steering *steering = dev->priv.steering;
2368+
int i;
2369+
2370+
if (!steering->esw_ingress_root_ns)
2371+
return;
2372+
2373+
for (i = 0; i < MLX5_TOTAL_VPORTS(dev); i++)
2374+
cleanup_root_ns(steering->esw_ingress_root_ns[i]);
2375+
2376+
kfree(steering->esw_ingress_root_ns);
2377+
}
2378+
23342379
void mlx5_cleanup_fs(struct mlx5_core_dev *dev)
23352380
{
23362381
struct mlx5_flow_steering *steering = dev->priv.steering;
23372382

23382383
cleanup_root_ns(steering->root_ns);
2339-
cleanup_root_ns(steering->esw_egress_root_ns);
2340-
cleanup_root_ns(steering->esw_ingress_root_ns);
2384+
cleanup_egress_acls_root_ns(dev);
2385+
cleanup_ingress_acls_root_ns(dev);
23412386
cleanup_root_ns(steering->fdb_root_ns);
23422387
cleanup_root_ns(steering->sniffer_rx_root_ns);
23432388
cleanup_root_ns(steering->sniffer_tx_root_ns);
@@ -2406,34 +2451,86 @@ static int init_fdb_root_ns(struct mlx5_flow_steering *steering)
24062451
return PTR_ERR(prio);
24072452
}
24082453

2409-
static int init_egress_acl_root_ns(struct mlx5_flow_steering *steering)
2454+
static int init_egress_acl_root_ns(struct mlx5_flow_steering *steering, int vport)
24102455
{
24112456
struct fs_prio *prio;
24122457

2413-
steering->esw_egress_root_ns = create_root_ns(steering, FS_FT_ESW_EGRESS_ACL);
2414-
if (!steering->esw_egress_root_ns)
2458+
steering->esw_egress_root_ns[vport] = create_root_ns(steering, FS_FT_ESW_EGRESS_ACL);
2459+
if (!steering->esw_egress_root_ns[vport])
24152460
return -ENOMEM;
24162461

24172462
/* create 1 prio*/
2418-
prio = fs_create_prio(&steering->esw_egress_root_ns->ns, 0,
2419-
MLX5_TOTAL_VPORTS(steering->dev));
2463+
prio = fs_create_prio(&steering->esw_egress_root_ns[vport]->ns, 0, 1);
24202464
return PTR_ERR_OR_ZERO(prio);
24212465
}
24222466

2423-
static int init_ingress_acl_root_ns(struct mlx5_flow_steering *steering)
2467+
static int init_ingress_acl_root_ns(struct mlx5_flow_steering *steering, int vport)
24242468
{
24252469
struct fs_prio *prio;
24262470

2427-
steering->esw_ingress_root_ns = create_root_ns(steering, FS_FT_ESW_INGRESS_ACL);
2428-
if (!steering->esw_ingress_root_ns)
2471+
steering->esw_ingress_root_ns[vport] = create_root_ns(steering, FS_FT_ESW_INGRESS_ACL);
2472+
if (!steering->esw_ingress_root_ns[vport])
24292473
return -ENOMEM;
24302474

24312475
/* create 1 prio*/
2432-
prio = fs_create_prio(&steering->esw_ingress_root_ns->ns, 0,
2433-
MLX5_TOTAL_VPORTS(steering->dev));
2476+
prio = fs_create_prio(&steering->esw_ingress_root_ns[vport]->ns, 0, 1);
24342477
return PTR_ERR_OR_ZERO(prio);
24352478
}
24362479

2480+
static int init_egress_acls_root_ns(struct mlx5_core_dev *dev)
2481+
{
2482+
struct mlx5_flow_steering *steering = dev->priv.steering;
2483+
int err;
2484+
int i;
2485+
2486+
steering->esw_egress_root_ns = kcalloc(MLX5_TOTAL_VPORTS(dev),
2487+
sizeof(*steering->esw_egress_root_ns),
2488+
GFP_KERNEL);
2489+
if (!steering->esw_egress_root_ns)
2490+
return -ENOMEM;
2491+
2492+
for (i = 0; i < MLX5_TOTAL_VPORTS(dev); i++) {
2493+
err = init_egress_acl_root_ns(steering, i);
2494+
if (err)
2495+
goto cleanup_root_ns;
2496+
}
2497+
2498+
return 0;
2499+
2500+
cleanup_root_ns:
2501+
for (i--; i >= 0; i--)
2502+
cleanup_root_ns(steering->esw_egress_root_ns[i]);
2503+
kfree(steering->esw_egress_root_ns);
2504+
return err;
2505+
}
2506+
2507+
static int init_ingress_acls_root_ns(struct mlx5_core_dev *dev)
2508+
{
2509+
struct mlx5_flow_steering *steering = dev->priv.steering;
2510+
int err;
2511+
int i;
2512+
2513+
steering->esw_ingress_root_ns = kcalloc(MLX5_TOTAL_VPORTS(dev),
2514+
sizeof(*steering->esw_ingress_root_ns),
2515+
GFP_KERNEL);
2516+
if (!steering->esw_ingress_root_ns)
2517+
return -ENOMEM;
2518+
2519+
for (i = 0; i < MLX5_TOTAL_VPORTS(dev); i++) {
2520+
err = init_ingress_acl_root_ns(steering, i);
2521+
if (err)
2522+
goto cleanup_root_ns;
2523+
}
2524+
2525+
return 0;
2526+
2527+
cleanup_root_ns:
2528+
for (i--; i >= 0; i--)
2529+
cleanup_root_ns(steering->esw_ingress_root_ns[i]);
2530+
kfree(steering->esw_ingress_root_ns);
2531+
return err;
2532+
}
2533+
24372534
int mlx5_init_fs(struct mlx5_core_dev *dev)
24382535
{
24392536
struct mlx5_flow_steering *steering;
@@ -2476,12 +2573,12 @@ int mlx5_init_fs(struct mlx5_core_dev *dev)
24762573
goto err;
24772574
}
24782575
if (MLX5_CAP_ESW_EGRESS_ACL(dev, ft_support)) {
2479-
err = init_egress_acl_root_ns(steering);
2576+
err = init_egress_acls_root_ns(dev);
24802577
if (err)
24812578
goto err;
24822579
}
24832580
if (MLX5_CAP_ESW_INGRESS_ACL(dev, ft_support)) {
2484-
err = init_ingress_acl_root_ns(steering);
2581+
err = init_ingress_acls_root_ns(dev);
24852582
if (err)
24862583
goto err;
24872584
}

‎drivers/net/ethernet/mellanox/mlx5/core/fs_core.h‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,8 @@ struct mlx5_flow_steering {
7171
struct kmem_cache *ftes_cache;
7272
struct mlx5_flow_root_namespace *root_ns;
7373
struct mlx5_flow_root_namespace *fdb_root_ns;
74-
struct mlx5_flow_root_namespace *esw_egress_root_ns;
75-
struct mlx5_flow_root_namespace *esw_ingress_root_ns;
74+
struct mlx5_flow_root_namespace **esw_egress_root_ns;
75+
struct mlx5_flow_root_namespace **esw_ingress_root_ns;
7676
struct mlx5_flow_root_namespace *sniffer_tx_root_ns;
7777
struct mlx5_flow_root_namespace *sniffer_rx_root_ns;
7878
};

‎include/linux/mlx5/fs.h‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,10 @@ struct mlx5_flow_destination {
9595
struct mlx5_flow_namespace *
9696
mlx5_get_flow_namespace(struct mlx5_core_dev *dev,
9797
enum mlx5_flow_namespace_type type);
98+
struct mlx5_flow_namespace *
99+
mlx5_get_flow_vport_acl_namespace(struct mlx5_core_dev *dev,
100+
enum mlx5_flow_namespace_type type,
101+
int vport);
98102

99103
struct mlx5_flow_table *
100104
mlx5_create_auto_grouped_flow_table(struct mlx5_flow_namespace *ns,

0 commit comments

Comments
 (0)