summaryrefslogtreecommitdiff
path: root/usr/src/uts/common/sys/fibre-channel/fcio.h
blob: 6584459fce1493ff8fb472fdbf74d2f463c06282 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License (the "License").
 * You may not use this file except in compliance with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*
 * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
 * Use is subject to license terms.
 */

#ifndef	_FCIO_H
#define	_FCIO_H


#include <sys/note.h>
#include <sys/fibre-channel/fc_types.h>
#include <sys/fibre-channel/fc_appif.h>

#ifdef	__cplusplus
extern "C" {
#endif

/*
 * ioctl definitions
 */
#define	FCTIO				('F'<< 8)

/*
 * New ioctl definitions
 */
#define	FCIO_CMD			(FCTIO | 1998)
#define	FCIO_SUB_CMD			('Z' << 8)
#define	FCIO_GET_NUM_DEVS		(FCIO_SUB_CMD + 0x01)
#define	FCIO_GET_DEV_LIST		(FCIO_SUB_CMD + 0x02)
#define	FCIO_GET_SYM_PNAME		(FCIO_SUB_CMD + 0x03)
#define	FCIO_GET_SYM_NNAME		(FCIO_SUB_CMD + 0x04)
#define	FCIO_SET_SYM_PNAME		(FCIO_SUB_CMD + 0x05)
#define	FCIO_SET_SYM_NNAME		(FCIO_SUB_CMD + 0x06)
#define	FCIO_GET_LOGI_PARAMS		(FCIO_SUB_CMD + 0x07)
#define	FCIO_DEV_LOGIN			(FCIO_SUB_CMD + 0x08)
#define	FCIO_DEV_LOGOUT			(FCIO_SUB_CMD + 0x09)
#define	FCIO_GET_STATE			(FCIO_SUB_CMD + 0x0A)
#define	FCIO_DEV_REMOVE			(FCIO_SUB_CMD + 0x0B)
#define	FCIO_GET_FCODE_REV		(FCIO_SUB_CMD + 0x0C)
#define	FCIO_GET_FW_REV			(FCIO_SUB_CMD + 0x0D)
#define	FCIO_GET_DUMP_SIZE		(FCIO_SUB_CMD + 0x0E)
#define	FCIO_FORCE_DUMP			(FCIO_SUB_CMD + 0x0F)
#define	FCIO_GET_DUMP			(FCIO_SUB_CMD + 0x10)
#define	FCIO_GET_TOPOLOGY		(FCIO_SUB_CMD + 0x11)
#define	FCIO_RESET_LINK			(FCIO_SUB_CMD + 0x12)
#define	FCIO_RESET_HARD			(FCIO_SUB_CMD + 0x13)
#define	FCIO_RESET_HARD_CORE		(FCIO_SUB_CMD + 0x14)
#define	FCIO_DIAG			(FCIO_SUB_CMD + 0x15)
#define	FCIO_NS				(FCIO_SUB_CMD + 0x16)
#define	FCIO_DOWNLOAD_FW		(FCIO_SUB_CMD + 0x17)
#define	FCIO_GET_HOST_PARAMS		(FCIO_SUB_CMD + 0x18)
#define	FCIO_LINK_STATUS		(FCIO_SUB_CMD + 0x19)
#define	FCIO_DOWNLOAD_FCODE		(FCIO_SUB_CMD + 0x1A)
#define	FCIO_GET_NODE_ID		(FCIO_SUB_CMD + 0x1B)
#define	FCIO_SET_NODE_ID		(FCIO_SUB_CMD + 0x1C)
#define	FCIO_SEND_NODE_ID		(FCIO_SUB_CMD + 0x1D)

/*
 * IOCTLs to handle T11's FC-HBA library
 */
#define	FCIO_GET_ADAPTER_ATTRIBUTES	(FCIO_SUB_CMD + 0x1E)
#define	FCIO_GET_OTHER_ADAPTER_PORTS	(FCIO_SUB_CMD + 0x1F)
#define	FCIO_GET_ADAPTER_PORT_ATTRIBUTES    (FCIO_SUB_CMD + 0x20)
#define	FCIO_GET_DISCOVERED_PORT_ATTRIBUTES (FCIO_SUB_CMD + 0x21)
#define	FCIO_GET_PORT_ATTRIBUTES	(FCIO_SUB_CMD + 0x22)
#define	FCIO_GET_ADAPTER_PORT_STATS	(FCIO_SUB_CMD + 0x23)
#define	FCIO_GET_ADAPTER_PORT_NPIV_ATTRIBUTES   (FCIO_SUB_CMD + 0x24)
#define	FCIO_CREATE_NPIV_PORT		(FCIO_SUB_CMD + 0x25)
#define	FCIO_GET_NPIV_ATTRIBUTES	(FCIO_SUB_CMD + 0x26)
#define	FCIO_GET_DISCOVERED_NPIV_ATTRIBUTES	(FCIO_SUB_CMD + 0x27)
#define	FCIO_GET_NPIV_PORT_LIST		(FCIO_SUB_CMD + 0x28)
#define	FCIO_DELETE_NPIV_PORT		(FCIO_SUB_CMD + 0x29)
#define	FCIO_NPIV_GET_ADAPTER_ATTRIBUTES	(FCIO_SUB_CMD + 0x2a)


/*
 * Fixed diag_codes for FCIO_DIAG. These is supported by all FCAs.
 * No FCA should define ioctls in this range.
 */
#define	FCIO_DIAG_PORT_DISABLE		(FCIO_SUB_CMD + 0x80)
#define	FCIO_DIAG_PORT_ENABLE		(FCIO_SUB_CMD + 0x81)

/* cmd_flags for FCIO_LINK_STATUS ioctl */
#define	FCIO_CFLAGS_RLS_DEST_NPORT	0x0000
#define	FCIO_CFLAGS_RLS_DEST_FPORT	0x0001

/*
 * Note about fc_port_dev_t structure : The dev_did.priv_lilp_posit field will
 * return the lilp map position of the port for diagnostics to use.
 * It is important to note that dev_did.priv_lilp_posit field will only have
 * valid loop position for Private Loop devices ONLY and the value
 * contained in this field for other topologies will be undetermined.
 */
typedef struct fc_port_dev {
	uchar_t		dev_dtype;		/* SCSI device type */
	uint32_t	dev_type[8];		/* protocol specific */
	uint32_t	dev_state;		/* port state */
	fc_portid_t	dev_did;		/* Destination Identifier */
	fc_hardaddr_t	dev_hard_addr;		/* Hard address */
	la_wwn_t	dev_pwwn;		/* port WWN */
	la_wwn_t	dev_nwwn;		/* node WWN */
} fc_port_dev_t;

#if defined(_SYSCALL32)

#if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4
#pragma pack(4)
#endif

typedef struct fc_port_dev32 {
	uchar_t		dev_dtype;		/* SCSI device type */
	uint32_t	dev_type[8];		/* protocol specific */
	uint32_t	dev_state;		/* port state */
	fc_portid_t	dev_did;		/* Destination Identifier */
	fc_hardaddr_t	dev_hard_addr;		/* Hard address */
	la_wwn_t	dev_pwwn;		/* port WWN */
	la_wwn_t	dev_nwwn;		/* node WWN */
} fc_port_dev32_t;

#if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4
#pragma pack()
#endif

#endif	/* _SYSCALL32 */

typedef struct fc_port_dev fc_ns_map_entry_t;

/*
 * fcio_xfer definitions
 */
#define	FCIO_XFER_NONE		0x00
#define	FCIO_XFER_READ		0x01
#define	FCIO_XFER_WRITE		0x02
#define	FCIO_XFER_RW		(FCIO_XFER_READ | FCIO_XFER_WRITE)

typedef struct fcio {
	uint16_t	fcio_xfer;	/* direction */
	uint16_t	fcio_cmd;	/* sub command */
	uint16_t	fcio_flags;	/* flags */
	uint16_t	fcio_cmd_flags;	/* command specific flags */
	size_t		fcio_ilen;	/* Input buffer length */
	caddr_t		fcio_ibuf;	/* Input buffer */
	size_t		fcio_olen;	/* Output buffer length */
	caddr_t		fcio_obuf;	/* Output buffer */
	size_t		fcio_alen;	/* Auxillary buffer length */
	caddr_t		fcio_abuf;	/* Auxillary buffer */
	int		fcio_errno;	/* FC internal error code */
} fcio_t;

/*
 * T11 FC-HBA exchange structures
 */
#define	FC_HBA_LIST_VERSION		    1
typedef struct fc_hba_list {
	uint32_t		version;    /* Set to FC_HBA_LIST_VERSION */
	uint32_t		numAdapters;
	uint64_t		reserved;
	char			hbaPaths[1][MAXPATHLEN]; /* numAdapters long */
} fc_hba_list_t;

#define	FC_HBA_NPIV_PORT_LIST_VERSION	1
typedef struct fc_hba_npiv_port_list {
	uint32_t		version;
	uint32_t		numAdapters;
	uint64_t		reserved;
	char			hbaPaths[1][MAXPATHLEN];
} fc_hba_npiv_port_list_t;

#define	FC_HBA_NPIV_ATTRIBUTES_VERSION	1
typedef struct fc_hba_npiv_attributes {
	uint32_t		version;
	la_wwn_t		NodeWWN;
	la_wwn_t		PortWWN;
	fc_hba_state_change_t	lastChange;
} fc_hba_npiv_attributes_t;

#define	FC_HBA_PORT_NPIV_ATTRIBUTES_VERSION	1
typedef struct fc_hba_port_npiv_attributes {
	uint32_t		version;
	int			npivflag;
	fc_hba_state_change_t	lastChange;
	la_wwn_t		NodeWWN;
	la_wwn_t		PortWWN;
	uint32_t		MaxNumberOfNPIVPorts;
	uint32_t		NumberOfNPIVPorts;
} fc_hba_port_npiv_attributes_t;

#define	FC_HBA_SINGLE_VERSION		    1
typedef struct fc_hba_single {
	uint32_t		version;    /* Set to FC_HBA_SINGLE_VERSION */
	uint64_t		reserved;
	char			hbaPath[MAXPATHLEN];
} fc_hba_single_t;

#define	FC_HBA_ADAPTER_ATTRIBUTES_VERSION   1
typedef struct fc_hba_adapter_attributes {
	uint32_t    version;	/* Set to FC_HBA_ADAPTER_ATTRIBUTES_VERSION */
	char	    Manufacturer[64];
	char	    SerialNumber[64];
	char	    Model[256];
	char	    ModelDescription[256];
	la_wwn_t    NodeWWN;
	char	    NodeSymbolicName[256];
	char	    HardwareVersion[256];
	char	    DriverVersion[256];
	char	    OptionROMVersion[256];
	char	    FirmwareVersion[256];
	uint32_t    VendorSpecificID;
	uint32_t    NumberOfPorts;
	char	    DriverName[256];
	uint64_t    reserved;
} fc_hba_adapter_attributes_t;

#if defined(_SYSCALL32)

#if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4
#pragma pack(4)
#endif

typedef struct fc_hba_adapter_attributes32 {
	uint32_t    version;	/* Set to FC_HBA_ADAPTER_ATTRIBUTES_VERSION */
	char	    Manufacturer[64];
	char	    SerialNumber[64];
	char	    Model[256];
	char	    ModelDescription[256];
	la_wwn_t    NodeWWN;
	char	    NodeSymbolicName[256];
	char	    HardwareVersion[256];
	char	    DriverVersion[256];
	char	    OptionROMVersion[256];
	char	    FirmwareVersion[256];
	uint32_t    VendorSpecificID;
	uint32_t    NumberOfPorts;
	char	    DriverName[256];
	uint64_t    reserved;
} fc_hba_adapter_attributes32_t;

#if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4
#pragma pack()
#endif

#endif	/* defined(_SYSCALL32) */

#define	FC_HBA_PORT_ATTRIBUTES_VERSION	    1
typedef struct fc_hba_port_attributes {
	uint32_t		version; /* FC_HBA_PORT_ATTRIBUTES_VERSION */
	fc_hba_state_change_t	lastChange;
	minor_t			fp_minor;
	la_wwn_t		NodeWWN;
	la_wwn_t		PortWWN;
	uint32_t		PortFcId;
	uint32_t		PortType;
	uint32_t		PortState;
	uint32_t		PortSupportedClassofService;
	uint8_t			PortSupportedFc4Types[32];
	uint8_t			PortActiveFc4Types[32];
	char			PortSymbolicName[256];
	uint32_t		PortSupportedSpeed;
	uint32_t		PortSpeed;
	uint32_t		PortMaxFrameSize;
	la_wwn_t		FabricName;
	uint32_t		NumberofDiscoveredPorts;
	uint64_t		reserved;
} fc_hba_port_attributes_t;

#if defined(_SYSCALL32)

#if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4
#pragma pack(4)
#endif

typedef struct fc_hba_port_attributes32 {
	uint32_t		version; /* FC_HBA_PORT_ATTRIBUTES_VERSION */
	fc_hba_state_change_t	lastChange;
	minor_t			fp_minor;
	la_wwn_t		NodeWWN;
	la_wwn_t		PortWWN;
	uint32_t		PortFcId;
	uint32_t		PortType;
	uint32_t		PortState;
	uint32_t		PortSupportedClassofService;
	uint8_t			PortSupportedFc4Types[32];
	uint8_t			PortActiveFc4Types[32];
	char			PortSymbolicName[256];
	uint32_t		PortSupportedSpeed;
	uint32_t		PortSpeed;
	uint32_t		PortMaxFrameSize;
	la_wwn_t		FabricName;
	uint32_t		NumberofDiscoveredPorts;
	uint64_t		reserved;
} fc_hba_port_attributes32_t;

#if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4
#pragma pack()
#endif

#endif	/* defined(_SYSCALL32) */

#define	FC_HBA_ADAPTER_PORT_STATS_VERSION   1
typedef struct fc_hba_adapter_port_stats {
	uint32_t	    version; /* FC_HBA_ADAPTER_PORT_STATS_VERSION */
	uint64_t	    SecondsSinceLastReset;
	uint64_t	    TxFrames;
	uint64_t	    TxWords;
	uint64_t	    RxFrames;
	uint64_t	    RxWords;
	uint64_t	    LIPCount;
	uint64_t	    NOSCount;
	uint64_t	    ErrorFrames;
	uint64_t	    DumpedFrames;
	uint64_t	    LinkFailureCount;
	uint64_t	    LossOfSyncCount;
	uint64_t	    LossOfSignalCount;
	uint64_t	    PrimitiveSeqProtocolErrCount;
	uint64_t	    InvalidTxWordCount;
	uint64_t	    InvalidCRCCount;
	uint64_t	    reserved;
} fc_hba_adapter_port_stats_t;


/*
 * Constant values derived from T11 FC-HBA
 */
#define	FC_HBA_PORTTYPE_UNKNOWN		1   /* Unknown */
#define	FC_HBA_PORTTYPE_OTHER		2   /* Other */
#define	FC_HBA_PORTTYPE_NOTPRESENT	3   /* Not present */
#define	FC_HBA_PORTTYPE_NPORT		5   /* Fabric  */
#define	FC_HBA_PORTTYPE_NLPORT		6   /* Public Loop */
#define	FC_HBA_PORTTYPE_FLPORT		7
#define	FC_HBA_PORTTYPE_FPORT		8   /* Fabric Port */
#define	FC_HBA_PORTTYPE_EPORT		9   /* Fabric expansion port */
#define	FC_HBA_PORTTYPE_GPORT		10  /* Generic Fabric Port */
#define	FC_HBA_PORTTYPE_LPORT		20  /* Private Loop */
#define	FC_HBA_PORTTYPE_PTP		21  /* Point to Point */

#define	FC_HBA_PORTSTATE_UNKNOWN	1   /* Unknown */
#define	FC_HBA_PORTSTATE_ONLINE		2   /* Operational */
#define	FC_HBA_PORTSTATE_OFFLINE	3   /* User Offline */
#define	FC_HBA_PORTSTATE_BYPASSED	4   /* Bypassed */
#define	FC_HBA_PORTSTATE_DIAGNOSTICS	5   /* In diagnostics mode */
#define	FC_HBA_PORTSTATE_LINKDOWN	6   /* Link Down */
#define	FC_HBA_PORTSTATE_ERROR		7   /* Port Error */
#define	FC_HBA_PORTSTATE_LOOPBACK	8   /* Loopback */



#if defined(_SYSCALL32)
/*
 * 32 bit varient of fcio_t; to be used
 * only in the driver and NOT applications
 */
struct fcio32 {
	uint16_t	fcio_xfer;	/* direction */
	uint16_t	fcio_cmd;	/* sub command */
	uint16_t	fcio_flags;	/* flags */
	uint16_t	fcio_cmd_flags;	/* command specific flags */
	size32_t	fcio_ilen;	/* Input buffer length */
	caddr32_t	fcio_ibuf;	/* Input buffer */
	size32_t	fcio_olen;	/* Output buffer length */
	caddr32_t	fcio_obuf;	/* Output buffer */
	size32_t	fcio_alen;	/* Auxillary buffer length */
	caddr32_t	fcio_abuf;	/* Auxillary buffer */
	int		fcio_errno;	/* FC internal error code */
};

#if	!defined(__lint)
_NOTE(SCHEME_PROTECTS_DATA("unique per request", fcio32))
#endif /* __lint */

#endif /* _SYSCALL32 */

#if	!defined(__lint)
_NOTE(SCHEME_PROTECTS_DATA("unique per request", fcio fc_port_dev))
#endif /* __lint */

#ifdef	__cplusplus
}
#endif

#endif	/* _FCIO_H */