xref: /titanic_50/usr/src/lib/libfcoe/common/libfcoe.h (revision 9f773e288f99c442ca8578e3006a51f82fb49aab)
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 
26 #ifndef	_LIBFCOE_H
27 #define	_LIBFCOE_H
28 
29 #include <time.h>
30 #include <wchar.h>
31 #include <sys/param.h>
32 #include <sys/ethernet.h>
33 #include <libnvpair.h>
34 
35 #ifdef	__cplusplus
36 extern "C" {
37 #endif
38 
39 /*
40  * FCoE Port Type
41  */
42 #define	FCOE_PORTTYPE_INITIATOR		0
43 #define	FCOE_PORTTYPE_TARGET		1
44 
45 #define	FCOE_MAX_MAC_NAME_LEN		32
46 
47 #define	FCOE_SCF_ADD		0
48 #define	FCOE_SCF_REMOVE		1
49 
50 #define	FCOE_SUCCESS			0
51 #define	FCOE_ERROR			1
52 #define	FCOE_ERROR_EXISTS		2
53 #define	FCOE_ERROR_SERVICE_NOT_FOUND	3
54 #define	FCOE_ERROR_NOMEM		4
55 #define	FCOE_ERROR_MEMBER_NOT_FOUND	5
56 #define	FCOE_ERROR_BUSY			6
57 
58 #define	FCOE_TARGET_SERVICE	"system/fcoe_target"
59 #define	FCOE_INITIATOR_SERVICE	"system/fcoe_initiator"
60 #define	FCOE_PG_NAME	"fcoe-port-list-pg"
61 #define	FCOE_PORT_LIST	"port_list_p"
62 
63 #define	FCOE_PORT_LIST_LENGTH	255
64 
65 typedef unsigned char	FCOE_UINT8;
66 typedef		 char	FCOE_INT8;
67 typedef unsigned short	FCOE_UINT16;
68 typedef		 short	FCOE_INT16;
69 typedef unsigned int	FCOE_UINT32;
70 typedef		 int	FCOE_INT32;
71 
72 typedef unsigned int	FCOE_STATUS;
73 
74 #define	FCOE_STATUS_OK				0
75 #define	FCOE_STATUS_ERROR			1
76 #define	FCOE_STATUS_ERROR_INVAL_ARG		2
77 #define	FCOE_STATUS_ERROR_BUSY			3
78 #define	FCOE_STATUS_ERROR_ALREADY		4
79 #define	FCOE_STATUS_ERROR_PERM			5
80 #define	FCOE_STATUS_ERROR_OPEN_DEV		6
81 #define	FCOE_STATUS_ERROR_WWN_SAME		7
82 #define	FCOE_STATUS_ERROR_MAC_LEN		8
83 #define	FCOE_STATUS_ERROR_PWWN_CONFLICTED	9
84 #define	FCOE_STATUS_ERROR_NWWN_CONFLICTED	10
85 #define	FCOE_STATUS_ERROR_NEED_JUMBO_FRAME	11
86 #define	FCOE_STATUS_ERROR_CREATE_MAC		12
87 #define	FCOE_STATUS_ERROR_OPEN_MAC		13
88 #define	FCOE_STATUS_ERROR_CREATE_PORT		14
89 #define	FCOE_STATUS_ERROR_MAC_NOT_FOUND		15
90 #define	FCOE_STATUS_ERROR_OFFLINE_DEV		16
91 #define	FCOE_STATUS_ERROR_MORE_DATA		17
92 #define	FCOE_STATUS_ERROR_CLASS_UNSUPPORT	18
93 #define	FCOE_STATUS_ERROR_GET_LINKINFO		19
94 
95 typedef struct fcoe_port_wwn {
96 	uchar_t	wwn[8];
97 } FCOE_PORT_WWN, *PFCOE_PORT_WWN;
98 
99 typedef struct fcoe_port_attr {
100 	FCOE_PORT_WWN	port_wwn;
101 	FCOE_UINT8	mac_link_name[MAXLINKNAMELEN];
102 	FCOE_UINT8	mac_factory_addr[ETHERADDRL];
103 	FCOE_UINT8	mac_current_addr[ETHERADDRL];
104 	FCOE_UINT8	port_type;
105 	FCOE_UINT32	mtu_size;
106 	FCOE_UINT8	mac_promisc;
107 } FCOE_PORT_ATTRIBUTE, *PFCOE_PORT_ATTRIBUTE;
108 
109 /*
110  * FCoE port instance in smf repository
111  */
112 typedef struct fcoe_smf_port_instance {
113 	FCOE_UINT8	mac_link_name[MAXLINKNAMELEN];
114 	FCOE_UINT8	port_type;
115 	FCOE_PORT_WWN	port_pwwn;
116 	FCOE_PORT_WWN	port_nwwn;
117 	FCOE_UINT8	mac_promisc;
118 } FCOE_SMF_PORT_INSTANCE, *PFCOE_SMF_PORT_INSTANCE;
119 
120 /*
121  * FCoE port instance list
122  */
123 typedef struct fcoe_smf_port_list {
124 	FCOE_UINT32	port_num;
125 	FCOE_SMF_PORT_INSTANCE	ports[1];
126 } FCOE_SMF_PORT_LIST, *PFCOE_SMF_PORT_LIST;
127 
128 /*
129  * macLinkName: mac name with maximum lenth 32
130  * portType: 0 (Initiator)/ 1(Target)
131  * pwwn: Port WWN
132  * nwwn: Nodw WWN
133  * promiscous: to enable promisc mode for mac interface
134  */
135 FCOE_STATUS FCOE_CreatePort(
136 	const FCOE_UINT8	*macLinkName,	/* maximum len: 32 */
137 	FCOE_UINT8	portType,
138 	FCOE_PORT_WWN	pwwn,
139 	FCOE_PORT_WWN	nwwn,
140 	FCOE_UINT8	promiscusous
141 );
142 
143 FCOE_STATUS FCOE_DeletePort(
144     const FCOE_UINT8	*macLinkName
145 );
146 
147 /*
148  * Make sure to free the memory pointed by portlist
149  */
150 FCOE_STATUS FCOE_GetPortList(
151     FCOE_UINT32		*port_num,
152     FCOE_PORT_ATTRIBUTE	**portlist
153 );
154 
155 /*
156  * Make sure to free the memory pointed by portlist
157  */
158 FCOE_STATUS FCOE_LoadConfig(
159     FCOE_UINT8		portType,
160     FCOE_SMF_PORT_LIST **portlist
161 );
162 
163 #ifdef	__cplusplus
164 }
165 #endif
166 
167 #endif	/* _LIBFCOE_H */
168