Lines Matching +full:cmd +full:- +full:cnt +full:- +full:name
1 // SPDX-License-Identifier: GPL-2.0-only
4 * Copyright (c) 2003-2014 QLogic Corporation
16 * qla2x00_get_cmd_direction() - Determine control_flag data direction.
25 struct scsi_cmnd *cmd = GET_CMD_SP(sp); in qla2x00_get_cmd_direction() local
26 struct scsi_qla_host *vha = sp->vha; in qla2x00_get_cmd_direction()
31 if (cmd->sc_data_direction == DMA_TO_DEVICE) { in qla2x00_get_cmd_direction()
33 vha->qla_stats.output_bytes += scsi_bufflen(cmd); in qla2x00_get_cmd_direction()
34 vha->qla_stats.output_requests++; in qla2x00_get_cmd_direction()
35 } else if (cmd->sc_data_direction == DMA_FROM_DEVICE) { in qla2x00_get_cmd_direction()
37 vha->qla_stats.input_bytes += scsi_bufflen(cmd); in qla2x00_get_cmd_direction()
38 vha->qla_stats.input_requests++; in qla2x00_get_cmd_direction()
44 * qla2x00_calc_iocbs_32() - Determine number of Command Type 2 and
58 iocbs += (dsds - 3) / 7; in qla2x00_calc_iocbs_32()
59 if ((dsds - 3) % 7) in qla2x00_calc_iocbs_32()
66 * qla2x00_calc_iocbs_64() - Determine number of Command Type 3 and
80 iocbs += (dsds - 2) / 5; in qla2x00_calc_iocbs_64()
81 if ((dsds - 2) % 5) in qla2x00_calc_iocbs_64()
88 * qla2x00_prep_cont_type0_iocb() - Initialize a Continuation Type 0 IOCB.
97 struct req_que *req = vha->req; in qla2x00_prep_cont_type0_iocb()
99 req->ring_index++; in qla2x00_prep_cont_type0_iocb()
100 if (req->ring_index == req->length) { in qla2x00_prep_cont_type0_iocb()
101 req->ring_index = 0; in qla2x00_prep_cont_type0_iocb()
102 req->ring_ptr = req->ring; in qla2x00_prep_cont_type0_iocb()
104 req->ring_ptr++; in qla2x00_prep_cont_type0_iocb()
107 cont_pkt = (cont_entry_t *)req->ring_ptr; in qla2x00_prep_cont_type0_iocb()
110 put_unaligned_le32(CONTINUE_TYPE, &cont_pkt->entry_type); in qla2x00_prep_cont_type0_iocb()
116 * qla2x00_prep_cont_type1_iocb() - Initialize a Continuation Type 1 IOCB.
128 req->ring_index++; in qla2x00_prep_cont_type1_iocb()
129 if (req->ring_index == req->length) { in qla2x00_prep_cont_type1_iocb()
130 req->ring_index = 0; in qla2x00_prep_cont_type1_iocb()
131 req->ring_ptr = req->ring; in qla2x00_prep_cont_type1_iocb()
133 req->ring_ptr++; in qla2x00_prep_cont_type1_iocb()
136 cont_pkt = (cont_a64_entry_t *)req->ring_ptr; in qla2x00_prep_cont_type1_iocb()
139 put_unaligned_le32(IS_QLAFX00(vha->hw) ? CONTINUE_A64_TYPE_FX00 : in qla2x00_prep_cont_type1_iocb()
140 CONTINUE_A64_TYPE, &cont_pkt->entry_type); in qla2x00_prep_cont_type1_iocb()
148 struct scsi_cmnd *cmd = GET_CMD_SP(sp); in qla24xx_configure_prot_mode() local
154 switch (scsi_get_prot_op(cmd)) { in qla24xx_configure_prot_mode()
169 if (cmd->prot_flags & SCSI_PROT_IP_CHECKSUM) in qla24xx_configure_prot_mode()
179 if (!(cmd->prot_flags & SCSI_PROT_GUARD_CHECK)) in qla24xx_configure_prot_mode()
182 return scsi_prot_sg_count(cmd); in qla24xx_configure_prot_mode()
186 * qla2x00_build_scsi_iocbs_32() - Build IOCB command utilizing 32bit
199 struct scsi_cmnd *cmd; in qla2x00_build_scsi_iocbs_32() local
203 cmd = GET_CMD_SP(sp); in qla2x00_build_scsi_iocbs_32()
206 put_unaligned_le32(COMMAND_TYPE, &cmd_pkt->entry_type); in qla2x00_build_scsi_iocbs_32()
209 if (!scsi_bufflen(cmd) || cmd->sc_data_direction == DMA_NONE) { in qla2x00_build_scsi_iocbs_32()
210 cmd_pkt->byte_count = cpu_to_le32(0); in qla2x00_build_scsi_iocbs_32()
214 vha = sp->vha; in qla2x00_build_scsi_iocbs_32()
215 cmd_pkt->control_flags |= cpu_to_le16(qla2x00_get_cmd_direction(sp)); in qla2x00_build_scsi_iocbs_32()
218 avail_dsds = ARRAY_SIZE(cmd_pkt->dsd32); in qla2x00_build_scsi_iocbs_32()
219 cur_dsd = cmd_pkt->dsd32; in qla2x00_build_scsi_iocbs_32()
222 scsi_for_each_sg(cmd, sg, tot_dsds, i) { in qla2x00_build_scsi_iocbs_32()
232 cur_dsd = cont_pkt->dsd; in qla2x00_build_scsi_iocbs_32()
233 avail_dsds = ARRAY_SIZE(cont_pkt->dsd); in qla2x00_build_scsi_iocbs_32()
237 avail_dsds--; in qla2x00_build_scsi_iocbs_32()
242 * qla2x00_build_scsi_iocbs_64() - Build IOCB command utilizing 64bit
255 struct scsi_cmnd *cmd; in qla2x00_build_scsi_iocbs_64() local
259 cmd = GET_CMD_SP(sp); in qla2x00_build_scsi_iocbs_64()
262 put_unaligned_le32(COMMAND_A64_TYPE, &cmd_pkt->entry_type); in qla2x00_build_scsi_iocbs_64()
265 if (!scsi_bufflen(cmd) || cmd->sc_data_direction == DMA_NONE) { in qla2x00_build_scsi_iocbs_64()
266 cmd_pkt->byte_count = cpu_to_le32(0); in qla2x00_build_scsi_iocbs_64()
270 vha = sp->vha; in qla2x00_build_scsi_iocbs_64()
271 cmd_pkt->control_flags |= cpu_to_le16(qla2x00_get_cmd_direction(sp)); in qla2x00_build_scsi_iocbs_64()
274 avail_dsds = ARRAY_SIZE(cmd_pkt->dsd64); in qla2x00_build_scsi_iocbs_64()
275 cur_dsd = cmd_pkt->dsd64; in qla2x00_build_scsi_iocbs_64()
278 scsi_for_each_sg(cmd, sg, tot_dsds, i) { in qla2x00_build_scsi_iocbs_64()
287 cont_pkt = qla2x00_prep_cont_type1_iocb(vha, vha->req); in qla2x00_build_scsi_iocbs_64()
288 cur_dsd = cont_pkt->dsd; in qla2x00_build_scsi_iocbs_64()
289 avail_dsds = ARRAY_SIZE(cont_pkt->dsd); in qla2x00_build_scsi_iocbs_64()
293 avail_dsds--; in qla2x00_build_scsi_iocbs_64()
299 * req->current_outstanding_cmd + 1. The caller must hold the lock that is
304 uint32_t index, handle = req->current_outstanding_cmd; in qla2xxx_get_next_handle()
306 for (index = 1; index < req->num_outstanding_cmds; index++) { in qla2xxx_get_next_handle()
308 if (handle == req->num_outstanding_cmds) in qla2xxx_get_next_handle()
310 if (!req->outstanding_cmds[handle]) in qla2xxx_get_next_handle()
318 * qla2x00_start_scsi() - Send a SCSI command to the ISP
321 * Returns non-zero if a failure occurred, else zero.
329 struct scsi_cmnd *cmd; in qla2x00_start_scsi() local
333 uint16_t cnt; in qla2x00_start_scsi() local
342 vha = sp->vha; in qla2x00_start_scsi()
343 ha = vha->hw; in qla2x00_start_scsi()
344 reg = &ha->iobase->isp; in qla2x00_start_scsi()
345 cmd = GET_CMD_SP(sp); in qla2x00_start_scsi()
346 req = ha->req_q_map[0]; in qla2x00_start_scsi()
347 rsp = ha->rsp_q_map[0]; in qla2x00_start_scsi()
352 if (vha->marker_needed != 0) { in qla2x00_start_scsi()
353 if (qla2x00_marker(vha, ha->base_qpair, 0, 0, MK_SYNC_ALL) != in qla2x00_start_scsi()
357 vha->marker_needed = 0; in qla2x00_start_scsi()
361 spin_lock_irqsave(&ha->hardware_lock, flags); in qla2x00_start_scsi()
368 if (scsi_sg_count(cmd)) { in qla2x00_start_scsi()
369 nseg = dma_map_sg(&ha->pdev->dev, scsi_sglist(cmd), in qla2x00_start_scsi()
370 scsi_sg_count(cmd), cmd->sc_data_direction); in qla2x00_start_scsi()
379 req_cnt = ha->isp_ops->calc_req_entries(tot_dsds); in qla2x00_start_scsi()
380 if (req->cnt < (req_cnt + 2)) { in qla2x00_start_scsi()
381 cnt = rd_reg_word_relaxed(ISP_REQ_Q_OUT(ha, reg)); in qla2x00_start_scsi()
382 if (req->ring_index < cnt) in qla2x00_start_scsi()
383 req->cnt = cnt - req->ring_index; in qla2x00_start_scsi()
385 req->cnt = req->length - in qla2x00_start_scsi()
386 (req->ring_index - cnt); in qla2x00_start_scsi()
388 if (req->cnt < (req_cnt + 2)) in qla2x00_start_scsi()
393 req->current_outstanding_cmd = handle; in qla2x00_start_scsi()
394 req->outstanding_cmds[handle] = sp; in qla2x00_start_scsi()
395 sp->handle = handle; in qla2x00_start_scsi()
396 cmd->host_scribble = (unsigned char *)(unsigned long)handle; in qla2x00_start_scsi()
397 req->cnt -= req_cnt; in qla2x00_start_scsi()
399 cmd_pkt = (cmd_entry_t *)req->ring_ptr; in qla2x00_start_scsi()
400 cmd_pkt->handle = handle; in qla2x00_start_scsi()
403 memset(clr_ptr, 0, REQUEST_ENTRY_SIZE - 8); in qla2x00_start_scsi()
404 cmd_pkt->dseg_count = cpu_to_le16(tot_dsds); in qla2x00_start_scsi()
407 SET_TARGET_ID(ha, cmd_pkt->target, sp->fcport->loop_id); in qla2x00_start_scsi()
408 cmd_pkt->lun = cpu_to_le16(cmd->device->lun); in qla2x00_start_scsi()
409 cmd_pkt->control_flags = cpu_to_le16(CF_SIMPLE_TAG); in qla2x00_start_scsi()
412 memcpy(cmd_pkt->scsi_cdb, cmd->cmnd, cmd->cmd_len); in qla2x00_start_scsi()
413 cmd_pkt->byte_count = cpu_to_le32((uint32_t)scsi_bufflen(cmd)); in qla2x00_start_scsi()
416 ha->isp_ops->build_iocbs(sp, cmd_pkt, tot_dsds); in qla2x00_start_scsi()
419 cmd_pkt->entry_count = (uint8_t)req_cnt; in qla2x00_start_scsi()
423 req->ring_index++; in qla2x00_start_scsi()
424 if (req->ring_index == req->length) { in qla2x00_start_scsi()
425 req->ring_index = 0; in qla2x00_start_scsi()
426 req->ring_ptr = req->ring; in qla2x00_start_scsi()
428 req->ring_ptr++; in qla2x00_start_scsi()
430 sp->flags |= SRB_DMA_VALID; in qla2x00_start_scsi()
433 wrt_reg_word(ISP_REQ_Q_IN(ha, reg), req->ring_index); in qla2x00_start_scsi()
437 if (vha->flags.process_response_queue && in qla2x00_start_scsi()
438 rsp->ring_ptr->signature != RESPONSE_PROCESSED) in qla2x00_start_scsi()
441 spin_unlock_irqrestore(&ha->hardware_lock, flags); in qla2x00_start_scsi()
446 scsi_dma_unmap(cmd); in qla2x00_start_scsi()
448 spin_unlock_irqrestore(&ha->hardware_lock, flags); in qla2x00_start_scsi()
454 * qla2x00_start_iocbs() - Execute the IOCB command
461 struct qla_hw_data *ha = vha->hw; in qla2x00_start_iocbs()
462 device_reg_t *reg = ISP_QUE_REG(ha, req->id); in qla2x00_start_iocbs()
468 req->ring_index++; in qla2x00_start_iocbs()
469 if (req->ring_index == req->length) { in qla2x00_start_iocbs()
470 req->ring_index = 0; in qla2x00_start_iocbs()
471 req->ring_ptr = req->ring; in qla2x00_start_iocbs()
473 req->ring_ptr++; in qla2x00_start_iocbs()
476 if (ha->mqenable || IS_QLA27XX(ha) || IS_QLA28XX(ha)) { in qla2x00_start_iocbs()
477 wrt_reg_dword(req->req_q_in, req->ring_index); in qla2x00_start_iocbs()
479 wrt_reg_dword(req->req_q_in, req->ring_index); in qla2x00_start_iocbs()
480 rd_reg_dword_relaxed(&ha->iobase->isp24.hccr); in qla2x00_start_iocbs()
482 wrt_reg_dword(®->ispfx00.req_q_in, req->ring_index); in qla2x00_start_iocbs()
483 rd_reg_dword_relaxed(®->ispfx00.req_q_in); in qla2x00_start_iocbs()
484 QLAFX00_SET_HST_INTR(ha, ha->rqstq_intr_code); in qla2x00_start_iocbs()
486 wrt_reg_dword(®->isp24.req_q_in, req->ring_index); in qla2x00_start_iocbs()
487 rd_reg_dword_relaxed(®->isp24.req_q_in); in qla2x00_start_iocbs()
489 wrt_reg_word(ISP_REQ_Q_IN(ha, ®->isp), in qla2x00_start_iocbs()
490 req->ring_index); in qla2x00_start_iocbs()
491 rd_reg_word_relaxed(ISP_REQ_Q_IN(ha, ®->isp)); in qla2x00_start_iocbs()
497 * __qla2x00_marker() - Send a marker IOCB to the firmware.
506 * Returns non-zero if a failure occurred, else zero.
514 struct req_que *req = qpair->req; in __qla2x00_marker()
515 struct qla_hw_data *ha = vha->hw; in __qla2x00_marker()
516 scsi_qla_host_t *base_vha = pci_get_drvdata(ha->pdev); in __qla2x00_marker()
528 mrk->entry_type = MARKER_TYPE; in __qla2x00_marker()
529 mrk->modifier = type; in __qla2x00_marker()
532 mrk24->nport_handle = cpu_to_le16(loop_id); in __qla2x00_marker()
533 int_to_scsilun(lun, (struct scsi_lun *)&mrk24->lun); in __qla2x00_marker()
534 host_to_fcp_swap(mrk24->lun, sizeof(mrk24->lun)); in __qla2x00_marker()
535 mrk24->vp_index = vha->vp_idx; in __qla2x00_marker()
537 SET_TARGET_ID(ha, mrk->target, loop_id); in __qla2x00_marker()
538 mrk->lun = cpu_to_le16((uint16_t)lun); in __qla2x00_marker()
543 mrk24->handle = QLA_SKIP_HANDLE; in __qla2x00_marker()
559 spin_lock_irqsave(qpair->qp_lock_ptr, flags); in qla2x00_marker()
561 spin_unlock_irqrestore(qpair->qp_lock_ptr, flags); in qla2x00_marker()
576 if (__qla2x00_marker(vha, vha->hw->base_qpair, 0, 0, in qla2x00_issue_marker()
580 if (qla2x00_marker(vha, vha->hw->base_qpair, 0, 0, in qla2x00_issue_marker()
584 vha->marker_needed = 0; in qla2x00_issue_marker()
594 struct scsi_cmnd *cmd; in qla24xx_build_scsi_type_6_iocbs() local
601 struct qla_qpair *qpair = sp->qpair; in qla24xx_build_scsi_type_6_iocbs()
603 cmd = GET_CMD_SP(sp); in qla24xx_build_scsi_type_6_iocbs()
606 put_unaligned_le32(COMMAND_TYPE_6, &cmd_pkt->entry_type); in qla24xx_build_scsi_type_6_iocbs()
609 if (!scsi_bufflen(cmd) || cmd->sc_data_direction == DMA_NONE || in qla24xx_build_scsi_type_6_iocbs()
611 cmd_pkt->byte_count = cpu_to_le32(0); in qla24xx_build_scsi_type_6_iocbs()
616 if (cmd->sc_data_direction == DMA_TO_DEVICE) { in qla24xx_build_scsi_type_6_iocbs()
617 cmd_pkt->control_flags = cpu_to_le16(CF_WRITE_DATA); in qla24xx_build_scsi_type_6_iocbs()
618 qpair->counters.output_bytes += scsi_bufflen(cmd); in qla24xx_build_scsi_type_6_iocbs()
619 qpair->counters.output_requests++; in qla24xx_build_scsi_type_6_iocbs()
620 } else if (cmd->sc_data_direction == DMA_FROM_DEVICE) { in qla24xx_build_scsi_type_6_iocbs()
621 cmd_pkt->control_flags = cpu_to_le16(CF_READ_DATA); in qla24xx_build_scsi_type_6_iocbs()
622 qpair->counters.input_bytes += scsi_bufflen(cmd); in qla24xx_build_scsi_type_6_iocbs()
623 qpair->counters.input_requests++; in qla24xx_build_scsi_type_6_iocbs()
626 cur_seg = scsi_sglist(cmd); in qla24xx_build_scsi_type_6_iocbs()
627 ctx = &sp->u.scmd.ct6_ctx; in qla24xx_build_scsi_type_6_iocbs()
632 tot_dsds -= avail_dsds; in qla24xx_build_scsi_type_6_iocbs()
635 dsd_ptr = list_first_entry(&qpair->dsd_list, struct dsd_dma, list); in qla24xx_build_scsi_type_6_iocbs()
636 next_dsd = dsd_ptr->dsd_addr; in qla24xx_build_scsi_type_6_iocbs()
637 list_del(&dsd_ptr->list); in qla24xx_build_scsi_type_6_iocbs()
638 qpair->dsd_avail--; in qla24xx_build_scsi_type_6_iocbs()
639 list_add_tail(&dsd_ptr->list, &ctx->dsd_list); in qla24xx_build_scsi_type_6_iocbs()
640 ctx->dsd_use_cnt++; in qla24xx_build_scsi_type_6_iocbs()
641 qpair->dsd_inuse++; in qla24xx_build_scsi_type_6_iocbs()
645 put_unaligned_le64(dsd_ptr->dsd_list_dma, in qla24xx_build_scsi_type_6_iocbs()
646 &cmd_pkt->fcp_dsd.address); in qla24xx_build_scsi_type_6_iocbs()
647 cmd_pkt->fcp_dsd.length = cpu_to_le32(dsd_list_len); in qla24xx_build_scsi_type_6_iocbs()
649 put_unaligned_le64(dsd_ptr->dsd_list_dma, in qla24xx_build_scsi_type_6_iocbs()
650 &cur_dsd->address); in qla24xx_build_scsi_type_6_iocbs()
651 cur_dsd->length = cpu_to_le32(dsd_list_len); in qla24xx_build_scsi_type_6_iocbs()
658 avail_dsds--; in qla24xx_build_scsi_type_6_iocbs()
663 cur_dsd->address = 0; in qla24xx_build_scsi_type_6_iocbs()
664 cur_dsd->length = 0; in qla24xx_build_scsi_type_6_iocbs()
666 cmd_pkt->control_flags |= cpu_to_le16(CF_DATA_SEG_DESCR_ENABLE); in qla24xx_build_scsi_type_6_iocbs()
671 * qla24xx_calc_dsd_lists() - Determine number of DSD list required
691 * qla24xx_build_scsi_iocbs() - Build IOCB command utilizing Command Type 7
706 struct scsi_cmnd *cmd; in qla24xx_build_scsi_iocbs() local
709 struct qla_qpair *qpair = sp->qpair; in qla24xx_build_scsi_iocbs()
711 cmd = GET_CMD_SP(sp); in qla24xx_build_scsi_iocbs()
714 put_unaligned_le32(COMMAND_TYPE_7, &cmd_pkt->entry_type); in qla24xx_build_scsi_iocbs()
717 if (!scsi_bufflen(cmd) || cmd->sc_data_direction == DMA_NONE) { in qla24xx_build_scsi_iocbs()
718 cmd_pkt->byte_count = cpu_to_le32(0); in qla24xx_build_scsi_iocbs()
722 vha = sp->vha; in qla24xx_build_scsi_iocbs()
725 if (cmd->sc_data_direction == DMA_TO_DEVICE) { in qla24xx_build_scsi_iocbs()
726 cmd_pkt->task_mgmt_flags = cpu_to_le16(TMF_WRITE_DATA); in qla24xx_build_scsi_iocbs()
727 qpair->counters.output_bytes += scsi_bufflen(cmd); in qla24xx_build_scsi_iocbs()
728 qpair->counters.output_requests++; in qla24xx_build_scsi_iocbs()
729 } else if (cmd->sc_data_direction == DMA_FROM_DEVICE) { in qla24xx_build_scsi_iocbs()
730 cmd_pkt->task_mgmt_flags = cpu_to_le16(TMF_READ_DATA); in qla24xx_build_scsi_iocbs()
731 qpair->counters.input_bytes += scsi_bufflen(cmd); in qla24xx_build_scsi_iocbs()
732 qpair->counters.input_requests++; in qla24xx_build_scsi_iocbs()
737 cur_dsd = &cmd_pkt->dsd; in qla24xx_build_scsi_iocbs()
741 scsi_for_each_sg(cmd, sg, tot_dsds, i) { in qla24xx_build_scsi_iocbs()
751 cur_dsd = cont_pkt->dsd; in qla24xx_build_scsi_iocbs()
752 avail_dsds = ARRAY_SIZE(cont_pkt->dsd); in qla24xx_build_scsi_iocbs()
756 avail_dsds--; in qla24xx_build_scsi_iocbs()
768 * qla24xx_set_t10dif_tags_from_cmd - Extract Ref and App tags from SCSI command
775 struct scsi_cmnd *cmd = GET_CMD_SP(sp); in qla24xx_set_t10dif_tags() local
777 pkt->ref_tag = cpu_to_le32(scsi_prot_ref_tag(cmd)); in qla24xx_set_t10dif_tags()
779 if (cmd->prot_flags & SCSI_PROT_REF_CHECK && in qla24xx_set_t10dif_tags()
781 pkt->ref_tag_mask[0] = 0xff; in qla24xx_set_t10dif_tags()
782 pkt->ref_tag_mask[1] = 0xff; in qla24xx_set_t10dif_tags()
783 pkt->ref_tag_mask[2] = 0xff; in qla24xx_set_t10dif_tags()
784 pkt->ref_tag_mask[3] = 0xff; in qla24xx_set_t10dif_tags()
787 pkt->app_tag = cpu_to_le16(0); in qla24xx_set_t10dif_tags()
788 pkt->app_tag_mask[0] = 0x0; in qla24xx_set_t10dif_tags()
789 pkt->app_tag_mask[1] = 0x0; in qla24xx_set_t10dif_tags()
800 if (sgx->num_bytes == sgx->tot_bytes) in qla24xx_get_one_block_sg()
803 sg = sgx->cur_sg; in qla24xx_get_one_block_sg()
804 cumulative_partial = sgx->tot_partial; in qla24xx_get_one_block_sg()
809 sgx->dma_addr = sg_dma_addr + sgx->bytes_consumed; in qla24xx_get_one_block_sg()
811 if ((cumulative_partial + (sg_len - sgx->bytes_consumed)) >= blk_sz) { in qla24xx_get_one_block_sg()
812 sgx->dma_len = (blk_sz - cumulative_partial); in qla24xx_get_one_block_sg()
813 sgx->tot_partial = 0; in qla24xx_get_one_block_sg()
814 sgx->num_bytes += blk_sz; in qla24xx_get_one_block_sg()
817 sgx->dma_len = sg_len - sgx->bytes_consumed; in qla24xx_get_one_block_sg()
818 sgx->tot_partial += sgx->dma_len; in qla24xx_get_one_block_sg()
822 sgx->bytes_consumed += sgx->dma_len; in qla24xx_get_one_block_sg()
824 if (sg_len == sgx->bytes_consumed) { in qla24xx_get_one_block_sg()
826 sgx->num_sg++; in qla24xx_get_one_block_sg()
827 sgx->cur_sg = sg; in qla24xx_get_one_block_sg()
828 sgx->bytes_consumed = 0; in qla24xx_get_one_block_sg()
850 struct scsi_cmnd *cmd; in qla24xx_walk_and_build_sglist_no_difb() local
854 cmd = GET_CMD_SP(sp); in qla24xx_walk_and_build_sglist_no_difb()
855 prot_int = scsi_prot_interval(cmd); in qla24xx_walk_and_build_sglist_no_difb()
857 sgx.tot_bytes = scsi_bufflen(cmd); in qla24xx_walk_and_build_sglist_no_difb()
858 sgx.cur_sg = scsi_sglist(cmd); in qla24xx_walk_and_build_sglist_no_difb()
861 sg_prot = scsi_prot_sglist(cmd); in qla24xx_walk_and_build_sglist_no_difb()
863 prot_int = tc->blk_sz; in qla24xx_walk_and_build_sglist_no_difb()
864 sgx.tot_bytes = tc->bufflen; in qla24xx_walk_and_build_sglist_no_difb()
865 sgx.cur_sg = tc->sg; in qla24xx_walk_and_build_sglist_no_difb()
866 sg_prot = tc->prot_sg; in qla24xx_walk_and_build_sglist_no_difb()
882 used_dsds -= avail_dsds; in qla24xx_walk_and_build_sglist_no_difb()
890 dsd_ptr->dsd_addr = next_dsd = in qla24xx_walk_and_build_sglist_no_difb()
891 dma_pool_alloc(ha->dl_dma_pool, GFP_ATOMIC, in qla24xx_walk_and_build_sglist_no_difb()
892 &dsd_ptr->dsd_list_dma); in qla24xx_walk_and_build_sglist_no_difb()
904 list_add_tail(&dsd_ptr->list, in qla24xx_walk_and_build_sglist_no_difb()
905 &sp->u.scmd.crc_ctx->dsd_list); in qla24xx_walk_and_build_sglist_no_difb()
907 sp->flags |= SRB_CRC_CTX_DSD_VALID; in qla24xx_walk_and_build_sglist_no_difb()
909 list_add_tail(&dsd_ptr->list, in qla24xx_walk_and_build_sglist_no_difb()
910 &(tc->ctx->dsd_list)); in qla24xx_walk_and_build_sglist_no_difb()
911 *tc->ctx_dsd_alloced = 1; in qla24xx_walk_and_build_sglist_no_difb()
915 /* add new list to cmd iocb or last list */ in qla24xx_walk_and_build_sglist_no_difb()
916 put_unaligned_le64(dsd_ptr->dsd_list_dma, in qla24xx_walk_and_build_sglist_no_difb()
917 &cur_dsd->address); in qla24xx_walk_and_build_sglist_no_difb()
918 cur_dsd->length = cpu_to_le32(dsd_list_len); in qla24xx_walk_and_build_sglist_no_difb()
921 put_unaligned_le64(sle_dma, &cur_dsd->address); in qla24xx_walk_and_build_sglist_no_difb()
922 cur_dsd->length = cpu_to_le32(sle_dma_len); in qla24xx_walk_and_build_sglist_no_difb()
924 avail_dsds--; in qla24xx_walk_and_build_sglist_no_difb()
937 partial = 1; /* So as to not re-enter this block */ in qla24xx_walk_and_build_sglist_no_difb()
942 cur_dsd->address = 0; in qla24xx_walk_and_build_sglist_no_difb()
943 cur_dsd->length = 0; in qla24xx_walk_and_build_sglist_no_difb()
960 struct scsi_cmnd *cmd; in qla24xx_walk_and_build_sglist() local
963 cmd = GET_CMD_SP(sp); in qla24xx_walk_and_build_sglist()
964 sgl = scsi_sglist(cmd); in qla24xx_walk_and_build_sglist()
966 sgl = tc->sg; in qla24xx_walk_and_build_sglist()
979 used_dsds -= avail_dsds; in qla24xx_walk_and_build_sglist()
987 dsd_ptr->dsd_addr = next_dsd = in qla24xx_walk_and_build_sglist()
988 dma_pool_alloc(ha->dl_dma_pool, GFP_ATOMIC, in qla24xx_walk_and_build_sglist()
989 &dsd_ptr->dsd_list_dma); in qla24xx_walk_and_build_sglist()
1001 list_add_tail(&dsd_ptr->list, in qla24xx_walk_and_build_sglist()
1002 &sp->u.scmd.crc_ctx->dsd_list); in qla24xx_walk_and_build_sglist()
1004 sp->flags |= SRB_CRC_CTX_DSD_VALID; in qla24xx_walk_and_build_sglist()
1006 list_add_tail(&dsd_ptr->list, in qla24xx_walk_and_build_sglist()
1007 &(tc->ctx->dsd_list)); in qla24xx_walk_and_build_sglist()
1008 *tc->ctx_dsd_alloced = 1; in qla24xx_walk_and_build_sglist()
1011 /* add new list to cmd iocb or last list */ in qla24xx_walk_and_build_sglist()
1012 put_unaligned_le64(dsd_ptr->dsd_list_dma, in qla24xx_walk_and_build_sglist()
1013 &cur_dsd->address); in qla24xx_walk_and_build_sglist()
1014 cur_dsd->length = cpu_to_le32(dsd_list_len); in qla24xx_walk_and_build_sglist()
1018 avail_dsds--; in qla24xx_walk_and_build_sglist()
1022 cur_dsd->address = 0; in qla24xx_walk_and_build_sglist()
1023 cur_dsd->length = 0; in qla24xx_walk_and_build_sglist()
1044 struct scsi_cmnd *cmd = GET_CMD_SP(sp); in qla24xx_walk_and_build_prot_sglist() local
1046 sgl = scsi_prot_sglist(cmd); in qla24xx_walk_and_build_prot_sglist()
1047 vha = sp->vha; in qla24xx_walk_and_build_prot_sglist()
1048 difctx = sp->u.scmd.crc_ctx; in qla24xx_walk_and_build_prot_sglist()
1049 direction_to_device = cmd->sc_data_direction == DMA_TO_DEVICE; in qla24xx_walk_and_build_prot_sglist()
1052 __func__, cmd, difctx, sp); in qla24xx_walk_and_build_prot_sglist()
1054 vha = tc->vha; in qla24xx_walk_and_build_prot_sglist()
1055 sgl = tc->prot_sg; in qla24xx_walk_and_build_prot_sglist()
1056 difctx = tc->ctx; in qla24xx_walk_and_build_prot_sglist()
1057 direction_to_device = tc->dma_data_direction == DMA_TO_DEVICE; in qla24xx_walk_and_build_prot_sglist()
1071 /* If SGE addr + len flips bits in upper 32-bits */ in qla24xx_walk_and_build_prot_sglist()
1072 if (MSD(sle_phys + sg->length) ^ MSD(sle_phys)) { in qla24xx_walk_and_build_prot_sglist()
1075 __func__, sle_phys, sg->length); in qla24xx_walk_and_build_prot_sglist()
1078 ha->dif_bundle_crossed_pages++; in qla24xx_walk_and_build_prot_sglist()
1089 ha->dif_bundle_writes++; in qla24xx_walk_and_build_prot_sglist()
1091 ha->dif_bundle_reads++; in qla24xx_walk_and_build_prot_sglist()
1102 difctx->no_dif_bundl = 0; in qla24xx_walk_and_build_prot_sglist()
1103 difctx->dif_bundl_len = 0; in qla24xx_walk_and_build_prot_sglist()
1106 INIT_LIST_HEAD(&difctx->ldif_dsd_list); in qla24xx_walk_and_build_prot_sglist()
1108 INIT_LIST_HEAD(&difctx->ldif_dma_hndl_list); in qla24xx_walk_and_build_prot_sglist()
1116 difctx->dif_bundl_len, ldma_needed); in qla24xx_walk_and_build_prot_sglist()
1134 ha->dif_bundle_kallocs++; in qla24xx_walk_and_build_prot_sglist()
1137 dsd_ptr->dsd_addr = dma_pool_alloc in qla24xx_walk_and_build_prot_sglist()
1138 (ha->dif_bundl_pool, GFP_ATOMIC, in qla24xx_walk_and_build_prot_sglist()
1139 &dsd_ptr->dsd_list_dma); in qla24xx_walk_and_build_prot_sglist()
1140 if (!dsd_ptr->dsd_addr) { in qla24xx_walk_and_build_prot_sglist()
1142 "%s: failed alloc ->dsd_ptr\n", in qla24xx_walk_and_build_prot_sglist()
1150 ha->dif_bundle_kallocs--; in qla24xx_walk_and_build_prot_sglist()
1153 ha->dif_bundle_dma_allocs++; in qla24xx_walk_and_build_prot_sglist()
1155 difctx->no_dif_bundl++; in qla24xx_walk_and_build_prot_sglist()
1156 list_add_tail(&dsd_ptr->list, in qla24xx_walk_and_build_prot_sglist()
1157 &difctx->ldif_dma_hndl_list); in qla24xx_walk_and_build_prot_sglist()
1162 (DIF_BUNDLING_DMA_POOL_SIZE - ldma_sg_len)) ? in qla24xx_walk_and_build_prot_sglist()
1163 DIF_BUNDLING_DMA_POOL_SIZE - ldma_sg_len : in qla24xx_walk_and_build_prot_sglist()
1168 dsd_ptr->dsd_addr + ldma_sg_len, xfrlen, in qla24xx_walk_and_build_prot_sglist()
1169 difctx->dif_bundl_len); in qla24xx_walk_and_build_prot_sglist()
1170 difctx->dif_bundl_len += xfrlen; in qla24xx_walk_and_build_prot_sglist()
1171 sglen -= xfrlen; in qla24xx_walk_and_build_prot_sglist()
1181 track_difbundl_buf = used_dsds = difctx->no_dif_bundl; in qla24xx_walk_and_build_prot_sglist()
1184 difctx->dif_bundl_len, difctx->no_dif_bundl, in qla24xx_walk_and_build_prot_sglist()
1188 sp->flags |= SRB_DIF_BUNDL_DMA_VALID; in qla24xx_walk_and_build_prot_sglist()
1190 tc->prot_flags = DIF_BUNDL_DMA_VALID; in qla24xx_walk_and_build_prot_sglist()
1193 &difctx->ldif_dma_hndl_list, list) { in qla24xx_walk_and_build_prot_sglist()
1194 u32 sglen = (difctx->dif_bundl_len > in qla24xx_walk_and_build_prot_sglist()
1196 DIF_BUNDLING_DMA_POOL_SIZE : difctx->dif_bundl_len; in qla24xx_walk_and_build_prot_sglist()
1209 used_dsds -= avail_dsds; in qla24xx_walk_and_build_prot_sglist()
1219 ha->dif_bundle_kallocs++; in qla24xx_walk_and_build_prot_sglist()
1221 difctx->no_ldif_dsd++; in qla24xx_walk_and_build_prot_sglist()
1223 dsd_ptr->dsd_addr = in qla24xx_walk_and_build_prot_sglist()
1224 dma_pool_alloc(ha->dl_dma_pool, GFP_ATOMIC, in qla24xx_walk_and_build_prot_sglist()
1225 &dsd_ptr->dsd_list_dma); in qla24xx_walk_and_build_prot_sglist()
1226 if (!dsd_ptr->dsd_addr) { in qla24xx_walk_and_build_prot_sglist()
1228 "%s: failed alloc ->dsd_addr\n", in qla24xx_walk_and_build_prot_sglist()
1235 ha->dif_bundle_kallocs--; in qla24xx_walk_and_build_prot_sglist()
1238 ha->dif_bundle_dma_allocs++; in qla24xx_walk_and_build_prot_sglist()
1241 list_add_tail(&dsd_ptr->list, in qla24xx_walk_and_build_prot_sglist()
1242 &difctx->ldif_dsd_list); in qla24xx_walk_and_build_prot_sglist()
1243 sp->flags |= SRB_CRC_CTX_DSD_VALID; in qla24xx_walk_and_build_prot_sglist()
1245 list_add_tail(&dsd_ptr->list, in qla24xx_walk_and_build_prot_sglist()
1246 &difctx->ldif_dsd_list); in qla24xx_walk_and_build_prot_sglist()
1247 tc->ctx_dsd_alloced = 1; in qla24xx_walk_and_build_prot_sglist()
1250 /* add new list to cmd iocb or last list */ in qla24xx_walk_and_build_prot_sglist()
1251 put_unaligned_le64(dsd_ptr->dsd_list_dma, in qla24xx_walk_and_build_prot_sglist()
1252 &cur_dsd->address); in qla24xx_walk_and_build_prot_sglist()
1253 cur_dsd->length = cpu_to_le32(dsd_list_len); in qla24xx_walk_and_build_prot_sglist()
1254 cur_dsd = dsd_ptr->dsd_addr; in qla24xx_walk_and_build_prot_sglist()
1256 put_unaligned_le64(dif_dsd->dsd_list_dma, in qla24xx_walk_and_build_prot_sglist()
1257 &cur_dsd->address); in qla24xx_walk_and_build_prot_sglist()
1258 cur_dsd->length = cpu_to_le32(sglen); in qla24xx_walk_and_build_prot_sglist()
1260 avail_dsds--; in qla24xx_walk_and_build_prot_sglist()
1261 difctx->dif_bundl_len -= sglen; in qla24xx_walk_and_build_prot_sglist()
1262 track_difbundl_buf--; in qla24xx_walk_and_build_prot_sglist()
1267 difctx->no_ldif_dsd, difctx->no_dif_bundl); in qla24xx_walk_and_build_prot_sglist()
1275 used_dsds -= avail_dsds; in qla24xx_walk_and_build_prot_sglist()
1288 dsd_ptr->dsd_addr = in qla24xx_walk_and_build_prot_sglist()
1289 dma_pool_alloc(ha->dl_dma_pool, GFP_ATOMIC, in qla24xx_walk_and_build_prot_sglist()
1290 &dsd_ptr->dsd_list_dma); in qla24xx_walk_and_build_prot_sglist()
1291 if (!dsd_ptr->dsd_addr) { in qla24xx_walk_and_build_prot_sglist()
1299 list_add_tail(&dsd_ptr->list, in qla24xx_walk_and_build_prot_sglist()
1300 &difctx->dsd_list); in qla24xx_walk_and_build_prot_sglist()
1301 sp->flags |= SRB_CRC_CTX_DSD_VALID; in qla24xx_walk_and_build_prot_sglist()
1303 list_add_tail(&dsd_ptr->list, in qla24xx_walk_and_build_prot_sglist()
1304 &difctx->dsd_list); in qla24xx_walk_and_build_prot_sglist()
1305 tc->ctx_dsd_alloced = 1; in qla24xx_walk_and_build_prot_sglist()
1308 /* add new list to cmd iocb or last list */ in qla24xx_walk_and_build_prot_sglist()
1309 put_unaligned_le64(dsd_ptr->dsd_list_dma, in qla24xx_walk_and_build_prot_sglist()
1310 &cur_dsd->address); in qla24xx_walk_and_build_prot_sglist()
1311 cur_dsd->length = cpu_to_le32(dsd_list_len); in qla24xx_walk_and_build_prot_sglist()
1312 cur_dsd = dsd_ptr->dsd_addr; in qla24xx_walk_and_build_prot_sglist()
1315 avail_dsds--; in qla24xx_walk_and_build_prot_sglist()
1319 cur_dsd->address = 0; in qla24xx_walk_and_build_prot_sglist()
1320 cur_dsd->length = 0; in qla24xx_walk_and_build_prot_sglist()
1326 * qla24xx_build_scsi_crc_2_iocbs() - Build IOCB command utilizing Command
1342 struct scsi_cmnd *cmd; in qla24xx_build_scsi_crc_2_iocbs() local
1355 cmd = GET_CMD_SP(sp); in qla24xx_build_scsi_crc_2_iocbs()
1358 put_unaligned_le32(COMMAND_TYPE_CRC_2, &cmd_pkt->entry_type); in qla24xx_build_scsi_crc_2_iocbs()
1360 vha = sp->vha; in qla24xx_build_scsi_crc_2_iocbs()
1361 ha = vha->hw; in qla24xx_build_scsi_crc_2_iocbs()
1364 data_bytes = scsi_bufflen(cmd); in qla24xx_build_scsi_crc_2_iocbs()
1365 if (!data_bytes || cmd->sc_data_direction == DMA_NONE) { in qla24xx_build_scsi_crc_2_iocbs()
1366 cmd_pkt->byte_count = cpu_to_le32(0); in qla24xx_build_scsi_crc_2_iocbs()
1370 cmd_pkt->vp_index = sp->vha->vp_idx; in qla24xx_build_scsi_crc_2_iocbs()
1373 if (cmd->sc_data_direction == DMA_TO_DEVICE) { in qla24xx_build_scsi_crc_2_iocbs()
1374 cmd_pkt->control_flags = in qla24xx_build_scsi_crc_2_iocbs()
1376 } else if (cmd->sc_data_direction == DMA_FROM_DEVICE) { in qla24xx_build_scsi_crc_2_iocbs()
1377 cmd_pkt->control_flags = in qla24xx_build_scsi_crc_2_iocbs()
1381 if ((scsi_get_prot_op(cmd) == SCSI_PROT_READ_INSERT) || in qla24xx_build_scsi_crc_2_iocbs()
1382 (scsi_get_prot_op(cmd) == SCSI_PROT_WRITE_STRIP) || in qla24xx_build_scsi_crc_2_iocbs()
1383 (scsi_get_prot_op(cmd) == SCSI_PROT_READ_STRIP) || in qla24xx_build_scsi_crc_2_iocbs()
1384 (scsi_get_prot_op(cmd) == SCSI_PROT_WRITE_INSERT)) in qla24xx_build_scsi_crc_2_iocbs()
1388 crc_ctx_pkt = sp->u.scmd.crc_ctx = in qla24xx_build_scsi_crc_2_iocbs()
1389 dma_pool_zalloc(ha->dl_dma_pool, GFP_ATOMIC, &crc_ctx_dma); in qla24xx_build_scsi_crc_2_iocbs()
1394 crc_ctx_pkt->crc_ctx_dma = crc_ctx_dma; in qla24xx_build_scsi_crc_2_iocbs()
1396 sp->flags |= SRB_CRC_CTX_DMA_VALID; in qla24xx_build_scsi_crc_2_iocbs()
1399 crc_ctx_pkt->handle = cmd_pkt->handle; in qla24xx_build_scsi_crc_2_iocbs()
1401 INIT_LIST_HEAD(&crc_ctx_pkt->dsd_list); in qla24xx_build_scsi_crc_2_iocbs()
1404 &crc_ctx_pkt->ref_tag, tot_prot_dsds); in qla24xx_build_scsi_crc_2_iocbs()
1406 put_unaligned_le64(crc_ctx_dma, &cmd_pkt->crc_context_address); in qla24xx_build_scsi_crc_2_iocbs()
1407 cmd_pkt->crc_context_len = cpu_to_le16(CRC_CONTEXT_LEN_FW); in qla24xx_build_scsi_crc_2_iocbs()
1409 /* Determine SCSI command length -- align to 4 byte boundary */ in qla24xx_build_scsi_crc_2_iocbs()
1410 if (cmd->cmd_len > 16) { in qla24xx_build_scsi_crc_2_iocbs()
1411 additional_fcpcdb_len = cmd->cmd_len - 16; in qla24xx_build_scsi_crc_2_iocbs()
1412 if ((cmd->cmd_len % 4) != 0) { in qla24xx_build_scsi_crc_2_iocbs()
1413 /* SCSI cmd > 16 bytes must be multiple of 4 */ in qla24xx_build_scsi_crc_2_iocbs()
1416 fcp_cmnd_len = 12 + cmd->cmd_len + 4; in qla24xx_build_scsi_crc_2_iocbs()
1422 fcp_cmnd = &crc_ctx_pkt->fcp_cmnd; in qla24xx_build_scsi_crc_2_iocbs()
1424 fcp_cmnd->additional_cdb_len = additional_fcpcdb_len; in qla24xx_build_scsi_crc_2_iocbs()
1425 if (cmd->sc_data_direction == DMA_TO_DEVICE) in qla24xx_build_scsi_crc_2_iocbs()
1426 fcp_cmnd->additional_cdb_len |= 1; in qla24xx_build_scsi_crc_2_iocbs()
1427 else if (cmd->sc_data_direction == DMA_FROM_DEVICE) in qla24xx_build_scsi_crc_2_iocbs()
1428 fcp_cmnd->additional_cdb_len |= 2; in qla24xx_build_scsi_crc_2_iocbs()
1430 int_to_scsilun(cmd->device->lun, &fcp_cmnd->lun); in qla24xx_build_scsi_crc_2_iocbs()
1431 memcpy(fcp_cmnd->cdb, cmd->cmnd, cmd->cmd_len); in qla24xx_build_scsi_crc_2_iocbs()
1432 cmd_pkt->fcp_cmnd_dseg_len = cpu_to_le16(fcp_cmnd_len); in qla24xx_build_scsi_crc_2_iocbs()
1434 &cmd_pkt->fcp_cmnd_dseg_address); in qla24xx_build_scsi_crc_2_iocbs()
1435 fcp_cmnd->task_management = 0; in qla24xx_build_scsi_crc_2_iocbs()
1436 fcp_cmnd->task_attribute = TSK_SIMPLE; in qla24xx_build_scsi_crc_2_iocbs()
1438 cmd_pkt->fcp_rsp_dseg_len = 0; /* Let response come in status iocb */ in qla24xx_build_scsi_crc_2_iocbs()
1442 blk_size = cmd->device->sector_size; in qla24xx_build_scsi_crc_2_iocbs()
1476 cur_dsd = &crc_ctx_pkt->u.nobundling.data_dsd[0]; in qla24xx_build_scsi_crc_2_iocbs()
1483 crc_ctx_pkt->u.bundling.dif_byte_count = cpu_to_le32(dif_bytes); in qla24xx_build_scsi_crc_2_iocbs()
1484 crc_ctx_pkt->u.bundling.dseg_count = cpu_to_le16(tot_dsds - in qla24xx_build_scsi_crc_2_iocbs()
1486 cur_dsd = &crc_ctx_pkt->u.bundling.data_dsd[0]; in qla24xx_build_scsi_crc_2_iocbs()
1490 crc_ctx_pkt->blk_size = cpu_to_le16(blk_size); in qla24xx_build_scsi_crc_2_iocbs()
1491 crc_ctx_pkt->prot_opts = cpu_to_le16(fw_prot_opts); in qla24xx_build_scsi_crc_2_iocbs()
1492 crc_ctx_pkt->byte_count = cpu_to_le32(data_bytes); in qla24xx_build_scsi_crc_2_iocbs()
1493 crc_ctx_pkt->guard_seed = cpu_to_le16(0); in qla24xx_build_scsi_crc_2_iocbs()
1495 cmd_pkt->byte_count = cpu_to_le32(total_bytes); in qla24xx_build_scsi_crc_2_iocbs()
1496 fcp_dl = (__be32 *)(crc_ctx_pkt->fcp_cmnd.cdb + 16 + in qla24xx_build_scsi_crc_2_iocbs()
1500 if (!data_bytes || cmd->sc_data_direction == DMA_NONE) { in qla24xx_build_scsi_crc_2_iocbs()
1501 cmd_pkt->byte_count = cpu_to_le32(0); in qla24xx_build_scsi_crc_2_iocbs()
1506 cmd_pkt->control_flags |= cpu_to_le16(CF_DATA_SEG_DESCR_ENABLE); in qla24xx_build_scsi_crc_2_iocbs()
1513 (tot_dsds - tot_prot_dsds), NULL)) in qla24xx_build_scsi_crc_2_iocbs()
1518 cmd_pkt->control_flags |= cpu_to_le16(CF_DIF_SEG_DESCR_ENABLE); in qla24xx_build_scsi_crc_2_iocbs()
1519 cur_dsd = &crc_ctx_pkt->u.bundling.dif_dsd; in qla24xx_build_scsi_crc_2_iocbs()
1533 * qla24xx_start_scsi() - Send a SCSI command to the ISP
1536 * Returns non-zero if a failure occurred, else zero.
1546 uint16_t cnt; in qla24xx_start_scsi() local
1551 struct scsi_cmnd *cmd = GET_CMD_SP(sp); in qla24xx_start_scsi() local
1552 struct scsi_qla_host *vha = sp->vha; in qla24xx_start_scsi()
1553 struct qla_hw_data *ha = vha->hw; in qla24xx_start_scsi()
1555 if (sp->fcport->edif.enable && (sp->fcport->flags & FCF_FCSP_DEVICE)) in qla24xx_start_scsi()
1559 req = vha->req; in qla24xx_start_scsi()
1560 rsp = req->rsp; in qla24xx_start_scsi()
1566 if (vha->marker_needed != 0) { in qla24xx_start_scsi()
1567 if (qla2x00_marker(vha, ha->base_qpair, 0, 0, MK_SYNC_ALL) != in qla24xx_start_scsi()
1570 vha->marker_needed = 0; in qla24xx_start_scsi()
1574 spin_lock_irqsave(&ha->hardware_lock, flags); in qla24xx_start_scsi()
1581 if (scsi_sg_count(cmd)) { in qla24xx_start_scsi()
1582 nseg = dma_map_sg(&ha->pdev->dev, scsi_sglist(cmd), in qla24xx_start_scsi()
1583 scsi_sg_count(cmd), cmd->sc_data_direction); in qla24xx_start_scsi()
1592 sp->iores.res_type = RESOURCE_IOCB | RESOURCE_EXCH; in qla24xx_start_scsi()
1593 sp->iores.exch_cnt = 1; in qla24xx_start_scsi()
1594 sp->iores.iocb_cnt = req_cnt; in qla24xx_start_scsi()
1595 if (qla_get_fw_resources(sp->qpair, &sp->iores)) in qla24xx_start_scsi()
1598 if (req->cnt < (req_cnt + 2)) { in qla24xx_start_scsi()
1600 cnt = *req->out_ptr; in qla24xx_start_scsi()
1602 cnt = rd_reg_dword_relaxed(req->req_q_out); in qla24xx_start_scsi()
1603 if (qla2x00_check_reg16_for_disconnect(vha, cnt)) in qla24xx_start_scsi()
1607 if (req->ring_index < cnt) in qla24xx_start_scsi()
1608 req->cnt = cnt - req->ring_index; in qla24xx_start_scsi()
1610 req->cnt = req->length - in qla24xx_start_scsi()
1611 (req->ring_index - cnt); in qla24xx_start_scsi()
1612 if (req->cnt < (req_cnt + 2)) in qla24xx_start_scsi()
1617 req->current_outstanding_cmd = handle; in qla24xx_start_scsi()
1618 req->outstanding_cmds[handle] = sp; in qla24xx_start_scsi()
1619 sp->handle = handle; in qla24xx_start_scsi()
1620 cmd->host_scribble = (unsigned char *)(unsigned long)handle; in qla24xx_start_scsi()
1621 req->cnt -= req_cnt; in qla24xx_start_scsi()
1623 cmd_pkt = (struct cmd_type_7 *)req->ring_ptr; in qla24xx_start_scsi()
1624 cmd_pkt->handle = make_handle(req->id, handle); in qla24xx_start_scsi()
1627 /* tagged queuing modifier -- default is TSK_SIMPLE (0). */ in qla24xx_start_scsi()
1629 memset(clr_ptr, 0, REQUEST_ENTRY_SIZE - 8); in qla24xx_start_scsi()
1630 cmd_pkt->dseg_count = cpu_to_le16(tot_dsds); in qla24xx_start_scsi()
1632 /* Set NPORT-ID and LUN number*/ in qla24xx_start_scsi()
1633 cmd_pkt->nport_handle = cpu_to_le16(sp->fcport->loop_id); in qla24xx_start_scsi()
1634 cmd_pkt->port_id[0] = sp->fcport->d_id.b.al_pa; in qla24xx_start_scsi()
1635 cmd_pkt->port_id[1] = sp->fcport->d_id.b.area; in qla24xx_start_scsi()
1636 cmd_pkt->port_id[2] = sp->fcport->d_id.b.domain; in qla24xx_start_scsi()
1637 cmd_pkt->vp_index = sp->vha->vp_idx; in qla24xx_start_scsi()
1639 int_to_scsilun(cmd->device->lun, &cmd_pkt->lun); in qla24xx_start_scsi()
1640 host_to_fcp_swap((uint8_t *)&cmd_pkt->lun, sizeof(cmd_pkt->lun)); in qla24xx_start_scsi()
1642 cmd_pkt->task = TSK_SIMPLE; in qla24xx_start_scsi()
1645 memcpy(cmd_pkt->fcp_cdb, cmd->cmnd, cmd->cmd_len); in qla24xx_start_scsi()
1646 host_to_fcp_swap(cmd_pkt->fcp_cdb, sizeof(cmd_pkt->fcp_cdb)); in qla24xx_start_scsi()
1648 cmd_pkt->byte_count = cpu_to_le32((uint32_t)scsi_bufflen(cmd)); in qla24xx_start_scsi()
1654 cmd_pkt->entry_count = (uint8_t)req_cnt; in qla24xx_start_scsi()
1657 req->ring_index++; in qla24xx_start_scsi()
1658 if (req->ring_index == req->length) { in qla24xx_start_scsi()
1659 req->ring_index = 0; in qla24xx_start_scsi()
1660 req->ring_ptr = req->ring; in qla24xx_start_scsi()
1662 req->ring_ptr++; in qla24xx_start_scsi()
1664 sp->qpair->cmd_cnt++; in qla24xx_start_scsi()
1665 sp->flags |= SRB_DMA_VALID; in qla24xx_start_scsi()
1668 wrt_reg_dword(req->req_q_in, req->ring_index); in qla24xx_start_scsi()
1671 if (vha->flags.process_response_queue && in qla24xx_start_scsi()
1672 rsp->ring_ptr->signature != RESPONSE_PROCESSED) in qla24xx_start_scsi()
1675 spin_unlock_irqrestore(&ha->hardware_lock, flags); in qla24xx_start_scsi()
1680 scsi_dma_unmap(cmd); in qla24xx_start_scsi()
1682 qla_put_fw_resources(sp->qpair, &sp->iores); in qla24xx_start_scsi()
1683 spin_unlock_irqrestore(&ha->hardware_lock, flags); in qla24xx_start_scsi()
1689 * qla24xx_dif_start_scsi() - Send a SCSI command to the ISP
1692 * Returns non-zero if a failure occurred, else zero.
1701 uint16_t cnt; in qla24xx_dif_start_scsi() local
1708 struct scsi_cmnd *cmd = GET_CMD_SP(sp); in qla24xx_dif_start_scsi() local
1709 struct scsi_qla_host *vha = sp->vha; in qla24xx_dif_start_scsi()
1710 struct qla_hw_data *ha = vha->hw; in qla24xx_dif_start_scsi()
1717 if (scsi_get_prot_op(cmd) == SCSI_PROT_NORMAL) { in qla24xx_dif_start_scsi()
1718 if (cmd->cmd_len <= 16) in qla24xx_dif_start_scsi()
1725 req = vha->req; in qla24xx_dif_start_scsi()
1726 rsp = req->rsp; in qla24xx_dif_start_scsi()
1732 if (vha->marker_needed != 0) { in qla24xx_dif_start_scsi()
1733 if (qla2x00_marker(vha, ha->base_qpair, 0, 0, MK_SYNC_ALL) != in qla24xx_dif_start_scsi()
1736 vha->marker_needed = 0; in qla24xx_dif_start_scsi()
1740 spin_lock_irqsave(&ha->hardware_lock, flags); in qla24xx_dif_start_scsi()
1748 if (scsi_sg_count(cmd)) { in qla24xx_dif_start_scsi()
1749 nseg = dma_map_sg(&ha->pdev->dev, scsi_sglist(cmd), in qla24xx_dif_start_scsi()
1750 scsi_sg_count(cmd), cmd->sc_data_direction); in qla24xx_dif_start_scsi()
1754 sp->flags |= SRB_DMA_VALID; in qla24xx_dif_start_scsi()
1756 if ((scsi_get_prot_op(cmd) == SCSI_PROT_READ_INSERT) || in qla24xx_dif_start_scsi()
1757 (scsi_get_prot_op(cmd) == SCSI_PROT_WRITE_STRIP)) { in qla24xx_dif_start_scsi()
1762 sgx.tot_bytes = scsi_bufflen(cmd); in qla24xx_dif_start_scsi()
1763 sgx.cur_sg = scsi_sglist(cmd); in qla24xx_dif_start_scsi()
1768 cmd->device->sector_size, &sgx, &partial)) in qla24xx_dif_start_scsi()
1779 nseg = dma_map_sg(&ha->pdev->dev, scsi_prot_sglist(cmd), in qla24xx_dif_start_scsi()
1780 scsi_prot_sg_count(cmd), cmd->sc_data_direction); in qla24xx_dif_start_scsi()
1784 sp->flags |= SRB_CRC_PROT_DMA_VALID; in qla24xx_dif_start_scsi()
1786 if ((scsi_get_prot_op(cmd) == SCSI_PROT_READ_INSERT) || in qla24xx_dif_start_scsi()
1787 (scsi_get_prot_op(cmd) == SCSI_PROT_WRITE_STRIP)) { in qla24xx_dif_start_scsi()
1788 nseg = scsi_bufflen(cmd) / cmd->device->sector_size; in qla24xx_dif_start_scsi()
1799 sp->iores.res_type = RESOURCE_IOCB | RESOURCE_EXCH; in qla24xx_dif_start_scsi()
1800 sp->iores.exch_cnt = 1; in qla24xx_dif_start_scsi()
1801 sp->iores.iocb_cnt = qla24xx_calc_iocbs(vha, tot_dsds); in qla24xx_dif_start_scsi()
1802 if (qla_get_fw_resources(sp->qpair, &sp->iores)) in qla24xx_dif_start_scsi()
1805 if (req->cnt < (req_cnt + 2)) { in qla24xx_dif_start_scsi()
1807 cnt = *req->out_ptr; in qla24xx_dif_start_scsi()
1809 cnt = rd_reg_dword_relaxed(req->req_q_out); in qla24xx_dif_start_scsi()
1810 if (qla2x00_check_reg16_for_disconnect(vha, cnt)) in qla24xx_dif_start_scsi()
1813 if (req->ring_index < cnt) in qla24xx_dif_start_scsi()
1814 req->cnt = cnt - req->ring_index; in qla24xx_dif_start_scsi()
1816 req->cnt = req->length - in qla24xx_dif_start_scsi()
1817 (req->ring_index - cnt); in qla24xx_dif_start_scsi()
1818 if (req->cnt < (req_cnt + 2)) in qla24xx_dif_start_scsi()
1825 req->current_outstanding_cmd = handle; in qla24xx_dif_start_scsi()
1826 req->outstanding_cmds[handle] = sp; in qla24xx_dif_start_scsi()
1827 sp->handle = handle; in qla24xx_dif_start_scsi()
1828 cmd->host_scribble = (unsigned char *)(unsigned long)handle; in qla24xx_dif_start_scsi()
1829 req->cnt -= req_cnt; in qla24xx_dif_start_scsi()
1831 /* Fill-in common area */ in qla24xx_dif_start_scsi()
1832 cmd_pkt = (struct cmd_type_crc_2 *)req->ring_ptr; in qla24xx_dif_start_scsi()
1833 cmd_pkt->handle = make_handle(req->id, handle); in qla24xx_dif_start_scsi()
1836 memset(clr_ptr, 0, REQUEST_ENTRY_SIZE - 8); in qla24xx_dif_start_scsi()
1838 /* Set NPORT-ID and LUN number*/ in qla24xx_dif_start_scsi()
1839 cmd_pkt->nport_handle = cpu_to_le16(sp->fcport->loop_id); in qla24xx_dif_start_scsi()
1840 cmd_pkt->port_id[0] = sp->fcport->d_id.b.al_pa; in qla24xx_dif_start_scsi()
1841 cmd_pkt->port_id[1] = sp->fcport->d_id.b.area; in qla24xx_dif_start_scsi()
1842 cmd_pkt->port_id[2] = sp->fcport->d_id.b.domain; in qla24xx_dif_start_scsi()
1844 int_to_scsilun(cmd->device->lun, &cmd_pkt->lun); in qla24xx_dif_start_scsi()
1845 host_to_fcp_swap((uint8_t *)&cmd_pkt->lun, sizeof(cmd_pkt->lun)); in qla24xx_dif_start_scsi()
1848 cmd_pkt->dseg_count = cpu_to_le16(tot_dsds); in qla24xx_dif_start_scsi()
1852 req->ring_ptr, tot_dsds, tot_prot_dsds, fw_prot_opts) != in qla24xx_dif_start_scsi()
1856 cmd_pkt->entry_count = (uint8_t)req_cnt; in qla24xx_dif_start_scsi()
1858 cmd_pkt->entry_status = (uint8_t) rsp->id; in qla24xx_dif_start_scsi()
1859 cmd_pkt->timeout = cpu_to_le16(0); in qla24xx_dif_start_scsi()
1863 req->ring_index++; in qla24xx_dif_start_scsi()
1864 if (req->ring_index == req->length) { in qla24xx_dif_start_scsi()
1865 req->ring_index = 0; in qla24xx_dif_start_scsi()
1866 req->ring_ptr = req->ring; in qla24xx_dif_start_scsi()
1868 req->ring_ptr++; in qla24xx_dif_start_scsi()
1870 sp->qpair->cmd_cnt++; in qla24xx_dif_start_scsi()
1872 wrt_reg_dword(req->req_q_in, req->ring_index); in qla24xx_dif_start_scsi()
1875 if (vha->flags.process_response_queue && in qla24xx_dif_start_scsi()
1876 rsp->ring_ptr->signature != RESPONSE_PROCESSED) in qla24xx_dif_start_scsi()
1879 spin_unlock_irqrestore(&ha->hardware_lock, flags); in qla24xx_dif_start_scsi()
1885 req->outstanding_cmds[handle] = NULL; in qla24xx_dif_start_scsi()
1886 req->cnt += req_cnt; in qla24xx_dif_start_scsi()
1890 qla_put_fw_resources(sp->qpair, &sp->iores); in qla24xx_dif_start_scsi()
1891 spin_unlock_irqrestore(&ha->hardware_lock, flags); in qla24xx_dif_start_scsi()
1897 * qla2xxx_start_scsi_mq() - Send a SCSI command to the ISP
1900 * Returns non-zero if a failure occurred, else zero.
1910 uint16_t cnt; in qla2xxx_start_scsi_mq() local
1915 struct scsi_cmnd *cmd = GET_CMD_SP(sp); in qla2xxx_start_scsi_mq() local
1916 struct scsi_qla_host *vha = sp->fcport->vha; in qla2xxx_start_scsi_mq()
1917 struct qla_hw_data *ha = vha->hw; in qla2xxx_start_scsi_mq()
1918 struct qla_qpair *qpair = sp->qpair; in qla2xxx_start_scsi_mq()
1920 if (sp->fcport->edif.enable && (sp->fcport->flags & FCF_FCSP_DEVICE)) in qla2xxx_start_scsi_mq()
1924 spin_lock_irqsave(&qpair->qp_lock, flags); in qla2xxx_start_scsi_mq()
1927 req = qpair->req; in qla2xxx_start_scsi_mq()
1928 rsp = qpair->rsp; in qla2xxx_start_scsi_mq()
1934 if (vha->marker_needed != 0) { in qla2xxx_start_scsi_mq()
1937 spin_unlock_irqrestore(&qpair->qp_lock, flags); in qla2xxx_start_scsi_mq()
1940 vha->marker_needed = 0; in qla2xxx_start_scsi_mq()
1948 if (scsi_sg_count(cmd)) { in qla2xxx_start_scsi_mq()
1949 nseg = dma_map_sg(&ha->pdev->dev, scsi_sglist(cmd), in qla2xxx_start_scsi_mq()
1950 scsi_sg_count(cmd), cmd->sc_data_direction); in qla2xxx_start_scsi_mq()
1959 sp->iores.res_type = RESOURCE_IOCB | RESOURCE_EXCH; in qla2xxx_start_scsi_mq()
1960 sp->iores.exch_cnt = 1; in qla2xxx_start_scsi_mq()
1961 sp->iores.iocb_cnt = req_cnt; in qla2xxx_start_scsi_mq()
1962 if (qla_get_fw_resources(sp->qpair, &sp->iores)) in qla2xxx_start_scsi_mq()
1965 if (req->cnt < (req_cnt + 2)) { in qla2xxx_start_scsi_mq()
1967 cnt = *req->out_ptr; in qla2xxx_start_scsi_mq()
1969 cnt = rd_reg_dword_relaxed(req->req_q_out); in qla2xxx_start_scsi_mq()
1970 if (qla2x00_check_reg16_for_disconnect(vha, cnt)) in qla2xxx_start_scsi_mq()
1974 if (req->ring_index < cnt) in qla2xxx_start_scsi_mq()
1975 req->cnt = cnt - req->ring_index; in qla2xxx_start_scsi_mq()
1977 req->cnt = req->length - in qla2xxx_start_scsi_mq()
1978 (req->ring_index - cnt); in qla2xxx_start_scsi_mq()
1979 if (req->cnt < (req_cnt + 2)) in qla2xxx_start_scsi_mq()
1984 req->current_outstanding_cmd = handle; in qla2xxx_start_scsi_mq()
1985 req->outstanding_cmds[handle] = sp; in qla2xxx_start_scsi_mq()
1986 sp->handle = handle; in qla2xxx_start_scsi_mq()
1987 cmd->host_scribble = (unsigned char *)(unsigned long)handle; in qla2xxx_start_scsi_mq()
1988 req->cnt -= req_cnt; in qla2xxx_start_scsi_mq()
1990 cmd_pkt = (struct cmd_type_7 *)req->ring_ptr; in qla2xxx_start_scsi_mq()
1991 cmd_pkt->handle = make_handle(req->id, handle); in qla2xxx_start_scsi_mq()
1994 /* tagged queuing modifier -- default is TSK_SIMPLE (0). */ in qla2xxx_start_scsi_mq()
1996 memset(clr_ptr, 0, REQUEST_ENTRY_SIZE - 8); in qla2xxx_start_scsi_mq()
1997 cmd_pkt->dseg_count = cpu_to_le16(tot_dsds); in qla2xxx_start_scsi_mq()
1999 /* Set NPORT-ID and LUN number*/ in qla2xxx_start_scsi_mq()
2000 cmd_pkt->nport_handle = cpu_to_le16(sp->fcport->loop_id); in qla2xxx_start_scsi_mq()
2001 cmd_pkt->port_id[0] = sp->fcport->d_id.b.al_pa; in qla2xxx_start_scsi_mq()
2002 cmd_pkt->port_id[1] = sp->fcport->d_id.b.area; in qla2xxx_start_scsi_mq()
2003 cmd_pkt->port_id[2] = sp->fcport->d_id.b.domain; in qla2xxx_start_scsi_mq()
2004 cmd_pkt->vp_index = sp->fcport->vha->vp_idx; in qla2xxx_start_scsi_mq()
2006 int_to_scsilun(cmd->device->lun, &cmd_pkt->lun); in qla2xxx_start_scsi_mq()
2007 host_to_fcp_swap((uint8_t *)&cmd_pkt->lun, sizeof(cmd_pkt->lun)); in qla2xxx_start_scsi_mq()
2009 cmd_pkt->task = TSK_SIMPLE; in qla2xxx_start_scsi_mq()
2012 memcpy(cmd_pkt->fcp_cdb, cmd->cmnd, cmd->cmd_len); in qla2xxx_start_scsi_mq()
2013 host_to_fcp_swap(cmd_pkt->fcp_cdb, sizeof(cmd_pkt->fcp_cdb)); in qla2xxx_start_scsi_mq()
2015 cmd_pkt->byte_count = cpu_to_le32((uint32_t)scsi_bufflen(cmd)); in qla2xxx_start_scsi_mq()
2021 cmd_pkt->entry_count = (uint8_t)req_cnt; in qla2xxx_start_scsi_mq()
2024 req->ring_index++; in qla2xxx_start_scsi_mq()
2025 if (req->ring_index == req->length) { in qla2xxx_start_scsi_mq()
2026 req->ring_index = 0; in qla2xxx_start_scsi_mq()
2027 req->ring_ptr = req->ring; in qla2xxx_start_scsi_mq()
2029 req->ring_ptr++; in qla2xxx_start_scsi_mq()
2031 sp->qpair->cmd_cnt++; in qla2xxx_start_scsi_mq()
2032 sp->flags |= SRB_DMA_VALID; in qla2xxx_start_scsi_mq()
2035 wrt_reg_dword(req->req_q_in, req->ring_index); in qla2xxx_start_scsi_mq()
2038 if (vha->flags.process_response_queue && in qla2xxx_start_scsi_mq()
2039 rsp->ring_ptr->signature != RESPONSE_PROCESSED) in qla2xxx_start_scsi_mq()
2042 spin_unlock_irqrestore(&qpair->qp_lock, flags); in qla2xxx_start_scsi_mq()
2047 scsi_dma_unmap(cmd); in qla2xxx_start_scsi_mq()
2049 qla_put_fw_resources(sp->qpair, &sp->iores); in qla2xxx_start_scsi_mq()
2050 spin_unlock_irqrestore(&qpair->qp_lock, flags); in qla2xxx_start_scsi_mq()
2057 * qla2xxx_dif_start_scsi_mq() - Send a SCSI command to the ISP
2060 * Returns non-zero if a failure occurred, else zero.
2069 uint16_t cnt; in qla2xxx_dif_start_scsi_mq() local
2076 struct scsi_cmnd *cmd = GET_CMD_SP(sp); in qla2xxx_dif_start_scsi_mq() local
2077 struct scsi_qla_host *vha = sp->fcport->vha; in qla2xxx_dif_start_scsi_mq()
2078 struct qla_hw_data *ha = vha->hw; in qla2xxx_dif_start_scsi_mq()
2081 struct qla_qpair *qpair = sp->qpair; in qla2xxx_dif_start_scsi_mq()
2086 if (!qpair->online) { in qla2xxx_dif_start_scsi_mq()
2087 cmd->result = DID_NO_CONNECT << 16; in qla2xxx_dif_start_scsi_mq()
2091 if (!qpair->difdix_supported && in qla2xxx_dif_start_scsi_mq()
2092 scsi_get_prot_op(cmd) != SCSI_PROT_NORMAL) { in qla2xxx_dif_start_scsi_mq()
2093 cmd->result = DID_NO_CONNECT << 16; in qla2xxx_dif_start_scsi_mq()
2098 if (scsi_get_prot_op(cmd) == SCSI_PROT_NORMAL) { in qla2xxx_dif_start_scsi_mq()
2099 if (cmd->cmd_len <= 16) in qla2xxx_dif_start_scsi_mq()
2105 spin_lock_irqsave(&qpair->qp_lock, flags); in qla2xxx_dif_start_scsi_mq()
2108 rsp = qpair->rsp; in qla2xxx_dif_start_scsi_mq()
2109 req = qpair->req; in qla2xxx_dif_start_scsi_mq()
2115 if (vha->marker_needed != 0) { in qla2xxx_dif_start_scsi_mq()
2118 spin_unlock_irqrestore(&qpair->qp_lock, flags); in qla2xxx_dif_start_scsi_mq()
2121 vha->marker_needed = 0; in qla2xxx_dif_start_scsi_mq()
2130 if (scsi_sg_count(cmd)) { in qla2xxx_dif_start_scsi_mq()
2131 nseg = dma_map_sg(&ha->pdev->dev, scsi_sglist(cmd), in qla2xxx_dif_start_scsi_mq()
2132 scsi_sg_count(cmd), cmd->sc_data_direction); in qla2xxx_dif_start_scsi_mq()
2136 sp->flags |= SRB_DMA_VALID; in qla2xxx_dif_start_scsi_mq()
2138 if ((scsi_get_prot_op(cmd) == SCSI_PROT_READ_INSERT) || in qla2xxx_dif_start_scsi_mq()
2139 (scsi_get_prot_op(cmd) == SCSI_PROT_WRITE_STRIP)) { in qla2xxx_dif_start_scsi_mq()
2144 sgx.tot_bytes = scsi_bufflen(cmd); in qla2xxx_dif_start_scsi_mq()
2145 sgx.cur_sg = scsi_sglist(cmd); in qla2xxx_dif_start_scsi_mq()
2150 cmd->device->sector_size, &sgx, &partial)) in qla2xxx_dif_start_scsi_mq()
2161 nseg = dma_map_sg(&ha->pdev->dev, scsi_prot_sglist(cmd), in qla2xxx_dif_start_scsi_mq()
2162 scsi_prot_sg_count(cmd), cmd->sc_data_direction); in qla2xxx_dif_start_scsi_mq()
2166 sp->flags |= SRB_CRC_PROT_DMA_VALID; in qla2xxx_dif_start_scsi_mq()
2168 if ((scsi_get_prot_op(cmd) == SCSI_PROT_READ_INSERT) || in qla2xxx_dif_start_scsi_mq()
2169 (scsi_get_prot_op(cmd) == SCSI_PROT_WRITE_STRIP)) { in qla2xxx_dif_start_scsi_mq()
2170 nseg = scsi_bufflen(cmd) / cmd->device->sector_size; in qla2xxx_dif_start_scsi_mq()
2181 sp->iores.res_type = RESOURCE_IOCB | RESOURCE_EXCH; in qla2xxx_dif_start_scsi_mq()
2182 sp->iores.exch_cnt = 1; in qla2xxx_dif_start_scsi_mq()
2183 sp->iores.iocb_cnt = qla24xx_calc_iocbs(vha, tot_dsds); in qla2xxx_dif_start_scsi_mq()
2184 if (qla_get_fw_resources(sp->qpair, &sp->iores)) in qla2xxx_dif_start_scsi_mq()
2187 if (req->cnt < (req_cnt + 2)) { in qla2xxx_dif_start_scsi_mq()
2189 cnt = *req->out_ptr; in qla2xxx_dif_start_scsi_mq()
2191 cnt = rd_reg_dword_relaxed(req->req_q_out); in qla2xxx_dif_start_scsi_mq()
2192 if (qla2x00_check_reg16_for_disconnect(vha, cnt)) in qla2xxx_dif_start_scsi_mq()
2196 if (req->ring_index < cnt) in qla2xxx_dif_start_scsi_mq()
2197 req->cnt = cnt - req->ring_index; in qla2xxx_dif_start_scsi_mq()
2199 req->cnt = req->length - in qla2xxx_dif_start_scsi_mq()
2200 (req->ring_index - cnt); in qla2xxx_dif_start_scsi_mq()
2201 if (req->cnt < (req_cnt + 2)) in qla2xxx_dif_start_scsi_mq()
2208 req->current_outstanding_cmd = handle; in qla2xxx_dif_start_scsi_mq()
2209 req->outstanding_cmds[handle] = sp; in qla2xxx_dif_start_scsi_mq()
2210 sp->handle = handle; in qla2xxx_dif_start_scsi_mq()
2211 cmd->host_scribble = (unsigned char *)(unsigned long)handle; in qla2xxx_dif_start_scsi_mq()
2212 req->cnt -= req_cnt; in qla2xxx_dif_start_scsi_mq()
2214 /* Fill-in common area */ in qla2xxx_dif_start_scsi_mq()
2215 cmd_pkt = (struct cmd_type_crc_2 *)req->ring_ptr; in qla2xxx_dif_start_scsi_mq()
2216 cmd_pkt->handle = make_handle(req->id, handle); in qla2xxx_dif_start_scsi_mq()
2219 memset(clr_ptr, 0, REQUEST_ENTRY_SIZE - 8); in qla2xxx_dif_start_scsi_mq()
2221 /* Set NPORT-ID and LUN number*/ in qla2xxx_dif_start_scsi_mq()
2222 cmd_pkt->nport_handle = cpu_to_le16(sp->fcport->loop_id); in qla2xxx_dif_start_scsi_mq()
2223 cmd_pkt->port_id[0] = sp->fcport->d_id.b.al_pa; in qla2xxx_dif_start_scsi_mq()
2224 cmd_pkt->port_id[1] = sp->fcport->d_id.b.area; in qla2xxx_dif_start_scsi_mq()
2225 cmd_pkt->port_id[2] = sp->fcport->d_id.b.domain; in qla2xxx_dif_start_scsi_mq()
2227 int_to_scsilun(cmd->device->lun, &cmd_pkt->lun); in qla2xxx_dif_start_scsi_mq()
2228 host_to_fcp_swap((uint8_t *)&cmd_pkt->lun, sizeof(cmd_pkt->lun)); in qla2xxx_dif_start_scsi_mq()
2231 cmd_pkt->dseg_count = cpu_to_le16(tot_dsds); in qla2xxx_dif_start_scsi_mq()
2235 req->ring_ptr, tot_dsds, tot_prot_dsds, fw_prot_opts) != in qla2xxx_dif_start_scsi_mq()
2239 cmd_pkt->entry_count = (uint8_t)req_cnt; in qla2xxx_dif_start_scsi_mq()
2240 cmd_pkt->timeout = cpu_to_le16(0); in qla2xxx_dif_start_scsi_mq()
2244 req->ring_index++; in qla2xxx_dif_start_scsi_mq()
2245 if (req->ring_index == req->length) { in qla2xxx_dif_start_scsi_mq()
2246 req->ring_index = 0; in qla2xxx_dif_start_scsi_mq()
2247 req->ring_ptr = req->ring; in qla2xxx_dif_start_scsi_mq()
2249 req->ring_ptr++; in qla2xxx_dif_start_scsi_mq()
2251 sp->qpair->cmd_cnt++; in qla2xxx_dif_start_scsi_mq()
2253 wrt_reg_dword(req->req_q_in, req->ring_index); in qla2xxx_dif_start_scsi_mq()
2256 if (vha->flags.process_response_queue && in qla2xxx_dif_start_scsi_mq()
2257 rsp->ring_ptr->signature != RESPONSE_PROCESSED) in qla2xxx_dif_start_scsi_mq()
2260 spin_unlock_irqrestore(&qpair->qp_lock, flags); in qla2xxx_dif_start_scsi_mq()
2266 req->outstanding_cmds[handle] = NULL; in qla2xxx_dif_start_scsi_mq()
2267 req->cnt += req_cnt; in qla2xxx_dif_start_scsi_mq()
2271 qla_put_fw_resources(sp->qpair, &sp->iores); in qla2xxx_dif_start_scsi_mq()
2272 spin_unlock_irqrestore(&qpair->qp_lock, flags); in qla2xxx_dif_start_scsi_mq()
2277 /* Generic Control-SRB manipulation functions. */
2284 scsi_qla_host_t *vha = qpair->vha; in __qla2x00_alloc_iocbs()
2285 struct qla_hw_data *ha = vha->hw; in __qla2x00_alloc_iocbs()
2286 struct req_que *req = qpair->req; in __qla2x00_alloc_iocbs()
2287 device_reg_t *reg = ISP_QUE_REG(ha, req->id); in __qla2x00_alloc_iocbs()
2290 uint16_t cnt, req_cnt; in __qla2x00_alloc_iocbs() local
2296 if (sp && (sp->type != SRB_SCSI_CMD)) { in __qla2x00_alloc_iocbs()
2297 /* Adjust entry-counts as needed. */ in __qla2x00_alloc_iocbs()
2298 req_cnt = sp->iocbs; in __qla2x00_alloc_iocbs()
2302 if (req->cnt < req_cnt + 2) { in __qla2x00_alloc_iocbs()
2303 if (qpair->use_shadow_reg) in __qla2x00_alloc_iocbs()
2304 cnt = *req->out_ptr; in __qla2x00_alloc_iocbs()
2305 else if (ha->mqenable || IS_QLA83XX(ha) || IS_QLA27XX(ha) || in __qla2x00_alloc_iocbs()
2307 cnt = rd_reg_dword(®->isp25mq.req_q_out); in __qla2x00_alloc_iocbs()
2309 cnt = rd_reg_dword(reg->isp82.req_q_out); in __qla2x00_alloc_iocbs()
2311 cnt = rd_reg_dword(®->isp24.req_q_out); in __qla2x00_alloc_iocbs()
2313 cnt = rd_reg_dword(®->ispfx00.req_q_out); in __qla2x00_alloc_iocbs()
2315 cnt = qla2x00_debounce_register( in __qla2x00_alloc_iocbs()
2316 ISP_REQ_Q_OUT(ha, ®->isp)); in __qla2x00_alloc_iocbs()
2318 if (!qpair->use_shadow_reg && cnt == ISP_REG16_DISCONNECT) { in __qla2x00_alloc_iocbs()
2323 if (req->ring_index < cnt) in __qla2x00_alloc_iocbs()
2324 req->cnt = cnt - req->ring_index; in __qla2x00_alloc_iocbs()
2326 req->cnt = req->length - in __qla2x00_alloc_iocbs()
2327 (req->ring_index - cnt); in __qla2x00_alloc_iocbs()
2329 if (req->cnt < req_cnt + 2) in __qla2x00_alloc_iocbs()
2336 "No room on outstanding cmd array.\n"); in __qla2x00_alloc_iocbs()
2341 req->current_outstanding_cmd = handle; in __qla2x00_alloc_iocbs()
2342 req->outstanding_cmds[handle] = sp; in __qla2x00_alloc_iocbs()
2343 sp->handle = handle; in __qla2x00_alloc_iocbs()
2347 req->cnt -= req_cnt; in __qla2x00_alloc_iocbs()
2348 pkt = req->ring_ptr; in __qla2x00_alloc_iocbs()
2351 wrt_reg_byte((u8 __force __iomem *)&pkt->entry_count, req_cnt); in __qla2x00_alloc_iocbs()
2352 wrt_reg_dword((__le32 __force __iomem *)&pkt->handle, handle); in __qla2x00_alloc_iocbs()
2354 pkt->entry_count = req_cnt; in __qla2x00_alloc_iocbs()
2355 pkt->handle = handle; in __qla2x00_alloc_iocbs()
2361 qpair->tgt_counters.num_alloc_iocb_failed++; in __qla2x00_alloc_iocbs()
2368 scsi_qla_host_t *vha = qpair->vha; in qla2x00_alloc_iocbs_ready()
2379 return __qla2x00_alloc_iocbs(vha->hw->base_qpair, sp); in qla2x00_alloc_iocbs()
2385 struct srb_iocb *lio = &sp->u.iocb_cmd; in qla24xx_prli_iocb()
2387 logio->entry_type = LOGINOUT_PORT_IOCB_TYPE; in qla24xx_prli_iocb()
2388 logio->control_flags = cpu_to_le16(LCF_COMMAND_PRLI); in qla24xx_prli_iocb()
2389 if (lio->u.logio.flags & SRB_LOGIN_NVME_PRLI) { in qla24xx_prli_iocb()
2390 logio->control_flags |= cpu_to_le16(LCF_NVME_PRLI); in qla24xx_prli_iocb()
2391 if (sp->vha->flags.nvme_first_burst) in qla24xx_prli_iocb()
2392 logio->io_parameter[0] = in qla24xx_prli_iocb()
2394 if (sp->vha->flags.nvme2_enabled) { in qla24xx_prli_iocb()
2396 logio->io_parameter[0] |= in qla24xx_prli_iocb()
2399 logio->io_parameter[0] |= in qla24xx_prli_iocb()
2402 logio->io_parameter[0] |= in qla24xx_prli_iocb()
2407 logio->nport_handle = cpu_to_le16(sp->fcport->loop_id); in qla24xx_prli_iocb()
2408 logio->port_id[0] = sp->fcport->d_id.b.al_pa; in qla24xx_prli_iocb()
2409 logio->port_id[1] = sp->fcport->d_id.b.area; in qla24xx_prli_iocb()
2410 logio->port_id[2] = sp->fcport->d_id.b.domain; in qla24xx_prli_iocb()
2411 logio->vp_index = sp->vha->vp_idx; in qla24xx_prli_iocb()
2417 struct srb_iocb *lio = &sp->u.iocb_cmd; in qla24xx_login_iocb()
2419 logio->entry_type = LOGINOUT_PORT_IOCB_TYPE; in qla24xx_login_iocb()
2420 logio->control_flags = cpu_to_le16(LCF_COMMAND_PLOGI); in qla24xx_login_iocb()
2422 if (lio->u.logio.flags & SRB_LOGIN_PRLI_ONLY) { in qla24xx_login_iocb()
2423 logio->control_flags = cpu_to_le16(LCF_COMMAND_PRLI); in qla24xx_login_iocb()
2425 logio->control_flags = cpu_to_le16(LCF_COMMAND_PLOGI); in qla24xx_login_iocb()
2426 if (lio->u.logio.flags & SRB_LOGIN_COND_PLOGI) in qla24xx_login_iocb()
2427 logio->control_flags |= cpu_to_le16(LCF_COND_PLOGI); in qla24xx_login_iocb()
2428 if (lio->u.logio.flags & SRB_LOGIN_SKIP_PRLI) in qla24xx_login_iocb()
2429 logio->control_flags |= cpu_to_le16(LCF_SKIP_PRLI); in qla24xx_login_iocb()
2430 if (lio->u.logio.flags & SRB_LOGIN_FCSP) { in qla24xx_login_iocb()
2431 logio->control_flags |= in qla24xx_login_iocb()
2433 logio->io_parameter[0] = in qla24xx_login_iocb()
2437 logio->nport_handle = cpu_to_le16(sp->fcport->loop_id); in qla24xx_login_iocb()
2438 logio->port_id[0] = sp->fcport->d_id.b.al_pa; in qla24xx_login_iocb()
2439 logio->port_id[1] = sp->fcport->d_id.b.area; in qla24xx_login_iocb()
2440 logio->port_id[2] = sp->fcport->d_id.b.domain; in qla24xx_login_iocb()
2441 logio->vp_index = sp->vha->vp_idx; in qla24xx_login_iocb()
2447 struct qla_hw_data *ha = sp->vha->hw; in qla2x00_login_iocb()
2448 struct srb_iocb *lio = &sp->u.iocb_cmd; in qla2x00_login_iocb()
2451 mbx->entry_type = MBX_IOCB_TYPE; in qla2x00_login_iocb()
2452 SET_TARGET_ID(ha, mbx->loop_id, sp->fcport->loop_id); in qla2x00_login_iocb()
2453 mbx->mb0 = cpu_to_le16(MBC_LOGIN_FABRIC_PORT); in qla2x00_login_iocb()
2454 opts = lio->u.logio.flags & SRB_LOGIN_COND_PLOGI ? BIT_0 : 0; in qla2x00_login_iocb()
2455 opts |= lio->u.logio.flags & SRB_LOGIN_SKIP_PRLI ? BIT_1 : 0; in qla2x00_login_iocb()
2457 mbx->mb1 = cpu_to_le16(sp->fcport->loop_id); in qla2x00_login_iocb()
2458 mbx->mb10 = cpu_to_le16(opts); in qla2x00_login_iocb()
2460 mbx->mb1 = cpu_to_le16((sp->fcport->loop_id << 8) | opts); in qla2x00_login_iocb()
2462 mbx->mb2 = cpu_to_le16(sp->fcport->d_id.b.domain); in qla2x00_login_iocb()
2463 mbx->mb3 = cpu_to_le16(sp->fcport->d_id.b.area << 8 | in qla2x00_login_iocb()
2464 sp->fcport->d_id.b.al_pa); in qla2x00_login_iocb()
2465 mbx->mb9 = cpu_to_le16(sp->vha->vp_idx); in qla2x00_login_iocb()
2472 logio->entry_type = LOGINOUT_PORT_IOCB_TYPE; in qla24xx_logout_iocb()
2474 if (sp->fcport->explicit_logout) { in qla24xx_logout_iocb()
2479 if (!sp->fcport->keep_nport_handle) in qla24xx_logout_iocb()
2483 logio->control_flags = cpu_to_le16(control_flags); in qla24xx_logout_iocb()
2484 logio->nport_handle = cpu_to_le16(sp->fcport->loop_id); in qla24xx_logout_iocb()
2485 logio->port_id[0] = sp->fcport->d_id.b.al_pa; in qla24xx_logout_iocb()
2486 logio->port_id[1] = sp->fcport->d_id.b.area; in qla24xx_logout_iocb()
2487 logio->port_id[2] = sp->fcport->d_id.b.domain; in qla24xx_logout_iocb()
2488 logio->vp_index = sp->vha->vp_idx; in qla24xx_logout_iocb()
2494 struct qla_hw_data *ha = sp->vha->hw; in qla2x00_logout_iocb()
2496 mbx->entry_type = MBX_IOCB_TYPE; in qla2x00_logout_iocb()
2497 SET_TARGET_ID(ha, mbx->loop_id, sp->fcport->loop_id); in qla2x00_logout_iocb()
2498 mbx->mb0 = cpu_to_le16(MBC_LOGOUT_FABRIC_PORT); in qla2x00_logout_iocb()
2499 mbx->mb1 = HAS_EXTENDED_IDS(ha) ? in qla2x00_logout_iocb()
2500 cpu_to_le16(sp->fcport->loop_id) : in qla2x00_logout_iocb()
2501 cpu_to_le16(sp->fcport->loop_id << 8); in qla2x00_logout_iocb()
2502 mbx->mb2 = cpu_to_le16(sp->fcport->d_id.b.domain); in qla2x00_logout_iocb()
2503 mbx->mb3 = cpu_to_le16(sp->fcport->d_id.b.area << 8 | in qla2x00_logout_iocb()
2504 sp->fcport->d_id.b.al_pa); in qla2x00_logout_iocb()
2505 mbx->mb9 = cpu_to_le16(sp->vha->vp_idx); in qla2x00_logout_iocb()
2506 /* Implicit: mbx->mbx10 = 0. */ in qla2x00_logout_iocb()
2512 logio->entry_type = LOGINOUT_PORT_IOCB_TYPE; in qla24xx_adisc_iocb()
2513 logio->control_flags = cpu_to_le16(LCF_COMMAND_ADISC); in qla24xx_adisc_iocb()
2514 logio->nport_handle = cpu_to_le16(sp->fcport->loop_id); in qla24xx_adisc_iocb()
2515 logio->vp_index = sp->vha->vp_idx; in qla24xx_adisc_iocb()
2521 struct qla_hw_data *ha = sp->vha->hw; in qla2x00_adisc_iocb()
2523 mbx->entry_type = MBX_IOCB_TYPE; in qla2x00_adisc_iocb()
2524 SET_TARGET_ID(ha, mbx->loop_id, sp->fcport->loop_id); in qla2x00_adisc_iocb()
2525 mbx->mb0 = cpu_to_le16(MBC_GET_PORT_DATABASE); in qla2x00_adisc_iocb()
2527 mbx->mb1 = cpu_to_le16(sp->fcport->loop_id); in qla2x00_adisc_iocb()
2528 mbx->mb10 = cpu_to_le16(BIT_0); in qla2x00_adisc_iocb()
2530 mbx->mb1 = cpu_to_le16((sp->fcport->loop_id << 8) | BIT_0); in qla2x00_adisc_iocb()
2532 mbx->mb2 = cpu_to_le16(MSW(ha->async_pd_dma)); in qla2x00_adisc_iocb()
2533 mbx->mb3 = cpu_to_le16(LSW(ha->async_pd_dma)); in qla2x00_adisc_iocb()
2534 mbx->mb6 = cpu_to_le16(MSW(MSD(ha->async_pd_dma))); in qla2x00_adisc_iocb()
2535 mbx->mb7 = cpu_to_le16(LSW(MSD(ha->async_pd_dma))); in qla2x00_adisc_iocb()
2536 mbx->mb9 = cpu_to_le16(sp->vha->vp_idx); in qla2x00_adisc_iocb()
2544 struct fc_port *fcport = sp->fcport; in qla24xx_tm_iocb()
2545 scsi_qla_host_t *vha = fcport->vha; in qla24xx_tm_iocb()
2546 struct qla_hw_data *ha = vha->hw; in qla24xx_tm_iocb()
2547 struct srb_iocb *iocb = &sp->u.iocb_cmd; in qla24xx_tm_iocb()
2548 struct req_que *req = sp->qpair->req; in qla24xx_tm_iocb()
2550 flags = iocb->u.tmf.flags; in qla24xx_tm_iocb()
2551 lun = iocb->u.tmf.lun; in qla24xx_tm_iocb()
2553 tsk->entry_type = TSK_MGMT_IOCB_TYPE; in qla24xx_tm_iocb()
2554 tsk->entry_count = 1; in qla24xx_tm_iocb()
2555 tsk->handle = make_handle(req->id, tsk->handle); in qla24xx_tm_iocb()
2556 tsk->nport_handle = cpu_to_le16(fcport->loop_id); in qla24xx_tm_iocb()
2557 tsk->timeout = cpu_to_le16(ha->r_a_tov / 10 * 2); in qla24xx_tm_iocb()
2558 tsk->control_flags = cpu_to_le32(flags); in qla24xx_tm_iocb()
2559 tsk->port_id[0] = fcport->d_id.b.al_pa; in qla24xx_tm_iocb()
2560 tsk->port_id[1] = fcport->d_id.b.area; in qla24xx_tm_iocb()
2561 tsk->port_id[2] = fcport->d_id.b.domain; in qla24xx_tm_iocb()
2562 tsk->vp_index = fcport->vha->vp_idx; in qla24xx_tm_iocb()
2566 int_to_scsilun(lun, &tsk->lun); in qla24xx_tm_iocb()
2567 host_to_fcp_swap((uint8_t *)&tsk->lun, in qla24xx_tm_iocb()
2568 sizeof(tsk->lun)); in qla24xx_tm_iocb()
2575 if (del_timer(&sp->u.iocb_cmd.timer)) { in qla2x00_async_done()
2580 if (kref_put(&sp->cmd_kref, qla2x00_sp_release)) in qla2x00_async_done()
2583 sp->async_done(sp, res); in qla2x00_async_done()
2590 struct scsi_qla_host *vha = sp->vha; in qla2x00_sp_release()
2592 switch (sp->type) { in qla2x00_sp_release()
2594 /* GPSC & GFPNID use fcport->ct_desc.ct_sns for both req & rsp */ in qla2x00_sp_release()
2595 if (sp->u.iocb_cmd.u.ctarg.req && in qla2x00_sp_release()
2596 (!sp->fcport || in qla2x00_sp_release()
2597 sp->u.iocb_cmd.u.ctarg.req != sp->fcport->ct_desc.ct_sns)) { in qla2x00_sp_release()
2598 dma_free_coherent(&vha->hw->pdev->dev, in qla2x00_sp_release()
2599 sp->u.iocb_cmd.u.ctarg.req_allocated_size, in qla2x00_sp_release()
2600 sp->u.iocb_cmd.u.ctarg.req, in qla2x00_sp_release()
2601 sp->u.iocb_cmd.u.ctarg.req_dma); in qla2x00_sp_release()
2602 sp->u.iocb_cmd.u.ctarg.req = NULL; in qla2x00_sp_release()
2604 if (sp->u.iocb_cmd.u.ctarg.rsp && in qla2x00_sp_release()
2605 (!sp->fcport || in qla2x00_sp_release()
2606 sp->u.iocb_cmd.u.ctarg.rsp != sp->fcport->ct_desc.ct_sns)) { in qla2x00_sp_release()
2607 dma_free_coherent(&vha->hw->pdev->dev, in qla2x00_sp_release()
2608 sp->u.iocb_cmd.u.ctarg.rsp_allocated_size, in qla2x00_sp_release()
2609 sp->u.iocb_cmd.u.ctarg.rsp, in qla2x00_sp_release()
2610 sp->u.iocb_cmd.u.ctarg.rsp_dma); in qla2x00_sp_release()
2611 sp->u.iocb_cmd.u.ctarg.rsp = NULL; in qla2x00_sp_release()
2618 sp->free(sp); in qla2x00_sp_release()
2625 timer_setup(&sp->u.iocb_cmd.timer, qla2x00_sp_timeout, 0); in qla2x00_init_async_sp()
2626 sp->done = qla2x00_async_done; in qla2x00_init_async_sp()
2627 sp->async_done = done; in qla2x00_init_async_sp()
2628 sp->free = qla2x00_sp_free; in qla2x00_init_async_sp()
2629 sp->u.iocb_cmd.timeout = qla2x00_async_iocb_timeout; in qla2x00_init_async_sp()
2630 sp->u.iocb_cmd.timer.expires = jiffies + tmo * HZ; in qla2x00_init_async_sp()
2631 if (IS_QLAFX00(sp->vha->hw) && sp->type == SRB_FXIOCB_DCMD) in qla2x00_init_async_sp()
2632 init_completion(&sp->u.iocb_cmd.u.fxiocb.fxiocb_comp); in qla2x00_init_async_sp()
2633 sp->start_timer = 1; in qla2x00_init_async_sp()
2638 struct srb_iocb *elsio = &sp->u.iocb_cmd; in qla2x00_els_dcmd_sp_free()
2640 if (sp->fcport) in qla2x00_els_dcmd_sp_free()
2641 qla2x00_free_fcport(sp->fcport); in qla2x00_els_dcmd_sp_free()
2643 if (elsio->u.els_logo.els_logo_pyld) in qla2x00_els_dcmd_sp_free()
2644 dma_free_coherent(&sp->vha->hw->pdev->dev, DMA_POOL_SIZE, in qla2x00_els_dcmd_sp_free()
2645 elsio->u.els_logo.els_logo_pyld, in qla2x00_els_dcmd_sp_free()
2646 elsio->u.els_logo.els_logo_pyld_dma); in qla2x00_els_dcmd_sp_free()
2648 del_timer(&elsio->timer); in qla2x00_els_dcmd_sp_free()
2656 fc_port_t *fcport = sp->fcport; in qla2x00_els_dcmd_iocb_timeout()
2657 struct scsi_qla_host *vha = sp->vha; in qla2x00_els_dcmd_iocb_timeout()
2658 struct srb_iocb *lio = &sp->u.iocb_cmd; in qla2x00_els_dcmd_iocb_timeout()
2664 sp->name, sp->handle, fcport->d_id.b.domain, fcport->d_id.b.area, in qla2x00_els_dcmd_iocb_timeout()
2665 fcport->d_id.b.al_pa); in qla2x00_els_dcmd_iocb_timeout()
2672 spin_lock_irqsave(sp->qpair->qp_lock_ptr, flags); in qla2x00_els_dcmd_iocb_timeout()
2673 for (h = 1; h < sp->qpair->req->num_outstanding_cmds; h++) { in qla2x00_els_dcmd_iocb_timeout()
2674 if (sp->qpair->req->outstanding_cmds[h] == sp) { in qla2x00_els_dcmd_iocb_timeout()
2675 sp->qpair->req->outstanding_cmds[h] = NULL; in qla2x00_els_dcmd_iocb_timeout()
2679 spin_unlock_irqrestore(sp->qpair->qp_lock_ptr, flags); in qla2x00_els_dcmd_iocb_timeout()
2680 complete(&lio->u.els_logo.comp); in qla2x00_els_dcmd_iocb_timeout()
2689 fc_port_t *fcport = sp->fcport; in qla2x00_els_dcmd_sp_done()
2690 struct srb_iocb *lio = &sp->u.iocb_cmd; in qla2x00_els_dcmd_sp_done()
2691 struct scsi_qla_host *vha = sp->vha; in qla2x00_els_dcmd_sp_done()
2695 sp->name, sp->handle, fcport->d_id.b.domain, in qla2x00_els_dcmd_sp_done()
2696 fcport->d_id.b.area, fcport->d_id.b.al_pa); in qla2x00_els_dcmd_sp_done()
2698 complete(&lio->u.els_logo.comp); in qla2x00_els_dcmd_sp_done()
2708 struct qla_hw_data *ha = vha->hw; in qla24xx_els_dcmd_iocb()
2715 return -ENOMEM; in qla24xx_els_dcmd_iocb()
2726 return -ENOMEM; in qla24xx_els_dcmd_iocb()
2729 elsio = &sp->u.iocb_cmd; in qla24xx_els_dcmd_iocb()
2730 fcport->loop_id = 0xFFFF; in qla24xx_els_dcmd_iocb()
2731 fcport->d_id.b.domain = remote_did.b.domain; in qla24xx_els_dcmd_iocb()
2732 fcport->d_id.b.area = remote_did.b.area; in qla24xx_els_dcmd_iocb()
2733 fcport->d_id.b.al_pa = remote_did.b.al_pa; in qla24xx_els_dcmd_iocb()
2736 fcport->d_id.b.domain, fcport->d_id.b.area, fcport->d_id.b.al_pa); in qla24xx_els_dcmd_iocb()
2738 sp->type = SRB_ELS_DCMD; in qla24xx_els_dcmd_iocb()
2739 sp->name = "ELS_DCMD"; in qla24xx_els_dcmd_iocb()
2740 sp->fcport = fcport; in qla24xx_els_dcmd_iocb()
2743 sp->free = qla2x00_els_dcmd_sp_free; in qla24xx_els_dcmd_iocb()
2744 sp->u.iocb_cmd.timeout = qla2x00_els_dcmd_iocb_timeout; in qla24xx_els_dcmd_iocb()
2745 init_completion(&sp->u.iocb_cmd.u.els_logo.comp); in qla24xx_els_dcmd_iocb()
2747 elsio->u.els_logo.els_logo_pyld = dma_alloc_coherent(&ha->pdev->dev, in qla24xx_els_dcmd_iocb()
2748 DMA_POOL_SIZE, &elsio->u.els_logo.els_logo_pyld_dma, in qla24xx_els_dcmd_iocb()
2751 if (!elsio->u.els_logo.els_logo_pyld) { in qla24xx_els_dcmd_iocb()
2753 kref_put(&sp->cmd_kref, qla2x00_sp_release); in qla24xx_els_dcmd_iocb()
2760 elsio->u.els_logo.els_cmd = els_opcode; in qla24xx_els_dcmd_iocb()
2762 logo_pyld.s_id[0] = vha->d_id.b.al_pa; in qla24xx_els_dcmd_iocb()
2763 logo_pyld.s_id[1] = vha->d_id.b.area; in qla24xx_els_dcmd_iocb()
2764 logo_pyld.s_id[2] = vha->d_id.b.domain; in qla24xx_els_dcmd_iocb()
2766 memcpy(&logo_pyld.wwpn, vha->port_name, WWN_SIZE); in qla24xx_els_dcmd_iocb()
2768 memcpy(elsio->u.els_logo.els_logo_pyld, &logo_pyld, in qla24xx_els_dcmd_iocb()
2772 elsio->u.els_logo.els_logo_pyld, in qla24xx_els_dcmd_iocb()
2773 sizeof(*elsio->u.els_logo.els_logo_pyld)); in qla24xx_els_dcmd_iocb()
2778 kref_put(&sp->cmd_kref, qla2x00_sp_release); in qla24xx_els_dcmd_iocb()
2785 sp->name, sp->handle, fcport->loop_id, fcport->d_id.b.domain, in qla24xx_els_dcmd_iocb()
2786 fcport->d_id.b.area, fcport->d_id.b.al_pa); in qla24xx_els_dcmd_iocb()
2788 wait_for_completion(&elsio->u.els_logo.comp); in qla24xx_els_dcmd_iocb()
2791 kref_put(&sp->cmd_kref, qla2x00_sp_release); in qla24xx_els_dcmd_iocb()
2798 scsi_qla_host_t *vha = sp->vha; in qla24xx_els_logo_iocb()
2799 struct srb_iocb *elsio = &sp->u.iocb_cmd; in qla24xx_els_logo_iocb()
2801 els_iocb->entry_type = ELS_IOCB_TYPE; in qla24xx_els_logo_iocb()
2802 els_iocb->entry_count = 1; in qla24xx_els_logo_iocb()
2803 els_iocb->sys_define = 0; in qla24xx_els_logo_iocb()
2804 els_iocb->entry_status = 0; in qla24xx_els_logo_iocb()
2805 els_iocb->handle = sp->handle; in qla24xx_els_logo_iocb()
2806 els_iocb->nport_handle = cpu_to_le16(sp->fcport->loop_id); in qla24xx_els_logo_iocb()
2807 els_iocb->tx_dsd_count = cpu_to_le16(1); in qla24xx_els_logo_iocb()
2808 els_iocb->vp_index = vha->vp_idx; in qla24xx_els_logo_iocb()
2809 els_iocb->sof_type = EST_SOFI3; in qla24xx_els_logo_iocb()
2810 els_iocb->rx_dsd_count = 0; in qla24xx_els_logo_iocb()
2811 els_iocb->opcode = elsio->u.els_logo.els_cmd; in qla24xx_els_logo_iocb()
2813 els_iocb->d_id[0] = sp->fcport->d_id.b.al_pa; in qla24xx_els_logo_iocb()
2814 els_iocb->d_id[1] = sp->fcport->d_id.b.area; in qla24xx_els_logo_iocb()
2815 els_iocb->d_id[2] = sp->fcport->d_id.b.domain; in qla24xx_els_logo_iocb()
2817 els_iocb->s_id[1] = vha->d_id.b.al_pa; in qla24xx_els_logo_iocb()
2818 els_iocb->s_id[2] = vha->d_id.b.area; in qla24xx_els_logo_iocb()
2819 els_iocb->s_id[0] = vha->d_id.b.domain; in qla24xx_els_logo_iocb()
2821 if (elsio->u.els_logo.els_cmd == ELS_DCMD_PLOGI) { in qla24xx_els_logo_iocb()
2822 if (vha->hw->flags.edif_enabled) in qla24xx_els_logo_iocb()
2823 els_iocb->control_flags = cpu_to_le16(ECF_SEC_LOGIN); in qla24xx_els_logo_iocb()
2825 els_iocb->control_flags = 0; in qla24xx_els_logo_iocb()
2826 els_iocb->tx_byte_count = els_iocb->tx_len = in qla24xx_els_logo_iocb()
2828 put_unaligned_le64(elsio->u.els_plogi.els_plogi_pyld_dma, in qla24xx_els_logo_iocb()
2829 &els_iocb->tx_address); in qla24xx_els_logo_iocb()
2830 els_iocb->rx_dsd_count = cpu_to_le16(1); in qla24xx_els_logo_iocb()
2831 els_iocb->rx_byte_count = els_iocb->rx_len = in qla24xx_els_logo_iocb()
2833 put_unaligned_le64(elsio->u.els_plogi.els_resp_pyld_dma, in qla24xx_els_logo_iocb()
2834 &els_iocb->rx_address); in qla24xx_els_logo_iocb()
2842 els_iocb->tx_byte_count = in qla24xx_els_logo_iocb()
2844 put_unaligned_le64(elsio->u.els_logo.els_logo_pyld_dma, in qla24xx_els_logo_iocb()
2845 &els_iocb->tx_address); in qla24xx_els_logo_iocb()
2846 els_iocb->tx_len = cpu_to_le32(sizeof(struct els_logo_payload)); in qla24xx_els_logo_iocb()
2848 els_iocb->rx_byte_count = 0; in qla24xx_els_logo_iocb()
2849 els_iocb->rx_address = 0; in qla24xx_els_logo_iocb()
2850 els_iocb->rx_len = 0; in qla24xx_els_logo_iocb()
2858 sp->vha->qla_stats.control_requests++; in qla24xx_els_logo_iocb()
2865 fc_port_t *fcport = sp->fcport; in qla2x00_els_dcmd2_iocb_timeout()
2866 struct scsi_qla_host *vha = sp->vha; in qla2x00_els_dcmd2_iocb_timeout()
2872 sp->name, sp->handle, fcport->port_name, fcport->d_id.b24); in qla2x00_els_dcmd2_iocb_timeout()
2880 spin_lock_irqsave(sp->qpair->qp_lock_ptr, flags); in qla2x00_els_dcmd2_iocb_timeout()
2881 for (h = 1; h < sp->qpair->req->num_outstanding_cmds; h++) { in qla2x00_els_dcmd2_iocb_timeout()
2882 if (sp->qpair->req->outstanding_cmds[h] == sp) { in qla2x00_els_dcmd2_iocb_timeout()
2883 sp->qpair->req->outstanding_cmds[h] = NULL; in qla2x00_els_dcmd2_iocb_timeout()
2887 spin_unlock_irqrestore(sp->qpair->qp_lock_ptr, flags); in qla2x00_els_dcmd2_iocb_timeout()
2888 sp->done(sp, QLA_FUNCTION_TIMEOUT); in qla2x00_els_dcmd2_iocb_timeout()
2894 if (els_plogi->els_plogi_pyld) in qla2x00_els_dcmd2_free()
2895 dma_free_coherent(&vha->hw->pdev->dev, in qla2x00_els_dcmd2_free()
2896 els_plogi->tx_size, in qla2x00_els_dcmd2_free()
2897 els_plogi->els_plogi_pyld, in qla2x00_els_dcmd2_free()
2898 els_plogi->els_plogi_pyld_dma); in qla2x00_els_dcmd2_free()
2900 if (els_plogi->els_resp_pyld) in qla2x00_els_dcmd2_free()
2901 dma_free_coherent(&vha->hw->pdev->dev, in qla2x00_els_dcmd2_free()
2902 els_plogi->rx_size, in qla2x00_els_dcmd2_free()
2903 els_plogi->els_resp_pyld, in qla2x00_els_dcmd2_free()
2904 els_plogi->els_resp_pyld_dma); in qla2x00_els_dcmd2_free()
2909 fc_port_t *fcport = sp->fcport; in qla2x00_els_dcmd2_sp_done()
2910 struct srb_iocb *lio = &sp->u.iocb_cmd; in qla2x00_els_dcmd2_sp_done()
2911 struct scsi_qla_host *vha = sp->vha; in qla2x00_els_dcmd2_sp_done()
2916 const __le32 *fw_status = sp->u.iocb_cmd.u.els_plogi.fw_status; in qla2x00_els_dcmd2_sp_done()
2921 sp->name, res, sp->handle, fcport->d_id.b24, fcport->port_name); in qla2x00_els_dcmd2_sp_done()
2923 fcport->flags &= ~(FCF_ASYNC_SENT|FCF_ASYNC_ACTIVE); in qla2x00_els_dcmd2_sp_done()
2925 fcport->logout_on_delete = 1; in qla2x00_els_dcmd2_sp_done()
2926 fcport->chip_reset = vha->hw->base_qpair->chip_reset; in qla2x00_els_dcmd2_sp_done()
2928 if (sp->flags & SRB_WAKEUP_ON_COMP) in qla2x00_els_dcmd2_sp_done()
2929 complete(&lio->u.els_plogi.comp); in qla2x00_els_dcmd2_sp_done()
2945 wwn_to_u64(fcport->port_name), in qla2x00_els_dcmd2_sp_done()
2946 fcport->d_id, lid, &conflict_fcport); in qla2x00_els_dcmd2_sp_done()
2955 conflict_fcport->conflict = fcport; in qla2x00_els_dcmd2_sp_done()
2956 fcport->login_pause = 1; in qla2x00_els_dcmd2_sp_done()
2960 fcport->port_name, in qla2x00_els_dcmd2_sp_done()
2961 fcport->d_id.b24, lid); in qla2x00_els_dcmd2_sp_done()
2966 fcport->port_name, in qla2x00_els_dcmd2_sp_done()
2967 fcport->d_id.b24, lid); in qla2x00_els_dcmd2_sp_done()
2969 set_bit(lid, vha->hw->loop_id_map); in qla2x00_els_dcmd2_sp_done()
2970 fcport->loop_id = lid; in qla2x00_els_dcmd2_sp_done()
2971 fcport->keep_nport_handle = 0; in qla2x00_els_dcmd2_sp_done()
2986 __func__, __LINE__, fcport->port_name, in qla2x00_els_dcmd2_sp_done()
2987 fcport->loop_id, cid.b24); in qla2x00_els_dcmd2_sp_done()
2988 set_bit(fcport->loop_id, in qla2x00_els_dcmd2_sp_done()
2989 vha->hw->loop_id_map); in qla2x00_els_dcmd2_sp_done()
2990 fcport->loop_id = FC_NO_LOOP_ID; in qla2x00_els_dcmd2_sp_done()
2995 vha->hw->exch_starvation++; in qla2x00_els_dcmd2_sp_done()
2996 if (vha->hw->exch_starvation > 5) { in qla2x00_els_dcmd2_sp_done()
2999 vha->hw->exch_starvation = 0; in qla2x00_els_dcmd2_sp_done()
3001 &vha->dpc_flags); in qla2x00_els_dcmd2_sp_done()
3008 "%s %8phC cmd error fw_status 0x%x 0x%x 0x%x\n", in qla2x00_els_dcmd2_sp_done()
3009 __func__, sp->fcport->port_name, in qla2x00_els_dcmd2_sp_done()
3012 fcport->flags &= ~FCF_ASYNC_SENT; in qla2x00_els_dcmd2_sp_done()
3020 "%s %8phC cmd error 2 fw_status 0x%x 0x%x 0x%x\n", in qla2x00_els_dcmd2_sp_done()
3021 __func__, sp->fcport->port_name, in qla2x00_els_dcmd2_sp_done()
3024 sp->fcport->flags &= ~FCF_ASYNC_SENT; in qla2x00_els_dcmd2_sp_done()
3031 struct srb_iocb *elsio = &sp->u.iocb_cmd; in qla2x00_els_dcmd2_sp_done()
3033 qla2x00_els_dcmd2_free(vha, &elsio->u.els_plogi); in qla2x00_els_dcmd2_sp_done()
3035 kref_put(&sp->cmd_kref, qla2x00_sp_release); in qla2x00_els_dcmd2_sp_done()
3038 e->u.iosb.sp = sp; in qla2x00_els_dcmd2_sp_done()
3049 struct qla_hw_data *ha = vha->hw; in qla24xx_els_dcmd2_iocb()
3063 fcport->flags |= FCF_ASYNC_SENT; in qla24xx_els_dcmd2_iocb()
3065 elsio = &sp->u.iocb_cmd; in qla24xx_els_dcmd2_iocb()
3067 "%s Enter: PLOGI portid=%06x\n", __func__, fcport->d_id.b24); in qla24xx_els_dcmd2_iocb()
3069 sp->type = SRB_ELS_DCMD; in qla24xx_els_dcmd2_iocb()
3070 sp->name = "ELS_DCMD"; in qla24xx_els_dcmd2_iocb()
3071 sp->fcport = fcport; in qla24xx_els_dcmd2_iocb()
3074 sp->u.iocb_cmd.timeout = qla2x00_els_dcmd2_iocb_timeout; in qla24xx_els_dcmd2_iocb()
3076 elsio->u.els_plogi.tx_size = elsio->u.els_plogi.rx_size = DMA_POOL_SIZE; in qla24xx_els_dcmd2_iocb()
3078 ptr = elsio->u.els_plogi.els_plogi_pyld = in qla24xx_els_dcmd2_iocb()
3079 dma_alloc_coherent(&ha->pdev->dev, elsio->u.els_plogi.tx_size, in qla24xx_els_dcmd2_iocb()
3080 &elsio->u.els_plogi.els_plogi_pyld_dma, GFP_KERNEL); in qla24xx_els_dcmd2_iocb()
3082 if (!elsio->u.els_plogi.els_plogi_pyld) { in qla24xx_els_dcmd2_iocb()
3087 resp_ptr = elsio->u.els_plogi.els_resp_pyld = in qla24xx_els_dcmd2_iocb()
3088 dma_alloc_coherent(&ha->pdev->dev, elsio->u.els_plogi.rx_size, in qla24xx_els_dcmd2_iocb()
3089 &elsio->u.els_plogi.els_resp_pyld_dma, GFP_KERNEL); in qla24xx_els_dcmd2_iocb()
3091 if (!elsio->u.els_plogi.els_resp_pyld) { in qla24xx_els_dcmd2_iocb()
3100 memcpy(elsio->u.els_plogi.els_plogi_pyld->data, in qla24xx_els_dcmd2_iocb()
3101 (void *)&ha->plogi_els_payld + offsetof(struct fc_els_flogi, fl_csp), in qla24xx_els_dcmd2_iocb()
3102 sizeof(ha->plogi_els_payld) - offsetof(struct fc_els_flogi, fl_csp)); in qla24xx_els_dcmd2_iocb()
3104 elsio->u.els_plogi.els_cmd = els_opcode; in qla24xx_els_dcmd2_iocb()
3105 elsio->u.els_plogi.els_plogi_pyld->opcode = els_opcode; in qla24xx_els_dcmd2_iocb()
3109 p->fl_csp.sp_features |= cpu_to_be16(FC_SP_FT_SEC); in qla24xx_els_dcmd2_iocb()
3114 (uint8_t *)elsio->u.els_plogi.els_plogi_pyld, in qla24xx_els_dcmd2_iocb()
3115 sizeof(*elsio->u.els_plogi.els_plogi_pyld)); in qla24xx_els_dcmd2_iocb()
3119 fcport->flags |= FCF_LOGIN_NEEDED; in qla24xx_els_dcmd2_iocb()
3120 set_bit(RELOGIN_NEEDED, &vha->dpc_flags); in qla24xx_els_dcmd2_iocb()
3125 sp->name, sp->handle, fcport->loop_id, in qla24xx_els_dcmd2_iocb()
3126 fcport->d_id.b24, vha->d_id.b24); in qla24xx_els_dcmd2_iocb()
3132 qla2x00_els_dcmd2_free(vha, &elsio->u.els_plogi); in qla24xx_els_dcmd2_iocb()
3134 kref_put(&sp->cmd_kref, qla2x00_sp_release); in qla24xx_els_dcmd2_iocb()
3136 fcport->flags &= ~(FCF_ASYNC_SENT | FCF_ASYNC_ACTIVE); in qla24xx_els_dcmd2_iocb()
3146 els_iocb->entry_type = ELS_IOCB_TYPE; in qla_els_pt_iocb()
3147 els_iocb->entry_count = 1; in qla_els_pt_iocb()
3148 els_iocb->sys_define = 0; in qla_els_pt_iocb()
3149 els_iocb->entry_status = 0; in qla_els_pt_iocb()
3150 els_iocb->handle = QLA_SKIP_HANDLE; in qla_els_pt_iocb()
3151 els_iocb->nport_handle = a->nport_handle; in qla_els_pt_iocb()
3152 els_iocb->rx_xchg_address = a->rx_xchg_address; in qla_els_pt_iocb()
3153 els_iocb->tx_dsd_count = cpu_to_le16(1); in qla_els_pt_iocb()
3154 els_iocb->vp_index = a->vp_idx; in qla_els_pt_iocb()
3155 els_iocb->sof_type = EST_SOFI3; in qla_els_pt_iocb()
3156 els_iocb->rx_dsd_count = cpu_to_le16(0); in qla_els_pt_iocb()
3157 els_iocb->opcode = a->els_opcode; in qla_els_pt_iocb()
3159 els_iocb->d_id[0] = a->did.b.al_pa; in qla_els_pt_iocb()
3160 els_iocb->d_id[1] = a->did.b.area; in qla_els_pt_iocb()
3161 els_iocb->d_id[2] = a->did.b.domain; in qla_els_pt_iocb()
3163 els_iocb->s_id[1] = vha->d_id.b.al_pa; in qla_els_pt_iocb()
3164 els_iocb->s_id[2] = vha->d_id.b.area; in qla_els_pt_iocb()
3165 els_iocb->s_id[0] = vha->d_id.b.domain; in qla_els_pt_iocb()
3167 els_iocb->control_flags = cpu_to_le16(a->control_flags); in qla_els_pt_iocb()
3169 els_iocb->tx_byte_count = cpu_to_le32(a->tx_byte_count); in qla_els_pt_iocb()
3170 els_iocb->tx_len = cpu_to_le32(a->tx_len); in qla_els_pt_iocb()
3171 put_unaligned_le64(a->tx_addr, &els_iocb->tx_address); in qla_els_pt_iocb()
3173 els_iocb->rx_byte_count = cpu_to_le32(a->rx_byte_count); in qla_els_pt_iocb()
3174 els_iocb->rx_len = cpu_to_le32(a->rx_len); in qla_els_pt_iocb()
3175 put_unaligned_le64(a->rx_addr, &els_iocb->rx_address); in qla_els_pt_iocb()
3181 struct bsg_job *bsg_job = sp->u.bsg_job; in qla24xx_els_iocb()
3182 struct fc_bsg_request *bsg_request = bsg_job->request; in qla24xx_els_iocb()
3184 els_iocb->entry_type = ELS_IOCB_TYPE; in qla24xx_els_iocb()
3185 els_iocb->entry_count = 1; in qla24xx_els_iocb()
3186 els_iocb->sys_define = 0; in qla24xx_els_iocb()
3187 els_iocb->entry_status = 0; in qla24xx_els_iocb()
3188 els_iocb->handle = sp->handle; in qla24xx_els_iocb()
3189 els_iocb->nport_handle = cpu_to_le16(sp->fcport->loop_id); in qla24xx_els_iocb()
3190 els_iocb->tx_dsd_count = cpu_to_le16(bsg_job->request_payload.sg_cnt); in qla24xx_els_iocb()
3191 els_iocb->vp_index = sp->vha->vp_idx; in qla24xx_els_iocb()
3192 els_iocb->sof_type = EST_SOFI3; in qla24xx_els_iocb()
3193 els_iocb->rx_dsd_count = cpu_to_le16(bsg_job->reply_payload.sg_cnt); in qla24xx_els_iocb()
3195 els_iocb->opcode = in qla24xx_els_iocb()
3196 sp->type == SRB_ELS_CMD_RPT ? in qla24xx_els_iocb()
3197 bsg_request->rqst_data.r_els.els_code : in qla24xx_els_iocb()
3198 bsg_request->rqst_data.h_els.command_code; in qla24xx_els_iocb()
3199 els_iocb->d_id[0] = sp->fcport->d_id.b.al_pa; in qla24xx_els_iocb()
3200 els_iocb->d_id[1] = sp->fcport->d_id.b.area; in qla24xx_els_iocb()
3201 els_iocb->d_id[2] = sp->fcport->d_id.b.domain; in qla24xx_els_iocb()
3202 els_iocb->control_flags = 0; in qla24xx_els_iocb()
3203 els_iocb->rx_byte_count = in qla24xx_els_iocb()
3204 cpu_to_le32(bsg_job->reply_payload.payload_len); in qla24xx_els_iocb()
3205 els_iocb->tx_byte_count = in qla24xx_els_iocb()
3206 cpu_to_le32(bsg_job->request_payload.payload_len); in qla24xx_els_iocb()
3208 put_unaligned_le64(sg_dma_address(bsg_job->request_payload.sg_list), in qla24xx_els_iocb()
3209 &els_iocb->tx_address); in qla24xx_els_iocb()
3210 els_iocb->tx_len = cpu_to_le32(sg_dma_len in qla24xx_els_iocb()
3211 (bsg_job->request_payload.sg_list)); in qla24xx_els_iocb()
3213 put_unaligned_le64(sg_dma_address(bsg_job->reply_payload.sg_list), in qla24xx_els_iocb()
3214 &els_iocb->rx_address); in qla24xx_els_iocb()
3215 els_iocb->rx_len = cpu_to_le32(sg_dma_len in qla24xx_els_iocb()
3216 (bsg_job->reply_payload.sg_list)); in qla24xx_els_iocb()
3218 sp->vha->qla_stats.control_requests++; in qla24xx_els_iocb()
3229 scsi_qla_host_t *vha = sp->vha; in qla2x00_ct_iocb()
3230 struct qla_hw_data *ha = vha->hw; in qla2x00_ct_iocb()
3231 struct bsg_job *bsg_job = sp->u.bsg_job; in qla2x00_ct_iocb()
3235 ct_iocb->entry_type = CT_IOCB_TYPE; in qla2x00_ct_iocb()
3236 ct_iocb->entry_status = 0; in qla2x00_ct_iocb()
3237 ct_iocb->handle1 = sp->handle; in qla2x00_ct_iocb()
3238 SET_TARGET_ID(ha, ct_iocb->loop_id, sp->fcport->loop_id); in qla2x00_ct_iocb()
3239 ct_iocb->status = cpu_to_le16(0); in qla2x00_ct_iocb()
3240 ct_iocb->control_flags = cpu_to_le16(0); in qla2x00_ct_iocb()
3241 ct_iocb->timeout = 0; in qla2x00_ct_iocb()
3242 ct_iocb->cmd_dsd_count = in qla2x00_ct_iocb()
3243 cpu_to_le16(bsg_job->request_payload.sg_cnt); in qla2x00_ct_iocb()
3244 ct_iocb->total_dsd_count = in qla2x00_ct_iocb()
3245 cpu_to_le16(bsg_job->request_payload.sg_cnt + 1); in qla2x00_ct_iocb()
3246 ct_iocb->req_bytecount = in qla2x00_ct_iocb()
3247 cpu_to_le32(bsg_job->request_payload.payload_len); in qla2x00_ct_iocb()
3248 ct_iocb->rsp_bytecount = in qla2x00_ct_iocb()
3249 cpu_to_le32(bsg_job->reply_payload.payload_len); in qla2x00_ct_iocb()
3251 put_unaligned_le64(sg_dma_address(bsg_job->request_payload.sg_list), in qla2x00_ct_iocb()
3252 &ct_iocb->req_dsd.address); in qla2x00_ct_iocb()
3253 ct_iocb->req_dsd.length = ct_iocb->req_bytecount; in qla2x00_ct_iocb()
3255 put_unaligned_le64(sg_dma_address(bsg_job->reply_payload.sg_list), in qla2x00_ct_iocb()
3256 &ct_iocb->rsp_dsd.address); in qla2x00_ct_iocb()
3257 ct_iocb->rsp_dsd.length = ct_iocb->rsp_bytecount; in qla2x00_ct_iocb()
3260 cur_dsd = &ct_iocb->rsp_dsd; in qla2x00_ct_iocb()
3262 tot_dsds = bsg_job->reply_payload.sg_cnt; in qla2x00_ct_iocb()
3264 for_each_sg(bsg_job->reply_payload.sg_list, sg, tot_dsds, index) { in qla2x00_ct_iocb()
3274 vha->hw->req_q_map[0]); in qla2x00_ct_iocb()
3275 cur_dsd = cont_pkt->dsd; in qla2x00_ct_iocb()
3281 avail_dsds--; in qla2x00_ct_iocb()
3283 ct_iocb->entry_count = entry_count; in qla2x00_ct_iocb()
3285 sp->vha->qla_stats.control_requests++; in qla2x00_ct_iocb()
3296 scsi_qla_host_t *vha = sp->vha; in qla24xx_ct_iocb()
3297 struct qla_hw_data *ha = vha->hw; in qla24xx_ct_iocb()
3298 struct bsg_job *bsg_job = sp->u.bsg_job; in qla24xx_ct_iocb()
3302 ct_iocb->entry_type = CT_IOCB_TYPE; in qla24xx_ct_iocb()
3303 ct_iocb->entry_status = 0; in qla24xx_ct_iocb()
3304 ct_iocb->sys_define = 0; in qla24xx_ct_iocb()
3305 ct_iocb->handle = sp->handle; in qla24xx_ct_iocb()
3307 ct_iocb->nport_handle = cpu_to_le16(sp->fcport->loop_id); in qla24xx_ct_iocb()
3308 ct_iocb->vp_index = sp->vha->vp_idx; in qla24xx_ct_iocb()
3309 ct_iocb->comp_status = cpu_to_le16(0); in qla24xx_ct_iocb()
3311 cmd_dsds = bsg_job->request_payload.sg_cnt; in qla24xx_ct_iocb()
3312 rsp_dsds = bsg_job->reply_payload.sg_cnt; in qla24xx_ct_iocb()
3314 ct_iocb->cmd_dsd_count = cpu_to_le16(cmd_dsds); in qla24xx_ct_iocb()
3315 ct_iocb->timeout = 0; in qla24xx_ct_iocb()
3316 ct_iocb->rsp_dsd_count = cpu_to_le16(rsp_dsds); in qla24xx_ct_iocb()
3317 ct_iocb->cmd_byte_count = in qla24xx_ct_iocb()
3318 cpu_to_le32(bsg_job->request_payload.payload_len); in qla24xx_ct_iocb()
3321 cur_dsd = ct_iocb->dsd; in qla24xx_ct_iocb()
3324 for_each_sg(bsg_job->request_payload.sg_list, sg, cmd_dsds, index) { in qla24xx_ct_iocb()
3332 vha, ha->req_q_map[0]); in qla24xx_ct_iocb()
3333 cur_dsd = cont_pkt->dsd; in qla24xx_ct_iocb()
3339 avail_dsds--; in qla24xx_ct_iocb()
3344 for_each_sg(bsg_job->reply_payload.sg_list, sg, rsp_dsds, index) { in qla24xx_ct_iocb()
3352 ha->req_q_map[0]); in qla24xx_ct_iocb()
3353 cur_dsd = cont_pkt->dsd; in qla24xx_ct_iocb()
3359 avail_dsds--; in qla24xx_ct_iocb()
3361 ct_iocb->entry_count = entry_count; in qla24xx_ct_iocb()
3365 * qla82xx_start_scsi() - Send a SCSI command to the ISP
3368 * Returns non-zero if a failure occurred, else zero.
3375 struct scsi_cmnd *cmd; in qla82xx_start_scsi() local
3378 uint16_t cnt; in qla82xx_start_scsi() local
3386 struct scsi_qla_host *vha = sp->vha; in qla82xx_start_scsi()
3387 struct qla_hw_data *ha = vha->hw; in qla82xx_start_scsi()
3390 struct qla_qpair *qpair = sp->qpair; in qla82xx_start_scsi()
3393 reg = &ha->iobase->isp82; in qla82xx_start_scsi()
3394 cmd = GET_CMD_SP(sp); in qla82xx_start_scsi()
3395 req = vha->req; in qla82xx_start_scsi()
3396 rsp = ha->rsp_q_map[0]; in qla82xx_start_scsi()
3401 dbval = 0x04 | (ha->portnum << 5); in qla82xx_start_scsi()
3404 if (vha->marker_needed != 0) { in qla82xx_start_scsi()
3405 if (qla2x00_marker(vha, ha->base_qpair, in qla82xx_start_scsi()
3408 "qla2x00_marker failed for cmd=%p.\n", cmd); in qla82xx_start_scsi()
3411 vha->marker_needed = 0; in qla82xx_start_scsi()
3415 spin_lock_irqsave(&ha->hardware_lock, flags); in qla82xx_start_scsi()
3422 if (scsi_sg_count(cmd)) { in qla82xx_start_scsi()
3423 nseg = dma_map_sg(&ha->pdev->dev, scsi_sglist(cmd), in qla82xx_start_scsi()
3424 scsi_sg_count(cmd), cmd->sc_data_direction); in qla82xx_start_scsi()
3439 if ((more_dsd_lists + qpair->dsd_inuse) >= NUM_DSD_CHAIN) { in qla82xx_start_scsi()
3441 "Num of DSD list %d is than %d for cmd=%p.\n", in qla82xx_start_scsi()
3442 more_dsd_lists + qpair->dsd_inuse, NUM_DSD_CHAIN, in qla82xx_start_scsi()
3443 cmd); in qla82xx_start_scsi()
3447 if (more_dsd_lists <= qpair->dsd_avail) in qla82xx_start_scsi()
3450 more_dsd_lists -= qpair->dsd_avail; in qla82xx_start_scsi()
3457 "for cmd=%p.\n", cmd); in qla82xx_start_scsi()
3461 dsd_ptr->dsd_addr = dma_pool_alloc(ha->dl_dma_pool, in qla82xx_start_scsi()
3462 GFP_ATOMIC, &dsd_ptr->dsd_list_dma); in qla82xx_start_scsi()
3463 if (!dsd_ptr->dsd_addr) { in qla82xx_start_scsi()
3467 "for cmd=%p.\n", cmd); in qla82xx_start_scsi()
3470 list_add_tail(&dsd_ptr->list, &qpair->dsd_list); in qla82xx_start_scsi()
3471 qpair->dsd_avail++; in qla82xx_start_scsi()
3477 if (req->cnt < (req_cnt + 2)) { in qla82xx_start_scsi()
3478 cnt = (uint16_t)rd_reg_dword_relaxed( in qla82xx_start_scsi()
3479 ®->req_q_out[0]); in qla82xx_start_scsi()
3480 if (req->ring_index < cnt) in qla82xx_start_scsi()
3481 req->cnt = cnt - req->ring_index; in qla82xx_start_scsi()
3483 req->cnt = req->length - in qla82xx_start_scsi()
3484 (req->ring_index - cnt); in qla82xx_start_scsi()
3485 if (req->cnt < (req_cnt + 2)) in qla82xx_start_scsi()
3489 ctx = &sp->u.scmd.ct6_ctx; in qla82xx_start_scsi()
3492 ctx->fcp_cmnd = dma_pool_zalloc(ha->fcp_cmnd_dma_pool, in qla82xx_start_scsi()
3493 GFP_ATOMIC, &ctx->fcp_cmnd_dma); in qla82xx_start_scsi()
3494 if (!ctx->fcp_cmnd) { in qla82xx_start_scsi()
3496 "Failed to allocate fcp_cmnd for cmd=%p.\n", cmd); in qla82xx_start_scsi()
3501 INIT_LIST_HEAD(&ctx->dsd_list); in qla82xx_start_scsi()
3502 ctx->dsd_use_cnt = 0; in qla82xx_start_scsi()
3504 if (cmd->cmd_len > 16) { in qla82xx_start_scsi()
3505 additional_cdb_len = cmd->cmd_len - 16; in qla82xx_start_scsi()
3506 if ((cmd->cmd_len % 4) != 0) { in qla82xx_start_scsi()
3511 "scsi cmd len %d not multiple of 4 " in qla82xx_start_scsi()
3512 "for cmd=%p.\n", cmd->cmd_len, cmd); in qla82xx_start_scsi()
3515 ctx->fcp_cmnd_len = 12 + cmd->cmd_len + 4; in qla82xx_start_scsi()
3518 ctx->fcp_cmnd_len = 12 + 16 + 4; in qla82xx_start_scsi()
3521 cmd_pkt = (struct cmd_type_6 *)req->ring_ptr; in qla82xx_start_scsi()
3522 cmd_pkt->handle = make_handle(req->id, handle); in qla82xx_start_scsi()
3525 /* tagged queuing modifier -- default is TSK_SIMPLE (0). */ in qla82xx_start_scsi()
3527 memset(clr_ptr, 0, REQUEST_ENTRY_SIZE - 8); in qla82xx_start_scsi()
3528 cmd_pkt->dseg_count = cpu_to_le16(tot_dsds); in qla82xx_start_scsi()
3530 /* Set NPORT-ID and LUN number*/ in qla82xx_start_scsi()
3531 cmd_pkt->nport_handle = cpu_to_le16(sp->fcport->loop_id); in qla82xx_start_scsi()
3532 cmd_pkt->port_id[0] = sp->fcport->d_id.b.al_pa; in qla82xx_start_scsi()
3533 cmd_pkt->port_id[1] = sp->fcport->d_id.b.area; in qla82xx_start_scsi()
3534 cmd_pkt->port_id[2] = sp->fcport->d_id.b.domain; in qla82xx_start_scsi()
3535 cmd_pkt->vp_index = sp->vha->vp_idx; in qla82xx_start_scsi()
3541 int_to_scsilun(cmd->device->lun, &cmd_pkt->lun); in qla82xx_start_scsi()
3542 host_to_fcp_swap((uint8_t *)&cmd_pkt->lun, sizeof(cmd_pkt->lun)); in qla82xx_start_scsi()
3545 int_to_scsilun(cmd->device->lun, &ctx->fcp_cmnd->lun); in qla82xx_start_scsi()
3546 ctx->fcp_cmnd->additional_cdb_len = additional_cdb_len; in qla82xx_start_scsi()
3548 if (cmd->sc_data_direction == DMA_TO_DEVICE) in qla82xx_start_scsi()
3549 ctx->fcp_cmnd->additional_cdb_len |= 1; in qla82xx_start_scsi()
3550 else if (cmd->sc_data_direction == DMA_FROM_DEVICE) in qla82xx_start_scsi()
3551 ctx->fcp_cmnd->additional_cdb_len |= 2; in qla82xx_start_scsi()
3554 if (ha->flags.fcp_prio_enabled) in qla82xx_start_scsi()
3555 ctx->fcp_cmnd->task_attribute |= in qla82xx_start_scsi()
3556 sp->fcport->fcp_prio << 3; in qla82xx_start_scsi()
3558 memcpy(ctx->fcp_cmnd->cdb, cmd->cmnd, cmd->cmd_len); in qla82xx_start_scsi()
3560 fcp_dl = (__be32 *)(ctx->fcp_cmnd->cdb + 16 + in qla82xx_start_scsi()
3562 *fcp_dl = htonl((uint32_t)scsi_bufflen(cmd)); in qla82xx_start_scsi()
3564 cmd_pkt->fcp_cmnd_dseg_len = cpu_to_le16(ctx->fcp_cmnd_len); in qla82xx_start_scsi()
3565 put_unaligned_le64(ctx->fcp_cmnd_dma, in qla82xx_start_scsi()
3566 &cmd_pkt->fcp_cmnd_dseg_address); in qla82xx_start_scsi()
3568 sp->flags |= SRB_FCP_CMND_DMA_VALID; in qla82xx_start_scsi()
3569 cmd_pkt->byte_count = cpu_to_le32((uint32_t)scsi_bufflen(cmd)); in qla82xx_start_scsi()
3571 cmd_pkt->entry_count = (uint8_t)req_cnt; in qla82xx_start_scsi()
3575 cmd_pkt->entry_status = (uint8_t) rsp->id; in qla82xx_start_scsi()
3580 if (req->cnt < (req_cnt + 2)) { in qla82xx_start_scsi()
3581 cnt = (uint16_t)rd_reg_dword_relaxed( in qla82xx_start_scsi()
3582 ®->req_q_out[0]); in qla82xx_start_scsi()
3583 if (req->ring_index < cnt) in qla82xx_start_scsi()
3584 req->cnt = cnt - req->ring_index; in qla82xx_start_scsi()
3586 req->cnt = req->length - in qla82xx_start_scsi()
3587 (req->ring_index - cnt); in qla82xx_start_scsi()
3589 if (req->cnt < (req_cnt + 2)) in qla82xx_start_scsi()
3592 cmd_pkt = (struct cmd_type_7 *)req->ring_ptr; in qla82xx_start_scsi()
3593 cmd_pkt->handle = make_handle(req->id, handle); in qla82xx_start_scsi()
3596 /* tagged queuing modifier -- default is TSK_SIMPLE (0).*/ in qla82xx_start_scsi()
3598 memset(clr_ptr, 0, REQUEST_ENTRY_SIZE - 8); in qla82xx_start_scsi()
3599 cmd_pkt->dseg_count = cpu_to_le16(tot_dsds); in qla82xx_start_scsi()
3601 /* Set NPORT-ID and LUN number*/ in qla82xx_start_scsi()
3602 cmd_pkt->nport_handle = cpu_to_le16(sp->fcport->loop_id); in qla82xx_start_scsi()
3603 cmd_pkt->port_id[0] = sp->fcport->d_id.b.al_pa; in qla82xx_start_scsi()
3604 cmd_pkt->port_id[1] = sp->fcport->d_id.b.area; in qla82xx_start_scsi()
3605 cmd_pkt->port_id[2] = sp->fcport->d_id.b.domain; in qla82xx_start_scsi()
3606 cmd_pkt->vp_index = sp->vha->vp_idx; in qla82xx_start_scsi()
3608 int_to_scsilun(cmd->device->lun, &cmd_pkt->lun); in qla82xx_start_scsi()
3609 host_to_fcp_swap((uint8_t *)&cmd_pkt->lun, in qla82xx_start_scsi()
3610 sizeof(cmd_pkt->lun)); in qla82xx_start_scsi()
3613 if (ha->flags.fcp_prio_enabled) in qla82xx_start_scsi()
3614 cmd_pkt->task |= sp->fcport->fcp_prio << 3; in qla82xx_start_scsi()
3617 memcpy(cmd_pkt->fcp_cdb, cmd->cmnd, cmd->cmd_len); in qla82xx_start_scsi()
3618 host_to_fcp_swap(cmd_pkt->fcp_cdb, sizeof(cmd_pkt->fcp_cdb)); in qla82xx_start_scsi()
3620 cmd_pkt->byte_count = cpu_to_le32((uint32_t)scsi_bufflen(cmd)); in qla82xx_start_scsi()
3626 cmd_pkt->entry_count = (uint8_t)req_cnt; in qla82xx_start_scsi()
3630 cmd_pkt->entry_status = (uint8_t) rsp->id; in qla82xx_start_scsi()
3634 req->current_outstanding_cmd = handle; in qla82xx_start_scsi()
3635 req->outstanding_cmds[handle] = sp; in qla82xx_start_scsi()
3636 sp->handle = handle; in qla82xx_start_scsi()
3637 cmd->host_scribble = (unsigned char *)(unsigned long)handle; in qla82xx_start_scsi()
3638 req->cnt -= req_cnt; in qla82xx_start_scsi()
3642 req->ring_index++; in qla82xx_start_scsi()
3643 if (req->ring_index == req->length) { in qla82xx_start_scsi()
3644 req->ring_index = 0; in qla82xx_start_scsi()
3645 req->ring_ptr = req->ring; in qla82xx_start_scsi()
3647 req->ring_ptr++; in qla82xx_start_scsi()
3649 sp->flags |= SRB_DMA_VALID; in qla82xx_start_scsi()
3653 dbval = dbval | (req->id << 8) | (req->ring_index << 16); in qla82xx_start_scsi()
3655 qla82xx_wr_32(ha, (uintptr_t __force)ha->nxdb_wr_ptr, dbval); in qla82xx_start_scsi()
3657 wrt_reg_dword(ha->nxdb_wr_ptr, dbval); in qla82xx_start_scsi()
3659 while (rd_reg_dword(ha->nxdb_rd_ptr) != dbval) { in qla82xx_start_scsi()
3660 wrt_reg_dword(ha->nxdb_wr_ptr, dbval); in qla82xx_start_scsi()
3666 if (vha->flags.process_response_queue && in qla82xx_start_scsi()
3667 rsp->ring_ptr->signature != RESPONSE_PROCESSED) in qla82xx_start_scsi()
3670 spin_unlock_irqrestore(&ha->hardware_lock, flags); in qla82xx_start_scsi()
3674 dma_pool_free(ha->fcp_cmnd_dma_pool, ctx->fcp_cmnd, ctx->fcp_cmnd_dma); in qla82xx_start_scsi()
3677 scsi_dma_unmap(cmd); in qla82xx_start_scsi()
3679 if (sp->u.scmd.crc_ctx) { in qla82xx_start_scsi()
3680 mempool_free(sp->u.scmd.crc_ctx, ha->ctx_mempool); in qla82xx_start_scsi()
3681 sp->u.scmd.crc_ctx = NULL; in qla82xx_start_scsi()
3683 spin_unlock_irqrestore(&ha->hardware_lock, flags); in qla82xx_start_scsi()
3691 struct srb_iocb *aio = &sp->u.iocb_cmd; in qla24xx_abort_iocb()
3692 scsi_qla_host_t *vha = sp->vha; in qla24xx_abort_iocb()
3693 struct req_que *req = sp->qpair->req; in qla24xx_abort_iocb()
3694 srb_t *orig_sp = sp->cmd_sp; in qla24xx_abort_iocb()
3697 abt_iocb->entry_type = ABORT_IOCB_TYPE; in qla24xx_abort_iocb()
3698 abt_iocb->entry_count = 1; in qla24xx_abort_iocb()
3699 abt_iocb->handle = make_handle(req->id, sp->handle); in qla24xx_abort_iocb()
3700 if (sp->fcport) { in qla24xx_abort_iocb()
3701 abt_iocb->nport_handle = cpu_to_le16(sp->fcport->loop_id); in qla24xx_abort_iocb()
3702 abt_iocb->port_id[0] = sp->fcport->d_id.b.al_pa; in qla24xx_abort_iocb()
3703 abt_iocb->port_id[1] = sp->fcport->d_id.b.area; in qla24xx_abort_iocb()
3704 abt_iocb->port_id[2] = sp->fcport->d_id.b.domain; in qla24xx_abort_iocb()
3706 abt_iocb->handle_to_abort = in qla24xx_abort_iocb()
3707 make_handle(le16_to_cpu(aio->u.abt.req_que_no), in qla24xx_abort_iocb()
3708 aio->u.abt.cmd_hndl); in qla24xx_abort_iocb()
3709 abt_iocb->vp_index = vha->vp_idx; in qla24xx_abort_iocb()
3710 abt_iocb->req_que_no = aio->u.abt.req_que_no; in qla24xx_abort_iocb()
3725 mbx->entry_type = MBX_IOCB_TYPE; in qla2x00_mb_iocb()
3726 mbx->handle = sp->handle; in qla2x00_mb_iocb()
3727 sz = min(ARRAY_SIZE(mbx->mb), ARRAY_SIZE(sp->u.iocb_cmd.u.mbx.out_mb)); in qla2x00_mb_iocb()
3730 mbx->mb[i] = sp->u.iocb_cmd.u.mbx.out_mb[i]; in qla2x00_mb_iocb()
3736 sp->u.iocb_cmd.u.ctarg.iocb = ct_pkt; in qla2x00_ctpthru_cmd_iocb()
3737 qla24xx_prep_ms_iocb(sp->vha, &sp->u.iocb_cmd.u.ctarg); in qla2x00_ctpthru_cmd_iocb()
3738 ct_pkt->handle = sp->handle; in qla2x00_ctpthru_cmd_iocb()
3744 struct imm_ntfy_from_isp *ntfy = sp->u.iocb_cmd.u.nack.ntfy; in qla2x00_send_notify_ack_iocb()
3746 nack->entry_type = NOTIFY_ACK_TYPE; in qla2x00_send_notify_ack_iocb()
3747 nack->entry_count = 1; in qla2x00_send_notify_ack_iocb()
3748 nack->ox_id = ntfy->ox_id; in qla2x00_send_notify_ack_iocb()
3750 nack->u.isp24.handle = sp->handle; in qla2x00_send_notify_ack_iocb()
3751 nack->u.isp24.nport_handle = ntfy->u.isp24.nport_handle; in qla2x00_send_notify_ack_iocb()
3752 if (le16_to_cpu(ntfy->u.isp24.status) == IMM_NTFY_ELS) { in qla2x00_send_notify_ack_iocb()
3753 nack->u.isp24.flags = ntfy->u.isp24.flags & in qla2x00_send_notify_ack_iocb()
3756 nack->u.isp24.srr_rx_id = ntfy->u.isp24.srr_rx_id; in qla2x00_send_notify_ack_iocb()
3757 nack->u.isp24.status = ntfy->u.isp24.status; in qla2x00_send_notify_ack_iocb()
3758 nack->u.isp24.status_subcode = ntfy->u.isp24.status_subcode; in qla2x00_send_notify_ack_iocb()
3759 nack->u.isp24.fw_handle = ntfy->u.isp24.fw_handle; in qla2x00_send_notify_ack_iocb()
3760 nack->u.isp24.exchange_address = ntfy->u.isp24.exchange_address; in qla2x00_send_notify_ack_iocb()
3761 nack->u.isp24.srr_rel_offs = ntfy->u.isp24.srr_rel_offs; in qla2x00_send_notify_ack_iocb()
3762 nack->u.isp24.srr_ui = ntfy->u.isp24.srr_ui; in qla2x00_send_notify_ack_iocb()
3763 nack->u.isp24.srr_flags = 0; in qla2x00_send_notify_ack_iocb()
3764 nack->u.isp24.srr_reject_code = 0; in qla2x00_send_notify_ack_iocb()
3765 nack->u.isp24.srr_reject_code_expl = 0; in qla2x00_send_notify_ack_iocb()
3766 nack->u.isp24.vp_index = ntfy->u.isp24.vp_index; in qla2x00_send_notify_ack_iocb()
3768 if (ntfy->u.isp24.status_subcode == ELS_PLOGI && in qla2x00_send_notify_ack_iocb()
3769 (le16_to_cpu(ntfy->u.isp24.flags) & NOTIFY24XX_FLAGS_FCSP) && in qla2x00_send_notify_ack_iocb()
3770 sp->vha->hw->flags.edif_enabled) { in qla2x00_send_notify_ack_iocb()
3771 ql_dbg(ql_dbg_disc, sp->vha, 0x3074, in qla2x00_send_notify_ack_iocb()
3773 sp->name, sp->handle, sp->fcport->loop_id, in qla2x00_send_notify_ack_iocb()
3774 sp->fcport->d_id.b24); in qla2x00_send_notify_ack_iocb()
3775 nack->u.isp24.flags |= cpu_to_le16(NOTIFY_ACK_FLAGS_FCSP); in qla2x00_send_notify_ack_iocb()
3787 nvme = &sp->u.iocb_cmd; in qla_nvme_ls()
3788 cmd_pkt->entry_type = PT_LS4_REQUEST; in qla_nvme_ls()
3789 cmd_pkt->entry_count = 1; in qla_nvme_ls()
3790 cmd_pkt->timeout = cpu_to_le16(nvme->u.nvme.timeout_sec); in qla_nvme_ls()
3791 cmd_pkt->vp_index = sp->fcport->vha->vp_idx; in qla_nvme_ls()
3793 if (sp->unsol_rsp) { in qla_nvme_ls()
3794 cmd_pkt->control_flags = in qla_nvme_ls()
3796 cmd_pkt->nport_handle = nvme->u.nvme.nport_handle; in qla_nvme_ls()
3797 cmd_pkt->exchange_address = nvme->u.nvme.exchange_address; in qla_nvme_ls()
3799 cmd_pkt->control_flags = in qla_nvme_ls()
3801 cmd_pkt->nport_handle = cpu_to_le16(sp->fcport->loop_id); in qla_nvme_ls()
3802 cmd_pkt->rx_dseg_count = cpu_to_le16(1); in qla_nvme_ls()
3803 cmd_pkt->rx_byte_count = nvme->u.nvme.rsp_len; in qla_nvme_ls()
3804 cmd_pkt->dsd[1].length = nvme->u.nvme.rsp_len; in qla_nvme_ls()
3805 put_unaligned_le64(nvme->u.nvme.rsp_dma, &cmd_pkt->dsd[1].address); in qla_nvme_ls()
3808 cmd_pkt->tx_dseg_count = cpu_to_le16(1); in qla_nvme_ls()
3809 cmd_pkt->tx_byte_count = nvme->u.nvme.cmd_len; in qla_nvme_ls()
3810 cmd_pkt->dsd[0].length = nvme->u.nvme.cmd_len; in qla_nvme_ls()
3811 put_unaligned_le64(nvme->u.nvme.cmd_dma, &cmd_pkt->dsd[0].address); in qla_nvme_ls()
3819 vce->entry_type = VP_CTRL_IOCB_TYPE; in qla25xx_ctrlvp_iocb()
3820 vce->handle = sp->handle; in qla25xx_ctrlvp_iocb()
3821 vce->entry_count = 1; in qla25xx_ctrlvp_iocb()
3822 vce->command = cpu_to_le16(sp->u.iocb_cmd.u.ctrlvp.cmd); in qla25xx_ctrlvp_iocb()
3823 vce->vp_count = cpu_to_le16(1); in qla25xx_ctrlvp_iocb()
3829 map = (sp->u.iocb_cmd.u.ctrlvp.vp_index - 1) / 8; in qla25xx_ctrlvp_iocb()
3830 pos = (sp->u.iocb_cmd.u.ctrlvp.vp_index - 1) & 7; in qla25xx_ctrlvp_iocb()
3831 vce->vp_idx_map[map] |= 1 << pos; in qla25xx_ctrlvp_iocb()
3837 logio->entry_type = LOGINOUT_PORT_IOCB_TYPE; in qla24xx_prlo_iocb()
3838 logio->control_flags = in qla24xx_prlo_iocb()
3841 logio->nport_handle = cpu_to_le16(sp->fcport->loop_id); in qla24xx_prlo_iocb()
3842 logio->port_id[0] = sp->fcport->d_id.b.al_pa; in qla24xx_prlo_iocb()
3843 logio->port_id[1] = sp->fcport->d_id.b.area; in qla24xx_prlo_iocb()
3844 logio->port_id[2] = sp->fcport->d_id.b.domain; in qla24xx_prlo_iocb()
3845 logio->vp_index = sp->fcport->vha->vp_idx; in qla24xx_prlo_iocb()
3854 sp->iores.res_type = RESOURCE_NONE; in qla_get_iocbs_resource()
3857 sp->iores.res_type = RESOURCE_NONE; in qla_get_iocbs_resource()
3859 switch (sp->type) { in qla_get_iocbs_resource()
3877 sp->iores.res_type = RESOURCE_NONE; in qla_get_iocbs_resource()
3895 sp->iores.res_type |= RESOURCE_IOCB; in qla_get_iocbs_resource()
3896 sp->iores.iocb_cnt = 1; in qla_get_iocbs_resource()
3898 sp->iores.res_type |= RESOURCE_EXCH; in qla_get_iocbs_resource()
3899 sp->iores.exch_cnt = 1; in qla_get_iocbs_resource()
3902 sp->iores.res_type |= RESOURCE_FORCE; in qla_get_iocbs_resource()
3904 return qla_get_fw_resources(sp->qpair, &sp->iores); in qla_get_iocbs_resource()
3910 mrk->entry_type = MARKER_TYPE; in qla_marker_iocb()
3911 mrk->modifier = sp->u.iocb_cmd.u.tmf.modifier; in qla_marker_iocb()
3912 mrk->handle = make_handle(sp->qpair->req->id, sp->handle); in qla_marker_iocb()
3913 if (sp->u.iocb_cmd.u.tmf.modifier != MK_SYNC_ALL) { in qla_marker_iocb()
3914 mrk->nport_handle = cpu_to_le16(sp->u.iocb_cmd.u.tmf.loop_id); in qla_marker_iocb()
3915 int_to_scsilun(sp->u.iocb_cmd.u.tmf.lun, (struct scsi_lun *)&mrk->lun); in qla_marker_iocb()
3916 host_to_fcp_swap(mrk->lun, sizeof(mrk->lun)); in qla_marker_iocb()
3917 mrk->vp_index = sp->u.iocb_cmd.u.tmf.vp_index; in qla_marker_iocb()
3925 scsi_qla_host_t *vha = sp->vha; in qla2x00_start_sp()
3926 struct qla_hw_data *ha = vha->hw; in qla2x00_start_sp()
3927 struct qla_qpair *qp = sp->qpair; in qla2x00_start_sp()
3931 if (vha->hw->flags.eeh_busy) in qla2x00_start_sp()
3932 return -EIO; in qla2x00_start_sp()
3934 spin_lock_irqsave(qp->qp_lock_ptr, flags); in qla2x00_start_sp()
3937 spin_unlock_irqrestore(qp->qp_lock_ptr, flags); in qla2x00_start_sp()
3938 return -EAGAIN; in qla2x00_start_sp()
3941 pkt = qla2x00_alloc_iocbs_ready(sp->qpair, sp); in qla2x00_start_sp()
3943 rval = -EAGAIN; in qla2x00_start_sp()
3949 switch (sp->type) { in qla2x00_start_sp()
3968 qla_els_pt_iocb(sp->vha, pkt, &sp->u.bsg_cmd.u.els_arg); in qla2x00_start_sp()
3969 ((struct els_entry_24xx *)pkt)->handle = sp->handle; in qla2x00_start_sp()
4031 if (sp->start_timer) { in qla2x00_start_sp()
4037 kref_get(&sp->cmd_kref); in qla2x00_start_sp()
4038 add_timer(&sp->u.iocb_cmd.timer); in qla2x00_start_sp()
4042 qla2x00_start_iocbs(vha, qp->req); in qla2x00_start_sp()
4045 qla_put_fw_resources(sp->qpair, &sp->iores); in qla2x00_start_sp()
4046 spin_unlock_irqrestore(qp->qp_lock_ptr, flags); in qla2x00_start_sp()
4061 struct bsg_job *bsg_job = sp->u.bsg_job; in qla25xx_build_bidir_iocb()
4064 put_unaligned_le32(COMMAND_BIDIRECTIONAL, &cmd_pkt->entry_type); in qla25xx_build_bidir_iocb()
4070 cmd_pkt->wr_dseg_count = cpu_to_le16(bsg_job->request_payload.sg_cnt); in qla25xx_build_bidir_iocb()
4071 cmd_pkt->rd_dseg_count = cpu_to_le16(bsg_job->reply_payload.sg_cnt); in qla25xx_build_bidir_iocb()
4072 cmd_pkt->control_flags = cpu_to_le16(BD_WRITE_DATA | BD_READ_DATA | in qla25xx_build_bidir_iocb()
4075 req_data_len = rsp_data_len = bsg_job->request_payload.payload_len; in qla25xx_build_bidir_iocb()
4076 cmd_pkt->wr_byte_count = cpu_to_le32(req_data_len); in qla25xx_build_bidir_iocb()
4077 cmd_pkt->rd_byte_count = cpu_to_le32(rsp_data_len); in qla25xx_build_bidir_iocb()
4078 cmd_pkt->timeout = cpu_to_le16(qla2x00_get_async_timeout(vha) + 2); in qla25xx_build_bidir_iocb()
4080 vha->bidi_stats.transfer_bytes += req_data_len; in qla25xx_build_bidir_iocb()
4081 vha->bidi_stats.io_count++; in qla25xx_build_bidir_iocb()
4083 vha->qla_stats.output_bytes += req_data_len; in qla25xx_build_bidir_iocb()
4084 vha->qla_stats.output_requests++; in qla25xx_build_bidir_iocb()
4090 cur_dsd = &cmd_pkt->fcp_dsd; in qla25xx_build_bidir_iocb()
4094 for_each_sg(bsg_job->request_payload.sg_list, sg, in qla25xx_build_bidir_iocb()
4095 bsg_job->request_payload.sg_cnt, index) { in qla25xx_build_bidir_iocb()
4103 cont_pkt = qla2x00_prep_cont_type1_iocb(vha, vha->req); in qla25xx_build_bidir_iocb()
4104 cur_dsd = cont_pkt->dsd; in qla25xx_build_bidir_iocb()
4109 avail_dsds--; in qla25xx_build_bidir_iocb()
4116 for_each_sg(bsg_job->reply_payload.sg_list, sg, in qla25xx_build_bidir_iocb()
4117 bsg_job->reply_payload.sg_cnt, index) { in qla25xx_build_bidir_iocb()
4125 cont_pkt = qla2x00_prep_cont_type1_iocb(vha, vha->req); in qla25xx_build_bidir_iocb()
4126 cur_dsd = cont_pkt->dsd; in qla25xx_build_bidir_iocb()
4131 avail_dsds--; in qla25xx_build_bidir_iocb()
4133 /* This value should be same as number of IOCB required for this cmd */ in qla25xx_build_bidir_iocb()
4134 cmd_pkt->entry_count = entry_count; in qla25xx_build_bidir_iocb()
4141 struct qla_hw_data *ha = vha->hw; in qla2x00_start_bidir()
4145 uint16_t cnt; in qla2x00_start_bidir() local
4154 rsp = ha->rsp_q_map[0]; in qla2x00_start_bidir()
4155 req = vha->req; in qla2x00_start_bidir()
4158 if (vha->marker_needed != 0) { in qla2x00_start_bidir()
4159 if (qla2x00_marker(vha, ha->base_qpair, in qla2x00_start_bidir()
4162 vha->marker_needed = 0; in qla2x00_start_bidir()
4166 spin_lock_irqsave(&ha->hardware_lock, flags); in qla2x00_start_bidir()
4178 if (req->cnt < req_cnt + 2) { in qla2x00_start_bidir()
4180 cnt = *req->out_ptr; in qla2x00_start_bidir()
4182 cnt = rd_reg_dword_relaxed(req->req_q_out); in qla2x00_start_bidir()
4183 if (qla2x00_check_reg16_for_disconnect(vha, cnt)) in qla2x00_start_bidir()
4187 if (req->ring_index < cnt) in qla2x00_start_bidir()
4188 req->cnt = cnt - req->ring_index; in qla2x00_start_bidir()
4190 req->cnt = req->length - in qla2x00_start_bidir()
4191 (req->ring_index - cnt); in qla2x00_start_bidir()
4193 if (req->cnt < req_cnt + 2) { in qla2x00_start_bidir()
4198 cmd_pkt = (struct cmd_bidir *)req->ring_ptr; in qla2x00_start_bidir()
4199 cmd_pkt->handle = make_handle(req->id, handle); in qla2x00_start_bidir()
4202 /* tagged queuing modifier -- default is TSK_SIMPLE (0).*/ in qla2x00_start_bidir()
4204 memset(clr_ptr, 0, REQUEST_ENTRY_SIZE - 8); in qla2x00_start_bidir()
4206 /* Set NPORT-ID (of vha)*/ in qla2x00_start_bidir()
4207 cmd_pkt->nport_handle = cpu_to_le16(vha->self_login_loop_id); in qla2x00_start_bidir()
4208 cmd_pkt->port_id[0] = vha->d_id.b.al_pa; in qla2x00_start_bidir()
4209 cmd_pkt->port_id[1] = vha->d_id.b.area; in qla2x00_start_bidir()
4210 cmd_pkt->port_id[2] = vha->d_id.b.domain; in qla2x00_start_bidir()
4213 cmd_pkt->entry_status = (uint8_t) rsp->id; in qla2x00_start_bidir()
4215 req->current_outstanding_cmd = handle; in qla2x00_start_bidir()
4216 req->outstanding_cmds[handle] = sp; in qla2x00_start_bidir()
4217 sp->handle = handle; in qla2x00_start_bidir()
4218 req->cnt -= req_cnt; in qla2x00_start_bidir()
4224 spin_unlock_irqrestore(&ha->hardware_lock, flags); in qla2x00_start_bidir()
4230 * qla_start_scsi_type6() - Send a SCSI command to the ISP
4233 * Returns non-zero if a failure occurred, else zero.
4243 uint16_t cnt; in qla_start_scsi_type6() local
4248 struct scsi_cmnd *cmd = GET_CMD_SP(sp); in qla_start_scsi_type6() local
4249 struct scsi_qla_host *vha = sp->fcport->vha; in qla_start_scsi_type6()
4250 struct qla_hw_data *ha = vha->hw; in qla_start_scsi_type6()
4251 struct qla_qpair *qpair = sp->qpair; in qla_start_scsi_type6()
4260 spin_lock_irqsave(&qpair->qp_lock, flags); in qla_start_scsi_type6()
4263 req = qpair->req; in qla_start_scsi_type6()
4264 rsp = qpair->rsp; in qla_start_scsi_type6()
4270 if (vha->marker_needed != 0) { in qla_start_scsi_type6()
4272 spin_unlock_irqrestore(&qpair->qp_lock, flags); in qla_start_scsi_type6()
4275 vha->marker_needed = 0; in qla_start_scsi_type6()
4283 if (scsi_sg_count(cmd)) { in qla_start_scsi_type6()
4284 nseg = dma_map_sg(&ha->pdev->dev, scsi_sglist(cmd), in qla_start_scsi_type6()
4285 scsi_sg_count(cmd), cmd->sc_data_direction); in qla_start_scsi_type6()
4297 sp->iores.res_type = RESOURCE_IOCB | RESOURCE_EXCH; in qla_start_scsi_type6()
4298 sp->iores.exch_cnt = 1; in qla_start_scsi_type6()
4299 sp->iores.iocb_cnt = req_cnt; in qla_start_scsi_type6()
4301 if (qla_get_fw_resources(sp->qpair, &sp->iores)) in qla_start_scsi_type6()
4305 if ((more_dsd_lists + qpair->dsd_inuse) >= NUM_DSD_CHAIN) { in qla_start_scsi_type6()
4307 "Num of DSD list %d is than %d for cmd=%p.\n", in qla_start_scsi_type6()
4308 more_dsd_lists + qpair->dsd_inuse, NUM_DSD_CHAIN, cmd); in qla_start_scsi_type6()
4312 if (more_dsd_lists <= qpair->dsd_avail) in qla_start_scsi_type6()
4315 more_dsd_lists -= qpair->dsd_avail; in qla_start_scsi_type6()
4321 "Failed to allocate memory for dsd_dma for cmd=%p.\n", cmd); in qla_start_scsi_type6()
4324 INIT_LIST_HEAD(&dsd_ptr->list); in qla_start_scsi_type6()
4326 dsd_ptr->dsd_addr = dma_pool_alloc(ha->dl_dma_pool, in qla_start_scsi_type6()
4327 GFP_ATOMIC, &dsd_ptr->dsd_list_dma); in qla_start_scsi_type6()
4328 if (!dsd_ptr->dsd_addr) { in qla_start_scsi_type6()
4331 "Failed to allocate memory for dsd_addr for cmd=%p.\n", cmd); in qla_start_scsi_type6()
4334 list_add_tail(&dsd_ptr->list, &qpair->dsd_list); in qla_start_scsi_type6()
4335 qpair->dsd_avail++; in qla_start_scsi_type6()
4341 if (req->cnt < (req_cnt + 2)) { in qla_start_scsi_type6()
4343 cnt = *req->out_ptr; in qla_start_scsi_type6()
4345 cnt = (uint16_t)rd_reg_dword_relaxed(req->req_q_out); in qla_start_scsi_type6()
4346 if (qla2x00_check_reg16_for_disconnect(vha, cnt)) in qla_start_scsi_type6()
4350 if (req->ring_index < cnt) in qla_start_scsi_type6()
4351 req->cnt = cnt - req->ring_index; in qla_start_scsi_type6()
4353 req->cnt = req->length - (req->ring_index - cnt); in qla_start_scsi_type6()
4354 if (req->cnt < (req_cnt + 2)) in qla_start_scsi_type6()
4358 ctx = &sp->u.scmd.ct6_ctx; in qla_start_scsi_type6()
4361 ctx->fcp_cmnd = dma_pool_zalloc(ha->fcp_cmnd_dma_pool, in qla_start_scsi_type6()
4362 GFP_ATOMIC, &ctx->fcp_cmnd_dma); in qla_start_scsi_type6()
4363 if (!ctx->fcp_cmnd) { in qla_start_scsi_type6()
4365 "Failed to allocate fcp_cmnd for cmd=%p.\n", cmd); in qla_start_scsi_type6()
4370 INIT_LIST_HEAD(&ctx->dsd_list); in qla_start_scsi_type6()
4371 ctx->dsd_use_cnt = 0; in qla_start_scsi_type6()
4373 if (cmd->cmd_len > 16) { in qla_start_scsi_type6()
4374 additional_cdb_len = cmd->cmd_len - 16; in qla_start_scsi_type6()
4375 if (cmd->cmd_len % 4 || in qla_start_scsi_type6()
4376 cmd->cmd_len > QLA_CDB_BUF_SIZE) { in qla_start_scsi_type6()
4382 "scsi cmd len %d not multiple of 4 for cmd=%p.\n", in qla_start_scsi_type6()
4383 cmd->cmd_len, cmd); in qla_start_scsi_type6()
4386 ctx->fcp_cmnd_len = 12 + cmd->cmd_len + 4; in qla_start_scsi_type6()
4389 ctx->fcp_cmnd_len = 12 + 16 + 4; in qla_start_scsi_type6()
4393 req->current_outstanding_cmd = handle; in qla_start_scsi_type6()
4394 req->outstanding_cmds[handle] = sp; in qla_start_scsi_type6()
4395 sp->handle = handle; in qla_start_scsi_type6()
4396 cmd->host_scribble = (unsigned char *)(unsigned long)handle; in qla_start_scsi_type6()
4397 req->cnt -= req_cnt; in qla_start_scsi_type6()
4399 cmd_pkt = (struct cmd_type_6 *)req->ring_ptr; in qla_start_scsi_type6()
4400 cmd_pkt->handle = make_handle(req->id, handle); in qla_start_scsi_type6()
4402 /* tagged queuing modifier -- default is TSK_SIMPLE (0). */ in qla_start_scsi_type6()
4404 memset(clr_ptr, 0, REQUEST_ENTRY_SIZE - 8); in qla_start_scsi_type6()
4405 cmd_pkt->dseg_count = cpu_to_le16(tot_dsds); in qla_start_scsi_type6()
4407 /* Set NPORT-ID and LUN number */ in qla_start_scsi_type6()
4408 cmd_pkt->nport_handle = cpu_to_le16(sp->fcport->loop_id); in qla_start_scsi_type6()
4409 cmd_pkt->port_id[0] = sp->fcport->d_id.b.al_pa; in qla_start_scsi_type6()
4410 cmd_pkt->port_id[1] = sp->fcport->d_id.b.area; in qla_start_scsi_type6()
4411 cmd_pkt->port_id[2] = sp->fcport->d_id.b.domain; in qla_start_scsi_type6()
4412 cmd_pkt->vp_index = sp->vha->vp_idx; in qla_start_scsi_type6()
4417 int_to_scsilun(cmd->device->lun, &cmd_pkt->lun); in qla_start_scsi_type6()
4418 host_to_fcp_swap((uint8_t *)&cmd_pkt->lun, sizeof(cmd_pkt->lun)); in qla_start_scsi_type6()
4421 int_to_scsilun(cmd->device->lun, &ctx->fcp_cmnd->lun); in qla_start_scsi_type6()
4422 ctx->fcp_cmnd->additional_cdb_len = additional_cdb_len; in qla_start_scsi_type6()
4424 if (cmd->sc_data_direction == DMA_TO_DEVICE) in qla_start_scsi_type6()
4425 ctx->fcp_cmnd->additional_cdb_len |= 1; in qla_start_scsi_type6()
4426 else if (cmd->sc_data_direction == DMA_FROM_DEVICE) in qla_start_scsi_type6()
4427 ctx->fcp_cmnd->additional_cdb_len |= 2; in qla_start_scsi_type6()
4430 if (ha->flags.fcp_prio_enabled) in qla_start_scsi_type6()
4431 ctx->fcp_cmnd->task_attribute |= in qla_start_scsi_type6()
4432 sp->fcport->fcp_prio << 3; in qla_start_scsi_type6()
4434 memcpy(ctx->fcp_cmnd->cdb, cmd->cmnd, cmd->cmd_len); in qla_start_scsi_type6()
4436 fcp_dl = (__be32 *)(ctx->fcp_cmnd->cdb + 16 + in qla_start_scsi_type6()
4438 *fcp_dl = htonl((uint32_t)scsi_bufflen(cmd)); in qla_start_scsi_type6()
4440 cmd_pkt->fcp_cmnd_dseg_len = cpu_to_le16(ctx->fcp_cmnd_len); in qla_start_scsi_type6()
4441 put_unaligned_le64(ctx->fcp_cmnd_dma, in qla_start_scsi_type6()
4442 &cmd_pkt->fcp_cmnd_dseg_address); in qla_start_scsi_type6()
4444 sp->flags |= SRB_FCP_CMND_DMA_VALID; in qla_start_scsi_type6()
4445 cmd_pkt->byte_count = cpu_to_le32((uint32_t)scsi_bufflen(cmd)); in qla_start_scsi_type6()
4447 cmd_pkt->entry_count = (uint8_t)req_cnt; in qla_start_scsi_type6()
4451 req->ring_index++; in qla_start_scsi_type6()
4452 if (req->ring_index == req->length) { in qla_start_scsi_type6()
4453 req->ring_index = 0; in qla_start_scsi_type6()
4454 req->ring_ptr = req->ring; in qla_start_scsi_type6()
4456 req->ring_ptr++; in qla_start_scsi_type6()
4459 sp->qpair->cmd_cnt++; in qla_start_scsi_type6()
4460 sp->flags |= SRB_DMA_VALID; in qla_start_scsi_type6()
4463 wrt_reg_dword(req->req_q_in, req->ring_index); in qla_start_scsi_type6()
4466 if (vha->flags.process_response_queue && in qla_start_scsi_type6()
4467 rsp->ring_ptr->signature != RESPONSE_PROCESSED) in qla_start_scsi_type6()
4470 spin_unlock_irqrestore(&qpair->qp_lock, flags); in qla_start_scsi_type6()
4475 dma_pool_free(ha->fcp_cmnd_dma_pool, ctx->fcp_cmnd, ctx->fcp_cmnd_dma); in qla_start_scsi_type6()
4479 scsi_dma_unmap(cmd); in qla_start_scsi_type6()
4481 qla_put_fw_resources(sp->qpair, &sp->iores); in qla_start_scsi_type6()
4483 if (sp->u.scmd.crc_ctx) { in qla_start_scsi_type6()
4484 mempool_free(sp->u.scmd.crc_ctx, ha->ctx_mempool); in qla_start_scsi_type6()
4485 sp->u.scmd.crc_ctx = NULL; in qla_start_scsi_type6()
4488 spin_unlock_irqrestore(&qpair->qp_lock, flags); in qla_start_scsi_type6()