xref: /illumos-gate/usr/src/uts/common/sys/fctio.h (revision 3ed623140e27064f81020d9d47f9fb17489d1190)
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 2009 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 #ifndef	_FCTIO_H
26 #define	_FCTIO_H
27 
28 #ifdef	__cplusplus
29 extern "C" {
30 #endif
31 
32 #define	FCT_IOCTL			(((uint32_t)'F') << 24)
33 #define	FCTIO_CMD			(FCT_IOCTL | 2007)
34 #define	FCTIO_SUB_CMD			('Z' << 8)
35 #define	FCTIO_ADAPTER_LIST			(FCTIO_SUB_CMD + 0x01)
36 #define	FCTIO_GET_ADAPTER_ATTRIBUTES		(FCTIO_SUB_CMD + 0x02)
37 #define	FCTIO_GET_ADAPTER_PORT_ATTRIBUTES	(FCTIO_SUB_CMD + 0x03)
38 #define	FCTIO_GET_DISCOVERED_PORT_ATTRIBUTES	(FCTIO_SUB_CMD + 0x04)
39 #define	FCTIO_GET_PORT_ATTRIBUTES		(FCTIO_SUB_CMD + 0x05)
40 #define	FCTIO_GET_ADAPTER_PORT_STATS		(FCTIO_SUB_CMD + 0x06)
41 #define	FCTIO_GET_LINK_STATUS			(FCTIO_SUB_CMD + 0x07)
42 
43 /*
44  * fcio_xfer definitions
45  */
46 #define	FCTIO_XFER_NONE		0x00
47 #define	FCTIO_XFER_READ		0x01
48 #define	FCTIO_XFER_WRITE	0x02
49 #define	FCTIO_XFER_RW		(FCTIO_XFER_READ | FCTIO_XFER_WRITE)
50 
51 typedef struct fctio {
52 	uint16_t	fctio_xfer;		/* direction */
53 	uint16_t	fctio_cmd;		/* sub command */
54 	uint16_t	fctio_flags;		/* flags */
55 	uint16_t	fctio_cmd_flags;	/* command specific flags */
56 	uint32_t	fctio_ilen;		/* Input buffer length */
57 	uint32_t	fctio_olen;		/* Output buffer length */
58 	uint32_t	fctio_alen;		/* Auxillary buffer length */
59 	uint32_t	fctio_errno;		/* FC internal error code */
60 	uint64_t	fctio_ibuf;		/* Input buffer */
61 	uint64_t	fctio_obuf;		/* Output buffer */
62 	uint64_t	fctio_abuf;		/* Auxillary buffer */
63 } fctio_t;
64 
65 #define	FCT_HBA_LIST_VERSION	1
66 typedef struct fc_tgt_hba_list {
67 	uint32_t	version;
68 	uint32_t	numPorts;
69 	uint8_t		port_wwn[1][8];
70 } fc_tgt_hba_list_t;
71 
72 #define	FCT_HBA_ADAPTER_ATTRIBUTES_VERSION   1
73 typedef struct fc_tgt_hba_adapter_attributes {
74 	uint32_t    version;	/* Set to FC_HBA_ADAPTER_ATTRIBUTES_VERSION */
75 	uint32_t    reserved_1;
76 	char	    Manufacturer[64];
77 	char	    SerialNumber[64];
78 	char	    Model[256];
79 	char	    ModelDescription[256];
80 	uint8_t	    NodeWWN[8];
81 	char	    NodeSymbolicName[256];
82 	char	    HardwareVersion[256];
83 	char	    DriverVersion[256];
84 	char	    OptionROMVersion[256];
85 	char	    FirmwareVersion[256];
86 	uint32_t    VendorSpecificID;
87 	uint32_t    NumberOfPorts;
88 	char	    DriverName[256];
89 	uint64_t    reserved_2;
90 } fc_tgt_hba_adapter_attributes_t;
91 
92 #define	FCT_HBA_PORT_ATTRIBUTES_VERSION	1
93 typedef struct fc_tgt_hba_port_attributes {
94 	uint32_t		version; /* FC_HBA_PORT_ATTRIBUTES_VERSION */
95 	uint32_t    		reserved_1;
96 	uint64_t		lastChange;
97 	uint8_t			NodeWWN[8];
98 	uint8_t			PortWWN[8];
99 	uint32_t		PortFcId;
100 	uint32_t		PortType;
101 	uint32_t		PortState;
102 	uint32_t		PortSupportedClassofService;
103 	uint8_t			PortSupportedFc4Types[32];
104 	uint8_t			PortActiveFc4Types[32];
105 	char			PortSymbolicName[256];
106 	uint32_t		PortSupportedSpeed;
107 	uint32_t		PortSpeed;
108 	uint32_t		PortMaxFrameSize;
109 	uint32_t		NumberofDiscoveredPorts;
110 	uint8_t			FabricName[8];
111 	uint64_t		reserved_2;
112 } fc_tgt_hba_port_attributes_t;
113 
114 #define	FCT_HBA_ADAPTER_PORT_STATS_VERSION   1
115 typedef struct fc_tgt_hba_adapter_port_stats {
116 	uint32_t		version; /* FC_HBA_ADAPTER_PORT_STATS_VERSION */
117 	uint32_t    		reserved_1;
118 	uint64_t		SecondsSinceLastReset;
119 	uint64_t		TxFrames;
120 	uint64_t		TxWords;
121 	uint64_t		RxFrames;
122 	uint64_t		RxWords;
123 	uint64_t		LIPCount;
124 	uint64_t		NOSCount;
125 	uint64_t		ErrorFrames;
126 	uint64_t		DumpedFrames;
127 	uint64_t		LinkFailureCount;
128 	uint64_t		LossOfSyncCount;
129 	uint64_t		LossOfSignalCount;
130 	uint64_t		PrimitiveSeqProtocolErrCount;
131 	uint64_t		InvalidTxWordCount;
132 	uint64_t		InvalidCRCCount;
133 	uint64_t		reserved_2;
134 } fc_tgt_hba_adapter_port_stats_t;
135 
136 /*
137  * Constant values derived from T11 FC-HBA
138  */
139 #define	FC_HBA_PORTTYPE_UNKNOWN		1	/* Unknown */
140 #define	FC_HBA_PORTTYPE_OTHER		2	/* Other */
141 #define	FC_HBA_PORTTYPE_NOTPRESENT	3	/* Not present */
142 #define	FC_HBA_PORTTYPE_NPORT		5	/* Fabric  */
143 #define	FC_HBA_PORTTYPE_NLPORT		6	/* Public Loop */
144 #define	FC_HBA_PORTTYPE_FLPORT		7
145 #define	FC_HBA_PORTTYPE_FPORT		8	/* Fabric Port */
146 #define	FC_HBA_PORTTYPE_EPORT		9	/* Fabric expansion port */
147 #define	FC_HBA_PORTTYPE_GPORT		10	/* Generic Fabric Port */
148 #define	FC_HBA_PORTTYPE_LPORT		20	/* Private Loop */
149 #define	FC_HBA_PORTTYPE_PTP		21	/* Point to Point */
150 
151 #define	FC_HBA_PORTSTATE_UNKNOWN	1	/* Unknown */
152 #define	FC_HBA_PORTSTATE_ONLINE		2	/* Operational */
153 #define	FC_HBA_PORTSTATE_OFFLINE	3	/* User Offline */
154 #define	FC_HBA_PORTSTATE_BYPASSED	4	/* Bypassed */
155 #define	FC_HBA_PORTSTATE_DIAGNOSTICS	5	/* In diagnostics mode */
156 #define	FC_HBA_PORTSTATE_LINKDOWN	6	/* Link Down */
157 #define	FC_HBA_PORTSTATE_ERROR		7	/* Port Error */
158 #define	FC_HBA_PORTSTATE_LOOPBACK	8	/* Loopback */
159 
160 /*
161  * HBA/Port attributes tracked for the T11 FC-HBA specification
162  */
163 #define	FC_HBA_PORTSPEED_UNKNOWN	0	/* Unknown - transceiver */
164 						/* incable of reporting */
165 #define	FC_HBA_PORTSPEED_1GBIT		1	/* 1 GBit/sec */
166 #define	FC_HBA_PORTSPEED_2GBIT		2	/* 2 GBit/sec */
167 #define	FC_HBA_PORTSPEED_10GBIT		4	/* 10 GBit/sec */
168 #define	FC_HBA_PORTSPEED_4GBIT		8	/* 4 GBit/sec */
169 #define	FC_HBA_PORTSPEED_8GBIT		16	/* 8 GBit/sec */
170 #define	FC_HBA_PORTSPEED_16GBIT		32	/* 16 GBit/sec */
171 #define	FC_HBA_PORTSPEED_NOT_NEGOTIATED	(1<<15)   /* Speed not established */
172 
173 #define	FCTIO_SUCCESS			0
174 #define	FCTIO_FAILURE			1
175 #define	FCTIO_BADWWN			2
176 #define	FCTIO_MOREDATA			3
177 #define	FCTIO_OUTOFBOUNDS		4
178 
179 /* Sysevent defs */
180 #define	EC_SUNFC		"EC_sunfc"
181 #define	ESC_SUNFC_PORT_ATTACH	"ESC_sunfc_port_attach"
182 #define	ESC_SUNFC_PORT_DETACH	"ESC_sunfc_port_detach"
183 #define	ESC_SUNFC_PORT_ONLINE	"ESC_sunfc_port_online"
184 #define	ESC_SUNFC_PORT_OFFLINE	"ESC_sunfc_port_offline"
185 #define	ESC_SUNFC_PORT_RSCN	"ESC_sunfc_port_rscn"
186 #define	ESC_SUNFC_TARGET_ADD	"ESC_sunfc_target_add"
187 #define	ESC_SUNFC_TARGET_REMOVE	"ESC_sunfc_target_remove"
188 
189 #ifdef	__cplusplus
190 }
191 #endif
192 
193 #endif /* _FCTIO_H */
194