aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/netxen/netxen_nic_ethtool.c
diff options
context:
space:
mode:
authorAmit S. Kale <amitkale@netxen.com>2007-02-05 10:40:49 -0500
committerJeff Garzik <jeff@garzik.org>2007-02-06 19:08:03 -0500
commit27d2ab54bdfaffdbdc1a81100dc53c6479c9db35 (patch)
tree27817bbfeb065a2a75ecce6f331596f002ddae7d /drivers/net/netxen/netxen_nic_ethtool.c
parent1fcca1a5fc81689d191b7132318970c969b4b635 (diff)
NetXen: Added ethtool support for user level tools.
NetXen: Added ethtool support for user level firmware management utilities. Signed-off-by: Amit S. Kale <amitkale@netxen.com> Signed-off-by: Jeff Garzik <jeff@garzik.org>
Diffstat (limited to 'drivers/net/netxen/netxen_nic_ethtool.c')
-rw-r--r--drivers/net/netxen/netxen_nic_ethtool.c96
1 files changed, 81 insertions, 15 deletions
diff --git a/drivers/net/netxen/netxen_nic_ethtool.c b/drivers/net/netxen/netxen_nic_ethtool.c
index c381d77a7336..cc0efe213e01 100644
--- a/drivers/net/netxen/netxen_nic_ethtool.c
+++ b/drivers/net/netxen/netxen_nic_ethtool.c
@@ -32,6 +32,7 @@
32 */ 32 */
33 33
34#include <linux/types.h> 34#include <linux/types.h>
35#include <linux/delay.h>
35#include <asm/uaccess.h> 36#include <asm/uaccess.h>
36#include <linux/pci.h> 37#include <linux/pci.h>
37#include <asm/io.h> 38#include <asm/io.h>
@@ -94,17 +95,7 @@ static const char netxen_nic_gstrings_test[][ETH_GSTRING_LEN] = {
94 95
95static int netxen_nic_get_eeprom_len(struct net_device *dev) 96static int netxen_nic_get_eeprom_len(struct net_device *dev)
96{ 97{
97 struct netxen_port *port = netdev_priv(dev); 98 return FLASH_TOTAL_SIZE;
98 struct netxen_adapter *adapter = port->adapter;
99 int n;
100
101 if ((netxen_rom_fast_read(adapter, 0, &n) == 0)
102 && (n & NETXEN_ROM_ROUNDUP)) {
103 n &= ~NETXEN_ROM_ROUNDUP;
104 if (n < NETXEN_MAX_EEPROM_LEN)
105 return n;
106 }
107 return 0;
108} 99}
109 100
110static void 101static void
@@ -440,18 +431,92 @@ netxen_nic_get_eeprom(struct net_device *dev, struct ethtool_eeprom *eeprom,
440 struct netxen_port *port = netdev_priv(dev); 431 struct netxen_port *port = netdev_priv(dev);
441 struct netxen_adapter *adapter = port->adapter; 432 struct netxen_adapter *adapter = port->adapter;
442 int offset; 433 int offset;
434 int ret;
443 435
444 if (eeprom->len == 0) 436 if (eeprom->len == 0)
445 return -EINVAL; 437 return -EINVAL;
446 438
447 eeprom->magic = (port->pdev)->vendor | ((port->pdev)->device << 16); 439 eeprom->magic = (port->pdev)->vendor | ((port->pdev)->device << 16);
448 for (offset = 0; offset < eeprom->len; offset++) 440 offset = eeprom->offset;
449 if (netxen_rom_fast_read 441
450 (adapter, (8 * offset) + 8, (int *)eeprom->data) == -1) 442 ret = netxen_rom_fast_read_words(adapter, offset, bytes,
451 return -EIO; 443 eeprom->len);
444 if (ret < 0)
445 return ret;
446
452 return 0; 447 return 0;
453} 448}
454 449
450static int
451netxen_nic_set_eeprom(struct net_device *dev, struct ethtool_eeprom *eeprom,
452 u8 * bytes)
453{
454 struct netxen_port *port = netdev_priv(dev);
455 struct netxen_adapter *adapter = port->adapter;
456 int offset = eeprom->offset;
457 static int flash_start;
458 static int ready_to_flash;
459 int ret;
460
461 if (flash_start == 0) {
462 ret = netxen_flash_unlock(adapter);
463 if (ret < 0) {
464 printk(KERN_ERR "%s: Flash unlock failed.\n",
465 netxen_nic_driver_name);
466 return ret;
467 }
468 printk(KERN_INFO "%s: flash unlocked. \n",
469 netxen_nic_driver_name);
470 ret = netxen_flash_erase_secondary(adapter);
471 if (ret != FLASH_SUCCESS) {
472 printk(KERN_ERR "%s: Flash erase failed.\n",
473 netxen_nic_driver_name);
474 return ret;
475 }
476 printk(KERN_INFO "%s: secondary flash erased successfully.\n",
477 netxen_nic_driver_name);
478 flash_start = 1;
479 return 0;
480 }
481
482 if (offset == BOOTLD_START) {
483 ret = netxen_flash_erase_primary(adapter);
484 if (ret != FLASH_SUCCESS) {
485 printk(KERN_ERR "%s: Flash erase failed.\n",
486 netxen_nic_driver_name);
487 return ret;
488 }
489
490 ret = netxen_rom_se(adapter, USER_START);
491 if (ret != FLASH_SUCCESS)
492 return ret;
493 ret = netxen_rom_se(adapter, FIXED_START);
494 if (ret != FLASH_SUCCESS)
495 return ret;
496
497 printk(KERN_INFO "%s: primary flash erased successfully\n",
498 netxen_nic_driver_name);
499
500 ret = netxen_backup_crbinit(adapter);
501 if (ret != FLASH_SUCCESS) {
502 printk(KERN_ERR "%s: CRBinit backup failed.\n",
503 netxen_nic_driver_name);
504 return ret;
505 }
506 printk(KERN_INFO "%s: CRBinit backup done.\n",
507 netxen_nic_driver_name);
508 ready_to_flash = 1;
509 }
510
511 if (!ready_to_flash) {
512 printk(KERN_ERR "%s: Invalid write sequence, returning...\n",
513 netxen_nic_driver_name);
514 return -EINVAL;
515 }
516
517 return netxen_rom_fast_write_words(adapter, offset, bytes, eeprom->len);
518}
519
455static void 520static void
456netxen_nic_get_ringparam(struct net_device *dev, struct ethtool_ringparam *ring) 521netxen_nic_get_ringparam(struct net_device *dev, struct ethtool_ringparam *ring)
457{ 522{
@@ -721,6 +786,7 @@ struct ethtool_ops netxen_nic_ethtool_ops = {
721 .get_link = netxen_nic_get_link, 786 .get_link = netxen_nic_get_link,
722 .get_eeprom_len = netxen_nic_get_eeprom_len, 787 .get_eeprom_len = netxen_nic_get_eeprom_len,
723 .get_eeprom = netxen_nic_get_eeprom, 788 .get_eeprom = netxen_nic_get_eeprom,
789 .set_eeprom = netxen_nic_set_eeprom,
724 .get_ringparam = netxen_nic_get_ringparam, 790 .get_ringparam = netxen_nic_get_ringparam,
725 .get_pauseparam = netxen_nic_get_pauseparam, 791 .get_pauseparam = netxen_nic_get_pauseparam,
726 .set_pauseparam = netxen_nic_set_pauseparam, 792 .set_pauseparam = netxen_nic_set_pauseparam,