xref: /titanic_51/usr/src/uts/common/sys/aggr.h (revision 15d9d0b528387242011cdcc6190c9e598cfe3a07)
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 2008 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 #ifndef	_SYS_AGGR_H
27 #define	_SYS_AGGR_H
28 
29 #pragma ident	"%Z%%M%	%I%	%E% SMI"
30 
31 #include <sys/types.h>
32 #include <sys/ethernet.h>
33 #include <sys/mac.h>
34 #include <sys/dls.h>
35 #include <sys/param.h>
36 
37 #ifdef	__cplusplus
38 extern "C" {
39 #endif
40 
41 /* control interface name */
42 #define	AGGR_DEVNAME_CTL	"ctl"
43 
44 /*
45  * Transmit load balancing policies.
46  */
47 
48 #define	AGGR_POLICY_L2		0x01
49 #define	AGGR_POLICY_L3		0x02
50 #define	AGGR_POLICY_L4		0x04
51 
52 /*
53  * LACP mode and timer.
54  */
55 
56 typedef enum {
57 	AGGR_LACP_OFF		= 0,
58 	AGGR_LACP_ACTIVE	= 1,
59 	AGGR_LACP_PASSIVE	= 2
60 } aggr_lacp_mode_t;
61 
62 typedef enum {
63 	AGGR_LACP_TIMER_LONG	= 0,
64 	AGGR_LACP_TIMER_SHORT	= 1
65 } aggr_lacp_timer_t;
66 
67 /*
68  * MAC port state.
69  */
70 typedef enum {
71 	AGGR_PORT_STATE_STANDBY = 1,
72 	AGGR_PORT_STATE_ATTACHED = 2
73 } aggr_port_state_t;
74 
75 /* Maximum number of ports per aggregation. */
76 #define	AGGR_MAX_PORTS	256
77 
78 /*
79  * The largest configurable aggregation key.  Because by default the key is
80  * used as the DLPI device PPA and default VLAN PPA's are calculated as
81  * ((1000 * vid) + PPA), the largest key can't be > 999.
82  */
83 #define	AGGR_MAX_KEY	999
84 
85 /*
86  * LACP port state.
87  */
88 typedef union {
89 	struct {
90 #if defined(_BIT_FIELDS_HTOL)
91 		uint8_t expired:	1;
92 		uint8_t defaulted:	1;
93 		uint8_t distributing:	1;
94 		uint8_t collecting:	1;
95 		uint8_t sync:	1;
96 		uint8_t aggregation:	1;
97 		uint8_t timeout:	1;
98 		uint8_t	activity:	1;
99 #elif defined(_BIT_FIELDS_LTOH)
100 		uint8_t	activity:	1;
101 		uint8_t timeout:	1;
102 		uint8_t aggregation:	1;
103 		uint8_t sync:	1;
104 		uint8_t collecting:	1;
105 		uint8_t distributing:	1;
106 		uint8_t defaulted:	1;
107 		uint8_t expired:	1;
108 #else
109 #error "unknown bit fields ordering"
110 #endif
111 	} bit;
112 	uint8_t state;
113 } aggr_lacp_state_t;
114 
115 #define	LAIOC(x)		(('l' << 24) | ('a' << 16) | ('m' << 8) | (x))
116 
117 /* one of the ports of a link aggregation group */
118 typedef struct laioc_port {
119 	datalink_id_t	lp_linkid;
120 } laioc_port_t;
121 
122 #define	LAIOC_CREATE		LAIOC(1)
123 
124 typedef struct laioc_create {
125 	datalink_id_t	lc_linkid;
126 	uint32_t	lc_key;
127 	uint32_t	lc_nports;
128 	uint32_t	lc_policy;
129 	uchar_t		lc_mac[ETHERADDRL];
130 	aggr_lacp_mode_t lc_lacp_mode;
131 	aggr_lacp_timer_t lc_lacp_timer;
132 	uint32_t	lc_mac_fixed : 1,
133 			lc_force : 1,
134 			lc_pad_bits : 30;
135 } laioc_create_t;
136 
137 #ifdef _SYSCALL32
138 
139 typedef struct laioc_create32 {
140 	datalink_id_t	lc_linkid;
141 	uint32_t	lc_key;
142 	uint32_t	lc_nports;
143 	uint32_t	lc_policy;
144 	uchar_t		lc_mac[ETHERADDRL];
145 	aggr_lacp_mode_t lc_lacp_mode;
146 	aggr_lacp_timer_t lc_lacp_timer;
147 	uint32_t	lc_mac_fixed : 1,
148 			lc_force : 1,
149 			lc_pad_bits : 30;
150 } laioc_create32_t;
151 
152 #endif /* _SYSCALL32 */
153 
154 #define	LAIOC_DELETE		LAIOC(2)
155 
156 typedef struct laioc_delete {
157 	datalink_id_t	ld_linkid;
158 } laioc_delete_t;
159 
160 #ifdef _SYSCALL32
161 
162 typedef struct laioc_delete32 {
163 	datalink_id_t	ld_linkid;
164 } laioc_delete32_t;
165 
166 #endif /* _SYSCALL32 */
167 
168 #define	LAIOC_INFO		LAIOC(3)
169 
170 typedef enum aggr_link_duplex {
171 	AGGR_LINK_DUPLEX_FULL = 1,
172 	AGGR_LINK_DUPLEX_HALF = 2,
173 	AGGR_LINK_DUPLEX_UNKNOWN = 3
174 } aggr_link_duplex_t;
175 
176 typedef enum aggr_link_state {
177 	AGGR_LINK_STATE_UP = 1,
178 	AGGR_LINK_STATE_DOWN = 2,
179 	AGGR_LINK_STATE_UNKNOWN = 3
180 } aggr_link_state_t;
181 
182 typedef struct laioc_info_port {
183 	datalink_id_t	lp_linkid;
184 	uchar_t		lp_mac[ETHERADDRL];
185 	aggr_port_state_t lp_state;
186 	aggr_lacp_state_t lp_lacp_state;
187 } laioc_info_port_t;
188 
189 typedef struct laioc_info_group {
190 	datalink_id_t	lg_linkid;
191 	uint32_t	lg_key;
192 	uchar_t		lg_mac[ETHERADDRL];
193 	boolean_t	lg_mac_fixed;
194 	boolean_t	lg_force;
195 	uint32_t	lg_policy;
196 	uint32_t	lg_nports;
197 	aggr_lacp_mode_t lg_lacp_mode;
198 	aggr_lacp_timer_t lg_lacp_timer;
199 } laioc_info_group_t;
200 
201 typedef struct laioc_info {
202 	/* Must not be DLADM_INVALID_LINKID */
203 	datalink_id_t	li_group_linkid;
204 } laioc_info_t;
205 
206 #define	LAIOC_ADD		LAIOC(4)
207 #define	LAIOC_REMOVE		LAIOC(5)
208 
209 typedef struct laioc_add_rem {
210 	datalink_id_t	la_linkid;
211 	uint32_t	la_nports;
212 	uint32_t	la_force;
213 } laioc_add_rem_t;
214 
215 #ifdef _SYSCALL32
216 
217 typedef struct laioc_add_rem32 {
218 	datalink_id_t	la_linkid;
219 	uint32_t	la_nports;
220 	uint32_t	la_force;
221 } laioc_add_rem32_t;
222 
223 #endif /* _SYSCALL32 */
224 
225 #define	LAIOC_MODIFY			LAIOC(6)
226 
227 #define	LAIOC_MODIFY_POLICY		0x01
228 #define	LAIOC_MODIFY_MAC		0x02
229 #define	LAIOC_MODIFY_LACP_MODE		0x04
230 #define	LAIOC_MODIFY_LACP_TIMER		0x08
231 
232 typedef struct laioc_modify {
233 	datalink_id_t	lu_linkid;
234 	uint8_t		lu_modify_mask;
235 	uint32_t	lu_policy;
236 	uchar_t		lu_mac[ETHERADDRL];
237 	boolean_t	lu_mac_fixed;
238 	aggr_lacp_mode_t lu_lacp_mode;
239 	aggr_lacp_timer_t lu_lacp_timer;
240 } laioc_modify_t;
241 
242 #ifdef _SYSCALL32
243 
244 typedef struct laioc_modify32 {
245 	datalink_id_t	lu_linkid;
246 	uint8_t		lu_modify_mask;
247 	uint32_t	lu_policy;
248 	uchar_t		lu_mac[ETHERADDRL];
249 	boolean_t	lu_mac_fixed;
250 	aggr_lacp_mode_t lu_lacp_mode;
251 	aggr_lacp_timer_t lu_lacp_timer;
252 } laioc_modify32_t;
253 
254 #endif /* _SYSCALL32 */
255 
256 #ifdef	__cplusplus
257 }
258 #endif
259 
260 #endif	/* _SYS_AGGR_H */
261