2 * Copyright(c) 1999 - 2004 Intel Corporation. All rights reserved.
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the Free
6 * Software Foundation; either version 2 of the License, or (at your option)
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14 * You should have received a copy of the GNU General Public License along with
15 * this program; if not, write to the Free Software Foundation, Inc., 59
16 * Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 * The full GNU General Public License is included in this distribution in the
19 * file called LICENSE.
23 //#define BONDING_DEBUG 1
25 #include <linux/skbuff.h>
26 #include <linux/if_ether.h>
27 #include <linux/netdevice.h>
28 #include <linux/spinlock.h>
29 #include <linux/ethtool.h>
30 #include <linux/if_bonding.h>
31 #include <linux/pkt_sched.h>
32 #include <net/net_namespace.h>
36 // General definitions
37 #define AD_SHORT_TIMEOUT 1
38 #define AD_LONG_TIMEOUT 0
39 #define AD_STANDBY 0x2
40 #define AD_MAX_TX_IN_SECOND 3
41 #define AD_COLLECTOR_MAX_DELAY 0
43 // Timer definitions(43.4.4 in the 802.3ad standard)
44 #define AD_FAST_PERIODIC_TIME 1
45 #define AD_SLOW_PERIODIC_TIME 30
46 #define AD_SHORT_TIMEOUT_TIME (3*AD_FAST_PERIODIC_TIME)
47 #define AD_LONG_TIMEOUT_TIME (3*AD_SLOW_PERIODIC_TIME)
48 #define AD_CHURN_DETECTION_TIME 60
49 #define AD_AGGREGATE_WAIT_TIME 2
51 // Port state definitions(43.4.2.2 in the 802.3ad standard)
52 #define AD_STATE_LACP_ACTIVITY 0x1
53 #define AD_STATE_LACP_TIMEOUT 0x2
54 #define AD_STATE_AGGREGATION 0x4
55 #define AD_STATE_SYNCHRONIZATION 0x8
56 #define AD_STATE_COLLECTING 0x10
57 #define AD_STATE_DISTRIBUTING 0x20
58 #define AD_STATE_DEFAULTED 0x40
59 #define AD_STATE_EXPIRED 0x80
61 // Port Variables definitions used by the State Machines(43.4.7 in the 802.3ad standard)
62 #define AD_PORT_BEGIN 0x1
63 #define AD_PORT_LACP_ENABLED 0x2
64 #define AD_PORT_ACTOR_CHURN 0x4
65 #define AD_PORT_PARTNER_CHURN 0x8
66 #define AD_PORT_READY 0x10
67 #define AD_PORT_READY_N 0x20
68 #define AD_PORT_MATCHED 0x40
69 #define AD_PORT_STANDBY 0x80
70 #define AD_PORT_SELECTED 0x100
71 #define AD_PORT_MOVED 0x200
73 // Port Key definitions
74 // key is determined according to the link speed, duplex and
75 // user key(which is yet not supported)
76 // ------------------------------------------------------------
77 // Port key : | User key | Speed |Duplex|
78 // ------------------------------------------------------------
80 #define AD_DUPLEX_KEY_BITS 0x1
81 #define AD_SPEED_KEY_BITS 0x3E
82 #define AD_USER_KEY_BITS 0xFFC0
85 #define AD_LINK_SPEED_BITMASK_1MBPS 0x1
86 #define AD_LINK_SPEED_BITMASK_10MBPS 0x2
87 #define AD_LINK_SPEED_BITMASK_100MBPS 0x4
88 #define AD_LINK_SPEED_BITMASK_1000MBPS 0x8
89 #define AD_LINK_SPEED_BITMASK_10000MBPS 0x10
92 // compare MAC addresses
93 #define MAC_ADDRESS_COMPARE(A, B) memcmp(A, B, ETH_ALEN)
95 static struct mac_addr null_mac_addr
= {{0, 0, 0, 0, 0, 0}};
96 static u16 ad_ticks_per_sec
;
97 static const int ad_delta_in_ticks
= (AD_TIMER_INTERVAL
* HZ
) / 1000;
99 // ================= 3AD api to bonding and kernel code ==================
100 static u16
__get_link_speed(struct port
*port
);
101 static u8
__get_duplex(struct port
*port
);
102 static inline void __initialize_port_locks(struct port
*port
);
104 static void __htons_lacpdu(struct lacpdu
*lacpdu
);
105 static u16
__ad_timer_to_ticks(u16 timer_type
, u16 Par
);
108 // ================= ad code helper functions ==================
109 //needed by ad_rx_machine(...)
110 static void __record_pdu(struct lacpdu
*lacpdu
, struct port
*port
);
111 static void __record_default(struct port
*port
);
112 static void __update_selected(struct lacpdu
*lacpdu
, struct port
*port
);
113 static void __update_default_selected(struct port
*port
);
114 static void __choose_matched(struct lacpdu
*lacpdu
, struct port
*port
);
115 static void __update_ntt(struct lacpdu
*lacpdu
, struct port
*port
);
117 //needed for ad_mux_machine(..)
118 static void __attach_bond_to_agg(struct port
*port
);
119 static void __detach_bond_from_agg(struct port
*port
);
120 static int __agg_ports_are_ready(struct aggregator
*aggregator
);
121 static void __set_agg_ports_ready(struct aggregator
*aggregator
, int val
);
123 //needed for ad_agg_selection_logic(...)
124 static u32
__get_agg_bandwidth(struct aggregator
*aggregator
);
125 static struct aggregator
*__get_active_agg(struct aggregator
*aggregator
);
128 // ================= main 802.3ad protocol functions ==================
129 static int ad_lacpdu_send(struct port
*port
);
130 static int ad_marker_send(struct port
*port
, struct marker
*marker
);
131 static void ad_mux_machine(struct port
*port
);
132 static void ad_rx_machine(struct lacpdu
*lacpdu
, struct port
*port
);
133 static void ad_tx_machine(struct port
*port
);
134 static void ad_periodic_machine(struct port
*port
);
135 static void ad_port_selection_logic(struct port
*port
);
136 static void ad_agg_selection_logic(struct aggregator
*aggregator
);
137 static void ad_clear_agg(struct aggregator
*aggregator
);
138 static void ad_initialize_agg(struct aggregator
*aggregator
);
139 static void ad_initialize_port(struct port
*port
, int lacp_fast
);
140 static void ad_initialize_lacpdu(struct lacpdu
*Lacpdu
);
141 static void ad_enable_collecting_distributing(struct port
*port
);
142 static void ad_disable_collecting_distributing(struct port
*port
);
143 static void ad_marker_info_received(struct marker
*marker_info
, struct port
*port
);
144 static void ad_marker_response_received(struct marker
*marker
, struct port
*port
);
147 /////////////////////////////////////////////////////////////////////////////////
148 // ================= api to bonding and kernel code ==================
149 /////////////////////////////////////////////////////////////////////////////////
152 * __get_bond_by_port - get the port's bonding struct
153 * @port: the port we're looking at
155 * Return @port's bonding struct, or %NULL if it can't be found.
157 static inline struct bonding
*__get_bond_by_port(struct port
*port
)
159 if (port
->slave
== NULL
) {
163 return bond_get_bond_by_slave(port
->slave
);
167 * __get_first_port - get the first port in the bond
168 * @bond: the bond we're looking at
170 * Return the port of the first slave in @bond, or %NULL if it can't be found.
172 static inline struct port
*__get_first_port(struct bonding
*bond
)
174 if (bond
->slave_cnt
== 0) {
178 return &(SLAVE_AD_INFO(bond
->first_slave
).port
);
182 * __get_next_port - get the next port in the bond
183 * @port: the port we're looking at
185 * Return the port of the slave that is next in line of @port's slave in the
186 * bond, or %NULL if it can't be found.
188 static inline struct port
*__get_next_port(struct port
*port
)
190 struct bonding
*bond
= __get_bond_by_port(port
);
191 struct slave
*slave
= port
->slave
;
193 // If there's no bond for this port, or this is the last slave
194 if ((bond
== NULL
) || (slave
->next
== bond
->first_slave
)) {
198 return &(SLAVE_AD_INFO(slave
->next
).port
);
202 * __get_first_agg - get the first aggregator in the bond
203 * @bond: the bond we're looking at
205 * Return the aggregator of the first slave in @bond, or %NULL if it can't be
208 static inline struct aggregator
*__get_first_agg(struct port
*port
)
210 struct bonding
*bond
= __get_bond_by_port(port
);
212 // If there's no bond for this port, or bond has no slaves
213 if ((bond
== NULL
) || (bond
->slave_cnt
== 0)) {
217 return &(SLAVE_AD_INFO(bond
->first_slave
).aggregator
);
221 * __get_next_agg - get the next aggregator in the bond
222 * @aggregator: the aggregator we're looking at
224 * Return the aggregator of the slave that is next in line of @aggregator's
225 * slave in the bond, or %NULL if it can't be found.
227 static inline struct aggregator
*__get_next_agg(struct aggregator
*aggregator
)
229 struct slave
*slave
= aggregator
->slave
;
230 struct bonding
*bond
= bond_get_bond_by_slave(slave
);
232 // If there's no bond for this aggregator, or this is the last slave
233 if ((bond
== NULL
) || (slave
->next
== bond
->first_slave
)) {
237 return &(SLAVE_AD_INFO(slave
->next
).aggregator
);
241 * __disable_port - disable the port's slave
242 * @port: the port we're looking at
245 static inline void __disable_port(struct port
*port
)
247 bond_set_slave_inactive_flags(port
->slave
);
251 * __enable_port - enable the port's slave, if it's up
252 * @port: the port we're looking at
255 static inline void __enable_port(struct port
*port
)
257 struct slave
*slave
= port
->slave
;
259 if ((slave
->link
== BOND_LINK_UP
) && IS_UP(slave
->dev
)) {
260 bond_set_slave_active_flags(slave
);
265 * __port_is_enabled - check if the port's slave is in active state
266 * @port: the port we're looking at
269 static inline int __port_is_enabled(struct port
*port
)
271 return(port
->slave
->state
== BOND_STATE_ACTIVE
);
275 * __get_agg_selection_mode - get the aggregator selection mode
276 * @port: the port we're looking at
278 * Get the aggregator selection mode. Can be %BANDWIDTH or %COUNT.
280 static inline u32
__get_agg_selection_mode(struct port
*port
)
282 struct bonding
*bond
= __get_bond_by_port(port
);
288 return BOND_AD_INFO(bond
).agg_select_mode
;
292 * __check_agg_selection_timer - check if the selection timer has expired
293 * @port: the port we're looking at
296 static inline int __check_agg_selection_timer(struct port
*port
)
298 struct bonding
*bond
= __get_bond_by_port(port
);
304 return BOND_AD_INFO(bond
).agg_select_timer
? 1 : 0;
308 * __get_rx_machine_lock - lock the port's RX machine
309 * @port: the port we're looking at
312 static inline void __get_rx_machine_lock(struct port
*port
)
314 spin_lock(&(SLAVE_AD_INFO(port
->slave
).rx_machine_lock
));
318 * __release_rx_machine_lock - unlock the port's RX machine
319 * @port: the port we're looking at
322 static inline void __release_rx_machine_lock(struct port
*port
)
324 spin_unlock(&(SLAVE_AD_INFO(port
->slave
).rx_machine_lock
));
328 * __get_link_speed - get a port's speed
329 * @port: the port we're looking at
331 * Return @port's speed in 802.3ad bitmask format. i.e. one of:
333 * %AD_LINK_SPEED_BITMASK_10MBPS,
334 * %AD_LINK_SPEED_BITMASK_100MBPS,
335 * %AD_LINK_SPEED_BITMASK_1000MBPS,
336 * %AD_LINK_SPEED_BITMASK_10000MBPS
338 static u16
__get_link_speed(struct port
*port
)
340 struct slave
*slave
= port
->slave
;
343 /* this if covers only a special case: when the configuration starts with
344 * link down, it sets the speed to 0.
345 * This is done in spite of the fact that the e100 driver reports 0 to be
346 * compatible with MVT in the future.*/
347 if (slave
->link
!= BOND_LINK_UP
) {
350 switch (slave
->speed
) {
352 speed
= AD_LINK_SPEED_BITMASK_10MBPS
;
356 speed
= AD_LINK_SPEED_BITMASK_100MBPS
;
360 speed
= AD_LINK_SPEED_BITMASK_1000MBPS
;
364 speed
= AD_LINK_SPEED_BITMASK_10000MBPS
;
368 speed
= 0; // unknown speed value from ethtool. shouldn't happen
373 dprintk("Port %d Received link speed %d update from adapter\n", port
->actor_port_number
, speed
);
378 * __get_duplex - get a port's duplex
379 * @port: the port we're looking at
381 * Return @port's duplex in 802.3ad bitmask format. i.e.:
382 * 0x01 if in full duplex
385 static u8
__get_duplex(struct port
*port
)
387 struct slave
*slave
= port
->slave
;
391 // handling a special case: when the configuration starts with
392 // link down, it sets the duplex to 0.
393 if (slave
->link
!= BOND_LINK_UP
) {
396 switch (slave
->duplex
) {
399 dprintk("Port %d Received status full duplex update from adapter\n", port
->actor_port_number
);
404 dprintk("Port %d Received status NOT full duplex update from adapter\n", port
->actor_port_number
);
412 * __initialize_port_locks - initialize a port's RX machine spinlock
413 * @port: the port we're looking at
416 static inline void __initialize_port_locks(struct port
*port
)
418 // make sure it isn't called twice
419 spin_lock_init(&(SLAVE_AD_INFO(port
->slave
).rx_machine_lock
));
424 * __htons_lacpdu - convert the contents of a LACPDU to network byte order
425 * @lacpdu: the speicifed lacpdu
427 * For each multi-byte field in the lacpdu, convert its content
429 static void __htons_lacpdu(struct lacpdu
*lacpdu
)
432 lacpdu
->actor_system_priority
= htons(lacpdu
->actor_system_priority
);
433 lacpdu
->actor_key
= htons(lacpdu
->actor_key
);
434 lacpdu
->actor_port_priority
= htons(lacpdu
->actor_port_priority
);
435 lacpdu
->actor_port
= htons(lacpdu
->actor_port
);
436 lacpdu
->partner_system_priority
= htons(lacpdu
->partner_system_priority
);
437 lacpdu
->partner_key
= htons(lacpdu
->partner_key
);
438 lacpdu
->partner_port_priority
= htons(lacpdu
->partner_port_priority
);
439 lacpdu
->partner_port
= htons(lacpdu
->partner_port
);
440 lacpdu
->collector_max_delay
= htons(lacpdu
->collector_max_delay
);
445 * __ad_timer_to_ticks - convert a given timer type to AD module ticks
446 * @timer_type: which timer to operate
447 * @par: timer parameter. see below
449 * If @timer_type is %current_while_timer, @par indicates long/short timer.
450 * If @timer_type is %periodic_timer, @par is one of %FAST_PERIODIC_TIME,
451 * %SLOW_PERIODIC_TIME.
453 static u16
__ad_timer_to_ticks(u16 timer_type
, u16 par
)
455 u16 retval
=0; //to silence the compiler
457 switch (timer_type
) {
458 case AD_CURRENT_WHILE_TIMER
: // for rx machine usage
459 if (par
) { // for short or long timeout
460 retval
= (AD_SHORT_TIMEOUT_TIME
*ad_ticks_per_sec
); // short timeout
462 retval
= (AD_LONG_TIMEOUT_TIME
*ad_ticks_per_sec
); // long timeout
465 case AD_ACTOR_CHURN_TIMER
: // for local churn machine
466 retval
= (AD_CHURN_DETECTION_TIME
*ad_ticks_per_sec
);
468 case AD_PERIODIC_TIMER
: // for periodic machine
469 retval
= (par
*ad_ticks_per_sec
); // long timeout
471 case AD_PARTNER_CHURN_TIMER
: // for remote churn machine
472 retval
= (AD_CHURN_DETECTION_TIME
*ad_ticks_per_sec
);
474 case AD_WAIT_WHILE_TIMER
: // for selection machine
475 retval
= (AD_AGGREGATE_WAIT_TIME
*ad_ticks_per_sec
);
482 /////////////////////////////////////////////////////////////////////////////////
483 // ================= ad_rx_machine helper functions ==================
484 /////////////////////////////////////////////////////////////////////////////////
487 * __record_pdu - record parameters from a received lacpdu
488 * @lacpdu: the lacpdu we've received
489 * @port: the port we're looking at
491 * Record the parameter values for the Actor carried in a received lacpdu as
492 * the current partner operational parameter values and sets
493 * actor_oper_port_state.defaulted to FALSE.
495 static void __record_pdu(struct lacpdu
*lacpdu
, struct port
*port
)
497 // validate lacpdu and port
498 if (lacpdu
&& port
) {
499 // record the new parameter values for the partner operational
500 port
->partner_oper_port_number
= ntohs(lacpdu
->actor_port
);
501 port
->partner_oper_port_priority
= ntohs(lacpdu
->actor_port_priority
);
502 port
->partner_oper_system
= lacpdu
->actor_system
;
503 port
->partner_oper_system_priority
= ntohs(lacpdu
->actor_system_priority
);
504 port
->partner_oper_key
= ntohs(lacpdu
->actor_key
);
505 // zero partener's lase states
506 port
->partner_oper_port_state
= 0;
507 port
->partner_oper_port_state
|= (lacpdu
->actor_state
& AD_STATE_LACP_ACTIVITY
);
508 port
->partner_oper_port_state
|= (lacpdu
->actor_state
& AD_STATE_LACP_TIMEOUT
);
509 port
->partner_oper_port_state
|= (lacpdu
->actor_state
& AD_STATE_AGGREGATION
);
510 port
->partner_oper_port_state
|= (lacpdu
->actor_state
& AD_STATE_SYNCHRONIZATION
);
511 port
->partner_oper_port_state
|= (lacpdu
->actor_state
& AD_STATE_COLLECTING
);
512 port
->partner_oper_port_state
|= (lacpdu
->actor_state
& AD_STATE_DISTRIBUTING
);
513 port
->partner_oper_port_state
|= (lacpdu
->actor_state
& AD_STATE_DEFAULTED
);
514 port
->partner_oper_port_state
|= (lacpdu
->actor_state
& AD_STATE_EXPIRED
);
516 // set actor_oper_port_state.defaulted to FALSE
517 port
->actor_oper_port_state
&= ~AD_STATE_DEFAULTED
;
519 // set the partner sync. to on if the partner is sync. and the port is matched
520 if ((port
->sm_vars
& AD_PORT_MATCHED
) && (lacpdu
->actor_state
& AD_STATE_SYNCHRONIZATION
)) {
521 port
->partner_oper_port_state
|= AD_STATE_SYNCHRONIZATION
;
523 port
->partner_oper_port_state
&= ~AD_STATE_SYNCHRONIZATION
;
529 * __record_default - record default parameters
530 * @port: the port we're looking at
532 * This function records the default parameter values for the partner carried
533 * in the Partner Admin parameters as the current partner operational parameter
534 * values and sets actor_oper_port_state.defaulted to TRUE.
536 static void __record_default(struct port
*port
)
540 // record the partner admin parameters
541 port
->partner_oper_port_number
= port
->partner_admin_port_number
;
542 port
->partner_oper_port_priority
= port
->partner_admin_port_priority
;
543 port
->partner_oper_system
= port
->partner_admin_system
;
544 port
->partner_oper_system_priority
= port
->partner_admin_system_priority
;
545 port
->partner_oper_key
= port
->partner_admin_key
;
546 port
->partner_oper_port_state
= port
->partner_admin_port_state
;
548 // set actor_oper_port_state.defaulted to true
549 port
->actor_oper_port_state
|= AD_STATE_DEFAULTED
;
554 * __update_selected - update a port's Selected variable from a received lacpdu
555 * @lacpdu: the lacpdu we've received
556 * @port: the port we're looking at
558 * Update the value of the selected variable, using parameter values from a
559 * newly received lacpdu. The parameter values for the Actor carried in the
560 * received PDU are compared with the corresponding operational parameter
561 * values for the ports partner. If one or more of the comparisons shows that
562 * the value(s) received in the PDU differ from the current operational values,
563 * then selected is set to FALSE and actor_oper_port_state.synchronization is
564 * set to out_of_sync. Otherwise, selected remains unchanged.
566 static void __update_selected(struct lacpdu
*lacpdu
, struct port
*port
)
568 // validate lacpdu and port
569 if (lacpdu
&& port
) {
570 // check if any parameter is different
571 if ((ntohs(lacpdu
->actor_port
) != port
->partner_oper_port_number
) ||
572 (ntohs(lacpdu
->actor_port_priority
) != port
->partner_oper_port_priority
) ||
573 MAC_ADDRESS_COMPARE(&(lacpdu
->actor_system
), &(port
->partner_oper_system
)) ||
574 (ntohs(lacpdu
->actor_system_priority
) != port
->partner_oper_system_priority
) ||
575 (ntohs(lacpdu
->actor_key
) != port
->partner_oper_key
) ||
576 ((lacpdu
->actor_state
& AD_STATE_AGGREGATION
) != (port
->partner_oper_port_state
& AD_STATE_AGGREGATION
))
578 // update the state machine Selected variable
579 port
->sm_vars
&= ~AD_PORT_SELECTED
;
585 * __update_default_selected - update a port's Selected variable from Partner
586 * @port: the port we're looking at
588 * This function updates the value of the selected variable, using the partner
589 * administrative parameter values. The administrative values are compared with
590 * the corresponding operational parameter values for the partner. If one or
591 * more of the comparisons shows that the administrative value(s) differ from
592 * the current operational values, then Selected is set to FALSE and
593 * actor_oper_port_state.synchronization is set to OUT_OF_SYNC. Otherwise,
594 * Selected remains unchanged.
596 static void __update_default_selected(struct port
*port
)
600 // check if any parameter is different
601 if ((port
->partner_admin_port_number
!= port
->partner_oper_port_number
) ||
602 (port
->partner_admin_port_priority
!= port
->partner_oper_port_priority
) ||
603 MAC_ADDRESS_COMPARE(&(port
->partner_admin_system
), &(port
->partner_oper_system
)) ||
604 (port
->partner_admin_system_priority
!= port
->partner_oper_system_priority
) ||
605 (port
->partner_admin_key
!= port
->partner_oper_key
) ||
606 ((port
->partner_admin_port_state
& AD_STATE_AGGREGATION
) != (port
->partner_oper_port_state
& AD_STATE_AGGREGATION
))
608 // update the state machine Selected variable
609 port
->sm_vars
&= ~AD_PORT_SELECTED
;
615 * __choose_matched - update a port's matched variable from a received lacpdu
616 * @lacpdu: the lacpdu we've received
617 * @port: the port we're looking at
619 * Update the value of the matched variable, using parameter values from a
620 * newly received lacpdu. Parameter values for the partner carried in the
621 * received PDU are compared with the corresponding operational parameter
622 * values for the actor. Matched is set to TRUE if all of these parameters
623 * match and the PDU parameter partner_state.aggregation has the same value as
624 * actor_oper_port_state.aggregation and lacp will actively maintain the link
625 * in the aggregation. Matched is also set to TRUE if the value of
626 * actor_state.aggregation in the received PDU is set to FALSE, i.e., indicates
627 * an individual link and lacp will actively maintain the link. Otherwise,
628 * matched is set to FALSE. LACP is considered to be actively maintaining the
629 * link if either the PDU's actor_state.lacp_activity variable is TRUE or both
630 * the actor's actor_oper_port_state.lacp_activity and the PDU's
631 * partner_state.lacp_activity variables are TRUE.
633 static void __choose_matched(struct lacpdu
*lacpdu
, struct port
*port
)
635 // validate lacpdu and port
636 if (lacpdu
&& port
) {
637 // check if all parameters are alike
638 if (((ntohs(lacpdu
->partner_port
) == port
->actor_port_number
) &&
639 (ntohs(lacpdu
->partner_port_priority
) == port
->actor_port_priority
) &&
640 !MAC_ADDRESS_COMPARE(&(lacpdu
->partner_system
), &(port
->actor_system
)) &&
641 (ntohs(lacpdu
->partner_system_priority
) == port
->actor_system_priority
) &&
642 (ntohs(lacpdu
->partner_key
) == port
->actor_oper_port_key
) &&
643 ((lacpdu
->partner_state
& AD_STATE_AGGREGATION
) == (port
->actor_oper_port_state
& AD_STATE_AGGREGATION
))) ||
644 // or this is individual link(aggregation == FALSE)
645 ((lacpdu
->actor_state
& AD_STATE_AGGREGATION
) == 0)
647 // update the state machine Matched variable
648 port
->sm_vars
|= AD_PORT_MATCHED
;
650 port
->sm_vars
&= ~AD_PORT_MATCHED
;
656 * __update_ntt - update a port's ntt variable from a received lacpdu
657 * @lacpdu: the lacpdu we've received
658 * @port: the port we're looking at
660 * Updates the value of the ntt variable, using parameter values from a newly
661 * received lacpdu. The parameter values for the partner carried in the
662 * received PDU are compared with the corresponding operational parameter
663 * values for the Actor. If one or more of the comparisons shows that the
664 * value(s) received in the PDU differ from the current operational values,
665 * then ntt is set to TRUE. Otherwise, ntt remains unchanged.
667 static void __update_ntt(struct lacpdu
*lacpdu
, struct port
*port
)
669 // validate lacpdu and port
670 if (lacpdu
&& port
) {
671 // check if any parameter is different
672 if ((ntohs(lacpdu
->partner_port
) != port
->actor_port_number
) ||
673 (ntohs(lacpdu
->partner_port_priority
) != port
->actor_port_priority
) ||
674 MAC_ADDRESS_COMPARE(&(lacpdu
->partner_system
), &(port
->actor_system
)) ||
675 (ntohs(lacpdu
->partner_system_priority
) != port
->actor_system_priority
) ||
676 (ntohs(lacpdu
->partner_key
) != port
->actor_oper_port_key
) ||
677 ((lacpdu
->partner_state
& AD_STATE_LACP_ACTIVITY
) != (port
->actor_oper_port_state
& AD_STATE_LACP_ACTIVITY
)) ||
678 ((lacpdu
->partner_state
& AD_STATE_LACP_TIMEOUT
) != (port
->actor_oper_port_state
& AD_STATE_LACP_TIMEOUT
)) ||
679 ((lacpdu
->partner_state
& AD_STATE_SYNCHRONIZATION
) != (port
->actor_oper_port_state
& AD_STATE_SYNCHRONIZATION
)) ||
680 ((lacpdu
->partner_state
& AD_STATE_AGGREGATION
) != (port
->actor_oper_port_state
& AD_STATE_AGGREGATION
))
682 // set ntt to be TRUE
689 * __attach_bond_to_agg
690 * @port: the port we're looking at
692 * Handle the attaching of the port's control parser/multiplexer and the
693 * aggregator. This function does nothing since the parser/multiplexer of the
694 * receive and the parser/multiplexer of the aggregator are already combined.
696 static void __attach_bond_to_agg(struct port
*port
)
698 port
=NULL
; // just to satisfy the compiler
699 // This function does nothing since the parser/multiplexer of the receive
700 // and the parser/multiplexer of the aggregator are already combined
704 * __detach_bond_from_agg
705 * @port: the port we're looking at
707 * Handle the detaching of the port's control parser/multiplexer from the
708 * aggregator. This function does nothing since the parser/multiplexer of the
709 * receive and the parser/multiplexer of the aggregator are already combined.
711 static void __detach_bond_from_agg(struct port
*port
)
713 port
=NULL
; // just to satisfy the compiler
714 // This function does nothing sience the parser/multiplexer of the receive
715 // and the parser/multiplexer of the aggregator are already combined
719 * __agg_ports_are_ready - check if all ports in an aggregator are ready
720 * @aggregator: the aggregator we're looking at
723 static int __agg_ports_are_ready(struct aggregator
*aggregator
)
729 // scan all ports in this aggregator to verfy if they are all ready
730 for (port
=aggregator
->lag_ports
; port
; port
=port
->next_port_in_aggregator
) {
731 if (!(port
->sm_vars
& AD_PORT_READY_N
)) {
742 * __set_agg_ports_ready - set value of Ready bit in all ports of an aggregator
743 * @aggregator: the aggregator we're looking at
744 * @val: Should the ports' ready bit be set on or off
747 static void __set_agg_ports_ready(struct aggregator
*aggregator
, int val
)
751 for (port
=aggregator
->lag_ports
; port
; port
=port
->next_port_in_aggregator
) {
753 port
->sm_vars
|= AD_PORT_READY
;
755 port
->sm_vars
&= ~AD_PORT_READY
;
761 * __get_agg_bandwidth - get the total bandwidth of an aggregator
762 * @aggregator: the aggregator we're looking at
765 static u32
__get_agg_bandwidth(struct aggregator
*aggregator
)
770 if (aggregator
->num_of_ports
) {
771 basic_speed
= __get_link_speed(aggregator
->lag_ports
);
772 switch (basic_speed
) {
773 case AD_LINK_SPEED_BITMASK_1MBPS
:
774 bandwidth
= aggregator
->num_of_ports
;
776 case AD_LINK_SPEED_BITMASK_10MBPS
:
777 bandwidth
= aggregator
->num_of_ports
* 10;
779 case AD_LINK_SPEED_BITMASK_100MBPS
:
780 bandwidth
= aggregator
->num_of_ports
* 100;
782 case AD_LINK_SPEED_BITMASK_1000MBPS
:
783 bandwidth
= aggregator
->num_of_ports
* 1000;
785 case AD_LINK_SPEED_BITMASK_10000MBPS
:
786 bandwidth
= aggregator
->num_of_ports
* 10000;
789 bandwidth
=0; // to silent the compilor ....
796 * __get_active_agg - get the current active aggregator
797 * @aggregator: the aggregator we're looking at
800 static struct aggregator
*__get_active_agg(struct aggregator
*aggregator
)
802 struct aggregator
*retval
= NULL
;
804 for (; aggregator
; aggregator
= __get_next_agg(aggregator
)) {
805 if (aggregator
->is_active
) {
815 * __update_lacpdu_from_port - update a port's lacpdu fields
816 * @port: the port we're looking at
819 static inline void __update_lacpdu_from_port(struct port
*port
)
821 struct lacpdu
*lacpdu
= &port
->lacpdu
;
823 /* update current actual Actor parameters */
824 /* lacpdu->subtype initialized
825 * lacpdu->version_number initialized
826 * lacpdu->tlv_type_actor_info initialized
827 * lacpdu->actor_information_length initialized
830 lacpdu
->actor_system_priority
= port
->actor_system_priority
;
831 lacpdu
->actor_system
= port
->actor_system
;
832 lacpdu
->actor_key
= port
->actor_oper_port_key
;
833 lacpdu
->actor_port_priority
= port
->actor_port_priority
;
834 lacpdu
->actor_port
= port
->actor_port_number
;
835 lacpdu
->actor_state
= port
->actor_oper_port_state
;
837 /* lacpdu->reserved_3_1 initialized
838 * lacpdu->tlv_type_partner_info initialized
839 * lacpdu->partner_information_length initialized
842 lacpdu
->partner_system_priority
= port
->partner_oper_system_priority
;
843 lacpdu
->partner_system
= port
->partner_oper_system
;
844 lacpdu
->partner_key
= port
->partner_oper_key
;
845 lacpdu
->partner_port_priority
= port
->partner_oper_port_priority
;
846 lacpdu
->partner_port
= port
->partner_oper_port_number
;
847 lacpdu
->partner_state
= port
->partner_oper_port_state
;
849 /* lacpdu->reserved_3_2 initialized
850 * lacpdu->tlv_type_collector_info initialized
851 * lacpdu->collector_information_length initialized
852 * collector_max_delay initialized
853 * reserved_12[12] initialized
854 * tlv_type_terminator initialized
855 * terminator_length initialized
856 * reserved_50[50] initialized
859 /* Convert all non u8 parameters to Big Endian for transmit */
860 __htons_lacpdu(lacpdu
);
863 //////////////////////////////////////////////////////////////////////////////////////
864 // ================= main 802.3ad protocol code ======================================
865 //////////////////////////////////////////////////////////////////////////////////////
868 * ad_lacpdu_send - send out a lacpdu packet on a given port
869 * @port: the port we're looking at
871 * Returns: 0 on success
874 static int ad_lacpdu_send(struct port
*port
)
876 struct slave
*slave
= port
->slave
;
878 struct lacpdu_header
*lacpdu_header
;
879 int length
= sizeof(struct lacpdu_header
);
880 struct mac_addr lacpdu_multicast_address
= AD_MULTICAST_LACPDU_ADDR
;
882 skb
= dev_alloc_skb(length
);
887 skb
->dev
= slave
->dev
;
888 skb_reset_mac_header(skb
);
889 skb
->network_header
= skb
->mac_header
+ ETH_HLEN
;
890 skb
->protocol
= PKT_TYPE_LACPDU
;
891 skb
->priority
= TC_PRIO_CONTROL
;
893 lacpdu_header
= (struct lacpdu_header
*)skb_put(skb
, length
);
895 lacpdu_header
->ad_header
.destination_address
= lacpdu_multicast_address
;
896 /* Note: source addres is set to be the member's PERMANENT address, because we use it
897 to identify loopback lacpdus in receive. */
898 lacpdu_header
->ad_header
.source_address
= *((struct mac_addr
*)(slave
->perm_hwaddr
));
899 lacpdu_header
->ad_header
.length_type
= PKT_TYPE_LACPDU
;
901 lacpdu_header
->lacpdu
= port
->lacpdu
; // struct copy
909 * ad_marker_send - send marker information/response on a given port
910 * @port: the port we're looking at
911 * @marker: marker data to send
913 * Returns: 0 on success
916 static int ad_marker_send(struct port
*port
, struct marker
*marker
)
918 struct slave
*slave
= port
->slave
;
920 struct marker_header
*marker_header
;
921 int length
= sizeof(struct marker_header
);
922 struct mac_addr lacpdu_multicast_address
= AD_MULTICAST_LACPDU_ADDR
;
924 skb
= dev_alloc_skb(length
+ 16);
929 skb_reserve(skb
, 16);
931 skb
->dev
= slave
->dev
;
932 skb_reset_mac_header(skb
);
933 skb
->network_header
= skb
->mac_header
+ ETH_HLEN
;
934 skb
->protocol
= PKT_TYPE_LACPDU
;
936 marker_header
= (struct marker_header
*)skb_put(skb
, length
);
938 marker_header
->ad_header
.destination_address
= lacpdu_multicast_address
;
939 /* Note: source addres is set to be the member's PERMANENT address, because we use it
940 to identify loopback MARKERs in receive. */
941 marker_header
->ad_header
.source_address
= *((struct mac_addr
*)(slave
->perm_hwaddr
));
942 marker_header
->ad_header
.length_type
= PKT_TYPE_LACPDU
;
944 marker_header
->marker
= *marker
; // struct copy
952 * ad_mux_machine - handle a port's mux state machine
953 * @port: the port we're looking at
956 static void ad_mux_machine(struct port
*port
)
958 mux_states_t last_state
;
960 // keep current State Machine state to compare later if it was changed
961 last_state
= port
->sm_mux_state
;
963 if (port
->sm_vars
& AD_PORT_BEGIN
) {
964 port
->sm_mux_state
= AD_MUX_DETACHED
; // next state
966 switch (port
->sm_mux_state
) {
967 case AD_MUX_DETACHED
:
968 if ((port
->sm_vars
& AD_PORT_SELECTED
) || (port
->sm_vars
& AD_PORT_STANDBY
)) { // if SELECTED or STANDBY
969 port
->sm_mux_state
= AD_MUX_WAITING
; // next state
973 // if SELECTED == FALSE return to DETACH state
974 if (!(port
->sm_vars
& AD_PORT_SELECTED
)) { // if UNSELECTED
975 port
->sm_vars
&= ~AD_PORT_READY_N
;
976 // in order to withhold the Selection Logic to check all ports READY_N value
977 // every callback cycle to update ready variable, we check READY_N and update READY here
978 __set_agg_ports_ready(port
->aggregator
, __agg_ports_are_ready(port
->aggregator
));
979 port
->sm_mux_state
= AD_MUX_DETACHED
; // next state
983 // check if the wait_while_timer expired
984 if (port
->sm_mux_timer_counter
&& !(--port
->sm_mux_timer_counter
)) {
985 port
->sm_vars
|= AD_PORT_READY_N
;
988 // in order to withhold the selection logic to check all ports READY_N value
989 // every callback cycle to update ready variable, we check READY_N and update READY here
990 __set_agg_ports_ready(port
->aggregator
, __agg_ports_are_ready(port
->aggregator
));
992 // if the wait_while_timer expired, and the port is in READY state, move to ATTACHED state
993 if ((port
->sm_vars
& AD_PORT_READY
) && !port
->sm_mux_timer_counter
) {
994 port
->sm_mux_state
= AD_MUX_ATTACHED
; // next state
997 case AD_MUX_ATTACHED
:
998 // check also if agg_select_timer expired(so the edable port will take place only after this timer)
999 if ((port
->sm_vars
& AD_PORT_SELECTED
) && (port
->partner_oper_port_state
& AD_STATE_SYNCHRONIZATION
) && !__check_agg_selection_timer(port
)) {
1000 port
->sm_mux_state
= AD_MUX_COLLECTING_DISTRIBUTING
;// next state
1001 } else if (!(port
->sm_vars
& AD_PORT_SELECTED
) || (port
->sm_vars
& AD_PORT_STANDBY
)) { // if UNSELECTED or STANDBY
1002 port
->sm_vars
&= ~AD_PORT_READY_N
;
1003 // in order to withhold the selection logic to check all ports READY_N value
1004 // every callback cycle to update ready variable, we check READY_N and update READY here
1005 __set_agg_ports_ready(port
->aggregator
, __agg_ports_are_ready(port
->aggregator
));
1006 port
->sm_mux_state
= AD_MUX_DETACHED
;// next state
1009 case AD_MUX_COLLECTING_DISTRIBUTING
:
1010 if (!(port
->sm_vars
& AD_PORT_SELECTED
) || (port
->sm_vars
& AD_PORT_STANDBY
) ||
1011 !(port
->partner_oper_port_state
& AD_STATE_SYNCHRONIZATION
)
1013 port
->sm_mux_state
= AD_MUX_ATTACHED
;// next state
1016 // if port state hasn't changed make
1017 // sure that a collecting distributing
1018 // port in an active aggregator is enabled
1019 if (port
->aggregator
&&
1020 port
->aggregator
->is_active
&&
1021 !__port_is_enabled(port
)) {
1023 __enable_port(port
);
1027 default: //to silence the compiler
1032 // check if the state machine was changed
1033 if (port
->sm_mux_state
!= last_state
) {
1034 dprintk("Mux Machine: Port=%d, Last State=%d, Curr State=%d\n", port
->actor_port_number
, last_state
, port
->sm_mux_state
);
1035 switch (port
->sm_mux_state
) {
1036 case AD_MUX_DETACHED
:
1037 __detach_bond_from_agg(port
);
1038 port
->actor_oper_port_state
&= ~AD_STATE_SYNCHRONIZATION
;
1039 ad_disable_collecting_distributing(port
);
1040 port
->actor_oper_port_state
&= ~AD_STATE_COLLECTING
;
1041 port
->actor_oper_port_state
&= ~AD_STATE_DISTRIBUTING
;
1044 case AD_MUX_WAITING
:
1045 port
->sm_mux_timer_counter
= __ad_timer_to_ticks(AD_WAIT_WHILE_TIMER
, 0);
1047 case AD_MUX_ATTACHED
:
1048 __attach_bond_to_agg(port
);
1049 port
->actor_oper_port_state
|= AD_STATE_SYNCHRONIZATION
;
1050 port
->actor_oper_port_state
&= ~AD_STATE_COLLECTING
;
1051 port
->actor_oper_port_state
&= ~AD_STATE_DISTRIBUTING
;
1052 ad_disable_collecting_distributing(port
);
1055 case AD_MUX_COLLECTING_DISTRIBUTING
:
1056 port
->actor_oper_port_state
|= AD_STATE_COLLECTING
;
1057 port
->actor_oper_port_state
|= AD_STATE_DISTRIBUTING
;
1058 ad_enable_collecting_distributing(port
);
1061 default: //to silence the compiler
1068 * ad_rx_machine - handle a port's rx State Machine
1069 * @lacpdu: the lacpdu we've received
1070 * @port: the port we're looking at
1072 * If lacpdu arrived, stop previous timer (if exists) and set the next state as
1073 * CURRENT. If timer expired set the state machine in the proper state.
1074 * In other cases, this function checks if we need to switch to other state.
1076 static void ad_rx_machine(struct lacpdu
*lacpdu
, struct port
*port
)
1078 rx_states_t last_state
;
1080 // Lock to prevent 2 instances of this function to run simultaneously(rx interrupt and periodic machine callback)
1081 __get_rx_machine_lock(port
);
1083 // keep current State Machine state to compare later if it was changed
1084 last_state
= port
->sm_rx_state
;
1086 // check if state machine should change state
1087 // first, check if port was reinitialized
1088 if (port
->sm_vars
& AD_PORT_BEGIN
) {
1089 port
->sm_rx_state
= AD_RX_INITIALIZE
; // next state
1091 // check if port is not enabled
1092 else if (!(port
->sm_vars
& AD_PORT_BEGIN
) && !port
->is_enabled
&& !(port
->sm_vars
& AD_PORT_MOVED
)) {
1093 port
->sm_rx_state
= AD_RX_PORT_DISABLED
; // next state
1095 // check if new lacpdu arrived
1096 else if (lacpdu
&& ((port
->sm_rx_state
== AD_RX_EXPIRED
) || (port
->sm_rx_state
== AD_RX_DEFAULTED
) || (port
->sm_rx_state
== AD_RX_CURRENT
))) {
1097 port
->sm_rx_timer_counter
= 0; // zero timer
1098 port
->sm_rx_state
= AD_RX_CURRENT
;
1100 // if timer is on, and if it is expired
1101 if (port
->sm_rx_timer_counter
&& !(--port
->sm_rx_timer_counter
)) {
1102 switch (port
->sm_rx_state
) {
1104 port
->sm_rx_state
= AD_RX_DEFAULTED
; // next state
1107 port
->sm_rx_state
= AD_RX_EXPIRED
; // next state
1109 default: //to silence the compiler
1113 // if no lacpdu arrived and no timer is on
1114 switch (port
->sm_rx_state
) {
1115 case AD_RX_PORT_DISABLED
:
1116 if (port
->sm_vars
& AD_PORT_MOVED
) {
1117 port
->sm_rx_state
= AD_RX_INITIALIZE
; // next state
1118 } else if (port
->is_enabled
&& (port
->sm_vars
& AD_PORT_LACP_ENABLED
)) {
1119 port
->sm_rx_state
= AD_RX_EXPIRED
; // next state
1120 } else if (port
->is_enabled
&& ((port
->sm_vars
& AD_PORT_LACP_ENABLED
) == 0)) {
1121 port
->sm_rx_state
= AD_RX_LACP_DISABLED
; // next state
1124 default: //to silence the compiler
1131 // check if the State machine was changed or new lacpdu arrived
1132 if ((port
->sm_rx_state
!= last_state
) || (lacpdu
)) {
1133 dprintk("Rx Machine: Port=%d, Last State=%d, Curr State=%d\n", port
->actor_port_number
, last_state
, port
->sm_rx_state
);
1134 switch (port
->sm_rx_state
) {
1135 case AD_RX_INITIALIZE
:
1136 if (!(port
->actor_oper_port_key
& AD_DUPLEX_KEY_BITS
)) {
1137 port
->sm_vars
&= ~AD_PORT_LACP_ENABLED
;
1139 port
->sm_vars
|= AD_PORT_LACP_ENABLED
;
1141 port
->sm_vars
&= ~AD_PORT_SELECTED
;
1142 __record_default(port
);
1143 port
->actor_oper_port_state
&= ~AD_STATE_EXPIRED
;
1144 port
->sm_vars
&= ~AD_PORT_MOVED
;
1145 port
->sm_rx_state
= AD_RX_PORT_DISABLED
; // next state
1147 /*- Fall Through -*/
1149 case AD_RX_PORT_DISABLED
:
1150 port
->sm_vars
&= ~AD_PORT_MATCHED
;
1152 case AD_RX_LACP_DISABLED
:
1153 port
->sm_vars
&= ~AD_PORT_SELECTED
;
1154 __record_default(port
);
1155 port
->partner_oper_port_state
&= ~AD_STATE_AGGREGATION
;
1156 port
->sm_vars
|= AD_PORT_MATCHED
;
1157 port
->actor_oper_port_state
&= ~AD_STATE_EXPIRED
;
1160 //Reset of the Synchronization flag. (Standard 43.4.12)
1161 //This reset cause to disable this port in the COLLECTING_DISTRIBUTING state of the
1162 //mux machine in case of EXPIRED even if LINK_DOWN didn't arrive for the port.
1163 port
->partner_oper_port_state
&= ~AD_STATE_SYNCHRONIZATION
;
1164 port
->sm_vars
&= ~AD_PORT_MATCHED
;
1165 port
->partner_oper_port_state
|= AD_SHORT_TIMEOUT
;
1166 port
->sm_rx_timer_counter
= __ad_timer_to_ticks(AD_CURRENT_WHILE_TIMER
, (u16
)(AD_SHORT_TIMEOUT
));
1167 port
->actor_oper_port_state
|= AD_STATE_EXPIRED
;
1169 case AD_RX_DEFAULTED
:
1170 __update_default_selected(port
);
1171 __record_default(port
);
1172 port
->sm_vars
|= AD_PORT_MATCHED
;
1173 port
->actor_oper_port_state
&= ~AD_STATE_EXPIRED
;
1176 // detect loopback situation
1177 if (!MAC_ADDRESS_COMPARE(&(lacpdu
->actor_system
), &(port
->actor_system
))) {
1178 // INFO_RECEIVED_LOOPBACK_FRAMES
1179 printk(KERN_ERR DRV_NAME
": %s: An illegal loopback occurred on "
1180 "adapter (%s). Check the configuration to verify that all "
1181 "Adapters are connected to 802.3ad compliant switch ports\n",
1182 port
->slave
->dev
->master
->name
, port
->slave
->dev
->name
);
1183 __release_rx_machine_lock(port
);
1186 __update_selected(lacpdu
, port
);
1187 __update_ntt(lacpdu
, port
);
1188 __record_pdu(lacpdu
, port
);
1189 __choose_matched(lacpdu
, port
);
1190 port
->sm_rx_timer_counter
= __ad_timer_to_ticks(AD_CURRENT_WHILE_TIMER
, (u16
)(port
->actor_oper_port_state
& AD_STATE_LACP_TIMEOUT
));
1191 port
->actor_oper_port_state
&= ~AD_STATE_EXPIRED
;
1192 // verify that if the aggregator is enabled, the port is enabled too.
1193 //(because if the link goes down for a short time, the 802.3ad will not
1194 // catch it, and the port will continue to be disabled)
1195 if (port
->aggregator
&& port
->aggregator
->is_active
&& !__port_is_enabled(port
)) {
1196 __enable_port(port
);
1199 default: //to silence the compiler
1203 __release_rx_machine_lock(port
);
1207 * ad_tx_machine - handle a port's tx state machine
1208 * @port: the port we're looking at
1211 static void ad_tx_machine(struct port
*port
)
1213 // check if tx timer expired, to verify that we do not send more than 3 packets per second
1214 if (port
->sm_tx_timer_counter
&& !(--port
->sm_tx_timer_counter
)) {
1215 // check if there is something to send
1216 if (port
->ntt
&& (port
->sm_vars
& AD_PORT_LACP_ENABLED
)) {
1217 __update_lacpdu_from_port(port
);
1219 if (ad_lacpdu_send(port
) >= 0) {
1220 dprintk("Sent LACPDU on port %d\n", port
->actor_port_number
);
1221 // mark ntt as false, so it will not be sent again until demanded
1225 // restart tx timer(to verify that we will not exceed AD_MAX_TX_IN_SECOND
1226 port
->sm_tx_timer_counter
=ad_ticks_per_sec
/AD_MAX_TX_IN_SECOND
;
1231 * ad_periodic_machine - handle a port's periodic state machine
1232 * @port: the port we're looking at
1234 * Turn ntt flag on priodically to perform periodic transmission of lacpdu's.
1236 static void ad_periodic_machine(struct port
*port
)
1238 periodic_states_t last_state
;
1240 // keep current state machine state to compare later if it was changed
1241 last_state
= port
->sm_periodic_state
;
1243 // check if port was reinitialized
1244 if (((port
->sm_vars
& AD_PORT_BEGIN
) || !(port
->sm_vars
& AD_PORT_LACP_ENABLED
) || !port
->is_enabled
) ||
1245 (!(port
->actor_oper_port_state
& AD_STATE_LACP_ACTIVITY
) && !(port
->partner_oper_port_state
& AD_STATE_LACP_ACTIVITY
))
1247 port
->sm_periodic_state
= AD_NO_PERIODIC
; // next state
1249 // check if state machine should change state
1250 else if (port
->sm_periodic_timer_counter
) {
1251 // check if periodic state machine expired
1252 if (!(--port
->sm_periodic_timer_counter
)) {
1253 // if expired then do tx
1254 port
->sm_periodic_state
= AD_PERIODIC_TX
; // next state
1256 // If not expired, check if there is some new timeout parameter from the partner state
1257 switch (port
->sm_periodic_state
) {
1258 case AD_FAST_PERIODIC
:
1259 if (!(port
->partner_oper_port_state
& AD_STATE_LACP_TIMEOUT
)) {
1260 port
->sm_periodic_state
= AD_SLOW_PERIODIC
; // next state
1263 case AD_SLOW_PERIODIC
:
1264 if ((port
->partner_oper_port_state
& AD_STATE_LACP_TIMEOUT
)) {
1265 // stop current timer
1266 port
->sm_periodic_timer_counter
= 0;
1267 port
->sm_periodic_state
= AD_PERIODIC_TX
; // next state
1270 default: //to silence the compiler
1275 switch (port
->sm_periodic_state
) {
1276 case AD_NO_PERIODIC
:
1277 port
->sm_periodic_state
= AD_FAST_PERIODIC
; // next state
1279 case AD_PERIODIC_TX
:
1280 if (!(port
->partner_oper_port_state
& AD_STATE_LACP_TIMEOUT
)) {
1281 port
->sm_periodic_state
= AD_SLOW_PERIODIC
; // next state
1283 port
->sm_periodic_state
= AD_FAST_PERIODIC
; // next state
1286 default: //to silence the compiler
1291 // check if the state machine was changed
1292 if (port
->sm_periodic_state
!= last_state
) {
1293 dprintk("Periodic Machine: Port=%d, Last State=%d, Curr State=%d\n", port
->actor_port_number
, last_state
, port
->sm_periodic_state
);
1294 switch (port
->sm_periodic_state
) {
1295 case AD_NO_PERIODIC
:
1296 port
->sm_periodic_timer_counter
= 0; // zero timer
1298 case AD_FAST_PERIODIC
:
1299 port
->sm_periodic_timer_counter
= __ad_timer_to_ticks(AD_PERIODIC_TIMER
, (u16
)(AD_FAST_PERIODIC_TIME
))-1; // decrement 1 tick we lost in the PERIODIC_TX cycle
1301 case AD_SLOW_PERIODIC
:
1302 port
->sm_periodic_timer_counter
= __ad_timer_to_ticks(AD_PERIODIC_TIMER
, (u16
)(AD_SLOW_PERIODIC_TIME
))-1; // decrement 1 tick we lost in the PERIODIC_TX cycle
1304 case AD_PERIODIC_TX
:
1307 default: //to silence the compiler
1314 * ad_port_selection_logic - select aggregation groups
1315 * @port: the port we're looking at
1317 * Select aggregation groups, and assign each port for it's aggregetor. The
1318 * selection logic is called in the inititalization (after all the handshkes),
1319 * and after every lacpdu receive (if selected is off).
1321 static void ad_port_selection_logic(struct port
*port
)
1323 struct aggregator
*aggregator
, *free_aggregator
= NULL
, *temp_aggregator
;
1324 struct port
*last_port
= NULL
, *curr_port
;
1327 // if the port is already Selected, do nothing
1328 if (port
->sm_vars
& AD_PORT_SELECTED
) {
1332 // if the port is connected to other aggregator, detach it
1333 if (port
->aggregator
) {
1334 // detach the port from its former aggregator
1335 temp_aggregator
=port
->aggregator
;
1336 for (curr_port
=temp_aggregator
->lag_ports
; curr_port
; last_port
=curr_port
, curr_port
=curr_port
->next_port_in_aggregator
) {
1337 if (curr_port
== port
) {
1338 temp_aggregator
->num_of_ports
--;
1339 if (!last_port
) {// if it is the first port attached to the aggregator
1340 temp_aggregator
->lag_ports
=port
->next_port_in_aggregator
;
1341 } else {// not the first port attached to the aggregator
1342 last_port
->next_port_in_aggregator
=port
->next_port_in_aggregator
;
1345 // clear the port's relations to this aggregator
1346 port
->aggregator
= NULL
;
1347 port
->next_port_in_aggregator
=NULL
;
1348 port
->actor_port_aggregator_identifier
=0;
1350 dprintk("Port %d left LAG %d\n", port
->actor_port_number
, temp_aggregator
->aggregator_identifier
);
1351 // if the aggregator is empty, clear its parameters, and set it ready to be attached
1352 if (!temp_aggregator
->lag_ports
) {
1353 ad_clear_agg(temp_aggregator
);
1358 if (!curr_port
) { // meaning: the port was related to an aggregator but was not on the aggregator port list
1359 printk(KERN_WARNING DRV_NAME
": %s: Warning: Port %d (on %s) was "
1360 "related to aggregator %d but was not on its port list\n",
1361 port
->slave
->dev
->master
->name
,
1362 port
->actor_port_number
, port
->slave
->dev
->name
,
1363 port
->aggregator
->aggregator_identifier
);
1366 // search on all aggregators for a suitable aggregator for this port
1367 for (aggregator
= __get_first_agg(port
); aggregator
;
1368 aggregator
= __get_next_agg(aggregator
)) {
1370 // keep a free aggregator for later use(if needed)
1371 if (!aggregator
->lag_ports
) {
1372 if (!free_aggregator
) {
1373 free_aggregator
=aggregator
;
1377 // check if current aggregator suits us
1378 if (((aggregator
->actor_oper_aggregator_key
== port
->actor_oper_port_key
) && // if all parameters match AND
1379 !MAC_ADDRESS_COMPARE(&(aggregator
->partner_system
), &(port
->partner_oper_system
)) &&
1380 (aggregator
->partner_system_priority
== port
->partner_oper_system_priority
) &&
1381 (aggregator
->partner_oper_aggregator_key
== port
->partner_oper_key
)
1383 ((MAC_ADDRESS_COMPARE(&(port
->partner_oper_system
), &(null_mac_addr
)) && // partner answers
1384 !aggregator
->is_individual
) // but is not individual OR
1387 // attach to the founded aggregator
1388 port
->aggregator
= aggregator
;
1389 port
->actor_port_aggregator_identifier
=port
->aggregator
->aggregator_identifier
;
1390 port
->next_port_in_aggregator
=aggregator
->lag_ports
;
1391 port
->aggregator
->num_of_ports
++;
1392 aggregator
->lag_ports
=port
;
1393 dprintk("Port %d joined LAG %d(existing LAG)\n", port
->actor_port_number
, port
->aggregator
->aggregator_identifier
);
1395 // mark this port as selected
1396 port
->sm_vars
|= AD_PORT_SELECTED
;
1402 // the port couldn't find an aggregator - attach it to a new aggregator
1404 if (free_aggregator
) {
1405 // assign port a new aggregator
1406 port
->aggregator
= free_aggregator
;
1407 port
->actor_port_aggregator_identifier
=port
->aggregator
->aggregator_identifier
;
1409 // update the new aggregator's parameters
1410 // if port was responsed from the end-user
1411 if (port
->actor_oper_port_key
& AD_DUPLEX_KEY_BITS
) {// if port is full duplex
1412 port
->aggregator
->is_individual
= 0;
1414 port
->aggregator
->is_individual
= 1;
1417 port
->aggregator
->actor_admin_aggregator_key
= port
->actor_admin_port_key
;
1418 port
->aggregator
->actor_oper_aggregator_key
= port
->actor_oper_port_key
;
1419 port
->aggregator
->partner_system
=port
->partner_oper_system
;
1420 port
->aggregator
->partner_system_priority
= port
->partner_oper_system_priority
;
1421 port
->aggregator
->partner_oper_aggregator_key
= port
->partner_oper_key
;
1422 port
->aggregator
->receive_state
= 1;
1423 port
->aggregator
->transmit_state
= 1;
1424 port
->aggregator
->lag_ports
= port
;
1425 port
->aggregator
->num_of_ports
++;
1427 // mark this port as selected
1428 port
->sm_vars
|= AD_PORT_SELECTED
;
1430 dprintk("Port %d joined LAG %d(new LAG)\n", port
->actor_port_number
, port
->aggregator
->aggregator_identifier
);
1432 printk(KERN_ERR DRV_NAME
": %s: Port %d (on %s) did not find a suitable aggregator\n",
1433 port
->slave
->dev
->master
->name
,
1434 port
->actor_port_number
, port
->slave
->dev
->name
);
1437 // if all aggregator's ports are READY_N == TRUE, set ready=TRUE in all aggregator's ports
1438 // else set ready=FALSE in all aggregator's ports
1439 __set_agg_ports_ready(port
->aggregator
, __agg_ports_are_ready(port
->aggregator
));
1441 if (!__check_agg_selection_timer(port
) && (aggregator
= __get_first_agg(port
))) {
1442 ad_agg_selection_logic(aggregator
);
1447 * ad_agg_selection_logic - select an aggregation group for a team
1448 * @aggregator: the aggregator we're looking at
1450 * It is assumed that only one aggregator may be selected for a team.
1451 * The logic of this function is to select (at first time) the aggregator with
1452 * the most ports attached to it, and to reselect the active aggregator only if
1453 * the previous aggregator has no more ports related to it.
1455 * FIXME: this function MUST be called with the first agg in the bond, or
1456 * __get_active_agg() won't work correctly. This function should be better
1457 * called with the bond itself, and retrieve the first agg from it.
1459 static void ad_agg_selection_logic(struct aggregator
*aggregator
)
1461 struct aggregator
*best_aggregator
= NULL
, *active_aggregator
= NULL
;
1462 struct aggregator
*last_active_aggregator
= NULL
, *origin_aggregator
;
1466 origin_aggregator
= aggregator
;
1468 //get current active aggregator
1469 last_active_aggregator
= __get_active_agg(aggregator
);
1471 // search for the aggregator with the most ports attached to it.
1473 // count how many candidate lag's we have
1474 if (aggregator
->lag_ports
) {
1477 if (aggregator
->is_active
&& !aggregator
->is_individual
&& // if current aggregator is the active aggregator
1478 MAC_ADDRESS_COMPARE(&(aggregator
->partner_system
), &(null_mac_addr
))) { // and partner answers to 802.3ad PDUs
1479 if (aggregator
->num_of_ports
) { // if any ports attached to the current aggregator
1480 best_aggregator
=NULL
; // disregard the best aggregator that was chosen by now
1481 break; // stop the selection of other aggregator if there are any ports attached to this active aggregator
1482 } else { // no ports attached to this active aggregator
1483 aggregator
->is_active
= 0; // mark this aggregator as not active anymore
1486 if (aggregator
->num_of_ports
) { // if any ports attached
1487 if (best_aggregator
) { // if there is a candidte aggregator
1488 //The reasons for choosing new best aggregator:
1489 // 1. if current agg is NOT individual and the best agg chosen so far is individual OR
1490 // current and best aggs are both individual or both not individual, AND
1491 // 2a. current agg partner reply but best agg partner do not reply OR
1492 // 2b. current agg partner reply OR current agg partner do not reply AND best agg partner also do not reply AND
1493 // current has more ports/bandwidth, or same amount of ports but current has faster ports, THEN
1494 // current agg become best agg so far
1496 //if current agg is NOT individual and the best agg chosen so far is individual change best_aggregator
1497 if (!aggregator
->is_individual
&& best_aggregator
->is_individual
) {
1498 best_aggregator
=aggregator
;
1500 // current and best aggs are both individual or both not individual
1501 else if ((aggregator
->is_individual
&& best_aggregator
->is_individual
) ||
1502 (!aggregator
->is_individual
&& !best_aggregator
->is_individual
)) {
1503 // current and best aggs are both individual or both not individual AND
1504 // current agg partner reply but best agg partner do not reply
1505 if ((MAC_ADDRESS_COMPARE(&(aggregator
->partner_system
), &(null_mac_addr
)) &&
1506 !MAC_ADDRESS_COMPARE(&(best_aggregator
->partner_system
), &(null_mac_addr
)))) {
1507 best_aggregator
=aggregator
;
1509 // current agg partner reply OR current agg partner do not reply AND best agg partner also do not reply
1510 else if (! (!MAC_ADDRESS_COMPARE(&(aggregator
->partner_system
), &(null_mac_addr
)) &&
1511 MAC_ADDRESS_COMPARE(&(best_aggregator
->partner_system
), &(null_mac_addr
)))) {
1512 if ((__get_agg_selection_mode(aggregator
->lag_ports
) == AD_BANDWIDTH
)&&
1513 (__get_agg_bandwidth(aggregator
) > __get_agg_bandwidth(best_aggregator
))) {
1514 best_aggregator
=aggregator
;
1515 } else if (__get_agg_selection_mode(aggregator
->lag_ports
) == AD_COUNT
) {
1516 if (((aggregator
->num_of_ports
> best_aggregator
->num_of_ports
) &&
1517 (aggregator
->actor_oper_aggregator_key
& AD_SPEED_KEY_BITS
))||
1518 ((aggregator
->num_of_ports
== best_aggregator
->num_of_ports
) &&
1519 ((u16
)(aggregator
->actor_oper_aggregator_key
& AD_SPEED_KEY_BITS
) >
1520 (u16
)(best_aggregator
->actor_oper_aggregator_key
& AD_SPEED_KEY_BITS
)))) {
1521 best_aggregator
=aggregator
;
1527 best_aggregator
=aggregator
;
1530 aggregator
->is_active
= 0; // mark all aggregators as not active anymore
1531 } while ((aggregator
= __get_next_agg(aggregator
)));
1533 // if we have new aggregator selected, don't replace the old aggregator if it has an answering partner,
1534 // or if both old aggregator and new aggregator don't have answering partner
1535 if (best_aggregator
) {
1536 if (last_active_aggregator
&& last_active_aggregator
->lag_ports
&& last_active_aggregator
->lag_ports
->is_enabled
&&
1537 (MAC_ADDRESS_COMPARE(&(last_active_aggregator
->partner_system
), &(null_mac_addr
)) || // partner answers OR
1538 (!MAC_ADDRESS_COMPARE(&(last_active_aggregator
->partner_system
), &(null_mac_addr
)) && // both old and new
1539 !MAC_ADDRESS_COMPARE(&(best_aggregator
->partner_system
), &(null_mac_addr
)))) // partner do not answer
1541 // if new aggregator has link, and old aggregator does not, replace old aggregator.(do nothing)
1542 // -> don't replace otherwise.
1543 if (!(!last_active_aggregator
->actor_oper_aggregator_key
&& best_aggregator
->actor_oper_aggregator_key
)) {
1544 best_aggregator
=NULL
;
1545 last_active_aggregator
->is_active
= 1; // don't replace good old aggregator
1551 // if there is new best aggregator, activate it
1552 if (best_aggregator
) {
1553 for (aggregator
= __get_first_agg(best_aggregator
->lag_ports
);
1555 aggregator
= __get_next_agg(aggregator
)) {
1557 dprintk("Agg=%d; Ports=%d; a key=%d; p key=%d; Indiv=%d; Active=%d\n",
1558 aggregator
->aggregator_identifier
, aggregator
->num_of_ports
,
1559 aggregator
->actor_oper_aggregator_key
, aggregator
->partner_oper_aggregator_key
,
1560 aggregator
->is_individual
, aggregator
->is_active
);
1563 // check if any partner replys
1564 if (best_aggregator
->is_individual
) {
1565 printk(KERN_WARNING DRV_NAME
": %s: Warning: No 802.3ad response from "
1566 "the link partner for any adapters in the bond\n",
1567 best_aggregator
->slave
->dev
->master
->name
);
1570 // check if there are more than one aggregator
1571 if (num_of_aggs
> 1) {
1572 dprintk("Warning: More than one Link Aggregation Group was "
1573 "found in the bond. Only one group will function in the bond\n");
1576 best_aggregator
->is_active
= 1;
1577 dprintk("LAG %d choosed as the active LAG\n", best_aggregator
->aggregator_identifier
);
1578 dprintk("Agg=%d; Ports=%d; a key=%d; p key=%d; Indiv=%d; Active=%d\n",
1579 best_aggregator
->aggregator_identifier
, best_aggregator
->num_of_ports
,
1580 best_aggregator
->actor_oper_aggregator_key
, best_aggregator
->partner_oper_aggregator_key
,
1581 best_aggregator
->is_individual
, best_aggregator
->is_active
);
1583 // disable the ports that were related to the former active_aggregator
1584 if (last_active_aggregator
) {
1585 for (port
=last_active_aggregator
->lag_ports
; port
; port
=port
->next_port_in_aggregator
) {
1586 __disable_port(port
);
1591 // if the selected aggregator is of join individuals(partner_system is NULL), enable their ports
1592 active_aggregator
= __get_active_agg(origin_aggregator
);
1594 if (active_aggregator
) {
1595 if (!MAC_ADDRESS_COMPARE(&(active_aggregator
->partner_system
), &(null_mac_addr
))) {
1596 for (port
=active_aggregator
->lag_ports
; port
; port
=port
->next_port_in_aggregator
) {
1597 __enable_port(port
);
1604 * ad_clear_agg - clear a given aggregator's parameters
1605 * @aggregator: the aggregator we're looking at
1608 static void ad_clear_agg(struct aggregator
*aggregator
)
1611 aggregator
->is_individual
= 0;
1612 aggregator
->actor_admin_aggregator_key
= 0;
1613 aggregator
->actor_oper_aggregator_key
= 0;
1614 aggregator
->partner_system
= null_mac_addr
;
1615 aggregator
->partner_system_priority
= 0;
1616 aggregator
->partner_oper_aggregator_key
= 0;
1617 aggregator
->receive_state
= 0;
1618 aggregator
->transmit_state
= 0;
1619 aggregator
->lag_ports
= NULL
;
1620 aggregator
->is_active
= 0;
1621 aggregator
->num_of_ports
= 0;
1622 dprintk("LAG %d was cleared\n", aggregator
->aggregator_identifier
);
1627 * ad_initialize_agg - initialize a given aggregator's parameters
1628 * @aggregator: the aggregator we're looking at
1631 static void ad_initialize_agg(struct aggregator
*aggregator
)
1634 ad_clear_agg(aggregator
);
1636 aggregator
->aggregator_mac_address
= null_mac_addr
;
1637 aggregator
->aggregator_identifier
= 0;
1638 aggregator
->slave
= NULL
;
1643 * ad_initialize_port - initialize a given port's parameters
1644 * @aggregator: the aggregator we're looking at
1645 * @lacp_fast: boolean. whether fast periodic should be used
1648 static void ad_initialize_port(struct port
*port
, int lacp_fast
)
1651 port
->actor_port_number
= 1;
1652 port
->actor_port_priority
= 0xff;
1653 port
->actor_system
= null_mac_addr
;
1654 port
->actor_system_priority
= 0xffff;
1655 port
->actor_port_aggregator_identifier
= 0;
1657 port
->actor_admin_port_key
= 1;
1658 port
->actor_oper_port_key
= 1;
1659 port
->actor_admin_port_state
= AD_STATE_AGGREGATION
| AD_STATE_LACP_ACTIVITY
;
1660 port
->actor_oper_port_state
= AD_STATE_AGGREGATION
| AD_STATE_LACP_ACTIVITY
;
1663 port
->actor_oper_port_state
|= AD_STATE_LACP_TIMEOUT
;
1666 port
->partner_admin_system
= null_mac_addr
;
1667 port
->partner_oper_system
= null_mac_addr
;
1668 port
->partner_admin_system_priority
= 0xffff;
1669 port
->partner_oper_system_priority
= 0xffff;
1670 port
->partner_admin_key
= 1;
1671 port
->partner_oper_key
= 1;
1672 port
->partner_admin_port_number
= 1;
1673 port
->partner_oper_port_number
= 1;
1674 port
->partner_admin_port_priority
= 0xff;
1675 port
->partner_oper_port_priority
= 0xff;
1676 port
->partner_admin_port_state
= 1;
1677 port
->partner_oper_port_state
= 1;
1678 port
->is_enabled
= 1;
1679 // ****** private parameters ******
1680 port
->sm_vars
= 0x3;
1681 port
->sm_rx_state
= 0;
1682 port
->sm_rx_timer_counter
= 0;
1683 port
->sm_periodic_state
= 0;
1684 port
->sm_periodic_timer_counter
= 0;
1685 port
->sm_mux_state
= 0;
1686 port
->sm_mux_timer_counter
= 0;
1687 port
->sm_tx_state
= 0;
1688 port
->sm_tx_timer_counter
= 0;
1690 port
->aggregator
= NULL
;
1691 port
->next_port_in_aggregator
= NULL
;
1692 port
->transaction_id
= 0;
1694 ad_initialize_lacpdu(&(port
->lacpdu
));
1699 * ad_enable_collecting_distributing - enable a port's transmit/receive
1700 * @port: the port we're looking at
1702 * Enable @port if it's in an active aggregator
1704 static void ad_enable_collecting_distributing(struct port
*port
)
1706 if (port
->aggregator
->is_active
) {
1707 dprintk("Enabling port %d(LAG %d)\n", port
->actor_port_number
, port
->aggregator
->aggregator_identifier
);
1708 __enable_port(port
);
1713 * ad_disable_collecting_distributing - disable a port's transmit/receive
1714 * @port: the port we're looking at
1717 static void ad_disable_collecting_distributing(struct port
*port
)
1719 if (port
->aggregator
&& MAC_ADDRESS_COMPARE(&(port
->aggregator
->partner_system
), &(null_mac_addr
))) {
1720 dprintk("Disabling port %d(LAG %d)\n", port
->actor_port_number
, port
->aggregator
->aggregator_identifier
);
1721 __disable_port(port
);
1727 * ad_marker_info_send - send a marker information frame
1728 * @port: the port we're looking at
1730 * This function does nothing since we decided not to implement send and handle
1731 * response for marker PDU's, in this stage, but only to respond to marker
1734 static void ad_marker_info_send(struct port
*port
)
1736 struct marker marker
;
1739 // fill the marker PDU with the appropriate values
1740 marker
.subtype
= 0x02;
1741 marker
.version_number
= 0x01;
1742 marker
.tlv_type
= AD_MARKER_INFORMATION_SUBTYPE
;
1743 marker
.marker_length
= 0x16;
1744 // convert requester_port to Big Endian
1745 marker
.requester_port
= (((port
->actor_port_number
& 0xFF) << 8) |((u16
)(port
->actor_port_number
& 0xFF00) >> 8));
1746 marker
.requester_system
= port
->actor_system
;
1747 // convert requester_port(u32) to Big Endian
1748 marker
.requester_transaction_id
= (((++port
->transaction_id
& 0xFF) << 24) |((port
->transaction_id
& 0xFF00) << 8) |((port
->transaction_id
& 0xFF0000) >> 8) |((port
->transaction_id
& 0xFF000000) >> 24));
1750 marker
.tlv_type_terminator
= 0x00;
1751 marker
.terminator_length
= 0x00;
1752 for (index
=0; index
<90; index
++) {
1753 marker
.reserved_90
[index
]=0;
1756 // send the marker information
1757 if (ad_marker_send(port
, &marker
) >= 0) {
1758 dprintk("Sent Marker Information on port %d\n", port
->actor_port_number
);
1764 * ad_marker_info_received - handle receive of a Marker information frame
1765 * @marker_info: Marker info received
1766 * @port: the port we're looking at
1769 static void ad_marker_info_received(struct marker
*marker_info
,struct port
*port
)
1771 struct marker marker
;
1773 // copy the received marker data to the response marker
1774 //marker = *marker_info;
1775 memcpy(&marker
, marker_info
, sizeof(struct marker
));
1776 // change the marker subtype to marker response
1777 marker
.tlv_type
=AD_MARKER_RESPONSE_SUBTYPE
;
1778 // send the marker response
1780 if (ad_marker_send(port
, &marker
) >= 0) {
1781 dprintk("Sent Marker Response on port %d\n", port
->actor_port_number
);
1786 * ad_marker_response_received - handle receive of a marker response frame
1787 * @marker: marker PDU received
1788 * @port: the port we're looking at
1790 * This function does nothing since we decided not to implement send and handle
1791 * response for marker PDU's, in this stage, but only to respond to marker
1794 static void ad_marker_response_received(struct marker
*marker
, struct port
*port
)
1796 marker
=NULL
; // just to satisfy the compiler
1797 port
=NULL
; // just to satisfy the compiler
1798 // DO NOTHING, SINCE WE DECIDED NOT TO IMPLEMENT THIS FEATURE FOR NOW
1802 * ad_initialize_lacpdu - initialize a given lacpdu structure
1803 * @lacpdu: lacpdu structure to initialize
1806 static void ad_initialize_lacpdu(struct lacpdu
*lacpdu
)
1810 // initialize lacpdu data
1811 lacpdu
->subtype
= 0x01;
1812 lacpdu
->version_number
= 0x01;
1813 lacpdu
->tlv_type_actor_info
= 0x01;
1814 lacpdu
->actor_information_length
= 0x14;
1815 // lacpdu->actor_system_priority updated on send
1816 // lacpdu->actor_system updated on send
1817 // lacpdu->actor_key updated on send
1818 // lacpdu->actor_port_priority updated on send
1819 // lacpdu->actor_port updated on send
1820 // lacpdu->actor_state updated on send
1821 lacpdu
->tlv_type_partner_info
= 0x02;
1822 lacpdu
->partner_information_length
= 0x14;
1823 for (index
=0; index
<=2; index
++) {
1824 lacpdu
->reserved_3_1
[index
]=0;
1826 // lacpdu->partner_system_priority updated on send
1827 // lacpdu->partner_system updated on send
1828 // lacpdu->partner_key updated on send
1829 // lacpdu->partner_port_priority updated on send
1830 // lacpdu->partner_port updated on send
1831 // lacpdu->partner_state updated on send
1832 for (index
=0; index
<=2; index
++) {
1833 lacpdu
->reserved_3_2
[index
]=0;
1835 lacpdu
->tlv_type_collector_info
= 0x03;
1836 lacpdu
->collector_information_length
= 0x10;
1837 lacpdu
->collector_max_delay
= AD_COLLECTOR_MAX_DELAY
;
1838 for (index
=0; index
<=11; index
++) {
1839 lacpdu
->reserved_12
[index
]=0;
1841 lacpdu
->tlv_type_terminator
= 0x00;
1842 lacpdu
->terminator_length
= 0;
1843 for (index
=0; index
<=49; index
++) {
1844 lacpdu
->reserved_50
[index
]=0;
1848 //////////////////////////////////////////////////////////////////////////////////////
1849 // ================= AD exported functions to the main bonding code ==================
1850 //////////////////////////////////////////////////////////////////////////////////////
1852 // Check aggregators status in team every T seconds
1853 #define AD_AGGREGATOR_SELECTION_TIMER 8
1855 static u16 aggregator_identifier
;
1858 * bond_3ad_initialize - initialize a bond's 802.3ad parameters and structures
1859 * @bond: bonding struct to work on
1860 * @tick_resolution: tick duration (millisecond resolution)
1861 * @lacp_fast: boolean. whether fast periodic should be used
1863 * Can be called only after the mac address of the bond is set.
1865 void bond_3ad_initialize(struct bonding
*bond
, u16 tick_resolution
, int lacp_fast
)
1867 // check that the bond is not initialized yet
1868 if (MAC_ADDRESS_COMPARE(&(BOND_AD_INFO(bond
).system
.sys_mac_addr
), &(bond
->dev
->dev_addr
))) {
1870 aggregator_identifier
= 0;
1872 BOND_AD_INFO(bond
).lacp_fast
= lacp_fast
;
1873 BOND_AD_INFO(bond
).system
.sys_priority
= 0xFFFF;
1874 BOND_AD_INFO(bond
).system
.sys_mac_addr
= *((struct mac_addr
*)bond
->dev
->dev_addr
);
1876 // initialize how many times this module is called in one second(should be about every 100ms)
1877 ad_ticks_per_sec
= tick_resolution
;
1879 // initialize the aggregator selection timer(to activate an aggregation selection after initialize)
1880 BOND_AD_INFO(bond
).agg_select_timer
= (AD_AGGREGATOR_SELECTION_TIMER
* ad_ticks_per_sec
);
1881 BOND_AD_INFO(bond
).agg_select_mode
= AD_BANDWIDTH
;
1886 * bond_3ad_bind_slave - initialize a slave's port
1887 * @slave: slave struct to work on
1889 * Returns: 0 on success
1892 int bond_3ad_bind_slave(struct slave
*slave
)
1894 struct bonding
*bond
= bond_get_bond_by_slave(slave
);
1896 struct aggregator
*aggregator
;
1899 printk(KERN_ERR DRV_NAME
": %s: The slave %s is not attached to its bond\n",
1900 slave
->dev
->master
->name
, slave
->dev
->name
);
1904 //check that the slave has not been intialized yet.
1905 if (SLAVE_AD_INFO(slave
).port
.slave
!= slave
) {
1907 // port initialization
1908 port
= &(SLAVE_AD_INFO(slave
).port
);
1910 ad_initialize_port(port
, BOND_AD_INFO(bond
).lacp_fast
);
1912 port
->slave
= slave
;
1913 port
->actor_port_number
= SLAVE_AD_INFO(slave
).id
;
1914 // key is determined according to the link speed, duplex and user key(which is yet not supported)
1915 // ------------------------------------------------------------
1916 // Port key : | User key | Speed |Duplex|
1917 // ------------------------------------------------------------
1919 port
->actor_admin_port_key
= 0; // initialize this parameter
1920 port
->actor_admin_port_key
|= __get_duplex(port
);
1921 port
->actor_admin_port_key
|= (__get_link_speed(port
) << 1);
1922 port
->actor_oper_port_key
= port
->actor_admin_port_key
;
1923 // if the port is not full duplex, then the port should be not lacp Enabled
1924 if (!(port
->actor_oper_port_key
& AD_DUPLEX_KEY_BITS
)) {
1925 port
->sm_vars
&= ~AD_PORT_LACP_ENABLED
;
1927 // actor system is the bond's system
1928 port
->actor_system
= BOND_AD_INFO(bond
).system
.sys_mac_addr
;
1929 // tx timer(to verify that no more than MAX_TX_IN_SECOND lacpdu's are sent in one second)
1930 port
->sm_tx_timer_counter
= ad_ticks_per_sec
/AD_MAX_TX_IN_SECOND
;
1931 port
->aggregator
= NULL
;
1932 port
->next_port_in_aggregator
= NULL
;
1934 __disable_port(port
);
1935 __initialize_port_locks(port
);
1938 // aggregator initialization
1939 aggregator
= &(SLAVE_AD_INFO(slave
).aggregator
);
1941 ad_initialize_agg(aggregator
);
1943 aggregator
->aggregator_mac_address
= *((struct mac_addr
*)bond
->dev
->dev_addr
);
1944 aggregator
->aggregator_identifier
= (++aggregator_identifier
);
1945 aggregator
->slave
= slave
;
1946 aggregator
->is_active
= 0;
1947 aggregator
->num_of_ports
= 0;
1954 * bond_3ad_unbind_slave - deinitialize a slave's port
1955 * @slave: slave struct to work on
1957 * Search for the aggregator that is related to this port, remove the
1958 * aggregator and assign another aggregator for other port related to it
1959 * (if any), and remove the port.
1961 void bond_3ad_unbind_slave(struct slave
*slave
)
1963 struct port
*port
, *prev_port
, *temp_port
;
1964 struct aggregator
*aggregator
, *new_aggregator
, *temp_aggregator
;
1965 int select_new_active_agg
= 0;
1967 // find the aggregator related to this slave
1968 aggregator
= &(SLAVE_AD_INFO(slave
).aggregator
);
1970 // find the port related to this slave
1971 port
= &(SLAVE_AD_INFO(slave
).port
);
1973 // if slave is null, the whole port is not initialized
1975 printk(KERN_WARNING DRV_NAME
": Warning: %s: Trying to "
1976 "unbind an uninitialized port on %s\n",
1977 slave
->dev
->master
->name
, slave
->dev
->name
);
1981 dprintk("Unbinding Link Aggregation Group %d\n", aggregator
->aggregator_identifier
);
1983 /* Tell the partner that this port is not suitable for aggregation */
1984 port
->actor_oper_port_state
&= ~AD_STATE_AGGREGATION
;
1985 __update_lacpdu_from_port(port
);
1986 ad_lacpdu_send(port
);
1988 // check if this aggregator is occupied
1989 if (aggregator
->lag_ports
) {
1990 // check if there are other ports related to this aggregator except
1991 // the port related to this slave(thats ensure us that there is a
1992 // reason to search for new aggregator, and that we will find one
1993 if ((aggregator
->lag_ports
!= port
) || (aggregator
->lag_ports
->next_port_in_aggregator
)) {
1994 // find new aggregator for the related port(s)
1995 new_aggregator
= __get_first_agg(port
);
1996 for (; new_aggregator
; new_aggregator
= __get_next_agg(new_aggregator
)) {
1997 // if the new aggregator is empty, or it connected to to our port only
1998 if (!new_aggregator
->lag_ports
|| ((new_aggregator
->lag_ports
== port
) && !new_aggregator
->lag_ports
->next_port_in_aggregator
)) {
2002 // if new aggregator found, copy the aggregator's parameters
2003 // and connect the related lag_ports to the new aggregator
2004 if ((new_aggregator
) && ((!new_aggregator
->lag_ports
) || ((new_aggregator
->lag_ports
== port
) && !new_aggregator
->lag_ports
->next_port_in_aggregator
))) {
2005 dprintk("Some port(s) related to LAG %d - replaceing with LAG %d\n", aggregator
->aggregator_identifier
, new_aggregator
->aggregator_identifier
);
2007 if ((new_aggregator
->lag_ports
== port
) && new_aggregator
->is_active
) {
2008 printk(KERN_INFO DRV_NAME
": %s: Removing an active aggregator\n",
2009 aggregator
->slave
->dev
->master
->name
);
2010 // select new active aggregator
2011 select_new_active_agg
= 1;
2014 new_aggregator
->is_individual
= aggregator
->is_individual
;
2015 new_aggregator
->actor_admin_aggregator_key
= aggregator
->actor_admin_aggregator_key
;
2016 new_aggregator
->actor_oper_aggregator_key
= aggregator
->actor_oper_aggregator_key
;
2017 new_aggregator
->partner_system
= aggregator
->partner_system
;
2018 new_aggregator
->partner_system_priority
= aggregator
->partner_system_priority
;
2019 new_aggregator
->partner_oper_aggregator_key
= aggregator
->partner_oper_aggregator_key
;
2020 new_aggregator
->receive_state
= aggregator
->receive_state
;
2021 new_aggregator
->transmit_state
= aggregator
->transmit_state
;
2022 new_aggregator
->lag_ports
= aggregator
->lag_ports
;
2023 new_aggregator
->is_active
= aggregator
->is_active
;
2024 new_aggregator
->num_of_ports
= aggregator
->num_of_ports
;
2026 // update the information that is written on the ports about the aggregator
2027 for (temp_port
=aggregator
->lag_ports
; temp_port
; temp_port
=temp_port
->next_port_in_aggregator
) {
2028 temp_port
->aggregator
=new_aggregator
;
2029 temp_port
->actor_port_aggregator_identifier
= new_aggregator
->aggregator_identifier
;
2032 // clear the aggregator
2033 ad_clear_agg(aggregator
);
2035 if (select_new_active_agg
) {
2036 ad_agg_selection_logic(__get_first_agg(port
));
2039 printk(KERN_WARNING DRV_NAME
": %s: Warning: unbinding aggregator, "
2040 "and could not find a new aggregator for its ports\n",
2041 slave
->dev
->master
->name
);
2043 } else { // in case that the only port related to this aggregator is the one we want to remove
2044 select_new_active_agg
= aggregator
->is_active
;
2045 // clear the aggregator
2046 ad_clear_agg(aggregator
);
2047 if (select_new_active_agg
) {
2048 printk(KERN_INFO DRV_NAME
": %s: Removing an active aggregator\n",
2049 slave
->dev
->master
->name
);
2050 // select new active aggregator
2051 ad_agg_selection_logic(__get_first_agg(port
));
2056 dprintk("Unbinding port %d\n", port
->actor_port_number
);
2057 // find the aggregator that this port is connected to
2058 temp_aggregator
= __get_first_agg(port
);
2059 for (; temp_aggregator
; temp_aggregator
= __get_next_agg(temp_aggregator
)) {
2061 // search the port in the aggregator's related ports
2062 for (temp_port
=temp_aggregator
->lag_ports
; temp_port
; prev_port
=temp_port
, temp_port
=temp_port
->next_port_in_aggregator
) {
2063 if (temp_port
== port
) { // the aggregator found - detach the port from this aggregator
2065 prev_port
->next_port_in_aggregator
= temp_port
->next_port_in_aggregator
;
2067 temp_aggregator
->lag_ports
= temp_port
->next_port_in_aggregator
;
2069 temp_aggregator
->num_of_ports
--;
2070 if (temp_aggregator
->num_of_ports
==0) {
2071 select_new_active_agg
= temp_aggregator
->is_active
;
2072 // clear the aggregator
2073 ad_clear_agg(temp_aggregator
);
2074 if (select_new_active_agg
) {
2075 printk(KERN_INFO DRV_NAME
": %s: Removing an active aggregator\n",
2076 slave
->dev
->master
->name
);
2077 // select new active aggregator
2078 ad_agg_selection_logic(__get_first_agg(port
));
2089 * bond_3ad_state_machine_handler - handle state machines timeout
2090 * @bond: bonding struct to work on
2092 * The state machine handling concept in this module is to check every tick
2093 * which state machine should operate any function. The execution order is
2094 * round robin, so when we have an interaction between state machines, the
2095 * reply of one to each other might be delayed until next tick.
2097 * This function also complete the initialization when the agg_select_timer
2098 * times out, and it selects an aggregator for the ports that are yet not
2099 * related to any aggregator, and selects the active aggregator for a bond.
2101 void bond_3ad_state_machine_handler(struct bonding
*bond
)
2104 struct aggregator
*aggregator
;
2106 read_lock(&bond
->lock
);
2108 if (bond
->kill_timers
) {
2112 //check if there are any slaves
2113 if (bond
->slave_cnt
== 0) {
2117 // check if agg_select_timer timer after initialize is timed out
2118 if (BOND_AD_INFO(bond
).agg_select_timer
&& !(--BOND_AD_INFO(bond
).agg_select_timer
)) {
2119 // select the active aggregator for the bond
2120 if ((port
= __get_first_port(bond
))) {
2122 printk(KERN_WARNING DRV_NAME
": %s: Warning: bond's first port is "
2123 "uninitialized\n", bond
->dev
->name
);
2127 aggregator
= __get_first_agg(port
);
2128 ad_agg_selection_logic(aggregator
);
2132 // for each port run the state machines
2133 for (port
= __get_first_port(bond
); port
; port
= __get_next_port(port
)) {
2135 printk(KERN_WARNING DRV_NAME
": %s: Warning: Found an uninitialized "
2136 "port\n", bond
->dev
->name
);
2140 ad_rx_machine(NULL
, port
);
2141 ad_periodic_machine(port
);
2142 ad_port_selection_logic(port
);
2143 ad_mux_machine(port
);
2144 ad_tx_machine(port
);
2146 // turn off the BEGIN bit, since we already handled it
2147 if (port
->sm_vars
& AD_PORT_BEGIN
) {
2148 port
->sm_vars
&= ~AD_PORT_BEGIN
;
2153 mod_timer(&(BOND_AD_INFO(bond
).ad_timer
), jiffies
+ ad_delta_in_ticks
);
2155 read_unlock(&bond
->lock
);
2159 * bond_3ad_rx_indication - handle a received frame
2160 * @lacpdu: received lacpdu
2161 * @slave: slave struct to work on
2162 * @length: length of the data received
2164 * It is assumed that frames that were sent on this NIC don't returned as new
2165 * received frames (loopback). Since only the payload is given to this
2166 * function, it check for loopback.
2168 static void bond_3ad_rx_indication(struct lacpdu
*lacpdu
, struct slave
*slave
, u16 length
)
2172 if (length
>= sizeof(struct lacpdu
)) {
2174 port
= &(SLAVE_AD_INFO(slave
).port
);
2177 printk(KERN_WARNING DRV_NAME
": %s: Warning: port of slave %s is "
2178 "uninitialized\n", slave
->dev
->name
, slave
->dev
->master
->name
);
2182 switch (lacpdu
->subtype
) {
2183 case AD_TYPE_LACPDU
:
2184 dprintk("Received LACPDU on port %d\n", port
->actor_port_number
);
2185 ad_rx_machine(lacpdu
, port
);
2188 case AD_TYPE_MARKER
:
2189 // No need to convert fields to Little Endian since we don't use the marker's fields.
2191 switch (((struct marker
*)lacpdu
)->tlv_type
) {
2192 case AD_MARKER_INFORMATION_SUBTYPE
:
2193 dprintk("Received Marker Information on port %d\n", port
->actor_port_number
);
2194 ad_marker_info_received((struct marker
*)lacpdu
, port
);
2197 case AD_MARKER_RESPONSE_SUBTYPE
:
2198 dprintk("Received Marker Response on port %d\n", port
->actor_port_number
);
2199 ad_marker_response_received((struct marker
*)lacpdu
, port
);
2203 dprintk("Received an unknown Marker subtype on slot %d\n", port
->actor_port_number
);
2210 * bond_3ad_adapter_speed_changed - handle a slave's speed change indication
2211 * @slave: slave struct to work on
2213 * Handle reselection of aggregator (if needed) for this port.
2215 void bond_3ad_adapter_speed_changed(struct slave
*slave
)
2219 port
= &(SLAVE_AD_INFO(slave
).port
);
2221 // if slave is null, the whole port is not initialized
2223 printk(KERN_WARNING DRV_NAME
": Warning: %s: speed "
2224 "changed for uninitialized port on %s\n",
2225 slave
->dev
->master
->name
, slave
->dev
->name
);
2229 port
->actor_admin_port_key
&= ~AD_SPEED_KEY_BITS
;
2230 port
->actor_oper_port_key
=port
->actor_admin_port_key
|= (__get_link_speed(port
) << 1);
2231 dprintk("Port %d changed speed\n", port
->actor_port_number
);
2232 // there is no need to reselect a new aggregator, just signal the
2233 // state machines to reinitialize
2234 port
->sm_vars
|= AD_PORT_BEGIN
;
2238 * bond_3ad_adapter_duplex_changed - handle a slave's duplex change indication
2239 * @slave: slave struct to work on
2241 * Handle reselection of aggregator (if needed) for this port.
2243 void bond_3ad_adapter_duplex_changed(struct slave
*slave
)
2247 port
=&(SLAVE_AD_INFO(slave
).port
);
2249 // if slave is null, the whole port is not initialized
2251 printk(KERN_WARNING DRV_NAME
": %s: Warning: duplex changed "
2252 "for uninitialized port on %s\n",
2253 slave
->dev
->master
->name
, slave
->dev
->name
);
2257 port
->actor_admin_port_key
&= ~AD_DUPLEX_KEY_BITS
;
2258 port
->actor_oper_port_key
=port
->actor_admin_port_key
|= __get_duplex(port
);
2259 dprintk("Port %d changed duplex\n", port
->actor_port_number
);
2260 // there is no need to reselect a new aggregator, just signal the
2261 // state machines to reinitialize
2262 port
->sm_vars
|= AD_PORT_BEGIN
;
2266 * bond_3ad_handle_link_change - handle a slave's link status change indication
2267 * @slave: slave struct to work on
2268 * @status: whether the link is now up or down
2270 * Handle reselection of aggregator (if needed) for this port.
2272 void bond_3ad_handle_link_change(struct slave
*slave
, char link
)
2276 port
= &(SLAVE_AD_INFO(slave
).port
);
2278 // if slave is null, the whole port is not initialized
2280 printk(KERN_WARNING DRV_NAME
": Warning: %s: link status changed for "
2281 "uninitialized port on %s\n",
2282 slave
->dev
->master
->name
, slave
->dev
->name
);
2286 // on link down we are zeroing duplex and speed since some of the adaptors(ce1000.lan) report full duplex/speed instead of N/A(duplex) / 0(speed)
2287 // on link up we are forcing recheck on the duplex and speed since some of he adaptors(ce1000.lan) report
2288 if (link
== BOND_LINK_UP
) {
2289 port
->is_enabled
= 1;
2290 port
->actor_admin_port_key
&= ~AD_DUPLEX_KEY_BITS
;
2291 port
->actor_oper_port_key
=port
->actor_admin_port_key
|= __get_duplex(port
);
2292 port
->actor_admin_port_key
&= ~AD_SPEED_KEY_BITS
;
2293 port
->actor_oper_port_key
=port
->actor_admin_port_key
|= (__get_link_speed(port
) << 1);
2295 /* link has failed */
2296 port
->is_enabled
= 0;
2297 port
->actor_admin_port_key
&= ~AD_DUPLEX_KEY_BITS
;
2298 port
->actor_oper_port_key
= (port
->actor_admin_port_key
&= ~AD_SPEED_KEY_BITS
);
2300 //BOND_PRINT_DBG(("Port %d changed link status to %s", port->actor_port_number, ((link == BOND_LINK_UP)?"UP":"DOWN")));
2301 // there is no need to reselect a new aggregator, just signal the
2302 // state machines to reinitialize
2303 port
->sm_vars
|= AD_PORT_BEGIN
;
2307 * set link state for bonding master: if we have an active
2308 * aggregator, we're up, if not, we're down. Presumes that we cannot
2309 * have an active aggregator if there are no slaves with link up.
2311 * This behavior complies with IEEE 802.3 section 43.3.9.
2313 * Called by bond_set_carrier(). Return zero if carrier state does not
2314 * change, nonzero if it does.
2316 int bond_3ad_set_carrier(struct bonding
*bond
)
2318 if (__get_active_agg(&(SLAVE_AD_INFO(bond
->first_slave
).aggregator
))) {
2319 if (!netif_carrier_ok(bond
->dev
)) {
2320 netif_carrier_on(bond
->dev
);
2326 if (netif_carrier_ok(bond
->dev
)) {
2327 netif_carrier_off(bond
->dev
);
2334 * bond_3ad_get_active_agg_info - get information of the active aggregator
2335 * @bond: bonding struct to work on
2336 * @ad_info: ad_info struct to fill with the bond's info
2338 * Returns: 0 on success
2341 int bond_3ad_get_active_agg_info(struct bonding
*bond
, struct ad_info
*ad_info
)
2343 struct aggregator
*aggregator
= NULL
;
2346 for (port
= __get_first_port(bond
); port
; port
= __get_next_port(port
)) {
2347 if (port
->aggregator
&& port
->aggregator
->is_active
) {
2348 aggregator
= port
->aggregator
;
2354 ad_info
->aggregator_id
= aggregator
->aggregator_identifier
;
2355 ad_info
->ports
= aggregator
->num_of_ports
;
2356 ad_info
->actor_key
= aggregator
->actor_oper_aggregator_key
;
2357 ad_info
->partner_key
= aggregator
->partner_oper_aggregator_key
;
2358 memcpy(ad_info
->partner_system
, aggregator
->partner_system
.mac_addr_value
, ETH_ALEN
);
2365 int bond_3ad_xmit_xor(struct sk_buff
*skb
, struct net_device
*dev
)
2367 struct slave
*slave
, *start_at
;
2368 struct bonding
*bond
= dev
->priv
;
2373 struct ad_info ad_info
;
2376 /* make sure that the slaves list will
2377 * not change during tx
2379 read_lock(&bond
->lock
);
2381 if (!BOND_IS_OK(bond
)) {
2385 if (bond_3ad_get_active_agg_info(bond
, &ad_info
)) {
2386 printk(KERN_DEBUG DRV_NAME
": %s: Error: "
2387 "bond_3ad_get_active_agg_info failed\n", dev
->name
);
2391 slaves_in_agg
= ad_info
.ports
;
2392 agg_id
= ad_info
.aggregator_id
;
2394 if (slaves_in_agg
== 0) {
2395 /*the aggregator is empty*/
2396 printk(KERN_DEBUG DRV_NAME
": %s: Error: active "
2397 "aggregator is empty\n",
2402 slave_agg_no
= bond
->xmit_hash_policy(skb
, dev
, slaves_in_agg
);
2404 bond_for_each_slave(bond
, slave
, i
) {
2405 struct aggregator
*agg
= SLAVE_AD_INFO(slave
).port
.aggregator
;
2407 if (agg
&& (agg
->aggregator_identifier
== agg_id
)) {
2409 if (slave_agg_no
< 0) {
2415 if (slave_agg_no
>= 0) {
2416 printk(KERN_ERR DRV_NAME
": %s: Error: Couldn't find a slave to tx on "
2417 "for aggregator ID %d\n", dev
->name
, agg_id
);
2423 bond_for_each_slave_from(bond
, slave
, i
, start_at
) {
2424 int slave_agg_id
= 0;
2425 struct aggregator
*agg
= SLAVE_AD_INFO(slave
).port
.aggregator
;
2428 slave_agg_id
= agg
->aggregator_identifier
;
2431 if (SLAVE_IS_OK(slave
) && agg
&& (slave_agg_id
== agg_id
)) {
2432 res
= bond_dev_queue_xmit(bond
, skb
, slave
->dev
);
2439 /* no suitable interface, frame not sent */
2442 read_unlock(&bond
->lock
);
2446 int bond_3ad_lacpdu_recv(struct sk_buff
*skb
, struct net_device
*dev
, struct packet_type
* ptype
, struct net_device
*orig_dev
)
2448 struct bonding
*bond
= dev
->priv
;
2449 struct slave
*slave
= NULL
;
2450 int ret
= NET_RX_DROP
;
2452 if (dev
->nd_net
!= &init_net
)
2455 if (!(dev
->flags
& IFF_MASTER
))
2458 read_lock(&bond
->lock
);
2459 slave
= bond_get_slave_by_dev((struct bonding
*)dev
->priv
, orig_dev
);
2463 bond_3ad_rx_indication((struct lacpdu
*) skb
->data
, slave
, skb
->len
);
2465 ret
= NET_RX_SUCCESS
;
2468 read_unlock(&bond
->lock
);