2 * QLogic Fibre Channel HBA Driver
3 * Copyright (c) 2003-2008 QLogic Corporation
5 * See LICENSE.qla2xxx for copyright and licensing details.
9 #include <linux/blkdev.h>
10 #include <linux/delay.h>
12 #include <scsi/scsi_tcq.h>
14 static request_t *qla2x00_req_pkt(struct scsi_qla_host *, struct req_que *,
16 static void qla2x00_isp_cmd(struct scsi_qla_host *, struct req_que *);
18 static void qla25xx_set_que(srb_t *, struct req_que **, struct rsp_que **);
20 * qla2x00_get_cmd_direction() - Determine control_flag data direction.
23 * Returns the proper CF_* direction based on CDB.
25 static inline uint16_t
26 qla2x00_get_cmd_direction(srb_t *sp)
32 /* Set transfer direction */
33 if (sp->cmd->sc_data_direction == DMA_TO_DEVICE) {
35 sp->fcport->vha->hw->qla_stats.output_bytes +=
36 scsi_bufflen(sp->cmd);
37 } else if (sp->cmd->sc_data_direction == DMA_FROM_DEVICE) {
39 sp->fcport->vha->hw->qla_stats.input_bytes +=
40 scsi_bufflen(sp->cmd);
46 * qla2x00_calc_iocbs_32() - Determine number of Command Type 2 and
47 * Continuation Type 0 IOCBs to allocate.
49 * @dsds: number of data segment decriptors needed
51 * Returns the number of IOCB entries needed to store @dsds.
54 qla2x00_calc_iocbs_32(uint16_t dsds)
60 iocbs += (dsds - 3) / 7;
68 * qla2x00_calc_iocbs_64() - Determine number of Command Type 3 and
69 * Continuation Type 1 IOCBs to allocate.
71 * @dsds: number of data segment decriptors needed
73 * Returns the number of IOCB entries needed to store @dsds.
76 qla2x00_calc_iocbs_64(uint16_t dsds)
82 iocbs += (dsds - 2) / 5;
90 * qla2x00_prep_cont_type0_iocb() - Initialize a Continuation Type 0 IOCB.
93 * Returns a pointer to the Continuation Type 0 IOCB packet.
95 static inline cont_entry_t *
96 qla2x00_prep_cont_type0_iocb(struct req_que *req, struct scsi_qla_host *vha)
98 cont_entry_t *cont_pkt;
99 /* Adjust ring index. */
101 if (req->ring_index == req->length) {
103 req->ring_ptr = req->ring;
108 cont_pkt = (cont_entry_t *)req->ring_ptr;
110 /* Load packet defaults. */
111 *((uint32_t *)(&cont_pkt->entry_type)) =
112 __constant_cpu_to_le32(CONTINUE_TYPE);
118 * qla2x00_prep_cont_type1_iocb() - Initialize a Continuation Type 1 IOCB.
121 * Returns a pointer to the continuation type 1 IOCB packet.
123 static inline cont_a64_entry_t *
124 qla2x00_prep_cont_type1_iocb(struct req_que *req, scsi_qla_host_t *vha)
126 cont_a64_entry_t *cont_pkt;
128 /* Adjust ring index. */
130 if (req->ring_index == req->length) {
132 req->ring_ptr = req->ring;
137 cont_pkt = (cont_a64_entry_t *)req->ring_ptr;
139 /* Load packet defaults. */
140 *((uint32_t *)(&cont_pkt->entry_type)) =
141 __constant_cpu_to_le32(CONTINUE_A64_TYPE);
147 * qla2x00_build_scsi_iocbs_32() - Build IOCB command utilizing 32bit
148 * capable IOCB types.
150 * @sp: SRB command to process
151 * @cmd_pkt: Command type 2 IOCB
152 * @tot_dsds: Total number of segments to transfer
154 void qla2x00_build_scsi_iocbs_32(srb_t *sp, cmd_entry_t *cmd_pkt,
159 scsi_qla_host_t *vha;
160 struct scsi_cmnd *cmd;
161 struct scatterlist *sg;
167 /* Update entry type to indicate Command Type 2 IOCB */
168 *((uint32_t *)(&cmd_pkt->entry_type)) =
169 __constant_cpu_to_le32(COMMAND_TYPE);
171 /* No data transfer */
172 if (!scsi_bufflen(cmd) || cmd->sc_data_direction == DMA_NONE) {
173 cmd_pkt->byte_count = __constant_cpu_to_le32(0);
177 vha = sp->fcport->vha;
180 cmd_pkt->control_flags |= cpu_to_le16(qla2x00_get_cmd_direction(sp));
182 /* Three DSDs are available in the Command Type 2 IOCB */
184 cur_dsd = (uint32_t *)&cmd_pkt->dseg_0_address;
186 /* Load data segments */
187 scsi_for_each_sg(cmd, sg, tot_dsds, i) {
188 cont_entry_t *cont_pkt;
190 /* Allocate additional continuation packets? */
191 if (avail_dsds == 0) {
193 * Seven DSDs are available in the Continuation
196 cont_pkt = qla2x00_prep_cont_type0_iocb(req, vha);
197 cur_dsd = (uint32_t *)&cont_pkt->dseg_0_address;
201 *cur_dsd++ = cpu_to_le32(sg_dma_address(sg));
202 *cur_dsd++ = cpu_to_le32(sg_dma_len(sg));
208 * qla2x00_build_scsi_iocbs_64() - Build IOCB command utilizing 64bit
209 * capable IOCB types.
211 * @sp: SRB command to process
212 * @cmd_pkt: Command type 3 IOCB
213 * @tot_dsds: Total number of segments to transfer
215 void qla2x00_build_scsi_iocbs_64(srb_t *sp, cmd_entry_t *cmd_pkt,
220 scsi_qla_host_t *vha;
221 struct scsi_cmnd *cmd;
222 struct scatterlist *sg;
228 /* Update entry type to indicate Command Type 3 IOCB */
229 *((uint32_t *)(&cmd_pkt->entry_type)) =
230 __constant_cpu_to_le32(COMMAND_A64_TYPE);
232 /* No data transfer */
233 if (!scsi_bufflen(cmd) || cmd->sc_data_direction == DMA_NONE) {
234 cmd_pkt->byte_count = __constant_cpu_to_le32(0);
238 vha = sp->fcport->vha;
241 cmd_pkt->control_flags |= cpu_to_le16(qla2x00_get_cmd_direction(sp));
243 /* Two DSDs are available in the Command Type 3 IOCB */
245 cur_dsd = (uint32_t *)&cmd_pkt->dseg_0_address;
247 /* Load data segments */
248 scsi_for_each_sg(cmd, sg, tot_dsds, i) {
250 cont_a64_entry_t *cont_pkt;
252 /* Allocate additional continuation packets? */
253 if (avail_dsds == 0) {
255 * Five DSDs are available in the Continuation
258 cont_pkt = qla2x00_prep_cont_type1_iocb(req, vha);
259 cur_dsd = (uint32_t *)cont_pkt->dseg_0_address;
263 sle_dma = sg_dma_address(sg);
264 *cur_dsd++ = cpu_to_le32(LSD(sle_dma));
265 *cur_dsd++ = cpu_to_le32(MSD(sle_dma));
266 *cur_dsd++ = cpu_to_le32(sg_dma_len(sg));
272 * qla2x00_start_scsi() - Send a SCSI command to the ISP
273 * @sp: command to send to the ISP
275 * Returns non-zero if a failure occurred, else zero.
278 qla2x00_start_scsi(srb_t *sp)
282 scsi_qla_host_t *vha;
283 struct scsi_cmnd *cmd;
287 cmd_entry_t *cmd_pkt;
291 struct device_reg_2xxx __iomem *reg;
292 struct qla_hw_data *ha;
296 /* Setup device pointers. */
298 vha = sp->fcport->vha;
300 reg = &ha->iobase->isp;
302 req = ha->req_q_map[0];
303 rsp = ha->rsp_q_map[0];
304 /* So we know we haven't pci_map'ed anything yet */
307 /* Send marker if required */
308 if (vha->marker_needed != 0) {
309 if (qla2x00_marker(vha, req, rsp, 0, 0, MK_SYNC_ALL)
311 return (QLA_FUNCTION_FAILED);
312 vha->marker_needed = 0;
315 /* Acquire ring specific lock */
316 spin_lock_irqsave(&ha->hardware_lock, flags);
318 /* Check for room in outstanding command list. */
319 handle = req->current_outstanding_cmd;
320 for (index = 1; index < MAX_OUTSTANDING_COMMANDS; index++) {
322 if (handle == MAX_OUTSTANDING_COMMANDS)
324 if (!req->outstanding_cmds[handle])
327 if (index == MAX_OUTSTANDING_COMMANDS)
330 /* Map the sg table so we have an accurate count of sg entries needed */
331 if (scsi_sg_count(cmd)) {
332 nseg = dma_map_sg(&ha->pdev->dev, scsi_sglist(cmd),
333 scsi_sg_count(cmd), cmd->sc_data_direction);
341 /* Calculate the number of request entries needed. */
342 req_cnt = ha->isp_ops->calc_req_entries(tot_dsds);
343 if (req->cnt < (req_cnt + 2)) {
344 cnt = RD_REG_WORD_RELAXED(ISP_REQ_Q_OUT(ha, reg));
345 if (req->ring_index < cnt)
346 req->cnt = cnt - req->ring_index;
348 req->cnt = req->length -
349 (req->ring_index - cnt);
351 if (req->cnt < (req_cnt + 2))
354 /* Build command packet */
355 req->current_outstanding_cmd = handle;
356 req->outstanding_cmds[handle] = sp;
358 sp->cmd->host_scribble = (unsigned char *)(unsigned long)handle;
361 cmd_pkt = (cmd_entry_t *)req->ring_ptr;
362 cmd_pkt->handle = handle;
363 /* Zero out remaining portion of packet. */
364 clr_ptr = (uint32_t *)cmd_pkt + 2;
365 memset(clr_ptr, 0, REQUEST_ENTRY_SIZE - 8);
366 cmd_pkt->dseg_count = cpu_to_le16(tot_dsds);
368 /* Set target ID and LUN number*/
369 SET_TARGET_ID(ha, cmd_pkt->target, sp->fcport->loop_id);
370 cmd_pkt->lun = cpu_to_le16(sp->cmd->device->lun);
372 /* Update tagged queuing modifier */
373 cmd_pkt->control_flags = __constant_cpu_to_le16(CF_SIMPLE_TAG);
375 /* Load SCSI command packet. */
376 memcpy(cmd_pkt->scsi_cdb, cmd->cmnd, cmd->cmd_len);
377 cmd_pkt->byte_count = cpu_to_le32((uint32_t)scsi_bufflen(cmd));
379 /* Build IOCB segments */
380 ha->isp_ops->build_iocbs(sp, cmd_pkt, tot_dsds);
382 /* Set total data segment count. */
383 cmd_pkt->entry_count = (uint8_t)req_cnt;
386 /* Adjust ring index. */
388 if (req->ring_index == req->length) {
390 req->ring_ptr = req->ring;
394 sp->flags |= SRB_DMA_VALID;
396 /* Set chip new ring index. */
397 WRT_REG_WORD(ISP_REQ_Q_IN(ha, reg), req->ring_index);
398 RD_REG_WORD_RELAXED(ISP_REQ_Q_IN(ha, reg)); /* PCI Posting. */
400 /* Manage unprocessed RIO/ZIO commands in response queue. */
401 if (vha->flags.process_response_queue &&
402 rsp->ring_ptr->signature != RESPONSE_PROCESSED)
403 qla2x00_process_response_queue(rsp);
405 spin_unlock_irqrestore(&ha->hardware_lock, flags);
406 return (QLA_SUCCESS);
412 spin_unlock_irqrestore(&ha->hardware_lock, flags);
414 return (QLA_FUNCTION_FAILED);
418 * qla2x00_marker() - Send a marker IOCB to the firmware.
422 * @type: marker modifier
424 * Can be called from both normal and interrupt context.
426 * Returns non-zero if a failure occurred, else zero.
429 __qla2x00_marker(struct scsi_qla_host *vha, struct req_que *req,
430 struct rsp_que *rsp, uint16_t loop_id,
431 uint16_t lun, uint8_t type)
434 struct mrk_entry_24xx *mrk24;
435 struct qla_hw_data *ha = vha->hw;
436 scsi_qla_host_t *base_vha = pci_get_drvdata(ha->pdev);
439 mrk = (mrk_entry_t *)qla2x00_req_pkt(vha, req, rsp);
441 DEBUG2_3(printk("%s(%ld): failed to allocate Marker IOCB.\n",
442 __func__, base_vha->host_no));
444 return (QLA_FUNCTION_FAILED);
447 mrk->entry_type = MARKER_TYPE;
448 mrk->modifier = type;
449 if (type != MK_SYNC_ALL) {
450 if (IS_FWI2_CAPABLE(ha)) {
451 mrk24 = (struct mrk_entry_24xx *) mrk;
452 mrk24->nport_handle = cpu_to_le16(loop_id);
453 mrk24->lun[1] = LSB(lun);
454 mrk24->lun[2] = MSB(lun);
455 host_to_fcp_swap(mrk24->lun, sizeof(mrk24->lun));
456 mrk24->vp_index = vha->vp_idx;
457 mrk24->handle = MAKE_HANDLE(req->id, mrk24->handle);
459 SET_TARGET_ID(ha, mrk->target, loop_id);
460 mrk->lun = cpu_to_le16(lun);
465 qla2x00_isp_cmd(vha, req);
467 return (QLA_SUCCESS);
471 qla2x00_marker(struct scsi_qla_host *vha, struct req_que *req,
472 struct rsp_que *rsp, uint16_t loop_id, uint16_t lun,
476 unsigned long flags = 0;
478 spin_lock_irqsave(&vha->hw->hardware_lock, flags);
479 ret = __qla2x00_marker(vha, req, rsp, loop_id, lun, type);
480 spin_unlock_irqrestore(&vha->hw->hardware_lock, flags);
486 * qla2x00_req_pkt() - Retrieve a request packet from the request ring.
489 * Note: The caller must hold the hardware lock before calling this routine.
491 * Returns NULL if function failed, else, a pointer to the request packet.
494 qla2x00_req_pkt(struct scsi_qla_host *vha, struct req_que *req,
497 struct qla_hw_data *ha = vha->hw;
498 device_reg_t __iomem *reg = ISP_QUE_REG(ha, req->id);
499 request_t *pkt = NULL;
503 uint16_t req_cnt = 1;
505 /* Wait 1 second for slot. */
506 for (timer = HZ; timer; timer--) {
507 if ((req_cnt + 2) >= req->cnt) {
508 /* Calculate number of free request entries. */
511 RD_REG_DWORD(®->isp25mq.req_q_out);
513 if (IS_FWI2_CAPABLE(ha))
514 cnt = (uint16_t)RD_REG_DWORD(
515 ®->isp24.req_q_out);
517 cnt = qla2x00_debounce_register(
518 ISP_REQ_Q_OUT(ha, ®->isp));
520 if (req->ring_index < cnt)
521 req->cnt = cnt - req->ring_index;
523 req->cnt = req->length -
524 (req->ring_index - cnt);
526 /* If room for request in request ring. */
527 if ((req_cnt + 2) < req->cnt) {
531 /* Zero out packet. */
532 dword_ptr = (uint32_t *)pkt;
533 for (cnt = 0; cnt < REQUEST_ENTRY_SIZE / 4; cnt++)
536 /* Set entry count. */
537 pkt->entry_count = 1;
542 /* Release ring specific lock */
543 spin_unlock_irq(&ha->hardware_lock);
545 udelay(2); /* 2 us */
547 /* Check for pending interrupts. */
548 /* During init we issue marker directly */
549 if (!vha->marker_needed && !vha->flags.init_done)
551 spin_lock_irq(&ha->hardware_lock);
554 DEBUG2_3(printk("%s(): **** FAILED ****\n", __func__));
561 * qla2x00_isp_cmd() - Modify the request ring pointer.
564 * Note: The caller must hold the hardware lock before calling this routine.
567 qla2x00_isp_cmd(struct scsi_qla_host *vha, struct req_que *req)
569 struct qla_hw_data *ha = vha->hw;
570 device_reg_t __iomem *reg = ISP_QUE_REG(ha, req->id);
571 struct device_reg_2xxx __iomem *ioreg = &ha->iobase->isp;
573 DEBUG5(printk("%s(): IOCB data:\n", __func__));
574 DEBUG5(qla2x00_dump_buffer(
575 (uint8_t *)req->ring_ptr, REQUEST_ENTRY_SIZE));
577 /* Adjust ring index. */
579 if (req->ring_index == req->length) {
581 req->ring_ptr = req->ring;
585 /* Set chip new ring index. */
587 WRT_REG_DWORD(®->isp25mq.req_q_in, req->ring_index);
588 RD_REG_DWORD(&ioreg->hccr);
591 if (IS_FWI2_CAPABLE(ha)) {
592 WRT_REG_DWORD(®->isp24.req_q_in, req->ring_index);
593 RD_REG_DWORD_RELAXED(®->isp24.req_q_in);
595 WRT_REG_WORD(ISP_REQ_Q_IN(ha, ®->isp),
597 RD_REG_WORD_RELAXED(ISP_REQ_Q_IN(ha, ®->isp));
604 * qla24xx_calc_iocbs() - Determine number of Command Type 3 and
605 * Continuation Type 1 IOCBs to allocate.
607 * @dsds: number of data segment decriptors needed
609 * Returns the number of IOCB entries needed to store @dsds.
611 static inline uint16_t
612 qla24xx_calc_iocbs(uint16_t dsds)
618 iocbs += (dsds - 1) / 5;
626 * qla24xx_build_scsi_iocbs() - Build IOCB command utilizing Command Type 7
629 * @sp: SRB command to process
630 * @cmd_pkt: Command type 3 IOCB
631 * @tot_dsds: Total number of segments to transfer
634 qla24xx_build_scsi_iocbs(srb_t *sp, struct cmd_type_7 *cmd_pkt,
639 scsi_qla_host_t *vha;
640 struct scsi_cmnd *cmd;
641 struct scatterlist *sg;
647 /* Update entry type to indicate Command Type 3 IOCB */
648 *((uint32_t *)(&cmd_pkt->entry_type)) =
649 __constant_cpu_to_le32(COMMAND_TYPE_7);
651 /* No data transfer */
652 if (!scsi_bufflen(cmd) || cmd->sc_data_direction == DMA_NONE) {
653 cmd_pkt->byte_count = __constant_cpu_to_le32(0);
657 vha = sp->fcport->vha;
660 /* Set transfer direction */
661 if (cmd->sc_data_direction == DMA_TO_DEVICE) {
662 cmd_pkt->task_mgmt_flags =
663 __constant_cpu_to_le16(TMF_WRITE_DATA);
664 sp->fcport->vha->hw->qla_stats.output_bytes +=
665 scsi_bufflen(sp->cmd);
666 } else if (cmd->sc_data_direction == DMA_FROM_DEVICE) {
667 cmd_pkt->task_mgmt_flags =
668 __constant_cpu_to_le16(TMF_READ_DATA);
669 sp->fcport->vha->hw->qla_stats.input_bytes +=
670 scsi_bufflen(sp->cmd);
673 /* One DSD is available in the Command Type 3 IOCB */
675 cur_dsd = (uint32_t *)&cmd_pkt->dseg_0_address;
677 /* Load data segments */
679 scsi_for_each_sg(cmd, sg, tot_dsds, i) {
681 cont_a64_entry_t *cont_pkt;
683 /* Allocate additional continuation packets? */
684 if (avail_dsds == 0) {
686 * Five DSDs are available in the Continuation
689 cont_pkt = qla2x00_prep_cont_type1_iocb(req, vha);
690 cur_dsd = (uint32_t *)cont_pkt->dseg_0_address;
694 sle_dma = sg_dma_address(sg);
695 *cur_dsd++ = cpu_to_le32(LSD(sle_dma));
696 *cur_dsd++ = cpu_to_le32(MSD(sle_dma));
697 *cur_dsd++ = cpu_to_le32(sg_dma_len(sg));
704 * qla24xx_start_scsi() - Send a SCSI command to the ISP
705 * @sp: command to send to the ISP
707 * Returns non-zero if a failure occurred, else zero.
710 qla24xx_start_scsi(srb_t *sp)
717 struct cmd_type_7 *cmd_pkt;
721 struct req_que *req = NULL;
722 struct rsp_que *rsp = NULL;
723 struct scsi_cmnd *cmd = sp->cmd;
724 struct scsi_qla_host *vha = sp->fcport->vha;
725 struct qla_hw_data *ha = vha->hw;
727 /* Setup device pointers. */
730 qla25xx_set_que(sp, &req, &rsp);
733 /* So we know we haven't pci_map'ed anything yet */
736 /* Send marker if required */
737 if (vha->marker_needed != 0) {
738 if (qla2x00_marker(vha, req, rsp, 0, 0, MK_SYNC_ALL)
740 return QLA_FUNCTION_FAILED;
741 vha->marker_needed = 0;
744 /* Acquire ring specific lock */
745 spin_lock_irqsave(&ha->hardware_lock, flags);
747 /* Check for room in outstanding command list. */
748 handle = req->current_outstanding_cmd;
749 for (index = 1; index < MAX_OUTSTANDING_COMMANDS; index++) {
751 if (handle == MAX_OUTSTANDING_COMMANDS)
753 if (!req->outstanding_cmds[handle])
756 if (index == MAX_OUTSTANDING_COMMANDS)
759 /* Map the sg table so we have an accurate count of sg entries needed */
760 if (scsi_sg_count(cmd)) {
761 nseg = dma_map_sg(&ha->pdev->dev, scsi_sglist(cmd),
762 scsi_sg_count(cmd), cmd->sc_data_direction);
770 req_cnt = qla24xx_calc_iocbs(tot_dsds);
771 if (req->cnt < (req_cnt + 2)) {
772 cnt = RD_REG_DWORD_RELAXED(req->req_q_out);
774 if (req->ring_index < cnt)
775 req->cnt = cnt - req->ring_index;
777 req->cnt = req->length -
778 (req->ring_index - cnt);
780 if (req->cnt < (req_cnt + 2))
783 /* Build command packet. */
784 req->current_outstanding_cmd = handle;
785 req->outstanding_cmds[handle] = sp;
786 sp->cmd->host_scribble = (unsigned char *)(unsigned long)handle;
789 cmd_pkt = (struct cmd_type_7 *)req->ring_ptr;
790 cmd_pkt->handle = MAKE_HANDLE(req->id, handle);
792 /* Zero out remaining portion of packet. */
793 /* tagged queuing modifier -- default is TSK_SIMPLE (0). */
794 clr_ptr = (uint32_t *)cmd_pkt + 2;
795 memset(clr_ptr, 0, REQUEST_ENTRY_SIZE - 8);
796 cmd_pkt->dseg_count = cpu_to_le16(tot_dsds);
798 /* Set NPORT-ID and LUN number*/
799 cmd_pkt->nport_handle = cpu_to_le16(sp->fcport->loop_id);
800 cmd_pkt->port_id[0] = sp->fcport->d_id.b.al_pa;
801 cmd_pkt->port_id[1] = sp->fcport->d_id.b.area;
802 cmd_pkt->port_id[2] = sp->fcport->d_id.b.domain;
803 cmd_pkt->vp_index = sp->fcport->vp_idx;
805 int_to_scsilun(sp->cmd->device->lun, &cmd_pkt->lun);
806 host_to_fcp_swap((uint8_t *)&cmd_pkt->lun, sizeof(cmd_pkt->lun));
808 /* Load SCSI command packet. */
809 memcpy(cmd_pkt->fcp_cdb, cmd->cmnd, cmd->cmd_len);
810 host_to_fcp_swap(cmd_pkt->fcp_cdb, sizeof(cmd_pkt->fcp_cdb));
812 cmd_pkt->byte_count = cpu_to_le32((uint32_t)scsi_bufflen(cmd));
814 /* Build IOCB segments */
815 qla24xx_build_scsi_iocbs(sp, cmd_pkt, tot_dsds);
817 /* Set total data segment count. */
818 cmd_pkt->entry_count = (uint8_t)req_cnt;
819 /* Specify response queue number where completion should happen */
820 cmd_pkt->entry_status = (uint8_t) rsp->id;
823 /* Adjust ring index. */
825 if (req->ring_index == req->length) {
827 req->ring_ptr = req->ring;
831 sp->flags |= SRB_DMA_VALID;
833 /* Set chip new ring index. */
834 WRT_REG_DWORD(req->req_q_in, req->ring_index);
835 RD_REG_DWORD_RELAXED(&ha->iobase->isp24.hccr);
837 /* Manage unprocessed RIO/ZIO commands in response queue. */
838 if (vha->flags.process_response_queue &&
839 rsp->ring_ptr->signature != RESPONSE_PROCESSED)
840 qla24xx_process_response_queue(vha, rsp);
842 spin_unlock_irqrestore(&ha->hardware_lock, flags);
849 spin_unlock_irqrestore(&ha->hardware_lock, flags);
851 return QLA_FUNCTION_FAILED;
854 static void qla25xx_set_que(srb_t *sp, struct req_que **req,
855 struct rsp_que **rsp)
857 struct scsi_cmnd *cmd = sp->cmd;
858 struct scsi_qla_host *vha = sp->fcport->vha;
859 struct qla_hw_data *ha = sp->fcport->vha->hw;
860 int affinity = cmd->request->cpu;
862 if (ql2xmultique_tag && affinity >= 0 &&
863 affinity < ha->max_rsp_queues - 1) {
864 *rsp = ha->rsp_q_map[affinity + 1];
865 *req = ha->req_q_map[1];
868 *rsp = ha->rsp_q_map[0];