summaryrefslogtreecommitdiffstats
path: root/drivers/net/ethernet
diff options
context:
space:
mode:
authorLama Kayal <lkayal@nvidia.com>2022-04-28 16:41:20 +0300
committerSaeed Mahameed <saeedm@nvidia.com>2022-07-28 13:55:28 -0700
commit454533aa87f4472826779bc8a2925548bf1ed4da (patch)
treef5f7edd7f0f2d53f825ad529b4928291b959eb87 /drivers/net/ethernet
parent23bde065c3a228e1e65c7ba9495f0b54535bea1a (diff)
downloadlinux-stable-454533aa87f4472826779bc8a2925548bf1ed4da.tar.gz
linux-stable-454533aa87f4472826779bc8a2925548bf1ed4da.tar.bz2
linux-stable-454533aa87f4472826779bc8a2925548bf1ed4da.zip
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 <lkayal@nvidia.com> Reviewed-by: Tariq Toukan <tariqt@nvidia.com> Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
Diffstat (limited to 'drivers/net/ethernet')
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/en.h2
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/en_fs.c52
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/en_main.c4
3 files changed, 46 insertions, 12 deletions
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en.h b/drivers/net/ethernet/mellanox/mlx5/core/en.h
index b07228f69b91..150a82af2072 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en.h
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en.h
@@ -987,6 +987,8 @@ enum mlx5e_profile_feature {
MLX5E_PROFILE_FEATURE_PTP_RX,
MLX5E_PROFILE_FEATURE_PTP_TX,
MLX5E_PROFILE_FEATURE_QOS_HTB,
+ MLX5E_PROFILE_FEATURE_FS_VLAN,
+ MLX5E_PROFILE_FEATURE_FS_TC,
};
struct mlx5e_profile {
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_fs.c b/drivers/net/ethernet/mellanox/mlx5/core/en_fs.c
index 86c5533950f1..4d5b1e444cbf 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_fs.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_fs.c
@@ -1343,27 +1343,57 @@ void mlx5e_destroy_flow_steering(struct mlx5e_priv *priv)
mlx5e_ethtool_cleanup_steering(priv);
}
+static int mlx5e_fs_vlan_alloc(struct mlx5e_flow_steering *fs)
+{
+ fs->vlan = kvzalloc(sizeof(*fs->vlan), GFP_KERNEL);
+ if (!fs->vlan)
+ return -ENOMEM;
+ return 0;
+}
+
+static void mlx5e_fs_vlan_free(struct mlx5e_flow_steering *fs)
+{
+ kvfree(fs->vlan);
+}
+
+static int mlx5e_fs_tc_alloc(struct mlx5e_flow_steering *fs)
+{
+ fs->tc = mlx5e_tc_table_alloc();
+ if (IS_ERR(fs->tc))
+ return -ENOMEM;
+ return 0;
+}
+
+static void mlx5e_fs_tc_free(struct mlx5e_flow_steering *fs)
+{
+ mlx5e_tc_table_free(fs->tc);
+}
+
int mlx5e_fs_init(struct mlx5e_priv *priv)
{
- priv->fs.vlan = kvzalloc(sizeof(*priv->fs.vlan), GFP_KERNEL);
- if (!priv->fs.vlan)
- goto err;
+ int err;
- priv->fs.tc = mlx5e_tc_table_alloc();
- if (IS_ERR(priv->fs.tc))
- goto err_free_vlan;
+ if (mlx5e_profile_feature_cap(priv->profile, FS_VLAN)) {
+ err = mlx5e_fs_vlan_alloc(&priv->fs);
+ if (err)
+ goto err;
+ }
+
+ if (mlx5e_profile_feature_cap(priv->profile, FS_TC)) {
+ err = mlx5e_fs_tc_alloc(&priv->fs);
+ if (err)
+ goto err_free_vlan;
+ }
return 0;
err_free_vlan:
- kvfree(priv->fs.vlan);
- priv->fs.vlan = NULL;
+ mlx5e_fs_vlan_free(&priv->fs);
err:
return -ENOMEM;
}
void mlx5e_fs_cleanup(struct mlx5e_priv *priv)
{
- mlx5e_tc_table_free(priv->fs.tc);
- kvfree(priv->fs.vlan);
- priv->fs.vlan = NULL;
+ mlx5e_fs_tc_free(&priv->fs);
+ mlx5e_fs_vlan_free(&priv->fs);
}
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
index 180b2f418339..6305069badf5 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
@@ -5242,7 +5242,9 @@ static const struct mlx5e_profile mlx5e_nic_profile = {
.stats_grps_num = mlx5e_nic_stats_grps_num,
.features = BIT(MLX5E_PROFILE_FEATURE_PTP_RX) |
BIT(MLX5E_PROFILE_FEATURE_PTP_TX) |
- BIT(MLX5E_PROFILE_FEATURE_QOS_HTB),
+ BIT(MLX5E_PROFILE_FEATURE_QOS_HTB) |
+ BIT(MLX5E_PROFILE_FEATURE_FS_VLAN) |
+ BIT(MLX5E_PROFILE_FEATURE_FS_TC),
};
static int mlx5e_profile_max_num_channels(struct mlx5_core_dev *mdev,