18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0-only
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci * QLogic Fibre Channel HBA Driver
48c2ecf20Sopenharmony_ci * Copyright (c)  2003-2014 QLogic Corporation
58c2ecf20Sopenharmony_ci */
68c2ecf20Sopenharmony_ci
78c2ecf20Sopenharmony_ci/*
88c2ecf20Sopenharmony_ci * Table for showing the current message id in use for particular level
98c2ecf20Sopenharmony_ci * Change this table for addition of log/debug messages.
108c2ecf20Sopenharmony_ci * ----------------------------------------------------------------------
118c2ecf20Sopenharmony_ci * |             Level            |   Last Value Used  |     Holes	|
128c2ecf20Sopenharmony_ci * ----------------------------------------------------------------------
138c2ecf20Sopenharmony_ci * | Module Init and Probe        |       0x0199       |                |
148c2ecf20Sopenharmony_ci * | Mailbox commands             |       0x1206       | 0x11a5-0x11ff	|
158c2ecf20Sopenharmony_ci * | Device Discovery             |       0x2134       | 0x210e-0x2115  |
168c2ecf20Sopenharmony_ci * |                              |                    | 0x211c-0x2128  |
178c2ecf20Sopenharmony_ci * |                              |                    | 0x212c-0x2134  |
188c2ecf20Sopenharmony_ci * | Queue Command and IO tracing |       0x3074       | 0x300b         |
198c2ecf20Sopenharmony_ci * |                              |                    | 0x3027-0x3028  |
208c2ecf20Sopenharmony_ci * |                              |                    | 0x303d-0x3041  |
218c2ecf20Sopenharmony_ci * |                              |                    | 0x302e,0x3033  |
228c2ecf20Sopenharmony_ci * |                              |                    | 0x3036,0x3038  |
238c2ecf20Sopenharmony_ci * |                              |                    | 0x303a		|
248c2ecf20Sopenharmony_ci * | DPC Thread                   |       0x4023       | 0x4002,0x4013  |
258c2ecf20Sopenharmony_ci * | Async Events                 |       0x509c       |                |
268c2ecf20Sopenharmony_ci * | Timer Routines               |       0x6012       |                |
278c2ecf20Sopenharmony_ci * | User Space Interactions      |       0x70e3       | 0x7018,0x702e  |
288c2ecf20Sopenharmony_ci * |				  |		       | 0x7020,0x7024  |
298c2ecf20Sopenharmony_ci * |                              |                    | 0x7039,0x7045  |
308c2ecf20Sopenharmony_ci * |                              |                    | 0x7073-0x7075  |
318c2ecf20Sopenharmony_ci * |                              |                    | 0x70a5-0x70a6  |
328c2ecf20Sopenharmony_ci * |                              |                    | 0x70a8,0x70ab  |
338c2ecf20Sopenharmony_ci * |                              |                    | 0x70ad-0x70ae  |
348c2ecf20Sopenharmony_ci * |                              |                    | 0x70d0-0x70d6	|
358c2ecf20Sopenharmony_ci * |                              |                    | 0x70d7-0x70db  |
368c2ecf20Sopenharmony_ci * | Task Management              |       0x8042       | 0x8000         |
378c2ecf20Sopenharmony_ci * |                              |                    | 0x8019         |
388c2ecf20Sopenharmony_ci * |                              |                    | 0x8025,0x8026  |
398c2ecf20Sopenharmony_ci * |                              |                    | 0x8031,0x8032  |
408c2ecf20Sopenharmony_ci * |                              |                    | 0x8039,0x803c  |
418c2ecf20Sopenharmony_ci * | AER/EEH                      |       0x9011       |		|
428c2ecf20Sopenharmony_ci * | Virtual Port                 |       0xa007       |		|
438c2ecf20Sopenharmony_ci * | ISP82XX Specific             |       0xb157       | 0xb002,0xb024  |
448c2ecf20Sopenharmony_ci * |                              |                    | 0xb09e,0xb0ae  |
458c2ecf20Sopenharmony_ci * |				  |		       | 0xb0c3,0xb0c6  |
468c2ecf20Sopenharmony_ci * |                              |                    | 0xb0e0-0xb0ef  |
478c2ecf20Sopenharmony_ci * |                              |                    | 0xb085,0xb0dc  |
488c2ecf20Sopenharmony_ci * |                              |                    | 0xb107,0xb108  |
498c2ecf20Sopenharmony_ci * |                              |                    | 0xb111,0xb11e  |
508c2ecf20Sopenharmony_ci * |                              |                    | 0xb12c,0xb12d  |
518c2ecf20Sopenharmony_ci * |                              |                    | 0xb13a,0xb142  |
528c2ecf20Sopenharmony_ci * |                              |                    | 0xb13c-0xb140  |
538c2ecf20Sopenharmony_ci * |                              |                    | 0xb149		|
548c2ecf20Sopenharmony_ci * | MultiQ                       |       0xc010       |		|
558c2ecf20Sopenharmony_ci * | Misc                         |       0xd303       | 0xd031-0xd0ff	|
568c2ecf20Sopenharmony_ci * |                              |                    | 0xd101-0xd1fe	|
578c2ecf20Sopenharmony_ci * |                              |                    | 0xd214-0xd2fe	|
588c2ecf20Sopenharmony_ci * | Target Mode		  |	  0xe081       |		|
598c2ecf20Sopenharmony_ci * | Target Mode Management	  |	  0xf09b       | 0xf002		|
608c2ecf20Sopenharmony_ci * |                              |                    | 0xf046-0xf049  |
618c2ecf20Sopenharmony_ci * | Target Mode Task Management  |	  0x1000d      |		|
628c2ecf20Sopenharmony_ci * ----------------------------------------------------------------------
638c2ecf20Sopenharmony_ci */
648c2ecf20Sopenharmony_ci
658c2ecf20Sopenharmony_ci#include "qla_def.h"
668c2ecf20Sopenharmony_ci
678c2ecf20Sopenharmony_ci#include <linux/delay.h>
688c2ecf20Sopenharmony_ci#define CREATE_TRACE_POINTS
698c2ecf20Sopenharmony_ci#include <trace/events/qla.h>
708c2ecf20Sopenharmony_ci
718c2ecf20Sopenharmony_cistatic uint32_t ql_dbg_offset = 0x800;
728c2ecf20Sopenharmony_ci
738c2ecf20Sopenharmony_cistatic inline void
748c2ecf20Sopenharmony_ciqla2xxx_prep_dump(struct qla_hw_data *ha, struct qla2xxx_fw_dump *fw_dump)
758c2ecf20Sopenharmony_ci{
768c2ecf20Sopenharmony_ci	fw_dump->fw_major_version = htonl(ha->fw_major_version);
778c2ecf20Sopenharmony_ci	fw_dump->fw_minor_version = htonl(ha->fw_minor_version);
788c2ecf20Sopenharmony_ci	fw_dump->fw_subminor_version = htonl(ha->fw_subminor_version);
798c2ecf20Sopenharmony_ci	fw_dump->fw_attributes = htonl(ha->fw_attributes);
808c2ecf20Sopenharmony_ci
818c2ecf20Sopenharmony_ci	fw_dump->vendor = htonl(ha->pdev->vendor);
828c2ecf20Sopenharmony_ci	fw_dump->device = htonl(ha->pdev->device);
838c2ecf20Sopenharmony_ci	fw_dump->subsystem_vendor = htonl(ha->pdev->subsystem_vendor);
848c2ecf20Sopenharmony_ci	fw_dump->subsystem_device = htonl(ha->pdev->subsystem_device);
858c2ecf20Sopenharmony_ci}
868c2ecf20Sopenharmony_ci
878c2ecf20Sopenharmony_cistatic inline void *
888c2ecf20Sopenharmony_ciqla2xxx_copy_queues(struct qla_hw_data *ha, void *ptr)
898c2ecf20Sopenharmony_ci{
908c2ecf20Sopenharmony_ci	struct req_que *req = ha->req_q_map[0];
918c2ecf20Sopenharmony_ci	struct rsp_que *rsp = ha->rsp_q_map[0];
928c2ecf20Sopenharmony_ci	/* Request queue. */
938c2ecf20Sopenharmony_ci	memcpy(ptr, req->ring, req->length *
948c2ecf20Sopenharmony_ci	    sizeof(request_t));
958c2ecf20Sopenharmony_ci
968c2ecf20Sopenharmony_ci	/* Response queue. */
978c2ecf20Sopenharmony_ci	ptr += req->length * sizeof(request_t);
988c2ecf20Sopenharmony_ci	memcpy(ptr, rsp->ring, rsp->length  *
998c2ecf20Sopenharmony_ci	    sizeof(response_t));
1008c2ecf20Sopenharmony_ci
1018c2ecf20Sopenharmony_ci	return ptr + (rsp->length * sizeof(response_t));
1028c2ecf20Sopenharmony_ci}
1038c2ecf20Sopenharmony_ci
1048c2ecf20Sopenharmony_ciint
1058c2ecf20Sopenharmony_ciqla27xx_dump_mpi_ram(struct qla_hw_data *ha, uint32_t addr, uint32_t *ram,
1068c2ecf20Sopenharmony_ci	uint32_t ram_dwords, void **nxt)
1078c2ecf20Sopenharmony_ci{
1088c2ecf20Sopenharmony_ci	struct device_reg_24xx __iomem *reg = &ha->iobase->isp24;
1098c2ecf20Sopenharmony_ci	dma_addr_t dump_dma = ha->gid_list_dma;
1108c2ecf20Sopenharmony_ci	uint32_t *chunk = (uint32_t *)ha->gid_list;
1118c2ecf20Sopenharmony_ci	uint32_t dwords = qla2x00_gid_list_size(ha) / 4;
1128c2ecf20Sopenharmony_ci	uint32_t stat;
1138c2ecf20Sopenharmony_ci	ulong i, j, timer = 6000000;
1148c2ecf20Sopenharmony_ci	int rval = QLA_FUNCTION_FAILED;
1158c2ecf20Sopenharmony_ci	scsi_qla_host_t *vha = pci_get_drvdata(ha->pdev);
1168c2ecf20Sopenharmony_ci
1178c2ecf20Sopenharmony_ci	clear_bit(MBX_INTERRUPT, &ha->mbx_cmd_flags);
1188c2ecf20Sopenharmony_ci
1198c2ecf20Sopenharmony_ci	if (qla_pci_disconnected(vha, reg))
1208c2ecf20Sopenharmony_ci		return rval;
1218c2ecf20Sopenharmony_ci
1228c2ecf20Sopenharmony_ci	for (i = 0; i < ram_dwords; i += dwords, addr += dwords) {
1238c2ecf20Sopenharmony_ci		if (i + dwords > ram_dwords)
1248c2ecf20Sopenharmony_ci			dwords = ram_dwords - i;
1258c2ecf20Sopenharmony_ci
1268c2ecf20Sopenharmony_ci		wrt_reg_word(&reg->mailbox0, MBC_LOAD_DUMP_MPI_RAM);
1278c2ecf20Sopenharmony_ci		wrt_reg_word(&reg->mailbox1, LSW(addr));
1288c2ecf20Sopenharmony_ci		wrt_reg_word(&reg->mailbox8, MSW(addr));
1298c2ecf20Sopenharmony_ci
1308c2ecf20Sopenharmony_ci		wrt_reg_word(&reg->mailbox2, MSW(LSD(dump_dma)));
1318c2ecf20Sopenharmony_ci		wrt_reg_word(&reg->mailbox3, LSW(LSD(dump_dma)));
1328c2ecf20Sopenharmony_ci		wrt_reg_word(&reg->mailbox6, MSW(MSD(dump_dma)));
1338c2ecf20Sopenharmony_ci		wrt_reg_word(&reg->mailbox7, LSW(MSD(dump_dma)));
1348c2ecf20Sopenharmony_ci
1358c2ecf20Sopenharmony_ci		wrt_reg_word(&reg->mailbox4, MSW(dwords));
1368c2ecf20Sopenharmony_ci		wrt_reg_word(&reg->mailbox5, LSW(dwords));
1378c2ecf20Sopenharmony_ci
1388c2ecf20Sopenharmony_ci		wrt_reg_word(&reg->mailbox9, 0);
1398c2ecf20Sopenharmony_ci		wrt_reg_dword(&reg->hccr, HCCRX_SET_HOST_INT);
1408c2ecf20Sopenharmony_ci
1418c2ecf20Sopenharmony_ci		ha->flags.mbox_int = 0;
1428c2ecf20Sopenharmony_ci		while (timer--) {
1438c2ecf20Sopenharmony_ci			udelay(5);
1448c2ecf20Sopenharmony_ci
1458c2ecf20Sopenharmony_ci			if (qla_pci_disconnected(vha, reg))
1468c2ecf20Sopenharmony_ci				return rval;
1478c2ecf20Sopenharmony_ci
1488c2ecf20Sopenharmony_ci			stat = rd_reg_dword(&reg->host_status);
1498c2ecf20Sopenharmony_ci			/* Check for pending interrupts. */
1508c2ecf20Sopenharmony_ci			if (!(stat & HSRX_RISC_INT))
1518c2ecf20Sopenharmony_ci				continue;
1528c2ecf20Sopenharmony_ci
1538c2ecf20Sopenharmony_ci			stat &= 0xff;
1548c2ecf20Sopenharmony_ci			if (stat != 0x1 && stat != 0x2 &&
1558c2ecf20Sopenharmony_ci			    stat != 0x10 && stat != 0x11) {
1568c2ecf20Sopenharmony_ci
1578c2ecf20Sopenharmony_ci				/* Clear this intr; it wasn't a mailbox intr */
1588c2ecf20Sopenharmony_ci				wrt_reg_dword(&reg->hccr, HCCRX_CLR_RISC_INT);
1598c2ecf20Sopenharmony_ci				rd_reg_dword(&reg->hccr);
1608c2ecf20Sopenharmony_ci				continue;
1618c2ecf20Sopenharmony_ci			}
1628c2ecf20Sopenharmony_ci
1638c2ecf20Sopenharmony_ci			set_bit(MBX_INTERRUPT, &ha->mbx_cmd_flags);
1648c2ecf20Sopenharmony_ci			rval = rd_reg_word(&reg->mailbox0) & MBS_MASK;
1658c2ecf20Sopenharmony_ci			wrt_reg_dword(&reg->hccr, HCCRX_CLR_RISC_INT);
1668c2ecf20Sopenharmony_ci			rd_reg_dword(&reg->hccr);
1678c2ecf20Sopenharmony_ci			break;
1688c2ecf20Sopenharmony_ci		}
1698c2ecf20Sopenharmony_ci		ha->flags.mbox_int = 1;
1708c2ecf20Sopenharmony_ci		*nxt = ram + i;
1718c2ecf20Sopenharmony_ci
1728c2ecf20Sopenharmony_ci		if (!test_and_clear_bit(MBX_INTERRUPT, &ha->mbx_cmd_flags)) {
1738c2ecf20Sopenharmony_ci			/* no interrupt, timed out*/
1748c2ecf20Sopenharmony_ci			return rval;
1758c2ecf20Sopenharmony_ci		}
1768c2ecf20Sopenharmony_ci		if (rval) {
1778c2ecf20Sopenharmony_ci			/* error completion status */
1788c2ecf20Sopenharmony_ci			return rval;
1798c2ecf20Sopenharmony_ci		}
1808c2ecf20Sopenharmony_ci		for (j = 0; j < dwords; j++) {
1818c2ecf20Sopenharmony_ci			ram[i + j] =
1828c2ecf20Sopenharmony_ci			    (IS_QLA27XX(ha) || IS_QLA28XX(ha)) ?
1838c2ecf20Sopenharmony_ci			    chunk[j] : swab32(chunk[j]);
1848c2ecf20Sopenharmony_ci		}
1858c2ecf20Sopenharmony_ci	}
1868c2ecf20Sopenharmony_ci
1878c2ecf20Sopenharmony_ci	*nxt = ram + i;
1888c2ecf20Sopenharmony_ci	return QLA_SUCCESS;
1898c2ecf20Sopenharmony_ci}
1908c2ecf20Sopenharmony_ci
1918c2ecf20Sopenharmony_ciint
1928c2ecf20Sopenharmony_ciqla24xx_dump_ram(struct qla_hw_data *ha, uint32_t addr, __be32 *ram,
1938c2ecf20Sopenharmony_ci		 uint32_t ram_dwords, void **nxt)
1948c2ecf20Sopenharmony_ci{
1958c2ecf20Sopenharmony_ci	int rval = QLA_FUNCTION_FAILED;
1968c2ecf20Sopenharmony_ci	struct device_reg_24xx __iomem *reg = &ha->iobase->isp24;
1978c2ecf20Sopenharmony_ci	dma_addr_t dump_dma = ha->gid_list_dma;
1988c2ecf20Sopenharmony_ci	uint32_t *chunk = (uint32_t *)ha->gid_list;
1998c2ecf20Sopenharmony_ci	uint32_t dwords = qla2x00_gid_list_size(ha) / 4;
2008c2ecf20Sopenharmony_ci	uint32_t stat;
2018c2ecf20Sopenharmony_ci	ulong i, j, timer = 6000000;
2028c2ecf20Sopenharmony_ci	scsi_qla_host_t *vha = pci_get_drvdata(ha->pdev);
2038c2ecf20Sopenharmony_ci
2048c2ecf20Sopenharmony_ci	clear_bit(MBX_INTERRUPT, &ha->mbx_cmd_flags);
2058c2ecf20Sopenharmony_ci
2068c2ecf20Sopenharmony_ci	if (qla_pci_disconnected(vha, reg))
2078c2ecf20Sopenharmony_ci		return rval;
2088c2ecf20Sopenharmony_ci
2098c2ecf20Sopenharmony_ci	for (i = 0; i < ram_dwords; i += dwords, addr += dwords) {
2108c2ecf20Sopenharmony_ci		if (i + dwords > ram_dwords)
2118c2ecf20Sopenharmony_ci			dwords = ram_dwords - i;
2128c2ecf20Sopenharmony_ci
2138c2ecf20Sopenharmony_ci		wrt_reg_word(&reg->mailbox0, MBC_DUMP_RISC_RAM_EXTENDED);
2148c2ecf20Sopenharmony_ci		wrt_reg_word(&reg->mailbox1, LSW(addr));
2158c2ecf20Sopenharmony_ci		wrt_reg_word(&reg->mailbox8, MSW(addr));
2168c2ecf20Sopenharmony_ci		wrt_reg_word(&reg->mailbox10, 0);
2178c2ecf20Sopenharmony_ci
2188c2ecf20Sopenharmony_ci		wrt_reg_word(&reg->mailbox2, MSW(LSD(dump_dma)));
2198c2ecf20Sopenharmony_ci		wrt_reg_word(&reg->mailbox3, LSW(LSD(dump_dma)));
2208c2ecf20Sopenharmony_ci		wrt_reg_word(&reg->mailbox6, MSW(MSD(dump_dma)));
2218c2ecf20Sopenharmony_ci		wrt_reg_word(&reg->mailbox7, LSW(MSD(dump_dma)));
2228c2ecf20Sopenharmony_ci
2238c2ecf20Sopenharmony_ci		wrt_reg_word(&reg->mailbox4, MSW(dwords));
2248c2ecf20Sopenharmony_ci		wrt_reg_word(&reg->mailbox5, LSW(dwords));
2258c2ecf20Sopenharmony_ci		wrt_reg_dword(&reg->hccr, HCCRX_SET_HOST_INT);
2268c2ecf20Sopenharmony_ci
2278c2ecf20Sopenharmony_ci		ha->flags.mbox_int = 0;
2288c2ecf20Sopenharmony_ci		while (timer--) {
2298c2ecf20Sopenharmony_ci			udelay(5);
2308c2ecf20Sopenharmony_ci			if (qla_pci_disconnected(vha, reg))
2318c2ecf20Sopenharmony_ci				return rval;
2328c2ecf20Sopenharmony_ci
2338c2ecf20Sopenharmony_ci			stat = rd_reg_dword(&reg->host_status);
2348c2ecf20Sopenharmony_ci			/* Check for pending interrupts. */
2358c2ecf20Sopenharmony_ci			if (!(stat & HSRX_RISC_INT))
2368c2ecf20Sopenharmony_ci				continue;
2378c2ecf20Sopenharmony_ci
2388c2ecf20Sopenharmony_ci			stat &= 0xff;
2398c2ecf20Sopenharmony_ci			if (stat != 0x1 && stat != 0x2 &&
2408c2ecf20Sopenharmony_ci			    stat != 0x10 && stat != 0x11) {
2418c2ecf20Sopenharmony_ci				wrt_reg_dword(&reg->hccr, HCCRX_CLR_RISC_INT);
2428c2ecf20Sopenharmony_ci				rd_reg_dword(&reg->hccr);
2438c2ecf20Sopenharmony_ci				continue;
2448c2ecf20Sopenharmony_ci			}
2458c2ecf20Sopenharmony_ci
2468c2ecf20Sopenharmony_ci			set_bit(MBX_INTERRUPT, &ha->mbx_cmd_flags);
2478c2ecf20Sopenharmony_ci			rval = rd_reg_word(&reg->mailbox0) & MBS_MASK;
2488c2ecf20Sopenharmony_ci			wrt_reg_dword(&reg->hccr, HCCRX_CLR_RISC_INT);
2498c2ecf20Sopenharmony_ci			rd_reg_dword(&reg->hccr);
2508c2ecf20Sopenharmony_ci			break;
2518c2ecf20Sopenharmony_ci		}
2528c2ecf20Sopenharmony_ci		ha->flags.mbox_int = 1;
2538c2ecf20Sopenharmony_ci		*nxt = ram + i;
2548c2ecf20Sopenharmony_ci
2558c2ecf20Sopenharmony_ci		if (!test_and_clear_bit(MBX_INTERRUPT, &ha->mbx_cmd_flags)) {
2568c2ecf20Sopenharmony_ci			/* no interrupt, timed out*/
2578c2ecf20Sopenharmony_ci			return rval;
2588c2ecf20Sopenharmony_ci		}
2598c2ecf20Sopenharmony_ci		if (rval) {
2608c2ecf20Sopenharmony_ci			/* error completion status */
2618c2ecf20Sopenharmony_ci			return rval;
2628c2ecf20Sopenharmony_ci		}
2638c2ecf20Sopenharmony_ci		for (j = 0; j < dwords; j++) {
2648c2ecf20Sopenharmony_ci			ram[i + j] = (__force __be32)
2658c2ecf20Sopenharmony_ci				((IS_QLA27XX(ha) || IS_QLA28XX(ha)) ?
2668c2ecf20Sopenharmony_ci				 chunk[j] : swab32(chunk[j]));
2678c2ecf20Sopenharmony_ci		}
2688c2ecf20Sopenharmony_ci	}
2698c2ecf20Sopenharmony_ci
2708c2ecf20Sopenharmony_ci	*nxt = ram + i;
2718c2ecf20Sopenharmony_ci	return QLA_SUCCESS;
2728c2ecf20Sopenharmony_ci}
2738c2ecf20Sopenharmony_ci
2748c2ecf20Sopenharmony_cistatic int
2758c2ecf20Sopenharmony_ciqla24xx_dump_memory(struct qla_hw_data *ha, __be32 *code_ram,
2768c2ecf20Sopenharmony_ci		    uint32_t cram_size, void **nxt)
2778c2ecf20Sopenharmony_ci{
2788c2ecf20Sopenharmony_ci	int rval;
2798c2ecf20Sopenharmony_ci
2808c2ecf20Sopenharmony_ci	/* Code RAM. */
2818c2ecf20Sopenharmony_ci	rval = qla24xx_dump_ram(ha, 0x20000, code_ram, cram_size / 4, nxt);
2828c2ecf20Sopenharmony_ci	if (rval != QLA_SUCCESS)
2838c2ecf20Sopenharmony_ci		return rval;
2848c2ecf20Sopenharmony_ci
2858c2ecf20Sopenharmony_ci	set_bit(RISC_SRAM_DUMP_CMPL, &ha->fw_dump_cap_flags);
2868c2ecf20Sopenharmony_ci
2878c2ecf20Sopenharmony_ci	/* External Memory. */
2888c2ecf20Sopenharmony_ci	rval = qla24xx_dump_ram(ha, 0x100000, *nxt,
2898c2ecf20Sopenharmony_ci	    ha->fw_memory_size - 0x100000 + 1, nxt);
2908c2ecf20Sopenharmony_ci	if (rval == QLA_SUCCESS)
2918c2ecf20Sopenharmony_ci		set_bit(RISC_EXT_MEM_DUMP_CMPL, &ha->fw_dump_cap_flags);
2928c2ecf20Sopenharmony_ci
2938c2ecf20Sopenharmony_ci	return rval;
2948c2ecf20Sopenharmony_ci}
2958c2ecf20Sopenharmony_ci
2968c2ecf20Sopenharmony_cistatic __be32 *
2978c2ecf20Sopenharmony_ciqla24xx_read_window(struct device_reg_24xx __iomem *reg, uint32_t iobase,
2988c2ecf20Sopenharmony_ci		    uint32_t count, __be32 *buf)
2998c2ecf20Sopenharmony_ci{
3008c2ecf20Sopenharmony_ci	__le32 __iomem *dmp_reg;
3018c2ecf20Sopenharmony_ci
3028c2ecf20Sopenharmony_ci	wrt_reg_dword(&reg->iobase_addr, iobase);
3038c2ecf20Sopenharmony_ci	dmp_reg = &reg->iobase_window;
3048c2ecf20Sopenharmony_ci	for ( ; count--; dmp_reg++)
3058c2ecf20Sopenharmony_ci		*buf++ = htonl(rd_reg_dword(dmp_reg));
3068c2ecf20Sopenharmony_ci
3078c2ecf20Sopenharmony_ci	return buf;
3088c2ecf20Sopenharmony_ci}
3098c2ecf20Sopenharmony_ci
3108c2ecf20Sopenharmony_civoid
3118c2ecf20Sopenharmony_ciqla24xx_pause_risc(struct device_reg_24xx __iomem *reg, struct qla_hw_data *ha)
3128c2ecf20Sopenharmony_ci{
3138c2ecf20Sopenharmony_ci	wrt_reg_dword(&reg->hccr, HCCRX_SET_RISC_PAUSE);
3148c2ecf20Sopenharmony_ci
3158c2ecf20Sopenharmony_ci	/* 100 usec delay is sufficient enough for hardware to pause RISC */
3168c2ecf20Sopenharmony_ci	udelay(100);
3178c2ecf20Sopenharmony_ci	if (rd_reg_dword(&reg->host_status) & HSRX_RISC_PAUSED)
3188c2ecf20Sopenharmony_ci		set_bit(RISC_PAUSE_CMPL, &ha->fw_dump_cap_flags);
3198c2ecf20Sopenharmony_ci}
3208c2ecf20Sopenharmony_ci
3218c2ecf20Sopenharmony_ciint
3228c2ecf20Sopenharmony_ciqla24xx_soft_reset(struct qla_hw_data *ha)
3238c2ecf20Sopenharmony_ci{
3248c2ecf20Sopenharmony_ci	int rval = QLA_SUCCESS;
3258c2ecf20Sopenharmony_ci	uint32_t cnt;
3268c2ecf20Sopenharmony_ci	uint16_t wd;
3278c2ecf20Sopenharmony_ci	struct device_reg_24xx __iomem *reg = &ha->iobase->isp24;
3288c2ecf20Sopenharmony_ci
3298c2ecf20Sopenharmony_ci	/*
3308c2ecf20Sopenharmony_ci	 * Reset RISC. The delay is dependent on system architecture.
3318c2ecf20Sopenharmony_ci	 * Driver can proceed with the reset sequence after waiting
3328c2ecf20Sopenharmony_ci	 * for a timeout period.
3338c2ecf20Sopenharmony_ci	 */
3348c2ecf20Sopenharmony_ci	wrt_reg_dword(&reg->ctrl_status, CSRX_DMA_SHUTDOWN|MWB_4096_BYTES);
3358c2ecf20Sopenharmony_ci	for (cnt = 0; cnt < 30000; cnt++) {
3368c2ecf20Sopenharmony_ci		if ((rd_reg_dword(&reg->ctrl_status) & CSRX_DMA_ACTIVE) == 0)
3378c2ecf20Sopenharmony_ci			break;
3388c2ecf20Sopenharmony_ci
3398c2ecf20Sopenharmony_ci		udelay(10);
3408c2ecf20Sopenharmony_ci	}
3418c2ecf20Sopenharmony_ci	if (!(rd_reg_dword(&reg->ctrl_status) & CSRX_DMA_ACTIVE))
3428c2ecf20Sopenharmony_ci		set_bit(DMA_SHUTDOWN_CMPL, &ha->fw_dump_cap_flags);
3438c2ecf20Sopenharmony_ci
3448c2ecf20Sopenharmony_ci	wrt_reg_dword(&reg->ctrl_status,
3458c2ecf20Sopenharmony_ci	    CSRX_ISP_SOFT_RESET|CSRX_DMA_SHUTDOWN|MWB_4096_BYTES);
3468c2ecf20Sopenharmony_ci	pci_read_config_word(ha->pdev, PCI_COMMAND, &wd);
3478c2ecf20Sopenharmony_ci
3488c2ecf20Sopenharmony_ci	udelay(100);
3498c2ecf20Sopenharmony_ci
3508c2ecf20Sopenharmony_ci	/* Wait for soft-reset to complete. */
3518c2ecf20Sopenharmony_ci	for (cnt = 0; cnt < 30000; cnt++) {
3528c2ecf20Sopenharmony_ci		if ((rd_reg_dword(&reg->ctrl_status) &
3538c2ecf20Sopenharmony_ci		    CSRX_ISP_SOFT_RESET) == 0)
3548c2ecf20Sopenharmony_ci			break;
3558c2ecf20Sopenharmony_ci
3568c2ecf20Sopenharmony_ci		udelay(10);
3578c2ecf20Sopenharmony_ci	}
3588c2ecf20Sopenharmony_ci	if (!(rd_reg_dword(&reg->ctrl_status) & CSRX_ISP_SOFT_RESET))
3598c2ecf20Sopenharmony_ci		set_bit(ISP_RESET_CMPL, &ha->fw_dump_cap_flags);
3608c2ecf20Sopenharmony_ci
3618c2ecf20Sopenharmony_ci	wrt_reg_dword(&reg->hccr, HCCRX_CLR_RISC_RESET);
3628c2ecf20Sopenharmony_ci	rd_reg_dword(&reg->hccr);             /* PCI Posting. */
3638c2ecf20Sopenharmony_ci
3648c2ecf20Sopenharmony_ci	for (cnt = 10000; rd_reg_word(&reg->mailbox0) != 0 &&
3658c2ecf20Sopenharmony_ci	    rval == QLA_SUCCESS; cnt--) {
3668c2ecf20Sopenharmony_ci		if (cnt)
3678c2ecf20Sopenharmony_ci			udelay(10);
3688c2ecf20Sopenharmony_ci		else
3698c2ecf20Sopenharmony_ci			rval = QLA_FUNCTION_TIMEOUT;
3708c2ecf20Sopenharmony_ci	}
3718c2ecf20Sopenharmony_ci	if (rval == QLA_SUCCESS)
3728c2ecf20Sopenharmony_ci		set_bit(RISC_RDY_AFT_RESET, &ha->fw_dump_cap_flags);
3738c2ecf20Sopenharmony_ci
3748c2ecf20Sopenharmony_ci	return rval;
3758c2ecf20Sopenharmony_ci}
3768c2ecf20Sopenharmony_ci
3778c2ecf20Sopenharmony_cistatic int
3788c2ecf20Sopenharmony_ciqla2xxx_dump_ram(struct qla_hw_data *ha, uint32_t addr, __be16 *ram,
3798c2ecf20Sopenharmony_ci    uint32_t ram_words, void **nxt)
3808c2ecf20Sopenharmony_ci{
3818c2ecf20Sopenharmony_ci	int rval;
3828c2ecf20Sopenharmony_ci	uint32_t cnt, stat, timer, words, idx;
3838c2ecf20Sopenharmony_ci	uint16_t mb0;
3848c2ecf20Sopenharmony_ci	struct device_reg_2xxx __iomem *reg = &ha->iobase->isp;
3858c2ecf20Sopenharmony_ci	dma_addr_t dump_dma = ha->gid_list_dma;
3868c2ecf20Sopenharmony_ci	__le16 *dump = (__force __le16 *)ha->gid_list;
3878c2ecf20Sopenharmony_ci
3888c2ecf20Sopenharmony_ci	rval = QLA_SUCCESS;
3898c2ecf20Sopenharmony_ci	mb0 = 0;
3908c2ecf20Sopenharmony_ci
3918c2ecf20Sopenharmony_ci	WRT_MAILBOX_REG(ha, reg, 0, MBC_DUMP_RISC_RAM_EXTENDED);
3928c2ecf20Sopenharmony_ci	clear_bit(MBX_INTERRUPT, &ha->mbx_cmd_flags);
3938c2ecf20Sopenharmony_ci
3948c2ecf20Sopenharmony_ci	words = qla2x00_gid_list_size(ha) / 2;
3958c2ecf20Sopenharmony_ci	for (cnt = 0; cnt < ram_words && rval == QLA_SUCCESS;
3968c2ecf20Sopenharmony_ci	    cnt += words, addr += words) {
3978c2ecf20Sopenharmony_ci		if (cnt + words > ram_words)
3988c2ecf20Sopenharmony_ci			words = ram_words - cnt;
3998c2ecf20Sopenharmony_ci
4008c2ecf20Sopenharmony_ci		WRT_MAILBOX_REG(ha, reg, 1, LSW(addr));
4018c2ecf20Sopenharmony_ci		WRT_MAILBOX_REG(ha, reg, 8, MSW(addr));
4028c2ecf20Sopenharmony_ci
4038c2ecf20Sopenharmony_ci		WRT_MAILBOX_REG(ha, reg, 2, MSW(dump_dma));
4048c2ecf20Sopenharmony_ci		WRT_MAILBOX_REG(ha, reg, 3, LSW(dump_dma));
4058c2ecf20Sopenharmony_ci		WRT_MAILBOX_REG(ha, reg, 6, MSW(MSD(dump_dma)));
4068c2ecf20Sopenharmony_ci		WRT_MAILBOX_REG(ha, reg, 7, LSW(MSD(dump_dma)));
4078c2ecf20Sopenharmony_ci
4088c2ecf20Sopenharmony_ci		WRT_MAILBOX_REG(ha, reg, 4, words);
4098c2ecf20Sopenharmony_ci		wrt_reg_word(&reg->hccr, HCCR_SET_HOST_INT);
4108c2ecf20Sopenharmony_ci
4118c2ecf20Sopenharmony_ci		for (timer = 6000000; timer; timer--) {
4128c2ecf20Sopenharmony_ci			/* Check for pending interrupts. */
4138c2ecf20Sopenharmony_ci			stat = rd_reg_dword(&reg->u.isp2300.host_status);
4148c2ecf20Sopenharmony_ci			if (stat & HSR_RISC_INT) {
4158c2ecf20Sopenharmony_ci				stat &= 0xff;
4168c2ecf20Sopenharmony_ci
4178c2ecf20Sopenharmony_ci				if (stat == 0x1 || stat == 0x2) {
4188c2ecf20Sopenharmony_ci					set_bit(MBX_INTERRUPT,
4198c2ecf20Sopenharmony_ci					    &ha->mbx_cmd_flags);
4208c2ecf20Sopenharmony_ci
4218c2ecf20Sopenharmony_ci					mb0 = RD_MAILBOX_REG(ha, reg, 0);
4228c2ecf20Sopenharmony_ci
4238c2ecf20Sopenharmony_ci					/* Release mailbox registers. */
4248c2ecf20Sopenharmony_ci					wrt_reg_word(&reg->semaphore, 0);
4258c2ecf20Sopenharmony_ci					wrt_reg_word(&reg->hccr,
4268c2ecf20Sopenharmony_ci					    HCCR_CLR_RISC_INT);
4278c2ecf20Sopenharmony_ci					rd_reg_word(&reg->hccr);
4288c2ecf20Sopenharmony_ci					break;
4298c2ecf20Sopenharmony_ci				} else if (stat == 0x10 || stat == 0x11) {
4308c2ecf20Sopenharmony_ci					set_bit(MBX_INTERRUPT,
4318c2ecf20Sopenharmony_ci					    &ha->mbx_cmd_flags);
4328c2ecf20Sopenharmony_ci
4338c2ecf20Sopenharmony_ci					mb0 = RD_MAILBOX_REG(ha, reg, 0);
4348c2ecf20Sopenharmony_ci
4358c2ecf20Sopenharmony_ci					wrt_reg_word(&reg->hccr,
4368c2ecf20Sopenharmony_ci					    HCCR_CLR_RISC_INT);
4378c2ecf20Sopenharmony_ci					rd_reg_word(&reg->hccr);
4388c2ecf20Sopenharmony_ci					break;
4398c2ecf20Sopenharmony_ci				}
4408c2ecf20Sopenharmony_ci
4418c2ecf20Sopenharmony_ci				/* clear this intr; it wasn't a mailbox intr */
4428c2ecf20Sopenharmony_ci				wrt_reg_word(&reg->hccr, HCCR_CLR_RISC_INT);
4438c2ecf20Sopenharmony_ci				rd_reg_word(&reg->hccr);
4448c2ecf20Sopenharmony_ci			}
4458c2ecf20Sopenharmony_ci			udelay(5);
4468c2ecf20Sopenharmony_ci		}
4478c2ecf20Sopenharmony_ci
4488c2ecf20Sopenharmony_ci		if (test_and_clear_bit(MBX_INTERRUPT, &ha->mbx_cmd_flags)) {
4498c2ecf20Sopenharmony_ci			rval = mb0 & MBS_MASK;
4508c2ecf20Sopenharmony_ci			for (idx = 0; idx < words; idx++)
4518c2ecf20Sopenharmony_ci				ram[cnt + idx] =
4528c2ecf20Sopenharmony_ci					cpu_to_be16(le16_to_cpu(dump[idx]));
4538c2ecf20Sopenharmony_ci		} else {
4548c2ecf20Sopenharmony_ci			rval = QLA_FUNCTION_FAILED;
4558c2ecf20Sopenharmony_ci		}
4568c2ecf20Sopenharmony_ci	}
4578c2ecf20Sopenharmony_ci
4588c2ecf20Sopenharmony_ci	*nxt = rval == QLA_SUCCESS ? &ram[cnt] : NULL;
4598c2ecf20Sopenharmony_ci	return rval;
4608c2ecf20Sopenharmony_ci}
4618c2ecf20Sopenharmony_ci
4628c2ecf20Sopenharmony_cistatic inline void
4638c2ecf20Sopenharmony_ciqla2xxx_read_window(struct device_reg_2xxx __iomem *reg, uint32_t count,
4648c2ecf20Sopenharmony_ci		    __be16 *buf)
4658c2ecf20Sopenharmony_ci{
4668c2ecf20Sopenharmony_ci	__le16 __iomem *dmp_reg = &reg->u.isp2300.fb_cmd;
4678c2ecf20Sopenharmony_ci
4688c2ecf20Sopenharmony_ci	for ( ; count--; dmp_reg++)
4698c2ecf20Sopenharmony_ci		*buf++ = htons(rd_reg_word(dmp_reg));
4708c2ecf20Sopenharmony_ci}
4718c2ecf20Sopenharmony_ci
4728c2ecf20Sopenharmony_cistatic inline void *
4738c2ecf20Sopenharmony_ciqla24xx_copy_eft(struct qla_hw_data *ha, void *ptr)
4748c2ecf20Sopenharmony_ci{
4758c2ecf20Sopenharmony_ci	if (!ha->eft)
4768c2ecf20Sopenharmony_ci		return ptr;
4778c2ecf20Sopenharmony_ci
4788c2ecf20Sopenharmony_ci	memcpy(ptr, ha->eft, ntohl(ha->fw_dump->eft_size));
4798c2ecf20Sopenharmony_ci	return ptr + ntohl(ha->fw_dump->eft_size);
4808c2ecf20Sopenharmony_ci}
4818c2ecf20Sopenharmony_ci
4828c2ecf20Sopenharmony_cistatic inline void *
4838c2ecf20Sopenharmony_ciqla25xx_copy_fce(struct qla_hw_data *ha, void *ptr, __be32 **last_chain)
4848c2ecf20Sopenharmony_ci{
4858c2ecf20Sopenharmony_ci	uint32_t cnt;
4868c2ecf20Sopenharmony_ci	__be32 *iter_reg;
4878c2ecf20Sopenharmony_ci	struct qla2xxx_fce_chain *fcec = ptr;
4888c2ecf20Sopenharmony_ci
4898c2ecf20Sopenharmony_ci	if (!ha->fce)
4908c2ecf20Sopenharmony_ci		return ptr;
4918c2ecf20Sopenharmony_ci
4928c2ecf20Sopenharmony_ci	*last_chain = &fcec->type;
4938c2ecf20Sopenharmony_ci	fcec->type = htonl(DUMP_CHAIN_FCE);
4948c2ecf20Sopenharmony_ci	fcec->chain_size = htonl(sizeof(struct qla2xxx_fce_chain) +
4958c2ecf20Sopenharmony_ci	    fce_calc_size(ha->fce_bufs));
4968c2ecf20Sopenharmony_ci	fcec->size = htonl(fce_calc_size(ha->fce_bufs));
4978c2ecf20Sopenharmony_ci	fcec->addr_l = htonl(LSD(ha->fce_dma));
4988c2ecf20Sopenharmony_ci	fcec->addr_h = htonl(MSD(ha->fce_dma));
4998c2ecf20Sopenharmony_ci
5008c2ecf20Sopenharmony_ci	iter_reg = fcec->eregs;
5018c2ecf20Sopenharmony_ci	for (cnt = 0; cnt < 8; cnt++)
5028c2ecf20Sopenharmony_ci		*iter_reg++ = htonl(ha->fce_mb[cnt]);
5038c2ecf20Sopenharmony_ci
5048c2ecf20Sopenharmony_ci	memcpy(iter_reg, ha->fce, ntohl(fcec->size));
5058c2ecf20Sopenharmony_ci
5068c2ecf20Sopenharmony_ci	return (char *)iter_reg + ntohl(fcec->size);
5078c2ecf20Sopenharmony_ci}
5088c2ecf20Sopenharmony_ci
5098c2ecf20Sopenharmony_cistatic inline void *
5108c2ecf20Sopenharmony_ciqla25xx_copy_exlogin(struct qla_hw_data *ha, void *ptr, __be32 **last_chain)
5118c2ecf20Sopenharmony_ci{
5128c2ecf20Sopenharmony_ci	struct qla2xxx_offld_chain *c = ptr;
5138c2ecf20Sopenharmony_ci
5148c2ecf20Sopenharmony_ci	if (!ha->exlogin_buf)
5158c2ecf20Sopenharmony_ci		return ptr;
5168c2ecf20Sopenharmony_ci
5178c2ecf20Sopenharmony_ci	*last_chain = &c->type;
5188c2ecf20Sopenharmony_ci
5198c2ecf20Sopenharmony_ci	c->type = cpu_to_be32(DUMP_CHAIN_EXLOGIN);
5208c2ecf20Sopenharmony_ci	c->chain_size = cpu_to_be32(sizeof(struct qla2xxx_offld_chain) +
5218c2ecf20Sopenharmony_ci	    ha->exlogin_size);
5228c2ecf20Sopenharmony_ci	c->size = cpu_to_be32(ha->exlogin_size);
5238c2ecf20Sopenharmony_ci	c->addr = cpu_to_be64(ha->exlogin_buf_dma);
5248c2ecf20Sopenharmony_ci
5258c2ecf20Sopenharmony_ci	ptr += sizeof(struct qla2xxx_offld_chain);
5268c2ecf20Sopenharmony_ci	memcpy(ptr, ha->exlogin_buf, ha->exlogin_size);
5278c2ecf20Sopenharmony_ci
5288c2ecf20Sopenharmony_ci	return (char *)ptr + be32_to_cpu(c->size);
5298c2ecf20Sopenharmony_ci}
5308c2ecf20Sopenharmony_ci
5318c2ecf20Sopenharmony_cistatic inline void *
5328c2ecf20Sopenharmony_ciqla81xx_copy_exchoffld(struct qla_hw_data *ha, void *ptr, __be32 **last_chain)
5338c2ecf20Sopenharmony_ci{
5348c2ecf20Sopenharmony_ci	struct qla2xxx_offld_chain *c = ptr;
5358c2ecf20Sopenharmony_ci
5368c2ecf20Sopenharmony_ci	if (!ha->exchoffld_buf)
5378c2ecf20Sopenharmony_ci		return ptr;
5388c2ecf20Sopenharmony_ci
5398c2ecf20Sopenharmony_ci	*last_chain = &c->type;
5408c2ecf20Sopenharmony_ci
5418c2ecf20Sopenharmony_ci	c->type = cpu_to_be32(DUMP_CHAIN_EXCHG);
5428c2ecf20Sopenharmony_ci	c->chain_size = cpu_to_be32(sizeof(struct qla2xxx_offld_chain) +
5438c2ecf20Sopenharmony_ci	    ha->exchoffld_size);
5448c2ecf20Sopenharmony_ci	c->size = cpu_to_be32(ha->exchoffld_size);
5458c2ecf20Sopenharmony_ci	c->addr = cpu_to_be64(ha->exchoffld_buf_dma);
5468c2ecf20Sopenharmony_ci
5478c2ecf20Sopenharmony_ci	ptr += sizeof(struct qla2xxx_offld_chain);
5488c2ecf20Sopenharmony_ci	memcpy(ptr, ha->exchoffld_buf, ha->exchoffld_size);
5498c2ecf20Sopenharmony_ci
5508c2ecf20Sopenharmony_ci	return (char *)ptr + be32_to_cpu(c->size);
5518c2ecf20Sopenharmony_ci}
5528c2ecf20Sopenharmony_ci
5538c2ecf20Sopenharmony_cistatic inline void *
5548c2ecf20Sopenharmony_ciqla2xxx_copy_atioqueues(struct qla_hw_data *ha, void *ptr,
5558c2ecf20Sopenharmony_ci			__be32 **last_chain)
5568c2ecf20Sopenharmony_ci{
5578c2ecf20Sopenharmony_ci	struct qla2xxx_mqueue_chain *q;
5588c2ecf20Sopenharmony_ci	struct qla2xxx_mqueue_header *qh;
5598c2ecf20Sopenharmony_ci	uint32_t num_queues;
5608c2ecf20Sopenharmony_ci	int que;
5618c2ecf20Sopenharmony_ci	struct {
5628c2ecf20Sopenharmony_ci		int length;
5638c2ecf20Sopenharmony_ci		void *ring;
5648c2ecf20Sopenharmony_ci	} aq, *aqp;
5658c2ecf20Sopenharmony_ci
5668c2ecf20Sopenharmony_ci	if (!ha->tgt.atio_ring)
5678c2ecf20Sopenharmony_ci		return ptr;
5688c2ecf20Sopenharmony_ci
5698c2ecf20Sopenharmony_ci	num_queues = 1;
5708c2ecf20Sopenharmony_ci	aqp = &aq;
5718c2ecf20Sopenharmony_ci	aqp->length = ha->tgt.atio_q_length;
5728c2ecf20Sopenharmony_ci	aqp->ring = ha->tgt.atio_ring;
5738c2ecf20Sopenharmony_ci
5748c2ecf20Sopenharmony_ci	for (que = 0; que < num_queues; que++) {
5758c2ecf20Sopenharmony_ci		/* aqp = ha->atio_q_map[que]; */
5768c2ecf20Sopenharmony_ci		q = ptr;
5778c2ecf20Sopenharmony_ci		*last_chain = &q->type;
5788c2ecf20Sopenharmony_ci		q->type = htonl(DUMP_CHAIN_QUEUE);
5798c2ecf20Sopenharmony_ci		q->chain_size = htonl(
5808c2ecf20Sopenharmony_ci		    sizeof(struct qla2xxx_mqueue_chain) +
5818c2ecf20Sopenharmony_ci		    sizeof(struct qla2xxx_mqueue_header) +
5828c2ecf20Sopenharmony_ci		    (aqp->length * sizeof(request_t)));
5838c2ecf20Sopenharmony_ci		ptr += sizeof(struct qla2xxx_mqueue_chain);
5848c2ecf20Sopenharmony_ci
5858c2ecf20Sopenharmony_ci		/* Add header. */
5868c2ecf20Sopenharmony_ci		qh = ptr;
5878c2ecf20Sopenharmony_ci		qh->queue = htonl(TYPE_ATIO_QUEUE);
5888c2ecf20Sopenharmony_ci		qh->number = htonl(que);
5898c2ecf20Sopenharmony_ci		qh->size = htonl(aqp->length * sizeof(request_t));
5908c2ecf20Sopenharmony_ci		ptr += sizeof(struct qla2xxx_mqueue_header);
5918c2ecf20Sopenharmony_ci
5928c2ecf20Sopenharmony_ci		/* Add data. */
5938c2ecf20Sopenharmony_ci		memcpy(ptr, aqp->ring, aqp->length * sizeof(request_t));
5948c2ecf20Sopenharmony_ci
5958c2ecf20Sopenharmony_ci		ptr += aqp->length * sizeof(request_t);
5968c2ecf20Sopenharmony_ci	}
5978c2ecf20Sopenharmony_ci
5988c2ecf20Sopenharmony_ci	return ptr;
5998c2ecf20Sopenharmony_ci}
6008c2ecf20Sopenharmony_ci
6018c2ecf20Sopenharmony_cistatic inline void *
6028c2ecf20Sopenharmony_ciqla25xx_copy_mqueues(struct qla_hw_data *ha, void *ptr, __be32 **last_chain)
6038c2ecf20Sopenharmony_ci{
6048c2ecf20Sopenharmony_ci	struct qla2xxx_mqueue_chain *q;
6058c2ecf20Sopenharmony_ci	struct qla2xxx_mqueue_header *qh;
6068c2ecf20Sopenharmony_ci	struct req_que *req;
6078c2ecf20Sopenharmony_ci	struct rsp_que *rsp;
6088c2ecf20Sopenharmony_ci	int que;
6098c2ecf20Sopenharmony_ci
6108c2ecf20Sopenharmony_ci	if (!ha->mqenable)
6118c2ecf20Sopenharmony_ci		return ptr;
6128c2ecf20Sopenharmony_ci
6138c2ecf20Sopenharmony_ci	/* Request queues */
6148c2ecf20Sopenharmony_ci	for (que = 1; que < ha->max_req_queues; que++) {
6158c2ecf20Sopenharmony_ci		req = ha->req_q_map[que];
6168c2ecf20Sopenharmony_ci		if (!req)
6178c2ecf20Sopenharmony_ci			break;
6188c2ecf20Sopenharmony_ci
6198c2ecf20Sopenharmony_ci		/* Add chain. */
6208c2ecf20Sopenharmony_ci		q = ptr;
6218c2ecf20Sopenharmony_ci		*last_chain = &q->type;
6228c2ecf20Sopenharmony_ci		q->type = htonl(DUMP_CHAIN_QUEUE);
6238c2ecf20Sopenharmony_ci		q->chain_size = htonl(
6248c2ecf20Sopenharmony_ci		    sizeof(struct qla2xxx_mqueue_chain) +
6258c2ecf20Sopenharmony_ci		    sizeof(struct qla2xxx_mqueue_header) +
6268c2ecf20Sopenharmony_ci		    (req->length * sizeof(request_t)));
6278c2ecf20Sopenharmony_ci		ptr += sizeof(struct qla2xxx_mqueue_chain);
6288c2ecf20Sopenharmony_ci
6298c2ecf20Sopenharmony_ci		/* Add header. */
6308c2ecf20Sopenharmony_ci		qh = ptr;
6318c2ecf20Sopenharmony_ci		qh->queue = htonl(TYPE_REQUEST_QUEUE);
6328c2ecf20Sopenharmony_ci		qh->number = htonl(que);
6338c2ecf20Sopenharmony_ci		qh->size = htonl(req->length * sizeof(request_t));
6348c2ecf20Sopenharmony_ci		ptr += sizeof(struct qla2xxx_mqueue_header);
6358c2ecf20Sopenharmony_ci
6368c2ecf20Sopenharmony_ci		/* Add data. */
6378c2ecf20Sopenharmony_ci		memcpy(ptr, req->ring, req->length * sizeof(request_t));
6388c2ecf20Sopenharmony_ci		ptr += req->length * sizeof(request_t);
6398c2ecf20Sopenharmony_ci	}
6408c2ecf20Sopenharmony_ci
6418c2ecf20Sopenharmony_ci	/* Response queues */
6428c2ecf20Sopenharmony_ci	for (que = 1; que < ha->max_rsp_queues; que++) {
6438c2ecf20Sopenharmony_ci		rsp = ha->rsp_q_map[que];
6448c2ecf20Sopenharmony_ci		if (!rsp)
6458c2ecf20Sopenharmony_ci			break;
6468c2ecf20Sopenharmony_ci
6478c2ecf20Sopenharmony_ci		/* Add chain. */
6488c2ecf20Sopenharmony_ci		q = ptr;
6498c2ecf20Sopenharmony_ci		*last_chain = &q->type;
6508c2ecf20Sopenharmony_ci		q->type = htonl(DUMP_CHAIN_QUEUE);
6518c2ecf20Sopenharmony_ci		q->chain_size = htonl(
6528c2ecf20Sopenharmony_ci		    sizeof(struct qla2xxx_mqueue_chain) +
6538c2ecf20Sopenharmony_ci		    sizeof(struct qla2xxx_mqueue_header) +
6548c2ecf20Sopenharmony_ci		    (rsp->length * sizeof(response_t)));
6558c2ecf20Sopenharmony_ci		ptr += sizeof(struct qla2xxx_mqueue_chain);
6568c2ecf20Sopenharmony_ci
6578c2ecf20Sopenharmony_ci		/* Add header. */
6588c2ecf20Sopenharmony_ci		qh = ptr;
6598c2ecf20Sopenharmony_ci		qh->queue = htonl(TYPE_RESPONSE_QUEUE);
6608c2ecf20Sopenharmony_ci		qh->number = htonl(que);
6618c2ecf20Sopenharmony_ci		qh->size = htonl(rsp->length * sizeof(response_t));
6628c2ecf20Sopenharmony_ci		ptr += sizeof(struct qla2xxx_mqueue_header);
6638c2ecf20Sopenharmony_ci
6648c2ecf20Sopenharmony_ci		/* Add data. */
6658c2ecf20Sopenharmony_ci		memcpy(ptr, rsp->ring, rsp->length * sizeof(response_t));
6668c2ecf20Sopenharmony_ci		ptr += rsp->length * sizeof(response_t);
6678c2ecf20Sopenharmony_ci	}
6688c2ecf20Sopenharmony_ci
6698c2ecf20Sopenharmony_ci	return ptr;
6708c2ecf20Sopenharmony_ci}
6718c2ecf20Sopenharmony_ci
6728c2ecf20Sopenharmony_cistatic inline void *
6738c2ecf20Sopenharmony_ciqla25xx_copy_mq(struct qla_hw_data *ha, void *ptr, __be32 **last_chain)
6748c2ecf20Sopenharmony_ci{
6758c2ecf20Sopenharmony_ci	uint32_t cnt, que_idx;
6768c2ecf20Sopenharmony_ci	uint8_t que_cnt;
6778c2ecf20Sopenharmony_ci	struct qla2xxx_mq_chain *mq = ptr;
6788c2ecf20Sopenharmony_ci	device_reg_t *reg;
6798c2ecf20Sopenharmony_ci
6808c2ecf20Sopenharmony_ci	if (!ha->mqenable || IS_QLA83XX(ha) || IS_QLA27XX(ha) ||
6818c2ecf20Sopenharmony_ci	    IS_QLA28XX(ha))
6828c2ecf20Sopenharmony_ci		return ptr;
6838c2ecf20Sopenharmony_ci
6848c2ecf20Sopenharmony_ci	mq = ptr;
6858c2ecf20Sopenharmony_ci	*last_chain = &mq->type;
6868c2ecf20Sopenharmony_ci	mq->type = htonl(DUMP_CHAIN_MQ);
6878c2ecf20Sopenharmony_ci	mq->chain_size = htonl(sizeof(struct qla2xxx_mq_chain));
6888c2ecf20Sopenharmony_ci
6898c2ecf20Sopenharmony_ci	que_cnt = ha->max_req_queues > ha->max_rsp_queues ?
6908c2ecf20Sopenharmony_ci		ha->max_req_queues : ha->max_rsp_queues;
6918c2ecf20Sopenharmony_ci	mq->count = htonl(que_cnt);
6928c2ecf20Sopenharmony_ci	for (cnt = 0; cnt < que_cnt; cnt++) {
6938c2ecf20Sopenharmony_ci		reg = ISP_QUE_REG(ha, cnt);
6948c2ecf20Sopenharmony_ci		que_idx = cnt * 4;
6958c2ecf20Sopenharmony_ci		mq->qregs[que_idx] =
6968c2ecf20Sopenharmony_ci		    htonl(rd_reg_dword(&reg->isp25mq.req_q_in));
6978c2ecf20Sopenharmony_ci		mq->qregs[que_idx+1] =
6988c2ecf20Sopenharmony_ci		    htonl(rd_reg_dword(&reg->isp25mq.req_q_out));
6998c2ecf20Sopenharmony_ci		mq->qregs[que_idx+2] =
7008c2ecf20Sopenharmony_ci		    htonl(rd_reg_dword(&reg->isp25mq.rsp_q_in));
7018c2ecf20Sopenharmony_ci		mq->qregs[que_idx+3] =
7028c2ecf20Sopenharmony_ci		    htonl(rd_reg_dword(&reg->isp25mq.rsp_q_out));
7038c2ecf20Sopenharmony_ci	}
7048c2ecf20Sopenharmony_ci
7058c2ecf20Sopenharmony_ci	return ptr + sizeof(struct qla2xxx_mq_chain);
7068c2ecf20Sopenharmony_ci}
7078c2ecf20Sopenharmony_ci
7088c2ecf20Sopenharmony_civoid
7098c2ecf20Sopenharmony_ciqla2xxx_dump_post_process(scsi_qla_host_t *vha, int rval)
7108c2ecf20Sopenharmony_ci{
7118c2ecf20Sopenharmony_ci	struct qla_hw_data *ha = vha->hw;
7128c2ecf20Sopenharmony_ci
7138c2ecf20Sopenharmony_ci	if (rval != QLA_SUCCESS) {
7148c2ecf20Sopenharmony_ci		ql_log(ql_log_warn, vha, 0xd000,
7158c2ecf20Sopenharmony_ci		    "Failed to dump firmware (%x), dump status flags (0x%lx).\n",
7168c2ecf20Sopenharmony_ci		    rval, ha->fw_dump_cap_flags);
7178c2ecf20Sopenharmony_ci		ha->fw_dumped = false;
7188c2ecf20Sopenharmony_ci	} else {
7198c2ecf20Sopenharmony_ci		ql_log(ql_log_info, vha, 0xd001,
7208c2ecf20Sopenharmony_ci		    "Firmware dump saved to temp buffer (%ld/%p), dump status flags (0x%lx).\n",
7218c2ecf20Sopenharmony_ci		    vha->host_no, ha->fw_dump, ha->fw_dump_cap_flags);
7228c2ecf20Sopenharmony_ci		ha->fw_dumped = true;
7238c2ecf20Sopenharmony_ci		qla2x00_post_uevent_work(vha, QLA_UEVENT_CODE_FW_DUMP);
7248c2ecf20Sopenharmony_ci	}
7258c2ecf20Sopenharmony_ci}
7268c2ecf20Sopenharmony_ci
7278c2ecf20Sopenharmony_civoid qla2xxx_dump_fw(scsi_qla_host_t *vha)
7288c2ecf20Sopenharmony_ci{
7298c2ecf20Sopenharmony_ci	unsigned long flags;
7308c2ecf20Sopenharmony_ci
7318c2ecf20Sopenharmony_ci	spin_lock_irqsave(&vha->hw->hardware_lock, flags);
7328c2ecf20Sopenharmony_ci	vha->hw->isp_ops->fw_dump(vha);
7338c2ecf20Sopenharmony_ci	spin_unlock_irqrestore(&vha->hw->hardware_lock, flags);
7348c2ecf20Sopenharmony_ci}
7358c2ecf20Sopenharmony_ci
7368c2ecf20Sopenharmony_ci/**
7378c2ecf20Sopenharmony_ci * qla2300_fw_dump() - Dumps binary data from the 2300 firmware.
7388c2ecf20Sopenharmony_ci * @vha: HA context
7398c2ecf20Sopenharmony_ci */
7408c2ecf20Sopenharmony_civoid
7418c2ecf20Sopenharmony_ciqla2300_fw_dump(scsi_qla_host_t *vha)
7428c2ecf20Sopenharmony_ci{
7438c2ecf20Sopenharmony_ci	int		rval;
7448c2ecf20Sopenharmony_ci	uint32_t	cnt;
7458c2ecf20Sopenharmony_ci	struct qla_hw_data *ha = vha->hw;
7468c2ecf20Sopenharmony_ci	struct device_reg_2xxx __iomem *reg = &ha->iobase->isp;
7478c2ecf20Sopenharmony_ci	__le16 __iomem *dmp_reg;
7488c2ecf20Sopenharmony_ci	struct qla2300_fw_dump	*fw;
7498c2ecf20Sopenharmony_ci	void		*nxt;
7508c2ecf20Sopenharmony_ci	struct scsi_qla_host *base_vha = pci_get_drvdata(ha->pdev);
7518c2ecf20Sopenharmony_ci
7528c2ecf20Sopenharmony_ci	lockdep_assert_held(&ha->hardware_lock);
7538c2ecf20Sopenharmony_ci
7548c2ecf20Sopenharmony_ci	if (!ha->fw_dump) {
7558c2ecf20Sopenharmony_ci		ql_log(ql_log_warn, vha, 0xd002,
7568c2ecf20Sopenharmony_ci		    "No buffer available for dump.\n");
7578c2ecf20Sopenharmony_ci		return;
7588c2ecf20Sopenharmony_ci	}
7598c2ecf20Sopenharmony_ci
7608c2ecf20Sopenharmony_ci	if (ha->fw_dumped) {
7618c2ecf20Sopenharmony_ci		ql_log(ql_log_warn, vha, 0xd003,
7628c2ecf20Sopenharmony_ci		    "Firmware has been previously dumped (%p) "
7638c2ecf20Sopenharmony_ci		    "-- ignoring request.\n",
7648c2ecf20Sopenharmony_ci		    ha->fw_dump);
7658c2ecf20Sopenharmony_ci		return;
7668c2ecf20Sopenharmony_ci	}
7678c2ecf20Sopenharmony_ci	fw = &ha->fw_dump->isp.isp23;
7688c2ecf20Sopenharmony_ci	qla2xxx_prep_dump(ha, ha->fw_dump);
7698c2ecf20Sopenharmony_ci
7708c2ecf20Sopenharmony_ci	rval = QLA_SUCCESS;
7718c2ecf20Sopenharmony_ci	fw->hccr = htons(rd_reg_word(&reg->hccr));
7728c2ecf20Sopenharmony_ci
7738c2ecf20Sopenharmony_ci	/* Pause RISC. */
7748c2ecf20Sopenharmony_ci	wrt_reg_word(&reg->hccr, HCCR_PAUSE_RISC);
7758c2ecf20Sopenharmony_ci	if (IS_QLA2300(ha)) {
7768c2ecf20Sopenharmony_ci		for (cnt = 30000;
7778c2ecf20Sopenharmony_ci		    (rd_reg_word(&reg->hccr) & HCCR_RISC_PAUSE) == 0 &&
7788c2ecf20Sopenharmony_ci			rval == QLA_SUCCESS; cnt--) {
7798c2ecf20Sopenharmony_ci			if (cnt)
7808c2ecf20Sopenharmony_ci				udelay(100);
7818c2ecf20Sopenharmony_ci			else
7828c2ecf20Sopenharmony_ci				rval = QLA_FUNCTION_TIMEOUT;
7838c2ecf20Sopenharmony_ci		}
7848c2ecf20Sopenharmony_ci	} else {
7858c2ecf20Sopenharmony_ci		rd_reg_word(&reg->hccr);		/* PCI Posting. */
7868c2ecf20Sopenharmony_ci		udelay(10);
7878c2ecf20Sopenharmony_ci	}
7888c2ecf20Sopenharmony_ci
7898c2ecf20Sopenharmony_ci	if (rval == QLA_SUCCESS) {
7908c2ecf20Sopenharmony_ci		dmp_reg = &reg->flash_address;
7918c2ecf20Sopenharmony_ci		for (cnt = 0; cnt < ARRAY_SIZE(fw->pbiu_reg); cnt++, dmp_reg++)
7928c2ecf20Sopenharmony_ci			fw->pbiu_reg[cnt] = htons(rd_reg_word(dmp_reg));
7938c2ecf20Sopenharmony_ci
7948c2ecf20Sopenharmony_ci		dmp_reg = &reg->u.isp2300.req_q_in;
7958c2ecf20Sopenharmony_ci		for (cnt = 0; cnt < ARRAY_SIZE(fw->risc_host_reg);
7968c2ecf20Sopenharmony_ci		    cnt++, dmp_reg++)
7978c2ecf20Sopenharmony_ci			fw->risc_host_reg[cnt] = htons(rd_reg_word(dmp_reg));
7988c2ecf20Sopenharmony_ci
7998c2ecf20Sopenharmony_ci		dmp_reg = &reg->u.isp2300.mailbox0;
8008c2ecf20Sopenharmony_ci		for (cnt = 0; cnt < ARRAY_SIZE(fw->mailbox_reg);
8018c2ecf20Sopenharmony_ci		    cnt++, dmp_reg++)
8028c2ecf20Sopenharmony_ci			fw->mailbox_reg[cnt] = htons(rd_reg_word(dmp_reg));
8038c2ecf20Sopenharmony_ci
8048c2ecf20Sopenharmony_ci		wrt_reg_word(&reg->ctrl_status, 0x40);
8058c2ecf20Sopenharmony_ci		qla2xxx_read_window(reg, 32, fw->resp_dma_reg);
8068c2ecf20Sopenharmony_ci
8078c2ecf20Sopenharmony_ci		wrt_reg_word(&reg->ctrl_status, 0x50);
8088c2ecf20Sopenharmony_ci		qla2xxx_read_window(reg, 48, fw->dma_reg);
8098c2ecf20Sopenharmony_ci
8108c2ecf20Sopenharmony_ci		wrt_reg_word(&reg->ctrl_status, 0x00);
8118c2ecf20Sopenharmony_ci		dmp_reg = &reg->risc_hw;
8128c2ecf20Sopenharmony_ci		for (cnt = 0; cnt < ARRAY_SIZE(fw->risc_hdw_reg);
8138c2ecf20Sopenharmony_ci		    cnt++, dmp_reg++)
8148c2ecf20Sopenharmony_ci			fw->risc_hdw_reg[cnt] = htons(rd_reg_word(dmp_reg));
8158c2ecf20Sopenharmony_ci
8168c2ecf20Sopenharmony_ci		wrt_reg_word(&reg->pcr, 0x2000);
8178c2ecf20Sopenharmony_ci		qla2xxx_read_window(reg, 16, fw->risc_gp0_reg);
8188c2ecf20Sopenharmony_ci
8198c2ecf20Sopenharmony_ci		wrt_reg_word(&reg->pcr, 0x2200);
8208c2ecf20Sopenharmony_ci		qla2xxx_read_window(reg, 16, fw->risc_gp1_reg);
8218c2ecf20Sopenharmony_ci
8228c2ecf20Sopenharmony_ci		wrt_reg_word(&reg->pcr, 0x2400);
8238c2ecf20Sopenharmony_ci		qla2xxx_read_window(reg, 16, fw->risc_gp2_reg);
8248c2ecf20Sopenharmony_ci
8258c2ecf20Sopenharmony_ci		wrt_reg_word(&reg->pcr, 0x2600);
8268c2ecf20Sopenharmony_ci		qla2xxx_read_window(reg, 16, fw->risc_gp3_reg);
8278c2ecf20Sopenharmony_ci
8288c2ecf20Sopenharmony_ci		wrt_reg_word(&reg->pcr, 0x2800);
8298c2ecf20Sopenharmony_ci		qla2xxx_read_window(reg, 16, fw->risc_gp4_reg);
8308c2ecf20Sopenharmony_ci
8318c2ecf20Sopenharmony_ci		wrt_reg_word(&reg->pcr, 0x2A00);
8328c2ecf20Sopenharmony_ci		qla2xxx_read_window(reg, 16, fw->risc_gp5_reg);
8338c2ecf20Sopenharmony_ci
8348c2ecf20Sopenharmony_ci		wrt_reg_word(&reg->pcr, 0x2C00);
8358c2ecf20Sopenharmony_ci		qla2xxx_read_window(reg, 16, fw->risc_gp6_reg);
8368c2ecf20Sopenharmony_ci
8378c2ecf20Sopenharmony_ci		wrt_reg_word(&reg->pcr, 0x2E00);
8388c2ecf20Sopenharmony_ci		qla2xxx_read_window(reg, 16, fw->risc_gp7_reg);
8398c2ecf20Sopenharmony_ci
8408c2ecf20Sopenharmony_ci		wrt_reg_word(&reg->ctrl_status, 0x10);
8418c2ecf20Sopenharmony_ci		qla2xxx_read_window(reg, 64, fw->frame_buf_hdw_reg);
8428c2ecf20Sopenharmony_ci
8438c2ecf20Sopenharmony_ci		wrt_reg_word(&reg->ctrl_status, 0x20);
8448c2ecf20Sopenharmony_ci		qla2xxx_read_window(reg, 64, fw->fpm_b0_reg);
8458c2ecf20Sopenharmony_ci
8468c2ecf20Sopenharmony_ci		wrt_reg_word(&reg->ctrl_status, 0x30);
8478c2ecf20Sopenharmony_ci		qla2xxx_read_window(reg, 64, fw->fpm_b1_reg);
8488c2ecf20Sopenharmony_ci
8498c2ecf20Sopenharmony_ci		/* Reset RISC. */
8508c2ecf20Sopenharmony_ci		wrt_reg_word(&reg->ctrl_status, CSR_ISP_SOFT_RESET);
8518c2ecf20Sopenharmony_ci		for (cnt = 0; cnt < 30000; cnt++) {
8528c2ecf20Sopenharmony_ci			if ((rd_reg_word(&reg->ctrl_status) &
8538c2ecf20Sopenharmony_ci			    CSR_ISP_SOFT_RESET) == 0)
8548c2ecf20Sopenharmony_ci				break;
8558c2ecf20Sopenharmony_ci
8568c2ecf20Sopenharmony_ci			udelay(10);
8578c2ecf20Sopenharmony_ci		}
8588c2ecf20Sopenharmony_ci	}
8598c2ecf20Sopenharmony_ci
8608c2ecf20Sopenharmony_ci	if (!IS_QLA2300(ha)) {
8618c2ecf20Sopenharmony_ci		for (cnt = 30000; RD_MAILBOX_REG(ha, reg, 0) != 0 &&
8628c2ecf20Sopenharmony_ci		    rval == QLA_SUCCESS; cnt--) {
8638c2ecf20Sopenharmony_ci			if (cnt)
8648c2ecf20Sopenharmony_ci				udelay(100);
8658c2ecf20Sopenharmony_ci			else
8668c2ecf20Sopenharmony_ci				rval = QLA_FUNCTION_TIMEOUT;
8678c2ecf20Sopenharmony_ci		}
8688c2ecf20Sopenharmony_ci	}
8698c2ecf20Sopenharmony_ci
8708c2ecf20Sopenharmony_ci	/* Get RISC SRAM. */
8718c2ecf20Sopenharmony_ci	if (rval == QLA_SUCCESS)
8728c2ecf20Sopenharmony_ci		rval = qla2xxx_dump_ram(ha, 0x800, fw->risc_ram,
8738c2ecf20Sopenharmony_ci					ARRAY_SIZE(fw->risc_ram), &nxt);
8748c2ecf20Sopenharmony_ci
8758c2ecf20Sopenharmony_ci	/* Get stack SRAM. */
8768c2ecf20Sopenharmony_ci	if (rval == QLA_SUCCESS)
8778c2ecf20Sopenharmony_ci		rval = qla2xxx_dump_ram(ha, 0x10000, fw->stack_ram,
8788c2ecf20Sopenharmony_ci					ARRAY_SIZE(fw->stack_ram), &nxt);
8798c2ecf20Sopenharmony_ci
8808c2ecf20Sopenharmony_ci	/* Get data SRAM. */
8818c2ecf20Sopenharmony_ci	if (rval == QLA_SUCCESS)
8828c2ecf20Sopenharmony_ci		rval = qla2xxx_dump_ram(ha, 0x11000, fw->data_ram,
8838c2ecf20Sopenharmony_ci		    ha->fw_memory_size - 0x11000 + 1, &nxt);
8848c2ecf20Sopenharmony_ci
8858c2ecf20Sopenharmony_ci	if (rval == QLA_SUCCESS)
8868c2ecf20Sopenharmony_ci		qla2xxx_copy_queues(ha, nxt);
8878c2ecf20Sopenharmony_ci
8888c2ecf20Sopenharmony_ci	qla2xxx_dump_post_process(base_vha, rval);
8898c2ecf20Sopenharmony_ci}
8908c2ecf20Sopenharmony_ci
8918c2ecf20Sopenharmony_ci/**
8928c2ecf20Sopenharmony_ci * qla2100_fw_dump() - Dumps binary data from the 2100/2200 firmware.
8938c2ecf20Sopenharmony_ci * @vha: HA context
8948c2ecf20Sopenharmony_ci */
8958c2ecf20Sopenharmony_civoid
8968c2ecf20Sopenharmony_ciqla2100_fw_dump(scsi_qla_host_t *vha)
8978c2ecf20Sopenharmony_ci{
8988c2ecf20Sopenharmony_ci	int		rval;
8998c2ecf20Sopenharmony_ci	uint32_t	cnt, timer;
9008c2ecf20Sopenharmony_ci	uint16_t	risc_address = 0;
9018c2ecf20Sopenharmony_ci	uint16_t	mb0 = 0, mb2 = 0;
9028c2ecf20Sopenharmony_ci	struct qla_hw_data *ha = vha->hw;
9038c2ecf20Sopenharmony_ci	struct device_reg_2xxx __iomem *reg = &ha->iobase->isp;
9048c2ecf20Sopenharmony_ci	__le16 __iomem *dmp_reg;
9058c2ecf20Sopenharmony_ci	struct qla2100_fw_dump	*fw;
9068c2ecf20Sopenharmony_ci	struct scsi_qla_host *base_vha = pci_get_drvdata(ha->pdev);
9078c2ecf20Sopenharmony_ci
9088c2ecf20Sopenharmony_ci	lockdep_assert_held(&ha->hardware_lock);
9098c2ecf20Sopenharmony_ci
9108c2ecf20Sopenharmony_ci	if (!ha->fw_dump) {
9118c2ecf20Sopenharmony_ci		ql_log(ql_log_warn, vha, 0xd004,
9128c2ecf20Sopenharmony_ci		    "No buffer available for dump.\n");
9138c2ecf20Sopenharmony_ci		return;
9148c2ecf20Sopenharmony_ci	}
9158c2ecf20Sopenharmony_ci
9168c2ecf20Sopenharmony_ci	if (ha->fw_dumped) {
9178c2ecf20Sopenharmony_ci		ql_log(ql_log_warn, vha, 0xd005,
9188c2ecf20Sopenharmony_ci		    "Firmware has been previously dumped (%p) "
9198c2ecf20Sopenharmony_ci		    "-- ignoring request.\n",
9208c2ecf20Sopenharmony_ci		    ha->fw_dump);
9218c2ecf20Sopenharmony_ci		return;
9228c2ecf20Sopenharmony_ci	}
9238c2ecf20Sopenharmony_ci	fw = &ha->fw_dump->isp.isp21;
9248c2ecf20Sopenharmony_ci	qla2xxx_prep_dump(ha, ha->fw_dump);
9258c2ecf20Sopenharmony_ci
9268c2ecf20Sopenharmony_ci	rval = QLA_SUCCESS;
9278c2ecf20Sopenharmony_ci	fw->hccr = htons(rd_reg_word(&reg->hccr));
9288c2ecf20Sopenharmony_ci
9298c2ecf20Sopenharmony_ci	/* Pause RISC. */
9308c2ecf20Sopenharmony_ci	wrt_reg_word(&reg->hccr, HCCR_PAUSE_RISC);
9318c2ecf20Sopenharmony_ci	for (cnt = 30000; (rd_reg_word(&reg->hccr) & HCCR_RISC_PAUSE) == 0 &&
9328c2ecf20Sopenharmony_ci	    rval == QLA_SUCCESS; cnt--) {
9338c2ecf20Sopenharmony_ci		if (cnt)
9348c2ecf20Sopenharmony_ci			udelay(100);
9358c2ecf20Sopenharmony_ci		else
9368c2ecf20Sopenharmony_ci			rval = QLA_FUNCTION_TIMEOUT;
9378c2ecf20Sopenharmony_ci	}
9388c2ecf20Sopenharmony_ci	if (rval == QLA_SUCCESS) {
9398c2ecf20Sopenharmony_ci		dmp_reg = &reg->flash_address;
9408c2ecf20Sopenharmony_ci		for (cnt = 0; cnt < ARRAY_SIZE(fw->pbiu_reg); cnt++, dmp_reg++)
9418c2ecf20Sopenharmony_ci			fw->pbiu_reg[cnt] = htons(rd_reg_word(dmp_reg));
9428c2ecf20Sopenharmony_ci
9438c2ecf20Sopenharmony_ci		dmp_reg = &reg->u.isp2100.mailbox0;
9448c2ecf20Sopenharmony_ci		for (cnt = 0; cnt < ha->mbx_count; cnt++, dmp_reg++) {
9458c2ecf20Sopenharmony_ci			if (cnt == 8)
9468c2ecf20Sopenharmony_ci				dmp_reg = &reg->u_end.isp2200.mailbox8;
9478c2ecf20Sopenharmony_ci
9488c2ecf20Sopenharmony_ci			fw->mailbox_reg[cnt] = htons(rd_reg_word(dmp_reg));
9498c2ecf20Sopenharmony_ci		}
9508c2ecf20Sopenharmony_ci
9518c2ecf20Sopenharmony_ci		dmp_reg = &reg->u.isp2100.unused_2[0];
9528c2ecf20Sopenharmony_ci		for (cnt = 0; cnt < ARRAY_SIZE(fw->dma_reg); cnt++, dmp_reg++)
9538c2ecf20Sopenharmony_ci			fw->dma_reg[cnt] = htons(rd_reg_word(dmp_reg));
9548c2ecf20Sopenharmony_ci
9558c2ecf20Sopenharmony_ci		wrt_reg_word(&reg->ctrl_status, 0x00);
9568c2ecf20Sopenharmony_ci		dmp_reg = &reg->risc_hw;
9578c2ecf20Sopenharmony_ci		for (cnt = 0; cnt < ARRAY_SIZE(fw->risc_hdw_reg); cnt++, dmp_reg++)
9588c2ecf20Sopenharmony_ci			fw->risc_hdw_reg[cnt] = htons(rd_reg_word(dmp_reg));
9598c2ecf20Sopenharmony_ci
9608c2ecf20Sopenharmony_ci		wrt_reg_word(&reg->pcr, 0x2000);
9618c2ecf20Sopenharmony_ci		qla2xxx_read_window(reg, 16, fw->risc_gp0_reg);
9628c2ecf20Sopenharmony_ci
9638c2ecf20Sopenharmony_ci		wrt_reg_word(&reg->pcr, 0x2100);
9648c2ecf20Sopenharmony_ci		qla2xxx_read_window(reg, 16, fw->risc_gp1_reg);
9658c2ecf20Sopenharmony_ci
9668c2ecf20Sopenharmony_ci		wrt_reg_word(&reg->pcr, 0x2200);
9678c2ecf20Sopenharmony_ci		qla2xxx_read_window(reg, 16, fw->risc_gp2_reg);
9688c2ecf20Sopenharmony_ci
9698c2ecf20Sopenharmony_ci		wrt_reg_word(&reg->pcr, 0x2300);
9708c2ecf20Sopenharmony_ci		qla2xxx_read_window(reg, 16, fw->risc_gp3_reg);
9718c2ecf20Sopenharmony_ci
9728c2ecf20Sopenharmony_ci		wrt_reg_word(&reg->pcr, 0x2400);
9738c2ecf20Sopenharmony_ci		qla2xxx_read_window(reg, 16, fw->risc_gp4_reg);
9748c2ecf20Sopenharmony_ci
9758c2ecf20Sopenharmony_ci		wrt_reg_word(&reg->pcr, 0x2500);
9768c2ecf20Sopenharmony_ci		qla2xxx_read_window(reg, 16, fw->risc_gp5_reg);
9778c2ecf20Sopenharmony_ci
9788c2ecf20Sopenharmony_ci		wrt_reg_word(&reg->pcr, 0x2600);
9798c2ecf20Sopenharmony_ci		qla2xxx_read_window(reg, 16, fw->risc_gp6_reg);
9808c2ecf20Sopenharmony_ci
9818c2ecf20Sopenharmony_ci		wrt_reg_word(&reg->pcr, 0x2700);
9828c2ecf20Sopenharmony_ci		qla2xxx_read_window(reg, 16, fw->risc_gp7_reg);
9838c2ecf20Sopenharmony_ci
9848c2ecf20Sopenharmony_ci		wrt_reg_word(&reg->ctrl_status, 0x10);
9858c2ecf20Sopenharmony_ci		qla2xxx_read_window(reg, 16, fw->frame_buf_hdw_reg);
9868c2ecf20Sopenharmony_ci
9878c2ecf20Sopenharmony_ci		wrt_reg_word(&reg->ctrl_status, 0x20);
9888c2ecf20Sopenharmony_ci		qla2xxx_read_window(reg, 64, fw->fpm_b0_reg);
9898c2ecf20Sopenharmony_ci
9908c2ecf20Sopenharmony_ci		wrt_reg_word(&reg->ctrl_status, 0x30);
9918c2ecf20Sopenharmony_ci		qla2xxx_read_window(reg, 64, fw->fpm_b1_reg);
9928c2ecf20Sopenharmony_ci
9938c2ecf20Sopenharmony_ci		/* Reset the ISP. */
9948c2ecf20Sopenharmony_ci		wrt_reg_word(&reg->ctrl_status, CSR_ISP_SOFT_RESET);
9958c2ecf20Sopenharmony_ci	}
9968c2ecf20Sopenharmony_ci
9978c2ecf20Sopenharmony_ci	for (cnt = 30000; RD_MAILBOX_REG(ha, reg, 0) != 0 &&
9988c2ecf20Sopenharmony_ci	    rval == QLA_SUCCESS; cnt--) {
9998c2ecf20Sopenharmony_ci		if (cnt)
10008c2ecf20Sopenharmony_ci			udelay(100);
10018c2ecf20Sopenharmony_ci		else
10028c2ecf20Sopenharmony_ci			rval = QLA_FUNCTION_TIMEOUT;
10038c2ecf20Sopenharmony_ci	}
10048c2ecf20Sopenharmony_ci
10058c2ecf20Sopenharmony_ci	/* Pause RISC. */
10068c2ecf20Sopenharmony_ci	if (rval == QLA_SUCCESS && (IS_QLA2200(ha) || (IS_QLA2100(ha) &&
10078c2ecf20Sopenharmony_ci	    (rd_reg_word(&reg->mctr) & (BIT_1 | BIT_0)) != 0))) {
10088c2ecf20Sopenharmony_ci
10098c2ecf20Sopenharmony_ci		wrt_reg_word(&reg->hccr, HCCR_PAUSE_RISC);
10108c2ecf20Sopenharmony_ci		for (cnt = 30000;
10118c2ecf20Sopenharmony_ci		    (rd_reg_word(&reg->hccr) & HCCR_RISC_PAUSE) == 0 &&
10128c2ecf20Sopenharmony_ci		    rval == QLA_SUCCESS; cnt--) {
10138c2ecf20Sopenharmony_ci			if (cnt)
10148c2ecf20Sopenharmony_ci				udelay(100);
10158c2ecf20Sopenharmony_ci			else
10168c2ecf20Sopenharmony_ci				rval = QLA_FUNCTION_TIMEOUT;
10178c2ecf20Sopenharmony_ci		}
10188c2ecf20Sopenharmony_ci		if (rval == QLA_SUCCESS) {
10198c2ecf20Sopenharmony_ci			/* Set memory configuration and timing. */
10208c2ecf20Sopenharmony_ci			if (IS_QLA2100(ha))
10218c2ecf20Sopenharmony_ci				wrt_reg_word(&reg->mctr, 0xf1);
10228c2ecf20Sopenharmony_ci			else
10238c2ecf20Sopenharmony_ci				wrt_reg_word(&reg->mctr, 0xf2);
10248c2ecf20Sopenharmony_ci			rd_reg_word(&reg->mctr);	/* PCI Posting. */
10258c2ecf20Sopenharmony_ci
10268c2ecf20Sopenharmony_ci			/* Release RISC. */
10278c2ecf20Sopenharmony_ci			wrt_reg_word(&reg->hccr, HCCR_RELEASE_RISC);
10288c2ecf20Sopenharmony_ci		}
10298c2ecf20Sopenharmony_ci	}
10308c2ecf20Sopenharmony_ci
10318c2ecf20Sopenharmony_ci	if (rval == QLA_SUCCESS) {
10328c2ecf20Sopenharmony_ci		/* Get RISC SRAM. */
10338c2ecf20Sopenharmony_ci		risc_address = 0x1000;
10348c2ecf20Sopenharmony_ci 		WRT_MAILBOX_REG(ha, reg, 0, MBC_READ_RAM_WORD);
10358c2ecf20Sopenharmony_ci		clear_bit(MBX_INTERRUPT, &ha->mbx_cmd_flags);
10368c2ecf20Sopenharmony_ci	}
10378c2ecf20Sopenharmony_ci	for (cnt = 0; cnt < ARRAY_SIZE(fw->risc_ram) && rval == QLA_SUCCESS;
10388c2ecf20Sopenharmony_ci	    cnt++, risc_address++) {
10398c2ecf20Sopenharmony_ci 		WRT_MAILBOX_REG(ha, reg, 1, risc_address);
10408c2ecf20Sopenharmony_ci		wrt_reg_word(&reg->hccr, HCCR_SET_HOST_INT);
10418c2ecf20Sopenharmony_ci
10428c2ecf20Sopenharmony_ci		for (timer = 6000000; timer != 0; timer--) {
10438c2ecf20Sopenharmony_ci			/* Check for pending interrupts. */
10448c2ecf20Sopenharmony_ci			if (rd_reg_word(&reg->istatus) & ISR_RISC_INT) {
10458c2ecf20Sopenharmony_ci				if (rd_reg_word(&reg->semaphore) & BIT_0) {
10468c2ecf20Sopenharmony_ci					set_bit(MBX_INTERRUPT,
10478c2ecf20Sopenharmony_ci					    &ha->mbx_cmd_flags);
10488c2ecf20Sopenharmony_ci
10498c2ecf20Sopenharmony_ci					mb0 = RD_MAILBOX_REG(ha, reg, 0);
10508c2ecf20Sopenharmony_ci					mb2 = RD_MAILBOX_REG(ha, reg, 2);
10518c2ecf20Sopenharmony_ci
10528c2ecf20Sopenharmony_ci					wrt_reg_word(&reg->semaphore, 0);
10538c2ecf20Sopenharmony_ci					wrt_reg_word(&reg->hccr,
10548c2ecf20Sopenharmony_ci					    HCCR_CLR_RISC_INT);
10558c2ecf20Sopenharmony_ci					rd_reg_word(&reg->hccr);
10568c2ecf20Sopenharmony_ci					break;
10578c2ecf20Sopenharmony_ci				}
10588c2ecf20Sopenharmony_ci				wrt_reg_word(&reg->hccr, HCCR_CLR_RISC_INT);
10598c2ecf20Sopenharmony_ci				rd_reg_word(&reg->hccr);
10608c2ecf20Sopenharmony_ci			}
10618c2ecf20Sopenharmony_ci			udelay(5);
10628c2ecf20Sopenharmony_ci		}
10638c2ecf20Sopenharmony_ci
10648c2ecf20Sopenharmony_ci		if (test_and_clear_bit(MBX_INTERRUPT, &ha->mbx_cmd_flags)) {
10658c2ecf20Sopenharmony_ci			rval = mb0 & MBS_MASK;
10668c2ecf20Sopenharmony_ci			fw->risc_ram[cnt] = htons(mb2);
10678c2ecf20Sopenharmony_ci		} else {
10688c2ecf20Sopenharmony_ci			rval = QLA_FUNCTION_FAILED;
10698c2ecf20Sopenharmony_ci		}
10708c2ecf20Sopenharmony_ci	}
10718c2ecf20Sopenharmony_ci
10728c2ecf20Sopenharmony_ci	if (rval == QLA_SUCCESS)
10738c2ecf20Sopenharmony_ci		qla2xxx_copy_queues(ha, &fw->queue_dump[0]);
10748c2ecf20Sopenharmony_ci
10758c2ecf20Sopenharmony_ci	qla2xxx_dump_post_process(base_vha, rval);
10768c2ecf20Sopenharmony_ci}
10778c2ecf20Sopenharmony_ci
10788c2ecf20Sopenharmony_civoid
10798c2ecf20Sopenharmony_ciqla24xx_fw_dump(scsi_qla_host_t *vha)
10808c2ecf20Sopenharmony_ci{
10818c2ecf20Sopenharmony_ci	int		rval;
10828c2ecf20Sopenharmony_ci	uint32_t	cnt;
10838c2ecf20Sopenharmony_ci	struct qla_hw_data *ha = vha->hw;
10848c2ecf20Sopenharmony_ci	struct device_reg_24xx __iomem *reg = &ha->iobase->isp24;
10858c2ecf20Sopenharmony_ci	__le32 __iomem *dmp_reg;
10868c2ecf20Sopenharmony_ci	__be32		*iter_reg;
10878c2ecf20Sopenharmony_ci	__le16 __iomem *mbx_reg;
10888c2ecf20Sopenharmony_ci	struct qla24xx_fw_dump *fw;
10898c2ecf20Sopenharmony_ci	void		*nxt;
10908c2ecf20Sopenharmony_ci	void		*nxt_chain;
10918c2ecf20Sopenharmony_ci	__be32		*last_chain = NULL;
10928c2ecf20Sopenharmony_ci	struct scsi_qla_host *base_vha = pci_get_drvdata(ha->pdev);
10938c2ecf20Sopenharmony_ci
10948c2ecf20Sopenharmony_ci	lockdep_assert_held(&ha->hardware_lock);
10958c2ecf20Sopenharmony_ci
10968c2ecf20Sopenharmony_ci	if (IS_P3P_TYPE(ha))
10978c2ecf20Sopenharmony_ci		return;
10988c2ecf20Sopenharmony_ci
10998c2ecf20Sopenharmony_ci	ha->fw_dump_cap_flags = 0;
11008c2ecf20Sopenharmony_ci
11018c2ecf20Sopenharmony_ci	if (!ha->fw_dump) {
11028c2ecf20Sopenharmony_ci		ql_log(ql_log_warn, vha, 0xd006,
11038c2ecf20Sopenharmony_ci		    "No buffer available for dump.\n");
11048c2ecf20Sopenharmony_ci		return;
11058c2ecf20Sopenharmony_ci	}
11068c2ecf20Sopenharmony_ci
11078c2ecf20Sopenharmony_ci	if (ha->fw_dumped) {
11088c2ecf20Sopenharmony_ci		ql_log(ql_log_warn, vha, 0xd007,
11098c2ecf20Sopenharmony_ci		    "Firmware has been previously dumped (%p) "
11108c2ecf20Sopenharmony_ci		    "-- ignoring request.\n",
11118c2ecf20Sopenharmony_ci		    ha->fw_dump);
11128c2ecf20Sopenharmony_ci		return;
11138c2ecf20Sopenharmony_ci	}
11148c2ecf20Sopenharmony_ci	QLA_FW_STOPPED(ha);
11158c2ecf20Sopenharmony_ci	fw = &ha->fw_dump->isp.isp24;
11168c2ecf20Sopenharmony_ci	qla2xxx_prep_dump(ha, ha->fw_dump);
11178c2ecf20Sopenharmony_ci
11188c2ecf20Sopenharmony_ci	fw->host_status = htonl(rd_reg_dword(&reg->host_status));
11198c2ecf20Sopenharmony_ci
11208c2ecf20Sopenharmony_ci	/*
11218c2ecf20Sopenharmony_ci	 * Pause RISC. No need to track timeout, as resetting the chip
11228c2ecf20Sopenharmony_ci	 * is the right approach incase of pause timeout
11238c2ecf20Sopenharmony_ci	 */
11248c2ecf20Sopenharmony_ci	qla24xx_pause_risc(reg, ha);
11258c2ecf20Sopenharmony_ci
11268c2ecf20Sopenharmony_ci	/* Host interface registers. */
11278c2ecf20Sopenharmony_ci	dmp_reg = &reg->flash_addr;
11288c2ecf20Sopenharmony_ci	for (cnt = 0; cnt < ARRAY_SIZE(fw->host_reg); cnt++, dmp_reg++)
11298c2ecf20Sopenharmony_ci		fw->host_reg[cnt] = htonl(rd_reg_dword(dmp_reg));
11308c2ecf20Sopenharmony_ci
11318c2ecf20Sopenharmony_ci	/* Disable interrupts. */
11328c2ecf20Sopenharmony_ci	wrt_reg_dword(&reg->ictrl, 0);
11338c2ecf20Sopenharmony_ci	rd_reg_dword(&reg->ictrl);
11348c2ecf20Sopenharmony_ci
11358c2ecf20Sopenharmony_ci	/* Shadow registers. */
11368c2ecf20Sopenharmony_ci	wrt_reg_dword(&reg->iobase_addr, 0x0F70);
11378c2ecf20Sopenharmony_ci	rd_reg_dword(&reg->iobase_addr);
11388c2ecf20Sopenharmony_ci	wrt_reg_dword(&reg->iobase_select, 0xB0000000);
11398c2ecf20Sopenharmony_ci	fw->shadow_reg[0] = htonl(rd_reg_dword(&reg->iobase_sdata));
11408c2ecf20Sopenharmony_ci
11418c2ecf20Sopenharmony_ci	wrt_reg_dword(&reg->iobase_select, 0xB0100000);
11428c2ecf20Sopenharmony_ci	fw->shadow_reg[1] = htonl(rd_reg_dword(&reg->iobase_sdata));
11438c2ecf20Sopenharmony_ci
11448c2ecf20Sopenharmony_ci	wrt_reg_dword(&reg->iobase_select, 0xB0200000);
11458c2ecf20Sopenharmony_ci	fw->shadow_reg[2] = htonl(rd_reg_dword(&reg->iobase_sdata));
11468c2ecf20Sopenharmony_ci
11478c2ecf20Sopenharmony_ci	wrt_reg_dword(&reg->iobase_select, 0xB0300000);
11488c2ecf20Sopenharmony_ci	fw->shadow_reg[3] = htonl(rd_reg_dword(&reg->iobase_sdata));
11498c2ecf20Sopenharmony_ci
11508c2ecf20Sopenharmony_ci	wrt_reg_dword(&reg->iobase_select, 0xB0400000);
11518c2ecf20Sopenharmony_ci	fw->shadow_reg[4] = htonl(rd_reg_dword(&reg->iobase_sdata));
11528c2ecf20Sopenharmony_ci
11538c2ecf20Sopenharmony_ci	wrt_reg_dword(&reg->iobase_select, 0xB0500000);
11548c2ecf20Sopenharmony_ci	fw->shadow_reg[5] = htonl(rd_reg_dword(&reg->iobase_sdata));
11558c2ecf20Sopenharmony_ci
11568c2ecf20Sopenharmony_ci	wrt_reg_dword(&reg->iobase_select, 0xB0600000);
11578c2ecf20Sopenharmony_ci	fw->shadow_reg[6] = htonl(rd_reg_dword(&reg->iobase_sdata));
11588c2ecf20Sopenharmony_ci
11598c2ecf20Sopenharmony_ci	/* Mailbox registers. */
11608c2ecf20Sopenharmony_ci	mbx_reg = &reg->mailbox0;
11618c2ecf20Sopenharmony_ci	for (cnt = 0; cnt < ARRAY_SIZE(fw->mailbox_reg); cnt++, mbx_reg++)
11628c2ecf20Sopenharmony_ci		fw->mailbox_reg[cnt] = htons(rd_reg_word(mbx_reg));
11638c2ecf20Sopenharmony_ci
11648c2ecf20Sopenharmony_ci	/* Transfer sequence registers. */
11658c2ecf20Sopenharmony_ci	iter_reg = fw->xseq_gp_reg;
11668c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0xBF00, 16, iter_reg);
11678c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0xBF10, 16, iter_reg);
11688c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0xBF20, 16, iter_reg);
11698c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0xBF30, 16, iter_reg);
11708c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0xBF40, 16, iter_reg);
11718c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0xBF50, 16, iter_reg);
11728c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0xBF60, 16, iter_reg);
11738c2ecf20Sopenharmony_ci	qla24xx_read_window(reg, 0xBF70, 16, iter_reg);
11748c2ecf20Sopenharmony_ci
11758c2ecf20Sopenharmony_ci	qla24xx_read_window(reg, 0xBFE0, 16, fw->xseq_0_reg);
11768c2ecf20Sopenharmony_ci	qla24xx_read_window(reg, 0xBFF0, 16, fw->xseq_1_reg);
11778c2ecf20Sopenharmony_ci
11788c2ecf20Sopenharmony_ci	/* Receive sequence registers. */
11798c2ecf20Sopenharmony_ci	iter_reg = fw->rseq_gp_reg;
11808c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0xFF00, 16, iter_reg);
11818c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0xFF10, 16, iter_reg);
11828c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0xFF20, 16, iter_reg);
11838c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0xFF30, 16, iter_reg);
11848c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0xFF40, 16, iter_reg);
11858c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0xFF50, 16, iter_reg);
11868c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0xFF60, 16, iter_reg);
11878c2ecf20Sopenharmony_ci	qla24xx_read_window(reg, 0xFF70, 16, iter_reg);
11888c2ecf20Sopenharmony_ci
11898c2ecf20Sopenharmony_ci	qla24xx_read_window(reg, 0xFFD0, 16, fw->rseq_0_reg);
11908c2ecf20Sopenharmony_ci	qla24xx_read_window(reg, 0xFFE0, 16, fw->rseq_1_reg);
11918c2ecf20Sopenharmony_ci	qla24xx_read_window(reg, 0xFFF0, 16, fw->rseq_2_reg);
11928c2ecf20Sopenharmony_ci
11938c2ecf20Sopenharmony_ci	/* Command DMA registers. */
11948c2ecf20Sopenharmony_ci	qla24xx_read_window(reg, 0x7100, 16, fw->cmd_dma_reg);
11958c2ecf20Sopenharmony_ci
11968c2ecf20Sopenharmony_ci	/* Queues. */
11978c2ecf20Sopenharmony_ci	iter_reg = fw->req0_dma_reg;
11988c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x7200, 8, iter_reg);
11998c2ecf20Sopenharmony_ci	dmp_reg = &reg->iobase_q;
12008c2ecf20Sopenharmony_ci	for (cnt = 0; cnt < 7; cnt++, dmp_reg++)
12018c2ecf20Sopenharmony_ci		*iter_reg++ = htonl(rd_reg_dword(dmp_reg));
12028c2ecf20Sopenharmony_ci
12038c2ecf20Sopenharmony_ci	iter_reg = fw->resp0_dma_reg;
12048c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x7300, 8, iter_reg);
12058c2ecf20Sopenharmony_ci	dmp_reg = &reg->iobase_q;
12068c2ecf20Sopenharmony_ci	for (cnt = 0; cnt < 7; cnt++, dmp_reg++)
12078c2ecf20Sopenharmony_ci		*iter_reg++ = htonl(rd_reg_dword(dmp_reg));
12088c2ecf20Sopenharmony_ci
12098c2ecf20Sopenharmony_ci	iter_reg = fw->req1_dma_reg;
12108c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x7400, 8, iter_reg);
12118c2ecf20Sopenharmony_ci	dmp_reg = &reg->iobase_q;
12128c2ecf20Sopenharmony_ci	for (cnt = 0; cnt < 7; cnt++, dmp_reg++)
12138c2ecf20Sopenharmony_ci		*iter_reg++ = htonl(rd_reg_dword(dmp_reg));
12148c2ecf20Sopenharmony_ci
12158c2ecf20Sopenharmony_ci	/* Transmit DMA registers. */
12168c2ecf20Sopenharmony_ci	iter_reg = fw->xmt0_dma_reg;
12178c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x7600, 16, iter_reg);
12188c2ecf20Sopenharmony_ci	qla24xx_read_window(reg, 0x7610, 16, iter_reg);
12198c2ecf20Sopenharmony_ci
12208c2ecf20Sopenharmony_ci	iter_reg = fw->xmt1_dma_reg;
12218c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x7620, 16, iter_reg);
12228c2ecf20Sopenharmony_ci	qla24xx_read_window(reg, 0x7630, 16, iter_reg);
12238c2ecf20Sopenharmony_ci
12248c2ecf20Sopenharmony_ci	iter_reg = fw->xmt2_dma_reg;
12258c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x7640, 16, iter_reg);
12268c2ecf20Sopenharmony_ci	qla24xx_read_window(reg, 0x7650, 16, iter_reg);
12278c2ecf20Sopenharmony_ci
12288c2ecf20Sopenharmony_ci	iter_reg = fw->xmt3_dma_reg;
12298c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x7660, 16, iter_reg);
12308c2ecf20Sopenharmony_ci	qla24xx_read_window(reg, 0x7670, 16, iter_reg);
12318c2ecf20Sopenharmony_ci
12328c2ecf20Sopenharmony_ci	iter_reg = fw->xmt4_dma_reg;
12338c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x7680, 16, iter_reg);
12348c2ecf20Sopenharmony_ci	qla24xx_read_window(reg, 0x7690, 16, iter_reg);
12358c2ecf20Sopenharmony_ci
12368c2ecf20Sopenharmony_ci	qla24xx_read_window(reg, 0x76A0, 16, fw->xmt_data_dma_reg);
12378c2ecf20Sopenharmony_ci
12388c2ecf20Sopenharmony_ci	/* Receive DMA registers. */
12398c2ecf20Sopenharmony_ci	iter_reg = fw->rcvt0_data_dma_reg;
12408c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x7700, 16, iter_reg);
12418c2ecf20Sopenharmony_ci	qla24xx_read_window(reg, 0x7710, 16, iter_reg);
12428c2ecf20Sopenharmony_ci
12438c2ecf20Sopenharmony_ci	iter_reg = fw->rcvt1_data_dma_reg;
12448c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x7720, 16, iter_reg);
12458c2ecf20Sopenharmony_ci	qla24xx_read_window(reg, 0x7730, 16, iter_reg);
12468c2ecf20Sopenharmony_ci
12478c2ecf20Sopenharmony_ci	/* RISC registers. */
12488c2ecf20Sopenharmony_ci	iter_reg = fw->risc_gp_reg;
12498c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x0F00, 16, iter_reg);
12508c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x0F10, 16, iter_reg);
12518c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x0F20, 16, iter_reg);
12528c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x0F30, 16, iter_reg);
12538c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x0F40, 16, iter_reg);
12548c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x0F50, 16, iter_reg);
12558c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x0F60, 16, iter_reg);
12568c2ecf20Sopenharmony_ci	qla24xx_read_window(reg, 0x0F70, 16, iter_reg);
12578c2ecf20Sopenharmony_ci
12588c2ecf20Sopenharmony_ci	/* Local memory controller registers. */
12598c2ecf20Sopenharmony_ci	iter_reg = fw->lmc_reg;
12608c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x3000, 16, iter_reg);
12618c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x3010, 16, iter_reg);
12628c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x3020, 16, iter_reg);
12638c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x3030, 16, iter_reg);
12648c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x3040, 16, iter_reg);
12658c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x3050, 16, iter_reg);
12668c2ecf20Sopenharmony_ci	qla24xx_read_window(reg, 0x3060, 16, iter_reg);
12678c2ecf20Sopenharmony_ci
12688c2ecf20Sopenharmony_ci	/* Fibre Protocol Module registers. */
12698c2ecf20Sopenharmony_ci	iter_reg = fw->fpm_hdw_reg;
12708c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x4000, 16, iter_reg);
12718c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x4010, 16, iter_reg);
12728c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x4020, 16, iter_reg);
12738c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x4030, 16, iter_reg);
12748c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x4040, 16, iter_reg);
12758c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x4050, 16, iter_reg);
12768c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x4060, 16, iter_reg);
12778c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x4070, 16, iter_reg);
12788c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x4080, 16, iter_reg);
12798c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x4090, 16, iter_reg);
12808c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x40A0, 16, iter_reg);
12818c2ecf20Sopenharmony_ci	qla24xx_read_window(reg, 0x40B0, 16, iter_reg);
12828c2ecf20Sopenharmony_ci
12838c2ecf20Sopenharmony_ci	/* Frame Buffer registers. */
12848c2ecf20Sopenharmony_ci	iter_reg = fw->fb_hdw_reg;
12858c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x6000, 16, iter_reg);
12868c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x6010, 16, iter_reg);
12878c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x6020, 16, iter_reg);
12888c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x6030, 16, iter_reg);
12898c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x6040, 16, iter_reg);
12908c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x6100, 16, iter_reg);
12918c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x6130, 16, iter_reg);
12928c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x6150, 16, iter_reg);
12938c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x6170, 16, iter_reg);
12948c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x6190, 16, iter_reg);
12958c2ecf20Sopenharmony_ci	qla24xx_read_window(reg, 0x61B0, 16, iter_reg);
12968c2ecf20Sopenharmony_ci
12978c2ecf20Sopenharmony_ci	rval = qla24xx_soft_reset(ha);
12988c2ecf20Sopenharmony_ci	if (rval != QLA_SUCCESS)
12998c2ecf20Sopenharmony_ci		goto qla24xx_fw_dump_failed_0;
13008c2ecf20Sopenharmony_ci
13018c2ecf20Sopenharmony_ci	rval = qla24xx_dump_memory(ha, fw->code_ram, sizeof(fw->code_ram),
13028c2ecf20Sopenharmony_ci	    &nxt);
13038c2ecf20Sopenharmony_ci	if (rval != QLA_SUCCESS)
13048c2ecf20Sopenharmony_ci		goto qla24xx_fw_dump_failed_0;
13058c2ecf20Sopenharmony_ci
13068c2ecf20Sopenharmony_ci	nxt = qla2xxx_copy_queues(ha, nxt);
13078c2ecf20Sopenharmony_ci
13088c2ecf20Sopenharmony_ci	qla24xx_copy_eft(ha, nxt);
13098c2ecf20Sopenharmony_ci
13108c2ecf20Sopenharmony_ci	nxt_chain = (void *)ha->fw_dump + ha->chain_offset;
13118c2ecf20Sopenharmony_ci	nxt_chain = qla2xxx_copy_atioqueues(ha, nxt_chain, &last_chain);
13128c2ecf20Sopenharmony_ci	if (last_chain) {
13138c2ecf20Sopenharmony_ci		ha->fw_dump->version |= htonl(DUMP_CHAIN_VARIANT);
13148c2ecf20Sopenharmony_ci		*last_chain |= htonl(DUMP_CHAIN_LAST);
13158c2ecf20Sopenharmony_ci	}
13168c2ecf20Sopenharmony_ci
13178c2ecf20Sopenharmony_ci	/* Adjust valid length. */
13188c2ecf20Sopenharmony_ci	ha->fw_dump_len = (nxt_chain - (void *)ha->fw_dump);
13198c2ecf20Sopenharmony_ci
13208c2ecf20Sopenharmony_ciqla24xx_fw_dump_failed_0:
13218c2ecf20Sopenharmony_ci	qla2xxx_dump_post_process(base_vha, rval);
13228c2ecf20Sopenharmony_ci}
13238c2ecf20Sopenharmony_ci
13248c2ecf20Sopenharmony_civoid
13258c2ecf20Sopenharmony_ciqla25xx_fw_dump(scsi_qla_host_t *vha)
13268c2ecf20Sopenharmony_ci{
13278c2ecf20Sopenharmony_ci	int		rval;
13288c2ecf20Sopenharmony_ci	uint32_t	cnt;
13298c2ecf20Sopenharmony_ci	struct qla_hw_data *ha = vha->hw;
13308c2ecf20Sopenharmony_ci	struct device_reg_24xx __iomem *reg = &ha->iobase->isp24;
13318c2ecf20Sopenharmony_ci	__le32 __iomem *dmp_reg;
13328c2ecf20Sopenharmony_ci	__be32		*iter_reg;
13338c2ecf20Sopenharmony_ci	__le16 __iomem *mbx_reg;
13348c2ecf20Sopenharmony_ci	struct qla25xx_fw_dump *fw;
13358c2ecf20Sopenharmony_ci	void		*nxt, *nxt_chain;
13368c2ecf20Sopenharmony_ci	__be32		*last_chain = NULL;
13378c2ecf20Sopenharmony_ci	struct scsi_qla_host *base_vha = pci_get_drvdata(ha->pdev);
13388c2ecf20Sopenharmony_ci
13398c2ecf20Sopenharmony_ci	lockdep_assert_held(&ha->hardware_lock);
13408c2ecf20Sopenharmony_ci
13418c2ecf20Sopenharmony_ci	ha->fw_dump_cap_flags = 0;
13428c2ecf20Sopenharmony_ci
13438c2ecf20Sopenharmony_ci	if (!ha->fw_dump) {
13448c2ecf20Sopenharmony_ci		ql_log(ql_log_warn, vha, 0xd008,
13458c2ecf20Sopenharmony_ci		    "No buffer available for dump.\n");
13468c2ecf20Sopenharmony_ci		return;
13478c2ecf20Sopenharmony_ci	}
13488c2ecf20Sopenharmony_ci
13498c2ecf20Sopenharmony_ci	if (ha->fw_dumped) {
13508c2ecf20Sopenharmony_ci		ql_log(ql_log_warn, vha, 0xd009,
13518c2ecf20Sopenharmony_ci		    "Firmware has been previously dumped (%p) "
13528c2ecf20Sopenharmony_ci		    "-- ignoring request.\n",
13538c2ecf20Sopenharmony_ci		    ha->fw_dump);
13548c2ecf20Sopenharmony_ci		return;
13558c2ecf20Sopenharmony_ci	}
13568c2ecf20Sopenharmony_ci	QLA_FW_STOPPED(ha);
13578c2ecf20Sopenharmony_ci	fw = &ha->fw_dump->isp.isp25;
13588c2ecf20Sopenharmony_ci	qla2xxx_prep_dump(ha, ha->fw_dump);
13598c2ecf20Sopenharmony_ci	ha->fw_dump->version = htonl(2);
13608c2ecf20Sopenharmony_ci
13618c2ecf20Sopenharmony_ci	fw->host_status = htonl(rd_reg_dword(&reg->host_status));
13628c2ecf20Sopenharmony_ci
13638c2ecf20Sopenharmony_ci	/*
13648c2ecf20Sopenharmony_ci	 * Pause RISC. No need to track timeout, as resetting the chip
13658c2ecf20Sopenharmony_ci	 * is the right approach incase of pause timeout
13668c2ecf20Sopenharmony_ci	 */
13678c2ecf20Sopenharmony_ci	qla24xx_pause_risc(reg, ha);
13688c2ecf20Sopenharmony_ci
13698c2ecf20Sopenharmony_ci	/* Host/Risc registers. */
13708c2ecf20Sopenharmony_ci	iter_reg = fw->host_risc_reg;
13718c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x7000, 16, iter_reg);
13728c2ecf20Sopenharmony_ci	qla24xx_read_window(reg, 0x7010, 16, iter_reg);
13738c2ecf20Sopenharmony_ci
13748c2ecf20Sopenharmony_ci	/* PCIe registers. */
13758c2ecf20Sopenharmony_ci	wrt_reg_dword(&reg->iobase_addr, 0x7C00);
13768c2ecf20Sopenharmony_ci	rd_reg_dword(&reg->iobase_addr);
13778c2ecf20Sopenharmony_ci	wrt_reg_dword(&reg->iobase_window, 0x01);
13788c2ecf20Sopenharmony_ci	dmp_reg = &reg->iobase_c4;
13798c2ecf20Sopenharmony_ci	fw->pcie_regs[0] = htonl(rd_reg_dword(dmp_reg));
13808c2ecf20Sopenharmony_ci	dmp_reg++;
13818c2ecf20Sopenharmony_ci	fw->pcie_regs[1] = htonl(rd_reg_dword(dmp_reg));
13828c2ecf20Sopenharmony_ci	dmp_reg++;
13838c2ecf20Sopenharmony_ci	fw->pcie_regs[2] = htonl(rd_reg_dword(dmp_reg));
13848c2ecf20Sopenharmony_ci	fw->pcie_regs[3] = htonl(rd_reg_dword(&reg->iobase_window));
13858c2ecf20Sopenharmony_ci
13868c2ecf20Sopenharmony_ci	wrt_reg_dword(&reg->iobase_window, 0x00);
13878c2ecf20Sopenharmony_ci	rd_reg_dword(&reg->iobase_window);
13888c2ecf20Sopenharmony_ci
13898c2ecf20Sopenharmony_ci	/* Host interface registers. */
13908c2ecf20Sopenharmony_ci	dmp_reg = &reg->flash_addr;
13918c2ecf20Sopenharmony_ci	for (cnt = 0; cnt < ARRAY_SIZE(fw->host_reg); cnt++, dmp_reg++)
13928c2ecf20Sopenharmony_ci		fw->host_reg[cnt] = htonl(rd_reg_dword(dmp_reg));
13938c2ecf20Sopenharmony_ci
13948c2ecf20Sopenharmony_ci	/* Disable interrupts. */
13958c2ecf20Sopenharmony_ci	wrt_reg_dword(&reg->ictrl, 0);
13968c2ecf20Sopenharmony_ci	rd_reg_dword(&reg->ictrl);
13978c2ecf20Sopenharmony_ci
13988c2ecf20Sopenharmony_ci	/* Shadow registers. */
13998c2ecf20Sopenharmony_ci	wrt_reg_dword(&reg->iobase_addr, 0x0F70);
14008c2ecf20Sopenharmony_ci	rd_reg_dword(&reg->iobase_addr);
14018c2ecf20Sopenharmony_ci	wrt_reg_dword(&reg->iobase_select, 0xB0000000);
14028c2ecf20Sopenharmony_ci	fw->shadow_reg[0] = htonl(rd_reg_dword(&reg->iobase_sdata));
14038c2ecf20Sopenharmony_ci
14048c2ecf20Sopenharmony_ci	wrt_reg_dword(&reg->iobase_select, 0xB0100000);
14058c2ecf20Sopenharmony_ci	fw->shadow_reg[1] = htonl(rd_reg_dword(&reg->iobase_sdata));
14068c2ecf20Sopenharmony_ci
14078c2ecf20Sopenharmony_ci	wrt_reg_dword(&reg->iobase_select, 0xB0200000);
14088c2ecf20Sopenharmony_ci	fw->shadow_reg[2] = htonl(rd_reg_dword(&reg->iobase_sdata));
14098c2ecf20Sopenharmony_ci
14108c2ecf20Sopenharmony_ci	wrt_reg_dword(&reg->iobase_select, 0xB0300000);
14118c2ecf20Sopenharmony_ci	fw->shadow_reg[3] = htonl(rd_reg_dword(&reg->iobase_sdata));
14128c2ecf20Sopenharmony_ci
14138c2ecf20Sopenharmony_ci	wrt_reg_dword(&reg->iobase_select, 0xB0400000);
14148c2ecf20Sopenharmony_ci	fw->shadow_reg[4] = htonl(rd_reg_dword(&reg->iobase_sdata));
14158c2ecf20Sopenharmony_ci
14168c2ecf20Sopenharmony_ci	wrt_reg_dword(&reg->iobase_select, 0xB0500000);
14178c2ecf20Sopenharmony_ci	fw->shadow_reg[5] = htonl(rd_reg_dword(&reg->iobase_sdata));
14188c2ecf20Sopenharmony_ci
14198c2ecf20Sopenharmony_ci	wrt_reg_dword(&reg->iobase_select, 0xB0600000);
14208c2ecf20Sopenharmony_ci	fw->shadow_reg[6] = htonl(rd_reg_dword(&reg->iobase_sdata));
14218c2ecf20Sopenharmony_ci
14228c2ecf20Sopenharmony_ci	wrt_reg_dword(&reg->iobase_select, 0xB0700000);
14238c2ecf20Sopenharmony_ci	fw->shadow_reg[7] = htonl(rd_reg_dword(&reg->iobase_sdata));
14248c2ecf20Sopenharmony_ci
14258c2ecf20Sopenharmony_ci	wrt_reg_dword(&reg->iobase_select, 0xB0800000);
14268c2ecf20Sopenharmony_ci	fw->shadow_reg[8] = htonl(rd_reg_dword(&reg->iobase_sdata));
14278c2ecf20Sopenharmony_ci
14288c2ecf20Sopenharmony_ci	wrt_reg_dword(&reg->iobase_select, 0xB0900000);
14298c2ecf20Sopenharmony_ci	fw->shadow_reg[9] = htonl(rd_reg_dword(&reg->iobase_sdata));
14308c2ecf20Sopenharmony_ci
14318c2ecf20Sopenharmony_ci	wrt_reg_dword(&reg->iobase_select, 0xB0A00000);
14328c2ecf20Sopenharmony_ci	fw->shadow_reg[10] = htonl(rd_reg_dword(&reg->iobase_sdata));
14338c2ecf20Sopenharmony_ci
14348c2ecf20Sopenharmony_ci	/* RISC I/O register. */
14358c2ecf20Sopenharmony_ci	wrt_reg_dword(&reg->iobase_addr, 0x0010);
14368c2ecf20Sopenharmony_ci	fw->risc_io_reg = htonl(rd_reg_dword(&reg->iobase_window));
14378c2ecf20Sopenharmony_ci
14388c2ecf20Sopenharmony_ci	/* Mailbox registers. */
14398c2ecf20Sopenharmony_ci	mbx_reg = &reg->mailbox0;
14408c2ecf20Sopenharmony_ci	for (cnt = 0; cnt < ARRAY_SIZE(fw->mailbox_reg); cnt++, mbx_reg++)
14418c2ecf20Sopenharmony_ci		fw->mailbox_reg[cnt] = htons(rd_reg_word(mbx_reg));
14428c2ecf20Sopenharmony_ci
14438c2ecf20Sopenharmony_ci	/* Transfer sequence registers. */
14448c2ecf20Sopenharmony_ci	iter_reg = fw->xseq_gp_reg;
14458c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0xBF00, 16, iter_reg);
14468c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0xBF10, 16, iter_reg);
14478c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0xBF20, 16, iter_reg);
14488c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0xBF30, 16, iter_reg);
14498c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0xBF40, 16, iter_reg);
14508c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0xBF50, 16, iter_reg);
14518c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0xBF60, 16, iter_reg);
14528c2ecf20Sopenharmony_ci	qla24xx_read_window(reg, 0xBF70, 16, iter_reg);
14538c2ecf20Sopenharmony_ci
14548c2ecf20Sopenharmony_ci	iter_reg = fw->xseq_0_reg;
14558c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0xBFC0, 16, iter_reg);
14568c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0xBFD0, 16, iter_reg);
14578c2ecf20Sopenharmony_ci	qla24xx_read_window(reg, 0xBFE0, 16, iter_reg);
14588c2ecf20Sopenharmony_ci
14598c2ecf20Sopenharmony_ci	qla24xx_read_window(reg, 0xBFF0, 16, fw->xseq_1_reg);
14608c2ecf20Sopenharmony_ci
14618c2ecf20Sopenharmony_ci	/* Receive sequence registers. */
14628c2ecf20Sopenharmony_ci	iter_reg = fw->rseq_gp_reg;
14638c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0xFF00, 16, iter_reg);
14648c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0xFF10, 16, iter_reg);
14658c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0xFF20, 16, iter_reg);
14668c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0xFF30, 16, iter_reg);
14678c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0xFF40, 16, iter_reg);
14688c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0xFF50, 16, iter_reg);
14698c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0xFF60, 16, iter_reg);
14708c2ecf20Sopenharmony_ci	qla24xx_read_window(reg, 0xFF70, 16, iter_reg);
14718c2ecf20Sopenharmony_ci
14728c2ecf20Sopenharmony_ci	iter_reg = fw->rseq_0_reg;
14738c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0xFFC0, 16, iter_reg);
14748c2ecf20Sopenharmony_ci	qla24xx_read_window(reg, 0xFFD0, 16, iter_reg);
14758c2ecf20Sopenharmony_ci
14768c2ecf20Sopenharmony_ci	qla24xx_read_window(reg, 0xFFE0, 16, fw->rseq_1_reg);
14778c2ecf20Sopenharmony_ci	qla24xx_read_window(reg, 0xFFF0, 16, fw->rseq_2_reg);
14788c2ecf20Sopenharmony_ci
14798c2ecf20Sopenharmony_ci	/* Auxiliary sequence registers. */
14808c2ecf20Sopenharmony_ci	iter_reg = fw->aseq_gp_reg;
14818c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0xB000, 16, iter_reg);
14828c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0xB010, 16, iter_reg);
14838c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0xB020, 16, iter_reg);
14848c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0xB030, 16, iter_reg);
14858c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0xB040, 16, iter_reg);
14868c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0xB050, 16, iter_reg);
14878c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0xB060, 16, iter_reg);
14888c2ecf20Sopenharmony_ci	qla24xx_read_window(reg, 0xB070, 16, iter_reg);
14898c2ecf20Sopenharmony_ci
14908c2ecf20Sopenharmony_ci	iter_reg = fw->aseq_0_reg;
14918c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0xB0C0, 16, iter_reg);
14928c2ecf20Sopenharmony_ci	qla24xx_read_window(reg, 0xB0D0, 16, iter_reg);
14938c2ecf20Sopenharmony_ci
14948c2ecf20Sopenharmony_ci	qla24xx_read_window(reg, 0xB0E0, 16, fw->aseq_1_reg);
14958c2ecf20Sopenharmony_ci	qla24xx_read_window(reg, 0xB0F0, 16, fw->aseq_2_reg);
14968c2ecf20Sopenharmony_ci
14978c2ecf20Sopenharmony_ci	/* Command DMA registers. */
14988c2ecf20Sopenharmony_ci	qla24xx_read_window(reg, 0x7100, 16, fw->cmd_dma_reg);
14998c2ecf20Sopenharmony_ci
15008c2ecf20Sopenharmony_ci	/* Queues. */
15018c2ecf20Sopenharmony_ci	iter_reg = fw->req0_dma_reg;
15028c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x7200, 8, iter_reg);
15038c2ecf20Sopenharmony_ci	dmp_reg = &reg->iobase_q;
15048c2ecf20Sopenharmony_ci	for (cnt = 0; cnt < 7; cnt++, dmp_reg++)
15058c2ecf20Sopenharmony_ci		*iter_reg++ = htonl(rd_reg_dword(dmp_reg));
15068c2ecf20Sopenharmony_ci
15078c2ecf20Sopenharmony_ci	iter_reg = fw->resp0_dma_reg;
15088c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x7300, 8, iter_reg);
15098c2ecf20Sopenharmony_ci	dmp_reg = &reg->iobase_q;
15108c2ecf20Sopenharmony_ci	for (cnt = 0; cnt < 7; cnt++, dmp_reg++)
15118c2ecf20Sopenharmony_ci		*iter_reg++ = htonl(rd_reg_dword(dmp_reg));
15128c2ecf20Sopenharmony_ci
15138c2ecf20Sopenharmony_ci	iter_reg = fw->req1_dma_reg;
15148c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x7400, 8, iter_reg);
15158c2ecf20Sopenharmony_ci	dmp_reg = &reg->iobase_q;
15168c2ecf20Sopenharmony_ci	for (cnt = 0; cnt < 7; cnt++, dmp_reg++)
15178c2ecf20Sopenharmony_ci		*iter_reg++ = htonl(rd_reg_dword(dmp_reg));
15188c2ecf20Sopenharmony_ci
15198c2ecf20Sopenharmony_ci	/* Transmit DMA registers. */
15208c2ecf20Sopenharmony_ci	iter_reg = fw->xmt0_dma_reg;
15218c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x7600, 16, iter_reg);
15228c2ecf20Sopenharmony_ci	qla24xx_read_window(reg, 0x7610, 16, iter_reg);
15238c2ecf20Sopenharmony_ci
15248c2ecf20Sopenharmony_ci	iter_reg = fw->xmt1_dma_reg;
15258c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x7620, 16, iter_reg);
15268c2ecf20Sopenharmony_ci	qla24xx_read_window(reg, 0x7630, 16, iter_reg);
15278c2ecf20Sopenharmony_ci
15288c2ecf20Sopenharmony_ci	iter_reg = fw->xmt2_dma_reg;
15298c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x7640, 16, iter_reg);
15308c2ecf20Sopenharmony_ci	qla24xx_read_window(reg, 0x7650, 16, iter_reg);
15318c2ecf20Sopenharmony_ci
15328c2ecf20Sopenharmony_ci	iter_reg = fw->xmt3_dma_reg;
15338c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x7660, 16, iter_reg);
15348c2ecf20Sopenharmony_ci	qla24xx_read_window(reg, 0x7670, 16, iter_reg);
15358c2ecf20Sopenharmony_ci
15368c2ecf20Sopenharmony_ci	iter_reg = fw->xmt4_dma_reg;
15378c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x7680, 16, iter_reg);
15388c2ecf20Sopenharmony_ci	qla24xx_read_window(reg, 0x7690, 16, iter_reg);
15398c2ecf20Sopenharmony_ci
15408c2ecf20Sopenharmony_ci	qla24xx_read_window(reg, 0x76A0, 16, fw->xmt_data_dma_reg);
15418c2ecf20Sopenharmony_ci
15428c2ecf20Sopenharmony_ci	/* Receive DMA registers. */
15438c2ecf20Sopenharmony_ci	iter_reg = fw->rcvt0_data_dma_reg;
15448c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x7700, 16, iter_reg);
15458c2ecf20Sopenharmony_ci	qla24xx_read_window(reg, 0x7710, 16, iter_reg);
15468c2ecf20Sopenharmony_ci
15478c2ecf20Sopenharmony_ci	iter_reg = fw->rcvt1_data_dma_reg;
15488c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x7720, 16, iter_reg);
15498c2ecf20Sopenharmony_ci	qla24xx_read_window(reg, 0x7730, 16, iter_reg);
15508c2ecf20Sopenharmony_ci
15518c2ecf20Sopenharmony_ci	/* RISC registers. */
15528c2ecf20Sopenharmony_ci	iter_reg = fw->risc_gp_reg;
15538c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x0F00, 16, iter_reg);
15548c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x0F10, 16, iter_reg);
15558c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x0F20, 16, iter_reg);
15568c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x0F30, 16, iter_reg);
15578c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x0F40, 16, iter_reg);
15588c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x0F50, 16, iter_reg);
15598c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x0F60, 16, iter_reg);
15608c2ecf20Sopenharmony_ci	qla24xx_read_window(reg, 0x0F70, 16, iter_reg);
15618c2ecf20Sopenharmony_ci
15628c2ecf20Sopenharmony_ci	/* Local memory controller registers. */
15638c2ecf20Sopenharmony_ci	iter_reg = fw->lmc_reg;
15648c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x3000, 16, iter_reg);
15658c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x3010, 16, iter_reg);
15668c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x3020, 16, iter_reg);
15678c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x3030, 16, iter_reg);
15688c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x3040, 16, iter_reg);
15698c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x3050, 16, iter_reg);
15708c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x3060, 16, iter_reg);
15718c2ecf20Sopenharmony_ci	qla24xx_read_window(reg, 0x3070, 16, iter_reg);
15728c2ecf20Sopenharmony_ci
15738c2ecf20Sopenharmony_ci	/* Fibre Protocol Module registers. */
15748c2ecf20Sopenharmony_ci	iter_reg = fw->fpm_hdw_reg;
15758c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x4000, 16, iter_reg);
15768c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x4010, 16, iter_reg);
15778c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x4020, 16, iter_reg);
15788c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x4030, 16, iter_reg);
15798c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x4040, 16, iter_reg);
15808c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x4050, 16, iter_reg);
15818c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x4060, 16, iter_reg);
15828c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x4070, 16, iter_reg);
15838c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x4080, 16, iter_reg);
15848c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x4090, 16, iter_reg);
15858c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x40A0, 16, iter_reg);
15868c2ecf20Sopenharmony_ci	qla24xx_read_window(reg, 0x40B0, 16, iter_reg);
15878c2ecf20Sopenharmony_ci
15888c2ecf20Sopenharmony_ci	/* Frame Buffer registers. */
15898c2ecf20Sopenharmony_ci	iter_reg = fw->fb_hdw_reg;
15908c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x6000, 16, iter_reg);
15918c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x6010, 16, iter_reg);
15928c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x6020, 16, iter_reg);
15938c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x6030, 16, iter_reg);
15948c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x6040, 16, iter_reg);
15958c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x6100, 16, iter_reg);
15968c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x6130, 16, iter_reg);
15978c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x6150, 16, iter_reg);
15988c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x6170, 16, iter_reg);
15998c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x6190, 16, iter_reg);
16008c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x61B0, 16, iter_reg);
16018c2ecf20Sopenharmony_ci	qla24xx_read_window(reg, 0x6F00, 16, iter_reg);
16028c2ecf20Sopenharmony_ci
16038c2ecf20Sopenharmony_ci	/* Multi queue registers */
16048c2ecf20Sopenharmony_ci	nxt_chain = qla25xx_copy_mq(ha, (void *)ha->fw_dump + ha->chain_offset,
16058c2ecf20Sopenharmony_ci	    &last_chain);
16068c2ecf20Sopenharmony_ci
16078c2ecf20Sopenharmony_ci	rval = qla24xx_soft_reset(ha);
16088c2ecf20Sopenharmony_ci	if (rval != QLA_SUCCESS)
16098c2ecf20Sopenharmony_ci		goto qla25xx_fw_dump_failed_0;
16108c2ecf20Sopenharmony_ci
16118c2ecf20Sopenharmony_ci	rval = qla24xx_dump_memory(ha, fw->code_ram, sizeof(fw->code_ram),
16128c2ecf20Sopenharmony_ci	    &nxt);
16138c2ecf20Sopenharmony_ci	if (rval != QLA_SUCCESS)
16148c2ecf20Sopenharmony_ci		goto qla25xx_fw_dump_failed_0;
16158c2ecf20Sopenharmony_ci
16168c2ecf20Sopenharmony_ci	nxt = qla2xxx_copy_queues(ha, nxt);
16178c2ecf20Sopenharmony_ci
16188c2ecf20Sopenharmony_ci	qla24xx_copy_eft(ha, nxt);
16198c2ecf20Sopenharmony_ci
16208c2ecf20Sopenharmony_ci	/* Chain entries -- started with MQ. */
16218c2ecf20Sopenharmony_ci	nxt_chain = qla25xx_copy_fce(ha, nxt_chain, &last_chain);
16228c2ecf20Sopenharmony_ci	nxt_chain = qla25xx_copy_mqueues(ha, nxt_chain, &last_chain);
16238c2ecf20Sopenharmony_ci	nxt_chain = qla2xxx_copy_atioqueues(ha, nxt_chain, &last_chain);
16248c2ecf20Sopenharmony_ci	nxt_chain = qla25xx_copy_exlogin(ha, nxt_chain, &last_chain);
16258c2ecf20Sopenharmony_ci	if (last_chain) {
16268c2ecf20Sopenharmony_ci		ha->fw_dump->version |= htonl(DUMP_CHAIN_VARIANT);
16278c2ecf20Sopenharmony_ci		*last_chain |= htonl(DUMP_CHAIN_LAST);
16288c2ecf20Sopenharmony_ci	}
16298c2ecf20Sopenharmony_ci
16308c2ecf20Sopenharmony_ci	/* Adjust valid length. */
16318c2ecf20Sopenharmony_ci	ha->fw_dump_len = (nxt_chain - (void *)ha->fw_dump);
16328c2ecf20Sopenharmony_ci
16338c2ecf20Sopenharmony_ciqla25xx_fw_dump_failed_0:
16348c2ecf20Sopenharmony_ci	qla2xxx_dump_post_process(base_vha, rval);
16358c2ecf20Sopenharmony_ci}
16368c2ecf20Sopenharmony_ci
16378c2ecf20Sopenharmony_civoid
16388c2ecf20Sopenharmony_ciqla81xx_fw_dump(scsi_qla_host_t *vha)
16398c2ecf20Sopenharmony_ci{
16408c2ecf20Sopenharmony_ci	int		rval;
16418c2ecf20Sopenharmony_ci	uint32_t	cnt;
16428c2ecf20Sopenharmony_ci	struct qla_hw_data *ha = vha->hw;
16438c2ecf20Sopenharmony_ci	struct device_reg_24xx __iomem *reg = &ha->iobase->isp24;
16448c2ecf20Sopenharmony_ci	__le32 __iomem *dmp_reg;
16458c2ecf20Sopenharmony_ci	__be32		*iter_reg;
16468c2ecf20Sopenharmony_ci	__le16 __iomem *mbx_reg;
16478c2ecf20Sopenharmony_ci	struct qla81xx_fw_dump *fw;
16488c2ecf20Sopenharmony_ci	void		*nxt, *nxt_chain;
16498c2ecf20Sopenharmony_ci	__be32		*last_chain = NULL;
16508c2ecf20Sopenharmony_ci	struct scsi_qla_host *base_vha = pci_get_drvdata(ha->pdev);
16518c2ecf20Sopenharmony_ci
16528c2ecf20Sopenharmony_ci	lockdep_assert_held(&ha->hardware_lock);
16538c2ecf20Sopenharmony_ci
16548c2ecf20Sopenharmony_ci	ha->fw_dump_cap_flags = 0;
16558c2ecf20Sopenharmony_ci
16568c2ecf20Sopenharmony_ci	if (!ha->fw_dump) {
16578c2ecf20Sopenharmony_ci		ql_log(ql_log_warn, vha, 0xd00a,
16588c2ecf20Sopenharmony_ci		    "No buffer available for dump.\n");
16598c2ecf20Sopenharmony_ci		return;
16608c2ecf20Sopenharmony_ci	}
16618c2ecf20Sopenharmony_ci
16628c2ecf20Sopenharmony_ci	if (ha->fw_dumped) {
16638c2ecf20Sopenharmony_ci		ql_log(ql_log_warn, vha, 0xd00b,
16648c2ecf20Sopenharmony_ci		    "Firmware has been previously dumped (%p) "
16658c2ecf20Sopenharmony_ci		    "-- ignoring request.\n",
16668c2ecf20Sopenharmony_ci		    ha->fw_dump);
16678c2ecf20Sopenharmony_ci		return;
16688c2ecf20Sopenharmony_ci	}
16698c2ecf20Sopenharmony_ci	fw = &ha->fw_dump->isp.isp81;
16708c2ecf20Sopenharmony_ci	qla2xxx_prep_dump(ha, ha->fw_dump);
16718c2ecf20Sopenharmony_ci
16728c2ecf20Sopenharmony_ci	fw->host_status = htonl(rd_reg_dword(&reg->host_status));
16738c2ecf20Sopenharmony_ci
16748c2ecf20Sopenharmony_ci	/*
16758c2ecf20Sopenharmony_ci	 * Pause RISC. No need to track timeout, as resetting the chip
16768c2ecf20Sopenharmony_ci	 * is the right approach incase of pause timeout
16778c2ecf20Sopenharmony_ci	 */
16788c2ecf20Sopenharmony_ci	qla24xx_pause_risc(reg, ha);
16798c2ecf20Sopenharmony_ci
16808c2ecf20Sopenharmony_ci	/* Host/Risc registers. */
16818c2ecf20Sopenharmony_ci	iter_reg = fw->host_risc_reg;
16828c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x7000, 16, iter_reg);
16838c2ecf20Sopenharmony_ci	qla24xx_read_window(reg, 0x7010, 16, iter_reg);
16848c2ecf20Sopenharmony_ci
16858c2ecf20Sopenharmony_ci	/* PCIe registers. */
16868c2ecf20Sopenharmony_ci	wrt_reg_dword(&reg->iobase_addr, 0x7C00);
16878c2ecf20Sopenharmony_ci	rd_reg_dword(&reg->iobase_addr);
16888c2ecf20Sopenharmony_ci	wrt_reg_dword(&reg->iobase_window, 0x01);
16898c2ecf20Sopenharmony_ci	dmp_reg = &reg->iobase_c4;
16908c2ecf20Sopenharmony_ci	fw->pcie_regs[0] = htonl(rd_reg_dword(dmp_reg));
16918c2ecf20Sopenharmony_ci	dmp_reg++;
16928c2ecf20Sopenharmony_ci	fw->pcie_regs[1] = htonl(rd_reg_dword(dmp_reg));
16938c2ecf20Sopenharmony_ci	dmp_reg++;
16948c2ecf20Sopenharmony_ci	fw->pcie_regs[2] = htonl(rd_reg_dword(dmp_reg));
16958c2ecf20Sopenharmony_ci	fw->pcie_regs[3] = htonl(rd_reg_dword(&reg->iobase_window));
16968c2ecf20Sopenharmony_ci
16978c2ecf20Sopenharmony_ci	wrt_reg_dword(&reg->iobase_window, 0x00);
16988c2ecf20Sopenharmony_ci	rd_reg_dword(&reg->iobase_window);
16998c2ecf20Sopenharmony_ci
17008c2ecf20Sopenharmony_ci	/* Host interface registers. */
17018c2ecf20Sopenharmony_ci	dmp_reg = &reg->flash_addr;
17028c2ecf20Sopenharmony_ci	for (cnt = 0; cnt < ARRAY_SIZE(fw->host_reg); cnt++, dmp_reg++)
17038c2ecf20Sopenharmony_ci		fw->host_reg[cnt] = htonl(rd_reg_dword(dmp_reg));
17048c2ecf20Sopenharmony_ci
17058c2ecf20Sopenharmony_ci	/* Disable interrupts. */
17068c2ecf20Sopenharmony_ci	wrt_reg_dword(&reg->ictrl, 0);
17078c2ecf20Sopenharmony_ci	rd_reg_dword(&reg->ictrl);
17088c2ecf20Sopenharmony_ci
17098c2ecf20Sopenharmony_ci	/* Shadow registers. */
17108c2ecf20Sopenharmony_ci	wrt_reg_dword(&reg->iobase_addr, 0x0F70);
17118c2ecf20Sopenharmony_ci	rd_reg_dword(&reg->iobase_addr);
17128c2ecf20Sopenharmony_ci	wrt_reg_dword(&reg->iobase_select, 0xB0000000);
17138c2ecf20Sopenharmony_ci	fw->shadow_reg[0] = htonl(rd_reg_dword(&reg->iobase_sdata));
17148c2ecf20Sopenharmony_ci
17158c2ecf20Sopenharmony_ci	wrt_reg_dword(&reg->iobase_select, 0xB0100000);
17168c2ecf20Sopenharmony_ci	fw->shadow_reg[1] = htonl(rd_reg_dword(&reg->iobase_sdata));
17178c2ecf20Sopenharmony_ci
17188c2ecf20Sopenharmony_ci	wrt_reg_dword(&reg->iobase_select, 0xB0200000);
17198c2ecf20Sopenharmony_ci	fw->shadow_reg[2] = htonl(rd_reg_dword(&reg->iobase_sdata));
17208c2ecf20Sopenharmony_ci
17218c2ecf20Sopenharmony_ci	wrt_reg_dword(&reg->iobase_select, 0xB0300000);
17228c2ecf20Sopenharmony_ci	fw->shadow_reg[3] = htonl(rd_reg_dword(&reg->iobase_sdata));
17238c2ecf20Sopenharmony_ci
17248c2ecf20Sopenharmony_ci	wrt_reg_dword(&reg->iobase_select, 0xB0400000);
17258c2ecf20Sopenharmony_ci	fw->shadow_reg[4] = htonl(rd_reg_dword(&reg->iobase_sdata));
17268c2ecf20Sopenharmony_ci
17278c2ecf20Sopenharmony_ci	wrt_reg_dword(&reg->iobase_select, 0xB0500000);
17288c2ecf20Sopenharmony_ci	fw->shadow_reg[5] = htonl(rd_reg_dword(&reg->iobase_sdata));
17298c2ecf20Sopenharmony_ci
17308c2ecf20Sopenharmony_ci	wrt_reg_dword(&reg->iobase_select, 0xB0600000);
17318c2ecf20Sopenharmony_ci	fw->shadow_reg[6] = htonl(rd_reg_dword(&reg->iobase_sdata));
17328c2ecf20Sopenharmony_ci
17338c2ecf20Sopenharmony_ci	wrt_reg_dword(&reg->iobase_select, 0xB0700000);
17348c2ecf20Sopenharmony_ci	fw->shadow_reg[7] = htonl(rd_reg_dword(&reg->iobase_sdata));
17358c2ecf20Sopenharmony_ci
17368c2ecf20Sopenharmony_ci	wrt_reg_dword(&reg->iobase_select, 0xB0800000);
17378c2ecf20Sopenharmony_ci	fw->shadow_reg[8] = htonl(rd_reg_dword(&reg->iobase_sdata));
17388c2ecf20Sopenharmony_ci
17398c2ecf20Sopenharmony_ci	wrt_reg_dword(&reg->iobase_select, 0xB0900000);
17408c2ecf20Sopenharmony_ci	fw->shadow_reg[9] = htonl(rd_reg_dword(&reg->iobase_sdata));
17418c2ecf20Sopenharmony_ci
17428c2ecf20Sopenharmony_ci	wrt_reg_dword(&reg->iobase_select, 0xB0A00000);
17438c2ecf20Sopenharmony_ci	fw->shadow_reg[10] = htonl(rd_reg_dword(&reg->iobase_sdata));
17448c2ecf20Sopenharmony_ci
17458c2ecf20Sopenharmony_ci	/* RISC I/O register. */
17468c2ecf20Sopenharmony_ci	wrt_reg_dword(&reg->iobase_addr, 0x0010);
17478c2ecf20Sopenharmony_ci	fw->risc_io_reg = htonl(rd_reg_dword(&reg->iobase_window));
17488c2ecf20Sopenharmony_ci
17498c2ecf20Sopenharmony_ci	/* Mailbox registers. */
17508c2ecf20Sopenharmony_ci	mbx_reg = &reg->mailbox0;
17518c2ecf20Sopenharmony_ci	for (cnt = 0; cnt < ARRAY_SIZE(fw->mailbox_reg); cnt++, mbx_reg++)
17528c2ecf20Sopenharmony_ci		fw->mailbox_reg[cnt] = htons(rd_reg_word(mbx_reg));
17538c2ecf20Sopenharmony_ci
17548c2ecf20Sopenharmony_ci	/* Transfer sequence registers. */
17558c2ecf20Sopenharmony_ci	iter_reg = fw->xseq_gp_reg;
17568c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0xBF00, 16, iter_reg);
17578c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0xBF10, 16, iter_reg);
17588c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0xBF20, 16, iter_reg);
17598c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0xBF30, 16, iter_reg);
17608c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0xBF40, 16, iter_reg);
17618c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0xBF50, 16, iter_reg);
17628c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0xBF60, 16, iter_reg);
17638c2ecf20Sopenharmony_ci	qla24xx_read_window(reg, 0xBF70, 16, iter_reg);
17648c2ecf20Sopenharmony_ci
17658c2ecf20Sopenharmony_ci	iter_reg = fw->xseq_0_reg;
17668c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0xBFC0, 16, iter_reg);
17678c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0xBFD0, 16, iter_reg);
17688c2ecf20Sopenharmony_ci	qla24xx_read_window(reg, 0xBFE0, 16, iter_reg);
17698c2ecf20Sopenharmony_ci
17708c2ecf20Sopenharmony_ci	qla24xx_read_window(reg, 0xBFF0, 16, fw->xseq_1_reg);
17718c2ecf20Sopenharmony_ci
17728c2ecf20Sopenharmony_ci	/* Receive sequence registers. */
17738c2ecf20Sopenharmony_ci	iter_reg = fw->rseq_gp_reg;
17748c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0xFF00, 16, iter_reg);
17758c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0xFF10, 16, iter_reg);
17768c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0xFF20, 16, iter_reg);
17778c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0xFF30, 16, iter_reg);
17788c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0xFF40, 16, iter_reg);
17798c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0xFF50, 16, iter_reg);
17808c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0xFF60, 16, iter_reg);
17818c2ecf20Sopenharmony_ci	qla24xx_read_window(reg, 0xFF70, 16, iter_reg);
17828c2ecf20Sopenharmony_ci
17838c2ecf20Sopenharmony_ci	iter_reg = fw->rseq_0_reg;
17848c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0xFFC0, 16, iter_reg);
17858c2ecf20Sopenharmony_ci	qla24xx_read_window(reg, 0xFFD0, 16, iter_reg);
17868c2ecf20Sopenharmony_ci
17878c2ecf20Sopenharmony_ci	qla24xx_read_window(reg, 0xFFE0, 16, fw->rseq_1_reg);
17888c2ecf20Sopenharmony_ci	qla24xx_read_window(reg, 0xFFF0, 16, fw->rseq_2_reg);
17898c2ecf20Sopenharmony_ci
17908c2ecf20Sopenharmony_ci	/* Auxiliary sequence registers. */
17918c2ecf20Sopenharmony_ci	iter_reg = fw->aseq_gp_reg;
17928c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0xB000, 16, iter_reg);
17938c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0xB010, 16, iter_reg);
17948c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0xB020, 16, iter_reg);
17958c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0xB030, 16, iter_reg);
17968c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0xB040, 16, iter_reg);
17978c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0xB050, 16, iter_reg);
17988c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0xB060, 16, iter_reg);
17998c2ecf20Sopenharmony_ci	qla24xx_read_window(reg, 0xB070, 16, iter_reg);
18008c2ecf20Sopenharmony_ci
18018c2ecf20Sopenharmony_ci	iter_reg = fw->aseq_0_reg;
18028c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0xB0C0, 16, iter_reg);
18038c2ecf20Sopenharmony_ci	qla24xx_read_window(reg, 0xB0D0, 16, iter_reg);
18048c2ecf20Sopenharmony_ci
18058c2ecf20Sopenharmony_ci	qla24xx_read_window(reg, 0xB0E0, 16, fw->aseq_1_reg);
18068c2ecf20Sopenharmony_ci	qla24xx_read_window(reg, 0xB0F0, 16, fw->aseq_2_reg);
18078c2ecf20Sopenharmony_ci
18088c2ecf20Sopenharmony_ci	/* Command DMA registers. */
18098c2ecf20Sopenharmony_ci	qla24xx_read_window(reg, 0x7100, 16, fw->cmd_dma_reg);
18108c2ecf20Sopenharmony_ci
18118c2ecf20Sopenharmony_ci	/* Queues. */
18128c2ecf20Sopenharmony_ci	iter_reg = fw->req0_dma_reg;
18138c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x7200, 8, iter_reg);
18148c2ecf20Sopenharmony_ci	dmp_reg = &reg->iobase_q;
18158c2ecf20Sopenharmony_ci	for (cnt = 0; cnt < 7; cnt++, dmp_reg++)
18168c2ecf20Sopenharmony_ci		*iter_reg++ = htonl(rd_reg_dword(dmp_reg));
18178c2ecf20Sopenharmony_ci
18188c2ecf20Sopenharmony_ci	iter_reg = fw->resp0_dma_reg;
18198c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x7300, 8, iter_reg);
18208c2ecf20Sopenharmony_ci	dmp_reg = &reg->iobase_q;
18218c2ecf20Sopenharmony_ci	for (cnt = 0; cnt < 7; cnt++, dmp_reg++)
18228c2ecf20Sopenharmony_ci		*iter_reg++ = htonl(rd_reg_dword(dmp_reg));
18238c2ecf20Sopenharmony_ci
18248c2ecf20Sopenharmony_ci	iter_reg = fw->req1_dma_reg;
18258c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x7400, 8, iter_reg);
18268c2ecf20Sopenharmony_ci	dmp_reg = &reg->iobase_q;
18278c2ecf20Sopenharmony_ci	for (cnt = 0; cnt < 7; cnt++, dmp_reg++)
18288c2ecf20Sopenharmony_ci		*iter_reg++ = htonl(rd_reg_dword(dmp_reg));
18298c2ecf20Sopenharmony_ci
18308c2ecf20Sopenharmony_ci	/* Transmit DMA registers. */
18318c2ecf20Sopenharmony_ci	iter_reg = fw->xmt0_dma_reg;
18328c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x7600, 16, iter_reg);
18338c2ecf20Sopenharmony_ci	qla24xx_read_window(reg, 0x7610, 16, iter_reg);
18348c2ecf20Sopenharmony_ci
18358c2ecf20Sopenharmony_ci	iter_reg = fw->xmt1_dma_reg;
18368c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x7620, 16, iter_reg);
18378c2ecf20Sopenharmony_ci	qla24xx_read_window(reg, 0x7630, 16, iter_reg);
18388c2ecf20Sopenharmony_ci
18398c2ecf20Sopenharmony_ci	iter_reg = fw->xmt2_dma_reg;
18408c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x7640, 16, iter_reg);
18418c2ecf20Sopenharmony_ci	qla24xx_read_window(reg, 0x7650, 16, iter_reg);
18428c2ecf20Sopenharmony_ci
18438c2ecf20Sopenharmony_ci	iter_reg = fw->xmt3_dma_reg;
18448c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x7660, 16, iter_reg);
18458c2ecf20Sopenharmony_ci	qla24xx_read_window(reg, 0x7670, 16, iter_reg);
18468c2ecf20Sopenharmony_ci
18478c2ecf20Sopenharmony_ci	iter_reg = fw->xmt4_dma_reg;
18488c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x7680, 16, iter_reg);
18498c2ecf20Sopenharmony_ci	qla24xx_read_window(reg, 0x7690, 16, iter_reg);
18508c2ecf20Sopenharmony_ci
18518c2ecf20Sopenharmony_ci	qla24xx_read_window(reg, 0x76A0, 16, fw->xmt_data_dma_reg);
18528c2ecf20Sopenharmony_ci
18538c2ecf20Sopenharmony_ci	/* Receive DMA registers. */
18548c2ecf20Sopenharmony_ci	iter_reg = fw->rcvt0_data_dma_reg;
18558c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x7700, 16, iter_reg);
18568c2ecf20Sopenharmony_ci	qla24xx_read_window(reg, 0x7710, 16, iter_reg);
18578c2ecf20Sopenharmony_ci
18588c2ecf20Sopenharmony_ci	iter_reg = fw->rcvt1_data_dma_reg;
18598c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x7720, 16, iter_reg);
18608c2ecf20Sopenharmony_ci	qla24xx_read_window(reg, 0x7730, 16, iter_reg);
18618c2ecf20Sopenharmony_ci
18628c2ecf20Sopenharmony_ci	/* RISC registers. */
18638c2ecf20Sopenharmony_ci	iter_reg = fw->risc_gp_reg;
18648c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x0F00, 16, iter_reg);
18658c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x0F10, 16, iter_reg);
18668c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x0F20, 16, iter_reg);
18678c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x0F30, 16, iter_reg);
18688c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x0F40, 16, iter_reg);
18698c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x0F50, 16, iter_reg);
18708c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x0F60, 16, iter_reg);
18718c2ecf20Sopenharmony_ci	qla24xx_read_window(reg, 0x0F70, 16, iter_reg);
18728c2ecf20Sopenharmony_ci
18738c2ecf20Sopenharmony_ci	/* Local memory controller registers. */
18748c2ecf20Sopenharmony_ci	iter_reg = fw->lmc_reg;
18758c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x3000, 16, iter_reg);
18768c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x3010, 16, iter_reg);
18778c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x3020, 16, iter_reg);
18788c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x3030, 16, iter_reg);
18798c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x3040, 16, iter_reg);
18808c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x3050, 16, iter_reg);
18818c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x3060, 16, iter_reg);
18828c2ecf20Sopenharmony_ci	qla24xx_read_window(reg, 0x3070, 16, iter_reg);
18838c2ecf20Sopenharmony_ci
18848c2ecf20Sopenharmony_ci	/* Fibre Protocol Module registers. */
18858c2ecf20Sopenharmony_ci	iter_reg = fw->fpm_hdw_reg;
18868c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x4000, 16, iter_reg);
18878c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x4010, 16, iter_reg);
18888c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x4020, 16, iter_reg);
18898c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x4030, 16, iter_reg);
18908c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x4040, 16, iter_reg);
18918c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x4050, 16, iter_reg);
18928c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x4060, 16, iter_reg);
18938c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x4070, 16, iter_reg);
18948c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x4080, 16, iter_reg);
18958c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x4090, 16, iter_reg);
18968c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x40A0, 16, iter_reg);
18978c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x40B0, 16, iter_reg);
18988c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x40C0, 16, iter_reg);
18998c2ecf20Sopenharmony_ci	qla24xx_read_window(reg, 0x40D0, 16, iter_reg);
19008c2ecf20Sopenharmony_ci
19018c2ecf20Sopenharmony_ci	/* Frame Buffer registers. */
19028c2ecf20Sopenharmony_ci	iter_reg = fw->fb_hdw_reg;
19038c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x6000, 16, iter_reg);
19048c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x6010, 16, iter_reg);
19058c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x6020, 16, iter_reg);
19068c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x6030, 16, iter_reg);
19078c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x6040, 16, iter_reg);
19088c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x6100, 16, iter_reg);
19098c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x6130, 16, iter_reg);
19108c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x6150, 16, iter_reg);
19118c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x6170, 16, iter_reg);
19128c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x6190, 16, iter_reg);
19138c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x61B0, 16, iter_reg);
19148c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x61C0, 16, iter_reg);
19158c2ecf20Sopenharmony_ci	qla24xx_read_window(reg, 0x6F00, 16, iter_reg);
19168c2ecf20Sopenharmony_ci
19178c2ecf20Sopenharmony_ci	/* Multi queue registers */
19188c2ecf20Sopenharmony_ci	nxt_chain = qla25xx_copy_mq(ha, (void *)ha->fw_dump + ha->chain_offset,
19198c2ecf20Sopenharmony_ci	    &last_chain);
19208c2ecf20Sopenharmony_ci
19218c2ecf20Sopenharmony_ci	rval = qla24xx_soft_reset(ha);
19228c2ecf20Sopenharmony_ci	if (rval != QLA_SUCCESS)
19238c2ecf20Sopenharmony_ci		goto qla81xx_fw_dump_failed_0;
19248c2ecf20Sopenharmony_ci
19258c2ecf20Sopenharmony_ci	rval = qla24xx_dump_memory(ha, fw->code_ram, sizeof(fw->code_ram),
19268c2ecf20Sopenharmony_ci	    &nxt);
19278c2ecf20Sopenharmony_ci	if (rval != QLA_SUCCESS)
19288c2ecf20Sopenharmony_ci		goto qla81xx_fw_dump_failed_0;
19298c2ecf20Sopenharmony_ci
19308c2ecf20Sopenharmony_ci	nxt = qla2xxx_copy_queues(ha, nxt);
19318c2ecf20Sopenharmony_ci
19328c2ecf20Sopenharmony_ci	qla24xx_copy_eft(ha, nxt);
19338c2ecf20Sopenharmony_ci
19348c2ecf20Sopenharmony_ci	/* Chain entries -- started with MQ. */
19358c2ecf20Sopenharmony_ci	nxt_chain = qla25xx_copy_fce(ha, nxt_chain, &last_chain);
19368c2ecf20Sopenharmony_ci	nxt_chain = qla25xx_copy_mqueues(ha, nxt_chain, &last_chain);
19378c2ecf20Sopenharmony_ci	nxt_chain = qla2xxx_copy_atioqueues(ha, nxt_chain, &last_chain);
19388c2ecf20Sopenharmony_ci	nxt_chain = qla25xx_copy_exlogin(ha, nxt_chain, &last_chain);
19398c2ecf20Sopenharmony_ci	nxt_chain = qla81xx_copy_exchoffld(ha, nxt_chain, &last_chain);
19408c2ecf20Sopenharmony_ci	if (last_chain) {
19418c2ecf20Sopenharmony_ci		ha->fw_dump->version |= htonl(DUMP_CHAIN_VARIANT);
19428c2ecf20Sopenharmony_ci		*last_chain |= htonl(DUMP_CHAIN_LAST);
19438c2ecf20Sopenharmony_ci	}
19448c2ecf20Sopenharmony_ci
19458c2ecf20Sopenharmony_ci	/* Adjust valid length. */
19468c2ecf20Sopenharmony_ci	ha->fw_dump_len = (nxt_chain - (void *)ha->fw_dump);
19478c2ecf20Sopenharmony_ci
19488c2ecf20Sopenharmony_ciqla81xx_fw_dump_failed_0:
19498c2ecf20Sopenharmony_ci	qla2xxx_dump_post_process(base_vha, rval);
19508c2ecf20Sopenharmony_ci}
19518c2ecf20Sopenharmony_ci
19528c2ecf20Sopenharmony_civoid
19538c2ecf20Sopenharmony_ciqla83xx_fw_dump(scsi_qla_host_t *vha)
19548c2ecf20Sopenharmony_ci{
19558c2ecf20Sopenharmony_ci	int		rval;
19568c2ecf20Sopenharmony_ci	uint32_t	cnt;
19578c2ecf20Sopenharmony_ci	struct qla_hw_data *ha = vha->hw;
19588c2ecf20Sopenharmony_ci	struct device_reg_24xx __iomem *reg = &ha->iobase->isp24;
19598c2ecf20Sopenharmony_ci	__le32 __iomem *dmp_reg;
19608c2ecf20Sopenharmony_ci	__be32		*iter_reg;
19618c2ecf20Sopenharmony_ci	__le16 __iomem *mbx_reg;
19628c2ecf20Sopenharmony_ci	struct qla83xx_fw_dump *fw;
19638c2ecf20Sopenharmony_ci	void		*nxt, *nxt_chain;
19648c2ecf20Sopenharmony_ci	__be32		*last_chain = NULL;
19658c2ecf20Sopenharmony_ci	struct scsi_qla_host *base_vha = pci_get_drvdata(ha->pdev);
19668c2ecf20Sopenharmony_ci
19678c2ecf20Sopenharmony_ci	lockdep_assert_held(&ha->hardware_lock);
19688c2ecf20Sopenharmony_ci
19698c2ecf20Sopenharmony_ci	ha->fw_dump_cap_flags = 0;
19708c2ecf20Sopenharmony_ci
19718c2ecf20Sopenharmony_ci	if (!ha->fw_dump) {
19728c2ecf20Sopenharmony_ci		ql_log(ql_log_warn, vha, 0xd00c,
19738c2ecf20Sopenharmony_ci		    "No buffer available for dump!!!\n");
19748c2ecf20Sopenharmony_ci		return;
19758c2ecf20Sopenharmony_ci	}
19768c2ecf20Sopenharmony_ci
19778c2ecf20Sopenharmony_ci	if (ha->fw_dumped) {
19788c2ecf20Sopenharmony_ci		ql_log(ql_log_warn, vha, 0xd00d,
19798c2ecf20Sopenharmony_ci		    "Firmware has been previously dumped (%p) -- ignoring "
19808c2ecf20Sopenharmony_ci		    "request...\n", ha->fw_dump);
19818c2ecf20Sopenharmony_ci		return;
19828c2ecf20Sopenharmony_ci	}
19838c2ecf20Sopenharmony_ci	QLA_FW_STOPPED(ha);
19848c2ecf20Sopenharmony_ci	fw = &ha->fw_dump->isp.isp83;
19858c2ecf20Sopenharmony_ci	qla2xxx_prep_dump(ha, ha->fw_dump);
19868c2ecf20Sopenharmony_ci
19878c2ecf20Sopenharmony_ci	fw->host_status = htonl(rd_reg_dword(&reg->host_status));
19888c2ecf20Sopenharmony_ci
19898c2ecf20Sopenharmony_ci	/*
19908c2ecf20Sopenharmony_ci	 * Pause RISC. No need to track timeout, as resetting the chip
19918c2ecf20Sopenharmony_ci	 * is the right approach incase of pause timeout
19928c2ecf20Sopenharmony_ci	 */
19938c2ecf20Sopenharmony_ci	qla24xx_pause_risc(reg, ha);
19948c2ecf20Sopenharmony_ci
19958c2ecf20Sopenharmony_ci	wrt_reg_dword(&reg->iobase_addr, 0x6000);
19968c2ecf20Sopenharmony_ci	dmp_reg = &reg->iobase_window;
19978c2ecf20Sopenharmony_ci	rd_reg_dword(dmp_reg);
19988c2ecf20Sopenharmony_ci	wrt_reg_dword(dmp_reg, 0);
19998c2ecf20Sopenharmony_ci
20008c2ecf20Sopenharmony_ci	dmp_reg = &reg->unused_4_1[0];
20018c2ecf20Sopenharmony_ci	rd_reg_dword(dmp_reg);
20028c2ecf20Sopenharmony_ci	wrt_reg_dword(dmp_reg, 0);
20038c2ecf20Sopenharmony_ci
20048c2ecf20Sopenharmony_ci	wrt_reg_dword(&reg->iobase_addr, 0x6010);
20058c2ecf20Sopenharmony_ci	dmp_reg = &reg->unused_4_1[2];
20068c2ecf20Sopenharmony_ci	rd_reg_dword(dmp_reg);
20078c2ecf20Sopenharmony_ci	wrt_reg_dword(dmp_reg, 0);
20088c2ecf20Sopenharmony_ci
20098c2ecf20Sopenharmony_ci	/* select PCR and disable ecc checking and correction */
20108c2ecf20Sopenharmony_ci	wrt_reg_dword(&reg->iobase_addr, 0x0F70);
20118c2ecf20Sopenharmony_ci	rd_reg_dword(&reg->iobase_addr);
20128c2ecf20Sopenharmony_ci	wrt_reg_dword(&reg->iobase_select, 0x60000000);	/* write to F0h = PCR */
20138c2ecf20Sopenharmony_ci
20148c2ecf20Sopenharmony_ci	/* Host/Risc registers. */
20158c2ecf20Sopenharmony_ci	iter_reg = fw->host_risc_reg;
20168c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x7000, 16, iter_reg);
20178c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x7010, 16, iter_reg);
20188c2ecf20Sopenharmony_ci	qla24xx_read_window(reg, 0x7040, 16, iter_reg);
20198c2ecf20Sopenharmony_ci
20208c2ecf20Sopenharmony_ci	/* PCIe registers. */
20218c2ecf20Sopenharmony_ci	wrt_reg_dword(&reg->iobase_addr, 0x7C00);
20228c2ecf20Sopenharmony_ci	rd_reg_dword(&reg->iobase_addr);
20238c2ecf20Sopenharmony_ci	wrt_reg_dword(&reg->iobase_window, 0x01);
20248c2ecf20Sopenharmony_ci	dmp_reg = &reg->iobase_c4;
20258c2ecf20Sopenharmony_ci	fw->pcie_regs[0] = htonl(rd_reg_dword(dmp_reg));
20268c2ecf20Sopenharmony_ci	dmp_reg++;
20278c2ecf20Sopenharmony_ci	fw->pcie_regs[1] = htonl(rd_reg_dword(dmp_reg));
20288c2ecf20Sopenharmony_ci	dmp_reg++;
20298c2ecf20Sopenharmony_ci	fw->pcie_regs[2] = htonl(rd_reg_dword(dmp_reg));
20308c2ecf20Sopenharmony_ci	fw->pcie_regs[3] = htonl(rd_reg_dword(&reg->iobase_window));
20318c2ecf20Sopenharmony_ci
20328c2ecf20Sopenharmony_ci	wrt_reg_dword(&reg->iobase_window, 0x00);
20338c2ecf20Sopenharmony_ci	rd_reg_dword(&reg->iobase_window);
20348c2ecf20Sopenharmony_ci
20358c2ecf20Sopenharmony_ci	/* Host interface registers. */
20368c2ecf20Sopenharmony_ci	dmp_reg = &reg->flash_addr;
20378c2ecf20Sopenharmony_ci	for (cnt = 0; cnt < ARRAY_SIZE(fw->host_reg); cnt++, dmp_reg++)
20388c2ecf20Sopenharmony_ci		fw->host_reg[cnt] = htonl(rd_reg_dword(dmp_reg));
20398c2ecf20Sopenharmony_ci
20408c2ecf20Sopenharmony_ci	/* Disable interrupts. */
20418c2ecf20Sopenharmony_ci	wrt_reg_dword(&reg->ictrl, 0);
20428c2ecf20Sopenharmony_ci	rd_reg_dword(&reg->ictrl);
20438c2ecf20Sopenharmony_ci
20448c2ecf20Sopenharmony_ci	/* Shadow registers. */
20458c2ecf20Sopenharmony_ci	wrt_reg_dword(&reg->iobase_addr, 0x0F70);
20468c2ecf20Sopenharmony_ci	rd_reg_dword(&reg->iobase_addr);
20478c2ecf20Sopenharmony_ci	wrt_reg_dword(&reg->iobase_select, 0xB0000000);
20488c2ecf20Sopenharmony_ci	fw->shadow_reg[0] = htonl(rd_reg_dword(&reg->iobase_sdata));
20498c2ecf20Sopenharmony_ci
20508c2ecf20Sopenharmony_ci	wrt_reg_dword(&reg->iobase_select, 0xB0100000);
20518c2ecf20Sopenharmony_ci	fw->shadow_reg[1] = htonl(rd_reg_dword(&reg->iobase_sdata));
20528c2ecf20Sopenharmony_ci
20538c2ecf20Sopenharmony_ci	wrt_reg_dword(&reg->iobase_select, 0xB0200000);
20548c2ecf20Sopenharmony_ci	fw->shadow_reg[2] = htonl(rd_reg_dword(&reg->iobase_sdata));
20558c2ecf20Sopenharmony_ci
20568c2ecf20Sopenharmony_ci	wrt_reg_dword(&reg->iobase_select, 0xB0300000);
20578c2ecf20Sopenharmony_ci	fw->shadow_reg[3] = htonl(rd_reg_dword(&reg->iobase_sdata));
20588c2ecf20Sopenharmony_ci
20598c2ecf20Sopenharmony_ci	wrt_reg_dword(&reg->iobase_select, 0xB0400000);
20608c2ecf20Sopenharmony_ci	fw->shadow_reg[4] = htonl(rd_reg_dword(&reg->iobase_sdata));
20618c2ecf20Sopenharmony_ci
20628c2ecf20Sopenharmony_ci	wrt_reg_dword(&reg->iobase_select, 0xB0500000);
20638c2ecf20Sopenharmony_ci	fw->shadow_reg[5] = htonl(rd_reg_dword(&reg->iobase_sdata));
20648c2ecf20Sopenharmony_ci
20658c2ecf20Sopenharmony_ci	wrt_reg_dword(&reg->iobase_select, 0xB0600000);
20668c2ecf20Sopenharmony_ci	fw->shadow_reg[6] = htonl(rd_reg_dword(&reg->iobase_sdata));
20678c2ecf20Sopenharmony_ci
20688c2ecf20Sopenharmony_ci	wrt_reg_dword(&reg->iobase_select, 0xB0700000);
20698c2ecf20Sopenharmony_ci	fw->shadow_reg[7] = htonl(rd_reg_dword(&reg->iobase_sdata));
20708c2ecf20Sopenharmony_ci
20718c2ecf20Sopenharmony_ci	wrt_reg_dword(&reg->iobase_select, 0xB0800000);
20728c2ecf20Sopenharmony_ci	fw->shadow_reg[8] = htonl(rd_reg_dword(&reg->iobase_sdata));
20738c2ecf20Sopenharmony_ci
20748c2ecf20Sopenharmony_ci	wrt_reg_dword(&reg->iobase_select, 0xB0900000);
20758c2ecf20Sopenharmony_ci	fw->shadow_reg[9] = htonl(rd_reg_dword(&reg->iobase_sdata));
20768c2ecf20Sopenharmony_ci
20778c2ecf20Sopenharmony_ci	wrt_reg_dword(&reg->iobase_select, 0xB0A00000);
20788c2ecf20Sopenharmony_ci	fw->shadow_reg[10] = htonl(rd_reg_dword(&reg->iobase_sdata));
20798c2ecf20Sopenharmony_ci
20808c2ecf20Sopenharmony_ci	/* RISC I/O register. */
20818c2ecf20Sopenharmony_ci	wrt_reg_dword(&reg->iobase_addr, 0x0010);
20828c2ecf20Sopenharmony_ci	fw->risc_io_reg = htonl(rd_reg_dword(&reg->iobase_window));
20838c2ecf20Sopenharmony_ci
20848c2ecf20Sopenharmony_ci	/* Mailbox registers. */
20858c2ecf20Sopenharmony_ci	mbx_reg = &reg->mailbox0;
20868c2ecf20Sopenharmony_ci	for (cnt = 0; cnt < ARRAY_SIZE(fw->mailbox_reg); cnt++, mbx_reg++)
20878c2ecf20Sopenharmony_ci		fw->mailbox_reg[cnt] = htons(rd_reg_word(mbx_reg));
20888c2ecf20Sopenharmony_ci
20898c2ecf20Sopenharmony_ci	/* Transfer sequence registers. */
20908c2ecf20Sopenharmony_ci	iter_reg = fw->xseq_gp_reg;
20918c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0xBE00, 16, iter_reg);
20928c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0xBE10, 16, iter_reg);
20938c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0xBE20, 16, iter_reg);
20948c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0xBE30, 16, iter_reg);
20958c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0xBE40, 16, iter_reg);
20968c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0xBE50, 16, iter_reg);
20978c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0xBE60, 16, iter_reg);
20988c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0xBE70, 16, iter_reg);
20998c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0xBF00, 16, iter_reg);
21008c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0xBF10, 16, iter_reg);
21018c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0xBF20, 16, iter_reg);
21028c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0xBF30, 16, iter_reg);
21038c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0xBF40, 16, iter_reg);
21048c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0xBF50, 16, iter_reg);
21058c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0xBF60, 16, iter_reg);
21068c2ecf20Sopenharmony_ci	qla24xx_read_window(reg, 0xBF70, 16, iter_reg);
21078c2ecf20Sopenharmony_ci
21088c2ecf20Sopenharmony_ci	iter_reg = fw->xseq_0_reg;
21098c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0xBFC0, 16, iter_reg);
21108c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0xBFD0, 16, iter_reg);
21118c2ecf20Sopenharmony_ci	qla24xx_read_window(reg, 0xBFE0, 16, iter_reg);
21128c2ecf20Sopenharmony_ci
21138c2ecf20Sopenharmony_ci	qla24xx_read_window(reg, 0xBFF0, 16, fw->xseq_1_reg);
21148c2ecf20Sopenharmony_ci
21158c2ecf20Sopenharmony_ci	qla24xx_read_window(reg, 0xBEF0, 16, fw->xseq_2_reg);
21168c2ecf20Sopenharmony_ci
21178c2ecf20Sopenharmony_ci	/* Receive sequence registers. */
21188c2ecf20Sopenharmony_ci	iter_reg = fw->rseq_gp_reg;
21198c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0xFE00, 16, iter_reg);
21208c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0xFE10, 16, iter_reg);
21218c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0xFE20, 16, iter_reg);
21228c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0xFE30, 16, iter_reg);
21238c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0xFE40, 16, iter_reg);
21248c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0xFE50, 16, iter_reg);
21258c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0xFE60, 16, iter_reg);
21268c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0xFE70, 16, iter_reg);
21278c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0xFF00, 16, iter_reg);
21288c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0xFF10, 16, iter_reg);
21298c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0xFF20, 16, iter_reg);
21308c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0xFF30, 16, iter_reg);
21318c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0xFF40, 16, iter_reg);
21328c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0xFF50, 16, iter_reg);
21338c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0xFF60, 16, iter_reg);
21348c2ecf20Sopenharmony_ci	qla24xx_read_window(reg, 0xFF70, 16, iter_reg);
21358c2ecf20Sopenharmony_ci
21368c2ecf20Sopenharmony_ci	iter_reg = fw->rseq_0_reg;
21378c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0xFFC0, 16, iter_reg);
21388c2ecf20Sopenharmony_ci	qla24xx_read_window(reg, 0xFFD0, 16, iter_reg);
21398c2ecf20Sopenharmony_ci
21408c2ecf20Sopenharmony_ci	qla24xx_read_window(reg, 0xFFE0, 16, fw->rseq_1_reg);
21418c2ecf20Sopenharmony_ci	qla24xx_read_window(reg, 0xFFF0, 16, fw->rseq_2_reg);
21428c2ecf20Sopenharmony_ci	qla24xx_read_window(reg, 0xFEF0, 16, fw->rseq_3_reg);
21438c2ecf20Sopenharmony_ci
21448c2ecf20Sopenharmony_ci	/* Auxiliary sequence registers. */
21458c2ecf20Sopenharmony_ci	iter_reg = fw->aseq_gp_reg;
21468c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0xB000, 16, iter_reg);
21478c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0xB010, 16, iter_reg);
21488c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0xB020, 16, iter_reg);
21498c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0xB030, 16, iter_reg);
21508c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0xB040, 16, iter_reg);
21518c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0xB050, 16, iter_reg);
21528c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0xB060, 16, iter_reg);
21538c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0xB070, 16, iter_reg);
21548c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0xB100, 16, iter_reg);
21558c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0xB110, 16, iter_reg);
21568c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0xB120, 16, iter_reg);
21578c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0xB130, 16, iter_reg);
21588c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0xB140, 16, iter_reg);
21598c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0xB150, 16, iter_reg);
21608c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0xB160, 16, iter_reg);
21618c2ecf20Sopenharmony_ci	qla24xx_read_window(reg, 0xB170, 16, iter_reg);
21628c2ecf20Sopenharmony_ci
21638c2ecf20Sopenharmony_ci	iter_reg = fw->aseq_0_reg;
21648c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0xB0C0, 16, iter_reg);
21658c2ecf20Sopenharmony_ci	qla24xx_read_window(reg, 0xB0D0, 16, iter_reg);
21668c2ecf20Sopenharmony_ci
21678c2ecf20Sopenharmony_ci	qla24xx_read_window(reg, 0xB0E0, 16, fw->aseq_1_reg);
21688c2ecf20Sopenharmony_ci	qla24xx_read_window(reg, 0xB0F0, 16, fw->aseq_2_reg);
21698c2ecf20Sopenharmony_ci	qla24xx_read_window(reg, 0xB1F0, 16, fw->aseq_3_reg);
21708c2ecf20Sopenharmony_ci
21718c2ecf20Sopenharmony_ci	/* Command DMA registers. */
21728c2ecf20Sopenharmony_ci	iter_reg = fw->cmd_dma_reg;
21738c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x7100, 16, iter_reg);
21748c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x7120, 16, iter_reg);
21758c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x7130, 16, iter_reg);
21768c2ecf20Sopenharmony_ci	qla24xx_read_window(reg, 0x71F0, 16, iter_reg);
21778c2ecf20Sopenharmony_ci
21788c2ecf20Sopenharmony_ci	/* Queues. */
21798c2ecf20Sopenharmony_ci	iter_reg = fw->req0_dma_reg;
21808c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x7200, 8, iter_reg);
21818c2ecf20Sopenharmony_ci	dmp_reg = &reg->iobase_q;
21828c2ecf20Sopenharmony_ci	for (cnt = 0; cnt < 7; cnt++, dmp_reg++)
21838c2ecf20Sopenharmony_ci		*iter_reg++ = htonl(rd_reg_dword(dmp_reg));
21848c2ecf20Sopenharmony_ci
21858c2ecf20Sopenharmony_ci	iter_reg = fw->resp0_dma_reg;
21868c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x7300, 8, iter_reg);
21878c2ecf20Sopenharmony_ci	dmp_reg = &reg->iobase_q;
21888c2ecf20Sopenharmony_ci	for (cnt = 0; cnt < 7; cnt++, dmp_reg++)
21898c2ecf20Sopenharmony_ci		*iter_reg++ = htonl(rd_reg_dword(dmp_reg));
21908c2ecf20Sopenharmony_ci
21918c2ecf20Sopenharmony_ci	iter_reg = fw->req1_dma_reg;
21928c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x7400, 8, iter_reg);
21938c2ecf20Sopenharmony_ci	dmp_reg = &reg->iobase_q;
21948c2ecf20Sopenharmony_ci	for (cnt = 0; cnt < 7; cnt++, dmp_reg++)
21958c2ecf20Sopenharmony_ci		*iter_reg++ = htonl(rd_reg_dword(dmp_reg));
21968c2ecf20Sopenharmony_ci
21978c2ecf20Sopenharmony_ci	/* Transmit DMA registers. */
21988c2ecf20Sopenharmony_ci	iter_reg = fw->xmt0_dma_reg;
21998c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x7600, 16, iter_reg);
22008c2ecf20Sopenharmony_ci	qla24xx_read_window(reg, 0x7610, 16, iter_reg);
22018c2ecf20Sopenharmony_ci
22028c2ecf20Sopenharmony_ci	iter_reg = fw->xmt1_dma_reg;
22038c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x7620, 16, iter_reg);
22048c2ecf20Sopenharmony_ci	qla24xx_read_window(reg, 0x7630, 16, iter_reg);
22058c2ecf20Sopenharmony_ci
22068c2ecf20Sopenharmony_ci	iter_reg = fw->xmt2_dma_reg;
22078c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x7640, 16, iter_reg);
22088c2ecf20Sopenharmony_ci	qla24xx_read_window(reg, 0x7650, 16, iter_reg);
22098c2ecf20Sopenharmony_ci
22108c2ecf20Sopenharmony_ci	iter_reg = fw->xmt3_dma_reg;
22118c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x7660, 16, iter_reg);
22128c2ecf20Sopenharmony_ci	qla24xx_read_window(reg, 0x7670, 16, iter_reg);
22138c2ecf20Sopenharmony_ci
22148c2ecf20Sopenharmony_ci	iter_reg = fw->xmt4_dma_reg;
22158c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x7680, 16, iter_reg);
22168c2ecf20Sopenharmony_ci	qla24xx_read_window(reg, 0x7690, 16, iter_reg);
22178c2ecf20Sopenharmony_ci
22188c2ecf20Sopenharmony_ci	qla24xx_read_window(reg, 0x76A0, 16, fw->xmt_data_dma_reg);
22198c2ecf20Sopenharmony_ci
22208c2ecf20Sopenharmony_ci	/* Receive DMA registers. */
22218c2ecf20Sopenharmony_ci	iter_reg = fw->rcvt0_data_dma_reg;
22228c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x7700, 16, iter_reg);
22238c2ecf20Sopenharmony_ci	qla24xx_read_window(reg, 0x7710, 16, iter_reg);
22248c2ecf20Sopenharmony_ci
22258c2ecf20Sopenharmony_ci	iter_reg = fw->rcvt1_data_dma_reg;
22268c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x7720, 16, iter_reg);
22278c2ecf20Sopenharmony_ci	qla24xx_read_window(reg, 0x7730, 16, iter_reg);
22288c2ecf20Sopenharmony_ci
22298c2ecf20Sopenharmony_ci	/* RISC registers. */
22308c2ecf20Sopenharmony_ci	iter_reg = fw->risc_gp_reg;
22318c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x0F00, 16, iter_reg);
22328c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x0F10, 16, iter_reg);
22338c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x0F20, 16, iter_reg);
22348c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x0F30, 16, iter_reg);
22358c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x0F40, 16, iter_reg);
22368c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x0F50, 16, iter_reg);
22378c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x0F60, 16, iter_reg);
22388c2ecf20Sopenharmony_ci	qla24xx_read_window(reg, 0x0F70, 16, iter_reg);
22398c2ecf20Sopenharmony_ci
22408c2ecf20Sopenharmony_ci	/* Local memory controller registers. */
22418c2ecf20Sopenharmony_ci	iter_reg = fw->lmc_reg;
22428c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x3000, 16, iter_reg);
22438c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x3010, 16, iter_reg);
22448c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x3020, 16, iter_reg);
22458c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x3030, 16, iter_reg);
22468c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x3040, 16, iter_reg);
22478c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x3050, 16, iter_reg);
22488c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x3060, 16, iter_reg);
22498c2ecf20Sopenharmony_ci	qla24xx_read_window(reg, 0x3070, 16, iter_reg);
22508c2ecf20Sopenharmony_ci
22518c2ecf20Sopenharmony_ci	/* Fibre Protocol Module registers. */
22528c2ecf20Sopenharmony_ci	iter_reg = fw->fpm_hdw_reg;
22538c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x4000, 16, iter_reg);
22548c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x4010, 16, iter_reg);
22558c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x4020, 16, iter_reg);
22568c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x4030, 16, iter_reg);
22578c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x4040, 16, iter_reg);
22588c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x4050, 16, iter_reg);
22598c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x4060, 16, iter_reg);
22608c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x4070, 16, iter_reg);
22618c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x4080, 16, iter_reg);
22628c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x4090, 16, iter_reg);
22638c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x40A0, 16, iter_reg);
22648c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x40B0, 16, iter_reg);
22658c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x40C0, 16, iter_reg);
22668c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x40D0, 16, iter_reg);
22678c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x40E0, 16, iter_reg);
22688c2ecf20Sopenharmony_ci	qla24xx_read_window(reg, 0x40F0, 16, iter_reg);
22698c2ecf20Sopenharmony_ci
22708c2ecf20Sopenharmony_ci	/* RQ0 Array registers. */
22718c2ecf20Sopenharmony_ci	iter_reg = fw->rq0_array_reg;
22728c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x5C00, 16, iter_reg);
22738c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x5C10, 16, iter_reg);
22748c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x5C20, 16, iter_reg);
22758c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x5C30, 16, iter_reg);
22768c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x5C40, 16, iter_reg);
22778c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x5C50, 16, iter_reg);
22788c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x5C60, 16, iter_reg);
22798c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x5C70, 16, iter_reg);
22808c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x5C80, 16, iter_reg);
22818c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x5C90, 16, iter_reg);
22828c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x5CA0, 16, iter_reg);
22838c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x5CB0, 16, iter_reg);
22848c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x5CC0, 16, iter_reg);
22858c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x5CD0, 16, iter_reg);
22868c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x5CE0, 16, iter_reg);
22878c2ecf20Sopenharmony_ci	qla24xx_read_window(reg, 0x5CF0, 16, iter_reg);
22888c2ecf20Sopenharmony_ci
22898c2ecf20Sopenharmony_ci	/* RQ1 Array registers. */
22908c2ecf20Sopenharmony_ci	iter_reg = fw->rq1_array_reg;
22918c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x5D00, 16, iter_reg);
22928c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x5D10, 16, iter_reg);
22938c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x5D20, 16, iter_reg);
22948c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x5D30, 16, iter_reg);
22958c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x5D40, 16, iter_reg);
22968c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x5D50, 16, iter_reg);
22978c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x5D60, 16, iter_reg);
22988c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x5D70, 16, iter_reg);
22998c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x5D80, 16, iter_reg);
23008c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x5D90, 16, iter_reg);
23018c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x5DA0, 16, iter_reg);
23028c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x5DB0, 16, iter_reg);
23038c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x5DC0, 16, iter_reg);
23048c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x5DD0, 16, iter_reg);
23058c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x5DE0, 16, iter_reg);
23068c2ecf20Sopenharmony_ci	qla24xx_read_window(reg, 0x5DF0, 16, iter_reg);
23078c2ecf20Sopenharmony_ci
23088c2ecf20Sopenharmony_ci	/* RP0 Array registers. */
23098c2ecf20Sopenharmony_ci	iter_reg = fw->rp0_array_reg;
23108c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x5E00, 16, iter_reg);
23118c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x5E10, 16, iter_reg);
23128c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x5E20, 16, iter_reg);
23138c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x5E30, 16, iter_reg);
23148c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x5E40, 16, iter_reg);
23158c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x5E50, 16, iter_reg);
23168c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x5E60, 16, iter_reg);
23178c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x5E70, 16, iter_reg);
23188c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x5E80, 16, iter_reg);
23198c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x5E90, 16, iter_reg);
23208c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x5EA0, 16, iter_reg);
23218c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x5EB0, 16, iter_reg);
23228c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x5EC0, 16, iter_reg);
23238c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x5ED0, 16, iter_reg);
23248c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x5EE0, 16, iter_reg);
23258c2ecf20Sopenharmony_ci	qla24xx_read_window(reg, 0x5EF0, 16, iter_reg);
23268c2ecf20Sopenharmony_ci
23278c2ecf20Sopenharmony_ci	/* RP1 Array registers. */
23288c2ecf20Sopenharmony_ci	iter_reg = fw->rp1_array_reg;
23298c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x5F00, 16, iter_reg);
23308c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x5F10, 16, iter_reg);
23318c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x5F20, 16, iter_reg);
23328c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x5F30, 16, iter_reg);
23338c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x5F40, 16, iter_reg);
23348c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x5F50, 16, iter_reg);
23358c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x5F60, 16, iter_reg);
23368c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x5F70, 16, iter_reg);
23378c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x5F80, 16, iter_reg);
23388c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x5F90, 16, iter_reg);
23398c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x5FA0, 16, iter_reg);
23408c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x5FB0, 16, iter_reg);
23418c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x5FC0, 16, iter_reg);
23428c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x5FD0, 16, iter_reg);
23438c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x5FE0, 16, iter_reg);
23448c2ecf20Sopenharmony_ci	qla24xx_read_window(reg, 0x5FF0, 16, iter_reg);
23458c2ecf20Sopenharmony_ci
23468c2ecf20Sopenharmony_ci	iter_reg = fw->at0_array_reg;
23478c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x7080, 16, iter_reg);
23488c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x7090, 16, iter_reg);
23498c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x70A0, 16, iter_reg);
23508c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x70B0, 16, iter_reg);
23518c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x70C0, 16, iter_reg);
23528c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x70D0, 16, iter_reg);
23538c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x70E0, 16, iter_reg);
23548c2ecf20Sopenharmony_ci	qla24xx_read_window(reg, 0x70F0, 16, iter_reg);
23558c2ecf20Sopenharmony_ci
23568c2ecf20Sopenharmony_ci	/* I/O Queue Control registers. */
23578c2ecf20Sopenharmony_ci	qla24xx_read_window(reg, 0x7800, 16, fw->queue_control_reg);
23588c2ecf20Sopenharmony_ci
23598c2ecf20Sopenharmony_ci	/* Frame Buffer registers. */
23608c2ecf20Sopenharmony_ci	iter_reg = fw->fb_hdw_reg;
23618c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x6000, 16, iter_reg);
23628c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x6010, 16, iter_reg);
23638c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x6020, 16, iter_reg);
23648c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x6030, 16, iter_reg);
23658c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x6040, 16, iter_reg);
23668c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x6060, 16, iter_reg);
23678c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x6070, 16, iter_reg);
23688c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x6100, 16, iter_reg);
23698c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x6130, 16, iter_reg);
23708c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x6150, 16, iter_reg);
23718c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x6170, 16, iter_reg);
23728c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x6190, 16, iter_reg);
23738c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x61B0, 16, iter_reg);
23748c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x61C0, 16, iter_reg);
23758c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x6530, 16, iter_reg);
23768c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x6540, 16, iter_reg);
23778c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x6550, 16, iter_reg);
23788c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x6560, 16, iter_reg);
23798c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x6570, 16, iter_reg);
23808c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x6580, 16, iter_reg);
23818c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x6590, 16, iter_reg);
23828c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x65A0, 16, iter_reg);
23838c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x65B0, 16, iter_reg);
23848c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x65C0, 16, iter_reg);
23858c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x65D0, 16, iter_reg);
23868c2ecf20Sopenharmony_ci	iter_reg = qla24xx_read_window(reg, 0x65E0, 16, iter_reg);
23878c2ecf20Sopenharmony_ci	qla24xx_read_window(reg, 0x6F00, 16, iter_reg);
23888c2ecf20Sopenharmony_ci
23898c2ecf20Sopenharmony_ci	/* Multi queue registers */
23908c2ecf20Sopenharmony_ci	nxt_chain = qla25xx_copy_mq(ha, (void *)ha->fw_dump + ha->chain_offset,
23918c2ecf20Sopenharmony_ci	    &last_chain);
23928c2ecf20Sopenharmony_ci
23938c2ecf20Sopenharmony_ci	rval = qla24xx_soft_reset(ha);
23948c2ecf20Sopenharmony_ci	if (rval != QLA_SUCCESS) {
23958c2ecf20Sopenharmony_ci		ql_log(ql_log_warn, vha, 0xd00e,
23968c2ecf20Sopenharmony_ci		    "SOFT RESET FAILED, forcing continuation of dump!!!\n");
23978c2ecf20Sopenharmony_ci		rval = QLA_SUCCESS;
23988c2ecf20Sopenharmony_ci
23998c2ecf20Sopenharmony_ci		ql_log(ql_log_warn, vha, 0xd00f, "try a bigger hammer!!!\n");
24008c2ecf20Sopenharmony_ci
24018c2ecf20Sopenharmony_ci		wrt_reg_dword(&reg->hccr, HCCRX_SET_RISC_RESET);
24028c2ecf20Sopenharmony_ci		rd_reg_dword(&reg->hccr);
24038c2ecf20Sopenharmony_ci
24048c2ecf20Sopenharmony_ci		wrt_reg_dword(&reg->hccr, HCCRX_REL_RISC_PAUSE);
24058c2ecf20Sopenharmony_ci		rd_reg_dword(&reg->hccr);
24068c2ecf20Sopenharmony_ci
24078c2ecf20Sopenharmony_ci		wrt_reg_dword(&reg->hccr, HCCRX_CLR_RISC_RESET);
24088c2ecf20Sopenharmony_ci		rd_reg_dword(&reg->hccr);
24098c2ecf20Sopenharmony_ci
24108c2ecf20Sopenharmony_ci		for (cnt = 30000; cnt && (rd_reg_word(&reg->mailbox0)); cnt--)
24118c2ecf20Sopenharmony_ci			udelay(5);
24128c2ecf20Sopenharmony_ci
24138c2ecf20Sopenharmony_ci		if (!cnt) {
24148c2ecf20Sopenharmony_ci			nxt = fw->code_ram;
24158c2ecf20Sopenharmony_ci			nxt += sizeof(fw->code_ram);
24168c2ecf20Sopenharmony_ci			nxt += (ha->fw_memory_size - 0x100000 + 1);
24178c2ecf20Sopenharmony_ci			goto copy_queue;
24188c2ecf20Sopenharmony_ci		} else {
24198c2ecf20Sopenharmony_ci			set_bit(RISC_RDY_AFT_RESET, &ha->fw_dump_cap_flags);
24208c2ecf20Sopenharmony_ci			ql_log(ql_log_warn, vha, 0xd010,
24218c2ecf20Sopenharmony_ci			    "bigger hammer success?\n");
24228c2ecf20Sopenharmony_ci		}
24238c2ecf20Sopenharmony_ci	}
24248c2ecf20Sopenharmony_ci
24258c2ecf20Sopenharmony_ci	rval = qla24xx_dump_memory(ha, fw->code_ram, sizeof(fw->code_ram),
24268c2ecf20Sopenharmony_ci	    &nxt);
24278c2ecf20Sopenharmony_ci	if (rval != QLA_SUCCESS)
24288c2ecf20Sopenharmony_ci		goto qla83xx_fw_dump_failed_0;
24298c2ecf20Sopenharmony_ci
24308c2ecf20Sopenharmony_cicopy_queue:
24318c2ecf20Sopenharmony_ci	nxt = qla2xxx_copy_queues(ha, nxt);
24328c2ecf20Sopenharmony_ci
24338c2ecf20Sopenharmony_ci	qla24xx_copy_eft(ha, nxt);
24348c2ecf20Sopenharmony_ci
24358c2ecf20Sopenharmony_ci	/* Chain entries -- started with MQ. */
24368c2ecf20Sopenharmony_ci	nxt_chain = qla25xx_copy_fce(ha, nxt_chain, &last_chain);
24378c2ecf20Sopenharmony_ci	nxt_chain = qla25xx_copy_mqueues(ha, nxt_chain, &last_chain);
24388c2ecf20Sopenharmony_ci	nxt_chain = qla2xxx_copy_atioqueues(ha, nxt_chain, &last_chain);
24398c2ecf20Sopenharmony_ci	nxt_chain = qla25xx_copy_exlogin(ha, nxt_chain, &last_chain);
24408c2ecf20Sopenharmony_ci	nxt_chain = qla81xx_copy_exchoffld(ha, nxt_chain, &last_chain);
24418c2ecf20Sopenharmony_ci	if (last_chain) {
24428c2ecf20Sopenharmony_ci		ha->fw_dump->version |= htonl(DUMP_CHAIN_VARIANT);
24438c2ecf20Sopenharmony_ci		*last_chain |= htonl(DUMP_CHAIN_LAST);
24448c2ecf20Sopenharmony_ci	}
24458c2ecf20Sopenharmony_ci
24468c2ecf20Sopenharmony_ci	/* Adjust valid length. */
24478c2ecf20Sopenharmony_ci	ha->fw_dump_len = (nxt_chain - (void *)ha->fw_dump);
24488c2ecf20Sopenharmony_ci
24498c2ecf20Sopenharmony_ciqla83xx_fw_dump_failed_0:
24508c2ecf20Sopenharmony_ci	qla2xxx_dump_post_process(base_vha, rval);
24518c2ecf20Sopenharmony_ci}
24528c2ecf20Sopenharmony_ci
24538c2ecf20Sopenharmony_ci/****************************************************************************/
24548c2ecf20Sopenharmony_ci/*                         Driver Debug Functions.                          */
24558c2ecf20Sopenharmony_ci/****************************************************************************/
24568c2ecf20Sopenharmony_ci
24578c2ecf20Sopenharmony_ci/* Write the debug message prefix into @pbuf. */
24588c2ecf20Sopenharmony_cistatic void ql_dbg_prefix(char *pbuf, int pbuf_size,
24598c2ecf20Sopenharmony_ci			  const scsi_qla_host_t *vha, uint msg_id)
24608c2ecf20Sopenharmony_ci{
24618c2ecf20Sopenharmony_ci	if (vha) {
24628c2ecf20Sopenharmony_ci		const struct pci_dev *pdev = vha->hw->pdev;
24638c2ecf20Sopenharmony_ci
24648c2ecf20Sopenharmony_ci		/* <module-name> [<dev-name>]-<msg-id>:<host>: */
24658c2ecf20Sopenharmony_ci		snprintf(pbuf, pbuf_size, "%s [%s]-%04x:%lu: ", QL_MSGHDR,
24668c2ecf20Sopenharmony_ci			 dev_name(&(pdev->dev)), msg_id, vha->host_no);
24678c2ecf20Sopenharmony_ci	} else {
24688c2ecf20Sopenharmony_ci		/* <module-name> [<dev-name>]-<msg-id>: : */
24698c2ecf20Sopenharmony_ci		snprintf(pbuf, pbuf_size, "%s [%s]-%04x: : ", QL_MSGHDR,
24708c2ecf20Sopenharmony_ci			 "0000:00:00.0", msg_id);
24718c2ecf20Sopenharmony_ci	}
24728c2ecf20Sopenharmony_ci}
24738c2ecf20Sopenharmony_ci
24748c2ecf20Sopenharmony_ci/*
24758c2ecf20Sopenharmony_ci * This function is for formatting and logging debug information.
24768c2ecf20Sopenharmony_ci * It is to be used when vha is available. It formats the message
24778c2ecf20Sopenharmony_ci * and logs it to the messages file.
24788c2ecf20Sopenharmony_ci * parameters:
24798c2ecf20Sopenharmony_ci * level: The level of the debug messages to be printed.
24808c2ecf20Sopenharmony_ci *        If ql2xextended_error_logging value is correctly set,
24818c2ecf20Sopenharmony_ci *        this message will appear in the messages file.
24828c2ecf20Sopenharmony_ci * vha:   Pointer to the scsi_qla_host_t.
24838c2ecf20Sopenharmony_ci * id:    This is a unique identifier for the level. It identifies the
24848c2ecf20Sopenharmony_ci *        part of the code from where the message originated.
24858c2ecf20Sopenharmony_ci * msg:   The message to be displayed.
24868c2ecf20Sopenharmony_ci */
24878c2ecf20Sopenharmony_civoid
24888c2ecf20Sopenharmony_ciql_dbg(uint level, scsi_qla_host_t *vha, uint id, const char *fmt, ...)
24898c2ecf20Sopenharmony_ci{
24908c2ecf20Sopenharmony_ci	va_list va;
24918c2ecf20Sopenharmony_ci	struct va_format vaf;
24928c2ecf20Sopenharmony_ci	char pbuf[64];
24938c2ecf20Sopenharmony_ci
24948c2ecf20Sopenharmony_ci	if (!ql_mask_match(level) && !trace_ql_dbg_log_enabled())
24958c2ecf20Sopenharmony_ci		return;
24968c2ecf20Sopenharmony_ci
24978c2ecf20Sopenharmony_ci	va_start(va, fmt);
24988c2ecf20Sopenharmony_ci
24998c2ecf20Sopenharmony_ci	vaf.fmt = fmt;
25008c2ecf20Sopenharmony_ci	vaf.va = &va;
25018c2ecf20Sopenharmony_ci
25028c2ecf20Sopenharmony_ci	ql_dbg_prefix(pbuf, ARRAY_SIZE(pbuf), vha, id);
25038c2ecf20Sopenharmony_ci
25048c2ecf20Sopenharmony_ci	if (!ql_mask_match(level))
25058c2ecf20Sopenharmony_ci		trace_ql_dbg_log(pbuf, &vaf);
25068c2ecf20Sopenharmony_ci	else
25078c2ecf20Sopenharmony_ci		pr_warn("%s%pV", pbuf, &vaf);
25088c2ecf20Sopenharmony_ci
25098c2ecf20Sopenharmony_ci	va_end(va);
25108c2ecf20Sopenharmony_ci
25118c2ecf20Sopenharmony_ci}
25128c2ecf20Sopenharmony_ci
25138c2ecf20Sopenharmony_ci/*
25148c2ecf20Sopenharmony_ci * This function is for formatting and logging debug information.
25158c2ecf20Sopenharmony_ci * It is to be used when vha is not available and pci is available,
25168c2ecf20Sopenharmony_ci * i.e., before host allocation. It formats the message and logs it
25178c2ecf20Sopenharmony_ci * to the messages file.
25188c2ecf20Sopenharmony_ci * parameters:
25198c2ecf20Sopenharmony_ci * level: The level of the debug messages to be printed.
25208c2ecf20Sopenharmony_ci *        If ql2xextended_error_logging value is correctly set,
25218c2ecf20Sopenharmony_ci *        this message will appear in the messages file.
25228c2ecf20Sopenharmony_ci * pdev:  Pointer to the struct pci_dev.
25238c2ecf20Sopenharmony_ci * id:    This is a unique id for the level. It identifies the part
25248c2ecf20Sopenharmony_ci *        of the code from where the message originated.
25258c2ecf20Sopenharmony_ci * msg:   The message to be displayed.
25268c2ecf20Sopenharmony_ci */
25278c2ecf20Sopenharmony_civoid
25288c2ecf20Sopenharmony_ciql_dbg_pci(uint level, struct pci_dev *pdev, uint id, const char *fmt, ...)
25298c2ecf20Sopenharmony_ci{
25308c2ecf20Sopenharmony_ci	va_list va;
25318c2ecf20Sopenharmony_ci	struct va_format vaf;
25328c2ecf20Sopenharmony_ci	char pbuf[128];
25338c2ecf20Sopenharmony_ci
25348c2ecf20Sopenharmony_ci	if (pdev == NULL)
25358c2ecf20Sopenharmony_ci		return;
25368c2ecf20Sopenharmony_ci	if (!ql_mask_match(level))
25378c2ecf20Sopenharmony_ci		return;
25388c2ecf20Sopenharmony_ci
25398c2ecf20Sopenharmony_ci	va_start(va, fmt);
25408c2ecf20Sopenharmony_ci
25418c2ecf20Sopenharmony_ci	vaf.fmt = fmt;
25428c2ecf20Sopenharmony_ci	vaf.va = &va;
25438c2ecf20Sopenharmony_ci
25448c2ecf20Sopenharmony_ci	ql_dbg_prefix(pbuf, ARRAY_SIZE(pbuf), NULL, id + ql_dbg_offset);
25458c2ecf20Sopenharmony_ci	pr_warn("%s%pV", pbuf, &vaf);
25468c2ecf20Sopenharmony_ci
25478c2ecf20Sopenharmony_ci	va_end(va);
25488c2ecf20Sopenharmony_ci}
25498c2ecf20Sopenharmony_ci
25508c2ecf20Sopenharmony_ci/*
25518c2ecf20Sopenharmony_ci * This function is for formatting and logging log messages.
25528c2ecf20Sopenharmony_ci * It is to be used when vha is available. It formats the message
25538c2ecf20Sopenharmony_ci * and logs it to the messages file. All the messages will be logged
25548c2ecf20Sopenharmony_ci * irrespective of value of ql2xextended_error_logging.
25558c2ecf20Sopenharmony_ci * parameters:
25568c2ecf20Sopenharmony_ci * level: The level of the log messages to be printed in the
25578c2ecf20Sopenharmony_ci *        messages file.
25588c2ecf20Sopenharmony_ci * vha:   Pointer to the scsi_qla_host_t
25598c2ecf20Sopenharmony_ci * id:    This is a unique id for the level. It identifies the
25608c2ecf20Sopenharmony_ci *        part of the code from where the message originated.
25618c2ecf20Sopenharmony_ci * msg:   The message to be displayed.
25628c2ecf20Sopenharmony_ci */
25638c2ecf20Sopenharmony_civoid
25648c2ecf20Sopenharmony_ciql_log(uint level, scsi_qla_host_t *vha, uint id, const char *fmt, ...)
25658c2ecf20Sopenharmony_ci{
25668c2ecf20Sopenharmony_ci	va_list va;
25678c2ecf20Sopenharmony_ci	struct va_format vaf;
25688c2ecf20Sopenharmony_ci	char pbuf[128];
25698c2ecf20Sopenharmony_ci
25708c2ecf20Sopenharmony_ci	if (level > ql_errlev)
25718c2ecf20Sopenharmony_ci		return;
25728c2ecf20Sopenharmony_ci
25738c2ecf20Sopenharmony_ci	ql_dbg_prefix(pbuf, ARRAY_SIZE(pbuf), vha, id);
25748c2ecf20Sopenharmony_ci
25758c2ecf20Sopenharmony_ci	va_start(va, fmt);
25768c2ecf20Sopenharmony_ci
25778c2ecf20Sopenharmony_ci	vaf.fmt = fmt;
25788c2ecf20Sopenharmony_ci	vaf.va = &va;
25798c2ecf20Sopenharmony_ci
25808c2ecf20Sopenharmony_ci	switch (level) {
25818c2ecf20Sopenharmony_ci	case ql_log_fatal: /* FATAL LOG */
25828c2ecf20Sopenharmony_ci		pr_crit("%s%pV", pbuf, &vaf);
25838c2ecf20Sopenharmony_ci		break;
25848c2ecf20Sopenharmony_ci	case ql_log_warn:
25858c2ecf20Sopenharmony_ci		pr_err("%s%pV", pbuf, &vaf);
25868c2ecf20Sopenharmony_ci		break;
25878c2ecf20Sopenharmony_ci	case ql_log_info:
25888c2ecf20Sopenharmony_ci		pr_warn("%s%pV", pbuf, &vaf);
25898c2ecf20Sopenharmony_ci		break;
25908c2ecf20Sopenharmony_ci	default:
25918c2ecf20Sopenharmony_ci		pr_info("%s%pV", pbuf, &vaf);
25928c2ecf20Sopenharmony_ci		break;
25938c2ecf20Sopenharmony_ci	}
25948c2ecf20Sopenharmony_ci
25958c2ecf20Sopenharmony_ci	va_end(va);
25968c2ecf20Sopenharmony_ci}
25978c2ecf20Sopenharmony_ci
25988c2ecf20Sopenharmony_ci/*
25998c2ecf20Sopenharmony_ci * This function is for formatting and logging log messages.
26008c2ecf20Sopenharmony_ci * It is to be used when vha is not available and pci is available,
26018c2ecf20Sopenharmony_ci * i.e., before host allocation. It formats the message and logs
26028c2ecf20Sopenharmony_ci * it to the messages file. All the messages are logged irrespective
26038c2ecf20Sopenharmony_ci * of the value of ql2xextended_error_logging.
26048c2ecf20Sopenharmony_ci * parameters:
26058c2ecf20Sopenharmony_ci * level: The level of the log messages to be printed in the
26068c2ecf20Sopenharmony_ci *        messages file.
26078c2ecf20Sopenharmony_ci * pdev:  Pointer to the struct pci_dev.
26088c2ecf20Sopenharmony_ci * id:    This is a unique id for the level. It identifies the
26098c2ecf20Sopenharmony_ci *        part of the code from where the message originated.
26108c2ecf20Sopenharmony_ci * msg:   The message to be displayed.
26118c2ecf20Sopenharmony_ci */
26128c2ecf20Sopenharmony_civoid
26138c2ecf20Sopenharmony_ciql_log_pci(uint level, struct pci_dev *pdev, uint id, const char *fmt, ...)
26148c2ecf20Sopenharmony_ci{
26158c2ecf20Sopenharmony_ci	va_list va;
26168c2ecf20Sopenharmony_ci	struct va_format vaf;
26178c2ecf20Sopenharmony_ci	char pbuf[128];
26188c2ecf20Sopenharmony_ci
26198c2ecf20Sopenharmony_ci	if (pdev == NULL)
26208c2ecf20Sopenharmony_ci		return;
26218c2ecf20Sopenharmony_ci	if (level > ql_errlev)
26228c2ecf20Sopenharmony_ci		return;
26238c2ecf20Sopenharmony_ci
26248c2ecf20Sopenharmony_ci	ql_dbg_prefix(pbuf, ARRAY_SIZE(pbuf), NULL, id);
26258c2ecf20Sopenharmony_ci
26268c2ecf20Sopenharmony_ci	va_start(va, fmt);
26278c2ecf20Sopenharmony_ci
26288c2ecf20Sopenharmony_ci	vaf.fmt = fmt;
26298c2ecf20Sopenharmony_ci	vaf.va = &va;
26308c2ecf20Sopenharmony_ci
26318c2ecf20Sopenharmony_ci	switch (level) {
26328c2ecf20Sopenharmony_ci	case ql_log_fatal: /* FATAL LOG */
26338c2ecf20Sopenharmony_ci		pr_crit("%s%pV", pbuf, &vaf);
26348c2ecf20Sopenharmony_ci		break;
26358c2ecf20Sopenharmony_ci	case ql_log_warn:
26368c2ecf20Sopenharmony_ci		pr_err("%s%pV", pbuf, &vaf);
26378c2ecf20Sopenharmony_ci		break;
26388c2ecf20Sopenharmony_ci	case ql_log_info:
26398c2ecf20Sopenharmony_ci		pr_warn("%s%pV", pbuf, &vaf);
26408c2ecf20Sopenharmony_ci		break;
26418c2ecf20Sopenharmony_ci	default:
26428c2ecf20Sopenharmony_ci		pr_info("%s%pV", pbuf, &vaf);
26438c2ecf20Sopenharmony_ci		break;
26448c2ecf20Sopenharmony_ci	}
26458c2ecf20Sopenharmony_ci
26468c2ecf20Sopenharmony_ci	va_end(va);
26478c2ecf20Sopenharmony_ci}
26488c2ecf20Sopenharmony_ci
26498c2ecf20Sopenharmony_civoid
26508c2ecf20Sopenharmony_ciql_dump_regs(uint level, scsi_qla_host_t *vha, uint id)
26518c2ecf20Sopenharmony_ci{
26528c2ecf20Sopenharmony_ci	int i;
26538c2ecf20Sopenharmony_ci	struct qla_hw_data *ha = vha->hw;
26548c2ecf20Sopenharmony_ci	struct device_reg_2xxx __iomem *reg = &ha->iobase->isp;
26558c2ecf20Sopenharmony_ci	struct device_reg_24xx __iomem *reg24 = &ha->iobase->isp24;
26568c2ecf20Sopenharmony_ci	struct device_reg_82xx __iomem *reg82 = &ha->iobase->isp82;
26578c2ecf20Sopenharmony_ci	__le16 __iomem *mbx_reg;
26588c2ecf20Sopenharmony_ci
26598c2ecf20Sopenharmony_ci	if (!ql_mask_match(level))
26608c2ecf20Sopenharmony_ci		return;
26618c2ecf20Sopenharmony_ci
26628c2ecf20Sopenharmony_ci	if (IS_P3P_TYPE(ha))
26638c2ecf20Sopenharmony_ci		mbx_reg = &reg82->mailbox_in[0];
26648c2ecf20Sopenharmony_ci	else if (IS_FWI2_CAPABLE(ha))
26658c2ecf20Sopenharmony_ci		mbx_reg = &reg24->mailbox0;
26668c2ecf20Sopenharmony_ci	else
26678c2ecf20Sopenharmony_ci		mbx_reg = MAILBOX_REG(ha, reg, 0);
26688c2ecf20Sopenharmony_ci
26698c2ecf20Sopenharmony_ci	ql_dbg(level, vha, id, "Mailbox registers:\n");
26708c2ecf20Sopenharmony_ci	for (i = 0; i < 6; i++, mbx_reg++)
26718c2ecf20Sopenharmony_ci		ql_dbg(level, vha, id,
26728c2ecf20Sopenharmony_ci		    "mbox[%d] %#04x\n", i, rd_reg_word(mbx_reg));
26738c2ecf20Sopenharmony_ci}
26748c2ecf20Sopenharmony_ci
26758c2ecf20Sopenharmony_civoid
26768c2ecf20Sopenharmony_ciql_dump_buffer(uint level, scsi_qla_host_t *vha, uint id, const void *buf,
26778c2ecf20Sopenharmony_ci	       uint size)
26788c2ecf20Sopenharmony_ci{
26798c2ecf20Sopenharmony_ci	uint cnt;
26808c2ecf20Sopenharmony_ci
26818c2ecf20Sopenharmony_ci	if (!ql_mask_match(level))
26828c2ecf20Sopenharmony_ci		return;
26838c2ecf20Sopenharmony_ci
26848c2ecf20Sopenharmony_ci	ql_dbg(level, vha, id,
26858c2ecf20Sopenharmony_ci	    "%-+5d  0  1  2  3  4  5  6  7  8  9  A  B  C  D  E  F\n", size);
26868c2ecf20Sopenharmony_ci	ql_dbg(level, vha, id,
26878c2ecf20Sopenharmony_ci	    "----- -----------------------------------------------\n");
26888c2ecf20Sopenharmony_ci	for (cnt = 0; cnt < size; cnt += 16) {
26898c2ecf20Sopenharmony_ci		ql_dbg(level, vha, id, "%04x: ", cnt);
26908c2ecf20Sopenharmony_ci		print_hex_dump(KERN_CONT, "", DUMP_PREFIX_NONE, 16, 1,
26918c2ecf20Sopenharmony_ci			       buf + cnt, min(16U, size - cnt), false);
26928c2ecf20Sopenharmony_ci	}
26938c2ecf20Sopenharmony_ci}
26948c2ecf20Sopenharmony_ci
26958c2ecf20Sopenharmony_ci/*
26968c2ecf20Sopenharmony_ci * This function is for formatting and logging log messages.
26978c2ecf20Sopenharmony_ci * It is to be used when vha is available. It formats the message
26988c2ecf20Sopenharmony_ci * and logs it to the messages file. All the messages will be logged
26998c2ecf20Sopenharmony_ci * irrespective of value of ql2xextended_error_logging.
27008c2ecf20Sopenharmony_ci * parameters:
27018c2ecf20Sopenharmony_ci * level: The level of the log messages to be printed in the
27028c2ecf20Sopenharmony_ci *        messages file.
27038c2ecf20Sopenharmony_ci * vha:   Pointer to the scsi_qla_host_t
27048c2ecf20Sopenharmony_ci * id:    This is a unique id for the level. It identifies the
27058c2ecf20Sopenharmony_ci *        part of the code from where the message originated.
27068c2ecf20Sopenharmony_ci * msg:   The message to be displayed.
27078c2ecf20Sopenharmony_ci */
27088c2ecf20Sopenharmony_civoid
27098c2ecf20Sopenharmony_ciql_log_qp(uint32_t level, struct qla_qpair *qpair, int32_t id,
27108c2ecf20Sopenharmony_ci    const char *fmt, ...)
27118c2ecf20Sopenharmony_ci{
27128c2ecf20Sopenharmony_ci	va_list va;
27138c2ecf20Sopenharmony_ci	struct va_format vaf;
27148c2ecf20Sopenharmony_ci	char pbuf[128];
27158c2ecf20Sopenharmony_ci
27168c2ecf20Sopenharmony_ci	if (level > ql_errlev)
27178c2ecf20Sopenharmony_ci		return;
27188c2ecf20Sopenharmony_ci
27198c2ecf20Sopenharmony_ci	ql_dbg_prefix(pbuf, ARRAY_SIZE(pbuf), qpair ? qpair->vha : NULL, id);
27208c2ecf20Sopenharmony_ci
27218c2ecf20Sopenharmony_ci	va_start(va, fmt);
27228c2ecf20Sopenharmony_ci
27238c2ecf20Sopenharmony_ci	vaf.fmt = fmt;
27248c2ecf20Sopenharmony_ci	vaf.va = &va;
27258c2ecf20Sopenharmony_ci
27268c2ecf20Sopenharmony_ci	switch (level) {
27278c2ecf20Sopenharmony_ci	case ql_log_fatal: /* FATAL LOG */
27288c2ecf20Sopenharmony_ci		pr_crit("%s%pV", pbuf, &vaf);
27298c2ecf20Sopenharmony_ci		break;
27308c2ecf20Sopenharmony_ci	case ql_log_warn:
27318c2ecf20Sopenharmony_ci		pr_err("%s%pV", pbuf, &vaf);
27328c2ecf20Sopenharmony_ci		break;
27338c2ecf20Sopenharmony_ci	case ql_log_info:
27348c2ecf20Sopenharmony_ci		pr_warn("%s%pV", pbuf, &vaf);
27358c2ecf20Sopenharmony_ci		break;
27368c2ecf20Sopenharmony_ci	default:
27378c2ecf20Sopenharmony_ci		pr_info("%s%pV", pbuf, &vaf);
27388c2ecf20Sopenharmony_ci		break;
27398c2ecf20Sopenharmony_ci	}
27408c2ecf20Sopenharmony_ci
27418c2ecf20Sopenharmony_ci	va_end(va);
27428c2ecf20Sopenharmony_ci}
27438c2ecf20Sopenharmony_ci
27448c2ecf20Sopenharmony_ci/*
27458c2ecf20Sopenharmony_ci * This function is for formatting and logging debug information.
27468c2ecf20Sopenharmony_ci * It is to be used when vha is available. It formats the message
27478c2ecf20Sopenharmony_ci * and logs it to the messages file.
27488c2ecf20Sopenharmony_ci * parameters:
27498c2ecf20Sopenharmony_ci * level: The level of the debug messages to be printed.
27508c2ecf20Sopenharmony_ci *        If ql2xextended_error_logging value is correctly set,
27518c2ecf20Sopenharmony_ci *        this message will appear in the messages file.
27528c2ecf20Sopenharmony_ci * vha:   Pointer to the scsi_qla_host_t.
27538c2ecf20Sopenharmony_ci * id:    This is a unique identifier for the level. It identifies the
27548c2ecf20Sopenharmony_ci *        part of the code from where the message originated.
27558c2ecf20Sopenharmony_ci * msg:   The message to be displayed.
27568c2ecf20Sopenharmony_ci */
27578c2ecf20Sopenharmony_civoid
27588c2ecf20Sopenharmony_ciql_dbg_qp(uint32_t level, struct qla_qpair *qpair, int32_t id,
27598c2ecf20Sopenharmony_ci    const char *fmt, ...)
27608c2ecf20Sopenharmony_ci{
27618c2ecf20Sopenharmony_ci	va_list va;
27628c2ecf20Sopenharmony_ci	struct va_format vaf;
27638c2ecf20Sopenharmony_ci	char pbuf[128];
27648c2ecf20Sopenharmony_ci
27658c2ecf20Sopenharmony_ci	if (!ql_mask_match(level))
27668c2ecf20Sopenharmony_ci		return;
27678c2ecf20Sopenharmony_ci
27688c2ecf20Sopenharmony_ci	va_start(va, fmt);
27698c2ecf20Sopenharmony_ci
27708c2ecf20Sopenharmony_ci	vaf.fmt = fmt;
27718c2ecf20Sopenharmony_ci	vaf.va = &va;
27728c2ecf20Sopenharmony_ci
27738c2ecf20Sopenharmony_ci	ql_dbg_prefix(pbuf, ARRAY_SIZE(pbuf), qpair ? qpair->vha : NULL,
27748c2ecf20Sopenharmony_ci		      id + ql_dbg_offset);
27758c2ecf20Sopenharmony_ci	pr_warn("%s%pV", pbuf, &vaf);
27768c2ecf20Sopenharmony_ci
27778c2ecf20Sopenharmony_ci	va_end(va);
27788c2ecf20Sopenharmony_ci
27798c2ecf20Sopenharmony_ci}
2780