Commit 6d2a4724 authored by Amit Kumar Salecha's avatar Amit Kumar Salecha Committed by David S. Miller

qlcnic: define macro for driver state

Defining macro to set and clear driver state.
Signed-off-by: default avatarAmit Kumar Salecha <amit.salecha@qlogic.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent f73dfc50
...@@ -707,6 +707,12 @@ enum { ...@@ -707,6 +707,12 @@ enum {
#define QLCNIC_DEV_FAILED 0x6 #define QLCNIC_DEV_FAILED 0x6
#define QLCNIC_DEV_QUISCENT 0x7 #define QLCNIC_DEV_QUISCENT 0x7
#define QLC_DEV_SET_REF_CNT(VAL, FN) ((VAL) |= (1 << (FN * 4)))
#define QLC_DEV_CLR_REF_CNT(VAL, FN) ((VAL) &= ~(1 << (FN * 4)))
#define QLC_DEV_SET_RST_RDY(VAL, FN) ((VAL) |= (1 << (FN * 4)))
#define QLC_DEV_SET_QSCNT_RDY(VAL, FN) ((VAL) |= (2 << (FN * 4)))
#define QLC_DEV_CLR_RST_QSCNT(VAL, FN) ((VAL) &= ~(3 << (FN * 4)))
#define QLCNIC_RCODE_DRIVER_INFO 0x20000000 #define QLCNIC_RCODE_DRIVER_INFO 0x20000000
#define QLCNIC_RCODE_DRIVER_CAN_RELOAD 0x40000000 #define QLCNIC_RCODE_DRIVER_CAN_RELOAD 0x40000000
#define QLCNIC_RCODE_FATAL_ERROR 0x80000000 #define QLCNIC_RCODE_FATAL_ERROR 0x80000000
......
...@@ -1963,9 +1963,9 @@ qlcnic_set_drv_state(struct qlcnic_adapter *adapter, int state) ...@@ -1963,9 +1963,9 @@ qlcnic_set_drv_state(struct qlcnic_adapter *adapter, int state)
val = QLCRD32(adapter, QLCNIC_CRB_DRV_STATE); val = QLCRD32(adapter, QLCNIC_CRB_DRV_STATE);
if (state == QLCNIC_DEV_NEED_RESET) if (state == QLCNIC_DEV_NEED_RESET)
val |= ((u32)0x1 << (adapter->portnum * 4)); QLC_DEV_SET_RST_RDY(val, adapter->portnum);
else if (state == QLCNIC_DEV_NEED_QUISCENT) else if (state == QLCNIC_DEV_NEED_QUISCENT)
val |= ((u32)0x1 << ((adapter->portnum * 4) + 1)); QLC_DEV_SET_QSCNT_RDY(val, adapter->portnum);
QLCWR32(adapter, QLCNIC_CRB_DRV_STATE, val); QLCWR32(adapter, QLCNIC_CRB_DRV_STATE, val);
...@@ -1981,7 +1981,7 @@ qlcnic_clr_drv_state(struct qlcnic_adapter *adapter) ...@@ -1981,7 +1981,7 @@ qlcnic_clr_drv_state(struct qlcnic_adapter *adapter)
return -EBUSY; return -EBUSY;
val = QLCRD32(adapter, QLCNIC_CRB_DRV_STATE); val = QLCRD32(adapter, QLCNIC_CRB_DRV_STATE);
val &= ~((u32)0x3 << (adapter->portnum * 4)); QLC_DEV_CLR_RST_QSCNT(val, adapter->portnum);
QLCWR32(adapter, QLCNIC_CRB_DRV_STATE, val); QLCWR32(adapter, QLCNIC_CRB_DRV_STATE, val);
qlcnic_api_unlock(adapter); qlcnic_api_unlock(adapter);
...@@ -1998,14 +1998,14 @@ qlcnic_clr_all_drv_state(struct qlcnic_adapter *adapter) ...@@ -1998,14 +1998,14 @@ qlcnic_clr_all_drv_state(struct qlcnic_adapter *adapter)
goto err; goto err;
val = QLCRD32(adapter, QLCNIC_CRB_DEV_REF_COUNT); val = QLCRD32(adapter, QLCNIC_CRB_DEV_REF_COUNT);
val &= ~((u32)0x1 << (adapter->portnum * 4)); QLC_DEV_CLR_REF_CNT(val, adapter->portnum);
QLCWR32(adapter, QLCNIC_CRB_DEV_REF_COUNT, val); QLCWR32(adapter, QLCNIC_CRB_DEV_REF_COUNT, val);
if (!(val & 0x11111111)) if (!(val & 0x11111111))
QLCWR32(adapter, QLCNIC_CRB_DEV_STATE, QLCNIC_DEV_COLD); QLCWR32(adapter, QLCNIC_CRB_DEV_STATE, QLCNIC_DEV_COLD);
val = QLCRD32(adapter, QLCNIC_CRB_DRV_STATE); val = QLCRD32(adapter, QLCNIC_CRB_DRV_STATE);
val &= ~((u32)0x3 << (adapter->portnum * 4)); QLC_DEV_CLR_RST_QSCNT(val, adapter->portnum);
QLCWR32(adapter, QLCNIC_CRB_DRV_STATE, val); QLCWR32(adapter, QLCNIC_CRB_DRV_STATE, val);
qlcnic_api_unlock(adapter); qlcnic_api_unlock(adapter);
...@@ -2036,7 +2036,7 @@ qlcnic_can_start_firmware(struct qlcnic_adapter *adapter) ...@@ -2036,7 +2036,7 @@ qlcnic_can_start_firmware(struct qlcnic_adapter *adapter)
{ {
u32 val, prev_state; u32 val, prev_state;
u8 dev_init_timeo = adapter->dev_init_timeo; u8 dev_init_timeo = adapter->dev_init_timeo;
int portnum = adapter->portnum; u8 portnum = adapter->portnum;
if (test_and_clear_bit(__QLCNIC_START_FW, &adapter->state)) if (test_and_clear_bit(__QLCNIC_START_FW, &adapter->state))
return 1; return 1;
...@@ -2045,8 +2045,8 @@ qlcnic_can_start_firmware(struct qlcnic_adapter *adapter) ...@@ -2045,8 +2045,8 @@ qlcnic_can_start_firmware(struct qlcnic_adapter *adapter)
return -1; return -1;
val = QLCRD32(adapter, QLCNIC_CRB_DEV_REF_COUNT); val = QLCRD32(adapter, QLCNIC_CRB_DEV_REF_COUNT);
if (!(val & ((int)0x1 << (portnum * 4)))) { if (!(val & (1 << (portnum * 4)))) {
val |= ((u32)0x1 << (portnum * 4)); QLC_DEV_SET_REF_CNT(val, portnum);
QLCWR32(adapter, QLCNIC_CRB_DEV_REF_COUNT, val); QLCWR32(adapter, QLCNIC_CRB_DEV_REF_COUNT, val);
} }
...@@ -2065,13 +2065,13 @@ qlcnic_can_start_firmware(struct qlcnic_adapter *adapter) ...@@ -2065,13 +2065,13 @@ qlcnic_can_start_firmware(struct qlcnic_adapter *adapter)
case QLCNIC_DEV_NEED_RESET: case QLCNIC_DEV_NEED_RESET:
val = QLCRD32(adapter, QLCNIC_CRB_DRV_STATE); val = QLCRD32(adapter, QLCNIC_CRB_DRV_STATE);
val |= ((u32)0x1 << (portnum * 4)); QLC_DEV_SET_RST_RDY(val, portnum);
QLCWR32(adapter, QLCNIC_CRB_DRV_STATE, val); QLCWR32(adapter, QLCNIC_CRB_DRV_STATE, val);
break; break;
case QLCNIC_DEV_NEED_QUISCENT: case QLCNIC_DEV_NEED_QUISCENT:
val = QLCRD32(adapter, QLCNIC_CRB_DRV_STATE); val = QLCRD32(adapter, QLCNIC_CRB_DRV_STATE);
val |= ((u32)0x1 << ((portnum * 4) + 1)); QLC_DEV_SET_QSCNT_RDY(val, portnum);
QLCWR32(adapter, QLCNIC_CRB_DRV_STATE, val); QLCWR32(adapter, QLCNIC_CRB_DRV_STATE, val);
break; break;
...@@ -2101,7 +2101,7 @@ qlcnic_can_start_firmware(struct qlcnic_adapter *adapter) ...@@ -2101,7 +2101,7 @@ qlcnic_can_start_firmware(struct qlcnic_adapter *adapter)
return -1; return -1;
val = QLCRD32(adapter, QLCNIC_CRB_DRV_STATE); val = QLCRD32(adapter, QLCNIC_CRB_DRV_STATE);
val &= ~((u32)0x3 << (portnum * 4)); QLC_DEV_CLR_RST_QSCNT(val, portnum);
QLCWR32(adapter, QLCNIC_CRB_DRV_STATE, val); QLCWR32(adapter, QLCNIC_CRB_DRV_STATE, val);
qlcnic_api_unlock(adapter); qlcnic_api_unlock(adapter);
......
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