1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 /*
22  * Copyright 1999 Sun Microsystems, Inc. All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 #ifndef	_SYS_SCSI_ADAPTERS_IFPIO_H
27 #define	_SYS_SCSI_ADAPTERS_IFPIO_H
28 
29 #pragma ident	"%Z%%M%	%I%	%E% SMI"
30 
31 /*
32  * Include any headers you depend on.
33  */
34 
35 #ifdef	__cplusplus
36 extern "C" {
37 #endif
38 
39 #define	IFP_IOC	('I' << 8)
40 
41 /*
42  * Get ifp device map ioctl.
43  */
44 #define	IFPIOCGMAP		(IFP_IOC|1)	/* Get device map/wwn's */
45 #define	IFPIO_ADISC_ELS		(IFP_IOC|2)	/* Get ADISC info */
46 #define	IFPIO_FORCE_LIP		(IFP_IOC|3)	/* Force a LIP */
47 #define	IFPIO_LINKSTATUS	(IFP_IOC|4)	/* Link Status */
48 #define	IFPIO_DIAG_GET_FWREV	(IFP_IOC|5)	/* SunVTS diag get fw rev */
49 #define	IFPIO_DIAG_NOP		(IFP_IOC|6)	/* SunVTS diag NOOP */
50 #define	IFPIO_DIAG_MBOXCMD	(IFP_IOC|7)	/* SunVTS diag mbox cmds */
51 #define	IFPIO_LOOPBACK_FRAME	(IFP_IOC|8)	/* Diagnostic loopback */
52 #define	IFPIO_DIAG_SELFTEST	(IFP_IOC|9)	/* Diagnostic selftest */
53 #define	IFPIO_BOARD_INFO	(IFP_IOC|10)	/* Get device id and rev's */
54 #define	IFPIO_FCODE_DOWNLOAD	(IFP_IOC|11)	/* Download fcode to flash */
55 
56 struct ifp_board_info {
57 	uint16_t	ifpd_major;		/* FW major revision */
58 	uint16_t	ifpd_minor;		/* FW minor revision */
59 	uint16_t	ifpd_subminor;		/* FW subminor revision */
60 	uint16_t	chip_rev;		/* chip revision level */
61 	uint16_t	ctrl_id;		/* 2100 or 2200 */
62 };
63 typedef struct ifp_board_info ifp_board_info_t;
64 
65 struct ifp_diag_fw_rev {
66 	uint16_t	ifpd_major;		/* FW major revision */
67 	uint16_t	ifpd_minor;		/* FW minor revision */
68 };
69 typedef struct ifp_diag_fw_rev ifp_diag_fw_rev_t;
70 
71 struct ifp_lb_frame_cmd {
72 	uint16_t	options;		/* diag loop-back options */
73 	uint32_t	iter_cnt;		/* count of loopback ops */
74 	uint32_t	xfer_cnt;		/* transmit/receive xfer len */
75 	caddr_t		xmit_addr;		/* transmit data address */
76 	caddr_t		recv_addr;		/* receive data address */
77 
78 	uint16_t	status;			/* completion status */
79 	uint16_t	crc_cnt;		/* crc error count */
80 	uint16_t	disparity_cnt;		/* disparity error count */
81 	uint16_t	frame_len_err_cnt;	/* frame length error count */
82 	uint32_t	fail_iter_cnt;		/* failing iteration count */
83 };
84 typedef struct ifp_lb_frame_cmd ifp_lb_frame_cmd_t;
85 
86 #if defined(_LP64)
87 struct ifp_lb_frame_cmd32 {
88 	uint16_t	options;		/* diag loop-back options */
89 	uint32_t	iter_cnt;		/* count of loopback ops */
90 	uint32_t	xfer_cnt;		/* transmit/receive xfer len */
91 	caddr32_t	xmit_addr;		/* transmit data address */
92 	caddr32_t	recv_addr;		/* receive data address */
93 
94 	uint16_t	status;			/* completion status */
95 	uint16_t	crc_cnt;		/* crc error count */
96 	uint16_t	disparity_cnt;		/* disparity error count */
97 	uint16_t	frame_len_err_cnt;	/* frame length error count */
98 	uint32_t	fail_iter_cnt;		/* failing iteration count */
99 };
100 #endif
101 
102 /* defines for options field */
103 #define	LOOP_10BIT	0x0000		/* loopback at 10 bit interface */
104 #define	LOOP_1BIT	0x0001		/* loopback at 1 bit interface */
105 #define	LOOP_EXTERNAL	0x0002		/* loopback on external loop */
106 #define	LOOP_XMIT_OFF	0x0004		/* transmitter powered off */
107 #define	LOOP_XMIT_RAM	0x0010		/* xmit data from system ram */
108 #define	LOOP_RECV_RAM	0x0020		/* receive data to system ram */
109 #define	LOOP_ERR_STOP	0x0080		/* stop test on error */
110 
111 struct ifp_diag_selftest {
112 	uint16_t	status;			/* completion status */
113 	uint16_t	test_num;		/* failing test number */
114 	uint16_t	fail_addr;		/* failure address */
115 	uint16_t	fail_data;		/* failure data */
116 };
117 typedef struct ifp_diag_selftest ifp_diag_selftest_t;
118 
119 /* offset of the fcode from begining of file */
120 #define	FCODE_OFFSET	0x20
121 struct ifp_download {
122 	uint32_t	dl_fcode_len;		/* length of the fcode array */
123 	uint16_t	dl_chip_id;		/* Chip id for FCODE */
124 	uchar_t	dl_fcode[1];		/* the fcode */
125 };
126 typedef struct ifp_download ifp_download_t;
127 
128 #define	IFP_NUM_ENTRIES_IN_MAP	127
129 #define	IFP_DIAG_MAX_MBOX	10
130 
131 struct ifp_al_addr_pair {
132 	uchar_t	ifp_al_pa;
133 	uchar_t	ifp_hard_address;
134 	uchar_t	ifp_inq_dtype;
135 	uchar_t	ifp_node_wwn[FC_WWN_SIZE];
136 	uchar_t	ifp_port_wwn[FC_WWN_SIZE];
137 };
138 typedef struct ifp_al_addr_pair ifp_al_addr_pair_t;
139 
140 struct ifp_al_map {
141 	short			ifp_count;
142 	ifp_al_addr_pair_t	ifp_addr_pair[IFP_NUM_ENTRIES_IN_MAP];
143 	ifp_al_addr_pair_t	ifp_hba_addr;
144 };
145 typedef struct ifp_al_map ifp_al_map_t;
146 
147 struct adisc_payload {
148 	uint_t	adisc_hardaddr;
149 	uchar_t	adisc_portwwn[8];
150 	uchar_t	adisc_nodewwn[8];
151 	uint_t	adisc_dest;
152 };
153 
154 struct rls_payload {
155 	uint_t	rls_portno;
156 	uint_t	rls_linkfail;
157 	uint_t	rls_syncfail;
158 	uint_t	rls_sigfail;
159 	uint_t	rls_primitiverr;
160 	uint_t	rls_invalidword;
161 	uint_t	rls_invalidcrc;
162 };
163 typedef struct rls_payload rls_payload_t;
164 
165 struct ifp_target_stats {
166 	int	logouts_recvd;
167 					/*
168 					 * unsolicited LOGOs recvd from
169 					 * target
170 					 */
171 	int	task_mgmt_failures;
172 	int	data_ro_mismatches;
173 	int	dl_len_mismatches;
174 };
175 typedef struct ifp_target_stats ifp_target_stats_t;
176 
177 struct ifp_stats {
178 	int	version;		/* version of this struct */
179 	int	lip_count;		/* lips forced by ifp */
180 	int	ncmds;			/* outstanding commands */
181 	ifp_target_stats_t tstats[IFP_NUM_ENTRIES_IN_MAP]; /* per tgt stats */
182 };
183 typedef struct ifp_stats ifp_stats_t;
184 
185 /* XXX temp hack to get sf/socal ioctls used by luxadm to work with ifp */
186 
187 #if !defined(SFIOCGMAP)
188 #define	SFIOCGMAP		((0xda << 8)|1)
189 #endif
190 #if !defined(FCIO_GETMAP)
191 #define	FCIO_GETMAP		(('F' << 8)|175)
192 struct lilpmap {
193 	ushort_t lilp_magic;
194 	ushort_t lilp_myalpa;
195 	uchar_t  lilp_length;
196 	uchar_t  lilp_list[127];
197 };
198 #endif
199 
200 /*
201  * Structure used for diag loopback commands.
202  * This is copied from socalvar.h and must
203  * remain the same as for the socal driver.
204  */
205 typedef	struct flb_hdr {
206 	uint_t max_length;
207 	uint_t length;
208 } flb_hdr_t;
209 /* This is the max loopback transfer size */
210 #define	MAX_LOOPBACK		65536
211 
212 #if !defined(FCIO_FORCE_LIP)
213 #define	FCIO_FORCE_LIP		(('F' << 8)|177)
214 #endif
215 #if !defined(FCIO_LINKSTATUS)
216 #define	FCIO_LINKSTATUS		(('F' << 8)|183)
217 #endif
218 #if !defined(FCIO_FCODE_MCODE_VERSION)
219 #define	FCIO_FCODE_MCODE_VERSION	(('F' << 8)|202)
220 #endif
221 struct ifp_fm_version {
222 	int	fcode_ver_len;
223 	int	mcode_ver_len;
224 	int	prom_ver_len;
225 	caddr_t	fcode_ver;
226 	caddr_t	mcode_ver;
227 	caddr_t	prom_ver;
228 };
229 #if defined(_LP64)
230 struct ifp_fm_version32 {
231 	int		fcode_ver_len;
232 	int		mcode_ver_len;
233 	int		prom_ver_len;
234 	caddr32_t	fcode_ver;
235 	caddr32_t	mcode_ver;
236 	caddr32_t	prom_ver;
237 };
238 #endif
239 
240 /* XXX end temp hack to get sf/socal ioctls used by luxadm to work with ifp */
241 
242 struct ifp_diag_mbox {
243 	ushort_t	ifp_in_mbox[8];	/* in regs -- from ISP */
244 	ushort_t	ifp_out_mbox[8];	/* out regs -- to ISP */
245 };
246 typedef struct ifp_diag_mbox ifp_diag_mbox_t;
247 
248 struct ifp_diag_regs {
249 	ushort_t		ifpd_mailbox[8];
250 	ushort_t		ifpd_hccr;
251 	ushort_t		ifpd_bus_sema;
252 	ushort_t		ifpd_isr;
253 	ushort_t		ifpd_icr;
254 	ushort_t		ifpd_icsr;
255 	ushort_t		ifpd_cdma_count;
256 	uint_t			ifpd_cdma_addr;
257 	ushort_t		ifpd_cdma_status;
258 	ushort_t		ifpd_cdma_control;
259 	uint_t			ifpd_rdma_count;
260 	uint_t			ifpd_rdma_addr;
261 	ushort_t		ifpd_rdma_status;
262 	ushort_t		ifpd_rdma_control;
263 	uint_t			ifpd_tdma_count;
264 	uint_t			ifpd_tdma_addr;
265 	ushort_t		ifpd_tdma_status;
266 	ushort_t		ifpd_tdma_control;
267 	ushort_t		ifpd_risc_reg[16];
268 	ushort_t		ifpd_risc_psr;
269 	ushort_t		ifpd_risc_ivr;
270 	ushort_t		ifpd_risc_pcr;
271 	ushort_t		ifpd_risc_rar0;
272 	ushort_t		ifpd_risc_rar1;
273 	ushort_t		ifpd_risc_lcr;
274 	ushort_t		ifpd_risc_pc;
275 	ushort_t		ifpd_risc_mtr;
276 	ushort_t		ifpd_risc_sp;
277 	ushort_t		ifpd_request_in;
278 	ushort_t		ifpd_request_out;
279 	ushort_t		ifpd_response_in;
280 	ushort_t		ifpd_response_out;
281 	void			*ifpd_current_req_ptr;
282 	void			*ifpd_base_req_ptr;
283 	void			*ifpd_current_resp_ptr;
284 	void			*ifpd_base_resp_ptr;
285 };
286 typedef struct ifp_diag_regs ifp_diag_regs_t;
287 
288 struct ifp_diag_cmd {
289 	short		ifp_cmds_rev;		/* revision */
290 	short		ifp_cmds_current_rev;	/* rev driver expects */
291 	short		ifp_cmds_count;		/* number of cmds */
292 	short		ifp_cmds_done;		/* number of cmds done */
293 	ifp_diag_regs_t	ifp_regs;		/* reg dump area */
294 	ifp_diag_mbox_t	ifp_mbox[IFP_DIAG_MAX_MBOX];	/* mbox values */
295 };
296 typedef struct ifp_diag_cmd ifp_diag_cmd_t;
297 
298 #define	IFP_DIAG_CMD_REV	0x1		/* diag cmd rev supported */
299 
300 #ifdef	__cplusplus
301 }
302 #endif
303 
304 #endif	/* _SYS_SCSI_ADAPTERS_IFPIO_H */
305