xref: /titanic_44/usr/src/lib/libfcoe/common/libfcoe.h (revision bda1f129971950880940a17bab0bf096d5744b0c)
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_CLASS_UNSUPPORT	18
74 #define	FCOE_STATUS_ERROR_GET_LINKINFO		19
75 
76 typedef struct fcoe_port_wwn {
77 	uchar_t	wwn[8];
78 } FCOE_PORT_WWN, *PFCOE_PORT_WWN;
79 
80 typedef struct fcoe_port_attr {
81 	FCOE_PORT_WWN	port_wwn;
82 	FCOE_UINT8	mac_link_name[MAXLINKNAMELEN];
83 	FCOE_UINT8	mac_factory_addr[ETHERADDRL];
84 	FCOE_UINT8	mac_current_addr[ETHERADDRL];
85 	FCOE_UINT8	port_type;
86 	FCOE_UINT32	mtu_size;
87 	FCOE_UINT8	mac_promisc;
88 } FCOE_PORT_ATTRIBUTE, *PFCOE_PORT_ATTRIBUTE;
89 
90 /*
91  * macLinkName: mac name with maximum lenth 32
92  * portType: 0 (Initiator)/ 1(Target)
93  * pwwn: Port WWN
94  * nwwn: Nodw WWN
95  * promiscous: to enable promisc mode for mac interface
96  */
97 FCOE_STATUS FCOE_CreatePort(
98 	const FCOE_UINT8	*macLinkName,	/* maximum len: 32 */
99 	FCOE_UINT8	portType,
100 	FCOE_PORT_WWN	pwwn,
101 	FCOE_PORT_WWN	nwwn,
102 	FCOE_UINT8	promiscusous
103 );
104 
105 FCOE_STATUS FCOE_DeletePort(
106     const FCOE_UINT8	*macLinkName
107 );
108 
109 /*
110  * Make sure to free the memory pointed by portlist
111  */
112 FCOE_STATUS FCOE_GetPortList(
113     FCOE_UINT32		*port_num,
114     FCOE_PORT_ATTRIBUTE	**portlist
115 );
116 
117 #ifdef	__cplusplus
118 }
119 #endif
120 
121 #endif	/* _LIBFCOE_H */
122