Skip to content

Commit 6ad4e91

Browse files
Moshe Shemeshdavem330
authored andcommitted
net/mlx4_en: Verify coalescing parameters are in range
Add check of coalescing parameters received through ethtool are within range of values supported by the HW. Driver gets the coalescing rx/tx-usecs and rx/tx-frames as set by the users through ethtool. The ethtool support up to 32 bit value for each. However, mlx4 modify cq limits the coalescing time parameter and coalescing frames parameters to 16 bits. Return out of range error if user tries to set these parameters to higher values. Change type of sample-interval and adaptive_rx_coal parameters in mlx4 driver to u32 as the ethtool holds them as u32 and these parameters are not limited due to mlx4 HW. Fixes: c27a02c ('mlx4_en: Add driver for Mellanox ConnectX 10GbE NIC') Signed-off-by: Moshe Shemesh <[email protected]> Signed-off-by: Tariq Toukan <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent aca06ea commit 6ad4e91

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

drivers/net/ethernet/mellanox/mlx4/en_ethtool.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1027,6 +1027,22 @@ static int mlx4_en_set_coalesce(struct net_device *dev,
10271027
if (!coal->tx_max_coalesced_frames_irq)
10281028
return -EINVAL;
10291029

1030+
if (coal->tx_coalesce_usecs > MLX4_EN_MAX_COAL_TIME ||
1031+
coal->rx_coalesce_usecs > MLX4_EN_MAX_COAL_TIME ||
1032+
coal->rx_coalesce_usecs_low > MLX4_EN_MAX_COAL_TIME ||
1033+
coal->rx_coalesce_usecs_high > MLX4_EN_MAX_COAL_TIME) {
1034+
netdev_info(dev, "%s: maximum coalesce time supported is %d usecs\n",
1035+
__func__, MLX4_EN_MAX_COAL_TIME);
1036+
return -ERANGE;
1037+
}
1038+
1039+
if (coal->tx_max_coalesced_frames > MLX4_EN_MAX_COAL_PKTS ||
1040+
coal->rx_max_coalesced_frames > MLX4_EN_MAX_COAL_PKTS) {
1041+
netdev_info(dev, "%s: maximum coalesced frames supported is %d\n",
1042+
__func__, MLX4_EN_MAX_COAL_PKTS);
1043+
return -ERANGE;
1044+
}
1045+
10301046
priv->rx_frames = (coal->rx_max_coalesced_frames ==
10311047
MLX4_EN_AUTO_CONF) ?
10321048
MLX4_EN_RX_COAL_TARGET :

drivers/net/ethernet/mellanox/mlx4/mlx4_en.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,9 @@
132132
#define MLX4_EN_TX_COAL_PKTS 16
133133
#define MLX4_EN_TX_COAL_TIME 0x10
134134

135+
#define MLX4_EN_MAX_COAL_PKTS U16_MAX
136+
#define MLX4_EN_MAX_COAL_TIME U16_MAX
137+
135138
#define MLX4_EN_RX_RATE_LOW 400000
136139
#define MLX4_EN_RX_COAL_TIME_LOW 0
137140
#define MLX4_EN_RX_RATE_HIGH 450000
@@ -552,8 +555,8 @@ struct mlx4_en_priv {
552555
u16 rx_usecs_low;
553556
u32 pkt_rate_high;
554557
u16 rx_usecs_high;
555-
u16 sample_interval;
556-
u16 adaptive_rx_coal;
558+
u32 sample_interval;
559+
u32 adaptive_rx_coal;
557560
u32 msg_enable;
558561
u32 loopback_ok;
559562
u32 validate_loopback;

0 commit comments

Comments
 (0)