]> git.ipfire.org Git - ipfire-2.x.git/blame - src/patches/suse-2.6.27.39/patches.drivers/qla4xxx-5.01.00-k8_sles11-03-update
Fix oinkmaster patch.
[ipfire-2.x.git] / src / patches / suse-2.6.27.39 / patches.drivers / qla4xxx-5.01.00-k8_sles11-03-update
CommitLineData
2cb7cef9
BS
1From: David Somayajulu <david.somayajulu@qlogic.com>
2Subject: Update qla4xxx to 5.01.00-k8_sles11-03
3References: bnc#444884
4
5This patch updates the qla4xxx driver to 5.01.00-k8_sles11-03.
6
7
8Signed-off-by: David Somayajulu <david.somayajulu@qlogic.com>
9Signed-off-by: Hannes Reinecke <hare@suse.de>
10
11---
12 drivers/scsi/qla4xxx/ql4_dbg.c | 36 --
13 drivers/scsi/qla4xxx/ql4_dbg.h | 59 ++--
14 drivers/scsi/qla4xxx/ql4_def.h | 11
15 drivers/scsi/qla4xxx/ql4_glbl.h | 10
82094b55 16 drivers/scsi/qla4xxx/ql4_init.c | 166 +++++++-----
2cb7cef9 17 drivers/scsi/qla4xxx/ql4_inline.h | 143 ++++++++++
82094b55
AF
18 drivers/scsi/qla4xxx/ql4_iocb.c | 161 +-----------
19 drivers/scsi/qla4xxx/ql4_isr.c | 31 +-
20 drivers/scsi/qla4xxx/ql4_mbx.c | 7
21 drivers/scsi/qla4xxx/ql4_os.c | 495 ++++++++++++++++++++-----------------
2cb7cef9
BS
22 drivers/scsi/qla4xxx/ql4_os.h | 125 +++++++++
23 drivers/scsi/qla4xxx/ql4_version.h | 3
82094b55 24 12 files changed, 727 insertions(+), 520 deletions(-)
2cb7cef9
BS
25
26--- a/drivers/scsi/qla4xxx/ql4_dbg.c
27+++ b/drivers/scsi/qla4xxx/ql4_dbg.c
28@@ -13,28 +13,6 @@
29
30 #include <scsi/scsi_dbg.h>
31
32-static void qla4xxx_print_srb_info(struct srb * srb)
33-{
34- printk("%s: srb = 0x%p, flags=0x%02x\n", __func__, srb, srb->flags);
35- printk("%s: cmd = 0x%p, saved_dma_handle = 0x%lx\n",
36- __func__, srb->cmd, (unsigned long) srb->dma_handle);
37- printk("%s: fw_ddb_index = %d, lun = %d\n",
38- __func__, srb->fw_ddb_index, srb->cmd->device->lun);
39- printk("%s: iocb_tov = %d\n",
40- __func__, srb->iocb_tov);
41- printk("%s: cc_stat = 0x%x\n", __func__, srb->cc_stat);
42-}
43-
44-void qla4xxx_print_scsi_cmd(struct scsi_cmnd *cmd)
45-{
46- printk("SCSI Command = 0x%p, Handle=0x%p\n", cmd, cmd->host_scribble);
47- printk(" b=%d, t=%02xh, l=%02xh, cmd_len = %02xh\n",
48- cmd->device->channel, cmd->device->id, cmd->device->lun,
49- cmd->cmd_len);
50- scsi_print_command(cmd);
51- qla4xxx_print_srb_info((struct srb *) cmd->SCp.ptr);
52-}
53-
54 void __dump_registers(struct scsi_qla_host *ha)
55 {
56 uint8_t i;
57@@ -143,17 +121,6 @@ void __dump_registers(struct scsi_qla_ho
58 }
59 }
60
61-void qla4xxx_dump_mbox_registers(struct scsi_qla_host *ha)
62-{
63- unsigned long flags = 0;
64- int i = 0;
65- spin_lock_irqsave(&ha->hardware_lock, flags);
66- for (i = 1; i < MBOX_REG_COUNT; i++)
67- printk(KERN_INFO " Mailbox[%d] = %08x\n", i,
68- readw(&ha->reg->mailbox[i]));
69- spin_unlock_irqrestore(&ha->hardware_lock, flags);
70-}
71-
72 void qla4xxx_dump_registers(struct scsi_qla_host *ha)
73 {
74 unsigned long flags = 0;
75@@ -179,6 +146,5 @@ void qla4xxx_dump_buffer(void *b, uint32
76 else
77 printk(KERN_DEBUG " ");
78 }
79- if (cnt % 16)
80- printk(KERN_DEBUG "\n");
81+ printk(KERN_DEBUG "\n");
82 }
83--- a/drivers/scsi/qla4xxx/ql4_dbg.h
84+++ b/drivers/scsi/qla4xxx/ql4_dbg.h
85@@ -14,49 +14,44 @@
86 /* #define QL_DEBUG_LEVEL_5 */
87 /* #define QL_DEBUG_LEVEL_6 */
88 /* #define QL_DEBUG_LEVEL_9 */
89+#ifndef _QL4_DBG_
90+#define _QL4_DBG_
91
92 #define QL_DEBUG_LEVEL_2 /* ALways enable error messagess */
93 #if defined(QL_DEBUG)
94-#define DEBUG(x) do {x;} while (0);
95+#define DEBUG(x) do {if(extended_error_logging & 0x01) x;} while (0);
96 #else
97-#define DEBUG(x) do {} while (0);
98+#define DEBUG(x)
99 #endif
100
101 #if defined(QL_DEBUG_LEVEL_2)
102-#define DEBUG2(x) do {if(extended_error_logging == 2) x;} while (0);
103-#define DEBUG2_3(x) do {x;} while (0);
104-#else /* */
105-#define DEBUG2(x) do {} while (0);
106-#endif /* */
107+#define DEBUG2(x) do {if(extended_error_logging & 0x02) x;} while (0);
108+#else
109+#define DEBUG2(x)
110+#endif
111
112 #if defined(QL_DEBUG_LEVEL_3)
113-#define DEBUG3(x) do {if(extended_error_logging == 3) x;} while (0);
114-#else /* */
115-#define DEBUG3(x) do {} while (0);
116-#if !defined(QL_DEBUG_LEVEL_2)
117-#define DEBUG2_3(x) do {} while (0);
118-#endif /* */
119-#endif /* */
120+#define DEBUG3(x) do {if(extended_error_logging & 0x04) x;} while (0);
121+#else
122+#define DEBUG3(x)
123+#endif
124+
125 #if defined(QL_DEBUG_LEVEL_4)
126-#define DEBUG4(x) do {x;} while (0);
127-#else /* */
128-#define DEBUG4(x) do {} while (0);
129-#endif /* */
130+#define DEBUG4(x) do {if(extended_error_logging & 0x08) x;} while (0);
131+#else
132+#define DEBUG4(x)
133+#endif
134
135 #if defined(QL_DEBUG_LEVEL_5)
136-#define DEBUG5(x) do {x;} while (0);
137-#else /* */
138-#define DEBUG5(x) do {} while (0);
139-#endif /* */
140+#define DEBUG5(x) do {if(extended_error_logging & 0x10) x;} while (0);
141+#else
142+#define DEBUG5(x)
143+#endif
144
145 #if defined(QL_DEBUG_LEVEL_6)
146-#define DEBUG6(x) do {x;} while (0);
147-#else /* */
148-#define DEBUG6(x) do {} while (0);
149-#endif /* */
150-
151-#if defined(QL_DEBUG_LEVEL_9)
152-#define DEBUG9(x) do {x;} while (0);
153-#else /* */
154-#define DEBUG9(x) do {} while (0);
155-#endif /* */
156+#define DEBUG6(x) do {if(extended_error_logging & 0x20) x;} while (0);
157+#else
158+#define DEBUG6(x)
159+#endif
160+
161+#endif /*_QL4_DBG_*/
162--- a/drivers/scsi/qla4xxx/ql4_def.h
163+++ b/drivers/scsi/qla4xxx/ql4_def.h
164@@ -144,7 +144,6 @@
165 #define RESET_FIRMWARE_TOV 30
166 #define LOGOUT_TOV 10
167 #define IOCB_TOV_MARGIN 10
168-#define RELOGIN_TOV 18
169 #define ISNS_DEREG_TOV 5
170
171 #define MAX_RESET_HA_RETRIES 2
172@@ -252,6 +251,8 @@ struct ddb_entry {
173 #define DF_NO_RELOGIN 1 /* Do not relogin if IOCTL
174 * logged it out */
175 #define DF_SCAN_ISSUED 2
176+#define DF_OFFLINE 3 /* Offline Device */
177+#define DF_DELETED 4 /* Device has been removed */
178
179 /*
180 * Asynchronous Event Queue structure
181@@ -286,7 +287,6 @@ struct scsi_qla_host {
182 uint32_t tot_ddbs;
183 unsigned long flags;
184
185-#define AF_ISNS_CMD_DONE 13 /* 0x00002000 */
186 #define AF_ONLINE 0 /* 0x00000001 */
187 #define AF_INIT_DONE 1 /* 0x00000002 */
188 #define AF_MBOX_COMMAND 2 /* 0x00000004 */
189@@ -294,9 +294,9 @@ struct scsi_qla_host {
190 #define AF_INTERRUPTS_ON 6 /* 0x00000040 Not Used */
191 #define AF_GET_CRASH_RECORD 7 /* 0x00000080 */
192 #define AF_LINK_UP 8 /* 0x00000100 */
193-#define AF_TOPCAT_CHIP_PRESENT 9 /* 0x00000200 */
194 #define AF_IRQ_ATTACHED 10 /* 0x00000400 */
195 #define AF_DISABLE_ACB_COMPLETE 11 /* 0x00000800 */
196+#define AF_OS_INDEX_VALID 12 /* 0x00001000 */
197
198 unsigned long dpc_flags;
199
200@@ -308,6 +308,8 @@ struct scsi_qla_host {
201 #define DPC_ISNS_RESTART 7 /* 0x00000080 */
202 #define DPC_AEN 9 /* 0x00000200 */
203 #define DPC_GET_DHCP_IP_ADDR 15 /* 0x00008000 */
204+#define DPC_OFFLINE_DEVICE 16 /* 0x00010000 */
205+#define DPC_DELETE_DEVICE 17 /* 0x00020000 */
206
207 uint16_t iocb_cnt;
208 uint16_t iocb_hiwat;
209@@ -460,7 +462,7 @@ struct scsi_qla_host {
210 void (*ql4getaenlog)(struct scsi_qla_host *ha, struct ql4_aen_log *aenl);
211 #define QL_INDICES_PER_ENTRY 32
212 #define QL_OSINDEX_ENTRIES (MAX_DDB_ENTRIES/QL_INDICES_PER_ENTRY)
213- volatile uint32_t os_map[QL_OSINDEX_ENTRIES];
214+ volatile unsigned long os_map[QL_OSINDEX_ENTRIES];
215 };
216
217 static inline int is_qla4010(struct scsi_qla_host *ha)
218@@ -468,6 +470,7 @@ static inline int is_qla4010(struct scsi
219 return ha->pdev->device == PCI_DEVICE_ID_QLOGIC_ISP4010;
220 }
221
222+
223 static inline int is_qla4022(struct scsi_qla_host *ha)
224 {
225 return ha->pdev->device == PCI_DEVICE_ID_QLOGIC_ISP4022;
226--- a/drivers/scsi/qla4xxx/ql4_glbl.h
227+++ b/drivers/scsi/qla4xxx/ql4_glbl.h
228@@ -10,7 +10,7 @@
229
230 struct iscsi_cls_conn;
231
232-void qla4xxx_hw_reset(struct scsi_qla_host *ha);
233+void qla4xxx_hw_reset(struct scsi_qla_host *ha, int hw_lock);
234 int ql4xxx_lock_drvr_wait(struct scsi_qla_host *a);
235 int qla4xxx_conn_start(struct iscsi_cls_conn *conn);
236 int qla4xxx_send_tgts(struct scsi_qla_host *ha, char *ip, uint16_t port);
237@@ -18,9 +18,9 @@ int qla4xxx_send_command_to_isp(struct s
238 int qla4xxx_initialize_adapter(struct scsi_qla_host * ha,
239 uint8_t renew_ddb_list);
240 int qla4xxx_soft_reset(struct scsi_qla_host *ha);
241-irqreturn_t qla4xxx_intr_handler(int irq, void *dev_id);
242
243 void qla4xxx_free_ddb_list(struct scsi_qla_host * ha);
244+void qla4xxx_free_ddb(struct scsi_qla_host *, struct ddb_entry *);
245 void qla4xxx_process_aen(struct scsi_qla_host * ha, uint8_t process_aen);
246
247 int qla4xxx_get_dhcp_ip_address(struct scsi_qla_host * ha);
248@@ -47,6 +47,8 @@ int qla4xxx_get_fwddb_entry(struct scsi_
249 uint16_t *tcp_source_port_num,
250 uint16_t *connection_id);
251
252+struct ddb_entry * qla4xxx_alloc_ddb(struct scsi_qla_host * ha,
253+ uint32_t fw_ddb_index);
254 int qla4xxx_set_ddb_entry(struct scsi_qla_host * ha, uint16_t fw_ddb_index,
255 dma_addr_t fw_ddb_entry_dma);
256
257@@ -77,10 +79,6 @@ int qla4xxx_process_ddb_changed(struct s
258
259 int qla4xxx_mailbox_command(struct scsi_qla_host *ha, uint8_t inCount,
260 uint8_t outCount, uint32_t *mbx_cmd, uint32_t *mbx_sts);
261-int qla4xxx_send_marker_iocb(struct scsi_qla_host *ha,
262- struct ddb_entry *ddb_entry, int lun);
263-
264-
265
266 extern int extended_error_logging;
267 extern int ql4xdiscoverywait;
268--- a/drivers/scsi/qla4xxx/ql4_init.c
269+++ b/drivers/scsi/qla4xxx/ql4_init.c
270@@ -10,6 +10,7 @@
271 #include "ql4_glbl.h"
272 #include "ql4_dbg.h"
273 #include "ql4_inline.h"
274+#include "ql4_os.h"
275
276 /* link auto negotiation normally takes roughly 2s. */
277 /* If we don't have link in 3 times that period quit. */
278@@ -19,9 +20,6 @@
279 * QLogic ISP4xxx Hardware Support Function Prototypes.
280 */
281
282-static struct ddb_entry * qla4xxx_alloc_ddb(struct scsi_qla_host *ha,
283- uint32_t fw_ddb_index);
284-
285 static void ql4xxx_set_mac_number(struct scsi_qla_host *ha)
286 {
287 uint32_t value;
82094b55 288@@ -59,8 +57,7 @@ static void ql4xxx_set_mac_number(struct
2cb7cef9
BS
289 * This routine deallocates and unlinks the specified ddb_entry from the
290 * adapter's
291 **/
292-static void qla4xxx_free_ddb(struct scsi_qla_host *ha,
293- struct ddb_entry *ddb_entry)
294+void qla4xxx_free_ddb(struct scsi_qla_host *ha, struct ddb_entry *ddb_entry)
295 {
296 /* Remove device entry from list */
297 list_del_init(&ddb_entry->list);
298@@ -359,8 +356,8 @@ static void qla4xxx_fill_ddb(struct ddb_
299 * This routine allocates a ddb_entry, ititializes some values, and
300 * inserts it into the ddb list.
301 **/
302-static struct ddb_entry * qla4xxx_alloc_ddb(struct scsi_qla_host *ha,
303- uint32_t fw_ddb_index)
304+struct ddb_entry * qla4xxx_alloc_ddb(struct scsi_qla_host *ha,
305+ uint32_t fw_ddb_index)
306 {
307 struct ddb_entry *ddb_entry;
308
309@@ -478,7 +475,7 @@ static int qla4xxx_build_ddb_list(struct
310 (strlen(fw_ddb_entry->iscsi_name) != 0)){
311 ddb_entry = qla4xxx_alloc_ddb(ha, fw_ddb_index);
312 if (ddb_entry == NULL) {
313- DEBUG2(dev_info(&ha->pdev->dev,"%s alloc_ddb %d "
314+ DEBUG2(dev_info(&ha->pdev->dev,"%s alloc_ddb %d"
315 "failed\n", __func__, fw_ddb_index));
316 goto exit_ddb_list;
317 }
2cb7cef9
BS
318@@ -695,6 +692,8 @@ static int qla4xxx_initialize_ddb_list(s
319
320 qla4xxx_flush_AENS(ha);
321
322+ /* Wait for an AEN */
323+ qla4xxx_devices_ready(ha);
324
325 /*
326 * First perform device discovery for active
327@@ -704,9 +703,6 @@ static int qla4xxx_initialize_ddb_list(s
328 if ((status = qla4xxx_build_ddb_list(ha)) == QLA_ERROR)
329 return status;
330
331- /* Wait for an AEN */
332- qla4xxx_devices_ready(ha);
333-
334 /*
335 * Targets can come online after the inital discovery, so processing
336 * the aens here will catch them.
337@@ -747,13 +743,15 @@ int qla4xxx_reinitialize_ddb_list(struct
338
339 qla4xxx_fill_ddb(ddb_entry, fw_ddb_entry);
340
341- if (ddb_entry->fw_ddb_device_state == DDB_DS_SESSION_ACTIVE) {
342+ if (ddb_entry->fw_ddb_device_state ==
343+ DDB_DS_SESSION_ACTIVE) {
344 atomic_set(&ddb_entry->state, DDB_STATE_ONLINE);
345 dev_info(&ha->pdev->dev,
346- "scsi%ld: %s: ddb[%d] os[%d] marked ONLINE\n",
347- ha->host_no, __func__, ddb_entry->fw_ddb_index,
348+ "%s: ddb[%d] os[%d] marked ONLINE\n",
349+ __func__, ddb_entry->fw_ddb_index,
350 ddb_entry->os_target_id);
351- } else if (atomic_read(&ddb_entry->state) == DDB_STATE_ONLINE)
352+ } else if (atomic_read(&ddb_entry->state) ==
353+ DDB_STATE_ONLINE)
354 qla4xxx_mark_device_missing(ha, ddb_entry);
355 }
356 }
357@@ -884,8 +882,8 @@ static int qla4xxx_start_firmware_from_f
358 writel(set_rmask(NVR_WRITE_ENABLE),
359 &ha->reg->u1.isp4022.nvram);
360
361- writel(2, &ha->reg->mailbox[6]);
362- readl(&ha->reg->mailbox[6]);
363+ writel(2, &ha->reg->mailbox[6]);
364+ readl(&ha->reg->mailbox[6]);
365
366 writel(set_rmask(CSR_BOOT_ENABLE), &ha->reg->ctrl_status);
367 readl(&ha->reg->ctrl_status);
368@@ -1054,7 +1052,7 @@ static int qla4xxx_start_firmware(struct
369 }
370 config_chip = 1;
371
372- /* Reset clears the semaphore, so acquire again */
373+ /* Reset clears the semaphore, so aquire again */
374 if (ql4xxx_lock_drvr_wait(ha) != QLA_SUCCESS)
375 return QLA_ERROR;
376 }
2cb7cef9
BS
377@@ -1119,12 +1117,12 @@ int qla4xxx_initialize_adapter(struct sc
378 * followed by 0x8014 aen" to trigger the tgt discovery process.
379 */
380 if (ha->firmware_state & FW_STATE_DHCP_IN_PROGRESS)
381- goto exit_init_online;
382+ goto exit_init_hba0;
383
384 /* Skip device discovery if ip and subnet is zero */
385 if (memcmp(ha->ip_address, ip_address, IP_ADDR_LEN) == 0 ||
386 memcmp(ha->subnet_mask, ip_address, IP_ADDR_LEN) == 0)
387- goto exit_init_online;
388+ goto exit_init_hba0;
389
390 if (renew_ddb_list == PRESERVE_DDB_LIST) {
391 /*
392@@ -1153,8 +1151,10 @@ int qla4xxx_initialize_adapter(struct sc
393 ha->host_no));
394 }
395
396-exit_init_online:
397+exit_init_hba0:
398 set_bit(AF_ONLINE, &ha->flags);
399+ dev_info(&ha->pdev->dev, "%s: adapter ONLINE\n", __func__);
400+
401 exit_init_hba:
402 return status;
403 }
404@@ -1204,40 +1204,63 @@ static void qla4xxx_add_device_dynamical
405 }
406 }
407
408- if (!found)
82094b55
AF
409+ if (!found) {
410 ddb_entry = qla4xxx_alloc_ddb(ha, fw_ddb_index);
2cb7cef9
BS
411- else if (ddb_entry->fw_ddb_index != fw_ddb_index) {
412- /* Target has been bound to a new fw_ddb_index */
413- qla4xxx_free_ddb(ha, ddb_entry);
82094b55 414- ddb_entry = qla4xxx_alloc_ddb(ha, fw_ddb_index);
2cb7cef9
BS
415- }
416
417- if (ddb_entry == NULL) {
418- DEBUG2(dev_info(&ha->pdev->dev, "%s NULL DDB %d\n",
419- __func__, fw_ddb_index));
420- goto exit_dyn_add;
421- }
422+ if (ddb_entry == NULL) {
423+ DEBUG2(dev_info(&ha->pdev->dev, "%s NULL DDB %d\n",
424+ __func__, fw_ddb_index));
425+ goto exit_dyn_add;
426+ }
427
428- ddb_entry->fw_ddb_index = fw_ddb_index;
429- ha->fw_ddb_index_map[fw_ddb_index] = ddb_entry;
430- ddb_entry->tcp_source_port_num = src_port;
431- ddb_entry->connection_id = conn_id;
432- qla4xxx_fill_ddb(ddb_entry, fw_ddb_entry);
433- ddb_entry->fw_ddb_device_state = ddb_state;
434+ ddb_entry->fw_ddb_index = fw_ddb_index;
435+ ha->fw_ddb_index_map[fw_ddb_index] = ddb_entry;
436+ ddb_entry->tcp_source_port_num = src_port;
437+ ddb_entry->connection_id = conn_id;
438+ qla4xxx_fill_ddb(ddb_entry, fw_ddb_entry);
439+ ddb_entry->fw_ddb_device_state = ddb_state;
440+
441+ if (probe)
442+ goto exit_dyn_add;
443
444- if (!probe) {
445 if (qla4xxx_add_sess(ddb_entry, 1)) {
446- DEBUG2(printk(KERN_WARNING
447- "scsi%ld: failed to add new device at index "
448- "[%d]\n Unable to add connection and session\n",
449- ha->host_no, fw_ddb_index));
450+ DEBUG2(dev_info(&ha->pdev->dev,
451+ "%s: failed to add new ddb %d\n",
452+ __func__, fw_ddb_index));
453 qla4xxx_free_ddb(ha, ddb_entry);
454+ } else {
455+ DEBUG6(dev_info(&ha->pdev->dev,
456+ "%s added ddb 0x%p sess 0x%p"
457+ " conn 0x%p state 0x%x\n",
458+ __func__, ddb_entry,
459+ ddb_entry->sess, ddb_entry->conn,
460+ ddb_entry->state));
461 }
462- }
463+ } else if (ddb_entry->fw_ddb_index != fw_ddb_index) {
464+ /* Target has been bound to a new fw_ddb_index */
465+ ha->fw_ddb_index_map[ddb_entry->fw_ddb_index] = NULL;
466+ ddb_entry->fw_ddb_index = fw_ddb_index;
467+ ddb_entry->fw_ddb_device_state = ddb_state;
468+ ha->fw_ddb_index_map[fw_ddb_index] = ddb_entry;
469+ atomic_set(&ddb_entry->port_down_timer,
470+ ha->port_down_retry_count);
471+ atomic_set(&ddb_entry->relogin_retry_count, 0);
472+ atomic_set(&ddb_entry->relogin_timer, 0);
473+ clear_bit(DF_RELOGIN, &ddb_entry->flags);
474+ clear_bit(DF_NO_RELOGIN, &ddb_entry->flags);
475+ atomic_set(&ddb_entry->state, DDB_STATE_ONLINE);
476
477- DEBUG6(dev_info(&ha->pdev->dev, "%s added ddb 0x%p sess 0x%p conn 0x%p"
478- " state 0x%x\n", __func__, ddb_entry, ddb_entry->sess,
479- ddb_entry->conn, ddb_entry->state));
480+ dev_info(&ha->pdev->dev,
481+ "scsi%ld: %s: ddb[%d] os[%d] marked ONLINE sess:%p conn:%p\n",
482+ ha->host_no, __func__, ddb_entry->fw_ddb_index,
483+ ddb_entry->os_target_id, ddb_entry->sess, ddb_entry->conn);
484+
485+ if (!probe)
486+ qla4xxx_conn_start(ddb_entry->conn);
487+ DEBUG6(dev_info(&ha->pdev->dev, "%s calling conn_start ddb 0x%p sess 0x%p"
488+ " conn 0x%p state 0x%x\n", __func__, ddb_entry, ddb_entry->sess,
489+ ddb_entry->conn, ddb_entry->state));
490+ }
491 exit_dyn_add:
492 dma_free_coherent(&ha->pdev->dev, sizeof(*fw_ddb_entry), fw_ddb_entry,
493 fw_ddb_entry_dma);
494@@ -1272,15 +1295,15 @@ int qla4xxx_process_ddb_changed(struct s
495 qla4xxx_add_device_dynamically(ha, fw_ddb_index, probe);
496 return QLA_SUCCESS;
497 }
498- DEBUG6(dev_info(&ha->pdev->dev, "%s ddb_entry 0x%p ostate 0x%x"
499- " sess 0x%p conn 0x%p\n", __func__, ddb_entry,
500- ddb_entry->state, ddb_entry->sess, ddb_entry->conn));
501+ DEBUG6(dev_info(&ha->pdev->dev, "%s ddb[%d] os[%d] ostate 0x%x"
502+ " sess 0x%p conn 0x%p o_fwstate 0x%x n_fwstate ox%x \n",
503+ __func__, ddb_entry->fw_ddb_index, ddb_entry->os_target_id,
504+ ddb_entry->state, ddb_entry->sess, ddb_entry->conn,
505+ ddb_entry->fw_ddb_device_state, state));
506
507 /* Device already exists in our database. */
508 old_fw_ddb_device_state = ddb_entry->fw_ddb_device_state;
509- DEBUG2(printk("scsi%ld: %s DDB - old state= 0x%x, new state=0x%x for "
510- "index [%d]\n", ha->host_no, __func__,
511- ddb_entry->fw_ddb_device_state, state, fw_ddb_index));
512+
513 if (old_fw_ddb_device_state == state &&
514 state == DDB_DS_SESSION_ACTIVE) {
515 /* Do nothing, state not changed. */
516@@ -1297,26 +1320,33 @@ int qla4xxx_process_ddb_changed(struct s
517 atomic_set(&ddb_entry->port_down_timer,
518 ha->port_down_retry_count);
519 atomic_set(&ddb_entry->state, DDB_STATE_ONLINE);
520+ dev_info(&ha->pdev->dev,
521+ "%s: ddb[%d] os[%d] marked ONLINE\n",
522+ __func__, ddb_entry->fw_ddb_index,
523+ ddb_entry->os_target_id);
524+
525 atomic_set(&ddb_entry->relogin_retry_count, 0);
526 atomic_set(&ddb_entry->relogin_timer, 0);
527 clear_bit(DF_RELOGIN, &ddb_entry->flags);
528 clear_bit(DF_NO_RELOGIN, &ddb_entry->flags);
529
530- DEBUG6(dev_info(&ha->pdev->dev, "%s conn startddb_entry 0x%p"
531- " sess 0x%p conn 0x%p\n",
82094b55 532- __func__, ddb_entry, ddb_entry->sess, ddb_entry->conn));
2cb7cef9
BS
533-
534- qla4xxx_conn_start(ddb_entry->conn);
535-
536- DEBUG6(dev_info(&ha->pdev->dev, "%s conn start done "
537- "ddb_entry 0x%p sess 0x%p conn 0x%p\n",
538- __func__, ddb_entry, ddb_entry->sess, ddb_entry->conn));
539-
540- if (!test_bit(DF_SCAN_ISSUED, &ddb_entry->flags)) {
541- scsi_scan_target(&ddb_entry->sess->dev, 0,
542- ddb_entry->sess->target_id,
543- SCAN_WILD_CARD, 0);
544- set_bit(DF_SCAN_ISSUED, &ddb_entry->flags);
545+ if (ddb_entry->conn) {
546+ DEBUG6(dev_info(&ha->pdev->dev,
547+ "%s conn startddb_entry 0x%p"
548+ " sess 0x%p conn 0x%p\n",
549+ __func__,
550+ ddb_entry, ddb_entry->sess, ddb_entry->conn));
551+
552+ qla4xxx_conn_start(ddb_entry->conn);
553+
554+ DEBUG6(dev_info(&ha->pdev->dev, "%s conn start done "
555+ "ddb_entry 0x%p sess 0x%p conn 0x%p\n",
556+ __func__, ddb_entry, ddb_entry->sess, ddb_entry->conn));
557+
558+ if (!test_bit(DF_SCAN_ISSUED, &ddb_entry->flags)) {
559+ qla4xxx_scan_target(ddb_entry);
560+ set_bit(DF_SCAN_ISSUED, &ddb_entry->flags);
561+ }
562 }
563 } else {
564 /* Device went away, try to relogin. */
565--- a/drivers/scsi/qla4xxx/ql4_inline.h
566+++ b/drivers/scsi/qla4xxx/ql4_inline.h
567@@ -34,6 +34,34 @@ qla4xxx_lookup_ddb_by_fw_index(struct sc
568 return ddb_entry;
569 }
570
571+/*
572+ * The MBOX_CMD_CLEAR_DATABASE_ENTRY (0x31) mailbox command does not
573+ * result in an AEN, so we need to process it seperately.
574+ */
575+static inline void qla4xxx_check_for_clear_ddb(struct scsi_qla_host *ha,
576+ uint32_t *mbox_cmd)
577+{
578+ uint32_t fw_ddb_index;
579+ struct ddb_entry *ddb_entry = NULL;
580+
581+ if (mbox_cmd[0] == MBOX_CMD_CLEAR_DATABASE_ENTRY) {
582+
583+ fw_ddb_index = mbox_cmd[1];
584+
585+ if (fw_ddb_index < MAX_DDB_ENTRIES)
586+ ddb_entry = ha->fw_ddb_index_map[fw_ddb_index];
587+
588+ if (ddb_entry) {
589+ dev_info(&ha->pdev->dev, "%s: ddb[%d] os[%d] freed\n",
590+ __func__, ddb_entry->fw_ddb_index,
591+ ddb_entry->os_target_id);
592+ set_bit(DF_DELETED, &ddb_entry->flags);
593+ set_bit(DPC_DELETE_DEVICE, &ha->dpc_flags);
594+ queue_work(ha->dpc_thread, &ha->dpc_work);
595+ }
596+ }
597+}
598+
599 static inline void
600 __qla4xxx_enable_intrs(struct scsi_qla_host *ha)
601 {
602@@ -81,3 +109,118 @@ qla4xxx_disable_intrs(struct scsi_qla_ho
603 __qla4xxx_disable_intrs(ha);
604 spin_unlock_irqrestore(&ha->hardware_lock, flags);
605 }
606+
607+static inline int qla4xxx_get_req_pkt(struct scsi_qla_host *ha,
608+ struct queue_entry **queue_entry)
609+{
610+ uint16_t request_in;
611+ uint8_t status = QLA_SUCCESS;
612+
613+ *queue_entry = ha->request_ptr;
614+
615+ /* get the latest request_in and request_out index */
616+ request_in = ha->request_in;
617+ ha->request_out = (uint16_t) le32_to_cpu(ha->shadow_regs->req_q_out);
618+
619+ /* Advance request queue pointer and check for queue full */
620+ if (request_in == (REQUEST_QUEUE_DEPTH - 1)) {
621+ request_in = 0;
622+ ha->request_ptr = ha->request_ring;
623+ } else {
624+ request_in++;
625+ ha->request_ptr++;
626+ }
627+
628+ /* request queue is full, try again later */
629+ if ((ha->iocb_cnt + 1) >= ha->iocb_hiwat) {
630+ /* restore request pointer */
631+ ha->request_ptr = *queue_entry;
632+ status = QLA_ERROR;
633+ } else {
634+ ha->request_in = request_in;
635+ memset(*queue_entry, 0, sizeof(**queue_entry));
636+ }
637+
638+ return status;
639+}
640+
641+/**
642+ * qla4xxx_send_marker_iocb - issues marker iocb to HBA
643+ * @ha: Pointer to host adapter structure.
644+ * @ddb_entry: Pointer to device database entry
645+ * @lun: SCSI LUN
646+ * @marker_type: marker identifier
647+ *
648+ * This routine issues a marker IOCB.
649+ **/
650+static inline int qla4xxx_send_marker_iocb(struct scsi_qla_host *ha,
651+ struct ddb_entry *ddb_entry, int lun)
652+{
653+ struct marker_entry *marker_entry;
654+ unsigned long flags = 0;
655+ uint8_t status = QLA_SUCCESS;
656+
657+ /* Acquire hardware specific lock */
658+ spin_lock_irqsave(&ha->hardware_lock, flags);
659+
660+ /* Get pointer to the queue entry for the marker */
661+ if (qla4xxx_get_req_pkt(ha, (struct queue_entry **) &marker_entry) !=
662+ QLA_SUCCESS) {
663+ status = QLA_ERROR;
664+ goto exit_send_marker;
665+ }
666+
667+ /* Put the marker in the request queue */
668+ marker_entry->hdr.entryType = ET_MARKER;
669+ marker_entry->hdr.entryCount = 1;
670+ marker_entry->target = cpu_to_le16(ddb_entry->fw_ddb_index);
671+ marker_entry->modifier = cpu_to_le16(MM_LUN_RESET);
672+ int_to_scsilun(lun, &marker_entry->lun);
673+ wmb();
674+
675+ /* Tell ISP it's got a new I/O request */
676+ writel(ha->request_in, &ha->reg->req_q_in);
677+ readl(&ha->reg->req_q_in);
678+
679+exit_send_marker:
680+ spin_unlock_irqrestore(&ha->hardware_lock, flags);
681+ return status;
682+}
683+
684+static inline struct continuation_t1_entry* qla4xxx_alloc_cont_entry(
685+ struct scsi_qla_host *ha)
686+{
687+ struct continuation_t1_entry *cont_entry;
688+
689+ cont_entry = (struct continuation_t1_entry *)ha->request_ptr;
690+
691+ /* Advance request queue pointer */
692+ if (ha->request_in == (REQUEST_QUEUE_DEPTH - 1)) {
693+ ha->request_in = 0;
694+ ha->request_ptr = ha->request_ring;
695+ } else {
696+ ha->request_in++;
697+ ha->request_ptr++;
698+ }
699+
700+ /* Load packet defaults */
701+ cont_entry->hdr.entryType = ET_CONTINUE;
702+ cont_entry->hdr.entryCount = 1;
703+ cont_entry->hdr.systemDefined = (uint8_t) cpu_to_le16(ha->request_in);
704+
705+ return cont_entry;
706+}
707+
708+static inline uint16_t qla4xxx_calc_request_entries(uint16_t dsds)
709+{
710+ uint16_t iocbs;
711+
712+ iocbs = 1;
713+ if (dsds > COMMAND_SEG) {
714+ iocbs += (dsds - COMMAND_SEG) / CONTINUE_SEG;
715+ if ((dsds - COMMAND_SEG) % CONTINUE_SEG)
716+ iocbs++;
717+ }
718+ return iocbs;
719+}
720+
721--- a/drivers/scsi/qla4xxx/ql4_iocb.c
722+++ b/drivers/scsi/qla4xxx/ql4_iocb.c
723@@ -11,133 +11,8 @@
724 #include "ql4_dbg.h"
725 #include "ql4_inline.h"
726
727-#define VMWARE_CMD_TIMEOUT 30
728 #include <scsi/scsi_tcq.h>
729
730-/**
731- * qla4xxx_get_req_pkt - returns a valid entry in request queue.
732- * @ha: Pointer to host adapter structure.
733- * @queue_entry: Pointer to pointer to queue entry structure
734- *
735- * This routine performs the following tasks:
736- * - returns the current request_in pointer (if queue not full)
737- * - advances the request_in pointer
738- * - checks for queue full
739- **/
740-static int qla4xxx_get_req_pkt(struct scsi_qla_host *ha,
741- struct queue_entry **queue_entry)
742-{
743- uint16_t request_in;
744- uint8_t status = QLA_SUCCESS;
745-
746- *queue_entry = ha->request_ptr;
747-
748- /* get the latest request_in and request_out index */
749- request_in = ha->request_in;
750- ha->request_out = (uint16_t) le32_to_cpu(ha->shadow_regs->req_q_out);
751-
752- /* Advance request queue pointer and check for queue full */
753- if (request_in == (REQUEST_QUEUE_DEPTH - 1)) {
754- request_in = 0;
755- ha->request_ptr = ha->request_ring;
756- } else {
757- request_in++;
758- ha->request_ptr++;
759- }
760-
761- /* request queue is full, try again later */
762- if ((ha->iocb_cnt + 1) >= ha->iocb_hiwat) {
763- /* restore request pointer */
764- ha->request_ptr = *queue_entry;
765- status = QLA_ERROR;
766- } else {
767- ha->request_in = request_in;
768- memset(*queue_entry, 0, sizeof(**queue_entry));
769- }
770-
771- return status;
772-}
773-
774-/**
775- * qla4xxx_send_marker_iocb - issues marker iocb to HBA
776- * @ha: Pointer to host adapter structure.
777- * @ddb_entry: Pointer to device database entry
778- * @lun: SCSI LUN
779- * @marker_type: marker identifier
780- *
781- * This routine issues a marker IOCB.
782- **/
783-int qla4xxx_send_marker_iocb(struct scsi_qla_host *ha,
784- struct ddb_entry *ddb_entry, int lun)
785-{
786- struct marker_entry *marker_entry;
787- unsigned long flags = 0;
788- uint8_t status = QLA_SUCCESS;
789-
790- /* Acquire hardware specific lock */
791- spin_lock_irqsave(&ha->hardware_lock, flags);
792-
793- /* Get pointer to the queue entry for the marker */
794- if (qla4xxx_get_req_pkt(ha, (struct queue_entry **) &marker_entry) !=
795- QLA_SUCCESS) {
796- status = QLA_ERROR;
797- goto exit_send_marker;
798- }
799-
800- /* Put the marker in the request queue */
801- marker_entry->hdr.entryType = ET_MARKER;
802- marker_entry->hdr.entryCount = 1;
803- marker_entry->target = cpu_to_le16(ddb_entry->fw_ddb_index);
804- marker_entry->modifier = cpu_to_le16(MM_LUN_RESET);
805- int_to_scsilun(lun, &marker_entry->lun);
806- wmb();
807-
808- /* Tell ISP it's got a new I/O request */
809- writel(ha->request_in, &ha->reg->req_q_in);
810- readl(&ha->reg->req_q_in);
811-
812-exit_send_marker:
813- spin_unlock_irqrestore(&ha->hardware_lock, flags);
814- return status;
815-}
816-
817-static struct continuation_t1_entry* qla4xxx_alloc_cont_entry(
818- struct scsi_qla_host *ha)
819-{
820- struct continuation_t1_entry *cont_entry;
821-
822- cont_entry = (struct continuation_t1_entry *)ha->request_ptr;
823-
824- /* Advance request queue pointer */
825- if (ha->request_in == (REQUEST_QUEUE_DEPTH - 1)) {
826- ha->request_in = 0;
827- ha->request_ptr = ha->request_ring;
828- } else {
829- ha->request_in++;
830- ha->request_ptr++;
831- }
832-
833- /* Load packet defaults */
834- cont_entry->hdr.entryType = ET_CONTINUE;
835- cont_entry->hdr.entryCount = 1;
836- cont_entry->hdr.systemDefined = (uint8_t) cpu_to_le16(ha->request_in);
837-
838- return cont_entry;
839-}
840-
841-static uint16_t qla4xxx_calc_request_entries(uint16_t dsds)
842-{
843- uint16_t iocbs;
844-
845- iocbs = 1;
846- if (dsds > COMMAND_SEG) {
847- iocbs += (dsds - COMMAND_SEG) / CONTINUE_SEG;
848- if ((dsds - COMMAND_SEG) % CONTINUE_SEG)
849- iocbs++;
850- }
851- return iocbs;
852-}
853-
854 static void qla4xxx_build_scsi_iocbs(struct srb *srb,
855 struct command_t3_entry *cmd_entry,
856 uint16_t tot_dsds)
857@@ -224,6 +99,7 @@ int qla4xxx_send_command_to_isp(struct s
858 /* Acquire hardware specific lock */
859 spin_lock_irqsave(&ha->hardware_lock, flags);
860
861+ //index = (uint32_t)cmd->request->tag;
862 index = ha->current_active_index;
863 for (i = 0; i < MAX_SRBS; i++) {
864 index++;
865@@ -242,10 +118,14 @@ int qla4xxx_send_command_to_isp(struct s
866 }
867
868 /* Calculate the number of request entries needed. */
869- nseg = scsi_dma_map(cmd);
870- if (nseg < 0)
871- goto queuing_error;
872- tot_dsds = nseg;
873+ if (srb->flags & SRB_SCSI_PASSTHRU)
874+ tot_dsds = 1;
875+ else {
876+ nseg = scsi_dma_map(cmd);
877+ if (nseg < 0)
878+ goto queuing_error;
879+ tot_dsds = nseg;
880+ }
881
882 req_cnt = qla4xxx_calc_request_entries(tot_dsds);
883
884@@ -281,9 +161,9 @@ int qla4xxx_send_command_to_isp(struct s
885 cmd_entry->hdr.entryCount = req_cnt;
886
887 /* Set data transfer direction control flags
888- * NOTE: Look at data_direction bits iff there is data to be
889- * transferred, as the data direction bit is sometimed filled
890- * in when there is no data to be transferred */
891+ * NOTE: Look at data_direction bits iff there is data to be
892+ * transferred, as the data direction bit is sometimed filled
893+ * in when there is no data to be transferred */
894 cmd_entry->control_flags = CF_NO_DATA;
895 if (scsi_bufflen(cmd)) {
896 if (cmd->sc_data_direction == DMA_TO_DEVICE)
897@@ -324,10 +204,10 @@ int qla4xxx_send_command_to_isp(struct s
898
899 /*
900 * Check to see if adapter is online before placing request on
901- * request queue. If a reset occurs and a request is in the queue,
902- * the firmware will still attempt to process the request, retrieving
903- * garbage for pointers.
904- */
905+ * request queue. If a reset occurs and a request is in the queue,
906+ * the firmware will still attempt to process the request, retrieving
907+ * garbage for pointers.
908+ */
909 if (!test_bit(AF_ONLINE, &ha->flags)) {
910 DEBUG2(printk("scsi%ld: %s: Adapter OFFLINE! "
911 "Do not issue command.\n",
912@@ -355,13 +235,12 @@ int qla4xxx_send_command_to_isp(struct s
913 return QLA_SUCCESS;
914
915 queuing_error:
916- if (srb->flags & SRB_SCSI_PASSTHRU)
917- return QLA_ERROR;
918-
919- if (tot_dsds)
920- scsi_dma_unmap(cmd);
921+ if (!(srb->flags & SRB_SCSI_PASSTHRU))
922+ if (tot_dsds)
923+ scsi_dma_unmap(cmd);
924
925 spin_unlock_irqrestore(&ha->hardware_lock, flags);
926
927 return QLA_ERROR;
928 }
929+
930--- a/drivers/scsi/qla4xxx/ql4_isr.c
931+++ b/drivers/scsi/qla4xxx/ql4_isr.c
932@@ -10,6 +10,7 @@
933 #include "ql4_glbl.h"
934 #include "ql4_dbg.h"
935 #include "ql4_inline.h"
936+#include "ql4_os.h"
937
938 /**
939 * qla4xxx_status_entry - processes status IOCBs
82094b55 940@@ -59,8 +60,8 @@ static void qla4xxx_status_entry(struct
2cb7cef9
BS
941 break;
942 }
943 if (sts_entry->iscsiFlags & ISCSI_FLAG_RESIDUAL_UNDER) {
944- scsi_set_resid(cmd, residual);
945- if (!scsi_status && ((scsi_bufflen(cmd) - residual) <
946+ QL_SET_SCSI_RESID(cmd, residual);
947+ if (!scsi_status && ((QL_SCSI_BUFFLEN(cmd) - residual) <
948 cmd->underflow)) {
949 cmd->result = DID_ERROR << 16;
950 break;
82094b55 951@@ -144,7 +145,7 @@ static void qla4xxx_status_entry(struct
2cb7cef9
BS
952 break;
953 }
954
955- scsi_set_resid(cmd, residual);
956+ QL_SET_SCSI_RESID(cmd, residual);
957
958 /*
959 * If there is scsi_status, it takes precedense over
82094b55 960@@ -184,7 +185,7 @@ static void qla4xxx_status_entry(struct
2cb7cef9
BS
961 if ((sts_entry->iscsiFlags &
962 ISCSI_FLAG_RESIDUAL_UNDER) == 0) {
963 cmd->result = DID_BUS_BUSY << 16;
964- } else if ((scsi_bufflen(cmd) - residual) <
965+ } else if ((QL_SCSI_BUFFLEN(cmd) - residual) <
966 cmd->underflow) {
967 /*
968 * Handle mid-layer underflow???
82094b55 969@@ -203,7 +204,7 @@ static void qla4xxx_status_entry(struct
2cb7cef9
BS
970 "resid = 0x%x, compstat = 0x%x\n",
971 ha->host_no, cmd->device->channel,
972 cmd->device->id, cmd->device->lun,
973- __func__, scsi_bufflen(cmd),
974+ __func__, QL_SCSI_BUFFLEN(cmd),
975 residual,
976 sts_entry->completionStatus));
977
978@@ -396,13 +397,13 @@ static void qla4xxx_isr_decode_mailbox(s
979 /* Immediately process the AENs that don't require much work.
980 * Only queue the database_changed AENs */
981
982- dev_info(&ha->pdev->dev, "%s mbx0 0x%08x mbx1 0x%08x"
983+ DEBUG6(dev_info(&ha->pdev->dev, "%s mbx0 0x%08x mbx1 0x%08x"
984 " mbx2 0x%08x mbx3 0x%08x mbx4 0x%08x mbx5 0x%08x "
985 "mbx6 0x%08x mbx7 0x%08x\n", __func__,
986 readl(&ha->reg->mailbox[0]), readl(&ha->reg->mailbox[1]),
987 readl(&ha->reg->mailbox[2]), readl(&ha->reg->mailbox[3]),
988 readl(&ha->reg->mailbox[4]), readl(&ha->reg->mailbox[5]),
989- readl(&ha->reg->mailbox[6]), readl(&ha->reg->mailbox[7]));
990+ readl(&ha->reg->mailbox[6]), readl(&ha->reg->mailbox[7])));
991
992 if (ha->aen_log.count < MAX_AEN_ENTRIES) {
993 for (i = 0; i < MBOX_AEN_REG_COUNT; i++)
994@@ -412,11 +413,13 @@ static void qla4xxx_isr_decode_mailbox(s
995 }
996 switch (mbox_status) {
997 case MBOX_ASTS_SYSTEM_ERROR:
998+ dev_info(&ha->pdev->dev, "%s: System Err\n", __func__);
999 /* Log Mailbox registers */
1000 if (ql4xdontresethba) {
1001 DEBUG2(printk("%s:Dont Reset HBA\n",
1002 __func__));
1003 } else {
1004+ qla4xxx_hw_reset(ha, 0);
1005 set_bit(AF_GET_CRASH_RECORD, &ha->flags);
1006 set_bit(DPC_RESET_HA, &ha->dpc_flags);
1007 }
1008@@ -433,15 +436,13 @@ static void qla4xxx_isr_decode_mailbox(s
1009 break;
1010
1011 case MBOX_ASTS_LINK_UP:
1012- DEBUG2(printk("scsi%ld: AEN %04x Adapter LINK UP\n",
1013- ha->host_no, mbox_status));
1014 set_bit(AF_LINK_UP, &ha->flags);
1015+ dev_info(&ha->pdev->dev, "%s: LINK UP\n", __func__);
1016 break;
1017
1018 case MBOX_ASTS_LINK_DOWN:
1019- DEBUG2(printk("scsi%ld: AEN %04x Adapter LINK DOWN\n",
1020- ha->host_no, mbox_status));
1021 clear_bit(AF_LINK_UP, &ha->flags);
1022+ dev_info(&ha->pdev->dev, "%s: LINK DOWN\n", __func__);
1023 break;
1024
1025 case MBOX_ASTS_HEARTBEAT:
82094b55 1026@@ -591,8 +592,9 @@ void qla4xxx_interrupt_service_routine(s
2cb7cef9
BS
1027 * qla4xxx_intr_handler - hardware interrupt handler.
1028 * @irq: Unused
1029 * @dev_id: Pointer to host adapter structure
1030+ * @regs: Unused
1031 **/
1032-irqreturn_t qla4xxx_intr_handler(int irq, void *dev_id)
1033+QL_DECLARE_INTR_HANDLER(qla4xxx_intr_handler, irq, dev_id, regs)
1034 {
2cb7cef9
BS
1035 struct scsi_qla_host *ha;
1036 uint32_t intr_status;
82094b55 1037@@ -624,8 +626,7 @@ irqreturn_t qla4xxx_intr_handler(int irq
2cb7cef9
BS
1038 intr_status = readl(&ha->reg->ctrl_status);
1039
1040 if ((intr_status &
1041- (CSR_SCSI_RESET_INTR|CSR_FATAL_ERROR|INTR_PENDING)) ==
1042- 0) {
1043+ (CSR_SCSI_RESET_INTR|CSR_FATAL_ERROR|INTR_PENDING)) == 0) {
1044 if (reqs_count == 0)
1045 ha->spurious_int_count++;
1046 break;
82094b55 1047@@ -661,6 +662,8 @@ irqreturn_t qla4xxx_intr_handler(int irq
2cb7cef9
BS
1048 break;
1049 } else if (intr_status & CSR_SCSI_RESET_INTR) {
1050 clear_bit(AF_ONLINE, &ha->flags);
1051+ dev_info(&ha->pdev->dev,"%s: adapter OFFLINE\n",
1052+ __func__);
1053 __qla4xxx_disable_intrs(ha);
1054
1055 writel(set_rmask(CSR_SCSI_RESET_INTR),
1056--- a/drivers/scsi/qla4xxx/ql4_mbx.c
1057+++ b/drivers/scsi/qla4xxx/ql4_mbx.c
1058@@ -10,6 +10,7 @@
1059 #include "ql4_glbl.h"
1060 #include "ql4_dbg.h"
1061 #include "ql4_inline.h"
1062+#include "ql4_os.h"
1063
1064
1065 /**
1066@@ -43,6 +44,7 @@ int qla4xxx_mailbox_command(struct scsi_
1067
1068 /* Mailbox code active */
1069 wait_count = MBOX_TOV * 100;
1070+
1071 while (wait_count--) {
1072 mutex_lock(&ha->mbox_sem);
1073 if (!test_bit(AF_MBOX_COMMAND, &ha->flags)) {
1074@@ -166,6 +168,8 @@ int qla4xxx_mailbox_command(struct scsi_
1075 spin_unlock_irqrestore(&ha->hardware_lock, flags);
1076
1077 mbox_exit:
1078+ if (status == QLA_SUCCESS)
1079+ qla4xxx_check_for_clear_ddb(ha, mbx_cmd);
1080 mutex_lock(&ha->mbox_sem);
1081 clear_bit(AF_MBOX_COMMAND, &ha->flags);
1082 mutex_unlock(&ha->mbox_sem);
2cb7cef9
BS
1083@@ -882,8 +886,7 @@ int qla4xxx_get_fw_version(struct scsi_q
1084 return QLA_SUCCESS;
1085 }
1086
1087-static int qla4xxx_get_default_ddb(struct scsi_qla_host *ha,
1088- dma_addr_t dma_addr)
1089+int qla4xxx_get_default_ddb(struct scsi_qla_host *ha, dma_addr_t dma_addr)
1090 {
1091 uint32_t mbox_cmd[MBOX_REG_COUNT];
1092 uint32_t mbox_sts[MBOX_REG_COUNT];
1093--- a/drivers/scsi/qla4xxx/ql4_os.c
1094+++ b/drivers/scsi/qla4xxx/ql4_os.c
1095@@ -15,6 +15,8 @@
1096 #include "ql4_glbl.h"
1097 #include "ql4_dbg.h"
1098 #include "ql4_inline.h"
1099+#include "ql4_os.h"
1100+
1101
1102 /*
1103 * Driver version
1104@@ -56,24 +58,32 @@ MODULE_PARM_DESC(extended_error_logging,
1105 "Option to enable extended error logging, "
1106 "Default is 0 - no logging, 1 - debug logging");
1107
1108+/* Command Timeout before ddb state goes to MISSING */
1109+int cmd_timeout = IOCB_CMD_TIMEOUT;
1110+module_param(cmd_timeout, int, S_IRUGO | S_IRUSR);
1111+MODULE_PARM_DESC(cmd_timeout, "Command Timeout");
1112+
1113+/* Timeout before ddb state MISSING goes DEAD */
1114+int recovery_tmo = RECOVERY_TIMEOUT;
1115+module_param(recovery_tmo, int, S_IRUGO | S_IRUSR);
1116+MODULE_PARM_DESC(recovery_tmo, "Recovery Timeout");
1117+
1118 int ql4_mod_unload = 0;
1119 /*
1120 * SCSI host template entry points
1121 */
1122-static void qla4xxx_config_dma_addressing(struct scsi_qla_host *ha);
1123+
1124+void qla4xxx_config_dma_addressing(struct scsi_qla_host *ha);
1125
1126 /*
1127 * iSCSI template entry points
1128 */
1129-static int qla4xxx_tgt_dscvr(struct Scsi_Host *shost,
1130- enum iscsi_tgt_dscvr type, uint32_t enable,
1131- struct sockaddr *dst_addr);
1132+static int qla4xxx_host_get_param(struct Scsi_Host *,
1133+ enum iscsi_host_param, char *);
1134 static int qla4xxx_conn_get_param(struct iscsi_cls_conn *conn,
1135 enum iscsi_param param, char *buf);
1136 static int qla4xxx_sess_get_param(struct iscsi_cls_session *sess,
1137 enum iscsi_param param, char *buf);
1138-static int qla4xxx_host_get_param(struct Scsi_Host *shost,
1139- enum iscsi_host_param param, char *buf);
1140 static void qla4xxx_recovery_timedout(struct iscsi_cls_session *session);
1141
1142 /*
1143@@ -85,11 +95,13 @@ static int qla4xxx_eh_device_reset(struc
1144 static int qla4xxx_eh_host_reset(struct scsi_cmnd *cmd);
1145 static int qla4xxx_slave_alloc(struct scsi_device *device);
1146 static int qla4xxx_slave_configure(struct scsi_device *device);
1147+static void qla4xxx_slave_destroy(struct scsi_device *device);
1148
1149 static struct scsi_host_template qla4xxx_driver_template = {
1150 .module = THIS_MODULE,
1151 .name = DRIVER_NAME,
1152 .proc_name = DRIVER_NAME,
1153+ .proc_info = qla4xxx_proc_info,
1154 .queuecommand = qla4xxx_queuecommand,
1155
1156 .eh_device_reset_handler = qla4xxx_eh_device_reset,
1157@@ -97,6 +109,7 @@ static struct scsi_host_template qla4xxx
1158
1159 .slave_configure = qla4xxx_slave_configure,
1160 .slave_alloc = qla4xxx_slave_alloc,
1161+ .slave_destroy = qla4xxx_slave_destroy,
1162
1163 .this_id = -1,
1164 .cmd_per_lun = 3,
1165@@ -113,10 +126,13 @@ static struct iscsi_transport qla4xxx_is
1166 ISCSI_CONN_ADDRESS |
1167 ISCSI_TARGET_NAME |
1168 ISCSI_TPGT,
1169- .tgt_dscvr = qla4xxx_tgt_dscvr,
1170+
1171+ QL_INIT_SESSION_DATASIZE(sessiondata_size)
1172+ QL_INIT_HOST_TEMPLATE(host_template)
1173+
1174+ .get_host_param = qla4xxx_host_get_param,
1175 .get_conn_param = qla4xxx_conn_get_param,
1176 .get_session_param = qla4xxx_sess_get_param,
1177- .get_host_param = qla4xxx_host_get_param,
1178 .session_recovery_timedout = qla4xxx_recovery_timedout,
1179 };
1180
1181@@ -134,31 +150,9 @@ static void qla4xxx_recovery_timedout(st
1182 ddb_entry->fw_ddb_index, ddb_entry->os_target_id,
1183 ha->port_down_retry_count);
1184
1185- DEBUG2(printk("scsi%ld: %s: scheduling dpc routine - dpc flags = "
1186- "0x%lx\n", ha->host_no, __func__, ha->dpc_flags));
1187- queue_work(ha->dpc_thread, &ha->dpc_work);
1188-}
1189-
1190-static int qla4xxx_host_get_param(struct Scsi_Host *shost,
1191- enum iscsi_host_param param, char *buf)
1192-{
1193- struct scsi_qla_host *ha = to_qla_host(shost);
1194- int len;
1195-
1196- switch (param) {
1197- case ISCSI_HOST_PARAM_IPADDRESS:
1198- len = sprintf(buf, "%d.%d.%d.%d", ha->ip_address[0],
1199- ha->ip_address[1], ha->ip_address[2],
1200- ha->ip_address[3]);
1201- break;
1202- case ISCSI_HOST_PARAM_INITIATOR_NAME:
1203- len = sprintf(buf, "%s", ha->name_string);
1204- break;
1205- default:
1206- return -ENOSYS;
1207- }
1208+ QL_SET_DDB_OFFLINE(ha, ddb_entry);
1209
1210- return len;
1211+ queue_work(ha->dpc_thread, &ha->dpc_work);
1212 }
1213
1214 int qla4xxx_conn_start(struct iscsi_cls_conn *conn)
1215@@ -166,7 +160,8 @@ int qla4xxx_conn_start(struct iscsi_cls_
1216 struct iscsi_cls_session *session;
1217 struct ddb_entry *ddb_entry;
1218
1219- session = iscsi_dev_to_session(conn->dev.parent);
1220+ session = QL_ISCSI_CONN_TO_SESS(conn);
1221+
1222 ddb_entry = session->dd_data;
1223
1224 DEBUG2(printk("scsi%ld: %s: index [%d] starting conn\n",
1225@@ -181,7 +176,8 @@ static void qla4xxx_conn_stop(struct isc
1226 struct iscsi_cls_session *session;
1227 struct ddb_entry *ddb_entry;
1228
1229- session = iscsi_dev_to_session(conn->dev.parent);
1230+ session = QL_ISCSI_CONN_TO_SESS(conn);
1231+
1232 ddb_entry = session->dd_data;
1233
1234 DEBUG2(printk("scsi%ld: %s: index [%d] stopping conn\n",
1235@@ -207,6 +203,12 @@ static int qla4xxx_sess_get_param(struct
1236 case ISCSI_PARAM_TPGT:
1237 len = sprintf(buf, "%u", ddb_entry->tpgt);
1238 break;
1239+
1240+#ifdef ISCSI_ISID
1241+ case ISCSI_PARAM_ISID:
1242+ len = sprintf(buf, "%u", QL_ISCSI_SESSION_ID(ddb_entry));
1243+ break;
1244+#endif
1245 default:
1246 return -ENOSYS;
1247 }
1248@@ -221,7 +223,8 @@ static int qla4xxx_conn_get_param(struct
1249 struct ddb_entry *ddb_entry;
1250 int len;
1251
1252- session = iscsi_dev_to_session(conn->dev.parent);
1253+ session = QL_ISCSI_CONN_TO_SESS(conn);
1254+
1255 ddb_entry = session->dd_data;
1256
1257 switch (param) {
1258@@ -240,47 +243,53 @@ static int qla4xxx_conn_get_param(struct
1259 return len;
1260 }
1261
1262-static int qla4xxx_tgt_dscvr(struct Scsi_Host *shost,
1263- enum iscsi_tgt_dscvr type, uint32_t enable,
1264- struct sockaddr *dst_addr)
1265+static int qla4xxx_host_get_param(struct Scsi_Host *shost,
1266+ enum iscsi_host_param param, char *buf)
1267 {
1268- struct scsi_qla_host *ha;
1269- struct sockaddr_in *addr;
1270- struct sockaddr_in6 *addr6;
1271- int ret = 0;
1272-
1273- ha = (struct scsi_qla_host *) shost->hostdata;
1274-
1275- switch (type) {
1276- case ISCSI_TGT_DSCVR_SEND_TARGETS:
1277- if (dst_addr->sa_family == AF_INET) {
1278- addr = (struct sockaddr_in *)dst_addr;
1279- if (qla4xxx_send_tgts(ha, (char *)&addr->sin_addr,
1280- addr->sin_port) != QLA_SUCCESS)
1281- ret = -EIO;
1282- } else if (dst_addr->sa_family == AF_INET6) {
1283- /*
1284- * TODO: fix qla4xxx_send_tgts
1285- */
1286- addr6 = (struct sockaddr_in6 *)dst_addr;
1287- if (qla4xxx_send_tgts(ha, (char *)&addr6->sin6_addr,
1288- addr6->sin6_port) != QLA_SUCCESS)
1289- ret = -EIO;
1290- } else
1291- ret = -ENOSYS;
1292+ struct scsi_qla_host *ha = to_qla_host(shost);
1293+ int len;
1294+
1295+ switch (param) {
1296+ case ISCSI_HOST_PARAM_IPADDRESS:
1297+ len = sprintf(buf, "%d.%d.%d.%d", ha->ip_address[0],
1298+ ha->ip_address[1], ha->ip_address[2],
1299+ ha->ip_address[3]);
1300+ break;
1301+ case ISCSI_HOST_PARAM_INITIATOR_NAME:
1302+ len = sprintf(buf, "%s", ha->name_string);
1303 break;
1304 default:
1305- ret = -ENOSYS;
1306+ return -ENOSYS;
1307 }
1308- return ret;
1309+
1310+ return len;
1311+}
1312+
1313+static int ql_alloc_osindex(struct scsi_qla_host *ha)
1314+{
1315+ unsigned int idx;
1316+
1317+ for (idx = 0; idx < MAX_DDB_ENTRIES; idx++)
1318+ if (test_and_set_bit((idx & 0x1F), &ha->os_map[(idx >> 5)]) == 0)
1319+ return idx;
1320+ return -1;
1321+}
1322+
1323+static void free_osindex(struct scsi_qla_host *ha, uint32_t idx)
1324+{
1325+ clear_bit((idx & 0x1F), &ha->os_map[idx >> 5]);
1326 }
1327
1328+
1329 void qla4xxx_destroy_sess(struct ddb_entry *ddb_entry)
1330 {
1331 if (!ddb_entry->sess)
1332 return;
1333+ free_osindex(ddb_entry->ha, ddb_entry->os_target_id);
1334
1335 if (ddb_entry->conn) {
1336+ QL_ISCSI_IF_DESTROY_SESSION_DONE(ddb_entry);
1337+ QL_ISCSI_DESTROY_CONN(ddb_entry);
1338 iscsi_remove_session(ddb_entry->sess);
1339 }
1340 iscsi_free_session(ddb_entry->sess);
1341@@ -290,25 +299,27 @@ int qla4xxx_add_sess(struct ddb_entry *d
1342 {
1343 int err;
1344
1345- err = iscsi_add_session(ddb_entry->sess, ddb_entry->fw_ddb_index);
1346+ err = QL_ISCSI_ADD_SESS(ddb_entry);
1347+
1348 if (err) {
1349 DEBUG2(printk(KERN_ERR "Could not add session.\n"));
1350 return err;
1351 }
1352
1353- ddb_entry->conn = iscsi_create_conn(ddb_entry->sess, 0, 0);
1354+ ddb_entry->conn = QL_ISCSI_CREATE_CONN(ddb_entry);
1355+
1356 if (!ddb_entry->conn) {
1357 iscsi_remove_session(ddb_entry->sess);
1358 DEBUG2(printk(KERN_ERR "Could not add connection.\n"));
1359 return -ENOMEM;
1360 }
1361
1362- ddb_entry->sess->recovery_tmo = ddb_entry->ha->port_down_retry_count;
1363- if (scan)
1364- scsi_scan_target(&ddb_entry->sess->dev, 0,
1365- ddb_entry->sess->target_id,
1366- SCAN_WILD_CARD, 0);
1367- iscsi_unblock_session(ddb_entry->sess);
1368+ ddb_entry->sess->recovery_tmo = QL_SESS_RECOVERY_TO(ddb_entry);
1369+
1370+ qla4xxx_scan_target(ddb_entry);
1371+
1372+ QL_ISCSI_CREATE_SESS_DONE(ddb_entry);
1373+
1374 return 0;
1375 }
1376
1377@@ -317,13 +328,20 @@ struct ddb_entry *qla4xxx_alloc_sess(str
1378 struct ddb_entry *ddb_entry;
1379 struct iscsi_cls_session *sess;
1380
1381- sess = iscsi_alloc_session(ha->host, &qla4xxx_iscsi_transport,
1382- sizeof(struct ddb_entry));
1383- if (!sess)
1384+ int os_idx;
1385+
1386+ if ((os_idx = ql_alloc_osindex(ha)) >= MAX_DDB_ENTRIES)
1387+ return NULL;
1388+
1389+ sess = QL_ISCSI_ALLOC_SESSION(ha, &qla4xxx_iscsi_transport);
1390+ if (!sess) {
1391+ free_osindex(ha, os_idx);
1392 return NULL;
1393+ }
1394
1395 ddb_entry = sess->dd_data;
1396 memset(ddb_entry, 0, sizeof(*ddb_entry));
1397+ ddb_entry->os_target_id = os_idx;
1398 ddb_entry->ha = ha;
1399 ddb_entry->sess = sess;
1400 return ddb_entry;
82094b55 1401@@ -371,9 +389,9 @@ void qla4xxx_mark_device_missing(struct
2cb7cef9
BS
1402 }
1403
1404 static struct srb* qla4xxx_get_new_srb(struct scsi_qla_host *ha,
1405- struct ddb_entry *ddb_entry,
1406- struct scsi_cmnd *cmd,
1407- void (*done)(struct scsi_cmnd *))
1408+ struct ddb_entry *ddb_entry,
1409+ struct scsi_cmnd *cmd,
1410+ void (*done)(struct scsi_cmnd *))
1411 {
1412 struct srb *srb;
1413
1414@@ -392,17 +410,6 @@ static struct srb* qla4xxx_get_new_srb(s
1415 return srb;
1416 }
1417
1418-static void qla4xxx_srb_free_dma(struct scsi_qla_host *ha, struct srb *srb)
1419-{
1420- struct scsi_cmnd *cmd = srb->cmd;
1421-
1422- if (srb->flags & SRB_DMA_VALID) {
1423- scsi_dma_unmap(cmd);
1424- srb->flags &= ~SRB_DMA_VALID;
1425- }
1426- cmd->SCp.ptr = NULL;
1427-}
1428-
1429 void qla4xxx_srb_compl(struct scsi_qla_host *ha, struct srb *srb)
1430 {
1431 struct scsi_cmnd *cmd = srb->cmd;
1432@@ -418,14 +425,14 @@ void qla4xxx_srb_compl(struct scsi_qla_h
1433 * qla4xxx_queuecommand - scsi layer issues scsi command to driver.
1434 * @cmd: Pointer to Linux's SCSI command structure
1435 * @done_fn: Function that the driver calls to notify the SCSI mid-layer
1436- * that the command has been processed.
1437+ * that the command has been processed.
1438 *
1439 * Remarks:
1440 * This routine is invoked by Linux to send a SCSI command to the driver.
1441 * The mid-level driver tries to ensure that queuecommand never gets
1442 * invoked concurrently with itself or the interrupt handler (although
1443 * the interrupt handler may call this routine as part of request-
1444- * completion handling). Unfortunely, it sometimes calls the scheduler
1445+ * completion handling). Unfortunely, it sometimes calls the scheduler
1446 * in interrupt context which is a big NO! NO!.
1447 **/
1448 static int qla4xxx_queuecommand(struct scsi_cmnd *cmd,
1449@@ -546,7 +553,7 @@ static int qla4xxx_mem_alloc(struct scsi
1450 align = 0;
1451 if ((unsigned long)ha->queues_dma & (MEM_ALIGN_VALUE - 1))
1452 align = MEM_ALIGN_VALUE - ((unsigned long)ha->queues_dma &
1453- (MEM_ALIGN_VALUE - 1));
1454+ (MEM_ALIGN_VALUE - 1));
1455
1456 /* Update request and response queue pointers. */
1457 ha->request_dma = ha->queues_dma + align;
1458@@ -554,16 +561,16 @@ static int qla4xxx_mem_alloc(struct scsi
1459 ha->response_dma = ha->queues_dma + align +
1460 (REQUEST_QUEUE_DEPTH * QUEUE_SIZE);
1461 ha->response_ring = (struct queue_entry *) (ha->queues + align +
1462- (REQUEST_QUEUE_DEPTH *
1463- QUEUE_SIZE));
1464+ (REQUEST_QUEUE_DEPTH *
1465+ QUEUE_SIZE));
1466 ha->shadow_regs_dma = ha->queues_dma + align +
1467 (REQUEST_QUEUE_DEPTH * QUEUE_SIZE) +
1468 (RESPONSE_QUEUE_DEPTH * QUEUE_SIZE);
1469 ha->shadow_regs = (struct shadow_regs *) (ha->queues + align +
1470 (REQUEST_QUEUE_DEPTH *
1471- QUEUE_SIZE) +
1472+ QUEUE_SIZE) +
1473 (RESPONSE_QUEUE_DEPTH *
1474- QUEUE_SIZE));
1475+ QUEUE_SIZE));
1476
1477 /* Allocate memory for srb pool. */
1478 ha->srb_mempool = mempool_create(SRB_MIN_REQ, mempool_alloc_slab,
1479@@ -595,12 +602,12 @@ static void qla4xxx_timer(struct scsi_ql
1480 list_for_each_entry_safe(ddb_entry, dtemp, &ha->ddb_list, list) {
1481 /* Count down time between sending relogins */
1482 if (adapter_up(ha) &&
1483- !test_bit(DF_RELOGIN, &ddb_entry->flags) &&
1484- atomic_read(&ddb_entry->state) != DDB_STATE_ONLINE) {
1485+ !test_bit(DF_RELOGIN, &ddb_entry->flags) &&
1486+ atomic_read(&ddb_entry->state) != DDB_STATE_ONLINE) {
1487 if (atomic_read(&ddb_entry->retry_relogin_timer) !=
1488- INVALID_ENTRY) {
1489+ INVALID_ENTRY) {
1490 if (atomic_read(&ddb_entry->retry_relogin_timer)
1491- == 0) {
1492+ == 0) {
1493 atomic_set(&ddb_entry->
1494 retry_relogin_timer,
1495 INVALID_ENTRY);
1496@@ -608,9 +615,9 @@ static void qla4xxx_timer(struct scsi_ql
1497 &ha->dpc_flags);
1498 set_bit(DF_RELOGIN, &ddb_entry->flags);
1499 DEBUG2(printk("scsi%ld: %s: index [%d]"
1500- " login device\n",
1501- ha->host_no, __func__,
1502- ddb_entry->fw_ddb_index));
1503+ " login device\n",
1504+ ha->host_no, __func__,
1505+ ddb_entry->fw_ddb_index));
1506 } else
1507 atomic_dec(&ddb_entry->
1508 retry_relogin_timer);
1509@@ -619,64 +626,64 @@ static void qla4xxx_timer(struct scsi_ql
1510
1511 /* Wait for relogin to timeout */
1512 if (atomic_read(&ddb_entry->relogin_timer) &&
1513- (atomic_dec_and_test(&ddb_entry->relogin_timer) != 0)) {
1514+ (atomic_dec_and_test(&ddb_entry->relogin_timer) != 0)) {
1515 /*
1516 * If the relogin times out and the device is
1517 * still NOT ONLINE then try and relogin again.
1518 */
1519 if (atomic_read(&ddb_entry->state) !=
1520- DDB_STATE_ONLINE &&
1521- ddb_entry->fw_ddb_device_state ==
1522- DDB_DS_SESSION_FAILED) {
1523+ DDB_STATE_ONLINE &&
1524+ ddb_entry->fw_ddb_device_state ==
1525+ DDB_DS_SESSION_FAILED) {
1526 /* Reset retry relogin timer */
1527 atomic_inc(&ddb_entry->relogin_retry_count);
1528 DEBUG2(printk("scsi%ld: index[%d] relogin"
1529- " timed out-retrying"
1530- " relogin (%d)\n",
1531- ha->host_no,
1532- ddb_entry->fw_ddb_index,
1533- atomic_read(&ddb_entry->
1534+ " timed out-retrying"
1535+ " relogin (%d)\n",
1536+ ha->host_no,
1537+ ddb_entry->fw_ddb_index,
1538+ atomic_read(&ddb_entry->
1539 relogin_retry_count))
1540 );
1541 start_dpc++;
1542 DEBUG(printk("scsi%ld:%d:%d: index [%d] "
1543- "initate relogin after"
1544- " %d seconds\n",
1545- ha->host_no, ddb_entry->bus,
1546- ddb_entry->target,
1547- ddb_entry->fw_ddb_index,
1548- ddb_entry->default_time2wait + 4)
1549- );
1550+ "initate relogin after"
1551+ " %d seconds\n",
1552+ ha->host_no, ddb_entry->bus,
1553+ ddb_entry->target,
1554+ ddb_entry->fw_ddb_index,
1555+ ddb_entry->default_time2wait + 4));
1556
1557 atomic_set(&ddb_entry->retry_relogin_timer,
1558- ddb_entry->default_time2wait + 4);
1559+ ddb_entry->default_time2wait + 4);
1560 }
1561 }
1562 }
1563
1564 /* Check for heartbeat interval. */
1565 if (ha->firmware_options & FWOPT_HEARTBEAT_ENABLE &&
1566- ha->heartbeat_interval != 0) {
1567+ ha->heartbeat_interval != 0) {
1568 ha->seconds_since_last_heartbeat++;
1569 if (ha->seconds_since_last_heartbeat >
1570- ha->heartbeat_interval + 2)
1571+ ha->heartbeat_interval + 2)
1572 set_bit(DPC_RESET_HA, &ha->dpc_flags);
1573 }
1574
1575
1576 /* Wakeup the dpc routine for this adapter, if needed. */
1577 if ((start_dpc ||
1578- test_bit(DPC_RESET_HA, &ha->dpc_flags) ||
1579- test_bit(DPC_RETRY_RESET_HA, &ha->dpc_flags) ||
1580- test_bit(DPC_RELOGIN_DEVICE, &ha->dpc_flags) ||
1581- test_bit(DPC_RESET_HA_DESTROY_DDB_LIST, &ha->dpc_flags) ||
1582- test_bit(DPC_RESET_HA_INTR, &ha->dpc_flags) ||
1583- test_bit(DPC_GET_DHCP_IP_ADDR, &ha->dpc_flags) ||
1584- test_bit(DPC_AEN, &ha->dpc_flags)) &&
1585- ha->dpc_thread) {
1586+ test_bit(DPC_RESET_HA, &ha->dpc_flags) ||
1587+ test_bit(DPC_RETRY_RESET_HA, &ha->dpc_flags) ||
1588+ test_bit(DPC_RELOGIN_DEVICE, &ha->dpc_flags) ||
1589+ test_bit(DPC_RESET_HA_DESTROY_DDB_LIST, &ha->dpc_flags) ||
1590+ test_bit(DPC_RESET_HA_INTR, &ha->dpc_flags) ||
1591+ test_bit(DPC_GET_DHCP_IP_ADDR, &ha->dpc_flags) ||
1592+ QL_DPC_OFFLINE_SET(ha) ||
1593+ test_bit(DPC_AEN, &ha->dpc_flags)) &&
1594+ ha->dpc_thread) {
1595 DEBUG2(printk("scsi%ld: %s: scheduling dpc routine"
1596- " - dpc flags = 0x%lx\n",
1597- ha->host_no, __func__, ha->dpc_flags));
1598+ " - dpc flags = 0x%lx\n",
1599+ ha->host_no, __func__, ha->dpc_flags));
1600 queue_work(ha->dpc_thread, &ha->dpc_work);
1601 }
1602
1603@@ -732,14 +739,15 @@ static int qla4xxx_cmd_wait(struct scsi_
1604 return stat;
1605 }
1606
1607-void qla4xxx_hw_reset(struct scsi_qla_host *ha)
1608+void qla4xxx_hw_reset(struct scsi_qla_host *ha, int hw_lock)
1609 {
1610 uint32_t ctrl_status;
1611 unsigned long flags = 0;
1612
1613 DEBUG2(printk(KERN_ERR "scsi%ld: %s\n", ha->host_no, __func__));
1614
1615- spin_lock_irqsave(&ha->hardware_lock, flags);
1616+ if (hw_lock)
1617+ spin_lock_irqsave(&ha->hardware_lock, flags);
1618 /*
1619 * If the SCSI Reset Interrupt bit is set, clear it.
1620 * Otherwise, the Soft Reset won't work.
1621@@ -752,7 +760,8 @@ void qla4xxx_hw_reset(struct scsi_qla_ho
1622 writel(set_rmask(CSR_SOFT_RESET), &ha->reg->ctrl_status);
1623 readl(&ha->reg->ctrl_status);
1624
1625- spin_unlock_irqrestore(&ha->hardware_lock, flags);
1626+ if (hw_lock)
1627+ spin_unlock_irqrestore(&ha->hardware_lock, flags);
1628 }
1629
1630 /**
1631@@ -766,7 +775,7 @@ int qla4xxx_soft_reset(struct scsi_qla_h
1632 int status = QLA_ERROR;
1633 uint32_t ctrl_status;
1634
1635- qla4xxx_hw_reset(ha);
1636+ qla4xxx_hw_reset(ha, 1);
1637
1638 /* Wait until the Network Reset Intr bit is cleared */
1639 max_wait_time = RESET_INTR_TOV;
1640@@ -783,9 +792,9 @@ int qla4xxx_soft_reset(struct scsi_qla_h
1641
1642 if ((ctrl_status & CSR_NET_RESET_INTR) != 0) {
1643 DEBUG2(printk(KERN_WARNING
1644- "scsi%ld: Network Reset Intr not cleared by "
1645- "Network function, clearing it now!\n",
1646- ha->host_no));
1647+ "scsi%ld: Network Reset Intr not cleared by "
1648+ "Network function, clearing it now!\n",
1649+ ha->host_no));
1650 spin_lock_irqsave(&ha->hardware_lock, flags);
1651 writel(set_rmask(CSR_NET_RESET_INTR), &ha->reg->ctrl_status);
1652 readl(&ha->reg->ctrl_status);
82094b55 1653@@ -887,8 +896,7 @@ static int qla4xxx_recover_adapter(struc
2cb7cef9
BS
1654
1655 /* Stall incoming I/O until we are done */
1656 clear_bit(AF_ONLINE, &ha->flags);
1657- DEBUG2(printk("scsi%ld: %s calling qla4xxx_cmd_wait\n", ha->host_no,
1658- __func__));
1659+ dev_info(&ha->pdev->dev, "%s: adapter OFFLINE\n", __func__);
1660
1661 /* Wait for outstanding commands to complete.
1662 * Stalls the driver for max 30 secs
1663@@ -905,7 +913,7 @@ static int qla4xxx_recover_adapter(struc
1664 */
1665 if (status == QLA_SUCCESS) {
1666 DEBUG2(printk(KERN_ERR "scsi%ld: %s - Performing soft reset..\n",
1667- ha->host_no, __func__));
1668+ ha->host_no, __func__));
1669 qla4xxx_flush_active_srbs(ha);
1670 if (ql4xxx_lock_drvr_wait(ha) == QLA_SUCCESS)
1671 status = qla4xxx_soft_reset(ha);
1672@@ -920,24 +928,26 @@ static int qla4xxx_recover_adapter(struc
1673 * with ISP interrupts enabled */
1674 if (status == QLA_SUCCESS) {
1675 DEBUG2(printk("scsi%ld: %s - Initializing adapter..\n",
1676- ha->host_no, __func__));
1677+ ha->host_no, __func__));
1678
1679 /* If successful, AF_ONLINE flag set in
1680 * qla4xxx_initialize_adapter */
1681+ if (ha->mac_index == 3)
1682+ ssleep(6);
1683 status = qla4xxx_initialize_adapter(ha, PRESERVE_DDB_LIST);
1684 }
1685
1686 /* Failed adapter initialization?
1687 * Retry reset_ha only if invoked via DPC (DPC_RESET_HA) */
1688 if ((test_bit(AF_ONLINE, &ha->flags) == 0) &&
1689- (test_bit(DPC_RESET_HA, &ha->dpc_flags))) {
1690+ (test_bit(DPC_RESET_HA, &ha->dpc_flags))) {
1691 /* Adapter initialization failed, see if we can retry
1692 * resetting the ha */
1693 if (!test_bit(DPC_RETRY_RESET_HA, &ha->dpc_flags)) {
1694 ha->retry_reset_ha_cnt = MAX_RESET_HA_RETRIES;
1695 DEBUG2(printk("scsi%ld: recover adapter - retrying "
1696- "(%d) more times\n", ha->host_no,
1697- ha->retry_reset_ha_cnt));
1698+ "(%d) more times\n", ha->host_no,
1699+ ha->retry_reset_ha_cnt));
1700 set_bit(DPC_RETRY_RESET_HA, &ha->dpc_flags);
1701 status = QLA_ERROR;
1702 } else {
1703@@ -945,9 +955,9 @@ static int qla4xxx_recover_adapter(struc
1704 /* Schedule another Reset HA--DPC will retry */
1705 ha->retry_reset_ha_cnt--;
1706 DEBUG2(printk("scsi%ld: recover adapter - "
1707- "retry remaining %d\n",
1708- ha->host_no,
1709- ha->retry_reset_ha_cnt));
1710+ "retry remaining %d\n",
1711+ ha->host_no,
1712+ ha->retry_reset_ha_cnt));
1713 status = QLA_ERROR;
1714 }
1715
1716@@ -955,8 +965,8 @@ static int qla4xxx_recover_adapter(struc
1717 /* Recover adapter retries have been exhausted.
1718 * Adapter DEAD */
1719 DEBUG2(printk("scsi%ld: recover adapter "
1720- "failed - board disabled\n",
1721- ha->host_no));
1722+ "failed - board disabled\n",
1723+ ha->host_no));
1724 qla4xxx_flush_active_srbs(ha);
1725 clear_bit(DPC_RETRY_RESET_HA, &ha->dpc_flags);
1726 clear_bit(DPC_RESET_HA, &ha->dpc_flags);
1727@@ -991,10 +1001,9 @@ static int qla4xxx_recover_adapter(struc
1728 * the mid-level tries to sleep when it reaches the driver threshold
1729 * "host->can_queue". This can cause a panic if we were in our interrupt code.
1730 **/
1731-static void qla4xxx_do_dpc(struct work_struct *work)
1732+static QL_DECLARE_DPC(qla4xxx_do_dpc, data)
1733 {
1734- struct scsi_qla_host *ha =
1735- container_of(work, struct scsi_qla_host, dpc_work);
1736+ struct scsi_qla_host *ha = QL_DPC_DATA_TO_HA(data);
1737 struct ddb_entry *ddb_entry, *dtemp;
1738 int status = QLA_ERROR;
1739
1740@@ -1009,11 +1018,11 @@ static void qla4xxx_do_dpc(struct work_s
1741 return;
1742
1743 if (adapter_up(ha) ||
1744- test_bit(DPC_RESET_HA, &ha->dpc_flags) ||
1745- test_bit(DPC_RESET_HA_INTR, &ha->dpc_flags) ||
1746- test_bit(DPC_RESET_HA_DESTROY_DDB_LIST, &ha->dpc_flags)) {
1747+ test_bit(DPC_RESET_HA, &ha->dpc_flags) ||
1748+ test_bit(DPC_RESET_HA_INTR, &ha->dpc_flags) ||
1749+ test_bit(DPC_RESET_HA_DESTROY_DDB_LIST, &ha->dpc_flags)) {
1750 if (test_bit(DPC_RESET_HA_DESTROY_DDB_LIST, &ha->dpc_flags) ||
1751- test_bit(DPC_RESET_HA, &ha->dpc_flags))
1752+ test_bit(DPC_RESET_HA, &ha->dpc_flags))
1753 qla4xxx_recover_adapter(ha);
1754
1755 if (test_bit(DPC_RESET_HA_INTR, &ha->dpc_flags)) {
82094b55 1756@@ -1025,10 +1034,11 @@ static void qla4xxx_do_dpc(struct work_s
2cb7cef9
BS
1757 break;
1758 msleep(1000);
1759 }
1760+
1761 if (wait_time == 0)
1762 DEBUG2(printk("scsi%ld: %s: SR|FSR "
1763- "bit not cleared-- resetting\n",
1764- ha->host_no, __func__));
1765+ "bit not cleared-- resetting\n",
1766+ ha->host_no, __func__));
1767 qla4xxx_flush_active_srbs(ha);
1768 if (ql4xxx_lock_drvr_wait(ha) == QLA_SUCCESS) {
1769 qla4xxx_process_aen(ha, FLUSH_DDB_CHANGED_AENS);
2cb7cef9
BS
1770@@ -1049,13 +1059,42 @@ static void qla4xxx_do_dpc(struct work_s
1771 if (test_and_clear_bit(DPC_GET_DHCP_IP_ADDR, &ha->dpc_flags))
1772 qla4xxx_get_dhcp_ip_address(ha);
1773
1774+ qla4xxx_check_dev_offline(ha);
1775+
1776+ if (test_and_clear_bit(DPC_DELETE_DEVICE, &ha->dpc_flags)) {
1777+ list_for_each_entry_safe(ddb_entry, dtemp,
1778+ &ha->ddb_list, list) {
1779+ if (test_and_clear_bit(DF_DELETED,
1780+ &ddb_entry->flags)) {
1781+ if (atomic_read(&ddb_entry->state) ==
1782+ DDB_STATE_DEAD) {
1783+ dev_info(&ha->pdev->dev,
1784+ "%s: ddb[%d] os[%d] - "
1785+ "delete\n",
1786+ __func__,
1787+ ddb_entry->fw_ddb_index,
1788+ ddb_entry->os_target_id);
1789+ } else {
1790+ dev_info(&ha->pdev->dev,
1791+ "%s: ddb[%d] os[%d] - "
1792+ "ddb state not dead but"
1793+ " marked for delete\n",
1794+ __func__,
1795+ ddb_entry->fw_ddb_index,
1796+ ddb_entry->os_target_id);
1797+ }
1798+ }
1799+ }
1800+ }
1801+
1802 /* ---- relogin device? --- */
1803 if (adapter_up(ha) &&
1804- test_and_clear_bit(DPC_RELOGIN_DEVICE, &ha->dpc_flags)) {
1805+ test_and_clear_bit(DPC_RELOGIN_DEVICE, &ha->dpc_flags)) {
1806 list_for_each_entry_safe(ddb_entry, dtemp,
1807 &ha->ddb_list, list) {
1808 if (test_and_clear_bit(DF_RELOGIN, &ddb_entry->flags) &&
1809- atomic_read(&ddb_entry->state) != DDB_STATE_ONLINE)
1810+ (atomic_read(&ddb_entry->state) !=
1811+ DDB_STATE_ONLINE))
1812 qla4xxx_relogin_device(ha, ddb_entry);
1813
1814 /*
82094b55 1815@@ -1092,7 +1131,7 @@ static void qla4xxx_free_adapter(struct
2cb7cef9
BS
1816
1817 /* Issue Soft Reset to put firmware in unknown state */
1818 if (ql4xxx_lock_drvr_wait(ha) == QLA_SUCCESS)
1819- qla4xxx_hw_reset(ha);
1820+ qla4xxx_hw_reset(ha, 1);
1821
1822 /* Remove timer thread, if present */
1823 if (ha->timer_active)
1824@@ -1142,6 +1181,7 @@ static int qla4xxx_iospace_config(struct
1825 if (!(mmio_flags & IORESOURCE_MEM)) {
1826 dev_err(&ha->pdev->dev,
1827 "region #0 not an MMIO resource, aborting\n");
1828+
1829 goto iospace_error_exit;
1830 }
1831 if (mmio_len < MIN_IOBASE_LEN) {
1832@@ -1173,14 +1213,6 @@ iospace_error_exit:
1833 return -ENOMEM;
1834 }
1835
1836-static void ql4_get_aen_log(struct scsi_qla_host *ha, struct ql4_aen_log *aenl)
1837-{
1838- if (aenl) {
1839- memcpy(aenl, &ha->aen_log, sizeof (ha->aen_log));
1840- ha->aen_log.count = 0;
1841- }
1842-}
1843-
1844 /**
1845 * qla4xxx_probe_adapter - callback function to probe HBA
1846 * @pdev: pointer to pci_dev structure
1847@@ -1191,7 +1223,7 @@ static void ql4_get_aen_log(struct scsi_
1848 * the driver.
1849 **/
1850 static int __devinit qla4xxx_probe_adapter(struct pci_dev *pdev,
1851- const struct pci_device_id *ent)
1852+ const struct pci_device_id *ent)
1853 {
1854 int ret = -ENODEV, status;
1855 struct Scsi_Host *host;
1856@@ -1206,7 +1238,7 @@ static int __devinit qla4xxx_probe_adapt
1857 host = scsi_host_alloc(&qla4xxx_driver_template, sizeof(*ha));
1858 if (host == NULL) {
1859 printk(KERN_WARNING
1860- "qla4xxx: Couldn't allocate host from scsi layer!\n");
1861+ "qla4xxx: Couldn't allocate host from scsi layer!\n");
1862 goto probe_disable_device;
1863 }
1864
1865@@ -1218,10 +1250,7 @@ static int __devinit qla4xxx_probe_adapt
1866 ha->pdev = pdev;
1867 ha->host = host;
1868 ha->host_no = host->host_no;
1869-
1870- ha->ql4mbx = qla4xxx_mailbox_command;
1871- ha->ql4cmd = qla4xxx_send_command_to_isp;
1872- ha->ql4getaenlog = ql4_get_aen_log;
1873+ set_bit(AF_OS_INDEX_VALID, &ha->flags);
1874
1875 /* Configure PCI I/O space. */
1876 ret = qla4xxx_iospace_config(ha);
1877@@ -1229,7 +1258,7 @@ static int __devinit qla4xxx_probe_adapt
1878 goto probe_failed;
1879
1880 dev_info(&ha->pdev->dev, "Found an ISP%04x, irq %d, iobase 0x%p\n",
1881- pdev->device, pdev->irq, ha->reg);
1882+ pdev->device, pdev->irq, ha->reg);
1883
1884 qla4xxx_config_dma_addressing(ha);
1885
1886@@ -1245,7 +1274,7 @@ static int __devinit qla4xxx_probe_adapt
1887 /* Allocate dma buffers */
1888 if (qla4xxx_mem_alloc(ha)) {
1889 dev_warn(&ha->pdev->dev,
1890- "[ERROR] Failed to allocate memory for adapter\n");
1891+ "[ERROR] Failed to allocate memory for adapter\n");
1892
1893 ret = -ENOMEM;
1894 goto probe_failed;
1895@@ -1258,8 +1287,8 @@ static int __devinit qla4xxx_probe_adapt
1896 */
1897 status = qla4xxx_initialize_adapter(ha, REBUILD_DDB_LIST);
1898 while (status == QLA_ERROR && init_retry_count++ < MAX_INIT_RETRIES) {
1899- DEBUG2(printk(KERN_ERR "scsi%ld: %s: retrying adapter initialization "
1900- "(%d)\n", ha->host_no, __func__, init_retry_count));
1901+ DEBUG2(dev_info(&ha->pdev->dev, "%s: retry adapter init %d\n",
1902+ __func__, init_retry_count));
1903 qla4xxx_soft_reset(ha);
1904 status = qla4xxx_initialize_adapter(ha, REBUILD_DDB_LIST);
1905 }
1906@@ -1280,7 +1309,7 @@ static int __devinit qla4xxx_probe_adapt
1907
1908 /* Startup the kernel thread for this host adapter. */
1909 DEBUG2(printk("scsi: %s: Starting kernel thread for "
1910- "qla4xxx_dpc\n", __func__));
1911+ "qla4xxx_dpc\n", __func__));
1912 sprintf(buf, "qla4xxx_%lu_dpc", ha->host_no);
1913 ha->dpc_thread = create_singlethread_workqueue(buf);
1914 if (!ha->dpc_thread) {
1915@@ -1288,9 +1317,11 @@ static int __devinit qla4xxx_probe_adapt
1916 ret = -ENODEV;
1917 goto probe_failed;
1918 }
1919- INIT_WORK(&ha->dpc_work, qla4xxx_do_dpc);
1920+ QL_INIT_WORK(ha, qla4xxx_do_dpc);
1921+
1922 ret = request_irq(pdev->irq, qla4xxx_intr_handler,
1923- IRQF_DISABLED | IRQF_SHARED, "qla4xxx", ha);
1924+ QL_REQ_IRQ_FLAGS, "qla4xxx", ha);
1925+
1926 if (ret) {
1927 dev_warn(&ha->pdev->dev, "Failed to reserve interrupt %d"
1928 " already in use.\n", pdev->irq);
1929@@ -1298,7 +1329,7 @@ static int __devinit qla4xxx_probe_adapt
1930 }
1931 set_bit(AF_IRQ_ATTACHED, &ha->flags);
1932 host->irq = pdev->irq;
1933- DEBUG(printk("scsi%d: irq %d attached\n", ha->host_no, ha->pdev->irq));
1934+ dev_info(&ha->pdev->dev, "irq %d attached\n", ha->pdev->irq);
1935
1936 qla4xxx_enable_intrs(ha);
1937
1938@@ -1313,6 +1344,9 @@ static int __devinit qla4xxx_probe_adapt
1939 if (ret)
1940 goto probe_failed;
1941
1942+ if ((ret = QL_ISCSI_REGISTER_HOST(host, qla4xxx_scsi_transport)))
1943+ goto remove_host;
1944+
1945 /* Update transport device information for all devices. */
1946 list_for_each_entry_safe(ddb_entry, ddbtemp, &ha->ddb_list, list) {
1947
1948@@ -1320,25 +1354,36 @@ static int __devinit qla4xxx_probe_adapt
1949 set_bit(DF_SCAN_ISSUED, &ddb_entry->flags);
1950
1951 if (qla4xxx_add_sess(ddb_entry,
1952- test_bit(DF_SCAN_ISSUED, &ddb_entry->flags)))
1953+ test_bit(DF_SCAN_ISSUED, &ddb_entry->flags))) {
1954+ QL_ISCSI_UNREGISTER_HOST(host, qla4xxx_scsi_transport);
1955 goto remove_host;
1956+ }
1957 if (!test_bit(DF_SCAN_ISSUED, &ddb_entry->flags))
1958 qla4xxx_mark_device_missing(ha, ddb_entry);
1959 }
1960
1961- printk(KERN_INFO
1962- " QLogic iSCSI HBA Driver version: %s\n"
1963- " QLogic ISP%04x @ %s, pdev = %p host#=%ld, fw=%02d.%02d.%02d.%02d\n",
1964- qla4xxx_version_str, ha->pdev->device, pci_name(ha->pdev), pdev,
1965- ha->host_no, ha->firmware_version[0], ha->firmware_version[1],
1966- ha->patch_number, ha->build_number);
1967+ dev_info(&ha->pdev->dev, " QLogic iSCSI HBA Driver version: %s\n"
1968+ " QLogic ISP%04x @ %s, pdev = %p host#=%ld,"
1969+ " fw=%02d.%02d.%02d.%02d\n", qla4xxx_version_str,
1970+ ha->pdev->device, pci_name(ha->pdev), pdev,
1971+ ha->host_no, ha->firmware_version[0], ha->firmware_version[1],
1972+ ha->patch_number, ha->build_number);
1973
1974 /* Insert new entry into the list of adapters. */
1975 klist_add_tail(&ha->node, &qla4xxx_hostlist);
1976 ha->instance = atomic_inc_return(&qla4xxx_hba_count) - 1;
1977
1978- DEBUG2(printk("qla4xxx: listhead=%p, done adding ha=%p i=%d\n",
1979- &qla4xxx_hostlist, &ha->node, ha->instance));
1980+ if (qla4xxx_ioctl_init(ha)) {
1981+ dev_info(&ha->pdev->dev, "ioctl init failed\n");
1982+ QL_ISCSI_UNREGISTER_HOST(host, qla4xxx_scsi_transport);
1983+ goto remove_host;
1984+ }
1985+
1986+ DEBUG2(dev_info(&ha->pdev->dev, "listhead=%p, done adding ha=%p i=%d\n",
1987+ &qla4xxx_hostlist, &ha->node, ha->instance));
1988+
1989+// set_bit(AF_INIT_DONE, &ha->flags);
1990+ dev_info(&ha->pdev->dev, "%s: AF_INIT_DONE\n", __func__);
1991
1992 return 0;
1993
1994@@ -1377,8 +1422,12 @@ static void __devexit qla4xxx_remove_ada
1995 /* remove devs from iscsi_sessions to scsi_devices */
1996 qla4xxx_free_ddb_list(ha);
1997
1998+ QL_ISCSI_UNREGISTER_HOST(ha->host, qla4xxx_scsi_transport);
1999+
2000 scsi_remove_host(ha->host);
2001
2002+ qla4xxx_ioctl_exit(ha);
2003+
2004 qla4xxx_free_adapter(ha);
2005
2006 scsi_host_put(ha->host);
2007@@ -1393,7 +1442,7 @@ static void __devexit qla4xxx_remove_ada
2008 * At exit, the @ha's flags.enable_64bit_addressing set to indicated
2009 * supported addressing method.
2010 */
2011-static void qla4xxx_config_dma_addressing(struct scsi_qla_host *ha)
2012+void qla4xxx_config_dma_addressing(struct scsi_qla_host *ha)
2013 {
2014 int retval;
2015
2016@@ -1402,9 +1451,9 @@ static void qla4xxx_config_dma_addressin
2017 if (pci_set_consistent_dma_mask(ha->pdev, DMA_64BIT_MASK)) {
2018 dev_dbg(&ha->pdev->dev,
2019 "Failed to set 64 bit PCI consistent mask; "
2020- "using 32 bit.\n");
2021+ "using 32 bit.\n");
2022 retval = pci_set_consistent_dma_mask(ha->pdev,
2023- DMA_32BIT_MASK);
2024+ DMA_32BIT_MASK);
2025 }
2026 } else
2027 retval = pci_set_dma_mask(ha->pdev, DMA_32BIT_MASK);
2028@@ -1412,7 +1461,7 @@ static void qla4xxx_config_dma_addressin
2029
2030 static int qla4xxx_slave_alloc(struct scsi_device *sdev)
2031 {
2032- struct iscsi_cls_session *sess = starget_to_session(sdev->sdev_target);
2033+ struct iscsi_cls_session *sess = QL_ISCSI_SDEV_TO_SESS(sdev);
2034
2035 if (sess) {
2036 sdev->hostdata = sess->dd_data;
2037@@ -1431,6 +1480,11 @@ static int qla4xxx_slave_configure(struc
2038 return 0;
2039 }
2040
2041+static void qla4xxx_slave_destroy(struct scsi_device *sdev)
2042+{
2043+ sdev->hostdata = NULL;
2044+}
2045+
2046 /**
2047 * qla4xxx_del_from_active_array - returns an active srb
2048 * @ha: Pointer to host adapter structure.
2049@@ -1470,7 +1524,7 @@ struct srb * qla4xxx_del_from_active_arr
2050 * for some max time.
2051 **/
2052 static int qla4xxx_eh_wait_on_command(struct scsi_qla_host *ha,
2053- struct scsi_cmnd *cmd)
2054+ struct scsi_cmnd *cmd)
2055 {
2056 int done = 0;
2057 struct srb *rp;
2058@@ -1564,8 +1618,8 @@ static int qla4xxx_eh_device_reset(struc
2059 return ret;
2060
2061 dev_info(&ha->pdev->dev,
2062- "scsi%ld:%d:%d:%d: DEVICE RESET ISSUED.\n", ha->host_no,
2063- cmd->device->channel, cmd->device->id, cmd->device->lun);
2064+ "%s: %d:%d:%d: DEVICE RESET ISSUED.\n", __func__,
2065+ cmd->device->channel, cmd->device->id, cmd->device->lun);
2066
2067 if (qla4xxx_wait_for_hba_online(ha) != QLA_SUCCESS) {
2068 dev_info(&ha->pdev->dev, "%s: HBA OFFLINE: FAILED\n", __func__);
2069@@ -1584,12 +1638,12 @@ static int qla4xxx_eh_device_reset(struc
2070 */
2071 if (cmd->device->host->shost_state == SHOST_RECOVERY) {
2072 if (qla4xxx_eh_wait_for_active_target_commands(ha,
2073- cmd->device->id,
2074- cmd->device->
2075- lun)) {
2076+ cmd->device->id,
2077+ cmd->device->
2078+ lun)) {
2079 dev_info(&ha->pdev->dev,
2080- "DEVICE RESET FAILED - waiting for "
2081- "commands.\n");
2082+ "DEVICE RESET FAILED - waiting for "
2083+ "commands.\n");
2084 goto eh_dev_reset_done;
2085 }
2086 }
2087@@ -1598,9 +1652,9 @@ static int qla4xxx_eh_device_reset(struc
2088 goto eh_dev_reset_done;
2089
2090 dev_info(&ha->pdev->dev,
2091- "scsi(%ld:%d:%d:%d): DEVICE RESET SUCCEEDED.\n",
2092- ha->host_no, cmd->device->channel, cmd->device->id,
2093- cmd->device->lun);
2094+ "scsi(%ld:%d:%d:%d): DEVICE RESET SUCCEEDED.\n",
2095+ ha->host_no, cmd->device->channel, cmd->device->id,
2096+ cmd->device->lun);
2097
2098 ret = SUCCESS;
2099
82094b55 2100@@ -1635,7 +1689,7 @@ static int qla4xxx_eh_host_reset(struct
2cb7cef9
BS
2101 }
2102
2103 dev_info(&ha->pdev->dev, "HOST RESET %s.\n",
2104- return_status == FAILED ? "FAILED" : "SUCCEDED");
2105+ return_status == FAILED ? "FAILED" : "SUCCEDED");
2106
2107 return return_status;
2108 }
2109@@ -1664,7 +1718,7 @@ static struct pci_device_id qla4xxx_pci_
2110 };
2111 MODULE_DEVICE_TABLE(pci, qla4xxx_pci_tbl);
2112
2113-static struct pci_driver qla4xxx_pci_driver = {
2114+struct pci_driver qla4xxx_pci_driver = {
2115 .name = DRIVER_NAME,
2116 .id_table = qla4xxx_pci_tbl,
2117 .probe = qla4xxx_probe_adapter,
2118@@ -1678,12 +1732,11 @@ static int __init qla4xxx_module_init(vo
2119 atomic_set(&qla4xxx_hba_count, 0);
2120 klist_init(&qla4xxx_hostlist, NULL, NULL);
2121 /* Allocate cache for SRBs. */
2122- srb_cachep = kmem_cache_create("qla4xxx_srbs", sizeof(struct srb), 0,
2123- SLAB_HWCACHE_ALIGN, NULL);
2124+ srb_cachep = ql_kmem_cache_create();
2125+
2126 if (srb_cachep == NULL) {
2127- printk(KERN_ERR
2128- "%s: Unable to allocate SRB cache..."
2129- "Failing load!\n", DRIVER_NAME);
2130+ printk(KERN_ERR "%s: Unable to allocate SRB cache..."
2131+ "Failing load!\n", DRIVER_NAME);
2132 ret = -ENOMEM;
2133 goto no_srp_cache;
2134 }
2135@@ -1700,7 +1753,14 @@ static int __init qla4xxx_module_init(vo
2136 goto release_srb_cache;
2137 }
2138
2139+ ret = QL_MISC_INIT;
2140+ if (ret) {
2141+ printk(KERN_INFO "QLogic iSCSI HBA Driver ioctl init failed\n");
2142+ goto unregister_transport;
2143+ }
2144+
2145 printk(KERN_INFO "QLogic iSCSI HBA Driver\n");
2146+
2147 ret = pci_register_driver(&qla4xxx_pci_driver);
2148 if (ret)
2149 goto unregister_transport;
2150@@ -1718,6 +1778,9 @@ no_srp_cache:
2151 static void __exit qla4xxx_module_exit(void)
2152 {
2153 ql4_mod_unload = 1;
2154+
2155+ QL_MISC_EXIT;
2156+
2157 pci_unregister_driver(&qla4xxx_pci_driver);
2158 iscsi_unregister_transport(&qla4xxx_iscsi_transport);
2159 kmem_cache_destroy(srb_cachep);
2160--- /dev/null
2161+++ b/drivers/scsi/qla4xxx/ql4_os.h
2162@@ -0,0 +1,125 @@
2163+/*
2164+ * QLogic iSCSI HBA Driver
2165+ * Copyright (c) 2003-2006 QLogic Corporation
2166+ *
2167+ * See LICENSE.qla4xxx for copyright and licensing details.
2168+ */
2169+
2170+/*
2171+ * This file encapsulates RHEL5 Specific Code
2172+ */
2173+
2174+#ifndef __QLA4x_OS_H
2175+#define __QLA4x_OS_H
2176+
2177+/* Common across all O.S platforms */
2178+#define IOCB_CMD_TIMEOUT 30
2179+#define RELOGIN_TOV 18
2180+#define RECOVERY_TIMEOUT 20 /* ddb state MISSING -> DEAD */
2181+
2182+#define QL_IOCB_CMD_TIMEOUT(cmd)
2183+
2184+#define QL_SET_DDB_OFFLINE(ha, ddb_entry)
2185+
2186+#define QL_SESS_RECOVERY_TO(ddb_entry) ddb_entry->ha->port_down_retry_count
2187+
2188+#define QL_DPC_OFFLINE_SET(ha) 0
2189+
2190+#define QL_ISCSI_CONN_TO_SESS(conn) iscsi_dev_to_session(conn->dev.parent)
2191+
2192+#define QL_ISCSI_SDEV_TO_SESS(sdev) starget_to_session(sdev->sdev_target)
2193+
2194+#define QL_ISCSI_ADD_SESS(ddb_entry) \
2195+ iscsi_add_session(ddb_entry->sess, ddb_entry->os_target_id)
2196+
2197+#define QL_ISCSI_REGISTER_HOST(host, trans) 0
2198+#define QL_ISCSI_UNREGISTER_HOST(host, trans)
2199+
2200+#define QL_ISCSI_SESSION_ID(ddb_entry) ddb_entry->sess->sid
2201+#define QL_ISCSI_IF_DESTROY_SESSION_DONE(ddb_entry)
2202+#define QL_ISCSI_DESTROY_CONN(ddb_entry)
2203+#define QL_ISCSI_CREATE_CONN(ddb_entry) \
2204+ iscsi_create_conn(ddb_entry->sess, 0, 0)
2205+#define QL_ISCSI_CREATE_SESS_DONE(ddb_entry) \
2206+ iscsi_unblock_session(ddb_entry->sess)
2207+#define QL_ISCSI_ALLOC_SESSION(ha, trans) \
2208+ iscsi_alloc_session(ha->host, trans, sizeof(struct ddb_entry))
2209+
2210+
2211+#define QL_MISC_INIT 0
2212+#define QL_MISC_EXIT
2213+
2214+#define qla4xxx_check_dev_offline(ha)
2215+#define qla4xxx_proc_info NULL
2216+
2217+#define QL_SET_SCSI_RESID(cmd, residual) scsi_set_resid(cmd, residual)
2218+#define QL_SCSI_BUFFLEN(cmd) scsi_bufflen(cmd)
2219+
2220+#define QL_DPC_DATA_TO_HA(work) \
2221+ container_of((struct work_struct *)work, struct scsi_qla_host, dpc_work)
2222+
2223+#define QL_INIT_WORK(ha, dpc_func) INIT_WORK(&ha->dpc_work, dpc_func)
2224+
2225+#define QL_REQ_IRQ_FLAGS (IRQF_DISABLED | IRQF_SHARED)
2226+
2227+#define QL_DECLARE_INTR_HANDLER(intr_func, irq, dev_id, regs) \
2228+ irqreturn_t intr_func(int irq, void *dev_id)
2229+
2230+#define QL_DECLARE_DPC(dpc_func, data) \
2231+ void dpc_func(struct work_struct *data)
2232+
2233+#define QL_INIT_SESSION_DATASIZE(sessiondata_size)
2234+// .sessiondata_size = sizeof(struct ddb_entry),
2235+
2236+#define QL_INIT_HOST_TEMPLATE(host_template)
2237+// .host_template = &qla4xxx_driver_template,
2238+
2239+QL_DECLARE_INTR_HANDLER(qla4xxx_intr_handler, irq, dev_id, regs);
2240+
2241+static inline struct kmem_cache *ql_kmem_cache_create(void)
2242+{
2243+ return (kmem_cache_create("qla4xxx_srbs", sizeof(struct srb), 0,
2244+ SLAB_HWCACHE_ALIGN, NULL));
2245+}
2246+
2247+static inline void qla4xxx_scan_target(struct ddb_entry * ddb_entry)
2248+{
2249+ scsi_scan_target(&ddb_entry->sess->dev, 0,
2250+ ddb_entry->sess->target_id, SCAN_WILD_CARD, 0);
2251+}
2252+
2253+static void ql4_get_aen_log(struct scsi_qla_host *ha, struct ql4_aen_log *aenl)
2254+{
2255+ if (aenl) {
2256+ memcpy(aenl, &ha->aen_log, sizeof (ha->aen_log));
2257+ ha->aen_log.count = 0;
2258+ }
2259+}
2260+
2261+static inline int qla4xxx_ioctl_init(struct scsi_qla_host *ha)
2262+{
2263+ ha->ql4mbx = qla4xxx_mailbox_command;
2264+ ha->ql4cmd = qla4xxx_send_command_to_isp;
2265+ ha->ql4getaenlog = ql4_get_aen_log;
2266+ return 0;
2267+}
2268+
2269+static inline void qla4xxx_ioctl_exit(struct scsi_qla_host *ha)
2270+{
2271+ return;
2272+}
2273+
2274+static inline void qla4xxx_srb_free_dma(struct scsi_qla_host *ha,
2275+ struct srb *srb)
2276+{
2277+ struct scsi_cmnd *cmd = srb->cmd;
2278+
2279+ if (srb->flags & SRB_DMA_VALID) {
2280+ scsi_dma_unmap(cmd);
2281+ srb->flags &= ~SRB_DMA_VALID;
2282+ }
2283+
2284+ cmd->SCp.ptr = NULL;
2285+}
2286+
2287+#endif /* _QLA4x_OS_H */
2288--- a/drivers/scsi/qla4xxx/ql4_version.h
2289+++ b/drivers/scsi/qla4xxx/ql4_version.h
2290@@ -5,6 +5,5 @@
2291 * See LICENSE.qla4xxx for copyright and licensing details.
2292 */
2293
2294-#define QLA4XXX_DRIVER_VERSION "5.01.00-k8_sles11-01"
2295-
2296+#define QLA4XXX_DRIVER_VERSION "5.01.00-k8_sles11-03"
2297