xref: /titanic_41/usr/src/uts/common/sys/vnic.h (revision 0a9f0670c79ebf123ca0a0c39ce9fd4d2957b7c2)
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 2010 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 #ifndef	_SYS_VNIC_H
27 #define	_SYS_VNIC_H
28 
29 #include <sys/types.h>
30 #include <sys/ethernet.h>
31 #include <sys/param.h>
32 #include <sys/mac.h>
33 #include <sys/mac_flow.h>
34 #include <sys/dld_ioc.h>
35 #include <inet/ip.h>
36 #include <inet/ip6.h>
37 
38 #ifdef	__cplusplus
39 extern "C" {
40 #endif
41 
42 /*
43  * Extended diagnostic codes that can be returned by the various
44  */
45 typedef enum {
46 	VNIC_IOC_DIAG_NONE,
47 	VNIC_IOC_DIAG_MACADDR_NIC,
48 	VNIC_IOC_DIAG_MACADDR_INUSE,
49 	VNIC_IOC_DIAG_MACADDR_INVALID,
50 	VNIC_IOC_DIAG_MACADDRLEN_INVALID,
51 	VNIC_IOC_DIAG_MACFACTORYSLOTINVALID,
52 	VNIC_IOC_DIAG_MACFACTORYSLOTUSED,
53 	VNIC_IOC_DIAG_MACFACTORYSLOTALLUSED,
54 	VNIC_IOC_DIAG_MACFACTORYNOTSUP,
55 	VNIC_IOC_DIAG_MACPREFIX_INVALID,
56 	VNIC_IOC_DIAG_MACPREFIXLEN_INVALID,
57 	VNIC_IOC_DIAG_MACMARGIN_INVALID,
58 	VNIC_IOC_DIAG_NO_HWRINGS,
59 	VNIC_IOC_DIAG_MACMTU_INVALID
60 } vnic_ioc_diag_t;
61 
62 /*
63  * Allowed VNIC MAC address types.
64  *
65  * - VNIC_MAC_ADDR_TYPE_FIXED, VNIC_MAC_ADDR_TYPE_RANDOM:
66  *   The MAC address is specified by value by the caller, which
67  *   itself can obtain it from the user directly,
68  *   or pick it in a random fashion. Which method is used by the
69  *   caller is irrelevant to the VNIC driver. However two different
70  *   types are provided so that the information can be made available
71  *   back to user-space when listing the kernel defined VNICs.
72  *
73  *   When a VNIC is created, the address in passed through the
74  *   vc_mac_addr and vc_mac_len fields of the vnic_ioc_create_t
75  *   structure.
76  *
77  * - VNIC_MAC_ADDR_TYPE_FACTORY: the MAC address is obtained from
78  *   one of the MAC factory MAC addresses of the underyling NIC.
79  *
80  * - VNIC_MAC_ADDR_TYPE_AUTO: the VNIC driver attempts to
81  *   obtain the address from one of the factory MAC addresses of
82  *   the underlying NIC. If none is available, the specified
83  *   MAC address value is used.
84  *
85  * - VNIC_MAC_ADDR_TYPE_PRIMARY: this is a VNIC based VLAN. The
86  *   address for this is the address of the primary MAC client.
87  *
88  */
89 
90 typedef enum {
91 	VNIC_MAC_ADDR_TYPE_UNKNOWN = -1,
92 	VNIC_MAC_ADDR_TYPE_FIXED,
93 	VNIC_MAC_ADDR_TYPE_RANDOM,
94 	VNIC_MAC_ADDR_TYPE_FACTORY,
95 	VNIC_MAC_ADDR_TYPE_AUTO,
96 	VNIC_MAC_ADDR_TYPE_PRIMARY,
97 	VNIC_MAC_ADDR_TYPE_VRID
98 } vnic_mac_addr_type_t;
99 
100 #if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4
101 #pragma pack(4)
102 #endif
103 
104 #define	VNIC_IOC_CREATE		VNICIOC(1)
105 
106 #define	VNIC_IOC_CREATE_NODUPCHECK		0x00000001
107 #define	VNIC_IOC_CREATE_ANCHOR			0x00000002
108 
109 /*
110  * Force creation of VLAN based VNIC without checking if the
111  * undelying MAC supports the margin size.
112  */
113 #define	VNIC_IOC_CREATE_FORCE			0x00000004
114 
115 typedef struct vnic_ioc_create {
116 	datalink_id_t	vc_vnic_id;
117 	datalink_id_t	vc_link_id;
118 	vnic_mac_addr_type_t vc_mac_addr_type;
119 	uint_t		vc_mac_len;
120 	uchar_t		vc_mac_addr[MAXMACADDRLEN];
121 	uint_t		vc_mac_prefix_len;
122 	int		vc_mac_slot;
123 	uint16_t	vc_vid;
124 	vrid_t		vc_vrid;
125 	int		vc_af;
126 	uint_t		vc_status;
127 	uint_t		vc_flags;
128 	vnic_ioc_diag_t	vc_diag;
129 	mac_resource_props_t vc_resource_props;
130 } vnic_ioc_create_t;
131 
132 #define	VNIC_IOC_DELETE		VNICIOC(2)
133 
134 typedef struct vnic_ioc_delete {
135 	datalink_id_t	vd_vnic_id;
136 } vnic_ioc_delete_t;
137 
138 #define	VNIC_IOC_INFO		VNICIOC(3)
139 
140 typedef struct vnic_info {
141 	datalink_id_t	vn_vnic_id;
142 	datalink_id_t	vn_link_id;
143 	vnic_mac_addr_type_t vn_mac_addr_type;
144 	uint_t		vn_mac_len;
145 	uchar_t		vn_mac_addr[MAXMACADDRLEN];
146 	uint_t		vn_mac_slot;
147 	uint32_t	vn_mac_prefix_len;
148 	uint16_t	vn_vid;
149 	vrid_t		vn_vrid;
150 	int		vn_af;
151 	boolean_t	vn_force;
152 	mac_resource_props_t vn_resource_props;
153 } vnic_info_t;
154 
155 typedef struct vnic_ioc_info {
156 	vnic_info_t	vi_info;
157 } vnic_ioc_info_t;
158 
159 #define	VNIC_IOC_MODIFY		VNICIOC(4)
160 
161 #define	VNIC_IOC_MODIFY_ADDR		0x01
162 #define	VNIC_IOC_MODIFY_RESOURCE_CTL	0x02
163 
164 typedef struct vnic_ioc_modify {
165 	datalink_id_t	vm_vnic_id;
166 	uint_t		vm_modify_mask;
167 	uint_t		vm_mac_len;
168 	int		vm_mac_slot;
169 	uchar_t		vm_mac_addr[MAXMACADDRLEN];
170 	vnic_mac_addr_type_t vm_mac_addr_type;
171 	mac_resource_props_t vm_resource_props;
172 	vnic_ioc_diag_t	vm_diag;
173 } vnic_ioc_modify_t;
174 
175 #if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4
176 #pragma pack()
177 #endif
178 
179 #ifdef	__cplusplus
180 }
181 #endif
182 
183 #endif	/* _SYS_VNIC_H */
184