aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/mlx4/en_params.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/mlx4/en_params.c')
-rw-r--r--drivers/net/mlx4/en_params.c87
1 files changed, 52 insertions, 35 deletions
diff --git a/drivers/net/mlx4/en_params.c b/drivers/net/mlx4/en_params.c
index 047b37f5a747..cfeef0f1bacc 100644
--- a/drivers/net/mlx4/en_params.c
+++ b/drivers/net/mlx4/en_params.c
@@ -65,15 +65,6 @@ MLX4_EN_PARM_INT(pfctx, 0, "Priority based Flow Control policy on TX[7:0]."
65MLX4_EN_PARM_INT(pfcrx, 0, "Priority based Flow Control policy on RX[7:0]." 65MLX4_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
68MLX4_EN_PARM_INT(rx_ring_num1, 0, "Number or Rx rings for port 1 (0 = #cores)");
69MLX4_EN_PARM_INT(rx_ring_num2, 0, "Number or Rx rings for port 2 (0 = #cores)");
70
71MLX4_EN_PARM_INT(tx_ring_size1, MLX4_EN_AUTO_CONF, "Tx ring size for port 1");
72MLX4_EN_PARM_INT(tx_ring_size2, MLX4_EN_AUTO_CONF, "Tx ring size for port 2");
73MLX4_EN_PARM_INT(rx_ring_size1, MLX4_EN_AUTO_CONF, "Rx ring size for port 1");
74MLX4_EN_PARM_INT(rx_ring_size2, MLX4_EN_AUTO_CONF, "Rx ring size for port 2");
75
76
77int mlx4_en_get_profile(struct mlx4_en_dev *mdev) 68int mlx4_en_get_profile(struct mlx4_en_dev *mdev)
78{ 69{
79 struct mlx4_en_profile *params = &mdev->profile; 70 struct mlx4_en_profile *params = &mdev->profile;
@@ -87,6 +78,8 @@ int mlx4_en_get_profile(struct mlx4_en_dev *mdev)
87 params->prof[i].rx_ppp = pfcrx; 78 params->prof[i].rx_ppp = pfcrx;
88 params->prof[i].tx_pause = 1; 79 params->prof[i].tx_pause = 1;
89 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;
90 } 83 }
91 if (pfcrx || pfctx) { 84 if (pfcrx || pfctx) {
92 params->prof[1].tx_ring_num = MLX4_EN_TX_RING_NUM; 85 params->prof[1].tx_ring_num = MLX4_EN_TX_RING_NUM;
@@ -95,32 +88,7 @@ int mlx4_en_get_profile(struct mlx4_en_dev *mdev)
95 params->prof[1].tx_ring_num = 1; 88 params->prof[1].tx_ring_num = 1;
96 params->prof[2].tx_ring_num = 1; 89 params->prof[2].tx_ring_num = 1;
97 } 90 }
98 params->prof[1].rx_ring_num = min_t(int, rx_ring_num1, MAX_RX_RINGS); 91
99 params->prof[2].rx_ring_num = min_t(int, rx_ring_num2, MAX_RX_RINGS);
100
101 if (tx_ring_size1 == MLX4_EN_AUTO_CONF)
102 tx_ring_size1 = MLX4_EN_DEF_TX_RING_SIZE;
103 params->prof[1].tx_ring_size =
104 (tx_ring_size1 < MLX4_EN_MIN_TX_SIZE) ?
105 MLX4_EN_MIN_TX_SIZE : roundup_pow_of_two(tx_ring_size1);
106
107 if (tx_ring_size2 == MLX4_EN_AUTO_CONF)
108 tx_ring_size2 = MLX4_EN_DEF_TX_RING_SIZE;
109 params->prof[2].tx_ring_size =
110 (tx_ring_size2 < MLX4_EN_MIN_TX_SIZE) ?
111 MLX4_EN_MIN_TX_SIZE : roundup_pow_of_two(tx_ring_size2);
112
113 if (rx_ring_size1 == MLX4_EN_AUTO_CONF)
114 rx_ring_size1 = MLX4_EN_DEF_RX_RING_SIZE;
115 params->prof[1].rx_ring_size =
116 (rx_ring_size1 < MLX4_EN_MIN_RX_SIZE) ?
117 MLX4_EN_MIN_RX_SIZE : roundup_pow_of_two(rx_ring_size1);
118
119 if (rx_ring_size2 == MLX4_EN_AUTO_CONF)
120 rx_ring_size2 = MLX4_EN_DEF_RX_RING_SIZE;
121 params->prof[2].rx_ring_size =
122 (rx_ring_size2 < MLX4_EN_MIN_RX_SIZE) ?
123 MLX4_EN_MIN_RX_SIZE : roundup_pow_of_two(rx_ring_size2);
124 return 0; 92 return 0;
125} 93}
126 94
@@ -417,6 +385,54 @@ static void mlx4_en_get_pauseparam(struct net_device *dev,
417 pause->rx_pause = priv->prof->rx_pause; 385 pause->rx_pause = priv->prof->rx_pause;
418} 386}
419 387
388static 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
431out:
432 mutex_unlock(&mdev->state_lock);
433 return err;
434}
435
420static void mlx4_en_get_ringparam(struct net_device *dev, 436static void mlx4_en_get_ringparam(struct net_device *dev,
421 struct ethtool_ringparam *param) 437 struct ethtool_ringparam *param)
422{ 438{
@@ -456,6 +472,7 @@ const struct ethtool_ops mlx4_en_ethtool_ops = {
456 .get_pauseparam = mlx4_en_get_pauseparam, 472 .get_pauseparam = mlx4_en_get_pauseparam,
457 .set_pauseparam = mlx4_en_set_pauseparam, 473 .set_pauseparam = mlx4_en_set_pauseparam,
458 .get_ringparam = mlx4_en_get_ringparam, 474 .get_ringparam = mlx4_en_get_ringparam,
475 .set_ringparam = mlx4_en_set_ringparam,
459 .get_flags = ethtool_op_get_flags, 476 .get_flags = ethtool_op_get_flags,
460 .set_flags = ethtool_op_set_flags, 477 .set_flags = ethtool_op_set_flags,
461}; 478};