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/delay.h>
10 #include <scsi/scsi_tcq.h>
12 static void qla2x00_mbx_completion(scsi_qla_host_t
*, uint16_t);
13 static void qla2x00_process_completed_request(struct scsi_qla_host
*,
14 struct req_que
*, uint32_t);
15 static void qla2x00_status_entry(scsi_qla_host_t
*, struct rsp_que
*, void *);
16 static void qla2x00_status_cont_entry(struct rsp_que
*, sts_cont_entry_t
*);
17 static void qla2x00_error_entry(scsi_qla_host_t
*, struct rsp_que
*,
21 * qla2100_intr_handler() - Process interrupts for the ISP2100 and ISP2200.
23 * @dev_id: SCSI driver HA context
25 * Called by system whenever the host adapter generates an interrupt.
27 * Returns handled flag.
30 qla2100_intr_handler(int irq
, void *dev_id
)
33 struct qla_hw_data
*ha
;
34 struct device_reg_2xxx __iomem
*reg
;
42 rsp
= (struct rsp_que
*) dev_id
;
45 "%s(): NULL response queue pointer\n", __func__
);
50 reg
= &ha
->iobase
->isp
;
53 spin_lock_irqsave(&ha
->hardware_lock
, flags
);
54 vha
= pci_get_drvdata(ha
->pdev
);
55 for (iter
= 50; iter
--; ) {
56 hccr
= RD_REG_WORD(®
->hccr
);
57 if (hccr
& HCCR_RISC_PAUSE
) {
58 if (pci_channel_offline(ha
->pdev
))
62 * Issue a "HARD" reset in order for the RISC interrupt
63 * bit to be cleared. Schedule a big hammmer to get
64 * out of the RISC PAUSED state.
66 WRT_REG_WORD(®
->hccr
, HCCR_RESET_RISC
);
67 RD_REG_WORD(®
->hccr
);
69 ha
->isp_ops
->fw_dump(vha
, 1);
70 set_bit(ISP_ABORT_NEEDED
, &vha
->dpc_flags
);
72 } else if ((RD_REG_WORD(®
->istatus
) & ISR_RISC_INT
) == 0)
75 if (RD_REG_WORD(®
->semaphore
) & BIT_0
) {
76 WRT_REG_WORD(®
->hccr
, HCCR_CLR_RISC_INT
);
77 RD_REG_WORD(®
->hccr
);
79 /* Get mailbox data. */
80 mb
[0] = RD_MAILBOX_REG(ha
, reg
, 0);
81 if (mb
[0] > 0x3fff && mb
[0] < 0x8000) {
82 qla2x00_mbx_completion(vha
, mb
[0]);
83 status
|= MBX_INTERRUPT
;
84 } else if (mb
[0] > 0x7fff && mb
[0] < 0xc000) {
85 mb
[1] = RD_MAILBOX_REG(ha
, reg
, 1);
86 mb
[2] = RD_MAILBOX_REG(ha
, reg
, 2);
87 mb
[3] = RD_MAILBOX_REG(ha
, reg
, 3);
88 qla2x00_async_event(vha
, rsp
, mb
);
91 DEBUG2(printk("scsi(%ld): Unrecognized "
92 "interrupt type (%d).\n",
93 vha
->host_no
, mb
[0]));
95 /* Release mailbox registers. */
96 WRT_REG_WORD(®
->semaphore
, 0);
97 RD_REG_WORD(®
->semaphore
);
99 qla2x00_process_response_queue(rsp
);
101 WRT_REG_WORD(®
->hccr
, HCCR_CLR_RISC_INT
);
102 RD_REG_WORD(®
->hccr
);
105 spin_unlock_irqrestore(&ha
->hardware_lock
, flags
);
107 if (test_bit(MBX_INTR_WAIT
, &ha
->mbx_cmd_flags
) &&
108 (status
& MBX_INTERRUPT
) && ha
->flags
.mbox_int
) {
109 set_bit(MBX_INTERRUPT
, &ha
->mbx_cmd_flags
);
110 complete(&ha
->mbx_intr_comp
);
113 return (IRQ_HANDLED
);
117 * qla2300_intr_handler() - Process interrupts for the ISP23xx and ISP63xx.
119 * @dev_id: SCSI driver HA context
121 * Called by system whenever the host adapter generates an interrupt.
123 * Returns handled flag.
126 qla2300_intr_handler(int irq
, void *dev_id
)
128 scsi_qla_host_t
*vha
;
129 struct device_reg_2xxx __iomem
*reg
;
136 struct qla_hw_data
*ha
;
139 rsp
= (struct rsp_que
*) dev_id
;
142 "%s(): NULL response queue pointer\n", __func__
);
147 reg
= &ha
->iobase
->isp
;
150 spin_lock_irqsave(&ha
->hardware_lock
, flags
);
151 vha
= pci_get_drvdata(ha
->pdev
);
152 for (iter
= 50; iter
--; ) {
153 stat
= RD_REG_DWORD(®
->u
.isp2300
.host_status
);
154 if (stat
& HSR_RISC_PAUSED
) {
155 if (pci_channel_offline(ha
->pdev
))
158 hccr
= RD_REG_WORD(®
->hccr
);
159 if (hccr
& (BIT_15
| BIT_13
| BIT_11
| BIT_8
))
160 qla_printk(KERN_INFO
, ha
, "Parity error -- "
161 "HCCR=%x, Dumping firmware!\n", hccr
);
163 qla_printk(KERN_INFO
, ha
, "RISC paused -- "
164 "HCCR=%x, Dumping firmware!\n", hccr
);
167 * Issue a "HARD" reset in order for the RISC
168 * interrupt bit to be cleared. Schedule a big
169 * hammmer to get out of the RISC PAUSED state.
171 WRT_REG_WORD(®
->hccr
, HCCR_RESET_RISC
);
172 RD_REG_WORD(®
->hccr
);
174 ha
->isp_ops
->fw_dump(vha
, 1);
175 set_bit(ISP_ABORT_NEEDED
, &vha
->dpc_flags
);
177 } else if ((stat
& HSR_RISC_INT
) == 0)
180 switch (stat
& 0xff) {
185 qla2x00_mbx_completion(vha
, MSW(stat
));
186 status
|= MBX_INTERRUPT
;
188 /* Release mailbox registers. */
189 WRT_REG_WORD(®
->semaphore
, 0);
193 mb
[1] = RD_MAILBOX_REG(ha
, reg
, 1);
194 mb
[2] = RD_MAILBOX_REG(ha
, reg
, 2);
195 mb
[3] = RD_MAILBOX_REG(ha
, reg
, 3);
196 qla2x00_async_event(vha
, rsp
, mb
);
199 qla2x00_process_response_queue(rsp
);
202 mb
[0] = MBA_CMPLT_1_16BIT
;
204 qla2x00_async_event(vha
, rsp
, mb
);
207 mb
[0] = MBA_SCSI_COMPLETION
;
209 mb
[2] = RD_MAILBOX_REG(ha
, reg
, 2);
210 qla2x00_async_event(vha
, rsp
, mb
);
213 DEBUG2(printk("scsi(%ld): Unrecognized interrupt type "
215 vha
->host_no
, stat
& 0xff));
218 WRT_REG_WORD(®
->hccr
, HCCR_CLR_RISC_INT
);
219 RD_REG_WORD_RELAXED(®
->hccr
);
221 spin_unlock_irqrestore(&ha
->hardware_lock
, flags
);
223 if (test_bit(MBX_INTR_WAIT
, &ha
->mbx_cmd_flags
) &&
224 (status
& MBX_INTERRUPT
) && ha
->flags
.mbox_int
) {
225 set_bit(MBX_INTERRUPT
, &ha
->mbx_cmd_flags
);
226 complete(&ha
->mbx_intr_comp
);
229 return (IRQ_HANDLED
);
233 * qla2x00_mbx_completion() - Process mailbox command completions.
234 * @ha: SCSI driver HA context
235 * @mb0: Mailbox0 register
238 qla2x00_mbx_completion(scsi_qla_host_t
*vha
, uint16_t mb0
)
241 uint16_t __iomem
*wptr
;
242 struct qla_hw_data
*ha
= vha
->hw
;
243 struct device_reg_2xxx __iomem
*reg
= &ha
->iobase
->isp
;
245 /* Load return mailbox registers. */
246 ha
->flags
.mbox_int
= 1;
247 ha
->mailbox_out
[0] = mb0
;
248 wptr
= (uint16_t __iomem
*)MAILBOX_REG(ha
, reg
, 1);
250 for (cnt
= 1; cnt
< ha
->mbx_count
; cnt
++) {
251 if (IS_QLA2200(ha
) && cnt
== 8)
252 wptr
= (uint16_t __iomem
*)MAILBOX_REG(ha
, reg
, 8);
253 if (cnt
== 4 || cnt
== 5)
254 ha
->mailbox_out
[cnt
] = qla2x00_debounce_register(wptr
);
256 ha
->mailbox_out
[cnt
] = RD_REG_WORD(wptr
);
262 DEBUG3(printk("%s(%ld): Got mailbox completion. cmd=%x.\n",
263 __func__
, vha
->host_no
, ha
->mcp
->mb
[0]));
265 DEBUG2_3(printk("%s(%ld): MBX pointer ERROR!\n",
266 __func__
, vha
->host_no
));
271 qla81xx_idc_event(scsi_qla_host_t
*vha
, uint16_t aen
, uint16_t descr
)
273 static char *event
[] =
274 { "Complete", "Request Notification", "Time Extension" };
276 struct device_reg_24xx __iomem
*reg24
= &vha
->hw
->iobase
->isp24
;
277 uint16_t __iomem
*wptr
;
278 uint16_t cnt
, timeout
, mb
[QLA_IDC_ACK_REGS
];
280 /* Seed data -- mailbox1 -> mailbox7. */
281 wptr
= (uint16_t __iomem
*)®24
->mailbox1
;
282 for (cnt
= 0; cnt
< QLA_IDC_ACK_REGS
; cnt
++, wptr
++)
283 mb
[cnt
] = RD_REG_WORD(wptr
);
285 DEBUG2(printk("scsi(%ld): Inter-Driver Commucation %s -- "
286 "%04x %04x %04x %04x %04x %04x %04x.\n", vha
->host_no
,
288 mb
[0], mb
[1], mb
[2], mb
[3], mb
[4], mb
[5], mb
[6]));
290 /* Acknowledgement needed? [Notify && non-zero timeout]. */
291 timeout
= (descr
>> 8) & 0xf;
292 if (aen
!= MBA_IDC_NOTIFY
|| !timeout
)
295 DEBUG2(printk("scsi(%ld): Inter-Driver Commucation %s -- "
296 "ACK timeout=%d.\n", vha
->host_no
, event
[aen
& 0xff], timeout
));
298 rval
= qla2x00_post_idc_ack_work(vha
, mb
);
299 if (rval
!= QLA_SUCCESS
)
300 qla_printk(KERN_WARNING
, vha
->hw
,
301 "IDC failed to post ACK.\n");
305 * qla2x00_async_event() - Process aynchronous events.
306 * @ha: SCSI driver HA context
307 * @mb: Mailbox registers (0 - 3)
310 qla2x00_async_event(scsi_qla_host_t
*vha
, struct rsp_que
*rsp
, uint16_t *mb
)
313 static char *link_speeds
[] = { "1", "2", "?", "4", "8", "10" };
318 struct qla_hw_data
*ha
= vha
->hw
;
319 struct device_reg_2xxx __iomem
*reg
= &ha
->iobase
->isp
;
320 uint32_t rscn_entry
, host_pid
;
321 uint8_t rscn_queue_index
;
324 /* Setup to process RIO completion. */
329 case MBA_SCSI_COMPLETION
:
330 handles
[0] = le32_to_cpu((uint32_t)((mb
[2] << 16) | mb
[1]));
333 case MBA_CMPLT_1_16BIT
:
336 mb
[0] = MBA_SCSI_COMPLETION
;
338 case MBA_CMPLT_2_16BIT
:
342 mb
[0] = MBA_SCSI_COMPLETION
;
344 case MBA_CMPLT_3_16BIT
:
349 mb
[0] = MBA_SCSI_COMPLETION
;
351 case MBA_CMPLT_4_16BIT
:
355 handles
[3] = (uint32_t)RD_MAILBOX_REG(ha
, reg
, 6);
357 mb
[0] = MBA_SCSI_COMPLETION
;
359 case MBA_CMPLT_5_16BIT
:
363 handles
[3] = (uint32_t)RD_MAILBOX_REG(ha
, reg
, 6);
364 handles
[4] = (uint32_t)RD_MAILBOX_REG(ha
, reg
, 7);
366 mb
[0] = MBA_SCSI_COMPLETION
;
368 case MBA_CMPLT_2_32BIT
:
369 handles
[0] = le32_to_cpu((uint32_t)((mb
[2] << 16) | mb
[1]));
370 handles
[1] = le32_to_cpu(
371 ((uint32_t)(RD_MAILBOX_REG(ha
, reg
, 7) << 16)) |
372 RD_MAILBOX_REG(ha
, reg
, 6));
374 mb
[0] = MBA_SCSI_COMPLETION
;
381 case MBA_SCSI_COMPLETION
: /* Fast Post */
382 if (!vha
->flags
.online
)
385 for (cnt
= 0; cnt
< handle_cnt
; cnt
++)
386 qla2x00_process_completed_request(vha
, rsp
->req
,
390 case MBA_RESET
: /* Reset */
391 DEBUG2(printk("scsi(%ld): Asynchronous RESET.\n",
394 set_bit(RESET_MARKER_NEEDED
, &vha
->dpc_flags
);
397 case MBA_SYSTEM_ERR
: /* System Error */
398 qla_printk(KERN_INFO
, ha
,
399 "ISP System Error - mbx1=%xh mbx2=%xh mbx3=%xh.\n",
400 mb
[1], mb
[2], mb
[3]);
402 ha
->isp_ops
->fw_dump(vha
, 1);
404 if (IS_FWI2_CAPABLE(ha
)) {
405 if (mb
[1] == 0 && mb
[2] == 0) {
406 qla_printk(KERN_ERR
, ha
,
407 "Unrecoverable Hardware Error: adapter "
408 "marked OFFLINE!\n");
409 vha
->flags
.online
= 0;
411 set_bit(ISP_ABORT_NEEDED
, &vha
->dpc_flags
);
412 } else if (mb
[1] == 0) {
413 qla_printk(KERN_INFO
, ha
,
414 "Unrecoverable Hardware Error: adapter marked "
416 vha
->flags
.online
= 0;
418 set_bit(ISP_ABORT_NEEDED
, &vha
->dpc_flags
);
421 case MBA_REQ_TRANSFER_ERR
: /* Request Transfer Error */
422 DEBUG2(printk("scsi(%ld): ISP Request Transfer Error.\n",
424 qla_printk(KERN_WARNING
, ha
, "ISP Request Transfer Error.\n");
426 set_bit(ISP_ABORT_NEEDED
, &vha
->dpc_flags
);
429 case MBA_RSP_TRANSFER_ERR
: /* Response Transfer Error */
430 DEBUG2(printk("scsi(%ld): ISP Response Transfer Error.\n",
432 qla_printk(KERN_WARNING
, ha
, "ISP Response Transfer Error.\n");
434 set_bit(ISP_ABORT_NEEDED
, &vha
->dpc_flags
);
437 case MBA_WAKEUP_THRES
: /* Request Queue Wake-up */
438 DEBUG2(printk("scsi(%ld): Asynchronous WAKEUP_THRES.\n",
442 case MBA_LIP_OCCURRED
: /* Loop Initialization Procedure */
443 DEBUG2(printk("scsi(%ld): LIP occurred (%x).\n", vha
->host_no
,
445 qla_printk(KERN_INFO
, ha
, "LIP occurred (%x).\n", mb
[1]);
447 if (atomic_read(&vha
->loop_state
) != LOOP_DOWN
) {
448 atomic_set(&vha
->loop_state
, LOOP_DOWN
);
449 atomic_set(&vha
->loop_down_timer
, LOOP_DOWN_TIME
);
450 qla2x00_mark_all_devices_lost(vha
, 1);
454 atomic_set(&vha
->vp_state
, VP_FAILED
);
455 fc_vport_set_state(vha
->fc_vport
, FC_VPORT_FAILED
);
458 set_bit(REGISTER_FC4_NEEDED
, &vha
->dpc_flags
);
459 set_bit(REGISTER_FDMI_NEEDED
, &vha
->dpc_flags
);
461 vha
->flags
.management_server_logged_in
= 0;
462 qla2x00_post_aen_work(vha
, FCH_EVT_LIP
, mb
[1]);
465 case MBA_LOOP_UP
: /* Loop Up Event */
466 if (IS_QLA2100(ha
) || IS_QLA2200(ha
)) {
467 link_speed
= link_speeds
[0];
468 ha
->link_data_rate
= PORT_SPEED_1GB
;
470 link_speed
= link_speeds
[LS_UNKNOWN
];
472 link_speed
= link_speeds
[mb
[1]];
473 else if (mb
[1] == 0x13)
474 link_speed
= link_speeds
[5];
475 ha
->link_data_rate
= mb
[1];
478 DEBUG2(printk("scsi(%ld): Asynchronous LOOP UP (%s Gbps).\n",
479 vha
->host_no
, link_speed
));
480 qla_printk(KERN_INFO
, ha
, "LOOP UP detected (%s Gbps).\n",
483 vha
->flags
.management_server_logged_in
= 0;
484 qla2x00_post_aen_work(vha
, FCH_EVT_LINKUP
, ha
->link_data_rate
);
487 case MBA_LOOP_DOWN
: /* Loop Down Event */
488 DEBUG2(printk("scsi(%ld): Asynchronous LOOP DOWN "
489 "(%x %x %x).\n", vha
->host_no
, mb
[1], mb
[2], mb
[3]));
490 qla_printk(KERN_INFO
, ha
, "LOOP DOWN detected (%x %x %x).\n",
491 mb
[1], mb
[2], mb
[3]);
493 if (atomic_read(&vha
->loop_state
) != LOOP_DOWN
) {
494 atomic_set(&vha
->loop_state
, LOOP_DOWN
);
495 atomic_set(&vha
->loop_down_timer
, LOOP_DOWN_TIME
);
496 vha
->device_flags
|= DFLG_NO_CABLE
;
497 qla2x00_mark_all_devices_lost(vha
, 1);
501 atomic_set(&vha
->vp_state
, VP_FAILED
);
502 fc_vport_set_state(vha
->fc_vport
, FC_VPORT_FAILED
);
505 vha
->flags
.management_server_logged_in
= 0;
506 ha
->link_data_rate
= PORT_SPEED_UNKNOWN
;
507 qla2x00_post_aen_work(vha
, FCH_EVT_LINKDOWN
, 0);
510 case MBA_LIP_RESET
: /* LIP reset occurred */
511 DEBUG2(printk("scsi(%ld): Asynchronous LIP RESET (%x).\n",
512 vha
->host_no
, mb
[1]));
513 qla_printk(KERN_INFO
, ha
,
514 "LIP reset occurred (%x).\n", mb
[1]);
516 if (atomic_read(&vha
->loop_state
) != LOOP_DOWN
) {
517 atomic_set(&vha
->loop_state
, LOOP_DOWN
);
518 atomic_set(&vha
->loop_down_timer
, LOOP_DOWN_TIME
);
519 qla2x00_mark_all_devices_lost(vha
, 1);
523 atomic_set(&vha
->vp_state
, VP_FAILED
);
524 fc_vport_set_state(vha
->fc_vport
, FC_VPORT_FAILED
);
527 set_bit(RESET_MARKER_NEEDED
, &vha
->dpc_flags
);
529 ha
->operating_mode
= LOOP
;
530 vha
->flags
.management_server_logged_in
= 0;
531 qla2x00_post_aen_work(vha
, FCH_EVT_LIPRESET
, mb
[1]);
534 /* case MBA_DCBX_COMPLETE: */
535 case MBA_POINT_TO_POINT
: /* Point-to-Point */
540 DEBUG2(printk("scsi(%ld): DCBX Completed -- %04x %04x "
541 "%04x\n", vha
->host_no
, mb
[1], mb
[2], mb
[3]));
543 DEBUG2(printk("scsi(%ld): Asynchronous P2P MODE "
544 "received.\n", vha
->host_no
));
547 * Until there's a transition from loop down to loop up, treat
548 * this as loop down only.
550 if (atomic_read(&vha
->loop_state
) != LOOP_DOWN
) {
551 atomic_set(&vha
->loop_state
, LOOP_DOWN
);
552 if (!atomic_read(&vha
->loop_down_timer
))
553 atomic_set(&vha
->loop_down_timer
,
555 qla2x00_mark_all_devices_lost(vha
, 1);
559 atomic_set(&vha
->vp_state
, VP_FAILED
);
560 fc_vport_set_state(vha
->fc_vport
, FC_VPORT_FAILED
);
563 if (!(test_bit(ABORT_ISP_ACTIVE
, &vha
->dpc_flags
)))
564 set_bit(RESET_MARKER_NEEDED
, &vha
->dpc_flags
);
566 set_bit(REGISTER_FC4_NEEDED
, &vha
->dpc_flags
);
567 set_bit(REGISTER_FDMI_NEEDED
, &vha
->dpc_flags
);
569 ha
->flags
.gpsc_supported
= 1;
570 vha
->flags
.management_server_logged_in
= 0;
573 case MBA_CHG_IN_CONNECTION
: /* Change in connection mode */
577 DEBUG2(printk("scsi(%ld): Asynchronous Change In Connection "
580 qla_printk(KERN_INFO
, ha
,
581 "Configuration change detected: value=%x.\n", mb
[1]);
583 if (atomic_read(&vha
->loop_state
) != LOOP_DOWN
) {
584 atomic_set(&vha
->loop_state
, LOOP_DOWN
);
585 if (!atomic_read(&vha
->loop_down_timer
))
586 atomic_set(&vha
->loop_down_timer
,
588 qla2x00_mark_all_devices_lost(vha
, 1);
592 atomic_set(&vha
->vp_state
, VP_FAILED
);
593 fc_vport_set_state(vha
->fc_vport
, FC_VPORT_FAILED
);
596 set_bit(LOOP_RESYNC_NEEDED
, &vha
->dpc_flags
);
597 set_bit(LOCAL_LOOP_UPDATE
, &vha
->dpc_flags
);
600 case MBA_PORT_UPDATE
: /* Port database update */
601 /* Only handle SCNs for our Vport index. */
602 if (vha
->vp_idx
&& vha
->vp_idx
!= (mb
[3] & 0xff))
606 * If PORT UPDATE is global (received LIP_OCCURRED/LIP_RESET
607 * event etc. earlier indicating loop is down) then process
608 * it. Otherwise ignore it and Wait for RSCN to come in.
610 atomic_set(&vha
->loop_down_timer
, 0);
611 if (atomic_read(&vha
->loop_state
) != LOOP_DOWN
&&
612 atomic_read(&vha
->loop_state
) != LOOP_DEAD
) {
613 DEBUG2(printk("scsi(%ld): Asynchronous PORT UPDATE "
614 "ignored %04x/%04x/%04x.\n", vha
->host_no
, mb
[1],
619 DEBUG2(printk("scsi(%ld): Asynchronous PORT UPDATE.\n",
621 DEBUG(printk(KERN_INFO
622 "scsi(%ld): Port database changed %04x %04x %04x.\n",
623 vha
->host_no
, mb
[1], mb
[2], mb
[3]));
626 * Mark all devices as missing so we will login again.
628 atomic_set(&vha
->loop_state
, LOOP_UP
);
630 qla2x00_mark_all_devices_lost(vha
, 1);
632 vha
->flags
.rscn_queue_overflow
= 1;
634 set_bit(LOOP_RESYNC_NEEDED
, &vha
->dpc_flags
);
635 set_bit(LOCAL_LOOP_UPDATE
, &vha
->dpc_flags
);
638 case MBA_RSCN_UPDATE
: /* State Change Registration */
639 /* Check if the Vport has issued a SCR */
640 if (vha
->vp_idx
&& test_bit(VP_SCR_NEEDED
, &vha
->vp_flags
))
642 /* Only handle SCNs for our Vport index. */
643 if (vha
->vp_idx
&& vha
->vp_idx
!= (mb
[3] & 0xff))
645 DEBUG2(printk("scsi(%ld): Asynchronous RSCR UPDATE.\n",
647 DEBUG(printk(KERN_INFO
648 "scsi(%ld): RSCN database changed -- %04x %04x %04x.\n",
649 vha
->host_no
, mb
[1], mb
[2], mb
[3]));
651 rscn_entry
= ((mb
[1] & 0xff) << 16) | mb
[2];
652 host_pid
= (vha
->d_id
.b
.domain
<< 16) | (vha
->d_id
.b
.area
<< 8)
654 if (rscn_entry
== host_pid
) {
655 DEBUG(printk(KERN_INFO
656 "scsi(%ld): Ignoring RSCN update to local host "
658 vha
->host_no
, host_pid
));
662 /* Ignore reserved bits from RSCN-payload. */
663 rscn_entry
= ((mb
[1] & 0x3ff) << 16) | mb
[2];
664 rscn_queue_index
= vha
->rscn_in_ptr
+ 1;
665 if (rscn_queue_index
== MAX_RSCN_COUNT
)
666 rscn_queue_index
= 0;
667 if (rscn_queue_index
!= vha
->rscn_out_ptr
) {
668 vha
->rscn_queue
[vha
->rscn_in_ptr
] = rscn_entry
;
669 vha
->rscn_in_ptr
= rscn_queue_index
;
671 vha
->flags
.rscn_queue_overflow
= 1;
674 atomic_set(&vha
->loop_state
, LOOP_UPDATE
);
675 atomic_set(&vha
->loop_down_timer
, 0);
676 vha
->flags
.management_server_logged_in
= 0;
678 set_bit(LOOP_RESYNC_NEEDED
, &vha
->dpc_flags
);
679 set_bit(RSCN_UPDATE
, &vha
->dpc_flags
);
680 qla2x00_post_aen_work(vha
, FCH_EVT_RSCN
, rscn_entry
);
683 /* case MBA_RIO_RESPONSE: */
684 case MBA_ZIO_RESPONSE
:
685 DEBUG3(printk("scsi(%ld): [R|Z]IO update completion.\n",
688 if (IS_FWI2_CAPABLE(ha
))
689 qla24xx_process_response_queue(vha
, rsp
);
691 qla2x00_process_response_queue(rsp
);
694 case MBA_DISCARD_RND_FRAME
:
695 DEBUG2(printk("scsi(%ld): Discard RND Frame -- %04x %04x "
696 "%04x.\n", vha
->host_no
, mb
[1], mb
[2], mb
[3]));
699 case MBA_TRACE_NOTIFICATION
:
700 DEBUG2(printk("scsi(%ld): Trace Notification -- %04x %04x.\n",
701 vha
->host_no
, mb
[1], mb
[2]));
704 case MBA_ISP84XX_ALERT
:
705 DEBUG2(printk("scsi(%ld): ISP84XX Alert Notification -- "
706 "%04x %04x %04x\n", vha
->host_no
, mb
[1], mb
[2], mb
[3]));
708 spin_lock_irqsave(&ha
->cs84xx
->access_lock
, flags
);
710 case A84_PANIC_RECOVERY
:
711 qla_printk(KERN_INFO
, ha
, "Alert 84XX: panic recovery "
712 "%04x %04x\n", mb
[2], mb
[3]);
714 case A84_OP_LOGIN_COMPLETE
:
715 ha
->cs84xx
->op_fw_version
= mb
[3] << 16 | mb
[2];
716 DEBUG2(qla_printk(KERN_INFO
, ha
, "Alert 84XX:"
717 "firmware version %x\n", ha
->cs84xx
->op_fw_version
));
719 case A84_DIAG_LOGIN_COMPLETE
:
720 ha
->cs84xx
->diag_fw_version
= mb
[3] << 16 | mb
[2];
721 DEBUG2(qla_printk(KERN_INFO
, ha
, "Alert 84XX:"
722 "diagnostic firmware version %x\n",
723 ha
->cs84xx
->diag_fw_version
));
725 case A84_GOLD_LOGIN_COMPLETE
:
726 ha
->cs84xx
->diag_fw_version
= mb
[3] << 16 | mb
[2];
727 ha
->cs84xx
->fw_update
= 1;
728 DEBUG2(qla_printk(KERN_INFO
, ha
, "Alert 84XX: gold "
729 "firmware version %x\n",
730 ha
->cs84xx
->gold_fw_version
));
733 qla_printk(KERN_ERR
, ha
,
734 "Alert 84xx: Invalid Alert %04x %04x %04x\n",
735 mb
[1], mb
[2], mb
[3]);
737 spin_unlock_irqrestore(&ha
->cs84xx
->access_lock
, flags
);
740 DEBUG2(printk("scsi(%ld): DCBX Started -- %04x %04x %04x\n",
741 vha
->host_no
, mb
[1], mb
[2], mb
[3]));
743 case MBA_DCBX_PARAM_UPDATE
:
744 DEBUG2(printk("scsi(%ld): DCBX Parameters Updated -- "
745 "%04x %04x %04x\n", vha
->host_no
, mb
[1], mb
[2], mb
[3]));
747 case MBA_FCF_CONF_ERR
:
748 DEBUG2(printk("scsi(%ld): FCF Configuration Error -- "
749 "%04x %04x %04x\n", vha
->host_no
, mb
[1], mb
[2], mb
[3]));
751 case MBA_IDC_COMPLETE
:
753 case MBA_IDC_TIME_EXT
:
754 qla81xx_idc_event(vha
, mb
[0], mb
[1]);
758 if (!vha
->vp_idx
&& ha
->num_vhosts
)
759 qla2x00_alert_all_vps(rsp
, mb
);
763 qla2x00_adjust_sdev_qdepth_up(struct scsi_device
*sdev
, void *data
)
765 fc_port_t
*fcport
= data
;
766 struct scsi_qla_host
*vha
= fcport
->vha
;
767 struct qla_hw_data
*ha
= vha
->hw
;
768 struct req_que
*req
= NULL
;
770 if (!ql2xqfulltracking
)
776 if (req
->max_q_depth
<= sdev
->queue_depth
)
779 if (sdev
->ordered_tags
)
780 scsi_adjust_queue_depth(sdev
, MSG_ORDERED_TAG
,
781 sdev
->queue_depth
+ 1);
783 scsi_adjust_queue_depth(sdev
, MSG_SIMPLE_TAG
,
784 sdev
->queue_depth
+ 1);
786 fcport
->last_ramp_up
= jiffies
;
788 DEBUG2(qla_printk(KERN_INFO
, ha
,
789 "scsi(%ld:%d:%d:%d): Queue depth adjusted-up to %d.\n",
790 fcport
->vha
->host_no
, sdev
->channel
, sdev
->id
, sdev
->lun
,
795 qla2x00_adjust_sdev_qdepth_down(struct scsi_device
*sdev
, void *data
)
797 fc_port_t
*fcport
= data
;
799 if (!scsi_track_queue_full(sdev
, sdev
->queue_depth
- 1))
802 DEBUG2(qla_printk(KERN_INFO
, fcport
->vha
->hw
,
803 "scsi(%ld:%d:%d:%d): Queue depth adjusted-down to %d.\n",
804 fcport
->vha
->host_no
, sdev
->channel
, sdev
->id
, sdev
->lun
,
809 qla2x00_ramp_up_queue_depth(scsi_qla_host_t
*vha
, struct req_que
*req
,
813 struct scsi_device
*sdev
;
815 if (!ql2xqfulltracking
)
818 sdev
= sp
->cmd
->device
;
819 if (sdev
->queue_depth
>= req
->max_q_depth
)
823 if (time_before(jiffies
,
824 fcport
->last_ramp_up
+ ql2xqfullrampup
* HZ
))
826 if (time_before(jiffies
,
827 fcport
->last_queue_full
+ ql2xqfullrampup
* HZ
))
830 starget_for_each_device(sdev
->sdev_target
, fcport
,
831 qla2x00_adjust_sdev_qdepth_up
);
835 * qla2x00_process_completed_request() - Process a Fast Post response.
836 * @ha: SCSI driver HA context
840 qla2x00_process_completed_request(struct scsi_qla_host
*vha
,
841 struct req_que
*req
, uint32_t index
)
844 struct qla_hw_data
*ha
= vha
->hw
;
846 /* Validate handle. */
847 if (index
>= MAX_OUTSTANDING_COMMANDS
) {
848 DEBUG2(printk("scsi(%ld): Invalid SCSI completion handle %d.\n",
849 vha
->host_no
, index
));
850 qla_printk(KERN_WARNING
, ha
,
851 "Invalid SCSI completion handle %d.\n", index
);
853 set_bit(ISP_ABORT_NEEDED
, &vha
->dpc_flags
);
857 sp
= req
->outstanding_cmds
[index
];
859 /* Free outstanding command slot. */
860 req
->outstanding_cmds
[index
] = NULL
;
862 /* Save ISP completion status */
863 sp
->cmd
->result
= DID_OK
<< 16;
865 qla2x00_ramp_up_queue_depth(vha
, req
, sp
);
866 qla2x00_sp_compl(ha
, sp
);
868 DEBUG2(printk("scsi(%ld) Req:%d: Invalid ISP SCSI completion"
869 " handle(%d)\n", vha
->host_no
, req
->id
, index
));
870 qla_printk(KERN_WARNING
, ha
,
871 "Invalid ISP SCSI completion handle\n");
873 set_bit(ISP_ABORT_NEEDED
, &vha
->dpc_flags
);
878 * qla2x00_process_response_queue() - Process response queue entries.
879 * @ha: SCSI driver HA context
882 qla2x00_process_response_queue(struct rsp_que
*rsp
)
884 struct scsi_qla_host
*vha
;
885 struct qla_hw_data
*ha
= rsp
->hw
;
886 struct device_reg_2xxx __iomem
*reg
= &ha
->iobase
->isp
;
891 vha
= pci_get_drvdata(ha
->pdev
);
893 if (!vha
->flags
.online
)
896 while (rsp
->ring_ptr
->signature
!= RESPONSE_PROCESSED
) {
897 pkt
= (sts_entry_t
*)rsp
->ring_ptr
;
900 if (rsp
->ring_index
== rsp
->length
) {
902 rsp
->ring_ptr
= rsp
->ring
;
907 if (pkt
->entry_status
!= 0) {
908 DEBUG3(printk(KERN_INFO
909 "scsi(%ld): Process error entry.\n", vha
->host_no
));
911 qla2x00_error_entry(vha
, rsp
, pkt
);
912 ((response_t
*)pkt
)->signature
= RESPONSE_PROCESSED
;
917 switch (pkt
->entry_type
) {
919 qla2x00_status_entry(vha
, rsp
, pkt
);
922 handle_cnt
= ((sts21_entry_t
*)pkt
)->handle_count
;
923 for (cnt
= 0; cnt
< handle_cnt
; cnt
++) {
924 qla2x00_process_completed_request(vha
, rsp
->req
,
925 ((sts21_entry_t
*)pkt
)->handle
[cnt
]);
929 handle_cnt
= ((sts22_entry_t
*)pkt
)->handle_count
;
930 for (cnt
= 0; cnt
< handle_cnt
; cnt
++) {
931 qla2x00_process_completed_request(vha
, rsp
->req
,
932 ((sts22_entry_t
*)pkt
)->handle
[cnt
]);
935 case STATUS_CONT_TYPE
:
936 qla2x00_status_cont_entry(rsp
, (sts_cont_entry_t
*)pkt
);
939 /* Type Not Supported. */
940 DEBUG4(printk(KERN_WARNING
941 "scsi(%ld): Received unknown response pkt type %x "
942 "entry status=%x.\n",
943 vha
->host_no
, pkt
->entry_type
, pkt
->entry_status
));
946 ((response_t
*)pkt
)->signature
= RESPONSE_PROCESSED
;
950 /* Adjust ring index */
951 WRT_REG_WORD(ISP_RSP_Q_OUT(ha
, reg
), rsp
->ring_index
);
955 qla2x00_handle_sense(srb_t
*sp
, uint8_t *sense_data
, uint32_t sense_len
,
958 struct scsi_cmnd
*cp
= sp
->cmd
;
960 if (sense_len
>= SCSI_SENSE_BUFFERSIZE
)
961 sense_len
= SCSI_SENSE_BUFFERSIZE
;
963 sp
->request_sense_length
= sense_len
;
964 sp
->request_sense_ptr
= cp
->sense_buffer
;
965 if (sp
->request_sense_length
> 32)
968 memcpy(cp
->sense_buffer
, sense_data
, sense_len
);
970 sp
->request_sense_ptr
+= sense_len
;
971 sp
->request_sense_length
-= sense_len
;
972 if (sp
->request_sense_length
!= 0)
973 rsp
->status_srb
= sp
;
975 DEBUG5(printk("%s(): Check condition Sense data, scsi(%ld:%d:%d:%d) "
976 "cmd=%p pid=%ld\n", __func__
, sp
->fcport
->vha
->host_no
,
977 cp
->device
->channel
, cp
->device
->id
, cp
->device
->lun
, cp
,
980 DEBUG5(qla2x00_dump_buffer(cp
->sense_buffer
, sense_len
));
984 * qla2x00_status_entry() - Process a Status IOCB entry.
985 * @ha: SCSI driver HA context
986 * @pkt: Entry pointer
989 qla2x00_status_entry(scsi_qla_host_t
*vha
, struct rsp_que
*rsp
, void *pkt
)
993 struct scsi_cmnd
*cp
;
995 struct sts_entry_24xx
*sts24
;
996 uint16_t comp_status
;
997 uint16_t scsi_status
;
998 uint8_t lscsi_status
;
1000 uint32_t sense_len
, rsp_info_len
, resid_len
, fw_resid_len
;
1001 uint8_t *rsp_info
, *sense_data
;
1002 struct qla_hw_data
*ha
= vha
->hw
;
1005 struct req_que
*req
;
1007 sts
= (sts_entry_t
*) pkt
;
1008 sts24
= (struct sts_entry_24xx
*) pkt
;
1009 if (IS_FWI2_CAPABLE(ha
)) {
1010 comp_status
= le16_to_cpu(sts24
->comp_status
);
1011 scsi_status
= le16_to_cpu(sts24
->scsi_status
) & SS_MASK
;
1013 comp_status
= le16_to_cpu(sts
->comp_status
);
1014 scsi_status
= le16_to_cpu(sts
->scsi_status
) & SS_MASK
;
1016 handle
= (uint32_t) LSW(sts
->handle
);
1017 que
= MSW(sts
->handle
);
1018 req
= ha
->req_q_map
[que
];
1019 /* Fast path completion. */
1020 if (comp_status
== CS_COMPLETE
&& scsi_status
== 0) {
1021 qla2x00_process_completed_request(vha
, req
, handle
);
1026 /* Validate handle. */
1027 if (handle
< MAX_OUTSTANDING_COMMANDS
) {
1028 sp
= req
->outstanding_cmds
[handle
];
1029 req
->outstanding_cmds
[handle
] = NULL
;
1034 DEBUG2(printk("scsi(%ld): Status Entry invalid handle.\n",
1036 qla_printk(KERN_WARNING
, ha
, "Status Entry invalid handle.\n");
1038 set_bit(ISP_ABORT_NEEDED
, &vha
->dpc_flags
);
1039 qla2xxx_wake_dpc(vha
);
1044 DEBUG2(printk("scsi(%ld): Command already returned back to OS "
1045 "pkt->handle=%d sp=%p.\n", vha
->host_no
, handle
, sp
));
1046 qla_printk(KERN_WARNING
, ha
,
1047 "Command is NULL: already returned to OS (sp=%p)\n", sp
);
1052 lscsi_status
= scsi_status
& STATUS_MASK
;
1054 fcport
= sp
->fcport
;
1056 sense_len
= rsp_info_len
= resid_len
= fw_resid_len
= 0;
1057 if (IS_FWI2_CAPABLE(ha
)) {
1058 sense_len
= le32_to_cpu(sts24
->sense_len
);
1059 rsp_info_len
= le32_to_cpu(sts24
->rsp_data_len
);
1060 resid_len
= le32_to_cpu(sts24
->rsp_residual_count
);
1061 fw_resid_len
= le32_to_cpu(sts24
->residual_len
);
1062 rsp_info
= sts24
->data
;
1063 sense_data
= sts24
->data
;
1064 host_to_fcp_swap(sts24
->data
, sizeof(sts24
->data
));
1066 sense_len
= le16_to_cpu(sts
->req_sense_length
);
1067 rsp_info_len
= le16_to_cpu(sts
->rsp_info_len
);
1068 resid_len
= le32_to_cpu(sts
->residual_length
);
1069 rsp_info
= sts
->rsp_info
;
1070 sense_data
= sts
->req_sense_data
;
1073 /* Check for any FCP transport errors. */
1074 if (scsi_status
& SS_RESPONSE_INFO_LEN_VALID
) {
1075 /* Sense data lies beyond any FCP RESPONSE data. */
1076 if (IS_FWI2_CAPABLE(ha
))
1077 sense_data
+= rsp_info_len
;
1078 if (rsp_info_len
> 3 && rsp_info
[3]) {
1079 DEBUG2(printk("scsi(%ld:%d:%d:%d) FCP I/O protocol "
1080 "failure (%x/%02x%02x%02x%02x%02x%02x%02x%02x)..."
1081 "retrying command\n", vha
->host_no
,
1082 cp
->device
->channel
, cp
->device
->id
,
1083 cp
->device
->lun
, rsp_info_len
, rsp_info
[0],
1084 rsp_info
[1], rsp_info
[2], rsp_info
[3], rsp_info
[4],
1085 rsp_info
[5], rsp_info
[6], rsp_info
[7]));
1087 cp
->result
= DID_BUS_BUSY
<< 16;
1088 qla2x00_sp_compl(ha
, sp
);
1093 /* Check for overrun. */
1094 if (IS_FWI2_CAPABLE(ha
) && comp_status
== CS_COMPLETE
&&
1095 scsi_status
& SS_RESIDUAL_OVER
)
1096 comp_status
= CS_DATA_OVERRUN
;
1099 * Based on Host and scsi status generate status code for Linux
1101 switch (comp_status
) {
1104 if (scsi_status
== 0) {
1105 cp
->result
= DID_OK
<< 16;
1108 if (scsi_status
& (SS_RESIDUAL_UNDER
| SS_RESIDUAL_OVER
)) {
1110 scsi_set_resid(cp
, resid
);
1112 if (!lscsi_status
&&
1113 ((unsigned)(scsi_bufflen(cp
) - resid
) <
1115 qla_printk(KERN_INFO
, ha
,
1116 "scsi(%ld:%d:%d:%d): Mid-layer underflow "
1117 "detected (%x of %x bytes)...returning "
1118 "error status.\n", vha
->host_no
,
1119 cp
->device
->channel
, cp
->device
->id
,
1120 cp
->device
->lun
, resid
,
1123 cp
->result
= DID_ERROR
<< 16;
1127 cp
->result
= DID_OK
<< 16 | lscsi_status
;
1129 if (lscsi_status
== SAM_STAT_TASK_SET_FULL
) {
1130 DEBUG2(printk(KERN_INFO
1131 "scsi(%ld): QUEUE FULL status detected "
1132 "0x%x-0x%x.\n", vha
->host_no
, comp_status
,
1135 /* Adjust queue depth for all luns on the port. */
1136 if (!ql2xqfulltracking
)
1138 fcport
->last_queue_full
= jiffies
;
1139 starget_for_each_device(cp
->device
->sdev_target
,
1140 fcport
, qla2x00_adjust_sdev_qdepth_down
);
1143 if (lscsi_status
!= SS_CHECK_CONDITION
)
1146 memset(cp
->sense_buffer
, 0, SCSI_SENSE_BUFFERSIZE
);
1147 if (!(scsi_status
& SS_SENSE_LEN_VALID
))
1150 qla2x00_handle_sense(sp
, sense_data
, sense_len
, rsp
);
1153 case CS_DATA_UNDERRUN
:
1155 /* Use F/W calculated residual length. */
1156 if (IS_FWI2_CAPABLE(ha
)) {
1157 if (!(scsi_status
& SS_RESIDUAL_UNDER
)) {
1159 } else if (resid
!= fw_resid_len
) {
1160 scsi_status
&= ~SS_RESIDUAL_UNDER
;
1163 resid
= fw_resid_len
;
1166 if (scsi_status
& SS_RESIDUAL_UNDER
) {
1167 scsi_set_resid(cp
, resid
);
1169 DEBUG2(printk(KERN_INFO
1170 "scsi(%ld:%d:%d) UNDERRUN status detected "
1171 "0x%x-0x%x. resid=0x%x fw_resid=0x%x cdb=0x%x "
1172 "os_underflow=0x%x\n", vha
->host_no
,
1173 cp
->device
->id
, cp
->device
->lun
, comp_status
,
1174 scsi_status
, resid_len
, resid
, cp
->cmnd
[0],
1180 * Check to see if SCSI Status is non zero. If so report SCSI
1183 if (lscsi_status
!= 0) {
1184 cp
->result
= DID_OK
<< 16 | lscsi_status
;
1186 if (lscsi_status
== SAM_STAT_TASK_SET_FULL
) {
1187 DEBUG2(printk(KERN_INFO
1188 "scsi(%ld): QUEUE FULL status detected "
1189 "0x%x-0x%x.\n", vha
->host_no
, comp_status
,
1193 * Adjust queue depth for all luns on the
1196 if (!ql2xqfulltracking
)
1198 fcport
->last_queue_full
= jiffies
;
1199 starget_for_each_device(
1200 cp
->device
->sdev_target
, fcport
,
1201 qla2x00_adjust_sdev_qdepth_down
);
1204 if (lscsi_status
!= SS_CHECK_CONDITION
)
1207 memset(cp
->sense_buffer
, 0, SCSI_SENSE_BUFFERSIZE
);
1208 if (!(scsi_status
& SS_SENSE_LEN_VALID
))
1211 qla2x00_handle_sense(sp
, sense_data
, sense_len
, rsp
);
1214 * If RISC reports underrun and target does not report
1215 * it then we must have a lost frame, so tell upper
1216 * layer to retry it by reporting an error.
1218 if (!(scsi_status
& SS_RESIDUAL_UNDER
)) {
1219 DEBUG2(printk("scsi(%ld:%d:%d:%d) Dropped "
1220 "frame(s) detected (%x of %x bytes)..."
1221 "retrying command.\n",
1222 vha
->host_no
, cp
->device
->channel
,
1223 cp
->device
->id
, cp
->device
->lun
, resid
,
1226 cp
->result
= DID_ERROR
<< 16;
1230 /* Handle mid-layer underflow */
1231 if ((unsigned)(scsi_bufflen(cp
) - resid
) <
1233 qla_printk(KERN_INFO
, ha
,
1234 "scsi(%ld:%d:%d:%d): Mid-layer underflow "
1235 "detected (%x of %x bytes)...returning "
1236 "error status.\n", vha
->host_no
,
1237 cp
->device
->channel
, cp
->device
->id
,
1238 cp
->device
->lun
, resid
,
1241 cp
->result
= DID_ERROR
<< 16;
1245 /* Everybody online, looking good... */
1246 cp
->result
= DID_OK
<< 16;
1250 case CS_DATA_OVERRUN
:
1251 DEBUG2(printk(KERN_INFO
1252 "scsi(%ld:%d:%d): OVERRUN status detected 0x%x-0x%x\n",
1253 vha
->host_no
, cp
->device
->id
, cp
->device
->lun
, comp_status
,
1255 DEBUG2(printk(KERN_INFO
1256 "CDB: 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x\n",
1257 cp
->cmnd
[0], cp
->cmnd
[1], cp
->cmnd
[2], cp
->cmnd
[3],
1258 cp
->cmnd
[4], cp
->cmnd
[5]));
1259 DEBUG2(printk(KERN_INFO
1260 "PID=0x%lx req=0x%x xtra=0x%x -- returning DID_ERROR "
1262 cp
->serial_number
, scsi_bufflen(cp
), resid_len
));
1264 cp
->result
= DID_ERROR
<< 16;
1267 case CS_PORT_LOGGED_OUT
:
1268 case CS_PORT_CONFIG_CHG
:
1271 case CS_PORT_UNAVAILABLE
:
1273 * If the port is in Target Down state, return all IOs for this
1274 * Target with DID_NO_CONNECT ELSE Queue the IOs in the
1277 DEBUG2(printk("scsi(%ld:%d:%d): status_entry: Port Down "
1278 "pid=%ld, compl status=0x%x, port state=0x%x\n",
1279 vha
->host_no
, cp
->device
->id
, cp
->device
->lun
,
1280 cp
->serial_number
, comp_status
,
1281 atomic_read(&fcport
->state
)));
1284 * We are going to have the fc class block the rport
1285 * while we try to recover so instruct the mid layer
1286 * to requeue until the class decides how to handle this.
1288 cp
->result
= DID_TRANSPORT_DISRUPTED
<< 16;
1289 if (atomic_read(&fcport
->state
) == FCS_ONLINE
)
1290 qla2x00_mark_device_lost(fcport
->vha
, fcport
, 1, 1);
1294 DEBUG2(printk(KERN_INFO
1295 "scsi(%ld): RESET status detected 0x%x-0x%x.\n",
1296 vha
->host_no
, comp_status
, scsi_status
));
1298 cp
->result
= DID_RESET
<< 16;
1303 * hv2.19.12 - DID_ABORT does not retry the request if we
1304 * aborted this request then abort otherwise it must be a
1307 DEBUG2(printk(KERN_INFO
1308 "scsi(%ld): ABORT status detected 0x%x-0x%x.\n",
1309 vha
->host_no
, comp_status
, scsi_status
));
1311 cp
->result
= DID_RESET
<< 16;
1316 * We are going to have the fc class block the rport
1317 * while we try to recover so instruct the mid layer
1318 * to requeue until the class decides how to handle this.
1320 cp
->result
= DID_TRANSPORT_DISRUPTED
<< 16;
1322 if (IS_FWI2_CAPABLE(ha
)) {
1323 DEBUG2(printk(KERN_INFO
1324 "scsi(%ld:%d:%d:%d): TIMEOUT status detected "
1325 "0x%x-0x%x\n", vha
->host_no
, cp
->device
->channel
,
1326 cp
->device
->id
, cp
->device
->lun
, comp_status
,
1330 DEBUG2(printk(KERN_INFO
1331 "scsi(%ld:%d:%d:%d): TIMEOUT status detected 0x%x-0x%x "
1332 "sflags=%x.\n", vha
->host_no
, cp
->device
->channel
,
1333 cp
->device
->id
, cp
->device
->lun
, comp_status
, scsi_status
,
1334 le16_to_cpu(sts
->status_flags
)));
1336 /* Check to see if logout occurred. */
1337 if ((le16_to_cpu(sts
->status_flags
) & SF_LOGOUT_SENT
))
1338 qla2x00_mark_device_lost(fcport
->vha
, fcport
, 1, 1);
1342 DEBUG3(printk("scsi(%ld): Error detected (unknown status) "
1343 "0x%x-0x%x.\n", vha
->host_no
, comp_status
, scsi_status
));
1344 qla_printk(KERN_INFO
, ha
,
1345 "Unknown status detected 0x%x-0x%x.\n",
1346 comp_status
, scsi_status
);
1348 cp
->result
= DID_ERROR
<< 16;
1352 /* Place command on done queue. */
1353 if (rsp
->status_srb
== NULL
)
1354 qla2x00_sp_compl(ha
, sp
);
1358 * qla2x00_status_cont_entry() - Process a Status Continuations entry.
1359 * @ha: SCSI driver HA context
1360 * @pkt: Entry pointer
1362 * Extended sense data.
1365 qla2x00_status_cont_entry(struct rsp_que
*rsp
, sts_cont_entry_t
*pkt
)
1367 uint8_t sense_sz
= 0;
1368 struct qla_hw_data
*ha
= rsp
->hw
;
1369 srb_t
*sp
= rsp
->status_srb
;
1370 struct scsi_cmnd
*cp
;
1372 if (sp
!= NULL
&& sp
->request_sense_length
!= 0) {
1375 DEBUG2(printk("%s(): Cmd already returned back to OS "
1376 "sp=%p.\n", __func__
, sp
));
1377 qla_printk(KERN_INFO
, ha
,
1378 "cmd is NULL: already returned to OS (sp=%p)\n",
1381 rsp
->status_srb
= NULL
;
1385 if (sp
->request_sense_length
> sizeof(pkt
->data
)) {
1386 sense_sz
= sizeof(pkt
->data
);
1388 sense_sz
= sp
->request_sense_length
;
1391 /* Move sense data. */
1392 if (IS_FWI2_CAPABLE(ha
))
1393 host_to_fcp_swap(pkt
->data
, sizeof(pkt
->data
));
1394 memcpy(sp
->request_sense_ptr
, pkt
->data
, sense_sz
);
1395 DEBUG5(qla2x00_dump_buffer(sp
->request_sense_ptr
, sense_sz
));
1397 sp
->request_sense_ptr
+= sense_sz
;
1398 sp
->request_sense_length
-= sense_sz
;
1400 /* Place command on done queue. */
1401 if (sp
->request_sense_length
== 0) {
1402 rsp
->status_srb
= NULL
;
1403 qla2x00_sp_compl(ha
, sp
);
1409 * qla2x00_error_entry() - Process an error entry.
1410 * @ha: SCSI driver HA context
1411 * @pkt: Entry pointer
1414 qla2x00_error_entry(scsi_qla_host_t
*vha
, struct rsp_que
*rsp
, sts_entry_t
*pkt
)
1417 struct qla_hw_data
*ha
= vha
->hw
;
1418 uint32_t handle
= LSW(pkt
->handle
);
1419 uint16_t que
= MSW(pkt
->handle
);
1420 struct req_que
*req
= ha
->req_q_map
[que
];
1421 #if defined(QL_DEBUG_LEVEL_2)
1422 if (pkt
->entry_status
& RF_INV_E_ORDER
)
1423 qla_printk(KERN_ERR
, ha
, "%s: Invalid Entry Order\n", __func__
);
1424 else if (pkt
->entry_status
& RF_INV_E_COUNT
)
1425 qla_printk(KERN_ERR
, ha
, "%s: Invalid Entry Count\n", __func__
);
1426 else if (pkt
->entry_status
& RF_INV_E_PARAM
)
1427 qla_printk(KERN_ERR
, ha
,
1428 "%s: Invalid Entry Parameter\n", __func__
);
1429 else if (pkt
->entry_status
& RF_INV_E_TYPE
)
1430 qla_printk(KERN_ERR
, ha
, "%s: Invalid Entry Type\n", __func__
);
1431 else if (pkt
->entry_status
& RF_BUSY
)
1432 qla_printk(KERN_ERR
, ha
, "%s: Busy\n", __func__
);
1434 qla_printk(KERN_ERR
, ha
, "%s: UNKNOWN flag error\n", __func__
);
1437 /* Validate handle. */
1438 if (handle
< MAX_OUTSTANDING_COMMANDS
)
1439 sp
= req
->outstanding_cmds
[handle
];
1444 /* Free outstanding command slot. */
1445 req
->outstanding_cmds
[handle
] = NULL
;
1447 /* Bad payload or header */
1448 if (pkt
->entry_status
&
1449 (RF_INV_E_ORDER
| RF_INV_E_COUNT
|
1450 RF_INV_E_PARAM
| RF_INV_E_TYPE
)) {
1451 sp
->cmd
->result
= DID_ERROR
<< 16;
1452 } else if (pkt
->entry_status
& RF_BUSY
) {
1453 sp
->cmd
->result
= DID_BUS_BUSY
<< 16;
1455 sp
->cmd
->result
= DID_ERROR
<< 16;
1457 qla2x00_sp_compl(ha
, sp
);
1459 } else if (pkt
->entry_type
== COMMAND_A64_TYPE
|| pkt
->entry_type
==
1460 COMMAND_TYPE
|| pkt
->entry_type
== COMMAND_TYPE_7
) {
1461 DEBUG2(printk("scsi(%ld): Error entry - invalid handle\n",
1463 qla_printk(KERN_WARNING
, ha
,
1464 "Error entry - invalid handle\n");
1466 set_bit(ISP_ABORT_NEEDED
, &vha
->dpc_flags
);
1467 qla2xxx_wake_dpc(vha
);
1472 * qla24xx_mbx_completion() - Process mailbox command completions.
1473 * @ha: SCSI driver HA context
1474 * @mb0: Mailbox0 register
1477 qla24xx_mbx_completion(scsi_qla_host_t
*vha
, uint16_t mb0
)
1480 uint16_t __iomem
*wptr
;
1481 struct qla_hw_data
*ha
= vha
->hw
;
1482 struct device_reg_24xx __iomem
*reg
= &ha
->iobase
->isp24
;
1484 /* Load return mailbox registers. */
1485 ha
->flags
.mbox_int
= 1;
1486 ha
->mailbox_out
[0] = mb0
;
1487 wptr
= (uint16_t __iomem
*)®
->mailbox1
;
1489 for (cnt
= 1; cnt
< ha
->mbx_count
; cnt
++) {
1490 ha
->mailbox_out
[cnt
] = RD_REG_WORD(wptr
);
1495 DEBUG3(printk("%s(%ld): Got mailbox completion. cmd=%x.\n",
1496 __func__
, vha
->host_no
, ha
->mcp
->mb
[0]));
1498 DEBUG2_3(printk("%s(%ld): MBX pointer ERROR!\n",
1499 __func__
, vha
->host_no
));
1504 * qla24xx_process_response_queue() - Process response queue entries.
1505 * @ha: SCSI driver HA context
1507 void qla24xx_process_response_queue(struct scsi_qla_host
*vha
,
1508 struct rsp_que
*rsp
)
1510 struct sts_entry_24xx
*pkt
;
1512 if (!vha
->flags
.online
)
1515 while (rsp
->ring_ptr
->signature
!= RESPONSE_PROCESSED
) {
1516 pkt
= (struct sts_entry_24xx
*)rsp
->ring_ptr
;
1519 if (rsp
->ring_index
== rsp
->length
) {
1520 rsp
->ring_index
= 0;
1521 rsp
->ring_ptr
= rsp
->ring
;
1526 if (pkt
->entry_status
!= 0) {
1527 DEBUG3(printk(KERN_INFO
1528 "scsi(%ld): Process error entry.\n", vha
->host_no
));
1530 qla2x00_error_entry(vha
, rsp
, (sts_entry_t
*) pkt
);
1531 ((response_t
*)pkt
)->signature
= RESPONSE_PROCESSED
;
1536 switch (pkt
->entry_type
) {
1538 qla2x00_status_entry(vha
, rsp
, pkt
);
1540 case STATUS_CONT_TYPE
:
1541 qla2x00_status_cont_entry(rsp
, (sts_cont_entry_t
*)pkt
);
1543 case VP_RPT_ID_IOCB_TYPE
:
1544 qla24xx_report_id_acquisition(vha
,
1545 (struct vp_rpt_id_entry_24xx
*)pkt
);
1548 /* Type Not Supported. */
1549 DEBUG4(printk(KERN_WARNING
1550 "scsi(%ld): Received unknown response pkt type %x "
1551 "entry status=%x.\n",
1552 vha
->host_no
, pkt
->entry_type
, pkt
->entry_status
));
1555 ((response_t
*)pkt
)->signature
= RESPONSE_PROCESSED
;
1559 /* Adjust ring index */
1560 WRT_REG_DWORD(rsp
->rsp_q_out
, rsp
->ring_index
);
1564 qla2xxx_check_risc_status(scsi_qla_host_t
*vha
)
1568 struct qla_hw_data
*ha
= vha
->hw
;
1569 struct device_reg_24xx __iomem
*reg
= &ha
->iobase
->isp24
;
1571 if (!IS_QLA25XX(ha
) && !IS_QLA81XX(ha
))
1575 WRT_REG_DWORD(®
->iobase_addr
, 0x7C00);
1576 RD_REG_DWORD(®
->iobase_addr
);
1577 WRT_REG_DWORD(®
->iobase_window
, 0x0001);
1578 for (cnt
= 10000; (RD_REG_DWORD(®
->iobase_window
) & BIT_0
) == 0 &&
1579 rval
== QLA_SUCCESS
; cnt
--) {
1581 WRT_REG_DWORD(®
->iobase_window
, 0x0001);
1584 rval
= QLA_FUNCTION_TIMEOUT
;
1586 if (rval
== QLA_SUCCESS
)
1589 WRT_REG_DWORD(®
->iobase_window
, 0x0003);
1590 for (cnt
= 100; (RD_REG_DWORD(®
->iobase_window
) & BIT_0
) == 0 &&
1591 rval
== QLA_SUCCESS
; cnt
--) {
1593 WRT_REG_DWORD(®
->iobase_window
, 0x0003);
1596 rval
= QLA_FUNCTION_TIMEOUT
;
1598 if (rval
!= QLA_SUCCESS
)
1602 if (RD_REG_DWORD(®
->iobase_c8
) & BIT_3
)
1603 qla_printk(KERN_INFO
, ha
, "Additional code -- 0x55AA.\n");
1606 WRT_REG_DWORD(®
->iobase_window
, 0x0000);
1607 RD_REG_DWORD(®
->iobase_window
);
1611 * qla24xx_intr_handler() - Process interrupts for the ISP23xx and ISP63xx.
1613 * @dev_id: SCSI driver HA context
1615 * Called by system whenever the host adapter generates an interrupt.
1617 * Returns handled flag.
1620 qla24xx_intr_handler(int irq
, void *dev_id
)
1622 scsi_qla_host_t
*vha
;
1623 struct qla_hw_data
*ha
;
1624 struct device_reg_24xx __iomem
*reg
;
1630 struct rsp_que
*rsp
;
1631 unsigned long flags
;
1633 rsp
= (struct rsp_que
*) dev_id
;
1636 "%s(): NULL response queue pointer\n", __func__
);
1641 reg
= &ha
->iobase
->isp24
;
1644 spin_lock_irqsave(&ha
->hardware_lock
, flags
);
1645 vha
= pci_get_drvdata(ha
->pdev
);
1646 for (iter
= 50; iter
--; ) {
1647 stat
= RD_REG_DWORD(®
->host_status
);
1648 if (stat
& HSRX_RISC_PAUSED
) {
1649 if (pci_channel_offline(ha
->pdev
))
1652 hccr
= RD_REG_DWORD(®
->hccr
);
1654 qla_printk(KERN_INFO
, ha
, "RISC paused -- HCCR=%x, "
1655 "Dumping firmware!\n", hccr
);
1657 qla2xxx_check_risc_status(vha
);
1659 ha
->isp_ops
->fw_dump(vha
, 1);
1660 set_bit(ISP_ABORT_NEEDED
, &vha
->dpc_flags
);
1662 } else if ((stat
& HSRX_RISC_INT
) == 0)
1665 switch (stat
& 0xff) {
1670 qla24xx_mbx_completion(vha
, MSW(stat
));
1671 status
|= MBX_INTERRUPT
;
1676 mb
[1] = RD_REG_WORD(®
->mailbox1
);
1677 mb
[2] = RD_REG_WORD(®
->mailbox2
);
1678 mb
[3] = RD_REG_WORD(®
->mailbox3
);
1679 qla2x00_async_event(vha
, rsp
, mb
);
1683 qla24xx_process_response_queue(vha
, rsp
);
1686 DEBUG2(printk("scsi(%ld): Unrecognized interrupt type "
1688 vha
->host_no
, stat
& 0xff));
1691 WRT_REG_DWORD(®
->hccr
, HCCRX_CLR_RISC_INT
);
1692 RD_REG_DWORD_RELAXED(®
->hccr
);
1694 spin_unlock_irqrestore(&ha
->hardware_lock
, flags
);
1696 if (test_bit(MBX_INTR_WAIT
, &ha
->mbx_cmd_flags
) &&
1697 (status
& MBX_INTERRUPT
) && ha
->flags
.mbox_int
) {
1698 set_bit(MBX_INTERRUPT
, &ha
->mbx_cmd_flags
);
1699 complete(&ha
->mbx_intr_comp
);
1706 qla24xx_msix_rsp_q(int irq
, void *dev_id
)
1708 struct qla_hw_data
*ha
;
1709 struct rsp_que
*rsp
;
1710 struct device_reg_24xx __iomem
*reg
;
1711 struct scsi_qla_host
*vha
;
1713 rsp
= (struct rsp_que
*) dev_id
;
1716 "%s(): NULL response queue pointer\n", __func__
);
1720 reg
= &ha
->iobase
->isp24
;
1722 spin_lock_irq(&ha
->hardware_lock
);
1724 vha
= qla25xx_get_host(rsp
);
1725 qla24xx_process_response_queue(vha
, rsp
);
1726 WRT_REG_DWORD(®
->hccr
, HCCRX_CLR_RISC_INT
);
1728 spin_unlock_irq(&ha
->hardware_lock
);
1734 qla25xx_msix_rsp_q(int irq
, void *dev_id
)
1736 struct qla_hw_data
*ha
;
1737 struct rsp_que
*rsp
;
1739 rsp
= (struct rsp_que
*) dev_id
;
1742 "%s(): NULL response queue pointer\n", __func__
);
1747 queue_work_on((int) (rsp
->id
- 1), ha
->wq
, &rsp
->q_work
);
1753 qla24xx_msix_default(int irq
, void *dev_id
)
1755 scsi_qla_host_t
*vha
;
1756 struct qla_hw_data
*ha
;
1757 struct rsp_que
*rsp
;
1758 struct device_reg_24xx __iomem
*reg
;
1764 rsp
= (struct rsp_que
*) dev_id
;
1767 "%s(): NULL response queue pointer\n", __func__
));
1771 reg
= &ha
->iobase
->isp24
;
1774 spin_lock_irq(&ha
->hardware_lock
);
1775 vha
= pci_get_drvdata(ha
->pdev
);
1777 stat
= RD_REG_DWORD(®
->host_status
);
1778 if (stat
& HSRX_RISC_PAUSED
) {
1779 if (pci_channel_offline(ha
->pdev
))
1782 hccr
= RD_REG_DWORD(®
->hccr
);
1784 qla_printk(KERN_INFO
, ha
, "RISC paused -- HCCR=%x, "
1785 "Dumping firmware!\n", hccr
);
1787 qla2xxx_check_risc_status(vha
);
1789 ha
->isp_ops
->fw_dump(vha
, 1);
1790 set_bit(ISP_ABORT_NEEDED
, &vha
->dpc_flags
);
1792 } else if ((stat
& HSRX_RISC_INT
) == 0)
1795 switch (stat
& 0xff) {
1800 qla24xx_mbx_completion(vha
, MSW(stat
));
1801 status
|= MBX_INTERRUPT
;
1806 mb
[1] = RD_REG_WORD(®
->mailbox1
);
1807 mb
[2] = RD_REG_WORD(®
->mailbox2
);
1808 mb
[3] = RD_REG_WORD(®
->mailbox3
);
1809 qla2x00_async_event(vha
, rsp
, mb
);
1813 qla24xx_process_response_queue(vha
, rsp
);
1816 DEBUG2(printk("scsi(%ld): Unrecognized interrupt type "
1818 vha
->host_no
, stat
& 0xff));
1821 WRT_REG_DWORD(®
->hccr
, HCCRX_CLR_RISC_INT
);
1823 spin_unlock_irq(&ha
->hardware_lock
);
1825 if (test_bit(MBX_INTR_WAIT
, &ha
->mbx_cmd_flags
) &&
1826 (status
& MBX_INTERRUPT
) && ha
->flags
.mbox_int
) {
1827 set_bit(MBX_INTERRUPT
, &ha
->mbx_cmd_flags
);
1828 complete(&ha
->mbx_intr_comp
);
1834 /* Interrupt handling helpers. */
1836 struct qla_init_msix_entry
{
1838 irq_handler_t handler
;
1841 static struct qla_init_msix_entry msix_entries
[3] = {
1842 { "qla2xxx (default)", qla24xx_msix_default
},
1843 { "qla2xxx (rsp_q)", qla24xx_msix_rsp_q
},
1844 { "qla2xxx (multiq)", qla25xx_msix_rsp_q
},
1848 qla24xx_disable_msix(struct qla_hw_data
*ha
)
1851 struct qla_msix_entry
*qentry
;
1853 for (i
= 0; i
< ha
->msix_count
; i
++) {
1854 qentry
= &ha
->msix_entries
[i
];
1855 if (qentry
->have_irq
)
1856 free_irq(qentry
->vector
, qentry
->rsp
);
1858 pci_disable_msix(ha
->pdev
);
1859 kfree(ha
->msix_entries
);
1860 ha
->msix_entries
= NULL
;
1861 ha
->flags
.msix_enabled
= 0;
1865 qla24xx_enable_msix(struct qla_hw_data
*ha
, struct rsp_que
*rsp
)
1867 #define MIN_MSIX_COUNT 2
1869 struct msix_entry
*entries
;
1870 struct qla_msix_entry
*qentry
;
1872 entries
= kzalloc(sizeof(struct msix_entry
) * ha
->msix_count
,
1877 for (i
= 0; i
< ha
->msix_count
; i
++)
1878 entries
[i
].entry
= i
;
1880 ret
= pci_enable_msix(ha
->pdev
, entries
, ha
->msix_count
);
1882 if (ret
< MIN_MSIX_COUNT
)
1885 qla_printk(KERN_WARNING
, ha
,
1886 "MSI-X: Failed to enable support -- %d/%d\n"
1887 " Retry with %d vectors\n", ha
->msix_count
, ret
, ret
);
1888 ha
->msix_count
= ret
;
1889 ret
= pci_enable_msix(ha
->pdev
, entries
, ha
->msix_count
);
1892 qla_printk(KERN_WARNING
, ha
, "MSI-X: Failed to enable"
1893 " support, giving up -- %d/%d\n",
1894 ha
->msix_count
, ret
);
1897 ha
->max_rsp_queues
= ha
->msix_count
- 1;
1899 ha
->msix_entries
= kzalloc(sizeof(struct qla_msix_entry
) *
1900 ha
->msix_count
, GFP_KERNEL
);
1901 if (!ha
->msix_entries
) {
1905 ha
->flags
.msix_enabled
= 1;
1907 for (i
= 0; i
< ha
->msix_count
; i
++) {
1908 qentry
= &ha
->msix_entries
[i
];
1909 qentry
->vector
= entries
[i
].vector
;
1910 qentry
->entry
= entries
[i
].entry
;
1911 qentry
->have_irq
= 0;
1915 /* Enable MSI-X vectors for the base queue */
1916 for (i
= 0; i
< 2; i
++) {
1917 qentry
= &ha
->msix_entries
[i
];
1918 ret
= request_irq(qentry
->vector
, msix_entries
[i
].handler
,
1919 0, msix_entries
[i
].name
, rsp
);
1921 qla_printk(KERN_WARNING
, ha
,
1922 "MSI-X: Unable to register handler -- %x/%d.\n",
1923 qentry
->vector
, ret
);
1924 qla24xx_disable_msix(ha
);
1928 qentry
->have_irq
= 1;
1933 /* Enable MSI-X vector for response queue update for queue 0 */
1934 if (ha
->mqiobase
&& (ha
->max_rsp_queues
> 1 || ha
->max_req_queues
> 1))
1943 qla2x00_request_irqs(struct qla_hw_data
*ha
, struct rsp_que
*rsp
)
1946 device_reg_t __iomem
*reg
= ha
->iobase
;
1948 /* If possible, enable MSI-X. */
1949 if (!IS_QLA2432(ha
) && !IS_QLA2532(ha
) &&
1950 !IS_QLA8432(ha
) && !IS_QLA8001(ha
))
1953 if (IS_QLA2432(ha
) && (ha
->pdev
->revision
< QLA_MSIX_CHIP_REV_24XX
||
1954 !QLA_MSIX_FW_MODE_1(ha
->fw_attributes
))) {
1955 DEBUG2(qla_printk(KERN_WARNING
, ha
,
1956 "MSI-X: Unsupported ISP2432 (0x%X, 0x%X).\n",
1957 ha
->pdev
->revision
, ha
->fw_attributes
));
1962 if (ha
->pdev
->subsystem_vendor
== PCI_VENDOR_ID_HP
&&
1963 (ha
->pdev
->subsystem_device
== 0x7040 ||
1964 ha
->pdev
->subsystem_device
== 0x7041 ||
1965 ha
->pdev
->subsystem_device
== 0x1705)) {
1966 DEBUG2(qla_printk(KERN_WARNING
, ha
,
1967 "MSI-X: Unsupported ISP2432 SSVID/SSDID (0x%X, 0x%X).\n",
1968 ha
->pdev
->subsystem_vendor
,
1969 ha
->pdev
->subsystem_device
));
1974 ret
= qla24xx_enable_msix(ha
, rsp
);
1976 DEBUG2(qla_printk(KERN_INFO
, ha
,
1977 "MSI-X: Enabled (0x%X, 0x%X).\n", ha
->chip_revision
,
1978 ha
->fw_attributes
));
1979 goto clear_risc_ints
;
1981 qla_printk(KERN_WARNING
, ha
,
1982 "MSI-X: Falling back-to INTa mode -- %d.\n", ret
);
1985 if (!IS_QLA24XX(ha
) && !IS_QLA2532(ha
) && !IS_QLA8432(ha
) &&
1989 ret
= pci_enable_msi(ha
->pdev
);
1991 DEBUG2(qla_printk(KERN_INFO
, ha
, "MSI: Enabled.\n"));
1992 ha
->flags
.msi_enabled
= 1;
1996 ret
= request_irq(ha
->pdev
->irq
, ha
->isp_ops
->intr_handler
,
1997 IRQF_SHARED
, QLA2XXX_DRIVER_NAME
, rsp
);
1999 qla_printk(KERN_WARNING
, ha
,
2000 "Failed to reserve interrupt %d already in use.\n",
2004 ha
->flags
.inta_enabled
= 1;
2008 * FIXME: Noted that 8014s were being dropped during NK testing.
2009 * Timing deltas during MSI-X/INTa transitions?
2013 spin_lock_irq(&ha
->hardware_lock
);
2014 if (IS_FWI2_CAPABLE(ha
)) {
2015 WRT_REG_DWORD(®
->isp24
.hccr
, HCCRX_CLR_HOST_INT
);
2016 WRT_REG_DWORD(®
->isp24
.hccr
, HCCRX_CLR_RISC_INT
);
2018 WRT_REG_WORD(®
->isp
.semaphore
, 0);
2019 WRT_REG_WORD(®
->isp
.hccr
, HCCR_CLR_RISC_INT
);
2020 WRT_REG_WORD(®
->isp
.hccr
, HCCR_CLR_HOST_INT
);
2022 spin_unlock_irq(&ha
->hardware_lock
);
2029 qla2x00_free_irqs(scsi_qla_host_t
*vha
)
2031 struct qla_hw_data
*ha
= vha
->hw
;
2032 struct rsp_que
*rsp
= ha
->rsp_q_map
[0];
2034 if (ha
->flags
.msix_enabled
)
2035 qla24xx_disable_msix(ha
);
2036 else if (ha
->flags
.inta_enabled
) {
2037 free_irq(ha
->pdev
->irq
, rsp
);
2038 pci_disable_msi(ha
->pdev
);
2043 int qla25xx_request_irq(struct rsp_que
*rsp
)
2045 struct qla_hw_data
*ha
= rsp
->hw
;
2046 struct qla_init_msix_entry
*intr
= &msix_entries
[2];
2047 struct qla_msix_entry
*msix
= rsp
->msix
;
2050 ret
= request_irq(msix
->vector
, intr
->handler
, 0, intr
->name
, rsp
);
2052 qla_printk(KERN_WARNING
, ha
,
2053 "MSI-X: Unable to register handler -- %x/%d.\n",
2062 struct scsi_qla_host
*
2063 qla25xx_get_host(struct rsp_que
*rsp
)
2066 struct qla_hw_data
*ha
= rsp
->hw
;
2067 struct scsi_qla_host
*vha
= NULL
;
2068 struct sts_entry_24xx
*pkt
;
2069 struct req_que
*req
;
2073 pkt
= (struct sts_entry_24xx
*) rsp
->ring_ptr
;
2074 que
= MSW(pkt
->handle
);
2075 handle
= (uint32_t) LSW(pkt
->handle
);
2076 req
= ha
->req_q_map
[que
];
2077 if (handle
< MAX_OUTSTANDING_COMMANDS
) {
2078 sp
= req
->outstanding_cmds
[handle
];
2080 return sp
->fcport
->vha
;
2085 vha
= pci_get_drvdata(ha
->pdev
);