Lines Matching refs:cmd

52 	struct afu_cmd *cmd;  in cmd_checkout()  local
57 cmd = &afu->cmd[k]; in cmd_checkout()
59 if (!atomic_dec_if_positive(&cmd->free)) { in cmd_checkout()
61 __func__, cmd->slot, cmd); in cmd_checkout()
62 memset(cmd->buf, 0, CMD_BUFSIZE); in cmd_checkout()
63 memset(cmd->rcb.cdb, 0, sizeof(cmd->rcb.cdb)); in cmd_checkout()
64 return cmd; in cmd_checkout()
81 static void cmd_checkin(struct afu_cmd *cmd) in cmd_checkin() argument
83 cmd->rcb.scp = NULL; in cmd_checkin()
84 cmd->rcb.timeout = 0; in cmd_checkin()
85 cmd->sa.ioasc = 0; in cmd_checkin()
86 cmd->cmd_tmf = false; in cmd_checkin()
87 cmd->sa.host_use[0] = 0; /* clears both completion and retry bytes */ in cmd_checkin()
89 if (unlikely(atomic_inc_return(&cmd->free) != 1)) { in cmd_checkin()
91 __func__, cmd->slot); in cmd_checkin()
95 pr_devel("%s: released cmd %p index=%d\n", __func__, cmd, cmd->slot); in cmd_checkin()
105 static void process_cmd_err(struct afu_cmd *cmd, struct scsi_cmnd *scp) in process_cmd_err() argument
111 if (unlikely(!cmd)) in process_cmd_err()
114 ioarcb = &(cmd->rcb); in process_cmd_err()
115 ioasa = &(cmd->sa); in process_cmd_err()
121 __func__, cmd, scp, resid); in process_cmd_err()
126 __func__, cmd, scp); in process_cmd_err()
217 static void cmd_complete(struct afu_cmd *cmd) in cmd_complete() argument
221 struct afu *afu = cmd->parent; in cmd_complete()
225 spin_lock_irqsave(&cmd->slock, lock_flags); in cmd_complete()
226 cmd->sa.host_use_b[0] |= B_DONE; in cmd_complete()
227 spin_unlock_irqrestore(&cmd->slock, lock_flags); in cmd_complete()
229 if (cmd->rcb.scp) { in cmd_complete()
230 scp = cmd->rcb.scp; in cmd_complete()
231 if (unlikely(cmd->sa.ioasc)) in cmd_complete()
232 process_cmd_err(cmd, scp); in cmd_complete()
236 cmd_is_tmf = cmd->cmd_tmf; in cmd_complete()
237 cmd_checkin(cmd); /* Don't use cmd after here */ in cmd_complete()
241 cmd->sa.ioasc); in cmd_complete()
253 complete(&cmd->cevent); in cmd_complete()
262 static void context_reset(struct afu_cmd *cmd) in context_reset() argument
267 struct afu *afu = cmd->parent; in context_reset()
270 pr_debug("%s: cmd=%p\n", __func__, cmd); in context_reset()
272 spin_lock_irqsave(&cmd->slock, lock_flags); in context_reset()
275 if (cmd->sa.host_use_b[0] & B_DONE) { in context_reset()
276 spin_unlock_irqrestore(&cmd->slock, lock_flags); in context_reset()
280 cmd->sa.host_use_b[0] |= (B_DONE | B_ERROR | B_TIMEOUT); in context_reset()
281 spin_unlock_irqrestore(&cmd->slock, lock_flags); in context_reset()
318 static int send_cmd(struct afu *afu, struct afu_cmd *cmd) in send_cmd() argument
345 __func__, cmd->rcb.cdb[0]); in send_cmd()
363 writeq_be((u64)&cmd->rcb, &afu->host_map->ioarrin); in send_cmd()
365 pr_devel("%s: cmd=%p len=%d ea=%p rc=%d\n", __func__, cmd, in send_cmd()
366 cmd->rcb.data_len, (void *)cmd->rcb.data_ea, rc); in send_cmd()
381 static void wait_resp(struct afu *afu, struct afu_cmd *cmd) in wait_resp() argument
383 ulong timeout = msecs_to_jiffies(cmd->rcb.timeout * 2 * 1000); in wait_resp()
385 timeout = wait_for_completion_timeout(&cmd->cevent, timeout); in wait_resp()
387 context_reset(cmd); in wait_resp()
389 if (unlikely(cmd->sa.ioasc != 0)) in wait_resp()
391 "scsi_rc 0x%X, fc_rc 0x%X\n", __func__, cmd->rcb.cdb[0], in wait_resp()
392 cmd->sa.rc.flags, cmd->sa.rc.afu_rc, cmd->sa.rc.scsi_rc, in wait_resp()
393 cmd->sa.rc.fc_rc); in wait_resp()
407 struct afu_cmd *cmd; in send_tmf() local
418 cmd = cmd_checkout(afu); in send_tmf()
419 if (unlikely(!cmd)) { in send_tmf()
432 cmd->cmd_tmf = true; in send_tmf()
435 cmd->rcb.ctx_id = afu->ctx_hndl; in send_tmf()
436 cmd->rcb.port_sel = port_sel; in send_tmf()
437 cmd->rcb.lun_id = lun_to_lunid(scp->device->lun); in send_tmf()
441 cmd->rcb.req_flags = (SISL_REQ_FLAGS_PORT_LUN_ID | in send_tmf()
445 cmd->rcb.scp = scp; in send_tmf()
448 memcpy(cmd->rcb.cdb, &tmfcmd, sizeof(tmfcmd)); in send_tmf()
451 rc = send_cmd(afu, cmd); in send_tmf()
453 cmd_checkin(cmd); in send_tmf()
499 struct afu_cmd *cmd; in cxlflash_queuecommand() local
543 cmd = cmd_checkout(afu); in cxlflash_queuecommand()
544 if (unlikely(!cmd)) { in cxlflash_queuecommand()
550 cmd->rcb.ctx_id = afu->ctx_hndl; in cxlflash_queuecommand()
551 cmd->rcb.port_sel = port_sel; in cxlflash_queuecommand()
552 cmd->rcb.lun_id = lun_to_lunid(scp->device->lun); in cxlflash_queuecommand()
559 cmd->rcb.req_flags = (SISL_REQ_FLAGS_PORT_LUN_ID | in cxlflash_queuecommand()
563 cmd->rcb.scp = scp; in cxlflash_queuecommand()
575 cmd->rcb.data_len = sg_dma_len(sg); in cxlflash_queuecommand()
576 cmd->rcb.data_ea = sg_dma_address(sg); in cxlflash_queuecommand()
580 memcpy(cmd->rcb.cdb, scp->cmnd, sizeof(cmd->rcb.cdb)); in cxlflash_queuecommand()
583 rc = send_cmd(afu, cmd); in cxlflash_queuecommand()
585 cmd_checkin(cmd); in cxlflash_queuecommand()
620 buf = afu->cmd[i].buf; in free_mem()
643 complete(&afu->cmd[i].cevent); in stop_afu()
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()
1235 struct afu_cmd *cmd; in cxlflash_rrq_irq() local
1249 cmd = (struct afu_cmd *)(entry & ~SISL_RESP_HANDLE_T_BIT); in cxlflash_rrq_irq()
1250 cmd_complete(cmd); in cxlflash_rrq_irq()
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()
1586 struct afu_cmd *cmd; in start_afu() local
1592 cmd = &afu->cmd[i]; in start_afu()
1594 init_completion(&cmd->cevent); in start_afu()
1595 spin_lock_init(&cmd->slock); in start_afu()
1596 cmd->parent = afu; in start_afu()
1802 struct afu_cmd *cmd = NULL; in cxlflash_afu_sync() local
1814 cmd = cmd_checkout(afu); in cxlflash_afu_sync()
1815 if (unlikely(!cmd)) { in cxlflash_afu_sync()
1825 pr_debug("%s: afu=%p cmd=%p %d\n", __func__, afu, cmd, ctx_hndl_u); in cxlflash_afu_sync()
1827 memset(cmd->rcb.cdb, 0, sizeof(cmd->rcb.cdb)); in cxlflash_afu_sync()
1829 cmd->rcb.req_flags = SISL_REQ_FLAGS_AFU_CMD; in cxlflash_afu_sync()
1830 cmd->rcb.port_sel = 0x0; /* NA */ in cxlflash_afu_sync()
1831 cmd->rcb.lun_id = 0x0; /* NA */ in cxlflash_afu_sync()
1832 cmd->rcb.data_len = 0x0; in cxlflash_afu_sync()
1833 cmd->rcb.data_ea = 0x0; in cxlflash_afu_sync()
1834 cmd->rcb.timeout = MC_AFU_SYNC_TIMEOUT; in cxlflash_afu_sync()
1836 cmd->rcb.cdb[0] = 0xC0; /* AFU Sync */ in cxlflash_afu_sync()
1837 cmd->rcb.cdb[1] = mode; in cxlflash_afu_sync()
1840 *((__be16 *)&cmd->rcb.cdb[2]) = cpu_to_be16(ctx_hndl_u); in cxlflash_afu_sync()
1841 *((__be32 *)&cmd->rcb.cdb[4]) = cpu_to_be32(res_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()
1850 if (unlikely((cmd->sa.ioasc != 0) || in cxlflash_afu_sync()
1851 (cmd->sa.host_use_b[0] & B_ERROR))) in cxlflash_afu_sync()
1855 if (cmd) in cxlflash_afu_sync()
1856 cmd_checkin(cmd); in cxlflash_afu_sync()