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