提交 a15ebd37 编写于 作者: H Himanshu Madhani 提交者: David S. Miller

qlcnic: macros for common register access

Refactor 82xx driver to support new adapter - Qlogic 83XX CNA
Use QLC_SHARED_REG_RD32 and QLC__SHARED_REG_WR32 macros
for 82xx and 83xx common register access.
Signed-off-by: NAnirban Chakraborty <anirban.chakraborty@qlogic.com>
Signed-off-by: NSony Chacko <sony.chacko@qlogic.com>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 7e2cf4fe
...@@ -28,6 +28,14 @@ enum qlcnic_regs { ...@@ -28,6 +28,14 @@ enum qlcnic_regs {
QLCNIC_FLASH_UNLOCK, QLCNIC_FLASH_UNLOCK,
}; };
/* Read from an address offset from BAR0, existing registers */
#define QLC_SHARED_REG_RD32(a, addr) \
readl(((a)->ahw->pci_base0) + ((a)->ahw->reg_tbl[addr]))
/* Write to an address offset from BAR0, existing registers */
#define QLC_SHARED_REG_WR32(a, addr, value) \
writel(value, ((a)->ahw->pci_base0) + ((a)->ahw->reg_tbl[addr]))
#define QLCNIC_CMD_CONFIGURE_IP_ADDR 0x1 #define QLCNIC_CMD_CONFIGURE_IP_ADDR 0x1
#define QLCNIC_CMD_CONFIG_INTRPT 0x2 #define QLCNIC_CMD_CONFIG_INTRPT 0x2
#define QLCNIC_CMD_CREATE_RX_CTX 0x7 #define QLCNIC_CMD_CREATE_RX_CTX 0x7
......
...@@ -5,11 +5,8 @@ ...@@ -5,11 +5,8 @@
* See LICENSE.qlcnic for copyright and licensing details. * See LICENSE.qlcnic for copyright and licensing details.
*/ */
#include <linux/netdevice.h>
#include <linux/delay.h>
#include <linux/slab.h>
#include <linux/if_vlan.h>
#include "qlcnic.h" #include "qlcnic.h"
#include "qlcnic_hw.h"
struct crb_addr_pair { struct crb_addr_pair {
u32 addr; u32 addr;
...@@ -327,7 +324,6 @@ static int qlcnic_wait_rom_done(struct qlcnic_adapter *adapter) ...@@ -327,7 +324,6 @@ static int qlcnic_wait_rom_done(struct qlcnic_adapter *adapter)
long done = 0; long done = 0;
cond_resched(); cond_resched();
while (done == 0) { while (done == 0) {
done = QLCRD32(adapter, QLCNIC_ROMUSB_GLB_STATUS); done = QLCRD32(adapter, QLCNIC_ROMUSB_GLB_STATUS);
done &= 2; done &= 2;
...@@ -416,8 +412,8 @@ int qlcnic_pinit_from_rom(struct qlcnic_adapter *adapter) ...@@ -416,8 +412,8 @@ int qlcnic_pinit_from_rom(struct qlcnic_adapter *adapter)
u32 off; u32 off;
struct pci_dev *pdev = adapter->pdev; struct pci_dev *pdev = adapter->pdev;
QLCWR32(adapter, CRB_CMDPEG_STATE, 0); QLC_SHARED_REG_WR32(adapter, QLCNIC_CMDPEG_STATE, 0);
QLCWR32(adapter, CRB_RCVPEG_STATE, 0); QLC_SHARED_REG_WR32(adapter, QLCNIC_RCVPEG_STATE, 0);
/* Halt all the indiviual PEGs and other blocks */ /* Halt all the indiviual PEGs and other blocks */
/* disable all I2Q */ /* disable all I2Q */
...@@ -564,8 +560,8 @@ int qlcnic_pinit_from_rom(struct qlcnic_adapter *adapter) ...@@ -564,8 +560,8 @@ int qlcnic_pinit_from_rom(struct qlcnic_adapter *adapter)
QLCWR32(adapter, QLCNIC_CRB_PEG_NET_4 + 0xc, 0); QLCWR32(adapter, QLCNIC_CRB_PEG_NET_4 + 0xc, 0);
msleep(1); msleep(1);
QLCWR32(adapter, QLCNIC_PEG_HALT_STATUS1, 0); QLC_SHARED_REG_WR32(adapter, QLCNIC_PEG_HALT_STATUS1, 0);
QLCWR32(adapter, QLCNIC_PEG_HALT_STATUS2, 0); QLC_SHARED_REG_WR32(adapter, QLCNIC_PEG_HALT_STATUS2, 0);
return 0; return 0;
} }
...@@ -576,7 +572,7 @@ static int qlcnic_cmd_peg_ready(struct qlcnic_adapter *adapter) ...@@ -576,7 +572,7 @@ static int qlcnic_cmd_peg_ready(struct qlcnic_adapter *adapter)
int retries = QLCNIC_CMDPEG_CHECK_RETRY_COUNT; int retries = QLCNIC_CMDPEG_CHECK_RETRY_COUNT;
do { do {
val = QLCRD32(adapter, CRB_CMDPEG_STATE); val = QLC_SHARED_REG_RD32(adapter, QLCNIC_CMDPEG_STATE);
switch (val) { switch (val) {
case PHAN_INITIALIZE_COMPLETE: case PHAN_INITIALIZE_COMPLETE:
...@@ -592,7 +588,8 @@ static int qlcnic_cmd_peg_ready(struct qlcnic_adapter *adapter) ...@@ -592,7 +588,8 @@ static int qlcnic_cmd_peg_ready(struct qlcnic_adapter *adapter)
} while (--retries); } while (--retries);
QLCWR32(adapter, CRB_CMDPEG_STATE, PHAN_INITIALIZE_FAILED); QLC_SHARED_REG_WR32(adapter, QLCNIC_CMDPEG_STATE,
PHAN_INITIALIZE_FAILED);
out_err: out_err:
dev_err(&adapter->pdev->dev, "Command Peg initialization not " dev_err(&adapter->pdev->dev, "Command Peg initialization not "
...@@ -607,7 +604,7 @@ qlcnic_receive_peg_ready(struct qlcnic_adapter *adapter) ...@@ -607,7 +604,7 @@ qlcnic_receive_peg_ready(struct qlcnic_adapter *adapter)
int retries = QLCNIC_RCVPEG_CHECK_RETRY_COUNT; int retries = QLCNIC_RCVPEG_CHECK_RETRY_COUNT;
do { do {
val = QLCRD32(adapter, CRB_RCVPEG_STATE); val = QLC_SHARED_REG_RD32(adapter, QLCNIC_RCVPEG_STATE);
if (val == PHAN_PEG_RCV_INITIALIZED) if (val == PHAN_PEG_RCV_INITIALIZED)
return 0; return 0;
...@@ -638,7 +635,7 @@ qlcnic_check_fw_status(struct qlcnic_adapter *adapter) ...@@ -638,7 +635,7 @@ qlcnic_check_fw_status(struct qlcnic_adapter *adapter)
if (err) if (err)
return err; return err;
QLCWR32(adapter, CRB_CMDPEG_STATE, PHAN_INITIALIZE_ACK); QLC_SHARED_REG_WR32(adapter, QLCNIC_CMDPEG_STATE, PHAN_INITIALIZE_ACK);
return err; return err;
} }
...@@ -649,7 +646,7 @@ qlcnic_setup_idc_param(struct qlcnic_adapter *adapter) { ...@@ -649,7 +646,7 @@ qlcnic_setup_idc_param(struct qlcnic_adapter *adapter) {
int timeo; int timeo;
u32 val; u32 val;
val = QLCRD32(adapter, QLCNIC_CRB_DEV_PARTITION_INFO); val = QLC_SHARED_REG_RD32(adapter, QLCNIC_CRB_DEV_PARTITION_INFO);
val = QLC_DEV_GET_DRV(val, adapter->portnum); val = QLC_DEV_GET_DRV(val, adapter->portnum);
if ((val & 0x3) != QLCNIC_TYPE_NIC) { if ((val & 0x3) != QLCNIC_TYPE_NIC) {
dev_err(&adapter->pdev->dev, dev_err(&adapter->pdev->dev,
...@@ -689,7 +686,7 @@ static int qlcnic_get_flt_entry(struct qlcnic_adapter *adapter, u8 region, ...@@ -689,7 +686,7 @@ static int qlcnic_get_flt_entry(struct qlcnic_adapter *adapter, u8 region,
} }
entry_size = flt_hdr.len - sizeof(struct qlcnic_flt_header); entry_size = flt_hdr.len - sizeof(struct qlcnic_flt_header);
flt_entry = (struct qlcnic_flt_entry *)vzalloc(entry_size); flt_entry = vzalloc(entry_size);
if (flt_entry == NULL) { if (flt_entry == NULL) {
dev_warn(&adapter->pdev->dev, "error allocating memory\n"); dev_warn(&adapter->pdev->dev, "error allocating memory\n");
return -EIO; return -EIO;
...@@ -1096,11 +1093,13 @@ qlcnic_check_fw_hearbeat(struct qlcnic_adapter *adapter) ...@@ -1096,11 +1093,13 @@ qlcnic_check_fw_hearbeat(struct qlcnic_adapter *adapter)
u32 heartbeat, ret = -EIO; u32 heartbeat, ret = -EIO;
int retries = QLCNIC_HEARTBEAT_CHECK_RETRY_COUNT; int retries = QLCNIC_HEARTBEAT_CHECK_RETRY_COUNT;
adapter->heartbeat = QLCRD32(adapter, QLCNIC_PEG_ALIVE_COUNTER); adapter->heartbeat = QLC_SHARED_REG_RD32(adapter,
QLCNIC_PEG_ALIVE_COUNTER);
do { do {
msleep(QLCNIC_HEARTBEAT_PERIOD_MSECS); msleep(QLCNIC_HEARTBEAT_PERIOD_MSECS);
heartbeat = QLCRD32(adapter, QLCNIC_PEG_ALIVE_COUNTER); heartbeat = QLC_SHARED_REG_RD32(adapter,
QLCNIC_PEG_ALIVE_COUNTER);
if (heartbeat != adapter->heartbeat) { if (heartbeat != adapter->heartbeat) {
ret = QLCNIC_RCODE_SUCCESS; ret = QLCNIC_RCODE_SUCCESS;
break; break;
...@@ -1270,7 +1269,7 @@ qlcnic_validate_firmware(struct qlcnic_adapter *adapter) ...@@ -1270,7 +1269,7 @@ qlcnic_validate_firmware(struct qlcnic_adapter *adapter)
return -EINVAL; return -EINVAL;
} }
QLCWR32(adapter, QLCNIC_CAM_RAM(0x1fc), QLCNIC_BDINFO_MAGIC); QLC_SHARED_REG_WR32(adapter, QLCNIC_FW_IMG_VALID, QLCNIC_BDINFO_MAGIC);
return 0; return 0;
} }
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#include <linux/interrupt.h> #include <linux/interrupt.h>
#include "qlcnic.h" #include "qlcnic.h"
#include "qlcnic_hw.h"
#include <linux/swab.h> #include <linux/swab.h>
#include <linux/dma-mapping.h> #include <linux/dma-mapping.h>
...@@ -426,7 +427,6 @@ int qlcnic_82xx_setup_intr(struct qlcnic_adapter *adapter, u8 num_intr) ...@@ -426,7 +427,6 @@ int qlcnic_82xx_setup_intr(struct qlcnic_adapter *adapter, u8 num_intr)
qlcnic_enable_msi_legacy(adapter); qlcnic_enable_msi_legacy(adapter);
return 0; return 0;
} }
static void static void
qlcnic_teardown_intr(struct qlcnic_adapter *adapter) qlcnic_teardown_intr(struct qlcnic_adapter *adapter)
{ {
...@@ -562,12 +562,12 @@ qlcnic_set_function_modes(struct qlcnic_adapter *adapter) ...@@ -562,12 +562,12 @@ qlcnic_set_function_modes(struct qlcnic_adapter *adapter)
QLC_DEV_SET_DRV(0xf, id)); QLC_DEV_SET_DRV(0xf, id));
} }
} else { } else {
data = QLCRD32(adapter, QLCNIC_DRV_OP_MODE); data = QLC_SHARED_REG_RD32(adapter, QLCNIC_DRV_OP_MODE);
data = (data & ~QLC_DEV_SET_DRV(0xf, ahw->pci_func)) | data = (data & ~QLC_DEV_SET_DRV(0xf, ahw->pci_func)) |
(QLC_DEV_SET_DRV(QLCNIC_MGMT_FUNC, (QLC_DEV_SET_DRV(QLCNIC_MGMT_FUNC,
ahw->pci_func)); ahw->pci_func));
} }
QLCWR32(adapter, QLCNIC_DRV_OP_MODE, data); QLC_SHARED_REG_WR32(adapter, QLCNIC_DRV_OP_MODE, data);
qlcnic_api_unlock(adapter); qlcnic_api_unlock(adapter);
err_lock: err_lock:
return ret; return ret;
...@@ -682,19 +682,26 @@ static void qlcnic_get_board_name(struct qlcnic_adapter *adapter, char *name) ...@@ -682,19 +682,26 @@ static void qlcnic_get_board_name(struct qlcnic_adapter *adapter, char *name)
static void static void
qlcnic_check_options(struct qlcnic_adapter *adapter) qlcnic_check_options(struct qlcnic_adapter *adapter)
{ {
int err;
u32 fw_major, fw_minor, fw_build, prev_fw_version; u32 fw_major, fw_minor, fw_build, prev_fw_version;
struct pci_dev *pdev = adapter->pdev; struct pci_dev *pdev = adapter->pdev;
struct qlcnic_fw_dump *fw_dump = &adapter->ahw->fw_dump; struct qlcnic_hardware_context *ahw = adapter->ahw;
struct qlcnic_fw_dump *fw_dump = &ahw->fw_dump;
prev_fw_version = adapter->fw_version; prev_fw_version = adapter->fw_version;
fw_major = QLCRD32(adapter, QLCNIC_FW_VERSION_MAJOR); fw_major = QLC_SHARED_REG_RD32(adapter, QLCNIC_FW_VERSION_MAJOR);
fw_minor = QLCRD32(adapter, QLCNIC_FW_VERSION_MINOR); fw_minor = QLC_SHARED_REG_RD32(adapter, QLCNIC_FW_VERSION_MINOR);
fw_build = QLCRD32(adapter, QLCNIC_FW_VERSION_SUB); fw_build = QLC_SHARED_REG_RD32(adapter, QLCNIC_FW_VERSION_SUB);
adapter->fw_version = QLCNIC_VERSION_CODE(fw_major, fw_minor, fw_build); adapter->fw_version = QLCNIC_VERSION_CODE(fw_major, fw_minor, fw_build);
if (adapter->ahw->op_mode != QLCNIC_NON_PRIV_FUNC) { err = qlcnic_get_board_info(adapter);
if (err) {
dev_err(&pdev->dev, "Error getting board config info.\n");
return;
}
if (ahw->op_mode != QLCNIC_NON_PRIV_FUNC) {
if (fw_dump->tmpl_hdr == NULL || if (fw_dump->tmpl_hdr == NULL ||
adapter->fw_version > prev_fw_version) { adapter->fw_version > prev_fw_version) {
if (fw_dump->tmpl_hdr) if (fw_dump->tmpl_hdr)
...@@ -1010,10 +1017,12 @@ static int qlcnic_check_npar_opertional(struct qlcnic_adapter *adapter) ...@@ -1010,10 +1017,12 @@ static int qlcnic_check_npar_opertional(struct qlcnic_adapter *adapter)
if (adapter->ahw->op_mode == QLCNIC_MGMT_FUNC) if (adapter->ahw->op_mode == QLCNIC_MGMT_FUNC)
return 0; return 0;
npar_state = QLCRD32(adapter, QLCNIC_CRB_DEV_NPAR_STATE); npar_state = QLC_SHARED_REG_RD32(adapter,
QLCNIC_CRB_DEV_NPAR_STATE);
while (npar_state != QLCNIC_DEV_NPAR_OPER && --npar_opt_timeo) { while (npar_state != QLCNIC_DEV_NPAR_OPER && --npar_opt_timeo) {
msleep(1000); msleep(1000);
npar_state = QLCRD32(adapter, QLCNIC_CRB_DEV_NPAR_STATE); npar_state = QLC_SHARED_REG_RD32(adapter,
QLCNIC_CRB_DEV_NPAR_STATE);
} }
if (!npar_opt_timeo) { if (!npar_opt_timeo) {
dev_err(&adapter->pdev->dev, dev_err(&adapter->pdev->dev,
...@@ -1085,9 +1094,8 @@ int qlcnic_82xx_start_firmware(struct qlcnic_adapter *adapter) ...@@ -1085,9 +1094,8 @@ int qlcnic_82xx_start_firmware(struct qlcnic_adapter *adapter)
if (err) if (err)
goto err_out; goto err_out;
QLCWR32(adapter, QLCNIC_CRB_DEV_STATE, QLCNIC_DEV_READY); QLC_SHARED_REG_WR32(adapter, QLCNIC_CRB_DEV_STATE, QLCNIC_DEV_READY);
qlcnic_idc_debug_info(adapter, 1); qlcnic_idc_debug_info(adapter, 1);
err = qlcnic_check_eswitch_mode(adapter); err = qlcnic_check_eswitch_mode(adapter);
if (err) { if (err) {
dev_err(&adapter->pdev->dev, dev_err(&adapter->pdev->dev,
...@@ -1105,7 +1113,7 @@ int qlcnic_82xx_start_firmware(struct qlcnic_adapter *adapter) ...@@ -1105,7 +1113,7 @@ int qlcnic_82xx_start_firmware(struct qlcnic_adapter *adapter)
return 0; return 0;
err_out: err_out:
QLCWR32(adapter, QLCNIC_CRB_DEV_STATE, QLCNIC_DEV_FAILED); QLC_SHARED_REG_WR32(adapter, QLCNIC_CRB_DEV_STATE, QLCNIC_DEV_FAILED);
dev_err(&adapter->pdev->dev, "Device state set to failed\n"); dev_err(&adapter->pdev->dev, "Device state set to failed\n");
qlcnic_release_firmware(adapter); qlcnic_release_firmware(adapter);
...@@ -1969,7 +1977,7 @@ static int qlcnic_check_temp(struct qlcnic_adapter *adapter) ...@@ -1969,7 +1977,7 @@ static int qlcnic_check_temp(struct qlcnic_adapter *adapter)
int rv = 0; int rv = 0;
if (qlcnic_82xx_check(adapter)) if (qlcnic_82xx_check(adapter))
temp = QLCRD32(adapter, CRB_TEMP_STATE); temp = QLC_SHARED_REG_RD32(adapter, QLCNIC_ASIC_TEMP);
temp_state = qlcnic_get_temp_state(temp); temp_state = qlcnic_get_temp_state(temp);
temp_val = qlcnic_get_temp_val(temp); temp_val = qlcnic_get_temp_val(temp);
...@@ -2131,7 +2139,7 @@ qlcnic_idc_debug_info(struct qlcnic_adapter *adapter, u8 encoding) ...@@ -2131,7 +2139,7 @@ qlcnic_idc_debug_info(struct qlcnic_adapter *adapter, u8 encoding)
val |= encoding << 7; val |= encoding << 7;
val |= (jiffies - adapter->dev_rst_time) << 8; val |= (jiffies - adapter->dev_rst_time) << 8;
QLCWR32(adapter, QLCNIC_CRB_DRV_SCRATCH, val); QLC_SHARED_REG_WR32(adapter, QLCNIC_CRB_DRV_SCRATCH, val);
adapter->dev_rst_time = jiffies; adapter->dev_rst_time = jiffies;
} }
...@@ -2146,14 +2154,14 @@ qlcnic_set_drv_state(struct qlcnic_adapter *adapter, u8 state) ...@@ -2146,14 +2154,14 @@ qlcnic_set_drv_state(struct qlcnic_adapter *adapter, u8 state)
if (qlcnic_api_lock(adapter)) if (qlcnic_api_lock(adapter))
return -EIO; return -EIO;
val = QLCRD32(adapter, QLCNIC_CRB_DRV_STATE); val = QLC_SHARED_REG_RD32(adapter, QLCNIC_CRB_DRV_STATE);
if (state == QLCNIC_DEV_NEED_RESET) if (state == QLCNIC_DEV_NEED_RESET)
QLC_DEV_SET_RST_RDY(val, adapter->portnum); QLC_DEV_SET_RST_RDY(val, adapter->portnum);
else if (state == QLCNIC_DEV_NEED_QUISCENT) else if (state == QLCNIC_DEV_NEED_QUISCENT)
QLC_DEV_SET_QSCNT_RDY(val, adapter->portnum); QLC_DEV_SET_QSCNT_RDY(val, adapter->portnum);
QLCWR32(adapter, QLCNIC_CRB_DRV_STATE, val); QLC_SHARED_REG_WR32(adapter, QLCNIC_CRB_DRV_STATE, val);
qlcnic_api_unlock(adapter); qlcnic_api_unlock(adapter);
...@@ -2168,9 +2176,9 @@ qlcnic_clr_drv_state(struct qlcnic_adapter *adapter) ...@@ -2168,9 +2176,9 @@ qlcnic_clr_drv_state(struct qlcnic_adapter *adapter)
if (qlcnic_api_lock(adapter)) if (qlcnic_api_lock(adapter))
return -EBUSY; return -EBUSY;
val = QLCRD32(adapter, QLCNIC_CRB_DRV_STATE); val = QLC_SHARED_REG_RD32(adapter, QLCNIC_CRB_DRV_STATE);
QLC_DEV_CLR_RST_QSCNT(val, adapter->portnum); QLC_DEV_CLR_RST_QSCNT(val, adapter->portnum);
QLCWR32(adapter, QLCNIC_CRB_DRV_STATE, val); QLC_SHARED_REG_WR32(adapter, QLCNIC_CRB_DRV_STATE, val);
qlcnic_api_unlock(adapter); qlcnic_api_unlock(adapter);
...@@ -2185,20 +2193,22 @@ qlcnic_clr_all_drv_state(struct qlcnic_adapter *adapter, u8 failed) ...@@ -2185,20 +2193,22 @@ qlcnic_clr_all_drv_state(struct qlcnic_adapter *adapter, u8 failed)
if (qlcnic_api_lock(adapter)) if (qlcnic_api_lock(adapter))
goto err; goto err;
val = QLCRD32(adapter, QLCNIC_CRB_DRV_ACTIVE); val = QLC_SHARED_REG_RD32(adapter, QLCNIC_CRB_DRV_ACTIVE);
QLC_DEV_CLR_REF_CNT(val, adapter->portnum); QLC_DEV_CLR_REF_CNT(val, adapter->portnum);
QLCWR32(adapter, QLCNIC_CRB_DRV_ACTIVE, val); QLC_SHARED_REG_WR32(adapter, QLCNIC_CRB_DRV_ACTIVE, val);
if (failed) { if (failed) {
QLCWR32(adapter, QLCNIC_CRB_DEV_STATE, QLCNIC_DEV_FAILED); QLC_SHARED_REG_WR32(adapter, QLCNIC_CRB_DEV_STATE,
QLCNIC_DEV_FAILED);
dev_info(&adapter->pdev->dev, dev_info(&adapter->pdev->dev,
"Device state set to Failed. Please Reboot\n"); "Device state set to Failed. Please Reboot\n");
} else if (!(val & 0x11111111)) } else if (!(val & 0x11111111))
QLCWR32(adapter, QLCNIC_CRB_DEV_STATE, QLCNIC_DEV_COLD); QLC_SHARED_REG_WR32(adapter, QLCNIC_CRB_DEV_STATE,
QLCNIC_DEV_COLD);
val = QLCRD32(adapter, QLCNIC_CRB_DRV_STATE); val = QLC_SHARED_REG_RD32(adapter, QLCNIC_CRB_DRV_STATE);
QLC_DEV_CLR_RST_QSCNT(val, adapter->portnum); QLC_DEV_CLR_RST_QSCNT(val, adapter->portnum);
QLCWR32(adapter, QLCNIC_CRB_DRV_STATE, val); QLC_SHARED_REG_WR32(adapter, QLCNIC_CRB_DRV_STATE, val);
qlcnic_api_unlock(adapter); qlcnic_api_unlock(adapter);
err: err:
...@@ -2213,12 +2223,13 @@ static int ...@@ -2213,12 +2223,13 @@ static int
qlcnic_check_drv_state(struct qlcnic_adapter *adapter) qlcnic_check_drv_state(struct qlcnic_adapter *adapter)
{ {
int act, state, active_mask; int act, state, active_mask;
struct qlcnic_hardware_context *ahw = adapter->ahw;
state = QLCRD32(adapter, QLCNIC_CRB_DRV_STATE); state = QLC_SHARED_REG_RD32(adapter, QLCNIC_CRB_DRV_STATE);
act = QLCRD32(adapter, QLCNIC_CRB_DRV_ACTIVE); act = QLC_SHARED_REG_RD32(adapter, QLCNIC_CRB_DRV_ACTIVE);
if (adapter->flags & QLCNIC_FW_RESET_OWNER) { if (adapter->flags & QLCNIC_FW_RESET_OWNER) {
active_mask = (~(1 << (adapter->ahw->pci_func * 4))); active_mask = (~(1 << (ahw->pci_func * 4)));
act = act & active_mask; act = act & active_mask;
} }
...@@ -2231,7 +2242,7 @@ qlcnic_check_drv_state(struct qlcnic_adapter *adapter) ...@@ -2231,7 +2242,7 @@ qlcnic_check_drv_state(struct qlcnic_adapter *adapter)
static int qlcnic_check_idc_ver(struct qlcnic_adapter *adapter) static int qlcnic_check_idc_ver(struct qlcnic_adapter *adapter)
{ {
u32 val = QLCRD32(adapter, QLCNIC_CRB_DRV_IDC_VER); u32 val = QLC_SHARED_REG_RD32(adapter, QLCNIC_CRB_DRV_IDC_VER);
if (val != QLCNIC_DRV_IDC_VER) { if (val != QLCNIC_DRV_IDC_VER) {
dev_warn(&adapter->pdev->dev, "IDC Version mismatch, driver's" dev_warn(&adapter->pdev->dev, "IDC Version mismatch, driver's"
...@@ -2255,19 +2266,21 @@ qlcnic_can_start_firmware(struct qlcnic_adapter *adapter) ...@@ -2255,19 +2266,21 @@ qlcnic_can_start_firmware(struct qlcnic_adapter *adapter)
if (qlcnic_api_lock(adapter)) if (qlcnic_api_lock(adapter))
return -1; return -1;
val = QLCRD32(adapter, QLCNIC_CRB_DRV_ACTIVE); val = QLC_SHARED_REG_RD32(adapter, QLCNIC_CRB_DRV_ACTIVE);
if (!(val & (1 << (portnum * 4)))) { if (!(val & (1 << (portnum * 4)))) {
QLC_DEV_SET_REF_CNT(val, portnum); QLC_DEV_SET_REF_CNT(val, portnum);
QLCWR32(adapter, QLCNIC_CRB_DRV_ACTIVE, val); QLC_SHARED_REG_WR32(adapter, QLCNIC_CRB_DRV_ACTIVE, val);
} }
prev_state = QLCRD32(adapter, QLCNIC_CRB_DEV_STATE); prev_state = QLC_SHARED_REG_RD32(adapter, QLCNIC_CRB_DEV_STATE);
QLCDB(adapter, HW, "Device state = %u\n", prev_state); QLCDB(adapter, HW, "Device state = %u\n", prev_state);
switch (prev_state) { switch (prev_state) {
case QLCNIC_DEV_COLD: case QLCNIC_DEV_COLD:
QLCWR32(adapter, QLCNIC_CRB_DEV_STATE, QLCNIC_DEV_INITIALIZING); QLC_SHARED_REG_WR32(adapter, QLCNIC_CRB_DEV_STATE,
QLCWR32(adapter, QLCNIC_CRB_DRV_IDC_VER, QLCNIC_DRV_IDC_VER); QLCNIC_DEV_INITIALIZING);
QLC_SHARED_REG_WR32(adapter, QLCNIC_CRB_DRV_IDC_VER,
QLCNIC_DRV_IDC_VER);
qlcnic_idc_debug_info(adapter, 0); qlcnic_idc_debug_info(adapter, 0);
qlcnic_api_unlock(adapter); qlcnic_api_unlock(adapter);
return 1; return 1;
...@@ -2278,15 +2291,15 @@ qlcnic_can_start_firmware(struct qlcnic_adapter *adapter) ...@@ -2278,15 +2291,15 @@ qlcnic_can_start_firmware(struct qlcnic_adapter *adapter)
return ret; return ret;
case QLCNIC_DEV_NEED_RESET: case QLCNIC_DEV_NEED_RESET:
val = QLCRD32(adapter, QLCNIC_CRB_DRV_STATE); val = QLC_SHARED_REG_RD32(adapter, QLCNIC_CRB_DRV_STATE);
QLC_DEV_SET_RST_RDY(val, portnum); QLC_DEV_SET_RST_RDY(val, portnum);
QLCWR32(adapter, QLCNIC_CRB_DRV_STATE, val); QLC_SHARED_REG_WR32(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 = QLC_SHARED_REG_RD32(adapter, QLCNIC_CRB_DRV_STATE);
QLC_DEV_SET_QSCNT_RDY(val, portnum); QLC_DEV_SET_QSCNT_RDY(val, portnum);
QLCWR32(adapter, QLCNIC_CRB_DRV_STATE, val); QLC_SHARED_REG_WR32(adapter, QLCNIC_CRB_DRV_STATE, val);
break; break;
case QLCNIC_DEV_FAILED: case QLCNIC_DEV_FAILED:
...@@ -2303,7 +2316,7 @@ qlcnic_can_start_firmware(struct qlcnic_adapter *adapter) ...@@ -2303,7 +2316,7 @@ qlcnic_can_start_firmware(struct qlcnic_adapter *adapter)
do { do {
msleep(1000); msleep(1000);
prev_state = QLCRD32(adapter, QLCNIC_CRB_DEV_STATE); prev_state = QLC_SHARED_REG_RD32(adapter, QLCNIC_CRB_DEV_STATE);
if (prev_state == QLCNIC_DEV_QUISCENT) if (prev_state == QLCNIC_DEV_QUISCENT)
continue; continue;
...@@ -2318,9 +2331,9 @@ qlcnic_can_start_firmware(struct qlcnic_adapter *adapter) ...@@ -2318,9 +2331,9 @@ qlcnic_can_start_firmware(struct qlcnic_adapter *adapter)
if (qlcnic_api_lock(adapter)) if (qlcnic_api_lock(adapter))
return -1; return -1;
val = QLCRD32(adapter, QLCNIC_CRB_DRV_STATE); val = QLC_SHARED_REG_RD32(adapter, QLCNIC_CRB_DRV_STATE);
QLC_DEV_CLR_RST_QSCNT(val, portnum); QLC_DEV_CLR_RST_QSCNT(val, portnum);
QLCWR32(adapter, QLCNIC_CRB_DRV_STATE, val); QLC_SHARED_REG_WR32(adapter, QLCNIC_CRB_DRV_STATE, val);
ret = qlcnic_check_idc_ver(adapter); ret = qlcnic_check_idc_ver(adapter);
qlcnic_api_unlock(adapter); qlcnic_api_unlock(adapter);
...@@ -2339,7 +2352,7 @@ qlcnic_fwinit_work(struct work_struct *work) ...@@ -2339,7 +2352,7 @@ qlcnic_fwinit_work(struct work_struct *work)
if (qlcnic_api_lock(adapter)) if (qlcnic_api_lock(adapter))
goto err_ret; goto err_ret;
dev_state = QLCRD32(adapter, QLCNIC_CRB_DEV_STATE); dev_state = QLC_SHARED_REG_RD32(adapter, QLCNIC_CRB_DEV_STATE);
if (dev_state == QLCNIC_DEV_QUISCENT || if (dev_state == QLCNIC_DEV_QUISCENT ||
dev_state == QLCNIC_DEV_NEED_QUISCENT) { dev_state == QLCNIC_DEV_NEED_QUISCENT) {
qlcnic_api_unlock(adapter); qlcnic_api_unlock(adapter);
...@@ -2368,17 +2381,19 @@ qlcnic_fwinit_work(struct work_struct *work) ...@@ -2368,17 +2381,19 @@ qlcnic_fwinit_work(struct work_struct *work)
if (!qlcnic_check_drv_state(adapter)) { if (!qlcnic_check_drv_state(adapter)) {
skip_ack_check: skip_ack_check:
dev_state = QLCRD32(adapter, QLCNIC_CRB_DEV_STATE); dev_state = QLC_SHARED_REG_RD32(adapter, QLCNIC_CRB_DEV_STATE);
if (dev_state == QLCNIC_DEV_NEED_RESET) { if (dev_state == QLCNIC_DEV_NEED_RESET) {
QLCWR32(adapter, QLCNIC_CRB_DEV_STATE, QLC_SHARED_REG_WR32(adapter, QLCNIC_CRB_DEV_STATE,
QLCNIC_DEV_INITIALIZING); QLCNIC_DEV_INITIALIZING);
set_bit(__QLCNIC_START_FW, &adapter->state); set_bit(__QLCNIC_START_FW, &adapter->state);
QLCDB(adapter, DRV, "Restarting fw\n"); QLCDB(adapter, DRV, "Restarting fw\n");
qlcnic_idc_debug_info(adapter, 0); qlcnic_idc_debug_info(adapter, 0);
val = QLCRD32(adapter, QLCNIC_CRB_DRV_STATE); val = QLC_SHARED_REG_RD32(adapter,
QLCNIC_CRB_DRV_STATE);
QLC_DEV_SET_RST_RDY(val, adapter->portnum); QLC_DEV_SET_RST_RDY(val, adapter->portnum);
QLCWR32(adapter, QLCNIC_CRB_DRV_STATE, val); QLC_SHARED_REG_WR32(adapter,
QLCNIC_CRB_DRV_STATE, val);
} }
qlcnic_api_unlock(adapter); qlcnic_api_unlock(adapter);
...@@ -2404,7 +2419,7 @@ qlcnic_fwinit_work(struct work_struct *work) ...@@ -2404,7 +2419,7 @@ qlcnic_fwinit_work(struct work_struct *work)
qlcnic_api_unlock(adapter); qlcnic_api_unlock(adapter);
wait_npar: wait_npar:
dev_state = QLCRD32(adapter, QLCNIC_CRB_DEV_STATE); dev_state = QLC_SHARED_REG_RD32(adapter, QLCNIC_CRB_DEV_STATE);
QLCDB(adapter, HW, "Func waiting: Device state=%u\n", dev_state); QLCDB(adapter, HW, "Func waiting: Device state=%u\n", dev_state);
switch (dev_state) { switch (dev_state) {
...@@ -2446,7 +2461,7 @@ qlcnic_detach_work(struct work_struct *work) ...@@ -2446,7 +2461,7 @@ qlcnic_detach_work(struct work_struct *work)
} else } else
qlcnic_down(adapter, netdev); qlcnic_down(adapter, netdev);
status = QLCRD32(adapter, QLCNIC_PEG_HALT_STATUS1); status = QLC_SHARED_REG_RD32(adapter, QLCNIC_PEG_HALT_STATUS1);
if (status & QLCNIC_RCODE_FATAL_ERROR) { if (status & QLCNIC_RCODE_FATAL_ERROR) {
dev_err(&adapter->pdev->dev, dev_err(&adapter->pdev->dev,
...@@ -2497,13 +2512,14 @@ qlcnic_set_npar_non_operational(struct qlcnic_adapter *adapter) ...@@ -2497,13 +2512,14 @@ qlcnic_set_npar_non_operational(struct qlcnic_adapter *adapter)
{ {
u32 state; u32 state;
state = QLCRD32(adapter, QLCNIC_CRB_DEV_NPAR_STATE); state = QLC_SHARED_REG_RD32(adapter, QLCNIC_CRB_DEV_NPAR_STATE);
if (state == QLCNIC_DEV_NPAR_NON_OPER) if (state == QLCNIC_DEV_NPAR_NON_OPER)
return; return;
if (qlcnic_api_lock(adapter)) if (qlcnic_api_lock(adapter))
return; return;
QLCWR32(adapter, QLCNIC_CRB_DEV_NPAR_STATE, QLCNIC_DEV_NPAR_NON_OPER); QLC_SHARED_REG_WR32(adapter, QLCNIC_CRB_DEV_NPAR_STATE,
QLCNIC_DEV_NPAR_NON_OPER);
qlcnic_api_unlock(adapter); qlcnic_api_unlock(adapter);
} }
...@@ -2551,7 +2567,8 @@ qlcnic_dev_set_npar_ready(struct qlcnic_adapter *adapter) ...@@ -2551,7 +2567,8 @@ qlcnic_dev_set_npar_ready(struct qlcnic_adapter *adapter)
if (qlcnic_api_lock(adapter)) if (qlcnic_api_lock(adapter))
return; return;
QLCWR32(adapter, QLCNIC_CRB_DEV_NPAR_STATE, QLCNIC_DEV_NPAR_OPER); QLC_SHARED_REG_WR32(adapter, QLCNIC_CRB_DEV_NPAR_STATE,
QLCNIC_DEV_NPAR_OPER);
QLCDB(adapter, DRV, "NPAR operational state set\n"); QLCDB(adapter, DRV, "NPAR operational state set\n");
qlcnic_api_unlock(adapter); qlcnic_api_unlock(adapter);
...@@ -2590,7 +2607,8 @@ qlcnic_attach_work(struct work_struct *work) ...@@ -2590,7 +2607,8 @@ qlcnic_attach_work(struct work_struct *work)
u32 npar_state; u32 npar_state;
if (adapter->ahw->op_mode != QLCNIC_MGMT_FUNC) { if (adapter->ahw->op_mode != QLCNIC_MGMT_FUNC) {
npar_state = QLCRD32(adapter, QLCNIC_CRB_DEV_NPAR_STATE); npar_state = QLC_SHARED_REG_RD32(adapter,
QLCNIC_CRB_DEV_NPAR_STATE);
if (adapter->fw_wait_cnt++ > QLCNIC_DEV_NPAR_OPER_TIMEO) if (adapter->fw_wait_cnt++ > QLCNIC_DEV_NPAR_OPER_TIMEO)
qlcnic_clr_all_drv_state(adapter, 0); qlcnic_clr_all_drv_state(adapter, 0);
else if (npar_state != QLCNIC_DEV_NPAR_OPER) else if (npar_state != QLCNIC_DEV_NPAR_OPER)
...@@ -2632,14 +2650,14 @@ qlcnic_check_health(struct qlcnic_adapter *adapter) ...@@ -2632,14 +2650,14 @@ qlcnic_check_health(struct qlcnic_adapter *adapter)
if (adapter->need_fw_reset) if (adapter->need_fw_reset)
qlcnic_dev_request_reset(adapter, 0); qlcnic_dev_request_reset(adapter, 0);
state = QLCRD32(adapter, QLCNIC_CRB_DEV_STATE); state = QLC_SHARED_REG_RD32(adapter, QLCNIC_CRB_DEV_STATE);
if (state == QLCNIC_DEV_NEED_RESET) { if (state == QLCNIC_DEV_NEED_RESET) {
qlcnic_set_npar_non_operational(adapter); qlcnic_set_npar_non_operational(adapter);
adapter->need_fw_reset = 1; adapter->need_fw_reset = 1;
} else if (state == QLCNIC_DEV_NEED_QUISCENT) } else if (state == QLCNIC_DEV_NEED_QUISCENT)
goto detach; goto detach;
heartbeat = QLCRD32(adapter, QLCNIC_PEG_ALIVE_COUNTER); heartbeat = QLC_SHARED_REG_RD32(adapter, QLCNIC_PEG_ALIVE_COUNTER);
if (heartbeat != adapter->heartbeat) { if (heartbeat != adapter->heartbeat) {
adapter->heartbeat = heartbeat; adapter->heartbeat = heartbeat;
adapter->fw_fail_cnt = 0; adapter->fw_fail_cnt = 0;
...@@ -2665,19 +2683,19 @@ qlcnic_check_health(struct qlcnic_adapter *adapter) ...@@ -2665,19 +2683,19 @@ qlcnic_check_health(struct qlcnic_adapter *adapter)
clear_bit(__QLCNIC_FW_ATTACHED, &adapter->state); clear_bit(__QLCNIC_FW_ATTACHED, &adapter->state);
dev_err(&adapter->pdev->dev, "firmware hang detected\n"); dev_err(&adapter->pdev->dev, "firmware hang detected\n");
peg_status = QLC_SHARED_REG_RD32(adapter, QLCNIC_PEG_HALT_STATUS1);
dev_err(&adapter->pdev->dev, "Dumping hw/fw registers\n" dev_err(&adapter->pdev->dev, "Dumping hw/fw registers\n"
"PEG_HALT_STATUS1: 0x%x, PEG_HALT_STATUS2: 0x%x,\n" "PEG_HALT_STATUS1: 0x%x, PEG_HALT_STATUS2: 0x%x,\n"
"PEG_NET_0_PC: 0x%x, PEG_NET_1_PC: 0x%x,\n" "PEG_NET_0_PC: 0x%x, PEG_NET_1_PC: 0x%x,\n"
"PEG_NET_2_PC: 0x%x, PEG_NET_3_PC: 0x%x,\n" "PEG_NET_2_PC: 0x%x, PEG_NET_3_PC: 0x%x,\n"
"PEG_NET_4_PC: 0x%x\n", "PEG_NET_4_PC: 0x%x\n",
QLCRD32(adapter, QLCNIC_PEG_HALT_STATUS1), peg_status,
QLCRD32(adapter, QLCNIC_PEG_HALT_STATUS2), QLC_SHARED_REG_RD32(adapter, QLCNIC_PEG_HALT_STATUS2),
QLCRD32(adapter, QLCNIC_CRB_PEG_NET_0 + 0x3c), QLCRD32(adapter, QLCNIC_CRB_PEG_NET_0 + 0x3c),
QLCRD32(adapter, QLCNIC_CRB_PEG_NET_1 + 0x3c), QLCRD32(adapter, QLCNIC_CRB_PEG_NET_1 + 0x3c),
QLCRD32(adapter, QLCNIC_CRB_PEG_NET_2 + 0x3c), QLCRD32(adapter, QLCNIC_CRB_PEG_NET_2 + 0x3c),
QLCRD32(adapter, QLCNIC_CRB_PEG_NET_3 + 0x3c), QLCRD32(adapter, QLCNIC_CRB_PEG_NET_3 + 0x3c),
QLCRD32(adapter, QLCNIC_CRB_PEG_NET_4 + 0x3c)); QLCRD32(adapter, QLCNIC_CRB_PEG_NET_4 + 0x3c));
peg_status = QLCRD32(adapter, QLCNIC_PEG_HALT_STATUS1);
if (QLCNIC_FWERROR_CODE(peg_status) == 0x67) if (QLCNIC_FWERROR_CODE(peg_status) == 0x67)
dev_err(&adapter->pdev->dev, dev_err(&adapter->pdev->dev,
"Firmware aborted with error code 0x00006700. " "Firmware aborted with error code 0x00006700. "
...@@ -2761,7 +2779,8 @@ static int qlcnic_attach_func(struct pci_dev *pdev) ...@@ -2761,7 +2779,8 @@ static int qlcnic_attach_func(struct pci_dev *pdev)
if (adapter->ahw->op_mode != QLCNIC_NON_PRIV_FUNC && first_func) { if (adapter->ahw->op_mode != QLCNIC_NON_PRIV_FUNC && first_func) {
adapter->need_fw_reset = 1; adapter->need_fw_reset = 1;
set_bit(__QLCNIC_START_FW, &adapter->state); set_bit(__QLCNIC_START_FW, &adapter->state);
QLCWR32(adapter, QLCNIC_CRB_DEV_STATE, QLCNIC_DEV_INITIALIZING); QLC_SHARED_REG_WR32(adapter, QLCNIC_CRB_DEV_STATE,
QLCNIC_DEV_INITIALIZING);
QLCDB(adapter, DRV, "Restarting fw\n"); QLCDB(adapter, DRV, "Restarting fw\n");
} }
qlcnic_api_unlock(adapter); qlcnic_api_unlock(adapter);
...@@ -2832,12 +2851,13 @@ static pci_ers_result_t qlcnic_io_slot_reset(struct pci_dev *pdev) ...@@ -2832,12 +2851,13 @@ static pci_ers_result_t qlcnic_io_slot_reset(struct pci_dev *pdev)
static void qlcnic_io_resume(struct pci_dev *pdev) static void qlcnic_io_resume(struct pci_dev *pdev)
{ {
u32 state;
struct qlcnic_adapter *adapter = pci_get_drvdata(pdev); struct qlcnic_adapter *adapter = pci_get_drvdata(pdev);
pci_cleanup_aer_uncorrect_error_status(pdev); pci_cleanup_aer_uncorrect_error_status(pdev);
state = QLC_SHARED_REG_RD32(adapter, QLCNIC_CRB_DEV_STATE);
if (QLCRD32(adapter, QLCNIC_CRB_DEV_STATE) == QLCNIC_DEV_READY && if (state == QLCNIC_DEV_READY && test_and_clear_bit(__QLCNIC_AER,
test_and_clear_bit(__QLCNIC_AER, &adapter->state)) &adapter->state))
qlcnic_schedule_work(adapter, qlcnic_fw_poll_work, qlcnic_schedule_work(adapter, qlcnic_fw_poll_work,
FW_POLL_DELAY); FW_POLL_DELAY);
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册