1 // SPDX-License-Identifier: GPL-2.0-only
3 * QLogic Fibre Channel HBA Driver
4 * Copyright (c) 2003-2014 QLogic Corporation
7 #include "qla_target.h"
9 #include <linux/delay.h>
10 #include <linux/gfp.h>
13 #define IS_PPCARCH true
15 #define IS_PPCARCH false
18 static struct mb_cmd_name
{
22 {MBC_GET_PORT_DATABASE
, "GPDB"},
23 {MBC_GET_ID_LIST
, "GIDList"},
24 {MBC_GET_LINK_PRIV_STATS
, "Stats"},
25 {MBC_GET_RESOURCE_COUNTS
, "ResCnt"},
28 static const char *mb_to_str(uint16_t cmd
)
31 struct mb_cmd_name
*e
;
33 for (i
= 0; i
< ARRAY_SIZE(mb_str
); i
++) {
41 static struct rom_cmd
{
45 { MBC_EXECUTE_FIRMWARE
},
46 { MBC_READ_RAM_WORD
},
47 { MBC_MAILBOX_REGISTER_TEST
},
48 { MBC_VERIFY_CHECKSUM
},
49 { MBC_GET_FIRMWARE_VERSION
},
50 { MBC_LOAD_RISC_RAM
},
51 { MBC_DUMP_RISC_RAM
},
52 { MBC_LOAD_RISC_RAM_EXTENDED
},
53 { MBC_DUMP_RISC_RAM_EXTENDED
},
54 { MBC_WRITE_RAM_WORD_EXTENDED
},
55 { MBC_READ_RAM_EXTENDED
},
56 { MBC_GET_RESOURCE_COUNTS
},
57 { MBC_SET_FIRMWARE_OPTION
},
58 { MBC_MID_INITIALIZE_FIRMWARE
},
59 { MBC_GET_FIRMWARE_STATE
},
60 { MBC_GET_MEM_OFFLOAD_CNTRL_STAT
},
61 { MBC_GET_RETRY_COUNT
},
62 { MBC_TRACE_CONTROL
},
63 { MBC_INITIALIZE_MULTIQ
},
64 { MBC_IOCB_COMMAND_A64
},
65 { MBC_GET_ADAPTER_LOOP_ID
},
67 { MBC_SET_RNID_PARAMS
},
68 { MBC_GET_RNID_PARAMS
},
69 { MBC_GET_SET_ZIO_THRESHOLD
},
72 static int is_rom_cmd(uint16_t cmd
)
77 for (i
= 0; i
< ARRAY_SIZE(rom_cmds
); i
++) {
87 * qla2x00_mailbox_command
88 * Issue mailbox command and waits for completion.
91 * ha = adapter block pointer.
92 * mcp = driver internal mbx struct pointer.
95 * mb[MAX_MAILBOX_REGISTER_COUNT] = returned mailbox data.
98 * 0 : QLA_SUCCESS = cmd performed success
99 * 1 : QLA_FUNCTION_FAILED (error encountered)
100 * 6 : QLA_FUNCTION_TIMEOUT (timeout condition encountered)
106 qla2x00_mailbox_command(scsi_qla_host_t
*vha
, mbx_cmd_t
*mcp
)
109 unsigned long flags
= 0;
111 uint8_t abort_active
, eeh_delay
;
113 uint16_t command
= 0;
115 __le16 __iomem
*optr
;
118 unsigned long wait_time
;
119 struct qla_hw_data
*ha
= vha
->hw
;
120 scsi_qla_host_t
*base_vha
= pci_get_drvdata(ha
->pdev
);
124 ql_dbg(ql_dbg_mbx
, vha
, 0x1000, "Entered %s.\n", __func__
);
126 if (ha
->pdev
->error_state
== pci_channel_io_perm_failure
) {
127 ql_log(ql_log_warn
, vha
, 0x1001,
128 "PCI channel failed permanently, exiting.\n");
129 return QLA_FUNCTION_TIMEOUT
;
132 if (vha
->device_flags
& DFLG_DEV_FAILED
) {
133 ql_log(ql_log_warn
, vha
, 0x1002,
134 "Device in failed state, exiting.\n");
135 return QLA_FUNCTION_TIMEOUT
;
138 /* if PCI error, then avoid mbx processing.*/
139 if (test_bit(PFLG_DISCONNECTED
, &base_vha
->dpc_flags
) &&
140 test_bit(UNLOADING
, &base_vha
->dpc_flags
)) {
141 ql_log(ql_log_warn
, vha
, 0xd04e,
142 "PCI error, exiting.\n");
143 return QLA_FUNCTION_TIMEOUT
;
147 io_lock_on
= base_vha
->flags
.init_done
;
150 abort_active
= test_bit(ABORT_ISP_ACTIVE
, &base_vha
->dpc_flags
);
151 chip_reset
= ha
->chip_reset
;
153 if (ha
->flags
.pci_channel_io_perm_failure
) {
154 ql_log(ql_log_warn
, vha
, 0x1003,
155 "Perm failure on EEH timeout MBX, exiting.\n");
156 return QLA_FUNCTION_TIMEOUT
;
159 if (IS_P3P_TYPE(ha
) && ha
->flags
.isp82xx_fw_hung
) {
160 /* Setting Link-Down error */
161 mcp
->mb
[0] = MBS_LINK_DOWN_ERROR
;
162 ql_log(ql_log_warn
, vha
, 0x1004,
163 "FW hung = %d.\n", ha
->flags
.isp82xx_fw_hung
);
164 return QLA_FUNCTION_TIMEOUT
;
167 /* check if ISP abort is active and return cmd with timeout */
168 if (((test_bit(ABORT_ISP_ACTIVE
, &base_vha
->dpc_flags
) ||
169 test_bit(ISP_ABORT_RETRY
, &base_vha
->dpc_flags
) ||
170 test_bit(ISP_ABORT_NEEDED
, &base_vha
->dpc_flags
)) &&
171 !is_rom_cmd(mcp
->mb
[0])) || ha
->flags
.eeh_busy
) {
172 ql_log(ql_log_info
, vha
, 0x1005,
173 "Cmd 0x%x aborted with timeout since ISP Abort is pending\n",
175 return QLA_FUNCTION_TIMEOUT
;
178 atomic_inc(&ha
->num_pend_mbx_stage1
);
180 * Wait for active mailbox commands to finish by waiting at most tov
181 * seconds. This is to serialize actual issuing of mailbox cmds during
182 * non ISP abort time.
184 if (!wait_for_completion_timeout(&ha
->mbx_cmd_comp
, mcp
->tov
* HZ
)) {
185 /* Timeout occurred. Return error. */
186 ql_log(ql_log_warn
, vha
, 0xd035,
187 "Cmd access timeout, cmd=0x%x, Exiting.\n",
190 atomic_dec(&ha
->num_pend_mbx_stage1
);
191 return QLA_FUNCTION_TIMEOUT
;
193 atomic_dec(&ha
->num_pend_mbx_stage1
);
194 if (ha
->flags
.purge_mbox
|| chip_reset
!= ha
->chip_reset
||
195 ha
->flags
.eeh_busy
) {
196 ql_log(ql_log_warn
, vha
, 0xd035,
197 "Purge mbox: purge[%d] eeh[%d] cmd=0x%x, Exiting.\n",
198 ha
->flags
.purge_mbox
, ha
->flags
.eeh_busy
, mcp
->mb
[0]);
204 /* Save mailbox command for debug */
207 ql_dbg(ql_dbg_mbx
, vha
, 0x1006,
208 "Prepare to issue mbox cmd=0x%x.\n", mcp
->mb
[0]);
210 spin_lock_irqsave(&ha
->hardware_lock
, flags
);
212 if (ha
->flags
.purge_mbox
|| chip_reset
!= ha
->chip_reset
||
213 ha
->flags
.mbox_busy
) {
215 spin_unlock_irqrestore(&ha
->hardware_lock
, flags
);
218 ha
->flags
.mbox_busy
= 1;
220 /* Load mailbox registers. */
222 optr
= ®
->isp82
.mailbox_in
[0];
223 else if (IS_FWI2_CAPABLE(ha
) && !(IS_P3P_TYPE(ha
)))
224 optr
= ®
->isp24
.mailbox0
;
226 optr
= MAILBOX_REG(ha
, ®
->isp
, 0);
229 command
= mcp
->mb
[0];
230 mboxes
= mcp
->out_mb
;
232 ql_dbg(ql_dbg_mbx
, vha
, 0x1111,
233 "Mailbox registers (OUT):\n");
234 for (cnt
= 0; cnt
< ha
->mbx_count
; cnt
++) {
235 if (IS_QLA2200(ha
) && cnt
== 8)
236 optr
= MAILBOX_REG(ha
, ®
->isp
, 8);
237 if (mboxes
& BIT_0
) {
238 ql_dbg(ql_dbg_mbx
, vha
, 0x1112,
239 "mbox[%d]<-0x%04x\n", cnt
, *iptr
);
240 wrt_reg_word(optr
, *iptr
);
242 wrt_reg_word(optr
, 0);
250 ql_dbg(ql_dbg_mbx
+ ql_dbg_buffer
, vha
, 0x1117,
251 "I/O Address = %p.\n", optr
);
253 /* Issue set host interrupt command to send cmd out. */
254 ha
->flags
.mbox_int
= 0;
255 clear_bit(MBX_INTERRUPT
, &ha
->mbx_cmd_flags
);
257 /* Unlock mbx registers and wait for interrupt */
258 ql_dbg(ql_dbg_mbx
, vha
, 0x100f,
259 "Going to unlock irq & waiting for interrupts. "
260 "jiffies=%lx.\n", jiffies
);
262 /* Wait for mbx cmd completion until timeout */
263 atomic_inc(&ha
->num_pend_mbx_stage2
);
264 if ((!abort_active
&& io_lock_on
) || IS_NOPOLLING_TYPE(ha
)) {
265 set_bit(MBX_INTR_WAIT
, &ha
->mbx_cmd_flags
);
268 wrt_reg_dword(®
->isp82
.hint
, HINT_MBX_INT_PENDING
);
269 else if (IS_FWI2_CAPABLE(ha
))
270 wrt_reg_dword(®
->isp24
.hccr
, HCCRX_SET_HOST_INT
);
272 wrt_reg_word(®
->isp
.hccr
, HCCR_SET_HOST_INT
);
273 spin_unlock_irqrestore(&ha
->hardware_lock
, flags
);
276 if (!wait_for_completion_timeout(&ha
->mbx_intr_comp
,
278 ql_dbg(ql_dbg_mbx
, vha
, 0x117a,
279 "cmd=%x Timeout.\n", command
);
280 spin_lock_irqsave(&ha
->hardware_lock
, flags
);
281 clear_bit(MBX_INTR_WAIT
, &ha
->mbx_cmd_flags
);
282 spin_unlock_irqrestore(&ha
->hardware_lock
, flags
);
284 if (chip_reset
!= ha
->chip_reset
) {
285 eeh_delay
= ha
->flags
.eeh_busy
? 1 : 0;
287 spin_lock_irqsave(&ha
->hardware_lock
, flags
);
288 ha
->flags
.mbox_busy
= 0;
289 spin_unlock_irqrestore(&ha
->hardware_lock
,
291 atomic_dec(&ha
->num_pend_mbx_stage2
);
295 } else if (ha
->flags
.purge_mbox
||
296 chip_reset
!= ha
->chip_reset
) {
297 eeh_delay
= ha
->flags
.eeh_busy
? 1 : 0;
299 spin_lock_irqsave(&ha
->hardware_lock
, flags
);
300 ha
->flags
.mbox_busy
= 0;
301 spin_unlock_irqrestore(&ha
->hardware_lock
, flags
);
302 atomic_dec(&ha
->num_pend_mbx_stage2
);
307 if (time_after(jiffies
, wait_time
+ 5 * HZ
))
308 ql_log(ql_log_warn
, vha
, 0x1015, "cmd=0x%x, waited %d msecs\n",
309 command
, jiffies_to_msecs(jiffies
- wait_time
));
311 ql_dbg(ql_dbg_mbx
, vha
, 0x1011,
312 "Cmd=%x Polling Mode.\n", command
);
314 if (IS_P3P_TYPE(ha
)) {
315 if (rd_reg_dword(®
->isp82
.hint
) &
316 HINT_MBX_INT_PENDING
) {
317 ha
->flags
.mbox_busy
= 0;
318 spin_unlock_irqrestore(&ha
->hardware_lock
,
320 atomic_dec(&ha
->num_pend_mbx_stage2
);
321 ql_dbg(ql_dbg_mbx
, vha
, 0x1012,
322 "Pending mailbox timeout, exiting.\n");
324 rval
= QLA_FUNCTION_TIMEOUT
;
327 wrt_reg_dword(®
->isp82
.hint
, HINT_MBX_INT_PENDING
);
328 } else if (IS_FWI2_CAPABLE(ha
))
329 wrt_reg_dword(®
->isp24
.hccr
, HCCRX_SET_HOST_INT
);
331 wrt_reg_word(®
->isp
.hccr
, HCCR_SET_HOST_INT
);
332 spin_unlock_irqrestore(&ha
->hardware_lock
, flags
);
334 wait_time
= jiffies
+ mcp
->tov
* HZ
; /* wait at most tov secs */
335 while (!ha
->flags
.mbox_int
) {
336 if (ha
->flags
.purge_mbox
||
337 chip_reset
!= ha
->chip_reset
) {
338 eeh_delay
= ha
->flags
.eeh_busy
? 1 : 0;
340 spin_lock_irqsave(&ha
->hardware_lock
, flags
);
341 ha
->flags
.mbox_busy
= 0;
342 spin_unlock_irqrestore(&ha
->hardware_lock
,
344 atomic_dec(&ha
->num_pend_mbx_stage2
);
349 if (time_after(jiffies
, wait_time
))
352 /* Check for pending interrupts. */
353 qla2x00_poll(ha
->rsp_q_map
[0]);
355 if (!ha
->flags
.mbox_int
&&
357 command
== MBC_LOAD_RISC_RAM_EXTENDED
))
360 ql_dbg(ql_dbg_mbx
, vha
, 0x1013,
362 (uint
)((jiffies
- (wait_time
- (mcp
->tov
* HZ
)))/HZ
));
364 atomic_dec(&ha
->num_pend_mbx_stage2
);
366 /* Check whether we timed out */
367 if (ha
->flags
.mbox_int
) {
370 ql_dbg(ql_dbg_mbx
, vha
, 0x1014,
371 "Cmd=%x completed.\n", command
);
373 /* Got interrupt. Clear the flag. */
374 ha
->flags
.mbox_int
= 0;
375 clear_bit(MBX_INTERRUPT
, &ha
->mbx_cmd_flags
);
377 if (IS_P3P_TYPE(ha
) && ha
->flags
.isp82xx_fw_hung
) {
378 spin_lock_irqsave(&ha
->hardware_lock
, flags
);
379 ha
->flags
.mbox_busy
= 0;
380 spin_unlock_irqrestore(&ha
->hardware_lock
, flags
);
382 /* Setting Link-Down error */
383 mcp
->mb
[0] = MBS_LINK_DOWN_ERROR
;
385 rval
= QLA_FUNCTION_FAILED
;
386 ql_log(ql_log_warn
, vha
, 0xd048,
387 "FW hung = %d.\n", ha
->flags
.isp82xx_fw_hung
);
391 if (ha
->mailbox_out
[0] != MBS_COMMAND_COMPLETE
) {
392 ql_dbg(ql_dbg_mbx
, vha
, 0x11ff,
393 "mb_out[0] = %#x <> %#x\n", ha
->mailbox_out
[0],
394 MBS_COMMAND_COMPLETE
);
395 rval
= QLA_FUNCTION_FAILED
;
398 /* Load return mailbox registers. */
400 iptr
= (uint16_t *)&ha
->mailbox_out
[0];
403 ql_dbg(ql_dbg_mbx
, vha
, 0x1113,
404 "Mailbox registers (IN):\n");
405 for (cnt
= 0; cnt
< ha
->mbx_count
; cnt
++) {
406 if (mboxes
& BIT_0
) {
408 ql_dbg(ql_dbg_mbx
, vha
, 0x1114,
409 "mbox[%d]->0x%04x\n", cnt
, *iptr2
);
419 uint32_t ictrl
, host_status
, hccr
;
422 if (IS_FWI2_CAPABLE(ha
)) {
423 mb
[0] = rd_reg_word(®
->isp24
.mailbox0
);
424 mb
[1] = rd_reg_word(®
->isp24
.mailbox1
);
425 mb
[2] = rd_reg_word(®
->isp24
.mailbox2
);
426 mb
[3] = rd_reg_word(®
->isp24
.mailbox3
);
427 mb
[7] = rd_reg_word(®
->isp24
.mailbox7
);
428 ictrl
= rd_reg_dword(®
->isp24
.ictrl
);
429 host_status
= rd_reg_dword(®
->isp24
.host_status
);
430 hccr
= rd_reg_dword(®
->isp24
.hccr
);
432 ql_log(ql_log_warn
, vha
, 0xd04c,
433 "MBX Command timeout for cmd %x, iocontrol=%x jiffies=%lx "
434 "mb[0-3]=[0x%x 0x%x 0x%x 0x%x] mb7 0x%x host_status 0x%x hccr 0x%x\n",
435 command
, ictrl
, jiffies
, mb
[0], mb
[1], mb
[2], mb
[3],
436 mb
[7], host_status
, hccr
);
440 mb
[0] = RD_MAILBOX_REG(ha
, ®
->isp
, 0);
441 ictrl
= rd_reg_word(®
->isp
.ictrl
);
442 ql_dbg(ql_dbg_mbx
+ ql_dbg_buffer
, vha
, 0x1119,
443 "MBX Command timeout for cmd %x, iocontrol=%x jiffies=%lx "
444 "mb[0]=0x%x\n", command
, ictrl
, jiffies
, mb
[0]);
447 ql_dump_regs(ql_dbg_mbx
+ ql_dbg_buffer
, vha
, 0x1019);
449 /* Capture FW dump only, if PCI device active */
450 if (!pci_channel_offline(vha
->hw
->pdev
)) {
451 pci_read_config_word(ha
->pdev
, PCI_VENDOR_ID
, &w
);
452 if (w
== 0xffff || ictrl
== 0xffffffff ||
453 (chip_reset
!= ha
->chip_reset
)) {
454 /* This is special case if there is unload
455 * of driver happening and if PCI device go
456 * into bad state due to PCI error condition
457 * then only PCI ERR flag would be set.
458 * we will do premature exit for above case.
460 spin_lock_irqsave(&ha
->hardware_lock
, flags
);
461 ha
->flags
.mbox_busy
= 0;
462 spin_unlock_irqrestore(&ha
->hardware_lock
,
464 rval
= QLA_FUNCTION_TIMEOUT
;
468 /* Attempt to capture firmware dump for further
469 * anallysis of the current formware state. we do not
470 * need to do this if we are intentionally generating
473 if (mcp
->mb
[0] != MBC_GEN_SYSTEM_ERROR
)
474 qla2xxx_dump_fw(vha
);
475 rval
= QLA_FUNCTION_TIMEOUT
;
478 spin_lock_irqsave(&ha
->hardware_lock
, flags
);
479 ha
->flags
.mbox_busy
= 0;
480 spin_unlock_irqrestore(&ha
->hardware_lock
, flags
);
485 if ((abort_active
|| !io_lock_on
) && !IS_NOPOLLING_TYPE(ha
)) {
486 ql_dbg(ql_dbg_mbx
, vha
, 0x101a,
487 "Checking for additional resp interrupt.\n");
489 /* polling mode for non isp_abort commands. */
490 qla2x00_poll(ha
->rsp_q_map
[0]);
493 if (rval
== QLA_FUNCTION_TIMEOUT
&&
494 mcp
->mb
[0] != MBC_GEN_SYSTEM_ERROR
) {
495 if (!io_lock_on
|| (mcp
->flags
& IOCTL_CMD
) ||
496 ha
->flags
.eeh_busy
) {
497 /* not in dpc. schedule it for dpc to take over. */
498 ql_dbg(ql_dbg_mbx
, vha
, 0x101b,
499 "Timeout, schedule isp_abort_needed.\n");
501 if (!test_bit(ISP_ABORT_NEEDED
, &vha
->dpc_flags
) &&
502 !test_bit(ABORT_ISP_ACTIVE
, &vha
->dpc_flags
) &&
503 !test_bit(ISP_ABORT_RETRY
, &vha
->dpc_flags
)) {
504 if (IS_QLA82XX(ha
)) {
505 ql_dbg(ql_dbg_mbx
, vha
, 0x112a,
506 "disabling pause transmit on port "
509 QLA82XX_CRB_NIU
+ 0x98,
510 CRB_NIU_XG_PAUSE_CTL_P0
|
511 CRB_NIU_XG_PAUSE_CTL_P1
);
513 ql_log(ql_log_info
, base_vha
, 0x101c,
514 "Mailbox cmd timeout occurred, cmd=0x%x, "
515 "mb[0]=0x%x, eeh_busy=0x%x. Scheduling ISP "
516 "abort.\n", command
, mcp
->mb
[0],
519 set_bit(ISP_ABORT_NEEDED
, &vha
->dpc_flags
);
520 qla2xxx_wake_dpc(vha
);
522 } else if (current
== ha
->dpc_thread
) {
523 /* call abort directly since we are in the DPC thread */
524 ql_dbg(ql_dbg_mbx
, vha
, 0x101d,
525 "Timeout, calling abort_isp.\n");
527 if (!test_bit(ISP_ABORT_NEEDED
, &vha
->dpc_flags
) &&
528 !test_bit(ABORT_ISP_ACTIVE
, &vha
->dpc_flags
) &&
529 !test_bit(ISP_ABORT_RETRY
, &vha
->dpc_flags
)) {
530 if (IS_QLA82XX(ha
)) {
531 ql_dbg(ql_dbg_mbx
, vha
, 0x112b,
532 "disabling pause transmit on port "
535 QLA82XX_CRB_NIU
+ 0x98,
536 CRB_NIU_XG_PAUSE_CTL_P0
|
537 CRB_NIU_XG_PAUSE_CTL_P1
);
539 ql_log(ql_log_info
, base_vha
, 0x101e,
540 "Mailbox cmd timeout occurred, cmd=0x%x, "
541 "mb[0]=0x%x. Scheduling ISP abort ",
542 command
, mcp
->mb
[0]);
544 set_bit(ABORT_ISP_ACTIVE
, &vha
->dpc_flags
);
545 clear_bit(ISP_ABORT_NEEDED
, &vha
->dpc_flags
);
546 /* Allow next mbx cmd to come in. */
547 complete(&ha
->mbx_cmd_comp
);
548 if (ha
->isp_ops
->abort_isp(vha
) &&
549 !ha
->flags
.eeh_busy
) {
550 /* Failed. retry later. */
551 set_bit(ISP_ABORT_NEEDED
,
554 clear_bit(ABORT_ISP_ACTIVE
, &vha
->dpc_flags
);
555 ql_dbg(ql_dbg_mbx
, vha
, 0x101f,
556 "Finished abort_isp.\n");
563 /* Allow next mbx cmd to come in. */
564 complete(&ha
->mbx_cmd_comp
);
567 if (rval
== QLA_ABORTED
) {
568 ql_log(ql_log_info
, vha
, 0xd035,
569 "Chip Reset in progress. Purging Mbox cmd=0x%x.\n",
572 if (ql2xextended_error_logging
& (ql_dbg_disc
|ql_dbg_mbx
)) {
573 pr_warn("%s [%s]-%04x:%ld: **** Failed=%x", QL_MSGHDR
,
574 dev_name(&ha
->pdev
->dev
), 0x1020+0x800,
578 for (i
= 0; i
< ha
->mbx_count
&& cnt
; i
++, mboxes
>>= 1)
579 if (mboxes
& BIT_0
) {
580 printk(" mb[%u]=%x", i
, mcp
->mb
[i
]);
583 pr_warn(" cmd=%x ****\n", command
);
585 if (IS_FWI2_CAPABLE(ha
) && !(IS_P3P_TYPE(ha
))) {
586 ql_dbg(ql_dbg_mbx
, vha
, 0x1198,
587 "host_status=%#x intr_ctrl=%#x intr_status=%#x\n",
588 rd_reg_dword(®
->isp24
.host_status
),
589 rd_reg_dword(®
->isp24
.ictrl
),
590 rd_reg_dword(®
->isp24
.istatus
));
592 ql_dbg(ql_dbg_mbx
, vha
, 0x1206,
593 "ctrl_status=%#x ictrl=%#x istatus=%#x\n",
594 rd_reg_word(®
->isp
.ctrl_status
),
595 rd_reg_word(®
->isp
.ictrl
),
596 rd_reg_word(®
->isp
.istatus
));
599 ql_dbg(ql_dbg_mbx
, base_vha
, 0x1021, "Done %s.\n", __func__
);
603 while (i
&& eeh_delay
&& (ha
->pci_error_state
< QLA_PCI_SLOT_RESET
)) {
605 * The caller of this mailbox encounter pci error.
606 * Hold the thread until PCIE link reset complete to make
607 * sure caller does not unmap dma while recovery is
617 qla2x00_load_ram(scsi_qla_host_t
*vha
, dma_addr_t req_dma
, uint32_t risc_addr
,
618 uint32_t risc_code_size
)
621 struct qla_hw_data
*ha
= vha
->hw
;
623 mbx_cmd_t
*mcp
= &mc
;
625 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x1022,
626 "Entered %s.\n", __func__
);
628 if (MSW(risc_addr
) || IS_FWI2_CAPABLE(ha
)) {
629 mcp
->mb
[0] = MBC_LOAD_RISC_RAM_EXTENDED
;
630 mcp
->mb
[8] = MSW(risc_addr
);
631 mcp
->out_mb
= MBX_8
|MBX_0
;
633 mcp
->mb
[0] = MBC_LOAD_RISC_RAM
;
636 mcp
->mb
[1] = LSW(risc_addr
);
637 mcp
->mb
[2] = MSW(req_dma
);
638 mcp
->mb
[3] = LSW(req_dma
);
639 mcp
->mb
[6] = MSW(MSD(req_dma
));
640 mcp
->mb
[7] = LSW(MSD(req_dma
));
641 mcp
->out_mb
|= MBX_7
|MBX_6
|MBX_3
|MBX_2
|MBX_1
;
642 if (IS_FWI2_CAPABLE(ha
)) {
643 mcp
->mb
[4] = MSW(risc_code_size
);
644 mcp
->mb
[5] = LSW(risc_code_size
);
645 mcp
->out_mb
|= MBX_5
|MBX_4
;
647 mcp
->mb
[4] = LSW(risc_code_size
);
648 mcp
->out_mb
|= MBX_4
;
651 mcp
->in_mb
= MBX_1
|MBX_0
;
652 mcp
->tov
= MBX_TOV_SECONDS
;
654 rval
= qla2x00_mailbox_command(vha
, mcp
);
656 if (rval
!= QLA_SUCCESS
) {
657 ql_dbg(ql_dbg_mbx
, vha
, 0x1023,
658 "Failed=%x mb[0]=%x mb[1]=%x.\n",
659 rval
, mcp
->mb
[0], mcp
->mb
[1]);
662 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x1024,
663 "Done %s.\n", __func__
);
669 #define NVME_ENABLE_FLAG BIT_3
670 #define EDIF_HW_SUPPORT BIT_10
674 * Start adapter firmware.
677 * ha = adapter block pointer.
678 * TARGET_QUEUE_LOCK must be released.
679 * ADAPTER_STATE_LOCK must be released.
682 * qla2x00 local function return status code.
688 qla2x00_execute_fw(scsi_qla_host_t
*vha
, uint32_t risc_addr
)
691 struct qla_hw_data
*ha
= vha
->hw
;
693 mbx_cmd_t
*mcp
= &mc
;
695 #define EXE_FW_FORCE_SEMAPHORE BIT_7
698 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x1025,
699 "Entered %s.\n", __func__
);
702 mcp
->mb
[0] = MBC_EXECUTE_FIRMWARE
;
705 if (IS_FWI2_CAPABLE(ha
)) {
706 mcp
->mb
[1] = MSW(risc_addr
);
707 mcp
->mb
[2] = LSW(risc_addr
);
713 if (ha
->flags
.lr_detected
) {
715 if (IS_BPM_RANGE_CAPABLE(ha
))
717 ha
->lr_distance
<< LR_DIST_FW_POS
;
720 if (ql2xnvmeenable
&& (IS_QLA27XX(ha
) || IS_QLA28XX(ha
)))
721 mcp
->mb
[4] |= NVME_ENABLE_FLAG
;
723 if (IS_QLA83XX(ha
) || IS_QLA27XX(ha
) || IS_QLA28XX(ha
)) {
724 struct nvram_81xx
*nv
= ha
->nvram
;
725 /* set minimum speed if specified in nvram */
726 if (nv
->min_supported_speed
>= 2 &&
727 nv
->min_supported_speed
<= 5) {
729 mcp
->mb
[11] |= nv
->min_supported_speed
& 0xF;
730 mcp
->out_mb
|= MBX_11
;
732 vha
->min_supported_speed
=
733 nv
->min_supported_speed
;
737 mcp
->mb
[11] |= BIT_4
;
740 if (ha
->flags
.exlogins_enabled
)
741 mcp
->mb
[4] |= ENABLE_EXTENDED_LOGIN
;
743 if (ha
->flags
.exchoffld_enabled
)
744 mcp
->mb
[4] |= ENABLE_EXCHANGE_OFFLD
;
747 mcp
->mb
[11] |= EXE_FW_FORCE_SEMAPHORE
;
749 mcp
->out_mb
|= MBX_4
| MBX_3
| MBX_2
| MBX_1
| MBX_11
;
750 mcp
->in_mb
|= MBX_5
| MBX_3
| MBX_2
| MBX_1
;
752 mcp
->mb
[1] = LSW(risc_addr
);
753 mcp
->out_mb
|= MBX_1
;
754 if (IS_QLA2322(ha
) || IS_QLA6322(ha
)) {
756 mcp
->out_mb
|= MBX_2
;
760 mcp
->tov
= MBX_TOV_SECONDS
;
762 rval
= qla2x00_mailbox_command(vha
, mcp
);
764 if (rval
!= QLA_SUCCESS
) {
765 if (IS_QLA28XX(ha
) && rval
== QLA_COMMAND_ERROR
&&
766 mcp
->mb
[1] == 0x27 && retry
) {
769 ql_dbg(ql_dbg_async
, vha
, 0x1026,
770 "Exe FW: force semaphore.\n");
776 ql_dbg(ql_dbg_async
, vha
, 0x509d,
777 "Exe FW retry: mb[0]=%x retry[%d]\n", mcp
->mb
[0], retry
);
780 ql_dbg(ql_dbg_mbx
, vha
, 0x1026,
781 "Failed=%x mb[0]=%x.\n", rval
, mcp
->mb
[0]);
786 if (!IS_FWI2_CAPABLE(ha
))
789 ha
->fw_ability_mask
= mcp
->mb
[3] << 16 | mcp
->mb
[2];
790 ql_dbg(ql_dbg_mbx
, vha
, 0x119a,
791 "fw_ability_mask=%x.\n", ha
->fw_ability_mask
);
792 ql_dbg(ql_dbg_mbx
, vha
, 0x1027, "exchanges=%x.\n", mcp
->mb
[1]);
793 if (IS_QLA27XX(ha
) || IS_QLA28XX(ha
)) {
794 ha
->max_supported_speed
= mcp
->mb
[2] & (BIT_0
|BIT_1
);
795 ql_dbg(ql_dbg_mbx
, vha
, 0x119b, "max_supported_speed=%s.\n",
796 ha
->max_supported_speed
== 0 ? "16Gps" :
797 ha
->max_supported_speed
== 1 ? "32Gps" :
798 ha
->max_supported_speed
== 2 ? "64Gps" : "unknown");
799 if (vha
->min_supported_speed
) {
800 ha
->min_supported_speed
= mcp
->mb
[5] &
801 (BIT_0
| BIT_1
| BIT_2
);
802 ql_dbg(ql_dbg_mbx
, vha
, 0x119c,
803 "min_supported_speed=%s.\n",
804 ha
->min_supported_speed
== 6 ? "64Gps" :
805 ha
->min_supported_speed
== 5 ? "32Gps" :
806 ha
->min_supported_speed
== 4 ? "16Gps" :
807 ha
->min_supported_speed
== 3 ? "8Gps" :
808 ha
->min_supported_speed
== 2 ? "4Gps" : "unknown");
812 if (IS_QLA28XX(ha
) && (mcp
->mb
[5] & EDIF_HW_SUPPORT
)) {
813 ha
->flags
.edif_hw
= 1;
814 ql_log(ql_log_info
, vha
, 0xffff,
815 "%s: edif HW\n", __func__
);
819 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x1028,
820 "Done %s.\n", __func__
);
826 * qla_get_exlogin_status
827 * Get extended login status
828 * uses the memory offload control/status Mailbox
831 * ha: adapter state pointer.
832 * fwopt: firmware options
835 * qla2x00 local function status
840 #define FETCH_XLOGINS_STAT 0x8
842 qla_get_exlogin_status(scsi_qla_host_t
*vha
, uint16_t *buf_sz
,
843 uint16_t *ex_logins_cnt
)
847 mbx_cmd_t
*mcp
= &mc
;
849 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x118f,
850 "Entered %s\n", __func__
);
852 memset(mcp
->mb
, 0 , sizeof(mcp
->mb
));
853 mcp
->mb
[0] = MBC_GET_MEM_OFFLOAD_CNTRL_STAT
;
854 mcp
->mb
[1] = FETCH_XLOGINS_STAT
;
855 mcp
->out_mb
= MBX_1
|MBX_0
;
856 mcp
->in_mb
= MBX_10
|MBX_4
|MBX_0
;
857 mcp
->tov
= MBX_TOV_SECONDS
;
860 rval
= qla2x00_mailbox_command(vha
, mcp
);
861 if (rval
!= QLA_SUCCESS
) {
862 ql_dbg(ql_dbg_mbx
, vha
, 0x1115, "Failed=%x.\n", rval
);
864 *buf_sz
= mcp
->mb
[4];
865 *ex_logins_cnt
= mcp
->mb
[10];
867 ql_log(ql_log_info
, vha
, 0x1190,
868 "buffer size 0x%x, exchange login count=%d\n",
869 mcp
->mb
[4], mcp
->mb
[10]);
871 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x1116,
872 "Done %s.\n", __func__
);
879 * qla_set_exlogin_mem_cfg
880 * set extended login memory configuration
881 * Mbx needs to be issues before init_cb is set
884 * ha: adapter state pointer.
885 * buffer: buffer pointer
886 * phys_addr: physical address of buffer
887 * size: size of buffer
888 * TARGET_QUEUE_LOCK must be released
889 * ADAPTER_STATE_LOCK must be release
892 * qla2x00 local funxtion status code.
897 #define CONFIG_XLOGINS_MEM 0x9
899 qla_set_exlogin_mem_cfg(scsi_qla_host_t
*vha
, dma_addr_t phys_addr
)
903 mbx_cmd_t
*mcp
= &mc
;
904 struct qla_hw_data
*ha
= vha
->hw
;
906 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x111a,
907 "Entered %s.\n", __func__
);
909 memset(mcp
->mb
, 0 , sizeof(mcp
->mb
));
910 mcp
->mb
[0] = MBC_GET_MEM_OFFLOAD_CNTRL_STAT
;
911 mcp
->mb
[1] = CONFIG_XLOGINS_MEM
;
912 mcp
->mb
[2] = MSW(phys_addr
);
913 mcp
->mb
[3] = LSW(phys_addr
);
914 mcp
->mb
[6] = MSW(MSD(phys_addr
));
915 mcp
->mb
[7] = LSW(MSD(phys_addr
));
916 mcp
->mb
[8] = MSW(ha
->exlogin_size
);
917 mcp
->mb
[9] = LSW(ha
->exlogin_size
);
918 mcp
->out_mb
= MBX_9
|MBX_8
|MBX_7
|MBX_6
|MBX_3
|MBX_2
|MBX_1
|MBX_0
;
919 mcp
->in_mb
= MBX_11
|MBX_0
;
920 mcp
->tov
= MBX_TOV_SECONDS
;
922 rval
= qla2x00_mailbox_command(vha
, mcp
);
923 if (rval
!= QLA_SUCCESS
) {
924 ql_dbg(ql_dbg_mbx
, vha
, 0x111b,
925 "EXlogin Failed=%x. MB0=%x MB11=%x\n",
926 rval
, mcp
->mb
[0], mcp
->mb
[11]);
928 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x118c,
929 "Done %s.\n", __func__
);
936 * qla_get_exchoffld_status
937 * Get exchange offload status
938 * uses the memory offload control/status Mailbox
941 * ha: adapter state pointer.
942 * fwopt: firmware options
945 * qla2x00 local function status
950 #define FETCH_XCHOFFLD_STAT 0x2
952 qla_get_exchoffld_status(scsi_qla_host_t
*vha
, uint16_t *buf_sz
,
953 uint16_t *ex_logins_cnt
)
957 mbx_cmd_t
*mcp
= &mc
;
959 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x1019,
960 "Entered %s\n", __func__
);
962 memset(mcp
->mb
, 0 , sizeof(mcp
->mb
));
963 mcp
->mb
[0] = MBC_GET_MEM_OFFLOAD_CNTRL_STAT
;
964 mcp
->mb
[1] = FETCH_XCHOFFLD_STAT
;
965 mcp
->out_mb
= MBX_1
|MBX_0
;
966 mcp
->in_mb
= MBX_10
|MBX_4
|MBX_0
;
967 mcp
->tov
= MBX_TOV_SECONDS
;
970 rval
= qla2x00_mailbox_command(vha
, mcp
);
971 if (rval
!= QLA_SUCCESS
) {
972 ql_dbg(ql_dbg_mbx
, vha
, 0x1155, "Failed=%x.\n", rval
);
974 *buf_sz
= mcp
->mb
[4];
975 *ex_logins_cnt
= mcp
->mb
[10];
977 ql_log(ql_log_info
, vha
, 0x118e,
978 "buffer size 0x%x, exchange offload count=%d\n",
979 mcp
->mb
[4], mcp
->mb
[10]);
981 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x1156,
982 "Done %s.\n", __func__
);
989 * qla_set_exchoffld_mem_cfg
990 * Set exchange offload memory configuration
991 * Mbx needs to be issues before init_cb is set
994 * ha: adapter state pointer.
995 * buffer: buffer pointer
996 * phys_addr: physical address of buffer
997 * size: size of buffer
998 * TARGET_QUEUE_LOCK must be released
999 * ADAPTER_STATE_LOCK must be release
1002 * qla2x00 local funxtion status code.
1007 #define CONFIG_XCHOFFLD_MEM 0x3
1009 qla_set_exchoffld_mem_cfg(scsi_qla_host_t
*vha
)
1013 mbx_cmd_t
*mcp
= &mc
;
1014 struct qla_hw_data
*ha
= vha
->hw
;
1016 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x1157,
1017 "Entered %s.\n", __func__
);
1019 memset(mcp
->mb
, 0 , sizeof(mcp
->mb
));
1020 mcp
->mb
[0] = MBC_GET_MEM_OFFLOAD_CNTRL_STAT
;
1021 mcp
->mb
[1] = CONFIG_XCHOFFLD_MEM
;
1022 mcp
->mb
[2] = MSW(ha
->exchoffld_buf_dma
);
1023 mcp
->mb
[3] = LSW(ha
->exchoffld_buf_dma
);
1024 mcp
->mb
[6] = MSW(MSD(ha
->exchoffld_buf_dma
));
1025 mcp
->mb
[7] = LSW(MSD(ha
->exchoffld_buf_dma
));
1026 mcp
->mb
[8] = MSW(ha
->exchoffld_size
);
1027 mcp
->mb
[9] = LSW(ha
->exchoffld_size
);
1028 mcp
->out_mb
= MBX_9
|MBX_8
|MBX_7
|MBX_6
|MBX_3
|MBX_2
|MBX_1
|MBX_0
;
1029 mcp
->in_mb
= MBX_11
|MBX_0
;
1030 mcp
->tov
= MBX_TOV_SECONDS
;
1032 rval
= qla2x00_mailbox_command(vha
, mcp
);
1033 if (rval
!= QLA_SUCCESS
) {
1035 ql_dbg(ql_dbg_mbx
, vha
, 0x1158, "Failed=%x.\n", rval
);
1037 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x1192,
1038 "Done %s.\n", __func__
);
1045 * qla2x00_get_fw_version
1046 * Get firmware version.
1049 * ha: adapter state pointer.
1050 * major: pointer for major number.
1051 * minor: pointer for minor number.
1052 * subminor: pointer for subminor number.
1055 * qla2x00 local function return status code.
1061 qla2x00_get_fw_version(scsi_qla_host_t
*vha
)
1065 mbx_cmd_t
*mcp
= &mc
;
1066 struct qla_hw_data
*ha
= vha
->hw
;
1068 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x1029,
1069 "Entered %s.\n", __func__
);
1071 mcp
->mb
[0] = MBC_GET_FIRMWARE_VERSION
;
1072 mcp
->out_mb
= MBX_0
;
1073 mcp
->in_mb
= MBX_6
|MBX_5
|MBX_4
|MBX_3
|MBX_2
|MBX_1
|MBX_0
;
1074 if (IS_QLA81XX(vha
->hw
) || IS_QLA8031(ha
) || IS_QLA8044(ha
))
1075 mcp
->in_mb
|= MBX_13
|MBX_12
|MBX_11
|MBX_10
|MBX_9
|MBX_8
;
1076 if (IS_FWI2_CAPABLE(ha
))
1077 mcp
->in_mb
|= MBX_17
|MBX_16
|MBX_15
;
1078 if (IS_QLA27XX(ha
) || IS_QLA28XX(ha
))
1080 MBX_25
|MBX_24
|MBX_23
|MBX_22
|MBX_21
|MBX_20
|MBX_19
|MBX_18
|
1081 MBX_14
|MBX_13
|MBX_11
|MBX_10
|MBX_9
|MBX_8
|MBX_7
;
1084 mcp
->tov
= MBX_TOV_SECONDS
;
1085 rval
= qla2x00_mailbox_command(vha
, mcp
);
1086 if (rval
!= QLA_SUCCESS
)
1089 /* Return mailbox data. */
1090 ha
->fw_major_version
= mcp
->mb
[1];
1091 ha
->fw_minor_version
= mcp
->mb
[2];
1092 ha
->fw_subminor_version
= mcp
->mb
[3];
1093 ha
->fw_attributes
= mcp
->mb
[6];
1094 if (IS_QLA2100(vha
->hw
) || IS_QLA2200(vha
->hw
))
1095 ha
->fw_memory_size
= 0x1FFFF; /* Defaults to 128KB. */
1097 ha
->fw_memory_size
= (mcp
->mb
[5] << 16) | mcp
->mb
[4];
1099 if (IS_QLA81XX(vha
->hw
) || IS_QLA8031(vha
->hw
) || IS_QLA8044(ha
)) {
1100 ha
->mpi_version
[0] = mcp
->mb
[10] & 0xff;
1101 ha
->mpi_version
[1] = mcp
->mb
[11] >> 8;
1102 ha
->mpi_version
[2] = mcp
->mb
[11] & 0xff;
1103 ha
->mpi_capabilities
= (mcp
->mb
[12] << 16) | mcp
->mb
[13];
1104 ha
->phy_version
[0] = mcp
->mb
[8] & 0xff;
1105 ha
->phy_version
[1] = mcp
->mb
[9] >> 8;
1106 ha
->phy_version
[2] = mcp
->mb
[9] & 0xff;
1109 if (IS_FWI2_CAPABLE(ha
)) {
1110 ha
->fw_attributes_h
= mcp
->mb
[15];
1111 ha
->fw_attributes_ext
[0] = mcp
->mb
[16];
1112 ha
->fw_attributes_ext
[1] = mcp
->mb
[17];
1113 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x1139,
1114 "%s: FW_attributes Upper: 0x%x, Lower: 0x%x.\n",
1115 __func__
, mcp
->mb
[15], mcp
->mb
[6]);
1116 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x112f,
1117 "%s: Ext_FwAttributes Upper: 0x%x, Lower: 0x%x.\n",
1118 __func__
, mcp
->mb
[17], mcp
->mb
[16]);
1120 if (ha
->fw_attributes_h
& 0x4)
1121 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x118d,
1122 "%s: Firmware supports Extended Login 0x%x\n",
1123 __func__
, ha
->fw_attributes_h
);
1125 if (ha
->fw_attributes_h
& 0x8)
1126 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x1191,
1127 "%s: Firmware supports Exchange Offload 0x%x\n",
1128 __func__
, ha
->fw_attributes_h
);
1131 * FW supports nvme and driver load parameter requested nvme.
1132 * BIT 26 of fw_attributes indicates NVMe support.
1134 if ((ha
->fw_attributes_h
&
1135 (FW_ATTR_H_NVME
| FW_ATTR_H_NVME_UPDATED
)) &&
1137 if (ha
->fw_attributes_h
& FW_ATTR_H_NVME_FBURST
)
1138 vha
->flags
.nvme_first_burst
= 1;
1140 vha
->flags
.nvme_enabled
= 1;
1141 ql_log(ql_log_info
, vha
, 0xd302,
1142 "%s: FC-NVMe is Enabled (0x%x)\n",
1143 __func__
, ha
->fw_attributes_h
);
1146 /* BIT_13 of Extended FW Attributes informs about NVMe2 support */
1147 if (ha
->fw_attributes_ext
[0] & FW_ATTR_EXT0_NVME2
) {
1148 ql_log(ql_log_info
, vha
, 0xd302,
1149 "Firmware supports NVMe2 0x%x\n",
1150 ha
->fw_attributes_ext
[0]);
1151 vha
->flags
.nvme2_enabled
= 1;
1154 if (IS_QLA28XX(ha
) && ha
->flags
.edif_hw
&& ql2xsecenable
&&
1155 (ha
->fw_attributes_ext
[0] & FW_ATTR_EXT0_EDIF
)) {
1156 ha
->flags
.edif_enabled
= 1;
1157 ql_log(ql_log_info
, vha
, 0xffff,
1158 "%s: edif is enabled\n", __func__
);
1162 if (IS_QLA27XX(ha
) || IS_QLA28XX(ha
)) {
1163 ha
->serdes_version
[0] = mcp
->mb
[7] & 0xff;
1164 ha
->serdes_version
[1] = mcp
->mb
[8] >> 8;
1165 ha
->serdes_version
[2] = mcp
->mb
[8] & 0xff;
1166 ha
->mpi_version
[0] = mcp
->mb
[10] & 0xff;
1167 ha
->mpi_version
[1] = mcp
->mb
[11] >> 8;
1168 ha
->mpi_version
[2] = mcp
->mb
[11] & 0xff;
1169 ha
->pep_version
[0] = mcp
->mb
[13] & 0xff;
1170 ha
->pep_version
[1] = mcp
->mb
[14] >> 8;
1171 ha
->pep_version
[2] = mcp
->mb
[14] & 0xff;
1172 ha
->fw_shared_ram_start
= (mcp
->mb
[19] << 16) | mcp
->mb
[18];
1173 ha
->fw_shared_ram_end
= (mcp
->mb
[21] << 16) | mcp
->mb
[20];
1174 ha
->fw_ddr_ram_start
= (mcp
->mb
[23] << 16) | mcp
->mb
[22];
1175 ha
->fw_ddr_ram_end
= (mcp
->mb
[25] << 16) | mcp
->mb
[24];
1176 if (IS_QLA28XX(ha
)) {
1177 if (mcp
->mb
[16] & BIT_10
)
1178 ha
->flags
.secure_fw
= 1;
1180 ql_log(ql_log_info
, vha
, 0xffff,
1181 "Secure Flash Update in FW: %s\n",
1182 (ha
->flags
.secure_fw
) ? "Supported" :
1186 if (ha
->flags
.scm_supported_a
&&
1187 (ha
->fw_attributes_ext
[0] & FW_ATTR_EXT0_SCM_SUPPORTED
)) {
1188 ha
->flags
.scm_supported_f
= 1;
1189 ha
->sf_init_cb
->flags
|= cpu_to_le16(BIT_13
);
1191 ql_log(ql_log_info
, vha
, 0x11a3, "SCM in FW: %s\n",
1192 (ha
->flags
.scm_supported_f
) ? "Supported" :
1195 if (vha
->flags
.nvme2_enabled
) {
1196 /* set BIT_15 of special feature control block for SLER */
1197 ha
->sf_init_cb
->flags
|= cpu_to_le16(BIT_15
);
1198 /* set BIT_14 of special feature control block for PI CTRL*/
1199 ha
->sf_init_cb
->flags
|= cpu_to_le16(BIT_14
);
1204 if (rval
!= QLA_SUCCESS
) {
1206 ql_dbg(ql_dbg_mbx
, vha
, 0x102a, "Failed=%x.\n", rval
);
1209 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x102b,
1210 "Done %s.\n", __func__
);
1216 * qla2x00_get_fw_options
1217 * Set firmware options.
1220 * ha = adapter block pointer.
1221 * fwopt = pointer for firmware options.
1224 * qla2x00 local function return status code.
1230 qla2x00_get_fw_options(scsi_qla_host_t
*vha
, uint16_t *fwopts
)
1234 mbx_cmd_t
*mcp
= &mc
;
1236 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x102c,
1237 "Entered %s.\n", __func__
);
1239 mcp
->mb
[0] = MBC_GET_FIRMWARE_OPTION
;
1240 mcp
->out_mb
= MBX_0
;
1241 mcp
->in_mb
= MBX_3
|MBX_2
|MBX_1
|MBX_0
;
1242 mcp
->tov
= MBX_TOV_SECONDS
;
1244 rval
= qla2x00_mailbox_command(vha
, mcp
);
1246 if (rval
!= QLA_SUCCESS
) {
1248 ql_dbg(ql_dbg_mbx
, vha
, 0x102d, "Failed=%x.\n", rval
);
1250 fwopts
[0] = mcp
->mb
[0];
1251 fwopts
[1] = mcp
->mb
[1];
1252 fwopts
[2] = mcp
->mb
[2];
1253 fwopts
[3] = mcp
->mb
[3];
1255 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x102e,
1256 "Done %s.\n", __func__
);
1264 * qla2x00_set_fw_options
1265 * Set firmware options.
1268 * ha = adapter block pointer.
1269 * fwopt = pointer for firmware options.
1272 * qla2x00 local function return status code.
1278 qla2x00_set_fw_options(scsi_qla_host_t
*vha
, uint16_t *fwopts
)
1282 mbx_cmd_t
*mcp
= &mc
;
1284 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x102f,
1285 "Entered %s.\n", __func__
);
1287 mcp
->mb
[0] = MBC_SET_FIRMWARE_OPTION
;
1288 mcp
->mb
[1] = fwopts
[1];
1289 mcp
->mb
[2] = fwopts
[2];
1290 mcp
->mb
[3] = fwopts
[3];
1291 mcp
->out_mb
= MBX_3
|MBX_2
|MBX_1
|MBX_0
;
1293 if (IS_FWI2_CAPABLE(vha
->hw
)) {
1294 mcp
->in_mb
|= MBX_1
;
1295 mcp
->mb
[10] = fwopts
[10];
1296 mcp
->out_mb
|= MBX_10
;
1298 mcp
->mb
[10] = fwopts
[10];
1299 mcp
->mb
[11] = fwopts
[11];
1300 mcp
->mb
[12] = 0; /* Undocumented, but used */
1301 mcp
->out_mb
|= MBX_12
|MBX_11
|MBX_10
;
1303 mcp
->tov
= MBX_TOV_SECONDS
;
1305 rval
= qla2x00_mailbox_command(vha
, mcp
);
1307 fwopts
[0] = mcp
->mb
[0];
1309 if (rval
!= QLA_SUCCESS
) {
1311 ql_dbg(ql_dbg_mbx
, vha
, 0x1030,
1312 "Failed=%x (%x/%x).\n", rval
, mcp
->mb
[0], mcp
->mb
[1]);
1315 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x1031,
1316 "Done %s.\n", __func__
);
1323 * qla2x00_mbx_reg_test
1324 * Mailbox register wrap test.
1327 * ha = adapter block pointer.
1328 * TARGET_QUEUE_LOCK must be released.
1329 * ADAPTER_STATE_LOCK must be released.
1332 * qla2x00 local function return status code.
1338 qla2x00_mbx_reg_test(scsi_qla_host_t
*vha
)
1342 mbx_cmd_t
*mcp
= &mc
;
1344 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x1032,
1345 "Entered %s.\n", __func__
);
1347 mcp
->mb
[0] = MBC_MAILBOX_REGISTER_TEST
;
1348 mcp
->mb
[1] = 0xAAAA;
1349 mcp
->mb
[2] = 0x5555;
1350 mcp
->mb
[3] = 0xAA55;
1351 mcp
->mb
[4] = 0x55AA;
1352 mcp
->mb
[5] = 0xA5A5;
1353 mcp
->mb
[6] = 0x5A5A;
1354 mcp
->mb
[7] = 0x2525;
1355 mcp
->out_mb
= MBX_7
|MBX_6
|MBX_5
|MBX_4
|MBX_3
|MBX_2
|MBX_1
|MBX_0
;
1356 mcp
->in_mb
= MBX_7
|MBX_6
|MBX_5
|MBX_4
|MBX_3
|MBX_2
|MBX_1
|MBX_0
;
1357 mcp
->tov
= MBX_TOV_SECONDS
;
1359 rval
= qla2x00_mailbox_command(vha
, mcp
);
1361 if (rval
== QLA_SUCCESS
) {
1362 if (mcp
->mb
[1] != 0xAAAA || mcp
->mb
[2] != 0x5555 ||
1363 mcp
->mb
[3] != 0xAA55 || mcp
->mb
[4] != 0x55AA)
1364 rval
= QLA_FUNCTION_FAILED
;
1365 if (mcp
->mb
[5] != 0xA5A5 || mcp
->mb
[6] != 0x5A5A ||
1366 mcp
->mb
[7] != 0x2525)
1367 rval
= QLA_FUNCTION_FAILED
;
1370 if (rval
!= QLA_SUCCESS
) {
1372 ql_dbg(ql_dbg_mbx
, vha
, 0x1033, "Failed=%x.\n", rval
);
1376 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x1034,
1377 "Done %s.\n", __func__
);
1384 * qla2x00_verify_checksum
1385 * Verify firmware checksum.
1388 * ha = adapter block pointer.
1389 * TARGET_QUEUE_LOCK must be released.
1390 * ADAPTER_STATE_LOCK must be released.
1393 * qla2x00 local function return status code.
1399 qla2x00_verify_checksum(scsi_qla_host_t
*vha
, uint32_t risc_addr
)
1403 mbx_cmd_t
*mcp
= &mc
;
1405 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x1035,
1406 "Entered %s.\n", __func__
);
1408 mcp
->mb
[0] = MBC_VERIFY_CHECKSUM
;
1409 mcp
->out_mb
= MBX_0
;
1411 if (IS_FWI2_CAPABLE(vha
->hw
)) {
1412 mcp
->mb
[1] = MSW(risc_addr
);
1413 mcp
->mb
[2] = LSW(risc_addr
);
1414 mcp
->out_mb
|= MBX_2
|MBX_1
;
1415 mcp
->in_mb
|= MBX_2
|MBX_1
;
1417 mcp
->mb
[1] = LSW(risc_addr
);
1418 mcp
->out_mb
|= MBX_1
;
1419 mcp
->in_mb
|= MBX_1
;
1422 mcp
->tov
= MBX_TOV_SECONDS
;
1424 rval
= qla2x00_mailbox_command(vha
, mcp
);
1426 if (rval
!= QLA_SUCCESS
) {
1427 ql_dbg(ql_dbg_mbx
, vha
, 0x1036,
1428 "Failed=%x chm sum=%x.\n", rval
, IS_FWI2_CAPABLE(vha
->hw
) ?
1429 (mcp
->mb
[2] << 16) | mcp
->mb
[1] : mcp
->mb
[1]);
1431 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x1037,
1432 "Done %s.\n", __func__
);
1439 * qla2x00_issue_iocb
1440 * Issue IOCB using mailbox command
1443 * ha = adapter state pointer.
1444 * buffer = buffer pointer.
1445 * phys_addr = physical address of buffer.
1446 * size = size of buffer.
1447 * TARGET_QUEUE_LOCK must be released.
1448 * ADAPTER_STATE_LOCK must be released.
1451 * qla2x00 local function return status code.
1457 qla2x00_issue_iocb_timeout(scsi_qla_host_t
*vha
, void *buffer
,
1458 dma_addr_t phys_addr
, size_t size
, uint32_t tov
)
1462 mbx_cmd_t
*mcp
= &mc
;
1464 if (!vha
->hw
->flags
.fw_started
)
1465 return QLA_INVALID_COMMAND
;
1467 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x1038,
1468 "Entered %s.\n", __func__
);
1470 mcp
->mb
[0] = MBC_IOCB_COMMAND_A64
;
1472 mcp
->mb
[2] = MSW(LSD(phys_addr
));
1473 mcp
->mb
[3] = LSW(LSD(phys_addr
));
1474 mcp
->mb
[6] = MSW(MSD(phys_addr
));
1475 mcp
->mb
[7] = LSW(MSD(phys_addr
));
1476 mcp
->out_mb
= MBX_7
|MBX_6
|MBX_3
|MBX_2
|MBX_1
|MBX_0
;
1477 mcp
->in_mb
= MBX_1
|MBX_0
;
1480 rval
= qla2x00_mailbox_command(vha
, mcp
);
1482 if (rval
!= QLA_SUCCESS
) {
1484 ql_dbg(ql_dbg_mbx
, vha
, 0x1039, "Failed=%x.\n", rval
);
1486 sts_entry_t
*sts_entry
= buffer
;
1488 /* Mask reserved bits. */
1489 sts_entry
->entry_status
&=
1490 IS_FWI2_CAPABLE(vha
->hw
) ? RF_MASK_24XX
: RF_MASK
;
1491 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x103a,
1492 "Done %s (status=%x).\n", __func__
,
1493 sts_entry
->entry_status
);
1500 qla2x00_issue_iocb(scsi_qla_host_t
*vha
, void *buffer
, dma_addr_t phys_addr
,
1503 return qla2x00_issue_iocb_timeout(vha
, buffer
, phys_addr
, size
,
1508 * qla2x00_abort_command
1509 * Abort command aborts a specified IOCB.
1512 * ha = adapter block pointer.
1513 * sp = SB structure pointer.
1516 * qla2x00 local function return status code.
1522 qla2x00_abort_command(srb_t
*sp
)
1524 unsigned long flags
= 0;
1526 uint32_t handle
= 0;
1528 mbx_cmd_t
*mcp
= &mc
;
1529 fc_port_t
*fcport
= sp
->fcport
;
1530 scsi_qla_host_t
*vha
= fcport
->vha
;
1531 struct qla_hw_data
*ha
= vha
->hw
;
1532 struct req_que
*req
;
1533 struct scsi_cmnd
*cmd
= GET_CMD_SP(sp
);
1535 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x103b,
1536 "Entered %s.\n", __func__
);
1539 req
= sp
->qpair
->req
;
1543 spin_lock_irqsave(&ha
->hardware_lock
, flags
);
1544 for (handle
= 1; handle
< req
->num_outstanding_cmds
; handle
++) {
1545 if (req
->outstanding_cmds
[handle
] == sp
)
1548 spin_unlock_irqrestore(&ha
->hardware_lock
, flags
);
1550 if (handle
== req
->num_outstanding_cmds
) {
1551 /* command not found */
1552 return QLA_FUNCTION_FAILED
;
1555 mcp
->mb
[0] = MBC_ABORT_COMMAND
;
1556 if (HAS_EXTENDED_IDS(ha
))
1557 mcp
->mb
[1] = fcport
->loop_id
;
1559 mcp
->mb
[1] = fcport
->loop_id
<< 8;
1560 mcp
->mb
[2] = (uint16_t)handle
;
1561 mcp
->mb
[3] = (uint16_t)(handle
>> 16);
1562 mcp
->mb
[6] = (uint16_t)cmd
->device
->lun
;
1563 mcp
->out_mb
= MBX_6
|MBX_3
|MBX_2
|MBX_1
|MBX_0
;
1565 mcp
->tov
= MBX_TOV_SECONDS
;
1567 rval
= qla2x00_mailbox_command(vha
, mcp
);
1569 if (rval
!= QLA_SUCCESS
) {
1570 ql_dbg(ql_dbg_mbx
, vha
, 0x103c, "Failed=%x.\n", rval
);
1572 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x103d,
1573 "Done %s.\n", __func__
);
1580 qla2x00_abort_target(struct fc_port
*fcport
, uint64_t l
, int tag
)
1584 mbx_cmd_t
*mcp
= &mc
;
1585 scsi_qla_host_t
*vha
;
1589 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x103e,
1590 "Entered %s.\n", __func__
);
1592 mcp
->mb
[0] = MBC_ABORT_TARGET
;
1593 mcp
->out_mb
= MBX_9
|MBX_2
|MBX_1
|MBX_0
;
1594 if (HAS_EXTENDED_IDS(vha
->hw
)) {
1595 mcp
->mb
[1] = fcport
->loop_id
;
1597 mcp
->out_mb
|= MBX_10
;
1599 mcp
->mb
[1] = fcport
->loop_id
<< 8;
1601 mcp
->mb
[2] = vha
->hw
->loop_reset_delay
;
1602 mcp
->mb
[9] = vha
->vp_idx
;
1605 mcp
->tov
= MBX_TOV_SECONDS
;
1607 rval
= qla2x00_mailbox_command(vha
, mcp
);
1608 if (rval
!= QLA_SUCCESS
) {
1609 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x103f,
1610 "Failed=%x.\n", rval
);
1613 /* Issue marker IOCB. */
1614 rval2
= qla2x00_marker(vha
, vha
->hw
->base_qpair
, fcport
->loop_id
, 0,
1616 if (rval2
!= QLA_SUCCESS
) {
1617 ql_dbg(ql_dbg_mbx
, vha
, 0x1040,
1618 "Failed to issue marker IOCB (%x).\n", rval2
);
1620 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x1041,
1621 "Done %s.\n", __func__
);
1628 qla2x00_lun_reset(struct fc_port
*fcport
, uint64_t l
, int tag
)
1632 mbx_cmd_t
*mcp
= &mc
;
1633 scsi_qla_host_t
*vha
;
1637 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x1042,
1638 "Entered %s.\n", __func__
);
1640 mcp
->mb
[0] = MBC_LUN_RESET
;
1641 mcp
->out_mb
= MBX_9
|MBX_3
|MBX_2
|MBX_1
|MBX_0
;
1642 if (HAS_EXTENDED_IDS(vha
->hw
))
1643 mcp
->mb
[1] = fcport
->loop_id
;
1645 mcp
->mb
[1] = fcport
->loop_id
<< 8;
1646 mcp
->mb
[2] = (u32
)l
;
1648 mcp
->mb
[9] = vha
->vp_idx
;
1651 mcp
->tov
= MBX_TOV_SECONDS
;
1653 rval
= qla2x00_mailbox_command(vha
, mcp
);
1654 if (rval
!= QLA_SUCCESS
) {
1655 ql_dbg(ql_dbg_mbx
, vha
, 0x1043, "Failed=%x.\n", rval
);
1658 /* Issue marker IOCB. */
1659 rval2
= qla2x00_marker(vha
, vha
->hw
->base_qpair
, fcport
->loop_id
, l
,
1661 if (rval2
!= QLA_SUCCESS
) {
1662 ql_dbg(ql_dbg_mbx
, vha
, 0x1044,
1663 "Failed to issue marker IOCB (%x).\n", rval2
);
1665 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x1045,
1666 "Done %s.\n", __func__
);
1673 * qla2x00_get_adapter_id
1674 * Get adapter ID and topology.
1677 * ha = adapter block pointer.
1678 * id = pointer for loop ID.
1679 * al_pa = pointer for AL_PA.
1680 * area = pointer for area.
1681 * domain = pointer for domain.
1682 * top = pointer for topology.
1683 * TARGET_QUEUE_LOCK must be released.
1684 * ADAPTER_STATE_LOCK must be released.
1687 * qla2x00 local function return status code.
1693 qla2x00_get_adapter_id(scsi_qla_host_t
*vha
, uint16_t *id
, uint8_t *al_pa
,
1694 uint8_t *area
, uint8_t *domain
, uint16_t *top
, uint16_t *sw_cap
)
1698 mbx_cmd_t
*mcp
= &mc
;
1700 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x1046,
1701 "Entered %s.\n", __func__
);
1703 mcp
->mb
[0] = MBC_GET_ADAPTER_LOOP_ID
;
1704 mcp
->mb
[9] = vha
->vp_idx
;
1705 mcp
->out_mb
= MBX_9
|MBX_0
;
1706 mcp
->in_mb
= MBX_9
|MBX_7
|MBX_6
|MBX_3
|MBX_2
|MBX_1
|MBX_0
;
1707 if (IS_CNA_CAPABLE(vha
->hw
))
1708 mcp
->in_mb
|= MBX_13
|MBX_12
|MBX_11
|MBX_10
;
1709 if (IS_FWI2_CAPABLE(vha
->hw
))
1710 mcp
->in_mb
|= MBX_19
|MBX_18
|MBX_17
|MBX_16
;
1711 if (IS_QLA27XX(vha
->hw
) || IS_QLA28XX(vha
->hw
))
1712 mcp
->in_mb
|= MBX_15
|MBX_21
|MBX_22
|MBX_23
;
1714 mcp
->tov
= MBX_TOV_SECONDS
;
1716 rval
= qla2x00_mailbox_command(vha
, mcp
);
1717 if (mcp
->mb
[0] == MBS_COMMAND_ERROR
)
1718 rval
= QLA_COMMAND_ERROR
;
1719 else if (mcp
->mb
[0] == MBS_INVALID_COMMAND
)
1720 rval
= QLA_INVALID_COMMAND
;
1724 *al_pa
= LSB(mcp
->mb
[2]);
1725 *area
= MSB(mcp
->mb
[2]);
1726 *domain
= LSB(mcp
->mb
[3]);
1728 *sw_cap
= mcp
->mb
[7];
1730 if (rval
!= QLA_SUCCESS
) {
1732 ql_dbg(ql_dbg_mbx
, vha
, 0x1047, "Failed=%x.\n", rval
);
1734 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x1048,
1735 "Done %s.\n", __func__
);
1737 if (IS_CNA_CAPABLE(vha
->hw
)) {
1738 vha
->fcoe_vlan_id
= mcp
->mb
[9] & 0xfff;
1739 vha
->fcoe_fcf_idx
= mcp
->mb
[10];
1740 vha
->fcoe_vn_port_mac
[5] = mcp
->mb
[11] >> 8;
1741 vha
->fcoe_vn_port_mac
[4] = mcp
->mb
[11] & 0xff;
1742 vha
->fcoe_vn_port_mac
[3] = mcp
->mb
[12] >> 8;
1743 vha
->fcoe_vn_port_mac
[2] = mcp
->mb
[12] & 0xff;
1744 vha
->fcoe_vn_port_mac
[1] = mcp
->mb
[13] >> 8;
1745 vha
->fcoe_vn_port_mac
[0] = mcp
->mb
[13] & 0xff;
1747 /* If FA-WWN supported */
1748 if (IS_FAWWN_CAPABLE(vha
->hw
)) {
1749 if (mcp
->mb
[7] & BIT_14
) {
1750 vha
->port_name
[0] = MSB(mcp
->mb
[16]);
1751 vha
->port_name
[1] = LSB(mcp
->mb
[16]);
1752 vha
->port_name
[2] = MSB(mcp
->mb
[17]);
1753 vha
->port_name
[3] = LSB(mcp
->mb
[17]);
1754 vha
->port_name
[4] = MSB(mcp
->mb
[18]);
1755 vha
->port_name
[5] = LSB(mcp
->mb
[18]);
1756 vha
->port_name
[6] = MSB(mcp
->mb
[19]);
1757 vha
->port_name
[7] = LSB(mcp
->mb
[19]);
1758 fc_host_port_name(vha
->host
) =
1759 wwn_to_u64(vha
->port_name
);
1760 ql_dbg(ql_dbg_mbx
, vha
, 0x10ca,
1761 "FA-WWN acquired %016llx\n",
1762 wwn_to_u64(vha
->port_name
));
1766 if (IS_QLA27XX(vha
->hw
) || IS_QLA28XX(vha
->hw
)) {
1767 vha
->bbcr
= mcp
->mb
[15];
1768 if (mcp
->mb
[7] & SCM_EDC_ACC_RECEIVED
) {
1769 ql_log(ql_log_info
, vha
, 0x11a4,
1770 "SCM: EDC ELS completed, flags 0x%x\n",
1773 if (mcp
->mb
[7] & SCM_RDF_ACC_RECEIVED
) {
1774 vha
->hw
->flags
.scm_enabled
= 1;
1775 vha
->scm_fabric_connection_flags
|=
1776 SCM_FLAG_RDF_COMPLETED
;
1777 ql_log(ql_log_info
, vha
, 0x11a5,
1778 "SCM: RDF ELS completed, flags 0x%x\n",
1788 * qla2x00_get_retry_cnt
1789 * Get current firmware login retry count and delay.
1792 * ha = adapter block pointer.
1793 * retry_cnt = pointer to login retry count.
1794 * tov = pointer to login timeout value.
1797 * qla2x00 local function return status code.
1803 qla2x00_get_retry_cnt(scsi_qla_host_t
*vha
, uint8_t *retry_cnt
, uint8_t *tov
,
1809 mbx_cmd_t
*mcp
= &mc
;
1811 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x1049,
1812 "Entered %s.\n", __func__
);
1814 mcp
->mb
[0] = MBC_GET_RETRY_COUNT
;
1815 mcp
->out_mb
= MBX_0
;
1816 mcp
->in_mb
= MBX_3
|MBX_2
|MBX_1
|MBX_0
;
1817 mcp
->tov
= MBX_TOV_SECONDS
;
1819 rval
= qla2x00_mailbox_command(vha
, mcp
);
1821 if (rval
!= QLA_SUCCESS
) {
1823 ql_dbg(ql_dbg_mbx
, vha
, 0x104a,
1824 "Failed=%x mb[0]=%x.\n", rval
, mcp
->mb
[0]);
1826 /* Convert returned data and check our values. */
1827 *r_a_tov
= mcp
->mb
[3] / 2;
1828 ratov
= (mcp
->mb
[3]/2) / 10; /* mb[3] value is in 100ms */
1829 if (mcp
->mb
[1] * ratov
> (*retry_cnt
) * (*tov
)) {
1830 /* Update to the larger values */
1831 *retry_cnt
= (uint8_t)mcp
->mb
[1];
1835 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x104b,
1836 "Done %s mb3=%d ratov=%d.\n", __func__
, mcp
->mb
[3], ratov
);
1843 * qla2x00_init_firmware
1844 * Initialize adapter firmware.
1847 * ha = adapter block pointer.
1848 * dptr = Initialization control block pointer.
1849 * size = size of initialization control block.
1850 * TARGET_QUEUE_LOCK must be released.
1851 * ADAPTER_STATE_LOCK must be released.
1854 * qla2x00 local function return status code.
1860 qla2x00_init_firmware(scsi_qla_host_t
*vha
, uint16_t size
)
1864 mbx_cmd_t
*mcp
= &mc
;
1865 struct qla_hw_data
*ha
= vha
->hw
;
1867 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x104c,
1868 "Entered %s.\n", __func__
);
1870 if (IS_P3P_TYPE(ha
) && ql2xdbwr
)
1871 qla82xx_wr_32(ha
, (uintptr_t __force
)ha
->nxdb_wr_ptr
,
1872 (0x04 | (ha
->portnum
<< 5) | (0 << 8) | (0 << 16)));
1874 if (ha
->flags
.npiv_supported
)
1875 mcp
->mb
[0] = MBC_MID_INITIALIZE_FIRMWARE
;
1877 mcp
->mb
[0] = MBC_INITIALIZE_FIRMWARE
;
1880 mcp
->mb
[2] = MSW(ha
->init_cb_dma
);
1881 mcp
->mb
[3] = LSW(ha
->init_cb_dma
);
1882 mcp
->mb
[6] = MSW(MSD(ha
->init_cb_dma
));
1883 mcp
->mb
[7] = LSW(MSD(ha
->init_cb_dma
));
1884 mcp
->out_mb
= MBX_7
|MBX_6
|MBX_3
|MBX_2
|MBX_1
|MBX_0
;
1885 if (ha
->ex_init_cb
&& ha
->ex_init_cb
->ex_version
) {
1887 mcp
->mb
[10] = MSW(ha
->ex_init_cb_dma
);
1888 mcp
->mb
[11] = LSW(ha
->ex_init_cb_dma
);
1889 mcp
->mb
[12] = MSW(MSD(ha
->ex_init_cb_dma
));
1890 mcp
->mb
[13] = LSW(MSD(ha
->ex_init_cb_dma
));
1891 mcp
->mb
[14] = sizeof(*ha
->ex_init_cb
);
1892 mcp
->out_mb
|= MBX_14
|MBX_13
|MBX_12
|MBX_11
|MBX_10
;
1895 if (ha
->flags
.scm_supported_f
|| vha
->flags
.nvme2_enabled
) {
1896 mcp
->mb
[1] |= BIT_1
;
1897 mcp
->mb
[16] = MSW(ha
->sf_init_cb_dma
);
1898 mcp
->mb
[17] = LSW(ha
->sf_init_cb_dma
);
1899 mcp
->mb
[18] = MSW(MSD(ha
->sf_init_cb_dma
));
1900 mcp
->mb
[19] = LSW(MSD(ha
->sf_init_cb_dma
));
1901 mcp
->mb
[15] = sizeof(*ha
->sf_init_cb
);
1902 mcp
->out_mb
|= MBX_19
|MBX_18
|MBX_17
|MBX_16
|MBX_15
;
1905 /* 1 and 2 should normally be captured. */
1906 mcp
->in_mb
= MBX_2
|MBX_1
|MBX_0
;
1907 if (IS_QLA83XX(ha
) || IS_QLA27XX(ha
) || IS_QLA28XX(ha
))
1908 /* mb3 is additional info about the installed SFP. */
1909 mcp
->in_mb
|= MBX_3
;
1910 mcp
->buf_size
= size
;
1911 mcp
->flags
= MBX_DMA_OUT
;
1912 mcp
->tov
= MBX_TOV_SECONDS
;
1913 rval
= qla2x00_mailbox_command(vha
, mcp
);
1915 if (rval
!= QLA_SUCCESS
) {
1917 ql_dbg(ql_dbg_mbx
, vha
, 0x104d,
1918 "Failed=%x mb[0]=%x, mb[1]=%x, mb[2]=%x, mb[3]=%x.\n",
1919 rval
, mcp
->mb
[0], mcp
->mb
[1], mcp
->mb
[2], mcp
->mb
[3]);
1921 ql_dbg(ql_dbg_mbx
, vha
, 0x104d, "init_cb:\n");
1922 ql_dump_buffer(ql_dbg_init
+ ql_dbg_verbose
, vha
,
1923 0x0104d, ha
->init_cb
, sizeof(*ha
->init_cb
));
1925 if (ha
->ex_init_cb
&& ha
->ex_init_cb
->ex_version
) {
1926 ql_dbg(ql_dbg_mbx
, vha
, 0x104d, "ex_init_cb:\n");
1927 ql_dump_buffer(ql_dbg_init
+ ql_dbg_verbose
, vha
,
1928 0x0104d, ha
->ex_init_cb
, sizeof(*ha
->ex_init_cb
));
1931 if (IS_QLA27XX(ha
) || IS_QLA28XX(ha
)) {
1932 if (mcp
->mb
[2] == 6 || mcp
->mb
[3] == 2)
1933 ql_dbg(ql_dbg_mbx
, vha
, 0x119d,
1934 "Invalid SFP/Validation Failed\n");
1936 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x104e,
1937 "Done %s.\n", __func__
);
1945 * qla2x00_get_port_database
1946 * Issue normal/enhanced get port database mailbox command
1947 * and copy device name as necessary.
1950 * ha = adapter state pointer.
1951 * dev = structure pointer.
1952 * opt = enhanced cmd option byte.
1955 * qla2x00 local function return status code.
1961 qla2x00_get_port_database(scsi_qla_host_t
*vha
, fc_port_t
*fcport
, uint8_t opt
)
1965 mbx_cmd_t
*mcp
= &mc
;
1966 port_database_t
*pd
;
1967 struct port_database_24xx
*pd24
;
1969 struct qla_hw_data
*ha
= vha
->hw
;
1971 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x104f,
1972 "Entered %s.\n", __func__
);
1975 pd
= dma_pool_zalloc(ha
->s_dma_pool
, GFP_KERNEL
, &pd_dma
);
1977 ql_log(ql_log_warn
, vha
, 0x1050,
1978 "Failed to allocate port database structure.\n");
1980 return QLA_MEMORY_ALLOC_FAILED
;
1983 mcp
->mb
[0] = MBC_GET_PORT_DATABASE
;
1984 if (opt
!= 0 && !IS_FWI2_CAPABLE(ha
))
1985 mcp
->mb
[0] = MBC_ENHANCED_GET_PORT_DATABASE
;
1986 mcp
->mb
[2] = MSW(pd_dma
);
1987 mcp
->mb
[3] = LSW(pd_dma
);
1988 mcp
->mb
[6] = MSW(MSD(pd_dma
));
1989 mcp
->mb
[7] = LSW(MSD(pd_dma
));
1990 mcp
->mb
[9] = vha
->vp_idx
;
1991 mcp
->out_mb
= MBX_9
|MBX_7
|MBX_6
|MBX_3
|MBX_2
|MBX_0
;
1993 if (IS_FWI2_CAPABLE(ha
)) {
1994 mcp
->mb
[1] = fcport
->loop_id
;
1996 mcp
->out_mb
|= MBX_10
|MBX_1
;
1997 mcp
->in_mb
|= MBX_1
;
1998 } else if (HAS_EXTENDED_IDS(ha
)) {
1999 mcp
->mb
[1] = fcport
->loop_id
;
2001 mcp
->out_mb
|= MBX_10
|MBX_1
;
2003 mcp
->mb
[1] = fcport
->loop_id
<< 8 | opt
;
2004 mcp
->out_mb
|= MBX_1
;
2006 mcp
->buf_size
= IS_FWI2_CAPABLE(ha
) ?
2007 PORT_DATABASE_24XX_SIZE
: PORT_DATABASE_SIZE
;
2008 mcp
->flags
= MBX_DMA_IN
;
2009 mcp
->tov
= (ha
->login_timeout
* 2) + (ha
->login_timeout
/ 2);
2010 rval
= qla2x00_mailbox_command(vha
, mcp
);
2011 if (rval
!= QLA_SUCCESS
)
2014 if (IS_FWI2_CAPABLE(ha
)) {
2016 u8 current_login_state
, last_login_state
;
2018 pd24
= (struct port_database_24xx
*) pd
;
2020 /* Check for logged in state. */
2021 if (NVME_TARGET(ha
, fcport
)) {
2022 current_login_state
= pd24
->current_login_state
>> 4;
2023 last_login_state
= pd24
->last_login_state
>> 4;
2025 current_login_state
= pd24
->current_login_state
& 0xf;
2026 last_login_state
= pd24
->last_login_state
& 0xf;
2028 fcport
->current_login_state
= pd24
->current_login_state
;
2029 fcport
->last_login_state
= pd24
->last_login_state
;
2031 /* Check for logged in state. */
2032 if (current_login_state
!= PDS_PRLI_COMPLETE
&&
2033 last_login_state
!= PDS_PRLI_COMPLETE
) {
2034 ql_dbg(ql_dbg_mbx
, vha
, 0x119a,
2035 "Unable to verify login-state (%x/%x) for loop_id %x.\n",
2036 current_login_state
, last_login_state
,
2038 rval
= QLA_FUNCTION_FAILED
;
2044 if (fcport
->loop_id
== FC_NO_LOOP_ID
||
2045 (memcmp(fcport
->port_name
, (uint8_t *)&zero
, 8) &&
2046 memcmp(fcport
->port_name
, pd24
->port_name
, 8))) {
2047 /* We lost the device mid way. */
2048 rval
= QLA_NOT_LOGGED_IN
;
2052 /* Names are little-endian. */
2053 memcpy(fcport
->node_name
, pd24
->node_name
, WWN_SIZE
);
2054 memcpy(fcport
->port_name
, pd24
->port_name
, WWN_SIZE
);
2056 /* Get port_id of device. */
2057 fcport
->d_id
.b
.domain
= pd24
->port_id
[0];
2058 fcport
->d_id
.b
.area
= pd24
->port_id
[1];
2059 fcport
->d_id
.b
.al_pa
= pd24
->port_id
[2];
2060 fcport
->d_id
.b
.rsvd_1
= 0;
2062 /* If not target must be initiator or unknown type. */
2063 if ((pd24
->prli_svc_param_word_3
[0] & BIT_4
) == 0)
2064 fcport
->port_type
= FCT_INITIATOR
;
2066 fcport
->port_type
= FCT_TARGET
;
2068 /* Passback COS information. */
2069 fcport
->supported_classes
= (pd24
->flags
& PDF_CLASS_2
) ?
2070 FC_COS_CLASS2
: FC_COS_CLASS3
;
2072 if (pd24
->prli_svc_param_word_3
[0] & BIT_7
)
2073 fcport
->flags
|= FCF_CONF_COMP_SUPPORTED
;
2077 /* Check for logged in state. */
2078 if (pd
->master_state
!= PD_STATE_PORT_LOGGED_IN
&&
2079 pd
->slave_state
!= PD_STATE_PORT_LOGGED_IN
) {
2080 ql_dbg(ql_dbg_mbx
, vha
, 0x100a,
2081 "Unable to verify login-state (%x/%x) - "
2082 "portid=%02x%02x%02x.\n", pd
->master_state
,
2083 pd
->slave_state
, fcport
->d_id
.b
.domain
,
2084 fcport
->d_id
.b
.area
, fcport
->d_id
.b
.al_pa
);
2085 rval
= QLA_FUNCTION_FAILED
;
2089 if (fcport
->loop_id
== FC_NO_LOOP_ID
||
2090 (memcmp(fcport
->port_name
, (uint8_t *)&zero
, 8) &&
2091 memcmp(fcport
->port_name
, pd
->port_name
, 8))) {
2092 /* We lost the device mid way. */
2093 rval
= QLA_NOT_LOGGED_IN
;
2097 /* Names are little-endian. */
2098 memcpy(fcport
->node_name
, pd
->node_name
, WWN_SIZE
);
2099 memcpy(fcport
->port_name
, pd
->port_name
, WWN_SIZE
);
2101 /* Get port_id of device. */
2102 fcport
->d_id
.b
.domain
= pd
->port_id
[0];
2103 fcport
->d_id
.b
.area
= pd
->port_id
[3];
2104 fcport
->d_id
.b
.al_pa
= pd
->port_id
[2];
2105 fcport
->d_id
.b
.rsvd_1
= 0;
2107 /* If not target must be initiator or unknown type. */
2108 if ((pd
->prli_svc_param_word_3
[0] & BIT_4
) == 0)
2109 fcport
->port_type
= FCT_INITIATOR
;
2111 fcport
->port_type
= FCT_TARGET
;
2113 /* Passback COS information. */
2114 fcport
->supported_classes
= (pd
->options
& BIT_4
) ?
2115 FC_COS_CLASS2
: FC_COS_CLASS3
;
2119 dma_pool_free(ha
->s_dma_pool
, pd
, pd_dma
);
2122 if (rval
!= QLA_SUCCESS
) {
2123 ql_dbg(ql_dbg_mbx
, vha
, 0x1052,
2124 "Failed=%x mb[0]=%x mb[1]=%x.\n", rval
,
2125 mcp
->mb
[0], mcp
->mb
[1]);
2127 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x1053,
2128 "Done %s.\n", __func__
);
2135 qla24xx_get_port_database(scsi_qla_host_t
*vha
, u16 nport_handle
,
2136 struct port_database_24xx
*pdb
)
2139 mbx_cmd_t
*mcp
= &mc
;
2143 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x1115,
2144 "Entered %s.\n", __func__
);
2146 memset(pdb
, 0, sizeof(*pdb
));
2148 pdb_dma
= dma_map_single(&vha
->hw
->pdev
->dev
, pdb
,
2149 sizeof(*pdb
), DMA_FROM_DEVICE
);
2151 ql_log(ql_log_warn
, vha
, 0x1116, "Failed to map dma buffer.\n");
2152 return QLA_MEMORY_ALLOC_FAILED
;
2155 mcp
->mb
[0] = MBC_GET_PORT_DATABASE
;
2156 mcp
->mb
[1] = nport_handle
;
2157 mcp
->mb
[2] = MSW(LSD(pdb_dma
));
2158 mcp
->mb
[3] = LSW(LSD(pdb_dma
));
2159 mcp
->mb
[6] = MSW(MSD(pdb_dma
));
2160 mcp
->mb
[7] = LSW(MSD(pdb_dma
));
2163 mcp
->out_mb
= MBX_10
|MBX_9
|MBX_7
|MBX_6
|MBX_3
|MBX_2
|MBX_1
|MBX_0
;
2164 mcp
->in_mb
= MBX_1
|MBX_0
;
2165 mcp
->buf_size
= sizeof(*pdb
);
2166 mcp
->flags
= MBX_DMA_IN
;
2167 mcp
->tov
= vha
->hw
->login_timeout
* 2;
2168 rval
= qla2x00_mailbox_command(vha
, mcp
);
2170 if (rval
!= QLA_SUCCESS
) {
2171 ql_dbg(ql_dbg_mbx
, vha
, 0x111a,
2172 "Failed=%x mb[0]=%x mb[1]=%x.\n",
2173 rval
, mcp
->mb
[0], mcp
->mb
[1]);
2175 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x111b,
2176 "Done %s.\n", __func__
);
2179 dma_unmap_single(&vha
->hw
->pdev
->dev
, pdb_dma
,
2180 sizeof(*pdb
), DMA_FROM_DEVICE
);
2186 * qla2x00_get_firmware_state
2187 * Get adapter firmware state.
2190 * ha = adapter block pointer.
2191 * dptr = pointer for firmware state.
2192 * TARGET_QUEUE_LOCK must be released.
2193 * ADAPTER_STATE_LOCK must be released.
2196 * qla2x00 local function return status code.
2202 qla2x00_get_firmware_state(scsi_qla_host_t
*vha
, uint16_t *states
)
2206 mbx_cmd_t
*mcp
= &mc
;
2207 struct qla_hw_data
*ha
= vha
->hw
;
2209 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x1054,
2210 "Entered %s.\n", __func__
);
2212 if (!ha
->flags
.fw_started
)
2213 return QLA_FUNCTION_FAILED
;
2215 mcp
->mb
[0] = MBC_GET_FIRMWARE_STATE
;
2216 mcp
->out_mb
= MBX_0
;
2217 if (IS_FWI2_CAPABLE(vha
->hw
))
2218 mcp
->in_mb
= MBX_6
|MBX_5
|MBX_4
|MBX_3
|MBX_2
|MBX_1
|MBX_0
;
2220 mcp
->in_mb
= MBX_1
|MBX_0
;
2221 mcp
->tov
= MBX_TOV_SECONDS
;
2223 rval
= qla2x00_mailbox_command(vha
, mcp
);
2225 /* Return firmware states. */
2226 states
[0] = mcp
->mb
[1];
2227 if (IS_FWI2_CAPABLE(vha
->hw
)) {
2228 states
[1] = mcp
->mb
[2];
2229 states
[2] = mcp
->mb
[3]; /* SFP info */
2230 states
[3] = mcp
->mb
[4];
2231 states
[4] = mcp
->mb
[5];
2232 states
[5] = mcp
->mb
[6]; /* DPORT status */
2235 if (rval
!= QLA_SUCCESS
) {
2237 ql_dbg(ql_dbg_mbx
, vha
, 0x1055, "Failed=%x.\n", rval
);
2239 if (IS_QLA27XX(ha
) || IS_QLA28XX(ha
)) {
2240 if (mcp
->mb
[2] == 6 || mcp
->mb
[3] == 2)
2241 ql_dbg(ql_dbg_mbx
, vha
, 0x119e,
2242 "Invalid SFP/Validation Failed\n");
2244 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x1056,
2245 "Done %s.\n", __func__
);
2252 * qla2x00_get_port_name
2253 * Issue get port name mailbox command.
2254 * Returned name is in big endian format.
2257 * ha = adapter block pointer.
2258 * loop_id = loop ID of device.
2259 * name = pointer for name.
2260 * TARGET_QUEUE_LOCK must be released.
2261 * ADAPTER_STATE_LOCK must be released.
2264 * qla2x00 local function return status code.
2270 qla2x00_get_port_name(scsi_qla_host_t
*vha
, uint16_t loop_id
, uint8_t *name
,
2275 mbx_cmd_t
*mcp
= &mc
;
2277 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x1057,
2278 "Entered %s.\n", __func__
);
2280 mcp
->mb
[0] = MBC_GET_PORT_NAME
;
2281 mcp
->mb
[9] = vha
->vp_idx
;
2282 mcp
->out_mb
= MBX_9
|MBX_1
|MBX_0
;
2283 if (HAS_EXTENDED_IDS(vha
->hw
)) {
2284 mcp
->mb
[1] = loop_id
;
2286 mcp
->out_mb
|= MBX_10
;
2288 mcp
->mb
[1] = loop_id
<< 8 | opt
;
2291 mcp
->in_mb
= MBX_7
|MBX_6
|MBX_3
|MBX_2
|MBX_1
|MBX_0
;
2292 mcp
->tov
= MBX_TOV_SECONDS
;
2294 rval
= qla2x00_mailbox_command(vha
, mcp
);
2296 if (rval
!= QLA_SUCCESS
) {
2298 ql_dbg(ql_dbg_mbx
, vha
, 0x1058, "Failed=%x.\n", rval
);
2301 /* This function returns name in big endian. */
2302 name
[0] = MSB(mcp
->mb
[2]);
2303 name
[1] = LSB(mcp
->mb
[2]);
2304 name
[2] = MSB(mcp
->mb
[3]);
2305 name
[3] = LSB(mcp
->mb
[3]);
2306 name
[4] = MSB(mcp
->mb
[6]);
2307 name
[5] = LSB(mcp
->mb
[6]);
2308 name
[6] = MSB(mcp
->mb
[7]);
2309 name
[7] = LSB(mcp
->mb
[7]);
2312 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x1059,
2313 "Done %s.\n", __func__
);
2320 * qla24xx_link_initialization
2321 * Issue link initialization mailbox command.
2324 * ha = adapter block pointer.
2325 * TARGET_QUEUE_LOCK must be released.
2326 * ADAPTER_STATE_LOCK must be released.
2329 * qla2x00 local function return status code.
2335 qla24xx_link_initialize(scsi_qla_host_t
*vha
)
2339 mbx_cmd_t
*mcp
= &mc
;
2341 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x1152,
2342 "Entered %s.\n", __func__
);
2344 if (!IS_FWI2_CAPABLE(vha
->hw
) || IS_CNA_CAPABLE(vha
->hw
))
2345 return QLA_FUNCTION_FAILED
;
2347 mcp
->mb
[0] = MBC_LINK_INITIALIZATION
;
2349 if (vha
->hw
->operating_mode
== LOOP
)
2350 mcp
->mb
[1] |= BIT_6
;
2352 mcp
->mb
[1] |= BIT_5
;
2355 mcp
->out_mb
= MBX_3
|MBX_2
|MBX_1
|MBX_0
;
2357 mcp
->tov
= MBX_TOV_SECONDS
;
2359 rval
= qla2x00_mailbox_command(vha
, mcp
);
2361 if (rval
!= QLA_SUCCESS
) {
2362 ql_dbg(ql_dbg_mbx
, vha
, 0x1153, "Failed=%x.\n", rval
);
2364 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x1154,
2365 "Done %s.\n", __func__
);
2373 * Issue LIP reset mailbox command.
2376 * ha = adapter block pointer.
2377 * TARGET_QUEUE_LOCK must be released.
2378 * ADAPTER_STATE_LOCK must be released.
2381 * qla2x00 local function return status code.
2387 qla2x00_lip_reset(scsi_qla_host_t
*vha
)
2391 mbx_cmd_t
*mcp
= &mc
;
2393 ql_dbg(ql_dbg_disc
, vha
, 0x105a,
2394 "Entered %s.\n", __func__
);
2396 if (IS_CNA_CAPABLE(vha
->hw
)) {
2397 /* Logout across all FCFs. */
2398 mcp
->mb
[0] = MBC_LIP_FULL_LOGIN
;
2401 mcp
->out_mb
= MBX_2
|MBX_1
|MBX_0
;
2402 } else if (IS_FWI2_CAPABLE(vha
->hw
)) {
2403 mcp
->mb
[0] = MBC_LIP_FULL_LOGIN
;
2406 mcp
->mb
[3] = vha
->hw
->loop_reset_delay
;
2407 mcp
->out_mb
= MBX_3
|MBX_2
|MBX_1
|MBX_0
;
2409 mcp
->mb
[0] = MBC_LIP_RESET
;
2410 mcp
->out_mb
= MBX_3
|MBX_2
|MBX_1
|MBX_0
;
2411 if (HAS_EXTENDED_IDS(vha
->hw
)) {
2412 mcp
->mb
[1] = 0x00ff;
2414 mcp
->out_mb
|= MBX_10
;
2416 mcp
->mb
[1] = 0xff00;
2418 mcp
->mb
[2] = vha
->hw
->loop_reset_delay
;
2422 mcp
->tov
= MBX_TOV_SECONDS
;
2424 rval
= qla2x00_mailbox_command(vha
, mcp
);
2426 if (rval
!= QLA_SUCCESS
) {
2428 ql_dbg(ql_dbg_mbx
, vha
, 0x105b, "Failed=%x.\n", rval
);
2431 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x105c,
2432 "Done %s.\n", __func__
);
2443 * ha = adapter block pointer.
2444 * sns = pointer for command.
2445 * cmd_size = command size.
2446 * buf_size = response/command size.
2447 * TARGET_QUEUE_LOCK must be released.
2448 * ADAPTER_STATE_LOCK must be released.
2451 * qla2x00 local function return status code.
2457 qla2x00_send_sns(scsi_qla_host_t
*vha
, dma_addr_t sns_phys_address
,
2458 uint16_t cmd_size
, size_t buf_size
)
2462 mbx_cmd_t
*mcp
= &mc
;
2464 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x105d,
2465 "Entered %s.\n", __func__
);
2467 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x105e,
2468 "Retry cnt=%d ratov=%d total tov=%d.\n",
2469 vha
->hw
->retry_count
, vha
->hw
->login_timeout
, mcp
->tov
);
2471 mcp
->mb
[0] = MBC_SEND_SNS_COMMAND
;
2472 mcp
->mb
[1] = cmd_size
;
2473 mcp
->mb
[2] = MSW(sns_phys_address
);
2474 mcp
->mb
[3] = LSW(sns_phys_address
);
2475 mcp
->mb
[6] = MSW(MSD(sns_phys_address
));
2476 mcp
->mb
[7] = LSW(MSD(sns_phys_address
));
2477 mcp
->out_mb
= MBX_7
|MBX_6
|MBX_3
|MBX_2
|MBX_1
|MBX_0
;
2478 mcp
->in_mb
= MBX_0
|MBX_1
;
2479 mcp
->buf_size
= buf_size
;
2480 mcp
->flags
= MBX_DMA_OUT
|MBX_DMA_IN
;
2481 mcp
->tov
= (vha
->hw
->login_timeout
* 2) + (vha
->hw
->login_timeout
/ 2);
2482 rval
= qla2x00_mailbox_command(vha
, mcp
);
2484 if (rval
!= QLA_SUCCESS
) {
2486 ql_dbg(ql_dbg_mbx
, vha
, 0x105f,
2487 "Failed=%x mb[0]=%x mb[1]=%x.\n",
2488 rval
, mcp
->mb
[0], mcp
->mb
[1]);
2491 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x1060,
2492 "Done %s.\n", __func__
);
2499 qla24xx_login_fabric(scsi_qla_host_t
*vha
, uint16_t loop_id
, uint8_t domain
,
2500 uint8_t area
, uint8_t al_pa
, uint16_t *mb
, uint8_t opt
)
2504 struct logio_entry_24xx
*lg
;
2507 struct qla_hw_data
*ha
= vha
->hw
;
2508 struct req_que
*req
;
2510 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x1061,
2511 "Entered %s.\n", __func__
);
2513 if (vha
->vp_idx
&& vha
->qpair
)
2514 req
= vha
->qpair
->req
;
2516 req
= ha
->req_q_map
[0];
2518 lg
= dma_pool_zalloc(ha
->s_dma_pool
, GFP_KERNEL
, &lg_dma
);
2520 ql_log(ql_log_warn
, vha
, 0x1062,
2521 "Failed to allocate login IOCB.\n");
2522 return QLA_MEMORY_ALLOC_FAILED
;
2525 lg
->entry_type
= LOGINOUT_PORT_IOCB_TYPE
;
2526 lg
->entry_count
= 1;
2527 lg
->handle
= make_handle(req
->id
, lg
->handle
);
2528 lg
->nport_handle
= cpu_to_le16(loop_id
);
2529 lg
->control_flags
= cpu_to_le16(LCF_COMMAND_PLOGI
);
2531 lg
->control_flags
|= cpu_to_le16(LCF_COND_PLOGI
);
2533 lg
->control_flags
|= cpu_to_le16(LCF_SKIP_PRLI
);
2534 lg
->port_id
[0] = al_pa
;
2535 lg
->port_id
[1] = area
;
2536 lg
->port_id
[2] = domain
;
2537 lg
->vp_index
= vha
->vp_idx
;
2538 rval
= qla2x00_issue_iocb_timeout(vha
, lg
, lg_dma
, 0,
2539 (ha
->r_a_tov
/ 10 * 2) + 2);
2540 if (rval
!= QLA_SUCCESS
) {
2541 ql_dbg(ql_dbg_mbx
, vha
, 0x1063,
2542 "Failed to issue login IOCB (%x).\n", rval
);
2543 } else if (lg
->entry_status
!= 0) {
2544 ql_dbg(ql_dbg_mbx
, vha
, 0x1064,
2545 "Failed to complete IOCB -- error status (%x).\n",
2547 rval
= QLA_FUNCTION_FAILED
;
2548 } else if (lg
->comp_status
!= cpu_to_le16(CS_COMPLETE
)) {
2549 iop
[0] = le32_to_cpu(lg
->io_parameter
[0]);
2550 iop
[1] = le32_to_cpu(lg
->io_parameter
[1]);
2552 ql_dbg(ql_dbg_mbx
, vha
, 0x1065,
2553 "Failed to complete IOCB -- completion status (%x) "
2554 "ioparam=%x/%x.\n", le16_to_cpu(lg
->comp_status
),
2558 case LSC_SCODE_PORTID_USED
:
2559 mb
[0] = MBS_PORT_ID_USED
;
2560 mb
[1] = LSW(iop
[1]);
2562 case LSC_SCODE_NPORT_USED
:
2563 mb
[0] = MBS_LOOP_ID_USED
;
2565 case LSC_SCODE_NOLINK
:
2566 case LSC_SCODE_NOIOCB
:
2567 case LSC_SCODE_NOXCB
:
2568 case LSC_SCODE_CMD_FAILED
:
2569 case LSC_SCODE_NOFABRIC
:
2570 case LSC_SCODE_FW_NOT_READY
:
2571 case LSC_SCODE_NOT_LOGGED_IN
:
2572 case LSC_SCODE_NOPCB
:
2573 case LSC_SCODE_ELS_REJECT
:
2574 case LSC_SCODE_CMD_PARAM_ERR
:
2575 case LSC_SCODE_NONPORT
:
2576 case LSC_SCODE_LOGGED_IN
:
2577 case LSC_SCODE_NOFLOGI_ACC
:
2579 mb
[0] = MBS_COMMAND_ERROR
;
2583 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x1066,
2584 "Done %s.\n", __func__
);
2586 iop
[0] = le32_to_cpu(lg
->io_parameter
[0]);
2588 mb
[0] = MBS_COMMAND_COMPLETE
;
2590 if (iop
[0] & BIT_4
) {
2596 /* Passback COS information. */
2598 if (lg
->io_parameter
[7] || lg
->io_parameter
[8])
2599 mb
[10] |= BIT_0
; /* Class 2. */
2600 if (lg
->io_parameter
[9] || lg
->io_parameter
[10])
2601 mb
[10] |= BIT_1
; /* Class 3. */
2602 if (lg
->io_parameter
[0] & cpu_to_le32(BIT_7
))
2603 mb
[10] |= BIT_7
; /* Confirmed Completion
2608 dma_pool_free(ha
->s_dma_pool
, lg
, lg_dma
);
2614 * qla2x00_login_fabric
2615 * Issue login fabric port mailbox command.
2618 * ha = adapter block pointer.
2619 * loop_id = device loop ID.
2620 * domain = device domain.
2621 * area = device area.
2622 * al_pa = device AL_PA.
2623 * status = pointer for return status.
2624 * opt = command options.
2625 * TARGET_QUEUE_LOCK must be released.
2626 * ADAPTER_STATE_LOCK must be released.
2629 * qla2x00 local function return status code.
2635 qla2x00_login_fabric(scsi_qla_host_t
*vha
, uint16_t loop_id
, uint8_t domain
,
2636 uint8_t area
, uint8_t al_pa
, uint16_t *mb
, uint8_t opt
)
2640 mbx_cmd_t
*mcp
= &mc
;
2641 struct qla_hw_data
*ha
= vha
->hw
;
2643 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x1067,
2644 "Entered %s.\n", __func__
);
2646 mcp
->mb
[0] = MBC_LOGIN_FABRIC_PORT
;
2647 mcp
->out_mb
= MBX_3
|MBX_2
|MBX_1
|MBX_0
;
2648 if (HAS_EXTENDED_IDS(ha
)) {
2649 mcp
->mb
[1] = loop_id
;
2651 mcp
->out_mb
|= MBX_10
;
2653 mcp
->mb
[1] = (loop_id
<< 8) | opt
;
2655 mcp
->mb
[2] = domain
;
2656 mcp
->mb
[3] = area
<< 8 | al_pa
;
2658 mcp
->in_mb
= MBX_7
|MBX_6
|MBX_2
|MBX_1
|MBX_0
;
2659 mcp
->tov
= (ha
->login_timeout
* 2) + (ha
->login_timeout
/ 2);
2661 rval
= qla2x00_mailbox_command(vha
, mcp
);
2663 /* Return mailbox statuses. */
2670 /* COS retrieved from Get-Port-Database mailbox command. */
2674 if (rval
!= QLA_SUCCESS
) {
2675 /* RLU tmp code: need to change main mailbox_command function to
2676 * return ok even when the mailbox completion value is not
2677 * SUCCESS. The caller needs to be responsible to interpret
2678 * the return values of this mailbox command if we're not
2679 * to change too much of the existing code.
2681 if (mcp
->mb
[0] == 0x4001 || mcp
->mb
[0] == 0x4002 ||
2682 mcp
->mb
[0] == 0x4003 || mcp
->mb
[0] == 0x4005 ||
2683 mcp
->mb
[0] == 0x4006)
2687 ql_dbg(ql_dbg_mbx
, vha
, 0x1068,
2688 "Failed=%x mb[0]=%x mb[1]=%x mb[2]=%x.\n",
2689 rval
, mcp
->mb
[0], mcp
->mb
[1], mcp
->mb
[2]);
2692 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x1069,
2693 "Done %s.\n", __func__
);
2700 * qla2x00_login_local_device
2701 * Issue login loop port mailbox command.
2704 * ha = adapter block pointer.
2705 * loop_id = device loop ID.
2706 * opt = command options.
2709 * Return status code.
2716 qla2x00_login_local_device(scsi_qla_host_t
*vha
, fc_port_t
*fcport
,
2717 uint16_t *mb_ret
, uint8_t opt
)
2721 mbx_cmd_t
*mcp
= &mc
;
2722 struct qla_hw_data
*ha
= vha
->hw
;
2724 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x106a,
2725 "Entered %s.\n", __func__
);
2727 if (IS_FWI2_CAPABLE(ha
))
2728 return qla24xx_login_fabric(vha
, fcport
->loop_id
,
2729 fcport
->d_id
.b
.domain
, fcport
->d_id
.b
.area
,
2730 fcport
->d_id
.b
.al_pa
, mb_ret
, opt
);
2732 mcp
->mb
[0] = MBC_LOGIN_LOOP_PORT
;
2733 if (HAS_EXTENDED_IDS(ha
))
2734 mcp
->mb
[1] = fcport
->loop_id
;
2736 mcp
->mb
[1] = fcport
->loop_id
<< 8;
2738 mcp
->out_mb
= MBX_2
|MBX_1
|MBX_0
;
2739 mcp
->in_mb
= MBX_7
|MBX_6
|MBX_1
|MBX_0
;
2740 mcp
->tov
= (ha
->login_timeout
* 2) + (ha
->login_timeout
/ 2);
2742 rval
= qla2x00_mailbox_command(vha
, mcp
);
2744 /* Return mailbox statuses. */
2745 if (mb_ret
!= NULL
) {
2746 mb_ret
[0] = mcp
->mb
[0];
2747 mb_ret
[1] = mcp
->mb
[1];
2748 mb_ret
[6] = mcp
->mb
[6];
2749 mb_ret
[7] = mcp
->mb
[7];
2752 if (rval
!= QLA_SUCCESS
) {
2753 /* AV tmp code: need to change main mailbox_command function to
2754 * return ok even when the mailbox completion value is not
2755 * SUCCESS. The caller needs to be responsible to interpret
2756 * the return values of this mailbox command if we're not
2757 * to change too much of the existing code.
2759 if (mcp
->mb
[0] == 0x4005 || mcp
->mb
[0] == 0x4006)
2762 ql_dbg(ql_dbg_mbx
, vha
, 0x106b,
2763 "Failed=%x mb[0]=%x mb[1]=%x mb[6]=%x mb[7]=%x.\n",
2764 rval
, mcp
->mb
[0], mcp
->mb
[1], mcp
->mb
[6], mcp
->mb
[7]);
2767 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x106c,
2768 "Done %s.\n", __func__
);
2775 qla24xx_fabric_logout(scsi_qla_host_t
*vha
, uint16_t loop_id
, uint8_t domain
,
2776 uint8_t area
, uint8_t al_pa
)
2779 struct logio_entry_24xx
*lg
;
2781 struct qla_hw_data
*ha
= vha
->hw
;
2782 struct req_que
*req
;
2784 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x106d,
2785 "Entered %s.\n", __func__
);
2787 lg
= dma_pool_zalloc(ha
->s_dma_pool
, GFP_KERNEL
, &lg_dma
);
2789 ql_log(ql_log_warn
, vha
, 0x106e,
2790 "Failed to allocate logout IOCB.\n");
2791 return QLA_MEMORY_ALLOC_FAILED
;
2795 lg
->entry_type
= LOGINOUT_PORT_IOCB_TYPE
;
2796 lg
->entry_count
= 1;
2797 lg
->handle
= make_handle(req
->id
, lg
->handle
);
2798 lg
->nport_handle
= cpu_to_le16(loop_id
);
2800 cpu_to_le16(LCF_COMMAND_LOGO
|LCF_IMPL_LOGO
|
2802 lg
->port_id
[0] = al_pa
;
2803 lg
->port_id
[1] = area
;
2804 lg
->port_id
[2] = domain
;
2805 lg
->vp_index
= vha
->vp_idx
;
2806 rval
= qla2x00_issue_iocb_timeout(vha
, lg
, lg_dma
, 0,
2807 (ha
->r_a_tov
/ 10 * 2) + 2);
2808 if (rval
!= QLA_SUCCESS
) {
2809 ql_dbg(ql_dbg_mbx
, vha
, 0x106f,
2810 "Failed to issue logout IOCB (%x).\n", rval
);
2811 } else if (lg
->entry_status
!= 0) {
2812 ql_dbg(ql_dbg_mbx
, vha
, 0x1070,
2813 "Failed to complete IOCB -- error status (%x).\n",
2815 rval
= QLA_FUNCTION_FAILED
;
2816 } else if (lg
->comp_status
!= cpu_to_le16(CS_COMPLETE
)) {
2817 ql_dbg(ql_dbg_mbx
, vha
, 0x1071,
2818 "Failed to complete IOCB -- completion status (%x) "
2819 "ioparam=%x/%x.\n", le16_to_cpu(lg
->comp_status
),
2820 le32_to_cpu(lg
->io_parameter
[0]),
2821 le32_to_cpu(lg
->io_parameter
[1]));
2824 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x1072,
2825 "Done %s.\n", __func__
);
2828 dma_pool_free(ha
->s_dma_pool
, lg
, lg_dma
);
2834 * qla2x00_fabric_logout
2835 * Issue logout fabric port mailbox command.
2838 * ha = adapter block pointer.
2839 * loop_id = device loop ID.
2840 * TARGET_QUEUE_LOCK must be released.
2841 * ADAPTER_STATE_LOCK must be released.
2844 * qla2x00 local function return status code.
2850 qla2x00_fabric_logout(scsi_qla_host_t
*vha
, uint16_t loop_id
, uint8_t domain
,
2851 uint8_t area
, uint8_t al_pa
)
2855 mbx_cmd_t
*mcp
= &mc
;
2857 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x1073,
2858 "Entered %s.\n", __func__
);
2860 mcp
->mb
[0] = MBC_LOGOUT_FABRIC_PORT
;
2861 mcp
->out_mb
= MBX_1
|MBX_0
;
2862 if (HAS_EXTENDED_IDS(vha
->hw
)) {
2863 mcp
->mb
[1] = loop_id
;
2865 mcp
->out_mb
|= MBX_10
;
2867 mcp
->mb
[1] = loop_id
<< 8;
2870 mcp
->in_mb
= MBX_1
|MBX_0
;
2871 mcp
->tov
= MBX_TOV_SECONDS
;
2873 rval
= qla2x00_mailbox_command(vha
, mcp
);
2875 if (rval
!= QLA_SUCCESS
) {
2877 ql_dbg(ql_dbg_mbx
, vha
, 0x1074,
2878 "Failed=%x mb[1]=%x.\n", rval
, mcp
->mb
[1]);
2881 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x1075,
2882 "Done %s.\n", __func__
);
2889 * qla2x00_full_login_lip
2890 * Issue full login LIP mailbox command.
2893 * ha = adapter block pointer.
2894 * TARGET_QUEUE_LOCK must be released.
2895 * ADAPTER_STATE_LOCK must be released.
2898 * qla2x00 local function return status code.
2904 qla2x00_full_login_lip(scsi_qla_host_t
*vha
)
2908 mbx_cmd_t
*mcp
= &mc
;
2910 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x1076,
2911 "Entered %s.\n", __func__
);
2913 mcp
->mb
[0] = MBC_LIP_FULL_LOGIN
;
2914 mcp
->mb
[1] = IS_FWI2_CAPABLE(vha
->hw
) ? BIT_4
: 0;
2917 mcp
->out_mb
= MBX_3
|MBX_2
|MBX_1
|MBX_0
;
2919 mcp
->tov
= MBX_TOV_SECONDS
;
2921 rval
= qla2x00_mailbox_command(vha
, mcp
);
2923 if (rval
!= QLA_SUCCESS
) {
2925 ql_dbg(ql_dbg_mbx
, vha
, 0x1077, "Failed=%x.\n", rval
);
2928 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x1078,
2929 "Done %s.\n", __func__
);
2936 * qla2x00_get_id_list
2939 * ha = adapter block pointer.
2942 * qla2x00 local function return status code.
2948 qla2x00_get_id_list(scsi_qla_host_t
*vha
, void *id_list
, dma_addr_t id_list_dma
,
2953 mbx_cmd_t
*mcp
= &mc
;
2955 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x1079,
2956 "Entered %s.\n", __func__
);
2958 if (id_list
== NULL
)
2959 return QLA_FUNCTION_FAILED
;
2961 mcp
->mb
[0] = MBC_GET_ID_LIST
;
2962 mcp
->out_mb
= MBX_0
;
2963 if (IS_FWI2_CAPABLE(vha
->hw
)) {
2964 mcp
->mb
[2] = MSW(id_list_dma
);
2965 mcp
->mb
[3] = LSW(id_list_dma
);
2966 mcp
->mb
[6] = MSW(MSD(id_list_dma
));
2967 mcp
->mb
[7] = LSW(MSD(id_list_dma
));
2969 mcp
->mb
[9] = vha
->vp_idx
;
2970 mcp
->out_mb
|= MBX_9
|MBX_8
|MBX_7
|MBX_6
|MBX_3
|MBX_2
;
2972 mcp
->mb
[1] = MSW(id_list_dma
);
2973 mcp
->mb
[2] = LSW(id_list_dma
);
2974 mcp
->mb
[3] = MSW(MSD(id_list_dma
));
2975 mcp
->mb
[6] = LSW(MSD(id_list_dma
));
2976 mcp
->out_mb
|= MBX_6
|MBX_3
|MBX_2
|MBX_1
;
2978 mcp
->in_mb
= MBX_1
|MBX_0
;
2979 mcp
->tov
= MBX_TOV_SECONDS
;
2981 rval
= qla2x00_mailbox_command(vha
, mcp
);
2983 if (rval
!= QLA_SUCCESS
) {
2985 ql_dbg(ql_dbg_mbx
, vha
, 0x107a, "Failed=%x.\n", rval
);
2987 *entries
= mcp
->mb
[1];
2988 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x107b,
2989 "Done %s.\n", __func__
);
2996 * qla2x00_get_resource_cnts
2997 * Get current firmware resource counts.
3000 * ha = adapter block pointer.
3003 * qla2x00 local function return status code.
3009 qla2x00_get_resource_cnts(scsi_qla_host_t
*vha
)
3011 struct qla_hw_data
*ha
= vha
->hw
;
3014 mbx_cmd_t
*mcp
= &mc
;
3016 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x107c,
3017 "Entered %s.\n", __func__
);
3019 mcp
->mb
[0] = MBC_GET_RESOURCE_COUNTS
;
3020 mcp
->out_mb
= MBX_0
;
3021 mcp
->in_mb
= MBX_11
|MBX_10
|MBX_7
|MBX_6
|MBX_3
|MBX_2
|MBX_1
|MBX_0
;
3022 if (IS_QLA81XX(ha
) || IS_QLA83XX(ha
) ||
3023 IS_QLA27XX(ha
) || IS_QLA28XX(ha
))
3024 mcp
->in_mb
|= MBX_12
;
3025 mcp
->tov
= MBX_TOV_SECONDS
;
3027 rval
= qla2x00_mailbox_command(vha
, mcp
);
3029 if (rval
!= QLA_SUCCESS
) {
3031 ql_dbg(ql_dbg_mbx
, vha
, 0x107d,
3032 "Failed mb[0]=%x.\n", mcp
->mb
[0]);
3034 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x107e,
3035 "Done %s mb1=%x mb2=%x mb3=%x mb6=%x mb7=%x mb10=%x "
3036 "mb11=%x mb12=%x.\n", __func__
, mcp
->mb
[1], mcp
->mb
[2],
3037 mcp
->mb
[3], mcp
->mb
[6], mcp
->mb
[7], mcp
->mb
[10],
3038 mcp
->mb
[11], mcp
->mb
[12]);
3040 ha
->orig_fw_tgt_xcb_count
= mcp
->mb
[1];
3041 ha
->cur_fw_tgt_xcb_count
= mcp
->mb
[2];
3042 ha
->cur_fw_xcb_count
= mcp
->mb
[3];
3043 ha
->orig_fw_xcb_count
= mcp
->mb
[6];
3044 ha
->cur_fw_iocb_count
= mcp
->mb
[7];
3045 ha
->orig_fw_iocb_count
= mcp
->mb
[10];
3046 if (ha
->flags
.npiv_supported
)
3047 ha
->max_npiv_vports
= mcp
->mb
[11];
3048 if (IS_QLA81XX(ha
) || IS_QLA83XX(ha
))
3049 ha
->fw_max_fcf_count
= mcp
->mb
[12];
3056 * qla2x00_get_fcal_position_map
3057 * Get FCAL (LILP) position map using mailbox command
3060 * ha = adapter state pointer.
3061 * pos_map = buffer pointer (can be NULL).
3064 * qla2x00 local function return status code.
3070 qla2x00_get_fcal_position_map(scsi_qla_host_t
*vha
, char *pos_map
,
3075 mbx_cmd_t
*mcp
= &mc
;
3077 dma_addr_t pmap_dma
;
3078 struct qla_hw_data
*ha
= vha
->hw
;
3080 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x107f,
3081 "Entered %s.\n", __func__
);
3083 pmap
= dma_pool_zalloc(ha
->s_dma_pool
, GFP_KERNEL
, &pmap_dma
);
3085 ql_log(ql_log_warn
, vha
, 0x1080,
3086 "Memory alloc failed.\n");
3087 return QLA_MEMORY_ALLOC_FAILED
;
3090 mcp
->mb
[0] = MBC_GET_FC_AL_POSITION_MAP
;
3091 mcp
->mb
[2] = MSW(pmap_dma
);
3092 mcp
->mb
[3] = LSW(pmap_dma
);
3093 mcp
->mb
[6] = MSW(MSD(pmap_dma
));
3094 mcp
->mb
[7] = LSW(MSD(pmap_dma
));
3095 mcp
->out_mb
= MBX_7
|MBX_6
|MBX_3
|MBX_2
|MBX_0
;
3096 mcp
->in_mb
= MBX_1
|MBX_0
;
3097 mcp
->buf_size
= FCAL_MAP_SIZE
;
3098 mcp
->flags
= MBX_DMA_IN
;
3099 mcp
->tov
= (ha
->login_timeout
* 2) + (ha
->login_timeout
/ 2);
3100 rval
= qla2x00_mailbox_command(vha
, mcp
);
3102 if (rval
== QLA_SUCCESS
) {
3103 ql_dbg(ql_dbg_mbx
+ ql_dbg_buffer
, vha
, 0x1081,
3104 "mb0/mb1=%x/%X FC/AL position map size (%x).\n",
3105 mcp
->mb
[0], mcp
->mb
[1], (unsigned)pmap
[0]);
3106 ql_dump_buffer(ql_dbg_mbx
+ ql_dbg_buffer
, vha
, 0x111d,
3110 memcpy(pos_map
, pmap
, FCAL_MAP_SIZE
);
3112 *num_entries
= pmap
[0];
3114 dma_pool_free(ha
->s_dma_pool
, pmap
, pmap_dma
);
3116 if (rval
!= QLA_SUCCESS
) {
3117 ql_dbg(ql_dbg_mbx
, vha
, 0x1082, "Failed=%x.\n", rval
);
3119 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x1083,
3120 "Done %s.\n", __func__
);
3127 * qla2x00_get_link_status
3130 * ha = adapter block pointer.
3131 * loop_id = device loop ID.
3132 * ret_buf = pointer to link status return buffer.
3136 * BIT_0 = mem alloc error.
3137 * BIT_1 = mailbox error.
3140 qla2x00_get_link_status(scsi_qla_host_t
*vha
, uint16_t loop_id
,
3141 struct link_statistics
*stats
, dma_addr_t stats_dma
)
3145 mbx_cmd_t
*mcp
= &mc
;
3146 uint32_t *iter
= (uint32_t *)stats
;
3147 ushort dwords
= offsetof(typeof(*stats
), link_up_cnt
)/sizeof(*iter
);
3148 struct qla_hw_data
*ha
= vha
->hw
;
3150 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x1084,
3151 "Entered %s.\n", __func__
);
3153 mcp
->mb
[0] = MBC_GET_LINK_STATUS
;
3154 mcp
->mb
[2] = MSW(LSD(stats_dma
));
3155 mcp
->mb
[3] = LSW(LSD(stats_dma
));
3156 mcp
->mb
[6] = MSW(MSD(stats_dma
));
3157 mcp
->mb
[7] = LSW(MSD(stats_dma
));
3158 mcp
->out_mb
= MBX_7
|MBX_6
|MBX_3
|MBX_2
|MBX_0
;
3160 if (IS_FWI2_CAPABLE(ha
)) {
3161 mcp
->mb
[1] = loop_id
;
3164 mcp
->out_mb
|= MBX_10
|MBX_4
|MBX_1
;
3165 mcp
->in_mb
|= MBX_1
;
3166 } else if (HAS_EXTENDED_IDS(ha
)) {
3167 mcp
->mb
[1] = loop_id
;
3169 mcp
->out_mb
|= MBX_10
|MBX_1
;
3171 mcp
->mb
[1] = loop_id
<< 8;
3172 mcp
->out_mb
|= MBX_1
;
3174 mcp
->tov
= MBX_TOV_SECONDS
;
3175 mcp
->flags
= IOCTL_CMD
;
3176 rval
= qla2x00_mailbox_command(vha
, mcp
);
3178 if (rval
== QLA_SUCCESS
) {
3179 if (mcp
->mb
[0] != MBS_COMMAND_COMPLETE
) {
3180 ql_dbg(ql_dbg_mbx
, vha
, 0x1085,
3181 "Failed=%x mb[0]=%x.\n", rval
, mcp
->mb
[0]);
3182 rval
= QLA_FUNCTION_FAILED
;
3184 /* Re-endianize - firmware data is le32. */
3185 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x1086,
3186 "Done %s.\n", __func__
);
3187 for ( ; dwords
--; iter
++)
3192 ql_dbg(ql_dbg_mbx
, vha
, 0x1087, "Failed=%x.\n", rval
);
3199 qla24xx_get_isp_stats(scsi_qla_host_t
*vha
, struct link_statistics
*stats
,
3200 dma_addr_t stats_dma
, uint16_t options
)
3204 mbx_cmd_t
*mcp
= &mc
;
3205 uint32_t *iter
= (uint32_t *)stats
;
3206 ushort dwords
= sizeof(*stats
)/sizeof(*iter
);
3208 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x1088,
3209 "Entered %s.\n", __func__
);
3211 memset(&mc
, 0, sizeof(mc
));
3212 mc
.mb
[0] = MBC_GET_LINK_PRIV_STATS
;
3213 mc
.mb
[2] = MSW(LSD(stats_dma
));
3214 mc
.mb
[3] = LSW(LSD(stats_dma
));
3215 mc
.mb
[6] = MSW(MSD(stats_dma
));
3216 mc
.mb
[7] = LSW(MSD(stats_dma
));
3218 mc
.mb
[9] = vha
->vp_idx
;
3219 mc
.mb
[10] = options
;
3221 rval
= qla24xx_send_mb_cmd(vha
, &mc
);
3223 if (rval
== QLA_SUCCESS
) {
3224 if (mcp
->mb
[0] != MBS_COMMAND_COMPLETE
) {
3225 ql_dbg(ql_dbg_mbx
, vha
, 0x1089,
3226 "Failed mb[0]=%x.\n", mcp
->mb
[0]);
3227 rval
= QLA_FUNCTION_FAILED
;
3229 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x108a,
3230 "Done %s.\n", __func__
);
3231 /* Re-endianize - firmware data is le32. */
3232 for ( ; dwords
--; iter
++)
3237 ql_dbg(ql_dbg_mbx
, vha
, 0x108b, "Failed=%x.\n", rval
);
3244 qla24xx_abort_command(srb_t
*sp
)
3247 unsigned long flags
= 0;
3249 struct abort_entry_24xx
*abt
;
3252 fc_port_t
*fcport
= sp
->fcport
;
3253 struct scsi_qla_host
*vha
= fcport
->vha
;
3254 struct qla_hw_data
*ha
= vha
->hw
;
3255 struct req_que
*req
;
3256 struct qla_qpair
*qpair
= sp
->qpair
;
3258 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x108c,
3259 "Entered %s.\n", __func__
);
3262 req
= sp
->qpair
->req
;
3264 return QLA_ERR_NO_QPAIR
;
3266 if (ql2xasynctmfenable
)
3267 return qla24xx_async_abort_command(sp
);
3269 spin_lock_irqsave(qpair
->qp_lock_ptr
, flags
);
3270 for (handle
= 1; handle
< req
->num_outstanding_cmds
; handle
++) {
3271 if (req
->outstanding_cmds
[handle
] == sp
)
3274 spin_unlock_irqrestore(qpair
->qp_lock_ptr
, flags
);
3275 if (handle
== req
->num_outstanding_cmds
) {
3276 /* Command not found. */
3277 return QLA_ERR_NOT_FOUND
;
3280 abt
= dma_pool_zalloc(ha
->s_dma_pool
, GFP_KERNEL
, &abt_dma
);
3282 ql_log(ql_log_warn
, vha
, 0x108d,
3283 "Failed to allocate abort IOCB.\n");
3284 return QLA_MEMORY_ALLOC_FAILED
;
3287 abt
->entry_type
= ABORT_IOCB_TYPE
;
3288 abt
->entry_count
= 1;
3289 abt
->handle
= make_handle(req
->id
, abt
->handle
);
3290 abt
->nport_handle
= cpu_to_le16(fcport
->loop_id
);
3291 abt
->handle_to_abort
= make_handle(req
->id
, handle
);
3292 abt
->port_id
[0] = fcport
->d_id
.b
.al_pa
;
3293 abt
->port_id
[1] = fcport
->d_id
.b
.area
;
3294 abt
->port_id
[2] = fcport
->d_id
.b
.domain
;
3295 abt
->vp_index
= fcport
->vha
->vp_idx
;
3297 abt
->req_que_no
= cpu_to_le16(req
->id
);
3298 /* Need to pass original sp */
3299 qla_nvme_abort_set_option(abt
, sp
);
3301 rval
= qla2x00_issue_iocb(vha
, abt
, abt_dma
, 0);
3302 if (rval
!= QLA_SUCCESS
) {
3303 ql_dbg(ql_dbg_mbx
, vha
, 0x108e,
3304 "Failed to issue IOCB (%x).\n", rval
);
3305 } else if (abt
->entry_status
!= 0) {
3306 ql_dbg(ql_dbg_mbx
, vha
, 0x108f,
3307 "Failed to complete IOCB -- error status (%x).\n",
3309 rval
= QLA_FUNCTION_FAILED
;
3310 } else if (abt
->nport_handle
!= cpu_to_le16(0)) {
3311 ql_dbg(ql_dbg_mbx
, vha
, 0x1090,
3312 "Failed to complete IOCB -- completion status (%x).\n",
3313 le16_to_cpu(abt
->nport_handle
));
3314 if (abt
->nport_handle
== cpu_to_le16(CS_IOCB_ERROR
))
3315 rval
= QLA_FUNCTION_PARAMETER_ERROR
;
3317 rval
= QLA_FUNCTION_FAILED
;
3319 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x1091,
3320 "Done %s.\n", __func__
);
3322 if (rval
== QLA_SUCCESS
)
3323 qla_nvme_abort_process_comp_status(abt
, sp
);
3325 qla_wait_nvme_release_cmd_kref(sp
);
3327 dma_pool_free(ha
->s_dma_pool
, abt
, abt_dma
);
3332 struct tsk_mgmt_cmd
{
3334 struct tsk_mgmt_entry tsk
;
3335 struct sts_entry_24xx sts
;
3340 __qla24xx_issue_tmf(char *name
, uint32_t type
, struct fc_port
*fcport
,
3341 uint64_t l
, int tag
)
3344 struct tsk_mgmt_cmd
*tsk
;
3345 struct sts_entry_24xx
*sts
;
3347 scsi_qla_host_t
*vha
;
3348 struct qla_hw_data
*ha
;
3349 struct req_que
*req
;
3350 struct qla_qpair
*qpair
;
3356 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x1092,
3357 "Entered %s.\n", __func__
);
3359 if (vha
->vp_idx
&& vha
->qpair
) {
3365 tsk
= dma_pool_zalloc(ha
->s_dma_pool
, GFP_KERNEL
, &tsk_dma
);
3367 ql_log(ql_log_warn
, vha
, 0x1093,
3368 "Failed to allocate task management IOCB.\n");
3369 return QLA_MEMORY_ALLOC_FAILED
;
3372 tsk
->p
.tsk
.entry_type
= TSK_MGMT_IOCB_TYPE
;
3373 tsk
->p
.tsk
.entry_count
= 1;
3374 tsk
->p
.tsk
.handle
= make_handle(req
->id
, tsk
->p
.tsk
.handle
);
3375 tsk
->p
.tsk
.nport_handle
= cpu_to_le16(fcport
->loop_id
);
3376 tsk
->p
.tsk
.timeout
= cpu_to_le16(ha
->r_a_tov
/ 10 * 2);
3377 tsk
->p
.tsk
.control_flags
= cpu_to_le32(type
);
3378 tsk
->p
.tsk
.port_id
[0] = fcport
->d_id
.b
.al_pa
;
3379 tsk
->p
.tsk
.port_id
[1] = fcport
->d_id
.b
.area
;
3380 tsk
->p
.tsk
.port_id
[2] = fcport
->d_id
.b
.domain
;
3381 tsk
->p
.tsk
.vp_index
= fcport
->vha
->vp_idx
;
3382 if (type
== TCF_LUN_RESET
) {
3383 int_to_scsilun(l
, &tsk
->p
.tsk
.lun
);
3384 host_to_fcp_swap((uint8_t *)&tsk
->p
.tsk
.lun
,
3385 sizeof(tsk
->p
.tsk
.lun
));
3389 rval
= qla2x00_issue_iocb(vha
, tsk
, tsk_dma
, 0);
3390 if (rval
!= QLA_SUCCESS
) {
3391 ql_dbg(ql_dbg_mbx
, vha
, 0x1094,
3392 "Failed to issue %s reset IOCB (%x).\n", name
, rval
);
3393 } else if (sts
->entry_status
!= 0) {
3394 ql_dbg(ql_dbg_mbx
, vha
, 0x1095,
3395 "Failed to complete IOCB -- error status (%x).\n",
3397 rval
= QLA_FUNCTION_FAILED
;
3398 } else if (sts
->comp_status
!= cpu_to_le16(CS_COMPLETE
)) {
3399 ql_dbg(ql_dbg_mbx
, vha
, 0x1096,
3400 "Failed to complete IOCB -- completion status (%x).\n",
3401 le16_to_cpu(sts
->comp_status
));
3402 rval
= QLA_FUNCTION_FAILED
;
3403 } else if (le16_to_cpu(sts
->scsi_status
) &
3404 SS_RESPONSE_INFO_LEN_VALID
) {
3405 if (le32_to_cpu(sts
->rsp_data_len
) < 4) {
3406 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x1097,
3407 "Ignoring inconsistent data length -- not enough "
3408 "response info (%d).\n",
3409 le32_to_cpu(sts
->rsp_data_len
));
3410 } else if (sts
->data
[3]) {
3411 ql_dbg(ql_dbg_mbx
, vha
, 0x1098,
3412 "Failed to complete IOCB -- response (%x).\n",
3414 rval
= QLA_FUNCTION_FAILED
;
3418 /* Issue marker IOCB. */
3419 rval2
= qla2x00_marker(vha
, ha
->base_qpair
, fcport
->loop_id
, l
,
3420 type
== TCF_LUN_RESET
? MK_SYNC_ID_LUN
: MK_SYNC_ID
);
3421 if (rval2
!= QLA_SUCCESS
) {
3422 ql_dbg(ql_dbg_mbx
, vha
, 0x1099,
3423 "Failed to issue marker IOCB (%x).\n", rval2
);
3425 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x109a,
3426 "Done %s.\n", __func__
);
3429 dma_pool_free(ha
->s_dma_pool
, tsk
, tsk_dma
);
3435 qla24xx_abort_target(struct fc_port
*fcport
, uint64_t l
, int tag
)
3437 struct qla_hw_data
*ha
= fcport
->vha
->hw
;
3439 if ((ql2xasynctmfenable
) && IS_FWI2_CAPABLE(ha
))
3440 return qla2x00_async_tm_cmd(fcport
, TCF_TARGET_RESET
, l
, tag
);
3442 return __qla24xx_issue_tmf("Target", TCF_TARGET_RESET
, fcport
, l
, tag
);
3446 qla24xx_lun_reset(struct fc_port
*fcport
, uint64_t l
, int tag
)
3448 struct qla_hw_data
*ha
= fcport
->vha
->hw
;
3450 if ((ql2xasynctmfenable
) && IS_FWI2_CAPABLE(ha
))
3451 return qla2x00_async_tm_cmd(fcport
, TCF_LUN_RESET
, l
, tag
);
3453 return __qla24xx_issue_tmf("Lun", TCF_LUN_RESET
, fcport
, l
, tag
);
3457 qla2x00_system_error(scsi_qla_host_t
*vha
)
3461 mbx_cmd_t
*mcp
= &mc
;
3462 struct qla_hw_data
*ha
= vha
->hw
;
3464 if (!IS_QLA23XX(ha
) && !IS_FWI2_CAPABLE(ha
))
3465 return QLA_FUNCTION_FAILED
;
3467 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x109b,
3468 "Entered %s.\n", __func__
);
3470 mcp
->mb
[0] = MBC_GEN_SYSTEM_ERROR
;
3471 mcp
->out_mb
= MBX_0
;
3475 rval
= qla2x00_mailbox_command(vha
, mcp
);
3477 if (rval
!= QLA_SUCCESS
) {
3478 ql_dbg(ql_dbg_mbx
, vha
, 0x109c, "Failed=%x.\n", rval
);
3480 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x109d,
3481 "Done %s.\n", __func__
);
3488 qla2x00_write_serdes_word(scsi_qla_host_t
*vha
, uint16_t addr
, uint16_t data
)
3492 mbx_cmd_t
*mcp
= &mc
;
3494 if (!IS_QLA25XX(vha
->hw
) && !IS_QLA2031(vha
->hw
) &&
3495 !IS_QLA27XX(vha
->hw
) && !IS_QLA28XX(vha
->hw
))
3496 return QLA_FUNCTION_FAILED
;
3498 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x1182,
3499 "Entered %s.\n", __func__
);
3501 mcp
->mb
[0] = MBC_WRITE_SERDES
;
3503 if (IS_QLA2031(vha
->hw
))
3504 mcp
->mb
[2] = data
& 0xff;
3509 mcp
->out_mb
= MBX_3
|MBX_2
|MBX_1
|MBX_0
;
3511 mcp
->tov
= MBX_TOV_SECONDS
;
3513 rval
= qla2x00_mailbox_command(vha
, mcp
);
3515 if (rval
!= QLA_SUCCESS
) {
3516 ql_dbg(ql_dbg_mbx
, vha
, 0x1183,
3517 "Failed=%x mb[0]=%x.\n", rval
, mcp
->mb
[0]);
3519 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x1184,
3520 "Done %s.\n", __func__
);
3527 qla2x00_read_serdes_word(scsi_qla_host_t
*vha
, uint16_t addr
, uint16_t *data
)
3531 mbx_cmd_t
*mcp
= &mc
;
3533 if (!IS_QLA25XX(vha
->hw
) && !IS_QLA2031(vha
->hw
) &&
3534 !IS_QLA27XX(vha
->hw
) && !IS_QLA28XX(vha
->hw
))
3535 return QLA_FUNCTION_FAILED
;
3537 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x1185,
3538 "Entered %s.\n", __func__
);
3540 mcp
->mb
[0] = MBC_READ_SERDES
;
3543 mcp
->out_mb
= MBX_3
|MBX_1
|MBX_0
;
3544 mcp
->in_mb
= MBX_1
|MBX_0
;
3545 mcp
->tov
= MBX_TOV_SECONDS
;
3547 rval
= qla2x00_mailbox_command(vha
, mcp
);
3549 if (IS_QLA2031(vha
->hw
))
3550 *data
= mcp
->mb
[1] & 0xff;
3554 if (rval
!= QLA_SUCCESS
) {
3555 ql_dbg(ql_dbg_mbx
, vha
, 0x1186,
3556 "Failed=%x mb[0]=%x.\n", rval
, mcp
->mb
[0]);
3558 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x1187,
3559 "Done %s.\n", __func__
);
3566 qla8044_write_serdes_word(scsi_qla_host_t
*vha
, uint32_t addr
, uint32_t data
)
3570 mbx_cmd_t
*mcp
= &mc
;
3572 if (!IS_QLA8044(vha
->hw
))
3573 return QLA_FUNCTION_FAILED
;
3575 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x11a0,
3576 "Entered %s.\n", __func__
);
3578 mcp
->mb
[0] = MBC_SET_GET_ETH_SERDES_REG
;
3579 mcp
->mb
[1] = HCS_WRITE_SERDES
;
3580 mcp
->mb
[3] = LSW(addr
);
3581 mcp
->mb
[4] = MSW(addr
);
3582 mcp
->mb
[5] = LSW(data
);
3583 mcp
->mb
[6] = MSW(data
);
3584 mcp
->out_mb
= MBX_6
|MBX_5
|MBX_4
|MBX_3
|MBX_1
|MBX_0
;
3586 mcp
->tov
= MBX_TOV_SECONDS
;
3588 rval
= qla2x00_mailbox_command(vha
, mcp
);
3590 if (rval
!= QLA_SUCCESS
) {
3591 ql_dbg(ql_dbg_mbx
, vha
, 0x11a1,
3592 "Failed=%x mb[0]=%x.\n", rval
, mcp
->mb
[0]);
3594 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x1188,
3595 "Done %s.\n", __func__
);
3602 qla8044_read_serdes_word(scsi_qla_host_t
*vha
, uint32_t addr
, uint32_t *data
)
3606 mbx_cmd_t
*mcp
= &mc
;
3608 if (!IS_QLA8044(vha
->hw
))
3609 return QLA_FUNCTION_FAILED
;
3611 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x1189,
3612 "Entered %s.\n", __func__
);
3614 mcp
->mb
[0] = MBC_SET_GET_ETH_SERDES_REG
;
3615 mcp
->mb
[1] = HCS_READ_SERDES
;
3616 mcp
->mb
[3] = LSW(addr
);
3617 mcp
->mb
[4] = MSW(addr
);
3618 mcp
->out_mb
= MBX_4
|MBX_3
|MBX_1
|MBX_0
;
3619 mcp
->in_mb
= MBX_2
|MBX_1
|MBX_0
;
3620 mcp
->tov
= MBX_TOV_SECONDS
;
3622 rval
= qla2x00_mailbox_command(vha
, mcp
);
3624 *data
= mcp
->mb
[2] << 16 | mcp
->mb
[1];
3626 if (rval
!= QLA_SUCCESS
) {
3627 ql_dbg(ql_dbg_mbx
, vha
, 0x118a,
3628 "Failed=%x mb[0]=%x.\n", rval
, mcp
->mb
[0]);
3630 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x118b,
3631 "Done %s.\n", __func__
);
3638 * qla2x00_set_serdes_params() -
3640 * @sw_em_1g: serial link options
3641 * @sw_em_2g: serial link options
3642 * @sw_em_4g: serial link options
3647 qla2x00_set_serdes_params(scsi_qla_host_t
*vha
, uint16_t sw_em_1g
,
3648 uint16_t sw_em_2g
, uint16_t sw_em_4g
)
3652 mbx_cmd_t
*mcp
= &mc
;
3654 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x109e,
3655 "Entered %s.\n", __func__
);
3657 mcp
->mb
[0] = MBC_SERDES_PARAMS
;
3659 mcp
->mb
[2] = sw_em_1g
| BIT_15
;
3660 mcp
->mb
[3] = sw_em_2g
| BIT_15
;
3661 mcp
->mb
[4] = sw_em_4g
| BIT_15
;
3662 mcp
->out_mb
= MBX_4
|MBX_3
|MBX_2
|MBX_1
|MBX_0
;
3664 mcp
->tov
= MBX_TOV_SECONDS
;
3666 rval
= qla2x00_mailbox_command(vha
, mcp
);
3668 if (rval
!= QLA_SUCCESS
) {
3670 ql_dbg(ql_dbg_mbx
, vha
, 0x109f,
3671 "Failed=%x mb[0]=%x.\n", rval
, mcp
->mb
[0]);
3674 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x10a0,
3675 "Done %s.\n", __func__
);
3682 qla2x00_stop_firmware(scsi_qla_host_t
*vha
)
3686 mbx_cmd_t
*mcp
= &mc
;
3688 if (!IS_FWI2_CAPABLE(vha
->hw
))
3689 return QLA_FUNCTION_FAILED
;
3691 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x10a1,
3692 "Entered %s.\n", __func__
);
3694 mcp
->mb
[0] = MBC_STOP_FIRMWARE
;
3696 mcp
->out_mb
= MBX_1
|MBX_0
;
3700 rval
= qla2x00_mailbox_command(vha
, mcp
);
3702 if (rval
!= QLA_SUCCESS
) {
3703 ql_dbg(ql_dbg_mbx
, vha
, 0x10a2, "Failed=%x.\n", rval
);
3704 if (mcp
->mb
[0] == MBS_INVALID_COMMAND
)
3705 rval
= QLA_INVALID_COMMAND
;
3707 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x10a3,
3708 "Done %s.\n", __func__
);
3715 qla2x00_enable_eft_trace(scsi_qla_host_t
*vha
, dma_addr_t eft_dma
,
3720 mbx_cmd_t
*mcp
= &mc
;
3722 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x10a4,
3723 "Entered %s.\n", __func__
);
3725 if (!IS_FWI2_CAPABLE(vha
->hw
))
3726 return QLA_FUNCTION_FAILED
;
3728 if (unlikely(pci_channel_offline(vha
->hw
->pdev
)))
3729 return QLA_FUNCTION_FAILED
;
3731 mcp
->mb
[0] = MBC_TRACE_CONTROL
;
3732 mcp
->mb
[1] = TC_EFT_ENABLE
;
3733 mcp
->mb
[2] = LSW(eft_dma
);
3734 mcp
->mb
[3] = MSW(eft_dma
);
3735 mcp
->mb
[4] = LSW(MSD(eft_dma
));
3736 mcp
->mb
[5] = MSW(MSD(eft_dma
));
3737 mcp
->mb
[6] = buffers
;
3738 mcp
->mb
[7] = TC_AEN_DISABLE
;
3739 mcp
->out_mb
= MBX_7
|MBX_6
|MBX_5
|MBX_4
|MBX_3
|MBX_2
|MBX_1
|MBX_0
;
3740 mcp
->in_mb
= MBX_1
|MBX_0
;
3741 mcp
->tov
= MBX_TOV_SECONDS
;
3743 rval
= qla2x00_mailbox_command(vha
, mcp
);
3744 if (rval
!= QLA_SUCCESS
) {
3745 ql_dbg(ql_dbg_mbx
, vha
, 0x10a5,
3746 "Failed=%x mb[0]=%x mb[1]=%x.\n",
3747 rval
, mcp
->mb
[0], mcp
->mb
[1]);
3749 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x10a6,
3750 "Done %s.\n", __func__
);
3757 qla2x00_disable_eft_trace(scsi_qla_host_t
*vha
)
3761 mbx_cmd_t
*mcp
= &mc
;
3763 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x10a7,
3764 "Entered %s.\n", __func__
);
3766 if (!IS_FWI2_CAPABLE(vha
->hw
))
3767 return QLA_FUNCTION_FAILED
;
3769 if (unlikely(pci_channel_offline(vha
->hw
->pdev
)))
3770 return QLA_FUNCTION_FAILED
;
3772 mcp
->mb
[0] = MBC_TRACE_CONTROL
;
3773 mcp
->mb
[1] = TC_EFT_DISABLE
;
3774 mcp
->out_mb
= MBX_1
|MBX_0
;
3775 mcp
->in_mb
= MBX_1
|MBX_0
;
3776 mcp
->tov
= MBX_TOV_SECONDS
;
3778 rval
= qla2x00_mailbox_command(vha
, mcp
);
3779 if (rval
!= QLA_SUCCESS
) {
3780 ql_dbg(ql_dbg_mbx
, vha
, 0x10a8,
3781 "Failed=%x mb[0]=%x mb[1]=%x.\n",
3782 rval
, mcp
->mb
[0], mcp
->mb
[1]);
3784 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x10a9,
3785 "Done %s.\n", __func__
);
3792 qla2x00_enable_fce_trace(scsi_qla_host_t
*vha
, dma_addr_t fce_dma
,
3793 uint16_t buffers
, uint16_t *mb
, uint32_t *dwords
)
3797 mbx_cmd_t
*mcp
= &mc
;
3799 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x10aa,
3800 "Entered %s.\n", __func__
);
3802 if (!IS_QLA25XX(vha
->hw
) && !IS_QLA81XX(vha
->hw
) &&
3803 !IS_QLA83XX(vha
->hw
) && !IS_QLA27XX(vha
->hw
) &&
3804 !IS_QLA28XX(vha
->hw
))
3805 return QLA_FUNCTION_FAILED
;
3807 if (unlikely(pci_channel_offline(vha
->hw
->pdev
)))
3808 return QLA_FUNCTION_FAILED
;
3810 mcp
->mb
[0] = MBC_TRACE_CONTROL
;
3811 mcp
->mb
[1] = TC_FCE_ENABLE
;
3812 mcp
->mb
[2] = LSW(fce_dma
);
3813 mcp
->mb
[3] = MSW(fce_dma
);
3814 mcp
->mb
[4] = LSW(MSD(fce_dma
));
3815 mcp
->mb
[5] = MSW(MSD(fce_dma
));
3816 mcp
->mb
[6] = buffers
;
3817 mcp
->mb
[7] = TC_AEN_DISABLE
;
3819 mcp
->mb
[9] = TC_FCE_DEFAULT_RX_SIZE
;
3820 mcp
->mb
[10] = TC_FCE_DEFAULT_TX_SIZE
;
3821 mcp
->out_mb
= MBX_10
|MBX_9
|MBX_8
|MBX_7
|MBX_6
|MBX_5
|MBX_4
|MBX_3
|MBX_2
|
3823 mcp
->in_mb
= MBX_6
|MBX_5
|MBX_4
|MBX_3
|MBX_2
|MBX_1
|MBX_0
;
3824 mcp
->tov
= MBX_TOV_SECONDS
;
3826 rval
= qla2x00_mailbox_command(vha
, mcp
);
3827 if (rval
!= QLA_SUCCESS
) {
3828 ql_dbg(ql_dbg_mbx
, vha
, 0x10ab,
3829 "Failed=%x mb[0]=%x mb[1]=%x.\n",
3830 rval
, mcp
->mb
[0], mcp
->mb
[1]);
3832 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x10ac,
3833 "Done %s.\n", __func__
);
3836 memcpy(mb
, mcp
->mb
, 8 * sizeof(*mb
));
3845 qla2x00_disable_fce_trace(scsi_qla_host_t
*vha
, uint64_t *wr
, uint64_t *rd
)
3849 mbx_cmd_t
*mcp
= &mc
;
3851 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x10ad,
3852 "Entered %s.\n", __func__
);
3854 if (!IS_FWI2_CAPABLE(vha
->hw
))
3855 return QLA_FUNCTION_FAILED
;
3857 if (unlikely(pci_channel_offline(vha
->hw
->pdev
)))
3858 return QLA_FUNCTION_FAILED
;
3860 mcp
->mb
[0] = MBC_TRACE_CONTROL
;
3861 mcp
->mb
[1] = TC_FCE_DISABLE
;
3862 mcp
->mb
[2] = TC_FCE_DISABLE_TRACE
;
3863 mcp
->out_mb
= MBX_2
|MBX_1
|MBX_0
;
3864 mcp
->in_mb
= MBX_9
|MBX_8
|MBX_7
|MBX_6
|MBX_5
|MBX_4
|MBX_3
|MBX_2
|
3866 mcp
->tov
= MBX_TOV_SECONDS
;
3868 rval
= qla2x00_mailbox_command(vha
, mcp
);
3869 if (rval
!= QLA_SUCCESS
) {
3870 ql_dbg(ql_dbg_mbx
, vha
, 0x10ae,
3871 "Failed=%x mb[0]=%x mb[1]=%x.\n",
3872 rval
, mcp
->mb
[0], mcp
->mb
[1]);
3874 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x10af,
3875 "Done %s.\n", __func__
);
3878 *wr
= (uint64_t) mcp
->mb
[5] << 48 |
3879 (uint64_t) mcp
->mb
[4] << 32 |
3880 (uint64_t) mcp
->mb
[3] << 16 |
3881 (uint64_t) mcp
->mb
[2];
3883 *rd
= (uint64_t) mcp
->mb
[9] << 48 |
3884 (uint64_t) mcp
->mb
[8] << 32 |
3885 (uint64_t) mcp
->mb
[7] << 16 |
3886 (uint64_t) mcp
->mb
[6];
3893 qla2x00_get_idma_speed(scsi_qla_host_t
*vha
, uint16_t loop_id
,
3894 uint16_t *port_speed
, uint16_t *mb
)
3898 mbx_cmd_t
*mcp
= &mc
;
3900 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x10b0,
3901 "Entered %s.\n", __func__
);
3903 if (!IS_IIDMA_CAPABLE(vha
->hw
))
3904 return QLA_FUNCTION_FAILED
;
3906 mcp
->mb
[0] = MBC_PORT_PARAMS
;
3907 mcp
->mb
[1] = loop_id
;
3908 mcp
->mb
[2] = mcp
->mb
[3] = 0;
3909 mcp
->mb
[9] = vha
->vp_idx
;
3910 mcp
->out_mb
= MBX_9
|MBX_3
|MBX_2
|MBX_1
|MBX_0
;
3911 mcp
->in_mb
= MBX_3
|MBX_1
|MBX_0
;
3912 mcp
->tov
= MBX_TOV_SECONDS
;
3914 rval
= qla2x00_mailbox_command(vha
, mcp
);
3916 /* Return mailbox statuses. */
3923 if (rval
!= QLA_SUCCESS
) {
3924 ql_dbg(ql_dbg_mbx
, vha
, 0x10b1, "Failed=%x.\n", rval
);
3926 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x10b2,
3927 "Done %s.\n", __func__
);
3929 *port_speed
= mcp
->mb
[3];
3936 qla2x00_set_idma_speed(scsi_qla_host_t
*vha
, uint16_t loop_id
,
3937 uint16_t port_speed
, uint16_t *mb
)
3941 mbx_cmd_t
*mcp
= &mc
;
3943 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x10b3,
3944 "Entered %s.\n", __func__
);
3946 if (!IS_IIDMA_CAPABLE(vha
->hw
))
3947 return QLA_FUNCTION_FAILED
;
3949 mcp
->mb
[0] = MBC_PORT_PARAMS
;
3950 mcp
->mb
[1] = loop_id
;
3952 mcp
->mb
[3] = port_speed
& 0x3F;
3953 mcp
->mb
[9] = vha
->vp_idx
;
3954 mcp
->out_mb
= MBX_9
|MBX_3
|MBX_2
|MBX_1
|MBX_0
;
3955 mcp
->in_mb
= MBX_3
|MBX_1
|MBX_0
;
3956 mcp
->tov
= MBX_TOV_SECONDS
;
3958 rval
= qla2x00_mailbox_command(vha
, mcp
);
3960 /* Return mailbox statuses. */
3967 if (rval
!= QLA_SUCCESS
) {
3968 ql_dbg(ql_dbg_mbx
, vha
, 0x10b4,
3969 "Failed=%x.\n", rval
);
3971 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x10b5,
3972 "Done %s.\n", __func__
);
3979 qla24xx_report_id_acquisition(scsi_qla_host_t
*vha
,
3980 struct vp_rpt_id_entry_24xx
*rptid_entry
)
3982 struct qla_hw_data
*ha
= vha
->hw
;
3983 scsi_qla_host_t
*vp
= NULL
;
3984 unsigned long flags
;
3987 struct fc_port
*fcport
;
3989 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x10b6,
3990 "Entered %s.\n", __func__
);
3992 if (rptid_entry
->entry_status
!= 0)
3995 id
.b
.domain
= rptid_entry
->port_id
[2];
3996 id
.b
.area
= rptid_entry
->port_id
[1];
3997 id
.b
.al_pa
= rptid_entry
->port_id
[0];
3999 ha
->flags
.n2n_ae
= 0;
4001 if (rptid_entry
->format
== 0) {
4003 ql_dbg(ql_dbg_async
, vha
, 0x10b7,
4004 "Format 0 : Number of VPs setup %d, number of "
4005 "VPs acquired %d.\n", rptid_entry
->vp_setup
,
4006 rptid_entry
->vp_acquired
);
4007 ql_dbg(ql_dbg_async
, vha
, 0x10b8,
4008 "Primary port id %02x%02x%02x.\n",
4009 rptid_entry
->port_id
[2], rptid_entry
->port_id
[1],
4010 rptid_entry
->port_id
[0]);
4011 ha
->current_topology
= ISP_CFG_NL
;
4012 qla_update_host_map(vha
, id
);
4014 } else if (rptid_entry
->format
== 1) {
4016 ql_dbg(ql_dbg_async
, vha
, 0x10b9,
4017 "Format 1: VP[%d] enabled - status %d - with "
4018 "port id %02x%02x%02x.\n", rptid_entry
->vp_idx
,
4019 rptid_entry
->vp_status
,
4020 rptid_entry
->port_id
[2], rptid_entry
->port_id
[1],
4021 rptid_entry
->port_id
[0]);
4022 ql_dbg(ql_dbg_async
, vha
, 0x5075,
4023 "Format 1: Remote WWPN %8phC.\n",
4024 rptid_entry
->u
.f1
.port_name
);
4026 ql_dbg(ql_dbg_async
, vha
, 0x5075,
4027 "Format 1: WWPN %8phC.\n",
4030 switch (rptid_entry
->u
.f1
.flags
& TOPO_MASK
) {
4032 ha
->current_topology
= ISP_CFG_N
;
4033 spin_lock_irqsave(&vha
->hw
->tgt
.sess_lock
, flags
);
4034 list_for_each_entry(fcport
, &vha
->vp_fcports
, list
) {
4035 fcport
->scan_state
= QLA_FCPORT_SCAN
;
4036 fcport
->n2n_flag
= 0;
4039 if (wwn_to_u64(vha
->port_name
) >
4040 wwn_to_u64(rptid_entry
->u
.f1
.port_name
)) {
4042 vha
->d_id
.b
.al_pa
= 1;
4043 ha
->flags
.n2n_bigger
= 1;
4046 ql_dbg(ql_dbg_async
, vha
, 0x5075,
4047 "Format 1: assign local id %x remote id %x\n",
4048 vha
->d_id
.b24
, id
.b24
);
4050 ql_dbg(ql_dbg_async
, vha
, 0x5075,
4051 "Format 1: Remote login - Waiting for WWPN %8phC.\n",
4052 rptid_entry
->u
.f1
.port_name
);
4053 ha
->flags
.n2n_bigger
= 0;
4056 fcport
= qla2x00_find_fcport_by_wwpn(vha
,
4057 rptid_entry
->u
.f1
.port_name
, 1);
4058 spin_unlock_irqrestore(&vha
->hw
->tgt
.sess_lock
, flags
);
4062 fcport
->plogi_nack_done_deadline
= jiffies
+ HZ
;
4063 fcport
->dm_login_expire
= jiffies
+
4064 QLA_N2N_WAIT_TIME
* HZ
;
4065 fcport
->scan_state
= QLA_FCPORT_FOUND
;
4066 fcport
->n2n_flag
= 1;
4067 fcport
->keep_nport_handle
= 1;
4068 fcport
->login_retry
= vha
->hw
->login_retry_count
;
4069 fcport
->fc4_type
= FS_FC4TYPE_FCP
;
4070 if (vha
->flags
.nvme_enabled
)
4071 fcport
->fc4_type
|= FS_FC4TYPE_NVME
;
4073 if (wwn_to_u64(vha
->port_name
) >
4074 wwn_to_u64(fcport
->port_name
)) {
4078 switch (fcport
->disc_state
) {
4080 set_bit(RELOGIN_NEEDED
,
4083 case DSC_DELETE_PEND
:
4086 qlt_schedule_sess_for_deletion(fcport
);
4090 qla24xx_post_newsess_work(vha
, &id
,
4091 rptid_entry
->u
.f1
.port_name
,
4092 rptid_entry
->u
.f1
.node_name
,
4097 /* if our portname is higher then initiate N2N login */
4099 set_bit(N2N_LOGIN_NEEDED
, &vha
->dpc_flags
);
4102 ha
->current_topology
= ISP_CFG_FL
;
4105 ha
->current_topology
= ISP_CFG_F
;
4111 ha
->flags
.gpsc_supported
= 1;
4112 ha
->current_topology
= ISP_CFG_F
;
4113 /* buffer to buffer credit flag */
4114 vha
->flags
.bbcr_enable
= (rptid_entry
->u
.f1
.bbcr
& 0xf) != 0;
4116 if (rptid_entry
->vp_idx
== 0) {
4117 if (rptid_entry
->vp_status
== VP_STAT_COMPL
) {
4118 /* FA-WWN is only for physical port */
4119 if (qla_ini_mode_enabled(vha
) &&
4120 ha
->flags
.fawwpn_enabled
&&
4121 (rptid_entry
->u
.f1
.flags
&
4123 memcpy(vha
->port_name
,
4124 rptid_entry
->u
.f1
.port_name
,
4128 qla_update_host_map(vha
, id
);
4131 set_bit(REGISTER_FC4_NEEDED
, &vha
->dpc_flags
);
4132 set_bit(REGISTER_FDMI_NEEDED
, &vha
->dpc_flags
);
4134 if (rptid_entry
->vp_status
!= VP_STAT_COMPL
&&
4135 rptid_entry
->vp_status
!= VP_STAT_ID_CHG
) {
4136 ql_dbg(ql_dbg_mbx
, vha
, 0x10ba,
4137 "Could not acquire ID for VP[%d].\n",
4138 rptid_entry
->vp_idx
);
4143 spin_lock_irqsave(&ha
->vport_slock
, flags
);
4144 list_for_each_entry(vp
, &ha
->vp_list
, list
) {
4145 if (rptid_entry
->vp_idx
== vp
->vp_idx
) {
4150 spin_unlock_irqrestore(&ha
->vport_slock
, flags
);
4155 qla_update_host_map(vp
, id
);
4158 * Cannot configure here as we are still sitting on the
4159 * response queue. Handle it in dpc context.
4161 set_bit(VP_IDX_ACQUIRED
, &vp
->vp_flags
);
4162 set_bit(REGISTER_FC4_NEEDED
, &vp
->dpc_flags
);
4163 set_bit(REGISTER_FDMI_NEEDED
, &vp
->dpc_flags
);
4165 set_bit(VP_DPC_NEEDED
, &vha
->dpc_flags
);
4166 qla2xxx_wake_dpc(vha
);
4167 } else if (rptid_entry
->format
== 2) {
4168 ql_dbg(ql_dbg_async
, vha
, 0x505f,
4169 "RIDA: format 2/N2N Primary port id %02x%02x%02x.\n",
4170 rptid_entry
->port_id
[2], rptid_entry
->port_id
[1],
4171 rptid_entry
->port_id
[0]);
4173 ql_dbg(ql_dbg_async
, vha
, 0x5075,
4174 "N2N: Remote WWPN %8phC.\n",
4175 rptid_entry
->u
.f2
.port_name
);
4177 /* N2N. direct connect */
4178 ha
->current_topology
= ISP_CFG_N
;
4179 ha
->flags
.rida_fmt2
= 1;
4180 vha
->d_id
.b
.domain
= rptid_entry
->port_id
[2];
4181 vha
->d_id
.b
.area
= rptid_entry
->port_id
[1];
4182 vha
->d_id
.b
.al_pa
= rptid_entry
->port_id
[0];
4184 ha
->flags
.n2n_ae
= 1;
4185 spin_lock_irqsave(&ha
->vport_slock
, flags
);
4186 qla_update_vp_map(vha
, SET_AL_PA
);
4187 spin_unlock_irqrestore(&ha
->vport_slock
, flags
);
4189 list_for_each_entry(fcport
, &vha
->vp_fcports
, list
) {
4190 fcport
->scan_state
= QLA_FCPORT_SCAN
;
4191 fcport
->n2n_flag
= 0;
4194 fcport
= qla2x00_find_fcport_by_wwpn(vha
,
4195 rptid_entry
->u
.f2
.port_name
, 1);
4198 fcport
->login_retry
= vha
->hw
->login_retry_count
;
4199 fcport
->plogi_nack_done_deadline
= jiffies
+ HZ
;
4200 fcport
->scan_state
= QLA_FCPORT_FOUND
;
4201 fcport
->keep_nport_handle
= 1;
4202 fcport
->n2n_flag
= 1;
4203 fcport
->d_id
.b
.domain
=
4204 rptid_entry
->u
.f2
.remote_nport_id
[2];
4205 fcport
->d_id
.b
.area
=
4206 rptid_entry
->u
.f2
.remote_nport_id
[1];
4207 fcport
->d_id
.b
.al_pa
=
4208 rptid_entry
->u
.f2
.remote_nport_id
[0];
4211 * For the case where remote port sending PRLO, FW
4212 * sends up RIDA Format 2 as an indication of session
4213 * loss. In other word, FW state change from PRLI
4214 * complete back to PLOGI complete. Delete the
4215 * session and let relogin drive the reconnect.
4217 if (atomic_read(&fcport
->state
) == FCS_ONLINE
)
4218 qlt_schedule_sess_for_deletion(fcport
);
4224 * qla24xx_modify_vp_config
4225 * Change VP configuration for vha
4228 * vha = adapter block pointer.
4231 * qla2xxx local function return status code.
4237 qla24xx_modify_vp_config(scsi_qla_host_t
*vha
)
4240 struct vp_config_entry_24xx
*vpmod
;
4241 dma_addr_t vpmod_dma
;
4242 struct qla_hw_data
*ha
= vha
->hw
;
4243 struct scsi_qla_host
*base_vha
= pci_get_drvdata(ha
->pdev
);
4245 /* This can be called by the parent */
4247 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x10bb,
4248 "Entered %s.\n", __func__
);
4250 vpmod
= dma_pool_zalloc(ha
->s_dma_pool
, GFP_KERNEL
, &vpmod_dma
);
4252 ql_log(ql_log_warn
, vha
, 0x10bc,
4253 "Failed to allocate modify VP IOCB.\n");
4254 return QLA_MEMORY_ALLOC_FAILED
;
4257 vpmod
->entry_type
= VP_CONFIG_IOCB_TYPE
;
4258 vpmod
->entry_count
= 1;
4259 vpmod
->command
= VCT_COMMAND_MOD_ENABLE_VPS
;
4260 vpmod
->vp_count
= 1;
4261 vpmod
->vp_index1
= vha
->vp_idx
;
4262 vpmod
->options_idx1
= BIT_3
|BIT_4
|BIT_5
;
4264 qlt_modify_vp_config(vha
, vpmod
);
4266 memcpy(vpmod
->node_name_idx1
, vha
->node_name
, WWN_SIZE
);
4267 memcpy(vpmod
->port_name_idx1
, vha
->port_name
, WWN_SIZE
);
4268 vpmod
->entry_count
= 1;
4270 rval
= qla2x00_issue_iocb(base_vha
, vpmod
, vpmod_dma
, 0);
4271 if (rval
!= QLA_SUCCESS
) {
4272 ql_dbg(ql_dbg_mbx
, vha
, 0x10bd,
4273 "Failed to issue VP config IOCB (%x).\n", rval
);
4274 } else if (vpmod
->comp_status
!= 0) {
4275 ql_dbg(ql_dbg_mbx
, vha
, 0x10be,
4276 "Failed to complete IOCB -- error status (%x).\n",
4277 vpmod
->comp_status
);
4278 rval
= QLA_FUNCTION_FAILED
;
4279 } else if (vpmod
->comp_status
!= cpu_to_le16(CS_COMPLETE
)) {
4280 ql_dbg(ql_dbg_mbx
, vha
, 0x10bf,
4281 "Failed to complete IOCB -- completion status (%x).\n",
4282 le16_to_cpu(vpmod
->comp_status
));
4283 rval
= QLA_FUNCTION_FAILED
;
4286 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x10c0,
4287 "Done %s.\n", __func__
);
4288 fc_vport_set_state(vha
->fc_vport
, FC_VPORT_INITIALIZING
);
4290 dma_pool_free(ha
->s_dma_pool
, vpmod
, vpmod_dma
);
4296 * qla2x00_send_change_request
4297 * Receive or disable RSCN request from fabric controller
4300 * ha = adapter block pointer
4301 * format = registration format:
4303 * 1 - Fabric detected registration
4304 * 2 - N_port detected registration
4305 * 3 - Full registration
4306 * FF - clear registration
4307 * vp_idx = Virtual port index
4310 * qla2x00 local function return status code.
4317 qla2x00_send_change_request(scsi_qla_host_t
*vha
, uint16_t format
,
4322 mbx_cmd_t
*mcp
= &mc
;
4324 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x10c7,
4325 "Entered %s.\n", __func__
);
4327 mcp
->mb
[0] = MBC_SEND_CHANGE_REQUEST
;
4328 mcp
->mb
[1] = format
;
4329 mcp
->mb
[9] = vp_idx
;
4330 mcp
->out_mb
= MBX_9
|MBX_1
|MBX_0
;
4331 mcp
->in_mb
= MBX_0
|MBX_1
;
4332 mcp
->tov
= MBX_TOV_SECONDS
;
4334 rval
= qla2x00_mailbox_command(vha
, mcp
);
4336 if (rval
== QLA_SUCCESS
) {
4337 if (mcp
->mb
[0] != MBS_COMMAND_COMPLETE
) {
4347 qla2x00_dump_ram(scsi_qla_host_t
*vha
, dma_addr_t req_dma
, uint32_t addr
,
4352 mbx_cmd_t
*mcp
= &mc
;
4354 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x1009,
4355 "Entered %s.\n", __func__
);
4357 if (MSW(addr
) || IS_FWI2_CAPABLE(vha
->hw
)) {
4358 mcp
->mb
[0] = MBC_DUMP_RISC_RAM_EXTENDED
;
4359 mcp
->mb
[8] = MSW(addr
);
4361 mcp
->out_mb
= MBX_10
|MBX_8
|MBX_0
;
4363 mcp
->mb
[0] = MBC_DUMP_RISC_RAM
;
4364 mcp
->out_mb
= MBX_0
;
4366 mcp
->mb
[1] = LSW(addr
);
4367 mcp
->mb
[2] = MSW(req_dma
);
4368 mcp
->mb
[3] = LSW(req_dma
);
4369 mcp
->mb
[6] = MSW(MSD(req_dma
));
4370 mcp
->mb
[7] = LSW(MSD(req_dma
));
4371 mcp
->out_mb
|= MBX_7
|MBX_6
|MBX_3
|MBX_2
|MBX_1
;
4372 if (IS_FWI2_CAPABLE(vha
->hw
)) {
4373 mcp
->mb
[4] = MSW(size
);
4374 mcp
->mb
[5] = LSW(size
);
4375 mcp
->out_mb
|= MBX_5
|MBX_4
;
4377 mcp
->mb
[4] = LSW(size
);
4378 mcp
->out_mb
|= MBX_4
;
4382 mcp
->tov
= MBX_TOV_SECONDS
;
4384 rval
= qla2x00_mailbox_command(vha
, mcp
);
4386 if (rval
!= QLA_SUCCESS
) {
4387 ql_dbg(ql_dbg_mbx
, vha
, 0x1008,
4388 "Failed=%x mb[0]=%x.\n", rval
, mcp
->mb
[0]);
4390 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x1007,
4391 "Done %s.\n", __func__
);
4396 /* 84XX Support **************************************************************/
4398 struct cs84xx_mgmt_cmd
{
4400 struct verify_chip_entry_84xx req
;
4401 struct verify_chip_rsp_84xx rsp
;
4406 qla84xx_verify_chip(struct scsi_qla_host
*vha
, uint16_t *status
)
4409 struct cs84xx_mgmt_cmd
*mn
;
4412 unsigned long flags
;
4413 struct qla_hw_data
*ha
= vha
->hw
;
4415 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x10c8,
4416 "Entered %s.\n", __func__
);
4418 mn
= dma_pool_alloc(ha
->s_dma_pool
, GFP_KERNEL
, &mn_dma
);
4420 return QLA_MEMORY_ALLOC_FAILED
;
4424 options
= ha
->cs84xx
->fw_update
? VCO_FORCE_UPDATE
: 0;
4425 /* Diagnostic firmware? */
4426 /* options |= MENLO_DIAG_FW; */
4427 /* We update the firmware with only one data sequence. */
4428 options
|= VCO_END_OF_DATA
;
4432 memset(mn
, 0, sizeof(*mn
));
4433 mn
->p
.req
.entry_type
= VERIFY_CHIP_IOCB_TYPE
;
4434 mn
->p
.req
.entry_count
= 1;
4435 mn
->p
.req
.options
= cpu_to_le16(options
);
4437 ql_dbg(ql_dbg_mbx
+ ql_dbg_buffer
, vha
, 0x111c,
4438 "Dump of Verify Request.\n");
4439 ql_dump_buffer(ql_dbg_mbx
+ ql_dbg_buffer
, vha
, 0x111e,
4442 rval
= qla2x00_issue_iocb_timeout(vha
, mn
, mn_dma
, 0, 120);
4443 if (rval
!= QLA_SUCCESS
) {
4444 ql_dbg(ql_dbg_mbx
, vha
, 0x10cb,
4445 "Failed to issue verify IOCB (%x).\n", rval
);
4449 ql_dbg(ql_dbg_mbx
+ ql_dbg_buffer
, vha
, 0x1110,
4450 "Dump of Verify Response.\n");
4451 ql_dump_buffer(ql_dbg_mbx
+ ql_dbg_buffer
, vha
, 0x1118,
4454 status
[0] = le16_to_cpu(mn
->p
.rsp
.comp_status
);
4455 status
[1] = status
[0] == CS_VCS_CHIP_FAILURE
?
4456 le16_to_cpu(mn
->p
.rsp
.failure_code
) : 0;
4457 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x10ce,
4458 "cs=%x fc=%x.\n", status
[0], status
[1]);
4460 if (status
[0] != CS_COMPLETE
) {
4461 rval
= QLA_FUNCTION_FAILED
;
4462 if (!(options
& VCO_DONT_UPDATE_FW
)) {
4463 ql_dbg(ql_dbg_mbx
, vha
, 0x10cf,
4464 "Firmware update failed. Retrying "
4465 "without update firmware.\n");
4466 options
|= VCO_DONT_UPDATE_FW
;
4467 options
&= ~VCO_FORCE_UPDATE
;
4471 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x10d0,
4472 "Firmware updated to %x.\n",
4473 le32_to_cpu(mn
->p
.rsp
.fw_ver
));
4475 /* NOTE: we only update OP firmware. */
4476 spin_lock_irqsave(&ha
->cs84xx
->access_lock
, flags
);
4477 ha
->cs84xx
->op_fw_version
=
4478 le32_to_cpu(mn
->p
.rsp
.fw_ver
);
4479 spin_unlock_irqrestore(&ha
->cs84xx
->access_lock
,
4485 dma_pool_free(ha
->s_dma_pool
, mn
, mn_dma
);
4487 if (rval
!= QLA_SUCCESS
) {
4488 ql_dbg(ql_dbg_mbx
, vha
, 0x10d1,
4489 "Failed=%x.\n", rval
);
4491 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x10d2,
4492 "Done %s.\n", __func__
);
4499 qla25xx_init_req_que(struct scsi_qla_host
*vha
, struct req_que
*req
)
4502 unsigned long flags
;
4504 mbx_cmd_t
*mcp
= &mc
;
4505 struct qla_hw_data
*ha
= vha
->hw
;
4507 if (!ha
->flags
.fw_started
)
4510 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x10d3,
4511 "Entered %s.\n", __func__
);
4513 if (IS_SHADOW_REG_CAPABLE(ha
))
4514 req
->options
|= BIT_13
;
4516 mcp
->mb
[0] = MBC_INITIALIZE_MULTIQ
;
4517 mcp
->mb
[1] = req
->options
;
4518 mcp
->mb
[2] = MSW(LSD(req
->dma
));
4519 mcp
->mb
[3] = LSW(LSD(req
->dma
));
4520 mcp
->mb
[6] = MSW(MSD(req
->dma
));
4521 mcp
->mb
[7] = LSW(MSD(req
->dma
));
4522 mcp
->mb
[5] = req
->length
;
4524 mcp
->mb
[10] = req
->rsp
->id
;
4525 mcp
->mb
[12] = req
->qos
;
4526 mcp
->mb
[11] = req
->vp_idx
;
4527 mcp
->mb
[13] = req
->rid
;
4528 if (IS_QLA83XX(ha
) || IS_QLA27XX(ha
) || IS_QLA28XX(ha
))
4531 mcp
->mb
[4] = req
->id
;
4532 /* que in ptr index */
4534 /* que out ptr index */
4535 mcp
->mb
[9] = *req
->out_ptr
= 0;
4536 mcp
->out_mb
= MBX_14
|MBX_13
|MBX_12
|MBX_11
|MBX_10
|MBX_9
|MBX_8
|MBX_7
|
4537 MBX_6
|MBX_5
|MBX_4
|MBX_3
|MBX_2
|MBX_1
|MBX_0
;
4539 mcp
->flags
= MBX_DMA_OUT
;
4540 mcp
->tov
= MBX_TOV_SECONDS
* 2;
4542 if (IS_QLA81XX(ha
) || IS_QLA83XX(ha
) || IS_QLA27XX(ha
) ||
4544 mcp
->in_mb
|= MBX_1
;
4545 if (IS_QLA83XX(ha
) || IS_QLA27XX(ha
) || IS_QLA28XX(ha
)) {
4546 mcp
->out_mb
|= MBX_15
;
4547 /* debug q create issue in SR-IOV */
4548 mcp
->in_mb
|= MBX_9
| MBX_8
| MBX_7
;
4551 spin_lock_irqsave(&ha
->hardware_lock
, flags
);
4552 if (!(req
->options
& BIT_0
)) {
4553 wrt_reg_dword(req
->req_q_in
, 0);
4554 if (!IS_QLA83XX(ha
) && !IS_QLA27XX(ha
) && !IS_QLA28XX(ha
))
4555 wrt_reg_dword(req
->req_q_out
, 0);
4557 spin_unlock_irqrestore(&ha
->hardware_lock
, flags
);
4559 rval
= qla2x00_mailbox_command(vha
, mcp
);
4560 if (rval
!= QLA_SUCCESS
) {
4561 ql_dbg(ql_dbg_mbx
, vha
, 0x10d4,
4562 "Failed=%x mb[0]=%x.\n", rval
, mcp
->mb
[0]);
4564 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x10d5,
4565 "Done %s.\n", __func__
);
4572 qla25xx_init_rsp_que(struct scsi_qla_host
*vha
, struct rsp_que
*rsp
)
4575 unsigned long flags
;
4577 mbx_cmd_t
*mcp
= &mc
;
4578 struct qla_hw_data
*ha
= vha
->hw
;
4580 if (!ha
->flags
.fw_started
)
4583 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x10d6,
4584 "Entered %s.\n", __func__
);
4586 if (IS_SHADOW_REG_CAPABLE(ha
))
4587 rsp
->options
|= BIT_13
;
4589 mcp
->mb
[0] = MBC_INITIALIZE_MULTIQ
;
4590 mcp
->mb
[1] = rsp
->options
;
4591 mcp
->mb
[2] = MSW(LSD(rsp
->dma
));
4592 mcp
->mb
[3] = LSW(LSD(rsp
->dma
));
4593 mcp
->mb
[6] = MSW(MSD(rsp
->dma
));
4594 mcp
->mb
[7] = LSW(MSD(rsp
->dma
));
4595 mcp
->mb
[5] = rsp
->length
;
4596 mcp
->mb
[14] = rsp
->msix
->entry
;
4597 mcp
->mb
[13] = rsp
->rid
;
4598 if (IS_QLA83XX(ha
) || IS_QLA27XX(ha
) || IS_QLA28XX(ha
))
4601 mcp
->mb
[4] = rsp
->id
;
4602 /* que in ptr index */
4603 mcp
->mb
[8] = *rsp
->in_ptr
= 0;
4604 /* que out ptr index */
4606 mcp
->out_mb
= MBX_14
|MBX_13
|MBX_9
|MBX_8
|MBX_7
4607 |MBX_6
|MBX_5
|MBX_4
|MBX_3
|MBX_2
|MBX_1
|MBX_0
;
4609 mcp
->flags
= MBX_DMA_OUT
;
4610 mcp
->tov
= MBX_TOV_SECONDS
* 2;
4612 if (IS_QLA81XX(ha
)) {
4613 mcp
->out_mb
|= MBX_12
|MBX_11
|MBX_10
;
4614 mcp
->in_mb
|= MBX_1
;
4615 } else if (IS_QLA83XX(ha
) || IS_QLA27XX(ha
) || IS_QLA28XX(ha
)) {
4616 mcp
->out_mb
|= MBX_15
|MBX_12
|MBX_11
|MBX_10
;
4617 mcp
->in_mb
|= MBX_1
;
4618 /* debug q create issue in SR-IOV */
4619 mcp
->in_mb
|= MBX_9
| MBX_8
| MBX_7
;
4622 spin_lock_irqsave(&ha
->hardware_lock
, flags
);
4623 if (!(rsp
->options
& BIT_0
)) {
4624 wrt_reg_dword(rsp
->rsp_q_out
, 0);
4625 if (!IS_QLA83XX(ha
) && !IS_QLA27XX(ha
) && !IS_QLA28XX(ha
))
4626 wrt_reg_dword(rsp
->rsp_q_in
, 0);
4629 spin_unlock_irqrestore(&ha
->hardware_lock
, flags
);
4631 rval
= qla2x00_mailbox_command(vha
, mcp
);
4632 if (rval
!= QLA_SUCCESS
) {
4633 ql_dbg(ql_dbg_mbx
, vha
, 0x10d7,
4634 "Failed=%x mb[0]=%x.\n", rval
, mcp
->mb
[0]);
4636 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x10d8,
4637 "Done %s.\n", __func__
);
4644 qla81xx_idc_ack(scsi_qla_host_t
*vha
, uint16_t *mb
)
4648 mbx_cmd_t
*mcp
= &mc
;
4650 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x10d9,
4651 "Entered %s.\n", __func__
);
4653 mcp
->mb
[0] = MBC_IDC_ACK
;
4654 memcpy(&mcp
->mb
[1], mb
, QLA_IDC_ACK_REGS
* sizeof(uint16_t));
4655 mcp
->out_mb
= MBX_7
|MBX_6
|MBX_5
|MBX_4
|MBX_3
|MBX_2
|MBX_1
|MBX_0
;
4657 mcp
->tov
= MBX_TOV_SECONDS
;
4659 rval
= qla2x00_mailbox_command(vha
, mcp
);
4661 if (rval
!= QLA_SUCCESS
) {
4662 ql_dbg(ql_dbg_mbx
, vha
, 0x10da,
4663 "Failed=%x mb[0]=%x.\n", rval
, mcp
->mb
[0]);
4665 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x10db,
4666 "Done %s.\n", __func__
);
4673 qla81xx_fac_get_sector_size(scsi_qla_host_t
*vha
, uint32_t *sector_size
)
4677 mbx_cmd_t
*mcp
= &mc
;
4679 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x10dc,
4680 "Entered %s.\n", __func__
);
4682 if (!IS_QLA81XX(vha
->hw
) && !IS_QLA83XX(vha
->hw
) &&
4683 !IS_QLA27XX(vha
->hw
) && !IS_QLA28XX(vha
->hw
))
4684 return QLA_FUNCTION_FAILED
;
4686 mcp
->mb
[0] = MBC_FLASH_ACCESS_CTRL
;
4687 mcp
->mb
[1] = FAC_OPT_CMD_GET_SECTOR_SIZE
;
4688 mcp
->out_mb
= MBX_1
|MBX_0
;
4689 mcp
->in_mb
= MBX_1
|MBX_0
;
4690 mcp
->tov
= MBX_TOV_SECONDS
;
4692 rval
= qla2x00_mailbox_command(vha
, mcp
);
4694 if (rval
!= QLA_SUCCESS
) {
4695 ql_dbg(ql_dbg_mbx
, vha
, 0x10dd,
4696 "Failed=%x mb[0]=%x mb[1]=%x.\n",
4697 rval
, mcp
->mb
[0], mcp
->mb
[1]);
4699 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x10de,
4700 "Done %s.\n", __func__
);
4701 *sector_size
= mcp
->mb
[1];
4708 qla81xx_fac_do_write_enable(scsi_qla_host_t
*vha
, int enable
)
4712 mbx_cmd_t
*mcp
= &mc
;
4714 if (!IS_QLA81XX(vha
->hw
) && !IS_QLA83XX(vha
->hw
) &&
4715 !IS_QLA27XX(vha
->hw
) && !IS_QLA28XX(vha
->hw
))
4716 return QLA_FUNCTION_FAILED
;
4718 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x10df,
4719 "Entered %s.\n", __func__
);
4721 mcp
->mb
[0] = MBC_FLASH_ACCESS_CTRL
;
4722 mcp
->mb
[1] = enable
? FAC_OPT_CMD_WRITE_ENABLE
:
4723 FAC_OPT_CMD_WRITE_PROTECT
;
4724 mcp
->out_mb
= MBX_1
|MBX_0
;
4725 mcp
->in_mb
= MBX_1
|MBX_0
;
4726 mcp
->tov
= MBX_TOV_SECONDS
;
4728 rval
= qla2x00_mailbox_command(vha
, mcp
);
4730 if (rval
!= QLA_SUCCESS
) {
4731 ql_dbg(ql_dbg_mbx
, vha
, 0x10e0,
4732 "Failed=%x mb[0]=%x mb[1]=%x.\n",
4733 rval
, mcp
->mb
[0], mcp
->mb
[1]);
4735 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x10e1,
4736 "Done %s.\n", __func__
);
4743 qla81xx_fac_erase_sector(scsi_qla_host_t
*vha
, uint32_t start
, uint32_t finish
)
4747 mbx_cmd_t
*mcp
= &mc
;
4749 if (!IS_QLA81XX(vha
->hw
) && !IS_QLA83XX(vha
->hw
) &&
4750 !IS_QLA27XX(vha
->hw
) && !IS_QLA28XX(vha
->hw
))
4751 return QLA_FUNCTION_FAILED
;
4753 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x10e2,
4754 "Entered %s.\n", __func__
);
4756 mcp
->mb
[0] = MBC_FLASH_ACCESS_CTRL
;
4757 mcp
->mb
[1] = FAC_OPT_CMD_ERASE_SECTOR
;
4758 mcp
->mb
[2] = LSW(start
);
4759 mcp
->mb
[3] = MSW(start
);
4760 mcp
->mb
[4] = LSW(finish
);
4761 mcp
->mb
[5] = MSW(finish
);
4762 mcp
->out_mb
= MBX_5
|MBX_4
|MBX_3
|MBX_2
|MBX_1
|MBX_0
;
4763 mcp
->in_mb
= MBX_2
|MBX_1
|MBX_0
;
4764 mcp
->tov
= MBX_TOV_SECONDS
;
4766 rval
= qla2x00_mailbox_command(vha
, mcp
);
4768 if (rval
!= QLA_SUCCESS
) {
4769 ql_dbg(ql_dbg_mbx
, vha
, 0x10e3,
4770 "Failed=%x mb[0]=%x mb[1]=%x mb[2]=%x.\n",
4771 rval
, mcp
->mb
[0], mcp
->mb
[1], mcp
->mb
[2]);
4773 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x10e4,
4774 "Done %s.\n", __func__
);
4781 qla81xx_fac_semaphore_access(scsi_qla_host_t
*vha
, int lock
)
4783 int rval
= QLA_SUCCESS
;
4785 mbx_cmd_t
*mcp
= &mc
;
4786 struct qla_hw_data
*ha
= vha
->hw
;
4788 if (!IS_QLA81XX(ha
) && !IS_QLA83XX(ha
) &&
4789 !IS_QLA27XX(ha
) && !IS_QLA28XX(ha
))
4792 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x10e2,
4793 "Entered %s.\n", __func__
);
4795 mcp
->mb
[0] = MBC_FLASH_ACCESS_CTRL
;
4796 mcp
->mb
[1] = (lock
? FAC_OPT_CMD_LOCK_SEMAPHORE
:
4797 FAC_OPT_CMD_UNLOCK_SEMAPHORE
);
4798 mcp
->out_mb
= MBX_1
|MBX_0
;
4799 mcp
->in_mb
= MBX_1
|MBX_0
;
4800 mcp
->tov
= MBX_TOV_SECONDS
;
4802 rval
= qla2x00_mailbox_command(vha
, mcp
);
4804 if (rval
!= QLA_SUCCESS
) {
4805 ql_dbg(ql_dbg_mbx
, vha
, 0x10e3,
4806 "Failed=%x mb[0]=%x mb[1]=%x mb[2]=%x.\n",
4807 rval
, mcp
->mb
[0], mcp
->mb
[1], mcp
->mb
[2]);
4809 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x10e4,
4810 "Done %s.\n", __func__
);
4817 qla81xx_restart_mpi_firmware(scsi_qla_host_t
*vha
)
4821 mbx_cmd_t
*mcp
= &mc
;
4823 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x10e5,
4824 "Entered %s.\n", __func__
);
4826 mcp
->mb
[0] = MBC_RESTART_MPI_FW
;
4827 mcp
->out_mb
= MBX_0
;
4828 mcp
->in_mb
= MBX_0
|MBX_1
;
4829 mcp
->tov
= MBX_TOV_SECONDS
;
4831 rval
= qla2x00_mailbox_command(vha
, mcp
);
4833 if (rval
!= QLA_SUCCESS
) {
4834 ql_dbg(ql_dbg_mbx
, vha
, 0x10e6,
4835 "Failed=%x mb[0]=%x mb[1]=%x.\n",
4836 rval
, mcp
->mb
[0], mcp
->mb
[1]);
4838 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x10e7,
4839 "Done %s.\n", __func__
);
4846 qla82xx_set_driver_version(scsi_qla_host_t
*vha
, char *version
)
4850 mbx_cmd_t
*mcp
= &mc
;
4854 struct qla_hw_data
*ha
= vha
->hw
;
4856 if (!IS_P3P_TYPE(ha
))
4857 return QLA_FUNCTION_FAILED
;
4859 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x117b,
4860 "Entered %s.\n", __func__
);
4862 str
= (__force __le16
*)version
;
4863 len
= strlen(version
);
4865 mcp
->mb
[0] = MBC_SET_RNID_PARAMS
;
4866 mcp
->mb
[1] = RNID_TYPE_SET_VERSION
<< 8;
4867 mcp
->out_mb
= MBX_1
|MBX_0
;
4868 for (i
= 4; i
< 16 && len
; i
++, str
++, len
-= 2) {
4869 mcp
->mb
[i
] = le16_to_cpup(str
);
4870 mcp
->out_mb
|= 1<<i
;
4872 for (; i
< 16; i
++) {
4874 mcp
->out_mb
|= 1<<i
;
4876 mcp
->in_mb
= MBX_1
|MBX_0
;
4877 mcp
->tov
= MBX_TOV_SECONDS
;
4879 rval
= qla2x00_mailbox_command(vha
, mcp
);
4881 if (rval
!= QLA_SUCCESS
) {
4882 ql_dbg(ql_dbg_mbx
, vha
, 0x117c,
4883 "Failed=%x mb[0]=%x,%x.\n", rval
, mcp
->mb
[0], mcp
->mb
[1]);
4885 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x117d,
4886 "Done %s.\n", __func__
);
4893 qla25xx_set_driver_version(scsi_qla_host_t
*vha
, char *version
)
4897 mbx_cmd_t
*mcp
= &mc
;
4902 struct qla_hw_data
*ha
= vha
->hw
;
4904 if (!IS_FWI2_CAPABLE(ha
) || IS_QLA24XX_TYPE(ha
) || IS_QLA81XX(ha
) ||
4906 return QLA_FUNCTION_FAILED
;
4908 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x117e,
4909 "Entered %s.\n", __func__
);
4911 str
= dma_pool_alloc(ha
->s_dma_pool
, GFP_KERNEL
, &str_dma
);
4913 ql_log(ql_log_warn
, vha
, 0x117f,
4914 "Failed to allocate driver version param.\n");
4915 return QLA_MEMORY_ALLOC_FAILED
;
4918 memcpy(str
, "\x7\x3\x11\x0", 4);
4920 len
= dwlen
* 4 - 4;
4921 memset(str
+ 4, 0, len
);
4922 if (len
> strlen(version
))
4923 len
= strlen(version
);
4924 memcpy(str
+ 4, version
, len
);
4926 mcp
->mb
[0] = MBC_SET_RNID_PARAMS
;
4927 mcp
->mb
[1] = RNID_TYPE_SET_VERSION
<< 8 | dwlen
;
4928 mcp
->mb
[2] = MSW(LSD(str_dma
));
4929 mcp
->mb
[3] = LSW(LSD(str_dma
));
4930 mcp
->mb
[6] = MSW(MSD(str_dma
));
4931 mcp
->mb
[7] = LSW(MSD(str_dma
));
4932 mcp
->out_mb
= MBX_7
|MBX_6
|MBX_3
|MBX_2
|MBX_1
|MBX_0
;
4933 mcp
->in_mb
= MBX_1
|MBX_0
;
4934 mcp
->tov
= MBX_TOV_SECONDS
;
4936 rval
= qla2x00_mailbox_command(vha
, mcp
);
4938 if (rval
!= QLA_SUCCESS
) {
4939 ql_dbg(ql_dbg_mbx
, vha
, 0x1180,
4940 "Failed=%x mb[0]=%x,%x.\n", rval
, mcp
->mb
[0], mcp
->mb
[1]);
4942 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x1181,
4943 "Done %s.\n", __func__
);
4946 dma_pool_free(ha
->s_dma_pool
, str
, str_dma
);
4952 qla24xx_get_port_login_templ(scsi_qla_host_t
*vha
, dma_addr_t buf_dma
,
4953 void *buf
, uint16_t bufsiz
)
4957 mbx_cmd_t
*mcp
= &mc
;
4960 if (!IS_FWI2_CAPABLE(vha
->hw
))
4961 return QLA_FUNCTION_FAILED
;
4963 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x1159,
4964 "Entered %s.\n", __func__
);
4966 mcp
->mb
[0] = MBC_GET_RNID_PARAMS
;
4967 mcp
->mb
[1] = RNID_TYPE_PORT_LOGIN
<< 8;
4968 mcp
->mb
[2] = MSW(buf_dma
);
4969 mcp
->mb
[3] = LSW(buf_dma
);
4970 mcp
->mb
[6] = MSW(MSD(buf_dma
));
4971 mcp
->mb
[7] = LSW(MSD(buf_dma
));
4972 mcp
->mb
[8] = bufsiz
/4;
4973 mcp
->out_mb
= MBX_8
|MBX_7
|MBX_6
|MBX_5
|MBX_4
|MBX_3
|MBX_2
|MBX_1
|MBX_0
;
4974 mcp
->in_mb
= MBX_1
|MBX_0
;
4975 mcp
->tov
= MBX_TOV_SECONDS
;
4977 rval
= qla2x00_mailbox_command(vha
, mcp
);
4979 if (rval
!= QLA_SUCCESS
) {
4980 ql_dbg(ql_dbg_mbx
, vha
, 0x115a,
4981 "Failed=%x mb[0]=%x,%x.\n", rval
, mcp
->mb
[0], mcp
->mb
[1]);
4983 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x115b,
4984 "Done %s.\n", __func__
);
4985 bp
= (uint32_t *) buf
;
4986 for (i
= 0; i
< (bufsiz
-4)/4; i
++, bp
++)
4987 *bp
= le32_to_cpu((__force __le32
)*bp
);
4993 #define PUREX_CMD_COUNT 4
4995 qla25xx_set_els_cmds_supported(scsi_qla_host_t
*vha
)
4999 mbx_cmd_t
*mcp
= &mc
;
5000 uint8_t *els_cmd_map
;
5001 uint8_t active_cnt
= 0;
5002 dma_addr_t els_cmd_map_dma
;
5003 uint8_t cmd_opcode
[PUREX_CMD_COUNT
];
5004 uint8_t i
, index
, purex_bit
;
5005 struct qla_hw_data
*ha
= vha
->hw
;
5007 if (!IS_QLA25XX(ha
) && !IS_QLA2031(ha
) &&
5008 !IS_QLA27XX(ha
) && !IS_QLA28XX(ha
))
5011 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x1197,
5012 "Entered %s.\n", __func__
);
5014 els_cmd_map
= dma_alloc_coherent(&ha
->pdev
->dev
, ELS_CMD_MAP_SIZE
,
5015 &els_cmd_map_dma
, GFP_KERNEL
);
5017 ql_log(ql_log_warn
, vha
, 0x7101,
5018 "Failed to allocate RDP els command param.\n");
5019 return QLA_MEMORY_ALLOC_FAILED
;
5022 /* List of Purex ELS */
5023 if (ql2xrdpenable
) {
5024 cmd_opcode
[active_cnt
] = ELS_RDP
;
5027 if (ha
->flags
.scm_supported_f
) {
5028 cmd_opcode
[active_cnt
] = ELS_FPIN
;
5031 if (ha
->flags
.edif_enabled
) {
5032 cmd_opcode
[active_cnt
] = ELS_AUTH_ELS
;
5036 for (i
= 0; i
< active_cnt
; i
++) {
5037 index
= cmd_opcode
[i
] / 8;
5038 purex_bit
= cmd_opcode
[i
] % 8;
5039 els_cmd_map
[index
] |= 1 << purex_bit
;
5042 mcp
->mb
[0] = MBC_SET_RNID_PARAMS
;
5043 mcp
->mb
[1] = RNID_TYPE_ELS_CMD
<< 8;
5044 mcp
->mb
[2] = MSW(LSD(els_cmd_map_dma
));
5045 mcp
->mb
[3] = LSW(LSD(els_cmd_map_dma
));
5046 mcp
->mb
[6] = MSW(MSD(els_cmd_map_dma
));
5047 mcp
->mb
[7] = LSW(MSD(els_cmd_map_dma
));
5048 mcp
->out_mb
= MBX_7
|MBX_6
|MBX_3
|MBX_2
|MBX_1
|MBX_0
;
5049 mcp
->in_mb
= MBX_1
|MBX_0
;
5050 mcp
->tov
= MBX_TOV_SECONDS
;
5051 mcp
->flags
= MBX_DMA_OUT
;
5052 mcp
->buf_size
= ELS_CMD_MAP_SIZE
;
5053 rval
= qla2x00_mailbox_command(vha
, mcp
);
5055 if (rval
!= QLA_SUCCESS
) {
5056 ql_dbg(ql_dbg_mbx
, vha
, 0x118d,
5057 "Failed=%x (%x,%x).\n", rval
, mcp
->mb
[0], mcp
->mb
[1]);
5059 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x118c,
5060 "Done %s.\n", __func__
);
5063 dma_free_coherent(&ha
->pdev
->dev
, ELS_CMD_MAP_SIZE
,
5064 els_cmd_map
, els_cmd_map_dma
);
5070 qla2x00_read_asic_temperature(scsi_qla_host_t
*vha
, uint16_t *temp
)
5074 mbx_cmd_t
*mcp
= &mc
;
5076 if (!IS_FWI2_CAPABLE(vha
->hw
))
5077 return QLA_FUNCTION_FAILED
;
5079 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x1159,
5080 "Entered %s.\n", __func__
);
5082 mcp
->mb
[0] = MBC_GET_RNID_PARAMS
;
5083 mcp
->mb
[1] = RNID_TYPE_ASIC_TEMP
<< 8;
5084 mcp
->out_mb
= MBX_1
|MBX_0
;
5085 mcp
->in_mb
= MBX_1
|MBX_0
;
5086 mcp
->tov
= MBX_TOV_SECONDS
;
5088 rval
= qla2x00_mailbox_command(vha
, mcp
);
5091 if (rval
!= QLA_SUCCESS
) {
5092 ql_dbg(ql_dbg_mbx
, vha
, 0x115a,
5093 "Failed=%x mb[0]=%x,%x.\n", rval
, mcp
->mb
[0], mcp
->mb
[1]);
5095 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x115b,
5096 "Done %s.\n", __func__
);
5103 qla2x00_read_sfp(scsi_qla_host_t
*vha
, dma_addr_t sfp_dma
, uint8_t *sfp
,
5104 uint16_t dev
, uint16_t off
, uint16_t len
, uint16_t opt
)
5108 mbx_cmd_t
*mcp
= &mc
;
5109 struct qla_hw_data
*ha
= vha
->hw
;
5111 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x10e8,
5112 "Entered %s.\n", __func__
);
5114 if (!IS_FWI2_CAPABLE(ha
))
5115 return QLA_FUNCTION_FAILED
;
5120 mcp
->mb
[0] = MBC_READ_SFP
;
5122 mcp
->mb
[2] = MSW(LSD(sfp_dma
));
5123 mcp
->mb
[3] = LSW(LSD(sfp_dma
));
5124 mcp
->mb
[6] = MSW(MSD(sfp_dma
));
5125 mcp
->mb
[7] = LSW(MSD(sfp_dma
));
5129 mcp
->out_mb
= MBX_10
|MBX_9
|MBX_8
|MBX_7
|MBX_6
|MBX_3
|MBX_2
|MBX_1
|MBX_0
;
5130 mcp
->in_mb
= MBX_1
|MBX_0
;
5131 mcp
->tov
= MBX_TOV_SECONDS
;
5133 rval
= qla2x00_mailbox_command(vha
, mcp
);
5138 if (rval
!= QLA_SUCCESS
) {
5139 ql_dbg(ql_dbg_mbx
, vha
, 0x10e9,
5140 "Failed=%x mb[0]=%x.\n", rval
, mcp
->mb
[0]);
5141 if (mcp
->mb
[0] == MBS_COMMAND_ERROR
&& mcp
->mb
[1] == 0x22) {
5142 /* sfp is not there */
5143 rval
= QLA_INTERFACE_ERROR
;
5146 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x10ea,
5147 "Done %s.\n", __func__
);
5154 qla2x00_write_sfp(scsi_qla_host_t
*vha
, dma_addr_t sfp_dma
, uint8_t *sfp
,
5155 uint16_t dev
, uint16_t off
, uint16_t len
, uint16_t opt
)
5159 mbx_cmd_t
*mcp
= &mc
;
5160 struct qla_hw_data
*ha
= vha
->hw
;
5162 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x10eb,
5163 "Entered %s.\n", __func__
);
5165 if (!IS_FWI2_CAPABLE(ha
))
5166 return QLA_FUNCTION_FAILED
;
5174 mcp
->mb
[0] = MBC_WRITE_SFP
;
5176 mcp
->mb
[2] = MSW(LSD(sfp_dma
));
5177 mcp
->mb
[3] = LSW(LSD(sfp_dma
));
5178 mcp
->mb
[6] = MSW(MSD(sfp_dma
));
5179 mcp
->mb
[7] = LSW(MSD(sfp_dma
));
5183 mcp
->out_mb
= MBX_10
|MBX_9
|MBX_8
|MBX_7
|MBX_6
|MBX_3
|MBX_2
|MBX_1
|MBX_0
;
5184 mcp
->in_mb
= MBX_1
|MBX_0
;
5185 mcp
->tov
= MBX_TOV_SECONDS
;
5187 rval
= qla2x00_mailbox_command(vha
, mcp
);
5189 if (rval
!= QLA_SUCCESS
) {
5190 ql_dbg(ql_dbg_mbx
, vha
, 0x10ec,
5191 "Failed=%x mb[0]=%x.\n", rval
, mcp
->mb
[0]);
5193 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x10ed,
5194 "Done %s.\n", __func__
);
5201 qla2x00_get_xgmac_stats(scsi_qla_host_t
*vha
, dma_addr_t stats_dma
,
5202 uint16_t size_in_bytes
, uint16_t *actual_size
)
5206 mbx_cmd_t
*mcp
= &mc
;
5208 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x10ee,
5209 "Entered %s.\n", __func__
);
5211 if (!IS_CNA_CAPABLE(vha
->hw
))
5212 return QLA_FUNCTION_FAILED
;
5214 mcp
->mb
[0] = MBC_GET_XGMAC_STATS
;
5215 mcp
->mb
[2] = MSW(stats_dma
);
5216 mcp
->mb
[3] = LSW(stats_dma
);
5217 mcp
->mb
[6] = MSW(MSD(stats_dma
));
5218 mcp
->mb
[7] = LSW(MSD(stats_dma
));
5219 mcp
->mb
[8] = size_in_bytes
>> 2;
5220 mcp
->out_mb
= MBX_8
|MBX_7
|MBX_6
|MBX_3
|MBX_2
|MBX_0
;
5221 mcp
->in_mb
= MBX_2
|MBX_1
|MBX_0
;
5222 mcp
->tov
= MBX_TOV_SECONDS
;
5224 rval
= qla2x00_mailbox_command(vha
, mcp
);
5226 if (rval
!= QLA_SUCCESS
) {
5227 ql_dbg(ql_dbg_mbx
, vha
, 0x10ef,
5228 "Failed=%x mb[0]=%x mb[1]=%x mb[2]=%x.\n",
5229 rval
, mcp
->mb
[0], mcp
->mb
[1], mcp
->mb
[2]);
5231 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x10f0,
5232 "Done %s.\n", __func__
);
5235 *actual_size
= mcp
->mb
[2] << 2;
5242 qla2x00_get_dcbx_params(scsi_qla_host_t
*vha
, dma_addr_t tlv_dma
,
5247 mbx_cmd_t
*mcp
= &mc
;
5249 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x10f1,
5250 "Entered %s.\n", __func__
);
5252 if (!IS_CNA_CAPABLE(vha
->hw
))
5253 return QLA_FUNCTION_FAILED
;
5255 mcp
->mb
[0] = MBC_GET_DCBX_PARAMS
;
5257 mcp
->mb
[2] = MSW(tlv_dma
);
5258 mcp
->mb
[3] = LSW(tlv_dma
);
5259 mcp
->mb
[6] = MSW(MSD(tlv_dma
));
5260 mcp
->mb
[7] = LSW(MSD(tlv_dma
));
5262 mcp
->out_mb
= MBX_8
|MBX_7
|MBX_6
|MBX_3
|MBX_2
|MBX_1
|MBX_0
;
5263 mcp
->in_mb
= MBX_2
|MBX_1
|MBX_0
;
5264 mcp
->tov
= MBX_TOV_SECONDS
;
5266 rval
= qla2x00_mailbox_command(vha
, mcp
);
5268 if (rval
!= QLA_SUCCESS
) {
5269 ql_dbg(ql_dbg_mbx
, vha
, 0x10f2,
5270 "Failed=%x mb[0]=%x mb[1]=%x mb[2]=%x.\n",
5271 rval
, mcp
->mb
[0], mcp
->mb
[1], mcp
->mb
[2]);
5273 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x10f3,
5274 "Done %s.\n", __func__
);
5281 qla2x00_read_ram_word(scsi_qla_host_t
*vha
, uint32_t risc_addr
, uint32_t *data
)
5285 mbx_cmd_t
*mcp
= &mc
;
5287 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x10f4,
5288 "Entered %s.\n", __func__
);
5290 if (!IS_FWI2_CAPABLE(vha
->hw
))
5291 return QLA_FUNCTION_FAILED
;
5293 mcp
->mb
[0] = MBC_READ_RAM_EXTENDED
;
5294 mcp
->mb
[1] = LSW(risc_addr
);
5295 mcp
->mb
[8] = MSW(risc_addr
);
5296 mcp
->out_mb
= MBX_8
|MBX_1
|MBX_0
;
5297 mcp
->in_mb
= MBX_3
|MBX_2
|MBX_0
;
5298 mcp
->tov
= MBX_TOV_SECONDS
;
5300 rval
= qla2x00_mailbox_command(vha
, mcp
);
5301 if (rval
!= QLA_SUCCESS
) {
5302 ql_dbg(ql_dbg_mbx
, vha
, 0x10f5,
5303 "Failed=%x mb[0]=%x.\n", rval
, mcp
->mb
[0]);
5305 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x10f6,
5306 "Done %s.\n", __func__
);
5307 *data
= mcp
->mb
[3] << 16 | mcp
->mb
[2];
5314 qla2x00_loopback_test(scsi_qla_host_t
*vha
, struct msg_echo_lb
*mreq
,
5319 mbx_cmd_t
*mcp
= &mc
;
5321 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x10f7,
5322 "Entered %s.\n", __func__
);
5324 memset(mcp
->mb
, 0 , sizeof(mcp
->mb
));
5325 mcp
->mb
[0] = MBC_DIAGNOSTIC_LOOP_BACK
;
5326 mcp
->mb
[1] = mreq
->options
| BIT_6
; // BIT_6 specifies 64 bit addressing
5328 /* transfer count */
5329 mcp
->mb
[10] = LSW(mreq
->transfer_size
);
5330 mcp
->mb
[11] = MSW(mreq
->transfer_size
);
5332 /* send data address */
5333 mcp
->mb
[14] = LSW(mreq
->send_dma
);
5334 mcp
->mb
[15] = MSW(mreq
->send_dma
);
5335 mcp
->mb
[20] = LSW(MSD(mreq
->send_dma
));
5336 mcp
->mb
[21] = MSW(MSD(mreq
->send_dma
));
5338 /* receive data address */
5339 mcp
->mb
[16] = LSW(mreq
->rcv_dma
);
5340 mcp
->mb
[17] = MSW(mreq
->rcv_dma
);
5341 mcp
->mb
[6] = LSW(MSD(mreq
->rcv_dma
));
5342 mcp
->mb
[7] = MSW(MSD(mreq
->rcv_dma
));
5344 /* Iteration count */
5345 mcp
->mb
[18] = LSW(mreq
->iteration_count
);
5346 mcp
->mb
[19] = MSW(mreq
->iteration_count
);
5348 mcp
->out_mb
= MBX_21
|MBX_20
|MBX_19
|MBX_18
|MBX_17
|MBX_16
|MBX_15
|
5349 MBX_14
|MBX_13
|MBX_12
|MBX_11
|MBX_10
|MBX_7
|MBX_6
|MBX_1
|MBX_0
;
5350 if (IS_CNA_CAPABLE(vha
->hw
))
5351 mcp
->out_mb
|= MBX_2
;
5352 mcp
->in_mb
= MBX_19
|MBX_18
|MBX_3
|MBX_2
|MBX_1
|MBX_0
;
5354 mcp
->buf_size
= mreq
->transfer_size
;
5355 mcp
->tov
= MBX_TOV_SECONDS
;
5356 mcp
->flags
= MBX_DMA_OUT
|MBX_DMA_IN
|IOCTL_CMD
;
5358 rval
= qla2x00_mailbox_command(vha
, mcp
);
5360 if (rval
!= QLA_SUCCESS
) {
5361 ql_dbg(ql_dbg_mbx
, vha
, 0x10f8,
5362 "Failed=%x mb[0]=%x mb[1]=%x mb[2]=%x mb[3]=%x mb[18]=%x "
5363 "mb[19]=%x.\n", rval
, mcp
->mb
[0], mcp
->mb
[1], mcp
->mb
[2],
5364 mcp
->mb
[3], mcp
->mb
[18], mcp
->mb
[19]);
5366 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x10f9,
5367 "Done %s.\n", __func__
);
5370 /* Copy mailbox information */
5371 memcpy( mresp
, mcp
->mb
, 64);
5376 qla2x00_echo_test(scsi_qla_host_t
*vha
, struct msg_echo_lb
*mreq
,
5381 mbx_cmd_t
*mcp
= &mc
;
5382 struct qla_hw_data
*ha
= vha
->hw
;
5384 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x10fa,
5385 "Entered %s.\n", __func__
);
5387 memset(mcp
->mb
, 0 , sizeof(mcp
->mb
));
5388 mcp
->mb
[0] = MBC_DIAGNOSTIC_ECHO
;
5389 /* BIT_6 specifies 64bit address */
5390 mcp
->mb
[1] = mreq
->options
| BIT_15
| BIT_6
;
5391 if (IS_CNA_CAPABLE(ha
)) {
5392 mcp
->mb
[2] = vha
->fcoe_fcf_idx
;
5394 mcp
->mb
[16] = LSW(mreq
->rcv_dma
);
5395 mcp
->mb
[17] = MSW(mreq
->rcv_dma
);
5396 mcp
->mb
[6] = LSW(MSD(mreq
->rcv_dma
));
5397 mcp
->mb
[7] = MSW(MSD(mreq
->rcv_dma
));
5399 mcp
->mb
[10] = LSW(mreq
->transfer_size
);
5401 mcp
->mb
[14] = LSW(mreq
->send_dma
);
5402 mcp
->mb
[15] = MSW(mreq
->send_dma
);
5403 mcp
->mb
[20] = LSW(MSD(mreq
->send_dma
));
5404 mcp
->mb
[21] = MSW(MSD(mreq
->send_dma
));
5406 mcp
->out_mb
= MBX_21
|MBX_20
|MBX_17
|MBX_16
|MBX_15
|
5407 MBX_14
|MBX_10
|MBX_7
|MBX_6
|MBX_1
|MBX_0
;
5408 if (IS_CNA_CAPABLE(ha
))
5409 mcp
->out_mb
|= MBX_2
;
5412 if (IS_CNA_CAPABLE(ha
) || IS_QLA24XX_TYPE(ha
) || IS_QLA25XX(ha
) ||
5413 IS_QLA2031(ha
) || IS_QLA27XX(ha
) || IS_QLA28XX(ha
))
5414 mcp
->in_mb
|= MBX_1
;
5415 if (IS_CNA_CAPABLE(ha
) || IS_QLA2031(ha
) || IS_QLA27XX(ha
) ||
5417 mcp
->in_mb
|= MBX_3
;
5419 mcp
->tov
= MBX_TOV_SECONDS
;
5420 mcp
->flags
= MBX_DMA_OUT
|MBX_DMA_IN
|IOCTL_CMD
;
5421 mcp
->buf_size
= mreq
->transfer_size
;
5423 rval
= qla2x00_mailbox_command(vha
, mcp
);
5425 if (rval
!= QLA_SUCCESS
) {
5426 ql_dbg(ql_dbg_mbx
, vha
, 0x10fb,
5427 "Failed=%x mb[0]=%x mb[1]=%x.\n",
5428 rval
, mcp
->mb
[0], mcp
->mb
[1]);
5430 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x10fc,
5431 "Done %s.\n", __func__
);
5434 /* Copy mailbox information */
5435 memcpy(mresp
, mcp
->mb
, 64);
5440 qla84xx_reset_chip(scsi_qla_host_t
*vha
, uint16_t enable_diagnostic
)
5444 mbx_cmd_t
*mcp
= &mc
;
5446 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x10fd,
5447 "Entered %s enable_diag=%d.\n", __func__
, enable_diagnostic
);
5449 mcp
->mb
[0] = MBC_ISP84XX_RESET
;
5450 mcp
->mb
[1] = enable_diagnostic
;
5451 mcp
->out_mb
= MBX_1
|MBX_0
;
5452 mcp
->in_mb
= MBX_1
|MBX_0
;
5453 mcp
->tov
= MBX_TOV_SECONDS
;
5454 mcp
->flags
= MBX_DMA_OUT
|MBX_DMA_IN
|IOCTL_CMD
;
5455 rval
= qla2x00_mailbox_command(vha
, mcp
);
5457 if (rval
!= QLA_SUCCESS
)
5458 ql_dbg(ql_dbg_mbx
, vha
, 0x10fe, "Failed=%x.\n", rval
);
5460 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x10ff,
5461 "Done %s.\n", __func__
);
5467 qla2x00_write_ram_word(scsi_qla_host_t
*vha
, uint32_t risc_addr
, uint32_t data
)
5471 mbx_cmd_t
*mcp
= &mc
;
5473 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x1100,
5474 "Entered %s.\n", __func__
);
5476 if (!IS_FWI2_CAPABLE(vha
->hw
))
5477 return QLA_FUNCTION_FAILED
;
5479 mcp
->mb
[0] = MBC_WRITE_RAM_WORD_EXTENDED
;
5480 mcp
->mb
[1] = LSW(risc_addr
);
5481 mcp
->mb
[2] = LSW(data
);
5482 mcp
->mb
[3] = MSW(data
);
5483 mcp
->mb
[8] = MSW(risc_addr
);
5484 mcp
->out_mb
= MBX_8
|MBX_3
|MBX_2
|MBX_1
|MBX_0
;
5485 mcp
->in_mb
= MBX_1
|MBX_0
;
5486 mcp
->tov
= MBX_TOV_SECONDS
;
5488 rval
= qla2x00_mailbox_command(vha
, mcp
);
5489 if (rval
!= QLA_SUCCESS
) {
5490 ql_dbg(ql_dbg_mbx
, vha
, 0x1101,
5491 "Failed=%x mb[0]=%x mb[1]=%x.\n",
5492 rval
, mcp
->mb
[0], mcp
->mb
[1]);
5494 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x1102,
5495 "Done %s.\n", __func__
);
5502 qla81xx_write_mpi_register(scsi_qla_host_t
*vha
, uint16_t *mb
)
5505 uint32_t stat
, timer
;
5507 struct qla_hw_data
*ha
= vha
->hw
;
5508 struct device_reg_24xx __iomem
*reg
= &ha
->iobase
->isp24
;
5512 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x1103,
5513 "Entered %s.\n", __func__
);
5515 clear_bit(MBX_INTERRUPT
, &ha
->mbx_cmd_flags
);
5517 /* Write the MBC data to the registers */
5518 wrt_reg_word(®
->mailbox0
, MBC_WRITE_MPI_REGISTER
);
5519 wrt_reg_word(®
->mailbox1
, mb
[0]);
5520 wrt_reg_word(®
->mailbox2
, mb
[1]);
5521 wrt_reg_word(®
->mailbox3
, mb
[2]);
5522 wrt_reg_word(®
->mailbox4
, mb
[3]);
5524 wrt_reg_dword(®
->hccr
, HCCRX_SET_HOST_INT
);
5526 /* Poll for MBC interrupt */
5527 for (timer
= 6000000; timer
; timer
--) {
5528 /* Check for pending interrupts. */
5529 stat
= rd_reg_dword(®
->host_status
);
5530 if (stat
& HSRX_RISC_INT
) {
5533 if (stat
== 0x1 || stat
== 0x2 ||
5534 stat
== 0x10 || stat
== 0x11) {
5535 set_bit(MBX_INTERRUPT
,
5536 &ha
->mbx_cmd_flags
);
5537 mb0
= rd_reg_word(®
->mailbox0
);
5538 wrt_reg_dword(®
->hccr
,
5539 HCCRX_CLR_RISC_INT
);
5540 rd_reg_dword(®
->hccr
);
5547 if (test_and_clear_bit(MBX_INTERRUPT
, &ha
->mbx_cmd_flags
))
5548 rval
= mb0
& MBS_MASK
;
5550 rval
= QLA_FUNCTION_FAILED
;
5552 if (rval
!= QLA_SUCCESS
) {
5553 ql_dbg(ql_dbg_mbx
, vha
, 0x1104,
5554 "Failed=%x mb[0]=%x.\n", rval
, mb
[0]);
5556 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x1105,
5557 "Done %s.\n", __func__
);
5563 /* Set the specified data rate */
5565 qla2x00_set_data_rate(scsi_qla_host_t
*vha
, uint16_t mode
)
5569 mbx_cmd_t
*mcp
= &mc
;
5570 struct qla_hw_data
*ha
= vha
->hw
;
5573 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x1106,
5574 "Entered %s speed:0x%x mode:0x%x.\n", __func__
, ha
->set_data_rate
,
5577 if (!IS_FWI2_CAPABLE(ha
))
5578 return QLA_FUNCTION_FAILED
;
5580 memset(mcp
, 0, sizeof(*mcp
));
5581 switch (ha
->set_data_rate
) {
5582 case PORT_SPEED_AUTO
:
5583 case PORT_SPEED_4GB
:
5584 case PORT_SPEED_8GB
:
5585 case PORT_SPEED_16GB
:
5586 case PORT_SPEED_32GB
:
5587 val
= ha
->set_data_rate
;
5590 ql_log(ql_log_warn
, vha
, 0x1199,
5591 "Unrecognized speed setting:%d. Setting Autoneg\n",
5593 val
= ha
->set_data_rate
= PORT_SPEED_AUTO
;
5597 mcp
->mb
[0] = MBC_DATA_RATE
;
5601 mcp
->out_mb
= MBX_2
|MBX_1
|MBX_0
;
5602 mcp
->in_mb
= MBX_2
|MBX_1
|MBX_0
;
5603 if (IS_QLA83XX(ha
) || IS_QLA27XX(ha
) || IS_QLA28XX(ha
))
5604 mcp
->in_mb
|= MBX_4
|MBX_3
;
5605 mcp
->tov
= MBX_TOV_SECONDS
;
5607 rval
= qla2x00_mailbox_command(vha
, mcp
);
5608 if (rval
!= QLA_SUCCESS
) {
5609 ql_dbg(ql_dbg_mbx
, vha
, 0x1107,
5610 "Failed=%x mb[0]=%x.\n", rval
, mcp
->mb
[0]);
5612 if (mcp
->mb
[1] != 0x7)
5613 ql_dbg(ql_dbg_mbx
, vha
, 0x1179,
5614 "Speed set:0x%x\n", mcp
->mb
[1]);
5616 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x1108,
5617 "Done %s.\n", __func__
);
5624 qla2x00_get_data_rate(scsi_qla_host_t
*vha
)
5628 mbx_cmd_t
*mcp
= &mc
;
5629 struct qla_hw_data
*ha
= vha
->hw
;
5631 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x1106,
5632 "Entered %s.\n", __func__
);
5634 if (!IS_FWI2_CAPABLE(ha
))
5635 return QLA_FUNCTION_FAILED
;
5637 mcp
->mb
[0] = MBC_DATA_RATE
;
5638 mcp
->mb
[1] = QLA_GET_DATA_RATE
;
5639 mcp
->out_mb
= MBX_1
|MBX_0
;
5640 mcp
->in_mb
= MBX_2
|MBX_1
|MBX_0
;
5641 if (IS_QLA83XX(ha
) || IS_QLA27XX(ha
) || IS_QLA28XX(ha
))
5642 mcp
->in_mb
|= MBX_4
|MBX_3
;
5643 mcp
->tov
= MBX_TOV_SECONDS
;
5645 rval
= qla2x00_mailbox_command(vha
, mcp
);
5646 if (rval
!= QLA_SUCCESS
) {
5647 ql_dbg(ql_dbg_mbx
, vha
, 0x1107,
5648 "Failed=%x mb[0]=%x.\n", rval
, mcp
->mb
[0]);
5650 if (mcp
->mb
[1] != 0x7)
5651 ha
->link_data_rate
= mcp
->mb
[1];
5653 if (IS_QLA83XX(ha
) || IS_QLA27XX(ha
) || IS_QLA28XX(ha
)) {
5654 if (mcp
->mb
[4] & BIT_0
)
5655 ql_log(ql_log_info
, vha
, 0x11a2,
5656 "FEC=enabled (data rate).\n");
5659 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x1108,
5660 "Done %s.\n", __func__
);
5661 if (mcp
->mb
[1] != 0x7)
5662 ha
->link_data_rate
= mcp
->mb
[1];
5669 qla81xx_get_port_config(scsi_qla_host_t
*vha
, uint16_t *mb
)
5673 mbx_cmd_t
*mcp
= &mc
;
5674 struct qla_hw_data
*ha
= vha
->hw
;
5676 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x1109,
5677 "Entered %s.\n", __func__
);
5679 if (!IS_QLA81XX(ha
) && !IS_QLA83XX(ha
) && !IS_QLA8044(ha
) &&
5680 !IS_QLA27XX(ha
) && !IS_QLA28XX(ha
))
5681 return QLA_FUNCTION_FAILED
;
5682 mcp
->mb
[0] = MBC_GET_PORT_CONFIG
;
5683 mcp
->out_mb
= MBX_0
;
5684 mcp
->in_mb
= MBX_4
|MBX_3
|MBX_2
|MBX_1
|MBX_0
;
5685 mcp
->tov
= MBX_TOV_SECONDS
;
5688 rval
= qla2x00_mailbox_command(vha
, mcp
);
5690 if (rval
!= QLA_SUCCESS
) {
5691 ql_dbg(ql_dbg_mbx
, vha
, 0x110a,
5692 "Failed=%x mb[0]=%x.\n", rval
, mcp
->mb
[0]);
5694 /* Copy all bits to preserve original value */
5695 memcpy(mb
, &mcp
->mb
[1], sizeof(uint16_t) * 4);
5697 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x110b,
5698 "Done %s.\n", __func__
);
5704 qla81xx_set_port_config(scsi_qla_host_t
*vha
, uint16_t *mb
)
5708 mbx_cmd_t
*mcp
= &mc
;
5710 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x110c,
5711 "Entered %s.\n", __func__
);
5713 mcp
->mb
[0] = MBC_SET_PORT_CONFIG
;
5714 /* Copy all bits to preserve original setting */
5715 memcpy(&mcp
->mb
[1], mb
, sizeof(uint16_t) * 4);
5716 mcp
->out_mb
= MBX_4
|MBX_3
|MBX_2
|MBX_1
|MBX_0
;
5718 mcp
->tov
= MBX_TOV_SECONDS
;
5720 rval
= qla2x00_mailbox_command(vha
, mcp
);
5722 if (rval
!= QLA_SUCCESS
) {
5723 ql_dbg(ql_dbg_mbx
, vha
, 0x110d,
5724 "Failed=%x mb[0]=%x.\n", rval
, mcp
->mb
[0]);
5726 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x110e,
5727 "Done %s.\n", __func__
);
5734 qla24xx_set_fcp_prio(scsi_qla_host_t
*vha
, uint16_t loop_id
, uint16_t priority
,
5739 mbx_cmd_t
*mcp
= &mc
;
5740 struct qla_hw_data
*ha
= vha
->hw
;
5742 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x110f,
5743 "Entered %s.\n", __func__
);
5745 if (!IS_QLA24XX_TYPE(ha
) && !IS_QLA25XX(ha
))
5746 return QLA_FUNCTION_FAILED
;
5748 mcp
->mb
[0] = MBC_PORT_PARAMS
;
5749 mcp
->mb
[1] = loop_id
;
5750 if (ha
->flags
.fcp_prio_enabled
)
5754 mcp
->mb
[4] = priority
& 0xf;
5755 mcp
->mb
[9] = vha
->vp_idx
;
5756 mcp
->out_mb
= MBX_9
|MBX_4
|MBX_3
|MBX_2
|MBX_1
|MBX_0
;
5757 mcp
->in_mb
= MBX_4
|MBX_3
|MBX_1
|MBX_0
;
5758 mcp
->tov
= MBX_TOV_SECONDS
;
5760 rval
= qla2x00_mailbox_command(vha
, mcp
);
5768 if (rval
!= QLA_SUCCESS
) {
5769 ql_dbg(ql_dbg_mbx
, vha
, 0x10cd, "Failed=%x.\n", rval
);
5771 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x10cc,
5772 "Done %s.\n", __func__
);
5779 qla2x00_get_thermal_temp(scsi_qla_host_t
*vha
, uint16_t *temp
)
5781 int rval
= QLA_FUNCTION_FAILED
;
5782 struct qla_hw_data
*ha
= vha
->hw
;
5785 if (!IS_FWI2_CAPABLE(ha
) || IS_QLA24XX_TYPE(ha
) || IS_QLA81XX(ha
)) {
5786 ql_dbg(ql_dbg_mbx
, vha
, 0x1150,
5787 "Thermal not supported by this card.\n");
5791 if (IS_QLA25XX(ha
)) {
5792 if (ha
->pdev
->subsystem_vendor
== PCI_VENDOR_ID_QLOGIC
&&
5793 ha
->pdev
->subsystem_device
== 0x0175) {
5794 rval
= qla2x00_read_sfp(vha
, 0, &byte
,
5795 0x98, 0x1, 1, BIT_13
|BIT_0
);
5799 if (ha
->pdev
->subsystem_vendor
== PCI_VENDOR_ID_HP
&&
5800 ha
->pdev
->subsystem_device
== 0x338e) {
5801 rval
= qla2x00_read_sfp(vha
, 0, &byte
,
5802 0x98, 0x1, 1, BIT_15
|BIT_14
|BIT_0
);
5806 ql_dbg(ql_dbg_mbx
, vha
, 0x10c9,
5807 "Thermal not supported by this card.\n");
5811 if (IS_QLA82XX(ha
)) {
5812 *temp
= qla82xx_read_temperature(vha
);
5815 } else if (IS_QLA8044(ha
)) {
5816 *temp
= qla8044_read_temperature(vha
);
5821 rval
= qla2x00_read_asic_temperature(vha
, temp
);
5826 qla82xx_mbx_intr_enable(scsi_qla_host_t
*vha
)
5829 struct qla_hw_data
*ha
= vha
->hw
;
5831 mbx_cmd_t
*mcp
= &mc
;
5833 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x1017,
5834 "Entered %s.\n", __func__
);
5836 if (!IS_FWI2_CAPABLE(ha
))
5837 return QLA_FUNCTION_FAILED
;
5839 memset(mcp
, 0, sizeof(mbx_cmd_t
));
5840 mcp
->mb
[0] = MBC_TOGGLE_INTERRUPT
;
5843 mcp
->out_mb
= MBX_1
|MBX_0
;
5845 mcp
->tov
= MBX_TOV_SECONDS
;
5848 rval
= qla2x00_mailbox_command(vha
, mcp
);
5849 if (rval
!= QLA_SUCCESS
) {
5850 ql_dbg(ql_dbg_mbx
, vha
, 0x1016,
5851 "Failed=%x mb[0]=%x.\n", rval
, mcp
->mb
[0]);
5853 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x100e,
5854 "Done %s.\n", __func__
);
5861 qla82xx_mbx_intr_disable(scsi_qla_host_t
*vha
)
5864 struct qla_hw_data
*ha
= vha
->hw
;
5866 mbx_cmd_t
*mcp
= &mc
;
5868 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x100d,
5869 "Entered %s.\n", __func__
);
5871 if (!IS_P3P_TYPE(ha
))
5872 return QLA_FUNCTION_FAILED
;
5874 memset(mcp
, 0, sizeof(mbx_cmd_t
));
5875 mcp
->mb
[0] = MBC_TOGGLE_INTERRUPT
;
5878 mcp
->out_mb
= MBX_1
|MBX_0
;
5880 mcp
->tov
= MBX_TOV_SECONDS
;
5883 rval
= qla2x00_mailbox_command(vha
, mcp
);
5884 if (rval
!= QLA_SUCCESS
) {
5885 ql_dbg(ql_dbg_mbx
, vha
, 0x100c,
5886 "Failed=%x mb[0]=%x.\n", rval
, mcp
->mb
[0]);
5888 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x100b,
5889 "Done %s.\n", __func__
);
5896 qla82xx_md_get_template_size(scsi_qla_host_t
*vha
)
5898 struct qla_hw_data
*ha
= vha
->hw
;
5900 mbx_cmd_t
*mcp
= &mc
;
5901 int rval
= QLA_FUNCTION_FAILED
;
5903 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x111f,
5904 "Entered %s.\n", __func__
);
5906 memset(mcp
->mb
, 0 , sizeof(mcp
->mb
));
5907 mcp
->mb
[0] = LSW(MBC_DIAGNOSTIC_MINIDUMP_TEMPLATE
);
5908 mcp
->mb
[1] = MSW(MBC_DIAGNOSTIC_MINIDUMP_TEMPLATE
);
5909 mcp
->mb
[2] = LSW(RQST_TMPLT_SIZE
);
5910 mcp
->mb
[3] = MSW(RQST_TMPLT_SIZE
);
5912 mcp
->out_mb
= MBX_3
|MBX_2
|MBX_1
|MBX_0
;
5913 mcp
->in_mb
= MBX_14
|MBX_13
|MBX_12
|MBX_11
|MBX_10
|MBX_9
|MBX_8
|
5914 MBX_7
|MBX_6
|MBX_5
|MBX_4
|MBX_3
|MBX_2
|MBX_1
|MBX_0
;
5916 mcp
->flags
= MBX_DMA_OUT
|MBX_DMA_IN
|IOCTL_CMD
;
5917 mcp
->tov
= MBX_TOV_SECONDS
;
5918 rval
= qla2x00_mailbox_command(vha
, mcp
);
5920 /* Always copy back return mailbox values. */
5921 if (rval
!= QLA_SUCCESS
) {
5922 ql_dbg(ql_dbg_mbx
, vha
, 0x1120,
5923 "mailbox command FAILED=0x%x, subcode=%x.\n",
5924 (mcp
->mb
[1] << 16) | mcp
->mb
[0],
5925 (mcp
->mb
[3] << 16) | mcp
->mb
[2]);
5927 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x1121,
5928 "Done %s.\n", __func__
);
5929 ha
->md_template_size
= ((mcp
->mb
[3] << 16) | mcp
->mb
[2]);
5930 if (!ha
->md_template_size
) {
5931 ql_dbg(ql_dbg_mbx
, vha
, 0x1122,
5932 "Null template size obtained.\n");
5933 rval
= QLA_FUNCTION_FAILED
;
5940 qla82xx_md_get_template(scsi_qla_host_t
*vha
)
5942 struct qla_hw_data
*ha
= vha
->hw
;
5944 mbx_cmd_t
*mcp
= &mc
;
5945 int rval
= QLA_FUNCTION_FAILED
;
5947 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x1123,
5948 "Entered %s.\n", __func__
);
5950 ha
->md_tmplt_hdr
= dma_alloc_coherent(&ha
->pdev
->dev
,
5951 ha
->md_template_size
, &ha
->md_tmplt_hdr_dma
, GFP_KERNEL
);
5952 if (!ha
->md_tmplt_hdr
) {
5953 ql_log(ql_log_warn
, vha
, 0x1124,
5954 "Unable to allocate memory for Minidump template.\n");
5958 memset(mcp
->mb
, 0 , sizeof(mcp
->mb
));
5959 mcp
->mb
[0] = LSW(MBC_DIAGNOSTIC_MINIDUMP_TEMPLATE
);
5960 mcp
->mb
[1] = MSW(MBC_DIAGNOSTIC_MINIDUMP_TEMPLATE
);
5961 mcp
->mb
[2] = LSW(RQST_TMPLT
);
5962 mcp
->mb
[3] = MSW(RQST_TMPLT
);
5963 mcp
->mb
[4] = LSW(LSD(ha
->md_tmplt_hdr_dma
));
5964 mcp
->mb
[5] = MSW(LSD(ha
->md_tmplt_hdr_dma
));
5965 mcp
->mb
[6] = LSW(MSD(ha
->md_tmplt_hdr_dma
));
5966 mcp
->mb
[7] = MSW(MSD(ha
->md_tmplt_hdr_dma
));
5967 mcp
->mb
[8] = LSW(ha
->md_template_size
);
5968 mcp
->mb
[9] = MSW(ha
->md_template_size
);
5970 mcp
->flags
= MBX_DMA_OUT
|MBX_DMA_IN
|IOCTL_CMD
;
5971 mcp
->tov
= MBX_TOV_SECONDS
;
5972 mcp
->out_mb
= MBX_11
|MBX_10
|MBX_9
|MBX_8
|
5973 MBX_7
|MBX_6
|MBX_5
|MBX_4
|MBX_3
|MBX_2
|MBX_1
|MBX_0
;
5974 mcp
->in_mb
= MBX_3
|MBX_2
|MBX_1
|MBX_0
;
5975 rval
= qla2x00_mailbox_command(vha
, mcp
);
5977 if (rval
!= QLA_SUCCESS
) {
5978 ql_dbg(ql_dbg_mbx
, vha
, 0x1125,
5979 "mailbox command FAILED=0x%x, subcode=%x.\n",
5980 ((mcp
->mb
[1] << 16) | mcp
->mb
[0]),
5981 ((mcp
->mb
[3] << 16) | mcp
->mb
[2]));
5983 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x1126,
5984 "Done %s.\n", __func__
);
5989 qla8044_md_get_template(scsi_qla_host_t
*vha
)
5991 struct qla_hw_data
*ha
= vha
->hw
;
5993 mbx_cmd_t
*mcp
= &mc
;
5994 int rval
= QLA_FUNCTION_FAILED
;
5995 int offset
= 0, size
= MINIDUMP_SIZE_36K
;
5997 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0xb11f,
5998 "Entered %s.\n", __func__
);
6000 ha
->md_tmplt_hdr
= dma_alloc_coherent(&ha
->pdev
->dev
,
6001 ha
->md_template_size
, &ha
->md_tmplt_hdr_dma
, GFP_KERNEL
);
6002 if (!ha
->md_tmplt_hdr
) {
6003 ql_log(ql_log_warn
, vha
, 0xb11b,
6004 "Unable to allocate memory for Minidump template.\n");
6008 memset(mcp
->mb
, 0 , sizeof(mcp
->mb
));
6009 while (offset
< ha
->md_template_size
) {
6010 mcp
->mb
[0] = LSW(MBC_DIAGNOSTIC_MINIDUMP_TEMPLATE
);
6011 mcp
->mb
[1] = MSW(MBC_DIAGNOSTIC_MINIDUMP_TEMPLATE
);
6012 mcp
->mb
[2] = LSW(RQST_TMPLT
);
6013 mcp
->mb
[3] = MSW(RQST_TMPLT
);
6014 mcp
->mb
[4] = LSW(LSD(ha
->md_tmplt_hdr_dma
+ offset
));
6015 mcp
->mb
[5] = MSW(LSD(ha
->md_tmplt_hdr_dma
+ offset
));
6016 mcp
->mb
[6] = LSW(MSD(ha
->md_tmplt_hdr_dma
+ offset
));
6017 mcp
->mb
[7] = MSW(MSD(ha
->md_tmplt_hdr_dma
+ offset
));
6018 mcp
->mb
[8] = LSW(size
);
6019 mcp
->mb
[9] = MSW(size
);
6020 mcp
->mb
[10] = offset
& 0x0000FFFF;
6021 mcp
->mb
[11] = offset
& 0xFFFF0000;
6022 mcp
->flags
= MBX_DMA_OUT
|MBX_DMA_IN
|IOCTL_CMD
;
6023 mcp
->tov
= MBX_TOV_SECONDS
;
6024 mcp
->out_mb
= MBX_11
|MBX_10
|MBX_9
|MBX_8
|
6025 MBX_7
|MBX_6
|MBX_5
|MBX_4
|MBX_3
|MBX_2
|MBX_1
|MBX_0
;
6026 mcp
->in_mb
= MBX_3
|MBX_2
|MBX_1
|MBX_0
;
6027 rval
= qla2x00_mailbox_command(vha
, mcp
);
6029 if (rval
!= QLA_SUCCESS
) {
6030 ql_dbg(ql_dbg_mbx
, vha
, 0xb11c,
6031 "mailbox command FAILED=0x%x, subcode=%x.\n",
6032 ((mcp
->mb
[1] << 16) | mcp
->mb
[0]),
6033 ((mcp
->mb
[3] << 16) | mcp
->mb
[2]));
6036 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0xb11d,
6037 "Done %s.\n", __func__
);
6038 offset
= offset
+ size
;
6044 qla81xx_set_led_config(scsi_qla_host_t
*vha
, uint16_t *led_cfg
)
6047 struct qla_hw_data
*ha
= vha
->hw
;
6049 mbx_cmd_t
*mcp
= &mc
;
6051 if (!IS_QLA81XX(ha
) && !IS_QLA8031(ha
))
6052 return QLA_FUNCTION_FAILED
;
6054 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x1133,
6055 "Entered %s.\n", __func__
);
6057 memset(mcp
, 0, sizeof(mbx_cmd_t
));
6058 mcp
->mb
[0] = MBC_SET_LED_CONFIG
;
6059 mcp
->mb
[1] = led_cfg
[0];
6060 mcp
->mb
[2] = led_cfg
[1];
6061 if (IS_QLA8031(ha
)) {
6062 mcp
->mb
[3] = led_cfg
[2];
6063 mcp
->mb
[4] = led_cfg
[3];
6064 mcp
->mb
[5] = led_cfg
[4];
6065 mcp
->mb
[6] = led_cfg
[5];
6068 mcp
->out_mb
= MBX_2
|MBX_1
|MBX_0
;
6070 mcp
->out_mb
|= MBX_6
|MBX_5
|MBX_4
|MBX_3
;
6072 mcp
->tov
= MBX_TOV_SECONDS
;
6075 rval
= qla2x00_mailbox_command(vha
, mcp
);
6076 if (rval
!= QLA_SUCCESS
) {
6077 ql_dbg(ql_dbg_mbx
, vha
, 0x1134,
6078 "Failed=%x mb[0]=%x.\n", rval
, mcp
->mb
[0]);
6080 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x1135,
6081 "Done %s.\n", __func__
);
6088 qla81xx_get_led_config(scsi_qla_host_t
*vha
, uint16_t *led_cfg
)
6091 struct qla_hw_data
*ha
= vha
->hw
;
6093 mbx_cmd_t
*mcp
= &mc
;
6095 if (!IS_QLA81XX(ha
) && !IS_QLA8031(ha
))
6096 return QLA_FUNCTION_FAILED
;
6098 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x1136,
6099 "Entered %s.\n", __func__
);
6101 memset(mcp
, 0, sizeof(mbx_cmd_t
));
6102 mcp
->mb
[0] = MBC_GET_LED_CONFIG
;
6104 mcp
->out_mb
= MBX_0
;
6105 mcp
->in_mb
= MBX_2
|MBX_1
|MBX_0
;
6107 mcp
->in_mb
|= MBX_6
|MBX_5
|MBX_4
|MBX_3
;
6108 mcp
->tov
= MBX_TOV_SECONDS
;
6111 rval
= qla2x00_mailbox_command(vha
, mcp
);
6112 if (rval
!= QLA_SUCCESS
) {
6113 ql_dbg(ql_dbg_mbx
, vha
, 0x1137,
6114 "Failed=%x mb[0]=%x.\n", rval
, mcp
->mb
[0]);
6116 led_cfg
[0] = mcp
->mb
[1];
6117 led_cfg
[1] = mcp
->mb
[2];
6118 if (IS_QLA8031(ha
)) {
6119 led_cfg
[2] = mcp
->mb
[3];
6120 led_cfg
[3] = mcp
->mb
[4];
6121 led_cfg
[4] = mcp
->mb
[5];
6122 led_cfg
[5] = mcp
->mb
[6];
6124 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x1138,
6125 "Done %s.\n", __func__
);
6132 qla82xx_mbx_beacon_ctl(scsi_qla_host_t
*vha
, int enable
)
6135 struct qla_hw_data
*ha
= vha
->hw
;
6137 mbx_cmd_t
*mcp
= &mc
;
6139 if (!IS_P3P_TYPE(ha
))
6140 return QLA_FUNCTION_FAILED
;
6142 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x1127,
6143 "Entered %s.\n", __func__
);
6145 memset(mcp
, 0, sizeof(mbx_cmd_t
));
6146 mcp
->mb
[0] = MBC_SET_LED_CONFIG
;
6152 mcp
->out_mb
= MBX_7
|MBX_0
;
6154 mcp
->tov
= MBX_TOV_SECONDS
;
6157 rval
= qla2x00_mailbox_command(vha
, mcp
);
6158 if (rval
!= QLA_SUCCESS
) {
6159 ql_dbg(ql_dbg_mbx
, vha
, 0x1128,
6160 "Failed=%x mb[0]=%x.\n", rval
, mcp
->mb
[0]);
6162 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x1129,
6163 "Done %s.\n", __func__
);
6170 qla83xx_wr_reg(scsi_qla_host_t
*vha
, uint32_t reg
, uint32_t data
)
6173 struct qla_hw_data
*ha
= vha
->hw
;
6175 mbx_cmd_t
*mcp
= &mc
;
6177 if (!IS_QLA83XX(ha
) && !IS_QLA27XX(ha
) && !IS_QLA28XX(ha
))
6178 return QLA_FUNCTION_FAILED
;
6180 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x1130,
6181 "Entered %s.\n", __func__
);
6183 mcp
->mb
[0] = MBC_WRITE_REMOTE_REG
;
6184 mcp
->mb
[1] = LSW(reg
);
6185 mcp
->mb
[2] = MSW(reg
);
6186 mcp
->mb
[3] = LSW(data
);
6187 mcp
->mb
[4] = MSW(data
);
6188 mcp
->out_mb
= MBX_4
|MBX_3
|MBX_2
|MBX_1
|MBX_0
;
6190 mcp
->in_mb
= MBX_1
|MBX_0
;
6191 mcp
->tov
= MBX_TOV_SECONDS
;
6193 rval
= qla2x00_mailbox_command(vha
, mcp
);
6195 if (rval
!= QLA_SUCCESS
) {
6196 ql_dbg(ql_dbg_mbx
, vha
, 0x1131,
6197 "Failed=%x mb[0]=%x.\n", rval
, mcp
->mb
[0]);
6199 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x1132,
6200 "Done %s.\n", __func__
);
6207 qla2x00_port_logout(scsi_qla_host_t
*vha
, struct fc_port
*fcport
)
6210 struct qla_hw_data
*ha
= vha
->hw
;
6212 mbx_cmd_t
*mcp
= &mc
;
6214 if (IS_QLA2100(ha
) || IS_QLA2200(ha
)) {
6215 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x113b,
6216 "Implicit LOGO Unsupported.\n");
6217 return QLA_FUNCTION_FAILED
;
6221 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x113c,
6222 "Entering %s.\n", __func__
);
6224 /* Perform Implicit LOGO. */
6225 mcp
->mb
[0] = MBC_PORT_LOGOUT
;
6226 mcp
->mb
[1] = fcport
->loop_id
;
6227 mcp
->mb
[10] = BIT_15
;
6228 mcp
->out_mb
= MBX_10
|MBX_1
|MBX_0
;
6230 mcp
->tov
= MBX_TOV_SECONDS
;
6232 rval
= qla2x00_mailbox_command(vha
, mcp
);
6233 if (rval
!= QLA_SUCCESS
)
6234 ql_dbg(ql_dbg_mbx
, vha
, 0x113d,
6235 "Failed=%x mb[0]=%x.\n", rval
, mcp
->mb
[0]);
6237 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x113e,
6238 "Done %s.\n", __func__
);
6244 qla83xx_rd_reg(scsi_qla_host_t
*vha
, uint32_t reg
, uint32_t *data
)
6248 mbx_cmd_t
*mcp
= &mc
;
6249 struct qla_hw_data
*ha
= vha
->hw
;
6250 unsigned long retry_max_time
= jiffies
+ (2 * HZ
);
6252 if (!IS_QLA83XX(ha
) && !IS_QLA27XX(ha
) && !IS_QLA28XX(ha
))
6253 return QLA_FUNCTION_FAILED
;
6255 ql_dbg(ql_dbg_mbx
, vha
, 0x114b, "Entered %s.\n", __func__
);
6258 mcp
->mb
[0] = MBC_READ_REMOTE_REG
;
6259 mcp
->mb
[1] = LSW(reg
);
6260 mcp
->mb
[2] = MSW(reg
);
6261 mcp
->out_mb
= MBX_2
|MBX_1
|MBX_0
;
6262 mcp
->in_mb
= MBX_4
|MBX_3
|MBX_1
|MBX_0
;
6263 mcp
->tov
= MBX_TOV_SECONDS
;
6265 rval
= qla2x00_mailbox_command(vha
, mcp
);
6267 if (rval
!= QLA_SUCCESS
) {
6268 ql_dbg(ql_dbg_mbx
, vha
, 0x114c,
6269 "Failed=%x mb[0]=%x mb[1]=%x.\n",
6270 rval
, mcp
->mb
[0], mcp
->mb
[1]);
6272 *data
= (mcp
->mb
[3] | (mcp
->mb
[4] << 16));
6273 if (*data
== QLA8XXX_BAD_VALUE
) {
6275 * During soft-reset CAMRAM register reads might
6276 * return 0xbad0bad0. So retry for MAX of 2 sec
6277 * while reading camram registers.
6279 if (time_after(jiffies
, retry_max_time
)) {
6280 ql_dbg(ql_dbg_mbx
, vha
, 0x1141,
6281 "Failure to read CAMRAM register. "
6282 "data=0x%x.\n", *data
);
6283 return QLA_FUNCTION_FAILED
;
6288 ql_dbg(ql_dbg_mbx
, vha
, 0x1142, "Done %s.\n", __func__
);
6295 qla83xx_restart_nic_firmware(scsi_qla_host_t
*vha
)
6299 mbx_cmd_t
*mcp
= &mc
;
6300 struct qla_hw_data
*ha
= vha
->hw
;
6302 if (!IS_QLA83XX(ha
))
6303 return QLA_FUNCTION_FAILED
;
6305 ql_dbg(ql_dbg_mbx
, vha
, 0x1143, "Entered %s.\n", __func__
);
6307 mcp
->mb
[0] = MBC_RESTART_NIC_FIRMWARE
;
6308 mcp
->out_mb
= MBX_0
;
6309 mcp
->in_mb
= MBX_1
|MBX_0
;
6310 mcp
->tov
= MBX_TOV_SECONDS
;
6312 rval
= qla2x00_mailbox_command(vha
, mcp
);
6314 if (rval
!= QLA_SUCCESS
) {
6315 ql_dbg(ql_dbg_mbx
, vha
, 0x1144,
6316 "Failed=%x mb[0]=%x mb[1]=%x.\n",
6317 rval
, mcp
->mb
[0], mcp
->mb
[1]);
6318 qla2xxx_dump_fw(vha
);
6320 ql_dbg(ql_dbg_mbx
, vha
, 0x1145, "Done %s.\n", __func__
);
6327 qla83xx_access_control(scsi_qla_host_t
*vha
, uint16_t options
,
6328 uint32_t start_addr
, uint32_t end_addr
, uint16_t *sector_size
)
6332 mbx_cmd_t
*mcp
= &mc
;
6333 uint8_t subcode
= (uint8_t)options
;
6334 struct qla_hw_data
*ha
= vha
->hw
;
6336 if (!IS_QLA8031(ha
))
6337 return QLA_FUNCTION_FAILED
;
6339 ql_dbg(ql_dbg_mbx
, vha
, 0x1146, "Entered %s.\n", __func__
);
6341 mcp
->mb
[0] = MBC_SET_ACCESS_CONTROL
;
6342 mcp
->mb
[1] = options
;
6343 mcp
->out_mb
= MBX_1
|MBX_0
;
6344 if (subcode
& BIT_2
) {
6345 mcp
->mb
[2] = LSW(start_addr
);
6346 mcp
->mb
[3] = MSW(start_addr
);
6347 mcp
->mb
[4] = LSW(end_addr
);
6348 mcp
->mb
[5] = MSW(end_addr
);
6349 mcp
->out_mb
|= MBX_5
|MBX_4
|MBX_3
|MBX_2
;
6351 mcp
->in_mb
= MBX_2
|MBX_1
|MBX_0
;
6352 if (!(subcode
& (BIT_2
| BIT_5
)))
6353 mcp
->in_mb
|= MBX_4
|MBX_3
;
6354 mcp
->tov
= MBX_TOV_SECONDS
;
6356 rval
= qla2x00_mailbox_command(vha
, mcp
);
6358 if (rval
!= QLA_SUCCESS
) {
6359 ql_dbg(ql_dbg_mbx
, vha
, 0x1147,
6360 "Failed=%x mb[0]=%x mb[1]=%x mb[2]=%x mb[3]=%x mb[4]=%x.\n",
6361 rval
, mcp
->mb
[0], mcp
->mb
[1], mcp
->mb
[2], mcp
->mb
[3],
6363 qla2xxx_dump_fw(vha
);
6365 if (subcode
& BIT_5
)
6366 *sector_size
= mcp
->mb
[1];
6367 else if (subcode
& (BIT_6
| BIT_7
)) {
6368 ql_dbg(ql_dbg_mbx
, vha
, 0x1148,
6369 "Driver-lock id=%x%x", mcp
->mb
[4], mcp
->mb
[3]);
6370 } else if (subcode
& (BIT_3
| BIT_4
)) {
6371 ql_dbg(ql_dbg_mbx
, vha
, 0x1149,
6372 "Flash-lock id=%x%x", mcp
->mb
[4], mcp
->mb
[3]);
6374 ql_dbg(ql_dbg_mbx
, vha
, 0x114a, "Done %s.\n", __func__
);
6381 qla2x00_dump_mctp_data(scsi_qla_host_t
*vha
, dma_addr_t req_dma
, uint32_t addr
,
6386 mbx_cmd_t
*mcp
= &mc
;
6388 if (!IS_MCTP_CAPABLE(vha
->hw
))
6389 return QLA_FUNCTION_FAILED
;
6391 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x114f,
6392 "Entered %s.\n", __func__
);
6394 mcp
->mb
[0] = MBC_DUMP_RISC_RAM_EXTENDED
;
6395 mcp
->mb
[1] = LSW(addr
);
6396 mcp
->mb
[2] = MSW(req_dma
);
6397 mcp
->mb
[3] = LSW(req_dma
);
6398 mcp
->mb
[4] = MSW(size
);
6399 mcp
->mb
[5] = LSW(size
);
6400 mcp
->mb
[6] = MSW(MSD(req_dma
));
6401 mcp
->mb
[7] = LSW(MSD(req_dma
));
6402 mcp
->mb
[8] = MSW(addr
);
6403 /* Setting RAM ID to valid */
6404 /* For MCTP RAM ID is 0x40 */
6405 mcp
->mb
[10] = BIT_7
| 0x40;
6407 mcp
->out_mb
|= MBX_10
|MBX_8
|MBX_7
|MBX_6
|MBX_5
|MBX_4
|MBX_3
|MBX_2
|MBX_1
|
6411 mcp
->tov
= MBX_TOV_SECONDS
;
6413 rval
= qla2x00_mailbox_command(vha
, mcp
);
6415 if (rval
!= QLA_SUCCESS
) {
6416 ql_dbg(ql_dbg_mbx
, vha
, 0x114e,
6417 "Failed=%x mb[0]=%x.\n", rval
, mcp
->mb
[0]);
6419 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x114d,
6420 "Done %s.\n", __func__
);
6427 qla26xx_dport_diagnostics(scsi_qla_host_t
*vha
,
6428 void *dd_buf
, uint size
, uint options
)
6432 mbx_cmd_t
*mcp
= &mc
;
6435 if (!IS_QLA83XX(vha
->hw
) && !IS_QLA27XX(vha
->hw
) &&
6436 !IS_QLA28XX(vha
->hw
))
6437 return QLA_FUNCTION_FAILED
;
6439 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x119f,
6440 "Entered %s.\n", __func__
);
6442 dd_dma
= dma_map_single(&vha
->hw
->pdev
->dev
,
6443 dd_buf
, size
, DMA_FROM_DEVICE
);
6444 if (dma_mapping_error(&vha
->hw
->pdev
->dev
, dd_dma
)) {
6445 ql_log(ql_log_warn
, vha
, 0x1194, "Failed to map dma buffer.\n");
6446 return QLA_MEMORY_ALLOC_FAILED
;
6449 memset(dd_buf
, 0, size
);
6451 mcp
->mb
[0] = MBC_DPORT_DIAGNOSTICS
;
6452 mcp
->mb
[1] = options
;
6453 mcp
->mb
[2] = MSW(LSD(dd_dma
));
6454 mcp
->mb
[3] = LSW(LSD(dd_dma
));
6455 mcp
->mb
[6] = MSW(MSD(dd_dma
));
6456 mcp
->mb
[7] = LSW(MSD(dd_dma
));
6458 mcp
->out_mb
= MBX_8
|MBX_7
|MBX_6
|MBX_3
|MBX_2
|MBX_1
|MBX_0
;
6459 mcp
->in_mb
= MBX_3
|MBX_2
|MBX_1
|MBX_0
;
6460 mcp
->buf_size
= size
;
6461 mcp
->flags
= MBX_DMA_IN
;
6462 mcp
->tov
= MBX_TOV_SECONDS
* 4;
6463 rval
= qla2x00_mailbox_command(vha
, mcp
);
6465 if (rval
!= QLA_SUCCESS
) {
6466 ql_dbg(ql_dbg_mbx
, vha
, 0x1195, "Failed=%x.\n", rval
);
6468 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x1196,
6469 "Done %s.\n", __func__
);
6472 dma_unmap_single(&vha
->hw
->pdev
->dev
, dd_dma
,
6473 size
, DMA_FROM_DEVICE
);
6479 qla26xx_dport_diagnostics_v2(scsi_qla_host_t
*vha
,
6480 struct qla_dport_diag_v2
*dd
, mbx_cmd_t
*mcp
)
6484 uint size
= sizeof(dd
->buf
);
6485 uint16_t options
= dd
->options
;
6487 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x119f,
6488 "Entered %s.\n", __func__
);
6490 dd_dma
= dma_map_single(&vha
->hw
->pdev
->dev
,
6491 dd
->buf
, size
, DMA_FROM_DEVICE
);
6492 if (dma_mapping_error(&vha
->hw
->pdev
->dev
, dd_dma
)) {
6493 ql_log(ql_log_warn
, vha
, 0x1194,
6494 "Failed to map dma buffer.\n");
6495 return QLA_MEMORY_ALLOC_FAILED
;
6498 memset(dd
->buf
, 0, size
);
6500 mcp
->mb
[0] = MBC_DPORT_DIAGNOSTICS
;
6501 mcp
->mb
[1] = options
;
6502 mcp
->mb
[2] = MSW(LSD(dd_dma
));
6503 mcp
->mb
[3] = LSW(LSD(dd_dma
));
6504 mcp
->mb
[6] = MSW(MSD(dd_dma
));
6505 mcp
->mb
[7] = LSW(MSD(dd_dma
));
6507 mcp
->out_mb
= MBX_8
| MBX_7
| MBX_6
| MBX_3
| MBX_2
| MBX_1
| MBX_0
;
6508 mcp
->in_mb
= MBX_3
| MBX_2
| MBX_1
| MBX_0
;
6509 mcp
->buf_size
= size
;
6510 mcp
->flags
= MBX_DMA_IN
;
6511 mcp
->tov
= MBX_TOV_SECONDS
* 4;
6512 rval
= qla2x00_mailbox_command(vha
, mcp
);
6514 if (rval
!= QLA_SUCCESS
) {
6515 ql_dbg(ql_dbg_mbx
, vha
, 0x1195, "Failed=%x.\n", rval
);
6517 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x1196,
6518 "Done %s.\n", __func__
);
6521 dma_unmap_single(&vha
->hw
->pdev
->dev
, dd_dma
, size
, DMA_FROM_DEVICE
);
6526 static void qla2x00_async_mb_sp_done(srb_t
*sp
, int res
)
6528 sp
->u
.iocb_cmd
.u
.mbx
.rc
= res
;
6530 complete(&sp
->u
.iocb_cmd
.u
.mbx
.comp
);
6531 /* don't free sp here. Let the caller do the free */
6535 * This mailbox uses the iocb interface to send MB command.
6536 * This allows non-critial (non chip setup) command to go
6539 int qla24xx_send_mb_cmd(struct scsi_qla_host
*vha
, mbx_cmd_t
*mcp
)
6541 int rval
= QLA_FUNCTION_FAILED
;
6545 if (!vha
->hw
->flags
.fw_started
)
6549 sp
= qla2x00_get_sp(vha
, NULL
, GFP_KERNEL
);
6553 c
= &sp
->u
.iocb_cmd
;
6554 init_completion(&c
->u
.mbx
.comp
);
6556 sp
->type
= SRB_MB_IOCB
;
6557 sp
->name
= mb_to_str(mcp
->mb
[0]);
6558 qla2x00_init_async_sp(sp
, qla2x00_get_async_timeout(vha
) + 2,
6559 qla2x00_async_mb_sp_done
);
6561 memcpy(sp
->u
.iocb_cmd
.u
.mbx
.out_mb
, mcp
->mb
, SIZEOF_IOCB_MB_REG
);
6563 rval
= qla2x00_start_sp(sp
);
6564 if (rval
!= QLA_SUCCESS
) {
6565 ql_dbg(ql_dbg_mbx
, vha
, 0x1018,
6566 "%s: %s Failed submission. %x.\n",
6567 __func__
, sp
->name
, rval
);
6571 ql_dbg(ql_dbg_mbx
, vha
, 0x113f, "MB:%s hndl %x submitted\n",
6572 sp
->name
, sp
->handle
);
6574 wait_for_completion(&c
->u
.mbx
.comp
);
6575 memcpy(mcp
->mb
, sp
->u
.iocb_cmd
.u
.mbx
.in_mb
, SIZEOF_IOCB_MB_REG
);
6579 case QLA_FUNCTION_TIMEOUT
:
6580 ql_dbg(ql_dbg_mbx
, vha
, 0x1140, "%s: %s Timeout. %x.\n",
6581 __func__
, sp
->name
, rval
);
6584 ql_dbg(ql_dbg_mbx
, vha
, 0x119d, "%s: %s done.\n",
6585 __func__
, sp
->name
);
6588 ql_dbg(ql_dbg_mbx
, vha
, 0x119e, "%s: %s Failed. %x.\n",
6589 __func__
, sp
->name
, rval
);
6595 kref_put(&sp
->cmd_kref
, qla2x00_sp_release
);
6602 * NOTE: Do not call this routine from DPC thread
6604 int qla24xx_gpdb_wait(struct scsi_qla_host
*vha
, fc_port_t
*fcport
, u8 opt
)
6606 int rval
= QLA_FUNCTION_FAILED
;
6608 struct port_database_24xx
*pd
;
6609 struct qla_hw_data
*ha
= vha
->hw
;
6612 if (!vha
->hw
->flags
.fw_started
)
6615 pd
= dma_pool_zalloc(ha
->s_dma_pool
, GFP_KERNEL
, &pd_dma
);
6617 ql_log(ql_log_warn
, vha
, 0xd047,
6618 "Failed to allocate port database structure.\n");
6622 memset(&mc
, 0, sizeof(mc
));
6623 mc
.mb
[0] = MBC_GET_PORT_DATABASE
;
6624 mc
.mb
[1] = fcport
->loop_id
;
6625 mc
.mb
[2] = MSW(pd_dma
);
6626 mc
.mb
[3] = LSW(pd_dma
);
6627 mc
.mb
[6] = MSW(MSD(pd_dma
));
6628 mc
.mb
[7] = LSW(MSD(pd_dma
));
6629 mc
.mb
[9] = vha
->vp_idx
;
6632 rval
= qla24xx_send_mb_cmd(vha
, &mc
);
6633 if (rval
!= QLA_SUCCESS
) {
6634 ql_dbg(ql_dbg_mbx
, vha
, 0x1193,
6635 "%s: %8phC fail\n", __func__
, fcport
->port_name
);
6639 rval
= __qla24xx_parse_gpdb(vha
, fcport
, pd
);
6641 ql_dbg(ql_dbg_mbx
, vha
, 0x1197, "%s: %8phC done\n",
6642 __func__
, fcport
->port_name
);
6646 dma_pool_free(ha
->s_dma_pool
, pd
, pd_dma
);
6651 int __qla24xx_parse_gpdb(struct scsi_qla_host
*vha
, fc_port_t
*fcport
,
6652 struct port_database_24xx
*pd
)
6654 int rval
= QLA_SUCCESS
;
6656 u8 current_login_state
, last_login_state
;
6658 if (NVME_TARGET(vha
->hw
, fcport
)) {
6659 current_login_state
= pd
->current_login_state
>> 4;
6660 last_login_state
= pd
->last_login_state
>> 4;
6662 current_login_state
= pd
->current_login_state
& 0xf;
6663 last_login_state
= pd
->last_login_state
& 0xf;
6666 /* Check for logged in state. */
6667 if (current_login_state
!= PDS_PRLI_COMPLETE
) {
6668 ql_dbg(ql_dbg_mbx
, vha
, 0x119a,
6669 "Unable to verify login-state (%x/%x) for loop_id %x.\n",
6670 current_login_state
, last_login_state
, fcport
->loop_id
);
6671 rval
= QLA_FUNCTION_FAILED
;
6675 if (fcport
->loop_id
== FC_NO_LOOP_ID
||
6676 (memcmp(fcport
->port_name
, (uint8_t *)&zero
, 8) &&
6677 memcmp(fcport
->port_name
, pd
->port_name
, 8))) {
6678 /* We lost the device mid way. */
6679 rval
= QLA_NOT_LOGGED_IN
;
6683 /* Names are little-endian. */
6684 memcpy(fcport
->node_name
, pd
->node_name
, WWN_SIZE
);
6685 memcpy(fcport
->port_name
, pd
->port_name
, WWN_SIZE
);
6687 /* Get port_id of device. */
6688 fcport
->d_id
.b
.domain
= pd
->port_id
[0];
6689 fcport
->d_id
.b
.area
= pd
->port_id
[1];
6690 fcport
->d_id
.b
.al_pa
= pd
->port_id
[2];
6691 fcport
->d_id
.b
.rsvd_1
= 0;
6693 ql_dbg(ql_dbg_disc
, vha
, 0x2062,
6694 "%8phC SVC Param w3 %02x%02x",
6696 pd
->prli_svc_param_word_3
[1],
6697 pd
->prli_svc_param_word_3
[0]);
6699 if (NVME_TARGET(vha
->hw
, fcport
)) {
6700 fcport
->port_type
= FCT_NVME
;
6701 if ((pd
->prli_svc_param_word_3
[0] & BIT_5
) == 0)
6702 fcport
->port_type
|= FCT_NVME_INITIATOR
;
6703 if ((pd
->prli_svc_param_word_3
[0] & BIT_4
) == 0)
6704 fcport
->port_type
|= FCT_NVME_TARGET
;
6705 if ((pd
->prli_svc_param_word_3
[0] & BIT_3
) == 0)
6706 fcport
->port_type
|= FCT_NVME_DISCOVERY
;
6708 /* If not target must be initiator or unknown type. */
6709 if ((pd
->prli_svc_param_word_3
[0] & BIT_4
) == 0)
6710 fcport
->port_type
= FCT_INITIATOR
;
6712 fcport
->port_type
= FCT_TARGET
;
6714 /* Passback COS information. */
6715 fcport
->supported_classes
= (pd
->flags
& PDF_CLASS_2
) ?
6716 FC_COS_CLASS2
: FC_COS_CLASS3
;
6718 if (pd
->prli_svc_param_word_3
[0] & BIT_7
) {
6719 fcport
->flags
|= FCF_CONF_COMP_SUPPORTED
;
6720 fcport
->conf_compl_supported
= 1;
6728 * qla24xx_gidlist__wait
6729 * NOTE: don't call this routine from DPC thread.
6731 int qla24xx_gidlist_wait(struct scsi_qla_host
*vha
,
6732 void *id_list
, dma_addr_t id_list_dma
, uint16_t *entries
)
6734 int rval
= QLA_FUNCTION_FAILED
;
6737 if (!vha
->hw
->flags
.fw_started
)
6740 memset(&mc
, 0, sizeof(mc
));
6741 mc
.mb
[0] = MBC_GET_ID_LIST
;
6742 mc
.mb
[2] = MSW(id_list_dma
);
6743 mc
.mb
[3] = LSW(id_list_dma
);
6744 mc
.mb
[6] = MSW(MSD(id_list_dma
));
6745 mc
.mb
[7] = LSW(MSD(id_list_dma
));
6747 mc
.mb
[9] = vha
->vp_idx
;
6749 rval
= qla24xx_send_mb_cmd(vha
, &mc
);
6750 if (rval
!= QLA_SUCCESS
) {
6751 ql_dbg(ql_dbg_mbx
, vha
, 0x119b,
6752 "%s: fail\n", __func__
);
6754 *entries
= mc
.mb
[1];
6755 ql_dbg(ql_dbg_mbx
, vha
, 0x119c,
6756 "%s: done\n", __func__
);
6762 int qla27xx_set_zio_threshold(scsi_qla_host_t
*vha
, uint16_t value
)
6766 mbx_cmd_t
*mcp
= &mc
;
6768 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x1200,
6769 "Entered %s\n", __func__
);
6771 memset(mcp
->mb
, 0 , sizeof(mcp
->mb
));
6772 mcp
->mb
[0] = MBC_GET_SET_ZIO_THRESHOLD
;
6775 mcp
->out_mb
= MBX_2
| MBX_1
| MBX_0
;
6776 mcp
->in_mb
= MBX_2
| MBX_0
;
6777 mcp
->tov
= MBX_TOV_SECONDS
;
6780 rval
= qla2x00_mailbox_command(vha
, mcp
);
6782 ql_dbg(ql_dbg_mbx
, vha
, 0x1201, "%s %x\n",
6783 (rval
!= QLA_SUCCESS
) ? "Failed" : "Done", rval
);
6788 int qla27xx_get_zio_threshold(scsi_qla_host_t
*vha
, uint16_t *value
)
6792 mbx_cmd_t
*mcp
= &mc
;
6794 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x1203,
6795 "Entered %s\n", __func__
);
6797 memset(mcp
->mb
, 0, sizeof(mcp
->mb
));
6798 mcp
->mb
[0] = MBC_GET_SET_ZIO_THRESHOLD
;
6800 mcp
->out_mb
= MBX_1
| MBX_0
;
6801 mcp
->in_mb
= MBX_2
| MBX_0
;
6802 mcp
->tov
= MBX_TOV_SECONDS
;
6805 rval
= qla2x00_mailbox_command(vha
, mcp
);
6806 if (rval
== QLA_SUCCESS
)
6809 ql_dbg(ql_dbg_mbx
, vha
, 0x1205, "%s %x\n",
6810 (rval
!= QLA_SUCCESS
) ? "Failed" : "Done", rval
);
6816 qla2x00_read_sfp_dev(struct scsi_qla_host
*vha
, char *buf
, int count
)
6818 struct qla_hw_data
*ha
= vha
->hw
;
6819 uint16_t iter
, addr
, offset
;
6820 dma_addr_t phys_addr
;
6824 memset(ha
->sfp_data
, 0, SFP_DEV_SIZE
);
6826 phys_addr
= ha
->sfp_data_dma
;
6827 sfp_data
= ha
->sfp_data
;
6830 for (iter
= 0; iter
< SFP_DEV_SIZE
/ SFP_BLOCK_SIZE
; iter
++) {
6832 /* Skip to next device address. */
6837 rval
= qla2x00_read_sfp(vha
, phys_addr
, sfp_data
,
6838 addr
, offset
, SFP_BLOCK_SIZE
, BIT_1
);
6839 if (rval
!= QLA_SUCCESS
) {
6840 ql_log(ql_log_warn
, vha
, 0x706d,
6841 "Unable to read SFP data (%x/%x/%x).\n", rval
,
6847 if (buf
&& (c
< count
)) {
6850 if ((count
- c
) >= SFP_BLOCK_SIZE
)
6851 sz
= SFP_BLOCK_SIZE
;
6855 memcpy(buf
, sfp_data
, sz
);
6856 buf
+= SFP_BLOCK_SIZE
;
6859 phys_addr
+= SFP_BLOCK_SIZE
;
6860 sfp_data
+= SFP_BLOCK_SIZE
;
6861 offset
+= SFP_BLOCK_SIZE
;
6867 int qla24xx_res_count_wait(struct scsi_qla_host
*vha
,
6868 uint16_t *out_mb
, int out_mb_sz
)
6870 int rval
= QLA_FUNCTION_FAILED
;
6873 if (!vha
->hw
->flags
.fw_started
)
6876 memset(&mc
, 0, sizeof(mc
));
6877 mc
.mb
[0] = MBC_GET_RESOURCE_COUNTS
;
6879 rval
= qla24xx_send_mb_cmd(vha
, &mc
);
6880 if (rval
!= QLA_SUCCESS
) {
6881 ql_dbg(ql_dbg_mbx
, vha
, 0xffff,
6882 "%s: fail\n", __func__
);
6884 if (out_mb_sz
<= SIZEOF_IOCB_MB_REG
)
6885 memcpy(out_mb
, mc
.mb
, out_mb_sz
);
6887 memcpy(out_mb
, mc
.mb
, SIZEOF_IOCB_MB_REG
);
6889 ql_dbg(ql_dbg_mbx
, vha
, 0xffff,
6890 "%s: done\n", __func__
);
6896 int qla28xx_secure_flash_update(scsi_qla_host_t
*vha
, uint16_t opts
,
6897 uint16_t region
, uint32_t len
, dma_addr_t sfub_dma_addr
,
6902 mbx_cmd_t
*mcp
= &mc
;
6904 mcp
->mb
[0] = MBC_SECURE_FLASH_UPDATE
;
6906 mcp
->mb
[2] = region
;
6907 mcp
->mb
[3] = MSW(len
);
6908 mcp
->mb
[4] = LSW(len
);
6909 mcp
->mb
[5] = MSW(sfub_dma_addr
);
6910 mcp
->mb
[6] = LSW(sfub_dma_addr
);
6911 mcp
->mb
[7] = MSW(MSD(sfub_dma_addr
));
6912 mcp
->mb
[8] = LSW(MSD(sfub_dma_addr
));
6913 mcp
->mb
[9] = sfub_len
;
6915 MBX_9
|MBX_8
|MBX_7
|MBX_6
|MBX_5
|MBX_4
|MBX_3
|MBX_2
|MBX_1
|MBX_0
;
6916 mcp
->in_mb
= MBX_2
|MBX_1
|MBX_0
;
6917 mcp
->tov
= MBX_TOV_SECONDS
;
6919 rval
= qla2x00_mailbox_command(vha
, mcp
);
6921 if (rval
!= QLA_SUCCESS
) {
6922 ql_dbg(ql_dbg_mbx
, vha
, 0xffff, "%s(%ld): failed rval 0x%x, %x %x %x",
6923 __func__
, vha
->host_no
, rval
, mcp
->mb
[0], mcp
->mb
[1],
6930 int qla2xxx_write_remote_register(scsi_qla_host_t
*vha
, uint32_t addr
,
6935 mbx_cmd_t
*mcp
= &mc
;
6937 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x10e8,
6938 "Entered %s.\n", __func__
);
6940 mcp
->mb
[0] = MBC_WRITE_REMOTE_REG
;
6941 mcp
->mb
[1] = LSW(addr
);
6942 mcp
->mb
[2] = MSW(addr
);
6943 mcp
->mb
[3] = LSW(data
);
6944 mcp
->mb
[4] = MSW(data
);
6945 mcp
->out_mb
= MBX_4
|MBX_3
|MBX_2
|MBX_1
|MBX_0
;
6946 mcp
->in_mb
= MBX_1
|MBX_0
;
6947 mcp
->tov
= MBX_TOV_SECONDS
;
6949 rval
= qla2x00_mailbox_command(vha
, mcp
);
6951 if (rval
!= QLA_SUCCESS
) {
6952 ql_dbg(ql_dbg_mbx
, vha
, 0x10e9,
6953 "Failed=%x mb[0]=%x.\n", rval
, mcp
->mb
[0]);
6955 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x10ea,
6956 "Done %s.\n", __func__
);
6962 int qla2xxx_read_remote_register(scsi_qla_host_t
*vha
, uint32_t addr
,
6967 mbx_cmd_t
*mcp
= &mc
;
6969 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x10e8,
6970 "Entered %s.\n", __func__
);
6972 mcp
->mb
[0] = MBC_READ_REMOTE_REG
;
6973 mcp
->mb
[1] = LSW(addr
);
6974 mcp
->mb
[2] = MSW(addr
);
6975 mcp
->out_mb
= MBX_2
|MBX_1
|MBX_0
;
6976 mcp
->in_mb
= MBX_4
|MBX_3
|MBX_2
|MBX_1
|MBX_0
;
6977 mcp
->tov
= MBX_TOV_SECONDS
;
6979 rval
= qla2x00_mailbox_command(vha
, mcp
);
6981 *data
= (uint32_t)((((uint32_t)mcp
->mb
[4]) << 16) | mcp
->mb
[3]);
6983 if (rval
!= QLA_SUCCESS
) {
6984 ql_dbg(ql_dbg_mbx
, vha
, 0x10e9,
6985 "Failed=%x mb[0]=%x.\n", rval
, mcp
->mb
[0]);
6987 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0x10ea,
6988 "Done %s.\n", __func__
);
6995 ql26xx_led_config(scsi_qla_host_t
*vha
, uint16_t options
, uint16_t *led
)
6997 struct qla_hw_data
*ha
= vha
->hw
;
6999 mbx_cmd_t
*mcp
= &mc
;
7002 if (!IS_QLA2031(ha
) && !IS_QLA27XX(ha
) && !IS_QLA28XX(ha
))
7003 return QLA_FUNCTION_FAILED
;
7005 ql_dbg(ql_dbg_mbx
, vha
, 0x7070, "Entered %s (options=%x).\n",
7008 mcp
->mb
[0] = MBC_SET_GET_FC_LED_CONFIG
;
7009 mcp
->mb
[1] = options
;
7010 mcp
->out_mb
= MBX_1
|MBX_0
;
7011 mcp
->in_mb
= MBX_1
|MBX_0
;
7012 if (options
& BIT_0
) {
7013 if (options
& BIT_1
) {
7014 mcp
->mb
[2] = led
[2];
7015 mcp
->out_mb
|= MBX_2
;
7017 if (options
& BIT_2
) {
7018 mcp
->mb
[3] = led
[0];
7019 mcp
->out_mb
|= MBX_3
;
7021 if (options
& BIT_3
) {
7022 mcp
->mb
[4] = led
[1];
7023 mcp
->out_mb
|= MBX_4
;
7026 mcp
->in_mb
|= MBX_4
|MBX_3
|MBX_2
;
7028 mcp
->tov
= MBX_TOV_SECONDS
;
7030 rval
= qla2x00_mailbox_command(vha
, mcp
);
7032 ql_dbg(ql_dbg_mbx
, vha
, 0x7071, "Failed %s %x (mb=%x,%x)\n",
7033 __func__
, rval
, mcp
->mb
[0], mcp
->mb
[1]);
7037 if (options
& BIT_0
) {
7038 ha
->beacon_blink_led
= 0;
7039 ql_dbg(ql_dbg_mbx
, vha
, 0x7072, "Done %s\n", __func__
);
7041 led
[2] = mcp
->mb
[2];
7042 led
[0] = mcp
->mb
[3];
7043 led
[1] = mcp
->mb
[4];
7044 ql_dbg(ql_dbg_mbx
, vha
, 0x7073, "Done %s (led=%x,%x,%x)\n",
7045 __func__
, led
[0], led
[1], led
[2]);
7052 * qla_no_op_mb(): This MB is used to check if FW is still alive and
7053 * able to generate an interrupt. Otherwise, a timeout will trigger
7055 * @vha: host adapter pointer
7058 void qla_no_op_mb(struct scsi_qla_host
*vha
)
7061 mbx_cmd_t
*mcp
= &mc
;
7064 memset(&mc
, 0, sizeof(mc
));
7065 mcp
->mb
[0] = 0; // noop cmd= 0
7066 mcp
->out_mb
= MBX_0
;
7070 rval
= qla2x00_mailbox_command(vha
, mcp
);
7073 ql_dbg(ql_dbg_async
, vha
, 0x7071,
7074 "Failed %s %x\n", __func__
, rval
);
7078 int qla_mailbox_passthru(scsi_qla_host_t
*vha
,
7079 uint16_t *mbx_in
, uint16_t *mbx_out
)
7082 mbx_cmd_t
*mcp
= &mc
;
7085 memset(&mc
, 0, sizeof(mc
));
7086 /* Receiving all 32 register's contents */
7087 memcpy(&mcp
->mb
, (char *)mbx_in
, (32 * sizeof(uint16_t)));
7089 mcp
->out_mb
= 0xFFFFFFFF;
7090 mcp
->in_mb
= 0xFFFFFFFF;
7092 mcp
->tov
= MBX_TOV_SECONDS
;
7096 rval
= qla2x00_mailbox_command(vha
, mcp
);
7098 if (rval
!= QLA_SUCCESS
) {
7099 ql_dbg(ql_dbg_mbx
, vha
, 0xf0a2,
7100 "Failed=%x mb[0]=%x.\n", rval
, mcp
->mb
[0]);
7102 ql_dbg(ql_dbg_mbx
+ ql_dbg_verbose
, vha
, 0xf0a3, "Done %s.\n",
7104 /* passing all 32 register's contents */
7105 memcpy(mbx_out
, &mcp
->mb
, 32 * sizeof(uint16_t));