]>
Commit | Line | Data |
---|---|---|
1da177e4 | 1 | /* |
fa90c54f AV |
2 | * QLogic Fibre Channel HBA Driver |
3 | * Copyright (c) 2003-2005 QLogic Corporation | |
1da177e4 | 4 | * |
fa90c54f | 5 | * See LICENSE.qla2xxx for copyright and licensing details. |
1da177e4 LT |
6 | */ |
7 | #include "qla_def.h" | |
8 | ||
9 | static void qla2x00_mbx_completion(scsi_qla_host_t *, uint16_t); | |
9a853f71 | 10 | static void qla2x00_async_event(scsi_qla_host_t *, uint16_t *); |
1da177e4 | 11 | static void qla2x00_process_completed_request(struct scsi_qla_host *, uint32_t); |
9a853f71 | 12 | static void qla2x00_status_entry(scsi_qla_host_t *, void *); |
1da177e4 LT |
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 *); | |
16 | ||
9a853f71 AV |
17 | static void qla24xx_ms_entry(scsi_qla_host_t *, struct ct_entry_24xx *); |
18 | ||
1da177e4 LT |
19 | /** |
20 | * qla2100_intr_handler() - Process interrupts for the ISP2100 and ISP2200. | |
21 | * @irq: | |
22 | * @dev_id: SCSI driver HA context | |
23 | * @regs: | |
24 | * | |
25 | * Called by system whenever the host adapter generates an interrupt. | |
26 | * | |
27 | * Returns handled flag. | |
28 | */ | |
29 | irqreturn_t | |
30 | qla2100_intr_handler(int irq, void *dev_id, struct pt_regs *regs) | |
31 | { | |
32 | scsi_qla_host_t *ha; | |
3d71644c | 33 | struct device_reg_2xxx __iomem *reg; |
1da177e4 LT |
34 | int status; |
35 | unsigned long flags; | |
36 | unsigned long iter; | |
9a853f71 | 37 | uint16_t mb[4]; |
1da177e4 LT |
38 | |
39 | ha = (scsi_qla_host_t *) dev_id; | |
40 | if (!ha) { | |
41 | printk(KERN_INFO | |
42 | "%s(): NULL host pointer\n", __func__); | |
43 | return (IRQ_NONE); | |
44 | } | |
45 | ||
3d71644c | 46 | reg = &ha->iobase->isp; |
1da177e4 LT |
47 | status = 0; |
48 | ||
49 | spin_lock_irqsave(&ha->hardware_lock, flags); | |
50 | for (iter = 50; iter--; ) { | |
51 | if ((RD_REG_WORD(®->istatus) & ISR_RISC_INT) == 0) | |
52 | break; | |
53 | ||
54 | if (RD_REG_WORD(®->semaphore) & BIT_0) { | |
55 | WRT_REG_WORD(®->hccr, HCCR_CLR_RISC_INT); | |
56 | RD_REG_WORD(®->hccr); | |
57 | ||
58 | /* Get mailbox data. */ | |
9a853f71 AV |
59 | mb[0] = RD_MAILBOX_REG(ha, reg, 0); |
60 | if (mb[0] > 0x3fff && mb[0] < 0x8000) { | |
61 | qla2x00_mbx_completion(ha, mb[0]); | |
1da177e4 | 62 | status |= MBX_INTERRUPT; |
9a853f71 AV |
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); | |
1da177e4 LT |
68 | } else { |
69 | /*EMPTY*/ | |
70 | DEBUG2(printk("scsi(%ld): Unrecognized " | |
9a853f71 AV |
71 | "interrupt type (%d).\n", |
72 | ha->host_no, mb[0])); | |
1da177e4 LT |
73 | } |
74 | /* Release mailbox registers. */ | |
75 | WRT_REG_WORD(®->semaphore, 0); | |
76 | RD_REG_WORD(®->semaphore); | |
77 | } else { | |
78 | qla2x00_process_response_queue(ha); | |
79 | ||
80 | WRT_REG_WORD(®->hccr, HCCR_CLR_RISC_INT); | |
81 | RD_REG_WORD(®->hccr); | |
82 | } | |
83 | } | |
84 | spin_unlock_irqrestore(&ha->hardware_lock, flags); | |
85 | ||
1da177e4 LT |
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); | |
89 | ||
90 | set_bit(MBX_INTERRUPT, &ha->mbx_cmd_flags); | |
91 | up(&ha->mbx_intr_sem); | |
92 | ||
93 | spin_unlock_irqrestore(&ha->mbx_reg_lock, flags); | |
94 | } | |
95 | ||
1da177e4 LT |
96 | return (IRQ_HANDLED); |
97 | } | |
98 | ||
99 | /** | |
100 | * qla2300_intr_handler() - Process interrupts for the ISP23xx and ISP63xx. | |
101 | * @irq: | |
102 | * @dev_id: SCSI driver HA context | |
103 | * @regs: | |
104 | * | |
105 | * Called by system whenever the host adapter generates an interrupt. | |
106 | * | |
107 | * Returns handled flag. | |
108 | */ | |
109 | irqreturn_t | |
110 | qla2300_intr_handler(int irq, void *dev_id, struct pt_regs *regs) | |
111 | { | |
112 | scsi_qla_host_t *ha; | |
3d71644c | 113 | struct device_reg_2xxx __iomem *reg; |
1da177e4 LT |
114 | int status; |
115 | unsigned long flags; | |
116 | unsigned long iter; | |
117 | uint32_t stat; | |
1da177e4 | 118 | uint16_t hccr; |
9a853f71 | 119 | uint16_t mb[4]; |
1da177e4 LT |
120 | |
121 | ha = (scsi_qla_host_t *) dev_id; | |
122 | if (!ha) { | |
123 | printk(KERN_INFO | |
124 | "%s(): NULL host pointer\n", __func__); | |
125 | return (IRQ_NONE); | |
126 | } | |
127 | ||
3d71644c | 128 | reg = &ha->iobase->isp; |
1da177e4 LT |
129 | status = 0; |
130 | ||
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); | |
139 | else | |
140 | qla_printk(KERN_INFO, ha, | |
9a853f71 | 141 | "RISC paused -- HCCR=%x.\n", hccr); |
1da177e4 LT |
142 | |
143 | /* | |
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. | |
147 | */ | |
148 | WRT_REG_WORD(®->hccr, HCCR_RESET_RISC); | |
149 | RD_REG_WORD(®->hccr); | |
150 | set_bit(ISP_ABORT_NEEDED, &ha->dpc_flags); | |
151 | break; | |
152 | } else if ((stat & HSR_RISC_INT) == 0) | |
153 | break; | |
154 | ||
1da177e4 | 155 | switch (stat & 0xff) { |
1da177e4 LT |
156 | case 0x1: |
157 | case 0x2: | |
158 | case 0x10: | |
159 | case 0x11: | |
9a853f71 | 160 | qla2x00_mbx_completion(ha, MSW(stat)); |
1da177e4 LT |
161 | status |= MBX_INTERRUPT; |
162 | ||
163 | /* Release mailbox registers. */ | |
164 | WRT_REG_WORD(®->semaphore, 0); | |
165 | break; | |
166 | case 0x12: | |
9a853f71 AV |
167 | mb[0] = MSW(stat); |
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); | |
172 | break; | |
173 | case 0x13: | |
174 | qla2x00_process_response_queue(ha); | |
1da177e4 LT |
175 | break; |
176 | case 0x15: | |
9a853f71 AV |
177 | mb[0] = MBA_CMPLT_1_16BIT; |
178 | mb[1] = MSW(stat); | |
179 | qla2x00_async_event(ha, mb); | |
1da177e4 LT |
180 | break; |
181 | case 0x16: | |
9a853f71 AV |
182 | mb[0] = MBA_SCSI_COMPLETION; |
183 | mb[1] = MSW(stat); | |
184 | mb[2] = RD_MAILBOX_REG(ha, reg, 2); | |
185 | qla2x00_async_event(ha, mb); | |
1da177e4 LT |
186 | break; |
187 | default: | |
188 | DEBUG2(printk("scsi(%ld): Unrecognized interrupt type " | |
9a853f71 | 189 | "(%d).\n", |
1da177e4 LT |
190 | ha->host_no, stat & 0xff)); |
191 | break; | |
192 | } | |
193 | WRT_REG_WORD(®->hccr, HCCR_CLR_RISC_INT); | |
194 | RD_REG_WORD_RELAXED(®->hccr); | |
195 | } | |
196 | spin_unlock_irqrestore(&ha->hardware_lock, flags); | |
197 | ||
1da177e4 LT |
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); | |
201 | ||
202 | set_bit(MBX_INTERRUPT, &ha->mbx_cmd_flags); | |
203 | up(&ha->mbx_intr_sem); | |
204 | ||
205 | spin_unlock_irqrestore(&ha->mbx_reg_lock, flags); | |
206 | } | |
207 | ||
1da177e4 LT |
208 | return (IRQ_HANDLED); |
209 | } | |
210 | ||
211 | /** | |
212 | * qla2x00_mbx_completion() - Process mailbox command completions. | |
213 | * @ha: SCSI driver HA context | |
214 | * @mb0: Mailbox0 register | |
215 | */ | |
216 | static void | |
217 | qla2x00_mbx_completion(scsi_qla_host_t *ha, uint16_t mb0) | |
218 | { | |
219 | uint16_t cnt; | |
220 | uint16_t __iomem *wptr; | |
3d71644c | 221 | struct device_reg_2xxx __iomem *reg = &ha->iobase->isp; |
1da177e4 LT |
222 | |
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); | |
227 | ||
228 | for (cnt = 1; cnt < ha->mbx_count; cnt++) { | |
fa2a1ce5 | 229 | if (IS_QLA2200(ha) && cnt == 8) |
1da177e4 LT |
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); | |
233 | else | |
234 | ha->mailbox_out[cnt] = RD_REG_WORD(wptr); | |
fa2a1ce5 | 235 | |
1da177e4 LT |
236 | wptr++; |
237 | } | |
238 | ||
239 | if (ha->mcp) { | |
240 | DEBUG3(printk("%s(%ld): Got mailbox completion. cmd=%x.\n", | |
241 | __func__, ha->host_no, ha->mcp->mb[0])); | |
242 | } else { | |
243 | DEBUG2_3(printk("%s(%ld): MBX pointer ERROR!\n", | |
244 | __func__, ha->host_no)); | |
245 | } | |
246 | } | |
247 | ||
248 | /** | |
249 | * qla2x00_async_event() - Process aynchronous events. | |
250 | * @ha: SCSI driver HA context | |
9a853f71 | 251 | * @mb: Mailbox registers (0 - 3) |
1da177e4 LT |
252 | */ |
253 | static void | |
9a853f71 | 254 | qla2x00_async_event(scsi_qla_host_t *ha, uint16_t *mb) |
1da177e4 | 255 | { |
9a853f71 AV |
256 | #define LS_UNKNOWN 2 |
257 | static char *link_speeds[5] = { "1", "2", "?", "4", "10" }; | |
1da177e4 | 258 | char *link_speed; |
1da177e4 LT |
259 | uint16_t handle_cnt; |
260 | uint16_t cnt; | |
261 | uint32_t handles[5]; | |
3d71644c | 262 | struct device_reg_2xxx __iomem *reg = &ha->iobase->isp; |
1da177e4 LT |
263 | uint32_t rscn_entry, host_pid; |
264 | uint8_t rscn_queue_index; | |
265 | ||
266 | /* Setup to process RIO completion. */ | |
267 | handle_cnt = 0; | |
1da177e4 LT |
268 | switch (mb[0]) { |
269 | case MBA_SCSI_COMPLETION: | |
9a853f71 | 270 | handles[0] = le32_to_cpu((uint32_t)((mb[2] << 16) | mb[1])); |
1da177e4 LT |
271 | handle_cnt = 1; |
272 | break; | |
273 | case MBA_CMPLT_1_16BIT: | |
9a853f71 | 274 | handles[0] = mb[1]; |
1da177e4 LT |
275 | handle_cnt = 1; |
276 | mb[0] = MBA_SCSI_COMPLETION; | |
277 | break; | |
278 | case MBA_CMPLT_2_16BIT: | |
9a853f71 AV |
279 | handles[0] = mb[1]; |
280 | handles[1] = mb[2]; | |
1da177e4 LT |
281 | handle_cnt = 2; |
282 | mb[0] = MBA_SCSI_COMPLETION; | |
283 | break; | |
284 | case MBA_CMPLT_3_16BIT: | |
9a853f71 AV |
285 | handles[0] = mb[1]; |
286 | handles[1] = mb[2]; | |
287 | handles[2] = mb[3]; | |
1da177e4 LT |
288 | handle_cnt = 3; |
289 | mb[0] = MBA_SCSI_COMPLETION; | |
290 | break; | |
291 | case MBA_CMPLT_4_16BIT: | |
9a853f71 AV |
292 | handles[0] = mb[1]; |
293 | handles[1] = mb[2]; | |
294 | handles[2] = mb[3]; | |
1da177e4 LT |
295 | handles[3] = (uint32_t)RD_MAILBOX_REG(ha, reg, 6); |
296 | handle_cnt = 4; | |
297 | mb[0] = MBA_SCSI_COMPLETION; | |
298 | break; | |
299 | case MBA_CMPLT_5_16BIT: | |
9a853f71 AV |
300 | handles[0] = mb[1]; |
301 | handles[1] = mb[2]; | |
302 | handles[2] = mb[3]; | |
1da177e4 LT |
303 | handles[3] = (uint32_t)RD_MAILBOX_REG(ha, reg, 6); |
304 | handles[4] = (uint32_t)RD_MAILBOX_REG(ha, reg, 7); | |
305 | handle_cnt = 5; | |
306 | mb[0] = MBA_SCSI_COMPLETION; | |
307 | break; | |
308 | case MBA_CMPLT_2_32BIT: | |
9a853f71 | 309 | handles[0] = le32_to_cpu((uint32_t)((mb[2] << 16) | mb[1])); |
1da177e4 LT |
310 | handles[1] = le32_to_cpu( |
311 | ((uint32_t)(RD_MAILBOX_REG(ha, reg, 7) << 16)) | | |
312 | RD_MAILBOX_REG(ha, reg, 6)); | |
313 | handle_cnt = 2; | |
314 | mb[0] = MBA_SCSI_COMPLETION; | |
315 | break; | |
316 | default: | |
317 | break; | |
318 | } | |
319 | ||
320 | switch (mb[0]) { | |
321 | case MBA_SCSI_COMPLETION: /* Fast Post */ | |
322 | if (!ha->flags.online) | |
323 | break; | |
324 | ||
325 | for (cnt = 0; cnt < handle_cnt; cnt++) | |
326 | qla2x00_process_completed_request(ha, handles[cnt]); | |
327 | break; | |
328 | ||
329 | case MBA_RESET: /* Reset */ | |
330 | DEBUG2(printk("scsi(%ld): Asynchronous RESET.\n", ha->host_no)); | |
331 | ||
332 | set_bit(RESET_MARKER_NEEDED, &ha->dpc_flags); | |
333 | break; | |
334 | ||
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); | |
339 | ||
340 | qla_printk(KERN_INFO, ha, | |
341 | "ISP System Error - mbx1=%xh mbx2=%xh mbx3=%xh.\n", | |
342 | mb[1], mb[2], mb[3]); | |
343 | ||
abbd8870 | 344 | ha->isp_ops.fw_dump(ha, 1); |
1da177e4 | 345 | |
044cc6c8 | 346 | if (IS_QLA24XX(ha) || IS_QLA54XX(ha)) { |
9a853f71 AV |
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; | |
352 | } else | |
353 | set_bit(ISP_ABORT_NEEDED, &ha->dpc_flags); | |
354 | } else if (mb[1] == 0) { | |
1da177e4 LT |
355 | qla_printk(KERN_INFO, ha, |
356 | "Unrecoverable Hardware Error: adapter marked " | |
357 | "OFFLINE!\n"); | |
358 | ha->flags.online = 0; | |
359 | } else | |
360 | set_bit(ISP_ABORT_NEEDED, &ha->dpc_flags); | |
361 | break; | |
362 | ||
363 | case MBA_REQ_TRANSFER_ERR: /* Request Transfer Error */ | |
364 | DEBUG2(printk("scsi(%ld): ISP Request Transfer Error.\n", | |
365 | ha->host_no)); | |
366 | qla_printk(KERN_WARNING, ha, "ISP Request Transfer Error.\n"); | |
367 | ||
368 | set_bit(ISP_ABORT_NEEDED, &ha->dpc_flags); | |
369 | break; | |
370 | ||
371 | case MBA_RSP_TRANSFER_ERR: /* Response Transfer Error */ | |
372 | DEBUG2(printk("scsi(%ld): ISP Response Transfer Error.\n", | |
373 | ha->host_no)); | |
374 | qla_printk(KERN_WARNING, ha, "ISP Response Transfer Error.\n"); | |
375 | ||
376 | set_bit(ISP_ABORT_NEEDED, &ha->dpc_flags); | |
377 | break; | |
378 | ||
379 | case MBA_WAKEUP_THRES: /* Request Queue Wake-up */ | |
380 | DEBUG2(printk("scsi(%ld): Asynchronous WAKEUP_THRES.\n", | |
381 | ha->host_no)); | |
382 | break; | |
383 | ||
384 | case MBA_LIP_OCCURRED: /* Loop Initialization Procedure */ | |
1da177e4 LT |
385 | DEBUG2(printk("scsi(%ld): LIP occured (%x).\n", ha->host_no, |
386 | mb[1])); | |
387 | qla_printk(KERN_INFO, ha, "LIP occured (%x).\n", mb[1]); | |
388 | ||
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); | |
d97994dc | 392 | qla2x00_mark_all_devices_lost(ha, 1); |
1da177e4 LT |
393 | } |
394 | ||
395 | set_bit(REGISTER_FC4_NEEDED, &ha->dpc_flags); | |
396 | ||
397 | ha->flags.management_server_logged_in = 0; | |
1da177e4 LT |
398 | break; |
399 | ||
400 | case MBA_LOOP_UP: /* Loop Up Event */ | |
1da177e4 LT |
401 | if (IS_QLA2100(ha) || IS_QLA2200(ha)) { |
402 | link_speed = link_speeds[0]; | |
04414013 | 403 | ha->link_data_rate = LDR_1GB; |
1da177e4 | 404 | } else { |
9a853f71 | 405 | link_speed = link_speeds[LS_UNKNOWN]; |
1da177e4 LT |
406 | if (mb[1] < 5) |
407 | link_speed = link_speeds[mb[1]]; | |
408 | ha->link_data_rate = mb[1]; | |
409 | } | |
410 | ||
411 | DEBUG2(printk("scsi(%ld): Asynchronous LOOP UP (%s Gbps).\n", | |
412 | ha->host_no, link_speed)); | |
413 | qla_printk(KERN_INFO, ha, "LOOP UP detected (%s Gbps).\n", | |
414 | link_speed); | |
415 | ||
416 | ha->flags.management_server_logged_in = 0; | |
1da177e4 LT |
417 | break; |
418 | ||
419 | case MBA_LOOP_DOWN: /* Loop Down Event */ | |
9a853f71 AV |
420 | DEBUG2(printk("scsi(%ld): Asynchronous LOOP DOWN (%x).\n", |
421 | ha->host_no, mb[1])); | |
422 | qla_printk(KERN_INFO, ha, "LOOP DOWN detected (%x).\n", mb[1]); | |
1da177e4 LT |
423 | |
424 | if (atomic_read(&ha->loop_state) != LOOP_DOWN) { | |
425 | atomic_set(&ha->loop_state, LOOP_DOWN); | |
426 | atomic_set(&ha->loop_down_timer, LOOP_DOWN_TIME); | |
427 | ha->device_flags |= DFLG_NO_CABLE; | |
d97994dc | 428 | qla2x00_mark_all_devices_lost(ha, 1); |
1da177e4 LT |
429 | } |
430 | ||
431 | ha->flags.management_server_logged_in = 0; | |
04414013 | 432 | ha->link_data_rate = LDR_UNKNOWN; |
cca5335c AV |
433 | if (ql2xfdmienable) |
434 | set_bit(REGISTER_FDMI_NEEDED, &ha->dpc_flags); | |
1da177e4 LT |
435 | break; |
436 | ||
437 | case MBA_LIP_RESET: /* LIP reset occurred */ | |
1da177e4 LT |
438 | DEBUG2(printk("scsi(%ld): Asynchronous LIP RESET (%x).\n", |
439 | ha->host_no, mb[1])); | |
440 | qla_printk(KERN_INFO, ha, | |
441 | "LIP reset occured (%x).\n", mb[1]); | |
442 | ||
443 | if (atomic_read(&ha->loop_state) != LOOP_DOWN) { | |
444 | atomic_set(&ha->loop_state, LOOP_DOWN); | |
445 | atomic_set(&ha->loop_down_timer, LOOP_DOWN_TIME); | |
d97994dc | 446 | qla2x00_mark_all_devices_lost(ha, 1); |
1da177e4 LT |
447 | } |
448 | ||
449 | set_bit(RESET_MARKER_NEEDED, &ha->dpc_flags); | |
450 | ||
451 | ha->operating_mode = LOOP; | |
452 | ha->flags.management_server_logged_in = 0; | |
1da177e4 LT |
453 | break; |
454 | ||
455 | case MBA_POINT_TO_POINT: /* Point-to-Point */ | |
456 | if (IS_QLA2100(ha)) | |
457 | break; | |
458 | ||
459 | DEBUG2(printk("scsi(%ld): Asynchronous P2P MODE received.\n", | |
460 | ha->host_no)); | |
461 | ||
462 | /* | |
463 | * Until there's a transition from loop down to loop up, treat | |
464 | * this as loop down only. | |
465 | */ | |
466 | if (atomic_read(&ha->loop_state) != LOOP_DOWN) { | |
467 | atomic_set(&ha->loop_state, LOOP_DOWN); | |
468 | if (!atomic_read(&ha->loop_down_timer)) | |
469 | atomic_set(&ha->loop_down_timer, | |
470 | LOOP_DOWN_TIME); | |
d97994dc | 471 | qla2x00_mark_all_devices_lost(ha, 1); |
1da177e4 LT |
472 | } |
473 | ||
474 | if (!(test_bit(ABORT_ISP_ACTIVE, &ha->dpc_flags))) { | |
475 | set_bit(RESET_MARKER_NEEDED, &ha->dpc_flags); | |
476 | } | |
477 | set_bit(REGISTER_FC4_NEEDED, &ha->dpc_flags); | |
478 | break; | |
479 | ||
480 | case MBA_CHG_IN_CONNECTION: /* Change in connection mode */ | |
481 | if (IS_QLA2100(ha)) | |
482 | break; | |
483 | ||
1da177e4 LT |
484 | DEBUG2(printk("scsi(%ld): Asynchronous Change In Connection " |
485 | "received.\n", | |
486 | ha->host_no)); | |
487 | qla_printk(KERN_INFO, ha, | |
488 | "Configuration change detected: value=%x.\n", mb[1]); | |
489 | ||
490 | if (atomic_read(&ha->loop_state) != LOOP_DOWN) { | |
fa2a1ce5 | 491 | atomic_set(&ha->loop_state, LOOP_DOWN); |
1da177e4 LT |
492 | if (!atomic_read(&ha->loop_down_timer)) |
493 | atomic_set(&ha->loop_down_timer, | |
494 | LOOP_DOWN_TIME); | |
d97994dc | 495 | qla2x00_mark_all_devices_lost(ha, 1); |
1da177e4 LT |
496 | } |
497 | ||
498 | set_bit(LOOP_RESYNC_NEEDED, &ha->dpc_flags); | |
499 | set_bit(LOCAL_LOOP_UPDATE, &ha->dpc_flags); | |
500 | break; | |
501 | ||
502 | case MBA_PORT_UPDATE: /* Port database update */ | |
1da177e4 LT |
503 | /* |
504 | * If PORT UPDATE is global (recieved LIP_OCCURED/LIP_RESET | |
505 | * event etc. earlier indicating loop is down) then process | |
506 | * it. Otherwise ignore it and Wait for RSCN to come in. | |
507 | */ | |
508 | atomic_set(&ha->loop_down_timer, 0); | |
509 | if (atomic_read(&ha->loop_state) != LOOP_DOWN && | |
510 | atomic_read(&ha->loop_state) != LOOP_DEAD) { | |
511 | DEBUG2(printk("scsi(%ld): Asynchronous PORT UPDATE " | |
9a853f71 AV |
512 | "ignored %04x/%04x/%04x.\n", ha->host_no, mb[1], |
513 | mb[2], mb[3])); | |
1da177e4 LT |
514 | break; |
515 | } | |
516 | ||
517 | DEBUG2(printk("scsi(%ld): Asynchronous PORT UPDATE.\n", | |
518 | ha->host_no)); | |
519 | DEBUG(printk(KERN_INFO | |
9a853f71 AV |
520 | "scsi(%ld): Port database changed %04x %04x %04x.\n", |
521 | ha->host_no, mb[1], mb[2], mb[3])); | |
1da177e4 LT |
522 | |
523 | /* | |
524 | * Mark all devices as missing so we will login again. | |
525 | */ | |
526 | atomic_set(&ha->loop_state, LOOP_UP); | |
527 | ||
d97994dc | 528 | qla2x00_mark_all_devices_lost(ha, 1); |
1da177e4 LT |
529 | |
530 | ha->flags.rscn_queue_overflow = 1; | |
531 | ||
532 | set_bit(LOOP_RESYNC_NEEDED, &ha->dpc_flags); | |
533 | set_bit(LOCAL_LOOP_UPDATE, &ha->dpc_flags); | |
1da177e4 LT |
534 | break; |
535 | ||
536 | case MBA_RSCN_UPDATE: /* State Change Registration */ | |
1da177e4 LT |
537 | DEBUG2(printk("scsi(%ld): Asynchronous RSCR UPDATE.\n", |
538 | ha->host_no)); | |
539 | DEBUG(printk(KERN_INFO | |
540 | "scsi(%ld): RSCN database changed -- %04x %04x.\n", | |
541 | ha->host_no, mb[1], mb[2])); | |
542 | ||
543 | rscn_entry = (mb[1] << 16) | mb[2]; | |
544 | host_pid = (ha->d_id.b.domain << 16) | (ha->d_id.b.area << 8) | | |
545 | ha->d_id.b.al_pa; | |
546 | if (rscn_entry == host_pid) { | |
547 | DEBUG(printk(KERN_INFO | |
548 | "scsi(%ld): Ignoring RSCN update to local host " | |
549 | "port ID (%06x)\n", | |
550 | ha->host_no, host_pid)); | |
551 | break; | |
552 | } | |
553 | ||
554 | rscn_queue_index = ha->rscn_in_ptr + 1; | |
555 | if (rscn_queue_index == MAX_RSCN_COUNT) | |
556 | rscn_queue_index = 0; | |
557 | if (rscn_queue_index != ha->rscn_out_ptr) { | |
558 | ha->rscn_queue[ha->rscn_in_ptr] = rscn_entry; | |
559 | ha->rscn_in_ptr = rscn_queue_index; | |
560 | } else { | |
561 | ha->flags.rscn_queue_overflow = 1; | |
562 | } | |
563 | ||
564 | atomic_set(&ha->loop_state, LOOP_UPDATE); | |
565 | atomic_set(&ha->loop_down_timer, 0); | |
566 | ha->flags.management_server_logged_in = 0; | |
567 | ||
568 | set_bit(LOOP_RESYNC_NEEDED, &ha->dpc_flags); | |
569 | set_bit(RSCN_UPDATE, &ha->dpc_flags); | |
1da177e4 LT |
570 | break; |
571 | ||
572 | /* case MBA_RIO_RESPONSE: */ | |
573 | case MBA_ZIO_RESPONSE: | |
574 | DEBUG2(printk("scsi(%ld): [R|Z]IO update completion.\n", | |
575 | ha->host_no)); | |
576 | DEBUG(printk(KERN_INFO | |
577 | "scsi(%ld): [R|Z]IO update completion.\n", | |
578 | ha->host_no)); | |
579 | ||
044cc6c8 | 580 | if (IS_QLA24XX(ha) || IS_QLA54XX(ha)) |
4fdfefe5 AV |
581 | qla24xx_process_response_queue(ha); |
582 | else | |
583 | qla2x00_process_response_queue(ha); | |
1da177e4 | 584 | break; |
9a853f71 AV |
585 | |
586 | case MBA_DISCARD_RND_FRAME: | |
587 | DEBUG2(printk("scsi(%ld): Discard RND Frame -- %04x %04x " | |
588 | "%04x.\n", ha->host_no, mb[1], mb[2], mb[3])); | |
589 | break; | |
45ebeb56 AV |
590 | |
591 | case MBA_TRACE_NOTIFICATION: | |
592 | DEBUG2(printk("scsi(%ld): Trace Notification -- %04x %04x.\n", | |
593 | ha->host_no, mb[1], mb[2])); | |
594 | break; | |
1da177e4 LT |
595 | } |
596 | } | |
597 | ||
598 | /** | |
599 | * qla2x00_process_completed_request() - Process a Fast Post response. | |
600 | * @ha: SCSI driver HA context | |
601 | * @index: SRB index | |
602 | */ | |
603 | static void | |
604 | qla2x00_process_completed_request(struct scsi_qla_host *ha, uint32_t index) | |
605 | { | |
606 | srb_t *sp; | |
607 | ||
608 | /* Validate handle. */ | |
609 | if (index >= MAX_OUTSTANDING_COMMANDS) { | |
610 | DEBUG2(printk("scsi(%ld): Invalid SCSI completion handle %d.\n", | |
611 | ha->host_no, index)); | |
612 | qla_printk(KERN_WARNING, ha, | |
613 | "Invalid SCSI completion handle %d.\n", index); | |
614 | ||
615 | set_bit(ISP_ABORT_NEEDED, &ha->dpc_flags); | |
616 | return; | |
617 | } | |
618 | ||
619 | sp = ha->outstanding_cmds[index]; | |
620 | if (sp) { | |
621 | /* Free outstanding command slot. */ | |
622 | ha->outstanding_cmds[index] = NULL; | |
623 | ||
1da177e4 LT |
624 | CMD_COMPL_STATUS(sp->cmd) = 0L; |
625 | CMD_SCSI_STATUS(sp->cmd) = 0L; | |
626 | ||
627 | /* Save ISP completion status */ | |
628 | sp->cmd->result = DID_OK << 16; | |
f4f051eb | 629 | qla2x00_sp_compl(ha, sp); |
1da177e4 LT |
630 | } else { |
631 | DEBUG2(printk("scsi(%ld): Invalid ISP SCSI completion handle\n", | |
632 | ha->host_no)); | |
633 | qla_printk(KERN_WARNING, ha, | |
634 | "Invalid ISP SCSI completion handle\n"); | |
635 | ||
636 | set_bit(ISP_ABORT_NEEDED, &ha->dpc_flags); | |
637 | } | |
638 | } | |
639 | ||
640 | /** | |
641 | * qla2x00_process_response_queue() - Process response queue entries. | |
642 | * @ha: SCSI driver HA context | |
643 | */ | |
644 | void | |
645 | qla2x00_process_response_queue(struct scsi_qla_host *ha) | |
646 | { | |
3d71644c | 647 | struct device_reg_2xxx __iomem *reg = &ha->iobase->isp; |
1da177e4 LT |
648 | sts_entry_t *pkt; |
649 | uint16_t handle_cnt; | |
650 | uint16_t cnt; | |
651 | ||
652 | if (!ha->flags.online) | |
653 | return; | |
654 | ||
655 | while (ha->response_ring_ptr->signature != RESPONSE_PROCESSED) { | |
656 | pkt = (sts_entry_t *)ha->response_ring_ptr; | |
657 | ||
658 | ha->rsp_ring_index++; | |
659 | if (ha->rsp_ring_index == ha->response_q_length) { | |
660 | ha->rsp_ring_index = 0; | |
661 | ha->response_ring_ptr = ha->response_ring; | |
662 | } else { | |
663 | ha->response_ring_ptr++; | |
664 | } | |
665 | ||
666 | if (pkt->entry_status != 0) { | |
667 | DEBUG3(printk(KERN_INFO | |
668 | "scsi(%ld): Process error entry.\n", ha->host_no)); | |
669 | ||
670 | qla2x00_error_entry(ha, pkt); | |
671 | ((response_t *)pkt)->signature = RESPONSE_PROCESSED; | |
672 | wmb(); | |
673 | continue; | |
674 | } | |
675 | ||
676 | switch (pkt->entry_type) { | |
677 | case STATUS_TYPE: | |
678 | qla2x00_status_entry(ha, pkt); | |
679 | break; | |
680 | case STATUS_TYPE_21: | |
681 | handle_cnt = ((sts21_entry_t *)pkt)->handle_count; | |
682 | for (cnt = 0; cnt < handle_cnt; cnt++) { | |
683 | qla2x00_process_completed_request(ha, | |
684 | ((sts21_entry_t *)pkt)->handle[cnt]); | |
685 | } | |
686 | break; | |
687 | case STATUS_TYPE_22: | |
688 | handle_cnt = ((sts22_entry_t *)pkt)->handle_count; | |
689 | for (cnt = 0; cnt < handle_cnt; cnt++) { | |
690 | qla2x00_process_completed_request(ha, | |
691 | ((sts22_entry_t *)pkt)->handle[cnt]); | |
692 | } | |
693 | break; | |
694 | case STATUS_CONT_TYPE: | |
695 | qla2x00_status_cont_entry(ha, (sts_cont_entry_t *)pkt); | |
696 | break; | |
697 | case MS_IOCB_TYPE: | |
698 | qla2x00_ms_entry(ha, (ms_iocb_entry_t *)pkt); | |
699 | break; | |
1da177e4 LT |
700 | default: |
701 | /* Type Not Supported. */ | |
702 | DEBUG4(printk(KERN_WARNING | |
703 | "scsi(%ld): Received unknown response pkt type %x " | |
704 | "entry status=%x.\n", | |
705 | ha->host_no, pkt->entry_type, pkt->entry_status)); | |
706 | break; | |
707 | } | |
708 | ((response_t *)pkt)->signature = RESPONSE_PROCESSED; | |
709 | wmb(); | |
710 | } | |
711 | ||
712 | /* Adjust ring index */ | |
713 | WRT_REG_WORD(ISP_RSP_Q_OUT(ha, reg), ha->rsp_ring_index); | |
714 | } | |
715 | ||
716 | /** | |
717 | * qla2x00_status_entry() - Process a Status IOCB entry. | |
718 | * @ha: SCSI driver HA context | |
719 | * @pkt: Entry pointer | |
720 | */ | |
721 | static void | |
9a853f71 | 722 | qla2x00_status_entry(scsi_qla_host_t *ha, void *pkt) |
1da177e4 | 723 | { |
1da177e4 | 724 | srb_t *sp; |
1da177e4 LT |
725 | fc_port_t *fcport; |
726 | struct scsi_cmnd *cp; | |
9a853f71 AV |
727 | sts_entry_t *sts; |
728 | struct sts_entry_24xx *sts24; | |
1da177e4 LT |
729 | uint16_t comp_status; |
730 | uint16_t scsi_status; | |
731 | uint8_t lscsi_status; | |
732 | int32_t resid; | |
ed17c71b | 733 | uint32_t sense_len, rsp_info_len, resid_len, fw_resid_len; |
9a853f71 AV |
734 | uint8_t *rsp_info, *sense_data; |
735 | ||
736 | sts = (sts_entry_t *) pkt; | |
737 | sts24 = (struct sts_entry_24xx *) pkt; | |
044cc6c8 | 738 | if (IS_QLA24XX(ha) || IS_QLA54XX(ha)) { |
9a853f71 AV |
739 | comp_status = le16_to_cpu(sts24->comp_status); |
740 | scsi_status = le16_to_cpu(sts24->scsi_status) & SS_MASK; | |
741 | } else { | |
742 | comp_status = le16_to_cpu(sts->comp_status); | |
743 | scsi_status = le16_to_cpu(sts->scsi_status) & SS_MASK; | |
744 | } | |
1da177e4 LT |
745 | |
746 | /* Fast path completion. */ | |
9a853f71 AV |
747 | if (comp_status == CS_COMPLETE && scsi_status == 0) { |
748 | qla2x00_process_completed_request(ha, sts->handle); | |
1da177e4 LT |
749 | |
750 | return; | |
751 | } | |
752 | ||
753 | /* Validate handle. */ | |
9a853f71 AV |
754 | if (sts->handle < MAX_OUTSTANDING_COMMANDS) { |
755 | sp = ha->outstanding_cmds[sts->handle]; | |
756 | ha->outstanding_cmds[sts->handle] = NULL; | |
1da177e4 LT |
757 | } else |
758 | sp = NULL; | |
759 | ||
760 | if (sp == NULL) { | |
761 | DEBUG2(printk("scsi(%ld): Status Entry invalid handle.\n", | |
762 | ha->host_no)); | |
763 | qla_printk(KERN_WARNING, ha, "Status Entry invalid handle.\n"); | |
764 | ||
765 | set_bit(ISP_ABORT_NEEDED, &ha->dpc_flags); | |
39a11240 | 766 | qla2xxx_wake_dpc(ha); |
1da177e4 LT |
767 | return; |
768 | } | |
769 | cp = sp->cmd; | |
770 | if (cp == NULL) { | |
771 | DEBUG2(printk("scsi(%ld): Command already returned back to OS " | |
75bc4190 | 772 | "pkt->handle=%d sp=%p.\n", ha->host_no, sts->handle, sp)); |
1da177e4 LT |
773 | qla_printk(KERN_WARNING, ha, |
774 | "Command is NULL: already returned to OS (sp=%p)\n", sp); | |
775 | ||
776 | return; | |
777 | } | |
778 | ||
9a853f71 AV |
779 | lscsi_status = scsi_status & STATUS_MASK; |
780 | CMD_ENTRY_STATUS(cp) = sts->entry_status; | |
1da177e4 LT |
781 | CMD_COMPL_STATUS(cp) = comp_status; |
782 | CMD_SCSI_STATUS(cp) = scsi_status; | |
783 | ||
bdf79621 | 784 | fcport = sp->fcport; |
1da177e4 | 785 | |
ed17c71b | 786 | sense_len = rsp_info_len = resid_len = fw_resid_len = 0; |
044cc6c8 | 787 | if (IS_QLA24XX(ha) || IS_QLA54XX(ha)) { |
9a853f71 AV |
788 | sense_len = le32_to_cpu(sts24->sense_len); |
789 | rsp_info_len = le32_to_cpu(sts24->rsp_data_len); | |
790 | resid_len = le32_to_cpu(sts24->rsp_residual_count); | |
ed17c71b | 791 | fw_resid_len = le32_to_cpu(sts24->residual_len); |
9a853f71 AV |
792 | rsp_info = sts24->data; |
793 | sense_data = sts24->data; | |
794 | host_to_fcp_swap(sts24->data, sizeof(sts24->data)); | |
795 | } else { | |
796 | sense_len = le16_to_cpu(sts->req_sense_length); | |
797 | rsp_info_len = le16_to_cpu(sts->rsp_info_len); | |
798 | resid_len = le32_to_cpu(sts->residual_length); | |
799 | rsp_info = sts->rsp_info; | |
800 | sense_data = sts->req_sense_data; | |
801 | } | |
802 | ||
1da177e4 LT |
803 | /* Check for any FCP transport errors. */ |
804 | if (scsi_status & SS_RESPONSE_INFO_LEN_VALID) { | |
9a853f71 | 805 | /* Sense data lies beyond any FCP RESPONSE data. */ |
044cc6c8 | 806 | if (IS_QLA24XX(ha) || IS_QLA54XX(ha)) |
9a853f71 AV |
807 | sense_data += rsp_info_len; |
808 | if (rsp_info_len > 3 && rsp_info[3]) { | |
1da177e4 LT |
809 | DEBUG2(printk("scsi(%ld:%d:%d:%d) FCP I/O protocol " |
810 | "failure (%x/%02x%02x%02x%02x%02x%02x%02x%02x)..." | |
9a853f71 AV |
811 | "retrying command\n", ha->host_no, |
812 | cp->device->channel, cp->device->id, | |
813 | cp->device->lun, rsp_info_len, rsp_info[0], | |
814 | rsp_info[1], rsp_info[2], rsp_info[3], rsp_info[4], | |
815 | rsp_info[5], rsp_info[6], rsp_info[7])); | |
1da177e4 LT |
816 | |
817 | cp->result = DID_BUS_BUSY << 16; | |
f4f051eb | 818 | qla2x00_sp_compl(ha, sp); |
1da177e4 LT |
819 | return; |
820 | } | |
821 | } | |
822 | ||
823 | /* | |
824 | * Based on Host and scsi status generate status code for Linux | |
825 | */ | |
826 | switch (comp_status) { | |
827 | case CS_COMPLETE: | |
828 | if (scsi_status == 0) { | |
829 | cp->result = DID_OK << 16; | |
830 | break; | |
831 | } | |
832 | if (scsi_status & (SS_RESIDUAL_UNDER | SS_RESIDUAL_OVER)) { | |
9a853f71 | 833 | resid = resid_len; |
1da177e4 LT |
834 | cp->resid = resid; |
835 | CMD_RESID_LEN(cp) = resid; | |
0da69df1 AV |
836 | |
837 | if (!lscsi_status && | |
838 | ((unsigned)(cp->request_bufflen - resid) < | |
839 | cp->underflow)) { | |
840 | qla_printk(KERN_INFO, ha, | |
841 | "scsi(%ld:%d:%d:%d): Mid-layer underflow " | |
842 | "detected (%x of %x bytes)...returning " | |
843 | "error status.\n", ha->host_no, | |
844 | cp->device->channel, cp->device->id, | |
845 | cp->device->lun, resid, | |
846 | cp->request_bufflen); | |
847 | ||
848 | cp->result = DID_ERROR << 16; | |
849 | break; | |
850 | } | |
1da177e4 | 851 | } |
1da177e4 LT |
852 | cp->result = DID_OK << 16 | lscsi_status; |
853 | ||
854 | if (lscsi_status != SS_CHECK_CONDITION) | |
855 | break; | |
856 | ||
9a853f71 | 857 | /* Copy Sense Data into sense buffer. */ |
1da177e4 LT |
858 | memset(cp->sense_buffer, 0, sizeof(cp->sense_buffer)); |
859 | ||
860 | if (!(scsi_status & SS_SENSE_LEN_VALID)) | |
861 | break; | |
862 | ||
9a853f71 AV |
863 | if (sense_len >= sizeof(cp->sense_buffer)) |
864 | sense_len = sizeof(cp->sense_buffer); | |
1da177e4 | 865 | |
9a853f71 AV |
866 | CMD_ACTUAL_SNSLEN(cp) = sense_len; |
867 | sp->request_sense_length = sense_len; | |
1da177e4 LT |
868 | sp->request_sense_ptr = cp->sense_buffer; |
869 | ||
870 | if (sp->request_sense_length > 32) | |
9a853f71 | 871 | sense_len = 32; |
1da177e4 | 872 | |
9a853f71 | 873 | memcpy(cp->sense_buffer, sense_data, sense_len); |
1da177e4 | 874 | |
9a853f71 AV |
875 | sp->request_sense_ptr += sense_len; |
876 | sp->request_sense_length -= sense_len; | |
1da177e4 LT |
877 | if (sp->request_sense_length != 0) |
878 | ha->status_srb = sp; | |
879 | ||
1da177e4 | 880 | DEBUG5(printk("%s(): Check condition Sense data, " |
9a853f71 AV |
881 | "scsi(%ld:%d:%d:%d) cmd=%p pid=%ld\n", __func__, |
882 | ha->host_no, cp->device->channel, cp->device->id, | |
883 | cp->device->lun, cp, cp->serial_number)); | |
884 | if (sense_len) | |
1da177e4 LT |
885 | DEBUG5(qla2x00_dump_buffer(cp->sense_buffer, |
886 | CMD_ACTUAL_SNSLEN(cp))); | |
887 | break; | |
888 | ||
889 | case CS_DATA_UNDERRUN: | |
9a853f71 | 890 | resid = resid_len; |
ed17c71b RA |
891 | /* Use F/W calculated residual length. */ |
892 | if (IS_QLA24XX(ha) || IS_QLA54XX(ha)) | |
893 | resid = fw_resid_len; | |
894 | ||
1da177e4 LT |
895 | if (scsi_status & SS_RESIDUAL_UNDER) { |
896 | cp->resid = resid; | |
897 | CMD_RESID_LEN(cp) = resid; | |
e038a1be AV |
898 | } else { |
899 | DEBUG2(printk(KERN_INFO | |
900 | "scsi(%ld:%d:%d) UNDERRUN status detected " | |
ed17c71b RA |
901 | "0x%x-0x%x. resid=0x%x fw_resid=0x%x cdb=0x%x " |
902 | "os_underflow=0x%x\n", ha->host_no, | |
903 | cp->device->id, cp->device->lun, comp_status, | |
904 | scsi_status, resid_len, resid, cp->cmnd[0], | |
905 | cp->underflow)); | |
e038a1be | 906 | |
1da177e4 LT |
907 | } |
908 | ||
909 | /* | |
fa2a1ce5 | 910 | * Check to see if SCSI Status is non zero. If so report SCSI |
1da177e4 LT |
911 | * Status. |
912 | */ | |
913 | if (lscsi_status != 0) { | |
1da177e4 LT |
914 | cp->result = DID_OK << 16 | lscsi_status; |
915 | ||
916 | if (lscsi_status != SS_CHECK_CONDITION) | |
917 | break; | |
918 | ||
919 | /* Copy Sense Data into sense buffer */ | |
920 | memset(cp->sense_buffer, 0, sizeof(cp->sense_buffer)); | |
921 | ||
922 | if (!(scsi_status & SS_SENSE_LEN_VALID)) | |
923 | break; | |
924 | ||
9a853f71 AV |
925 | if (sense_len >= sizeof(cp->sense_buffer)) |
926 | sense_len = sizeof(cp->sense_buffer); | |
1da177e4 | 927 | |
9a853f71 AV |
928 | CMD_ACTUAL_SNSLEN(cp) = sense_len; |
929 | sp->request_sense_length = sense_len; | |
1da177e4 LT |
930 | sp->request_sense_ptr = cp->sense_buffer; |
931 | ||
fa2a1ce5 | 932 | if (sp->request_sense_length > 32) |
9a853f71 | 933 | sense_len = 32; |
1da177e4 | 934 | |
9a853f71 | 935 | memcpy(cp->sense_buffer, sense_data, sense_len); |
1da177e4 | 936 | |
9a853f71 AV |
937 | sp->request_sense_ptr += sense_len; |
938 | sp->request_sense_length -= sense_len; | |
1da177e4 LT |
939 | if (sp->request_sense_length != 0) |
940 | ha->status_srb = sp; | |
941 | ||
1da177e4 LT |
942 | DEBUG5(printk("%s(): Check condition Sense data, " |
943 | "scsi(%ld:%d:%d:%d) cmd=%p pid=%ld\n", | |
9a853f71 AV |
944 | __func__, ha->host_no, cp->device->channel, |
945 | cp->device->id, cp->device->lun, cp, | |
1da177e4 | 946 | cp->serial_number)); |
9a853f71 AV |
947 | |
948 | if (sense_len) | |
1da177e4 LT |
949 | DEBUG5(qla2x00_dump_buffer(cp->sense_buffer, |
950 | CMD_ACTUAL_SNSLEN(cp))); | |
951 | } else { | |
952 | /* | |
953 | * If RISC reports underrun and target does not report | |
954 | * it then we must have a lost frame, so tell upper | |
955 | * layer to retry it by reporting a bus busy. | |
956 | */ | |
957 | if (!(scsi_status & SS_RESIDUAL_UNDER)) { | |
958 | DEBUG2(printk("scsi(%ld:%d:%d:%d) Dropped " | |
959 | "frame(s) detected (%x of %x bytes)..." | |
9a853f71 AV |
960 | "retrying command.\n", ha->host_no, |
961 | cp->device->channel, cp->device->id, | |
962 | cp->device->lun, resid, | |
1da177e4 LT |
963 | cp->request_bufflen)); |
964 | ||
965 | cp->result = DID_BUS_BUSY << 16; | |
1da177e4 LT |
966 | break; |
967 | } | |
968 | ||
969 | /* Handle mid-layer underflow */ | |
970 | if ((unsigned)(cp->request_bufflen - resid) < | |
971 | cp->underflow) { | |
972 | qla_printk(KERN_INFO, ha, | |
973 | "scsi(%ld:%d:%d:%d): Mid-layer underflow " | |
974 | "detected (%x of %x bytes)...returning " | |
9a853f71 AV |
975 | "error status.\n", ha->host_no, |
976 | cp->device->channel, cp->device->id, | |
977 | cp->device->lun, resid, | |
1da177e4 LT |
978 | cp->request_bufflen); |
979 | ||
980 | cp->result = DID_ERROR << 16; | |
981 | break; | |
982 | } | |
983 | ||
984 | /* Everybody online, looking good... */ | |
985 | cp->result = DID_OK << 16; | |
986 | } | |
987 | break; | |
988 | ||
989 | case CS_DATA_OVERRUN: | |
990 | DEBUG2(printk(KERN_INFO | |
991 | "scsi(%ld:%d:%d): OVERRUN status detected 0x%x-0x%x\n", | |
9a853f71 AV |
992 | ha->host_no, cp->device->id, cp->device->lun, comp_status, |
993 | scsi_status)); | |
1da177e4 LT |
994 | DEBUG2(printk(KERN_INFO |
995 | "CDB: 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x\n", | |
996 | cp->cmnd[0], cp->cmnd[1], cp->cmnd[2], cp->cmnd[3], | |
997 | cp->cmnd[4], cp->cmnd[5])); | |
998 | DEBUG2(printk(KERN_INFO | |
999 | "PID=0x%lx req=0x%x xtra=0x%x -- returning DID_ERROR " | |
1000 | "status!\n", | |
9a853f71 | 1001 | cp->serial_number, cp->request_bufflen, resid_len)); |
1da177e4 LT |
1002 | |
1003 | cp->result = DID_ERROR << 16; | |
1004 | break; | |
1005 | ||
1006 | case CS_PORT_LOGGED_OUT: | |
1007 | case CS_PORT_CONFIG_CHG: | |
1008 | case CS_PORT_BUSY: | |
1009 | case CS_INCOMPLETE: | |
1010 | case CS_PORT_UNAVAILABLE: | |
1011 | /* | |
1012 | * If the port is in Target Down state, return all IOs for this | |
1013 | * Target with DID_NO_CONNECT ELSE Queue the IOs in the | |
1014 | * retry_queue. | |
1015 | */ | |
1da177e4 LT |
1016 | DEBUG2(printk("scsi(%ld:%d:%d): status_entry: Port Down " |
1017 | "pid=%ld, compl status=0x%x, port state=0x%x\n", | |
9a853f71 AV |
1018 | ha->host_no, cp->device->id, cp->device->lun, |
1019 | cp->serial_number, comp_status, | |
1da177e4 LT |
1020 | atomic_read(&fcport->state))); |
1021 | ||
f4f051eb | 1022 | cp->result = DID_BUS_BUSY << 16; |
1da177e4 | 1023 | if (atomic_read(&fcport->state) == FCS_ONLINE) { |
d97994dc | 1024 | qla2x00_mark_device_lost(ha, fcport, 1, 1); |
1da177e4 | 1025 | } |
1da177e4 LT |
1026 | break; |
1027 | ||
1028 | case CS_RESET: | |
1029 | DEBUG2(printk(KERN_INFO | |
1030 | "scsi(%ld): RESET status detected 0x%x-0x%x.\n", | |
1031 | ha->host_no, comp_status, scsi_status)); | |
1032 | ||
f4f051eb | 1033 | cp->result = DID_RESET << 16; |
1da177e4 LT |
1034 | break; |
1035 | ||
1036 | case CS_ABORTED: | |
fa2a1ce5 | 1037 | /* |
1da177e4 LT |
1038 | * hv2.19.12 - DID_ABORT does not retry the request if we |
1039 | * aborted this request then abort otherwise it must be a | |
1040 | * reset. | |
1041 | */ | |
1042 | DEBUG2(printk(KERN_INFO | |
1043 | "scsi(%ld): ABORT status detected 0x%x-0x%x.\n", | |
1044 | ha->host_no, comp_status, scsi_status)); | |
1045 | ||
1046 | cp->result = DID_RESET << 16; | |
1047 | break; | |
1048 | ||
1049 | case CS_TIMEOUT: | |
9a853f71 AV |
1050 | cp->result = DID_BUS_BUSY << 16; |
1051 | ||
044cc6c8 | 1052 | if (IS_QLA24XX(ha) || IS_QLA54XX(ha)) { |
9a853f71 AV |
1053 | DEBUG2(printk(KERN_INFO |
1054 | "scsi(%ld:%d:%d:%d): TIMEOUT status detected " | |
1055 | "0x%x-0x%x\n", ha->host_no, cp->device->channel, | |
1056 | cp->device->id, cp->device->lun, comp_status, | |
1057 | scsi_status)); | |
1058 | break; | |
1059 | } | |
1da177e4 LT |
1060 | DEBUG2(printk(KERN_INFO |
1061 | "scsi(%ld:%d:%d:%d): TIMEOUT status detected 0x%x-0x%x " | |
9a853f71 AV |
1062 | "sflags=%x.\n", ha->host_no, cp->device->channel, |
1063 | cp->device->id, cp->device->lun, comp_status, scsi_status, | |
1064 | le16_to_cpu(sts->status_flags))); | |
1da177e4 | 1065 | |
9a853f71 AV |
1066 | /* Check to see if logout occurred. */ |
1067 | if ((le16_to_cpu(sts->status_flags) & SF_LOGOUT_SENT)) | |
d97994dc | 1068 | qla2x00_mark_device_lost(ha, fcport, 1, 1); |
1da177e4 LT |
1069 | break; |
1070 | ||
1071 | case CS_QUEUE_FULL: | |
1072 | DEBUG2(printk(KERN_INFO | |
1073 | "scsi(%ld): QUEUE FULL status detected 0x%x-0x%x.\n", | |
1074 | ha->host_no, comp_status, scsi_status)); | |
1075 | ||
1076 | /* SCSI Mid-Layer handles device queue full */ | |
1077 | ||
fa2a1ce5 | 1078 | cp->result = DID_OK << 16 | lscsi_status; |
1da177e4 | 1079 | |
1da177e4 LT |
1080 | break; |
1081 | ||
1082 | default: | |
1083 | DEBUG3(printk("scsi(%ld): Error detected (unknown status) " | |
9a853f71 | 1084 | "0x%x-0x%x.\n", ha->host_no, comp_status, scsi_status)); |
1da177e4 LT |
1085 | qla_printk(KERN_INFO, ha, |
1086 | "Unknown status detected 0x%x-0x%x.\n", | |
1087 | comp_status, scsi_status); | |
1088 | ||
1089 | cp->result = DID_ERROR << 16; | |
1090 | break; | |
1091 | } | |
1092 | ||
1093 | /* Place command on done queue. */ | |
1094 | if (ha->status_srb == NULL) | |
f4f051eb | 1095 | qla2x00_sp_compl(ha, sp); |
1da177e4 LT |
1096 | } |
1097 | ||
1098 | /** | |
1099 | * qla2x00_status_cont_entry() - Process a Status Continuations entry. | |
1100 | * @ha: SCSI driver HA context | |
1101 | * @pkt: Entry pointer | |
1102 | * | |
1103 | * Extended sense data. | |
1104 | */ | |
1105 | static void | |
1106 | qla2x00_status_cont_entry(scsi_qla_host_t *ha, sts_cont_entry_t *pkt) | |
1107 | { | |
1108 | uint8_t sense_sz = 0; | |
1109 | srb_t *sp = ha->status_srb; | |
1110 | struct scsi_cmnd *cp; | |
1111 | ||
1112 | if (sp != NULL && sp->request_sense_length != 0) { | |
1113 | cp = sp->cmd; | |
1114 | if (cp == NULL) { | |
1115 | DEBUG2(printk("%s(): Cmd already returned back to OS " | |
75bc4190 | 1116 | "sp=%p.\n", __func__, sp)); |
1da177e4 LT |
1117 | qla_printk(KERN_INFO, ha, |
1118 | "cmd is NULL: already returned to OS (sp=%p)\n", | |
fa2a1ce5 | 1119 | sp); |
1da177e4 LT |
1120 | |
1121 | ha->status_srb = NULL; | |
1122 | return; | |
1123 | } | |
1124 | ||
1125 | if (sp->request_sense_length > sizeof(pkt->data)) { | |
1126 | sense_sz = sizeof(pkt->data); | |
1127 | } else { | |
1128 | sense_sz = sp->request_sense_length; | |
1129 | } | |
1130 | ||
1131 | /* Move sense data. */ | |
044cc6c8 | 1132 | if (IS_QLA24XX(ha) || IS_QLA54XX(ha)) |
9a853f71 | 1133 | host_to_fcp_swap(pkt->data, sizeof(pkt->data)); |
1da177e4 LT |
1134 | memcpy(sp->request_sense_ptr, pkt->data, sense_sz); |
1135 | DEBUG5(qla2x00_dump_buffer(sp->request_sense_ptr, sense_sz)); | |
1136 | ||
1137 | sp->request_sense_ptr += sense_sz; | |
1138 | sp->request_sense_length -= sense_sz; | |
1139 | ||
1140 | /* Place command on done queue. */ | |
1141 | if (sp->request_sense_length == 0) { | |
1da177e4 | 1142 | ha->status_srb = NULL; |
f4f051eb | 1143 | qla2x00_sp_compl(ha, sp); |
1da177e4 LT |
1144 | } |
1145 | } | |
1146 | } | |
1147 | ||
1148 | /** | |
1149 | * qla2x00_error_entry() - Process an error entry. | |
1150 | * @ha: SCSI driver HA context | |
1151 | * @pkt: Entry pointer | |
1152 | */ | |
1153 | static void | |
9a853f71 | 1154 | qla2x00_error_entry(scsi_qla_host_t *ha, sts_entry_t *pkt) |
1da177e4 LT |
1155 | { |
1156 | srb_t *sp; | |
1157 | ||
1158 | #if defined(QL_DEBUG_LEVEL_2) | |
1159 | if (pkt->entry_status & RF_INV_E_ORDER) | |
1160 | qla_printk(KERN_ERR, ha, "%s: Invalid Entry Order\n", __func__); | |
1161 | else if (pkt->entry_status & RF_INV_E_COUNT) | |
1162 | qla_printk(KERN_ERR, ha, "%s: Invalid Entry Count\n", __func__); | |
1163 | else if (pkt->entry_status & RF_INV_E_PARAM) | |
fa2a1ce5 | 1164 | qla_printk(KERN_ERR, ha, |
1da177e4 LT |
1165 | "%s: Invalid Entry Parameter\n", __func__); |
1166 | else if (pkt->entry_status & RF_INV_E_TYPE) | |
1167 | qla_printk(KERN_ERR, ha, "%s: Invalid Entry Type\n", __func__); | |
1168 | else if (pkt->entry_status & RF_BUSY) | |
1169 | qla_printk(KERN_ERR, ha, "%s: Busy\n", __func__); | |
1170 | else | |
1171 | qla_printk(KERN_ERR, ha, "%s: UNKNOWN flag error\n", __func__); | |
1172 | #endif | |
1173 | ||
1174 | /* Validate handle. */ | |
1175 | if (pkt->handle < MAX_OUTSTANDING_COMMANDS) | |
1176 | sp = ha->outstanding_cmds[pkt->handle]; | |
1177 | else | |
1178 | sp = NULL; | |
1179 | ||
1180 | if (sp) { | |
1181 | /* Free outstanding command slot. */ | |
1182 | ha->outstanding_cmds[pkt->handle] = NULL; | |
354d6b21 | 1183 | |
1da177e4 LT |
1184 | /* Bad payload or header */ |
1185 | if (pkt->entry_status & | |
1186 | (RF_INV_E_ORDER | RF_INV_E_COUNT | | |
1187 | RF_INV_E_PARAM | RF_INV_E_TYPE)) { | |
1188 | sp->cmd->result = DID_ERROR << 16; | |
1189 | } else if (pkt->entry_status & RF_BUSY) { | |
1190 | sp->cmd->result = DID_BUS_BUSY << 16; | |
1191 | } else { | |
1192 | sp->cmd->result = DID_ERROR << 16; | |
1193 | } | |
f4f051eb | 1194 | qla2x00_sp_compl(ha, sp); |
1da177e4 | 1195 | |
9a853f71 AV |
1196 | } else if (pkt->entry_type == COMMAND_A64_TYPE || pkt->entry_type == |
1197 | COMMAND_TYPE || pkt->entry_type == COMMAND_TYPE_7) { | |
1da177e4 LT |
1198 | DEBUG2(printk("scsi(%ld): Error entry - invalid handle\n", |
1199 | ha->host_no)); | |
1200 | qla_printk(KERN_WARNING, ha, | |
1201 | "Error entry - invalid handle\n"); | |
1202 | ||
1203 | set_bit(ISP_ABORT_NEEDED, &ha->dpc_flags); | |
39a11240 | 1204 | qla2xxx_wake_dpc(ha); |
1da177e4 LT |
1205 | } |
1206 | } | |
1207 | ||
1208 | /** | |
1209 | * qla2x00_ms_entry() - Process a Management Server entry. | |
1210 | * @ha: SCSI driver HA context | |
1211 | * @index: Response queue out pointer | |
1212 | */ | |
1213 | static void | |
9a853f71 | 1214 | qla2x00_ms_entry(scsi_qla_host_t *ha, ms_iocb_entry_t *pkt) |
1da177e4 LT |
1215 | { |
1216 | srb_t *sp; | |
1217 | ||
1218 | DEBUG3(printk("%s(%ld): pkt=%p pkthandle=%d.\n", | |
1219 | __func__, ha->host_no, pkt, pkt->handle1)); | |
1220 | ||
1221 | /* Validate handle. */ | |
1222 | if (pkt->handle1 < MAX_OUTSTANDING_COMMANDS) | |
1223 | sp = ha->outstanding_cmds[pkt->handle1]; | |
1224 | else | |
1225 | sp = NULL; | |
1226 | ||
1227 | if (sp == NULL) { | |
1228 | DEBUG2(printk("scsi(%ld): MS entry - invalid handle\n", | |
1229 | ha->host_no)); | |
1230 | qla_printk(KERN_WARNING, ha, "MS entry - invalid handle\n"); | |
1231 | ||
1232 | set_bit(ISP_ABORT_NEEDED, &ha->dpc_flags); | |
1233 | return; | |
1234 | } | |
1235 | ||
1236 | CMD_COMPL_STATUS(sp->cmd) = le16_to_cpu(pkt->status); | |
1237 | CMD_ENTRY_STATUS(sp->cmd) = pkt->entry_status; | |
1238 | ||
1239 | /* Free outstanding command slot. */ | |
1240 | ha->outstanding_cmds[pkt->handle1] = NULL; | |
1241 | ||
f4f051eb | 1242 | qla2x00_sp_compl(ha, sp); |
1da177e4 | 1243 | } |
9a853f71 AV |
1244 | |
1245 | ||
1246 | /** | |
1247 | * qla24xx_mbx_completion() - Process mailbox command completions. | |
1248 | * @ha: SCSI driver HA context | |
1249 | * @mb0: Mailbox0 register | |
1250 | */ | |
1251 | static void | |
1252 | qla24xx_mbx_completion(scsi_qla_host_t *ha, uint16_t mb0) | |
1253 | { | |
1254 | uint16_t cnt; | |
1255 | uint16_t __iomem *wptr; | |
1256 | struct device_reg_24xx __iomem *reg = &ha->iobase->isp24; | |
1257 | ||
1258 | /* Load return mailbox registers. */ | |
1259 | ha->flags.mbox_int = 1; | |
1260 | ha->mailbox_out[0] = mb0; | |
1261 | wptr = (uint16_t __iomem *)®->mailbox1; | |
1262 | ||
1263 | for (cnt = 1; cnt < ha->mbx_count; cnt++) { | |
1264 | ha->mailbox_out[cnt] = RD_REG_WORD(wptr); | |
1265 | wptr++; | |
1266 | } | |
1267 | ||
1268 | if (ha->mcp) { | |
1269 | DEBUG3(printk("%s(%ld): Got mailbox completion. cmd=%x.\n", | |
1270 | __func__, ha->host_no, ha->mcp->mb[0])); | |
1271 | } else { | |
1272 | DEBUG2_3(printk("%s(%ld): MBX pointer ERROR!\n", | |
1273 | __func__, ha->host_no)); | |
1274 | } | |
1275 | } | |
1276 | ||
1277 | /** | |
1278 | * qla24xx_process_response_queue() - Process response queue entries. | |
1279 | * @ha: SCSI driver HA context | |
1280 | */ | |
1281 | void | |
1282 | qla24xx_process_response_queue(struct scsi_qla_host *ha) | |
1283 | { | |
1284 | struct device_reg_24xx __iomem *reg = &ha->iobase->isp24; | |
1285 | struct sts_entry_24xx *pkt; | |
1286 | ||
1287 | if (!ha->flags.online) | |
1288 | return; | |
1289 | ||
1290 | while (ha->response_ring_ptr->signature != RESPONSE_PROCESSED) { | |
1291 | pkt = (struct sts_entry_24xx *)ha->response_ring_ptr; | |
1292 | ||
1293 | ha->rsp_ring_index++; | |
1294 | if (ha->rsp_ring_index == ha->response_q_length) { | |
1295 | ha->rsp_ring_index = 0; | |
1296 | ha->response_ring_ptr = ha->response_ring; | |
1297 | } else { | |
1298 | ha->response_ring_ptr++; | |
1299 | } | |
1300 | ||
1301 | if (pkt->entry_status != 0) { | |
1302 | DEBUG3(printk(KERN_INFO | |
1303 | "scsi(%ld): Process error entry.\n", ha->host_no)); | |
1304 | ||
9a853f71 AV |
1305 | qla2x00_error_entry(ha, (sts_entry_t *) pkt); |
1306 | ((response_t *)pkt)->signature = RESPONSE_PROCESSED; | |
1307 | wmb(); | |
1308 | continue; | |
1309 | } | |
1310 | ||
1311 | switch (pkt->entry_type) { | |
1312 | case STATUS_TYPE: | |
1313 | qla2x00_status_entry(ha, pkt); | |
1314 | break; | |
1315 | case STATUS_CONT_TYPE: | |
1316 | qla2x00_status_cont_entry(ha, (sts_cont_entry_t *)pkt); | |
1317 | break; | |
1318 | case MS_IOCB_TYPE: | |
1319 | qla24xx_ms_entry(ha, (struct ct_entry_24xx *)pkt); | |
1320 | break; | |
1321 | default: | |
1322 | /* Type Not Supported. */ | |
1323 | DEBUG4(printk(KERN_WARNING | |
1324 | "scsi(%ld): Received unknown response pkt type %x " | |
1325 | "entry status=%x.\n", | |
1326 | ha->host_no, pkt->entry_type, pkt->entry_status)); | |
1327 | break; | |
1328 | } | |
1329 | ((response_t *)pkt)->signature = RESPONSE_PROCESSED; | |
1330 | wmb(); | |
1331 | } | |
1332 | ||
1333 | /* Adjust ring index */ | |
1334 | WRT_REG_DWORD(®->rsp_q_out, ha->rsp_ring_index); | |
1335 | } | |
1336 | ||
1337 | /** | |
1338 | * qla24xx_intr_handler() - Process interrupts for the ISP23xx and ISP63xx. | |
1339 | * @irq: | |
1340 | * @dev_id: SCSI driver HA context | |
1341 | * @regs: | |
1342 | * | |
1343 | * Called by system whenever the host adapter generates an interrupt. | |
1344 | * | |
1345 | * Returns handled flag. | |
1346 | */ | |
1347 | irqreturn_t | |
1348 | qla24xx_intr_handler(int irq, void *dev_id, struct pt_regs *regs) | |
1349 | { | |
1350 | scsi_qla_host_t *ha; | |
1351 | struct device_reg_24xx __iomem *reg; | |
1352 | int status; | |
1353 | unsigned long flags; | |
1354 | unsigned long iter; | |
1355 | uint32_t stat; | |
1356 | uint32_t hccr; | |
1357 | uint16_t mb[4]; | |
1358 | ||
1359 | ha = (scsi_qla_host_t *) dev_id; | |
1360 | if (!ha) { | |
1361 | printk(KERN_INFO | |
1362 | "%s(): NULL host pointer\n", __func__); | |
1363 | return IRQ_NONE; | |
1364 | } | |
1365 | ||
1366 | reg = &ha->iobase->isp24; | |
1367 | status = 0; | |
1368 | ||
1369 | spin_lock_irqsave(&ha->hardware_lock, flags); | |
1370 | for (iter = 50; iter--; ) { | |
1371 | stat = RD_REG_DWORD(®->host_status); | |
1372 | if (stat & HSRX_RISC_PAUSED) { | |
1373 | hccr = RD_REG_DWORD(®->hccr); | |
1374 | ||
1375 | qla_printk(KERN_INFO, ha, "RISC paused -- HCCR=%x, " | |
1376 | "Dumping firmware!\n", hccr); | |
1377 | qla24xx_fw_dump(ha, 1); | |
1378 | ||
1379 | set_bit(ISP_ABORT_NEEDED, &ha->dpc_flags); | |
1380 | break; | |
1381 | } else if ((stat & HSRX_RISC_INT) == 0) | |
1382 | break; | |
1383 | ||
1384 | switch (stat & 0xff) { | |
1385 | case 0x1: | |
1386 | case 0x2: | |
1387 | case 0x10: | |
1388 | case 0x11: | |
1389 | qla24xx_mbx_completion(ha, MSW(stat)); | |
1390 | status |= MBX_INTERRUPT; | |
1391 | ||
1392 | break; | |
1393 | case 0x12: | |
1394 | mb[0] = MSW(stat); | |
1395 | mb[1] = RD_REG_WORD(®->mailbox1); | |
1396 | mb[2] = RD_REG_WORD(®->mailbox2); | |
1397 | mb[3] = RD_REG_WORD(®->mailbox3); | |
1398 | qla2x00_async_event(ha, mb); | |
1399 | break; | |
1400 | case 0x13: | |
1401 | qla24xx_process_response_queue(ha); | |
1402 | break; | |
1403 | default: | |
1404 | DEBUG2(printk("scsi(%ld): Unrecognized interrupt type " | |
1405 | "(%d).\n", | |
1406 | ha->host_no, stat & 0xff)); | |
1407 | break; | |
1408 | } | |
1409 | WRT_REG_DWORD(®->hccr, HCCRX_CLR_RISC_INT); | |
1410 | RD_REG_DWORD_RELAXED(®->hccr); | |
1411 | } | |
1412 | spin_unlock_irqrestore(&ha->hardware_lock, flags); | |
1413 | ||
1414 | if (test_bit(MBX_INTR_WAIT, &ha->mbx_cmd_flags) && | |
1415 | (status & MBX_INTERRUPT) && ha->flags.mbox_int) { | |
1416 | spin_lock_irqsave(&ha->mbx_reg_lock, flags); | |
1417 | ||
1418 | set_bit(MBX_INTERRUPT, &ha->mbx_cmd_flags); | |
1419 | up(&ha->mbx_intr_sem); | |
1420 | ||
1421 | spin_unlock_irqrestore(&ha->mbx_reg_lock, flags); | |
1422 | } | |
1423 | ||
1424 | return IRQ_HANDLED; | |
1425 | } | |
1426 | ||
1427 | /** | |
1428 | * qla24xx_ms_entry() - Process a Management Server entry. | |
1429 | * @ha: SCSI driver HA context | |
1430 | * @index: Response queue out pointer | |
1431 | */ | |
1432 | static void | |
1433 | qla24xx_ms_entry(scsi_qla_host_t *ha, struct ct_entry_24xx *pkt) | |
1434 | { | |
1435 | srb_t *sp; | |
1436 | ||
1437 | DEBUG3(printk("%s(%ld): pkt=%p pkthandle=%d.\n", | |
1438 | __func__, ha->host_no, pkt, pkt->handle)); | |
1439 | ||
744f11fd AV |
1440 | DEBUG9(printk("%s: ct pkt dump:\n", __func__)); |
1441 | DEBUG9(qla2x00_dump_buffer((void *)pkt, sizeof(struct ct_entry_24xx))); | |
9a853f71 AV |
1442 | |
1443 | /* Validate handle. */ | |
1444 | if (pkt->handle < MAX_OUTSTANDING_COMMANDS) | |
1445 | sp = ha->outstanding_cmds[pkt->handle]; | |
1446 | else | |
1447 | sp = NULL; | |
1448 | ||
1449 | if (sp == NULL) { | |
1450 | DEBUG2(printk("scsi(%ld): MS entry - invalid handle\n", | |
1451 | ha->host_no)); | |
1452 | DEBUG10(printk("scsi(%ld): MS entry - invalid handle\n", | |
1453 | ha->host_no)); | |
1454 | qla_printk(KERN_WARNING, ha, "MS entry - invalid handle %d\n", | |
1455 | pkt->handle); | |
1456 | ||
1457 | set_bit(ISP_ABORT_NEEDED, &ha->dpc_flags); | |
1458 | return; | |
1459 | } | |
1460 | ||
1461 | CMD_COMPL_STATUS(sp->cmd) = le16_to_cpu(pkt->comp_status); | |
1462 | CMD_ENTRY_STATUS(sp->cmd) = pkt->entry_status; | |
1463 | ||
1464 | /* Free outstanding command slot. */ | |
1465 | ha->outstanding_cmds[pkt->handle] = NULL; | |
1466 | ||
1467 | qla2x00_sp_compl(ha, sp); | |
1468 | } | |
1469 |