aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net
diff options
context:
space:
mode:
authorYevgeny Petrilin <yevgenyp@mellanox.co.il>2011-03-22 18:37:36 -0400
committerDavid S. Miller <davem@davemloft.net>2011-03-23 15:24:16 -0400
commit46afd0fb01d62ee217f142ab9c26054304ab7454 (patch)
treecce928161b2b291410f07a227dd944eac24f8b4a /drivers/net
parent39f17b44aaaa6bc47ded0bbb17fc617ec6cf08bb (diff)
mlx4_en: optimize adaptive moderation algorithm for better latency
Signed-off-by: Yevgeny Petrilin <yevgenyp@mellanox.co.il> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net')
-rw-r--r--drivers/net/mlx4/en_netdev.c18
-rw-r--r--drivers/net/mlx4/mlx4_en.h1
2 files changed, 6 insertions, 13 deletions
diff --git a/drivers/net/mlx4/en_netdev.c b/drivers/net/mlx4/en_netdev.c
index 56627c26d918..b1180dd5e173 100644
--- a/drivers/net/mlx4/en_netdev.c
+++ b/drivers/net/mlx4/en_netdev.c
@@ -417,7 +417,6 @@ static void mlx4_en_auto_moderation(struct mlx4_en_priv *priv)
417 unsigned long avg_pkt_size; 417 unsigned long avg_pkt_size;
418 unsigned long rx_packets; 418 unsigned long rx_packets;
419 unsigned long rx_bytes; 419 unsigned long rx_bytes;
420 unsigned long rx_byte_diff;
421 unsigned long tx_packets; 420 unsigned long tx_packets;
422 unsigned long tx_pkt_diff; 421 unsigned long tx_pkt_diff;
423 unsigned long rx_pkt_diff; 422 unsigned long rx_pkt_diff;
@@ -441,25 +440,20 @@ static void mlx4_en_auto_moderation(struct mlx4_en_priv *priv)
441 rx_pkt_diff = ((unsigned long) (rx_packets - 440 rx_pkt_diff = ((unsigned long) (rx_packets -
442 priv->last_moder_packets)); 441 priv->last_moder_packets));
443 packets = max(tx_pkt_diff, rx_pkt_diff); 442 packets = max(tx_pkt_diff, rx_pkt_diff);
444 rx_byte_diff = rx_bytes - priv->last_moder_bytes;
445 rx_byte_diff = rx_byte_diff ? rx_byte_diff : 1;
446 rate = packets * HZ / period; 443 rate = packets * HZ / period;
447 avg_pkt_size = packets ? ((unsigned long) (rx_bytes - 444 avg_pkt_size = packets ? ((unsigned long) (rx_bytes -
448 priv->last_moder_bytes)) / packets : 0; 445 priv->last_moder_bytes)) / packets : 0;
449 446
450 /* Apply auto-moderation only when packet rate exceeds a rate that 447 /* Apply auto-moderation only when packet rate exceeds a rate that
451 * it matters */ 448 * it matters */
452 if (rate > MLX4_EN_RX_RATE_THRESH) { 449 if (rate > MLX4_EN_RX_RATE_THRESH && avg_pkt_size > MLX4_EN_AVG_PKT_SMALL) {
453 /* If tx and rx packet rates are not balanced, assume that 450 /* If tx and rx packet rates are not balanced, assume that
454 * traffic is mainly BW bound and apply maximum moderation. 451 * traffic is mainly BW bound and apply maximum moderation.
455 * Otherwise, moderate according to packet rate */ 452 * Otherwise, moderate according to packet rate */
456 if (2 * tx_pkt_diff > 3 * rx_pkt_diff && 453 if (2 * tx_pkt_diff > 3 * rx_pkt_diff ||
457 rx_pkt_diff / rx_byte_diff < 454 2 * rx_pkt_diff > 3 * tx_pkt_diff) {
458 MLX4_EN_SMALL_PKT_SIZE)
459 moder_time = priv->rx_usecs_low;
460 else if (2 * rx_pkt_diff > 3 * tx_pkt_diff)
461 moder_time = priv->rx_usecs_high; 455 moder_time = priv->rx_usecs_high;
462 else { 456 } else {
463 if (rate < priv->pkt_rate_low) 457 if (rate < priv->pkt_rate_low)
464 moder_time = priv->rx_usecs_low; 458 moder_time = priv->rx_usecs_low;
465 else if (rate > priv->pkt_rate_high) 459 else if (rate > priv->pkt_rate_high)
@@ -471,9 +465,7 @@ static void mlx4_en_auto_moderation(struct mlx4_en_priv *priv)
471 priv->rx_usecs_low; 465 priv->rx_usecs_low;
472 } 466 }
473 } else { 467 } else {
474 /* When packet rate is low, use default moderation rather than 468 moder_time = priv->rx_usecs_low;
475 * 0 to prevent interrupt storms if traffic suddenly increases */
476 moder_time = priv->rx_usecs;
477 } 469 }
478 470
479 en_dbg(INTR, priv, "tx rate:%lu rx_rate:%lu\n", 471 en_dbg(INTR, priv, "tx rate:%lu rx_rate:%lu\n",
diff --git a/drivers/net/mlx4/mlx4_en.h b/drivers/net/mlx4/mlx4_en.h
index dfed6a07c2d7..5387c4e9f295 100644
--- a/drivers/net/mlx4/mlx4_en.h
+++ b/drivers/net/mlx4/mlx4_en.h
@@ -124,6 +124,7 @@ enum {
124#define MLX4_EN_RX_SIZE_THRESH 1024 124#define MLX4_EN_RX_SIZE_THRESH 1024
125#define MLX4_EN_RX_RATE_THRESH (1000000 / MLX4_EN_RX_COAL_TIME_HIGH) 125#define MLX4_EN_RX_RATE_THRESH (1000000 / MLX4_EN_RX_COAL_TIME_HIGH)
126#define MLX4_EN_SAMPLE_INTERVAL 0 126#define MLX4_EN_SAMPLE_INTERVAL 0
127#define MLX4_EN_AVG_PKT_SMALL 256
127 128
128#define MLX4_EN_AUTO_CONF 0xffff 129#define MLX4_EN_AUTO_CONF 0xffff
129 130