]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
net/mlx5e: Don't allow more than max supported channels
authorAchiad Shochat <achiad@mellanox.com>
Tue, 3 Nov 2015 06:07:21 +0000 (08:07 +0200)
committerDavid S. Miller <davem@davemloft.net>
Tue, 3 Nov 2015 15:41:50 +0000 (10:41 -0500)
Consider MLX5E_MAX_NUM_CHANNELS @ethtool set/get_channels

Signed-off-by: Achiad Shochat <achiad@mellanox.com>
Signed-off-by: Or Gerlitz <ogerlitz@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/mellanox/mlx5/core/en.h
drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c
drivers/net/ethernet/mellanox/mlx5/core/en_main.c

index 0983a208b299531e2ffb1ebc1aa6c710ed671a31..f2ae62dd8c094ac4c11917f29d65fbb63c2194a2 100644 (file)
@@ -617,5 +617,11 @@ static inline void mlx5e_cq_arm(struct mlx5e_cq *cq)
        mlx5_cq_arm(mcq, MLX5_CQ_DB_REQ_NOT, mcq->uar->map, NULL, cq->wq.cc);
 }
 
        mlx5_cq_arm(mcq, MLX5_CQ_DB_REQ_NOT, mcq->uar->map, NULL, cq->wq.cc);
 }
 
+static inline int mlx5e_get_max_num_channels(struct mlx5_core_dev *mdev)
+{
+       return min_t(int, mdev->priv.eq_table.num_comp_vectors,
+                    MLX5E_MAX_NUM_CHANNELS);
+}
+
 extern const struct ethtool_ops mlx5e_ethtool_ops;
 u16 mlx5e_get_max_inline_cap(struct mlx5_core_dev *mdev);
 extern const struct ethtool_ops mlx5e_ethtool_ops;
 u16 mlx5e_get_max_inline_cap(struct mlx5_core_dev *mdev);
index bce912688ca821e5b17f6781c16a0cec713913ef..2e022e9009393eee6e923c7e8b02c8bf24fa2f13 100644 (file)
@@ -345,9 +345,8 @@ static void mlx5e_get_channels(struct net_device *dev,
                               struct ethtool_channels *ch)
 {
        struct mlx5e_priv *priv = netdev_priv(dev);
                               struct ethtool_channels *ch)
 {
        struct mlx5e_priv *priv = netdev_priv(dev);
-       int ncv = priv->mdev->priv.eq_table.num_comp_vectors;
 
 
-       ch->max_combined   = ncv;
+       ch->max_combined   = mlx5e_get_max_num_channels(priv->mdev);
        ch->combined_count = priv->params.num_channels;
 }
 
        ch->combined_count = priv->params.num_channels;
 }
 
@@ -355,7 +354,7 @@ static int mlx5e_set_channels(struct net_device *dev,
                              struct ethtool_channels *ch)
 {
        struct mlx5e_priv *priv = netdev_priv(dev);
                              struct ethtool_channels *ch)
 {
        struct mlx5e_priv *priv = netdev_priv(dev);
-       int ncv = priv->mdev->priv.eq_table.num_comp_vectors;
+       int ncv = mlx5e_get_max_num_channels(priv->mdev);
        unsigned int count = ch->combined_count;
        bool was_opened;
        int err = 0;
        unsigned int count = ch->combined_count;
        bool was_opened;
        int err = 0;
index 0bab33c6cec0092dbe97b0b51652cc58c04b37da..febf711859648aab8acb355f1ea7a9a431ef35bf 100644 (file)
@@ -2047,8 +2047,7 @@ static void *mlx5e_create_netdev(struct mlx5_core_dev *mdev)
 {
        struct net_device *netdev;
        struct mlx5e_priv *priv;
 {
        struct net_device *netdev;
        struct mlx5e_priv *priv;
-       int nch = min_t(int, mdev->priv.eq_table.num_comp_vectors,
-                       MLX5E_MAX_NUM_CHANNELS);
+       int nch = mlx5e_get_max_num_channels(mdev);
        int err;
 
        if (mlx5e_check_required_hca_cap(mdev))
        int err;
 
        if (mlx5e_check_required_hca_cap(mdev))