xref: /freebsd/sys/dev/qlxgbe/ql_ioctl.h (revision b65c0c07)
1718cf2ccSPedro F. Giffuni /*-
2718cf2ccSPedro F. Giffuni  * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
3718cf2ccSPedro F. Giffuni  *
435291c22SDavid C Somayajulu  * Copyright (c) 2013-2016 Qlogic Corporation
5f10a77bbSDavid C Somayajulu  * All rights reserved.
6f10a77bbSDavid C Somayajulu  *
7f10a77bbSDavid C Somayajulu  *  Redistribution and use in source and binary forms, with or without
8f10a77bbSDavid C Somayajulu  *  modification, are permitted provided that the following conditions
9f10a77bbSDavid C Somayajulu  *  are met:
10f10a77bbSDavid C Somayajulu  *
11f10a77bbSDavid C Somayajulu  *  1. Redistributions of source code must retain the above copyright
12f10a77bbSDavid C Somayajulu  *     notice, this list of conditions and the following disclaimer.
13f10a77bbSDavid C Somayajulu  *  2. Redistributions in binary form must reproduce the above copyright
14f10a77bbSDavid C Somayajulu  *     notice, this list of conditions and the following disclaimer in the
15f10a77bbSDavid C Somayajulu  *     documentation and/or other materials provided with the distribution.
16f10a77bbSDavid C Somayajulu  *
17f10a77bbSDavid C Somayajulu  *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18f10a77bbSDavid C Somayajulu  *  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19f10a77bbSDavid C Somayajulu  *  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20f10a77bbSDavid C Somayajulu  *  ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
21f10a77bbSDavid C Somayajulu  *  LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22f10a77bbSDavid C Somayajulu  *  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23f10a77bbSDavid C Somayajulu  *  SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24f10a77bbSDavid C Somayajulu  *  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25f10a77bbSDavid C Somayajulu  *  CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26f10a77bbSDavid C Somayajulu  *  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27f10a77bbSDavid C Somayajulu  *  POSSIBILITY OF SUCH DAMAGE.
28f10a77bbSDavid C Somayajulu  *
29f10a77bbSDavid C Somayajulu  * $FreeBSD$
30f10a77bbSDavid C Somayajulu  */
31f10a77bbSDavid C Somayajulu /*
32f10a77bbSDavid C Somayajulu  * File: ql_ioctl.h
33f10a77bbSDavid C Somayajulu  * Author : David C Somayajulu, Qlogic Corporation, Aliso Viejo, CA 92656.
34f10a77bbSDavid C Somayajulu  */
35f10a77bbSDavid C Somayajulu 
36f10a77bbSDavid C Somayajulu #ifndef _QL_IOCTL_H_
37f10a77bbSDavid C Somayajulu #define _QL_IOCTL_H_
38f10a77bbSDavid C Somayajulu 
39f10a77bbSDavid C Somayajulu #include <sys/ioccom.h>
40f10a77bbSDavid C Somayajulu 
41f10a77bbSDavid C Somayajulu struct qla_reg_val {
42f10a77bbSDavid C Somayajulu         uint16_t rd;
43f10a77bbSDavid C Somayajulu         uint16_t direct;
44f10a77bbSDavid C Somayajulu         uint32_t reg;
45f10a77bbSDavid C Somayajulu         uint32_t val;
46f10a77bbSDavid C Somayajulu };
47f10a77bbSDavid C Somayajulu typedef struct qla_reg_val qla_reg_val_t;
48f10a77bbSDavid C Somayajulu 
49f10a77bbSDavid C Somayajulu struct qla_rd_flash {
50f10a77bbSDavid C Somayajulu         uint32_t off;
51f10a77bbSDavid C Somayajulu         uint32_t data;
52f10a77bbSDavid C Somayajulu };
53f10a77bbSDavid C Somayajulu typedef struct qla_rd_flash qla_rd_flash_t;
54f10a77bbSDavid C Somayajulu 
55f10a77bbSDavid C Somayajulu struct qla_wr_flash {
56f10a77bbSDavid C Somayajulu 	uint32_t off;
57f10a77bbSDavid C Somayajulu 	uint32_t size;
58f10a77bbSDavid C Somayajulu 	void *buffer;
59f10a77bbSDavid C Somayajulu 	uint32_t pattern;
60f10a77bbSDavid C Somayajulu };
61f10a77bbSDavid C Somayajulu typedef struct qla_wr_flash qla_wr_flash_t;
62f10a77bbSDavid C Somayajulu 
63f10a77bbSDavid C Somayajulu struct qla_erase_flash {
64f10a77bbSDavid C Somayajulu 	uint32_t off;
65f10a77bbSDavid C Somayajulu 	uint32_t size;
66f10a77bbSDavid C Somayajulu };
67f10a77bbSDavid C Somayajulu typedef struct qla_erase_flash qla_erase_flash_t;
68f10a77bbSDavid C Somayajulu 
69f10a77bbSDavid C Somayajulu struct qla_rd_pci_ids {
70f10a77bbSDavid C Somayajulu 	uint16_t ven_id;
71f10a77bbSDavid C Somayajulu 	uint16_t dev_id;
72f10a77bbSDavid C Somayajulu 	uint16_t subsys_ven_id;
73f10a77bbSDavid C Somayajulu 	uint16_t subsys_dev_id;
74f10a77bbSDavid C Somayajulu 	uint8_t rev_id;
75f10a77bbSDavid C Somayajulu };
76f10a77bbSDavid C Somayajulu typedef struct qla_rd_pci_ids qla_rd_pci_ids_t;
77f10a77bbSDavid C Somayajulu 
78b65c0c07SDavid C Somayajulu #define NUM_LOG_ENTRY_PARAMS	5
79b65c0c07SDavid C Somayajulu #define NUM_LOG_ENTRIES		512
80b65c0c07SDavid C Somayajulu 
81b65c0c07SDavid C Somayajulu struct qla_sp_log_entry {
82b65c0c07SDavid C Somayajulu 	uint32_t fmtstr_idx;
83b65c0c07SDavid C Somayajulu 	uint32_t num_params;
84b65c0c07SDavid C Somayajulu 	uint64_t usec_ts;
85b65c0c07SDavid C Somayajulu 	uint32_t params[NUM_LOG_ENTRY_PARAMS];
86b65c0c07SDavid C Somayajulu };
87b65c0c07SDavid C Somayajulu typedef struct qla_sp_log_entry qla_sp_log_entry_t;
88b65c0c07SDavid C Somayajulu 
89f10a77bbSDavid C Somayajulu /*
90f10a77bbSDavid C Somayajulu  * structure encapsulating the value to read/write from/to offchip (MS) memory
91f10a77bbSDavid C Somayajulu  */
92f10a77bbSDavid C Somayajulu struct qla_offchip_mem_val {
93f10a77bbSDavid C Somayajulu 	uint16_t rd;
94f10a77bbSDavid C Somayajulu 	uint64_t off;
95f10a77bbSDavid C Somayajulu 	uint32_t data_lo;
96f10a77bbSDavid C Somayajulu 	uint32_t data_hi;
97f10a77bbSDavid C Somayajulu 	uint32_t data_ulo;
98f10a77bbSDavid C Somayajulu 	uint32_t data_uhi;
99f10a77bbSDavid C Somayajulu };
100f10a77bbSDavid C Somayajulu typedef struct qla_offchip_mem_val qla_offchip_mem_val_t;
101f10a77bbSDavid C Somayajulu 
102f10a77bbSDavid C Somayajulu struct qla_rd_fw_dump {
103f10a77bbSDavid C Somayajulu 	uint16_t pci_func;
104b65c0c07SDavid C Somayajulu 	uint16_t saved;
105b65c0c07SDavid C Somayajulu 	uint64_t usec_ts;
1066a62bec0SDavid C Somayajulu 	uint32_t minidump_size;
1076a62bec0SDavid C Somayajulu 	void *minidump;
108f10a77bbSDavid C Somayajulu };
109f10a77bbSDavid C Somayajulu typedef struct qla_rd_fw_dump qla_rd_fw_dump_t;
110f10a77bbSDavid C Somayajulu 
111ab142b3fSDavid C Somayajulu struct qla_drvr_state_tx {
112ab142b3fSDavid C Somayajulu 	uint64_t	base_p_addr;
113ab142b3fSDavid C Somayajulu 	uint64_t	cons_p_addr;
114ab142b3fSDavid C Somayajulu 	uint32_t	tx_prod_reg;
115ab142b3fSDavid C Somayajulu 	uint32_t	tx_cntxt_id;
116ab142b3fSDavid C Somayajulu 	uint32_t	txr_free;
117ab142b3fSDavid C Somayajulu 	uint32_t	txr_next;
118ab142b3fSDavid C Somayajulu 	uint32_t	txr_comp;
119ab142b3fSDavid C Somayajulu };
120ab142b3fSDavid C Somayajulu typedef struct qla_drvr_state_tx qla_drvr_state_tx_t;
121ab142b3fSDavid C Somayajulu 
122ab142b3fSDavid C Somayajulu struct qla_drvr_state_sds {
123ab142b3fSDavid C Somayajulu 	uint32_t        sdsr_next; /* next entry in SDS ring to process */
124ab142b3fSDavid C Somayajulu 	uint32_t        sds_consumer;
125ab142b3fSDavid C Somayajulu };
126ab142b3fSDavid C Somayajulu typedef struct qla_drvr_state_sds qla_drvr_state_sds_t;
127ab142b3fSDavid C Somayajulu 
128ab142b3fSDavid C Somayajulu struct qla_drvr_state_rx {
129ab142b3fSDavid C Somayajulu 	uint32_t	prod_std;
130ab142b3fSDavid C Somayajulu 	uint32_t	rx_next; /* next standard rcv ring to arm fw */;
131ab142b3fSDavid C Somayajulu };
132ab142b3fSDavid C Somayajulu typedef struct qla_drvr_state_rx qla_drvr_state_rx_t;
133ab142b3fSDavid C Somayajulu 
134ab142b3fSDavid C Somayajulu struct qla_drvr_state_hdr {
135ab142b3fSDavid C Somayajulu 	uint32_t	drvr_version_major;
136ab142b3fSDavid C Somayajulu 	uint32_t	drvr_version_minor;
137ab142b3fSDavid C Somayajulu 	uint32_t	drvr_version_build;
138ab142b3fSDavid C Somayajulu 
139ab142b3fSDavid C Somayajulu 	uint8_t         mac_addr[ETHER_ADDR_LEN];
140b65c0c07SDavid C Somayajulu 	uint16_t	saved;
141b65c0c07SDavid C Somayajulu 	uint64_t	usec_ts;
142ab142b3fSDavid C Somayajulu         uint16_t        link_speed;
143ab142b3fSDavid C Somayajulu         uint16_t        cable_length;
144ab142b3fSDavid C Somayajulu         uint32_t        cable_oui;
145ab142b3fSDavid C Somayajulu         uint8_t         link_up;
146ab142b3fSDavid C Somayajulu         uint8_t         module_type;
147ab142b3fSDavid C Somayajulu         uint8_t         link_faults;
148ab142b3fSDavid C Somayajulu         uint32_t        rcv_intr_coalesce;
149ab142b3fSDavid C Somayajulu         uint32_t        xmt_intr_coalesce;
150ab142b3fSDavid C Somayajulu 
151ab142b3fSDavid C Somayajulu 	uint32_t	tx_state_offset;/* size = sizeof (qla_drvr_state_tx_t) * num_tx_rings */
152ab142b3fSDavid C Somayajulu 	uint32_t	rx_state_offset;/* size = sizeof (qla_drvr_state_rx_t) * num_rx_rings */
153ab142b3fSDavid C Somayajulu 	uint32_t	sds_state_offset;/* size = sizeof (qla_drvr_state_sds_t) * num_sds_rings */
154ab142b3fSDavid C Somayajulu 
155ab142b3fSDavid C Somayajulu 	uint32_t	num_tx_rings; /* number of tx rings */
156ab142b3fSDavid C Somayajulu 	uint32_t	txr_size; /* size of each tx ring in bytes */
157ab142b3fSDavid C Somayajulu 	uint32_t	txr_entries; /* number of descriptors in each tx ring */
158ab142b3fSDavid C Somayajulu 	uint32_t	txr_offset; /* start of tx ring [0 - #rings] content */
159ab142b3fSDavid C Somayajulu 
160ab142b3fSDavid C Somayajulu 	uint32_t	num_rx_rings; /* number of rx rings */
161ab142b3fSDavid C Somayajulu 	uint32_t	rxr_size; /* size of each rx ring in bytes */
162ab142b3fSDavid C Somayajulu 	uint32_t	rxr_entries; /* number of descriptors in each rx ring */
163ab142b3fSDavid C Somayajulu 	uint32_t	rxr_offset; /* start of rx ring [0 - #rings] content */
164ab142b3fSDavid C Somayajulu 
165ab142b3fSDavid C Somayajulu 	uint32_t	num_sds_rings; /* number of sds rings */
166ab142b3fSDavid C Somayajulu 	uint32_t	sds_ring_size; /* size of each sds ring in bytes */
167ab142b3fSDavid C Somayajulu 	uint32_t	sds_entries; /* number of descriptors in each sds ring */
168ab142b3fSDavid C Somayajulu 	uint32_t	sds_offset; /* start of sds ring [0 - #rings] content */
169ab142b3fSDavid C Somayajulu };
170ab142b3fSDavid C Somayajulu 
171ab142b3fSDavid C Somayajulu typedef struct qla_drvr_state_hdr qla_drvr_state_hdr_t;
172ab142b3fSDavid C Somayajulu 
173ab142b3fSDavid C Somayajulu struct qla_driver_state {
174ab142b3fSDavid C Somayajulu 	uint32_t	size;
175ab142b3fSDavid C Somayajulu 	void		*buffer;
176ab142b3fSDavid C Somayajulu };
177ab142b3fSDavid C Somayajulu typedef struct qla_driver_state qla_driver_state_t;
178ab142b3fSDavid C Somayajulu 
179b65c0c07SDavid C Somayajulu struct qla_sp_log {
180b65c0c07SDavid C Somayajulu 	uint32_t	next_idx; /* index of next entry in slowpath trace log */
181b65c0c07SDavid C Somayajulu 	uint32_t	num_entries; /* number of entries in slowpath trace log */
182b65c0c07SDavid C Somayajulu 	void		*buffer;
183b65c0c07SDavid C Somayajulu };
184b65c0c07SDavid C Somayajulu typedef struct qla_sp_log qla_sp_log_t;
185b65c0c07SDavid C Somayajulu 
186f10a77bbSDavid C Somayajulu /*
187f10a77bbSDavid C Somayajulu  * Read/Write Register
188f10a77bbSDavid C Somayajulu  */
189f10a77bbSDavid C Somayajulu #define QLA_RDWR_REG		_IOWR('q', 1, qla_reg_val_t)
190f10a77bbSDavid C Somayajulu 
191f10a77bbSDavid C Somayajulu /*
192f10a77bbSDavid C Somayajulu  * Read Flash
193f10a77bbSDavid C Somayajulu  */
194f10a77bbSDavid C Somayajulu #define QLA_RD_FLASH		_IOWR('q', 2, qla_rd_flash_t)
195f10a77bbSDavid C Somayajulu 
196f10a77bbSDavid C Somayajulu /*
197f10a77bbSDavid C Somayajulu  * Write Flash
198f10a77bbSDavid C Somayajulu  */
199f10a77bbSDavid C Somayajulu #define QLA_WR_FLASH		_IOWR('q', 3, qla_wr_flash_t)
200f10a77bbSDavid C Somayajulu 
201f10a77bbSDavid C Somayajulu /*
202f10a77bbSDavid C Somayajulu  * Read Offchip (MS) Memory
203f10a77bbSDavid C Somayajulu  */
204f10a77bbSDavid C Somayajulu #define QLA_RDWR_MS_MEM		_IOWR('q', 4, qla_offchip_mem_val_t)
205f10a77bbSDavid C Somayajulu 
206f10a77bbSDavid C Somayajulu /*
207f10a77bbSDavid C Somayajulu  * Erase Flash
208f10a77bbSDavid C Somayajulu  */
209f10a77bbSDavid C Somayajulu #define QLA_ERASE_FLASH		_IOWR('q', 5, qla_erase_flash_t)
210f10a77bbSDavid C Somayajulu 
211f10a77bbSDavid C Somayajulu /*
212f10a77bbSDavid C Somayajulu  * Read PCI IDs
213f10a77bbSDavid C Somayajulu  */
214f10a77bbSDavid C Somayajulu #define QLA_RD_PCI_IDS		_IOWR('q', 6, qla_rd_pci_ids_t)
215f10a77bbSDavid C Somayajulu 
216f10a77bbSDavid C Somayajulu /*
217f10a77bbSDavid C Somayajulu  * Read Minidump Template Size
218f10a77bbSDavid C Somayajulu  */
219f10a77bbSDavid C Somayajulu #define QLA_RD_FW_DUMP_SIZE	_IOWR('q', 7, qla_rd_fw_dump_t)
220f10a77bbSDavid C Somayajulu 
221f10a77bbSDavid C Somayajulu /*
222f10a77bbSDavid C Somayajulu  * Read Minidump Template
223f10a77bbSDavid C Somayajulu  */
224f10a77bbSDavid C Somayajulu #define QLA_RD_FW_DUMP		_IOWR('q', 8, qla_rd_fw_dump_t)
225f10a77bbSDavid C Somayajulu 
226ab142b3fSDavid C Somayajulu /*
227ab142b3fSDavid C Somayajulu  * Read Driver State
228ab142b3fSDavid C Somayajulu  */
229ab142b3fSDavid C Somayajulu #define QLA_RD_DRVR_STATE	_IOWR('q', 9, qla_driver_state_t)
230ab142b3fSDavid C Somayajulu 
231b65c0c07SDavid C Somayajulu /*
232b65c0c07SDavid C Somayajulu  * Read Slowpath Log
233b65c0c07SDavid C Somayajulu  */
234b65c0c07SDavid C Somayajulu #define QLA_RD_SLOWPATH_LOG	_IOWR('q', 10, qla_sp_log_t)
235b65c0c07SDavid C Somayajulu 
236b65c0c07SDavid C Somayajulu /*
237b65c0c07SDavid C Somayajulu  * Format Strings For Slowpath Trace Logs
238b65c0c07SDavid C Somayajulu  */
239b65c0c07SDavid C Somayajulu #define SP_TLOG_FMT_STR_0	\
240b65c0c07SDavid C Somayajulu 	"qla_mbx_cmd [%ld]: enter no_pause = %d [0x%08x 0x%08x 0x%08x 0x%08x]\n"
241b65c0c07SDavid C Somayajulu 
242b65c0c07SDavid C Somayajulu #define SP_TLOG_FMT_STR_1	\
243b65c0c07SDavid C Somayajulu 	"qla_mbx_cmd [%ld]: offline = 0x%08x qla_initiate_recovery = 0x%08x exit1\n"
244b65c0c07SDavid C Somayajulu 
245b65c0c07SDavid C Somayajulu #define SP_TLOG_FMT_STR_2	\
246b65c0c07SDavid C Somayajulu 	"qla_mbx_cmd [%ld]: qla_initiate_recovery = 0x%08x exit2\n"
247b65c0c07SDavid C Somayajulu 
248b65c0c07SDavid C Somayajulu #define SP_TLOG_FMT_STR_3	\
249b65c0c07SDavid C Somayajulu 	"qla_mbx_cmd [%ld]: timeout exit3 [host_mbx_cntrl = 0x%08x]\n"
250b65c0c07SDavid C Somayajulu 
251b65c0c07SDavid C Somayajulu #define SP_TLOG_FMT_STR_4	\
252b65c0c07SDavid C Somayajulu 	"qla_mbx_cmd [%ld]: qla_initiate_recovery = 0x%08x exit4\n"
253b65c0c07SDavid C Somayajulu 
254b65c0c07SDavid C Somayajulu #define SP_TLOG_FMT_STR_5	\
255b65c0c07SDavid C Somayajulu 	"qla_mbx_cmd [%ld]: timeout exit5 [fw_mbx_cntrl = 0x%08x]\n"
256b65c0c07SDavid C Somayajulu 
257b65c0c07SDavid C Somayajulu #define SP_TLOG_FMT_STR_6	\
258b65c0c07SDavid C Somayajulu 	"qla_mbx_cmd [%ld]: qla_initiate_recovery = 0x%08x exit6\n"
259b65c0c07SDavid C Somayajulu 
260b65c0c07SDavid C Somayajulu #define SP_TLOG_FMT_STR_7	\
261b65c0c07SDavid C Somayajulu 	"qla_mbx_cmd [%ld]: exit [0x%08x 0x%08x 0x%08x 0x%08x 0x%08x]\n"
262b65c0c07SDavid C Somayajulu 
263b65c0c07SDavid C Somayajulu #define SP_TLOG_FMT_STR_8	\
264b65c0c07SDavid C Somayajulu 	"qla_ioctl [%ld]: SIOCSIFADDR if_drv_flags = 0x%08x [0x%08x] ipv4 = 0x%08x\n"
265b65c0c07SDavid C Somayajulu 
266b65c0c07SDavid C Somayajulu #define SP_TLOG_FMT_STR_9	\
267b65c0c07SDavid C Somayajulu 	"qla_ioctl [%ld]: SIOCSIFMTU if_drv_flags = 0x%08x [0x%08x] max_frame_size = 0x%08x if_mtu = 0x%08x\n"
268b65c0c07SDavid C Somayajulu 
269b65c0c07SDavid C Somayajulu #define SP_TLOG_FMT_STR_10	\
270b65c0c07SDavid C Somayajulu 	"qla_ioctl [%ld]: SIOCSIFFLAGS if_drv_flags = 0x%08x [0x%08x] ha->if_flags = 0x%08x ifp->if_flags = 0x%08x\n"
271b65c0c07SDavid C Somayajulu 
272b65c0c07SDavid C Somayajulu #define SP_TLOG_FMT_STR_11	\
273b65c0c07SDavid C Somayajulu 	"qla_ioctl [%ld]: SIOCSIFCAP if_drv_flags = 0x%08x [0x%08x] mask = 0x%08x ifp->if_capenable = 0x%08x\n"
274b65c0c07SDavid C Somayajulu 
275b65c0c07SDavid C Somayajulu #define SP_TLOG_FMT_STR_12	\
276b65c0c07SDavid C Somayajulu 	"qla_set_multi [%ld]: if_drv_flags = 0x%08x [0x%08x] add_multi = 0x%08x mcnt = 0x%08x\n"
277b65c0c07SDavid C Somayajulu 
278b65c0c07SDavid C Somayajulu #define SP_TLOG_FMT_STR_13	\
279b65c0c07SDavid C Somayajulu 	"qla_stop [%ld]: \n"
280b65c0c07SDavid C Somayajulu 
281b65c0c07SDavid C Somayajulu #define SP_TLOG_FMT_STR_14	\
282b65c0c07SDavid C Somayajulu 	"qla_init_locked [%ld]: \n"
283b65c0c07SDavid C Somayajulu 
284ab142b3fSDavid C Somayajulu 
285f10a77bbSDavid C Somayajulu #endif /* #ifndef _QL_IOCTL_H_ */
286