19087SZhong.Wang@Sun.COM /*
29087SZhong.Wang@Sun.COM  * CDDL HEADER START
39087SZhong.Wang@Sun.COM  *
49087SZhong.Wang@Sun.COM  * The contents of this file are subject to the terms of the
59087SZhong.Wang@Sun.COM  * Common Development and Distribution License (the "License").
69087SZhong.Wang@Sun.COM  * You may not use this file except in compliance with the License.
79087SZhong.Wang@Sun.COM  *
89087SZhong.Wang@Sun.COM  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
99087SZhong.Wang@Sun.COM  * or http://www.opensolaris.org/os/licensing.
109087SZhong.Wang@Sun.COM  * See the License for the specific language governing permissions
119087SZhong.Wang@Sun.COM  * and limitations under the License.
129087SZhong.Wang@Sun.COM  *
139087SZhong.Wang@Sun.COM  * When distributing Covered Code, include this CDDL HEADER in each
149087SZhong.Wang@Sun.COM  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
159087SZhong.Wang@Sun.COM  * If applicable, add the following below this CDDL HEADER, with the
169087SZhong.Wang@Sun.COM  * fields enclosed by brackets "[]" replaced with your own identifying
179087SZhong.Wang@Sun.COM  * information: Portions Copyright [yyyy] [name of copyright owner]
189087SZhong.Wang@Sun.COM  *
199087SZhong.Wang@Sun.COM  * CDDL HEADER END
209087SZhong.Wang@Sun.COM  */
219087SZhong.Wang@Sun.COM /*
229087SZhong.Wang@Sun.COM  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
239087SZhong.Wang@Sun.COM  * Use is subject to license terms.
249087SZhong.Wang@Sun.COM  */
259087SZhong.Wang@Sun.COM 
269087SZhong.Wang@Sun.COM #ifndef	_LIBFCOE_H
279087SZhong.Wang@Sun.COM #define	_LIBFCOE_H
289087SZhong.Wang@Sun.COM 
299087SZhong.Wang@Sun.COM #include <time.h>
309087SZhong.Wang@Sun.COM #include <wchar.h>
319087SZhong.Wang@Sun.COM #include <sys/param.h>
329087SZhong.Wang@Sun.COM #include <sys/ethernet.h>
339087SZhong.Wang@Sun.COM #include <libnvpair.h>
349087SZhong.Wang@Sun.COM 
359087SZhong.Wang@Sun.COM #ifdef	__cplusplus
369087SZhong.Wang@Sun.COM extern "C" {
379087SZhong.Wang@Sun.COM #endif
389087SZhong.Wang@Sun.COM 
399087SZhong.Wang@Sun.COM /*
40*9895SKevin.Yu@Sun.COM  * FCoE Port Type
419087SZhong.Wang@Sun.COM  */
429087SZhong.Wang@Sun.COM #define	FCOE_PORTTYPE_INITIATOR		0
439087SZhong.Wang@Sun.COM #define	FCOE_PORTTYPE_TARGET		1
449087SZhong.Wang@Sun.COM 
459087SZhong.Wang@Sun.COM #define	FCOE_MAX_MAC_NAME_LEN		32
46*9895SKevin.Yu@Sun.COM 
47*9895SKevin.Yu@Sun.COM #define	FCOE_SCF_ADD		0
48*9895SKevin.Yu@Sun.COM #define	FCOE_SCF_REMOVE		1
49*9895SKevin.Yu@Sun.COM 
50*9895SKevin.Yu@Sun.COM #define	FCOE_SUCCESS			0
51*9895SKevin.Yu@Sun.COM #define	FCOE_ERROR			1
52*9895SKevin.Yu@Sun.COM #define	FCOE_ERROR_EXISTS		2
53*9895SKevin.Yu@Sun.COM #define	FCOE_ERROR_SERVICE_NOT_FOUND	3
54*9895SKevin.Yu@Sun.COM #define	FCOE_ERROR_NOMEM		4
55*9895SKevin.Yu@Sun.COM #define	FCOE_ERROR_MEMBER_NOT_FOUND	5
56*9895SKevin.Yu@Sun.COM #define	FCOE_ERROR_BUSY			6
57*9895SKevin.Yu@Sun.COM 
58*9895SKevin.Yu@Sun.COM #define	FCOE_TARGET_SERVICE	"system/fcoe_target"
59*9895SKevin.Yu@Sun.COM #define	FCOE_INITIATOR_SERVICE	"system/fcoe_initiator"
60*9895SKevin.Yu@Sun.COM #define	FCOE_PG_NAME	"fcoe-port-list-pg"
61*9895SKevin.Yu@Sun.COM #define	FCOE_PORT_LIST	"port_list_p"
62*9895SKevin.Yu@Sun.COM 
63*9895SKevin.Yu@Sun.COM #define	FCOE_PORT_LIST_LENGTH	255
64*9895SKevin.Yu@Sun.COM 
659087SZhong.Wang@Sun.COM typedef unsigned char	FCOE_UINT8;
669087SZhong.Wang@Sun.COM typedef		 char	FCOE_INT8;
679087SZhong.Wang@Sun.COM typedef unsigned short	FCOE_UINT16;
689087SZhong.Wang@Sun.COM typedef		 short	FCOE_INT16;
699087SZhong.Wang@Sun.COM typedef unsigned int	FCOE_UINT32;
709087SZhong.Wang@Sun.COM typedef		 int	FCOE_INT32;
719087SZhong.Wang@Sun.COM 
729087SZhong.Wang@Sun.COM typedef unsigned int	FCOE_STATUS;
739087SZhong.Wang@Sun.COM 
749087SZhong.Wang@Sun.COM #define	FCOE_STATUS_OK				0
759087SZhong.Wang@Sun.COM #define	FCOE_STATUS_ERROR			1
769087SZhong.Wang@Sun.COM #define	FCOE_STATUS_ERROR_INVAL_ARG		2
779087SZhong.Wang@Sun.COM #define	FCOE_STATUS_ERROR_BUSY			3
789087SZhong.Wang@Sun.COM #define	FCOE_STATUS_ERROR_ALREADY		4
799087SZhong.Wang@Sun.COM #define	FCOE_STATUS_ERROR_PERM			5
809087SZhong.Wang@Sun.COM #define	FCOE_STATUS_ERROR_OPEN_DEV		6
819087SZhong.Wang@Sun.COM #define	FCOE_STATUS_ERROR_WWN_SAME		7
829087SZhong.Wang@Sun.COM #define	FCOE_STATUS_ERROR_MAC_LEN		8
839087SZhong.Wang@Sun.COM #define	FCOE_STATUS_ERROR_PWWN_CONFLICTED	9
849087SZhong.Wang@Sun.COM #define	FCOE_STATUS_ERROR_NWWN_CONFLICTED	10
859087SZhong.Wang@Sun.COM #define	FCOE_STATUS_ERROR_NEED_JUMBO_FRAME	11
869087SZhong.Wang@Sun.COM #define	FCOE_STATUS_ERROR_CREATE_MAC		12
879087SZhong.Wang@Sun.COM #define	FCOE_STATUS_ERROR_OPEN_MAC		13
889087SZhong.Wang@Sun.COM #define	FCOE_STATUS_ERROR_CREATE_PORT		14
899087SZhong.Wang@Sun.COM #define	FCOE_STATUS_ERROR_MAC_NOT_FOUND		15
909087SZhong.Wang@Sun.COM #define	FCOE_STATUS_ERROR_OFFLINE_DEV		16
919087SZhong.Wang@Sun.COM #define	FCOE_STATUS_ERROR_MORE_DATA		17
929307Skelly.hu@Sun.COM #define	FCOE_STATUS_ERROR_CLASS_UNSUPPORT	18
939307Skelly.hu@Sun.COM #define	FCOE_STATUS_ERROR_GET_LINKINFO		19
949087SZhong.Wang@Sun.COM 
959087SZhong.Wang@Sun.COM typedef struct fcoe_port_wwn {
969087SZhong.Wang@Sun.COM 	uchar_t	wwn[8];
979087SZhong.Wang@Sun.COM } FCOE_PORT_WWN, *PFCOE_PORT_WWN;
989087SZhong.Wang@Sun.COM 
999087SZhong.Wang@Sun.COM typedef struct fcoe_port_attr {
1009087SZhong.Wang@Sun.COM 	FCOE_PORT_WWN	port_wwn;
1019087SZhong.Wang@Sun.COM 	FCOE_UINT8	mac_link_name[MAXLINKNAMELEN];
1029087SZhong.Wang@Sun.COM 	FCOE_UINT8	mac_factory_addr[ETHERADDRL];
1039087SZhong.Wang@Sun.COM 	FCOE_UINT8	mac_current_addr[ETHERADDRL];
1049087SZhong.Wang@Sun.COM 	FCOE_UINT8	port_type;
1059087SZhong.Wang@Sun.COM 	FCOE_UINT32	mtu_size;
1069087SZhong.Wang@Sun.COM 	FCOE_UINT8	mac_promisc;
1079087SZhong.Wang@Sun.COM } FCOE_PORT_ATTRIBUTE, *PFCOE_PORT_ATTRIBUTE;
1089087SZhong.Wang@Sun.COM 
1099087SZhong.Wang@Sun.COM /*
110*9895SKevin.Yu@Sun.COM  * FCoE port instance in smf repository
111*9895SKevin.Yu@Sun.COM  */
112*9895SKevin.Yu@Sun.COM typedef struct fcoe_smf_port_instance {
113*9895SKevin.Yu@Sun.COM 	FCOE_UINT8	mac_link_name[MAXLINKNAMELEN];
114*9895SKevin.Yu@Sun.COM 	FCOE_UINT8	port_type;
115*9895SKevin.Yu@Sun.COM 	FCOE_PORT_WWN	port_pwwn;
116*9895SKevin.Yu@Sun.COM 	FCOE_PORT_WWN	port_nwwn;
117*9895SKevin.Yu@Sun.COM 	FCOE_UINT8	mac_promisc;
118*9895SKevin.Yu@Sun.COM } FCOE_SMF_PORT_INSTANCE, *PFCOE_SMF_PORT_INSTANCE;
119*9895SKevin.Yu@Sun.COM 
120*9895SKevin.Yu@Sun.COM /*
121*9895SKevin.Yu@Sun.COM  * FCoE port instance list
122*9895SKevin.Yu@Sun.COM  */
123*9895SKevin.Yu@Sun.COM typedef struct fcoe_smf_port_list {
124*9895SKevin.Yu@Sun.COM 	FCOE_UINT32	port_num;
125*9895SKevin.Yu@Sun.COM 	FCOE_SMF_PORT_INSTANCE	ports[1];
126*9895SKevin.Yu@Sun.COM } FCOE_SMF_PORT_LIST, *PFCOE_SMF_PORT_LIST;
127*9895SKevin.Yu@Sun.COM 
128*9895SKevin.Yu@Sun.COM /*
1299087SZhong.Wang@Sun.COM  * macLinkName: mac name with maximum lenth 32
1309087SZhong.Wang@Sun.COM  * portType: 0 (Initiator)/ 1(Target)
1319087SZhong.Wang@Sun.COM  * pwwn: Port WWN
1329087SZhong.Wang@Sun.COM  * nwwn: Nodw WWN
1339087SZhong.Wang@Sun.COM  * promiscous: to enable promisc mode for mac interface
1349087SZhong.Wang@Sun.COM  */
1359087SZhong.Wang@Sun.COM FCOE_STATUS FCOE_CreatePort(
1369087SZhong.Wang@Sun.COM 	const FCOE_UINT8	*macLinkName,	/* maximum len: 32 */
1379087SZhong.Wang@Sun.COM 	FCOE_UINT8	portType,
1389087SZhong.Wang@Sun.COM 	FCOE_PORT_WWN	pwwn,
1399087SZhong.Wang@Sun.COM 	FCOE_PORT_WWN	nwwn,
1409087SZhong.Wang@Sun.COM 	FCOE_UINT8	promiscusous
1419087SZhong.Wang@Sun.COM );
1429087SZhong.Wang@Sun.COM 
1439087SZhong.Wang@Sun.COM FCOE_STATUS FCOE_DeletePort(
1449087SZhong.Wang@Sun.COM     const FCOE_UINT8	*macLinkName
1459087SZhong.Wang@Sun.COM );
1469087SZhong.Wang@Sun.COM 
1479087SZhong.Wang@Sun.COM /*
1489087SZhong.Wang@Sun.COM  * Make sure to free the memory pointed by portlist
1499087SZhong.Wang@Sun.COM  */
1509087SZhong.Wang@Sun.COM FCOE_STATUS FCOE_GetPortList(
1519087SZhong.Wang@Sun.COM     FCOE_UINT32		*port_num,
1529087SZhong.Wang@Sun.COM     FCOE_PORT_ATTRIBUTE	**portlist
1539087SZhong.Wang@Sun.COM );
1549087SZhong.Wang@Sun.COM 
155*9895SKevin.Yu@Sun.COM /*
156*9895SKevin.Yu@Sun.COM  * Make sure to free the memory pointed by portlist
157*9895SKevin.Yu@Sun.COM  */
158*9895SKevin.Yu@Sun.COM FCOE_STATUS FCOE_LoadConfig(
159*9895SKevin.Yu@Sun.COM     FCOE_UINT8		portType,
160*9895SKevin.Yu@Sun.COM     FCOE_SMF_PORT_LIST **portlist
161*9895SKevin.Yu@Sun.COM );
162*9895SKevin.Yu@Sun.COM 
1639087SZhong.Wang@Sun.COM #ifdef	__cplusplus
1649087SZhong.Wang@Sun.COM }
1659087SZhong.Wang@Sun.COM #endif
1669087SZhong.Wang@Sun.COM 
1679087SZhong.Wang@Sun.COM #endif	/* _LIBFCOE_H */
168