2 * QLOGIC LINUX SOFTWARE
4 * QLogic ISP2x00 device driver for Linux 2.6.x
5 * Copyright (C) 2003-2004 QLogic Corporation
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by the
10 * Free Software Foundation; either version 2, or (at your option) any
13 * This program is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * General Public License for more details.
21 static void qla2x00_mbx_completion(scsi_qla_host_t
*, uint16_t);
22 static void qla2x00_async_event(scsi_qla_host_t
*, uint32_t);
23 static void qla2x00_process_completed_request(struct scsi_qla_host
*, uint32_t);
24 void qla2x00_process_response_queue(struct scsi_qla_host
*);
25 static void qla2x00_status_entry(scsi_qla_host_t
*, sts_entry_t
*);
26 static void qla2x00_status_cont_entry(scsi_qla_host_t
*, sts_cont_entry_t
*);
27 static void qla2x00_error_entry(scsi_qla_host_t
*, sts_entry_t
*);
28 static void qla2x00_ms_entry(scsi_qla_host_t
*, ms_iocb_entry_t
*);
30 static int qla2x00_check_sense(struct scsi_cmnd
*cp
, os_lun_t
*);
33 * qla2100_intr_handler() - Process interrupts for the ISP2100 and ISP2200.
35 * @dev_id: SCSI driver HA context
38 * Called by system whenever the host adapter generates an interrupt.
40 * Returns handled flag.
43 qla2100_intr_handler(int irq
, void *dev_id
, struct pt_regs
*regs
)
46 device_reg_t __iomem
*reg
;
52 ha
= (scsi_qla_host_t
*) dev_id
;
55 "%s(): NULL host pointer\n", __func__
);
62 spin_lock_irqsave(&ha
->hardware_lock
, flags
);
63 for (iter
= 50; iter
--; ) {
64 if ((RD_REG_WORD(®
->istatus
) & ISR_RISC_INT
) == 0)
67 if (RD_REG_WORD(®
->semaphore
) & BIT_0
) {
68 WRT_REG_WORD(®
->hccr
, HCCR_CLR_RISC_INT
);
69 RD_REG_WORD(®
->hccr
);
71 /* Get mailbox data. */
72 mbx
= RD_MAILBOX_REG(ha
, reg
, 0);
73 if (mbx
> 0x3fff && mbx
< 0x8000) {
74 qla2x00_mbx_completion(ha
, (uint16_t)mbx
);
75 status
|= MBX_INTERRUPT
;
76 } else if (mbx
> 0x7fff && mbx
< 0xc000) {
77 qla2x00_async_event(ha
, mbx
);
80 DEBUG2(printk("scsi(%ld): Unrecognized "
81 "interrupt type (%d)\n",
84 /* Release mailbox registers. */
85 WRT_REG_WORD(®
->semaphore
, 0);
86 RD_REG_WORD(®
->semaphore
);
88 qla2x00_process_response_queue(ha
);
90 WRT_REG_WORD(®
->hccr
, HCCR_CLR_RISC_INT
);
91 RD_REG_WORD(®
->hccr
);
94 spin_unlock_irqrestore(&ha
->hardware_lock
, flags
);
97 ha
->last_irq_cpu
= _smp_processor_id();
100 if (test_bit(MBX_INTR_WAIT
, &ha
->mbx_cmd_flags
) &&
101 (status
& MBX_INTERRUPT
) && ha
->flags
.mbox_int
) {
102 spin_lock_irqsave(&ha
->mbx_reg_lock
, flags
);
104 set_bit(MBX_INTERRUPT
, &ha
->mbx_cmd_flags
);
105 up(&ha
->mbx_intr_sem
);
107 spin_unlock_irqrestore(&ha
->mbx_reg_lock
, flags
);
110 if (!list_empty(&ha
->done_queue
))
113 return (IRQ_HANDLED
);
117 * qla2300_intr_handler() - Process interrupts for the ISP23xx and ISP63xx.
119 * @dev_id: SCSI driver HA context
122 * Called by system whenever the host adapter generates an interrupt.
124 * Returns handled flag.
127 qla2300_intr_handler(int irq
, void *dev_id
, struct pt_regs
*regs
)
130 device_reg_t __iomem
*reg
;
138 ha
= (scsi_qla_host_t
*) dev_id
;
141 "%s(): NULL host pointer\n", __func__
);
148 spin_lock_irqsave(&ha
->hardware_lock
, flags
);
149 for (iter
= 50; iter
--; ) {
150 stat
= RD_REG_DWORD(®
->u
.isp2300
.host_status
);
151 if (stat
& HSR_RISC_PAUSED
) {
152 hccr
= RD_REG_WORD(®
->hccr
);
153 if (hccr
& (BIT_15
| BIT_13
| BIT_11
| BIT_8
))
154 qla_printk(KERN_INFO
, ha
,
155 "Parity error -- HCCR=%x.\n", hccr
);
157 qla_printk(KERN_INFO
, ha
,
158 "RISC paused -- HCCR=%x\n", hccr
);
161 * Issue a "HARD" reset in order for the RISC
162 * interrupt bit to be cleared. Schedule a big
163 * hammmer to get out of the RISC PAUSED state.
165 WRT_REG_WORD(®
->hccr
, HCCR_RESET_RISC
);
166 RD_REG_WORD(®
->hccr
);
167 set_bit(ISP_ABORT_NEEDED
, &ha
->dpc_flags
);
169 } else if ((stat
& HSR_RISC_INT
) == 0)
173 switch (stat
& 0xff) {
175 qla2x00_process_response_queue(ha
);
181 qla2x00_mbx_completion(ha
, (uint16_t)mbx
);
182 status
|= MBX_INTERRUPT
;
184 /* Release mailbox registers. */
185 WRT_REG_WORD(®
->semaphore
, 0);
188 qla2x00_async_event(ha
, mbx
);
191 mbx
= mbx
<< 16 | MBA_CMPLT_1_16BIT
;
192 qla2x00_async_event(ha
, mbx
);
195 mbx
= mbx
<< 16 | MBA_SCSI_COMPLETION
;
196 qla2x00_async_event(ha
, mbx
);
199 DEBUG2(printk("scsi(%ld): Unrecognized interrupt type "
201 ha
->host_no
, stat
& 0xff));
204 WRT_REG_WORD(®
->hccr
, HCCR_CLR_RISC_INT
);
205 RD_REG_WORD_RELAXED(®
->hccr
);
207 spin_unlock_irqrestore(&ha
->hardware_lock
, flags
);
210 ha
->last_irq_cpu
= _smp_processor_id();
213 if (test_bit(MBX_INTR_WAIT
, &ha
->mbx_cmd_flags
) &&
214 (status
& MBX_INTERRUPT
) && ha
->flags
.mbox_int
) {
215 spin_lock_irqsave(&ha
->mbx_reg_lock
, flags
);
217 set_bit(MBX_INTERRUPT
, &ha
->mbx_cmd_flags
);
218 up(&ha
->mbx_intr_sem
);
220 spin_unlock_irqrestore(&ha
->mbx_reg_lock
, flags
);
223 if (!list_empty(&ha
->done_queue
))
226 return (IRQ_HANDLED
);
230 * qla2x00_mbx_completion() - Process mailbox command completions.
231 * @ha: SCSI driver HA context
232 * @mb0: Mailbox0 register
235 qla2x00_mbx_completion(scsi_qla_host_t
*ha
, uint16_t mb0
)
238 uint16_t __iomem
*wptr
;
239 device_reg_t __iomem
*reg
= ha
->iobase
;
241 /* Load return mailbox registers. */
242 ha
->flags
.mbox_int
= 1;
243 ha
->mailbox_out
[0] = mb0
;
244 wptr
= (uint16_t __iomem
*)MAILBOX_REG(ha
, reg
, 1);
246 for (cnt
= 1; cnt
< ha
->mbx_count
; cnt
++) {
247 if (IS_QLA2200(ha
) && cnt
== 8)
248 wptr
= (uint16_t __iomem
*)MAILBOX_REG(ha
, reg
, 8);
249 if (cnt
== 4 || cnt
== 5)
250 ha
->mailbox_out
[cnt
] = qla2x00_debounce_register(wptr
);
252 ha
->mailbox_out
[cnt
] = RD_REG_WORD(wptr
);
258 DEBUG3(printk("%s(%ld): Got mailbox completion. cmd=%x.\n",
259 __func__
, ha
->host_no
, ha
->mcp
->mb
[0]));
261 DEBUG2_3(printk("%s(%ld): MBX pointer ERROR!\n",
262 __func__
, ha
->host_no
));
267 * qla2x00_async_event() - Process aynchronous events.
268 * @ha: SCSI driver HA context
269 * @mb0: Mailbox0 register
272 qla2x00_async_event(scsi_qla_host_t
*ha
, uint32_t mbx
)
274 static char *link_speeds
[5] = { "1", "2", "4", "?", "10" };
280 device_reg_t __iomem
*reg
= ha
->iobase
;
281 uint32_t rscn_entry
, host_pid
;
282 uint8_t rscn_queue_index
;
284 /* Setup to process RIO completion. */
288 case MBA_SCSI_COMPLETION
:
289 if (IS_QLA2100(ha
) || IS_QLA2200(ha
))
290 handles
[0] = le32_to_cpu(
291 ((uint32_t)(RD_MAILBOX_REG(ha
, reg
, 2) << 16)) |
292 RD_MAILBOX_REG(ha
, reg
, 1));
294 handles
[0] = le32_to_cpu(
295 ((uint32_t)(RD_MAILBOX_REG(ha
, reg
, 2) << 16)) |
299 case MBA_CMPLT_1_16BIT
:
300 if (IS_QLA2100(ha
) || IS_QLA2200(ha
))
301 handles
[0] = (uint32_t)RD_MAILBOX_REG(ha
, reg
, 1);
303 handles
[0] = MSW(mbx
);
305 mb
[0] = MBA_SCSI_COMPLETION
;
307 case MBA_CMPLT_2_16BIT
:
308 handles
[0] = (uint32_t)RD_MAILBOX_REG(ha
, reg
, 1);
309 handles
[1] = (uint32_t)RD_MAILBOX_REG(ha
, reg
, 2);
311 mb
[0] = MBA_SCSI_COMPLETION
;
313 case MBA_CMPLT_3_16BIT
:
314 handles
[0] = (uint32_t)RD_MAILBOX_REG(ha
, reg
, 1);
315 handles
[1] = (uint32_t)RD_MAILBOX_REG(ha
, reg
, 2);
316 handles
[2] = (uint32_t)RD_MAILBOX_REG(ha
, reg
, 3);
318 mb
[0] = MBA_SCSI_COMPLETION
;
320 case MBA_CMPLT_4_16BIT
:
321 handles
[0] = (uint32_t)RD_MAILBOX_REG(ha
, reg
, 1);
322 handles
[1] = (uint32_t)RD_MAILBOX_REG(ha
, reg
, 2);
323 handles
[2] = (uint32_t)RD_MAILBOX_REG(ha
, reg
, 3);
324 handles
[3] = (uint32_t)RD_MAILBOX_REG(ha
, reg
, 6);
326 mb
[0] = MBA_SCSI_COMPLETION
;
328 case MBA_CMPLT_5_16BIT
:
329 handles
[0] = (uint32_t)RD_MAILBOX_REG(ha
, reg
, 1);
330 handles
[1] = (uint32_t)RD_MAILBOX_REG(ha
, reg
, 2);
331 handles
[2] = (uint32_t)RD_MAILBOX_REG(ha
, reg
, 3);
332 handles
[3] = (uint32_t)RD_MAILBOX_REG(ha
, reg
, 6);
333 handles
[4] = (uint32_t)RD_MAILBOX_REG(ha
, reg
, 7);
335 mb
[0] = MBA_SCSI_COMPLETION
;
337 case MBA_CMPLT_2_32BIT
:
338 handles
[0] = le32_to_cpu(
339 ((uint32_t)(RD_MAILBOX_REG(ha
, reg
, 2) << 16)) |
340 RD_MAILBOX_REG(ha
, reg
, 1));
341 handles
[1] = le32_to_cpu(
342 ((uint32_t)(RD_MAILBOX_REG(ha
, reg
, 7) << 16)) |
343 RD_MAILBOX_REG(ha
, reg
, 6));
345 mb
[0] = MBA_SCSI_COMPLETION
;
352 case MBA_SCSI_COMPLETION
: /* Fast Post */
353 if (!ha
->flags
.online
)
356 for (cnt
= 0; cnt
< handle_cnt
; cnt
++)
357 qla2x00_process_completed_request(ha
, handles
[cnt
]);
360 case MBA_RESET
: /* Reset */
361 DEBUG2(printk("scsi(%ld): Asynchronous RESET.\n", ha
->host_no
));
363 set_bit(RESET_MARKER_NEEDED
, &ha
->dpc_flags
);
366 case MBA_SYSTEM_ERR
: /* System Error */
367 mb
[1] = RD_MAILBOX_REG(ha
, reg
, 1);
368 mb
[2] = RD_MAILBOX_REG(ha
, reg
, 2);
369 mb
[3] = RD_MAILBOX_REG(ha
, reg
, 3);
371 qla_printk(KERN_INFO
, ha
,
372 "ISP System Error - mbx1=%xh mbx2=%xh mbx3=%xh.\n",
373 mb
[1], mb
[2], mb
[3]);
375 if (IS_QLA2100(ha
) || IS_QLA2200(ha
))
376 qla2100_fw_dump(ha
, 1);
378 qla2300_fw_dump(ha
, 1);
381 qla_printk(KERN_INFO
, ha
,
382 "Unrecoverable Hardware Error: adapter marked "
384 ha
->flags
.online
= 0;
386 set_bit(ISP_ABORT_NEEDED
, &ha
->dpc_flags
);
389 case MBA_REQ_TRANSFER_ERR
: /* Request Transfer Error */
390 DEBUG2(printk("scsi(%ld): ISP Request Transfer Error.\n",
392 qla_printk(KERN_WARNING
, ha
, "ISP Request Transfer Error.\n");
394 set_bit(ISP_ABORT_NEEDED
, &ha
->dpc_flags
);
397 case MBA_RSP_TRANSFER_ERR
: /* Response Transfer Error */
398 DEBUG2(printk("scsi(%ld): ISP Response Transfer Error.\n",
400 qla_printk(KERN_WARNING
, ha
, "ISP Response Transfer Error.\n");
402 set_bit(ISP_ABORT_NEEDED
, &ha
->dpc_flags
);
405 case MBA_WAKEUP_THRES
: /* Request Queue Wake-up */
406 DEBUG2(printk("scsi(%ld): Asynchronous WAKEUP_THRES.\n",
410 case MBA_LIP_OCCURRED
: /* Loop Initialization Procedure */
411 mb
[1] = RD_MAILBOX_REG(ha
, reg
, 1);
413 DEBUG2(printk("scsi(%ld): LIP occured (%x).\n", ha
->host_no
,
415 qla_printk(KERN_INFO
, ha
, "LIP occured (%x).\n", mb
[1]);
417 if (atomic_read(&ha
->loop_state
) != LOOP_DOWN
) {
418 atomic_set(&ha
->loop_state
, LOOP_DOWN
);
419 atomic_set(&ha
->loop_down_timer
, LOOP_DOWN_TIME
);
420 qla2x00_mark_all_devices_lost(ha
);
423 set_bit(REGISTER_FC4_NEEDED
, &ha
->dpc_flags
);
425 ha
->flags
.management_server_logged_in
= 0;
427 /* Update AEN queue. */
428 qla2x00_enqueue_aen(ha
, MBA_LIP_OCCURRED
, NULL
);
433 case MBA_LOOP_UP
: /* Loop Up Event */
434 mb
[1] = RD_MAILBOX_REG(ha
, reg
, 1);
436 ha
->link_data_rate
= 0;
437 if (IS_QLA2100(ha
) || IS_QLA2200(ha
)) {
438 link_speed
= link_speeds
[0];
440 link_speed
= link_speeds
[3];
442 link_speed
= link_speeds
[mb
[1]];
443 ha
->link_data_rate
= mb
[1];
446 DEBUG2(printk("scsi(%ld): Asynchronous LOOP UP (%s Gbps).\n",
447 ha
->host_no
, link_speed
));
448 qla_printk(KERN_INFO
, ha
, "LOOP UP detected (%s Gbps).\n",
451 ha
->flags
.management_server_logged_in
= 0;
453 /* Update AEN queue. */
454 qla2x00_enqueue_aen(ha
, MBA_LOOP_UP
, NULL
);
457 case MBA_LOOP_DOWN
: /* Loop Down Event */
458 DEBUG2(printk("scsi(%ld): Asynchronous LOOP DOWN.\n",
460 qla_printk(KERN_INFO
, ha
, "LOOP DOWN detected.\n");
462 if (atomic_read(&ha
->loop_state
) != LOOP_DOWN
) {
463 atomic_set(&ha
->loop_state
, LOOP_DOWN
);
464 atomic_set(&ha
->loop_down_timer
, LOOP_DOWN_TIME
);
465 ha
->device_flags
|= DFLG_NO_CABLE
;
466 qla2x00_mark_all_devices_lost(ha
);
469 ha
->flags
.management_server_logged_in
= 0;
470 ha
->link_data_rate
= 0;
472 /* Update AEN queue. */
473 qla2x00_enqueue_aen(ha
, MBA_LOOP_DOWN
, NULL
);
476 case MBA_LIP_RESET
: /* LIP reset occurred */
477 mb
[1] = RD_MAILBOX_REG(ha
, reg
, 1);
479 DEBUG2(printk("scsi(%ld): Asynchronous LIP RESET (%x).\n",
480 ha
->host_no
, mb
[1]));
481 qla_printk(KERN_INFO
, ha
,
482 "LIP reset occured (%x).\n", mb
[1]);
484 if (atomic_read(&ha
->loop_state
) != LOOP_DOWN
) {
485 atomic_set(&ha
->loop_state
, LOOP_DOWN
);
486 atomic_set(&ha
->loop_down_timer
, LOOP_DOWN_TIME
);
487 qla2x00_mark_all_devices_lost(ha
);
490 set_bit(RESET_MARKER_NEEDED
, &ha
->dpc_flags
);
492 ha
->operating_mode
= LOOP
;
493 ha
->flags
.management_server_logged_in
= 0;
495 /* Update AEN queue. */
496 qla2x00_enqueue_aen(ha
, MBA_LIP_RESET
, NULL
);
501 case MBA_POINT_TO_POINT
: /* Point-to-Point */
505 DEBUG2(printk("scsi(%ld): Asynchronous P2P MODE received.\n",
509 * Until there's a transition from loop down to loop up, treat
510 * this as loop down only.
512 if (atomic_read(&ha
->loop_state
) != LOOP_DOWN
) {
513 atomic_set(&ha
->loop_state
, LOOP_DOWN
);
514 if (!atomic_read(&ha
->loop_down_timer
))
515 atomic_set(&ha
->loop_down_timer
,
517 qla2x00_mark_all_devices_lost(ha
);
520 if (!(test_bit(ABORT_ISP_ACTIVE
, &ha
->dpc_flags
))) {
521 set_bit(RESET_MARKER_NEEDED
, &ha
->dpc_flags
);
523 set_bit(REGISTER_FC4_NEEDED
, &ha
->dpc_flags
);
526 case MBA_CHG_IN_CONNECTION
: /* Change in connection mode */
530 mb
[1] = RD_MAILBOX_REG(ha
, reg
, 1);
532 DEBUG2(printk("scsi(%ld): Asynchronous Change In Connection "
535 qla_printk(KERN_INFO
, ha
,
536 "Configuration change detected: value=%x.\n", mb
[1]);
538 if (atomic_read(&ha
->loop_state
) != LOOP_DOWN
) {
539 atomic_set(&ha
->loop_state
, LOOP_DOWN
);
540 if (!atomic_read(&ha
->loop_down_timer
))
541 atomic_set(&ha
->loop_down_timer
,
543 qla2x00_mark_all_devices_lost(ha
);
546 set_bit(LOOP_RESYNC_NEEDED
, &ha
->dpc_flags
);
547 set_bit(LOCAL_LOOP_UPDATE
, &ha
->dpc_flags
);
550 case MBA_PORT_UPDATE
: /* Port database update */
551 mb
[1] = RD_MAILBOX_REG(ha
, reg
, 1);
552 mb
[2] = RD_MAILBOX_REG(ha
, reg
, 2);
555 * If a single remote port just logged into (or logged out of)
556 * us, create a new entry in our rscn fcports list and handle
557 * the event like an RSCN.
559 if (!IS_QLA2100(ha
) && !IS_QLA2200(ha
) && !IS_QLA6312(ha
) &&
560 !IS_QLA6322(ha
) && ha
->flags
.init_done
&& mb
[1] != 0xffff &&
561 ((ha
->operating_mode
== P2P
&& mb
[1] != 0) ||
562 (ha
->operating_mode
!= P2P
&& mb
[1] !=
563 SNS_FIRST_LOOP_ID
)) && (mb
[2] == 6 || mb
[2] == 7)) {
565 fc_port_t
*rscn_fcport
;
567 /* Create new fcport for login. */
568 rscn_fcport
= qla2x00_alloc_rscn_fcport(ha
, GFP_ATOMIC
);
570 DEBUG14(printk("scsi(%ld): Port Update -- "
571 "creating RSCN fcport %p for %x/%x.\n",
572 ha
->host_no
, rscn_fcport
, mb
[1], mb
[2]));
574 rscn_fcport
->loop_id
= mb
[1];
575 rscn_fcport
->d_id
.b24
= INVALID_PORT_ID
;
576 atomic_set(&rscn_fcport
->state
,
578 list_add_tail(&rscn_fcport
->list
,
581 rval
= qla2x00_handle_port_rscn(ha
, 0,
583 if (rval
== QLA_SUCCESS
)
586 DEBUG14(printk("scsi(%ld): Port Update -- "
587 "-- unable to allocate RSCN fcport "
588 "login.\n", ha
->host_no
));
593 * If PORT UPDATE is global (recieved LIP_OCCURED/LIP_RESET
594 * event etc. earlier indicating loop is down) then process
595 * it. Otherwise ignore it and Wait for RSCN to come in.
597 atomic_set(&ha
->loop_down_timer
, 0);
598 if (atomic_read(&ha
->loop_state
) != LOOP_DOWN
&&
599 atomic_read(&ha
->loop_state
) != LOOP_DEAD
) {
600 DEBUG2(printk("scsi(%ld): Asynchronous PORT UPDATE "
601 "ignored.\n", ha
->host_no
));
605 DEBUG2(printk("scsi(%ld): Asynchronous PORT UPDATE.\n",
607 DEBUG(printk(KERN_INFO
608 "scsi(%ld): Port database changed %04x %04x.\n",
609 ha
->host_no
, mb
[1], mb
[2]));
612 * Mark all devices as missing so we will login again.
614 atomic_set(&ha
->loop_state
, LOOP_UP
);
616 qla2x00_mark_all_devices_lost(ha
);
618 ha
->flags
.rscn_queue_overflow
= 1;
620 set_bit(LOOP_RESYNC_NEEDED
, &ha
->dpc_flags
);
621 set_bit(LOCAL_LOOP_UPDATE
, &ha
->dpc_flags
);
623 /* Update AEN queue. */
624 qla2x00_enqueue_aen(ha
, MBA_PORT_UPDATE
, NULL
);
627 case MBA_RSCN_UPDATE
: /* State Change Registration */
628 mb
[1] = RD_MAILBOX_REG(ha
, reg
, 1);
629 mb
[2] = RD_MAILBOX_REG(ha
, reg
, 2);
631 DEBUG2(printk("scsi(%ld): Asynchronous RSCR UPDATE.\n",
633 DEBUG(printk(KERN_INFO
634 "scsi(%ld): RSCN database changed -- %04x %04x.\n",
635 ha
->host_no
, mb
[1], mb
[2]));
637 rscn_entry
= (mb
[1] << 16) | mb
[2];
638 host_pid
= (ha
->d_id
.b
.domain
<< 16) | (ha
->d_id
.b
.area
<< 8) |
640 if (rscn_entry
== host_pid
) {
641 DEBUG(printk(KERN_INFO
642 "scsi(%ld): Ignoring RSCN update to local host "
644 ha
->host_no
, host_pid
));
648 rscn_queue_index
= ha
->rscn_in_ptr
+ 1;
649 if (rscn_queue_index
== MAX_RSCN_COUNT
)
650 rscn_queue_index
= 0;
651 if (rscn_queue_index
!= ha
->rscn_out_ptr
) {
652 ha
->rscn_queue
[ha
->rscn_in_ptr
] = rscn_entry
;
653 ha
->rscn_in_ptr
= rscn_queue_index
;
655 ha
->flags
.rscn_queue_overflow
= 1;
658 atomic_set(&ha
->loop_state
, LOOP_UPDATE
);
659 atomic_set(&ha
->loop_down_timer
, 0);
660 ha
->flags
.management_server_logged_in
= 0;
662 set_bit(LOOP_RESYNC_NEEDED
, &ha
->dpc_flags
);
663 set_bit(RSCN_UPDATE
, &ha
->dpc_flags
);
665 /* Update AEN queue. */
666 qla2x00_enqueue_aen(ha
, MBA_RSCN_UPDATE
, &mb
[0]);
669 /* case MBA_RIO_RESPONSE: */
670 case MBA_ZIO_RESPONSE
:
671 DEBUG2(printk("scsi(%ld): [R|Z]IO update completion.\n",
673 DEBUG(printk(KERN_INFO
674 "scsi(%ld): [R|Z]IO update completion.\n",
677 qla2x00_process_response_queue(ha
);
683 * qla2x00_process_completed_request() - Process a Fast Post response.
684 * @ha: SCSI driver HA context
688 qla2x00_process_completed_request(struct scsi_qla_host
*ha
, uint32_t index
)
692 /* Validate handle. */
693 if (index
>= MAX_OUTSTANDING_COMMANDS
) {
694 DEBUG2(printk("scsi(%ld): Invalid SCSI completion handle %d.\n",
695 ha
->host_no
, index
));
696 qla_printk(KERN_WARNING
, ha
,
697 "Invalid SCSI completion handle %d.\n", index
);
699 set_bit(ISP_ABORT_NEEDED
, &ha
->dpc_flags
);
703 sp
= ha
->outstanding_cmds
[index
];
705 /* Free outstanding command slot. */
706 ha
->outstanding_cmds
[index
] = NULL
;
710 sp
->lun_queue
->out_cnt
--;
711 CMD_COMPL_STATUS(sp
->cmd
) = 0L;
712 CMD_SCSI_STATUS(sp
->cmd
) = 0L;
714 /* Save ISP completion status */
715 sp
->cmd
->result
= DID_OK
<< 16;
716 sp
->fo_retry_cnt
= 0;
717 add_to_done_queue(ha
, sp
);
719 DEBUG2(printk("scsi(%ld): Invalid ISP SCSI completion handle\n",
721 qla_printk(KERN_WARNING
, ha
,
722 "Invalid ISP SCSI completion handle\n");
724 set_bit(ISP_ABORT_NEEDED
, &ha
->dpc_flags
);
729 * qla2x00_process_response_queue() - Process response queue entries.
730 * @ha: SCSI driver HA context
733 qla2x00_process_response_queue(struct scsi_qla_host
*ha
)
735 device_reg_t __iomem
*reg
= ha
->iobase
;
740 if (!ha
->flags
.online
)
743 while (ha
->response_ring_ptr
->signature
!= RESPONSE_PROCESSED
) {
744 pkt
= (sts_entry_t
*)ha
->response_ring_ptr
;
746 ha
->rsp_ring_index
++;
747 if (ha
->rsp_ring_index
== ha
->response_q_length
) {
748 ha
->rsp_ring_index
= 0;
749 ha
->response_ring_ptr
= ha
->response_ring
;
751 ha
->response_ring_ptr
++;
754 if (pkt
->entry_status
!= 0) {
755 DEBUG3(printk(KERN_INFO
756 "scsi(%ld): Process error entry.\n", ha
->host_no
));
758 qla2x00_error_entry(ha
, pkt
);
759 ((response_t
*)pkt
)->signature
= RESPONSE_PROCESSED
;
764 switch (pkt
->entry_type
) {
766 qla2x00_status_entry(ha
, pkt
);
769 handle_cnt
= ((sts21_entry_t
*)pkt
)->handle_count
;
770 for (cnt
= 0; cnt
< handle_cnt
; cnt
++) {
771 qla2x00_process_completed_request(ha
,
772 ((sts21_entry_t
*)pkt
)->handle
[cnt
]);
776 handle_cnt
= ((sts22_entry_t
*)pkt
)->handle_count
;
777 for (cnt
= 0; cnt
< handle_cnt
; cnt
++) {
778 qla2x00_process_completed_request(ha
,
779 ((sts22_entry_t
*)pkt
)->handle
[cnt
]);
782 case STATUS_CONT_TYPE
:
783 qla2x00_status_cont_entry(ha
, (sts_cont_entry_t
*)pkt
);
786 qla2x00_ms_entry(ha
, (ms_iocb_entry_t
*)pkt
);
789 if (!IS_QLA2100(ha
) && !IS_QLA2200(ha
) &&
790 !IS_QLA6312(ha
) && !IS_QLA6322(ha
)) {
791 if (pkt
->sys_define
== SOURCE_ASYNC_IOCB
) {
792 qla2x00_process_iodesc(ha
,
793 (struct mbx_entry
*)pkt
);
795 /* MBX IOCB Type Not Supported. */
796 DEBUG4(printk(KERN_WARNING
797 "scsi(%ld): Received unknown MBX "
798 "IOCB response pkt type=%x "
799 "source=%x entry status=%x.\n",
800 ha
->host_no
, pkt
->entry_type
,
808 /* Type Not Supported. */
809 DEBUG4(printk(KERN_WARNING
810 "scsi(%ld): Received unknown response pkt type %x "
811 "entry status=%x.\n",
812 ha
->host_no
, pkt
->entry_type
, pkt
->entry_status
));
815 ((response_t
*)pkt
)->signature
= RESPONSE_PROCESSED
;
819 /* Adjust ring index */
820 WRT_REG_WORD(ISP_RSP_Q_OUT(ha
, reg
), ha
->rsp_ring_index
);
824 * qla2x00_status_entry() - Process a Status IOCB entry.
825 * @ha: SCSI driver HA context
826 * @pkt: Entry pointer
829 qla2x00_status_entry(scsi_qla_host_t
*ha
, sts_entry_t
*pkt
)
837 struct scsi_cmnd
*cp
;
838 uint16_t comp_status
;
839 uint16_t scsi_status
;
840 uint8_t lscsi_status
;
842 uint8_t sense_sz
= 0;
843 uint16_t rsp_info_len
;
845 /* Fast path completion. */
846 if (le16_to_cpu(pkt
->comp_status
) == CS_COMPLETE
&&
847 (le16_to_cpu(pkt
->scsi_status
) & SS_MASK
) == 0) {
848 qla2x00_process_completed_request(ha
, pkt
->handle
);
853 /* Validate handle. */
854 if (pkt
->handle
< MAX_OUTSTANDING_COMMANDS
) {
855 sp
= ha
->outstanding_cmds
[pkt
->handle
];
856 ha
->outstanding_cmds
[pkt
->handle
] = NULL
;
861 DEBUG2(printk("scsi(%ld): Status Entry invalid handle.\n",
863 qla_printk(KERN_WARNING
, ha
, "Status Entry invalid handle.\n");
865 set_bit(ISP_ABORT_NEEDED
, &ha
->dpc_flags
);
866 if (ha
->dpc_wait
&& !ha
->dpc_active
)
873 DEBUG2(printk("scsi(%ld): Command already returned back to OS "
874 "pkt->handle=%d sp=%p sp->state:%d\n",
875 ha
->host_no
, pkt
->handle
, sp
, sp
->state
));
876 qla_printk(KERN_WARNING
, ha
,
877 "Command is NULL: already returned to OS (sp=%p)\n", sp
);
885 if (sp
->lun_queue
== NULL
) {
886 DEBUG2(printk("scsi(%ld): Status Entry invalid lun pointer.\n",
888 qla_printk(KERN_WARNING
, ha
,
889 "Status Entry invalid lun pointer.\n");
891 set_bit(ISP_ABORT_NEEDED
, &ha
->dpc_flags
);
892 if (ha
->dpc_wait
&& !ha
->dpc_active
)
898 sp
->lun_queue
->out_cnt
--;
900 comp_status
= le16_to_cpu(pkt
->comp_status
);
901 /* Mask of reserved bits 12-15, before we examine the scsi status */
902 scsi_status
= le16_to_cpu(pkt
->scsi_status
) & SS_MASK
;
903 lscsi_status
= scsi_status
& STATUS_MASK
;
905 CMD_ENTRY_STATUS(cp
) = pkt
->entry_status
;
906 CMD_COMPL_STATUS(cp
) = comp_status
;
907 CMD_SCSI_STATUS(cp
) = scsi_status
;
909 /* Generate LU queue on cntrl, target, LUN */
910 b
= cp
->device
->channel
;
918 * If loop is in transient state Report DID_BUS_BUSY
920 if ((comp_status
!= CS_COMPLETE
|| scsi_status
!= 0)) {
921 if (!(sp
->flags
& (SRB_IOCTL
| SRB_TAPE
)) &&
922 (atomic_read(&ha
->loop_down_timer
) ||
923 atomic_read(&ha
->loop_state
) != LOOP_READY
)) {
925 DEBUG2(printk("scsi(%ld:%d:%d:%d): Loop Not Ready - "
927 ha
->host_no
, b
, t
, l
, cp
->serial_number
));
929 qla2x00_extend_timeout(cp
, EXTEND_CMD_TIMEOUT
);
930 add_to_retry_queue(ha
, sp
);
935 /* Check for any FCP transport errors. */
936 if (scsi_status
& SS_RESPONSE_INFO_LEN_VALID
) {
937 rsp_info_len
= le16_to_cpu(pkt
->rsp_info_len
);
938 if (rsp_info_len
> 3 && pkt
->rsp_info
[3]) {
939 DEBUG2(printk("scsi(%ld:%d:%d:%d) FCP I/O protocol "
940 "failure (%x/%02x%02x%02x%02x%02x%02x%02x%02x)..."
941 "retrying command\n", ha
->host_no
, b
, t
, l
,
942 rsp_info_len
, pkt
->rsp_info
[0], pkt
->rsp_info
[1],
943 pkt
->rsp_info
[2], pkt
->rsp_info
[3],
944 pkt
->rsp_info
[4], pkt
->rsp_info
[5],
945 pkt
->rsp_info
[6], pkt
->rsp_info
[7]));
947 cp
->result
= DID_BUS_BUSY
<< 16;
948 add_to_done_queue(ha
, sp
);
954 * Based on Host and scsi status generate status code for Linux
956 switch (comp_status
) {
958 if (scsi_status
== 0) {
959 cp
->result
= DID_OK
<< 16;
962 if (scsi_status
& (SS_RESIDUAL_UNDER
| SS_RESIDUAL_OVER
)) {
963 resid
= le32_to_cpu(pkt
->residual_length
);
965 CMD_RESID_LEN(cp
) = resid
;
967 if (lscsi_status
== SS_BUSY_CONDITION
) {
968 cp
->result
= DID_BUS_BUSY
<< 16 | lscsi_status
;
972 cp
->result
= DID_OK
<< 16 | lscsi_status
;
974 if (lscsi_status
!= SS_CHECK_CONDITION
)
978 * Copy Sense Data into sense buffer
980 memset(cp
->sense_buffer
, 0, sizeof(cp
->sense_buffer
));
982 if (!(scsi_status
& SS_SENSE_LEN_VALID
))
985 if (le16_to_cpu(pkt
->req_sense_length
) <
986 sizeof(cp
->sense_buffer
))
987 sense_sz
= le16_to_cpu(pkt
->req_sense_length
);
989 sense_sz
= sizeof(cp
->sense_buffer
);
991 CMD_ACTUAL_SNSLEN(cp
) = sense_sz
;
992 sp
->request_sense_length
= sense_sz
;
993 sp
->request_sense_ptr
= cp
->sense_buffer
;
995 if (sp
->request_sense_length
> 32)
998 memcpy(cp
->sense_buffer
, pkt
->req_sense_data
, sense_sz
);
1000 sp
->request_sense_ptr
+= sense_sz
;
1001 sp
->request_sense_length
-= sense_sz
;
1002 if (sp
->request_sense_length
!= 0)
1003 ha
->status_srb
= sp
;
1005 if (!(sp
->flags
& (SRB_IOCTL
| SRB_TAPE
)) &&
1006 qla2x00_check_sense(cp
, lq
) == QLA_SUCCESS
) {
1007 /* Throw away status_cont if any */
1008 ha
->status_srb
= NULL
;
1009 add_to_scsi_retry_queue(ha
, sp
);
1013 DEBUG5(printk("%s(): Check condition Sense data, "
1014 "scsi(%ld:%d:%d:%d) cmd=%p pid=%ld\n",
1015 __func__
, ha
->host_no
, b
, t
, l
, cp
,
1016 cp
->serial_number
));
1018 DEBUG5(qla2x00_dump_buffer(cp
->sense_buffer
,
1019 CMD_ACTUAL_SNSLEN(cp
)));
1022 case CS_DATA_UNDERRUN
:
1023 DEBUG2(printk(KERN_INFO
1024 "scsi(%ld:%d:%d) UNDERRUN status detected 0x%x-0x%x.\n",
1025 ha
->host_no
, t
, l
, comp_status
, scsi_status
));
1027 resid
= le32_to_cpu(pkt
->residual_length
);
1028 if (scsi_status
& SS_RESIDUAL_UNDER
) {
1030 CMD_RESID_LEN(cp
) = resid
;
1034 * Check to see if SCSI Status is non zero. If so report SCSI
1037 if (lscsi_status
!= 0) {
1038 if (lscsi_status
== SS_BUSY_CONDITION
) {
1039 cp
->result
= DID_BUS_BUSY
<< 16 |
1044 cp
->result
= DID_OK
<< 16 | lscsi_status
;
1046 if (lscsi_status
!= SS_CHECK_CONDITION
)
1049 /* Copy Sense Data into sense buffer */
1050 memset(cp
->sense_buffer
, 0, sizeof(cp
->sense_buffer
));
1052 if (!(scsi_status
& SS_SENSE_LEN_VALID
))
1055 if (le16_to_cpu(pkt
->req_sense_length
) <
1056 sizeof(cp
->sense_buffer
))
1057 sense_sz
= le16_to_cpu(pkt
->req_sense_length
);
1059 sense_sz
= sizeof(cp
->sense_buffer
);
1061 CMD_ACTUAL_SNSLEN(cp
) = sense_sz
;
1062 sp
->request_sense_length
= sense_sz
;
1063 sp
->request_sense_ptr
= cp
->sense_buffer
;
1065 if (sp
->request_sense_length
> 32)
1068 memcpy(cp
->sense_buffer
, pkt
->req_sense_data
, sense_sz
);
1070 sp
->request_sense_ptr
+= sense_sz
;
1071 sp
->request_sense_length
-= sense_sz
;
1072 if (sp
->request_sense_length
!= 0)
1073 ha
->status_srb
= sp
;
1075 if (!(sp
->flags
& (SRB_IOCTL
| SRB_TAPE
)) &&
1076 (qla2x00_check_sense(cp
, lq
) == QLA_SUCCESS
)) {
1077 ha
->status_srb
= NULL
;
1078 add_to_scsi_retry_queue(ha
, sp
);
1081 DEBUG5(printk("%s(): Check condition Sense data, "
1082 "scsi(%ld:%d:%d:%d) cmd=%p pid=%ld\n",
1083 __func__
, ha
->host_no
, b
, t
, l
, cp
,
1084 cp
->serial_number
));
1086 DEBUG5(qla2x00_dump_buffer(cp
->sense_buffer
,
1087 CMD_ACTUAL_SNSLEN(cp
)));
1090 * If RISC reports underrun and target does not report
1091 * it then we must have a lost frame, so tell upper
1092 * layer to retry it by reporting a bus busy.
1094 if (!(scsi_status
& SS_RESIDUAL_UNDER
)) {
1095 DEBUG2(printk("scsi(%ld:%d:%d:%d) Dropped "
1096 "frame(s) detected (%x of %x bytes)..."
1097 "retrying command.\n",
1098 ha
->host_no
, b
, t
, l
, resid
,
1099 cp
->request_bufflen
));
1101 cp
->result
= DID_BUS_BUSY
<< 16;
1102 ha
->dropped_frame_error_cnt
++;
1106 /* Handle mid-layer underflow */
1107 if ((unsigned)(cp
->request_bufflen
- resid
) <
1109 qla_printk(KERN_INFO
, ha
,
1110 "scsi(%ld:%d:%d:%d): Mid-layer underflow "
1111 "detected (%x of %x bytes)...returning "
1113 ha
->host_no
, b
, t
, l
, resid
,
1114 cp
->request_bufflen
);
1116 cp
->result
= DID_ERROR
<< 16;
1120 /* Everybody online, looking good... */
1121 cp
->result
= DID_OK
<< 16;
1125 case CS_DATA_OVERRUN
:
1126 DEBUG2(printk(KERN_INFO
1127 "scsi(%ld:%d:%d): OVERRUN status detected 0x%x-0x%x\n",
1128 ha
->host_no
, t
, l
, comp_status
, scsi_status
));
1129 DEBUG2(printk(KERN_INFO
1130 "CDB: 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x\n",
1131 cp
->cmnd
[0], cp
->cmnd
[1], cp
->cmnd
[2], cp
->cmnd
[3],
1132 cp
->cmnd
[4], cp
->cmnd
[5]));
1133 DEBUG2(printk(KERN_INFO
1134 "PID=0x%lx req=0x%x xtra=0x%x -- returning DID_ERROR "
1136 cp
->serial_number
, cp
->request_bufflen
,
1137 le32_to_cpu(pkt
->residual_length
)));
1139 cp
->result
= DID_ERROR
<< 16;
1142 case CS_PORT_LOGGED_OUT
:
1143 case CS_PORT_CONFIG_CHG
:
1146 case CS_PORT_UNAVAILABLE
:
1148 * If the port is in Target Down state, return all IOs for this
1149 * Target with DID_NO_CONNECT ELSE Queue the IOs in the
1152 fcport
= sp
->fclun
->fcport
;
1153 DEBUG2(printk("scsi(%ld:%d:%d): status_entry: Port Down "
1154 "pid=%ld, compl status=0x%x, port state=0x%x\n",
1155 ha
->host_no
, t
, l
, cp
->serial_number
, comp_status
,
1156 atomic_read(&fcport
->state
)));
1158 if ((sp
->flags
& (SRB_IOCTL
| SRB_TAPE
)) ||
1159 atomic_read(&fcport
->state
) == FCS_DEVICE_DEAD
) {
1160 cp
->result
= DID_NO_CONNECT
<< 16;
1161 if (atomic_read(&ha
->loop_state
) == LOOP_DOWN
)
1162 sp
->err_id
= SRB_ERR_LOOP
;
1164 sp
->err_id
= SRB_ERR_PORT
;
1165 add_to_done_queue(ha
, sp
);
1167 qla2x00_extend_timeout(cp
, EXTEND_CMD_TIMEOUT
);
1168 add_to_retry_queue(ha
, sp
);
1171 if (atomic_read(&fcport
->state
) == FCS_ONLINE
) {
1172 qla2x00_mark_device_lost(ha
, fcport
, 1);
1179 DEBUG2(printk(KERN_INFO
1180 "scsi(%ld): RESET status detected 0x%x-0x%x.\n",
1181 ha
->host_no
, comp_status
, scsi_status
));
1183 if (sp
->flags
& (SRB_IOCTL
| SRB_TAPE
)) {
1184 cp
->result
= DID_RESET
<< 16;
1186 qla2x00_extend_timeout(cp
, EXTEND_CMD_TIMEOUT
);
1187 add_to_retry_queue(ha
, sp
);
1194 * hv2.19.12 - DID_ABORT does not retry the request if we
1195 * aborted this request then abort otherwise it must be a
1198 DEBUG2(printk(KERN_INFO
1199 "scsi(%ld): ABORT status detected 0x%x-0x%x.\n",
1200 ha
->host_no
, comp_status
, scsi_status
));
1202 cp
->result
= DID_RESET
<< 16;
1206 DEBUG2(printk(KERN_INFO
1207 "scsi(%ld:%d:%d:%d): TIMEOUT status detected 0x%x-0x%x "
1208 "sflags=%x.\n", ha
->host_no
, b
, t
, l
, comp_status
,
1209 scsi_status
, le16_to_cpu(pkt
->status_flags
)));
1211 cp
->result
= DID_BUS_BUSY
<< 16;
1213 fcport
= lq
->fclun
->fcport
;
1215 /* Check to see if logout occurred */
1216 if ((le16_to_cpu(pkt
->status_flags
) & SF_LOGOUT_SENT
)) {
1217 qla2x00_mark_device_lost(ha
, fcport
, 1);
1222 DEBUG2(printk(KERN_INFO
1223 "scsi(%ld): QUEUE FULL status detected 0x%x-0x%x.\n",
1224 ha
->host_no
, comp_status
, scsi_status
));
1226 /* SCSI Mid-Layer handles device queue full */
1228 cp
->result
= DID_OK
<< 16 | lscsi_status
;
1231 /* Adjust queue depth */
1232 ret
= scsi_track_queue_full(cp
->device
,
1233 sp
->lun_queue
->out_cnt
- 1);
1235 qla_printk(KERN_INFO
, ha
,
1236 "scsi(%ld:%d:%d:%d): Queue depth adjusted to %d.\n",
1237 ha
->host_no
, cp
->device
->channel
, cp
->device
->id
,
1238 cp
->device
->lun
, ret
);
1243 DEBUG3(printk("scsi(%ld): Error detected (unknown status) "
1245 ha
->host_no
, comp_status
, scsi_status
));
1246 qla_printk(KERN_INFO
, ha
,
1247 "Unknown status detected 0x%x-0x%x.\n",
1248 comp_status
, scsi_status
);
1250 cp
->result
= DID_ERROR
<< 16;
1254 /* Place command on done queue. */
1255 if (ha
->status_srb
== NULL
)
1256 add_to_done_queue(ha
, sp
);
1260 * qla2x00_status_cont_entry() - Process a Status Continuations entry.
1261 * @ha: SCSI driver HA context
1262 * @pkt: Entry pointer
1264 * Extended sense data.
1267 qla2x00_status_cont_entry(scsi_qla_host_t
*ha
, sts_cont_entry_t
*pkt
)
1269 uint8_t sense_sz
= 0;
1270 srb_t
*sp
= ha
->status_srb
;
1271 struct scsi_cmnd
*cp
;
1273 if (sp
!= NULL
&& sp
->request_sense_length
!= 0) {
1276 DEBUG2(printk("%s(): Cmd already returned back to OS "
1277 "sp=%p sp->state:%d\n", __func__
, sp
, sp
->state
));
1278 qla_printk(KERN_INFO
, ha
,
1279 "cmd is NULL: already returned to OS (sp=%p)\n",
1282 ha
->status_srb
= NULL
;
1286 if (sp
->request_sense_length
> sizeof(pkt
->data
)) {
1287 sense_sz
= sizeof(pkt
->data
);
1289 sense_sz
= sp
->request_sense_length
;
1292 /* Move sense data. */
1293 memcpy(sp
->request_sense_ptr
, pkt
->data
, sense_sz
);
1294 DEBUG5(qla2x00_dump_buffer(sp
->request_sense_ptr
, sense_sz
));
1296 sp
->request_sense_ptr
+= sense_sz
;
1297 sp
->request_sense_length
-= sense_sz
;
1299 /* Place command on done queue. */
1300 if (sp
->request_sense_length
== 0) {
1301 add_to_done_queue(ha
, sp
);
1302 ha
->status_srb
= NULL
;
1308 * qla2x00_error_entry() - Process an error entry.
1309 * @ha: SCSI driver HA context
1310 * @pkt: Entry pointer
1313 qla2x00_error_entry(scsi_qla_host_t
*ha
, sts_entry_t
*pkt
)
1317 #if defined(QL_DEBUG_LEVEL_2)
1318 if (pkt
->entry_status
& RF_INV_E_ORDER
)
1319 qla_printk(KERN_ERR
, ha
, "%s: Invalid Entry Order\n", __func__
);
1320 else if (pkt
->entry_status
& RF_INV_E_COUNT
)
1321 qla_printk(KERN_ERR
, ha
, "%s: Invalid Entry Count\n", __func__
);
1322 else if (pkt
->entry_status
& RF_INV_E_PARAM
)
1323 qla_printk(KERN_ERR
, ha
,
1324 "%s: Invalid Entry Parameter\n", __func__
);
1325 else if (pkt
->entry_status
& RF_INV_E_TYPE
)
1326 qla_printk(KERN_ERR
, ha
, "%s: Invalid Entry Type\n", __func__
);
1327 else if (pkt
->entry_status
& RF_BUSY
)
1328 qla_printk(KERN_ERR
, ha
, "%s: Busy\n", __func__
);
1330 qla_printk(KERN_ERR
, ha
, "%s: UNKNOWN flag error\n", __func__
);
1333 /* Validate handle. */
1334 if (pkt
->handle
< MAX_OUTSTANDING_COMMANDS
)
1335 sp
= ha
->outstanding_cmds
[pkt
->handle
];
1340 /* Free outstanding command slot. */
1341 ha
->outstanding_cmds
[pkt
->handle
] = NULL
;
1344 sp
->lun_queue
->out_cnt
--;
1346 /* Bad payload or header */
1347 if (pkt
->entry_status
&
1348 (RF_INV_E_ORDER
| RF_INV_E_COUNT
|
1349 RF_INV_E_PARAM
| RF_INV_E_TYPE
)) {
1350 sp
->cmd
->result
= DID_ERROR
<< 16;
1351 } else if (pkt
->entry_status
& RF_BUSY
) {
1352 sp
->cmd
->result
= DID_BUS_BUSY
<< 16;
1354 sp
->cmd
->result
= DID_ERROR
<< 16;
1356 /* Place command on done queue. */
1357 add_to_done_queue(ha
, sp
);
1359 } else if (pkt
->entry_type
== COMMAND_A64_TYPE
||
1360 pkt
->entry_type
== COMMAND_TYPE
) {
1361 DEBUG2(printk("scsi(%ld): Error entry - invalid handle\n",
1363 qla_printk(KERN_WARNING
, ha
,
1364 "Error entry - invalid handle\n");
1366 set_bit(ISP_ABORT_NEEDED
, &ha
->dpc_flags
);
1367 if (ha
->dpc_wait
&& !ha
->dpc_active
)
1373 * qla2x00_ms_entry() - Process a Management Server entry.
1374 * @ha: SCSI driver HA context
1375 * @index: Response queue out pointer
1378 qla2x00_ms_entry(scsi_qla_host_t
*ha
, ms_iocb_entry_t
*pkt
)
1382 DEBUG3(printk("%s(%ld): pkt=%p pkthandle=%d.\n",
1383 __func__
, ha
->host_no
, pkt
, pkt
->handle1
));
1385 /* Validate handle. */
1386 if (pkt
->handle1
< MAX_OUTSTANDING_COMMANDS
)
1387 sp
= ha
->outstanding_cmds
[pkt
->handle1
];
1392 DEBUG2(printk("scsi(%ld): MS entry - invalid handle\n",
1394 qla_printk(KERN_WARNING
, ha
, "MS entry - invalid handle\n");
1396 set_bit(ISP_ABORT_NEEDED
, &ha
->dpc_flags
);
1400 CMD_COMPL_STATUS(sp
->cmd
) = le16_to_cpu(pkt
->status
);
1401 CMD_ENTRY_STATUS(sp
->cmd
) = pkt
->entry_status
;
1403 /* Free outstanding command slot. */
1404 ha
->outstanding_cmds
[pkt
->handle1
] = NULL
;
1406 add_to_done_queue(ha
, sp
);
1410 * qla2x00_check_sense() - Perform any sense data interrogation.
1414 * Returns QLA_SUCCESS if the lun queue is suspended, else
1415 * QLA_FUNCTION_FAILED (lun queue not suspended).
1418 qla2x00_check_sense(struct scsi_cmnd
*cp
, os_lun_t
*lq
)
1420 scsi_qla_host_t
*ha
;
1424 ha
= (scsi_qla_host_t
*) cp
->device
->host
->hostdata
;
1425 if ((cp
->sense_buffer
[0] & 0x70) != 0x70) {
1426 return (QLA_FUNCTION_FAILED
);
1429 sp
= (srb_t
* )CMD_SP(cp
);
1430 sp
->flags
|= SRB_GOT_SENSE
;
1432 switch (cp
->sense_buffer
[2] & 0xf) {
1433 case RECOVERED_ERROR
:
1434 cp
->result
= DID_OK
<< 16;
1435 cp
->sense_buffer
[0] = 0;
1439 fcport
= lq
->fclun
->fcport
;
1442 * Suspend the lun only for hard disk device type.
1444 if ((fcport
->flags
& FCF_TAPE_PRESENT
) == 0 &&
1445 lq
->q_state
!= LUN_STATE_TIMEOUT
) {
1447 * If target is in process of being ready then suspend
1448 * lun for 6 secs and retry all the commands.
1450 if (cp
->sense_buffer
[12] == 0x4 &&
1451 cp
->sense_buffer
[13] == 0x1) {
1453 /* Suspend the lun for 6 secs */
1454 qla2x00_suspend_lun(ha
, lq
, 6,
1457 return (QLA_SUCCESS
);
1463 return (QLA_FUNCTION_FAILED
);