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 */
602 * Handle only global and vn-port update events
605 * mb[1] = N_Port handle of changed port
606 * OR 0xffff for global event
607 * mb[2] = New login state
608 * 7 = Port logged out
609 * mb[3] = LSB is vp_idx, 0xff = all vps
611 * Skip processing if:
612 * Event is global, vp_idx is NOT all vps,
613 * vp_idx does not match
614 * Event is not global, vp_idx does not match
616 if ((mb
[1] == 0xffff && (mb
[3] & 0xff) != 0xff)
617 || (mb
[1] != 0xffff)) {
618 if (vha
->vp_idx
!= (mb
[3] & 0xff))
622 /* Global event -- port logout or port unavailable. */
623 if (mb
[1] == 0xffff && mb
[2] == 0x7) {
624 DEBUG2(printk("scsi(%ld): Asynchronous PORT UPDATE.\n",
626 DEBUG(printk(KERN_INFO
627 "scsi(%ld): Port unavailable %04x %04x %04x.\n",
628 vha
->host_no
, mb
[1], mb
[2], mb
[3]));
630 if (atomic_read(&vha
->loop_state
) != LOOP_DOWN
) {
631 atomic_set(&vha
->loop_state
, LOOP_DOWN
);
632 atomic_set(&vha
->loop_down_timer
,
634 vha
->device_flags
|= DFLG_NO_CABLE
;
635 qla2x00_mark_all_devices_lost(vha
, 1);
639 atomic_set(&vha
->vp_state
, VP_FAILED
);
640 fc_vport_set_state(vha
->fc_vport
,
642 qla2x00_mark_all_devices_lost(vha
, 1);
645 vha
->flags
.management_server_logged_in
= 0;
646 ha
->link_data_rate
= PORT_SPEED_UNKNOWN
;
651 * If PORT UPDATE is global (received LIP_OCCURRED/LIP_RESET
652 * event etc. earlier indicating loop is down) then process
653 * it. Otherwise ignore it and Wait for RSCN to come in.
655 atomic_set(&vha
->loop_down_timer
, 0);
656 if (atomic_read(&vha
->loop_state
) != LOOP_DOWN
&&
657 atomic_read(&vha
->loop_state
) != LOOP_DEAD
) {
658 DEBUG2(printk("scsi(%ld): Asynchronous PORT UPDATE "
659 "ignored %04x/%04x/%04x.\n", vha
->host_no
, mb
[1],
664 DEBUG2(printk("scsi(%ld): Asynchronous PORT UPDATE.\n",
666 DEBUG(printk(KERN_INFO
667 "scsi(%ld): Port database changed %04x %04x %04x.\n",
668 vha
->host_no
, mb
[1], mb
[2], mb
[3]));
671 * Mark all devices as missing so we will login again.
673 atomic_set(&vha
->loop_state
, LOOP_UP
);
675 qla2x00_mark_all_devices_lost(vha
, 1);
677 vha
->flags
.rscn_queue_overflow
= 1;
679 set_bit(LOOP_RESYNC_NEEDED
, &vha
->dpc_flags
);
680 set_bit(LOCAL_LOOP_UPDATE
, &vha
->dpc_flags
);
683 case MBA_RSCN_UPDATE
: /* State Change Registration */
684 /* Check if the Vport has issued a SCR */
685 if (vha
->vp_idx
&& test_bit(VP_SCR_NEEDED
, &vha
->vp_flags
))
687 /* Only handle SCNs for our Vport index. */
688 if (vha
->vp_idx
&& vha
->vp_idx
!= (mb
[3] & 0xff))
690 DEBUG2(printk("scsi(%ld): Asynchronous RSCR UPDATE.\n",
692 DEBUG(printk(KERN_INFO
693 "scsi(%ld): RSCN database changed -- %04x %04x %04x.\n",
694 vha
->host_no
, mb
[1], mb
[2], mb
[3]));
696 rscn_entry
= ((mb
[1] & 0xff) << 16) | mb
[2];
697 host_pid
= (vha
->d_id
.b
.domain
<< 16) | (vha
->d_id
.b
.area
<< 8)
699 if (rscn_entry
== host_pid
) {
700 DEBUG(printk(KERN_INFO
701 "scsi(%ld): Ignoring RSCN update to local host "
703 vha
->host_no
, host_pid
));
707 /* Ignore reserved bits from RSCN-payload. */
708 rscn_entry
= ((mb
[1] & 0x3ff) << 16) | mb
[2];
709 rscn_queue_index
= vha
->rscn_in_ptr
+ 1;
710 if (rscn_queue_index
== MAX_RSCN_COUNT
)
711 rscn_queue_index
= 0;
712 if (rscn_queue_index
!= vha
->rscn_out_ptr
) {
713 vha
->rscn_queue
[vha
->rscn_in_ptr
] = rscn_entry
;
714 vha
->rscn_in_ptr
= rscn_queue_index
;
716 vha
->flags
.rscn_queue_overflow
= 1;
719 atomic_set(&vha
->loop_state
, LOOP_UPDATE
);
720 atomic_set(&vha
->loop_down_timer
, 0);
721 vha
->flags
.management_server_logged_in
= 0;
723 set_bit(LOOP_RESYNC_NEEDED
, &vha
->dpc_flags
);
724 set_bit(RSCN_UPDATE
, &vha
->dpc_flags
);
725 qla2x00_post_aen_work(vha
, FCH_EVT_RSCN
, rscn_entry
);
728 /* case MBA_RIO_RESPONSE: */
729 case MBA_ZIO_RESPONSE
:
730 DEBUG3(printk("scsi(%ld): [R|Z]IO update completion.\n",
733 if (IS_FWI2_CAPABLE(ha
))
734 qla24xx_process_response_queue(vha
, rsp
);
736 qla2x00_process_response_queue(rsp
);
739 case MBA_DISCARD_RND_FRAME
:
740 DEBUG2(printk("scsi(%ld): Discard RND Frame -- %04x %04x "
741 "%04x.\n", vha
->host_no
, mb
[1], mb
[2], mb
[3]));
744 case MBA_TRACE_NOTIFICATION
:
745 DEBUG2(printk("scsi(%ld): Trace Notification -- %04x %04x.\n",
746 vha
->host_no
, mb
[1], mb
[2]));
749 case MBA_ISP84XX_ALERT
:
750 DEBUG2(printk("scsi(%ld): ISP84XX Alert Notification -- "
751 "%04x %04x %04x\n", vha
->host_no
, mb
[1], mb
[2], mb
[3]));
753 spin_lock_irqsave(&ha
->cs84xx
->access_lock
, flags
);
755 case A84_PANIC_RECOVERY
:
756 qla_printk(KERN_INFO
, ha
, "Alert 84XX: panic recovery "
757 "%04x %04x\n", mb
[2], mb
[3]);
759 case A84_OP_LOGIN_COMPLETE
:
760 ha
->cs84xx
->op_fw_version
= mb
[3] << 16 | mb
[2];
761 DEBUG2(qla_printk(KERN_INFO
, ha
, "Alert 84XX:"
762 "firmware version %x\n", ha
->cs84xx
->op_fw_version
));
764 case A84_DIAG_LOGIN_COMPLETE
:
765 ha
->cs84xx
->diag_fw_version
= mb
[3] << 16 | mb
[2];
766 DEBUG2(qla_printk(KERN_INFO
, ha
, "Alert 84XX:"
767 "diagnostic firmware version %x\n",
768 ha
->cs84xx
->diag_fw_version
));
770 case A84_GOLD_LOGIN_COMPLETE
:
771 ha
->cs84xx
->diag_fw_version
= mb
[3] << 16 | mb
[2];
772 ha
->cs84xx
->fw_update
= 1;
773 DEBUG2(qla_printk(KERN_INFO
, ha
, "Alert 84XX: gold "
774 "firmware version %x\n",
775 ha
->cs84xx
->gold_fw_version
));
778 qla_printk(KERN_ERR
, ha
,
779 "Alert 84xx: Invalid Alert %04x %04x %04x\n",
780 mb
[1], mb
[2], mb
[3]);
782 spin_unlock_irqrestore(&ha
->cs84xx
->access_lock
, flags
);
785 DEBUG2(printk("scsi(%ld): DCBX Started -- %04x %04x %04x\n",
786 vha
->host_no
, mb
[1], mb
[2], mb
[3]));
788 case MBA_DCBX_PARAM_UPDATE
:
789 DEBUG2(printk("scsi(%ld): DCBX Parameters Updated -- "
790 "%04x %04x %04x\n", vha
->host_no
, mb
[1], mb
[2], mb
[3]));
792 case MBA_FCF_CONF_ERR
:
793 DEBUG2(printk("scsi(%ld): FCF Configuration Error -- "
794 "%04x %04x %04x\n", vha
->host_no
, mb
[1], mb
[2], mb
[3]));
796 case MBA_IDC_COMPLETE
:
798 case MBA_IDC_TIME_EXT
:
799 qla81xx_idc_event(vha
, mb
[0], mb
[1]);
803 if (!vha
->vp_idx
&& ha
->num_vhosts
)
804 qla2x00_alert_all_vps(rsp
, mb
);
808 qla2x00_adjust_sdev_qdepth_up(struct scsi_device
*sdev
, void *data
)
810 fc_port_t
*fcport
= data
;
811 struct scsi_qla_host
*vha
= fcport
->vha
;
812 struct qla_hw_data
*ha
= vha
->hw
;
813 struct req_que
*req
= NULL
;
815 if (!ql2xqfulltracking
)
821 if (req
->max_q_depth
<= sdev
->queue_depth
)
824 if (sdev
->ordered_tags
)
825 scsi_adjust_queue_depth(sdev
, MSG_ORDERED_TAG
,
826 sdev
->queue_depth
+ 1);
828 scsi_adjust_queue_depth(sdev
, MSG_SIMPLE_TAG
,
829 sdev
->queue_depth
+ 1);
831 fcport
->last_ramp_up
= jiffies
;
833 DEBUG2(qla_printk(KERN_INFO
, ha
,
834 "scsi(%ld:%d:%d:%d): Queue depth adjusted-up to %d.\n",
835 fcport
->vha
->host_no
, sdev
->channel
, sdev
->id
, sdev
->lun
,
840 qla2x00_adjust_sdev_qdepth_down(struct scsi_device
*sdev
, void *data
)
842 fc_port_t
*fcport
= data
;
844 if (!scsi_track_queue_full(sdev
, sdev
->queue_depth
- 1))
847 DEBUG2(qla_printk(KERN_INFO
, fcport
->vha
->hw
,
848 "scsi(%ld:%d:%d:%d): Queue depth adjusted-down to %d.\n",
849 fcport
->vha
->host_no
, sdev
->channel
, sdev
->id
, sdev
->lun
,
854 qla2x00_ramp_up_queue_depth(scsi_qla_host_t
*vha
, struct req_que
*req
,
858 struct scsi_device
*sdev
;
860 if (!ql2xqfulltracking
)
863 sdev
= sp
->cmd
->device
;
864 if (sdev
->queue_depth
>= req
->max_q_depth
)
868 if (time_before(jiffies
,
869 fcport
->last_ramp_up
+ ql2xqfullrampup
* HZ
))
871 if (time_before(jiffies
,
872 fcport
->last_queue_full
+ ql2xqfullrampup
* HZ
))
875 starget_for_each_device(sdev
->sdev_target
, fcport
,
876 qla2x00_adjust_sdev_qdepth_up
);
880 * qla2x00_process_completed_request() - Process a Fast Post response.
881 * @ha: SCSI driver HA context
885 qla2x00_process_completed_request(struct scsi_qla_host
*vha
,
886 struct req_que
*req
, uint32_t index
)
889 struct qla_hw_data
*ha
= vha
->hw
;
891 /* Validate handle. */
892 if (index
>= MAX_OUTSTANDING_COMMANDS
) {
893 DEBUG2(printk("scsi(%ld): Invalid SCSI completion handle %d.\n",
894 vha
->host_no
, index
));
895 qla_printk(KERN_WARNING
, ha
,
896 "Invalid SCSI completion handle %d.\n", index
);
898 set_bit(ISP_ABORT_NEEDED
, &vha
->dpc_flags
);
902 sp
= req
->outstanding_cmds
[index
];
904 /* Free outstanding command slot. */
905 req
->outstanding_cmds
[index
] = NULL
;
907 /* Save ISP completion status */
908 sp
->cmd
->result
= DID_OK
<< 16;
910 qla2x00_ramp_up_queue_depth(vha
, req
, sp
);
911 qla2x00_sp_compl(ha
, sp
);
913 DEBUG2(printk("scsi(%ld) Req:%d: Invalid ISP SCSI completion"
914 " handle(%d)\n", vha
->host_no
, req
->id
, index
));
915 qla_printk(KERN_WARNING
, ha
,
916 "Invalid ISP SCSI completion handle\n");
918 set_bit(ISP_ABORT_NEEDED
, &vha
->dpc_flags
);
923 * qla2x00_process_response_queue() - Process response queue entries.
924 * @ha: SCSI driver HA context
927 qla2x00_process_response_queue(struct rsp_que
*rsp
)
929 struct scsi_qla_host
*vha
;
930 struct qla_hw_data
*ha
= rsp
->hw
;
931 struct device_reg_2xxx __iomem
*reg
= &ha
->iobase
->isp
;
936 vha
= pci_get_drvdata(ha
->pdev
);
938 if (!vha
->flags
.online
)
941 while (rsp
->ring_ptr
->signature
!= RESPONSE_PROCESSED
) {
942 pkt
= (sts_entry_t
*)rsp
->ring_ptr
;
945 if (rsp
->ring_index
== rsp
->length
) {
947 rsp
->ring_ptr
= rsp
->ring
;
952 if (pkt
->entry_status
!= 0) {
953 DEBUG3(printk(KERN_INFO
954 "scsi(%ld): Process error entry.\n", vha
->host_no
));
956 qla2x00_error_entry(vha
, rsp
, pkt
);
957 ((response_t
*)pkt
)->signature
= RESPONSE_PROCESSED
;
962 switch (pkt
->entry_type
) {
964 qla2x00_status_entry(vha
, rsp
, pkt
);
967 handle_cnt
= ((sts21_entry_t
*)pkt
)->handle_count
;
968 for (cnt
= 0; cnt
< handle_cnt
; cnt
++) {
969 qla2x00_process_completed_request(vha
, rsp
->req
,
970 ((sts21_entry_t
*)pkt
)->handle
[cnt
]);
974 handle_cnt
= ((sts22_entry_t
*)pkt
)->handle_count
;
975 for (cnt
= 0; cnt
< handle_cnt
; cnt
++) {
976 qla2x00_process_completed_request(vha
, rsp
->req
,
977 ((sts22_entry_t
*)pkt
)->handle
[cnt
]);
980 case STATUS_CONT_TYPE
:
981 qla2x00_status_cont_entry(rsp
, (sts_cont_entry_t
*)pkt
);
984 /* Type Not Supported. */
985 DEBUG4(printk(KERN_WARNING
986 "scsi(%ld): Received unknown response pkt type %x "
987 "entry status=%x.\n",
988 vha
->host_no
, pkt
->entry_type
, pkt
->entry_status
));
991 ((response_t
*)pkt
)->signature
= RESPONSE_PROCESSED
;
995 /* Adjust ring index */
996 WRT_REG_WORD(ISP_RSP_Q_OUT(ha
, reg
), rsp
->ring_index
);
1000 qla2x00_handle_sense(srb_t
*sp
, uint8_t *sense_data
, uint32_t sense_len
,
1001 struct rsp_que
*rsp
)
1003 struct scsi_cmnd
*cp
= sp
->cmd
;
1005 if (sense_len
>= SCSI_SENSE_BUFFERSIZE
)
1006 sense_len
= SCSI_SENSE_BUFFERSIZE
;
1008 sp
->request_sense_length
= sense_len
;
1009 sp
->request_sense_ptr
= cp
->sense_buffer
;
1010 if (sp
->request_sense_length
> 32)
1013 memcpy(cp
->sense_buffer
, sense_data
, sense_len
);
1015 sp
->request_sense_ptr
+= sense_len
;
1016 sp
->request_sense_length
-= sense_len
;
1017 if (sp
->request_sense_length
!= 0)
1018 rsp
->status_srb
= sp
;
1020 DEBUG5(printk("%s(): Check condition Sense data, scsi(%ld:%d:%d:%d) "
1021 "cmd=%p pid=%ld\n", __func__
, sp
->fcport
->vha
->host_no
,
1022 cp
->device
->channel
, cp
->device
->id
, cp
->device
->lun
, cp
,
1023 cp
->serial_number
));
1025 DEBUG5(qla2x00_dump_buffer(cp
->sense_buffer
, sense_len
));
1029 * qla2x00_status_entry() - Process a Status IOCB entry.
1030 * @ha: SCSI driver HA context
1031 * @pkt: Entry pointer
1034 qla2x00_status_entry(scsi_qla_host_t
*vha
, struct rsp_que
*rsp
, void *pkt
)
1038 struct scsi_cmnd
*cp
;
1040 struct sts_entry_24xx
*sts24
;
1041 uint16_t comp_status
;
1042 uint16_t scsi_status
;
1043 uint8_t lscsi_status
;
1045 uint32_t sense_len
, rsp_info_len
, resid_len
, fw_resid_len
;
1046 uint8_t *rsp_info
, *sense_data
;
1047 struct qla_hw_data
*ha
= vha
->hw
;
1050 struct req_que
*req
;
1052 sts
= (sts_entry_t
*) pkt
;
1053 sts24
= (struct sts_entry_24xx
*) pkt
;
1054 if (IS_FWI2_CAPABLE(ha
)) {
1055 comp_status
= le16_to_cpu(sts24
->comp_status
);
1056 scsi_status
= le16_to_cpu(sts24
->scsi_status
) & SS_MASK
;
1058 comp_status
= le16_to_cpu(sts
->comp_status
);
1059 scsi_status
= le16_to_cpu(sts
->scsi_status
) & SS_MASK
;
1061 handle
= (uint32_t) LSW(sts
->handle
);
1062 que
= MSW(sts
->handle
);
1063 req
= ha
->req_q_map
[que
];
1064 /* Fast path completion. */
1065 if (comp_status
== CS_COMPLETE
&& scsi_status
== 0) {
1066 qla2x00_process_completed_request(vha
, req
, handle
);
1071 /* Validate handle. */
1072 if (handle
< MAX_OUTSTANDING_COMMANDS
) {
1073 sp
= req
->outstanding_cmds
[handle
];
1074 req
->outstanding_cmds
[handle
] = NULL
;
1079 DEBUG2(printk("scsi(%ld): Status Entry invalid handle.\n",
1081 qla_printk(KERN_WARNING
, ha
, "Status Entry invalid handle.\n");
1083 set_bit(ISP_ABORT_NEEDED
, &vha
->dpc_flags
);
1084 qla2xxx_wake_dpc(vha
);
1089 DEBUG2(printk("scsi(%ld): Command already returned back to OS "
1090 "pkt->handle=%d sp=%p.\n", vha
->host_no
, handle
, sp
));
1091 qla_printk(KERN_WARNING
, ha
,
1092 "Command is NULL: already returned to OS (sp=%p)\n", sp
);
1097 lscsi_status
= scsi_status
& STATUS_MASK
;
1099 fcport
= sp
->fcport
;
1101 sense_len
= rsp_info_len
= resid_len
= fw_resid_len
= 0;
1102 if (IS_FWI2_CAPABLE(ha
)) {
1103 sense_len
= le32_to_cpu(sts24
->sense_len
);
1104 rsp_info_len
= le32_to_cpu(sts24
->rsp_data_len
);
1105 resid_len
= le32_to_cpu(sts24
->rsp_residual_count
);
1106 fw_resid_len
= le32_to_cpu(sts24
->residual_len
);
1107 rsp_info
= sts24
->data
;
1108 sense_data
= sts24
->data
;
1109 host_to_fcp_swap(sts24
->data
, sizeof(sts24
->data
));
1111 sense_len
= le16_to_cpu(sts
->req_sense_length
);
1112 rsp_info_len
= le16_to_cpu(sts
->rsp_info_len
);
1113 resid_len
= le32_to_cpu(sts
->residual_length
);
1114 rsp_info
= sts
->rsp_info
;
1115 sense_data
= sts
->req_sense_data
;
1118 /* Check for any FCP transport errors. */
1119 if (scsi_status
& SS_RESPONSE_INFO_LEN_VALID
) {
1120 /* Sense data lies beyond any FCP RESPONSE data. */
1121 if (IS_FWI2_CAPABLE(ha
))
1122 sense_data
+= rsp_info_len
;
1123 if (rsp_info_len
> 3 && rsp_info
[3]) {
1124 DEBUG2(printk("scsi(%ld:%d:%d:%d) FCP I/O protocol "
1125 "failure (%x/%02x%02x%02x%02x%02x%02x%02x%02x)..."
1126 "retrying command\n", vha
->host_no
,
1127 cp
->device
->channel
, cp
->device
->id
,
1128 cp
->device
->lun
, rsp_info_len
, rsp_info
[0],
1129 rsp_info
[1], rsp_info
[2], rsp_info
[3], rsp_info
[4],
1130 rsp_info
[5], rsp_info
[6], rsp_info
[7]));
1132 cp
->result
= DID_BUS_BUSY
<< 16;
1133 qla2x00_sp_compl(ha
, sp
);
1138 /* Check for overrun. */
1139 if (IS_FWI2_CAPABLE(ha
) && comp_status
== CS_COMPLETE
&&
1140 scsi_status
& SS_RESIDUAL_OVER
)
1141 comp_status
= CS_DATA_OVERRUN
;
1144 * Based on Host and scsi status generate status code for Linux
1146 switch (comp_status
) {
1149 if (scsi_status
== 0) {
1150 cp
->result
= DID_OK
<< 16;
1153 if (scsi_status
& (SS_RESIDUAL_UNDER
| SS_RESIDUAL_OVER
)) {
1155 scsi_set_resid(cp
, resid
);
1157 if (!lscsi_status
&&
1158 ((unsigned)(scsi_bufflen(cp
) - resid
) <
1160 qla_printk(KERN_INFO
, ha
,
1161 "scsi(%ld:%d:%d:%d): Mid-layer underflow "
1162 "detected (%x of %x bytes)...returning "
1163 "error status.\n", vha
->host_no
,
1164 cp
->device
->channel
, cp
->device
->id
,
1165 cp
->device
->lun
, resid
,
1168 cp
->result
= DID_ERROR
<< 16;
1172 cp
->result
= DID_OK
<< 16 | lscsi_status
;
1174 if (lscsi_status
== SAM_STAT_TASK_SET_FULL
) {
1175 DEBUG2(printk(KERN_INFO
1176 "scsi(%ld): QUEUE FULL status detected "
1177 "0x%x-0x%x.\n", vha
->host_no
, comp_status
,
1180 /* Adjust queue depth for all luns on the port. */
1181 if (!ql2xqfulltracking
)
1183 fcport
->last_queue_full
= jiffies
;
1184 starget_for_each_device(cp
->device
->sdev_target
,
1185 fcport
, qla2x00_adjust_sdev_qdepth_down
);
1188 if (lscsi_status
!= SS_CHECK_CONDITION
)
1191 memset(cp
->sense_buffer
, 0, SCSI_SENSE_BUFFERSIZE
);
1192 if (!(scsi_status
& SS_SENSE_LEN_VALID
))
1195 qla2x00_handle_sense(sp
, sense_data
, sense_len
, rsp
);
1198 case CS_DATA_UNDERRUN
:
1200 /* Use F/W calculated residual length. */
1201 if (IS_FWI2_CAPABLE(ha
)) {
1202 if (!(scsi_status
& SS_RESIDUAL_UNDER
)) {
1204 } else if (resid
!= fw_resid_len
) {
1205 scsi_status
&= ~SS_RESIDUAL_UNDER
;
1208 resid
= fw_resid_len
;
1211 if (scsi_status
& SS_RESIDUAL_UNDER
) {
1212 scsi_set_resid(cp
, resid
);
1214 DEBUG2(printk(KERN_INFO
1215 "scsi(%ld:%d:%d) UNDERRUN status detected "
1216 "0x%x-0x%x. resid=0x%x fw_resid=0x%x cdb=0x%x "
1217 "os_underflow=0x%x\n", vha
->host_no
,
1218 cp
->device
->id
, cp
->device
->lun
, comp_status
,
1219 scsi_status
, resid_len
, resid
, cp
->cmnd
[0],
1225 * Check to see if SCSI Status is non zero. If so report SCSI
1228 if (lscsi_status
!= 0) {
1229 cp
->result
= DID_OK
<< 16 | lscsi_status
;
1231 if (lscsi_status
== SAM_STAT_TASK_SET_FULL
) {
1232 DEBUG2(printk(KERN_INFO
1233 "scsi(%ld): QUEUE FULL status detected "
1234 "0x%x-0x%x.\n", vha
->host_no
, comp_status
,
1238 * Adjust queue depth for all luns on the
1241 if (!ql2xqfulltracking
)
1243 fcport
->last_queue_full
= jiffies
;
1244 starget_for_each_device(
1245 cp
->device
->sdev_target
, fcport
,
1246 qla2x00_adjust_sdev_qdepth_down
);
1249 if (lscsi_status
!= SS_CHECK_CONDITION
)
1252 memset(cp
->sense_buffer
, 0, SCSI_SENSE_BUFFERSIZE
);
1253 if (!(scsi_status
& SS_SENSE_LEN_VALID
))
1256 qla2x00_handle_sense(sp
, sense_data
, sense_len
, rsp
);
1259 * If RISC reports underrun and target does not report
1260 * it then we must have a lost frame, so tell upper
1261 * layer to retry it by reporting an error.
1263 if (!(scsi_status
& SS_RESIDUAL_UNDER
)) {
1264 DEBUG2(printk("scsi(%ld:%d:%d:%d) Dropped "
1265 "frame(s) detected (%x of %x bytes)..."
1266 "retrying command.\n",
1267 vha
->host_no
, cp
->device
->channel
,
1268 cp
->device
->id
, cp
->device
->lun
, resid
,
1271 scsi_set_resid(cp
, resid
);
1272 cp
->result
= DID_ERROR
<< 16;
1276 /* Handle mid-layer underflow */
1277 if ((unsigned)(scsi_bufflen(cp
) - resid
) <
1279 qla_printk(KERN_INFO
, ha
,
1280 "scsi(%ld:%d:%d:%d): Mid-layer underflow "
1281 "detected (%x of %x bytes)...returning "
1282 "error status.\n", vha
->host_no
,
1283 cp
->device
->channel
, cp
->device
->id
,
1284 cp
->device
->lun
, resid
,
1287 cp
->result
= DID_ERROR
<< 16;
1291 /* Everybody online, looking good... */
1292 cp
->result
= DID_OK
<< 16;
1296 case CS_DATA_OVERRUN
:
1297 DEBUG2(printk(KERN_INFO
1298 "scsi(%ld:%d:%d): OVERRUN status detected 0x%x-0x%x\n",
1299 vha
->host_no
, cp
->device
->id
, cp
->device
->lun
, comp_status
,
1301 DEBUG2(printk(KERN_INFO
1302 "CDB: 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x\n",
1303 cp
->cmnd
[0], cp
->cmnd
[1], cp
->cmnd
[2], cp
->cmnd
[3],
1304 cp
->cmnd
[4], cp
->cmnd
[5]));
1305 DEBUG2(printk(KERN_INFO
1306 "PID=0x%lx req=0x%x xtra=0x%x -- returning DID_ERROR "
1308 cp
->serial_number
, scsi_bufflen(cp
), resid_len
));
1310 cp
->result
= DID_ERROR
<< 16;
1313 case CS_PORT_LOGGED_OUT
:
1314 case CS_PORT_CONFIG_CHG
:
1317 case CS_PORT_UNAVAILABLE
:
1319 * If the port is in Target Down state, return all IOs for this
1320 * Target with DID_NO_CONNECT ELSE Queue the IOs in the
1323 DEBUG2(printk("scsi(%ld:%d:%d): status_entry: Port Down "
1324 "pid=%ld, compl status=0x%x, port state=0x%x\n",
1325 vha
->host_no
, cp
->device
->id
, cp
->device
->lun
,
1326 cp
->serial_number
, comp_status
,
1327 atomic_read(&fcport
->state
)));
1330 * We are going to have the fc class block the rport
1331 * while we try to recover so instruct the mid layer
1332 * to requeue until the class decides how to handle this.
1334 cp
->result
= DID_TRANSPORT_DISRUPTED
<< 16;
1335 if (atomic_read(&fcport
->state
) == FCS_ONLINE
)
1336 qla2x00_mark_device_lost(fcport
->vha
, fcport
, 1, 1);
1340 DEBUG2(printk(KERN_INFO
1341 "scsi(%ld): RESET status detected 0x%x-0x%x.\n",
1342 vha
->host_no
, comp_status
, scsi_status
));
1344 cp
->result
= DID_RESET
<< 16;
1349 * hv2.19.12 - DID_ABORT does not retry the request if we
1350 * aborted this request then abort otherwise it must be a
1353 DEBUG2(printk(KERN_INFO
1354 "scsi(%ld): ABORT status detected 0x%x-0x%x.\n",
1355 vha
->host_no
, comp_status
, scsi_status
));
1357 cp
->result
= DID_RESET
<< 16;
1362 * We are going to have the fc class block the rport
1363 * while we try to recover so instruct the mid layer
1364 * to requeue until the class decides how to handle this.
1366 cp
->result
= DID_TRANSPORT_DISRUPTED
<< 16;
1368 if (IS_FWI2_CAPABLE(ha
)) {
1369 DEBUG2(printk(KERN_INFO
1370 "scsi(%ld:%d:%d:%d): TIMEOUT status detected "
1371 "0x%x-0x%x\n", vha
->host_no
, cp
->device
->channel
,
1372 cp
->device
->id
, cp
->device
->lun
, comp_status
,
1376 DEBUG2(printk(KERN_INFO
1377 "scsi(%ld:%d:%d:%d): TIMEOUT status detected 0x%x-0x%x "
1378 "sflags=%x.\n", vha
->host_no
, cp
->device
->channel
,
1379 cp
->device
->id
, cp
->device
->lun
, comp_status
, scsi_status
,
1380 le16_to_cpu(sts
->status_flags
)));
1382 /* Check to see if logout occurred. */
1383 if ((le16_to_cpu(sts
->status_flags
) & SF_LOGOUT_SENT
))
1384 qla2x00_mark_device_lost(fcport
->vha
, fcport
, 1, 1);
1388 DEBUG3(printk("scsi(%ld): Error detected (unknown status) "
1389 "0x%x-0x%x.\n", vha
->host_no
, comp_status
, scsi_status
));
1390 qla_printk(KERN_INFO
, ha
,
1391 "Unknown status detected 0x%x-0x%x.\n",
1392 comp_status
, scsi_status
);
1394 cp
->result
= DID_ERROR
<< 16;
1398 /* Place command on done queue. */
1399 if (rsp
->status_srb
== NULL
)
1400 qla2x00_sp_compl(ha
, sp
);
1404 * qla2x00_status_cont_entry() - Process a Status Continuations entry.
1405 * @ha: SCSI driver HA context
1406 * @pkt: Entry pointer
1408 * Extended sense data.
1411 qla2x00_status_cont_entry(struct rsp_que
*rsp
, sts_cont_entry_t
*pkt
)
1413 uint8_t sense_sz
= 0;
1414 struct qla_hw_data
*ha
= rsp
->hw
;
1415 srb_t
*sp
= rsp
->status_srb
;
1416 struct scsi_cmnd
*cp
;
1418 if (sp
!= NULL
&& sp
->request_sense_length
!= 0) {
1421 DEBUG2(printk("%s(): Cmd already returned back to OS "
1422 "sp=%p.\n", __func__
, sp
));
1423 qla_printk(KERN_INFO
, ha
,
1424 "cmd is NULL: already returned to OS (sp=%p)\n",
1427 rsp
->status_srb
= NULL
;
1431 if (sp
->request_sense_length
> sizeof(pkt
->data
)) {
1432 sense_sz
= sizeof(pkt
->data
);
1434 sense_sz
= sp
->request_sense_length
;
1437 /* Move sense data. */
1438 if (IS_FWI2_CAPABLE(ha
))
1439 host_to_fcp_swap(pkt
->data
, sizeof(pkt
->data
));
1440 memcpy(sp
->request_sense_ptr
, pkt
->data
, sense_sz
);
1441 DEBUG5(qla2x00_dump_buffer(sp
->request_sense_ptr
, sense_sz
));
1443 sp
->request_sense_ptr
+= sense_sz
;
1444 sp
->request_sense_length
-= sense_sz
;
1446 /* Place command on done queue. */
1447 if (sp
->request_sense_length
== 0) {
1448 rsp
->status_srb
= NULL
;
1449 qla2x00_sp_compl(ha
, sp
);
1455 * qla2x00_error_entry() - Process an error entry.
1456 * @ha: SCSI driver HA context
1457 * @pkt: Entry pointer
1460 qla2x00_error_entry(scsi_qla_host_t
*vha
, struct rsp_que
*rsp
, sts_entry_t
*pkt
)
1463 struct qla_hw_data
*ha
= vha
->hw
;
1464 uint32_t handle
= LSW(pkt
->handle
);
1465 uint16_t que
= MSW(pkt
->handle
);
1466 struct req_que
*req
= ha
->req_q_map
[que
];
1467 #if defined(QL_DEBUG_LEVEL_2)
1468 if (pkt
->entry_status
& RF_INV_E_ORDER
)
1469 qla_printk(KERN_ERR
, ha
, "%s: Invalid Entry Order\n", __func__
);
1470 else if (pkt
->entry_status
& RF_INV_E_COUNT
)
1471 qla_printk(KERN_ERR
, ha
, "%s: Invalid Entry Count\n", __func__
);
1472 else if (pkt
->entry_status
& RF_INV_E_PARAM
)
1473 qla_printk(KERN_ERR
, ha
,
1474 "%s: Invalid Entry Parameter\n", __func__
);
1475 else if (pkt
->entry_status
& RF_INV_E_TYPE
)
1476 qla_printk(KERN_ERR
, ha
, "%s: Invalid Entry Type\n", __func__
);
1477 else if (pkt
->entry_status
& RF_BUSY
)
1478 qla_printk(KERN_ERR
, ha
, "%s: Busy\n", __func__
);
1480 qla_printk(KERN_ERR
, ha
, "%s: UNKNOWN flag error\n", __func__
);
1483 /* Validate handle. */
1484 if (handle
< MAX_OUTSTANDING_COMMANDS
)
1485 sp
= req
->outstanding_cmds
[handle
];
1490 /* Free outstanding command slot. */
1491 req
->outstanding_cmds
[handle
] = NULL
;
1493 /* Bad payload or header */
1494 if (pkt
->entry_status
&
1495 (RF_INV_E_ORDER
| RF_INV_E_COUNT
|
1496 RF_INV_E_PARAM
| RF_INV_E_TYPE
)) {
1497 sp
->cmd
->result
= DID_ERROR
<< 16;
1498 } else if (pkt
->entry_status
& RF_BUSY
) {
1499 sp
->cmd
->result
= DID_BUS_BUSY
<< 16;
1501 sp
->cmd
->result
= DID_ERROR
<< 16;
1503 qla2x00_sp_compl(ha
, sp
);
1505 } else if (pkt
->entry_type
== COMMAND_A64_TYPE
|| pkt
->entry_type
==
1506 COMMAND_TYPE
|| pkt
->entry_type
== COMMAND_TYPE_7
) {
1507 DEBUG2(printk("scsi(%ld): Error entry - invalid handle\n",
1509 qla_printk(KERN_WARNING
, ha
,
1510 "Error entry - invalid handle\n");
1512 set_bit(ISP_ABORT_NEEDED
, &vha
->dpc_flags
);
1513 qla2xxx_wake_dpc(vha
);
1518 * qla24xx_mbx_completion() - Process mailbox command completions.
1519 * @ha: SCSI driver HA context
1520 * @mb0: Mailbox0 register
1523 qla24xx_mbx_completion(scsi_qla_host_t
*vha
, uint16_t mb0
)
1526 uint16_t __iomem
*wptr
;
1527 struct qla_hw_data
*ha
= vha
->hw
;
1528 struct device_reg_24xx __iomem
*reg
= &ha
->iobase
->isp24
;
1530 /* Load return mailbox registers. */
1531 ha
->flags
.mbox_int
= 1;
1532 ha
->mailbox_out
[0] = mb0
;
1533 wptr
= (uint16_t __iomem
*)®
->mailbox1
;
1535 for (cnt
= 1; cnt
< ha
->mbx_count
; cnt
++) {
1536 ha
->mailbox_out
[cnt
] = RD_REG_WORD(wptr
);
1541 DEBUG3(printk("%s(%ld): Got mailbox completion. cmd=%x.\n",
1542 __func__
, vha
->host_no
, ha
->mcp
->mb
[0]));
1544 DEBUG2_3(printk("%s(%ld): MBX pointer ERROR!\n",
1545 __func__
, vha
->host_no
));
1550 * qla24xx_process_response_queue() - Process response queue entries.
1551 * @ha: SCSI driver HA context
1553 void qla24xx_process_response_queue(struct scsi_qla_host
*vha
,
1554 struct rsp_que
*rsp
)
1556 struct sts_entry_24xx
*pkt
;
1558 if (!vha
->flags
.online
)
1561 while (rsp
->ring_ptr
->signature
!= RESPONSE_PROCESSED
) {
1562 pkt
= (struct sts_entry_24xx
*)rsp
->ring_ptr
;
1565 if (rsp
->ring_index
== rsp
->length
) {
1566 rsp
->ring_index
= 0;
1567 rsp
->ring_ptr
= rsp
->ring
;
1572 if (pkt
->entry_status
!= 0) {
1573 DEBUG3(printk(KERN_INFO
1574 "scsi(%ld): Process error entry.\n", vha
->host_no
));
1576 qla2x00_error_entry(vha
, rsp
, (sts_entry_t
*) pkt
);
1577 ((response_t
*)pkt
)->signature
= RESPONSE_PROCESSED
;
1582 switch (pkt
->entry_type
) {
1584 qla2x00_status_entry(vha
, rsp
, pkt
);
1586 case STATUS_CONT_TYPE
:
1587 qla2x00_status_cont_entry(rsp
, (sts_cont_entry_t
*)pkt
);
1589 case VP_RPT_ID_IOCB_TYPE
:
1590 qla24xx_report_id_acquisition(vha
,
1591 (struct vp_rpt_id_entry_24xx
*)pkt
);
1594 /* Type Not Supported. */
1595 DEBUG4(printk(KERN_WARNING
1596 "scsi(%ld): Received unknown response pkt type %x "
1597 "entry status=%x.\n",
1598 vha
->host_no
, pkt
->entry_type
, pkt
->entry_status
));
1601 ((response_t
*)pkt
)->signature
= RESPONSE_PROCESSED
;
1605 /* Adjust ring index */
1606 WRT_REG_DWORD(rsp
->rsp_q_out
, rsp
->ring_index
);
1610 qla2xxx_check_risc_status(scsi_qla_host_t
*vha
)
1614 struct qla_hw_data
*ha
= vha
->hw
;
1615 struct device_reg_24xx __iomem
*reg
= &ha
->iobase
->isp24
;
1617 if (!IS_QLA25XX(ha
) && !IS_QLA81XX(ha
))
1621 WRT_REG_DWORD(®
->iobase_addr
, 0x7C00);
1622 RD_REG_DWORD(®
->iobase_addr
);
1623 WRT_REG_DWORD(®
->iobase_window
, 0x0001);
1624 for (cnt
= 10000; (RD_REG_DWORD(®
->iobase_window
) & BIT_0
) == 0 &&
1625 rval
== QLA_SUCCESS
; cnt
--) {
1627 WRT_REG_DWORD(®
->iobase_window
, 0x0001);
1630 rval
= QLA_FUNCTION_TIMEOUT
;
1632 if (rval
== QLA_SUCCESS
)
1635 WRT_REG_DWORD(®
->iobase_window
, 0x0003);
1636 for (cnt
= 100; (RD_REG_DWORD(®
->iobase_window
) & BIT_0
) == 0 &&
1637 rval
== QLA_SUCCESS
; cnt
--) {
1639 WRT_REG_DWORD(®
->iobase_window
, 0x0003);
1642 rval
= QLA_FUNCTION_TIMEOUT
;
1644 if (rval
!= QLA_SUCCESS
)
1648 if (RD_REG_DWORD(®
->iobase_c8
) & BIT_3
)
1649 qla_printk(KERN_INFO
, ha
, "Additional code -- 0x55AA.\n");
1652 WRT_REG_DWORD(®
->iobase_window
, 0x0000);
1653 RD_REG_DWORD(®
->iobase_window
);
1657 * qla24xx_intr_handler() - Process interrupts for the ISP23xx and ISP63xx.
1659 * @dev_id: SCSI driver HA context
1661 * Called by system whenever the host adapter generates an interrupt.
1663 * Returns handled flag.
1666 qla24xx_intr_handler(int irq
, void *dev_id
)
1668 scsi_qla_host_t
*vha
;
1669 struct qla_hw_data
*ha
;
1670 struct device_reg_24xx __iomem
*reg
;
1676 struct rsp_que
*rsp
;
1677 unsigned long flags
;
1679 rsp
= (struct rsp_que
*) dev_id
;
1682 "%s(): NULL response queue pointer\n", __func__
);
1687 reg
= &ha
->iobase
->isp24
;
1690 spin_lock_irqsave(&ha
->hardware_lock
, flags
);
1691 vha
= pci_get_drvdata(ha
->pdev
);
1692 for (iter
= 50; iter
--; ) {
1693 stat
= RD_REG_DWORD(®
->host_status
);
1694 if (stat
& HSRX_RISC_PAUSED
) {
1695 if (pci_channel_offline(ha
->pdev
))
1698 hccr
= RD_REG_DWORD(®
->hccr
);
1700 qla_printk(KERN_INFO
, ha
, "RISC paused -- HCCR=%x, "
1701 "Dumping firmware!\n", hccr
);
1703 qla2xxx_check_risc_status(vha
);
1705 ha
->isp_ops
->fw_dump(vha
, 1);
1706 set_bit(ISP_ABORT_NEEDED
, &vha
->dpc_flags
);
1708 } else if ((stat
& HSRX_RISC_INT
) == 0)
1711 switch (stat
& 0xff) {
1716 qla24xx_mbx_completion(vha
, MSW(stat
));
1717 status
|= MBX_INTERRUPT
;
1722 mb
[1] = RD_REG_WORD(®
->mailbox1
);
1723 mb
[2] = RD_REG_WORD(®
->mailbox2
);
1724 mb
[3] = RD_REG_WORD(®
->mailbox3
);
1725 qla2x00_async_event(vha
, rsp
, mb
);
1729 qla24xx_process_response_queue(vha
, rsp
);
1732 DEBUG2(printk("scsi(%ld): Unrecognized interrupt type "
1734 vha
->host_no
, stat
& 0xff));
1737 WRT_REG_DWORD(®
->hccr
, HCCRX_CLR_RISC_INT
);
1738 RD_REG_DWORD_RELAXED(®
->hccr
);
1740 spin_unlock_irqrestore(&ha
->hardware_lock
, flags
);
1742 if (test_bit(MBX_INTR_WAIT
, &ha
->mbx_cmd_flags
) &&
1743 (status
& MBX_INTERRUPT
) && ha
->flags
.mbox_int
) {
1744 set_bit(MBX_INTERRUPT
, &ha
->mbx_cmd_flags
);
1745 complete(&ha
->mbx_intr_comp
);
1752 qla24xx_msix_rsp_q(int irq
, void *dev_id
)
1754 struct qla_hw_data
*ha
;
1755 struct rsp_que
*rsp
;
1756 struct device_reg_24xx __iomem
*reg
;
1757 struct scsi_qla_host
*vha
;
1759 rsp
= (struct rsp_que
*) dev_id
;
1762 "%s(): NULL response queue pointer\n", __func__
);
1766 reg
= &ha
->iobase
->isp24
;
1768 spin_lock_irq(&ha
->hardware_lock
);
1770 vha
= qla25xx_get_host(rsp
);
1771 qla24xx_process_response_queue(vha
, rsp
);
1772 WRT_REG_DWORD(®
->hccr
, HCCRX_CLR_RISC_INT
);
1774 spin_unlock_irq(&ha
->hardware_lock
);
1780 qla25xx_msix_rsp_q(int irq
, void *dev_id
)
1782 struct qla_hw_data
*ha
;
1783 struct rsp_que
*rsp
;
1785 rsp
= (struct rsp_que
*) dev_id
;
1788 "%s(): NULL response queue pointer\n", __func__
);
1793 queue_work_on((int) (rsp
->id
- 1), ha
->wq
, &rsp
->q_work
);
1799 qla24xx_msix_default(int irq
, void *dev_id
)
1801 scsi_qla_host_t
*vha
;
1802 struct qla_hw_data
*ha
;
1803 struct rsp_que
*rsp
;
1804 struct device_reg_24xx __iomem
*reg
;
1810 rsp
= (struct rsp_que
*) dev_id
;
1813 "%s(): NULL response queue pointer\n", __func__
));
1817 reg
= &ha
->iobase
->isp24
;
1820 spin_lock_irq(&ha
->hardware_lock
);
1821 vha
= pci_get_drvdata(ha
->pdev
);
1823 stat
= RD_REG_DWORD(®
->host_status
);
1824 if (stat
& HSRX_RISC_PAUSED
) {
1825 if (pci_channel_offline(ha
->pdev
))
1828 hccr
= RD_REG_DWORD(®
->hccr
);
1830 qla_printk(KERN_INFO
, ha
, "RISC paused -- HCCR=%x, "
1831 "Dumping firmware!\n", hccr
);
1833 qla2xxx_check_risc_status(vha
);
1835 ha
->isp_ops
->fw_dump(vha
, 1);
1836 set_bit(ISP_ABORT_NEEDED
, &vha
->dpc_flags
);
1838 } else if ((stat
& HSRX_RISC_INT
) == 0)
1841 switch (stat
& 0xff) {
1846 qla24xx_mbx_completion(vha
, MSW(stat
));
1847 status
|= MBX_INTERRUPT
;
1852 mb
[1] = RD_REG_WORD(®
->mailbox1
);
1853 mb
[2] = RD_REG_WORD(®
->mailbox2
);
1854 mb
[3] = RD_REG_WORD(®
->mailbox3
);
1855 qla2x00_async_event(vha
, rsp
, mb
);
1859 qla24xx_process_response_queue(vha
, rsp
);
1862 DEBUG2(printk("scsi(%ld): Unrecognized interrupt type "
1864 vha
->host_no
, stat
& 0xff));
1867 WRT_REG_DWORD(®
->hccr
, HCCRX_CLR_RISC_INT
);
1869 spin_unlock_irq(&ha
->hardware_lock
);
1871 if (test_bit(MBX_INTR_WAIT
, &ha
->mbx_cmd_flags
) &&
1872 (status
& MBX_INTERRUPT
) && ha
->flags
.mbox_int
) {
1873 set_bit(MBX_INTERRUPT
, &ha
->mbx_cmd_flags
);
1874 complete(&ha
->mbx_intr_comp
);
1880 /* Interrupt handling helpers. */
1882 struct qla_init_msix_entry
{
1884 irq_handler_t handler
;
1887 static struct qla_init_msix_entry msix_entries
[3] = {
1888 { "qla2xxx (default)", qla24xx_msix_default
},
1889 { "qla2xxx (rsp_q)", qla24xx_msix_rsp_q
},
1890 { "qla2xxx (multiq)", qla25xx_msix_rsp_q
},
1894 qla24xx_disable_msix(struct qla_hw_data
*ha
)
1897 struct qla_msix_entry
*qentry
;
1899 for (i
= 0; i
< ha
->msix_count
; i
++) {
1900 qentry
= &ha
->msix_entries
[i
];
1901 if (qentry
->have_irq
)
1902 free_irq(qentry
->vector
, qentry
->rsp
);
1904 pci_disable_msix(ha
->pdev
);
1905 kfree(ha
->msix_entries
);
1906 ha
->msix_entries
= NULL
;
1907 ha
->flags
.msix_enabled
= 0;
1911 qla24xx_enable_msix(struct qla_hw_data
*ha
, struct rsp_que
*rsp
)
1913 #define MIN_MSIX_COUNT 2
1915 struct msix_entry
*entries
;
1916 struct qla_msix_entry
*qentry
;
1918 entries
= kzalloc(sizeof(struct msix_entry
) * ha
->msix_count
,
1923 for (i
= 0; i
< ha
->msix_count
; i
++)
1924 entries
[i
].entry
= i
;
1926 ret
= pci_enable_msix(ha
->pdev
, entries
, ha
->msix_count
);
1928 if (ret
< MIN_MSIX_COUNT
)
1931 qla_printk(KERN_WARNING
, ha
,
1932 "MSI-X: Failed to enable support -- %d/%d\n"
1933 " Retry with %d vectors\n", ha
->msix_count
, ret
, ret
);
1934 ha
->msix_count
= ret
;
1935 ret
= pci_enable_msix(ha
->pdev
, entries
, ha
->msix_count
);
1938 qla_printk(KERN_WARNING
, ha
, "MSI-X: Failed to enable"
1939 " support, giving up -- %d/%d\n",
1940 ha
->msix_count
, ret
);
1943 ha
->max_rsp_queues
= ha
->msix_count
- 1;
1945 ha
->msix_entries
= kzalloc(sizeof(struct qla_msix_entry
) *
1946 ha
->msix_count
, GFP_KERNEL
);
1947 if (!ha
->msix_entries
) {
1951 ha
->flags
.msix_enabled
= 1;
1953 for (i
= 0; i
< ha
->msix_count
; i
++) {
1954 qentry
= &ha
->msix_entries
[i
];
1955 qentry
->vector
= entries
[i
].vector
;
1956 qentry
->entry
= entries
[i
].entry
;
1957 qentry
->have_irq
= 0;
1961 /* Enable MSI-X vectors for the base queue */
1962 for (i
= 0; i
< 2; i
++) {
1963 qentry
= &ha
->msix_entries
[i
];
1964 ret
= request_irq(qentry
->vector
, msix_entries
[i
].handler
,
1965 0, msix_entries
[i
].name
, rsp
);
1967 qla_printk(KERN_WARNING
, ha
,
1968 "MSI-X: Unable to register handler -- %x/%d.\n",
1969 qentry
->vector
, ret
);
1970 qla24xx_disable_msix(ha
);
1974 qentry
->have_irq
= 1;
1979 /* Enable MSI-X vector for response queue update for queue 0 */
1980 if (ha
->mqiobase
&& (ha
->max_rsp_queues
> 1 || ha
->max_req_queues
> 1))
1989 qla2x00_request_irqs(struct qla_hw_data
*ha
, struct rsp_que
*rsp
)
1992 device_reg_t __iomem
*reg
= ha
->iobase
;
1994 /* If possible, enable MSI-X. */
1995 if (!IS_QLA2432(ha
) && !IS_QLA2532(ha
) &&
1996 !IS_QLA8432(ha
) && !IS_QLA8001(ha
))
1999 if (IS_QLA2432(ha
) && (ha
->pdev
->revision
< QLA_MSIX_CHIP_REV_24XX
||
2000 !QLA_MSIX_FW_MODE_1(ha
->fw_attributes
))) {
2001 DEBUG2(qla_printk(KERN_WARNING
, ha
,
2002 "MSI-X: Unsupported ISP2432 (0x%X, 0x%X).\n",
2003 ha
->pdev
->revision
, ha
->fw_attributes
));
2008 if (ha
->pdev
->subsystem_vendor
== PCI_VENDOR_ID_HP
&&
2009 (ha
->pdev
->subsystem_device
== 0x7040 ||
2010 ha
->pdev
->subsystem_device
== 0x7041 ||
2011 ha
->pdev
->subsystem_device
== 0x1705)) {
2012 DEBUG2(qla_printk(KERN_WARNING
, ha
,
2013 "MSI-X: Unsupported ISP2432 SSVID/SSDID (0x%X, 0x%X).\n",
2014 ha
->pdev
->subsystem_vendor
,
2015 ha
->pdev
->subsystem_device
));
2020 ret
= qla24xx_enable_msix(ha
, rsp
);
2022 DEBUG2(qla_printk(KERN_INFO
, ha
,
2023 "MSI-X: Enabled (0x%X, 0x%X).\n", ha
->chip_revision
,
2024 ha
->fw_attributes
));
2025 goto clear_risc_ints
;
2027 qla_printk(KERN_WARNING
, ha
,
2028 "MSI-X: Falling back-to INTa mode -- %d.\n", ret
);
2031 if (!IS_QLA24XX(ha
) && !IS_QLA2532(ha
) && !IS_QLA8432(ha
) &&
2035 ret
= pci_enable_msi(ha
->pdev
);
2037 DEBUG2(qla_printk(KERN_INFO
, ha
, "MSI: Enabled.\n"));
2038 ha
->flags
.msi_enabled
= 1;
2042 ret
= request_irq(ha
->pdev
->irq
, ha
->isp_ops
->intr_handler
,
2043 IRQF_SHARED
, QLA2XXX_DRIVER_NAME
, rsp
);
2045 qla_printk(KERN_WARNING
, ha
,
2046 "Failed to reserve interrupt %d already in use.\n",
2050 ha
->flags
.inta_enabled
= 1;
2054 * FIXME: Noted that 8014s were being dropped during NK testing.
2055 * Timing deltas during MSI-X/INTa transitions?
2059 spin_lock_irq(&ha
->hardware_lock
);
2060 if (IS_FWI2_CAPABLE(ha
)) {
2061 WRT_REG_DWORD(®
->isp24
.hccr
, HCCRX_CLR_HOST_INT
);
2062 WRT_REG_DWORD(®
->isp24
.hccr
, HCCRX_CLR_RISC_INT
);
2064 WRT_REG_WORD(®
->isp
.semaphore
, 0);
2065 WRT_REG_WORD(®
->isp
.hccr
, HCCR_CLR_RISC_INT
);
2066 WRT_REG_WORD(®
->isp
.hccr
, HCCR_CLR_HOST_INT
);
2068 spin_unlock_irq(&ha
->hardware_lock
);
2075 qla2x00_free_irqs(scsi_qla_host_t
*vha
)
2077 struct qla_hw_data
*ha
= vha
->hw
;
2078 struct rsp_que
*rsp
= ha
->rsp_q_map
[0];
2080 if (ha
->flags
.msix_enabled
)
2081 qla24xx_disable_msix(ha
);
2082 else if (ha
->flags
.inta_enabled
) {
2083 free_irq(ha
->pdev
->irq
, rsp
);
2084 pci_disable_msi(ha
->pdev
);
2089 int qla25xx_request_irq(struct rsp_que
*rsp
)
2091 struct qla_hw_data
*ha
= rsp
->hw
;
2092 struct qla_init_msix_entry
*intr
= &msix_entries
[2];
2093 struct qla_msix_entry
*msix
= rsp
->msix
;
2096 ret
= request_irq(msix
->vector
, intr
->handler
, 0, intr
->name
, rsp
);
2098 qla_printk(KERN_WARNING
, ha
,
2099 "MSI-X: Unable to register handler -- %x/%d.\n",
2108 struct scsi_qla_host
*
2109 qla25xx_get_host(struct rsp_que
*rsp
)
2112 struct qla_hw_data
*ha
= rsp
->hw
;
2113 struct scsi_qla_host
*vha
= NULL
;
2114 struct sts_entry_24xx
*pkt
;
2115 struct req_que
*req
;
2119 pkt
= (struct sts_entry_24xx
*) rsp
->ring_ptr
;
2120 que
= MSW(pkt
->handle
);
2121 handle
= (uint32_t) LSW(pkt
->handle
);
2122 req
= ha
->req_q_map
[que
];
2123 if (handle
< MAX_OUTSTANDING_COMMANDS
) {
2124 sp
= req
->outstanding_cmds
[handle
];
2126 return sp
->fcport
->vha
;
2131 vha
= pci_get_drvdata(ha
->pdev
);