xref: /titanic_44/usr/src/uts/common/sys/aggr.h (revision 587032cf0967234b39ccb50adca936a367841063)
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 	uint32_t	lc_policy;
121 	uchar_t		lc_mac[ETHERADDRL];
122 	boolean_t	lc_mac_fixed;
123 	aggr_lacp_mode_t lc_lacp_mode;
124 	aggr_lacp_timer_t lc_lacp_timer;
125 } laioc_create_t;
126 
127 #ifdef _SYSCALL32
128 
129 typedef struct laioc_create32 {
130 	uint32_t	lc_key;
131 	uint32_t	lc_nports;
132 	uint32_t	lc_policy;
133 	uchar_t		lc_mac[ETHERADDRL];
134 	boolean_t	lc_mac_fixed;
135 	aggr_lacp_mode_t lc_lacp_mode;
136 	aggr_lacp_timer_t lc_lacp_timer;
137 } laioc_create32_t;
138 
139 #endif /* _SYSCALL32 */
140 
141 #define	LAIOC_DELETE		LAIOC(2)
142 
143 typedef struct laioc_delete {
144 	uint32_t	ld_key;
145 } laioc_delete_t;
146 
147 #ifdef _SYSCALL32
148 
149 typedef struct laioc_delete32 {
150 	uint32_t	ld_key;
151 } laioc_delete32_t;
152 
153 #endif /* _SYSCALL32 */
154 
155 #define	LAIOC_INFO		LAIOC(3)
156 
157 typedef enum aggr_link_duplex {
158 	AGGR_LINK_DUPLEX_FULL = 1,
159 	AGGR_LINK_DUPLEX_HALF = 2,
160 	AGGR_LINK_DUPLEX_UNKNOWN = 3
161 } aggr_link_duplex_t;
162 
163 typedef enum aggr_link_state {
164 	AGGR_LINK_STATE_UP = 1,
165 	AGGR_LINK_STATE_DOWN = 2,
166 	AGGR_LINK_STATE_UNKNOWN = 3
167 } aggr_link_state_t;
168 
169 typedef struct laioc_info_port {
170 	char		lp_devname[MAXNAMELEN + 1];
171 	uint32_t	lp_port;
172 	uchar_t		lp_mac[ETHERADDRL];
173 	aggr_port_state_t lp_state;
174 	aggr_lacp_state_t lp_lacp_state;
175 } laioc_info_port_t;
176 
177 typedef struct laioc_info_group {
178 	uint32_t	lg_key;
179 	uchar_t		lg_mac[ETHERADDRL];
180 	boolean_t	lg_mac_fixed;
181 	uint32_t	lg_policy;
182 	uint32_t	lg_nports;
183 	aggr_lacp_mode_t lg_lacp_mode;
184 	aggr_lacp_timer_t lg_lacp_timer;
185 } laioc_info_group_t;
186 
187 typedef struct laioc_info {
188 	uint32_t	li_ngroups;
189 	uint32_t	li_group_key;	/* 0 returns all */
190 } laioc_info_t;
191 
192 #define	LAIOC_ADD		LAIOC(4)
193 #define	LAIOC_REMOVE		LAIOC(5)
194 
195 typedef struct laioc_add_rem {
196 	uint32_t	la_key;
197 	uint32_t	la_nports;
198 } laioc_add_rem_t;
199 
200 #ifdef _SYSCALL32
201 
202 typedef struct laioc_add_rem32 {
203 	uint32_t	la_key;
204 	uint32_t	la_nports;
205 } laioc_add_rem32_t;
206 
207 #endif /* _SYSCALL32 */
208 
209 #define	LAIOC_MODIFY			LAIOC(6)
210 
211 #define	LAIOC_MODIFY_POLICY		0x01
212 #define	LAIOC_MODIFY_MAC		0x02
213 #define	LAIOC_MODIFY_LACP_MODE		0x04
214 #define	LAIOC_MODIFY_LACP_TIMER		0x08
215 
216 typedef struct laioc_modify {
217 	uint32_t	lu_key;
218 	uint8_t		lu_modify_mask;
219 	uint32_t	lu_policy;
220 	uchar_t		lu_mac[ETHERADDRL];
221 	boolean_t	lu_mac_fixed;
222 	aggr_lacp_mode_t lu_lacp_mode;
223 	aggr_lacp_timer_t lu_lacp_timer;
224 } laioc_modify_t;
225 
226 #ifdef _SYSCALL32
227 
228 typedef struct laioc_modify32 {
229 	uint32_t	lu_key;
230 	uint8_t		lu_modify_mask;
231 	uint32_t	lu_policy;
232 	uchar_t		lu_mac[ETHERADDRL];
233 	boolean_t	lu_mac_fixed;
234 	aggr_lacp_mode_t lu_lacp_mode;
235 	aggr_lacp_timer_t lu_lacp_timer;
236 } laioc_modify32_t;
237 
238 #endif /* _SYSCALL32 */
239 
240 #ifdef	__cplusplus
241 }
242 #endif
243 
244 #endif	/* _SYS_AGGR_H */
245