2 * QLogic iSCSI HBA Driver
3 * Copyright (c) 2003-2012 QLogic Corporation
5 * See LICENSE.qla4xxx for copyright and licensing details.
11 #include "ql4_inline.h"
14 * qla4xxx_copy_sense - copy sense data into cmd sense buffer
15 * @ha: Pointer to host adapter structure.
16 * @sts_entry: Pointer to status entry structure.
17 * @srb: Pointer to srb structure.
19 static void qla4xxx_copy_sense(struct scsi_qla_host *ha,
20 struct status_entry *sts_entry,
23 struct scsi_cmnd *cmd = srb->cmd;
26 memset(cmd->sense_buffer, 0, SCSI_SENSE_BUFFERSIZE);
27 sense_len = le16_to_cpu(sts_entry->senseDataByteCnt);
29 DEBUG2(ql4_printk(KERN_INFO, ha, "scsi%ld:%d:%d:%d: %s:"
30 " sense len 0\n", ha->host_no,
31 cmd->device->channel, cmd->device->id,
32 cmd->device->lun, __func__));
33 ha->status_srb = NULL;
36 /* Save total available sense length,
37 * not to exceed cmd's sense buffer size */
38 sense_len = min_t(uint16_t, sense_len, SCSI_SENSE_BUFFERSIZE);
39 srb->req_sense_ptr = cmd->sense_buffer;
40 srb->req_sense_len = sense_len;
42 /* Copy sense from sts_entry pkt */
43 sense_len = min_t(uint16_t, sense_len, IOCB_MAX_SENSEDATA_LEN);
44 memcpy(cmd->sense_buffer, sts_entry->senseData, sense_len);
46 DEBUG2(printk(KERN_INFO "scsi%ld:%d:%d:%d: %s: sense key = %x, "
47 "ASL= %02x, ASC/ASCQ = %02x/%02x\n", ha->host_no,
48 cmd->device->channel, cmd->device->id,
49 cmd->device->lun, __func__,
50 sts_entry->senseData[2] & 0x0f,
51 sts_entry->senseData[7],
52 sts_entry->senseData[12],
53 sts_entry->senseData[13]));
55 DEBUG5(qla4xxx_dump_buffer(cmd->sense_buffer, sense_len));
56 srb->flags |= SRB_GOT_SENSE;
58 /* Update srb, in case a sts_cont pkt follows */
59 srb->req_sense_ptr += sense_len;
60 srb->req_sense_len -= sense_len;
61 if (srb->req_sense_len != 0)
64 ha->status_srb = NULL;
68 * qla4xxx_status_cont_entry - Process a Status Continuations entry.
69 * @ha: SCSI driver HA context
70 * @sts_cont: Entry pointer
72 * Extended sense data.
75 qla4xxx_status_cont_entry(struct scsi_qla_host *ha,
76 struct status_cont_entry *sts_cont)
78 struct srb *srb = ha->status_srb;
79 struct scsi_cmnd *cmd;
87 DEBUG2(printk(KERN_INFO "scsi%ld: %s: Cmd already returned "
88 "back to OS srb=%p srb->state:%d\n", ha->host_no,
89 __func__, srb, srb->state));
90 ha->status_srb = NULL;
94 /* Copy sense data. */
95 sense_len = min_t(uint16_t, srb->req_sense_len,
96 IOCB_MAX_EXT_SENSEDATA_LEN);
97 memcpy(srb->req_sense_ptr, sts_cont->ext_sense_data, sense_len);
98 DEBUG5(qla4xxx_dump_buffer(srb->req_sense_ptr, sense_len));
100 srb->req_sense_ptr += sense_len;
101 srb->req_sense_len -= sense_len;
103 /* Place command on done queue. */
104 if (srb->req_sense_len == 0) {
105 kref_put(&srb->srb_ref, qla4xxx_srb_compl);
106 ha->status_srb = NULL;
111 * qla4xxx_status_entry - processes status IOCBs
112 * @ha: Pointer to host adapter structure.
113 * @sts_entry: Pointer to status entry structure.
115 static void qla4xxx_status_entry(struct scsi_qla_host *ha,
116 struct status_entry *sts_entry)
119 struct scsi_cmnd *cmd;
121 struct ddb_entry *ddb_entry;
124 srb = qla4xxx_del_from_active_array(ha, le32_to_cpu(sts_entry->handle));
126 ql4_printk(KERN_WARNING, ha, "%s invalid status entry: "
127 "handle=0x%0x, srb=%p\n", __func__,
128 sts_entry->handle, srb);
130 set_bit(DPC_RESET_HA_FW_CONTEXT, &ha->dpc_flags);
132 set_bit(DPC_RESET_HA, &ha->dpc_flags);
138 DEBUG2(printk("scsi%ld: %s: Command already returned back to "
139 "OS pkt->handle=%d srb=%p srb->state:%d\n",
140 ha->host_no, __func__, sts_entry->handle,
142 ql4_printk(KERN_WARNING, ha, "Command is NULL:"
143 " already returned to OS (srb=%p)\n", srb);
147 ddb_entry = srb->ddb;
148 if (ddb_entry == NULL) {
149 cmd->result = DID_NO_CONNECT << 16;
150 goto status_entry_exit;
153 residual = le32_to_cpu(sts_entry->residualByteCnt);
155 /* Translate ISP error to a Linux SCSI error. */
156 scsi_status = sts_entry->scsiStatus;
157 switch (sts_entry->completionStatus) {
160 if (sts_entry->iscsiFlags & ISCSI_FLAG_RESIDUAL_OVER) {
161 cmd->result = DID_ERROR << 16;
165 if (sts_entry->iscsiFlags &ISCSI_FLAG_RESIDUAL_UNDER) {
166 scsi_set_resid(cmd, residual);
167 if (!scsi_status && ((scsi_bufflen(cmd) - residual) <
170 cmd->result = DID_ERROR << 16;
172 DEBUG2(printk("scsi%ld:%d:%d:%d: %s: "
173 "Mid-layer Data underrun0, "
175 "residual = 0x%x\n", ha->host_no,
176 cmd->device->channel,
178 cmd->device->lun, __func__,
179 scsi_bufflen(cmd), residual));
184 cmd->result = DID_OK << 16 | scsi_status;
186 if (scsi_status != SCSI_CHECK_CONDITION)
189 /* Copy Sense Data into sense buffer. */
190 qla4xxx_copy_sense(ha, sts_entry, srb);
194 /* Always set the status to DID_ERROR, since
195 * all conditions result in that status anyway */
196 cmd->result = DID_ERROR << 16;
199 case SCS_RESET_OCCURRED:
200 DEBUG2(printk("scsi%ld:%d:%d:%d: %s: Device RESET occurred\n",
201 ha->host_no, cmd->device->channel,
202 cmd->device->id, cmd->device->lun, __func__));
204 cmd->result = DID_RESET << 16;
208 DEBUG2(printk("scsi%ld:%d:%d:%d: %s: Abort occurred\n",
209 ha->host_no, cmd->device->channel,
210 cmd->device->id, cmd->device->lun, __func__));
212 cmd->result = DID_RESET << 16;
216 DEBUG2(printk(KERN_INFO "scsi%ld:%d:%d:%d: Timeout\n",
217 ha->host_no, cmd->device->channel,
218 cmd->device->id, cmd->device->lun));
220 cmd->result = DID_TRANSPORT_DISRUPTED << 16;
223 * Mark device missing so that we won't continue to send
224 * I/O to this device. We should get a ddb state change
227 if (iscsi_is_session_online(ddb_entry->sess))
228 qla4xxx_mark_device_missing(ddb_entry->sess);
231 case SCS_DATA_UNDERRUN:
232 case SCS_DATA_OVERRUN:
233 if ((sts_entry->iscsiFlags & ISCSI_FLAG_RESIDUAL_OVER) ||
234 (sts_entry->completionStatus == SCS_DATA_OVERRUN)) {
235 DEBUG2(printk("scsi%ld:%d:%d:%d: %s: " "Data overrun\n",
237 cmd->device->channel, cmd->device->id,
238 cmd->device->lun, __func__));
240 cmd->result = DID_ERROR << 16;
244 scsi_set_resid(cmd, residual);
246 if (sts_entry->iscsiFlags & ISCSI_FLAG_RESIDUAL_UNDER) {
248 /* Both the firmware and target reported UNDERRUN:
250 * MID-LAYER UNDERFLOW case:
251 * Some kernels do not properly detect midlayer
252 * underflow, so we manually check it and return
253 * ERROR if the minimum required data was not
257 * Fall thru to check scsi_status
259 if (!scsi_status && (scsi_bufflen(cmd) - residual) <
261 DEBUG2(ql4_printk(KERN_INFO, ha,
262 "scsi%ld:%d:%d:%d: %s: Mid-layer Data underrun, xferlen = 0x%x,residual = 0x%x\n",
264 cmd->device->channel,
266 cmd->device->lun, __func__,
270 cmd->result = DID_ERROR << 16;
274 } else if (scsi_status != SAM_STAT_TASK_SET_FULL &&
275 scsi_status != SAM_STAT_BUSY) {
278 * The firmware reports UNDERRUN, but the target does
281 * scsi_status | host_byte device_byte
283 * ============= | ========= ===========
284 * TASK_SET_FULL | DID_OK scsi_status
285 * BUSY | DID_OK scsi_status
286 * ALL OTHERS | DID_ERROR scsi_status
288 * Note: If scsi_status is task set full or busy,
289 * then this else if would fall thru to check the
290 * scsi_status and return DID_OK.
293 DEBUG2(ql4_printk(KERN_INFO, ha,
294 "scsi%ld:%d:%d:%d: %s: Dropped frame(s) detected (0x%x of 0x%x bytes).\n",
296 cmd->device->channel,
298 cmd->device->lun, __func__,
302 cmd->result = DID_ERROR << 16 | scsi_status;
303 goto check_scsi_status;
306 cmd->result = DID_OK << 16 | scsi_status;
309 if (scsi_status == SAM_STAT_CHECK_CONDITION)
310 qla4xxx_copy_sense(ha, sts_entry, srb);
314 case SCS_DEVICE_LOGGED_OUT:
315 case SCS_DEVICE_UNAVAILABLE:
316 DEBUG2(printk(KERN_INFO "scsi%ld:%d:%d:%d: SCS_DEVICE "
317 "state: 0x%x\n", ha->host_no,
318 cmd->device->channel, cmd->device->id,
319 cmd->device->lun, sts_entry->completionStatus));
321 * Mark device missing so that we won't continue to
322 * send I/O to this device. We should get a ddb
323 * state change AEN soon.
325 if (iscsi_is_session_online(ddb_entry->sess))
326 qla4xxx_mark_device_missing(ddb_entry->sess);
328 cmd->result = DID_TRANSPORT_DISRUPTED << 16;
333 * SCSI Mid-Layer handles device queue full
335 cmd->result = DID_OK << 16 | sts_entry->scsiStatus;
336 DEBUG2(printk("scsi%ld:%d:%d: %s: QUEUE FULL detected "
337 "compl=%02x, scsi=%02x, state=%02x, iFlags=%02x,"
338 " iResp=%02x\n", ha->host_no, cmd->device->id,
339 cmd->device->lun, __func__,
340 sts_entry->completionStatus,
341 sts_entry->scsiStatus, sts_entry->state_flags,
342 sts_entry->iscsiFlags,
343 sts_entry->iscsiResponse));
347 cmd->result = DID_ERROR << 16;
353 /* complete the request, if not waiting for status_continuation pkt */
354 srb->cc_stat = sts_entry->completionStatus;
355 if (ha->status_srb == NULL)
356 kref_put(&srb->srb_ref, qla4xxx_srb_compl);
360 * qla4xxx_passthru_status_entry - processes passthru status IOCBs (0x3C)
361 * @ha: Pointer to host adapter structure.
362 * @sts_entry: Pointer to status entry structure.
364 static void qla4xxx_passthru_status_entry(struct scsi_qla_host *ha,
365 struct passthru_status *sts_entry)
367 struct iscsi_task *task;
368 struct ddb_entry *ddb_entry;
369 struct ql4_task_data *task_data;
370 struct iscsi_cls_conn *cls_conn;
371 struct iscsi_conn *conn;
373 uint32_t fw_ddb_index;
375 itt = sts_entry->handle;
376 fw_ddb_index = le32_to_cpu(sts_entry->target);
378 ddb_entry = qla4xxx_lookup_ddb_by_fw_index(ha, fw_ddb_index);
380 if (ddb_entry == NULL) {
381 ql4_printk(KERN_ERR, ha, "%s: Invalid target index = 0x%x\n",
382 __func__, sts_entry->target);
386 cls_conn = ddb_entry->conn;
387 conn = cls_conn->dd_data;
388 spin_lock(&conn->session->lock);
389 task = iscsi_itt_to_task(conn, itt);
390 spin_unlock(&conn->session->lock);
393 ql4_printk(KERN_ERR, ha, "%s: Task is NULL\n", __func__);
397 task_data = task->dd_data;
398 memcpy(&task_data->sts, sts_entry, sizeof(struct passthru_status));
399 ha->iocb_cnt -= task_data->iocb_req_cnt;
400 queue_work(ha->task_wq, &task_data->task_work);
403 static struct mrb *qla4xxx_del_mrb_from_active_array(struct scsi_qla_host *ha,
406 struct mrb *mrb = NULL;
408 /* validate handle and remove from active array */
409 if (index >= MAX_MRB)
412 mrb = ha->active_mrb_array[index];
413 ha->active_mrb_array[index] = NULL;
417 /* update counters */
418 ha->iocb_cnt -= mrb->iocb_cnt;
423 static void qla4xxx_mbox_status_entry(struct scsi_qla_host *ha,
424 struct mbox_status_iocb *mbox_sts_entry)
430 mrb = qla4xxx_del_mrb_from_active_array(ha,
431 le32_to_cpu(mbox_sts_entry->handle));
434 ql4_printk(KERN_WARNING, ha, "%s: mrb[%d] is null\n", __func__,
435 mbox_sts_entry->handle);
439 switch (mrb->mbox_cmd) {
441 DEBUG2(ql4_printk(KERN_INFO, ha, "%s: mbox_cmd = 0x%x, "
442 "mbox_sts[0] = 0x%x, mbox_sts[6] = 0x%x\n",
443 __func__, mrb->mbox_cmd,
444 mbox_sts_entry->out_mbox[0],
445 mbox_sts_entry->out_mbox[6]));
447 if (mbox_sts_entry->out_mbox[0] == MBOX_STS_COMMAND_COMPLETE)
448 status = ISCSI_PING_SUCCESS;
450 status = mbox_sts_entry->out_mbox[6];
452 data_size = sizeof(mbox_sts_entry->out_mbox);
454 qla4xxx_post_ping_evt_work(ha, status, mrb->pid, data_size,
455 (uint8_t *) mbox_sts_entry->out_mbox);
459 DEBUG2(ql4_printk(KERN_WARNING, ha, "%s: invalid mbox_cmd = "
460 "0x%x\n", __func__, mrb->mbox_cmd));
468 * qla4xxx_process_response_queue - process response queue completions
469 * @ha: Pointer to host adapter structure.
471 * This routine process response queue completions in interrupt context.
472 * Hardware_lock locked upon entry
474 void qla4xxx_process_response_queue(struct scsi_qla_host *ha)
477 struct srb *srb = NULL;
478 struct status_entry *sts_entry;
480 /* Process all responses from response queue */
481 while ((ha->response_ptr->signature != RESPONSE_PROCESSED)) {
482 sts_entry = (struct status_entry *) ha->response_ptr;
485 /* Advance pointers for next entry */
486 if (ha->response_out == (RESPONSE_QUEUE_DEPTH - 1)) {
487 ha->response_out = 0;
488 ha->response_ptr = ha->response_ring;
495 switch (sts_entry->hdr.entryType) {
498 qla4xxx_status_entry(ha, sts_entry);
501 case ET_PASSTHRU_STATUS:
502 if (sts_entry->hdr.systemDefined == SD_ISCSI_PDU)
503 qla4xxx_passthru_status_entry(ha,
504 (struct passthru_status *)sts_entry);
506 ql4_printk(KERN_ERR, ha,
507 "%s: Invalid status received\n",
512 case ET_STATUS_CONTINUATION:
513 qla4xxx_status_cont_entry(ha,
514 (struct status_cont_entry *) sts_entry);
518 /* ISP device queue is full. Command not
519 * accepted by ISP. Queue command for
522 srb = qla4xxx_del_from_active_array(ha,
523 le32_to_cpu(sts_entry->
526 goto exit_prq_invalid_handle;
528 DEBUG2(printk("scsi%ld: %s: FW device queue full, "
529 "srb %p\n", ha->host_no, __func__, srb));
531 /* ETRY normally by sending it back with
533 srb->cmd->result = DID_BUS_BUSY << 16;
534 kref_put(&srb->srb_ref, qla4xxx_srb_compl);
538 /* Just throw away the continuation entries */
539 DEBUG2(printk("scsi%ld: %s: Continuation entry - "
540 "ignoring\n", ha->host_no, __func__));
544 DEBUG2(ql4_printk(KERN_INFO, ha,
545 "%s: mbox status IOCB\n", __func__));
546 qla4xxx_mbox_status_entry(ha,
547 (struct mbox_status_iocb *)sts_entry);
552 * Invalid entry in response queue, reset RISC
555 DEBUG2(printk("scsi%ld: %s: Invalid entry %x in "
556 "response queue \n", ha->host_no,
558 sts_entry->hdr.entryType));
561 ((struct response *)sts_entry)->signature = RESPONSE_PROCESSED;
566 * Tell ISP we're done with response(s). This also clears the interrupt.
568 ha->isp_ops->complete_iocb(ha);
572 exit_prq_invalid_handle:
573 DEBUG2(printk("scsi%ld: %s: Invalid handle(srb)=%p type=%x IOCS=%x\n",
574 ha->host_no, __func__, srb, sts_entry->hdr.entryType,
575 sts_entry->completionStatus));
578 ha->isp_ops->complete_iocb(ha);
579 set_bit(DPC_RESET_HA, &ha->dpc_flags);
583 * qla4_83xx_loopback_in_progress: Is loopback in progress?
584 * @ha: Pointer to host adapter structure.
585 * @ret: 1 = loopback in progress, 0 = loopback not in progress
587 static int qla4_83xx_loopback_in_progress(struct scsi_qla_host *ha)
591 if (is_qla8032(ha) || is_qla8042(ha)) {
592 if ((ha->idc_info.info2 & ENABLE_INTERNAL_LOOPBACK) ||
593 (ha->idc_info.info2 & ENABLE_EXTERNAL_LOOPBACK)) {
594 DEBUG2(ql4_printk(KERN_INFO, ha,
595 "%s: Loopback diagnostics in progress\n",
599 DEBUG2(ql4_printk(KERN_INFO, ha,
600 "%s: Loopback diagnostics not in progress\n",
610 * qla4xxx_isr_decode_mailbox - decodes mailbox status
611 * @ha: Pointer to host adapter structure.
612 * @mailbox_status: Mailbox status.
614 * This routine decodes the mailbox status during the ISR.
615 * Hardware_lock locked upon entry. runs in interrupt context.
617 static void qla4xxx_isr_decode_mailbox(struct scsi_qla_host * ha,
618 uint32_t mbox_status)
621 uint32_t mbox_sts[MBOX_AEN_REG_COUNT];
622 __le32 __iomem *mailbox_out;
624 if (is_qla8032(ha) || is_qla8042(ha))
625 mailbox_out = &ha->qla4_83xx_reg->mailbox_out[0];
626 else if (is_qla8022(ha))
627 mailbox_out = &ha->qla4_82xx_reg->mailbox_out[0];
629 mailbox_out = &ha->reg->mailbox[0];
631 if ((mbox_status == MBOX_STS_BUSY) ||
632 (mbox_status == MBOX_STS_INTERMEDIATE_COMPLETION) ||
633 (mbox_status >> 12 == MBOX_COMPLETION_STATUS)) {
634 ha->mbox_status[0] = mbox_status;
636 if (test_bit(AF_MBOX_COMMAND, &ha->flags)) {
638 * Copy all mailbox registers to a temporary
639 * location and set mailbox command done flag
641 for (i = 0; i < ha->mbox_status_count; i++)
642 ha->mbox_status[i] = readl(&mailbox_out[i]);
644 set_bit(AF_MBOX_COMMAND_DONE, &ha->flags);
646 if (test_bit(AF_MBOX_COMMAND_NOPOLL, &ha->flags))
647 complete(&ha->mbx_intr_comp);
649 } else if (mbox_status >> 12 == MBOX_ASYNC_EVENT_STATUS) {
650 for (i = 0; i < MBOX_AEN_REG_COUNT; i++)
651 mbox_sts[i] = readl(&mailbox_out[i]);
653 /* Immediately process the AENs that don't require much work.
654 * Only queue the database_changed AENs */
655 if (ha->aen_log.count < MAX_AEN_ENTRIES) {
656 for (i = 0; i < MBOX_AEN_REG_COUNT; i++)
657 ha->aen_log.entry[ha->aen_log.count].mbox_sts[i] =
661 switch (mbox_status) {
662 case MBOX_ASTS_SYSTEM_ERROR:
663 /* Log Mailbox registers */
664 ql4_printk(KERN_INFO, ha, "%s: System Err\n", __func__);
665 qla4xxx_dump_registers(ha);
667 if ((is_qla8022(ha) && ql4xdontresethba) ||
668 ((is_qla8032(ha) || is_qla8042(ha)) &&
669 qla4_83xx_idc_dontreset(ha))) {
670 DEBUG2(printk("scsi%ld: %s:Don't Reset HBA\n",
671 ha->host_no, __func__));
673 set_bit(AF_GET_CRASH_RECORD, &ha->flags);
674 set_bit(DPC_RESET_HA, &ha->dpc_flags);
678 case MBOX_ASTS_REQUEST_TRANSFER_ERROR:
679 case MBOX_ASTS_RESPONSE_TRANSFER_ERROR:
680 case MBOX_ASTS_NVRAM_INVALID:
681 case MBOX_ASTS_IP_ADDRESS_CHANGED:
682 case MBOX_ASTS_DHCP_LEASE_EXPIRED:
683 DEBUG2(printk("scsi%ld: AEN %04x, ERROR Status, "
684 "Reset HA\n", ha->host_no, mbox_status));
686 set_bit(DPC_RESET_HA_FW_CONTEXT,
689 set_bit(DPC_RESET_HA, &ha->dpc_flags);
692 case MBOX_ASTS_LINK_UP:
693 set_bit(AF_LINK_UP, &ha->flags);
694 if (test_bit(AF_INIT_DONE, &ha->flags))
695 set_bit(DPC_LINK_CHANGED, &ha->dpc_flags);
697 ql4_printk(KERN_INFO, ha, "%s: LINK UP\n", __func__);
698 qla4xxx_post_aen_work(ha, ISCSI_EVENT_LINKUP,
700 (uint8_t *) mbox_sts);
703 case MBOX_ASTS_LINK_DOWN:
704 clear_bit(AF_LINK_UP, &ha->flags);
705 if (test_bit(AF_INIT_DONE, &ha->flags)) {
706 set_bit(DPC_LINK_CHANGED, &ha->dpc_flags);
707 qla4xxx_wake_dpc(ha);
710 ql4_printk(KERN_INFO, ha, "%s: LINK DOWN\n", __func__);
711 qla4xxx_post_aen_work(ha, ISCSI_EVENT_LINKDOWN,
713 (uint8_t *) mbox_sts);
716 case MBOX_ASTS_HEARTBEAT:
717 ha->seconds_since_last_heartbeat = 0;
720 case MBOX_ASTS_DHCP_LEASE_ACQUIRED:
721 DEBUG2(printk("scsi%ld: AEN %04x DHCP LEASE "
722 "ACQUIRED\n", ha->host_no, mbox_status));
723 set_bit(DPC_GET_DHCP_IP_ADDR, &ha->dpc_flags);
726 case MBOX_ASTS_PROTOCOL_STATISTIC_ALARM:
727 case MBOX_ASTS_SCSI_COMMAND_PDU_REJECTED: /* Target
730 case MBOX_ASTS_UNSOLICITED_PDU_RECEIVED: /* Connection mode */
731 case MBOX_ASTS_IPSEC_SYSTEM_FATAL_ERROR:
732 case MBOX_ASTS_SUBNET_STATE_CHANGE:
733 case MBOX_ASTS_DUPLICATE_IP:
735 DEBUG2(printk("scsi%ld: AEN %04x\n", ha->host_no,
739 case MBOX_ASTS_IP_ADDR_STATE_CHANGED:
740 printk("scsi%ld: AEN %04x, mbox_sts[2]=%04x, "
741 "mbox_sts[3]=%04x\n", ha->host_no, mbox_sts[0],
742 mbox_sts[2], mbox_sts[3]);
744 /* mbox_sts[2] = Old ACB state
745 * mbox_sts[3] = new ACB state */
746 if ((mbox_sts[3] == ACB_STATE_VALID) &&
747 ((mbox_sts[2] == ACB_STATE_TENTATIVE) ||
748 (mbox_sts[2] == ACB_STATE_ACQUIRING)))
749 set_bit(DPC_GET_DHCP_IP_ADDR, &ha->dpc_flags);
750 else if ((mbox_sts[3] == ACB_STATE_ACQUIRING) &&
751 (mbox_sts[2] == ACB_STATE_VALID)) {
753 set_bit(DPC_RESET_HA_FW_CONTEXT,
756 set_bit(DPC_RESET_HA, &ha->dpc_flags);
757 } else if ((mbox_sts[3] == ACB_STATE_UNCONFIGURED))
758 complete(&ha->disable_acb_comp);
761 case MBOX_ASTS_MAC_ADDRESS_CHANGED:
764 DEBUG2(printk(KERN_INFO "scsi%ld: AEN %04x, "
765 "mbox_sts[1]=%04x, mbox_sts[2]=%04x\n",
766 ha->host_no, mbox_sts[0],
767 mbox_sts[1], mbox_sts[2]));
770 case MBOX_ASTS_SELF_TEST_FAILED:
771 case MBOX_ASTS_LOGIN_FAILED:
773 DEBUG2(printk("scsi%ld: AEN %04x, mbox_sts[1]=%04x, "
774 "mbox_sts[2]=%04x, mbox_sts[3]=%04x\n",
775 ha->host_no, mbox_sts[0], mbox_sts[1],
776 mbox_sts[2], mbox_sts[3]));
779 case MBOX_ASTS_DATABASE_CHANGED:
780 /* Queue AEN information and process it in the DPC
782 if (ha->aen_q_count > 0) {
784 /* decrement available counter */
787 for (i = 0; i < MBOX_AEN_REG_COUNT; i++)
788 ha->aen_q[ha->aen_in].mbox_sts[i] =
791 /* print debug message */
792 DEBUG2(printk("scsi%ld: AEN[%d] %04x queued "
793 "mb1:0x%x mb2:0x%x mb3:0x%x "
794 "mb4:0x%x mb5:0x%x\n",
795 ha->host_no, ha->aen_in,
796 mbox_sts[0], mbox_sts[1],
797 mbox_sts[2], mbox_sts[3],
798 mbox_sts[4], mbox_sts[5]));
800 /* advance pointer */
802 if (ha->aen_in == MAX_AEN_ENTRIES)
805 /* The DPC routine will process the aen */
806 set_bit(DPC_AEN, &ha->dpc_flags);
808 DEBUG2(printk("scsi%ld: %s: aen %04x, queue "
809 "overflowed! AEN LOST!!\n",
810 ha->host_no, __func__,
813 DEBUG2(printk("scsi%ld: DUMP AEN QUEUE\n",
816 for (i = 0; i < MAX_AEN_ENTRIES; i++) {
817 DEBUG2(printk("AEN[%d] %04x %04x %04x "
818 "%04x\n", i, mbox_sts[0],
819 mbox_sts[1], mbox_sts[2],
825 case MBOX_ASTS_TXSCVR_INSERTED:
826 DEBUG2(printk(KERN_WARNING
827 "scsi%ld: AEN %04x Transceiver"
828 " inserted\n", ha->host_no, mbox_sts[0]));
831 case MBOX_ASTS_TXSCVR_REMOVED:
832 DEBUG2(printk(KERN_WARNING
833 "scsi%ld: AEN %04x Transceiver"
834 " removed\n", ha->host_no, mbox_sts[0]));
837 case MBOX_ASTS_IDC_REQUEST_NOTIFICATION:
840 if (is_qla8032(ha) || is_qla8042(ha)) {
841 DEBUG2(ql4_printk(KERN_INFO, ha,
842 "scsi%ld: AEN %04x, mbox_sts[1]=%08x, mbox_sts[2]=%08x, mbox_sts[3]=%08x, mbox_sts[4]=%08x\n",
843 ha->host_no, mbox_sts[0],
844 mbox_sts[1], mbox_sts[2],
845 mbox_sts[3], mbox_sts[4]));
846 opcode = mbox_sts[1] >> 16;
847 if ((opcode == MBOX_CMD_SET_PORT_CONFIG) ||
848 (opcode == MBOX_CMD_PORT_RESET)) {
849 set_bit(DPC_POST_IDC_ACK,
851 ha->idc_info.request_desc = mbox_sts[1];
852 ha->idc_info.info1 = mbox_sts[2];
853 ha->idc_info.info2 = mbox_sts[3];
854 ha->idc_info.info3 = mbox_sts[4];
855 qla4xxx_wake_dpc(ha);
861 case MBOX_ASTS_IDC_COMPLETE:
862 if (is_qla8032(ha) || is_qla8042(ha)) {
863 DEBUG2(ql4_printk(KERN_INFO, ha,
864 "scsi%ld: AEN %04x, mbox_sts[1]=%08x, mbox_sts[2]=%08x, mbox_sts[3]=%08x, mbox_sts[4]=%08x\n",
865 ha->host_no, mbox_sts[0],
866 mbox_sts[1], mbox_sts[2],
867 mbox_sts[3], mbox_sts[4]));
868 DEBUG2(ql4_printk(KERN_INFO, ha,
869 "scsi:%ld: AEN %04x IDC Complete notification\n",
870 ha->host_no, mbox_sts[0]));
872 if (qla4_83xx_loopback_in_progress(ha))
873 set_bit(AF_LOOPBACK, &ha->flags);
875 clear_bit(AF_LOOPBACK, &ha->flags);
879 case MBOX_ASTS_IPV6_DEFAULT_ROUTER_CHANGED:
880 DEBUG2(ql4_printk(KERN_INFO, ha,
881 "scsi%ld: AEN %04x, mbox_sts[1]=%08x, mbox_sts[2]=%08x, mbox_sts[3]=%08x, mbox_sts[4]=%08x mbox_sts[5]=%08x\n",
882 ha->host_no, mbox_sts[0], mbox_sts[1],
883 mbox_sts[2], mbox_sts[3], mbox_sts[4],
885 DEBUG2(ql4_printk(KERN_INFO, ha,
886 "scsi%ld: AEN %04x Received IPv6 default router changed notification\n",
887 ha->host_no, mbox_sts[0]));
890 case MBOX_ASTS_INITIALIZATION_FAILED:
891 DEBUG2(ql4_printk(KERN_INFO, ha,
892 "scsi%ld: AEN %04x, mbox_sts[3]=%08x\n",
893 ha->host_no, mbox_sts[0],
897 case MBOX_ASTS_SYSTEM_WARNING_EVENT:
898 DEBUG2(ql4_printk(KERN_WARNING, ha,
899 "scsi%ld: AEN %04x, mbox_sts[1]=%08x, mbox_sts[2]=%08x, mbox_sts[3]=%08x, mbox_sts[4]=%08x mbox_sts[5]=%08x\n",
900 ha->host_no, mbox_sts[0], mbox_sts[1],
901 mbox_sts[2], mbox_sts[3], mbox_sts[4],
905 case MBOX_ASTS_DCBX_CONF_CHANGE:
906 DEBUG2(ql4_printk(KERN_INFO, ha,
907 "scsi%ld: AEN %04x, mbox_sts[1]=%08x, mbox_sts[2]=%08x, mbox_sts[3]=%08x, mbox_sts[4]=%08x mbox_sts[5]=%08x\n",
908 ha->host_no, mbox_sts[0], mbox_sts[1],
909 mbox_sts[2], mbox_sts[3], mbox_sts[4],
911 DEBUG2(ql4_printk(KERN_INFO, ha,
912 "scsi%ld: AEN %04x Received DCBX configuration changed notification\n",
913 ha->host_no, mbox_sts[0]));
917 DEBUG2(printk(KERN_WARNING
918 "scsi%ld: AEN %04x UNKNOWN\n",
919 ha->host_no, mbox_sts[0]));
923 DEBUG2(printk("scsi%ld: Unknown mailbox status %08X\n",
924 ha->host_no, mbox_status));
926 ha->mbox_status[0] = mbox_status;
930 void qla4_83xx_interrupt_service_routine(struct scsi_qla_host *ha,
931 uint32_t intr_status)
933 /* Process mailbox/asynch event interrupt.*/
935 qla4xxx_isr_decode_mailbox(ha,
936 readl(&ha->qla4_83xx_reg->mailbox_out[0]));
937 /* clear the interrupt */
938 writel(0, &ha->qla4_83xx_reg->risc_intr);
940 qla4xxx_process_response_queue(ha);
943 /* clear the interrupt */
944 writel(0, &ha->qla4_83xx_reg->mb_int_mask);
948 * qla4_82xx_interrupt_service_routine - isr
949 * @ha: pointer to host adapter structure.
951 * This is the main interrupt service routine.
952 * hardware_lock locked upon entry. runs in interrupt context.
954 void qla4_82xx_interrupt_service_routine(struct scsi_qla_host *ha,
955 uint32_t intr_status)
957 /* Process response queue interrupt. */
958 if (intr_status & HSRX_RISC_IOCB_INT)
959 qla4xxx_process_response_queue(ha);
961 /* Process mailbox/asynch event interrupt.*/
962 if (intr_status & HSRX_RISC_MB_INT)
963 qla4xxx_isr_decode_mailbox(ha,
964 readl(&ha->qla4_82xx_reg->mailbox_out[0]));
966 /* clear the interrupt */
967 writel(0, &ha->qla4_82xx_reg->host_int);
968 readl(&ha->qla4_82xx_reg->host_int);
972 * qla4xxx_interrupt_service_routine - isr
973 * @ha: pointer to host adapter structure.
975 * This is the main interrupt service routine.
976 * hardware_lock locked upon entry. runs in interrupt context.
978 void qla4xxx_interrupt_service_routine(struct scsi_qla_host * ha,
979 uint32_t intr_status)
981 /* Process response queue interrupt. */
982 if (intr_status & CSR_SCSI_COMPLETION_INTR)
983 qla4xxx_process_response_queue(ha);
985 /* Process mailbox/asynch event interrupt.*/
986 if (intr_status & CSR_SCSI_PROCESSOR_INTR) {
987 qla4xxx_isr_decode_mailbox(ha,
988 readl(&ha->reg->mailbox[0]));
990 /* Clear Mailbox Interrupt */
991 writel(set_rmask(CSR_SCSI_PROCESSOR_INTR),
992 &ha->reg->ctrl_status);
993 readl(&ha->reg->ctrl_status);
998 * qla4_82xx_spurious_interrupt - processes spurious interrupt
999 * @ha: pointer to host adapter structure.
1003 static void qla4_82xx_spurious_interrupt(struct scsi_qla_host *ha,
1009 DEBUG2(ql4_printk(KERN_INFO, ha, "Spurious Interrupt\n"));
1010 if (is_qla8022(ha)) {
1011 writel(0, &ha->qla4_82xx_reg->host_int);
1012 if (test_bit(AF_INTx_ENABLED, &ha->flags))
1013 qla4_82xx_wr_32(ha, ha->nx_legacy_intr.tgt_mask_reg,
1016 ha->spurious_int_count++;
1020 * qla4xxx_intr_handler - hardware interrupt handler.
1022 * @dev_id: Pointer to host adapter structure
1024 irqreturn_t qla4xxx_intr_handler(int irq, void *dev_id)
1026 struct scsi_qla_host *ha;
1027 uint32_t intr_status;
1028 unsigned long flags = 0;
1029 uint8_t reqs_count = 0;
1031 ha = (struct scsi_qla_host *) dev_id;
1033 DEBUG2(printk(KERN_INFO
1034 "qla4xxx: Interrupt with NULL host ptr\n"));
1038 spin_lock_irqsave(&ha->hardware_lock, flags);
1042 * Repeatedly service interrupts up to a maximum of
1043 * MAX_REQS_SERVICED_PER_INTR
1047 * Read interrupt status
1049 if (ha->isp_ops->rd_shdw_rsp_q_in(ha) !=
1051 intr_status = CSR_SCSI_COMPLETION_INTR;
1053 intr_status = readl(&ha->reg->ctrl_status);
1056 (CSR_SCSI_RESET_INTR|CSR_FATAL_ERROR|INTR_PENDING)) == 0) {
1057 if (reqs_count == 0)
1058 ha->spurious_int_count++;
1062 if (intr_status & CSR_FATAL_ERROR) {
1063 DEBUG2(printk(KERN_INFO "scsi%ld: Fatal Error, "
1064 "Status 0x%04x\n", ha->host_no,
1065 readl(isp_port_error_status (ha))));
1067 /* Issue Soft Reset to clear this error condition.
1068 * This will prevent the RISC from repeatedly
1069 * interrupting the driver; thus, allowing the DPC to
1070 * get scheduled to continue error recovery.
1071 * NOTE: Disabling RISC interrupts does not work in
1072 * this case, as CSR_FATAL_ERROR overrides
1073 * CSR_SCSI_INTR_ENABLE */
1074 if ((readl(&ha->reg->ctrl_status) &
1075 CSR_SCSI_RESET_INTR) == 0) {
1076 writel(set_rmask(CSR_SOFT_RESET),
1077 &ha->reg->ctrl_status);
1078 readl(&ha->reg->ctrl_status);
1081 writel(set_rmask(CSR_FATAL_ERROR),
1082 &ha->reg->ctrl_status);
1083 readl(&ha->reg->ctrl_status);
1085 __qla4xxx_disable_intrs(ha);
1087 set_bit(DPC_RESET_HA, &ha->dpc_flags);
1090 } else if (intr_status & CSR_SCSI_RESET_INTR) {
1091 clear_bit(AF_ONLINE, &ha->flags);
1092 __qla4xxx_disable_intrs(ha);
1094 writel(set_rmask(CSR_SCSI_RESET_INTR),
1095 &ha->reg->ctrl_status);
1096 readl(&ha->reg->ctrl_status);
1098 if (!test_bit(AF_HA_REMOVAL, &ha->flags))
1099 set_bit(DPC_RESET_HA_INTR, &ha->dpc_flags);
1102 } else if (intr_status & INTR_PENDING) {
1103 ha->isp_ops->interrupt_service_routine(ha, intr_status);
1104 ha->total_io_count++;
1105 if (++reqs_count == MAX_REQS_SERVICED_PER_INTR)
1110 spin_unlock_irqrestore(&ha->hardware_lock, flags);
1116 * qla4_82xx_intr_handler - hardware interrupt handler.
1118 * @dev_id: Pointer to host adapter structure
1120 irqreturn_t qla4_82xx_intr_handler(int irq, void *dev_id)
1122 struct scsi_qla_host *ha = dev_id;
1123 uint32_t intr_status;
1125 unsigned long flags = 0;
1126 uint8_t reqs_count = 0;
1128 if (unlikely(pci_channel_offline(ha->pdev)))
1132 status = qla4_82xx_rd_32(ha, ISR_INT_VECTOR);
1133 if (!(status & ha->nx_legacy_intr.int_vec_bit))
1136 status = qla4_82xx_rd_32(ha, ISR_INT_STATE_REG);
1137 if (!ISR_IS_LEGACY_INTR_TRIGGERED(status)) {
1138 DEBUG7(ql4_printk(KERN_INFO, ha,
1139 "%s legacy Int not triggered\n", __func__));
1143 /* clear the interrupt */
1144 qla4_82xx_wr_32(ha, ha->nx_legacy_intr.tgt_status_reg, 0xffffffff);
1146 /* read twice to ensure write is flushed */
1147 qla4_82xx_rd_32(ha, ISR_INT_VECTOR);
1148 qla4_82xx_rd_32(ha, ISR_INT_VECTOR);
1150 spin_lock_irqsave(&ha->hardware_lock, flags);
1152 if (!(readl(&ha->qla4_82xx_reg->host_int) &
1153 ISRX_82XX_RISC_INT)) {
1154 qla4_82xx_spurious_interrupt(ha, reqs_count);
1157 intr_status = readl(&ha->qla4_82xx_reg->host_status);
1159 (HSRX_RISC_MB_INT | HSRX_RISC_IOCB_INT)) == 0) {
1160 qla4_82xx_spurious_interrupt(ha, reqs_count);
1164 ha->isp_ops->interrupt_service_routine(ha, intr_status);
1166 /* Enable Interrupt */
1167 qla4_82xx_wr_32(ha, ha->nx_legacy_intr.tgt_mask_reg, 0xfbff);
1169 if (++reqs_count == MAX_REQS_SERVICED_PER_INTR)
1173 spin_unlock_irqrestore(&ha->hardware_lock, flags);
1177 #define LEG_INT_PTR_B31 (1 << 31)
1178 #define LEG_INT_PTR_B30 (1 << 30)
1179 #define PF_BITS_MASK (0xF << 16)
1182 * qla4_83xx_intr_handler - hardware interrupt handler.
1184 * @dev_id: Pointer to host adapter structure
1186 irqreturn_t qla4_83xx_intr_handler(int irq, void *dev_id)
1188 struct scsi_qla_host *ha = dev_id;
1189 uint32_t leg_int_ptr = 0;
1190 unsigned long flags = 0;
1193 leg_int_ptr = readl(&ha->qla4_83xx_reg->leg_int_ptr);
1195 /* Legacy interrupt is valid if bit31 of leg_int_ptr is set */
1196 if (!(leg_int_ptr & LEG_INT_PTR_B31)) {
1197 DEBUG7(ql4_printk(KERN_ERR, ha,
1198 "%s: Legacy Interrupt Bit 31 not set, spurious interrupt!\n",
1203 /* Validate the PCIE function ID set in leg_int_ptr bits [19..16] */
1204 if ((leg_int_ptr & PF_BITS_MASK) != ha->pf_bit) {
1205 DEBUG7(ql4_printk(KERN_ERR, ha,
1206 "%s: Incorrect function ID 0x%x in legacy interrupt register, ha->pf_bit = 0x%x\n",
1207 __func__, (leg_int_ptr & PF_BITS_MASK),
1212 /* To de-assert legacy interrupt, write 0 to Legacy Interrupt Trigger
1213 * Control register and poll till Legacy Interrupt Pointer register
1216 writel(0, &ha->qla4_83xx_reg->leg_int_trig);
1218 leg_int_ptr = readl(&ha->qla4_83xx_reg->leg_int_ptr);
1219 if ((leg_int_ptr & PF_BITS_MASK) != ha->pf_bit)
1221 } while (leg_int_ptr & LEG_INT_PTR_B30);
1223 spin_lock_irqsave(&ha->hardware_lock, flags);
1224 leg_int_ptr = readl(&ha->qla4_83xx_reg->risc_intr);
1225 ha->isp_ops->interrupt_service_routine(ha, leg_int_ptr);
1226 spin_unlock_irqrestore(&ha->hardware_lock, flags);
1232 qla4_8xxx_msi_handler(int irq, void *dev_id)
1234 struct scsi_qla_host *ha;
1236 ha = (struct scsi_qla_host *) dev_id;
1238 DEBUG2(printk(KERN_INFO
1239 "qla4xxx: MSIX: Interrupt with NULL host ptr\n"));
1244 /* clear the interrupt */
1245 qla4_82xx_wr_32(ha, ha->nx_legacy_intr.tgt_status_reg, 0xffffffff);
1247 /* read twice to ensure write is flushed */
1248 qla4_82xx_rd_32(ha, ISR_INT_VECTOR);
1249 qla4_82xx_rd_32(ha, ISR_INT_VECTOR);
1251 return qla4_8xxx_default_intr_handler(irq, dev_id);
1254 static irqreturn_t qla4_83xx_mailbox_intr_handler(int irq, void *dev_id)
1256 struct scsi_qla_host *ha = dev_id;
1257 unsigned long flags;
1260 spin_lock_irqsave(&ha->hardware_lock, flags);
1262 ival = readl(&ha->qla4_83xx_reg->risc_intr);
1264 ql4_printk(KERN_INFO, ha,
1265 "%s: It is a spurious mailbox interrupt!\n",
1267 ival = readl(&ha->qla4_83xx_reg->mb_int_mask);
1268 ival &= ~INT_MASK_FW_MB;
1269 writel(ival, &ha->qla4_83xx_reg->mb_int_mask);
1273 qla4xxx_isr_decode_mailbox(ha,
1274 readl(&ha->qla4_83xx_reg->mailbox_out[0]));
1275 writel(0, &ha->qla4_83xx_reg->risc_intr);
1276 ival = readl(&ha->qla4_83xx_reg->mb_int_mask);
1277 ival &= ~INT_MASK_FW_MB;
1278 writel(ival, &ha->qla4_83xx_reg->mb_int_mask);
1281 spin_unlock_irqrestore(&ha->hardware_lock, flags);
1286 * qla4_8xxx_default_intr_handler - hardware interrupt handler.
1288 * @dev_id: Pointer to host adapter structure
1290 * This interrupt handler is called directly for MSI-X, and
1291 * called indirectly for MSI.
1294 qla4_8xxx_default_intr_handler(int irq, void *dev_id)
1296 struct scsi_qla_host *ha = dev_id;
1297 unsigned long flags;
1298 uint32_t intr_status;
1299 uint8_t reqs_count = 0;
1301 if (is_qla8032(ha) || is_qla8042(ha)) {
1302 qla4_83xx_mailbox_intr_handler(irq, dev_id);
1304 spin_lock_irqsave(&ha->hardware_lock, flags);
1306 if (!(readl(&ha->qla4_82xx_reg->host_int) &
1307 ISRX_82XX_RISC_INT)) {
1308 qla4_82xx_spurious_interrupt(ha, reqs_count);
1312 intr_status = readl(&ha->qla4_82xx_reg->host_status);
1314 (HSRX_RISC_MB_INT | HSRX_RISC_IOCB_INT)) == 0) {
1315 qla4_82xx_spurious_interrupt(ha, reqs_count);
1319 ha->isp_ops->interrupt_service_routine(ha, intr_status);
1321 if (++reqs_count == MAX_REQS_SERVICED_PER_INTR)
1325 spin_unlock_irqrestore(&ha->hardware_lock, flags);
1331 qla4_8xxx_msix_rsp_q(int irq, void *dev_id)
1333 struct scsi_qla_host *ha = dev_id;
1334 unsigned long flags;
1337 spin_lock_irqsave(&ha->hardware_lock, flags);
1338 if (is_qla8032(ha) || is_qla8042(ha)) {
1339 ival = readl(&ha->qla4_83xx_reg->iocb_int_mask);
1341 ql4_printk(KERN_INFO, ha, "%s: It is a spurious iocb interrupt!\n",
1343 goto exit_msix_rsp_q;
1345 qla4xxx_process_response_queue(ha);
1346 writel(0, &ha->qla4_83xx_reg->iocb_int_mask);
1348 qla4xxx_process_response_queue(ha);
1349 writel(0, &ha->qla4_82xx_reg->host_int);
1353 spin_unlock_irqrestore(&ha->hardware_lock, flags);
1358 * qla4xxx_process_aen - processes AENs generated by firmware
1359 * @ha: pointer to host adapter structure.
1360 * @process_aen: type of AENs to process
1362 * Processes specific types of Asynchronous Events generated by firmware.
1363 * The type of AENs to process is specified by process_aen and can be
1364 * PROCESS_ALL_AENS 0
1365 * FLUSH_DDB_CHANGED_AENS 1
1366 * RELOGIN_DDB_CHANGED_AENS 2
1368 void qla4xxx_process_aen(struct scsi_qla_host * ha, uint8_t process_aen)
1370 uint32_t mbox_sts[MBOX_AEN_REG_COUNT];
1373 unsigned long flags;
1375 spin_lock_irqsave(&ha->hardware_lock, flags);
1376 while (ha->aen_out != ha->aen_in) {
1377 aen = &ha->aen_q[ha->aen_out];
1378 /* copy aen information to local structure */
1379 for (i = 0; i < MBOX_AEN_REG_COUNT; i++)
1380 mbox_sts[i] = aen->mbox_sts[i];
1385 if (ha->aen_out == MAX_AEN_ENTRIES)
1388 spin_unlock_irqrestore(&ha->hardware_lock, flags);
1390 DEBUG2(printk("qla4xxx(%ld): AEN[%d]=0x%08x, mbx1=0x%08x mbx2=0x%08x"
1391 " mbx3=0x%08x mbx4=0x%08x\n", ha->host_no,
1392 (ha->aen_out ? (ha->aen_out-1): (MAX_AEN_ENTRIES-1)),
1393 mbox_sts[0], mbox_sts[1], mbox_sts[2],
1394 mbox_sts[3], mbox_sts[4]));
1396 switch (mbox_sts[0]) {
1397 case MBOX_ASTS_DATABASE_CHANGED:
1398 switch (process_aen) {
1399 case FLUSH_DDB_CHANGED_AENS:
1400 DEBUG2(printk("scsi%ld: AEN[%d] %04x, index "
1401 "[%d] state=%04x FLUSHED!\n",
1402 ha->host_no, ha->aen_out,
1403 mbox_sts[0], mbox_sts[2],
1406 case PROCESS_ALL_AENS:
1408 /* Specific device. */
1409 if (mbox_sts[1] == 1)
1410 qla4xxx_process_ddb_changed(ha,
1411 mbox_sts[2], mbox_sts[3],
1416 spin_lock_irqsave(&ha->hardware_lock, flags);
1418 spin_unlock_irqrestore(&ha->hardware_lock, flags);
1421 int qla4xxx_request_irqs(struct scsi_qla_host *ha)
1428 if (ql4xenablemsix == 2) {
1429 /* Note: MSI Interrupts not supported for ISP8324 and ISP8042 */
1430 if (is_qla8032(ha) || is_qla8042(ha)) {
1431 ql4_printk(KERN_INFO, ha, "%s: MSI Interrupts not supported for ISP%04x, Falling back-to INTx mode\n",
1432 __func__, ha->pdev->device);
1438 if (ql4xenablemsix == 0 || ql4xenablemsix != 1)
1442 ret = qla4_8xxx_enable_msix(ha);
1444 DEBUG2(ql4_printk(KERN_INFO, ha,
1445 "MSI-X: Enabled (0x%X).\n", ha->revision_id));
1448 if (is_qla8032(ha) || is_qla8042(ha)) {
1449 ql4_printk(KERN_INFO, ha, "%s: ISP%04x: MSI-X: Falling back-to INTx mode. ret = %d\n",
1450 __func__, ha->pdev->device, ret);
1455 ql4_printk(KERN_WARNING, ha,
1456 "MSI-X: Falling back-to MSI mode -- %d.\n", ret);
1460 ret = pci_enable_msi(ha->pdev);
1462 ret = request_irq(ha->pdev->irq, qla4_8xxx_msi_handler,
1463 0, DRIVER_NAME, ha);
1465 DEBUG2(ql4_printk(KERN_INFO, ha, "MSI: Enabled.\n"));
1466 set_bit(AF_MSI_ENABLED, &ha->flags);
1469 ql4_printk(KERN_WARNING, ha,
1470 "MSI: Failed to reserve interrupt %d "
1471 "already in use.\n", ha->pdev->irq);
1472 pci_disable_msi(ha->pdev);
1477 * Prevent interrupts from falling back to INTx mode in cases where
1478 * interrupts cannot get acquired through MSI-X or MSI mode.
1480 if (is_qla8022(ha)) {
1481 ql4_printk(KERN_WARNING, ha, "IRQ not attached -- %d.\n", ret);
1482 goto irq_not_attached;
1486 ret = request_irq(ha->pdev->irq, ha->isp_ops->intr_handler,
1487 IRQF_SHARED, DRIVER_NAME, ha);
1489 DEBUG2(ql4_printk(KERN_INFO, ha, "INTx: Enabled.\n"));
1490 set_bit(AF_INTx_ENABLED, &ha->flags);
1494 ql4_printk(KERN_WARNING, ha,
1495 "INTx: Failed to reserve interrupt %d already in"
1496 " use.\n", ha->pdev->irq);
1497 goto irq_not_attached;
1501 set_bit(AF_IRQ_ATTACHED, &ha->flags);
1502 ha->host->irq = ha->pdev->irq;
1503 ql4_printk(KERN_INFO, ha, "%s: irq %d attached\n",
1504 __func__, ha->pdev->irq);
1509 void qla4xxx_free_irqs(struct scsi_qla_host *ha)
1511 if (test_and_clear_bit(AF_IRQ_ATTACHED, &ha->flags)) {
1512 if (test_bit(AF_MSIX_ENABLED, &ha->flags)) {
1513 qla4_8xxx_disable_msix(ha);
1514 } else if (test_and_clear_bit(AF_MSI_ENABLED, &ha->flags)) {
1515 free_irq(ha->pdev->irq, ha);
1516 pci_disable_msi(ha->pdev);
1517 } else if (test_and_clear_bit(AF_INTx_ENABLED, &ha->flags)) {
1518 free_irq(ha->pdev->irq, ha);