xref: /titanic_41/usr/src/uts/common/sys/vnic.h (revision 02d09e03eb27f3a2dc299de704e45dae5173f43f)
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 2009 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_t;
60 
61 /*
62  * Allowed VNIC MAC address types.
63  *
64  * - VNIC_MAC_ADDR_TYPE_FIXED, VNIC_MAC_ADDR_TYPE_RANDOM:
65  *   The MAC address is specified by value by the caller, which
66  *   itself can obtain it from the user directly,
67  *   or pick it in a random fashion. Which method is used by the
68  *   caller is irrelevant to the VNIC driver. However two different
69  *   types are provided so that the information can be made available
70  *   back to user-space when listing the kernel defined VNICs.
71  *
72  *   When a VNIC is created, the address in passed through the
73  *   vc_mac_addr and vc_mac_len fields of the vnic_ioc_create_t
74  *   structure.
75  *
76  * - VNIC_MAC_ADDR_TYPE_FACTORY: the MAC address is obtained from
77  *   one of the MAC factory MAC addresses of the underyling NIC.
78  *
79  * - VNIC_MAC_ADDR_TYPE_AUTO: the VNIC driver attempts to
80  *   obtain the address from one of the factory MAC addresses of
81  *   the underlying NIC. If none is available, the specified
82  *   MAC address value is used.
83  *
84  * - VNIC_MAC_ADDR_TYPE_PRIMARY: this is a VNIC based VLAN. The
85  *   address for this is the address of the primary MAC client.
86  *
87  */
88 
89 typedef enum {
90 	VNIC_MAC_ADDR_TYPE_UNKNOWN = -1,
91 	VNIC_MAC_ADDR_TYPE_FIXED,
92 	VNIC_MAC_ADDR_TYPE_RANDOM,
93 	VNIC_MAC_ADDR_TYPE_FACTORY,
94 	VNIC_MAC_ADDR_TYPE_AUTO,
95 	VNIC_MAC_ADDR_TYPE_PRIMARY,
96 	VNIC_MAC_ADDR_TYPE_VRID
97 } vnic_mac_addr_type_t;
98 
99 #if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4
100 #pragma pack(4)
101 #endif
102 
103 #define	VNIC_IOC_CREATE		VNICIOC(1)
104 
105 #define	VNIC_IOC_CREATE_NODUPCHECK		0x00000001
106 #define	VNIC_IOC_CREATE_ANCHOR			0x00000002
107 
108 /*
109  * Force creation of VLAN based VNIC without checking if the
110  * undelying MAC supports the margin size.
111  */
112 #define	VNIC_IOC_CREATE_FORCE			0x00000004
113 
114 /* Allocate a hardware ring to the vnic */
115 #define	VNIC_IOC_CREATE_REQ_HWRINGS		0x00000008
116 
117 typedef struct vnic_ioc_create {
118 	datalink_id_t	vc_vnic_id;
119 	datalink_id_t	vc_link_id;
120 	vnic_mac_addr_type_t vc_mac_addr_type;
121 	uint_t		vc_mac_len;
122 	uchar_t		vc_mac_addr[MAXMACADDRLEN];
123 	uint_t		vc_mac_prefix_len;
124 	int		vc_mac_slot;
125 	uint16_t	vc_vid;
126 	vrid_t		vc_vrid;
127 	int		vc_af;
128 	uint_t		vc_status;
129 	uint_t		vc_flags;
130 	vnic_ioc_diag_t	vc_diag;
131 	mac_resource_props_t vc_resource_props;
132 } vnic_ioc_create_t;
133 
134 #define	VNIC_IOC_DELETE		VNICIOC(2)
135 
136 typedef struct vnic_ioc_delete {
137 	datalink_id_t	vd_vnic_id;
138 } vnic_ioc_delete_t;
139 
140 #define	VNIC_IOC_INFO		VNICIOC(3)
141 
142 typedef struct vnic_info {
143 	datalink_id_t	vn_vnic_id;
144 	datalink_id_t	vn_link_id;
145 	vnic_mac_addr_type_t vn_mac_addr_type;
146 	uint_t		vn_mac_len;
147 	uchar_t		vn_mac_addr[MAXMACADDRLEN];
148 	uint_t		vn_mac_slot;
149 	uint32_t	vn_mac_prefix_len;
150 	uint16_t	vn_vid;
151 	vrid_t		vn_vrid;
152 	int		vn_af;
153 	boolean_t	vn_force;
154 	mac_resource_props_t vn_resource_props;
155 } vnic_info_t;
156 
157 typedef struct vnic_ioc_info {
158 	vnic_info_t	vi_info;
159 } vnic_ioc_info_t;
160 
161 #define	VNIC_IOC_MODIFY		VNICIOC(4)
162 
163 #define	VNIC_IOC_MODIFY_ADDR		0x01
164 #define	VNIC_IOC_MODIFY_RESOURCE_CTL	0x02
165 
166 typedef struct vnic_ioc_modify {
167 	datalink_id_t	vm_vnic_id;
168 	uint_t		vm_modify_mask;
169 	uint_t		vm_mac_len;
170 	int		vm_mac_slot;
171 	uchar_t		vm_mac_addr[MAXMACADDRLEN];
172 	vnic_mac_addr_type_t vm_mac_addr_type;
173 	mac_resource_props_t vm_resource_props;
174 	vnic_ioc_diag_t	vm_diag;
175 } vnic_ioc_modify_t;
176 
177 #if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4
178 #pragma pack()
179 #endif
180 
181 #ifdef	__cplusplus
182 }
183 #endif
184 
185 #endif	/* _SYS_VNIC_H */
186