xref: /titanic_44/usr/src/uts/common/sys/aggr.h (revision 3c4993fb5a74112f361d71dab20997bdc749a7fb)
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 2006 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/param.h>
34 
35 #ifdef	__cplusplus
36 extern "C" {
37 #endif
38 
39 /* control interface name */
40 #define	AGGR_DEVNAME_CTL	"ctl"
41 
42 /*
43  * Transmit load balancing policies.
44  */
45 
46 #define	AGGR_POLICY_L2		0x01
47 #define	AGGR_POLICY_L3		0x02
48 #define	AGGR_POLICY_L4		0x04
49 
50 /*
51  * LACP mode and timer.
52  */
53 
54 typedef enum {
55 	AGGR_LACP_OFF		= 0,
56 	AGGR_LACP_ACTIVE	= 1,
57 	AGGR_LACP_PASSIVE	= 2
58 } aggr_lacp_mode_t;
59 
60 typedef enum {
61 	AGGR_LACP_TIMER_LONG	= 0,
62 	AGGR_LACP_TIMER_SHORT	= 1
63 } aggr_lacp_timer_t;
64 
65 /*
66  * MAC port state.
67  */
68 typedef enum {
69 	AGGR_PORT_STATE_STANDBY = 1,
70 	AGGR_PORT_STATE_ATTACHED = 2
71 } aggr_port_state_t;
72 
73 /* Maximum number of ports per aggregation. */
74 #define	AGGR_MAX_PORTS	256
75 
76 /*
77  * LACP port state.
78  */
79 typedef union {
80 	struct {
81 #if defined(_BIT_FIELDS_HTOL)
82 		uint8_t expired:	1;
83 		uint8_t defaulted:	1;
84 		uint8_t distributing:	1;
85 		uint8_t collecting:	1;
86 		uint8_t sync:	1;
87 		uint8_t aggregation:	1;
88 		uint8_t timeout:	1;
89 		uint8_t	activity:	1;
90 #elif defined(_BIT_FIELDS_LTOH)
91 		uint8_t	activity:	1;
92 		uint8_t timeout:	1;
93 		uint8_t aggregation:	1;
94 		uint8_t sync:	1;
95 		uint8_t collecting:	1;
96 		uint8_t distributing:	1;
97 		uint8_t defaulted:	1;
98 		uint8_t expired:	1;
99 #else
100 #error "unknown bit fields ordering"
101 #endif
102 	} bit;
103 	uint8_t state;
104 } aggr_lacp_state_t;
105 
106 #define	LAIOC(x)		(('l' << 24) | ('a' << 16) | ('m' << 8) | (x))
107 
108 /* one of the ports of a link aggregation group */
109 typedef struct laioc_port {
110 	char		lp_devname[MAXNAMELEN + 1];
111 } laioc_port_t;
112 
113 #define	LAIOC_CREATE		LAIOC(1)
114 
115 typedef struct laioc_create {
116 	uint32_t	lc_key;
117 	uint32_t	lc_nports;
118 	uint32_t	lc_policy;
119 	uchar_t		lc_mac[ETHERADDRL];
120 	boolean_t	lc_mac_fixed;
121 	aggr_lacp_mode_t lc_lacp_mode;
122 	aggr_lacp_timer_t lc_lacp_timer;
123 } laioc_create_t;
124 
125 #ifdef _SYSCALL32
126 
127 typedef struct laioc_create32 {
128 	uint32_t	lc_key;
129 	uint32_t	lc_nports;
130 	uint32_t	lc_policy;
131 	uchar_t		lc_mac[ETHERADDRL];
132 	boolean_t	lc_mac_fixed;
133 	aggr_lacp_mode_t lc_lacp_mode;
134 	aggr_lacp_timer_t lc_lacp_timer;
135 } laioc_create32_t;
136 
137 #endif /* _SYSCALL32 */
138 
139 #define	LAIOC_DELETE		LAIOC(2)
140 
141 typedef struct laioc_delete {
142 	uint32_t	ld_key;
143 } laioc_delete_t;
144 
145 #ifdef _SYSCALL32
146 
147 typedef struct laioc_delete32 {
148 	uint32_t	ld_key;
149 } laioc_delete32_t;
150 
151 #endif /* _SYSCALL32 */
152 
153 #define	LAIOC_INFO		LAIOC(3)
154 
155 typedef enum aggr_link_duplex {
156 	AGGR_LINK_DUPLEX_FULL = 1,
157 	AGGR_LINK_DUPLEX_HALF = 2,
158 	AGGR_LINK_DUPLEX_UNKNOWN = 3
159 } aggr_link_duplex_t;
160 
161 typedef enum aggr_link_state {
162 	AGGR_LINK_STATE_UP = 1,
163 	AGGR_LINK_STATE_DOWN = 2,
164 	AGGR_LINK_STATE_UNKNOWN = 3
165 } aggr_link_state_t;
166 
167 typedef struct laioc_info_port {
168 	char		lp_devname[MAXNAMELEN + 1];
169 	uchar_t		lp_mac[ETHERADDRL];
170 	aggr_port_state_t lp_state;
171 	aggr_lacp_state_t lp_lacp_state;
172 } laioc_info_port_t;
173 
174 typedef struct laioc_info_group {
175 	uint32_t	lg_key;
176 	uchar_t		lg_mac[ETHERADDRL];
177 	boolean_t	lg_mac_fixed;
178 	uint32_t	lg_policy;
179 	uint32_t	lg_nports;
180 	aggr_lacp_mode_t lg_lacp_mode;
181 	aggr_lacp_timer_t lg_lacp_timer;
182 } laioc_info_group_t;
183 
184 typedef struct laioc_info {
185 	uint32_t	li_ngroups;
186 	uint32_t	li_group_key;	/* 0 returns all */
187 } laioc_info_t;
188 
189 #define	LAIOC_ADD		LAIOC(4)
190 #define	LAIOC_REMOVE		LAIOC(5)
191 
192 typedef struct laioc_add_rem {
193 	uint32_t	la_key;
194 	uint32_t	la_nports;
195 } laioc_add_rem_t;
196 
197 #ifdef _SYSCALL32
198 
199 typedef struct laioc_add_rem32 {
200 	uint32_t	la_key;
201 	uint32_t	la_nports;
202 } laioc_add_rem32_t;
203 
204 #endif /* _SYSCALL32 */
205 
206 #define	LAIOC_MODIFY			LAIOC(6)
207 
208 #define	LAIOC_MODIFY_POLICY		0x01
209 #define	LAIOC_MODIFY_MAC		0x02
210 #define	LAIOC_MODIFY_LACP_MODE		0x04
211 #define	LAIOC_MODIFY_LACP_TIMER		0x08
212 
213 typedef struct laioc_modify {
214 	uint32_t	lu_key;
215 	uint8_t		lu_modify_mask;
216 	uint32_t	lu_policy;
217 	uchar_t		lu_mac[ETHERADDRL];
218 	boolean_t	lu_mac_fixed;
219 	aggr_lacp_mode_t lu_lacp_mode;
220 	aggr_lacp_timer_t lu_lacp_timer;
221 } laioc_modify_t;
222 
223 #ifdef _SYSCALL32
224 
225 typedef struct laioc_modify32 {
226 	uint32_t	lu_key;
227 	uint8_t		lu_modify_mask;
228 	uint32_t	lu_policy;
229 	uchar_t		lu_mac[ETHERADDRL];
230 	boolean_t	lu_mac_fixed;
231 	aggr_lacp_mode_t lu_lacp_mode;
232 	aggr_lacp_timer_t lu_lacp_timer;
233 } laioc_modify32_t;
234 
235 #endif /* _SYSCALL32 */
236 
237 #ifdef	__cplusplus
238 }
239 #endif
240 
241 #endif	/* _SYS_AGGR_H */
242