• Home
  • Raw
  • Download

Lines Matching refs:port

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);
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_distributing(struct port *port,
107 static void ad_disable_collecting_distributing(struct port *port,
110 struct port *port);
112 struct port *port);
113 static void ad_update_actor_keys(struct port *port, bool reset);
124 static inline struct bonding *__get_bond_by_port(struct port *port) in __get_bond_by_port() argument
126 if (port->slave == NULL) in __get_bond_by_port()
129 return bond_get_bond_by_slave(port->slave); in __get_bond_by_port()
140 static inline struct aggregator *__get_first_agg(struct port *port) in __get_first_agg() argument
142 struct bonding *bond = __get_bond_by_port(port); in __get_first_agg()
174 static inline void __disable_port(struct port *port) in __disable_port() argument
176 bond_set_slave_inactive_flags(port->slave, BOND_SLAVE_NOTIFY_LATER); in __disable_port()
183 static inline void __enable_port(struct port *port) in __enable_port() argument
185 struct slave *slave = port->slave; in __enable_port()
195 static inline int __port_is_enabled(struct port *port) in __port_is_enabled() argument
197 return bond_is_active_slave(port->slave); in __port_is_enabled()
206 static inline u32 __get_agg_selection_mode(struct port *port) in __get_agg_selection_mode() argument
208 struct bonding *bond = __get_bond_by_port(port); in __get_agg_selection_mode()
220 static inline int __check_agg_selection_timer(struct port *port) in __check_agg_selection_timer() argument
222 struct bonding *bond = __get_bond_by_port(port); in __check_agg_selection_timer()
250 static u16 __get_link_speed(struct port *port) in __get_link_speed() argument
252 struct slave *slave = port->slave; in __get_link_speed()
322 port->actor_port_number); in __get_link_speed()
329 port->actor_port_number, speed); in __get_link_speed()
341 static u8 __get_duplex(struct port *port) in __get_duplex() argument
343 struct slave *slave = port->slave; in __get_duplex()
354 port->actor_port_number); in __get_duplex()
360 port->actor_port_number); in __get_duplex()
367 static void __ad_actor_update_port(struct port *port) in __ad_actor_update_port() argument
369 const struct bonding *bond = bond_get_bond_by_slave(port->slave); in __ad_actor_update_port()
371 port->actor_system = BOND_AD_INFO(bond).system.sys_mac_addr; in __ad_actor_update_port()
372 port->actor_system_priority = BOND_AD_INFO(bond).system.sys_priority; in __ad_actor_update_port()
440 static void __choose_matched(struct lacpdu *lacpdu, struct port *port) in __choose_matched() argument
446 if (((ntohs(lacpdu->partner_port) == port->actor_port_number) && in __choose_matched()
447 (ntohs(lacpdu->partner_port_priority) == port->actor_port_priority) && in __choose_matched()
448 MAC_ADDRESS_EQUAL(&(lacpdu->partner_system), &(port->actor_system)) && in __choose_matched()
449 (ntohs(lacpdu->partner_system_priority) == port->actor_system_priority) && in __choose_matched()
450 (ntohs(lacpdu->partner_key) == port->actor_oper_port_key) && in __choose_matched()
451 …((lacpdu->partner_state & LACP_STATE_AGGREGATION) == (port->actor_oper_port_state & LACP_STATE_AGG… in __choose_matched()
454 port->sm_vars |= AD_PORT_MATCHED; in __choose_matched()
456 port->sm_vars &= ~AD_PORT_MATCHED; in __choose_matched()
469 static void __record_pdu(struct lacpdu *lacpdu, struct port *port) in __record_pdu() argument
471 if (lacpdu && port) { in __record_pdu()
472 struct port_params *partner = &port->partner_oper; in __record_pdu()
474 __choose_matched(lacpdu, port); in __record_pdu()
486 port->actor_oper_port_state &= ~LACP_STATE_DEFAULTED; in __record_pdu()
491 if ((port->sm_vars & AD_PORT_MATCHED) && in __record_pdu()
494 slave_dbg(port->slave->bond->dev, port->slave->dev, in __record_pdu()
498 slave_dbg(port->slave->bond->dev, port->slave->dev, in __record_pdu()
512 static void __record_default(struct port *port) in __record_default() argument
514 if (port) { in __record_default()
516 memcpy(&port->partner_oper, &port->partner_admin, in __record_default()
520 port->actor_oper_port_state |= LACP_STATE_DEFAULTED; in __record_default()
537 static void __update_selected(struct lacpdu *lacpdu, struct port *port) in __update_selected() argument
539 if (lacpdu && port) { in __update_selected()
540 const struct port_params *partner = &port->partner_oper; in __update_selected()
551 port->sm_vars &= ~AD_PORT_SELECTED; in __update_selected()
568 static void __update_default_selected(struct port *port) in __update_default_selected() argument
570 if (port) { in __update_default_selected()
571 const struct port_params *admin = &port->partner_admin; in __update_default_selected()
572 const struct port_params *oper = &port->partner_oper; in __update_default_selected()
584 port->sm_vars &= ~AD_PORT_SELECTED; in __update_default_selected()
601 static void __update_ntt(struct lacpdu *lacpdu, struct port *port) in __update_ntt() argument
604 if (lacpdu && port) { in __update_ntt()
608 if ((ntohs(lacpdu->partner_port) != port->actor_port_number) || in __update_ntt()
609 (ntohs(lacpdu->partner_port_priority) != port->actor_port_priority) || in __update_ntt()
610 !MAC_ADDRESS_EQUAL(&(lacpdu->partner_system), &(port->actor_system)) || in __update_ntt()
611 (ntohs(lacpdu->partner_system_priority) != port->actor_system_priority) || in __update_ntt()
612 (ntohs(lacpdu->partner_key) != port->actor_oper_port_key) || in __update_ntt()
613 …((lacpdu->partner_state & LACP_STATE_LACP_ACTIVITY) != (port->actor_oper_port_state & LACP_STATE_L… in __update_ntt()
614 …((lacpdu->partner_state & LACP_STATE_LACP_TIMEOUT) != (port->actor_oper_port_state & LACP_STATE_LA… in __update_ntt()
615 …((lacpdu->partner_state & LACP_STATE_SYNCHRONIZATION) != (port->actor_oper_port_state & LACP_STATE… in __update_ntt()
616 …((lacpdu->partner_state & LACP_STATE_AGGREGATION) != (port->actor_oper_port_state & LACP_STATE_AGG… in __update_ntt()
618 port->ntt = true; in __update_ntt()
630 struct port *port; in __agg_ports_are_ready() local
637 for (port = aggregator->lag_ports; in __agg_ports_are_ready()
638 port; in __agg_ports_are_ready()
639 port = port->next_port_in_aggregator) { in __agg_ports_are_ready()
640 if (!(port->sm_vars & AD_PORT_READY_N)) { in __agg_ports_are_ready()
658 struct port *port; in __set_agg_ports_ready() local
660 for (port = aggregator->lag_ports; port; in __set_agg_ports_ready()
661 port = port->next_port_in_aggregator) { in __set_agg_ports_ready()
663 port->sm_vars |= AD_PORT_READY; in __set_agg_ports_ready()
665 port->sm_vars &= ~AD_PORT_READY; in __set_agg_ports_ready()
671 struct port *port; in __agg_active_ports() local
674 for (port = agg->lag_ports; port; in __agg_active_ports()
675 port = port->next_port_in_aggregator) { in __agg_active_ports()
676 if (port->is_enabled) in __agg_active_ports()
767 static inline void __update_lacpdu_from_port(struct port *port) in __update_lacpdu_from_port() argument
769 struct lacpdu *lacpdu = &port->lacpdu; in __update_lacpdu_from_port()
770 const struct port_params *partner = &port->partner_oper; in __update_lacpdu_from_port()
779 lacpdu->actor_system_priority = htons(port->actor_system_priority); in __update_lacpdu_from_port()
780 lacpdu->actor_system = port->actor_system; in __update_lacpdu_from_port()
781 lacpdu->actor_key = htons(port->actor_oper_port_key); in __update_lacpdu_from_port()
782 lacpdu->actor_port_priority = htons(port->actor_port_priority); in __update_lacpdu_from_port()
783 lacpdu->actor_port = htons(port->actor_port_number); in __update_lacpdu_from_port()
784 lacpdu->actor_state = port->actor_oper_port_state; in __update_lacpdu_from_port()
785 slave_dbg(port->slave->bond->dev, port->slave->dev, in __update_lacpdu_from_port()
787 port->actor_oper_port_state); in __update_lacpdu_from_port()
821 static int ad_lacpdu_send(struct port *port) in ad_lacpdu_send() argument
823 struct slave *slave = port->slave; in ad_lacpdu_send()
850 lacpdu_header->lacpdu = port->lacpdu; in ad_lacpdu_send()
865 static int ad_marker_send(struct port *port, struct bond_marker *marker) in ad_marker_send() argument
867 struct slave *slave = port->slave; in ad_marker_send()
915 static void ad_mux_machine(struct port *port, bool *update_slave_arr) in ad_mux_machine() argument
922 last_state = port->sm_mux_state; in ad_mux_machine()
924 if (port->sm_vars & AD_PORT_BEGIN) { in ad_mux_machine()
925 port->sm_mux_state = AD_MUX_DETACHED; in ad_mux_machine()
927 switch (port->sm_mux_state) { in ad_mux_machine()
929 if ((port->sm_vars & AD_PORT_SELECTED) in ad_mux_machine()
930 || (port->sm_vars & AD_PORT_STANDBY)) in ad_mux_machine()
932 port->sm_mux_state = AD_MUX_WAITING; in ad_mux_machine()
936 if (!(port->sm_vars & AD_PORT_SELECTED)) { in ad_mux_machine()
937 port->sm_vars &= ~AD_PORT_READY_N; in ad_mux_machine()
943 __set_agg_ports_ready(port->aggregator, __agg_ports_are_ready(port->aggregator)); in ad_mux_machine()
944 port->sm_mux_state = AD_MUX_DETACHED; in ad_mux_machine()
949 if (port->sm_mux_timer_counter in ad_mux_machine()
950 && !(--port->sm_mux_timer_counter)) in ad_mux_machine()
951 port->sm_vars |= AD_PORT_READY_N; in ad_mux_machine()
958 __set_agg_ports_ready(port->aggregator, __agg_ports_are_ready(port->aggregator)); in ad_mux_machine()
963 if ((port->sm_vars & AD_PORT_READY) in ad_mux_machine()
964 && !port->sm_mux_timer_counter) in ad_mux_machine()
965 port->sm_mux_state = AD_MUX_ATTACHED; in ad_mux_machine()
971 if ((port->sm_vars & AD_PORT_SELECTED) && in ad_mux_machine()
972 (port->partner_oper.port_state & LACP_STATE_SYNCHRONIZATION) && in ad_mux_machine()
973 !__check_agg_selection_timer(port)) { in ad_mux_machine()
974 if (port->aggregator->is_active) in ad_mux_machine()
975 port->sm_mux_state = in ad_mux_machine()
977 } else if (!(port->sm_vars & AD_PORT_SELECTED) || in ad_mux_machine()
978 (port->sm_vars & AD_PORT_STANDBY)) { in ad_mux_machine()
980 port->sm_vars &= ~AD_PORT_READY_N; in ad_mux_machine()
986 __set_agg_ports_ready(port->aggregator, __agg_ports_are_ready(port->aggregator)); in ad_mux_machine()
987 port->sm_mux_state = AD_MUX_DETACHED; in ad_mux_machine()
988 } else if (port->aggregator->is_active) { in ad_mux_machine()
989 port->actor_oper_port_state |= in ad_mux_machine()
994 if (!(port->sm_vars & AD_PORT_SELECTED) || in ad_mux_machine()
995 (port->sm_vars & AD_PORT_STANDBY) || in ad_mux_machine()
996 !(port->partner_oper.port_state & LACP_STATE_SYNCHRONIZATION) || in ad_mux_machine()
997 !(port->actor_oper_port_state & LACP_STATE_SYNCHRONIZATION)) { in ad_mux_machine()
998 port->sm_mux_state = AD_MUX_ATTACHED; in ad_mux_machine()
1004 if (port->aggregator && in ad_mux_machine()
1005 port->aggregator->is_active && in ad_mux_machine()
1006 !__port_is_enabled(port)) { in ad_mux_machine()
1007 __enable_port(port); in ad_mux_machine()
1018 if (port->sm_mux_state != last_state) { in ad_mux_machine()
1019 slave_dbg(port->slave->bond->dev, port->slave->dev, in ad_mux_machine()
1021 port->actor_port_number, in ad_mux_machine()
1023 port->sm_mux_state); in ad_mux_machine()
1024 switch (port->sm_mux_state) { in ad_mux_machine()
1026 port->actor_oper_port_state &= ~LACP_STATE_SYNCHRONIZATION; in ad_mux_machine()
1027 ad_disable_collecting_distributing(port, in ad_mux_machine()
1029 port->actor_oper_port_state &= ~LACP_STATE_COLLECTING; in ad_mux_machine()
1030 port->actor_oper_port_state &= ~LACP_STATE_DISTRIBUTING; in ad_mux_machine()
1031 port->ntt = true; in ad_mux_machine()
1034 port->sm_mux_timer_counter = __ad_timer_to_ticks(AD_WAIT_WHILE_TIMER, 0); in ad_mux_machine()
1037 if (port->aggregator->is_active) in ad_mux_machine()
1038 port->actor_oper_port_state |= in ad_mux_machine()
1041 port->actor_oper_port_state &= in ad_mux_machine()
1043 port->actor_oper_port_state &= ~LACP_STATE_COLLECTING; in ad_mux_machine()
1044 port->actor_oper_port_state &= ~LACP_STATE_DISTRIBUTING; in ad_mux_machine()
1045 ad_disable_collecting_distributing(port, in ad_mux_machine()
1047 port->ntt = true; in ad_mux_machine()
1050 port->actor_oper_port_state |= LACP_STATE_COLLECTING; in ad_mux_machine()
1051 port->actor_oper_port_state |= LACP_STATE_DISTRIBUTING; in ad_mux_machine()
1052 port->actor_oper_port_state |= LACP_STATE_SYNCHRONIZATION; in ad_mux_machine()
1053 ad_enable_collecting_distributing(port, in ad_mux_machine()
1055 port->ntt = true; in ad_mux_machine()
1072 static void ad_rx_machine(struct lacpdu *lacpdu, struct port *port) in ad_rx_machine() argument
1079 last_state = port->sm_rx_state; in ad_rx_machine()
1082 atomic64_inc(&SLAVE_AD_INFO(port->slave)->stats.lacpdu_rx); in ad_rx_machine()
1083 atomic64_inc(&BOND_AD_INFO(port->slave->bond).stats.lacpdu_rx); in ad_rx_machine()
1088 if (port->sm_vars & AD_PORT_BEGIN) { in ad_rx_machine()
1089 port->sm_rx_state = AD_RX_INITIALIZE; in ad_rx_machine()
1090 port->sm_vars |= AD_PORT_CHURNED; in ad_rx_machine()
1092 } else if (!(port->sm_vars & AD_PORT_BEGIN) && !port->is_enabled) in ad_rx_machine()
1093 port->sm_rx_state = AD_RX_PORT_DISABLED; in ad_rx_machine()
1095 else if (lacpdu && ((port->sm_rx_state == AD_RX_EXPIRED) || in ad_rx_machine()
1096 (port->sm_rx_state == AD_RX_DEFAULTED) || in ad_rx_machine()
1097 (port->sm_rx_state == AD_RX_CURRENT))) { in ad_rx_machine()
1098 if (port->sm_rx_state != AD_RX_CURRENT) in ad_rx_machine()
1099 port->sm_vars |= AD_PORT_CHURNED; in ad_rx_machine()
1100 port->sm_rx_timer_counter = 0; in ad_rx_machine()
1101 port->sm_rx_state = AD_RX_CURRENT; in ad_rx_machine()
1104 if (port->sm_rx_timer_counter && in ad_rx_machine()
1105 !(--port->sm_rx_timer_counter)) { in ad_rx_machine()
1106 switch (port->sm_rx_state) { in ad_rx_machine()
1108 port->sm_rx_state = AD_RX_DEFAULTED; in ad_rx_machine()
1111 port->sm_rx_state = AD_RX_EXPIRED; in ad_rx_machine()
1118 switch (port->sm_rx_state) { in ad_rx_machine()
1120 if (port->is_enabled && in ad_rx_machine()
1121 (port->sm_vars & AD_PORT_LACP_ENABLED)) in ad_rx_machine()
1122 port->sm_rx_state = AD_RX_EXPIRED; in ad_rx_machine()
1123 else if (port->is_enabled in ad_rx_machine()
1124 && ((port->sm_vars in ad_rx_machine()
1126 port->sm_rx_state = AD_RX_LACP_DISABLED; in ad_rx_machine()
1136 if ((port->sm_rx_state != last_state) || (lacpdu)) { in ad_rx_machine()
1137 slave_dbg(port->slave->bond->dev, port->slave->dev, in ad_rx_machine()
1139 port->actor_port_number, in ad_rx_machine()
1141 port->sm_rx_state); in ad_rx_machine()
1142 switch (port->sm_rx_state) { in ad_rx_machine()
1144 if (!(port->actor_oper_port_key & AD_DUPLEX_KEY_MASKS)) in ad_rx_machine()
1145 port->sm_vars &= ~AD_PORT_LACP_ENABLED; in ad_rx_machine()
1147 port->sm_vars |= AD_PORT_LACP_ENABLED; in ad_rx_machine()
1148 port->sm_vars &= ~AD_PORT_SELECTED; in ad_rx_machine()
1149 __record_default(port); in ad_rx_machine()
1150 port->actor_oper_port_state &= ~LACP_STATE_EXPIRED; in ad_rx_machine()
1151 port->sm_rx_state = AD_RX_PORT_DISABLED; in ad_rx_machine()
1155 port->sm_vars &= ~AD_PORT_MATCHED; in ad_rx_machine()
1158 port->sm_vars &= ~AD_PORT_SELECTED; in ad_rx_machine()
1159 __record_default(port); in ad_rx_machine()
1160 port->partner_oper.port_state &= ~LACP_STATE_AGGREGATION; in ad_rx_machine()
1161 port->sm_vars |= AD_PORT_MATCHED; in ad_rx_machine()
1162 port->actor_oper_port_state &= ~LACP_STATE_EXPIRED; in ad_rx_machine()
1171 port->partner_oper.port_state &= ~LACP_STATE_SYNCHRONIZATION; in ad_rx_machine()
1172 port->sm_vars &= ~AD_PORT_MATCHED; in ad_rx_machine()
1173 port->partner_oper.port_state |= LACP_STATE_LACP_TIMEOUT; in ad_rx_machine()
1174 port->partner_oper.port_state |= LACP_STATE_LACP_ACTIVITY; in ad_rx_machine()
1175 port->sm_rx_timer_counter = __ad_timer_to_ticks(AD_CURRENT_WHILE_TIMER, (u16)(AD_SHORT_TIMEOUT)); in ad_rx_machine()
1176 port->actor_oper_port_state |= LACP_STATE_EXPIRED; in ad_rx_machine()
1177 port->sm_vars |= AD_PORT_CHURNED; in ad_rx_machine()
1180 __update_default_selected(port); in ad_rx_machine()
1181 __record_default(port); in ad_rx_machine()
1182 port->sm_vars |= AD_PORT_MATCHED; in ad_rx_machine()
1183 port->actor_oper_port_state &= ~LACP_STATE_EXPIRED; in ad_rx_machine()
1188 &(port->actor_system))) { in ad_rx_machine()
1189 slave_err(port->slave->bond->dev, port->slave->dev, "An illegal loopback occurred on slave\n" in ad_rx_machine()
1193 __update_selected(lacpdu, port); in ad_rx_machine()
1194 __update_ntt(lacpdu, port); in ad_rx_machine()
1195 __record_pdu(lacpdu, port); in ad_rx_machine()
1196port->sm_rx_timer_counter = __ad_timer_to_ticks(AD_CURRENT_WHILE_TIMER, (u16)(port->actor_oper_por… in ad_rx_machine()
1197 port->actor_oper_port_state &= ~LACP_STATE_EXPIRED; in ad_rx_machine()
1210 static void ad_churn_machine(struct port *port) in ad_churn_machine() argument
1212 if (port->sm_vars & AD_PORT_CHURNED) { in ad_churn_machine()
1213 port->sm_vars &= ~AD_PORT_CHURNED; in ad_churn_machine()
1214 port->sm_churn_actor_state = AD_CHURN_MONITOR; in ad_churn_machine()
1215 port->sm_churn_partner_state = AD_CHURN_MONITOR; in ad_churn_machine()
1216 port->sm_churn_actor_timer_counter = in ad_churn_machine()
1218 port->sm_churn_partner_timer_counter = in ad_churn_machine()
1222 if (port->sm_churn_actor_timer_counter && in ad_churn_machine()
1223 !(--port->sm_churn_actor_timer_counter) && in ad_churn_machine()
1224 port->sm_churn_actor_state == AD_CHURN_MONITOR) { in ad_churn_machine()
1225 if (port->actor_oper_port_state & LACP_STATE_SYNCHRONIZATION) { in ad_churn_machine()
1226 port->sm_churn_actor_state = AD_NO_CHURN; in ad_churn_machine()
1228 port->churn_actor_count++; in ad_churn_machine()
1229 port->sm_churn_actor_state = AD_CHURN; in ad_churn_machine()
1232 if (port->sm_churn_partner_timer_counter && in ad_churn_machine()
1233 !(--port->sm_churn_partner_timer_counter) && in ad_churn_machine()
1234 port->sm_churn_partner_state == AD_CHURN_MONITOR) { in ad_churn_machine()
1235 if (port->partner_oper.port_state & LACP_STATE_SYNCHRONIZATION) { in ad_churn_machine()
1236 port->sm_churn_partner_state = AD_NO_CHURN; in ad_churn_machine()
1238 port->churn_partner_count++; in ad_churn_machine()
1239 port->sm_churn_partner_state = AD_CHURN; in ad_churn_machine()
1248 static void ad_tx_machine(struct port *port) in ad_tx_machine() argument
1253 if (port->sm_tx_timer_counter && !(--port->sm_tx_timer_counter)) { in ad_tx_machine()
1255 if (port->ntt && (port->sm_vars & AD_PORT_LACP_ENABLED)) { in ad_tx_machine()
1256 __update_lacpdu_from_port(port); in ad_tx_machine()
1258 if (ad_lacpdu_send(port) >= 0) { in ad_tx_machine()
1259 slave_dbg(port->slave->bond->dev, in ad_tx_machine()
1260 port->slave->dev, in ad_tx_machine()
1262 port->actor_port_number); in ad_tx_machine()
1267 port->ntt = false; in ad_tx_machine()
1273 port->sm_tx_timer_counter = ad_ticks_per_sec/AD_MAX_TX_IN_SECOND; in ad_tx_machine()
1283 static void ad_periodic_machine(struct port *port) in ad_periodic_machine() argument
1288 last_state = port->sm_periodic_state; in ad_periodic_machine()
1291 …if (((port->sm_vars & AD_PORT_BEGIN) || !(port->sm_vars & AD_PORT_LACP_ENABLED) || !port->is_enabl… in ad_periodic_machine()
1292 …(!(port->actor_oper_port_state & LACP_STATE_LACP_ACTIVITY) && !(port->partner_oper.port_state & LA… in ad_periodic_machine()
1294 port->sm_periodic_state = AD_NO_PERIODIC; in ad_periodic_machine()
1297 else if (port->sm_periodic_timer_counter) { in ad_periodic_machine()
1299 if (!(--port->sm_periodic_timer_counter)) { in ad_periodic_machine()
1301 port->sm_periodic_state = AD_PERIODIC_TX; in ad_periodic_machine()
1306 switch (port->sm_periodic_state) { in ad_periodic_machine()
1308 if (!(port->partner_oper.port_state in ad_periodic_machine()
1310 port->sm_periodic_state = AD_SLOW_PERIODIC; in ad_periodic_machine()
1313 if ((port->partner_oper.port_state & LACP_STATE_LACP_TIMEOUT)) { in ad_periodic_machine()
1314 port->sm_periodic_timer_counter = 0; in ad_periodic_machine()
1315 port->sm_periodic_state = AD_PERIODIC_TX; in ad_periodic_machine()
1323 switch (port->sm_periodic_state) { in ad_periodic_machine()
1325 port->sm_periodic_state = AD_FAST_PERIODIC; 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()
1332 port->sm_periodic_state = AD_FAST_PERIODIC; in ad_periodic_machine()
1340 if (port->sm_periodic_state != last_state) { in ad_periodic_machine()
1341 slave_dbg(port->slave->bond->dev, port->slave->dev, in ad_periodic_machine()
1343 port->actor_port_number, last_state, in ad_periodic_machine()
1344 port->sm_periodic_state); in ad_periodic_machine()
1345 switch (port->sm_periodic_state) { in ad_periodic_machine()
1347 port->sm_periodic_timer_counter = 0; in ad_periodic_machine()
1351port->sm_periodic_timer_counter = __ad_timer_to_ticks(AD_PERIODIC_TIMER, (u16)(AD_FAST_PERIODIC_TI… in ad_periodic_machine()
1355port->sm_periodic_timer_counter = __ad_timer_to_ticks(AD_PERIODIC_TIMER, (u16)(AD_SLOW_PERIODIC_TI… in ad_periodic_machine()
1358 port->ntt = true; in ad_periodic_machine()
1375 static void ad_port_selection_logic(struct port *port, bool *update_slave_arr) in ad_port_selection_logic() argument
1378 struct port *last_port = NULL, *curr_port; in ad_port_selection_logic()
1385 if (port->sm_vars & AD_PORT_SELECTED) in ad_port_selection_logic()
1388 bond = __get_bond_by_port(port); in ad_port_selection_logic()
1391 if (port->aggregator) { in ad_port_selection_logic()
1393 temp_aggregator = port->aggregator; in ad_port_selection_logic()
1397 if (curr_port == port) { in ad_port_selection_logic()
1404 port->next_port_in_aggregator; in ad_port_selection_logic()
1410 port->next_port_in_aggregator; in ad_port_selection_logic()
1416 port->aggregator = NULL; in ad_port_selection_logic()
1417 port->next_port_in_aggregator = NULL; in ad_port_selection_logic()
1418 port->actor_port_aggregator_identifier = 0; in ad_port_selection_logic()
1420 slave_dbg(bond->dev, port->slave->dev, "Port %d left LAG %d\n", in ad_port_selection_logic()
1421 port->actor_port_number, in ad_port_selection_logic()
1436 port->slave->bond->dev->name, in ad_port_selection_logic()
1437 port->slave->dev->name, in ad_port_selection_logic()
1438 port->actor_port_number, in ad_port_selection_logic()
1439 port->aggregator->aggregator_identifier); in ad_port_selection_logic()
1453 …if (((aggregator->actor_oper_aggregator_key == port->actor_oper_port_key) && /* if all parameters … in ad_port_selection_logic()
1454 MAC_ADDRESS_EQUAL(&(aggregator->partner_system), &(port->partner_oper.system)) && in ad_port_selection_logic()
1455 (aggregator->partner_system_priority == port->partner_oper.system_priority) && in ad_port_selection_logic()
1456 (aggregator->partner_oper_aggregator_key == port->partner_oper.key) in ad_port_selection_logic()
1458 ((!MAC_ADDRESS_EQUAL(&(port->partner_oper.system), &(null_mac_addr)) && /* partner answers */ in ad_port_selection_logic()
1463 port->aggregator = aggregator; in ad_port_selection_logic()
1464 port->actor_port_aggregator_identifier = in ad_port_selection_logic()
1465 port->aggregator->aggregator_identifier; in ad_port_selection_logic()
1466 port->next_port_in_aggregator = aggregator->lag_ports; in ad_port_selection_logic()
1467 port->aggregator->num_of_ports++; in ad_port_selection_logic()
1468 aggregator->lag_ports = port; in ad_port_selection_logic()
1470 port->actor_port_number, in ad_port_selection_logic()
1471 port->aggregator->aggregator_identifier); in ad_port_selection_logic()
1474 port->sm_vars |= AD_PORT_SELECTED; in ad_port_selection_logic()
1486 port->aggregator = free_aggregator; in ad_port_selection_logic()
1487 port->actor_port_aggregator_identifier = in ad_port_selection_logic()
1488 port->aggregator->aggregator_identifier; in ad_port_selection_logic()
1493 if (port->actor_oper_port_key & AD_DUPLEX_KEY_MASKS) in ad_port_selection_logic()
1495 port->aggregator->is_individual = false; in ad_port_selection_logic()
1497 port->aggregator->is_individual = true; in ad_port_selection_logic()
1499 port->aggregator->actor_admin_aggregator_key = in ad_port_selection_logic()
1500 port->actor_admin_port_key; in ad_port_selection_logic()
1501 port->aggregator->actor_oper_aggregator_key = in ad_port_selection_logic()
1502 port->actor_oper_port_key; in ad_port_selection_logic()
1503 port->aggregator->partner_system = in ad_port_selection_logic()
1504 port->partner_oper.system; in ad_port_selection_logic()
1505 port->aggregator->partner_system_priority = in ad_port_selection_logic()
1506 port->partner_oper.system_priority; in ad_port_selection_logic()
1507 port->aggregator->partner_oper_aggregator_key = port->partner_oper.key; in ad_port_selection_logic()
1508 port->aggregator->receive_state = 1; in ad_port_selection_logic()
1509 port->aggregator->transmit_state = 1; in ad_port_selection_logic()
1510 port->aggregator->lag_ports = port; in ad_port_selection_logic()
1511 port->aggregator->num_of_ports++; in ad_port_selection_logic()
1514 port->sm_vars |= AD_PORT_SELECTED; in ad_port_selection_logic()
1516 slave_dbg(bond->dev, port->slave->dev, "Port %d joined LAG %d (new LAG)\n", in ad_port_selection_logic()
1517 port->actor_port_number, in ad_port_selection_logic()
1518 port->aggregator->aggregator_identifier); in ad_port_selection_logic()
1520 slave_err(bond->dev, port->slave->dev, in ad_port_selection_logic()
1522 port->actor_port_number); in ad_port_selection_logic()
1529 __set_agg_ports_ready(port->aggregator, in ad_port_selection_logic()
1530 __agg_ports_are_ready(port->aggregator)); in ad_port_selection_logic()
1532 aggregator = __get_first_agg(port); in ad_port_selection_logic()
1535 if (!port->aggregator->is_active) in ad_port_selection_logic()
1536 port->actor_oper_port_state &= ~LACP_STATE_SYNCHRONIZATION; in ad_port_selection_logic()
1613 struct port *port = agg->lag_ports; in agg_device_up() local
1615 if (!port) in agg_device_up()
1618 for (port = agg->lag_ports; port; in agg_device_up()
1619 port = port->next_port_in_aggregator) { in agg_device_up()
1620 if (netif_running(port->slave->dev) && in agg_device_up()
1621 netif_carrier_ok(port->slave->dev)) in agg_device_up()
1661 struct port *port; in ad_agg_selection_logic() local
1744 for (port = active->lag_ports; port; in ad_agg_selection_logic()
1745 port = port->next_port_in_aggregator) { in ad_agg_selection_logic()
1746 __disable_port(port); in ad_agg_selection_logic()
1760 for (port = active->lag_ports; port; in ad_agg_selection_logic()
1761 port = port->next_port_in_aggregator) { in ad_agg_selection_logic()
1762 __enable_port(port); in ad_agg_selection_logic()
1818 static void ad_initialize_port(struct port *port, int lacp_fast) in ad_initialize_port() argument
1839 if (port) { in ad_initialize_port()
1840 port->actor_port_priority = 0xff; in ad_initialize_port()
1841 port->actor_port_aggregator_identifier = 0; in ad_initialize_port()
1842 port->ntt = false; in ad_initialize_port()
1843 port->actor_admin_port_state = LACP_STATE_AGGREGATION | in ad_initialize_port()
1845 port->actor_oper_port_state = LACP_STATE_AGGREGATION | in ad_initialize_port()
1849 port->actor_oper_port_state |= LACP_STATE_LACP_TIMEOUT; in ad_initialize_port()
1851 memcpy(&port->partner_admin, &tmpl, sizeof(tmpl)); in ad_initialize_port()
1852 memcpy(&port->partner_oper, &tmpl, sizeof(tmpl)); in ad_initialize_port()
1854 port->is_enabled = true; in ad_initialize_port()
1856 port->sm_vars = AD_PORT_BEGIN | AD_PORT_LACP_ENABLED; in ad_initialize_port()
1857 port->sm_rx_state = 0; in ad_initialize_port()
1858 port->sm_rx_timer_counter = 0; in ad_initialize_port()
1859 port->sm_periodic_state = 0; in ad_initialize_port()
1860 port->sm_periodic_timer_counter = 0; in ad_initialize_port()
1861 port->sm_mux_state = 0; in ad_initialize_port()
1862 port->sm_mux_timer_counter = 0; in ad_initialize_port()
1863 port->sm_tx_state = 0; in ad_initialize_port()
1864 port->aggregator = NULL; in ad_initialize_port()
1865 port->next_port_in_aggregator = NULL; in ad_initialize_port()
1866 port->transaction_id = 0; in ad_initialize_port()
1868 port->sm_churn_actor_timer_counter = 0; in ad_initialize_port()
1869 port->sm_churn_actor_state = 0; in ad_initialize_port()
1870 port->churn_actor_count = 0; in ad_initialize_port()
1871 port->sm_churn_partner_timer_counter = 0; in ad_initialize_port()
1872 port->sm_churn_partner_state = 0; in ad_initialize_port()
1873 port->churn_partner_count = 0; in ad_initialize_port()
1875 memcpy(&port->lacpdu, &lacpdu, sizeof(lacpdu)); in ad_initialize_port()
1886 static void ad_enable_collecting_distributing(struct port *port, in ad_enable_collecting_distributing() argument
1889 if (port->aggregator->is_active) { in ad_enable_collecting_distributing()
1890 slave_dbg(port->slave->bond->dev, port->slave->dev, in ad_enable_collecting_distributing()
1892 port->actor_port_number, in ad_enable_collecting_distributing()
1893 port->aggregator->aggregator_identifier); in ad_enable_collecting_distributing()
1894 __enable_port(port); in ad_enable_collecting_distributing()
1905 static void ad_disable_collecting_distributing(struct port *port, in ad_disable_collecting_distributing() argument
1908 if (port->aggregator && in ad_disable_collecting_distributing()
1909 !MAC_ADDRESS_EQUAL(&(port->aggregator->partner_system), in ad_disable_collecting_distributing()
1911 slave_dbg(port->slave->bond->dev, port->slave->dev, in ad_disable_collecting_distributing()
1913 port->actor_port_number, in ad_disable_collecting_distributing()
1914 port->aggregator->aggregator_identifier); in ad_disable_collecting_distributing()
1915 __disable_port(port); in ad_disable_collecting_distributing()
1927 struct port *port) in ad_marker_info_received() argument
1931 atomic64_inc(&SLAVE_AD_INFO(port->slave)->stats.marker_rx); in ad_marker_info_received()
1932 atomic64_inc(&BOND_AD_INFO(port->slave->bond).stats.marker_rx); in ad_marker_info_received()
1940 if (ad_marker_send(port, &marker) >= 0) in ad_marker_info_received()
1941 slave_dbg(port->slave->bond->dev, port->slave->dev, in ad_marker_info_received()
1943 port->actor_port_number); in ad_marker_info_received()
1956 struct port *port) in ad_marker_response_received() argument
1958 atomic64_inc(&SLAVE_AD_INFO(port->slave)->stats.marker_resp_rx); in ad_marker_response_received()
1959 atomic64_inc(&BOND_AD_INFO(port->slave->bond).stats.marker_resp_rx); in ad_marker_response_received()
2022 struct port *port; in bond_3ad_bind_slave() local
2026 if (SLAVE_AD_INFO(slave)->port.slave != slave) { in bond_3ad_bind_slave()
2029 port = &(SLAVE_AD_INFO(slave)->port); in bond_3ad_bind_slave()
2031 ad_initialize_port(port, bond->params.lacp_fast); in bond_3ad_bind_slave()
2033 port->slave = slave; in bond_3ad_bind_slave()
2034 port->actor_port_number = SLAVE_AD_INFO(slave)->id; in bond_3ad_bind_slave()
2038 port->actor_admin_port_key = bond->params.ad_user_port_key << 6; in bond_3ad_bind_slave()
2039 ad_update_actor_keys(port, false); in bond_3ad_bind_slave()
2041 __ad_actor_update_port(port); in bond_3ad_bind_slave()
2045 port->sm_tx_timer_counter = ad_ticks_per_sec/AD_MAX_TX_IN_SECOND; in bond_3ad_bind_slave()
2047 __disable_port(port); in bond_3ad_bind_slave()
2072 struct port *port, *prev_port, *temp_port; in bond_3ad_unbind_slave() local
2083 port = &(SLAVE_AD_INFO(slave)->port); in bond_3ad_unbind_slave()
2086 if (!port->slave) { in bond_3ad_unbind_slave()
2095 port->actor_oper_port_state &= ~LACP_STATE_SYNCHRONIZATION; in bond_3ad_unbind_slave()
2096 port->actor_oper_port_state &= ~LACP_STATE_COLLECTING; in bond_3ad_unbind_slave()
2097 port->actor_oper_port_state &= ~LACP_STATE_DISTRIBUTING; in bond_3ad_unbind_slave()
2098 port->actor_oper_port_state &= ~LACP_STATE_AGGREGATION; in bond_3ad_unbind_slave()
2099 __update_lacpdu_from_port(port); in bond_3ad_unbind_slave()
2100 ad_lacpdu_send(port); in bond_3ad_unbind_slave()
2109 if ((aggregator->lag_ports != port) || in bond_3ad_unbind_slave()
2118 ((new_aggregator->lag_ports == port) && in bond_3ad_unbind_slave()
2129 …if ((new_aggregator) && ((!new_aggregator->lag_ports) || ((new_aggregator->lag_ports == port) && !… in bond_3ad_unbind_slave()
2134 if ((new_aggregator->lag_ports == port) && in bond_3ad_unbind_slave()
2164 ad_agg_selection_logic(__get_first_agg(port), in bond_3ad_unbind_slave()
2178 temp_aggregator = __get_first_agg(port); in bond_3ad_unbind_slave()
2186 slave_dbg(bond->dev, slave->dev, "Unbinding port %d\n", port->actor_port_number); in bond_3ad_unbind_slave()
2196 if (temp_port == port) { in bond_3ad_unbind_slave()
2212 ad_agg_selection_logic(__get_first_agg(port), in bond_3ad_unbind_slave()
2220 port->slave = NULL; in bond_3ad_unbind_slave()
2250 struct port *port = &(SLAVE_AD_INFO(slave))->port; in bond_3ad_update_ad_actor_settings() local
2252 __ad_actor_update_port(port); in bond_3ad_update_ad_actor_settings()
2253 port->ntt = true; in bond_3ad_update_ad_actor_settings()
2300 struct port *port; in bond_3ad_state_machine_handler() local
2317 port = slave ? &(SLAVE_AD_INFO(slave)->port) : NULL; in bond_3ad_state_machine_handler()
2320 if (port) { in bond_3ad_state_machine_handler()
2321 if (!port->slave) { in bond_3ad_state_machine_handler()
2327 aggregator = __get_first_agg(port); in bond_3ad_state_machine_handler()
2335 port = &(SLAVE_AD_INFO(slave)->port); in bond_3ad_state_machine_handler()
2336 if (!port->slave) { in bond_3ad_state_machine_handler()
2342 ad_rx_machine(NULL, port); in bond_3ad_state_machine_handler()
2343 ad_periodic_machine(port); in bond_3ad_state_machine_handler()
2344 ad_port_selection_logic(port, &update_slave_arr); in bond_3ad_state_machine_handler()
2345 ad_mux_machine(port, &update_slave_arr); in bond_3ad_state_machine_handler()
2346 ad_tx_machine(port); in bond_3ad_state_machine_handler()
2347 ad_churn_machine(port); in bond_3ad_state_machine_handler()
2350 if (port->sm_vars & AD_PORT_BEGIN) in bond_3ad_state_machine_handler()
2351 port->sm_vars &= ~AD_PORT_BEGIN; in bond_3ad_state_machine_handler()
2388 struct port *port; in bond_3ad_rx_indication() local
2391 port = &(SLAVE_AD_INFO(slave)->port); in bond_3ad_rx_indication()
2392 if (!port->slave) { in bond_3ad_rx_indication()
2403 port->actor_port_number); in bond_3ad_rx_indication()
2406 ad_rx_machine(lacpdu, port); in bond_3ad_rx_indication()
2418 port->actor_port_number); in bond_3ad_rx_indication()
2419 ad_marker_info_received(marker, port); in bond_3ad_rx_indication()
2423 port->actor_port_number); in bond_3ad_rx_indication()
2424 ad_marker_response_received(marker, port); in bond_3ad_rx_indication()
2428 port->actor_port_number); in bond_3ad_rx_indication()
2454 static void ad_update_actor_keys(struct port *port, bool reset) in ad_update_actor_keys() argument
2458 u16 old_oper_key = port->actor_oper_port_key; in ad_update_actor_keys()
2460 port->actor_admin_port_key &= ~(AD_SPEED_KEY_MASKS|AD_DUPLEX_KEY_MASKS); in ad_update_actor_keys()
2462 speed = __get_link_speed(port); in ad_update_actor_keys()
2464 duplex = __get_duplex(port); in ad_update_actor_keys()
2465 port->actor_admin_port_key |= (speed << 1) | duplex; in ad_update_actor_keys()
2467 port->actor_oper_port_key = port->actor_admin_port_key; in ad_update_actor_keys()
2469 if (old_oper_key != port->actor_oper_port_key) { in ad_update_actor_keys()
2472 port->sm_vars |= AD_PORT_LACP_ENABLED; in ad_update_actor_keys()
2474 port->sm_vars &= ~AD_PORT_LACP_ENABLED; in ad_update_actor_keys()
2478 slave_err(port->slave->bond->dev, in ad_update_actor_keys()
2479 port->slave->dev, in ad_update_actor_keys()
2481 port->actor_port_number); in ad_update_actor_keys()
2484 port->sm_vars |= AD_PORT_BEGIN; in ad_update_actor_keys()
2500 struct port *port; in bond_3ad_adapter_speed_duplex_changed() local
2502 port = &(SLAVE_AD_INFO(slave)->port); in bond_3ad_adapter_speed_duplex_changed()
2505 if (!port->slave) { in bond_3ad_adapter_speed_duplex_changed()
2512 ad_update_actor_keys(port, false); in bond_3ad_adapter_speed_duplex_changed()
2515 port->actor_port_number); in bond_3ad_adapter_speed_duplex_changed()
2528 struct port *port; in bond_3ad_handle_link_change() local
2531 port = &(SLAVE_AD_INFO(slave)->port); in bond_3ad_handle_link_change()
2534 if (!port->slave) { in bond_3ad_handle_link_change()
2548 port->is_enabled = true; in bond_3ad_handle_link_change()
2549 ad_update_actor_keys(port, false); in bond_3ad_handle_link_change()
2552 port->is_enabled = false; in bond_3ad_handle_link_change()
2553 ad_update_actor_keys(port, true); in bond_3ad_handle_link_change()
2555 agg = __get_first_agg(port); in bond_3ad_handle_link_change()
2561 port->actor_port_number, in bond_3ad_handle_link_change()
2629 struct port *port; in __bond_3ad_get_active_agg_info() local
2632 port = &(SLAVE_AD_INFO(slave)->port); in __bond_3ad_get_active_agg_info()
2633 if (port->aggregator && port->aggregator->is_active) { in __bond_3ad_get_active_agg_info()
2634 aggregator = port->aggregator; in __bond_3ad_get_active_agg_info()
2696 struct port *port = NULL; in bond_3ad_update_lacp_rate() local
2704 port = &(SLAVE_AD_INFO(slave)->port); in bond_3ad_update_lacp_rate()
2706 port->actor_oper_port_state |= LACP_STATE_LACP_TIMEOUT; in bond_3ad_update_lacp_rate()
2708 port->actor_oper_port_state &= ~LACP_STATE_LACP_TIMEOUT; in bond_3ad_update_lacp_rate()