2 * QLogic Fibre Channel HBA Driver
3 * Copyright (c) 2003-2013 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 (IS_P3P_TYPE(ha
) && 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_P3P_TYPE(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 ql_dbg(ql_dbg_mbx
+ ql_dbg_buffer
, vha
, 0x1111,
121 "Mailbox registers (OUT):\n");
122 for (cnt
= 0; cnt
< ha
->mbx_count
; cnt
++) {
123 if (IS_QLA2200(ha
) && cnt
== 8)
125 (uint16_t __iomem
*)MAILBOX_REG(ha
, ®
->isp
, 8);
126 if (mboxes
& BIT_0
) {
127 ql_dbg(ql_dbg_mbx
, vha
, 0x1112,
128 "mbox[%d]<-0x%04x\n", cnt
, *iptr
);
129 WRT_REG_WORD(optr
, *iptr
);
137 ql_dbg(ql_dbg_mbx
+ ql_dbg_buffer
, vha
, 0x1117,
138 "I/O Address = %p.\n", optr
);
140 /* Issue set host interrupt command to send cmd out. */
141 ha
->flags
.mbox_int
= 0;
142 clear_bit(MBX_INTERRUPT
, &ha
->mbx_cmd_flags
);
144 /* Unlock mbx registers and wait for interrupt */
145 ql_dbg(ql_dbg_mbx
, vha
, 0x100f,
146 "Going to unlock irq & waiting for interrupts. "
147 "jiffies=%lx.\n", jiffies
);
149 /* Wait for mbx cmd completion until timeout */
151 if ((!abort_active
&& io_lock_on
) || IS_NOPOLLING_TYPE(ha
)) {
152 set_bit(MBX_INTR_WAIT
, &ha
->mbx_cmd_flags
);
154 if (IS_P3P_TYPE(ha
)) {
155 if (RD_REG_DWORD(®
->isp82
.hint
) &
156 HINT_MBX_INT_PENDING
) {
157 spin_unlock_irqrestore(&ha
->hardware_lock
,
159 ha
->flags
.mbox_busy
= 0;
160 ql_dbg(ql_dbg_mbx
, vha
, 0x1010,
161 "Pending mailbox timeout, exiting.\n");
162 rval
= QLA_FUNCTION_TIMEOUT
;
165 WRT_REG_DWORD(®
->isp82
.hint
, HINT_MBX_INT_PENDING
);
166 } else if (IS_FWI2_CAPABLE(ha
))
167 WRT_REG_DWORD(®
->isp24
.hccr
, HCCRX_SET_HOST_INT
);
169 WRT_REG_WORD(®
->isp
.hccr
, HCCR_SET_HOST_INT
);
170 spin_unlock_irqrestore(&ha
->hardware_lock
, flags
);
172 if (!wait_for_completion_timeout(&ha
->mbx_intr_comp
,
174 ql_dbg(ql_dbg_mbx
, vha
, 0x117a,
175 "cmd=%x Timeout.\n", command
);
176 spin_lock_irqsave(&ha
->hardware_lock
, flags
);
177 clear_bit(MBX_INTR_WAIT
, &ha
->mbx_cmd_flags
);
178 spin_unlock_irqrestore(&ha
->hardware_lock
, flags
);
181 ql_dbg(ql_dbg_mbx
, vha
, 0x1011,
182 "Cmd=%x Polling Mode.\n", command
);
184 if (IS_P3P_TYPE(ha
)) {
185 if (RD_REG_DWORD(®
->isp82
.hint
) &
186 HINT_MBX_INT_PENDING
) {
187 spin_unlock_irqrestore(&ha
->hardware_lock
,
189 ha
->flags
.mbox_busy
= 0;
190 ql_dbg(ql_dbg_mbx
, vha
, 0x1012,
191 "Pending mailbox timeout, exiting.\n");
192 rval
= QLA_FUNCTION_TIMEOUT
;
195 WRT_REG_DWORD(®
->isp82
.hint
, HINT_MBX_INT_PENDING
);
196 } else if (IS_FWI2_CAPABLE(ha
))
197 WRT_REG_DWORD(®
->isp24
.hccr
, HCCRX_SET_HOST_INT
);
199 WRT_REG_WORD(®
->isp
.hccr
, HCCR_SET_HOST_INT
);
200 spin_unlock_irqrestore(&ha
->hardware_lock
, flags
);
202 wait_time
= jiffies
+ mcp
->tov
* HZ
; /* wait at most tov secs */
203 while (!ha
->flags
.mbox_int
) {
204 if (time_after(jiffies
, wait_time
))
207 /* Check for pending interrupts. */
208 qla2x00_poll(ha
->rsp_q_map
[0]);
210 if (!ha
->flags
.mbox_int
&&
212 command
== MBC_LOAD_RISC_RAM_EXTENDED
))
215 ql_dbg(ql_dbg_mbx
, vha
, 0x1013,
217 (uint
)((jiffies
- (wait_time
- (mcp
->tov
* HZ
)))/HZ
));
220 /* Check whether we timed out */
221 if (ha
->flags
.mbox_int
) {
224 ql_dbg(ql_dbg_mbx
, vha
, 0x1014,
225 "Cmd=%x completed.\n", command
);
227 /* Got interrupt. Clear the flag. */
228 ha
->flags
.mbox_int
= 0;
229 clear_bit(MBX_INTERRUPT
, &ha
->mbx_cmd_flags
);
231 if (IS_P3P_TYPE(ha
) && ha
->flags
.isp82xx_fw_hung
) {
232 ha
->flags
.mbox_busy
= 0;
233 /* Setting Link-Down error */
234 mcp
->mb
[0] = MBS_LINK_DOWN_ERROR
;
236 rval
= QLA_FUNCTION_FAILED
;
237 ql_log(ql_log_warn
, vha
, 0x1015,
238 "FW hung = %d.\n", ha
->flags
.isp82xx_fw_hung
);
242 if (ha
->mailbox_out
[0] != MBS_COMMAND_COMPLETE
)
243 rval
= QLA_FUNCTION_FAILED
;
245 /* Load return mailbox registers. */
247 iptr
= (uint16_t *)&ha
->mailbox_out
[0];
250 ql_dbg(ql_dbg_mbx
, vha
, 0x1113,
251 "Mailbox registers (IN):\n");
252 for (cnt
= 0; cnt
< ha
->mbx_count
; cnt
++) {
253 if (mboxes
& BIT_0
) {
255 ql_dbg(ql_dbg_mbx
, vha
, 0x1114,
256 "mbox[%d]->0x%04x\n", cnt
, *iptr2
);
268 if (IS_FWI2_CAPABLE(ha
)) {
269 mb0
= RD_REG_WORD(®
->isp24
.mailbox0
);
270 ictrl
= RD_REG_DWORD(®
->isp24
.ictrl
);
272 mb0
= RD_MAILBOX_REG(ha
, ®
->isp
, 0);
273 ictrl
= RD_REG_WORD(®
->isp
.ictrl
);
275 ql_dbg(ql_dbg_mbx
+ ql_dbg_buffer
, vha
, 0x1119,
276 "MBX Command timeout for cmd %x, iocontrol=%x jiffies=%lx "
277 "mb[0]=0x%x\n", command
, ictrl
, jiffies
, mb0
);
278 ql_dump_regs(ql_dbg_mbx
+ ql_dbg_buffer
, vha
, 0x1019);
281 * Attempt to capture a firmware dump for further analysis
282 * of the current firmware state. We do not need to do this
283 * if we are intentionally generating a dump.
285 if (mcp
->mb
[0] != MBC_GEN_SYSTEM_ERROR
)
286 ha
->isp_ops
->fw_dump(vha
, 0);
288 rval
= QLA_FUNCTION_TIMEOUT
;
291 ha
->flags
.mbox_busy
= 0;
296 if ((abort_active
|| !io_lock_on
) && !IS_NOPOLLING_TYPE(ha
)) {
297 ql_dbg(ql_dbg_mbx
, vha
, 0x101a,
298 "Checking for additional resp interrupt.\n");
300 /* polling mode for non isp_abort commands. */
301 qla2x00_poll(ha
->rsp_q_map
[0]);
304 if (rval
== QLA_FUNCTION_TIMEOUT
&&
305 mcp
->mb
[0] != MBC_GEN_SYSTEM_ERROR
) {
306 if (!io_lock_on
|| (mcp
->flags
& IOCTL_CMD
) ||
307 ha
->flags
.eeh_busy
) {
308 /* not in dpc. schedule it for dpc to take over. */
309 ql_dbg(ql_dbg_mbx
, vha
, 0x101b,
310 "Timeout, schedule isp_abort_needed.\n");
312 if (!test_bit(ISP_ABORT_NEEDED
, &vha
->dpc_flags
) &&
313 !test_bit(ABORT_ISP_ACTIVE
, &vha
->dpc_flags
) &&
314 !test_bit(ISP_ABORT_RETRY
, &vha
->dpc_flags
)) {
315 if (IS_QLA82XX(ha
)) {
316 ql_dbg(ql_dbg_mbx
, vha
, 0x112a,
317 "disabling pause transmit on port "
320 QLA82XX_CRB_NIU
+ 0x98,
321 CRB_NIU_XG_PAUSE_CTL_P0
|
322 CRB_NIU_XG_PAUSE_CTL_P1
);
324 ql_log(ql_log_info
, base_vha
, 0x101c,
325 "Mailbox cmd timeout occurred, cmd=0x%x, "
326 "mb[0]=0x%x, eeh_busy=0x%x. Scheduling ISP "
327 "abort.\n", command
, mcp
->mb
[0],
329 set_bit(ISP_ABORT_NEEDED
, &vha
->dpc_flags
);
330 qla2xxx_wake_dpc(vha
);
332 } else if (!abort_active
) {
333 /* call abort directly since we are in the DPC thread */
334 ql_dbg(ql_dbg_mbx
, vha
, 0x101d,
335 "Timeout, calling abort_isp.\n");
337 if (!test_bit(ISP_ABORT_NEEDED
, &vha
->dpc_flags
) &&
338 !test_bit(ABORT_ISP_ACTIVE
, &vha
->dpc_flags
) &&
339 !test_bit(ISP_ABORT_RETRY
, &vha
->dpc_flags
)) {
340 if (IS_QLA82XX(ha
)) {
341 ql_dbg(ql_dbg_mbx
, vha
, 0x112b,
342 "disabling pause transmit on port "
345 QLA82XX_CRB_NIU
+ 0x98,
346 CRB_NIU_XG_PAUSE_CTL_P0
|
347 CRB_NIU_XG_PAUSE_CTL_P1
);
349 ql_log(ql_log_info
, base_vha
, 0x101e,
350 "Mailbox cmd timeout occurred, cmd=0x%x, "
351 "mb[0]=0x%x. Scheduling ISP abort ",
352 command
, mcp
->mb
[0]);
353 set_bit(ABORT_ISP_ACTIVE
, &vha
->dpc_flags
);
354 clear_bit(ISP_ABORT_NEEDED
, &vha
->dpc_flags
);
355 /* Allow next mbx cmd to come in. */
356 complete(&ha
->mbx_cmd_comp
);
357 if (ha
->isp_ops
->abort_isp(vha
)) {
358 /* Failed. retry later. */
359 set_bit(ISP_ABORT_NEEDED
,
362 clear_bit(ABORT_ISP_ACTIVE
, &vha
->dpc_flags
);
363 ql_dbg(ql_dbg_mbx
, vha
, 0x101f,
364 "Finished abort_isp.\n");
371 /* Allow next mbx cmd to come in. */
372 complete(&ha
->mbx_cmd_comp
);
376 ql_log(ql_log_warn
, base_vha
, 0x1020,
377 "**** Failed mbx[0]=%x, mb[1]=%x, mb[2]=%x, mb[3]=%x, cmd=%x ****.\n",
378 mcp
->mb
[0], mcp
->mb
[1], mcp
->mb
[2], mcp
->mb
[3], command
);
380 ql_dbg(ql_dbg_mbx
, base_vha
, 0x1021, "Done %s.\n", __func__
);
387 qla2x00_load_ram(scsi_qla_host_t
*vha
, dma_addr_t req_dma
, uint32_t risc_addr
,
388 uint32_t risc_code_size
)
391 struct qla_hw_data
*ha
= vha
->hw
;
393 mbx_cmd_t
*mcp
= &mc
;
395 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x1022,
396 "Entered %s.\n", __func__
);
398 if (MSW(risc_addr
) || IS_FWI2_CAPABLE(ha
)) {
399 mcp
->mb
[0] = MBC_LOAD_RISC_RAM_EXTENDED
;
400 mcp
->mb
[8] = MSW(risc_addr
);
401 mcp
->out_mb
= MBX_8
|MBX_0
;
403 mcp
->mb
[0] = MBC_LOAD_RISC_RAM
;
406 mcp
->mb
[1] = LSW(risc_addr
);
407 mcp
->mb
[2] = MSW(req_dma
);
408 mcp
->mb
[3] = LSW(req_dma
);
409 mcp
->mb
[6] = MSW(MSD(req_dma
));
410 mcp
->mb
[7] = LSW(MSD(req_dma
));
411 mcp
->out_mb
|= MBX_7
|MBX_6
|MBX_3
|MBX_2
|MBX_1
;
412 if (IS_FWI2_CAPABLE(ha
)) {
413 mcp
->mb
[4] = MSW(risc_code_size
);
414 mcp
->mb
[5] = LSW(risc_code_size
);
415 mcp
->out_mb
|= MBX_5
|MBX_4
;
417 mcp
->mb
[4] = LSW(risc_code_size
);
418 mcp
->out_mb
|= MBX_4
;
422 mcp
->tov
= MBX_TOV_SECONDS
;
424 rval
= qla2x00_mailbox_command(vha
, mcp
);
426 if (rval
!= QLA_SUCCESS
) {
427 ql_dbg(ql_dbg_mbx
, vha
, 0x1023,
428 "Failed=%x mb[0]=%x.\n", rval
, mcp
->mb
[0]);
430 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x1024,
431 "Done %s.\n", __func__
);
437 #define EXTENDED_BB_CREDITS BIT_0
440 * Start adapter firmware.
443 * ha = adapter block pointer.
444 * TARGET_QUEUE_LOCK must be released.
445 * ADAPTER_STATE_LOCK must be released.
448 * qla2x00 local function return status code.
454 qla2x00_execute_fw(scsi_qla_host_t
*vha
, uint32_t risc_addr
)
457 struct qla_hw_data
*ha
= vha
->hw
;
459 mbx_cmd_t
*mcp
= &mc
;
461 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x1025,
462 "Entered %s.\n", __func__
);
464 mcp
->mb
[0] = MBC_EXECUTE_FIRMWARE
;
467 if (IS_FWI2_CAPABLE(ha
)) {
468 mcp
->mb
[1] = MSW(risc_addr
);
469 mcp
->mb
[2] = LSW(risc_addr
);
471 if (IS_QLA81XX(ha
) || IS_QLA83XX(ha
)) {
472 struct nvram_81xx
*nv
= ha
->nvram
;
473 mcp
->mb
[4] = (nv
->enhanced_features
&
474 EXTENDED_BB_CREDITS
);
477 mcp
->out_mb
|= MBX_4
|MBX_3
|MBX_2
|MBX_1
;
480 mcp
->mb
[1] = LSW(risc_addr
);
481 mcp
->out_mb
|= MBX_1
;
482 if (IS_QLA2322(ha
) || IS_QLA6322(ha
)) {
484 mcp
->out_mb
|= MBX_2
;
488 mcp
->tov
= MBX_TOV_SECONDS
;
490 rval
= qla2x00_mailbox_command(vha
, mcp
);
492 if (rval
!= QLA_SUCCESS
) {
493 ql_dbg(ql_dbg_mbx
, vha
, 0x1026,
494 "Failed=%x mb[0]=%x.\n", rval
, mcp
->mb
[0]);
496 if (IS_FWI2_CAPABLE(ha
)) {
497 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x1027,
498 "Done exchanges=%x.\n", mcp
->mb
[1]);
500 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x1028,
501 "Done %s.\n", __func__
);
509 * qla2x00_get_fw_version
510 * Get firmware version.
513 * ha: adapter state pointer.
514 * major: pointer for major number.
515 * minor: pointer for minor number.
516 * subminor: pointer for subminor number.
519 * qla2x00 local function return status code.
525 qla2x00_get_fw_version(scsi_qla_host_t
*vha
)
529 mbx_cmd_t
*mcp
= &mc
;
530 struct qla_hw_data
*ha
= vha
->hw
;
532 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x1029,
533 "Entered %s.\n", __func__
);
535 mcp
->mb
[0] = MBC_GET_FIRMWARE_VERSION
;
537 mcp
->in_mb
= MBX_6
|MBX_5
|MBX_4
|MBX_3
|MBX_2
|MBX_1
|MBX_0
;
538 if (IS_QLA81XX(vha
->hw
) || IS_QLA8031(ha
) || IS_QLA8044(ha
))
539 mcp
->in_mb
|= MBX_13
|MBX_12
|MBX_11
|MBX_10
|MBX_9
|MBX_8
;
540 if (IS_FWI2_CAPABLE(ha
))
541 mcp
->in_mb
|= MBX_17
|MBX_16
|MBX_15
;
543 mcp
->tov
= MBX_TOV_SECONDS
;
544 rval
= qla2x00_mailbox_command(vha
, mcp
);
545 if (rval
!= QLA_SUCCESS
)
548 /* Return mailbox data. */
549 ha
->fw_major_version
= mcp
->mb
[1];
550 ha
->fw_minor_version
= mcp
->mb
[2];
551 ha
->fw_subminor_version
= mcp
->mb
[3];
552 ha
->fw_attributes
= mcp
->mb
[6];
553 if (IS_QLA2100(vha
->hw
) || IS_QLA2200(vha
->hw
))
554 ha
->fw_memory_size
= 0x1FFFF; /* Defaults to 128KB. */
556 ha
->fw_memory_size
= (mcp
->mb
[5] << 16) | mcp
->mb
[4];
557 if (IS_QLA81XX(vha
->hw
) || IS_QLA8031(vha
->hw
) || IS_QLA8044(ha
)) {
558 ha
->mpi_version
[0] = mcp
->mb
[10] & 0xff;
559 ha
->mpi_version
[1] = mcp
->mb
[11] >> 8;
560 ha
->mpi_version
[2] = mcp
->mb
[11] & 0xff;
561 ha
->mpi_capabilities
= (mcp
->mb
[12] << 16) | mcp
->mb
[13];
562 ha
->phy_version
[0] = mcp
->mb
[8] & 0xff;
563 ha
->phy_version
[1] = mcp
->mb
[9] >> 8;
564 ha
->phy_version
[2] = mcp
->mb
[9] & 0xff;
566 if (IS_FWI2_CAPABLE(ha
)) {
567 ha
->fw_attributes_h
= mcp
->mb
[15];
568 ha
->fw_attributes_ext
[0] = mcp
->mb
[16];
569 ha
->fw_attributes_ext
[1] = mcp
->mb
[17];
570 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x1139,
571 "%s: FW_attributes Upper: 0x%x, Lower: 0x%x.\n",
572 __func__
, mcp
->mb
[15], mcp
->mb
[6]);
573 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x112f,
574 "%s: Ext_FwAttributes Upper: 0x%x, Lower: 0x%x.\n",
575 __func__
, mcp
->mb
[17], mcp
->mb
[16]);
579 if (rval
!= QLA_SUCCESS
) {
581 ql_dbg(ql_dbg_mbx
, vha
, 0x102a, "Failed=%x.\n", rval
);
584 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x102b,
585 "Done %s.\n", __func__
);
591 * qla2x00_get_fw_options
592 * Set firmware options.
595 * ha = adapter block pointer.
596 * fwopt = pointer for firmware options.
599 * qla2x00 local function return status code.
605 qla2x00_get_fw_options(scsi_qla_host_t
*vha
, uint16_t *fwopts
)
609 mbx_cmd_t
*mcp
= &mc
;
611 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x102c,
612 "Entered %s.\n", __func__
);
614 mcp
->mb
[0] = MBC_GET_FIRMWARE_OPTION
;
616 mcp
->in_mb
= MBX_3
|MBX_2
|MBX_1
|MBX_0
;
617 mcp
->tov
= MBX_TOV_SECONDS
;
619 rval
= qla2x00_mailbox_command(vha
, mcp
);
621 if (rval
!= QLA_SUCCESS
) {
623 ql_dbg(ql_dbg_mbx
, vha
, 0x102d, "Failed=%x.\n", rval
);
625 fwopts
[0] = mcp
->mb
[0];
626 fwopts
[1] = mcp
->mb
[1];
627 fwopts
[2] = mcp
->mb
[2];
628 fwopts
[3] = mcp
->mb
[3];
630 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x102e,
631 "Done %s.\n", __func__
);
639 * qla2x00_set_fw_options
640 * Set firmware options.
643 * ha = adapter block pointer.
644 * fwopt = pointer for firmware options.
647 * qla2x00 local function return status code.
653 qla2x00_set_fw_options(scsi_qla_host_t
*vha
, uint16_t *fwopts
)
657 mbx_cmd_t
*mcp
= &mc
;
659 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x102f,
660 "Entered %s.\n", __func__
);
662 mcp
->mb
[0] = MBC_SET_FIRMWARE_OPTION
;
663 mcp
->mb
[1] = fwopts
[1];
664 mcp
->mb
[2] = fwopts
[2];
665 mcp
->mb
[3] = fwopts
[3];
666 mcp
->out_mb
= MBX_3
|MBX_2
|MBX_1
|MBX_0
;
668 if (IS_FWI2_CAPABLE(vha
->hw
)) {
671 mcp
->mb
[10] = fwopts
[10];
672 mcp
->mb
[11] = fwopts
[11];
673 mcp
->mb
[12] = 0; /* Undocumented, but used */
674 mcp
->out_mb
|= MBX_12
|MBX_11
|MBX_10
;
676 mcp
->tov
= MBX_TOV_SECONDS
;
678 rval
= qla2x00_mailbox_command(vha
, mcp
);
680 fwopts
[0] = mcp
->mb
[0];
682 if (rval
!= QLA_SUCCESS
) {
684 ql_dbg(ql_dbg_mbx
, vha
, 0x1030,
685 "Failed=%x (%x/%x).\n", rval
, mcp
->mb
[0], mcp
->mb
[1]);
688 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x1031,
689 "Done %s.\n", __func__
);
696 * qla2x00_mbx_reg_test
697 * Mailbox register wrap test.
700 * ha = adapter block pointer.
701 * TARGET_QUEUE_LOCK must be released.
702 * ADAPTER_STATE_LOCK must be released.
705 * qla2x00 local function return status code.
711 qla2x00_mbx_reg_test(scsi_qla_host_t
*vha
)
715 mbx_cmd_t
*mcp
= &mc
;
717 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x1032,
718 "Entered %s.\n", __func__
);
720 mcp
->mb
[0] = MBC_MAILBOX_REGISTER_TEST
;
728 mcp
->out_mb
= MBX_7
|MBX_6
|MBX_5
|MBX_4
|MBX_3
|MBX_2
|MBX_1
|MBX_0
;
729 mcp
->in_mb
= MBX_7
|MBX_6
|MBX_5
|MBX_4
|MBX_3
|MBX_2
|MBX_1
|MBX_0
;
730 mcp
->tov
= MBX_TOV_SECONDS
;
732 rval
= qla2x00_mailbox_command(vha
, mcp
);
734 if (rval
== QLA_SUCCESS
) {
735 if (mcp
->mb
[1] != 0xAAAA || mcp
->mb
[2] != 0x5555 ||
736 mcp
->mb
[3] != 0xAA55 || mcp
->mb
[4] != 0x55AA)
737 rval
= QLA_FUNCTION_FAILED
;
738 if (mcp
->mb
[5] != 0xA5A5 || mcp
->mb
[6] != 0x5A5A ||
739 mcp
->mb
[7] != 0x2525)
740 rval
= QLA_FUNCTION_FAILED
;
743 if (rval
!= QLA_SUCCESS
) {
745 ql_dbg(ql_dbg_mbx
, vha
, 0x1033, "Failed=%x.\n", rval
);
748 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x1034,
749 "Done %s.\n", __func__
);
756 * qla2x00_verify_checksum
757 * Verify firmware checksum.
760 * ha = adapter block pointer.
761 * TARGET_QUEUE_LOCK must be released.
762 * ADAPTER_STATE_LOCK must be released.
765 * qla2x00 local function return status code.
771 qla2x00_verify_checksum(scsi_qla_host_t
*vha
, uint32_t risc_addr
)
775 mbx_cmd_t
*mcp
= &mc
;
777 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x1035,
778 "Entered %s.\n", __func__
);
780 mcp
->mb
[0] = MBC_VERIFY_CHECKSUM
;
783 if (IS_FWI2_CAPABLE(vha
->hw
)) {
784 mcp
->mb
[1] = MSW(risc_addr
);
785 mcp
->mb
[2] = LSW(risc_addr
);
786 mcp
->out_mb
|= MBX_2
|MBX_1
;
787 mcp
->in_mb
|= MBX_2
|MBX_1
;
789 mcp
->mb
[1] = LSW(risc_addr
);
790 mcp
->out_mb
|= MBX_1
;
794 mcp
->tov
= MBX_TOV_SECONDS
;
796 rval
= qla2x00_mailbox_command(vha
, mcp
);
798 if (rval
!= QLA_SUCCESS
) {
799 ql_dbg(ql_dbg_mbx
, vha
, 0x1036,
800 "Failed=%x chm sum=%x.\n", rval
, IS_FWI2_CAPABLE(vha
->hw
) ?
801 (mcp
->mb
[2] << 16) | mcp
->mb
[1] : mcp
->mb
[1]);
803 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x1037,
804 "Done %s.\n", __func__
);
812 * Issue IOCB using mailbox command
815 * ha = adapter state pointer.
816 * buffer = buffer pointer.
817 * phys_addr = physical address of buffer.
818 * size = size of buffer.
819 * TARGET_QUEUE_LOCK must be released.
820 * ADAPTER_STATE_LOCK must be released.
823 * qla2x00 local function return status code.
829 qla2x00_issue_iocb_timeout(scsi_qla_host_t
*vha
, void *buffer
,
830 dma_addr_t phys_addr
, size_t size
, uint32_t tov
)
834 mbx_cmd_t
*mcp
= &mc
;
836 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x1038,
837 "Entered %s.\n", __func__
);
839 mcp
->mb
[0] = MBC_IOCB_COMMAND_A64
;
841 mcp
->mb
[2] = MSW(phys_addr
);
842 mcp
->mb
[3] = LSW(phys_addr
);
843 mcp
->mb
[6] = MSW(MSD(phys_addr
));
844 mcp
->mb
[7] = LSW(MSD(phys_addr
));
845 mcp
->out_mb
= MBX_7
|MBX_6
|MBX_3
|MBX_2
|MBX_1
|MBX_0
;
846 mcp
->in_mb
= MBX_2
|MBX_0
;
849 rval
= qla2x00_mailbox_command(vha
, mcp
);
851 if (rval
!= QLA_SUCCESS
) {
853 ql_dbg(ql_dbg_mbx
, vha
, 0x1039, "Failed=%x.\n", rval
);
855 sts_entry_t
*sts_entry
= (sts_entry_t
*) buffer
;
857 /* Mask reserved bits. */
858 sts_entry
->entry_status
&=
859 IS_FWI2_CAPABLE(vha
->hw
) ? RF_MASK_24XX
: RF_MASK
;
860 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x103a,
861 "Done %s.\n", __func__
);
868 qla2x00_issue_iocb(scsi_qla_host_t
*vha
, void *buffer
, dma_addr_t phys_addr
,
871 return qla2x00_issue_iocb_timeout(vha
, buffer
, phys_addr
, size
,
876 * qla2x00_abort_command
877 * Abort command aborts a specified IOCB.
880 * ha = adapter block pointer.
881 * sp = SB structure pointer.
884 * qla2x00 local function return status code.
890 qla2x00_abort_command(srb_t
*sp
)
892 unsigned long flags
= 0;
896 mbx_cmd_t
*mcp
= &mc
;
897 fc_port_t
*fcport
= sp
->fcport
;
898 scsi_qla_host_t
*vha
= fcport
->vha
;
899 struct qla_hw_data
*ha
= vha
->hw
;
900 struct req_que
*req
= vha
->req
;
901 struct scsi_cmnd
*cmd
= GET_CMD_SP(sp
);
903 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x103b,
904 "Entered %s.\n", __func__
);
906 spin_lock_irqsave(&ha
->hardware_lock
, flags
);
907 for (handle
= 1; handle
< req
->num_outstanding_cmds
; handle
++) {
908 if (req
->outstanding_cmds
[handle
] == sp
)
911 spin_unlock_irqrestore(&ha
->hardware_lock
, flags
);
913 if (handle
== req
->num_outstanding_cmds
) {
914 /* command not found */
915 return QLA_FUNCTION_FAILED
;
918 mcp
->mb
[0] = MBC_ABORT_COMMAND
;
919 if (HAS_EXTENDED_IDS(ha
))
920 mcp
->mb
[1] = fcport
->loop_id
;
922 mcp
->mb
[1] = fcport
->loop_id
<< 8;
923 mcp
->mb
[2] = (uint16_t)handle
;
924 mcp
->mb
[3] = (uint16_t)(handle
>> 16);
925 mcp
->mb
[6] = (uint16_t)cmd
->device
->lun
;
926 mcp
->out_mb
= MBX_6
|MBX_3
|MBX_2
|MBX_1
|MBX_0
;
928 mcp
->tov
= MBX_TOV_SECONDS
;
930 rval
= qla2x00_mailbox_command(vha
, mcp
);
932 if (rval
!= QLA_SUCCESS
) {
933 ql_dbg(ql_dbg_mbx
, vha
, 0x103c, "Failed=%x.\n", rval
);
935 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x103d,
936 "Done %s.\n", __func__
);
943 qla2x00_abort_target(struct fc_port
*fcport
, unsigned int l
, int tag
)
947 mbx_cmd_t
*mcp
= &mc
;
948 scsi_qla_host_t
*vha
;
955 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x103e,
956 "Entered %s.\n", __func__
);
958 req
= vha
->hw
->req_q_map
[0];
960 mcp
->mb
[0] = MBC_ABORT_TARGET
;
961 mcp
->out_mb
= MBX_9
|MBX_2
|MBX_1
|MBX_0
;
962 if (HAS_EXTENDED_IDS(vha
->hw
)) {
963 mcp
->mb
[1] = fcport
->loop_id
;
965 mcp
->out_mb
|= MBX_10
;
967 mcp
->mb
[1] = fcport
->loop_id
<< 8;
969 mcp
->mb
[2] = vha
->hw
->loop_reset_delay
;
970 mcp
->mb
[9] = vha
->vp_idx
;
973 mcp
->tov
= MBX_TOV_SECONDS
;
975 rval
= qla2x00_mailbox_command(vha
, mcp
);
976 if (rval
!= QLA_SUCCESS
) {
977 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x103f,
978 "Failed=%x.\n", rval
);
981 /* Issue marker IOCB. */
982 rval2
= qla2x00_marker(vha
, req
, rsp
, fcport
->loop_id
, 0,
984 if (rval2
!= QLA_SUCCESS
) {
985 ql_dbg(ql_dbg_mbx
, vha
, 0x1040,
986 "Failed to issue marker IOCB (%x).\n", rval2
);
988 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x1041,
989 "Done %s.\n", __func__
);
996 qla2x00_lun_reset(struct fc_port
*fcport
, unsigned int l
, int tag
)
1000 mbx_cmd_t
*mcp
= &mc
;
1001 scsi_qla_host_t
*vha
;
1002 struct req_que
*req
;
1003 struct rsp_que
*rsp
;
1007 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x1042,
1008 "Entered %s.\n", __func__
);
1010 req
= vha
->hw
->req_q_map
[0];
1012 mcp
->mb
[0] = MBC_LUN_RESET
;
1013 mcp
->out_mb
= MBX_9
|MBX_3
|MBX_2
|MBX_1
|MBX_0
;
1014 if (HAS_EXTENDED_IDS(vha
->hw
))
1015 mcp
->mb
[1] = fcport
->loop_id
;
1017 mcp
->mb
[1] = fcport
->loop_id
<< 8;
1020 mcp
->mb
[9] = vha
->vp_idx
;
1023 mcp
->tov
= MBX_TOV_SECONDS
;
1025 rval
= qla2x00_mailbox_command(vha
, mcp
);
1026 if (rval
!= QLA_SUCCESS
) {
1027 ql_dbg(ql_dbg_mbx
, vha
, 0x1043, "Failed=%x.\n", rval
);
1030 /* Issue marker IOCB. */
1031 rval2
= qla2x00_marker(vha
, req
, rsp
, fcport
->loop_id
, l
,
1033 if (rval2
!= QLA_SUCCESS
) {
1034 ql_dbg(ql_dbg_mbx
, vha
, 0x1044,
1035 "Failed to issue marker IOCB (%x).\n", rval2
);
1037 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x1045,
1038 "Done %s.\n", __func__
);
1045 * qla2x00_get_adapter_id
1046 * Get adapter ID and topology.
1049 * ha = adapter block pointer.
1050 * id = pointer for loop ID.
1051 * al_pa = pointer for AL_PA.
1052 * area = pointer for area.
1053 * domain = pointer for domain.
1054 * top = pointer for topology.
1055 * TARGET_QUEUE_LOCK must be released.
1056 * ADAPTER_STATE_LOCK must be released.
1059 * qla2x00 local function return status code.
1065 qla2x00_get_adapter_id(scsi_qla_host_t
*vha
, uint16_t *id
, uint8_t *al_pa
,
1066 uint8_t *area
, uint8_t *domain
, uint16_t *top
, uint16_t *sw_cap
)
1070 mbx_cmd_t
*mcp
= &mc
;
1072 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x1046,
1073 "Entered %s.\n", __func__
);
1075 mcp
->mb
[0] = MBC_GET_ADAPTER_LOOP_ID
;
1076 mcp
->mb
[9] = vha
->vp_idx
;
1077 mcp
->out_mb
= MBX_9
|MBX_0
;
1078 mcp
->in_mb
= MBX_9
|MBX_7
|MBX_6
|MBX_3
|MBX_2
|MBX_1
|MBX_0
;
1079 if (IS_CNA_CAPABLE(vha
->hw
))
1080 mcp
->in_mb
|= MBX_13
|MBX_12
|MBX_11
|MBX_10
;
1081 mcp
->tov
= MBX_TOV_SECONDS
;
1083 rval
= qla2x00_mailbox_command(vha
, mcp
);
1084 if (mcp
->mb
[0] == MBS_COMMAND_ERROR
)
1085 rval
= QLA_COMMAND_ERROR
;
1086 else if (mcp
->mb
[0] == MBS_INVALID_COMMAND
)
1087 rval
= QLA_INVALID_COMMAND
;
1091 *al_pa
= LSB(mcp
->mb
[2]);
1092 *area
= MSB(mcp
->mb
[2]);
1093 *domain
= LSB(mcp
->mb
[3]);
1095 *sw_cap
= mcp
->mb
[7];
1097 if (rval
!= QLA_SUCCESS
) {
1099 ql_dbg(ql_dbg_mbx
, vha
, 0x1047, "Failed=%x.\n", rval
);
1101 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x1048,
1102 "Done %s.\n", __func__
);
1104 if (IS_CNA_CAPABLE(vha
->hw
)) {
1105 vha
->fcoe_vlan_id
= mcp
->mb
[9] & 0xfff;
1106 vha
->fcoe_fcf_idx
= mcp
->mb
[10];
1107 vha
->fcoe_vn_port_mac
[5] = mcp
->mb
[11] >> 8;
1108 vha
->fcoe_vn_port_mac
[4] = mcp
->mb
[11] & 0xff;
1109 vha
->fcoe_vn_port_mac
[3] = mcp
->mb
[12] >> 8;
1110 vha
->fcoe_vn_port_mac
[2] = mcp
->mb
[12] & 0xff;
1111 vha
->fcoe_vn_port_mac
[1] = mcp
->mb
[13] >> 8;
1112 vha
->fcoe_vn_port_mac
[0] = mcp
->mb
[13] & 0xff;
1120 * qla2x00_get_retry_cnt
1121 * Get current firmware login retry count and delay.
1124 * ha = adapter block pointer.
1125 * retry_cnt = pointer to login retry count.
1126 * tov = pointer to login timeout value.
1129 * qla2x00 local function return status code.
1135 qla2x00_get_retry_cnt(scsi_qla_host_t
*vha
, uint8_t *retry_cnt
, uint8_t *tov
,
1141 mbx_cmd_t
*mcp
= &mc
;
1143 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x1049,
1144 "Entered %s.\n", __func__
);
1146 mcp
->mb
[0] = MBC_GET_RETRY_COUNT
;
1147 mcp
->out_mb
= MBX_0
;
1148 mcp
->in_mb
= MBX_3
|MBX_2
|MBX_1
|MBX_0
;
1149 mcp
->tov
= MBX_TOV_SECONDS
;
1151 rval
= qla2x00_mailbox_command(vha
, mcp
);
1153 if (rval
!= QLA_SUCCESS
) {
1155 ql_dbg(ql_dbg_mbx
, vha
, 0x104a,
1156 "Failed=%x mb[0]=%x.\n", rval
, mcp
->mb
[0]);
1158 /* Convert returned data and check our values. */
1159 *r_a_tov
= mcp
->mb
[3] / 2;
1160 ratov
= (mcp
->mb
[3]/2) / 10; /* mb[3] value is in 100ms */
1161 if (mcp
->mb
[1] * ratov
> (*retry_cnt
) * (*tov
)) {
1162 /* Update to the larger values */
1163 *retry_cnt
= (uint8_t)mcp
->mb
[1];
1167 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x104b,
1168 "Done %s mb3=%d ratov=%d.\n", __func__
, mcp
->mb
[3], ratov
);
1175 * qla2x00_init_firmware
1176 * Initialize adapter firmware.
1179 * ha = adapter block pointer.
1180 * dptr = Initialization control block pointer.
1181 * size = size of initialization control block.
1182 * TARGET_QUEUE_LOCK must be released.
1183 * ADAPTER_STATE_LOCK must be released.
1186 * qla2x00 local function return status code.
1192 qla2x00_init_firmware(scsi_qla_host_t
*vha
, uint16_t size
)
1196 mbx_cmd_t
*mcp
= &mc
;
1197 struct qla_hw_data
*ha
= vha
->hw
;
1199 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x104c,
1200 "Entered %s.\n", __func__
);
1202 if (IS_P3P_TYPE(ha
) && ql2xdbwr
)
1203 qla82xx_wr_32(ha
, ha
->nxdb_wr_ptr
,
1204 (0x04 | (ha
->portnum
<< 5) | (0 << 8) | (0 << 16)));
1206 if (ha
->flags
.npiv_supported
)
1207 mcp
->mb
[0] = MBC_MID_INITIALIZE_FIRMWARE
;
1209 mcp
->mb
[0] = MBC_INITIALIZE_FIRMWARE
;
1212 mcp
->mb
[2] = MSW(ha
->init_cb_dma
);
1213 mcp
->mb
[3] = LSW(ha
->init_cb_dma
);
1214 mcp
->mb
[6] = MSW(MSD(ha
->init_cb_dma
));
1215 mcp
->mb
[7] = LSW(MSD(ha
->init_cb_dma
));
1216 mcp
->out_mb
= MBX_7
|MBX_6
|MBX_3
|MBX_2
|MBX_1
|MBX_0
;
1217 if ((IS_QLA81XX(ha
) || IS_QLA83XX(ha
)) && ha
->ex_init_cb
->ex_version
) {
1219 mcp
->mb
[10] = MSW(ha
->ex_init_cb_dma
);
1220 mcp
->mb
[11] = LSW(ha
->ex_init_cb_dma
);
1221 mcp
->mb
[12] = MSW(MSD(ha
->ex_init_cb_dma
));
1222 mcp
->mb
[13] = LSW(MSD(ha
->ex_init_cb_dma
));
1223 mcp
->mb
[14] = sizeof(*ha
->ex_init_cb
);
1224 mcp
->out_mb
|= MBX_14
|MBX_13
|MBX_12
|MBX_11
|MBX_10
;
1226 /* 1 and 2 should normally be captured. */
1227 mcp
->in_mb
= MBX_2
|MBX_1
|MBX_0
;
1229 /* mb3 is additional info about the installed SFP. */
1230 mcp
->in_mb
|= MBX_3
;
1231 mcp
->buf_size
= size
;
1232 mcp
->flags
= MBX_DMA_OUT
;
1233 mcp
->tov
= MBX_TOV_SECONDS
;
1234 rval
= qla2x00_mailbox_command(vha
, mcp
);
1236 if (rval
!= QLA_SUCCESS
) {
1238 ql_dbg(ql_dbg_mbx
, vha
, 0x104d,
1239 "Failed=%x mb[0]=%x, mb[1]=%x, mb[2]=%x, mb[3]=%x,.\n",
1240 rval
, mcp
->mb
[0], mcp
->mb
[1], mcp
->mb
[2], mcp
->mb
[3]);
1243 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x104e,
1244 "Done %s.\n", __func__
);
1251 * qla2x00_get_node_name_list
1252 * Issue get node name list mailbox command, kmalloc()
1253 * and return the resulting list. Caller must kfree() it!
1256 * ha = adapter state pointer.
1257 * out_data = resulting list
1258 * out_len = length of the resulting list
1261 * qla2x00 local function return status code.
1267 qla2x00_get_node_name_list(scsi_qla_host_t
*vha
, void **out_data
, int *out_len
)
1269 struct qla_hw_data
*ha
= vha
->hw
;
1270 struct qla_port_24xx_data
*list
= NULL
;
1273 dma_addr_t pmap_dma
;
1279 dma_size
= left
* sizeof(*list
);
1280 pmap
= dma_alloc_coherent(&ha
->pdev
->dev
, dma_size
,
1281 &pmap_dma
, GFP_KERNEL
);
1283 ql_log(ql_log_warn
, vha
, 0x113f,
1284 "%s(%ld): DMA Alloc failed of %ld\n",
1285 __func__
, vha
->host_no
, dma_size
);
1286 rval
= QLA_MEMORY_ALLOC_FAILED
;
1290 mc
.mb
[0] = MBC_PORT_NODE_NAME_LIST
;
1291 mc
.mb
[1] = BIT_1
| BIT_3
;
1292 mc
.mb
[2] = MSW(pmap_dma
);
1293 mc
.mb
[3] = LSW(pmap_dma
);
1294 mc
.mb
[6] = MSW(MSD(pmap_dma
));
1295 mc
.mb
[7] = LSW(MSD(pmap_dma
));
1296 mc
.mb
[8] = dma_size
;
1297 mc
.out_mb
= MBX_0
|MBX_1
|MBX_2
|MBX_3
|MBX_6
|MBX_7
|MBX_8
;
1298 mc
.in_mb
= MBX_0
|MBX_1
;
1300 mc
.flags
= MBX_DMA_IN
;
1302 rval
= qla2x00_mailbox_command(vha
, &mc
);
1303 if (rval
!= QLA_SUCCESS
) {
1304 if ((mc
.mb
[0] == MBS_COMMAND_ERROR
) &&
1305 (mc
.mb
[1] == 0xA)) {
1306 left
+= le16_to_cpu(mc
.mb
[2]) /
1307 sizeof(struct qla_port_24xx_data
);
1315 list
= kzalloc(dma_size
, GFP_KERNEL
);
1317 ql_log(ql_log_warn
, vha
, 0x1140,
1318 "%s(%ld): failed to allocate node names list "
1319 "structure.\n", __func__
, vha
->host_no
);
1320 rval
= QLA_MEMORY_ALLOC_FAILED
;
1324 memcpy(list
, pmap
, dma_size
);
1326 dma_free_coherent(&ha
->pdev
->dev
, dma_size
, pmap
, pmap_dma
);
1330 *out_len
= dma_size
;
1336 dma_free_coherent(&ha
->pdev
->dev
, dma_size
, pmap
, pmap_dma
);
1341 * qla2x00_get_port_database
1342 * Issue normal/enhanced get port database mailbox command
1343 * and copy device name as necessary.
1346 * ha = adapter state pointer.
1347 * dev = structure pointer.
1348 * opt = enhanced cmd option byte.
1351 * qla2x00 local function return status code.
1357 qla2x00_get_port_database(scsi_qla_host_t
*vha
, fc_port_t
*fcport
, uint8_t opt
)
1361 mbx_cmd_t
*mcp
= &mc
;
1362 port_database_t
*pd
;
1363 struct port_database_24xx
*pd24
;
1365 struct qla_hw_data
*ha
= vha
->hw
;
1367 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x104f,
1368 "Entered %s.\n", __func__
);
1371 pd
= dma_pool_alloc(ha
->s_dma_pool
, GFP_KERNEL
, &pd_dma
);
1373 ql_log(ql_log_warn
, vha
, 0x1050,
1374 "Failed to allocate port database structure.\n");
1375 return QLA_MEMORY_ALLOC_FAILED
;
1377 memset(pd
, 0, max(PORT_DATABASE_SIZE
, PORT_DATABASE_24XX_SIZE
));
1379 mcp
->mb
[0] = MBC_GET_PORT_DATABASE
;
1380 if (opt
!= 0 && !IS_FWI2_CAPABLE(ha
))
1381 mcp
->mb
[0] = MBC_ENHANCED_GET_PORT_DATABASE
;
1382 mcp
->mb
[2] = MSW(pd_dma
);
1383 mcp
->mb
[3] = LSW(pd_dma
);
1384 mcp
->mb
[6] = MSW(MSD(pd_dma
));
1385 mcp
->mb
[7] = LSW(MSD(pd_dma
));
1386 mcp
->mb
[9] = vha
->vp_idx
;
1387 mcp
->out_mb
= MBX_9
|MBX_7
|MBX_6
|MBX_3
|MBX_2
|MBX_0
;
1389 if (IS_FWI2_CAPABLE(ha
)) {
1390 mcp
->mb
[1] = fcport
->loop_id
;
1392 mcp
->out_mb
|= MBX_10
|MBX_1
;
1393 mcp
->in_mb
|= MBX_1
;
1394 } else if (HAS_EXTENDED_IDS(ha
)) {
1395 mcp
->mb
[1] = fcport
->loop_id
;
1397 mcp
->out_mb
|= MBX_10
|MBX_1
;
1399 mcp
->mb
[1] = fcport
->loop_id
<< 8 | opt
;
1400 mcp
->out_mb
|= MBX_1
;
1402 mcp
->buf_size
= IS_FWI2_CAPABLE(ha
) ?
1403 PORT_DATABASE_24XX_SIZE
: PORT_DATABASE_SIZE
;
1404 mcp
->flags
= MBX_DMA_IN
;
1405 mcp
->tov
= (ha
->login_timeout
* 2) + (ha
->login_timeout
/ 2);
1406 rval
= qla2x00_mailbox_command(vha
, mcp
);
1407 if (rval
!= QLA_SUCCESS
)
1410 if (IS_FWI2_CAPABLE(ha
)) {
1412 pd24
= (struct port_database_24xx
*) pd
;
1414 /* Check for logged in state. */
1415 if (pd24
->current_login_state
!= PDS_PRLI_COMPLETE
&&
1416 pd24
->last_login_state
!= PDS_PRLI_COMPLETE
) {
1417 ql_dbg(ql_dbg_mbx
, vha
, 0x1051,
1418 "Unable to verify login-state (%x/%x) for "
1419 "loop_id %x.\n", pd24
->current_login_state
,
1420 pd24
->last_login_state
, fcport
->loop_id
);
1421 rval
= QLA_FUNCTION_FAILED
;
1425 if (fcport
->loop_id
== FC_NO_LOOP_ID
||
1426 (memcmp(fcport
->port_name
, (uint8_t *)&zero
, 8) &&
1427 memcmp(fcport
->port_name
, pd24
->port_name
, 8))) {
1428 /* We lost the device mid way. */
1429 rval
= QLA_NOT_LOGGED_IN
;
1433 /* Names are little-endian. */
1434 memcpy(fcport
->node_name
, pd24
->node_name
, WWN_SIZE
);
1435 memcpy(fcport
->port_name
, pd24
->port_name
, WWN_SIZE
);
1437 /* Get port_id of device. */
1438 fcport
->d_id
.b
.domain
= pd24
->port_id
[0];
1439 fcport
->d_id
.b
.area
= pd24
->port_id
[1];
1440 fcport
->d_id
.b
.al_pa
= pd24
->port_id
[2];
1441 fcport
->d_id
.b
.rsvd_1
= 0;
1443 /* If not target must be initiator or unknown type. */
1444 if ((pd24
->prli_svc_param_word_3
[0] & BIT_4
) == 0)
1445 fcport
->port_type
= FCT_INITIATOR
;
1447 fcport
->port_type
= FCT_TARGET
;
1449 /* Passback COS information. */
1450 fcport
->supported_classes
= (pd24
->flags
& PDF_CLASS_2
) ?
1451 FC_COS_CLASS2
: FC_COS_CLASS3
;
1453 if (pd24
->prli_svc_param_word_3
[0] & BIT_7
)
1454 fcport
->flags
|= FCF_CONF_COMP_SUPPORTED
;
1458 /* Check for logged in state. */
1459 if (pd
->master_state
!= PD_STATE_PORT_LOGGED_IN
&&
1460 pd
->slave_state
!= PD_STATE_PORT_LOGGED_IN
) {
1461 ql_dbg(ql_dbg_mbx
, vha
, 0x100a,
1462 "Unable to verify login-state (%x/%x) - "
1463 "portid=%02x%02x%02x.\n", pd
->master_state
,
1464 pd
->slave_state
, fcport
->d_id
.b
.domain
,
1465 fcport
->d_id
.b
.area
, fcport
->d_id
.b
.al_pa
);
1466 rval
= QLA_FUNCTION_FAILED
;
1470 if (fcport
->loop_id
== FC_NO_LOOP_ID
||
1471 (memcmp(fcport
->port_name
, (uint8_t *)&zero
, 8) &&
1472 memcmp(fcport
->port_name
, pd
->port_name
, 8))) {
1473 /* We lost the device mid way. */
1474 rval
= QLA_NOT_LOGGED_IN
;
1478 /* Names are little-endian. */
1479 memcpy(fcport
->node_name
, pd
->node_name
, WWN_SIZE
);
1480 memcpy(fcport
->port_name
, pd
->port_name
, WWN_SIZE
);
1482 /* Get port_id of device. */
1483 fcport
->d_id
.b
.domain
= pd
->port_id
[0];
1484 fcport
->d_id
.b
.area
= pd
->port_id
[3];
1485 fcport
->d_id
.b
.al_pa
= pd
->port_id
[2];
1486 fcport
->d_id
.b
.rsvd_1
= 0;
1488 /* If not target must be initiator or unknown type. */
1489 if ((pd
->prli_svc_param_word_3
[0] & BIT_4
) == 0)
1490 fcport
->port_type
= FCT_INITIATOR
;
1492 fcport
->port_type
= FCT_TARGET
;
1494 /* Passback COS information. */
1495 fcport
->supported_classes
= (pd
->options
& BIT_4
) ?
1496 FC_COS_CLASS2
: FC_COS_CLASS3
;
1500 dma_pool_free(ha
->s_dma_pool
, pd
, pd_dma
);
1502 if (rval
!= QLA_SUCCESS
) {
1503 ql_dbg(ql_dbg_mbx
, vha
, 0x1052,
1504 "Failed=%x mb[0]=%x mb[1]=%x.\n", rval
,
1505 mcp
->mb
[0], mcp
->mb
[1]);
1507 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x1053,
1508 "Done %s.\n", __func__
);
1515 * qla2x00_get_firmware_state
1516 * Get adapter firmware state.
1519 * ha = adapter block pointer.
1520 * dptr = pointer for firmware state.
1521 * TARGET_QUEUE_LOCK must be released.
1522 * ADAPTER_STATE_LOCK must be released.
1525 * qla2x00 local function return status code.
1531 qla2x00_get_firmware_state(scsi_qla_host_t
*vha
, uint16_t *states
)
1535 mbx_cmd_t
*mcp
= &mc
;
1537 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x1054,
1538 "Entered %s.\n", __func__
);
1540 mcp
->mb
[0] = MBC_GET_FIRMWARE_STATE
;
1541 mcp
->out_mb
= MBX_0
;
1542 if (IS_FWI2_CAPABLE(vha
->hw
))
1543 mcp
->in_mb
= MBX_5
|MBX_4
|MBX_3
|MBX_2
|MBX_1
|MBX_0
;
1545 mcp
->in_mb
= MBX_1
|MBX_0
;
1546 mcp
->tov
= MBX_TOV_SECONDS
;
1548 rval
= qla2x00_mailbox_command(vha
, mcp
);
1550 /* Return firmware states. */
1551 states
[0] = mcp
->mb
[1];
1552 if (IS_FWI2_CAPABLE(vha
->hw
)) {
1553 states
[1] = mcp
->mb
[2];
1554 states
[2] = mcp
->mb
[3];
1555 states
[3] = mcp
->mb
[4];
1556 states
[4] = mcp
->mb
[5];
1559 if (rval
!= QLA_SUCCESS
) {
1561 ql_dbg(ql_dbg_mbx
, vha
, 0x1055, "Failed=%x.\n", rval
);
1564 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x1056,
1565 "Done %s.\n", __func__
);
1572 * qla2x00_get_port_name
1573 * Issue get port name mailbox command.
1574 * Returned name is in big endian format.
1577 * ha = adapter block pointer.
1578 * loop_id = loop ID of device.
1579 * name = pointer for name.
1580 * TARGET_QUEUE_LOCK must be released.
1581 * ADAPTER_STATE_LOCK must be released.
1584 * qla2x00 local function return status code.
1590 qla2x00_get_port_name(scsi_qla_host_t
*vha
, uint16_t loop_id
, uint8_t *name
,
1595 mbx_cmd_t
*mcp
= &mc
;
1597 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x1057,
1598 "Entered %s.\n", __func__
);
1600 mcp
->mb
[0] = MBC_GET_PORT_NAME
;
1601 mcp
->mb
[9] = vha
->vp_idx
;
1602 mcp
->out_mb
= MBX_9
|MBX_1
|MBX_0
;
1603 if (HAS_EXTENDED_IDS(vha
->hw
)) {
1604 mcp
->mb
[1] = loop_id
;
1606 mcp
->out_mb
|= MBX_10
;
1608 mcp
->mb
[1] = loop_id
<< 8 | opt
;
1611 mcp
->in_mb
= MBX_7
|MBX_6
|MBX_3
|MBX_2
|MBX_1
|MBX_0
;
1612 mcp
->tov
= MBX_TOV_SECONDS
;
1614 rval
= qla2x00_mailbox_command(vha
, mcp
);
1616 if (rval
!= QLA_SUCCESS
) {
1618 ql_dbg(ql_dbg_mbx
, vha
, 0x1058, "Failed=%x.\n", rval
);
1621 /* This function returns name in big endian. */
1622 name
[0] = MSB(mcp
->mb
[2]);
1623 name
[1] = LSB(mcp
->mb
[2]);
1624 name
[2] = MSB(mcp
->mb
[3]);
1625 name
[3] = LSB(mcp
->mb
[3]);
1626 name
[4] = MSB(mcp
->mb
[6]);
1627 name
[5] = LSB(mcp
->mb
[6]);
1628 name
[6] = MSB(mcp
->mb
[7]);
1629 name
[7] = LSB(mcp
->mb
[7]);
1632 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x1059,
1633 "Done %s.\n", __func__
);
1640 * qla24xx_link_initialization
1641 * Issue link initialization mailbox command.
1644 * ha = adapter block pointer.
1645 * TARGET_QUEUE_LOCK must be released.
1646 * ADAPTER_STATE_LOCK must be released.
1649 * qla2x00 local function return status code.
1655 qla24xx_link_initialize(scsi_qla_host_t
*vha
)
1659 mbx_cmd_t
*mcp
= &mc
;
1661 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x1152,
1662 "Entered %s.\n", __func__
);
1664 if (!IS_FWI2_CAPABLE(vha
->hw
) || IS_CNA_CAPABLE(vha
->hw
))
1665 return QLA_FUNCTION_FAILED
;
1667 mcp
->mb
[0] = MBC_LINK_INITIALIZATION
;
1669 if (vha
->hw
->operating_mode
== LOOP
)
1670 mcp
->mb
[1] |= BIT_6
;
1672 mcp
->mb
[1] |= BIT_5
;
1675 mcp
->out_mb
= MBX_3
|MBX_2
|MBX_1
|MBX_0
;
1677 mcp
->tov
= MBX_TOV_SECONDS
;
1679 rval
= qla2x00_mailbox_command(vha
, mcp
);
1681 if (rval
!= QLA_SUCCESS
) {
1682 ql_dbg(ql_dbg_mbx
, vha
, 0x1153, "Failed=%x.\n", rval
);
1684 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x1154,
1685 "Done %s.\n", __func__
);
1693 * Issue LIP reset mailbox command.
1696 * ha = adapter block pointer.
1697 * TARGET_QUEUE_LOCK must be released.
1698 * ADAPTER_STATE_LOCK must be released.
1701 * qla2x00 local function return status code.
1707 qla2x00_lip_reset(scsi_qla_host_t
*vha
)
1711 mbx_cmd_t
*mcp
= &mc
;
1713 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x105a,
1714 "Entered %s.\n", __func__
);
1716 if (IS_CNA_CAPABLE(vha
->hw
)) {
1717 /* Logout across all FCFs. */
1718 mcp
->mb
[0] = MBC_LIP_FULL_LOGIN
;
1721 mcp
->out_mb
= MBX_2
|MBX_1
|MBX_0
;
1722 } else if (IS_FWI2_CAPABLE(vha
->hw
)) {
1723 mcp
->mb
[0] = MBC_LIP_FULL_LOGIN
;
1726 mcp
->mb
[3] = vha
->hw
->loop_reset_delay
;
1727 mcp
->out_mb
= MBX_3
|MBX_2
|MBX_1
|MBX_0
;
1729 mcp
->mb
[0] = MBC_LIP_RESET
;
1730 mcp
->out_mb
= MBX_3
|MBX_2
|MBX_1
|MBX_0
;
1731 if (HAS_EXTENDED_IDS(vha
->hw
)) {
1732 mcp
->mb
[1] = 0x00ff;
1734 mcp
->out_mb
|= MBX_10
;
1736 mcp
->mb
[1] = 0xff00;
1738 mcp
->mb
[2] = vha
->hw
->loop_reset_delay
;
1742 mcp
->tov
= MBX_TOV_SECONDS
;
1744 rval
= qla2x00_mailbox_command(vha
, mcp
);
1746 if (rval
!= QLA_SUCCESS
) {
1748 ql_dbg(ql_dbg_mbx
, vha
, 0x105b, "Failed=%x.\n", rval
);
1751 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x105c,
1752 "Done %s.\n", __func__
);
1763 * ha = adapter block pointer.
1764 * sns = pointer for command.
1765 * cmd_size = command size.
1766 * buf_size = response/command size.
1767 * TARGET_QUEUE_LOCK must be released.
1768 * ADAPTER_STATE_LOCK must be released.
1771 * qla2x00 local function return status code.
1777 qla2x00_send_sns(scsi_qla_host_t
*vha
, dma_addr_t sns_phys_address
,
1778 uint16_t cmd_size
, size_t buf_size
)
1782 mbx_cmd_t
*mcp
= &mc
;
1784 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x105d,
1785 "Entered %s.\n", __func__
);
1787 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x105e,
1788 "Retry cnt=%d ratov=%d total tov=%d.\n",
1789 vha
->hw
->retry_count
, vha
->hw
->login_timeout
, mcp
->tov
);
1791 mcp
->mb
[0] = MBC_SEND_SNS_COMMAND
;
1792 mcp
->mb
[1] = cmd_size
;
1793 mcp
->mb
[2] = MSW(sns_phys_address
);
1794 mcp
->mb
[3] = LSW(sns_phys_address
);
1795 mcp
->mb
[6] = MSW(MSD(sns_phys_address
));
1796 mcp
->mb
[7] = LSW(MSD(sns_phys_address
));
1797 mcp
->out_mb
= MBX_7
|MBX_6
|MBX_3
|MBX_2
|MBX_1
|MBX_0
;
1798 mcp
->in_mb
= MBX_0
|MBX_1
;
1799 mcp
->buf_size
= buf_size
;
1800 mcp
->flags
= MBX_DMA_OUT
|MBX_DMA_IN
;
1801 mcp
->tov
= (vha
->hw
->login_timeout
* 2) + (vha
->hw
->login_timeout
/ 2);
1802 rval
= qla2x00_mailbox_command(vha
, mcp
);
1804 if (rval
!= QLA_SUCCESS
) {
1806 ql_dbg(ql_dbg_mbx
, vha
, 0x105f,
1807 "Failed=%x mb[0]=%x mb[1]=%x.\n",
1808 rval
, mcp
->mb
[0], mcp
->mb
[1]);
1811 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x1060,
1812 "Done %s.\n", __func__
);
1819 qla24xx_login_fabric(scsi_qla_host_t
*vha
, uint16_t loop_id
, uint8_t domain
,
1820 uint8_t area
, uint8_t al_pa
, uint16_t *mb
, uint8_t opt
)
1824 struct logio_entry_24xx
*lg
;
1827 struct qla_hw_data
*ha
= vha
->hw
;
1828 struct req_que
*req
;
1829 struct rsp_que
*rsp
;
1831 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x1061,
1832 "Entered %s.\n", __func__
);
1834 if (ha
->flags
.cpu_affinity_enabled
)
1835 req
= ha
->req_q_map
[0];
1840 lg
= dma_pool_alloc(ha
->s_dma_pool
, GFP_KERNEL
, &lg_dma
);
1842 ql_log(ql_log_warn
, vha
, 0x1062,
1843 "Failed to allocate login IOCB.\n");
1844 return QLA_MEMORY_ALLOC_FAILED
;
1846 memset(lg
, 0, sizeof(struct logio_entry_24xx
));
1848 lg
->entry_type
= LOGINOUT_PORT_IOCB_TYPE
;
1849 lg
->entry_count
= 1;
1850 lg
->handle
= MAKE_HANDLE(req
->id
, lg
->handle
);
1851 lg
->nport_handle
= cpu_to_le16(loop_id
);
1852 lg
->control_flags
= __constant_cpu_to_le16(LCF_COMMAND_PLOGI
);
1854 lg
->control_flags
|= __constant_cpu_to_le16(LCF_COND_PLOGI
);
1856 lg
->control_flags
|= __constant_cpu_to_le16(LCF_SKIP_PRLI
);
1857 lg
->port_id
[0] = al_pa
;
1858 lg
->port_id
[1] = area
;
1859 lg
->port_id
[2] = domain
;
1860 lg
->vp_index
= vha
->vp_idx
;
1861 rval
= qla2x00_issue_iocb_timeout(vha
, lg
, lg_dma
, 0,
1862 (ha
->r_a_tov
/ 10 * 2) + 2);
1863 if (rval
!= QLA_SUCCESS
) {
1864 ql_dbg(ql_dbg_mbx
, vha
, 0x1063,
1865 "Failed to issue login IOCB (%x).\n", rval
);
1866 } else if (lg
->entry_status
!= 0) {
1867 ql_dbg(ql_dbg_mbx
, vha
, 0x1064,
1868 "Failed to complete IOCB -- error status (%x).\n",
1870 rval
= QLA_FUNCTION_FAILED
;
1871 } else if (lg
->comp_status
!= __constant_cpu_to_le16(CS_COMPLETE
)) {
1872 iop
[0] = le32_to_cpu(lg
->io_parameter
[0]);
1873 iop
[1] = le32_to_cpu(lg
->io_parameter
[1]);
1875 ql_dbg(ql_dbg_mbx
, vha
, 0x1065,
1876 "Failed to complete IOCB -- completion status (%x) "
1877 "ioparam=%x/%x.\n", le16_to_cpu(lg
->comp_status
),
1881 case LSC_SCODE_PORTID_USED
:
1882 mb
[0] = MBS_PORT_ID_USED
;
1883 mb
[1] = LSW(iop
[1]);
1885 case LSC_SCODE_NPORT_USED
:
1886 mb
[0] = MBS_LOOP_ID_USED
;
1888 case LSC_SCODE_NOLINK
:
1889 case LSC_SCODE_NOIOCB
:
1890 case LSC_SCODE_NOXCB
:
1891 case LSC_SCODE_CMD_FAILED
:
1892 case LSC_SCODE_NOFABRIC
:
1893 case LSC_SCODE_FW_NOT_READY
:
1894 case LSC_SCODE_NOT_LOGGED_IN
:
1895 case LSC_SCODE_NOPCB
:
1896 case LSC_SCODE_ELS_REJECT
:
1897 case LSC_SCODE_CMD_PARAM_ERR
:
1898 case LSC_SCODE_NONPORT
:
1899 case LSC_SCODE_LOGGED_IN
:
1900 case LSC_SCODE_NOFLOGI_ACC
:
1902 mb
[0] = MBS_COMMAND_ERROR
;
1906 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x1066,
1907 "Done %s.\n", __func__
);
1909 iop
[0] = le32_to_cpu(lg
->io_parameter
[0]);
1911 mb
[0] = MBS_COMMAND_COMPLETE
;
1913 if (iop
[0] & BIT_4
) {
1919 /* Passback COS information. */
1921 if (lg
->io_parameter
[7] || lg
->io_parameter
[8])
1922 mb
[10] |= BIT_0
; /* Class 2. */
1923 if (lg
->io_parameter
[9] || lg
->io_parameter
[10])
1924 mb
[10] |= BIT_1
; /* Class 3. */
1925 if (lg
->io_parameter
[0] & __constant_cpu_to_le32(BIT_7
))
1926 mb
[10] |= BIT_7
; /* Confirmed Completion
1931 dma_pool_free(ha
->s_dma_pool
, lg
, lg_dma
);
1937 * qla2x00_login_fabric
1938 * Issue login fabric port mailbox command.
1941 * ha = adapter block pointer.
1942 * loop_id = device loop ID.
1943 * domain = device domain.
1944 * area = device area.
1945 * al_pa = device AL_PA.
1946 * status = pointer for return status.
1947 * opt = command options.
1948 * TARGET_QUEUE_LOCK must be released.
1949 * ADAPTER_STATE_LOCK must be released.
1952 * qla2x00 local function return status code.
1958 qla2x00_login_fabric(scsi_qla_host_t
*vha
, uint16_t loop_id
, uint8_t domain
,
1959 uint8_t area
, uint8_t al_pa
, uint16_t *mb
, uint8_t opt
)
1963 mbx_cmd_t
*mcp
= &mc
;
1964 struct qla_hw_data
*ha
= vha
->hw
;
1966 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x1067,
1967 "Entered %s.\n", __func__
);
1969 mcp
->mb
[0] = MBC_LOGIN_FABRIC_PORT
;
1970 mcp
->out_mb
= MBX_3
|MBX_2
|MBX_1
|MBX_0
;
1971 if (HAS_EXTENDED_IDS(ha
)) {
1972 mcp
->mb
[1] = loop_id
;
1974 mcp
->out_mb
|= MBX_10
;
1976 mcp
->mb
[1] = (loop_id
<< 8) | opt
;
1978 mcp
->mb
[2] = domain
;
1979 mcp
->mb
[3] = area
<< 8 | al_pa
;
1981 mcp
->in_mb
= MBX_7
|MBX_6
|MBX_2
|MBX_1
|MBX_0
;
1982 mcp
->tov
= (ha
->login_timeout
* 2) + (ha
->login_timeout
/ 2);
1984 rval
= qla2x00_mailbox_command(vha
, mcp
);
1986 /* Return mailbox statuses. */
1993 /* COS retrieved from Get-Port-Database mailbox command. */
1997 if (rval
!= QLA_SUCCESS
) {
1998 /* RLU tmp code: need to change main mailbox_command function to
1999 * return ok even when the mailbox completion value is not
2000 * SUCCESS. The caller needs to be responsible to interpret
2001 * the return values of this mailbox command if we're not
2002 * to change too much of the existing code.
2004 if (mcp
->mb
[0] == 0x4001 || mcp
->mb
[0] == 0x4002 ||
2005 mcp
->mb
[0] == 0x4003 || mcp
->mb
[0] == 0x4005 ||
2006 mcp
->mb
[0] == 0x4006)
2010 ql_dbg(ql_dbg_mbx
, vha
, 0x1068,
2011 "Failed=%x mb[0]=%x mb[1]=%x mb[2]=%x.\n",
2012 rval
, mcp
->mb
[0], mcp
->mb
[1], mcp
->mb
[2]);
2015 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x1069,
2016 "Done %s.\n", __func__
);
2023 * qla2x00_login_local_device
2024 * Issue login loop port mailbox command.
2027 * ha = adapter block pointer.
2028 * loop_id = device loop ID.
2029 * opt = command options.
2032 * Return status code.
2039 qla2x00_login_local_device(scsi_qla_host_t
*vha
, fc_port_t
*fcport
,
2040 uint16_t *mb_ret
, uint8_t opt
)
2044 mbx_cmd_t
*mcp
= &mc
;
2045 struct qla_hw_data
*ha
= vha
->hw
;
2047 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x106a,
2048 "Entered %s.\n", __func__
);
2050 if (IS_FWI2_CAPABLE(ha
))
2051 return qla24xx_login_fabric(vha
, fcport
->loop_id
,
2052 fcport
->d_id
.b
.domain
, fcport
->d_id
.b
.area
,
2053 fcport
->d_id
.b
.al_pa
, mb_ret
, opt
);
2055 mcp
->mb
[0] = MBC_LOGIN_LOOP_PORT
;
2056 if (HAS_EXTENDED_IDS(ha
))
2057 mcp
->mb
[1] = fcport
->loop_id
;
2059 mcp
->mb
[1] = fcport
->loop_id
<< 8;
2061 mcp
->out_mb
= MBX_2
|MBX_1
|MBX_0
;
2062 mcp
->in_mb
= MBX_7
|MBX_6
|MBX_1
|MBX_0
;
2063 mcp
->tov
= (ha
->login_timeout
* 2) + (ha
->login_timeout
/ 2);
2065 rval
= qla2x00_mailbox_command(vha
, mcp
);
2067 /* Return mailbox statuses. */
2068 if (mb_ret
!= NULL
) {
2069 mb_ret
[0] = mcp
->mb
[0];
2070 mb_ret
[1] = mcp
->mb
[1];
2071 mb_ret
[6] = mcp
->mb
[6];
2072 mb_ret
[7] = mcp
->mb
[7];
2075 if (rval
!= QLA_SUCCESS
) {
2076 /* AV tmp code: need to change main mailbox_command function to
2077 * return ok even when the mailbox completion value is not
2078 * SUCCESS. The caller needs to be responsible to interpret
2079 * the return values of this mailbox command if we're not
2080 * to change too much of the existing code.
2082 if (mcp
->mb
[0] == 0x4005 || mcp
->mb
[0] == 0x4006)
2085 ql_dbg(ql_dbg_mbx
, vha
, 0x106b,
2086 "Failed=%x mb[0]=%x mb[1]=%x mb[6]=%x mb[7]=%x.\n",
2087 rval
, mcp
->mb
[0], mcp
->mb
[1], mcp
->mb
[6], mcp
->mb
[7]);
2090 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x106c,
2091 "Done %s.\n", __func__
);
2098 qla24xx_fabric_logout(scsi_qla_host_t
*vha
, uint16_t loop_id
, uint8_t domain
,
2099 uint8_t area
, uint8_t al_pa
)
2102 struct logio_entry_24xx
*lg
;
2104 struct qla_hw_data
*ha
= vha
->hw
;
2105 struct req_que
*req
;
2106 struct rsp_que
*rsp
;
2108 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x106d,
2109 "Entered %s.\n", __func__
);
2111 lg
= dma_pool_alloc(ha
->s_dma_pool
, GFP_KERNEL
, &lg_dma
);
2113 ql_log(ql_log_warn
, vha
, 0x106e,
2114 "Failed to allocate logout IOCB.\n");
2115 return QLA_MEMORY_ALLOC_FAILED
;
2117 memset(lg
, 0, sizeof(struct logio_entry_24xx
));
2119 if (ql2xmaxqueues
> 1)
2120 req
= ha
->req_q_map
[0];
2124 lg
->entry_type
= LOGINOUT_PORT_IOCB_TYPE
;
2125 lg
->entry_count
= 1;
2126 lg
->handle
= MAKE_HANDLE(req
->id
, lg
->handle
);
2127 lg
->nport_handle
= cpu_to_le16(loop_id
);
2129 __constant_cpu_to_le16(LCF_COMMAND_LOGO
|LCF_IMPL_LOGO
|
2131 lg
->port_id
[0] = al_pa
;
2132 lg
->port_id
[1] = area
;
2133 lg
->port_id
[2] = domain
;
2134 lg
->vp_index
= vha
->vp_idx
;
2135 rval
= qla2x00_issue_iocb_timeout(vha
, lg
, lg_dma
, 0,
2136 (ha
->r_a_tov
/ 10 * 2) + 2);
2137 if (rval
!= QLA_SUCCESS
) {
2138 ql_dbg(ql_dbg_mbx
, vha
, 0x106f,
2139 "Failed to issue logout IOCB (%x).\n", rval
);
2140 } else if (lg
->entry_status
!= 0) {
2141 ql_dbg(ql_dbg_mbx
, vha
, 0x1070,
2142 "Failed to complete IOCB -- error status (%x).\n",
2144 rval
= QLA_FUNCTION_FAILED
;
2145 } else if (lg
->comp_status
!= __constant_cpu_to_le16(CS_COMPLETE
)) {
2146 ql_dbg(ql_dbg_mbx
, vha
, 0x1071,
2147 "Failed to complete IOCB -- completion status (%x) "
2148 "ioparam=%x/%x.\n", le16_to_cpu(lg
->comp_status
),
2149 le32_to_cpu(lg
->io_parameter
[0]),
2150 le32_to_cpu(lg
->io_parameter
[1]));
2153 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x1072,
2154 "Done %s.\n", __func__
);
2157 dma_pool_free(ha
->s_dma_pool
, lg
, lg_dma
);
2163 * qla2x00_fabric_logout
2164 * Issue logout fabric port mailbox command.
2167 * ha = adapter block pointer.
2168 * loop_id = device loop ID.
2169 * TARGET_QUEUE_LOCK must be released.
2170 * ADAPTER_STATE_LOCK must be released.
2173 * qla2x00 local function return status code.
2179 qla2x00_fabric_logout(scsi_qla_host_t
*vha
, uint16_t loop_id
, uint8_t domain
,
2180 uint8_t area
, uint8_t al_pa
)
2184 mbx_cmd_t
*mcp
= &mc
;
2186 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x1073,
2187 "Entered %s.\n", __func__
);
2189 mcp
->mb
[0] = MBC_LOGOUT_FABRIC_PORT
;
2190 mcp
->out_mb
= MBX_1
|MBX_0
;
2191 if (HAS_EXTENDED_IDS(vha
->hw
)) {
2192 mcp
->mb
[1] = loop_id
;
2194 mcp
->out_mb
|= MBX_10
;
2196 mcp
->mb
[1] = loop_id
<< 8;
2199 mcp
->in_mb
= MBX_1
|MBX_0
;
2200 mcp
->tov
= MBX_TOV_SECONDS
;
2202 rval
= qla2x00_mailbox_command(vha
, mcp
);
2204 if (rval
!= QLA_SUCCESS
) {
2206 ql_dbg(ql_dbg_mbx
, vha
, 0x1074,
2207 "Failed=%x mb[1]=%x.\n", rval
, mcp
->mb
[1]);
2210 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x1075,
2211 "Done %s.\n", __func__
);
2218 * qla2x00_full_login_lip
2219 * Issue full login LIP mailbox command.
2222 * ha = adapter block pointer.
2223 * TARGET_QUEUE_LOCK must be released.
2224 * ADAPTER_STATE_LOCK must be released.
2227 * qla2x00 local function return status code.
2233 qla2x00_full_login_lip(scsi_qla_host_t
*vha
)
2237 mbx_cmd_t
*mcp
= &mc
;
2239 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x1076,
2240 "Entered %s.\n", __func__
);
2242 mcp
->mb
[0] = MBC_LIP_FULL_LOGIN
;
2243 mcp
->mb
[1] = IS_FWI2_CAPABLE(vha
->hw
) ? BIT_3
: 0;
2246 mcp
->out_mb
= MBX_3
|MBX_2
|MBX_1
|MBX_0
;
2248 mcp
->tov
= MBX_TOV_SECONDS
;
2250 rval
= qla2x00_mailbox_command(vha
, mcp
);
2252 if (rval
!= QLA_SUCCESS
) {
2254 ql_dbg(ql_dbg_mbx
, vha
, 0x1077, "Failed=%x.\n", rval
);
2257 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x1078,
2258 "Done %s.\n", __func__
);
2265 * qla2x00_get_id_list
2268 * ha = adapter block pointer.
2271 * qla2x00 local function return status code.
2277 qla2x00_get_id_list(scsi_qla_host_t
*vha
, void *id_list
, dma_addr_t id_list_dma
,
2282 mbx_cmd_t
*mcp
= &mc
;
2284 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x1079,
2285 "Entered %s.\n", __func__
);
2287 if (id_list
== NULL
)
2288 return QLA_FUNCTION_FAILED
;
2290 mcp
->mb
[0] = MBC_GET_ID_LIST
;
2291 mcp
->out_mb
= MBX_0
;
2292 if (IS_FWI2_CAPABLE(vha
->hw
)) {
2293 mcp
->mb
[2] = MSW(id_list_dma
);
2294 mcp
->mb
[3] = LSW(id_list_dma
);
2295 mcp
->mb
[6] = MSW(MSD(id_list_dma
));
2296 mcp
->mb
[7] = LSW(MSD(id_list_dma
));
2298 mcp
->mb
[9] = vha
->vp_idx
;
2299 mcp
->out_mb
|= MBX_9
|MBX_8
|MBX_7
|MBX_6
|MBX_3
|MBX_2
;
2301 mcp
->mb
[1] = MSW(id_list_dma
);
2302 mcp
->mb
[2] = LSW(id_list_dma
);
2303 mcp
->mb
[3] = MSW(MSD(id_list_dma
));
2304 mcp
->mb
[6] = LSW(MSD(id_list_dma
));
2305 mcp
->out_mb
|= MBX_6
|MBX_3
|MBX_2
|MBX_1
;
2307 mcp
->in_mb
= MBX_1
|MBX_0
;
2308 mcp
->tov
= MBX_TOV_SECONDS
;
2310 rval
= qla2x00_mailbox_command(vha
, mcp
);
2312 if (rval
!= QLA_SUCCESS
) {
2314 ql_dbg(ql_dbg_mbx
, vha
, 0x107a, "Failed=%x.\n", rval
);
2316 *entries
= mcp
->mb
[1];
2317 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x107b,
2318 "Done %s.\n", __func__
);
2325 * qla2x00_get_resource_cnts
2326 * Get current firmware resource counts.
2329 * ha = adapter block pointer.
2332 * qla2x00 local function return status code.
2338 qla2x00_get_resource_cnts(scsi_qla_host_t
*vha
, uint16_t *cur_xchg_cnt
,
2339 uint16_t *orig_xchg_cnt
, uint16_t *cur_iocb_cnt
,
2340 uint16_t *orig_iocb_cnt
, uint16_t *max_npiv_vports
, uint16_t *max_fcfs
)
2344 mbx_cmd_t
*mcp
= &mc
;
2346 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x107c,
2347 "Entered %s.\n", __func__
);
2349 mcp
->mb
[0] = MBC_GET_RESOURCE_COUNTS
;
2350 mcp
->out_mb
= MBX_0
;
2351 mcp
->in_mb
= MBX_11
|MBX_10
|MBX_7
|MBX_6
|MBX_3
|MBX_2
|MBX_1
|MBX_0
;
2352 if (IS_QLA81XX(vha
->hw
) || IS_QLA83XX(vha
->hw
))
2353 mcp
->in_mb
|= MBX_12
;
2354 mcp
->tov
= MBX_TOV_SECONDS
;
2356 rval
= qla2x00_mailbox_command(vha
, mcp
);
2358 if (rval
!= QLA_SUCCESS
) {
2360 ql_dbg(ql_dbg_mbx
, vha
, 0x107d,
2361 "Failed mb[0]=%x.\n", mcp
->mb
[0]);
2363 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x107e,
2364 "Done %s mb1=%x mb2=%x mb3=%x mb6=%x mb7=%x mb10=%x "
2365 "mb11=%x mb12=%x.\n", __func__
, mcp
->mb
[1], mcp
->mb
[2],
2366 mcp
->mb
[3], mcp
->mb
[6], mcp
->mb
[7], mcp
->mb
[10],
2367 mcp
->mb
[11], mcp
->mb
[12]);
2370 *cur_xchg_cnt
= mcp
->mb
[3];
2372 *orig_xchg_cnt
= mcp
->mb
[6];
2374 *cur_iocb_cnt
= mcp
->mb
[7];
2376 *orig_iocb_cnt
= mcp
->mb
[10];
2377 if (vha
->hw
->flags
.npiv_supported
&& max_npiv_vports
)
2378 *max_npiv_vports
= mcp
->mb
[11];
2379 if ((IS_QLA81XX(vha
->hw
) || IS_QLA83XX(vha
->hw
)) && max_fcfs
)
2380 *max_fcfs
= mcp
->mb
[12];
2387 * qla2x00_get_fcal_position_map
2388 * Get FCAL (LILP) position map using mailbox command
2391 * ha = adapter state pointer.
2392 * pos_map = buffer pointer (can be NULL).
2395 * qla2x00 local function return status code.
2401 qla2x00_get_fcal_position_map(scsi_qla_host_t
*vha
, char *pos_map
)
2405 mbx_cmd_t
*mcp
= &mc
;
2407 dma_addr_t pmap_dma
;
2408 struct qla_hw_data
*ha
= vha
->hw
;
2410 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x107f,
2411 "Entered %s.\n", __func__
);
2413 pmap
= dma_pool_alloc(ha
->s_dma_pool
, GFP_KERNEL
, &pmap_dma
);
2415 ql_log(ql_log_warn
, vha
, 0x1080,
2416 "Memory alloc failed.\n");
2417 return QLA_MEMORY_ALLOC_FAILED
;
2419 memset(pmap
, 0, FCAL_MAP_SIZE
);
2421 mcp
->mb
[0] = MBC_GET_FC_AL_POSITION_MAP
;
2422 mcp
->mb
[2] = MSW(pmap_dma
);
2423 mcp
->mb
[3] = LSW(pmap_dma
);
2424 mcp
->mb
[6] = MSW(MSD(pmap_dma
));
2425 mcp
->mb
[7] = LSW(MSD(pmap_dma
));
2426 mcp
->out_mb
= MBX_7
|MBX_6
|MBX_3
|MBX_2
|MBX_0
;
2427 mcp
->in_mb
= MBX_1
|MBX_0
;
2428 mcp
->buf_size
= FCAL_MAP_SIZE
;
2429 mcp
->flags
= MBX_DMA_IN
;
2430 mcp
->tov
= (ha
->login_timeout
* 2) + (ha
->login_timeout
/ 2);
2431 rval
= qla2x00_mailbox_command(vha
, mcp
);
2433 if (rval
== QLA_SUCCESS
) {
2434 ql_dbg(ql_dbg_mbx
+ ql_dbg_buffer
, vha
, 0x1081,
2435 "mb0/mb1=%x/%X FC/AL position map size (%x).\n",
2436 mcp
->mb
[0], mcp
->mb
[1], (unsigned)pmap
[0]);
2437 ql_dump_buffer(ql_dbg_mbx
+ ql_dbg_buffer
, vha
, 0x111d,
2441 memcpy(pos_map
, pmap
, FCAL_MAP_SIZE
);
2443 dma_pool_free(ha
->s_dma_pool
, pmap
, pmap_dma
);
2445 if (rval
!= QLA_SUCCESS
) {
2446 ql_dbg(ql_dbg_mbx
, vha
, 0x1082, "Failed=%x.\n", rval
);
2448 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x1083,
2449 "Done %s.\n", __func__
);
2456 * qla2x00_get_link_status
2459 * ha = adapter block pointer.
2460 * loop_id = device loop ID.
2461 * ret_buf = pointer to link status return buffer.
2465 * BIT_0 = mem alloc error.
2466 * BIT_1 = mailbox error.
2469 qla2x00_get_link_status(scsi_qla_host_t
*vha
, uint16_t loop_id
,
2470 struct link_statistics
*stats
, dma_addr_t stats_dma
)
2474 mbx_cmd_t
*mcp
= &mc
;
2475 uint32_t *siter
, *diter
, dwords
;
2476 struct qla_hw_data
*ha
= vha
->hw
;
2478 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x1084,
2479 "Entered %s.\n", __func__
);
2481 mcp
->mb
[0] = MBC_GET_LINK_STATUS
;
2482 mcp
->mb
[2] = MSW(stats_dma
);
2483 mcp
->mb
[3] = LSW(stats_dma
);
2484 mcp
->mb
[6] = MSW(MSD(stats_dma
));
2485 mcp
->mb
[7] = LSW(MSD(stats_dma
));
2486 mcp
->out_mb
= MBX_7
|MBX_6
|MBX_3
|MBX_2
|MBX_0
;
2488 if (IS_FWI2_CAPABLE(ha
)) {
2489 mcp
->mb
[1] = loop_id
;
2492 mcp
->out_mb
|= MBX_10
|MBX_4
|MBX_1
;
2493 mcp
->in_mb
|= MBX_1
;
2494 } else if (HAS_EXTENDED_IDS(ha
)) {
2495 mcp
->mb
[1] = loop_id
;
2497 mcp
->out_mb
|= MBX_10
|MBX_1
;
2499 mcp
->mb
[1] = loop_id
<< 8;
2500 mcp
->out_mb
|= MBX_1
;
2502 mcp
->tov
= MBX_TOV_SECONDS
;
2503 mcp
->flags
= IOCTL_CMD
;
2504 rval
= qla2x00_mailbox_command(vha
, mcp
);
2506 if (rval
== QLA_SUCCESS
) {
2507 if (mcp
->mb
[0] != MBS_COMMAND_COMPLETE
) {
2508 ql_dbg(ql_dbg_mbx
, vha
, 0x1085,
2509 "Failed=%x mb[0]=%x.\n", rval
, mcp
->mb
[0]);
2510 rval
= QLA_FUNCTION_FAILED
;
2512 /* Copy over data -- firmware data is LE. */
2513 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x1086,
2514 "Done %s.\n", __func__
);
2515 dwords
= offsetof(struct link_statistics
, unused1
) / 4;
2516 siter
= diter
= &stats
->link_fail_cnt
;
2518 *diter
++ = le32_to_cpu(*siter
++);
2522 ql_dbg(ql_dbg_mbx
, vha
, 0x1087, "Failed=%x.\n", rval
);
2529 qla24xx_get_isp_stats(scsi_qla_host_t
*vha
, struct link_statistics
*stats
,
2530 dma_addr_t stats_dma
)
2534 mbx_cmd_t
*mcp
= &mc
;
2535 uint32_t *siter
, *diter
, dwords
;
2537 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x1088,
2538 "Entered %s.\n", __func__
);
2540 mcp
->mb
[0] = MBC_GET_LINK_PRIV_STATS
;
2541 mcp
->mb
[2] = MSW(stats_dma
);
2542 mcp
->mb
[3] = LSW(stats_dma
);
2543 mcp
->mb
[6] = MSW(MSD(stats_dma
));
2544 mcp
->mb
[7] = LSW(MSD(stats_dma
));
2545 mcp
->mb
[8] = sizeof(struct link_statistics
) / 4;
2546 mcp
->mb
[9] = vha
->vp_idx
;
2548 mcp
->out_mb
= MBX_10
|MBX_9
|MBX_8
|MBX_7
|MBX_6
|MBX_3
|MBX_2
|MBX_0
;
2549 mcp
->in_mb
= MBX_2
|MBX_1
|MBX_0
;
2550 mcp
->tov
= MBX_TOV_SECONDS
;
2551 mcp
->flags
= IOCTL_CMD
;
2552 rval
= qla2x00_mailbox_command(vha
, mcp
);
2554 if (rval
== QLA_SUCCESS
) {
2555 if (mcp
->mb
[0] != MBS_COMMAND_COMPLETE
) {
2556 ql_dbg(ql_dbg_mbx
, vha
, 0x1089,
2557 "Failed mb[0]=%x.\n", mcp
->mb
[0]);
2558 rval
= QLA_FUNCTION_FAILED
;
2560 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x108a,
2561 "Done %s.\n", __func__
);
2562 /* Copy over data -- firmware data is LE. */
2563 dwords
= sizeof(struct link_statistics
) / 4;
2564 siter
= diter
= &stats
->link_fail_cnt
;
2566 *diter
++ = le32_to_cpu(*siter
++);
2570 ql_dbg(ql_dbg_mbx
, vha
, 0x108b, "Failed=%x.\n", rval
);
2577 qla24xx_abort_command(srb_t
*sp
)
2580 unsigned long flags
= 0;
2582 struct abort_entry_24xx
*abt
;
2585 fc_port_t
*fcport
= sp
->fcport
;
2586 struct scsi_qla_host
*vha
= fcport
->vha
;
2587 struct qla_hw_data
*ha
= vha
->hw
;
2588 struct req_que
*req
= vha
->req
;
2590 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x108c,
2591 "Entered %s.\n", __func__
);
2593 spin_lock_irqsave(&ha
->hardware_lock
, flags
);
2594 for (handle
= 1; handle
< req
->num_outstanding_cmds
; handle
++) {
2595 if (req
->outstanding_cmds
[handle
] == sp
)
2598 spin_unlock_irqrestore(&ha
->hardware_lock
, flags
);
2599 if (handle
== req
->num_outstanding_cmds
) {
2600 /* Command not found. */
2601 return QLA_FUNCTION_FAILED
;
2604 abt
= dma_pool_alloc(ha
->s_dma_pool
, GFP_KERNEL
, &abt_dma
);
2606 ql_log(ql_log_warn
, vha
, 0x108d,
2607 "Failed to allocate abort IOCB.\n");
2608 return QLA_MEMORY_ALLOC_FAILED
;
2610 memset(abt
, 0, sizeof(struct abort_entry_24xx
));
2612 abt
->entry_type
= ABORT_IOCB_TYPE
;
2613 abt
->entry_count
= 1;
2614 abt
->handle
= MAKE_HANDLE(req
->id
, abt
->handle
);
2615 abt
->nport_handle
= cpu_to_le16(fcport
->loop_id
);
2616 abt
->handle_to_abort
= MAKE_HANDLE(req
->id
, handle
);
2617 abt
->port_id
[0] = fcport
->d_id
.b
.al_pa
;
2618 abt
->port_id
[1] = fcport
->d_id
.b
.area
;
2619 abt
->port_id
[2] = fcport
->d_id
.b
.domain
;
2620 abt
->vp_index
= fcport
->vha
->vp_idx
;
2622 abt
->req_que_no
= cpu_to_le16(req
->id
);
2624 rval
= qla2x00_issue_iocb(vha
, abt
, abt_dma
, 0);
2625 if (rval
!= QLA_SUCCESS
) {
2626 ql_dbg(ql_dbg_mbx
, vha
, 0x108e,
2627 "Failed to issue IOCB (%x).\n", rval
);
2628 } else if (abt
->entry_status
!= 0) {
2629 ql_dbg(ql_dbg_mbx
, vha
, 0x108f,
2630 "Failed to complete IOCB -- error status (%x).\n",
2632 rval
= QLA_FUNCTION_FAILED
;
2633 } else if (abt
->nport_handle
!= __constant_cpu_to_le16(0)) {
2634 ql_dbg(ql_dbg_mbx
, vha
, 0x1090,
2635 "Failed to complete IOCB -- completion status (%x).\n",
2636 le16_to_cpu(abt
->nport_handle
));
2637 rval
= QLA_FUNCTION_FAILED
;
2639 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x1091,
2640 "Done %s.\n", __func__
);
2643 dma_pool_free(ha
->s_dma_pool
, abt
, abt_dma
);
2648 struct tsk_mgmt_cmd
{
2650 struct tsk_mgmt_entry tsk
;
2651 struct sts_entry_24xx sts
;
2656 __qla24xx_issue_tmf(char *name
, uint32_t type
, struct fc_port
*fcport
,
2657 unsigned int l
, int tag
)
2660 struct tsk_mgmt_cmd
*tsk
;
2661 struct sts_entry_24xx
*sts
;
2663 scsi_qla_host_t
*vha
;
2664 struct qla_hw_data
*ha
;
2665 struct req_que
*req
;
2666 struct rsp_que
*rsp
;
2672 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x1092,
2673 "Entered %s.\n", __func__
);
2675 if (ha
->flags
.cpu_affinity_enabled
)
2676 rsp
= ha
->rsp_q_map
[tag
+ 1];
2679 tsk
= dma_pool_alloc(ha
->s_dma_pool
, GFP_KERNEL
, &tsk_dma
);
2681 ql_log(ql_log_warn
, vha
, 0x1093,
2682 "Failed to allocate task management IOCB.\n");
2683 return QLA_MEMORY_ALLOC_FAILED
;
2685 memset(tsk
, 0, sizeof(struct tsk_mgmt_cmd
));
2687 tsk
->p
.tsk
.entry_type
= TSK_MGMT_IOCB_TYPE
;
2688 tsk
->p
.tsk
.entry_count
= 1;
2689 tsk
->p
.tsk
.handle
= MAKE_HANDLE(req
->id
, tsk
->p
.tsk
.handle
);
2690 tsk
->p
.tsk
.nport_handle
= cpu_to_le16(fcport
->loop_id
);
2691 tsk
->p
.tsk
.timeout
= cpu_to_le16(ha
->r_a_tov
/ 10 * 2);
2692 tsk
->p
.tsk
.control_flags
= cpu_to_le32(type
);
2693 tsk
->p
.tsk
.port_id
[0] = fcport
->d_id
.b
.al_pa
;
2694 tsk
->p
.tsk
.port_id
[1] = fcport
->d_id
.b
.area
;
2695 tsk
->p
.tsk
.port_id
[2] = fcport
->d_id
.b
.domain
;
2696 tsk
->p
.tsk
.vp_index
= fcport
->vha
->vp_idx
;
2697 if (type
== TCF_LUN_RESET
) {
2698 int_to_scsilun(l
, &tsk
->p
.tsk
.lun
);
2699 host_to_fcp_swap((uint8_t *)&tsk
->p
.tsk
.lun
,
2700 sizeof(tsk
->p
.tsk
.lun
));
2704 rval
= qla2x00_issue_iocb(vha
, tsk
, tsk_dma
, 0);
2705 if (rval
!= QLA_SUCCESS
) {
2706 ql_dbg(ql_dbg_mbx
, vha
, 0x1094,
2707 "Failed to issue %s reset IOCB (%x).\n", name
, rval
);
2708 } else if (sts
->entry_status
!= 0) {
2709 ql_dbg(ql_dbg_mbx
, vha
, 0x1095,
2710 "Failed to complete IOCB -- error status (%x).\n",
2712 rval
= QLA_FUNCTION_FAILED
;
2713 } else if (sts
->comp_status
!=
2714 __constant_cpu_to_le16(CS_COMPLETE
)) {
2715 ql_dbg(ql_dbg_mbx
, vha
, 0x1096,
2716 "Failed to complete IOCB -- completion status (%x).\n",
2717 le16_to_cpu(sts
->comp_status
));
2718 rval
= QLA_FUNCTION_FAILED
;
2719 } else if (le16_to_cpu(sts
->scsi_status
) &
2720 SS_RESPONSE_INFO_LEN_VALID
) {
2721 if (le32_to_cpu(sts
->rsp_data_len
) < 4) {
2722 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x1097,
2723 "Ignoring inconsistent data length -- not enough "
2724 "response info (%d).\n",
2725 le32_to_cpu(sts
->rsp_data_len
));
2726 } else if (sts
->data
[3]) {
2727 ql_dbg(ql_dbg_mbx
, vha
, 0x1098,
2728 "Failed to complete IOCB -- response (%x).\n",
2730 rval
= QLA_FUNCTION_FAILED
;
2734 /* Issue marker IOCB. */
2735 rval2
= qla2x00_marker(vha
, req
, rsp
, fcport
->loop_id
, l
,
2736 type
== TCF_LUN_RESET
? MK_SYNC_ID_LUN
: MK_SYNC_ID
);
2737 if (rval2
!= QLA_SUCCESS
) {
2738 ql_dbg(ql_dbg_mbx
, vha
, 0x1099,
2739 "Failed to issue marker IOCB (%x).\n", rval2
);
2741 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x109a,
2742 "Done %s.\n", __func__
);
2745 dma_pool_free(ha
->s_dma_pool
, tsk
, tsk_dma
);
2751 qla24xx_abort_target(struct fc_port
*fcport
, unsigned int l
, int tag
)
2753 struct qla_hw_data
*ha
= fcport
->vha
->hw
;
2755 if ((ql2xasynctmfenable
) && IS_FWI2_CAPABLE(ha
))
2756 return qla2x00_async_tm_cmd(fcport
, TCF_TARGET_RESET
, l
, tag
);
2758 return __qla24xx_issue_tmf("Target", TCF_TARGET_RESET
, fcport
, l
, tag
);
2762 qla24xx_lun_reset(struct fc_port
*fcport
, unsigned int l
, int tag
)
2764 struct qla_hw_data
*ha
= fcport
->vha
->hw
;
2766 if ((ql2xasynctmfenable
) && IS_FWI2_CAPABLE(ha
))
2767 return qla2x00_async_tm_cmd(fcport
, TCF_LUN_RESET
, l
, tag
);
2769 return __qla24xx_issue_tmf("Lun", TCF_LUN_RESET
, fcport
, l
, tag
);
2773 qla2x00_system_error(scsi_qla_host_t
*vha
)
2777 mbx_cmd_t
*mcp
= &mc
;
2778 struct qla_hw_data
*ha
= vha
->hw
;
2780 if (!IS_QLA23XX(ha
) && !IS_FWI2_CAPABLE(ha
))
2781 return QLA_FUNCTION_FAILED
;
2783 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x109b,
2784 "Entered %s.\n", __func__
);
2786 mcp
->mb
[0] = MBC_GEN_SYSTEM_ERROR
;
2787 mcp
->out_mb
= MBX_0
;
2791 rval
= qla2x00_mailbox_command(vha
, mcp
);
2793 if (rval
!= QLA_SUCCESS
) {
2794 ql_dbg(ql_dbg_mbx
, vha
, 0x109c, "Failed=%x.\n", rval
);
2796 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x109d,
2797 "Done %s.\n", __func__
);
2804 * qla2x00_set_serdes_params() -
2810 qla2x00_set_serdes_params(scsi_qla_host_t
*vha
, uint16_t sw_em_1g
,
2811 uint16_t sw_em_2g
, uint16_t sw_em_4g
)
2815 mbx_cmd_t
*mcp
= &mc
;
2817 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x109e,
2818 "Entered %s.\n", __func__
);
2820 mcp
->mb
[0] = MBC_SERDES_PARAMS
;
2822 mcp
->mb
[2] = sw_em_1g
| BIT_15
;
2823 mcp
->mb
[3] = sw_em_2g
| BIT_15
;
2824 mcp
->mb
[4] = sw_em_4g
| BIT_15
;
2825 mcp
->out_mb
= MBX_4
|MBX_3
|MBX_2
|MBX_1
|MBX_0
;
2827 mcp
->tov
= MBX_TOV_SECONDS
;
2829 rval
= qla2x00_mailbox_command(vha
, mcp
);
2831 if (rval
!= QLA_SUCCESS
) {
2833 ql_dbg(ql_dbg_mbx
, vha
, 0x109f,
2834 "Failed=%x mb[0]=%x.\n", rval
, mcp
->mb
[0]);
2837 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x10a0,
2838 "Done %s.\n", __func__
);
2845 qla2x00_stop_firmware(scsi_qla_host_t
*vha
)
2849 mbx_cmd_t
*mcp
= &mc
;
2851 if (!IS_FWI2_CAPABLE(vha
->hw
))
2852 return QLA_FUNCTION_FAILED
;
2854 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x10a1,
2855 "Entered %s.\n", __func__
);
2857 mcp
->mb
[0] = MBC_STOP_FIRMWARE
;
2859 mcp
->out_mb
= MBX_1
|MBX_0
;
2863 rval
= qla2x00_mailbox_command(vha
, mcp
);
2865 if (rval
!= QLA_SUCCESS
) {
2866 ql_dbg(ql_dbg_mbx
, vha
, 0x10a2, "Failed=%x.\n", rval
);
2867 if (mcp
->mb
[0] == MBS_INVALID_COMMAND
)
2868 rval
= QLA_INVALID_COMMAND
;
2870 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x10a3,
2871 "Done %s.\n", __func__
);
2878 qla2x00_enable_eft_trace(scsi_qla_host_t
*vha
, dma_addr_t eft_dma
,
2883 mbx_cmd_t
*mcp
= &mc
;
2885 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x10a4,
2886 "Entered %s.\n", __func__
);
2888 if (!IS_FWI2_CAPABLE(vha
->hw
))
2889 return QLA_FUNCTION_FAILED
;
2891 if (unlikely(pci_channel_offline(vha
->hw
->pdev
)))
2892 return QLA_FUNCTION_FAILED
;
2894 mcp
->mb
[0] = MBC_TRACE_CONTROL
;
2895 mcp
->mb
[1] = TC_EFT_ENABLE
;
2896 mcp
->mb
[2] = LSW(eft_dma
);
2897 mcp
->mb
[3] = MSW(eft_dma
);
2898 mcp
->mb
[4] = LSW(MSD(eft_dma
));
2899 mcp
->mb
[5] = MSW(MSD(eft_dma
));
2900 mcp
->mb
[6] = buffers
;
2901 mcp
->mb
[7] = TC_AEN_DISABLE
;
2902 mcp
->out_mb
= MBX_7
|MBX_6
|MBX_5
|MBX_4
|MBX_3
|MBX_2
|MBX_1
|MBX_0
;
2903 mcp
->in_mb
= MBX_1
|MBX_0
;
2904 mcp
->tov
= MBX_TOV_SECONDS
;
2906 rval
= qla2x00_mailbox_command(vha
, mcp
);
2907 if (rval
!= QLA_SUCCESS
) {
2908 ql_dbg(ql_dbg_mbx
, vha
, 0x10a5,
2909 "Failed=%x mb[0]=%x mb[1]=%x.\n",
2910 rval
, mcp
->mb
[0], mcp
->mb
[1]);
2912 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x10a6,
2913 "Done %s.\n", __func__
);
2920 qla2x00_disable_eft_trace(scsi_qla_host_t
*vha
)
2924 mbx_cmd_t
*mcp
= &mc
;
2926 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x10a7,
2927 "Entered %s.\n", __func__
);
2929 if (!IS_FWI2_CAPABLE(vha
->hw
))
2930 return QLA_FUNCTION_FAILED
;
2932 if (unlikely(pci_channel_offline(vha
->hw
->pdev
)))
2933 return QLA_FUNCTION_FAILED
;
2935 mcp
->mb
[0] = MBC_TRACE_CONTROL
;
2936 mcp
->mb
[1] = TC_EFT_DISABLE
;
2937 mcp
->out_mb
= MBX_1
|MBX_0
;
2938 mcp
->in_mb
= MBX_1
|MBX_0
;
2939 mcp
->tov
= MBX_TOV_SECONDS
;
2941 rval
= qla2x00_mailbox_command(vha
, mcp
);
2942 if (rval
!= QLA_SUCCESS
) {
2943 ql_dbg(ql_dbg_mbx
, vha
, 0x10a8,
2944 "Failed=%x mb[0]=%x mb[1]=%x.\n",
2945 rval
, mcp
->mb
[0], mcp
->mb
[1]);
2947 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x10a9,
2948 "Done %s.\n", __func__
);
2955 qla2x00_enable_fce_trace(scsi_qla_host_t
*vha
, dma_addr_t fce_dma
,
2956 uint16_t buffers
, uint16_t *mb
, uint32_t *dwords
)
2960 mbx_cmd_t
*mcp
= &mc
;
2962 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x10aa,
2963 "Entered %s.\n", __func__
);
2965 if (!IS_QLA25XX(vha
->hw
) && !IS_QLA81XX(vha
->hw
) &&
2966 !IS_QLA83XX(vha
->hw
))
2967 return QLA_FUNCTION_FAILED
;
2969 if (unlikely(pci_channel_offline(vha
->hw
->pdev
)))
2970 return QLA_FUNCTION_FAILED
;
2972 mcp
->mb
[0] = MBC_TRACE_CONTROL
;
2973 mcp
->mb
[1] = TC_FCE_ENABLE
;
2974 mcp
->mb
[2] = LSW(fce_dma
);
2975 mcp
->mb
[3] = MSW(fce_dma
);
2976 mcp
->mb
[4] = LSW(MSD(fce_dma
));
2977 mcp
->mb
[5] = MSW(MSD(fce_dma
));
2978 mcp
->mb
[6] = buffers
;
2979 mcp
->mb
[7] = TC_AEN_DISABLE
;
2981 mcp
->mb
[9] = TC_FCE_DEFAULT_RX_SIZE
;
2982 mcp
->mb
[10] = TC_FCE_DEFAULT_TX_SIZE
;
2983 mcp
->out_mb
= MBX_10
|MBX_9
|MBX_8
|MBX_7
|MBX_6
|MBX_5
|MBX_4
|MBX_3
|MBX_2
|
2985 mcp
->in_mb
= MBX_6
|MBX_5
|MBX_4
|MBX_3
|MBX_2
|MBX_1
|MBX_0
;
2986 mcp
->tov
= MBX_TOV_SECONDS
;
2988 rval
= qla2x00_mailbox_command(vha
, mcp
);
2989 if (rval
!= QLA_SUCCESS
) {
2990 ql_dbg(ql_dbg_mbx
, vha
, 0x10ab,
2991 "Failed=%x mb[0]=%x mb[1]=%x.\n",
2992 rval
, mcp
->mb
[0], mcp
->mb
[1]);
2994 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x10ac,
2995 "Done %s.\n", __func__
);
2998 memcpy(mb
, mcp
->mb
, 8 * sizeof(*mb
));
3007 qla2x00_disable_fce_trace(scsi_qla_host_t
*vha
, uint64_t *wr
, uint64_t *rd
)
3011 mbx_cmd_t
*mcp
= &mc
;
3013 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x10ad,
3014 "Entered %s.\n", __func__
);
3016 if (!IS_FWI2_CAPABLE(vha
->hw
))
3017 return QLA_FUNCTION_FAILED
;
3019 if (unlikely(pci_channel_offline(vha
->hw
->pdev
)))
3020 return QLA_FUNCTION_FAILED
;
3022 mcp
->mb
[0] = MBC_TRACE_CONTROL
;
3023 mcp
->mb
[1] = TC_FCE_DISABLE
;
3024 mcp
->mb
[2] = TC_FCE_DISABLE_TRACE
;
3025 mcp
->out_mb
= MBX_2
|MBX_1
|MBX_0
;
3026 mcp
->in_mb
= MBX_9
|MBX_8
|MBX_7
|MBX_6
|MBX_5
|MBX_4
|MBX_3
|MBX_2
|
3028 mcp
->tov
= MBX_TOV_SECONDS
;
3030 rval
= qla2x00_mailbox_command(vha
, mcp
);
3031 if (rval
!= QLA_SUCCESS
) {
3032 ql_dbg(ql_dbg_mbx
, vha
, 0x10ae,
3033 "Failed=%x mb[0]=%x mb[1]=%x.\n",
3034 rval
, mcp
->mb
[0], mcp
->mb
[1]);
3036 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x10af,
3037 "Done %s.\n", __func__
);
3040 *wr
= (uint64_t) mcp
->mb
[5] << 48 |
3041 (uint64_t) mcp
->mb
[4] << 32 |
3042 (uint64_t) mcp
->mb
[3] << 16 |
3043 (uint64_t) mcp
->mb
[2];
3045 *rd
= (uint64_t) mcp
->mb
[9] << 48 |
3046 (uint64_t) mcp
->mb
[8] << 32 |
3047 (uint64_t) mcp
->mb
[7] << 16 |
3048 (uint64_t) mcp
->mb
[6];
3055 qla2x00_get_idma_speed(scsi_qla_host_t
*vha
, uint16_t loop_id
,
3056 uint16_t *port_speed
, uint16_t *mb
)
3060 mbx_cmd_t
*mcp
= &mc
;
3062 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x10b0,
3063 "Entered %s.\n", __func__
);
3065 if (!IS_IIDMA_CAPABLE(vha
->hw
))
3066 return QLA_FUNCTION_FAILED
;
3068 mcp
->mb
[0] = MBC_PORT_PARAMS
;
3069 mcp
->mb
[1] = loop_id
;
3070 mcp
->mb
[2] = mcp
->mb
[3] = 0;
3071 mcp
->mb
[9] = vha
->vp_idx
;
3072 mcp
->out_mb
= MBX_9
|MBX_3
|MBX_2
|MBX_1
|MBX_0
;
3073 mcp
->in_mb
= MBX_3
|MBX_1
|MBX_0
;
3074 mcp
->tov
= MBX_TOV_SECONDS
;
3076 rval
= qla2x00_mailbox_command(vha
, mcp
);
3078 /* Return mailbox statuses. */
3085 if (rval
!= QLA_SUCCESS
) {
3086 ql_dbg(ql_dbg_mbx
, vha
, 0x10b1, "Failed=%x.\n", rval
);
3088 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x10b2,
3089 "Done %s.\n", __func__
);
3091 *port_speed
= mcp
->mb
[3];
3098 qla2x00_set_idma_speed(scsi_qla_host_t
*vha
, uint16_t loop_id
,
3099 uint16_t port_speed
, uint16_t *mb
)
3103 mbx_cmd_t
*mcp
= &mc
;
3105 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x10b3,
3106 "Entered %s.\n", __func__
);
3108 if (!IS_IIDMA_CAPABLE(vha
->hw
))
3109 return QLA_FUNCTION_FAILED
;
3111 mcp
->mb
[0] = MBC_PORT_PARAMS
;
3112 mcp
->mb
[1] = loop_id
;
3114 if (IS_CNA_CAPABLE(vha
->hw
))
3115 mcp
->mb
[3] = port_speed
& (BIT_5
|BIT_4
|BIT_3
|BIT_2
|BIT_1
|BIT_0
);
3117 mcp
->mb
[3] = port_speed
& (BIT_2
|BIT_1
|BIT_0
);
3118 mcp
->mb
[9] = vha
->vp_idx
;
3119 mcp
->out_mb
= MBX_9
|MBX_3
|MBX_2
|MBX_1
|MBX_0
;
3120 mcp
->in_mb
= MBX_3
|MBX_1
|MBX_0
;
3121 mcp
->tov
= MBX_TOV_SECONDS
;
3123 rval
= qla2x00_mailbox_command(vha
, mcp
);
3125 /* Return mailbox statuses. */
3132 if (rval
!= QLA_SUCCESS
) {
3133 ql_dbg(ql_dbg_mbx
, vha
, 0x10b4,
3134 "Failed=%x.\n", rval
);
3136 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x10b5,
3137 "Done %s.\n", __func__
);
3144 qla24xx_report_id_acquisition(scsi_qla_host_t
*vha
,
3145 struct vp_rpt_id_entry_24xx
*rptid_entry
)
3148 uint16_t stat
= le16_to_cpu(rptid_entry
->vp_idx
);
3149 struct qla_hw_data
*ha
= vha
->hw
;
3150 scsi_qla_host_t
*vp
;
3151 unsigned long flags
;
3154 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x10b6,
3155 "Entered %s.\n", __func__
);
3157 if (rptid_entry
->entry_status
!= 0)
3160 if (rptid_entry
->format
== 0) {
3161 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x10b7,
3162 "Format 0 : Number of VPs setup %d, number of "
3163 "VPs acquired %d.\n",
3164 MSB(le16_to_cpu(rptid_entry
->vp_count
)),
3165 LSB(le16_to_cpu(rptid_entry
->vp_count
)));
3166 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x10b8,
3167 "Primary port id %02x%02x%02x.\n",
3168 rptid_entry
->port_id
[2], rptid_entry
->port_id
[1],
3169 rptid_entry
->port_id
[0]);
3170 } else if (rptid_entry
->format
== 1) {
3172 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x10b9,
3173 "Format 1: VP[%d] enabled - status %d - with "
3174 "port id %02x%02x%02x.\n", vp_idx
, MSB(stat
),
3175 rptid_entry
->port_id
[2], rptid_entry
->port_id
[1],
3176 rptid_entry
->port_id
[0]);
3179 if (vp_idx
== 0 && (MSB(stat
) != 1))
3182 if (MSB(stat
) != 0 && MSB(stat
) != 2) {
3183 ql_dbg(ql_dbg_mbx
, vha
, 0x10ba,
3184 "Could not acquire ID for VP[%d].\n", vp_idx
);
3189 spin_lock_irqsave(&ha
->vport_slock
, flags
);
3190 list_for_each_entry(vp
, &ha
->vp_list
, list
) {
3191 if (vp_idx
== vp
->vp_idx
) {
3196 spin_unlock_irqrestore(&ha
->vport_slock
, flags
);
3201 vp
->d_id
.b
.domain
= rptid_entry
->port_id
[2];
3202 vp
->d_id
.b
.area
= rptid_entry
->port_id
[1];
3203 vp
->d_id
.b
.al_pa
= rptid_entry
->port_id
[0];
3206 * Cannot configure here as we are still sitting on the
3207 * response queue. Handle it in dpc context.
3209 set_bit(VP_IDX_ACQUIRED
, &vp
->vp_flags
);
3212 set_bit(REGISTER_FC4_NEEDED
, &vp
->dpc_flags
);
3213 set_bit(REGISTER_FDMI_NEEDED
, &vp
->dpc_flags
);
3214 set_bit(VP_DPC_NEEDED
, &vha
->dpc_flags
);
3215 qla2xxx_wake_dpc(vha
);
3220 * qla24xx_modify_vp_config
3221 * Change VP configuration for vha
3224 * vha = adapter block pointer.
3227 * qla2xxx local function return status code.
3233 qla24xx_modify_vp_config(scsi_qla_host_t
*vha
)
3236 struct vp_config_entry_24xx
*vpmod
;
3237 dma_addr_t vpmod_dma
;
3238 struct qla_hw_data
*ha
= vha
->hw
;
3239 struct scsi_qla_host
*base_vha
= pci_get_drvdata(ha
->pdev
);
3241 /* This can be called by the parent */
3243 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x10bb,
3244 "Entered %s.\n", __func__
);
3246 vpmod
= dma_pool_alloc(ha
->s_dma_pool
, GFP_KERNEL
, &vpmod_dma
);
3248 ql_log(ql_log_warn
, vha
, 0x10bc,
3249 "Failed to allocate modify VP IOCB.\n");
3250 return QLA_MEMORY_ALLOC_FAILED
;
3253 memset(vpmod
, 0, sizeof(struct vp_config_entry_24xx
));
3254 vpmod
->entry_type
= VP_CONFIG_IOCB_TYPE
;
3255 vpmod
->entry_count
= 1;
3256 vpmod
->command
= VCT_COMMAND_MOD_ENABLE_VPS
;
3257 vpmod
->vp_count
= 1;
3258 vpmod
->vp_index1
= vha
->vp_idx
;
3259 vpmod
->options_idx1
= BIT_3
|BIT_4
|BIT_5
;
3261 qlt_modify_vp_config(vha
, vpmod
);
3263 memcpy(vpmod
->node_name_idx1
, vha
->node_name
, WWN_SIZE
);
3264 memcpy(vpmod
->port_name_idx1
, vha
->port_name
, WWN_SIZE
);
3265 vpmod
->entry_count
= 1;
3267 rval
= qla2x00_issue_iocb(base_vha
, vpmod
, vpmod_dma
, 0);
3268 if (rval
!= QLA_SUCCESS
) {
3269 ql_dbg(ql_dbg_mbx
, vha
, 0x10bd,
3270 "Failed to issue VP config IOCB (%x).\n", rval
);
3271 } else if (vpmod
->comp_status
!= 0) {
3272 ql_dbg(ql_dbg_mbx
, vha
, 0x10be,
3273 "Failed to complete IOCB -- error status (%x).\n",
3274 vpmod
->comp_status
);
3275 rval
= QLA_FUNCTION_FAILED
;
3276 } else if (vpmod
->comp_status
!= __constant_cpu_to_le16(CS_COMPLETE
)) {
3277 ql_dbg(ql_dbg_mbx
, vha
, 0x10bf,
3278 "Failed to complete IOCB -- completion status (%x).\n",
3279 le16_to_cpu(vpmod
->comp_status
));
3280 rval
= QLA_FUNCTION_FAILED
;
3283 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x10c0,
3284 "Done %s.\n", __func__
);
3285 fc_vport_set_state(vha
->fc_vport
, FC_VPORT_INITIALIZING
);
3287 dma_pool_free(ha
->s_dma_pool
, vpmod
, vpmod_dma
);
3293 * qla24xx_control_vp
3294 * Enable a virtual port for given host
3297 * ha = adapter block pointer.
3298 * vhba = virtual adapter (unused)
3299 * index = index number for enabled VP
3302 * qla2xxx local function return status code.
3308 qla24xx_control_vp(scsi_qla_host_t
*vha
, int cmd
)
3312 struct vp_ctrl_entry_24xx
*vce
;
3314 struct qla_hw_data
*ha
= vha
->hw
;
3315 int vp_index
= vha
->vp_idx
;
3316 struct scsi_qla_host
*base_vha
= pci_get_drvdata(ha
->pdev
);
3318 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x10c1,
3319 "Entered %s enabling index %d.\n", __func__
, vp_index
);
3321 if (vp_index
== 0 || vp_index
>= ha
->max_npiv_vports
)
3322 return QLA_PARAMETER_ERROR
;
3324 vce
= dma_pool_alloc(ha
->s_dma_pool
, GFP_KERNEL
, &vce_dma
);
3326 ql_log(ql_log_warn
, vha
, 0x10c2,
3327 "Failed to allocate VP control IOCB.\n");
3328 return QLA_MEMORY_ALLOC_FAILED
;
3330 memset(vce
, 0, sizeof(struct vp_ctrl_entry_24xx
));
3332 vce
->entry_type
= VP_CTRL_IOCB_TYPE
;
3333 vce
->entry_count
= 1;
3334 vce
->command
= cpu_to_le16(cmd
);
3335 vce
->vp_count
= __constant_cpu_to_le16(1);
3337 /* index map in firmware starts with 1; decrement index
3338 * this is ok as we never use index 0
3340 map
= (vp_index
- 1) / 8;
3341 pos
= (vp_index
- 1) & 7;
3342 mutex_lock(&ha
->vport_lock
);
3343 vce
->vp_idx_map
[map
] |= 1 << pos
;
3344 mutex_unlock(&ha
->vport_lock
);
3346 rval
= qla2x00_issue_iocb(base_vha
, vce
, vce_dma
, 0);
3347 if (rval
!= QLA_SUCCESS
) {
3348 ql_dbg(ql_dbg_mbx
, vha
, 0x10c3,
3349 "Failed to issue VP control IOCB (%x).\n", rval
);
3350 } else if (vce
->entry_status
!= 0) {
3351 ql_dbg(ql_dbg_mbx
, vha
, 0x10c4,
3352 "Failed to complete IOCB -- error status (%x).\n",
3354 rval
= QLA_FUNCTION_FAILED
;
3355 } else if (vce
->comp_status
!= __constant_cpu_to_le16(CS_COMPLETE
)) {
3356 ql_dbg(ql_dbg_mbx
, vha
, 0x10c5,
3357 "Failed to complet IOCB -- completion status (%x).\n",
3358 le16_to_cpu(vce
->comp_status
));
3359 rval
= QLA_FUNCTION_FAILED
;
3361 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x10c6,
3362 "Done %s.\n", __func__
);
3365 dma_pool_free(ha
->s_dma_pool
, vce
, vce_dma
);
3371 * qla2x00_send_change_request
3372 * Receive or disable RSCN request from fabric controller
3375 * ha = adapter block pointer
3376 * format = registration format:
3378 * 1 - Fabric detected registration
3379 * 2 - N_port detected registration
3380 * 3 - Full registration
3381 * FF - clear registration
3382 * vp_idx = Virtual port index
3385 * qla2x00 local function return status code.
3392 qla2x00_send_change_request(scsi_qla_host_t
*vha
, uint16_t format
,
3397 mbx_cmd_t
*mcp
= &mc
;
3399 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x10c7,
3400 "Entered %s.\n", __func__
);
3402 mcp
->mb
[0] = MBC_SEND_CHANGE_REQUEST
;
3403 mcp
->mb
[1] = format
;
3404 mcp
->mb
[9] = vp_idx
;
3405 mcp
->out_mb
= MBX_9
|MBX_1
|MBX_0
;
3406 mcp
->in_mb
= MBX_0
|MBX_1
;
3407 mcp
->tov
= MBX_TOV_SECONDS
;
3409 rval
= qla2x00_mailbox_command(vha
, mcp
);
3411 if (rval
== QLA_SUCCESS
) {
3412 if (mcp
->mb
[0] != MBS_COMMAND_COMPLETE
) {
3422 qla2x00_dump_ram(scsi_qla_host_t
*vha
, dma_addr_t req_dma
, uint32_t addr
,
3427 mbx_cmd_t
*mcp
= &mc
;
3429 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x1009,
3430 "Entered %s.\n", __func__
);
3432 if (MSW(addr
) || IS_FWI2_CAPABLE(vha
->hw
)) {
3433 mcp
->mb
[0] = MBC_DUMP_RISC_RAM_EXTENDED
;
3434 mcp
->mb
[8] = MSW(addr
);
3435 mcp
->out_mb
= MBX_8
|MBX_0
;
3437 mcp
->mb
[0] = MBC_DUMP_RISC_RAM
;
3438 mcp
->out_mb
= MBX_0
;
3440 mcp
->mb
[1] = LSW(addr
);
3441 mcp
->mb
[2] = MSW(req_dma
);
3442 mcp
->mb
[3] = LSW(req_dma
);
3443 mcp
->mb
[6] = MSW(MSD(req_dma
));
3444 mcp
->mb
[7] = LSW(MSD(req_dma
));
3445 mcp
->out_mb
|= MBX_7
|MBX_6
|MBX_3
|MBX_2
|MBX_1
;
3446 if (IS_FWI2_CAPABLE(vha
->hw
)) {
3447 mcp
->mb
[4] = MSW(size
);
3448 mcp
->mb
[5] = LSW(size
);
3449 mcp
->out_mb
|= MBX_5
|MBX_4
;
3451 mcp
->mb
[4] = LSW(size
);
3452 mcp
->out_mb
|= MBX_4
;
3456 mcp
->tov
= MBX_TOV_SECONDS
;
3458 rval
= qla2x00_mailbox_command(vha
, mcp
);
3460 if (rval
!= QLA_SUCCESS
) {
3461 ql_dbg(ql_dbg_mbx
, vha
, 0x1008,
3462 "Failed=%x mb[0]=%x.\n", rval
, mcp
->mb
[0]);
3464 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x1007,
3465 "Done %s.\n", __func__
);
3470 /* 84XX Support **************************************************************/
3472 struct cs84xx_mgmt_cmd
{
3474 struct verify_chip_entry_84xx req
;
3475 struct verify_chip_rsp_84xx rsp
;
3480 qla84xx_verify_chip(struct scsi_qla_host
*vha
, uint16_t *status
)
3483 struct cs84xx_mgmt_cmd
*mn
;
3486 unsigned long flags
;
3487 struct qla_hw_data
*ha
= vha
->hw
;
3489 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x10c8,
3490 "Entered %s.\n", __func__
);
3492 mn
= dma_pool_alloc(ha
->s_dma_pool
, GFP_KERNEL
, &mn_dma
);
3494 return QLA_MEMORY_ALLOC_FAILED
;
3498 options
= ha
->cs84xx
->fw_update
? VCO_FORCE_UPDATE
: 0;
3499 /* Diagnostic firmware? */
3500 /* options |= MENLO_DIAG_FW; */
3501 /* We update the firmware with only one data sequence. */
3502 options
|= VCO_END_OF_DATA
;
3506 memset(mn
, 0, sizeof(*mn
));
3507 mn
->p
.req
.entry_type
= VERIFY_CHIP_IOCB_TYPE
;
3508 mn
->p
.req
.entry_count
= 1;
3509 mn
->p
.req
.options
= cpu_to_le16(options
);
3511 ql_dbg(ql_dbg_mbx
+ ql_dbg_buffer
, vha
, 0x111c,
3512 "Dump of Verify Request.\n");
3513 ql_dump_buffer(ql_dbg_mbx
+ ql_dbg_buffer
, vha
, 0x111e,
3514 (uint8_t *)mn
, sizeof(*mn
));
3516 rval
= qla2x00_issue_iocb_timeout(vha
, mn
, mn_dma
, 0, 120);
3517 if (rval
!= QLA_SUCCESS
) {
3518 ql_dbg(ql_dbg_mbx
, vha
, 0x10cb,
3519 "Failed to issue verify IOCB (%x).\n", rval
);
3523 ql_dbg(ql_dbg_mbx
+ ql_dbg_buffer
, vha
, 0x1110,
3524 "Dump of Verify Response.\n");
3525 ql_dump_buffer(ql_dbg_mbx
+ ql_dbg_buffer
, vha
, 0x1118,
3526 (uint8_t *)mn
, sizeof(*mn
));
3528 status
[0] = le16_to_cpu(mn
->p
.rsp
.comp_status
);
3529 status
[1] = status
[0] == CS_VCS_CHIP_FAILURE
?
3530 le16_to_cpu(mn
->p
.rsp
.failure_code
) : 0;
3531 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x10ce,
3532 "cs=%x fc=%x.\n", status
[0], status
[1]);
3534 if (status
[0] != CS_COMPLETE
) {
3535 rval
= QLA_FUNCTION_FAILED
;
3536 if (!(options
& VCO_DONT_UPDATE_FW
)) {
3537 ql_dbg(ql_dbg_mbx
, vha
, 0x10cf,
3538 "Firmware update failed. Retrying "
3539 "without update firmware.\n");
3540 options
|= VCO_DONT_UPDATE_FW
;
3541 options
&= ~VCO_FORCE_UPDATE
;
3545 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x10d0,
3546 "Firmware updated to %x.\n",
3547 le32_to_cpu(mn
->p
.rsp
.fw_ver
));
3549 /* NOTE: we only update OP firmware. */
3550 spin_lock_irqsave(&ha
->cs84xx
->access_lock
, flags
);
3551 ha
->cs84xx
->op_fw_version
=
3552 le32_to_cpu(mn
->p
.rsp
.fw_ver
);
3553 spin_unlock_irqrestore(&ha
->cs84xx
->access_lock
,
3559 dma_pool_free(ha
->s_dma_pool
, mn
, mn_dma
);
3561 if (rval
!= QLA_SUCCESS
) {
3562 ql_dbg(ql_dbg_mbx
, vha
, 0x10d1,
3563 "Failed=%x.\n", rval
);
3565 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x10d2,
3566 "Done %s.\n", __func__
);
3573 qla25xx_init_req_que(struct scsi_qla_host
*vha
, struct req_que
*req
)
3576 unsigned long flags
;
3578 mbx_cmd_t
*mcp
= &mc
;
3579 struct qla_hw_data
*ha
= vha
->hw
;
3581 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x10d3,
3582 "Entered %s.\n", __func__
);
3584 mcp
->mb
[0] = MBC_INITIALIZE_MULTIQ
;
3585 mcp
->mb
[1] = req
->options
;
3586 mcp
->mb
[2] = MSW(LSD(req
->dma
));
3587 mcp
->mb
[3] = LSW(LSD(req
->dma
));
3588 mcp
->mb
[6] = MSW(MSD(req
->dma
));
3589 mcp
->mb
[7] = LSW(MSD(req
->dma
));
3590 mcp
->mb
[5] = req
->length
;
3592 mcp
->mb
[10] = req
->rsp
->id
;
3593 mcp
->mb
[12] = req
->qos
;
3594 mcp
->mb
[11] = req
->vp_idx
;
3595 mcp
->mb
[13] = req
->rid
;
3599 mcp
->mb
[4] = req
->id
;
3600 /* que in ptr index */
3602 /* que out ptr index */
3604 mcp
->out_mb
= MBX_14
|MBX_13
|MBX_12
|MBX_11
|MBX_10
|MBX_9
|MBX_8
|MBX_7
|
3605 MBX_6
|MBX_5
|MBX_4
|MBX_3
|MBX_2
|MBX_1
|MBX_0
;
3607 mcp
->flags
= MBX_DMA_OUT
;
3608 mcp
->tov
= MBX_TOV_SECONDS
* 2;
3610 if (IS_QLA81XX(ha
) || IS_QLA83XX(ha
))
3611 mcp
->in_mb
|= MBX_1
;
3612 if (IS_QLA83XX(ha
)) {
3613 mcp
->out_mb
|= MBX_15
;
3614 /* debug q create issue in SR-IOV */
3615 mcp
->in_mb
|= MBX_9
| MBX_8
| MBX_7
;
3618 spin_lock_irqsave(&ha
->hardware_lock
, flags
);
3619 if (!(req
->options
& BIT_0
)) {
3620 WRT_REG_DWORD(req
->req_q_in
, 0);
3621 if (!IS_QLA83XX(ha
))
3622 WRT_REG_DWORD(req
->req_q_out
, 0);
3624 spin_unlock_irqrestore(&ha
->hardware_lock
, flags
);
3626 rval
= qla2x00_mailbox_command(vha
, mcp
);
3627 if (rval
!= QLA_SUCCESS
) {
3628 ql_dbg(ql_dbg_mbx
, vha
, 0x10d4,
3629 "Failed=%x mb[0]=%x.\n", rval
, mcp
->mb
[0]);
3631 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x10d5,
3632 "Done %s.\n", __func__
);
3639 qla25xx_init_rsp_que(struct scsi_qla_host
*vha
, struct rsp_que
*rsp
)
3642 unsigned long flags
;
3644 mbx_cmd_t
*mcp
= &mc
;
3645 struct qla_hw_data
*ha
= vha
->hw
;
3647 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x10d6,
3648 "Entered %s.\n", __func__
);
3650 mcp
->mb
[0] = MBC_INITIALIZE_MULTIQ
;
3651 mcp
->mb
[1] = rsp
->options
;
3652 mcp
->mb
[2] = MSW(LSD(rsp
->dma
));
3653 mcp
->mb
[3] = LSW(LSD(rsp
->dma
));
3654 mcp
->mb
[6] = MSW(MSD(rsp
->dma
));
3655 mcp
->mb
[7] = LSW(MSD(rsp
->dma
));
3656 mcp
->mb
[5] = rsp
->length
;
3657 mcp
->mb
[14] = rsp
->msix
->entry
;
3658 mcp
->mb
[13] = rsp
->rid
;
3662 mcp
->mb
[4] = rsp
->id
;
3663 /* que in ptr index */
3665 /* que out ptr index */
3667 mcp
->out_mb
= MBX_14
|MBX_13
|MBX_9
|MBX_8
|MBX_7
3668 |MBX_6
|MBX_5
|MBX_4
|MBX_3
|MBX_2
|MBX_1
|MBX_0
;
3670 mcp
->flags
= MBX_DMA_OUT
;
3671 mcp
->tov
= MBX_TOV_SECONDS
* 2;
3673 if (IS_QLA81XX(ha
)) {
3674 mcp
->out_mb
|= MBX_12
|MBX_11
|MBX_10
;
3675 mcp
->in_mb
|= MBX_1
;
3676 } else if (IS_QLA83XX(ha
)) {
3677 mcp
->out_mb
|= MBX_15
|MBX_12
|MBX_11
|MBX_10
;
3678 mcp
->in_mb
|= MBX_1
;
3679 /* debug q create issue in SR-IOV */
3680 mcp
->in_mb
|= MBX_9
| MBX_8
| MBX_7
;
3683 spin_lock_irqsave(&ha
->hardware_lock
, flags
);
3684 if (!(rsp
->options
& BIT_0
)) {
3685 WRT_REG_DWORD(rsp
->rsp_q_out
, 0);
3686 if (!IS_QLA83XX(ha
))
3687 WRT_REG_DWORD(rsp
->rsp_q_in
, 0);
3690 spin_unlock_irqrestore(&ha
->hardware_lock
, flags
);
3692 rval
= qla2x00_mailbox_command(vha
, mcp
);
3693 if (rval
!= QLA_SUCCESS
) {
3694 ql_dbg(ql_dbg_mbx
, vha
, 0x10d7,
3695 "Failed=%x mb[0]=%x.\n", rval
, mcp
->mb
[0]);
3697 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x10d8,
3698 "Done %s.\n", __func__
);
3705 qla81xx_idc_ack(scsi_qla_host_t
*vha
, uint16_t *mb
)
3709 mbx_cmd_t
*mcp
= &mc
;
3711 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x10d9,
3712 "Entered %s.\n", __func__
);
3714 mcp
->mb
[0] = MBC_IDC_ACK
;
3715 memcpy(&mcp
->mb
[1], mb
, QLA_IDC_ACK_REGS
* sizeof(uint16_t));
3716 mcp
->out_mb
= MBX_7
|MBX_6
|MBX_5
|MBX_4
|MBX_3
|MBX_2
|MBX_1
|MBX_0
;
3718 mcp
->tov
= MBX_TOV_SECONDS
;
3720 rval
= qla2x00_mailbox_command(vha
, mcp
);
3722 if (rval
!= QLA_SUCCESS
) {
3723 ql_dbg(ql_dbg_mbx
, vha
, 0x10da,
3724 "Failed=%x mb[0]=%x.\n", rval
, mcp
->mb
[0]);
3726 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x10db,
3727 "Done %s.\n", __func__
);
3734 qla81xx_fac_get_sector_size(scsi_qla_host_t
*vha
, uint32_t *sector_size
)
3738 mbx_cmd_t
*mcp
= &mc
;
3740 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x10dc,
3741 "Entered %s.\n", __func__
);
3743 if (!IS_QLA81XX(vha
->hw
) && !IS_QLA83XX(vha
->hw
))
3744 return QLA_FUNCTION_FAILED
;
3746 mcp
->mb
[0] = MBC_FLASH_ACCESS_CTRL
;
3747 mcp
->mb
[1] = FAC_OPT_CMD_GET_SECTOR_SIZE
;
3748 mcp
->out_mb
= MBX_1
|MBX_0
;
3749 mcp
->in_mb
= MBX_1
|MBX_0
;
3750 mcp
->tov
= MBX_TOV_SECONDS
;
3752 rval
= qla2x00_mailbox_command(vha
, mcp
);
3754 if (rval
!= QLA_SUCCESS
) {
3755 ql_dbg(ql_dbg_mbx
, vha
, 0x10dd,
3756 "Failed=%x mb[0]=%x mb[1]=%x.\n",
3757 rval
, mcp
->mb
[0], mcp
->mb
[1]);
3759 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x10de,
3760 "Done %s.\n", __func__
);
3761 *sector_size
= mcp
->mb
[1];
3768 qla81xx_fac_do_write_enable(scsi_qla_host_t
*vha
, int enable
)
3772 mbx_cmd_t
*mcp
= &mc
;
3774 if (!IS_QLA81XX(vha
->hw
) && !IS_QLA83XX(vha
->hw
))
3775 return QLA_FUNCTION_FAILED
;
3777 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x10df,
3778 "Entered %s.\n", __func__
);
3780 mcp
->mb
[0] = MBC_FLASH_ACCESS_CTRL
;
3781 mcp
->mb
[1] = enable
? FAC_OPT_CMD_WRITE_ENABLE
:
3782 FAC_OPT_CMD_WRITE_PROTECT
;
3783 mcp
->out_mb
= MBX_1
|MBX_0
;
3784 mcp
->in_mb
= MBX_1
|MBX_0
;
3785 mcp
->tov
= MBX_TOV_SECONDS
;
3787 rval
= qla2x00_mailbox_command(vha
, mcp
);
3789 if (rval
!= QLA_SUCCESS
) {
3790 ql_dbg(ql_dbg_mbx
, vha
, 0x10e0,
3791 "Failed=%x mb[0]=%x mb[1]=%x.\n",
3792 rval
, mcp
->mb
[0], mcp
->mb
[1]);
3794 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x10e1,
3795 "Done %s.\n", __func__
);
3802 qla81xx_fac_erase_sector(scsi_qla_host_t
*vha
, uint32_t start
, uint32_t finish
)
3806 mbx_cmd_t
*mcp
= &mc
;
3808 if (!IS_QLA81XX(vha
->hw
) && !IS_QLA83XX(vha
->hw
))
3809 return QLA_FUNCTION_FAILED
;
3811 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x10e2,
3812 "Entered %s.\n", __func__
);
3814 mcp
->mb
[0] = MBC_FLASH_ACCESS_CTRL
;
3815 mcp
->mb
[1] = FAC_OPT_CMD_ERASE_SECTOR
;
3816 mcp
->mb
[2] = LSW(start
);
3817 mcp
->mb
[3] = MSW(start
);
3818 mcp
->mb
[4] = LSW(finish
);
3819 mcp
->mb
[5] = MSW(finish
);
3820 mcp
->out_mb
= MBX_5
|MBX_4
|MBX_3
|MBX_2
|MBX_1
|MBX_0
;
3821 mcp
->in_mb
= MBX_2
|MBX_1
|MBX_0
;
3822 mcp
->tov
= MBX_TOV_SECONDS
;
3824 rval
= qla2x00_mailbox_command(vha
, mcp
);
3826 if (rval
!= QLA_SUCCESS
) {
3827 ql_dbg(ql_dbg_mbx
, vha
, 0x10e3,
3828 "Failed=%x mb[0]=%x mb[1]=%x mb[2]=%x.\n",
3829 rval
, mcp
->mb
[0], mcp
->mb
[1], mcp
->mb
[2]);
3831 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x10e4,
3832 "Done %s.\n", __func__
);
3839 qla81xx_restart_mpi_firmware(scsi_qla_host_t
*vha
)
3843 mbx_cmd_t
*mcp
= &mc
;
3845 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x10e5,
3846 "Entered %s.\n", __func__
);
3848 mcp
->mb
[0] = MBC_RESTART_MPI_FW
;
3849 mcp
->out_mb
= MBX_0
;
3850 mcp
->in_mb
= MBX_0
|MBX_1
;
3851 mcp
->tov
= MBX_TOV_SECONDS
;
3853 rval
= qla2x00_mailbox_command(vha
, mcp
);
3855 if (rval
!= QLA_SUCCESS
) {
3856 ql_dbg(ql_dbg_mbx
, vha
, 0x10e6,
3857 "Failed=%x mb[0]=%x mb[1]=%x.\n",
3858 rval
, mcp
->mb
[0], mcp
->mb
[1]);
3860 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x10e7,
3861 "Done %s.\n", __func__
);
3868 qla82xx_set_driver_version(scsi_qla_host_t
*vha
, char *version
)
3872 mbx_cmd_t
*mcp
= &mc
;
3876 struct qla_hw_data
*ha
= vha
->hw
;
3878 if (!IS_P3P_TYPE(ha
))
3879 return QLA_FUNCTION_FAILED
;
3881 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x117b,
3882 "Entered %s.\n", __func__
);
3884 str
= (void *)version
;
3885 len
= strlen(version
);
3887 mcp
->mb
[0] = MBC_SET_RNID_PARAMS
;
3888 mcp
->mb
[1] = RNID_TYPE_SET_VERSION
<< 8;
3889 mcp
->out_mb
= MBX_1
|MBX_0
;
3890 for (i
= 4; i
< 16 && len
; i
++, str
++, len
-= 2) {
3891 mcp
->mb
[i
] = cpu_to_le16p(str
);
3892 mcp
->out_mb
|= 1<<i
;
3894 for (; i
< 16; i
++) {
3896 mcp
->out_mb
|= 1<<i
;
3898 mcp
->in_mb
= MBX_1
|MBX_0
;
3899 mcp
->tov
= MBX_TOV_SECONDS
;
3901 rval
= qla2x00_mailbox_command(vha
, mcp
);
3903 if (rval
!= QLA_SUCCESS
) {
3904 ql_dbg(ql_dbg_mbx
, vha
, 0x117c,
3905 "Failed=%x mb[0]=%x,%x.\n", rval
, mcp
->mb
[0], mcp
->mb
[1]);
3907 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x117d,
3908 "Done %s.\n", __func__
);
3915 qla25xx_set_driver_version(scsi_qla_host_t
*vha
, char *version
)
3919 mbx_cmd_t
*mcp
= &mc
;
3924 struct qla_hw_data
*ha
= vha
->hw
;
3926 if (!IS_FWI2_CAPABLE(ha
) || IS_QLA24XX_TYPE(ha
) || IS_QLA81XX(ha
) ||
3928 return QLA_FUNCTION_FAILED
;
3930 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x117e,
3931 "Entered %s.\n", __func__
);
3933 str
= dma_pool_alloc(ha
->s_dma_pool
, GFP_KERNEL
, &str_dma
);
3935 ql_log(ql_log_warn
, vha
, 0x117f,
3936 "Failed to allocate driver version param.\n");
3937 return QLA_MEMORY_ALLOC_FAILED
;
3940 memcpy(str
, "\x7\x3\x11\x0", 4);
3942 len
= dwlen
* 4 - 4;
3943 memset(str
+ 4, 0, len
);
3944 if (len
> strlen(version
))
3945 len
= strlen(version
);
3946 memcpy(str
+ 4, version
, len
);
3948 mcp
->mb
[0] = MBC_SET_RNID_PARAMS
;
3949 mcp
->mb
[1] = RNID_TYPE_SET_VERSION
<< 8 | dwlen
;
3950 mcp
->mb
[2] = MSW(LSD(str_dma
));
3951 mcp
->mb
[3] = LSW(LSD(str_dma
));
3952 mcp
->mb
[6] = MSW(MSD(str_dma
));
3953 mcp
->mb
[7] = LSW(MSD(str_dma
));
3954 mcp
->out_mb
= MBX_7
|MBX_6
|MBX_3
|MBX_2
|MBX_1
|MBX_0
;
3955 mcp
->in_mb
= MBX_1
|MBX_0
;
3956 mcp
->tov
= MBX_TOV_SECONDS
;
3958 rval
= qla2x00_mailbox_command(vha
, mcp
);
3960 if (rval
!= QLA_SUCCESS
) {
3961 ql_dbg(ql_dbg_mbx
, vha
, 0x1180,
3962 "Failed=%x mb[0]=%x,%x.\n", rval
, mcp
->mb
[0], mcp
->mb
[1]);
3964 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x1181,
3965 "Done %s.\n", __func__
);
3968 dma_pool_free(ha
->s_dma_pool
, str
, str_dma
);
3974 qla2x00_read_asic_temperature(scsi_qla_host_t
*vha
, uint16_t *temp
)
3978 mbx_cmd_t
*mcp
= &mc
;
3980 if (!IS_FWI2_CAPABLE(vha
->hw
))
3981 return QLA_FUNCTION_FAILED
;
3983 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x1159,
3984 "Entered %s.\n", __func__
);
3986 mcp
->mb
[0] = MBC_GET_RNID_PARAMS
;
3987 mcp
->mb
[1] = RNID_TYPE_ASIC_TEMP
<< 8;
3988 mcp
->out_mb
= MBX_1
|MBX_0
;
3989 mcp
->in_mb
= MBX_1
|MBX_0
;
3990 mcp
->tov
= MBX_TOV_SECONDS
;
3992 rval
= qla2x00_mailbox_command(vha
, mcp
);
3995 if (rval
!= QLA_SUCCESS
) {
3996 ql_dbg(ql_dbg_mbx
, vha
, 0x115a,
3997 "Failed=%x mb[0]=%x,%x.\n", rval
, mcp
->mb
[0], mcp
->mb
[1]);
3999 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x115b,
4000 "Done %s.\n", __func__
);
4007 qla2x00_read_sfp(scsi_qla_host_t
*vha
, dma_addr_t sfp_dma
, uint8_t *sfp
,
4008 uint16_t dev
, uint16_t off
, uint16_t len
, uint16_t opt
)
4012 mbx_cmd_t
*mcp
= &mc
;
4013 struct qla_hw_data
*ha
= vha
->hw
;
4015 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x10e8,
4016 "Entered %s.\n", __func__
);
4018 if (!IS_FWI2_CAPABLE(ha
))
4019 return QLA_FUNCTION_FAILED
;
4024 mcp
->mb
[0] = MBC_READ_SFP
;
4026 mcp
->mb
[2] = MSW(sfp_dma
);
4027 mcp
->mb
[3] = LSW(sfp_dma
);
4028 mcp
->mb
[6] = MSW(MSD(sfp_dma
));
4029 mcp
->mb
[7] = LSW(MSD(sfp_dma
));
4033 mcp
->out_mb
= MBX_10
|MBX_9
|MBX_8
|MBX_7
|MBX_6
|MBX_3
|MBX_2
|MBX_1
|MBX_0
;
4034 mcp
->in_mb
= MBX_1
|MBX_0
;
4035 mcp
->tov
= MBX_TOV_SECONDS
;
4037 rval
= qla2x00_mailbox_command(vha
, mcp
);
4042 if (rval
!= QLA_SUCCESS
) {
4043 ql_dbg(ql_dbg_mbx
, vha
, 0x10e9,
4044 "Failed=%x mb[0]=%x.\n", rval
, mcp
->mb
[0]);
4046 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x10ea,
4047 "Done %s.\n", __func__
);
4054 qla2x00_write_sfp(scsi_qla_host_t
*vha
, dma_addr_t sfp_dma
, uint8_t *sfp
,
4055 uint16_t dev
, uint16_t off
, uint16_t len
, uint16_t opt
)
4059 mbx_cmd_t
*mcp
= &mc
;
4060 struct qla_hw_data
*ha
= vha
->hw
;
4062 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x10eb,
4063 "Entered %s.\n", __func__
);
4065 if (!IS_FWI2_CAPABLE(ha
))
4066 return QLA_FUNCTION_FAILED
;
4074 mcp
->mb
[0] = MBC_WRITE_SFP
;
4076 mcp
->mb
[2] = MSW(sfp_dma
);
4077 mcp
->mb
[3] = LSW(sfp_dma
);
4078 mcp
->mb
[6] = MSW(MSD(sfp_dma
));
4079 mcp
->mb
[7] = LSW(MSD(sfp_dma
));
4083 mcp
->out_mb
= MBX_10
|MBX_9
|MBX_8
|MBX_7
|MBX_6
|MBX_3
|MBX_2
|MBX_1
|MBX_0
;
4084 mcp
->in_mb
= MBX_1
|MBX_0
;
4085 mcp
->tov
= MBX_TOV_SECONDS
;
4087 rval
= qla2x00_mailbox_command(vha
, mcp
);
4089 if (rval
!= QLA_SUCCESS
) {
4090 ql_dbg(ql_dbg_mbx
, vha
, 0x10ec,
4091 "Failed=%x mb[0]=%x.\n", rval
, mcp
->mb
[0]);
4093 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x10ed,
4094 "Done %s.\n", __func__
);
4101 qla2x00_get_xgmac_stats(scsi_qla_host_t
*vha
, dma_addr_t stats_dma
,
4102 uint16_t size_in_bytes
, uint16_t *actual_size
)
4106 mbx_cmd_t
*mcp
= &mc
;
4108 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x10ee,
4109 "Entered %s.\n", __func__
);
4111 if (!IS_CNA_CAPABLE(vha
->hw
))
4112 return QLA_FUNCTION_FAILED
;
4114 mcp
->mb
[0] = MBC_GET_XGMAC_STATS
;
4115 mcp
->mb
[2] = MSW(stats_dma
);
4116 mcp
->mb
[3] = LSW(stats_dma
);
4117 mcp
->mb
[6] = MSW(MSD(stats_dma
));
4118 mcp
->mb
[7] = LSW(MSD(stats_dma
));
4119 mcp
->mb
[8] = size_in_bytes
>> 2;
4120 mcp
->out_mb
= MBX_8
|MBX_7
|MBX_6
|MBX_3
|MBX_2
|MBX_0
;
4121 mcp
->in_mb
= MBX_2
|MBX_1
|MBX_0
;
4122 mcp
->tov
= MBX_TOV_SECONDS
;
4124 rval
= qla2x00_mailbox_command(vha
, mcp
);
4126 if (rval
!= QLA_SUCCESS
) {
4127 ql_dbg(ql_dbg_mbx
, vha
, 0x10ef,
4128 "Failed=%x mb[0]=%x mb[1]=%x mb[2]=%x.\n",
4129 rval
, mcp
->mb
[0], mcp
->mb
[1], mcp
->mb
[2]);
4131 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x10f0,
4132 "Done %s.\n", __func__
);
4135 *actual_size
= mcp
->mb
[2] << 2;
4142 qla2x00_get_dcbx_params(scsi_qla_host_t
*vha
, dma_addr_t tlv_dma
,
4147 mbx_cmd_t
*mcp
= &mc
;
4149 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x10f1,
4150 "Entered %s.\n", __func__
);
4152 if (!IS_CNA_CAPABLE(vha
->hw
))
4153 return QLA_FUNCTION_FAILED
;
4155 mcp
->mb
[0] = MBC_GET_DCBX_PARAMS
;
4157 mcp
->mb
[2] = MSW(tlv_dma
);
4158 mcp
->mb
[3] = LSW(tlv_dma
);
4159 mcp
->mb
[6] = MSW(MSD(tlv_dma
));
4160 mcp
->mb
[7] = LSW(MSD(tlv_dma
));
4162 mcp
->out_mb
= MBX_8
|MBX_7
|MBX_6
|MBX_3
|MBX_2
|MBX_1
|MBX_0
;
4163 mcp
->in_mb
= MBX_2
|MBX_1
|MBX_0
;
4164 mcp
->tov
= MBX_TOV_SECONDS
;
4166 rval
= qla2x00_mailbox_command(vha
, mcp
);
4168 if (rval
!= QLA_SUCCESS
) {
4169 ql_dbg(ql_dbg_mbx
, vha
, 0x10f2,
4170 "Failed=%x mb[0]=%x mb[1]=%x mb[2]=%x.\n",
4171 rval
, mcp
->mb
[0], mcp
->mb
[1], mcp
->mb
[2]);
4173 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x10f3,
4174 "Done %s.\n", __func__
);
4181 qla2x00_read_ram_word(scsi_qla_host_t
*vha
, uint32_t risc_addr
, uint32_t *data
)
4185 mbx_cmd_t
*mcp
= &mc
;
4187 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x10f4,
4188 "Entered %s.\n", __func__
);
4190 if (!IS_FWI2_CAPABLE(vha
->hw
))
4191 return QLA_FUNCTION_FAILED
;
4193 mcp
->mb
[0] = MBC_READ_RAM_EXTENDED
;
4194 mcp
->mb
[1] = LSW(risc_addr
);
4195 mcp
->mb
[8] = MSW(risc_addr
);
4196 mcp
->out_mb
= MBX_8
|MBX_1
|MBX_0
;
4197 mcp
->in_mb
= MBX_3
|MBX_2
|MBX_0
;
4200 rval
= qla2x00_mailbox_command(vha
, mcp
);
4201 if (rval
!= QLA_SUCCESS
) {
4202 ql_dbg(ql_dbg_mbx
, vha
, 0x10f5,
4203 "Failed=%x mb[0]=%x.\n", rval
, mcp
->mb
[0]);
4205 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x10f6,
4206 "Done %s.\n", __func__
);
4207 *data
= mcp
->mb
[3] << 16 | mcp
->mb
[2];
4214 qla2x00_loopback_test(scsi_qla_host_t
*vha
, struct msg_echo_lb
*mreq
,
4219 mbx_cmd_t
*mcp
= &mc
;
4221 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x10f7,
4222 "Entered %s.\n", __func__
);
4224 memset(mcp
->mb
, 0 , sizeof(mcp
->mb
));
4225 mcp
->mb
[0] = MBC_DIAGNOSTIC_LOOP_BACK
;
4226 mcp
->mb
[1] = mreq
->options
| BIT_6
; // BIT_6 specifies 64 bit addressing
4228 /* transfer count */
4229 mcp
->mb
[10] = LSW(mreq
->transfer_size
);
4230 mcp
->mb
[11] = MSW(mreq
->transfer_size
);
4232 /* send data address */
4233 mcp
->mb
[14] = LSW(mreq
->send_dma
);
4234 mcp
->mb
[15] = MSW(mreq
->send_dma
);
4235 mcp
->mb
[20] = LSW(MSD(mreq
->send_dma
));
4236 mcp
->mb
[21] = MSW(MSD(mreq
->send_dma
));
4238 /* receive data address */
4239 mcp
->mb
[16] = LSW(mreq
->rcv_dma
);
4240 mcp
->mb
[17] = MSW(mreq
->rcv_dma
);
4241 mcp
->mb
[6] = LSW(MSD(mreq
->rcv_dma
));
4242 mcp
->mb
[7] = MSW(MSD(mreq
->rcv_dma
));
4244 /* Iteration count */
4245 mcp
->mb
[18] = LSW(mreq
->iteration_count
);
4246 mcp
->mb
[19] = MSW(mreq
->iteration_count
);
4248 mcp
->out_mb
= MBX_21
|MBX_20
|MBX_19
|MBX_18
|MBX_17
|MBX_16
|MBX_15
|
4249 MBX_14
|MBX_13
|MBX_12
|MBX_11
|MBX_10
|MBX_7
|MBX_6
|MBX_1
|MBX_0
;
4250 if (IS_CNA_CAPABLE(vha
->hw
))
4251 mcp
->out_mb
|= MBX_2
;
4252 mcp
->in_mb
= MBX_19
|MBX_18
|MBX_3
|MBX_2
|MBX_1
|MBX_0
;
4254 mcp
->buf_size
= mreq
->transfer_size
;
4255 mcp
->tov
= MBX_TOV_SECONDS
;
4256 mcp
->flags
= MBX_DMA_OUT
|MBX_DMA_IN
|IOCTL_CMD
;
4258 rval
= qla2x00_mailbox_command(vha
, mcp
);
4260 if (rval
!= QLA_SUCCESS
) {
4261 ql_dbg(ql_dbg_mbx
, vha
, 0x10f8,
4262 "Failed=%x mb[0]=%x mb[1]=%x mb[2]=%x mb[3]=%x mb[18]=%x "
4263 "mb[19]=%x.\n", rval
, mcp
->mb
[0], mcp
->mb
[1], mcp
->mb
[2],
4264 mcp
->mb
[3], mcp
->mb
[18], mcp
->mb
[19]);
4266 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x10f9,
4267 "Done %s.\n", __func__
);
4270 /* Copy mailbox information */
4271 memcpy( mresp
, mcp
->mb
, 64);
4276 qla2x00_echo_test(scsi_qla_host_t
*vha
, struct msg_echo_lb
*mreq
,
4281 mbx_cmd_t
*mcp
= &mc
;
4282 struct qla_hw_data
*ha
= vha
->hw
;
4284 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x10fa,
4285 "Entered %s.\n", __func__
);
4287 memset(mcp
->mb
, 0 , sizeof(mcp
->mb
));
4288 mcp
->mb
[0] = MBC_DIAGNOSTIC_ECHO
;
4289 mcp
->mb
[1] = mreq
->options
| BIT_6
; /* BIT_6 specifies 64bit address */
4290 if (IS_CNA_CAPABLE(ha
)) {
4291 mcp
->mb
[1] |= BIT_15
;
4292 mcp
->mb
[2] = vha
->fcoe_fcf_idx
;
4294 mcp
->mb
[16] = LSW(mreq
->rcv_dma
);
4295 mcp
->mb
[17] = MSW(mreq
->rcv_dma
);
4296 mcp
->mb
[6] = LSW(MSD(mreq
->rcv_dma
));
4297 mcp
->mb
[7] = MSW(MSD(mreq
->rcv_dma
));
4299 mcp
->mb
[10] = LSW(mreq
->transfer_size
);
4301 mcp
->mb
[14] = LSW(mreq
->send_dma
);
4302 mcp
->mb
[15] = MSW(mreq
->send_dma
);
4303 mcp
->mb
[20] = LSW(MSD(mreq
->send_dma
));
4304 mcp
->mb
[21] = MSW(MSD(mreq
->send_dma
));
4306 mcp
->out_mb
= MBX_21
|MBX_20
|MBX_17
|MBX_16
|MBX_15
|
4307 MBX_14
|MBX_10
|MBX_7
|MBX_6
|MBX_1
|MBX_0
;
4308 if (IS_CNA_CAPABLE(ha
))
4309 mcp
->out_mb
|= MBX_2
;
4312 if (IS_QLA24XX_TYPE(ha
) || IS_QLA25XX(ha
) ||
4313 IS_CNA_CAPABLE(ha
) || IS_QLA2031(ha
))
4314 mcp
->in_mb
|= MBX_1
;
4315 if (IS_CNA_CAPABLE(ha
) || IS_QLA2031(ha
))
4316 mcp
->in_mb
|= MBX_3
;
4318 mcp
->tov
= MBX_TOV_SECONDS
;
4319 mcp
->flags
= MBX_DMA_OUT
|MBX_DMA_IN
|IOCTL_CMD
;
4320 mcp
->buf_size
= mreq
->transfer_size
;
4322 rval
= qla2x00_mailbox_command(vha
, mcp
);
4324 if (rval
!= QLA_SUCCESS
) {
4325 ql_dbg(ql_dbg_mbx
, vha
, 0x10fb,
4326 "Failed=%x mb[0]=%x mb[1]=%x.\n",
4327 rval
, mcp
->mb
[0], mcp
->mb
[1]);
4329 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x10fc,
4330 "Done %s.\n", __func__
);
4333 /* Copy mailbox information */
4334 memcpy(mresp
, mcp
->mb
, 64);
4339 qla84xx_reset_chip(scsi_qla_host_t
*vha
, uint16_t enable_diagnostic
)
4343 mbx_cmd_t
*mcp
= &mc
;
4345 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x10fd,
4346 "Entered %s enable_diag=%d.\n", __func__
, enable_diagnostic
);
4348 mcp
->mb
[0] = MBC_ISP84XX_RESET
;
4349 mcp
->mb
[1] = enable_diagnostic
;
4350 mcp
->out_mb
= MBX_1
|MBX_0
;
4351 mcp
->in_mb
= MBX_1
|MBX_0
;
4352 mcp
->tov
= MBX_TOV_SECONDS
;
4353 mcp
->flags
= MBX_DMA_OUT
|MBX_DMA_IN
|IOCTL_CMD
;
4354 rval
= qla2x00_mailbox_command(vha
, mcp
);
4356 if (rval
!= QLA_SUCCESS
)
4357 ql_dbg(ql_dbg_mbx
, vha
, 0x10fe, "Failed=%x.\n", rval
);
4359 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x10ff,
4360 "Done %s.\n", __func__
);
4366 qla2x00_write_ram_word(scsi_qla_host_t
*vha
, uint32_t risc_addr
, uint32_t data
)
4370 mbx_cmd_t
*mcp
= &mc
;
4372 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x1100,
4373 "Entered %s.\n", __func__
);
4375 if (!IS_FWI2_CAPABLE(vha
->hw
))
4376 return QLA_FUNCTION_FAILED
;
4378 mcp
->mb
[0] = MBC_WRITE_RAM_WORD_EXTENDED
;
4379 mcp
->mb
[1] = LSW(risc_addr
);
4380 mcp
->mb
[2] = LSW(data
);
4381 mcp
->mb
[3] = MSW(data
);
4382 mcp
->mb
[8] = MSW(risc_addr
);
4383 mcp
->out_mb
= MBX_8
|MBX_3
|MBX_2
|MBX_1
|MBX_0
;
4387 rval
= qla2x00_mailbox_command(vha
, mcp
);
4388 if (rval
!= QLA_SUCCESS
) {
4389 ql_dbg(ql_dbg_mbx
, vha
, 0x1101,
4390 "Failed=%x mb[0]=%x.\n", rval
, mcp
->mb
[0]);
4392 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x1102,
4393 "Done %s.\n", __func__
);
4400 qla81xx_write_mpi_register(scsi_qla_host_t
*vha
, uint16_t *mb
)
4403 uint32_t stat
, timer
;
4405 struct qla_hw_data
*ha
= vha
->hw
;
4406 struct device_reg_24xx __iomem
*reg
= &ha
->iobase
->isp24
;
4410 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x1103,
4411 "Entered %s.\n", __func__
);
4413 clear_bit(MBX_INTERRUPT
, &ha
->mbx_cmd_flags
);
4415 /* Write the MBC data to the registers */
4416 WRT_REG_WORD(®
->mailbox0
, MBC_WRITE_MPI_REGISTER
);
4417 WRT_REG_WORD(®
->mailbox1
, mb
[0]);
4418 WRT_REG_WORD(®
->mailbox2
, mb
[1]);
4419 WRT_REG_WORD(®
->mailbox3
, mb
[2]);
4420 WRT_REG_WORD(®
->mailbox4
, mb
[3]);
4422 WRT_REG_DWORD(®
->hccr
, HCCRX_SET_HOST_INT
);
4424 /* Poll for MBC interrupt */
4425 for (timer
= 6000000; timer
; timer
--) {
4426 /* Check for pending interrupts. */
4427 stat
= RD_REG_DWORD(®
->host_status
);
4428 if (stat
& HSRX_RISC_INT
) {
4431 if (stat
== 0x1 || stat
== 0x2 ||
4432 stat
== 0x10 || stat
== 0x11) {
4433 set_bit(MBX_INTERRUPT
,
4434 &ha
->mbx_cmd_flags
);
4435 mb0
= RD_REG_WORD(®
->mailbox0
);
4436 WRT_REG_DWORD(®
->hccr
,
4437 HCCRX_CLR_RISC_INT
);
4438 RD_REG_DWORD(®
->hccr
);
4445 if (test_and_clear_bit(MBX_INTERRUPT
, &ha
->mbx_cmd_flags
))
4446 rval
= mb0
& MBS_MASK
;
4448 rval
= QLA_FUNCTION_FAILED
;
4450 if (rval
!= QLA_SUCCESS
) {
4451 ql_dbg(ql_dbg_mbx
, vha
, 0x1104,
4452 "Failed=%x mb[0]=%x.\n", rval
, mb
[0]);
4454 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x1105,
4455 "Done %s.\n", __func__
);
4462 qla2x00_get_data_rate(scsi_qla_host_t
*vha
)
4466 mbx_cmd_t
*mcp
= &mc
;
4467 struct qla_hw_data
*ha
= vha
->hw
;
4469 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x1106,
4470 "Entered %s.\n", __func__
);
4472 if (!IS_FWI2_CAPABLE(ha
))
4473 return QLA_FUNCTION_FAILED
;
4475 mcp
->mb
[0] = MBC_DATA_RATE
;
4477 mcp
->out_mb
= MBX_1
|MBX_0
;
4478 mcp
->in_mb
= MBX_2
|MBX_1
|MBX_0
;
4480 mcp
->in_mb
|= MBX_3
;
4481 mcp
->tov
= MBX_TOV_SECONDS
;
4483 rval
= qla2x00_mailbox_command(vha
, mcp
);
4484 if (rval
!= QLA_SUCCESS
) {
4485 ql_dbg(ql_dbg_mbx
, vha
, 0x1107,
4486 "Failed=%x mb[0]=%x.\n", rval
, mcp
->mb
[0]);
4488 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x1108,
4489 "Done %s.\n", __func__
);
4490 if (mcp
->mb
[1] != 0x7)
4491 ha
->link_data_rate
= mcp
->mb
[1];
4498 qla81xx_get_port_config(scsi_qla_host_t
*vha
, uint16_t *mb
)
4502 mbx_cmd_t
*mcp
= &mc
;
4503 struct qla_hw_data
*ha
= vha
->hw
;
4505 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x1109,
4506 "Entered %s.\n", __func__
);
4508 if (!IS_QLA81XX(ha
) && !IS_QLA83XX(ha
) && !IS_QLA8044(ha
))
4509 return QLA_FUNCTION_FAILED
;
4510 mcp
->mb
[0] = MBC_GET_PORT_CONFIG
;
4511 mcp
->out_mb
= MBX_0
;
4512 mcp
->in_mb
= MBX_4
|MBX_3
|MBX_2
|MBX_1
|MBX_0
;
4513 mcp
->tov
= MBX_TOV_SECONDS
;
4516 rval
= qla2x00_mailbox_command(vha
, mcp
);
4518 if (rval
!= QLA_SUCCESS
) {
4519 ql_dbg(ql_dbg_mbx
, vha
, 0x110a,
4520 "Failed=%x mb[0]=%x.\n", rval
, mcp
->mb
[0]);
4522 /* Copy all bits to preserve original value */
4523 memcpy(mb
, &mcp
->mb
[1], sizeof(uint16_t) * 4);
4525 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x110b,
4526 "Done %s.\n", __func__
);
4532 qla81xx_set_port_config(scsi_qla_host_t
*vha
, uint16_t *mb
)
4536 mbx_cmd_t
*mcp
= &mc
;
4538 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x110c,
4539 "Entered %s.\n", __func__
);
4541 mcp
->mb
[0] = MBC_SET_PORT_CONFIG
;
4542 /* Copy all bits to preserve original setting */
4543 memcpy(&mcp
->mb
[1], mb
, sizeof(uint16_t) * 4);
4544 mcp
->out_mb
= MBX_4
|MBX_3
|MBX_2
|MBX_1
|MBX_0
;
4546 mcp
->tov
= MBX_TOV_SECONDS
;
4548 rval
= qla2x00_mailbox_command(vha
, mcp
);
4550 if (rval
!= QLA_SUCCESS
) {
4551 ql_dbg(ql_dbg_mbx
, vha
, 0x110d,
4552 "Failed=%x mb[0]=%x.\n", rval
, mcp
->mb
[0]);
4554 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x110e,
4555 "Done %s.\n", __func__
);
4562 qla24xx_set_fcp_prio(scsi_qla_host_t
*vha
, uint16_t loop_id
, uint16_t priority
,
4567 mbx_cmd_t
*mcp
= &mc
;
4568 struct qla_hw_data
*ha
= vha
->hw
;
4570 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x110f,
4571 "Entered %s.\n", __func__
);
4573 if (!IS_QLA24XX_TYPE(ha
) && !IS_QLA25XX(ha
))
4574 return QLA_FUNCTION_FAILED
;
4576 mcp
->mb
[0] = MBC_PORT_PARAMS
;
4577 mcp
->mb
[1] = loop_id
;
4578 if (ha
->flags
.fcp_prio_enabled
)
4582 mcp
->mb
[4] = priority
& 0xf;
4583 mcp
->mb
[9] = vha
->vp_idx
;
4584 mcp
->out_mb
= MBX_9
|MBX_4
|MBX_3
|MBX_2
|MBX_1
|MBX_0
;
4585 mcp
->in_mb
= MBX_4
|MBX_3
|MBX_1
|MBX_0
;
4588 rval
= qla2x00_mailbox_command(vha
, mcp
);
4596 if (rval
!= QLA_SUCCESS
) {
4597 ql_dbg(ql_dbg_mbx
, vha
, 0x10cd, "Failed=%x.\n", rval
);
4599 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x10cc,
4600 "Done %s.\n", __func__
);
4607 qla2x00_get_thermal_temp(scsi_qla_host_t
*vha
, uint16_t *temp
)
4609 int rval
= QLA_FUNCTION_FAILED
;
4610 struct qla_hw_data
*ha
= vha
->hw
;
4613 if (!IS_FWI2_CAPABLE(ha
) || IS_QLA24XX_TYPE(ha
) || IS_QLA81XX(ha
)) {
4614 ql_dbg(ql_dbg_mbx
, vha
, 0x1150,
4615 "Thermal not supported by this card.\n");
4619 if (IS_QLA25XX(ha
)) {
4620 if (ha
->pdev
->subsystem_vendor
== PCI_VENDOR_ID_QLOGIC
&&
4621 ha
->pdev
->subsystem_device
== 0x0175) {
4622 rval
= qla2x00_read_sfp(vha
, 0, &byte
,
4623 0x98, 0x1, 1, BIT_13
|BIT_0
);
4627 if (ha
->pdev
->subsystem_vendor
== PCI_VENDOR_ID_HP
&&
4628 ha
->pdev
->subsystem_device
== 0x338e) {
4629 rval
= qla2x00_read_sfp(vha
, 0, &byte
,
4630 0x98, 0x1, 1, BIT_15
|BIT_14
|BIT_0
);
4634 ql_dbg(ql_dbg_mbx
, vha
, 0x10c9,
4635 "Thermal not supported by this card.\n");
4639 if (IS_QLA82XX(ha
)) {
4640 *temp
= qla82xx_read_temperature(vha
);
4643 } else if (IS_QLA8044(ha
)) {
4644 *temp
= qla8044_read_temperature(vha
);
4649 rval
= qla2x00_read_asic_temperature(vha
, temp
);
4654 qla82xx_mbx_intr_enable(scsi_qla_host_t
*vha
)
4657 struct qla_hw_data
*ha
= vha
->hw
;
4659 mbx_cmd_t
*mcp
= &mc
;
4661 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x1017,
4662 "Entered %s.\n", __func__
);
4664 if (!IS_FWI2_CAPABLE(ha
))
4665 return QLA_FUNCTION_FAILED
;
4667 memset(mcp
, 0, sizeof(mbx_cmd_t
));
4668 mcp
->mb
[0] = MBC_TOGGLE_INTERRUPT
;
4671 mcp
->out_mb
= MBX_1
|MBX_0
;
4676 rval
= qla2x00_mailbox_command(vha
, mcp
);
4677 if (rval
!= QLA_SUCCESS
) {
4678 ql_dbg(ql_dbg_mbx
, vha
, 0x1016,
4679 "Failed=%x mb[0]=%x.\n", rval
, mcp
->mb
[0]);
4681 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x100e,
4682 "Done %s.\n", __func__
);
4689 qla82xx_mbx_intr_disable(scsi_qla_host_t
*vha
)
4692 struct qla_hw_data
*ha
= vha
->hw
;
4694 mbx_cmd_t
*mcp
= &mc
;
4696 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x100d,
4697 "Entered %s.\n", __func__
);
4699 if (!IS_P3P_TYPE(ha
))
4700 return QLA_FUNCTION_FAILED
;
4702 memset(mcp
, 0, sizeof(mbx_cmd_t
));
4703 mcp
->mb
[0] = MBC_TOGGLE_INTERRUPT
;
4706 mcp
->out_mb
= MBX_1
|MBX_0
;
4711 rval
= qla2x00_mailbox_command(vha
, mcp
);
4712 if (rval
!= QLA_SUCCESS
) {
4713 ql_dbg(ql_dbg_mbx
, vha
, 0x100c,
4714 "Failed=%x mb[0]=%x.\n", rval
, mcp
->mb
[0]);
4716 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x100b,
4717 "Done %s.\n", __func__
);
4724 qla82xx_md_get_template_size(scsi_qla_host_t
*vha
)
4726 struct qla_hw_data
*ha
= vha
->hw
;
4728 mbx_cmd_t
*mcp
= &mc
;
4729 int rval
= QLA_FUNCTION_FAILED
;
4731 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x111f,
4732 "Entered %s.\n", __func__
);
4734 memset(mcp
->mb
, 0 , sizeof(mcp
->mb
));
4735 mcp
->mb
[0] = LSW(MBC_DIAGNOSTIC_MINIDUMP_TEMPLATE
);
4736 mcp
->mb
[1] = MSW(MBC_DIAGNOSTIC_MINIDUMP_TEMPLATE
);
4737 mcp
->mb
[2] = LSW(RQST_TMPLT_SIZE
);
4738 mcp
->mb
[3] = MSW(RQST_TMPLT_SIZE
);
4740 mcp
->out_mb
= MBX_3
|MBX_2
|MBX_1
|MBX_0
;
4741 mcp
->in_mb
= MBX_14
|MBX_13
|MBX_12
|MBX_11
|MBX_10
|MBX_9
|MBX_8
|
4742 MBX_7
|MBX_6
|MBX_5
|MBX_4
|MBX_3
|MBX_2
|MBX_1
|MBX_0
;
4744 mcp
->flags
= MBX_DMA_OUT
|MBX_DMA_IN
|IOCTL_CMD
;
4745 mcp
->tov
= MBX_TOV_SECONDS
;
4746 rval
= qla2x00_mailbox_command(vha
, mcp
);
4748 /* Always copy back return mailbox values. */
4749 if (rval
!= QLA_SUCCESS
) {
4750 ql_dbg(ql_dbg_mbx
, vha
, 0x1120,
4751 "mailbox command FAILED=0x%x, subcode=%x.\n",
4752 (mcp
->mb
[1] << 16) | mcp
->mb
[0],
4753 (mcp
->mb
[3] << 16) | mcp
->mb
[2]);
4755 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x1121,
4756 "Done %s.\n", __func__
);
4757 ha
->md_template_size
= ((mcp
->mb
[3] << 16) | mcp
->mb
[2]);
4758 if (!ha
->md_template_size
) {
4759 ql_dbg(ql_dbg_mbx
, vha
, 0x1122,
4760 "Null template size obtained.\n");
4761 rval
= QLA_FUNCTION_FAILED
;
4768 qla82xx_md_get_template(scsi_qla_host_t
*vha
)
4770 struct qla_hw_data
*ha
= vha
->hw
;
4772 mbx_cmd_t
*mcp
= &mc
;
4773 int rval
= QLA_FUNCTION_FAILED
;
4775 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x1123,
4776 "Entered %s.\n", __func__
);
4778 ha
->md_tmplt_hdr
= dma_alloc_coherent(&ha
->pdev
->dev
,
4779 ha
->md_template_size
, &ha
->md_tmplt_hdr_dma
, GFP_KERNEL
);
4780 if (!ha
->md_tmplt_hdr
) {
4781 ql_log(ql_log_warn
, vha
, 0x1124,
4782 "Unable to allocate memory for Minidump template.\n");
4786 memset(mcp
->mb
, 0 , sizeof(mcp
->mb
));
4787 mcp
->mb
[0] = LSW(MBC_DIAGNOSTIC_MINIDUMP_TEMPLATE
);
4788 mcp
->mb
[1] = MSW(MBC_DIAGNOSTIC_MINIDUMP_TEMPLATE
);
4789 mcp
->mb
[2] = LSW(RQST_TMPLT
);
4790 mcp
->mb
[3] = MSW(RQST_TMPLT
);
4791 mcp
->mb
[4] = LSW(LSD(ha
->md_tmplt_hdr_dma
));
4792 mcp
->mb
[5] = MSW(LSD(ha
->md_tmplt_hdr_dma
));
4793 mcp
->mb
[6] = LSW(MSD(ha
->md_tmplt_hdr_dma
));
4794 mcp
->mb
[7] = MSW(MSD(ha
->md_tmplt_hdr_dma
));
4795 mcp
->mb
[8] = LSW(ha
->md_template_size
);
4796 mcp
->mb
[9] = MSW(ha
->md_template_size
);
4798 mcp
->flags
= MBX_DMA_OUT
|MBX_DMA_IN
|IOCTL_CMD
;
4799 mcp
->tov
= MBX_TOV_SECONDS
;
4800 mcp
->out_mb
= MBX_11
|MBX_10
|MBX_9
|MBX_8
|
4801 MBX_7
|MBX_6
|MBX_5
|MBX_4
|MBX_3
|MBX_2
|MBX_1
|MBX_0
;
4802 mcp
->in_mb
= MBX_3
|MBX_2
|MBX_1
|MBX_0
;
4803 rval
= qla2x00_mailbox_command(vha
, mcp
);
4805 if (rval
!= QLA_SUCCESS
) {
4806 ql_dbg(ql_dbg_mbx
, vha
, 0x1125,
4807 "mailbox command FAILED=0x%x, subcode=%x.\n",
4808 ((mcp
->mb
[1] << 16) | mcp
->mb
[0]),
4809 ((mcp
->mb
[3] << 16) | mcp
->mb
[2]));
4811 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x1126,
4812 "Done %s.\n", __func__
);
4817 qla8044_md_get_template(scsi_qla_host_t
*vha
)
4819 struct qla_hw_data
*ha
= vha
->hw
;
4821 mbx_cmd_t
*mcp
= &mc
;
4822 int rval
= QLA_FUNCTION_FAILED
;
4823 int offset
= 0, size
= MINIDUMP_SIZE_36K
;
4824 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0xb11f,
4825 "Entered %s.\n", __func__
);
4827 ha
->md_tmplt_hdr
= dma_alloc_coherent(&ha
->pdev
->dev
,
4828 ha
->md_template_size
, &ha
->md_tmplt_hdr_dma
, GFP_KERNEL
);
4829 if (!ha
->md_tmplt_hdr
) {
4830 ql_log(ql_log_warn
, vha
, 0xb11b,
4831 "Unable to allocate memory for Minidump template.\n");
4835 memset(mcp
->mb
, 0 , sizeof(mcp
->mb
));
4836 while (offset
< ha
->md_template_size
) {
4837 mcp
->mb
[0] = LSW(MBC_DIAGNOSTIC_MINIDUMP_TEMPLATE
);
4838 mcp
->mb
[1] = MSW(MBC_DIAGNOSTIC_MINIDUMP_TEMPLATE
);
4839 mcp
->mb
[2] = LSW(RQST_TMPLT
);
4840 mcp
->mb
[3] = MSW(RQST_TMPLT
);
4841 mcp
->mb
[4] = LSW(LSD(ha
->md_tmplt_hdr_dma
+ offset
));
4842 mcp
->mb
[5] = MSW(LSD(ha
->md_tmplt_hdr_dma
+ offset
));
4843 mcp
->mb
[6] = LSW(MSD(ha
->md_tmplt_hdr_dma
+ offset
));
4844 mcp
->mb
[7] = MSW(MSD(ha
->md_tmplt_hdr_dma
+ offset
));
4845 mcp
->mb
[8] = LSW(size
);
4846 mcp
->mb
[9] = MSW(size
);
4847 mcp
->mb
[10] = offset
& 0x0000FFFF;
4848 mcp
->mb
[11] = offset
& 0xFFFF0000;
4849 mcp
->flags
= MBX_DMA_OUT
|MBX_DMA_IN
|IOCTL_CMD
;
4850 mcp
->tov
= MBX_TOV_SECONDS
;
4851 mcp
->out_mb
= MBX_11
|MBX_10
|MBX_9
|MBX_8
|
4852 MBX_7
|MBX_6
|MBX_5
|MBX_4
|MBX_3
|MBX_2
|MBX_1
|MBX_0
;
4853 mcp
->in_mb
= MBX_3
|MBX_2
|MBX_1
|MBX_0
;
4854 rval
= qla2x00_mailbox_command(vha
, mcp
);
4856 if (rval
!= QLA_SUCCESS
) {
4857 ql_dbg(ql_dbg_mbx
, vha
, 0xb11c,
4858 "mailbox command FAILED=0x%x, subcode=%x.\n",
4859 ((mcp
->mb
[1] << 16) | mcp
->mb
[0]),
4860 ((mcp
->mb
[3] << 16) | mcp
->mb
[2]));
4863 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0xb11d,
4864 "Done %s.\n", __func__
);
4865 offset
= offset
+ size
;
4871 qla81xx_set_led_config(scsi_qla_host_t
*vha
, uint16_t *led_cfg
)
4874 struct qla_hw_data
*ha
= vha
->hw
;
4876 mbx_cmd_t
*mcp
= &mc
;
4878 if (!IS_QLA81XX(ha
) && !IS_QLA8031(ha
))
4879 return QLA_FUNCTION_FAILED
;
4881 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x1133,
4882 "Entered %s.\n", __func__
);
4884 memset(mcp
, 0, sizeof(mbx_cmd_t
));
4885 mcp
->mb
[0] = MBC_SET_LED_CONFIG
;
4886 mcp
->mb
[1] = led_cfg
[0];
4887 mcp
->mb
[2] = led_cfg
[1];
4888 if (IS_QLA8031(ha
)) {
4889 mcp
->mb
[3] = led_cfg
[2];
4890 mcp
->mb
[4] = led_cfg
[3];
4891 mcp
->mb
[5] = led_cfg
[4];
4892 mcp
->mb
[6] = led_cfg
[5];
4895 mcp
->out_mb
= MBX_2
|MBX_1
|MBX_0
;
4897 mcp
->out_mb
|= MBX_6
|MBX_5
|MBX_4
|MBX_3
;
4902 rval
= qla2x00_mailbox_command(vha
, mcp
);
4903 if (rval
!= QLA_SUCCESS
) {
4904 ql_dbg(ql_dbg_mbx
, vha
, 0x1134,
4905 "Failed=%x mb[0]=%x.\n", rval
, mcp
->mb
[0]);
4907 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x1135,
4908 "Done %s.\n", __func__
);
4915 qla81xx_get_led_config(scsi_qla_host_t
*vha
, uint16_t *led_cfg
)
4918 struct qla_hw_data
*ha
= vha
->hw
;
4920 mbx_cmd_t
*mcp
= &mc
;
4922 if (!IS_QLA81XX(ha
) && !IS_QLA8031(ha
))
4923 return QLA_FUNCTION_FAILED
;
4925 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x1136,
4926 "Entered %s.\n", __func__
);
4928 memset(mcp
, 0, sizeof(mbx_cmd_t
));
4929 mcp
->mb
[0] = MBC_GET_LED_CONFIG
;
4931 mcp
->out_mb
= MBX_0
;
4932 mcp
->in_mb
= MBX_2
|MBX_1
|MBX_0
;
4934 mcp
->in_mb
|= MBX_6
|MBX_5
|MBX_4
|MBX_3
;
4938 rval
= qla2x00_mailbox_command(vha
, mcp
);
4939 if (rval
!= QLA_SUCCESS
) {
4940 ql_dbg(ql_dbg_mbx
, vha
, 0x1137,
4941 "Failed=%x mb[0]=%x.\n", rval
, mcp
->mb
[0]);
4943 led_cfg
[0] = mcp
->mb
[1];
4944 led_cfg
[1] = mcp
->mb
[2];
4945 if (IS_QLA8031(ha
)) {
4946 led_cfg
[2] = mcp
->mb
[3];
4947 led_cfg
[3] = mcp
->mb
[4];
4948 led_cfg
[4] = mcp
->mb
[5];
4949 led_cfg
[5] = mcp
->mb
[6];
4951 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x1138,
4952 "Done %s.\n", __func__
);
4959 qla82xx_mbx_beacon_ctl(scsi_qla_host_t
*vha
, int enable
)
4962 struct qla_hw_data
*ha
= vha
->hw
;
4964 mbx_cmd_t
*mcp
= &mc
;
4966 if (!IS_P3P_TYPE(ha
))
4967 return QLA_FUNCTION_FAILED
;
4969 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x1127,
4970 "Entered %s.\n", __func__
);
4972 memset(mcp
, 0, sizeof(mbx_cmd_t
));
4973 mcp
->mb
[0] = MBC_SET_LED_CONFIG
;
4979 mcp
->out_mb
= MBX_7
|MBX_0
;
4981 mcp
->tov
= MBX_TOV_SECONDS
;
4984 rval
= qla2x00_mailbox_command(vha
, mcp
);
4985 if (rval
!= QLA_SUCCESS
) {
4986 ql_dbg(ql_dbg_mbx
, vha
, 0x1128,
4987 "Failed=%x mb[0]=%x.\n", rval
, mcp
->mb
[0]);
4989 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x1129,
4990 "Done %s.\n", __func__
);
4997 qla83xx_wr_reg(scsi_qla_host_t
*vha
, uint32_t reg
, uint32_t data
)
5000 struct qla_hw_data
*ha
= vha
->hw
;
5002 mbx_cmd_t
*mcp
= &mc
;
5004 if (!IS_QLA83XX(ha
))
5005 return QLA_FUNCTION_FAILED
;
5007 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x1130,
5008 "Entered %s.\n", __func__
);
5010 mcp
->mb
[0] = MBC_WRITE_REMOTE_REG
;
5011 mcp
->mb
[1] = LSW(reg
);
5012 mcp
->mb
[2] = MSW(reg
);
5013 mcp
->mb
[3] = LSW(data
);
5014 mcp
->mb
[4] = MSW(data
);
5015 mcp
->out_mb
= MBX_4
|MBX_3
|MBX_2
|MBX_1
|MBX_0
;
5017 mcp
->in_mb
= MBX_1
|MBX_0
;
5018 mcp
->tov
= MBX_TOV_SECONDS
;
5020 rval
= qla2x00_mailbox_command(vha
, mcp
);
5022 if (rval
!= QLA_SUCCESS
) {
5023 ql_dbg(ql_dbg_mbx
, vha
, 0x1131,
5024 "Failed=%x mb[0]=%x.\n", rval
, mcp
->mb
[0]);
5026 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x1132,
5027 "Done %s.\n", __func__
);
5034 qla2x00_port_logout(scsi_qla_host_t
*vha
, struct fc_port
*fcport
)
5037 struct qla_hw_data
*ha
= vha
->hw
;
5039 mbx_cmd_t
*mcp
= &mc
;
5041 if (IS_QLA2100(ha
) || IS_QLA2200(ha
)) {
5042 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x113b,
5043 "Implicit LOGO Unsupported.\n");
5044 return QLA_FUNCTION_FAILED
;
5048 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x113c,
5049 "Entering %s.\n", __func__
);
5051 /* Perform Implicit LOGO. */
5052 mcp
->mb
[0] = MBC_PORT_LOGOUT
;
5053 mcp
->mb
[1] = fcport
->loop_id
;
5054 mcp
->mb
[10] = BIT_15
;
5055 mcp
->out_mb
= MBX_10
|MBX_1
|MBX_0
;
5057 mcp
->tov
= MBX_TOV_SECONDS
;
5059 rval
= qla2x00_mailbox_command(vha
, mcp
);
5060 if (rval
!= QLA_SUCCESS
)
5061 ql_dbg(ql_dbg_mbx
, vha
, 0x113d,
5062 "Failed=%x mb[0]=%x.\n", rval
, mcp
->mb
[0]);
5064 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x113e,
5065 "Done %s.\n", __func__
);
5071 qla83xx_rd_reg(scsi_qla_host_t
*vha
, uint32_t reg
, uint32_t *data
)
5075 mbx_cmd_t
*mcp
= &mc
;
5076 struct qla_hw_data
*ha
= vha
->hw
;
5077 unsigned long retry_max_time
= jiffies
+ (2 * HZ
);
5079 if (!IS_QLA83XX(ha
))
5080 return QLA_FUNCTION_FAILED
;
5082 ql_dbg(ql_dbg_mbx
, vha
, 0x114b, "Entered %s.\n", __func__
);
5085 mcp
->mb
[0] = MBC_READ_REMOTE_REG
;
5086 mcp
->mb
[1] = LSW(reg
);
5087 mcp
->mb
[2] = MSW(reg
);
5088 mcp
->out_mb
= MBX_2
|MBX_1
|MBX_0
;
5089 mcp
->in_mb
= MBX_4
|MBX_3
|MBX_1
|MBX_0
;
5090 mcp
->tov
= MBX_TOV_SECONDS
;
5092 rval
= qla2x00_mailbox_command(vha
, mcp
);
5094 if (rval
!= QLA_SUCCESS
) {
5095 ql_dbg(ql_dbg_mbx
, vha
, 0x114c,
5096 "Failed=%x mb[0]=%x mb[1]=%x.\n",
5097 rval
, mcp
->mb
[0], mcp
->mb
[1]);
5099 *data
= (mcp
->mb
[3] | (mcp
->mb
[4] << 16));
5100 if (*data
== QLA8XXX_BAD_VALUE
) {
5102 * During soft-reset CAMRAM register reads might
5103 * return 0xbad0bad0. So retry for MAX of 2 sec
5104 * while reading camram registers.
5106 if (time_after(jiffies
, retry_max_time
)) {
5107 ql_dbg(ql_dbg_mbx
, vha
, 0x1141,
5108 "Failure to read CAMRAM register. "
5109 "data=0x%x.\n", *data
);
5110 return QLA_FUNCTION_FAILED
;
5115 ql_dbg(ql_dbg_mbx
, vha
, 0x1142, "Done %s.\n", __func__
);
5122 qla83xx_restart_nic_firmware(scsi_qla_host_t
*vha
)
5126 mbx_cmd_t
*mcp
= &mc
;
5127 struct qla_hw_data
*ha
= vha
->hw
;
5129 if (!IS_QLA83XX(ha
))
5130 return QLA_FUNCTION_FAILED
;
5132 ql_dbg(ql_dbg_mbx
, vha
, 0x1143, "Entered %s.\n", __func__
);
5134 mcp
->mb
[0] = MBC_RESTART_NIC_FIRMWARE
;
5135 mcp
->out_mb
= MBX_0
;
5136 mcp
->in_mb
= MBX_1
|MBX_0
;
5137 mcp
->tov
= MBX_TOV_SECONDS
;
5139 rval
= qla2x00_mailbox_command(vha
, mcp
);
5141 if (rval
!= QLA_SUCCESS
) {
5142 ql_dbg(ql_dbg_mbx
, vha
, 0x1144,
5143 "Failed=%x mb[0]=%x mb[1]=%x.\n",
5144 rval
, mcp
->mb
[0], mcp
->mb
[1]);
5145 ha
->isp_ops
->fw_dump(vha
, 0);
5147 ql_dbg(ql_dbg_mbx
, vha
, 0x1145, "Done %s.\n", __func__
);
5154 qla83xx_access_control(scsi_qla_host_t
*vha
, uint16_t options
,
5155 uint32_t start_addr
, uint32_t end_addr
, uint16_t *sector_size
)
5159 mbx_cmd_t
*mcp
= &mc
;
5160 uint8_t subcode
= (uint8_t)options
;
5161 struct qla_hw_data
*ha
= vha
->hw
;
5163 if (!IS_QLA8031(ha
))
5164 return QLA_FUNCTION_FAILED
;
5166 ql_dbg(ql_dbg_mbx
, vha
, 0x1146, "Entered %s.\n", __func__
);
5168 mcp
->mb
[0] = MBC_SET_ACCESS_CONTROL
;
5169 mcp
->mb
[1] = options
;
5170 mcp
->out_mb
= MBX_1
|MBX_0
;
5171 if (subcode
& BIT_2
) {
5172 mcp
->mb
[2] = LSW(start_addr
);
5173 mcp
->mb
[3] = MSW(start_addr
);
5174 mcp
->mb
[4] = LSW(end_addr
);
5175 mcp
->mb
[5] = MSW(end_addr
);
5176 mcp
->out_mb
|= MBX_5
|MBX_4
|MBX_3
|MBX_2
;
5178 mcp
->in_mb
= MBX_2
|MBX_1
|MBX_0
;
5179 if (!(subcode
& (BIT_2
| BIT_5
)))
5180 mcp
->in_mb
|= MBX_4
|MBX_3
;
5181 mcp
->tov
= MBX_TOV_SECONDS
;
5183 rval
= qla2x00_mailbox_command(vha
, mcp
);
5185 if (rval
!= QLA_SUCCESS
) {
5186 ql_dbg(ql_dbg_mbx
, vha
, 0x1147,
5187 "Failed=%x mb[0]=%x mb[1]=%x mb[2]=%x mb[3]=%x mb[4]=%x.\n",
5188 rval
, mcp
->mb
[0], mcp
->mb
[1], mcp
->mb
[2], mcp
->mb
[3],
5190 ha
->isp_ops
->fw_dump(vha
, 0);
5192 if (subcode
& BIT_5
)
5193 *sector_size
= mcp
->mb
[1];
5194 else if (subcode
& (BIT_6
| BIT_7
)) {
5195 ql_dbg(ql_dbg_mbx
, vha
, 0x1148,
5196 "Driver-lock id=%x%x", mcp
->mb
[4], mcp
->mb
[3]);
5197 } else if (subcode
& (BIT_3
| BIT_4
)) {
5198 ql_dbg(ql_dbg_mbx
, vha
, 0x1149,
5199 "Flash-lock id=%x%x", mcp
->mb
[4], mcp
->mb
[3]);
5201 ql_dbg(ql_dbg_mbx
, vha
, 0x114a, "Done %s.\n", __func__
);
5208 qla2x00_dump_mctp_data(scsi_qla_host_t
*vha
, dma_addr_t req_dma
, uint32_t addr
,
5213 mbx_cmd_t
*mcp
= &mc
;
5215 if (!IS_MCTP_CAPABLE(vha
->hw
))
5216 return QLA_FUNCTION_FAILED
;
5218 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x114f,
5219 "Entered %s.\n", __func__
);
5221 mcp
->mb
[0] = MBC_DUMP_RISC_RAM_EXTENDED
;
5222 mcp
->mb
[1] = LSW(addr
);
5223 mcp
->mb
[2] = MSW(req_dma
);
5224 mcp
->mb
[3] = LSW(req_dma
);
5225 mcp
->mb
[4] = MSW(size
);
5226 mcp
->mb
[5] = LSW(size
);
5227 mcp
->mb
[6] = MSW(MSD(req_dma
));
5228 mcp
->mb
[7] = LSW(MSD(req_dma
));
5229 mcp
->mb
[8] = MSW(addr
);
5230 /* Setting RAM ID to valid */
5231 mcp
->mb
[10] |= BIT_7
;
5232 /* For MCTP RAM ID is 0x40 */
5233 mcp
->mb
[10] |= 0x40;
5235 mcp
->out_mb
|= MBX_10
|MBX_8
|MBX_7
|MBX_6
|MBX_5
|MBX_4
|MBX_3
|MBX_2
|MBX_1
|
5239 mcp
->tov
= MBX_TOV_SECONDS
;
5241 rval
= qla2x00_mailbox_command(vha
, mcp
);
5243 if (rval
!= QLA_SUCCESS
) {
5244 ql_dbg(ql_dbg_mbx
, vha
, 0x114e,
5245 "Failed=%x mb[0]=%x.\n", rval
, mcp
->mb
[0]);
5247 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x114d,
5248 "Done %s.\n", __func__
);