diff options
| -rw-r--r-- | drivers/net/ethernet/mellanox/mlx4/en_ethtool.c | 59 |
1 files changed, 30 insertions, 29 deletions
diff --git a/drivers/net/ethernet/mellanox/mlx4/en_ethtool.c b/drivers/net/ethernet/mellanox/mlx4/en_ethtool.c index 9d0b88eea02b..dc8ccb446b62 100644 --- a/drivers/net/ethernet/mellanox/mlx4/en_ethtool.c +++ b/drivers/net/ethernet/mellanox/mlx4/en_ethtool.c | |||
| @@ -43,6 +43,34 @@ | |||
| 43 | #define EN_ETHTOOL_SHORT_MASK cpu_to_be16(0xffff) | 43 | #define EN_ETHTOOL_SHORT_MASK cpu_to_be16(0xffff) |
| 44 | #define EN_ETHTOOL_WORD_MASK cpu_to_be32(0xffffffff) | 44 | #define EN_ETHTOOL_WORD_MASK cpu_to_be32(0xffffffff) |
| 45 | 45 | ||
| 46 | static int mlx4_en_moderation_update(struct mlx4_en_priv *priv) | ||
| 47 | { | ||
| 48 | int i; | ||
| 49 | int err = 0; | ||
| 50 | |||
| 51 | for (i = 0; i < priv->tx_ring_num; i++) { | ||
| 52 | priv->tx_cq[i].moder_cnt = priv->tx_frames; | ||
| 53 | priv->tx_cq[i].moder_time = priv->tx_usecs; | ||
| 54 | err = mlx4_en_set_cq_moder(priv, &priv->tx_cq[i]); | ||
| 55 | if (err) | ||
| 56 | return err; | ||
| 57 | } | ||
| 58 | |||
| 59 | if (priv->adaptive_rx_coal) | ||
| 60 | return 0; | ||
| 61 | |||
| 62 | for (i = 0; i < priv->rx_ring_num; i++) { | ||
| 63 | priv->rx_cq[i].moder_cnt = priv->rx_frames; | ||
| 64 | priv->rx_cq[i].moder_time = priv->rx_usecs; | ||
| 65 | priv->last_moder_time[i] = MLX4_EN_AUTO_CONF; | ||
| 66 | err = mlx4_en_set_cq_moder(priv, &priv->rx_cq[i]); | ||
| 67 | if (err) | ||
| 68 | return err; | ||
| 69 | } | ||
| 70 | |||
| 71 | return err; | ||
| 72 | } | ||
| 73 | |||
| 46 | static void | 74 | static void |
| 47 | mlx4_en_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *drvinfo) | 75 | mlx4_en_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *drvinfo) |
| 48 | { | 76 | { |
| @@ -381,7 +409,6 @@ static int mlx4_en_set_coalesce(struct net_device *dev, | |||
| 381 | struct ethtool_coalesce *coal) | 409 | struct ethtool_coalesce *coal) |
| 382 | { | 410 | { |
| 383 | struct mlx4_en_priv *priv = netdev_priv(dev); | 411 | struct mlx4_en_priv *priv = netdev_priv(dev); |
| 384 | int err, i; | ||
| 385 | 412 | ||
| 386 | priv->rx_frames = (coal->rx_max_coalesced_frames == | 413 | priv->rx_frames = (coal->rx_max_coalesced_frames == |
| 387 | MLX4_EN_AUTO_CONF) ? | 414 | MLX4_EN_AUTO_CONF) ? |
| @@ -397,14 +424,6 @@ static int mlx4_en_set_coalesce(struct net_device *dev, | |||
| 397 | coal->tx_max_coalesced_frames != priv->tx_frames) { | 424 | coal->tx_max_coalesced_frames != priv->tx_frames) { |
| 398 | priv->tx_usecs = coal->tx_coalesce_usecs; | 425 | priv->tx_usecs = coal->tx_coalesce_usecs; |
| 399 | priv->tx_frames = coal->tx_max_coalesced_frames; | 426 | priv->tx_frames = coal->tx_max_coalesced_frames; |
| 400 | for (i = 0; i < priv->tx_ring_num; i++) { | ||
| 401 | priv->tx_cq[i].moder_cnt = priv->tx_frames; | ||
| 402 | priv->tx_cq[i].moder_time = priv->tx_usecs; | ||
| 403 | if (mlx4_en_set_cq_moder(priv, &priv->tx_cq[i])) { | ||
| 404 | en_warn(priv, "Failed changing moderation " | ||
| 405 | "for TX cq %d\n", i); | ||
| 406 | } | ||
| 407 | } | ||
| 408 | } | 427 | } |
| 409 | 428 | ||
| 410 | /* Set adaptive coalescing params */ | 429 | /* Set adaptive coalescing params */ |
| @@ -414,18 +433,8 @@ static int mlx4_en_set_coalesce(struct net_device *dev, | |||
| 414 | priv->rx_usecs_high = coal->rx_coalesce_usecs_high; | 433 | priv->rx_usecs_high = coal->rx_coalesce_usecs_high; |
| 415 | priv->sample_interval = coal->rate_sample_interval; | 434 | priv->sample_interval = coal->rate_sample_interval; |
| 416 | priv->adaptive_rx_coal = coal->use_adaptive_rx_coalesce; | 435 | priv->adaptive_rx_coal = coal->use_adaptive_rx_coalesce; |
| 417 | if (priv->adaptive_rx_coal) | ||
| 418 | return 0; | ||
| 419 | 436 | ||
| 420 | for (i = 0; i < priv->rx_ring_num; i++) { | 437 | return mlx4_en_moderation_update(priv); |
| 421 | priv->rx_cq[i].moder_cnt = priv->rx_frames; | ||
| 422 | priv->rx_cq[i].moder_time = priv->rx_usecs; | ||
| 423 | priv->last_moder_time[i] = MLX4_EN_AUTO_CONF; | ||
| 424 | err = mlx4_en_set_cq_moder(priv, &priv->rx_cq[i]); | ||
| 425 | if (err) | ||
| 426 | return err; | ||
| 427 | } | ||
| 428 | return 0; | ||
| 429 | } | 438 | } |
| 430 | 439 | ||
| 431 | static int mlx4_en_set_pauseparam(struct net_device *dev, | 440 | static int mlx4_en_set_pauseparam(struct net_device *dev, |
| @@ -466,7 +475,6 @@ static int mlx4_en_set_ringparam(struct net_device *dev, | |||
| 466 | u32 rx_size, tx_size; | 475 | u32 rx_size, tx_size; |
| 467 | int port_up = 0; | 476 | int port_up = 0; |
| 468 | int err = 0; | 477 | int err = 0; |
| 469 | int i; | ||
| 470 | 478 | ||
| 471 | if (param->rx_jumbo_pending || param->rx_mini_pending) | 479 | if (param->rx_jumbo_pending || param->rx_mini_pending) |
| 472 | return -EINVAL; | 480 | return -EINVAL; |
| @@ -505,14 +513,7 @@ static int mlx4_en_set_ringparam(struct net_device *dev, | |||
| 505 | en_err(priv, "Failed starting port\n"); | 513 | en_err(priv, "Failed starting port\n"); |
| 506 | } | 514 | } |
| 507 | 515 | ||
| 508 | for (i = 0; i < priv->rx_ring_num; i++) { | 516 | err = mlx4_en_moderation_update(priv); |
| 509 | priv->rx_cq[i].moder_cnt = priv->rx_frames; | ||
| 510 | priv->rx_cq[i].moder_time = priv->rx_usecs; | ||
| 511 | priv->last_moder_time[i] = MLX4_EN_AUTO_CONF; | ||
| 512 | err = mlx4_en_set_cq_moder(priv, &priv->rx_cq[i]); | ||
| 513 | if (err) | ||
| 514 | goto out; | ||
| 515 | } | ||
| 516 | 517 | ||
| 517 | out: | 518 | out: |
| 518 | mutex_unlock(&mdev->state_lock); | 519 | mutex_unlock(&mdev->state_lock); |
