diff options
author | Yevgeny Petrilin <yevgenyp@mellanox.co.il> | 2008-12-29 21:39:20 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2008-12-29 21:39:20 -0500 |
commit | 18cc42a3a17d19774b332e933cf34c71b0d3903c (patch) | |
tree | 91fb800e7db44ebff7201124fe487eb2089f146a /drivers/net/mlx4/en_params.c | |
parent | 2d6a7b7559b47f81c50a1df91910edefff79b9b4 (diff) |
mlx4_en: Added "set_ringparam" Ethtool interface implementation
Now using Ethtool to determine ring sizes, removed the module parameters
that controlled those values.
Modifying ring size requires restart of the interface.
Signed-off-by: Yevgeny Petrilin <yevgenyp@mellanox.co.il>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/mlx4/en_params.c')
-rw-r--r-- | drivers/net/mlx4/en_params.c | 80 |
1 files changed, 51 insertions, 29 deletions
diff --git a/drivers/net/mlx4/en_params.c b/drivers/net/mlx4/en_params.c index 6483ae9d45b1..cfeef0f1bacc 100644 --- a/drivers/net/mlx4/en_params.c +++ b/drivers/net/mlx4/en_params.c | |||
@@ -65,12 +65,6 @@ MLX4_EN_PARM_INT(pfctx, 0, "Priority based Flow Control policy on TX[7:0]." | |||
65 | MLX4_EN_PARM_INT(pfcrx, 0, "Priority based Flow Control policy on RX[7:0]." | 65 | MLX4_EN_PARM_INT(pfcrx, 0, "Priority based Flow Control policy on RX[7:0]." |
66 | " Per priority bit mask"); | 66 | " Per priority bit mask"); |
67 | 67 | ||
68 | MLX4_EN_PARM_INT(tx_ring_size1, MLX4_EN_AUTO_CONF, "Tx ring size for port 1"); | ||
69 | MLX4_EN_PARM_INT(tx_ring_size2, MLX4_EN_AUTO_CONF, "Tx ring size for port 2"); | ||
70 | MLX4_EN_PARM_INT(rx_ring_size1, MLX4_EN_AUTO_CONF, "Rx ring size for port 1"); | ||
71 | MLX4_EN_PARM_INT(rx_ring_size2, MLX4_EN_AUTO_CONF, "Rx ring size for port 2"); | ||
72 | |||
73 | |||
74 | int mlx4_en_get_profile(struct mlx4_en_dev *mdev) | 68 | int mlx4_en_get_profile(struct mlx4_en_dev *mdev) |
75 | { | 69 | { |
76 | struct mlx4_en_profile *params = &mdev->profile; | 70 | struct mlx4_en_profile *params = &mdev->profile; |
@@ -84,6 +78,8 @@ int mlx4_en_get_profile(struct mlx4_en_dev *mdev) | |||
84 | params->prof[i].rx_ppp = pfcrx; | 78 | params->prof[i].rx_ppp = pfcrx; |
85 | params->prof[i].tx_pause = 1; | 79 | params->prof[i].tx_pause = 1; |
86 | params->prof[i].tx_ppp = pfctx; | 80 | params->prof[i].tx_ppp = pfctx; |
81 | params->prof[i].tx_ring_size = MLX4_EN_DEF_TX_RING_SIZE; | ||
82 | params->prof[i].rx_ring_size = MLX4_EN_DEF_RX_RING_SIZE; | ||
87 | } | 83 | } |
88 | if (pfcrx || pfctx) { | 84 | if (pfcrx || pfctx) { |
89 | params->prof[1].tx_ring_num = MLX4_EN_TX_RING_NUM; | 85 | params->prof[1].tx_ring_num = MLX4_EN_TX_RING_NUM; |
@@ -93,29 +89,6 @@ int mlx4_en_get_profile(struct mlx4_en_dev *mdev) | |||
93 | params->prof[2].tx_ring_num = 1; | 89 | params->prof[2].tx_ring_num = 1; |
94 | } | 90 | } |
95 | 91 | ||
96 | if (tx_ring_size1 == MLX4_EN_AUTO_CONF) | ||
97 | tx_ring_size1 = MLX4_EN_DEF_TX_RING_SIZE; | ||
98 | params->prof[1].tx_ring_size = | ||
99 | (tx_ring_size1 < MLX4_EN_MIN_TX_SIZE) ? | ||
100 | MLX4_EN_MIN_TX_SIZE : roundup_pow_of_two(tx_ring_size1); | ||
101 | |||
102 | if (tx_ring_size2 == MLX4_EN_AUTO_CONF) | ||
103 | tx_ring_size2 = MLX4_EN_DEF_TX_RING_SIZE; | ||
104 | params->prof[2].tx_ring_size = | ||
105 | (tx_ring_size2 < MLX4_EN_MIN_TX_SIZE) ? | ||
106 | MLX4_EN_MIN_TX_SIZE : roundup_pow_of_two(tx_ring_size2); | ||
107 | |||
108 | if (rx_ring_size1 == MLX4_EN_AUTO_CONF) | ||
109 | rx_ring_size1 = MLX4_EN_DEF_RX_RING_SIZE; | ||
110 | params->prof[1].rx_ring_size = | ||
111 | (rx_ring_size1 < MLX4_EN_MIN_RX_SIZE) ? | ||
112 | MLX4_EN_MIN_RX_SIZE : roundup_pow_of_two(rx_ring_size1); | ||
113 | |||
114 | if (rx_ring_size2 == MLX4_EN_AUTO_CONF) | ||
115 | rx_ring_size2 = MLX4_EN_DEF_RX_RING_SIZE; | ||
116 | params->prof[2].rx_ring_size = | ||
117 | (rx_ring_size2 < MLX4_EN_MIN_RX_SIZE) ? | ||
118 | MLX4_EN_MIN_RX_SIZE : roundup_pow_of_two(rx_ring_size2); | ||
119 | return 0; | 92 | return 0; |
120 | } | 93 | } |
121 | 94 | ||
@@ -412,6 +385,54 @@ static void mlx4_en_get_pauseparam(struct net_device *dev, | |||
412 | pause->rx_pause = priv->prof->rx_pause; | 385 | pause->rx_pause = priv->prof->rx_pause; |
413 | } | 386 | } |
414 | 387 | ||
388 | static int mlx4_en_set_ringparam(struct net_device *dev, | ||
389 | struct ethtool_ringparam *param) | ||
390 | { | ||
391 | struct mlx4_en_priv *priv = netdev_priv(dev); | ||
392 | struct mlx4_en_dev *mdev = priv->mdev; | ||
393 | u32 rx_size, tx_size; | ||
394 | int port_up = 0; | ||
395 | int err = 0; | ||
396 | |||
397 | if (param->rx_jumbo_pending || param->rx_mini_pending) | ||
398 | return -EINVAL; | ||
399 | |||
400 | rx_size = roundup_pow_of_two(param->rx_pending); | ||
401 | rx_size = max_t(u32, rx_size, MLX4_EN_MIN_RX_SIZE); | ||
402 | tx_size = roundup_pow_of_two(param->tx_pending); | ||
403 | tx_size = max_t(u32, tx_size, MLX4_EN_MIN_TX_SIZE); | ||
404 | |||
405 | if (rx_size == priv->prof->rx_ring_size && | ||
406 | tx_size == priv->prof->tx_ring_size) | ||
407 | return 0; | ||
408 | |||
409 | mutex_lock(&mdev->state_lock); | ||
410 | if (priv->port_up) { | ||
411 | port_up = 1; | ||
412 | mlx4_en_stop_port(dev); | ||
413 | } | ||
414 | |||
415 | mlx4_en_free_resources(priv); | ||
416 | |||
417 | priv->prof->tx_ring_size = tx_size; | ||
418 | priv->prof->rx_ring_size = rx_size; | ||
419 | |||
420 | err = mlx4_en_alloc_resources(priv); | ||
421 | if (err) { | ||
422 | mlx4_err(mdev, "Failed reallocating port resources\n"); | ||
423 | goto out; | ||
424 | } | ||
425 | if (port_up) { | ||
426 | err = mlx4_en_start_port(dev); | ||
427 | if (err) | ||
428 | mlx4_err(mdev, "Failed starting port\n"); | ||
429 | } | ||
430 | |||
431 | out: | ||
432 | mutex_unlock(&mdev->state_lock); | ||
433 | return err; | ||
434 | } | ||
435 | |||
415 | static void mlx4_en_get_ringparam(struct net_device *dev, | 436 | static void mlx4_en_get_ringparam(struct net_device *dev, |
416 | struct ethtool_ringparam *param) | 437 | struct ethtool_ringparam *param) |
417 | { | 438 | { |
@@ -451,6 +472,7 @@ const struct ethtool_ops mlx4_en_ethtool_ops = { | |||
451 | .get_pauseparam = mlx4_en_get_pauseparam, | 472 | .get_pauseparam = mlx4_en_get_pauseparam, |
452 | .set_pauseparam = mlx4_en_set_pauseparam, | 473 | .set_pauseparam = mlx4_en_set_pauseparam, |
453 | .get_ringparam = mlx4_en_get_ringparam, | 474 | .get_ringparam = mlx4_en_get_ringparam, |
475 | .set_ringparam = mlx4_en_set_ringparam, | ||
454 | .get_flags = ethtool_op_get_flags, | 476 | .get_flags = ethtool_op_get_flags, |
455 | .set_flags = ethtool_op_set_flags, | 477 | .set_flags = ethtool_op_set_flags, |
456 | }; | 478 | }; |