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.
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.
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]
22 * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
31 #include <sys/param.h>
32 #include <sys/ethernet.h>
33 #include <libnvpair.h>
42 #define FCOE_PORTTYPE_INITIATOR 0
43 #define FCOE_PORTTYPE_TARGET 1
45 #define FCOE_MAX_MAC_NAME_LEN 32
47 #define FCOE_SCF_ADD 0
48 #define FCOE_SCF_REMOVE 1
50 #define FCOE_SUCCESS 0
52 #define FCOE_ERROR_EXISTS 2
53 #define FCOE_ERROR_SERVICE_NOT_FOUND 3
54 #define FCOE_ERROR_NOMEM 4
55 #define FCOE_ERROR_MEMBER_NOT_FOUND 5
56 #define FCOE_ERROR_BUSY 6
58 #define FCOE_TARGET_SERVICE "system/fcoe_target"
59 #define FCOE_INITIATOR_SERVICE "system/fcoe_initiator"
60 #define FCOE_PG_NAME "fcoe-port-list-pg"
61 #define FCOE_PORT_LIST "port_list_p"
63 #define FCOE_PORT_LIST_LENGTH 255
65 typedef unsigned char FCOE_UINT8
;
66 typedef char FCOE_INT8
;
67 typedef unsigned short FCOE_UINT16
;
68 typedef short FCOE_INT16
;
69 typedef unsigned int FCOE_UINT32
;
70 typedef int FCOE_INT32
;
72 typedef unsigned int FCOE_STATUS
;
74 #define FCOE_STATUS_OK 0
75 #define FCOE_STATUS_ERROR 1
76 #define FCOE_STATUS_ERROR_INVAL_ARG 2
77 #define FCOE_STATUS_ERROR_BUSY 3
78 #define FCOE_STATUS_ERROR_ALREADY 4
79 #define FCOE_STATUS_ERROR_PERM 5
80 #define FCOE_STATUS_ERROR_OPEN_DEV 6
81 #define FCOE_STATUS_ERROR_WWN_SAME 7
82 #define FCOE_STATUS_ERROR_MAC_LEN 8
83 #define FCOE_STATUS_ERROR_PWWN_CONFLICTED 9
84 #define FCOE_STATUS_ERROR_NWWN_CONFLICTED 10
85 #define FCOE_STATUS_ERROR_NEED_JUMBO_FRAME 11
86 #define FCOE_STATUS_ERROR_CREATE_MAC 12
87 #define FCOE_STATUS_ERROR_OPEN_MAC 13
88 #define FCOE_STATUS_ERROR_CREATE_PORT 14
89 #define FCOE_STATUS_ERROR_MAC_NOT_FOUND 15
90 #define FCOE_STATUS_ERROR_OFFLINE_DEV 16
91 #define FCOE_STATUS_ERROR_MORE_DATA 17
92 #define FCOE_STATUS_ERROR_CLASS_UNSUPPORT 18
93 #define FCOE_STATUS_ERROR_GET_LINKINFO 19
95 typedef struct fcoe_port_wwn
{
97 } FCOE_PORT_WWN
, *PFCOE_PORT_WWN
;
99 typedef struct fcoe_port_attr
{
100 FCOE_PORT_WWN port_wwn
;
101 FCOE_UINT8 mac_link_name
[MAXLINKNAMELEN
];
102 FCOE_UINT8 mac_factory_addr
[ETHERADDRL
];
103 FCOE_UINT8 mac_current_addr
[ETHERADDRL
];
104 FCOE_UINT8 port_type
;
105 FCOE_UINT32 mtu_size
;
106 FCOE_UINT8 mac_promisc
;
107 } FCOE_PORT_ATTRIBUTE
, *PFCOE_PORT_ATTRIBUTE
;
110 * FCoE port instance in smf repository
112 typedef struct fcoe_smf_port_instance
{
113 FCOE_UINT8 mac_link_name
[MAXLINKNAMELEN
];
114 FCOE_UINT8 port_type
;
115 FCOE_PORT_WWN port_pwwn
;
116 FCOE_PORT_WWN port_nwwn
;
117 FCOE_UINT8 mac_promisc
;
118 } FCOE_SMF_PORT_INSTANCE
, *PFCOE_SMF_PORT_INSTANCE
;
121 * FCoE port instance list
123 typedef struct fcoe_smf_port_list
{
124 FCOE_UINT32 port_num
;
125 FCOE_SMF_PORT_INSTANCE ports
[1];
126 } FCOE_SMF_PORT_LIST
, *PFCOE_SMF_PORT_LIST
;
129 * macLinkName: mac name with maximum lenth 32
130 * portType: 0 (Initiator)/ 1(Target)
133 * promiscous: to enable promisc mode for mac interface
135 FCOE_STATUS
FCOE_CreatePort(
136 const FCOE_UINT8
*macLinkName
, /* maximum len: 32 */
140 FCOE_UINT8 promiscusous
143 FCOE_STATUS
FCOE_DeletePort(
144 const FCOE_UINT8
*macLinkName
148 * Make sure to free the memory pointed by portlist
150 FCOE_STATUS
FCOE_GetPortList(
151 FCOE_UINT32
*port_num
,
152 FCOE_PORT_ATTRIBUTE
**portlist
156 * Make sure to free the memory pointed by portlist
158 FCOE_STATUS
FCOE_LoadConfig(
160 FCOE_SMF_PORT_LIST
**portlist
167 #endif /* _LIBFCOE_H */