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