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 * qla2x00_process_completed_request() - Process a Fast Post response.
15 * @ha: SCSI driver HA context
18 static void qla4xxx_process_completed_request(struct scsi_qla_host *ha,
23 srb = qla4xxx_del_from_active_array(ha, index);
25 /* Save ISP completion status */
26 srb->cmd->result = DID_OK << 16;
27 qla4xxx_srb_compl(ha, srb);
29 DEBUG2(printk("scsi%ld: Invalid ISP SCSI completion handle = "
30 "%d\n", ha->host_no, index));
31 set_bit(DPC_RESET_HA, &ha->dpc_flags);
36 * qla4xxx_status_entry - processes status IOCBs
37 * @ha: Pointer to host adapter structure.
38 * @sts_entry: Pointer to status entry structure.
40 static void qla4xxx_status_entry(struct scsi_qla_host *ha,
41 struct status_entry *sts_entry)
44 struct scsi_cmnd *cmd;
46 struct ddb_entry *ddb_entry;
48 uint16_t sensebytecnt;
50 if (sts_entry->completionStatus == SCS_COMPLETE &&
51 sts_entry->scsiStatus == 0) {
52 qla4xxx_process_completed_request(ha,
53 le32_to_cpu(sts_entry->
58 srb = qla4xxx_del_from_active_array(ha, le32_to_cpu(sts_entry->handle));
60 /* FIXMEdg: Don't we need to reset ISP in this case??? */
61 DEBUG2(printk(KERN_WARNING "scsi%ld: %s: Status Entry invalid "
62 "handle 0x%x, sp=%p. This cmd may have already "
63 "been completed.\n", ha->host_no, __func__,
64 le32_to_cpu(sts_entry->handle), srb));
70 DEBUG2(printk("scsi%ld: %s: Command already returned back to "
71 "OS pkt->handle=%d srb=%p srb->state:%d\n",
72 ha->host_no, __func__, sts_entry->handle,
74 dev_warn(&ha->pdev->dev, "Command is NULL:"
75 " already returned to OS (srb=%p)\n", srb);
80 if (ddb_entry == NULL) {
81 cmd->result = DID_NO_CONNECT << 16;
82 goto status_entry_exit;
85 residual = le32_to_cpu(sts_entry->residualByteCnt);
87 /* Translate ISP error to a Linux SCSI error. */
88 scsi_status = sts_entry->scsiStatus;
89 switch (sts_entry->completionStatus) {
91 if (scsi_status == 0) {
92 cmd->result = DID_OK << 16;
96 if (sts_entry->iscsiFlags &
97 (ISCSI_FLAG_RESIDUAL_OVER|ISCSI_FLAG_RESIDUAL_UNDER))
98 scsi_set_resid(cmd, residual);
100 cmd->result = DID_OK << 16 | scsi_status;
102 if (scsi_status != SCSI_CHECK_CONDITION)
105 /* Copy Sense Data into sense buffer. */
106 memset(cmd->sense_buffer, 0, sizeof(cmd->sense_buffer));
108 sensebytecnt = le16_to_cpu(sts_entry->senseDataByteCnt);
109 if (sensebytecnt == 0)
112 memcpy(cmd->sense_buffer, sts_entry->senseData,
114 (uint16_t) sizeof(cmd->sense_buffer)));
116 DEBUG2(printk("scsi%ld:%d:%d:%d: %s: sense key = %x, "
117 "ASC/ASCQ = %02x/%02x\n", ha->host_no,
118 cmd->device->channel, cmd->device->id,
119 cmd->device->lun, __func__,
120 sts_entry->senseData[2] & 0x0f,
121 sts_entry->senseData[12],
122 sts_entry->senseData[13]));
124 srb->flags |= SRB_GOT_SENSE;
128 /* Always set the status to DID_ERROR, since
129 * all conditions result in that status anyway */
130 cmd->result = DID_ERROR << 16;
133 case SCS_RESET_OCCURRED:
134 DEBUG2(printk("scsi%ld:%d:%d:%d: %s: Device RESET occurred\n",
135 ha->host_no, cmd->device->channel,
136 cmd->device->id, cmd->device->lun, __func__));
138 cmd->result = DID_RESET << 16;
142 DEBUG2(printk("scsi%ld:%d:%d:%d: %s: Abort occurred\n",
143 ha->host_no, cmd->device->channel,
144 cmd->device->id, cmd->device->lun, __func__));
146 cmd->result = DID_RESET << 16;
150 DEBUG2(printk(KERN_INFO "scsi%ld:%d:%d:%d: Timeout\n",
151 ha->host_no, cmd->device->channel,
152 cmd->device->id, cmd->device->lun));
154 cmd->result = DID_BUS_BUSY << 16;
157 * Mark device missing so that we won't continue to send
158 * I/O to this device. We should get a ddb state change
161 if (atomic_read(&ddb_entry->state) == DDB_STATE_ONLINE)
162 qla4xxx_mark_device_missing(ha, ddb_entry);
165 case SCS_DATA_UNDERRUN:
166 case SCS_DATA_OVERRUN:
167 if (sts_entry->iscsiFlags & ISCSI_FLAG_RESIDUAL_OVER) {
168 DEBUG2(printk("scsi%ld:%d:%d:%d: %s: " "Data overrun, "
169 "residual = 0x%x\n", ha->host_no,
170 cmd->device->channel, cmd->device->id,
171 cmd->device->lun, __func__, residual));
173 cmd->result = DID_ERROR << 16;
177 if ((sts_entry->iscsiFlags & ISCSI_FLAG_RESIDUAL_UNDER) == 0) {
179 * Firmware detected a SCSI transport underrun
182 scsi_set_resid(cmd, residual);
183 DEBUG2(printk("scsi%ld:%d:%d:%d: %s: UNDERRUN status "
184 "detected, xferlen = 0x%x, residual = "
186 ha->host_no, cmd->device->channel,
188 cmd->device->lun, __func__,
194 * If there is scsi_status, it takes precedense over
195 * underflow condition.
197 if (scsi_status != 0) {
198 cmd->result = DID_OK << 16 | scsi_status;
200 if (scsi_status != SCSI_CHECK_CONDITION)
203 /* Copy Sense Data into sense buffer. */
204 memset(cmd->sense_buffer, 0,
205 sizeof(cmd->sense_buffer));
208 le16_to_cpu(sts_entry->senseDataByteCnt);
209 if (sensebytecnt == 0)
212 memcpy(cmd->sense_buffer, sts_entry->senseData,
214 (uint16_t) sizeof(cmd->sense_buffer)));
216 DEBUG2(printk("scsi%ld:%d:%d:%d: %s: sense key = %x, "
217 "ASC/ASCQ = %02x/%02x\n", ha->host_no,
218 cmd->device->channel, cmd->device->id,
219 cmd->device->lun, __func__,
220 sts_entry->senseData[2] & 0x0f,
221 sts_entry->senseData[12],
222 sts_entry->senseData[13]));
225 * If RISC reports underrun and target does not
226 * report it then we must have a lost frame, so
227 * tell upper layer to retry it by reporting a
230 if ((sts_entry->iscsiFlags &
231 ISCSI_FLAG_RESIDUAL_UNDER) == 0) {
232 cmd->result = DID_BUS_BUSY << 16;
233 } else if ((scsi_bufflen(cmd) - residual) <
236 * Handle mid-layer underflow???
238 * For kernels less than 2.4, the driver must
239 * return an error if an underflow is detected.
240 * For kernels equal-to and above 2.4, the
241 * mid-layer will appearantly handle the
242 * underflow by detecting the residual count --
243 * unfortunately, we do not see where this is
244 * actually being done. In the interim, we
245 * will return DID_ERROR.
247 DEBUG2(printk("scsi%ld:%d:%d:%d: %s: "
248 "Mid-layer Data underrun, "
250 "residual = 0x%x\n", ha->host_no,
251 cmd->device->channel,
253 cmd->device->lun, __func__,
254 scsi_bufflen(cmd), residual));
256 cmd->result = DID_ERROR << 16;
258 cmd->result = DID_OK << 16;
263 case SCS_DEVICE_LOGGED_OUT:
264 case SCS_DEVICE_UNAVAILABLE:
266 * Mark device missing so that we won't continue to
267 * send I/O to this device. We should get a ddb
268 * state change AEN soon.
270 if (atomic_read(&ddb_entry->state) == DDB_STATE_ONLINE)
271 qla4xxx_mark_device_missing(ha, ddb_entry);
273 cmd->result = DID_BUS_BUSY << 16;
278 * SCSI Mid-Layer handles device queue full
280 cmd->result = DID_OK << 16 | sts_entry->scsiStatus;
281 DEBUG2(printk("scsi%ld:%d:%d: %s: QUEUE FULL detected "
282 "compl=%02x, scsi=%02x, state=%02x, iFlags=%02x,"
283 " iResp=%02x\n", ha->host_no, cmd->device->id,
284 cmd->device->lun, __func__,
285 sts_entry->completionStatus,
286 sts_entry->scsiStatus, sts_entry->state_flags,
287 sts_entry->iscsiFlags,
288 sts_entry->iscsiResponse));
292 cmd->result = DID_ERROR << 16;
298 /* complete the request */
299 srb->cc_stat = sts_entry->completionStatus;
300 qla4xxx_srb_compl(ha, srb);
304 * qla4xxx_process_response_queue - process response queue completions
305 * @ha: Pointer to host adapter structure.
307 * This routine process response queue completions in interrupt context.
308 * Hardware_lock locked upon entry
310 static void qla4xxx_process_response_queue(struct scsi_qla_host * ha)
313 struct srb *srb = NULL;
314 struct status_entry *sts_entry;
316 /* Process all responses from response queue */
317 while ((ha->response_in =
318 (uint16_t)le32_to_cpu(ha->shadow_regs->rsp_q_in)) !=
320 sts_entry = (struct status_entry *) ha->response_ptr;
323 /* Advance pointers for next entry */
324 if (ha->response_out == (RESPONSE_QUEUE_DEPTH - 1)) {
325 ha->response_out = 0;
326 ha->response_ptr = ha->response_ring;
333 switch (sts_entry->hdr.entryType) {
336 * Common status - Single completion posted in single
339 qla4xxx_status_entry(ha, sts_entry);
342 case ET_PASSTHRU_STATUS:
345 case ET_STATUS_CONTINUATION:
346 /* Just throw away the status continuation entries */
347 DEBUG2(printk("scsi%ld: %s: Status Continuation entry "
348 "- ignoring\n", ha->host_no, __func__));
352 /* ISP device queue is full. Command not
353 * accepted by ISP. Queue command for
356 srb = qla4xxx_del_from_active_array(ha,
357 le32_to_cpu(sts_entry->
360 goto exit_prq_invalid_handle;
362 DEBUG2(printk("scsi%ld: %s: FW device queue full, "
363 "srb %p\n", ha->host_no, __func__, srb));
365 /* ETRY normally by sending it back with
367 srb->cmd->result = DID_BUS_BUSY << 16;
368 qla4xxx_srb_compl(ha, srb);
372 /* Just throw away the continuation entries */
373 DEBUG2(printk("scsi%ld: %s: Continuation entry - "
374 "ignoring\n", ha->host_no, __func__));
379 * Invalid entry in response queue, reset RISC
382 DEBUG2(printk("scsi%ld: %s: Invalid entry %x in "
383 "response queue \n", ha->host_no,
385 sts_entry->hdr.entryType));
391 * Done with responses, update the ISP For QLA4010, this also clears
394 writel(ha->response_out, &ha->reg->rsp_q_out);
395 readl(&ha->reg->rsp_q_out);
399 exit_prq_invalid_handle:
400 DEBUG2(printk("scsi%ld: %s: Invalid handle(srb)=%p type=%x IOCS=%x\n",
401 ha->host_no, __func__, srb, sts_entry->hdr.entryType,
402 sts_entry->completionStatus));
405 writel(ha->response_out, &ha->reg->rsp_q_out);
406 readl(&ha->reg->rsp_q_out);
408 set_bit(DPC_RESET_HA, &ha->dpc_flags);
412 * qla4xxx_isr_decode_mailbox - decodes mailbox status
413 * @ha: Pointer to host adapter structure.
414 * @mailbox_status: Mailbox status.
416 * This routine decodes the mailbox status during the ISR.
417 * Hardware_lock locked upon entry. runs in interrupt context.
419 static void qla4xxx_isr_decode_mailbox(struct scsi_qla_host * ha,
420 uint32_t mbox_status)
423 uint32_t mbox_stat2, mbox_stat3;
425 if ((mbox_status == MBOX_STS_BUSY) ||
426 (mbox_status == MBOX_STS_INTERMEDIATE_COMPLETION) ||
427 (mbox_status >> 12 == MBOX_COMPLETION_STATUS)) {
428 ha->mbox_status[0] = mbox_status;
430 if (test_bit(AF_MBOX_COMMAND, &ha->flags)) {
432 * Copy all mailbox registers to a temporary
433 * location and set mailbox command done flag
435 for (i = 1; i < ha->mbox_status_count; i++)
437 readl(&ha->reg->mailbox[i]);
439 set_bit(AF_MBOX_COMMAND_DONE, &ha->flags);
441 } else if (mbox_status >> 12 == MBOX_ASYNC_EVENT_STATUS) {
442 /* Immediately process the AENs that don't require much work.
443 * Only queue the database_changed AENs */
444 if (ha->aen_log.count < MAX_AEN_ENTRIES) {
445 for (i = 0; i < MBOX_AEN_REG_COUNT; i++)
446 ha->aen_log.entry[ha->aen_log.count].mbox_sts[i] =
447 readl(&ha->reg->mailbox[i]);
450 switch (mbox_status) {
451 case MBOX_ASTS_SYSTEM_ERROR:
452 /* Log Mailbox registers */
453 if (ql4xdontresethba) {
454 DEBUG2(printk("%s:Dont Reset HBA\n",
457 set_bit(AF_GET_CRASH_RECORD, &ha->flags);
458 set_bit(DPC_RESET_HA, &ha->dpc_flags);
462 case MBOX_ASTS_REQUEST_TRANSFER_ERROR:
463 case MBOX_ASTS_RESPONSE_TRANSFER_ERROR:
464 case MBOX_ASTS_NVRAM_INVALID:
465 case MBOX_ASTS_IP_ADDRESS_CHANGED:
466 case MBOX_ASTS_DHCP_LEASE_EXPIRED:
467 DEBUG2(printk("scsi%ld: AEN %04x, ERROR Status, "
468 "Reset HA\n", ha->host_no, mbox_status));
469 set_bit(DPC_RESET_HA, &ha->dpc_flags);
472 case MBOX_ASTS_LINK_UP:
473 DEBUG2(printk("scsi%ld: AEN %04x Adapter LINK UP\n",
474 ha->host_no, mbox_status));
475 set_bit(AF_LINK_UP, &ha->flags);
478 case MBOX_ASTS_LINK_DOWN:
479 DEBUG2(printk("scsi%ld: AEN %04x Adapter LINK DOWN\n",
480 ha->host_no, mbox_status));
481 clear_bit(AF_LINK_UP, &ha->flags);
484 case MBOX_ASTS_HEARTBEAT:
485 ha->seconds_since_last_heartbeat = 0;
488 case MBOX_ASTS_DHCP_LEASE_ACQUIRED:
489 DEBUG2(printk("scsi%ld: AEN %04x DHCP LEASE "
490 "ACQUIRED\n", ha->host_no, mbox_status));
491 set_bit(DPC_GET_DHCP_IP_ADDR, &ha->dpc_flags);
494 case MBOX_ASTS_PROTOCOL_STATISTIC_ALARM:
495 case MBOX_ASTS_SCSI_COMMAND_PDU_REJECTED: /* Target
498 case MBOX_ASTS_UNSOLICITED_PDU_RECEIVED: /* Connection mode */
499 case MBOX_ASTS_IPSEC_SYSTEM_FATAL_ERROR:
500 case MBOX_ASTS_SUBNET_STATE_CHANGE:
502 DEBUG2(printk("scsi%ld: AEN %04x\n", ha->host_no,
506 case MBOX_ASTS_IP_ADDR_STATE_CHANGED:
507 mbox_stat2 = readl(&ha->reg->mailbox[2]);
508 mbox_stat3 = readl(&ha->reg->mailbox[3]);
510 if ((mbox_stat3 == 5) && (mbox_stat2 == 3))
511 set_bit(DPC_GET_DHCP_IP_ADDR, &ha->dpc_flags);
512 else if ((mbox_stat3 == 2) && (mbox_stat2 == 5))
513 set_bit(DPC_RESET_HA, &ha->dpc_flags);
516 case MBOX_ASTS_MAC_ADDRESS_CHANGED:
519 DEBUG2(printk(KERN_INFO "scsi%ld: AEN %04x, "
520 "mbox_sts[1]=%04x, mbox_sts[2]=%04x\n",
521 ha->host_no, mbox_status,
522 readl(&ha->reg->mailbox[1]),
523 readl(&ha->reg->mailbox[2])));
526 case MBOX_ASTS_SELF_TEST_FAILED:
527 case MBOX_ASTS_LOGIN_FAILED:
529 DEBUG2(printk("scsi%ld: AEN %04x, mbox_sts[1]=%04x, "
530 "mbox_sts[2]=%04x, mbox_sts[3]=%04x\n",
531 ha->host_no, mbox_status,
532 readl(&ha->reg->mailbox[1]),
533 readl(&ha->reg->mailbox[2]),
534 readl(&ha->reg->mailbox[3])));
537 case MBOX_ASTS_DATABASE_CHANGED:
538 /* Queue AEN information and process it in the DPC
540 if (ha->aen_q_count > 0) {
542 /* decrement available counter */
545 for (i = 1; i < MBOX_AEN_REG_COUNT; i++)
546 ha->aen_q[ha->aen_in].mbox_sts[i] =
547 readl(&ha->reg->mailbox[i]);
549 ha->aen_q[ha->aen_in].mbox_sts[0] = mbox_status;
551 /* print debug message */
552 DEBUG2(printk("scsi%ld: AEN[%d] %04x queued"
553 " mb1:0x%x mb2:0x%x mb3:0x%x mb4:0x%x\n",
554 ha->host_no, ha->aen_in,
556 ha->aen_q[ha->aen_in].mbox_sts[1],
557 ha->aen_q[ha->aen_in].mbox_sts[2],
558 ha->aen_q[ha->aen_in].mbox_sts[3],
559 ha->aen_q[ha->aen_in]. mbox_sts[4]));
560 /* advance pointer */
562 if (ha->aen_in == MAX_AEN_ENTRIES)
565 /* The DPC routine will process the aen */
566 set_bit(DPC_AEN, &ha->dpc_flags);
568 DEBUG2(printk("scsi%ld: %s: aen %04x, queue "
569 "overflowed! AEN LOST!!\n",
570 ha->host_no, __func__,
573 DEBUG2(printk("scsi%ld: DUMP AEN QUEUE\n",
576 for (i = 0; i < MAX_AEN_ENTRIES; i++) {
577 DEBUG2(printk("AEN[%d] %04x %04x %04x "
579 ha->aen_q[i].mbox_sts[0],
580 ha->aen_q[i].mbox_sts[1],
581 ha->aen_q[i].mbox_sts[2],
582 ha->aen_q[i].mbox_sts[3]));
588 DEBUG2(printk(KERN_WARNING
589 "scsi%ld: AEN %04x UNKNOWN\n",
590 ha->host_no, mbox_status));
594 DEBUG2(printk("scsi%ld: Unknown mailbox status %08X\n",
595 ha->host_no, mbox_status));
597 ha->mbox_status[0] = mbox_status;
602 * qla4xxx_interrupt_service_routine - isr
603 * @ha: pointer to host adapter structure.
605 * This is the main interrupt service routine.
606 * hardware_lock locked upon entry. runs in interrupt context.
608 void qla4xxx_interrupt_service_routine(struct scsi_qla_host * ha,
609 uint32_t intr_status)
611 /* Process response queue interrupt. */
612 if (intr_status & CSR_SCSI_COMPLETION_INTR)
613 qla4xxx_process_response_queue(ha);
615 /* Process mailbox/asynch event interrupt.*/
616 if (intr_status & CSR_SCSI_PROCESSOR_INTR) {
617 qla4xxx_isr_decode_mailbox(ha,
618 readl(&ha->reg->mailbox[0]));
620 /* Clear Mailbox Interrupt */
621 writel(set_rmask(CSR_SCSI_PROCESSOR_INTR),
622 &ha->reg->ctrl_status);
623 readl(&ha->reg->ctrl_status);
628 * qla4xxx_intr_handler - hardware interrupt handler.
630 * @dev_id: Pointer to host adapter structure
632 irqreturn_t qla4xxx_intr_handler(int irq, void *dev_id)
634 struct scsi_qla_host *ha;
635 uint32_t intr_status;
636 unsigned long flags = 0;
637 uint8_t reqs_count = 0;
639 ha = (struct scsi_qla_host *) dev_id;
641 DEBUG2(printk(KERN_INFO
642 "qla4xxx: Interrupt with NULL host ptr\n"));
646 spin_lock_irqsave(&ha->hardware_lock, flags);
650 * Repeatedly service interrupts up to a maximum of
651 * MAX_REQS_SERVICED_PER_INTR
655 * Read interrupt status
657 if (le32_to_cpu(ha->shadow_regs->rsp_q_in) !=
659 intr_status = CSR_SCSI_COMPLETION_INTR;
661 intr_status = readl(&ha->reg->ctrl_status);
664 (CSR_SCSI_RESET_INTR|CSR_FATAL_ERROR|INTR_PENDING)) ==
667 ha->spurious_int_count++;
671 if (intr_status & CSR_FATAL_ERROR) {
672 DEBUG2(printk(KERN_INFO "scsi%ld: Fatal Error, "
673 "Status 0x%04x\n", ha->host_no,
674 readl(isp_port_error_status (ha))));
676 /* Issue Soft Reset to clear this error condition.
677 * This will prevent the RISC from repeatedly
678 * interrupting the driver; thus, allowing the DPC to
679 * get scheduled to continue error recovery.
680 * NOTE: Disabling RISC interrupts does not work in
681 * this case, as CSR_FATAL_ERROR overrides
682 * CSR_SCSI_INTR_ENABLE */
683 if ((readl(&ha->reg->ctrl_status) &
684 CSR_SCSI_RESET_INTR) == 0) {
685 writel(set_rmask(CSR_SOFT_RESET),
686 &ha->reg->ctrl_status);
687 readl(&ha->reg->ctrl_status);
690 writel(set_rmask(CSR_FATAL_ERROR),
691 &ha->reg->ctrl_status);
692 readl(&ha->reg->ctrl_status);
694 __qla4xxx_disable_intrs(ha);
696 set_bit(DPC_RESET_HA, &ha->dpc_flags);
699 } else if (intr_status & CSR_SCSI_RESET_INTR) {
700 clear_bit(AF_ONLINE, &ha->flags);
701 __qla4xxx_disable_intrs(ha);
703 writel(set_rmask(CSR_SCSI_RESET_INTR),
704 &ha->reg->ctrl_status);
705 readl(&ha->reg->ctrl_status);
708 set_bit(DPC_RESET_HA_INTR, &ha->dpc_flags);
711 } else if (intr_status & INTR_PENDING) {
712 qla4xxx_interrupt_service_routine(ha, intr_status);
713 ha->total_io_count++;
714 if (++reqs_count == MAX_REQS_SERVICED_PER_INTR)
721 spin_unlock_irqrestore(&ha->hardware_lock, flags);
727 * qla4xxx_process_aen - processes AENs generated by firmware
728 * @ha: pointer to host adapter structure.
729 * @process_aen: type of AENs to process
731 * Processes specific types of Asynchronous Events generated by firmware.
732 * The type of AENs to process is specified by process_aen and can be
734 * FLUSH_DDB_CHANGED_AENS 1
735 * RELOGIN_DDB_CHANGED_AENS 2
737 void qla4xxx_process_aen(struct scsi_qla_host * ha, uint8_t process_aen)
739 uint32_t mbox_sts[MBOX_AEN_REG_COUNT];
744 spin_lock_irqsave(&ha->hardware_lock, flags);
745 while (ha->aen_out != ha->aen_in) {
746 aen = &ha->aen_q[ha->aen_out];
747 /* copy aen information to local structure */
748 for (i = 0; i < MBOX_AEN_REG_COUNT; i++)
749 mbox_sts[i] = aen->mbox_sts[i];
754 if (ha->aen_out == MAX_AEN_ENTRIES)
757 spin_unlock_irqrestore(&ha->hardware_lock, flags);
759 DEBUG2(printk("qla4xxx(%ld): AEN[%d]=0x%08x, mbx1=0x%08x mbx2=0x%08x"
760 " mbx3=0x%08x mbx4=0x%08x\n", ha->host_no,
761 (ha->aen_out ? (ha->aen_out-1): (MAX_AEN_ENTRIES-1)),
762 mbox_sts[0], mbox_sts[1], mbox_sts[2],
763 mbox_sts[3], mbox_sts[4]));
765 switch (mbox_sts[0]) {
766 case MBOX_ASTS_DATABASE_CHANGED:
767 if (process_aen == FLUSH_DDB_CHANGED_AENS) {
768 DEBUG2(printk("scsi%ld: AEN[%d] %04x, index "
769 "[%d] state=%04x FLUSHED!\n",
770 ha->host_no, ha->aen_out,
771 mbox_sts[0], mbox_sts[2],
774 } else if (process_aen == RELOGIN_DDB_CHANGED_AENS) {
775 /* for use during init time, we only want to
776 * relogin non-active ddbs */
777 struct ddb_entry *ddb_entry;
780 /* FIXME: name length? */
781 qla4xxx_lookup_ddb_by_fw_index(ha,
786 ddb_entry->dev_scan_wait_to_complete_relogin =
788 ddb_entry->dev_scan_wait_to_start_relogin =
790 ((ddb_entry->default_time2wait +
793 DEBUG2(printk("scsi%ld: ddb index [%d] initate"
794 " RELOGIN after %d seconds\n",
796 ddb_entry->fw_ddb_index,
797 ddb_entry->default_time2wait +
802 if (mbox_sts[1] == 0) { /* Global DB change. */
803 qla4xxx_reinitialize_ddb_list(ha);
804 } else if (mbox_sts[1] == 1) { /* Specific device. */
805 qla4xxx_process_ddb_changed(ha, mbox_sts[2],
810 spin_lock_irqsave(&ha->hardware_lock, flags);
812 spin_unlock_irqrestore(&ha->hardware_lock, flags);