Lines Matching full:port

34 /* Port Variables definitions used by the State Machines (43.4.7 in the
49 /* Port Key definitions
53 * Port key | User key (10 bits) | Speed (5 bits) | Duplex|
93 static int ad_lacpdu_send(struct port *port);
94 static int ad_marker_send(struct port *port, struct bond_marker *marker);
95 static void ad_mux_machine(struct port *port, bool *update_slave_arr);
96 static void ad_rx_machine(struct lacpdu *lacpdu, struct port *port);
97 static void ad_tx_machine(struct port *port);
98 static void ad_periodic_machine(struct port *port, struct bond_params *bond_params);
99 static void ad_port_selection_logic(struct port *port, bool *update_slave_arr);
104 static void ad_initialize_port(struct port *port, int lacp_fast);
105 static void ad_enable_collecting(struct port *port);
106 static void ad_disable_distributing(struct port *port,
108 static void ad_enable_collecting_distributing(struct port *port,
110 static void ad_disable_collecting_distributing(struct port *port,
113 struct port *port);
115 struct port *port);
116 static void ad_update_actor_keys(struct port *port, bool reset);
122 * __get_bond_by_port - get the port's bonding struct
123 * @port: the port we're looking at
125 * Return @port's bonding struct, or %NULL if it can't be found.
127 static inline struct bonding *__get_bond_by_port(struct port *port) in __get_bond_by_port() argument
129 if (port->slave == NULL) in __get_bond_by_port()
132 return bond_get_bond_by_slave(port->slave); in __get_bond_by_port()
137 * @port: the port we're looking at
143 static inline struct aggregator *__get_first_agg(struct port *port) in __get_first_agg() argument
145 struct bonding *bond = __get_bond_by_port(port); in __get_first_agg()
149 /* If there's no bond for this port, or bond has no slaves */ in __get_first_agg()
174 * __disable_distributing_port - disable the port's slave for distributing.
175 * Port will still be able to collect.
176 * @port: the port we're looking at
178 * This will disable only distributing on the port's slave.
180 static void __disable_distributing_port(struct port *port) in __disable_distributing_port() argument
182 bond_set_slave_tx_disabled_flags(port->slave, BOND_SLAVE_NOTIFY_LATER); in __disable_distributing_port()
186 * __enable_collecting_port - enable the port's slave for collecting,
188 * @port: the port we're looking at
190 * This will enable only collecting on the port's slave.
192 static void __enable_collecting_port(struct port *port) in __enable_collecting_port() argument
194 struct slave *slave = port->slave; in __enable_collecting_port()
201 * __disable_port - disable the port's slave
202 * @port: the port we're looking at
204 * This will disable both collecting and distributing on the port's slave.
206 static inline void __disable_port(struct port *port) in __disable_port() argument
208 bond_set_slave_inactive_flags(port->slave, BOND_SLAVE_NOTIFY_LATER); in __disable_port()
212 * __enable_port - enable the port's slave, if it's up
213 * @port: the port we're looking at
215 * This will enable both collecting and distributing on the port's slave.
217 static inline void __enable_port(struct port *port) in __enable_port() argument
219 struct slave *slave = port->slave; in __enable_port()
226 * __port_move_to_attached_state - check if port should transition back to attached
228 * @port: the port we're looking at
230 static bool __port_move_to_attached_state(struct port *port) in __port_move_to_attached_state() argument
232 if (!(port->sm_vars & AD_PORT_SELECTED) || in __port_move_to_attached_state()
233 (port->sm_vars & AD_PORT_STANDBY) || in __port_move_to_attached_state()
234 !(port->partner_oper.port_state & LACP_STATE_SYNCHRONIZATION) || in __port_move_to_attached_state()
235 !(port->actor_oper_port_state & LACP_STATE_SYNCHRONIZATION)) in __port_move_to_attached_state()
236 port->sm_mux_state = AD_MUX_ATTACHED; in __port_move_to_attached_state()
238 return port->sm_mux_state == AD_MUX_ATTACHED; in __port_move_to_attached_state()
242 * __port_is_collecting_distributing - check if the port's slave is in the
244 * @port: the port we're looking at
246 static int __port_is_collecting_distributing(struct port *port) in __port_is_collecting_distributing() argument
248 return bond_is_active_slave(port->slave); in __port_is_collecting_distributing()
253 * @port: the port we're looking at
257 static inline u32 __get_agg_selection_mode(struct port *port) in __get_agg_selection_mode() argument
259 struct bonding *bond = __get_bond_by_port(port); in __get_agg_selection_mode()
269 * @port: the port we're looking at
271 static inline int __check_agg_selection_timer(struct port *port) in __check_agg_selection_timer() argument
273 struct bonding *bond = __get_bond_by_port(port); in __check_agg_selection_timer()
282 * __get_link_speed - get a port's speed
283 * @port: the port we're looking at
285 * Return @port's speed in 802.3ad enum format. i.e. one of:
304 static u16 __get_link_speed(struct port *port) in __get_link_speed() argument
306 struct slave *slave = port->slave; in __get_link_speed()
385 pr_err_once("%s: (slave %s): unknown ethtool speed (%d) for port %d (set it to 0)\n", in __get_link_speed()
388 port->actor_port_number); in __get_link_speed()
394 slave_dbg(slave->bond->dev, slave->dev, "Port %d Received link speed %d update from adapter\n", in __get_link_speed()
395 port->actor_port_number, speed); in __get_link_speed()
400 * __get_duplex - get a port's duplex
401 * @port: the port we're looking at
403 * Return @port's duplex in 802.3ad bitmask format. i.e.:
407 static u8 __get_duplex(struct port *port) in __get_duplex() argument
409 struct slave *slave = port->slave; in __get_duplex()
419 …slave_dbg(slave->bond->dev, slave->dev, "Port %d Received status full duplex update from adapter\n… in __get_duplex()
420 port->actor_port_number); in __get_duplex()
425 …slave_dbg(slave->bond->dev, slave->dev, "Port %d Received status NOT full duplex update from adapt… in __get_duplex()
426 port->actor_port_number); in __get_duplex()
433 static void __ad_actor_update_port(struct port *port) in __ad_actor_update_port() argument
435 const struct bonding *bond = bond_get_bond_by_slave(port->slave); in __ad_actor_update_port()
437 port->actor_system = BOND_AD_INFO(bond).system.sys_mac_addr; in __ad_actor_update_port()
438 port->actor_system_priority = BOND_AD_INFO(bond).system.sys_priority; in __ad_actor_update_port()
484 * __choose_matched - update a port's matched variable from a received lacpdu
486 * @port: the port we're looking at
506 static void __choose_matched(struct lacpdu *lacpdu, struct port *port) in __choose_matched() argument
512 if (((ntohs(lacpdu->partner_port) == port->actor_port_number) && in __choose_matched()
513 (ntohs(lacpdu->partner_port_priority) == port->actor_port_priority) && in __choose_matched()
514 MAC_ADDRESS_EQUAL(&(lacpdu->partner_system), &(port->actor_system)) && in __choose_matched()
515 (ntohs(lacpdu->partner_system_priority) == port->actor_system_priority) && in __choose_matched()
516 (ntohs(lacpdu->partner_key) == port->actor_oper_port_key) && in __choose_matched()
517 …((lacpdu->partner_state & LACP_STATE_AGGREGATION) == (port->actor_oper_port_state & LACP_STATE_AGG… in __choose_matched()
520 port->sm_vars |= AD_PORT_MATCHED; in __choose_matched()
522 port->sm_vars &= ~AD_PORT_MATCHED; in __choose_matched()
529 * @port: the port we're looking at
535 static void __record_pdu(struct lacpdu *lacpdu, struct port *port) in __record_pdu() argument
537 if (lacpdu && port) { in __record_pdu()
538 struct port_params *partner = &port->partner_oper; in __record_pdu()
540 __choose_matched(lacpdu, port); in __record_pdu()
552 port->actor_oper_port_state &= ~LACP_STATE_DEFAULTED; in __record_pdu()
555 * and the port is matched in __record_pdu()
557 if ((port->sm_vars & AD_PORT_MATCHED) && in __record_pdu()
560 slave_dbg(port->slave->bond->dev, port->slave->dev, in __record_pdu()
564 slave_dbg(port->slave->bond->dev, port->slave->dev, in __record_pdu()
572 * @port: the port we're looking at
578 static void __record_default(struct port *port) in __record_default() argument
580 if (port) { in __record_default()
582 memcpy(&port->partner_oper, &port->partner_admin, in __record_default()
586 port->actor_oper_port_state |= LACP_STATE_DEFAULTED; in __record_default()
591 * __update_selected - update a port's Selected variable from a received lacpdu
593 * @port: the port we're looking at
603 static void __update_selected(struct lacpdu *lacpdu, struct port *port) in __update_selected() argument
605 if (lacpdu && port) { in __update_selected()
606 const struct port_params *partner = &port->partner_oper; in __update_selected()
617 port->sm_vars &= ~AD_PORT_SELECTED; in __update_selected()
623 * __update_default_selected - update a port's Selected variable from Partner
624 * @port: the port we're looking at
634 static void __update_default_selected(struct port *port) in __update_default_selected() argument
636 if (port) { in __update_default_selected()
637 const struct port_params *admin = &port->partner_admin; in __update_default_selected()
638 const struct port_params *oper = &port->partner_oper; in __update_default_selected()
650 port->sm_vars &= ~AD_PORT_SELECTED; in __update_default_selected()
656 * __update_ntt - update a port's ntt variable from a received lacpdu
658 * @port: the port we're looking at
667 static void __update_ntt(struct lacpdu *lacpdu, struct port *port) in __update_ntt() argument
669 /* validate lacpdu and port */ in __update_ntt()
670 if (lacpdu && port) { in __update_ntt()
672 * update the port->ntt. in __update_ntt()
674 if ((ntohs(lacpdu->partner_port) != port->actor_port_number) || in __update_ntt()
675 (ntohs(lacpdu->partner_port_priority) != port->actor_port_priority) || in __update_ntt()
676 !MAC_ADDRESS_EQUAL(&(lacpdu->partner_system), &(port->actor_system)) || in __update_ntt()
677 (ntohs(lacpdu->partner_system_priority) != port->actor_system_priority) || in __update_ntt()
678 (ntohs(lacpdu->partner_key) != port->actor_oper_port_key) || in __update_ntt()
679 …((lacpdu->partner_state & LACP_STATE_LACP_ACTIVITY) != (port->actor_oper_port_state & LACP_STATE_L… in __update_ntt()
680 …((lacpdu->partner_state & LACP_STATE_LACP_TIMEOUT) != (port->actor_oper_port_state & LACP_STATE_LA… in __update_ntt()
681 …((lacpdu->partner_state & LACP_STATE_SYNCHRONIZATION) != (port->actor_oper_port_state & LACP_STATE… in __update_ntt()
682 …((lacpdu->partner_state & LACP_STATE_AGGREGATION) != (port->actor_oper_port_state & LACP_STATE_AGG… in __update_ntt()
684 port->ntt = true; in __update_ntt()
696 struct port *port; in __agg_ports_are_ready() local
703 for (port = aggregator->lag_ports; in __agg_ports_are_ready()
704 port; in __agg_ports_are_ready()
705 port = port->next_port_in_aggregator) { in __agg_ports_are_ready()
706 if (!(port->sm_vars & AD_PORT_READY_N)) { in __agg_ports_are_ready()
724 struct port *port; in __set_agg_ports_ready() local
726 for (port = aggregator->lag_ports; port; in __set_agg_ports_ready()
727 port = port->next_port_in_aggregator) { in __set_agg_ports_ready()
729 port->sm_vars |= AD_PORT_READY; in __set_agg_ports_ready()
731 port->sm_vars &= ~AD_PORT_READY; in __set_agg_ports_ready()
737 struct port *port; in __agg_active_ports() local
740 for (port = agg->lag_ports; port; in __agg_active_ports()
741 port = port->next_port_in_aggregator) { in __agg_active_ports()
742 if (port->is_enabled) in __agg_active_ports()
839 * __update_lacpdu_from_port - update a port's lacpdu fields
840 * @port: the port we're looking at
842 static inline void __update_lacpdu_from_port(struct port *port) in __update_lacpdu_from_port() argument
844 struct lacpdu *lacpdu = &port->lacpdu; in __update_lacpdu_from_port()
845 const struct port_params *partner = &port->partner_oper; in __update_lacpdu_from_port()
854 lacpdu->actor_system_priority = htons(port->actor_system_priority); in __update_lacpdu_from_port()
855 lacpdu->actor_system = port->actor_system; in __update_lacpdu_from_port()
856 lacpdu->actor_key = htons(port->actor_oper_port_key); in __update_lacpdu_from_port()
857 lacpdu->actor_port_priority = htons(port->actor_port_priority); in __update_lacpdu_from_port()
858 lacpdu->actor_port = htons(port->actor_port_number); in __update_lacpdu_from_port()
859 lacpdu->actor_state = port->actor_oper_port_state; in __update_lacpdu_from_port()
860 slave_dbg(port->slave->bond->dev, port->slave->dev, in __update_lacpdu_from_port()
861 "update lacpdu: actor port state %x\n", in __update_lacpdu_from_port()
862 port->actor_oper_port_state); in __update_lacpdu_from_port()
890 * ad_lacpdu_send - send out a lacpdu packet on a given port
891 * @port: the port we're looking at
896 static int ad_lacpdu_send(struct port *port) in ad_lacpdu_send() argument
898 struct slave *slave = port->slave; in ad_lacpdu_send()
925 lacpdu_header->lacpdu = port->lacpdu; in ad_lacpdu_send()
933 * ad_marker_send - send marker information/response on a given port
934 * @port: the port we're looking at
940 static int ad_marker_send(struct port *port, struct bond_marker *marker) in ad_marker_send() argument
942 struct slave *slave = port->slave; in ad_marker_send()
986 * ad_mux_machine - handle a port's mux state machine
987 * @port: the port we're looking at
990 static void ad_mux_machine(struct port *port, bool *update_slave_arr) in ad_mux_machine() argument
992 struct bonding *bond = __get_bond_by_port(port); in ad_mux_machine()
998 last_state = port->sm_mux_state; in ad_mux_machine()
1000 if (port->sm_vars & AD_PORT_BEGIN) { in ad_mux_machine()
1001 port->sm_mux_state = AD_MUX_DETACHED; in ad_mux_machine()
1003 switch (port->sm_mux_state) { in ad_mux_machine()
1005 if ((port->sm_vars & AD_PORT_SELECTED) in ad_mux_machine()
1006 || (port->sm_vars & AD_PORT_STANDBY)) in ad_mux_machine()
1008 port->sm_mux_state = AD_MUX_WAITING; in ad_mux_machine()
1012 if (!(port->sm_vars & AD_PORT_SELECTED)) { in ad_mux_machine()
1013 port->sm_vars &= ~AD_PORT_READY_N; in ad_mux_machine()
1019 __set_agg_ports_ready(port->aggregator, __agg_ports_are_ready(port->aggregator)); in ad_mux_machine()
1020 port->sm_mux_state = AD_MUX_DETACHED; in ad_mux_machine()
1025 if (port->sm_mux_timer_counter in ad_mux_machine()
1026 && !(--port->sm_mux_timer_counter)) in ad_mux_machine()
1027 port->sm_vars |= AD_PORT_READY_N; in ad_mux_machine()
1034 __set_agg_ports_ready(port->aggregator, __agg_ports_are_ready(port->aggregator)); in ad_mux_machine()
1036 /* if the wait_while_timer expired, and the port is in ad_mux_machine()
1039 if ((port->sm_vars & AD_PORT_READY) in ad_mux_machine()
1040 && !port->sm_mux_timer_counter) in ad_mux_machine()
1041 port->sm_mux_state = AD_MUX_ATTACHED; in ad_mux_machine()
1045 * edable port will take place only after this timer) in ad_mux_machine()
1047 if ((port->sm_vars & AD_PORT_SELECTED) && in ad_mux_machine()
1048 (port->partner_oper.port_state & LACP_STATE_SYNCHRONIZATION) && in ad_mux_machine()
1049 !__check_agg_selection_timer(port)) { in ad_mux_machine()
1050 if (port->aggregator->is_active) { in ad_mux_machine()
1055 port->sm_mux_state = state; in ad_mux_machine()
1057 } else if (!(port->sm_vars & AD_PORT_SELECTED) || in ad_mux_machine()
1058 (port->sm_vars & AD_PORT_STANDBY)) { in ad_mux_machine()
1060 port->sm_vars &= ~AD_PORT_READY_N; in ad_mux_machine()
1066 __set_agg_ports_ready(port->aggregator, __agg_ports_are_ready(port->aggregator)); in ad_mux_machine()
1067 port->sm_mux_state = AD_MUX_DETACHED; in ad_mux_machine()
1068 } else if (port->aggregator->is_active) { in ad_mux_machine()
1069 port->actor_oper_port_state |= in ad_mux_machine()
1074 if (!__port_move_to_attached_state(port)) { in ad_mux_machine()
1075 /* if port state hasn't changed make in ad_mux_machine()
1077 * port in an active aggregator is enabled in ad_mux_machine()
1079 if (port->aggregator->is_active && in ad_mux_machine()
1080 !__port_is_collecting_distributing(port)) { in ad_mux_machine()
1081 __enable_port(port); in ad_mux_machine()
1087 if (!__port_move_to_attached_state(port)) { in ad_mux_machine()
1088 if ((port->sm_vars & AD_PORT_SELECTED) && in ad_mux_machine()
1089 (port->partner_oper.port_state & LACP_STATE_SYNCHRONIZATION) && in ad_mux_machine()
1090 (port->partner_oper.port_state & LACP_STATE_COLLECTING)) { in ad_mux_machine()
1091 port->sm_mux_state = AD_MUX_DISTRIBUTING; in ad_mux_machine()
1093 /* If port state hasn't changed, make sure that a collecting in ad_mux_machine()
1094 * port is enabled for an active aggregator. in ad_mux_machine()
1096 struct slave *slave = port->slave; in ad_mux_machine()
1098 if (port->aggregator->is_active && in ad_mux_machine()
1100 ad_enable_collecting(port); in ad_mux_machine()
1107 if (!(port->sm_vars & AD_PORT_SELECTED) || in ad_mux_machine()
1108 (port->sm_vars & AD_PORT_STANDBY) || in ad_mux_machine()
1109 !(port->partner_oper.port_state & LACP_STATE_COLLECTING) || in ad_mux_machine()
1110 !(port->partner_oper.port_state & LACP_STATE_SYNCHRONIZATION) || in ad_mux_machine()
1111 !(port->actor_oper_port_state & LACP_STATE_SYNCHRONIZATION)) { in ad_mux_machine()
1112 port->sm_mux_state = AD_MUX_COLLECTING; in ad_mux_machine()
1114 /* if port state hasn't changed make in ad_mux_machine()
1116 * port in an active aggregator is enabled in ad_mux_machine()
1118 if (port->aggregator && in ad_mux_machine()
1119 port->aggregator->is_active && in ad_mux_machine()
1120 !__port_is_collecting_distributing(port)) { in ad_mux_machine()
1121 __enable_port(port); in ad_mux_machine()
1132 if (port->sm_mux_state != last_state) { in ad_mux_machine()
1133 slave_dbg(port->slave->bond->dev, port->slave->dev, in ad_mux_machine()
1134 "Mux Machine: Port=%d, Last State=%d, Curr State=%d\n", in ad_mux_machine()
1135 port->actor_port_number, in ad_mux_machine()
1137 port->sm_mux_state); in ad_mux_machine()
1138 switch (port->sm_mux_state) { in ad_mux_machine()
1140 port->actor_oper_port_state &= ~LACP_STATE_SYNCHRONIZATION; in ad_mux_machine()
1141 ad_disable_collecting_distributing(port, in ad_mux_machine()
1143 port->actor_oper_port_state &= ~LACP_STATE_COLLECTING; in ad_mux_machine()
1144 port->actor_oper_port_state &= ~LACP_STATE_DISTRIBUTING; in ad_mux_machine()
1145 port->ntt = true; in ad_mux_machine()
1148 port->sm_mux_timer_counter = __ad_timer_to_ticks(AD_WAIT_WHILE_TIMER, 0); in ad_mux_machine()
1151 if (port->aggregator->is_active) in ad_mux_machine()
1152 port->actor_oper_port_state |= in ad_mux_machine()
1155 port->actor_oper_port_state &= in ad_mux_machine()
1157 port->actor_oper_port_state &= ~LACP_STATE_COLLECTING; in ad_mux_machine()
1158 port->actor_oper_port_state &= ~LACP_STATE_DISTRIBUTING; in ad_mux_machine()
1159 ad_disable_collecting_distributing(port, in ad_mux_machine()
1161 port->ntt = true; in ad_mux_machine()
1164 port->actor_oper_port_state |= LACP_STATE_COLLECTING; in ad_mux_machine()
1165 port->actor_oper_port_state |= LACP_STATE_DISTRIBUTING; in ad_mux_machine()
1166 port->actor_oper_port_state |= LACP_STATE_SYNCHRONIZATION; in ad_mux_machine()
1167 ad_enable_collecting_distributing(port, in ad_mux_machine()
1169 port->ntt = true; in ad_mux_machine()
1172 port->actor_oper_port_state |= LACP_STATE_COLLECTING; in ad_mux_machine()
1173 port->actor_oper_port_state &= ~LACP_STATE_DISTRIBUTING; in ad_mux_machine()
1174 port->actor_oper_port_state |= LACP_STATE_SYNCHRONIZATION; in ad_mux_machine()
1175 ad_enable_collecting(port); in ad_mux_machine()
1176 ad_disable_distributing(port, update_slave_arr); in ad_mux_machine()
1177 port->ntt = true; in ad_mux_machine()
1180 port->actor_oper_port_state |= LACP_STATE_DISTRIBUTING; in ad_mux_machine()
1181 port->actor_oper_port_state |= LACP_STATE_SYNCHRONIZATION; in ad_mux_machine()
1182 ad_enable_collecting_distributing(port, in ad_mux_machine()
1192 * ad_rx_machine - handle a port's rx State Machine
1194 * @port: the port we're looking at
1200 static void ad_rx_machine(struct lacpdu *lacpdu, struct port *port) in ad_rx_machine() argument
1207 last_state = port->sm_rx_state; in ad_rx_machine()
1210 atomic64_inc(&SLAVE_AD_INFO(port->slave)->stats.lacpdu_rx); in ad_rx_machine()
1211 atomic64_inc(&BOND_AD_INFO(port->slave->bond).stats.lacpdu_rx); in ad_rx_machine()
1215 /* first, check if port was reinitialized */ in ad_rx_machine()
1216 if (port->sm_vars & AD_PORT_BEGIN) { in ad_rx_machine()
1217 port->sm_rx_state = AD_RX_INITIALIZE; in ad_rx_machine()
1218 port->sm_vars |= AD_PORT_CHURNED; in ad_rx_machine()
1219 /* check if port is not enabled */ in ad_rx_machine()
1220 } else if (!(port->sm_vars & AD_PORT_BEGIN) && !port->is_enabled) in ad_rx_machine()
1221 port->sm_rx_state = AD_RX_PORT_DISABLED; in ad_rx_machine()
1223 else if (lacpdu && ((port->sm_rx_state == AD_RX_EXPIRED) || in ad_rx_machine()
1224 (port->sm_rx_state == AD_RX_DEFAULTED) || in ad_rx_machine()
1225 (port->sm_rx_state == AD_RX_CURRENT))) { in ad_rx_machine()
1226 if (port->sm_rx_state != AD_RX_CURRENT) in ad_rx_machine()
1227 port->sm_vars |= AD_PORT_CHURNED; in ad_rx_machine()
1228 port->sm_rx_timer_counter = 0; in ad_rx_machine()
1229 port->sm_rx_state = AD_RX_CURRENT; in ad_rx_machine()
1232 if (port->sm_rx_timer_counter && in ad_rx_machine()
1233 !(--port->sm_rx_timer_counter)) { in ad_rx_machine()
1234 switch (port->sm_rx_state) { in ad_rx_machine()
1236 port->sm_rx_state = AD_RX_DEFAULTED; in ad_rx_machine()
1239 port->sm_rx_state = AD_RX_EXPIRED; in ad_rx_machine()
1246 switch (port->sm_rx_state) { in ad_rx_machine()
1248 if (port->is_enabled && in ad_rx_machine()
1249 (port->sm_vars & AD_PORT_LACP_ENABLED)) in ad_rx_machine()
1250 port->sm_rx_state = AD_RX_EXPIRED; in ad_rx_machine()
1251 else if (port->is_enabled in ad_rx_machine()
1252 && ((port->sm_vars in ad_rx_machine()
1254 port->sm_rx_state = AD_RX_LACP_DISABLED; in ad_rx_machine()
1264 if ((port->sm_rx_state != last_state) || (lacpdu)) { in ad_rx_machine()
1265 slave_dbg(port->slave->bond->dev, port->slave->dev, in ad_rx_machine()
1266 "Rx Machine: Port=%d, Last State=%d, Curr State=%d\n", in ad_rx_machine()
1267 port->actor_port_number, in ad_rx_machine()
1269 port->sm_rx_state); in ad_rx_machine()
1270 switch (port->sm_rx_state) { in ad_rx_machine()
1272 if (!(port->actor_oper_port_key & AD_DUPLEX_KEY_MASKS)) in ad_rx_machine()
1273 port->sm_vars &= ~AD_PORT_LACP_ENABLED; in ad_rx_machine()
1275 port->sm_vars |= AD_PORT_LACP_ENABLED; in ad_rx_machine()
1276 port->sm_vars &= ~AD_PORT_SELECTED; in ad_rx_machine()
1277 __record_default(port); in ad_rx_machine()
1278 port->actor_oper_port_state &= ~LACP_STATE_EXPIRED; in ad_rx_machine()
1279 port->sm_rx_state = AD_RX_PORT_DISABLED; in ad_rx_machine()
1283 port->sm_vars &= ~AD_PORT_MATCHED; in ad_rx_machine()
1286 port->sm_vars &= ~AD_PORT_SELECTED; in ad_rx_machine()
1287 __record_default(port); in ad_rx_machine()
1288 port->partner_oper.port_state &= ~LACP_STATE_AGGREGATION; in ad_rx_machine()
1289 port->sm_vars |= AD_PORT_MATCHED; in ad_rx_machine()
1290 port->actor_oper_port_state &= ~LACP_STATE_EXPIRED; in ad_rx_machine()
1294 * This reset cause to disable this port in the in ad_rx_machine()
1297 * the port. in ad_rx_machine()
1299 port->partner_oper.port_state &= ~LACP_STATE_SYNCHRONIZATION; in ad_rx_machine()
1300 port->sm_vars &= ~AD_PORT_MATCHED; in ad_rx_machine()
1301 port->partner_oper.port_state |= LACP_STATE_LACP_TIMEOUT; in ad_rx_machine()
1302 port->partner_oper.port_state |= LACP_STATE_LACP_ACTIVITY; in ad_rx_machine()
1303 port->sm_rx_timer_counter = __ad_timer_to_ticks(AD_CURRENT_WHILE_TIMER, (u16)(AD_SHORT_TIMEOUT)); in ad_rx_machine()
1304 port->actor_oper_port_state |= LACP_STATE_EXPIRED; in ad_rx_machine()
1305 port->sm_vars |= AD_PORT_CHURNED; in ad_rx_machine()
1308 __update_default_selected(port); in ad_rx_machine()
1309 __record_default(port); in ad_rx_machine()
1310 port->sm_vars |= AD_PORT_MATCHED; in ad_rx_machine()
1311 port->actor_oper_port_state &= ~LACP_STATE_EXPIRED; in ad_rx_machine()
1316 &(port->actor_system))) { in ad_rx_machine()
1317 slave_err(port->slave->bond->dev, port->slave->dev, "An illegal loopback occurred on slave\n" in ad_rx_machine()
1321 __update_selected(lacpdu, port); in ad_rx_machine()
1322 __update_ntt(lacpdu, port); in ad_rx_machine()
1323 __record_pdu(lacpdu, port); in ad_rx_machine()
1324port->sm_rx_timer_counter = __ad_timer_to_ticks(AD_CURRENT_WHILE_TIMER, (u16)(port->actor_oper_por… in ad_rx_machine()
1325 port->actor_oper_port_state &= ~LACP_STATE_EXPIRED; in ad_rx_machine()
1334 * ad_churn_machine - handle port churn's state machine
1335 * @port: the port we're looking at
1338 static void ad_churn_machine(struct port *port) in ad_churn_machine() argument
1340 if (port->sm_vars & AD_PORT_CHURNED) { in ad_churn_machine()
1341 port->sm_vars &= ~AD_PORT_CHURNED; in ad_churn_machine()
1342 port->sm_churn_actor_state = AD_CHURN_MONITOR; in ad_churn_machine()
1343 port->sm_churn_partner_state = AD_CHURN_MONITOR; in ad_churn_machine()
1344 port->sm_churn_actor_timer_counter = in ad_churn_machine()
1346 port->sm_churn_partner_timer_counter = in ad_churn_machine()
1350 if (port->sm_churn_actor_timer_counter && in ad_churn_machine()
1351 !(--port->sm_churn_actor_timer_counter) && in ad_churn_machine()
1352 port->sm_churn_actor_state == AD_CHURN_MONITOR) { in ad_churn_machine()
1353 if (port->actor_oper_port_state & LACP_STATE_SYNCHRONIZATION) { in ad_churn_machine()
1354 port->sm_churn_actor_state = AD_NO_CHURN; in ad_churn_machine()
1356 port->churn_actor_count++; in ad_churn_machine()
1357 port->sm_churn_actor_state = AD_CHURN; in ad_churn_machine()
1360 if (port->sm_churn_partner_timer_counter && in ad_churn_machine()
1361 !(--port->sm_churn_partner_timer_counter) && in ad_churn_machine()
1362 port->sm_churn_partner_state == AD_CHURN_MONITOR) { in ad_churn_machine()
1363 if (port->partner_oper.port_state & LACP_STATE_SYNCHRONIZATION) { in ad_churn_machine()
1364 port->sm_churn_partner_state = AD_NO_CHURN; in ad_churn_machine()
1366 port->churn_partner_count++; in ad_churn_machine()
1367 port->sm_churn_partner_state = AD_CHURN; in ad_churn_machine()
1373 * ad_tx_machine - handle a port's tx state machine
1374 * @port: the port we're looking at
1376 static void ad_tx_machine(struct port *port) in ad_tx_machine() argument
1381 if (port->sm_tx_timer_counter && !(--port->sm_tx_timer_counter)) { in ad_tx_machine()
1383 if (port->ntt && (port->sm_vars & AD_PORT_LACP_ENABLED)) { in ad_tx_machine()
1384 __update_lacpdu_from_port(port); in ad_tx_machine()
1386 if (ad_lacpdu_send(port) >= 0) { in ad_tx_machine()
1387 slave_dbg(port->slave->bond->dev, in ad_tx_machine()
1388 port->slave->dev, in ad_tx_machine()
1389 "Sent LACPDU on port %d\n", in ad_tx_machine()
1390 port->actor_port_number); in ad_tx_machine()
1395 port->ntt = false; in ad_tx_machine()
1401 port->sm_tx_timer_counter = ad_ticks_per_sec/AD_MAX_TX_IN_SECOND; in ad_tx_machine()
1406 * ad_periodic_machine - handle a port's periodic state machine
1407 * @port: the port we're looking at
1412 static void ad_periodic_machine(struct port *port, struct bond_params *bond_params) in ad_periodic_machine() argument
1417 last_state = port->sm_periodic_state; in ad_periodic_machine()
1419 /* check if port was reinitialized */ in ad_periodic_machine()
1420 …if (((port->sm_vars & AD_PORT_BEGIN) || !(port->sm_vars & AD_PORT_LACP_ENABLED) || !port->is_enabl… in ad_periodic_machine()
1421 …(!(port->actor_oper_port_state & LACP_STATE_LACP_ACTIVITY) && !(port->partner_oper.port_state & LA… in ad_periodic_machine()
1423 port->sm_periodic_state = AD_NO_PERIODIC; in ad_periodic_machine()
1426 else if (port->sm_periodic_timer_counter) { in ad_periodic_machine()
1428 if (!(--port->sm_periodic_timer_counter)) { in ad_periodic_machine()
1430 port->sm_periodic_state = AD_PERIODIC_TX; in ad_periodic_machine()
1435 switch (port->sm_periodic_state) { in ad_periodic_machine()
1437 if (!(port->partner_oper.port_state in ad_periodic_machine()
1439 port->sm_periodic_state = AD_SLOW_PERIODIC; in ad_periodic_machine()
1442 if ((port->partner_oper.port_state & LACP_STATE_LACP_TIMEOUT)) { in ad_periodic_machine()
1443 port->sm_periodic_timer_counter = 0; in ad_periodic_machine()
1444 port->sm_periodic_state = AD_PERIODIC_TX; in ad_periodic_machine()
1452 switch (port->sm_periodic_state) { in ad_periodic_machine()
1454 port->sm_periodic_state = AD_FAST_PERIODIC; in ad_periodic_machine()
1457 if (!(port->partner_oper.port_state & in ad_periodic_machine()
1459 port->sm_periodic_state = AD_SLOW_PERIODIC; in ad_periodic_machine()
1461 port->sm_periodic_state = AD_FAST_PERIODIC; in ad_periodic_machine()
1469 if (port->sm_periodic_state != last_state) { in ad_periodic_machine()
1470 slave_dbg(port->slave->bond->dev, port->slave->dev, in ad_periodic_machine()
1471 "Periodic Machine: Port=%d, Last State=%d, Curr State=%d\n", in ad_periodic_machine()
1472 port->actor_port_number, last_state, in ad_periodic_machine()
1473 port->sm_periodic_state); in ad_periodic_machine()
1474 switch (port->sm_periodic_state) { in ad_periodic_machine()
1476 port->sm_periodic_timer_counter = 0; in ad_periodic_machine()
1480port->sm_periodic_timer_counter = __ad_timer_to_ticks(AD_PERIODIC_TIMER, (u16)(AD_FAST_PERIODIC_TI… in ad_periodic_machine()
1484port->sm_periodic_timer_counter = __ad_timer_to_ticks(AD_PERIODIC_TIMER, (u16)(AD_SLOW_PERIODIC_TI… in ad_periodic_machine()
1487 port->ntt = true; in ad_periodic_machine()
1497 * @port: the port we're looking at
1500 * Select aggregation groups, and assign each port for it's aggregetor. The
1504 static void ad_port_selection_logic(struct port *port, bool *update_slave_arr) in ad_port_selection_logic() argument
1507 struct port *last_port = NULL, *curr_port; in ad_port_selection_logic()
1513 /* if the port is already Selected, do nothing */ in ad_port_selection_logic()
1514 if (port->sm_vars & AD_PORT_SELECTED) in ad_port_selection_logic()
1517 bond = __get_bond_by_port(port); in ad_port_selection_logic()
1519 /* if the port is connected to other aggregator, detach it */ in ad_port_selection_logic()
1520 if (port->aggregator) { in ad_port_selection_logic()
1521 /* detach the port from its former aggregator */ in ad_port_selection_logic()
1522 temp_aggregator = port->aggregator; in ad_port_selection_logic()
1526 if (curr_port == port) { in ad_port_selection_logic()
1528 /* if it is the first port attached to the in ad_port_selection_logic()
1533 port->next_port_in_aggregator; in ad_port_selection_logic()
1535 /* not the first port attached to the in ad_port_selection_logic()
1539 port->next_port_in_aggregator; in ad_port_selection_logic()
1542 /* clear the port's relations to this in ad_port_selection_logic()
1545 port->aggregator = NULL; in ad_port_selection_logic()
1546 port->next_port_in_aggregator = NULL; in ad_port_selection_logic()
1547 port->actor_port_aggregator_identifier = 0; in ad_port_selection_logic()
1549 slave_dbg(bond->dev, port->slave->dev, "Port %d left LAG %d\n", in ad_port_selection_logic()
1550 port->actor_port_number, in ad_port_selection_logic()
1561 /* meaning: the port was related to an aggregator in ad_port_selection_logic()
1562 * but was not on the aggregator port list in ad_port_selection_logic()
1564 …et_warn_ratelimited("%s: (slave %s): Warning: Port %d was related to aggregator %d but was not on … in ad_port_selection_logic()
1565 port->slave->bond->dev->name, in ad_port_selection_logic()
1566 port->slave->dev->name, in ad_port_selection_logic()
1567 port->actor_port_number, in ad_port_selection_logic()
1568 port->aggregator->aggregator_identifier); in ad_port_selection_logic()
1571 /* search on all aggregators for a suitable aggregator for this port */ in ad_port_selection_logic()
1582 …if (((aggregator->actor_oper_aggregator_key == port->actor_oper_port_key) && /* if all parameters … in ad_port_selection_logic()
1583 MAC_ADDRESS_EQUAL(&(aggregator->partner_system), &(port->partner_oper.system)) && in ad_port_selection_logic()
1584 (aggregator->partner_system_priority == port->partner_oper.system_priority) && in ad_port_selection_logic()
1585 (aggregator->partner_oper_aggregator_key == port->partner_oper.key) in ad_port_selection_logic()
1592 port->aggregator = aggregator; in ad_port_selection_logic()
1593 port->actor_port_aggregator_identifier = in ad_port_selection_logic()
1594 port->aggregator->aggregator_identifier; in ad_port_selection_logic()
1595 port->next_port_in_aggregator = aggregator->lag_ports; in ad_port_selection_logic()
1596 port->aggregator->num_of_ports++; in ad_port_selection_logic()
1597 aggregator->lag_ports = port; in ad_port_selection_logic()
1598 slave_dbg(bond->dev, slave->dev, "Port %d joined LAG %d (existing LAG)\n", in ad_port_selection_logic()
1599 port->actor_port_number, in ad_port_selection_logic()
1600 port->aggregator->aggregator_identifier); in ad_port_selection_logic()
1602 /* mark this port as selected */ in ad_port_selection_logic()
1603 port->sm_vars |= AD_PORT_SELECTED; in ad_port_selection_logic()
1609 /* the port couldn't find an aggregator - attach it to a new in ad_port_selection_logic()
1614 /* assign port a new aggregator */ in ad_port_selection_logic()
1615 port->aggregator = free_aggregator; in ad_port_selection_logic()
1616 port->actor_port_aggregator_identifier = in ad_port_selection_logic()
1617 port->aggregator->aggregator_identifier; in ad_port_selection_logic()
1620 * if port was responsed from the end-user in ad_port_selection_logic()
1622 if (port->actor_oper_port_key & AD_DUPLEX_KEY_MASKS) in ad_port_selection_logic()
1623 /* if port is full duplex */ in ad_port_selection_logic()
1624 port->aggregator->is_individual = false; in ad_port_selection_logic()
1626 port->aggregator->is_individual = true; in ad_port_selection_logic()
1628 port->aggregator->actor_admin_aggregator_key = in ad_port_selection_logic()
1629 port->actor_admin_port_key; in ad_port_selection_logic()
1630 port->aggregator->actor_oper_aggregator_key = in ad_port_selection_logic()
1631 port->actor_oper_port_key; in ad_port_selection_logic()
1632 port->aggregator->partner_system = in ad_port_selection_logic()
1633 port->partner_oper.system; in ad_port_selection_logic()
1634 port->aggregator->partner_system_priority = in ad_port_selection_logic()
1635 port->partner_oper.system_priority; in ad_port_selection_logic()
1636 port->aggregator->partner_oper_aggregator_key = port->partner_oper.key; in ad_port_selection_logic()
1637 port->aggregator->receive_state = 1; in ad_port_selection_logic()
1638 port->aggregator->transmit_state = 1; in ad_port_selection_logic()
1639 port->aggregator->lag_ports = port; in ad_port_selection_logic()
1640 port->aggregator->num_of_ports++; in ad_port_selection_logic()
1642 /* mark this port as selected */ in ad_port_selection_logic()
1643 port->sm_vars |= AD_PORT_SELECTED; in ad_port_selection_logic()
1645 slave_dbg(bond->dev, port->slave->dev, "Port %d joined LAG %d (new LAG)\n", in ad_port_selection_logic()
1646 port->actor_port_number, in ad_port_selection_logic()
1647 port->aggregator->aggregator_identifier); in ad_port_selection_logic()
1649 slave_err(bond->dev, port->slave->dev, in ad_port_selection_logic()
1650 "Port %d did not find a suitable aggregator\n", in ad_port_selection_logic()
1651 port->actor_port_number); in ad_port_selection_logic()
1659 __set_agg_ports_ready(port->aggregator, in ad_port_selection_logic()
1660 __agg_ports_are_ready(port->aggregator)); in ad_port_selection_logic()
1662 aggregator = __get_first_agg(port); in ad_port_selection_logic()
1665 if (!port->aggregator->is_active) in ad_port_selection_logic()
1666 port->actor_oper_port_state &= ~LACP_STATE_SYNCHRONIZATION; in ad_port_selection_logic()
1743 struct port *port = agg->lag_ports; in agg_device_up() local
1745 if (!port) in agg_device_up()
1748 for (port = agg->lag_ports; port; in agg_device_up()
1749 port = port->next_port_in_aggregator) { in agg_device_up()
1750 if (netif_running(port->slave->dev) && in agg_device_up()
1751 netif_carrier_ok(port->slave->dev)) in agg_device_up()
1791 struct port *port; in ad_agg_selection_logic() local
1874 for (port = active->lag_ports; port; in ad_agg_selection_logic()
1875 port = port->next_port_in_aggregator) { in ad_agg_selection_logic()
1876 __disable_port(port); in ad_agg_selection_logic()
1890 for (port = active->lag_ports; port; in ad_agg_selection_logic()
1891 port = port->next_port_in_aggregator) { in ad_agg_selection_logic()
1892 __enable_port(port); in ad_agg_selection_logic()
1944 * ad_initialize_port - initialize a given port's parameters
1945 * @port: the port we're looking at
1948 static void ad_initialize_port(struct port *port, int lacp_fast) in ad_initialize_port() argument
1969 if (port) { in ad_initialize_port()
1970 port->actor_port_priority = 0xff; in ad_initialize_port()
1971 port->actor_port_aggregator_identifier = 0; in ad_initialize_port()
1972 port->ntt = false; in ad_initialize_port()
1973 port->actor_admin_port_state = LACP_STATE_AGGREGATION | in ad_initialize_port()
1975 port->actor_oper_port_state = LACP_STATE_AGGREGATION | in ad_initialize_port()
1979 port->actor_oper_port_state |= LACP_STATE_LACP_TIMEOUT; in ad_initialize_port()
1981 memcpy(&port->partner_admin, &tmpl, sizeof(tmpl)); in ad_initialize_port()
1982 memcpy(&port->partner_oper, &tmpl, sizeof(tmpl)); in ad_initialize_port()
1984 port->is_enabled = true; in ad_initialize_port()
1986 port->sm_vars = AD_PORT_BEGIN | AD_PORT_LACP_ENABLED; in ad_initialize_port()
1987 port->sm_rx_state = 0; in ad_initialize_port()
1988 port->sm_rx_timer_counter = 0; in ad_initialize_port()
1989 port->sm_periodic_state = 0; in ad_initialize_port()
1990 port->sm_periodic_timer_counter = 0; in ad_initialize_port()
1991 port->sm_mux_state = 0; in ad_initialize_port()
1992 port->sm_mux_timer_counter = 0; in ad_initialize_port()
1993 port->sm_tx_state = 0; in ad_initialize_port()
1994 port->aggregator = NULL; in ad_initialize_port()
1995 port->next_port_in_aggregator = NULL; in ad_initialize_port()
1996 port->transaction_id = 0; in ad_initialize_port()
1998 port->sm_churn_actor_timer_counter = 0; in ad_initialize_port()
1999 port->sm_churn_actor_state = 0; in ad_initialize_port()
2000 port->churn_actor_count = 0; in ad_initialize_port()
2001 port->sm_churn_partner_timer_counter = 0; in ad_initialize_port()
2002 port->sm_churn_partner_state = 0; in ad_initialize_port()
2003 port->churn_partner_count = 0; in ad_initialize_port()
2005 memcpy(&port->lacpdu, &lacpdu, sizeof(lacpdu)); in ad_initialize_port()
2010 * ad_enable_collecting - enable a port's receive
2011 * @port: the port we're looking at
2013 * Enable @port if it's in an active aggregator
2015 static void ad_enable_collecting(struct port *port) in ad_enable_collecting() argument
2017 if (port->aggregator->is_active) { in ad_enable_collecting()
2018 struct slave *slave = port->slave; in ad_enable_collecting()
2021 "Enabling collecting on port %d (LAG %d)\n", in ad_enable_collecting()
2022 port->actor_port_number, in ad_enable_collecting()
2023 port->aggregator->aggregator_identifier); in ad_enable_collecting()
2024 __enable_collecting_port(port); in ad_enable_collecting()
2029 * ad_disable_distributing - disable a port's transmit
2030 * @port: the port we're looking at
2033 static void ad_disable_distributing(struct port *port, bool *update_slave_arr) in ad_disable_distributing() argument
2035 if (port->aggregator && __agg_has_partner(port->aggregator)) { in ad_disable_distributing()
2036 slave_dbg(port->slave->bond->dev, port->slave->dev, in ad_disable_distributing()
2037 "Disabling distributing on port %d (LAG %d)\n", in ad_disable_distributing()
2038 port->actor_port_number, in ad_disable_distributing()
2039 port->aggregator->aggregator_identifier); in ad_disable_distributing()
2040 __disable_distributing_port(port); in ad_disable_distributing()
2047 * ad_enable_collecting_distributing - enable a port's transmit/receive
2048 * @port: the port we're looking at
2051 * Enable @port if it's in an active aggregator
2053 static void ad_enable_collecting_distributing(struct port *port, in ad_enable_collecting_distributing() argument
2056 if (port->aggregator->is_active) { in ad_enable_collecting_distributing()
2057 slave_dbg(port->slave->bond->dev, port->slave->dev, in ad_enable_collecting_distributing()
2058 "Enabling port %d (LAG %d)\n", in ad_enable_collecting_distributing()
2059 port->actor_port_number, in ad_enable_collecting_distributing()
2060 port->aggregator->aggregator_identifier); in ad_enable_collecting_distributing()
2061 __enable_port(port); in ad_enable_collecting_distributing()
2068 * ad_disable_collecting_distributing - disable a port's transmit/receive
2069 * @port: the port we're looking at
2072 static void ad_disable_collecting_distributing(struct port *port, in ad_disable_collecting_distributing() argument
2075 if (port->aggregator && __agg_has_partner(port->aggregator)) { in ad_disable_collecting_distributing()
2076 slave_dbg(port->slave->bond->dev, port->slave->dev, in ad_disable_collecting_distributing()
2077 "Disabling port %d (LAG %d)\n", in ad_disable_collecting_distributing()
2078 port->actor_port_number, in ad_disable_collecting_distributing()
2079 port->aggregator->aggregator_identifier); in ad_disable_collecting_distributing()
2080 __disable_port(port); in ad_disable_collecting_distributing()
2089 * @port: the port we're looking at
2092 struct port *port) in ad_marker_info_received() argument
2096 atomic64_inc(&SLAVE_AD_INFO(port->slave)->stats.marker_rx); in ad_marker_info_received()
2097 atomic64_inc(&BOND_AD_INFO(port->slave->bond).stats.marker_rx); in ad_marker_info_received()
2105 if (ad_marker_send(port, &marker) >= 0) in ad_marker_info_received()
2106 slave_dbg(port->slave->bond->dev, port->slave->dev, in ad_marker_info_received()
2107 "Sent Marker Response on port %d\n", in ad_marker_info_received()
2108 port->actor_port_number); in ad_marker_info_received()
2114 * @port: the port we're looking at
2121 struct port *port) in ad_marker_response_received() argument
2123 atomic64_inc(&SLAVE_AD_INFO(port->slave)->stats.marker_resp_rx); in ad_marker_response_received()
2124 atomic64_inc(&BOND_AD_INFO(port->slave->bond).stats.marker_resp_rx); in ad_marker_response_received()
2172 * bond_3ad_bind_slave - initialize a slave's port
2181 struct port *port; in bond_3ad_bind_slave() local
2185 if (SLAVE_AD_INFO(slave)->port.slave != slave) { in bond_3ad_bind_slave()
2187 /* port initialization */ in bond_3ad_bind_slave()
2188 port = &(SLAVE_AD_INFO(slave)->port); in bond_3ad_bind_slave()
2190 ad_initialize_port(port, bond->params.lacp_fast); in bond_3ad_bind_slave()
2192 port->slave = slave; in bond_3ad_bind_slave()
2193 port->actor_port_number = SLAVE_AD_INFO(slave)->id; in bond_3ad_bind_slave()
2197 port->actor_admin_port_key = bond->params.ad_user_port_key << 6; in bond_3ad_bind_slave()
2198 ad_update_actor_keys(port, false); in bond_3ad_bind_slave()
2200 __ad_actor_update_port(port); in bond_3ad_bind_slave()
2204 port->sm_tx_timer_counter = ad_ticks_per_sec/AD_MAX_TX_IN_SECOND; in bond_3ad_bind_slave()
2206 __disable_port(port); in bond_3ad_bind_slave()
2222 * bond_3ad_unbind_slave - deinitialize a slave's port
2225 * Search for the aggregator that is related to this port, remove the
2226 * aggregator and assign another aggregator for other port related to it
2227 * (if any), and remove the port.
2231 struct port *port, *prev_port, *temp_port; in bond_3ad_unbind_slave() local
2242 port = &(SLAVE_AD_INFO(slave)->port); in bond_3ad_unbind_slave()
2244 /* if slave is null, the whole port is not initialized */ in bond_3ad_unbind_slave()
2245 if (!port->slave) { in bond_3ad_unbind_slave()
2246 slave_warn(bond->dev, slave->dev, "Trying to unbind an uninitialized port\n"); in bond_3ad_unbind_slave()
2253 /* Tell the partner that this port is not suitable for aggregation */ in bond_3ad_unbind_slave()
2254 port->actor_oper_port_state &= ~LACP_STATE_SYNCHRONIZATION; in bond_3ad_unbind_slave()
2255 port->actor_oper_port_state &= ~LACP_STATE_COLLECTING; in bond_3ad_unbind_slave()
2256 port->actor_oper_port_state &= ~LACP_STATE_DISTRIBUTING; in bond_3ad_unbind_slave()
2257 port->actor_oper_port_state &= ~LACP_STATE_AGGREGATION; in bond_3ad_unbind_slave()
2258 __update_lacpdu_from_port(port); in bond_3ad_unbind_slave()
2259 ad_lacpdu_send(port); in bond_3ad_unbind_slave()
2264 * except the port related to this slave(thats ensure us that in bond_3ad_unbind_slave()
2268 if ((aggregator->lag_ports != port) || in bond_3ad_unbind_slave()
2270 /* find new aggregator for the related port(s) */ in bond_3ad_unbind_slave()
2274 * connected to our port only in bond_3ad_unbind_slave()
2277 ((new_aggregator->lag_ports == port) && in bond_3ad_unbind_slave()
2288 …if ((new_aggregator) && ((!new_aggregator->lag_ports) || ((new_aggregator->lag_ports == port) && !… in bond_3ad_unbind_slave()
2289 slave_dbg(bond->dev, slave->dev, "Some port(s) related to LAG %d - replacing with LAG %d\n", in bond_3ad_unbind_slave()
2293 if ((new_aggregator->lag_ports == port) && in bond_3ad_unbind_slave()
2323 ad_agg_selection_logic(__get_first_agg(port), in bond_3ad_unbind_slave()
2329 /* in case that the only port related to this in bond_3ad_unbind_slave()
2337 temp_aggregator = __get_first_agg(port); in bond_3ad_unbind_slave()
2345 slave_dbg(bond->dev, slave->dev, "Unbinding port %d\n", port->actor_port_number); in bond_3ad_unbind_slave()
2347 /* find the aggregator that this port is connected to */ in bond_3ad_unbind_slave()
2351 /* search the port in the aggregator's related ports */ in bond_3ad_unbind_slave()
2355 if (temp_port == port) { in bond_3ad_unbind_slave()
2356 /* the aggregator found - detach the port from in bond_3ad_unbind_slave()
2371 ad_agg_selection_logic(__get_first_agg(port), in bond_3ad_unbind_slave()
2379 port->slave = NULL; in bond_3ad_unbind_slave()
2389 * If an ad_actor setting gets changed we need to update the individual port
2409 struct port *port = &(SLAVE_AD_INFO(slave))->port; in bond_3ad_update_ad_actor_settings() local
2411 __ad_actor_update_port(port); in bond_3ad_update_ad_actor_settings()
2412 port->ntt = true; in bond_3ad_update_ad_actor_settings()
2459 struct port *port; in bond_3ad_state_machine_handler() local
2463 /* Lock to protect data accessed by all (e.g., port->sm_vars) and in bond_3ad_state_machine_handler()
2476 port = slave ? &(SLAVE_AD_INFO(slave)->port) : NULL; in bond_3ad_state_machine_handler()
2479 if (port) { in bond_3ad_state_machine_handler()
2480 if (!port->slave) { in bond_3ad_state_machine_handler()
2481 net_warn_ratelimited("%s: Warning: bond's first port is uninitialized\n", in bond_3ad_state_machine_handler()
2486 aggregator = __get_first_agg(port); in bond_3ad_state_machine_handler()
2492 /* for each port run the state machines */ in bond_3ad_state_machine_handler()
2494 port = &(SLAVE_AD_INFO(slave)->port); in bond_3ad_state_machine_handler()
2495 if (!port->slave) { in bond_3ad_state_machine_handler()
2496 net_warn_ratelimited("%s: Warning: Found an uninitialized port\n", in bond_3ad_state_machine_handler()
2501 ad_rx_machine(NULL, port); in bond_3ad_state_machine_handler()
2502 ad_periodic_machine(port, &bond->params); in bond_3ad_state_machine_handler()
2503 ad_port_selection_logic(port, &update_slave_arr); in bond_3ad_state_machine_handler()
2504 ad_mux_machine(port, &update_slave_arr); in bond_3ad_state_machine_handler()
2505 ad_tx_machine(port); in bond_3ad_state_machine_handler()
2506 ad_churn_machine(port); in bond_3ad_state_machine_handler()
2509 if (port->sm_vars & AD_PORT_BEGIN) in bond_3ad_state_machine_handler()
2510 port->sm_vars &= ~AD_PORT_BEGIN; in bond_3ad_state_machine_handler()
2547 struct port *port; in bond_3ad_rx_indication() local
2550 port = &(SLAVE_AD_INFO(slave)->port); in bond_3ad_rx_indication()
2551 if (!port->slave) { in bond_3ad_rx_indication()
2552 net_warn_ratelimited("%s: Warning: port of slave %s is uninitialized\n", in bond_3ad_rx_indication()
2561 "Received LACPDU on port %d\n", in bond_3ad_rx_indication()
2562 port->actor_port_number); in bond_3ad_rx_indication()
2565 ad_rx_machine(lacpdu, port); in bond_3ad_rx_indication()
2576 slave_dbg(slave->bond->dev, slave->dev, "Received Marker Information on port %d\n", in bond_3ad_rx_indication()
2577 port->actor_port_number); in bond_3ad_rx_indication()
2578 ad_marker_info_received(marker, port); in bond_3ad_rx_indication()
2581 slave_dbg(slave->bond->dev, slave->dev, "Received Marker Response on port %d\n", in bond_3ad_rx_indication()
2582 port->actor_port_number); in bond_3ad_rx_indication()
2583 ad_marker_response_received(marker, port); in bond_3ad_rx_indication()
2586 slave_dbg(slave->bond->dev, slave->dev, "Received an unknown Marker subtype on port %d\n", in bond_3ad_rx_indication()
2587 port->actor_port_number); in bond_3ad_rx_indication()
2603 * ad_update_actor_keys - Update the oper / admin keys for a port based on
2606 * @port: the port we'are looking at
2610 * (a) A full duplex port can participate in LACP with partner.
2613 static void ad_update_actor_keys(struct port *port, bool reset) in ad_update_actor_keys() argument
2617 u16 old_oper_key = port->actor_oper_port_key; in ad_update_actor_keys()
2619 port->actor_admin_port_key &= ~(AD_SPEED_KEY_MASKS|AD_DUPLEX_KEY_MASKS); in ad_update_actor_keys()
2621 speed = __get_link_speed(port); in ad_update_actor_keys()
2623 duplex = __get_duplex(port); in ad_update_actor_keys()
2624 port->actor_admin_port_key |= (speed << 1) | duplex; in ad_update_actor_keys()
2626 port->actor_oper_port_key = port->actor_admin_port_key; in ad_update_actor_keys()
2628 if (old_oper_key != port->actor_oper_port_key) { in ad_update_actor_keys()
2629 /* Only 'duplex' port participates in LACP */ in ad_update_actor_keys()
2631 port->sm_vars |= AD_PORT_LACP_ENABLED; in ad_update_actor_keys()
2633 port->sm_vars &= ~AD_PORT_LACP_ENABLED; in ad_update_actor_keys()
2637 slave_err(port->slave->bond->dev, in ad_update_actor_keys()
2638 port->slave->dev, in ad_update_actor_keys()
2639 "speed changed to 0 on port %d\n", in ad_update_actor_keys()
2640 port->actor_port_number); in ad_update_actor_keys()
2643 port->sm_vars |= AD_PORT_BEGIN; in ad_update_actor_keys()
2655 * Handle reselection of aggregator (if needed) for this port.
2659 struct port *port; in bond_3ad_adapter_speed_duplex_changed() local
2661 port = &(SLAVE_AD_INFO(slave)->port); in bond_3ad_adapter_speed_duplex_changed()
2663 /* if slave is null, the whole port is not initialized */ in bond_3ad_adapter_speed_duplex_changed()
2664 if (!port->slave) { in bond_3ad_adapter_speed_duplex_changed()
2666 "speed/duplex changed for uninitialized port\n"); in bond_3ad_adapter_speed_duplex_changed()
2671 ad_update_actor_keys(port, false); in bond_3ad_adapter_speed_duplex_changed()
2673 slave_dbg(slave->bond->dev, slave->dev, "Port %d changed speed/duplex\n", in bond_3ad_adapter_speed_duplex_changed()
2674 port->actor_port_number); in bond_3ad_adapter_speed_duplex_changed()
2682 * Handle reselection of aggregator (if needed) for this port.
2687 struct port *port; in bond_3ad_handle_link_change() local
2690 port = &(SLAVE_AD_INFO(slave)->port); in bond_3ad_handle_link_change()
2692 /* if slave is null, the whole port is not initialized */ in bond_3ad_handle_link_change()
2693 if (!port->slave) { in bond_3ad_handle_link_change()
2694 slave_warn(slave->bond->dev, slave->dev, "link status changed for uninitialized port\n"); in bond_3ad_handle_link_change()
2707 port->is_enabled = true; in bond_3ad_handle_link_change()
2708 ad_update_actor_keys(port, false); in bond_3ad_handle_link_change()
2711 port->is_enabled = false; in bond_3ad_handle_link_change()
2712 ad_update_actor_keys(port, true); in bond_3ad_handle_link_change()
2714 agg = __get_first_agg(port); in bond_3ad_handle_link_change()
2719 slave_dbg(slave->bond->dev, slave->dev, "Port %d changed link status to %s\n", in bond_3ad_handle_link_change()
2720 port->actor_port_number, in bond_3ad_handle_link_change()
2788 struct port *port; in __bond_3ad_get_active_agg_info() local
2791 port = &(SLAVE_AD_INFO(slave)->port); in __bond_3ad_get_active_agg_info()
2792 if (port->aggregator && port->aggregator->is_active) { in __bond_3ad_get_active_agg_info()
2793 aggregator = port->aggregator; in __bond_3ad_get_active_agg_info()
2847 * update actor_oper_port_state of each port.
2850 * so we can modify port->actor_oper_port_state,
2855 struct port *port = NULL; in bond_3ad_update_lacp_rate() local
2863 port = &(SLAVE_AD_INFO(slave)->port); in bond_3ad_update_lacp_rate()
2865 port->actor_oper_port_state |= LACP_STATE_LACP_TIMEOUT; in bond_3ad_update_lacp_rate()
2867 port->actor_oper_port_state &= ~LACP_STATE_LACP_TIMEOUT; in bond_3ad_update_lacp_rate()