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