diff options
author | Amit Kumar Salecha <amit@netxen.com> | 2009-07-27 14:15:54 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2009-07-27 14:15:54 -0400 |
commit | 7042cd8f148345bfca6c336f009c96a416674f5e (patch) | |
tree | 4a37459aeb3696283f29106abee7d50ab3ed6916 /drivers | |
parent | 028afe719855a157e32450c36b7a12e1f9e85abe (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')
-rw-r--r-- | drivers/net/netxen/netxen_nic.h | 3 | ||||
-rw-r--r-- | drivers/net/netxen/netxen_nic_ethtool.c | 60 | ||||
-rw-r--r-- | drivers/net/netxen/netxen_nic_main.c | 45 |
3 files changed, 97 insertions, 11 deletions
diff --git a/drivers/net/netxen/netxen_nic.h b/drivers/net/netxen/netxen_nic.h index d01cc092450e..b68a70dc720e 100644 --- a/drivers/net/netxen/netxen_nic.h +++ b/drivers/net/netxen/netxen_nic.h | |||
@@ -1427,6 +1427,9 @@ struct net_device_stats *netxen_nic_get_stats(struct net_device *netdev); | |||
1427 | void netxen_nic_update_cmd_producer(struct netxen_adapter *adapter, | 1427 | void netxen_nic_update_cmd_producer(struct netxen_adapter *adapter, |
1428 | struct nx_host_tx_ring *tx_ring); | 1428 | struct nx_host_tx_ring *tx_ring); |
1429 | 1429 | ||
1430 | /* Functions from netxen_nic_main.c */ | ||
1431 | int netxen_nic_reset_context(struct netxen_adapter *); | ||
1432 | |||
1430 | /* | 1433 | /* |
1431 | * NetXen Board information | 1434 | * NetXen Board information |
1432 | */ | 1435 | */ |
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 | ||
492 | static void | 492 | static void |
493 | netxen_nic_get_ringparam(struct net_device *dev, struct ethtool_ringparam *ring) | 493 | netxen_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 | ||
517 | static u32 | ||
518 | netxen_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 | |||
533 | static int | ||
534 | netxen_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 | |||
516 | static void | 573 | static void |
517 | netxen_nic_get_pauseparam(struct net_device *dev, | 574 | netxen_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, |
diff --git a/drivers/net/netxen/netxen_nic_main.c b/drivers/net/netxen/netxen_nic_main.c index ff7ee9c43ef5..2bbefa6a37bc 100644 --- a/drivers/net/netxen/netxen_nic_main.c +++ b/drivers/net/netxen/netxen_nic_main.c | |||
@@ -910,6 +910,9 @@ netxen_nic_attach(struct netxen_adapter *adapter) | |||
910 | struct nx_host_rds_ring *rds_ring; | 910 | struct nx_host_rds_ring *rds_ring; |
911 | struct nx_host_tx_ring *tx_ring; | 911 | struct nx_host_tx_ring *tx_ring; |
912 | 912 | ||
913 | if (adapter->is_up == NETXEN_ADAPTER_UP_MAGIC) | ||
914 | return 0; | ||
915 | |||
913 | err = netxen_init_firmware(adapter); | 916 | err = netxen_init_firmware(adapter); |
914 | if (err != 0) { | 917 | if (err != 0) { |
915 | printk(KERN_ERR "Failed to init firmware\n"); | 918 | printk(KERN_ERR "Failed to init firmware\n"); |
@@ -973,6 +976,9 @@ err_out_free_sw: | |||
973 | static void | 976 | static void |
974 | netxen_nic_detach(struct netxen_adapter *adapter) | 977 | netxen_nic_detach(struct netxen_adapter *adapter) |
975 | { | 978 | { |
979 | if (adapter->is_up != NETXEN_ADAPTER_UP_MAGIC) | ||
980 | return; | ||
981 | |||
976 | netxen_free_hw_resources(adapter); | 982 | netxen_free_hw_resources(adapter); |
977 | netxen_release_rx_buffers(adapter); | 983 | netxen_release_rx_buffers(adapter); |
978 | netxen_nic_free_irq(adapter); | 984 | netxen_nic_free_irq(adapter); |
@@ -981,6 +987,30 @@ netxen_nic_detach(struct netxen_adapter *adapter) | |||
981 | adapter->is_up = 0; | 987 | adapter->is_up = 0; |
982 | } | 988 | } |
983 | 989 | ||
990 | int | ||
991 | netxen_nic_reset_context(struct netxen_adapter *adapter) | ||
992 | { | ||
993 | int err = 0; | ||
994 | struct net_device *netdev = adapter->netdev; | ||
995 | |||
996 | if (adapter->is_up == NETXEN_ADAPTER_UP_MAGIC) { | ||
997 | |||
998 | if (netif_running(netdev)) | ||
999 | netxen_nic_down(adapter, netdev); | ||
1000 | |||
1001 | netxen_nic_detach(adapter); | ||
1002 | |||
1003 | err = netxen_nic_attach(adapter); | ||
1004 | if (err) | ||
1005 | goto done; | ||
1006 | |||
1007 | if (netif_running(netdev)) | ||
1008 | err = netxen_nic_up(adapter, netdev); | ||
1009 | } | ||
1010 | done: | ||
1011 | return err; | ||
1012 | } | ||
1013 | |||
984 | static int | 1014 | static int |
985 | netxen_setup_netdev(struct netxen_adapter *adapter, | 1015 | netxen_setup_netdev(struct netxen_adapter *adapter, |
986 | struct net_device *netdev) | 1016 | struct net_device *netdev) |
@@ -1202,9 +1232,7 @@ static void __devexit netxen_nic_remove(struct pci_dev *pdev) | |||
1202 | 1232 | ||
1203 | unregister_netdev(netdev); | 1233 | unregister_netdev(netdev); |
1204 | 1234 | ||
1205 | if (adapter->is_up == NETXEN_ADAPTER_UP_MAGIC) { | 1235 | netxen_nic_detach(adapter); |
1206 | netxen_nic_detach(adapter); | ||
1207 | } | ||
1208 | 1236 | ||
1209 | if (adapter->portnum == 0) | 1237 | if (adapter->portnum == 0) |
1210 | netxen_free_dummy_dma(adapter); | 1238 | netxen_free_dummy_dma(adapter); |
@@ -1236,8 +1264,7 @@ netxen_nic_suspend(struct pci_dev *pdev, pm_message_t state) | |||
1236 | if (netif_running(netdev)) | 1264 | if (netif_running(netdev)) |
1237 | netxen_nic_down(adapter, netdev); | 1265 | netxen_nic_down(adapter, netdev); |
1238 | 1266 | ||
1239 | if (adapter->is_up == NETXEN_ADAPTER_UP_MAGIC) | 1267 | netxen_nic_detach(adapter); |
1240 | netxen_nic_detach(adapter); | ||
1241 | 1268 | ||
1242 | pci_save_state(pdev); | 1269 | pci_save_state(pdev); |
1243 | 1270 | ||
@@ -1298,11 +1325,9 @@ static int netxen_nic_open(struct net_device *netdev) | |||
1298 | if (adapter->driver_mismatch) | 1325 | if (adapter->driver_mismatch) |
1299 | return -EIO; | 1326 | return -EIO; |
1300 | 1327 | ||
1301 | if (adapter->is_up != NETXEN_ADAPTER_UP_MAGIC) { | 1328 | err = netxen_nic_attach(adapter); |
1302 | err = netxen_nic_attach(adapter); | 1329 | if (err) |
1303 | if (err) | 1330 | return err; |
1304 | return err; | ||
1305 | } | ||
1306 | 1331 | ||
1307 | err = netxen_nic_up(adapter, netdev); | 1332 | err = netxen_nic_up(adapter, netdev); |
1308 | if (err) | 1333 | if (err) |