Lines Matching refs:hw

102 static void csio_hw_initialize(struct csio_hw *hw);
103 static void csio_evtq_stop(struct csio_hw *hw);
104 static void csio_evtq_start(struct csio_hw *hw);
106 int csio_is_hw_ready(struct csio_hw *hw) in csio_is_hw_ready() argument
108 return csio_match_state(hw, csio_hws_ready); in csio_is_hw_ready()
111 int csio_is_hw_removing(struct csio_hw *hw) in csio_is_hw_removing() argument
113 return csio_match_state(hw, csio_hws_removing); in csio_is_hw_removing()
133 csio_hw_wait_op_done_val(struct csio_hw *hw, int reg, uint32_t mask, in csio_hw_wait_op_done_val() argument
138 val = csio_rd_reg32(hw, reg); in csio_hw_wait_op_done_val()
163 csio_hw_tp_wr_bits_indirect(struct csio_hw *hw, unsigned int addr, in csio_hw_tp_wr_bits_indirect() argument
166 csio_wr_reg32(hw, addr, TP_PIO_ADDR_A); in csio_hw_tp_wr_bits_indirect()
167 val |= csio_rd_reg32(hw, TP_PIO_DATA_A) & ~mask; in csio_hw_tp_wr_bits_indirect()
168 csio_wr_reg32(hw, val, TP_PIO_DATA_A); in csio_hw_tp_wr_bits_indirect()
172 csio_set_reg_field(struct csio_hw *hw, uint32_t reg, uint32_t mask, in csio_set_reg_field() argument
175 uint32_t val = csio_rd_reg32(hw, reg) & ~mask; in csio_set_reg_field()
177 csio_wr_reg32(hw, val | value, reg); in csio_set_reg_field()
179 csio_rd_reg32(hw, reg); in csio_set_reg_field()
184 csio_memory_write(struct csio_hw *hw, int mtype, u32 addr, u32 len, u32 *buf) in csio_memory_write() argument
186 return hw->chip_ops->chip_memory_rw(hw, MEMWIN_CSIOSTOR, mtype, in csio_memory_write()
212 csio_hw_seeprom_read(struct csio_hw *hw, uint32_t addr, uint32_t *data) in csio_hw_seeprom_read() argument
216 uint32_t base = hw->params.pci.vpd_cap_addr; in csio_hw_seeprom_read()
221 pci_write_config_word(hw->pdev, base + PCI_VPD_ADDR, (uint16_t)addr); in csio_hw_seeprom_read()
225 pci_read_config_word(hw->pdev, base + PCI_VPD_ADDR, &val); in csio_hw_seeprom_read()
229 csio_err(hw, "reading EEPROM address 0x%x failed\n", addr); in csio_hw_seeprom_read()
233 pci_read_config_dword(hw->pdev, base + PCI_VPD_DATA, data); in csio_hw_seeprom_read()
303 csio_hw_get_vpd_params(struct csio_hw *hw, struct csio_vpd *p) in csio_hw_get_vpd_params() argument
311 if (csio_is_valid_vpd(hw)) in csio_hw_get_vpd_params()
314 ret = csio_pci_capability(hw->pdev, PCI_CAP_ID_VPD, in csio_hw_get_vpd_params()
315 &hw->params.pci.vpd_cap_addr); in csio_hw_get_vpd_params()
327 ret = csio_hw_seeprom_read(hw, VPD_BASE, (uint32_t *)(vpd)); in csio_hw_get_vpd_params()
331 ret = csio_hw_seeprom_read(hw, addr + i, (uint32_t *)(vpd + i)); in csio_hw_get_vpd_params()
339 hw->flags &= (~CSIO_HWF_VPD_VALID); in csio_hw_get_vpd_params()
346 csio_err(hw, "missing VPD keyword " name "\n"); \ in csio_hw_get_vpd_params()
357 csio_err(hw, "corrupted VPD EEPROM, actual csum %u\n", csum); in csio_hw_get_vpd_params()
373 csio_valid_vpd_copied(hw); in csio_hw_get_vpd_params()
392 csio_hw_sf1_read(struct csio_hw *hw, uint32_t byte_cnt, int32_t cont, in csio_hw_sf1_read() argument
399 if (csio_rd_reg32(hw, SF_OP_A) & SF_BUSY_F) in csio_hw_sf1_read()
402 csio_wr_reg32(hw, SF_LOCK_V(lock) | SF_CONT_V(cont) | in csio_hw_sf1_read()
404 ret = csio_hw_wait_op_done_val(hw, SF_OP_A, SF_BUSY_F, 0, SF_ATTEMPTS, in csio_hw_sf1_read()
407 *valp = csio_rd_reg32(hw, SF_DATA_A); in csio_hw_sf1_read()
424 csio_hw_sf1_write(struct csio_hw *hw, uint32_t byte_cnt, uint32_t cont, in csio_hw_sf1_write() argument
429 if (csio_rd_reg32(hw, SF_OP_A) & SF_BUSY_F) in csio_hw_sf1_write()
432 csio_wr_reg32(hw, val, SF_DATA_A); in csio_hw_sf1_write()
433 csio_wr_reg32(hw, SF_CONT_V(cont) | BYTECNT_V(byte_cnt - 1) | in csio_hw_sf1_write()
436 return csio_hw_wait_op_done_val(hw, SF_OP_A, SF_BUSY_F, 0, SF_ATTEMPTS, in csio_hw_sf1_write()
449 csio_hw_flash_wait_op(struct csio_hw *hw, int32_t attempts, int32_t delay) in csio_hw_flash_wait_op() argument
455 ret = csio_hw_sf1_write(hw, 1, 1, 1, SF_RD_STATUS); in csio_hw_flash_wait_op()
459 ret = csio_hw_sf1_read(hw, 1, 0, 1, &status); in csio_hw_flash_wait_op()
486 csio_hw_read_flash(struct csio_hw *hw, uint32_t addr, uint32_t nwords, in csio_hw_read_flash() argument
491 if (addr + nwords * sizeof(uint32_t) > hw->params.sf_size || (addr & 3)) in csio_hw_read_flash()
496 ret = csio_hw_sf1_write(hw, 4, 1, 0, addr); in csio_hw_read_flash()
500 ret = csio_hw_sf1_read(hw, 1, 1, 0, data); in csio_hw_read_flash()
505 ret = csio_hw_sf1_read(hw, 4, nwords > 1, nwords == 1, data); in csio_hw_read_flash()
507 csio_wr_reg32(hw, 0, SF_OP_A); /* unlock SF */ in csio_hw_read_flash()
527 csio_hw_write_flash(struct csio_hw *hw, uint32_t addr, in csio_hw_write_flash() argument
534 if (addr >= hw->params.sf_size || offset + n > SF_PAGE_SIZE) in csio_hw_write_flash()
539 ret = csio_hw_sf1_write(hw, 1, 0, 1, SF_WR_ENABLE); in csio_hw_write_flash()
543 ret = csio_hw_sf1_write(hw, 4, 1, 1, val); in csio_hw_write_flash()
552 ret = csio_hw_sf1_write(hw, c, c != left, 1, val); in csio_hw_write_flash()
556 ret = csio_hw_flash_wait_op(hw, 8, 1); in csio_hw_write_flash()
560 csio_wr_reg32(hw, 0, SF_OP_A); /* unlock SF */ in csio_hw_write_flash()
563 ret = csio_hw_read_flash(hw, addr & ~0xff, ARRAY_SIZE(buf), buf, 1); in csio_hw_write_flash()
568 csio_err(hw, in csio_hw_write_flash()
577 csio_wr_reg32(hw, 0, SF_OP_A); /* unlock SF */ in csio_hw_write_flash()
590 csio_hw_flash_erase_sectors(struct csio_hw *hw, int32_t start, int32_t end) in csio_hw_flash_erase_sectors() argument
596 ret = csio_hw_sf1_write(hw, 1, 0, 1, SF_WR_ENABLE); in csio_hw_flash_erase_sectors()
600 ret = csio_hw_sf1_write(hw, 4, 0, 1, in csio_hw_flash_erase_sectors()
605 ret = csio_hw_flash_wait_op(hw, 14, 500); in csio_hw_flash_erase_sectors()
613 csio_err(hw, "erase of flash sector %d failed, error %d\n", in csio_hw_flash_erase_sectors()
615 csio_wr_reg32(hw, 0, SF_OP_A); /* unlock SF */ in csio_hw_flash_erase_sectors()
620 csio_hw_print_fw_version(struct csio_hw *hw, char *str) in csio_hw_print_fw_version() argument
622 csio_info(hw, "%s: %u.%u.%u.%u\n", str, in csio_hw_print_fw_version()
623 FW_HDR_FW_VER_MAJOR_G(hw->fwrev), in csio_hw_print_fw_version()
624 FW_HDR_FW_VER_MINOR_G(hw->fwrev), in csio_hw_print_fw_version()
625 FW_HDR_FW_VER_MICRO_G(hw->fwrev), in csio_hw_print_fw_version()
626 FW_HDR_FW_VER_BUILD_G(hw->fwrev)); in csio_hw_print_fw_version()
637 csio_hw_get_fw_version(struct csio_hw *hw, uint32_t *vers) in csio_hw_get_fw_version() argument
639 return csio_hw_read_flash(hw, FLASH_FW_START + in csio_hw_get_fw_version()
652 csio_hw_get_tp_version(struct csio_hw *hw, u32 *vers) in csio_hw_get_tp_version() argument
654 return csio_hw_read_flash(hw, FLASH_FW_START + in csio_hw_get_tp_version()
668 csio_hw_fw_dload(struct csio_hw *hw, uint8_t *fw_data, uint32_t size) in csio_hw_fw_dload() argument
679 if ((!hw->params.sf_size) || (!hw->params.sf_nsec)) { in csio_hw_fw_dload()
680 csio_err(hw, "Serial Flash data invalid\n"); in csio_hw_fw_dload()
685 csio_err(hw, "FW image has no data\n"); in csio_hw_fw_dload()
690 csio_err(hw, "FW image size not multiple of 512 bytes\n"); in csio_hw_fw_dload()
695 csio_err(hw, "FW image size differs from size in FW header\n"); in csio_hw_fw_dload()
700 csio_err(hw, "FW image too large, max is %u bytes\n", in csio_hw_fw_dload()
709 csio_err(hw, "corrupted firmware image, checksum %#x\n", csum); in csio_hw_fw_dload()
713 sf_sec_size = hw->params.sf_size / hw->params.sf_nsec; in csio_hw_fw_dload()
716 csio_dbg(hw, "Erasing sectors... start:%d end:%d\n", in csio_hw_fw_dload()
719 ret = csio_hw_flash_erase_sectors(hw, FLASH_FW_START_SEC, in csio_hw_fw_dload()
722 csio_err(hw, "Flash Erase failed\n"); in csio_hw_fw_dload()
733 ret = csio_hw_write_flash(hw, FLASH_FW_START, SF_PAGE_SIZE, first_page); in csio_hw_fw_dload()
737 csio_dbg(hw, "Writing Flash .. start:%d end:%d\n", in csio_hw_fw_dload()
744 ret = csio_hw_write_flash(hw, addr, SF_PAGE_SIZE, fw_data); in csio_hw_fw_dload()
749 ret = csio_hw_write_flash(hw, in csio_hw_fw_dload()
757 csio_err(hw, "firmware download failed, error %d\n", ret); in csio_hw_fw_dload()
762 csio_hw_get_flash_params(struct csio_hw *hw) in csio_hw_get_flash_params() argument
767 ret = csio_hw_sf1_write(hw, 1, 1, 0, SF_RD_ID); in csio_hw_get_flash_params()
769 ret = csio_hw_sf1_read(hw, 3, 0, 1, &info); in csio_hw_get_flash_params()
770 csio_wr_reg32(hw, 0, SF_OP_A); /* unlock SF */ in csio_hw_get_flash_params()
778 hw->params.sf_nsec = 1 << (info - 16); in csio_hw_get_flash_params()
780 hw->params.sf_nsec = 64; in csio_hw_get_flash_params()
783 hw->params.sf_size = 1 << info; in csio_hw_get_flash_params()
793 csio_hw_dev_ready(struct csio_hw *hw) in csio_hw_dev_ready() argument
798 while (((reg = csio_rd_reg32(hw, PL_WHOAMI_A)) == 0xFFFFFFFF) && in csio_hw_dev_ready()
804 csio_err(hw, "PL_WHOAMI returned 0x%x, cnt:%d\n", reg, cnt); in csio_hw_dev_ready()
808 hw->pfn = SOURCEPF_G(reg); in csio_hw_dev_ready()
821 csio_do_hello(struct csio_hw *hw, enum csio_dev_state *state) in csio_do_hello() argument
832 mbp = mempool_alloc(hw->mb_mempool, GFP_ATOMIC); in csio_do_hello()
835 CSIO_INC_STATS(hw, n_err_nomem); in csio_do_hello()
840 csio_mb_hello(hw, mbp, CSIO_MB_DEFAULT_TMO, hw->pfn, in csio_do_hello()
841 hw->pfn, CSIO_MASTER_MAY, NULL); in csio_do_hello()
843 rv = csio_mb_issue(hw, mbp); in csio_do_hello()
845 csio_err(hw, "failed to issue HELLO cmd. ret:%d.\n", rv); in csio_do_hello()
849 csio_mb_process_hello_rsp(hw, mbp, &retval, state, &mpfn); in csio_do_hello()
851 csio_err(hw, "HELLO cmd failed with ret: %d\n", retval); in csio_do_hello()
857 if (hw->pfn == mpfn) { in csio_do_hello()
858 hw->flags |= CSIO_HWF_MASTER; in csio_do_hello()
885 spin_unlock_irq(&hw->lock); in csio_do_hello()
887 spin_lock_irq(&hw->lock); in csio_do_hello()
896 pcie_fw = csio_rd_reg32(hw, PCIE_FW_A); in csio_do_hello()
930 hw->flags &= ~CSIO_HWF_MASTER; in csio_do_hello()
948 if (hw->pfn == mpfn) in csio_do_hello()
949 csio_info(hw, "PF: %d, Coming up as MASTER, HW state: %s\n", in csio_do_hello()
950 hw->pfn, state_str); in csio_do_hello()
952 csio_info(hw, in csio_do_hello()
954 hw->pfn, mpfn, state_str); in csio_do_hello()
957 mempool_free(mbp, hw->mb_mempool); in csio_do_hello()
968 csio_do_bye(struct csio_hw *hw) in csio_do_bye() argument
973 mbp = mempool_alloc(hw->mb_mempool, GFP_ATOMIC); in csio_do_bye()
975 CSIO_INC_STATS(hw, n_err_nomem); in csio_do_bye()
979 csio_mb_bye(hw, mbp, CSIO_MB_DEFAULT_TMO, NULL); in csio_do_bye()
981 if (csio_mb_issue(hw, mbp)) { in csio_do_bye()
982 csio_err(hw, "Issue of BYE command failed\n"); in csio_do_bye()
983 mempool_free(mbp, hw->mb_mempool); in csio_do_bye()
989 mempool_free(mbp, hw->mb_mempool); in csio_do_bye()
993 mempool_free(mbp, hw->mb_mempool); in csio_do_bye()
1008 csio_do_reset(struct csio_hw *hw, bool fw_rst) in csio_do_reset() argument
1015 csio_wr_reg32(hw, PIORSTMODE_F | PIORST_F, PL_RST_A); in csio_do_reset()
1020 mbp = mempool_alloc(hw->mb_mempool, GFP_ATOMIC); in csio_do_reset()
1022 CSIO_INC_STATS(hw, n_err_nomem); in csio_do_reset()
1026 csio_mb_reset(hw, mbp, CSIO_MB_DEFAULT_TMO, in csio_do_reset()
1029 if (csio_mb_issue(hw, mbp)) { in csio_do_reset()
1030 csio_err(hw, "Issue of RESET command failed.n"); in csio_do_reset()
1031 mempool_free(mbp, hw->mb_mempool); in csio_do_reset()
1037 csio_err(hw, "RESET cmd failed with ret:0x%x.\n", retval); in csio_do_reset()
1038 mempool_free(mbp, hw->mb_mempool); in csio_do_reset()
1042 mempool_free(mbp, hw->mb_mempool); in csio_do_reset()
1048 csio_hw_validate_caps(struct csio_hw *hw, struct csio_mb *mbp) in csio_hw_validate_caps() argument
1056 csio_err(hw, "No FCoE Initiator capability in the firmware.\n"); in csio_hw_validate_caps()
1061 csio_err(hw, "No FCoE Control Offload capability\n"); in csio_hw_validate_caps()
1085 csio_hw_fw_halt(struct csio_hw *hw, uint32_t mbox, int32_t force) in csio_hw_fw_halt() argument
1096 mbp = mempool_alloc(hw->mb_mempool, GFP_ATOMIC); in csio_hw_fw_halt()
1098 CSIO_INC_STATS(hw, n_err_nomem); in csio_hw_fw_halt()
1102 csio_mb_reset(hw, mbp, CSIO_MB_DEFAULT_TMO, in csio_hw_fw_halt()
1106 if (csio_mb_issue(hw, mbp)) { in csio_hw_fw_halt()
1107 csio_err(hw, "Issue of RESET command failed!\n"); in csio_hw_fw_halt()
1108 mempool_free(mbp, hw->mb_mempool); in csio_hw_fw_halt()
1113 mempool_free(mbp, hw->mb_mempool); in csio_hw_fw_halt()
1130 csio_set_reg_field(hw, CIM_BOOT_CFG_A, UPCRST_F, UPCRST_F); in csio_hw_fw_halt()
1131 csio_set_reg_field(hw, PCIE_FW_A, PCIE_FW_HALT_F, in csio_hw_fw_halt()
1164 csio_hw_fw_restart(struct csio_hw *hw, uint32_t mbox, int32_t reset) in csio_hw_fw_restart() argument
1172 csio_set_reg_field(hw, PCIE_FW_A, PCIE_FW_HALT_F, 0); in csio_hw_fw_restart()
1182 csio_set_reg_field(hw, CIM_BOOT_CFG_A, UPCRST_F, 0); in csio_hw_fw_restart()
1184 if (csio_do_reset(hw, true) == 0) in csio_hw_fw_restart()
1188 csio_wr_reg32(hw, PIORSTMODE_F | PIORST_F, PL_RST_A); in csio_hw_fw_restart()
1193 csio_set_reg_field(hw, CIM_BOOT_CFG_A, UPCRST_F, 0); in csio_hw_fw_restart()
1195 if (!(csio_rd_reg32(hw, PCIE_FW_A) & PCIE_FW_HALT_F)) in csio_hw_fw_restart()
1227 csio_hw_fw_upgrade(struct csio_hw *hw, uint32_t mbox, in csio_hw_fw_upgrade() argument
1233 ret = csio_hw_fw_halt(hw, mbox, force); in csio_hw_fw_upgrade()
1237 ret = csio_hw_fw_dload(hw, (uint8_t *) fw_data, size); in csio_hw_fw_upgrade()
1250 return csio_hw_fw_restart(hw, mbox, reset); in csio_hw_fw_upgrade()
1259 csio_get_device_params(struct csio_hw *hw) in csio_get_device_params() argument
1261 struct csio_wrm *wrm = csio_hw_to_wrm(hw); in csio_get_device_params()
1269 hw->pport[i].portid = -1; in csio_get_device_params()
1271 mbp = mempool_alloc(hw->mb_mempool, GFP_ATOMIC); in csio_get_device_params()
1273 CSIO_INC_STATS(hw, n_err_nomem); in csio_get_device_params()
1291 csio_mb_params(hw, mbp, CSIO_MB_DEFAULT_TMO, hw->pfn, 0, in csio_get_device_params()
1293 if (csio_mb_issue(hw, mbp)) { in csio_get_device_params()
1294 csio_err(hw, "Issue of FW_PARAMS_CMD(read) failed!\n"); in csio_get_device_params()
1295 mempool_free(mbp, hw->mb_mempool); in csio_get_device_params()
1299 csio_mb_process_read_params_rsp(hw, mbp, &retval, in csio_get_device_params()
1302 csio_err(hw, "FW_PARAMS_CMD(read) failed with ret:0x%x!\n", in csio_get_device_params()
1304 mempool_free(mbp, hw->mb_mempool); in csio_get_device_params()
1309 hw->port_vec = param[0]; in csio_get_device_params()
1310 hw->vpd.cclk = param[1]; in csio_get_device_params()
1315 if ((hw->flags & CSIO_HWF_USING_SOFT_PARAMS) || in csio_get_device_params()
1316 !csio_is_hw_master(hw)) { in csio_get_device_params()
1317 hw->cfg_niq = param[5] - param[4] + 1; in csio_get_device_params()
1318 hw->cfg_neq = param[3] - param[2] + 1; in csio_get_device_params()
1319 csio_dbg(hw, "Using fwconfig max niqs %d neqs %d\n", in csio_get_device_params()
1320 hw->cfg_niq, hw->cfg_neq); in csio_get_device_params()
1323 hw->port_vec &= csio_port_mask; in csio_get_device_params()
1325 hw->num_pports = hweight32(hw->port_vec); in csio_get_device_params()
1327 csio_dbg(hw, "Port vector: 0x%x, #ports: %d\n", in csio_get_device_params()
1328 hw->port_vec, hw->num_pports); in csio_get_device_params()
1330 for (i = 0; i < hw->num_pports; i++) { in csio_get_device_params()
1331 while ((hw->port_vec & (1 << j)) == 0) in csio_get_device_params()
1333 hw->pport[i].portid = j++; in csio_get_device_params()
1334 csio_dbg(hw, "Found Port:%d\n", hw->pport[i].portid); in csio_get_device_params()
1336 mempool_free(mbp, hw->mb_mempool); in csio_get_device_params()
1348 csio_config_device_caps(struct csio_hw *hw) in csio_config_device_caps() argument
1354 mbp = mempool_alloc(hw->mb_mempool, GFP_ATOMIC); in csio_config_device_caps()
1356 CSIO_INC_STATS(hw, n_err_nomem); in csio_config_device_caps()
1361 csio_mb_caps_config(hw, mbp, CSIO_MB_DEFAULT_TMO, 0, 0, 0, 0, NULL); in csio_config_device_caps()
1363 if (csio_mb_issue(hw, mbp)) { in csio_config_device_caps()
1364 csio_err(hw, "Issue of FW_CAPS_CONFIG_CMD(r) failed!\n"); in csio_config_device_caps()
1370 csio_err(hw, "FW_CAPS_CONFIG_CMD(r) returned %d!\n", retval); in csio_config_device_caps()
1375 rv = csio_hw_validate_caps(hw, mbp); in csio_config_device_caps()
1380 if (hw->fw_state == CSIO_DEV_STATE_INIT) { in csio_config_device_caps()
1386 csio_mb_caps_config(hw, mbp, CSIO_MB_DEFAULT_TMO, true, true, in csio_config_device_caps()
1389 if (csio_mb_issue(hw, mbp)) { in csio_config_device_caps()
1390 csio_err(hw, "Issue of FW_CAPS_CONFIG_CMD(w) failed!\n"); in csio_config_device_caps()
1396 csio_err(hw, "FW_CAPS_CONFIG_CMD(w) returned %d!\n", retval); in csio_config_device_caps()
1402 mempool_free(mbp, hw->mb_mempool); in csio_config_device_caps()
1412 csio_enable_ports(struct csio_hw *hw) in csio_enable_ports() argument
1419 mbp = mempool_alloc(hw->mb_mempool, GFP_ATOMIC); in csio_enable_ports()
1421 CSIO_INC_STATS(hw, n_err_nomem); in csio_enable_ports()
1425 for (i = 0; i < hw->num_pports; i++) { in csio_enable_ports()
1426 portid = hw->pport[i].portid; in csio_enable_ports()
1429 csio_mb_port(hw, mbp, CSIO_MB_DEFAULT_TMO, portid, in csio_enable_ports()
1432 if (csio_mb_issue(hw, mbp)) { in csio_enable_ports()
1433 csio_err(hw, "failed to issue FW_PORT_CMD(r) port:%d\n", in csio_enable_ports()
1435 mempool_free(mbp, hw->mb_mempool); in csio_enable_ports()
1439 csio_mb_process_read_port_rsp(hw, mbp, &retval, in csio_enable_ports()
1440 &hw->pport[i].pcap); in csio_enable_ports()
1442 csio_err(hw, "FW_PORT_CMD(r) port:%d failed: 0x%x\n", in csio_enable_ports()
1444 mempool_free(mbp, hw->mb_mempool); in csio_enable_ports()
1449 csio_mb_port(hw, mbp, CSIO_MB_DEFAULT_TMO, portid, true, in csio_enable_ports()
1450 (PAUSE_RX | PAUSE_TX), hw->pport[i].pcap, NULL); in csio_enable_ports()
1452 if (csio_mb_issue(hw, mbp)) { in csio_enable_ports()
1453 csio_err(hw, "failed to issue FW_PORT_CMD(w) port:%d\n", in csio_enable_ports()
1455 mempool_free(mbp, hw->mb_mempool); in csio_enable_ports()
1461 csio_err(hw, "FW_PORT_CMD(w) port:%d failed :0x%x\n", in csio_enable_ports()
1463 mempool_free(mbp, hw->mb_mempool); in csio_enable_ports()
1469 mempool_free(mbp, hw->mb_mempool); in csio_enable_ports()
1480 csio_get_fcoe_resinfo(struct csio_hw *hw) in csio_get_fcoe_resinfo() argument
1482 struct csio_fcoe_res_info *res_info = &hw->fres_info; in csio_get_fcoe_resinfo()
1487 mbp = mempool_alloc(hw->mb_mempool, GFP_ATOMIC); in csio_get_fcoe_resinfo()
1489 CSIO_INC_STATS(hw, n_err_nomem); in csio_get_fcoe_resinfo()
1494 csio_fcoe_read_res_info_init_mb(hw, mbp, CSIO_MB_DEFAULT_TMO, NULL); in csio_get_fcoe_resinfo()
1496 if (csio_mb_issue(hw, mbp)) { in csio_get_fcoe_resinfo()
1497 csio_err(hw, "failed to issue FW_FCOE_RES_INFO_CMD\n"); in csio_get_fcoe_resinfo()
1498 mempool_free(mbp, hw->mb_mempool); in csio_get_fcoe_resinfo()
1505 csio_err(hw, "FW_FCOE_RES_INFO_CMD failed with ret x%x\n", in csio_get_fcoe_resinfo()
1507 mempool_free(mbp, hw->mb_mempool); in csio_get_fcoe_resinfo()
1524 csio_dbg(hw, "max ssns:%d max xchgs:%d\n", res_info->max_ssns, in csio_get_fcoe_resinfo()
1526 mempool_free(mbp, hw->mb_mempool); in csio_get_fcoe_resinfo()
1532 csio_hw_check_fwconfig(struct csio_hw *hw, u32 *param) in csio_hw_check_fwconfig() argument
1538 mbp = mempool_alloc(hw->mb_mempool, GFP_ATOMIC); in csio_hw_check_fwconfig()
1540 CSIO_INC_STATS(hw, n_err_nomem); in csio_hw_check_fwconfig()
1551 csio_mb_params(hw, mbp, CSIO_MB_DEFAULT_TMO, hw->pfn, 0, in csio_hw_check_fwconfig()
1553 if (csio_mb_issue(hw, mbp)) { in csio_hw_check_fwconfig()
1554 csio_err(hw, "Issue of FW_PARAMS_CMD(read) failed!\n"); in csio_hw_check_fwconfig()
1555 mempool_free(mbp, hw->mb_mempool); in csio_hw_check_fwconfig()
1559 csio_mb_process_read_params_rsp(hw, mbp, &retval, in csio_hw_check_fwconfig()
1562 csio_err(hw, "FW_PARAMS_CMD(read) failed with ret:0x%x!\n", in csio_hw_check_fwconfig()
1564 mempool_free(mbp, hw->mb_mempool); in csio_hw_check_fwconfig()
1568 mempool_free(mbp, hw->mb_mempool); in csio_hw_check_fwconfig()
1575 csio_hw_flash_config(struct csio_hw *hw, u32 *fw_cfg_param, char *path) in csio_hw_flash_config() argument
1579 struct pci_dev *pci_dev = hw->pdev; in csio_hw_flash_config()
1586 csio_err(hw, "could not find config file %s, err: %d\n", in csio_hw_flash_config()
1601 if (csio_hw_check_fwconfig(hw, fw_cfg_param) != 0) { in csio_hw_flash_config()
1609 ret = csio_memory_write(hw, mtype, maddr, in csio_hw_flash_config()
1623 ret = csio_memory_write(hw, mtype, maddr + size, 4, &last.word); in csio_hw_flash_config()
1626 csio_info(hw, "config file upgraded to %s\n", in csio_hw_flash_config()
1654 csio_hw_use_fwconfig(struct csio_hw *hw, int reset, u32 *fw_cfg_param) in csio_hw_use_fwconfig() argument
1668 rv = csio_do_reset(hw, true); in csio_hw_use_fwconfig()
1678 spin_unlock_irq(&hw->lock); in csio_hw_use_fwconfig()
1679 rv = csio_hw_flash_config(hw, fw_cfg_param, path); in csio_hw_use_fwconfig()
1680 spin_lock_irq(&hw->lock); in csio_hw_use_fwconfig()
1688 maddr = hw->chip_ops->chip_flash_cfg_addr(hw); in csio_hw_use_fwconfig()
1695 mbp = mempool_alloc(hw->mb_mempool, GFP_ATOMIC); in csio_hw_use_fwconfig()
1697 CSIO_INC_STATS(hw, n_err_nomem); in csio_hw_use_fwconfig()
1707 CSIO_INIT_MBP(mbp, caps_cmd, CSIO_MB_DEFAULT_TMO, hw, NULL, 1); in csio_hw_use_fwconfig()
1718 if (csio_mb_issue(hw, mbp)) { in csio_hw_use_fwconfig()
1731 CSIO_INIT_MBP(mbp, caps_cmd, CSIO_MB_DEFAULT_TMO, hw, NULL, 1); in csio_hw_use_fwconfig()
1737 if (csio_mb_issue(hw, mbp)) { in csio_hw_use_fwconfig()
1761 if (csio_mb_issue(hw, mbp)) { in csio_hw_use_fwconfig()
1768 csio_dbg(hw, "FW_CAPS_CONFIG_CMD returned %d!\n", rv); in csio_hw_use_fwconfig()
1772 mempool_free(mbp, hw->mb_mempool); in csio_hw_use_fwconfig()
1774 csio_warn(hw, in csio_hw_use_fwconfig()
1780 rv = csio_hw_validate_caps(hw, mbp); in csio_hw_use_fwconfig()
1788 hw->flags |= CSIO_HWF_USING_SOFT_PARAMS; in csio_hw_use_fwconfig()
1791 rv = csio_get_device_params(hw); in csio_hw_use_fwconfig()
1796 csio_wr_sge_init(hw); in csio_hw_use_fwconfig()
1803 csio_post_event(&hw->sm, CSIO_HWE_INIT); in csio_hw_use_fwconfig()
1805 csio_info(hw, "Successfully configure using Firmware " in csio_hw_use_fwconfig()
1815 mempool_free(mbp, hw->mb_mempool); in csio_hw_use_fwconfig()
1816 hw->flags &= ~CSIO_HWF_USING_SOFT_PARAMS; in csio_hw_use_fwconfig()
1817 csio_warn(hw, "Configuration file error %d\n", rv); in csio_hw_use_fwconfig()
1844 static int csio_should_install_fs_fw(struct csio_hw *hw, int card_fw_usable, in csio_should_install_fs_fw() argument
1862 csio_err(hw, "firmware on card (%u.%u.%u.%u) is %s, " in csio_should_install_fs_fw()
1900 static int csio_hw_prep_fw(struct csio_hw *hw, struct fw_info *fw_info, in csio_hw_prep_fw() argument
1912 ret = csio_hw_read_flash(hw, FLASH_FW_START, in csio_hw_prep_fw()
1918 csio_err(hw, in csio_hw_prep_fw()
1938 csio_should_install_fs_fw(hw, card_fw_usable, in csio_hw_prep_fw()
1941 ret = csio_hw_fw_upgrade(hw, hw->pfn, fw_data, in csio_hw_prep_fw()
1944 csio_err(hw, in csio_hw_prep_fw()
1962 csio_err(hw, "Cannot find a usable firmware: " in csio_hw_prep_fw()
1978 hw->fwrev = be32_to_cpu(card_fw->fw_ver); in csio_hw_prep_fw()
1979 hw->tp_vers = be32_to_cpu(card_fw->tp_microcode_ver); in csio_hw_prep_fw()
1992 csio_hw_flash_fw(struct csio_hw *hw, int *reset) in csio_hw_flash_fw() argument
1998 struct pci_dev *pci_dev = hw->pdev; in csio_hw_flash_fw()
2006 fw_info = find_fw_info(CHELSIO_CHIP_VERSION(hw->chip_id)); in csio_hw_flash_fw()
2008 csio_err(hw, in csio_hw_flash_fw()
2010 CHELSIO_CHIP_VERSION(hw->chip_id)); in csio_hw_flash_fw()
2015 csio_err(hw, "could not find firmware image %s, err: %d\n", in csio_hw_flash_fw()
2028 ret = csio_hw_prep_fw(hw, fw_info, fw_data, fw_size, card_fw, in csio_hw_flash_fw()
2029 hw->fw_state, reset); in csio_hw_flash_fw()
2044 csio_hw_configure(struct csio_hw *hw) in csio_hw_configure() argument
2050 rv = csio_hw_dev_ready(hw); in csio_hw_configure()
2052 CSIO_INC_STATS(hw, n_err_fatal); in csio_hw_configure()
2053 csio_post_event(&hw->sm, CSIO_HWE_FATAL); in csio_hw_configure()
2058 hw->chip_ver = (char)csio_rd_reg32(hw, PL_REV_A); in csio_hw_configure()
2061 rv = csio_hw_get_flash_params(hw); in csio_hw_configure()
2063 csio_err(hw, "Failed to get serial flash params rv:%d\n", rv); in csio_hw_configure()
2064 csio_post_event(&hw->sm, CSIO_HWE_FATAL); in csio_hw_configure()
2069 if (pci_is_pcie(hw->pdev)) in csio_hw_configure()
2070 pcie_capability_clear_and_set_word(hw->pdev, PCI_EXP_DEVCTL2, in csio_hw_configure()
2073 hw->chip_ops->chip_set_mem_win(hw, MEMWIN_CSIOSTOR); in csio_hw_configure()
2075 rv = csio_hw_get_fw_version(hw, &hw->fwrev); in csio_hw_configure()
2079 csio_hw_print_fw_version(hw, "Firmware revision"); in csio_hw_configure()
2081 rv = csio_do_hello(hw, &hw->fw_state); in csio_hw_configure()
2083 CSIO_INC_STATS(hw, n_err_fatal); in csio_hw_configure()
2084 csio_post_event(&hw->sm, CSIO_HWE_FATAL); in csio_hw_configure()
2089 rv = csio_hw_get_vpd_params(hw, &hw->vpd); in csio_hw_configure()
2093 csio_hw_get_fw_version(hw, &hw->fwrev); in csio_hw_configure()
2094 csio_hw_get_tp_version(hw, &hw->tp_vers); in csio_hw_configure()
2095 if (csio_is_hw_master(hw) && hw->fw_state != CSIO_DEV_STATE_INIT) { in csio_hw_configure()
2098 spin_unlock_irq(&hw->lock); in csio_hw_configure()
2099 rv = csio_hw_flash_fw(hw, &reset); in csio_hw_configure()
2100 spin_lock_irq(&hw->lock); in csio_hw_configure()
2108 rv = csio_hw_check_fwconfig(hw, param); in csio_hw_configure()
2110 csio_info(hw, "Firmware doesn't support " in csio_hw_configure()
2119 rv = csio_hw_use_fwconfig(hw, reset, param); in csio_hw_configure()
2121 csio_info(hw, "Could not initialize " in csio_hw_configure()
2126 csio_info(hw, "Could not initialize " in csio_hw_configure()
2132 if (hw->fw_state == CSIO_DEV_STATE_INIT) { in csio_hw_configure()
2134 hw->flags |= CSIO_HWF_USING_SOFT_PARAMS; in csio_hw_configure()
2137 rv = csio_get_device_params(hw); in csio_hw_configure()
2142 rv = csio_config_device_caps(hw); in csio_hw_configure()
2147 csio_wr_sge_init(hw); in csio_hw_configure()
2150 csio_post_event(&hw->sm, CSIO_HWE_INIT); in csio_hw_configure()
2165 csio_hw_initialize(struct csio_hw *hw) in csio_hw_initialize() argument
2172 if (csio_is_hw_master(hw) && hw->fw_state != CSIO_DEV_STATE_INIT) { in csio_hw_initialize()
2173 mbp = mempool_alloc(hw->mb_mempool, GFP_ATOMIC); in csio_hw_initialize()
2177 csio_mb_initialize(hw, mbp, CSIO_MB_DEFAULT_TMO, NULL); in csio_hw_initialize()
2179 if (csio_mb_issue(hw, mbp)) { in csio_hw_initialize()
2180 csio_err(hw, "Issue of FW_INITIALIZE_CMD failed!\n"); in csio_hw_initialize()
2186 csio_err(hw, "FW_INITIALIZE_CMD returned 0x%x!\n", in csio_hw_initialize()
2191 mempool_free(mbp, hw->mb_mempool); in csio_hw_initialize()
2194 rv = csio_get_fcoe_resinfo(hw); in csio_hw_initialize()
2196 csio_err(hw, "Failed to read fcoe resource info: %d\n", rv); in csio_hw_initialize()
2200 spin_unlock_irq(&hw->lock); in csio_hw_initialize()
2201 rv = csio_config_queues(hw); in csio_hw_initialize()
2202 spin_lock_irq(&hw->lock); in csio_hw_initialize()
2205 csio_err(hw, "Config of queues failed!: %d\n", rv); in csio_hw_initialize()
2209 for (i = 0; i < hw->num_pports; i++) in csio_hw_initialize()
2210 hw->pport[i].mod_type = FW_PORT_MOD_TYPE_NA; in csio_hw_initialize()
2212 if (csio_is_hw_master(hw) && hw->fw_state != CSIO_DEV_STATE_INIT) { in csio_hw_initialize()
2213 rv = csio_enable_ports(hw); in csio_hw_initialize()
2215 csio_err(hw, "Failed to enable ports: %d\n", rv); in csio_hw_initialize()
2220 csio_post_event(&hw->sm, CSIO_HWE_INIT_DONE); in csio_hw_initialize()
2224 mempool_free(mbp, hw->mb_mempool); in csio_hw_initialize()
2238 csio_hw_intr_enable(struct csio_hw *hw) in csio_hw_intr_enable() argument
2240 uint16_t vec = (uint16_t)csio_get_mb_intr_idx(csio_hw_to_mbm(hw)); in csio_hw_intr_enable()
2241 uint32_t pf = SOURCEPF_G(csio_rd_reg32(hw, PL_WHOAMI_A)); in csio_hw_intr_enable()
2242 uint32_t pl = csio_rd_reg32(hw, PL_INT_ENABLE_A); in csio_hw_intr_enable()
2248 if (hw->intr_mode == CSIO_IM_MSIX) in csio_hw_intr_enable()
2249 csio_set_reg_field(hw, MYPF_REG(PCIE_PF_CFG_A), in csio_hw_intr_enable()
2251 else if (hw->intr_mode == CSIO_IM_MSI) in csio_hw_intr_enable()
2252 csio_set_reg_field(hw, MYPF_REG(PCIE_PF_CFG_A), in csio_hw_intr_enable()
2255 csio_wr_reg32(hw, PF_INTR_MASK, MYPF_REG(PL_PF_INT_ENABLE_A)); in csio_hw_intr_enable()
2258 csio_mb_intr_enable(hw); in csio_hw_intr_enable()
2261 if (csio_is_hw_master(hw)) { in csio_hw_intr_enable()
2266 csio_wr_reg32(hw, pl, PL_INT_ENABLE_A); in csio_hw_intr_enable()
2268 csio_wr_reg32(hw, ERR_CPL_EXCEED_IQE_SIZE_F | in csio_hw_intr_enable()
2277 csio_set_reg_field(hw, PL_INT_MAP0_A, 0, 1 << pf); in csio_hw_intr_enable()
2280 hw->flags |= CSIO_HWF_HW_INTR_ENABLED; in csio_hw_intr_enable()
2291 csio_hw_intr_disable(struct csio_hw *hw) in csio_hw_intr_disable() argument
2293 uint32_t pf = SOURCEPF_G(csio_rd_reg32(hw, PL_WHOAMI_A)); in csio_hw_intr_disable()
2295 if (!(hw->flags & CSIO_HWF_HW_INTR_ENABLED)) in csio_hw_intr_disable()
2298 hw->flags &= ~CSIO_HWF_HW_INTR_ENABLED; in csio_hw_intr_disable()
2300 csio_wr_reg32(hw, 0, MYPF_REG(PL_PF_INT_ENABLE_A)); in csio_hw_intr_disable()
2301 if (csio_is_hw_master(hw)) in csio_hw_intr_disable()
2302 csio_set_reg_field(hw, PL_INT_MAP0_A, 1 << pf, 0); in csio_hw_intr_disable()
2305 csio_mb_intr_disable(hw); in csio_hw_intr_disable()
2310 csio_hw_fatal_err(struct csio_hw *hw) in csio_hw_fatal_err() argument
2312 csio_set_reg_field(hw, SGE_CONTROL_A, GLOBALENABLE_F, 0); in csio_hw_fatal_err()
2313 csio_hw_intr_disable(hw); in csio_hw_fatal_err()
2316 csio_fatal(hw, "HW Fatal error encountered!\n"); in csio_hw_fatal_err()
2329 csio_hws_uninit(struct csio_hw *hw, enum csio_hw_ev evt) in csio_hws_uninit() argument
2331 hw->prev_evt = hw->cur_evt; in csio_hws_uninit()
2332 hw->cur_evt = evt; in csio_hws_uninit()
2333 CSIO_INC_STATS(hw, n_evt_sm[evt]); in csio_hws_uninit()
2337 csio_set_state(&hw->sm, csio_hws_configuring); in csio_hws_uninit()
2338 csio_hw_configure(hw); in csio_hws_uninit()
2342 CSIO_INC_STATS(hw, n_evt_unexp); in csio_hws_uninit()
2354 csio_hws_configuring(struct csio_hw *hw, enum csio_hw_ev evt) in csio_hws_configuring() argument
2356 hw->prev_evt = hw->cur_evt; in csio_hws_configuring()
2357 hw->cur_evt = evt; in csio_hws_configuring()
2358 CSIO_INC_STATS(hw, n_evt_sm[evt]); in csio_hws_configuring()
2362 csio_set_state(&hw->sm, csio_hws_initializing); in csio_hws_configuring()
2363 csio_hw_initialize(hw); in csio_hws_configuring()
2367 csio_set_state(&hw->sm, csio_hws_ready); in csio_hws_configuring()
2369 csio_notify_lnodes(hw, CSIO_LN_NOTIFY_HWREADY); in csio_hws_configuring()
2373 csio_set_state(&hw->sm, csio_hws_uninit); in csio_hws_configuring()
2377 csio_do_bye(hw); in csio_hws_configuring()
2380 CSIO_INC_STATS(hw, n_evt_unexp); in csio_hws_configuring()
2392 csio_hws_initializing(struct csio_hw *hw, enum csio_hw_ev evt) in csio_hws_initializing() argument
2394 hw->prev_evt = hw->cur_evt; in csio_hws_initializing()
2395 hw->cur_evt = evt; in csio_hws_initializing()
2396 CSIO_INC_STATS(hw, n_evt_sm[evt]); in csio_hws_initializing()
2400 csio_set_state(&hw->sm, csio_hws_ready); in csio_hws_initializing()
2403 csio_notify_lnodes(hw, CSIO_LN_NOTIFY_HWREADY); in csio_hws_initializing()
2406 csio_hw_intr_enable(hw); in csio_hws_initializing()
2410 csio_set_state(&hw->sm, csio_hws_uninit); in csio_hws_initializing()
2414 csio_do_bye(hw); in csio_hws_initializing()
2418 CSIO_INC_STATS(hw, n_evt_unexp); in csio_hws_initializing()
2430 csio_hws_ready(struct csio_hw *hw, enum csio_hw_ev evt) in csio_hws_ready() argument
2433 hw->evtflag = evt; in csio_hws_ready()
2435 hw->prev_evt = hw->cur_evt; in csio_hws_ready()
2436 hw->cur_evt = evt; in csio_hws_ready()
2437 CSIO_INC_STATS(hw, n_evt_sm[evt]); in csio_hws_ready()
2445 csio_set_state(&hw->sm, csio_hws_quiescing); in csio_hws_ready()
2449 csio_scsim_cleanup_io(csio_hw_to_scsim(hw), false); in csio_hws_ready()
2451 csio_scsim_cleanup_io(csio_hw_to_scsim(hw), true); in csio_hws_ready()
2453 csio_hw_intr_disable(hw); in csio_hws_ready()
2454 csio_hw_mbm_cleanup(hw); in csio_hws_ready()
2455 csio_evtq_stop(hw); in csio_hws_ready()
2456 csio_notify_lnodes(hw, CSIO_LN_NOTIFY_HWSTOP); in csio_hws_ready()
2457 csio_evtq_flush(hw); in csio_hws_ready()
2458 csio_mgmtm_cleanup(csio_hw_to_mgmtm(hw)); in csio_hws_ready()
2459 csio_post_event(&hw->sm, CSIO_HWE_QUIESCED); in csio_hws_ready()
2463 csio_set_state(&hw->sm, csio_hws_uninit); in csio_hws_ready()
2467 CSIO_INC_STATS(hw, n_evt_unexp); in csio_hws_ready()
2479 csio_hws_quiescing(struct csio_hw *hw, enum csio_hw_ev evt) in csio_hws_quiescing() argument
2481 hw->prev_evt = hw->cur_evt; in csio_hws_quiescing()
2482 hw->cur_evt = evt; in csio_hws_quiescing()
2483 CSIO_INC_STATS(hw, n_evt_sm[evt]); in csio_hws_quiescing()
2487 switch (hw->evtflag) { in csio_hws_quiescing()
2489 csio_set_state(&hw->sm, csio_hws_resetting); in csio_hws_quiescing()
2494 csio_set_state(&hw->sm, csio_hws_resetting); in csio_hws_quiescing()
2496 csio_notify_lnodes(hw, CSIO_LN_NOTIFY_HWRESET); in csio_hws_quiescing()
2497 csio_wr_destroy_queues(hw, false); in csio_hws_quiescing()
2498 csio_do_reset(hw, false); in csio_hws_quiescing()
2499 csio_post_event(&hw->sm, CSIO_HWE_HBA_RESET_DONE); in csio_hws_quiescing()
2503 csio_set_state(&hw->sm, csio_hws_removing); in csio_hws_quiescing()
2504 csio_notify_lnodes(hw, CSIO_LN_NOTIFY_HWREMOVE); in csio_hws_quiescing()
2505 csio_wr_destroy_queues(hw, true); in csio_hws_quiescing()
2507 csio_do_bye(hw); in csio_hws_quiescing()
2511 csio_set_state(&hw->sm, csio_hws_quiesced); in csio_hws_quiescing()
2515 csio_set_state(&hw->sm, csio_hws_pcierr); in csio_hws_quiescing()
2516 csio_wr_destroy_queues(hw, false); in csio_hws_quiescing()
2520 CSIO_INC_STATS(hw, n_evt_unexp); in csio_hws_quiescing()
2527 CSIO_INC_STATS(hw, n_evt_unexp); in csio_hws_quiescing()
2539 csio_hws_quiesced(struct csio_hw *hw, enum csio_hw_ev evt) in csio_hws_quiesced() argument
2541 hw->prev_evt = hw->cur_evt; in csio_hws_quiesced()
2542 hw->cur_evt = evt; in csio_hws_quiesced()
2543 CSIO_INC_STATS(hw, n_evt_sm[evt]); in csio_hws_quiesced()
2547 csio_set_state(&hw->sm, csio_hws_configuring); in csio_hws_quiesced()
2548 csio_hw_configure(hw); in csio_hws_quiesced()
2552 CSIO_INC_STATS(hw, n_evt_unexp); in csio_hws_quiesced()
2564 csio_hws_resetting(struct csio_hw *hw, enum csio_hw_ev evt) in csio_hws_resetting() argument
2566 hw->prev_evt = hw->cur_evt; in csio_hws_resetting()
2567 hw->cur_evt = evt; in csio_hws_resetting()
2568 CSIO_INC_STATS(hw, n_evt_sm[evt]); in csio_hws_resetting()
2572 csio_evtq_start(hw); in csio_hws_resetting()
2573 csio_set_state(&hw->sm, csio_hws_configuring); in csio_hws_resetting()
2574 csio_hw_configure(hw); in csio_hws_resetting()
2578 CSIO_INC_STATS(hw, n_evt_unexp); in csio_hws_resetting()
2590 csio_hws_removing(struct csio_hw *hw, enum csio_hw_ev evt) in csio_hws_removing() argument
2592 hw->prev_evt = hw->cur_evt; in csio_hws_removing()
2593 hw->cur_evt = evt; in csio_hws_removing()
2594 CSIO_INC_STATS(hw, n_evt_sm[evt]); in csio_hws_removing()
2598 if (!csio_is_hw_master(hw)) in csio_hws_removing()
2605 csio_err(hw, "Resetting HW and waiting 2 seconds...\n"); in csio_hws_removing()
2606 csio_wr_reg32(hw, PIORSTMODE_F | PIORST_F, PL_RST_A); in csio_hws_removing()
2612 CSIO_INC_STATS(hw, n_evt_unexp); in csio_hws_removing()
2625 csio_hws_pcierr(struct csio_hw *hw, enum csio_hw_ev evt) in csio_hws_pcierr() argument
2627 hw->prev_evt = hw->cur_evt; in csio_hws_pcierr()
2628 hw->cur_evt = evt; in csio_hws_pcierr()
2629 CSIO_INC_STATS(hw, n_evt_sm[evt]); in csio_hws_pcierr()
2633 csio_evtq_start(hw); in csio_hws_pcierr()
2634 csio_set_state(&hw->sm, csio_hws_configuring); in csio_hws_pcierr()
2635 csio_hw_configure(hw); in csio_hws_pcierr()
2639 CSIO_INC_STATS(hw, n_evt_unexp); in csio_hws_pcierr()
2662 csio_handle_intr_status(struct csio_hw *hw, unsigned int reg, in csio_handle_intr_status() argument
2667 unsigned int status = csio_rd_reg32(hw, reg); in csio_handle_intr_status()
2674 csio_fatal(hw, "Fatal %s (0x%x)\n", in csio_handle_intr_status()
2677 csio_info(hw, "%s (0x%x)\n", in csio_handle_intr_status()
2683 csio_wr_reg32(hw, status, reg); in csio_handle_intr_status()
2690 static void csio_tp_intr_handler(struct csio_hw *hw) in csio_tp_intr_handler() argument
2698 if (csio_handle_intr_status(hw, TP_INT_CAUSE_A, tp_intr_info)) in csio_tp_intr_handler()
2699 csio_hw_fatal_err(hw); in csio_tp_intr_handler()
2705 static void csio_sge_intr_handler(struct csio_hw *hw) in csio_sge_intr_handler() argument
2735 v = (uint64_t)csio_rd_reg32(hw, SGE_INT_CAUSE1_A) | in csio_sge_intr_handler()
2736 ((uint64_t)csio_rd_reg32(hw, SGE_INT_CAUSE2_A) << 32); in csio_sge_intr_handler()
2738 csio_fatal(hw, "SGE parity error (%#llx)\n", in csio_sge_intr_handler()
2740 csio_wr_reg32(hw, (uint32_t)(v & 0xFFFFFFFF), in csio_sge_intr_handler()
2742 csio_wr_reg32(hw, (uint32_t)(v >> 32), SGE_INT_CAUSE2_A); in csio_sge_intr_handler()
2745 v |= csio_handle_intr_status(hw, SGE_INT_CAUSE3_A, sge_intr_info); in csio_sge_intr_handler()
2747 if (csio_handle_intr_status(hw, SGE_INT_CAUSE3_A, sge_intr_info) || in csio_sge_intr_handler()
2749 csio_hw_fatal_err(hw); in csio_sge_intr_handler()
2760 static void csio_cim_intr_handler(struct csio_hw *hw) in csio_cim_intr_handler() argument
2806 fat = csio_handle_intr_status(hw, CIM_HOST_INT_CAUSE_A, in csio_cim_intr_handler()
2808 csio_handle_intr_status(hw, CIM_HOST_UPACC_INT_CAUSE_A, in csio_cim_intr_handler()
2811 csio_hw_fatal_err(hw); in csio_cim_intr_handler()
2817 static void csio_ulprx_intr_handler(struct csio_hw *hw) in csio_ulprx_intr_handler() argument
2825 if (csio_handle_intr_status(hw, ULP_RX_INT_CAUSE_A, ulprx_intr_info)) in csio_ulprx_intr_handler()
2826 csio_hw_fatal_err(hw); in csio_ulprx_intr_handler()
2832 static void csio_ulptx_intr_handler(struct csio_hw *hw) in csio_ulptx_intr_handler() argument
2847 if (csio_handle_intr_status(hw, ULP_TX_INT_CAUSE_A, ulptx_intr_info)) in csio_ulptx_intr_handler()
2848 csio_hw_fatal_err(hw); in csio_ulptx_intr_handler()
2854 static void csio_pmtx_intr_handler(struct csio_hw *hw) in csio_pmtx_intr_handler() argument
2870 if (csio_handle_intr_status(hw, PM_TX_INT_CAUSE_A, pmtx_intr_info)) in csio_pmtx_intr_handler()
2871 csio_hw_fatal_err(hw); in csio_pmtx_intr_handler()
2877 static void csio_pmrx_intr_handler(struct csio_hw *hw) in csio_pmrx_intr_handler() argument
2890 if (csio_handle_intr_status(hw, PM_RX_INT_CAUSE_A, pmrx_intr_info)) in csio_pmrx_intr_handler()
2891 csio_hw_fatal_err(hw); in csio_pmrx_intr_handler()
2897 static void csio_cplsw_intr_handler(struct csio_hw *hw) in csio_cplsw_intr_handler() argument
2909 if (csio_handle_intr_status(hw, CPL_INTR_CAUSE_A, cplsw_intr_info)) in csio_cplsw_intr_handler()
2910 csio_hw_fatal_err(hw); in csio_cplsw_intr_handler()
2916 static void csio_le_intr_handler(struct csio_hw *hw) in csio_le_intr_handler() argument
2927 if (csio_handle_intr_status(hw, LE_DB_INT_CAUSE_A, le_intr_info)) in csio_le_intr_handler()
2928 csio_hw_fatal_err(hw); in csio_le_intr_handler()
2934 static void csio_mps_intr_handler(struct csio_hw *hw) in csio_mps_intr_handler() argument
2980 fat = csio_handle_intr_status(hw, MPS_RX_PERR_INT_CAUSE_A, in csio_mps_intr_handler()
2982 csio_handle_intr_status(hw, MPS_TX_INT_CAUSE_A, in csio_mps_intr_handler()
2984 csio_handle_intr_status(hw, MPS_TRC_INT_CAUSE_A, in csio_mps_intr_handler()
2986 csio_handle_intr_status(hw, MPS_STAT_PERR_INT_CAUSE_SRAM_A, in csio_mps_intr_handler()
2988 csio_handle_intr_status(hw, MPS_STAT_PERR_INT_CAUSE_TX_FIFO_A, in csio_mps_intr_handler()
2990 csio_handle_intr_status(hw, MPS_STAT_PERR_INT_CAUSE_RX_FIFO_A, in csio_mps_intr_handler()
2992 csio_handle_intr_status(hw, MPS_CLS_INT_CAUSE_A, in csio_mps_intr_handler()
2995 csio_wr_reg32(hw, 0, MPS_INT_CAUSE_A); in csio_mps_intr_handler()
2996 csio_rd_reg32(hw, MPS_INT_CAUSE_A); /* flush */ in csio_mps_intr_handler()
2998 csio_hw_fatal_err(hw); in csio_mps_intr_handler()
3007 static void csio_mem_intr_handler(struct csio_hw *hw, int idx) in csio_mem_intr_handler() argument
3021 v = csio_rd_reg32(hw, addr) & MEM_INT_MASK; in csio_mem_intr_handler()
3023 csio_fatal(hw, "%s FIFO parity error\n", name[idx]); in csio_mem_intr_handler()
3025 uint32_t cnt = ECC_CECNT_G(csio_rd_reg32(hw, cnt_addr)); in csio_mem_intr_handler()
3027 csio_wr_reg32(hw, ECC_CECNT_V(ECC_CECNT_M), cnt_addr); in csio_mem_intr_handler()
3028 csio_warn(hw, "%u %s correctable ECC data error%s\n", in csio_mem_intr_handler()
3032 csio_fatal(hw, "%s uncorrectable ECC data error\n", name[idx]); in csio_mem_intr_handler()
3034 csio_wr_reg32(hw, v, addr); in csio_mem_intr_handler()
3036 csio_hw_fatal_err(hw); in csio_mem_intr_handler()
3042 static void csio_ma_intr_handler(struct csio_hw *hw) in csio_ma_intr_handler() argument
3044 uint32_t v, status = csio_rd_reg32(hw, MA_INT_CAUSE_A); in csio_ma_intr_handler()
3047 csio_fatal(hw, "MA parity error, parity status %#x\n", in csio_ma_intr_handler()
3048 csio_rd_reg32(hw, MA_PARITY_ERROR_STATUS_A)); in csio_ma_intr_handler()
3050 v = csio_rd_reg32(hw, MA_INT_WRAP_STATUS_A); in csio_ma_intr_handler()
3051 csio_fatal(hw, in csio_ma_intr_handler()
3055 csio_wr_reg32(hw, status, MA_INT_CAUSE_A); in csio_ma_intr_handler()
3056 csio_hw_fatal_err(hw); in csio_ma_intr_handler()
3062 static void csio_smb_intr_handler(struct csio_hw *hw) in csio_smb_intr_handler() argument
3071 if (csio_handle_intr_status(hw, SMB_INT_CAUSE_A, smb_intr_info)) in csio_smb_intr_handler()
3072 csio_hw_fatal_err(hw); in csio_smb_intr_handler()
3078 static void csio_ncsi_intr_handler(struct csio_hw *hw) in csio_ncsi_intr_handler() argument
3088 if (csio_handle_intr_status(hw, NCSI_INT_CAUSE_A, ncsi_intr_info)) in csio_ncsi_intr_handler()
3089 csio_hw_fatal_err(hw); in csio_ncsi_intr_handler()
3095 static void csio_xgmac_intr_handler(struct csio_hw *hw, int port) in csio_xgmac_intr_handler() argument
3097 uint32_t v = csio_rd_reg32(hw, T5_PORT_REG(port, MAC_PORT_INT_CAUSE_A)); in csio_xgmac_intr_handler()
3104 csio_fatal(hw, "XGMAC %d Tx FIFO parity error\n", port); in csio_xgmac_intr_handler()
3106 csio_fatal(hw, "XGMAC %d Rx FIFO parity error\n", port); in csio_xgmac_intr_handler()
3107 csio_wr_reg32(hw, v, T5_PORT_REG(port, MAC_PORT_INT_CAUSE_A)); in csio_xgmac_intr_handler()
3108 csio_hw_fatal_err(hw); in csio_xgmac_intr_handler()
3114 static void csio_pl_intr_handler(struct csio_hw *hw) in csio_pl_intr_handler() argument
3122 if (csio_handle_intr_status(hw, PL_PL_INT_CAUSE_A, pl_intr_info)) in csio_pl_intr_handler()
3123 csio_hw_fatal_err(hw); in csio_pl_intr_handler()
3135 csio_hw_slow_intr_handler(struct csio_hw *hw) in csio_hw_slow_intr_handler() argument
3137 uint32_t cause = csio_rd_reg32(hw, PL_INT_CAUSE_A); in csio_hw_slow_intr_handler()
3140 CSIO_INC_STATS(hw, n_plint_unexp); in csio_hw_slow_intr_handler()
3144 csio_dbg(hw, "Slow interrupt! cause: 0x%x\n", cause); in csio_hw_slow_intr_handler()
3146 CSIO_INC_STATS(hw, n_plint_cnt); in csio_hw_slow_intr_handler()
3149 csio_cim_intr_handler(hw); in csio_hw_slow_intr_handler()
3152 csio_mps_intr_handler(hw); in csio_hw_slow_intr_handler()
3155 csio_ncsi_intr_handler(hw); in csio_hw_slow_intr_handler()
3158 csio_pl_intr_handler(hw); in csio_hw_slow_intr_handler()
3161 csio_smb_intr_handler(hw); in csio_hw_slow_intr_handler()
3164 csio_xgmac_intr_handler(hw, 0); in csio_hw_slow_intr_handler()
3167 csio_xgmac_intr_handler(hw, 1); in csio_hw_slow_intr_handler()
3170 csio_xgmac_intr_handler(hw, 2); in csio_hw_slow_intr_handler()
3173 csio_xgmac_intr_handler(hw, 3); in csio_hw_slow_intr_handler()
3176 hw->chip_ops->chip_pcie_intr_handler(hw); in csio_hw_slow_intr_handler()
3179 csio_mem_intr_handler(hw, MEM_MC); in csio_hw_slow_intr_handler()
3182 csio_mem_intr_handler(hw, MEM_EDC0); in csio_hw_slow_intr_handler()
3185 csio_mem_intr_handler(hw, MEM_EDC1); in csio_hw_slow_intr_handler()
3188 csio_le_intr_handler(hw); in csio_hw_slow_intr_handler()
3191 csio_tp_intr_handler(hw); in csio_hw_slow_intr_handler()
3194 csio_ma_intr_handler(hw); in csio_hw_slow_intr_handler()
3197 csio_pmtx_intr_handler(hw); in csio_hw_slow_intr_handler()
3200 csio_pmrx_intr_handler(hw); in csio_hw_slow_intr_handler()
3203 csio_ulprx_intr_handler(hw); in csio_hw_slow_intr_handler()
3206 csio_cplsw_intr_handler(hw); in csio_hw_slow_intr_handler()
3209 csio_sge_intr_handler(hw); in csio_hw_slow_intr_handler()
3212 csio_ulptx_intr_handler(hw); in csio_hw_slow_intr_handler()
3215 csio_wr_reg32(hw, cause & CSIO_GLBL_INTR_MASK, PL_INT_CAUSE_A); in csio_hw_slow_intr_handler()
3216 csio_rd_reg32(hw, PL_INT_CAUSE_A); /* flush */ in csio_hw_slow_intr_handler()
3234 struct csio_hw *hw = (struct csio_hw *)data; in csio_mberr_worker() local
3235 struct csio_mbm *mbm = &hw->mbm; in csio_mberr_worker()
3242 spin_lock_irq(&hw->lock); in csio_mberr_worker()
3244 spin_unlock_irq(&hw->lock); in csio_mberr_worker()
3256 rv = csio_mb_issue(hw, mbp_next); in csio_mberr_worker()
3262 spin_unlock_irq(&hw->lock); in csio_mberr_worker()
3265 csio_mb_completions(hw, &cbfn_q); in csio_mberr_worker()
3277 struct csio_hw *hw = (struct csio_hw *)data; in csio_hw_mb_timer() local
3280 spin_lock_irq(&hw->lock); in csio_hw_mb_timer()
3281 mbp = csio_mb_tmo_handler(hw); in csio_hw_mb_timer()
3282 spin_unlock_irq(&hw->lock); in csio_hw_mb_timer()
3286 mbp->mb_cbfn(hw, mbp); in csio_hw_mb_timer()
3300 csio_hw_mbm_cleanup(struct csio_hw *hw) in csio_hw_mbm_cleanup() argument
3304 csio_mb_cancel_all(hw, &cbfn_q); in csio_hw_mbm_cleanup()
3306 spin_unlock_irq(&hw->lock); in csio_hw_mbm_cleanup()
3307 csio_mb_completions(hw, &cbfn_q); in csio_hw_mbm_cleanup()
3308 spin_lock_irq(&hw->lock); in csio_hw_mbm_cleanup()
3315 csio_enqueue_evt(struct csio_hw *hw, enum csio_evt type, void *evt_msg, in csio_enqueue_evt() argument
3326 if (hw->flags & CSIO_HWF_FWEVT_STOP) in csio_enqueue_evt()
3329 if (list_empty(&hw->evt_free_q)) { in csio_enqueue_evt()
3330 csio_err(hw, "Failed to alloc evt entry, msg type %d len %d\n", in csio_enqueue_evt()
3335 evt_entry = list_first_entry(&hw->evt_free_q, in csio_enqueue_evt()
3342 list_add_tail(&evt_entry->list, &hw->evt_active_q); in csio_enqueue_evt()
3344 CSIO_DEC_STATS(hw, n_evt_freeq); in csio_enqueue_evt()
3345 CSIO_INC_STATS(hw, n_evt_activeq); in csio_enqueue_evt()
3351 csio_enqueue_evt_lock(struct csio_hw *hw, enum csio_evt type, void *evt_msg, in csio_enqueue_evt_lock() argument
3366 spin_lock_irqsave(&hw->lock, flags); in csio_enqueue_evt_lock()
3367 if (hw->flags & CSIO_HWF_FWEVT_STOP) { in csio_enqueue_evt_lock()
3372 if (list_empty(&hw->evt_free_q)) { in csio_enqueue_evt_lock()
3373 csio_err(hw, "Failed to alloc evt entry, msg type %d len %d\n", in csio_enqueue_evt_lock()
3379 evt_entry = list_first_entry(&hw->evt_free_q, in csio_enqueue_evt_lock()
3398 list_add_tail(&evt_entry->list, &hw->evt_active_q); in csio_enqueue_evt_lock()
3399 CSIO_DEC_STATS(hw, n_evt_freeq); in csio_enqueue_evt_lock()
3400 CSIO_INC_STATS(hw, n_evt_activeq); in csio_enqueue_evt_lock()
3402 spin_unlock_irqrestore(&hw->lock, flags); in csio_enqueue_evt_lock()
3407 csio_free_evt(struct csio_hw *hw, struct csio_evt_msg *evt_entry) in csio_free_evt() argument
3410 spin_lock_irq(&hw->lock); in csio_free_evt()
3412 list_add_tail(&evt_entry->list, &hw->evt_free_q); in csio_free_evt()
3413 CSIO_DEC_STATS(hw, n_evt_activeq); in csio_free_evt()
3414 CSIO_INC_STATS(hw, n_evt_freeq); in csio_free_evt()
3415 spin_unlock_irq(&hw->lock); in csio_free_evt()
3420 csio_evtq_flush(struct csio_hw *hw) in csio_evtq_flush() argument
3424 while (hw->flags & CSIO_HWF_FWEVT_PENDING && count--) { in csio_evtq_flush()
3425 spin_unlock_irq(&hw->lock); in csio_evtq_flush()
3427 spin_lock_irq(&hw->lock); in csio_evtq_flush()
3430 CSIO_DB_ASSERT(!(hw->flags & CSIO_HWF_FWEVT_PENDING)); in csio_evtq_flush()
3434 csio_evtq_stop(struct csio_hw *hw) in csio_evtq_stop() argument
3436 hw->flags |= CSIO_HWF_FWEVT_STOP; in csio_evtq_stop()
3440 csio_evtq_start(struct csio_hw *hw) in csio_evtq_start() argument
3442 hw->flags &= ~CSIO_HWF_FWEVT_STOP; in csio_evtq_start()
3446 csio_evtq_cleanup(struct csio_hw *hw) in csio_evtq_cleanup() argument
3451 if (!list_empty(&hw->evt_active_q)) in csio_evtq_cleanup()
3452 list_splice_tail_init(&hw->evt_active_q, &hw->evt_free_q); in csio_evtq_cleanup()
3454 hw->stats.n_evt_activeq = 0; in csio_evtq_cleanup()
3455 hw->flags &= ~CSIO_HWF_FWEVT_PENDING; in csio_evtq_cleanup()
3458 list_for_each_safe(evt_entry, next_entry, &hw->evt_free_q) { in csio_evtq_cleanup()
3460 CSIO_DEC_STATS(hw, n_evt_freeq); in csio_evtq_cleanup()
3463 hw->stats.n_evt_freeq = 0; in csio_evtq_cleanup()
3468 csio_process_fwevtq_entry(struct csio_hw *hw, void *wr, uint32_t len, in csio_process_fwevtq_entry() argument
3478 CSIO_INC_STATS(hw, n_cpl_fw6_pld); in csio_process_fwevtq_entry()
3480 CSIO_INC_STATS(hw, n_cpl_unexp); in csio_process_fwevtq_entry()
3489 CSIO_INC_STATS(hw, n_cpl_fw6_msg); in csio_process_fwevtq_entry()
3495 csio_warn(hw, "unexpected CPL %#x on FW event queue\n", op); in csio_process_fwevtq_entry()
3496 CSIO_INC_STATS(hw, n_cpl_unexp); in csio_process_fwevtq_entry()
3504 if (csio_enqueue_evt_lock(hw, CSIO_EVT_FW, msg, in csio_process_fwevtq_entry()
3506 CSIO_INC_STATS(hw, n_evt_drop); in csio_process_fwevtq_entry()
3512 struct csio_hw *hw = container_of(work, struct csio_hw, evtq_work); in csio_evtq_worker() local
3521 csio_dbg(hw, "event worker thread active evts#%d\n", in csio_evtq_worker()
3522 hw->stats.n_evt_activeq); in csio_evtq_worker()
3524 spin_lock_irq(&hw->lock); in csio_evtq_worker()
3525 while (!list_empty(&hw->evt_active_q)) { in csio_evtq_worker()
3526 list_splice_tail_init(&hw->evt_active_q, &evt_q); in csio_evtq_worker()
3527 spin_unlock_irq(&hw->lock); in csio_evtq_worker()
3533 spin_lock_irq(&hw->lock); in csio_evtq_worker()
3534 if (hw->flags & CSIO_HWF_FWEVT_STOP) in csio_evtq_worker()
3536 spin_unlock_irq(&hw->lock); in csio_evtq_worker()
3538 CSIO_INC_STATS(hw, n_evt_drop); in csio_evtq_worker()
3549 rv = csio_mb_fwevt_handler(hw, in csio_evtq_worker()
3554 csio_fcoe_fwevt_handler(hw, in csio_evtq_worker()
3558 csio_fcoe_fwevt_handler(hw, in csio_evtq_worker()
3561 csio_warn(hw, in csio_evtq_worker()
3564 CSIO_INC_STATS(hw, n_evt_drop); in csio_evtq_worker()
3569 csio_mberr_worker(hw); in csio_evtq_worker()
3578 csio_warn(hw, "Unhandled event %x on evtq\n", in csio_evtq_worker()
3580 CSIO_INC_STATS(hw, n_evt_unexp); in csio_evtq_worker()
3584 csio_free_evt(hw, evt_msg); in csio_evtq_worker()
3587 spin_lock_irq(&hw->lock); in csio_evtq_worker()
3589 hw->flags &= ~CSIO_HWF_FWEVT_PENDING; in csio_evtq_worker()
3590 spin_unlock_irq(&hw->lock); in csio_evtq_worker()
3594 csio_fwevtq_handler(struct csio_hw *hw) in csio_fwevtq_handler() argument
3598 if (csio_q_iqid(hw, hw->fwevt_iq_idx) == CSIO_MAX_QID) { in csio_fwevtq_handler()
3599 CSIO_INC_STATS(hw, n_int_stray); in csio_fwevtq_handler()
3603 rv = csio_wr_process_iq_idx(hw, hw->fwevt_iq_idx, in csio_fwevtq_handler()
3649 csio_dbg(mgmtm->hw, "Mgmt timer invoked!\n"); in csio_mgmt_tmo_handler()
3651 spin_lock_irq(&mgmtm->hw->lock); in csio_mgmt_tmo_handler()
3664 io_req->io_cbfn(mgmtm->hw, io_req); in csio_mgmt_tmo_handler()
3675 spin_unlock_irq(&mgmtm->hw->lock); in csio_mgmt_tmo_handler()
3681 struct csio_hw *hw = mgmtm->hw; in csio_mgmtm_cleanup() local
3689 spin_unlock_irq(&hw->lock); in csio_mgmtm_cleanup()
3691 spin_lock_irq(&hw->lock); in csio_mgmtm_cleanup()
3703 io_req->io_cbfn(mgmtm->hw, io_req); in csio_mgmtm_cleanup()
3723 csio_mgmtm_init(struct csio_mgmtm *mgmtm, struct csio_hw *hw) in csio_mgmtm_init() argument
3734 mgmtm->hw = hw; in csio_mgmtm_init()
3765 csio_hw_start(struct csio_hw *hw) in csio_hw_start() argument
3767 spin_lock_irq(&hw->lock); in csio_hw_start()
3768 csio_post_event(&hw->sm, CSIO_HWE_CFG); in csio_hw_start()
3769 spin_unlock_irq(&hw->lock); in csio_hw_start()
3771 if (csio_is_hw_ready(hw)) in csio_hw_start()
3778 csio_hw_stop(struct csio_hw *hw) in csio_hw_stop() argument
3780 csio_post_event(&hw->sm, CSIO_HWE_PCI_REMOVE); in csio_hw_stop()
3782 if (csio_is_hw_removing(hw)) in csio_hw_stop()
3798 csio_hw_reset(struct csio_hw *hw) in csio_hw_reset() argument
3800 if (!csio_is_hw_master(hw)) in csio_hw_reset()
3803 if (hw->rst_retries >= CSIO_MAX_RESET_RETRIES) { in csio_hw_reset()
3804 csio_dbg(hw, "Max hw reset attempts reached.."); in csio_hw_reset()
3808 hw->rst_retries++; in csio_hw_reset()
3809 csio_post_event(&hw->sm, CSIO_HWE_HBA_RESET); in csio_hw_reset()
3811 if (csio_is_hw_ready(hw)) { in csio_hw_reset()
3812 hw->rst_retries = 0; in csio_hw_reset()
3813 hw->stats.n_reset_start = jiffies_to_msecs(jiffies); in csio_hw_reset()
3824 csio_hw_get_device_id(struct csio_hw *hw) in csio_hw_get_device_id() argument
3827 if (csio_is_dev_id_cached(hw)) in csio_hw_get_device_id()
3831 pci_read_config_word(hw->pdev, PCI_VENDOR_ID, in csio_hw_get_device_id()
3832 &hw->params.pci.vendor_id); in csio_hw_get_device_id()
3833 pci_read_config_word(hw->pdev, PCI_DEVICE_ID, in csio_hw_get_device_id()
3834 &hw->params.pci.device_id); in csio_hw_get_device_id()
3836 csio_dev_id_cached(hw); in csio_hw_get_device_id()
3837 hw->chip_id = (hw->params.pci.device_id & CSIO_HW_CHIP_MASK); in csio_hw_get_device_id()
3848 csio_hw_set_description(struct csio_hw *hw, uint16_t ven_id, uint16_t dev_id) in csio_hw_set_description() argument
3857 memcpy(hw->hw_ver, in csio_hw_set_description()
3859 memcpy(hw->model_desc, in csio_hw_set_description()
3864 memcpy(hw->model_desc, tempName, 32); in csio_hw_set_description()
3876 csio_hw_init(struct csio_hw *hw) in csio_hw_init() argument
3883 INIT_LIST_HEAD(&hw->sm.sm_list); in csio_hw_init()
3884 csio_init_state(&hw->sm, csio_hws_uninit); in csio_hw_init()
3885 spin_lock_init(&hw->lock); in csio_hw_init()
3886 INIT_LIST_HEAD(&hw->sln_head); in csio_hw_init()
3889 csio_hw_get_device_id(hw); in csio_hw_init()
3891 strcpy(hw->name, CSIO_HW_NAME); in csio_hw_init()
3894 hw->chip_ops = &t5_ops; in csio_hw_init()
3898 ven_id = hw->params.pci.vendor_id; in csio_hw_init()
3899 dev_id = hw->params.pci.device_id; in csio_hw_init()
3901 csio_hw_set_description(hw, ven_id, dev_id); in csio_hw_init()
3904 hw->params.log_level = (uint32_t) csio_dbg_level; in csio_hw_init()
3906 csio_set_fwevt_intr_idx(hw, -1); in csio_hw_init()
3907 csio_set_nondata_intr_idx(hw, -1); in csio_hw_init()
3910 if (csio_mbm_init(csio_hw_to_mbm(hw), hw, csio_hw_mb_timer)) in csio_hw_init()
3913 rv = csio_wrm_init(csio_hw_to_wrm(hw), hw); in csio_hw_init()
3917 rv = csio_scsim_init(csio_hw_to_scsim(hw), hw); in csio_hw_init()
3921 rv = csio_mgmtm_init(csio_hw_to_mgmtm(hw), hw); in csio_hw_init()
3925 INIT_LIST_HEAD(&hw->evt_active_q); in csio_hw_init()
3926 INIT_LIST_HEAD(&hw->evt_free_q); in csio_hw_init()
3932 csio_err(hw, "Failed to initialize eventq"); in csio_hw_init()
3936 list_add_tail(&evt_entry->list, &hw->evt_free_q); in csio_hw_init()
3937 CSIO_INC_STATS(hw, n_evt_freeq); in csio_hw_init()
3940 hw->dev_num = dev_num; in csio_hw_init()
3946 csio_evtq_cleanup(hw); in csio_hw_init()
3947 csio_mgmtm_exit(csio_hw_to_mgmtm(hw)); in csio_hw_init()
3949 csio_scsim_exit(csio_hw_to_scsim(hw)); in csio_hw_init()
3951 csio_wrm_exit(csio_hw_to_wrm(hw), hw); in csio_hw_init()
3953 csio_mbm_exit(csio_hw_to_mbm(hw)); in csio_hw_init()
3964 csio_hw_exit(struct csio_hw *hw) in csio_hw_exit() argument
3966 csio_evtq_cleanup(hw); in csio_hw_exit()
3967 csio_mgmtm_exit(csio_hw_to_mgmtm(hw)); in csio_hw_exit()
3968 csio_scsim_exit(csio_hw_to_scsim(hw)); in csio_hw_exit()
3969 csio_wrm_exit(csio_hw_to_wrm(hw), hw); in csio_hw_exit()
3970 csio_mbm_exit(csio_hw_to_mbm(hw)); in csio_hw_exit()