aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/netxen
diff options
context:
space:
mode:
authorNarender Kumar <narender.kumar@qlogic.com>2009-10-16 11:50:11 -0400
committerDavid S. Miller <davem@davemloft.net>2009-10-18 02:44:46 -0400
commitcaa2dd53bc2f9c44938f2f261ebe15e2f26cc51e (patch)
tree6fade4ac91dcd549acfec39891dc7bc57f0a6341 /drivers/net/netxen
parent7cecdca133ea9791adce21819b9e9eed79045f23 (diff)
netxen: sysfs control for auto firmware recovery
Firmware hang detection and recovery (reset) need to be disabled for diagnostic tools, which can run some disruptive tests. This adds a driver level control to turn off this feature by diag tools. Signed-off-by: Narender Kumar <narender.kumar@qlogic.com> Signed-off-by: Dhananjay Phadke <dhananjay@netxen.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/netxen')
-rw-r--r--drivers/net/netxen/netxen_nic.h3
-rw-r--r--drivers/net/netxen/netxen_nic_main.c50
2 files changed, 52 insertions, 1 deletions
diff --git a/drivers/net/netxen/netxen_nic.h b/drivers/net/netxen/netxen_nic.h
index db28f8a6f8af..fa7511e2f2e9 100644
--- a/drivers/net/netxen/netxen_nic.h
+++ b/drivers/net/netxen/netxen_nic.h
@@ -1044,6 +1044,9 @@ typedef struct {
1044#define LINKEVENT_LINKSPEED_MBPS 0 1044#define LINKEVENT_LINKSPEED_MBPS 0
1045#define LINKEVENT_LINKSPEED_ENCODED 1 1045#define LINKEVENT_LINKSPEED_ENCODED 1
1046 1046
1047#define AUTO_FW_RESET_ENABLED 0xEF10AF12
1048#define AUTO_FW_RESET_DISABLED 0xDCBAAF12
1049
1047/* firmware response header: 1050/* firmware response header:
1048 * 63:58 - message type 1051 * 63:58 - message type
1049 * 57:56 - owner 1052 * 57:56 - owner
diff --git a/drivers/net/netxen/netxen_nic_main.c b/drivers/net/netxen/netxen_nic_main.c
index 30d9afe7366a..1071f090a124 100644
--- a/drivers/net/netxen/netxen_nic_main.c
+++ b/drivers/net/netxen/netxen_nic_main.c
@@ -52,6 +52,8 @@ static int use_msi = 1;
52 52
53static int use_msi_x = 1; 53static int use_msi_x = 1;
54 54
55static unsigned long auto_fw_reset = AUTO_FW_RESET_ENABLED;
56
55/* Local functions to NetXen NIC driver */ 57/* Local functions to NetXen NIC driver */
56static int __devinit netxen_nic_probe(struct pci_dev *pdev, 58static int __devinit netxen_nic_probe(struct pci_dev *pdev,
57 const struct pci_device_id *ent); 59 const struct pci_device_id *ent);
@@ -2264,7 +2266,8 @@ netxen_check_health(struct netxen_adapter *adapter)
2264 dev_info(&netdev->dev, "firmware hang detected\n"); 2266 dev_info(&netdev->dev, "firmware hang detected\n");
2265 2267
2266detach: 2268detach:
2267 if (!test_and_set_bit(__NX_RESETTING, &adapter->state)) 2269 if ((auto_fw_reset == AUTO_FW_RESET_ENABLED) &&
2270 !test_and_set_bit(__NX_RESETTING, &adapter->state))
2268 netxen_schedule_work(adapter, netxen_detach_work, 0); 2271 netxen_schedule_work(adapter, netxen_detach_work, 0);
2269 return 1; 2272 return 1;
2270} 2273}
@@ -2496,6 +2499,41 @@ static struct bin_attribute bin_attr_mem = {
2496 .write = netxen_sysfs_write_mem, 2499 .write = netxen_sysfs_write_mem,
2497}; 2500};
2498 2501
2502static ssize_t
2503netxen_store_auto_fw_reset(struct module_attribute *mattr,
2504 struct module *mod, const char *buf, size_t count)
2505
2506{
2507 unsigned long new;
2508
2509 if (strict_strtoul(buf, 16, &new))
2510 return -EINVAL;
2511
2512 if ((new == AUTO_FW_RESET_ENABLED) || (new == AUTO_FW_RESET_DISABLED)) {
2513 auto_fw_reset = new;
2514 return count;
2515 }
2516
2517 return -EINVAL;
2518}
2519
2520static ssize_t
2521netxen_show_auto_fw_reset(struct module_attribute *mattr,
2522 struct module *mod, char *buf)
2523
2524{
2525 if (auto_fw_reset == AUTO_FW_RESET_ENABLED)
2526 return sprintf(buf, "enabled\n");
2527 else
2528 return sprintf(buf, "disabled\n");
2529}
2530
2531static struct module_attribute mod_attr_fw_reset = {
2532 .attr = {.name = "auto_fw_reset", .mode = (S_IRUGO | S_IWUSR)},
2533 .show = netxen_show_auto_fw_reset,
2534 .store = netxen_store_auto_fw_reset,
2535};
2536
2499static void 2537static void
2500netxen_create_sysfs_entries(struct netxen_adapter *adapter) 2538netxen_create_sysfs_entries(struct netxen_adapter *adapter)
2501{ 2539{
@@ -2700,6 +2738,8 @@ static struct pci_driver netxen_driver = {
2700 2738
2701static int __init netxen_init_module(void) 2739static int __init netxen_init_module(void)
2702{ 2740{
2741 struct module *mod = THIS_MODULE;
2742
2703 printk(KERN_INFO "%s\n", netxen_nic_driver_string); 2743 printk(KERN_INFO "%s\n", netxen_nic_driver_string);
2704 2744
2705#ifdef CONFIG_INET 2745#ifdef CONFIG_INET
@@ -2707,6 +2747,10 @@ static int __init netxen_init_module(void)
2707 register_inetaddr_notifier(&netxen_inetaddr_cb); 2747 register_inetaddr_notifier(&netxen_inetaddr_cb);
2708#endif 2748#endif
2709 2749
2750 if (sysfs_create_file(&mod->mkobj.kobj, &mod_attr_fw_reset.attr))
2751 printk(KERN_ERR "%s: Failed to create auto_fw_reset "
2752 "sysfs entry.", netxen_nic_driver_name);
2753
2710 return pci_register_driver(&netxen_driver); 2754 return pci_register_driver(&netxen_driver);
2711} 2755}
2712 2756
@@ -2714,6 +2758,10 @@ module_init(netxen_init_module);
2714 2758
2715static void __exit netxen_exit_module(void) 2759static void __exit netxen_exit_module(void)
2716{ 2760{
2761 struct module *mod = THIS_MODULE;
2762
2763 sysfs_remove_file(&mod->mkobj.kobj, &mod_attr_fw_reset.attr);
2764
2717 pci_unregister_driver(&netxen_driver); 2765 pci_unregister_driver(&netxen_driver);
2718 2766
2719#ifdef CONFIG_INET 2767#ifdef CONFIG_INET