blob: 09d6d4b76f39536512b3578142b26a1a0f27bcf8 [file] [log] [blame]
David Somayajuluafaf5a22006-09-19 10:28:00 -07001/*
2 * QLogic iSCSI HBA Driver
3 * Copyright (c) 2003-2006 QLogic Corporation
4 *
5 * See LICENSE.qla4xxx for copyright and licensing details.
6 */
7
8#include "ql4_def.h"
David C Somayajuluc0e344c2007-05-23 18:03:27 -07009#include "ql4_glbl.h"
10#include "ql4_dbg.h"
11#include "ql4_inline.h"
David Somayajuluafaf5a22006-09-19 10:28:00 -070012
13
14/**
15 * qla4xxx_mailbox_command - issues mailbox commands
16 * @ha: Pointer to host adapter structure.
17 * @inCount: number of mailbox registers to load.
18 * @outCount: number of mailbox registers to return.
19 * @mbx_cmd: data pointer for mailbox in registers.
20 * @mbx_sts: data pointer for mailbox out registers.
21 *
22 * This routine sssue mailbox commands and waits for completion.
23 * If outCount is 0, this routine completes successfully WITHOUT waiting
24 * for the mailbox command to complete.
25 **/
Adrian Bunk47975472007-04-26 00:35:16 -070026static int qla4xxx_mailbox_command(struct scsi_qla_host *ha, uint8_t inCount,
27 uint8_t outCount, uint32_t *mbx_cmd,
28 uint32_t *mbx_sts)
David Somayajuluafaf5a22006-09-19 10:28:00 -070029{
30 int status = QLA_ERROR;
31 uint8_t i;
32 u_long wait_count;
33 uint32_t intr_status;
34 unsigned long flags = 0;
David Somayajuluafaf5a22006-09-19 10:28:00 -070035
36 /* Make sure that pointers are valid */
37 if (!mbx_cmd || !mbx_sts) {
38 DEBUG2(printk("scsi%ld: %s: Invalid mbx_cmd or mbx_sts "
39 "pointer\n", ha->host_no, __func__));
David C Somayajulu477ffb92007-01-22 12:26:11 -080040 return status;
41 }
42 /* Mailbox code active */
43 wait_count = MBOX_TOV * 100;
44
45 while (wait_count--) {
46 mutex_lock(&ha->mbox_sem);
47 if (!test_bit(AF_MBOX_COMMAND, &ha->flags)) {
48 set_bit(AF_MBOX_COMMAND, &ha->flags);
49 mutex_unlock(&ha->mbox_sem);
50 break;
51 }
52 mutex_unlock(&ha->mbox_sem);
53 if (!wait_count) {
54 DEBUG2(printk("scsi%ld: %s: mbox_sem failed\n",
55 ha->host_no, __func__));
56 return status;
57 }
58 msleep(10);
David Somayajuluafaf5a22006-09-19 10:28:00 -070059 }
60
61 /* To prevent overwriting mailbox registers for a command that has
62 * not yet been serviced, check to see if a previously issued
63 * mailbox command is interrupting.
64 * -----------------------------------------------------------------
65 */
66 spin_lock_irqsave(&ha->hardware_lock, flags);
67 intr_status = readl(&ha->reg->ctrl_status);
68 if (intr_status & CSR_SCSI_PROCESSOR_INTR) {
69 /* Service existing interrupt */
70 qla4xxx_interrupt_service_routine(ha, intr_status);
71 clear_bit(AF_MBOX_COMMAND_DONE, &ha->flags);
72 }
73
74 /* Send the mailbox command to the firmware */
75 ha->mbox_status_count = outCount;
76 for (i = 0; i < outCount; i++)
77 ha->mbox_status[i] = 0;
78
79 /* Load all mailbox registers, except mailbox 0. */
80 for (i = 1; i < inCount; i++)
81 writel(mbx_cmd[i], &ha->reg->mailbox[i]);
82
83 /* Wakeup firmware */
84 writel(mbx_cmd[0], &ha->reg->mailbox[0]);
85 readl(&ha->reg->mailbox[0]);
86 writel(set_rmask(CSR_INTR_RISC), &ha->reg->ctrl_status);
87 readl(&ha->reg->ctrl_status);
88 spin_unlock_irqrestore(&ha->hardware_lock, flags);
89
90 /* Wait for completion */
David Somayajuluafaf5a22006-09-19 10:28:00 -070091
92 /*
93 * If we don't want status, don't wait for the mailbox command to
94 * complete. For example, MBOX_CMD_RESET_FW doesn't return status,
95 * you must poll the inbound Interrupt Mask for completion.
96 */
97 if (outCount == 0) {
98 status = QLA_SUCCESS;
David Somayajuluafaf5a22006-09-19 10:28:00 -070099 goto mbox_exit;
100 }
101 /* Wait for command to complete */
102 wait_count = jiffies + MBOX_TOV * HZ;
103 while (test_bit(AF_MBOX_COMMAND_DONE, &ha->flags) == 0) {
104 if (time_after_eq(jiffies, wait_count))
105 break;
106
107 spin_lock_irqsave(&ha->hardware_lock, flags);
108 intr_status = readl(&ha->reg->ctrl_status);
109 if (intr_status & INTR_PENDING) {
110 /*
111 * Service the interrupt.
112 * The ISR will save the mailbox status registers
113 * to a temporary storage location in the adapter
114 * structure.
115 */
116 ha->mbox_status_count = outCount;
117 qla4xxx_interrupt_service_routine(ha, intr_status);
118 }
119 spin_unlock_irqrestore(&ha->hardware_lock, flags);
120 msleep(10);
121 }
David Somayajuluafaf5a22006-09-19 10:28:00 -0700122
123 /* Check for mailbox timeout. */
124 if (!test_bit(AF_MBOX_COMMAND_DONE, &ha->flags)) {
125 DEBUG2(printk("scsi%ld: Mailbox Cmd 0x%08X timed out ...,"
126 " Scheduling Adapter Reset\n", ha->host_no,
127 mbx_cmd[0]));
128 ha->mailbox_timeout_count++;
129 mbx_sts[0] = (-1);
130 set_bit(DPC_RESET_HA, &ha->dpc_flags);
131 goto mbox_exit;
132 }
133
134 /*
135 * Copy the mailbox out registers to the caller's mailbox in/out
136 * structure.
137 */
138 spin_lock_irqsave(&ha->hardware_lock, flags);
139 for (i = 0; i < outCount; i++)
140 mbx_sts[i] = ha->mbox_status[i];
141
142 /* Set return status and error flags (if applicable). */
143 switch (ha->mbox_status[0]) {
144 case MBOX_STS_COMMAND_COMPLETE:
145 status = QLA_SUCCESS;
146 break;
147
148 case MBOX_STS_INTERMEDIATE_COMPLETION:
149 status = QLA_SUCCESS;
150 break;
151
152 case MBOX_STS_BUSY:
153 DEBUG2( printk("scsi%ld: %s: Cmd = %08X, ISP BUSY\n",
154 ha->host_no, __func__, mbx_cmd[0]));
155 ha->mailbox_timeout_count++;
156 break;
157
158 default:
159 DEBUG2(printk("scsi%ld: %s: **** FAILED, cmd = %08X, "
160 "sts = %08X ****\n", ha->host_no, __func__,
161 mbx_cmd[0], mbx_sts[0]));
162 break;
163 }
164 spin_unlock_irqrestore(&ha->hardware_lock, flags);
165
166mbox_exit:
David C Somayajulu477ffb92007-01-22 12:26:11 -0800167 mutex_lock(&ha->mbox_sem);
David Somayajuluafaf5a22006-09-19 10:28:00 -0700168 clear_bit(AF_MBOX_COMMAND, &ha->flags);
David Somayajuluafaf5a22006-09-19 10:28:00 -0700169 mutex_unlock(&ha->mbox_sem);
David C Somayajulu477ffb92007-01-22 12:26:11 -0800170 clear_bit(AF_MBOX_COMMAND_DONE, &ha->flags);
David Somayajuluafaf5a22006-09-19 10:28:00 -0700171
172 return status;
173}
174
David Somayajuluafaf5a22006-09-19 10:28:00 -0700175/**
176 * qla4xxx_initialize_fw_cb - initializes firmware control block.
177 * @ha: Pointer to host adapter structure.
178 **/
179int qla4xxx_initialize_fw_cb(struct scsi_qla_host * ha)
180{
181 struct init_fw_ctrl_blk *init_fw_cb;
182 dma_addr_t init_fw_cb_dma;
183 uint32_t mbox_cmd[MBOX_REG_COUNT];
184 uint32_t mbox_sts[MBOX_REG_COUNT];
185 int status = QLA_ERROR;
186
187 init_fw_cb = dma_alloc_coherent(&ha->pdev->dev,
188 sizeof(struct init_fw_ctrl_blk),
189 &init_fw_cb_dma, GFP_KERNEL);
190 if (init_fw_cb == NULL) {
191 DEBUG2(printk("scsi%ld: %s: Unable to alloc init_cb\n",
192 ha->host_no, __func__));
193 return 10;
194 }
195 memset(init_fw_cb, 0, sizeof(struct init_fw_ctrl_blk));
196
197 /* Get Initialize Firmware Control Block. */
198 memset(&mbox_cmd, 0, sizeof(mbox_cmd));
199 memset(&mbox_sts, 0, sizeof(mbox_sts));
David C Somayajuluc0e344c2007-05-23 18:03:27 -0700200
David Somayajuluafaf5a22006-09-19 10:28:00 -0700201 mbox_cmd[0] = MBOX_CMD_GET_INIT_FW_CTRL_BLOCK;
202 mbox_cmd[2] = LSDW(init_fw_cb_dma);
203 mbox_cmd[3] = MSDW(init_fw_cb_dma);
David C Somayajuluc0e344c2007-05-23 18:03:27 -0700204 mbox_cmd[4] = sizeof(struct init_fw_ctrl_blk);
205
206 if (qla4xxx_mailbox_command(ha, MBOX_REG_COUNT, 1, &mbox_cmd[0], &mbox_sts[0]) !=
David Somayajuluafaf5a22006-09-19 10:28:00 -0700207 QLA_SUCCESS) {
208 dma_free_coherent(&ha->pdev->dev,
209 sizeof(struct init_fw_ctrl_blk),
210 init_fw_cb, init_fw_cb_dma);
211 return status;
212 }
213
214 /* Initialize request and response queues. */
215 qla4xxx_init_rings(ha);
216
217 /* Fill in the request and response queue information. */
David C Somayajuluc0e344c2007-05-23 18:03:27 -0700218 init_fw_cb->pri.rqq_consumer_idx = cpu_to_le16(ha->request_out);
219 init_fw_cb->pri.compq_producer_idx = cpu_to_le16(ha->response_in);
220 init_fw_cb->pri.rqq_len = __constant_cpu_to_le16(REQUEST_QUEUE_DEPTH);
221 init_fw_cb->pri.compq_len = __constant_cpu_to_le16(RESPONSE_QUEUE_DEPTH);
222 init_fw_cb->pri.rqq_addr_lo = cpu_to_le32(LSDW(ha->request_dma));
223 init_fw_cb->pri.rqq_addr_hi = cpu_to_le32(MSDW(ha->request_dma));
224 init_fw_cb->pri.compq_addr_lo = cpu_to_le32(LSDW(ha->response_dma));
225 init_fw_cb->pri.compq_addr_hi = cpu_to_le32(MSDW(ha->response_dma));
226 init_fw_cb->pri.shdwreg_addr_lo =
David Somayajuluafaf5a22006-09-19 10:28:00 -0700227 cpu_to_le32(LSDW(ha->shadow_regs_dma));
David C Somayajuluc0e344c2007-05-23 18:03:27 -0700228 init_fw_cb->pri.shdwreg_addr_hi =
David Somayajuluafaf5a22006-09-19 10:28:00 -0700229 cpu_to_le32(MSDW(ha->shadow_regs_dma));
230
231 /* Set up required options. */
David C Somayajuluc0e344c2007-05-23 18:03:27 -0700232 init_fw_cb->pri.fw_options |=
David Somayajuluafaf5a22006-09-19 10:28:00 -0700233 __constant_cpu_to_le16(FWOPT_SESSION_MODE |
234 FWOPT_INITIATOR_MODE);
David C Somayajuluc0e344c2007-05-23 18:03:27 -0700235 init_fw_cb->pri.fw_options &= __constant_cpu_to_le16(~FWOPT_TARGET_MODE);
David Somayajuluafaf5a22006-09-19 10:28:00 -0700236
237 /* Save some info in adapter structure. */
David C Somayajuluc0e344c2007-05-23 18:03:27 -0700238 ha->firmware_options = le16_to_cpu(init_fw_cb->pri.fw_options);
239 ha->tcp_options = le16_to_cpu(init_fw_cb->pri.ipv4_tcp_opts);
240 ha->heartbeat_interval = init_fw_cb->pri.hb_interval;
241 memcpy(ha->ip_address, init_fw_cb->pri.ipv4_addr,
242 min(sizeof(ha->ip_address), sizeof(init_fw_cb->pri.ipv4_addr)));
243 memcpy(ha->subnet_mask, init_fw_cb->pri.ipv4_subnet,
244 min(sizeof(ha->subnet_mask), sizeof(init_fw_cb->pri.ipv4_subnet)));
245 memcpy(ha->gateway, init_fw_cb->pri.ipv4_gw_addr,
246 min(sizeof(ha->gateway), sizeof(init_fw_cb->pri.ipv4_gw_addr)));
247 memcpy(ha->name_string, init_fw_cb->pri.iscsi_name,
David Somayajuluafaf5a22006-09-19 10:28:00 -0700248 min(sizeof(ha->name_string),
David C Somayajuluc0e344c2007-05-23 18:03:27 -0700249 sizeof(init_fw_cb->pri.iscsi_name)));
250 /*memcpy(ha->alias, init_fw_cb->Alias,
251 min(sizeof(ha->alias), sizeof(init_fw_cb->Alias)));*/
David Somayajuluafaf5a22006-09-19 10:28:00 -0700252
253 /* Save Command Line Paramater info */
David C Somayajuluc0e344c2007-05-23 18:03:27 -0700254 ha->port_down_retry_count = le16_to_cpu(init_fw_cb->pri.conn_ka_timeout);
David Somayajuluafaf5a22006-09-19 10:28:00 -0700255 ha->discovery_wait = ql4xdiscoverywait;
256
257 /* Send Initialize Firmware Control Block. */
David C Somayajuluc0e344c2007-05-23 18:03:27 -0700258 memset(&mbox_cmd, 0, sizeof(mbox_cmd));
259 memset(&mbox_sts, 0, sizeof(mbox_sts));
260
David Somayajuluafaf5a22006-09-19 10:28:00 -0700261 mbox_cmd[0] = MBOX_CMD_INITIALIZE_FIRMWARE;
262 mbox_cmd[1] = 0;
263 mbox_cmd[2] = LSDW(init_fw_cb_dma);
264 mbox_cmd[3] = MSDW(init_fw_cb_dma);
David C Somayajuluc0e344c2007-05-23 18:03:27 -0700265 mbox_cmd[4] = sizeof(struct init_fw_ctrl_blk);
266
267 if (qla4xxx_mailbox_command(ha, MBOX_REG_COUNT, 1, &mbox_cmd[0], &mbox_sts[0]) ==
David Somayajuluafaf5a22006-09-19 10:28:00 -0700268 QLA_SUCCESS)
269 status = QLA_SUCCESS;
270 else {
271 DEBUG2(printk("scsi%ld: %s: MBOX_CMD_INITIALIZE_FIRMWARE "
272 "failed w/ status %04X\n", ha->host_no, __func__,
273 mbox_sts[0]));
274 }
275 dma_free_coherent(&ha->pdev->dev, sizeof(struct init_fw_ctrl_blk),
276 init_fw_cb, init_fw_cb_dma);
277
278 return status;
279}
280
281/**
282 * qla4xxx_get_dhcp_ip_address - gets HBA ip address via DHCP
283 * @ha: Pointer to host adapter structure.
284 **/
285int qla4xxx_get_dhcp_ip_address(struct scsi_qla_host * ha)
286{
287 struct init_fw_ctrl_blk *init_fw_cb;
288 dma_addr_t init_fw_cb_dma;
289 uint32_t mbox_cmd[MBOX_REG_COUNT];
290 uint32_t mbox_sts[MBOX_REG_COUNT];
291
292 init_fw_cb = dma_alloc_coherent(&ha->pdev->dev,
293 sizeof(struct init_fw_ctrl_blk),
294 &init_fw_cb_dma, GFP_KERNEL);
295 if (init_fw_cb == NULL) {
296 printk("scsi%ld: %s: Unable to alloc init_cb\n", ha->host_no,
297 __func__);
298 return 10;
299 }
300
301 /* Get Initialize Firmware Control Block. */
302 memset(&mbox_cmd, 0, sizeof(mbox_cmd));
303 memset(&mbox_sts, 0, sizeof(mbox_sts));
David C Somayajuluc0e344c2007-05-23 18:03:27 -0700304
David Somayajuluafaf5a22006-09-19 10:28:00 -0700305 memset(init_fw_cb, 0, sizeof(struct init_fw_ctrl_blk));
306 mbox_cmd[0] = MBOX_CMD_GET_INIT_FW_CTRL_BLOCK;
307 mbox_cmd[2] = LSDW(init_fw_cb_dma);
308 mbox_cmd[3] = MSDW(init_fw_cb_dma);
David C Somayajuluc0e344c2007-05-23 18:03:27 -0700309 mbox_cmd[4] = sizeof(struct init_fw_ctrl_blk);
David Somayajuluafaf5a22006-09-19 10:28:00 -0700310
David C Somayajuluc0e344c2007-05-23 18:03:27 -0700311 if (qla4xxx_mailbox_command(ha, MBOX_REG_COUNT, 1, &mbox_cmd[0], &mbox_sts[0]) !=
David Somayajuluafaf5a22006-09-19 10:28:00 -0700312 QLA_SUCCESS) {
313 DEBUG2(printk("scsi%ld: %s: Failed to get init_fw_ctrl_blk\n",
314 ha->host_no, __func__));
315 dma_free_coherent(&ha->pdev->dev,
316 sizeof(struct init_fw_ctrl_blk),
317 init_fw_cb, init_fw_cb_dma);
318 return QLA_ERROR;
319 }
320
321 /* Save IP Address. */
David C Somayajuluc0e344c2007-05-23 18:03:27 -0700322 memcpy(ha->ip_address, init_fw_cb->pri.ipv4_addr,
323 min(sizeof(ha->ip_address), sizeof(init_fw_cb->pri.ipv4_addr)));
324 memcpy(ha->subnet_mask, init_fw_cb->pri.ipv4_subnet,
325 min(sizeof(ha->subnet_mask), sizeof(init_fw_cb->pri.ipv4_subnet)));
326 memcpy(ha->gateway, init_fw_cb->pri.ipv4_gw_addr,
327 min(sizeof(ha->gateway), sizeof(init_fw_cb->pri.ipv4_gw_addr)));
David Somayajuluafaf5a22006-09-19 10:28:00 -0700328
329 dma_free_coherent(&ha->pdev->dev, sizeof(struct init_fw_ctrl_blk),
330 init_fw_cb, init_fw_cb_dma);
331
332 return QLA_SUCCESS;
333}
334
335/**
336 * qla4xxx_get_firmware_state - gets firmware state of HBA
337 * @ha: Pointer to host adapter structure.
338 **/
339int qla4xxx_get_firmware_state(struct scsi_qla_host * ha)
340{
341 uint32_t mbox_cmd[MBOX_REG_COUNT];
342 uint32_t mbox_sts[MBOX_REG_COUNT];
343
344 /* Get firmware version */
345 memset(&mbox_cmd, 0, sizeof(mbox_cmd));
346 memset(&mbox_sts, 0, sizeof(mbox_sts));
David C Somayajuluc0e344c2007-05-23 18:03:27 -0700347
David Somayajuluafaf5a22006-09-19 10:28:00 -0700348 mbox_cmd[0] = MBOX_CMD_GET_FW_STATE;
David C Somayajuluc0e344c2007-05-23 18:03:27 -0700349
350 if (qla4xxx_mailbox_command(ha, MBOX_REG_COUNT, 4, &mbox_cmd[0], &mbox_sts[0]) !=
David Somayajuluafaf5a22006-09-19 10:28:00 -0700351 QLA_SUCCESS) {
352 DEBUG2(printk("scsi%ld: %s: MBOX_CMD_GET_FW_STATE failed w/ "
353 "status %04X\n", ha->host_no, __func__,
354 mbox_sts[0]));
355 return QLA_ERROR;
356 }
357 ha->firmware_state = mbox_sts[1];
358 ha->board_id = mbox_sts[2];
359 ha->addl_fw_state = mbox_sts[3];
360 DEBUG2(printk("scsi%ld: %s firmware_state=0x%x\n",
361 ha->host_no, __func__, ha->firmware_state);)
362
363 return QLA_SUCCESS;
364}
365
366/**
367 * qla4xxx_get_firmware_status - retrieves firmware status
368 * @ha: Pointer to host adapter structure.
369 **/
370int qla4xxx_get_firmware_status(struct scsi_qla_host * ha)
371{
372 uint32_t mbox_cmd[MBOX_REG_COUNT];
373 uint32_t mbox_sts[MBOX_REG_COUNT];
374
375 /* Get firmware version */
376 memset(&mbox_cmd, 0, sizeof(mbox_cmd));
377 memset(&mbox_sts, 0, sizeof(mbox_sts));
David C Somayajuluc0e344c2007-05-23 18:03:27 -0700378
David Somayajuluafaf5a22006-09-19 10:28:00 -0700379 mbox_cmd[0] = MBOX_CMD_GET_FW_STATUS;
David C Somayajuluc0e344c2007-05-23 18:03:27 -0700380
381 if (qla4xxx_mailbox_command(ha, MBOX_REG_COUNT, 3, &mbox_cmd[0], &mbox_sts[0]) !=
David Somayajuluafaf5a22006-09-19 10:28:00 -0700382 QLA_SUCCESS) {
383 DEBUG2(printk("scsi%ld: %s: MBOX_CMD_GET_FW_STATUS failed w/ "
384 "status %04X\n", ha->host_no, __func__,
385 mbox_sts[0]));
386 return QLA_ERROR;
387 }
David Somayajuluafaf5a22006-09-19 10:28:00 -0700388 return QLA_SUCCESS;
389}
390
391/**
392 * qla4xxx_get_fwddb_entry - retrieves firmware ddb entry
393 * @ha: Pointer to host adapter structure.
394 * @fw_ddb_index: Firmware's device database index
395 * @fw_ddb_entry: Pointer to firmware's device database entry structure
396 * @num_valid_ddb_entries: Pointer to number of valid ddb entries
397 * @next_ddb_index: Pointer to next valid device database index
398 * @fw_ddb_device_state: Pointer to device state
399 **/
400int qla4xxx_get_fwddb_entry(struct scsi_qla_host *ha,
401 uint16_t fw_ddb_index,
402 struct dev_db_entry *fw_ddb_entry,
403 dma_addr_t fw_ddb_entry_dma,
404 uint32_t *num_valid_ddb_entries,
405 uint32_t *next_ddb_index,
406 uint32_t *fw_ddb_device_state,
407 uint32_t *conn_err_detail,
408 uint16_t *tcp_source_port_num,
409 uint16_t *connection_id)
410{
411 int status = QLA_ERROR;
412 uint32_t mbox_cmd[MBOX_REG_COUNT];
413 uint32_t mbox_sts[MBOX_REG_COUNT];
414
415 /* Make sure the device index is valid */
416 if (fw_ddb_index >= MAX_DDB_ENTRIES) {
417 DEBUG2(printk("scsi%ld: %s: index [%d] out of range.\n",
418 ha->host_no, __func__, fw_ddb_index));
419 goto exit_get_fwddb;
420 }
421 memset(&mbox_cmd, 0, sizeof(mbox_cmd));
422 memset(&mbox_sts, 0, sizeof(mbox_sts));
David C Somayajuluc0e344c2007-05-23 18:03:27 -0700423
David Somayajuluafaf5a22006-09-19 10:28:00 -0700424 mbox_cmd[0] = MBOX_CMD_GET_DATABASE_ENTRY;
425 mbox_cmd[1] = (uint32_t) fw_ddb_index;
426 mbox_cmd[2] = LSDW(fw_ddb_entry_dma);
427 mbox_cmd[3] = MSDW(fw_ddb_entry_dma);
David C Somayajuluc0e344c2007-05-23 18:03:27 -0700428 mbox_cmd[4] = sizeof(struct dev_db_entry);
429
430 if (qla4xxx_mailbox_command(ha, MBOX_REG_COUNT, 7, &mbox_cmd[0], &mbox_sts[0]) ==
David Somayajuluafaf5a22006-09-19 10:28:00 -0700431 QLA_ERROR) {
432 DEBUG2(printk("scsi%ld: %s: MBOX_CMD_GET_DATABASE_ENTRY failed"
433 " with status 0x%04X\n", ha->host_no, __func__,
434 mbox_sts[0]));
435 goto exit_get_fwddb;
436 }
437 if (fw_ddb_index != mbox_sts[1]) {
438 DEBUG2(printk("scsi%ld: %s: index mismatch [%d] != [%d].\n",
439 ha->host_no, __func__, fw_ddb_index,
440 mbox_sts[1]));
441 goto exit_get_fwddb;
442 }
443 if (fw_ddb_entry) {
444 dev_info(&ha->pdev->dev, "DDB[%d] MB0 %04x Tot %d Next %d "
445 "State %04x ConnErr %08x %d.%d.%d.%d:%04d \"%s\"\n",
446 fw_ddb_index, mbox_sts[0], mbox_sts[2], mbox_sts[3],
David C Somayajuluc0e344c2007-05-23 18:03:27 -0700447 mbox_sts[4], mbox_sts[5], fw_ddb_entry->ip_addr[0],
448 fw_ddb_entry->ip_addr[1], fw_ddb_entry->ip_addr[2],
449 fw_ddb_entry->ip_addr[3],
450 le16_to_cpu(fw_ddb_entry->port),
451 fw_ddb_entry->iscsi_name);
David Somayajuluafaf5a22006-09-19 10:28:00 -0700452 }
453 if (num_valid_ddb_entries)
454 *num_valid_ddb_entries = mbox_sts[2];
455 if (next_ddb_index)
456 *next_ddb_index = mbox_sts[3];
457 if (fw_ddb_device_state)
458 *fw_ddb_device_state = mbox_sts[4];
459
460 /*
461 * RA: This mailbox has been changed to pass connection error and
462 * details. Its true for ISP4010 as per Version E - Not sure when it
463 * was changed. Get the time2wait from the fw_dd_entry field :
464 * default_time2wait which we call it as minTime2Wait DEV_DB_ENTRY
465 * struct.
466 */
467 if (conn_err_detail)
468 *conn_err_detail = mbox_sts[5];
469 if (tcp_source_port_num)
470 *tcp_source_port_num = (uint16_t) mbox_sts[6] >> 16;
471 if (connection_id)
472 *connection_id = (uint16_t) mbox_sts[6] & 0x00FF;
473 status = QLA_SUCCESS;
474
475exit_get_fwddb:
476 return status;
477}
478
479/**
480 * qla4xxx_set_fwddb_entry - sets a ddb entry.
481 * @ha: Pointer to host adapter structure.
482 * @fw_ddb_index: Firmware's device database index
483 * @fw_ddb_entry: Pointer to firmware's ddb entry structure, or NULL.
484 *
485 * This routine initializes or updates the adapter's device database
486 * entry for the specified device. It also triggers a login for the
487 * specified device. Therefore, it may also be used as a secondary
488 * login routine when a NULL pointer is specified for the fw_ddb_entry.
489 **/
490int qla4xxx_set_ddb_entry(struct scsi_qla_host * ha, uint16_t fw_ddb_index,
491 dma_addr_t fw_ddb_entry_dma)
492{
493 uint32_t mbox_cmd[MBOX_REG_COUNT];
494 uint32_t mbox_sts[MBOX_REG_COUNT];
495
496 /* Do not wait for completion. The firmware will send us an
497 * ASTS_DATABASE_CHANGED (0x8014) to notify us of the login status.
498 */
499 memset(&mbox_cmd, 0, sizeof(mbox_cmd));
500 memset(&mbox_sts, 0, sizeof(mbox_sts));
501
502 mbox_cmd[0] = MBOX_CMD_SET_DATABASE_ENTRY;
503 mbox_cmd[1] = (uint32_t) fw_ddb_index;
504 mbox_cmd[2] = LSDW(fw_ddb_entry_dma);
505 mbox_cmd[3] = MSDW(fw_ddb_entry_dma);
David C Somayajuluc0e344c2007-05-23 18:03:27 -0700506 mbox_cmd[4] = sizeof(struct dev_db_entry);
507
508 return qla4xxx_mailbox_command(ha, MBOX_REG_COUNT, 1, &mbox_cmd[0], &mbox_sts[0]);
David Somayajuluafaf5a22006-09-19 10:28:00 -0700509}
510
David Somayajuluafaf5a22006-09-19 10:28:00 -0700511/**
512 * qla4xxx_get_crash_record - retrieves crash record.
513 * @ha: Pointer to host adapter structure.
514 *
515 * This routine retrieves a crash record from the QLA4010 after an 8002h aen.
516 **/
517void qla4xxx_get_crash_record(struct scsi_qla_host * ha)
518{
519 uint32_t mbox_cmd[MBOX_REG_COUNT];
520 uint32_t mbox_sts[MBOX_REG_COUNT];
521 struct crash_record *crash_record = NULL;
522 dma_addr_t crash_record_dma = 0;
523 uint32_t crash_record_size = 0;
David C Somayajuluc0e344c2007-05-23 18:03:27 -0700524
David Somayajuluafaf5a22006-09-19 10:28:00 -0700525 memset(&mbox_cmd, 0, sizeof(mbox_cmd));
526 memset(&mbox_sts, 0, sizeof(mbox_cmd));
527
528 /* Get size of crash record. */
529 mbox_cmd[0] = MBOX_CMD_GET_CRASH_RECORD;
David C Somayajuluc0e344c2007-05-23 18:03:27 -0700530
531 if (qla4xxx_mailbox_command(ha, MBOX_REG_COUNT, 5, &mbox_cmd[0], &mbox_sts[0]) !=
David Somayajuluafaf5a22006-09-19 10:28:00 -0700532 QLA_SUCCESS) {
533 DEBUG2(printk("scsi%ld: %s: ERROR: Unable to retrieve size!\n",
534 ha->host_no, __func__));
535 goto exit_get_crash_record;
536 }
537 crash_record_size = mbox_sts[4];
538 if (crash_record_size == 0) {
539 DEBUG2(printk("scsi%ld: %s: ERROR: Crash record size is 0!\n",
540 ha->host_no, __func__));
541 goto exit_get_crash_record;
542 }
543
544 /* Alloc Memory for Crash Record. */
545 crash_record = dma_alloc_coherent(&ha->pdev->dev, crash_record_size,
546 &crash_record_dma, GFP_KERNEL);
547 if (crash_record == NULL)
548 goto exit_get_crash_record;
549
550 /* Get Crash Record. */
David C Somayajuluc0e344c2007-05-23 18:03:27 -0700551 memset(&mbox_cmd, 0, sizeof(mbox_cmd));
552 memset(&mbox_sts, 0, sizeof(mbox_cmd));
553
David Somayajuluafaf5a22006-09-19 10:28:00 -0700554 mbox_cmd[0] = MBOX_CMD_GET_CRASH_RECORD;
555 mbox_cmd[2] = LSDW(crash_record_dma);
556 mbox_cmd[3] = MSDW(crash_record_dma);
557 mbox_cmd[4] = crash_record_size;
David C Somayajuluc0e344c2007-05-23 18:03:27 -0700558
559 if (qla4xxx_mailbox_command(ha, MBOX_REG_COUNT, 5, &mbox_cmd[0], &mbox_sts[0]) !=
David Somayajuluafaf5a22006-09-19 10:28:00 -0700560 QLA_SUCCESS)
561 goto exit_get_crash_record;
562
563 /* Dump Crash Record. */
564
565exit_get_crash_record:
566 if (crash_record)
567 dma_free_coherent(&ha->pdev->dev, crash_record_size,
568 crash_record, crash_record_dma);
569}
570
571/**
572 * qla4xxx_get_conn_event_log - retrieves connection event log
573 * @ha: Pointer to host adapter structure.
574 **/
575void qla4xxx_get_conn_event_log(struct scsi_qla_host * ha)
576{
577 uint32_t mbox_cmd[MBOX_REG_COUNT];
578 uint32_t mbox_sts[MBOX_REG_COUNT];
579 struct conn_event_log_entry *event_log = NULL;
580 dma_addr_t event_log_dma = 0;
581 uint32_t event_log_size = 0;
582 uint32_t num_valid_entries;
583 uint32_t oldest_entry = 0;
584 uint32_t max_event_log_entries;
585 uint8_t i;
586
587
588 memset(&mbox_cmd, 0, sizeof(mbox_cmd));
589 memset(&mbox_sts, 0, sizeof(mbox_cmd));
590
591 /* Get size of crash record. */
592 mbox_cmd[0] = MBOX_CMD_GET_CONN_EVENT_LOG;
David C Somayajuluc0e344c2007-05-23 18:03:27 -0700593
594 if (qla4xxx_mailbox_command(ha, MBOX_REG_COUNT, 5, &mbox_cmd[0], &mbox_sts[0]) !=
David Somayajuluafaf5a22006-09-19 10:28:00 -0700595 QLA_SUCCESS)
596 goto exit_get_event_log;
597
598 event_log_size = mbox_sts[4];
599 if (event_log_size == 0)
600 goto exit_get_event_log;
601
602 /* Alloc Memory for Crash Record. */
603 event_log = dma_alloc_coherent(&ha->pdev->dev, event_log_size,
604 &event_log_dma, GFP_KERNEL);
605 if (event_log == NULL)
606 goto exit_get_event_log;
607
608 /* Get Crash Record. */
David C Somayajuluc0e344c2007-05-23 18:03:27 -0700609 memset(&mbox_cmd, 0, sizeof(mbox_cmd));
610 memset(&mbox_sts, 0, sizeof(mbox_cmd));
611
David Somayajuluafaf5a22006-09-19 10:28:00 -0700612 mbox_cmd[0] = MBOX_CMD_GET_CONN_EVENT_LOG;
613 mbox_cmd[2] = LSDW(event_log_dma);
614 mbox_cmd[3] = MSDW(event_log_dma);
David C Somayajuluc0e344c2007-05-23 18:03:27 -0700615
616 if (qla4xxx_mailbox_command(ha, MBOX_REG_COUNT, 5, &mbox_cmd[0], &mbox_sts[0]) !=
David Somayajuluafaf5a22006-09-19 10:28:00 -0700617 QLA_SUCCESS) {
618 DEBUG2(printk("scsi%ld: %s: ERROR: Unable to retrieve event "
619 "log!\n", ha->host_no, __func__));
620 goto exit_get_event_log;
621 }
622
623 /* Dump Event Log. */
624 num_valid_entries = mbox_sts[1];
625
626 max_event_log_entries = event_log_size /
627 sizeof(struct conn_event_log_entry);
628
629 if (num_valid_entries > max_event_log_entries)
630 oldest_entry = num_valid_entries % max_event_log_entries;
631
632 DEBUG3(printk("scsi%ld: Connection Event Log Dump (%d entries):\n",
633 ha->host_no, num_valid_entries));
634
Andrew Vasquez11010fe2006-10-06 09:54:59 -0700635 if (ql4xextended_error_logging == 3) {
David Somayajuluafaf5a22006-09-19 10:28:00 -0700636 if (oldest_entry == 0) {
637 /* Circular Buffer has not wrapped around */
638 for (i=0; i < num_valid_entries; i++) {
639 qla4xxx_dump_buffer((uint8_t *)event_log+
640 (i*sizeof(*event_log)),
641 sizeof(*event_log));
642 }
643 }
644 else {
645 /* Circular Buffer has wrapped around -
646 * display accordingly*/
647 for (i=oldest_entry; i < max_event_log_entries; i++) {
648 qla4xxx_dump_buffer((uint8_t *)event_log+
649 (i*sizeof(*event_log)),
650 sizeof(*event_log));
651 }
652 for (i=0; i < oldest_entry; i++) {
653 qla4xxx_dump_buffer((uint8_t *)event_log+
654 (i*sizeof(*event_log)),
655 sizeof(*event_log));
656 }
657 }
658 }
659
660exit_get_event_log:
661 if (event_log)
662 dma_free_coherent(&ha->pdev->dev, event_log_size, event_log,
663 event_log_dma);
664}
665
666/**
667 * qla4xxx_reset_lun - issues LUN Reset
668 * @ha: Pointer to host adapter structure.
669 * @db_entry: Pointer to device database entry
670 * @un_entry: Pointer to lun entry structure
671 *
672 * This routine performs a LUN RESET on the specified target/lun.
673 * The caller must ensure that the ddb_entry and lun_entry pointers
674 * are valid before calling this routine.
675 **/
676int qla4xxx_reset_lun(struct scsi_qla_host * ha, struct ddb_entry * ddb_entry,
677 int lun)
678{
679 uint32_t mbox_cmd[MBOX_REG_COUNT];
680 uint32_t mbox_sts[MBOX_REG_COUNT];
681 int status = QLA_SUCCESS;
682
683 DEBUG2(printk("scsi%ld:%d:%d: lun reset issued\n", ha->host_no,
684 ddb_entry->os_target_id, lun));
685
686 /*
687 * Send lun reset command to ISP, so that the ISP will return all
688 * outstanding requests with RESET status
689 */
690 memset(&mbox_cmd, 0, sizeof(mbox_cmd));
691 memset(&mbox_sts, 0, sizeof(mbox_sts));
David C Somayajuluc0e344c2007-05-23 18:03:27 -0700692
David Somayajuluafaf5a22006-09-19 10:28:00 -0700693 mbox_cmd[0] = MBOX_CMD_LUN_RESET;
694 mbox_cmd[1] = ddb_entry->fw_ddb_index;
695 mbox_cmd[2] = lun << 8;
696 mbox_cmd[5] = 0x01; /* Immediate Command Enable */
David C Somayajuluc0e344c2007-05-23 18:03:27 -0700697
698 qla4xxx_mailbox_command(ha, MBOX_REG_COUNT, 1, &mbox_cmd[0], &mbox_sts[0]);
David Somayajuluafaf5a22006-09-19 10:28:00 -0700699 if (mbox_sts[0] != MBOX_STS_COMMAND_COMPLETE &&
700 mbox_sts[0] != MBOX_STS_COMMAND_ERROR)
701 status = QLA_ERROR;
702
703 return status;
704}
705
Mike Christiece545032008-02-29 18:25:20 -0600706/**
707 * qla4xxx_reset_target - issues target Reset
708 * @ha: Pointer to host adapter structure.
709 * @db_entry: Pointer to device database entry
710 * @un_entry: Pointer to lun entry structure
711 *
712 * This routine performs a TARGET RESET on the specified target.
713 * The caller must ensure that the ddb_entry pointers
714 * are valid before calling this routine.
715 **/
716int qla4xxx_reset_target(struct scsi_qla_host *ha,
717 struct ddb_entry *ddb_entry)
718{
719 uint32_t mbox_cmd[MBOX_REG_COUNT];
720 uint32_t mbox_sts[MBOX_REG_COUNT];
721 int status = QLA_SUCCESS;
722
723 DEBUG2(printk("scsi%ld:%d: target reset issued\n", ha->host_no,
724 ddb_entry->os_target_id));
725
726 /*
727 * Send target reset command to ISP, so that the ISP will return all
728 * outstanding requests with RESET status
729 */
730 memset(&mbox_cmd, 0, sizeof(mbox_cmd));
731 memset(&mbox_sts, 0, sizeof(mbox_sts));
732
733 mbox_cmd[0] = MBOX_CMD_TARGET_WARM_RESET;
734 mbox_cmd[1] = ddb_entry->fw_ddb_index;
735 mbox_cmd[5] = 0x01; /* Immediate Command Enable */
736
737 qla4xxx_mailbox_command(ha, MBOX_REG_COUNT, 1, &mbox_cmd[0],
738 &mbox_sts[0]);
739 if (mbox_sts[0] != MBOX_STS_COMMAND_COMPLETE &&
740 mbox_sts[0] != MBOX_STS_COMMAND_ERROR)
741 status = QLA_ERROR;
742
743 return status;
744}
David Somayajuluafaf5a22006-09-19 10:28:00 -0700745
746int qla4xxx_get_flash(struct scsi_qla_host * ha, dma_addr_t dma_addr,
747 uint32_t offset, uint32_t len)
748{
749 uint32_t mbox_cmd[MBOX_REG_COUNT];
750 uint32_t mbox_sts[MBOX_REG_COUNT];
751
752 memset(&mbox_cmd, 0, sizeof(mbox_cmd));
753 memset(&mbox_sts, 0, sizeof(mbox_sts));
David C Somayajuluc0e344c2007-05-23 18:03:27 -0700754
David Somayajuluafaf5a22006-09-19 10:28:00 -0700755 mbox_cmd[0] = MBOX_CMD_READ_FLASH;
756 mbox_cmd[1] = LSDW(dma_addr);
757 mbox_cmd[2] = MSDW(dma_addr);
758 mbox_cmd[3] = offset;
759 mbox_cmd[4] = len;
David C Somayajuluc0e344c2007-05-23 18:03:27 -0700760
761 if (qla4xxx_mailbox_command(ha, MBOX_REG_COUNT, 2, &mbox_cmd[0], &mbox_sts[0]) !=
David Somayajuluafaf5a22006-09-19 10:28:00 -0700762 QLA_SUCCESS) {
763 DEBUG2(printk("scsi%ld: %s: MBOX_CMD_READ_FLASH, failed w/ "
764 "status %04X %04X, offset %08x, len %08x\n", ha->host_no,
765 __func__, mbox_sts[0], mbox_sts[1], offset, len));
766 return QLA_ERROR;
767 }
768 return QLA_SUCCESS;
769}
770
771/**
772 * qla4xxx_get_fw_version - gets firmware version
773 * @ha: Pointer to host adapter structure.
774 *
775 * Retrieves the firmware version on HBA. In QLA4010, mailboxes 2 & 3 may
776 * hold an address for data. Make sure that we write 0 to those mailboxes,
777 * if unused.
778 **/
779int qla4xxx_get_fw_version(struct scsi_qla_host * ha)
780{
781 uint32_t mbox_cmd[MBOX_REG_COUNT];
782 uint32_t mbox_sts[MBOX_REG_COUNT];
783
784 /* Get firmware version. */
785 memset(&mbox_cmd, 0, sizeof(mbox_cmd));
786 memset(&mbox_sts, 0, sizeof(mbox_sts));
David C Somayajuluc0e344c2007-05-23 18:03:27 -0700787
David Somayajuluafaf5a22006-09-19 10:28:00 -0700788 mbox_cmd[0] = MBOX_CMD_ABOUT_FW;
David C Somayajuluc0e344c2007-05-23 18:03:27 -0700789
790 if (qla4xxx_mailbox_command(ha, MBOX_REG_COUNT, 5, &mbox_cmd[0], &mbox_sts[0]) !=
David Somayajuluafaf5a22006-09-19 10:28:00 -0700791 QLA_SUCCESS) {
792 DEBUG2(printk("scsi%ld: %s: MBOX_CMD_ABOUT_FW failed w/ "
793 "status %04X\n", ha->host_no, __func__, mbox_sts[0]));
794 return QLA_ERROR;
795 }
796
797 /* Save firmware version information. */
798 ha->firmware_version[0] = mbox_sts[1];
799 ha->firmware_version[1] = mbox_sts[2];
800 ha->patch_number = mbox_sts[3];
801 ha->build_number = mbox_sts[4];
802
803 return QLA_SUCCESS;
804}
805
Adrian Bunk47975472007-04-26 00:35:16 -0700806static int qla4xxx_get_default_ddb(struct scsi_qla_host *ha,
807 dma_addr_t dma_addr)
David Somayajuluafaf5a22006-09-19 10:28:00 -0700808{
809 uint32_t mbox_cmd[MBOX_REG_COUNT];
810 uint32_t mbox_sts[MBOX_REG_COUNT];
811
812 memset(&mbox_cmd, 0, sizeof(mbox_cmd));
813 memset(&mbox_sts, 0, sizeof(mbox_sts));
814
815 mbox_cmd[0] = MBOX_CMD_GET_DATABASE_ENTRY_DEFAULTS;
816 mbox_cmd[2] = LSDW(dma_addr);
817 mbox_cmd[3] = MSDW(dma_addr);
818
David C Somayajuluc0e344c2007-05-23 18:03:27 -0700819 if (qla4xxx_mailbox_command(ha, MBOX_REG_COUNT, 1, &mbox_cmd[0], &mbox_sts[0]) !=
David Somayajuluafaf5a22006-09-19 10:28:00 -0700820 QLA_SUCCESS) {
821 DEBUG2(printk("scsi%ld: %s: failed status %04X\n",
822 ha->host_no, __func__, mbox_sts[0]));
823 return QLA_ERROR;
824 }
825 return QLA_SUCCESS;
826}
827
Adrian Bunk47975472007-04-26 00:35:16 -0700828static int qla4xxx_req_ddb_entry(struct scsi_qla_host *ha, uint32_t *ddb_index)
David Somayajuluafaf5a22006-09-19 10:28:00 -0700829{
830 uint32_t mbox_cmd[MBOX_REG_COUNT];
831 uint32_t mbox_sts[MBOX_REG_COUNT];
832
833 memset(&mbox_cmd, 0, sizeof(mbox_cmd));
834 memset(&mbox_sts, 0, sizeof(mbox_sts));
835
836 mbox_cmd[0] = MBOX_CMD_REQUEST_DATABASE_ENTRY;
837 mbox_cmd[1] = MAX_PRST_DEV_DB_ENTRIES;
838
David C Somayajuluc0e344c2007-05-23 18:03:27 -0700839 if (qla4xxx_mailbox_command(ha, MBOX_REG_COUNT, 3, &mbox_cmd[0], &mbox_sts[0]) !=
David Somayajuluafaf5a22006-09-19 10:28:00 -0700840 QLA_SUCCESS) {
841 if (mbox_sts[0] == MBOX_STS_COMMAND_ERROR) {
842 *ddb_index = mbox_sts[2];
843 } else {
844 DEBUG2(printk("scsi%ld: %s: failed status %04X\n",
845 ha->host_no, __func__, mbox_sts[0]));
846 return QLA_ERROR;
847 }
848 } else {
849 *ddb_index = MAX_PRST_DEV_DB_ENTRIES;
850 }
851
852 return QLA_SUCCESS;
853}
854
855
856int qla4xxx_send_tgts(struct scsi_qla_host *ha, char *ip, uint16_t port)
857{
858 struct dev_db_entry *fw_ddb_entry;
859 dma_addr_t fw_ddb_entry_dma;
860 uint32_t ddb_index;
861 int ret_val = QLA_SUCCESS;
862
863
864 fw_ddb_entry = dma_alloc_coherent(&ha->pdev->dev,
865 sizeof(*fw_ddb_entry),
866 &fw_ddb_entry_dma, GFP_KERNEL);
867 if (!fw_ddb_entry) {
868 DEBUG2(printk("scsi%ld: %s: Unable to allocate dma buffer.\n",
869 ha->host_no, __func__));
870 ret_val = QLA_ERROR;
871 goto qla4xxx_send_tgts_exit;
872 }
873
874 ret_val = qla4xxx_get_default_ddb(ha, fw_ddb_entry_dma);
875 if (ret_val != QLA_SUCCESS)
876 goto qla4xxx_send_tgts_exit;
877
878 ret_val = qla4xxx_req_ddb_entry(ha, &ddb_index);
879 if (ret_val != QLA_SUCCESS)
880 goto qla4xxx_send_tgts_exit;
881
David C Somayajuluc0e344c2007-05-23 18:03:27 -0700882 memset(fw_ddb_entry->iscsi_alias, 0,
883 sizeof(fw_ddb_entry->iscsi_alias));
David Somayajuluafaf5a22006-09-19 10:28:00 -0700884
David C Somayajuluc0e344c2007-05-23 18:03:27 -0700885 memset(fw_ddb_entry->iscsi_name, 0,
886 sizeof(fw_ddb_entry->iscsi_name));
David Somayajuluafaf5a22006-09-19 10:28:00 -0700887
David C Somayajuluc0e344c2007-05-23 18:03:27 -0700888 memset(fw_ddb_entry->ip_addr, 0, sizeof(fw_ddb_entry->ip_addr));
889 memset(fw_ddb_entry->tgt_addr, 0,
890 sizeof(fw_ddb_entry->tgt_addr));
David Somayajuluafaf5a22006-09-19 10:28:00 -0700891
892 fw_ddb_entry->options = (DDB_OPT_DISC_SESSION | DDB_OPT_TARGET);
David C Somayajuluc0e344c2007-05-23 18:03:27 -0700893 fw_ddb_entry->port = cpu_to_le16(ntohs(port));
David Somayajuluafaf5a22006-09-19 10:28:00 -0700894
David C Somayajuluc0e344c2007-05-23 18:03:27 -0700895 fw_ddb_entry->ip_addr[0] = *ip;
896 fw_ddb_entry->ip_addr[1] = *(ip + 1);
897 fw_ddb_entry->ip_addr[2] = *(ip + 2);
898 fw_ddb_entry->ip_addr[3] = *(ip + 3);
David Somayajuluafaf5a22006-09-19 10:28:00 -0700899
900 ret_val = qla4xxx_set_ddb_entry(ha, ddb_index, fw_ddb_entry_dma);
901
902qla4xxx_send_tgts_exit:
903 dma_free_coherent(&ha->pdev->dev, sizeof(*fw_ddb_entry),
904 fw_ddb_entry, fw_ddb_entry_dma);
905 return ret_val;
906}
907