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