Lines Matching refs:port
96 static int ad_lacpdu_send(struct port *port);
97 static int ad_marker_send(struct port *port, struct bond_marker *marker);
98 static void ad_mux_machine(struct port *port, bool *update_slave_arr);
99 static void ad_rx_machine(struct lacpdu *lacpdu, struct port *port);
100 static void ad_tx_machine(struct port *port);
101 static void ad_periodic_machine(struct port *port, struct bond_params *bond_params);
102 static void ad_port_selection_logic(struct port *port, bool *update_slave_arr);
107 static void ad_initialize_port(struct port *port, int lacp_fast);
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);
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()
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()
177 static inline void __disable_port(struct port *port) in __disable_port() argument
179 bond_set_slave_inactive_flags(port->slave, BOND_SLAVE_NOTIFY_LATER); in __disable_port()
186 static inline void __enable_port(struct port *port) in __enable_port() argument
188 struct slave *slave = port->slave; in __enable_port()
198 static inline int __port_is_enabled(struct port *port) in __port_is_enabled() argument
200 return bond_is_active_slave(port->slave); in __port_is_enabled()
209 static inline u32 __get_agg_selection_mode(struct port *port) in __get_agg_selection_mode() argument
211 struct bonding *bond = __get_bond_by_port(port); in __get_agg_selection_mode()
223 static inline int __check_agg_selection_timer(struct port *port) in __check_agg_selection_timer() argument
225 struct bonding *bond = __get_bond_by_port(port); in __check_agg_selection_timer()
255 static u16 __get_link_speed(struct port *port) in __get_link_speed() argument
257 struct slave *slave = port->slave; in __get_link_speed()
335 port->actor_port_number); in __get_link_speed()
342 port->actor_port_number, speed); in __get_link_speed()
354 static u8 __get_duplex(struct port *port) in __get_duplex() argument
356 struct slave *slave = port->slave; in __get_duplex()
367 port->actor_port_number); in __get_duplex()
373 port->actor_port_number); in __get_duplex()
380 static void __ad_actor_update_port(struct port *port) in __ad_actor_update_port() argument
382 const struct bonding *bond = bond_get_bond_by_slave(port->slave); in __ad_actor_update_port()
384 port->actor_system = BOND_AD_INFO(bond).system.sys_mac_addr; in __ad_actor_update_port()
385 port->actor_system_priority = BOND_AD_INFO(bond).system.sys_priority; in __ad_actor_update_port()
453 static void __choose_matched(struct lacpdu *lacpdu, struct port *port) in __choose_matched() argument
459 if (((ntohs(lacpdu->partner_port) == port->actor_port_number) && in __choose_matched()
460 (ntohs(lacpdu->partner_port_priority) == port->actor_port_priority) && in __choose_matched()
461 MAC_ADDRESS_EQUAL(&(lacpdu->partner_system), &(port->actor_system)) && in __choose_matched()
462 (ntohs(lacpdu->partner_system_priority) == port->actor_system_priority) && in __choose_matched()
463 (ntohs(lacpdu->partner_key) == port->actor_oper_port_key) && in __choose_matched()
464 …((lacpdu->partner_state & LACP_STATE_AGGREGATION) == (port->actor_oper_port_state & LACP_STATE_AGG… in __choose_matched()
467 port->sm_vars |= AD_PORT_MATCHED; in __choose_matched()
469 port->sm_vars &= ~AD_PORT_MATCHED; in __choose_matched()
482 static void __record_pdu(struct lacpdu *lacpdu, struct port *port) in __record_pdu() argument
484 if (lacpdu && port) { in __record_pdu()
485 struct port_params *partner = &port->partner_oper; in __record_pdu()
487 __choose_matched(lacpdu, port); in __record_pdu()
499 port->actor_oper_port_state &= ~LACP_STATE_DEFAULTED; in __record_pdu()
504 if ((port->sm_vars & AD_PORT_MATCHED) && in __record_pdu()
507 slave_dbg(port->slave->bond->dev, port->slave->dev, in __record_pdu()
511 slave_dbg(port->slave->bond->dev, port->slave->dev, in __record_pdu()
525 static void __record_default(struct port *port) in __record_default() argument
527 if (port) { in __record_default()
529 memcpy(&port->partner_oper, &port->partner_admin, in __record_default()
533 port->actor_oper_port_state |= LACP_STATE_DEFAULTED; in __record_default()
550 static void __update_selected(struct lacpdu *lacpdu, struct port *port) in __update_selected() argument
552 if (lacpdu && port) { in __update_selected()
553 const struct port_params *partner = &port->partner_oper; in __update_selected()
564 port->sm_vars &= ~AD_PORT_SELECTED; in __update_selected()
581 static void __update_default_selected(struct port *port) in __update_default_selected() argument
583 if (port) { in __update_default_selected()
584 const struct port_params *admin = &port->partner_admin; in __update_default_selected()
585 const struct port_params *oper = &port->partner_oper; in __update_default_selected()
597 port->sm_vars &= ~AD_PORT_SELECTED; in __update_default_selected()
614 static void __update_ntt(struct lacpdu *lacpdu, struct port *port) in __update_ntt() argument
617 if (lacpdu && port) { in __update_ntt()
621 if ((ntohs(lacpdu->partner_port) != port->actor_port_number) || in __update_ntt()
622 (ntohs(lacpdu->partner_port_priority) != port->actor_port_priority) || in __update_ntt()
623 !MAC_ADDRESS_EQUAL(&(lacpdu->partner_system), &(port->actor_system)) || in __update_ntt()
624 (ntohs(lacpdu->partner_system_priority) != port->actor_system_priority) || in __update_ntt()
625 (ntohs(lacpdu->partner_key) != port->actor_oper_port_key) || in __update_ntt()
626 …((lacpdu->partner_state & LACP_STATE_LACP_ACTIVITY) != (port->actor_oper_port_state & LACP_STATE_L… in __update_ntt()
627 …((lacpdu->partner_state & LACP_STATE_LACP_TIMEOUT) != (port->actor_oper_port_state & LACP_STATE_LA… in __update_ntt()
628 …((lacpdu->partner_state & LACP_STATE_SYNCHRONIZATION) != (port->actor_oper_port_state & LACP_STATE… in __update_ntt()
629 …((lacpdu->partner_state & LACP_STATE_AGGREGATION) != (port->actor_oper_port_state & LACP_STATE_AGG… in __update_ntt()
631 port->ntt = true; in __update_ntt()
643 struct port *port; in __agg_ports_are_ready() local
650 for (port = aggregator->lag_ports; in __agg_ports_are_ready()
651 port; in __agg_ports_are_ready()
652 port = port->next_port_in_aggregator) { in __agg_ports_are_ready()
653 if (!(port->sm_vars & AD_PORT_READY_N)) { in __agg_ports_are_ready()
671 struct port *port; in __set_agg_ports_ready() local
673 for (port = aggregator->lag_ports; port; in __set_agg_ports_ready()
674 port = port->next_port_in_aggregator) { in __set_agg_ports_ready()
676 port->sm_vars |= AD_PORT_READY; in __set_agg_ports_ready()
678 port->sm_vars &= ~AD_PORT_READY; in __set_agg_ports_ready()
684 struct port *port; in __agg_active_ports() local
687 for (port = agg->lag_ports; port; in __agg_active_ports()
688 port = port->next_port_in_aggregator) { in __agg_active_ports()
689 if (port->is_enabled) in __agg_active_ports()
786 static inline void __update_lacpdu_from_port(struct port *port) in __update_lacpdu_from_port() argument
788 struct lacpdu *lacpdu = &port->lacpdu; in __update_lacpdu_from_port()
789 const struct port_params *partner = &port->partner_oper; in __update_lacpdu_from_port()
798 lacpdu->actor_system_priority = htons(port->actor_system_priority); in __update_lacpdu_from_port()
799 lacpdu->actor_system = port->actor_system; in __update_lacpdu_from_port()
800 lacpdu->actor_key = htons(port->actor_oper_port_key); in __update_lacpdu_from_port()
801 lacpdu->actor_port_priority = htons(port->actor_port_priority); in __update_lacpdu_from_port()
802 lacpdu->actor_port = htons(port->actor_port_number); in __update_lacpdu_from_port()
803 lacpdu->actor_state = port->actor_oper_port_state; in __update_lacpdu_from_port()
804 slave_dbg(port->slave->bond->dev, port->slave->dev, in __update_lacpdu_from_port()
806 port->actor_oper_port_state); in __update_lacpdu_from_port()
840 static int ad_lacpdu_send(struct port *port) in ad_lacpdu_send() argument
842 struct slave *slave = port->slave; in ad_lacpdu_send()
869 lacpdu_header->lacpdu = port->lacpdu; in ad_lacpdu_send()
884 static int ad_marker_send(struct port *port, struct bond_marker *marker) in ad_marker_send() argument
886 struct slave *slave = port->slave; in ad_marker_send()
934 static void ad_mux_machine(struct port *port, bool *update_slave_arr) in ad_mux_machine() argument
941 last_state = port->sm_mux_state; in ad_mux_machine()
943 if (port->sm_vars & AD_PORT_BEGIN) { in ad_mux_machine()
944 port->sm_mux_state = AD_MUX_DETACHED; in ad_mux_machine()
946 switch (port->sm_mux_state) { in ad_mux_machine()
948 if ((port->sm_vars & AD_PORT_SELECTED) in ad_mux_machine()
949 || (port->sm_vars & AD_PORT_STANDBY)) in ad_mux_machine()
951 port->sm_mux_state = AD_MUX_WAITING; in ad_mux_machine()
955 if (!(port->sm_vars & AD_PORT_SELECTED)) { in ad_mux_machine()
956 port->sm_vars &= ~AD_PORT_READY_N; in ad_mux_machine()
962 __set_agg_ports_ready(port->aggregator, __agg_ports_are_ready(port->aggregator)); in ad_mux_machine()
963 port->sm_mux_state = AD_MUX_DETACHED; in ad_mux_machine()
968 if (port->sm_mux_timer_counter in ad_mux_machine()
969 && !(--port->sm_mux_timer_counter)) in ad_mux_machine()
970 port->sm_vars |= AD_PORT_READY_N; in ad_mux_machine()
977 __set_agg_ports_ready(port->aggregator, __agg_ports_are_ready(port->aggregator)); in ad_mux_machine()
982 if ((port->sm_vars & AD_PORT_READY) in ad_mux_machine()
983 && !port->sm_mux_timer_counter) in ad_mux_machine()
984 port->sm_mux_state = AD_MUX_ATTACHED; in ad_mux_machine()
990 if ((port->sm_vars & AD_PORT_SELECTED) && in ad_mux_machine()
991 (port->partner_oper.port_state & LACP_STATE_SYNCHRONIZATION) && in ad_mux_machine()
992 !__check_agg_selection_timer(port)) { in ad_mux_machine()
993 if (port->aggregator->is_active) in ad_mux_machine()
994 port->sm_mux_state = in ad_mux_machine()
996 } else if (!(port->sm_vars & AD_PORT_SELECTED) || in ad_mux_machine()
997 (port->sm_vars & AD_PORT_STANDBY)) { in ad_mux_machine()
999 port->sm_vars &= ~AD_PORT_READY_N; in ad_mux_machine()
1005 __set_agg_ports_ready(port->aggregator, __agg_ports_are_ready(port->aggregator)); in ad_mux_machine()
1006 port->sm_mux_state = AD_MUX_DETACHED; in ad_mux_machine()
1007 } else if (port->aggregator->is_active) { in ad_mux_machine()
1008 port->actor_oper_port_state |= in ad_mux_machine()
1013 if (!(port->sm_vars & AD_PORT_SELECTED) || in ad_mux_machine()
1014 (port->sm_vars & AD_PORT_STANDBY) || in ad_mux_machine()
1015 !(port->partner_oper.port_state & LACP_STATE_SYNCHRONIZATION) || in ad_mux_machine()
1016 !(port->actor_oper_port_state & LACP_STATE_SYNCHRONIZATION)) { in ad_mux_machine()
1017 port->sm_mux_state = AD_MUX_ATTACHED; in ad_mux_machine()
1023 if (port->aggregator && in ad_mux_machine()
1024 port->aggregator->is_active && in ad_mux_machine()
1025 !__port_is_enabled(port)) { in ad_mux_machine()
1026 __enable_port(port); in ad_mux_machine()
1037 if (port->sm_mux_state != last_state) { in ad_mux_machine()
1038 slave_dbg(port->slave->bond->dev, port->slave->dev, in ad_mux_machine()
1040 port->actor_port_number, in ad_mux_machine()
1042 port->sm_mux_state); in ad_mux_machine()
1043 switch (port->sm_mux_state) { in ad_mux_machine()
1045 port->actor_oper_port_state &= ~LACP_STATE_SYNCHRONIZATION; in ad_mux_machine()
1046 ad_disable_collecting_distributing(port, in ad_mux_machine()
1048 port->actor_oper_port_state &= ~LACP_STATE_COLLECTING; in ad_mux_machine()
1049 port->actor_oper_port_state &= ~LACP_STATE_DISTRIBUTING; in ad_mux_machine()
1050 port->ntt = true; in ad_mux_machine()
1053 port->sm_mux_timer_counter = __ad_timer_to_ticks(AD_WAIT_WHILE_TIMER, 0); in ad_mux_machine()
1056 if (port->aggregator->is_active) in ad_mux_machine()
1057 port->actor_oper_port_state |= in ad_mux_machine()
1060 port->actor_oper_port_state &= in ad_mux_machine()
1062 port->actor_oper_port_state &= ~LACP_STATE_COLLECTING; in ad_mux_machine()
1063 port->actor_oper_port_state &= ~LACP_STATE_DISTRIBUTING; in ad_mux_machine()
1064 ad_disable_collecting_distributing(port, in ad_mux_machine()
1066 port->ntt = true; in ad_mux_machine()
1069 port->actor_oper_port_state |= LACP_STATE_COLLECTING; in ad_mux_machine()
1070 port->actor_oper_port_state |= LACP_STATE_DISTRIBUTING; in ad_mux_machine()
1071 port->actor_oper_port_state |= LACP_STATE_SYNCHRONIZATION; in ad_mux_machine()
1072 ad_enable_collecting_distributing(port, in ad_mux_machine()
1074 port->ntt = true; in ad_mux_machine()
1091 static void ad_rx_machine(struct lacpdu *lacpdu, struct port *port) in ad_rx_machine() argument
1098 last_state = port->sm_rx_state; in ad_rx_machine()
1101 atomic64_inc(&SLAVE_AD_INFO(port->slave)->stats.lacpdu_rx); in ad_rx_machine()
1102 atomic64_inc(&BOND_AD_INFO(port->slave->bond).stats.lacpdu_rx); in ad_rx_machine()
1107 if (port->sm_vars & AD_PORT_BEGIN) { in ad_rx_machine()
1108 port->sm_rx_state = AD_RX_INITIALIZE; in ad_rx_machine()
1109 port->sm_vars |= AD_PORT_CHURNED; in ad_rx_machine()
1111 } else if (!(port->sm_vars & AD_PORT_BEGIN) && !port->is_enabled) in ad_rx_machine()
1112 port->sm_rx_state = AD_RX_PORT_DISABLED; in ad_rx_machine()
1114 else if (lacpdu && ((port->sm_rx_state == AD_RX_EXPIRED) || in ad_rx_machine()
1115 (port->sm_rx_state == AD_RX_DEFAULTED) || in ad_rx_machine()
1116 (port->sm_rx_state == AD_RX_CURRENT))) { in ad_rx_machine()
1117 if (port->sm_rx_state != AD_RX_CURRENT) in ad_rx_machine()
1118 port->sm_vars |= AD_PORT_CHURNED; in ad_rx_machine()
1119 port->sm_rx_timer_counter = 0; in ad_rx_machine()
1120 port->sm_rx_state = AD_RX_CURRENT; in ad_rx_machine()
1123 if (port->sm_rx_timer_counter && in ad_rx_machine()
1124 !(--port->sm_rx_timer_counter)) { in ad_rx_machine()
1125 switch (port->sm_rx_state) { in ad_rx_machine()
1127 port->sm_rx_state = AD_RX_DEFAULTED; in ad_rx_machine()
1130 port->sm_rx_state = AD_RX_EXPIRED; in ad_rx_machine()
1137 switch (port->sm_rx_state) { in ad_rx_machine()
1139 if (port->is_enabled && in ad_rx_machine()
1140 (port->sm_vars & AD_PORT_LACP_ENABLED)) in ad_rx_machine()
1141 port->sm_rx_state = AD_RX_EXPIRED; in ad_rx_machine()
1142 else if (port->is_enabled in ad_rx_machine()
1143 && ((port->sm_vars in ad_rx_machine()
1145 port->sm_rx_state = AD_RX_LACP_DISABLED; in ad_rx_machine()
1155 if ((port->sm_rx_state != last_state) || (lacpdu)) { in ad_rx_machine()
1156 slave_dbg(port->slave->bond->dev, port->slave->dev, in ad_rx_machine()
1158 port->actor_port_number, in ad_rx_machine()
1160 port->sm_rx_state); in ad_rx_machine()
1161 switch (port->sm_rx_state) { in ad_rx_machine()
1163 if (!(port->actor_oper_port_key & AD_DUPLEX_KEY_MASKS)) in ad_rx_machine()
1164 port->sm_vars &= ~AD_PORT_LACP_ENABLED; in ad_rx_machine()
1166 port->sm_vars |= AD_PORT_LACP_ENABLED; in ad_rx_machine()
1167 port->sm_vars &= ~AD_PORT_SELECTED; in ad_rx_machine()
1168 __record_default(port); in ad_rx_machine()
1169 port->actor_oper_port_state &= ~LACP_STATE_EXPIRED; in ad_rx_machine()
1170 port->sm_rx_state = AD_RX_PORT_DISABLED; in ad_rx_machine()
1174 port->sm_vars &= ~AD_PORT_MATCHED; in ad_rx_machine()
1177 port->sm_vars &= ~AD_PORT_SELECTED; in ad_rx_machine()
1178 __record_default(port); in ad_rx_machine()
1179 port->partner_oper.port_state &= ~LACP_STATE_AGGREGATION; in ad_rx_machine()
1180 port->sm_vars |= AD_PORT_MATCHED; in ad_rx_machine()
1181 port->actor_oper_port_state &= ~LACP_STATE_EXPIRED; in ad_rx_machine()
1190 port->partner_oper.port_state &= ~LACP_STATE_SYNCHRONIZATION; in ad_rx_machine()
1191 port->sm_vars &= ~AD_PORT_MATCHED; in ad_rx_machine()
1192 port->partner_oper.port_state |= LACP_STATE_LACP_TIMEOUT; in ad_rx_machine()
1193 port->partner_oper.port_state |= LACP_STATE_LACP_ACTIVITY; in ad_rx_machine()
1194 port->sm_rx_timer_counter = __ad_timer_to_ticks(AD_CURRENT_WHILE_TIMER, (u16)(AD_SHORT_TIMEOUT)); in ad_rx_machine()
1195 port->actor_oper_port_state |= LACP_STATE_EXPIRED; in ad_rx_machine()
1196 port->sm_vars |= AD_PORT_CHURNED; in ad_rx_machine()
1199 __update_default_selected(port); in ad_rx_machine()
1200 __record_default(port); in ad_rx_machine()
1201 port->sm_vars |= AD_PORT_MATCHED; in ad_rx_machine()
1202 port->actor_oper_port_state &= ~LACP_STATE_EXPIRED; in ad_rx_machine()
1207 &(port->actor_system))) { in ad_rx_machine()
1208 slave_err(port->slave->bond->dev, port->slave->dev, "An illegal loopback occurred on slave\n" in ad_rx_machine()
1212 __update_selected(lacpdu, port); in ad_rx_machine()
1213 __update_ntt(lacpdu, port); in ad_rx_machine()
1214 __record_pdu(lacpdu, port); in ad_rx_machine()
1215 …port->sm_rx_timer_counter = __ad_timer_to_ticks(AD_CURRENT_WHILE_TIMER, (u16)(port->actor_oper_por… in ad_rx_machine()
1216 port->actor_oper_port_state &= ~LACP_STATE_EXPIRED; in ad_rx_machine()
1229 static void ad_churn_machine(struct port *port) in ad_churn_machine() argument
1231 if (port->sm_vars & AD_PORT_CHURNED) { in ad_churn_machine()
1232 port->sm_vars &= ~AD_PORT_CHURNED; in ad_churn_machine()
1233 port->sm_churn_actor_state = AD_CHURN_MONITOR; in ad_churn_machine()
1234 port->sm_churn_partner_state = AD_CHURN_MONITOR; in ad_churn_machine()
1235 port->sm_churn_actor_timer_counter = in ad_churn_machine()
1237 port->sm_churn_partner_timer_counter = in ad_churn_machine()
1241 if (port->sm_churn_actor_timer_counter && in ad_churn_machine()
1242 !(--port->sm_churn_actor_timer_counter) && in ad_churn_machine()
1243 port->sm_churn_actor_state == AD_CHURN_MONITOR) { in ad_churn_machine()
1244 if (port->actor_oper_port_state & LACP_STATE_SYNCHRONIZATION) { in ad_churn_machine()
1245 port->sm_churn_actor_state = AD_NO_CHURN; in ad_churn_machine()
1247 port->churn_actor_count++; in ad_churn_machine()
1248 port->sm_churn_actor_state = AD_CHURN; in ad_churn_machine()
1251 if (port->sm_churn_partner_timer_counter && in ad_churn_machine()
1252 !(--port->sm_churn_partner_timer_counter) && in ad_churn_machine()
1253 port->sm_churn_partner_state == AD_CHURN_MONITOR) { in ad_churn_machine()
1254 if (port->partner_oper.port_state & LACP_STATE_SYNCHRONIZATION) { in ad_churn_machine()
1255 port->sm_churn_partner_state = AD_NO_CHURN; in ad_churn_machine()
1257 port->churn_partner_count++; in ad_churn_machine()
1258 port->sm_churn_partner_state = AD_CHURN; in ad_churn_machine()
1267 static void ad_tx_machine(struct port *port) in ad_tx_machine() argument
1272 if (port->sm_tx_timer_counter && !(--port->sm_tx_timer_counter)) { in ad_tx_machine()
1274 if (port->ntt && (port->sm_vars & AD_PORT_LACP_ENABLED)) { in ad_tx_machine()
1275 __update_lacpdu_from_port(port); in ad_tx_machine()
1277 if (ad_lacpdu_send(port) >= 0) { in ad_tx_machine()
1278 slave_dbg(port->slave->bond->dev, in ad_tx_machine()
1279 port->slave->dev, in ad_tx_machine()
1281 port->actor_port_number); in ad_tx_machine()
1286 port->ntt = false; in ad_tx_machine()
1292 port->sm_tx_timer_counter = ad_ticks_per_sec/AD_MAX_TX_IN_SECOND; in ad_tx_machine()
1303 static void ad_periodic_machine(struct port *port, struct bond_params *bond_params) in ad_periodic_machine() argument
1308 last_state = port->sm_periodic_state; in ad_periodic_machine()
1311 …if (((port->sm_vars & AD_PORT_BEGIN) || !(port->sm_vars & AD_PORT_LACP_ENABLED) || !port->is_enabl… in ad_periodic_machine()
1312 …(!(port->actor_oper_port_state & LACP_STATE_LACP_ACTIVITY) && !(port->partner_oper.port_state & LA… in ad_periodic_machine()
1314 port->sm_periodic_state = AD_NO_PERIODIC; in ad_periodic_machine()
1317 else if (port->sm_periodic_timer_counter) { in ad_periodic_machine()
1319 if (!(--port->sm_periodic_timer_counter)) { in ad_periodic_machine()
1321 port->sm_periodic_state = AD_PERIODIC_TX; in ad_periodic_machine()
1326 switch (port->sm_periodic_state) { in ad_periodic_machine()
1328 if (!(port->partner_oper.port_state in ad_periodic_machine()
1330 port->sm_periodic_state = AD_SLOW_PERIODIC; in ad_periodic_machine()
1333 if ((port->partner_oper.port_state & LACP_STATE_LACP_TIMEOUT)) { in ad_periodic_machine()
1334 port->sm_periodic_timer_counter = 0; in ad_periodic_machine()
1335 port->sm_periodic_state = AD_PERIODIC_TX; in ad_periodic_machine()
1343 switch (port->sm_periodic_state) { in ad_periodic_machine()
1345 port->sm_periodic_state = AD_FAST_PERIODIC; in ad_periodic_machine()
1348 if (!(port->partner_oper.port_state & in ad_periodic_machine()
1350 port->sm_periodic_state = AD_SLOW_PERIODIC; in ad_periodic_machine()
1352 port->sm_periodic_state = AD_FAST_PERIODIC; in ad_periodic_machine()
1360 if (port->sm_periodic_state != last_state) { in ad_periodic_machine()
1361 slave_dbg(port->slave->bond->dev, port->slave->dev, in ad_periodic_machine()
1363 port->actor_port_number, last_state, in ad_periodic_machine()
1364 port->sm_periodic_state); in ad_periodic_machine()
1365 switch (port->sm_periodic_state) { in ad_periodic_machine()
1367 port->sm_periodic_timer_counter = 0; in ad_periodic_machine()
1371 …port->sm_periodic_timer_counter = __ad_timer_to_ticks(AD_PERIODIC_TIMER, (u16)(AD_FAST_PERIODIC_TI… in ad_periodic_machine()
1375 …port->sm_periodic_timer_counter = __ad_timer_to_ticks(AD_PERIODIC_TIMER, (u16)(AD_SLOW_PERIODIC_TI… in ad_periodic_machine()
1378 port->ntt = true; in ad_periodic_machine()
1395 static void ad_port_selection_logic(struct port *port, bool *update_slave_arr) in ad_port_selection_logic() argument
1398 struct port *last_port = NULL, *curr_port; in ad_port_selection_logic()
1405 if (port->sm_vars & AD_PORT_SELECTED) in ad_port_selection_logic()
1408 bond = __get_bond_by_port(port); in ad_port_selection_logic()
1411 if (port->aggregator) { in ad_port_selection_logic()
1413 temp_aggregator = port->aggregator; in ad_port_selection_logic()
1417 if (curr_port == port) { in ad_port_selection_logic()
1424 port->next_port_in_aggregator; in ad_port_selection_logic()
1430 port->next_port_in_aggregator; in ad_port_selection_logic()
1436 port->aggregator = NULL; in ad_port_selection_logic()
1437 port->next_port_in_aggregator = NULL; in ad_port_selection_logic()
1438 port->actor_port_aggregator_identifier = 0; in ad_port_selection_logic()
1440 slave_dbg(bond->dev, port->slave->dev, "Port %d left LAG %d\n", in ad_port_selection_logic()
1441 port->actor_port_number, in ad_port_selection_logic()
1456 port->slave->bond->dev->name, in ad_port_selection_logic()
1457 port->slave->dev->name, in ad_port_selection_logic()
1458 port->actor_port_number, in ad_port_selection_logic()
1459 port->aggregator->aggregator_identifier); in ad_port_selection_logic()
1473 …if (((aggregator->actor_oper_aggregator_key == port->actor_oper_port_key) && /* if all parameters … in ad_port_selection_logic()
1474 MAC_ADDRESS_EQUAL(&(aggregator->partner_system), &(port->partner_oper.system)) && in ad_port_selection_logic()
1475 (aggregator->partner_system_priority == port->partner_oper.system_priority) && in ad_port_selection_logic()
1476 (aggregator->partner_oper_aggregator_key == port->partner_oper.key) in ad_port_selection_logic()
1478 ((!MAC_ADDRESS_EQUAL(&(port->partner_oper.system), &(null_mac_addr)) && /* partner answers */ in ad_port_selection_logic()
1483 port->aggregator = aggregator; in ad_port_selection_logic()
1484 port->actor_port_aggregator_identifier = in ad_port_selection_logic()
1485 port->aggregator->aggregator_identifier; in ad_port_selection_logic()
1486 port->next_port_in_aggregator = aggregator->lag_ports; in ad_port_selection_logic()
1487 port->aggregator->num_of_ports++; in ad_port_selection_logic()
1488 aggregator->lag_ports = port; in ad_port_selection_logic()
1490 port->actor_port_number, in ad_port_selection_logic()
1491 port->aggregator->aggregator_identifier); in ad_port_selection_logic()
1494 port->sm_vars |= AD_PORT_SELECTED; in ad_port_selection_logic()
1506 port->aggregator = free_aggregator; in ad_port_selection_logic()
1507 port->actor_port_aggregator_identifier = in ad_port_selection_logic()
1508 port->aggregator->aggregator_identifier; in ad_port_selection_logic()
1513 if (port->actor_oper_port_key & AD_DUPLEX_KEY_MASKS) in ad_port_selection_logic()
1515 port->aggregator->is_individual = false; in ad_port_selection_logic()
1517 port->aggregator->is_individual = true; in ad_port_selection_logic()
1519 port->aggregator->actor_admin_aggregator_key = in ad_port_selection_logic()
1520 port->actor_admin_port_key; in ad_port_selection_logic()
1521 port->aggregator->actor_oper_aggregator_key = in ad_port_selection_logic()
1522 port->actor_oper_port_key; in ad_port_selection_logic()
1523 port->aggregator->partner_system = in ad_port_selection_logic()
1524 port->partner_oper.system; in ad_port_selection_logic()
1525 port->aggregator->partner_system_priority = in ad_port_selection_logic()
1526 port->partner_oper.system_priority; in ad_port_selection_logic()
1527 port->aggregator->partner_oper_aggregator_key = port->partner_oper.key; in ad_port_selection_logic()
1528 port->aggregator->receive_state = 1; in ad_port_selection_logic()
1529 port->aggregator->transmit_state = 1; in ad_port_selection_logic()
1530 port->aggregator->lag_ports = port; in ad_port_selection_logic()
1531 port->aggregator->num_of_ports++; in ad_port_selection_logic()
1534 port->sm_vars |= AD_PORT_SELECTED; in ad_port_selection_logic()
1536 slave_dbg(bond->dev, port->slave->dev, "Port %d joined LAG %d (new LAG)\n", in ad_port_selection_logic()
1537 port->actor_port_number, in ad_port_selection_logic()
1538 port->aggregator->aggregator_identifier); in ad_port_selection_logic()
1540 slave_err(bond->dev, port->slave->dev, in ad_port_selection_logic()
1542 port->actor_port_number); in ad_port_selection_logic()
1550 __set_agg_ports_ready(port->aggregator, in ad_port_selection_logic()
1551 __agg_ports_are_ready(port->aggregator)); in ad_port_selection_logic()
1553 aggregator = __get_first_agg(port); in ad_port_selection_logic()
1556 if (!port->aggregator->is_active) in ad_port_selection_logic()
1557 port->actor_oper_port_state &= ~LACP_STATE_SYNCHRONIZATION; in ad_port_selection_logic()
1634 struct port *port = agg->lag_ports; in agg_device_up() local
1636 if (!port) in agg_device_up()
1639 for (port = agg->lag_ports; port; in agg_device_up()
1640 port = port->next_port_in_aggregator) { in agg_device_up()
1641 if (netif_running(port->slave->dev) && in agg_device_up()
1642 netif_carrier_ok(port->slave->dev)) in agg_device_up()
1682 struct port *port; in ad_agg_selection_logic() local
1765 for (port = active->lag_ports; port; in ad_agg_selection_logic()
1766 port = port->next_port_in_aggregator) { in ad_agg_selection_logic()
1767 __disable_port(port); in ad_agg_selection_logic()
1781 for (port = active->lag_ports; port; in ad_agg_selection_logic()
1782 port = port->next_port_in_aggregator) { in ad_agg_selection_logic()
1783 __enable_port(port); in ad_agg_selection_logic()
1839 static void ad_initialize_port(struct port *port, int lacp_fast) in ad_initialize_port() argument
1860 if (port) { in ad_initialize_port()
1861 port->actor_port_priority = 0xff; in ad_initialize_port()
1862 port->actor_port_aggregator_identifier = 0; in ad_initialize_port()
1863 port->ntt = false; in ad_initialize_port()
1864 port->actor_admin_port_state = LACP_STATE_AGGREGATION | in ad_initialize_port()
1866 port->actor_oper_port_state = LACP_STATE_AGGREGATION | in ad_initialize_port()
1870 port->actor_oper_port_state |= LACP_STATE_LACP_TIMEOUT; in ad_initialize_port()
1872 memcpy(&port->partner_admin, &tmpl, sizeof(tmpl)); in ad_initialize_port()
1873 memcpy(&port->partner_oper, &tmpl, sizeof(tmpl)); in ad_initialize_port()
1875 port->is_enabled = true; in ad_initialize_port()
1877 port->sm_vars = AD_PORT_BEGIN | AD_PORT_LACP_ENABLED; in ad_initialize_port()
1878 port->sm_rx_state = 0; in ad_initialize_port()
1879 port->sm_rx_timer_counter = 0; in ad_initialize_port()
1880 port->sm_periodic_state = 0; in ad_initialize_port()
1881 port->sm_periodic_timer_counter = 0; in ad_initialize_port()
1882 port->sm_mux_state = 0; in ad_initialize_port()
1883 port->sm_mux_timer_counter = 0; in ad_initialize_port()
1884 port->sm_tx_state = 0; in ad_initialize_port()
1885 port->aggregator = NULL; in ad_initialize_port()
1886 port->next_port_in_aggregator = NULL; in ad_initialize_port()
1887 port->transaction_id = 0; in ad_initialize_port()
1889 port->sm_churn_actor_timer_counter = 0; in ad_initialize_port()
1890 port->sm_churn_actor_state = 0; in ad_initialize_port()
1891 port->churn_actor_count = 0; in ad_initialize_port()
1892 port->sm_churn_partner_timer_counter = 0; in ad_initialize_port()
1893 port->sm_churn_partner_state = 0; in ad_initialize_port()
1894 port->churn_partner_count = 0; in ad_initialize_port()
1896 memcpy(&port->lacpdu, &lacpdu, sizeof(lacpdu)); in ad_initialize_port()
1907 static void ad_enable_collecting_distributing(struct port *port, in ad_enable_collecting_distributing() argument
1910 if (port->aggregator->is_active) { in ad_enable_collecting_distributing()
1911 slave_dbg(port->slave->bond->dev, port->slave->dev, in ad_enable_collecting_distributing()
1913 port->actor_port_number, in ad_enable_collecting_distributing()
1914 port->aggregator->aggregator_identifier); in ad_enable_collecting_distributing()
1915 __enable_port(port); in ad_enable_collecting_distributing()
1926 static void ad_disable_collecting_distributing(struct port *port, in ad_disable_collecting_distributing() argument
1929 if (port->aggregator && in ad_disable_collecting_distributing()
1930 !MAC_ADDRESS_EQUAL(&(port->aggregator->partner_system), in ad_disable_collecting_distributing()
1932 slave_dbg(port->slave->bond->dev, port->slave->dev, in ad_disable_collecting_distributing()
1934 port->actor_port_number, in ad_disable_collecting_distributing()
1935 port->aggregator->aggregator_identifier); in ad_disable_collecting_distributing()
1936 __disable_port(port); in ad_disable_collecting_distributing()
1948 struct port *port) in ad_marker_info_received() argument
1952 atomic64_inc(&SLAVE_AD_INFO(port->slave)->stats.marker_rx); in ad_marker_info_received()
1953 atomic64_inc(&BOND_AD_INFO(port->slave->bond).stats.marker_rx); in ad_marker_info_received()
1961 if (ad_marker_send(port, &marker) >= 0) in ad_marker_info_received()
1962 slave_dbg(port->slave->bond->dev, port->slave->dev, in ad_marker_info_received()
1964 port->actor_port_number); in ad_marker_info_received()
1977 struct port *port) in ad_marker_response_received() argument
1979 atomic64_inc(&SLAVE_AD_INFO(port->slave)->stats.marker_resp_rx); in ad_marker_response_received()
1980 atomic64_inc(&BOND_AD_INFO(port->slave->bond).stats.marker_resp_rx); in ad_marker_response_received()
2037 struct port *port; in bond_3ad_bind_slave() local
2041 if (SLAVE_AD_INFO(slave)->port.slave != slave) { in bond_3ad_bind_slave()
2044 port = &(SLAVE_AD_INFO(slave)->port); in bond_3ad_bind_slave()
2046 ad_initialize_port(port, bond->params.lacp_fast); in bond_3ad_bind_slave()
2048 port->slave = slave; in bond_3ad_bind_slave()
2049 port->actor_port_number = SLAVE_AD_INFO(slave)->id; in bond_3ad_bind_slave()
2053 port->actor_admin_port_key = bond->params.ad_user_port_key << 6; in bond_3ad_bind_slave()
2054 ad_update_actor_keys(port, false); in bond_3ad_bind_slave()
2056 __ad_actor_update_port(port); in bond_3ad_bind_slave()
2060 port->sm_tx_timer_counter = ad_ticks_per_sec/AD_MAX_TX_IN_SECOND; in bond_3ad_bind_slave()
2062 __disable_port(port); in bond_3ad_bind_slave()
2087 struct port *port, *prev_port, *temp_port; in bond_3ad_unbind_slave() local
2098 port = &(SLAVE_AD_INFO(slave)->port); in bond_3ad_unbind_slave()
2101 if (!port->slave) { in bond_3ad_unbind_slave()
2110 port->actor_oper_port_state &= ~LACP_STATE_SYNCHRONIZATION; in bond_3ad_unbind_slave()
2111 port->actor_oper_port_state &= ~LACP_STATE_COLLECTING; in bond_3ad_unbind_slave()
2112 port->actor_oper_port_state &= ~LACP_STATE_DISTRIBUTING; in bond_3ad_unbind_slave()
2113 port->actor_oper_port_state &= ~LACP_STATE_AGGREGATION; in bond_3ad_unbind_slave()
2114 __update_lacpdu_from_port(port); in bond_3ad_unbind_slave()
2115 ad_lacpdu_send(port); in bond_3ad_unbind_slave()
2124 if ((aggregator->lag_ports != port) || in bond_3ad_unbind_slave()
2133 ((new_aggregator->lag_ports == port) && in bond_3ad_unbind_slave()
2144 …if ((new_aggregator) && ((!new_aggregator->lag_ports) || ((new_aggregator->lag_ports == port) && !… in bond_3ad_unbind_slave()
2149 if ((new_aggregator->lag_ports == port) && in bond_3ad_unbind_slave()
2179 ad_agg_selection_logic(__get_first_agg(port), in bond_3ad_unbind_slave()
2193 temp_aggregator = __get_first_agg(port); in bond_3ad_unbind_slave()
2201 slave_dbg(bond->dev, slave->dev, "Unbinding port %d\n", port->actor_port_number); in bond_3ad_unbind_slave()
2211 if (temp_port == port) { in bond_3ad_unbind_slave()
2227 ad_agg_selection_logic(__get_first_agg(port), in bond_3ad_unbind_slave()
2235 port->slave = NULL; in bond_3ad_unbind_slave()
2265 struct port *port = &(SLAVE_AD_INFO(slave))->port; in bond_3ad_update_ad_actor_settings() local
2267 __ad_actor_update_port(port); in bond_3ad_update_ad_actor_settings()
2268 port->ntt = true; in bond_3ad_update_ad_actor_settings()
2315 struct port *port; in bond_3ad_state_machine_handler() local
2332 port = slave ? &(SLAVE_AD_INFO(slave)->port) : NULL; in bond_3ad_state_machine_handler()
2335 if (port) { in bond_3ad_state_machine_handler()
2336 if (!port->slave) { in bond_3ad_state_machine_handler()
2342 aggregator = __get_first_agg(port); in bond_3ad_state_machine_handler()
2350 port = &(SLAVE_AD_INFO(slave)->port); in bond_3ad_state_machine_handler()
2351 if (!port->slave) { in bond_3ad_state_machine_handler()
2357 ad_rx_machine(NULL, port); in bond_3ad_state_machine_handler()
2358 ad_periodic_machine(port, &bond->params); in bond_3ad_state_machine_handler()
2359 ad_port_selection_logic(port, &update_slave_arr); in bond_3ad_state_machine_handler()
2360 ad_mux_machine(port, &update_slave_arr); in bond_3ad_state_machine_handler()
2361 ad_tx_machine(port); in bond_3ad_state_machine_handler()
2362 ad_churn_machine(port); in bond_3ad_state_machine_handler()
2365 if (port->sm_vars & AD_PORT_BEGIN) in bond_3ad_state_machine_handler()
2366 port->sm_vars &= ~AD_PORT_BEGIN; in bond_3ad_state_machine_handler()
2403 struct port *port; in bond_3ad_rx_indication() local
2406 port = &(SLAVE_AD_INFO(slave)->port); in bond_3ad_rx_indication()
2407 if (!port->slave) { in bond_3ad_rx_indication()
2418 port->actor_port_number); in bond_3ad_rx_indication()
2421 ad_rx_machine(lacpdu, port); in bond_3ad_rx_indication()
2433 port->actor_port_number); in bond_3ad_rx_indication()
2434 ad_marker_info_received(marker, port); in bond_3ad_rx_indication()
2438 port->actor_port_number); in bond_3ad_rx_indication()
2439 ad_marker_response_received(marker, port); in bond_3ad_rx_indication()
2443 port->actor_port_number); in bond_3ad_rx_indication()
2469 static void ad_update_actor_keys(struct port *port, bool reset) in ad_update_actor_keys() argument
2473 u16 old_oper_key = port->actor_oper_port_key; in ad_update_actor_keys()
2475 port->actor_admin_port_key &= ~(AD_SPEED_KEY_MASKS|AD_DUPLEX_KEY_MASKS); in ad_update_actor_keys()
2477 speed = __get_link_speed(port); in ad_update_actor_keys()
2479 duplex = __get_duplex(port); in ad_update_actor_keys()
2480 port->actor_admin_port_key |= (speed << 1) | duplex; in ad_update_actor_keys()
2482 port->actor_oper_port_key = port->actor_admin_port_key; in ad_update_actor_keys()
2484 if (old_oper_key != port->actor_oper_port_key) { in ad_update_actor_keys()
2487 port->sm_vars |= AD_PORT_LACP_ENABLED; in ad_update_actor_keys()
2489 port->sm_vars &= ~AD_PORT_LACP_ENABLED; in ad_update_actor_keys()
2493 slave_err(port->slave->bond->dev, in ad_update_actor_keys()
2494 port->slave->dev, in ad_update_actor_keys()
2496 port->actor_port_number); in ad_update_actor_keys()
2499 port->sm_vars |= AD_PORT_BEGIN; in ad_update_actor_keys()
2515 struct port *port; in bond_3ad_adapter_speed_duplex_changed() local
2517 port = &(SLAVE_AD_INFO(slave)->port); in bond_3ad_adapter_speed_duplex_changed()
2520 if (!port->slave) { in bond_3ad_adapter_speed_duplex_changed()
2527 ad_update_actor_keys(port, false); in bond_3ad_adapter_speed_duplex_changed()
2530 port->actor_port_number); in bond_3ad_adapter_speed_duplex_changed()
2543 struct port *port; in bond_3ad_handle_link_change() local
2546 port = &(SLAVE_AD_INFO(slave)->port); in bond_3ad_handle_link_change()
2549 if (!port->slave) { in bond_3ad_handle_link_change()
2563 port->is_enabled = true; in bond_3ad_handle_link_change()
2564 ad_update_actor_keys(port, false); in bond_3ad_handle_link_change()
2567 port->is_enabled = false; in bond_3ad_handle_link_change()
2568 ad_update_actor_keys(port, true); in bond_3ad_handle_link_change()
2570 agg = __get_first_agg(port); in bond_3ad_handle_link_change()
2576 port->actor_port_number, in bond_3ad_handle_link_change()
2644 struct port *port; in __bond_3ad_get_active_agg_info() local
2647 port = &(SLAVE_AD_INFO(slave)->port); in __bond_3ad_get_active_agg_info()
2648 if (port->aggregator && port->aggregator->is_active) { in __bond_3ad_get_active_agg_info()
2649 aggregator = port->aggregator; in __bond_3ad_get_active_agg_info()
2711 struct port *port = NULL; in bond_3ad_update_lacp_rate() local
2719 port = &(SLAVE_AD_INFO(slave)->port); in bond_3ad_update_lacp_rate()
2721 port->actor_oper_port_state |= LACP_STATE_LACP_TIMEOUT; in bond_3ad_update_lacp_rate()
2723 port->actor_oper_port_state &= ~LACP_STATE_LACP_TIMEOUT; in bond_3ad_update_lacp_rate()