libfcoe.h revision 9895:adcf72c91c4f
1246149Ssjg/*
2246149Ssjg * CDDL HEADER START
3246149Ssjg *
4246149Ssjg * The contents of this file are subject to the terms of the
5246149Ssjg * Common Development and Distribution License (the "License").
6246149Ssjg * You may not use this file except in compliance with the License.
7246149Ssjg *
8246149Ssjg * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9246149Ssjg * or http://www.opensolaris.org/os/licensing.
10246149Ssjg * See the License for the specific language governing permissions
11246149Ssjg * and limitations under the License.
12246149Ssjg *
13246149Ssjg * When distributing Covered Code, include this CDDL HEADER in each
14246149Ssjg * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15246149Ssjg * If applicable, add the following below this CDDL HEADER, with the
16246149Ssjg * fields enclosed by brackets "[]" replaced with your own identifying
17246149Ssjg * information: Portions Copyright [yyyy] [name of copyright owner]
18246149Ssjg *
19246149Ssjg * CDDL HEADER END
20246149Ssjg */
21246149Ssjg/*
22246149Ssjg * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
23246149Ssjg * Use is subject to license terms.
24246149Ssjg */
25246149Ssjg
26246149Ssjg#ifndef	_LIBFCOE_H
27246149Ssjg#define	_LIBFCOE_H
28246149Ssjg
29246149Ssjg#include <time.h>
30246149Ssjg#include <wchar.h>
31246149Ssjg#include <sys/param.h>
32246149Ssjg#include <sys/ethernet.h>
33246149Ssjg#include <libnvpair.h>
34246149Ssjg
35246149Ssjg#ifdef	__cplusplus
36246149Ssjgextern "C" {
37246149Ssjg#endif
38249033Ssjg
39246149Ssjg/*
40249033Ssjg * FCoE Port Type
41249033Ssjg */
42246149Ssjg#define	FCOE_PORTTYPE_INITIATOR		0
43246149Ssjg#define	FCOE_PORTTYPE_TARGET		1
44246149Ssjg
45246149Ssjg#define	FCOE_MAX_MAC_NAME_LEN		32
46246149Ssjg
47246149Ssjg#define	FCOE_SCF_ADD		0
48246149Ssjg#define	FCOE_SCF_REMOVE		1
49246149Ssjg
50246149Ssjg#define	FCOE_SUCCESS			0
51246149Ssjg#define	FCOE_ERROR			1
52246149Ssjg#define	FCOE_ERROR_EXISTS		2
53246149Ssjg#define	FCOE_ERROR_SERVICE_NOT_FOUND	3
54246149Ssjg#define	FCOE_ERROR_NOMEM		4
55246149Ssjg#define	FCOE_ERROR_MEMBER_NOT_FOUND	5
56246149Ssjg#define	FCOE_ERROR_BUSY			6
57246149Ssjg
58246149Ssjg#define	FCOE_TARGET_SERVICE	"system/fcoe_target"
59246149Ssjg#define	FCOE_INITIATOR_SERVICE	"system/fcoe_initiator"
60246149Ssjg#define	FCOE_PG_NAME	"fcoe-port-list-pg"
61246149Ssjg#define	FCOE_PORT_LIST	"port_list_p"
62246149Ssjg
63246149Ssjg#define	FCOE_PORT_LIST_LENGTH	255
64246149Ssjg
65246149Ssjgtypedef unsigned char	FCOE_UINT8;
66246149Ssjgtypedef		 char	FCOE_INT8;
67246149Ssjgtypedef unsigned short	FCOE_UINT16;
68246149Ssjgtypedef		 short	FCOE_INT16;
69246149Ssjgtypedef unsigned int	FCOE_UINT32;
70246149Ssjgtypedef		 int	FCOE_INT32;
71246149Ssjg
72246149Ssjgtypedef unsigned int	FCOE_STATUS;
73246149Ssjg
74246149Ssjg#define	FCOE_STATUS_OK				0
75246149Ssjg#define	FCOE_STATUS_ERROR			1
76246149Ssjg#define	FCOE_STATUS_ERROR_INVAL_ARG		2
77246149Ssjg#define	FCOE_STATUS_ERROR_BUSY			3
78246149Ssjg#define	FCOE_STATUS_ERROR_ALREADY		4
79246149Ssjg#define	FCOE_STATUS_ERROR_PERM			5
80246149Ssjg#define	FCOE_STATUS_ERROR_OPEN_DEV		6
81246149Ssjg#define	FCOE_STATUS_ERROR_WWN_SAME		7
82246149Ssjg#define	FCOE_STATUS_ERROR_MAC_LEN		8
83246149Ssjg#define	FCOE_STATUS_ERROR_PWWN_CONFLICTED	9
84246149Ssjg#define	FCOE_STATUS_ERROR_NWWN_CONFLICTED	10
85246149Ssjg#define	FCOE_STATUS_ERROR_NEED_JUMBO_FRAME	11
86246149Ssjg#define	FCOE_STATUS_ERROR_CREATE_MAC		12
87246149Ssjg#define	FCOE_STATUS_ERROR_OPEN_MAC		13
88246149Ssjg#define	FCOE_STATUS_ERROR_CREATE_PORT		14
89246149Ssjg#define	FCOE_STATUS_ERROR_MAC_NOT_FOUND		15
90246149Ssjg#define	FCOE_STATUS_ERROR_OFFLINE_DEV		16
91246149Ssjg#define	FCOE_STATUS_ERROR_MORE_DATA		17
92246149Ssjg#define	FCOE_STATUS_ERROR_CLASS_UNSUPPORT	18
93246149Ssjg#define	FCOE_STATUS_ERROR_GET_LINKINFO		19
94246149Ssjg
95246149Ssjgtypedef struct fcoe_port_wwn {
96246149Ssjg	uchar_t	wwn[8];
97246149Ssjg} FCOE_PORT_WWN, *PFCOE_PORT_WWN;
98246149Ssjg
99246149Ssjgtypedef struct fcoe_port_attr {
100246149Ssjg	FCOE_PORT_WWN	port_wwn;
101246149Ssjg	FCOE_UINT8	mac_link_name[MAXLINKNAMELEN];
102246149Ssjg	FCOE_UINT8	mac_factory_addr[ETHERADDRL];
103246149Ssjg	FCOE_UINT8	mac_current_addr[ETHERADDRL];
104246149Ssjg	FCOE_UINT8	port_type;
105246149Ssjg	FCOE_UINT32	mtu_size;
106246149Ssjg	FCOE_UINT8	mac_promisc;
107246149Ssjg} FCOE_PORT_ATTRIBUTE, *PFCOE_PORT_ATTRIBUTE;
108246149Ssjg
109246149Ssjg/*
110246149Ssjg * FCoE port instance in smf repository
111246149Ssjg */
112246149Ssjgtypedef struct fcoe_smf_port_instance {
113246149Ssjg	FCOE_UINT8	mac_link_name[MAXLINKNAMELEN];
114246149Ssjg	FCOE_UINT8	port_type;
115246149Ssjg	FCOE_PORT_WWN	port_pwwn;
116246149Ssjg	FCOE_PORT_WWN	port_nwwn;
117246149Ssjg	FCOE_UINT8	mac_promisc;
118246149Ssjg} FCOE_SMF_PORT_INSTANCE, *PFCOE_SMF_PORT_INSTANCE;
119246149Ssjg
120246149Ssjg/*
121246149Ssjg * FCoE port instance list
122246149Ssjg */
123246149Ssjgtypedef struct fcoe_smf_port_list {
124246149Ssjg	FCOE_UINT32	port_num;
125246149Ssjg	FCOE_SMF_PORT_INSTANCE	ports[1];
126246149Ssjg} FCOE_SMF_PORT_LIST, *PFCOE_SMF_PORT_LIST;
127246149Ssjg
128246149Ssjg/*
129246149Ssjg * macLinkName: mac name with maximum lenth 32
130246149Ssjg * portType: 0 (Initiator)/ 1(Target)
131246149Ssjg * pwwn: Port WWN
132246149Ssjg * nwwn: Nodw WWN
133246149Ssjg * promiscous: to enable promisc mode for mac interface
134246149Ssjg */
135246149SsjgFCOE_STATUS FCOE_CreatePort(
136246149Ssjg	const FCOE_UINT8	*macLinkName,	/* maximum len: 32 */
137246149Ssjg	FCOE_UINT8	portType,
138246149Ssjg	FCOE_PORT_WWN	pwwn,
139246149Ssjg	FCOE_PORT_WWN	nwwn,
140246149Ssjg	FCOE_UINT8	promiscusous
141246149Ssjg);
142246149Ssjg
143246149SsjgFCOE_STATUS FCOE_DeletePort(
144246149Ssjg    const FCOE_UINT8	*macLinkName
145246149Ssjg);
146246149Ssjg
147246149Ssjg/*
148246149Ssjg * Make sure to free the memory pointed by portlist
149246149Ssjg */
150246149SsjgFCOE_STATUS FCOE_GetPortList(
151246149Ssjg    FCOE_UINT32		*port_num,
152246149Ssjg    FCOE_PORT_ATTRIBUTE	**portlist
153249033Ssjg);
154246149Ssjg
155246149Ssjg/*
156246149Ssjg * Make sure to free the memory pointed by portlist
157246149Ssjg */
158246149SsjgFCOE_STATUS FCOE_LoadConfig(
159246149Ssjg    FCOE_UINT8		portType,
160246149Ssjg    FCOE_SMF_PORT_LIST **portlist
161246149Ssjg);
162246149Ssjg
163246149Ssjg#ifdef	__cplusplus
164246149Ssjg}
165246149Ssjg#endif
166246149Ssjg
167246149Ssjg#endif	/* _LIBFCOE_H */
168246149Ssjg