xref: /titanic_52/usr/src/uts/common/sys/aggr.h (revision 0bb073995ac5a95bd35f2dd790df1ea3d8c2d507)
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 #include <sys/types.h>
30 #include <sys/ethernet.h>
31 #include <sys/mac.h>
32 #include <sys/dls.h>
33 #include <sys/param.h>
34 #include <sys/dld_ioc.h>
35 
36 #ifdef	__cplusplus
37 extern "C" {
38 #endif
39 
40 /*
41  * Note that the datastructures defined here define an ioctl interface
42  * that is shared betwen user and kernel space.  The aggr driver thus
43  * assumes that the structures have identical layout and size when
44  * compiled in either IPL32 or LP64.
45  */
46 
47 /*
48  * Transmit load balancing policies.
49  */
50 
51 #define	AGGR_POLICY_L2		0x01
52 #define	AGGR_POLICY_L3		0x02
53 #define	AGGR_POLICY_L4		0x04
54 
55 /*
56  * LACP mode and timer.
57  */
58 
59 typedef enum {
60 	AGGR_LACP_OFF		= 0,
61 	AGGR_LACP_ACTIVE	= 1,
62 	AGGR_LACP_PASSIVE	= 2
63 } aggr_lacp_mode_t;
64 
65 typedef enum {
66 	AGGR_LACP_TIMER_LONG	= 0,
67 	AGGR_LACP_TIMER_SHORT	= 1
68 } aggr_lacp_timer_t;
69 
70 /*
71  * MAC port state.
72  */
73 typedef enum {
74 	AGGR_PORT_STATE_STANDBY = 1,
75 	AGGR_PORT_STATE_ATTACHED = 2
76 } aggr_port_state_t;
77 
78 /* Maximum number of ports per aggregation. */
79 #define	AGGR_MAX_PORTS	256
80 
81 /*
82  * The largest configurable aggregation key.  Because by default the key is
83  * used as the DLPI device PPA and default VLAN PPA's are calculated as
84  * ((1000 * vid) + PPA), the largest key can't be > 999.
85  */
86 #define	AGGR_MAX_KEY	999
87 
88 /*
89  * LACP port state.
90  */
91 typedef union {
92 	struct {
93 #if defined(_BIT_FIELDS_HTOL)
94 		uint8_t expired:	1;
95 		uint8_t defaulted:	1;
96 		uint8_t distributing:	1;
97 		uint8_t collecting:	1;
98 		uint8_t sync:	1;
99 		uint8_t aggregation:	1;
100 		uint8_t timeout:	1;
101 		uint8_t	activity:	1;
102 #elif defined(_BIT_FIELDS_LTOH)
103 		uint8_t	activity:	1;
104 		uint8_t timeout:	1;
105 		uint8_t aggregation:	1;
106 		uint8_t sync:	1;
107 		uint8_t collecting:	1;
108 		uint8_t distributing:	1;
109 		uint8_t defaulted:	1;
110 		uint8_t expired:	1;
111 #else
112 #error "unknown bit fields ordering"
113 #endif
114 	} bit;
115 	uint8_t state;
116 } aggr_lacp_state_t;
117 
118 /* one of the ports of a link aggregation group */
119 typedef struct laioc_port {
120 	datalink_id_t	lp_linkid;
121 } laioc_port_t;
122 
123 #define	LAIOC_CREATE		AGGRIOC(1)
124 
125 typedef struct laioc_create {
126 	datalink_id_t	lc_linkid;
127 	uint32_t	lc_key;
128 	uint32_t	lc_nports;
129 	uint32_t	lc_policy;
130 	uchar_t		lc_mac[ETHERADDRL];
131 	aggr_lacp_mode_t lc_lacp_mode;
132 	aggr_lacp_timer_t lc_lacp_timer;
133 	uint32_t	lc_mac_fixed : 1,
134 			lc_force : 1,
135 			lc_pad_bits : 30;
136 } laioc_create_t;
137 
138 #define	LAIOC_DELETE		AGGRIOC(2)
139 
140 typedef struct laioc_delete {
141 	datalink_id_t	ld_linkid;
142 } laioc_delete_t;
143 
144 #define	LAIOC_INFO		AGGRIOC(3)
145 
146 typedef enum aggr_link_duplex {
147 	AGGR_LINK_DUPLEX_FULL = 1,
148 	AGGR_LINK_DUPLEX_HALF = 2,
149 	AGGR_LINK_DUPLEX_UNKNOWN = 3
150 } aggr_link_duplex_t;
151 
152 typedef enum aggr_link_state {
153 	AGGR_LINK_STATE_UP = 1,
154 	AGGR_LINK_STATE_DOWN = 2,
155 	AGGR_LINK_STATE_UNKNOWN = 3
156 } aggr_link_state_t;
157 
158 typedef struct laioc_info_port {
159 	datalink_id_t	lp_linkid;
160 	uchar_t		lp_mac[ETHERADDRL];
161 	aggr_port_state_t lp_state;
162 	aggr_lacp_state_t lp_lacp_state;
163 } laioc_info_port_t;
164 
165 typedef struct laioc_info_group {
166 	datalink_id_t	lg_linkid;
167 	uint32_t	lg_key;
168 	uchar_t		lg_mac[ETHERADDRL];
169 	boolean_t	lg_mac_fixed;
170 	boolean_t	lg_force;
171 	uint32_t	lg_policy;
172 	uint32_t	lg_nports;
173 	aggr_lacp_mode_t lg_lacp_mode;
174 	aggr_lacp_timer_t lg_lacp_timer;
175 } laioc_info_group_t;
176 
177 typedef struct laioc_info {
178 	/* Must not be DLADM_INVALID_LINKID */
179 	datalink_id_t	li_group_linkid;
180 	uint32_t	li_bufsize;
181 } laioc_info_t;
182 
183 #define	LAIOC_ADD		AGGRIOC(4)
184 #define	LAIOC_REMOVE		AGGRIOC(5)
185 
186 typedef struct laioc_add_rem {
187 	datalink_id_t	la_linkid;
188 	uint32_t	la_nports;
189 	uint32_t	la_force;
190 } laioc_add_rem_t;
191 
192 #define	LAIOC_MODIFY			AGGRIOC(6)
193 
194 #define	LAIOC_MODIFY_POLICY		0x01
195 #define	LAIOC_MODIFY_MAC		0x02
196 #define	LAIOC_MODIFY_LACP_MODE		0x04
197 #define	LAIOC_MODIFY_LACP_TIMER		0x08
198 
199 typedef struct laioc_modify {
200 	datalink_id_t	lu_linkid;
201 	uint8_t		lu_modify_mask;
202 	uint32_t	lu_policy;
203 	uchar_t		lu_mac[ETHERADDRL];
204 	boolean_t	lu_mac_fixed;
205 	aggr_lacp_mode_t lu_lacp_mode;
206 	aggr_lacp_timer_t lu_lacp_timer;
207 } laioc_modify_t;
208 
209 #ifdef	__cplusplus
210 }
211 #endif
212 
213 #endif	/* _SYS_AGGR_H */
214