2 * QLogic Fibre Channel HBA Driver
3 * Copyright (c) 2003-2011 QLogic Corporation
5 * See LICENSE.qla2xxx for copyright and licensing details.
9 #include <linux/delay.h>
10 #include <linux/gfp.h>
14 * qla2x00_mailbox_command
15 * Issue mailbox command and waits for completion.
18 * ha = adapter block pointer.
19 * mcp = driver internal mbx struct pointer.
22 * mb[MAX_MAILBOX_REGISTER_COUNT] = returned mailbox data.
25 * 0 : QLA_SUCCESS = cmd performed success
26 * 1 : QLA_FUNCTION_FAILED (error encountered)
27 * 6 : QLA_FUNCTION_TIMEOUT (timeout condition encountered)
33 qla2x00_mailbox_command(scsi_qla_host_t
*vha
, mbx_cmd_t
*mcp
)
36 unsigned long flags
= 0;
37 device_reg_t __iomem
*reg
;
42 uint16_t __iomem
*optr
;
45 unsigned long wait_time
;
46 struct qla_hw_data
*ha
= vha
->hw
;
47 scsi_qla_host_t
*base_vha
= pci_get_drvdata(ha
->pdev
);
49 if (ha
->pdev
->error_state
> pci_channel_io_frozen
)
50 return QLA_FUNCTION_TIMEOUT
;
52 if (vha
->device_flags
& DFLG_DEV_FAILED
) {
53 DEBUG2_3_11(qla_printk(KERN_WARNING
, ha
,
54 "%s(%ld): Device in failed state, "
55 "timeout MBX Exiting.\n",
56 __func__
, base_vha
->host_no
));
57 return QLA_FUNCTION_TIMEOUT
;
61 io_lock_on
= base_vha
->flags
.init_done
;
64 abort_active
= test_bit(ABORT_ISP_ACTIVE
, &base_vha
->dpc_flags
);
66 DEBUG11(printk("%s(%ld): entered.\n", __func__
, base_vha
->host_no
));
68 if (ha
->flags
.pci_channel_io_perm_failure
) {
69 DEBUG(printk("%s(%ld): Perm failure on EEH, timeout MBX "
70 "Exiting.\n", __func__
, vha
->host_no
));
71 return QLA_FUNCTION_TIMEOUT
;
74 if (ha
->flags
.isp82xx_fw_hung
) {
75 /* Setting Link-Down error */
76 mcp
->mb
[0] = MBS_LINK_DOWN_ERROR
;
77 rval
= QLA_FUNCTION_FAILED
;
82 * Wait for active mailbox commands to finish by waiting at most tov
83 * seconds. This is to serialize actual issuing of mailbox cmds during
86 if (!wait_for_completion_timeout(&ha
->mbx_cmd_comp
, mcp
->tov
* HZ
)) {
87 /* Timeout occurred. Return error. */
88 DEBUG2_3_11(printk("%s(%ld): cmd access timeout. "
89 "Exiting.\n", __func__
, base_vha
->host_no
));
90 return QLA_FUNCTION_TIMEOUT
;
93 ha
->flags
.mbox_busy
= 1;
94 /* Save mailbox command for debug */
97 DEBUG11(printk("scsi(%ld): prepare to issue mbox cmd=0x%x.\n",
98 base_vha
->host_no
, mcp
->mb
[0]));
100 spin_lock_irqsave(&ha
->hardware_lock
, flags
);
102 /* Load mailbox registers. */
104 optr
= (uint16_t __iomem
*)®
->isp82
.mailbox_in
[0];
105 else if (IS_FWI2_CAPABLE(ha
) && !IS_QLA82XX(ha
))
106 optr
= (uint16_t __iomem
*)®
->isp24
.mailbox0
;
108 optr
= (uint16_t __iomem
*)MAILBOX_REG(ha
, ®
->isp
, 0);
111 command
= mcp
->mb
[0];
112 mboxes
= mcp
->out_mb
;
114 for (cnt
= 0; cnt
< ha
->mbx_count
; cnt
++) {
115 if (IS_QLA2200(ha
) && cnt
== 8)
117 (uint16_t __iomem
*)MAILBOX_REG(ha
, ®
->isp
, 8);
119 WRT_REG_WORD(optr
, *iptr
);
126 #if defined(QL_DEBUG_LEVEL_1)
127 printk("%s(%ld): Loaded MBX registers (displayed in bytes) = \n",
128 __func__
, base_vha
->host_no
);
129 qla2x00_dump_buffer((uint8_t *)mcp
->mb
, 16);
131 qla2x00_dump_buffer(((uint8_t *)mcp
->mb
+ 0x10), 16);
133 qla2x00_dump_buffer(((uint8_t *)mcp
->mb
+ 0x20), 8);
135 printk("%s(%ld): I/O address = %p.\n", __func__
, base_vha
->host_no
,
137 qla2x00_dump_regs(base_vha
);
140 /* Issue set host interrupt command to send cmd out. */
141 ha
->flags
.mbox_int
= 0;
142 clear_bit(MBX_INTERRUPT
, &ha
->mbx_cmd_flags
);
144 /* Unlock mbx registers and wait for interrupt */
145 DEBUG11(printk("%s(%ld): going to unlock irq & waiting for interrupt. "
146 "jiffies=%lx.\n", __func__
, base_vha
->host_no
, jiffies
));
148 /* Wait for mbx cmd completion until timeout */
150 if ((!abort_active
&& io_lock_on
) || IS_NOPOLLING_TYPE(ha
)) {
151 set_bit(MBX_INTR_WAIT
, &ha
->mbx_cmd_flags
);
153 if (IS_QLA82XX(ha
)) {
154 if (RD_REG_DWORD(®
->isp82
.hint
) &
155 HINT_MBX_INT_PENDING
) {
156 spin_unlock_irqrestore(&ha
->hardware_lock
,
158 DEBUG2_3_11(printk(KERN_INFO
159 "%s(%ld): Pending Mailbox timeout. "
160 "Exiting.\n", __func__
, base_vha
->host_no
));
161 rval
= QLA_FUNCTION_TIMEOUT
;
164 WRT_REG_DWORD(®
->isp82
.hint
, HINT_MBX_INT_PENDING
);
165 } else if (IS_FWI2_CAPABLE(ha
))
166 WRT_REG_DWORD(®
->isp24
.hccr
, HCCRX_SET_HOST_INT
);
168 WRT_REG_WORD(®
->isp
.hccr
, HCCR_SET_HOST_INT
);
169 spin_unlock_irqrestore(&ha
->hardware_lock
, flags
);
171 wait_for_completion_timeout(&ha
->mbx_intr_comp
, mcp
->tov
* HZ
);
173 clear_bit(MBX_INTR_WAIT
, &ha
->mbx_cmd_flags
);
176 DEBUG3_11(printk("%s(%ld): cmd=%x POLLING MODE.\n", __func__
,
177 base_vha
->host_no
, command
));
179 if (IS_QLA82XX(ha
)) {
180 if (RD_REG_DWORD(®
->isp82
.hint
) &
181 HINT_MBX_INT_PENDING
) {
182 spin_unlock_irqrestore(&ha
->hardware_lock
,
184 DEBUG2_3_11(printk(KERN_INFO
185 "%s(%ld): Pending Mailbox timeout. "
186 "Exiting.\n", __func__
, base_vha
->host_no
));
187 rval
= QLA_FUNCTION_TIMEOUT
;
190 WRT_REG_DWORD(®
->isp82
.hint
, HINT_MBX_INT_PENDING
);
191 } else if (IS_FWI2_CAPABLE(ha
))
192 WRT_REG_DWORD(®
->isp24
.hccr
, HCCRX_SET_HOST_INT
);
194 WRT_REG_WORD(®
->isp
.hccr
, HCCR_SET_HOST_INT
);
195 spin_unlock_irqrestore(&ha
->hardware_lock
, flags
);
197 wait_time
= jiffies
+ mcp
->tov
* HZ
; /* wait at most tov secs */
198 while (!ha
->flags
.mbox_int
) {
199 if (time_after(jiffies
, wait_time
))
202 /* Check for pending interrupts. */
203 qla2x00_poll(ha
->rsp_q_map
[0]);
205 if (!ha
->flags
.mbox_int
&&
207 command
== MBC_LOAD_RISC_RAM_EXTENDED
))
210 DEBUG17(qla_printk(KERN_WARNING
, ha
,
212 (uint
)((jiffies
- (wait_time
- (mcp
->tov
* HZ
)))/HZ
)));
215 /* Check whether we timed out */
216 if (ha
->flags
.mbox_int
) {
219 DEBUG3_11(printk("%s(%ld): cmd %x completed.\n", __func__
,
220 base_vha
->host_no
, command
));
222 /* Got interrupt. Clear the flag. */
223 ha
->flags
.mbox_int
= 0;
224 clear_bit(MBX_INTERRUPT
, &ha
->mbx_cmd_flags
);
226 if (ha
->flags
.isp82xx_fw_hung
) {
227 ha
->flags
.mbox_busy
= 0;
228 /* Setting Link-Down error */
229 mcp
->mb
[0] = MBS_LINK_DOWN_ERROR
;
231 rval
= QLA_FUNCTION_FAILED
;
235 if (ha
->mailbox_out
[0] != MBS_COMMAND_COMPLETE
)
236 rval
= QLA_FUNCTION_FAILED
;
238 /* Load return mailbox registers. */
240 iptr
= (uint16_t *)&ha
->mailbox_out
[0];
242 for (cnt
= 0; cnt
< ha
->mbx_count
; cnt
++) {
252 #if defined(QL_DEBUG_LEVEL_2) || defined(QL_DEBUG_LEVEL_3) || \
253 defined(QL_DEBUG_LEVEL_11)
257 if (IS_FWI2_CAPABLE(ha
)) {
258 mb0
= RD_REG_WORD(®
->isp24
.mailbox0
);
259 ictrl
= RD_REG_DWORD(®
->isp24
.ictrl
);
261 mb0
= RD_MAILBOX_REG(ha
, ®
->isp
, 0);
262 ictrl
= RD_REG_WORD(®
->isp
.ictrl
);
264 printk("%s(%ld): **** MB Command Timeout for cmd %x ****\n",
265 __func__
, base_vha
->host_no
, command
);
266 printk("%s(%ld): icontrol=%x jiffies=%lx\n", __func__
,
267 base_vha
->host_no
, ictrl
, jiffies
);
268 printk("%s(%ld): *** mailbox[0] = 0x%x ***\n", __func__
,
269 base_vha
->host_no
, mb0
);
270 qla2x00_dump_regs(base_vha
);
273 rval
= QLA_FUNCTION_TIMEOUT
;
276 ha
->flags
.mbox_busy
= 0;
281 if ((abort_active
|| !io_lock_on
) && !IS_NOPOLLING_TYPE(ha
)) {
282 DEBUG11(printk("%s(%ld): checking for additional resp "
283 "interrupt.\n", __func__
, base_vha
->host_no
));
285 /* polling mode for non isp_abort commands. */
286 qla2x00_poll(ha
->rsp_q_map
[0]);
289 if (rval
== QLA_FUNCTION_TIMEOUT
&&
290 mcp
->mb
[0] != MBC_GEN_SYSTEM_ERROR
) {
291 if (!io_lock_on
|| (mcp
->flags
& IOCTL_CMD
) ||
292 ha
->flags
.eeh_busy
) {
293 /* not in dpc. schedule it for dpc to take over. */
294 DEBUG(printk("%s(%ld): timeout schedule "
295 "isp_abort_needed.\n", __func__
,
297 DEBUG2_3_11(printk("%s(%ld): timeout schedule "
298 "isp_abort_needed.\n", __func__
,
301 if (!test_bit(ISP_ABORT_NEEDED
, &vha
->dpc_flags
) &&
302 !test_bit(ABORT_ISP_ACTIVE
, &vha
->dpc_flags
) &&
303 !test_bit(ISP_ABORT_RETRY
, &vha
->dpc_flags
)) {
305 qla_printk(KERN_WARNING
, ha
,
306 "Mailbox command timeout occurred. "
307 "Scheduling ISP " "abort. eeh_busy: 0x%x\n",
309 set_bit(ISP_ABORT_NEEDED
, &vha
->dpc_flags
);
310 qla2xxx_wake_dpc(vha
);
312 } else if (!abort_active
) {
313 /* call abort directly since we are in the DPC thread */
314 DEBUG(printk("%s(%ld): timeout calling abort_isp\n",
315 __func__
, base_vha
->host_no
));
316 DEBUG2_3_11(printk("%s(%ld): timeout calling "
317 "abort_isp\n", __func__
, base_vha
->host_no
));
319 if (!test_bit(ISP_ABORT_NEEDED
, &vha
->dpc_flags
) &&
320 !test_bit(ABORT_ISP_ACTIVE
, &vha
->dpc_flags
) &&
321 !test_bit(ISP_ABORT_RETRY
, &vha
->dpc_flags
)) {
323 qla_printk(KERN_WARNING
, ha
,
324 "Mailbox command timeout occurred. "
325 "Issuing ISP abort.\n");
327 set_bit(ABORT_ISP_ACTIVE
, &vha
->dpc_flags
);
328 clear_bit(ISP_ABORT_NEEDED
, &vha
->dpc_flags
);
329 if (ha
->isp_ops
->abort_isp(vha
)) {
330 /* Failed. retry later. */
331 set_bit(ISP_ABORT_NEEDED
,
334 clear_bit(ABORT_ISP_ACTIVE
, &vha
->dpc_flags
);
335 DEBUG(printk("%s(%ld): finished abort_isp\n",
336 __func__
, vha
->host_no
));
338 "%s(%ld): finished abort_isp\n",
339 __func__
, vha
->host_no
));
345 /* Allow next mbx cmd to come in. */
346 complete(&ha
->mbx_cmd_comp
);
349 DEBUG2_3_11(printk("%s(%ld): **** FAILED. mbx0=%x, mbx1=%x, "
350 "mbx2=%x, cmd=%x ****\n", __func__
, base_vha
->host_no
,
351 mcp
->mb
[0], mcp
->mb
[1], mcp
->mb
[2], command
));
353 DEBUG11(printk("%s(%ld): done.\n", __func__
,
361 qla2x00_load_ram(scsi_qla_host_t
*vha
, dma_addr_t req_dma
, uint32_t risc_addr
,
362 uint32_t risc_code_size
)
365 struct qla_hw_data
*ha
= vha
->hw
;
367 mbx_cmd_t
*mcp
= &mc
;
369 DEBUG11(printk("%s(%ld): entered.\n", __func__
, vha
->host_no
));
371 if (MSW(risc_addr
) || IS_FWI2_CAPABLE(ha
)) {
372 mcp
->mb
[0] = MBC_LOAD_RISC_RAM_EXTENDED
;
373 mcp
->mb
[8] = MSW(risc_addr
);
374 mcp
->out_mb
= MBX_8
|MBX_0
;
376 mcp
->mb
[0] = MBC_LOAD_RISC_RAM
;
379 mcp
->mb
[1] = LSW(risc_addr
);
380 mcp
->mb
[2] = MSW(req_dma
);
381 mcp
->mb
[3] = LSW(req_dma
);
382 mcp
->mb
[6] = MSW(MSD(req_dma
));
383 mcp
->mb
[7] = LSW(MSD(req_dma
));
384 mcp
->out_mb
|= MBX_7
|MBX_6
|MBX_3
|MBX_2
|MBX_1
;
385 if (IS_FWI2_CAPABLE(ha
)) {
386 mcp
->mb
[4] = MSW(risc_code_size
);
387 mcp
->mb
[5] = LSW(risc_code_size
);
388 mcp
->out_mb
|= MBX_5
|MBX_4
;
390 mcp
->mb
[4] = LSW(risc_code_size
);
391 mcp
->out_mb
|= MBX_4
;
395 mcp
->tov
= MBX_TOV_SECONDS
;
397 rval
= qla2x00_mailbox_command(vha
, mcp
);
399 if (rval
!= QLA_SUCCESS
) {
400 DEBUG2_3_11(printk("%s(%ld): failed=%x mb[0]=%x.\n", __func__
,
401 vha
->host_no
, rval
, mcp
->mb
[0]));
403 DEBUG11(printk("%s(%ld): done.\n", __func__
, vha
->host_no
));
409 #define EXTENDED_BB_CREDITS BIT_0
412 * Start adapter firmware.
415 * ha = adapter block pointer.
416 * TARGET_QUEUE_LOCK must be released.
417 * ADAPTER_STATE_LOCK must be released.
420 * qla2x00 local function return status code.
426 qla2x00_execute_fw(scsi_qla_host_t
*vha
, uint32_t risc_addr
)
429 struct qla_hw_data
*ha
= vha
->hw
;
431 mbx_cmd_t
*mcp
= &mc
;
433 DEBUG11(printk("%s(%ld): entered.\n", __func__
, vha
->host_no
));
435 mcp
->mb
[0] = MBC_EXECUTE_FIRMWARE
;
438 if (IS_FWI2_CAPABLE(ha
)) {
439 mcp
->mb
[1] = MSW(risc_addr
);
440 mcp
->mb
[2] = LSW(risc_addr
);
442 if (IS_QLA81XX(ha
)) {
443 struct nvram_81xx
*nv
= ha
->nvram
;
444 mcp
->mb
[4] = (nv
->enhanced_features
&
445 EXTENDED_BB_CREDITS
);
448 mcp
->out_mb
|= MBX_4
|MBX_3
|MBX_2
|MBX_1
;
451 mcp
->mb
[1] = LSW(risc_addr
);
452 mcp
->out_mb
|= MBX_1
;
453 if (IS_QLA2322(ha
) || IS_QLA6322(ha
)) {
455 mcp
->out_mb
|= MBX_2
;
459 mcp
->tov
= MBX_TOV_SECONDS
;
461 rval
= qla2x00_mailbox_command(vha
, mcp
);
463 if (rval
!= QLA_SUCCESS
) {
464 DEBUG2_3_11(printk("%s(%ld): failed=%x mb[0]=%x.\n", __func__
,
465 vha
->host_no
, rval
, mcp
->mb
[0]));
467 if (IS_FWI2_CAPABLE(ha
)) {
468 DEBUG11(printk("%s(%ld): done exchanges=%x.\n",
469 __func__
, vha
->host_no
, mcp
->mb
[1]));
471 DEBUG11(printk("%s(%ld): done.\n", __func__
,
480 * qla2x00_get_fw_version
481 * Get firmware version.
484 * ha: adapter state pointer.
485 * major: pointer for major number.
486 * minor: pointer for minor number.
487 * subminor: pointer for subminor number.
490 * qla2x00 local function return status code.
496 qla2x00_get_fw_version(scsi_qla_host_t
*vha
, uint16_t *major
, uint16_t *minor
,
497 uint16_t *subminor
, uint16_t *attributes
, uint32_t *memory
, uint8_t *mpi
,
498 uint32_t *mpi_caps
, uint8_t *phy
)
502 mbx_cmd_t
*mcp
= &mc
;
504 DEBUG11(printk("%s(%ld): entered.\n", __func__
, vha
->host_no
));
506 mcp
->mb
[0] = MBC_GET_FIRMWARE_VERSION
;
508 mcp
->in_mb
= MBX_6
|MBX_5
|MBX_4
|MBX_3
|MBX_2
|MBX_1
|MBX_0
;
509 if (IS_QLA81XX(vha
->hw
))
510 mcp
->in_mb
|= MBX_13
|MBX_12
|MBX_11
|MBX_10
|MBX_9
|MBX_8
;
512 mcp
->tov
= MBX_TOV_SECONDS
;
513 rval
= qla2x00_mailbox_command(vha
, mcp
);
514 if (rval
!= QLA_SUCCESS
)
517 /* Return mailbox data. */
520 *subminor
= mcp
->mb
[3];
521 *attributes
= mcp
->mb
[6];
522 if (IS_QLA2100(vha
->hw
) || IS_QLA2200(vha
->hw
))
523 *memory
= 0x1FFFF; /* Defaults to 128KB. */
525 *memory
= (mcp
->mb
[5] << 16) | mcp
->mb
[4];
526 if (IS_QLA81XX(vha
->hw
)) {
527 mpi
[0] = mcp
->mb
[10] & 0xff;
528 mpi
[1] = mcp
->mb
[11] >> 8;
529 mpi
[2] = mcp
->mb
[11] & 0xff;
530 *mpi_caps
= (mcp
->mb
[12] << 16) | mcp
->mb
[13];
531 phy
[0] = mcp
->mb
[8] & 0xff;
532 phy
[1] = mcp
->mb
[9] >> 8;
533 phy
[2] = mcp
->mb
[9] & 0xff;
536 if (rval
!= QLA_SUCCESS
) {
538 DEBUG2_3_11(printk("%s(%ld): failed=%x.\n", __func__
,
539 vha
->host_no
, rval
));
542 DEBUG11(printk("%s(%ld): done.\n", __func__
, vha
->host_no
));
548 * qla2x00_get_fw_options
549 * Set firmware options.
552 * ha = adapter block pointer.
553 * fwopt = pointer for firmware options.
556 * qla2x00 local function return status code.
562 qla2x00_get_fw_options(scsi_qla_host_t
*vha
, uint16_t *fwopts
)
566 mbx_cmd_t
*mcp
= &mc
;
568 DEBUG11(printk("%s(%ld): entered.\n", __func__
, vha
->host_no
));
570 mcp
->mb
[0] = MBC_GET_FIRMWARE_OPTION
;
572 mcp
->in_mb
= MBX_3
|MBX_2
|MBX_1
|MBX_0
;
573 mcp
->tov
= MBX_TOV_SECONDS
;
575 rval
= qla2x00_mailbox_command(vha
, mcp
);
577 if (rval
!= QLA_SUCCESS
) {
579 DEBUG2_3_11(printk("%s(%ld): failed=%x.\n", __func__
,
580 vha
->host_no
, rval
));
582 fwopts
[0] = mcp
->mb
[0];
583 fwopts
[1] = mcp
->mb
[1];
584 fwopts
[2] = mcp
->mb
[2];
585 fwopts
[3] = mcp
->mb
[3];
587 DEBUG11(printk("%s(%ld): done.\n", __func__
, vha
->host_no
));
595 * qla2x00_set_fw_options
596 * Set firmware options.
599 * ha = adapter block pointer.
600 * fwopt = pointer for firmware options.
603 * qla2x00 local function return status code.
609 qla2x00_set_fw_options(scsi_qla_host_t
*vha
, uint16_t *fwopts
)
613 mbx_cmd_t
*mcp
= &mc
;
615 DEBUG11(printk("%s(%ld): entered.\n", __func__
, vha
->host_no
));
617 mcp
->mb
[0] = MBC_SET_FIRMWARE_OPTION
;
618 mcp
->mb
[1] = fwopts
[1];
619 mcp
->mb
[2] = fwopts
[2];
620 mcp
->mb
[3] = fwopts
[3];
621 mcp
->out_mb
= MBX_3
|MBX_2
|MBX_1
|MBX_0
;
623 if (IS_FWI2_CAPABLE(vha
->hw
)) {
626 mcp
->mb
[10] = fwopts
[10];
627 mcp
->mb
[11] = fwopts
[11];
628 mcp
->mb
[12] = 0; /* Undocumented, but used */
629 mcp
->out_mb
|= MBX_12
|MBX_11
|MBX_10
;
631 mcp
->tov
= MBX_TOV_SECONDS
;
633 rval
= qla2x00_mailbox_command(vha
, mcp
);
635 fwopts
[0] = mcp
->mb
[0];
637 if (rval
!= QLA_SUCCESS
) {
639 DEBUG2_3_11(printk("%s(%ld): failed=%x (%x/%x).\n", __func__
,
640 vha
->host_no
, rval
, mcp
->mb
[0], mcp
->mb
[1]));
643 DEBUG11(printk("%s(%ld): done.\n", __func__
, vha
->host_no
));
650 * qla2x00_mbx_reg_test
651 * Mailbox register wrap test.
654 * ha = adapter block pointer.
655 * TARGET_QUEUE_LOCK must be released.
656 * ADAPTER_STATE_LOCK must be released.
659 * qla2x00 local function return status code.
665 qla2x00_mbx_reg_test(scsi_qla_host_t
*vha
)
669 mbx_cmd_t
*mcp
= &mc
;
671 DEBUG11(printk("qla2x00_mbx_reg_test(%ld): entered.\n", vha
->host_no
));
673 mcp
->mb
[0] = MBC_MAILBOX_REGISTER_TEST
;
681 mcp
->out_mb
= MBX_7
|MBX_6
|MBX_5
|MBX_4
|MBX_3
|MBX_2
|MBX_1
|MBX_0
;
682 mcp
->in_mb
= MBX_7
|MBX_6
|MBX_5
|MBX_4
|MBX_3
|MBX_2
|MBX_1
|MBX_0
;
683 mcp
->tov
= MBX_TOV_SECONDS
;
685 rval
= qla2x00_mailbox_command(vha
, mcp
);
687 if (rval
== QLA_SUCCESS
) {
688 if (mcp
->mb
[1] != 0xAAAA || mcp
->mb
[2] != 0x5555 ||
689 mcp
->mb
[3] != 0xAA55 || mcp
->mb
[4] != 0x55AA)
690 rval
= QLA_FUNCTION_FAILED
;
691 if (mcp
->mb
[5] != 0xA5A5 || mcp
->mb
[6] != 0x5A5A ||
692 mcp
->mb
[7] != 0x2525)
693 rval
= QLA_FUNCTION_FAILED
;
696 if (rval
!= QLA_SUCCESS
) {
698 DEBUG2_3_11(printk("qla2x00_mbx_reg_test(%ld): failed=%x.\n",
699 vha
->host_no
, rval
));
702 DEBUG11(printk("qla2x00_mbx_reg_test(%ld): done.\n",
710 * qla2x00_verify_checksum
711 * Verify firmware checksum.
714 * ha = adapter block pointer.
715 * TARGET_QUEUE_LOCK must be released.
716 * ADAPTER_STATE_LOCK must be released.
719 * qla2x00 local function return status code.
725 qla2x00_verify_checksum(scsi_qla_host_t
*vha
, uint32_t risc_addr
)
729 mbx_cmd_t
*mcp
= &mc
;
731 DEBUG11(printk("%s(%ld): entered.\n", __func__
, vha
->host_no
));
733 mcp
->mb
[0] = MBC_VERIFY_CHECKSUM
;
736 if (IS_FWI2_CAPABLE(vha
->hw
)) {
737 mcp
->mb
[1] = MSW(risc_addr
);
738 mcp
->mb
[2] = LSW(risc_addr
);
739 mcp
->out_mb
|= MBX_2
|MBX_1
;
740 mcp
->in_mb
|= MBX_2
|MBX_1
;
742 mcp
->mb
[1] = LSW(risc_addr
);
743 mcp
->out_mb
|= MBX_1
;
747 mcp
->tov
= MBX_TOV_SECONDS
;
749 rval
= qla2x00_mailbox_command(vha
, mcp
);
751 if (rval
!= QLA_SUCCESS
) {
752 DEBUG2_3_11(printk("%s(%ld): failed=%x chk sum=%x.\n", __func__
,
753 vha
->host_no
, rval
, IS_FWI2_CAPABLE(vha
->hw
) ?
754 (mcp
->mb
[2] << 16) | mcp
->mb
[1]: mcp
->mb
[1]));
756 DEBUG11(printk("%s(%ld): done.\n", __func__
, vha
->host_no
));
764 * Issue IOCB using mailbox command
767 * ha = adapter state pointer.
768 * buffer = buffer pointer.
769 * phys_addr = physical address of buffer.
770 * size = size of buffer.
771 * TARGET_QUEUE_LOCK must be released.
772 * ADAPTER_STATE_LOCK must be released.
775 * qla2x00 local function return status code.
781 qla2x00_issue_iocb_timeout(scsi_qla_host_t
*vha
, void *buffer
,
782 dma_addr_t phys_addr
, size_t size
, uint32_t tov
)
786 mbx_cmd_t
*mcp
= &mc
;
788 mcp
->mb
[0] = MBC_IOCB_COMMAND_A64
;
790 mcp
->mb
[2] = MSW(phys_addr
);
791 mcp
->mb
[3] = LSW(phys_addr
);
792 mcp
->mb
[6] = MSW(MSD(phys_addr
));
793 mcp
->mb
[7] = LSW(MSD(phys_addr
));
794 mcp
->out_mb
= MBX_7
|MBX_6
|MBX_3
|MBX_2
|MBX_1
|MBX_0
;
795 mcp
->in_mb
= MBX_2
|MBX_0
;
798 rval
= qla2x00_mailbox_command(vha
, mcp
);
800 if (rval
!= QLA_SUCCESS
) {
802 DEBUG(printk("qla2x00_issue_iocb(%ld): failed rval 0x%x\n",
803 vha
->host_no
, rval
));
805 sts_entry_t
*sts_entry
= (sts_entry_t
*) buffer
;
807 /* Mask reserved bits. */
808 sts_entry
->entry_status
&=
809 IS_FWI2_CAPABLE(vha
->hw
) ? RF_MASK_24XX
: RF_MASK
;
816 qla2x00_issue_iocb(scsi_qla_host_t
*vha
, void *buffer
, dma_addr_t phys_addr
,
819 return qla2x00_issue_iocb_timeout(vha
, buffer
, phys_addr
, size
,
824 * qla2x00_abort_command
825 * Abort command aborts a specified IOCB.
828 * ha = adapter block pointer.
829 * sp = SB structure pointer.
832 * qla2x00 local function return status code.
838 qla2x00_abort_command(srb_t
*sp
)
840 unsigned long flags
= 0;
844 mbx_cmd_t
*mcp
= &mc
;
845 fc_port_t
*fcport
= sp
->fcport
;
846 scsi_qla_host_t
*vha
= fcport
->vha
;
847 struct qla_hw_data
*ha
= vha
->hw
;
848 struct req_que
*req
= vha
->req
;
850 DEBUG11(printk("qla2x00_abort_command(%ld): entered.\n", vha
->host_no
));
852 spin_lock_irqsave(&ha
->hardware_lock
, flags
);
853 for (handle
= 1; handle
< MAX_OUTSTANDING_COMMANDS
; handle
++) {
854 if (req
->outstanding_cmds
[handle
] == sp
)
857 spin_unlock_irqrestore(&ha
->hardware_lock
, flags
);
859 if (handle
== MAX_OUTSTANDING_COMMANDS
) {
860 /* command not found */
861 return QLA_FUNCTION_FAILED
;
864 mcp
->mb
[0] = MBC_ABORT_COMMAND
;
865 if (HAS_EXTENDED_IDS(ha
))
866 mcp
->mb
[1] = fcport
->loop_id
;
868 mcp
->mb
[1] = fcport
->loop_id
<< 8;
869 mcp
->mb
[2] = (uint16_t)handle
;
870 mcp
->mb
[3] = (uint16_t)(handle
>> 16);
871 mcp
->mb
[6] = (uint16_t)sp
->cmd
->device
->lun
;
872 mcp
->out_mb
= MBX_6
|MBX_3
|MBX_2
|MBX_1
|MBX_0
;
874 mcp
->tov
= MBX_TOV_SECONDS
;
876 rval
= qla2x00_mailbox_command(vha
, mcp
);
878 if (rval
!= QLA_SUCCESS
) {
879 DEBUG2_3_11(printk("qla2x00_abort_command(%ld): failed=%x.\n",
880 vha
->host_no
, rval
));
882 DEBUG11(printk("qla2x00_abort_command(%ld): done.\n",
890 qla2x00_abort_target(struct fc_port
*fcport
, unsigned int l
, int tag
)
894 mbx_cmd_t
*mcp
= &mc
;
895 scsi_qla_host_t
*vha
;
899 DEBUG11(printk("%s(%ld): entered.\n", __func__
, fcport
->vha
->host_no
));
903 req
= vha
->hw
->req_q_map
[0];
905 mcp
->mb
[0] = MBC_ABORT_TARGET
;
906 mcp
->out_mb
= MBX_9
|MBX_2
|MBX_1
|MBX_0
;
907 if (HAS_EXTENDED_IDS(vha
->hw
)) {
908 mcp
->mb
[1] = fcport
->loop_id
;
910 mcp
->out_mb
|= MBX_10
;
912 mcp
->mb
[1] = fcport
->loop_id
<< 8;
914 mcp
->mb
[2] = vha
->hw
->loop_reset_delay
;
915 mcp
->mb
[9] = vha
->vp_idx
;
918 mcp
->tov
= MBX_TOV_SECONDS
;
920 rval
= qla2x00_mailbox_command(vha
, mcp
);
921 if (rval
!= QLA_SUCCESS
) {
922 DEBUG2_3_11(printk("%s(%ld): failed=%x.\n", __func__
,
923 vha
->host_no
, rval
));
926 /* Issue marker IOCB. */
927 rval2
= qla2x00_marker(vha
, req
, rsp
, fcport
->loop_id
, 0,
929 if (rval2
!= QLA_SUCCESS
) {
930 DEBUG2_3_11(printk("%s(%ld): failed to issue Marker IOCB "
931 "(%x).\n", __func__
, vha
->host_no
, rval2
));
933 DEBUG11(printk("%s(%ld): done.\n", __func__
, vha
->host_no
));
940 qla2x00_lun_reset(struct fc_port
*fcport
, unsigned int l
, int tag
)
944 mbx_cmd_t
*mcp
= &mc
;
945 scsi_qla_host_t
*vha
;
949 DEBUG11(printk("%s(%ld): entered.\n", __func__
, fcport
->vha
->host_no
));
952 req
= vha
->hw
->req_q_map
[0];
954 mcp
->mb
[0] = MBC_LUN_RESET
;
955 mcp
->out_mb
= MBX_9
|MBX_3
|MBX_2
|MBX_1
|MBX_0
;
956 if (HAS_EXTENDED_IDS(vha
->hw
))
957 mcp
->mb
[1] = fcport
->loop_id
;
959 mcp
->mb
[1] = fcport
->loop_id
<< 8;
962 mcp
->mb
[9] = vha
->vp_idx
;
965 mcp
->tov
= MBX_TOV_SECONDS
;
967 rval
= qla2x00_mailbox_command(vha
, mcp
);
968 if (rval
!= QLA_SUCCESS
) {
969 DEBUG2_3_11(printk("%s(%ld): failed=%x.\n", __func__
,
970 vha
->host_no
, rval
));
973 /* Issue marker IOCB. */
974 rval2
= qla2x00_marker(vha
, req
, rsp
, fcport
->loop_id
, l
,
976 if (rval2
!= QLA_SUCCESS
) {
977 DEBUG2_3_11(printk("%s(%ld): failed to issue Marker IOCB "
978 "(%x).\n", __func__
, vha
->host_no
, rval2
));
980 DEBUG11(printk("%s(%ld): done.\n", __func__
, vha
->host_no
));
987 * qla2x00_get_adapter_id
988 * Get adapter ID and topology.
991 * ha = adapter block pointer.
992 * id = pointer for loop ID.
993 * al_pa = pointer for AL_PA.
994 * area = pointer for area.
995 * domain = pointer for domain.
996 * top = pointer for topology.
997 * TARGET_QUEUE_LOCK must be released.
998 * ADAPTER_STATE_LOCK must be released.
1001 * qla2x00 local function return status code.
1007 qla2x00_get_adapter_id(scsi_qla_host_t
*vha
, uint16_t *id
, uint8_t *al_pa
,
1008 uint8_t *area
, uint8_t *domain
, uint16_t *top
, uint16_t *sw_cap
)
1012 mbx_cmd_t
*mcp
= &mc
;
1014 DEBUG11(printk("qla2x00_get_adapter_id(%ld): entered.\n",
1017 mcp
->mb
[0] = MBC_GET_ADAPTER_LOOP_ID
;
1018 mcp
->mb
[9] = vha
->vp_idx
;
1019 mcp
->out_mb
= MBX_9
|MBX_0
;
1020 mcp
->in_mb
= MBX_9
|MBX_7
|MBX_6
|MBX_3
|MBX_2
|MBX_1
|MBX_0
;
1021 if (IS_QLA8XXX_TYPE(vha
->hw
))
1022 mcp
->in_mb
|= MBX_13
|MBX_12
|MBX_11
|MBX_10
;
1023 mcp
->tov
= MBX_TOV_SECONDS
;
1025 rval
= qla2x00_mailbox_command(vha
, mcp
);
1026 if (mcp
->mb
[0] == MBS_COMMAND_ERROR
)
1027 rval
= QLA_COMMAND_ERROR
;
1028 else if (mcp
->mb
[0] == MBS_INVALID_COMMAND
)
1029 rval
= QLA_INVALID_COMMAND
;
1033 *al_pa
= LSB(mcp
->mb
[2]);
1034 *area
= MSB(mcp
->mb
[2]);
1035 *domain
= LSB(mcp
->mb
[3]);
1037 *sw_cap
= mcp
->mb
[7];
1039 if (rval
!= QLA_SUCCESS
) {
1041 DEBUG2_3_11(printk("qla2x00_get_adapter_id(%ld): failed=%x.\n",
1042 vha
->host_no
, rval
));
1044 DEBUG11(printk("qla2x00_get_adapter_id(%ld): done.\n",
1047 if (IS_QLA8XXX_TYPE(vha
->hw
)) {
1048 vha
->fcoe_vlan_id
= mcp
->mb
[9] & 0xfff;
1049 vha
->fcoe_fcf_idx
= mcp
->mb
[10];
1050 vha
->fcoe_vn_port_mac
[5] = mcp
->mb
[11] >> 8;
1051 vha
->fcoe_vn_port_mac
[4] = mcp
->mb
[11] & 0xff;
1052 vha
->fcoe_vn_port_mac
[3] = mcp
->mb
[12] >> 8;
1053 vha
->fcoe_vn_port_mac
[2] = mcp
->mb
[12] & 0xff;
1054 vha
->fcoe_vn_port_mac
[1] = mcp
->mb
[13] >> 8;
1055 vha
->fcoe_vn_port_mac
[0] = mcp
->mb
[13] & 0xff;
1063 * qla2x00_get_retry_cnt
1064 * Get current firmware login retry count and delay.
1067 * ha = adapter block pointer.
1068 * retry_cnt = pointer to login retry count.
1069 * tov = pointer to login timeout value.
1072 * qla2x00 local function return status code.
1078 qla2x00_get_retry_cnt(scsi_qla_host_t
*vha
, uint8_t *retry_cnt
, uint8_t *tov
,
1084 mbx_cmd_t
*mcp
= &mc
;
1086 DEBUG11(printk("qla2x00_get_retry_cnt(%ld): entered.\n",
1089 mcp
->mb
[0] = MBC_GET_RETRY_COUNT
;
1090 mcp
->out_mb
= MBX_0
;
1091 mcp
->in_mb
= MBX_3
|MBX_2
|MBX_1
|MBX_0
;
1092 mcp
->tov
= MBX_TOV_SECONDS
;
1094 rval
= qla2x00_mailbox_command(vha
, mcp
);
1096 if (rval
!= QLA_SUCCESS
) {
1098 DEBUG2_3_11(printk("qla2x00_get_retry_cnt(%ld): failed = %x.\n",
1099 vha
->host_no
, mcp
->mb
[0]));
1101 /* Convert returned data and check our values. */
1102 *r_a_tov
= mcp
->mb
[3] / 2;
1103 ratov
= (mcp
->mb
[3]/2) / 10; /* mb[3] value is in 100ms */
1104 if (mcp
->mb
[1] * ratov
> (*retry_cnt
) * (*tov
)) {
1105 /* Update to the larger values */
1106 *retry_cnt
= (uint8_t)mcp
->mb
[1];
1110 DEBUG11(printk("qla2x00_get_retry_cnt(%ld): done. mb3=%d "
1111 "ratov=%d.\n", vha
->host_no
, mcp
->mb
[3], ratov
));
1118 * qla2x00_init_firmware
1119 * Initialize adapter firmware.
1122 * ha = adapter block pointer.
1123 * dptr = Initialization control block pointer.
1124 * size = size of initialization control block.
1125 * TARGET_QUEUE_LOCK must be released.
1126 * ADAPTER_STATE_LOCK must be released.
1129 * qla2x00 local function return status code.
1135 qla2x00_init_firmware(scsi_qla_host_t
*vha
, uint16_t size
)
1139 mbx_cmd_t
*mcp
= &mc
;
1140 struct qla_hw_data
*ha
= vha
->hw
;
1142 DEBUG11(printk("qla2x00_init_firmware(%ld): entered.\n",
1145 if (IS_QLA82XX(ha
) && ql2xdbwr
)
1146 qla82xx_wr_32(ha
, ha
->nxdb_wr_ptr
,
1147 (0x04 | (ha
->portnum
<< 5) | (0 << 8) | (0 << 16)));
1149 if (ha
->flags
.npiv_supported
)
1150 mcp
->mb
[0] = MBC_MID_INITIALIZE_FIRMWARE
;
1152 mcp
->mb
[0] = MBC_INITIALIZE_FIRMWARE
;
1155 mcp
->mb
[2] = MSW(ha
->init_cb_dma
);
1156 mcp
->mb
[3] = LSW(ha
->init_cb_dma
);
1157 mcp
->mb
[6] = MSW(MSD(ha
->init_cb_dma
));
1158 mcp
->mb
[7] = LSW(MSD(ha
->init_cb_dma
));
1159 mcp
->out_mb
= MBX_7
|MBX_6
|MBX_3
|MBX_2
|MBX_1
|MBX_0
;
1160 if (IS_QLA81XX(ha
) && ha
->ex_init_cb
->ex_version
) {
1162 mcp
->mb
[10] = MSW(ha
->ex_init_cb_dma
);
1163 mcp
->mb
[11] = LSW(ha
->ex_init_cb_dma
);
1164 mcp
->mb
[12] = MSW(MSD(ha
->ex_init_cb_dma
));
1165 mcp
->mb
[13] = LSW(MSD(ha
->ex_init_cb_dma
));
1166 mcp
->mb
[14] = sizeof(*ha
->ex_init_cb
);
1167 mcp
->out_mb
|= MBX_14
|MBX_13
|MBX_12
|MBX_11
|MBX_10
;
1170 mcp
->buf_size
= size
;
1171 mcp
->flags
= MBX_DMA_OUT
;
1172 mcp
->tov
= MBX_TOV_SECONDS
;
1173 rval
= qla2x00_mailbox_command(vha
, mcp
);
1175 if (rval
!= QLA_SUCCESS
) {
1177 DEBUG2_3_11(printk("qla2x00_init_firmware(%ld): failed=%x "
1179 vha
->host_no
, rval
, mcp
->mb
[0]));
1182 DEBUG11(printk("qla2x00_init_firmware(%ld): done.\n",
1190 * qla2x00_get_port_database
1191 * Issue normal/enhanced get port database mailbox command
1192 * and copy device name as necessary.
1195 * ha = adapter state pointer.
1196 * dev = structure pointer.
1197 * opt = enhanced cmd option byte.
1200 * qla2x00 local function return status code.
1206 qla2x00_get_port_database(scsi_qla_host_t
*vha
, fc_port_t
*fcport
, uint8_t opt
)
1210 mbx_cmd_t
*mcp
= &mc
;
1211 port_database_t
*pd
;
1212 struct port_database_24xx
*pd24
;
1214 struct qla_hw_data
*ha
= vha
->hw
;
1216 DEBUG11(printk("%s(%ld): entered.\n", __func__
, vha
->host_no
));
1219 pd
= dma_pool_alloc(ha
->s_dma_pool
, GFP_KERNEL
, &pd_dma
);
1221 DEBUG2_3(printk("%s(%ld): failed to allocate Port Database "
1222 "structure.\n", __func__
, vha
->host_no
));
1223 return QLA_MEMORY_ALLOC_FAILED
;
1225 memset(pd
, 0, max(PORT_DATABASE_SIZE
, PORT_DATABASE_24XX_SIZE
));
1227 mcp
->mb
[0] = MBC_GET_PORT_DATABASE
;
1228 if (opt
!= 0 && !IS_FWI2_CAPABLE(ha
))
1229 mcp
->mb
[0] = MBC_ENHANCED_GET_PORT_DATABASE
;
1230 mcp
->mb
[2] = MSW(pd_dma
);
1231 mcp
->mb
[3] = LSW(pd_dma
);
1232 mcp
->mb
[6] = MSW(MSD(pd_dma
));
1233 mcp
->mb
[7] = LSW(MSD(pd_dma
));
1234 mcp
->mb
[9] = vha
->vp_idx
;
1235 mcp
->out_mb
= MBX_9
|MBX_7
|MBX_6
|MBX_3
|MBX_2
|MBX_0
;
1237 if (IS_FWI2_CAPABLE(ha
)) {
1238 mcp
->mb
[1] = fcport
->loop_id
;
1240 mcp
->out_mb
|= MBX_10
|MBX_1
;
1241 mcp
->in_mb
|= MBX_1
;
1242 } else if (HAS_EXTENDED_IDS(ha
)) {
1243 mcp
->mb
[1] = fcport
->loop_id
;
1245 mcp
->out_mb
|= MBX_10
|MBX_1
;
1247 mcp
->mb
[1] = fcport
->loop_id
<< 8 | opt
;
1248 mcp
->out_mb
|= MBX_1
;
1250 mcp
->buf_size
= IS_FWI2_CAPABLE(ha
) ?
1251 PORT_DATABASE_24XX_SIZE
: PORT_DATABASE_SIZE
;
1252 mcp
->flags
= MBX_DMA_IN
;
1253 mcp
->tov
= (ha
->login_timeout
* 2) + (ha
->login_timeout
/ 2);
1254 rval
= qla2x00_mailbox_command(vha
, mcp
);
1255 if (rval
!= QLA_SUCCESS
)
1258 if (IS_FWI2_CAPABLE(ha
)) {
1259 pd24
= (struct port_database_24xx
*) pd
;
1261 /* Check for logged in state. */
1262 if (pd24
->current_login_state
!= PDS_PRLI_COMPLETE
&&
1263 pd24
->last_login_state
!= PDS_PRLI_COMPLETE
) {
1264 DEBUG2(qla_printk(KERN_WARNING
, ha
,
1265 "scsi(%ld): Unable to verify login-state (%x/%x) "
1266 " - portid=%02x%02x%02x.\n", vha
->host_no
,
1267 pd24
->current_login_state
, pd24
->last_login_state
,
1268 fcport
->d_id
.b
.domain
, fcport
->d_id
.b
.area
,
1269 fcport
->d_id
.b
.al_pa
));
1270 rval
= QLA_FUNCTION_FAILED
;
1274 /* Names are little-endian. */
1275 memcpy(fcport
->node_name
, pd24
->node_name
, WWN_SIZE
);
1276 memcpy(fcport
->port_name
, pd24
->port_name
, WWN_SIZE
);
1278 /* Get port_id of device. */
1279 fcport
->d_id
.b
.domain
= pd24
->port_id
[0];
1280 fcport
->d_id
.b
.area
= pd24
->port_id
[1];
1281 fcport
->d_id
.b
.al_pa
= pd24
->port_id
[2];
1282 fcport
->d_id
.b
.rsvd_1
= 0;
1284 /* If not target must be initiator or unknown type. */
1285 if ((pd24
->prli_svc_param_word_3
[0] & BIT_4
) == 0)
1286 fcport
->port_type
= FCT_INITIATOR
;
1288 fcport
->port_type
= FCT_TARGET
;
1290 /* Check for logged in state. */
1291 if (pd
->master_state
!= PD_STATE_PORT_LOGGED_IN
&&
1292 pd
->slave_state
!= PD_STATE_PORT_LOGGED_IN
) {
1293 DEBUG2(qla_printk(KERN_WARNING
, ha
,
1294 "scsi(%ld): Unable to verify login-state (%x/%x) "
1295 " - portid=%02x%02x%02x.\n", vha
->host_no
,
1296 pd
->master_state
, pd
->slave_state
,
1297 fcport
->d_id
.b
.domain
, fcport
->d_id
.b
.area
,
1298 fcport
->d_id
.b
.al_pa
));
1299 rval
= QLA_FUNCTION_FAILED
;
1303 /* Names are little-endian. */
1304 memcpy(fcport
->node_name
, pd
->node_name
, WWN_SIZE
);
1305 memcpy(fcport
->port_name
, pd
->port_name
, WWN_SIZE
);
1307 /* Get port_id of device. */
1308 fcport
->d_id
.b
.domain
= pd
->port_id
[0];
1309 fcport
->d_id
.b
.area
= pd
->port_id
[3];
1310 fcport
->d_id
.b
.al_pa
= pd
->port_id
[2];
1311 fcport
->d_id
.b
.rsvd_1
= 0;
1313 /* If not target must be initiator or unknown type. */
1314 if ((pd
->prli_svc_param_word_3
[0] & BIT_4
) == 0)
1315 fcport
->port_type
= FCT_INITIATOR
;
1317 fcport
->port_type
= FCT_TARGET
;
1319 /* Passback COS information. */
1320 fcport
->supported_classes
= (pd
->options
& BIT_4
) ?
1321 FC_COS_CLASS2
: FC_COS_CLASS3
;
1325 dma_pool_free(ha
->s_dma_pool
, pd
, pd_dma
);
1327 if (rval
!= QLA_SUCCESS
) {
1328 DEBUG2_3_11(printk("%s(%ld): failed=%x mb[0]=%x mb[1]=%x.\n",
1329 __func__
, vha
->host_no
, rval
, mcp
->mb
[0], mcp
->mb
[1]));
1331 DEBUG11(printk("%s(%ld): done.\n", __func__
, vha
->host_no
));
1338 * qla2x00_get_firmware_state
1339 * Get adapter firmware state.
1342 * ha = adapter block pointer.
1343 * dptr = pointer for firmware state.
1344 * TARGET_QUEUE_LOCK must be released.
1345 * ADAPTER_STATE_LOCK must be released.
1348 * qla2x00 local function return status code.
1354 qla2x00_get_firmware_state(scsi_qla_host_t
*vha
, uint16_t *states
)
1358 mbx_cmd_t
*mcp
= &mc
;
1360 DEBUG11(printk("qla2x00_get_firmware_state(%ld): entered.\n",
1363 mcp
->mb
[0] = MBC_GET_FIRMWARE_STATE
;
1364 mcp
->out_mb
= MBX_0
;
1365 if (IS_FWI2_CAPABLE(vha
->hw
))
1366 mcp
->in_mb
= MBX_5
|MBX_4
|MBX_3
|MBX_2
|MBX_1
|MBX_0
;
1368 mcp
->in_mb
= MBX_1
|MBX_0
;
1369 mcp
->tov
= MBX_TOV_SECONDS
;
1371 rval
= qla2x00_mailbox_command(vha
, mcp
);
1373 /* Return firmware states. */
1374 states
[0] = mcp
->mb
[1];
1375 if (IS_FWI2_CAPABLE(vha
->hw
)) {
1376 states
[1] = mcp
->mb
[2];
1377 states
[2] = mcp
->mb
[3];
1378 states
[3] = mcp
->mb
[4];
1379 states
[4] = mcp
->mb
[5];
1382 if (rval
!= QLA_SUCCESS
) {
1384 DEBUG2_3_11(printk("qla2x00_get_firmware_state(%ld): "
1385 "failed=%x.\n", vha
->host_no
, rval
));
1388 DEBUG11(printk("qla2x00_get_firmware_state(%ld): done.\n",
1396 * qla2x00_get_port_name
1397 * Issue get port name mailbox command.
1398 * Returned name is in big endian format.
1401 * ha = adapter block pointer.
1402 * loop_id = loop ID of device.
1403 * name = pointer for name.
1404 * TARGET_QUEUE_LOCK must be released.
1405 * ADAPTER_STATE_LOCK must be released.
1408 * qla2x00 local function return status code.
1414 qla2x00_get_port_name(scsi_qla_host_t
*vha
, uint16_t loop_id
, uint8_t *name
,
1419 mbx_cmd_t
*mcp
= &mc
;
1421 DEBUG11(printk("qla2x00_get_port_name(%ld): entered.\n",
1424 mcp
->mb
[0] = MBC_GET_PORT_NAME
;
1425 mcp
->mb
[9] = vha
->vp_idx
;
1426 mcp
->out_mb
= MBX_9
|MBX_1
|MBX_0
;
1427 if (HAS_EXTENDED_IDS(vha
->hw
)) {
1428 mcp
->mb
[1] = loop_id
;
1430 mcp
->out_mb
|= MBX_10
;
1432 mcp
->mb
[1] = loop_id
<< 8 | opt
;
1435 mcp
->in_mb
= MBX_7
|MBX_6
|MBX_3
|MBX_2
|MBX_1
|MBX_0
;
1436 mcp
->tov
= MBX_TOV_SECONDS
;
1438 rval
= qla2x00_mailbox_command(vha
, mcp
);
1440 if (rval
!= QLA_SUCCESS
) {
1442 DEBUG2_3_11(printk("qla2x00_get_port_name(%ld): failed=%x.\n",
1443 vha
->host_no
, rval
));
1446 /* This function returns name in big endian. */
1447 name
[0] = MSB(mcp
->mb
[2]);
1448 name
[1] = LSB(mcp
->mb
[2]);
1449 name
[2] = MSB(mcp
->mb
[3]);
1450 name
[3] = LSB(mcp
->mb
[3]);
1451 name
[4] = MSB(mcp
->mb
[6]);
1452 name
[5] = LSB(mcp
->mb
[6]);
1453 name
[6] = MSB(mcp
->mb
[7]);
1454 name
[7] = LSB(mcp
->mb
[7]);
1457 DEBUG11(printk("qla2x00_get_port_name(%ld): done.\n",
1466 * Issue LIP reset mailbox command.
1469 * ha = adapter block pointer.
1470 * TARGET_QUEUE_LOCK must be released.
1471 * ADAPTER_STATE_LOCK must be released.
1474 * qla2x00 local function return status code.
1480 qla2x00_lip_reset(scsi_qla_host_t
*vha
)
1484 mbx_cmd_t
*mcp
= &mc
;
1486 DEBUG11(printk("%s(%ld): entered.\n", __func__
, vha
->host_no
));
1488 if (IS_QLA8XXX_TYPE(vha
->hw
)) {
1489 /* Logout across all FCFs. */
1490 mcp
->mb
[0] = MBC_LIP_FULL_LOGIN
;
1493 mcp
->out_mb
= MBX_2
|MBX_1
|MBX_0
;
1494 } else if (IS_FWI2_CAPABLE(vha
->hw
)) {
1495 mcp
->mb
[0] = MBC_LIP_FULL_LOGIN
;
1498 mcp
->mb
[3] = vha
->hw
->loop_reset_delay
;
1499 mcp
->out_mb
= MBX_3
|MBX_2
|MBX_1
|MBX_0
;
1501 mcp
->mb
[0] = MBC_LIP_RESET
;
1502 mcp
->out_mb
= MBX_3
|MBX_2
|MBX_1
|MBX_0
;
1503 if (HAS_EXTENDED_IDS(vha
->hw
)) {
1504 mcp
->mb
[1] = 0x00ff;
1506 mcp
->out_mb
|= MBX_10
;
1508 mcp
->mb
[1] = 0xff00;
1510 mcp
->mb
[2] = vha
->hw
->loop_reset_delay
;
1514 mcp
->tov
= MBX_TOV_SECONDS
;
1516 rval
= qla2x00_mailbox_command(vha
, mcp
);
1518 if (rval
!= QLA_SUCCESS
) {
1520 DEBUG2_3_11(printk("%s(%ld): failed=%x.\n",
1521 __func__
, vha
->host_no
, rval
));
1524 DEBUG11(printk("%s(%ld): done.\n", __func__
, vha
->host_no
));
1535 * ha = adapter block pointer.
1536 * sns = pointer for command.
1537 * cmd_size = command size.
1538 * buf_size = response/command size.
1539 * TARGET_QUEUE_LOCK must be released.
1540 * ADAPTER_STATE_LOCK must be released.
1543 * qla2x00 local function return status code.
1549 qla2x00_send_sns(scsi_qla_host_t
*vha
, dma_addr_t sns_phys_address
,
1550 uint16_t cmd_size
, size_t buf_size
)
1554 mbx_cmd_t
*mcp
= &mc
;
1556 DEBUG11(printk("qla2x00_send_sns(%ld): entered.\n",
1559 DEBUG11(printk("qla2x00_send_sns: retry cnt=%d ratov=%d total "
1560 "tov=%d.\n", vha
->hw
->retry_count
, vha
->hw
->login_timeout
,
1563 mcp
->mb
[0] = MBC_SEND_SNS_COMMAND
;
1564 mcp
->mb
[1] = cmd_size
;
1565 mcp
->mb
[2] = MSW(sns_phys_address
);
1566 mcp
->mb
[3] = LSW(sns_phys_address
);
1567 mcp
->mb
[6] = MSW(MSD(sns_phys_address
));
1568 mcp
->mb
[7] = LSW(MSD(sns_phys_address
));
1569 mcp
->out_mb
= MBX_7
|MBX_6
|MBX_3
|MBX_2
|MBX_1
|MBX_0
;
1570 mcp
->in_mb
= MBX_0
|MBX_1
;
1571 mcp
->buf_size
= buf_size
;
1572 mcp
->flags
= MBX_DMA_OUT
|MBX_DMA_IN
;
1573 mcp
->tov
= (vha
->hw
->login_timeout
* 2) + (vha
->hw
->login_timeout
/ 2);
1574 rval
= qla2x00_mailbox_command(vha
, mcp
);
1576 if (rval
!= QLA_SUCCESS
) {
1578 DEBUG(printk("qla2x00_send_sns(%ld): failed=%x mb[0]=%x "
1579 "mb[1]=%x.\n", vha
->host_no
, rval
, mcp
->mb
[0], mcp
->mb
[1]));
1580 DEBUG2_3_11(printk("qla2x00_send_sns(%ld): failed=%x mb[0]=%x "
1581 "mb[1]=%x.\n", vha
->host_no
, rval
, mcp
->mb
[0], mcp
->mb
[1]));
1584 DEBUG11(printk("qla2x00_send_sns(%ld): done.\n", vha
->host_no
));
1591 qla24xx_login_fabric(scsi_qla_host_t
*vha
, uint16_t loop_id
, uint8_t domain
,
1592 uint8_t area
, uint8_t al_pa
, uint16_t *mb
, uint8_t opt
)
1596 struct logio_entry_24xx
*lg
;
1599 struct qla_hw_data
*ha
= vha
->hw
;
1600 struct req_que
*req
;
1601 struct rsp_que
*rsp
;
1603 DEBUG11(printk("%s(%ld): entered.\n", __func__
, vha
->host_no
));
1605 if (ha
->flags
.cpu_affinity_enabled
)
1606 req
= ha
->req_q_map
[0];
1611 lg
= dma_pool_alloc(ha
->s_dma_pool
, GFP_KERNEL
, &lg_dma
);
1613 DEBUG2_3(printk("%s(%ld): failed to allocate Login IOCB.\n",
1614 __func__
, vha
->host_no
));
1615 return QLA_MEMORY_ALLOC_FAILED
;
1617 memset(lg
, 0, sizeof(struct logio_entry_24xx
));
1619 lg
->entry_type
= LOGINOUT_PORT_IOCB_TYPE
;
1620 lg
->entry_count
= 1;
1621 lg
->handle
= MAKE_HANDLE(req
->id
, lg
->handle
);
1622 lg
->nport_handle
= cpu_to_le16(loop_id
);
1623 lg
->control_flags
= __constant_cpu_to_le16(LCF_COMMAND_PLOGI
);
1625 lg
->control_flags
|= __constant_cpu_to_le16(LCF_COND_PLOGI
);
1627 lg
->control_flags
|= __constant_cpu_to_le16(LCF_SKIP_PRLI
);
1628 lg
->port_id
[0] = al_pa
;
1629 lg
->port_id
[1] = area
;
1630 lg
->port_id
[2] = domain
;
1631 lg
->vp_index
= vha
->vp_idx
;
1632 rval
= qla2x00_issue_iocb(vha
, lg
, lg_dma
, 0);
1633 if (rval
!= QLA_SUCCESS
) {
1634 DEBUG2_3_11(printk("%s(%ld): failed to issue Login IOCB "
1635 "(%x).\n", __func__
, vha
->host_no
, rval
));
1636 } else if (lg
->entry_status
!= 0) {
1637 DEBUG2_3_11(printk("%s(%ld): failed to complete IOCB "
1638 "-- error status (%x).\n", __func__
, vha
->host_no
,
1640 rval
= QLA_FUNCTION_FAILED
;
1641 } else if (lg
->comp_status
!= __constant_cpu_to_le16(CS_COMPLETE
)) {
1642 iop
[0] = le32_to_cpu(lg
->io_parameter
[0]);
1643 iop
[1] = le32_to_cpu(lg
->io_parameter
[1]);
1645 DEBUG2_3_11(printk("%s(%ld): failed to complete IOCB "
1646 "-- completion status (%x) ioparam=%x/%x.\n", __func__
,
1647 vha
->host_no
, le16_to_cpu(lg
->comp_status
), iop
[0],
1651 case LSC_SCODE_PORTID_USED
:
1652 mb
[0] = MBS_PORT_ID_USED
;
1653 mb
[1] = LSW(iop
[1]);
1655 case LSC_SCODE_NPORT_USED
:
1656 mb
[0] = MBS_LOOP_ID_USED
;
1658 case LSC_SCODE_NOLINK
:
1659 case LSC_SCODE_NOIOCB
:
1660 case LSC_SCODE_NOXCB
:
1661 case LSC_SCODE_CMD_FAILED
:
1662 case LSC_SCODE_NOFABRIC
:
1663 case LSC_SCODE_FW_NOT_READY
:
1664 case LSC_SCODE_NOT_LOGGED_IN
:
1665 case LSC_SCODE_NOPCB
:
1666 case LSC_SCODE_ELS_REJECT
:
1667 case LSC_SCODE_CMD_PARAM_ERR
:
1668 case LSC_SCODE_NONPORT
:
1669 case LSC_SCODE_LOGGED_IN
:
1670 case LSC_SCODE_NOFLOGI_ACC
:
1672 mb
[0] = MBS_COMMAND_ERROR
;
1676 DEBUG11(printk("%s(%ld): done.\n", __func__
, vha
->host_no
));
1678 iop
[0] = le32_to_cpu(lg
->io_parameter
[0]);
1680 mb
[0] = MBS_COMMAND_COMPLETE
;
1682 if (iop
[0] & BIT_4
) {
1688 /* Passback COS information. */
1690 if (lg
->io_parameter
[7] || lg
->io_parameter
[8])
1691 mb
[10] |= BIT_0
; /* Class 2. */
1692 if (lg
->io_parameter
[9] || lg
->io_parameter
[10])
1693 mb
[10] |= BIT_1
; /* Class 3. */
1696 dma_pool_free(ha
->s_dma_pool
, lg
, lg_dma
);
1702 * qla2x00_login_fabric
1703 * Issue login fabric port mailbox command.
1706 * ha = adapter block pointer.
1707 * loop_id = device loop ID.
1708 * domain = device domain.
1709 * area = device area.
1710 * al_pa = device AL_PA.
1711 * status = pointer for return status.
1712 * opt = command options.
1713 * TARGET_QUEUE_LOCK must be released.
1714 * ADAPTER_STATE_LOCK must be released.
1717 * qla2x00 local function return status code.
1723 qla2x00_login_fabric(scsi_qla_host_t
*vha
, uint16_t loop_id
, uint8_t domain
,
1724 uint8_t area
, uint8_t al_pa
, uint16_t *mb
, uint8_t opt
)
1728 mbx_cmd_t
*mcp
= &mc
;
1729 struct qla_hw_data
*ha
= vha
->hw
;
1731 DEBUG11(printk("qla2x00_login_fabric(%ld): entered.\n", vha
->host_no
));
1733 mcp
->mb
[0] = MBC_LOGIN_FABRIC_PORT
;
1734 mcp
->out_mb
= MBX_3
|MBX_2
|MBX_1
|MBX_0
;
1735 if (HAS_EXTENDED_IDS(ha
)) {
1736 mcp
->mb
[1] = loop_id
;
1738 mcp
->out_mb
|= MBX_10
;
1740 mcp
->mb
[1] = (loop_id
<< 8) | opt
;
1742 mcp
->mb
[2] = domain
;
1743 mcp
->mb
[3] = area
<< 8 | al_pa
;
1745 mcp
->in_mb
= MBX_7
|MBX_6
|MBX_2
|MBX_1
|MBX_0
;
1746 mcp
->tov
= (ha
->login_timeout
* 2) + (ha
->login_timeout
/ 2);
1748 rval
= qla2x00_mailbox_command(vha
, mcp
);
1750 /* Return mailbox statuses. */
1757 /* COS retrieved from Get-Port-Database mailbox command. */
1761 if (rval
!= QLA_SUCCESS
) {
1762 /* RLU tmp code: need to change main mailbox_command function to
1763 * return ok even when the mailbox completion value is not
1764 * SUCCESS. The caller needs to be responsible to interpret
1765 * the return values of this mailbox command if we're not
1766 * to change too much of the existing code.
1768 if (mcp
->mb
[0] == 0x4001 || mcp
->mb
[0] == 0x4002 ||
1769 mcp
->mb
[0] == 0x4003 || mcp
->mb
[0] == 0x4005 ||
1770 mcp
->mb
[0] == 0x4006)
1774 DEBUG2_3_11(printk("qla2x00_login_fabric(%ld): failed=%x "
1775 "mb[0]=%x mb[1]=%x mb[2]=%x.\n", vha
->host_no
, rval
,
1776 mcp
->mb
[0], mcp
->mb
[1], mcp
->mb
[2]));
1779 DEBUG11(printk("qla2x00_login_fabric(%ld): done.\n",
1787 * qla2x00_login_local_device
1788 * Issue login loop port mailbox command.
1791 * ha = adapter block pointer.
1792 * loop_id = device loop ID.
1793 * opt = command options.
1796 * Return status code.
1803 qla2x00_login_local_device(scsi_qla_host_t
*vha
, fc_port_t
*fcport
,
1804 uint16_t *mb_ret
, uint8_t opt
)
1808 mbx_cmd_t
*mcp
= &mc
;
1809 struct qla_hw_data
*ha
= vha
->hw
;
1811 if (IS_FWI2_CAPABLE(ha
))
1812 return qla24xx_login_fabric(vha
, fcport
->loop_id
,
1813 fcport
->d_id
.b
.domain
, fcport
->d_id
.b
.area
,
1814 fcport
->d_id
.b
.al_pa
, mb_ret
, opt
);
1816 DEBUG3(printk("%s(%ld): entered.\n", __func__
, vha
->host_no
));
1818 mcp
->mb
[0] = MBC_LOGIN_LOOP_PORT
;
1819 if (HAS_EXTENDED_IDS(ha
))
1820 mcp
->mb
[1] = fcport
->loop_id
;
1822 mcp
->mb
[1] = fcport
->loop_id
<< 8;
1824 mcp
->out_mb
= MBX_2
|MBX_1
|MBX_0
;
1825 mcp
->in_mb
= MBX_7
|MBX_6
|MBX_1
|MBX_0
;
1826 mcp
->tov
= (ha
->login_timeout
* 2) + (ha
->login_timeout
/ 2);
1828 rval
= qla2x00_mailbox_command(vha
, mcp
);
1830 /* Return mailbox statuses. */
1831 if (mb_ret
!= NULL
) {
1832 mb_ret
[0] = mcp
->mb
[0];
1833 mb_ret
[1] = mcp
->mb
[1];
1834 mb_ret
[6] = mcp
->mb
[6];
1835 mb_ret
[7] = mcp
->mb
[7];
1838 if (rval
!= QLA_SUCCESS
) {
1839 /* AV tmp code: need to change main mailbox_command function to
1840 * return ok even when the mailbox completion value is not
1841 * SUCCESS. The caller needs to be responsible to interpret
1842 * the return values of this mailbox command if we're not
1843 * to change too much of the existing code.
1845 if (mcp
->mb
[0] == 0x4005 || mcp
->mb
[0] == 0x4006)
1848 DEBUG(printk("%s(%ld): failed=%x mb[0]=%x mb[1]=%x "
1849 "mb[6]=%x mb[7]=%x.\n", __func__
, vha
->host_no
, rval
,
1850 mcp
->mb
[0], mcp
->mb
[1], mcp
->mb
[6], mcp
->mb
[7]));
1851 DEBUG2_3(printk("%s(%ld): failed=%x mb[0]=%x mb[1]=%x "
1852 "mb[6]=%x mb[7]=%x.\n", __func__
, vha
->host_no
, rval
,
1853 mcp
->mb
[0], mcp
->mb
[1], mcp
->mb
[6], mcp
->mb
[7]));
1856 DEBUG3(printk("%s(%ld): done.\n", __func__
, vha
->host_no
));
1863 qla24xx_fabric_logout(scsi_qla_host_t
*vha
, uint16_t loop_id
, uint8_t domain
,
1864 uint8_t area
, uint8_t al_pa
)
1867 struct logio_entry_24xx
*lg
;
1869 struct qla_hw_data
*ha
= vha
->hw
;
1870 struct req_que
*req
;
1871 struct rsp_que
*rsp
;
1873 DEBUG11(printk("%s(%ld): entered.\n", __func__
, vha
->host_no
));
1875 lg
= dma_pool_alloc(ha
->s_dma_pool
, GFP_KERNEL
, &lg_dma
);
1877 DEBUG2_3(printk("%s(%ld): failed to allocate Logout IOCB.\n",
1878 __func__
, vha
->host_no
));
1879 return QLA_MEMORY_ALLOC_FAILED
;
1881 memset(lg
, 0, sizeof(struct logio_entry_24xx
));
1883 if (ql2xmaxqueues
> 1)
1884 req
= ha
->req_q_map
[0];
1888 lg
->entry_type
= LOGINOUT_PORT_IOCB_TYPE
;
1889 lg
->entry_count
= 1;
1890 lg
->handle
= MAKE_HANDLE(req
->id
, lg
->handle
);
1891 lg
->nport_handle
= cpu_to_le16(loop_id
);
1893 __constant_cpu_to_le16(LCF_COMMAND_LOGO
|LCF_IMPL_LOGO
|
1895 lg
->port_id
[0] = al_pa
;
1896 lg
->port_id
[1] = area
;
1897 lg
->port_id
[2] = domain
;
1898 lg
->vp_index
= vha
->vp_idx
;
1900 rval
= qla2x00_issue_iocb(vha
, lg
, lg_dma
, 0);
1901 if (rval
!= QLA_SUCCESS
) {
1902 DEBUG2_3_11(printk("%s(%ld): failed to issue Logout IOCB "
1903 "(%x).\n", __func__
, vha
->host_no
, rval
));
1904 } else if (lg
->entry_status
!= 0) {
1905 DEBUG2_3_11(printk("%s(%ld): failed to complete IOCB "
1906 "-- error status (%x).\n", __func__
, vha
->host_no
,
1908 rval
= QLA_FUNCTION_FAILED
;
1909 } else if (lg
->comp_status
!= __constant_cpu_to_le16(CS_COMPLETE
)) {
1910 DEBUG2_3_11(printk("%s(%ld %d): failed to complete IOCB "
1911 "-- completion status (%x) ioparam=%x/%x.\n", __func__
,
1912 vha
->host_no
, vha
->vp_idx
, le16_to_cpu(lg
->comp_status
),
1913 le32_to_cpu(lg
->io_parameter
[0]),
1914 le32_to_cpu(lg
->io_parameter
[1])));
1917 DEBUG11(printk("%s(%ld): done.\n", __func__
, vha
->host_no
));
1920 dma_pool_free(ha
->s_dma_pool
, lg
, lg_dma
);
1926 * qla2x00_fabric_logout
1927 * Issue logout fabric port mailbox command.
1930 * ha = adapter block pointer.
1931 * loop_id = device loop ID.
1932 * TARGET_QUEUE_LOCK must be released.
1933 * ADAPTER_STATE_LOCK must be released.
1936 * qla2x00 local function return status code.
1942 qla2x00_fabric_logout(scsi_qla_host_t
*vha
, uint16_t loop_id
, uint8_t domain
,
1943 uint8_t area
, uint8_t al_pa
)
1947 mbx_cmd_t
*mcp
= &mc
;
1949 DEBUG11(printk("qla2x00_fabric_logout(%ld): entered.\n",
1952 mcp
->mb
[0] = MBC_LOGOUT_FABRIC_PORT
;
1953 mcp
->out_mb
= MBX_1
|MBX_0
;
1954 if (HAS_EXTENDED_IDS(vha
->hw
)) {
1955 mcp
->mb
[1] = loop_id
;
1957 mcp
->out_mb
|= MBX_10
;
1959 mcp
->mb
[1] = loop_id
<< 8;
1962 mcp
->in_mb
= MBX_1
|MBX_0
;
1963 mcp
->tov
= MBX_TOV_SECONDS
;
1965 rval
= qla2x00_mailbox_command(vha
, mcp
);
1967 if (rval
!= QLA_SUCCESS
) {
1969 DEBUG2_3_11(printk("qla2x00_fabric_logout(%ld): failed=%x "
1970 "mbx1=%x.\n", vha
->host_no
, rval
, mcp
->mb
[1]));
1973 DEBUG11(printk("qla2x00_fabric_logout(%ld): done.\n",
1981 * qla2x00_full_login_lip
1982 * Issue full login LIP mailbox command.
1985 * ha = adapter block pointer.
1986 * TARGET_QUEUE_LOCK must be released.
1987 * ADAPTER_STATE_LOCK must be released.
1990 * qla2x00 local function return status code.
1996 qla2x00_full_login_lip(scsi_qla_host_t
*vha
)
2000 mbx_cmd_t
*mcp
= &mc
;
2002 DEBUG11(printk("qla2x00_full_login_lip(%ld): entered.\n",
2005 mcp
->mb
[0] = MBC_LIP_FULL_LOGIN
;
2006 mcp
->mb
[1] = IS_FWI2_CAPABLE(vha
->hw
) ? BIT_3
: 0;
2009 mcp
->out_mb
= MBX_3
|MBX_2
|MBX_1
|MBX_0
;
2011 mcp
->tov
= MBX_TOV_SECONDS
;
2013 rval
= qla2x00_mailbox_command(vha
, mcp
);
2015 if (rval
!= QLA_SUCCESS
) {
2017 DEBUG2_3_11(printk("qla2x00_full_login_lip(%ld): failed=%x.\n",
2018 vha
->host_no
, rval
));
2021 DEBUG11(printk("qla2x00_full_login_lip(%ld): done.\n",
2029 * qla2x00_get_id_list
2032 * ha = adapter block pointer.
2035 * qla2x00 local function return status code.
2041 qla2x00_get_id_list(scsi_qla_host_t
*vha
, void *id_list
, dma_addr_t id_list_dma
,
2046 mbx_cmd_t
*mcp
= &mc
;
2048 DEBUG11(printk("qla2x00_get_id_list(%ld): entered.\n",
2051 if (id_list
== NULL
)
2052 return QLA_FUNCTION_FAILED
;
2054 mcp
->mb
[0] = MBC_GET_ID_LIST
;
2055 mcp
->out_mb
= MBX_0
;
2056 if (IS_FWI2_CAPABLE(vha
->hw
)) {
2057 mcp
->mb
[2] = MSW(id_list_dma
);
2058 mcp
->mb
[3] = LSW(id_list_dma
);
2059 mcp
->mb
[6] = MSW(MSD(id_list_dma
));
2060 mcp
->mb
[7] = LSW(MSD(id_list_dma
));
2062 mcp
->mb
[9] = vha
->vp_idx
;
2063 mcp
->out_mb
|= MBX_9
|MBX_8
|MBX_7
|MBX_6
|MBX_3
|MBX_2
;
2065 mcp
->mb
[1] = MSW(id_list_dma
);
2066 mcp
->mb
[2] = LSW(id_list_dma
);
2067 mcp
->mb
[3] = MSW(MSD(id_list_dma
));
2068 mcp
->mb
[6] = LSW(MSD(id_list_dma
));
2069 mcp
->out_mb
|= MBX_6
|MBX_3
|MBX_2
|MBX_1
;
2071 mcp
->in_mb
= MBX_1
|MBX_0
;
2072 mcp
->tov
= MBX_TOV_SECONDS
;
2074 rval
= qla2x00_mailbox_command(vha
, mcp
);
2076 if (rval
!= QLA_SUCCESS
) {
2078 DEBUG2_3_11(printk("qla2x00_get_id_list(%ld): failed=%x.\n",
2079 vha
->host_no
, rval
));
2081 *entries
= mcp
->mb
[1];
2082 DEBUG11(printk("qla2x00_get_id_list(%ld): done.\n",
2090 * qla2x00_get_resource_cnts
2091 * Get current firmware resource counts.
2094 * ha = adapter block pointer.
2097 * qla2x00 local function return status code.
2103 qla2x00_get_resource_cnts(scsi_qla_host_t
*vha
, uint16_t *cur_xchg_cnt
,
2104 uint16_t *orig_xchg_cnt
, uint16_t *cur_iocb_cnt
,
2105 uint16_t *orig_iocb_cnt
, uint16_t *max_npiv_vports
, uint16_t *max_fcfs
)
2109 mbx_cmd_t
*mcp
= &mc
;
2111 DEBUG11(printk("%s(%ld): entered.\n", __func__
, vha
->host_no
));
2113 mcp
->mb
[0] = MBC_GET_RESOURCE_COUNTS
;
2114 mcp
->out_mb
= MBX_0
;
2115 mcp
->in_mb
= MBX_11
|MBX_10
|MBX_7
|MBX_6
|MBX_3
|MBX_2
|MBX_1
|MBX_0
;
2116 if (IS_QLA81XX(vha
->hw
))
2117 mcp
->in_mb
|= MBX_12
;
2118 mcp
->tov
= MBX_TOV_SECONDS
;
2120 rval
= qla2x00_mailbox_command(vha
, mcp
);
2122 if (rval
!= QLA_SUCCESS
) {
2124 DEBUG2_3_11(printk("%s(%ld): failed = %x.\n", __func__
,
2125 vha
->host_no
, mcp
->mb
[0]));
2127 DEBUG11(printk("%s(%ld): done. mb1=%x mb2=%x mb3=%x mb6=%x "
2128 "mb7=%x mb10=%x mb11=%x mb12=%x.\n", __func__
,
2129 vha
->host_no
, mcp
->mb
[1], mcp
->mb
[2], mcp
->mb
[3],
2130 mcp
->mb
[6], mcp
->mb
[7], mcp
->mb
[10], mcp
->mb
[11],
2134 *cur_xchg_cnt
= mcp
->mb
[3];
2136 *orig_xchg_cnt
= mcp
->mb
[6];
2138 *cur_iocb_cnt
= mcp
->mb
[7];
2140 *orig_iocb_cnt
= mcp
->mb
[10];
2141 if (vha
->hw
->flags
.npiv_supported
&& max_npiv_vports
)
2142 *max_npiv_vports
= mcp
->mb
[11];
2143 if (IS_QLA81XX(vha
->hw
) && max_fcfs
)
2144 *max_fcfs
= mcp
->mb
[12];
2150 #if defined(QL_DEBUG_LEVEL_3)
2152 * qla2x00_get_fcal_position_map
2153 * Get FCAL (LILP) position map using mailbox command
2156 * ha = adapter state pointer.
2157 * pos_map = buffer pointer (can be NULL).
2160 * qla2x00 local function return status code.
2166 qla2x00_get_fcal_position_map(scsi_qla_host_t
*vha
, char *pos_map
)
2170 mbx_cmd_t
*mcp
= &mc
;
2172 dma_addr_t pmap_dma
;
2173 struct qla_hw_data
*ha
= vha
->hw
;
2175 pmap
= dma_pool_alloc(ha
->s_dma_pool
, GFP_KERNEL
, &pmap_dma
);
2177 DEBUG2_3_11(printk("%s(%ld): **** Mem Alloc Failed ****",
2178 __func__
, vha
->host_no
));
2179 return QLA_MEMORY_ALLOC_FAILED
;
2181 memset(pmap
, 0, FCAL_MAP_SIZE
);
2183 mcp
->mb
[0] = MBC_GET_FC_AL_POSITION_MAP
;
2184 mcp
->mb
[2] = MSW(pmap_dma
);
2185 mcp
->mb
[3] = LSW(pmap_dma
);
2186 mcp
->mb
[6] = MSW(MSD(pmap_dma
));
2187 mcp
->mb
[7] = LSW(MSD(pmap_dma
));
2188 mcp
->out_mb
= MBX_7
|MBX_6
|MBX_3
|MBX_2
|MBX_0
;
2189 mcp
->in_mb
= MBX_1
|MBX_0
;
2190 mcp
->buf_size
= FCAL_MAP_SIZE
;
2191 mcp
->flags
= MBX_DMA_IN
;
2192 mcp
->tov
= (ha
->login_timeout
* 2) + (ha
->login_timeout
/ 2);
2193 rval
= qla2x00_mailbox_command(vha
, mcp
);
2195 if (rval
== QLA_SUCCESS
) {
2196 DEBUG11(printk("%s(%ld): (mb0=%x/mb1=%x) FC/AL Position Map "
2197 "size (%x)\n", __func__
, vha
->host_no
, mcp
->mb
[0],
2198 mcp
->mb
[1], (unsigned)pmap
[0]));
2199 DEBUG11(qla2x00_dump_buffer(pmap
, pmap
[0] + 1));
2202 memcpy(pos_map
, pmap
, FCAL_MAP_SIZE
);
2204 dma_pool_free(ha
->s_dma_pool
, pmap
, pmap_dma
);
2206 if (rval
!= QLA_SUCCESS
) {
2207 DEBUG2_3_11(printk("%s(%ld): failed=%x.\n", __func__
,
2208 vha
->host_no
, rval
));
2210 DEBUG11(printk("%s(%ld): done.\n", __func__
, vha
->host_no
));
2218 * qla2x00_get_link_status
2221 * ha = adapter block pointer.
2222 * loop_id = device loop ID.
2223 * ret_buf = pointer to link status return buffer.
2227 * BIT_0 = mem alloc error.
2228 * BIT_1 = mailbox error.
2231 qla2x00_get_link_status(scsi_qla_host_t
*vha
, uint16_t loop_id
,
2232 struct link_statistics
*stats
, dma_addr_t stats_dma
)
2236 mbx_cmd_t
*mcp
= &mc
;
2237 uint32_t *siter
, *diter
, dwords
;
2238 struct qla_hw_data
*ha
= vha
->hw
;
2240 DEBUG11(printk("%s(%ld): entered.\n", __func__
, vha
->host_no
));
2242 mcp
->mb
[0] = MBC_GET_LINK_STATUS
;
2243 mcp
->mb
[2] = MSW(stats_dma
);
2244 mcp
->mb
[3] = LSW(stats_dma
);
2245 mcp
->mb
[6] = MSW(MSD(stats_dma
));
2246 mcp
->mb
[7] = LSW(MSD(stats_dma
));
2247 mcp
->out_mb
= MBX_7
|MBX_6
|MBX_3
|MBX_2
|MBX_0
;
2249 if (IS_FWI2_CAPABLE(ha
)) {
2250 mcp
->mb
[1] = loop_id
;
2253 mcp
->out_mb
|= MBX_10
|MBX_4
|MBX_1
;
2254 mcp
->in_mb
|= MBX_1
;
2255 } else if (HAS_EXTENDED_IDS(ha
)) {
2256 mcp
->mb
[1] = loop_id
;
2258 mcp
->out_mb
|= MBX_10
|MBX_1
;
2260 mcp
->mb
[1] = loop_id
<< 8;
2261 mcp
->out_mb
|= MBX_1
;
2263 mcp
->tov
= MBX_TOV_SECONDS
;
2264 mcp
->flags
= IOCTL_CMD
;
2265 rval
= qla2x00_mailbox_command(vha
, mcp
);
2267 if (rval
== QLA_SUCCESS
) {
2268 if (mcp
->mb
[0] != MBS_COMMAND_COMPLETE
) {
2269 DEBUG2_3_11(printk("%s(%ld): cmd failed. mbx0=%x.\n",
2270 __func__
, vha
->host_no
, mcp
->mb
[0]));
2271 rval
= QLA_FUNCTION_FAILED
;
2273 /* Copy over data -- firmware data is LE. */
2274 dwords
= offsetof(struct link_statistics
, unused1
) / 4;
2275 siter
= diter
= &stats
->link_fail_cnt
;
2277 *diter
++ = le32_to_cpu(*siter
++);
2281 DEBUG2_3_11(printk("%s(%ld): failed=%x.\n", __func__
,
2282 vha
->host_no
, rval
));
2289 qla24xx_get_isp_stats(scsi_qla_host_t
*vha
, struct link_statistics
*stats
,
2290 dma_addr_t stats_dma
)
2294 mbx_cmd_t
*mcp
= &mc
;
2295 uint32_t *siter
, *diter
, dwords
;
2297 DEBUG11(printk("%s(%ld): entered.\n", __func__
, vha
->host_no
));
2299 mcp
->mb
[0] = MBC_GET_LINK_PRIV_STATS
;
2300 mcp
->mb
[2] = MSW(stats_dma
);
2301 mcp
->mb
[3] = LSW(stats_dma
);
2302 mcp
->mb
[6] = MSW(MSD(stats_dma
));
2303 mcp
->mb
[7] = LSW(MSD(stats_dma
));
2304 mcp
->mb
[8] = sizeof(struct link_statistics
) / 4;
2305 mcp
->mb
[9] = vha
->vp_idx
;
2307 mcp
->out_mb
= MBX_10
|MBX_9
|MBX_8
|MBX_7
|MBX_6
|MBX_3
|MBX_2
|MBX_0
;
2308 mcp
->in_mb
= MBX_2
|MBX_1
|MBX_0
;
2309 mcp
->tov
= MBX_TOV_SECONDS
;
2310 mcp
->flags
= IOCTL_CMD
;
2311 rval
= qla2x00_mailbox_command(vha
, mcp
);
2313 if (rval
== QLA_SUCCESS
) {
2314 if (mcp
->mb
[0] != MBS_COMMAND_COMPLETE
) {
2315 DEBUG2_3_11(printk("%s(%ld): cmd failed. mbx0=%x.\n",
2316 __func__
, vha
->host_no
, mcp
->mb
[0]));
2317 rval
= QLA_FUNCTION_FAILED
;
2319 /* Copy over data -- firmware data is LE. */
2320 dwords
= sizeof(struct link_statistics
) / 4;
2321 siter
= diter
= &stats
->link_fail_cnt
;
2323 *diter
++ = le32_to_cpu(*siter
++);
2327 DEBUG2_3_11(printk("%s(%ld): failed=%x.\n", __func__
,
2328 vha
->host_no
, rval
));
2335 qla24xx_abort_command(srb_t
*sp
)
2338 unsigned long flags
= 0;
2340 struct abort_entry_24xx
*abt
;
2343 fc_port_t
*fcport
= sp
->fcport
;
2344 struct scsi_qla_host
*vha
= fcport
->vha
;
2345 struct qla_hw_data
*ha
= vha
->hw
;
2346 struct req_que
*req
= vha
->req
;
2348 DEBUG11(printk("%s(%ld): entered.\n", __func__
, vha
->host_no
));
2350 spin_lock_irqsave(&ha
->hardware_lock
, flags
);
2351 for (handle
= 1; handle
< MAX_OUTSTANDING_COMMANDS
; handle
++) {
2352 if (req
->outstanding_cmds
[handle
] == sp
)
2355 spin_unlock_irqrestore(&ha
->hardware_lock
, flags
);
2356 if (handle
== MAX_OUTSTANDING_COMMANDS
) {
2357 /* Command not found. */
2358 return QLA_FUNCTION_FAILED
;
2361 abt
= dma_pool_alloc(ha
->s_dma_pool
, GFP_KERNEL
, &abt_dma
);
2363 DEBUG2_3(printk("%s(%ld): failed to allocate Abort IOCB.\n",
2364 __func__
, vha
->host_no
));
2365 return QLA_MEMORY_ALLOC_FAILED
;
2367 memset(abt
, 0, sizeof(struct abort_entry_24xx
));
2369 abt
->entry_type
= ABORT_IOCB_TYPE
;
2370 abt
->entry_count
= 1;
2371 abt
->handle
= MAKE_HANDLE(req
->id
, abt
->handle
);
2372 abt
->nport_handle
= cpu_to_le16(fcport
->loop_id
);
2373 abt
->handle_to_abort
= MAKE_HANDLE(req
->id
, handle
);
2374 abt
->port_id
[0] = fcport
->d_id
.b
.al_pa
;
2375 abt
->port_id
[1] = fcport
->d_id
.b
.area
;
2376 abt
->port_id
[2] = fcport
->d_id
.b
.domain
;
2377 abt
->vp_index
= fcport
->vp_idx
;
2379 abt
->req_que_no
= cpu_to_le16(req
->id
);
2381 rval
= qla2x00_issue_iocb(vha
, abt
, abt_dma
, 0);
2382 if (rval
!= QLA_SUCCESS
) {
2383 DEBUG2_3_11(printk("%s(%ld): failed to issue IOCB (%x).\n",
2384 __func__
, vha
->host_no
, rval
));
2385 } else if (abt
->entry_status
!= 0) {
2386 DEBUG2_3_11(printk("%s(%ld): failed to complete IOCB "
2387 "-- error status (%x).\n", __func__
, vha
->host_no
,
2388 abt
->entry_status
));
2389 rval
= QLA_FUNCTION_FAILED
;
2390 } else if (abt
->nport_handle
!= __constant_cpu_to_le16(0)) {
2391 DEBUG2_3_11(printk("%s(%ld): failed to complete IOCB "
2392 "-- completion status (%x).\n", __func__
, vha
->host_no
,
2393 le16_to_cpu(abt
->nport_handle
)));
2394 rval
= QLA_FUNCTION_FAILED
;
2396 DEBUG11(printk("%s(%ld): done.\n", __func__
, vha
->host_no
));
2399 dma_pool_free(ha
->s_dma_pool
, abt
, abt_dma
);
2404 struct tsk_mgmt_cmd
{
2406 struct tsk_mgmt_entry tsk
;
2407 struct sts_entry_24xx sts
;
2412 __qla24xx_issue_tmf(char *name
, uint32_t type
, struct fc_port
*fcport
,
2413 unsigned int l
, int tag
)
2416 struct tsk_mgmt_cmd
*tsk
;
2417 struct sts_entry_24xx
*sts
;
2419 scsi_qla_host_t
*vha
;
2420 struct qla_hw_data
*ha
;
2421 struct req_que
*req
;
2422 struct rsp_que
*rsp
;
2424 DEBUG11(printk("%s(%ld): entered.\n", __func__
, fcport
->vha
->host_no
));
2429 if (ha
->flags
.cpu_affinity_enabled
)
2430 rsp
= ha
->rsp_q_map
[tag
+ 1];
2433 tsk
= dma_pool_alloc(ha
->s_dma_pool
, GFP_KERNEL
, &tsk_dma
);
2435 DEBUG2_3(printk("%s(%ld): failed to allocate Task Management "
2436 "IOCB.\n", __func__
, vha
->host_no
));
2437 return QLA_MEMORY_ALLOC_FAILED
;
2439 memset(tsk
, 0, sizeof(struct tsk_mgmt_cmd
));
2441 tsk
->p
.tsk
.entry_type
= TSK_MGMT_IOCB_TYPE
;
2442 tsk
->p
.tsk
.entry_count
= 1;
2443 tsk
->p
.tsk
.handle
= MAKE_HANDLE(req
->id
, tsk
->p
.tsk
.handle
);
2444 tsk
->p
.tsk
.nport_handle
= cpu_to_le16(fcport
->loop_id
);
2445 tsk
->p
.tsk
.timeout
= cpu_to_le16(ha
->r_a_tov
/ 10 * 2);
2446 tsk
->p
.tsk
.control_flags
= cpu_to_le32(type
);
2447 tsk
->p
.tsk
.port_id
[0] = fcport
->d_id
.b
.al_pa
;
2448 tsk
->p
.tsk
.port_id
[1] = fcport
->d_id
.b
.area
;
2449 tsk
->p
.tsk
.port_id
[2] = fcport
->d_id
.b
.domain
;
2450 tsk
->p
.tsk
.vp_index
= fcport
->vp_idx
;
2451 if (type
== TCF_LUN_RESET
) {
2452 int_to_scsilun(l
, &tsk
->p
.tsk
.lun
);
2453 host_to_fcp_swap((uint8_t *)&tsk
->p
.tsk
.lun
,
2454 sizeof(tsk
->p
.tsk
.lun
));
2458 rval
= qla2x00_issue_iocb(vha
, tsk
, tsk_dma
, 0);
2459 if (rval
!= QLA_SUCCESS
) {
2460 DEBUG2_3_11(printk("%s(%ld): failed to issue %s Reset IOCB "
2461 "(%x).\n", __func__
, vha
->host_no
, name
, rval
));
2462 } else if (sts
->entry_status
!= 0) {
2463 DEBUG2_3_11(printk("%s(%ld): failed to complete IOCB "
2464 "-- error status (%x).\n", __func__
, vha
->host_no
,
2465 sts
->entry_status
));
2466 rval
= QLA_FUNCTION_FAILED
;
2467 } else if (sts
->comp_status
!=
2468 __constant_cpu_to_le16(CS_COMPLETE
)) {
2469 DEBUG2_3_11(printk("%s(%ld): failed to complete IOCB "
2470 "-- completion status (%x).\n", __func__
,
2471 vha
->host_no
, le16_to_cpu(sts
->comp_status
)));
2472 rval
= QLA_FUNCTION_FAILED
;
2473 } else if (le16_to_cpu(sts
->scsi_status
) &
2474 SS_RESPONSE_INFO_LEN_VALID
) {
2475 if (le32_to_cpu(sts
->rsp_data_len
) < 4) {
2476 DEBUG2_3_11(printk("%s(%ld): ignoring inconsistent "
2477 "data length -- not enough response info (%d).\n",
2478 __func__
, vha
->host_no
,
2479 le32_to_cpu(sts
->rsp_data_len
)));
2480 } else if (sts
->data
[3]) {
2481 DEBUG2_3_11(printk("%s(%ld): failed to complete IOCB "
2482 "-- response (%x).\n", __func__
,
2483 vha
->host_no
, sts
->data
[3]));
2484 rval
= QLA_FUNCTION_FAILED
;
2488 /* Issue marker IOCB. */
2489 rval2
= qla2x00_marker(vha
, req
, rsp
, fcport
->loop_id
, l
,
2490 type
== TCF_LUN_RESET
? MK_SYNC_ID_LUN
: MK_SYNC_ID
);
2491 if (rval2
!= QLA_SUCCESS
) {
2492 DEBUG2_3_11(printk("%s(%ld): failed to issue Marker IOCB "
2493 "(%x).\n", __func__
, vha
->host_no
, rval2
));
2495 DEBUG11(printk("%s(%ld): done.\n", __func__
, vha
->host_no
));
2498 dma_pool_free(ha
->s_dma_pool
, tsk
, tsk_dma
);
2504 qla24xx_abort_target(struct fc_port
*fcport
, unsigned int l
, int tag
)
2506 struct qla_hw_data
*ha
= fcport
->vha
->hw
;
2508 if ((ql2xasynctmfenable
) && IS_FWI2_CAPABLE(ha
))
2509 return qla2x00_async_tm_cmd(fcport
, TCF_TARGET_RESET
, l
, tag
);
2511 return __qla24xx_issue_tmf("Target", TCF_TARGET_RESET
, fcport
, l
, tag
);
2515 qla24xx_lun_reset(struct fc_port
*fcport
, unsigned int l
, int tag
)
2517 struct qla_hw_data
*ha
= fcport
->vha
->hw
;
2519 if ((ql2xasynctmfenable
) && IS_FWI2_CAPABLE(ha
))
2520 return qla2x00_async_tm_cmd(fcport
, TCF_LUN_RESET
, l
, tag
);
2522 return __qla24xx_issue_tmf("Lun", TCF_LUN_RESET
, fcport
, l
, tag
);
2526 qla2x00_system_error(scsi_qla_host_t
*vha
)
2530 mbx_cmd_t
*mcp
= &mc
;
2531 struct qla_hw_data
*ha
= vha
->hw
;
2533 if (!IS_QLA23XX(ha
) && !IS_FWI2_CAPABLE(ha
))
2534 return QLA_FUNCTION_FAILED
;
2536 DEBUG11(printk("%s(%ld): entered.\n", __func__
, vha
->host_no
));
2538 mcp
->mb
[0] = MBC_GEN_SYSTEM_ERROR
;
2539 mcp
->out_mb
= MBX_0
;
2543 rval
= qla2x00_mailbox_command(vha
, mcp
);
2545 if (rval
!= QLA_SUCCESS
) {
2546 DEBUG2_3_11(printk("%s(%ld): failed=%x.\n", __func__
,
2547 vha
->host_no
, rval
));
2549 DEBUG11(printk("%s(%ld): done.\n", __func__
, vha
->host_no
));
2556 * qla2x00_set_serdes_params() -
2562 qla2x00_set_serdes_params(scsi_qla_host_t
*vha
, uint16_t sw_em_1g
,
2563 uint16_t sw_em_2g
, uint16_t sw_em_4g
)
2567 mbx_cmd_t
*mcp
= &mc
;
2569 DEBUG11(printk("%s(%ld): entered.\n", __func__
, vha
->host_no
));
2571 mcp
->mb
[0] = MBC_SERDES_PARAMS
;
2573 mcp
->mb
[2] = sw_em_1g
| BIT_15
;
2574 mcp
->mb
[3] = sw_em_2g
| BIT_15
;
2575 mcp
->mb
[4] = sw_em_4g
| BIT_15
;
2576 mcp
->out_mb
= MBX_4
|MBX_3
|MBX_2
|MBX_1
|MBX_0
;
2578 mcp
->tov
= MBX_TOV_SECONDS
;
2580 rval
= qla2x00_mailbox_command(vha
, mcp
);
2582 if (rval
!= QLA_SUCCESS
) {
2584 DEBUG2_3_11(printk("%s(%ld): failed=%x (%x).\n", __func__
,
2585 vha
->host_no
, rval
, mcp
->mb
[0]));
2588 DEBUG11(printk("%s(%ld): done.\n", __func__
, vha
->host_no
));
2595 qla2x00_stop_firmware(scsi_qla_host_t
*vha
)
2599 mbx_cmd_t
*mcp
= &mc
;
2601 if (!IS_FWI2_CAPABLE(vha
->hw
))
2602 return QLA_FUNCTION_FAILED
;
2604 DEBUG11(printk("%s(%ld): entered.\n", __func__
, vha
->host_no
));
2606 mcp
->mb
[0] = MBC_STOP_FIRMWARE
;
2607 mcp
->out_mb
= MBX_0
;
2611 rval
= qla2x00_mailbox_command(vha
, mcp
);
2613 if (rval
!= QLA_SUCCESS
) {
2614 DEBUG2_3_11(printk("%s(%ld): failed=%x.\n", __func__
,
2615 vha
->host_no
, rval
));
2616 if (mcp
->mb
[0] == MBS_INVALID_COMMAND
)
2617 rval
= QLA_INVALID_COMMAND
;
2619 DEBUG11(printk("%s(%ld): done.\n", __func__
, vha
->host_no
));
2626 qla2x00_enable_eft_trace(scsi_qla_host_t
*vha
, dma_addr_t eft_dma
,
2631 mbx_cmd_t
*mcp
= &mc
;
2633 if (!IS_FWI2_CAPABLE(vha
->hw
))
2634 return QLA_FUNCTION_FAILED
;
2636 if (unlikely(pci_channel_offline(vha
->hw
->pdev
)))
2637 return QLA_FUNCTION_FAILED
;
2639 DEBUG11(printk("%s(%ld): entered.\n", __func__
, vha
->host_no
));
2641 mcp
->mb
[0] = MBC_TRACE_CONTROL
;
2642 mcp
->mb
[1] = TC_EFT_ENABLE
;
2643 mcp
->mb
[2] = LSW(eft_dma
);
2644 mcp
->mb
[3] = MSW(eft_dma
);
2645 mcp
->mb
[4] = LSW(MSD(eft_dma
));
2646 mcp
->mb
[5] = MSW(MSD(eft_dma
));
2647 mcp
->mb
[6] = buffers
;
2648 mcp
->mb
[7] = TC_AEN_DISABLE
;
2649 mcp
->out_mb
= MBX_7
|MBX_6
|MBX_5
|MBX_4
|MBX_3
|MBX_2
|MBX_1
|MBX_0
;
2650 mcp
->in_mb
= MBX_1
|MBX_0
;
2651 mcp
->tov
= MBX_TOV_SECONDS
;
2653 rval
= qla2x00_mailbox_command(vha
, mcp
);
2654 if (rval
!= QLA_SUCCESS
) {
2655 DEBUG2_3_11(printk("%s(%ld): failed=%x mb[0]=%x mb[1]=%x.\n",
2656 __func__
, vha
->host_no
, rval
, mcp
->mb
[0], mcp
->mb
[1]));
2658 DEBUG11(printk("%s(%ld): done.\n", __func__
, vha
->host_no
));
2665 qla2x00_disable_eft_trace(scsi_qla_host_t
*vha
)
2669 mbx_cmd_t
*mcp
= &mc
;
2671 if (!IS_FWI2_CAPABLE(vha
->hw
))
2672 return QLA_FUNCTION_FAILED
;
2674 if (unlikely(pci_channel_offline(vha
->hw
->pdev
)))
2675 return QLA_FUNCTION_FAILED
;
2677 DEBUG11(printk("%s(%ld): entered.\n", __func__
, vha
->host_no
));
2679 mcp
->mb
[0] = MBC_TRACE_CONTROL
;
2680 mcp
->mb
[1] = TC_EFT_DISABLE
;
2681 mcp
->out_mb
= MBX_1
|MBX_0
;
2682 mcp
->in_mb
= MBX_1
|MBX_0
;
2683 mcp
->tov
= MBX_TOV_SECONDS
;
2685 rval
= qla2x00_mailbox_command(vha
, mcp
);
2686 if (rval
!= QLA_SUCCESS
) {
2687 DEBUG2_3_11(printk("%s(%ld): failed=%x mb[0]=%x mb[1]=%x.\n",
2688 __func__
, vha
->host_no
, rval
, mcp
->mb
[0], mcp
->mb
[1]));
2690 DEBUG11(printk("%s(%ld): done.\n", __func__
, vha
->host_no
));
2697 qla2x00_enable_fce_trace(scsi_qla_host_t
*vha
, dma_addr_t fce_dma
,
2698 uint16_t buffers
, uint16_t *mb
, uint32_t *dwords
)
2702 mbx_cmd_t
*mcp
= &mc
;
2704 if (!IS_QLA25XX(vha
->hw
) && !IS_QLA81XX(vha
->hw
))
2705 return QLA_FUNCTION_FAILED
;
2707 if (unlikely(pci_channel_offline(vha
->hw
->pdev
)))
2708 return QLA_FUNCTION_FAILED
;
2710 DEBUG11(printk("%s(%ld): entered.\n", __func__
, vha
->host_no
));
2712 mcp
->mb
[0] = MBC_TRACE_CONTROL
;
2713 mcp
->mb
[1] = TC_FCE_ENABLE
;
2714 mcp
->mb
[2] = LSW(fce_dma
);
2715 mcp
->mb
[3] = MSW(fce_dma
);
2716 mcp
->mb
[4] = LSW(MSD(fce_dma
));
2717 mcp
->mb
[5] = MSW(MSD(fce_dma
));
2718 mcp
->mb
[6] = buffers
;
2719 mcp
->mb
[7] = TC_AEN_DISABLE
;
2721 mcp
->mb
[9] = TC_FCE_DEFAULT_RX_SIZE
;
2722 mcp
->mb
[10] = TC_FCE_DEFAULT_TX_SIZE
;
2723 mcp
->out_mb
= MBX_10
|MBX_9
|MBX_8
|MBX_7
|MBX_6
|MBX_5
|MBX_4
|MBX_3
|MBX_2
|
2725 mcp
->in_mb
= MBX_6
|MBX_5
|MBX_4
|MBX_3
|MBX_2
|MBX_1
|MBX_0
;
2726 mcp
->tov
= MBX_TOV_SECONDS
;
2728 rval
= qla2x00_mailbox_command(vha
, mcp
);
2729 if (rval
!= QLA_SUCCESS
) {
2730 DEBUG2_3_11(printk("%s(%ld): failed=%x mb[0]=%x mb[1]=%x.\n",
2731 __func__
, vha
->host_no
, rval
, mcp
->mb
[0], mcp
->mb
[1]));
2733 DEBUG11(printk("%s(%ld): done.\n", __func__
, vha
->host_no
));
2736 memcpy(mb
, mcp
->mb
, 8 * sizeof(*mb
));
2745 qla2x00_disable_fce_trace(scsi_qla_host_t
*vha
, uint64_t *wr
, uint64_t *rd
)
2749 mbx_cmd_t
*mcp
= &mc
;
2751 if (!IS_FWI2_CAPABLE(vha
->hw
))
2752 return QLA_FUNCTION_FAILED
;
2754 if (unlikely(pci_channel_offline(vha
->hw
->pdev
)))
2755 return QLA_FUNCTION_FAILED
;
2757 DEBUG11(printk("%s(%ld): entered.\n", __func__
, vha
->host_no
));
2759 mcp
->mb
[0] = MBC_TRACE_CONTROL
;
2760 mcp
->mb
[1] = TC_FCE_DISABLE
;
2761 mcp
->mb
[2] = TC_FCE_DISABLE_TRACE
;
2762 mcp
->out_mb
= MBX_2
|MBX_1
|MBX_0
;
2763 mcp
->in_mb
= MBX_9
|MBX_8
|MBX_7
|MBX_6
|MBX_5
|MBX_4
|MBX_3
|MBX_2
|
2765 mcp
->tov
= MBX_TOV_SECONDS
;
2767 rval
= qla2x00_mailbox_command(vha
, mcp
);
2768 if (rval
!= QLA_SUCCESS
) {
2769 DEBUG2_3_11(printk("%s(%ld): failed=%x mb[0]=%x mb[1]=%x.\n",
2770 __func__
, vha
->host_no
, rval
, mcp
->mb
[0], mcp
->mb
[1]));
2772 DEBUG11(printk("%s(%ld): done.\n", __func__
, vha
->host_no
));
2775 *wr
= (uint64_t) mcp
->mb
[5] << 48 |
2776 (uint64_t) mcp
->mb
[4] << 32 |
2777 (uint64_t) mcp
->mb
[3] << 16 |
2778 (uint64_t) mcp
->mb
[2];
2780 *rd
= (uint64_t) mcp
->mb
[9] << 48 |
2781 (uint64_t) mcp
->mb
[8] << 32 |
2782 (uint64_t) mcp
->mb
[7] << 16 |
2783 (uint64_t) mcp
->mb
[6];
2790 qla2x00_get_idma_speed(scsi_qla_host_t
*vha
, uint16_t loop_id
,
2791 uint16_t *port_speed
, uint16_t *mb
)
2795 mbx_cmd_t
*mcp
= &mc
;
2797 if (!IS_IIDMA_CAPABLE(vha
->hw
))
2798 return QLA_FUNCTION_FAILED
;
2800 DEBUG11(printk("%s(%ld): entered.\n", __func__
, vha
->host_no
));
2802 mcp
->mb
[0] = MBC_PORT_PARAMS
;
2803 mcp
->mb
[1] = loop_id
;
2804 mcp
->mb
[2] = mcp
->mb
[3] = 0;
2805 mcp
->mb
[9] = vha
->vp_idx
;
2806 mcp
->out_mb
= MBX_9
|MBX_3
|MBX_2
|MBX_1
|MBX_0
;
2807 mcp
->in_mb
= MBX_3
|MBX_1
|MBX_0
;
2808 mcp
->tov
= MBX_TOV_SECONDS
;
2810 rval
= qla2x00_mailbox_command(vha
, mcp
);
2812 /* Return mailbox statuses. */
2819 if (rval
!= QLA_SUCCESS
) {
2820 DEBUG2_3_11(printk("%s(%ld): failed=%x.\n", __func__
,
2821 vha
->host_no
, rval
));
2823 DEBUG11(printk("%s(%ld): done.\n", __func__
, vha
->host_no
));
2825 *port_speed
= mcp
->mb
[3];
2832 qla2x00_set_idma_speed(scsi_qla_host_t
*vha
, uint16_t loop_id
,
2833 uint16_t port_speed
, uint16_t *mb
)
2837 mbx_cmd_t
*mcp
= &mc
;
2839 if (!IS_IIDMA_CAPABLE(vha
->hw
))
2840 return QLA_FUNCTION_FAILED
;
2842 DEBUG11(printk("%s(%ld): entered.\n", __func__
, vha
->host_no
));
2844 mcp
->mb
[0] = MBC_PORT_PARAMS
;
2845 mcp
->mb
[1] = loop_id
;
2847 if (IS_QLA8XXX_TYPE(vha
->hw
))
2848 mcp
->mb
[3] = port_speed
& (BIT_5
|BIT_4
|BIT_3
|BIT_2
|BIT_1
|BIT_0
);
2850 mcp
->mb
[3] = port_speed
& (BIT_2
|BIT_1
|BIT_0
);
2851 mcp
->mb
[9] = vha
->vp_idx
;
2852 mcp
->out_mb
= MBX_9
|MBX_3
|MBX_2
|MBX_1
|MBX_0
;
2853 mcp
->in_mb
= MBX_3
|MBX_1
|MBX_0
;
2854 mcp
->tov
= MBX_TOV_SECONDS
;
2856 rval
= qla2x00_mailbox_command(vha
, mcp
);
2858 /* Return mailbox statuses. */
2865 if (rval
!= QLA_SUCCESS
) {
2866 DEBUG2_3_11(printk("%s(%ld): failed=%x.\n", __func__
,
2867 vha
->host_no
, rval
));
2869 DEBUG11(printk("%s(%ld): done.\n", __func__
, vha
->host_no
));
2876 qla24xx_report_id_acquisition(scsi_qla_host_t
*vha
,
2877 struct vp_rpt_id_entry_24xx
*rptid_entry
)
2880 uint16_t stat
= le16_to_cpu(rptid_entry
->vp_idx
);
2881 struct qla_hw_data
*ha
= vha
->hw
;
2882 scsi_qla_host_t
*vp
;
2883 unsigned long flags
;
2885 if (rptid_entry
->entry_status
!= 0)
2888 if (rptid_entry
->format
== 0) {
2889 DEBUG15(printk("%s:format 0 : scsi(%ld) number of VPs setup %d,"
2890 " number of VPs acquired %d\n", __func__
, vha
->host_no
,
2891 MSB(le16_to_cpu(rptid_entry
->vp_count
)),
2892 LSB(le16_to_cpu(rptid_entry
->vp_count
))));
2893 DEBUG15(printk("%s primary port id %02x%02x%02x\n", __func__
,
2894 rptid_entry
->port_id
[2], rptid_entry
->port_id
[1],
2895 rptid_entry
->port_id
[0]));
2896 } else if (rptid_entry
->format
== 1) {
2898 DEBUG15(printk("%s:format 1: scsi(%ld): VP[%d] enabled "
2900 "with port id %02x%02x%02x\n", __func__
, vha
->host_no
,
2902 rptid_entry
->port_id
[2], rptid_entry
->port_id
[1],
2903 rptid_entry
->port_id
[0]));
2906 if (vp_idx
== 0 && (MSB(stat
) != 1))
2909 if (MSB(stat
) == 1) {
2910 DEBUG2(printk("scsi(%ld): Could not acquire ID for "
2911 "VP[%d].\n", vha
->host_no
, vp_idx
));
2915 spin_lock_irqsave(&ha
->vport_slock
, flags
);
2916 list_for_each_entry(vp
, &ha
->vp_list
, list
)
2917 if (vp_idx
== vp
->vp_idx
)
2919 spin_unlock_irqrestore(&ha
->vport_slock
, flags
);
2924 vp
->d_id
.b
.domain
= rptid_entry
->port_id
[2];
2925 vp
->d_id
.b
.area
= rptid_entry
->port_id
[1];
2926 vp
->d_id
.b
.al_pa
= rptid_entry
->port_id
[0];
2929 * Cannot configure here as we are still sitting on the
2930 * response queue. Handle it in dpc context.
2932 set_bit(VP_IDX_ACQUIRED
, &vp
->vp_flags
);
2935 set_bit(REGISTER_FC4_NEEDED
, &vp
->dpc_flags
);
2936 set_bit(REGISTER_FDMI_NEEDED
, &vp
->dpc_flags
);
2937 set_bit(VP_DPC_NEEDED
, &vha
->dpc_flags
);
2938 qla2xxx_wake_dpc(vha
);
2943 * qla24xx_modify_vp_config
2944 * Change VP configuration for vha
2947 * vha = adapter block pointer.
2950 * qla2xxx local function return status code.
2956 qla24xx_modify_vp_config(scsi_qla_host_t
*vha
)
2959 struct vp_config_entry_24xx
*vpmod
;
2960 dma_addr_t vpmod_dma
;
2961 struct qla_hw_data
*ha
= vha
->hw
;
2962 struct scsi_qla_host
*base_vha
= pci_get_drvdata(ha
->pdev
);
2964 /* This can be called by the parent */
2966 vpmod
= dma_pool_alloc(ha
->s_dma_pool
, GFP_KERNEL
, &vpmod_dma
);
2968 DEBUG2_3(printk("%s(%ld): failed to allocate Modify VP "
2969 "IOCB.\n", __func__
, vha
->host_no
));
2970 return QLA_MEMORY_ALLOC_FAILED
;
2973 memset(vpmod
, 0, sizeof(struct vp_config_entry_24xx
));
2974 vpmod
->entry_type
= VP_CONFIG_IOCB_TYPE
;
2975 vpmod
->entry_count
= 1;
2976 vpmod
->command
= VCT_COMMAND_MOD_ENABLE_VPS
;
2977 vpmod
->vp_count
= 1;
2978 vpmod
->vp_index1
= vha
->vp_idx
;
2979 vpmod
->options_idx1
= BIT_3
|BIT_4
|BIT_5
;
2980 memcpy(vpmod
->node_name_idx1
, vha
->node_name
, WWN_SIZE
);
2981 memcpy(vpmod
->port_name_idx1
, vha
->port_name
, WWN_SIZE
);
2982 vpmod
->entry_count
= 1;
2984 rval
= qla2x00_issue_iocb(base_vha
, vpmod
, vpmod_dma
, 0);
2985 if (rval
!= QLA_SUCCESS
) {
2986 DEBUG2_3_11(printk("%s(%ld): failed to issue VP config IOCB"
2987 "(%x).\n", __func__
, base_vha
->host_no
, rval
));
2988 } else if (vpmod
->comp_status
!= 0) {
2989 DEBUG2_3_11(printk("%s(%ld): failed to complete IOCB "
2990 "-- error status (%x).\n", __func__
, base_vha
->host_no
,
2991 vpmod
->comp_status
));
2992 rval
= QLA_FUNCTION_FAILED
;
2993 } else if (vpmod
->comp_status
!= __constant_cpu_to_le16(CS_COMPLETE
)) {
2994 DEBUG2_3_11(printk("%s(%ld): failed to complete IOCB "
2995 "-- completion status (%x).\n", __func__
, base_vha
->host_no
,
2996 le16_to_cpu(vpmod
->comp_status
)));
2997 rval
= QLA_FUNCTION_FAILED
;
3000 DEBUG11(printk("%s(%ld): done.\n", __func__
,
3001 base_vha
->host_no
));
3002 fc_vport_set_state(vha
->fc_vport
, FC_VPORT_INITIALIZING
);
3004 dma_pool_free(ha
->s_dma_pool
, vpmod
, vpmod_dma
);
3010 * qla24xx_control_vp
3011 * Enable a virtual port for given host
3014 * ha = adapter block pointer.
3015 * vhba = virtual adapter (unused)
3016 * index = index number for enabled VP
3019 * qla2xxx local function return status code.
3025 qla24xx_control_vp(scsi_qla_host_t
*vha
, int cmd
)
3029 struct vp_ctrl_entry_24xx
*vce
;
3031 struct qla_hw_data
*ha
= vha
->hw
;
3032 int vp_index
= vha
->vp_idx
;
3033 struct scsi_qla_host
*base_vha
= pci_get_drvdata(ha
->pdev
);
3035 DEBUG11(printk("%s(%ld): entered. Enabling index %d\n", __func__
,
3036 vha
->host_no
, vp_index
));
3038 if (vp_index
== 0 || vp_index
>= ha
->max_npiv_vports
)
3039 return QLA_PARAMETER_ERROR
;
3041 vce
= dma_pool_alloc(ha
->s_dma_pool
, GFP_KERNEL
, &vce_dma
);
3043 DEBUG2_3(printk("%s(%ld): "
3044 "failed to allocate VP Control IOCB.\n", __func__
,
3045 base_vha
->host_no
));
3046 return QLA_MEMORY_ALLOC_FAILED
;
3048 memset(vce
, 0, sizeof(struct vp_ctrl_entry_24xx
));
3050 vce
->entry_type
= VP_CTRL_IOCB_TYPE
;
3051 vce
->entry_count
= 1;
3052 vce
->command
= cpu_to_le16(cmd
);
3053 vce
->vp_count
= __constant_cpu_to_le16(1);
3055 /* index map in firmware starts with 1; decrement index
3056 * this is ok as we never use index 0
3058 map
= (vp_index
- 1) / 8;
3059 pos
= (vp_index
- 1) & 7;
3060 mutex_lock(&ha
->vport_lock
);
3061 vce
->vp_idx_map
[map
] |= 1 << pos
;
3062 mutex_unlock(&ha
->vport_lock
);
3064 rval
= qla2x00_issue_iocb(base_vha
, vce
, vce_dma
, 0);
3065 if (rval
!= QLA_SUCCESS
) {
3066 DEBUG2_3_11(printk("%s(%ld): failed to issue VP control IOCB"
3067 "(%x).\n", __func__
, base_vha
->host_no
, rval
));
3068 printk("%s(%ld): failed to issue VP control IOCB"
3069 "(%x).\n", __func__
, base_vha
->host_no
, rval
);
3070 } else if (vce
->entry_status
!= 0) {
3071 DEBUG2_3_11(printk("%s(%ld): failed to complete IOCB "
3072 "-- error status (%x).\n", __func__
, base_vha
->host_no
,
3073 vce
->entry_status
));
3074 printk("%s(%ld): failed to complete IOCB "
3075 "-- error status (%x).\n", __func__
, base_vha
->host_no
,
3077 rval
= QLA_FUNCTION_FAILED
;
3078 } else if (vce
->comp_status
!= __constant_cpu_to_le16(CS_COMPLETE
)) {
3079 DEBUG2_3_11(printk("%s(%ld): failed to complete IOCB "
3080 "-- completion status (%x).\n", __func__
, base_vha
->host_no
,
3081 le16_to_cpu(vce
->comp_status
)));
3082 printk("%s(%ld): failed to complete IOCB "
3083 "-- completion status (%x).\n", __func__
, base_vha
->host_no
,
3084 le16_to_cpu(vce
->comp_status
));
3085 rval
= QLA_FUNCTION_FAILED
;
3087 DEBUG2(printk("%s(%ld): done.\n", __func__
, base_vha
->host_no
));
3090 dma_pool_free(ha
->s_dma_pool
, vce
, vce_dma
);
3096 * qla2x00_send_change_request
3097 * Receive or disable RSCN request from fabric controller
3100 * ha = adapter block pointer
3101 * format = registration format:
3103 * 1 - Fabric detected registration
3104 * 2 - N_port detected registration
3105 * 3 - Full registration
3106 * FF - clear registration
3107 * vp_idx = Virtual port index
3110 * qla2x00 local function return status code.
3117 qla2x00_send_change_request(scsi_qla_host_t
*vha
, uint16_t format
,
3122 mbx_cmd_t
*mcp
= &mc
;
3125 * This command is implicitly executed by firmware during login for the
3129 return QLA_FUNCTION_FAILED
;
3131 mcp
->mb
[0] = MBC_SEND_CHANGE_REQUEST
;
3132 mcp
->mb
[1] = format
;
3133 mcp
->mb
[9] = vp_idx
;
3134 mcp
->out_mb
= MBX_9
|MBX_1
|MBX_0
;
3135 mcp
->in_mb
= MBX_0
|MBX_1
;
3136 mcp
->tov
= MBX_TOV_SECONDS
;
3138 rval
= qla2x00_mailbox_command(vha
, mcp
);
3140 if (rval
== QLA_SUCCESS
) {
3141 if (mcp
->mb
[0] != MBS_COMMAND_COMPLETE
) {
3151 qla2x00_dump_ram(scsi_qla_host_t
*vha
, dma_addr_t req_dma
, uint32_t addr
,
3156 mbx_cmd_t
*mcp
= &mc
;
3158 DEBUG11(printk("%s(%ld): entered.\n", __func__
, vha
->host_no
));
3160 if (MSW(addr
) || IS_FWI2_CAPABLE(vha
->hw
)) {
3161 mcp
->mb
[0] = MBC_DUMP_RISC_RAM_EXTENDED
;
3162 mcp
->mb
[8] = MSW(addr
);
3163 mcp
->out_mb
= MBX_8
|MBX_0
;
3165 mcp
->mb
[0] = MBC_DUMP_RISC_RAM
;
3166 mcp
->out_mb
= MBX_0
;
3168 mcp
->mb
[1] = LSW(addr
);
3169 mcp
->mb
[2] = MSW(req_dma
);
3170 mcp
->mb
[3] = LSW(req_dma
);
3171 mcp
->mb
[6] = MSW(MSD(req_dma
));
3172 mcp
->mb
[7] = LSW(MSD(req_dma
));
3173 mcp
->out_mb
|= MBX_7
|MBX_6
|MBX_3
|MBX_2
|MBX_1
;
3174 if (IS_FWI2_CAPABLE(vha
->hw
)) {
3175 mcp
->mb
[4] = MSW(size
);
3176 mcp
->mb
[5] = LSW(size
);
3177 mcp
->out_mb
|= MBX_5
|MBX_4
;
3179 mcp
->mb
[4] = LSW(size
);
3180 mcp
->out_mb
|= MBX_4
;
3184 mcp
->tov
= MBX_TOV_SECONDS
;
3186 rval
= qla2x00_mailbox_command(vha
, mcp
);
3188 if (rval
!= QLA_SUCCESS
) {
3189 DEBUG2_3_11(printk("%s(%ld): failed=%x mb[0]=%x.\n", __func__
,
3190 vha
->host_no
, rval
, mcp
->mb
[0]));
3192 DEBUG11(printk("%s(%ld): done.\n", __func__
, vha
->host_no
));
3198 /* 84XX Support **************************************************************/
3200 struct cs84xx_mgmt_cmd
{
3202 struct verify_chip_entry_84xx req
;
3203 struct verify_chip_rsp_84xx rsp
;
3208 qla84xx_verify_chip(struct scsi_qla_host
*vha
, uint16_t *status
)
3211 struct cs84xx_mgmt_cmd
*mn
;
3214 unsigned long flags
;
3215 struct qla_hw_data
*ha
= vha
->hw
;
3217 DEBUG16(printk("%s(%ld): entered.\n", __func__
, vha
->host_no
));
3219 mn
= dma_pool_alloc(ha
->s_dma_pool
, GFP_KERNEL
, &mn_dma
);
3221 DEBUG2_3(printk("%s(%ld): failed to allocate Verify ISP84XX "
3222 "IOCB.\n", __func__
, vha
->host_no
));
3223 return QLA_MEMORY_ALLOC_FAILED
;
3227 options
= ha
->cs84xx
->fw_update
? VCO_FORCE_UPDATE
: 0;
3228 /* Diagnostic firmware? */
3229 /* options |= MENLO_DIAG_FW; */
3230 /* We update the firmware with only one data sequence. */
3231 options
|= VCO_END_OF_DATA
;
3235 memset(mn
, 0, sizeof(*mn
));
3236 mn
->p
.req
.entry_type
= VERIFY_CHIP_IOCB_TYPE
;
3237 mn
->p
.req
.entry_count
= 1;
3238 mn
->p
.req
.options
= cpu_to_le16(options
);
3240 DEBUG16(printk("%s(%ld): Dump of Verify Request.\n", __func__
,
3242 DEBUG16(qla2x00_dump_buffer((uint8_t *)mn
,
3245 rval
= qla2x00_issue_iocb_timeout(vha
, mn
, mn_dma
, 0, 120);
3246 if (rval
!= QLA_SUCCESS
) {
3247 DEBUG2_16(printk("%s(%ld): failed to issue Verify "
3248 "IOCB (%x).\n", __func__
, vha
->host_no
, rval
));
3252 DEBUG16(printk("%s(%ld): Dump of Verify Response.\n", __func__
,
3254 DEBUG16(qla2x00_dump_buffer((uint8_t *)mn
,
3257 status
[0] = le16_to_cpu(mn
->p
.rsp
.comp_status
);
3258 status
[1] = status
[0] == CS_VCS_CHIP_FAILURE
?
3259 le16_to_cpu(mn
->p
.rsp
.failure_code
) : 0;
3260 DEBUG2_16(printk("%s(%ld): cs=%x fc=%x\n", __func__
,
3261 vha
->host_no
, status
[0], status
[1]));
3263 if (status
[0] != CS_COMPLETE
) {
3264 rval
= QLA_FUNCTION_FAILED
;
3265 if (!(options
& VCO_DONT_UPDATE_FW
)) {
3266 DEBUG2_16(printk("%s(%ld): Firmware update "
3267 "failed. Retrying without update "
3268 "firmware.\n", __func__
, vha
->host_no
));
3269 options
|= VCO_DONT_UPDATE_FW
;
3270 options
&= ~VCO_FORCE_UPDATE
;
3274 DEBUG2_16(printk("%s(%ld): firmware updated to %x.\n",
3275 __func__
, vha
->host_no
,
3276 le32_to_cpu(mn
->p
.rsp
.fw_ver
)));
3278 /* NOTE: we only update OP firmware. */
3279 spin_lock_irqsave(&ha
->cs84xx
->access_lock
, flags
);
3280 ha
->cs84xx
->op_fw_version
=
3281 le32_to_cpu(mn
->p
.rsp
.fw_ver
);
3282 spin_unlock_irqrestore(&ha
->cs84xx
->access_lock
,
3288 dma_pool_free(ha
->s_dma_pool
, mn
, mn_dma
);
3290 if (rval
!= QLA_SUCCESS
) {
3291 DEBUG2_16(printk("%s(%ld): failed=%x.\n", __func__
,
3292 vha
->host_no
, rval
));
3294 DEBUG16(printk("%s(%ld): done.\n", __func__
, vha
->host_no
));
3301 qla25xx_init_req_que(struct scsi_qla_host
*vha
, struct req_que
*req
)
3304 unsigned long flags
;
3306 mbx_cmd_t
*mcp
= &mc
;
3307 struct device_reg_25xxmq __iomem
*reg
;
3308 struct qla_hw_data
*ha
= vha
->hw
;
3310 mcp
->mb
[0] = MBC_INITIALIZE_MULTIQ
;
3311 mcp
->mb
[1] = req
->options
;
3312 mcp
->mb
[2] = MSW(LSD(req
->dma
));
3313 mcp
->mb
[3] = LSW(LSD(req
->dma
));
3314 mcp
->mb
[6] = MSW(MSD(req
->dma
));
3315 mcp
->mb
[7] = LSW(MSD(req
->dma
));
3316 mcp
->mb
[5] = req
->length
;
3318 mcp
->mb
[10] = req
->rsp
->id
;
3319 mcp
->mb
[12] = req
->qos
;
3320 mcp
->mb
[11] = req
->vp_idx
;
3321 mcp
->mb
[13] = req
->rid
;
3323 reg
= (struct device_reg_25xxmq
*)((void *)(ha
->mqiobase
) +
3324 QLA_QUE_PAGE
* req
->id
);
3326 mcp
->mb
[4] = req
->id
;
3327 /* que in ptr index */
3329 /* que out ptr index */
3331 mcp
->out_mb
= MBX_14
|MBX_13
|MBX_12
|MBX_11
|MBX_10
|MBX_9
|MBX_8
|MBX_7
|
3332 MBX_6
|MBX_5
|MBX_4
|MBX_3
|MBX_2
|MBX_1
|MBX_0
;
3334 mcp
->flags
= MBX_DMA_OUT
;
3337 spin_lock_irqsave(&ha
->hardware_lock
, flags
);
3338 if (!(req
->options
& BIT_0
)) {
3339 WRT_REG_DWORD(®
->req_q_in
, 0);
3340 WRT_REG_DWORD(®
->req_q_out
, 0);
3342 req
->req_q_in
= ®
->req_q_in
;
3343 req
->req_q_out
= ®
->req_q_out
;
3344 spin_unlock_irqrestore(&ha
->hardware_lock
, flags
);
3346 rval
= qla2x00_mailbox_command(vha
, mcp
);
3347 if (rval
!= QLA_SUCCESS
)
3348 DEBUG2_3_11(printk(KERN_WARNING
"%s(%ld): failed=%x mb0=%x.\n",
3349 __func__
, vha
->host_no
, rval
, mcp
->mb
[0]));
3354 qla25xx_init_rsp_que(struct scsi_qla_host
*vha
, struct rsp_que
*rsp
)
3357 unsigned long flags
;
3359 mbx_cmd_t
*mcp
= &mc
;
3360 struct device_reg_25xxmq __iomem
*reg
;
3361 struct qla_hw_data
*ha
= vha
->hw
;
3363 mcp
->mb
[0] = MBC_INITIALIZE_MULTIQ
;
3364 mcp
->mb
[1] = rsp
->options
;
3365 mcp
->mb
[2] = MSW(LSD(rsp
->dma
));
3366 mcp
->mb
[3] = LSW(LSD(rsp
->dma
));
3367 mcp
->mb
[6] = MSW(MSD(rsp
->dma
));
3368 mcp
->mb
[7] = LSW(MSD(rsp
->dma
));
3369 mcp
->mb
[5] = rsp
->length
;
3370 mcp
->mb
[14] = rsp
->msix
->entry
;
3371 mcp
->mb
[13] = rsp
->rid
;
3373 reg
= (struct device_reg_25xxmq
*)((void *)(ha
->mqiobase
) +
3374 QLA_QUE_PAGE
* rsp
->id
);
3376 mcp
->mb
[4] = rsp
->id
;
3377 /* que in ptr index */
3379 /* que out ptr index */
3381 mcp
->out_mb
= MBX_14
|MBX_13
|MBX_9
|MBX_8
|MBX_7
3382 |MBX_6
|MBX_5
|MBX_4
|MBX_3
|MBX_2
|MBX_1
|MBX_0
;
3384 mcp
->flags
= MBX_DMA_OUT
;
3387 spin_lock_irqsave(&ha
->hardware_lock
, flags
);
3388 if (!(rsp
->options
& BIT_0
)) {
3389 WRT_REG_DWORD(®
->rsp_q_out
, 0);
3390 WRT_REG_DWORD(®
->rsp_q_in
, 0);
3393 spin_unlock_irqrestore(&ha
->hardware_lock
, flags
);
3395 rval
= qla2x00_mailbox_command(vha
, mcp
);
3396 if (rval
!= QLA_SUCCESS
)
3397 DEBUG2_3_11(printk(KERN_WARNING
"%s(%ld): failed=%x "
3398 "mb0=%x.\n", __func__
,
3399 vha
->host_no
, rval
, mcp
->mb
[0]));
3404 qla81xx_idc_ack(scsi_qla_host_t
*vha
, uint16_t *mb
)
3408 mbx_cmd_t
*mcp
= &mc
;
3410 DEBUG11(printk("%s(%ld): entered.\n", __func__
, vha
->host_no
));
3412 mcp
->mb
[0] = MBC_IDC_ACK
;
3413 memcpy(&mcp
->mb
[1], mb
, QLA_IDC_ACK_REGS
* sizeof(uint16_t));
3414 mcp
->out_mb
= MBX_7
|MBX_6
|MBX_5
|MBX_4
|MBX_3
|MBX_2
|MBX_1
|MBX_0
;
3416 mcp
->tov
= MBX_TOV_SECONDS
;
3418 rval
= qla2x00_mailbox_command(vha
, mcp
);
3420 if (rval
!= QLA_SUCCESS
) {
3421 DEBUG2_3_11(printk("%s(%ld): failed=%x (%x).\n", __func__
,
3422 vha
->host_no
, rval
, mcp
->mb
[0]));
3424 DEBUG11(printk("%s(%ld): done.\n", __func__
, vha
->host_no
));
3431 qla81xx_fac_get_sector_size(scsi_qla_host_t
*vha
, uint32_t *sector_size
)
3435 mbx_cmd_t
*mcp
= &mc
;
3437 if (!IS_QLA81XX(vha
->hw
))
3438 return QLA_FUNCTION_FAILED
;
3440 DEBUG11(printk("%s(%ld): entered.\n", __func__
, vha
->host_no
));
3442 mcp
->mb
[0] = MBC_FLASH_ACCESS_CTRL
;
3443 mcp
->mb
[1] = FAC_OPT_CMD_GET_SECTOR_SIZE
;
3444 mcp
->out_mb
= MBX_1
|MBX_0
;
3445 mcp
->in_mb
= MBX_1
|MBX_0
;
3446 mcp
->tov
= MBX_TOV_SECONDS
;
3448 rval
= qla2x00_mailbox_command(vha
, mcp
);
3450 if (rval
!= QLA_SUCCESS
) {
3451 DEBUG2_3_11(printk("%s(%ld): failed=%x mb[0]=%x mb[1]=%x.\n",
3452 __func__
, vha
->host_no
, rval
, mcp
->mb
[0], mcp
->mb
[1]));
3454 DEBUG11(printk("%s(%ld): done.\n", __func__
, vha
->host_no
));
3455 *sector_size
= mcp
->mb
[1];
3462 qla81xx_fac_do_write_enable(scsi_qla_host_t
*vha
, int enable
)
3466 mbx_cmd_t
*mcp
= &mc
;
3468 if (!IS_QLA81XX(vha
->hw
))
3469 return QLA_FUNCTION_FAILED
;
3471 DEBUG11(printk("%s(%ld): entered.\n", __func__
, vha
->host_no
));
3473 mcp
->mb
[0] = MBC_FLASH_ACCESS_CTRL
;
3474 mcp
->mb
[1] = enable
? FAC_OPT_CMD_WRITE_ENABLE
:
3475 FAC_OPT_CMD_WRITE_PROTECT
;
3476 mcp
->out_mb
= MBX_1
|MBX_0
;
3477 mcp
->in_mb
= MBX_1
|MBX_0
;
3478 mcp
->tov
= MBX_TOV_SECONDS
;
3480 rval
= qla2x00_mailbox_command(vha
, mcp
);
3482 if (rval
!= QLA_SUCCESS
) {
3483 DEBUG2_3_11(printk("%s(%ld): failed=%x mb[0]=%x mb[1]=%x.\n",
3484 __func__
, vha
->host_no
, rval
, mcp
->mb
[0], mcp
->mb
[1]));
3486 DEBUG11(printk("%s(%ld): done.\n", __func__
, vha
->host_no
));
3493 qla81xx_fac_erase_sector(scsi_qla_host_t
*vha
, uint32_t start
, uint32_t finish
)
3497 mbx_cmd_t
*mcp
= &mc
;
3499 if (!IS_QLA81XX(vha
->hw
))
3500 return QLA_FUNCTION_FAILED
;
3502 DEBUG11(printk("%s(%ld): entered.\n", __func__
, vha
->host_no
));
3504 mcp
->mb
[0] = MBC_FLASH_ACCESS_CTRL
;
3505 mcp
->mb
[1] = FAC_OPT_CMD_ERASE_SECTOR
;
3506 mcp
->mb
[2] = LSW(start
);
3507 mcp
->mb
[3] = MSW(start
);
3508 mcp
->mb
[4] = LSW(finish
);
3509 mcp
->mb
[5] = MSW(finish
);
3510 mcp
->out_mb
= MBX_5
|MBX_4
|MBX_3
|MBX_2
|MBX_1
|MBX_0
;
3511 mcp
->in_mb
= MBX_2
|MBX_1
|MBX_0
;
3512 mcp
->tov
= MBX_TOV_SECONDS
;
3514 rval
= qla2x00_mailbox_command(vha
, mcp
);
3516 if (rval
!= QLA_SUCCESS
) {
3517 DEBUG2_3_11(printk("%s(%ld): failed=%x mb[0]=%x mb[1]=%x "
3518 "mb[2]=%x.\n", __func__
, vha
->host_no
, rval
, mcp
->mb
[0],
3519 mcp
->mb
[1], mcp
->mb
[2]));
3521 DEBUG11(printk("%s(%ld): done.\n", __func__
, vha
->host_no
));
3528 qla81xx_restart_mpi_firmware(scsi_qla_host_t
*vha
)
3532 mbx_cmd_t
*mcp
= &mc
;
3534 DEBUG11(printk("%s(%ld): entered.\n", __func__
, vha
->host_no
));
3536 mcp
->mb
[0] = MBC_RESTART_MPI_FW
;
3537 mcp
->out_mb
= MBX_0
;
3538 mcp
->in_mb
= MBX_0
|MBX_1
;
3539 mcp
->tov
= MBX_TOV_SECONDS
;
3541 rval
= qla2x00_mailbox_command(vha
, mcp
);
3543 if (rval
!= QLA_SUCCESS
) {
3544 DEBUG2_3_11(printk("%s(%ld): failed=%x mb[0]=0x%x mb[1]=0x%x.\n",
3545 __func__
, vha
->host_no
, rval
, mcp
->mb
[0], mcp
->mb
[1]));
3547 DEBUG11(printk("%s(%ld): done.\n", __func__
, vha
->host_no
));
3554 qla2x00_read_sfp(scsi_qla_host_t
*vha
, dma_addr_t sfp_dma
, uint8_t *sfp
,
3555 uint16_t dev
, uint16_t off
, uint16_t len
, uint16_t opt
)
3559 mbx_cmd_t
*mcp
= &mc
;
3560 struct qla_hw_data
*ha
= vha
->hw
;
3562 if (!IS_FWI2_CAPABLE(ha
))
3563 return QLA_FUNCTION_FAILED
;
3565 DEBUG11(printk("%s(%ld): entered.\n", __func__
, vha
->host_no
));
3570 mcp
->mb
[0] = MBC_READ_SFP
;
3572 mcp
->mb
[2] = MSW(sfp_dma
);
3573 mcp
->mb
[3] = LSW(sfp_dma
);
3574 mcp
->mb
[6] = MSW(MSD(sfp_dma
));
3575 mcp
->mb
[7] = LSW(MSD(sfp_dma
));
3579 mcp
->out_mb
= MBX_10
|MBX_9
|MBX_8
|MBX_7
|MBX_6
|MBX_3
|MBX_2
|MBX_1
|MBX_0
;
3580 mcp
->in_mb
= MBX_1
|MBX_0
;
3581 mcp
->tov
= MBX_TOV_SECONDS
;
3583 rval
= qla2x00_mailbox_command(vha
, mcp
);
3588 if (rval
!= QLA_SUCCESS
) {
3589 DEBUG2_3_11(printk("%s(%ld): failed=%x (%x).\n", __func__
,
3590 vha
->host_no
, rval
, mcp
->mb
[0]));
3592 DEBUG11(printk("%s(%ld): done.\n", __func__
, vha
->host_no
));
3599 qla2x00_write_sfp(scsi_qla_host_t
*vha
, dma_addr_t sfp_dma
, uint8_t *sfp
,
3600 uint16_t dev
, uint16_t off
, uint16_t len
, uint16_t opt
)
3604 mbx_cmd_t
*mcp
= &mc
;
3605 struct qla_hw_data
*ha
= vha
->hw
;
3607 if (!IS_FWI2_CAPABLE(ha
))
3608 return QLA_FUNCTION_FAILED
;
3610 DEBUG11(printk("%s(%ld): entered.\n", __func__
, vha
->host_no
));
3618 mcp
->mb
[0] = MBC_WRITE_SFP
;
3620 mcp
->mb
[2] = MSW(sfp_dma
);
3621 mcp
->mb
[3] = LSW(sfp_dma
);
3622 mcp
->mb
[6] = MSW(MSD(sfp_dma
));
3623 mcp
->mb
[7] = LSW(MSD(sfp_dma
));
3627 mcp
->out_mb
= MBX_10
|MBX_9
|MBX_8
|MBX_7
|MBX_6
|MBX_3
|MBX_2
|MBX_1
|MBX_0
;
3628 mcp
->in_mb
= MBX_1
|MBX_0
;
3629 mcp
->tov
= MBX_TOV_SECONDS
;
3631 rval
= qla2x00_mailbox_command(vha
, mcp
);
3633 if (rval
!= QLA_SUCCESS
) {
3634 DEBUG2_3_11(printk("%s(%ld): failed=%x (%x).\n", __func__
,
3635 vha
->host_no
, rval
, mcp
->mb
[0]));
3637 DEBUG11(printk("%s(%ld): done.\n", __func__
, vha
->host_no
));
3644 qla2x00_get_xgmac_stats(scsi_qla_host_t
*vha
, dma_addr_t stats_dma
,
3645 uint16_t size_in_bytes
, uint16_t *actual_size
)
3649 mbx_cmd_t
*mcp
= &mc
;
3651 if (!IS_QLA8XXX_TYPE(vha
->hw
))
3652 return QLA_FUNCTION_FAILED
;
3654 DEBUG11(printk("%s(%ld): entered.\n", __func__
, vha
->host_no
));
3656 mcp
->mb
[0] = MBC_GET_XGMAC_STATS
;
3657 mcp
->mb
[2] = MSW(stats_dma
);
3658 mcp
->mb
[3] = LSW(stats_dma
);
3659 mcp
->mb
[6] = MSW(MSD(stats_dma
));
3660 mcp
->mb
[7] = LSW(MSD(stats_dma
));
3661 mcp
->mb
[8] = size_in_bytes
>> 2;
3662 mcp
->out_mb
= MBX_8
|MBX_7
|MBX_6
|MBX_3
|MBX_2
|MBX_0
;
3663 mcp
->in_mb
= MBX_2
|MBX_1
|MBX_0
;
3664 mcp
->tov
= MBX_TOV_SECONDS
;
3666 rval
= qla2x00_mailbox_command(vha
, mcp
);
3668 if (rval
!= QLA_SUCCESS
) {
3669 DEBUG2_3_11(printk("%s(%ld): failed=%x mb[0]=0x%x "
3670 "mb[1]=0x%x mb[2]=0x%x.\n", __func__
, vha
->host_no
, rval
,
3671 mcp
->mb
[0], mcp
->mb
[1], mcp
->mb
[2]));
3673 DEBUG11(printk("%s(%ld): done.\n", __func__
, vha
->host_no
));
3675 *actual_size
= mcp
->mb
[2] << 2;
3682 qla2x00_get_dcbx_params(scsi_qla_host_t
*vha
, dma_addr_t tlv_dma
,
3687 mbx_cmd_t
*mcp
= &mc
;
3689 if (!IS_QLA8XXX_TYPE(vha
->hw
))
3690 return QLA_FUNCTION_FAILED
;
3692 DEBUG11(printk("%s(%ld): entered.\n", __func__
, vha
->host_no
));
3694 mcp
->mb
[0] = MBC_GET_DCBX_PARAMS
;
3696 mcp
->mb
[2] = MSW(tlv_dma
);
3697 mcp
->mb
[3] = LSW(tlv_dma
);
3698 mcp
->mb
[6] = MSW(MSD(tlv_dma
));
3699 mcp
->mb
[7] = LSW(MSD(tlv_dma
));
3701 mcp
->out_mb
= MBX_8
|MBX_7
|MBX_6
|MBX_3
|MBX_2
|MBX_1
|MBX_0
;
3702 mcp
->in_mb
= MBX_2
|MBX_1
|MBX_0
;
3703 mcp
->tov
= MBX_TOV_SECONDS
;
3705 rval
= qla2x00_mailbox_command(vha
, mcp
);
3707 if (rval
!= QLA_SUCCESS
) {
3708 DEBUG2_3_11(printk("%s(%ld): failed=%x mb[0]=0x%x "
3709 "mb[1]=0x%x mb[2]=0x%x.\n", __func__
, vha
->host_no
, rval
,
3710 mcp
->mb
[0], mcp
->mb
[1], mcp
->mb
[2]));
3712 DEBUG11(printk("%s(%ld): done.\n", __func__
, vha
->host_no
));
3719 qla2x00_read_ram_word(scsi_qla_host_t
*vha
, uint32_t risc_addr
, uint32_t *data
)
3723 mbx_cmd_t
*mcp
= &mc
;
3725 if (!IS_FWI2_CAPABLE(vha
->hw
))
3726 return QLA_FUNCTION_FAILED
;
3728 DEBUG11(printk("%s(%ld): entered.\n", __func__
, vha
->host_no
));
3730 mcp
->mb
[0] = MBC_READ_RAM_EXTENDED
;
3731 mcp
->mb
[1] = LSW(risc_addr
);
3732 mcp
->mb
[8] = MSW(risc_addr
);
3733 mcp
->out_mb
= MBX_8
|MBX_1
|MBX_0
;
3734 mcp
->in_mb
= MBX_3
|MBX_2
|MBX_0
;
3737 rval
= qla2x00_mailbox_command(vha
, mcp
);
3738 if (rval
!= QLA_SUCCESS
) {
3739 DEBUG2_3_11(printk("%s(%ld): failed=%x mb[0]=%x.\n", __func__
,
3740 vha
->host_no
, rval
, mcp
->mb
[0]));
3742 DEBUG11(printk("%s(%ld): done.\n", __func__
, vha
->host_no
));
3743 *data
= mcp
->mb
[3] << 16 | mcp
->mb
[2];
3750 qla2x00_loopback_test(scsi_qla_host_t
*vha
, struct msg_echo_lb
*mreq
,
3755 mbx_cmd_t
*mcp
= &mc
;
3756 uint32_t iter_cnt
= 0x1;
3758 DEBUG11(printk("scsi(%ld): entered.\n", vha
->host_no
));
3760 memset(mcp
->mb
, 0 , sizeof(mcp
->mb
));
3761 mcp
->mb
[0] = MBC_DIAGNOSTIC_LOOP_BACK
;
3762 mcp
->mb
[1] = mreq
->options
| BIT_6
; // BIT_6 specifies 64 bit addressing
3764 /* transfer count */
3765 mcp
->mb
[10] = LSW(mreq
->transfer_size
);
3766 mcp
->mb
[11] = MSW(mreq
->transfer_size
);
3768 /* send data address */
3769 mcp
->mb
[14] = LSW(mreq
->send_dma
);
3770 mcp
->mb
[15] = MSW(mreq
->send_dma
);
3771 mcp
->mb
[20] = LSW(MSD(mreq
->send_dma
));
3772 mcp
->mb
[21] = MSW(MSD(mreq
->send_dma
));
3774 /* receive data address */
3775 mcp
->mb
[16] = LSW(mreq
->rcv_dma
);
3776 mcp
->mb
[17] = MSW(mreq
->rcv_dma
);
3777 mcp
->mb
[6] = LSW(MSD(mreq
->rcv_dma
));
3778 mcp
->mb
[7] = MSW(MSD(mreq
->rcv_dma
));
3780 /* Iteration count */
3781 mcp
->mb
[18] = LSW(iter_cnt
);
3782 mcp
->mb
[19] = MSW(iter_cnt
);
3784 mcp
->out_mb
= MBX_21
|MBX_20
|MBX_19
|MBX_18
|MBX_17
|MBX_16
|MBX_15
|
3785 MBX_14
|MBX_13
|MBX_12
|MBX_11
|MBX_10
|MBX_7
|MBX_6
|MBX_1
|MBX_0
;
3786 if (IS_QLA8XXX_TYPE(vha
->hw
))
3787 mcp
->out_mb
|= MBX_2
;
3788 mcp
->in_mb
= MBX_19
|MBX_18
|MBX_3
|MBX_2
|MBX_1
|MBX_0
;
3790 mcp
->buf_size
= mreq
->transfer_size
;
3791 mcp
->tov
= MBX_TOV_SECONDS
;
3792 mcp
->flags
= MBX_DMA_OUT
|MBX_DMA_IN
|IOCTL_CMD
;
3794 rval
= qla2x00_mailbox_command(vha
, mcp
);
3796 if (rval
!= QLA_SUCCESS
) {
3797 DEBUG2(printk(KERN_WARNING
3798 "(%ld): failed=%x mb[0]=0x%x "
3799 "mb[1]=0x%x mb[2]=0x%x mb[3]=0x%x mb[18]=0x%x "
3801 vha
->host_no
, rval
, mcp
->mb
[0], mcp
->mb
[1], mcp
->mb
[2],
3802 mcp
->mb
[3], mcp
->mb
[18], mcp
->mb
[19]));
3804 DEBUG2(printk(KERN_WARNING
3805 "scsi(%ld): done.\n", vha
->host_no
));
3808 /* Copy mailbox information */
3809 memcpy( mresp
, mcp
->mb
, 64);
3814 qla2x00_echo_test(scsi_qla_host_t
*vha
, struct msg_echo_lb
*mreq
,
3819 mbx_cmd_t
*mcp
= &mc
;
3820 struct qla_hw_data
*ha
= vha
->hw
;
3822 DEBUG11(printk("scsi(%ld): entered.\n", vha
->host_no
));
3824 memset(mcp
->mb
, 0 , sizeof(mcp
->mb
));
3825 mcp
->mb
[0] = MBC_DIAGNOSTIC_ECHO
;
3826 mcp
->mb
[1] = mreq
->options
| BIT_6
; /* BIT_6 specifies 64bit address */
3827 if (IS_QLA8XXX_TYPE(ha
)) {
3828 mcp
->mb
[1] |= BIT_15
;
3829 mcp
->mb
[2] = vha
->fcoe_fcf_idx
;
3831 mcp
->mb
[16] = LSW(mreq
->rcv_dma
);
3832 mcp
->mb
[17] = MSW(mreq
->rcv_dma
);
3833 mcp
->mb
[6] = LSW(MSD(mreq
->rcv_dma
));
3834 mcp
->mb
[7] = MSW(MSD(mreq
->rcv_dma
));
3836 mcp
->mb
[10] = LSW(mreq
->transfer_size
);
3838 mcp
->mb
[14] = LSW(mreq
->send_dma
);
3839 mcp
->mb
[15] = MSW(mreq
->send_dma
);
3840 mcp
->mb
[20] = LSW(MSD(mreq
->send_dma
));
3841 mcp
->mb
[21] = MSW(MSD(mreq
->send_dma
));
3843 mcp
->out_mb
= MBX_21
|MBX_20
|MBX_17
|MBX_16
|MBX_15
|
3844 MBX_14
|MBX_10
|MBX_7
|MBX_6
|MBX_1
|MBX_0
;
3845 if (IS_QLA8XXX_TYPE(ha
))
3846 mcp
->out_mb
|= MBX_2
;
3849 if (IS_QLA24XX_TYPE(ha
) || IS_QLA25XX(ha
) || IS_QLA8XXX_TYPE(ha
))
3850 mcp
->in_mb
|= MBX_1
;
3851 if (IS_QLA8XXX_TYPE(ha
))
3852 mcp
->in_mb
|= MBX_3
;
3854 mcp
->tov
= MBX_TOV_SECONDS
;
3855 mcp
->flags
= MBX_DMA_OUT
|MBX_DMA_IN
|IOCTL_CMD
;
3856 mcp
->buf_size
= mreq
->transfer_size
;
3858 rval
= qla2x00_mailbox_command(vha
, mcp
);
3860 if (rval
!= QLA_SUCCESS
) {
3861 DEBUG2(printk(KERN_WARNING
3862 "(%ld): failed=%x mb[0]=0x%x mb[1]=0x%x.\n",
3863 vha
->host_no
, rval
, mcp
->mb
[0], mcp
->mb
[1]));
3865 DEBUG2(printk(KERN_WARNING
3866 "scsi(%ld): done.\n", vha
->host_no
));
3869 /* Copy mailbox information */
3870 memcpy(mresp
, mcp
->mb
, 64);
3875 qla84xx_reset_chip(scsi_qla_host_t
*ha
, uint16_t enable_diagnostic
)
3879 mbx_cmd_t
*mcp
= &mc
;
3881 DEBUG16(printk("%s(%ld): enable_diag=%d entered.\n", __func__
,
3882 ha
->host_no
, enable_diagnostic
));
3884 mcp
->mb
[0] = MBC_ISP84XX_RESET
;
3885 mcp
->mb
[1] = enable_diagnostic
;
3886 mcp
->out_mb
= MBX_1
|MBX_0
;
3887 mcp
->in_mb
= MBX_1
|MBX_0
;
3888 mcp
->tov
= MBX_TOV_SECONDS
;
3889 mcp
->flags
= MBX_DMA_OUT
|MBX_DMA_IN
|IOCTL_CMD
;
3890 rval
= qla2x00_mailbox_command(ha
, mcp
);
3892 if (rval
!= QLA_SUCCESS
)
3893 DEBUG16(printk("%s(%ld): failed=%x.\n", __func__
, ha
->host_no
,
3896 DEBUG16(printk("%s(%ld): done.\n", __func__
, ha
->host_no
));
3902 qla2x00_write_ram_word(scsi_qla_host_t
*vha
, uint32_t risc_addr
, uint32_t data
)
3906 mbx_cmd_t
*mcp
= &mc
;
3908 if (!IS_FWI2_CAPABLE(vha
->hw
))
3909 return QLA_FUNCTION_FAILED
;
3911 DEBUG11(printk("%s(%ld): entered.\n", __func__
, vha
->host_no
));
3913 mcp
->mb
[0] = MBC_WRITE_RAM_WORD_EXTENDED
;
3914 mcp
->mb
[1] = LSW(risc_addr
);
3915 mcp
->mb
[2] = LSW(data
);
3916 mcp
->mb
[3] = MSW(data
);
3917 mcp
->mb
[8] = MSW(risc_addr
);
3918 mcp
->out_mb
= MBX_8
|MBX_3
|MBX_2
|MBX_1
|MBX_0
;
3922 rval
= qla2x00_mailbox_command(vha
, mcp
);
3923 if (rval
!= QLA_SUCCESS
) {
3924 DEBUG2_3_11(printk("%s(%ld): failed=%x mb[0]=%x.\n", __func__
,
3925 vha
->host_no
, rval
, mcp
->mb
[0]));
3927 DEBUG11(printk("%s(%ld): done.\n", __func__
, vha
->host_no
));
3934 qla81xx_write_mpi_register(scsi_qla_host_t
*vha
, uint16_t *mb
)
3937 uint32_t stat
, timer
;
3939 struct qla_hw_data
*ha
= vha
->hw
;
3940 struct device_reg_24xx __iomem
*reg
= &ha
->iobase
->isp24
;
3944 DEBUG11(qla_printk(KERN_INFO
, ha
,
3945 "%s(%ld): entered.\n", __func__
, vha
->host_no
));
3947 clear_bit(MBX_INTERRUPT
, &ha
->mbx_cmd_flags
);
3949 /* Write the MBC data to the registers */
3950 WRT_REG_WORD(®
->mailbox0
, MBC_WRITE_MPI_REGISTER
);
3951 WRT_REG_WORD(®
->mailbox1
, mb
[0]);
3952 WRT_REG_WORD(®
->mailbox2
, mb
[1]);
3953 WRT_REG_WORD(®
->mailbox3
, mb
[2]);
3954 WRT_REG_WORD(®
->mailbox4
, mb
[3]);
3956 WRT_REG_DWORD(®
->hccr
, HCCRX_SET_HOST_INT
);
3958 /* Poll for MBC interrupt */
3959 for (timer
= 6000000; timer
; timer
--) {
3960 /* Check for pending interrupts. */
3961 stat
= RD_REG_DWORD(®
->host_status
);
3962 if (stat
& HSRX_RISC_INT
) {
3965 if (stat
== 0x1 || stat
== 0x2 ||
3966 stat
== 0x10 || stat
== 0x11) {
3967 set_bit(MBX_INTERRUPT
,
3968 &ha
->mbx_cmd_flags
);
3969 mb0
= RD_REG_WORD(®
->mailbox0
);
3970 WRT_REG_DWORD(®
->hccr
,
3971 HCCRX_CLR_RISC_INT
);
3972 RD_REG_DWORD(®
->hccr
);
3979 if (test_and_clear_bit(MBX_INTERRUPT
, &ha
->mbx_cmd_flags
))
3980 rval
= mb0
& MBS_MASK
;
3982 rval
= QLA_FUNCTION_FAILED
;
3984 if (rval
!= QLA_SUCCESS
) {
3985 DEBUG2_3_11(printk(KERN_INFO
"%s(%ld): failed=%x mb[0]=%x.\n",
3986 __func__
, vha
->host_no
, rval
, mb
[0]));
3988 DEBUG11(printk(KERN_INFO
3989 "%s(%ld): done.\n", __func__
, vha
->host_no
));
3995 qla2x00_get_data_rate(scsi_qla_host_t
*vha
)
3999 mbx_cmd_t
*mcp
= &mc
;
4000 struct qla_hw_data
*ha
= vha
->hw
;
4002 if (!IS_FWI2_CAPABLE(ha
))
4003 return QLA_FUNCTION_FAILED
;
4005 DEBUG11(qla_printk(KERN_INFO
, ha
,
4006 "%s(%ld): entered.\n", __func__
, vha
->host_no
));
4008 mcp
->mb
[0] = MBC_DATA_RATE
;
4010 mcp
->out_mb
= MBX_1
|MBX_0
;
4011 mcp
->in_mb
= MBX_2
|MBX_1
|MBX_0
;
4012 mcp
->tov
= MBX_TOV_SECONDS
;
4014 rval
= qla2x00_mailbox_command(vha
, mcp
);
4015 if (rval
!= QLA_SUCCESS
) {
4016 DEBUG2_3_11(printk(KERN_INFO
"%s(%ld): failed=%x mb[0]=%x.\n",
4017 __func__
, vha
->host_no
, rval
, mcp
->mb
[0]));
4019 DEBUG11(printk(KERN_INFO
4020 "%s(%ld): done.\n", __func__
, vha
->host_no
));
4021 if (mcp
->mb
[1] != 0x7)
4022 ha
->link_data_rate
= mcp
->mb
[1];
4029 qla81xx_get_port_config(scsi_qla_host_t
*vha
, uint16_t *mb
)
4033 mbx_cmd_t
*mcp
= &mc
;
4034 struct qla_hw_data
*ha
= vha
->hw
;
4036 DEBUG11(printk(KERN_INFO
4037 "%s(%ld): entered.\n", __func__
, vha
->host_no
));
4039 if (!IS_QLA81XX(ha
))
4040 return QLA_FUNCTION_FAILED
;
4041 mcp
->mb
[0] = MBC_GET_PORT_CONFIG
;
4042 mcp
->out_mb
= MBX_0
;
4043 mcp
->in_mb
= MBX_4
|MBX_3
|MBX_2
|MBX_1
|MBX_0
;
4044 mcp
->tov
= MBX_TOV_SECONDS
;
4047 rval
= qla2x00_mailbox_command(vha
, mcp
);
4049 if (rval
!= QLA_SUCCESS
) {
4050 DEBUG2_3_11(printk(KERN_WARNING
4051 "%s(%ld): failed=%x (%x).\n", __func__
,
4052 vha
->host_no
, rval
, mcp
->mb
[0]));
4054 /* Copy all bits to preserve original value */
4055 memcpy(mb
, &mcp
->mb
[1], sizeof(uint16_t) * 4);
4057 DEBUG11(printk(KERN_INFO
4058 "%s(%ld): done.\n", __func__
, vha
->host_no
));
4064 qla81xx_set_port_config(scsi_qla_host_t
*vha
, uint16_t *mb
)
4068 mbx_cmd_t
*mcp
= &mc
;
4070 DEBUG11(printk(KERN_INFO
4071 "%s(%ld): entered.\n", __func__
, vha
->host_no
));
4073 mcp
->mb
[0] = MBC_SET_PORT_CONFIG
;
4074 /* Copy all bits to preserve original setting */
4075 memcpy(&mcp
->mb
[1], mb
, sizeof(uint16_t) * 4);
4076 mcp
->out_mb
= MBX_4
|MBX_3
|MBX_2
|MBX_1
|MBX_0
;
4078 mcp
->tov
= MBX_TOV_SECONDS
;
4080 rval
= qla2x00_mailbox_command(vha
, mcp
);
4082 if (rval
!= QLA_SUCCESS
) {
4083 DEBUG2_3_11(printk(KERN_WARNING
4084 "%s(%ld): failed=%x (%x).\n", __func__
,
4085 vha
->host_no
, rval
, mcp
->mb
[0]));
4087 DEBUG11(printk(KERN_INFO
4088 "%s(%ld): done.\n", __func__
, vha
->host_no
));
4095 qla24xx_set_fcp_prio(scsi_qla_host_t
*vha
, uint16_t loop_id
, uint16_t priority
,
4100 mbx_cmd_t
*mcp
= &mc
;
4101 struct qla_hw_data
*ha
= vha
->hw
;
4103 if (!IS_QLA24XX_TYPE(ha
) && !IS_QLA25XX(ha
))
4104 return QLA_FUNCTION_FAILED
;
4106 DEBUG11(printk(KERN_INFO
4107 "%s(%ld): entered.\n", __func__
, vha
->host_no
));
4109 mcp
->mb
[0] = MBC_PORT_PARAMS
;
4110 mcp
->mb
[1] = loop_id
;
4111 if (ha
->flags
.fcp_prio_enabled
)
4115 mcp
->mb
[4] = priority
& 0xf;
4116 mcp
->mb
[9] = vha
->vp_idx
;
4117 mcp
->out_mb
= MBX_9
|MBX_4
|MBX_3
|MBX_2
|MBX_1
|MBX_0
;
4118 mcp
->in_mb
= MBX_4
|MBX_3
|MBX_1
|MBX_0
;
4121 rval
= qla2x00_mailbox_command(vha
, mcp
);
4129 if (rval
!= QLA_SUCCESS
) {
4130 DEBUG2_3_11(printk(KERN_WARNING
4131 "%s(%ld): failed=%x.\n", __func__
,
4132 vha
->host_no
, rval
));
4134 DEBUG11(printk(KERN_INFO
4135 "%s(%ld): done.\n", __func__
, vha
->host_no
));
4142 qla2x00_get_thermal_temp(scsi_qla_host_t
*vha
, uint16_t *temp
, uint16_t *frac
)
4146 struct qla_hw_data
*ha
= vha
->hw
;
4148 DEBUG11(printk(KERN_INFO
"%s(%ld): entered.\n", __func__
, vha
->host_no
));
4151 rval
= qla2x00_read_sfp(vha
, 0, &byte
, 0x98, 0x01, 1, BIT_13
|BIT_0
);
4152 if (rval
!= QLA_SUCCESS
) {
4153 DEBUG2_3_11(printk(KERN_WARNING
4154 "%s(%ld): failed=%x.\n", __func__
, vha
->host_no
, rval
));
4155 ha
->flags
.thermal_supported
= 0;
4161 rval
= qla2x00_read_sfp(vha
, 0, &byte
, 0x98, 0x10, 1, BIT_13
|BIT_0
);
4162 if (rval
!= QLA_SUCCESS
) {
4163 DEBUG2_3_11(printk(KERN_WARNING
4164 "%s(%ld): failed=%x.\n", __func__
, vha
->host_no
, rval
));
4165 ha
->flags
.thermal_supported
= 0;
4168 *frac
= (byte
>> 6) * 25;
4170 DEBUG11(printk(KERN_INFO
"%s(%ld): done.\n", __func__
, vha
->host_no
));
4176 qla82xx_mbx_intr_enable(scsi_qla_host_t
*vha
)
4179 struct qla_hw_data
*ha
= vha
->hw
;
4181 mbx_cmd_t
*mcp
= &mc
;
4183 if (!IS_FWI2_CAPABLE(ha
))
4184 return QLA_FUNCTION_FAILED
;
4186 DEBUG11(qla_printk(KERN_INFO
, ha
,
4187 "%s(%ld): entered.\n", __func__
, vha
->host_no
));
4189 memset(mcp
, 0, sizeof(mbx_cmd_t
));
4190 mcp
->mb
[0] = MBC_TOGGLE_INTERRUPT
;
4193 mcp
->out_mb
= MBX_1
|MBX_0
;
4198 rval
= qla2x00_mailbox_command(vha
, mcp
);
4199 if (rval
!= QLA_SUCCESS
) {
4200 DEBUG2_3_11(qla_printk(KERN_WARNING
, ha
,
4201 "%s(%ld): failed=%x mb[0]=%x.\n", __func__
,
4202 vha
->host_no
, rval
, mcp
->mb
[0]));
4204 DEBUG11(qla_printk(KERN_INFO
, ha
,
4205 "%s(%ld): done.\n", __func__
, vha
->host_no
));
4212 qla82xx_mbx_intr_disable(scsi_qla_host_t
*vha
)
4215 struct qla_hw_data
*ha
= vha
->hw
;
4217 mbx_cmd_t
*mcp
= &mc
;
4219 if (!IS_QLA82XX(ha
))
4220 return QLA_FUNCTION_FAILED
;
4222 DEBUG11(qla_printk(KERN_INFO
, ha
,
4223 "%s(%ld): entered.\n", __func__
, vha
->host_no
));
4225 memset(mcp
, 0, sizeof(mbx_cmd_t
));
4226 mcp
->mb
[0] = MBC_TOGGLE_INTERRUPT
;
4229 mcp
->out_mb
= MBX_1
|MBX_0
;
4234 rval
= qla2x00_mailbox_command(vha
, mcp
);
4235 if (rval
!= QLA_SUCCESS
) {
4236 DEBUG2_3_11(qla_printk(KERN_WARNING
, ha
,
4237 "%s(%ld): failed=%x mb[0]=%x.\n", __func__
,
4238 vha
->host_no
, rval
, mcp
->mb
[0]));
4240 DEBUG11(qla_printk(KERN_INFO
, ha
,
4241 "%s(%ld): done.\n", __func__
, vha
->host_no
));