2 * QLogic Fibre Channel HBA Driver
3 * Copyright (c) 2003-2005 QLogic Corporation
5 * See LICENSE.qla2xxx for copyright and licensing details.
9 static void qla2x00_mbx_completion(scsi_qla_host_t *, uint16_t);
10 static void qla2x00_async_event(scsi_qla_host_t *, uint16_t *);
11 static void qla2x00_process_completed_request(struct scsi_qla_host *, uint32_t);
12 static void qla2x00_status_entry(scsi_qla_host_t *, void *);
13 static void qla2x00_status_cont_entry(scsi_qla_host_t *, sts_cont_entry_t *);
14 static void qla2x00_error_entry(scsi_qla_host_t *, sts_entry_t *);
15 static void qla2x00_ms_entry(scsi_qla_host_t *, ms_iocb_entry_t *);
17 static void qla24xx_ms_entry(scsi_qla_host_t *, struct ct_entry_24xx *);
20 * qla2100_intr_handler() - Process interrupts for the ISP2100 and ISP2200.
22 * @dev_id: SCSI driver HA context
25 * Called by system whenever the host adapter generates an interrupt.
27 * Returns handled flag.
30 qla2100_intr_handler(int irq, void *dev_id, struct pt_regs *regs)
33 struct device_reg_2xxx __iomem *reg;
39 ha = (scsi_qla_host_t *) dev_id;
42 "%s(): NULL host pointer\n", __func__);
46 reg = &ha->iobase->isp;
49 spin_lock_irqsave(&ha->hardware_lock, flags);
50 for (iter = 50; iter--; ) {
51 if ((RD_REG_WORD(®->istatus) & ISR_RISC_INT) == 0)
54 if (RD_REG_WORD(®->semaphore) & BIT_0) {
55 WRT_REG_WORD(®->hccr, HCCR_CLR_RISC_INT);
56 RD_REG_WORD(®->hccr);
58 /* Get mailbox data. */
59 mb[0] = RD_MAILBOX_REG(ha, reg, 0);
60 if (mb[0] > 0x3fff && mb[0] < 0x8000) {
61 qla2x00_mbx_completion(ha, mb[0]);
62 status |= MBX_INTERRUPT;
63 } else if (mb[0] > 0x7fff && mb[0] < 0xc000) {
64 mb[1] = RD_MAILBOX_REG(ha, reg, 1);
65 mb[2] = RD_MAILBOX_REG(ha, reg, 2);
66 mb[3] = RD_MAILBOX_REG(ha, reg, 3);
67 qla2x00_async_event(ha, mb);
70 DEBUG2(printk("scsi(%ld): Unrecognized "
71 "interrupt type (%d).\n",
74 /* Release mailbox registers. */
75 WRT_REG_WORD(®->semaphore, 0);
76 RD_REG_WORD(®->semaphore);
78 qla2x00_process_response_queue(ha);
80 WRT_REG_WORD(®->hccr, HCCR_CLR_RISC_INT);
81 RD_REG_WORD(®->hccr);
84 spin_unlock_irqrestore(&ha->hardware_lock, flags);
86 if (test_bit(MBX_INTR_WAIT, &ha->mbx_cmd_flags) &&
87 (status & MBX_INTERRUPT) && ha->flags.mbox_int) {
88 spin_lock_irqsave(&ha->mbx_reg_lock, flags);
90 set_bit(MBX_INTERRUPT, &ha->mbx_cmd_flags);
91 up(&ha->mbx_intr_sem);
93 spin_unlock_irqrestore(&ha->mbx_reg_lock, flags);
100 * qla2300_intr_handler() - Process interrupts for the ISP23xx and ISP63xx.
102 * @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, struct pt_regs *regs)
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,
138 "Parity error -- HCCR=%x.\n", hccr);
140 qla_printk(KERN_INFO, ha,
141 "RISC paused -- HCCR=%x.\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);
150 set_bit(ISP_ABORT_NEEDED, &ha->dpc_flags);
152 } else if ((stat & HSR_RISC_INT) == 0)
155 switch (stat & 0xff) {
160 qla2x00_mbx_completion(ha, MSW(stat));
161 status |= MBX_INTERRUPT;
163 /* Release mailbox registers. */
164 WRT_REG_WORD(®->semaphore, 0);
168 mb[1] = RD_MAILBOX_REG(ha, reg, 1);
169 mb[2] = RD_MAILBOX_REG(ha, reg, 2);
170 mb[3] = RD_MAILBOX_REG(ha, reg, 3);
171 qla2x00_async_event(ha, mb);
174 qla2x00_process_response_queue(ha);
177 mb[0] = MBA_CMPLT_1_16BIT;
179 qla2x00_async_event(ha, mb);
182 mb[0] = MBA_SCSI_COMPLETION;
184 mb[2] = RD_MAILBOX_REG(ha, reg, 2);
185 qla2x00_async_event(ha, mb);
188 DEBUG2(printk("scsi(%ld): Unrecognized interrupt type "
190 ha->host_no, stat & 0xff));
193 WRT_REG_WORD(®->hccr, HCCR_CLR_RISC_INT);
194 RD_REG_WORD_RELAXED(®->hccr);
196 spin_unlock_irqrestore(&ha->hardware_lock, flags);
198 if (test_bit(MBX_INTR_WAIT, &ha->mbx_cmd_flags) &&
199 (status & MBX_INTERRUPT) && ha->flags.mbox_int) {
200 spin_lock_irqsave(&ha->mbx_reg_lock, flags);
202 set_bit(MBX_INTERRUPT, &ha->mbx_cmd_flags);
203 up(&ha->mbx_intr_sem);
205 spin_unlock_irqrestore(&ha->mbx_reg_lock, flags);
208 return (IRQ_HANDLED);
212 * qla2x00_mbx_completion() - Process mailbox command completions.
213 * @ha: SCSI driver HA context
214 * @mb0: Mailbox0 register
217 qla2x00_mbx_completion(scsi_qla_host_t *ha, uint16_t mb0)
220 uint16_t __iomem *wptr;
221 struct device_reg_2xxx __iomem *reg = &ha->iobase->isp;
223 /* Load return mailbox registers. */
224 ha->flags.mbox_int = 1;
225 ha->mailbox_out[0] = mb0;
226 wptr = (uint16_t __iomem *)MAILBOX_REG(ha, reg, 1);
228 for (cnt = 1; cnt < ha->mbx_count; cnt++) {
229 if (IS_QLA2200(ha) && cnt == 8)
230 wptr = (uint16_t __iomem *)MAILBOX_REG(ha, reg, 8);
231 if (cnt == 4 || cnt == 5)
232 ha->mailbox_out[cnt] = qla2x00_debounce_register(wptr);
234 ha->mailbox_out[cnt] = RD_REG_WORD(wptr);
240 DEBUG3(printk("%s(%ld): Got mailbox completion. cmd=%x.\n",
241 __func__, ha->host_no, ha->mcp->mb[0]));
243 DEBUG2_3(printk("%s(%ld): MBX pointer ERROR!\n",
244 __func__, ha->host_no));
249 * qla2x00_async_event() - Process aynchronous events.
250 * @ha: SCSI driver HA context
251 * @mb: Mailbox registers (0 - 3)
254 qla2x00_async_event(scsi_qla_host_t *ha, uint16_t *mb)
257 static char *link_speeds[5] = { "1", "2", "?", "4", "10" };
262 struct device_reg_2xxx __iomem *reg = &ha->iobase->isp;
263 uint32_t rscn_entry, host_pid;
264 uint8_t rscn_queue_index;
266 /* Setup to process RIO completion. */
269 case MBA_SCSI_COMPLETION:
270 handles[0] = le32_to_cpu((uint32_t)((mb[2] << 16) | mb[1]));
273 case MBA_CMPLT_1_16BIT:
276 mb[0] = MBA_SCSI_COMPLETION;
278 case MBA_CMPLT_2_16BIT:
282 mb[0] = MBA_SCSI_COMPLETION;
284 case MBA_CMPLT_3_16BIT:
289 mb[0] = MBA_SCSI_COMPLETION;
291 case MBA_CMPLT_4_16BIT:
295 handles[3] = (uint32_t)RD_MAILBOX_REG(ha, reg, 6);
297 mb[0] = MBA_SCSI_COMPLETION;
299 case MBA_CMPLT_5_16BIT:
303 handles[3] = (uint32_t)RD_MAILBOX_REG(ha, reg, 6);
304 handles[4] = (uint32_t)RD_MAILBOX_REG(ha, reg, 7);
306 mb[0] = MBA_SCSI_COMPLETION;
308 case MBA_CMPLT_2_32BIT:
309 handles[0] = le32_to_cpu((uint32_t)((mb[2] << 16) | mb[1]));
310 handles[1] = le32_to_cpu(
311 ((uint32_t)(RD_MAILBOX_REG(ha, reg, 7) << 16)) |
312 RD_MAILBOX_REG(ha, reg, 6));
314 mb[0] = MBA_SCSI_COMPLETION;
321 case MBA_SCSI_COMPLETION: /* Fast Post */
322 if (!ha->flags.online)
325 for (cnt = 0; cnt < handle_cnt; cnt++)
326 qla2x00_process_completed_request(ha, handles[cnt]);
329 case MBA_RESET: /* Reset */
330 DEBUG2(printk("scsi(%ld): Asynchronous RESET.\n", ha->host_no));
332 set_bit(RESET_MARKER_NEEDED, &ha->dpc_flags);
335 case MBA_SYSTEM_ERR: /* System Error */
336 mb[1] = RD_MAILBOX_REG(ha, reg, 1);
337 mb[2] = RD_MAILBOX_REG(ha, reg, 2);
338 mb[3] = RD_MAILBOX_REG(ha, reg, 3);
340 qla_printk(KERN_INFO, ha,
341 "ISP System Error - mbx1=%xh mbx2=%xh mbx3=%xh.\n",
342 mb[1], mb[2], mb[3]);
344 ha->isp_ops.fw_dump(ha, 1);
346 if (IS_QLA24XX(ha) || IS_QLA25XX(ha)) {
347 if (mb[1] == 0 && mb[2] == 0) {
348 qla_printk(KERN_ERR, ha,
349 "Unrecoverable Hardware Error: adapter "
350 "marked OFFLINE!\n");
351 ha->flags.online = 0;
353 set_bit(ISP_ABORT_NEEDED, &ha->dpc_flags);
354 } else if (mb[1] == 0) {
355 qla_printk(KERN_INFO, ha,
356 "Unrecoverable Hardware Error: adapter marked "
358 ha->flags.online = 0;
360 set_bit(ISP_ABORT_NEEDED, &ha->dpc_flags);
363 case MBA_REQ_TRANSFER_ERR: /* Request Transfer Error */
364 DEBUG2(printk("scsi(%ld): ISP Request Transfer Error.\n",
366 qla_printk(KERN_WARNING, ha, "ISP Request Transfer Error.\n");
368 set_bit(ISP_ABORT_NEEDED, &ha->dpc_flags);
371 case MBA_RSP_TRANSFER_ERR: /* Response Transfer Error */
372 DEBUG2(printk("scsi(%ld): ISP Response Transfer Error.\n",
374 qla_printk(KERN_WARNING, ha, "ISP Response Transfer Error.\n");
376 set_bit(ISP_ABORT_NEEDED, &ha->dpc_flags);
379 case MBA_WAKEUP_THRES: /* Request Queue Wake-up */
380 DEBUG2(printk("scsi(%ld): Asynchronous WAKEUP_THRES.\n",
384 case MBA_LIP_OCCURRED: /* Loop Initialization Procedure */
385 DEBUG2(printk("scsi(%ld): LIP occured (%x).\n", ha->host_no,
387 qla_printk(KERN_INFO, ha, "LIP occured (%x).\n", mb[1]);
389 if (atomic_read(&ha->loop_state) != LOOP_DOWN) {
390 atomic_set(&ha->loop_state, LOOP_DOWN);
391 atomic_set(&ha->loop_down_timer, LOOP_DOWN_TIME);
392 qla2x00_mark_all_devices_lost(ha);
395 set_bit(REGISTER_FC4_NEEDED, &ha->dpc_flags);
397 ha->flags.management_server_logged_in = 0;
399 /* Update AEN queue. */
400 qla2x00_enqueue_aen(ha, MBA_LIP_OCCURRED, NULL);
404 case MBA_LOOP_UP: /* Loop Up Event */
405 ha->link_data_rate = 0;
406 if (IS_QLA2100(ha) || IS_QLA2200(ha)) {
407 link_speed = link_speeds[0];
409 link_speed = link_speeds[LS_UNKNOWN];
411 link_speed = link_speeds[mb[1]];
412 ha->link_data_rate = mb[1];
415 DEBUG2(printk("scsi(%ld): Asynchronous LOOP UP (%s Gbps).\n",
416 ha->host_no, link_speed));
417 qla_printk(KERN_INFO, ha, "LOOP UP detected (%s Gbps).\n",
420 ha->flags.management_server_logged_in = 0;
422 /* Update AEN queue. */
423 qla2x00_enqueue_aen(ha, MBA_LOOP_UP, NULL);
426 case MBA_LOOP_DOWN: /* Loop Down Event */
427 DEBUG2(printk("scsi(%ld): Asynchronous LOOP DOWN (%x).\n",
428 ha->host_no, mb[1]));
429 qla_printk(KERN_INFO, ha, "LOOP DOWN detected (%x).\n", mb[1]);
431 if (atomic_read(&ha->loop_state) != LOOP_DOWN) {
432 atomic_set(&ha->loop_state, LOOP_DOWN);
433 atomic_set(&ha->loop_down_timer, LOOP_DOWN_TIME);
434 ha->device_flags |= DFLG_NO_CABLE;
435 qla2x00_mark_all_devices_lost(ha);
438 ha->flags.management_server_logged_in = 0;
439 ha->link_data_rate = 0;
441 set_bit(REGISTER_FDMI_NEEDED, &ha->dpc_flags);
443 /* Update AEN queue. */
444 qla2x00_enqueue_aen(ha, MBA_LOOP_DOWN, NULL);
447 case MBA_LIP_RESET: /* LIP reset occurred */
448 DEBUG2(printk("scsi(%ld): Asynchronous LIP RESET (%x).\n",
449 ha->host_no, mb[1]));
450 qla_printk(KERN_INFO, ha,
451 "LIP reset occured (%x).\n", mb[1]);
453 if (atomic_read(&ha->loop_state) != LOOP_DOWN) {
454 atomic_set(&ha->loop_state, LOOP_DOWN);
455 atomic_set(&ha->loop_down_timer, LOOP_DOWN_TIME);
456 qla2x00_mark_all_devices_lost(ha);
459 set_bit(RESET_MARKER_NEEDED, &ha->dpc_flags);
461 ha->operating_mode = LOOP;
462 ha->flags.management_server_logged_in = 0;
464 /* Update AEN queue. */
465 qla2x00_enqueue_aen(ha, MBA_LIP_RESET, NULL);
469 case MBA_POINT_TO_POINT: /* Point-to-Point */
473 DEBUG2(printk("scsi(%ld): Asynchronous P2P MODE received.\n",
477 * Until there's a transition from loop down to loop up, treat
478 * this as loop down only.
480 if (atomic_read(&ha->loop_state) != LOOP_DOWN) {
481 atomic_set(&ha->loop_state, LOOP_DOWN);
482 if (!atomic_read(&ha->loop_down_timer))
483 atomic_set(&ha->loop_down_timer,
485 qla2x00_mark_all_devices_lost(ha);
488 if (!(test_bit(ABORT_ISP_ACTIVE, &ha->dpc_flags))) {
489 set_bit(RESET_MARKER_NEEDED, &ha->dpc_flags);
491 set_bit(REGISTER_FC4_NEEDED, &ha->dpc_flags);
494 case MBA_CHG_IN_CONNECTION: /* Change in connection mode */
498 DEBUG2(printk("scsi(%ld): Asynchronous Change In Connection "
501 qla_printk(KERN_INFO, ha,
502 "Configuration change detected: value=%x.\n", mb[1]);
504 if (atomic_read(&ha->loop_state) != LOOP_DOWN) {
505 atomic_set(&ha->loop_state, LOOP_DOWN);
506 if (!atomic_read(&ha->loop_down_timer))
507 atomic_set(&ha->loop_down_timer,
509 qla2x00_mark_all_devices_lost(ha);
512 set_bit(LOOP_RESYNC_NEEDED, &ha->dpc_flags);
513 set_bit(LOCAL_LOOP_UPDATE, &ha->dpc_flags);
516 case MBA_PORT_UPDATE: /* Port database update */
518 * If a single remote port just logged into (or logged out of)
519 * us, create a new entry in our rscn fcports list and handle
520 * the event like an RSCN.
522 if (!IS_QLA2100(ha) && !IS_QLA2200(ha) && !IS_QLA6312(ha) &&
523 !IS_QLA6322(ha) && !IS_QLA24XX(ha) && !IS_QLA25XX(ha) &&
524 ha->flags.init_done && mb[1] != 0xffff &&
525 ((ha->operating_mode == P2P && mb[1] != 0) ||
526 (ha->operating_mode != P2P && mb[1] !=
527 SNS_FIRST_LOOP_ID)) && (mb[2] == 6 || mb[2] == 7)) {
529 fc_port_t *rscn_fcport;
531 /* Create new fcport for login. */
532 rscn_fcport = qla2x00_alloc_rscn_fcport(ha, GFP_ATOMIC);
534 DEBUG14(printk("scsi(%ld): Port Update -- "
535 "creating RSCN fcport %p for %x/%x/%x.\n",
536 ha->host_no, rscn_fcport, mb[1], mb[2],
539 rscn_fcport->loop_id = mb[1];
540 rscn_fcport->d_id.b24 = INVALID_PORT_ID;
541 atomic_set(&rscn_fcport->state,
543 list_add_tail(&rscn_fcport->list,
546 rval = qla2x00_handle_port_rscn(ha, 0,
548 if (rval == QLA_SUCCESS)
551 DEBUG14(printk("scsi(%ld): Port Update -- "
552 "-- unable to allocate RSCN fcport "
553 "login.\n", ha->host_no));
558 * If PORT UPDATE is global (recieved LIP_OCCURED/LIP_RESET
559 * event etc. earlier indicating loop is down) then process
560 * it. Otherwise ignore it and Wait for RSCN to come in.
562 atomic_set(&ha->loop_down_timer, 0);
563 if (atomic_read(&ha->loop_state) != LOOP_DOWN &&
564 atomic_read(&ha->loop_state) != LOOP_DEAD) {
565 DEBUG2(printk("scsi(%ld): Asynchronous PORT UPDATE "
566 "ignored %04x/%04x/%04x.\n", ha->host_no, mb[1],
571 DEBUG2(printk("scsi(%ld): Asynchronous PORT UPDATE.\n",
573 DEBUG(printk(KERN_INFO
574 "scsi(%ld): Port database changed %04x %04x %04x.\n",
575 ha->host_no, mb[1], mb[2], mb[3]));
578 * Mark all devices as missing so we will login again.
580 atomic_set(&ha->loop_state, LOOP_UP);
582 qla2x00_mark_all_devices_lost(ha);
584 ha->flags.rscn_queue_overflow = 1;
586 set_bit(LOOP_RESYNC_NEEDED, &ha->dpc_flags);
587 set_bit(LOCAL_LOOP_UPDATE, &ha->dpc_flags);
589 /* Update AEN queue. */
590 qla2x00_enqueue_aen(ha, MBA_PORT_UPDATE, NULL);
593 case MBA_RSCN_UPDATE: /* State Change Registration */
594 DEBUG2(printk("scsi(%ld): Asynchronous RSCR UPDATE.\n",
596 DEBUG(printk(KERN_INFO
597 "scsi(%ld): RSCN database changed -- %04x %04x.\n",
598 ha->host_no, mb[1], mb[2]));
600 rscn_entry = (mb[1] << 16) | mb[2];
601 host_pid = (ha->d_id.b.domain << 16) | (ha->d_id.b.area << 8) |
603 if (rscn_entry == host_pid) {
604 DEBUG(printk(KERN_INFO
605 "scsi(%ld): Ignoring RSCN update to local host "
607 ha->host_no, host_pid));
611 rscn_queue_index = ha->rscn_in_ptr + 1;
612 if (rscn_queue_index == MAX_RSCN_COUNT)
613 rscn_queue_index = 0;
614 if (rscn_queue_index != ha->rscn_out_ptr) {
615 ha->rscn_queue[ha->rscn_in_ptr] = rscn_entry;
616 ha->rscn_in_ptr = rscn_queue_index;
618 ha->flags.rscn_queue_overflow = 1;
621 atomic_set(&ha->loop_state, LOOP_UPDATE);
622 atomic_set(&ha->loop_down_timer, 0);
623 ha->flags.management_server_logged_in = 0;
625 set_bit(LOOP_RESYNC_NEEDED, &ha->dpc_flags);
626 set_bit(RSCN_UPDATE, &ha->dpc_flags);
628 /* Update AEN queue. */
629 qla2x00_enqueue_aen(ha, MBA_RSCN_UPDATE, &mb[0]);
632 /* case MBA_RIO_RESPONSE: */
633 case MBA_ZIO_RESPONSE:
634 DEBUG2(printk("scsi(%ld): [R|Z]IO update completion.\n",
636 DEBUG(printk(KERN_INFO
637 "scsi(%ld): [R|Z]IO update completion.\n",
640 if (IS_QLA24XX(ha) || IS_QLA25XX(ha))
641 qla24xx_process_response_queue(ha);
643 qla2x00_process_response_queue(ha);
646 case MBA_DISCARD_RND_FRAME:
647 DEBUG2(printk("scsi(%ld): Discard RND Frame -- %04x %04x "
648 "%04x.\n", ha->host_no, mb[1], mb[2], mb[3]));
654 * qla2x00_process_completed_request() - Process a Fast Post response.
655 * @ha: SCSI driver HA context
659 qla2x00_process_completed_request(struct scsi_qla_host *ha, uint32_t index)
663 /* Validate handle. */
664 if (index >= MAX_OUTSTANDING_COMMANDS) {
665 DEBUG2(printk("scsi(%ld): Invalid SCSI completion handle %d.\n",
666 ha->host_no, index));
667 qla_printk(KERN_WARNING, ha,
668 "Invalid SCSI completion handle %d.\n", index);
670 set_bit(ISP_ABORT_NEEDED, &ha->dpc_flags);
674 sp = ha->outstanding_cmds[index];
676 /* Free outstanding command slot. */
677 ha->outstanding_cmds[index] = NULL;
679 CMD_COMPL_STATUS(sp->cmd) = 0L;
680 CMD_SCSI_STATUS(sp->cmd) = 0L;
682 /* Save ISP completion status */
683 sp->cmd->result = DID_OK << 16;
684 qla2x00_sp_compl(ha, sp);
686 DEBUG2(printk("scsi(%ld): Invalid ISP SCSI completion handle\n",
688 qla_printk(KERN_WARNING, ha,
689 "Invalid ISP SCSI completion handle\n");
691 set_bit(ISP_ABORT_NEEDED, &ha->dpc_flags);
696 * qla2x00_process_response_queue() - Process response queue entries.
697 * @ha: SCSI driver HA context
700 qla2x00_process_response_queue(struct scsi_qla_host *ha)
702 struct device_reg_2xxx __iomem *reg = &ha->iobase->isp;
707 if (!ha->flags.online)
710 while (ha->response_ring_ptr->signature != RESPONSE_PROCESSED) {
711 pkt = (sts_entry_t *)ha->response_ring_ptr;
713 ha->rsp_ring_index++;
714 if (ha->rsp_ring_index == ha->response_q_length) {
715 ha->rsp_ring_index = 0;
716 ha->response_ring_ptr = ha->response_ring;
718 ha->response_ring_ptr++;
721 if (pkt->entry_status != 0) {
722 DEBUG3(printk(KERN_INFO
723 "scsi(%ld): Process error entry.\n", ha->host_no));
725 qla2x00_error_entry(ha, pkt);
726 ((response_t *)pkt)->signature = RESPONSE_PROCESSED;
731 switch (pkt->entry_type) {
733 qla2x00_status_entry(ha, pkt);
736 handle_cnt = ((sts21_entry_t *)pkt)->handle_count;
737 for (cnt = 0; cnt < handle_cnt; cnt++) {
738 qla2x00_process_completed_request(ha,
739 ((sts21_entry_t *)pkt)->handle[cnt]);
743 handle_cnt = ((sts22_entry_t *)pkt)->handle_count;
744 for (cnt = 0; cnt < handle_cnt; cnt++) {
745 qla2x00_process_completed_request(ha,
746 ((sts22_entry_t *)pkt)->handle[cnt]);
749 case STATUS_CONT_TYPE:
750 qla2x00_status_cont_entry(ha, (sts_cont_entry_t *)pkt);
753 qla2x00_ms_entry(ha, (ms_iocb_entry_t *)pkt);
756 if (!IS_QLA2100(ha) && !IS_QLA2200(ha) &&
757 !IS_QLA6312(ha) && !IS_QLA6322(ha)) {
758 if (pkt->sys_define == SOURCE_ASYNC_IOCB) {
759 qla2x00_process_iodesc(ha,
760 (struct mbx_entry *)pkt);
762 /* MBX IOCB Type Not Supported. */
763 DEBUG4(printk(KERN_WARNING
764 "scsi(%ld): Received unknown MBX "
765 "IOCB response pkt type=%x "
766 "source=%x entry status=%x.\n",
767 ha->host_no, pkt->entry_type,
775 /* Type Not Supported. */
776 DEBUG4(printk(KERN_WARNING
777 "scsi(%ld): Received unknown response pkt type %x "
778 "entry status=%x.\n",
779 ha->host_no, pkt->entry_type, pkt->entry_status));
782 ((response_t *)pkt)->signature = RESPONSE_PROCESSED;
786 /* Adjust ring index */
787 WRT_REG_WORD(ISP_RSP_Q_OUT(ha, reg), ha->rsp_ring_index);
791 * qla2x00_status_entry() - Process a Status IOCB entry.
792 * @ha: SCSI driver HA context
793 * @pkt: Entry pointer
796 qla2x00_status_entry(scsi_qla_host_t *ha, void *pkt)
800 struct scsi_cmnd *cp;
802 struct sts_entry_24xx *sts24;
803 uint16_t comp_status;
804 uint16_t scsi_status;
805 uint8_t lscsi_status;
807 uint32_t sense_len, rsp_info_len, resid_len;
808 uint8_t *rsp_info, *sense_data;
810 sts = (sts_entry_t *) pkt;
811 sts24 = (struct sts_entry_24xx *) pkt;
812 if (IS_QLA24XX(ha) || IS_QLA25XX(ha)) {
813 comp_status = le16_to_cpu(sts24->comp_status);
814 scsi_status = le16_to_cpu(sts24->scsi_status) & SS_MASK;
816 comp_status = le16_to_cpu(sts->comp_status);
817 scsi_status = le16_to_cpu(sts->scsi_status) & SS_MASK;
820 /* Fast path completion. */
821 if (comp_status == CS_COMPLETE && scsi_status == 0) {
822 qla2x00_process_completed_request(ha, sts->handle);
827 /* Validate handle. */
828 if (sts->handle < MAX_OUTSTANDING_COMMANDS) {
829 sp = ha->outstanding_cmds[sts->handle];
830 ha->outstanding_cmds[sts->handle] = NULL;
835 DEBUG2(printk("scsi(%ld): Status Entry invalid handle.\n",
837 qla_printk(KERN_WARNING, ha, "Status Entry invalid handle.\n");
839 set_bit(ISP_ABORT_NEEDED, &ha->dpc_flags);
840 if (ha->dpc_wait && !ha->dpc_active)
847 DEBUG2(printk("scsi(%ld): Command already returned back to OS "
848 "pkt->handle=%d sp=%p sp->state:%d\n",
849 ha->host_no, sts->handle, sp, sp->state));
850 qla_printk(KERN_WARNING, ha,
851 "Command is NULL: already returned to OS (sp=%p)\n", sp);
856 lscsi_status = scsi_status & STATUS_MASK;
857 CMD_ENTRY_STATUS(cp) = sts->entry_status;
858 CMD_COMPL_STATUS(cp) = comp_status;
859 CMD_SCSI_STATUS(cp) = scsi_status;
863 sense_len = rsp_info_len = resid_len = 0;
864 if (IS_QLA24XX(ha) || IS_QLA25XX(ha)) {
865 sense_len = le32_to_cpu(sts24->sense_len);
866 rsp_info_len = le32_to_cpu(sts24->rsp_data_len);
867 resid_len = le32_to_cpu(sts24->rsp_residual_count);
868 rsp_info = sts24->data;
869 sense_data = sts24->data;
870 host_to_fcp_swap(sts24->data, sizeof(sts24->data));
872 sense_len = le16_to_cpu(sts->req_sense_length);
873 rsp_info_len = le16_to_cpu(sts->rsp_info_len);
874 resid_len = le32_to_cpu(sts->residual_length);
875 rsp_info = sts->rsp_info;
876 sense_data = sts->req_sense_data;
879 /* Check for any FCP transport errors. */
880 if (scsi_status & SS_RESPONSE_INFO_LEN_VALID) {
881 /* Sense data lies beyond any FCP RESPONSE data. */
882 if (IS_QLA24XX(ha) || IS_QLA25XX(ha))
883 sense_data += rsp_info_len;
884 if (rsp_info_len > 3 && rsp_info[3]) {
885 DEBUG2(printk("scsi(%ld:%d:%d:%d) FCP I/O protocol "
886 "failure (%x/%02x%02x%02x%02x%02x%02x%02x%02x)..."
887 "retrying command\n", ha->host_no,
888 cp->device->channel, cp->device->id,
889 cp->device->lun, rsp_info_len, rsp_info[0],
890 rsp_info[1], rsp_info[2], rsp_info[3], rsp_info[4],
891 rsp_info[5], rsp_info[6], rsp_info[7]));
893 cp->result = DID_BUS_BUSY << 16;
894 qla2x00_sp_compl(ha, sp);
900 * Based on Host and scsi status generate status code for Linux
902 switch (comp_status) {
904 if (scsi_status == 0) {
905 cp->result = DID_OK << 16;
908 if (scsi_status & (SS_RESIDUAL_UNDER | SS_RESIDUAL_OVER)) {
911 CMD_RESID_LEN(cp) = resid;
913 cp->result = DID_OK << 16 | lscsi_status;
915 if (lscsi_status != SS_CHECK_CONDITION)
918 /* Copy Sense Data into sense buffer. */
919 memset(cp->sense_buffer, 0, sizeof(cp->sense_buffer));
921 if (!(scsi_status & SS_SENSE_LEN_VALID))
924 if (sense_len >= sizeof(cp->sense_buffer))
925 sense_len = sizeof(cp->sense_buffer);
927 CMD_ACTUAL_SNSLEN(cp) = sense_len;
928 sp->request_sense_length = sense_len;
929 sp->request_sense_ptr = cp->sense_buffer;
931 if (sp->request_sense_length > 32)
934 memcpy(cp->sense_buffer, sense_data, sense_len);
936 sp->request_sense_ptr += sense_len;
937 sp->request_sense_length -= sense_len;
938 if (sp->request_sense_length != 0)
941 DEBUG5(printk("%s(): Check condition Sense data, "
942 "scsi(%ld:%d:%d:%d) cmd=%p pid=%ld\n", __func__,
943 ha->host_no, cp->device->channel, cp->device->id,
944 cp->device->lun, cp, cp->serial_number));
946 DEBUG5(qla2x00_dump_buffer(cp->sense_buffer,
947 CMD_ACTUAL_SNSLEN(cp)));
950 case CS_DATA_UNDERRUN:
951 DEBUG2(printk(KERN_INFO
952 "scsi(%ld:%d:%d) UNDERRUN status detected 0x%x-0x%x.\n",
953 ha->host_no, cp->device->id, cp->device->lun, comp_status,
957 if (scsi_status & SS_RESIDUAL_UNDER) {
959 CMD_RESID_LEN(cp) = resid;
963 * Check to see if SCSI Status is non zero. If so report SCSI
966 if (lscsi_status != 0) {
967 cp->result = DID_OK << 16 | lscsi_status;
969 if (lscsi_status != SS_CHECK_CONDITION)
972 /* Copy Sense Data into sense buffer */
973 memset(cp->sense_buffer, 0, sizeof(cp->sense_buffer));
975 if (!(scsi_status & SS_SENSE_LEN_VALID))
978 if (sense_len >= sizeof(cp->sense_buffer))
979 sense_len = sizeof(cp->sense_buffer);
981 CMD_ACTUAL_SNSLEN(cp) = sense_len;
982 sp->request_sense_length = sense_len;
983 sp->request_sense_ptr = cp->sense_buffer;
985 if (sp->request_sense_length > 32)
988 memcpy(cp->sense_buffer, sense_data, sense_len);
990 sp->request_sense_ptr += sense_len;
991 sp->request_sense_length -= sense_len;
992 if (sp->request_sense_length != 0)
995 DEBUG5(printk("%s(): Check condition Sense data, "
996 "scsi(%ld:%d:%d:%d) cmd=%p pid=%ld\n",
997 __func__, ha->host_no, cp->device->channel,
998 cp->device->id, cp->device->lun, cp,
1002 DEBUG5(qla2x00_dump_buffer(cp->sense_buffer,
1003 CMD_ACTUAL_SNSLEN(cp)));
1006 * If RISC reports underrun and target does not report
1007 * it then we must have a lost frame, so tell upper
1008 * layer to retry it by reporting a bus busy.
1010 if (!(scsi_status & SS_RESIDUAL_UNDER)) {
1011 DEBUG2(printk("scsi(%ld:%d:%d:%d) Dropped "
1012 "frame(s) detected (%x of %x bytes)..."
1013 "retrying command.\n", ha->host_no,
1014 cp->device->channel, cp->device->id,
1015 cp->device->lun, resid,
1016 cp->request_bufflen));
1018 cp->result = DID_BUS_BUSY << 16;
1022 /* Handle mid-layer underflow */
1023 if ((unsigned)(cp->request_bufflen - resid) <
1025 qla_printk(KERN_INFO, ha,
1026 "scsi(%ld:%d:%d:%d): Mid-layer underflow "
1027 "detected (%x of %x bytes)...returning "
1028 "error status.\n", ha->host_no,
1029 cp->device->channel, cp->device->id,
1030 cp->device->lun, resid,
1031 cp->request_bufflen);
1033 cp->result = DID_ERROR << 16;
1037 /* Everybody online, looking good... */
1038 cp->result = DID_OK << 16;
1042 case CS_DATA_OVERRUN:
1043 DEBUG2(printk(KERN_INFO
1044 "scsi(%ld:%d:%d): OVERRUN status detected 0x%x-0x%x\n",
1045 ha->host_no, cp->device->id, cp->device->lun, comp_status,
1047 DEBUG2(printk(KERN_INFO
1048 "CDB: 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x\n",
1049 cp->cmnd[0], cp->cmnd[1], cp->cmnd[2], cp->cmnd[3],
1050 cp->cmnd[4], cp->cmnd[5]));
1051 DEBUG2(printk(KERN_INFO
1052 "PID=0x%lx req=0x%x xtra=0x%x -- returning DID_ERROR "
1054 cp->serial_number, cp->request_bufflen, resid_len));
1056 cp->result = DID_ERROR << 16;
1059 case CS_PORT_LOGGED_OUT:
1060 case CS_PORT_CONFIG_CHG:
1063 case CS_PORT_UNAVAILABLE:
1065 * If the port is in Target Down state, return all IOs for this
1066 * Target with DID_NO_CONNECT ELSE Queue the IOs in the
1069 DEBUG2(printk("scsi(%ld:%d:%d): status_entry: Port Down "
1070 "pid=%ld, compl status=0x%x, port state=0x%x\n",
1071 ha->host_no, cp->device->id, cp->device->lun,
1072 cp->serial_number, comp_status,
1073 atomic_read(&fcport->state)));
1075 cp->result = DID_BUS_BUSY << 16;
1076 if (atomic_read(&fcport->state) == FCS_ONLINE) {
1077 qla2x00_mark_device_lost(ha, fcport, 1);
1082 DEBUG2(printk(KERN_INFO
1083 "scsi(%ld): RESET status detected 0x%x-0x%x.\n",
1084 ha->host_no, comp_status, scsi_status));
1086 cp->result = DID_RESET << 16;
1091 * hv2.19.12 - DID_ABORT does not retry the request if we
1092 * aborted this request then abort otherwise it must be a
1095 DEBUG2(printk(KERN_INFO
1096 "scsi(%ld): ABORT status detected 0x%x-0x%x.\n",
1097 ha->host_no, comp_status, scsi_status));
1099 cp->result = DID_RESET << 16;
1103 cp->result = DID_BUS_BUSY << 16;
1105 if (IS_QLA24XX(ha) || IS_QLA25XX(ha)) {
1106 DEBUG2(printk(KERN_INFO
1107 "scsi(%ld:%d:%d:%d): TIMEOUT status detected "
1108 "0x%x-0x%x\n", ha->host_no, cp->device->channel,
1109 cp->device->id, cp->device->lun, comp_status,
1113 DEBUG2(printk(KERN_INFO
1114 "scsi(%ld:%d:%d:%d): TIMEOUT status detected 0x%x-0x%x "
1115 "sflags=%x.\n", ha->host_no, cp->device->channel,
1116 cp->device->id, cp->device->lun, comp_status, scsi_status,
1117 le16_to_cpu(sts->status_flags)));
1119 /* Check to see if logout occurred. */
1120 if ((le16_to_cpu(sts->status_flags) & SF_LOGOUT_SENT))
1121 qla2x00_mark_device_lost(ha, fcport, 1);
1125 DEBUG2(printk(KERN_INFO
1126 "scsi(%ld): QUEUE FULL status detected 0x%x-0x%x.\n",
1127 ha->host_no, comp_status, scsi_status));
1129 /* SCSI Mid-Layer handles device queue full */
1131 cp->result = DID_OK << 16 | lscsi_status;
1136 DEBUG3(printk("scsi(%ld): Error detected (unknown status) "
1137 "0x%x-0x%x.\n", ha->host_no, comp_status, scsi_status));
1138 qla_printk(KERN_INFO, ha,
1139 "Unknown status detected 0x%x-0x%x.\n",
1140 comp_status, scsi_status);
1142 cp->result = DID_ERROR << 16;
1146 /* Place command on done queue. */
1147 if (ha->status_srb == NULL)
1148 qla2x00_sp_compl(ha, sp);
1152 * qla2x00_status_cont_entry() - Process a Status Continuations entry.
1153 * @ha: SCSI driver HA context
1154 * @pkt: Entry pointer
1156 * Extended sense data.
1159 qla2x00_status_cont_entry(scsi_qla_host_t *ha, sts_cont_entry_t *pkt)
1161 uint8_t sense_sz = 0;
1162 srb_t *sp = ha->status_srb;
1163 struct scsi_cmnd *cp;
1165 if (sp != NULL && sp->request_sense_length != 0) {
1168 DEBUG2(printk("%s(): Cmd already returned back to OS "
1169 "sp=%p sp->state:%d\n", __func__, sp, sp->state));
1170 qla_printk(KERN_INFO, ha,
1171 "cmd is NULL: already returned to OS (sp=%p)\n",
1174 ha->status_srb = NULL;
1178 if (sp->request_sense_length > sizeof(pkt->data)) {
1179 sense_sz = sizeof(pkt->data);
1181 sense_sz = sp->request_sense_length;
1184 /* Move sense data. */
1185 if (IS_QLA24XX(ha) || IS_QLA25XX(ha))
1186 host_to_fcp_swap(pkt->data, sizeof(pkt->data));
1187 memcpy(sp->request_sense_ptr, pkt->data, sense_sz);
1188 DEBUG5(qla2x00_dump_buffer(sp->request_sense_ptr, sense_sz));
1190 sp->request_sense_ptr += sense_sz;
1191 sp->request_sense_length -= sense_sz;
1193 /* Place command on done queue. */
1194 if (sp->request_sense_length == 0) {
1195 ha->status_srb = NULL;
1196 qla2x00_sp_compl(ha, sp);
1202 * qla2x00_error_entry() - Process an error entry.
1203 * @ha: SCSI driver HA context
1204 * @pkt: Entry pointer
1207 qla2x00_error_entry(scsi_qla_host_t *ha, sts_entry_t *pkt)
1211 #if defined(QL_DEBUG_LEVEL_2)
1212 if (pkt->entry_status & RF_INV_E_ORDER)
1213 qla_printk(KERN_ERR, ha, "%s: Invalid Entry Order\n", __func__);
1214 else if (pkt->entry_status & RF_INV_E_COUNT)
1215 qla_printk(KERN_ERR, ha, "%s: Invalid Entry Count\n", __func__);
1216 else if (pkt->entry_status & RF_INV_E_PARAM)
1217 qla_printk(KERN_ERR, ha,
1218 "%s: Invalid Entry Parameter\n", __func__);
1219 else if (pkt->entry_status & RF_INV_E_TYPE)
1220 qla_printk(KERN_ERR, ha, "%s: Invalid Entry Type\n", __func__);
1221 else if (pkt->entry_status & RF_BUSY)
1222 qla_printk(KERN_ERR, ha, "%s: Busy\n", __func__);
1224 qla_printk(KERN_ERR, ha, "%s: UNKNOWN flag error\n", __func__);
1227 /* Validate handle. */
1228 if (pkt->handle < MAX_OUTSTANDING_COMMANDS)
1229 sp = ha->outstanding_cmds[pkt->handle];
1234 /* Free outstanding command slot. */
1235 ha->outstanding_cmds[pkt->handle] = NULL;
1237 /* Bad payload or header */
1238 if (pkt->entry_status &
1239 (RF_INV_E_ORDER | RF_INV_E_COUNT |
1240 RF_INV_E_PARAM | RF_INV_E_TYPE)) {
1241 sp->cmd->result = DID_ERROR << 16;
1242 } else if (pkt->entry_status & RF_BUSY) {
1243 sp->cmd->result = DID_BUS_BUSY << 16;
1245 sp->cmd->result = DID_ERROR << 16;
1247 qla2x00_sp_compl(ha, sp);
1249 } else if (pkt->entry_type == COMMAND_A64_TYPE || pkt->entry_type ==
1250 COMMAND_TYPE || pkt->entry_type == COMMAND_TYPE_7) {
1251 DEBUG2(printk("scsi(%ld): Error entry - invalid handle\n",
1253 qla_printk(KERN_WARNING, ha,
1254 "Error entry - invalid handle\n");
1256 set_bit(ISP_ABORT_NEEDED, &ha->dpc_flags);
1257 if (ha->dpc_wait && !ha->dpc_active)
1263 * qla2x00_ms_entry() - Process a Management Server entry.
1264 * @ha: SCSI driver HA context
1265 * @index: Response queue out pointer
1268 qla2x00_ms_entry(scsi_qla_host_t *ha, ms_iocb_entry_t *pkt)
1272 DEBUG3(printk("%s(%ld): pkt=%p pkthandle=%d.\n",
1273 __func__, ha->host_no, pkt, pkt->handle1));
1275 /* Validate handle. */
1276 if (pkt->handle1 < MAX_OUTSTANDING_COMMANDS)
1277 sp = ha->outstanding_cmds[pkt->handle1];
1282 DEBUG2(printk("scsi(%ld): MS entry - invalid handle\n",
1284 qla_printk(KERN_WARNING, ha, "MS entry - invalid handle\n");
1286 set_bit(ISP_ABORT_NEEDED, &ha->dpc_flags);
1290 CMD_COMPL_STATUS(sp->cmd) = le16_to_cpu(pkt->status);
1291 CMD_ENTRY_STATUS(sp->cmd) = pkt->entry_status;
1293 /* Free outstanding command slot. */
1294 ha->outstanding_cmds[pkt->handle1] = NULL;
1296 qla2x00_sp_compl(ha, sp);
1301 * qla24xx_mbx_completion() - Process mailbox command completions.
1302 * @ha: SCSI driver HA context
1303 * @mb0: Mailbox0 register
1306 qla24xx_mbx_completion(scsi_qla_host_t *ha, uint16_t mb0)
1309 uint16_t __iomem *wptr;
1310 struct device_reg_24xx __iomem *reg = &ha->iobase->isp24;
1312 /* Load return mailbox registers. */
1313 ha->flags.mbox_int = 1;
1314 ha->mailbox_out[0] = mb0;
1315 wptr = (uint16_t __iomem *)®->mailbox1;
1317 for (cnt = 1; cnt < ha->mbx_count; cnt++) {
1318 ha->mailbox_out[cnt] = RD_REG_WORD(wptr);
1323 DEBUG3(printk("%s(%ld): Got mailbox completion. cmd=%x.\n",
1324 __func__, ha->host_no, ha->mcp->mb[0]));
1326 DEBUG2_3(printk("%s(%ld): MBX pointer ERROR!\n",
1327 __func__, ha->host_no));
1332 * qla24xx_process_response_queue() - Process response queue entries.
1333 * @ha: SCSI driver HA context
1336 qla24xx_process_response_queue(struct scsi_qla_host *ha)
1338 struct device_reg_24xx __iomem *reg = &ha->iobase->isp24;
1339 struct sts_entry_24xx *pkt;
1341 if (!ha->flags.online)
1344 while (ha->response_ring_ptr->signature != RESPONSE_PROCESSED) {
1345 pkt = (struct sts_entry_24xx *)ha->response_ring_ptr;
1347 ha->rsp_ring_index++;
1348 if (ha->rsp_ring_index == ha->response_q_length) {
1349 ha->rsp_ring_index = 0;
1350 ha->response_ring_ptr = ha->response_ring;
1352 ha->response_ring_ptr++;
1355 if (pkt->entry_status != 0) {
1356 DEBUG3(printk(KERN_INFO
1357 "scsi(%ld): Process error entry.\n", ha->host_no));
1359 qla2x00_error_entry(ha, (sts_entry_t *) pkt);
1360 ((response_t *)pkt)->signature = RESPONSE_PROCESSED;
1365 switch (pkt->entry_type) {
1367 qla2x00_status_entry(ha, pkt);
1369 case STATUS_CONT_TYPE:
1370 qla2x00_status_cont_entry(ha, (sts_cont_entry_t *)pkt);
1373 qla24xx_ms_entry(ha, (struct ct_entry_24xx *)pkt);
1376 /* Type Not Supported. */
1377 DEBUG4(printk(KERN_WARNING
1378 "scsi(%ld): Received unknown response pkt type %x "
1379 "entry status=%x.\n",
1380 ha->host_no, pkt->entry_type, pkt->entry_status));
1383 ((response_t *)pkt)->signature = RESPONSE_PROCESSED;
1387 /* Adjust ring index */
1388 WRT_REG_DWORD(®->rsp_q_out, ha->rsp_ring_index);
1392 * qla24xx_intr_handler() - Process interrupts for the ISP23xx and ISP63xx.
1394 * @dev_id: SCSI driver HA context
1397 * Called by system whenever the host adapter generates an interrupt.
1399 * Returns handled flag.
1402 qla24xx_intr_handler(int irq, void *dev_id, struct pt_regs *regs)
1404 scsi_qla_host_t *ha;
1405 struct device_reg_24xx __iomem *reg;
1407 unsigned long flags;
1413 ha = (scsi_qla_host_t *) dev_id;
1416 "%s(): NULL host pointer\n", __func__);
1420 reg = &ha->iobase->isp24;
1423 spin_lock_irqsave(&ha->hardware_lock, flags);
1424 for (iter = 50; iter--; ) {
1425 stat = RD_REG_DWORD(®->host_status);
1426 if (stat & HSRX_RISC_PAUSED) {
1427 hccr = RD_REG_DWORD(®->hccr);
1429 qla_printk(KERN_INFO, ha, "RISC paused -- HCCR=%x, "
1430 "Dumping firmware!\n", hccr);
1431 qla24xx_fw_dump(ha, 1);
1433 set_bit(ISP_ABORT_NEEDED, &ha->dpc_flags);
1435 } else if ((stat & HSRX_RISC_INT) == 0)
1438 switch (stat & 0xff) {
1443 qla24xx_mbx_completion(ha, MSW(stat));
1444 status |= MBX_INTERRUPT;
1449 mb[1] = RD_REG_WORD(®->mailbox1);
1450 mb[2] = RD_REG_WORD(®->mailbox2);
1451 mb[3] = RD_REG_WORD(®->mailbox3);
1452 qla2x00_async_event(ha, mb);
1455 qla24xx_process_response_queue(ha);
1458 DEBUG2(printk("scsi(%ld): Unrecognized interrupt type "
1460 ha->host_no, stat & 0xff));
1463 WRT_REG_DWORD(®->hccr, HCCRX_CLR_RISC_INT);
1464 RD_REG_DWORD_RELAXED(®->hccr);
1466 spin_unlock_irqrestore(&ha->hardware_lock, flags);
1468 if (test_bit(MBX_INTR_WAIT, &ha->mbx_cmd_flags) &&
1469 (status & MBX_INTERRUPT) && ha->flags.mbox_int) {
1470 spin_lock_irqsave(&ha->mbx_reg_lock, flags);
1472 set_bit(MBX_INTERRUPT, &ha->mbx_cmd_flags);
1473 up(&ha->mbx_intr_sem);
1475 spin_unlock_irqrestore(&ha->mbx_reg_lock, flags);
1482 * qla24xx_ms_entry() - Process a Management Server entry.
1483 * @ha: SCSI driver HA context
1484 * @index: Response queue out pointer
1487 qla24xx_ms_entry(scsi_qla_host_t *ha, struct ct_entry_24xx *pkt)
1491 DEBUG3(printk("%s(%ld): pkt=%p pkthandle=%d.\n",
1492 __func__, ha->host_no, pkt, pkt->handle));
1494 DEBUG9(printk("%s: ct pkt dump:\n", __func__);)
1495 DEBUG9(qla2x00_dump_buffer((void *)pkt, sizeof(struct ct_entry_24xx));)
1497 /* Validate handle. */
1498 if (pkt->handle < MAX_OUTSTANDING_COMMANDS)
1499 sp = ha->outstanding_cmds[pkt->handle];
1504 DEBUG2(printk("scsi(%ld): MS entry - invalid handle\n",
1506 DEBUG10(printk("scsi(%ld): MS entry - invalid handle\n",
1508 qla_printk(KERN_WARNING, ha, "MS entry - invalid handle %d\n",
1511 set_bit(ISP_ABORT_NEEDED, &ha->dpc_flags);
1515 CMD_COMPL_STATUS(sp->cmd) = le16_to_cpu(pkt->comp_status);
1516 CMD_ENTRY_STATUS(sp->cmd) = pkt->entry_status;
1518 /* Free outstanding command slot. */
1519 ha->outstanding_cmds[pkt->handle] = NULL;
1521 qla2x00_sp_compl(ha, sp);