1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23#ifndef _NET_BOND_3AD_H
24#define _NET_BOND_3AD_H
25
26#include <asm/byteorder.h>
27#include <linux/skbuff.h>
28#include <linux/netdevice.h>
29#include <linux/if_ether.h>
30
31
32#define PKT_TYPE_LACPDU cpu_to_be16(ETH_P_SLOW)
33#define AD_TIMER_INTERVAL 100
34
35#define MULTICAST_LACPDU_ADDR {0x01, 0x80, 0xC2, 0x00, 0x00, 0x02}
36
37#define AD_LACP_SLOW 0
38#define AD_LACP_FAST 1
39
40typedef struct mac_addr {
41 u8 mac_addr_value[ETH_ALEN];
42} __packed mac_addr_t;
43
44enum {
45 BOND_AD_STABLE = 0,
46 BOND_AD_BANDWIDTH = 1,
47 BOND_AD_COUNT = 2,
48};
49
50
51typedef enum {
52 AD_RX_DUMMY,
53 AD_RX_INITIALIZE,
54 AD_RX_PORT_DISABLED,
55 AD_RX_LACP_DISABLED,
56 AD_RX_EXPIRED,
57 AD_RX_DEFAULTED,
58 AD_RX_CURRENT
59} rx_states_t;
60
61
62typedef enum {
63 AD_PERIODIC_DUMMY,
64 AD_NO_PERIODIC,
65 AD_FAST_PERIODIC,
66 AD_SLOW_PERIODIC,
67 AD_PERIODIC_TX
68} periodic_states_t;
69
70
71typedef enum {
72 AD_MUX_DUMMY,
73 AD_MUX_DETACHED,
74 AD_MUX_WAITING,
75 AD_MUX_ATTACHED,
76 AD_MUX_COLLECTING_DISTRIBUTING
77} mux_states_t;
78
79
80typedef enum {
81 AD_TX_DUMMY,
82 AD_TRANSMIT
83} tx_states_t;
84
85
86typedef enum {
87 AD_CHURN_MONITOR,
88 AD_CHURN,
89 AD_NO_CHURN
90} churn_state_t;
91
92
93typedef enum {
94 AD_TYPE_LACPDU = 1,
95 AD_TYPE_MARKER
96} pdu_type_t;
97
98
99typedef enum {
100 AD_MARKER_INFORMATION_SUBTYPE = 1,
101 AD_MARKER_RESPONSE_SUBTYPE
102} bond_marker_subtype_t;
103
104
105typedef enum {
106 AD_CURRENT_WHILE_TIMER,
107 AD_ACTOR_CHURN_TIMER,
108 AD_PERIODIC_TIMER,
109 AD_PARTNER_CHURN_TIMER,
110 AD_WAIT_WHILE_TIMER
111} ad_timers_t;
112
113#pragma pack(1)
114
115
116typedef struct lacpdu {
117 u8 subtype;
118 u8 version_number;
119 u8 tlv_type_actor_info;
120 u8 actor_information_length;
121 __be16 actor_system_priority;
122 struct mac_addr actor_system;
123 __be16 actor_key;
124 __be16 actor_port_priority;
125 __be16 actor_port;
126 u8 actor_state;
127 u8 reserved_3_1[3];
128 u8 tlv_type_partner_info;
129 u8 partner_information_length;
130 __be16 partner_system_priority;
131 struct mac_addr partner_system;
132 __be16 partner_key;
133 __be16 partner_port_priority;
134 __be16 partner_port;
135 u8 partner_state;
136 u8 reserved_3_2[3];
137 u8 tlv_type_collector_info;
138 u8 collector_information_length;
139 __be16 collector_max_delay;
140 u8 reserved_12[12];
141 u8 tlv_type_terminator;
142 u8 terminator_length;
143 u8 reserved_50[50];
144} __packed lacpdu_t;
145
146typedef struct lacpdu_header {
147 struct ethhdr hdr;
148 struct lacpdu lacpdu;
149} __packed lacpdu_header_t;
150
151
152typedef struct bond_marker {
153 u8 subtype;
154 u8 version_number;
155 u8 tlv_type;
156
157 u8 marker_length;
158 u16 requester_port;
159 struct mac_addr requester_system;
160 u32 requester_transaction_id;
161 u16 pad;
162 u8 tlv_type_terminator;
163 u8 terminator_length;
164 u8 reserved_90[90];
165} __packed bond_marker_t;
166
167typedef struct bond_marker_header {
168 struct ethhdr hdr;
169 struct bond_marker marker;
170} __packed bond_marker_header_t;
171
172#pragma pack()
173
174struct slave;
175struct bonding;
176struct ad_info;
177struct port;
178
179#ifdef __ia64__
180#pragma pack(8)
181#endif
182
183
184typedef struct aggregator {
185 struct mac_addr aggregator_mac_address;
186 u16 aggregator_identifier;
187 bool is_individual;
188 u16 actor_admin_aggregator_key;
189 u16 actor_oper_aggregator_key;
190 struct mac_addr partner_system;
191 u16 partner_system_priority;
192 u16 partner_oper_aggregator_key;
193 u16 receive_state;
194 u16 transmit_state;
195 struct port *lag_ports;
196
197 struct slave *slave;
198 u16 is_active;
199 u16 num_of_ports;
200} aggregator_t;
201
202struct port_params {
203 struct mac_addr system;
204 u16 system_priority;
205 u16 key;
206 u16 port_number;
207 u16 port_priority;
208 u16 port_state;
209};
210
211
212typedef struct port {
213 u16 actor_port_number;
214 u16 actor_port_priority;
215 struct mac_addr actor_system;
216 u16 actor_system_priority;
217 u16 actor_port_aggregator_identifier;
218 bool ntt;
219 u16 actor_admin_port_key;
220 u16 actor_oper_port_key;
221 u8 actor_admin_port_state;
222 u8 actor_oper_port_state;
223
224 struct port_params partner_admin;
225 struct port_params partner_oper;
226
227 bool is_enabled;
228
229
230 u16 sm_vars;
231 rx_states_t sm_rx_state;
232 u16 sm_rx_timer_counter;
233 periodic_states_t sm_periodic_state;
234 u16 sm_periodic_timer_counter;
235 mux_states_t sm_mux_state;
236 u16 sm_mux_timer_counter;
237 tx_states_t sm_tx_state;
238 u16 sm_tx_timer_counter;
239 u16 sm_churn_actor_timer_counter;
240 u16 sm_churn_partner_timer_counter;
241 u32 churn_actor_count;
242 u32 churn_partner_count;
243 churn_state_t sm_churn_actor_state;
244 churn_state_t sm_churn_partner_state;
245 struct slave *slave;
246 struct aggregator *aggregator;
247 struct port *next_port_in_aggregator;
248 u32 transaction_id;
249 struct lacpdu lacpdu;
250} port_t;
251
252
253struct ad_system {
254 u16 sys_priority;
255 struct mac_addr sys_mac_addr;
256};
257
258#ifdef __ia64__
259#pragma pack()
260#endif
261
262
263#define BOND_AD_INFO(bond) ((bond)->ad_info)
264#define SLAVE_AD_INFO(slave) ((slave)->ad_info)
265
266struct ad_bond_info {
267 struct ad_system system;
268 u32 agg_select_timer;
269 u16 aggregator_identifier;
270};
271
272struct ad_slave_info {
273 struct aggregator aggregator;
274 struct port port;
275 u16 id;
276};
277
278static inline const char *bond_3ad_churn_desc(churn_state_t state)
279{
280 static const char *const churn_description[] = {
281 "monitoring",
282 "churned",
283 "none",
284 "unknown"
285 };
286 int max_size = ARRAY_SIZE(churn_description);
287
288 if (state >= max_size)
289 state = max_size - 1;
290
291 return churn_description[state];
292}
293
294
295void bond_3ad_initialize(struct bonding *bond, u16 tick_resolution);
296void bond_3ad_bind_slave(struct slave *slave);
297void bond_3ad_unbind_slave(struct slave *slave);
298void bond_3ad_state_machine_handler(struct work_struct *);
299void bond_3ad_initiate_agg_selection(struct bonding *bond, int timeout);
300void bond_3ad_adapter_speed_duplex_changed(struct slave *slave);
301void bond_3ad_handle_link_change(struct slave *slave, char link);
302int bond_3ad_get_active_agg_info(struct bonding *bond, struct ad_info *ad_info);
303int __bond_3ad_get_active_agg_info(struct bonding *bond,
304 struct ad_info *ad_info);
305int bond_3ad_lacpdu_recv(const struct sk_buff *skb, struct bonding *bond,
306 struct slave *slave);
307int bond_3ad_set_carrier(struct bonding *bond);
308void bond_3ad_update_lacp_rate(struct bonding *bond);
309void bond_3ad_update_ad_actor_settings(struct bonding *bond);
310#endif
311
312