Lines Matching refs:scmd
52 * mpi3mr_host_tag_for_scmd - Get host tag for a scmd
54 * @scmd: SCSI command reference
56 * Calculate the host tag based on block tag for a given scmd.
61 struct scsi_cmnd *scmd)
67 unique_tag = blk_mq_unique_tag(scsi_cmd_to_rq(scmd));
77 priv = scsi_cmd_priv(scmd);
80 priv->scmd = scmd;
103 struct scsi_cmnd *scmd = NULL;
112 scmd = scsi_host_find_tag(mrioc->shost, unique_tag);
113 if (scmd) {
114 priv = scsi_cmd_priv(scmd);
116 scmd = NULL;
119 return scmd;
125 * @scmd: SCSI command reference
133 struct scsi_cmnd *scmd)
137 priv = scsi_cmd_priv(scmd);
143 priv->scmd = NULL;
452 struct scsi_cmnd *scmd = blk_mq_rq_to_pdu(rq);
455 if (scmd) {
456 priv = scsi_cmd_priv(scmd);
462 scsi_print_command(scmd);
483 struct scsi_cmnd *scmd = blk_mq_rq_to_pdu(rq);
486 if (scmd) {
487 priv = scsi_cmd_priv(scmd);
492 dma_unmap_sg(&mrioc->pdev->dev, scsi_prot_sglist(scmd),
493 scsi_prot_sg_count(scmd), scmd->sc_data_direction);
494 mpi3mr_clear_scmd_priv(mrioc, scmd);
495 scsi_dma_unmap(scmd);
496 scmd->result = DID_RESET << 16;
497 scsi_print_command(scmd);
498 scsi_done(scmd);
523 struct scsi_cmnd *scmd = blk_mq_rq_to_pdu(rq);
526 if (scmd) {
527 priv = scsi_cmd_priv(scmd);
530 if (scmd->device == sdev)
555 struct scsi_cmnd *scmd = blk_mq_rq_to_pdu(rq);
558 if (scmd) {
559 priv = scsi_cmd_priv(scmd);
562 if (scmd->device && (scsi_target(scmd->device) == starget))
2943 * @scmd: SCSI command reference
2953 struct scsi_cmnd *scmd, struct mpi3_scsi_io_request *scsiio_req)
2956 unsigned char prot_op = scsi_get_prot_op(scmd);
2980 if (scmd->prot_flags & SCSI_PROT_IP_CHECKSUM) {
2993 if (scmd->prot_flags & SCSI_PROT_GUARD_CHECK)
2996 if (scmd->prot_flags & SCSI_PROT_IP_CHECKSUM)
2999 if (scmd->prot_flags & SCSI_PROT_REF_CHECK) {
3003 cpu_to_be32(scsi_prot_ref_tag(scmd));
3006 if (scmd->prot_flags & SCSI_PROT_REF_INCREMENT)
3011 switch (scsi_prot_interval(scmd)) {
3074 * @scmd: SCSI command reference
3082 static void mpi3mr_map_eedp_error(struct scsi_cmnd *scmd,
3102 mpi3mr_build_sense_buffer(0, scmd->sense_buffer, ILLEGAL_REQUEST,
3104 scmd->result = (DID_ABORT << 16) | SAM_STAT_CHECK_CONDITION;
3131 struct scsi_cmnd *scmd = NULL;
3192 scmd = mpi3mr_scmd_from_host_tag(mrioc, host_tag, qidx);
3193 if (!scmd) {
3194 panic("%s: Cannot Identify scmd for host_tag 0x%x\n",
3198 priv = scsi_cmd_priv(scmd);
3200 data_len_blks = scsi_bufflen(scmd) >> 9;
3201 sdev_priv_data = scmd->device->hostdata;
3245 scmd->result = DID_OK << 16;
3249 scsi_set_resid(scmd, scsi_bufflen(scmd) - xfer_count);
3260 memcpy(scmd->sense_buffer, sense_buf, sz);
3266 scmd->result = SAM_STAT_BUSY;
3269 scmd->result = DID_NO_CONNECT << 16;
3272 scmd->result = DID_SOFT_ERROR << 16;
3276 scmd->result = DID_RESET << 16;
3279 if ((xfer_count == 0) || (scmd->underflow > xfer_count))
3280 scmd->result = DID_SOFT_ERROR << 16;
3282 scmd->result = (DID_OK << 16) | scsi_status;
3285 scmd->result = (DID_OK << 16) | scsi_status;
3288 if (xfer_count < scmd->underflow) {
3290 scmd->result = SAM_STAT_BUSY;
3292 scmd->result = DID_SOFT_ERROR << 16;
3295 scmd->result = DID_SOFT_ERROR << 16;
3297 scmd->result = DID_RESET << 16;
3300 scsi_set_resid(scmd, 0);
3304 scmd->result = (DID_OK << 16) | scsi_status;
3308 scmd->result = DID_SOFT_ERROR << 16;
3310 scmd->result = DID_RESET << 16;
3315 mpi3mr_map_eedp_error(scmd, ioc_status);
3327 scmd->result = DID_SOFT_ERROR << 16;
3331 if (scmd->result != (DID_OK << 16) && (scmd->cmnd[0] != ATA_12) &&
3332 (scmd->cmnd[0] != ATA_16) &&
3334 ioc_info(mrioc, "%s :scmd->result 0x%x\n", __func__,
3335 scmd->result);
3336 scsi_print_command(scmd);
3354 dma_unmap_sg(&mrioc->pdev->dev, scsi_prot_sglist(scmd),
3355 scsi_prot_sg_count(scmd), scmd->sc_data_direction);
3357 mpi3mr_clear_scmd_priv(mrioc, scmd);
3358 scsi_dma_unmap(scmd);
3359 scsi_done(scmd);
3397 * @scmd: SCSI command reference
3407 struct scsi_cmnd *scmd, struct mpi3_scsi_io_request *scsiio_req)
3423 priv = scsi_cmd_priv(scmd);
3443 sg_scmd = scsi_prot_sglist(scmd);
3445 scsi_prot_sglist(scmd),
3446 scsi_prot_sg_count(scmd),
3447 scmd->sc_data_direction);
3450 sg_scmd = scsi_sglist(scmd);
3451 sges_left = scsi_dma_map(scmd);
3455 sdev_printk(KERN_ERR, scmd->device,
3457 scsi_bufflen(scmd));
3461 sdev_printk(KERN_ERR, scmd->device,
3538 * @scmd: SCSI command reference
3548 struct scsi_cmnd *scmd, struct mpi3_scsi_io_request *scsiio_req)
3552 ret = mpi3mr_prepare_sg_scmd(mrioc, scmd, scsiio_req);
3560 ret = mpi3mr_prepare_sg_scmd(mrioc, scmd, scsiio_req);
3636 * @scmd: SCSI command
3648 u8 *resp_code, struct scsi_cmnd *scmd)
3695 if (scmd) {
3696 sdev = scmd->device;
3983 * @scmd: SCSI command reference
3995 struct scsi_cmnd *scmd, struct mpi3_scsi_io_request *scsiio_req,
3999 u8 opcode = scmd->cmnd[0];
4001 u16 sa = (scmd->cmnd[8] << 8) | (scmd->cmnd[9]);
4004 unmap = scmd->cmnd[1] & 0x08;
4005 ndob = scmd->cmnd[1] & 0x01;
4006 num_blocks = get_unaligned_be32(scmd->cmnd + 10);
4008 unmap = scmd->cmnd[10] & 0x08;
4009 ndob = scmd->cmnd[10] & 0x01;
4010 num_blocks = get_unaligned_be32(scmd->cmnd + 28);
4024 * @scmd: SCSI command reference
4026 * Issue controller reset if the scmd is for a Physical Device,
4027 * if the scmd is for RAID volume, then wait for
4033 static int mpi3mr_eh_host_reset(struct scsi_cmnd *scmd)
4035 struct mpi3mr_ioc *mrioc = shost_priv(scmd->device->host);
4041 sdev_priv_data = scmd->device->hostdata;
4064 sdev_printk(KERN_INFO, scmd->device,
4065 "Host reset is %s for scmd(%p)\n",
4066 ((retval == SUCCESS) ? "SUCCESS" : "FAILED"), scmd);
4073 * @scmd: SCSI command reference
4075 * Issue Target reset Task Management and verify the scmd is
4078 * Return: SUCCESS of successful termination of the scmd else
4081 static int mpi3mr_eh_target_reset(struct scsi_cmnd *scmd)
4083 struct mpi3mr_ioc *mrioc = shost_priv(scmd->device->host);
4090 sdev_printk(KERN_INFO, scmd->device,
4091 "Attempting Target Reset! scmd(%p)\n", scmd);
4092 scsi_print_command(scmd);
4094 sdev_priv_data = scmd->device->hostdata;
4096 sdev_printk(KERN_INFO, scmd->device,
4105 struct scmd_priv *cmd_priv = scsi_cmd_priv(scmd);
4106 sdev_printk(KERN_INFO, scmd->device,
4115 sdev_printk(KERN_INFO, scmd->device,
4122 MPI3MR_RESETTM_TIMEOUT, &mrioc->host_tm_cmds, &resp_code, scmd);
4128 sdev_printk(KERN_INFO, scmd->device,
4136 sdev_printk(KERN_INFO, scmd->device,
4137 "%s: target reset is %s for scmd(%p)\n", mrioc->name,
4138 ((retval == SUCCESS) ? "SUCCESS" : "FAILED"), scmd);
4145 * @scmd: SCSI command reference
4147 * Issue lun reset Task Management and verify the scmd is
4150 * Return: SUCCESS of successful termination of the scmd else
4153 static int mpi3mr_eh_dev_reset(struct scsi_cmnd *scmd)
4155 struct mpi3mr_ioc *mrioc = shost_priv(scmd->device->host);
4162 sdev_printk(KERN_INFO, scmd->device,
4163 "Attempting Device(lun) Reset! scmd(%p)\n", scmd);
4164 scsi_print_command(scmd);
4166 sdev_priv_data = scmd->device->hostdata;
4168 sdev_printk(KERN_INFO, scmd->device,
4177 struct scmd_priv *cmd_priv = scsi_cmd_priv(scmd);
4178 sdev_printk(KERN_INFO, scmd->device,
4187 sdev_printk(KERN_INFO, scmd->device,
4193 MPI3MR_RESETTM_TIMEOUT, &mrioc->host_tm_cmds, &resp_code, scmd);
4199 sdev_printk(KERN_INFO, scmd->device,
4206 sdev_printk(KERN_INFO, scmd->device,
4207 "%s: device(LUN) reset is %s for scmd(%p)\n", mrioc->name,
4208 ((retval == SUCCESS) ? "SUCCESS" : "FAILED"), scmd);
4579 * @scmd: SCSI Command reference
4589 struct scsi_cmnd *scmd)
4594 trunc_param_len = param_len = get_unaligned_be16(scmd->cmnd + 7);
4599 dprint_scsi_command(mrioc, scmd, MPI3_DEBUG_SCSI_ERROR);
4603 put_unaligned_be16(trunc_param_len, scmd->cmnd + 7);
4604 dprint_scsi_command(mrioc, scmd, MPI3_DEBUG_SCSI_ERROR);
4613 scsi_print_command(scmd);
4614 scmd->result = DID_OK << 16;
4615 scsi_done(scmd);
4623 scsi_print_command(scmd);
4624 scmd->result = SAM_STAT_CHECK_CONDITION;
4625 scsi_build_sense_buffer(0, scmd->sense_buffer, ILLEGAL_REQUEST,
4627 scsi_done(scmd);
4630 if (param_len != scsi_bufflen(scmd)) {
4633 __func__, param_len, scsi_bufflen(scmd));
4634 scsi_print_command(scmd);
4635 scmd->result = SAM_STAT_CHECK_CONDITION;
4636 scsi_build_sense_buffer(0, scmd->sense_buffer, ILLEGAL_REQUEST,
4638 scsi_done(scmd);
4641 buf = kzalloc(scsi_bufflen(scmd), GFP_ATOMIC);
4643 scsi_print_command(scmd);
4644 scmd->result = SAM_STAT_CHECK_CONDITION;
4645 scsi_build_sense_buffer(0, scmd->sense_buffer, ILLEGAL_REQUEST,
4647 scsi_done(scmd);
4650 scsi_sg_copy_to_buffer(scmd, buf, scsi_bufflen(scmd));
4657 scsi_print_command(scmd);
4658 scmd->result = SAM_STAT_CHECK_CONDITION;
4659 scsi_build_sense_buffer(0, scmd->sense_buffer, ILLEGAL_REQUEST,
4661 scsi_done(scmd);
4668 scsi_print_command(scmd);
4672 put_unaligned_be16(trunc_param_len, scmd->cmnd + 7);
4673 scsi_print_command(scmd);
4682 * @scmd: SCSI Command reference
4689 inline bool mpi3mr_allow_scmd_to_fw(struct scsi_cmnd *scmd)
4691 switch (scmd->cmnd[0]) {
4703 * @scmd: SCSI Command reference
4713 struct scsi_cmnd *scmd)
4725 struct request *rq = scsi_cmd_to_rq(scmd);
4733 scmd->result = DID_ERROR << 16;
4734 scsi_done(scmd);
4738 sdev_priv_data = scmd->device->hostdata;
4740 scmd->result = DID_NO_CONNECT << 16;
4741 scsi_done(scmd);
4746 !(mpi3mr_allow_scmd_to_fw(scmd))) {
4747 scmd->result = DID_NO_CONNECT << 16;
4748 scsi_done(scmd);
4757 if (scmd->device->host->shost_state == SHOST_RECOVERY &&
4758 scmd->cmnd[0] == TEST_UNIT_READY &&
4760 scsi_build_sense(scmd, 0, UNIT_ATTENTION, 0x29, 0x07);
4761 scsi_done(scmd);
4772 scmd->result = DID_NO_CONNECT << 16;
4773 scsi_done(scmd);
4781 scmd->result = DID_NO_CONNECT << 16;
4782 scsi_done(scmd);
4786 scmd->result = DID_NO_CONNECT << 16;
4787 scsi_done(scmd);
4793 if ((scmd->cmnd[0] == UNMAP) && is_pcie_dev &&
4795 mpi3mr_check_return_unmap(mrioc, scmd))
4798 host_tag = mpi3mr_host_tag_for_scmd(mrioc, scmd);
4800 scmd->result = DID_ERROR << 16;
4801 scsi_done(scmd);
4805 if (scmd->sc_data_direction == DMA_FROM_DEVICE)
4807 else if (scmd->sc_data_direction == DMA_TO_DEVICE)
4820 if (scmd->cmd_len > 16)
4823 scmd_priv_data = scsi_cmd_priv(scmd);
4829 mpi3mr_setup_eedp(mrioc, scmd, scsiio_req);
4832 mpi3mr_setup_divert_ws(mrioc, scmd, scsiio_req, &scsiio_flags,
4835 memcpy(scsiio_req->cdb.cdb32, scmd->cmnd, scmd->cmd_len);
4836 scsiio_req->data_length = cpu_to_le32(scsi_bufflen(scmd));
4842 if (mpi3mr_build_sg_scmd(mrioc, scmd, scsiio_req)) {
4843 mpi3mr_clear_scmd_priv(mrioc, scmd);
4848 data_len_blks = scsi_bufflen(scmd) >> 9;
4884 mpi3mr_clear_scmd_priv(mrioc, scmd);