2 * QLogic Fibre Channel HBA Driver
3 * Copyright (c) 2003-2010 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(printk("%s(%ld): Unable to verify "
1265 "login-state (%x/%x) for loop_id %x\n",
1266 __func__
, vha
->host_no
,
1267 pd24
->current_login_state
,
1268 pd24
->last_login_state
, fcport
->loop_id
));
1269 rval
= QLA_FUNCTION_FAILED
;
1273 /* Names are little-endian. */
1274 memcpy(fcport
->node_name
, pd24
->node_name
, WWN_SIZE
);
1275 memcpy(fcport
->port_name
, pd24
->port_name
, WWN_SIZE
);
1277 /* Get port_id of device. */
1278 fcport
->d_id
.b
.domain
= pd24
->port_id
[0];
1279 fcport
->d_id
.b
.area
= pd24
->port_id
[1];
1280 fcport
->d_id
.b
.al_pa
= pd24
->port_id
[2];
1281 fcport
->d_id
.b
.rsvd_1
= 0;
1283 /* If not target must be initiator or unknown type. */
1284 if ((pd24
->prli_svc_param_word_3
[0] & BIT_4
) == 0)
1285 fcport
->port_type
= FCT_INITIATOR
;
1287 fcport
->port_type
= FCT_TARGET
;
1289 /* Check for logged in state. */
1290 if (pd
->master_state
!= PD_STATE_PORT_LOGGED_IN
&&
1291 pd
->slave_state
!= PD_STATE_PORT_LOGGED_IN
) {
1292 rval
= QLA_FUNCTION_FAILED
;
1296 /* Names are little-endian. */
1297 memcpy(fcport
->node_name
, pd
->node_name
, WWN_SIZE
);
1298 memcpy(fcport
->port_name
, pd
->port_name
, WWN_SIZE
);
1300 /* Get port_id of device. */
1301 fcport
->d_id
.b
.domain
= pd
->port_id
[0];
1302 fcport
->d_id
.b
.area
= pd
->port_id
[3];
1303 fcport
->d_id
.b
.al_pa
= pd
->port_id
[2];
1304 fcport
->d_id
.b
.rsvd_1
= 0;
1306 /* If not target must be initiator or unknown type. */
1307 if ((pd
->prli_svc_param_word_3
[0] & BIT_4
) == 0)
1308 fcport
->port_type
= FCT_INITIATOR
;
1310 fcport
->port_type
= FCT_TARGET
;
1312 /* Passback COS information. */
1313 fcport
->supported_classes
= (pd
->options
& BIT_4
) ?
1314 FC_COS_CLASS2
: FC_COS_CLASS3
;
1318 dma_pool_free(ha
->s_dma_pool
, pd
, pd_dma
);
1320 if (rval
!= QLA_SUCCESS
) {
1321 DEBUG2_3_11(printk("%s(%ld): failed=%x mb[0]=%x mb[1]=%x.\n",
1322 __func__
, vha
->host_no
, rval
, mcp
->mb
[0], mcp
->mb
[1]));
1324 DEBUG11(printk("%s(%ld): done.\n", __func__
, vha
->host_no
));
1331 * qla2x00_get_firmware_state
1332 * Get adapter firmware state.
1335 * ha = adapter block pointer.
1336 * dptr = pointer for firmware state.
1337 * TARGET_QUEUE_LOCK must be released.
1338 * ADAPTER_STATE_LOCK must be released.
1341 * qla2x00 local function return status code.
1347 qla2x00_get_firmware_state(scsi_qla_host_t
*vha
, uint16_t *states
)
1351 mbx_cmd_t
*mcp
= &mc
;
1353 DEBUG11(printk("qla2x00_get_firmware_state(%ld): entered.\n",
1356 mcp
->mb
[0] = MBC_GET_FIRMWARE_STATE
;
1357 mcp
->out_mb
= MBX_0
;
1358 if (IS_FWI2_CAPABLE(vha
->hw
))
1359 mcp
->in_mb
= MBX_5
|MBX_4
|MBX_3
|MBX_2
|MBX_1
|MBX_0
;
1361 mcp
->in_mb
= MBX_1
|MBX_0
;
1362 mcp
->tov
= MBX_TOV_SECONDS
;
1364 rval
= qla2x00_mailbox_command(vha
, mcp
);
1366 /* Return firmware states. */
1367 states
[0] = mcp
->mb
[1];
1368 if (IS_FWI2_CAPABLE(vha
->hw
)) {
1369 states
[1] = mcp
->mb
[2];
1370 states
[2] = mcp
->mb
[3];
1371 states
[3] = mcp
->mb
[4];
1372 states
[4] = mcp
->mb
[5];
1375 if (rval
!= QLA_SUCCESS
) {
1377 DEBUG2_3_11(printk("qla2x00_get_firmware_state(%ld): "
1378 "failed=%x.\n", vha
->host_no
, rval
));
1381 DEBUG11(printk("qla2x00_get_firmware_state(%ld): done.\n",
1389 * qla2x00_get_port_name
1390 * Issue get port name mailbox command.
1391 * Returned name is in big endian format.
1394 * ha = adapter block pointer.
1395 * loop_id = loop ID of device.
1396 * name = pointer for name.
1397 * TARGET_QUEUE_LOCK must be released.
1398 * ADAPTER_STATE_LOCK must be released.
1401 * qla2x00 local function return status code.
1407 qla2x00_get_port_name(scsi_qla_host_t
*vha
, uint16_t loop_id
, uint8_t *name
,
1412 mbx_cmd_t
*mcp
= &mc
;
1414 DEBUG11(printk("qla2x00_get_port_name(%ld): entered.\n",
1417 mcp
->mb
[0] = MBC_GET_PORT_NAME
;
1418 mcp
->mb
[9] = vha
->vp_idx
;
1419 mcp
->out_mb
= MBX_9
|MBX_1
|MBX_0
;
1420 if (HAS_EXTENDED_IDS(vha
->hw
)) {
1421 mcp
->mb
[1] = loop_id
;
1423 mcp
->out_mb
|= MBX_10
;
1425 mcp
->mb
[1] = loop_id
<< 8 | opt
;
1428 mcp
->in_mb
= MBX_7
|MBX_6
|MBX_3
|MBX_2
|MBX_1
|MBX_0
;
1429 mcp
->tov
= MBX_TOV_SECONDS
;
1431 rval
= qla2x00_mailbox_command(vha
, mcp
);
1433 if (rval
!= QLA_SUCCESS
) {
1435 DEBUG2_3_11(printk("qla2x00_get_port_name(%ld): failed=%x.\n",
1436 vha
->host_no
, rval
));
1439 /* This function returns name in big endian. */
1440 name
[0] = MSB(mcp
->mb
[2]);
1441 name
[1] = LSB(mcp
->mb
[2]);
1442 name
[2] = MSB(mcp
->mb
[3]);
1443 name
[3] = LSB(mcp
->mb
[3]);
1444 name
[4] = MSB(mcp
->mb
[6]);
1445 name
[5] = LSB(mcp
->mb
[6]);
1446 name
[6] = MSB(mcp
->mb
[7]);
1447 name
[7] = LSB(mcp
->mb
[7]);
1450 DEBUG11(printk("qla2x00_get_port_name(%ld): done.\n",
1459 * Issue LIP reset mailbox command.
1462 * ha = adapter block pointer.
1463 * TARGET_QUEUE_LOCK must be released.
1464 * ADAPTER_STATE_LOCK must be released.
1467 * qla2x00 local function return status code.
1473 qla2x00_lip_reset(scsi_qla_host_t
*vha
)
1477 mbx_cmd_t
*mcp
= &mc
;
1479 DEBUG11(printk("%s(%ld): entered.\n", __func__
, vha
->host_no
));
1481 if (IS_QLA8XXX_TYPE(vha
->hw
)) {
1482 /* Logout across all FCFs. */
1483 mcp
->mb
[0] = MBC_LIP_FULL_LOGIN
;
1486 mcp
->out_mb
= MBX_2
|MBX_1
|MBX_0
;
1487 } else if (IS_FWI2_CAPABLE(vha
->hw
)) {
1488 mcp
->mb
[0] = MBC_LIP_FULL_LOGIN
;
1491 mcp
->mb
[3] = vha
->hw
->loop_reset_delay
;
1492 mcp
->out_mb
= MBX_3
|MBX_2
|MBX_1
|MBX_0
;
1494 mcp
->mb
[0] = MBC_LIP_RESET
;
1495 mcp
->out_mb
= MBX_3
|MBX_2
|MBX_1
|MBX_0
;
1496 if (HAS_EXTENDED_IDS(vha
->hw
)) {
1497 mcp
->mb
[1] = 0x00ff;
1499 mcp
->out_mb
|= MBX_10
;
1501 mcp
->mb
[1] = 0xff00;
1503 mcp
->mb
[2] = vha
->hw
->loop_reset_delay
;
1507 mcp
->tov
= MBX_TOV_SECONDS
;
1509 rval
= qla2x00_mailbox_command(vha
, mcp
);
1511 if (rval
!= QLA_SUCCESS
) {
1513 DEBUG2_3_11(printk("%s(%ld): failed=%x.\n",
1514 __func__
, vha
->host_no
, rval
));
1517 DEBUG11(printk("%s(%ld): done.\n", __func__
, vha
->host_no
));
1528 * ha = adapter block pointer.
1529 * sns = pointer for command.
1530 * cmd_size = command size.
1531 * buf_size = response/command size.
1532 * TARGET_QUEUE_LOCK must be released.
1533 * ADAPTER_STATE_LOCK must be released.
1536 * qla2x00 local function return status code.
1542 qla2x00_send_sns(scsi_qla_host_t
*vha
, dma_addr_t sns_phys_address
,
1543 uint16_t cmd_size
, size_t buf_size
)
1547 mbx_cmd_t
*mcp
= &mc
;
1549 DEBUG11(printk("qla2x00_send_sns(%ld): entered.\n",
1552 DEBUG11(printk("qla2x00_send_sns: retry cnt=%d ratov=%d total "
1553 "tov=%d.\n", vha
->hw
->retry_count
, vha
->hw
->login_timeout
,
1556 mcp
->mb
[0] = MBC_SEND_SNS_COMMAND
;
1557 mcp
->mb
[1] = cmd_size
;
1558 mcp
->mb
[2] = MSW(sns_phys_address
);
1559 mcp
->mb
[3] = LSW(sns_phys_address
);
1560 mcp
->mb
[6] = MSW(MSD(sns_phys_address
));
1561 mcp
->mb
[7] = LSW(MSD(sns_phys_address
));
1562 mcp
->out_mb
= MBX_7
|MBX_6
|MBX_3
|MBX_2
|MBX_1
|MBX_0
;
1563 mcp
->in_mb
= MBX_0
|MBX_1
;
1564 mcp
->buf_size
= buf_size
;
1565 mcp
->flags
= MBX_DMA_OUT
|MBX_DMA_IN
;
1566 mcp
->tov
= (vha
->hw
->login_timeout
* 2) + (vha
->hw
->login_timeout
/ 2);
1567 rval
= qla2x00_mailbox_command(vha
, mcp
);
1569 if (rval
!= QLA_SUCCESS
) {
1571 DEBUG(printk("qla2x00_send_sns(%ld): failed=%x mb[0]=%x "
1572 "mb[1]=%x.\n", vha
->host_no
, rval
, mcp
->mb
[0], mcp
->mb
[1]));
1573 DEBUG2_3_11(printk("qla2x00_send_sns(%ld): failed=%x mb[0]=%x "
1574 "mb[1]=%x.\n", vha
->host_no
, rval
, mcp
->mb
[0], mcp
->mb
[1]));
1577 DEBUG11(printk("qla2x00_send_sns(%ld): done.\n", vha
->host_no
));
1584 qla24xx_login_fabric(scsi_qla_host_t
*vha
, uint16_t loop_id
, uint8_t domain
,
1585 uint8_t area
, uint8_t al_pa
, uint16_t *mb
, uint8_t opt
)
1589 struct logio_entry_24xx
*lg
;
1592 struct qla_hw_data
*ha
= vha
->hw
;
1593 struct req_que
*req
;
1594 struct rsp_que
*rsp
;
1596 DEBUG11(printk("%s(%ld): entered.\n", __func__
, vha
->host_no
));
1598 if (ha
->flags
.cpu_affinity_enabled
)
1599 req
= ha
->req_q_map
[0];
1604 lg
= dma_pool_alloc(ha
->s_dma_pool
, GFP_KERNEL
, &lg_dma
);
1606 DEBUG2_3(printk("%s(%ld): failed to allocate Login IOCB.\n",
1607 __func__
, vha
->host_no
));
1608 return QLA_MEMORY_ALLOC_FAILED
;
1610 memset(lg
, 0, sizeof(struct logio_entry_24xx
));
1612 lg
->entry_type
= LOGINOUT_PORT_IOCB_TYPE
;
1613 lg
->entry_count
= 1;
1614 lg
->handle
= MAKE_HANDLE(req
->id
, lg
->handle
);
1615 lg
->nport_handle
= cpu_to_le16(loop_id
);
1616 lg
->control_flags
= __constant_cpu_to_le16(LCF_COMMAND_PLOGI
);
1618 lg
->control_flags
|= __constant_cpu_to_le16(LCF_COND_PLOGI
);
1620 lg
->control_flags
|= __constant_cpu_to_le16(LCF_SKIP_PRLI
);
1621 lg
->port_id
[0] = al_pa
;
1622 lg
->port_id
[1] = area
;
1623 lg
->port_id
[2] = domain
;
1624 lg
->vp_index
= vha
->vp_idx
;
1625 rval
= qla2x00_issue_iocb(vha
, lg
, lg_dma
, 0);
1626 if (rval
!= QLA_SUCCESS
) {
1627 DEBUG2_3_11(printk("%s(%ld): failed to issue Login IOCB "
1628 "(%x).\n", __func__
, vha
->host_no
, rval
));
1629 } else if (lg
->entry_status
!= 0) {
1630 DEBUG2_3_11(printk("%s(%ld): failed to complete IOCB "
1631 "-- error status (%x).\n", __func__
, vha
->host_no
,
1633 rval
= QLA_FUNCTION_FAILED
;
1634 } else if (lg
->comp_status
!= __constant_cpu_to_le16(CS_COMPLETE
)) {
1635 iop
[0] = le32_to_cpu(lg
->io_parameter
[0]);
1636 iop
[1] = le32_to_cpu(lg
->io_parameter
[1]);
1638 DEBUG2_3_11(printk("%s(%ld): failed to complete IOCB "
1639 "-- completion status (%x) ioparam=%x/%x.\n", __func__
,
1640 vha
->host_no
, le16_to_cpu(lg
->comp_status
), iop
[0],
1644 case LSC_SCODE_PORTID_USED
:
1645 mb
[0] = MBS_PORT_ID_USED
;
1646 mb
[1] = LSW(iop
[1]);
1648 case LSC_SCODE_NPORT_USED
:
1649 mb
[0] = MBS_LOOP_ID_USED
;
1651 case LSC_SCODE_NOLINK
:
1652 case LSC_SCODE_NOIOCB
:
1653 case LSC_SCODE_NOXCB
:
1654 case LSC_SCODE_CMD_FAILED
:
1655 case LSC_SCODE_NOFABRIC
:
1656 case LSC_SCODE_FW_NOT_READY
:
1657 case LSC_SCODE_NOT_LOGGED_IN
:
1658 case LSC_SCODE_NOPCB
:
1659 case LSC_SCODE_ELS_REJECT
:
1660 case LSC_SCODE_CMD_PARAM_ERR
:
1661 case LSC_SCODE_NONPORT
:
1662 case LSC_SCODE_LOGGED_IN
:
1663 case LSC_SCODE_NOFLOGI_ACC
:
1665 mb
[0] = MBS_COMMAND_ERROR
;
1669 DEBUG11(printk("%s(%ld): done.\n", __func__
, vha
->host_no
));
1671 iop
[0] = le32_to_cpu(lg
->io_parameter
[0]);
1673 mb
[0] = MBS_COMMAND_COMPLETE
;
1675 if (iop
[0] & BIT_4
) {
1681 /* Passback COS information. */
1683 if (lg
->io_parameter
[7] || lg
->io_parameter
[8])
1684 mb
[10] |= BIT_0
; /* Class 2. */
1685 if (lg
->io_parameter
[9] || lg
->io_parameter
[10])
1686 mb
[10] |= BIT_1
; /* Class 3. */
1689 dma_pool_free(ha
->s_dma_pool
, lg
, lg_dma
);
1695 * qla2x00_login_fabric
1696 * Issue login fabric port mailbox command.
1699 * ha = adapter block pointer.
1700 * loop_id = device loop ID.
1701 * domain = device domain.
1702 * area = device area.
1703 * al_pa = device AL_PA.
1704 * status = pointer for return status.
1705 * opt = command options.
1706 * TARGET_QUEUE_LOCK must be released.
1707 * ADAPTER_STATE_LOCK must be released.
1710 * qla2x00 local function return status code.
1716 qla2x00_login_fabric(scsi_qla_host_t
*vha
, uint16_t loop_id
, uint8_t domain
,
1717 uint8_t area
, uint8_t al_pa
, uint16_t *mb
, uint8_t opt
)
1721 mbx_cmd_t
*mcp
= &mc
;
1722 struct qla_hw_data
*ha
= vha
->hw
;
1724 DEBUG11(printk("qla2x00_login_fabric(%ld): entered.\n", vha
->host_no
));
1726 mcp
->mb
[0] = MBC_LOGIN_FABRIC_PORT
;
1727 mcp
->out_mb
= MBX_3
|MBX_2
|MBX_1
|MBX_0
;
1728 if (HAS_EXTENDED_IDS(ha
)) {
1729 mcp
->mb
[1] = loop_id
;
1731 mcp
->out_mb
|= MBX_10
;
1733 mcp
->mb
[1] = (loop_id
<< 8) | opt
;
1735 mcp
->mb
[2] = domain
;
1736 mcp
->mb
[3] = area
<< 8 | al_pa
;
1738 mcp
->in_mb
= MBX_7
|MBX_6
|MBX_2
|MBX_1
|MBX_0
;
1739 mcp
->tov
= (ha
->login_timeout
* 2) + (ha
->login_timeout
/ 2);
1741 rval
= qla2x00_mailbox_command(vha
, mcp
);
1743 /* Return mailbox statuses. */
1750 /* COS retrieved from Get-Port-Database mailbox command. */
1754 if (rval
!= QLA_SUCCESS
) {
1755 /* RLU tmp code: need to change main mailbox_command function to
1756 * return ok even when the mailbox completion value is not
1757 * SUCCESS. The caller needs to be responsible to interpret
1758 * the return values of this mailbox command if we're not
1759 * to change too much of the existing code.
1761 if (mcp
->mb
[0] == 0x4001 || mcp
->mb
[0] == 0x4002 ||
1762 mcp
->mb
[0] == 0x4003 || mcp
->mb
[0] == 0x4005 ||
1763 mcp
->mb
[0] == 0x4006)
1767 DEBUG2_3_11(printk("qla2x00_login_fabric(%ld): failed=%x "
1768 "mb[0]=%x mb[1]=%x mb[2]=%x.\n", vha
->host_no
, rval
,
1769 mcp
->mb
[0], mcp
->mb
[1], mcp
->mb
[2]));
1772 DEBUG11(printk("qla2x00_login_fabric(%ld): done.\n",
1780 * qla2x00_login_local_device
1781 * Issue login loop port mailbox command.
1784 * ha = adapter block pointer.
1785 * loop_id = device loop ID.
1786 * opt = command options.
1789 * Return status code.
1796 qla2x00_login_local_device(scsi_qla_host_t
*vha
, fc_port_t
*fcport
,
1797 uint16_t *mb_ret
, uint8_t opt
)
1801 mbx_cmd_t
*mcp
= &mc
;
1802 struct qla_hw_data
*ha
= vha
->hw
;
1804 if (IS_FWI2_CAPABLE(ha
))
1805 return qla24xx_login_fabric(vha
, fcport
->loop_id
,
1806 fcport
->d_id
.b
.domain
, fcport
->d_id
.b
.area
,
1807 fcport
->d_id
.b
.al_pa
, mb_ret
, opt
);
1809 DEBUG3(printk("%s(%ld): entered.\n", __func__
, vha
->host_no
));
1811 mcp
->mb
[0] = MBC_LOGIN_LOOP_PORT
;
1812 if (HAS_EXTENDED_IDS(ha
))
1813 mcp
->mb
[1] = fcport
->loop_id
;
1815 mcp
->mb
[1] = fcport
->loop_id
<< 8;
1817 mcp
->out_mb
= MBX_2
|MBX_1
|MBX_0
;
1818 mcp
->in_mb
= MBX_7
|MBX_6
|MBX_1
|MBX_0
;
1819 mcp
->tov
= (ha
->login_timeout
* 2) + (ha
->login_timeout
/ 2);
1821 rval
= qla2x00_mailbox_command(vha
, mcp
);
1823 /* Return mailbox statuses. */
1824 if (mb_ret
!= NULL
) {
1825 mb_ret
[0] = mcp
->mb
[0];
1826 mb_ret
[1] = mcp
->mb
[1];
1827 mb_ret
[6] = mcp
->mb
[6];
1828 mb_ret
[7] = mcp
->mb
[7];
1831 if (rval
!= QLA_SUCCESS
) {
1832 /* AV tmp code: need to change main mailbox_command function to
1833 * return ok even when the mailbox completion value is not
1834 * SUCCESS. The caller needs to be responsible to interpret
1835 * the return values of this mailbox command if we're not
1836 * to change too much of the existing code.
1838 if (mcp
->mb
[0] == 0x4005 || mcp
->mb
[0] == 0x4006)
1841 DEBUG(printk("%s(%ld): failed=%x mb[0]=%x mb[1]=%x "
1842 "mb[6]=%x mb[7]=%x.\n", __func__
, vha
->host_no
, rval
,
1843 mcp
->mb
[0], mcp
->mb
[1], mcp
->mb
[6], mcp
->mb
[7]));
1844 DEBUG2_3(printk("%s(%ld): failed=%x mb[0]=%x mb[1]=%x "
1845 "mb[6]=%x mb[7]=%x.\n", __func__
, vha
->host_no
, rval
,
1846 mcp
->mb
[0], mcp
->mb
[1], mcp
->mb
[6], mcp
->mb
[7]));
1849 DEBUG3(printk("%s(%ld): done.\n", __func__
, vha
->host_no
));
1856 qla24xx_fabric_logout(scsi_qla_host_t
*vha
, uint16_t loop_id
, uint8_t domain
,
1857 uint8_t area
, uint8_t al_pa
)
1860 struct logio_entry_24xx
*lg
;
1862 struct qla_hw_data
*ha
= vha
->hw
;
1863 struct req_que
*req
;
1864 struct rsp_que
*rsp
;
1866 DEBUG11(printk("%s(%ld): entered.\n", __func__
, vha
->host_no
));
1868 lg
= dma_pool_alloc(ha
->s_dma_pool
, GFP_KERNEL
, &lg_dma
);
1870 DEBUG2_3(printk("%s(%ld): failed to allocate Logout IOCB.\n",
1871 __func__
, vha
->host_no
));
1872 return QLA_MEMORY_ALLOC_FAILED
;
1874 memset(lg
, 0, sizeof(struct logio_entry_24xx
));
1876 if (ql2xmaxqueues
> 1)
1877 req
= ha
->req_q_map
[0];
1881 lg
->entry_type
= LOGINOUT_PORT_IOCB_TYPE
;
1882 lg
->entry_count
= 1;
1883 lg
->handle
= MAKE_HANDLE(req
->id
, lg
->handle
);
1884 lg
->nport_handle
= cpu_to_le16(loop_id
);
1886 __constant_cpu_to_le16(LCF_COMMAND_LOGO
|LCF_IMPL_LOGO
);
1887 lg
->port_id
[0] = al_pa
;
1888 lg
->port_id
[1] = area
;
1889 lg
->port_id
[2] = domain
;
1890 lg
->vp_index
= vha
->vp_idx
;
1892 rval
= qla2x00_issue_iocb(vha
, lg
, lg_dma
, 0);
1893 if (rval
!= QLA_SUCCESS
) {
1894 DEBUG2_3_11(printk("%s(%ld): failed to issue Logout IOCB "
1895 "(%x).\n", __func__
, vha
->host_no
, rval
));
1896 } else if (lg
->entry_status
!= 0) {
1897 DEBUG2_3_11(printk("%s(%ld): failed to complete IOCB "
1898 "-- error status (%x).\n", __func__
, vha
->host_no
,
1900 rval
= QLA_FUNCTION_FAILED
;
1901 } else if (lg
->comp_status
!= __constant_cpu_to_le16(CS_COMPLETE
)) {
1902 DEBUG2_3_11(printk("%s(%ld %d): failed to complete IOCB "
1903 "-- completion status (%x) ioparam=%x/%x.\n", __func__
,
1904 vha
->host_no
, vha
->vp_idx
, le16_to_cpu(lg
->comp_status
),
1905 le32_to_cpu(lg
->io_parameter
[0]),
1906 le32_to_cpu(lg
->io_parameter
[1])));
1909 DEBUG11(printk("%s(%ld): done.\n", __func__
, vha
->host_no
));
1912 dma_pool_free(ha
->s_dma_pool
, lg
, lg_dma
);
1918 * qla2x00_fabric_logout
1919 * Issue logout fabric port mailbox command.
1922 * ha = adapter block pointer.
1923 * loop_id = device loop ID.
1924 * TARGET_QUEUE_LOCK must be released.
1925 * ADAPTER_STATE_LOCK must be released.
1928 * qla2x00 local function return status code.
1934 qla2x00_fabric_logout(scsi_qla_host_t
*vha
, uint16_t loop_id
, uint8_t domain
,
1935 uint8_t area
, uint8_t al_pa
)
1939 mbx_cmd_t
*mcp
= &mc
;
1941 DEBUG11(printk("qla2x00_fabric_logout(%ld): entered.\n",
1944 mcp
->mb
[0] = MBC_LOGOUT_FABRIC_PORT
;
1945 mcp
->out_mb
= MBX_1
|MBX_0
;
1946 if (HAS_EXTENDED_IDS(vha
->hw
)) {
1947 mcp
->mb
[1] = loop_id
;
1949 mcp
->out_mb
|= MBX_10
;
1951 mcp
->mb
[1] = loop_id
<< 8;
1954 mcp
->in_mb
= MBX_1
|MBX_0
;
1955 mcp
->tov
= MBX_TOV_SECONDS
;
1957 rval
= qla2x00_mailbox_command(vha
, mcp
);
1959 if (rval
!= QLA_SUCCESS
) {
1961 DEBUG2_3_11(printk("qla2x00_fabric_logout(%ld): failed=%x "
1962 "mbx1=%x.\n", vha
->host_no
, rval
, mcp
->mb
[1]));
1965 DEBUG11(printk("qla2x00_fabric_logout(%ld): done.\n",
1973 * qla2x00_full_login_lip
1974 * Issue full login LIP mailbox command.
1977 * ha = adapter block pointer.
1978 * TARGET_QUEUE_LOCK must be released.
1979 * ADAPTER_STATE_LOCK must be released.
1982 * qla2x00 local function return status code.
1988 qla2x00_full_login_lip(scsi_qla_host_t
*vha
)
1992 mbx_cmd_t
*mcp
= &mc
;
1994 DEBUG11(printk("qla2x00_full_login_lip(%ld): entered.\n",
1997 mcp
->mb
[0] = MBC_LIP_FULL_LOGIN
;
1998 mcp
->mb
[1] = IS_FWI2_CAPABLE(vha
->hw
) ? BIT_3
: 0;
2001 mcp
->out_mb
= MBX_3
|MBX_2
|MBX_1
|MBX_0
;
2003 mcp
->tov
= MBX_TOV_SECONDS
;
2005 rval
= qla2x00_mailbox_command(vha
, mcp
);
2007 if (rval
!= QLA_SUCCESS
) {
2009 DEBUG2_3_11(printk("qla2x00_full_login_lip(%ld): failed=%x.\n",
2010 vha
->host_no
, rval
));
2013 DEBUG11(printk("qla2x00_full_login_lip(%ld): done.\n",
2021 * qla2x00_get_id_list
2024 * ha = adapter block pointer.
2027 * qla2x00 local function return status code.
2033 qla2x00_get_id_list(scsi_qla_host_t
*vha
, void *id_list
, dma_addr_t id_list_dma
,
2038 mbx_cmd_t
*mcp
= &mc
;
2040 DEBUG11(printk("qla2x00_get_id_list(%ld): entered.\n",
2043 if (id_list
== NULL
)
2044 return QLA_FUNCTION_FAILED
;
2046 mcp
->mb
[0] = MBC_GET_ID_LIST
;
2047 mcp
->out_mb
= MBX_0
;
2048 if (IS_FWI2_CAPABLE(vha
->hw
)) {
2049 mcp
->mb
[2] = MSW(id_list_dma
);
2050 mcp
->mb
[3] = LSW(id_list_dma
);
2051 mcp
->mb
[6] = MSW(MSD(id_list_dma
));
2052 mcp
->mb
[7] = LSW(MSD(id_list_dma
));
2054 mcp
->mb
[9] = vha
->vp_idx
;
2055 mcp
->out_mb
|= MBX_9
|MBX_8
|MBX_7
|MBX_6
|MBX_3
|MBX_2
;
2057 mcp
->mb
[1] = MSW(id_list_dma
);
2058 mcp
->mb
[2] = LSW(id_list_dma
);
2059 mcp
->mb
[3] = MSW(MSD(id_list_dma
));
2060 mcp
->mb
[6] = LSW(MSD(id_list_dma
));
2061 mcp
->out_mb
|= MBX_6
|MBX_3
|MBX_2
|MBX_1
;
2063 mcp
->in_mb
= MBX_1
|MBX_0
;
2064 mcp
->tov
= MBX_TOV_SECONDS
;
2066 rval
= qla2x00_mailbox_command(vha
, mcp
);
2068 if (rval
!= QLA_SUCCESS
) {
2070 DEBUG2_3_11(printk("qla2x00_get_id_list(%ld): failed=%x.\n",
2071 vha
->host_no
, rval
));
2073 *entries
= mcp
->mb
[1];
2074 DEBUG11(printk("qla2x00_get_id_list(%ld): done.\n",
2082 * qla2x00_get_resource_cnts
2083 * Get current firmware resource counts.
2086 * ha = adapter block pointer.
2089 * qla2x00 local function return status code.
2095 qla2x00_get_resource_cnts(scsi_qla_host_t
*vha
, uint16_t *cur_xchg_cnt
,
2096 uint16_t *orig_xchg_cnt
, uint16_t *cur_iocb_cnt
,
2097 uint16_t *orig_iocb_cnt
, uint16_t *max_npiv_vports
, uint16_t *max_fcfs
)
2101 mbx_cmd_t
*mcp
= &mc
;
2103 DEBUG11(printk("%s(%ld): entered.\n", __func__
, vha
->host_no
));
2105 mcp
->mb
[0] = MBC_GET_RESOURCE_COUNTS
;
2106 mcp
->out_mb
= MBX_0
;
2107 mcp
->in_mb
= MBX_11
|MBX_10
|MBX_7
|MBX_6
|MBX_3
|MBX_2
|MBX_1
|MBX_0
;
2108 if (IS_QLA81XX(vha
->hw
))
2109 mcp
->in_mb
|= MBX_12
;
2110 mcp
->tov
= MBX_TOV_SECONDS
;
2112 rval
= qla2x00_mailbox_command(vha
, mcp
);
2114 if (rval
!= QLA_SUCCESS
) {
2116 DEBUG2_3_11(printk("%s(%ld): failed = %x.\n", __func__
,
2117 vha
->host_no
, mcp
->mb
[0]));
2119 DEBUG11(printk("%s(%ld): done. mb1=%x mb2=%x mb3=%x mb6=%x "
2120 "mb7=%x mb10=%x mb11=%x mb12=%x.\n", __func__
,
2121 vha
->host_no
, mcp
->mb
[1], mcp
->mb
[2], mcp
->mb
[3],
2122 mcp
->mb
[6], mcp
->mb
[7], mcp
->mb
[10], mcp
->mb
[11],
2126 *cur_xchg_cnt
= mcp
->mb
[3];
2128 *orig_xchg_cnt
= mcp
->mb
[6];
2130 *cur_iocb_cnt
= mcp
->mb
[7];
2132 *orig_iocb_cnt
= mcp
->mb
[10];
2133 if (vha
->hw
->flags
.npiv_supported
&& max_npiv_vports
)
2134 *max_npiv_vports
= mcp
->mb
[11];
2135 if (IS_QLA81XX(vha
->hw
) && max_fcfs
)
2136 *max_fcfs
= mcp
->mb
[12];
2142 #if defined(QL_DEBUG_LEVEL_3)
2144 * qla2x00_get_fcal_position_map
2145 * Get FCAL (LILP) position map using mailbox command
2148 * ha = adapter state pointer.
2149 * pos_map = buffer pointer (can be NULL).
2152 * qla2x00 local function return status code.
2158 qla2x00_get_fcal_position_map(scsi_qla_host_t
*vha
, char *pos_map
)
2162 mbx_cmd_t
*mcp
= &mc
;
2164 dma_addr_t pmap_dma
;
2165 struct qla_hw_data
*ha
= vha
->hw
;
2167 pmap
= dma_pool_alloc(ha
->s_dma_pool
, GFP_KERNEL
, &pmap_dma
);
2169 DEBUG2_3_11(printk("%s(%ld): **** Mem Alloc Failed ****",
2170 __func__
, vha
->host_no
));
2171 return QLA_MEMORY_ALLOC_FAILED
;
2173 memset(pmap
, 0, FCAL_MAP_SIZE
);
2175 mcp
->mb
[0] = MBC_GET_FC_AL_POSITION_MAP
;
2176 mcp
->mb
[2] = MSW(pmap_dma
);
2177 mcp
->mb
[3] = LSW(pmap_dma
);
2178 mcp
->mb
[6] = MSW(MSD(pmap_dma
));
2179 mcp
->mb
[7] = LSW(MSD(pmap_dma
));
2180 mcp
->out_mb
= MBX_7
|MBX_6
|MBX_3
|MBX_2
|MBX_0
;
2181 mcp
->in_mb
= MBX_1
|MBX_0
;
2182 mcp
->buf_size
= FCAL_MAP_SIZE
;
2183 mcp
->flags
= MBX_DMA_IN
;
2184 mcp
->tov
= (ha
->login_timeout
* 2) + (ha
->login_timeout
/ 2);
2185 rval
= qla2x00_mailbox_command(vha
, mcp
);
2187 if (rval
== QLA_SUCCESS
) {
2188 DEBUG11(printk("%s(%ld): (mb0=%x/mb1=%x) FC/AL Position Map "
2189 "size (%x)\n", __func__
, vha
->host_no
, mcp
->mb
[0],
2190 mcp
->mb
[1], (unsigned)pmap
[0]));
2191 DEBUG11(qla2x00_dump_buffer(pmap
, pmap
[0] + 1));
2194 memcpy(pos_map
, pmap
, FCAL_MAP_SIZE
);
2196 dma_pool_free(ha
->s_dma_pool
, pmap
, pmap_dma
);
2198 if (rval
!= QLA_SUCCESS
) {
2199 DEBUG2_3_11(printk("%s(%ld): failed=%x.\n", __func__
,
2200 vha
->host_no
, rval
));
2202 DEBUG11(printk("%s(%ld): done.\n", __func__
, vha
->host_no
));
2210 * qla2x00_get_link_status
2213 * ha = adapter block pointer.
2214 * loop_id = device loop ID.
2215 * ret_buf = pointer to link status return buffer.
2219 * BIT_0 = mem alloc error.
2220 * BIT_1 = mailbox error.
2223 qla2x00_get_link_status(scsi_qla_host_t
*vha
, uint16_t loop_id
,
2224 struct link_statistics
*stats
, dma_addr_t stats_dma
)
2228 mbx_cmd_t
*mcp
= &mc
;
2229 uint32_t *siter
, *diter
, dwords
;
2230 struct qla_hw_data
*ha
= vha
->hw
;
2232 DEBUG11(printk("%s(%ld): entered.\n", __func__
, vha
->host_no
));
2234 mcp
->mb
[0] = MBC_GET_LINK_STATUS
;
2235 mcp
->mb
[2] = MSW(stats_dma
);
2236 mcp
->mb
[3] = LSW(stats_dma
);
2237 mcp
->mb
[6] = MSW(MSD(stats_dma
));
2238 mcp
->mb
[7] = LSW(MSD(stats_dma
));
2239 mcp
->out_mb
= MBX_7
|MBX_6
|MBX_3
|MBX_2
|MBX_0
;
2241 if (IS_FWI2_CAPABLE(ha
)) {
2242 mcp
->mb
[1] = loop_id
;
2245 mcp
->out_mb
|= MBX_10
|MBX_4
|MBX_1
;
2246 mcp
->in_mb
|= MBX_1
;
2247 } else if (HAS_EXTENDED_IDS(ha
)) {
2248 mcp
->mb
[1] = loop_id
;
2250 mcp
->out_mb
|= MBX_10
|MBX_1
;
2252 mcp
->mb
[1] = loop_id
<< 8;
2253 mcp
->out_mb
|= MBX_1
;
2255 mcp
->tov
= MBX_TOV_SECONDS
;
2256 mcp
->flags
= IOCTL_CMD
;
2257 rval
= qla2x00_mailbox_command(vha
, mcp
);
2259 if (rval
== QLA_SUCCESS
) {
2260 if (mcp
->mb
[0] != MBS_COMMAND_COMPLETE
) {
2261 DEBUG2_3_11(printk("%s(%ld): cmd failed. mbx0=%x.\n",
2262 __func__
, vha
->host_no
, mcp
->mb
[0]));
2263 rval
= QLA_FUNCTION_FAILED
;
2265 /* Copy over data -- firmware data is LE. */
2266 dwords
= offsetof(struct link_statistics
, unused1
) / 4;
2267 siter
= diter
= &stats
->link_fail_cnt
;
2269 *diter
++ = le32_to_cpu(*siter
++);
2273 DEBUG2_3_11(printk("%s(%ld): failed=%x.\n", __func__
,
2274 vha
->host_no
, rval
));
2281 qla24xx_get_isp_stats(scsi_qla_host_t
*vha
, struct link_statistics
*stats
,
2282 dma_addr_t stats_dma
)
2286 mbx_cmd_t
*mcp
= &mc
;
2287 uint32_t *siter
, *diter
, dwords
;
2289 DEBUG11(printk("%s(%ld): entered.\n", __func__
, vha
->host_no
));
2291 mcp
->mb
[0] = MBC_GET_LINK_PRIV_STATS
;
2292 mcp
->mb
[2] = MSW(stats_dma
);
2293 mcp
->mb
[3] = LSW(stats_dma
);
2294 mcp
->mb
[6] = MSW(MSD(stats_dma
));
2295 mcp
->mb
[7] = LSW(MSD(stats_dma
));
2296 mcp
->mb
[8] = sizeof(struct link_statistics
) / 4;
2297 mcp
->mb
[9] = vha
->vp_idx
;
2299 mcp
->out_mb
= MBX_10
|MBX_9
|MBX_8
|MBX_7
|MBX_6
|MBX_3
|MBX_2
|MBX_0
;
2300 mcp
->in_mb
= MBX_2
|MBX_1
|MBX_0
;
2301 mcp
->tov
= MBX_TOV_SECONDS
;
2302 mcp
->flags
= IOCTL_CMD
;
2303 rval
= qla2x00_mailbox_command(vha
, mcp
);
2305 if (rval
== QLA_SUCCESS
) {
2306 if (mcp
->mb
[0] != MBS_COMMAND_COMPLETE
) {
2307 DEBUG2_3_11(printk("%s(%ld): cmd failed. mbx0=%x.\n",
2308 __func__
, vha
->host_no
, mcp
->mb
[0]));
2309 rval
= QLA_FUNCTION_FAILED
;
2311 /* Copy over data -- firmware data is LE. */
2312 dwords
= sizeof(struct link_statistics
) / 4;
2313 siter
= diter
= &stats
->link_fail_cnt
;
2315 *diter
++ = le32_to_cpu(*siter
++);
2319 DEBUG2_3_11(printk("%s(%ld): failed=%x.\n", __func__
,
2320 vha
->host_no
, rval
));
2327 qla24xx_abort_command(srb_t
*sp
)
2330 unsigned long flags
= 0;
2332 struct abort_entry_24xx
*abt
;
2335 fc_port_t
*fcport
= sp
->fcport
;
2336 struct scsi_qla_host
*vha
= fcport
->vha
;
2337 struct qla_hw_data
*ha
= vha
->hw
;
2338 struct req_que
*req
= vha
->req
;
2340 DEBUG11(printk("%s(%ld): entered.\n", __func__
, vha
->host_no
));
2342 spin_lock_irqsave(&ha
->hardware_lock
, flags
);
2343 for (handle
= 1; handle
< MAX_OUTSTANDING_COMMANDS
; handle
++) {
2344 if (req
->outstanding_cmds
[handle
] == sp
)
2347 spin_unlock_irqrestore(&ha
->hardware_lock
, flags
);
2348 if (handle
== MAX_OUTSTANDING_COMMANDS
) {
2349 /* Command not found. */
2350 return QLA_FUNCTION_FAILED
;
2353 abt
= dma_pool_alloc(ha
->s_dma_pool
, GFP_KERNEL
, &abt_dma
);
2355 DEBUG2_3(printk("%s(%ld): failed to allocate Abort IOCB.\n",
2356 __func__
, vha
->host_no
));
2357 return QLA_MEMORY_ALLOC_FAILED
;
2359 memset(abt
, 0, sizeof(struct abort_entry_24xx
));
2361 abt
->entry_type
= ABORT_IOCB_TYPE
;
2362 abt
->entry_count
= 1;
2363 abt
->handle
= MAKE_HANDLE(req
->id
, abt
->handle
);
2364 abt
->nport_handle
= cpu_to_le16(fcport
->loop_id
);
2365 abt
->handle_to_abort
= MAKE_HANDLE(req
->id
, handle
);
2366 abt
->port_id
[0] = fcport
->d_id
.b
.al_pa
;
2367 abt
->port_id
[1] = fcport
->d_id
.b
.area
;
2368 abt
->port_id
[2] = fcport
->d_id
.b
.domain
;
2369 abt
->vp_index
= fcport
->vp_idx
;
2371 abt
->req_que_no
= cpu_to_le16(req
->id
);
2373 rval
= qla2x00_issue_iocb(vha
, abt
, abt_dma
, 0);
2374 if (rval
!= QLA_SUCCESS
) {
2375 DEBUG2_3_11(printk("%s(%ld): failed to issue IOCB (%x).\n",
2376 __func__
, vha
->host_no
, rval
));
2377 } else if (abt
->entry_status
!= 0) {
2378 DEBUG2_3_11(printk("%s(%ld): failed to complete IOCB "
2379 "-- error status (%x).\n", __func__
, vha
->host_no
,
2380 abt
->entry_status
));
2381 rval
= QLA_FUNCTION_FAILED
;
2382 } else if (abt
->nport_handle
!= __constant_cpu_to_le16(0)) {
2383 DEBUG2_3_11(printk("%s(%ld): failed to complete IOCB "
2384 "-- completion status (%x).\n", __func__
, vha
->host_no
,
2385 le16_to_cpu(abt
->nport_handle
)));
2386 rval
= QLA_FUNCTION_FAILED
;
2388 DEBUG11(printk("%s(%ld): done.\n", __func__
, vha
->host_no
));
2391 dma_pool_free(ha
->s_dma_pool
, abt
, abt_dma
);
2396 struct tsk_mgmt_cmd
{
2398 struct tsk_mgmt_entry tsk
;
2399 struct sts_entry_24xx sts
;
2404 __qla24xx_issue_tmf(char *name
, uint32_t type
, struct fc_port
*fcport
,
2405 unsigned int l
, int tag
)
2408 struct tsk_mgmt_cmd
*tsk
;
2409 struct sts_entry_24xx
*sts
;
2411 scsi_qla_host_t
*vha
;
2412 struct qla_hw_data
*ha
;
2413 struct req_que
*req
;
2414 struct rsp_que
*rsp
;
2416 DEBUG11(printk("%s(%ld): entered.\n", __func__
, fcport
->vha
->host_no
));
2421 if (ha
->flags
.cpu_affinity_enabled
)
2422 rsp
= ha
->rsp_q_map
[tag
+ 1];
2425 tsk
= dma_pool_alloc(ha
->s_dma_pool
, GFP_KERNEL
, &tsk_dma
);
2427 DEBUG2_3(printk("%s(%ld): failed to allocate Task Management "
2428 "IOCB.\n", __func__
, vha
->host_no
));
2429 return QLA_MEMORY_ALLOC_FAILED
;
2431 memset(tsk
, 0, sizeof(struct tsk_mgmt_cmd
));
2433 tsk
->p
.tsk
.entry_type
= TSK_MGMT_IOCB_TYPE
;
2434 tsk
->p
.tsk
.entry_count
= 1;
2435 tsk
->p
.tsk
.handle
= MAKE_HANDLE(req
->id
, tsk
->p
.tsk
.handle
);
2436 tsk
->p
.tsk
.nport_handle
= cpu_to_le16(fcport
->loop_id
);
2437 tsk
->p
.tsk
.timeout
= cpu_to_le16(ha
->r_a_tov
/ 10 * 2);
2438 tsk
->p
.tsk
.control_flags
= cpu_to_le32(type
);
2439 tsk
->p
.tsk
.port_id
[0] = fcport
->d_id
.b
.al_pa
;
2440 tsk
->p
.tsk
.port_id
[1] = fcport
->d_id
.b
.area
;
2441 tsk
->p
.tsk
.port_id
[2] = fcport
->d_id
.b
.domain
;
2442 tsk
->p
.tsk
.vp_index
= fcport
->vp_idx
;
2443 if (type
== TCF_LUN_RESET
) {
2444 int_to_scsilun(l
, &tsk
->p
.tsk
.lun
);
2445 host_to_fcp_swap((uint8_t *)&tsk
->p
.tsk
.lun
,
2446 sizeof(tsk
->p
.tsk
.lun
));
2450 rval
= qla2x00_issue_iocb(vha
, tsk
, tsk_dma
, 0);
2451 if (rval
!= QLA_SUCCESS
) {
2452 DEBUG2_3_11(printk("%s(%ld): failed to issue %s Reset IOCB "
2453 "(%x).\n", __func__
, vha
->host_no
, name
, rval
));
2454 } else if (sts
->entry_status
!= 0) {
2455 DEBUG2_3_11(printk("%s(%ld): failed to complete IOCB "
2456 "-- error status (%x).\n", __func__
, vha
->host_no
,
2457 sts
->entry_status
));
2458 rval
= QLA_FUNCTION_FAILED
;
2459 } else if (sts
->comp_status
!=
2460 __constant_cpu_to_le16(CS_COMPLETE
)) {
2461 DEBUG2_3_11(printk("%s(%ld): failed to complete IOCB "
2462 "-- completion status (%x).\n", __func__
,
2463 vha
->host_no
, le16_to_cpu(sts
->comp_status
)));
2464 rval
= QLA_FUNCTION_FAILED
;
2465 } else if (le16_to_cpu(sts
->scsi_status
) &
2466 SS_RESPONSE_INFO_LEN_VALID
) {
2467 if (le32_to_cpu(sts
->rsp_data_len
) < 4) {
2468 DEBUG2_3_11(printk("%s(%ld): ignoring inconsistent "
2469 "data length -- not enough response info (%d).\n",
2470 __func__
, vha
->host_no
,
2471 le32_to_cpu(sts
->rsp_data_len
)));
2472 } else if (sts
->data
[3]) {
2473 DEBUG2_3_11(printk("%s(%ld): failed to complete IOCB "
2474 "-- response (%x).\n", __func__
,
2475 vha
->host_no
, sts
->data
[3]));
2476 rval
= QLA_FUNCTION_FAILED
;
2480 /* Issue marker IOCB. */
2481 rval2
= qla2x00_marker(vha
, req
, rsp
, fcport
->loop_id
, l
,
2482 type
== TCF_LUN_RESET
? MK_SYNC_ID_LUN
: MK_SYNC_ID
);
2483 if (rval2
!= QLA_SUCCESS
) {
2484 DEBUG2_3_11(printk("%s(%ld): failed to issue Marker IOCB "
2485 "(%x).\n", __func__
, vha
->host_no
, rval2
));
2487 DEBUG11(printk("%s(%ld): done.\n", __func__
, vha
->host_no
));
2490 dma_pool_free(ha
->s_dma_pool
, tsk
, tsk_dma
);
2496 qla24xx_abort_target(struct fc_port
*fcport
, unsigned int l
, int tag
)
2498 struct qla_hw_data
*ha
= fcport
->vha
->hw
;
2500 if ((ql2xasynctmfenable
) && IS_FWI2_CAPABLE(ha
))
2501 return qla2x00_async_tm_cmd(fcport
, TCF_TARGET_RESET
, l
, tag
);
2503 return __qla24xx_issue_tmf("Target", TCF_TARGET_RESET
, fcport
, l
, tag
);
2507 qla24xx_lun_reset(struct fc_port
*fcport
, unsigned int l
, int tag
)
2509 struct qla_hw_data
*ha
= fcport
->vha
->hw
;
2511 if ((ql2xasynctmfenable
) && IS_FWI2_CAPABLE(ha
))
2512 return qla2x00_async_tm_cmd(fcport
, TCF_LUN_RESET
, l
, tag
);
2514 return __qla24xx_issue_tmf("Lun", TCF_LUN_RESET
, fcport
, l
, tag
);
2518 qla2x00_system_error(scsi_qla_host_t
*vha
)
2522 mbx_cmd_t
*mcp
= &mc
;
2523 struct qla_hw_data
*ha
= vha
->hw
;
2525 if (!IS_QLA23XX(ha
) && !IS_FWI2_CAPABLE(ha
))
2526 return QLA_FUNCTION_FAILED
;
2528 DEBUG11(printk("%s(%ld): entered.\n", __func__
, vha
->host_no
));
2530 mcp
->mb
[0] = MBC_GEN_SYSTEM_ERROR
;
2531 mcp
->out_mb
= MBX_0
;
2535 rval
= qla2x00_mailbox_command(vha
, mcp
);
2537 if (rval
!= QLA_SUCCESS
) {
2538 DEBUG2_3_11(printk("%s(%ld): failed=%x.\n", __func__
,
2539 vha
->host_no
, rval
));
2541 DEBUG11(printk("%s(%ld): done.\n", __func__
, vha
->host_no
));
2548 * qla2x00_set_serdes_params() -
2554 qla2x00_set_serdes_params(scsi_qla_host_t
*vha
, uint16_t sw_em_1g
,
2555 uint16_t sw_em_2g
, uint16_t sw_em_4g
)
2559 mbx_cmd_t
*mcp
= &mc
;
2561 DEBUG11(printk("%s(%ld): entered.\n", __func__
, vha
->host_no
));
2563 mcp
->mb
[0] = MBC_SERDES_PARAMS
;
2565 mcp
->mb
[2] = sw_em_1g
| BIT_15
;
2566 mcp
->mb
[3] = sw_em_2g
| BIT_15
;
2567 mcp
->mb
[4] = sw_em_4g
| BIT_15
;
2568 mcp
->out_mb
= MBX_4
|MBX_3
|MBX_2
|MBX_1
|MBX_0
;
2570 mcp
->tov
= MBX_TOV_SECONDS
;
2572 rval
= qla2x00_mailbox_command(vha
, mcp
);
2574 if (rval
!= QLA_SUCCESS
) {
2576 DEBUG2_3_11(printk("%s(%ld): failed=%x (%x).\n", __func__
,
2577 vha
->host_no
, rval
, mcp
->mb
[0]));
2580 DEBUG11(printk("%s(%ld): done.\n", __func__
, vha
->host_no
));
2587 qla2x00_stop_firmware(scsi_qla_host_t
*vha
)
2591 mbx_cmd_t
*mcp
= &mc
;
2593 if (!IS_FWI2_CAPABLE(vha
->hw
))
2594 return QLA_FUNCTION_FAILED
;
2596 DEBUG11(printk("%s(%ld): entered.\n", __func__
, vha
->host_no
));
2598 mcp
->mb
[0] = MBC_STOP_FIRMWARE
;
2599 mcp
->out_mb
= MBX_0
;
2603 rval
= qla2x00_mailbox_command(vha
, mcp
);
2605 if (rval
!= QLA_SUCCESS
) {
2606 DEBUG2_3_11(printk("%s(%ld): failed=%x.\n", __func__
,
2607 vha
->host_no
, rval
));
2608 if (mcp
->mb
[0] == MBS_INVALID_COMMAND
)
2609 rval
= QLA_INVALID_COMMAND
;
2611 DEBUG11(printk("%s(%ld): done.\n", __func__
, vha
->host_no
));
2618 qla2x00_enable_eft_trace(scsi_qla_host_t
*vha
, dma_addr_t eft_dma
,
2623 mbx_cmd_t
*mcp
= &mc
;
2625 if (!IS_FWI2_CAPABLE(vha
->hw
))
2626 return QLA_FUNCTION_FAILED
;
2628 if (unlikely(pci_channel_offline(vha
->hw
->pdev
)))
2629 return QLA_FUNCTION_FAILED
;
2631 DEBUG11(printk("%s(%ld): entered.\n", __func__
, vha
->host_no
));
2633 mcp
->mb
[0] = MBC_TRACE_CONTROL
;
2634 mcp
->mb
[1] = TC_EFT_ENABLE
;
2635 mcp
->mb
[2] = LSW(eft_dma
);
2636 mcp
->mb
[3] = MSW(eft_dma
);
2637 mcp
->mb
[4] = LSW(MSD(eft_dma
));
2638 mcp
->mb
[5] = MSW(MSD(eft_dma
));
2639 mcp
->mb
[6] = buffers
;
2640 mcp
->mb
[7] = TC_AEN_DISABLE
;
2641 mcp
->out_mb
= MBX_7
|MBX_6
|MBX_5
|MBX_4
|MBX_3
|MBX_2
|MBX_1
|MBX_0
;
2642 mcp
->in_mb
= MBX_1
|MBX_0
;
2643 mcp
->tov
= MBX_TOV_SECONDS
;
2645 rval
= qla2x00_mailbox_command(vha
, mcp
);
2646 if (rval
!= QLA_SUCCESS
) {
2647 DEBUG2_3_11(printk("%s(%ld): failed=%x mb[0]=%x mb[1]=%x.\n",
2648 __func__
, vha
->host_no
, rval
, mcp
->mb
[0], mcp
->mb
[1]));
2650 DEBUG11(printk("%s(%ld): done.\n", __func__
, vha
->host_no
));
2657 qla2x00_disable_eft_trace(scsi_qla_host_t
*vha
)
2661 mbx_cmd_t
*mcp
= &mc
;
2663 if (!IS_FWI2_CAPABLE(vha
->hw
))
2664 return QLA_FUNCTION_FAILED
;
2666 if (unlikely(pci_channel_offline(vha
->hw
->pdev
)))
2667 return QLA_FUNCTION_FAILED
;
2669 DEBUG11(printk("%s(%ld): entered.\n", __func__
, vha
->host_no
));
2671 mcp
->mb
[0] = MBC_TRACE_CONTROL
;
2672 mcp
->mb
[1] = TC_EFT_DISABLE
;
2673 mcp
->out_mb
= MBX_1
|MBX_0
;
2674 mcp
->in_mb
= MBX_1
|MBX_0
;
2675 mcp
->tov
= MBX_TOV_SECONDS
;
2677 rval
= qla2x00_mailbox_command(vha
, mcp
);
2678 if (rval
!= QLA_SUCCESS
) {
2679 DEBUG2_3_11(printk("%s(%ld): failed=%x mb[0]=%x mb[1]=%x.\n",
2680 __func__
, vha
->host_no
, rval
, mcp
->mb
[0], mcp
->mb
[1]));
2682 DEBUG11(printk("%s(%ld): done.\n", __func__
, vha
->host_no
));
2689 qla2x00_enable_fce_trace(scsi_qla_host_t
*vha
, dma_addr_t fce_dma
,
2690 uint16_t buffers
, uint16_t *mb
, uint32_t *dwords
)
2694 mbx_cmd_t
*mcp
= &mc
;
2696 if (!IS_QLA25XX(vha
->hw
) && !IS_QLA81XX(vha
->hw
))
2697 return QLA_FUNCTION_FAILED
;
2699 if (unlikely(pci_channel_offline(vha
->hw
->pdev
)))
2700 return QLA_FUNCTION_FAILED
;
2702 DEBUG11(printk("%s(%ld): entered.\n", __func__
, vha
->host_no
));
2704 mcp
->mb
[0] = MBC_TRACE_CONTROL
;
2705 mcp
->mb
[1] = TC_FCE_ENABLE
;
2706 mcp
->mb
[2] = LSW(fce_dma
);
2707 mcp
->mb
[3] = MSW(fce_dma
);
2708 mcp
->mb
[4] = LSW(MSD(fce_dma
));
2709 mcp
->mb
[5] = MSW(MSD(fce_dma
));
2710 mcp
->mb
[6] = buffers
;
2711 mcp
->mb
[7] = TC_AEN_DISABLE
;
2713 mcp
->mb
[9] = TC_FCE_DEFAULT_RX_SIZE
;
2714 mcp
->mb
[10] = TC_FCE_DEFAULT_TX_SIZE
;
2715 mcp
->out_mb
= MBX_10
|MBX_9
|MBX_8
|MBX_7
|MBX_6
|MBX_5
|MBX_4
|MBX_3
|MBX_2
|
2717 mcp
->in_mb
= MBX_6
|MBX_5
|MBX_4
|MBX_3
|MBX_2
|MBX_1
|MBX_0
;
2718 mcp
->tov
= MBX_TOV_SECONDS
;
2720 rval
= qla2x00_mailbox_command(vha
, mcp
);
2721 if (rval
!= QLA_SUCCESS
) {
2722 DEBUG2_3_11(printk("%s(%ld): failed=%x mb[0]=%x mb[1]=%x.\n",
2723 __func__
, vha
->host_no
, rval
, mcp
->mb
[0], mcp
->mb
[1]));
2725 DEBUG11(printk("%s(%ld): done.\n", __func__
, vha
->host_no
));
2728 memcpy(mb
, mcp
->mb
, 8 * sizeof(*mb
));
2737 qla2x00_disable_fce_trace(scsi_qla_host_t
*vha
, uint64_t *wr
, uint64_t *rd
)
2741 mbx_cmd_t
*mcp
= &mc
;
2743 if (!IS_FWI2_CAPABLE(vha
->hw
))
2744 return QLA_FUNCTION_FAILED
;
2746 if (unlikely(pci_channel_offline(vha
->hw
->pdev
)))
2747 return QLA_FUNCTION_FAILED
;
2749 DEBUG11(printk("%s(%ld): entered.\n", __func__
, vha
->host_no
));
2751 mcp
->mb
[0] = MBC_TRACE_CONTROL
;
2752 mcp
->mb
[1] = TC_FCE_DISABLE
;
2753 mcp
->mb
[2] = TC_FCE_DISABLE_TRACE
;
2754 mcp
->out_mb
= MBX_2
|MBX_1
|MBX_0
;
2755 mcp
->in_mb
= MBX_9
|MBX_8
|MBX_7
|MBX_6
|MBX_5
|MBX_4
|MBX_3
|MBX_2
|
2757 mcp
->tov
= MBX_TOV_SECONDS
;
2759 rval
= qla2x00_mailbox_command(vha
, mcp
);
2760 if (rval
!= QLA_SUCCESS
) {
2761 DEBUG2_3_11(printk("%s(%ld): failed=%x mb[0]=%x mb[1]=%x.\n",
2762 __func__
, vha
->host_no
, rval
, mcp
->mb
[0], mcp
->mb
[1]));
2764 DEBUG11(printk("%s(%ld): done.\n", __func__
, vha
->host_no
));
2767 *wr
= (uint64_t) mcp
->mb
[5] << 48 |
2768 (uint64_t) mcp
->mb
[4] << 32 |
2769 (uint64_t) mcp
->mb
[3] << 16 |
2770 (uint64_t) mcp
->mb
[2];
2772 *rd
= (uint64_t) mcp
->mb
[9] << 48 |
2773 (uint64_t) mcp
->mb
[8] << 32 |
2774 (uint64_t) mcp
->mb
[7] << 16 |
2775 (uint64_t) mcp
->mb
[6];
2782 qla2x00_read_sfp(scsi_qla_host_t
*vha
, dma_addr_t sfp_dma
, uint16_t addr
,
2783 uint16_t off
, uint16_t count
)
2787 mbx_cmd_t
*mcp
= &mc
;
2789 if (!IS_FWI2_CAPABLE(vha
->hw
))
2790 return QLA_FUNCTION_FAILED
;
2792 DEBUG11(printk("%s(%ld): entered.\n", __func__
, vha
->host_no
));
2794 mcp
->mb
[0] = MBC_READ_SFP
;
2796 mcp
->mb
[2] = MSW(sfp_dma
);
2797 mcp
->mb
[3] = LSW(sfp_dma
);
2798 mcp
->mb
[6] = MSW(MSD(sfp_dma
));
2799 mcp
->mb
[7] = LSW(MSD(sfp_dma
));
2803 mcp
->out_mb
= MBX_10
|MBX_9
|MBX_8
|MBX_7
|MBX_6
|MBX_3
|MBX_2
|MBX_1
|MBX_0
;
2805 mcp
->tov
= MBX_TOV_SECONDS
;
2807 rval
= qla2x00_mailbox_command(vha
, mcp
);
2809 if (rval
!= QLA_SUCCESS
) {
2810 DEBUG2_3_11(printk("%s(%ld): failed=%x (%x).\n", __func__
,
2811 vha
->host_no
, rval
, mcp
->mb
[0]));
2813 DEBUG11(printk("%s(%ld): done.\n", __func__
, vha
->host_no
));
2820 qla2x00_get_idma_speed(scsi_qla_host_t
*vha
, uint16_t loop_id
,
2821 uint16_t *port_speed
, uint16_t *mb
)
2825 mbx_cmd_t
*mcp
= &mc
;
2827 if (!IS_IIDMA_CAPABLE(vha
->hw
))
2828 return QLA_FUNCTION_FAILED
;
2830 DEBUG11(printk("%s(%ld): entered.\n", __func__
, vha
->host_no
));
2832 mcp
->mb
[0] = MBC_PORT_PARAMS
;
2833 mcp
->mb
[1] = loop_id
;
2834 mcp
->mb
[2] = mcp
->mb
[3] = 0;
2835 mcp
->mb
[9] = vha
->vp_idx
;
2836 mcp
->out_mb
= MBX_9
|MBX_3
|MBX_2
|MBX_1
|MBX_0
;
2837 mcp
->in_mb
= MBX_3
|MBX_1
|MBX_0
;
2838 mcp
->tov
= MBX_TOV_SECONDS
;
2840 rval
= qla2x00_mailbox_command(vha
, mcp
);
2842 /* Return mailbox statuses. */
2849 if (rval
!= QLA_SUCCESS
) {
2850 DEBUG2_3_11(printk("%s(%ld): failed=%x.\n", __func__
,
2851 vha
->host_no
, rval
));
2853 DEBUG11(printk("%s(%ld): done.\n", __func__
, vha
->host_no
));
2855 *port_speed
= mcp
->mb
[3];
2862 qla2x00_set_idma_speed(scsi_qla_host_t
*vha
, uint16_t loop_id
,
2863 uint16_t port_speed
, uint16_t *mb
)
2867 mbx_cmd_t
*mcp
= &mc
;
2869 if (!IS_IIDMA_CAPABLE(vha
->hw
))
2870 return QLA_FUNCTION_FAILED
;
2872 DEBUG11(printk("%s(%ld): entered.\n", __func__
, vha
->host_no
));
2874 mcp
->mb
[0] = MBC_PORT_PARAMS
;
2875 mcp
->mb
[1] = loop_id
;
2877 if (IS_QLA8XXX_TYPE(vha
->hw
))
2878 mcp
->mb
[3] = port_speed
& (BIT_5
|BIT_4
|BIT_3
|BIT_2
|BIT_1
|BIT_0
);
2880 mcp
->mb
[3] = port_speed
& (BIT_2
|BIT_1
|BIT_0
);
2881 mcp
->mb
[9] = vha
->vp_idx
;
2882 mcp
->out_mb
= MBX_9
|MBX_3
|MBX_2
|MBX_1
|MBX_0
;
2883 mcp
->in_mb
= MBX_3
|MBX_1
|MBX_0
;
2884 mcp
->tov
= MBX_TOV_SECONDS
;
2886 rval
= qla2x00_mailbox_command(vha
, mcp
);
2888 /* Return mailbox statuses. */
2895 if (rval
!= QLA_SUCCESS
) {
2896 DEBUG2_3_11(printk("%s(%ld): failed=%x.\n", __func__
,
2897 vha
->host_no
, rval
));
2899 DEBUG11(printk("%s(%ld): done.\n", __func__
, vha
->host_no
));
2906 qla24xx_report_id_acquisition(scsi_qla_host_t
*vha
,
2907 struct vp_rpt_id_entry_24xx
*rptid_entry
)
2910 uint16_t stat
= le16_to_cpu(rptid_entry
->vp_idx
);
2911 struct qla_hw_data
*ha
= vha
->hw
;
2912 scsi_qla_host_t
*vp
;
2913 unsigned long flags
;
2915 if (rptid_entry
->entry_status
!= 0)
2918 if (rptid_entry
->format
== 0) {
2919 DEBUG15(printk("%s:format 0 : scsi(%ld) number of VPs setup %d,"
2920 " number of VPs acquired %d\n", __func__
, vha
->host_no
,
2921 MSB(le16_to_cpu(rptid_entry
->vp_count
)),
2922 LSB(le16_to_cpu(rptid_entry
->vp_count
))));
2923 DEBUG15(printk("%s primary port id %02x%02x%02x\n", __func__
,
2924 rptid_entry
->port_id
[2], rptid_entry
->port_id
[1],
2925 rptid_entry
->port_id
[0]));
2926 } else if (rptid_entry
->format
== 1) {
2928 DEBUG15(printk("%s:format 1: scsi(%ld): VP[%d] enabled "
2930 "with port id %02x%02x%02x\n", __func__
, vha
->host_no
,
2932 rptid_entry
->port_id
[2], rptid_entry
->port_id
[1],
2933 rptid_entry
->port_id
[0]));
2936 if (vp_idx
== 0 && (MSB(stat
) != 1))
2939 if (MSB(stat
) == 1) {
2940 DEBUG2(printk("scsi(%ld): Could not acquire ID for "
2941 "VP[%d].\n", vha
->host_no
, vp_idx
));
2945 spin_lock_irqsave(&ha
->vport_slock
, flags
);
2946 list_for_each_entry(vp
, &ha
->vp_list
, list
)
2947 if (vp_idx
== vp
->vp_idx
)
2949 spin_unlock_irqrestore(&ha
->vport_slock
, flags
);
2954 vp
->d_id
.b
.domain
= rptid_entry
->port_id
[2];
2955 vp
->d_id
.b
.area
= rptid_entry
->port_id
[1];
2956 vp
->d_id
.b
.al_pa
= rptid_entry
->port_id
[0];
2959 * Cannot configure here as we are still sitting on the
2960 * response queue. Handle it in dpc context.
2962 set_bit(VP_IDX_ACQUIRED
, &vp
->vp_flags
);
2965 set_bit(REGISTER_FC4_NEEDED
, &vp
->dpc_flags
);
2966 set_bit(REGISTER_FDMI_NEEDED
, &vp
->dpc_flags
);
2967 set_bit(VP_DPC_NEEDED
, &vha
->dpc_flags
);
2968 qla2xxx_wake_dpc(vha
);
2973 * qla24xx_modify_vp_config
2974 * Change VP configuration for vha
2977 * vha = adapter block pointer.
2980 * qla2xxx local function return status code.
2986 qla24xx_modify_vp_config(scsi_qla_host_t
*vha
)
2989 struct vp_config_entry_24xx
*vpmod
;
2990 dma_addr_t vpmod_dma
;
2991 struct qla_hw_data
*ha
= vha
->hw
;
2992 struct scsi_qla_host
*base_vha
= pci_get_drvdata(ha
->pdev
);
2994 /* This can be called by the parent */
2996 vpmod
= dma_pool_alloc(ha
->s_dma_pool
, GFP_KERNEL
, &vpmod_dma
);
2998 DEBUG2_3(printk("%s(%ld): failed to allocate Modify VP "
2999 "IOCB.\n", __func__
, vha
->host_no
));
3000 return QLA_MEMORY_ALLOC_FAILED
;
3003 memset(vpmod
, 0, sizeof(struct vp_config_entry_24xx
));
3004 vpmod
->entry_type
= VP_CONFIG_IOCB_TYPE
;
3005 vpmod
->entry_count
= 1;
3006 vpmod
->command
= VCT_COMMAND_MOD_ENABLE_VPS
;
3007 vpmod
->vp_count
= 1;
3008 vpmod
->vp_index1
= vha
->vp_idx
;
3009 vpmod
->options_idx1
= BIT_3
|BIT_4
|BIT_5
;
3010 memcpy(vpmod
->node_name_idx1
, vha
->node_name
, WWN_SIZE
);
3011 memcpy(vpmod
->port_name_idx1
, vha
->port_name
, WWN_SIZE
);
3012 vpmod
->entry_count
= 1;
3014 rval
= qla2x00_issue_iocb(base_vha
, vpmod
, vpmod_dma
, 0);
3015 if (rval
!= QLA_SUCCESS
) {
3016 DEBUG2_3_11(printk("%s(%ld): failed to issue VP config IOCB"
3017 "(%x).\n", __func__
, base_vha
->host_no
, rval
));
3018 } else if (vpmod
->comp_status
!= 0) {
3019 DEBUG2_3_11(printk("%s(%ld): failed to complete IOCB "
3020 "-- error status (%x).\n", __func__
, base_vha
->host_no
,
3021 vpmod
->comp_status
));
3022 rval
= QLA_FUNCTION_FAILED
;
3023 } else if (vpmod
->comp_status
!= __constant_cpu_to_le16(CS_COMPLETE
)) {
3024 DEBUG2_3_11(printk("%s(%ld): failed to complete IOCB "
3025 "-- completion status (%x).\n", __func__
, base_vha
->host_no
,
3026 le16_to_cpu(vpmod
->comp_status
)));
3027 rval
= QLA_FUNCTION_FAILED
;
3030 DEBUG11(printk("%s(%ld): done.\n", __func__
,
3031 base_vha
->host_no
));
3032 fc_vport_set_state(vha
->fc_vport
, FC_VPORT_INITIALIZING
);
3034 dma_pool_free(ha
->s_dma_pool
, vpmod
, vpmod_dma
);
3040 * qla24xx_control_vp
3041 * Enable a virtual port for given host
3044 * ha = adapter block pointer.
3045 * vhba = virtual adapter (unused)
3046 * index = index number for enabled VP
3049 * qla2xxx local function return status code.
3055 qla24xx_control_vp(scsi_qla_host_t
*vha
, int cmd
)
3059 struct vp_ctrl_entry_24xx
*vce
;
3061 struct qla_hw_data
*ha
= vha
->hw
;
3062 int vp_index
= vha
->vp_idx
;
3063 struct scsi_qla_host
*base_vha
= pci_get_drvdata(ha
->pdev
);
3065 DEBUG11(printk("%s(%ld): entered. Enabling index %d\n", __func__
,
3066 vha
->host_no
, vp_index
));
3068 if (vp_index
== 0 || vp_index
>= ha
->max_npiv_vports
)
3069 return QLA_PARAMETER_ERROR
;
3071 vce
= dma_pool_alloc(ha
->s_dma_pool
, GFP_KERNEL
, &vce_dma
);
3073 DEBUG2_3(printk("%s(%ld): "
3074 "failed to allocate VP Control IOCB.\n", __func__
,
3075 base_vha
->host_no
));
3076 return QLA_MEMORY_ALLOC_FAILED
;
3078 memset(vce
, 0, sizeof(struct vp_ctrl_entry_24xx
));
3080 vce
->entry_type
= VP_CTRL_IOCB_TYPE
;
3081 vce
->entry_count
= 1;
3082 vce
->command
= cpu_to_le16(cmd
);
3083 vce
->vp_count
= __constant_cpu_to_le16(1);
3085 /* index map in firmware starts with 1; decrement index
3086 * this is ok as we never use index 0
3088 map
= (vp_index
- 1) / 8;
3089 pos
= (vp_index
- 1) & 7;
3090 mutex_lock(&ha
->vport_lock
);
3091 vce
->vp_idx_map
[map
] |= 1 << pos
;
3092 mutex_unlock(&ha
->vport_lock
);
3094 rval
= qla2x00_issue_iocb(base_vha
, vce
, vce_dma
, 0);
3095 if (rval
!= QLA_SUCCESS
) {
3096 DEBUG2_3_11(printk("%s(%ld): failed to issue VP control IOCB"
3097 "(%x).\n", __func__
, base_vha
->host_no
, rval
));
3098 printk("%s(%ld): failed to issue VP control IOCB"
3099 "(%x).\n", __func__
, base_vha
->host_no
, rval
);
3100 } else if (vce
->entry_status
!= 0) {
3101 DEBUG2_3_11(printk("%s(%ld): failed to complete IOCB "
3102 "-- error status (%x).\n", __func__
, base_vha
->host_no
,
3103 vce
->entry_status
));
3104 printk("%s(%ld): failed to complete IOCB "
3105 "-- error status (%x).\n", __func__
, base_vha
->host_no
,
3107 rval
= QLA_FUNCTION_FAILED
;
3108 } else if (vce
->comp_status
!= __constant_cpu_to_le16(CS_COMPLETE
)) {
3109 DEBUG2_3_11(printk("%s(%ld): failed to complete IOCB "
3110 "-- completion status (%x).\n", __func__
, base_vha
->host_no
,
3111 le16_to_cpu(vce
->comp_status
)));
3112 printk("%s(%ld): failed to complete IOCB "
3113 "-- completion status (%x).\n", __func__
, base_vha
->host_no
,
3114 le16_to_cpu(vce
->comp_status
));
3115 rval
= QLA_FUNCTION_FAILED
;
3117 DEBUG2(printk("%s(%ld): done.\n", __func__
, base_vha
->host_no
));
3120 dma_pool_free(ha
->s_dma_pool
, vce
, vce_dma
);
3126 * qla2x00_send_change_request
3127 * Receive or disable RSCN request from fabric controller
3130 * ha = adapter block pointer
3131 * format = registration format:
3133 * 1 - Fabric detected registration
3134 * 2 - N_port detected registration
3135 * 3 - Full registration
3136 * FF - clear registration
3137 * vp_idx = Virtual port index
3140 * qla2x00 local function return status code.
3147 qla2x00_send_change_request(scsi_qla_host_t
*vha
, uint16_t format
,
3152 mbx_cmd_t
*mcp
= &mc
;
3155 * This command is implicitly executed by firmware during login for the
3159 return QLA_FUNCTION_FAILED
;
3161 mcp
->mb
[0] = MBC_SEND_CHANGE_REQUEST
;
3162 mcp
->mb
[1] = format
;
3163 mcp
->mb
[9] = vp_idx
;
3164 mcp
->out_mb
= MBX_9
|MBX_1
|MBX_0
;
3165 mcp
->in_mb
= MBX_0
|MBX_1
;
3166 mcp
->tov
= MBX_TOV_SECONDS
;
3168 rval
= qla2x00_mailbox_command(vha
, mcp
);
3170 if (rval
== QLA_SUCCESS
) {
3171 if (mcp
->mb
[0] != MBS_COMMAND_COMPLETE
) {
3181 qla2x00_dump_ram(scsi_qla_host_t
*vha
, dma_addr_t req_dma
, uint32_t addr
,
3186 mbx_cmd_t
*mcp
= &mc
;
3188 DEBUG11(printk("%s(%ld): entered.\n", __func__
, vha
->host_no
));
3190 if (MSW(addr
) || IS_FWI2_CAPABLE(vha
->hw
)) {
3191 mcp
->mb
[0] = MBC_DUMP_RISC_RAM_EXTENDED
;
3192 mcp
->mb
[8] = MSW(addr
);
3193 mcp
->out_mb
= MBX_8
|MBX_0
;
3195 mcp
->mb
[0] = MBC_DUMP_RISC_RAM
;
3196 mcp
->out_mb
= MBX_0
;
3198 mcp
->mb
[1] = LSW(addr
);
3199 mcp
->mb
[2] = MSW(req_dma
);
3200 mcp
->mb
[3] = LSW(req_dma
);
3201 mcp
->mb
[6] = MSW(MSD(req_dma
));
3202 mcp
->mb
[7] = LSW(MSD(req_dma
));
3203 mcp
->out_mb
|= MBX_7
|MBX_6
|MBX_3
|MBX_2
|MBX_1
;
3204 if (IS_FWI2_CAPABLE(vha
->hw
)) {
3205 mcp
->mb
[4] = MSW(size
);
3206 mcp
->mb
[5] = LSW(size
);
3207 mcp
->out_mb
|= MBX_5
|MBX_4
;
3209 mcp
->mb
[4] = LSW(size
);
3210 mcp
->out_mb
|= MBX_4
;
3214 mcp
->tov
= MBX_TOV_SECONDS
;
3216 rval
= qla2x00_mailbox_command(vha
, mcp
);
3218 if (rval
!= QLA_SUCCESS
) {
3219 DEBUG2_3_11(printk("%s(%ld): failed=%x mb[0]=%x.\n", __func__
,
3220 vha
->host_no
, rval
, mcp
->mb
[0]));
3222 DEBUG11(printk("%s(%ld): done.\n", __func__
, vha
->host_no
));
3228 /* 84XX Support **************************************************************/
3230 struct cs84xx_mgmt_cmd
{
3232 struct verify_chip_entry_84xx req
;
3233 struct verify_chip_rsp_84xx rsp
;
3238 qla84xx_verify_chip(struct scsi_qla_host
*vha
, uint16_t *status
)
3241 struct cs84xx_mgmt_cmd
*mn
;
3244 unsigned long flags
;
3245 struct qla_hw_data
*ha
= vha
->hw
;
3247 DEBUG16(printk("%s(%ld): entered.\n", __func__
, vha
->host_no
));
3249 mn
= dma_pool_alloc(ha
->s_dma_pool
, GFP_KERNEL
, &mn_dma
);
3251 DEBUG2_3(printk("%s(%ld): failed to allocate Verify ISP84XX "
3252 "IOCB.\n", __func__
, vha
->host_no
));
3253 return QLA_MEMORY_ALLOC_FAILED
;
3257 options
= ha
->cs84xx
->fw_update
? VCO_FORCE_UPDATE
: 0;
3258 /* Diagnostic firmware? */
3259 /* options |= MENLO_DIAG_FW; */
3260 /* We update the firmware with only one data sequence. */
3261 options
|= VCO_END_OF_DATA
;
3265 memset(mn
, 0, sizeof(*mn
));
3266 mn
->p
.req
.entry_type
= VERIFY_CHIP_IOCB_TYPE
;
3267 mn
->p
.req
.entry_count
= 1;
3268 mn
->p
.req
.options
= cpu_to_le16(options
);
3270 DEBUG16(printk("%s(%ld): Dump of Verify Request.\n", __func__
,
3272 DEBUG16(qla2x00_dump_buffer((uint8_t *)mn
,
3275 rval
= qla2x00_issue_iocb_timeout(vha
, mn
, mn_dma
, 0, 120);
3276 if (rval
!= QLA_SUCCESS
) {
3277 DEBUG2_16(printk("%s(%ld): failed to issue Verify "
3278 "IOCB (%x).\n", __func__
, vha
->host_no
, rval
));
3282 DEBUG16(printk("%s(%ld): Dump of Verify Response.\n", __func__
,
3284 DEBUG16(qla2x00_dump_buffer((uint8_t *)mn
,
3287 status
[0] = le16_to_cpu(mn
->p
.rsp
.comp_status
);
3288 status
[1] = status
[0] == CS_VCS_CHIP_FAILURE
?
3289 le16_to_cpu(mn
->p
.rsp
.failure_code
) : 0;
3290 DEBUG2_16(printk("%s(%ld): cs=%x fc=%x\n", __func__
,
3291 vha
->host_no
, status
[0], status
[1]));
3293 if (status
[0] != CS_COMPLETE
) {
3294 rval
= QLA_FUNCTION_FAILED
;
3295 if (!(options
& VCO_DONT_UPDATE_FW
)) {
3296 DEBUG2_16(printk("%s(%ld): Firmware update "
3297 "failed. Retrying without update "
3298 "firmware.\n", __func__
, vha
->host_no
));
3299 options
|= VCO_DONT_UPDATE_FW
;
3300 options
&= ~VCO_FORCE_UPDATE
;
3304 DEBUG2_16(printk("%s(%ld): firmware updated to %x.\n",
3305 __func__
, vha
->host_no
,
3306 le32_to_cpu(mn
->p
.rsp
.fw_ver
)));
3308 /* NOTE: we only update OP firmware. */
3309 spin_lock_irqsave(&ha
->cs84xx
->access_lock
, flags
);
3310 ha
->cs84xx
->op_fw_version
=
3311 le32_to_cpu(mn
->p
.rsp
.fw_ver
);
3312 spin_unlock_irqrestore(&ha
->cs84xx
->access_lock
,
3318 dma_pool_free(ha
->s_dma_pool
, mn
, mn_dma
);
3320 if (rval
!= QLA_SUCCESS
) {
3321 DEBUG2_16(printk("%s(%ld): failed=%x.\n", __func__
,
3322 vha
->host_no
, rval
));
3324 DEBUG16(printk("%s(%ld): done.\n", __func__
, vha
->host_no
));
3331 qla25xx_init_req_que(struct scsi_qla_host
*vha
, struct req_que
*req
)
3334 unsigned long flags
;
3336 mbx_cmd_t
*mcp
= &mc
;
3337 struct device_reg_25xxmq __iomem
*reg
;
3338 struct qla_hw_data
*ha
= vha
->hw
;
3340 mcp
->mb
[0] = MBC_INITIALIZE_MULTIQ
;
3341 mcp
->mb
[1] = req
->options
;
3342 mcp
->mb
[2] = MSW(LSD(req
->dma
));
3343 mcp
->mb
[3] = LSW(LSD(req
->dma
));
3344 mcp
->mb
[6] = MSW(MSD(req
->dma
));
3345 mcp
->mb
[7] = LSW(MSD(req
->dma
));
3346 mcp
->mb
[5] = req
->length
;
3348 mcp
->mb
[10] = req
->rsp
->id
;
3349 mcp
->mb
[12] = req
->qos
;
3350 mcp
->mb
[11] = req
->vp_idx
;
3351 mcp
->mb
[13] = req
->rid
;
3353 reg
= (struct device_reg_25xxmq
*)((void *)(ha
->mqiobase
) +
3354 QLA_QUE_PAGE
* req
->id
);
3356 mcp
->mb
[4] = req
->id
;
3357 /* que in ptr index */
3359 /* que out ptr index */
3361 mcp
->out_mb
= MBX_14
|MBX_13
|MBX_12
|MBX_11
|MBX_10
|MBX_9
|MBX_8
|MBX_7
|
3362 MBX_6
|MBX_5
|MBX_4
|MBX_3
|MBX_2
|MBX_1
|MBX_0
;
3364 mcp
->flags
= MBX_DMA_OUT
;
3367 spin_lock_irqsave(&ha
->hardware_lock
, flags
);
3368 if (!(req
->options
& BIT_0
)) {
3369 WRT_REG_DWORD(®
->req_q_in
, 0);
3370 WRT_REG_DWORD(®
->req_q_out
, 0);
3372 req
->req_q_in
= ®
->req_q_in
;
3373 req
->req_q_out
= ®
->req_q_out
;
3374 spin_unlock_irqrestore(&ha
->hardware_lock
, flags
);
3376 rval
= qla2x00_mailbox_command(vha
, mcp
);
3377 if (rval
!= QLA_SUCCESS
)
3378 DEBUG2_3_11(printk(KERN_WARNING
"%s(%ld): failed=%x mb0=%x.\n",
3379 __func__
, vha
->host_no
, rval
, mcp
->mb
[0]));
3384 qla25xx_init_rsp_que(struct scsi_qla_host
*vha
, struct rsp_que
*rsp
)
3387 unsigned long flags
;
3389 mbx_cmd_t
*mcp
= &mc
;
3390 struct device_reg_25xxmq __iomem
*reg
;
3391 struct qla_hw_data
*ha
= vha
->hw
;
3393 mcp
->mb
[0] = MBC_INITIALIZE_MULTIQ
;
3394 mcp
->mb
[1] = rsp
->options
;
3395 mcp
->mb
[2] = MSW(LSD(rsp
->dma
));
3396 mcp
->mb
[3] = LSW(LSD(rsp
->dma
));
3397 mcp
->mb
[6] = MSW(MSD(rsp
->dma
));
3398 mcp
->mb
[7] = LSW(MSD(rsp
->dma
));
3399 mcp
->mb
[5] = rsp
->length
;
3400 mcp
->mb
[14] = rsp
->msix
->entry
;
3401 mcp
->mb
[13] = rsp
->rid
;
3403 reg
= (struct device_reg_25xxmq
*)((void *)(ha
->mqiobase
) +
3404 QLA_QUE_PAGE
* rsp
->id
);
3406 mcp
->mb
[4] = rsp
->id
;
3407 /* que in ptr index */
3409 /* que out ptr index */
3411 mcp
->out_mb
= MBX_14
|MBX_13
|MBX_9
|MBX_8
|MBX_7
3412 |MBX_6
|MBX_5
|MBX_4
|MBX_3
|MBX_2
|MBX_1
|MBX_0
;
3414 mcp
->flags
= MBX_DMA_OUT
;
3417 spin_lock_irqsave(&ha
->hardware_lock
, flags
);
3418 if (!(rsp
->options
& BIT_0
)) {
3419 WRT_REG_DWORD(®
->rsp_q_out
, 0);
3420 WRT_REG_DWORD(®
->rsp_q_in
, 0);
3423 spin_unlock_irqrestore(&ha
->hardware_lock
, flags
);
3425 rval
= qla2x00_mailbox_command(vha
, mcp
);
3426 if (rval
!= QLA_SUCCESS
)
3427 DEBUG2_3_11(printk(KERN_WARNING
"%s(%ld): failed=%x "
3428 "mb0=%x.\n", __func__
,
3429 vha
->host_no
, rval
, mcp
->mb
[0]));
3434 qla81xx_idc_ack(scsi_qla_host_t
*vha
, uint16_t *mb
)
3438 mbx_cmd_t
*mcp
= &mc
;
3440 DEBUG11(printk("%s(%ld): entered.\n", __func__
, vha
->host_no
));
3442 mcp
->mb
[0] = MBC_IDC_ACK
;
3443 memcpy(&mcp
->mb
[1], mb
, QLA_IDC_ACK_REGS
* sizeof(uint16_t));
3444 mcp
->out_mb
= MBX_7
|MBX_6
|MBX_5
|MBX_4
|MBX_3
|MBX_2
|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 (%x).\n", __func__
,
3452 vha
->host_no
, rval
, mcp
->mb
[0]));
3454 DEBUG11(printk("%s(%ld): done.\n", __func__
, vha
->host_no
));
3461 qla81xx_fac_get_sector_size(scsi_qla_host_t
*vha
, uint32_t *sector_size
)
3465 mbx_cmd_t
*mcp
= &mc
;
3467 if (!IS_QLA81XX(vha
->hw
))
3468 return QLA_FUNCTION_FAILED
;
3470 DEBUG11(printk("%s(%ld): entered.\n", __func__
, vha
->host_no
));
3472 mcp
->mb
[0] = MBC_FLASH_ACCESS_CTRL
;
3473 mcp
->mb
[1] = FAC_OPT_CMD_GET_SECTOR_SIZE
;
3474 mcp
->out_mb
= MBX_1
|MBX_0
;
3475 mcp
->in_mb
= MBX_1
|MBX_0
;
3476 mcp
->tov
= MBX_TOV_SECONDS
;
3478 rval
= qla2x00_mailbox_command(vha
, mcp
);
3480 if (rval
!= QLA_SUCCESS
) {
3481 DEBUG2_3_11(printk("%s(%ld): failed=%x mb[0]=%x mb[1]=%x.\n",
3482 __func__
, vha
->host_no
, rval
, mcp
->mb
[0], mcp
->mb
[1]));
3484 DEBUG11(printk("%s(%ld): done.\n", __func__
, vha
->host_no
));
3485 *sector_size
= mcp
->mb
[1];
3492 qla81xx_fac_do_write_enable(scsi_qla_host_t
*vha
, int enable
)
3496 mbx_cmd_t
*mcp
= &mc
;
3498 if (!IS_QLA81XX(vha
->hw
))
3499 return QLA_FUNCTION_FAILED
;
3501 DEBUG11(printk("%s(%ld): entered.\n", __func__
, vha
->host_no
));
3503 mcp
->mb
[0] = MBC_FLASH_ACCESS_CTRL
;
3504 mcp
->mb
[1] = enable
? FAC_OPT_CMD_WRITE_ENABLE
:
3505 FAC_OPT_CMD_WRITE_PROTECT
;
3506 mcp
->out_mb
= MBX_1
|MBX_0
;
3507 mcp
->in_mb
= MBX_1
|MBX_0
;
3508 mcp
->tov
= MBX_TOV_SECONDS
;
3510 rval
= qla2x00_mailbox_command(vha
, mcp
);
3512 if (rval
!= QLA_SUCCESS
) {
3513 DEBUG2_3_11(printk("%s(%ld): failed=%x mb[0]=%x mb[1]=%x.\n",
3514 __func__
, vha
->host_no
, rval
, mcp
->mb
[0], mcp
->mb
[1]));
3516 DEBUG11(printk("%s(%ld): done.\n", __func__
, vha
->host_no
));
3523 qla81xx_fac_erase_sector(scsi_qla_host_t
*vha
, uint32_t start
, uint32_t finish
)
3527 mbx_cmd_t
*mcp
= &mc
;
3529 if (!IS_QLA81XX(vha
->hw
))
3530 return QLA_FUNCTION_FAILED
;
3532 DEBUG11(printk("%s(%ld): entered.\n", __func__
, vha
->host_no
));
3534 mcp
->mb
[0] = MBC_FLASH_ACCESS_CTRL
;
3535 mcp
->mb
[1] = FAC_OPT_CMD_ERASE_SECTOR
;
3536 mcp
->mb
[2] = LSW(start
);
3537 mcp
->mb
[3] = MSW(start
);
3538 mcp
->mb
[4] = LSW(finish
);
3539 mcp
->mb
[5] = MSW(finish
);
3540 mcp
->out_mb
= MBX_5
|MBX_4
|MBX_3
|MBX_2
|MBX_1
|MBX_0
;
3541 mcp
->in_mb
= MBX_2
|MBX_1
|MBX_0
;
3542 mcp
->tov
= MBX_TOV_SECONDS
;
3544 rval
= qla2x00_mailbox_command(vha
, mcp
);
3546 if (rval
!= QLA_SUCCESS
) {
3547 DEBUG2_3_11(printk("%s(%ld): failed=%x mb[0]=%x mb[1]=%x "
3548 "mb[2]=%x.\n", __func__
, vha
->host_no
, rval
, mcp
->mb
[0],
3549 mcp
->mb
[1], mcp
->mb
[2]));
3551 DEBUG11(printk("%s(%ld): done.\n", __func__
, vha
->host_no
));
3558 qla81xx_restart_mpi_firmware(scsi_qla_host_t
*vha
)
3562 mbx_cmd_t
*mcp
= &mc
;
3564 DEBUG11(printk("%s(%ld): entered.\n", __func__
, vha
->host_no
));
3566 mcp
->mb
[0] = MBC_RESTART_MPI_FW
;
3567 mcp
->out_mb
= MBX_0
;
3568 mcp
->in_mb
= MBX_0
|MBX_1
;
3569 mcp
->tov
= MBX_TOV_SECONDS
;
3571 rval
= qla2x00_mailbox_command(vha
, mcp
);
3573 if (rval
!= QLA_SUCCESS
) {
3574 DEBUG2_3_11(printk("%s(%ld): failed=%x mb[0]=0x%x mb[1]=0x%x.\n",
3575 __func__
, vha
->host_no
, rval
, mcp
->mb
[0], mcp
->mb
[1]));
3577 DEBUG11(printk("%s(%ld): done.\n", __func__
, vha
->host_no
));
3584 qla2x00_read_edc(scsi_qla_host_t
*vha
, uint16_t dev
, uint16_t adr
,
3585 dma_addr_t sfp_dma
, uint8_t *sfp
, uint16_t len
, uint16_t opt
)
3589 mbx_cmd_t
*mcp
= &mc
;
3591 DEBUG11(printk("%s(%ld): entered.\n", __func__
, vha
->host_no
));
3593 mcp
->mb
[0] = MBC_READ_SFP
;
3595 mcp
->mb
[2] = MSW(sfp_dma
);
3596 mcp
->mb
[3] = LSW(sfp_dma
);
3597 mcp
->mb
[6] = MSW(MSD(sfp_dma
));
3598 mcp
->mb
[7] = LSW(MSD(sfp_dma
));
3602 mcp
->out_mb
= MBX_10
|MBX_9
|MBX_8
|MBX_7
|MBX_6
|MBX_3
|MBX_2
|MBX_1
|MBX_0
;
3604 mcp
->tov
= MBX_TOV_SECONDS
;
3606 rval
= qla2x00_mailbox_command(vha
, mcp
);
3612 if (rval
!= QLA_SUCCESS
) {
3613 DEBUG2_3_11(printk("%s(%ld): failed=%x (%x).\n", __func__
,
3614 vha
->host_no
, rval
, mcp
->mb
[0]));
3616 DEBUG11(printk("%s(%ld): done.\n", __func__
, vha
->host_no
));
3623 qla2x00_write_edc(scsi_qla_host_t
*vha
, uint16_t dev
, uint16_t adr
,
3624 dma_addr_t sfp_dma
, uint8_t *sfp
, uint16_t len
, uint16_t opt
)
3628 mbx_cmd_t
*mcp
= &mc
;
3630 DEBUG11(printk("%s(%ld): entered.\n", __func__
, vha
->host_no
));
3636 mcp
->mb
[0] = MBC_WRITE_SFP
;
3638 mcp
->mb
[2] = MSW(sfp_dma
);
3639 mcp
->mb
[3] = LSW(sfp_dma
);
3640 mcp
->mb
[6] = MSW(MSD(sfp_dma
));
3641 mcp
->mb
[7] = LSW(MSD(sfp_dma
));
3645 mcp
->out_mb
= MBX_10
|MBX_9
|MBX_8
|MBX_7
|MBX_6
|MBX_3
|MBX_2
|MBX_1
|MBX_0
;
3647 mcp
->tov
= MBX_TOV_SECONDS
;
3649 rval
= qla2x00_mailbox_command(vha
, mcp
);
3651 if (rval
!= QLA_SUCCESS
) {
3652 DEBUG2_3_11(printk("%s(%ld): failed=%x (%x).\n", __func__
,
3653 vha
->host_no
, rval
, mcp
->mb
[0]));
3655 DEBUG11(printk("%s(%ld): done.\n", __func__
, vha
->host_no
));
3662 qla2x00_get_xgmac_stats(scsi_qla_host_t
*vha
, dma_addr_t stats_dma
,
3663 uint16_t size_in_bytes
, uint16_t *actual_size
)
3667 mbx_cmd_t
*mcp
= &mc
;
3669 if (!IS_QLA8XXX_TYPE(vha
->hw
))
3670 return QLA_FUNCTION_FAILED
;
3672 DEBUG11(printk("%s(%ld): entered.\n", __func__
, vha
->host_no
));
3674 mcp
->mb
[0] = MBC_GET_XGMAC_STATS
;
3675 mcp
->mb
[2] = MSW(stats_dma
);
3676 mcp
->mb
[3] = LSW(stats_dma
);
3677 mcp
->mb
[6] = MSW(MSD(stats_dma
));
3678 mcp
->mb
[7] = LSW(MSD(stats_dma
));
3679 mcp
->mb
[8] = size_in_bytes
>> 2;
3680 mcp
->out_mb
= MBX_8
|MBX_7
|MBX_6
|MBX_3
|MBX_2
|MBX_0
;
3681 mcp
->in_mb
= MBX_2
|MBX_1
|MBX_0
;
3682 mcp
->tov
= MBX_TOV_SECONDS
;
3684 rval
= qla2x00_mailbox_command(vha
, mcp
);
3686 if (rval
!= QLA_SUCCESS
) {
3687 DEBUG2_3_11(printk("%s(%ld): failed=%x mb[0]=0x%x "
3688 "mb[1]=0x%x mb[2]=0x%x.\n", __func__
, vha
->host_no
, rval
,
3689 mcp
->mb
[0], mcp
->mb
[1], mcp
->mb
[2]));
3691 DEBUG11(printk("%s(%ld): done.\n", __func__
, vha
->host_no
));
3693 *actual_size
= mcp
->mb
[2] << 2;
3700 qla2x00_get_dcbx_params(scsi_qla_host_t
*vha
, dma_addr_t tlv_dma
,
3705 mbx_cmd_t
*mcp
= &mc
;
3707 if (!IS_QLA8XXX_TYPE(vha
->hw
))
3708 return QLA_FUNCTION_FAILED
;
3710 DEBUG11(printk("%s(%ld): entered.\n", __func__
, vha
->host_no
));
3712 mcp
->mb
[0] = MBC_GET_DCBX_PARAMS
;
3714 mcp
->mb
[2] = MSW(tlv_dma
);
3715 mcp
->mb
[3] = LSW(tlv_dma
);
3716 mcp
->mb
[6] = MSW(MSD(tlv_dma
));
3717 mcp
->mb
[7] = LSW(MSD(tlv_dma
));
3719 mcp
->out_mb
= MBX_8
|MBX_7
|MBX_6
|MBX_3
|MBX_2
|MBX_1
|MBX_0
;
3720 mcp
->in_mb
= MBX_2
|MBX_1
|MBX_0
;
3721 mcp
->tov
= MBX_TOV_SECONDS
;
3723 rval
= qla2x00_mailbox_command(vha
, mcp
);
3725 if (rval
!= QLA_SUCCESS
) {
3726 DEBUG2_3_11(printk("%s(%ld): failed=%x mb[0]=0x%x "
3727 "mb[1]=0x%x mb[2]=0x%x.\n", __func__
, vha
->host_no
, rval
,
3728 mcp
->mb
[0], mcp
->mb
[1], mcp
->mb
[2]));
3730 DEBUG11(printk("%s(%ld): done.\n", __func__
, vha
->host_no
));
3737 qla2x00_read_ram_word(scsi_qla_host_t
*vha
, uint32_t risc_addr
, uint32_t *data
)
3741 mbx_cmd_t
*mcp
= &mc
;
3743 if (!IS_FWI2_CAPABLE(vha
->hw
))
3744 return QLA_FUNCTION_FAILED
;
3746 DEBUG11(printk("%s(%ld): entered.\n", __func__
, vha
->host_no
));
3748 mcp
->mb
[0] = MBC_READ_RAM_EXTENDED
;
3749 mcp
->mb
[1] = LSW(risc_addr
);
3750 mcp
->mb
[8] = MSW(risc_addr
);
3751 mcp
->out_mb
= MBX_8
|MBX_1
|MBX_0
;
3752 mcp
->in_mb
= MBX_3
|MBX_2
|MBX_0
;
3755 rval
= qla2x00_mailbox_command(vha
, mcp
);
3756 if (rval
!= QLA_SUCCESS
) {
3757 DEBUG2_3_11(printk("%s(%ld): failed=%x mb[0]=%x.\n", __func__
,
3758 vha
->host_no
, rval
, mcp
->mb
[0]));
3760 DEBUG11(printk("%s(%ld): done.\n", __func__
, vha
->host_no
));
3761 *data
= mcp
->mb
[3] << 16 | mcp
->mb
[2];
3768 qla2x00_loopback_test(scsi_qla_host_t
*vha
, struct msg_echo_lb
*mreq
,
3773 mbx_cmd_t
*mcp
= &mc
;
3774 uint32_t iter_cnt
= 0x1;
3776 DEBUG11(printk("scsi(%ld): entered.\n", vha
->host_no
));
3778 memset(mcp
->mb
, 0 , sizeof(mcp
->mb
));
3779 mcp
->mb
[0] = MBC_DIAGNOSTIC_LOOP_BACK
;
3780 mcp
->mb
[1] = mreq
->options
| BIT_6
; // BIT_6 specifies 64 bit addressing
3782 /* transfer count */
3783 mcp
->mb
[10] = LSW(mreq
->transfer_size
);
3784 mcp
->mb
[11] = MSW(mreq
->transfer_size
);
3786 /* send data address */
3787 mcp
->mb
[14] = LSW(mreq
->send_dma
);
3788 mcp
->mb
[15] = MSW(mreq
->send_dma
);
3789 mcp
->mb
[20] = LSW(MSD(mreq
->send_dma
));
3790 mcp
->mb
[21] = MSW(MSD(mreq
->send_dma
));
3792 /* receive data address */
3793 mcp
->mb
[16] = LSW(mreq
->rcv_dma
);
3794 mcp
->mb
[17] = MSW(mreq
->rcv_dma
);
3795 mcp
->mb
[6] = LSW(MSD(mreq
->rcv_dma
));
3796 mcp
->mb
[7] = MSW(MSD(mreq
->rcv_dma
));
3798 /* Iteration count */
3799 mcp
->mb
[18] = LSW(iter_cnt
);
3800 mcp
->mb
[19] = MSW(iter_cnt
);
3802 mcp
->out_mb
= MBX_21
|MBX_20
|MBX_19
|MBX_18
|MBX_17
|MBX_16
|MBX_15
|
3803 MBX_14
|MBX_13
|MBX_12
|MBX_11
|MBX_10
|MBX_7
|MBX_6
|MBX_1
|MBX_0
;
3804 if (IS_QLA8XXX_TYPE(vha
->hw
))
3805 mcp
->out_mb
|= MBX_2
;
3806 mcp
->in_mb
= MBX_19
|MBX_18
|MBX_3
|MBX_2
|MBX_1
|MBX_0
;
3808 mcp
->buf_size
= mreq
->transfer_size
;
3809 mcp
->tov
= MBX_TOV_SECONDS
;
3810 mcp
->flags
= MBX_DMA_OUT
|MBX_DMA_IN
|IOCTL_CMD
;
3812 rval
= qla2x00_mailbox_command(vha
, mcp
);
3814 if (rval
!= QLA_SUCCESS
) {
3815 DEBUG2(printk(KERN_WARNING
3816 "(%ld): failed=%x mb[0]=0x%x "
3817 "mb[1]=0x%x mb[2]=0x%x mb[3]=0x%x mb[18]=0x%x "
3819 vha
->host_no
, rval
, mcp
->mb
[0], mcp
->mb
[1], mcp
->mb
[2],
3820 mcp
->mb
[3], mcp
->mb
[18], mcp
->mb
[19]));
3822 DEBUG2(printk(KERN_WARNING
3823 "scsi(%ld): done.\n", vha
->host_no
));
3826 /* Copy mailbox information */
3827 memcpy( mresp
, mcp
->mb
, 64);
3832 qla2x00_echo_test(scsi_qla_host_t
*vha
, struct msg_echo_lb
*mreq
,
3837 mbx_cmd_t
*mcp
= &mc
;
3838 struct qla_hw_data
*ha
= vha
->hw
;
3840 DEBUG11(printk("scsi(%ld): entered.\n", vha
->host_no
));
3842 memset(mcp
->mb
, 0 , sizeof(mcp
->mb
));
3843 mcp
->mb
[0] = MBC_DIAGNOSTIC_ECHO
;
3844 mcp
->mb
[1] = mreq
->options
| BIT_6
; /* BIT_6 specifies 64bit address */
3845 if (IS_QLA8XXX_TYPE(ha
)) {
3846 mcp
->mb
[1] |= BIT_15
;
3847 mcp
->mb
[2] = vha
->fcoe_fcf_idx
;
3849 mcp
->mb
[16] = LSW(mreq
->rcv_dma
);
3850 mcp
->mb
[17] = MSW(mreq
->rcv_dma
);
3851 mcp
->mb
[6] = LSW(MSD(mreq
->rcv_dma
));
3852 mcp
->mb
[7] = MSW(MSD(mreq
->rcv_dma
));
3854 mcp
->mb
[10] = LSW(mreq
->transfer_size
);
3856 mcp
->mb
[14] = LSW(mreq
->send_dma
);
3857 mcp
->mb
[15] = MSW(mreq
->send_dma
);
3858 mcp
->mb
[20] = LSW(MSD(mreq
->send_dma
));
3859 mcp
->mb
[21] = MSW(MSD(mreq
->send_dma
));
3861 mcp
->out_mb
= MBX_21
|MBX_20
|MBX_17
|MBX_16
|MBX_15
|
3862 MBX_14
|MBX_10
|MBX_7
|MBX_6
|MBX_1
|MBX_0
;
3863 if (IS_QLA8XXX_TYPE(ha
))
3864 mcp
->out_mb
|= MBX_2
;
3867 if (IS_QLA24XX_TYPE(ha
) || IS_QLA25XX(ha
) || IS_QLA8XXX_TYPE(ha
))
3868 mcp
->in_mb
|= MBX_1
;
3869 if (IS_QLA8XXX_TYPE(ha
))
3870 mcp
->in_mb
|= MBX_3
;
3872 mcp
->tov
= MBX_TOV_SECONDS
;
3873 mcp
->flags
= MBX_DMA_OUT
|MBX_DMA_IN
|IOCTL_CMD
;
3874 mcp
->buf_size
= mreq
->transfer_size
;
3876 rval
= qla2x00_mailbox_command(vha
, mcp
);
3878 if (rval
!= QLA_SUCCESS
) {
3879 DEBUG2(printk(KERN_WARNING
3880 "(%ld): failed=%x mb[0]=0x%x mb[1]=0x%x.\n",
3881 vha
->host_no
, rval
, mcp
->mb
[0], mcp
->mb
[1]));
3883 DEBUG2(printk(KERN_WARNING
3884 "scsi(%ld): done.\n", vha
->host_no
));
3887 /* Copy mailbox information */
3888 memcpy(mresp
, mcp
->mb
, 64);
3893 qla84xx_reset_chip(scsi_qla_host_t
*ha
, uint16_t enable_diagnostic
)
3897 mbx_cmd_t
*mcp
= &mc
;
3899 DEBUG16(printk("%s(%ld): enable_diag=%d entered.\n", __func__
,
3900 ha
->host_no
, enable_diagnostic
));
3902 mcp
->mb
[0] = MBC_ISP84XX_RESET
;
3903 mcp
->mb
[1] = enable_diagnostic
;
3904 mcp
->out_mb
= MBX_1
|MBX_0
;
3905 mcp
->in_mb
= MBX_1
|MBX_0
;
3906 mcp
->tov
= MBX_TOV_SECONDS
;
3907 mcp
->flags
= MBX_DMA_OUT
|MBX_DMA_IN
|IOCTL_CMD
;
3908 rval
= qla2x00_mailbox_command(ha
, mcp
);
3910 if (rval
!= QLA_SUCCESS
)
3911 DEBUG16(printk("%s(%ld): failed=%x.\n", __func__
, ha
->host_no
,
3914 DEBUG16(printk("%s(%ld): done.\n", __func__
, ha
->host_no
));
3920 qla2x00_write_ram_word(scsi_qla_host_t
*vha
, uint32_t risc_addr
, uint32_t data
)
3924 mbx_cmd_t
*mcp
= &mc
;
3926 if (!IS_FWI2_CAPABLE(vha
->hw
))
3927 return QLA_FUNCTION_FAILED
;
3929 DEBUG11(printk("%s(%ld): entered.\n", __func__
, vha
->host_no
));
3931 mcp
->mb
[0] = MBC_WRITE_RAM_WORD_EXTENDED
;
3932 mcp
->mb
[1] = LSW(risc_addr
);
3933 mcp
->mb
[2] = LSW(data
);
3934 mcp
->mb
[3] = MSW(data
);
3935 mcp
->mb
[8] = MSW(risc_addr
);
3936 mcp
->out_mb
= MBX_8
|MBX_3
|MBX_2
|MBX_1
|MBX_0
;
3940 rval
= qla2x00_mailbox_command(vha
, mcp
);
3941 if (rval
!= QLA_SUCCESS
) {
3942 DEBUG2_3_11(printk("%s(%ld): failed=%x mb[0]=%x.\n", __func__
,
3943 vha
->host_no
, rval
, mcp
->mb
[0]));
3945 DEBUG11(printk("%s(%ld): done.\n", __func__
, vha
->host_no
));
3952 qla81xx_write_mpi_register(scsi_qla_host_t
*vha
, uint16_t *mb
)
3955 uint32_t stat
, timer
;
3957 struct qla_hw_data
*ha
= vha
->hw
;
3958 struct device_reg_24xx __iomem
*reg
= &ha
->iobase
->isp24
;
3962 DEBUG11(qla_printk(KERN_INFO
, ha
,
3963 "%s(%ld): entered.\n", __func__
, vha
->host_no
));
3965 clear_bit(MBX_INTERRUPT
, &ha
->mbx_cmd_flags
);
3967 /* Write the MBC data to the registers */
3968 WRT_REG_WORD(®
->mailbox0
, MBC_WRITE_MPI_REGISTER
);
3969 WRT_REG_WORD(®
->mailbox1
, mb
[0]);
3970 WRT_REG_WORD(®
->mailbox2
, mb
[1]);
3971 WRT_REG_WORD(®
->mailbox3
, mb
[2]);
3972 WRT_REG_WORD(®
->mailbox4
, mb
[3]);
3974 WRT_REG_DWORD(®
->hccr
, HCCRX_SET_HOST_INT
);
3976 /* Poll for MBC interrupt */
3977 for (timer
= 6000000; timer
; timer
--) {
3978 /* Check for pending interrupts. */
3979 stat
= RD_REG_DWORD(®
->host_status
);
3980 if (stat
& HSRX_RISC_INT
) {
3983 if (stat
== 0x1 || stat
== 0x2 ||
3984 stat
== 0x10 || stat
== 0x11) {
3985 set_bit(MBX_INTERRUPT
,
3986 &ha
->mbx_cmd_flags
);
3987 mb0
= RD_REG_WORD(®
->mailbox0
);
3988 WRT_REG_DWORD(®
->hccr
,
3989 HCCRX_CLR_RISC_INT
);
3990 RD_REG_DWORD(®
->hccr
);
3997 if (test_and_clear_bit(MBX_INTERRUPT
, &ha
->mbx_cmd_flags
))
3998 rval
= mb0
& MBS_MASK
;
4000 rval
= QLA_FUNCTION_FAILED
;
4002 if (rval
!= QLA_SUCCESS
) {
4003 DEBUG2_3_11(printk(KERN_INFO
"%s(%ld): failed=%x mb[0]=%x.\n",
4004 __func__
, vha
->host_no
, rval
, mb
[0]));
4006 DEBUG11(printk(KERN_INFO
4007 "%s(%ld): done.\n", __func__
, vha
->host_no
));
4013 qla2x00_get_data_rate(scsi_qla_host_t
*vha
)
4017 mbx_cmd_t
*mcp
= &mc
;
4018 struct qla_hw_data
*ha
= vha
->hw
;
4020 if (!IS_FWI2_CAPABLE(ha
))
4021 return QLA_FUNCTION_FAILED
;
4023 DEBUG11(qla_printk(KERN_INFO
, ha
,
4024 "%s(%ld): entered.\n", __func__
, vha
->host_no
));
4026 mcp
->mb
[0] = MBC_DATA_RATE
;
4028 mcp
->out_mb
= MBX_1
|MBX_0
;
4029 mcp
->in_mb
= MBX_2
|MBX_1
|MBX_0
;
4030 mcp
->tov
= MBX_TOV_SECONDS
;
4032 rval
= qla2x00_mailbox_command(vha
, mcp
);
4033 if (rval
!= QLA_SUCCESS
) {
4034 DEBUG2_3_11(printk(KERN_INFO
"%s(%ld): failed=%x mb[0]=%x.\n",
4035 __func__
, vha
->host_no
, rval
, mcp
->mb
[0]));
4037 DEBUG11(printk(KERN_INFO
4038 "%s(%ld): done.\n", __func__
, vha
->host_no
));
4039 if (mcp
->mb
[1] != 0x7)
4040 ha
->link_data_rate
= mcp
->mb
[1];
4047 qla81xx_get_port_config(scsi_qla_host_t
*vha
, uint16_t *mb
)
4051 mbx_cmd_t
*mcp
= &mc
;
4052 struct qla_hw_data
*ha
= vha
->hw
;
4054 DEBUG11(printk(KERN_INFO
4055 "%s(%ld): entered.\n", __func__
, vha
->host_no
));
4057 if (!IS_QLA81XX(ha
))
4058 return QLA_FUNCTION_FAILED
;
4059 mcp
->mb
[0] = MBC_GET_PORT_CONFIG
;
4060 mcp
->out_mb
= MBX_0
;
4061 mcp
->in_mb
= MBX_4
|MBX_3
|MBX_2
|MBX_1
|MBX_0
;
4062 mcp
->tov
= MBX_TOV_SECONDS
;
4065 rval
= qla2x00_mailbox_command(vha
, mcp
);
4067 if (rval
!= QLA_SUCCESS
) {
4068 DEBUG2_3_11(printk(KERN_WARNING
4069 "%s(%ld): failed=%x (%x).\n", __func__
,
4070 vha
->host_no
, rval
, mcp
->mb
[0]));
4072 /* Copy all bits to preserve original value */
4073 memcpy(mb
, &mcp
->mb
[1], sizeof(uint16_t) * 4);
4075 DEBUG11(printk(KERN_INFO
4076 "%s(%ld): done.\n", __func__
, vha
->host_no
));
4082 qla81xx_set_port_config(scsi_qla_host_t
*vha
, uint16_t *mb
)
4086 mbx_cmd_t
*mcp
= &mc
;
4088 DEBUG11(printk(KERN_INFO
4089 "%s(%ld): entered.\n", __func__
, vha
->host_no
));
4091 mcp
->mb
[0] = MBC_SET_PORT_CONFIG
;
4092 /* Copy all bits to preserve original setting */
4093 memcpy(&mcp
->mb
[1], mb
, sizeof(uint16_t) * 4);
4094 mcp
->out_mb
= MBX_4
|MBX_3
|MBX_2
|MBX_1
|MBX_0
;
4096 mcp
->tov
= MBX_TOV_SECONDS
;
4098 rval
= qla2x00_mailbox_command(vha
, mcp
);
4100 if (rval
!= QLA_SUCCESS
) {
4101 DEBUG2_3_11(printk(KERN_WARNING
4102 "%s(%ld): failed=%x (%x).\n", __func__
,
4103 vha
->host_no
, rval
, mcp
->mb
[0]));
4105 DEBUG11(printk(KERN_INFO
4106 "%s(%ld): done.\n", __func__
, vha
->host_no
));
4113 qla24xx_set_fcp_prio(scsi_qla_host_t
*vha
, uint16_t loop_id
, uint16_t priority
,
4118 mbx_cmd_t
*mcp
= &mc
;
4119 struct qla_hw_data
*ha
= vha
->hw
;
4121 if (!IS_QLA24XX_TYPE(ha
) && !IS_QLA25XX(ha
))
4122 return QLA_FUNCTION_FAILED
;
4124 DEBUG11(printk(KERN_INFO
4125 "%s(%ld): entered.\n", __func__
, vha
->host_no
));
4127 mcp
->mb
[0] = MBC_PORT_PARAMS
;
4128 mcp
->mb
[1] = loop_id
;
4129 if (ha
->flags
.fcp_prio_enabled
)
4133 mcp
->mb
[4] = priority
& 0xf;
4134 mcp
->mb
[9] = vha
->vp_idx
;
4135 mcp
->out_mb
= MBX_9
|MBX_4
|MBX_3
|MBX_2
|MBX_1
|MBX_0
;
4136 mcp
->in_mb
= MBX_4
|MBX_3
|MBX_1
|MBX_0
;
4139 rval
= qla2x00_mailbox_command(vha
, mcp
);
4147 if (rval
!= QLA_SUCCESS
) {
4148 DEBUG2_3_11(printk(KERN_WARNING
4149 "%s(%ld): failed=%x.\n", __func__
,
4150 vha
->host_no
, rval
));
4152 DEBUG11(printk(KERN_INFO
4153 "%s(%ld): done.\n", __func__
, vha
->host_no
));
4160 qla2x00_get_thermal_temp(scsi_qla_host_t
*vha
, uint16_t *temp
, uint16_t *frac
)
4164 mbx_cmd_t
*mcp
= &mc
;
4165 struct qla_hw_data
*ha
= vha
->hw
;
4167 DEBUG11(printk(KERN_INFO
"%s(%ld): entered.\n", __func__
, ha
->host_no
));
4170 mcp
->mb
[0] = MBC_READ_SFP
;
4178 mcp
->mb
[10] = BIT_13
|BIT_0
;
4179 mcp
->out_mb
= MBX_10
|MBX_9
|MBX_8
|MBX_7
|MBX_6
|MBX_3
|MBX_2
|MBX_1
|MBX_0
;
4180 mcp
->in_mb
= MBX_1
|MBX_0
;
4181 mcp
->tov
= MBX_TOV_SECONDS
;
4183 rval
= qla2x00_mailbox_command(vha
, mcp
);
4184 if (rval
!= QLA_SUCCESS
) {
4185 DEBUG2_3_11(printk(KERN_WARNING
4186 "%s(%ld): failed=%x (%x).\n", __func__
,
4187 vha
->host_no
, rval
, mcp
->mb
[0]));
4188 ha
->flags
.thermal_supported
= 0;
4191 *temp
= mcp
->mb
[1] & 0xFF;
4194 mcp
->mb
[0] = MBC_READ_SFP
;
4202 mcp
->mb
[10] = BIT_13
|BIT_0
;
4203 mcp
->out_mb
= MBX_10
|MBX_9
|MBX_8
|MBX_7
|MBX_6
|MBX_3
|MBX_2
|MBX_1
|MBX_0
;
4204 mcp
->in_mb
= MBX_1
|MBX_0
;
4205 mcp
->tov
= MBX_TOV_SECONDS
;
4207 rval
= qla2x00_mailbox_command(vha
, mcp
);
4208 if (rval
!= QLA_SUCCESS
) {
4209 DEBUG2_3_11(printk(KERN_WARNING
4210 "%s(%ld): failed=%x (%x).\n", __func__
,
4211 vha
->host_no
, rval
, mcp
->mb
[0]));
4212 ha
->flags
.thermal_supported
= 0;
4215 *frac
= ((mcp
->mb
[1] & 0xFF) >> 6) * 25;
4217 if (rval
== QLA_SUCCESS
)
4218 DEBUG11(printk(KERN_INFO
4219 "%s(%ld): done.\n", __func__
, ha
->host_no
));
4225 qla82xx_mbx_intr_enable(scsi_qla_host_t
*vha
)
4228 struct qla_hw_data
*ha
= vha
->hw
;
4230 mbx_cmd_t
*mcp
= &mc
;
4232 if (!IS_FWI2_CAPABLE(ha
))
4233 return QLA_FUNCTION_FAILED
;
4235 DEBUG11(qla_printk(KERN_INFO
, ha
,
4236 "%s(%ld): entered.\n", __func__
, vha
->host_no
));
4238 memset(mcp
, 0, sizeof(mbx_cmd_t
));
4239 mcp
->mb
[0] = MBC_TOGGLE_INTERRUPT
;
4242 mcp
->out_mb
= MBX_1
|MBX_0
;
4247 rval
= qla2x00_mailbox_command(vha
, mcp
);
4248 if (rval
!= QLA_SUCCESS
) {
4249 DEBUG2_3_11(qla_printk(KERN_WARNING
, ha
,
4250 "%s(%ld): failed=%x mb[0]=%x.\n", __func__
,
4251 vha
->host_no
, rval
, mcp
->mb
[0]));
4253 DEBUG11(qla_printk(KERN_INFO
, ha
,
4254 "%s(%ld): done.\n", __func__
, vha
->host_no
));
4261 qla82xx_mbx_intr_disable(scsi_qla_host_t
*vha
)
4264 struct qla_hw_data
*ha
= vha
->hw
;
4266 mbx_cmd_t
*mcp
= &mc
;
4268 if (!IS_QLA82XX(ha
))
4269 return QLA_FUNCTION_FAILED
;
4271 DEBUG11(qla_printk(KERN_INFO
, ha
,
4272 "%s(%ld): entered.\n", __func__
, vha
->host_no
));
4274 memset(mcp
, 0, sizeof(mbx_cmd_t
));
4275 mcp
->mb
[0] = MBC_TOGGLE_INTERRUPT
;
4278 mcp
->out_mb
= MBX_1
|MBX_0
;
4283 rval
= qla2x00_mailbox_command(vha
, mcp
);
4284 if (rval
!= QLA_SUCCESS
) {
4285 DEBUG2_3_11(qla_printk(KERN_WARNING
, ha
,
4286 "%s(%ld): failed=%x mb[0]=%x.\n", __func__
,
4287 vha
->host_no
, rval
, mcp
->mb
[0]));
4289 DEBUG11(qla_printk(KERN_INFO
, ha
,
4290 "%s(%ld): done.\n", __func__
, vha
->host_no
));