Skip to content

Commit 454533a

Browse files
Lama KayalSaeed Mahameed
authored andcommitted
net/mlx5e: Allocate VLAN and TC for featured profiles only
Introduce allocation and de-allocation functions for both flow steering VLAN and TC as part of fs API. Add allocations of VLAN and TC as nic profile feature, such that fs_init() will allocate both VLAN and TC only if they're featured in the profile. VLAN and TC are relevant for nic_profile only. Signed-off-by: Lama Kayal <[email protected]> Reviewed-by: Tariq Toukan <[email protected]> Signed-off-by: Saeed Mahameed <[email protected]>
1 parent 23bde06 commit 454533a

File tree

3 files changed

+46
-12
lines changed

3 files changed

+46
-12
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -987,6 +987,8 @@ enum mlx5e_profile_feature {
987987
MLX5E_PROFILE_FEATURE_PTP_RX,
988988
MLX5E_PROFILE_FEATURE_PTP_TX,
989989
MLX5E_PROFILE_FEATURE_QOS_HTB,
990+
MLX5E_PROFILE_FEATURE_FS_VLAN,
991+
MLX5E_PROFILE_FEATURE_FS_TC,
990992
};
991993

992994
struct mlx5e_profile {

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

Lines changed: 41 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1343,27 +1343,57 @@ void mlx5e_destroy_flow_steering(struct mlx5e_priv *priv)
13431343
mlx5e_ethtool_cleanup_steering(priv);
13441344
}
13451345

1346+
static int mlx5e_fs_vlan_alloc(struct mlx5e_flow_steering *fs)
1347+
{
1348+
fs->vlan = kvzalloc(sizeof(*fs->vlan), GFP_KERNEL);
1349+
if (!fs->vlan)
1350+
return -ENOMEM;
1351+
return 0;
1352+
}
1353+
1354+
static void mlx5e_fs_vlan_free(struct mlx5e_flow_steering *fs)
1355+
{
1356+
kvfree(fs->vlan);
1357+
}
1358+
1359+
static int mlx5e_fs_tc_alloc(struct mlx5e_flow_steering *fs)
1360+
{
1361+
fs->tc = mlx5e_tc_table_alloc();
1362+
if (IS_ERR(fs->tc))
1363+
return -ENOMEM;
1364+
return 0;
1365+
}
1366+
1367+
static void mlx5e_fs_tc_free(struct mlx5e_flow_steering *fs)
1368+
{
1369+
mlx5e_tc_table_free(fs->tc);
1370+
}
1371+
13461372
int mlx5e_fs_init(struct mlx5e_priv *priv)
13471373
{
1348-
priv->fs.vlan = kvzalloc(sizeof(*priv->fs.vlan), GFP_KERNEL);
1349-
if (!priv->fs.vlan)
1350-
goto err;
1374+
int err;
13511375

1352-
priv->fs.tc = mlx5e_tc_table_alloc();
1353-
if (IS_ERR(priv->fs.tc))
1354-
goto err_free_vlan;
1376+
if (mlx5e_profile_feature_cap(priv->profile, FS_VLAN)) {
1377+
err = mlx5e_fs_vlan_alloc(&priv->fs);
1378+
if (err)
1379+
goto err;
1380+
}
1381+
1382+
if (mlx5e_profile_feature_cap(priv->profile, FS_TC)) {
1383+
err = mlx5e_fs_tc_alloc(&priv->fs);
1384+
if (err)
1385+
goto err_free_vlan;
1386+
}
13551387

13561388
return 0;
13571389
err_free_vlan:
1358-
kvfree(priv->fs.vlan);
1359-
priv->fs.vlan = NULL;
1390+
mlx5e_fs_vlan_free(&priv->fs);
13601391
err:
13611392
return -ENOMEM;
13621393
}
13631394

13641395
void mlx5e_fs_cleanup(struct mlx5e_priv *priv)
13651396
{
1366-
mlx5e_tc_table_free(priv->fs.tc);
1367-
kvfree(priv->fs.vlan);
1368-
priv->fs.vlan = NULL;
1397+
mlx5e_fs_tc_free(&priv->fs);
1398+
mlx5e_fs_vlan_free(&priv->fs);
13691399
}

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5242,7 +5242,9 @@ static const struct mlx5e_profile mlx5e_nic_profile = {
52425242
.stats_grps_num = mlx5e_nic_stats_grps_num,
52435243
.features = BIT(MLX5E_PROFILE_FEATURE_PTP_RX) |
52445244
BIT(MLX5E_PROFILE_FEATURE_PTP_TX) |
5245-
BIT(MLX5E_PROFILE_FEATURE_QOS_HTB),
5245+
BIT(MLX5E_PROFILE_FEATURE_QOS_HTB) |
5246+
BIT(MLX5E_PROFILE_FEATURE_FS_VLAN) |
5247+
BIT(MLX5E_PROFILE_FEATURE_FS_TC),
52465248
};
52475249

52485250
static int mlx5e_profile_max_num_channels(struct mlx5_core_dev *mdev,

0 commit comments

Comments
 (0)