aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net
diff options
context:
space:
mode:
authorYevgeny Petrilin <yevgenyp@mellanox.co.il>2008-12-29 21:39:20 -0500
committerDavid S. Miller <davem@davemloft.net>2008-12-29 21:39:20 -0500
commit18cc42a3a17d19774b332e933cf34c71b0d3903c (patch)
tree91fb800e7db44ebff7201124fe487eb2089f146a /drivers/net
parent2d6a7b7559b47f81c50a1df91910edefff79b9b4 (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')
-rw-r--r--drivers/net/mlx4/en_netdev.c8
-rw-r--r--drivers/net/mlx4/en_params.c80
-rw-r--r--drivers/net/mlx4/mlx4_en.h6
3 files changed, 61 insertions, 33 deletions
diff --git a/drivers/net/mlx4/en_netdev.c b/drivers/net/mlx4/en_netdev.c
index ebada3c7aff2..15bb38d99304 100644
--- a/drivers/net/mlx4/en_netdev.c
+++ b/drivers/net/mlx4/en_netdev.c
@@ -552,7 +552,7 @@ static void mlx4_en_linkstate(struct work_struct *work)
552} 552}
553 553
554 554
555static int mlx4_en_start_port(struct net_device *dev) 555int mlx4_en_start_port(struct net_device *dev)
556{ 556{
557 struct mlx4_en_priv *priv = netdev_priv(dev); 557 struct mlx4_en_priv *priv = netdev_priv(dev);
558 struct mlx4_en_dev *mdev = priv->mdev; 558 struct mlx4_en_dev *mdev = priv->mdev;
@@ -707,7 +707,7 @@ cq_err:
707} 707}
708 708
709 709
710static void mlx4_en_stop_port(struct net_device *dev) 710void mlx4_en_stop_port(struct net_device *dev)
711{ 711{
712 struct mlx4_en_priv *priv = netdev_priv(dev); 712 struct mlx4_en_priv *priv = netdev_priv(dev);
713 struct mlx4_en_dev *mdev = priv->mdev; 713 struct mlx4_en_dev *mdev = priv->mdev;
@@ -826,7 +826,7 @@ static int mlx4_en_close(struct net_device *dev)
826 return 0; 826 return 0;
827} 827}
828 828
829static void mlx4_en_free_resources(struct mlx4_en_priv *priv) 829void mlx4_en_free_resources(struct mlx4_en_priv *priv)
830{ 830{
831 int i; 831 int i;
832 832
@@ -845,7 +845,7 @@ static void mlx4_en_free_resources(struct mlx4_en_priv *priv)
845 } 845 }
846} 846}
847 847
848static int mlx4_en_alloc_resources(struct mlx4_en_priv *priv) 848int mlx4_en_alloc_resources(struct mlx4_en_priv *priv)
849{ 849{
850 struct mlx4_en_dev *mdev = priv->mdev; 850 struct mlx4_en_dev *mdev = priv->mdev;
851 struct mlx4_en_port_profile *prof = priv->prof; 851 struct mlx4_en_port_profile *prof = priv->prof;
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]."
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(tx_ring_size1, MLX4_EN_AUTO_CONF, "Tx ring size for port 1");
69MLX4_EN_PARM_INT(tx_ring_size2, MLX4_EN_AUTO_CONF, "Tx ring size for port 2");
70MLX4_EN_PARM_INT(rx_ring_size1, MLX4_EN_AUTO_CONF, "Rx ring size for port 1");
71MLX4_EN_PARM_INT(rx_ring_size2, MLX4_EN_AUTO_CONF, "Rx ring size for port 2");
72
73
74int mlx4_en_get_profile(struct mlx4_en_dev *mdev) 68int 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
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
415static void mlx4_en_get_ringparam(struct net_device *dev, 436static 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};
diff --git a/drivers/net/mlx4/mlx4_en.h b/drivers/net/mlx4/mlx4_en.h
index e78209768def..2e96c7b2180a 100644
--- a/drivers/net/mlx4/mlx4_en.h
+++ b/drivers/net/mlx4/mlx4_en.h
@@ -489,6 +489,12 @@ void mlx4_en_destroy_netdev(struct net_device *dev);
489int mlx4_en_init_netdev(struct mlx4_en_dev *mdev, int port, 489int mlx4_en_init_netdev(struct mlx4_en_dev *mdev, int port,
490 struct mlx4_en_port_profile *prof); 490 struct mlx4_en_port_profile *prof);
491 491
492int mlx4_en_start_port(struct net_device *dev);
493void mlx4_en_stop_port(struct net_device *dev);
494
495void mlx4_en_free_resources(struct mlx4_en_priv *priv);
496int mlx4_en_alloc_resources(struct mlx4_en_priv *priv);
497
492int mlx4_en_get_profile(struct mlx4_en_dev *mdev); 498int mlx4_en_get_profile(struct mlx4_en_dev *mdev);
493 499
494int mlx4_en_create_cq(struct mlx4_en_priv *priv, struct mlx4_en_cq *cq, 500int mlx4_en_create_cq(struct mlx4_en_priv *priv, struct mlx4_en_cq *cq,