2 * QLogic iSCSI HBA Driver
3 * Copyright (c) 2003-2006 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);
31 /* Save total available sense length,
32 * not to exceed cmd's sense buffer size */
33 sense_len = min_t(uint16_t, sense_len, SCSI_SENSE_BUFFERSIZE);
34 srb->req_sense_ptr = cmd->sense_buffer;
35 srb->req_sense_len = sense_len;
37 /* Copy sense from sts_entry pkt */
38 sense_len = min_t(uint16_t, sense_len, IOCB_MAX_SENSEDATA_LEN);
39 memcpy(cmd->sense_buffer, sts_entry->senseData, sense_len);
41 DEBUG2(printk(KERN_INFO "scsi%ld:%d:%d:%d: %s: sense key = %x, "
42 "ASL= %02x, ASC/ASCQ = %02x/%02x\n", ha->host_no,
43 cmd->device->channel, cmd->device->id,
44 cmd->device->lun, __func__,
45 sts_entry->senseData[2] & 0x0f,
46 sts_entry->senseData[7],
47 sts_entry->senseData[12],
48 sts_entry->senseData[13]));
50 DEBUG5(qla4xxx_dump_buffer(cmd->sense_buffer, sense_len));
51 srb->flags |= SRB_GOT_SENSE;
53 /* Update srb, in case a sts_cont pkt follows */
54 srb->req_sense_ptr += sense_len;
55 srb->req_sense_len -= sense_len;
56 if (srb->req_sense_len != 0)
59 ha->status_srb = NULL;
63 * qla4xxx_status_cont_entry - Process a Status Continuations entry.
64 * @ha: SCSI driver HA context
65 * @sts_cont: Entry pointer
67 * Extended sense data.
70 qla4xxx_status_cont_entry(struct scsi_qla_host *ha,
71 struct status_cont_entry *sts_cont)
73 struct srb *srb = ha->status_srb;
74 struct scsi_cmnd *cmd;
82 DEBUG2(printk(KERN_INFO "scsi%ld: %s: Cmd already returned "
83 "back to OS srb=%p srb->state:%d\n", ha->host_no,
84 __func__, srb, srb->state));
85 ha->status_srb = NULL;
89 /* Copy sense data. */
90 sense_len = min_t(uint16_t, srb->req_sense_len,
91 IOCB_MAX_EXT_SENSEDATA_LEN);
92 memcpy(srb->req_sense_ptr, sts_cont->ext_sense_data, sense_len);
93 DEBUG5(qla4xxx_dump_buffer(srb->req_sense_ptr, sense_len));
95 srb->req_sense_ptr += sense_len;
96 srb->req_sense_len -= sense_len;
98 /* Place command on done queue. */
99 if (srb->req_sense_len == 0) {
100 kref_put(&srb->srb_ref, qla4xxx_srb_compl);
101 ha->status_srb = NULL;
106 * qla4xxx_status_entry - processes status IOCBs
107 * @ha: Pointer to host adapter structure.
108 * @sts_entry: Pointer to status entry structure.
110 static void qla4xxx_status_entry(struct scsi_qla_host *ha,
111 struct status_entry *sts_entry)
114 struct scsi_cmnd *cmd;
116 struct ddb_entry *ddb_entry;
119 srb = qla4xxx_del_from_active_array(ha, le32_to_cpu(sts_entry->handle));
121 /* FIXMEdg: Don't we need to reset ISP in this case??? */
122 DEBUG2(printk(KERN_WARNING "scsi%ld: %s: Status Entry invalid "
123 "handle 0x%x, sp=%p. This cmd may have already "
124 "been completed.\n", ha->host_no, __func__,
125 le32_to_cpu(sts_entry->handle), srb));
126 dev_warn(&ha->pdev->dev, "%s invalid status entry:"
127 " handle=0x%0x\n", __func__, sts_entry->handle);
128 set_bit(DPC_RESET_HA, &ha->dpc_flags);
134 DEBUG2(printk("scsi%ld: %s: Command already returned back to "
135 "OS pkt->handle=%d srb=%p srb->state:%d\n",
136 ha->host_no, __func__, sts_entry->handle,
138 dev_warn(&ha->pdev->dev, "Command is NULL:"
139 " already returned to OS (srb=%p)\n", srb);
143 ddb_entry = srb->ddb;
144 if (ddb_entry == NULL) {
145 cmd->result = DID_NO_CONNECT << 16;
146 goto status_entry_exit;
149 residual = le32_to_cpu(sts_entry->residualByteCnt);
151 /* Translate ISP error to a Linux SCSI error. */
152 scsi_status = sts_entry->scsiStatus;
153 switch (sts_entry->completionStatus) {
156 if (sts_entry->iscsiFlags & ISCSI_FLAG_RESIDUAL_OVER) {
157 cmd->result = DID_ERROR << 16;
161 if (sts_entry->iscsiFlags &ISCSI_FLAG_RESIDUAL_UNDER) {
162 scsi_set_resid(cmd, residual);
163 if (!scsi_status && ((scsi_bufflen(cmd) - residual) <
166 cmd->result = DID_ERROR << 16;
168 DEBUG2(printk("scsi%ld:%d:%d:%d: %s: "
169 "Mid-layer Data underrun0, "
171 "residual = 0x%x\n", ha->host_no,
172 cmd->device->channel,
174 cmd->device->lun, __func__,
175 scsi_bufflen(cmd), residual));
180 cmd->result = DID_OK << 16 | scsi_status;
182 if (scsi_status != SCSI_CHECK_CONDITION)
185 /* Copy Sense Data into sense buffer. */
186 qla4xxx_copy_sense(ha, sts_entry, srb);
190 /* Always set the status to DID_ERROR, since
191 * all conditions result in that status anyway */
192 cmd->result = DID_ERROR << 16;
195 case SCS_RESET_OCCURRED:
196 DEBUG2(printk("scsi%ld:%d:%d:%d: %s: Device RESET occurred\n",
197 ha->host_no, cmd->device->channel,
198 cmd->device->id, cmd->device->lun, __func__));
200 cmd->result = DID_RESET << 16;
204 DEBUG2(printk("scsi%ld:%d:%d:%d: %s: Abort occurred\n",
205 ha->host_no, cmd->device->channel,
206 cmd->device->id, cmd->device->lun, __func__));
208 cmd->result = DID_RESET << 16;
212 DEBUG2(printk(KERN_INFO "scsi%ld:%d:%d:%d: Timeout\n",
213 ha->host_no, cmd->device->channel,
214 cmd->device->id, cmd->device->lun));
216 cmd->result = DID_TRANSPORT_DISRUPTED << 16;
219 * Mark device missing so that we won't continue to send
220 * I/O to this device. We should get a ddb state change
223 if (atomic_read(&ddb_entry->state) == DDB_STATE_ONLINE)
224 qla4xxx_mark_device_missing(ha, ddb_entry);
227 case SCS_DATA_UNDERRUN:
228 case SCS_DATA_OVERRUN:
229 if ((sts_entry->iscsiFlags & ISCSI_FLAG_RESIDUAL_OVER) ||
230 (sts_entry->completionStatus == SCS_DATA_OVERRUN)) {
231 DEBUG2(printk("scsi%ld:%d:%d:%d: %s: " "Data overrun\n",
233 cmd->device->channel, cmd->device->id,
234 cmd->device->lun, __func__));
236 cmd->result = DID_ERROR << 16;
240 scsi_set_resid(cmd, residual);
243 * If there is scsi_status, it takes precedense over
244 * underflow condition.
246 if (scsi_status != 0) {
247 cmd->result = DID_OK << 16 | scsi_status;
249 if (scsi_status != SCSI_CHECK_CONDITION)
252 /* Copy Sense Data into sense buffer. */
253 qla4xxx_copy_sense(ha, sts_entry, srb);
256 * If RISC reports underrun and target does not
257 * report it then we must have a lost frame, so
258 * tell upper layer to retry it by reporting a
261 if ((sts_entry->iscsiFlags &
262 ISCSI_FLAG_RESIDUAL_UNDER) == 0) {
263 cmd->result = DID_BUS_BUSY << 16;
264 } else if ((scsi_bufflen(cmd) - residual) <
267 * Handle mid-layer underflow???
269 * For kernels less than 2.4, the driver must
270 * return an error if an underflow is detected.
271 * For kernels equal-to and above 2.4, the
272 * mid-layer will appearantly handle the
273 * underflow by detecting the residual count --
274 * unfortunately, we do not see where this is
275 * actually being done. In the interim, we
276 * will return DID_ERROR.
278 DEBUG2(printk("scsi%ld:%d:%d:%d: %s: "
279 "Mid-layer Data underrun1, "
281 "residual = 0x%x\n", ha->host_no,
282 cmd->device->channel,
284 cmd->device->lun, __func__,
285 scsi_bufflen(cmd), residual));
287 cmd->result = DID_ERROR << 16;
289 cmd->result = DID_OK << 16;
294 case SCS_DEVICE_LOGGED_OUT:
295 case SCS_DEVICE_UNAVAILABLE:
297 * Mark device missing so that we won't continue to
298 * send I/O to this device. We should get a ddb
299 * state change AEN soon.
301 if (atomic_read(&ddb_entry->state) == DDB_STATE_ONLINE)
302 qla4xxx_mark_device_missing(ha, ddb_entry);
304 cmd->result = DID_TRANSPORT_DISRUPTED << 16;
309 * SCSI Mid-Layer handles device queue full
311 cmd->result = DID_OK << 16 | sts_entry->scsiStatus;
312 DEBUG2(printk("scsi%ld:%d:%d: %s: QUEUE FULL detected "
313 "compl=%02x, scsi=%02x, state=%02x, iFlags=%02x,"
314 " iResp=%02x\n", ha->host_no, cmd->device->id,
315 cmd->device->lun, __func__,
316 sts_entry->completionStatus,
317 sts_entry->scsiStatus, sts_entry->state_flags,
318 sts_entry->iscsiFlags,
319 sts_entry->iscsiResponse));
323 cmd->result = DID_ERROR << 16;
329 /* complete the request, if not waiting for status_continuation pkt */
330 srb->cc_stat = sts_entry->completionStatus;
331 if (ha->status_srb == NULL)
332 kref_put(&srb->srb_ref, qla4xxx_srb_compl);
336 * qla4xxx_process_response_queue - process response queue completions
337 * @ha: Pointer to host adapter structure.
339 * This routine process response queue completions in interrupt context.
340 * Hardware_lock locked upon entry
342 static void qla4xxx_process_response_queue(struct scsi_qla_host * ha)
345 struct srb *srb = NULL;
346 struct status_entry *sts_entry;
348 /* Process all responses from response queue */
349 while ((ha->response_in =
350 (uint16_t)le32_to_cpu(ha->shadow_regs->rsp_q_in)) !=
352 sts_entry = (struct status_entry *) ha->response_ptr;
355 /* Advance pointers for next entry */
356 if (ha->response_out == (RESPONSE_QUEUE_DEPTH - 1)) {
357 ha->response_out = 0;
358 ha->response_ptr = ha->response_ring;
365 switch (sts_entry->hdr.entryType) {
368 qla4xxx_status_entry(ha, sts_entry);
371 case ET_PASSTHRU_STATUS:
374 case ET_STATUS_CONTINUATION:
375 qla4xxx_status_cont_entry(ha,
376 (struct status_cont_entry *) sts_entry);
380 /* ISP device queue is full. Command not
381 * accepted by ISP. Queue command for
384 srb = qla4xxx_del_from_active_array(ha,
385 le32_to_cpu(sts_entry->
388 goto exit_prq_invalid_handle;
390 DEBUG2(printk("scsi%ld: %s: FW device queue full, "
391 "srb %p\n", ha->host_no, __func__, srb));
393 /* ETRY normally by sending it back with
395 srb->cmd->result = DID_BUS_BUSY << 16;
396 kref_put(&srb->srb_ref, qla4xxx_srb_compl);
400 /* Just throw away the continuation entries */
401 DEBUG2(printk("scsi%ld: %s: Continuation entry - "
402 "ignoring\n", ha->host_no, __func__));
407 * Invalid entry in response queue, reset RISC
410 DEBUG2(printk("scsi%ld: %s: Invalid entry %x in "
411 "response queue \n", ha->host_no,
413 sts_entry->hdr.entryType));
419 * Done with responses, update the ISP For QLA4010, this also clears
422 writel(ha->response_out, &ha->reg->rsp_q_out);
423 readl(&ha->reg->rsp_q_out);
427 exit_prq_invalid_handle:
428 DEBUG2(printk("scsi%ld: %s: Invalid handle(srb)=%p type=%x IOCS=%x\n",
429 ha->host_no, __func__, srb, sts_entry->hdr.entryType,
430 sts_entry->completionStatus));
433 writel(ha->response_out, &ha->reg->rsp_q_out);
434 readl(&ha->reg->rsp_q_out);
436 set_bit(DPC_RESET_HA, &ha->dpc_flags);
440 * qla4xxx_isr_decode_mailbox - decodes mailbox status
441 * @ha: Pointer to host adapter structure.
442 * @mailbox_status: Mailbox status.
444 * This routine decodes the mailbox status during the ISR.
445 * Hardware_lock locked upon entry. runs in interrupt context.
447 static void qla4xxx_isr_decode_mailbox(struct scsi_qla_host * ha,
448 uint32_t mbox_status)
451 uint32_t mbox_stat2, mbox_stat3;
453 if ((mbox_status == MBOX_STS_BUSY) ||
454 (mbox_status == MBOX_STS_INTERMEDIATE_COMPLETION) ||
455 (mbox_status >> 12 == MBOX_COMPLETION_STATUS)) {
456 ha->mbox_status[0] = mbox_status;
458 if (test_bit(AF_MBOX_COMMAND, &ha->flags)) {
460 * Copy all mailbox registers to a temporary
461 * location and set mailbox command done flag
463 for (i = 1; i < ha->mbox_status_count; i++)
465 readl(&ha->reg->mailbox[i]);
467 set_bit(AF_MBOX_COMMAND_DONE, &ha->flags);
469 } else if (mbox_status >> 12 == MBOX_ASYNC_EVENT_STATUS) {
470 /* Immediately process the AENs that don't require much work.
471 * Only queue the database_changed AENs */
472 if (ha->aen_log.count < MAX_AEN_ENTRIES) {
473 for (i = 0; i < MBOX_AEN_REG_COUNT; i++)
474 ha->aen_log.entry[ha->aen_log.count].mbox_sts[i] =
475 readl(&ha->reg->mailbox[i]);
478 switch (mbox_status) {
479 case MBOX_ASTS_SYSTEM_ERROR:
480 /* Log Mailbox registers */
481 if (ql4xdontresethba) {
482 DEBUG2(printk("%s:Dont Reset HBA\n",
485 set_bit(AF_GET_CRASH_RECORD, &ha->flags);
486 set_bit(DPC_RESET_HA, &ha->dpc_flags);
490 case MBOX_ASTS_REQUEST_TRANSFER_ERROR:
491 case MBOX_ASTS_RESPONSE_TRANSFER_ERROR:
492 case MBOX_ASTS_NVRAM_INVALID:
493 case MBOX_ASTS_IP_ADDRESS_CHANGED:
494 case MBOX_ASTS_DHCP_LEASE_EXPIRED:
495 DEBUG2(printk("scsi%ld: AEN %04x, ERROR Status, "
496 "Reset HA\n", ha->host_no, mbox_status));
497 set_bit(DPC_RESET_HA, &ha->dpc_flags);
500 case MBOX_ASTS_LINK_UP:
501 set_bit(AF_LINK_UP, &ha->flags);
502 if (test_bit(AF_INIT_DONE, &ha->flags))
503 set_bit(DPC_LINK_CHANGED, &ha->dpc_flags);
505 DEBUG2(printk(KERN_INFO "scsi%ld: AEN %04x Adapter"
506 " LINK UP\n", ha->host_no,
510 case MBOX_ASTS_LINK_DOWN:
511 clear_bit(AF_LINK_UP, &ha->flags);
512 set_bit(DPC_LINK_CHANGED, &ha->dpc_flags);
514 DEBUG2(printk(KERN_INFO "scsi%ld: AEN %04x Adapter"
515 " LINK DOWN\n", ha->host_no,
519 case MBOX_ASTS_HEARTBEAT:
520 ha->seconds_since_last_heartbeat = 0;
523 case MBOX_ASTS_DHCP_LEASE_ACQUIRED:
524 DEBUG2(printk("scsi%ld: AEN %04x DHCP LEASE "
525 "ACQUIRED\n", ha->host_no, mbox_status));
526 set_bit(DPC_GET_DHCP_IP_ADDR, &ha->dpc_flags);
529 case MBOX_ASTS_PROTOCOL_STATISTIC_ALARM:
530 case MBOX_ASTS_SCSI_COMMAND_PDU_REJECTED: /* Target
533 case MBOX_ASTS_UNSOLICITED_PDU_RECEIVED: /* Connection mode */
534 case MBOX_ASTS_IPSEC_SYSTEM_FATAL_ERROR:
535 case MBOX_ASTS_SUBNET_STATE_CHANGE:
537 DEBUG2(printk("scsi%ld: AEN %04x\n", ha->host_no,
541 case MBOX_ASTS_IP_ADDR_STATE_CHANGED:
542 mbox_stat2 = readl(&ha->reg->mailbox[2]);
543 mbox_stat3 = readl(&ha->reg->mailbox[3]);
545 if ((mbox_stat3 == 5) && (mbox_stat2 == 3))
546 set_bit(DPC_GET_DHCP_IP_ADDR, &ha->dpc_flags);
547 else if ((mbox_stat3 == 2) && (mbox_stat2 == 5))
548 set_bit(DPC_RESET_HA, &ha->dpc_flags);
551 case MBOX_ASTS_MAC_ADDRESS_CHANGED:
554 DEBUG2(printk(KERN_INFO "scsi%ld: AEN %04x, "
555 "mbox_sts[1]=%04x, mbox_sts[2]=%04x\n",
556 ha->host_no, mbox_status,
557 readl(&ha->reg->mailbox[1]),
558 readl(&ha->reg->mailbox[2])));
561 case MBOX_ASTS_SELF_TEST_FAILED:
562 case MBOX_ASTS_LOGIN_FAILED:
564 DEBUG2(printk("scsi%ld: AEN %04x, mbox_sts[1]=%04x, "
565 "mbox_sts[2]=%04x, mbox_sts[3]=%04x\n",
566 ha->host_no, mbox_status,
567 readl(&ha->reg->mailbox[1]),
568 readl(&ha->reg->mailbox[2]),
569 readl(&ha->reg->mailbox[3])));
572 case MBOX_ASTS_DATABASE_CHANGED:
573 /* Queue AEN information and process it in the DPC
575 if (ha->aen_q_count > 0) {
577 /* decrement available counter */
580 for (i = 1; i < MBOX_AEN_REG_COUNT; i++)
581 ha->aen_q[ha->aen_in].mbox_sts[i] =
582 readl(&ha->reg->mailbox[i]);
584 ha->aen_q[ha->aen_in].mbox_sts[0] = mbox_status;
586 /* print debug message */
587 DEBUG2(printk("scsi%ld: AEN[%d] %04x queued"
588 " mb1:0x%x mb2:0x%x mb3:0x%x mb4:0x%x\n",
589 ha->host_no, ha->aen_in,
591 ha->aen_q[ha->aen_in].mbox_sts[1],
592 ha->aen_q[ha->aen_in].mbox_sts[2],
593 ha->aen_q[ha->aen_in].mbox_sts[3],
594 ha->aen_q[ha->aen_in]. mbox_sts[4]));
595 /* advance pointer */
597 if (ha->aen_in == MAX_AEN_ENTRIES)
600 /* The DPC routine will process the aen */
601 set_bit(DPC_AEN, &ha->dpc_flags);
603 DEBUG2(printk("scsi%ld: %s: aen %04x, queue "
604 "overflowed! AEN LOST!!\n",
605 ha->host_no, __func__,
608 DEBUG2(printk("scsi%ld: DUMP AEN QUEUE\n",
611 for (i = 0; i < MAX_AEN_ENTRIES; i++) {
612 DEBUG2(printk("AEN[%d] %04x %04x %04x "
614 ha->aen_q[i].mbox_sts[0],
615 ha->aen_q[i].mbox_sts[1],
616 ha->aen_q[i].mbox_sts[2],
617 ha->aen_q[i].mbox_sts[3]));
623 DEBUG2(printk(KERN_WARNING
624 "scsi%ld: AEN %04x UNKNOWN\n",
625 ha->host_no, mbox_status));
629 DEBUG2(printk("scsi%ld: Unknown mailbox status %08X\n",
630 ha->host_no, mbox_status));
632 ha->mbox_status[0] = mbox_status;
637 * qla4xxx_interrupt_service_routine - isr
638 * @ha: pointer to host adapter structure.
640 * This is the main interrupt service routine.
641 * hardware_lock locked upon entry. runs in interrupt context.
643 void qla4xxx_interrupt_service_routine(struct scsi_qla_host * ha,
644 uint32_t intr_status)
646 /* Process response queue interrupt. */
647 if (intr_status & CSR_SCSI_COMPLETION_INTR)
648 qla4xxx_process_response_queue(ha);
650 /* Process mailbox/asynch event interrupt.*/
651 if (intr_status & CSR_SCSI_PROCESSOR_INTR) {
652 qla4xxx_isr_decode_mailbox(ha,
653 readl(&ha->reg->mailbox[0]));
655 /* Clear Mailbox Interrupt */
656 writel(set_rmask(CSR_SCSI_PROCESSOR_INTR),
657 &ha->reg->ctrl_status);
658 readl(&ha->reg->ctrl_status);
663 * qla4xxx_intr_handler - hardware interrupt handler.
665 * @dev_id: Pointer to host adapter structure
667 irqreturn_t qla4xxx_intr_handler(int irq, void *dev_id)
669 struct scsi_qla_host *ha;
670 uint32_t intr_status;
671 unsigned long flags = 0;
672 uint8_t reqs_count = 0;
674 ha = (struct scsi_qla_host *) dev_id;
676 DEBUG2(printk(KERN_INFO
677 "qla4xxx: Interrupt with NULL host ptr\n"));
681 spin_lock_irqsave(&ha->hardware_lock, flags);
685 * Repeatedly service interrupts up to a maximum of
686 * MAX_REQS_SERVICED_PER_INTR
690 * Read interrupt status
692 if (le32_to_cpu(ha->shadow_regs->rsp_q_in) !=
694 intr_status = CSR_SCSI_COMPLETION_INTR;
696 intr_status = readl(&ha->reg->ctrl_status);
699 (CSR_SCSI_RESET_INTR|CSR_FATAL_ERROR|INTR_PENDING)) ==
702 ha->spurious_int_count++;
706 if (intr_status & CSR_FATAL_ERROR) {
707 DEBUG2(printk(KERN_INFO "scsi%ld: Fatal Error, "
708 "Status 0x%04x\n", ha->host_no,
709 readl(isp_port_error_status (ha))));
711 /* Issue Soft Reset to clear this error condition.
712 * This will prevent the RISC from repeatedly
713 * interrupting the driver; thus, allowing the DPC to
714 * get scheduled to continue error recovery.
715 * NOTE: Disabling RISC interrupts does not work in
716 * this case, as CSR_FATAL_ERROR overrides
717 * CSR_SCSI_INTR_ENABLE */
718 if ((readl(&ha->reg->ctrl_status) &
719 CSR_SCSI_RESET_INTR) == 0) {
720 writel(set_rmask(CSR_SOFT_RESET),
721 &ha->reg->ctrl_status);
722 readl(&ha->reg->ctrl_status);
725 writel(set_rmask(CSR_FATAL_ERROR),
726 &ha->reg->ctrl_status);
727 readl(&ha->reg->ctrl_status);
729 __qla4xxx_disable_intrs(ha);
731 set_bit(DPC_RESET_HA, &ha->dpc_flags);
734 } else if (intr_status & CSR_SCSI_RESET_INTR) {
735 clear_bit(AF_ONLINE, &ha->flags);
736 __qla4xxx_disable_intrs(ha);
738 writel(set_rmask(CSR_SCSI_RESET_INTR),
739 &ha->reg->ctrl_status);
740 readl(&ha->reg->ctrl_status);
743 set_bit(DPC_RESET_HA_INTR, &ha->dpc_flags);
746 } else if (intr_status & INTR_PENDING) {
747 qla4xxx_interrupt_service_routine(ha, intr_status);
748 ha->total_io_count++;
749 if (++reqs_count == MAX_REQS_SERVICED_PER_INTR)
756 spin_unlock_irqrestore(&ha->hardware_lock, flags);
762 * qla4xxx_process_aen - processes AENs generated by firmware
763 * @ha: pointer to host adapter structure.
764 * @process_aen: type of AENs to process
766 * Processes specific types of Asynchronous Events generated by firmware.
767 * The type of AENs to process is specified by process_aen and can be
769 * FLUSH_DDB_CHANGED_AENS 1
770 * RELOGIN_DDB_CHANGED_AENS 2
772 void qla4xxx_process_aen(struct scsi_qla_host * ha, uint8_t process_aen)
774 uint32_t mbox_sts[MBOX_AEN_REG_COUNT];
779 spin_lock_irqsave(&ha->hardware_lock, flags);
780 while (ha->aen_out != ha->aen_in) {
781 aen = &ha->aen_q[ha->aen_out];
782 /* copy aen information to local structure */
783 for (i = 0; i < MBOX_AEN_REG_COUNT; i++)
784 mbox_sts[i] = aen->mbox_sts[i];
789 if (ha->aen_out == MAX_AEN_ENTRIES)
792 spin_unlock_irqrestore(&ha->hardware_lock, flags);
794 DEBUG2(printk("qla4xxx(%ld): AEN[%d]=0x%08x, mbx1=0x%08x mbx2=0x%08x"
795 " mbx3=0x%08x mbx4=0x%08x\n", ha->host_no,
796 (ha->aen_out ? (ha->aen_out-1): (MAX_AEN_ENTRIES-1)),
797 mbox_sts[0], mbox_sts[1], mbox_sts[2],
798 mbox_sts[3], mbox_sts[4]));
800 switch (mbox_sts[0]) {
801 case MBOX_ASTS_DATABASE_CHANGED:
802 if (process_aen == FLUSH_DDB_CHANGED_AENS) {
803 DEBUG2(printk("scsi%ld: AEN[%d] %04x, index "
804 "[%d] state=%04x FLUSHED!\n",
805 ha->host_no, ha->aen_out,
806 mbox_sts[0], mbox_sts[2],
809 } else if (process_aen == RELOGIN_DDB_CHANGED_AENS) {
810 /* for use during init time, we only want to
811 * relogin non-active ddbs */
812 struct ddb_entry *ddb_entry;
815 /* FIXME: name length? */
816 qla4xxx_lookup_ddb_by_fw_index(ha,
821 ddb_entry->dev_scan_wait_to_complete_relogin =
823 ddb_entry->dev_scan_wait_to_start_relogin =
825 ((ddb_entry->default_time2wait +
828 DEBUG2(printk("scsi%ld: ddb index [%d] initate"
829 " RELOGIN after %d seconds\n",
831 ddb_entry->fw_ddb_index,
832 ddb_entry->default_time2wait +
837 if (mbox_sts[1] == 0) { /* Global DB change. */
838 qla4xxx_reinitialize_ddb_list(ha);
839 } else if (mbox_sts[1] == 1) { /* Specific device. */
840 qla4xxx_process_ddb_changed(ha, mbox_sts[2],
841 mbox_sts[3], mbox_sts[4]);
845 spin_lock_irqsave(&ha->hardware_lock, flags);
847 spin_unlock_irqrestore(&ha->hardware_lock, flags);