xref: /illumos-gate/usr/src/lib/libfcoe/common/libfcoe.h (revision b1593d50e783f7d66722dde093752b74ffa95176)
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 typedef unsigned char	FCOE_UINT8;
47 typedef		 char	FCOE_INT8;
48 typedef unsigned short	FCOE_UINT16;
49 typedef		 short	FCOE_INT16;
50 typedef unsigned int	FCOE_UINT32;
51 typedef		 int	FCOE_INT32;
52 
53 typedef unsigned int	FCOE_STATUS;
54 
55 #define	FCOE_STATUS_OK				0
56 #define	FCOE_STATUS_ERROR			1
57 #define	FCOE_STATUS_ERROR_INVAL_ARG		2
58 #define	FCOE_STATUS_ERROR_BUSY			3
59 #define	FCOE_STATUS_ERROR_ALREADY		4
60 #define	FCOE_STATUS_ERROR_PERM			5
61 #define	FCOE_STATUS_ERROR_OPEN_DEV		6
62 #define	FCOE_STATUS_ERROR_WWN_SAME		7
63 #define	FCOE_STATUS_ERROR_MAC_LEN		8
64 #define	FCOE_STATUS_ERROR_PWWN_CONFLICTED	9
65 #define	FCOE_STATUS_ERROR_NWWN_CONFLICTED	10
66 #define	FCOE_STATUS_ERROR_NEED_JUMBO_FRAME	11
67 #define	FCOE_STATUS_ERROR_CREATE_MAC		12
68 #define	FCOE_STATUS_ERROR_OPEN_MAC		13
69 #define	FCOE_STATUS_ERROR_CREATE_PORT		14
70 #define	FCOE_STATUS_ERROR_MAC_NOT_FOUND		15
71 #define	FCOE_STATUS_ERROR_OFFLINE_DEV		16
72 #define	FCOE_STATUS_ERROR_MORE_DATA		17
73 #define	FCOE_STATUS_ERROR_VNIC_UNSUPPORT	18
74 
75 typedef struct fcoe_port_wwn {
76 	uchar_t	wwn[8];
77 } FCOE_PORT_WWN, *PFCOE_PORT_WWN;
78 
79 typedef struct fcoe_port_attr {
80 	FCOE_PORT_WWN	port_wwn;
81 	FCOE_UINT8	mac_link_name[MAXLINKNAMELEN];
82 	FCOE_UINT8	mac_factory_addr[ETHERADDRL];
83 	FCOE_UINT8	mac_current_addr[ETHERADDRL];
84 	FCOE_UINT8	port_type;
85 	FCOE_UINT32	mtu_size;
86 	FCOE_UINT8	mac_promisc;
87 } FCOE_PORT_ATTRIBUTE, *PFCOE_PORT_ATTRIBUTE;
88 
89 /*
90  * macLinkName: mac name with maximum lenth 32
91  * portType: 0 (Initiator)/ 1(Target)
92  * pwwn: Port WWN
93  * nwwn: Nodw WWN
94  * promiscous: to enable promisc mode for mac interface
95  */
96 FCOE_STATUS FCOE_CreatePort(
97 	const FCOE_UINT8	*macLinkName,	/* maximum len: 32 */
98 	FCOE_UINT8	portType,
99 	FCOE_PORT_WWN	pwwn,
100 	FCOE_PORT_WWN	nwwn,
101 	FCOE_UINT8	promiscusous
102 );
103 
104 FCOE_STATUS FCOE_DeletePort(
105     const FCOE_UINT8	*macLinkName
106 );
107 
108 /*
109  * Make sure to free the memory pointed by portlist
110  */
111 FCOE_STATUS FCOE_GetPortList(
112     FCOE_UINT32		*port_num,
113     FCOE_PORT_ATTRIBUTE	**portlist
114 );
115 
116 #ifdef	__cplusplus
117 }
118 #endif
119 
120 #endif	/* _LIBFCOE_H */
121