1700 Add SCSI UNMAP support
[unleashed.git] / usr / src / uts / common / sys / aggr_lacp.h
blobef8c7408accb62dd7f1b87da14ab9f0acbdc720d
1 /*
2 * CDDL HEADER START
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.
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.
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]
19 * CDDL HEADER END
22 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
26 #ifndef _SYS_AGGR_LACP_H
27 #define _SYS_AGGR_LACP_H
29 #include <sys/aggr.h>
30 #include <sys/ethernet.h>
32 #ifdef __cplusplus
33 extern "C" {
34 #endif
36 #ifdef _KERNEL
39 * 802.3ad LACP version number
41 #define LACP_VERSION 0x01 /* LACP version from 802.3ad */
42 #define LACP_SUBTYPE 0x1
45 * TLV type (type/length/value carried in the LACPDU structure.
47 #define ACTOR_TLV 0x01 /* actor TLV type */
48 #define PARTNER_TLV 0x02 /* partner TLV type */
49 #define COLLECTOR_TLV 0x03 /* collector TLV type */
50 #define TERMINATOR_TLV 0x00 /* end of message */
53 * Length fields as per 802.3ad.
55 #define LACP_COLLECTOR_INFO_LEN 0x10
56 #define LACP_TERMINATOR_INFO_LEN 0x00
58 /* LACP Receive State Machine states */
59 typedef enum {
60 LACP_INITIALIZE = 0,
61 LACP_PORT_DISABLED = 1,
62 LACP_EXPIRED = 2,
63 LACP_DISABLED = 3,
64 LACP_DEFAULTED = 4,
65 LACP_CURRENT = 5
66 } lacp_receive_state_t;
68 #define LACP_RECEIVE_STATE_STRINGS { \
69 "LACP_INITIALIZE", \
70 "LACP_PORT_DISABLED", \
71 "LACP_EXPIRED", \
72 "LACP_DISABLED", \
73 "LACP_DEFAULTED", \
74 "LACP_CURRENT" \
77 /* LACP Periodic State Machine states */
78 typedef enum {
79 LACP_NO_PERIODIC = 0,
80 LACP_FAST_PERIODIC = 1,
81 LACP_SLOW_PERIODIC = 2,
82 LACP_PERIODIC_TX = 3
83 } lacp_periodic_state_t;
85 #define LACP_PERIODIC_STRINGS { \
86 "LACP_NO_PERIODIC", \
87 "LACP_FAST_PERIODIC", \
88 "LACP_SLOW_PERIODIC", \
89 "LACP_PERIODIC_TX" \
93 /* LACP Mux State Machine states */
94 typedef enum {
95 LACP_DETACHED = 0,
96 LACP_WAITING = 1,
97 LACP_ATTACHED = 2,
98 LACP_COLLECTING_DISTRIBUTING = 3
99 } lacp_mux_state_t;
101 #define LACP_MUX_STRINGS { \
102 "LACP_DETACHED", \
103 "LACP_WAITING", \
104 "LACP_ATTACHED", \
105 "LACP_COLLECTING_DISTRIBUTING" \
108 /* LACP Churn State Machine states */
109 typedef enum {
110 LACP_NO_ACTOR_CHURN = 0,
111 LACP_ACTOR_CHURN_MONITOR = 1,
112 LACP_ACTOR_CHURN = 2
113 } lacp_churn_state_t;
116 * 802.3ad timer constants. (IEEE 802.3ad: section 43.4.4)
118 * All timers specified have a implementation tolerance of +- 250 ms.
120 #define FAST_PERIODIC_TIME 1 /* using short timeouts (tx) */
121 #define SLOW_PERIODIC_TIME 30 /* using long timeouts (tx) */
122 #define SHORT_TIMEOUT_TIME 3 /* before invalidate LACPDU */
123 #define LONG_TIMEOUT_TIME 90 /* before invalidate LACPDU */
124 #define CHURN_DETECTION_TIME 60 /* sync between actor/partner */
125 #define AGGREGATE_WAIT_TIME 2 /* Delay wait to aggregate links */
128 * 802.3ad Variables associated with the system (section 43.4.5)
130 typedef struct system_info {
131 struct ether_addr system_id; /* MAC address assigned by admin */
132 uint16_t system_priority; /* system priority assigned by admin */
133 } system_info_t;
135 typedef struct lacp_timer {
136 uint32_t val;
137 timeout_id_t id;
138 } lacp_timer_t;
141 * 802.3ad Variables associated with each aggregation (section 43.4.6)
142 * Note: These are on a per aggregation basis.
144 typedef struct Agg {
145 uint32_t AggregatorIdentifier; /* not used */
146 boolean_t IndividualAggr; /* individual aggregator */
147 uint32_t ActorAdminKey; /* assigned by admin. */
148 uint32_t ActorOperKey; /* assigned by admin. */
149 struct ether_addr PartnerSystem; /* partner system ID */
150 uint32_t PartnerSystemPriority; /* partner system priority */
151 uint32_t PartnerOperAggrKey; /* parter oper aggr. key */
152 boolean_t ReceiveState; /* Enabled/Disabled */
153 boolean_t TransmitState; /* Enabled/Disabled */
155 uint16_t ActorSystemPriority; /* System Priority */
156 uint16_t CollectorMaxDelay; /* tens of Usecs */
157 aggr_lacp_timer_t PeriodicTimer; /* AGGR_LACP_{LONG,SHORT} */
158 uint64_t TimeOfLastOperChange; /* Time in state */
159 boolean_t ready; /* Ready_N for all ports TRUE */
160 } Agg_t;
163 * 802.3ad Variables used for managing the operation of
164 * the state machines (section 43.4.8)
165 * Note: These are on a per port basis.
167 typedef enum {
168 AGGR_UNSELECTED, /* aggregator not selected */
169 AGGR_SELECTED, /* aggregator selected */
170 AGGR_STANDBY /* port in standby */
171 } lacp_selected_t;
173 typedef struct state_machine {
174 uint32_t lacp_on : 1, /* LACP on or off */
175 begin : 1, /* LACP init(or reinit.) */
176 lacp_enabled : 1, /* Full/Half Duplex */
177 port_enabled : 1, /* Link Up/Down */
178 actor_churn : 1, /* failed to converge */
179 partner_churn : 1,
180 ready_n : 1, /* waiting */
181 port_moved : 1, /* any port is not waiting */
182 pad_bits : 24;
183 /* "Ready" is accessed from the aggregator structure */
184 lacp_selected_t selected; /* SELECTED/UNSELECTED/STANDBY */
185 uint32_t current_while_timer_exp; /* # of times timer expired */
186 lacp_periodic_state_t periodic_state; /* State of periodic machine */
187 lacp_receive_state_t receive_state; /* State of receive machine */
188 lacp_mux_state_t mux_state; /* State of mux machine */
189 lacp_churn_state_t churn_state; /* State of churn machine */
190 } state_machine_t;
193 * The following three flags are set when specific timer is timed out; used
194 * by the LACP timer handler thread.
196 #define LACP_PERIODIC_TIMEOUT 0x01
197 #define LACP_WAIT_WHILE_TIMEOUT 0x02
198 #define LACP_CURRENT_WHILE_TIMEOUT 0x04
200 * Set when the port is being deleted; used to inform the LACP timer handler
201 * thread to exit.
203 #define LACP_THREAD_EXIT 0x08
206 * 802.3ad Variables associated with each port (section 43.4.7)
208 typedef struct aggr_lacp_port {
209 uint16_t ActorPortNumber; /* actor port number */
210 uint16_t ActorPortPriority; /* actor port priority */
211 uint32_t ActorPortAggrId; /* aggregator id */
212 boolean_t NTT; /* need to transmit */
213 uint16_t ActorAdminPortKey; /* admin. port key */
214 uint16_t ActorOperPortKey; /* oper port key */
215 aggr_lacp_state_t ActorAdminPortState; /* actor admin. port state */
216 aggr_lacp_state_t ActorOperPortState; /* actor oper. port state */
219 * partner information
221 struct ether_addr PartnerAdminSystem; /* partner admin. system */
222 struct ether_addr PartnerOperSystem; /* partner oper.system */
223 uint16_t PartnerAdminSysPriority; /* partner admin. sys. pri. */
224 uint16_t PartnerOperSysPriority; /* partner oper. sys. pri. */
225 uint16_t PartnerAdminKey; /* partner admin. key */
226 uint16_t PartnerOperKey; /* partner oper. key */
227 uint16_t PartnerAdminPortNum; /* partner admin. port # */
228 uint16_t PartnerOperPortNum; /* partner oper. port # */
229 uint16_t PartnerAdminPortPriority; /* partner admin. port pri. */
230 uint16_t PartnerOperPortPriority; /* partner oper. port pri. */
231 aggr_lacp_state_t PartnerAdminPortState; /* partner admin port state */
232 aggr_lacp_state_t PartnerOperPortState; /* partner oper port state */
233 uint16_t PartnerCollectorMaxDelay; /* tens of microseconds */
236 * State machine and Timer information.
238 state_machine_t sm; /* state machine variables per port */
239 lacp_timer_t current_while_timer;
240 lacp_timer_t periodic_timer;
241 lacp_timer_t wait_while_timer;
242 uint32_t lacp_timer_bits;
243 kthread_t *lacp_timer_thread;
244 kmutex_t lacp_timer_lock;
245 kcondvar_t lacp_timer_cv;
246 hrtime_t time;
247 } aggr_lacp_port_t;
249 typedef struct lacp_stats_s {
250 uint64_t LACPDUsRx;
251 uint64_t MarkerPDUsRx;
252 uint64_t MarkerResponsePDUsRx;
253 uint64_t UnknownRx;
254 uint64_t IllegalRx;
255 uint64_t LACPDUsTx;
256 uint64_t MarkerPDUsTx;
257 uint64_t MarkerResponsePDUsTx;
258 } lacp_stats_t;
261 * 802.3ad protocol information
264 * Actor/Partner information
266 typedef struct link_info {
267 uint8_t tlv_type; /* type/length/value */
268 uint8_t information_len; /* information length */
269 uint16_t system_priority; /* system priority */
270 struct ether_addr system_id; /* encoded as MAC address */
271 uint16_t key; /* operational key */
272 uint16_t port_priority; /* port priority */
273 uint16_t port; /* port */
274 aggr_lacp_state_t state; /* state info */
275 uint8_t reserved[3]; /* reserved */
276 } link_info_t;
279 * Link Aggregation Control Protocol (LACPDU) structure
281 typedef struct lacp {
282 uint8_t subtype; /* = LACP */
283 uint8_t version; /* LACP version */
284 link_info_t actor_info; /* actor information */
285 link_info_t partner_info; /* partner information */
286 uint8_t tlv_collector; /* collector tlv */
287 uint8_t collector_len; /* collector len */
288 uint16_t collector_max_delay; /* tens of miscrosecond */
289 uint8_t reserved[12]; /* reserved */
290 uint8_t tlv_terminator; /* terminator tlv */
291 uint8_t terminator_len; /* terminator len */
292 uint8_t lacp_reserved[50]; /* reserved */
293 } lacp_t;
296 * Marker protocol
299 #define MARKER_VERSION 0x1 /* 802.3ad Marker version number */
300 #define MARKER_SUBTYPE 0x2
301 #define MARKER_INFO_RESPONSE_LENGTH 16
304 * marker TLV_type
306 #define MARKER_INFO_TLV 0x01 /* marker information */
307 #define MARKER_RESPONSE_TLV 0x02 /* marker response information */
309 typedef struct marker_pdu {
310 struct ether_addr dest_addr; /* Slow protocol multicast */
311 struct ether_addr src_addr; /* Source address */
312 uint16_t type; /* Slow protocol type */
313 uint8_t subtype; /* = Marker 0x2 */
314 uint8_t version; /* Marker version 0x01 */
315 uint8_t tlv_marker; /* marker tlv */
316 uint8_t marker_len; /* marker len */
317 uint16_t requestor_port; /* requestor port */
318 struct ether_addr system_id; /* requestor system */
319 uint8_t transaction_id[4]; /* transaction id */
320 uint8_t pad[2]; /* zeros to align */
321 uint8_t reserved[90]; /* reserved */
322 uint32_t fcs; /* generated by MAC */
323 } marker_pdu_t;
326 * 802.3ad Link Aggregation Group Identifier (IEEE 802.3ad 43.3.6)
327 * port identifire = port priority and port number.
329 typedef struct lag_id {
330 uint16_t system_priority; /* system priority */
331 struct ether_addr system_id; /* system identifier */
332 uint16_t oper_key; /* operational key */
333 uint16_t port_priority; /* port priority */
334 uint16_t port_number; /* 0: aggregatable */
335 } lag_id_t;
337 #endif /* _KERNEL */
339 #ifdef __cplusplus
341 #endif
343 #endif /* _SYS_AGGR_LACP_H */