Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

net/mlx4_en: Fix wrong limitation for number of TX rings

XDP_TX rings should not be limited by max_num_tx_rings_p_up.
To make sure total number of TX rings never exceed MAX_TX_RINGS,
add similar check in mlx4_en_alloc_tx_queue_per_tc(), where
a new value is assigned for num_up.

Fixes: 7e1dc5e926d5 ("net/mlx4_en: Limit the number of TX rings")
Signed-off-by: Tariq Toukan <tariqt@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Tariq Toukan and committed by
David S. Miller
2744bf42 4f0e97d0

+13 -4
+4 -4
drivers/net/ethernet/mellanox/mlx4/en_ethtool.c
··· 1812 1812 struct mlx4_en_dev *mdev = priv->mdev; 1813 1813 struct mlx4_en_port_profile new_prof; 1814 1814 struct mlx4_en_priv *tmp; 1815 + int total_tx_count; 1815 1816 int port_up = 0; 1816 1817 int xdp_count; 1817 1818 int err = 0; ··· 1827 1826 1828 1827 mutex_lock(&mdev->state_lock); 1829 1828 xdp_count = priv->tx_ring_num[TX_XDP] ? channel->rx_count : 0; 1830 - if (channel->tx_count * priv->prof->num_up + xdp_count > 1831 - priv->mdev->profile.max_num_tx_rings_p_up * priv->prof->num_up) { 1829 + total_tx_count = channel->tx_count * priv->prof->num_up + xdp_count; 1830 + if (total_tx_count > MAX_TX_RINGS) { 1832 1831 err = -EINVAL; 1833 1832 en_err(priv, 1834 1833 "Total number of TX and XDP rings (%d) exceeds the maximum supported (%d)\n", 1835 - channel->tx_count * priv->prof->num_up + xdp_count, 1836 - MAX_TX_RINGS); 1834 + total_tx_count, MAX_TX_RINGS); 1837 1835 goto out; 1838 1836 } 1839 1837
+9
drivers/net/ethernet/mellanox/mlx4/en_netdev.c
··· 91 91 struct mlx4_en_dev *mdev = priv->mdev; 92 92 struct mlx4_en_port_profile new_prof; 93 93 struct mlx4_en_priv *tmp; 94 + int total_count; 94 95 int port_up = 0; 95 96 int err = 0; 96 97 ··· 105 104 MLX4_EN_NUM_UP_HIGH; 106 105 new_prof.tx_ring_num[TX] = new_prof.num_tx_rings_p_up * 107 106 new_prof.num_up; 107 + total_count = new_prof.tx_ring_num[TX] + new_prof.tx_ring_num[TX_XDP]; 108 + if (total_count > MAX_TX_RINGS) { 109 + err = -EINVAL; 110 + en_err(priv, 111 + "Total number of TX and XDP rings (%d) exceeds the maximum supported (%d)\n", 112 + total_count, MAX_TX_RINGS); 113 + goto out; 114 + } 108 115 err = mlx4_en_try_alloc_resources(priv, tmp, &new_prof, true); 109 116 if (err) 110 117 goto out;