2 * QLogic Fibre Channel HBA Driver
3 * Copyright (c) 2003-2014 QLogic Corporation
5 * See LICENSE.qla2xxx for copyright and licensing details.
8 #include "qla_target.h"
10 #include <linux/delay.h>
11 #include <linux/slab.h>
12 #include <scsi/scsi_tcq.h>
13 #include <scsi/scsi_bsg_fc.h>
14 #include <scsi/scsi_eh.h>
16 static void qla2x00_mbx_completion(scsi_qla_host_t
*, uint16_t);
17 static void qla2x00_status_entry(scsi_qla_host_t
*, struct rsp_que
*, void *);
18 static void qla2x00_status_cont_entry(struct rsp_que
*, sts_cont_entry_t
*);
19 static void qla2x00_error_entry(scsi_qla_host_t
*, struct rsp_que
*,
23 * qla2100_intr_handler() - Process interrupts for the ISP2100 and ISP2200.
25 * @dev_id: SCSI driver HA context
27 * Called by system whenever the host adapter generates an interrupt.
29 * Returns handled flag.
32 qla2100_intr_handler(int irq
, void *dev_id
)
35 struct qla_hw_data
*ha
;
36 struct device_reg_2xxx __iomem
*reg
;
44 rsp
= (struct rsp_que
*) dev_id
;
46 ql_log(ql_log_info
, NULL
, 0x505d,
47 "%s: NULL response queue pointer.\n", __func__
);
52 reg
= &ha
->iobase
->isp
;
55 spin_lock_irqsave(&ha
->hardware_lock
, flags
);
56 vha
= pci_get_drvdata(ha
->pdev
);
57 for (iter
= 50; iter
--; ) {
58 hccr
= RD_REG_WORD(®
->hccr
);
59 if (qla2x00_check_reg16_for_disconnect(vha
, hccr
))
61 if (hccr
& HCCR_RISC_PAUSE
) {
62 if (pci_channel_offline(ha
->pdev
))
66 * Issue a "HARD" reset in order for the RISC interrupt
67 * bit to be cleared. Schedule a big hammer to get
68 * out of the RISC PAUSED state.
70 WRT_REG_WORD(®
->hccr
, HCCR_RESET_RISC
);
71 RD_REG_WORD(®
->hccr
);
73 ha
->isp_ops
->fw_dump(vha
, 1);
74 set_bit(ISP_ABORT_NEEDED
, &vha
->dpc_flags
);
76 } else if ((RD_REG_WORD(®
->istatus
) & ISR_RISC_INT
) == 0)
79 if (RD_REG_WORD(®
->semaphore
) & BIT_0
) {
80 WRT_REG_WORD(®
->hccr
, HCCR_CLR_RISC_INT
);
81 RD_REG_WORD(®
->hccr
);
83 /* Get mailbox data. */
84 mb
[0] = RD_MAILBOX_REG(ha
, reg
, 0);
85 if (mb
[0] > 0x3fff && mb
[0] < 0x8000) {
86 qla2x00_mbx_completion(vha
, mb
[0]);
87 status
|= MBX_INTERRUPT
;
88 } else if (mb
[0] > 0x7fff && mb
[0] < 0xc000) {
89 mb
[1] = RD_MAILBOX_REG(ha
, reg
, 1);
90 mb
[2] = RD_MAILBOX_REG(ha
, reg
, 2);
91 mb
[3] = RD_MAILBOX_REG(ha
, reg
, 3);
92 qla2x00_async_event(vha
, rsp
, mb
);
95 ql_dbg(ql_dbg_async
, vha
, 0x5025,
96 "Unrecognized interrupt type (%d).\n",
99 /* Release mailbox registers. */
100 WRT_REG_WORD(®
->semaphore
, 0);
101 RD_REG_WORD(®
->semaphore
);
103 qla2x00_process_response_queue(rsp
);
105 WRT_REG_WORD(®
->hccr
, HCCR_CLR_RISC_INT
);
106 RD_REG_WORD(®
->hccr
);
109 qla2x00_handle_mbx_completion(ha
, status
);
110 spin_unlock_irqrestore(&ha
->hardware_lock
, flags
);
112 return (IRQ_HANDLED
);
116 qla2x00_check_reg32_for_disconnect(scsi_qla_host_t
*vha
, uint32_t reg
)
118 /* Check for PCI disconnection */
119 if (reg
== 0xffffffff && !pci_channel_offline(vha
->hw
->pdev
)) {
120 if (!test_and_set_bit(PFLG_DISCONNECTED
, &vha
->pci_flags
) &&
121 !test_bit(PFLG_DRIVER_REMOVING
, &vha
->pci_flags
) &&
122 !test_bit(PFLG_DRIVER_PROBING
, &vha
->pci_flags
)) {
124 * Schedule this (only once) on the default system
125 * workqueue so that all the adapter workqueues and the
126 * DPC thread can be shutdown cleanly.
128 schedule_work(&vha
->hw
->board_disable
);
136 qla2x00_check_reg16_for_disconnect(scsi_qla_host_t
*vha
, uint16_t reg
)
138 return qla2x00_check_reg32_for_disconnect(vha
, 0xffff0000 | reg
);
142 * qla2300_intr_handler() - Process interrupts for the ISP23xx and ISP63xx.
144 * @dev_id: SCSI driver HA context
146 * Called by system whenever the host adapter generates an interrupt.
148 * Returns handled flag.
151 qla2300_intr_handler(int irq
, void *dev_id
)
153 scsi_qla_host_t
*vha
;
154 struct device_reg_2xxx __iomem
*reg
;
161 struct qla_hw_data
*ha
;
164 rsp
= (struct rsp_que
*) dev_id
;
166 ql_log(ql_log_info
, NULL
, 0x5058,
167 "%s: NULL response queue pointer.\n", __func__
);
172 reg
= &ha
->iobase
->isp
;
175 spin_lock_irqsave(&ha
->hardware_lock
, flags
);
176 vha
= pci_get_drvdata(ha
->pdev
);
177 for (iter
= 50; iter
--; ) {
178 stat
= RD_REG_DWORD(®
->u
.isp2300
.host_status
);
179 if (qla2x00_check_reg32_for_disconnect(vha
, stat
))
181 if (stat
& HSR_RISC_PAUSED
) {
182 if (unlikely(pci_channel_offline(ha
->pdev
)))
185 hccr
= RD_REG_WORD(®
->hccr
);
187 if (hccr
& (BIT_15
| BIT_13
| BIT_11
| BIT_8
))
188 ql_log(ql_log_warn
, vha
, 0x5026,
189 "Parity error -- HCCR=%x, Dumping "
190 "firmware.\n", hccr
);
192 ql_log(ql_log_warn
, vha
, 0x5027,
193 "RISC paused -- HCCR=%x, Dumping "
194 "firmware.\n", hccr
);
197 * Issue a "HARD" reset in order for the RISC
198 * interrupt bit to be cleared. Schedule a big
199 * hammer to get out of the RISC PAUSED state.
201 WRT_REG_WORD(®
->hccr
, HCCR_RESET_RISC
);
202 RD_REG_WORD(®
->hccr
);
204 ha
->isp_ops
->fw_dump(vha
, 1);
205 set_bit(ISP_ABORT_NEEDED
, &vha
->dpc_flags
);
207 } else if ((stat
& HSR_RISC_INT
) == 0)
210 switch (stat
& 0xff) {
215 qla2x00_mbx_completion(vha
, MSW(stat
));
216 status
|= MBX_INTERRUPT
;
218 /* Release mailbox registers. */
219 WRT_REG_WORD(®
->semaphore
, 0);
223 mb
[1] = RD_MAILBOX_REG(ha
, reg
, 1);
224 mb
[2] = RD_MAILBOX_REG(ha
, reg
, 2);
225 mb
[3] = RD_MAILBOX_REG(ha
, reg
, 3);
226 qla2x00_async_event(vha
, rsp
, mb
);
229 qla2x00_process_response_queue(rsp
);
232 mb
[0] = MBA_CMPLT_1_16BIT
;
234 qla2x00_async_event(vha
, rsp
, mb
);
237 mb
[0] = MBA_SCSI_COMPLETION
;
239 mb
[2] = RD_MAILBOX_REG(ha
, reg
, 2);
240 qla2x00_async_event(vha
, rsp
, mb
);
243 ql_dbg(ql_dbg_async
, vha
, 0x5028,
244 "Unrecognized interrupt type (%d).\n", stat
& 0xff);
247 WRT_REG_WORD(®
->hccr
, HCCR_CLR_RISC_INT
);
248 RD_REG_WORD_RELAXED(®
->hccr
);
250 qla2x00_handle_mbx_completion(ha
, status
);
251 spin_unlock_irqrestore(&ha
->hardware_lock
, flags
);
253 return (IRQ_HANDLED
);
257 * qla2x00_mbx_completion() - Process mailbox command completions.
258 * @ha: SCSI driver HA context
259 * @mb0: Mailbox0 register
262 qla2x00_mbx_completion(scsi_qla_host_t
*vha
, uint16_t mb0
)
266 uint16_t __iomem
*wptr
;
267 struct qla_hw_data
*ha
= vha
->hw
;
268 struct device_reg_2xxx __iomem
*reg
= &ha
->iobase
->isp
;
270 /* Read all mbox registers? */
271 WARN_ON_ONCE(ha
->mbx_count
> 32);
272 mboxes
= (1ULL << ha
->mbx_count
) - 1;
274 ql_dbg(ql_dbg_async
, vha
, 0x5001, "MBX pointer ERROR.\n");
276 mboxes
= ha
->mcp
->in_mb
;
278 /* Load return mailbox registers. */
279 ha
->flags
.mbox_int
= 1;
280 ha
->mailbox_out
[0] = mb0
;
282 wptr
= (uint16_t __iomem
*)MAILBOX_REG(ha
, reg
, 1);
284 for (cnt
= 1; cnt
< ha
->mbx_count
; cnt
++) {
285 if (IS_QLA2200(ha
) && cnt
== 8)
286 wptr
= (uint16_t __iomem
*)MAILBOX_REG(ha
, reg
, 8);
287 if ((cnt
== 4 || cnt
== 5) && (mboxes
& BIT_0
))
288 ha
->mailbox_out
[cnt
] = qla2x00_debounce_register(wptr
);
289 else if (mboxes
& BIT_0
)
290 ha
->mailbox_out
[cnt
] = RD_REG_WORD(wptr
);
298 qla81xx_idc_event(scsi_qla_host_t
*vha
, uint16_t aen
, uint16_t descr
)
300 static char *event
[] =
301 { "Complete", "Request Notification", "Time Extension" };
303 struct device_reg_24xx __iomem
*reg24
= &vha
->hw
->iobase
->isp24
;
304 struct device_reg_82xx __iomem
*reg82
= &vha
->hw
->iobase
->isp82
;
305 uint16_t __iomem
*wptr
;
306 uint16_t cnt
, timeout
, mb
[QLA_IDC_ACK_REGS
];
308 /* Seed data -- mailbox1 -> mailbox7. */
309 if (IS_QLA81XX(vha
->hw
) || IS_QLA83XX(vha
->hw
))
310 wptr
= (uint16_t __iomem
*)®24
->mailbox1
;
311 else if (IS_QLA8044(vha
->hw
))
312 wptr
= (uint16_t __iomem
*)®82
->mailbox_out
[1];
316 for (cnt
= 0; cnt
< QLA_IDC_ACK_REGS
; cnt
++, wptr
++)
317 mb
[cnt
] = RD_REG_WORD(wptr
);
319 ql_dbg(ql_dbg_async
, vha
, 0x5021,
320 "Inter-Driver Communication %s -- "
321 "%04x %04x %04x %04x %04x %04x %04x.\n",
322 event
[aen
& 0xff], mb
[0], mb
[1], mb
[2], mb
[3],
323 mb
[4], mb
[5], mb
[6]);
325 /* Handle IDC Error completion case. */
326 case MBA_IDC_COMPLETE
:
328 vha
->hw
->flags
.idc_compl_status
= 1;
329 if (vha
->hw
->notify_dcbx_comp
&& !vha
->vp_idx
)
330 complete(&vha
->hw
->dcbx_comp
);
335 /* Acknowledgement needed? [Notify && non-zero timeout]. */
336 timeout
= (descr
>> 8) & 0xf;
337 ql_dbg(ql_dbg_async
, vha
, 0x5022,
338 "%lu Inter-Driver Communication %s -- ACK timeout=%d.\n",
339 vha
->host_no
, event
[aen
& 0xff], timeout
);
343 rval
= qla2x00_post_idc_ack_work(vha
, mb
);
344 if (rval
!= QLA_SUCCESS
)
345 ql_log(ql_log_warn
, vha
, 0x5023,
346 "IDC failed to post ACK.\n");
348 case MBA_IDC_TIME_EXT
:
349 vha
->hw
->idc_extend_tmo
= descr
;
350 ql_dbg(ql_dbg_async
, vha
, 0x5087,
351 "%lu Inter-Driver Communication %s -- "
352 "Extend timeout by=%d.\n",
353 vha
->host_no
, event
[aen
& 0xff], vha
->hw
->idc_extend_tmo
);
360 qla2x00_get_link_speed_str(struct qla_hw_data
*ha
, uint16_t speed
)
362 static const char *const link_speeds
[] = {
363 "1", "2", "?", "4", "8", "16", "32", "10"
365 #define QLA_LAST_SPEED 7
367 if (IS_QLA2100(ha
) || IS_QLA2200(ha
))
368 return link_speeds
[0];
369 else if (speed
== 0x13)
370 return link_speeds
[QLA_LAST_SPEED
];
371 else if (speed
< QLA_LAST_SPEED
)
372 return link_speeds
[speed
];
374 return link_speeds
[LS_UNKNOWN
];
378 qla83xx_handle_8200_aen(scsi_qla_host_t
*vha
, uint16_t *mb
)
380 struct qla_hw_data
*ha
= vha
->hw
;
383 * 8200 AEN Interpretation:
385 * mb[1] = AEN Reason code
386 * mb[2] = LSW of Peg-Halt Status-1 Register
387 * mb[6] = MSW of Peg-Halt Status-1 Register
388 * mb[3] = LSW of Peg-Halt Status-2 register
389 * mb[7] = MSW of Peg-Halt Status-2 register
390 * mb[4] = IDC Device-State Register value
391 * mb[5] = IDC Driver-Presence Register value
393 ql_dbg(ql_dbg_async
, vha
, 0x506b, "AEN Code: mb[0] = 0x%x AEN reason: "
394 "mb[1] = 0x%x PH-status1: mb[2] = 0x%x PH-status1: mb[6] = 0x%x.\n",
395 mb
[0], mb
[1], mb
[2], mb
[6]);
396 ql_dbg(ql_dbg_async
, vha
, 0x506c, "PH-status2: mb[3] = 0x%x "
397 "PH-status2: mb[7] = 0x%x Device-State: mb[4] = 0x%x "
398 "Drv-Presence: mb[5] = 0x%x.\n", mb
[3], mb
[7], mb
[4], mb
[5]);
400 if (mb
[1] & (IDC_PEG_HALT_STATUS_CHANGE
| IDC_NIC_FW_REPORTED_FAILURE
|
401 IDC_HEARTBEAT_FAILURE
)) {
402 ha
->flags
.nic_core_hung
= 1;
403 ql_log(ql_log_warn
, vha
, 0x5060,
404 "83XX: F/W Error Reported: Check if reset required.\n");
406 if (mb
[1] & IDC_PEG_HALT_STATUS_CHANGE
) {
407 uint32_t protocol_engine_id
, fw_err_code
, err_level
;
410 * IDC_PEG_HALT_STATUS_CHANGE interpretation:
411 * - PEG-Halt Status-1 Register:
412 * (LSW = mb[2], MSW = mb[6])
413 * Bits 0-7 = protocol-engine ID
414 * Bits 8-28 = f/w error code
415 * Bits 29-31 = Error-level
416 * Error-level 0x1 = Non-Fatal error
417 * Error-level 0x2 = Recoverable Fatal error
418 * Error-level 0x4 = UnRecoverable Fatal error
419 * - PEG-Halt Status-2 Register:
420 * (LSW = mb[3], MSW = mb[7])
422 protocol_engine_id
= (mb
[2] & 0xff);
423 fw_err_code
= (((mb
[2] & 0xff00) >> 8) |
424 ((mb
[6] & 0x1fff) << 8));
425 err_level
= ((mb
[6] & 0xe000) >> 13);
426 ql_log(ql_log_warn
, vha
, 0x5061, "PegHalt Status-1 "
427 "Register: protocol_engine_id=0x%x "
428 "fw_err_code=0x%x err_level=0x%x.\n",
429 protocol_engine_id
, fw_err_code
, err_level
);
430 ql_log(ql_log_warn
, vha
, 0x5062, "PegHalt Status-2 "
431 "Register: 0x%x%x.\n", mb
[7], mb
[3]);
432 if (err_level
== ERR_LEVEL_NON_FATAL
) {
433 ql_log(ql_log_warn
, vha
, 0x5063,
434 "Not a fatal error, f/w has recovered "
436 } else if (err_level
== ERR_LEVEL_RECOVERABLE_FATAL
) {
437 ql_log(ql_log_fatal
, vha
, 0x5064,
438 "Recoverable Fatal error: Chip reset "
440 qla83xx_schedule_work(vha
,
441 QLA83XX_NIC_CORE_RESET
);
442 } else if (err_level
== ERR_LEVEL_UNRECOVERABLE_FATAL
) {
443 ql_log(ql_log_fatal
, vha
, 0x5065,
444 "Unrecoverable Fatal error: Set FAILED "
445 "state, reboot required.\n");
446 qla83xx_schedule_work(vha
,
447 QLA83XX_NIC_CORE_UNRECOVERABLE
);
451 if (mb
[1] & IDC_NIC_FW_REPORTED_FAILURE
) {
452 uint16_t peg_fw_state
, nw_interface_link_up
;
453 uint16_t nw_interface_signal_detect
, sfp_status
;
454 uint16_t htbt_counter
, htbt_monitor_enable
;
455 uint16_t sfp_additonal_info
, sfp_multirate
;
456 uint16_t sfp_tx_fault
, link_speed
, dcbx_status
;
459 * IDC_NIC_FW_REPORTED_FAILURE interpretation:
460 * - PEG-to-FC Status Register:
461 * (LSW = mb[2], MSW = mb[6])
462 * Bits 0-7 = Peg-Firmware state
463 * Bit 8 = N/W Interface Link-up
464 * Bit 9 = N/W Interface signal detected
465 * Bits 10-11 = SFP Status
466 * SFP Status 0x0 = SFP+ transceiver not expected
467 * SFP Status 0x1 = SFP+ transceiver not present
468 * SFP Status 0x2 = SFP+ transceiver invalid
469 * SFP Status 0x3 = SFP+ transceiver present and
471 * Bits 12-14 = Heartbeat Counter
472 * Bit 15 = Heartbeat Monitor Enable
473 * Bits 16-17 = SFP Additional Info
474 * SFP info 0x0 = Unregocnized transceiver for
476 * SFP info 0x1 = SFP+ brand validation failed
477 * SFP info 0x2 = SFP+ speed validation failed
478 * SFP info 0x3 = SFP+ access error
479 * Bit 18 = SFP Multirate
480 * Bit 19 = SFP Tx Fault
481 * Bits 20-22 = Link Speed
482 * Bits 23-27 = Reserved
483 * Bits 28-30 = DCBX Status
484 * DCBX Status 0x0 = DCBX Disabled
485 * DCBX Status 0x1 = DCBX Enabled
486 * DCBX Status 0x2 = DCBX Exchange error
489 peg_fw_state
= (mb
[2] & 0x00ff);
490 nw_interface_link_up
= ((mb
[2] & 0x0100) >> 8);
491 nw_interface_signal_detect
= ((mb
[2] & 0x0200) >> 9);
492 sfp_status
= ((mb
[2] & 0x0c00) >> 10);
493 htbt_counter
= ((mb
[2] & 0x7000) >> 12);
494 htbt_monitor_enable
= ((mb
[2] & 0x8000) >> 15);
495 sfp_additonal_info
= (mb
[6] & 0x0003);
496 sfp_multirate
= ((mb
[6] & 0x0004) >> 2);
497 sfp_tx_fault
= ((mb
[6] & 0x0008) >> 3);
498 link_speed
= ((mb
[6] & 0x0070) >> 4);
499 dcbx_status
= ((mb
[6] & 0x7000) >> 12);
501 ql_log(ql_log_warn
, vha
, 0x5066,
502 "Peg-to-Fc Status Register:\n"
503 "peg_fw_state=0x%x, nw_interface_link_up=0x%x, "
504 "nw_interface_signal_detect=0x%x"
505 "\nsfp_statis=0x%x.\n ", peg_fw_state
,
506 nw_interface_link_up
, nw_interface_signal_detect
,
508 ql_log(ql_log_warn
, vha
, 0x5067,
509 "htbt_counter=0x%x, htbt_monitor_enable=0x%x, "
510 "sfp_additonal_info=0x%x, sfp_multirate=0x%x.\n ",
511 htbt_counter
, htbt_monitor_enable
,
512 sfp_additonal_info
, sfp_multirate
);
513 ql_log(ql_log_warn
, vha
, 0x5068,
514 "sfp_tx_fault=0x%x, link_state=0x%x, "
515 "dcbx_status=0x%x.\n", sfp_tx_fault
, link_speed
,
518 qla83xx_schedule_work(vha
, QLA83XX_NIC_CORE_RESET
);
521 if (mb
[1] & IDC_HEARTBEAT_FAILURE
) {
522 ql_log(ql_log_warn
, vha
, 0x5069,
523 "Heartbeat Failure encountered, chip reset "
526 qla83xx_schedule_work(vha
, QLA83XX_NIC_CORE_RESET
);
530 if (mb
[1] & IDC_DEVICE_STATE_CHANGE
) {
531 ql_log(ql_log_info
, vha
, 0x506a,
532 "IDC Device-State changed = 0x%x.\n", mb
[4]);
533 if (ha
->flags
.nic_core_reset_owner
)
535 qla83xx_schedule_work(vha
, MBA_IDC_AEN
);
540 qla2x00_is_a_vp_did(scsi_qla_host_t
*vha
, uint32_t rscn_entry
)
542 struct qla_hw_data
*ha
= vha
->hw
;
551 spin_lock_irqsave(&ha
->vport_slock
, flags
);
552 list_for_each_entry(vp
, &ha
->vp_list
, list
) {
553 vp_did
= vp
->d_id
.b24
;
554 if (vp_did
== rscn_entry
) {
559 spin_unlock_irqrestore(&ha
->vport_slock
, flags
);
564 static inline fc_port_t
*
565 qla2x00_find_fcport_by_loopid(scsi_qla_host_t
*vha
, uint16_t loop_id
)
569 list_for_each_entry(fcport
, &vha
->vp_fcports
, list
)
570 if (fcport
->loop_id
== loop_id
)
576 * qla2x00_async_event() - Process aynchronous events.
577 * @ha: SCSI driver HA context
578 * @mb: Mailbox registers (0 - 3)
581 qla2x00_async_event(scsi_qla_host_t
*vha
, struct rsp_que
*rsp
, uint16_t *mb
)
586 struct qla_hw_data
*ha
= vha
->hw
;
587 struct device_reg_2xxx __iomem
*reg
= &ha
->iobase
->isp
;
588 struct device_reg_24xx __iomem
*reg24
= &ha
->iobase
->isp24
;
589 struct device_reg_82xx __iomem
*reg82
= &ha
->iobase
->isp82
;
590 uint32_t rscn_entry
, host_pid
;
592 fc_port_t
*fcport
= NULL
;
594 /* Setup to process RIO completion. */
596 if (IS_CNA_CAPABLE(ha
))
599 case MBA_SCSI_COMPLETION
:
600 handles
[0] = le32_to_cpu((uint32_t)((mb
[2] << 16) | mb
[1]));
603 case MBA_CMPLT_1_16BIT
:
606 mb
[0] = MBA_SCSI_COMPLETION
;
608 case MBA_CMPLT_2_16BIT
:
612 mb
[0] = MBA_SCSI_COMPLETION
;
614 case MBA_CMPLT_3_16BIT
:
619 mb
[0] = MBA_SCSI_COMPLETION
;
621 case MBA_CMPLT_4_16BIT
:
625 handles
[3] = (uint32_t)RD_MAILBOX_REG(ha
, reg
, 6);
627 mb
[0] = MBA_SCSI_COMPLETION
;
629 case MBA_CMPLT_5_16BIT
:
633 handles
[3] = (uint32_t)RD_MAILBOX_REG(ha
, reg
, 6);
634 handles
[4] = (uint32_t)RD_MAILBOX_REG(ha
, reg
, 7);
636 mb
[0] = MBA_SCSI_COMPLETION
;
638 case MBA_CMPLT_2_32BIT
:
639 handles
[0] = le32_to_cpu((uint32_t)((mb
[2] << 16) | mb
[1]));
640 handles
[1] = le32_to_cpu(
641 ((uint32_t)(RD_MAILBOX_REG(ha
, reg
, 7) << 16)) |
642 RD_MAILBOX_REG(ha
, reg
, 6));
644 mb
[0] = MBA_SCSI_COMPLETION
;
651 case MBA_SCSI_COMPLETION
: /* Fast Post */
652 if (!vha
->flags
.online
)
655 for (cnt
= 0; cnt
< handle_cnt
; cnt
++)
656 qla2x00_process_completed_request(vha
, rsp
->req
,
660 case MBA_RESET
: /* Reset */
661 ql_dbg(ql_dbg_async
, vha
, 0x5002,
662 "Asynchronous RESET.\n");
664 set_bit(RESET_MARKER_NEEDED
, &vha
->dpc_flags
);
667 case MBA_SYSTEM_ERR
: /* System Error */
668 mbx
= (IS_QLA81XX(ha
) || IS_QLA83XX(ha
) || IS_QLA27XX(ha
)) ?
669 RD_REG_WORD(®24
->mailbox7
) : 0;
670 ql_log(ql_log_warn
, vha
, 0x5003,
671 "ISP System Error - mbx1=%xh mbx2=%xh mbx3=%xh "
672 "mbx7=%xh.\n", mb
[1], mb
[2], mb
[3], mbx
);
674 ha
->isp_ops
->fw_dump(vha
, 1);
676 if (IS_FWI2_CAPABLE(ha
)) {
677 if (mb
[1] == 0 && mb
[2] == 0) {
678 ql_log(ql_log_fatal
, vha
, 0x5004,
679 "Unrecoverable Hardware Error: adapter "
680 "marked OFFLINE!\n");
681 vha
->flags
.online
= 0;
682 vha
->device_flags
|= DFLG_DEV_FAILED
;
684 /* Check to see if MPI timeout occurred */
685 if ((mbx
& MBX_3
) && (ha
->port_no
== 0))
686 set_bit(MPI_RESET_NEEDED
,
689 set_bit(ISP_ABORT_NEEDED
, &vha
->dpc_flags
);
691 } else if (mb
[1] == 0) {
692 ql_log(ql_log_fatal
, vha
, 0x5005,
693 "Unrecoverable Hardware Error: adapter marked "
695 vha
->flags
.online
= 0;
696 vha
->device_flags
|= DFLG_DEV_FAILED
;
698 set_bit(ISP_ABORT_NEEDED
, &vha
->dpc_flags
);
701 case MBA_REQ_TRANSFER_ERR
: /* Request Transfer Error */
702 ql_log(ql_log_warn
, vha
, 0x5006,
703 "ISP Request Transfer Error (%x).\n", mb
[1]);
705 set_bit(ISP_ABORT_NEEDED
, &vha
->dpc_flags
);
708 case MBA_RSP_TRANSFER_ERR
: /* Response Transfer Error */
709 ql_log(ql_log_warn
, vha
, 0x5007,
710 "ISP Response Transfer Error.\n");
712 set_bit(ISP_ABORT_NEEDED
, &vha
->dpc_flags
);
715 case MBA_WAKEUP_THRES
: /* Request Queue Wake-up */
716 ql_dbg(ql_dbg_async
, vha
, 0x5008,
717 "Asynchronous WAKEUP_THRES.\n");
720 case MBA_LIP_OCCURRED
: /* Loop Initialization Procedure */
721 ql_dbg(ql_dbg_async
, vha
, 0x5009,
722 "LIP occurred (%x).\n", mb
[1]);
724 if (atomic_read(&vha
->loop_state
) != LOOP_DOWN
) {
725 atomic_set(&vha
->loop_state
, LOOP_DOWN
);
726 atomic_set(&vha
->loop_down_timer
, LOOP_DOWN_TIME
);
727 qla2x00_mark_all_devices_lost(vha
, 1);
731 atomic_set(&vha
->vp_state
, VP_FAILED
);
732 fc_vport_set_state(vha
->fc_vport
, FC_VPORT_FAILED
);
735 set_bit(REGISTER_FC4_NEEDED
, &vha
->dpc_flags
);
736 set_bit(REGISTER_FDMI_NEEDED
, &vha
->dpc_flags
);
738 vha
->flags
.management_server_logged_in
= 0;
739 qla2x00_post_aen_work(vha
, FCH_EVT_LIP
, mb
[1]);
742 case MBA_LOOP_UP
: /* Loop Up Event */
743 if (IS_QLA2100(ha
) || IS_QLA2200(ha
))
744 ha
->link_data_rate
= PORT_SPEED_1GB
;
746 ha
->link_data_rate
= mb
[1];
748 ql_log(ql_log_info
, vha
, 0x500a,
749 "LOOP UP detected (%s Gbps).\n",
750 qla2x00_get_link_speed_str(ha
, ha
->link_data_rate
));
752 vha
->flags
.management_server_logged_in
= 0;
753 qla2x00_post_aen_work(vha
, FCH_EVT_LINKUP
, ha
->link_data_rate
);
756 case MBA_LOOP_DOWN
: /* Loop Down Event */
757 mbx
= (IS_QLA81XX(ha
) || IS_QLA8031(ha
))
758 ? RD_REG_WORD(®24
->mailbox4
) : 0;
759 mbx
= (IS_P3P_TYPE(ha
)) ? RD_REG_WORD(®82
->mailbox_out
[4])
761 ql_log(ql_log_info
, vha
, 0x500b,
762 "LOOP DOWN detected (%x %x %x %x).\n",
763 mb
[1], mb
[2], mb
[3], mbx
);
765 if (atomic_read(&vha
->loop_state
) != LOOP_DOWN
) {
766 atomic_set(&vha
->loop_state
, LOOP_DOWN
);
767 atomic_set(&vha
->loop_down_timer
, LOOP_DOWN_TIME
);
769 * In case of loop down, restore WWPN from
770 * NVRAM in case of FA-WWPN capable ISP
771 * Restore for Physical Port only
774 if (ha
->flags
.fawwpn_enabled
) {
775 void *wwpn
= ha
->init_cb
->port_name
;
776 memcpy(vha
->port_name
, wwpn
, WWN_SIZE
);
777 fc_host_port_name(vha
->host
) =
778 wwn_to_u64(vha
->port_name
);
779 ql_dbg(ql_dbg_init
+ ql_dbg_verbose
,
780 vha
, 0x0144, "LOOP DOWN detected,"
781 "restore WWPN %016llx\n",
782 wwn_to_u64(vha
->port_name
));
785 clear_bit(VP_CONFIG_OK
, &vha
->vp_flags
);
788 vha
->device_flags
|= DFLG_NO_CABLE
;
789 qla2x00_mark_all_devices_lost(vha
, 1);
793 atomic_set(&vha
->vp_state
, VP_FAILED
);
794 fc_vport_set_state(vha
->fc_vport
, FC_VPORT_FAILED
);
797 vha
->flags
.management_server_logged_in
= 0;
798 ha
->link_data_rate
= PORT_SPEED_UNKNOWN
;
799 qla2x00_post_aen_work(vha
, FCH_EVT_LINKDOWN
, 0);
802 case MBA_LIP_RESET
: /* LIP reset occurred */
803 ql_dbg(ql_dbg_async
, vha
, 0x500c,
804 "LIP reset occurred (%x).\n", mb
[1]);
806 if (atomic_read(&vha
->loop_state
) != LOOP_DOWN
) {
807 atomic_set(&vha
->loop_state
, LOOP_DOWN
);
808 atomic_set(&vha
->loop_down_timer
, LOOP_DOWN_TIME
);
809 qla2x00_mark_all_devices_lost(vha
, 1);
813 atomic_set(&vha
->vp_state
, VP_FAILED
);
814 fc_vport_set_state(vha
->fc_vport
, FC_VPORT_FAILED
);
817 set_bit(RESET_MARKER_NEEDED
, &vha
->dpc_flags
);
819 ha
->operating_mode
= LOOP
;
820 vha
->flags
.management_server_logged_in
= 0;
821 qla2x00_post_aen_work(vha
, FCH_EVT_LIPRESET
, mb
[1]);
824 /* case MBA_DCBX_COMPLETE: */
825 case MBA_POINT_TO_POINT
: /* Point-to-Point */
829 if (IS_CNA_CAPABLE(ha
)) {
830 ql_dbg(ql_dbg_async
, vha
, 0x500d,
831 "DCBX Completed -- %04x %04x %04x.\n",
832 mb
[1], mb
[2], mb
[3]);
833 if (ha
->notify_dcbx_comp
&& !vha
->vp_idx
)
834 complete(&ha
->dcbx_comp
);
837 ql_dbg(ql_dbg_async
, vha
, 0x500e,
838 "Asynchronous P2P MODE received.\n");
841 * Until there's a transition from loop down to loop up, treat
842 * this as loop down only.
844 if (atomic_read(&vha
->loop_state
) != LOOP_DOWN
) {
845 atomic_set(&vha
->loop_state
, LOOP_DOWN
);
846 if (!atomic_read(&vha
->loop_down_timer
))
847 atomic_set(&vha
->loop_down_timer
,
849 qla2x00_mark_all_devices_lost(vha
, 1);
853 atomic_set(&vha
->vp_state
, VP_FAILED
);
854 fc_vport_set_state(vha
->fc_vport
, FC_VPORT_FAILED
);
857 if (!(test_bit(ABORT_ISP_ACTIVE
, &vha
->dpc_flags
)))
858 set_bit(RESET_MARKER_NEEDED
, &vha
->dpc_flags
);
860 set_bit(REGISTER_FC4_NEEDED
, &vha
->dpc_flags
);
861 set_bit(REGISTER_FDMI_NEEDED
, &vha
->dpc_flags
);
863 ha
->flags
.gpsc_supported
= 1;
864 vha
->flags
.management_server_logged_in
= 0;
867 case MBA_CHG_IN_CONNECTION
: /* Change in connection mode */
871 ql_dbg(ql_dbg_async
, vha
, 0x500f,
872 "Configuration change detected: value=%x.\n", mb
[1]);
874 if (atomic_read(&vha
->loop_state
) != LOOP_DOWN
) {
875 atomic_set(&vha
->loop_state
, LOOP_DOWN
);
876 if (!atomic_read(&vha
->loop_down_timer
))
877 atomic_set(&vha
->loop_down_timer
,
879 qla2x00_mark_all_devices_lost(vha
, 1);
883 atomic_set(&vha
->vp_state
, VP_FAILED
);
884 fc_vport_set_state(vha
->fc_vport
, FC_VPORT_FAILED
);
887 set_bit(LOOP_RESYNC_NEEDED
, &vha
->dpc_flags
);
888 set_bit(LOCAL_LOOP_UPDATE
, &vha
->dpc_flags
);
891 case MBA_PORT_UPDATE
: /* Port database update */
893 * Handle only global and vn-port update events
896 * mb[1] = N_Port handle of changed port
897 * OR 0xffff for global event
898 * mb[2] = New login state
899 * 7 = Port logged out
900 * mb[3] = LSB is vp_idx, 0xff = all vps
902 * Skip processing if:
903 * Event is global, vp_idx is NOT all vps,
904 * vp_idx does not match
905 * Event is not global, vp_idx does not match
907 if (IS_QLA2XXX_MIDTYPE(ha
) &&
908 ((mb
[1] == 0xffff && (mb
[3] & 0xff) != 0xff) ||
909 (mb
[1] != 0xffff)) && vha
->vp_idx
!= (mb
[3] & 0xff))
913 ql_dbg(ql_dbg_async
, vha
, 0x5010,
914 "Port %s %04x %04x %04x.\n",
915 mb
[1] == 0xffff ? "unavailable" : "logout",
916 mb
[1], mb
[2], mb
[3]);
919 goto global_port_update
;
922 fcport
= qla2x00_find_fcport_by_loopid(vha
, mb
[1]);
925 if (atomic_read(&fcport
->state
) != FCS_ONLINE
)
927 ql_dbg(ql_dbg_async
, vha
, 0x508a,
928 "Marking port lost loopid=%04x portid=%06x.\n",
929 fcport
->loop_id
, fcport
->d_id
.b24
);
930 qla2x00_mark_device_lost(fcport
->vha
, fcport
, 1, 1);
934 /* Port unavailable. */
935 ql_log(ql_log_warn
, vha
, 0x505e,
936 "Link is offline.\n");
938 if (atomic_read(&vha
->loop_state
) != LOOP_DOWN
) {
939 atomic_set(&vha
->loop_state
, LOOP_DOWN
);
940 atomic_set(&vha
->loop_down_timer
,
942 vha
->device_flags
|= DFLG_NO_CABLE
;
943 qla2x00_mark_all_devices_lost(vha
, 1);
947 atomic_set(&vha
->vp_state
, VP_FAILED
);
948 fc_vport_set_state(vha
->fc_vport
,
950 qla2x00_mark_all_devices_lost(vha
, 1);
953 vha
->flags
.management_server_logged_in
= 0;
954 ha
->link_data_rate
= PORT_SPEED_UNKNOWN
;
959 * If PORT UPDATE is global (received LIP_OCCURRED/LIP_RESET
960 * event etc. earlier indicating loop is down) then process
961 * it. Otherwise ignore it and Wait for RSCN to come in.
963 atomic_set(&vha
->loop_down_timer
, 0);
964 if (atomic_read(&vha
->loop_state
) != LOOP_DOWN
&&
965 atomic_read(&vha
->loop_state
) != LOOP_DEAD
) {
966 ql_dbg(ql_dbg_async
, vha
, 0x5011,
967 "Asynchronous PORT UPDATE ignored %04x/%04x/%04x.\n",
968 mb
[1], mb
[2], mb
[3]);
970 qlt_async_event(mb
[0], vha
, mb
);
974 ql_dbg(ql_dbg_async
, vha
, 0x5012,
975 "Port database changed %04x %04x %04x.\n",
976 mb
[1], mb
[2], mb
[3]);
979 * Mark all devices as missing so we will login again.
981 atomic_set(&vha
->loop_state
, LOOP_UP
);
983 qla2x00_mark_all_devices_lost(vha
, 1);
985 if (vha
->vp_idx
== 0 && !qla_ini_mode_enabled(vha
))
986 set_bit(SCR_PENDING
, &vha
->dpc_flags
);
988 set_bit(LOOP_RESYNC_NEEDED
, &vha
->dpc_flags
);
989 set_bit(LOCAL_LOOP_UPDATE
, &vha
->dpc_flags
);
990 set_bit(VP_CONFIG_OK
, &vha
->vp_flags
);
992 qlt_async_event(mb
[0], vha
, mb
);
995 case MBA_RSCN_UPDATE
: /* State Change Registration */
996 /* Check if the Vport has issued a SCR */
997 if (vha
->vp_idx
&& test_bit(VP_SCR_NEEDED
, &vha
->vp_flags
))
999 /* Only handle SCNs for our Vport index. */
1000 if (ha
->flags
.npiv_supported
&& vha
->vp_idx
!= (mb
[3] & 0xff))
1003 ql_dbg(ql_dbg_async
, vha
, 0x5013,
1004 "RSCN database changed -- %04x %04x %04x.\n",
1005 mb
[1], mb
[2], mb
[3]);
1007 rscn_entry
= ((mb
[1] & 0xff) << 16) | mb
[2];
1008 host_pid
= (vha
->d_id
.b
.domain
<< 16) | (vha
->d_id
.b
.area
<< 8)
1009 | vha
->d_id
.b
.al_pa
;
1010 if (rscn_entry
== host_pid
) {
1011 ql_dbg(ql_dbg_async
, vha
, 0x5014,
1012 "Ignoring RSCN update to local host "
1013 "port ID (%06x).\n", host_pid
);
1017 /* Ignore reserved bits from RSCN-payload. */
1018 rscn_entry
= ((mb
[1] & 0x3ff) << 16) | mb
[2];
1020 /* Skip RSCNs for virtual ports on the same physical port */
1021 if (qla2x00_is_a_vp_did(vha
, rscn_entry
))
1025 * Search for the rport related to this RSCN entry and mark it
1028 list_for_each_entry(fcport
, &vha
->vp_fcports
, list
) {
1029 if (atomic_read(&fcport
->state
) != FCS_ONLINE
)
1031 if (fcport
->d_id
.b24
== rscn_entry
) {
1032 qla2x00_mark_device_lost(vha
, fcport
, 0, 0);
1037 atomic_set(&vha
->loop_down_timer
, 0);
1038 vha
->flags
.management_server_logged_in
= 0;
1040 set_bit(LOOP_RESYNC_NEEDED
, &vha
->dpc_flags
);
1041 set_bit(RSCN_UPDATE
, &vha
->dpc_flags
);
1042 qla2x00_post_aen_work(vha
, FCH_EVT_RSCN
, rscn_entry
);
1045 /* case MBA_RIO_RESPONSE: */
1046 case MBA_ZIO_RESPONSE
:
1047 ql_dbg(ql_dbg_async
, vha
, 0x5015,
1048 "[R|Z]IO update completion.\n");
1050 if (IS_FWI2_CAPABLE(ha
))
1051 qla24xx_process_response_queue(vha
, rsp
);
1053 qla2x00_process_response_queue(rsp
);
1056 case MBA_DISCARD_RND_FRAME
:
1057 ql_dbg(ql_dbg_async
, vha
, 0x5016,
1058 "Discard RND Frame -- %04x %04x %04x.\n",
1059 mb
[1], mb
[2], mb
[3]);
1062 case MBA_TRACE_NOTIFICATION
:
1063 ql_dbg(ql_dbg_async
, vha
, 0x5017,
1064 "Trace Notification -- %04x %04x.\n", mb
[1], mb
[2]);
1067 case MBA_ISP84XX_ALERT
:
1068 ql_dbg(ql_dbg_async
, vha
, 0x5018,
1069 "ISP84XX Alert Notification -- %04x %04x %04x.\n",
1070 mb
[1], mb
[2], mb
[3]);
1072 spin_lock_irqsave(&ha
->cs84xx
->access_lock
, flags
);
1074 case A84_PANIC_RECOVERY
:
1075 ql_log(ql_log_info
, vha
, 0x5019,
1076 "Alert 84XX: panic recovery %04x %04x.\n",
1079 case A84_OP_LOGIN_COMPLETE
:
1080 ha
->cs84xx
->op_fw_version
= mb
[3] << 16 | mb
[2];
1081 ql_log(ql_log_info
, vha
, 0x501a,
1082 "Alert 84XX: firmware version %x.\n",
1083 ha
->cs84xx
->op_fw_version
);
1085 case A84_DIAG_LOGIN_COMPLETE
:
1086 ha
->cs84xx
->diag_fw_version
= mb
[3] << 16 | mb
[2];
1087 ql_log(ql_log_info
, vha
, 0x501b,
1088 "Alert 84XX: diagnostic firmware version %x.\n",
1089 ha
->cs84xx
->diag_fw_version
);
1091 case A84_GOLD_LOGIN_COMPLETE
:
1092 ha
->cs84xx
->diag_fw_version
= mb
[3] << 16 | mb
[2];
1093 ha
->cs84xx
->fw_update
= 1;
1094 ql_log(ql_log_info
, vha
, 0x501c,
1095 "Alert 84XX: gold firmware version %x.\n",
1096 ha
->cs84xx
->gold_fw_version
);
1099 ql_log(ql_log_warn
, vha
, 0x501d,
1100 "Alert 84xx: Invalid Alert %04x %04x %04x.\n",
1101 mb
[1], mb
[2], mb
[3]);
1103 spin_unlock_irqrestore(&ha
->cs84xx
->access_lock
, flags
);
1105 case MBA_DCBX_START
:
1106 ql_dbg(ql_dbg_async
, vha
, 0x501e,
1107 "DCBX Started -- %04x %04x %04x.\n",
1108 mb
[1], mb
[2], mb
[3]);
1110 case MBA_DCBX_PARAM_UPDATE
:
1111 ql_dbg(ql_dbg_async
, vha
, 0x501f,
1112 "DCBX Parameters Updated -- %04x %04x %04x.\n",
1113 mb
[1], mb
[2], mb
[3]);
1115 case MBA_FCF_CONF_ERR
:
1116 ql_dbg(ql_dbg_async
, vha
, 0x5020,
1117 "FCF Configuration Error -- %04x %04x %04x.\n",
1118 mb
[1], mb
[2], mb
[3]);
1120 case MBA_IDC_NOTIFY
:
1121 if (IS_QLA8031(vha
->hw
) || IS_QLA8044(ha
)) {
1122 mb
[4] = RD_REG_WORD(®24
->mailbox4
);
1123 if (((mb
[2] & 0x7fff) == MBC_PORT_RESET
||
1124 (mb
[2] & 0x7fff) == MBC_SET_PORT_CONFIG
) &&
1125 (mb
[4] & INTERNAL_LOOPBACK_MASK
) != 0) {
1126 set_bit(ISP_QUIESCE_NEEDED
, &vha
->dpc_flags
);
1128 * Extend loop down timer since port is active.
1130 if (atomic_read(&vha
->loop_state
) == LOOP_DOWN
)
1131 atomic_set(&vha
->loop_down_timer
,
1133 qla2xxx_wake_dpc(vha
);
1136 case MBA_IDC_COMPLETE
:
1137 if (ha
->notify_lb_portup_comp
&& !vha
->vp_idx
)
1138 complete(&ha
->lb_portup_comp
);
1140 case MBA_IDC_TIME_EXT
:
1141 if (IS_QLA81XX(vha
->hw
) || IS_QLA8031(vha
->hw
) ||
1143 qla81xx_idc_event(vha
, mb
[0], mb
[1]);
1147 mb
[4] = RD_REG_WORD(®24
->mailbox4
);
1148 mb
[5] = RD_REG_WORD(®24
->mailbox5
);
1149 mb
[6] = RD_REG_WORD(®24
->mailbox6
);
1150 mb
[7] = RD_REG_WORD(®24
->mailbox7
);
1151 qla83xx_handle_8200_aen(vha
, mb
);
1154 case MBA_DPORT_DIAGNOSTICS
:
1155 ql_dbg(ql_dbg_async
, vha
, 0x5052,
1156 "D-Port Diagnostics: %04x %04x=%s\n", mb
[0], mb
[1],
1157 mb
[1] == 0 ? "start" :
1158 mb
[1] == 1 ? "done (ok)" :
1159 mb
[1] == 2 ? "done (error)" : "other");
1163 ql_dbg(ql_dbg_async
, vha
, 0x5057,
1164 "Unknown AEN:%04x %04x %04x %04x\n",
1165 mb
[0], mb
[1], mb
[2], mb
[3]);
1168 qlt_async_event(mb
[0], vha
, mb
);
1170 if (!vha
->vp_idx
&& ha
->num_vhosts
)
1171 qla2x00_alert_all_vps(rsp
, mb
);
1175 * qla2x00_process_completed_request() - Process a Fast Post response.
1176 * @ha: SCSI driver HA context
1180 qla2x00_process_completed_request(struct scsi_qla_host
*vha
,
1181 struct req_que
*req
, uint32_t index
)
1184 struct qla_hw_data
*ha
= vha
->hw
;
1186 /* Validate handle. */
1187 if (index
>= req
->num_outstanding_cmds
) {
1188 ql_log(ql_log_warn
, vha
, 0x3014,
1189 "Invalid SCSI command index (%x).\n", index
);
1191 if (IS_P3P_TYPE(ha
))
1192 set_bit(FCOE_CTX_RESET_NEEDED
, &vha
->dpc_flags
);
1194 set_bit(ISP_ABORT_NEEDED
, &vha
->dpc_flags
);
1198 sp
= req
->outstanding_cmds
[index
];
1200 /* Free outstanding command slot. */
1201 req
->outstanding_cmds
[index
] = NULL
;
1203 /* Save ISP completion status */
1204 sp
->done(ha
, sp
, DID_OK
<< 16);
1206 ql_log(ql_log_warn
, vha
, 0x3016, "Invalid SCSI SRB.\n");
1208 if (IS_P3P_TYPE(ha
))
1209 set_bit(FCOE_CTX_RESET_NEEDED
, &vha
->dpc_flags
);
1211 set_bit(ISP_ABORT_NEEDED
, &vha
->dpc_flags
);
1216 qla2x00_get_sp_from_handle(scsi_qla_host_t
*vha
, const char *func
,
1217 struct req_que
*req
, void *iocb
)
1219 struct qla_hw_data
*ha
= vha
->hw
;
1220 sts_entry_t
*pkt
= iocb
;
1224 index
= LSW(pkt
->handle
);
1225 if (index
>= req
->num_outstanding_cmds
) {
1226 ql_log(ql_log_warn
, vha
, 0x5031,
1227 "Invalid command index (%x).\n", index
);
1228 if (IS_P3P_TYPE(ha
))
1229 set_bit(FCOE_CTX_RESET_NEEDED
, &vha
->dpc_flags
);
1231 set_bit(ISP_ABORT_NEEDED
, &vha
->dpc_flags
);
1234 sp
= req
->outstanding_cmds
[index
];
1236 ql_log(ql_log_warn
, vha
, 0x5032,
1237 "Invalid completion handle (%x) -- timed-out.\n", index
);
1240 if (sp
->handle
!= index
) {
1241 ql_log(ql_log_warn
, vha
, 0x5033,
1242 "SRB handle (%x) mismatch %x.\n", sp
->handle
, index
);
1246 req
->outstanding_cmds
[index
] = NULL
;
1253 qla2x00_mbx_iocb_entry(scsi_qla_host_t
*vha
, struct req_que
*req
,
1254 struct mbx_entry
*mbx
)
1256 const char func
[] = "MBX-IOCB";
1260 struct srb_iocb
*lio
;
1264 sp
= qla2x00_get_sp_from_handle(vha
, func
, req
, mbx
);
1268 lio
= &sp
->u
.iocb_cmd
;
1270 fcport
= sp
->fcport
;
1271 data
= lio
->u
.logio
.data
;
1273 data
[0] = MBS_COMMAND_ERROR
;
1274 data
[1] = lio
->u
.logio
.flags
& SRB_LOGIN_RETRIED
?
1275 QLA_LOGIO_LOGIN_RETRIED
: 0;
1276 if (mbx
->entry_status
) {
1277 ql_dbg(ql_dbg_async
, vha
, 0x5043,
1278 "Async-%s error entry - hdl=%x portid=%02x%02x%02x "
1279 "entry-status=%x status=%x state-flag=%x "
1280 "status-flags=%x.\n", type
, sp
->handle
,
1281 fcport
->d_id
.b
.domain
, fcport
->d_id
.b
.area
,
1282 fcport
->d_id
.b
.al_pa
, mbx
->entry_status
,
1283 le16_to_cpu(mbx
->status
), le16_to_cpu(mbx
->state_flags
),
1284 le16_to_cpu(mbx
->status_flags
));
1286 ql_dump_buffer(ql_dbg_async
+ ql_dbg_buffer
, vha
, 0x5029,
1287 (uint8_t *)mbx
, sizeof(*mbx
));
1292 status
= le16_to_cpu(mbx
->status
);
1293 if (status
== 0x30 && sp
->type
== SRB_LOGIN_CMD
&&
1294 le16_to_cpu(mbx
->mb0
) == MBS_COMMAND_COMPLETE
)
1296 if (!status
&& le16_to_cpu(mbx
->mb0
) == MBS_COMMAND_COMPLETE
) {
1297 ql_dbg(ql_dbg_async
, vha
, 0x5045,
1298 "Async-%s complete - hdl=%x portid=%02x%02x%02x mbx1=%x.\n",
1299 type
, sp
->handle
, fcport
->d_id
.b
.domain
,
1300 fcport
->d_id
.b
.area
, fcport
->d_id
.b
.al_pa
,
1301 le16_to_cpu(mbx
->mb1
));
1303 data
[0] = MBS_COMMAND_COMPLETE
;
1304 if (sp
->type
== SRB_LOGIN_CMD
) {
1305 fcport
->port_type
= FCT_TARGET
;
1306 if (le16_to_cpu(mbx
->mb1
) & BIT_0
)
1307 fcport
->port_type
= FCT_INITIATOR
;
1308 else if (le16_to_cpu(mbx
->mb1
) & BIT_1
)
1309 fcport
->flags
|= FCF_FCP2_DEVICE
;
1314 data
[0] = le16_to_cpu(mbx
->mb0
);
1316 case MBS_PORT_ID_USED
:
1317 data
[1] = le16_to_cpu(mbx
->mb1
);
1319 case MBS_LOOP_ID_USED
:
1322 data
[0] = MBS_COMMAND_ERROR
;
1326 ql_log(ql_log_warn
, vha
, 0x5046,
1327 "Async-%s failed - hdl=%x portid=%02x%02x%02x status=%x "
1328 "mb0=%x mb1=%x mb2=%x mb6=%x mb7=%x.\n", type
, sp
->handle
,
1329 fcport
->d_id
.b
.domain
, fcport
->d_id
.b
.area
, fcport
->d_id
.b
.al_pa
,
1330 status
, le16_to_cpu(mbx
->mb0
), le16_to_cpu(mbx
->mb1
),
1331 le16_to_cpu(mbx
->mb2
), le16_to_cpu(mbx
->mb6
),
1332 le16_to_cpu(mbx
->mb7
));
1335 sp
->done(vha
, sp
, 0);
1339 qla2x00_ct_entry(scsi_qla_host_t
*vha
, struct req_que
*req
,
1340 sts_entry_t
*pkt
, int iocb_type
)
1342 const char func
[] = "CT_IOCB";
1345 struct fc_bsg_job
*bsg_job
;
1346 uint16_t comp_status
;
1349 sp
= qla2x00_get_sp_from_handle(vha
, func
, req
, pkt
);
1353 bsg_job
= sp
->u
.bsg_job
;
1355 type
= "ct pass-through";
1357 comp_status
= le16_to_cpu(pkt
->comp_status
);
1359 /* return FC_CTELS_STATUS_OK and leave the decoding of the ELS/CT
1360 * fc payload to the caller
1362 bsg_job
->reply
->reply_data
.ctels_reply
.status
= FC_CTELS_STATUS_OK
;
1363 bsg_job
->reply_len
= sizeof(struct fc_bsg_reply
);
1365 if (comp_status
!= CS_COMPLETE
) {
1366 if (comp_status
== CS_DATA_UNDERRUN
) {
1368 bsg_job
->reply
->reply_payload_rcv_len
=
1369 le16_to_cpu(((sts_entry_t
*)pkt
)->rsp_info_len
);
1371 ql_log(ql_log_warn
, vha
, 0x5048,
1372 "CT pass-through-%s error "
1373 "comp_status-status=0x%x total_byte = 0x%x.\n",
1375 bsg_job
->reply
->reply_payload_rcv_len
);
1377 ql_log(ql_log_warn
, vha
, 0x5049,
1378 "CT pass-through-%s error "
1379 "comp_status-status=0x%x.\n", type
, comp_status
);
1380 res
= DID_ERROR
<< 16;
1381 bsg_job
->reply
->reply_payload_rcv_len
= 0;
1383 ql_dump_buffer(ql_dbg_async
+ ql_dbg_buffer
, vha
, 0x5035,
1384 (uint8_t *)pkt
, sizeof(*pkt
));
1387 bsg_job
->reply
->reply_payload_rcv_len
=
1388 bsg_job
->reply_payload
.payload_len
;
1389 bsg_job
->reply_len
= 0;
1392 sp
->done(vha
, sp
, res
);
1396 qla24xx_els_ct_entry(scsi_qla_host_t
*vha
, struct req_que
*req
,
1397 struct sts_entry_24xx
*pkt
, int iocb_type
)
1399 const char func
[] = "ELS_CT_IOCB";
1402 struct fc_bsg_job
*bsg_job
;
1403 uint16_t comp_status
;
1404 uint32_t fw_status
[3];
1405 uint8_t* fw_sts_ptr
;
1408 sp
= qla2x00_get_sp_from_handle(vha
, func
, req
, pkt
);
1411 bsg_job
= sp
->u
.bsg_job
;
1415 case SRB_ELS_CMD_RPT
:
1416 case SRB_ELS_CMD_HST
:
1420 type
= "ct pass-through";
1423 ql_dbg(ql_dbg_user
, vha
, 0x503e,
1424 "Unrecognized SRB: (%p) type=%d.\n", sp
, sp
->type
);
1428 comp_status
= fw_status
[0] = le16_to_cpu(pkt
->comp_status
);
1429 fw_status
[1] = le16_to_cpu(((struct els_sts_entry_24xx
*)pkt
)->error_subcode_1
);
1430 fw_status
[2] = le16_to_cpu(((struct els_sts_entry_24xx
*)pkt
)->error_subcode_2
);
1432 /* return FC_CTELS_STATUS_OK and leave the decoding of the ELS/CT
1433 * fc payload to the caller
1435 bsg_job
->reply
->reply_data
.ctels_reply
.status
= FC_CTELS_STATUS_OK
;
1436 bsg_job
->reply_len
= sizeof(struct fc_bsg_reply
) + sizeof(fw_status
);
1438 if (comp_status
!= CS_COMPLETE
) {
1439 if (comp_status
== CS_DATA_UNDERRUN
) {
1441 bsg_job
->reply
->reply_payload_rcv_len
=
1442 le16_to_cpu(((struct els_sts_entry_24xx
*)pkt
)->total_byte_count
);
1444 ql_dbg(ql_dbg_user
, vha
, 0x503f,
1445 "ELS-CT pass-through-%s error hdl=%x comp_status-status=0x%x "
1446 "error subcode 1=0x%x error subcode 2=0x%x total_byte = 0x%x.\n",
1447 type
, sp
->handle
, comp_status
, fw_status
[1], fw_status
[2],
1448 le16_to_cpu(((struct els_sts_entry_24xx
*)
1449 pkt
)->total_byte_count
));
1450 fw_sts_ptr
= ((uint8_t*)bsg_job
->req
->sense
) + sizeof(struct fc_bsg_reply
);
1451 memcpy( fw_sts_ptr
, fw_status
, sizeof(fw_status
));
1454 ql_dbg(ql_dbg_user
, vha
, 0x5040,
1455 "ELS-CT pass-through-%s error hdl=%x comp_status-status=0x%x "
1456 "error subcode 1=0x%x error subcode 2=0x%x.\n",
1457 type
, sp
->handle
, comp_status
,
1458 le16_to_cpu(((struct els_sts_entry_24xx
*)
1459 pkt
)->error_subcode_1
),
1460 le16_to_cpu(((struct els_sts_entry_24xx
*)
1461 pkt
)->error_subcode_2
));
1462 res
= DID_ERROR
<< 16;
1463 bsg_job
->reply
->reply_payload_rcv_len
= 0;
1464 fw_sts_ptr
= ((uint8_t*)bsg_job
->req
->sense
) + sizeof(struct fc_bsg_reply
);
1465 memcpy( fw_sts_ptr
, fw_status
, sizeof(fw_status
));
1467 ql_dump_buffer(ql_dbg_user
+ ql_dbg_buffer
, vha
, 0x5056,
1468 (uint8_t *)pkt
, sizeof(*pkt
));
1472 bsg_job
->reply
->reply_payload_rcv_len
= bsg_job
->reply_payload
.payload_len
;
1473 bsg_job
->reply_len
= 0;
1476 sp
->done(vha
, sp
, res
);
1480 qla24xx_logio_entry(scsi_qla_host_t
*vha
, struct req_que
*req
,
1481 struct logio_entry_24xx
*logio
)
1483 const char func
[] = "LOGIO-IOCB";
1487 struct srb_iocb
*lio
;
1491 sp
= qla2x00_get_sp_from_handle(vha
, func
, req
, logio
);
1495 lio
= &sp
->u
.iocb_cmd
;
1497 fcport
= sp
->fcport
;
1498 data
= lio
->u
.logio
.data
;
1500 data
[0] = MBS_COMMAND_ERROR
;
1501 data
[1] = lio
->u
.logio
.flags
& SRB_LOGIN_RETRIED
?
1502 QLA_LOGIO_LOGIN_RETRIED
: 0;
1503 if (logio
->entry_status
) {
1504 ql_log(ql_log_warn
, fcport
->vha
, 0x5034,
1505 "Async-%s error entry - hdl=%x"
1506 "portid=%02x%02x%02x entry-status=%x.\n",
1507 type
, sp
->handle
, fcport
->d_id
.b
.domain
,
1508 fcport
->d_id
.b
.area
, fcport
->d_id
.b
.al_pa
,
1509 logio
->entry_status
);
1510 ql_dump_buffer(ql_dbg_async
+ ql_dbg_buffer
, vha
, 0x504d,
1511 (uint8_t *)logio
, sizeof(*logio
));
1516 if (le16_to_cpu(logio
->comp_status
) == CS_COMPLETE
) {
1517 ql_dbg(ql_dbg_async
, fcport
->vha
, 0x5036,
1518 "Async-%s complete - hdl=%x portid=%02x%02x%02x "
1519 "iop0=%x.\n", type
, sp
->handle
, fcport
->d_id
.b
.domain
,
1520 fcport
->d_id
.b
.area
, fcport
->d_id
.b
.al_pa
,
1521 le32_to_cpu(logio
->io_parameter
[0]));
1523 data
[0] = MBS_COMMAND_COMPLETE
;
1524 if (sp
->type
!= SRB_LOGIN_CMD
)
1527 iop
[0] = le32_to_cpu(logio
->io_parameter
[0]);
1528 if (iop
[0] & BIT_4
) {
1529 fcport
->port_type
= FCT_TARGET
;
1531 fcport
->flags
|= FCF_FCP2_DEVICE
;
1532 } else if (iop
[0] & BIT_5
)
1533 fcport
->port_type
= FCT_INITIATOR
;
1536 fcport
->flags
|= FCF_CONF_COMP_SUPPORTED
;
1538 if (logio
->io_parameter
[7] || logio
->io_parameter
[8])
1539 fcport
->supported_classes
|= FC_COS_CLASS2
;
1540 if (logio
->io_parameter
[9] || logio
->io_parameter
[10])
1541 fcport
->supported_classes
|= FC_COS_CLASS3
;
1546 iop
[0] = le32_to_cpu(logio
->io_parameter
[0]);
1547 iop
[1] = le32_to_cpu(logio
->io_parameter
[1]);
1549 case LSC_SCODE_PORTID_USED
:
1550 data
[0] = MBS_PORT_ID_USED
;
1551 data
[1] = LSW(iop
[1]);
1553 case LSC_SCODE_NPORT_USED
:
1554 data
[0] = MBS_LOOP_ID_USED
;
1557 data
[0] = MBS_COMMAND_ERROR
;
1561 ql_dbg(ql_dbg_async
, fcport
->vha
, 0x5037,
1562 "Async-%s failed - hdl=%x portid=%02x%02x%02x comp=%x "
1563 "iop0=%x iop1=%x.\n", type
, sp
->handle
, fcport
->d_id
.b
.domain
,
1564 fcport
->d_id
.b
.area
, fcport
->d_id
.b
.al_pa
,
1565 le16_to_cpu(logio
->comp_status
),
1566 le32_to_cpu(logio
->io_parameter
[0]),
1567 le32_to_cpu(logio
->io_parameter
[1]));
1570 sp
->done(vha
, sp
, 0);
1574 qla24xx_tm_iocb_entry(scsi_qla_host_t
*vha
, struct req_que
*req
, void *tsk
)
1576 const char func
[] = "TMF-IOCB";
1580 struct srb_iocb
*iocb
;
1581 struct sts_entry_24xx
*sts
= (struct sts_entry_24xx
*)tsk
;
1583 sp
= qla2x00_get_sp_from_handle(vha
, func
, req
, tsk
);
1587 iocb
= &sp
->u
.iocb_cmd
;
1589 fcport
= sp
->fcport
;
1590 iocb
->u
.tmf
.data
= QLA_SUCCESS
;
1592 if (sts
->entry_status
) {
1593 ql_log(ql_log_warn
, fcport
->vha
, 0x5038,
1594 "Async-%s error - hdl=%x entry-status(%x).\n",
1595 type
, sp
->handle
, sts
->entry_status
);
1596 iocb
->u
.tmf
.data
= QLA_FUNCTION_FAILED
;
1597 } else if (sts
->comp_status
!= cpu_to_le16(CS_COMPLETE
)) {
1598 ql_log(ql_log_warn
, fcport
->vha
, 0x5039,
1599 "Async-%s error - hdl=%x completion status(%x).\n",
1600 type
, sp
->handle
, sts
->comp_status
);
1601 iocb
->u
.tmf
.data
= QLA_FUNCTION_FAILED
;
1602 } else if ((le16_to_cpu(sts
->scsi_status
) &
1603 SS_RESPONSE_INFO_LEN_VALID
)) {
1604 if (le32_to_cpu(sts
->rsp_data_len
) < 4) {
1605 ql_log(ql_log_warn
, fcport
->vha
, 0x503b,
1606 "Async-%s error - hdl=%x not enough response(%d).\n",
1607 type
, sp
->handle
, sts
->rsp_data_len
);
1608 } else if (sts
->data
[3]) {
1609 ql_log(ql_log_warn
, fcport
->vha
, 0x503c,
1610 "Async-%s error - hdl=%x response(%x).\n",
1611 type
, sp
->handle
, sts
->data
[3]);
1612 iocb
->u
.tmf
.data
= QLA_FUNCTION_FAILED
;
1616 if (iocb
->u
.tmf
.data
!= QLA_SUCCESS
)
1617 ql_dump_buffer(ql_dbg_async
+ ql_dbg_buffer
, vha
, 0x5055,
1618 (uint8_t *)sts
, sizeof(*sts
));
1620 sp
->done(vha
, sp
, 0);
1624 * qla2x00_process_response_queue() - Process response queue entries.
1625 * @ha: SCSI driver HA context
1628 qla2x00_process_response_queue(struct rsp_que
*rsp
)
1630 struct scsi_qla_host
*vha
;
1631 struct qla_hw_data
*ha
= rsp
->hw
;
1632 struct device_reg_2xxx __iomem
*reg
= &ha
->iobase
->isp
;
1634 uint16_t handle_cnt
;
1637 vha
= pci_get_drvdata(ha
->pdev
);
1639 if (!vha
->flags
.online
)
1642 while (rsp
->ring_ptr
->signature
!= RESPONSE_PROCESSED
) {
1643 pkt
= (sts_entry_t
*)rsp
->ring_ptr
;
1646 if (rsp
->ring_index
== rsp
->length
) {
1647 rsp
->ring_index
= 0;
1648 rsp
->ring_ptr
= rsp
->ring
;
1653 if (pkt
->entry_status
!= 0) {
1654 qla2x00_error_entry(vha
, rsp
, pkt
);
1655 ((response_t
*)pkt
)->signature
= RESPONSE_PROCESSED
;
1660 switch (pkt
->entry_type
) {
1662 qla2x00_status_entry(vha
, rsp
, pkt
);
1664 case STATUS_TYPE_21
:
1665 handle_cnt
= ((sts21_entry_t
*)pkt
)->handle_count
;
1666 for (cnt
= 0; cnt
< handle_cnt
; cnt
++) {
1667 qla2x00_process_completed_request(vha
, rsp
->req
,
1668 ((sts21_entry_t
*)pkt
)->handle
[cnt
]);
1671 case STATUS_TYPE_22
:
1672 handle_cnt
= ((sts22_entry_t
*)pkt
)->handle_count
;
1673 for (cnt
= 0; cnt
< handle_cnt
; cnt
++) {
1674 qla2x00_process_completed_request(vha
, rsp
->req
,
1675 ((sts22_entry_t
*)pkt
)->handle
[cnt
]);
1678 case STATUS_CONT_TYPE
:
1679 qla2x00_status_cont_entry(rsp
, (sts_cont_entry_t
*)pkt
);
1682 qla2x00_mbx_iocb_entry(vha
, rsp
->req
,
1683 (struct mbx_entry
*)pkt
);
1686 qla2x00_ct_entry(vha
, rsp
->req
, pkt
, CT_IOCB_TYPE
);
1689 /* Type Not Supported. */
1690 ql_log(ql_log_warn
, vha
, 0x504a,
1691 "Received unknown response pkt type %x "
1692 "entry status=%x.\n",
1693 pkt
->entry_type
, pkt
->entry_status
);
1696 ((response_t
*)pkt
)->signature
= RESPONSE_PROCESSED
;
1700 /* Adjust ring index */
1701 WRT_REG_WORD(ISP_RSP_Q_OUT(ha
, reg
), rsp
->ring_index
);
1705 qla2x00_handle_sense(srb_t
*sp
, uint8_t *sense_data
, uint32_t par_sense_len
,
1706 uint32_t sense_len
, struct rsp_que
*rsp
, int res
)
1708 struct scsi_qla_host
*vha
= sp
->fcport
->vha
;
1709 struct scsi_cmnd
*cp
= GET_CMD_SP(sp
);
1710 uint32_t track_sense_len
;
1712 if (sense_len
>= SCSI_SENSE_BUFFERSIZE
)
1713 sense_len
= SCSI_SENSE_BUFFERSIZE
;
1715 SET_CMD_SENSE_LEN(sp
, sense_len
);
1716 SET_CMD_SENSE_PTR(sp
, cp
->sense_buffer
);
1717 track_sense_len
= sense_len
;
1719 if (sense_len
> par_sense_len
)
1720 sense_len
= par_sense_len
;
1722 memcpy(cp
->sense_buffer
, sense_data
, sense_len
);
1724 SET_CMD_SENSE_PTR(sp
, cp
->sense_buffer
+ sense_len
);
1725 track_sense_len
-= sense_len
;
1726 SET_CMD_SENSE_LEN(sp
, track_sense_len
);
1728 if (track_sense_len
!= 0) {
1729 rsp
->status_srb
= sp
;
1734 ql_dbg(ql_dbg_io
+ ql_dbg_buffer
, vha
, 0x301c,
1735 "Check condition Sense data, nexus%ld:%d:%llu cmd=%p.\n",
1736 sp
->fcport
->vha
->host_no
, cp
->device
->id
, cp
->device
->lun
,
1738 ql_dump_buffer(ql_dbg_io
+ ql_dbg_buffer
, vha
, 0x302b,
1739 cp
->sense_buffer
, sense_len
);
1743 struct scsi_dif_tuple
{
1744 __be16 guard
; /* Checksum */
1745 __be16 app_tag
; /* APPL identifier */
1746 __be32 ref_tag
; /* Target LBA or indirect LBA */
1750 * Checks the guard or meta-data for the type of error
1751 * detected by the HBA. In case of errors, we set the
1752 * ASC/ASCQ fields in the sense buffer with ILLEGAL_REQUEST
1753 * to indicate to the kernel that the HBA detected error.
1756 qla2x00_handle_dif_error(srb_t
*sp
, struct sts_entry_24xx
*sts24
)
1758 struct scsi_qla_host
*vha
= sp
->fcport
->vha
;
1759 struct scsi_cmnd
*cmd
= GET_CMD_SP(sp
);
1760 uint8_t *ap
= &sts24
->data
[12];
1761 uint8_t *ep
= &sts24
->data
[20];
1762 uint32_t e_ref_tag
, a_ref_tag
;
1763 uint16_t e_app_tag
, a_app_tag
;
1764 uint16_t e_guard
, a_guard
;
1767 * swab32 of the "data" field in the beginning of qla2x00_status_entry()
1768 * would make guard field appear at offset 2
1770 a_guard
= le16_to_cpu(*(uint16_t *)(ap
+ 2));
1771 a_app_tag
= le16_to_cpu(*(uint16_t *)(ap
+ 0));
1772 a_ref_tag
= le32_to_cpu(*(uint32_t *)(ap
+ 4));
1773 e_guard
= le16_to_cpu(*(uint16_t *)(ep
+ 2));
1774 e_app_tag
= le16_to_cpu(*(uint16_t *)(ep
+ 0));
1775 e_ref_tag
= le32_to_cpu(*(uint32_t *)(ep
+ 4));
1777 ql_dbg(ql_dbg_io
, vha
, 0x3023,
1778 "iocb(s) %p Returned STATUS.\n", sts24
);
1780 ql_dbg(ql_dbg_io
, vha
, 0x3024,
1781 "DIF ERROR in cmd 0x%x lba 0x%llx act ref"
1782 " tag=0x%x, exp ref_tag=0x%x, act app tag=0x%x, exp app"
1783 " tag=0x%x, act guard=0x%x, exp guard=0x%x.\n",
1784 cmd
->cmnd
[0], (u64
)scsi_get_lba(cmd
), a_ref_tag
, e_ref_tag
,
1785 a_app_tag
, e_app_tag
, a_guard
, e_guard
);
1789 * For type 3: ref & app tag is all 'f's
1790 * For type 0,1,2: app tag is all 'f's
1792 if ((a_app_tag
== 0xffff) &&
1793 ((scsi_get_prot_type(cmd
) != SCSI_PROT_DIF_TYPE3
) ||
1794 (a_ref_tag
== 0xffffffff))) {
1795 uint32_t blocks_done
, resid
;
1796 sector_t lba_s
= scsi_get_lba(cmd
);
1798 /* 2TB boundary case covered automatically with this */
1799 blocks_done
= e_ref_tag
- (uint32_t)lba_s
+ 1;
1801 resid
= scsi_bufflen(cmd
) - (blocks_done
*
1802 cmd
->device
->sector_size
);
1804 scsi_set_resid(cmd
, resid
);
1805 cmd
->result
= DID_OK
<< 16;
1807 /* Update protection tag */
1808 if (scsi_prot_sg_count(cmd
)) {
1809 uint32_t i
, j
= 0, k
= 0, num_ent
;
1810 struct scatterlist
*sg
;
1811 struct sd_dif_tuple
*spt
;
1813 /* Patch the corresponding protection tags */
1814 scsi_for_each_prot_sg(cmd
, sg
,
1815 scsi_prot_sg_count(cmd
), i
) {
1816 num_ent
= sg_dma_len(sg
) / 8;
1817 if (k
+ num_ent
< blocks_done
) {
1821 j
= blocks_done
- k
- 1;
1826 if (k
!= blocks_done
) {
1827 ql_log(ql_log_warn
, vha
, 0x302f,
1828 "unexpected tag values tag:lba=%x:%llx)\n",
1829 e_ref_tag
, (unsigned long long)lba_s
);
1833 spt
= page_address(sg_page(sg
)) + sg
->offset
;
1836 spt
->app_tag
= 0xffff;
1837 if (scsi_get_prot_type(cmd
) == SCSI_PROT_DIF_TYPE3
)
1838 spt
->ref_tag
= 0xffffffff;
1845 if (e_guard
!= a_guard
) {
1846 scsi_build_sense_buffer(1, cmd
->sense_buffer
, ILLEGAL_REQUEST
,
1848 set_driver_byte(cmd
, DRIVER_SENSE
);
1849 set_host_byte(cmd
, DID_ABORT
);
1850 cmd
->result
|= SAM_STAT_CHECK_CONDITION
<< 1;
1855 if (e_ref_tag
!= a_ref_tag
) {
1856 scsi_build_sense_buffer(1, cmd
->sense_buffer
, ILLEGAL_REQUEST
,
1858 set_driver_byte(cmd
, DRIVER_SENSE
);
1859 set_host_byte(cmd
, DID_ABORT
);
1860 cmd
->result
|= SAM_STAT_CHECK_CONDITION
<< 1;
1864 /* check appl tag */
1865 if (e_app_tag
!= a_app_tag
) {
1866 scsi_build_sense_buffer(1, cmd
->sense_buffer
, ILLEGAL_REQUEST
,
1868 set_driver_byte(cmd
, DRIVER_SENSE
);
1869 set_host_byte(cmd
, DID_ABORT
);
1870 cmd
->result
|= SAM_STAT_CHECK_CONDITION
<< 1;
1878 qla25xx_process_bidir_status_iocb(scsi_qla_host_t
*vha
, void *pkt
,
1879 struct req_que
*req
, uint32_t index
)
1881 struct qla_hw_data
*ha
= vha
->hw
;
1883 uint16_t comp_status
;
1884 uint16_t scsi_status
;
1886 uint32_t rval
= EXT_STATUS_OK
;
1887 struct fc_bsg_job
*bsg_job
= NULL
;
1889 struct sts_entry_24xx
*sts24
;
1890 sts
= (sts_entry_t
*) pkt
;
1891 sts24
= (struct sts_entry_24xx
*) pkt
;
1893 /* Validate handle. */
1894 if (index
>= req
->num_outstanding_cmds
) {
1895 ql_log(ql_log_warn
, vha
, 0x70af,
1896 "Invalid SCSI completion handle 0x%x.\n", index
);
1897 set_bit(ISP_ABORT_NEEDED
, &vha
->dpc_flags
);
1901 sp
= req
->outstanding_cmds
[index
];
1903 /* Free outstanding command slot. */
1904 req
->outstanding_cmds
[index
] = NULL
;
1905 bsg_job
= sp
->u
.bsg_job
;
1907 ql_log(ql_log_warn
, vha
, 0x70b0,
1908 "Req:%d: Invalid ISP SCSI completion handle(0x%x)\n",
1911 set_bit(ISP_ABORT_NEEDED
, &vha
->dpc_flags
);
1915 if (IS_FWI2_CAPABLE(ha
)) {
1916 comp_status
= le16_to_cpu(sts24
->comp_status
);
1917 scsi_status
= le16_to_cpu(sts24
->scsi_status
) & SS_MASK
;
1919 comp_status
= le16_to_cpu(sts
->comp_status
);
1920 scsi_status
= le16_to_cpu(sts
->scsi_status
) & SS_MASK
;
1923 thread_id
= bsg_job
->request
->rqst_data
.h_vendor
.vendor_cmd
[1];
1924 switch (comp_status
) {
1926 if (scsi_status
== 0) {
1927 bsg_job
->reply
->reply_payload_rcv_len
=
1928 bsg_job
->reply_payload
.payload_len
;
1929 vha
->qla_stats
.input_bytes
+=
1930 bsg_job
->reply
->reply_payload_rcv_len
;
1931 vha
->qla_stats
.input_requests
++;
1932 rval
= EXT_STATUS_OK
;
1936 case CS_DATA_OVERRUN
:
1937 ql_dbg(ql_dbg_user
, vha
, 0x70b1,
1938 "Command completed with date overrun thread_id=%d\n",
1940 rval
= EXT_STATUS_DATA_OVERRUN
;
1943 case CS_DATA_UNDERRUN
:
1944 ql_dbg(ql_dbg_user
, vha
, 0x70b2,
1945 "Command completed with date underrun thread_id=%d\n",
1947 rval
= EXT_STATUS_DATA_UNDERRUN
;
1949 case CS_BIDIR_RD_OVERRUN
:
1950 ql_dbg(ql_dbg_user
, vha
, 0x70b3,
1951 "Command completed with read data overrun thread_id=%d\n",
1953 rval
= EXT_STATUS_DATA_OVERRUN
;
1956 case CS_BIDIR_RD_WR_OVERRUN
:
1957 ql_dbg(ql_dbg_user
, vha
, 0x70b4,
1958 "Command completed with read and write data overrun "
1959 "thread_id=%d\n", thread_id
);
1960 rval
= EXT_STATUS_DATA_OVERRUN
;
1963 case CS_BIDIR_RD_OVERRUN_WR_UNDERRUN
:
1964 ql_dbg(ql_dbg_user
, vha
, 0x70b5,
1965 "Command completed with read data over and write data "
1966 "underrun thread_id=%d\n", thread_id
);
1967 rval
= EXT_STATUS_DATA_OVERRUN
;
1970 case CS_BIDIR_RD_UNDERRUN
:
1971 ql_dbg(ql_dbg_user
, vha
, 0x70b6,
1972 "Command completed with read data data underrun "
1973 "thread_id=%d\n", thread_id
);
1974 rval
= EXT_STATUS_DATA_UNDERRUN
;
1977 case CS_BIDIR_RD_UNDERRUN_WR_OVERRUN
:
1978 ql_dbg(ql_dbg_user
, vha
, 0x70b7,
1979 "Command completed with read data under and write data "
1980 "overrun thread_id=%d\n", thread_id
);
1981 rval
= EXT_STATUS_DATA_UNDERRUN
;
1984 case CS_BIDIR_RD_WR_UNDERRUN
:
1985 ql_dbg(ql_dbg_user
, vha
, 0x70b8,
1986 "Command completed with read and write data underrun "
1987 "thread_id=%d\n", thread_id
);
1988 rval
= EXT_STATUS_DATA_UNDERRUN
;
1992 ql_dbg(ql_dbg_user
, vha
, 0x70b9,
1993 "Command completed with data DMA error thread_id=%d\n",
1995 rval
= EXT_STATUS_DMA_ERR
;
1999 ql_dbg(ql_dbg_user
, vha
, 0x70ba,
2000 "Command completed with timeout thread_id=%d\n",
2002 rval
= EXT_STATUS_TIMEOUT
;
2005 ql_dbg(ql_dbg_user
, vha
, 0x70bb,
2006 "Command completed with completion status=0x%x "
2007 "thread_id=%d\n", comp_status
, thread_id
);
2008 rval
= EXT_STATUS_ERR
;
2011 bsg_job
->reply
->reply_payload_rcv_len
= 0;
2014 /* Return the vendor specific reply to API */
2015 bsg_job
->reply
->reply_data
.vendor_reply
.vendor_rsp
[0] = rval
;
2016 bsg_job
->reply_len
= sizeof(struct fc_bsg_reply
);
2017 /* Always return DID_OK, bsg will send the vendor specific response
2018 * in this case only */
2019 sp
->done(vha
, sp
, (DID_OK
<< 6));
2024 * qla2x00_status_entry() - Process a Status IOCB entry.
2025 * @ha: SCSI driver HA context
2026 * @pkt: Entry pointer
2029 qla2x00_status_entry(scsi_qla_host_t
*vha
, struct rsp_que
*rsp
, void *pkt
)
2033 struct scsi_cmnd
*cp
;
2035 struct sts_entry_24xx
*sts24
;
2036 uint16_t comp_status
;
2037 uint16_t scsi_status
;
2039 uint8_t lscsi_status
;
2041 uint32_t sense_len
, par_sense_len
, rsp_info_len
, resid_len
,
2043 uint8_t *rsp_info
, *sense_data
;
2044 struct qla_hw_data
*ha
= vha
->hw
;
2047 struct req_que
*req
;
2050 uint16_t state_flags
= 0;
2051 uint16_t retry_delay
= 0;
2053 sts
= (sts_entry_t
*) pkt
;
2054 sts24
= (struct sts_entry_24xx
*) pkt
;
2055 if (IS_FWI2_CAPABLE(ha
)) {
2056 comp_status
= le16_to_cpu(sts24
->comp_status
);
2057 scsi_status
= le16_to_cpu(sts24
->scsi_status
) & SS_MASK
;
2058 state_flags
= le16_to_cpu(sts24
->state_flags
);
2060 comp_status
= le16_to_cpu(sts
->comp_status
);
2061 scsi_status
= le16_to_cpu(sts
->scsi_status
) & SS_MASK
;
2063 handle
= (uint32_t) LSW(sts
->handle
);
2064 que
= MSW(sts
->handle
);
2065 req
= ha
->req_q_map
[que
];
2067 /* Check for invalid queue pointer */
2069 que
>= find_first_zero_bit(ha
->req_qid_map
, ha
->max_req_queues
)) {
2070 ql_dbg(ql_dbg_io
, vha
, 0x3059,
2071 "Invalid status handle (0x%x): Bad req pointer. req=%p, "
2072 "que=%u.\n", sts
->handle
, req
, que
);
2076 /* Validate handle. */
2077 if (handle
< req
->num_outstanding_cmds
) {
2078 sp
= req
->outstanding_cmds
[handle
];
2080 ql_dbg(ql_dbg_io
, vha
, 0x3075,
2081 "%s(%ld): Already returned command for status handle (0x%x).\n",
2082 __func__
, vha
->host_no
, sts
->handle
);
2086 ql_dbg(ql_dbg_io
, vha
, 0x3017,
2087 "Invalid status handle, out of range (0x%x).\n",
2090 if (!test_bit(ABORT_ISP_ACTIVE
, &vha
->dpc_flags
)) {
2091 if (IS_P3P_TYPE(ha
))
2092 set_bit(FCOE_CTX_RESET_NEEDED
, &vha
->dpc_flags
);
2094 set_bit(ISP_ABORT_NEEDED
, &vha
->dpc_flags
);
2095 qla2xxx_wake_dpc(vha
);
2100 if (unlikely((state_flags
& BIT_1
) && (sp
->type
== SRB_BIDI_CMD
))) {
2101 qla25xx_process_bidir_status_iocb(vha
, pkt
, req
, handle
);
2105 /* Task Management completion. */
2106 if (sp
->type
== SRB_TM_CMD
) {
2107 qla24xx_tm_iocb_entry(vha
, req
, pkt
);
2111 /* Fast path completion. */
2112 if (comp_status
== CS_COMPLETE
&& scsi_status
== 0) {
2113 qla2x00_process_completed_request(vha
, req
, handle
);
2118 req
->outstanding_cmds
[handle
] = NULL
;
2119 cp
= GET_CMD_SP(sp
);
2121 ql_dbg(ql_dbg_io
, vha
, 0x3018,
2122 "Command already returned (0x%x/%p).\n",
2128 lscsi_status
= scsi_status
& STATUS_MASK
;
2130 fcport
= sp
->fcport
;
2133 sense_len
= par_sense_len
= rsp_info_len
= resid_len
=
2135 if (IS_FWI2_CAPABLE(ha
)) {
2136 if (scsi_status
& SS_SENSE_LEN_VALID
)
2137 sense_len
= le32_to_cpu(sts24
->sense_len
);
2138 if (scsi_status
& SS_RESPONSE_INFO_LEN_VALID
)
2139 rsp_info_len
= le32_to_cpu(sts24
->rsp_data_len
);
2140 if (scsi_status
& (SS_RESIDUAL_UNDER
| SS_RESIDUAL_OVER
))
2141 resid_len
= le32_to_cpu(sts24
->rsp_residual_count
);
2142 if (comp_status
== CS_DATA_UNDERRUN
)
2143 fw_resid_len
= le32_to_cpu(sts24
->residual_len
);
2144 rsp_info
= sts24
->data
;
2145 sense_data
= sts24
->data
;
2146 host_to_fcp_swap(sts24
->data
, sizeof(sts24
->data
));
2147 ox_id
= le16_to_cpu(sts24
->ox_id
);
2148 par_sense_len
= sizeof(sts24
->data
);
2149 /* Valid values of the retry delay timer are 0x1-0xffef */
2150 if (sts24
->retry_delay
> 0 && sts24
->retry_delay
< 0xfff1)
2151 retry_delay
= sts24
->retry_delay
;
2153 if (scsi_status
& SS_SENSE_LEN_VALID
)
2154 sense_len
= le16_to_cpu(sts
->req_sense_length
);
2155 if (scsi_status
& SS_RESPONSE_INFO_LEN_VALID
)
2156 rsp_info_len
= le16_to_cpu(sts
->rsp_info_len
);
2157 resid_len
= le32_to_cpu(sts
->residual_length
);
2158 rsp_info
= sts
->rsp_info
;
2159 sense_data
= sts
->req_sense_data
;
2160 par_sense_len
= sizeof(sts
->req_sense_data
);
2163 /* Check for any FCP transport errors. */
2164 if (scsi_status
& SS_RESPONSE_INFO_LEN_VALID
) {
2165 /* Sense data lies beyond any FCP RESPONSE data. */
2166 if (IS_FWI2_CAPABLE(ha
)) {
2167 sense_data
+= rsp_info_len
;
2168 par_sense_len
-= rsp_info_len
;
2170 if (rsp_info_len
> 3 && rsp_info
[3]) {
2171 ql_dbg(ql_dbg_io
, fcport
->vha
, 0x3019,
2172 "FCP I/O protocol failure (0x%x/0x%x).\n",
2173 rsp_info_len
, rsp_info
[3]);
2175 res
= DID_BUS_BUSY
<< 16;
2180 /* Check for overrun. */
2181 if (IS_FWI2_CAPABLE(ha
) && comp_status
== CS_COMPLETE
&&
2182 scsi_status
& SS_RESIDUAL_OVER
)
2183 comp_status
= CS_DATA_OVERRUN
;
2186 * Check retry_delay_timer value if we receive a busy or
2189 if (lscsi_status
== SAM_STAT_TASK_SET_FULL
||
2190 lscsi_status
== SAM_STAT_BUSY
)
2191 qla2x00_set_retry_delay_timestamp(fcport
, retry_delay
);
2194 * Based on Host and scsi status generate status code for Linux
2196 switch (comp_status
) {
2199 if (scsi_status
== 0) {
2203 if (scsi_status
& (SS_RESIDUAL_UNDER
| SS_RESIDUAL_OVER
)) {
2205 scsi_set_resid(cp
, resid
);
2207 if (!lscsi_status
&&
2208 ((unsigned)(scsi_bufflen(cp
) - resid
) <
2210 ql_dbg(ql_dbg_io
, fcport
->vha
, 0x301a,
2211 "Mid-layer underflow "
2212 "detected (0x%x of 0x%x bytes).\n",
2213 resid
, scsi_bufflen(cp
));
2215 res
= DID_ERROR
<< 16;
2219 res
= DID_OK
<< 16 | lscsi_status
;
2221 if (lscsi_status
== SAM_STAT_TASK_SET_FULL
) {
2222 ql_dbg(ql_dbg_io
, fcport
->vha
, 0x301b,
2223 "QUEUE FULL detected.\n");
2227 if (lscsi_status
!= SS_CHECK_CONDITION
)
2230 memset(cp
->sense_buffer
, 0, SCSI_SENSE_BUFFERSIZE
);
2231 if (!(scsi_status
& SS_SENSE_LEN_VALID
))
2234 qla2x00_handle_sense(sp
, sense_data
, par_sense_len
, sense_len
,
2238 case CS_DATA_UNDERRUN
:
2239 /* Use F/W calculated residual length. */
2240 resid
= IS_FWI2_CAPABLE(ha
) ? fw_resid_len
: resid_len
;
2241 scsi_set_resid(cp
, resid
);
2242 if (scsi_status
& SS_RESIDUAL_UNDER
) {
2243 if (IS_FWI2_CAPABLE(ha
) && fw_resid_len
!= resid_len
) {
2244 ql_dbg(ql_dbg_io
, fcport
->vha
, 0x301d,
2245 "Dropped frame(s) detected "
2246 "(0x%x of 0x%x bytes).\n",
2247 resid
, scsi_bufflen(cp
));
2249 res
= DID_ERROR
<< 16 | lscsi_status
;
2250 goto check_scsi_status
;
2253 if (!lscsi_status
&&
2254 ((unsigned)(scsi_bufflen(cp
) - resid
) <
2256 ql_dbg(ql_dbg_io
, fcport
->vha
, 0x301e,
2257 "Mid-layer underflow "
2258 "detected (0x%x of 0x%x bytes).\n",
2259 resid
, scsi_bufflen(cp
));
2261 res
= DID_ERROR
<< 16;
2264 } else if (lscsi_status
!= SAM_STAT_TASK_SET_FULL
&&
2265 lscsi_status
!= SAM_STAT_BUSY
) {
2267 * scsi status of task set and busy are considered to be
2268 * task not completed.
2271 ql_dbg(ql_dbg_io
, fcport
->vha
, 0x301f,
2272 "Dropped frame(s) detected (0x%x "
2273 "of 0x%x bytes).\n", resid
,
2276 res
= DID_ERROR
<< 16 | lscsi_status
;
2277 goto check_scsi_status
;
2279 ql_dbg(ql_dbg_io
, fcport
->vha
, 0x3030,
2280 "scsi_status: 0x%x, lscsi_status: 0x%x\n",
2281 scsi_status
, lscsi_status
);
2284 res
= DID_OK
<< 16 | lscsi_status
;
2289 * Check to see if SCSI Status is non zero. If so report SCSI
2292 if (lscsi_status
!= 0) {
2293 if (lscsi_status
== SAM_STAT_TASK_SET_FULL
) {
2294 ql_dbg(ql_dbg_io
, fcport
->vha
, 0x3020,
2295 "QUEUE FULL detected.\n");
2299 if (lscsi_status
!= SS_CHECK_CONDITION
)
2302 memset(cp
->sense_buffer
, 0, SCSI_SENSE_BUFFERSIZE
);
2303 if (!(scsi_status
& SS_SENSE_LEN_VALID
))
2306 qla2x00_handle_sense(sp
, sense_data
, par_sense_len
,
2307 sense_len
, rsp
, res
);
2311 case CS_PORT_LOGGED_OUT
:
2312 case CS_PORT_CONFIG_CHG
:
2315 case CS_PORT_UNAVAILABLE
:
2320 * We are going to have the fc class block the rport
2321 * while we try to recover so instruct the mid layer
2322 * to requeue until the class decides how to handle this.
2324 res
= DID_TRANSPORT_DISRUPTED
<< 16;
2326 if (comp_status
== CS_TIMEOUT
) {
2327 if (IS_FWI2_CAPABLE(ha
))
2329 else if ((le16_to_cpu(sts
->status_flags
) &
2330 SF_LOGOUT_SENT
) == 0)
2334 ql_dbg(ql_dbg_io
, fcport
->vha
, 0x3021,
2335 "Port to be marked lost on fcport=%02x%02x%02x, current "
2336 "port state= %s.\n", fcport
->d_id
.b
.domain
,
2337 fcport
->d_id
.b
.area
, fcport
->d_id
.b
.al_pa
,
2338 port_state_str
[atomic_read(&fcport
->state
)]);
2340 if (atomic_read(&fcport
->state
) == FCS_ONLINE
)
2341 qla2x00_mark_device_lost(fcport
->vha
, fcport
, 1, 1);
2345 res
= DID_RESET
<< 16;
2349 logit
= qla2x00_handle_dif_error(sp
, sts24
);
2354 res
= DID_ERROR
<< 16;
2356 if (!IS_PI_SPLIT_DET_CAPABLE(ha
))
2359 if (state_flags
& BIT_4
)
2360 scmd_printk(KERN_WARNING
, cp
,
2361 "Unsupported device '%s' found.\n",
2362 cp
->device
->vendor
);
2366 res
= DID_ERROR
<< 16;
2372 ql_dbg(ql_dbg_io
, fcport
->vha
, 0x3022,
2373 "FCP command status: 0x%x-0x%x (0x%x) nexus=%ld:%d:%llu "
2374 "portid=%02x%02x%02x oxid=0x%x cdb=%10phN len=0x%x "
2375 "rsp_info=0x%x resid=0x%x fw_resid=0x%x sp=%p cp=%p.\n",
2376 comp_status
, scsi_status
, res
, vha
->host_no
,
2377 cp
->device
->id
, cp
->device
->lun
, fcport
->d_id
.b
.domain
,
2378 fcport
->d_id
.b
.area
, fcport
->d_id
.b
.al_pa
, ox_id
,
2379 cp
->cmnd
, scsi_bufflen(cp
), rsp_info_len
,
2380 resid_len
, fw_resid_len
, sp
, cp
);
2382 if (rsp
->status_srb
== NULL
)
2383 sp
->done(ha
, sp
, res
);
2387 * qla2x00_status_cont_entry() - Process a Status Continuations entry.
2388 * @ha: SCSI driver HA context
2389 * @pkt: Entry pointer
2391 * Extended sense data.
2394 qla2x00_status_cont_entry(struct rsp_que
*rsp
, sts_cont_entry_t
*pkt
)
2396 uint8_t sense_sz
= 0;
2397 struct qla_hw_data
*ha
= rsp
->hw
;
2398 struct scsi_qla_host
*vha
= pci_get_drvdata(ha
->pdev
);
2399 srb_t
*sp
= rsp
->status_srb
;
2400 struct scsi_cmnd
*cp
;
2404 if (!sp
|| !GET_CMD_SENSE_LEN(sp
))
2407 sense_len
= GET_CMD_SENSE_LEN(sp
);
2408 sense_ptr
= GET_CMD_SENSE_PTR(sp
);
2410 cp
= GET_CMD_SP(sp
);
2412 ql_log(ql_log_warn
, vha
, 0x3025,
2413 "cmd is NULL: already returned to OS (sp=%p).\n", sp
);
2415 rsp
->status_srb
= NULL
;
2419 if (sense_len
> sizeof(pkt
->data
))
2420 sense_sz
= sizeof(pkt
->data
);
2422 sense_sz
= sense_len
;
2424 /* Move sense data. */
2425 if (IS_FWI2_CAPABLE(ha
))
2426 host_to_fcp_swap(pkt
->data
, sizeof(pkt
->data
));
2427 memcpy(sense_ptr
, pkt
->data
, sense_sz
);
2428 ql_dump_buffer(ql_dbg_io
+ ql_dbg_buffer
, vha
, 0x302c,
2429 sense_ptr
, sense_sz
);
2431 sense_len
-= sense_sz
;
2432 sense_ptr
+= sense_sz
;
2434 SET_CMD_SENSE_PTR(sp
, sense_ptr
);
2435 SET_CMD_SENSE_LEN(sp
, sense_len
);
2437 /* Place command on done queue. */
2438 if (sense_len
== 0) {
2439 rsp
->status_srb
= NULL
;
2440 sp
->done(ha
, sp
, cp
->result
);
2445 * qla2x00_error_entry() - Process an error entry.
2446 * @ha: SCSI driver HA context
2447 * @pkt: Entry pointer
2450 qla2x00_error_entry(scsi_qla_host_t
*vha
, struct rsp_que
*rsp
, sts_entry_t
*pkt
)
2453 struct qla_hw_data
*ha
= vha
->hw
;
2454 const char func
[] = "ERROR-IOCB";
2455 uint16_t que
= MSW(pkt
->handle
);
2456 struct req_que
*req
= NULL
;
2457 int res
= DID_ERROR
<< 16;
2459 ql_dbg(ql_dbg_async
, vha
, 0x502a,
2460 "type of error status in response: 0x%x\n", pkt
->entry_status
);
2462 if (que
>= ha
->max_req_queues
|| !ha
->req_q_map
[que
])
2465 req
= ha
->req_q_map
[que
];
2467 if (pkt
->entry_status
& RF_BUSY
)
2468 res
= DID_BUS_BUSY
<< 16;
2470 if (pkt
->entry_type
== NOTIFY_ACK_TYPE
&&
2471 pkt
->handle
== QLA_TGT_SKIP_HANDLE
)
2474 sp
= qla2x00_get_sp_from_handle(vha
, func
, req
, pkt
);
2476 sp
->done(ha
, sp
, res
);
2480 ql_log(ql_log_warn
, vha
, 0x5030,
2481 "Error entry - invalid handle/queue (%04x).\n", que
);
2485 * qla24xx_mbx_completion() - Process mailbox command completions.
2486 * @ha: SCSI driver HA context
2487 * @mb0: Mailbox0 register
2490 qla24xx_mbx_completion(scsi_qla_host_t
*vha
, uint16_t mb0
)
2494 uint16_t __iomem
*wptr
;
2495 struct qla_hw_data
*ha
= vha
->hw
;
2496 struct device_reg_24xx __iomem
*reg
= &ha
->iobase
->isp24
;
2498 /* Read all mbox registers? */
2499 WARN_ON_ONCE(ha
->mbx_count
> 32);
2500 mboxes
= (1ULL << ha
->mbx_count
) - 1;
2502 ql_dbg(ql_dbg_async
, vha
, 0x504e, "MBX pointer ERROR.\n");
2504 mboxes
= ha
->mcp
->in_mb
;
2506 /* Load return mailbox registers. */
2507 ha
->flags
.mbox_int
= 1;
2508 ha
->mailbox_out
[0] = mb0
;
2510 wptr
= (uint16_t __iomem
*)®
->mailbox1
;
2512 for (cnt
= 1; cnt
< ha
->mbx_count
; cnt
++) {
2514 ha
->mailbox_out
[cnt
] = RD_REG_WORD(wptr
);
2522 qla24xx_abort_iocb_entry(scsi_qla_host_t
*vha
, struct req_que
*req
,
2523 struct abort_entry_24xx
*pkt
)
2525 const char func
[] = "ABT_IOCB";
2527 struct srb_iocb
*abt
;
2529 sp
= qla2x00_get_sp_from_handle(vha
, func
, req
, pkt
);
2533 abt
= &sp
->u
.iocb_cmd
;
2534 abt
->u
.abt
.comp_status
= le32_to_cpu(pkt
->nport_handle
);
2535 sp
->done(vha
, sp
, 0);
2539 * qla24xx_process_response_queue() - Process response queue entries.
2540 * @ha: SCSI driver HA context
2542 void qla24xx_process_response_queue(struct scsi_qla_host
*vha
,
2543 struct rsp_que
*rsp
)
2545 struct sts_entry_24xx
*pkt
;
2546 struct qla_hw_data
*ha
= vha
->hw
;
2548 if (!vha
->flags
.online
)
2551 while (rsp
->ring_ptr
->signature
!= RESPONSE_PROCESSED
) {
2552 pkt
= (struct sts_entry_24xx
*)rsp
->ring_ptr
;
2555 if (rsp
->ring_index
== rsp
->length
) {
2556 rsp
->ring_index
= 0;
2557 rsp
->ring_ptr
= rsp
->ring
;
2562 if (pkt
->entry_status
!= 0) {
2563 qla2x00_error_entry(vha
, rsp
, (sts_entry_t
*) pkt
);
2565 if (qlt_24xx_process_response_error(vha
, pkt
))
2568 ((response_t
*)pkt
)->signature
= RESPONSE_PROCESSED
;
2574 switch (pkt
->entry_type
) {
2576 qla2x00_status_entry(vha
, rsp
, pkt
);
2578 case STATUS_CONT_TYPE
:
2579 qla2x00_status_cont_entry(rsp
, (sts_cont_entry_t
*)pkt
);
2581 case VP_RPT_ID_IOCB_TYPE
:
2582 qla24xx_report_id_acquisition(vha
,
2583 (struct vp_rpt_id_entry_24xx
*)pkt
);
2585 case LOGINOUT_PORT_IOCB_TYPE
:
2586 qla24xx_logio_entry(vha
, rsp
->req
,
2587 (struct logio_entry_24xx
*)pkt
);
2590 qla24xx_els_ct_entry(vha
, rsp
->req
, pkt
, CT_IOCB_TYPE
);
2593 qla24xx_els_ct_entry(vha
, rsp
->req
, pkt
, ELS_IOCB_TYPE
);
2595 case ABTS_RECV_24XX
:
2596 /* ensure that the ATIO queue is empty */
2597 qlt_24xx_process_atio_queue(vha
);
2598 case ABTS_RESP_24XX
:
2600 case NOTIFY_ACK_TYPE
:
2602 qlt_response_pkt_all_vps(vha
, (response_t
*)pkt
);
2605 /* Do nothing in this case, this check is to prevent it
2606 * from falling into default case
2609 case ABORT_IOCB_TYPE
:
2610 qla24xx_abort_iocb_entry(vha
, rsp
->req
,
2611 (struct abort_entry_24xx
*)pkt
);
2614 /* Type Not Supported. */
2615 ql_dbg(ql_dbg_async
, vha
, 0x5042,
2616 "Received unknown response pkt type %x "
2617 "entry status=%x.\n",
2618 pkt
->entry_type
, pkt
->entry_status
);
2621 ((response_t
*)pkt
)->signature
= RESPONSE_PROCESSED
;
2625 /* Adjust ring index */
2626 if (IS_P3P_TYPE(ha
)) {
2627 struct device_reg_82xx __iomem
*reg
= &ha
->iobase
->isp82
;
2628 WRT_REG_DWORD(®
->rsp_q_out
[0], rsp
->ring_index
);
2630 WRT_REG_DWORD(rsp
->rsp_q_out
, rsp
->ring_index
);
2634 qla2xxx_check_risc_status(scsi_qla_host_t
*vha
)
2638 struct qla_hw_data
*ha
= vha
->hw
;
2639 struct device_reg_24xx __iomem
*reg
= &ha
->iobase
->isp24
;
2641 if (!IS_QLA25XX(ha
) && !IS_QLA81XX(ha
) && !IS_QLA83XX(ha
) &&
2646 WRT_REG_DWORD(®
->iobase_addr
, 0x7C00);
2647 RD_REG_DWORD(®
->iobase_addr
);
2648 WRT_REG_DWORD(®
->iobase_window
, 0x0001);
2649 for (cnt
= 10000; (RD_REG_DWORD(®
->iobase_window
) & BIT_0
) == 0 &&
2650 rval
== QLA_SUCCESS
; cnt
--) {
2652 WRT_REG_DWORD(®
->iobase_window
, 0x0001);
2655 rval
= QLA_FUNCTION_TIMEOUT
;
2657 if (rval
== QLA_SUCCESS
)
2661 WRT_REG_DWORD(®
->iobase_window
, 0x0003);
2662 for (cnt
= 100; (RD_REG_DWORD(®
->iobase_window
) & BIT_0
) == 0 &&
2663 rval
== QLA_SUCCESS
; cnt
--) {
2665 WRT_REG_DWORD(®
->iobase_window
, 0x0003);
2668 rval
= QLA_FUNCTION_TIMEOUT
;
2670 if (rval
!= QLA_SUCCESS
)
2674 if (RD_REG_DWORD(®
->iobase_c8
) & BIT_3
)
2675 ql_log(ql_log_info
, vha
, 0x504c,
2676 "Additional code -- 0x55AA.\n");
2679 WRT_REG_DWORD(®
->iobase_window
, 0x0000);
2680 RD_REG_DWORD(®
->iobase_window
);
2684 * qla24xx_intr_handler() - Process interrupts for the ISP23xx and ISP24xx.
2686 * @dev_id: SCSI driver HA context
2688 * Called by system whenever the host adapter generates an interrupt.
2690 * Returns handled flag.
2693 qla24xx_intr_handler(int irq
, void *dev_id
)
2695 scsi_qla_host_t
*vha
;
2696 struct qla_hw_data
*ha
;
2697 struct device_reg_24xx __iomem
*reg
;
2703 struct rsp_que
*rsp
;
2704 unsigned long flags
;
2706 rsp
= (struct rsp_que
*) dev_id
;
2708 ql_log(ql_log_info
, NULL
, 0x5059,
2709 "%s: NULL response queue pointer.\n", __func__
);
2714 reg
= &ha
->iobase
->isp24
;
2717 if (unlikely(pci_channel_offline(ha
->pdev
)))
2720 spin_lock_irqsave(&ha
->hardware_lock
, flags
);
2721 vha
= pci_get_drvdata(ha
->pdev
);
2722 for (iter
= 50; iter
--; ) {
2723 stat
= RD_REG_DWORD(®
->host_status
);
2724 if (qla2x00_check_reg32_for_disconnect(vha
, stat
))
2726 if (stat
& HSRX_RISC_PAUSED
) {
2727 if (unlikely(pci_channel_offline(ha
->pdev
)))
2730 hccr
= RD_REG_DWORD(®
->hccr
);
2732 ql_log(ql_log_warn
, vha
, 0x504b,
2733 "RISC paused -- HCCR=%x, Dumping firmware.\n",
2736 qla2xxx_check_risc_status(vha
);
2738 ha
->isp_ops
->fw_dump(vha
, 1);
2739 set_bit(ISP_ABORT_NEEDED
, &vha
->dpc_flags
);
2741 } else if ((stat
& HSRX_RISC_INT
) == 0)
2744 switch (stat
& 0xff) {
2745 case INTR_ROM_MB_SUCCESS
:
2746 case INTR_ROM_MB_FAILED
:
2747 case INTR_MB_SUCCESS
:
2748 case INTR_MB_FAILED
:
2749 qla24xx_mbx_completion(vha
, MSW(stat
));
2750 status
|= MBX_INTERRUPT
;
2753 case INTR_ASYNC_EVENT
:
2755 mb
[1] = RD_REG_WORD(®
->mailbox1
);
2756 mb
[2] = RD_REG_WORD(®
->mailbox2
);
2757 mb
[3] = RD_REG_WORD(®
->mailbox3
);
2758 qla2x00_async_event(vha
, rsp
, mb
);
2760 case INTR_RSP_QUE_UPDATE
:
2761 case INTR_RSP_QUE_UPDATE_83XX
:
2762 qla24xx_process_response_queue(vha
, rsp
);
2764 case INTR_ATIO_QUE_UPDATE
:
2765 qlt_24xx_process_atio_queue(vha
);
2767 case INTR_ATIO_RSP_QUE_UPDATE
:
2768 qlt_24xx_process_atio_queue(vha
);
2769 qla24xx_process_response_queue(vha
, rsp
);
2772 ql_dbg(ql_dbg_async
, vha
, 0x504f,
2773 "Unrecognized interrupt type (%d).\n", stat
* 0xff);
2776 WRT_REG_DWORD(®
->hccr
, HCCRX_CLR_RISC_INT
);
2777 RD_REG_DWORD_RELAXED(®
->hccr
);
2778 if (unlikely(IS_QLA83XX(ha
) && (ha
->pdev
->revision
== 1)))
2781 qla2x00_handle_mbx_completion(ha
, status
);
2782 spin_unlock_irqrestore(&ha
->hardware_lock
, flags
);
2788 qla24xx_msix_rsp_q(int irq
, void *dev_id
)
2790 struct qla_hw_data
*ha
;
2791 struct rsp_que
*rsp
;
2792 struct device_reg_24xx __iomem
*reg
;
2793 struct scsi_qla_host
*vha
;
2794 unsigned long flags
;
2797 rsp
= (struct rsp_que
*) dev_id
;
2799 ql_log(ql_log_info
, NULL
, 0x505a,
2800 "%s: NULL response queue pointer.\n", __func__
);
2804 reg
= &ha
->iobase
->isp24
;
2806 spin_lock_irqsave(&ha
->hardware_lock
, flags
);
2808 vha
= pci_get_drvdata(ha
->pdev
);
2810 * Use host_status register to check to PCI disconnection before we
2811 * we process the response queue.
2813 stat
= RD_REG_DWORD(®
->host_status
);
2814 if (qla2x00_check_reg32_for_disconnect(vha
, stat
))
2816 qla24xx_process_response_queue(vha
, rsp
);
2817 if (!ha
->flags
.disable_msix_handshake
) {
2818 WRT_REG_DWORD(®
->hccr
, HCCRX_CLR_RISC_INT
);
2819 RD_REG_DWORD_RELAXED(®
->hccr
);
2822 spin_unlock_irqrestore(&ha
->hardware_lock
, flags
);
2828 qla25xx_msix_rsp_q(int irq
, void *dev_id
)
2830 struct qla_hw_data
*ha
;
2831 scsi_qla_host_t
*vha
;
2832 struct rsp_que
*rsp
;
2833 struct device_reg_24xx __iomem
*reg
;
2834 unsigned long flags
;
2837 rsp
= (struct rsp_que
*) dev_id
;
2839 ql_log(ql_log_info
, NULL
, 0x505b,
2840 "%s: NULL response queue pointer.\n", __func__
);
2844 vha
= pci_get_drvdata(ha
->pdev
);
2846 /* Clear the interrupt, if enabled, for this response queue */
2847 if (!ha
->flags
.disable_msix_handshake
) {
2848 reg
= &ha
->iobase
->isp24
;
2849 spin_lock_irqsave(&ha
->hardware_lock
, flags
);
2850 WRT_REG_DWORD(®
->hccr
, HCCRX_CLR_RISC_INT
);
2851 hccr
= RD_REG_DWORD_RELAXED(®
->hccr
);
2852 spin_unlock_irqrestore(&ha
->hardware_lock
, flags
);
2854 if (qla2x00_check_reg32_for_disconnect(vha
, hccr
))
2856 queue_work_on((int) (rsp
->id
- 1), ha
->wq
, &rsp
->q_work
);
2863 qla24xx_msix_default(int irq
, void *dev_id
)
2865 scsi_qla_host_t
*vha
;
2866 struct qla_hw_data
*ha
;
2867 struct rsp_que
*rsp
;
2868 struct device_reg_24xx __iomem
*reg
;
2873 unsigned long flags
;
2875 rsp
= (struct rsp_que
*) dev_id
;
2877 ql_log(ql_log_info
, NULL
, 0x505c,
2878 "%s: NULL response queue pointer.\n", __func__
);
2882 reg
= &ha
->iobase
->isp24
;
2885 spin_lock_irqsave(&ha
->hardware_lock
, flags
);
2886 vha
= pci_get_drvdata(ha
->pdev
);
2888 stat
= RD_REG_DWORD(®
->host_status
);
2889 if (qla2x00_check_reg32_for_disconnect(vha
, stat
))
2891 if (stat
& HSRX_RISC_PAUSED
) {
2892 if (unlikely(pci_channel_offline(ha
->pdev
)))
2895 hccr
= RD_REG_DWORD(®
->hccr
);
2897 ql_log(ql_log_info
, vha
, 0x5050,
2898 "RISC paused -- HCCR=%x, Dumping firmware.\n",
2901 qla2xxx_check_risc_status(vha
);
2903 ha
->isp_ops
->fw_dump(vha
, 1);
2904 set_bit(ISP_ABORT_NEEDED
, &vha
->dpc_flags
);
2906 } else if ((stat
& HSRX_RISC_INT
) == 0)
2909 switch (stat
& 0xff) {
2910 case INTR_ROM_MB_SUCCESS
:
2911 case INTR_ROM_MB_FAILED
:
2912 case INTR_MB_SUCCESS
:
2913 case INTR_MB_FAILED
:
2914 qla24xx_mbx_completion(vha
, MSW(stat
));
2915 status
|= MBX_INTERRUPT
;
2918 case INTR_ASYNC_EVENT
:
2920 mb
[1] = RD_REG_WORD(®
->mailbox1
);
2921 mb
[2] = RD_REG_WORD(®
->mailbox2
);
2922 mb
[3] = RD_REG_WORD(®
->mailbox3
);
2923 qla2x00_async_event(vha
, rsp
, mb
);
2925 case INTR_RSP_QUE_UPDATE
:
2926 case INTR_RSP_QUE_UPDATE_83XX
:
2927 qla24xx_process_response_queue(vha
, rsp
);
2929 case INTR_ATIO_QUE_UPDATE
:
2930 qlt_24xx_process_atio_queue(vha
);
2932 case INTR_ATIO_RSP_QUE_UPDATE
:
2933 qlt_24xx_process_atio_queue(vha
);
2934 qla24xx_process_response_queue(vha
, rsp
);
2937 ql_dbg(ql_dbg_async
, vha
, 0x5051,
2938 "Unrecognized interrupt type (%d).\n", stat
& 0xff);
2941 WRT_REG_DWORD(®
->hccr
, HCCRX_CLR_RISC_INT
);
2943 qla2x00_handle_mbx_completion(ha
, status
);
2944 spin_unlock_irqrestore(&ha
->hardware_lock
, flags
);
2949 /* Interrupt handling helpers. */
2951 struct qla_init_msix_entry
{
2953 irq_handler_t handler
;
2956 static struct qla_init_msix_entry msix_entries
[3] = {
2957 { "qla2xxx (default)", qla24xx_msix_default
},
2958 { "qla2xxx (rsp_q)", qla24xx_msix_rsp_q
},
2959 { "qla2xxx (multiq)", qla25xx_msix_rsp_q
},
2962 static struct qla_init_msix_entry qla82xx_msix_entries
[2] = {
2963 { "qla2xxx (default)", qla82xx_msix_default
},
2964 { "qla2xxx (rsp_q)", qla82xx_msix_rsp_q
},
2967 static struct qla_init_msix_entry qla83xx_msix_entries
[3] = {
2968 { "qla2xxx (default)", qla24xx_msix_default
},
2969 { "qla2xxx (rsp_q)", qla24xx_msix_rsp_q
},
2970 { "qla2xxx (atio_q)", qla83xx_msix_atio_q
},
2974 qla24xx_disable_msix(struct qla_hw_data
*ha
)
2977 struct qla_msix_entry
*qentry
;
2978 scsi_qla_host_t
*vha
= pci_get_drvdata(ha
->pdev
);
2980 for (i
= 0; i
< ha
->msix_count
; i
++) {
2981 qentry
= &ha
->msix_entries
[i
];
2982 if (qentry
->have_irq
)
2983 free_irq(qentry
->vector
, qentry
->rsp
);
2985 pci_disable_msix(ha
->pdev
);
2986 kfree(ha
->msix_entries
);
2987 ha
->msix_entries
= NULL
;
2988 ha
->flags
.msix_enabled
= 0;
2989 ql_dbg(ql_dbg_init
, vha
, 0x0042,
2990 "Disabled the MSI.\n");
2994 qla24xx_enable_msix(struct qla_hw_data
*ha
, struct rsp_que
*rsp
)
2996 #define MIN_MSIX_COUNT 2
2997 #define ATIO_VECTOR 2
2999 struct msix_entry
*entries
;
3000 struct qla_msix_entry
*qentry
;
3001 scsi_qla_host_t
*vha
= pci_get_drvdata(ha
->pdev
);
3003 entries
= kzalloc(sizeof(struct msix_entry
) * ha
->msix_count
,
3006 ql_log(ql_log_warn
, vha
, 0x00bc,
3007 "Failed to allocate memory for msix_entry.\n");
3011 for (i
= 0; i
< ha
->msix_count
; i
++)
3012 entries
[i
].entry
= i
;
3014 ret
= pci_enable_msix_range(ha
->pdev
,
3015 entries
, MIN_MSIX_COUNT
, ha
->msix_count
);
3017 ql_log(ql_log_fatal
, vha
, 0x00c7,
3018 "MSI-X: Failed to enable support, "
3019 "giving up -- %d/%d.\n",
3020 ha
->msix_count
, ret
);
3022 } else if (ret
< ha
->msix_count
) {
3023 ql_log(ql_log_warn
, vha
, 0x00c6,
3024 "MSI-X: Failed to enable support "
3025 "-- %d/%d\n Retry with %d vectors.\n",
3026 ha
->msix_count
, ret
, ret
);
3027 ha
->msix_count
= ret
;
3028 ha
->max_rsp_queues
= ha
->msix_count
- 1;
3030 ha
->msix_entries
= kzalloc(sizeof(struct qla_msix_entry
) *
3031 ha
->msix_count
, GFP_KERNEL
);
3032 if (!ha
->msix_entries
) {
3033 ql_log(ql_log_fatal
, vha
, 0x00c8,
3034 "Failed to allocate memory for ha->msix_entries.\n");
3038 ha
->flags
.msix_enabled
= 1;
3040 for (i
= 0; i
< ha
->msix_count
; i
++) {
3041 qentry
= &ha
->msix_entries
[i
];
3042 qentry
->vector
= entries
[i
].vector
;
3043 qentry
->entry
= entries
[i
].entry
;
3044 qentry
->have_irq
= 0;
3048 /* Enable MSI-X vectors for the base queue */
3049 for (i
= 0; i
< 2; i
++) {
3050 qentry
= &ha
->msix_entries
[i
];
3051 if (IS_P3P_TYPE(ha
))
3052 ret
= request_irq(qentry
->vector
,
3053 qla82xx_msix_entries
[i
].handler
,
3054 0, qla82xx_msix_entries
[i
].name
, rsp
);
3056 ret
= request_irq(qentry
->vector
,
3057 msix_entries
[i
].handler
,
3058 0, msix_entries
[i
].name
, rsp
);
3060 goto msix_register_fail
;
3061 qentry
->have_irq
= 1;
3067 * If target mode is enable, also request the vector for the ATIO
3070 if (QLA_TGT_MODE_ENABLED() && IS_ATIO_MSIX_CAPABLE(ha
)) {
3071 qentry
= &ha
->msix_entries
[ATIO_VECTOR
];
3072 ret
= request_irq(qentry
->vector
,
3073 qla83xx_msix_entries
[ATIO_VECTOR
].handler
,
3074 0, qla83xx_msix_entries
[ATIO_VECTOR
].name
, rsp
);
3075 qentry
->have_irq
= 1;
3082 ql_log(ql_log_fatal
, vha
, 0x00cb,
3083 "MSI-X: unable to register handler -- %x/%d.\n",
3084 qentry
->vector
, ret
);
3085 qla24xx_disable_msix(ha
);
3090 /* Enable MSI-X vector for response queue update for queue 0 */
3091 if (IS_QLA83XX(ha
) || IS_QLA27XX(ha
)) {
3092 if (ha
->msixbase
&& ha
->mqiobase
&&
3093 (ha
->max_rsp_queues
> 1 || ha
->max_req_queues
> 1))
3097 && (ha
->max_rsp_queues
> 1 || ha
->max_req_queues
> 1))
3099 ql_dbg(ql_dbg_multiq
, vha
, 0xc005,
3100 "mqiobase=%p, max_rsp_queues=%d, max_req_queues=%d.\n",
3101 ha
->mqiobase
, ha
->max_rsp_queues
, ha
->max_req_queues
);
3102 ql_dbg(ql_dbg_init
, vha
, 0x0055,
3103 "mqiobase=%p, max_rsp_queues=%d, max_req_queues=%d.\n",
3104 ha
->mqiobase
, ha
->max_rsp_queues
, ha
->max_req_queues
);
3112 qla2x00_request_irqs(struct qla_hw_data
*ha
, struct rsp_que
*rsp
)
3114 int ret
= QLA_FUNCTION_FAILED
;
3115 device_reg_t
*reg
= ha
->iobase
;
3116 scsi_qla_host_t
*vha
= pci_get_drvdata(ha
->pdev
);
3118 /* If possible, enable MSI-X. */
3119 if (!IS_QLA2432(ha
) && !IS_QLA2532(ha
) && !IS_QLA8432(ha
) &&
3120 !IS_CNA_CAPABLE(ha
) && !IS_QLA2031(ha
) && !IS_QLAFX00(ha
) &&
3124 if (ha
->pdev
->subsystem_vendor
== PCI_VENDOR_ID_HP
&&
3125 (ha
->pdev
->subsystem_device
== 0x7040 ||
3126 ha
->pdev
->subsystem_device
== 0x7041 ||
3127 ha
->pdev
->subsystem_device
== 0x1705)) {
3128 ql_log(ql_log_warn
, vha
, 0x0034,
3129 "MSI-X: Unsupported ISP 2432 SSVID/SSDID (0x%X,0x%X).\n",
3130 ha
->pdev
->subsystem_vendor
,
3131 ha
->pdev
->subsystem_device
);
3135 if (IS_QLA2432(ha
) && (ha
->pdev
->revision
< QLA_MSIX_CHIP_REV_24XX
)) {
3136 ql_log(ql_log_warn
, vha
, 0x0035,
3137 "MSI-X; Unsupported ISP2432 (0x%X, 0x%X).\n",
3138 ha
->pdev
->revision
, QLA_MSIX_CHIP_REV_24XX
);
3142 ret
= qla24xx_enable_msix(ha
, rsp
);
3144 ql_dbg(ql_dbg_init
, vha
, 0x0036,
3145 "MSI-X: Enabled (0x%X, 0x%X).\n",
3146 ha
->chip_revision
, ha
->fw_attributes
);
3147 goto clear_risc_ints
;
3152 ql_log(ql_log_info
, vha
, 0x0037,
3153 "Falling back-to MSI mode -%d.\n", ret
);
3155 if (!IS_QLA24XX(ha
) && !IS_QLA2532(ha
) && !IS_QLA8432(ha
) &&
3156 !IS_QLA8001(ha
) && !IS_P3P_TYPE(ha
) && !IS_QLAFX00(ha
) &&
3160 ret
= pci_enable_msi(ha
->pdev
);
3162 ql_dbg(ql_dbg_init
, vha
, 0x0038,
3164 ha
->flags
.msi_enabled
= 1;
3166 ql_log(ql_log_warn
, vha
, 0x0039,
3167 "Falling back-to INTa mode -- %d.\n", ret
);
3170 /* Skip INTx on ISP82xx. */
3171 if (!ha
->flags
.msi_enabled
&& IS_QLA82XX(ha
))
3172 return QLA_FUNCTION_FAILED
;
3174 ret
= request_irq(ha
->pdev
->irq
, ha
->isp_ops
->intr_handler
,
3175 ha
->flags
.msi_enabled
? 0 : IRQF_SHARED
,
3176 QLA2XXX_DRIVER_NAME
, rsp
);
3178 ql_log(ql_log_warn
, vha
, 0x003a,
3179 "Failed to reserve interrupt %d already in use.\n",
3182 } else if (!ha
->flags
.msi_enabled
) {
3183 ql_dbg(ql_dbg_init
, vha
, 0x0125,
3184 "INTa mode: Enabled.\n");
3185 ha
->flags
.mr_intr_valid
= 1;
3189 if (IS_FWI2_CAPABLE(ha
) || IS_QLAFX00(ha
))
3192 spin_lock_irq(&ha
->hardware_lock
);
3193 WRT_REG_WORD(®
->isp
.semaphore
, 0);
3194 spin_unlock_irq(&ha
->hardware_lock
);
3201 qla2x00_free_irqs(scsi_qla_host_t
*vha
)
3203 struct qla_hw_data
*ha
= vha
->hw
;
3204 struct rsp_que
*rsp
;
3207 * We need to check that ha->rsp_q_map is valid in case we are called
3208 * from a probe failure context.
3210 if (!ha
->rsp_q_map
|| !ha
->rsp_q_map
[0])
3212 rsp
= ha
->rsp_q_map
[0];
3214 if (ha
->flags
.msix_enabled
)
3215 qla24xx_disable_msix(ha
);
3216 else if (ha
->flags
.msi_enabled
) {
3217 free_irq(ha
->pdev
->irq
, rsp
);
3218 pci_disable_msi(ha
->pdev
);
3220 free_irq(ha
->pdev
->irq
, rsp
);
3224 int qla25xx_request_irq(struct rsp_que
*rsp
)
3226 struct qla_hw_data
*ha
= rsp
->hw
;
3227 struct qla_init_msix_entry
*intr
= &msix_entries
[2];
3228 struct qla_msix_entry
*msix
= rsp
->msix
;
3229 scsi_qla_host_t
*vha
= pci_get_drvdata(ha
->pdev
);
3232 ret
= request_irq(msix
->vector
, intr
->handler
, 0, intr
->name
, rsp
);
3234 ql_log(ql_log_fatal
, vha
, 0x00e6,
3235 "MSI-X: Unable to register handler -- %x/%d.\n",