Commit b9c11984 authored by Jitendra Kalsaria's avatar Jitendra Kalsaria Committed by David S. Miller

qlcnic: Enhance diagnostic loopback error codes.

o Enhanced the driver to use standard Linux error codes
o Return a unique error code to indicate loopback is in progress
Signed-off-by: default avatarJitendra Kalsaria <jitendra.kalsaria@qlogic.com>
Signed-off-by: default avatarHimanshu Madhani <himanshu.madhani@qlogic.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent a594e4f8
...@@ -950,12 +950,6 @@ struct qlcnic_ipaddr { ...@@ -950,12 +950,6 @@ struct qlcnic_ipaddr {
#define QLCNIC_READD_AGE 20 #define QLCNIC_READD_AGE 20
#define QLCNIC_LB_MAX_FILTERS 64 #define QLCNIC_LB_MAX_FILTERS 64
#define QLCNIC_LB_BUCKET_SIZE 32 #define QLCNIC_LB_BUCKET_SIZE 32
/* QLCNIC Driver Error Code */
#define QLCNIC_FW_NOT_RESPOND 51
#define QLCNIC_TEST_IN_PROGRESS 52
#define QLCNIC_UNDEFINED_ERROR 53
#define QLCNIC_LB_CABLE_NOT_CONN 54
#define QLCNIC_ILB_MAX_RCV_LOOP 10 #define QLCNIC_ILB_MAX_RCV_LOOP 10
struct qlcnic_filter { struct qlcnic_filter {
......
...@@ -1652,7 +1652,7 @@ int qlcnic_83xx_loopback_test(struct net_device *netdev, u8 mode) ...@@ -1652,7 +1652,7 @@ int qlcnic_83xx_loopback_test(struct net_device *netdev, u8 mode)
if (ahw->op_mode == QLCNIC_NON_PRIV_FUNC) { if (ahw->op_mode == QLCNIC_NON_PRIV_FUNC) {
netdev_warn(netdev, netdev_warn(netdev,
"Loopback test not supported in non privileged mode\n"); "Loopback test not supported in non privileged mode\n");
return ret; return -ENOTSUPP;
} }
if (test_bit(__QLCNIC_RESETTING, &adapter->state)) { if (test_bit(__QLCNIC_RESETTING, &adapter->state)) {
...@@ -1686,13 +1686,13 @@ int qlcnic_83xx_loopback_test(struct net_device *netdev, u8 mode) ...@@ -1686,13 +1686,13 @@ int qlcnic_83xx_loopback_test(struct net_device *netdev, u8 mode)
if (test_bit(__QLCNIC_RESETTING, &adapter->state)) { if (test_bit(__QLCNIC_RESETTING, &adapter->state)) {
netdev_info(netdev, netdev_info(netdev,
"Device is resetting, free LB test resources\n"); "Device is resetting, free LB test resources\n");
ret = -EIO; ret = -EBUSY;
goto free_diag_res; goto free_diag_res;
} }
if (loop++ > QLC_83XX_LB_WAIT_COUNT) { if (loop++ > QLC_83XX_LB_WAIT_COUNT) {
netdev_info(netdev, netdev_info(netdev,
"Firmware didn't sent link up event to loopback request\n"); "Firmware didn't sent link up event to loopback request\n");
ret = -QLCNIC_FW_NOT_RESPOND; ret = -ETIMEDOUT;
qlcnic_83xx_clear_lb_mode(adapter, mode); qlcnic_83xx_clear_lb_mode(adapter, mode);
goto free_diag_res; goto free_diag_res;
} }
...@@ -1729,6 +1729,15 @@ int qlcnic_83xx_set_lb_mode(struct qlcnic_adapter *adapter, u8 mode) ...@@ -1729,6 +1729,15 @@ int qlcnic_83xx_set_lb_mode(struct qlcnic_adapter *adapter, u8 mode)
return status; return status;
config = ahw->port_config; config = ahw->port_config;
/* Check if port is already in loopback mode */
if ((config & QLC_83XX_CFG_LOOPBACK_HSS) ||
(config & QLC_83XX_CFG_LOOPBACK_EXT)) {
netdev_err(netdev,
"Port already in Loopback mode.\n");
return -EINPROGRESS;
}
set_bit(QLC_83XX_IDC_COMP_AEN, &ahw->idc.status); set_bit(QLC_83XX_IDC_COMP_AEN, &ahw->idc.status);
if (mode == QLCNIC_ILB_MODE) if (mode == QLCNIC_ILB_MODE)
...@@ -1756,14 +1765,14 @@ int qlcnic_83xx_set_lb_mode(struct qlcnic_adapter *adapter, u8 mode) ...@@ -1756,14 +1765,14 @@ int qlcnic_83xx_set_lb_mode(struct qlcnic_adapter *adapter, u8 mode)
netdev_info(netdev, netdev_info(netdev,
"Device is resetting, free LB test resources\n"); "Device is resetting, free LB test resources\n");
clear_bit(QLC_83XX_IDC_COMP_AEN, &ahw->idc.status); clear_bit(QLC_83XX_IDC_COMP_AEN, &ahw->idc.status);
return -EIO; return -EBUSY;
} }
if (loop++ > QLC_83XX_LB_WAIT_COUNT) { if (loop++ > QLC_83XX_LB_WAIT_COUNT) {
netdev_err(netdev, netdev_err(netdev,
"Did not receive IDC completion AEN\n"); "Did not receive IDC completion AEN\n");
clear_bit(QLC_83XX_IDC_COMP_AEN, &ahw->idc.status); clear_bit(QLC_83XX_IDC_COMP_AEN, &ahw->idc.status);
qlcnic_83xx_clear_lb_mode(adapter, mode); qlcnic_83xx_clear_lb_mode(adapter, mode);
return -EIO; return -ETIMEDOUT;
} }
} while (test_bit(QLC_83XX_IDC_COMP_AEN, &ahw->idc.status)); } while (test_bit(QLC_83XX_IDC_COMP_AEN, &ahw->idc.status));
...@@ -1805,14 +1814,14 @@ int qlcnic_83xx_clear_lb_mode(struct qlcnic_adapter *adapter, u8 mode) ...@@ -1805,14 +1814,14 @@ int qlcnic_83xx_clear_lb_mode(struct qlcnic_adapter *adapter, u8 mode)
netdev_info(netdev, netdev_info(netdev,
"Device is resetting, free LB test resources\n"); "Device is resetting, free LB test resources\n");
clear_bit(QLC_83XX_IDC_COMP_AEN, &ahw->idc.status); clear_bit(QLC_83XX_IDC_COMP_AEN, &ahw->idc.status);
return -EIO; return -EBUSY;
} }
if (loop++ > QLC_83XX_LB_WAIT_COUNT) { if (loop++ > QLC_83XX_LB_WAIT_COUNT) {
netdev_err(netdev, netdev_err(netdev,
"Did not receive IDC completion AEN\n"); "Did not receive IDC completion AEN\n");
clear_bit(QLC_83XX_IDC_COMP_AEN, &ahw->idc.status); clear_bit(QLC_83XX_IDC_COMP_AEN, &ahw->idc.status);
return -EIO; return -ETIMEDOUT;
} }
} while (test_bit(QLC_83XX_IDC_COMP_AEN, &ahw->idc.status)); } while (test_bit(QLC_83XX_IDC_COMP_AEN, &ahw->idc.status));
......
...@@ -980,9 +980,9 @@ int qlcnic_loopback_test(struct net_device *netdev, u8 mode) ...@@ -980,9 +980,9 @@ int qlcnic_loopback_test(struct net_device *netdev, u8 mode)
msleep(500); msleep(500);
qlcnic_process_rcv_ring_diag(sds_ring); qlcnic_process_rcv_ring_diag(sds_ring);
if (loop++ > QLCNIC_ILB_MAX_RCV_LOOP) { if (loop++ > QLCNIC_ILB_MAX_RCV_LOOP) {
netdev_info(netdev, "firmware didnt respond to loopback" netdev_info(netdev,
" configure request\n"); "Firmware didn't sent link up event to loopback request\n");
ret = -QLCNIC_FW_NOT_RESPOND; ret = -ETIMEDOUT;
goto free_res; goto free_res;
} else if (adapter->ahw->diag_cnt) { } else if (adapter->ahw->diag_cnt) {
ret = adapter->ahw->diag_cnt; ret = adapter->ahw->diag_cnt;
......
...@@ -919,17 +919,17 @@ static void qlcnic_handle_fw_message(int desc_cnt, int index, ...@@ -919,17 +919,17 @@ static void qlcnic_handle_fw_message(int desc_cnt, int index,
break; break;
case 1: case 1:
dev_info(dev, "loopback already in progress\n"); dev_info(dev, "loopback already in progress\n");
adapter->ahw->diag_cnt = -QLCNIC_TEST_IN_PROGRESS; adapter->ahw->diag_cnt = -EINPROGRESS;
break; break;
case 2: case 2:
dev_info(dev, "loopback cable is not connected\n"); dev_info(dev, "loopback cable is not connected\n");
adapter->ahw->diag_cnt = -QLCNIC_LB_CABLE_NOT_CONN; adapter->ahw->diag_cnt = -ENODEV;
break; break;
default: default:
dev_info(dev, dev_info(dev,
"loopback configure request failed, err %x\n", "loopback configure request failed, err %x\n",
ret); ret);
adapter->ahw->diag_cnt = -QLCNIC_UNDEFINED_ERROR; adapter->ahw->diag_cnt = -EIO;
break; break;
} }
break; break;
......
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