xref: /titanic_52/usr/src/uts/common/sys/aggr.h (revision 1a7c1b724419d3cb5fa6eea75123c6b2060ba31b)
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, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef	_SYS_AGGR_H
28 #define	_SYS_AGGR_H
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 #include <sys/types.h>
33 #include <sys/ethernet.h>
34 #include <sys/param.h>
35 
36 #ifdef	__cplusplus
37 extern "C" {
38 #endif
39 
40 /* control interface name */
41 #define	AGGR_DEVNAME_CTL	"ctl"
42 
43 /*
44  * Transmit load balancing policies.
45  */
46 
47 #define	AGGR_POLICY_L2		0x01
48 #define	AGGR_POLICY_L3		0x02
49 #define	AGGR_POLICY_L4		0x04
50 
51 /*
52  * LACP mode and timer.
53  */
54 
55 typedef enum {
56 	AGGR_LACP_OFF		= 0,
57 	AGGR_LACP_ACTIVE	= 1,
58 	AGGR_LACP_PASSIVE	= 2
59 } aggr_lacp_mode_t;
60 
61 typedef enum {
62 	AGGR_LACP_TIMER_LONG	= 0,
63 	AGGR_LACP_TIMER_SHORT	= 1
64 } aggr_lacp_timer_t;
65 
66 /*
67  * MAC port state.
68  */
69 typedef enum {
70 	AGGR_PORT_STATE_STANDBY = 1,
71 	AGGR_PORT_STATE_ATTACHED = 2
72 } aggr_port_state_t;
73 
74 /* Maximum number of ports per aggregation. */
75 #define	AGGR_MAX_PORTS	256
76 
77 /*
78  * LACP port state.
79  */
80 typedef union {
81 	struct {
82 #if defined(_BIT_FIELDS_HTOL)
83 		uint8_t expired:	1;
84 		uint8_t defaulted:	1;
85 		uint8_t distributing:	1;
86 		uint8_t collecting:	1;
87 		uint8_t sync:	1;
88 		uint8_t aggregation:	1;
89 		uint8_t timeout:	1;
90 		uint8_t	activity:	1;
91 #elif defined(_BIT_FIELDS_LTOH)
92 		uint8_t	activity:	1;
93 		uint8_t timeout:	1;
94 		uint8_t aggregation:	1;
95 		uint8_t sync:	1;
96 		uint8_t collecting:	1;
97 		uint8_t distributing:	1;
98 		uint8_t defaulted:	1;
99 		uint8_t expired:	1;
100 #else
101 #error "unknown bit fields ordering"
102 #endif
103 	} bit;
104 	uint8_t state;
105 } aggr_lacp_state_t;
106 
107 #define	LAIOC(x)		(('l' << 24) | ('a' << 16) | ('m' << 8) | (x))
108 
109 /* one of the ports of a link aggregation group */
110 typedef struct laioc_port {
111 	char		lp_devname[MAXNAMELEN + 1];
112 	uint_t		lp_port;
113 } laioc_port_t;
114 
115 #define	LAIOC_CREATE		LAIOC(1)
116 
117 typedef struct laioc_create {
118 	uint32_t	lc_key;
119 	uint32_t	lc_nports;
120 	caddr_t		lc_ports;	/* ptr to lacio_port_t */
121 	uint32_t	lc_policy;
122 	uchar_t		lc_mac[ETHERADDRL];
123 	boolean_t	lc_mac_fixed;
124 	aggr_lacp_mode_t lc_lacp_mode;
125 	aggr_lacp_timer_t lc_lacp_timer;
126 } laioc_create_t;
127 
128 #ifdef _SYSCALL32
129 
130 typedef struct laioc_create32 {
131 	uint32_t	lc_key;
132 	uint32_t	lc_nports;
133 	caddr32_t	lc_ports;
134 	uint32_t	lc_policy;
135 	uchar_t		lc_mac[ETHERADDRL];
136 	boolean_t	lc_mac_fixed;
137 	aggr_lacp_mode_t lc_lacp_mode;
138 	aggr_lacp_timer_t lc_lacp_timer;
139 } laioc_create32_t;
140 
141 #endif /* _SYSCALL32 */
142 
143 #define	LAIOC_DELETE		LAIOC(2)
144 
145 typedef struct laioc_delete {
146 	uint32_t	ld_key;
147 } laioc_delete_t;
148 
149 #ifdef _SYSCALL32
150 
151 typedef struct laioc_delete32 {
152 	uint32_t	ld_key;
153 } laioc_delete32_t;
154 
155 #endif /* _SYSCALL32 */
156 
157 #define	LAIOC_INFO		LAIOC(3)
158 
159 typedef enum aggr_link_duplex {
160 	AGGR_LINK_DUPLEX_FULL = 1,
161 	AGGR_LINK_DUPLEX_HALF = 2,
162 	AGGR_LINK_DUPLEX_UNKNOWN = 3
163 } aggr_link_duplex_t;
164 
165 typedef enum aggr_link_state {
166 	AGGR_LINK_STATE_UP = 1,
167 	AGGR_LINK_STATE_DOWN = 2,
168 	AGGR_LINK_STATE_UNKNOWN = 3
169 } aggr_link_state_t;
170 
171 typedef struct laioc_info_port {
172 	char		lp_devname[MAXNAMELEN + 1];
173 	uint32_t	lp_port;
174 	uchar_t		lp_mac[ETHERADDRL];
175 	aggr_port_state_t lp_state;
176 	aggr_lacp_state_t lp_lacp_state;
177 } laioc_info_port_t;
178 
179 typedef struct laioc_info_group {
180 	uint32_t	lg_key;
181 	uchar_t		lg_mac[ETHERADDRL];
182 	boolean_t	lg_mac_fixed;
183 	uint32_t	lg_policy;
184 	uint32_t	lg_nports;
185 	aggr_lacp_mode_t lg_lacp_mode;
186 	aggr_lacp_timer_t lg_lacp_timer;
187 } laioc_info_group_t;
188 
189 typedef struct laioc_info {
190 	uint32_t	li_bufsize;
191 	uint32_t	li_ngroups;
192 	uint32_t	li_group_key;	/* 0 returns all */
193 } laioc_info_t;
194 
195 #define	LAIOC_ADD		LAIOC(4)
196 #define	LAIOC_REMOVE		LAIOC(5)
197 
198 typedef struct laioc_add_rem {
199 	uint32_t	la_key;
200 	uint32_t	la_nports;
201 	caddr_t		la_ports;
202 } laioc_add_t;
203 
204 #ifdef _SYSCALL32
205 
206 typedef struct laioc_add_rem32 {
207 	uint32_t	la_key;
208 	uint32_t	la_nports;
209 	caddr32_t	la_ports;
210 } laioc_add_rem32_t;
211 
212 #endif /* _SYSCALL32 */
213 
214 #define	LAIOC_MODIFY			LAIOC(6)
215 
216 #define	LAIOC_MODIFY_POLICY		0x01
217 #define	LAIOC_MODIFY_MAC		0x02
218 #define	LAIOC_MODIFY_LACP_MODE		0x04
219 #define	LAIOC_MODIFY_LACP_TIMER		0x08
220 
221 typedef struct laioc_modify {
222 	uint32_t	lu_key;
223 	uint8_t		lu_modify_mask;
224 	uint32_t	lu_policy;
225 	uchar_t		lu_mac[ETHERADDRL];
226 	boolean_t	lu_mac_fixed;
227 	aggr_lacp_mode_t lu_lacp_mode;
228 	aggr_lacp_timer_t lu_lacp_timer;
229 } laioc_modify_t;
230 
231 #ifdef _SYSCALL32
232 
233 typedef struct laioc_modify32 {
234 	uint32_t	lu_key;
235 	uint8_t		lu_modify_mask;
236 	uint32_t	lu_policy;
237 	uchar_t		lu_mac[ETHERADDRL];
238 	boolean_t	lu_mac_fixed;
239 	aggr_lacp_mode_t lu_lacp_mode;
240 	aggr_lacp_timer_t lu_lacp_timer;
241 } laioc_modify32_t;
242 
243 #endif /* _SYSCALL32 */
244 
245 #ifdef	__cplusplus
246 }
247 #endif
248 
249 #endif	/* _SYS_AGGR_H */
250