Commit caa2dd53 authored by Narender Kumar's avatar Narender Kumar Committed by David S. Miller

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: default avatarNarender Kumar <narender.kumar@qlogic.com>
Signed-off-by: default avatarDhananjay Phadke <dhananjay@netxen.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 7cecdca1
...@@ -1044,6 +1044,9 @@ typedef struct { ...@@ -1044,6 +1044,9 @@ typedef struct {
#define LINKEVENT_LINKSPEED_MBPS 0 #define LINKEVENT_LINKSPEED_MBPS 0
#define LINKEVENT_LINKSPEED_ENCODED 1 #define LINKEVENT_LINKSPEED_ENCODED 1
#define AUTO_FW_RESET_ENABLED 0xEF10AF12
#define AUTO_FW_RESET_DISABLED 0xDCBAAF12
/* firmware response header: /* firmware response header:
* 63:58 - message type * 63:58 - message type
* 57:56 - owner * 57:56 - owner
......
...@@ -52,6 +52,8 @@ static int use_msi = 1; ...@@ -52,6 +52,8 @@ static int use_msi = 1;
static int use_msi_x = 1; static int use_msi_x = 1;
static unsigned long auto_fw_reset = AUTO_FW_RESET_ENABLED;
/* Local functions to NetXen NIC driver */ /* Local functions to NetXen NIC driver */
static int __devinit netxen_nic_probe(struct pci_dev *pdev, static int __devinit netxen_nic_probe(struct pci_dev *pdev,
const struct pci_device_id *ent); const struct pci_device_id *ent);
...@@ -2264,7 +2266,8 @@ netxen_check_health(struct netxen_adapter *adapter) ...@@ -2264,7 +2266,8 @@ netxen_check_health(struct netxen_adapter *adapter)
dev_info(&netdev->dev, "firmware hang detected\n"); dev_info(&netdev->dev, "firmware hang detected\n");
detach: detach:
if (!test_and_set_bit(__NX_RESETTING, &adapter->state)) if ((auto_fw_reset == AUTO_FW_RESET_ENABLED) &&
!test_and_set_bit(__NX_RESETTING, &adapter->state))
netxen_schedule_work(adapter, netxen_detach_work, 0); netxen_schedule_work(adapter, netxen_detach_work, 0);
return 1; return 1;
} }
...@@ -2496,6 +2499,41 @@ static struct bin_attribute bin_attr_mem = { ...@@ -2496,6 +2499,41 @@ static struct bin_attribute bin_attr_mem = {
.write = netxen_sysfs_write_mem, .write = netxen_sysfs_write_mem,
}; };
static ssize_t
netxen_store_auto_fw_reset(struct module_attribute *mattr,
struct module *mod, const char *buf, size_t count)
{
unsigned long new;
if (strict_strtoul(buf, 16, &new))
return -EINVAL;
if ((new == AUTO_FW_RESET_ENABLED) || (new == AUTO_FW_RESET_DISABLED)) {
auto_fw_reset = new;
return count;
}
return -EINVAL;
}
static ssize_t
netxen_show_auto_fw_reset(struct module_attribute *mattr,
struct module *mod, char *buf)
{
if (auto_fw_reset == AUTO_FW_RESET_ENABLED)
return sprintf(buf, "enabled\n");
else
return sprintf(buf, "disabled\n");
}
static struct module_attribute mod_attr_fw_reset = {
.attr = {.name = "auto_fw_reset", .mode = (S_IRUGO | S_IWUSR)},
.show = netxen_show_auto_fw_reset,
.store = netxen_store_auto_fw_reset,
};
static void static void
netxen_create_sysfs_entries(struct netxen_adapter *adapter) netxen_create_sysfs_entries(struct netxen_adapter *adapter)
{ {
...@@ -2700,6 +2738,8 @@ static struct pci_driver netxen_driver = { ...@@ -2700,6 +2738,8 @@ static struct pci_driver netxen_driver = {
static int __init netxen_init_module(void) static int __init netxen_init_module(void)
{ {
struct module *mod = THIS_MODULE;
printk(KERN_INFO "%s\n", netxen_nic_driver_string); printk(KERN_INFO "%s\n", netxen_nic_driver_string);
#ifdef CONFIG_INET #ifdef CONFIG_INET
...@@ -2707,6 +2747,10 @@ static int __init netxen_init_module(void) ...@@ -2707,6 +2747,10 @@ static int __init netxen_init_module(void)
register_inetaddr_notifier(&netxen_inetaddr_cb); register_inetaddr_notifier(&netxen_inetaddr_cb);
#endif #endif
if (sysfs_create_file(&mod->mkobj.kobj, &mod_attr_fw_reset.attr))
printk(KERN_ERR "%s: Failed to create auto_fw_reset "
"sysfs entry.", netxen_nic_driver_name);
return pci_register_driver(&netxen_driver); return pci_register_driver(&netxen_driver);
} }
...@@ -2714,6 +2758,10 @@ module_init(netxen_init_module); ...@@ -2714,6 +2758,10 @@ module_init(netxen_init_module);
static void __exit netxen_exit_module(void) static void __exit netxen_exit_module(void)
{ {
struct module *mod = THIS_MODULE;
sysfs_remove_file(&mod->mkobj.kobj, &mod_attr_fw_reset.attr);
pci_unregister_driver(&netxen_driver); pci_unregister_driver(&netxen_driver);
#ifdef CONFIG_INET #ifdef CONFIG_INET
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment