Skip to content

Commit

Permalink
mlx4_en: Added Ethtool support for TX Interrupt coalescing
Browse files Browse the repository at this point in the history
Signed-off-by: Yevgeny Petrilin <yevgenyp@mellanox.co.il>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Yevgeny Petrilin authored and David S. Miller committed Apr 24, 2012
1 parent da882c1 commit a19a848
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
19 changes: 17 additions & 2 deletions drivers/net/ethernet/mellanox/mlx4/en_ethtool.c
Original file line number Diff line number Diff line change
Expand Up @@ -359,8 +359,8 @@ static int mlx4_en_get_coalesce(struct net_device *dev,
{
struct mlx4_en_priv *priv = netdev_priv(dev);

coal->tx_coalesce_usecs = 0;
coal->tx_max_coalesced_frames = 0;
coal->tx_coalesce_usecs = priv->tx_usecs;
coal->tx_max_coalesced_frames = priv->tx_frames;
coal->rx_coalesce_usecs = priv->rx_usecs;
coal->rx_max_coalesced_frames = priv->rx_frames;

Expand Down Expand Up @@ -388,6 +388,21 @@ static int mlx4_en_set_coalesce(struct net_device *dev,
MLX4_EN_RX_COAL_TIME :
coal->rx_coalesce_usecs;

/* Setting TX coalescing parameters */
if (coal->tx_coalesce_usecs != priv->tx_usecs ||
coal->tx_max_coalesced_frames != priv->tx_frames) {
priv->tx_usecs = coal->tx_coalesce_usecs;
priv->tx_frames = coal->tx_max_coalesced_frames;
for (i = 0; i < priv->tx_ring_num; i++) {
priv->tx_cq[i].moder_cnt = priv->tx_frames;
priv->tx_cq[i].moder_time = priv->tx_usecs;
if (mlx4_en_set_cq_moder(priv, &priv->tx_cq[i])) {
en_warn(priv, "Failed changing moderation "
"for TX cq %d\n", i);
}
}
}

/* Set adaptive coalescing params */
priv->pkt_rate_low = coal->pkt_rate_low;
priv->rx_usecs_low = coal->rx_coalesce_usecs_low;
Expand Down
6 changes: 4 additions & 2 deletions drivers/net/ethernet/mellanox/mlx4/en_netdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,8 @@ static void mlx4_en_set_default_moderation(struct mlx4_en_priv *priv)
*/
priv->rx_frames = MLX4_EN_RX_COAL_TARGET;
priv->rx_usecs = MLX4_EN_RX_COAL_TIME;
priv->tx_frames = MLX4_EN_TX_COAL_PKTS;
priv->tx_usecs = MLX4_EN_TX_COAL_TIME;
en_dbg(INTR, priv, "Default coalesing params for mtu:%d - "
"rx_frames:%d rx_usecs:%d\n",
priv->dev->mtu, priv->rx_frames, priv->rx_usecs);
Expand All @@ -445,8 +447,8 @@ static void mlx4_en_set_default_moderation(struct mlx4_en_priv *priv)

for (i = 0; i < priv->tx_ring_num; i++) {
cq = &priv->tx_cq[i];
cq->moder_cnt = MLX4_EN_TX_COAL_PKTS;
cq->moder_time = MLX4_EN_TX_COAL_TIME;
cq->moder_cnt = priv->tx_frames;
cq->moder_time = priv->tx_usecs;
}

/* Reset auto-moderation params */
Expand Down

0 comments on commit a19a848

Please sign in to comment.