2 * QLogic iSCSI HBA Driver
3 * Copyright (c) 2003-2006 QLogic Corporation
5 * See LICENSE.qla4xxx for copyright and licensing details.
11 * qla2x00_process_completed_request() - Process a Fast Post response.
12 * @ha: SCSI driver HA context
15 static void qla4xxx_process_completed_request(struct scsi_qla_host
*ha
,
20 srb
= qla4xxx_del_from_active_array(ha
, index
);
22 /* Save ISP completion status */
23 srb
->cmd
->result
= DID_OK
<< 16;
24 qla4xxx_srb_compl(ha
, srb
);
26 DEBUG2(printk("scsi%ld: Invalid ISP SCSI completion handle = "
27 "%d\n", ha
->host_no
, index
));
28 set_bit(DPC_RESET_HA
, &ha
->dpc_flags
);
33 * qla4xxx_status_entry - processes status IOCBs
34 * @ha: Pointer to host adapter structure.
35 * @sts_entry: Pointer to status entry structure.
37 static void qla4xxx_status_entry(struct scsi_qla_host
*ha
,
38 struct status_entry
*sts_entry
)
41 struct scsi_cmnd
*cmd
;
43 struct ddb_entry
*ddb_entry
;
45 uint16_t sensebytecnt
;
47 if (sts_entry
->completionStatus
== SCS_COMPLETE
&&
48 sts_entry
->scsiStatus
== 0) {
49 qla4xxx_process_completed_request(ha
,
50 le32_to_cpu(sts_entry
->
55 srb
= qla4xxx_del_from_active_array(ha
, le32_to_cpu(sts_entry
->handle
));
57 /* FIXMEdg: Don't we need to reset ISP in this case??? */
58 DEBUG2(printk(KERN_WARNING
"scsi%ld: %s: Status Entry invalid "
59 "handle 0x%x, sp=%p. This cmd may have already "
60 "been completed.\n", ha
->host_no
, __func__
,
61 le32_to_cpu(sts_entry
->handle
), srb
));
67 DEBUG2(printk("scsi%ld: %s: Command already returned back to "
68 "OS pkt->handle=%d srb=%p srb->state:%d\n",
69 ha
->host_no
, __func__
, sts_entry
->handle
,
71 dev_warn(&ha
->pdev
->dev
, "Command is NULL:"
72 " already returned to OS (srb=%p)\n", srb
);
77 if (ddb_entry
== NULL
) {
78 cmd
->result
= DID_NO_CONNECT
<< 16;
79 goto status_entry_exit
;
82 residual
= le32_to_cpu(sts_entry
->residualByteCnt
);
84 /* Translate ISP error to a Linux SCSI error. */
85 scsi_status
= sts_entry
->scsiStatus
;
86 switch (sts_entry
->completionStatus
) {
88 if (scsi_status
== 0) {
89 cmd
->result
= DID_OK
<< 16;
93 if (sts_entry
->iscsiFlags
&
94 (ISCSI_FLAG_RESIDUAL_OVER
|ISCSI_FLAG_RESIDUAL_UNDER
))
95 cmd
->resid
= residual
;
97 cmd
->result
= DID_OK
<< 16 | scsi_status
;
99 if (scsi_status
!= SCSI_CHECK_CONDITION
)
102 /* Copy Sense Data into sense buffer. */
103 memset(cmd
->sense_buffer
, 0, sizeof(cmd
->sense_buffer
));
105 sensebytecnt
= le16_to_cpu(sts_entry
->senseDataByteCnt
);
106 if (sensebytecnt
== 0)
109 memcpy(cmd
->sense_buffer
, sts_entry
->senseData
,
111 (uint16_t) sizeof(cmd
->sense_buffer
)));
113 DEBUG2(printk("scsi%ld:%d:%d:%d: %s: sense key = %x, "
114 "ASC/ASCQ = %02x/%02x\n", ha
->host_no
,
115 cmd
->device
->channel
, cmd
->device
->id
,
116 cmd
->device
->lun
, __func__
,
117 sts_entry
->senseData
[2] & 0x0f,
118 sts_entry
->senseData
[12],
119 sts_entry
->senseData
[13]));
121 srb
->flags
|= SRB_GOT_SENSE
;
125 /* Always set the status to DID_ERROR, since
126 * all conditions result in that status anyway */
127 cmd
->result
= DID_ERROR
<< 16;
130 case SCS_RESET_OCCURRED
:
131 DEBUG2(printk("scsi%ld:%d:%d:%d: %s: Device RESET occurred\n",
132 ha
->host_no
, cmd
->device
->channel
,
133 cmd
->device
->id
, cmd
->device
->lun
, __func__
));
135 cmd
->result
= DID_RESET
<< 16;
139 DEBUG2(printk("scsi%ld:%d:%d:%d: %s: Abort occurred\n",
140 ha
->host_no
, cmd
->device
->channel
,
141 cmd
->device
->id
, cmd
->device
->lun
, __func__
));
143 cmd
->result
= DID_RESET
<< 16;
147 DEBUG2(printk(KERN_INFO
"scsi%ld:%d:%d:%d: Timeout\n",
148 ha
->host_no
, cmd
->device
->channel
,
149 cmd
->device
->id
, cmd
->device
->lun
));
151 cmd
->result
= DID_BUS_BUSY
<< 16;
154 * Mark device missing so that we won't continue to send
155 * I/O to this device. We should get a ddb state change
158 if (atomic_read(&ddb_entry
->state
) == DDB_STATE_ONLINE
)
159 qla4xxx_mark_device_missing(ha
, ddb_entry
);
162 case SCS_DATA_UNDERRUN
:
163 case SCS_DATA_OVERRUN
:
164 if (sts_entry
->iscsiFlags
& ISCSI_FLAG_RESIDUAL_OVER
) {
165 DEBUG2(printk("scsi%ld:%d:%d:%d: %s: " "Data overrun, "
166 "residual = 0x%x\n", ha
->host_no
,
167 cmd
->device
->channel
, cmd
->device
->id
,
168 cmd
->device
->lun
, __func__
, residual
));
170 cmd
->result
= DID_ERROR
<< 16;
174 if ((sts_entry
->iscsiFlags
& ISCSI_FLAG_RESIDUAL_UNDER
) == 0) {
176 * Firmware detected a SCSI transport underrun
179 cmd
->resid
= residual
;
180 DEBUG2(printk("scsi%ld:%d:%d:%d: %s: UNDERRUN status "
181 "detected, xferlen = 0x%x, residual = "
183 ha
->host_no
, cmd
->device
->channel
,
185 cmd
->device
->lun
, __func__
,
186 cmd
->request_bufflen
,
191 * If there is scsi_status, it takes precedense over
192 * underflow condition.
194 if (scsi_status
!= 0) {
195 cmd
->result
= DID_OK
<< 16 | scsi_status
;
197 if (scsi_status
!= SCSI_CHECK_CONDITION
)
200 /* Copy Sense Data into sense buffer. */
201 memset(cmd
->sense_buffer
, 0,
202 sizeof(cmd
->sense_buffer
));
205 le16_to_cpu(sts_entry
->senseDataByteCnt
);
206 if (sensebytecnt
== 0)
209 memcpy(cmd
->sense_buffer
, sts_entry
->senseData
,
211 (uint16_t) sizeof(cmd
->sense_buffer
)));
213 DEBUG2(printk("scsi%ld:%d:%d:%d: %s: sense key = %x, "
214 "ASC/ASCQ = %02x/%02x\n", ha
->host_no
,
215 cmd
->device
->channel
, cmd
->device
->id
,
216 cmd
->device
->lun
, __func__
,
217 sts_entry
->senseData
[2] & 0x0f,
218 sts_entry
->senseData
[12],
219 sts_entry
->senseData
[13]));
222 * If RISC reports underrun and target does not
223 * report it then we must have a lost frame, so
224 * tell upper layer to retry it by reporting a
227 if ((sts_entry
->iscsiFlags
&
228 ISCSI_FLAG_RESIDUAL_UNDER
) == 0) {
229 cmd
->result
= DID_BUS_BUSY
<< 16;
230 } else if ((cmd
->request_bufflen
- residual
) <
233 * Handle mid-layer underflow???
235 * For kernels less than 2.4, the driver must
236 * return an error if an underflow is detected.
237 * For kernels equal-to and above 2.4, the
238 * mid-layer will appearantly handle the
239 * underflow by detecting the residual count --
240 * unfortunately, we do not see where this is
241 * actually being done. In the interim, we
242 * will return DID_ERROR.
244 DEBUG2(printk("scsi%ld:%d:%d:%d: %s: "
245 "Mid-layer Data underrun, "
247 "residual = 0x%x\n", ha
->host_no
,
248 cmd
->device
->channel
,
250 cmd
->device
->lun
, __func__
,
251 cmd
->request_bufflen
, residual
));
253 cmd
->result
= DID_ERROR
<< 16;
255 cmd
->result
= DID_OK
<< 16;
260 case SCS_DEVICE_LOGGED_OUT
:
261 case SCS_DEVICE_UNAVAILABLE
:
263 * Mark device missing so that we won't continue to
264 * send I/O to this device. We should get a ddb
265 * state change AEN soon.
267 if (atomic_read(&ddb_entry
->state
) == DDB_STATE_ONLINE
)
268 qla4xxx_mark_device_missing(ha
, ddb_entry
);
270 cmd
->result
= DID_BUS_BUSY
<< 16;
275 * SCSI Mid-Layer handles device queue full
277 cmd
->result
= DID_OK
<< 16 | sts_entry
->scsiStatus
;
278 DEBUG2(printk("scsi%ld:%d:%d: %s: QUEUE FULL detected "
279 "compl=%02x, scsi=%02x, state=%02x, iFlags=%02x,"
280 " iResp=%02x\n", ha
->host_no
, cmd
->device
->id
,
281 cmd
->device
->lun
, __func__
,
282 sts_entry
->completionStatus
,
283 sts_entry
->scsiStatus
, sts_entry
->state_flags
,
284 sts_entry
->iscsiFlags
,
285 sts_entry
->iscsiResponse
));
289 cmd
->result
= DID_ERROR
<< 16;
295 /* complete the request */
296 srb
->cc_stat
= sts_entry
->completionStatus
;
297 qla4xxx_srb_compl(ha
, srb
);
301 * qla4xxx_process_response_queue - process response queue completions
302 * @ha: Pointer to host adapter structure.
304 * This routine process response queue completions in interrupt context.
305 * Hardware_lock locked upon entry
307 static void qla4xxx_process_response_queue(struct scsi_qla_host
* ha
)
310 struct srb
*srb
= NULL
;
311 struct status_entry
*sts_entry
;
313 /* Process all responses from response queue */
314 while ((ha
->response_in
=
315 (uint16_t)le32_to_cpu(ha
->shadow_regs
->rsp_q_in
)) !=
317 sts_entry
= (struct status_entry
*) ha
->response_ptr
;
320 /* Advance pointers for next entry */
321 if (ha
->response_out
== (RESPONSE_QUEUE_DEPTH
- 1)) {
322 ha
->response_out
= 0;
323 ha
->response_ptr
= ha
->response_ring
;
330 switch (sts_entry
->hdr
.entryType
) {
333 * Common status - Single completion posted in single
336 qla4xxx_status_entry(ha
, sts_entry
);
339 case ET_PASSTHRU_STATUS
:
342 case ET_STATUS_CONTINUATION
:
343 /* Just throw away the status continuation entries */
344 DEBUG2(printk("scsi%ld: %s: Status Continuation entry "
345 "- ignoring\n", ha
->host_no
, __func__
));
349 /* ISP device queue is full. Command not
350 * accepted by ISP. Queue command for
353 srb
= qla4xxx_del_from_active_array(ha
,
354 le32_to_cpu(sts_entry
->
357 goto exit_prq_invalid_handle
;
359 DEBUG2(printk("scsi%ld: %s: FW device queue full, "
360 "srb %p\n", ha
->host_no
, __func__
, srb
));
362 /* ETRY normally by sending it back with
364 srb
->cmd
->result
= DID_BUS_BUSY
<< 16;
365 qla4xxx_srb_compl(ha
, srb
);
369 /* Just throw away the continuation entries */
370 DEBUG2(printk("scsi%ld: %s: Continuation entry - "
371 "ignoring\n", ha
->host_no
, __func__
));
376 * Invalid entry in response queue, reset RISC
379 DEBUG2(printk("scsi%ld: %s: Invalid entry %x in "
380 "response queue \n", ha
->host_no
,
382 sts_entry
->hdr
.entryType
));
388 * Done with responses, update the ISP For QLA4010, this also clears
391 writel(ha
->response_out
, &ha
->reg
->rsp_q_out
);
392 readl(&ha
->reg
->rsp_q_out
);
396 exit_prq_invalid_handle
:
397 DEBUG2(printk("scsi%ld: %s: Invalid handle(srb)=%p type=%x IOCS=%x\n",
398 ha
->host_no
, __func__
, srb
, sts_entry
->hdr
.entryType
,
399 sts_entry
->completionStatus
));
402 writel(ha
->response_out
, &ha
->reg
->rsp_q_out
);
403 readl(&ha
->reg
->rsp_q_out
);
405 set_bit(DPC_RESET_HA
, &ha
->dpc_flags
);
409 * qla4xxx_isr_decode_mailbox - decodes mailbox status
410 * @ha: Pointer to host adapter structure.
411 * @mailbox_status: Mailbox status.
413 * This routine decodes the mailbox status during the ISR.
414 * Hardware_lock locked upon entry. runs in interrupt context.
416 static void qla4xxx_isr_decode_mailbox(struct scsi_qla_host
* ha
,
417 uint32_t mbox_status
)
421 if ((mbox_status
== MBOX_STS_BUSY
) ||
422 (mbox_status
== MBOX_STS_INTERMEDIATE_COMPLETION
) ||
423 (mbox_status
>> 12 == MBOX_COMPLETION_STATUS
)) {
424 ha
->mbox_status
[0] = mbox_status
;
426 if (test_bit(AF_MBOX_COMMAND
, &ha
->flags
)) {
428 * Copy all mailbox registers to a temporary
429 * location and set mailbox command done flag
431 for (i
= 1; i
< ha
->mbox_status_count
; i
++)
433 readl(&ha
->reg
->mailbox
[i
]);
435 set_bit(AF_MBOX_COMMAND_DONE
, &ha
->flags
);
437 } else if (mbox_status
>> 12 == MBOX_ASYNC_EVENT_STATUS
) {
438 /* Immediately process the AENs that don't require much work.
439 * Only queue the database_changed AENs */
440 switch (mbox_status
) {
441 case MBOX_ASTS_SYSTEM_ERROR
:
442 /* Log Mailbox registers */
443 if (ql4xdontresethba
) {
444 DEBUG2(printk("%s:Dont Reset HBA\n",
447 set_bit(AF_GET_CRASH_RECORD
, &ha
->flags
);
448 set_bit(DPC_RESET_HA
, &ha
->dpc_flags
);
452 case MBOX_ASTS_REQUEST_TRANSFER_ERROR
:
453 case MBOX_ASTS_RESPONSE_TRANSFER_ERROR
:
454 case MBOX_ASTS_NVRAM_INVALID
:
455 case MBOX_ASTS_IP_ADDRESS_CHANGED
:
456 case MBOX_ASTS_DHCP_LEASE_EXPIRED
:
457 DEBUG2(printk("scsi%ld: AEN %04x, ERROR Status, "
458 "Reset HA\n", ha
->host_no
, mbox_status
));
459 set_bit(DPC_RESET_HA
, &ha
->dpc_flags
);
462 case MBOX_ASTS_LINK_UP
:
463 DEBUG2(printk("scsi%ld: AEN %04x Adapter LINK UP\n",
464 ha
->host_no
, mbox_status
));
465 set_bit(AF_LINK_UP
, &ha
->flags
);
468 case MBOX_ASTS_LINK_DOWN
:
469 DEBUG2(printk("scsi%ld: AEN %04x Adapter LINK DOWN\n",
470 ha
->host_no
, mbox_status
));
471 clear_bit(AF_LINK_UP
, &ha
->flags
);
474 case MBOX_ASTS_HEARTBEAT
:
475 ha
->seconds_since_last_heartbeat
= 0;
478 case MBOX_ASTS_DHCP_LEASE_ACQUIRED
:
479 DEBUG2(printk("scsi%ld: AEN %04x DHCP LEASE "
480 "ACQUIRED\n", ha
->host_no
, mbox_status
));
481 set_bit(DPC_GET_DHCP_IP_ADDR
, &ha
->dpc_flags
);
484 case MBOX_ASTS_PROTOCOL_STATISTIC_ALARM
:
485 case MBOX_ASTS_SCSI_COMMAND_PDU_REJECTED
: /* Target
488 case MBOX_ASTS_UNSOLICITED_PDU_RECEIVED
: /* Connection mode */
489 case MBOX_ASTS_IPSEC_SYSTEM_FATAL_ERROR
:
490 case MBOX_ASTS_SUBNET_STATE_CHANGE
:
492 DEBUG2(printk("scsi%ld: AEN %04x\n", ha
->host_no
,
496 case MBOX_ASTS_MAC_ADDRESS_CHANGED
:
499 DEBUG2(printk(KERN_INFO
"scsi%ld: AEN %04x, "
500 "mbox_sts[1]=%04x, mbox_sts[2]=%04x\n",
501 ha
->host_no
, mbox_status
,
502 readl(&ha
->reg
->mailbox
[1]),
503 readl(&ha
->reg
->mailbox
[2])));
506 case MBOX_ASTS_SELF_TEST_FAILED
:
507 case MBOX_ASTS_LOGIN_FAILED
:
509 DEBUG2(printk("scsi%ld: AEN %04x, mbox_sts[1]=%04x, "
510 "mbox_sts[2]=%04x, mbox_sts[3]=%04x\n",
511 ha
->host_no
, mbox_status
,
512 readl(&ha
->reg
->mailbox
[1]),
513 readl(&ha
->reg
->mailbox
[2]),
514 readl(&ha
->reg
->mailbox
[3])));
517 case MBOX_ASTS_DATABASE_CHANGED
:
518 /* Queue AEN information and process it in the DPC
520 if (ha
->aen_q_count
> 0) {
521 /* advance pointer */
522 if (ha
->aen_in
== (MAX_AEN_ENTRIES
- 1))
527 /* decrement available counter */
530 for (i
= 1; i
< MBOX_AEN_REG_COUNT
; i
++)
531 ha
->aen_q
[ha
->aen_in
].mbox_sts
[i
] =
532 readl(&ha
->reg
->mailbox
[i
]);
534 ha
->aen_q
[ha
->aen_in
].mbox_sts
[0] = mbox_status
;
536 /* print debug message */
537 DEBUG2(printk("scsi%ld: AEN[%d] %04x queued"
538 " mb1:0x%x mb2:0x%x mb3:0x%x mb4:0x%x\n",
539 ha
->host_no
, ha
->aen_in
,
541 ha
->aen_q
[ha
->aen_in
].mbox_sts
[1],
542 ha
->aen_q
[ha
->aen_in
].mbox_sts
[2],
543 ha
->aen_q
[ha
->aen_in
].mbox_sts
[3],
544 ha
->aen_q
[ha
->aen_in
]. mbox_sts
[4]));
546 /* The DPC routine will process the aen */
547 set_bit(DPC_AEN
, &ha
->dpc_flags
);
549 DEBUG2(printk("scsi%ld: %s: aen %04x, queue "
550 "overflowed! AEN LOST!!\n",
551 ha
->host_no
, __func__
,
554 DEBUG2(printk("scsi%ld: DUMP AEN QUEUE\n",
557 for (i
= 0; i
< MAX_AEN_ENTRIES
; i
++) {
558 DEBUG2(printk("AEN[%d] %04x %04x %04x "
560 ha
->aen_q
[i
].mbox_sts
[0],
561 ha
->aen_q
[i
].mbox_sts
[1],
562 ha
->aen_q
[i
].mbox_sts
[2],
563 ha
->aen_q
[i
].mbox_sts
[3]));
569 DEBUG2(printk(KERN_WARNING
570 "scsi%ld: AEN %04x UNKNOWN\n",
571 ha
->host_no
, mbox_status
));
575 DEBUG2(printk("scsi%ld: Unknown mailbox status %08X\n",
576 ha
->host_no
, mbox_status
));
578 ha
->mbox_status
[0] = mbox_status
;
583 * qla4xxx_interrupt_service_routine - isr
584 * @ha: pointer to host adapter structure.
586 * This is the main interrupt service routine.
587 * hardware_lock locked upon entry. runs in interrupt context.
589 void qla4xxx_interrupt_service_routine(struct scsi_qla_host
* ha
,
590 uint32_t intr_status
)
592 /* Process response queue interrupt. */
593 if (intr_status
& CSR_SCSI_COMPLETION_INTR
)
594 qla4xxx_process_response_queue(ha
);
596 /* Process mailbox/asynch event interrupt.*/
597 if (intr_status
& CSR_SCSI_PROCESSOR_INTR
) {
598 qla4xxx_isr_decode_mailbox(ha
,
599 readl(&ha
->reg
->mailbox
[0]));
601 /* Clear Mailbox Interrupt */
602 writel(set_rmask(CSR_SCSI_PROCESSOR_INTR
),
603 &ha
->reg
->ctrl_status
);
604 readl(&ha
->reg
->ctrl_status
);
609 * qla4xxx_intr_handler - hardware interrupt handler.
611 * @dev_id: Pointer to host adapter structure
613 irqreturn_t
qla4xxx_intr_handler(int irq
, void *dev_id
)
615 struct scsi_qla_host
*ha
;
616 uint32_t intr_status
;
617 unsigned long flags
= 0;
618 uint8_t reqs_count
= 0;
620 ha
= (struct scsi_qla_host
*) dev_id
;
622 DEBUG2(printk(KERN_INFO
623 "qla4xxx: Interrupt with NULL host ptr\n"));
627 spin_lock_irqsave(&ha
->hardware_lock
, flags
);
631 * Repeatedly service interrupts up to a maximum of
632 * MAX_REQS_SERVICED_PER_INTR
636 * Read interrupt status
638 if (le32_to_cpu(ha
->shadow_regs
->rsp_q_in
) !=
640 intr_status
= CSR_SCSI_COMPLETION_INTR
;
642 intr_status
= readl(&ha
->reg
->ctrl_status
);
645 (CSR_SCSI_RESET_INTR
|CSR_FATAL_ERROR
|INTR_PENDING
)) ==
648 ha
->spurious_int_count
++;
652 if (intr_status
& CSR_FATAL_ERROR
) {
653 DEBUG2(printk(KERN_INFO
"scsi%ld: Fatal Error, "
654 "Status 0x%04x\n", ha
->host_no
,
655 readl(isp_port_error_status (ha
))));
657 /* Issue Soft Reset to clear this error condition.
658 * This will prevent the RISC from repeatedly
659 * interrupting the driver; thus, allowing the DPC to
660 * get scheduled to continue error recovery.
661 * NOTE: Disabling RISC interrupts does not work in
662 * this case, as CSR_FATAL_ERROR overrides
663 * CSR_SCSI_INTR_ENABLE */
664 if ((readl(&ha
->reg
->ctrl_status
) &
665 CSR_SCSI_RESET_INTR
) == 0) {
666 writel(set_rmask(CSR_SOFT_RESET
),
667 &ha
->reg
->ctrl_status
);
668 readl(&ha
->reg
->ctrl_status
);
671 writel(set_rmask(CSR_FATAL_ERROR
),
672 &ha
->reg
->ctrl_status
);
673 readl(&ha
->reg
->ctrl_status
);
675 __qla4xxx_disable_intrs(ha
);
677 set_bit(DPC_RESET_HA
, &ha
->dpc_flags
);
680 } else if (intr_status
& CSR_SCSI_RESET_INTR
) {
681 clear_bit(AF_ONLINE
, &ha
->flags
);
682 __qla4xxx_disable_intrs(ha
);
684 writel(set_rmask(CSR_SCSI_RESET_INTR
),
685 &ha
->reg
->ctrl_status
);
686 readl(&ha
->reg
->ctrl_status
);
689 set_bit(DPC_RESET_HA_INTR
, &ha
->dpc_flags
);
692 } else if (intr_status
& INTR_PENDING
) {
693 qla4xxx_interrupt_service_routine(ha
, intr_status
);
694 ha
->total_io_count
++;
695 if (++reqs_count
== MAX_REQS_SERVICED_PER_INTR
)
702 spin_unlock_irqrestore(&ha
->hardware_lock
, flags
);
708 * qla4xxx_process_aen - processes AENs generated by firmware
709 * @ha: pointer to host adapter structure.
710 * @process_aen: type of AENs to process
712 * Processes specific types of Asynchronous Events generated by firmware.
713 * The type of AENs to process is specified by process_aen and can be
715 * FLUSH_DDB_CHANGED_AENS 1
716 * RELOGIN_DDB_CHANGED_AENS 2
718 void qla4xxx_process_aen(struct scsi_qla_host
* ha
, uint8_t process_aen
)
720 uint32_t mbox_sts
[MBOX_AEN_REG_COUNT
];
725 spin_lock_irqsave(&ha
->hardware_lock
, flags
);
726 while (ha
->aen_out
!= ha
->aen_in
) {
727 /* Advance pointers for next entry */
728 if (ha
->aen_out
== (MAX_AEN_ENTRIES
- 1))
734 aen
= &ha
->aen_q
[ha
->aen_out
];
736 /* copy aen information to local structure */
737 for (i
= 0; i
< MBOX_AEN_REG_COUNT
; i
++)
738 mbox_sts
[i
] = aen
->mbox_sts
[i
];
740 spin_unlock_irqrestore(&ha
->hardware_lock
, flags
);
742 DEBUG(printk("scsi%ld: AEN[%d] %04x, index [%d] state=%04x "
743 "mod=%x conerr=%08x \n", ha
->host_no
, ha
->aen_out
,
744 mbox_sts
[0], mbox_sts
[2], mbox_sts
[3],
745 mbox_sts
[1], mbox_sts
[4]));
747 switch (mbox_sts
[0]) {
748 case MBOX_ASTS_DATABASE_CHANGED
:
749 if (process_aen
== FLUSH_DDB_CHANGED_AENS
) {
750 DEBUG2(printk("scsi%ld: AEN[%d] %04x, index "
751 "[%d] state=%04x FLUSHED!\n",
752 ha
->host_no
, ha
->aen_out
,
753 mbox_sts
[0], mbox_sts
[2],
756 } else if (process_aen
== RELOGIN_DDB_CHANGED_AENS
) {
757 /* for use during init time, we only want to
758 * relogin non-active ddbs */
759 struct ddb_entry
*ddb_entry
;
762 /* FIXME: name length? */
763 qla4xxx_lookup_ddb_by_fw_index(ha
,
768 ddb_entry
->dev_scan_wait_to_complete_relogin
=
770 ddb_entry
->dev_scan_wait_to_start_relogin
=
772 ((ddb_entry
->default_time2wait
+
775 DEBUG2(printk("scsi%ld: ddb index [%d] initate"
776 " RELOGIN after %d seconds\n",
778 ddb_entry
->fw_ddb_index
,
779 ddb_entry
->default_time2wait
+
784 if (mbox_sts
[1] == 0) { /* Global DB change. */
785 qla4xxx_reinitialize_ddb_list(ha
);
786 } else if (mbox_sts
[1] == 1) { /* Specific device. */
787 qla4xxx_process_ddb_changed(ha
, mbox_sts
[2],
792 spin_lock_irqsave(&ha
->hardware_lock
, flags
);
794 spin_unlock_irqrestore(&ha
->hardware_lock
, flags
);