2 * QLogic Fibre Channel HBA Driver
3 * Copyright (c) 2003-2005 QLogic Corporation
5 * See LICENSE.qla2xxx for copyright and licensing details.
9 #include <scsi/scsi_tcq.h>
11 static void qla2x00_mbx_completion(scsi_qla_host_t *, uint16_t);
12 static void qla2x00_async_event(scsi_qla_host_t *, uint16_t *);
13 static void qla2x00_process_completed_request(struct scsi_qla_host *, uint32_t);
14 static void qla2x00_status_entry(scsi_qla_host_t *, void *);
15 static void qla2x00_status_cont_entry(scsi_qla_host_t *, sts_cont_entry_t *);
16 static void qla2x00_error_entry(scsi_qla_host_t *, sts_entry_t *);
17 static void qla2x00_ms_entry(scsi_qla_host_t *, ms_iocb_entry_t *);
19 static void qla24xx_ms_entry(scsi_qla_host_t *, struct ct_entry_24xx *);
22 * qla2100_intr_handler() - Process interrupts for the ISP2100 and ISP2200.
24 * @dev_id: SCSI driver HA context
26 * Called by system whenever the host adapter generates an interrupt.
28 * Returns handled flag.
31 qla2100_intr_handler(int irq, void *dev_id)
34 struct device_reg_2xxx __iomem *reg;
40 ha = (scsi_qla_host_t *) dev_id;
43 "%s(): NULL host pointer\n", __func__);
47 reg = &ha->iobase->isp;
50 spin_lock_irqsave(&ha->hardware_lock, flags);
51 for (iter = 50; iter--; ) {
52 if ((RD_REG_WORD(®->istatus) & ISR_RISC_INT) == 0)
55 if (RD_REG_WORD(®->semaphore) & BIT_0) {
56 WRT_REG_WORD(®->hccr, HCCR_CLR_RISC_INT);
57 RD_REG_WORD(®->hccr);
59 /* Get mailbox data. */
60 mb[0] = RD_MAILBOX_REG(ha, reg, 0);
61 if (mb[0] > 0x3fff && mb[0] < 0x8000) {
62 qla2x00_mbx_completion(ha, mb[0]);
63 status |= MBX_INTERRUPT;
64 } else if (mb[0] > 0x7fff && mb[0] < 0xc000) {
65 mb[1] = RD_MAILBOX_REG(ha, reg, 1);
66 mb[2] = RD_MAILBOX_REG(ha, reg, 2);
67 mb[3] = RD_MAILBOX_REG(ha, reg, 3);
68 qla2x00_async_event(ha, mb);
71 DEBUG2(printk("scsi(%ld): Unrecognized "
72 "interrupt type (%d).\n",
75 /* Release mailbox registers. */
76 WRT_REG_WORD(®->semaphore, 0);
77 RD_REG_WORD(®->semaphore);
79 qla2x00_process_response_queue(ha);
81 WRT_REG_WORD(®->hccr, HCCR_CLR_RISC_INT);
82 RD_REG_WORD(®->hccr);
85 spin_unlock_irqrestore(&ha->hardware_lock, flags);
87 if (test_bit(MBX_INTR_WAIT, &ha->mbx_cmd_flags) &&
88 (status & MBX_INTERRUPT) && ha->flags.mbox_int) {
89 spin_lock_irqsave(&ha->mbx_reg_lock, flags);
91 set_bit(MBX_INTERRUPT, &ha->mbx_cmd_flags);
92 up(&ha->mbx_intr_sem);
94 spin_unlock_irqrestore(&ha->mbx_reg_lock, flags);
101 * qla2300_intr_handler() - Process interrupts for the ISP23xx and ISP63xx.
103 * @dev_id: SCSI driver HA context
105 * Called by system whenever the host adapter generates an interrupt.
107 * Returns handled flag.
110 qla2300_intr_handler(int irq, void *dev_id)
113 struct device_reg_2xxx __iomem *reg;
121 ha = (scsi_qla_host_t *) dev_id;
124 "%s(): NULL host pointer\n", __func__);
128 reg = &ha->iobase->isp;
131 spin_lock_irqsave(&ha->hardware_lock, flags);
132 for (iter = 50; iter--; ) {
133 stat = RD_REG_DWORD(®->u.isp2300.host_status);
134 if (stat & HSR_RISC_PAUSED) {
135 hccr = RD_REG_WORD(®->hccr);
136 if (hccr & (BIT_15 | BIT_13 | BIT_11 | BIT_8))
137 qla_printk(KERN_INFO, ha, "Parity error -- "
138 "HCCR=%x, Dumping firmware!\n", hccr);
140 qla_printk(KERN_INFO, ha, "RISC paused -- "
141 "HCCR=%x, Dumping firmware!\n", hccr);
144 * Issue a "HARD" reset in order for the RISC
145 * interrupt bit to be cleared. Schedule a big
146 * hammmer to get out of the RISC PAUSED state.
148 WRT_REG_WORD(®->hccr, HCCR_RESET_RISC);
149 RD_REG_WORD(®->hccr);
151 ha->isp_ops.fw_dump(ha, 1);
152 set_bit(ISP_ABORT_NEEDED, &ha->dpc_flags);
154 } else if ((stat & HSR_RISC_INT) == 0)
157 switch (stat & 0xff) {
162 qla2x00_mbx_completion(ha, MSW(stat));
163 status |= MBX_INTERRUPT;
165 /* Release mailbox registers. */
166 WRT_REG_WORD(®->semaphore, 0);
170 mb[1] = RD_MAILBOX_REG(ha, reg, 1);
171 mb[2] = RD_MAILBOX_REG(ha, reg, 2);
172 mb[3] = RD_MAILBOX_REG(ha, reg, 3);
173 qla2x00_async_event(ha, mb);
176 qla2x00_process_response_queue(ha);
179 mb[0] = MBA_CMPLT_1_16BIT;
181 qla2x00_async_event(ha, mb);
184 mb[0] = MBA_SCSI_COMPLETION;
186 mb[2] = RD_MAILBOX_REG(ha, reg, 2);
187 qla2x00_async_event(ha, mb);
190 DEBUG2(printk("scsi(%ld): Unrecognized interrupt type "
192 ha->host_no, stat & 0xff));
195 WRT_REG_WORD(®->hccr, HCCR_CLR_RISC_INT);
196 RD_REG_WORD_RELAXED(®->hccr);
198 spin_unlock_irqrestore(&ha->hardware_lock, flags);
200 if (test_bit(MBX_INTR_WAIT, &ha->mbx_cmd_flags) &&
201 (status & MBX_INTERRUPT) && ha->flags.mbox_int) {
202 spin_lock_irqsave(&ha->mbx_reg_lock, flags);
204 set_bit(MBX_INTERRUPT, &ha->mbx_cmd_flags);
205 up(&ha->mbx_intr_sem);
207 spin_unlock_irqrestore(&ha->mbx_reg_lock, flags);
210 return (IRQ_HANDLED);
214 * qla2x00_mbx_completion() - Process mailbox command completions.
215 * @ha: SCSI driver HA context
216 * @mb0: Mailbox0 register
219 qla2x00_mbx_completion(scsi_qla_host_t *ha, uint16_t mb0)
222 uint16_t __iomem *wptr;
223 struct device_reg_2xxx __iomem *reg = &ha->iobase->isp;
225 /* Load return mailbox registers. */
226 ha->flags.mbox_int = 1;
227 ha->mailbox_out[0] = mb0;
228 wptr = (uint16_t __iomem *)MAILBOX_REG(ha, reg, 1);
230 for (cnt = 1; cnt < ha->mbx_count; cnt++) {
231 if (IS_QLA2200(ha) && cnt == 8)
232 wptr = (uint16_t __iomem *)MAILBOX_REG(ha, reg, 8);
233 if (cnt == 4 || cnt == 5)
234 ha->mailbox_out[cnt] = qla2x00_debounce_register(wptr);
236 ha->mailbox_out[cnt] = RD_REG_WORD(wptr);
242 DEBUG3(printk("%s(%ld): Got mailbox completion. cmd=%x.\n",
243 __func__, ha->host_no, ha->mcp->mb[0]));
245 DEBUG2_3(printk("%s(%ld): MBX pointer ERROR!\n",
246 __func__, ha->host_no));
251 * qla2x00_async_event() - Process aynchronous events.
252 * @ha: SCSI driver HA context
253 * @mb: Mailbox registers (0 - 3)
256 qla2x00_async_event(scsi_qla_host_t *ha, uint16_t *mb)
259 static char *link_speeds[5] = { "1", "2", "?", "4", "10" };
264 struct device_reg_2xxx __iomem *reg = &ha->iobase->isp;
265 uint32_t rscn_entry, host_pid;
266 uint8_t rscn_queue_index;
268 /* Setup to process RIO completion. */
271 case MBA_SCSI_COMPLETION:
272 handles[0] = le32_to_cpu((uint32_t)((mb[2] << 16) | mb[1]));
275 case MBA_CMPLT_1_16BIT:
278 mb[0] = MBA_SCSI_COMPLETION;
280 case MBA_CMPLT_2_16BIT:
284 mb[0] = MBA_SCSI_COMPLETION;
286 case MBA_CMPLT_3_16BIT:
291 mb[0] = MBA_SCSI_COMPLETION;
293 case MBA_CMPLT_4_16BIT:
297 handles[3] = (uint32_t)RD_MAILBOX_REG(ha, reg, 6);
299 mb[0] = MBA_SCSI_COMPLETION;
301 case MBA_CMPLT_5_16BIT:
305 handles[3] = (uint32_t)RD_MAILBOX_REG(ha, reg, 6);
306 handles[4] = (uint32_t)RD_MAILBOX_REG(ha, reg, 7);
308 mb[0] = MBA_SCSI_COMPLETION;
310 case MBA_CMPLT_2_32BIT:
311 handles[0] = le32_to_cpu((uint32_t)((mb[2] << 16) | mb[1]));
312 handles[1] = le32_to_cpu(
313 ((uint32_t)(RD_MAILBOX_REG(ha, reg, 7) << 16)) |
314 RD_MAILBOX_REG(ha, reg, 6));
316 mb[0] = MBA_SCSI_COMPLETION;
323 case MBA_SCSI_COMPLETION: /* Fast Post */
324 if (!ha->flags.online)
327 for (cnt = 0; cnt < handle_cnt; cnt++)
328 qla2x00_process_completed_request(ha, handles[cnt]);
331 case MBA_RESET: /* Reset */
332 DEBUG2(printk("scsi(%ld): Asynchronous RESET.\n", ha->host_no));
334 set_bit(RESET_MARKER_NEEDED, &ha->dpc_flags);
337 case MBA_SYSTEM_ERR: /* System Error */
338 mb[1] = RD_MAILBOX_REG(ha, reg, 1);
339 mb[2] = RD_MAILBOX_REG(ha, reg, 2);
340 mb[3] = RD_MAILBOX_REG(ha, reg, 3);
342 qla_printk(KERN_INFO, ha,
343 "ISP System Error - mbx1=%xh mbx2=%xh mbx3=%xh.\n",
344 mb[1], mb[2], mb[3]);
346 ha->isp_ops.fw_dump(ha, 1);
348 if (IS_QLA24XX(ha) || IS_QLA54XX(ha)) {
349 if (mb[1] == 0 && mb[2] == 0) {
350 qla_printk(KERN_ERR, ha,
351 "Unrecoverable Hardware Error: adapter "
352 "marked OFFLINE!\n");
353 ha->flags.online = 0;
355 set_bit(ISP_ABORT_NEEDED, &ha->dpc_flags);
356 } else if (mb[1] == 0) {
357 qla_printk(KERN_INFO, ha,
358 "Unrecoverable Hardware Error: adapter marked "
360 ha->flags.online = 0;
362 set_bit(ISP_ABORT_NEEDED, &ha->dpc_flags);
365 case MBA_REQ_TRANSFER_ERR: /* Request Transfer Error */
366 DEBUG2(printk("scsi(%ld): ISP Request Transfer Error.\n",
368 qla_printk(KERN_WARNING, ha, "ISP Request Transfer Error.\n");
370 set_bit(ISP_ABORT_NEEDED, &ha->dpc_flags);
373 case MBA_RSP_TRANSFER_ERR: /* Response Transfer Error */
374 DEBUG2(printk("scsi(%ld): ISP Response Transfer Error.\n",
376 qla_printk(KERN_WARNING, ha, "ISP Response Transfer Error.\n");
378 set_bit(ISP_ABORT_NEEDED, &ha->dpc_flags);
381 case MBA_WAKEUP_THRES: /* Request Queue Wake-up */
382 DEBUG2(printk("scsi(%ld): Asynchronous WAKEUP_THRES.\n",
386 case MBA_LIP_OCCURRED: /* Loop Initialization Procedure */
387 DEBUG2(printk("scsi(%ld): LIP occured (%x).\n", ha->host_no,
389 qla_printk(KERN_INFO, ha, "LIP occured (%x).\n", mb[1]);
391 if (atomic_read(&ha->loop_state) != LOOP_DOWN) {
392 atomic_set(&ha->loop_state, LOOP_DOWN);
393 atomic_set(&ha->loop_down_timer, LOOP_DOWN_TIME);
394 qla2x00_mark_all_devices_lost(ha, 1);
397 set_bit(REGISTER_FC4_NEEDED, &ha->dpc_flags);
399 ha->flags.management_server_logged_in = 0;
402 case MBA_LOOP_UP: /* Loop Up Event */
403 if (IS_QLA2100(ha) || IS_QLA2200(ha)) {
404 link_speed = link_speeds[0];
405 ha->link_data_rate = PORT_SPEED_1GB;
407 link_speed = link_speeds[LS_UNKNOWN];
409 link_speed = link_speeds[mb[1]];
410 ha->link_data_rate = mb[1];
413 DEBUG2(printk("scsi(%ld): Asynchronous LOOP UP (%s Gbps).\n",
414 ha->host_no, link_speed));
415 qla_printk(KERN_INFO, ha, "LOOP UP detected (%s Gbps).\n",
418 ha->flags.management_server_logged_in = 0;
421 case MBA_LOOP_DOWN: /* Loop Down Event */
422 DEBUG2(printk("scsi(%ld): Asynchronous LOOP DOWN (%x).\n",
423 ha->host_no, mb[1]));
424 qla_printk(KERN_INFO, ha, "LOOP DOWN detected (%x).\n", mb[1]);
426 if (atomic_read(&ha->loop_state) != LOOP_DOWN) {
427 atomic_set(&ha->loop_state, LOOP_DOWN);
428 atomic_set(&ha->loop_down_timer, LOOP_DOWN_TIME);
429 ha->device_flags |= DFLG_NO_CABLE;
430 qla2x00_mark_all_devices_lost(ha, 1);
433 ha->flags.management_server_logged_in = 0;
434 ha->link_data_rate = PORT_SPEED_UNKNOWN;
436 set_bit(REGISTER_FDMI_NEEDED, &ha->dpc_flags);
439 case MBA_LIP_RESET: /* LIP reset occurred */
440 DEBUG2(printk("scsi(%ld): Asynchronous LIP RESET (%x).\n",
441 ha->host_no, mb[1]));
442 qla_printk(KERN_INFO, ha,
443 "LIP reset occured (%x).\n", mb[1]);
445 if (atomic_read(&ha->loop_state) != LOOP_DOWN) {
446 atomic_set(&ha->loop_state, LOOP_DOWN);
447 atomic_set(&ha->loop_down_timer, LOOP_DOWN_TIME);
448 qla2x00_mark_all_devices_lost(ha, 1);
451 set_bit(RESET_MARKER_NEEDED, &ha->dpc_flags);
453 ha->operating_mode = LOOP;
454 ha->flags.management_server_logged_in = 0;
457 case MBA_POINT_TO_POINT: /* Point-to-Point */
461 DEBUG2(printk("scsi(%ld): Asynchronous P2P MODE received.\n",
465 * Until there's a transition from loop down to loop up, treat
466 * this as loop down only.
468 if (atomic_read(&ha->loop_state) != LOOP_DOWN) {
469 atomic_set(&ha->loop_state, LOOP_DOWN);
470 if (!atomic_read(&ha->loop_down_timer))
471 atomic_set(&ha->loop_down_timer,
473 qla2x00_mark_all_devices_lost(ha, 1);
476 if (!(test_bit(ABORT_ISP_ACTIVE, &ha->dpc_flags))) {
477 set_bit(RESET_MARKER_NEEDED, &ha->dpc_flags);
479 set_bit(REGISTER_FC4_NEEDED, &ha->dpc_flags);
481 ha->flags.gpsc_supported = 1;
484 case MBA_CHG_IN_CONNECTION: /* Change in connection mode */
488 DEBUG2(printk("scsi(%ld): Asynchronous Change In Connection "
491 qla_printk(KERN_INFO, ha,
492 "Configuration change detected: value=%x.\n", mb[1]);
494 if (atomic_read(&ha->loop_state) != LOOP_DOWN) {
495 atomic_set(&ha->loop_state, LOOP_DOWN);
496 if (!atomic_read(&ha->loop_down_timer))
497 atomic_set(&ha->loop_down_timer,
499 qla2x00_mark_all_devices_lost(ha, 1);
502 set_bit(LOOP_RESYNC_NEEDED, &ha->dpc_flags);
503 set_bit(LOCAL_LOOP_UPDATE, &ha->dpc_flags);
506 case MBA_PORT_UPDATE: /* Port database update */
508 * If PORT UPDATE is global (recieved LIP_OCCURED/LIP_RESET
509 * event etc. earlier indicating loop is down) then process
510 * it. Otherwise ignore it and Wait for RSCN to come in.
512 atomic_set(&ha->loop_down_timer, 0);
513 if (atomic_read(&ha->loop_state) != LOOP_DOWN &&
514 atomic_read(&ha->loop_state) != LOOP_DEAD) {
515 DEBUG2(printk("scsi(%ld): Asynchronous PORT UPDATE "
516 "ignored %04x/%04x/%04x.\n", ha->host_no, mb[1],
521 DEBUG2(printk("scsi(%ld): Asynchronous PORT UPDATE.\n",
523 DEBUG(printk(KERN_INFO
524 "scsi(%ld): Port database changed %04x %04x %04x.\n",
525 ha->host_no, mb[1], mb[2], mb[3]));
528 * Mark all devices as missing so we will login again.
530 atomic_set(&ha->loop_state, LOOP_UP);
532 qla2x00_mark_all_devices_lost(ha, 1);
534 ha->flags.rscn_queue_overflow = 1;
536 set_bit(LOOP_RESYNC_NEEDED, &ha->dpc_flags);
537 set_bit(LOCAL_LOOP_UPDATE, &ha->dpc_flags);
540 case MBA_RSCN_UPDATE: /* State Change Registration */
541 DEBUG2(printk("scsi(%ld): Asynchronous RSCR UPDATE.\n",
543 DEBUG(printk(KERN_INFO
544 "scsi(%ld): RSCN database changed -- %04x %04x.\n",
545 ha->host_no, mb[1], mb[2]));
547 rscn_entry = (mb[1] << 16) | mb[2];
548 host_pid = (ha->d_id.b.domain << 16) | (ha->d_id.b.area << 8) |
550 if (rscn_entry == host_pid) {
551 DEBUG(printk(KERN_INFO
552 "scsi(%ld): Ignoring RSCN update to local host "
554 ha->host_no, host_pid));
558 rscn_queue_index = ha->rscn_in_ptr + 1;
559 if (rscn_queue_index == MAX_RSCN_COUNT)
560 rscn_queue_index = 0;
561 if (rscn_queue_index != ha->rscn_out_ptr) {
562 ha->rscn_queue[ha->rscn_in_ptr] = rscn_entry;
563 ha->rscn_in_ptr = rscn_queue_index;
565 ha->flags.rscn_queue_overflow = 1;
568 atomic_set(&ha->loop_state, LOOP_UPDATE);
569 atomic_set(&ha->loop_down_timer, 0);
570 ha->flags.management_server_logged_in = 0;
572 set_bit(LOOP_RESYNC_NEEDED, &ha->dpc_flags);
573 set_bit(RSCN_UPDATE, &ha->dpc_flags);
576 /* case MBA_RIO_RESPONSE: */
577 case MBA_ZIO_RESPONSE:
578 DEBUG2(printk("scsi(%ld): [R|Z]IO update completion.\n",
580 DEBUG(printk(KERN_INFO
581 "scsi(%ld): [R|Z]IO update completion.\n",
584 if (IS_QLA24XX(ha) || IS_QLA54XX(ha))
585 qla24xx_process_response_queue(ha);
587 qla2x00_process_response_queue(ha);
590 case MBA_DISCARD_RND_FRAME:
591 DEBUG2(printk("scsi(%ld): Discard RND Frame -- %04x %04x "
592 "%04x.\n", ha->host_no, mb[1], mb[2], mb[3]));
595 case MBA_TRACE_NOTIFICATION:
596 DEBUG2(printk("scsi(%ld): Trace Notification -- %04x %04x.\n",
597 ha->host_no, mb[1], mb[2]));
603 qla2x00_adjust_sdev_qdepth_up(struct scsi_device *sdev, void *data)
605 fc_port_t *fcport = data;
607 if (fcport->ha->max_q_depth <= sdev->queue_depth)
610 if (sdev->ordered_tags)
611 scsi_adjust_queue_depth(sdev, MSG_ORDERED_TAG,
612 sdev->queue_depth + 1);
614 scsi_adjust_queue_depth(sdev, MSG_SIMPLE_TAG,
615 sdev->queue_depth + 1);
617 fcport->last_ramp_up = jiffies;
619 DEBUG2(qla_printk(KERN_INFO, fcport->ha,
620 "scsi(%ld:%d:%d:%d): Queue depth adjusted-up to %d.\n",
621 fcport->ha->host_no, sdev->channel, sdev->id, sdev->lun,
626 qla2x00_adjust_sdev_qdepth_down(struct scsi_device *sdev, void *data)
628 fc_port_t *fcport = data;
630 if (!scsi_track_queue_full(sdev, sdev->queue_depth - 1))
633 DEBUG2(qla_printk(KERN_INFO, fcport->ha,
634 "scsi(%ld:%d:%d:%d): Queue depth adjusted-down to %d.\n",
635 fcport->ha->host_no, sdev->channel, sdev->id, sdev->lun,
640 qla2x00_ramp_up_queue_depth(scsi_qla_host_t *ha, srb_t *sp)
643 struct scsi_device *sdev;
645 sdev = sp->cmd->device;
646 if (sdev->queue_depth >= ha->max_q_depth)
650 if (time_before(jiffies,
651 fcport->last_ramp_up + ql2xqfullrampup * HZ))
653 if (time_before(jiffies,
654 fcport->last_queue_full + ql2xqfullrampup * HZ))
657 spin_unlock_irq(&ha->hardware_lock);
658 starget_for_each_device(sdev->sdev_target, fcport,
659 qla2x00_adjust_sdev_qdepth_up);
660 spin_lock_irq(&ha->hardware_lock);
664 * qla2x00_process_completed_request() - Process a Fast Post response.
665 * @ha: SCSI driver HA context
669 qla2x00_process_completed_request(struct scsi_qla_host *ha, uint32_t index)
673 /* Validate handle. */
674 if (index >= MAX_OUTSTANDING_COMMANDS) {
675 DEBUG2(printk("scsi(%ld): Invalid SCSI completion handle %d.\n",
676 ha->host_no, index));
677 qla_printk(KERN_WARNING, ha,
678 "Invalid SCSI completion handle %d.\n", index);
680 set_bit(ISP_ABORT_NEEDED, &ha->dpc_flags);
684 sp = ha->outstanding_cmds[index];
686 /* Free outstanding command slot. */
687 ha->outstanding_cmds[index] = NULL;
689 CMD_COMPL_STATUS(sp->cmd) = 0L;
690 CMD_SCSI_STATUS(sp->cmd) = 0L;
692 /* Save ISP completion status */
693 sp->cmd->result = DID_OK << 16;
695 qla2x00_ramp_up_queue_depth(ha, sp);
696 qla2x00_sp_compl(ha, sp);
698 DEBUG2(printk("scsi(%ld): Invalid ISP SCSI completion handle\n",
700 qla_printk(KERN_WARNING, ha,
701 "Invalid ISP SCSI completion handle\n");
703 set_bit(ISP_ABORT_NEEDED, &ha->dpc_flags);
708 * qla2x00_process_response_queue() - Process response queue entries.
709 * @ha: SCSI driver HA context
712 qla2x00_process_response_queue(struct scsi_qla_host *ha)
714 struct device_reg_2xxx __iomem *reg = &ha->iobase->isp;
719 if (!ha->flags.online)
722 while (ha->response_ring_ptr->signature != RESPONSE_PROCESSED) {
723 pkt = (sts_entry_t *)ha->response_ring_ptr;
725 ha->rsp_ring_index++;
726 if (ha->rsp_ring_index == ha->response_q_length) {
727 ha->rsp_ring_index = 0;
728 ha->response_ring_ptr = ha->response_ring;
730 ha->response_ring_ptr++;
733 if (pkt->entry_status != 0) {
734 DEBUG3(printk(KERN_INFO
735 "scsi(%ld): Process error entry.\n", ha->host_no));
737 qla2x00_error_entry(ha, pkt);
738 ((response_t *)pkt)->signature = RESPONSE_PROCESSED;
743 switch (pkt->entry_type) {
745 qla2x00_status_entry(ha, pkt);
748 handle_cnt = ((sts21_entry_t *)pkt)->handle_count;
749 for (cnt = 0; cnt < handle_cnt; cnt++) {
750 qla2x00_process_completed_request(ha,
751 ((sts21_entry_t *)pkt)->handle[cnt]);
755 handle_cnt = ((sts22_entry_t *)pkt)->handle_count;
756 for (cnt = 0; cnt < handle_cnt; cnt++) {
757 qla2x00_process_completed_request(ha,
758 ((sts22_entry_t *)pkt)->handle[cnt]);
761 case STATUS_CONT_TYPE:
762 qla2x00_status_cont_entry(ha, (sts_cont_entry_t *)pkt);
765 qla2x00_ms_entry(ha, (ms_iocb_entry_t *)pkt);
768 /* Type Not Supported. */
769 DEBUG4(printk(KERN_WARNING
770 "scsi(%ld): Received unknown response pkt type %x "
771 "entry status=%x.\n",
772 ha->host_no, pkt->entry_type, pkt->entry_status));
775 ((response_t *)pkt)->signature = RESPONSE_PROCESSED;
779 /* Adjust ring index */
780 WRT_REG_WORD(ISP_RSP_Q_OUT(ha, reg), ha->rsp_ring_index);
784 * qla2x00_status_entry() - Process a Status IOCB entry.
785 * @ha: SCSI driver HA context
786 * @pkt: Entry pointer
789 qla2x00_status_entry(scsi_qla_host_t *ha, void *pkt)
793 struct scsi_cmnd *cp;
795 struct sts_entry_24xx *sts24;
796 uint16_t comp_status;
797 uint16_t scsi_status;
798 uint8_t lscsi_status;
800 uint32_t sense_len, rsp_info_len, resid_len, fw_resid_len;
801 uint8_t *rsp_info, *sense_data;
803 sts = (sts_entry_t *) pkt;
804 sts24 = (struct sts_entry_24xx *) pkt;
805 if (IS_QLA24XX(ha) || IS_QLA54XX(ha)) {
806 comp_status = le16_to_cpu(sts24->comp_status);
807 scsi_status = le16_to_cpu(sts24->scsi_status) & SS_MASK;
809 comp_status = le16_to_cpu(sts->comp_status);
810 scsi_status = le16_to_cpu(sts->scsi_status) & SS_MASK;
813 /* Fast path completion. */
814 if (comp_status == CS_COMPLETE && scsi_status == 0) {
815 qla2x00_process_completed_request(ha, sts->handle);
820 /* Validate handle. */
821 if (sts->handle < MAX_OUTSTANDING_COMMANDS) {
822 sp = ha->outstanding_cmds[sts->handle];
823 ha->outstanding_cmds[sts->handle] = NULL;
828 DEBUG2(printk("scsi(%ld): Status Entry invalid handle.\n",
830 qla_printk(KERN_WARNING, ha, "Status Entry invalid handle.\n");
832 set_bit(ISP_ABORT_NEEDED, &ha->dpc_flags);
833 qla2xxx_wake_dpc(ha);
838 DEBUG2(printk("scsi(%ld): Command already returned back to OS "
839 "pkt->handle=%d sp=%p.\n", ha->host_no, sts->handle, sp));
840 qla_printk(KERN_WARNING, ha,
841 "Command is NULL: already returned to OS (sp=%p)\n", sp);
846 lscsi_status = scsi_status & STATUS_MASK;
847 CMD_ENTRY_STATUS(cp) = sts->entry_status;
848 CMD_COMPL_STATUS(cp) = comp_status;
849 CMD_SCSI_STATUS(cp) = scsi_status;
853 sense_len = rsp_info_len = resid_len = fw_resid_len = 0;
854 if (IS_QLA24XX(ha) || IS_QLA54XX(ha)) {
855 sense_len = le32_to_cpu(sts24->sense_len);
856 rsp_info_len = le32_to_cpu(sts24->rsp_data_len);
857 resid_len = le32_to_cpu(sts24->rsp_residual_count);
858 fw_resid_len = le32_to_cpu(sts24->residual_len);
859 rsp_info = sts24->data;
860 sense_data = sts24->data;
861 host_to_fcp_swap(sts24->data, sizeof(sts24->data));
863 sense_len = le16_to_cpu(sts->req_sense_length);
864 rsp_info_len = le16_to_cpu(sts->rsp_info_len);
865 resid_len = le32_to_cpu(sts->residual_length);
866 rsp_info = sts->rsp_info;
867 sense_data = sts->req_sense_data;
870 /* Check for any FCP transport errors. */
871 if (scsi_status & SS_RESPONSE_INFO_LEN_VALID) {
872 /* Sense data lies beyond any FCP RESPONSE data. */
873 if (IS_QLA24XX(ha) || IS_QLA54XX(ha))
874 sense_data += rsp_info_len;
875 if (rsp_info_len > 3 && rsp_info[3]) {
876 DEBUG2(printk("scsi(%ld:%d:%d:%d) FCP I/O protocol "
877 "failure (%x/%02x%02x%02x%02x%02x%02x%02x%02x)..."
878 "retrying command\n", ha->host_no,
879 cp->device->channel, cp->device->id,
880 cp->device->lun, rsp_info_len, rsp_info[0],
881 rsp_info[1], rsp_info[2], rsp_info[3], rsp_info[4],
882 rsp_info[5], rsp_info[6], rsp_info[7]));
884 cp->result = DID_BUS_BUSY << 16;
885 qla2x00_sp_compl(ha, sp);
891 * Based on Host and scsi status generate status code for Linux
893 switch (comp_status) {
896 if (scsi_status == 0) {
897 cp->result = DID_OK << 16;
900 if (scsi_status & (SS_RESIDUAL_UNDER | SS_RESIDUAL_OVER)) {
903 CMD_RESID_LEN(cp) = resid;
906 ((unsigned)(cp->request_bufflen - resid) <
908 qla_printk(KERN_INFO, ha,
909 "scsi(%ld:%d:%d:%d): Mid-layer underflow "
910 "detected (%x of %x bytes)...returning "
911 "error status.\n", ha->host_no,
912 cp->device->channel, cp->device->id,
913 cp->device->lun, resid,
914 cp->request_bufflen);
916 cp->result = DID_ERROR << 16;
920 cp->result = DID_OK << 16 | lscsi_status;
922 if (lscsi_status == SAM_STAT_TASK_SET_FULL) {
923 DEBUG2(printk(KERN_INFO
924 "scsi(%ld): QUEUE FULL status detected "
925 "0x%x-0x%x.\n", ha->host_no, comp_status,
928 /* Adjust queue depth for all luns on the port. */
929 fcport->last_queue_full = jiffies;
930 spin_unlock_irq(&ha->hardware_lock);
931 starget_for_each_device(cp->device->sdev_target,
932 fcport, qla2x00_adjust_sdev_qdepth_down);
933 spin_lock_irq(&ha->hardware_lock);
936 if (lscsi_status != SS_CHECK_CONDITION)
939 /* Copy Sense Data into sense buffer. */
940 memset(cp->sense_buffer, 0, sizeof(cp->sense_buffer));
942 if (!(scsi_status & SS_SENSE_LEN_VALID))
945 if (sense_len >= sizeof(cp->sense_buffer))
946 sense_len = sizeof(cp->sense_buffer);
948 CMD_ACTUAL_SNSLEN(cp) = sense_len;
949 sp->request_sense_length = sense_len;
950 sp->request_sense_ptr = cp->sense_buffer;
952 if (sp->request_sense_length > 32)
955 memcpy(cp->sense_buffer, sense_data, sense_len);
957 sp->request_sense_ptr += sense_len;
958 sp->request_sense_length -= sense_len;
959 if (sp->request_sense_length != 0)
962 DEBUG5(printk("%s(): Check condition Sense data, "
963 "scsi(%ld:%d:%d:%d) cmd=%p pid=%ld\n", __func__,
964 ha->host_no, cp->device->channel, cp->device->id,
965 cp->device->lun, cp, cp->serial_number));
967 DEBUG5(qla2x00_dump_buffer(cp->sense_buffer,
968 CMD_ACTUAL_SNSLEN(cp)));
971 case CS_DATA_UNDERRUN:
973 /* Use F/W calculated residual length. */
974 if (IS_QLA24XX(ha) || IS_QLA54XX(ha))
975 resid = fw_resid_len;
977 if (scsi_status & SS_RESIDUAL_UNDER) {
979 CMD_RESID_LEN(cp) = resid;
981 DEBUG2(printk(KERN_INFO
982 "scsi(%ld:%d:%d) UNDERRUN status detected "
983 "0x%x-0x%x. resid=0x%x fw_resid=0x%x cdb=0x%x "
984 "os_underflow=0x%x\n", ha->host_no,
985 cp->device->id, cp->device->lun, comp_status,
986 scsi_status, resid_len, resid, cp->cmnd[0],
992 * Check to see if SCSI Status is non zero. If so report SCSI
995 if (lscsi_status != 0) {
996 cp->result = DID_OK << 16 | lscsi_status;
998 if (lscsi_status != SS_CHECK_CONDITION)
1001 /* Copy Sense Data into sense buffer */
1002 memset(cp->sense_buffer, 0, sizeof(cp->sense_buffer));
1004 if (!(scsi_status & SS_SENSE_LEN_VALID))
1007 if (sense_len >= sizeof(cp->sense_buffer))
1008 sense_len = sizeof(cp->sense_buffer);
1010 CMD_ACTUAL_SNSLEN(cp) = sense_len;
1011 sp->request_sense_length = sense_len;
1012 sp->request_sense_ptr = cp->sense_buffer;
1014 if (sp->request_sense_length > 32)
1017 memcpy(cp->sense_buffer, sense_data, sense_len);
1019 sp->request_sense_ptr += sense_len;
1020 sp->request_sense_length -= sense_len;
1021 if (sp->request_sense_length != 0)
1022 ha->status_srb = sp;
1024 DEBUG5(printk("%s(): Check condition Sense data, "
1025 "scsi(%ld:%d:%d:%d) cmd=%p pid=%ld\n",
1026 __func__, ha->host_no, cp->device->channel,
1027 cp->device->id, cp->device->lun, cp,
1028 cp->serial_number));
1031 DEBUG5(qla2x00_dump_buffer(cp->sense_buffer,
1032 CMD_ACTUAL_SNSLEN(cp)));
1035 * If RISC reports underrun and target does not report
1036 * it then we must have a lost frame, so tell upper
1037 * layer to retry it by reporting a bus busy.
1039 if (!(scsi_status & SS_RESIDUAL_UNDER)) {
1040 DEBUG2(printk("scsi(%ld:%d:%d:%d) Dropped "
1041 "frame(s) detected (%x of %x bytes)..."
1042 "retrying command.\n", ha->host_no,
1043 cp->device->channel, cp->device->id,
1044 cp->device->lun, resid,
1045 cp->request_bufflen));
1047 cp->result = DID_BUS_BUSY << 16;
1051 /* Handle mid-layer underflow */
1052 if ((unsigned)(cp->request_bufflen - resid) <
1054 qla_printk(KERN_INFO, ha,
1055 "scsi(%ld:%d:%d:%d): Mid-layer underflow "
1056 "detected (%x of %x bytes)...returning "
1057 "error status.\n", ha->host_no,
1058 cp->device->channel, cp->device->id,
1059 cp->device->lun, resid,
1060 cp->request_bufflen);
1062 cp->result = DID_ERROR << 16;
1066 /* Everybody online, looking good... */
1067 cp->result = DID_OK << 16;
1071 case CS_DATA_OVERRUN:
1072 DEBUG2(printk(KERN_INFO
1073 "scsi(%ld:%d:%d): OVERRUN status detected 0x%x-0x%x\n",
1074 ha->host_no, cp->device->id, cp->device->lun, comp_status,
1076 DEBUG2(printk(KERN_INFO
1077 "CDB: 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x\n",
1078 cp->cmnd[0], cp->cmnd[1], cp->cmnd[2], cp->cmnd[3],
1079 cp->cmnd[4], cp->cmnd[5]));
1080 DEBUG2(printk(KERN_INFO
1081 "PID=0x%lx req=0x%x xtra=0x%x -- returning DID_ERROR "
1083 cp->serial_number, cp->request_bufflen, resid_len));
1085 cp->result = DID_ERROR << 16;
1088 case CS_PORT_LOGGED_OUT:
1089 case CS_PORT_CONFIG_CHG:
1092 case CS_PORT_UNAVAILABLE:
1094 * If the port is in Target Down state, return all IOs for this
1095 * Target with DID_NO_CONNECT ELSE Queue the IOs in the
1098 DEBUG2(printk("scsi(%ld:%d:%d): status_entry: Port Down "
1099 "pid=%ld, compl status=0x%x, port state=0x%x\n",
1100 ha->host_no, cp->device->id, cp->device->lun,
1101 cp->serial_number, comp_status,
1102 atomic_read(&fcport->state)));
1104 cp->result = DID_BUS_BUSY << 16;
1105 if (atomic_read(&fcport->state) == FCS_ONLINE) {
1106 qla2x00_mark_device_lost(ha, fcport, 1, 1);
1111 DEBUG2(printk(KERN_INFO
1112 "scsi(%ld): RESET status detected 0x%x-0x%x.\n",
1113 ha->host_no, comp_status, scsi_status));
1115 cp->result = DID_RESET << 16;
1120 * hv2.19.12 - DID_ABORT does not retry the request if we
1121 * aborted this request then abort otherwise it must be a
1124 DEBUG2(printk(KERN_INFO
1125 "scsi(%ld): ABORT status detected 0x%x-0x%x.\n",
1126 ha->host_no, comp_status, scsi_status));
1128 cp->result = DID_RESET << 16;
1132 cp->result = DID_BUS_BUSY << 16;
1134 if (IS_QLA24XX(ha) || IS_QLA54XX(ha)) {
1135 DEBUG2(printk(KERN_INFO
1136 "scsi(%ld:%d:%d:%d): TIMEOUT status detected "
1137 "0x%x-0x%x\n", ha->host_no, cp->device->channel,
1138 cp->device->id, cp->device->lun, comp_status,
1142 DEBUG2(printk(KERN_INFO
1143 "scsi(%ld:%d:%d:%d): TIMEOUT status detected 0x%x-0x%x "
1144 "sflags=%x.\n", ha->host_no, cp->device->channel,
1145 cp->device->id, cp->device->lun, comp_status, scsi_status,
1146 le16_to_cpu(sts->status_flags)));
1148 /* Check to see if logout occurred. */
1149 if ((le16_to_cpu(sts->status_flags) & SF_LOGOUT_SENT))
1150 qla2x00_mark_device_lost(ha, fcport, 1, 1);
1154 DEBUG3(printk("scsi(%ld): Error detected (unknown status) "
1155 "0x%x-0x%x.\n", ha->host_no, comp_status, scsi_status));
1156 qla_printk(KERN_INFO, ha,
1157 "Unknown status detected 0x%x-0x%x.\n",
1158 comp_status, scsi_status);
1160 cp->result = DID_ERROR << 16;
1164 /* Place command on done queue. */
1165 if (ha->status_srb == NULL)
1166 qla2x00_sp_compl(ha, sp);
1170 * qla2x00_status_cont_entry() - Process a Status Continuations entry.
1171 * @ha: SCSI driver HA context
1172 * @pkt: Entry pointer
1174 * Extended sense data.
1177 qla2x00_status_cont_entry(scsi_qla_host_t *ha, sts_cont_entry_t *pkt)
1179 uint8_t sense_sz = 0;
1180 srb_t *sp = ha->status_srb;
1181 struct scsi_cmnd *cp;
1183 if (sp != NULL && sp->request_sense_length != 0) {
1186 DEBUG2(printk("%s(): Cmd already returned back to OS "
1187 "sp=%p.\n", __func__, sp));
1188 qla_printk(KERN_INFO, ha,
1189 "cmd is NULL: already returned to OS (sp=%p)\n",
1192 ha->status_srb = NULL;
1196 if (sp->request_sense_length > sizeof(pkt->data)) {
1197 sense_sz = sizeof(pkt->data);
1199 sense_sz = sp->request_sense_length;
1202 /* Move sense data. */
1203 if (IS_QLA24XX(ha) || IS_QLA54XX(ha))
1204 host_to_fcp_swap(pkt->data, sizeof(pkt->data));
1205 memcpy(sp->request_sense_ptr, pkt->data, sense_sz);
1206 DEBUG5(qla2x00_dump_buffer(sp->request_sense_ptr, sense_sz));
1208 sp->request_sense_ptr += sense_sz;
1209 sp->request_sense_length -= sense_sz;
1211 /* Place command on done queue. */
1212 if (sp->request_sense_length == 0) {
1213 ha->status_srb = NULL;
1214 qla2x00_sp_compl(ha, sp);
1220 * qla2x00_error_entry() - Process an error entry.
1221 * @ha: SCSI driver HA context
1222 * @pkt: Entry pointer
1225 qla2x00_error_entry(scsi_qla_host_t *ha, sts_entry_t *pkt)
1229 #if defined(QL_DEBUG_LEVEL_2)
1230 if (pkt->entry_status & RF_INV_E_ORDER)
1231 qla_printk(KERN_ERR, ha, "%s: Invalid Entry Order\n", __func__);
1232 else if (pkt->entry_status & RF_INV_E_COUNT)
1233 qla_printk(KERN_ERR, ha, "%s: Invalid Entry Count\n", __func__);
1234 else if (pkt->entry_status & RF_INV_E_PARAM)
1235 qla_printk(KERN_ERR, ha,
1236 "%s: Invalid Entry Parameter\n", __func__);
1237 else if (pkt->entry_status & RF_INV_E_TYPE)
1238 qla_printk(KERN_ERR, ha, "%s: Invalid Entry Type\n", __func__);
1239 else if (pkt->entry_status & RF_BUSY)
1240 qla_printk(KERN_ERR, ha, "%s: Busy\n", __func__);
1242 qla_printk(KERN_ERR, ha, "%s: UNKNOWN flag error\n", __func__);
1245 /* Validate handle. */
1246 if (pkt->handle < MAX_OUTSTANDING_COMMANDS)
1247 sp = ha->outstanding_cmds[pkt->handle];
1252 /* Free outstanding command slot. */
1253 ha->outstanding_cmds[pkt->handle] = NULL;
1255 /* Bad payload or header */
1256 if (pkt->entry_status &
1257 (RF_INV_E_ORDER | RF_INV_E_COUNT |
1258 RF_INV_E_PARAM | RF_INV_E_TYPE)) {
1259 sp->cmd->result = DID_ERROR << 16;
1260 } else if (pkt->entry_status & RF_BUSY) {
1261 sp->cmd->result = DID_BUS_BUSY << 16;
1263 sp->cmd->result = DID_ERROR << 16;
1265 qla2x00_sp_compl(ha, sp);
1267 } else if (pkt->entry_type == COMMAND_A64_TYPE || pkt->entry_type ==
1268 COMMAND_TYPE || pkt->entry_type == COMMAND_TYPE_7) {
1269 DEBUG2(printk("scsi(%ld): Error entry - invalid handle\n",
1271 qla_printk(KERN_WARNING, ha,
1272 "Error entry - invalid handle\n");
1274 set_bit(ISP_ABORT_NEEDED, &ha->dpc_flags);
1275 qla2xxx_wake_dpc(ha);
1280 * qla2x00_ms_entry() - Process a Management Server entry.
1281 * @ha: SCSI driver HA context
1282 * @index: Response queue out pointer
1285 qla2x00_ms_entry(scsi_qla_host_t *ha, ms_iocb_entry_t *pkt)
1289 DEBUG3(printk("%s(%ld): pkt=%p pkthandle=%d.\n",
1290 __func__, ha->host_no, pkt, pkt->handle1));
1292 /* Validate handle. */
1293 if (pkt->handle1 < MAX_OUTSTANDING_COMMANDS)
1294 sp = ha->outstanding_cmds[pkt->handle1];
1299 DEBUG2(printk("scsi(%ld): MS entry - invalid handle\n",
1301 qla_printk(KERN_WARNING, ha, "MS entry - invalid handle\n");
1303 set_bit(ISP_ABORT_NEEDED, &ha->dpc_flags);
1307 CMD_COMPL_STATUS(sp->cmd) = le16_to_cpu(pkt->status);
1308 CMD_ENTRY_STATUS(sp->cmd) = pkt->entry_status;
1310 /* Free outstanding command slot. */
1311 ha->outstanding_cmds[pkt->handle1] = NULL;
1313 qla2x00_sp_compl(ha, sp);
1318 * qla24xx_mbx_completion() - Process mailbox command completions.
1319 * @ha: SCSI driver HA context
1320 * @mb0: Mailbox0 register
1323 qla24xx_mbx_completion(scsi_qla_host_t *ha, uint16_t mb0)
1326 uint16_t __iomem *wptr;
1327 struct device_reg_24xx __iomem *reg = &ha->iobase->isp24;
1329 /* Load return mailbox registers. */
1330 ha->flags.mbox_int = 1;
1331 ha->mailbox_out[0] = mb0;
1332 wptr = (uint16_t __iomem *)®->mailbox1;
1334 for (cnt = 1; cnt < ha->mbx_count; cnt++) {
1335 ha->mailbox_out[cnt] = RD_REG_WORD(wptr);
1340 DEBUG3(printk("%s(%ld): Got mailbox completion. cmd=%x.\n",
1341 __func__, ha->host_no, ha->mcp->mb[0]));
1343 DEBUG2_3(printk("%s(%ld): MBX pointer ERROR!\n",
1344 __func__, ha->host_no));
1349 * qla24xx_process_response_queue() - Process response queue entries.
1350 * @ha: SCSI driver HA context
1353 qla24xx_process_response_queue(struct scsi_qla_host *ha)
1355 struct device_reg_24xx __iomem *reg = &ha->iobase->isp24;
1356 struct sts_entry_24xx *pkt;
1358 if (!ha->flags.online)
1361 while (ha->response_ring_ptr->signature != RESPONSE_PROCESSED) {
1362 pkt = (struct sts_entry_24xx *)ha->response_ring_ptr;
1364 ha->rsp_ring_index++;
1365 if (ha->rsp_ring_index == ha->response_q_length) {
1366 ha->rsp_ring_index = 0;
1367 ha->response_ring_ptr = ha->response_ring;
1369 ha->response_ring_ptr++;
1372 if (pkt->entry_status != 0) {
1373 DEBUG3(printk(KERN_INFO
1374 "scsi(%ld): Process error entry.\n", ha->host_no));
1376 qla2x00_error_entry(ha, (sts_entry_t *) pkt);
1377 ((response_t *)pkt)->signature = RESPONSE_PROCESSED;
1382 switch (pkt->entry_type) {
1384 qla2x00_status_entry(ha, pkt);
1386 case STATUS_CONT_TYPE:
1387 qla2x00_status_cont_entry(ha, (sts_cont_entry_t *)pkt);
1390 qla24xx_ms_entry(ha, (struct ct_entry_24xx *)pkt);
1393 /* Type Not Supported. */
1394 DEBUG4(printk(KERN_WARNING
1395 "scsi(%ld): Received unknown response pkt type %x "
1396 "entry status=%x.\n",
1397 ha->host_no, pkt->entry_type, pkt->entry_status));
1400 ((response_t *)pkt)->signature = RESPONSE_PROCESSED;
1404 /* Adjust ring index */
1405 WRT_REG_DWORD(®->rsp_q_out, ha->rsp_ring_index);
1409 * qla24xx_intr_handler() - Process interrupts for the ISP23xx and ISP63xx.
1411 * @dev_id: SCSI driver HA context
1413 * Called by system whenever the host adapter generates an interrupt.
1415 * Returns handled flag.
1418 qla24xx_intr_handler(int irq, void *dev_id)
1420 scsi_qla_host_t *ha;
1421 struct device_reg_24xx __iomem *reg;
1423 unsigned long flags;
1429 ha = (scsi_qla_host_t *) dev_id;
1432 "%s(): NULL host pointer\n", __func__);
1436 reg = &ha->iobase->isp24;
1439 spin_lock_irqsave(&ha->hardware_lock, flags);
1440 for (iter = 50; iter--; ) {
1441 stat = RD_REG_DWORD(®->host_status);
1442 if (stat & HSRX_RISC_PAUSED) {
1443 hccr = RD_REG_DWORD(®->hccr);
1445 qla_printk(KERN_INFO, ha, "RISC paused -- HCCR=%x, "
1446 "Dumping firmware!\n", hccr);
1447 ha->isp_ops.fw_dump(ha, 1);
1448 set_bit(ISP_ABORT_NEEDED, &ha->dpc_flags);
1450 } else if ((stat & HSRX_RISC_INT) == 0)
1453 switch (stat & 0xff) {
1458 qla24xx_mbx_completion(ha, MSW(stat));
1459 status |= MBX_INTERRUPT;
1464 mb[1] = RD_REG_WORD(®->mailbox1);
1465 mb[2] = RD_REG_WORD(®->mailbox2);
1466 mb[3] = RD_REG_WORD(®->mailbox3);
1467 qla2x00_async_event(ha, mb);
1470 qla24xx_process_response_queue(ha);
1473 DEBUG2(printk("scsi(%ld): Unrecognized interrupt type "
1475 ha->host_no, stat & 0xff));
1478 WRT_REG_DWORD(®->hccr, HCCRX_CLR_RISC_INT);
1479 RD_REG_DWORD_RELAXED(®->hccr);
1481 spin_unlock_irqrestore(&ha->hardware_lock, flags);
1483 if (test_bit(MBX_INTR_WAIT, &ha->mbx_cmd_flags) &&
1484 (status & MBX_INTERRUPT) && ha->flags.mbox_int) {
1485 spin_lock_irqsave(&ha->mbx_reg_lock, flags);
1487 set_bit(MBX_INTERRUPT, &ha->mbx_cmd_flags);
1488 up(&ha->mbx_intr_sem);
1490 spin_unlock_irqrestore(&ha->mbx_reg_lock, flags);
1497 * qla24xx_ms_entry() - Process a Management Server entry.
1498 * @ha: SCSI driver HA context
1499 * @index: Response queue out pointer
1502 qla24xx_ms_entry(scsi_qla_host_t *ha, struct ct_entry_24xx *pkt)
1506 DEBUG3(printk("%s(%ld): pkt=%p pkthandle=%d.\n",
1507 __func__, ha->host_no, pkt, pkt->handle));
1509 DEBUG9(printk("%s: ct pkt dump:\n", __func__));
1510 DEBUG9(qla2x00_dump_buffer((void *)pkt, sizeof(struct ct_entry_24xx)));
1512 /* Validate handle. */
1513 if (pkt->handle < MAX_OUTSTANDING_COMMANDS)
1514 sp = ha->outstanding_cmds[pkt->handle];
1519 DEBUG2(printk("scsi(%ld): MS entry - invalid handle\n",
1521 DEBUG10(printk("scsi(%ld): MS entry - invalid handle\n",
1523 qla_printk(KERN_WARNING, ha, "MS entry - invalid handle %d\n",
1526 set_bit(ISP_ABORT_NEEDED, &ha->dpc_flags);
1530 CMD_COMPL_STATUS(sp->cmd) = le16_to_cpu(pkt->comp_status);
1531 CMD_ENTRY_STATUS(sp->cmd) = pkt->entry_status;
1533 /* Free outstanding command slot. */
1534 ha->outstanding_cmds[pkt->handle] = NULL;
1536 qla2x00_sp_compl(ha, sp);