Lines Matching refs:afu
49 static struct afu_cmd *cmd_checkout(struct afu *afu) in cmd_checkout() argument
55 k = (afu->cmd_couts++ & (CXLFLASH_NUM_CMDS - 1)); in cmd_checkout()
57 cmd = &afu->cmd[k]; in cmd_checkout()
221 struct afu *afu = cmd->parent; in cmd_complete() local
222 struct cxlflash_cfg *cfg = afu->parent; in cmd_complete()
267 struct afu *afu = cmd->parent; in context_reset() local
288 room = readq_be(&afu->host_map->cmd_room); in context_reset()
289 atomic64_set(&afu->room, room); in context_reset()
300 writeq_be(rrin, &afu->host_map->ioarrin); in context_reset()
302 rrin = readq_be(&afu->host_map->ioarrin); in context_reset()
318 static int send_cmd(struct afu *afu, struct afu_cmd *cmd) in send_cmd() argument
320 struct cxlflash_cfg *cfg = afu->parent; in send_cmd()
334 newval = atomic64_dec_if_positive(&afu->room); in send_cmd()
337 room = readq_be(&afu->host_map->cmd_room); in send_cmd()
338 atomic64_set(&afu->room, room); in send_cmd()
363 writeq_be((u64)&cmd->rcb, &afu->host_map->ioarrin); in send_cmd()
370 afu->read_room = true; in send_cmd()
381 static void wait_resp(struct afu *afu, struct afu_cmd *cmd) in wait_resp() argument
405 static int send_tmf(struct afu *afu, struct scsi_cmnd *scp, u64 tmfcmd) in send_tmf() argument
418 cmd = cmd_checkout(afu); in send_tmf()
435 cmd->rcb.ctx_id = afu->ctx_hndl; in send_tmf()
451 rc = send_cmd(afu, cmd); in send_tmf()
497 struct afu *afu = cfg->afu; in cxlflash_queuecommand() local
543 cmd = cmd_checkout(afu); in cxlflash_queuecommand()
550 cmd->rcb.ctx_id = afu->ctx_hndl; in cxlflash_queuecommand()
583 rc = send_cmd(afu, cmd); in cxlflash_queuecommand()
616 struct afu *afu = cfg->afu; in free_mem() local
618 if (cfg->afu) { in free_mem()
620 buf = afu->cmd[i].buf; in free_mem()
625 free_pages((ulong)afu, get_order(sizeof(struct afu))); in free_mem()
626 cfg->afu = NULL; in free_mem()
639 struct afu *afu = cfg->afu; in stop_afu() local
641 if (likely(afu)) { in stop_afu()
643 complete(&afu->cmd[i].cevent); in stop_afu()
645 if (likely(afu->afu_map)) { in stop_afu()
646 cxl_psa_unmap((void __iomem *)afu->afu_map); in stop_afu()
647 afu->afu_map = NULL; in stop_afu()
662 struct afu *afu = cfg->afu; in term_mc() local
665 if (!afu || !cfg->mcctx) { in term_mc()
676 cxl_unmap_afu_irq(cfg->mcctx, 3, afu); in term_mc()
678 cxl_unmap_afu_irq(cfg->mcctx, 2, afu); in term_mc()
680 cxl_unmap_afu_irq(cfg->mcctx, 1, afu); in term_mc()
698 if (cfg->afu) in term_afu()
766 cfg->afu = (void *)__get_free_pages(GFP_KERNEL | __GFP_ZERO, in alloc_mem()
767 get_order(sizeof(struct afu))); in alloc_mem()
768 if (unlikely(!cfg->afu)) { in alloc_mem()
770 __func__, get_order(sizeof(struct afu))); in alloc_mem()
774 cfg->afu->parent = cfg; in alloc_mem()
775 cfg->afu->afu_map = NULL; in alloc_mem()
790 cfg->afu->cmd[i].buf = buf; in alloc_mem()
791 atomic_set(&cfg->afu->cmd[i].free, 1); in alloc_mem()
792 cfg->afu->cmd[i].slot = i; in alloc_mem()
1020 static int afu_set_wwpn(struct afu *afu, int port, __be64 __iomem *fc_regs, in afu_set_wwpn() argument
1066 static void afu_link_reset(struct afu *afu, int port, __be64 __iomem *fc_regs) in afu_link_reset() argument
1071 port_sel = readq_be(&afu->afu_map->global.regs.afu_port_sel); in afu_link_reset()
1073 writeq_be(port_sel, &afu->afu_map->global.regs.afu_port_sel); in afu_link_reset()
1074 cxlflash_afu_sync(afu, 0, 0, AFU_GSYNC); in afu_link_reset()
1090 writeq_be(port_sel, &afu->afu_map->global.regs.afu_port_sel); in afu_link_reset()
1091 cxlflash_afu_sync(afu, 0, 0, AFU_GSYNC); in afu_link_reset()
1140 static void afu_err_intr_init(struct afu *afu) in afu_err_intr_init() argument
1153 writeq_be(-1ULL, &afu->afu_map->global.regs.aintr_mask); in afu_err_intr_init()
1155 reg = ((u64) (((afu->ctx_hndl << 8) | SISL_MSI_ASYNC_ERROR)) << 40); in afu_err_intr_init()
1157 if (afu->internal_lun) in afu_err_intr_init()
1159 writeq_be(reg, &afu->afu_map->global.regs.afu_ctrl); in afu_err_intr_init()
1161 writeq_be(-1ULL, &afu->afu_map->global.regs.aintr_clear); in afu_err_intr_init()
1164 writeq_be(SISL_ASTATUS_MASK, &afu->afu_map->global.regs.aintr_mask); in afu_err_intr_init()
1167 writeq_be(-1ULL, &afu->afu_map->global.regs.aintr_clear); in afu_err_intr_init()
1170 reg = readq_be(&afu->afu_map->global.fc_regs[0][FC_CONFIG2 / 8]); in afu_err_intr_init()
1172 if (afu->internal_lun) in afu_err_intr_init()
1173 reg |= ((u64)(afu->internal_lun - 1) << SISL_FC_INTERNAL_SHIFT); in afu_err_intr_init()
1174 writeq_be(reg, &afu->afu_map->global.fc_regs[0][FC_CONFIG2 / 8]); in afu_err_intr_init()
1179 &afu->afu_map->global.fc_regs[i][FC_ERROR / 8]); in afu_err_intr_init()
1180 writeq_be(0, &afu->afu_map->global.fc_regs[i][FC_ERRCAP / 8]); in afu_err_intr_init()
1189 writeq_be(SISL_MSI_SYNC_ERROR, &afu->host_map->ctx_ctrl); in afu_err_intr_init()
1190 writeq_be(SISL_ISTATUS_MASK, &afu->host_map->intr_mask); in afu_err_intr_init()
1202 struct afu *afu = (struct afu *)data; in cxlflash_sync_err_irq() local
1206 reg = readq_be(&afu->host_map->intr_status); in cxlflash_sync_err_irq()
1211 __func__, (u64)afu, reg); in cxlflash_sync_err_irq()
1216 __func__, (u64)afu, reg); in cxlflash_sync_err_irq()
1218 writeq_be(reg_unmasked, &afu->host_map->intr_clear); in cxlflash_sync_err_irq()
1234 struct afu *afu = (struct afu *)data; in cxlflash_rrq_irq() local
1236 bool toggle = afu->toggle; in cxlflash_rrq_irq()
1238 *hrrq_start = afu->hrrq_start, in cxlflash_rrq_irq()
1239 *hrrq_end = afu->hrrq_end, in cxlflash_rrq_irq()
1240 *hrrq_curr = afu->hrrq_curr; in cxlflash_rrq_irq()
1261 afu->hrrq_curr = hrrq_curr; in cxlflash_rrq_irq()
1262 afu->toggle = toggle; in cxlflash_rrq_irq()
1276 struct afu *afu = (struct afu *)data; in cxlflash_async_err_irq() local
1277 struct cxlflash_cfg *cfg = afu->parent; in cxlflash_async_err_irq()
1281 struct sisl_global_map __iomem *global = &afu->afu_map->global; in cxlflash_async_err_irq()
1344 dev_dbg(dev, "%s: returning IRQ_HANDLED, afu=%p\n", __func__, afu); in cxlflash_async_err_irq()
1359 cfg->afu->work.work_element_descriptor, in start_context()
1466 struct afu *afu = cfg->afu; in init_pcr() local
1471 ctrl_map = &afu->afu_map->ctrls[i].ctrl; in init_pcr()
1480 afu->ctx_hndl = (u16) cxl_process_element(cfg->mcctx); in init_pcr()
1481 afu->host_map = &afu->afu_map->hosts[afu->ctx_hndl].host; in init_pcr()
1482 afu->ctrl_map = &afu->afu_map->ctrls[afu->ctx_hndl].ctrl; in init_pcr()
1485 writeq_be(SISL_ENDIAN_CTRL, &afu->host_map->endian_ctrl); in init_pcr()
1489 afu->cmd[i].rcb.ctx_id = afu->ctx_hndl; in init_pcr()
1490 afu->cmd[i].rcb.msi = SISL_MSI_RRQ_UPDATED; in init_pcr()
1491 afu->cmd[i].rcb.rrq = 0x0; in init_pcr()
1501 struct afu *afu = cfg->afu; in init_global() local
1517 writeq_be((u64) afu->hrrq_start, &afu->host_map->rrq_start); in init_global()
1518 writeq_be((u64) afu->hrrq_end, &afu->host_map->rrq_end); in init_global()
1521 reg = readq_be(&afu->afu_map->global.regs.afu_config); in init_global()
1527 writeq_be(reg, &afu->afu_map->global.regs.afu_config); in init_global()
1530 if (afu->internal_lun) { in init_global()
1532 writeq_be(PORT0, &afu->afu_map->global.regs.afu_port_sel); in init_global()
1535 writeq_be(BOTH_PORTS, &afu->afu_map->global.regs.afu_port_sel); in init_global()
1541 writeq_be(0, &afu->afu_map->global.fc_regs[i][FC_ERRMSK / 8]); in init_global()
1543 (void)readq_be(&afu->afu_map->global. in init_global()
1545 writeq_be(MC_CRC_THRESH, &afu->afu_map->global.fc_regs[i] in init_global()
1550 afu_set_wwpn(afu, i, in init_global()
1551 &afu->afu_map->global.fc_regs[i][0], in init_global()
1567 (void)readq_be(&afu->ctrl_map->mbox_r); /* unlock ctx_cap */ in init_global()
1571 &afu->ctrl_map->ctx_cap); in init_global()
1573 afu->hb = readq_be(&afu->afu_map->global.regs.afu_hb); in init_global()
1585 struct afu *afu = cfg->afu; in start_afu() local
1592 cmd = &afu->cmd[i]; in start_afu()
1596 cmd->parent = afu; in start_afu()
1602 memset(&afu->rrq_entry, 0, sizeof(afu->rrq_entry)); in start_afu()
1605 afu->hrrq_start = &afu->rrq_entry[0]; in start_afu()
1606 afu->hrrq_end = &afu->rrq_entry[NUM_RRQ_ENTRY - 1]; in start_afu()
1607 afu->hrrq_curr = afu->hrrq_start; in start_afu()
1608 afu->toggle = 1; in start_afu()
1626 struct afu *afu = cfg->afu; in init_mc() local
1655 rc = cxl_map_afu_irq(ctx, 1, cxlflash_sync_err_irq, afu, in init_mc()
1664 rc = cxl_map_afu_irq(ctx, 2, cxlflash_rrq_irq, afu, in init_mc()
1673 rc = cxl_map_afu_irq(ctx, 3, cxlflash_async_err_irq, afu, in init_mc()
1715 struct afu *afu = cfg->afu; in init_afu() local
1728 afu->afu_map = cxl_psa_map(cfg->mcctx); in init_afu()
1729 if (!afu->afu_map) { in init_afu()
1736 reg = readq(&afu->afu_map->global.regs.afu_version); in init_afu()
1737 memcpy(afu->version, ®, sizeof(reg)); in init_afu()
1738 afu->interface_version = in init_afu()
1739 readq_be(&afu->afu_map->global.regs.interface_version); in init_afu()
1740 if ((afu->interface_version + 1) == 0) { in init_afu()
1742 "interface version 0x%llx\n", afu->version, in init_afu()
1743 afu->interface_version); in init_afu()
1749 afu->version, afu->interface_version); in init_afu()
1758 afu_err_intr_init(cfg->afu); in init_afu()
1759 atomic64_set(&afu->room, readq_be(&afu->host_map->cmd_room)); in init_afu()
1768 cxl_psa_unmap((void __iomem *)afu->afu_map); in init_afu()
1769 afu->afu_map = NULL; in init_afu()
1797 int cxlflash_afu_sync(struct afu *afu, ctx_hndl_t ctx_hndl_u, in cxlflash_afu_sync() argument
1800 struct cxlflash_cfg *cfg = afu->parent; in cxlflash_afu_sync()
1814 cmd = cmd_checkout(afu); in cxlflash_afu_sync()
1825 pr_debug("%s: afu=%p cmd=%p %d\n", __func__, afu, cmd, ctx_hndl_u); in cxlflash_afu_sync()
1843 rc = send_cmd(afu, cmd); in cxlflash_afu_sync()
1847 wait_resp(afu, cmd); in cxlflash_afu_sync()
1895 struct afu *afu = cfg->afu; in cxlflash_eh_device_reset_handler() local
1910 rcr = send_tmf(afu, scp, TMF_LUN_RESET); in cxlflash_eh_device_reset_handler()
2003 static ssize_t cxlflash_show_port_status(u32 port, struct afu *afu, char *buf) in cxlflash_show_port_status() argument
2012 fc_regs = &afu->afu_map->global.fc_regs[port][0]; in cxlflash_show_port_status()
2040 struct afu *afu = cfg->afu; in port0_show() local
2042 return cxlflash_show_port_status(0, afu, buf); in port0_show()
2059 struct afu *afu = cfg->afu; in port1_show() local
2061 return cxlflash_show_port_status(1, afu, buf); in port1_show()
2077 struct afu *afu = cfg->afu; in lun_mode_show() local
2079 return scnprintf(buf, PAGE_SIZE, "%u\n", afu->internal_lun); in lun_mode_show()
2110 struct afu *afu = cfg->afu; in lun_mode_store() local
2115 if (!rc && (lun_mode < 5) && (lun_mode != afu->internal_lun)) { in lun_mode_store()
2116 afu->internal_lun = lun_mode; in lun_mode_store()
2147 struct afu *afu, in cxlflash_show_port_lun_table() argument
2157 fc_port = &afu->afu_map->global.fc_port[port][0]; in cxlflash_show_port_lun_table()
2179 struct afu *afu = cfg->afu; in port0_lun_table_show() local
2181 return cxlflash_show_port_lun_table(0, afu, buf); in port0_lun_table_show()
2198 struct afu *afu = cfg->afu; in port1_lun_table_show() local
2200 return cxlflash_show_port_lun_table(1, afu, buf); in port1_lun_table_show()
2303 struct afu *afu = cfg->afu; in cxlflash_worker_thread() local
2325 afu_link_reset(afu, port, in cxlflash_worker_thread()
2326 &afu->afu_map->global.fc_regs[port][0]); in cxlflash_worker_thread()
2333 if (afu->read_room) { in cxlflash_worker_thread()
2334 atomic64_set(&afu->room, readq_be(&afu->host_map->cmd_room)); in cxlflash_worker_thread()
2335 afu->read_room = false; in cxlflash_worker_thread()