OSDN Git Service

net/mlx5e: Add profile indications for PTP and QOS HTB features
authorTariq Toukan <tariqt@nvidia.com>
Tue, 7 Dec 2021 06:38:42 +0000 (08:38 +0200)
committerSaeed Mahameed <saeedm@nvidia.com>
Wed, 22 Dec 2021 03:08:56 +0000 (19:08 -0800)
Let the profile indicate support of the PTP and HTB (QOS) features.
This unifies the logic that calculates the number of netdev queues needed
for the features, and allows simplification of mlx5e_create_netdev(),
which no longer requires number of rx/tx queues as parameters.

Signed-off-by: Tariq Toukan <tariqt@nvidia.com>
Reviewed-by: Moshe Shemesh <moshe@nvidia.com>
Reviewed-by: Aya Levin <ayal@nvidia.com>
Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
drivers/net/ethernet/mellanox/mlx5/core/en.h
drivers/net/ethernet/mellanox/mlx5/core/en_main.c
drivers/net/ethernet/mellanox/mlx5/core/en_rep.c

index a8fa7f1..ff194c7 100644 (file)
@@ -958,6 +958,8 @@ extern const struct mlx5e_rx_handlers mlx5e_rx_handlers_nic;
 
 enum mlx5e_profile_feature {
        MLX5E_PROFILE_FEATURE_PTP_RX,
+       MLX5E_PROFILE_FEATURE_PTP_TX,
+       MLX5E_PROFILE_FEATURE_QOS_HTB,
 };
 
 struct mlx5e_profile {
@@ -1195,8 +1197,7 @@ int mlx5e_priv_init(struct mlx5e_priv *priv,
                    struct mlx5_core_dev *mdev);
 void mlx5e_priv_cleanup(struct mlx5e_priv *priv);
 struct net_device *
-mlx5e_create_netdev(struct mlx5_core_dev *mdev, const struct mlx5e_profile *profile,
-                   unsigned int txqs, unsigned int rxqs);
+mlx5e_create_netdev(struct mlx5_core_dev *mdev, const struct mlx5e_profile *profile);
 int mlx5e_attach_netdev(struct mlx5e_priv *priv);
 void mlx5e_detach_netdev(struct mlx5e_priv *priv);
 void mlx5e_destroy_netdev(struct mlx5e_priv *priv);
index 6ca2240..a0d9a17 100644 (file)
@@ -5093,7 +5093,9 @@ static const struct mlx5e_profile mlx5e_nic_profile = {
        .rq_groups         = MLX5E_NUM_RQ_GROUPS(XSK),
        .stats_grps        = mlx5e_nic_stats_grps,
        .stats_grps_num    = mlx5e_nic_stats_grps_num,
-       .features          = BIT(MLX5E_PROFILE_FEATURE_PTP_RX),
+       .features          = BIT(MLX5E_PROFILE_FEATURE_PTP_RX) |
+               BIT(MLX5E_PROFILE_FEATURE_PTP_TX) |
+               BIT(MLX5E_PROFILE_FEATURE_QOS_HTB),
 };
 
 static unsigned int
@@ -5181,13 +5183,44 @@ void mlx5e_priv_cleanup(struct mlx5e_priv *priv)
        memset(priv, 0, sizeof(*priv));
 }
 
+static unsigned int mlx5e_get_max_num_txqs(struct mlx5_core_dev *mdev,
+                                          const struct mlx5e_profile *profile)
+{
+       unsigned int nch, ptp_txqs, qos_txqs;
+
+       nch = mlx5e_get_max_num_channels(mdev);
+
+       ptp_txqs = MLX5_CAP_GEN(mdev, ts_cqe_to_dest_cqn) &&
+               mlx5e_profile_feature_cap(profile, PTP_TX) ?
+               profile->max_tc : 0;
+
+       qos_txqs = mlx5_qos_is_supported(mdev) &&
+               mlx5e_profile_feature_cap(profile, QOS_HTB) ?
+               mlx5e_qos_max_leaf_nodes(mdev) : 0;
+
+       return nch * profile->max_tc + ptp_txqs + qos_txqs;
+}
+
+static unsigned int mlx5e_get_max_num_rxqs(struct mlx5_core_dev *mdev,
+                                          const struct mlx5e_profile *profile)
+{
+       unsigned int nch;
+
+       nch = mlx5e_get_max_num_channels(mdev);
+
+       return nch * profile->rq_groups;
+}
+
 struct net_device *
-mlx5e_create_netdev(struct mlx5_core_dev *mdev, const struct mlx5e_profile *profile,
-                   unsigned int txqs, unsigned int rxqs)
+mlx5e_create_netdev(struct mlx5_core_dev *mdev, const struct mlx5e_profile *profile)
 {
        struct net_device *netdev;
+       unsigned int txqs, rxqs;
        int err;
 
+       txqs = mlx5e_get_max_num_txqs(mdev, profile);
+       rxqs = mlx5e_get_max_num_rxqs(mdev, profile);
+
        netdev = alloc_etherdev_mqs(sizeof(struct mlx5e_priv), txqs, rxqs);
        if (!netdev) {
                mlx5_core_err(mdev, "alloc_etherdev_mqs() failed\n");
@@ -5432,22 +5465,10 @@ static int mlx5e_probe(struct auxiliary_device *adev,
        struct mlx5_core_dev *mdev = edev->mdev;
        struct net_device *netdev;
        pm_message_t state = {};
-       unsigned int txqs, rxqs, ptp_txqs = 0;
        struct mlx5e_priv *priv;
-       int qos_sqs = 0;
        int err;
-       int nch;
 
-       if (MLX5_CAP_GEN(mdev, ts_cqe_to_dest_cqn))
-               ptp_txqs = profile->max_tc;
-
-       if (mlx5_qos_is_supported(mdev))
-               qos_sqs = mlx5e_qos_max_leaf_nodes(mdev);
-
-       nch = mlx5e_get_max_num_channels(mdev);
-       txqs = nch * profile->max_tc + ptp_txqs + qos_sqs;
-       rxqs = nch * profile->rq_groups;
-       netdev = mlx5e_create_netdev(mdev, profile, txqs, rxqs);
+       netdev = mlx5e_create_netdev(mdev, profile);
        if (!netdev) {
                mlx5_core_err(mdev, "mlx5e_create_netdev failed\n");
                return -ENOMEM;
index 17d27d4..0bd3721 100644 (file)
@@ -1183,14 +1183,10 @@ mlx5e_vport_vf_rep_load(struct mlx5_core_dev *dev, struct mlx5_eswitch_rep *rep)
        struct devlink_port *dl_port;
        struct net_device *netdev;
        struct mlx5e_priv *priv;
-       unsigned int txqs, rxqs;
-       int nch, err;
+       int err;
 
        profile = &mlx5e_rep_profile;
-       nch = mlx5e_get_max_num_channels(dev);
-       txqs = nch * profile->max_tc;
-       rxqs = nch * profile->rq_groups;
-       netdev = mlx5e_create_netdev(dev, profile, txqs, rxqs);
+       netdev = mlx5e_create_netdev(dev, profile);
        if (!netdev) {
                mlx5_core_warn(dev,
                               "Failed to create representor netdev for vport %d\n",