2 * QLogic Fibre Channel HBA Driver
3 * Copyright (c) 2003-2011 QLogic Corporation
5 * See LICENSE.qla2xxx for copyright and licensing details.
8 #include "qla_target.h"
10 #include <linux/delay.h>
11 #include <linux/gfp.h>
15 * qla2x00_mailbox_command
16 * Issue mailbox command and waits for completion.
19 * ha = adapter block pointer.
20 * mcp = driver internal mbx struct pointer.
23 * mb[MAX_MAILBOX_REGISTER_COUNT] = returned mailbox data.
26 * 0 : QLA_SUCCESS = cmd performed success
27 * 1 : QLA_FUNCTION_FAILED (error encountered)
28 * 6 : QLA_FUNCTION_TIMEOUT (timeout condition encountered)
34 qla2x00_mailbox_command(scsi_qla_host_t
*vha
, mbx_cmd_t
*mcp
)
37 unsigned long flags
= 0;
38 device_reg_t __iomem
*reg
;
43 uint16_t __iomem
*optr
;
46 unsigned long wait_time
;
47 struct qla_hw_data
*ha
= vha
->hw
;
48 scsi_qla_host_t
*base_vha
= pci_get_drvdata(ha
->pdev
);
50 ql_dbg(ql_dbg_mbx
, vha
, 0x1000, "Entered %s.\n", __func__
);
52 if (ha
->pdev
->error_state
> pci_channel_io_frozen
) {
53 ql_log(ql_log_warn
, vha
, 0x1001,
54 "error_state is greater than pci_channel_io_frozen, "
56 return QLA_FUNCTION_TIMEOUT
;
59 if (vha
->device_flags
& DFLG_DEV_FAILED
) {
60 ql_log(ql_log_warn
, vha
, 0x1002,
61 "Device in failed state, exiting.\n");
62 return QLA_FUNCTION_TIMEOUT
;
66 io_lock_on
= base_vha
->flags
.init_done
;
69 abort_active
= test_bit(ABORT_ISP_ACTIVE
, &base_vha
->dpc_flags
);
72 if (ha
->flags
.pci_channel_io_perm_failure
) {
73 ql_log(ql_log_warn
, vha
, 0x1003,
74 "Perm failure on EEH timeout MBX, exiting.\n");
75 return QLA_FUNCTION_TIMEOUT
;
78 if (ha
->flags
.isp82xx_fw_hung
) {
79 /* Setting Link-Down error */
80 mcp
->mb
[0] = MBS_LINK_DOWN_ERROR
;
81 ql_log(ql_log_warn
, vha
, 0x1004,
82 "FW hung = %d.\n", ha
->flags
.isp82xx_fw_hung
);
83 return QLA_FUNCTION_TIMEOUT
;
87 * Wait for active mailbox commands to finish by waiting at most tov
88 * seconds. This is to serialize actual issuing of mailbox cmds during
91 if (!wait_for_completion_timeout(&ha
->mbx_cmd_comp
, mcp
->tov
* HZ
)) {
92 /* Timeout occurred. Return error. */
93 ql_log(ql_log_warn
, vha
, 0x1005,
94 "Cmd access timeout, cmd=0x%x, Exiting.\n",
96 return QLA_FUNCTION_TIMEOUT
;
99 ha
->flags
.mbox_busy
= 1;
100 /* Save mailbox command for debug */
103 ql_dbg(ql_dbg_mbx
, vha
, 0x1006,
104 "Prepare to issue mbox cmd=0x%x.\n", mcp
->mb
[0]);
106 spin_lock_irqsave(&ha
->hardware_lock
, flags
);
108 /* Load mailbox registers. */
110 optr
= (uint16_t __iomem
*)®
->isp82
.mailbox_in
[0];
111 else if (IS_FWI2_CAPABLE(ha
) && !IS_QLA82XX(ha
))
112 optr
= (uint16_t __iomem
*)®
->isp24
.mailbox0
;
114 optr
= (uint16_t __iomem
*)MAILBOX_REG(ha
, ®
->isp
, 0);
117 command
= mcp
->mb
[0];
118 mboxes
= mcp
->out_mb
;
120 for (cnt
= 0; cnt
< ha
->mbx_count
; cnt
++) {
121 if (IS_QLA2200(ha
) && cnt
== 8)
123 (uint16_t __iomem
*)MAILBOX_REG(ha
, ®
->isp
, 8);
125 WRT_REG_WORD(optr
, *iptr
);
132 ql_dbg(ql_dbg_mbx
+ ql_dbg_buffer
, vha
, 0x1111,
133 "Loaded MBX registers (displayed in bytes) =.\n");
134 ql_dump_buffer(ql_dbg_mbx
+ ql_dbg_buffer
, vha
, 0x1112,
135 (uint8_t *)mcp
->mb
, 16);
136 ql_dbg(ql_dbg_mbx
+ ql_dbg_buffer
, vha
, 0x1113,
138 ql_dump_buffer(ql_dbg_mbx
+ ql_dbg_buffer
, vha
, 0x1114,
139 ((uint8_t *)mcp
->mb
+ 0x10), 16);
140 ql_dbg(ql_dbg_mbx
+ ql_dbg_buffer
, vha
, 0x1115,
142 ql_dump_buffer(ql_dbg_mbx
+ ql_dbg_buffer
, vha
, 0x1116,
143 ((uint8_t *)mcp
->mb
+ 0x20), 8);
144 ql_dbg(ql_dbg_mbx
+ ql_dbg_buffer
, vha
, 0x1117,
145 "I/O Address = %p.\n", optr
);
146 ql_dump_regs(ql_dbg_mbx
+ ql_dbg_buffer
, vha
, 0x100e);
148 /* Issue set host interrupt command to send cmd out. */
149 ha
->flags
.mbox_int
= 0;
150 clear_bit(MBX_INTERRUPT
, &ha
->mbx_cmd_flags
);
152 /* Unlock mbx registers and wait for interrupt */
153 ql_dbg(ql_dbg_mbx
, vha
, 0x100f,
154 "Going to unlock irq & waiting for interrupts. "
155 "jiffies=%lx.\n", jiffies
);
157 /* Wait for mbx cmd completion until timeout */
159 if ((!abort_active
&& io_lock_on
) || IS_NOPOLLING_TYPE(ha
)) {
160 set_bit(MBX_INTR_WAIT
, &ha
->mbx_cmd_flags
);
162 if (IS_QLA82XX(ha
)) {
163 if (RD_REG_DWORD(®
->isp82
.hint
) &
164 HINT_MBX_INT_PENDING
) {
165 spin_unlock_irqrestore(&ha
->hardware_lock
,
167 ha
->flags
.mbox_busy
= 0;
168 ql_dbg(ql_dbg_mbx
, vha
, 0x1010,
169 "Pending mailbox timeout, exiting.\n");
170 rval
= QLA_FUNCTION_TIMEOUT
;
173 WRT_REG_DWORD(®
->isp82
.hint
, HINT_MBX_INT_PENDING
);
174 } else if (IS_FWI2_CAPABLE(ha
))
175 WRT_REG_DWORD(®
->isp24
.hccr
, HCCRX_SET_HOST_INT
);
177 WRT_REG_WORD(®
->isp
.hccr
, HCCR_SET_HOST_INT
);
178 spin_unlock_irqrestore(&ha
->hardware_lock
, flags
);
180 wait_for_completion_timeout(&ha
->mbx_intr_comp
, mcp
->tov
* HZ
);
182 clear_bit(MBX_INTR_WAIT
, &ha
->mbx_cmd_flags
);
185 ql_dbg(ql_dbg_mbx
, vha
, 0x1011,
186 "Cmd=%x Polling Mode.\n", command
);
188 if (IS_QLA82XX(ha
)) {
189 if (RD_REG_DWORD(®
->isp82
.hint
) &
190 HINT_MBX_INT_PENDING
) {
191 spin_unlock_irqrestore(&ha
->hardware_lock
,
193 ha
->flags
.mbox_busy
= 0;
194 ql_dbg(ql_dbg_mbx
, vha
, 0x1012,
195 "Pending mailbox timeout, exiting.\n");
196 rval
= QLA_FUNCTION_TIMEOUT
;
199 WRT_REG_DWORD(®
->isp82
.hint
, HINT_MBX_INT_PENDING
);
200 } else if (IS_FWI2_CAPABLE(ha
))
201 WRT_REG_DWORD(®
->isp24
.hccr
, HCCRX_SET_HOST_INT
);
203 WRT_REG_WORD(®
->isp
.hccr
, HCCR_SET_HOST_INT
);
204 spin_unlock_irqrestore(&ha
->hardware_lock
, flags
);
206 wait_time
= jiffies
+ mcp
->tov
* HZ
; /* wait at most tov secs */
207 while (!ha
->flags
.mbox_int
) {
208 if (time_after(jiffies
, wait_time
))
211 /* Check for pending interrupts. */
212 qla2x00_poll(ha
->rsp_q_map
[0]);
214 if (!ha
->flags
.mbox_int
&&
216 command
== MBC_LOAD_RISC_RAM_EXTENDED
))
219 ql_dbg(ql_dbg_mbx
, vha
, 0x1013,
221 (uint
)((jiffies
- (wait_time
- (mcp
->tov
* HZ
)))/HZ
));
224 /* Check whether we timed out */
225 if (ha
->flags
.mbox_int
) {
228 ql_dbg(ql_dbg_mbx
, vha
, 0x1014,
229 "Cmd=%x completed.\n", command
);
231 /* Got interrupt. Clear the flag. */
232 ha
->flags
.mbox_int
= 0;
233 clear_bit(MBX_INTERRUPT
, &ha
->mbx_cmd_flags
);
235 if (ha
->flags
.isp82xx_fw_hung
) {
236 ha
->flags
.mbox_busy
= 0;
237 /* Setting Link-Down error */
238 mcp
->mb
[0] = MBS_LINK_DOWN_ERROR
;
240 rval
= QLA_FUNCTION_FAILED
;
241 ql_log(ql_log_warn
, vha
, 0x1015,
242 "FW hung = %d.\n", ha
->flags
.isp82xx_fw_hung
);
246 if (ha
->mailbox_out
[0] != MBS_COMMAND_COMPLETE
)
247 rval
= QLA_FUNCTION_FAILED
;
249 /* Load return mailbox registers. */
251 iptr
= (uint16_t *)&ha
->mailbox_out
[0];
253 for (cnt
= 0; cnt
< ha
->mbx_count
; cnt
++) {
266 if (IS_FWI2_CAPABLE(ha
)) {
267 mb0
= RD_REG_WORD(®
->isp24
.mailbox0
);
268 ictrl
= RD_REG_DWORD(®
->isp24
.ictrl
);
270 mb0
= RD_MAILBOX_REG(ha
, ®
->isp
, 0);
271 ictrl
= RD_REG_WORD(®
->isp
.ictrl
);
273 ql_dbg(ql_dbg_mbx
+ ql_dbg_buffer
, vha
, 0x1119,
274 "MBX Command timeout for cmd %x, iocontrol=%x jiffies=%lx "
275 "mb[0]=0x%x\n", command
, ictrl
, jiffies
, mb0
);
276 ql_dump_regs(ql_dbg_mbx
+ ql_dbg_buffer
, vha
, 0x1019);
279 * Attempt to capture a firmware dump for further analysis
280 * of the current firmware state
282 ha
->isp_ops
->fw_dump(vha
, 0);
284 rval
= QLA_FUNCTION_TIMEOUT
;
287 ha
->flags
.mbox_busy
= 0;
292 if ((abort_active
|| !io_lock_on
) && !IS_NOPOLLING_TYPE(ha
)) {
293 ql_dbg(ql_dbg_mbx
, vha
, 0x101a,
294 "Checking for additional resp interrupt.\n");
296 /* polling mode for non isp_abort commands. */
297 qla2x00_poll(ha
->rsp_q_map
[0]);
300 if (rval
== QLA_FUNCTION_TIMEOUT
&&
301 mcp
->mb
[0] != MBC_GEN_SYSTEM_ERROR
) {
302 if (!io_lock_on
|| (mcp
->flags
& IOCTL_CMD
) ||
303 ha
->flags
.eeh_busy
) {
304 /* not in dpc. schedule it for dpc to take over. */
305 ql_dbg(ql_dbg_mbx
, vha
, 0x101b,
306 "Timeout, schedule isp_abort_needed.\n");
308 if (!test_bit(ISP_ABORT_NEEDED
, &vha
->dpc_flags
) &&
309 !test_bit(ABORT_ISP_ACTIVE
, &vha
->dpc_flags
) &&
310 !test_bit(ISP_ABORT_RETRY
, &vha
->dpc_flags
)) {
311 if (IS_QLA82XX(ha
)) {
312 ql_dbg(ql_dbg_mbx
, vha
, 0x112a,
313 "disabling pause transmit on port "
316 QLA82XX_CRB_NIU
+ 0x98,
317 CRB_NIU_XG_PAUSE_CTL_P0
|
318 CRB_NIU_XG_PAUSE_CTL_P1
);
320 ql_log(ql_log_info
, base_vha
, 0x101c,
321 "Mailbox cmd timeout occurred, cmd=0x%x, "
322 "mb[0]=0x%x, eeh_busy=0x%x. Scheduling ISP "
323 "abort.\n", command
, mcp
->mb
[0],
325 set_bit(ISP_ABORT_NEEDED
, &vha
->dpc_flags
);
326 qla2xxx_wake_dpc(vha
);
328 } else if (!abort_active
) {
329 /* call abort directly since we are in the DPC thread */
330 ql_dbg(ql_dbg_mbx
, vha
, 0x101d,
331 "Timeout, calling abort_isp.\n");
333 if (!test_bit(ISP_ABORT_NEEDED
, &vha
->dpc_flags
) &&
334 !test_bit(ABORT_ISP_ACTIVE
, &vha
->dpc_flags
) &&
335 !test_bit(ISP_ABORT_RETRY
, &vha
->dpc_flags
)) {
336 if (IS_QLA82XX(ha
)) {
337 ql_dbg(ql_dbg_mbx
, vha
, 0x112b,
338 "disabling pause transmit on port "
341 QLA82XX_CRB_NIU
+ 0x98,
342 CRB_NIU_XG_PAUSE_CTL_P0
|
343 CRB_NIU_XG_PAUSE_CTL_P1
);
345 ql_log(ql_log_info
, base_vha
, 0x101e,
346 "Mailbox cmd timeout occurred, cmd=0x%x, "
347 "mb[0]=0x%x. Scheduling ISP abort ",
348 command
, mcp
->mb
[0]);
349 set_bit(ABORT_ISP_ACTIVE
, &vha
->dpc_flags
);
350 clear_bit(ISP_ABORT_NEEDED
, &vha
->dpc_flags
);
351 /* Allow next mbx cmd to come in. */
352 complete(&ha
->mbx_cmd_comp
);
353 if (ha
->isp_ops
->abort_isp(vha
)) {
354 /* Failed. retry later. */
355 set_bit(ISP_ABORT_NEEDED
,
358 clear_bit(ABORT_ISP_ACTIVE
, &vha
->dpc_flags
);
359 ql_dbg(ql_dbg_mbx
, vha
, 0x101f,
360 "Finished abort_isp.\n");
367 /* Allow next mbx cmd to come in. */
368 complete(&ha
->mbx_cmd_comp
);
372 ql_dbg(ql_dbg_mbx
, base_vha
, 0x1020,
373 "**** Failed mbx[0]=%x, mb[1]=%x, mb[2]=%x, mb[3]=%x, cmd=%x ****.\n",
374 mcp
->mb
[0], mcp
->mb
[1], mcp
->mb
[2], mcp
->mb
[3], command
);
376 ql_dbg(ql_dbg_mbx
, base_vha
, 0x1021, "Done %s.\n", __func__
);
383 qla2x00_load_ram(scsi_qla_host_t
*vha
, dma_addr_t req_dma
, uint32_t risc_addr
,
384 uint32_t risc_code_size
)
387 struct qla_hw_data
*ha
= vha
->hw
;
389 mbx_cmd_t
*mcp
= &mc
;
391 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x1022,
392 "Entered %s.\n", __func__
);
394 if (MSW(risc_addr
) || IS_FWI2_CAPABLE(ha
)) {
395 mcp
->mb
[0] = MBC_LOAD_RISC_RAM_EXTENDED
;
396 mcp
->mb
[8] = MSW(risc_addr
);
397 mcp
->out_mb
= MBX_8
|MBX_0
;
399 mcp
->mb
[0] = MBC_LOAD_RISC_RAM
;
402 mcp
->mb
[1] = LSW(risc_addr
);
403 mcp
->mb
[2] = MSW(req_dma
);
404 mcp
->mb
[3] = LSW(req_dma
);
405 mcp
->mb
[6] = MSW(MSD(req_dma
));
406 mcp
->mb
[7] = LSW(MSD(req_dma
));
407 mcp
->out_mb
|= MBX_7
|MBX_6
|MBX_3
|MBX_2
|MBX_1
;
408 if (IS_FWI2_CAPABLE(ha
)) {
409 mcp
->mb
[4] = MSW(risc_code_size
);
410 mcp
->mb
[5] = LSW(risc_code_size
);
411 mcp
->out_mb
|= MBX_5
|MBX_4
;
413 mcp
->mb
[4] = LSW(risc_code_size
);
414 mcp
->out_mb
|= MBX_4
;
418 mcp
->tov
= MBX_TOV_SECONDS
;
420 rval
= qla2x00_mailbox_command(vha
, mcp
);
422 if (rval
!= QLA_SUCCESS
) {
423 ql_dbg(ql_dbg_mbx
, vha
, 0x1023,
424 "Failed=%x mb[0]=%x.\n", rval
, mcp
->mb
[0]);
426 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x1024,
427 "Done %s.\n", __func__
);
433 #define EXTENDED_BB_CREDITS BIT_0
436 * Start adapter firmware.
439 * ha = adapter block pointer.
440 * TARGET_QUEUE_LOCK must be released.
441 * ADAPTER_STATE_LOCK must be released.
444 * qla2x00 local function return status code.
450 qla2x00_execute_fw(scsi_qla_host_t
*vha
, uint32_t risc_addr
)
453 struct qla_hw_data
*ha
= vha
->hw
;
455 mbx_cmd_t
*mcp
= &mc
;
457 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x1025,
458 "Entered %s.\n", __func__
);
460 mcp
->mb
[0] = MBC_EXECUTE_FIRMWARE
;
463 if (IS_FWI2_CAPABLE(ha
)) {
464 mcp
->mb
[1] = MSW(risc_addr
);
465 mcp
->mb
[2] = LSW(risc_addr
);
467 if (IS_QLA81XX(ha
) || IS_QLA83XX(ha
)) {
468 struct nvram_81xx
*nv
= ha
->nvram
;
469 mcp
->mb
[4] = (nv
->enhanced_features
&
470 EXTENDED_BB_CREDITS
);
473 mcp
->out_mb
|= MBX_4
|MBX_3
|MBX_2
|MBX_1
;
476 mcp
->mb
[1] = LSW(risc_addr
);
477 mcp
->out_mb
|= MBX_1
;
478 if (IS_QLA2322(ha
) || IS_QLA6322(ha
)) {
480 mcp
->out_mb
|= MBX_2
;
484 mcp
->tov
= MBX_TOV_SECONDS
;
486 rval
= qla2x00_mailbox_command(vha
, mcp
);
488 if (rval
!= QLA_SUCCESS
) {
489 ql_dbg(ql_dbg_mbx
, vha
, 0x1026,
490 "Failed=%x mb[0]=%x.\n", rval
, mcp
->mb
[0]);
492 if (IS_FWI2_CAPABLE(ha
)) {
493 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x1027,
494 "Done exchanges=%x.\n", mcp
->mb
[1]);
496 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x1028,
497 "Done %s.\n", __func__
);
505 * qla2x00_get_fw_version
506 * Get firmware version.
509 * ha: adapter state pointer.
510 * major: pointer for major number.
511 * minor: pointer for minor number.
512 * subminor: pointer for subminor number.
515 * qla2x00 local function return status code.
521 qla2x00_get_fw_version(scsi_qla_host_t
*vha
)
525 mbx_cmd_t
*mcp
= &mc
;
526 struct qla_hw_data
*ha
= vha
->hw
;
528 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x1029,
529 "Entered %s.\n", __func__
);
531 mcp
->mb
[0] = MBC_GET_FIRMWARE_VERSION
;
533 mcp
->in_mb
= MBX_6
|MBX_5
|MBX_4
|MBX_3
|MBX_2
|MBX_1
|MBX_0
;
534 if (IS_QLA81XX(vha
->hw
) || IS_QLA8031(ha
))
535 mcp
->in_mb
|= MBX_13
|MBX_12
|MBX_11
|MBX_10
|MBX_9
|MBX_8
;
536 if (IS_QLA83XX(vha
->hw
))
537 mcp
->in_mb
|= MBX_17
|MBX_16
|MBX_15
;
539 mcp
->tov
= MBX_TOV_SECONDS
;
540 rval
= qla2x00_mailbox_command(vha
, mcp
);
541 if (rval
!= QLA_SUCCESS
)
544 /* Return mailbox data. */
545 ha
->fw_major_version
= mcp
->mb
[1];
546 ha
->fw_minor_version
= mcp
->mb
[2];
547 ha
->fw_subminor_version
= mcp
->mb
[3];
548 ha
->fw_attributes
= mcp
->mb
[6];
549 if (IS_QLA2100(vha
->hw
) || IS_QLA2200(vha
->hw
))
550 ha
->fw_memory_size
= 0x1FFFF; /* Defaults to 128KB. */
552 ha
->fw_memory_size
= (mcp
->mb
[5] << 16) | mcp
->mb
[4];
553 if (IS_QLA81XX(vha
->hw
) || IS_QLA8031(vha
->hw
)) {
554 ha
->mpi_version
[0] = mcp
->mb
[10] & 0xff;
555 ha
->mpi_version
[1] = mcp
->mb
[11] >> 8;
556 ha
->mpi_version
[2] = mcp
->mb
[11] & 0xff;
557 ha
->mpi_capabilities
= (mcp
->mb
[12] << 16) | mcp
->mb
[13];
558 ha
->phy_version
[0] = mcp
->mb
[8] & 0xff;
559 ha
->phy_version
[1] = mcp
->mb
[9] >> 8;
560 ha
->phy_version
[2] = mcp
->mb
[9] & 0xff;
562 if (IS_QLA83XX(ha
)) {
563 if (mcp
->mb
[6] & BIT_15
) {
564 ha
->fw_attributes_h
= mcp
->mb
[15];
565 ha
->fw_attributes_ext
[0] = mcp
->mb
[16];
566 ha
->fw_attributes_ext
[1] = mcp
->mb
[17];
567 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x1139,
568 "%s: FW_attributes Upper: 0x%x, Lower: 0x%x.\n",
569 __func__
, mcp
->mb
[15], mcp
->mb
[6]);
571 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x112f,
572 "%s: FwAttributes [Upper] invalid, MB6:%04x\n",
573 __func__
, mcp
->mb
[6]);
577 if (rval
!= QLA_SUCCESS
) {
579 ql_dbg(ql_dbg_mbx
, vha
, 0x102a, "Failed=%x.\n", rval
);
582 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x102b,
583 "Done %s.\n", __func__
);
589 * qla2x00_get_fw_options
590 * Set firmware options.
593 * ha = adapter block pointer.
594 * fwopt = pointer for firmware options.
597 * qla2x00 local function return status code.
603 qla2x00_get_fw_options(scsi_qla_host_t
*vha
, uint16_t *fwopts
)
607 mbx_cmd_t
*mcp
= &mc
;
609 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x102c,
610 "Entered %s.\n", __func__
);
612 mcp
->mb
[0] = MBC_GET_FIRMWARE_OPTION
;
614 mcp
->in_mb
= MBX_3
|MBX_2
|MBX_1
|MBX_0
;
615 mcp
->tov
= MBX_TOV_SECONDS
;
617 rval
= qla2x00_mailbox_command(vha
, mcp
);
619 if (rval
!= QLA_SUCCESS
) {
621 ql_dbg(ql_dbg_mbx
, vha
, 0x102d, "Failed=%x.\n", rval
);
623 fwopts
[0] = mcp
->mb
[0];
624 fwopts
[1] = mcp
->mb
[1];
625 fwopts
[2] = mcp
->mb
[2];
626 fwopts
[3] = mcp
->mb
[3];
628 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x102e,
629 "Done %s.\n", __func__
);
637 * qla2x00_set_fw_options
638 * Set firmware options.
641 * ha = adapter block pointer.
642 * fwopt = pointer for firmware options.
645 * qla2x00 local function return status code.
651 qla2x00_set_fw_options(scsi_qla_host_t
*vha
, uint16_t *fwopts
)
655 mbx_cmd_t
*mcp
= &mc
;
657 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x102f,
658 "Entered %s.\n", __func__
);
660 mcp
->mb
[0] = MBC_SET_FIRMWARE_OPTION
;
661 mcp
->mb
[1] = fwopts
[1];
662 mcp
->mb
[2] = fwopts
[2];
663 mcp
->mb
[3] = fwopts
[3];
664 mcp
->out_mb
= MBX_3
|MBX_2
|MBX_1
|MBX_0
;
666 if (IS_FWI2_CAPABLE(vha
->hw
)) {
669 mcp
->mb
[10] = fwopts
[10];
670 mcp
->mb
[11] = fwopts
[11];
671 mcp
->mb
[12] = 0; /* Undocumented, but used */
672 mcp
->out_mb
|= MBX_12
|MBX_11
|MBX_10
;
674 mcp
->tov
= MBX_TOV_SECONDS
;
676 rval
= qla2x00_mailbox_command(vha
, mcp
);
678 fwopts
[0] = mcp
->mb
[0];
680 if (rval
!= QLA_SUCCESS
) {
682 ql_dbg(ql_dbg_mbx
, vha
, 0x1030,
683 "Failed=%x (%x/%x).\n", rval
, mcp
->mb
[0], mcp
->mb
[1]);
686 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x1031,
687 "Done %s.\n", __func__
);
694 * qla2x00_mbx_reg_test
695 * Mailbox register wrap test.
698 * ha = adapter block pointer.
699 * TARGET_QUEUE_LOCK must be released.
700 * ADAPTER_STATE_LOCK must be released.
703 * qla2x00 local function return status code.
709 qla2x00_mbx_reg_test(scsi_qla_host_t
*vha
)
713 mbx_cmd_t
*mcp
= &mc
;
715 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x1032,
716 "Entered %s.\n", __func__
);
718 mcp
->mb
[0] = MBC_MAILBOX_REGISTER_TEST
;
726 mcp
->out_mb
= MBX_7
|MBX_6
|MBX_5
|MBX_4
|MBX_3
|MBX_2
|MBX_1
|MBX_0
;
727 mcp
->in_mb
= MBX_7
|MBX_6
|MBX_5
|MBX_4
|MBX_3
|MBX_2
|MBX_1
|MBX_0
;
728 mcp
->tov
= MBX_TOV_SECONDS
;
730 rval
= qla2x00_mailbox_command(vha
, mcp
);
732 if (rval
== QLA_SUCCESS
) {
733 if (mcp
->mb
[1] != 0xAAAA || mcp
->mb
[2] != 0x5555 ||
734 mcp
->mb
[3] != 0xAA55 || mcp
->mb
[4] != 0x55AA)
735 rval
= QLA_FUNCTION_FAILED
;
736 if (mcp
->mb
[5] != 0xA5A5 || mcp
->mb
[6] != 0x5A5A ||
737 mcp
->mb
[7] != 0x2525)
738 rval
= QLA_FUNCTION_FAILED
;
741 if (rval
!= QLA_SUCCESS
) {
743 ql_dbg(ql_dbg_mbx
, vha
, 0x1033, "Failed=%x.\n", rval
);
746 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x1034,
747 "Done %s.\n", __func__
);
754 * qla2x00_verify_checksum
755 * Verify firmware checksum.
758 * ha = adapter block pointer.
759 * TARGET_QUEUE_LOCK must be released.
760 * ADAPTER_STATE_LOCK must be released.
763 * qla2x00 local function return status code.
769 qla2x00_verify_checksum(scsi_qla_host_t
*vha
, uint32_t risc_addr
)
773 mbx_cmd_t
*mcp
= &mc
;
775 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x1035,
776 "Entered %s.\n", __func__
);
778 mcp
->mb
[0] = MBC_VERIFY_CHECKSUM
;
781 if (IS_FWI2_CAPABLE(vha
->hw
)) {
782 mcp
->mb
[1] = MSW(risc_addr
);
783 mcp
->mb
[2] = LSW(risc_addr
);
784 mcp
->out_mb
|= MBX_2
|MBX_1
;
785 mcp
->in_mb
|= MBX_2
|MBX_1
;
787 mcp
->mb
[1] = LSW(risc_addr
);
788 mcp
->out_mb
|= MBX_1
;
792 mcp
->tov
= MBX_TOV_SECONDS
;
794 rval
= qla2x00_mailbox_command(vha
, mcp
);
796 if (rval
!= QLA_SUCCESS
) {
797 ql_dbg(ql_dbg_mbx
, vha
, 0x1036,
798 "Failed=%x chm sum=%x.\n", rval
, IS_FWI2_CAPABLE(vha
->hw
) ?
799 (mcp
->mb
[2] << 16) | mcp
->mb
[1] : mcp
->mb
[1]);
801 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x1037,
802 "Done %s.\n", __func__
);
810 * Issue IOCB using mailbox command
813 * ha = adapter state pointer.
814 * buffer = buffer pointer.
815 * phys_addr = physical address of buffer.
816 * size = size of buffer.
817 * TARGET_QUEUE_LOCK must be released.
818 * ADAPTER_STATE_LOCK must be released.
821 * qla2x00 local function return status code.
827 qla2x00_issue_iocb_timeout(scsi_qla_host_t
*vha
, void *buffer
,
828 dma_addr_t phys_addr
, size_t size
, uint32_t tov
)
832 mbx_cmd_t
*mcp
= &mc
;
834 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x1038,
835 "Entered %s.\n", __func__
);
837 mcp
->mb
[0] = MBC_IOCB_COMMAND_A64
;
839 mcp
->mb
[2] = MSW(phys_addr
);
840 mcp
->mb
[3] = LSW(phys_addr
);
841 mcp
->mb
[6] = MSW(MSD(phys_addr
));
842 mcp
->mb
[7] = LSW(MSD(phys_addr
));
843 mcp
->out_mb
= MBX_7
|MBX_6
|MBX_3
|MBX_2
|MBX_1
|MBX_0
;
844 mcp
->in_mb
= MBX_2
|MBX_0
;
847 rval
= qla2x00_mailbox_command(vha
, mcp
);
849 if (rval
!= QLA_SUCCESS
) {
851 ql_dbg(ql_dbg_mbx
, vha
, 0x1039, "Failed=%x.\n", rval
);
853 sts_entry_t
*sts_entry
= (sts_entry_t
*) buffer
;
855 /* Mask reserved bits. */
856 sts_entry
->entry_status
&=
857 IS_FWI2_CAPABLE(vha
->hw
) ? RF_MASK_24XX
: RF_MASK
;
858 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x103a,
859 "Done %s.\n", __func__
);
866 qla2x00_issue_iocb(scsi_qla_host_t
*vha
, void *buffer
, dma_addr_t phys_addr
,
869 return qla2x00_issue_iocb_timeout(vha
, buffer
, phys_addr
, size
,
874 * qla2x00_abort_command
875 * Abort command aborts a specified IOCB.
878 * ha = adapter block pointer.
879 * sp = SB structure pointer.
882 * qla2x00 local function return status code.
888 qla2x00_abort_command(srb_t
*sp
)
890 unsigned long flags
= 0;
894 mbx_cmd_t
*mcp
= &mc
;
895 fc_port_t
*fcport
= sp
->fcport
;
896 scsi_qla_host_t
*vha
= fcport
->vha
;
897 struct qla_hw_data
*ha
= vha
->hw
;
898 struct req_que
*req
= vha
->req
;
899 struct scsi_cmnd
*cmd
= GET_CMD_SP(sp
);
901 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x103b,
902 "Entered %s.\n", __func__
);
904 spin_lock_irqsave(&ha
->hardware_lock
, flags
);
905 for (handle
= 1; handle
< MAX_OUTSTANDING_COMMANDS
; handle
++) {
906 if (req
->outstanding_cmds
[handle
] == sp
)
909 spin_unlock_irqrestore(&ha
->hardware_lock
, flags
);
911 if (handle
== MAX_OUTSTANDING_COMMANDS
) {
912 /* command not found */
913 return QLA_FUNCTION_FAILED
;
916 mcp
->mb
[0] = MBC_ABORT_COMMAND
;
917 if (HAS_EXTENDED_IDS(ha
))
918 mcp
->mb
[1] = fcport
->loop_id
;
920 mcp
->mb
[1] = fcport
->loop_id
<< 8;
921 mcp
->mb
[2] = (uint16_t)handle
;
922 mcp
->mb
[3] = (uint16_t)(handle
>> 16);
923 mcp
->mb
[6] = (uint16_t)cmd
->device
->lun
;
924 mcp
->out_mb
= MBX_6
|MBX_3
|MBX_2
|MBX_1
|MBX_0
;
926 mcp
->tov
= MBX_TOV_SECONDS
;
928 rval
= qla2x00_mailbox_command(vha
, mcp
);
930 if (rval
!= QLA_SUCCESS
) {
931 ql_dbg(ql_dbg_mbx
, vha
, 0x103c, "Failed=%x.\n", rval
);
933 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x103d,
934 "Done %s.\n", __func__
);
941 qla2x00_abort_target(struct fc_port
*fcport
, unsigned int l
, int tag
)
945 mbx_cmd_t
*mcp
= &mc
;
946 scsi_qla_host_t
*vha
;
953 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x103e,
954 "Entered %s.\n", __func__
);
956 req
= vha
->hw
->req_q_map
[0];
958 mcp
->mb
[0] = MBC_ABORT_TARGET
;
959 mcp
->out_mb
= MBX_9
|MBX_2
|MBX_1
|MBX_0
;
960 if (HAS_EXTENDED_IDS(vha
->hw
)) {
961 mcp
->mb
[1] = fcport
->loop_id
;
963 mcp
->out_mb
|= MBX_10
;
965 mcp
->mb
[1] = fcport
->loop_id
<< 8;
967 mcp
->mb
[2] = vha
->hw
->loop_reset_delay
;
968 mcp
->mb
[9] = vha
->vp_idx
;
971 mcp
->tov
= MBX_TOV_SECONDS
;
973 rval
= qla2x00_mailbox_command(vha
, mcp
);
974 if (rval
!= QLA_SUCCESS
) {
975 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x103f,
976 "Failed=%x.\n", rval
);
979 /* Issue marker IOCB. */
980 rval2
= qla2x00_marker(vha
, req
, rsp
, fcport
->loop_id
, 0,
982 if (rval2
!= QLA_SUCCESS
) {
983 ql_dbg(ql_dbg_mbx
, vha
, 0x1040,
984 "Failed to issue marker IOCB (%x).\n", rval2
);
986 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x1041,
987 "Done %s.\n", __func__
);
994 qla2x00_lun_reset(struct fc_port
*fcport
, unsigned int l
, int tag
)
998 mbx_cmd_t
*mcp
= &mc
;
999 scsi_qla_host_t
*vha
;
1000 struct req_que
*req
;
1001 struct rsp_que
*rsp
;
1005 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x1042,
1006 "Entered %s.\n", __func__
);
1008 req
= vha
->hw
->req_q_map
[0];
1010 mcp
->mb
[0] = MBC_LUN_RESET
;
1011 mcp
->out_mb
= MBX_9
|MBX_3
|MBX_2
|MBX_1
|MBX_0
;
1012 if (HAS_EXTENDED_IDS(vha
->hw
))
1013 mcp
->mb
[1] = fcport
->loop_id
;
1015 mcp
->mb
[1] = fcport
->loop_id
<< 8;
1018 mcp
->mb
[9] = vha
->vp_idx
;
1021 mcp
->tov
= MBX_TOV_SECONDS
;
1023 rval
= qla2x00_mailbox_command(vha
, mcp
);
1024 if (rval
!= QLA_SUCCESS
) {
1025 ql_dbg(ql_dbg_mbx
, vha
, 0x1043, "Failed=%x.\n", rval
);
1028 /* Issue marker IOCB. */
1029 rval2
= qla2x00_marker(vha
, req
, rsp
, fcport
->loop_id
, l
,
1031 if (rval2
!= QLA_SUCCESS
) {
1032 ql_dbg(ql_dbg_mbx
, vha
, 0x1044,
1033 "Failed to issue marker IOCB (%x).\n", rval2
);
1035 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x1045,
1036 "Done %s.\n", __func__
);
1043 * qla2x00_get_adapter_id
1044 * Get adapter ID and topology.
1047 * ha = adapter block pointer.
1048 * id = pointer for loop ID.
1049 * al_pa = pointer for AL_PA.
1050 * area = pointer for area.
1051 * domain = pointer for domain.
1052 * top = pointer for topology.
1053 * TARGET_QUEUE_LOCK must be released.
1054 * ADAPTER_STATE_LOCK must be released.
1057 * qla2x00 local function return status code.
1063 qla2x00_get_adapter_id(scsi_qla_host_t
*vha
, uint16_t *id
, uint8_t *al_pa
,
1064 uint8_t *area
, uint8_t *domain
, uint16_t *top
, uint16_t *sw_cap
)
1068 mbx_cmd_t
*mcp
= &mc
;
1070 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x1046,
1071 "Entered %s.\n", __func__
);
1073 mcp
->mb
[0] = MBC_GET_ADAPTER_LOOP_ID
;
1074 mcp
->mb
[9] = vha
->vp_idx
;
1075 mcp
->out_mb
= MBX_9
|MBX_0
;
1076 mcp
->in_mb
= MBX_9
|MBX_7
|MBX_6
|MBX_3
|MBX_2
|MBX_1
|MBX_0
;
1077 if (IS_CNA_CAPABLE(vha
->hw
))
1078 mcp
->in_mb
|= MBX_13
|MBX_12
|MBX_11
|MBX_10
;
1079 mcp
->tov
= MBX_TOV_SECONDS
;
1081 rval
= qla2x00_mailbox_command(vha
, mcp
);
1082 if (mcp
->mb
[0] == MBS_COMMAND_ERROR
)
1083 rval
= QLA_COMMAND_ERROR
;
1084 else if (mcp
->mb
[0] == MBS_INVALID_COMMAND
)
1085 rval
= QLA_INVALID_COMMAND
;
1089 *al_pa
= LSB(mcp
->mb
[2]);
1090 *area
= MSB(mcp
->mb
[2]);
1091 *domain
= LSB(mcp
->mb
[3]);
1093 *sw_cap
= mcp
->mb
[7];
1095 if (rval
!= QLA_SUCCESS
) {
1097 ql_dbg(ql_dbg_mbx
, vha
, 0x1047, "Failed=%x.\n", rval
);
1099 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x1048,
1100 "Done %s.\n", __func__
);
1102 if (IS_CNA_CAPABLE(vha
->hw
)) {
1103 vha
->fcoe_vlan_id
= mcp
->mb
[9] & 0xfff;
1104 vha
->fcoe_fcf_idx
= mcp
->mb
[10];
1105 vha
->fcoe_vn_port_mac
[5] = mcp
->mb
[11] >> 8;
1106 vha
->fcoe_vn_port_mac
[4] = mcp
->mb
[11] & 0xff;
1107 vha
->fcoe_vn_port_mac
[3] = mcp
->mb
[12] >> 8;
1108 vha
->fcoe_vn_port_mac
[2] = mcp
->mb
[12] & 0xff;
1109 vha
->fcoe_vn_port_mac
[1] = mcp
->mb
[13] >> 8;
1110 vha
->fcoe_vn_port_mac
[0] = mcp
->mb
[13] & 0xff;
1118 * qla2x00_get_retry_cnt
1119 * Get current firmware login retry count and delay.
1122 * ha = adapter block pointer.
1123 * retry_cnt = pointer to login retry count.
1124 * tov = pointer to login timeout value.
1127 * qla2x00 local function return status code.
1133 qla2x00_get_retry_cnt(scsi_qla_host_t
*vha
, uint8_t *retry_cnt
, uint8_t *tov
,
1139 mbx_cmd_t
*mcp
= &mc
;
1141 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x1049,
1142 "Entered %s.\n", __func__
);
1144 mcp
->mb
[0] = MBC_GET_RETRY_COUNT
;
1145 mcp
->out_mb
= MBX_0
;
1146 mcp
->in_mb
= MBX_3
|MBX_2
|MBX_1
|MBX_0
;
1147 mcp
->tov
= MBX_TOV_SECONDS
;
1149 rval
= qla2x00_mailbox_command(vha
, mcp
);
1151 if (rval
!= QLA_SUCCESS
) {
1153 ql_dbg(ql_dbg_mbx
, vha
, 0x104a,
1154 "Failed=%x mb[0]=%x.\n", rval
, mcp
->mb
[0]);
1156 /* Convert returned data and check our values. */
1157 *r_a_tov
= mcp
->mb
[3] / 2;
1158 ratov
= (mcp
->mb
[3]/2) / 10; /* mb[3] value is in 100ms */
1159 if (mcp
->mb
[1] * ratov
> (*retry_cnt
) * (*tov
)) {
1160 /* Update to the larger values */
1161 *retry_cnt
= (uint8_t)mcp
->mb
[1];
1165 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x104b,
1166 "Done %s mb3=%d ratov=%d.\n", __func__
, mcp
->mb
[3], ratov
);
1173 * qla2x00_init_firmware
1174 * Initialize adapter firmware.
1177 * ha = adapter block pointer.
1178 * dptr = Initialization control block pointer.
1179 * size = size of initialization control block.
1180 * TARGET_QUEUE_LOCK must be released.
1181 * ADAPTER_STATE_LOCK must be released.
1184 * qla2x00 local function return status code.
1190 qla2x00_init_firmware(scsi_qla_host_t
*vha
, uint16_t size
)
1194 mbx_cmd_t
*mcp
= &mc
;
1195 struct qla_hw_data
*ha
= vha
->hw
;
1197 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x104c,
1198 "Entered %s.\n", __func__
);
1200 if (IS_QLA82XX(ha
) && ql2xdbwr
)
1201 qla82xx_wr_32(ha
, ha
->nxdb_wr_ptr
,
1202 (0x04 | (ha
->portnum
<< 5) | (0 << 8) | (0 << 16)));
1204 if (ha
->flags
.npiv_supported
)
1205 mcp
->mb
[0] = MBC_MID_INITIALIZE_FIRMWARE
;
1207 mcp
->mb
[0] = MBC_INITIALIZE_FIRMWARE
;
1210 mcp
->mb
[2] = MSW(ha
->init_cb_dma
);
1211 mcp
->mb
[3] = LSW(ha
->init_cb_dma
);
1212 mcp
->mb
[6] = MSW(MSD(ha
->init_cb_dma
));
1213 mcp
->mb
[7] = LSW(MSD(ha
->init_cb_dma
));
1214 mcp
->out_mb
= MBX_7
|MBX_6
|MBX_3
|MBX_2
|MBX_1
|MBX_0
;
1215 if ((IS_QLA81XX(ha
) || IS_QLA83XX(ha
)) && ha
->ex_init_cb
->ex_version
) {
1217 mcp
->mb
[10] = MSW(ha
->ex_init_cb_dma
);
1218 mcp
->mb
[11] = LSW(ha
->ex_init_cb_dma
);
1219 mcp
->mb
[12] = MSW(MSD(ha
->ex_init_cb_dma
));
1220 mcp
->mb
[13] = LSW(MSD(ha
->ex_init_cb_dma
));
1221 mcp
->mb
[14] = sizeof(*ha
->ex_init_cb
);
1222 mcp
->out_mb
|= MBX_14
|MBX_13
|MBX_12
|MBX_11
|MBX_10
;
1224 /* 1 and 2 should normally be captured. */
1225 mcp
->in_mb
= MBX_2
|MBX_1
|MBX_0
;
1227 /* mb3 is additional info about the installed SFP. */
1228 mcp
->in_mb
|= MBX_3
;
1229 mcp
->buf_size
= size
;
1230 mcp
->flags
= MBX_DMA_OUT
;
1231 mcp
->tov
= MBX_TOV_SECONDS
;
1232 rval
= qla2x00_mailbox_command(vha
, mcp
);
1234 if (rval
!= QLA_SUCCESS
) {
1236 ql_dbg(ql_dbg_mbx
, vha
, 0x104d,
1237 "Failed=%x mb[0]=%x, mb[1]=%x, mb[2]=%x, mb[3]=%x,.\n",
1238 rval
, mcp
->mb
[0], mcp
->mb
[1], mcp
->mb
[2], mcp
->mb
[3]);
1241 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x104e,
1242 "Done %s.\n", __func__
);
1249 * qla2x00_get_node_name_list
1250 * Issue get node name list mailbox command, kmalloc()
1251 * and return the resulting list. Caller must kfree() it!
1254 * ha = adapter state pointer.
1255 * out_data = resulting list
1256 * out_len = length of the resulting list
1259 * qla2x00 local function return status code.
1265 qla2x00_get_node_name_list(scsi_qla_host_t
*vha
, void **out_data
, int *out_len
)
1267 struct qla_hw_data
*ha
= vha
->hw
;
1268 struct qla_port_24xx_data
*list
= NULL
;
1271 dma_addr_t pmap_dma
;
1277 dma_size
= left
* sizeof(*list
);
1278 pmap
= dma_alloc_coherent(&ha
->pdev
->dev
, dma_size
,
1279 &pmap_dma
, GFP_KERNEL
);
1281 ql_log(ql_log_warn
, vha
, 0x113f,
1282 "%s(%ld): DMA Alloc failed of %ld\n",
1283 __func__
, vha
->host_no
, dma_size
);
1284 rval
= QLA_MEMORY_ALLOC_FAILED
;
1288 mc
.mb
[0] = MBC_PORT_NODE_NAME_LIST
;
1289 mc
.mb
[1] = BIT_1
| BIT_3
;
1290 mc
.mb
[2] = MSW(pmap_dma
);
1291 mc
.mb
[3] = LSW(pmap_dma
);
1292 mc
.mb
[6] = MSW(MSD(pmap_dma
));
1293 mc
.mb
[7] = LSW(MSD(pmap_dma
));
1294 mc
.mb
[8] = dma_size
;
1295 mc
.out_mb
= MBX_0
|MBX_1
|MBX_2
|MBX_3
|MBX_6
|MBX_7
|MBX_8
;
1296 mc
.in_mb
= MBX_0
|MBX_1
;
1298 mc
.flags
= MBX_DMA_IN
;
1300 rval
= qla2x00_mailbox_command(vha
, &mc
);
1301 if (rval
!= QLA_SUCCESS
) {
1302 if ((mc
.mb
[0] == MBS_COMMAND_ERROR
) &&
1303 (mc
.mb
[1] == 0xA)) {
1304 left
+= le16_to_cpu(mc
.mb
[2]) /
1305 sizeof(struct qla_port_24xx_data
);
1313 list
= kzalloc(dma_size
, GFP_KERNEL
);
1315 ql_log(ql_log_warn
, vha
, 0x1140,
1316 "%s(%ld): failed to allocate node names list "
1317 "structure.\n", __func__
, vha
->host_no
);
1318 rval
= QLA_MEMORY_ALLOC_FAILED
;
1322 memcpy(list
, pmap
, dma_size
);
1324 dma_free_coherent(&ha
->pdev
->dev
, dma_size
, pmap
, pmap_dma
);
1328 *out_len
= dma_size
;
1334 dma_free_coherent(&ha
->pdev
->dev
, dma_size
, pmap
, pmap_dma
);
1339 * qla2x00_get_port_database
1340 * Issue normal/enhanced get port database mailbox command
1341 * and copy device name as necessary.
1344 * ha = adapter state pointer.
1345 * dev = structure pointer.
1346 * opt = enhanced cmd option byte.
1349 * qla2x00 local function return status code.
1355 qla2x00_get_port_database(scsi_qla_host_t
*vha
, fc_port_t
*fcport
, uint8_t opt
)
1359 mbx_cmd_t
*mcp
= &mc
;
1360 port_database_t
*pd
;
1361 struct port_database_24xx
*pd24
;
1363 struct qla_hw_data
*ha
= vha
->hw
;
1365 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x104f,
1366 "Entered %s.\n", __func__
);
1369 pd
= dma_pool_alloc(ha
->s_dma_pool
, GFP_KERNEL
, &pd_dma
);
1371 ql_log(ql_log_warn
, vha
, 0x1050,
1372 "Failed to allocate port database structure.\n");
1373 return QLA_MEMORY_ALLOC_FAILED
;
1375 memset(pd
, 0, max(PORT_DATABASE_SIZE
, PORT_DATABASE_24XX_SIZE
));
1377 mcp
->mb
[0] = MBC_GET_PORT_DATABASE
;
1378 if (opt
!= 0 && !IS_FWI2_CAPABLE(ha
))
1379 mcp
->mb
[0] = MBC_ENHANCED_GET_PORT_DATABASE
;
1380 mcp
->mb
[2] = MSW(pd_dma
);
1381 mcp
->mb
[3] = LSW(pd_dma
);
1382 mcp
->mb
[6] = MSW(MSD(pd_dma
));
1383 mcp
->mb
[7] = LSW(MSD(pd_dma
));
1384 mcp
->mb
[9] = vha
->vp_idx
;
1385 mcp
->out_mb
= MBX_9
|MBX_7
|MBX_6
|MBX_3
|MBX_2
|MBX_0
;
1387 if (IS_FWI2_CAPABLE(ha
)) {
1388 mcp
->mb
[1] = fcport
->loop_id
;
1390 mcp
->out_mb
|= MBX_10
|MBX_1
;
1391 mcp
->in_mb
|= MBX_1
;
1392 } else if (HAS_EXTENDED_IDS(ha
)) {
1393 mcp
->mb
[1] = fcport
->loop_id
;
1395 mcp
->out_mb
|= MBX_10
|MBX_1
;
1397 mcp
->mb
[1] = fcport
->loop_id
<< 8 | opt
;
1398 mcp
->out_mb
|= MBX_1
;
1400 mcp
->buf_size
= IS_FWI2_CAPABLE(ha
) ?
1401 PORT_DATABASE_24XX_SIZE
: PORT_DATABASE_SIZE
;
1402 mcp
->flags
= MBX_DMA_IN
;
1403 mcp
->tov
= (ha
->login_timeout
* 2) + (ha
->login_timeout
/ 2);
1404 rval
= qla2x00_mailbox_command(vha
, mcp
);
1405 if (rval
!= QLA_SUCCESS
)
1408 if (IS_FWI2_CAPABLE(ha
)) {
1410 pd24
= (struct port_database_24xx
*) pd
;
1412 /* Check for logged in state. */
1413 if (pd24
->current_login_state
!= PDS_PRLI_COMPLETE
&&
1414 pd24
->last_login_state
!= PDS_PRLI_COMPLETE
) {
1415 ql_dbg(ql_dbg_mbx
, vha
, 0x1051,
1416 "Unable to verify login-state (%x/%x) for "
1417 "loop_id %x.\n", pd24
->current_login_state
,
1418 pd24
->last_login_state
, fcport
->loop_id
);
1419 rval
= QLA_FUNCTION_FAILED
;
1423 if (fcport
->loop_id
== FC_NO_LOOP_ID
||
1424 (memcmp(fcport
->port_name
, (uint8_t *)&zero
, 8) &&
1425 memcmp(fcport
->port_name
, pd24
->port_name
, 8))) {
1426 /* We lost the device mid way. */
1427 rval
= QLA_NOT_LOGGED_IN
;
1431 /* Names are little-endian. */
1432 memcpy(fcport
->node_name
, pd24
->node_name
, WWN_SIZE
);
1433 memcpy(fcport
->port_name
, pd24
->port_name
, WWN_SIZE
);
1435 /* Get port_id of device. */
1436 fcport
->d_id
.b
.domain
= pd24
->port_id
[0];
1437 fcport
->d_id
.b
.area
= pd24
->port_id
[1];
1438 fcport
->d_id
.b
.al_pa
= pd24
->port_id
[2];
1439 fcport
->d_id
.b
.rsvd_1
= 0;
1441 /* If not target must be initiator or unknown type. */
1442 if ((pd24
->prli_svc_param_word_3
[0] & BIT_4
) == 0)
1443 fcport
->port_type
= FCT_INITIATOR
;
1445 fcport
->port_type
= FCT_TARGET
;
1447 /* Passback COS information. */
1448 fcport
->supported_classes
= (pd24
->flags
& PDF_CLASS_2
) ?
1449 FC_COS_CLASS2
: FC_COS_CLASS3
;
1451 if (pd24
->prli_svc_param_word_3
[0] & BIT_7
)
1452 fcport
->flags
|= FCF_CONF_COMP_SUPPORTED
;
1456 /* Check for logged in state. */
1457 if (pd
->master_state
!= PD_STATE_PORT_LOGGED_IN
&&
1458 pd
->slave_state
!= PD_STATE_PORT_LOGGED_IN
) {
1459 ql_dbg(ql_dbg_mbx
, vha
, 0x100a,
1460 "Unable to verify login-state (%x/%x) - "
1461 "portid=%02x%02x%02x.\n", pd
->master_state
,
1462 pd
->slave_state
, fcport
->d_id
.b
.domain
,
1463 fcport
->d_id
.b
.area
, fcport
->d_id
.b
.al_pa
);
1464 rval
= QLA_FUNCTION_FAILED
;
1468 if (fcport
->loop_id
== FC_NO_LOOP_ID
||
1469 (memcmp(fcport
->port_name
, (uint8_t *)&zero
, 8) &&
1470 memcmp(fcport
->port_name
, pd
->port_name
, 8))) {
1471 /* We lost the device mid way. */
1472 rval
= QLA_NOT_LOGGED_IN
;
1476 /* Names are little-endian. */
1477 memcpy(fcport
->node_name
, pd
->node_name
, WWN_SIZE
);
1478 memcpy(fcport
->port_name
, pd
->port_name
, WWN_SIZE
);
1480 /* Get port_id of device. */
1481 fcport
->d_id
.b
.domain
= pd
->port_id
[0];
1482 fcport
->d_id
.b
.area
= pd
->port_id
[3];
1483 fcport
->d_id
.b
.al_pa
= pd
->port_id
[2];
1484 fcport
->d_id
.b
.rsvd_1
= 0;
1486 /* If not target must be initiator or unknown type. */
1487 if ((pd
->prli_svc_param_word_3
[0] & BIT_4
) == 0)
1488 fcport
->port_type
= FCT_INITIATOR
;
1490 fcport
->port_type
= FCT_TARGET
;
1492 /* Passback COS information. */
1493 fcport
->supported_classes
= (pd
->options
& BIT_4
) ?
1494 FC_COS_CLASS2
: FC_COS_CLASS3
;
1498 dma_pool_free(ha
->s_dma_pool
, pd
, pd_dma
);
1500 if (rval
!= QLA_SUCCESS
) {
1501 ql_dbg(ql_dbg_mbx
, vha
, 0x1052,
1502 "Failed=%x mb[0]=%x mb[1]=%x.\n", rval
,
1503 mcp
->mb
[0], mcp
->mb
[1]);
1505 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x1053,
1506 "Done %s.\n", __func__
);
1513 * qla2x00_get_firmware_state
1514 * Get adapter firmware state.
1517 * ha = adapter block pointer.
1518 * dptr = pointer for firmware state.
1519 * TARGET_QUEUE_LOCK must be released.
1520 * ADAPTER_STATE_LOCK must be released.
1523 * qla2x00 local function return status code.
1529 qla2x00_get_firmware_state(scsi_qla_host_t
*vha
, uint16_t *states
)
1533 mbx_cmd_t
*mcp
= &mc
;
1535 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x1054,
1536 "Entered %s.\n", __func__
);
1538 mcp
->mb
[0] = MBC_GET_FIRMWARE_STATE
;
1539 mcp
->out_mb
= MBX_0
;
1540 if (IS_FWI2_CAPABLE(vha
->hw
))
1541 mcp
->in_mb
= MBX_5
|MBX_4
|MBX_3
|MBX_2
|MBX_1
|MBX_0
;
1543 mcp
->in_mb
= MBX_1
|MBX_0
;
1544 mcp
->tov
= MBX_TOV_SECONDS
;
1546 rval
= qla2x00_mailbox_command(vha
, mcp
);
1548 /* Return firmware states. */
1549 states
[0] = mcp
->mb
[1];
1550 if (IS_FWI2_CAPABLE(vha
->hw
)) {
1551 states
[1] = mcp
->mb
[2];
1552 states
[2] = mcp
->mb
[3];
1553 states
[3] = mcp
->mb
[4];
1554 states
[4] = mcp
->mb
[5];
1557 if (rval
!= QLA_SUCCESS
) {
1559 ql_dbg(ql_dbg_mbx
, vha
, 0x1055, "Failed=%x.\n", rval
);
1562 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x1056,
1563 "Done %s.\n", __func__
);
1570 * qla2x00_get_port_name
1571 * Issue get port name mailbox command.
1572 * Returned name is in big endian format.
1575 * ha = adapter block pointer.
1576 * loop_id = loop ID of device.
1577 * name = pointer for name.
1578 * TARGET_QUEUE_LOCK must be released.
1579 * ADAPTER_STATE_LOCK must be released.
1582 * qla2x00 local function return status code.
1588 qla2x00_get_port_name(scsi_qla_host_t
*vha
, uint16_t loop_id
, uint8_t *name
,
1593 mbx_cmd_t
*mcp
= &mc
;
1595 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x1057,
1596 "Entered %s.\n", __func__
);
1598 mcp
->mb
[0] = MBC_GET_PORT_NAME
;
1599 mcp
->mb
[9] = vha
->vp_idx
;
1600 mcp
->out_mb
= MBX_9
|MBX_1
|MBX_0
;
1601 if (HAS_EXTENDED_IDS(vha
->hw
)) {
1602 mcp
->mb
[1] = loop_id
;
1604 mcp
->out_mb
|= MBX_10
;
1606 mcp
->mb
[1] = loop_id
<< 8 | opt
;
1609 mcp
->in_mb
= MBX_7
|MBX_6
|MBX_3
|MBX_2
|MBX_1
|MBX_0
;
1610 mcp
->tov
= MBX_TOV_SECONDS
;
1612 rval
= qla2x00_mailbox_command(vha
, mcp
);
1614 if (rval
!= QLA_SUCCESS
) {
1616 ql_dbg(ql_dbg_mbx
, vha
, 0x1058, "Failed=%x.\n", rval
);
1619 /* This function returns name in big endian. */
1620 name
[0] = MSB(mcp
->mb
[2]);
1621 name
[1] = LSB(mcp
->mb
[2]);
1622 name
[2] = MSB(mcp
->mb
[3]);
1623 name
[3] = LSB(mcp
->mb
[3]);
1624 name
[4] = MSB(mcp
->mb
[6]);
1625 name
[5] = LSB(mcp
->mb
[6]);
1626 name
[6] = MSB(mcp
->mb
[7]);
1627 name
[7] = LSB(mcp
->mb
[7]);
1630 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x1059,
1631 "Done %s.\n", __func__
);
1639 * Issue LIP reset mailbox command.
1642 * ha = adapter block pointer.
1643 * TARGET_QUEUE_LOCK must be released.
1644 * ADAPTER_STATE_LOCK must be released.
1647 * qla2x00 local function return status code.
1653 qla2x00_lip_reset(scsi_qla_host_t
*vha
)
1657 mbx_cmd_t
*mcp
= &mc
;
1659 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x105a,
1660 "Entered %s.\n", __func__
);
1662 if (IS_CNA_CAPABLE(vha
->hw
)) {
1663 /* Logout across all FCFs. */
1664 mcp
->mb
[0] = MBC_LIP_FULL_LOGIN
;
1667 mcp
->out_mb
= MBX_2
|MBX_1
|MBX_0
;
1668 } else if (IS_FWI2_CAPABLE(vha
->hw
)) {
1669 mcp
->mb
[0] = MBC_LIP_FULL_LOGIN
;
1672 mcp
->mb
[3] = vha
->hw
->loop_reset_delay
;
1673 mcp
->out_mb
= MBX_3
|MBX_2
|MBX_1
|MBX_0
;
1675 mcp
->mb
[0] = MBC_LIP_RESET
;
1676 mcp
->out_mb
= MBX_3
|MBX_2
|MBX_1
|MBX_0
;
1677 if (HAS_EXTENDED_IDS(vha
->hw
)) {
1678 mcp
->mb
[1] = 0x00ff;
1680 mcp
->out_mb
|= MBX_10
;
1682 mcp
->mb
[1] = 0xff00;
1684 mcp
->mb
[2] = vha
->hw
->loop_reset_delay
;
1688 mcp
->tov
= MBX_TOV_SECONDS
;
1690 rval
= qla2x00_mailbox_command(vha
, mcp
);
1692 if (rval
!= QLA_SUCCESS
) {
1694 ql_dbg(ql_dbg_mbx
, vha
, 0x105b, "Failed=%x.\n", rval
);
1697 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x105c,
1698 "Done %s.\n", __func__
);
1709 * ha = adapter block pointer.
1710 * sns = pointer for command.
1711 * cmd_size = command size.
1712 * buf_size = response/command size.
1713 * TARGET_QUEUE_LOCK must be released.
1714 * ADAPTER_STATE_LOCK must be released.
1717 * qla2x00 local function return status code.
1723 qla2x00_send_sns(scsi_qla_host_t
*vha
, dma_addr_t sns_phys_address
,
1724 uint16_t cmd_size
, size_t buf_size
)
1728 mbx_cmd_t
*mcp
= &mc
;
1730 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x105d,
1731 "Entered %s.\n", __func__
);
1733 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x105e,
1734 "Retry cnt=%d ratov=%d total tov=%d.\n",
1735 vha
->hw
->retry_count
, vha
->hw
->login_timeout
, mcp
->tov
);
1737 mcp
->mb
[0] = MBC_SEND_SNS_COMMAND
;
1738 mcp
->mb
[1] = cmd_size
;
1739 mcp
->mb
[2] = MSW(sns_phys_address
);
1740 mcp
->mb
[3] = LSW(sns_phys_address
);
1741 mcp
->mb
[6] = MSW(MSD(sns_phys_address
));
1742 mcp
->mb
[7] = LSW(MSD(sns_phys_address
));
1743 mcp
->out_mb
= MBX_7
|MBX_6
|MBX_3
|MBX_2
|MBX_1
|MBX_0
;
1744 mcp
->in_mb
= MBX_0
|MBX_1
;
1745 mcp
->buf_size
= buf_size
;
1746 mcp
->flags
= MBX_DMA_OUT
|MBX_DMA_IN
;
1747 mcp
->tov
= (vha
->hw
->login_timeout
* 2) + (vha
->hw
->login_timeout
/ 2);
1748 rval
= qla2x00_mailbox_command(vha
, mcp
);
1750 if (rval
!= QLA_SUCCESS
) {
1752 ql_dbg(ql_dbg_mbx
, vha
, 0x105f,
1753 "Failed=%x mb[0]=%x mb[1]=%x.\n",
1754 rval
, mcp
->mb
[0], mcp
->mb
[1]);
1757 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x1060,
1758 "Done %s.\n", __func__
);
1765 qla24xx_login_fabric(scsi_qla_host_t
*vha
, uint16_t loop_id
, uint8_t domain
,
1766 uint8_t area
, uint8_t al_pa
, uint16_t *mb
, uint8_t opt
)
1770 struct logio_entry_24xx
*lg
;
1773 struct qla_hw_data
*ha
= vha
->hw
;
1774 struct req_que
*req
;
1775 struct rsp_que
*rsp
;
1777 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x1061,
1778 "Entered %s.\n", __func__
);
1780 if (ha
->flags
.cpu_affinity_enabled
)
1781 req
= ha
->req_q_map
[0];
1786 lg
= dma_pool_alloc(ha
->s_dma_pool
, GFP_KERNEL
, &lg_dma
);
1788 ql_log(ql_log_warn
, vha
, 0x1062,
1789 "Failed to allocate login IOCB.\n");
1790 return QLA_MEMORY_ALLOC_FAILED
;
1792 memset(lg
, 0, sizeof(struct logio_entry_24xx
));
1794 lg
->entry_type
= LOGINOUT_PORT_IOCB_TYPE
;
1795 lg
->entry_count
= 1;
1796 lg
->handle
= MAKE_HANDLE(req
->id
, lg
->handle
);
1797 lg
->nport_handle
= cpu_to_le16(loop_id
);
1798 lg
->control_flags
= __constant_cpu_to_le16(LCF_COMMAND_PLOGI
);
1800 lg
->control_flags
|= __constant_cpu_to_le16(LCF_COND_PLOGI
);
1802 lg
->control_flags
|= __constant_cpu_to_le16(LCF_SKIP_PRLI
);
1803 lg
->port_id
[0] = al_pa
;
1804 lg
->port_id
[1] = area
;
1805 lg
->port_id
[2] = domain
;
1806 lg
->vp_index
= vha
->vp_idx
;
1807 rval
= qla2x00_issue_iocb_timeout(vha
, lg
, lg_dma
, 0,
1808 (ha
->r_a_tov
/ 10 * 2) + 2);
1809 if (rval
!= QLA_SUCCESS
) {
1810 ql_dbg(ql_dbg_mbx
, vha
, 0x1063,
1811 "Failed to issue login IOCB (%x).\n", rval
);
1812 } else if (lg
->entry_status
!= 0) {
1813 ql_dbg(ql_dbg_mbx
, vha
, 0x1064,
1814 "Failed to complete IOCB -- error status (%x).\n",
1816 rval
= QLA_FUNCTION_FAILED
;
1817 } else if (lg
->comp_status
!= __constant_cpu_to_le16(CS_COMPLETE
)) {
1818 iop
[0] = le32_to_cpu(lg
->io_parameter
[0]);
1819 iop
[1] = le32_to_cpu(lg
->io_parameter
[1]);
1821 ql_dbg(ql_dbg_mbx
, vha
, 0x1065,
1822 "Failed to complete IOCB -- completion status (%x) "
1823 "ioparam=%x/%x.\n", le16_to_cpu(lg
->comp_status
),
1827 case LSC_SCODE_PORTID_USED
:
1828 mb
[0] = MBS_PORT_ID_USED
;
1829 mb
[1] = LSW(iop
[1]);
1831 case LSC_SCODE_NPORT_USED
:
1832 mb
[0] = MBS_LOOP_ID_USED
;
1834 case LSC_SCODE_NOLINK
:
1835 case LSC_SCODE_NOIOCB
:
1836 case LSC_SCODE_NOXCB
:
1837 case LSC_SCODE_CMD_FAILED
:
1838 case LSC_SCODE_NOFABRIC
:
1839 case LSC_SCODE_FW_NOT_READY
:
1840 case LSC_SCODE_NOT_LOGGED_IN
:
1841 case LSC_SCODE_NOPCB
:
1842 case LSC_SCODE_ELS_REJECT
:
1843 case LSC_SCODE_CMD_PARAM_ERR
:
1844 case LSC_SCODE_NONPORT
:
1845 case LSC_SCODE_LOGGED_IN
:
1846 case LSC_SCODE_NOFLOGI_ACC
:
1848 mb
[0] = MBS_COMMAND_ERROR
;
1852 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x1066,
1853 "Done %s.\n", __func__
);
1855 iop
[0] = le32_to_cpu(lg
->io_parameter
[0]);
1857 mb
[0] = MBS_COMMAND_COMPLETE
;
1859 if (iop
[0] & BIT_4
) {
1865 /* Passback COS information. */
1867 if (lg
->io_parameter
[7] || lg
->io_parameter
[8])
1868 mb
[10] |= BIT_0
; /* Class 2. */
1869 if (lg
->io_parameter
[9] || lg
->io_parameter
[10])
1870 mb
[10] |= BIT_1
; /* Class 3. */
1871 if (lg
->io_parameter
[0] & __constant_cpu_to_le32(BIT_7
))
1872 mb
[10] |= BIT_7
; /* Confirmed Completion
1877 dma_pool_free(ha
->s_dma_pool
, lg
, lg_dma
);
1883 * qla2x00_login_fabric
1884 * Issue login fabric port mailbox command.
1887 * ha = adapter block pointer.
1888 * loop_id = device loop ID.
1889 * domain = device domain.
1890 * area = device area.
1891 * al_pa = device AL_PA.
1892 * status = pointer for return status.
1893 * opt = command options.
1894 * TARGET_QUEUE_LOCK must be released.
1895 * ADAPTER_STATE_LOCK must be released.
1898 * qla2x00 local function return status code.
1904 qla2x00_login_fabric(scsi_qla_host_t
*vha
, uint16_t loop_id
, uint8_t domain
,
1905 uint8_t area
, uint8_t al_pa
, uint16_t *mb
, uint8_t opt
)
1909 mbx_cmd_t
*mcp
= &mc
;
1910 struct qla_hw_data
*ha
= vha
->hw
;
1912 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x1067,
1913 "Entered %s.\n", __func__
);
1915 mcp
->mb
[0] = MBC_LOGIN_FABRIC_PORT
;
1916 mcp
->out_mb
= MBX_3
|MBX_2
|MBX_1
|MBX_0
;
1917 if (HAS_EXTENDED_IDS(ha
)) {
1918 mcp
->mb
[1] = loop_id
;
1920 mcp
->out_mb
|= MBX_10
;
1922 mcp
->mb
[1] = (loop_id
<< 8) | opt
;
1924 mcp
->mb
[2] = domain
;
1925 mcp
->mb
[3] = area
<< 8 | al_pa
;
1927 mcp
->in_mb
= MBX_7
|MBX_6
|MBX_2
|MBX_1
|MBX_0
;
1928 mcp
->tov
= (ha
->login_timeout
* 2) + (ha
->login_timeout
/ 2);
1930 rval
= qla2x00_mailbox_command(vha
, mcp
);
1932 /* Return mailbox statuses. */
1939 /* COS retrieved from Get-Port-Database mailbox command. */
1943 if (rval
!= QLA_SUCCESS
) {
1944 /* RLU tmp code: need to change main mailbox_command function to
1945 * return ok even when the mailbox completion value is not
1946 * SUCCESS. The caller needs to be responsible to interpret
1947 * the return values of this mailbox command if we're not
1948 * to change too much of the existing code.
1950 if (mcp
->mb
[0] == 0x4001 || mcp
->mb
[0] == 0x4002 ||
1951 mcp
->mb
[0] == 0x4003 || mcp
->mb
[0] == 0x4005 ||
1952 mcp
->mb
[0] == 0x4006)
1956 ql_dbg(ql_dbg_mbx
, vha
, 0x1068,
1957 "Failed=%x mb[0]=%x mb[1]=%x mb[2]=%x.\n",
1958 rval
, mcp
->mb
[0], mcp
->mb
[1], mcp
->mb
[2]);
1961 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x1069,
1962 "Done %s.\n", __func__
);
1969 * qla2x00_login_local_device
1970 * Issue login loop port mailbox command.
1973 * ha = adapter block pointer.
1974 * loop_id = device loop ID.
1975 * opt = command options.
1978 * Return status code.
1985 qla2x00_login_local_device(scsi_qla_host_t
*vha
, fc_port_t
*fcport
,
1986 uint16_t *mb_ret
, uint8_t opt
)
1990 mbx_cmd_t
*mcp
= &mc
;
1991 struct qla_hw_data
*ha
= vha
->hw
;
1993 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x106a,
1994 "Entered %s.\n", __func__
);
1996 if (IS_FWI2_CAPABLE(ha
))
1997 return qla24xx_login_fabric(vha
, fcport
->loop_id
,
1998 fcport
->d_id
.b
.domain
, fcport
->d_id
.b
.area
,
1999 fcport
->d_id
.b
.al_pa
, mb_ret
, opt
);
2001 mcp
->mb
[0] = MBC_LOGIN_LOOP_PORT
;
2002 if (HAS_EXTENDED_IDS(ha
))
2003 mcp
->mb
[1] = fcport
->loop_id
;
2005 mcp
->mb
[1] = fcport
->loop_id
<< 8;
2007 mcp
->out_mb
= MBX_2
|MBX_1
|MBX_0
;
2008 mcp
->in_mb
= MBX_7
|MBX_6
|MBX_1
|MBX_0
;
2009 mcp
->tov
= (ha
->login_timeout
* 2) + (ha
->login_timeout
/ 2);
2011 rval
= qla2x00_mailbox_command(vha
, mcp
);
2013 /* Return mailbox statuses. */
2014 if (mb_ret
!= NULL
) {
2015 mb_ret
[0] = mcp
->mb
[0];
2016 mb_ret
[1] = mcp
->mb
[1];
2017 mb_ret
[6] = mcp
->mb
[6];
2018 mb_ret
[7] = mcp
->mb
[7];
2021 if (rval
!= QLA_SUCCESS
) {
2022 /* AV tmp code: need to change main mailbox_command function to
2023 * return ok even when the mailbox completion value is not
2024 * SUCCESS. The caller needs to be responsible to interpret
2025 * the return values of this mailbox command if we're not
2026 * to change too much of the existing code.
2028 if (mcp
->mb
[0] == 0x4005 || mcp
->mb
[0] == 0x4006)
2031 ql_dbg(ql_dbg_mbx
, vha
, 0x106b,
2032 "Failed=%x mb[0]=%x mb[1]=%x mb[6]=%x mb[7]=%x.\n",
2033 rval
, mcp
->mb
[0], mcp
->mb
[1], mcp
->mb
[6], mcp
->mb
[7]);
2036 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x106c,
2037 "Done %s.\n", __func__
);
2044 qla24xx_fabric_logout(scsi_qla_host_t
*vha
, uint16_t loop_id
, uint8_t domain
,
2045 uint8_t area
, uint8_t al_pa
)
2048 struct logio_entry_24xx
*lg
;
2050 struct qla_hw_data
*ha
= vha
->hw
;
2051 struct req_que
*req
;
2052 struct rsp_que
*rsp
;
2054 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x106d,
2055 "Entered %s.\n", __func__
);
2057 lg
= dma_pool_alloc(ha
->s_dma_pool
, GFP_KERNEL
, &lg_dma
);
2059 ql_log(ql_log_warn
, vha
, 0x106e,
2060 "Failed to allocate logout IOCB.\n");
2061 return QLA_MEMORY_ALLOC_FAILED
;
2063 memset(lg
, 0, sizeof(struct logio_entry_24xx
));
2065 if (ql2xmaxqueues
> 1)
2066 req
= ha
->req_q_map
[0];
2070 lg
->entry_type
= LOGINOUT_PORT_IOCB_TYPE
;
2071 lg
->entry_count
= 1;
2072 lg
->handle
= MAKE_HANDLE(req
->id
, lg
->handle
);
2073 lg
->nport_handle
= cpu_to_le16(loop_id
);
2075 __constant_cpu_to_le16(LCF_COMMAND_LOGO
|LCF_IMPL_LOGO
|
2077 lg
->port_id
[0] = al_pa
;
2078 lg
->port_id
[1] = area
;
2079 lg
->port_id
[2] = domain
;
2080 lg
->vp_index
= vha
->vp_idx
;
2081 rval
= qla2x00_issue_iocb_timeout(vha
, lg
, lg_dma
, 0,
2082 (ha
->r_a_tov
/ 10 * 2) + 2);
2083 if (rval
!= QLA_SUCCESS
) {
2084 ql_dbg(ql_dbg_mbx
, vha
, 0x106f,
2085 "Failed to issue logout IOCB (%x).\n", rval
);
2086 } else if (lg
->entry_status
!= 0) {
2087 ql_dbg(ql_dbg_mbx
, vha
, 0x1070,
2088 "Failed to complete IOCB -- error status (%x).\n",
2090 rval
= QLA_FUNCTION_FAILED
;
2091 } else if (lg
->comp_status
!= __constant_cpu_to_le16(CS_COMPLETE
)) {
2092 ql_dbg(ql_dbg_mbx
, vha
, 0x1071,
2093 "Failed to complete IOCB -- completion status (%x) "
2094 "ioparam=%x/%x.\n", le16_to_cpu(lg
->comp_status
),
2095 le32_to_cpu(lg
->io_parameter
[0]),
2096 le32_to_cpu(lg
->io_parameter
[1]));
2099 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x1072,
2100 "Done %s.\n", __func__
);
2103 dma_pool_free(ha
->s_dma_pool
, lg
, lg_dma
);
2109 * qla2x00_fabric_logout
2110 * Issue logout fabric port mailbox command.
2113 * ha = adapter block pointer.
2114 * loop_id = device loop ID.
2115 * TARGET_QUEUE_LOCK must be released.
2116 * ADAPTER_STATE_LOCK must be released.
2119 * qla2x00 local function return status code.
2125 qla2x00_fabric_logout(scsi_qla_host_t
*vha
, uint16_t loop_id
, uint8_t domain
,
2126 uint8_t area
, uint8_t al_pa
)
2130 mbx_cmd_t
*mcp
= &mc
;
2132 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x1073,
2133 "Entered %s.\n", __func__
);
2135 mcp
->mb
[0] = MBC_LOGOUT_FABRIC_PORT
;
2136 mcp
->out_mb
= MBX_1
|MBX_0
;
2137 if (HAS_EXTENDED_IDS(vha
->hw
)) {
2138 mcp
->mb
[1] = loop_id
;
2140 mcp
->out_mb
|= MBX_10
;
2142 mcp
->mb
[1] = loop_id
<< 8;
2145 mcp
->in_mb
= MBX_1
|MBX_0
;
2146 mcp
->tov
= MBX_TOV_SECONDS
;
2148 rval
= qla2x00_mailbox_command(vha
, mcp
);
2150 if (rval
!= QLA_SUCCESS
) {
2152 ql_dbg(ql_dbg_mbx
, vha
, 0x1074,
2153 "Failed=%x mb[1]=%x.\n", rval
, mcp
->mb
[1]);
2156 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x1075,
2157 "Done %s.\n", __func__
);
2164 * qla2x00_full_login_lip
2165 * Issue full login LIP mailbox command.
2168 * ha = adapter block pointer.
2169 * TARGET_QUEUE_LOCK must be released.
2170 * ADAPTER_STATE_LOCK must be released.
2173 * qla2x00 local function return status code.
2179 qla2x00_full_login_lip(scsi_qla_host_t
*vha
)
2183 mbx_cmd_t
*mcp
= &mc
;
2185 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x1076,
2186 "Entered %s.\n", __func__
);
2188 mcp
->mb
[0] = MBC_LIP_FULL_LOGIN
;
2189 mcp
->mb
[1] = IS_FWI2_CAPABLE(vha
->hw
) ? BIT_3
: 0;
2192 mcp
->out_mb
= MBX_3
|MBX_2
|MBX_1
|MBX_0
;
2194 mcp
->tov
= MBX_TOV_SECONDS
;
2196 rval
= qla2x00_mailbox_command(vha
, mcp
);
2198 if (rval
!= QLA_SUCCESS
) {
2200 ql_dbg(ql_dbg_mbx
, vha
, 0x1077, "Failed=%x.\n", rval
);
2203 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x1078,
2204 "Done %s.\n", __func__
);
2211 * qla2x00_get_id_list
2214 * ha = adapter block pointer.
2217 * qla2x00 local function return status code.
2223 qla2x00_get_id_list(scsi_qla_host_t
*vha
, void *id_list
, dma_addr_t id_list_dma
,
2228 mbx_cmd_t
*mcp
= &mc
;
2230 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x1079,
2231 "Entered %s.\n", __func__
);
2233 if (id_list
== NULL
)
2234 return QLA_FUNCTION_FAILED
;
2236 mcp
->mb
[0] = MBC_GET_ID_LIST
;
2237 mcp
->out_mb
= MBX_0
;
2238 if (IS_FWI2_CAPABLE(vha
->hw
)) {
2239 mcp
->mb
[2] = MSW(id_list_dma
);
2240 mcp
->mb
[3] = LSW(id_list_dma
);
2241 mcp
->mb
[6] = MSW(MSD(id_list_dma
));
2242 mcp
->mb
[7] = LSW(MSD(id_list_dma
));
2244 mcp
->mb
[9] = vha
->vp_idx
;
2245 mcp
->out_mb
|= MBX_9
|MBX_8
|MBX_7
|MBX_6
|MBX_3
|MBX_2
;
2247 mcp
->mb
[1] = MSW(id_list_dma
);
2248 mcp
->mb
[2] = LSW(id_list_dma
);
2249 mcp
->mb
[3] = MSW(MSD(id_list_dma
));
2250 mcp
->mb
[6] = LSW(MSD(id_list_dma
));
2251 mcp
->out_mb
|= MBX_6
|MBX_3
|MBX_2
|MBX_1
;
2253 mcp
->in_mb
= MBX_1
|MBX_0
;
2254 mcp
->tov
= MBX_TOV_SECONDS
;
2256 rval
= qla2x00_mailbox_command(vha
, mcp
);
2258 if (rval
!= QLA_SUCCESS
) {
2260 ql_dbg(ql_dbg_mbx
, vha
, 0x107a, "Failed=%x.\n", rval
);
2262 *entries
= mcp
->mb
[1];
2263 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x107b,
2264 "Done %s.\n", __func__
);
2271 * qla2x00_get_resource_cnts
2272 * Get current firmware resource counts.
2275 * ha = adapter block pointer.
2278 * qla2x00 local function return status code.
2284 qla2x00_get_resource_cnts(scsi_qla_host_t
*vha
, uint16_t *cur_xchg_cnt
,
2285 uint16_t *orig_xchg_cnt
, uint16_t *cur_iocb_cnt
,
2286 uint16_t *orig_iocb_cnt
, uint16_t *max_npiv_vports
, uint16_t *max_fcfs
)
2290 mbx_cmd_t
*mcp
= &mc
;
2292 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x107c,
2293 "Entered %s.\n", __func__
);
2295 mcp
->mb
[0] = MBC_GET_RESOURCE_COUNTS
;
2296 mcp
->out_mb
= MBX_0
;
2297 mcp
->in_mb
= MBX_11
|MBX_10
|MBX_7
|MBX_6
|MBX_3
|MBX_2
|MBX_1
|MBX_0
;
2298 if (IS_QLA81XX(vha
->hw
) || IS_QLA83XX(vha
->hw
))
2299 mcp
->in_mb
|= MBX_12
;
2300 mcp
->tov
= MBX_TOV_SECONDS
;
2302 rval
= qla2x00_mailbox_command(vha
, mcp
);
2304 if (rval
!= QLA_SUCCESS
) {
2306 ql_dbg(ql_dbg_mbx
, vha
, 0x107d,
2307 "Failed mb[0]=%x.\n", mcp
->mb
[0]);
2309 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x107e,
2310 "Done %s mb1=%x mb2=%x mb3=%x mb6=%x mb7=%x mb10=%x "
2311 "mb11=%x mb12=%x.\n", __func__
, mcp
->mb
[1], mcp
->mb
[2],
2312 mcp
->mb
[3], mcp
->mb
[6], mcp
->mb
[7], mcp
->mb
[10],
2313 mcp
->mb
[11], mcp
->mb
[12]);
2316 *cur_xchg_cnt
= mcp
->mb
[3];
2318 *orig_xchg_cnt
= mcp
->mb
[6];
2320 *cur_iocb_cnt
= mcp
->mb
[7];
2322 *orig_iocb_cnt
= mcp
->mb
[10];
2323 if (vha
->hw
->flags
.npiv_supported
&& max_npiv_vports
)
2324 *max_npiv_vports
= mcp
->mb
[11];
2325 if ((IS_QLA81XX(vha
->hw
) || IS_QLA83XX(vha
->hw
)) && max_fcfs
)
2326 *max_fcfs
= mcp
->mb
[12];
2333 * qla2x00_get_fcal_position_map
2334 * Get FCAL (LILP) position map using mailbox command
2337 * ha = adapter state pointer.
2338 * pos_map = buffer pointer (can be NULL).
2341 * qla2x00 local function return status code.
2347 qla2x00_get_fcal_position_map(scsi_qla_host_t
*vha
, char *pos_map
)
2351 mbx_cmd_t
*mcp
= &mc
;
2353 dma_addr_t pmap_dma
;
2354 struct qla_hw_data
*ha
= vha
->hw
;
2356 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x107f,
2357 "Entered %s.\n", __func__
);
2359 pmap
= dma_pool_alloc(ha
->s_dma_pool
, GFP_KERNEL
, &pmap_dma
);
2361 ql_log(ql_log_warn
, vha
, 0x1080,
2362 "Memory alloc failed.\n");
2363 return QLA_MEMORY_ALLOC_FAILED
;
2365 memset(pmap
, 0, FCAL_MAP_SIZE
);
2367 mcp
->mb
[0] = MBC_GET_FC_AL_POSITION_MAP
;
2368 mcp
->mb
[2] = MSW(pmap_dma
);
2369 mcp
->mb
[3] = LSW(pmap_dma
);
2370 mcp
->mb
[6] = MSW(MSD(pmap_dma
));
2371 mcp
->mb
[7] = LSW(MSD(pmap_dma
));
2372 mcp
->out_mb
= MBX_7
|MBX_6
|MBX_3
|MBX_2
|MBX_0
;
2373 mcp
->in_mb
= MBX_1
|MBX_0
;
2374 mcp
->buf_size
= FCAL_MAP_SIZE
;
2375 mcp
->flags
= MBX_DMA_IN
;
2376 mcp
->tov
= (ha
->login_timeout
* 2) + (ha
->login_timeout
/ 2);
2377 rval
= qla2x00_mailbox_command(vha
, mcp
);
2379 if (rval
== QLA_SUCCESS
) {
2380 ql_dbg(ql_dbg_mbx
+ ql_dbg_buffer
, vha
, 0x1081,
2381 "mb0/mb1=%x/%X FC/AL position map size (%x).\n",
2382 mcp
->mb
[0], mcp
->mb
[1], (unsigned)pmap
[0]);
2383 ql_dump_buffer(ql_dbg_mbx
+ ql_dbg_buffer
, vha
, 0x111d,
2387 memcpy(pos_map
, pmap
, FCAL_MAP_SIZE
);
2389 dma_pool_free(ha
->s_dma_pool
, pmap
, pmap_dma
);
2391 if (rval
!= QLA_SUCCESS
) {
2392 ql_dbg(ql_dbg_mbx
, vha
, 0x1082, "Failed=%x.\n", rval
);
2394 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x1083,
2395 "Done %s.\n", __func__
);
2402 * qla2x00_get_link_status
2405 * ha = adapter block pointer.
2406 * loop_id = device loop ID.
2407 * ret_buf = pointer to link status return buffer.
2411 * BIT_0 = mem alloc error.
2412 * BIT_1 = mailbox error.
2415 qla2x00_get_link_status(scsi_qla_host_t
*vha
, uint16_t loop_id
,
2416 struct link_statistics
*stats
, dma_addr_t stats_dma
)
2420 mbx_cmd_t
*mcp
= &mc
;
2421 uint32_t *siter
, *diter
, dwords
;
2422 struct qla_hw_data
*ha
= vha
->hw
;
2424 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x1084,
2425 "Entered %s.\n", __func__
);
2427 mcp
->mb
[0] = MBC_GET_LINK_STATUS
;
2428 mcp
->mb
[2] = MSW(stats_dma
);
2429 mcp
->mb
[3] = LSW(stats_dma
);
2430 mcp
->mb
[6] = MSW(MSD(stats_dma
));
2431 mcp
->mb
[7] = LSW(MSD(stats_dma
));
2432 mcp
->out_mb
= MBX_7
|MBX_6
|MBX_3
|MBX_2
|MBX_0
;
2434 if (IS_FWI2_CAPABLE(ha
)) {
2435 mcp
->mb
[1] = loop_id
;
2438 mcp
->out_mb
|= MBX_10
|MBX_4
|MBX_1
;
2439 mcp
->in_mb
|= MBX_1
;
2440 } else if (HAS_EXTENDED_IDS(ha
)) {
2441 mcp
->mb
[1] = loop_id
;
2443 mcp
->out_mb
|= MBX_10
|MBX_1
;
2445 mcp
->mb
[1] = loop_id
<< 8;
2446 mcp
->out_mb
|= MBX_1
;
2448 mcp
->tov
= MBX_TOV_SECONDS
;
2449 mcp
->flags
= IOCTL_CMD
;
2450 rval
= qla2x00_mailbox_command(vha
, mcp
);
2452 if (rval
== QLA_SUCCESS
) {
2453 if (mcp
->mb
[0] != MBS_COMMAND_COMPLETE
) {
2454 ql_dbg(ql_dbg_mbx
, vha
, 0x1085,
2455 "Failed=%x mb[0]=%x.\n", rval
, mcp
->mb
[0]);
2456 rval
= QLA_FUNCTION_FAILED
;
2458 /* Copy over data -- firmware data is LE. */
2459 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x1086,
2460 "Done %s.\n", __func__
);
2461 dwords
= offsetof(struct link_statistics
, unused1
) / 4;
2462 siter
= diter
= &stats
->link_fail_cnt
;
2464 *diter
++ = le32_to_cpu(*siter
++);
2468 ql_dbg(ql_dbg_mbx
, vha
, 0x1087, "Failed=%x.\n", rval
);
2475 qla24xx_get_isp_stats(scsi_qla_host_t
*vha
, struct link_statistics
*stats
,
2476 dma_addr_t stats_dma
)
2480 mbx_cmd_t
*mcp
= &mc
;
2481 uint32_t *siter
, *diter
, dwords
;
2483 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x1088,
2484 "Entered %s.\n", __func__
);
2486 mcp
->mb
[0] = MBC_GET_LINK_PRIV_STATS
;
2487 mcp
->mb
[2] = MSW(stats_dma
);
2488 mcp
->mb
[3] = LSW(stats_dma
);
2489 mcp
->mb
[6] = MSW(MSD(stats_dma
));
2490 mcp
->mb
[7] = LSW(MSD(stats_dma
));
2491 mcp
->mb
[8] = sizeof(struct link_statistics
) / 4;
2492 mcp
->mb
[9] = vha
->vp_idx
;
2494 mcp
->out_mb
= MBX_10
|MBX_9
|MBX_8
|MBX_7
|MBX_6
|MBX_3
|MBX_2
|MBX_0
;
2495 mcp
->in_mb
= MBX_2
|MBX_1
|MBX_0
;
2496 mcp
->tov
= MBX_TOV_SECONDS
;
2497 mcp
->flags
= IOCTL_CMD
;
2498 rval
= qla2x00_mailbox_command(vha
, mcp
);
2500 if (rval
== QLA_SUCCESS
) {
2501 if (mcp
->mb
[0] != MBS_COMMAND_COMPLETE
) {
2502 ql_dbg(ql_dbg_mbx
, vha
, 0x1089,
2503 "Failed mb[0]=%x.\n", mcp
->mb
[0]);
2504 rval
= QLA_FUNCTION_FAILED
;
2506 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x108a,
2507 "Done %s.\n", __func__
);
2508 /* Copy over data -- firmware data is LE. */
2509 dwords
= sizeof(struct link_statistics
) / 4;
2510 siter
= diter
= &stats
->link_fail_cnt
;
2512 *diter
++ = le32_to_cpu(*siter
++);
2516 ql_dbg(ql_dbg_mbx
, vha
, 0x108b, "Failed=%x.\n", rval
);
2523 qla24xx_abort_command(srb_t
*sp
)
2526 unsigned long flags
= 0;
2528 struct abort_entry_24xx
*abt
;
2531 fc_port_t
*fcport
= sp
->fcport
;
2532 struct scsi_qla_host
*vha
= fcport
->vha
;
2533 struct qla_hw_data
*ha
= vha
->hw
;
2534 struct req_que
*req
= vha
->req
;
2536 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x108c,
2537 "Entered %s.\n", __func__
);
2539 spin_lock_irqsave(&ha
->hardware_lock
, flags
);
2540 for (handle
= 1; handle
< MAX_OUTSTANDING_COMMANDS
; handle
++) {
2541 if (req
->outstanding_cmds
[handle
] == sp
)
2544 spin_unlock_irqrestore(&ha
->hardware_lock
, flags
);
2545 if (handle
== MAX_OUTSTANDING_COMMANDS
) {
2546 /* Command not found. */
2547 return QLA_FUNCTION_FAILED
;
2550 abt
= dma_pool_alloc(ha
->s_dma_pool
, GFP_KERNEL
, &abt_dma
);
2552 ql_log(ql_log_warn
, vha
, 0x108d,
2553 "Failed to allocate abort IOCB.\n");
2554 return QLA_MEMORY_ALLOC_FAILED
;
2556 memset(abt
, 0, sizeof(struct abort_entry_24xx
));
2558 abt
->entry_type
= ABORT_IOCB_TYPE
;
2559 abt
->entry_count
= 1;
2560 abt
->handle
= MAKE_HANDLE(req
->id
, abt
->handle
);
2561 abt
->nport_handle
= cpu_to_le16(fcport
->loop_id
);
2562 abt
->handle_to_abort
= MAKE_HANDLE(req
->id
, handle
);
2563 abt
->port_id
[0] = fcport
->d_id
.b
.al_pa
;
2564 abt
->port_id
[1] = fcport
->d_id
.b
.area
;
2565 abt
->port_id
[2] = fcport
->d_id
.b
.domain
;
2566 abt
->vp_index
= fcport
->vha
->vp_idx
;
2568 abt
->req_que_no
= cpu_to_le16(req
->id
);
2570 rval
= qla2x00_issue_iocb(vha
, abt
, abt_dma
, 0);
2571 if (rval
!= QLA_SUCCESS
) {
2572 ql_dbg(ql_dbg_mbx
, vha
, 0x108e,
2573 "Failed to issue IOCB (%x).\n", rval
);
2574 } else if (abt
->entry_status
!= 0) {
2575 ql_dbg(ql_dbg_mbx
, vha
, 0x108f,
2576 "Failed to complete IOCB -- error status (%x).\n",
2578 rval
= QLA_FUNCTION_FAILED
;
2579 } else if (abt
->nport_handle
!= __constant_cpu_to_le16(0)) {
2580 ql_dbg(ql_dbg_mbx
, vha
, 0x1090,
2581 "Failed to complete IOCB -- completion status (%x).\n",
2582 le16_to_cpu(abt
->nport_handle
));
2583 rval
= QLA_FUNCTION_FAILED
;
2585 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x1091,
2586 "Done %s.\n", __func__
);
2589 dma_pool_free(ha
->s_dma_pool
, abt
, abt_dma
);
2594 struct tsk_mgmt_cmd
{
2596 struct tsk_mgmt_entry tsk
;
2597 struct sts_entry_24xx sts
;
2602 __qla24xx_issue_tmf(char *name
, uint32_t type
, struct fc_port
*fcport
,
2603 unsigned int l
, int tag
)
2606 struct tsk_mgmt_cmd
*tsk
;
2607 struct sts_entry_24xx
*sts
;
2609 scsi_qla_host_t
*vha
;
2610 struct qla_hw_data
*ha
;
2611 struct req_que
*req
;
2612 struct rsp_que
*rsp
;
2618 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x1092,
2619 "Entered %s.\n", __func__
);
2621 if (ha
->flags
.cpu_affinity_enabled
)
2622 rsp
= ha
->rsp_q_map
[tag
+ 1];
2625 tsk
= dma_pool_alloc(ha
->s_dma_pool
, GFP_KERNEL
, &tsk_dma
);
2627 ql_log(ql_log_warn
, vha
, 0x1093,
2628 "Failed to allocate task management IOCB.\n");
2629 return QLA_MEMORY_ALLOC_FAILED
;
2631 memset(tsk
, 0, sizeof(struct tsk_mgmt_cmd
));
2633 tsk
->p
.tsk
.entry_type
= TSK_MGMT_IOCB_TYPE
;
2634 tsk
->p
.tsk
.entry_count
= 1;
2635 tsk
->p
.tsk
.handle
= MAKE_HANDLE(req
->id
, tsk
->p
.tsk
.handle
);
2636 tsk
->p
.tsk
.nport_handle
= cpu_to_le16(fcport
->loop_id
);
2637 tsk
->p
.tsk
.timeout
= cpu_to_le16(ha
->r_a_tov
/ 10 * 2);
2638 tsk
->p
.tsk
.control_flags
= cpu_to_le32(type
);
2639 tsk
->p
.tsk
.port_id
[0] = fcport
->d_id
.b
.al_pa
;
2640 tsk
->p
.tsk
.port_id
[1] = fcport
->d_id
.b
.area
;
2641 tsk
->p
.tsk
.port_id
[2] = fcport
->d_id
.b
.domain
;
2642 tsk
->p
.tsk
.vp_index
= fcport
->vha
->vp_idx
;
2643 if (type
== TCF_LUN_RESET
) {
2644 int_to_scsilun(l
, &tsk
->p
.tsk
.lun
);
2645 host_to_fcp_swap((uint8_t *)&tsk
->p
.tsk
.lun
,
2646 sizeof(tsk
->p
.tsk
.lun
));
2650 rval
= qla2x00_issue_iocb(vha
, tsk
, tsk_dma
, 0);
2651 if (rval
!= QLA_SUCCESS
) {
2652 ql_dbg(ql_dbg_mbx
, vha
, 0x1094,
2653 "Failed to issue %s reset IOCB (%x).\n", name
, rval
);
2654 } else if (sts
->entry_status
!= 0) {
2655 ql_dbg(ql_dbg_mbx
, vha
, 0x1095,
2656 "Failed to complete IOCB -- error status (%x).\n",
2658 rval
= QLA_FUNCTION_FAILED
;
2659 } else if (sts
->comp_status
!=
2660 __constant_cpu_to_le16(CS_COMPLETE
)) {
2661 ql_dbg(ql_dbg_mbx
, vha
, 0x1096,
2662 "Failed to complete IOCB -- completion status (%x).\n",
2663 le16_to_cpu(sts
->comp_status
));
2664 rval
= QLA_FUNCTION_FAILED
;
2665 } else if (le16_to_cpu(sts
->scsi_status
) &
2666 SS_RESPONSE_INFO_LEN_VALID
) {
2667 if (le32_to_cpu(sts
->rsp_data_len
) < 4) {
2668 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x1097,
2669 "Ignoring inconsistent data length -- not enough "
2670 "response info (%d).\n",
2671 le32_to_cpu(sts
->rsp_data_len
));
2672 } else if (sts
->data
[3]) {
2673 ql_dbg(ql_dbg_mbx
, vha
, 0x1098,
2674 "Failed to complete IOCB -- response (%x).\n",
2676 rval
= QLA_FUNCTION_FAILED
;
2680 /* Issue marker IOCB. */
2681 rval2
= qla2x00_marker(vha
, req
, rsp
, fcport
->loop_id
, l
,
2682 type
== TCF_LUN_RESET
? MK_SYNC_ID_LUN
: MK_SYNC_ID
);
2683 if (rval2
!= QLA_SUCCESS
) {
2684 ql_dbg(ql_dbg_mbx
, vha
, 0x1099,
2685 "Failed to issue marker IOCB (%x).\n", rval2
);
2687 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x109a,
2688 "Done %s.\n", __func__
);
2691 dma_pool_free(ha
->s_dma_pool
, tsk
, tsk_dma
);
2697 qla24xx_abort_target(struct fc_port
*fcport
, unsigned int l
, int tag
)
2699 struct qla_hw_data
*ha
= fcport
->vha
->hw
;
2701 if ((ql2xasynctmfenable
) && IS_FWI2_CAPABLE(ha
))
2702 return qla2x00_async_tm_cmd(fcport
, TCF_TARGET_RESET
, l
, tag
);
2704 return __qla24xx_issue_tmf("Target", TCF_TARGET_RESET
, fcport
, l
, tag
);
2708 qla24xx_lun_reset(struct fc_port
*fcport
, unsigned int l
, int tag
)
2710 struct qla_hw_data
*ha
= fcport
->vha
->hw
;
2712 if ((ql2xasynctmfenable
) && IS_FWI2_CAPABLE(ha
))
2713 return qla2x00_async_tm_cmd(fcport
, TCF_LUN_RESET
, l
, tag
);
2715 return __qla24xx_issue_tmf("Lun", TCF_LUN_RESET
, fcport
, l
, tag
);
2719 qla2x00_system_error(scsi_qla_host_t
*vha
)
2723 mbx_cmd_t
*mcp
= &mc
;
2724 struct qla_hw_data
*ha
= vha
->hw
;
2726 if (!IS_QLA23XX(ha
) && !IS_FWI2_CAPABLE(ha
))
2727 return QLA_FUNCTION_FAILED
;
2729 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x109b,
2730 "Entered %s.\n", __func__
);
2732 mcp
->mb
[0] = MBC_GEN_SYSTEM_ERROR
;
2733 mcp
->out_mb
= MBX_0
;
2737 rval
= qla2x00_mailbox_command(vha
, mcp
);
2739 if (rval
!= QLA_SUCCESS
) {
2740 ql_dbg(ql_dbg_mbx
, vha
, 0x109c, "Failed=%x.\n", rval
);
2742 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x109d,
2743 "Done %s.\n", __func__
);
2750 * qla2x00_set_serdes_params() -
2756 qla2x00_set_serdes_params(scsi_qla_host_t
*vha
, uint16_t sw_em_1g
,
2757 uint16_t sw_em_2g
, uint16_t sw_em_4g
)
2761 mbx_cmd_t
*mcp
= &mc
;
2763 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x109e,
2764 "Entered %s.\n", __func__
);
2766 mcp
->mb
[0] = MBC_SERDES_PARAMS
;
2768 mcp
->mb
[2] = sw_em_1g
| BIT_15
;
2769 mcp
->mb
[3] = sw_em_2g
| BIT_15
;
2770 mcp
->mb
[4] = sw_em_4g
| BIT_15
;
2771 mcp
->out_mb
= MBX_4
|MBX_3
|MBX_2
|MBX_1
|MBX_0
;
2773 mcp
->tov
= MBX_TOV_SECONDS
;
2775 rval
= qla2x00_mailbox_command(vha
, mcp
);
2777 if (rval
!= QLA_SUCCESS
) {
2779 ql_dbg(ql_dbg_mbx
, vha
, 0x109f,
2780 "Failed=%x mb[0]=%x.\n", rval
, mcp
->mb
[0]);
2783 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x10a0,
2784 "Done %s.\n", __func__
);
2791 qla2x00_stop_firmware(scsi_qla_host_t
*vha
)
2795 mbx_cmd_t
*mcp
= &mc
;
2797 if (!IS_FWI2_CAPABLE(vha
->hw
))
2798 return QLA_FUNCTION_FAILED
;
2800 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x10a1,
2801 "Entered %s.\n", __func__
);
2803 mcp
->mb
[0] = MBC_STOP_FIRMWARE
;
2805 mcp
->out_mb
= MBX_1
|MBX_0
;
2809 rval
= qla2x00_mailbox_command(vha
, mcp
);
2811 if (rval
!= QLA_SUCCESS
) {
2812 ql_dbg(ql_dbg_mbx
, vha
, 0x10a2, "Failed=%x.\n", rval
);
2813 if (mcp
->mb
[0] == MBS_INVALID_COMMAND
)
2814 rval
= QLA_INVALID_COMMAND
;
2816 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x10a3,
2817 "Done %s.\n", __func__
);
2824 qla2x00_enable_eft_trace(scsi_qla_host_t
*vha
, dma_addr_t eft_dma
,
2829 mbx_cmd_t
*mcp
= &mc
;
2831 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x10a4,
2832 "Entered %s.\n", __func__
);
2834 if (!IS_FWI2_CAPABLE(vha
->hw
))
2835 return QLA_FUNCTION_FAILED
;
2837 if (unlikely(pci_channel_offline(vha
->hw
->pdev
)))
2838 return QLA_FUNCTION_FAILED
;
2840 mcp
->mb
[0] = MBC_TRACE_CONTROL
;
2841 mcp
->mb
[1] = TC_EFT_ENABLE
;
2842 mcp
->mb
[2] = LSW(eft_dma
);
2843 mcp
->mb
[3] = MSW(eft_dma
);
2844 mcp
->mb
[4] = LSW(MSD(eft_dma
));
2845 mcp
->mb
[5] = MSW(MSD(eft_dma
));
2846 mcp
->mb
[6] = buffers
;
2847 mcp
->mb
[7] = TC_AEN_DISABLE
;
2848 mcp
->out_mb
= MBX_7
|MBX_6
|MBX_5
|MBX_4
|MBX_3
|MBX_2
|MBX_1
|MBX_0
;
2849 mcp
->in_mb
= MBX_1
|MBX_0
;
2850 mcp
->tov
= MBX_TOV_SECONDS
;
2852 rval
= qla2x00_mailbox_command(vha
, mcp
);
2853 if (rval
!= QLA_SUCCESS
) {
2854 ql_dbg(ql_dbg_mbx
, vha
, 0x10a5,
2855 "Failed=%x mb[0]=%x mb[1]=%x.\n",
2856 rval
, mcp
->mb
[0], mcp
->mb
[1]);
2858 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x10a6,
2859 "Done %s.\n", __func__
);
2866 qla2x00_disable_eft_trace(scsi_qla_host_t
*vha
)
2870 mbx_cmd_t
*mcp
= &mc
;
2872 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x10a7,
2873 "Entered %s.\n", __func__
);
2875 if (!IS_FWI2_CAPABLE(vha
->hw
))
2876 return QLA_FUNCTION_FAILED
;
2878 if (unlikely(pci_channel_offline(vha
->hw
->pdev
)))
2879 return QLA_FUNCTION_FAILED
;
2881 mcp
->mb
[0] = MBC_TRACE_CONTROL
;
2882 mcp
->mb
[1] = TC_EFT_DISABLE
;
2883 mcp
->out_mb
= MBX_1
|MBX_0
;
2884 mcp
->in_mb
= MBX_1
|MBX_0
;
2885 mcp
->tov
= MBX_TOV_SECONDS
;
2887 rval
= qla2x00_mailbox_command(vha
, mcp
);
2888 if (rval
!= QLA_SUCCESS
) {
2889 ql_dbg(ql_dbg_mbx
, vha
, 0x10a8,
2890 "Failed=%x mb[0]=%x mb[1]=%x.\n",
2891 rval
, mcp
->mb
[0], mcp
->mb
[1]);
2893 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x10a9,
2894 "Done %s.\n", __func__
);
2901 qla2x00_enable_fce_trace(scsi_qla_host_t
*vha
, dma_addr_t fce_dma
,
2902 uint16_t buffers
, uint16_t *mb
, uint32_t *dwords
)
2906 mbx_cmd_t
*mcp
= &mc
;
2908 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x10aa,
2909 "Entered %s.\n", __func__
);
2911 if (!IS_QLA25XX(vha
->hw
) && !IS_QLA81XX(vha
->hw
) &&
2912 !IS_QLA83XX(vha
->hw
))
2913 return QLA_FUNCTION_FAILED
;
2915 if (unlikely(pci_channel_offline(vha
->hw
->pdev
)))
2916 return QLA_FUNCTION_FAILED
;
2918 mcp
->mb
[0] = MBC_TRACE_CONTROL
;
2919 mcp
->mb
[1] = TC_FCE_ENABLE
;
2920 mcp
->mb
[2] = LSW(fce_dma
);
2921 mcp
->mb
[3] = MSW(fce_dma
);
2922 mcp
->mb
[4] = LSW(MSD(fce_dma
));
2923 mcp
->mb
[5] = MSW(MSD(fce_dma
));
2924 mcp
->mb
[6] = buffers
;
2925 mcp
->mb
[7] = TC_AEN_DISABLE
;
2927 mcp
->mb
[9] = TC_FCE_DEFAULT_RX_SIZE
;
2928 mcp
->mb
[10] = TC_FCE_DEFAULT_TX_SIZE
;
2929 mcp
->out_mb
= MBX_10
|MBX_9
|MBX_8
|MBX_7
|MBX_6
|MBX_5
|MBX_4
|MBX_3
|MBX_2
|
2931 mcp
->in_mb
= MBX_6
|MBX_5
|MBX_4
|MBX_3
|MBX_2
|MBX_1
|MBX_0
;
2932 mcp
->tov
= MBX_TOV_SECONDS
;
2934 rval
= qla2x00_mailbox_command(vha
, mcp
);
2935 if (rval
!= QLA_SUCCESS
) {
2936 ql_dbg(ql_dbg_mbx
, vha
, 0x10ab,
2937 "Failed=%x mb[0]=%x mb[1]=%x.\n",
2938 rval
, mcp
->mb
[0], mcp
->mb
[1]);
2940 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x10ac,
2941 "Done %s.\n", __func__
);
2944 memcpy(mb
, mcp
->mb
, 8 * sizeof(*mb
));
2953 qla2x00_disable_fce_trace(scsi_qla_host_t
*vha
, uint64_t *wr
, uint64_t *rd
)
2957 mbx_cmd_t
*mcp
= &mc
;
2959 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x10ad,
2960 "Entered %s.\n", __func__
);
2962 if (!IS_FWI2_CAPABLE(vha
->hw
))
2963 return QLA_FUNCTION_FAILED
;
2965 if (unlikely(pci_channel_offline(vha
->hw
->pdev
)))
2966 return QLA_FUNCTION_FAILED
;
2968 mcp
->mb
[0] = MBC_TRACE_CONTROL
;
2969 mcp
->mb
[1] = TC_FCE_DISABLE
;
2970 mcp
->mb
[2] = TC_FCE_DISABLE_TRACE
;
2971 mcp
->out_mb
= MBX_2
|MBX_1
|MBX_0
;
2972 mcp
->in_mb
= MBX_9
|MBX_8
|MBX_7
|MBX_6
|MBX_5
|MBX_4
|MBX_3
|MBX_2
|
2974 mcp
->tov
= MBX_TOV_SECONDS
;
2976 rval
= qla2x00_mailbox_command(vha
, mcp
);
2977 if (rval
!= QLA_SUCCESS
) {
2978 ql_dbg(ql_dbg_mbx
, vha
, 0x10ae,
2979 "Failed=%x mb[0]=%x mb[1]=%x.\n",
2980 rval
, mcp
->mb
[0], mcp
->mb
[1]);
2982 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x10af,
2983 "Done %s.\n", __func__
);
2986 *wr
= (uint64_t) mcp
->mb
[5] << 48 |
2987 (uint64_t) mcp
->mb
[4] << 32 |
2988 (uint64_t) mcp
->mb
[3] << 16 |
2989 (uint64_t) mcp
->mb
[2];
2991 *rd
= (uint64_t) mcp
->mb
[9] << 48 |
2992 (uint64_t) mcp
->mb
[8] << 32 |
2993 (uint64_t) mcp
->mb
[7] << 16 |
2994 (uint64_t) mcp
->mb
[6];
3001 qla2x00_get_idma_speed(scsi_qla_host_t
*vha
, uint16_t loop_id
,
3002 uint16_t *port_speed
, uint16_t *mb
)
3006 mbx_cmd_t
*mcp
= &mc
;
3008 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x10b0,
3009 "Entered %s.\n", __func__
);
3011 if (!IS_IIDMA_CAPABLE(vha
->hw
))
3012 return QLA_FUNCTION_FAILED
;
3014 mcp
->mb
[0] = MBC_PORT_PARAMS
;
3015 mcp
->mb
[1] = loop_id
;
3016 mcp
->mb
[2] = mcp
->mb
[3] = 0;
3017 mcp
->mb
[9] = vha
->vp_idx
;
3018 mcp
->out_mb
= MBX_9
|MBX_3
|MBX_2
|MBX_1
|MBX_0
;
3019 mcp
->in_mb
= MBX_3
|MBX_1
|MBX_0
;
3020 mcp
->tov
= MBX_TOV_SECONDS
;
3022 rval
= qla2x00_mailbox_command(vha
, mcp
);
3024 /* Return mailbox statuses. */
3031 if (rval
!= QLA_SUCCESS
) {
3032 ql_dbg(ql_dbg_mbx
, vha
, 0x10b1, "Failed=%x.\n", rval
);
3034 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x10b2,
3035 "Done %s.\n", __func__
);
3037 *port_speed
= mcp
->mb
[3];
3044 qla2x00_set_idma_speed(scsi_qla_host_t
*vha
, uint16_t loop_id
,
3045 uint16_t port_speed
, uint16_t *mb
)
3049 mbx_cmd_t
*mcp
= &mc
;
3051 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x10b3,
3052 "Entered %s.\n", __func__
);
3054 if (!IS_IIDMA_CAPABLE(vha
->hw
))
3055 return QLA_FUNCTION_FAILED
;
3057 mcp
->mb
[0] = MBC_PORT_PARAMS
;
3058 mcp
->mb
[1] = loop_id
;
3060 if (IS_CNA_CAPABLE(vha
->hw
))
3061 mcp
->mb
[3] = port_speed
& (BIT_5
|BIT_4
|BIT_3
|BIT_2
|BIT_1
|BIT_0
);
3063 mcp
->mb
[3] = port_speed
& (BIT_2
|BIT_1
|BIT_0
);
3064 mcp
->mb
[9] = vha
->vp_idx
;
3065 mcp
->out_mb
= MBX_9
|MBX_3
|MBX_2
|MBX_1
|MBX_0
;
3066 mcp
->in_mb
= MBX_3
|MBX_1
|MBX_0
;
3067 mcp
->tov
= MBX_TOV_SECONDS
;
3069 rval
= qla2x00_mailbox_command(vha
, mcp
);
3071 /* Return mailbox statuses. */
3078 if (rval
!= QLA_SUCCESS
) {
3079 ql_dbg(ql_dbg_mbx
, vha
, 0x10b4,
3080 "Failed=%x.\n", rval
);
3082 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x10b5,
3083 "Done %s.\n", __func__
);
3090 qla24xx_report_id_acquisition(scsi_qla_host_t
*vha
,
3091 struct vp_rpt_id_entry_24xx
*rptid_entry
)
3094 uint16_t stat
= le16_to_cpu(rptid_entry
->vp_idx
);
3095 struct qla_hw_data
*ha
= vha
->hw
;
3096 scsi_qla_host_t
*vp
;
3097 unsigned long flags
;
3099 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x10b6,
3100 "Entered %s.\n", __func__
);
3102 if (rptid_entry
->entry_status
!= 0)
3105 if (rptid_entry
->format
== 0) {
3106 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x10b7,
3107 "Format 0 : Number of VPs setup %d, number of "
3108 "VPs acquired %d.\n",
3109 MSB(le16_to_cpu(rptid_entry
->vp_count
)),
3110 LSB(le16_to_cpu(rptid_entry
->vp_count
)));
3111 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x10b8,
3112 "Primary port id %02x%02x%02x.\n",
3113 rptid_entry
->port_id
[2], rptid_entry
->port_id
[1],
3114 rptid_entry
->port_id
[0]);
3115 } else if (rptid_entry
->format
== 1) {
3117 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x10b9,
3118 "Format 1: VP[%d] enabled - status %d - with "
3119 "port id %02x%02x%02x.\n", vp_idx
, MSB(stat
),
3120 rptid_entry
->port_id
[2], rptid_entry
->port_id
[1],
3121 rptid_entry
->port_id
[0]);
3124 if (vp_idx
== 0 && (MSB(stat
) != 1))
3127 if (MSB(stat
) != 0) {
3128 ql_dbg(ql_dbg_mbx
, vha
, 0x10ba,
3129 "Could not acquire ID for VP[%d].\n", vp_idx
);
3133 spin_lock_irqsave(&ha
->vport_slock
, flags
);
3134 list_for_each_entry(vp
, &ha
->vp_list
, list
)
3135 if (vp_idx
== vp
->vp_idx
)
3137 spin_unlock_irqrestore(&ha
->vport_slock
, flags
);
3142 vp
->d_id
.b
.domain
= rptid_entry
->port_id
[2];
3143 vp
->d_id
.b
.area
= rptid_entry
->port_id
[1];
3144 vp
->d_id
.b
.al_pa
= rptid_entry
->port_id
[0];
3147 * Cannot configure here as we are still sitting on the
3148 * response queue. Handle it in dpc context.
3150 set_bit(VP_IDX_ACQUIRED
, &vp
->vp_flags
);
3153 set_bit(REGISTER_FC4_NEEDED
, &vp
->dpc_flags
);
3154 set_bit(REGISTER_FDMI_NEEDED
, &vp
->dpc_flags
);
3155 set_bit(VP_DPC_NEEDED
, &vha
->dpc_flags
);
3156 qla2xxx_wake_dpc(vha
);
3161 * qla24xx_modify_vp_config
3162 * Change VP configuration for vha
3165 * vha = adapter block pointer.
3168 * qla2xxx local function return status code.
3174 qla24xx_modify_vp_config(scsi_qla_host_t
*vha
)
3177 struct vp_config_entry_24xx
*vpmod
;
3178 dma_addr_t vpmod_dma
;
3179 struct qla_hw_data
*ha
= vha
->hw
;
3180 struct scsi_qla_host
*base_vha
= pci_get_drvdata(ha
->pdev
);
3182 /* This can be called by the parent */
3184 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x10bb,
3185 "Entered %s.\n", __func__
);
3187 vpmod
= dma_pool_alloc(ha
->s_dma_pool
, GFP_KERNEL
, &vpmod_dma
);
3189 ql_log(ql_log_warn
, vha
, 0x10bc,
3190 "Failed to allocate modify VP IOCB.\n");
3191 return QLA_MEMORY_ALLOC_FAILED
;
3194 memset(vpmod
, 0, sizeof(struct vp_config_entry_24xx
));
3195 vpmod
->entry_type
= VP_CONFIG_IOCB_TYPE
;
3196 vpmod
->entry_count
= 1;
3197 vpmod
->command
= VCT_COMMAND_MOD_ENABLE_VPS
;
3198 vpmod
->vp_count
= 1;
3199 vpmod
->vp_index1
= vha
->vp_idx
;
3200 vpmod
->options_idx1
= BIT_3
|BIT_4
|BIT_5
;
3202 qlt_modify_vp_config(vha
, vpmod
);
3204 memcpy(vpmod
->node_name_idx1
, vha
->node_name
, WWN_SIZE
);
3205 memcpy(vpmod
->port_name_idx1
, vha
->port_name
, WWN_SIZE
);
3206 vpmod
->entry_count
= 1;
3208 rval
= qla2x00_issue_iocb(base_vha
, vpmod
, vpmod_dma
, 0);
3209 if (rval
!= QLA_SUCCESS
) {
3210 ql_dbg(ql_dbg_mbx
, vha
, 0x10bd,
3211 "Failed to issue VP config IOCB (%x).\n", rval
);
3212 } else if (vpmod
->comp_status
!= 0) {
3213 ql_dbg(ql_dbg_mbx
, vha
, 0x10be,
3214 "Failed to complete IOCB -- error status (%x).\n",
3215 vpmod
->comp_status
);
3216 rval
= QLA_FUNCTION_FAILED
;
3217 } else if (vpmod
->comp_status
!= __constant_cpu_to_le16(CS_COMPLETE
)) {
3218 ql_dbg(ql_dbg_mbx
, vha
, 0x10bf,
3219 "Failed to complete IOCB -- completion status (%x).\n",
3220 le16_to_cpu(vpmod
->comp_status
));
3221 rval
= QLA_FUNCTION_FAILED
;
3224 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x10c0,
3225 "Done %s.\n", __func__
);
3226 fc_vport_set_state(vha
->fc_vport
, FC_VPORT_INITIALIZING
);
3228 dma_pool_free(ha
->s_dma_pool
, vpmod
, vpmod_dma
);
3234 * qla24xx_control_vp
3235 * Enable a virtual port for given host
3238 * ha = adapter block pointer.
3239 * vhba = virtual adapter (unused)
3240 * index = index number for enabled VP
3243 * qla2xxx local function return status code.
3249 qla24xx_control_vp(scsi_qla_host_t
*vha
, int cmd
)
3253 struct vp_ctrl_entry_24xx
*vce
;
3255 struct qla_hw_data
*ha
= vha
->hw
;
3256 int vp_index
= vha
->vp_idx
;
3257 struct scsi_qla_host
*base_vha
= pci_get_drvdata(ha
->pdev
);
3259 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x10c1,
3260 "Entered %s enabling index %d.\n", __func__
, vp_index
);
3262 if (vp_index
== 0 || vp_index
>= ha
->max_npiv_vports
)
3263 return QLA_PARAMETER_ERROR
;
3265 vce
= dma_pool_alloc(ha
->s_dma_pool
, GFP_KERNEL
, &vce_dma
);
3267 ql_log(ql_log_warn
, vha
, 0x10c2,
3268 "Failed to allocate VP control IOCB.\n");
3269 return QLA_MEMORY_ALLOC_FAILED
;
3271 memset(vce
, 0, sizeof(struct vp_ctrl_entry_24xx
));
3273 vce
->entry_type
= VP_CTRL_IOCB_TYPE
;
3274 vce
->entry_count
= 1;
3275 vce
->command
= cpu_to_le16(cmd
);
3276 vce
->vp_count
= __constant_cpu_to_le16(1);
3278 /* index map in firmware starts with 1; decrement index
3279 * this is ok as we never use index 0
3281 map
= (vp_index
- 1) / 8;
3282 pos
= (vp_index
- 1) & 7;
3283 mutex_lock(&ha
->vport_lock
);
3284 vce
->vp_idx_map
[map
] |= 1 << pos
;
3285 mutex_unlock(&ha
->vport_lock
);
3287 rval
= qla2x00_issue_iocb(base_vha
, vce
, vce_dma
, 0);
3288 if (rval
!= QLA_SUCCESS
) {
3289 ql_dbg(ql_dbg_mbx
, vha
, 0x10c3,
3290 "Failed to issue VP control IOCB (%x).\n", rval
);
3291 } else if (vce
->entry_status
!= 0) {
3292 ql_dbg(ql_dbg_mbx
, vha
, 0x10c4,
3293 "Failed to complete IOCB -- error status (%x).\n",
3295 rval
= QLA_FUNCTION_FAILED
;
3296 } else if (vce
->comp_status
!= __constant_cpu_to_le16(CS_COMPLETE
)) {
3297 ql_dbg(ql_dbg_mbx
, vha
, 0x10c5,
3298 "Failed to complet IOCB -- completion status (%x).\n",
3299 le16_to_cpu(vce
->comp_status
));
3300 rval
= QLA_FUNCTION_FAILED
;
3302 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x10c6,
3303 "Done %s.\n", __func__
);
3306 dma_pool_free(ha
->s_dma_pool
, vce
, vce_dma
);
3312 * qla2x00_send_change_request
3313 * Receive or disable RSCN request from fabric controller
3316 * ha = adapter block pointer
3317 * format = registration format:
3319 * 1 - Fabric detected registration
3320 * 2 - N_port detected registration
3321 * 3 - Full registration
3322 * FF - clear registration
3323 * vp_idx = Virtual port index
3326 * qla2x00 local function return status code.
3333 qla2x00_send_change_request(scsi_qla_host_t
*vha
, uint16_t format
,
3338 mbx_cmd_t
*mcp
= &mc
;
3340 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x10c7,
3341 "Entered %s.\n", __func__
);
3343 mcp
->mb
[0] = MBC_SEND_CHANGE_REQUEST
;
3344 mcp
->mb
[1] = format
;
3345 mcp
->mb
[9] = vp_idx
;
3346 mcp
->out_mb
= MBX_9
|MBX_1
|MBX_0
;
3347 mcp
->in_mb
= MBX_0
|MBX_1
;
3348 mcp
->tov
= MBX_TOV_SECONDS
;
3350 rval
= qla2x00_mailbox_command(vha
, mcp
);
3352 if (rval
== QLA_SUCCESS
) {
3353 if (mcp
->mb
[0] != MBS_COMMAND_COMPLETE
) {
3363 qla2x00_dump_ram(scsi_qla_host_t
*vha
, dma_addr_t req_dma
, uint32_t addr
,
3368 mbx_cmd_t
*mcp
= &mc
;
3370 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x1009,
3371 "Entered %s.\n", __func__
);
3373 if (MSW(addr
) || IS_FWI2_CAPABLE(vha
->hw
)) {
3374 mcp
->mb
[0] = MBC_DUMP_RISC_RAM_EXTENDED
;
3375 mcp
->mb
[8] = MSW(addr
);
3376 mcp
->out_mb
= MBX_8
|MBX_0
;
3378 mcp
->mb
[0] = MBC_DUMP_RISC_RAM
;
3379 mcp
->out_mb
= MBX_0
;
3381 mcp
->mb
[1] = LSW(addr
);
3382 mcp
->mb
[2] = MSW(req_dma
);
3383 mcp
->mb
[3] = LSW(req_dma
);
3384 mcp
->mb
[6] = MSW(MSD(req_dma
));
3385 mcp
->mb
[7] = LSW(MSD(req_dma
));
3386 mcp
->out_mb
|= MBX_7
|MBX_6
|MBX_3
|MBX_2
|MBX_1
;
3387 if (IS_FWI2_CAPABLE(vha
->hw
)) {
3388 mcp
->mb
[4] = MSW(size
);
3389 mcp
->mb
[5] = LSW(size
);
3390 mcp
->out_mb
|= MBX_5
|MBX_4
;
3392 mcp
->mb
[4] = LSW(size
);
3393 mcp
->out_mb
|= MBX_4
;
3397 mcp
->tov
= MBX_TOV_SECONDS
;
3399 rval
= qla2x00_mailbox_command(vha
, mcp
);
3401 if (rval
!= QLA_SUCCESS
) {
3402 ql_dbg(ql_dbg_mbx
, vha
, 0x1008,
3403 "Failed=%x mb[0]=%x.\n", rval
, mcp
->mb
[0]);
3405 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x1007,
3406 "Done %s.\n", __func__
);
3412 /* 84XX Support **************************************************************/
3414 struct cs84xx_mgmt_cmd
{
3416 struct verify_chip_entry_84xx req
;
3417 struct verify_chip_rsp_84xx rsp
;
3422 qla84xx_verify_chip(struct scsi_qla_host
*vha
, uint16_t *status
)
3425 struct cs84xx_mgmt_cmd
*mn
;
3428 unsigned long flags
;
3429 struct qla_hw_data
*ha
= vha
->hw
;
3431 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x10c8,
3432 "Entered %s.\n", __func__
);
3434 mn
= dma_pool_alloc(ha
->s_dma_pool
, GFP_KERNEL
, &mn_dma
);
3436 return QLA_MEMORY_ALLOC_FAILED
;
3440 options
= ha
->cs84xx
->fw_update
? VCO_FORCE_UPDATE
: 0;
3441 /* Diagnostic firmware? */
3442 /* options |= MENLO_DIAG_FW; */
3443 /* We update the firmware with only one data sequence. */
3444 options
|= VCO_END_OF_DATA
;
3448 memset(mn
, 0, sizeof(*mn
));
3449 mn
->p
.req
.entry_type
= VERIFY_CHIP_IOCB_TYPE
;
3450 mn
->p
.req
.entry_count
= 1;
3451 mn
->p
.req
.options
= cpu_to_le16(options
);
3453 ql_dbg(ql_dbg_mbx
+ ql_dbg_buffer
, vha
, 0x111c,
3454 "Dump of Verify Request.\n");
3455 ql_dump_buffer(ql_dbg_mbx
+ ql_dbg_buffer
, vha
, 0x111e,
3456 (uint8_t *)mn
, sizeof(*mn
));
3458 rval
= qla2x00_issue_iocb_timeout(vha
, mn
, mn_dma
, 0, 120);
3459 if (rval
!= QLA_SUCCESS
) {
3460 ql_dbg(ql_dbg_mbx
, vha
, 0x10cb,
3461 "Failed to issue verify IOCB (%x).\n", rval
);
3465 ql_dbg(ql_dbg_mbx
+ ql_dbg_buffer
, vha
, 0x1110,
3466 "Dump of Verify Response.\n");
3467 ql_dump_buffer(ql_dbg_mbx
+ ql_dbg_buffer
, vha
, 0x1118,
3468 (uint8_t *)mn
, sizeof(*mn
));
3470 status
[0] = le16_to_cpu(mn
->p
.rsp
.comp_status
);
3471 status
[1] = status
[0] == CS_VCS_CHIP_FAILURE
?
3472 le16_to_cpu(mn
->p
.rsp
.failure_code
) : 0;
3473 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x10ce,
3474 "cs=%x fc=%x.\n", status
[0], status
[1]);
3476 if (status
[0] != CS_COMPLETE
) {
3477 rval
= QLA_FUNCTION_FAILED
;
3478 if (!(options
& VCO_DONT_UPDATE_FW
)) {
3479 ql_dbg(ql_dbg_mbx
, vha
, 0x10cf,
3480 "Firmware update failed. Retrying "
3481 "without update firmware.\n");
3482 options
|= VCO_DONT_UPDATE_FW
;
3483 options
&= ~VCO_FORCE_UPDATE
;
3487 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x10d0,
3488 "Firmware updated to %x.\n",
3489 le32_to_cpu(mn
->p
.rsp
.fw_ver
));
3491 /* NOTE: we only update OP firmware. */
3492 spin_lock_irqsave(&ha
->cs84xx
->access_lock
, flags
);
3493 ha
->cs84xx
->op_fw_version
=
3494 le32_to_cpu(mn
->p
.rsp
.fw_ver
);
3495 spin_unlock_irqrestore(&ha
->cs84xx
->access_lock
,
3501 dma_pool_free(ha
->s_dma_pool
, mn
, mn_dma
);
3503 if (rval
!= QLA_SUCCESS
) {
3504 ql_dbg(ql_dbg_mbx
, vha
, 0x10d1,
3505 "Failed=%x.\n", rval
);
3507 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x10d2,
3508 "Done %s.\n", __func__
);
3515 qla25xx_init_req_que(struct scsi_qla_host
*vha
, struct req_que
*req
)
3518 unsigned long flags
;
3520 mbx_cmd_t
*mcp
= &mc
;
3521 struct device_reg_25xxmq __iomem
*reg
;
3522 struct qla_hw_data
*ha
= vha
->hw
;
3524 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x10d3,
3525 "Entered %s.\n", __func__
);
3527 mcp
->mb
[0] = MBC_INITIALIZE_MULTIQ
;
3528 mcp
->mb
[1] = req
->options
;
3529 mcp
->mb
[2] = MSW(LSD(req
->dma
));
3530 mcp
->mb
[3] = LSW(LSD(req
->dma
));
3531 mcp
->mb
[6] = MSW(MSD(req
->dma
));
3532 mcp
->mb
[7] = LSW(MSD(req
->dma
));
3533 mcp
->mb
[5] = req
->length
;
3535 mcp
->mb
[10] = req
->rsp
->id
;
3536 mcp
->mb
[12] = req
->qos
;
3537 mcp
->mb
[11] = req
->vp_idx
;
3538 mcp
->mb
[13] = req
->rid
;
3542 reg
= (struct device_reg_25xxmq
*)((void *)(ha
->mqiobase
) +
3543 QLA_QUE_PAGE
* req
->id
);
3545 mcp
->mb
[4] = req
->id
;
3546 /* que in ptr index */
3548 /* que out ptr index */
3550 mcp
->out_mb
= MBX_14
|MBX_13
|MBX_12
|MBX_11
|MBX_10
|MBX_9
|MBX_8
|MBX_7
|
3551 MBX_6
|MBX_5
|MBX_4
|MBX_3
|MBX_2
|MBX_1
|MBX_0
;
3553 mcp
->flags
= MBX_DMA_OUT
;
3554 mcp
->tov
= MBX_TOV_SECONDS
* 2;
3556 if (IS_QLA81XX(ha
) || IS_QLA83XX(ha
))
3557 mcp
->in_mb
|= MBX_1
;
3558 if (IS_QLA83XX(ha
)) {
3559 mcp
->out_mb
|= MBX_15
;
3560 /* debug q create issue in SR-IOV */
3561 mcp
->in_mb
|= MBX_9
| MBX_8
| MBX_7
;
3564 spin_lock_irqsave(&ha
->hardware_lock
, flags
);
3565 if (!(req
->options
& BIT_0
)) {
3566 WRT_REG_DWORD(®
->req_q_in
, 0);
3567 if (!IS_QLA83XX(ha
))
3568 WRT_REG_DWORD(®
->req_q_out
, 0);
3570 req
->req_q_in
= ®
->req_q_in
;
3571 req
->req_q_out
= ®
->req_q_out
;
3572 spin_unlock_irqrestore(&ha
->hardware_lock
, flags
);
3574 rval
= qla2x00_mailbox_command(vha
, mcp
);
3575 if (rval
!= QLA_SUCCESS
) {
3576 ql_dbg(ql_dbg_mbx
, vha
, 0x10d4,
3577 "Failed=%x mb[0]=%x.\n", rval
, mcp
->mb
[0]);
3579 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x10d5,
3580 "Done %s.\n", __func__
);
3587 qla25xx_init_rsp_que(struct scsi_qla_host
*vha
, struct rsp_que
*rsp
)
3590 unsigned long flags
;
3592 mbx_cmd_t
*mcp
= &mc
;
3593 struct device_reg_25xxmq __iomem
*reg
;
3594 struct qla_hw_data
*ha
= vha
->hw
;
3596 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x10d6,
3597 "Entered %s.\n", __func__
);
3599 mcp
->mb
[0] = MBC_INITIALIZE_MULTIQ
;
3600 mcp
->mb
[1] = rsp
->options
;
3601 mcp
->mb
[2] = MSW(LSD(rsp
->dma
));
3602 mcp
->mb
[3] = LSW(LSD(rsp
->dma
));
3603 mcp
->mb
[6] = MSW(MSD(rsp
->dma
));
3604 mcp
->mb
[7] = LSW(MSD(rsp
->dma
));
3605 mcp
->mb
[5] = rsp
->length
;
3606 mcp
->mb
[14] = rsp
->msix
->entry
;
3607 mcp
->mb
[13] = rsp
->rid
;
3611 reg
= (struct device_reg_25xxmq
*)((void *)(ha
->mqiobase
) +
3612 QLA_QUE_PAGE
* rsp
->id
);
3614 mcp
->mb
[4] = rsp
->id
;
3615 /* que in ptr index */
3617 /* que out ptr index */
3619 mcp
->out_mb
= MBX_14
|MBX_13
|MBX_9
|MBX_8
|MBX_7
3620 |MBX_6
|MBX_5
|MBX_4
|MBX_3
|MBX_2
|MBX_1
|MBX_0
;
3622 mcp
->flags
= MBX_DMA_OUT
;
3623 mcp
->tov
= MBX_TOV_SECONDS
* 2;
3625 if (IS_QLA81XX(ha
)) {
3626 mcp
->out_mb
|= MBX_12
|MBX_11
|MBX_10
;
3627 mcp
->in_mb
|= MBX_1
;
3628 } else if (IS_QLA83XX(ha
)) {
3629 mcp
->out_mb
|= MBX_15
|MBX_12
|MBX_11
|MBX_10
;
3630 mcp
->in_mb
|= MBX_1
;
3631 /* debug q create issue in SR-IOV */
3632 mcp
->in_mb
|= MBX_9
| MBX_8
| MBX_7
;
3635 spin_lock_irqsave(&ha
->hardware_lock
, flags
);
3636 if (!(rsp
->options
& BIT_0
)) {
3637 WRT_REG_DWORD(®
->rsp_q_out
, 0);
3638 if (!IS_QLA83XX(ha
))
3639 WRT_REG_DWORD(®
->rsp_q_in
, 0);
3642 spin_unlock_irqrestore(&ha
->hardware_lock
, flags
);
3644 rval
= qla2x00_mailbox_command(vha
, mcp
);
3645 if (rval
!= QLA_SUCCESS
) {
3646 ql_dbg(ql_dbg_mbx
, vha
, 0x10d7,
3647 "Failed=%x mb[0]=%x.\n", rval
, mcp
->mb
[0]);
3649 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x10d8,
3650 "Done %s.\n", __func__
);
3657 qla81xx_idc_ack(scsi_qla_host_t
*vha
, uint16_t *mb
)
3661 mbx_cmd_t
*mcp
= &mc
;
3663 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x10d9,
3664 "Entered %s.\n", __func__
);
3666 mcp
->mb
[0] = MBC_IDC_ACK
;
3667 memcpy(&mcp
->mb
[1], mb
, QLA_IDC_ACK_REGS
* sizeof(uint16_t));
3668 mcp
->out_mb
= MBX_7
|MBX_6
|MBX_5
|MBX_4
|MBX_3
|MBX_2
|MBX_1
|MBX_0
;
3670 mcp
->tov
= MBX_TOV_SECONDS
;
3672 rval
= qla2x00_mailbox_command(vha
, mcp
);
3674 if (rval
!= QLA_SUCCESS
) {
3675 ql_dbg(ql_dbg_mbx
, vha
, 0x10da,
3676 "Failed=%x mb[0]=%x.\n", rval
, mcp
->mb
[0]);
3678 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x10db,
3679 "Done %s.\n", __func__
);
3686 qla81xx_fac_get_sector_size(scsi_qla_host_t
*vha
, uint32_t *sector_size
)
3690 mbx_cmd_t
*mcp
= &mc
;
3692 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x10dc,
3693 "Entered %s.\n", __func__
);
3695 if (!IS_QLA81XX(vha
->hw
) && !IS_QLA83XX(vha
->hw
))
3696 return QLA_FUNCTION_FAILED
;
3698 mcp
->mb
[0] = MBC_FLASH_ACCESS_CTRL
;
3699 mcp
->mb
[1] = FAC_OPT_CMD_GET_SECTOR_SIZE
;
3700 mcp
->out_mb
= MBX_1
|MBX_0
;
3701 mcp
->in_mb
= MBX_1
|MBX_0
;
3702 mcp
->tov
= MBX_TOV_SECONDS
;
3704 rval
= qla2x00_mailbox_command(vha
, mcp
);
3706 if (rval
!= QLA_SUCCESS
) {
3707 ql_dbg(ql_dbg_mbx
, vha
, 0x10dd,
3708 "Failed=%x mb[0]=%x mb[1]=%x.\n",
3709 rval
, mcp
->mb
[0], mcp
->mb
[1]);
3711 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x10de,
3712 "Done %s.\n", __func__
);
3713 *sector_size
= mcp
->mb
[1];
3720 qla81xx_fac_do_write_enable(scsi_qla_host_t
*vha
, int enable
)
3724 mbx_cmd_t
*mcp
= &mc
;
3726 if (!IS_QLA81XX(vha
->hw
) && !IS_QLA83XX(vha
->hw
))
3727 return QLA_FUNCTION_FAILED
;
3729 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x10df,
3730 "Entered %s.\n", __func__
);
3732 mcp
->mb
[0] = MBC_FLASH_ACCESS_CTRL
;
3733 mcp
->mb
[1] = enable
? FAC_OPT_CMD_WRITE_ENABLE
:
3734 FAC_OPT_CMD_WRITE_PROTECT
;
3735 mcp
->out_mb
= MBX_1
|MBX_0
;
3736 mcp
->in_mb
= MBX_1
|MBX_0
;
3737 mcp
->tov
= MBX_TOV_SECONDS
;
3739 rval
= qla2x00_mailbox_command(vha
, mcp
);
3741 if (rval
!= QLA_SUCCESS
) {
3742 ql_dbg(ql_dbg_mbx
, vha
, 0x10e0,
3743 "Failed=%x mb[0]=%x mb[1]=%x.\n",
3744 rval
, mcp
->mb
[0], mcp
->mb
[1]);
3746 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x10e1,
3747 "Done %s.\n", __func__
);
3754 qla81xx_fac_erase_sector(scsi_qla_host_t
*vha
, uint32_t start
, uint32_t finish
)
3758 mbx_cmd_t
*mcp
= &mc
;
3760 if (!IS_QLA81XX(vha
->hw
) && !IS_QLA83XX(vha
->hw
))
3761 return QLA_FUNCTION_FAILED
;
3763 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x10e2,
3764 "Entered %s.\n", __func__
);
3766 mcp
->mb
[0] = MBC_FLASH_ACCESS_CTRL
;
3767 mcp
->mb
[1] = FAC_OPT_CMD_ERASE_SECTOR
;
3768 mcp
->mb
[2] = LSW(start
);
3769 mcp
->mb
[3] = MSW(start
);
3770 mcp
->mb
[4] = LSW(finish
);
3771 mcp
->mb
[5] = MSW(finish
);
3772 mcp
->out_mb
= MBX_5
|MBX_4
|MBX_3
|MBX_2
|MBX_1
|MBX_0
;
3773 mcp
->in_mb
= MBX_2
|MBX_1
|MBX_0
;
3774 mcp
->tov
= MBX_TOV_SECONDS
;
3776 rval
= qla2x00_mailbox_command(vha
, mcp
);
3778 if (rval
!= QLA_SUCCESS
) {
3779 ql_dbg(ql_dbg_mbx
, vha
, 0x10e3,
3780 "Failed=%x mb[0]=%x mb[1]=%x mb[2]=%x.\n",
3781 rval
, mcp
->mb
[0], mcp
->mb
[1], mcp
->mb
[2]);
3783 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x10e4,
3784 "Done %s.\n", __func__
);
3791 qla81xx_restart_mpi_firmware(scsi_qla_host_t
*vha
)
3795 mbx_cmd_t
*mcp
= &mc
;
3797 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x10e5,
3798 "Entered %s.\n", __func__
);
3800 mcp
->mb
[0] = MBC_RESTART_MPI_FW
;
3801 mcp
->out_mb
= MBX_0
;
3802 mcp
->in_mb
= MBX_0
|MBX_1
;
3803 mcp
->tov
= MBX_TOV_SECONDS
;
3805 rval
= qla2x00_mailbox_command(vha
, mcp
);
3807 if (rval
!= QLA_SUCCESS
) {
3808 ql_dbg(ql_dbg_mbx
, vha
, 0x10e6,
3809 "Failed=%x mb[0]=%x mb[1]=%x.\n",
3810 rval
, mcp
->mb
[0], mcp
->mb
[1]);
3812 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x10e7,
3813 "Done %s.\n", __func__
);
3820 qla2x00_read_sfp(scsi_qla_host_t
*vha
, dma_addr_t sfp_dma
, uint8_t *sfp
,
3821 uint16_t dev
, uint16_t off
, uint16_t len
, uint16_t opt
)
3825 mbx_cmd_t
*mcp
= &mc
;
3826 struct qla_hw_data
*ha
= vha
->hw
;
3828 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x10e8,
3829 "Entered %s.\n", __func__
);
3831 if (!IS_FWI2_CAPABLE(ha
))
3832 return QLA_FUNCTION_FAILED
;
3837 mcp
->mb
[0] = MBC_READ_SFP
;
3839 mcp
->mb
[2] = MSW(sfp_dma
);
3840 mcp
->mb
[3] = LSW(sfp_dma
);
3841 mcp
->mb
[6] = MSW(MSD(sfp_dma
));
3842 mcp
->mb
[7] = LSW(MSD(sfp_dma
));
3846 mcp
->out_mb
= MBX_10
|MBX_9
|MBX_8
|MBX_7
|MBX_6
|MBX_3
|MBX_2
|MBX_1
|MBX_0
;
3847 mcp
->in_mb
= MBX_1
|MBX_0
;
3848 mcp
->tov
= MBX_TOV_SECONDS
;
3850 rval
= qla2x00_mailbox_command(vha
, mcp
);
3855 if (rval
!= QLA_SUCCESS
) {
3856 ql_dbg(ql_dbg_mbx
, vha
, 0x10e9,
3857 "Failed=%x mb[0]=%x.\n", rval
, mcp
->mb
[0]);
3859 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x10ea,
3860 "Done %s.\n", __func__
);
3867 qla2x00_write_sfp(scsi_qla_host_t
*vha
, dma_addr_t sfp_dma
, uint8_t *sfp
,
3868 uint16_t dev
, uint16_t off
, uint16_t len
, uint16_t opt
)
3872 mbx_cmd_t
*mcp
= &mc
;
3873 struct qla_hw_data
*ha
= vha
->hw
;
3875 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x10eb,
3876 "Entered %s.\n", __func__
);
3878 if (!IS_FWI2_CAPABLE(ha
))
3879 return QLA_FUNCTION_FAILED
;
3887 mcp
->mb
[0] = MBC_WRITE_SFP
;
3889 mcp
->mb
[2] = MSW(sfp_dma
);
3890 mcp
->mb
[3] = LSW(sfp_dma
);
3891 mcp
->mb
[6] = MSW(MSD(sfp_dma
));
3892 mcp
->mb
[7] = LSW(MSD(sfp_dma
));
3896 mcp
->out_mb
= MBX_10
|MBX_9
|MBX_8
|MBX_7
|MBX_6
|MBX_3
|MBX_2
|MBX_1
|MBX_0
;
3897 mcp
->in_mb
= MBX_1
|MBX_0
;
3898 mcp
->tov
= MBX_TOV_SECONDS
;
3900 rval
= qla2x00_mailbox_command(vha
, mcp
);
3902 if (rval
!= QLA_SUCCESS
) {
3903 ql_dbg(ql_dbg_mbx
, vha
, 0x10ec,
3904 "Failed=%x mb[0]=%x.\n", rval
, mcp
->mb
[0]);
3906 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x10ed,
3907 "Done %s.\n", __func__
);
3914 qla2x00_get_xgmac_stats(scsi_qla_host_t
*vha
, dma_addr_t stats_dma
,
3915 uint16_t size_in_bytes
, uint16_t *actual_size
)
3919 mbx_cmd_t
*mcp
= &mc
;
3921 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x10ee,
3922 "Entered %s.\n", __func__
);
3924 if (!IS_CNA_CAPABLE(vha
->hw
))
3925 return QLA_FUNCTION_FAILED
;
3927 mcp
->mb
[0] = MBC_GET_XGMAC_STATS
;
3928 mcp
->mb
[2] = MSW(stats_dma
);
3929 mcp
->mb
[3] = LSW(stats_dma
);
3930 mcp
->mb
[6] = MSW(MSD(stats_dma
));
3931 mcp
->mb
[7] = LSW(MSD(stats_dma
));
3932 mcp
->mb
[8] = size_in_bytes
>> 2;
3933 mcp
->out_mb
= MBX_8
|MBX_7
|MBX_6
|MBX_3
|MBX_2
|MBX_0
;
3934 mcp
->in_mb
= MBX_2
|MBX_1
|MBX_0
;
3935 mcp
->tov
= MBX_TOV_SECONDS
;
3937 rval
= qla2x00_mailbox_command(vha
, mcp
);
3939 if (rval
!= QLA_SUCCESS
) {
3940 ql_dbg(ql_dbg_mbx
, vha
, 0x10ef,
3941 "Failed=%x mb[0]=%x mb[1]=%x mb[2]=%x.\n",
3942 rval
, mcp
->mb
[0], mcp
->mb
[1], mcp
->mb
[2]);
3944 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x10f0,
3945 "Done %s.\n", __func__
);
3948 *actual_size
= mcp
->mb
[2] << 2;
3955 qla2x00_get_dcbx_params(scsi_qla_host_t
*vha
, dma_addr_t tlv_dma
,
3960 mbx_cmd_t
*mcp
= &mc
;
3962 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x10f1,
3963 "Entered %s.\n", __func__
);
3965 if (!IS_CNA_CAPABLE(vha
->hw
))
3966 return QLA_FUNCTION_FAILED
;
3968 mcp
->mb
[0] = MBC_GET_DCBX_PARAMS
;
3970 mcp
->mb
[2] = MSW(tlv_dma
);
3971 mcp
->mb
[3] = LSW(tlv_dma
);
3972 mcp
->mb
[6] = MSW(MSD(tlv_dma
));
3973 mcp
->mb
[7] = LSW(MSD(tlv_dma
));
3975 mcp
->out_mb
= MBX_8
|MBX_7
|MBX_6
|MBX_3
|MBX_2
|MBX_1
|MBX_0
;
3976 mcp
->in_mb
= MBX_2
|MBX_1
|MBX_0
;
3977 mcp
->tov
= MBX_TOV_SECONDS
;
3979 rval
= qla2x00_mailbox_command(vha
, mcp
);
3981 if (rval
!= QLA_SUCCESS
) {
3982 ql_dbg(ql_dbg_mbx
, vha
, 0x10f2,
3983 "Failed=%x mb[0]=%x mb[1]=%x mb[2]=%x.\n",
3984 rval
, mcp
->mb
[0], mcp
->mb
[1], mcp
->mb
[2]);
3986 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x10f3,
3987 "Done %s.\n", __func__
);
3994 qla2x00_read_ram_word(scsi_qla_host_t
*vha
, uint32_t risc_addr
, uint32_t *data
)
3998 mbx_cmd_t
*mcp
= &mc
;
4000 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x10f4,
4001 "Entered %s.\n", __func__
);
4003 if (!IS_FWI2_CAPABLE(vha
->hw
))
4004 return QLA_FUNCTION_FAILED
;
4006 mcp
->mb
[0] = MBC_READ_RAM_EXTENDED
;
4007 mcp
->mb
[1] = LSW(risc_addr
);
4008 mcp
->mb
[8] = MSW(risc_addr
);
4009 mcp
->out_mb
= MBX_8
|MBX_1
|MBX_0
;
4010 mcp
->in_mb
= MBX_3
|MBX_2
|MBX_0
;
4013 rval
= qla2x00_mailbox_command(vha
, mcp
);
4014 if (rval
!= QLA_SUCCESS
) {
4015 ql_dbg(ql_dbg_mbx
, vha
, 0x10f5,
4016 "Failed=%x mb[0]=%x.\n", rval
, mcp
->mb
[0]);
4018 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x10f6,
4019 "Done %s.\n", __func__
);
4020 *data
= mcp
->mb
[3] << 16 | mcp
->mb
[2];
4027 qla2x00_loopback_test(scsi_qla_host_t
*vha
, struct msg_echo_lb
*mreq
,
4032 mbx_cmd_t
*mcp
= &mc
;
4033 uint32_t iter_cnt
= 0x1;
4035 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x10f7,
4036 "Entered %s.\n", __func__
);
4038 memset(mcp
->mb
, 0 , sizeof(mcp
->mb
));
4039 mcp
->mb
[0] = MBC_DIAGNOSTIC_LOOP_BACK
;
4040 mcp
->mb
[1] = mreq
->options
| BIT_6
; // BIT_6 specifies 64 bit addressing
4042 /* transfer count */
4043 mcp
->mb
[10] = LSW(mreq
->transfer_size
);
4044 mcp
->mb
[11] = MSW(mreq
->transfer_size
);
4046 /* send data address */
4047 mcp
->mb
[14] = LSW(mreq
->send_dma
);
4048 mcp
->mb
[15] = MSW(mreq
->send_dma
);
4049 mcp
->mb
[20] = LSW(MSD(mreq
->send_dma
));
4050 mcp
->mb
[21] = MSW(MSD(mreq
->send_dma
));
4052 /* receive data address */
4053 mcp
->mb
[16] = LSW(mreq
->rcv_dma
);
4054 mcp
->mb
[17] = MSW(mreq
->rcv_dma
);
4055 mcp
->mb
[6] = LSW(MSD(mreq
->rcv_dma
));
4056 mcp
->mb
[7] = MSW(MSD(mreq
->rcv_dma
));
4058 /* Iteration count */
4059 mcp
->mb
[18] = LSW(iter_cnt
);
4060 mcp
->mb
[19] = MSW(iter_cnt
);
4062 mcp
->out_mb
= MBX_21
|MBX_20
|MBX_19
|MBX_18
|MBX_17
|MBX_16
|MBX_15
|
4063 MBX_14
|MBX_13
|MBX_12
|MBX_11
|MBX_10
|MBX_7
|MBX_6
|MBX_1
|MBX_0
;
4064 if (IS_CNA_CAPABLE(vha
->hw
))
4065 mcp
->out_mb
|= MBX_2
;
4066 mcp
->in_mb
= MBX_19
|MBX_18
|MBX_3
|MBX_2
|MBX_1
|MBX_0
;
4068 mcp
->buf_size
= mreq
->transfer_size
;
4069 mcp
->tov
= MBX_TOV_SECONDS
;
4070 mcp
->flags
= MBX_DMA_OUT
|MBX_DMA_IN
|IOCTL_CMD
;
4072 rval
= qla2x00_mailbox_command(vha
, mcp
);
4074 if (rval
!= QLA_SUCCESS
) {
4075 ql_dbg(ql_dbg_mbx
, vha
, 0x10f8,
4076 "Failed=%x mb[0]=%x mb[1]=%x mb[2]=%x mb[3]=%x mb[18]=%x "
4077 "mb[19]=%x.\n", rval
, mcp
->mb
[0], mcp
->mb
[1], mcp
->mb
[2],
4078 mcp
->mb
[3], mcp
->mb
[18], mcp
->mb
[19]);
4080 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x10f9,
4081 "Done %s.\n", __func__
);
4084 /* Copy mailbox information */
4085 memcpy( mresp
, mcp
->mb
, 64);
4090 qla2x00_echo_test(scsi_qla_host_t
*vha
, struct msg_echo_lb
*mreq
,
4095 mbx_cmd_t
*mcp
= &mc
;
4096 struct qla_hw_data
*ha
= vha
->hw
;
4098 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x10fa,
4099 "Entered %s.\n", __func__
);
4101 memset(mcp
->mb
, 0 , sizeof(mcp
->mb
));
4102 mcp
->mb
[0] = MBC_DIAGNOSTIC_ECHO
;
4103 mcp
->mb
[1] = mreq
->options
| BIT_6
; /* BIT_6 specifies 64bit address */
4104 if (IS_CNA_CAPABLE(ha
)) {
4105 mcp
->mb
[1] |= BIT_15
;
4106 mcp
->mb
[2] = vha
->fcoe_fcf_idx
;
4108 mcp
->mb
[16] = LSW(mreq
->rcv_dma
);
4109 mcp
->mb
[17] = MSW(mreq
->rcv_dma
);
4110 mcp
->mb
[6] = LSW(MSD(mreq
->rcv_dma
));
4111 mcp
->mb
[7] = MSW(MSD(mreq
->rcv_dma
));
4113 mcp
->mb
[10] = LSW(mreq
->transfer_size
);
4115 mcp
->mb
[14] = LSW(mreq
->send_dma
);
4116 mcp
->mb
[15] = MSW(mreq
->send_dma
);
4117 mcp
->mb
[20] = LSW(MSD(mreq
->send_dma
));
4118 mcp
->mb
[21] = MSW(MSD(mreq
->send_dma
));
4120 mcp
->out_mb
= MBX_21
|MBX_20
|MBX_17
|MBX_16
|MBX_15
|
4121 MBX_14
|MBX_10
|MBX_7
|MBX_6
|MBX_1
|MBX_0
;
4122 if (IS_CNA_CAPABLE(ha
))
4123 mcp
->out_mb
|= MBX_2
;
4126 if (IS_QLA24XX_TYPE(ha
) || IS_QLA25XX(ha
) ||
4127 IS_CNA_CAPABLE(ha
) || IS_QLA2031(ha
))
4128 mcp
->in_mb
|= MBX_1
;
4129 if (IS_CNA_CAPABLE(ha
) || IS_QLA2031(ha
))
4130 mcp
->in_mb
|= MBX_3
;
4132 mcp
->tov
= MBX_TOV_SECONDS
;
4133 mcp
->flags
= MBX_DMA_OUT
|MBX_DMA_IN
|IOCTL_CMD
;
4134 mcp
->buf_size
= mreq
->transfer_size
;
4136 rval
= qla2x00_mailbox_command(vha
, mcp
);
4138 if (rval
!= QLA_SUCCESS
) {
4139 ql_dbg(ql_dbg_mbx
, vha
, 0x10fb,
4140 "Failed=%x mb[0]=%x mb[1]=%x.\n",
4141 rval
, mcp
->mb
[0], mcp
->mb
[1]);
4143 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x10fc,
4144 "Done %s.\n", __func__
);
4147 /* Copy mailbox information */
4148 memcpy(mresp
, mcp
->mb
, 64);
4153 qla84xx_reset_chip(scsi_qla_host_t
*vha
, uint16_t enable_diagnostic
)
4157 mbx_cmd_t
*mcp
= &mc
;
4159 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x10fd,
4160 "Entered %s enable_diag=%d.\n", __func__
, enable_diagnostic
);
4162 mcp
->mb
[0] = MBC_ISP84XX_RESET
;
4163 mcp
->mb
[1] = enable_diagnostic
;
4164 mcp
->out_mb
= MBX_1
|MBX_0
;
4165 mcp
->in_mb
= MBX_1
|MBX_0
;
4166 mcp
->tov
= MBX_TOV_SECONDS
;
4167 mcp
->flags
= MBX_DMA_OUT
|MBX_DMA_IN
|IOCTL_CMD
;
4168 rval
= qla2x00_mailbox_command(vha
, mcp
);
4170 if (rval
!= QLA_SUCCESS
)
4171 ql_dbg(ql_dbg_mbx
, vha
, 0x10fe, "Failed=%x.\n", rval
);
4173 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x10ff,
4174 "Done %s.\n", __func__
);
4180 qla2x00_write_ram_word(scsi_qla_host_t
*vha
, uint32_t risc_addr
, uint32_t data
)
4184 mbx_cmd_t
*mcp
= &mc
;
4186 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x1100,
4187 "Entered %s.\n", __func__
);
4189 if (!IS_FWI2_CAPABLE(vha
->hw
))
4190 return QLA_FUNCTION_FAILED
;
4192 mcp
->mb
[0] = MBC_WRITE_RAM_WORD_EXTENDED
;
4193 mcp
->mb
[1] = LSW(risc_addr
);
4194 mcp
->mb
[2] = LSW(data
);
4195 mcp
->mb
[3] = MSW(data
);
4196 mcp
->mb
[8] = MSW(risc_addr
);
4197 mcp
->out_mb
= MBX_8
|MBX_3
|MBX_2
|MBX_1
|MBX_0
;
4201 rval
= qla2x00_mailbox_command(vha
, mcp
);
4202 if (rval
!= QLA_SUCCESS
) {
4203 ql_dbg(ql_dbg_mbx
, vha
, 0x1101,
4204 "Failed=%x mb[0]=%x.\n", rval
, mcp
->mb
[0]);
4206 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x1102,
4207 "Done %s.\n", __func__
);
4214 qla81xx_write_mpi_register(scsi_qla_host_t
*vha
, uint16_t *mb
)
4217 uint32_t stat
, timer
;
4219 struct qla_hw_data
*ha
= vha
->hw
;
4220 struct device_reg_24xx __iomem
*reg
= &ha
->iobase
->isp24
;
4224 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x1103,
4225 "Entered %s.\n", __func__
);
4227 clear_bit(MBX_INTERRUPT
, &ha
->mbx_cmd_flags
);
4229 /* Write the MBC data to the registers */
4230 WRT_REG_WORD(®
->mailbox0
, MBC_WRITE_MPI_REGISTER
);
4231 WRT_REG_WORD(®
->mailbox1
, mb
[0]);
4232 WRT_REG_WORD(®
->mailbox2
, mb
[1]);
4233 WRT_REG_WORD(®
->mailbox3
, mb
[2]);
4234 WRT_REG_WORD(®
->mailbox4
, mb
[3]);
4236 WRT_REG_DWORD(®
->hccr
, HCCRX_SET_HOST_INT
);
4238 /* Poll for MBC interrupt */
4239 for (timer
= 6000000; timer
; timer
--) {
4240 /* Check for pending interrupts. */
4241 stat
= RD_REG_DWORD(®
->host_status
);
4242 if (stat
& HSRX_RISC_INT
) {
4245 if (stat
== 0x1 || stat
== 0x2 ||
4246 stat
== 0x10 || stat
== 0x11) {
4247 set_bit(MBX_INTERRUPT
,
4248 &ha
->mbx_cmd_flags
);
4249 mb0
= RD_REG_WORD(®
->mailbox0
);
4250 WRT_REG_DWORD(®
->hccr
,
4251 HCCRX_CLR_RISC_INT
);
4252 RD_REG_DWORD(®
->hccr
);
4259 if (test_and_clear_bit(MBX_INTERRUPT
, &ha
->mbx_cmd_flags
))
4260 rval
= mb0
& MBS_MASK
;
4262 rval
= QLA_FUNCTION_FAILED
;
4264 if (rval
!= QLA_SUCCESS
) {
4265 ql_dbg(ql_dbg_mbx
, vha
, 0x1104,
4266 "Failed=%x mb[0]=%x.\n", rval
, mb
[0]);
4268 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x1105,
4269 "Done %s.\n", __func__
);
4276 qla2x00_get_data_rate(scsi_qla_host_t
*vha
)
4280 mbx_cmd_t
*mcp
= &mc
;
4281 struct qla_hw_data
*ha
= vha
->hw
;
4283 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x1106,
4284 "Entered %s.\n", __func__
);
4286 if (!IS_FWI2_CAPABLE(ha
))
4287 return QLA_FUNCTION_FAILED
;
4289 mcp
->mb
[0] = MBC_DATA_RATE
;
4291 mcp
->out_mb
= MBX_1
|MBX_0
;
4292 mcp
->in_mb
= MBX_2
|MBX_1
|MBX_0
;
4294 mcp
->in_mb
|= MBX_3
;
4295 mcp
->tov
= MBX_TOV_SECONDS
;
4297 rval
= qla2x00_mailbox_command(vha
, mcp
);
4298 if (rval
!= QLA_SUCCESS
) {
4299 ql_dbg(ql_dbg_mbx
, vha
, 0x1107,
4300 "Failed=%x mb[0]=%x.\n", rval
, mcp
->mb
[0]);
4302 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x1108,
4303 "Done %s.\n", __func__
);
4304 if (mcp
->mb
[1] != 0x7)
4305 ha
->link_data_rate
= mcp
->mb
[1];
4312 qla81xx_get_port_config(scsi_qla_host_t
*vha
, uint16_t *mb
)
4316 mbx_cmd_t
*mcp
= &mc
;
4317 struct qla_hw_data
*ha
= vha
->hw
;
4319 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x1109,
4320 "Entered %s.\n", __func__
);
4322 if (!IS_QLA81XX(ha
) && !IS_QLA83XX(ha
))
4323 return QLA_FUNCTION_FAILED
;
4324 mcp
->mb
[0] = MBC_GET_PORT_CONFIG
;
4325 mcp
->out_mb
= MBX_0
;
4326 mcp
->in_mb
= MBX_4
|MBX_3
|MBX_2
|MBX_1
|MBX_0
;
4327 mcp
->tov
= MBX_TOV_SECONDS
;
4330 rval
= qla2x00_mailbox_command(vha
, mcp
);
4332 if (rval
!= QLA_SUCCESS
) {
4333 ql_dbg(ql_dbg_mbx
, vha
, 0x110a,
4334 "Failed=%x mb[0]=%x.\n", rval
, mcp
->mb
[0]);
4336 /* Copy all bits to preserve original value */
4337 memcpy(mb
, &mcp
->mb
[1], sizeof(uint16_t) * 4);
4339 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x110b,
4340 "Done %s.\n", __func__
);
4346 qla81xx_set_port_config(scsi_qla_host_t
*vha
, uint16_t *mb
)
4350 mbx_cmd_t
*mcp
= &mc
;
4352 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x110c,
4353 "Entered %s.\n", __func__
);
4355 mcp
->mb
[0] = MBC_SET_PORT_CONFIG
;
4356 /* Copy all bits to preserve original setting */
4357 memcpy(&mcp
->mb
[1], mb
, sizeof(uint16_t) * 4);
4358 mcp
->out_mb
= MBX_4
|MBX_3
|MBX_2
|MBX_1
|MBX_0
;
4360 mcp
->tov
= MBX_TOV_SECONDS
;
4362 rval
= qla2x00_mailbox_command(vha
, mcp
);
4364 if (rval
!= QLA_SUCCESS
) {
4365 ql_dbg(ql_dbg_mbx
, vha
, 0x110d,
4366 "Failed=%x mb[0]=%x.\n", rval
, mcp
->mb
[0]);
4368 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x110e,
4369 "Done %s.\n", __func__
);
4376 qla24xx_set_fcp_prio(scsi_qla_host_t
*vha
, uint16_t loop_id
, uint16_t priority
,
4381 mbx_cmd_t
*mcp
= &mc
;
4382 struct qla_hw_data
*ha
= vha
->hw
;
4384 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x110f,
4385 "Entered %s.\n", __func__
);
4387 if (!IS_QLA24XX_TYPE(ha
) && !IS_QLA25XX(ha
))
4388 return QLA_FUNCTION_FAILED
;
4390 mcp
->mb
[0] = MBC_PORT_PARAMS
;
4391 mcp
->mb
[1] = loop_id
;
4392 if (ha
->flags
.fcp_prio_enabled
)
4396 mcp
->mb
[4] = priority
& 0xf;
4397 mcp
->mb
[9] = vha
->vp_idx
;
4398 mcp
->out_mb
= MBX_9
|MBX_4
|MBX_3
|MBX_2
|MBX_1
|MBX_0
;
4399 mcp
->in_mb
= MBX_4
|MBX_3
|MBX_1
|MBX_0
;
4402 rval
= qla2x00_mailbox_command(vha
, mcp
);
4410 if (rval
!= QLA_SUCCESS
) {
4411 ql_dbg(ql_dbg_mbx
, vha
, 0x10cd, "Failed=%x.\n", rval
);
4413 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x10cc,
4414 "Done %s.\n", __func__
);
4421 qla2x00_get_thermal_temp(scsi_qla_host_t
*vha
, uint16_t *temp
, uint16_t *frac
)
4425 struct qla_hw_data
*ha
= vha
->hw
;
4427 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x10ca,
4428 "Entered %s.\n", __func__
);
4431 rval
= qla2x00_read_sfp(vha
, 0, &byte
, 0x98, 0x01, 1, BIT_13
|BIT_0
);
4432 if (rval
!= QLA_SUCCESS
) {
4433 ql_dbg(ql_dbg_mbx
, vha
, 0x10c9, "Failed=%x.\n", rval
);
4434 ha
->flags
.thermal_supported
= 0;
4440 rval
= qla2x00_read_sfp(vha
, 0, &byte
, 0x98, 0x10, 1, BIT_13
|BIT_0
);
4441 if (rval
!= QLA_SUCCESS
) {
4442 ql_dbg(ql_dbg_mbx
, vha
, 0x1019, "Failed=%x.\n", rval
);
4443 ha
->flags
.thermal_supported
= 0;
4446 *frac
= (byte
>> 6) * 25;
4448 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x1018,
4449 "Done %s.\n", __func__
);
4455 qla82xx_mbx_intr_enable(scsi_qla_host_t
*vha
)
4458 struct qla_hw_data
*ha
= vha
->hw
;
4460 mbx_cmd_t
*mcp
= &mc
;
4462 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x1017,
4463 "Entered %s.\n", __func__
);
4465 if (!IS_FWI2_CAPABLE(ha
))
4466 return QLA_FUNCTION_FAILED
;
4468 memset(mcp
, 0, sizeof(mbx_cmd_t
));
4469 mcp
->mb
[0] = MBC_TOGGLE_INTERRUPT
;
4472 mcp
->out_mb
= MBX_1
|MBX_0
;
4477 rval
= qla2x00_mailbox_command(vha
, mcp
);
4478 if (rval
!= QLA_SUCCESS
) {
4479 ql_dbg(ql_dbg_mbx
, vha
, 0x1016,
4480 "Failed=%x mb[0]=%x.\n", rval
, mcp
->mb
[0]);
4482 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x100e,
4483 "Done %s.\n", __func__
);
4490 qla82xx_mbx_intr_disable(scsi_qla_host_t
*vha
)
4493 struct qla_hw_data
*ha
= vha
->hw
;
4495 mbx_cmd_t
*mcp
= &mc
;
4497 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x100d,
4498 "Entered %s.\n", __func__
);
4500 if (!IS_QLA82XX(ha
))
4501 return QLA_FUNCTION_FAILED
;
4503 memset(mcp
, 0, sizeof(mbx_cmd_t
));
4504 mcp
->mb
[0] = MBC_TOGGLE_INTERRUPT
;
4507 mcp
->out_mb
= MBX_1
|MBX_0
;
4512 rval
= qla2x00_mailbox_command(vha
, mcp
);
4513 if (rval
!= QLA_SUCCESS
) {
4514 ql_dbg(ql_dbg_mbx
, vha
, 0x100c,
4515 "Failed=%x mb[0]=%x.\n", rval
, mcp
->mb
[0]);
4517 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x100b,
4518 "Done %s.\n", __func__
);
4525 qla82xx_md_get_template_size(scsi_qla_host_t
*vha
)
4527 struct qla_hw_data
*ha
= vha
->hw
;
4529 mbx_cmd_t
*mcp
= &mc
;
4530 int rval
= QLA_FUNCTION_FAILED
;
4532 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x111f,
4533 "Entered %s.\n", __func__
);
4535 memset(mcp
->mb
, 0 , sizeof(mcp
->mb
));
4536 mcp
->mb
[0] = LSW(MBC_DIAGNOSTIC_MINIDUMP_TEMPLATE
);
4537 mcp
->mb
[1] = MSW(MBC_DIAGNOSTIC_MINIDUMP_TEMPLATE
);
4538 mcp
->mb
[2] = LSW(RQST_TMPLT_SIZE
);
4539 mcp
->mb
[3] = MSW(RQST_TMPLT_SIZE
);
4541 mcp
->out_mb
= MBX_3
|MBX_2
|MBX_1
|MBX_0
;
4542 mcp
->in_mb
= MBX_14
|MBX_13
|MBX_12
|MBX_11
|MBX_10
|MBX_9
|MBX_8
|
4543 MBX_7
|MBX_6
|MBX_5
|MBX_4
|MBX_3
|MBX_2
|MBX_1
|MBX_0
;
4545 mcp
->flags
= MBX_DMA_OUT
|MBX_DMA_IN
|IOCTL_CMD
;
4546 mcp
->tov
= MBX_TOV_SECONDS
;
4547 rval
= qla2x00_mailbox_command(vha
, mcp
);
4549 /* Always copy back return mailbox values. */
4550 if (rval
!= QLA_SUCCESS
) {
4551 ql_dbg(ql_dbg_mbx
, vha
, 0x1120,
4552 "mailbox command FAILED=0x%x, subcode=%x.\n",
4553 (mcp
->mb
[1] << 16) | mcp
->mb
[0],
4554 (mcp
->mb
[3] << 16) | mcp
->mb
[2]);
4556 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x1121,
4557 "Done %s.\n", __func__
);
4558 ha
->md_template_size
= ((mcp
->mb
[3] << 16) | mcp
->mb
[2]);
4559 if (!ha
->md_template_size
) {
4560 ql_dbg(ql_dbg_mbx
, vha
, 0x1122,
4561 "Null template size obtained.\n");
4562 rval
= QLA_FUNCTION_FAILED
;
4569 qla82xx_md_get_template(scsi_qla_host_t
*vha
)
4571 struct qla_hw_data
*ha
= vha
->hw
;
4573 mbx_cmd_t
*mcp
= &mc
;
4574 int rval
= QLA_FUNCTION_FAILED
;
4576 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x1123,
4577 "Entered %s.\n", __func__
);
4579 ha
->md_tmplt_hdr
= dma_alloc_coherent(&ha
->pdev
->dev
,
4580 ha
->md_template_size
, &ha
->md_tmplt_hdr_dma
, GFP_KERNEL
);
4581 if (!ha
->md_tmplt_hdr
) {
4582 ql_log(ql_log_warn
, vha
, 0x1124,
4583 "Unable to allocate memory for Minidump template.\n");
4587 memset(mcp
->mb
, 0 , sizeof(mcp
->mb
));
4588 mcp
->mb
[0] = LSW(MBC_DIAGNOSTIC_MINIDUMP_TEMPLATE
);
4589 mcp
->mb
[1] = MSW(MBC_DIAGNOSTIC_MINIDUMP_TEMPLATE
);
4590 mcp
->mb
[2] = LSW(RQST_TMPLT
);
4591 mcp
->mb
[3] = MSW(RQST_TMPLT
);
4592 mcp
->mb
[4] = LSW(LSD(ha
->md_tmplt_hdr_dma
));
4593 mcp
->mb
[5] = MSW(LSD(ha
->md_tmplt_hdr_dma
));
4594 mcp
->mb
[6] = LSW(MSD(ha
->md_tmplt_hdr_dma
));
4595 mcp
->mb
[7] = MSW(MSD(ha
->md_tmplt_hdr_dma
));
4596 mcp
->mb
[8] = LSW(ha
->md_template_size
);
4597 mcp
->mb
[9] = MSW(ha
->md_template_size
);
4599 mcp
->flags
= MBX_DMA_OUT
|MBX_DMA_IN
|IOCTL_CMD
;
4600 mcp
->tov
= MBX_TOV_SECONDS
;
4601 mcp
->out_mb
= MBX_11
|MBX_10
|MBX_9
|MBX_8
|
4602 MBX_7
|MBX_6
|MBX_5
|MBX_4
|MBX_3
|MBX_2
|MBX_1
|MBX_0
;
4603 mcp
->in_mb
= MBX_3
|MBX_2
|MBX_1
|MBX_0
;
4604 rval
= qla2x00_mailbox_command(vha
, mcp
);
4606 if (rval
!= QLA_SUCCESS
) {
4607 ql_dbg(ql_dbg_mbx
, vha
, 0x1125,
4608 "mailbox command FAILED=0x%x, subcode=%x.\n",
4609 ((mcp
->mb
[1] << 16) | mcp
->mb
[0]),
4610 ((mcp
->mb
[3] << 16) | mcp
->mb
[2]));
4612 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x1126,
4613 "Done %s.\n", __func__
);
4618 qla81xx_set_led_config(scsi_qla_host_t
*vha
, uint16_t *led_cfg
)
4621 struct qla_hw_data
*ha
= vha
->hw
;
4623 mbx_cmd_t
*mcp
= &mc
;
4625 if (!IS_QLA81XX(ha
) && !IS_QLA8031(ha
))
4626 return QLA_FUNCTION_FAILED
;
4628 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x1133,
4629 "Entered %s.\n", __func__
);
4631 memset(mcp
, 0, sizeof(mbx_cmd_t
));
4632 mcp
->mb
[0] = MBC_SET_LED_CONFIG
;
4633 mcp
->mb
[1] = led_cfg
[0];
4634 mcp
->mb
[2] = led_cfg
[1];
4635 if (IS_QLA8031(ha
)) {
4636 mcp
->mb
[3] = led_cfg
[2];
4637 mcp
->mb
[4] = led_cfg
[3];
4638 mcp
->mb
[5] = led_cfg
[4];
4639 mcp
->mb
[6] = led_cfg
[5];
4642 mcp
->out_mb
= MBX_2
|MBX_1
|MBX_0
;
4644 mcp
->out_mb
|= MBX_6
|MBX_5
|MBX_4
|MBX_3
;
4649 rval
= qla2x00_mailbox_command(vha
, mcp
);
4650 if (rval
!= QLA_SUCCESS
) {
4651 ql_dbg(ql_dbg_mbx
, vha
, 0x1134,
4652 "Failed=%x mb[0]=%x.\n", rval
, mcp
->mb
[0]);
4654 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x1135,
4655 "Done %s.\n", __func__
);
4662 qla81xx_get_led_config(scsi_qla_host_t
*vha
, uint16_t *led_cfg
)
4665 struct qla_hw_data
*ha
= vha
->hw
;
4667 mbx_cmd_t
*mcp
= &mc
;
4669 if (!IS_QLA81XX(ha
) && !IS_QLA8031(ha
))
4670 return QLA_FUNCTION_FAILED
;
4672 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x1136,
4673 "Entered %s.\n", __func__
);
4675 memset(mcp
, 0, sizeof(mbx_cmd_t
));
4676 mcp
->mb
[0] = MBC_GET_LED_CONFIG
;
4678 mcp
->out_mb
= MBX_0
;
4679 mcp
->in_mb
= MBX_2
|MBX_1
|MBX_0
;
4681 mcp
->in_mb
|= MBX_6
|MBX_5
|MBX_4
|MBX_3
;
4685 rval
= qla2x00_mailbox_command(vha
, mcp
);
4686 if (rval
!= QLA_SUCCESS
) {
4687 ql_dbg(ql_dbg_mbx
, vha
, 0x1137,
4688 "Failed=%x mb[0]=%x.\n", rval
, mcp
->mb
[0]);
4690 led_cfg
[0] = mcp
->mb
[1];
4691 led_cfg
[1] = mcp
->mb
[2];
4692 if (IS_QLA8031(ha
)) {
4693 led_cfg
[2] = mcp
->mb
[3];
4694 led_cfg
[3] = mcp
->mb
[4];
4695 led_cfg
[4] = mcp
->mb
[5];
4696 led_cfg
[5] = mcp
->mb
[6];
4698 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x1138,
4699 "Done %s.\n", __func__
);
4706 qla82xx_mbx_beacon_ctl(scsi_qla_host_t
*vha
, int enable
)
4709 struct qla_hw_data
*ha
= vha
->hw
;
4711 mbx_cmd_t
*mcp
= &mc
;
4713 if (!IS_QLA82XX(ha
))
4714 return QLA_FUNCTION_FAILED
;
4716 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x1127,
4717 "Entered %s.\n", __func__
);
4719 memset(mcp
, 0, sizeof(mbx_cmd_t
));
4720 mcp
->mb
[0] = MBC_SET_LED_CONFIG
;
4726 mcp
->out_mb
= MBX_7
|MBX_0
;
4728 mcp
->tov
= MBX_TOV_SECONDS
;
4731 rval
= qla2x00_mailbox_command(vha
, mcp
);
4732 if (rval
!= QLA_SUCCESS
) {
4733 ql_dbg(ql_dbg_mbx
, vha
, 0x1128,
4734 "Failed=%x mb[0]=%x.\n", rval
, mcp
->mb
[0]);
4736 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x1129,
4737 "Done %s.\n", __func__
);
4744 qla83xx_write_remote_reg(scsi_qla_host_t
*vha
, uint32_t reg
, uint32_t data
)
4747 struct qla_hw_data
*ha
= vha
->hw
;
4749 mbx_cmd_t
*mcp
= &mc
;
4751 if (!IS_QLA83XX(ha
))
4752 return QLA_FUNCTION_FAILED
;
4754 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x1130,
4755 "Entered %s.\n", __func__
);
4757 mcp
->mb
[0] = MBC_WRITE_REMOTE_REG
;
4758 mcp
->mb
[1] = LSW(reg
);
4759 mcp
->mb
[2] = MSW(reg
);
4760 mcp
->mb
[3] = LSW(data
);
4761 mcp
->mb
[4] = MSW(data
);
4762 mcp
->out_mb
= MBX_4
|MBX_3
|MBX_2
|MBX_1
|MBX_0
;
4764 mcp
->in_mb
= MBX_1
|MBX_0
;
4765 mcp
->tov
= MBX_TOV_SECONDS
;
4767 rval
= qla2x00_mailbox_command(vha
, mcp
);
4769 if (rval
!= QLA_SUCCESS
) {
4770 ql_dbg(ql_dbg_mbx
, vha
, 0x1131,
4771 "Failed=%x mb[0]=%x.\n", rval
, mcp
->mb
[0]);
4773 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x1132,
4774 "Done %s.\n", __func__
);
4781 qla2x00_port_logout(scsi_qla_host_t
*vha
, struct fc_port
*fcport
)
4784 struct qla_hw_data
*ha
= vha
->hw
;
4786 mbx_cmd_t
*mcp
= &mc
;
4788 if (IS_QLA2100(ha
) || IS_QLA2200(ha
)) {
4789 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x113b,
4790 "Implicit LOGO Unsupported.\n");
4791 return QLA_FUNCTION_FAILED
;
4795 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x113c,
4796 "Entering %s.\n", __func__
);
4798 /* Perform Implicit LOGO. */
4799 mcp
->mb
[0] = MBC_PORT_LOGOUT
;
4800 mcp
->mb
[1] = fcport
->loop_id
;
4801 mcp
->mb
[10] = BIT_15
;
4802 mcp
->out_mb
= MBX_10
|MBX_1
|MBX_0
;
4804 mcp
->tov
= MBX_TOV_SECONDS
;
4806 rval
= qla2x00_mailbox_command(vha
, mcp
);
4807 if (rval
!= QLA_SUCCESS
)
4808 ql_dbg(ql_dbg_mbx
, vha
, 0x113d,
4809 "Failed=%x mb[0]=%x.\n", rval
, mcp
->mb
[0]);
4811 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x113e,
4812 "Done %s.\n", __func__
);