Print this page
6274 MAC tries to use aggr rings from downed links
Reviewed by: Bryan Cantrill <bryan@joyent.com>
Reviewed by: Patrick Mooney <patrick.mooney@joyent.com>
Reviewed by: Dan McDonald <danmcd@omniti.com>
Approved by: Richard Lowe <richlowe@richlowe.net>
| Split |
Close |
| Expand all |
| Collapse all |
--- old/usr/src/uts/common/sys/aggr_impl.h
+++ new/usr/src/uts/common/sys/aggr_impl.h
1 1 /*
2 2 * CDDL HEADER START
3 3 *
4 4 * The contents of this file are subject to the terms of the
5 5 * Common Development and Distribution License (the "License").
6 6 * You may not use this file except in compliance with the License.
7 7 *
8 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 9 * or http://www.opensolaris.org/os/licensing.
10 10 * See the License for the specific language governing permissions
11 11 * and limitations under the License.
12 12 *
13 13 * When distributing Covered Code, include this CDDL HEADER in each
14 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 15 * If applicable, add the following below this CDDL HEADER, with the
16 16 * fields enclosed by brackets "[]" replaced with your own identifying
17 17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 18 *
19 19 * CDDL HEADER END
20 20 */
21 21 /*
22 22 * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
23 23 * Use is subject to license terms.
24 24 * Copyright 2012 OmniTI Computer Consulting, Inc All rights reserved.
25 25 */
26 26
27 27 #ifndef _SYS_AGGR_IMPL_H
28 28 #define _SYS_AGGR_IMPL_H
29 29
30 30 #include <sys/types.h>
31 31 #include <sys/cred.h>
32 32 #include <sys/mac_ether.h>
33 33 #include <sys/mac_provider.h>
34 34 #include <sys/mac_client.h>
35 35 #include <sys/mac_client_priv.h>
36 36 #include <sys/aggr_lacp.h>
37 37
38 38 #ifdef __cplusplus
39 39 extern "C" {
40 40 #endif
41 41
42 42 #ifdef _KERNEL
43 43
44 44 #define AGGR_MINOR_CTL 1 /* control interface minor */
45 45
46 46 /* flags for aggr_grp_modify() */
47 47 #define AGGR_MODIFY_POLICY 0x01
48 48 #define AGGR_MODIFY_MAC 0x02
49 49 #define AGGR_MODIFY_LACP_MODE 0x04
50 50 #define AGGR_MODIFY_LACP_TIMER 0x08
51 51
52 52 /*
53 53 * Possible value of aggr_rseudo_rx_ring_t.arr_flags. Set when the ring entry
54 54 * in the pseudo RX group is used.
55 55 */
56 56 #define MAC_PSEUDO_RING_INUSE 0x01
57 57
58 58 typedef struct aggr_unicst_addr_s {
59 59 uint8_t aua_addr[ETHERADDRL];
60 60 struct aggr_unicst_addr_s *aua_next;
61 61 } aggr_unicst_addr_t;
62 62
63 63 typedef struct aggr_pseudo_rx_ring_s {
64 64 mac_ring_handle_t arr_rh; /* filled in by aggr_fill_ring() */
65 65 struct aggr_port_s *arr_port;
66 66 mac_ring_handle_t arr_hw_rh;
67 67 uint_t arr_flags;
68 68 uint64_t arr_gen;
69 69 } aggr_pseudo_rx_ring_t;
70 70
71 71 typedef struct aggr_pseudo_rx_group_s {
72 72 struct aggr_grp_s *arg_grp; /* filled in by aggr_fill_group() */
73 73 mac_group_handle_t arg_gh; /* filled in by aggr_fill_group() */
74 74 aggr_unicst_addr_t *arg_macaddr;
75 75 aggr_pseudo_rx_ring_t arg_rings[MAX_RINGS_PER_GROUP];
76 76 uint_t arg_ring_cnt;
77 77 } aggr_pseudo_rx_group_t;
78 78
79 79 typedef struct aggr_pseudo_tx_ring_s {
80 80 mac_ring_handle_t atr_rh; /* filled in by aggr_fill_ring() */
81 81 struct aggr_port_s *atr_port;
82 82 mac_ring_handle_t atr_hw_rh;
83 83 uint_t atr_flags;
84 84 } aggr_pseudo_tx_ring_t;
85 85
86 86 typedef struct aggr_pseudo_tx_group_s {
87 87 mac_group_handle_t atg_gh; /* filled in by aggr_fill_group() */
88 88 uint_t atg_ring_cnt;
89 89 aggr_pseudo_tx_ring_t atg_rings[MAX_RINGS_PER_GROUP];
90 90 } aggr_pseudo_tx_group_t;
91 91
92 92 /*
93 93 * A link aggregation MAC port.
94 94 * Note that lp_next is protected by the lg_lock of the group the
95 95 * port is part of.
96 96 */
97 97 typedef struct aggr_port_s {
98 98 struct aggr_port_s *lp_next;
99 99 struct aggr_grp_s *lp_grp; /* back ptr to group */
100 100 datalink_id_t lp_linkid;
101 101 uint16_t lp_portid;
102 102 uint8_t lp_addr[ETHERADDRL]; /* port MAC address */
103 103 uint32_t lp_refs; /* refcount */
104 104 aggr_port_state_t lp_state;
105 105 uint32_t lp_started : 1,
106 106 lp_tx_enabled : 1,
107 107 lp_collector_enabled : 1,
108 108 lp_promisc_on : 1,
109 109 lp_no_link_update : 1,
110 110 lp_rx_grp_added : 1,
111 111 lp_tx_grp_added : 1,
112 112 lp_closing : 1,
113 113 lp_pad_bits : 24;
114 114 mac_handle_t lp_mh;
115 115 mac_client_handle_t lp_mch;
116 116 const mac_info_t *lp_mip;
117 117 mac_notify_handle_t lp_mnh;
118 118 uint_t lp_tx_idx; /* idx in group's tx array */
119 119 uint64_t lp_ifspeed;
120 120 link_state_t lp_link_state;
121 121 link_duplex_t lp_link_duplex;
122 122 uint64_t lp_stat[MAC_NSTAT];
123 123 uint64_t lp_ether_stat[ETHER_NSTAT];
124 124 aggr_lacp_port_t lp_lacp; /* LACP state */
125 125 lacp_stats_t lp_lacp_stats;
126 126 uint32_t lp_margin;
127 127 mac_promisc_handle_t lp_mphp;
128 128 mac_unicast_handle_t lp_mah;
129 129
130 130 /* List of non-primary addresses that requires promiscous mode set */
131 131 aggr_unicst_addr_t *lp_prom_addr;
132 132 /* handle of the underlying HW RX group */
133 133 mac_group_handle_t lp_hwgh;
134 134 int lp_tx_ring_cnt;
135 135 /* handles of the underlying HW TX rings */
136 136 mac_ring_handle_t *lp_tx_rings;
137 137 /*
138 138 * Handles of the pseudo TX rings. Each of them maps to
139 139 * corresponding hardware TX ring in lp_tx_rings[]. A
140 140 * pseudo TX ring is presented to aggr primary mac
141 141 * client even when underlying NIC has no TX ring.
142 142 */
143 143 mac_ring_handle_t *lp_pseudo_tx_rings;
144 144 void *lp_tx_notify_mh;
145 145 } aggr_port_t;
146 146
147 147 /*
148 148 * A link aggregation group.
149 149 *
150 150 * The following per-group flags are defined:
151 151 *
152 152 * - lg_addr_fixed: set when the MAC address has been explicitely set
153 153 * when the group was created, or by a m_unicst_set() request.
154 154 * If this flag is not set, the MAC address of the group will be
155 155 * set to the first port that is added to the group.
156 156 *
157 157 * - lg_add_set: used only when lg_addr_fixed is not set. Captures whether
158 158 * the MAC address was initialized according to the members of the group.
159 159 * When set, the lg_port field points to the port from which the
160 160 * MAC address was initialized.
161 161 *
162 162 */
163 163 typedef struct aggr_grp_s {
164 164 datalink_id_t lg_linkid;
165 165 uint16_t lg_key; /* key (group port number) */
166 166 uint32_t lg_refs; /* refcount */
167 167 uint16_t lg_nports; /* number of MAC ports */
168 168 uint8_t lg_addr[ETHERADDRL]; /* group MAC address */
169 169 uint16_t
170 170 lg_closing : 1,
171 171 lg_addr_fixed : 1, /* fixed MAC address? */
172 172 lg_started : 1, /* group started? */
173 173 lg_promisc : 1, /* in promiscuous mode? */
174 174 lg_zcopy : 1,
175 175 lg_vlan : 1,
176 176 lg_force : 1,
177 177 lg_lso : 1,
178 178 lg_pad_bits : 8;
179 179 aggr_port_t *lg_ports; /* list of configured ports */
180 180 aggr_port_t *lg_mac_addr_port;
181 181 mac_handle_t lg_mh;
182 182 zoneid_t lg_zoneid;
183 183 uint_t lg_nattached_ports;
184 184 krwlock_t lg_tx_lock;
185 185 uint_t lg_ntx_ports;
186 186 aggr_port_t **lg_tx_ports; /* array of tx ports */
187 187 uint_t lg_tx_ports_size; /* size of lg_tx_ports */
188 188 uint32_t lg_tx_policy; /* outbound policy */
189 189 uint8_t lg_mac_tx_policy;
190 190 uint64_t lg_ifspeed;
191 191 link_state_t lg_link_state;
192 192 link_duplex_t lg_link_duplex;
193 193 uint64_t lg_stat[MAC_NSTAT];
194 194 uint64_t lg_ether_stat[ETHER_NSTAT];
195 195 aggr_lacp_mode_t lg_lacp_mode; /* off, active, or passive */
196 196 Agg_t aggr; /* 802.3ad data */
197 197 uint32_t lg_hcksum_txflags;
198 198 uint_t lg_max_sdu;
199 199 uint32_t lg_margin;
200 200 mac_capab_lso_t lg_cap_lso;
201 201
202 202 /*
203 203 * The following fields are used by the LACP packets processing.
204 204 * Specifically, as the LACP packets processing is not performance
205 205 * critical, all LACP packets will be handled by a dedicated thread
206 206 * instead of in the mac_rx() call. This is to avoid the dead lock
207 207 * with mac_unicast_remove(), which holding the mac perimeter of the
208 208 * aggr, and wait for the mr_refcnt of the RX ring to drop to zero.
209 209 */
210 210 kmutex_t lg_lacp_lock;
211 211 kcondvar_t lg_lacp_cv;
212 212 mblk_t *lg_lacp_head;
213 213 mblk_t *lg_lacp_tail;
214 214 kthread_t *lg_lacp_rx_thread;
215 215 boolean_t lg_lacp_done;
216 216
217 217 aggr_pseudo_rx_group_t lg_rx_group;
218 218 aggr_pseudo_tx_group_t lg_tx_group;
219 219
220 220 kmutex_t lg_tx_flowctl_lock;
221 221 kcondvar_t lg_tx_flowctl_cv;
222 222 uint_t lg_tx_blocked_cnt;
223 223 mac_ring_handle_t *lg_tx_blocked_rings;
224 224 kthread_t *lg_tx_notify_thread;
225 225 boolean_t lg_tx_notify_done;
226 226
227 227 /*
228 228 * The following fields are used by aggr to wait for all the
229 229 * aggr_port_notify_cb() and aggr_port_timer_thread() to finish
230 230 * before it calls mac_unregister() when the aggr is deleted.
231 231 */
232 232 kmutex_t lg_port_lock;
233 233 kcondvar_t lg_port_cv;
234 234 int lg_port_ref;
235 235 } aggr_grp_t;
236 236
237 237 #define AGGR_GRP_REFHOLD(grp) { \
238 238 atomic_inc_32(&(grp)->lg_refs); \
239 239 ASSERT((grp)->lg_refs != 0); \
240 240 }
241 241
242 242 #define AGGR_GRP_REFRELE(grp) { \
243 243 ASSERT((grp)->lg_refs != 0); \
244 244 membar_exit(); \
245 245 if (atomic_dec_32_nv(&(grp)->lg_refs) == 0) \
246 246 aggr_grp_free(grp); \
247 247 }
248 248
249 249 #define AGGR_PORT_REFHOLD(port) { \
250 250 atomic_inc_32(&(port)->lp_refs); \
251 251 ASSERT((port)->lp_refs != 0); \
252 252 }
253 253
254 254 #define AGGR_PORT_REFRELE(port) { \
255 255 ASSERT((port)->lp_refs != 0); \
256 256 membar_exit(); \
257 257 if (atomic_dec_32_nv(&(port)->lp_refs) == 0) \
258 258 aggr_port_free(port); \
259 259 }
260 260
261 261 extern dev_info_t *aggr_dip;
262 262 extern int aggr_ioc_init(void);
263 263 extern void aggr_ioc_fini(void);
264 264
265 265 typedef int (*aggr_grp_info_new_grp_fn_t)(void *, datalink_id_t, uint32_t,
266 266 uchar_t *, boolean_t, boolean_t, uint32_t, uint32_t, aggr_lacp_mode_t,
267 267 aggr_lacp_timer_t);
268 268 typedef int (*aggr_grp_info_new_port_fn_t)(void *, datalink_id_t, uchar_t *,
269 269 aggr_port_state_t, aggr_lacp_state_t *);
270 270
271 271 extern void aggr_grp_init(void);
272 272 extern void aggr_grp_fini(void);
273 273 extern int aggr_grp_create(datalink_id_t, uint32_t, uint_t, laioc_port_t *,
274 274 uint32_t, boolean_t, boolean_t, uchar_t *, aggr_lacp_mode_t,
275 275 aggr_lacp_timer_t, cred_t *);
276 276 extern int aggr_grp_delete(datalink_id_t, cred_t *);
277 277 extern void aggr_grp_free(aggr_grp_t *);
278 278
279 279 extern int aggr_grp_info(datalink_id_t, void *, aggr_grp_info_new_grp_fn_t,
280 280 aggr_grp_info_new_port_fn_t, cred_t *);
281 281 extern void aggr_grp_notify(aggr_grp_t *, uint32_t);
282 282 extern boolean_t aggr_grp_attach_port(aggr_grp_t *, aggr_port_t *);
283 283 extern boolean_t aggr_grp_detach_port(aggr_grp_t *, aggr_port_t *);
|
↓ open down ↓ |
283 lines elided |
↑ open up ↑ |
284 284 extern void aggr_grp_port_mac_changed(aggr_grp_t *, aggr_port_t *,
285 285 boolean_t *, boolean_t *);
286 286 extern int aggr_grp_add_ports(datalink_id_t, uint_t, boolean_t,
287 287 laioc_port_t *);
288 288 extern int aggr_grp_rem_ports(datalink_id_t, uint_t, laioc_port_t *);
289 289 extern boolean_t aggr_grp_update_ports_mac(aggr_grp_t *);
290 290 extern int aggr_grp_modify(datalink_id_t, uint8_t, uint32_t, boolean_t,
291 291 const uchar_t *, aggr_lacp_mode_t, aggr_lacp_timer_t);
292 292 extern void aggr_grp_multicst_port(aggr_port_t *, boolean_t);
293 293 extern uint_t aggr_grp_count(void);
294 +extern void aggr_grp_update_default(aggr_grp_t *);
294 295
295 296 extern void aggr_port_init(void);
296 297 extern void aggr_port_fini(void);
297 298 extern int aggr_port_create(aggr_grp_t *, const datalink_id_t, boolean_t,
298 299 aggr_port_t **);
299 300 extern void aggr_port_delete(aggr_port_t *);
300 301 extern void aggr_port_free(aggr_port_t *);
301 302 extern int aggr_port_start(aggr_port_t *);
302 303 extern void aggr_port_stop(aggr_port_t *);
303 304 extern int aggr_port_promisc(aggr_port_t *, boolean_t);
304 305 extern int aggr_port_unicst(aggr_port_t *);
305 306 extern int aggr_port_multicst(void *, boolean_t, const uint8_t *);
306 307 extern uint64_t aggr_port_stat(aggr_port_t *, uint_t);
307 308 extern boolean_t aggr_port_notify_link(aggr_grp_t *, aggr_port_t *);
308 309 extern void aggr_port_init_callbacks(aggr_port_t *);
309 310
310 311 extern void aggr_recv_cb(void *, mac_resource_handle_t, mblk_t *, boolean_t);
311 312 extern void aggr_recv_promisc_cb(void *, mac_resource_handle_t, mblk_t *,
312 313 boolean_t);
313 314
314 315 extern void aggr_tx_ring_update(void *, uintptr_t);
315 316 extern void aggr_tx_notify_thread(void *);
316 317 extern void aggr_send_port_enable(aggr_port_t *);
317 318 extern void aggr_send_port_disable(aggr_port_t *);
318 319 extern void aggr_send_update_policy(aggr_grp_t *, uint32_t);
319 320
320 321 extern void aggr_lacp_init(void);
321 322 extern void aggr_lacp_fini(void);
322 323 extern void aggr_lacp_init_port(aggr_port_t *);
323 324 extern void aggr_lacp_init_grp(aggr_grp_t *);
324 325 extern void aggr_lacp_set_mode(aggr_grp_t *, aggr_lacp_mode_t,
325 326 aggr_lacp_timer_t);
326 327 extern void aggr_lacp_update_mode(aggr_grp_t *, aggr_lacp_mode_t);
327 328 extern void aggr_lacp_update_timer(aggr_grp_t *, aggr_lacp_timer_t);
328 329 extern void aggr_lacp_rx_enqueue(aggr_port_t *, mblk_t *);
329 330 extern void aggr_lacp_port_attached(aggr_port_t *);
330 331 extern void aggr_lacp_port_detached(aggr_port_t *);
331 332 extern void aggr_port_lacp_set_mode(aggr_grp_t *, aggr_port_t *);
332 333
333 334 extern void aggr_lacp_rx_thread(void *);
334 335 extern void aggr_recv_lacp(aggr_port_t *, mac_resource_handle_t, mblk_t *);
335 336
336 337 extern void aggr_grp_port_hold(aggr_port_t *);
337 338 extern void aggr_grp_port_rele(aggr_port_t *);
338 339 extern void aggr_grp_port_wait(aggr_grp_t *);
339 340
340 341 extern int aggr_port_addmac(aggr_port_t *, const uint8_t *);
341 342 extern void aggr_port_remmac(aggr_port_t *, const uint8_t *);
342 343
343 344 extern mblk_t *aggr_ring_tx(void *, mblk_t *);
344 345 extern mblk_t *aggr_find_tx_ring(void *, mblk_t *,
345 346 uintptr_t, mac_ring_handle_t *);
346 347
347 348 #endif /* _KERNEL */
348 349
349 350 #ifdef __cplusplus
350 351 }
351 352 #endif
352 353
353 354 #endif /* _SYS_AGGR_IMPL_H */
|
↓ open down ↓ |
50 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX