Lines Matching full: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()
119 * @hw: the HW module
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()
155 * @hw: the adapter
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()
203 * @hw: hw to read
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()
297 * @hw: HW module
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()
381 * @hw: the HW module
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()
413 * @hw: the HW module
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()
442 * @hw: the HW module
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()
474 * @hw: the HW module
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()
518 * @hw: the hw
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()
583 * @hw: the HW module
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()
631 * @hw: HW module
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()
646 * @hw: HW module
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()
661 * @hw: HW module
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
779 ret = csio_hw_sf1_write(hw, 1, 1, 0, SF_RD_ID); in csio_hw_get_flash_params()
781 ret = csio_hw_sf1_read(hw, 3, 0, 1, &flashid); in csio_hw_get_flash_params()
782 csio_wr_reg32(hw, 0, SF_OP_A); /* unlock SF */ in csio_hw_get_flash_params()
790 hw->params.sf_size = supported_flash[part].size_mb; in csio_hw_get_flash_params()
791 hw->params.sf_nsec = in csio_hw_get_flash_params()
792 hw->params.sf_size / SF_SEC_SIZE; in csio_hw_get_flash_params()
861 csio_warn(hw, "Unknown Flash Part, ID = %#x, assuming 4MB\n", in csio_hw_get_flash_params()
867 hw->params.sf_size = size; in csio_hw_get_flash_params()
868 hw->params.sf_nsec = size / SF_SEC_SIZE; in csio_hw_get_flash_params()
871 if (hw->params.sf_size < FLASH_MIN_SIZE) in csio_hw_get_flash_params()
872 csio_warn(hw, "WARNING: Flash Part ID %#x, size %#x < %#x\n", in csio_hw_get_flash_params()
873 flashid, hw->params.sf_size, FLASH_MIN_SIZE); in csio_hw_get_flash_params()
878 /* HW State machine assists */
882 csio_hw_dev_ready(struct csio_hw *hw) in csio_hw_dev_ready() argument
888 while (((reg = csio_rd_reg32(hw, PL_WHOAMI_A)) == 0xFFFFFFFF) && in csio_hw_dev_ready()
892 if (csio_is_t5(hw->pdev->device & CSIO_HW_CHIP_MASK)) in csio_hw_dev_ready()
899 csio_err(hw, "PL_WHOAMI returned 0x%x, cnt:%d\n", reg, cnt); in csio_hw_dev_ready()
903 hw->pfn = src_pf; in csio_hw_dev_ready()
910 * @hw: HW module
916 csio_do_hello(struct csio_hw *hw, enum csio_dev_state *state) in csio_do_hello() argument
927 mbp = mempool_alloc(hw->mb_mempool, GFP_ATOMIC); in csio_do_hello()
930 CSIO_INC_STATS(hw, n_err_nomem); in csio_do_hello()
935 csio_mb_hello(hw, mbp, CSIO_MB_DEFAULT_TMO, hw->pfn, in csio_do_hello()
936 hw->pfn, CSIO_MASTER_MAY, NULL); in csio_do_hello()
938 rv = csio_mb_issue(hw, mbp); in csio_do_hello()
940 csio_err(hw, "failed to issue HELLO cmd. ret:%d.\n", rv); in csio_do_hello()
944 csio_mb_process_hello_rsp(hw, mbp, &retval, state, &mpfn); in csio_do_hello()
946 csio_err(hw, "HELLO cmd failed with ret: %d\n", retval); in csio_do_hello()
952 if (hw->pfn == mpfn) { in csio_do_hello()
953 hw->flags |= CSIO_HWF_MASTER; in csio_do_hello()
980 spin_unlock_irq(&hw->lock); in csio_do_hello()
982 spin_lock_irq(&hw->lock); in csio_do_hello()
991 pcie_fw = csio_rd_reg32(hw, PCIE_FW_A); in csio_do_hello()
1025 hw->flags &= ~CSIO_HWF_MASTER; in csio_do_hello()
1043 if (hw->pfn == mpfn) in csio_do_hello()
1044 csio_info(hw, "PF: %d, Coming up as MASTER, HW state: %s\n", in csio_do_hello()
1045 hw->pfn, state_str); in csio_do_hello()
1047 csio_info(hw, in csio_do_hello()
1048 "PF: %d, Coming up as SLAVE, Master PF: %d, HW state: %s\n", in csio_do_hello()
1049 hw->pfn, mpfn, state_str); in csio_do_hello()
1052 mempool_free(mbp, hw->mb_mempool); in csio_do_hello()
1059 * @hw: HW module
1063 csio_do_bye(struct csio_hw *hw) in csio_do_bye() argument
1068 mbp = mempool_alloc(hw->mb_mempool, GFP_ATOMIC); in csio_do_bye()
1070 CSIO_INC_STATS(hw, n_err_nomem); in csio_do_bye()
1074 csio_mb_bye(hw, mbp, CSIO_MB_DEFAULT_TMO, NULL); in csio_do_bye()
1076 if (csio_mb_issue(hw, mbp)) { in csio_do_bye()
1077 csio_err(hw, "Issue of BYE command failed\n"); in csio_do_bye()
1078 mempool_free(mbp, hw->mb_mempool); in csio_do_bye()
1084 mempool_free(mbp, hw->mb_mempool); in csio_do_bye()
1088 mempool_free(mbp, hw->mb_mempool); in csio_do_bye()
1095 * @hw: HW module
1103 csio_do_reset(struct csio_hw *hw, bool fw_rst) in csio_do_reset() argument
1110 csio_wr_reg32(hw, PIORSTMODE_F | PIORST_F, PL_RST_A); in csio_do_reset()
1115 mbp = mempool_alloc(hw->mb_mempool, GFP_ATOMIC); in csio_do_reset()
1117 CSIO_INC_STATS(hw, n_err_nomem); in csio_do_reset()
1121 csio_mb_reset(hw, mbp, CSIO_MB_DEFAULT_TMO, in csio_do_reset()
1124 if (csio_mb_issue(hw, mbp)) { in csio_do_reset()
1125 csio_err(hw, "Issue of RESET command failed.n"); in csio_do_reset()
1126 mempool_free(mbp, hw->mb_mempool); in csio_do_reset()
1132 csio_err(hw, "RESET cmd failed with ret:0x%x.\n", retval); in csio_do_reset()
1133 mempool_free(mbp, hw->mb_mempool); in csio_do_reset()
1137 mempool_free(mbp, hw->mb_mempool); in csio_do_reset()
1143 csio_hw_validate_caps(struct csio_hw *hw, struct csio_mb *mbp) in csio_hw_validate_caps() argument
1151 csio_err(hw, "No FCoE Initiator capability in the firmware.\n"); in csio_hw_validate_caps()
1156 csio_err(hw, "No FCoE Control Offload capability\n"); in csio_hw_validate_caps()
1165 * @hw: the HW module
1180 csio_hw_fw_halt(struct csio_hw *hw, uint32_t mbox, int32_t force) in csio_hw_fw_halt() argument
1191 mbp = mempool_alloc(hw->mb_mempool, GFP_ATOMIC); in csio_hw_fw_halt()
1193 CSIO_INC_STATS(hw, n_err_nomem); in csio_hw_fw_halt()
1197 csio_mb_reset(hw, mbp, CSIO_MB_DEFAULT_TMO, in csio_hw_fw_halt()
1201 if (csio_mb_issue(hw, mbp)) { in csio_hw_fw_halt()
1202 csio_err(hw, "Issue of RESET command failed!\n"); in csio_hw_fw_halt()
1203 mempool_free(mbp, hw->mb_mempool); in csio_hw_fw_halt()
1208 mempool_free(mbp, hw->mb_mempool); in csio_hw_fw_halt()
1225 csio_set_reg_field(hw, CIM_BOOT_CFG_A, UPCRST_F, UPCRST_F); in csio_hw_fw_halt()
1226 csio_set_reg_field(hw, PCIE_FW_A, PCIE_FW_HALT_F, in csio_hw_fw_halt()
1239 * @hw: the HW module
1259 csio_hw_fw_restart(struct csio_hw *hw, uint32_t mbox, int32_t reset) in csio_hw_fw_restart() argument
1267 csio_set_reg_field(hw, PCIE_FW_A, PCIE_FW_HALT_F, 0); in csio_hw_fw_restart()
1277 csio_set_reg_field(hw, CIM_BOOT_CFG_A, UPCRST_F, 0); in csio_hw_fw_restart()
1279 if (csio_do_reset(hw, true) == 0) in csio_hw_fw_restart()
1283 csio_wr_reg32(hw, PIORSTMODE_F | PIORST_F, PL_RST_A); in csio_hw_fw_restart()
1288 csio_set_reg_field(hw, CIM_BOOT_CFG_A, UPCRST_F, 0); in csio_hw_fw_restart()
1290 if (!(csio_rd_reg32(hw, PCIE_FW_A) & PCIE_FW_HALT_F)) in csio_hw_fw_restart()
1302 * @hw: the HW module
1322 csio_hw_fw_upgrade(struct csio_hw *hw, uint32_t mbox, in csio_hw_fw_upgrade() argument
1328 ret = csio_hw_fw_halt(hw, mbox, force); in csio_hw_fw_upgrade()
1332 ret = csio_hw_fw_dload(hw, (uint8_t *) fw_data, size); in csio_hw_fw_upgrade()
1345 return csio_hw_fw_restart(hw, mbox, reset); in csio_hw_fw_upgrade()
1350 * @hw: HW module
1354 csio_get_device_params(struct csio_hw *hw) in csio_get_device_params() argument
1356 struct csio_wrm *wrm = csio_hw_to_wrm(hw); in csio_get_device_params()
1364 hw->pport[i].portid = -1; in csio_get_device_params()
1366 mbp = mempool_alloc(hw->mb_mempool, GFP_ATOMIC); in csio_get_device_params()
1368 CSIO_INC_STATS(hw, n_err_nomem); in csio_get_device_params()
1386 csio_mb_params(hw, mbp, CSIO_MB_DEFAULT_TMO, hw->pfn, 0, in csio_get_device_params()
1388 if (csio_mb_issue(hw, mbp)) { in csio_get_device_params()
1389 csio_err(hw, "Issue of FW_PARAMS_CMD(read) failed!\n"); in csio_get_device_params()
1390 mempool_free(mbp, hw->mb_mempool); in csio_get_device_params()
1394 csio_mb_process_read_params_rsp(hw, mbp, &retval, in csio_get_device_params()
1397 csio_err(hw, "FW_PARAMS_CMD(read) failed with ret:0x%x!\n", in csio_get_device_params()
1399 mempool_free(mbp, hw->mb_mempool); in csio_get_device_params()
1404 hw->port_vec = param[0]; in csio_get_device_params()
1405 hw->vpd.cclk = param[1]; in csio_get_device_params()
1410 if ((hw->flags & CSIO_HWF_USING_SOFT_PARAMS) || in csio_get_device_params()
1411 !csio_is_hw_master(hw)) { in csio_get_device_params()
1412 hw->cfg_niq = param[5] - param[4] + 1; in csio_get_device_params()
1413 hw->cfg_neq = param[3] - param[2] + 1; in csio_get_device_params()
1414 csio_dbg(hw, "Using fwconfig max niqs %d neqs %d\n", in csio_get_device_params()
1415 hw->cfg_niq, hw->cfg_neq); in csio_get_device_params()
1418 hw->port_vec &= csio_port_mask; in csio_get_device_params()
1420 hw->num_pports = hweight32(hw->port_vec); in csio_get_device_params()
1422 csio_dbg(hw, "Port vector: 0x%x, #ports: %d\n", in csio_get_device_params()
1423 hw->port_vec, hw->num_pports); in csio_get_device_params()
1425 for (i = 0; i < hw->num_pports; i++) { in csio_get_device_params()
1426 while ((hw->port_vec & (1 << j)) == 0) in csio_get_device_params()
1428 hw->pport[i].portid = j++; in csio_get_device_params()
1429 csio_dbg(hw, "Found Port:%d\n", hw->pport[i].portid); in csio_get_device_params()
1431 mempool_free(mbp, hw->mb_mempool); in csio_get_device_params()
1439 * @hw: HW module
1443 csio_config_device_caps(struct csio_hw *hw) in csio_config_device_caps() argument
1449 mbp = mempool_alloc(hw->mb_mempool, GFP_ATOMIC); in csio_config_device_caps()
1451 CSIO_INC_STATS(hw, n_err_nomem); in csio_config_device_caps()
1456 csio_mb_caps_config(hw, mbp, CSIO_MB_DEFAULT_TMO, 0, 0, 0, 0, NULL); in csio_config_device_caps()
1458 if (csio_mb_issue(hw, mbp)) { in csio_config_device_caps()
1459 csio_err(hw, "Issue of FW_CAPS_CONFIG_CMD(r) failed!\n"); in csio_config_device_caps()
1465 csio_err(hw, "FW_CAPS_CONFIG_CMD(r) returned %d!\n", retval); in csio_config_device_caps()
1470 rv = csio_hw_validate_caps(hw, mbp); in csio_config_device_caps()
1475 if (hw->fw_state == CSIO_DEV_STATE_INIT) { in csio_config_device_caps()
1481 csio_mb_caps_config(hw, mbp, CSIO_MB_DEFAULT_TMO, true, true, in csio_config_device_caps()
1484 if (csio_mb_issue(hw, mbp)) { in csio_config_device_caps()
1485 csio_err(hw, "Issue of FW_CAPS_CONFIG_CMD(w) failed!\n"); in csio_config_device_caps()
1491 csio_err(hw, "FW_CAPS_CONFIG_CMD(w) returned %d!\n", retval); in csio_config_device_caps()
1497 mempool_free(mbp, hw->mb_mempool); in csio_config_device_caps()
1772 * @hw: HW module.
1776 csio_enable_ports(struct csio_hw *hw) in csio_enable_ports() argument
1785 mbp = mempool_alloc(hw->mb_mempool, GFP_ATOMIC); in csio_enable_ports()
1787 CSIO_INC_STATS(hw, n_err_nomem); in csio_enable_ports()
1791 for (i = 0; i < hw->num_pports; i++) { in csio_enable_ports()
1792 portid = hw->pport[i].portid; in csio_enable_ports()
1801 csio_mb_params(hw, mbp, CSIO_MB_DEFAULT_TMO, in csio_enable_ports()
1802 hw->pfn, 0, 1, &param, &val, true, in csio_enable_ports()
1805 if (csio_mb_issue(hw, mbp)) { in csio_enable_ports()
1806 csio_err(hw, "failed to issue FW_PARAMS_CMD(r) port:%d\n", in csio_enable_ports()
1808 mempool_free(mbp, hw->mb_mempool); in csio_enable_ports()
1812 csio_mb_process_read_params_rsp(hw, mbp, &retval, in csio_enable_ports()
1818 csio_mb_port(hw, mbp, CSIO_MB_DEFAULT_TMO, portid, in csio_enable_ports()
1821 if (csio_mb_issue(hw, mbp)) { in csio_enable_ports()
1822 csio_err(hw, "failed to issue FW_PORT_CMD(r) port:%d\n", in csio_enable_ports()
1824 mempool_free(mbp, hw->mb_mempool); in csio_enable_ports()
1828 csio_mb_process_read_port_rsp(hw, mbp, &retval, fw_caps, in csio_enable_ports()
1831 csio_err(hw, "FW_PORT_CMD(r) port:%d failed: 0x%x\n", in csio_enable_ports()
1833 mempool_free(mbp, hw->mb_mempool); in csio_enable_ports()
1837 csio_init_link_config(&hw->pport[i].link_cfg, pcaps, acaps); in csio_enable_ports()
1839 csio_link_l1cfg(&hw->pport[i].link_cfg, fw_caps, &rcaps); in csio_enable_ports()
1842 csio_mb_port(hw, mbp, CSIO_MB_DEFAULT_TMO, portid, in csio_enable_ports()
1845 if (csio_mb_issue(hw, mbp)) { in csio_enable_ports()
1846 csio_err(hw, "failed to issue FW_PORT_CMD(w) port:%d\n", in csio_enable_ports()
1848 mempool_free(mbp, hw->mb_mempool); in csio_enable_ports()
1854 csio_err(hw, "FW_PORT_CMD(w) port:%d failed :0x%x\n", in csio_enable_ports()
1856 mempool_free(mbp, hw->mb_mempool); in csio_enable_ports()
1862 mempool_free(mbp, hw->mb_mempool); in csio_enable_ports()
1869 * @hw: HW module
1873 csio_get_fcoe_resinfo(struct csio_hw *hw) in csio_get_fcoe_resinfo() argument
1875 struct csio_fcoe_res_info *res_info = &hw->fres_info; in csio_get_fcoe_resinfo()
1880 mbp = mempool_alloc(hw->mb_mempool, GFP_ATOMIC); in csio_get_fcoe_resinfo()
1882 CSIO_INC_STATS(hw, n_err_nomem); in csio_get_fcoe_resinfo()
1887 csio_fcoe_read_res_info_init_mb(hw, mbp, CSIO_MB_DEFAULT_TMO, NULL); in csio_get_fcoe_resinfo()
1889 if (csio_mb_issue(hw, mbp)) { in csio_get_fcoe_resinfo()
1890 csio_err(hw, "failed to issue FW_FCOE_RES_INFO_CMD\n"); in csio_get_fcoe_resinfo()
1891 mempool_free(mbp, hw->mb_mempool); in csio_get_fcoe_resinfo()
1898 csio_err(hw, "FW_FCOE_RES_INFO_CMD failed with ret x%x\n", in csio_get_fcoe_resinfo()
1900 mempool_free(mbp, hw->mb_mempool); in csio_get_fcoe_resinfo()
1917 csio_dbg(hw, "max ssns:%d max xchgs:%d\n", res_info->max_ssns, in csio_get_fcoe_resinfo()
1919 mempool_free(mbp, hw->mb_mempool); in csio_get_fcoe_resinfo()
1925 csio_hw_check_fwconfig(struct csio_hw *hw, u32 *param) in csio_hw_check_fwconfig() argument
1931 mbp = mempool_alloc(hw->mb_mempool, GFP_ATOMIC); in csio_hw_check_fwconfig()
1933 CSIO_INC_STATS(hw, n_err_nomem); in csio_hw_check_fwconfig()
1944 csio_mb_params(hw, mbp, CSIO_MB_DEFAULT_TMO, hw->pfn, 0, in csio_hw_check_fwconfig()
1946 if (csio_mb_issue(hw, mbp)) { in csio_hw_check_fwconfig()
1947 csio_err(hw, "Issue of FW_PARAMS_CMD(read) failed!\n"); in csio_hw_check_fwconfig()
1948 mempool_free(mbp, hw->mb_mempool); in csio_hw_check_fwconfig()
1952 csio_mb_process_read_params_rsp(hw, mbp, &retval, in csio_hw_check_fwconfig()
1955 csio_err(hw, "FW_PARAMS_CMD(read) failed with ret:0x%x!\n", in csio_hw_check_fwconfig()
1957 mempool_free(mbp, hw->mb_mempool); in csio_hw_check_fwconfig()
1961 mempool_free(mbp, hw->mb_mempool); in csio_hw_check_fwconfig()
1968 csio_hw_flash_config(struct csio_hw *hw, u32 *fw_cfg_param, char *path) in csio_hw_flash_config() argument
1972 struct pci_dev *pci_dev = hw->pdev; in csio_hw_flash_config()
1985 csio_err(hw, "could not find config file %s, err: %d\n", in csio_hw_flash_config()
2000 if (csio_hw_check_fwconfig(hw, fw_cfg_param) != 0) { in csio_hw_flash_config()
2008 ret = csio_memory_write(hw, mtype, maddr, in csio_hw_flash_config()
2022 ret = csio_memory_write(hw, mtype, maddr + size, 4, &last.word); in csio_hw_flash_config()
2025 csio_info(hw, "config file upgraded to %s\n", fw_cfg_file); in csio_hw_flash_config()
2036 * HW initialization: contact FW, obtain config, perform basic init.
2049 * Attempt to initialize the HW via a Firmware Configuration File.
2052 csio_hw_use_fwconfig(struct csio_hw *hw, int reset, u32 *fw_cfg_param) in csio_hw_use_fwconfig() argument
2066 rv = csio_do_reset(hw, true); in csio_hw_use_fwconfig()
2074 * in the HW flash ... in csio_hw_use_fwconfig()
2076 spin_unlock_irq(&hw->lock); in csio_hw_use_fwconfig()
2077 rv = csio_hw_flash_config(hw, fw_cfg_param, path); in csio_hw_use_fwconfig()
2078 spin_lock_irq(&hw->lock); in csio_hw_use_fwconfig()
2086 maddr = hw->chip_ops->chip_flash_cfg_addr(hw); in csio_hw_use_fwconfig()
2093 mbp = mempool_alloc(hw->mb_mempool, GFP_ATOMIC); in csio_hw_use_fwconfig()
2095 CSIO_INC_STATS(hw, n_err_nomem); in csio_hw_use_fwconfig()
2105 CSIO_INIT_MBP(mbp, caps_cmd, CSIO_MB_DEFAULT_TMO, hw, NULL, 1); in csio_hw_use_fwconfig()
2116 if (csio_mb_issue(hw, mbp)) { in csio_hw_use_fwconfig()
2129 CSIO_INIT_MBP(mbp, caps_cmd, CSIO_MB_DEFAULT_TMO, hw, NULL, 1); in csio_hw_use_fwconfig()
2135 if (csio_mb_issue(hw, mbp)) { in csio_hw_use_fwconfig()
2159 if (csio_mb_issue(hw, mbp)) { in csio_hw_use_fwconfig()
2166 csio_dbg(hw, "FW_CAPS_CONFIG_CMD returned %d!\n", rv); in csio_hw_use_fwconfig()
2171 csio_warn(hw, in csio_hw_use_fwconfig()
2177 rv = csio_hw_validate_caps(hw, mbp); in csio_hw_use_fwconfig()
2181 mempool_free(mbp, hw->mb_mempool); in csio_hw_use_fwconfig()
2189 hw->flags |= CSIO_HWF_USING_SOFT_PARAMS; in csio_hw_use_fwconfig()
2192 rv = csio_get_device_params(hw); in csio_hw_use_fwconfig()
2197 csio_wr_sge_init(hw); in csio_hw_use_fwconfig()
2204 csio_post_event(&hw->sm, CSIO_HWE_INIT); in csio_hw_use_fwconfig()
2206 csio_info(hw, "Successfully configure using Firmware " in csio_hw_use_fwconfig()
2216 mempool_free(mbp, hw->mb_mempool); in csio_hw_use_fwconfig()
2217 hw->flags &= ~CSIO_HWF_USING_SOFT_PARAMS; in csio_hw_use_fwconfig()
2218 csio_warn(hw, "Configuration file error %d\n", rv); in csio_hw_use_fwconfig()
2245 static int csio_should_install_fs_fw(struct csio_hw *hw, int card_fw_usable, in csio_should_install_fs_fw() argument
2263 csio_err(hw, "firmware on card (%u.%u.%u.%u) is %s, " in csio_should_install_fs_fw()
2314 static int csio_hw_prep_fw(struct csio_hw *hw, struct fw_info *fw_info, in csio_hw_prep_fw() argument
2326 ret = csio_hw_read_flash(hw, FLASH_FW_START, in csio_hw_prep_fw()
2332 csio_err(hw, in csio_hw_prep_fw()
2352 csio_should_install_fs_fw(hw, card_fw_usable, in csio_hw_prep_fw()
2355 ret = csio_hw_fw_upgrade(hw, hw->pfn, fw_data, in csio_hw_prep_fw()
2358 csio_err(hw, in csio_hw_prep_fw()
2376 csio_err(hw, "Cannot find a usable firmware: " in csio_hw_prep_fw()
2392 hw->fwrev = be32_to_cpu(card_fw->fw_ver); in csio_hw_prep_fw()
2393 hw->tp_vers = be32_to_cpu(card_fw->tp_microcode_ver); in csio_hw_prep_fw()
2406 csio_hw_flash_fw(struct csio_hw *hw, int *reset) in csio_hw_flash_fw() argument
2412 struct pci_dev *pci_dev = hw->pdev; in csio_hw_flash_fw()
2421 fw_info = find_fw_info(CHELSIO_CHIP_VERSION(hw->chip_id)); in csio_hw_flash_fw()
2423 csio_err(hw, in csio_hw_flash_fw()
2425 CHELSIO_CHIP_VERSION(hw->chip_id)); in csio_hw_flash_fw()
2442 csio_err(hw, "could not find firmware image %s, err: %d\n", in csio_hw_flash_fw()
2450 ret = csio_hw_prep_fw(hw, fw_info, fw_data, fw_size, card_fw, in csio_hw_flash_fw()
2451 hw->fw_state, reset); in csio_hw_flash_fw()
2460 static int csio_hw_check_fwver(struct csio_hw *hw) in csio_hw_check_fwver() argument
2462 if (csio_is_t6(hw->pdev->device & CSIO_HW_CHIP_MASK) && in csio_hw_check_fwver()
2463 (hw->fwrev < CSIO_MIN_T6_FW)) { in csio_hw_check_fwver()
2464 csio_hw_print_fw_version(hw, "T6 unsupported fw"); in csio_hw_check_fwver()
2472 * csio_hw_configure - Configure HW
2473 * @hw - HW module
2477 csio_hw_configure(struct csio_hw *hw) in csio_hw_configure() argument
2483 rv = csio_hw_dev_ready(hw); in csio_hw_configure()
2485 CSIO_INC_STATS(hw, n_err_fatal); in csio_hw_configure()
2486 csio_post_event(&hw->sm, CSIO_HWE_FATAL); in csio_hw_configure()
2490 /* HW version */ in csio_hw_configure()
2491 hw->chip_ver = (char)csio_rd_reg32(hw, PL_REV_A); in csio_hw_configure()
2494 rv = csio_hw_get_flash_params(hw); in csio_hw_configure()
2496 csio_err(hw, "Failed to get serial flash params rv:%d\n", rv); in csio_hw_configure()
2497 csio_post_event(&hw->sm, CSIO_HWE_FATAL); in csio_hw_configure()
2502 if (pci_is_pcie(hw->pdev)) in csio_hw_configure()
2503 pcie_capability_clear_and_set_word(hw->pdev, PCI_EXP_DEVCTL2, in csio_hw_configure()
2506 hw->chip_ops->chip_set_mem_win(hw, MEMWIN_CSIOSTOR); in csio_hw_configure()
2508 rv = csio_hw_get_fw_version(hw, &hw->fwrev); in csio_hw_configure()
2512 csio_hw_print_fw_version(hw, "Firmware revision"); in csio_hw_configure()
2514 rv = csio_do_hello(hw, &hw->fw_state); in csio_hw_configure()
2516 CSIO_INC_STATS(hw, n_err_fatal); in csio_hw_configure()
2517 csio_post_event(&hw->sm, CSIO_HWE_FATAL); in csio_hw_configure()
2522 rv = csio_hw_get_vpd_params(hw, &hw->vpd); in csio_hw_configure()
2526 csio_hw_get_fw_version(hw, &hw->fwrev); in csio_hw_configure()
2527 csio_hw_get_tp_version(hw, &hw->tp_vers); in csio_hw_configure()
2528 if (csio_is_hw_master(hw) && hw->fw_state != CSIO_DEV_STATE_INIT) { in csio_hw_configure()
2531 spin_unlock_irq(&hw->lock); in csio_hw_configure()
2532 rv = csio_hw_flash_fw(hw, &reset); in csio_hw_configure()
2533 spin_lock_irq(&hw->lock); in csio_hw_configure()
2538 rv = csio_hw_check_fwver(hw); in csio_hw_configure()
2545 rv = csio_hw_check_fwconfig(hw, param); in csio_hw_configure()
2547 csio_info(hw, "Firmware doesn't support " in csio_hw_configure()
2556 rv = csio_hw_use_fwconfig(hw, reset, param); in csio_hw_configure()
2558 csio_info(hw, "Could not initialize " in csio_hw_configure()
2563 csio_info(hw, "Could not initialize " in csio_hw_configure()
2569 rv = csio_hw_check_fwver(hw); in csio_hw_configure()
2573 if (hw->fw_state == CSIO_DEV_STATE_INIT) { in csio_hw_configure()
2575 hw->flags |= CSIO_HWF_USING_SOFT_PARAMS; in csio_hw_configure()
2578 rv = csio_get_device_params(hw); in csio_hw_configure()
2583 rv = csio_config_device_caps(hw); in csio_hw_configure()
2588 csio_wr_sge_init(hw); in csio_hw_configure()
2591 csio_post_event(&hw->sm, CSIO_HWE_INIT); in csio_hw_configure()
2601 * csio_hw_initialize - Initialize HW
2602 * @hw - HW module
2606 csio_hw_initialize(struct csio_hw *hw) in csio_hw_initialize() argument
2613 if (csio_is_hw_master(hw) && hw->fw_state != CSIO_DEV_STATE_INIT) { in csio_hw_initialize()
2614 mbp = mempool_alloc(hw->mb_mempool, GFP_ATOMIC); in csio_hw_initialize()
2618 csio_mb_initialize(hw, mbp, CSIO_MB_DEFAULT_TMO, NULL); in csio_hw_initialize()
2620 if (csio_mb_issue(hw, mbp)) { in csio_hw_initialize()
2621 csio_err(hw, "Issue of FW_INITIALIZE_CMD failed!\n"); in csio_hw_initialize()
2627 csio_err(hw, "FW_INITIALIZE_CMD returned 0x%x!\n", in csio_hw_initialize()
2632 mempool_free(mbp, hw->mb_mempool); in csio_hw_initialize()
2635 rv = csio_get_fcoe_resinfo(hw); in csio_hw_initialize()
2637 csio_err(hw, "Failed to read fcoe resource info: %d\n", rv); in csio_hw_initialize()
2641 spin_unlock_irq(&hw->lock); in csio_hw_initialize()
2642 rv = csio_config_queues(hw); in csio_hw_initialize()
2643 spin_lock_irq(&hw->lock); in csio_hw_initialize()
2646 csio_err(hw, "Config of queues failed!: %d\n", rv); in csio_hw_initialize()
2650 for (i = 0; i < hw->num_pports; i++) in csio_hw_initialize()
2651 hw->pport[i].mod_type = FW_PORT_MOD_TYPE_NA; in csio_hw_initialize()
2653 if (csio_is_hw_master(hw) && hw->fw_state != CSIO_DEV_STATE_INIT) { in csio_hw_initialize()
2654 rv = csio_enable_ports(hw); in csio_hw_initialize()
2656 csio_err(hw, "Failed to enable ports: %d\n", rv); in csio_hw_initialize()
2661 csio_post_event(&hw->sm, CSIO_HWE_INIT_DONE); in csio_hw_initialize()
2665 mempool_free(mbp, hw->mb_mempool); in csio_hw_initialize()
2673 * csio_hw_intr_enable - Enable HW interrupts
2674 * @hw: Pointer to HW module.
2676 * Enable interrupts in HW registers.
2679 csio_hw_intr_enable(struct csio_hw *hw) in csio_hw_intr_enable() argument
2681 uint16_t vec = (uint16_t)csio_get_mb_intr_idx(csio_hw_to_mbm(hw)); in csio_hw_intr_enable()
2683 uint32_t pl = csio_rd_reg32(hw, PL_INT_ENABLE_A); in csio_hw_intr_enable()
2685 if (csio_is_t5(hw->pdev->device & CSIO_HW_CHIP_MASK)) in csio_hw_intr_enable()
2686 pf = SOURCEPF_G(csio_rd_reg32(hw, PL_WHOAMI_A)); in csio_hw_intr_enable()
2688 pf = T6_SOURCEPF_G(csio_rd_reg32(hw, PL_WHOAMI_A)); in csio_hw_intr_enable()
2694 if (hw->intr_mode == CSIO_IM_MSIX) in csio_hw_intr_enable()
2695 csio_set_reg_field(hw, MYPF_REG(PCIE_PF_CFG_A), in csio_hw_intr_enable()
2697 else if (hw->intr_mode == CSIO_IM_MSI) in csio_hw_intr_enable()
2698 csio_set_reg_field(hw, MYPF_REG(PCIE_PF_CFG_A), in csio_hw_intr_enable()
2701 csio_wr_reg32(hw, PF_INTR_MASK, MYPF_REG(PL_PF_INT_ENABLE_A)); in csio_hw_intr_enable()
2704 csio_mb_intr_enable(hw); in csio_hw_intr_enable()
2707 if (csio_is_hw_master(hw)) { in csio_hw_intr_enable()
2712 csio_wr_reg32(hw, pl, PL_INT_ENABLE_A); in csio_hw_intr_enable()
2714 csio_wr_reg32(hw, ERR_CPL_EXCEED_IQE_SIZE_F | in csio_hw_intr_enable()
2723 csio_set_reg_field(hw, PL_INT_MAP0_A, 0, 1 << pf); in csio_hw_intr_enable()
2726 hw->flags |= CSIO_HWF_HW_INTR_ENABLED; in csio_hw_intr_enable()
2731 * csio_hw_intr_disable - Disable HW interrupts
2732 * @hw: Pointer to HW module.
2737 csio_hw_intr_disable(struct csio_hw *hw) in csio_hw_intr_disable() argument
2741 if (csio_is_t5(hw->pdev->device & CSIO_HW_CHIP_MASK)) in csio_hw_intr_disable()
2742 pf = SOURCEPF_G(csio_rd_reg32(hw, PL_WHOAMI_A)); in csio_hw_intr_disable()
2744 pf = T6_SOURCEPF_G(csio_rd_reg32(hw, PL_WHOAMI_A)); in csio_hw_intr_disable()
2746 if (!(hw->flags & CSIO_HWF_HW_INTR_ENABLED)) in csio_hw_intr_disable()
2749 hw->flags &= ~CSIO_HWF_HW_INTR_ENABLED; in csio_hw_intr_disable()
2751 csio_wr_reg32(hw, 0, MYPF_REG(PL_PF_INT_ENABLE_A)); in csio_hw_intr_disable()
2752 if (csio_is_hw_master(hw)) in csio_hw_intr_disable()
2753 csio_set_reg_field(hw, PL_INT_MAP0_A, 1 << pf, 0); in csio_hw_intr_disable()
2756 csio_mb_intr_disable(hw); in csio_hw_intr_disable()
2761 csio_hw_fatal_err(struct csio_hw *hw) in csio_hw_fatal_err() argument
2763 csio_set_reg_field(hw, SGE_CONTROL_A, GLOBALENABLE_F, 0); in csio_hw_fatal_err()
2764 csio_hw_intr_disable(hw); in csio_hw_fatal_err()
2766 /* Do not reset HW, we may need FW state for debugging */ in csio_hw_fatal_err()
2767 csio_fatal(hw, "HW Fatal error encountered!\n"); in csio_hw_fatal_err()
2771 /* START: HW SM */
2775 * @hw - HW module
2780 csio_hws_uninit(struct csio_hw *hw, enum csio_hw_ev evt) in csio_hws_uninit() argument
2782 hw->prev_evt = hw->cur_evt; in csio_hws_uninit()
2783 hw->cur_evt = evt; in csio_hws_uninit()
2784 CSIO_INC_STATS(hw, n_evt_sm[evt]); in csio_hws_uninit()
2788 csio_set_state(&hw->sm, csio_hws_configuring); in csio_hws_uninit()
2789 csio_hw_configure(hw); in csio_hws_uninit()
2793 CSIO_INC_STATS(hw, n_evt_unexp); in csio_hws_uninit()
2800 * @hw - HW module
2805 csio_hws_configuring(struct csio_hw *hw, enum csio_hw_ev evt) in csio_hws_configuring() argument
2807 hw->prev_evt = hw->cur_evt; in csio_hws_configuring()
2808 hw->cur_evt = evt; in csio_hws_configuring()
2809 CSIO_INC_STATS(hw, n_evt_sm[evt]); in csio_hws_configuring()
2813 csio_set_state(&hw->sm, csio_hws_initializing); in csio_hws_configuring()
2814 csio_hw_initialize(hw); in csio_hws_configuring()
2818 csio_set_state(&hw->sm, csio_hws_ready); in csio_hws_configuring()
2820 csio_notify_lnodes(hw, CSIO_LN_NOTIFY_HWREADY); in csio_hws_configuring()
2824 csio_set_state(&hw->sm, csio_hws_uninit); in csio_hws_configuring()
2828 csio_do_bye(hw); in csio_hws_configuring()
2831 CSIO_INC_STATS(hw, n_evt_unexp); in csio_hws_configuring()
2838 * @hw - HW module
2843 csio_hws_initializing(struct csio_hw *hw, enum csio_hw_ev evt) in csio_hws_initializing() argument
2845 hw->prev_evt = hw->cur_evt; in csio_hws_initializing()
2846 hw->cur_evt = evt; in csio_hws_initializing()
2847 CSIO_INC_STATS(hw, n_evt_sm[evt]); in csio_hws_initializing()
2851 csio_set_state(&hw->sm, csio_hws_ready); in csio_hws_initializing()
2854 csio_notify_lnodes(hw, CSIO_LN_NOTIFY_HWREADY); in csio_hws_initializing()
2857 csio_hw_intr_enable(hw); in csio_hws_initializing()
2861 csio_set_state(&hw->sm, csio_hws_uninit); in csio_hws_initializing()
2865 csio_do_bye(hw); in csio_hws_initializing()
2869 CSIO_INC_STATS(hw, n_evt_unexp); in csio_hws_initializing()
2876 * @hw - HW module
2881 csio_hws_ready(struct csio_hw *hw, enum csio_hw_ev evt) in csio_hws_ready() argument
2884 hw->evtflag = evt; in csio_hws_ready()
2886 hw->prev_evt = hw->cur_evt; in csio_hws_ready()
2887 hw->cur_evt = evt; in csio_hws_ready()
2888 CSIO_INC_STATS(hw, n_evt_sm[evt]); in csio_hws_ready()
2896 csio_set_state(&hw->sm, csio_hws_quiescing); in csio_hws_ready()
2900 csio_scsim_cleanup_io(csio_hw_to_scsim(hw), false); in csio_hws_ready()
2902 csio_scsim_cleanup_io(csio_hw_to_scsim(hw), true); in csio_hws_ready()
2904 csio_hw_intr_disable(hw); in csio_hws_ready()
2905 csio_hw_mbm_cleanup(hw); in csio_hws_ready()
2906 csio_evtq_stop(hw); in csio_hws_ready()
2907 csio_notify_lnodes(hw, CSIO_LN_NOTIFY_HWSTOP); in csio_hws_ready()
2908 csio_evtq_flush(hw); in csio_hws_ready()
2909 csio_mgmtm_cleanup(csio_hw_to_mgmtm(hw)); in csio_hws_ready()
2910 csio_post_event(&hw->sm, CSIO_HWE_QUIESCED); in csio_hws_ready()
2914 csio_set_state(&hw->sm, csio_hws_uninit); in csio_hws_ready()
2918 CSIO_INC_STATS(hw, n_evt_unexp); in csio_hws_ready()
2925 * @hw - HW module
2930 csio_hws_quiescing(struct csio_hw *hw, enum csio_hw_ev evt) in csio_hws_quiescing() argument
2932 hw->prev_evt = hw->cur_evt; in csio_hws_quiescing()
2933 hw->cur_evt = evt; in csio_hws_quiescing()
2934 CSIO_INC_STATS(hw, n_evt_sm[evt]); in csio_hws_quiescing()
2938 switch (hw->evtflag) { in csio_hws_quiescing()
2940 csio_set_state(&hw->sm, csio_hws_resetting); in csio_hws_quiescing()
2945 csio_set_state(&hw->sm, csio_hws_resetting); in csio_hws_quiescing()
2947 csio_notify_lnodes(hw, CSIO_LN_NOTIFY_HWRESET); in csio_hws_quiescing()
2948 csio_wr_destroy_queues(hw, false); in csio_hws_quiescing()
2949 csio_do_reset(hw, false); in csio_hws_quiescing()
2950 csio_post_event(&hw->sm, CSIO_HWE_HBA_RESET_DONE); in csio_hws_quiescing()
2954 csio_set_state(&hw->sm, csio_hws_removing); in csio_hws_quiescing()
2955 csio_notify_lnodes(hw, CSIO_LN_NOTIFY_HWREMOVE); in csio_hws_quiescing()
2956 csio_wr_destroy_queues(hw, true); in csio_hws_quiescing()
2958 csio_do_bye(hw); in csio_hws_quiescing()
2962 csio_set_state(&hw->sm, csio_hws_quiesced); in csio_hws_quiescing()
2966 csio_set_state(&hw->sm, csio_hws_pcierr); in csio_hws_quiescing()
2967 csio_wr_destroy_queues(hw, false); in csio_hws_quiescing()
2971 CSIO_INC_STATS(hw, n_evt_unexp); in csio_hws_quiescing()
2978 CSIO_INC_STATS(hw, n_evt_unexp); in csio_hws_quiescing()
2985 * @hw - HW module
2990 csio_hws_quiesced(struct csio_hw *hw, enum csio_hw_ev evt) in csio_hws_quiesced() argument
2992 hw->prev_evt = hw->cur_evt; in csio_hws_quiesced()
2993 hw->cur_evt = evt; in csio_hws_quiesced()
2994 CSIO_INC_STATS(hw, n_evt_sm[evt]); in csio_hws_quiesced()
2998 csio_set_state(&hw->sm, csio_hws_configuring); in csio_hws_quiesced()
2999 csio_hw_configure(hw); in csio_hws_quiesced()
3003 CSIO_INC_STATS(hw, n_evt_unexp); in csio_hws_quiesced()
3009 * csio_hws_resetting - HW Resetting state
3010 * @hw - HW module
3015 csio_hws_resetting(struct csio_hw *hw, enum csio_hw_ev evt) in csio_hws_resetting() argument
3017 hw->prev_evt = hw->cur_evt; in csio_hws_resetting()
3018 hw->cur_evt = evt; in csio_hws_resetting()
3019 CSIO_INC_STATS(hw, n_evt_sm[evt]); in csio_hws_resetting()
3023 csio_evtq_start(hw); in csio_hws_resetting()
3024 csio_set_state(&hw->sm, csio_hws_configuring); in csio_hws_resetting()
3025 csio_hw_configure(hw); in csio_hws_resetting()
3029 CSIO_INC_STATS(hw, n_evt_unexp); in csio_hws_resetting()
3036 * @hw - HW module
3041 csio_hws_removing(struct csio_hw *hw, enum csio_hw_ev evt) in csio_hws_removing() argument
3043 hw->prev_evt = hw->cur_evt; in csio_hws_removing()
3044 hw->cur_evt = evt; in csio_hws_removing()
3045 CSIO_INC_STATS(hw, n_evt_sm[evt]); in csio_hws_removing()
3049 if (!csio_is_hw_master(hw)) in csio_hws_removing()
3056 csio_err(hw, "Resetting HW and waiting 2 seconds...\n"); in csio_hws_removing()
3057 csio_wr_reg32(hw, PIORSTMODE_F | PIORST_F, PL_RST_A); in csio_hws_removing()
3063 CSIO_INC_STATS(hw, n_evt_unexp); in csio_hws_removing()
3071 * @hw - HW module
3076 csio_hws_pcierr(struct csio_hw *hw, enum csio_hw_ev evt) in csio_hws_pcierr() argument
3078 hw->prev_evt = hw->cur_evt; in csio_hws_pcierr()
3079 hw->cur_evt = evt; in csio_hws_pcierr()
3080 CSIO_INC_STATS(hw, n_evt_sm[evt]); in csio_hws_pcierr()
3084 csio_evtq_start(hw); in csio_hws_pcierr()
3085 csio_set_state(&hw->sm, csio_hws_configuring); in csio_hws_pcierr()
3086 csio_hw_configure(hw); in csio_hws_pcierr()
3090 CSIO_INC_STATS(hw, n_evt_unexp); in csio_hws_pcierr()
3096 /* END: HW SM */
3101 * @hw: HW instance
3113 csio_handle_intr_status(struct csio_hw *hw, unsigned int reg, in csio_handle_intr_status() argument
3118 unsigned int status = csio_rd_reg32(hw, reg); in csio_handle_intr_status()
3125 csio_fatal(hw, "Fatal %s (0x%x)\n", in csio_handle_intr_status()
3128 csio_info(hw, "%s (0x%x)\n", in csio_handle_intr_status()
3134 csio_wr_reg32(hw, status, reg); in csio_handle_intr_status()
3141 static void csio_tp_intr_handler(struct csio_hw *hw) in csio_tp_intr_handler() argument
3149 if (csio_handle_intr_status(hw, TP_INT_CAUSE_A, tp_intr_info)) in csio_tp_intr_handler()
3150 csio_hw_fatal_err(hw); in csio_tp_intr_handler()
3156 static void csio_sge_intr_handler(struct csio_hw *hw) in csio_sge_intr_handler() argument
3186 v = (uint64_t)csio_rd_reg32(hw, SGE_INT_CAUSE1_A) | in csio_sge_intr_handler()
3187 ((uint64_t)csio_rd_reg32(hw, SGE_INT_CAUSE2_A) << 32); in csio_sge_intr_handler()
3189 csio_fatal(hw, "SGE parity error (%#llx)\n", in csio_sge_intr_handler()
3191 csio_wr_reg32(hw, (uint32_t)(v & 0xFFFFFFFF), in csio_sge_intr_handler()
3193 csio_wr_reg32(hw, (uint32_t)(v >> 32), SGE_INT_CAUSE2_A); in csio_sge_intr_handler()
3196 v |= csio_handle_intr_status(hw, SGE_INT_CAUSE3_A, sge_intr_info); in csio_sge_intr_handler()
3198 if (csio_handle_intr_status(hw, SGE_INT_CAUSE3_A, sge_intr_info) || in csio_sge_intr_handler()
3200 csio_hw_fatal_err(hw); in csio_sge_intr_handler()
3211 static void csio_cim_intr_handler(struct csio_hw *hw) in csio_cim_intr_handler() argument
3257 fat = csio_handle_intr_status(hw, CIM_HOST_INT_CAUSE_A, in csio_cim_intr_handler()
3259 csio_handle_intr_status(hw, CIM_HOST_UPACC_INT_CAUSE_A, in csio_cim_intr_handler()
3262 csio_hw_fatal_err(hw); in csio_cim_intr_handler()
3268 static void csio_ulprx_intr_handler(struct csio_hw *hw) in csio_ulprx_intr_handler() argument
3276 if (csio_handle_intr_status(hw, ULP_RX_INT_CAUSE_A, ulprx_intr_info)) in csio_ulprx_intr_handler()
3277 csio_hw_fatal_err(hw); in csio_ulprx_intr_handler()
3283 static void csio_ulptx_intr_handler(struct csio_hw *hw) in csio_ulptx_intr_handler() argument
3298 if (csio_handle_intr_status(hw, ULP_TX_INT_CAUSE_A, ulptx_intr_info)) in csio_ulptx_intr_handler()
3299 csio_hw_fatal_err(hw); in csio_ulptx_intr_handler()
3305 static void csio_pmtx_intr_handler(struct csio_hw *hw) in csio_pmtx_intr_handler() argument
3321 if (csio_handle_intr_status(hw, PM_TX_INT_CAUSE_A, pmtx_intr_info)) in csio_pmtx_intr_handler()
3322 csio_hw_fatal_err(hw); in csio_pmtx_intr_handler()
3328 static void csio_pmrx_intr_handler(struct csio_hw *hw) in csio_pmrx_intr_handler() argument
3341 if (csio_handle_intr_status(hw, PM_RX_INT_CAUSE_A, pmrx_intr_info)) in csio_pmrx_intr_handler()
3342 csio_hw_fatal_err(hw); in csio_pmrx_intr_handler()
3348 static void csio_cplsw_intr_handler(struct csio_hw *hw) in csio_cplsw_intr_handler() argument
3360 if (csio_handle_intr_status(hw, CPL_INTR_CAUSE_A, cplsw_intr_info)) in csio_cplsw_intr_handler()
3361 csio_hw_fatal_err(hw); in csio_cplsw_intr_handler()
3367 static void csio_le_intr_handler(struct csio_hw *hw) in csio_le_intr_handler() argument
3369 enum chip_type chip = CHELSIO_CHIP_VERSION(hw->chip_id); in csio_le_intr_handler()
3389 if (csio_handle_intr_status(hw, LE_DB_INT_CAUSE_A, in csio_le_intr_handler()
3392 csio_hw_fatal_err(hw); in csio_le_intr_handler()
3398 static void csio_mps_intr_handler(struct csio_hw *hw) in csio_mps_intr_handler() argument
3444 fat = csio_handle_intr_status(hw, MPS_RX_PERR_INT_CAUSE_A, in csio_mps_intr_handler()
3446 csio_handle_intr_status(hw, MPS_TX_INT_CAUSE_A, in csio_mps_intr_handler()
3448 csio_handle_intr_status(hw, MPS_TRC_INT_CAUSE_A, in csio_mps_intr_handler()
3450 csio_handle_intr_status(hw, MPS_STAT_PERR_INT_CAUSE_SRAM_A, in csio_mps_intr_handler()
3452 csio_handle_intr_status(hw, MPS_STAT_PERR_INT_CAUSE_TX_FIFO_A, in csio_mps_intr_handler()
3454 csio_handle_intr_status(hw, MPS_STAT_PERR_INT_CAUSE_RX_FIFO_A, in csio_mps_intr_handler()
3456 csio_handle_intr_status(hw, MPS_CLS_INT_CAUSE_A, in csio_mps_intr_handler()
3459 csio_wr_reg32(hw, 0, MPS_INT_CAUSE_A); in csio_mps_intr_handler()
3460 csio_rd_reg32(hw, MPS_INT_CAUSE_A); /* flush */ in csio_mps_intr_handler()
3462 csio_hw_fatal_err(hw); in csio_mps_intr_handler()
3471 static void csio_mem_intr_handler(struct csio_hw *hw, int idx) in csio_mem_intr_handler() argument
3485 v = csio_rd_reg32(hw, addr) & MEM_INT_MASK; in csio_mem_intr_handler()
3487 csio_fatal(hw, "%s FIFO parity error\n", name[idx]); in csio_mem_intr_handler()
3489 uint32_t cnt = ECC_CECNT_G(csio_rd_reg32(hw, cnt_addr)); in csio_mem_intr_handler()
3491 csio_wr_reg32(hw, ECC_CECNT_V(ECC_CECNT_M), cnt_addr); in csio_mem_intr_handler()
3492 csio_warn(hw, "%u %s correctable ECC data error%s\n", in csio_mem_intr_handler()
3496 csio_fatal(hw, "%s uncorrectable ECC data error\n", name[idx]); in csio_mem_intr_handler()
3498 csio_wr_reg32(hw, v, addr); in csio_mem_intr_handler()
3500 csio_hw_fatal_err(hw); in csio_mem_intr_handler()
3506 static void csio_ma_intr_handler(struct csio_hw *hw) in csio_ma_intr_handler() argument
3508 uint32_t v, status = csio_rd_reg32(hw, MA_INT_CAUSE_A); in csio_ma_intr_handler()
3511 csio_fatal(hw, "MA parity error, parity status %#x\n", in csio_ma_intr_handler()
3512 csio_rd_reg32(hw, MA_PARITY_ERROR_STATUS_A)); in csio_ma_intr_handler()
3514 v = csio_rd_reg32(hw, MA_INT_WRAP_STATUS_A); in csio_ma_intr_handler()
3515 csio_fatal(hw, in csio_ma_intr_handler()
3519 csio_wr_reg32(hw, status, MA_INT_CAUSE_A); in csio_ma_intr_handler()
3520 csio_hw_fatal_err(hw); in csio_ma_intr_handler()
3526 static void csio_smb_intr_handler(struct csio_hw *hw) in csio_smb_intr_handler() argument
3535 if (csio_handle_intr_status(hw, SMB_INT_CAUSE_A, smb_intr_info)) in csio_smb_intr_handler()
3536 csio_hw_fatal_err(hw); in csio_smb_intr_handler()
3542 static void csio_ncsi_intr_handler(struct csio_hw *hw) in csio_ncsi_intr_handler() argument
3552 if (csio_handle_intr_status(hw, NCSI_INT_CAUSE_A, ncsi_intr_info)) in csio_ncsi_intr_handler()
3553 csio_hw_fatal_err(hw); in csio_ncsi_intr_handler()
3559 static void csio_xgmac_intr_handler(struct csio_hw *hw, int port) in csio_xgmac_intr_handler() argument
3561 uint32_t v = csio_rd_reg32(hw, T5_PORT_REG(port, MAC_PORT_INT_CAUSE_A)); in csio_xgmac_intr_handler()
3568 csio_fatal(hw, "XGMAC %d Tx FIFO parity error\n", port); in csio_xgmac_intr_handler()
3570 csio_fatal(hw, "XGMAC %d Rx FIFO parity error\n", port); in csio_xgmac_intr_handler()
3571 csio_wr_reg32(hw, v, T5_PORT_REG(port, MAC_PORT_INT_CAUSE_A)); in csio_xgmac_intr_handler()
3572 csio_hw_fatal_err(hw); in csio_xgmac_intr_handler()
3578 static void csio_pl_intr_handler(struct csio_hw *hw) in csio_pl_intr_handler() argument
3586 if (csio_handle_intr_status(hw, PL_PL_INT_CAUSE_A, pl_intr_info)) in csio_pl_intr_handler()
3587 csio_hw_fatal_err(hw); in csio_pl_intr_handler()
3592 * @hw: HW module
3599 csio_hw_slow_intr_handler(struct csio_hw *hw) in csio_hw_slow_intr_handler() argument
3601 uint32_t cause = csio_rd_reg32(hw, PL_INT_CAUSE_A); in csio_hw_slow_intr_handler()
3604 CSIO_INC_STATS(hw, n_plint_unexp); in csio_hw_slow_intr_handler()
3608 csio_dbg(hw, "Slow interrupt! cause: 0x%x\n", cause); in csio_hw_slow_intr_handler()
3610 CSIO_INC_STATS(hw, n_plint_cnt); in csio_hw_slow_intr_handler()
3613 csio_cim_intr_handler(hw); in csio_hw_slow_intr_handler()
3616 csio_mps_intr_handler(hw); in csio_hw_slow_intr_handler()
3619 csio_ncsi_intr_handler(hw); in csio_hw_slow_intr_handler()
3622 csio_pl_intr_handler(hw); in csio_hw_slow_intr_handler()
3625 csio_smb_intr_handler(hw); in csio_hw_slow_intr_handler()
3628 csio_xgmac_intr_handler(hw, 0); in csio_hw_slow_intr_handler()
3631 csio_xgmac_intr_handler(hw, 1); in csio_hw_slow_intr_handler()
3634 csio_xgmac_intr_handler(hw, 2); in csio_hw_slow_intr_handler()
3637 csio_xgmac_intr_handler(hw, 3); in csio_hw_slow_intr_handler()
3640 hw->chip_ops->chip_pcie_intr_handler(hw); in csio_hw_slow_intr_handler()
3643 csio_mem_intr_handler(hw, MEM_MC); in csio_hw_slow_intr_handler()
3646 csio_mem_intr_handler(hw, MEM_EDC0); in csio_hw_slow_intr_handler()
3649 csio_mem_intr_handler(hw, MEM_EDC1); in csio_hw_slow_intr_handler()
3652 csio_le_intr_handler(hw); in csio_hw_slow_intr_handler()
3655 csio_tp_intr_handler(hw); in csio_hw_slow_intr_handler()
3658 csio_ma_intr_handler(hw); in csio_hw_slow_intr_handler()
3661 csio_pmtx_intr_handler(hw); in csio_hw_slow_intr_handler()
3664 csio_pmrx_intr_handler(hw); in csio_hw_slow_intr_handler()
3667 csio_ulprx_intr_handler(hw); in csio_hw_slow_intr_handler()
3670 csio_cplsw_intr_handler(hw); in csio_hw_slow_intr_handler()
3673 csio_sge_intr_handler(hw); in csio_hw_slow_intr_handler()
3676 csio_ulptx_intr_handler(hw); in csio_hw_slow_intr_handler()
3679 csio_wr_reg32(hw, cause & CSIO_GLBL_INTR_MASK, PL_INT_CAUSE_A); in csio_hw_slow_intr_handler()
3680 csio_rd_reg32(hw, PL_INT_CAUSE_A); /* flush */ in csio_hw_slow_intr_handler()
3686 * HW <--> mailbox interfacing routines.
3698 struct csio_hw *hw = (struct csio_hw *)data; in csio_mberr_worker() local
3699 struct csio_mbm *mbm = &hw->mbm; in csio_mberr_worker()
3706 spin_lock_irq(&hw->lock); in csio_mberr_worker()
3708 spin_unlock_irq(&hw->lock); in csio_mberr_worker()
3720 rv = csio_mb_issue(hw, mbp_next); in csio_mberr_worker()
3726 spin_unlock_irq(&hw->lock); in csio_mberr_worker()
3729 csio_mb_completions(hw, &cbfn_q); in csio_mberr_worker()
3742 struct csio_hw *hw = mbm->hw; in csio_hw_mb_timer() local
3745 spin_lock_irq(&hw->lock); in csio_hw_mb_timer()
3746 mbp = csio_mb_tmo_handler(hw); in csio_hw_mb_timer()
3747 spin_unlock_irq(&hw->lock); in csio_hw_mb_timer()
3751 mbp->mb_cbfn(hw, mbp); in csio_hw_mb_timer()
3757 * @hw: HW module
3765 csio_hw_mbm_cleanup(struct csio_hw *hw) in csio_hw_mbm_cleanup() argument
3769 csio_mb_cancel_all(hw, &cbfn_q); in csio_hw_mbm_cleanup()
3771 spin_unlock_irq(&hw->lock); in csio_hw_mbm_cleanup()
3772 csio_mb_completions(hw, &cbfn_q); in csio_hw_mbm_cleanup()
3773 spin_lock_irq(&hw->lock); in csio_hw_mbm_cleanup()
3780 csio_enqueue_evt(struct csio_hw *hw, enum csio_evt type, void *evt_msg, in csio_enqueue_evt() argument
3791 if (hw->flags & CSIO_HWF_FWEVT_STOP) in csio_enqueue_evt()
3794 if (list_empty(&hw->evt_free_q)) { in csio_enqueue_evt()
3795 csio_err(hw, "Failed to alloc evt entry, msg type %d len %d\n", in csio_enqueue_evt()
3800 evt_entry = list_first_entry(&hw->evt_free_q, in csio_enqueue_evt()
3807 list_add_tail(&evt_entry->list, &hw->evt_active_q); in csio_enqueue_evt()
3809 CSIO_DEC_STATS(hw, n_evt_freeq); in csio_enqueue_evt()
3810 CSIO_INC_STATS(hw, n_evt_activeq); in csio_enqueue_evt()
3816 csio_enqueue_evt_lock(struct csio_hw *hw, enum csio_evt type, void *evt_msg, in csio_enqueue_evt_lock() argument
3831 spin_lock_irqsave(&hw->lock, flags); in csio_enqueue_evt_lock()
3832 if (hw->flags & CSIO_HWF_FWEVT_STOP) { in csio_enqueue_evt_lock()
3837 if (list_empty(&hw->evt_free_q)) { in csio_enqueue_evt_lock()
3838 csio_err(hw, "Failed to alloc evt entry, msg type %d len %d\n", in csio_enqueue_evt_lock()
3844 evt_entry = list_first_entry(&hw->evt_free_q, in csio_enqueue_evt_lock()
3863 list_add_tail(&evt_entry->list, &hw->evt_active_q); in csio_enqueue_evt_lock()
3864 CSIO_DEC_STATS(hw, n_evt_freeq); in csio_enqueue_evt_lock()
3865 CSIO_INC_STATS(hw, n_evt_activeq); in csio_enqueue_evt_lock()
3867 spin_unlock_irqrestore(&hw->lock, flags); in csio_enqueue_evt_lock()
3872 csio_free_evt(struct csio_hw *hw, struct csio_evt_msg *evt_entry) in csio_free_evt() argument
3875 spin_lock_irq(&hw->lock); in csio_free_evt()
3877 list_add_tail(&evt_entry->list, &hw->evt_free_q); in csio_free_evt()
3878 CSIO_DEC_STATS(hw, n_evt_activeq); in csio_free_evt()
3879 CSIO_INC_STATS(hw, n_evt_freeq); in csio_free_evt()
3880 spin_unlock_irq(&hw->lock); in csio_free_evt()
3885 csio_evtq_flush(struct csio_hw *hw) in csio_evtq_flush() argument
3889 while (hw->flags & CSIO_HWF_FWEVT_PENDING && count--) { in csio_evtq_flush()
3890 spin_unlock_irq(&hw->lock); in csio_evtq_flush()
3892 spin_lock_irq(&hw->lock); in csio_evtq_flush()
3895 CSIO_DB_ASSERT(!(hw->flags & CSIO_HWF_FWEVT_PENDING)); in csio_evtq_flush()
3899 csio_evtq_stop(struct csio_hw *hw) in csio_evtq_stop() argument
3901 hw->flags |= CSIO_HWF_FWEVT_STOP; in csio_evtq_stop()
3905 csio_evtq_start(struct csio_hw *hw) in csio_evtq_start() argument
3907 hw->flags &= ~CSIO_HWF_FWEVT_STOP; in csio_evtq_start()
3911 csio_evtq_cleanup(struct csio_hw *hw) in csio_evtq_cleanup() argument
3916 if (!list_empty(&hw->evt_active_q)) in csio_evtq_cleanup()
3917 list_splice_tail_init(&hw->evt_active_q, &hw->evt_free_q); in csio_evtq_cleanup()
3919 hw->stats.n_evt_activeq = 0; in csio_evtq_cleanup()
3920 hw->flags &= ~CSIO_HWF_FWEVT_PENDING; in csio_evtq_cleanup()
3923 list_for_each_safe(evt_entry, next_entry, &hw->evt_free_q) { in csio_evtq_cleanup()
3925 CSIO_DEC_STATS(hw, n_evt_freeq); in csio_evtq_cleanup()
3928 hw->stats.n_evt_freeq = 0; in csio_evtq_cleanup()
3933 csio_process_fwevtq_entry(struct csio_hw *hw, void *wr, uint32_t len, in csio_process_fwevtq_entry() argument
3943 CSIO_INC_STATS(hw, n_cpl_fw6_pld); in csio_process_fwevtq_entry()
3945 CSIO_INC_STATS(hw, n_cpl_unexp); in csio_process_fwevtq_entry()
3954 CSIO_INC_STATS(hw, n_cpl_fw6_msg); in csio_process_fwevtq_entry()
3960 csio_warn(hw, "unexpected CPL %#x on FW event queue\n", op); in csio_process_fwevtq_entry()
3961 CSIO_INC_STATS(hw, n_cpl_unexp); in csio_process_fwevtq_entry()
3969 if (csio_enqueue_evt_lock(hw, CSIO_EVT_FW, msg, in csio_process_fwevtq_entry()
3971 CSIO_INC_STATS(hw, n_evt_drop); in csio_process_fwevtq_entry()
3977 struct csio_hw *hw = container_of(work, struct csio_hw, evtq_work); in csio_evtq_worker() local
3986 csio_dbg(hw, "event worker thread active evts#%d\n", in csio_evtq_worker()
3987 hw->stats.n_evt_activeq); in csio_evtq_worker()
3989 spin_lock_irq(&hw->lock); in csio_evtq_worker()
3990 while (!list_empty(&hw->evt_active_q)) { in csio_evtq_worker()
3991 list_splice_tail_init(&hw->evt_active_q, &evt_q); in csio_evtq_worker()
3992 spin_unlock_irq(&hw->lock); in csio_evtq_worker()
3998 spin_lock_irq(&hw->lock); in csio_evtq_worker()
3999 if (hw->flags & CSIO_HWF_FWEVT_STOP) in csio_evtq_worker()
4001 spin_unlock_irq(&hw->lock); in csio_evtq_worker()
4003 CSIO_INC_STATS(hw, n_evt_drop); in csio_evtq_worker()
4014 rv = csio_mb_fwevt_handler(hw, in csio_evtq_worker()
4019 csio_fcoe_fwevt_handler(hw, in csio_evtq_worker()
4023 csio_fcoe_fwevt_handler(hw, in csio_evtq_worker()
4026 csio_warn(hw, in csio_evtq_worker()
4029 CSIO_INC_STATS(hw, n_evt_drop); in csio_evtq_worker()
4034 csio_mberr_worker(hw); in csio_evtq_worker()
4043 csio_warn(hw, "Unhandled event %x on evtq\n", in csio_evtq_worker()
4045 CSIO_INC_STATS(hw, n_evt_unexp); in csio_evtq_worker()
4049 csio_free_evt(hw, evt_msg); in csio_evtq_worker()
4052 spin_lock_irq(&hw->lock); in csio_evtq_worker()
4054 hw->flags &= ~CSIO_HWF_FWEVT_PENDING; in csio_evtq_worker()
4055 spin_unlock_irq(&hw->lock); in csio_evtq_worker()
4059 csio_fwevtq_handler(struct csio_hw *hw) in csio_fwevtq_handler() argument
4063 if (csio_q_iqid(hw, hw->fwevt_iq_idx) == CSIO_MAX_QID) { in csio_fwevtq_handler()
4064 CSIO_INC_STATS(hw, n_int_stray); in csio_fwevtq_handler()
4068 rv = csio_wr_process_iq_idx(hw, hw->fwevt_iq_idx, in csio_fwevtq_handler()
4114 csio_dbg(mgmtm->hw, "Mgmt timer invoked!\n"); in csio_mgmt_tmo_handler()
4116 spin_lock_irq(&mgmtm->hw->lock); in csio_mgmt_tmo_handler()
4129 io_req->io_cbfn(mgmtm->hw, io_req); in csio_mgmt_tmo_handler()
4140 spin_unlock_irq(&mgmtm->hw->lock); in csio_mgmt_tmo_handler()
4146 struct csio_hw *hw = mgmtm->hw; in csio_mgmtm_cleanup() local
4154 spin_unlock_irq(&hw->lock); in csio_mgmtm_cleanup()
4156 spin_lock_irq(&hw->lock); in csio_mgmtm_cleanup()
4168 io_req->io_cbfn(mgmtm->hw, io_req); in csio_mgmtm_cleanup()
4176 * @hw - HW module
4188 csio_mgmtm_init(struct csio_mgmtm *mgmtm, struct csio_hw *hw) in csio_mgmtm_init() argument
4195 mgmtm->hw = hw; in csio_mgmtm_init()
4196 /*mgmtm->iq_idx = hw->fwevt_iq_idx;*/ in csio_mgmtm_init()
4218 * csio_hw_start - Kicks off the HW State machine
4219 * @hw: Pointer to HW module.
4222 * So when we return after posting the event, the HW SM should be in
4226 csio_hw_start(struct csio_hw *hw) in csio_hw_start() argument
4228 spin_lock_irq(&hw->lock); in csio_hw_start()
4229 csio_post_event(&hw->sm, CSIO_HWE_CFG); in csio_hw_start()
4230 spin_unlock_irq(&hw->lock); in csio_hw_start()
4232 if (csio_is_hw_ready(hw)) in csio_hw_start()
4234 else if (csio_match_state(hw, csio_hws_uninit)) in csio_hw_start()
4241 csio_hw_stop(struct csio_hw *hw) in csio_hw_stop() argument
4243 csio_post_event(&hw->sm, CSIO_HWE_PCI_REMOVE); in csio_hw_stop()
4245 if (csio_is_hw_removing(hw)) in csio_hw_stop()
4256 * @hw: HW module.
4261 csio_hw_reset(struct csio_hw *hw) in csio_hw_reset() argument
4263 if (!csio_is_hw_master(hw)) in csio_hw_reset()
4266 if (hw->rst_retries >= CSIO_MAX_RESET_RETRIES) { in csio_hw_reset()
4267 csio_dbg(hw, "Max hw reset attempts reached.."); in csio_hw_reset()
4271 hw->rst_retries++; in csio_hw_reset()
4272 csio_post_event(&hw->sm, CSIO_HWE_HBA_RESET); in csio_hw_reset()
4274 if (csio_is_hw_ready(hw)) { in csio_hw_reset()
4275 hw->rst_retries = 0; in csio_hw_reset()
4276 hw->stats.n_reset_start = jiffies_to_msecs(jiffies); in csio_hw_reset()
4284 * @hw: HW module.
4287 csio_hw_get_device_id(struct csio_hw *hw) in csio_hw_get_device_id() argument
4290 if (csio_is_dev_id_cached(hw)) in csio_hw_get_device_id()
4294 pci_read_config_word(hw->pdev, PCI_VENDOR_ID, in csio_hw_get_device_id()
4295 &hw->params.pci.vendor_id); in csio_hw_get_device_id()
4296 pci_read_config_word(hw->pdev, PCI_DEVICE_ID, in csio_hw_get_device_id()
4297 &hw->params.pci.device_id); in csio_hw_get_device_id()
4299 csio_dev_id_cached(hw); in csio_hw_get_device_id()
4300 hw->chip_id = (hw->params.pci.device_id & CSIO_HW_CHIP_MASK); in csio_hw_get_device_id()
4305 * csio_hw_set_description - Set the model, description of the hw.
4306 * @hw: HW module.
4311 csio_hw_set_description(struct csio_hw *hw, uint16_t ven_id, uint16_t dev_id) in csio_hw_set_description() argument
4320 memcpy(hw->hw_ver, in csio_hw_set_description()
4322 memcpy(hw->model_desc, in csio_hw_set_description()
4327 memcpy(hw->model_desc, tempName, 32); in csio_hw_set_description()
4333 * csio_hw_init - Initialize HW module.
4334 * @hw: Pointer to HW module.
4336 * Initialize the members of the HW module.
4339 csio_hw_init(struct csio_hw *hw) in csio_hw_init() argument
4346 INIT_LIST_HEAD(&hw->sm.sm_list); in csio_hw_init()
4347 csio_init_state(&hw->sm, csio_hws_uninit); in csio_hw_init()
4348 spin_lock_init(&hw->lock); in csio_hw_init()
4349 INIT_LIST_HEAD(&hw->sln_head); in csio_hw_init()
4352 csio_hw_get_device_id(hw); in csio_hw_init()
4354 strcpy(hw->name, CSIO_HW_NAME); in csio_hw_init()
4356 /* Initialize the HW chip ops T5 specific ops */ in csio_hw_init()
4357 hw->chip_ops = &t5_ops; in csio_hw_init()
4361 ven_id = hw->params.pci.vendor_id; in csio_hw_init()
4362 dev_id = hw->params.pci.device_id; in csio_hw_init()
4364 csio_hw_set_description(hw, ven_id, dev_id); in csio_hw_init()
4367 hw->params.log_level = (uint32_t) csio_dbg_level; in csio_hw_init()
4369 csio_set_fwevt_intr_idx(hw, -1); in csio_hw_init()
4370 csio_set_nondata_intr_idx(hw, -1); in csio_hw_init()
4373 if (csio_mbm_init(csio_hw_to_mbm(hw), hw, csio_hw_mb_timer)) in csio_hw_init()
4376 rv = csio_wrm_init(csio_hw_to_wrm(hw), hw); in csio_hw_init()
4380 rv = csio_scsim_init(csio_hw_to_scsim(hw), hw); in csio_hw_init()
4384 rv = csio_mgmtm_init(csio_hw_to_mgmtm(hw), hw); in csio_hw_init()
4388 INIT_LIST_HEAD(&hw->evt_active_q); in csio_hw_init()
4389 INIT_LIST_HEAD(&hw->evt_free_q); in csio_hw_init()
4395 csio_err(hw, "Failed to initialize eventq"); in csio_hw_init()
4399 list_add_tail(&evt_entry->list, &hw->evt_free_q); in csio_hw_init()
4400 CSIO_INC_STATS(hw, n_evt_freeq); in csio_hw_init()
4403 hw->dev_num = dev_num; in csio_hw_init()
4409 csio_evtq_cleanup(hw); in csio_hw_init()
4410 csio_mgmtm_exit(csio_hw_to_mgmtm(hw)); in csio_hw_init()
4412 csio_scsim_exit(csio_hw_to_scsim(hw)); in csio_hw_init()
4414 csio_wrm_exit(csio_hw_to_wrm(hw), hw); in csio_hw_init()
4416 csio_mbm_exit(csio_hw_to_mbm(hw)); in csio_hw_init()
4422 * csio_hw_exit - Un-initialize HW module.
4423 * @hw: Pointer to HW module.
4427 csio_hw_exit(struct csio_hw *hw) in csio_hw_exit() argument
4429 csio_evtq_cleanup(hw); in csio_hw_exit()
4430 csio_mgmtm_exit(csio_hw_to_mgmtm(hw)); in csio_hw_exit()
4431 csio_scsim_exit(csio_hw_to_scsim(hw)); in csio_hw_exit()
4432 csio_wrm_exit(csio_hw_to_wrm(hw), hw); in csio_hw_exit()
4433 csio_mbm_exit(csio_hw_to_mbm(hw)); in csio_hw_exit()