aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/netxen/netxen_nic_ethtool.c
diff options
context:
space:
mode:
authorAmit Kumar Salecha <amit@netxen.com>2009-07-27 14:15:54 -0400
committerDavid S. Miller <davem@davemloft.net>2009-07-27 14:15:54 -0400
commit7042cd8f148345bfca6c336f009c96a416674f5e (patch)
tree4a37459aeb3696283f29106abee7d50ab3ed6916 /drivers/net/netxen/netxen_nic_ethtool.c
parent028afe719855a157e32450c36b7a12e1f9e85abe (diff)
netxen: support for ethtool set ringparam
Add support for ethtool -G to tune rx and tx ring sizes per interface basis. This is only supported for NX3031 based cards. Signed-off-by: Amit Kumar Salecha <amit@netxen.com> Signed-off-by: Dhananjay Phadke <dhananjay@netxen.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/netxen/netxen_nic_ethtool.c')
-rw-r--r--drivers/net/netxen/netxen_nic_ethtool.c60
1 files changed, 59 insertions, 1 deletions
diff --git a/drivers/net/netxen/netxen_nic_ethtool.c b/drivers/net/netxen/netxen_nic_ethtool.c
index 80d286db8eb4..39a308c363c7 100644
--- a/drivers/net/netxen/netxen_nic_ethtool.c
+++ b/drivers/net/netxen/netxen_nic_ethtool.c
@@ -490,7 +490,8 @@ netxen_nic_get_eeprom(struct net_device *dev, struct ethtool_eeprom *eeprom,
490} 490}
491 491
492static void 492static void
493netxen_nic_get_ringparam(struct net_device *dev, struct ethtool_ringparam *ring) 493netxen_nic_get_ringparam(struct net_device *dev,
494 struct ethtool_ringparam *ring)
494{ 495{
495 struct netxen_adapter *adapter = netdev_priv(dev); 496 struct netxen_adapter *adapter = netdev_priv(dev);
496 497
@@ -513,6 +514,62 @@ netxen_nic_get_ringparam(struct net_device *dev, struct ethtool_ringparam *ring)
513 ring->rx_mini_pending = 0; 514 ring->rx_mini_pending = 0;
514} 515}
515 516
517static u32
518netxen_validate_ringparam(u32 val, u32 min, u32 max, char *r_name)
519{
520 u32 num_desc;
521 num_desc = max(val, min);
522 num_desc = min(num_desc, max);
523 num_desc = roundup_pow_of_two(num_desc);
524
525 if (val != num_desc) {
526 printk(KERN_INFO "%s: setting %s ring size %d instead of %d\n",
527 netxen_nic_driver_name, r_name, num_desc, val);
528 }
529
530 return num_desc;
531}
532
533static int
534netxen_nic_set_ringparam(struct net_device *dev,
535 struct ethtool_ringparam *ring)
536{
537 struct netxen_adapter *adapter = netdev_priv(dev);
538 u16 max_rcv_desc = MAX_RCV_DESCRIPTORS_10G;
539 u16 max_jumbo_desc = MAX_JUMBO_RCV_DESCRIPTORS_10G;
540 u16 num_rxd, num_jumbo_rxd, num_txd;
541
542 if (NX_IS_REVISION_P2(adapter->ahw.revision_id))
543 return -EOPNOTSUPP;
544
545 if (ring->rx_mini_pending)
546 return -EOPNOTSUPP;
547
548 if (adapter->ahw.port_type == NETXEN_NIC_GBE) {
549 max_rcv_desc = MAX_RCV_DESCRIPTORS_1G;
550 max_jumbo_desc = MAX_JUMBO_RCV_DESCRIPTORS_10G;
551 }
552
553 num_rxd = netxen_validate_ringparam(ring->rx_pending,
554 MIN_RCV_DESCRIPTORS, max_rcv_desc, "rx");
555
556 num_jumbo_rxd = netxen_validate_ringparam(ring->rx_jumbo_pending,
557 MIN_JUMBO_DESCRIPTORS, max_jumbo_desc, "rx jumbo");
558
559 num_txd = netxen_validate_ringparam(ring->tx_pending,
560 MIN_CMD_DESCRIPTORS, MAX_CMD_DESCRIPTORS, "tx");
561
562 if (num_rxd == adapter->num_rxd && num_txd == adapter->num_txd &&
563 num_jumbo_rxd == adapter->num_jumbo_rxd)
564 return 0;
565
566 adapter->num_rxd = num_rxd;
567 adapter->num_jumbo_rxd = num_jumbo_rxd;
568 adapter->num_txd = num_txd;
569
570 return netxen_nic_reset_context(adapter);
571}
572
516static void 573static void
517netxen_nic_get_pauseparam(struct net_device *dev, 574netxen_nic_get_pauseparam(struct net_device *dev,
518 struct ethtool_pauseparam *pause) 575 struct ethtool_pauseparam *pause)
@@ -894,6 +951,7 @@ struct ethtool_ops netxen_nic_ethtool_ops = {
894 .get_eeprom_len = netxen_nic_get_eeprom_len, 951 .get_eeprom_len = netxen_nic_get_eeprom_len,
895 .get_eeprom = netxen_nic_get_eeprom, 952 .get_eeprom = netxen_nic_get_eeprom,
896 .get_ringparam = netxen_nic_get_ringparam, 953 .get_ringparam = netxen_nic_get_ringparam,
954 .set_ringparam = netxen_nic_set_ringparam,
897 .get_pauseparam = netxen_nic_get_pauseparam, 955 .get_pauseparam = netxen_nic_get_pauseparam,
898 .set_pauseparam = netxen_nic_set_pauseparam, 956 .set_pauseparam = netxen_nic_set_pauseparam,
899 .set_tx_csum = ethtool_op_set_tx_csum, 957 .set_tx_csum = ethtool_op_set_tx_csum,