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.
24 * 2003/05/01 - Tsippy Mendelson <tsippy.mendelson at intel dot com> and
25 * Amir Noam <amir.noam at intel dot com>
26 * - Added support for lacp_rate module param.
28 * 2003/05/01 - Shmulik Hen <shmulik.hen at intel dot com>
29 * - Based on discussion on mailing list, changed locking scheme
30 * to use lock/unlock or lock_bh/unlock_bh appropriately instead
31 * of lock_irqsave/unlock_irqrestore. The new scheme helps exposing
32 * hidden bugs and solves system hangs that occurred due to the fact
33 * that holding lock_irqsave doesn't prevent softirqs from running.
34 * This also increases total throughput since interrupts are not
35 * blocked on each transmitted packets or monitor timeout.
37 * 2003/05/01 - Shmulik Hen <shmulik.hen at intel dot com>
38 * - Renamed bond_3ad_link_status_changed() to
39 * bond_3ad_handle_link_change() for compatibility with TLB.
41 * 2003/05/20 - Amir Noam <amir.noam at intel dot com>
42 * - Fix long fail over time when releasing last slave of an active
43 * aggregator - send LACPDU on unbind of slave to tell partner this
44 * port is no longer aggregatable.
46 * 2003/06/25 - Tsippy Mendelson <tsippy.mendelson at intel dot com>
47 * - Send LACPDU as highest priority packet to further fix the above
48 * problem on very high Tx traffic load where packets may get dropped
51 * 2003/12/01 - Shmulik Hen <shmulik.hen at intel dot com>
52 * - Code cleanup and style changes
55 //#define BONDING_DEBUG 1
57 #include <linux/skbuff.h>
58 #include <linux/if_ether.h>
59 #include <linux/netdevice.h>
60 #include <linux/spinlock.h>
61 #include <linux/ethtool.h>
62 #include <linux/if_bonding.h>
63 #include <linux/pkt_sched.h>
67 // General definitions
68 #define AD_SHORT_TIMEOUT 1
69 #define AD_LONG_TIMEOUT 0
70 #define AD_STANDBY 0x2
71 #define AD_MAX_TX_IN_SECOND 3
72 #define AD_COLLECTOR_MAX_DELAY 0
74 // Timer definitions(43.4.4 in the 802.3ad standard)
75 #define AD_FAST_PERIODIC_TIME 1
76 #define AD_SLOW_PERIODIC_TIME 30
77 #define AD_SHORT_TIMEOUT_TIME (3*AD_FAST_PERIODIC_TIME)
78 #define AD_LONG_TIMEOUT_TIME (3*AD_SLOW_PERIODIC_TIME)
79 #define AD_CHURN_DETECTION_TIME 60
80 #define AD_AGGREGATE_WAIT_TIME 2
82 // Port state definitions(43.4.2.2 in the 802.3ad standard)
83 #define AD_STATE_LACP_ACTIVITY 0x1
84 #define AD_STATE_LACP_TIMEOUT 0x2
85 #define AD_STATE_AGGREGATION 0x4
86 #define AD_STATE_SYNCHRONIZATION 0x8
87 #define AD_STATE_COLLECTING 0x10
88 #define AD_STATE_DISTRIBUTING 0x20
89 #define AD_STATE_DEFAULTED 0x40
90 #define AD_STATE_EXPIRED 0x80
92 // Port Variables definitions used by the State Machines(43.4.7 in the 802.3ad standard)
93 #define AD_PORT_BEGIN 0x1
94 #define AD_PORT_LACP_ENABLED 0x2
95 #define AD_PORT_ACTOR_CHURN 0x4
96 #define AD_PORT_PARTNER_CHURN 0x8
97 #define AD_PORT_READY 0x10
98 #define AD_PORT_READY_N 0x20
99 #define AD_PORT_MATCHED 0x40
100 #define AD_PORT_STANDBY 0x80
101 #define AD_PORT_SELECTED 0x100
102 #define AD_PORT_MOVED 0x200
104 // Port Key definitions
105 // key is determined according to the link speed, duplex and
106 // user key(which is yet not supported)
107 // ------------------------------------------------------------
108 // Port key : | User key | Speed |Duplex|
109 // ------------------------------------------------------------
111 #define AD_DUPLEX_KEY_BITS 0x1
112 #define AD_SPEED_KEY_BITS 0x3E
113 #define AD_USER_KEY_BITS 0xFFC0
116 #define AD_LINK_SPEED_BITMASK_1MBPS 0x1
117 #define AD_LINK_SPEED_BITMASK_10MBPS 0x2
118 #define AD_LINK_SPEED_BITMASK_100MBPS 0x4
119 #define AD_LINK_SPEED_BITMASK_1000MBPS 0x8
122 // compare MAC addresses
123 #define MAC_ADDRESS_COMPARE(A, B) memcmp(A, B, ETH_ALEN)
125 static struct mac_addr null_mac_addr
= {{0, 0, 0, 0, 0, 0}};
126 static u16 ad_ticks_per_sec
;
127 static const int ad_delta_in_ticks
= (AD_TIMER_INTERVAL
* HZ
) / 1000;
129 // ================= 3AD api to bonding and kernel code ==================
130 static u16
__get_link_speed(struct port
*port
);
131 static u8
__get_duplex(struct port
*port
);
132 static inline void __initialize_port_locks(struct port
*port
);
134 static void __ntohs_lacpdu(struct lacpdu
*lacpdu
);
135 static u16
__ad_timer_to_ticks(u16 timer_type
, u16 Par
);
138 // ================= ad code helper functions ==================
139 //needed by ad_rx_machine(...)
140 static void __record_pdu(struct lacpdu
*lacpdu
, struct port
*port
);
141 static void __record_default(struct port
*port
);
142 static void __update_selected(struct lacpdu
*lacpdu
, struct port
*port
);
143 static void __update_default_selected(struct port
*port
);
144 static void __choose_matched(struct lacpdu
*lacpdu
, struct port
*port
);
145 static void __update_ntt(struct lacpdu
*lacpdu
, struct port
*port
);
147 //needed for ad_mux_machine(..)
148 static void __attach_bond_to_agg(struct port
*port
);
149 static void __detach_bond_from_agg(struct port
*port
);
150 static int __agg_ports_are_ready(struct aggregator
*aggregator
);
151 static void __set_agg_ports_ready(struct aggregator
*aggregator
, int val
);
153 //needed for ad_agg_selection_logic(...)
154 static u32
__get_agg_bandwidth(struct aggregator
*aggregator
);
155 static struct aggregator
*__get_active_agg(struct aggregator
*aggregator
);
158 // ================= main 802.3ad protocol functions ==================
159 static int ad_lacpdu_send(struct port
*port
);
160 static int ad_marker_send(struct port
*port
, struct marker
*marker
);
161 static void ad_mux_machine(struct port
*port
);
162 static void ad_rx_machine(struct lacpdu
*lacpdu
, struct port
*port
);
163 static void ad_tx_machine(struct port
*port
);
164 static void ad_periodic_machine(struct port
*port
);
165 static void ad_port_selection_logic(struct port
*port
);
166 static void ad_agg_selection_logic(struct aggregator
*aggregator
);
167 static void ad_clear_agg(struct aggregator
*aggregator
);
168 static void ad_initialize_agg(struct aggregator
*aggregator
);
169 static void ad_initialize_port(struct port
*port
, int lacp_fast
);
170 static void ad_initialize_lacpdu(struct lacpdu
*Lacpdu
);
171 static void ad_enable_collecting_distributing(struct port
*port
);
172 static void ad_disable_collecting_distributing(struct port
*port
);
173 static void ad_marker_info_received(struct marker
*marker_info
, struct port
*port
);
174 static void ad_marker_response_received(struct marker
*marker
, struct port
*port
);
177 /////////////////////////////////////////////////////////////////////////////////
178 // ================= api to bonding and kernel code ==================
179 /////////////////////////////////////////////////////////////////////////////////
182 * __get_bond_by_port - get the port's bonding struct
183 * @port: the port we're looking at
185 * Return @port's bonding struct, or %NULL if it can't be found.
187 static inline struct bonding
*__get_bond_by_port(struct port
*port
)
189 if (port
->slave
== NULL
) {
193 return bond_get_bond_by_slave(port
->slave
);
197 * __get_first_port - get the first port in the bond
198 * @bond: the bond we're looking at
200 * Return the port of the first slave in @bond, or %NULL if it can't be found.
202 static inline struct port
*__get_first_port(struct bonding
*bond
)
204 if (bond
->slave_cnt
== 0) {
208 return &(SLAVE_AD_INFO(bond
->first_slave
).port
);
212 * __get_next_port - get the next port in the bond
213 * @port: the port we're looking at
215 * Return the port of the slave that is next in line of @port's slave in the
216 * bond, or %NULL if it can't be found.
218 static inline struct port
*__get_next_port(struct port
*port
)
220 struct bonding
*bond
= __get_bond_by_port(port
);
221 struct slave
*slave
= port
->slave
;
223 // If there's no bond for this port, or this is the last slave
224 if ((bond
== NULL
) || (slave
->next
== bond
->first_slave
)) {
228 return &(SLAVE_AD_INFO(slave
->next
).port
);
232 * __get_first_agg - get the first aggregator in the bond
233 * @bond: the bond we're looking at
235 * Return the aggregator of the first slave in @bond, or %NULL if it can't be
238 static inline struct aggregator
*__get_first_agg(struct port
*port
)
240 struct bonding
*bond
= __get_bond_by_port(port
);
242 // If there's no bond for this port, or bond has no slaves
243 if ((bond
== NULL
) || (bond
->slave_cnt
== 0)) {
247 return &(SLAVE_AD_INFO(bond
->first_slave
).aggregator
);
251 * __get_next_agg - get the next aggregator in the bond
252 * @aggregator: the aggregator we're looking at
254 * Return the aggregator of the slave that is next in line of @aggregator's
255 * slave in the bond, or %NULL if it can't be found.
257 static inline struct aggregator
*__get_next_agg(struct aggregator
*aggregator
)
259 struct slave
*slave
= aggregator
->slave
;
260 struct bonding
*bond
= bond_get_bond_by_slave(slave
);
262 // If there's no bond for this aggregator, or this is the last slave
263 if ((bond
== NULL
) || (slave
->next
== bond
->first_slave
)) {
267 return &(SLAVE_AD_INFO(slave
->next
).aggregator
);
271 * __disable_port - disable the port's slave
272 * @port: the port we're looking at
275 static inline void __disable_port(struct port
*port
)
277 bond_set_slave_inactive_flags(port
->slave
);
281 * __enable_port - enable the port's slave, if it's up
282 * @port: the port we're looking at
285 static inline void __enable_port(struct port
*port
)
287 struct slave
*slave
= port
->slave
;
289 if ((slave
->link
== BOND_LINK_UP
) && IS_UP(slave
->dev
)) {
290 bond_set_slave_active_flags(slave
);
295 * __port_is_enabled - check if the port's slave is in active state
296 * @port: the port we're looking at
299 static inline int __port_is_enabled(struct port
*port
)
301 return(port
->slave
->state
== BOND_STATE_ACTIVE
);
305 * __get_agg_selection_mode - get the aggregator selection mode
306 * @port: the port we're looking at
308 * Get the aggregator selection mode. Can be %BANDWIDTH or %COUNT.
310 static inline u32
__get_agg_selection_mode(struct port
*port
)
312 struct bonding
*bond
= __get_bond_by_port(port
);
318 return BOND_AD_INFO(bond
).agg_select_mode
;
322 * __check_agg_selection_timer - check if the selection timer has expired
323 * @port: the port we're looking at
326 static inline int __check_agg_selection_timer(struct port
*port
)
328 struct bonding
*bond
= __get_bond_by_port(port
);
334 return BOND_AD_INFO(bond
).agg_select_timer
? 1 : 0;
338 * __get_rx_machine_lock - lock the port's RX machine
339 * @port: the port we're looking at
342 static inline void __get_rx_machine_lock(struct port
*port
)
344 spin_lock(&(SLAVE_AD_INFO(port
->slave
).rx_machine_lock
));
348 * __release_rx_machine_lock - unlock the port's RX machine
349 * @port: the port we're looking at
352 static inline void __release_rx_machine_lock(struct port
*port
)
354 spin_unlock(&(SLAVE_AD_INFO(port
->slave
).rx_machine_lock
));
358 * __get_link_speed - get a port's speed
359 * @port: the port we're looking at
361 * Return @port's speed in 802.3ad bitmask format. i.e. one of:
363 * %AD_LINK_SPEED_BITMASK_10MBPS,
364 * %AD_LINK_SPEED_BITMASK_100MBPS,
365 * %AD_LINK_SPEED_BITMASK_1000MBPS
367 static u16
__get_link_speed(struct port
*port
)
369 struct slave
*slave
= port
->slave
;
372 /* this if covers only a special case: when the configuration starts with
373 * link down, it sets the speed to 0.
374 * This is done in spite of the fact that the e100 driver reports 0 to be
375 * compatible with MVT in the future.*/
376 if (slave
->link
!= BOND_LINK_UP
) {
379 switch (slave
->speed
) {
381 speed
= AD_LINK_SPEED_BITMASK_10MBPS
;
385 speed
= AD_LINK_SPEED_BITMASK_100MBPS
;
389 speed
= AD_LINK_SPEED_BITMASK_1000MBPS
;
393 speed
= 0; // unknown speed value from ethtool. shouldn't happen
398 dprintk("Port %d Received link speed %d update from adapter\n", port
->actor_port_number
, speed
);
403 * __get_duplex - get a port's duplex
404 * @port: the port we're looking at
406 * Return @port's duplex in 802.3ad bitmask format. i.e.:
407 * 0x01 if in full duplex
410 static u8
__get_duplex(struct port
*port
)
412 struct slave
*slave
= port
->slave
;
416 // handling a special case: when the configuration starts with
417 // link down, it sets the duplex to 0.
418 if (slave
->link
!= BOND_LINK_UP
) {
421 switch (slave
->duplex
) {
424 dprintk("Port %d Received status full duplex update from adapter\n", port
->actor_port_number
);
429 dprintk("Port %d Received status NOT full duplex update from adapter\n", port
->actor_port_number
);
437 * __initialize_port_locks - initialize a port's RX machine spinlock
438 * @port: the port we're looking at
441 static inline void __initialize_port_locks(struct port
*port
)
443 // make sure it isn't called twice
444 spin_lock_init(&(SLAVE_AD_INFO(port
->slave
).rx_machine_lock
));
449 * __ntohs_lacpdu - convert the contents of a LACPDU to host byte order
450 * @lacpdu: the speicifed lacpdu
452 * For each multi-byte field in the lacpdu, convert its content
454 static void __ntohs_lacpdu(struct lacpdu
*lacpdu
)
457 lacpdu
->actor_system_priority
= ntohs(lacpdu
->actor_system_priority
);
458 lacpdu
->actor_key
= ntohs(lacpdu
->actor_key
);
459 lacpdu
->actor_port_priority
= ntohs(lacpdu
->actor_port_priority
);
460 lacpdu
->actor_port
= ntohs(lacpdu
->actor_port
);
461 lacpdu
->partner_system_priority
= ntohs(lacpdu
->partner_system_priority
);
462 lacpdu
->partner_key
= ntohs(lacpdu
->partner_key
);
463 lacpdu
->partner_port_priority
= ntohs(lacpdu
->partner_port_priority
);
464 lacpdu
->partner_port
= ntohs(lacpdu
->partner_port
);
465 lacpdu
->collector_max_delay
= ntohs(lacpdu
->collector_max_delay
);
470 * __ad_timer_to_ticks - convert a given timer type to AD module ticks
471 * @timer_type: which timer to operate
472 * @par: timer parameter. see below
474 * If @timer_type is %current_while_timer, @par indicates long/short timer.
475 * If @timer_type is %periodic_timer, @par is one of %FAST_PERIODIC_TIME,
476 * %SLOW_PERIODIC_TIME.
478 static u16
__ad_timer_to_ticks(u16 timer_type
, u16 par
)
480 u16 retval
=0; //to silence the compiler
482 switch (timer_type
) {
483 case AD_CURRENT_WHILE_TIMER
: // for rx machine usage
484 if (par
) { // for short or long timeout
485 retval
= (AD_SHORT_TIMEOUT_TIME
*ad_ticks_per_sec
); // short timeout
487 retval
= (AD_LONG_TIMEOUT_TIME
*ad_ticks_per_sec
); // long timeout
490 case AD_ACTOR_CHURN_TIMER
: // for local churn machine
491 retval
= (AD_CHURN_DETECTION_TIME
*ad_ticks_per_sec
);
493 case AD_PERIODIC_TIMER
: // for periodic machine
494 retval
= (par
*ad_ticks_per_sec
); // long timeout
496 case AD_PARTNER_CHURN_TIMER
: // for remote churn machine
497 retval
= (AD_CHURN_DETECTION_TIME
*ad_ticks_per_sec
);
499 case AD_WAIT_WHILE_TIMER
: // for selection machine
500 retval
= (AD_AGGREGATE_WAIT_TIME
*ad_ticks_per_sec
);
507 /////////////////////////////////////////////////////////////////////////////////
508 // ================= ad_rx_machine helper functions ==================
509 /////////////////////////////////////////////////////////////////////////////////
512 * __record_pdu - record parameters from a received lacpdu
513 * @lacpdu: the lacpdu we've received
514 * @port: the port we're looking at
516 * Record the parameter values for the Actor carried in a received lacpdu as
517 * the current partner operational parameter values and sets
518 * actor_oper_port_state.defaulted to FALSE.
520 static void __record_pdu(struct lacpdu
*lacpdu
, struct port
*port
)
522 // validate lacpdu and port
523 if (lacpdu
&& port
) {
524 // record the new parameter values for the partner operational
525 port
->partner_oper_port_number
= lacpdu
->actor_port
;
526 port
->partner_oper_port_priority
= lacpdu
->actor_port_priority
;
527 port
->partner_oper_system
= lacpdu
->actor_system
;
528 port
->partner_oper_system_priority
= lacpdu
->actor_system_priority
;
529 port
->partner_oper_key
= lacpdu
->actor_key
;
530 // zero partener's lase states
531 port
->partner_oper_port_state
= 0;
532 port
->partner_oper_port_state
|= (lacpdu
->actor_state
& AD_STATE_LACP_ACTIVITY
);
533 port
->partner_oper_port_state
|= (lacpdu
->actor_state
& AD_STATE_LACP_TIMEOUT
);
534 port
->partner_oper_port_state
|= (lacpdu
->actor_state
& AD_STATE_AGGREGATION
);
535 port
->partner_oper_port_state
|= (lacpdu
->actor_state
& AD_STATE_SYNCHRONIZATION
);
536 port
->partner_oper_port_state
|= (lacpdu
->actor_state
& AD_STATE_COLLECTING
);
537 port
->partner_oper_port_state
|= (lacpdu
->actor_state
& AD_STATE_DISTRIBUTING
);
538 port
->partner_oper_port_state
|= (lacpdu
->actor_state
& AD_STATE_DEFAULTED
);
539 port
->partner_oper_port_state
|= (lacpdu
->actor_state
& AD_STATE_EXPIRED
);
541 // set actor_oper_port_state.defaulted to FALSE
542 port
->actor_oper_port_state
&= ~AD_STATE_DEFAULTED
;
544 // set the partner sync. to on if the partner is sync. and the port is matched
545 if ((port
->sm_vars
& AD_PORT_MATCHED
) && (lacpdu
->actor_state
& AD_STATE_SYNCHRONIZATION
)) {
546 port
->partner_oper_port_state
|= AD_STATE_SYNCHRONIZATION
;
548 port
->partner_oper_port_state
&= ~AD_STATE_SYNCHRONIZATION
;
554 * __record_default - record default parameters
555 * @port: the port we're looking at
557 * This function records the default parameter values for the partner carried
558 * in the Partner Admin parameters as the current partner operational parameter
559 * values and sets actor_oper_port_state.defaulted to TRUE.
561 static void __record_default(struct port
*port
)
565 // record the partner admin parameters
566 port
->partner_oper_port_number
= port
->partner_admin_port_number
;
567 port
->partner_oper_port_priority
= port
->partner_admin_port_priority
;
568 port
->partner_oper_system
= port
->partner_admin_system
;
569 port
->partner_oper_system_priority
= port
->partner_admin_system_priority
;
570 port
->partner_oper_key
= port
->partner_admin_key
;
571 port
->partner_oper_port_state
= port
->partner_admin_port_state
;
573 // set actor_oper_port_state.defaulted to true
574 port
->actor_oper_port_state
|= AD_STATE_DEFAULTED
;
579 * __update_selected - update a port's Selected variable from a received lacpdu
580 * @lacpdu: the lacpdu we've received
581 * @port: the port we're looking at
583 * Update the value of the selected variable, using parameter values from a
584 * newly received lacpdu. The parameter values for the Actor carried in the
585 * received PDU are compared with the corresponding operational parameter
586 * values for the ports partner. If one or more of the comparisons shows that
587 * the value(s) received in the PDU differ from the current operational values,
588 * then selected is set to FALSE and actor_oper_port_state.synchronization is
589 * set to out_of_sync. Otherwise, selected remains unchanged.
591 static void __update_selected(struct lacpdu
*lacpdu
, struct port
*port
)
593 // validate lacpdu and port
594 if (lacpdu
&& port
) {
595 // check if any parameter is different
596 if ((lacpdu
->actor_port
!= port
->partner_oper_port_number
) ||
597 (lacpdu
->actor_port_priority
!= port
->partner_oper_port_priority
) ||
598 MAC_ADDRESS_COMPARE(&(lacpdu
->actor_system
), &(port
->partner_oper_system
)) ||
599 (lacpdu
->actor_system_priority
!= port
->partner_oper_system_priority
) ||
600 (lacpdu
->actor_key
!= port
->partner_oper_key
) ||
601 ((lacpdu
->actor_state
& AD_STATE_AGGREGATION
) != (port
->partner_oper_port_state
& AD_STATE_AGGREGATION
))
603 // update the state machine Selected variable
604 port
->sm_vars
&= ~AD_PORT_SELECTED
;
610 * __update_default_selected - update a port's Selected variable from Partner
611 * @port: the port we're looking at
613 * This function updates the value of the selected variable, using the partner
614 * administrative parameter values. The administrative values are compared with
615 * the corresponding operational parameter values for the partner. If one or
616 * more of the comparisons shows that the administrative value(s) differ from
617 * the current operational values, then Selected is set to FALSE and
618 * actor_oper_port_state.synchronization is set to OUT_OF_SYNC. Otherwise,
619 * Selected remains unchanged.
621 static void __update_default_selected(struct port
*port
)
625 // check if any parameter is different
626 if ((port
->partner_admin_port_number
!= port
->partner_oper_port_number
) ||
627 (port
->partner_admin_port_priority
!= port
->partner_oper_port_priority
) ||
628 MAC_ADDRESS_COMPARE(&(port
->partner_admin_system
), &(port
->partner_oper_system
)) ||
629 (port
->partner_admin_system_priority
!= port
->partner_oper_system_priority
) ||
630 (port
->partner_admin_key
!= port
->partner_oper_key
) ||
631 ((port
->partner_admin_port_state
& AD_STATE_AGGREGATION
) != (port
->partner_oper_port_state
& AD_STATE_AGGREGATION
))
633 // update the state machine Selected variable
634 port
->sm_vars
&= ~AD_PORT_SELECTED
;
640 * __choose_matched - update a port's matched variable from a received lacpdu
641 * @lacpdu: the lacpdu we've received
642 * @port: the port we're looking at
644 * Update the value of the matched variable, using parameter values from a
645 * newly received lacpdu. Parameter values for the partner carried in the
646 * received PDU are compared with the corresponding operational parameter
647 * values for the actor. Matched is set to TRUE if all of these parameters
648 * match and the PDU parameter partner_state.aggregation has the same value as
649 * actor_oper_port_state.aggregation and lacp will actively maintain the link
650 * in the aggregation. Matched is also set to TRUE if the value of
651 * actor_state.aggregation in the received PDU is set to FALSE, i.e., indicates
652 * an individual link and lacp will actively maintain the link. Otherwise,
653 * matched is set to FALSE. LACP is considered to be actively maintaining the
654 * link if either the PDU's actor_state.lacp_activity variable is TRUE or both
655 * the actor's actor_oper_port_state.lacp_activity and the PDU's
656 * partner_state.lacp_activity variables are TRUE.
658 static void __choose_matched(struct lacpdu
*lacpdu
, struct port
*port
)
660 // validate lacpdu and port
661 if (lacpdu
&& port
) {
662 // check if all parameters are alike
663 if (((lacpdu
->partner_port
== port
->actor_port_number
) &&
664 (lacpdu
->partner_port_priority
== port
->actor_port_priority
) &&
665 !MAC_ADDRESS_COMPARE(&(lacpdu
->partner_system
), &(port
->actor_system
)) &&
666 (lacpdu
->partner_system_priority
== port
->actor_system_priority
) &&
667 (lacpdu
->partner_key
== port
->actor_oper_port_key
) &&
668 ((lacpdu
->partner_state
& AD_STATE_AGGREGATION
) == (port
->actor_oper_port_state
& AD_STATE_AGGREGATION
))) ||
669 // or this is individual link(aggregation == FALSE)
670 ((lacpdu
->actor_state
& AD_STATE_AGGREGATION
) == 0)
672 // update the state machine Matched variable
673 port
->sm_vars
|= AD_PORT_MATCHED
;
675 port
->sm_vars
&= ~AD_PORT_MATCHED
;
681 * __update_ntt - update a port's ntt variable from a received lacpdu
682 * @lacpdu: the lacpdu we've received
683 * @port: the port we're looking at
685 * Updates the value of the ntt variable, using parameter values from a newly
686 * received lacpdu. The parameter values for the partner carried in the
687 * received PDU are compared with the corresponding operational parameter
688 * values for the Actor. If one or more of the comparisons shows that the
689 * value(s) received in the PDU differ from the current operational values,
690 * then ntt is set to TRUE. Otherwise, ntt remains unchanged.
692 static void __update_ntt(struct lacpdu
*lacpdu
, struct port
*port
)
694 // validate lacpdu and port
695 if (lacpdu
&& port
) {
696 // check if any parameter is different
697 if ((lacpdu
->partner_port
!= port
->actor_port_number
) ||
698 (lacpdu
->partner_port_priority
!= port
->actor_port_priority
) ||
699 MAC_ADDRESS_COMPARE(&(lacpdu
->partner_system
), &(port
->actor_system
)) ||
700 (lacpdu
->partner_system_priority
!= port
->actor_system_priority
) ||
701 (lacpdu
->partner_key
!= port
->actor_oper_port_key
) ||
702 ((lacpdu
->partner_state
& AD_STATE_LACP_ACTIVITY
) != (port
->actor_oper_port_state
& AD_STATE_LACP_ACTIVITY
)) ||
703 ((lacpdu
->partner_state
& AD_STATE_LACP_TIMEOUT
) != (port
->actor_oper_port_state
& AD_STATE_LACP_TIMEOUT
)) ||
704 ((lacpdu
->partner_state
& AD_STATE_SYNCHRONIZATION
) != (port
->actor_oper_port_state
& AD_STATE_SYNCHRONIZATION
)) ||
705 ((lacpdu
->partner_state
& AD_STATE_AGGREGATION
) != (port
->actor_oper_port_state
& AD_STATE_AGGREGATION
))
707 // set ntt to be TRUE
714 * __attach_bond_to_agg
715 * @port: the port we're looking at
717 * Handle the attaching of the port's control parser/multiplexer and the
718 * aggregator. This function does nothing since the parser/multiplexer of the
719 * receive and the parser/multiplexer of the aggregator are already combined.
721 static void __attach_bond_to_agg(struct port
*port
)
723 port
=NULL
; // just to satisfy the compiler
724 // This function does nothing since the parser/multiplexer of the receive
725 // and the parser/multiplexer of the aggregator are already combined
729 * __detach_bond_from_agg
730 * @port: the port we're looking at
732 * Handle the detaching of the port's control parser/multiplexer from the
733 * aggregator. This function does nothing since the parser/multiplexer of the
734 * receive and the parser/multiplexer of the aggregator are already combined.
736 static void __detach_bond_from_agg(struct port
*port
)
738 port
=NULL
; // just to satisfy the compiler
739 // This function does nothing sience the parser/multiplexer of the receive
740 // and the parser/multiplexer of the aggregator are already combined
744 * __agg_ports_are_ready - check if all ports in an aggregator are ready
745 * @aggregator: the aggregator we're looking at
748 static int __agg_ports_are_ready(struct aggregator
*aggregator
)
754 // scan all ports in this aggregator to verfy if they are all ready
755 for (port
=aggregator
->lag_ports
; port
; port
=port
->next_port_in_aggregator
) {
756 if (!(port
->sm_vars
& AD_PORT_READY_N
)) {
767 * __set_agg_ports_ready - set value of Ready bit in all ports of an aggregator
768 * @aggregator: the aggregator we're looking at
769 * @val: Should the ports' ready bit be set on or off
772 static void __set_agg_ports_ready(struct aggregator
*aggregator
, int val
)
776 for (port
=aggregator
->lag_ports
; port
; port
=port
->next_port_in_aggregator
) {
778 port
->sm_vars
|= AD_PORT_READY
;
780 port
->sm_vars
&= ~AD_PORT_READY
;
786 * __get_agg_bandwidth - get the total bandwidth of an aggregator
787 * @aggregator: the aggregator we're looking at
790 static u32
__get_agg_bandwidth(struct aggregator
*aggregator
)
795 if (aggregator
->num_of_ports
) {
796 basic_speed
= __get_link_speed(aggregator
->lag_ports
);
797 switch (basic_speed
) {
798 case AD_LINK_SPEED_BITMASK_1MBPS
:
799 bandwidth
= aggregator
->num_of_ports
;
801 case AD_LINK_SPEED_BITMASK_10MBPS
:
802 bandwidth
= aggregator
->num_of_ports
* 10;
804 case AD_LINK_SPEED_BITMASK_100MBPS
:
805 bandwidth
= aggregator
->num_of_ports
* 100;
807 case AD_LINK_SPEED_BITMASK_1000MBPS
:
808 bandwidth
= aggregator
->num_of_ports
* 1000;
811 bandwidth
=0; // to silent the compilor ....
818 * __get_active_agg - get the current active aggregator
819 * @aggregator: the aggregator we're looking at
822 static struct aggregator
*__get_active_agg(struct aggregator
*aggregator
)
824 struct aggregator
*retval
= NULL
;
826 for (; aggregator
; aggregator
= __get_next_agg(aggregator
)) {
827 if (aggregator
->is_active
) {
837 * __update_lacpdu_from_port - update a port's lacpdu fields
838 * @port: the port we're looking at
841 static inline void __update_lacpdu_from_port(struct port
*port
)
843 struct lacpdu
*lacpdu
= &port
->lacpdu
;
845 /* update current actual Actor parameters */
846 /* lacpdu->subtype initialized
847 * lacpdu->version_number initialized
848 * lacpdu->tlv_type_actor_info initialized
849 * lacpdu->actor_information_length initialized
852 lacpdu
->actor_system_priority
= port
->actor_system_priority
;
853 lacpdu
->actor_system
= port
->actor_system
;
854 lacpdu
->actor_key
= port
->actor_oper_port_key
;
855 lacpdu
->actor_port_priority
= port
->actor_port_priority
;
856 lacpdu
->actor_port
= port
->actor_port_number
;
857 lacpdu
->actor_state
= port
->actor_oper_port_state
;
859 /* lacpdu->reserved_3_1 initialized
860 * lacpdu->tlv_type_partner_info initialized
861 * lacpdu->partner_information_length initialized
864 lacpdu
->partner_system_priority
= port
->partner_oper_system_priority
;
865 lacpdu
->partner_system
= port
->partner_oper_system
;
866 lacpdu
->partner_key
= port
->partner_oper_key
;
867 lacpdu
->partner_port_priority
= port
->partner_oper_port_priority
;
868 lacpdu
->partner_port
= port
->partner_oper_port_number
;
869 lacpdu
->partner_state
= port
->partner_oper_port_state
;
871 /* lacpdu->reserved_3_2 initialized
872 * lacpdu->tlv_type_collector_info initialized
873 * lacpdu->collector_information_length initialized
874 * collector_max_delay initialized
875 * reserved_12[12] initialized
876 * tlv_type_terminator initialized
877 * terminator_length initialized
878 * reserved_50[50] initialized
881 /* Convert all non u8 parameters to Big Endian for transmit */
882 __ntohs_lacpdu(lacpdu
);
885 //////////////////////////////////////////////////////////////////////////////////////
886 // ================= main 802.3ad protocol code ======================================
887 //////////////////////////////////////////////////////////////////////////////////////
890 * ad_lacpdu_send - send out a lacpdu packet on a given port
891 * @port: the port we're looking at
893 * Returns: 0 on success
896 static int ad_lacpdu_send(struct port
*port
)
898 struct slave
*slave
= port
->slave
;
900 struct lacpdu_header
*lacpdu_header
;
901 int length
= sizeof(struct lacpdu_header
);
902 struct mac_addr lacpdu_multicast_address
= AD_MULTICAST_LACPDU_ADDR
;
904 skb
= dev_alloc_skb(length
);
909 skb
->dev
= slave
->dev
;
910 skb
->mac
.raw
= skb
->data
;
911 skb
->nh
.raw
= skb
->data
+ ETH_HLEN
;
912 skb
->protocol
= PKT_TYPE_LACPDU
;
913 skb
->priority
= TC_PRIO_CONTROL
;
915 lacpdu_header
= (struct lacpdu_header
*)skb_put(skb
, length
);
917 lacpdu_header
->ad_header
.destination_address
= lacpdu_multicast_address
;
918 /* Note: source addres is set to be the member's PERMANENT address, because we use it
919 to identify loopback lacpdus in receive. */
920 lacpdu_header
->ad_header
.source_address
= *((struct mac_addr
*)(slave
->perm_hwaddr
));
921 lacpdu_header
->ad_header
.length_type
= PKT_TYPE_LACPDU
;
923 lacpdu_header
->lacpdu
= port
->lacpdu
; // struct copy
931 * ad_marker_send - send marker information/response on a given port
932 * @port: the port we're looking at
933 * @marker: marker data to send
935 * Returns: 0 on success
938 static int ad_marker_send(struct port
*port
, struct marker
*marker
)
940 struct slave
*slave
= port
->slave
;
942 struct marker_header
*marker_header
;
943 int length
= sizeof(struct marker_header
);
944 struct mac_addr lacpdu_multicast_address
= AD_MULTICAST_LACPDU_ADDR
;
946 skb
= dev_alloc_skb(length
+ 16);
951 skb_reserve(skb
, 16);
953 skb
->dev
= slave
->dev
;
954 skb
->mac
.raw
= skb
->data
;
955 skb
->nh
.raw
= skb
->data
+ ETH_HLEN
;
956 skb
->protocol
= PKT_TYPE_LACPDU
;
958 marker_header
= (struct marker_header
*)skb_put(skb
, length
);
960 marker_header
->ad_header
.destination_address
= lacpdu_multicast_address
;
961 /* Note: source addres is set to be the member's PERMANENT address, because we use it
962 to identify loopback MARKERs in receive. */
963 marker_header
->ad_header
.source_address
= *((struct mac_addr
*)(slave
->perm_hwaddr
));
964 marker_header
->ad_header
.length_type
= PKT_TYPE_LACPDU
;
966 marker_header
->marker
= *marker
; // struct copy
974 * ad_mux_machine - handle a port's mux state machine
975 * @port: the port we're looking at
978 static void ad_mux_machine(struct port
*port
)
980 mux_states_t last_state
;
982 // keep current State Machine state to compare later if it was changed
983 last_state
= port
->sm_mux_state
;
985 if (port
->sm_vars
& AD_PORT_BEGIN
) {
986 port
->sm_mux_state
= AD_MUX_DETACHED
; // next state
988 switch (port
->sm_mux_state
) {
989 case AD_MUX_DETACHED
:
990 if ((port
->sm_vars
& AD_PORT_SELECTED
) || (port
->sm_vars
& AD_PORT_STANDBY
)) { // if SELECTED or STANDBY
991 port
->sm_mux_state
= AD_MUX_WAITING
; // next state
995 // if SELECTED == FALSE return to DETACH state
996 if (!(port
->sm_vars
& AD_PORT_SELECTED
)) { // if UNSELECTED
997 port
->sm_vars
&= ~AD_PORT_READY_N
;
998 // in order to withhold the Selection Logic to check all ports READY_N value
999 // every callback cycle to update ready variable, we check READY_N and update READY here
1000 __set_agg_ports_ready(port
->aggregator
, __agg_ports_are_ready(port
->aggregator
));
1001 port
->sm_mux_state
= AD_MUX_DETACHED
; // next state
1005 // check if the wait_while_timer expired
1006 if (port
->sm_mux_timer_counter
&& !(--port
->sm_mux_timer_counter
)) {
1007 port
->sm_vars
|= AD_PORT_READY_N
;
1010 // in order to withhold the selection logic to check all ports READY_N value
1011 // every callback cycle to update ready variable, we check READY_N and update READY here
1012 __set_agg_ports_ready(port
->aggregator
, __agg_ports_are_ready(port
->aggregator
));
1014 // if the wait_while_timer expired, and the port is in READY state, move to ATTACHED state
1015 if ((port
->sm_vars
& AD_PORT_READY
) && !port
->sm_mux_timer_counter
) {
1016 port
->sm_mux_state
= AD_MUX_ATTACHED
; // next state
1019 case AD_MUX_ATTACHED
:
1020 // check also if agg_select_timer expired(so the edable port will take place only after this timer)
1021 if ((port
->sm_vars
& AD_PORT_SELECTED
) && (port
->partner_oper_port_state
& AD_STATE_SYNCHRONIZATION
) && !__check_agg_selection_timer(port
)) {
1022 port
->sm_mux_state
= AD_MUX_COLLECTING_DISTRIBUTING
;// next state
1023 } else if (!(port
->sm_vars
& AD_PORT_SELECTED
) || (port
->sm_vars
& AD_PORT_STANDBY
)) { // if UNSELECTED or STANDBY
1024 port
->sm_vars
&= ~AD_PORT_READY_N
;
1025 // in order to withhold the selection logic to check all ports READY_N value
1026 // every callback cycle to update ready variable, we check READY_N and update READY here
1027 __set_agg_ports_ready(port
->aggregator
, __agg_ports_are_ready(port
->aggregator
));
1028 port
->sm_mux_state
= AD_MUX_DETACHED
;// next state
1031 case AD_MUX_COLLECTING_DISTRIBUTING
:
1032 if (!(port
->sm_vars
& AD_PORT_SELECTED
) || (port
->sm_vars
& AD_PORT_STANDBY
) ||
1033 !(port
->partner_oper_port_state
& AD_STATE_SYNCHRONIZATION
)
1035 port
->sm_mux_state
= AD_MUX_ATTACHED
;// next state
1038 // if port state hasn't changed make
1039 // sure that a collecting distributing
1040 // port in an active aggregator is enabled
1041 if (port
->aggregator
&&
1042 port
->aggregator
->is_active
&&
1043 !__port_is_enabled(port
)) {
1045 __enable_port(port
);
1049 default: //to silence the compiler
1054 // check if the state machine was changed
1055 if (port
->sm_mux_state
!= last_state
) {
1056 dprintk("Mux Machine: Port=%d, Last State=%d, Curr State=%d\n", port
->actor_port_number
, last_state
, port
->sm_mux_state
);
1057 switch (port
->sm_mux_state
) {
1058 case AD_MUX_DETACHED
:
1059 __detach_bond_from_agg(port
);
1060 port
->actor_oper_port_state
&= ~AD_STATE_SYNCHRONIZATION
;
1061 ad_disable_collecting_distributing(port
);
1062 port
->actor_oper_port_state
&= ~AD_STATE_COLLECTING
;
1063 port
->actor_oper_port_state
&= ~AD_STATE_DISTRIBUTING
;
1066 case AD_MUX_WAITING
:
1067 port
->sm_mux_timer_counter
= __ad_timer_to_ticks(AD_WAIT_WHILE_TIMER
, 0);
1069 case AD_MUX_ATTACHED
:
1070 __attach_bond_to_agg(port
);
1071 port
->actor_oper_port_state
|= AD_STATE_SYNCHRONIZATION
;
1072 port
->actor_oper_port_state
&= ~AD_STATE_COLLECTING
;
1073 port
->actor_oper_port_state
&= ~AD_STATE_DISTRIBUTING
;
1074 ad_disable_collecting_distributing(port
);
1077 case AD_MUX_COLLECTING_DISTRIBUTING
:
1078 port
->actor_oper_port_state
|= AD_STATE_COLLECTING
;
1079 port
->actor_oper_port_state
|= AD_STATE_DISTRIBUTING
;
1080 ad_enable_collecting_distributing(port
);
1083 default: //to silence the compiler
1090 * ad_rx_machine - handle a port's rx State Machine
1091 * @lacpdu: the lacpdu we've received
1092 * @port: the port we're looking at
1094 * If lacpdu arrived, stop previous timer (if exists) and set the next state as
1095 * CURRENT. If timer expired set the state machine in the proper state.
1096 * In other cases, this function checks if we need to switch to other state.
1098 static void ad_rx_machine(struct lacpdu
*lacpdu
, struct port
*port
)
1100 rx_states_t last_state
;
1102 // Lock to prevent 2 instances of this function to run simultaneously(rx interrupt and periodic machine callback)
1103 __get_rx_machine_lock(port
);
1105 // keep current State Machine state to compare later if it was changed
1106 last_state
= port
->sm_rx_state
;
1108 // check if state machine should change state
1109 // first, check if port was reinitialized
1110 if (port
->sm_vars
& AD_PORT_BEGIN
) {
1111 port
->sm_rx_state
= AD_RX_INITIALIZE
; // next state
1113 // check if port is not enabled
1114 else if (!(port
->sm_vars
& AD_PORT_BEGIN
) && !port
->is_enabled
&& !(port
->sm_vars
& AD_PORT_MOVED
)) {
1115 port
->sm_rx_state
= AD_RX_PORT_DISABLED
; // next state
1117 // check if new lacpdu arrived
1118 else if (lacpdu
&& ((port
->sm_rx_state
== AD_RX_EXPIRED
) || (port
->sm_rx_state
== AD_RX_DEFAULTED
) || (port
->sm_rx_state
== AD_RX_CURRENT
))) {
1119 port
->sm_rx_timer_counter
= 0; // zero timer
1120 port
->sm_rx_state
= AD_RX_CURRENT
;
1122 // if timer is on, and if it is expired
1123 if (port
->sm_rx_timer_counter
&& !(--port
->sm_rx_timer_counter
)) {
1124 switch (port
->sm_rx_state
) {
1126 port
->sm_rx_state
= AD_RX_DEFAULTED
; // next state
1129 port
->sm_rx_state
= AD_RX_EXPIRED
; // next state
1131 default: //to silence the compiler
1135 // if no lacpdu arrived and no timer is on
1136 switch (port
->sm_rx_state
) {
1137 case AD_RX_PORT_DISABLED
:
1138 if (port
->sm_vars
& AD_PORT_MOVED
) {
1139 port
->sm_rx_state
= AD_RX_INITIALIZE
; // next state
1140 } else if (port
->is_enabled
&& (port
->sm_vars
& AD_PORT_LACP_ENABLED
)) {
1141 port
->sm_rx_state
= AD_RX_EXPIRED
; // next state
1142 } else if (port
->is_enabled
&& ((port
->sm_vars
& AD_PORT_LACP_ENABLED
) == 0)) {
1143 port
->sm_rx_state
= AD_RX_LACP_DISABLED
; // next state
1146 default: //to silence the compiler
1153 // check if the State machine was changed or new lacpdu arrived
1154 if ((port
->sm_rx_state
!= last_state
) || (lacpdu
)) {
1155 dprintk("Rx Machine: Port=%d, Last State=%d, Curr State=%d\n", port
->actor_port_number
, last_state
, port
->sm_rx_state
);
1156 switch (port
->sm_rx_state
) {
1157 case AD_RX_INITIALIZE
:
1158 if (!(port
->actor_oper_port_key
& AD_DUPLEX_KEY_BITS
)) {
1159 port
->sm_vars
&= ~AD_PORT_LACP_ENABLED
;
1161 port
->sm_vars
|= AD_PORT_LACP_ENABLED
;
1163 port
->sm_vars
&= ~AD_PORT_SELECTED
;
1164 __record_default(port
);
1165 port
->actor_oper_port_state
&= ~AD_STATE_EXPIRED
;
1166 port
->sm_vars
&= ~AD_PORT_MOVED
;
1167 port
->sm_rx_state
= AD_RX_PORT_DISABLED
; // next state
1169 /*- Fall Through -*/
1171 case AD_RX_PORT_DISABLED
:
1172 port
->sm_vars
&= ~AD_PORT_MATCHED
;
1174 case AD_RX_LACP_DISABLED
:
1175 port
->sm_vars
&= ~AD_PORT_SELECTED
;
1176 __record_default(port
);
1177 port
->partner_oper_port_state
&= ~AD_STATE_AGGREGATION
;
1178 port
->sm_vars
|= AD_PORT_MATCHED
;
1179 port
->actor_oper_port_state
&= ~AD_STATE_EXPIRED
;
1182 //Reset of the Synchronization flag. (Standard 43.4.12)
1183 //This reset cause to disable this port in the COLLECTING_DISTRIBUTING state of the
1184 //mux machine in case of EXPIRED even if LINK_DOWN didn't arrive for the port.
1185 port
->partner_oper_port_state
&= ~AD_STATE_SYNCHRONIZATION
;
1186 port
->sm_vars
&= ~AD_PORT_MATCHED
;
1187 port
->partner_oper_port_state
|= AD_SHORT_TIMEOUT
;
1188 port
->sm_rx_timer_counter
= __ad_timer_to_ticks(AD_CURRENT_WHILE_TIMER
, (u16
)(AD_SHORT_TIMEOUT
));
1189 port
->actor_oper_port_state
|= AD_STATE_EXPIRED
;
1191 case AD_RX_DEFAULTED
:
1192 __update_default_selected(port
);
1193 __record_default(port
);
1194 port
->sm_vars
|= AD_PORT_MATCHED
;
1195 port
->actor_oper_port_state
&= ~AD_STATE_EXPIRED
;
1198 // detect loopback situation
1199 if (!MAC_ADDRESS_COMPARE(&(lacpdu
->actor_system
), &(port
->actor_system
))) {
1200 // INFO_RECEIVED_LOOPBACK_FRAMES
1201 printk(KERN_ERR DRV_NAME
": %s: An illegal loopback occurred on "
1202 "adapter (%s). Check the configuration to verify that all "
1203 "Adapters are connected to 802.3ad compliant switch ports\n",
1204 port
->slave
->dev
->master
->name
, port
->slave
->dev
->name
);
1205 __release_rx_machine_lock(port
);
1208 __update_selected(lacpdu
, port
);
1209 __update_ntt(lacpdu
, port
);
1210 __record_pdu(lacpdu
, port
);
1211 __choose_matched(lacpdu
, port
);
1212 port
->sm_rx_timer_counter
= __ad_timer_to_ticks(AD_CURRENT_WHILE_TIMER
, (u16
)(port
->actor_oper_port_state
& AD_STATE_LACP_TIMEOUT
));
1213 port
->actor_oper_port_state
&= ~AD_STATE_EXPIRED
;
1214 // verify that if the aggregator is enabled, the port is enabled too.
1215 //(because if the link goes down for a short time, the 802.3ad will not
1216 // catch it, and the port will continue to be disabled)
1217 if (port
->aggregator
&& port
->aggregator
->is_active
&& !__port_is_enabled(port
)) {
1218 __enable_port(port
);
1221 default: //to silence the compiler
1225 __release_rx_machine_lock(port
);
1229 * ad_tx_machine - handle a port's tx state machine
1230 * @port: the port we're looking at
1233 static void ad_tx_machine(struct port
*port
)
1235 // check if tx timer expired, to verify that we do not send more than 3 packets per second
1236 if (port
->sm_tx_timer_counter
&& !(--port
->sm_tx_timer_counter
)) {
1237 // check if there is something to send
1238 if (port
->ntt
&& (port
->sm_vars
& AD_PORT_LACP_ENABLED
)) {
1239 __update_lacpdu_from_port(port
);
1241 if (ad_lacpdu_send(port
) >= 0) {
1242 dprintk("Sent LACPDU on port %d\n", port
->actor_port_number
);
1243 // mark ntt as false, so it will not be sent again until demanded
1247 // restart tx timer(to verify that we will not exceed AD_MAX_TX_IN_SECOND
1248 port
->sm_tx_timer_counter
=ad_ticks_per_sec
/AD_MAX_TX_IN_SECOND
;
1253 * ad_periodic_machine - handle a port's periodic state machine
1254 * @port: the port we're looking at
1256 * Turn ntt flag on priodically to perform periodic transmission of lacpdu's.
1258 static void ad_periodic_machine(struct port
*port
)
1260 periodic_states_t last_state
;
1262 // keep current state machine state to compare later if it was changed
1263 last_state
= port
->sm_periodic_state
;
1265 // check if port was reinitialized
1266 if (((port
->sm_vars
& AD_PORT_BEGIN
) || !(port
->sm_vars
& AD_PORT_LACP_ENABLED
) || !port
->is_enabled
) ||
1267 (!(port
->actor_oper_port_state
& AD_STATE_LACP_ACTIVITY
) && !(port
->partner_oper_port_state
& AD_STATE_LACP_ACTIVITY
))
1269 port
->sm_periodic_state
= AD_NO_PERIODIC
; // next state
1271 // check if state machine should change state
1272 else if (port
->sm_periodic_timer_counter
) {
1273 // check if periodic state machine expired
1274 if (!(--port
->sm_periodic_timer_counter
)) {
1275 // if expired then do tx
1276 port
->sm_periodic_state
= AD_PERIODIC_TX
; // next state
1278 // If not expired, check if there is some new timeout parameter from the partner state
1279 switch (port
->sm_periodic_state
) {
1280 case AD_FAST_PERIODIC
:
1281 if (!(port
->partner_oper_port_state
& AD_STATE_LACP_TIMEOUT
)) {
1282 port
->sm_periodic_state
= AD_SLOW_PERIODIC
; // next state
1285 case AD_SLOW_PERIODIC
:
1286 if ((port
->partner_oper_port_state
& AD_STATE_LACP_TIMEOUT
)) {
1287 // stop current timer
1288 port
->sm_periodic_timer_counter
= 0;
1289 port
->sm_periodic_state
= AD_PERIODIC_TX
; // next state
1292 default: //to silence the compiler
1297 switch (port
->sm_periodic_state
) {
1298 case AD_NO_PERIODIC
:
1299 port
->sm_periodic_state
= AD_FAST_PERIODIC
; // next state
1301 case AD_PERIODIC_TX
:
1302 if (!(port
->partner_oper_port_state
& AD_STATE_LACP_TIMEOUT
)) {
1303 port
->sm_periodic_state
= AD_SLOW_PERIODIC
; // next state
1305 port
->sm_periodic_state
= AD_FAST_PERIODIC
; // next state
1308 default: //to silence the compiler
1313 // check if the state machine was changed
1314 if (port
->sm_periodic_state
!= last_state
) {
1315 dprintk("Periodic Machine: Port=%d, Last State=%d, Curr State=%d\n", port
->actor_port_number
, last_state
, port
->sm_periodic_state
);
1316 switch (port
->sm_periodic_state
) {
1317 case AD_NO_PERIODIC
:
1318 port
->sm_periodic_timer_counter
= 0; // zero timer
1320 case AD_FAST_PERIODIC
:
1321 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
1323 case AD_SLOW_PERIODIC
:
1324 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
1326 case AD_PERIODIC_TX
:
1329 default: //to silence the compiler
1336 * ad_port_selection_logic - select aggregation groups
1337 * @port: the port we're looking at
1339 * Select aggregation groups, and assign each port for it's aggregetor. The
1340 * selection logic is called in the inititalization (after all the handshkes),
1341 * and after every lacpdu receive (if selected is off).
1343 static void ad_port_selection_logic(struct port
*port
)
1345 struct aggregator
*aggregator
, *free_aggregator
= NULL
, *temp_aggregator
;
1346 struct port
*last_port
= NULL
, *curr_port
;
1349 // if the port is already Selected, do nothing
1350 if (port
->sm_vars
& AD_PORT_SELECTED
) {
1354 // if the port is connected to other aggregator, detach it
1355 if (port
->aggregator
) {
1356 // detach the port from its former aggregator
1357 temp_aggregator
=port
->aggregator
;
1358 for (curr_port
=temp_aggregator
->lag_ports
; curr_port
; last_port
=curr_port
, curr_port
=curr_port
->next_port_in_aggregator
) {
1359 if (curr_port
== port
) {
1360 temp_aggregator
->num_of_ports
--;
1361 if (!last_port
) {// if it is the first port attached to the aggregator
1362 temp_aggregator
->lag_ports
=port
->next_port_in_aggregator
;
1363 } else {// not the first port attached to the aggregator
1364 last_port
->next_port_in_aggregator
=port
->next_port_in_aggregator
;
1367 // clear the port's relations to this aggregator
1368 port
->aggregator
= NULL
;
1369 port
->next_port_in_aggregator
=NULL
;
1370 port
->actor_port_aggregator_identifier
=0;
1372 dprintk("Port %d left LAG %d\n", port
->actor_port_number
, temp_aggregator
->aggregator_identifier
);
1373 // if the aggregator is empty, clear its parameters, and set it ready to be attached
1374 if (!temp_aggregator
->lag_ports
) {
1375 ad_clear_agg(temp_aggregator
);
1380 if (!curr_port
) { // meaning: the port was related to an aggregator but was not on the aggregator port list
1381 printk(KERN_WARNING DRV_NAME
": %s: Warning: Port %d (on %s) was "
1382 "related to aggregator %d but was not on its port list\n",
1383 port
->slave
->dev
->master
->name
,
1384 port
->actor_port_number
, port
->slave
->dev
->name
,
1385 port
->aggregator
->aggregator_identifier
);
1388 // search on all aggregators for a suitable aggregator for this port
1389 for (aggregator
= __get_first_agg(port
); aggregator
;
1390 aggregator
= __get_next_agg(aggregator
)) {
1392 // keep a free aggregator for later use(if needed)
1393 if (!aggregator
->lag_ports
) {
1394 if (!free_aggregator
) {
1395 free_aggregator
=aggregator
;
1399 // check if current aggregator suits us
1400 if (((aggregator
->actor_oper_aggregator_key
== port
->actor_oper_port_key
) && // if all parameters match AND
1401 !MAC_ADDRESS_COMPARE(&(aggregator
->partner_system
), &(port
->partner_oper_system
)) &&
1402 (aggregator
->partner_system_priority
== port
->partner_oper_system_priority
) &&
1403 (aggregator
->partner_oper_aggregator_key
== port
->partner_oper_key
)
1405 ((MAC_ADDRESS_COMPARE(&(port
->partner_oper_system
), &(null_mac_addr
)) && // partner answers
1406 !aggregator
->is_individual
) // but is not individual OR
1409 // attach to the founded aggregator
1410 port
->aggregator
= aggregator
;
1411 port
->actor_port_aggregator_identifier
=port
->aggregator
->aggregator_identifier
;
1412 port
->next_port_in_aggregator
=aggregator
->lag_ports
;
1413 port
->aggregator
->num_of_ports
++;
1414 aggregator
->lag_ports
=port
;
1415 dprintk("Port %d joined LAG %d(existing LAG)\n", port
->actor_port_number
, port
->aggregator
->aggregator_identifier
);
1417 // mark this port as selected
1418 port
->sm_vars
|= AD_PORT_SELECTED
;
1424 // the port couldn't find an aggregator - attach it to a new aggregator
1426 if (free_aggregator
) {
1427 // assign port a new aggregator
1428 port
->aggregator
= free_aggregator
;
1429 port
->actor_port_aggregator_identifier
=port
->aggregator
->aggregator_identifier
;
1431 // update the new aggregator's parameters
1432 // if port was responsed from the end-user
1433 if (port
->actor_oper_port_key
& AD_DUPLEX_KEY_BITS
) {// if port is full duplex
1434 port
->aggregator
->is_individual
= 0;
1436 port
->aggregator
->is_individual
= 1;
1439 port
->aggregator
->actor_admin_aggregator_key
= port
->actor_admin_port_key
;
1440 port
->aggregator
->actor_oper_aggregator_key
= port
->actor_oper_port_key
;
1441 port
->aggregator
->partner_system
=port
->partner_oper_system
;
1442 port
->aggregator
->partner_system_priority
= port
->partner_oper_system_priority
;
1443 port
->aggregator
->partner_oper_aggregator_key
= port
->partner_oper_key
;
1444 port
->aggregator
->receive_state
= 1;
1445 port
->aggregator
->transmit_state
= 1;
1446 port
->aggregator
->lag_ports
= port
;
1447 port
->aggregator
->num_of_ports
++;
1449 // mark this port as selected
1450 port
->sm_vars
|= AD_PORT_SELECTED
;
1452 dprintk("Port %d joined LAG %d(new LAG)\n", port
->actor_port_number
, port
->aggregator
->aggregator_identifier
);
1454 printk(KERN_ERR DRV_NAME
": %s: Port %d (on %s) did not find a suitable aggregator\n",
1455 port
->slave
->dev
->master
->name
,
1456 port
->actor_port_number
, port
->slave
->dev
->name
);
1459 // if all aggregator's ports are READY_N == TRUE, set ready=TRUE in all aggregator's ports
1460 // else set ready=FALSE in all aggregator's ports
1461 __set_agg_ports_ready(port
->aggregator
, __agg_ports_are_ready(port
->aggregator
));
1463 if (!__check_agg_selection_timer(port
) && (aggregator
= __get_first_agg(port
))) {
1464 ad_agg_selection_logic(aggregator
);
1469 * ad_agg_selection_logic - select an aggregation group for a team
1470 * @aggregator: the aggregator we're looking at
1472 * It is assumed that only one aggregator may be selected for a team.
1473 * The logic of this function is to select (at first time) the aggregator with
1474 * the most ports attached to it, and to reselect the active aggregator only if
1475 * the previous aggregator has no more ports related to it.
1477 * FIXME: this function MUST be called with the first agg in the bond, or
1478 * __get_active_agg() won't work correctly. This function should be better
1479 * called with the bond itself, and retrieve the first agg from it.
1481 static void ad_agg_selection_logic(struct aggregator
*aggregator
)
1483 struct aggregator
*best_aggregator
= NULL
, *active_aggregator
= NULL
;
1484 struct aggregator
*last_active_aggregator
= NULL
, *origin_aggregator
;
1488 origin_aggregator
= aggregator
;
1490 //get current active aggregator
1491 last_active_aggregator
= __get_active_agg(aggregator
);
1493 // search for the aggregator with the most ports attached to it.
1495 // count how many candidate lag's we have
1496 if (aggregator
->lag_ports
) {
1499 if (aggregator
->is_active
&& !aggregator
->is_individual
&& // if current aggregator is the active aggregator
1500 MAC_ADDRESS_COMPARE(&(aggregator
->partner_system
), &(null_mac_addr
))) { // and partner answers to 802.3ad PDUs
1501 if (aggregator
->num_of_ports
) { // if any ports attached to the current aggregator
1502 best_aggregator
=NULL
; // disregard the best aggregator that was chosen by now
1503 break; // stop the selection of other aggregator if there are any ports attached to this active aggregator
1504 } else { // no ports attached to this active aggregator
1505 aggregator
->is_active
= 0; // mark this aggregator as not active anymore
1508 if (aggregator
->num_of_ports
) { // if any ports attached
1509 if (best_aggregator
) { // if there is a candidte aggregator
1510 //The reasons for choosing new best aggregator:
1511 // 1. if current agg is NOT individual and the best agg chosen so far is individual OR
1512 // current and best aggs are both individual or both not individual, AND
1513 // 2a. current agg partner reply but best agg partner do not reply OR
1514 // 2b. current agg partner reply OR current agg partner do not reply AND best agg partner also do not reply AND
1515 // current has more ports/bandwidth, or same amount of ports but current has faster ports, THEN
1516 // current agg become best agg so far
1518 //if current agg is NOT individual and the best agg chosen so far is individual change best_aggregator
1519 if (!aggregator
->is_individual
&& best_aggregator
->is_individual
) {
1520 best_aggregator
=aggregator
;
1522 // current and best aggs are both individual or both not individual
1523 else if ((aggregator
->is_individual
&& best_aggregator
->is_individual
) ||
1524 (!aggregator
->is_individual
&& !best_aggregator
->is_individual
)) {
1525 // current and best aggs are both individual or both not individual AND
1526 // current agg partner reply but best agg partner do not reply
1527 if ((MAC_ADDRESS_COMPARE(&(aggregator
->partner_system
), &(null_mac_addr
)) &&
1528 !MAC_ADDRESS_COMPARE(&(best_aggregator
->partner_system
), &(null_mac_addr
)))) {
1529 best_aggregator
=aggregator
;
1531 // current agg partner reply OR current agg partner do not reply AND best agg partner also do not reply
1532 else if (! (!MAC_ADDRESS_COMPARE(&(aggregator
->partner_system
), &(null_mac_addr
)) &&
1533 MAC_ADDRESS_COMPARE(&(best_aggregator
->partner_system
), &(null_mac_addr
)))) {
1534 if ((__get_agg_selection_mode(aggregator
->lag_ports
) == AD_BANDWIDTH
)&&
1535 (__get_agg_bandwidth(aggregator
) > __get_agg_bandwidth(best_aggregator
))) {
1536 best_aggregator
=aggregator
;
1537 } else if (__get_agg_selection_mode(aggregator
->lag_ports
) == AD_COUNT
) {
1538 if (((aggregator
->num_of_ports
> best_aggregator
->num_of_ports
) &&
1539 (aggregator
->actor_oper_aggregator_key
& AD_SPEED_KEY_BITS
))||
1540 ((aggregator
->num_of_ports
== best_aggregator
->num_of_ports
) &&
1541 ((u16
)(aggregator
->actor_oper_aggregator_key
& AD_SPEED_KEY_BITS
) >
1542 (u16
)(best_aggregator
->actor_oper_aggregator_key
& AD_SPEED_KEY_BITS
)))) {
1543 best_aggregator
=aggregator
;
1549 best_aggregator
=aggregator
;
1552 aggregator
->is_active
= 0; // mark all aggregators as not active anymore
1553 } while ((aggregator
= __get_next_agg(aggregator
)));
1555 // if we have new aggregator selected, don't replace the old aggregator if it has an answering partner,
1556 // or if both old aggregator and new aggregator don't have answering partner
1557 if (best_aggregator
) {
1558 if (last_active_aggregator
&& last_active_aggregator
->lag_ports
&& last_active_aggregator
->lag_ports
->is_enabled
&&
1559 (MAC_ADDRESS_COMPARE(&(last_active_aggregator
->partner_system
), &(null_mac_addr
)) || // partner answers OR
1560 (!MAC_ADDRESS_COMPARE(&(last_active_aggregator
->partner_system
), &(null_mac_addr
)) && // both old and new
1561 !MAC_ADDRESS_COMPARE(&(best_aggregator
->partner_system
), &(null_mac_addr
)))) // partner do not answer
1563 // if new aggregator has link, and old aggregator does not, replace old aggregator.(do nothing)
1564 // -> don't replace otherwise.
1565 if (!(!last_active_aggregator
->actor_oper_aggregator_key
&& best_aggregator
->actor_oper_aggregator_key
)) {
1566 best_aggregator
=NULL
;
1567 last_active_aggregator
->is_active
= 1; // don't replace good old aggregator
1573 // if there is new best aggregator, activate it
1574 if (best_aggregator
) {
1575 for (aggregator
= __get_first_agg(best_aggregator
->lag_ports
);
1577 aggregator
= __get_next_agg(aggregator
)) {
1579 dprintk("Agg=%d; Ports=%d; a key=%d; p key=%d; Indiv=%d; Active=%d\n",
1580 aggregator
->aggregator_identifier
, aggregator
->num_of_ports
,
1581 aggregator
->actor_oper_aggregator_key
, aggregator
->partner_oper_aggregator_key
,
1582 aggregator
->is_individual
, aggregator
->is_active
);
1585 // check if any partner replys
1586 if (best_aggregator
->is_individual
) {
1587 printk(KERN_WARNING DRV_NAME
": %s: Warning: No 802.3ad response from "
1588 "the link partner for any adapters in the bond\n",
1589 best_aggregator
->slave
->dev
->master
->name
);
1592 // check if there are more than one aggregator
1593 if (num_of_aggs
> 1) {
1594 dprintk("Warning: More than one Link Aggregation Group was "
1595 "found in the bond. Only one group will function in the bond\n");
1598 best_aggregator
->is_active
= 1;
1599 dprintk("LAG %d choosed as the active LAG\n", best_aggregator
->aggregator_identifier
);
1600 dprintk("Agg=%d; Ports=%d; a key=%d; p key=%d; Indiv=%d; Active=%d\n",
1601 best_aggregator
->aggregator_identifier
, best_aggregator
->num_of_ports
,
1602 best_aggregator
->actor_oper_aggregator_key
, best_aggregator
->partner_oper_aggregator_key
,
1603 best_aggregator
->is_individual
, best_aggregator
->is_active
);
1605 // disable the ports that were related to the former active_aggregator
1606 if (last_active_aggregator
) {
1607 for (port
=last_active_aggregator
->lag_ports
; port
; port
=port
->next_port_in_aggregator
) {
1608 __disable_port(port
);
1613 // if the selected aggregator is of join individuals(partner_system is NULL), enable their ports
1614 active_aggregator
= __get_active_agg(origin_aggregator
);
1616 if (active_aggregator
) {
1617 if (!MAC_ADDRESS_COMPARE(&(active_aggregator
->partner_system
), &(null_mac_addr
))) {
1618 for (port
=active_aggregator
->lag_ports
; port
; port
=port
->next_port_in_aggregator
) {
1619 __enable_port(port
);
1626 * ad_clear_agg - clear a given aggregator's parameters
1627 * @aggregator: the aggregator we're looking at
1630 static void ad_clear_agg(struct aggregator
*aggregator
)
1633 aggregator
->is_individual
= 0;
1634 aggregator
->actor_admin_aggregator_key
= 0;
1635 aggregator
->actor_oper_aggregator_key
= 0;
1636 aggregator
->partner_system
= null_mac_addr
;
1637 aggregator
->partner_system_priority
= 0;
1638 aggregator
->partner_oper_aggregator_key
= 0;
1639 aggregator
->receive_state
= 0;
1640 aggregator
->transmit_state
= 0;
1641 aggregator
->lag_ports
= NULL
;
1642 aggregator
->is_active
= 0;
1643 aggregator
->num_of_ports
= 0;
1644 dprintk("LAG %d was cleared\n", aggregator
->aggregator_identifier
);
1649 * ad_initialize_agg - initialize a given aggregator's parameters
1650 * @aggregator: the aggregator we're looking at
1653 static void ad_initialize_agg(struct aggregator
*aggregator
)
1656 ad_clear_agg(aggregator
);
1658 aggregator
->aggregator_mac_address
= null_mac_addr
;
1659 aggregator
->aggregator_identifier
= 0;
1660 aggregator
->slave
= NULL
;
1665 * ad_initialize_port - initialize a given port's parameters
1666 * @aggregator: the aggregator we're looking at
1667 * @lacp_fast: boolean. whether fast periodic should be used
1670 static void ad_initialize_port(struct port
*port
, int lacp_fast
)
1673 port
->actor_port_number
= 1;
1674 port
->actor_port_priority
= 0xff;
1675 port
->actor_system
= null_mac_addr
;
1676 port
->actor_system_priority
= 0xffff;
1677 port
->actor_port_aggregator_identifier
= 0;
1679 port
->actor_admin_port_key
= 1;
1680 port
->actor_oper_port_key
= 1;
1681 port
->actor_admin_port_state
= AD_STATE_AGGREGATION
| AD_STATE_LACP_ACTIVITY
;
1682 port
->actor_oper_port_state
= AD_STATE_AGGREGATION
| AD_STATE_LACP_ACTIVITY
;
1685 port
->actor_oper_port_state
|= AD_STATE_LACP_TIMEOUT
;
1688 port
->partner_admin_system
= null_mac_addr
;
1689 port
->partner_oper_system
= null_mac_addr
;
1690 port
->partner_admin_system_priority
= 0xffff;
1691 port
->partner_oper_system_priority
= 0xffff;
1692 port
->partner_admin_key
= 1;
1693 port
->partner_oper_key
= 1;
1694 port
->partner_admin_port_number
= 1;
1695 port
->partner_oper_port_number
= 1;
1696 port
->partner_admin_port_priority
= 0xff;
1697 port
->partner_oper_port_priority
= 0xff;
1698 port
->partner_admin_port_state
= 1;
1699 port
->partner_oper_port_state
= 1;
1700 port
->is_enabled
= 1;
1701 // ****** private parameters ******
1702 port
->sm_vars
= 0x3;
1703 port
->sm_rx_state
= 0;
1704 port
->sm_rx_timer_counter
= 0;
1705 port
->sm_periodic_state
= 0;
1706 port
->sm_periodic_timer_counter
= 0;
1707 port
->sm_mux_state
= 0;
1708 port
->sm_mux_timer_counter
= 0;
1709 port
->sm_tx_state
= 0;
1710 port
->sm_tx_timer_counter
= 0;
1712 port
->aggregator
= NULL
;
1713 port
->next_port_in_aggregator
= NULL
;
1714 port
->transaction_id
= 0;
1716 ad_initialize_lacpdu(&(port
->lacpdu
));
1721 * ad_enable_collecting_distributing - enable a port's transmit/receive
1722 * @port: the port we're looking at
1724 * Enable @port if it's in an active aggregator
1726 static void ad_enable_collecting_distributing(struct port
*port
)
1728 if (port
->aggregator
->is_active
) {
1729 dprintk("Enabling port %d(LAG %d)\n", port
->actor_port_number
, port
->aggregator
->aggregator_identifier
);
1730 __enable_port(port
);
1735 * ad_disable_collecting_distributing - disable a port's transmit/receive
1736 * @port: the port we're looking at
1739 static void ad_disable_collecting_distributing(struct port
*port
)
1741 if (port
->aggregator
&& MAC_ADDRESS_COMPARE(&(port
->aggregator
->partner_system
), &(null_mac_addr
))) {
1742 dprintk("Disabling port %d(LAG %d)\n", port
->actor_port_number
, port
->aggregator
->aggregator_identifier
);
1743 __disable_port(port
);
1749 * ad_marker_info_send - send a marker information frame
1750 * @port: the port we're looking at
1752 * This function does nothing since we decided not to implement send and handle
1753 * response for marker PDU's, in this stage, but only to respond to marker
1756 static void ad_marker_info_send(struct port
*port
)
1758 struct marker marker
;
1761 // fill the marker PDU with the appropriate values
1762 marker
.subtype
= 0x02;
1763 marker
.version_number
= 0x01;
1764 marker
.tlv_type
= AD_MARKER_INFORMATION_SUBTYPE
;
1765 marker
.marker_length
= 0x16;
1766 // convert requester_port to Big Endian
1767 marker
.requester_port
= (((port
->actor_port_number
& 0xFF) << 8) |((u16
)(port
->actor_port_number
& 0xFF00) >> 8));
1768 marker
.requester_system
= port
->actor_system
;
1769 // convert requester_port(u32) to Big Endian
1770 marker
.requester_transaction_id
= (((++port
->transaction_id
& 0xFF) << 24) |((port
->transaction_id
& 0xFF00) << 8) |((port
->transaction_id
& 0xFF0000) >> 8) |((port
->transaction_id
& 0xFF000000) >> 24));
1772 marker
.tlv_type_terminator
= 0x00;
1773 marker
.terminator_length
= 0x00;
1774 for (index
=0; index
<90; index
++) {
1775 marker
.reserved_90
[index
]=0;
1778 // send the marker information
1779 if (ad_marker_send(port
, &marker
) >= 0) {
1780 dprintk("Sent Marker Information on port %d\n", port
->actor_port_number
);
1786 * ad_marker_info_received - handle receive of a Marker information frame
1787 * @marker_info: Marker info received
1788 * @port: the port we're looking at
1791 static void ad_marker_info_received(struct marker
*marker_info
,struct port
*port
)
1793 struct marker marker
;
1795 // copy the received marker data to the response marker
1796 //marker = *marker_info;
1797 memcpy(&marker
, marker_info
, sizeof(struct marker
));
1798 // change the marker subtype to marker response
1799 marker
.tlv_type
=AD_MARKER_RESPONSE_SUBTYPE
;
1800 // send the marker response
1802 if (ad_marker_send(port
, &marker
) >= 0) {
1803 dprintk("Sent Marker Response on port %d\n", port
->actor_port_number
);
1808 * ad_marker_response_received - handle receive of a marker response frame
1809 * @marker: marker PDU received
1810 * @port: the port we're looking at
1812 * This function does nothing since we decided not to implement send and handle
1813 * response for marker PDU's, in this stage, but only to respond to marker
1816 static void ad_marker_response_received(struct marker
*marker
, struct port
*port
)
1818 marker
=NULL
; // just to satisfy the compiler
1819 port
=NULL
; // just to satisfy the compiler
1820 // DO NOTHING, SINCE WE DECIDED NOT TO IMPLEMENT THIS FEATURE FOR NOW
1824 * ad_initialize_lacpdu - initialize a given lacpdu structure
1825 * @lacpdu: lacpdu structure to initialize
1828 static void ad_initialize_lacpdu(struct lacpdu
*lacpdu
)
1832 // initialize lacpdu data
1833 lacpdu
->subtype
= 0x01;
1834 lacpdu
->version_number
= 0x01;
1835 lacpdu
->tlv_type_actor_info
= 0x01;
1836 lacpdu
->actor_information_length
= 0x14;
1837 // lacpdu->actor_system_priority updated on send
1838 // lacpdu->actor_system updated on send
1839 // lacpdu->actor_key updated on send
1840 // lacpdu->actor_port_priority updated on send
1841 // lacpdu->actor_port updated on send
1842 // lacpdu->actor_state updated on send
1843 lacpdu
->tlv_type_partner_info
= 0x02;
1844 lacpdu
->partner_information_length
= 0x14;
1845 for (index
=0; index
<=2; index
++) {
1846 lacpdu
->reserved_3_1
[index
]=0;
1848 // lacpdu->partner_system_priority updated on send
1849 // lacpdu->partner_system updated on send
1850 // lacpdu->partner_key updated on send
1851 // lacpdu->partner_port_priority updated on send
1852 // lacpdu->partner_port updated on send
1853 // lacpdu->partner_state updated on send
1854 for (index
=0; index
<=2; index
++) {
1855 lacpdu
->reserved_3_2
[index
]=0;
1857 lacpdu
->tlv_type_collector_info
= 0x03;
1858 lacpdu
->collector_information_length
= 0x10;
1859 lacpdu
->collector_max_delay
= AD_COLLECTOR_MAX_DELAY
;
1860 for (index
=0; index
<=11; index
++) {
1861 lacpdu
->reserved_12
[index
]=0;
1863 lacpdu
->tlv_type_terminator
= 0x00;
1864 lacpdu
->terminator_length
= 0;
1865 for (index
=0; index
<=49; index
++) {
1866 lacpdu
->reserved_50
[index
]=0;
1870 //////////////////////////////////////////////////////////////////////////////////////
1871 // ================= AD exported functions to the main bonding code ==================
1872 //////////////////////////////////////////////////////////////////////////////////////
1874 // Check aggregators status in team every T seconds
1875 #define AD_AGGREGATOR_SELECTION_TIMER 8
1877 static u16 aggregator_identifier
;
1880 * bond_3ad_initialize - initialize a bond's 802.3ad parameters and structures
1881 * @bond: bonding struct to work on
1882 * @tick_resolution: tick duration (millisecond resolution)
1883 * @lacp_fast: boolean. whether fast periodic should be used
1885 * Can be called only after the mac address of the bond is set.
1887 void bond_3ad_initialize(struct bonding
*bond
, u16 tick_resolution
, int lacp_fast
)
1889 // check that the bond is not initialized yet
1890 if (MAC_ADDRESS_COMPARE(&(BOND_AD_INFO(bond
).system
.sys_mac_addr
), &(bond
->dev
->dev_addr
))) {
1892 aggregator_identifier
= 0;
1894 BOND_AD_INFO(bond
).lacp_fast
= lacp_fast
;
1895 BOND_AD_INFO(bond
).system
.sys_priority
= 0xFFFF;
1896 BOND_AD_INFO(bond
).system
.sys_mac_addr
= *((struct mac_addr
*)bond
->dev
->dev_addr
);
1898 // initialize how many times this module is called in one second(should be about every 100ms)
1899 ad_ticks_per_sec
= tick_resolution
;
1901 // initialize the aggregator selection timer(to activate an aggregation selection after initialize)
1902 BOND_AD_INFO(bond
).agg_select_timer
= (AD_AGGREGATOR_SELECTION_TIMER
* ad_ticks_per_sec
);
1903 BOND_AD_INFO(bond
).agg_select_mode
= AD_BANDWIDTH
;
1908 * bond_3ad_bind_slave - initialize a slave's port
1909 * @slave: slave struct to work on
1911 * Returns: 0 on success
1914 int bond_3ad_bind_slave(struct slave
*slave
)
1916 struct bonding
*bond
= bond_get_bond_by_slave(slave
);
1918 struct aggregator
*aggregator
;
1921 printk(KERN_ERR DRV_NAME
": %s: The slave %s is not attached to its bond\n",
1922 slave
->dev
->master
->name
, slave
->dev
->name
);
1926 //check that the slave has not been intialized yet.
1927 if (SLAVE_AD_INFO(slave
).port
.slave
!= slave
) {
1929 // port initialization
1930 port
= &(SLAVE_AD_INFO(slave
).port
);
1932 ad_initialize_port(port
, BOND_AD_INFO(bond
).lacp_fast
);
1934 port
->slave
= slave
;
1935 port
->actor_port_number
= SLAVE_AD_INFO(slave
).id
;
1936 // key is determined according to the link speed, duplex and user key(which is yet not supported)
1937 // ------------------------------------------------------------
1938 // Port key : | User key | Speed |Duplex|
1939 // ------------------------------------------------------------
1941 port
->actor_admin_port_key
= 0; // initialize this parameter
1942 port
->actor_admin_port_key
|= __get_duplex(port
);
1943 port
->actor_admin_port_key
|= (__get_link_speed(port
) << 1);
1944 port
->actor_oper_port_key
= port
->actor_admin_port_key
;
1945 // if the port is not full duplex, then the port should be not lacp Enabled
1946 if (!(port
->actor_oper_port_key
& AD_DUPLEX_KEY_BITS
)) {
1947 port
->sm_vars
&= ~AD_PORT_LACP_ENABLED
;
1949 // actor system is the bond's system
1950 port
->actor_system
= BOND_AD_INFO(bond
).system
.sys_mac_addr
;
1951 // tx timer(to verify that no more than MAX_TX_IN_SECOND lacpdu's are sent in one second)
1952 port
->sm_tx_timer_counter
= ad_ticks_per_sec
/AD_MAX_TX_IN_SECOND
;
1953 port
->aggregator
= NULL
;
1954 port
->next_port_in_aggregator
= NULL
;
1956 __disable_port(port
);
1957 __initialize_port_locks(port
);
1960 // aggregator initialization
1961 aggregator
= &(SLAVE_AD_INFO(slave
).aggregator
);
1963 ad_initialize_agg(aggregator
);
1965 aggregator
->aggregator_mac_address
= *((struct mac_addr
*)bond
->dev
->dev_addr
);
1966 aggregator
->aggregator_identifier
= (++aggregator_identifier
);
1967 aggregator
->slave
= slave
;
1968 aggregator
->is_active
= 0;
1969 aggregator
->num_of_ports
= 0;
1976 * bond_3ad_unbind_slave - deinitialize a slave's port
1977 * @slave: slave struct to work on
1979 * Search for the aggregator that is related to this port, remove the
1980 * aggregator and assign another aggregator for other port related to it
1981 * (if any), and remove the port.
1983 void bond_3ad_unbind_slave(struct slave
*slave
)
1985 struct port
*port
, *prev_port
, *temp_port
;
1986 struct aggregator
*aggregator
, *new_aggregator
, *temp_aggregator
;
1987 int select_new_active_agg
= 0;
1989 // find the aggregator related to this slave
1990 aggregator
= &(SLAVE_AD_INFO(slave
).aggregator
);
1992 // find the port related to this slave
1993 port
= &(SLAVE_AD_INFO(slave
).port
);
1995 // if slave is null, the whole port is not initialized
1997 printk(KERN_WARNING DRV_NAME
": Warning: %s: Trying to "
1998 "unbind an uninitialized port on %s\n",
1999 slave
->dev
->master
->name
, slave
->dev
->name
);
2003 dprintk("Unbinding Link Aggregation Group %d\n", aggregator
->aggregator_identifier
);
2005 /* Tell the partner that this port is not suitable for aggregation */
2006 port
->actor_oper_port_state
&= ~AD_STATE_AGGREGATION
;
2007 __update_lacpdu_from_port(port
);
2008 ad_lacpdu_send(port
);
2010 // check if this aggregator is occupied
2011 if (aggregator
->lag_ports
) {
2012 // check if there are other ports related to this aggregator except
2013 // the port related to this slave(thats ensure us that there is a
2014 // reason to search for new aggregator, and that we will find one
2015 if ((aggregator
->lag_ports
!= port
) || (aggregator
->lag_ports
->next_port_in_aggregator
)) {
2016 // find new aggregator for the related port(s)
2017 new_aggregator
= __get_first_agg(port
);
2018 for (; new_aggregator
; new_aggregator
= __get_next_agg(new_aggregator
)) {
2019 // if the new aggregator is empty, or it connected to to our port only
2020 if (!new_aggregator
->lag_ports
|| ((new_aggregator
->lag_ports
== port
) && !new_aggregator
->lag_ports
->next_port_in_aggregator
)) {
2024 // if new aggregator found, copy the aggregator's parameters
2025 // and connect the related lag_ports to the new aggregator
2026 if ((new_aggregator
) && ((!new_aggregator
->lag_ports
) || ((new_aggregator
->lag_ports
== port
) && !new_aggregator
->lag_ports
->next_port_in_aggregator
))) {
2027 dprintk("Some port(s) related to LAG %d - replaceing with LAG %d\n", aggregator
->aggregator_identifier
, new_aggregator
->aggregator_identifier
);
2029 if ((new_aggregator
->lag_ports
== port
) && new_aggregator
->is_active
) {
2030 printk(KERN_INFO DRV_NAME
": %s: Removing an active aggregator\n",
2031 aggregator
->slave
->dev
->master
->name
);
2032 // select new active aggregator
2033 select_new_active_agg
= 1;
2036 new_aggregator
->is_individual
= aggregator
->is_individual
;
2037 new_aggregator
->actor_admin_aggregator_key
= aggregator
->actor_admin_aggregator_key
;
2038 new_aggregator
->actor_oper_aggregator_key
= aggregator
->actor_oper_aggregator_key
;
2039 new_aggregator
->partner_system
= aggregator
->partner_system
;
2040 new_aggregator
->partner_system_priority
= aggregator
->partner_system_priority
;
2041 new_aggregator
->partner_oper_aggregator_key
= aggregator
->partner_oper_aggregator_key
;
2042 new_aggregator
->receive_state
= aggregator
->receive_state
;
2043 new_aggregator
->transmit_state
= aggregator
->transmit_state
;
2044 new_aggregator
->lag_ports
= aggregator
->lag_ports
;
2045 new_aggregator
->is_active
= aggregator
->is_active
;
2046 new_aggregator
->num_of_ports
= aggregator
->num_of_ports
;
2048 // update the information that is written on the ports about the aggregator
2049 for (temp_port
=aggregator
->lag_ports
; temp_port
; temp_port
=temp_port
->next_port_in_aggregator
) {
2050 temp_port
->aggregator
=new_aggregator
;
2051 temp_port
->actor_port_aggregator_identifier
= new_aggregator
->aggregator_identifier
;
2054 // clear the aggregator
2055 ad_clear_agg(aggregator
);
2057 if (select_new_active_agg
) {
2058 ad_agg_selection_logic(__get_first_agg(port
));
2061 printk(KERN_WARNING DRV_NAME
": %s: Warning: unbinding aggregator, "
2062 "and could not find a new aggregator for its ports\n",
2063 slave
->dev
->master
->name
);
2065 } else { // in case that the only port related to this aggregator is the one we want to remove
2066 select_new_active_agg
= aggregator
->is_active
;
2067 // clear the aggregator
2068 ad_clear_agg(aggregator
);
2069 if (select_new_active_agg
) {
2070 printk(KERN_INFO DRV_NAME
": %s: Removing an active aggregator\n",
2071 slave
->dev
->master
->name
);
2072 // select new active aggregator
2073 ad_agg_selection_logic(__get_first_agg(port
));
2078 dprintk("Unbinding port %d\n", port
->actor_port_number
);
2079 // find the aggregator that this port is connected to
2080 temp_aggregator
= __get_first_agg(port
);
2081 for (; temp_aggregator
; temp_aggregator
= __get_next_agg(temp_aggregator
)) {
2083 // search the port in the aggregator's related ports
2084 for (temp_port
=temp_aggregator
->lag_ports
; temp_port
; prev_port
=temp_port
, temp_port
=temp_port
->next_port_in_aggregator
) {
2085 if (temp_port
== port
) { // the aggregator found - detach the port from this aggregator
2087 prev_port
->next_port_in_aggregator
= temp_port
->next_port_in_aggregator
;
2089 temp_aggregator
->lag_ports
= temp_port
->next_port_in_aggregator
;
2091 temp_aggregator
->num_of_ports
--;
2092 if (temp_aggregator
->num_of_ports
==0) {
2093 select_new_active_agg
= temp_aggregator
->is_active
;
2094 // clear the aggregator
2095 ad_clear_agg(temp_aggregator
);
2096 if (select_new_active_agg
) {
2097 printk(KERN_INFO DRV_NAME
": %s: Removing an active aggregator\n",
2098 slave
->dev
->master
->name
);
2099 // select new active aggregator
2100 ad_agg_selection_logic(__get_first_agg(port
));
2111 * bond_3ad_state_machine_handler - handle state machines timeout
2112 * @bond: bonding struct to work on
2114 * The state machine handling concept in this module is to check every tick
2115 * which state machine should operate any function. The execution order is
2116 * round robin, so when we have an interaction between state machines, the
2117 * reply of one to each other might be delayed until next tick.
2119 * This function also complete the initialization when the agg_select_timer
2120 * times out, and it selects an aggregator for the ports that are yet not
2121 * related to any aggregator, and selects the active aggregator for a bond.
2123 void bond_3ad_state_machine_handler(struct bonding
*bond
)
2126 struct aggregator
*aggregator
;
2128 read_lock(&bond
->lock
);
2130 if (bond
->kill_timers
) {
2134 //check if there are any slaves
2135 if (bond
->slave_cnt
== 0) {
2139 // check if agg_select_timer timer after initialize is timed out
2140 if (BOND_AD_INFO(bond
).agg_select_timer
&& !(--BOND_AD_INFO(bond
).agg_select_timer
)) {
2141 // select the active aggregator for the bond
2142 if ((port
= __get_first_port(bond
))) {
2144 printk(KERN_WARNING DRV_NAME
": %s: Warning: bond's first port is "
2145 "uninitialized\n", bond
->dev
->name
);
2149 aggregator
= __get_first_agg(port
);
2150 ad_agg_selection_logic(aggregator
);
2154 // for each port run the state machines
2155 for (port
= __get_first_port(bond
); port
; port
= __get_next_port(port
)) {
2157 printk(KERN_WARNING DRV_NAME
": %s: Warning: Found an uninitialized "
2158 "port\n", bond
->dev
->name
);
2162 ad_rx_machine(NULL
, port
);
2163 ad_periodic_machine(port
);
2164 ad_port_selection_logic(port
);
2165 ad_mux_machine(port
);
2166 ad_tx_machine(port
);
2168 // turn off the BEGIN bit, since we already handled it
2169 if (port
->sm_vars
& AD_PORT_BEGIN
) {
2170 port
->sm_vars
&= ~AD_PORT_BEGIN
;
2175 mod_timer(&(BOND_AD_INFO(bond
).ad_timer
), jiffies
+ ad_delta_in_ticks
);
2177 read_unlock(&bond
->lock
);
2181 * bond_3ad_rx_indication - handle a received frame
2182 * @lacpdu: received lacpdu
2183 * @slave: slave struct to work on
2184 * @length: length of the data received
2186 * It is assumed that frames that were sent on this NIC don't returned as new
2187 * received frames (loopback). Since only the payload is given to this
2188 * function, it check for loopback.
2190 static void bond_3ad_rx_indication(struct lacpdu
*lacpdu
, struct slave
*slave
, u16 length
)
2194 if (length
>= sizeof(struct lacpdu
)) {
2196 port
= &(SLAVE_AD_INFO(slave
).port
);
2199 printk(KERN_WARNING DRV_NAME
": %s: Warning: port of slave %s is "
2200 "uninitialized\n", slave
->dev
->name
, slave
->dev
->master
->name
);
2204 switch (lacpdu
->subtype
) {
2205 case AD_TYPE_LACPDU
:
2206 __ntohs_lacpdu(lacpdu
);
2207 dprintk("Received LACPDU on port %d\n", port
->actor_port_number
);
2208 ad_rx_machine(lacpdu
, port
);
2211 case AD_TYPE_MARKER
:
2212 // No need to convert fields to Little Endian since we don't use the marker's fields.
2214 switch (((struct marker
*)lacpdu
)->tlv_type
) {
2215 case AD_MARKER_INFORMATION_SUBTYPE
:
2216 dprintk("Received Marker Information on port %d\n", port
->actor_port_number
);
2217 ad_marker_info_received((struct marker
*)lacpdu
, port
);
2220 case AD_MARKER_RESPONSE_SUBTYPE
:
2221 dprintk("Received Marker Response on port %d\n", port
->actor_port_number
);
2222 ad_marker_response_received((struct marker
*)lacpdu
, port
);
2226 dprintk("Received an unknown Marker subtype on slot %d\n", port
->actor_port_number
);
2233 * bond_3ad_adapter_speed_changed - handle a slave's speed change indication
2234 * @slave: slave struct to work on
2236 * Handle reselection of aggregator (if needed) for this port.
2238 void bond_3ad_adapter_speed_changed(struct slave
*slave
)
2242 port
= &(SLAVE_AD_INFO(slave
).port
);
2244 // if slave is null, the whole port is not initialized
2246 printk(KERN_WARNING DRV_NAME
": Warning: %s: speed "
2247 "changed for uninitialized port on %s\n",
2248 slave
->dev
->master
->name
, slave
->dev
->name
);
2252 port
->actor_admin_port_key
&= ~AD_SPEED_KEY_BITS
;
2253 port
->actor_oper_port_key
=port
->actor_admin_port_key
|= (__get_link_speed(port
) << 1);
2254 dprintk("Port %d changed speed\n", port
->actor_port_number
);
2255 // there is no need to reselect a new aggregator, just signal the
2256 // state machines to reinitialize
2257 port
->sm_vars
|= AD_PORT_BEGIN
;
2261 * bond_3ad_adapter_duplex_changed - handle a slave's duplex change indication
2262 * @slave: slave struct to work on
2264 * Handle reselection of aggregator (if needed) for this port.
2266 void bond_3ad_adapter_duplex_changed(struct slave
*slave
)
2270 port
=&(SLAVE_AD_INFO(slave
).port
);
2272 // if slave is null, the whole port is not initialized
2274 printk(KERN_WARNING DRV_NAME
": %s: Warning: duplex changed "
2275 "for uninitialized port on %s\n",
2276 slave
->dev
->master
->name
, slave
->dev
->name
);
2280 port
->actor_admin_port_key
&= ~AD_DUPLEX_KEY_BITS
;
2281 port
->actor_oper_port_key
=port
->actor_admin_port_key
|= __get_duplex(port
);
2282 dprintk("Port %d changed duplex\n", port
->actor_port_number
);
2283 // there is no need to reselect a new aggregator, just signal the
2284 // state machines to reinitialize
2285 port
->sm_vars
|= AD_PORT_BEGIN
;
2289 * bond_3ad_handle_link_change - handle a slave's link status change indication
2290 * @slave: slave struct to work on
2291 * @status: whether the link is now up or down
2293 * Handle reselection of aggregator (if needed) for this port.
2295 void bond_3ad_handle_link_change(struct slave
*slave
, char link
)
2299 port
= &(SLAVE_AD_INFO(slave
).port
);
2301 // if slave is null, the whole port is not initialized
2303 printk(KERN_WARNING DRV_NAME
": Warning: %s: link status changed for "
2304 "uninitialized port on %s\n",
2305 slave
->dev
->master
->name
, slave
->dev
->name
);
2309 // 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)
2310 // on link up we are forcing recheck on the duplex and speed since some of he adaptors(ce1000.lan) report
2311 if (link
== BOND_LINK_UP
) {
2312 port
->is_enabled
= 1;
2313 port
->actor_admin_port_key
&= ~AD_DUPLEX_KEY_BITS
;
2314 port
->actor_oper_port_key
=port
->actor_admin_port_key
|= __get_duplex(port
);
2315 port
->actor_admin_port_key
&= ~AD_SPEED_KEY_BITS
;
2316 port
->actor_oper_port_key
=port
->actor_admin_port_key
|= (__get_link_speed(port
) << 1);
2318 /* link has failed */
2319 port
->is_enabled
= 0;
2320 port
->actor_admin_port_key
&= ~AD_DUPLEX_KEY_BITS
;
2321 port
->actor_oper_port_key
= (port
->actor_admin_port_key
&= ~AD_SPEED_KEY_BITS
);
2323 //BOND_PRINT_DBG(("Port %d changed link status to %s", port->actor_port_number, ((link == BOND_LINK_UP)?"UP":"DOWN")));
2324 // there is no need to reselect a new aggregator, just signal the
2325 // state machines to reinitialize
2326 port
->sm_vars
|= AD_PORT_BEGIN
;
2330 * bond_3ad_get_active_agg_info - get information of the active aggregator
2331 * @bond: bonding struct to work on
2332 * @ad_info: ad_info struct to fill with the bond's info
2334 * Returns: 0 on success
2337 int bond_3ad_get_active_agg_info(struct bonding
*bond
, struct ad_info
*ad_info
)
2339 struct aggregator
*aggregator
= NULL
;
2342 for (port
= __get_first_port(bond
); port
; port
= __get_next_port(port
)) {
2343 if (port
->aggregator
&& port
->aggregator
->is_active
) {
2344 aggregator
= port
->aggregator
;
2350 ad_info
->aggregator_id
= aggregator
->aggregator_identifier
;
2351 ad_info
->ports
= aggregator
->num_of_ports
;
2352 ad_info
->actor_key
= aggregator
->actor_oper_aggregator_key
;
2353 ad_info
->partner_key
= aggregator
->partner_oper_aggregator_key
;
2354 memcpy(ad_info
->partner_system
, aggregator
->partner_system
.mac_addr_value
, ETH_ALEN
);
2361 int bond_3ad_xmit_xor(struct sk_buff
*skb
, struct net_device
*dev
)
2363 struct slave
*slave
, *start_at
;
2364 struct bonding
*bond
= dev
->priv
;
2369 struct ad_info ad_info
;
2372 /* make sure that the slaves list will
2373 * not change during tx
2375 read_lock(&bond
->lock
);
2377 if (!BOND_IS_OK(bond
)) {
2381 if (bond_3ad_get_active_agg_info(bond
, &ad_info
)) {
2382 printk(KERN_DEBUG DRV_NAME
": %s: Error: "
2383 "bond_3ad_get_active_agg_info failed\n", dev
->name
);
2387 slaves_in_agg
= ad_info
.ports
;
2388 agg_id
= ad_info
.aggregator_id
;
2390 if (slaves_in_agg
== 0) {
2391 /*the aggregator is empty*/
2392 printk(KERN_DEBUG DRV_NAME
": %s: Error: active "
2393 "aggregator is empty\n",
2398 slave_agg_no
= bond
->xmit_hash_policy(skb
, dev
, slaves_in_agg
);
2400 bond_for_each_slave(bond
, slave
, i
) {
2401 struct aggregator
*agg
= SLAVE_AD_INFO(slave
).port
.aggregator
;
2403 if (agg
&& (agg
->aggregator_identifier
== agg_id
)) {
2405 if (slave_agg_no
< 0) {
2411 if (slave_agg_no
>= 0) {
2412 printk(KERN_ERR DRV_NAME
": %s: Error: Couldn't find a slave to tx on "
2413 "for aggregator ID %d\n", dev
->name
, agg_id
);
2419 bond_for_each_slave_from(bond
, slave
, i
, start_at
) {
2420 int slave_agg_id
= 0;
2421 struct aggregator
*agg
= SLAVE_AD_INFO(slave
).port
.aggregator
;
2424 slave_agg_id
= agg
->aggregator_identifier
;
2427 if (SLAVE_IS_OK(slave
) && agg
&& (slave_agg_id
== agg_id
)) {
2428 res
= bond_dev_queue_xmit(bond
, skb
, slave
->dev
);
2435 /* no suitable interface, frame not sent */
2438 read_unlock(&bond
->lock
);
2442 int bond_3ad_lacpdu_recv(struct sk_buff
*skb
, struct net_device
*dev
, struct packet_type
* ptype
, struct net_device
*orig_dev
)
2444 struct bonding
*bond
= dev
->priv
;
2445 struct slave
*slave
= NULL
;
2446 int ret
= NET_RX_DROP
;
2448 if (!(dev
->flags
& IFF_MASTER
))
2451 read_lock(&bond
->lock
);
2452 slave
= bond_get_slave_by_dev((struct bonding
*)dev
->priv
, orig_dev
);
2456 bond_3ad_rx_indication((struct lacpdu
*) skb
->data
, slave
, skb
->len
);
2458 ret
= NET_RX_SUCCESS
;
2461 read_unlock(&bond
->lock
);