xref: /titanic_51/usr/src/uts/common/sys/vnic.h (revision a776d98e5f349dbb7f5a47eca48f50e6117adcb7)
1843e1988Sjohnlev /*
2843e1988Sjohnlev  * CDDL HEADER START
3843e1988Sjohnlev  *
4843e1988Sjohnlev  * The contents of this file are subject to the terms of the
5843e1988Sjohnlev  * Common Development and Distribution License (the "License").
6843e1988Sjohnlev  * You may not use this file except in compliance with the License.
7843e1988Sjohnlev  *
8843e1988Sjohnlev  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9843e1988Sjohnlev  * or http://www.opensolaris.org/os/licensing.
10843e1988Sjohnlev  * See the License for the specific language governing permissions
11843e1988Sjohnlev  * and limitations under the License.
12843e1988Sjohnlev  *
13843e1988Sjohnlev  * When distributing Covered Code, include this CDDL HEADER in each
14843e1988Sjohnlev  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15843e1988Sjohnlev  * If applicable, add the following below this CDDL HEADER, with the
16843e1988Sjohnlev  * fields enclosed by brackets "[]" replaced with your own identifying
17843e1988Sjohnlev  * information: Portions Copyright [yyyy] [name of copyright owner]
18843e1988Sjohnlev  *
19843e1988Sjohnlev  * CDDL HEADER END
20843e1988Sjohnlev  */
21843e1988Sjohnlev /*
220dc2366fSVenugopal Iyer  * Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
23843e1988Sjohnlev  * Use is subject to license terms.
24843e1988Sjohnlev  */
25843e1988Sjohnlev 
26843e1988Sjohnlev #ifndef	_SYS_VNIC_H
27843e1988Sjohnlev #define	_SYS_VNIC_H
28843e1988Sjohnlev 
29843e1988Sjohnlev #include <sys/types.h>
30843e1988Sjohnlev #include <sys/ethernet.h>
31843e1988Sjohnlev #include <sys/param.h>
32843e1988Sjohnlev #include <sys/mac.h>
33da14cebeSEric Cheng #include <sys/mac_flow.h>
34eae72b5bSSebastien Roy #include <sys/dld_ioc.h>
35da14cebeSEric Cheng #include <inet/ip.h>
36da14cebeSEric Cheng #include <inet/ip6.h>
37843e1988Sjohnlev 
38843e1988Sjohnlev #ifdef	__cplusplus
39843e1988Sjohnlev extern "C" {
40843e1988Sjohnlev #endif
41843e1988Sjohnlev 
42eae72b5bSSebastien Roy /*
43da14cebeSEric Cheng  * Extended diagnostic codes that can be returned by the various
44eae72b5bSSebastien Roy  */
45da14cebeSEric Cheng typedef enum {
46da14cebeSEric Cheng 	VNIC_IOC_DIAG_NONE,
47da14cebeSEric Cheng 	VNIC_IOC_DIAG_MACADDR_NIC,
48da14cebeSEric Cheng 	VNIC_IOC_DIAG_MACADDR_INUSE,
49da14cebeSEric Cheng 	VNIC_IOC_DIAG_MACADDR_INVALID,
50da14cebeSEric Cheng 	VNIC_IOC_DIAG_MACADDRLEN_INVALID,
51da14cebeSEric Cheng 	VNIC_IOC_DIAG_MACFACTORYSLOTINVALID,
52da14cebeSEric Cheng 	VNIC_IOC_DIAG_MACFACTORYSLOTUSED,
53da14cebeSEric Cheng 	VNIC_IOC_DIAG_MACFACTORYSLOTALLUSED,
54da14cebeSEric Cheng 	VNIC_IOC_DIAG_MACFACTORYNOTSUP,
55da14cebeSEric Cheng 	VNIC_IOC_DIAG_MACPREFIX_INVALID,
56da14cebeSEric Cheng 	VNIC_IOC_DIAG_MACPREFIXLEN_INVALID,
57da14cebeSEric Cheng 	VNIC_IOC_DIAG_MACMARGIN_INVALID,
58*a776d98eSRobert Mustacchi 	VNIC_IOC_DIAG_NO_HWRINGS,
59*a776d98eSRobert Mustacchi 	VNIC_IOC_DIAG_MACMTU_INVALID
60da14cebeSEric Cheng } vnic_ioc_diag_t;
61843e1988Sjohnlev 
62843e1988Sjohnlev /*
63da14cebeSEric Cheng  * Allowed VNIC MAC address types.
64da14cebeSEric Cheng  *
65da14cebeSEric Cheng  * - VNIC_MAC_ADDR_TYPE_FIXED, VNIC_MAC_ADDR_TYPE_RANDOM:
66da14cebeSEric Cheng  *   The MAC address is specified by value by the caller, which
67da14cebeSEric Cheng  *   itself can obtain it from the user directly,
68da14cebeSEric Cheng  *   or pick it in a random fashion. Which method is used by the
69da14cebeSEric Cheng  *   caller is irrelevant to the VNIC driver. However two different
70da14cebeSEric Cheng  *   types are provided so that the information can be made available
71da14cebeSEric Cheng  *   back to user-space when listing the kernel defined VNICs.
72da14cebeSEric Cheng  *
73da14cebeSEric Cheng  *   When a VNIC is created, the address in passed through the
74da14cebeSEric Cheng  *   vc_mac_addr and vc_mac_len fields of the vnic_ioc_create_t
75da14cebeSEric Cheng  *   structure.
76da14cebeSEric Cheng  *
77da14cebeSEric Cheng  * - VNIC_MAC_ADDR_TYPE_FACTORY: the MAC address is obtained from
78da14cebeSEric Cheng  *   one of the MAC factory MAC addresses of the underyling NIC.
79da14cebeSEric Cheng  *
80da14cebeSEric Cheng  * - VNIC_MAC_ADDR_TYPE_AUTO: the VNIC driver attempts to
81da14cebeSEric Cheng  *   obtain the address from one of the factory MAC addresses of
82da14cebeSEric Cheng  *   the underlying NIC. If none is available, the specified
83da14cebeSEric Cheng  *   MAC address value is used.
84da14cebeSEric Cheng  *
85da14cebeSEric Cheng  * - VNIC_MAC_ADDR_TYPE_PRIMARY: this is a VNIC based VLAN. The
86da14cebeSEric Cheng  *   address for this is the address of the primary MAC client.
87da14cebeSEric Cheng  *
88843e1988Sjohnlev  */
89843e1988Sjohnlev 
90843e1988Sjohnlev typedef enum {
911cb875aeSCathy Zhou 	VNIC_MAC_ADDR_TYPE_UNKNOWN = -1,
92da14cebeSEric Cheng 	VNIC_MAC_ADDR_TYPE_FIXED,
93da14cebeSEric Cheng 	VNIC_MAC_ADDR_TYPE_RANDOM,
94da14cebeSEric Cheng 	VNIC_MAC_ADDR_TYPE_FACTORY,
95da14cebeSEric Cheng 	VNIC_MAC_ADDR_TYPE_AUTO,
961cb875aeSCathy Zhou 	VNIC_MAC_ADDR_TYPE_PRIMARY,
971cb875aeSCathy Zhou 	VNIC_MAC_ADDR_TYPE_VRID
98843e1988Sjohnlev } vnic_mac_addr_type_t;
99843e1988Sjohnlev 
100da14cebeSEric Cheng #if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4
101da14cebeSEric Cheng #pragma pack(4)
102da14cebeSEric Cheng #endif
103da14cebeSEric Cheng 
104eae72b5bSSebastien Roy #define	VNIC_IOC_CREATE		VNICIOC(1)
105843e1988Sjohnlev 
106da14cebeSEric Cheng #define	VNIC_IOC_CREATE_NODUPCHECK		0x00000001
107da14cebeSEric Cheng #define	VNIC_IOC_CREATE_ANCHOR			0x00000002
108da14cebeSEric Cheng 
109da14cebeSEric Cheng /*
110da14cebeSEric Cheng  * Force creation of VLAN based VNIC without checking if the
111da14cebeSEric Cheng  * undelying MAC supports the margin size.
112da14cebeSEric Cheng  */
113da14cebeSEric Cheng #define	VNIC_IOC_CREATE_FORCE			0x00000004
114da14cebeSEric Cheng 
115843e1988Sjohnlev typedef struct vnic_ioc_create {
116d62bc4baSyz147064 	datalink_id_t	vc_vnic_id;
117d62bc4baSyz147064 	datalink_id_t	vc_link_id;
118843e1988Sjohnlev 	vnic_mac_addr_type_t vc_mac_addr_type;
119da14cebeSEric Cheng 	uint_t		vc_mac_len;
120843e1988Sjohnlev 	uchar_t		vc_mac_addr[MAXMACADDRLEN];
121da14cebeSEric Cheng 	uint_t		vc_mac_prefix_len;
122da14cebeSEric Cheng 	int		vc_mac_slot;
123da14cebeSEric Cheng 	uint16_t	vc_vid;
1241cb875aeSCathy Zhou 	vrid_t		vc_vrid;
1251cb875aeSCathy Zhou 	int		vc_af;
126da14cebeSEric Cheng 	uint_t		vc_status;
127da14cebeSEric Cheng 	uint_t		vc_flags;
128da14cebeSEric Cheng 	vnic_ioc_diag_t	vc_diag;
129da14cebeSEric Cheng 	mac_resource_props_t vc_resource_props;
130843e1988Sjohnlev } vnic_ioc_create_t;
131843e1988Sjohnlev 
132eae72b5bSSebastien Roy #define	VNIC_IOC_DELETE		VNICIOC(2)
133843e1988Sjohnlev 
134843e1988Sjohnlev typedef struct vnic_ioc_delete {
135d62bc4baSyz147064 	datalink_id_t	vd_vnic_id;
136843e1988Sjohnlev } vnic_ioc_delete_t;
137843e1988Sjohnlev 
138eae72b5bSSebastien Roy #define	VNIC_IOC_INFO		VNICIOC(3)
139843e1988Sjohnlev 
140da14cebeSEric Cheng typedef struct vnic_info {
141d62bc4baSyz147064 	datalink_id_t	vn_vnic_id;
142d62bc4baSyz147064 	datalink_id_t	vn_link_id;
143843e1988Sjohnlev 	vnic_mac_addr_type_t vn_mac_addr_type;
144da14cebeSEric Cheng 	uint_t		vn_mac_len;
145da14cebeSEric Cheng 	uchar_t		vn_mac_addr[MAXMACADDRLEN];
146da14cebeSEric Cheng 	uint_t		vn_mac_slot;
147da14cebeSEric Cheng 	uint32_t	vn_mac_prefix_len;
148da14cebeSEric Cheng 	uint16_t	vn_vid;
1491cb875aeSCathy Zhou 	vrid_t		vn_vrid;
1501cb875aeSCathy Zhou 	int		vn_af;
151da14cebeSEric Cheng 	boolean_t	vn_force;
152da14cebeSEric Cheng 	mac_resource_props_t vn_resource_props;
153da14cebeSEric Cheng } vnic_info_t;
154843e1988Sjohnlev 
155843e1988Sjohnlev typedef struct vnic_ioc_info {
156da14cebeSEric Cheng 	vnic_info_t	vi_info;
157843e1988Sjohnlev } vnic_ioc_info_t;
158843e1988Sjohnlev 
159eae72b5bSSebastien Roy #define	VNIC_IOC_MODIFY		VNICIOC(4)
160843e1988Sjohnlev 
161843e1988Sjohnlev #define	VNIC_IOC_MODIFY_ADDR		0x01
162da14cebeSEric Cheng #define	VNIC_IOC_MODIFY_RESOURCE_CTL	0x02
163843e1988Sjohnlev 
164843e1988Sjohnlev typedef struct vnic_ioc_modify {
165d62bc4baSyz147064 	datalink_id_t	vm_vnic_id;
166843e1988Sjohnlev 	uint_t		vm_modify_mask;
167da14cebeSEric Cheng 	uint_t		vm_mac_len;
168da14cebeSEric Cheng 	int		vm_mac_slot;
169843e1988Sjohnlev 	uchar_t		vm_mac_addr[MAXMACADDRLEN];
170843e1988Sjohnlev 	vnic_mac_addr_type_t vm_mac_addr_type;
171da14cebeSEric Cheng 	mac_resource_props_t vm_resource_props;
172da14cebeSEric Cheng 	vnic_ioc_diag_t	vm_diag;
173843e1988Sjohnlev } vnic_ioc_modify_t;
174843e1988Sjohnlev 
175da14cebeSEric Cheng #if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4
176da14cebeSEric Cheng #pragma pack()
177da14cebeSEric Cheng #endif
178da14cebeSEric Cheng 
179843e1988Sjohnlev #ifdef	__cplusplus
180843e1988Sjohnlev }
181843e1988Sjohnlev #endif
182843e1988Sjohnlev 
183843e1988Sjohnlev #endif	/* _SYS_VNIC_H */
184