Commit d0e1b319 authored by Kalesh AP's avatar Kalesh AP Committed by David S. Miller

be2net: refactor error detect/recovery function

Currently when an error is detected, the queue resources are being cleaned up
in the recovery routine. The resources are better cleaned up in the error
detection routine itself (similar to EEH code.)
So, this patch re-factors error processing logic to follow the following sequence:
	- check if there is an error in adapter
	- if error,
		- cleanup resources
		- attempt recovery

The patch renames lancer_recover_func() to be_err_recover() as this
routine will be used in the future for error recovery on Skyhawk too.
Signed-off-by: default avatarKalesh AP <kalesh.purayil@emulex.com>
Signed-off-by: default avatarSathya Perla <sathya.perla@emulex.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent eb7dd46c
...@@ -2844,12 +2844,12 @@ void be_detect_error(struct be_adapter *adapter) ...@@ -2844,12 +2844,12 @@ void be_detect_error(struct be_adapter *adapter)
sliport_err2 = ioread32(adapter->db + sliport_err2 = ioread32(adapter->db +
SLIPORT_ERROR2_OFFSET); SLIPORT_ERROR2_OFFSET);
adapter->hw_error = true; adapter->hw_error = true;
error_detected = true;
/* Do not log error messages if its a FW reset */ /* Do not log error messages if its a FW reset */
if (sliport_err1 == SLIPORT_ERROR_FW_RESET1 && if (sliport_err1 == SLIPORT_ERROR_FW_RESET1 &&
sliport_err2 == SLIPORT_ERROR_FW_RESET2) { sliport_err2 == SLIPORT_ERROR_FW_RESET2) {
dev_info(dev, "Firmware update in progress\n"); dev_info(dev, "Firmware update in progress\n");
} else { } else {
error_detected = true;
dev_err(dev, "Error detected in the card\n"); dev_err(dev, "Error detected in the card\n");
dev_err(dev, "ERR: sliport status 0x%x\n", dev_err(dev, "ERR: sliport status 0x%x\n",
sliport_status); sliport_status);
...@@ -4903,8 +4903,9 @@ static void be_netdev_init(struct net_device *netdev) ...@@ -4903,8 +4903,9 @@ static void be_netdev_init(struct net_device *netdev)
netdev->ethtool_ops = &be_ethtool_ops; netdev->ethtool_ops = &be_ethtool_ops;
} }
static int lancer_recover_func(struct be_adapter *adapter) static int be_err_recover(struct be_adapter *adapter)
{ {
struct net_device *netdev = adapter->netdev;
struct device *dev = &adapter->pdev->dev; struct device *dev = &adapter->pdev->dev;
int status; int status;
...@@ -4912,23 +4913,20 @@ static int lancer_recover_func(struct be_adapter *adapter) ...@@ -4912,23 +4913,20 @@ static int lancer_recover_func(struct be_adapter *adapter)
if (status) if (status)
goto err; goto err;
if (netif_running(adapter->netdev))
be_close(adapter->netdev);
be_clear(adapter);
be_clear_all_error(adapter); be_clear_all_error(adapter);
status = be_setup(adapter); status = be_setup(adapter);
if (status) if (status)
goto err; goto err;
if (netif_running(adapter->netdev)) { if (netif_running(netdev)) {
status = be_open(adapter->netdev); status = be_open(netdev);
if (status) if (status)
goto err; goto err;
} }
netif_device_attach(netdev);
dev_err(dev, "Adapter recovery successful\n"); dev_err(dev, "Adapter recovery successful\n");
return 0; return 0;
err: err:
...@@ -4945,18 +4943,23 @@ static void be_err_detection_task(struct work_struct *work) ...@@ -4945,18 +4943,23 @@ static void be_err_detection_task(struct work_struct *work)
struct be_adapter *adapter = struct be_adapter *adapter =
container_of(work, struct be_adapter, container_of(work, struct be_adapter,
be_err_detection_work.work); be_err_detection_work.work);
struct net_device *netdev = adapter->netdev;
int status = 0; int status = 0;
be_detect_error(adapter); be_detect_error(adapter);
if (adapter->hw_error && lancer_chip(adapter)) { if (adapter->hw_error) {
rtnl_lock(); rtnl_lock();
netif_device_detach(adapter->netdev); netif_device_detach(netdev);
if (netif_running(netdev))
be_close(netdev);
rtnl_unlock(); rtnl_unlock();
status = lancer_recover_func(adapter); be_clear(adapter);
if (!status)
netif_device_attach(adapter->netdev); /* As of now error recovery support is in Lancer only */
if (lancer_chip(adapter))
status = be_err_recover(adapter);
} }
/* In Lancer, for all errors other than provisioning error (-EAGAIN), /* In Lancer, for all errors other than provisioning error (-EAGAIN),
......
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