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