xref: /illumos-gate/usr/src/uts/common/sys/fc4/fcio.h (revision 42b53e0fbc5c05289c3d334bb864b784fafe5ce4)
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, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 
23 /*
24  * Copyright (c) 1998-1999 by Sun Microsystems, Inc.
25  * All rights reserved.
26  */
27 
28 #ifndef	_SYS_FC4_FCIO_H
29 #define	_SYS_FC4_FCIO_H
30 
31 /*
32  * Include any headers you depend on.
33  */
34 
35 #ifdef	__cplusplus
36 extern "C" {
37 #endif
38 
39 #include <sys/fc4/fcal_linkapp.h>
40 
41 /*
42  * ioctl definitions
43  */
44 #define	FIOC	('F'<<8)
45 #define	SF_IOC	(0xda << 8)
46 #define	SFIOCGMAP	(SF_IOC|1)	/* Get device map */
47 #define	SF_NUM_ENTRIES_IN_MAP	127
48 
49 #define	FCIO_GETMAP		(FIOC|175)	/* Get limited map */
50 #define	FCIO_FORCE_LIP		(FIOC|177)	/* Force LIP */
51 #define	FCIO_LINKSTATUS		(FIOC|183)	/* Get link status */
52 #define	FCIO_FCODE_MCODE_VERSION	(FIOC|202) /* Get code versions */
53 
54 #define	IFPIOCGMAP		SFIOCGMAP
55 #define	IFP_NUM_ENTRIES_IN_MAP	SF_NUM_ENTRIES_IN_MAP
56 #define	IFPIO_FORCE_LIP		FCIO_FORCE_LIP
57 #define	IFPIO_LINKSTATUS	FCIO_LINKSTATUS
58 
59 typedef struct sf_al_addr_pair {
60 	uchar_t	sf_al_pa;
61 	uchar_t	sf_hard_address;
62 	uchar_t	sf_inq_dtype;
63 	uchar_t	sf_node_wwn[FC_WWN_SIZE];
64 	uchar_t	sf_port_wwn[FC_WWN_SIZE];
65 } sf_al_addr_pair_t;
66 
67 typedef struct sf_al_map {
68 	short			sf_count;
69 	sf_al_addr_pair_t	sf_addr_pair[SF_NUM_ENTRIES_IN_MAP];
70 	sf_al_addr_pair_t	sf_hba_addr;
71 } sf_al_map_t;
72 
73 
74 
75 struct rls_payload {
76 	uint_t	rls_portno;
77 	uint_t	rls_linkfail;
78 	uint_t	rls_syncfail;
79 	uint_t	rls_sigfail;
80 	uint_t	rls_primitiverr;
81 	uint_t	rls_invalidword;
82 	uint_t	rls_invalidcrc;
83 };
84 
85 struct lilpmap {
86 	ushort_t lilp_magic;
87 	ushort_t lilp_myalpa;
88 	uchar_t  lilp_length;
89 	uchar_t  lilp_list[127];
90 };
91 
92 
93 struct socal_fm_version {
94 	uint_t	fcode_ver_len;
95 	uint_t	mcode_ver_len;
96 	uint_t	prom_ver_len;
97 	char	*fcode_ver;
98 	char	*mcode_ver;
99 	char	*prom_ver;
100 };
101 
102 /*
103  * kstat structures
104  */
105 typedef struct sf_target_stats {
106 	uint_t	els_failures;		/* failures on PLOGI, PRLI, ADISC etc */
107 	uint_t	timeouts;
108 					/*
109 					 * sf detected command timeouts,
110 					 * implies an ABTS
111 					 */
112 	uint_t	abts_failures;		/* ABTS failures */
113 	uint_t	task_mgmt_failures;
114 					/*
115 					 * SF task management(aborts,
116 					 * resets etc) failures
117 					 */
118 	uint_t	data_ro_mismatches;	/* SF_DATA RO mismatches */
119 	uint_t	dl_len_mismatches;
120 					/*
121 					 * SF_DATA length different from
122 					 * BURST_LEN
123 					 */
124 	uint_t	logouts_recvd;
125 					/*
126 					 * unsolicited LOGOs recvd from
127 					 * target
128 					 */
129 } sf_target_stats_t;
130 
131 typedef	struct sf_stats {
132 	uint_t	version;		/* version of this struct, >1 */
133 	uint_t	lip_count;		/* lips forced by sf */
134 	uint_t	lip_failures;
135 					/*
136 					 * lip failures, ie, no ONLINE response
137 					 * after forcing lip
138 					 */
139 	uint_t	cralloc_failures;
140 					/*
141 					 * command/response block allocation
142 					 * failures
143 					 */
144 	uint_t	ncmds;			/* outstanding commands */
145 	uint_t	throttle_limit;		/* current throttle limit */
146 	uint_t	cr_pool_size;
147 					/*
148 					 * num of chunks in command/response
149 					 * pool, each chunk allows 128 packets
150 					 */
151 	struct	sf_target_stats tstats[127]; /* per target stats */
152 	char	drvr_name[MAXNAMELEN];	/* Name of driver, NULL term. */
153 } sf_stats_t;
154 
155 
156 /* SOCAL Host Adapter kstat structures. */
157 #define	FC_STATUS_ENTRIES	256
158 struct fc_pstats {
159 	uint_t   port;		/* which port  0 or 1 */
160 	uint_t   requests;	/* requests issued by this soc+ */
161 	uint_t   sol_resps;	/* solicited responses received */
162 	uint_t   unsol_resps;	/* unsolicited responses received */
163 	uint_t   lips;		/* forced loop initialization */
164 	uint_t   els_sent;	/* extended link service commands issued */
165 	uint_t   els_rcvd;	/* extended link service commands received */
166 	uint_t   abts;		/* aborts attempted */
167 	uint_t   abts_ok;	/* aborts successful */
168 	uint_t   offlines;	/* changes to offline state */
169 	uint_t   onlines;	/* changes to online state */
170 	uint_t   online_loops;	/* changes to online-loop state */
171 	uint_t   resp_status[FC_STATUS_ENTRIES];	/* response status */
172 };
173 
174 /*
175  * Fibre Channel Response codes
176  */
177 #define	FCAL_STATUS_OK			0
178 #define	FCAL_STATUS_P_RJT		2
179 #define	FCAL_STATUS_F_RJT		3
180 #define	FCAL_STATUS_P_BSY		4
181 #define	FCAL_STATUS_F_BSY		5
182 #define	FCAL_STATUS_ONLINE		0x10
183 #define	FCAL_STATUS_OLDPORT_ONLINE	FCAL_STATUS_ONLINE
184 #define	FCAL_STATUS_ERR_OFFLINE		0x11
185 #define	FCAL_STATUS_TIMEOUT		0x12
186 #define	FCAL_STATUS_ERR_OVERRUN		0x13
187 #define	FCAL_STATUS_LOOP_ONLINE		0x14
188 #define	FCAL_STATUS_OLD_PORT		0x15
189 #define	FCAL_STATUS_AL_PORT		0x16
190 #define	FCAL_STATUS_UNKNOWN_CQ_TYPE	0x20	/* unknown request type */
191 #define	FCAL_STATUS_BAD_SEG_CNT		0x21	/* insufficient # of segments */
192 #define	FCAL_STATUS_MAX_XCHG_EXCEEDED	0x22
193 #define	FCAL_STATUS_BAD_XID		0x23
194 #define	FCAL_STATUS_XCHG_BUSY		0x24
195 #define	FCAL_STATUS_BAD_POOL_ID		0x25
196 #define	FCAL_STATUS_INSUFFICIENT_CQES	0x26
197 #define	FCAL_STATUS_ALLOC_FAIL		0x27
198 #define	FCAL_STATUS_BAD_SID		0x28
199 #define	FCAL_STATUS_NO_SEQ_INIT		0x29
200 #define	FCAL_STATUS_BAD_DID		0x2a
201 #define	FCAL_STATUS_ABORTED		0x30
202 #define	FCAL_STATUS_ABORT_FAILED	0x31
203 #define	FCAL_STATUS_DIAG_BUSY		0x32
204 #define	FCAL_STATUS_DIAG_INVALID	0x33
205 #define	FCAL_STATUS_INCOMPLETE_DMA_ERR	0x34
206 #define	FCAL_STATUS_CRC_ERR		0x35
207 #define	FCAL_STATUS_OPEN_FAIL		0x36
208 #define	FCAL_STATUS_ERROR		0x80
209 #define	FCAL_STATUS_ONLINE_TIMEOUT	0x81
210 #define	FCAL_STATUS_MAX_STATUS		FCAL_STATUS_CRC_ERR
211 
212 typedef struct socal_stats {
213 	uint_t   version;	/* version of this struct, >1 */
214 	uint_t   resets;		/* chip resets */
215 	uint_t   reqq_intrs;	/* request queue interrupts */
216 	uint_t   qfulls;		/* request queue full encountered */
217 	struct	fc_pstats pstats[2]; /* per port kstats */
218 	char	drvr_name[MAXNAMELEN];	/* Name of driver, NULL term. */
219 	char	fw_revision[MAXNAMELEN];	/* Firmware date string.\0 */
220 	char	node_wwn[17];		/* Node WWN */
221 	char	port_wwn[2][17];	/* Port WWN \0 */
222 	uint_t	parity_chk_enabled;	/* != 0 if HBA checks parity. */
223 } socal_stats_t;
224 
225 
226 struct ifp_target_stats {
227 	int	logouts_recvd;
228 					/*
229 					 * unsolicited LOGOs recvd from
230 					 * target
231 					 */
232 	int	task_mgmt_failures;
233 	int	data_ro_mismatches;
234 	int	dl_len_mismatches;
235 };
236 typedef struct ifp_target_stats ifp_target_stats_t;
237 
238 struct ifp_stats {
239 	int	version;		/* version of this struct, >1 */
240 	int	lip_count;		/* lips forced by ifp */
241 	int	ncmds;			/* outstanding commands */
242 	ifp_target_stats_t tstats[127]; /* per target stats */
243 	char	drvr_name[MAXNAMELEN];	/* Name of driver, NULL term. */
244 	char	fw_revision[MAXNAMELEN];	/* Firmware date string.\0 */
245 	char	node_wwn[17];		/* Node WWN */
246 	char	port_wwn[17];		/* Port WWN \0 */
247 	uint_t	parity_chk_enabled;	/* != 0 if HBA checks parity. */
248 	uint_t   resp_status[FC_STATUS_ENTRIES];	/* response status */
249 };
250 typedef struct ifp_stats ifp_stats_t;
251 
252 /*
253  * Defines for the QLA21xx resp_status -- this is the command completion status
254  */
255 #define	IFP_CMD_CMPLT		0x00	/* no transport errors */
256 #define	IFP_CMD_INCOMPLETE	0x01	/* abnormal transport state */
257 #define	IFP_CMD_DMA_DERR	0x02	/* DMA direction error */
258 #define	IFP_CMD_TRAN_ERR	0x03	/* unspecified transport error */
259 #define	IFP_CMD_RESET		0x04	/* reset aborted transport */
260 #define	IFP_CMD_ABORTED		0x05	/* aborted on request */
261 #define	IFP_CMD_TIMEOUT		0x06	/* command timed out */
262 #define	IFP_CMD_DATA_OVR	0x07	/* data overrun--discard extra */
263 #define	IFP_CMD_ABORT_REJECTED	0x0e	/* target rejected abort msg */
264 #define	IFP_CMD_RESET_REJECTED	0x12	/* target rejected reset msg */
265 #define	IFP_CMD_DATA_UNDER	0x15	/* data underrun */
266 #define	IFP_CMD_QUEUE_FULL	0x1c	/* queue full SCSI status */
267 #define	IFP_CMD_PORT_UNAVAIL	0x28	/* port unavailable */
268 #define	IFP_CMD_PORT_LOGGED_OUT	0x29	/* port loged out */
269 #define	IFP_CMD_PORT_CONFIG_CHANGED 0x2a	/* port name changed */
270 
271 
272 
273 #ifdef	__cplusplus
274 }
275 #endif
276 
277 #endif	/* _SYS_FC4_FCIO_H */
278