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