xref: /illumos-gate/usr/src/uts/common/sys/vnic.h (revision da14cebe)
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 /*
22d62bc4baSyz147064  * Copyright 2008 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>
33*da14cebeSEric Cheng #include <sys/mac_flow.h>
34eae72b5bSSebastien Roy #include <sys/dld_ioc.h>
35*da14cebeSEric Cheng #include <inet/ip.h>
36*da14cebeSEric Cheng #include <inet/ip6.h>
37843e1988Sjohnlev 
38843e1988Sjohnlev #ifdef	__cplusplus
39843e1988Sjohnlev extern "C" {
40843e1988Sjohnlev #endif
41843e1988Sjohnlev 
42eae72b5bSSebastien Roy /*
43*da14cebeSEric Cheng  * Extended diagnostic codes that can be returned by the various
44eae72b5bSSebastien Roy  */
45*da14cebeSEric Cheng typedef enum {
46*da14cebeSEric Cheng 	VNIC_IOC_DIAG_NONE,
47*da14cebeSEric Cheng 	VNIC_IOC_DIAG_MACADDR_NIC,
48*da14cebeSEric Cheng 	VNIC_IOC_DIAG_MACADDR_INUSE,
49*da14cebeSEric Cheng 	VNIC_IOC_DIAG_MACADDR_INVALID,
50*da14cebeSEric Cheng 	VNIC_IOC_DIAG_MACADDRLEN_INVALID,
51*da14cebeSEric Cheng 	VNIC_IOC_DIAG_MACFACTORYSLOTINVALID,
52*da14cebeSEric Cheng 	VNIC_IOC_DIAG_MACFACTORYSLOTUSED,
53*da14cebeSEric Cheng 	VNIC_IOC_DIAG_MACFACTORYSLOTALLUSED,
54*da14cebeSEric Cheng 	VNIC_IOC_DIAG_MACFACTORYNOTSUP,
55*da14cebeSEric Cheng 	VNIC_IOC_DIAG_MACPREFIX_INVALID,
56*da14cebeSEric Cheng 	VNIC_IOC_DIAG_MACPREFIXLEN_INVALID,
57*da14cebeSEric Cheng 	VNIC_IOC_DIAG_MACMARGIN_INVALID,
58*da14cebeSEric Cheng 	VNIC_IOC_DIAG_NO_HWRINGS
59*da14cebeSEric Cheng } vnic_ioc_diag_t;
60843e1988Sjohnlev 
61843e1988Sjohnlev /*
62*da14cebeSEric Cheng  * Allowed VNIC MAC address types.
63*da14cebeSEric Cheng  *
64*da14cebeSEric Cheng  * - VNIC_MAC_ADDR_TYPE_FIXED, VNIC_MAC_ADDR_TYPE_RANDOM:
65*da14cebeSEric Cheng  *   The MAC address is specified by value by the caller, which
66*da14cebeSEric Cheng  *   itself can obtain it from the user directly,
67*da14cebeSEric Cheng  *   or pick it in a random fashion. Which method is used by the
68*da14cebeSEric Cheng  *   caller is irrelevant to the VNIC driver. However two different
69*da14cebeSEric Cheng  *   types are provided so that the information can be made available
70*da14cebeSEric Cheng  *   back to user-space when listing the kernel defined VNICs.
71*da14cebeSEric Cheng  *
72*da14cebeSEric Cheng  *   When a VNIC is created, the address in passed through the
73*da14cebeSEric Cheng  *   vc_mac_addr and vc_mac_len fields of the vnic_ioc_create_t
74*da14cebeSEric Cheng  *   structure.
75*da14cebeSEric Cheng  *
76*da14cebeSEric Cheng  * - VNIC_MAC_ADDR_TYPE_FACTORY: the MAC address is obtained from
77*da14cebeSEric Cheng  *   one of the MAC factory MAC addresses of the underyling NIC.
78*da14cebeSEric Cheng  *
79*da14cebeSEric Cheng  * - VNIC_MAC_ADDR_TYPE_AUTO: the VNIC driver attempts to
80*da14cebeSEric Cheng  *   obtain the address from one of the factory MAC addresses of
81*da14cebeSEric Cheng  *   the underlying NIC. If none is available, the specified
82*da14cebeSEric Cheng  *   MAC address value is used.
83*da14cebeSEric Cheng  *
84*da14cebeSEric Cheng  * - VNIC_MAC_ADDR_TYPE_PRIMARY: this is a VNIC based VLAN. The
85*da14cebeSEric Cheng  *   address for this is the address of the primary MAC client.
86*da14cebeSEric Cheng  *
87843e1988Sjohnlev  */
88843e1988Sjohnlev 
89843e1988Sjohnlev typedef enum {
90*da14cebeSEric Cheng 	VNIC_MAC_ADDR_TYPE_FIXED,
91*da14cebeSEric Cheng 	VNIC_MAC_ADDR_TYPE_RANDOM,
92*da14cebeSEric Cheng 	VNIC_MAC_ADDR_TYPE_FACTORY,
93*da14cebeSEric Cheng 	VNIC_MAC_ADDR_TYPE_AUTO,
94*da14cebeSEric Cheng 	VNIC_MAC_ADDR_TYPE_PRIMARY
95843e1988Sjohnlev } vnic_mac_addr_type_t;
96843e1988Sjohnlev 
97*da14cebeSEric Cheng #if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4
98*da14cebeSEric Cheng #pragma pack(4)
99*da14cebeSEric Cheng #endif
100*da14cebeSEric Cheng 
101eae72b5bSSebastien Roy #define	VNIC_IOC_CREATE		VNICIOC(1)
102843e1988Sjohnlev 
103*da14cebeSEric Cheng #define	VNIC_IOC_CREATE_NODUPCHECK		0x00000001
104*da14cebeSEric Cheng #define	VNIC_IOC_CREATE_ANCHOR			0x00000002
105*da14cebeSEric Cheng 
106*da14cebeSEric Cheng /*
107*da14cebeSEric Cheng  * Force creation of VLAN based VNIC without checking if the
108*da14cebeSEric Cheng  * undelying MAC supports the margin size.
109*da14cebeSEric Cheng  */
110*da14cebeSEric Cheng #define	VNIC_IOC_CREATE_FORCE			0x00000004
111*da14cebeSEric Cheng 
112*da14cebeSEric Cheng /* Allocate a hardware ring to the vnic */
113*da14cebeSEric Cheng #define	VNIC_IOC_CREATE_REQ_HWRINGS		0x00000008
114*da14cebeSEric 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;
119*da14cebeSEric Cheng 	uint_t		vc_mac_len;
120843e1988Sjohnlev 	uchar_t		vc_mac_addr[MAXMACADDRLEN];
121*da14cebeSEric Cheng 	uint_t		vc_mac_prefix_len;
122*da14cebeSEric Cheng 	int		vc_mac_slot;
123*da14cebeSEric Cheng 	uint16_t	vc_vid;
124*da14cebeSEric Cheng 	uint_t		vc_status;
125*da14cebeSEric Cheng 	uint_t		vc_flags;
126*da14cebeSEric Cheng 	vnic_ioc_diag_t	vc_diag;
127*da14cebeSEric Cheng 	mac_resource_props_t vc_resource_props;
128843e1988Sjohnlev } vnic_ioc_create_t;
129843e1988Sjohnlev 
130eae72b5bSSebastien Roy #define	VNIC_IOC_DELETE		VNICIOC(2)
131843e1988Sjohnlev 
132843e1988Sjohnlev typedef struct vnic_ioc_delete {
133d62bc4baSyz147064 	datalink_id_t	vd_vnic_id;
134843e1988Sjohnlev } vnic_ioc_delete_t;
135843e1988Sjohnlev 
136eae72b5bSSebastien Roy #define	VNIC_IOC_INFO		VNICIOC(3)
137843e1988Sjohnlev 
138*da14cebeSEric Cheng typedef struct vnic_info {
139d62bc4baSyz147064 	datalink_id_t	vn_vnic_id;
140d62bc4baSyz147064 	datalink_id_t	vn_link_id;
141843e1988Sjohnlev 	vnic_mac_addr_type_t vn_mac_addr_type;
142*da14cebeSEric Cheng 	uint_t		vn_mac_len;
143*da14cebeSEric Cheng 	uchar_t		vn_mac_addr[MAXMACADDRLEN];
144*da14cebeSEric Cheng 	uint_t		vn_mac_slot;
145*da14cebeSEric Cheng 	uint32_t	vn_mac_prefix_len;
146*da14cebeSEric Cheng 	uint16_t	vn_vid;
147*da14cebeSEric Cheng 	boolean_t	vn_force;
148*da14cebeSEric Cheng 	mac_resource_props_t vn_resource_props;
149*da14cebeSEric Cheng } vnic_info_t;
150843e1988Sjohnlev 
151843e1988Sjohnlev typedef struct vnic_ioc_info {
152*da14cebeSEric Cheng 	vnic_info_t	vi_info;
153843e1988Sjohnlev } vnic_ioc_info_t;
154843e1988Sjohnlev 
155eae72b5bSSebastien Roy #define	VNIC_IOC_MODIFY		VNICIOC(4)
156843e1988Sjohnlev 
157843e1988Sjohnlev #define	VNIC_IOC_MODIFY_ADDR		0x01
158*da14cebeSEric Cheng #define	VNIC_IOC_MODIFY_RESOURCE_CTL	0x02
159843e1988Sjohnlev 
160843e1988Sjohnlev typedef struct vnic_ioc_modify {
161d62bc4baSyz147064 	datalink_id_t	vm_vnic_id;
162843e1988Sjohnlev 	uint_t		vm_modify_mask;
163*da14cebeSEric Cheng 	uint_t		vm_mac_len;
164*da14cebeSEric Cheng 	int		vm_mac_slot;
165843e1988Sjohnlev 	uchar_t		vm_mac_addr[MAXMACADDRLEN];
166843e1988Sjohnlev 	vnic_mac_addr_type_t vm_mac_addr_type;
167*da14cebeSEric Cheng 	mac_resource_props_t vm_resource_props;
168*da14cebeSEric Cheng 	vnic_ioc_diag_t	vm_diag;
169843e1988Sjohnlev } vnic_ioc_modify_t;
170843e1988Sjohnlev 
171*da14cebeSEric Cheng #if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4
172*da14cebeSEric Cheng #pragma pack()
173*da14cebeSEric Cheng #endif
174*da14cebeSEric Cheng 
175843e1988Sjohnlev #ifdef	__cplusplus
176843e1988Sjohnlev }
177843e1988Sjohnlev #endif
178843e1988Sjohnlev 
179843e1988Sjohnlev #endif	/* _SYS_VNIC_H */
180