xref: /titanic_50/usr/src/lib/libfcoe/common/libfcoe.h (revision e6eb57e72471348376359efe9105d50bf487a312)
12a8164dfSZhong Wang /*
22a8164dfSZhong Wang  * CDDL HEADER START
32a8164dfSZhong Wang  *
42a8164dfSZhong Wang  * The contents of this file are subject to the terms of the
52a8164dfSZhong Wang  * Common Development and Distribution License (the "License").
62a8164dfSZhong Wang  * You may not use this file except in compliance with the License.
72a8164dfSZhong Wang  *
82a8164dfSZhong Wang  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
92a8164dfSZhong Wang  * or http://www.opensolaris.org/os/licensing.
102a8164dfSZhong Wang  * See the License for the specific language governing permissions
112a8164dfSZhong Wang  * and limitations under the License.
122a8164dfSZhong Wang  *
132a8164dfSZhong Wang  * When distributing Covered Code, include this CDDL HEADER in each
142a8164dfSZhong Wang  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
152a8164dfSZhong Wang  * If applicable, add the following below this CDDL HEADER, with the
162a8164dfSZhong Wang  * fields enclosed by brackets "[]" replaced with your own identifying
172a8164dfSZhong Wang  * information: Portions Copyright [yyyy] [name of copyright owner]
182a8164dfSZhong Wang  *
192a8164dfSZhong Wang  * CDDL HEADER END
202a8164dfSZhong Wang  */
212a8164dfSZhong Wang /*
222a8164dfSZhong Wang  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
232a8164dfSZhong Wang  * Use is subject to license terms.
242a8164dfSZhong Wang  */
252a8164dfSZhong Wang 
262a8164dfSZhong Wang #ifndef	_LIBFCOE_H
272a8164dfSZhong Wang #define	_LIBFCOE_H
282a8164dfSZhong Wang 
292a8164dfSZhong Wang #include <time.h>
302a8164dfSZhong Wang #include <wchar.h>
312a8164dfSZhong Wang #include <sys/param.h>
322a8164dfSZhong Wang #include <sys/ethernet.h>
332a8164dfSZhong Wang #include <libnvpair.h>
342a8164dfSZhong Wang 
352a8164dfSZhong Wang #ifdef	__cplusplus
362a8164dfSZhong Wang extern "C" {
372a8164dfSZhong Wang #endif
382a8164dfSZhong Wang 
392a8164dfSZhong Wang /*
40*e6eb57e7SKevin Yu  * FCoE Port Type
412a8164dfSZhong Wang  */
422a8164dfSZhong Wang #define	FCOE_PORTTYPE_INITIATOR		0
432a8164dfSZhong Wang #define	FCOE_PORTTYPE_TARGET		1
442a8164dfSZhong Wang 
452a8164dfSZhong Wang #define	FCOE_MAX_MAC_NAME_LEN		32
46*e6eb57e7SKevin Yu 
47*e6eb57e7SKevin Yu #define	FCOE_SCF_ADD		0
48*e6eb57e7SKevin Yu #define	FCOE_SCF_REMOVE		1
49*e6eb57e7SKevin Yu 
50*e6eb57e7SKevin Yu #define	FCOE_SUCCESS			0
51*e6eb57e7SKevin Yu #define	FCOE_ERROR			1
52*e6eb57e7SKevin Yu #define	FCOE_ERROR_EXISTS		2
53*e6eb57e7SKevin Yu #define	FCOE_ERROR_SERVICE_NOT_FOUND	3
54*e6eb57e7SKevin Yu #define	FCOE_ERROR_NOMEM		4
55*e6eb57e7SKevin Yu #define	FCOE_ERROR_MEMBER_NOT_FOUND	5
56*e6eb57e7SKevin Yu #define	FCOE_ERROR_BUSY			6
57*e6eb57e7SKevin Yu 
58*e6eb57e7SKevin Yu #define	FCOE_TARGET_SERVICE	"system/fcoe_target"
59*e6eb57e7SKevin Yu #define	FCOE_INITIATOR_SERVICE	"system/fcoe_initiator"
60*e6eb57e7SKevin Yu #define	FCOE_PG_NAME	"fcoe-port-list-pg"
61*e6eb57e7SKevin Yu #define	FCOE_PORT_LIST	"port_list_p"
62*e6eb57e7SKevin Yu 
63*e6eb57e7SKevin Yu #define	FCOE_PORT_LIST_LENGTH	255
64*e6eb57e7SKevin Yu 
652a8164dfSZhong Wang typedef unsigned char	FCOE_UINT8;
662a8164dfSZhong Wang typedef		 char	FCOE_INT8;
672a8164dfSZhong Wang typedef unsigned short	FCOE_UINT16;
682a8164dfSZhong Wang typedef		 short	FCOE_INT16;
692a8164dfSZhong Wang typedef unsigned int	FCOE_UINT32;
702a8164dfSZhong Wang typedef		 int	FCOE_INT32;
712a8164dfSZhong Wang 
722a8164dfSZhong Wang typedef unsigned int	FCOE_STATUS;
732a8164dfSZhong Wang 
742a8164dfSZhong Wang #define	FCOE_STATUS_OK				0
752a8164dfSZhong Wang #define	FCOE_STATUS_ERROR			1
762a8164dfSZhong Wang #define	FCOE_STATUS_ERROR_INVAL_ARG		2
772a8164dfSZhong Wang #define	FCOE_STATUS_ERROR_BUSY			3
782a8164dfSZhong Wang #define	FCOE_STATUS_ERROR_ALREADY		4
792a8164dfSZhong Wang #define	FCOE_STATUS_ERROR_PERM			5
802a8164dfSZhong Wang #define	FCOE_STATUS_ERROR_OPEN_DEV		6
812a8164dfSZhong Wang #define	FCOE_STATUS_ERROR_WWN_SAME		7
822a8164dfSZhong Wang #define	FCOE_STATUS_ERROR_MAC_LEN		8
832a8164dfSZhong Wang #define	FCOE_STATUS_ERROR_PWWN_CONFLICTED	9
842a8164dfSZhong Wang #define	FCOE_STATUS_ERROR_NWWN_CONFLICTED	10
852a8164dfSZhong Wang #define	FCOE_STATUS_ERROR_NEED_JUMBO_FRAME	11
862a8164dfSZhong Wang #define	FCOE_STATUS_ERROR_CREATE_MAC		12
872a8164dfSZhong Wang #define	FCOE_STATUS_ERROR_OPEN_MAC		13
882a8164dfSZhong Wang #define	FCOE_STATUS_ERROR_CREATE_PORT		14
892a8164dfSZhong Wang #define	FCOE_STATUS_ERROR_MAC_NOT_FOUND		15
902a8164dfSZhong Wang #define	FCOE_STATUS_ERROR_OFFLINE_DEV		16
912a8164dfSZhong Wang #define	FCOE_STATUS_ERROR_MORE_DATA		17
92d4401b99SKelly Hu #define	FCOE_STATUS_ERROR_CLASS_UNSUPPORT	18
93d4401b99SKelly Hu #define	FCOE_STATUS_ERROR_GET_LINKINFO		19
942a8164dfSZhong Wang 
952a8164dfSZhong Wang typedef struct fcoe_port_wwn {
962a8164dfSZhong Wang 	uchar_t	wwn[8];
972a8164dfSZhong Wang } FCOE_PORT_WWN, *PFCOE_PORT_WWN;
982a8164dfSZhong Wang 
992a8164dfSZhong Wang typedef struct fcoe_port_attr {
1002a8164dfSZhong Wang 	FCOE_PORT_WWN	port_wwn;
1012a8164dfSZhong Wang 	FCOE_UINT8	mac_link_name[MAXLINKNAMELEN];
1022a8164dfSZhong Wang 	FCOE_UINT8	mac_factory_addr[ETHERADDRL];
1032a8164dfSZhong Wang 	FCOE_UINT8	mac_current_addr[ETHERADDRL];
1042a8164dfSZhong Wang 	FCOE_UINT8	port_type;
1052a8164dfSZhong Wang 	FCOE_UINT32	mtu_size;
1062a8164dfSZhong Wang 	FCOE_UINT8	mac_promisc;
1072a8164dfSZhong Wang } FCOE_PORT_ATTRIBUTE, *PFCOE_PORT_ATTRIBUTE;
1082a8164dfSZhong Wang 
1092a8164dfSZhong Wang /*
110*e6eb57e7SKevin Yu  * FCoE port instance in smf repository
111*e6eb57e7SKevin Yu  */
112*e6eb57e7SKevin Yu typedef struct fcoe_smf_port_instance {
113*e6eb57e7SKevin Yu 	FCOE_UINT8	mac_link_name[MAXLINKNAMELEN];
114*e6eb57e7SKevin Yu 	FCOE_UINT8	port_type;
115*e6eb57e7SKevin Yu 	FCOE_PORT_WWN	port_pwwn;
116*e6eb57e7SKevin Yu 	FCOE_PORT_WWN	port_nwwn;
117*e6eb57e7SKevin Yu 	FCOE_UINT8	mac_promisc;
118*e6eb57e7SKevin Yu } FCOE_SMF_PORT_INSTANCE, *PFCOE_SMF_PORT_INSTANCE;
119*e6eb57e7SKevin Yu 
120*e6eb57e7SKevin Yu /*
121*e6eb57e7SKevin Yu  * FCoE port instance list
122*e6eb57e7SKevin Yu  */
123*e6eb57e7SKevin Yu typedef struct fcoe_smf_port_list {
124*e6eb57e7SKevin Yu 	FCOE_UINT32	port_num;
125*e6eb57e7SKevin Yu 	FCOE_SMF_PORT_INSTANCE	ports[1];
126*e6eb57e7SKevin Yu } FCOE_SMF_PORT_LIST, *PFCOE_SMF_PORT_LIST;
127*e6eb57e7SKevin Yu 
128*e6eb57e7SKevin Yu /*
1292a8164dfSZhong Wang  * macLinkName: mac name with maximum lenth 32
1302a8164dfSZhong Wang  * portType: 0 (Initiator)/ 1(Target)
1312a8164dfSZhong Wang  * pwwn: Port WWN
1322a8164dfSZhong Wang  * nwwn: Nodw WWN
1332a8164dfSZhong Wang  * promiscous: to enable promisc mode for mac interface
1342a8164dfSZhong Wang  */
1352a8164dfSZhong Wang FCOE_STATUS FCOE_CreatePort(
1362a8164dfSZhong Wang 	const FCOE_UINT8	*macLinkName,	/* maximum len: 32 */
1372a8164dfSZhong Wang 	FCOE_UINT8	portType,
1382a8164dfSZhong Wang 	FCOE_PORT_WWN	pwwn,
1392a8164dfSZhong Wang 	FCOE_PORT_WWN	nwwn,
1402a8164dfSZhong Wang 	FCOE_UINT8	promiscusous
1412a8164dfSZhong Wang );
1422a8164dfSZhong Wang 
1432a8164dfSZhong Wang FCOE_STATUS FCOE_DeletePort(
1442a8164dfSZhong Wang     const FCOE_UINT8	*macLinkName
1452a8164dfSZhong Wang );
1462a8164dfSZhong Wang 
1472a8164dfSZhong Wang /*
1482a8164dfSZhong Wang  * Make sure to free the memory pointed by portlist
1492a8164dfSZhong Wang  */
1502a8164dfSZhong Wang FCOE_STATUS FCOE_GetPortList(
1512a8164dfSZhong Wang     FCOE_UINT32		*port_num,
1522a8164dfSZhong Wang     FCOE_PORT_ATTRIBUTE	**portlist
1532a8164dfSZhong Wang );
1542a8164dfSZhong Wang 
155*e6eb57e7SKevin Yu /*
156*e6eb57e7SKevin Yu  * Make sure to free the memory pointed by portlist
157*e6eb57e7SKevin Yu  */
158*e6eb57e7SKevin Yu FCOE_STATUS FCOE_LoadConfig(
159*e6eb57e7SKevin Yu     FCOE_UINT8		portType,
160*e6eb57e7SKevin Yu     FCOE_SMF_PORT_LIST **portlist
161*e6eb57e7SKevin Yu );
162*e6eb57e7SKevin Yu 
1632a8164dfSZhong Wang #ifdef	__cplusplus
1642a8164dfSZhong Wang }
1652a8164dfSZhong Wang #endif
1662a8164dfSZhong Wang 
1672a8164dfSZhong Wang #endif	/* _LIBFCOE_H */
168