diff options
author | Amit Kumar Salecha <amit.salecha@qlogic.com> | 2010-04-21 22:51:38 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2010-04-22 18:28:28 -0400 |
commit | 6d2a47241f0f780819c111eaabaae0e86a937a40 (patch) | |
tree | 2012c4d382439d0c982e8debf7e623ad7ba8e4be /drivers/net/qlcnic | |
parent | f73dfc50f14d5c4c7f6243a87a65b78aef6f3a48 (diff) |
qlcnic: define macro for driver state
Defining macro to set and clear driver state.
Signed-off-by: Amit Kumar Salecha <amit.salecha@qlogic.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/qlcnic')
-rw-r--r-- | drivers/net/qlcnic/qlcnic_hdr.h | 6 | ||||
-rw-r--r-- | drivers/net/qlcnic/qlcnic_main.c | 22 |
2 files changed, 17 insertions, 11 deletions
diff --git a/drivers/net/qlcnic/qlcnic_hdr.h b/drivers/net/qlcnic/qlcnic_hdr.h index 8285a06eecdb..a984cd227582 100644 --- a/drivers/net/qlcnic/qlcnic_hdr.h +++ b/drivers/net/qlcnic/qlcnic_hdr.h | |||
@@ -707,6 +707,12 @@ enum { | |||
707 | #define QLCNIC_DEV_FAILED 0x6 | 707 | #define QLCNIC_DEV_FAILED 0x6 |
708 | #define QLCNIC_DEV_QUISCENT 0x7 | 708 | #define QLCNIC_DEV_QUISCENT 0x7 |
709 | 709 | ||
710 | #define QLC_DEV_SET_REF_CNT(VAL, FN) ((VAL) |= (1 << (FN * 4))) | ||
711 | #define QLC_DEV_CLR_REF_CNT(VAL, FN) ((VAL) &= ~(1 << (FN * 4))) | ||
712 | #define QLC_DEV_SET_RST_RDY(VAL, FN) ((VAL) |= (1 << (FN * 4))) | ||
713 | #define QLC_DEV_SET_QSCNT_RDY(VAL, FN) ((VAL) |= (2 << (FN * 4))) | ||
714 | #define QLC_DEV_CLR_RST_QSCNT(VAL, FN) ((VAL) &= ~(3 << (FN * 4))) | ||
715 | |||
710 | #define QLCNIC_RCODE_DRIVER_INFO 0x20000000 | 716 | #define QLCNIC_RCODE_DRIVER_INFO 0x20000000 |
711 | #define QLCNIC_RCODE_DRIVER_CAN_RELOAD 0x40000000 | 717 | #define QLCNIC_RCODE_DRIVER_CAN_RELOAD 0x40000000 |
712 | #define QLCNIC_RCODE_FATAL_ERROR 0x80000000 | 718 | #define QLCNIC_RCODE_FATAL_ERROR 0x80000000 |
diff --git a/drivers/net/qlcnic/qlcnic_main.c b/drivers/net/qlcnic/qlcnic_main.c index 06349908092f..3c8a963f68a9 100644 --- a/drivers/net/qlcnic/qlcnic_main.c +++ b/drivers/net/qlcnic/qlcnic_main.c | |||
@@ -1963,9 +1963,9 @@ qlcnic_set_drv_state(struct qlcnic_adapter *adapter, int state) | |||
1963 | val = QLCRD32(adapter, QLCNIC_CRB_DRV_STATE); | 1963 | val = QLCRD32(adapter, QLCNIC_CRB_DRV_STATE); |
1964 | 1964 | ||
1965 | if (state == QLCNIC_DEV_NEED_RESET) | 1965 | if (state == QLCNIC_DEV_NEED_RESET) |
1966 | val |= ((u32)0x1 << (adapter->portnum * 4)); | 1966 | QLC_DEV_SET_RST_RDY(val, adapter->portnum); |
1967 | else if (state == QLCNIC_DEV_NEED_QUISCENT) | 1967 | else if (state == QLCNIC_DEV_NEED_QUISCENT) |
1968 | val |= ((u32)0x1 << ((adapter->portnum * 4) + 1)); | 1968 | QLC_DEV_SET_QSCNT_RDY(val, adapter->portnum); |
1969 | 1969 | ||
1970 | QLCWR32(adapter, QLCNIC_CRB_DRV_STATE, val); | 1970 | QLCWR32(adapter, QLCNIC_CRB_DRV_STATE, val); |
1971 | 1971 | ||
@@ -1981,7 +1981,7 @@ qlcnic_clr_drv_state(struct qlcnic_adapter *adapter) | |||
1981 | return -EBUSY; | 1981 | return -EBUSY; |
1982 | 1982 | ||
1983 | val = QLCRD32(adapter, QLCNIC_CRB_DRV_STATE); | 1983 | val = QLCRD32(adapter, QLCNIC_CRB_DRV_STATE); |
1984 | val &= ~((u32)0x3 << (adapter->portnum * 4)); | 1984 | QLC_DEV_CLR_RST_QSCNT(val, adapter->portnum); |
1985 | QLCWR32(adapter, QLCNIC_CRB_DRV_STATE, val); | 1985 | QLCWR32(adapter, QLCNIC_CRB_DRV_STATE, val); |
1986 | 1986 | ||
1987 | qlcnic_api_unlock(adapter); | 1987 | qlcnic_api_unlock(adapter); |
@@ -1998,14 +1998,14 @@ qlcnic_clr_all_drv_state(struct qlcnic_adapter *adapter) | |||
1998 | goto err; | 1998 | goto err; |
1999 | 1999 | ||
2000 | val = QLCRD32(adapter, QLCNIC_CRB_DEV_REF_COUNT); | 2000 | val = QLCRD32(adapter, QLCNIC_CRB_DEV_REF_COUNT); |
2001 | val &= ~((u32)0x1 << (adapter->portnum * 4)); | 2001 | QLC_DEV_CLR_REF_CNT(val, adapter->portnum); |
2002 | QLCWR32(adapter, QLCNIC_CRB_DEV_REF_COUNT, val); | 2002 | QLCWR32(adapter, QLCNIC_CRB_DEV_REF_COUNT, val); |
2003 | 2003 | ||
2004 | if (!(val & 0x11111111)) | 2004 | if (!(val & 0x11111111)) |
2005 | QLCWR32(adapter, QLCNIC_CRB_DEV_STATE, QLCNIC_DEV_COLD); | 2005 | QLCWR32(adapter, QLCNIC_CRB_DEV_STATE, QLCNIC_DEV_COLD); |
2006 | 2006 | ||
2007 | val = QLCRD32(adapter, QLCNIC_CRB_DRV_STATE); | 2007 | val = QLCRD32(adapter, QLCNIC_CRB_DRV_STATE); |
2008 | val &= ~((u32)0x3 << (adapter->portnum * 4)); | 2008 | QLC_DEV_CLR_RST_QSCNT(val, adapter->portnum); |
2009 | QLCWR32(adapter, QLCNIC_CRB_DRV_STATE, val); | 2009 | QLCWR32(adapter, QLCNIC_CRB_DRV_STATE, val); |
2010 | 2010 | ||
2011 | qlcnic_api_unlock(adapter); | 2011 | qlcnic_api_unlock(adapter); |
@@ -2036,7 +2036,7 @@ qlcnic_can_start_firmware(struct qlcnic_adapter *adapter) | |||
2036 | { | 2036 | { |
2037 | u32 val, prev_state; | 2037 | u32 val, prev_state; |
2038 | u8 dev_init_timeo = adapter->dev_init_timeo; | 2038 | u8 dev_init_timeo = adapter->dev_init_timeo; |
2039 | int portnum = adapter->portnum; | 2039 | u8 portnum = adapter->portnum; |
2040 | 2040 | ||
2041 | if (test_and_clear_bit(__QLCNIC_START_FW, &adapter->state)) | 2041 | if (test_and_clear_bit(__QLCNIC_START_FW, &adapter->state)) |
2042 | return 1; | 2042 | return 1; |
@@ -2045,8 +2045,8 @@ qlcnic_can_start_firmware(struct qlcnic_adapter *adapter) | |||
2045 | return -1; | 2045 | return -1; |
2046 | 2046 | ||
2047 | val = QLCRD32(adapter, QLCNIC_CRB_DEV_REF_COUNT); | 2047 | val = QLCRD32(adapter, QLCNIC_CRB_DEV_REF_COUNT); |
2048 | if (!(val & ((int)0x1 << (portnum * 4)))) { | 2048 | if (!(val & (1 << (portnum * 4)))) { |
2049 | val |= ((u32)0x1 << (portnum * 4)); | 2049 | QLC_DEV_SET_REF_CNT(val, portnum); |
2050 | QLCWR32(adapter, QLCNIC_CRB_DEV_REF_COUNT, val); | 2050 | QLCWR32(adapter, QLCNIC_CRB_DEV_REF_COUNT, val); |
2051 | } | 2051 | } |
2052 | 2052 | ||
@@ -2065,13 +2065,13 @@ qlcnic_can_start_firmware(struct qlcnic_adapter *adapter) | |||
2065 | 2065 | ||
2066 | case QLCNIC_DEV_NEED_RESET: | 2066 | case QLCNIC_DEV_NEED_RESET: |
2067 | val = QLCRD32(adapter, QLCNIC_CRB_DRV_STATE); | 2067 | val = QLCRD32(adapter, QLCNIC_CRB_DRV_STATE); |
2068 | val |= ((u32)0x1 << (portnum * 4)); | 2068 | QLC_DEV_SET_RST_RDY(val, portnum); |
2069 | QLCWR32(adapter, QLCNIC_CRB_DRV_STATE, val); | 2069 | QLCWR32(adapter, QLCNIC_CRB_DRV_STATE, val); |
2070 | break; | 2070 | break; |
2071 | 2071 | ||
2072 | case QLCNIC_DEV_NEED_QUISCENT: | 2072 | case QLCNIC_DEV_NEED_QUISCENT: |
2073 | val = QLCRD32(adapter, QLCNIC_CRB_DRV_STATE); | 2073 | val = QLCRD32(adapter, QLCNIC_CRB_DRV_STATE); |
2074 | val |= ((u32)0x1 << ((portnum * 4) + 1)); | 2074 | QLC_DEV_SET_QSCNT_RDY(val, portnum); |
2075 | QLCWR32(adapter, QLCNIC_CRB_DRV_STATE, val); | 2075 | QLCWR32(adapter, QLCNIC_CRB_DRV_STATE, val); |
2076 | break; | 2076 | break; |
2077 | 2077 | ||
@@ -2101,7 +2101,7 @@ qlcnic_can_start_firmware(struct qlcnic_adapter *adapter) | |||
2101 | return -1; | 2101 | return -1; |
2102 | 2102 | ||
2103 | val = QLCRD32(adapter, QLCNIC_CRB_DRV_STATE); | 2103 | val = QLCRD32(adapter, QLCNIC_CRB_DRV_STATE); |
2104 | val &= ~((u32)0x3 << (portnum * 4)); | 2104 | QLC_DEV_CLR_RST_QSCNT(val, portnum); |
2105 | QLCWR32(adapter, QLCNIC_CRB_DRV_STATE, val); | 2105 | QLCWR32(adapter, QLCNIC_CRB_DRV_STATE, val); |
2106 | 2106 | ||
2107 | qlcnic_api_unlock(adapter); | 2107 | qlcnic_api_unlock(adapter); |