]>
Commit | Line | Data |
---|---|---|
d55578af GKH |
1 | From foo@baz Wed May 16 16:57:32 CEST 2018 |
2 | From: Moshe Shemesh <moshe@mellanox.com> | |
3 | Date: Wed, 9 May 2018 18:35:13 +0300 | |
4 | Subject: net/mlx4_en: Verify coalescing parameters are in range | |
5 | ||
6 | From: Moshe Shemesh <moshe@mellanox.com> | |
7 | ||
8 | [ Upstream commit 6ad4e91c6d796b38a7f0e724db1de28eeb122bad ] | |
9 | ||
10 | Add check of coalescing parameters received through ethtool are within | |
11 | range of values supported by the HW. | |
12 | Driver gets the coalescing rx/tx-usecs and rx/tx-frames as set by the | |
13 | users through ethtool. The ethtool support up to 32 bit value for each. | |
14 | However, mlx4 modify cq limits the coalescing time parameter and | |
15 | coalescing frames parameters to 16 bits. | |
16 | Return out of range error if user tries to set these parameters to | |
17 | higher values. | |
18 | Change type of sample-interval and adaptive_rx_coal parameters in mlx4 | |
19 | driver to u32 as the ethtool holds them as u32 and these parameters are | |
20 | not limited due to mlx4 HW. | |
21 | ||
22 | Fixes: c27a02cd94d6 ('mlx4_en: Add driver for Mellanox ConnectX 10GbE NIC') | |
23 | Signed-off-by: Moshe Shemesh <moshe@mellanox.com> | |
24 | Signed-off-by: Tariq Toukan <tariqt@mellanox.com> | |
25 | Signed-off-by: David S. Miller <davem@davemloft.net> | |
26 | Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> | |
27 | --- | |
28 | drivers/net/ethernet/mellanox/mlx4/en_ethtool.c | 16 ++++++++++++++++ | |
29 | drivers/net/ethernet/mellanox/mlx4/mlx4_en.h | 7 +++++-- | |
30 | 2 files changed, 21 insertions(+), 2 deletions(-) | |
31 | ||
32 | --- a/drivers/net/ethernet/mellanox/mlx4/en_ethtool.c | |
33 | +++ b/drivers/net/ethernet/mellanox/mlx4/en_ethtool.c | |
34 | @@ -967,6 +967,22 @@ static int mlx4_en_set_coalesce(struct n | |
35 | if (!coal->tx_max_coalesced_frames_irq) | |
36 | return -EINVAL; | |
37 | ||
38 | + if (coal->tx_coalesce_usecs > MLX4_EN_MAX_COAL_TIME || | |
39 | + coal->rx_coalesce_usecs > MLX4_EN_MAX_COAL_TIME || | |
40 | + coal->rx_coalesce_usecs_low > MLX4_EN_MAX_COAL_TIME || | |
41 | + coal->rx_coalesce_usecs_high > MLX4_EN_MAX_COAL_TIME) { | |
42 | + netdev_info(dev, "%s: maximum coalesce time supported is %d usecs\n", | |
43 | + __func__, MLX4_EN_MAX_COAL_TIME); | |
44 | + return -ERANGE; | |
45 | + } | |
46 | + | |
47 | + if (coal->tx_max_coalesced_frames > MLX4_EN_MAX_COAL_PKTS || | |
48 | + coal->rx_max_coalesced_frames > MLX4_EN_MAX_COAL_PKTS) { | |
49 | + netdev_info(dev, "%s: maximum coalesced frames supported is %d\n", | |
50 | + __func__, MLX4_EN_MAX_COAL_PKTS); | |
51 | + return -ERANGE; | |
52 | + } | |
53 | + | |
54 | priv->rx_frames = (coal->rx_max_coalesced_frames == | |
55 | MLX4_EN_AUTO_CONF) ? | |
56 | MLX4_EN_RX_COAL_TARGET : | |
57 | --- a/drivers/net/ethernet/mellanox/mlx4/mlx4_en.h | |
58 | +++ b/drivers/net/ethernet/mellanox/mlx4/mlx4_en.h | |
59 | @@ -140,6 +140,9 @@ enum { | |
60 | #define MLX4_EN_TX_COAL_PKTS 16 | |
61 | #define MLX4_EN_TX_COAL_TIME 0x10 | |
62 | ||
63 | +#define MLX4_EN_MAX_COAL_PKTS U16_MAX | |
64 | +#define MLX4_EN_MAX_COAL_TIME U16_MAX | |
65 | + | |
66 | #define MLX4_EN_RX_RATE_LOW 400000 | |
67 | #define MLX4_EN_RX_COAL_TIME_LOW 0 | |
68 | #define MLX4_EN_RX_RATE_HIGH 450000 | |
69 | @@ -518,8 +521,8 @@ struct mlx4_en_priv { | |
70 | u16 rx_usecs_low; | |
71 | u32 pkt_rate_high; | |
72 | u16 rx_usecs_high; | |
73 | - u16 sample_interval; | |
74 | - u16 adaptive_rx_coal; | |
75 | + u32 sample_interval; | |
76 | + u32 adaptive_rx_coal; | |
77 | u32 msg_enable; | |
78 | u32 loopback_ok; | |
79 | u32 validate_loopback; |