diff options
author | Bandan Das <bandan.das@stratus.com> | 2010-10-16 16:19:59 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2010-10-21 06:09:49 -0400 |
commit | 7bfc47532301a84c575cfc20b4531f5de5c326bc (patch) | |
tree | fbe14b9923e12084c1b983fc09ba8158744907cc /drivers | |
parent | 128ea6c3eece8e87c05813d3a57f4ea079c3dbc7 (diff) |
bonding: cleanup: remove braces from single block statements
checkpatch.pl cleanup : Remove braces from single statement
blocks.
Signed-off-by: Bandan Das <bandan.das@stratus.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/net/bonding/bond_3ad.c | 163 |
1 files changed, 72 insertions, 91 deletions
diff --git a/drivers/net/bonding/bond_3ad.c b/drivers/net/bonding/bond_3ad.c index 6b06b00af359..881914bc4e9c 100644 --- a/drivers/net/bonding/bond_3ad.c +++ b/drivers/net/bonding/bond_3ad.c | |||
@@ -129,9 +129,8 @@ static void ad_marker_response_received(struct bond_marker *marker, struct port | |||
129 | */ | 129 | */ |
130 | static inline struct bonding *__get_bond_by_port(struct port *port) | 130 | static inline struct bonding *__get_bond_by_port(struct port *port) |
131 | { | 131 | { |
132 | if (port->slave == NULL) { | 132 | if (port->slave == NULL) |
133 | return NULL; | 133 | return NULL; |
134 | } | ||
135 | 134 | ||
136 | return bond_get_bond_by_slave(port->slave); | 135 | return bond_get_bond_by_slave(port->slave); |
137 | } | 136 | } |
@@ -144,9 +143,8 @@ static inline struct bonding *__get_bond_by_port(struct port *port) | |||
144 | */ | 143 | */ |
145 | static inline struct port *__get_first_port(struct bonding *bond) | 144 | static inline struct port *__get_first_port(struct bonding *bond) |
146 | { | 145 | { |
147 | if (bond->slave_cnt == 0) { | 146 | if (bond->slave_cnt == 0) |
148 | return NULL; | 147 | return NULL; |
149 | } | ||
150 | 148 | ||
151 | return &(SLAVE_AD_INFO(bond->first_slave).port); | 149 | return &(SLAVE_AD_INFO(bond->first_slave).port); |
152 | } | 150 | } |
@@ -164,9 +162,8 @@ static inline struct port *__get_next_port(struct port *port) | |||
164 | struct slave *slave = port->slave; | 162 | struct slave *slave = port->slave; |
165 | 163 | ||
166 | // If there's no bond for this port, or this is the last slave | 164 | // If there's no bond for this port, or this is the last slave |
167 | if ((bond == NULL) || (slave->next == bond->first_slave)) { | 165 | if ((bond == NULL) || (slave->next == bond->first_slave)) |
168 | return NULL; | 166 | return NULL; |
169 | } | ||
170 | 167 | ||
171 | return &(SLAVE_AD_INFO(slave->next).port); | 168 | return &(SLAVE_AD_INFO(slave->next).port); |
172 | } | 169 | } |
@@ -183,9 +180,8 @@ static inline struct aggregator *__get_first_agg(struct port *port) | |||
183 | struct bonding *bond = __get_bond_by_port(port); | 180 | struct bonding *bond = __get_bond_by_port(port); |
184 | 181 | ||
185 | // If there's no bond for this port, or bond has no slaves | 182 | // If there's no bond for this port, or bond has no slaves |
186 | if ((bond == NULL) || (bond->slave_cnt == 0)) { | 183 | if ((bond == NULL) || (bond->slave_cnt == 0)) |
187 | return NULL; | 184 | return NULL; |
188 | } | ||
189 | 185 | ||
190 | return &(SLAVE_AD_INFO(bond->first_slave).aggregator); | 186 | return &(SLAVE_AD_INFO(bond->first_slave).aggregator); |
191 | } | 187 | } |
@@ -203,9 +199,8 @@ static inline struct aggregator *__get_next_agg(struct aggregator *aggregator) | |||
203 | struct bonding *bond = bond_get_bond_by_slave(slave); | 199 | struct bonding *bond = bond_get_bond_by_slave(slave); |
204 | 200 | ||
205 | // If there's no bond for this aggregator, or this is the last slave | 201 | // If there's no bond for this aggregator, or this is the last slave |
206 | if ((bond == NULL) || (slave->next == bond->first_slave)) { | 202 | if ((bond == NULL) || (slave->next == bond->first_slave)) |
207 | return NULL; | 203 | return NULL; |
208 | } | ||
209 | 204 | ||
210 | return &(SLAVE_AD_INFO(slave->next).aggregator); | 205 | return &(SLAVE_AD_INFO(slave->next).aggregator); |
211 | } | 206 | } |
@@ -240,9 +235,8 @@ static inline void __enable_port(struct port *port) | |||
240 | { | 235 | { |
241 | struct slave *slave = port->slave; | 236 | struct slave *slave = port->slave; |
242 | 237 | ||
243 | if ((slave->link == BOND_LINK_UP) && IS_UP(slave->dev)) { | 238 | if ((slave->link == BOND_LINK_UP) && IS_UP(slave->dev)) |
244 | bond_set_slave_active_flags(slave); | 239 | bond_set_slave_active_flags(slave); |
245 | } | ||
246 | } | 240 | } |
247 | 241 | ||
248 | /** | 242 | /** |
@@ -265,9 +259,8 @@ static inline u32 __get_agg_selection_mode(struct port *port) | |||
265 | { | 259 | { |
266 | struct bonding *bond = __get_bond_by_port(port); | 260 | struct bonding *bond = __get_bond_by_port(port); |
267 | 261 | ||
268 | if (bond == NULL) { | 262 | if (bond == NULL) |
269 | return BOND_AD_STABLE; | 263 | return BOND_AD_STABLE; |
270 | } | ||
271 | 264 | ||
272 | return BOND_AD_INFO(bond).agg_select_mode; | 265 | return BOND_AD_INFO(bond).agg_select_mode; |
273 | } | 266 | } |
@@ -281,9 +274,8 @@ static inline int __check_agg_selection_timer(struct port *port) | |||
281 | { | 274 | { |
282 | struct bonding *bond = __get_bond_by_port(port); | 275 | struct bonding *bond = __get_bond_by_port(port); |
283 | 276 | ||
284 | if (bond == NULL) { | 277 | if (bond == NULL) |
285 | return 0; | 278 | return 0; |
286 | } | ||
287 | 279 | ||
288 | return BOND_AD_INFO(bond).agg_select_timer ? 1 : 0; | 280 | return BOND_AD_INFO(bond).agg_select_timer ? 1 : 0; |
289 | } | 281 | } |
@@ -328,9 +320,9 @@ static u16 __get_link_speed(struct port *port) | |||
328 | * link down, it sets the speed to 0. | 320 | * link down, it sets the speed to 0. |
329 | * This is done in spite of the fact that the e100 driver reports 0 to be | 321 | * This is done in spite of the fact that the e100 driver reports 0 to be |
330 | * compatible with MVT in the future.*/ | 322 | * compatible with MVT in the future.*/ |
331 | if (slave->link != BOND_LINK_UP) { | 323 | if (slave->link != BOND_LINK_UP) |
332 | speed = 0; | 324 | speed = 0; |
333 | } else { | 325 | else { |
334 | switch (slave->speed) { | 326 | switch (slave->speed) { |
335 | case SPEED_10: | 327 | case SPEED_10: |
336 | speed = AD_LINK_SPEED_BITMASK_10MBPS; | 328 | speed = AD_LINK_SPEED_BITMASK_10MBPS; |
@@ -375,9 +367,9 @@ static u8 __get_duplex(struct port *port) | |||
375 | 367 | ||
376 | // handling a special case: when the configuration starts with | 368 | // handling a special case: when the configuration starts with |
377 | // link down, it sets the duplex to 0. | 369 | // link down, it sets the duplex to 0. |
378 | if (slave->link != BOND_LINK_UP) { | 370 | if (slave->link != BOND_LINK_UP) |
379 | retval = 0x0; | 371 | retval = 0x0; |
380 | } else { | 372 | else { |
381 | switch (slave->duplex) { | 373 | switch (slave->duplex) { |
382 | case DUPLEX_FULL: | 374 | case DUPLEX_FULL: |
383 | retval = 0x1; | 375 | retval = 0x1; |
@@ -423,11 +415,10 @@ static u16 __ad_timer_to_ticks(u16 timer_type, u16 par) | |||
423 | 415 | ||
424 | switch (timer_type) { | 416 | switch (timer_type) { |
425 | case AD_CURRENT_WHILE_TIMER: // for rx machine usage | 417 | case AD_CURRENT_WHILE_TIMER: // for rx machine usage |
426 | if (par) { // for short or long timeout | 418 | if (par) |
427 | retval = (AD_SHORT_TIMEOUT_TIME*ad_ticks_per_sec); // short timeout | 419 | retval = (AD_SHORT_TIMEOUT_TIME*ad_ticks_per_sec); // short timeout |
428 | } else { | 420 | else |
429 | retval = (AD_LONG_TIMEOUT_TIME*ad_ticks_per_sec); // long timeout | 421 | retval = (AD_LONG_TIMEOUT_TIME*ad_ticks_per_sec); // long timeout |
430 | } | ||
431 | break; | 422 | break; |
432 | case AD_ACTOR_CHURN_TIMER: // for local churn machine | 423 | case AD_ACTOR_CHURN_TIMER: // for local churn machine |
433 | retval = (AD_CHURN_DETECTION_TIME*ad_ticks_per_sec); | 424 | retval = (AD_CHURN_DETECTION_TIME*ad_ticks_per_sec); |
@@ -519,11 +510,11 @@ static void __record_pdu(struct lacpdu *lacpdu, struct port *port) | |||
519 | port->actor_oper_port_state &= ~AD_STATE_DEFAULTED; | 510 | port->actor_oper_port_state &= ~AD_STATE_DEFAULTED; |
520 | 511 | ||
521 | // set the partner sync. to on if the partner is sync. and the port is matched | 512 | // set the partner sync. to on if the partner is sync. and the port is matched |
522 | if ((port->sm_vars & AD_PORT_MATCHED) && (lacpdu->actor_state & AD_STATE_SYNCHRONIZATION)) { | 513 | if ((port->sm_vars & AD_PORT_MATCHED) |
514 | && (lacpdu->actor_state & AD_STATE_SYNCHRONIZATION)) | ||
523 | partner->port_state |= AD_STATE_SYNCHRONIZATION; | 515 | partner->port_state |= AD_STATE_SYNCHRONIZATION; |
524 | } else { | 516 | else |
525 | partner->port_state &= ~AD_STATE_SYNCHRONIZATION; | 517 | partner->port_state &= ~AD_STATE_SYNCHRONIZATION; |
526 | } | ||
527 | } | 518 | } |
528 | } | 519 | } |
529 | 520 | ||
@@ -710,11 +701,10 @@ static void __set_agg_ports_ready(struct aggregator *aggregator, int val) | |||
710 | 701 | ||
711 | for (port = aggregator->lag_ports; port; | 702 | for (port = aggregator->lag_ports; port; |
712 | port = port->next_port_in_aggregator) { | 703 | port = port->next_port_in_aggregator) { |
713 | if (val) { | 704 | if (val) |
714 | port->sm_vars |= AD_PORT_READY; | 705 | port->sm_vars |= AD_PORT_READY; |
715 | } else { | 706 | else |
716 | port->sm_vars &= ~AD_PORT_READY; | 707 | port->sm_vars &= ~AD_PORT_READY; |
717 | } | ||
718 | } | 708 | } |
719 | } | 709 | } |
720 | 710 | ||
@@ -838,9 +828,8 @@ static int ad_lacpdu_send(struct port *port) | |||
838 | int length = sizeof(struct lacpdu_header); | 828 | int length = sizeof(struct lacpdu_header); |
839 | 829 | ||
840 | skb = dev_alloc_skb(length); | 830 | skb = dev_alloc_skb(length); |
841 | if (!skb) { | 831 | if (!skb) |
842 | return -ENOMEM; | 832 | return -ENOMEM; |
843 | } | ||
844 | 833 | ||
845 | skb->dev = slave->dev; | 834 | skb->dev = slave->dev; |
846 | skb_reset_mac_header(skb); | 835 | skb_reset_mac_header(skb); |
@@ -879,9 +868,8 @@ static int ad_marker_send(struct port *port, struct bond_marker *marker) | |||
879 | int length = sizeof(struct bond_marker_header); | 868 | int length = sizeof(struct bond_marker_header); |
880 | 869 | ||
881 | skb = dev_alloc_skb(length + 16); | 870 | skb = dev_alloc_skb(length + 16); |
882 | if (!skb) { | 871 | if (!skb) |
883 | return -ENOMEM; | 872 | return -ENOMEM; |
884 | } | ||
885 | 873 | ||
886 | skb_reserve(skb, 16); | 874 | skb_reserve(skb, 16); |
887 | 875 | ||
@@ -922,9 +910,10 @@ static void ad_mux_machine(struct port *port) | |||
922 | } else { | 910 | } else { |
923 | switch (port->sm_mux_state) { | 911 | switch (port->sm_mux_state) { |
924 | case AD_MUX_DETACHED: | 912 | case AD_MUX_DETACHED: |
925 | if ((port->sm_vars & AD_PORT_SELECTED) || (port->sm_vars & AD_PORT_STANDBY)) { // if SELECTED or STANDBY | 913 | if ((port->sm_vars & AD_PORT_SELECTED) |
914 | || (port->sm_vars & AD_PORT_STANDBY)) | ||
915 | /* if SELECTED or STANDBY */ | ||
926 | port->sm_mux_state = AD_MUX_WAITING; // next state | 916 | port->sm_mux_state = AD_MUX_WAITING; // next state |
927 | } | ||
928 | break; | 917 | break; |
929 | case AD_MUX_WAITING: | 918 | case AD_MUX_WAITING: |
930 | // if SELECTED == FALSE return to DETACH state | 919 | // if SELECTED == FALSE return to DETACH state |
@@ -938,18 +927,18 @@ static void ad_mux_machine(struct port *port) | |||
938 | } | 927 | } |
939 | 928 | ||
940 | // check if the wait_while_timer expired | 929 | // check if the wait_while_timer expired |
941 | if (port->sm_mux_timer_counter && !(--port->sm_mux_timer_counter)) { | 930 | if (port->sm_mux_timer_counter |
931 | && !(--port->sm_mux_timer_counter)) | ||
942 | port->sm_vars |= AD_PORT_READY_N; | 932 | port->sm_vars |= AD_PORT_READY_N; |
943 | } | ||
944 | 933 | ||
945 | // in order to withhold the selection logic to check all ports READY_N value | 934 | // in order to withhold the selection logic to check all ports READY_N value |
946 | // every callback cycle to update ready variable, we check READY_N and update READY here | 935 | // every callback cycle to update ready variable, we check READY_N and update READY here |
947 | __set_agg_ports_ready(port->aggregator, __agg_ports_are_ready(port->aggregator)); | 936 | __set_agg_ports_ready(port->aggregator, __agg_ports_are_ready(port->aggregator)); |
948 | 937 | ||
949 | // if the wait_while_timer expired, and the port is in READY state, move to ATTACHED state | 938 | // if the wait_while_timer expired, and the port is in READY state, move to ATTACHED state |
950 | if ((port->sm_vars & AD_PORT_READY) && !port->sm_mux_timer_counter) { | 939 | if ((port->sm_vars & AD_PORT_READY) |
940 | && !port->sm_mux_timer_counter) | ||
951 | port->sm_mux_state = AD_MUX_ATTACHED; // next state | 941 | port->sm_mux_state = AD_MUX_ATTACHED; // next state |
952 | } | ||
953 | break; | 942 | break; |
954 | case AD_MUX_ATTACHED: | 943 | case AD_MUX_ATTACHED: |
955 | // check also if agg_select_timer expired(so the edable port will take place only after this timer) | 944 | // check also if agg_select_timer expired(so the edable port will take place only after this timer) |
@@ -1044,13 +1033,14 @@ static void ad_rx_machine(struct lacpdu *lacpdu, struct port *port) | |||
1044 | 1033 | ||
1045 | // check if state machine should change state | 1034 | // check if state machine should change state |
1046 | // first, check if port was reinitialized | 1035 | // first, check if port was reinitialized |
1047 | if (port->sm_vars & AD_PORT_BEGIN) { | 1036 | if (port->sm_vars & AD_PORT_BEGIN) |
1048 | port->sm_rx_state = AD_RX_INITIALIZE; // next state | 1037 | /* next state */ |
1049 | } | 1038 | port->sm_rx_state = AD_RX_INITIALIZE; |
1050 | // check if port is not enabled | 1039 | // check if port is not enabled |
1051 | else if (!(port->sm_vars & AD_PORT_BEGIN) && !port->is_enabled && !(port->sm_vars & AD_PORT_MOVED)) { | 1040 | else if (!(port->sm_vars & AD_PORT_BEGIN) |
1052 | port->sm_rx_state = AD_RX_PORT_DISABLED; // next state | 1041 | && !port->is_enabled && !(port->sm_vars & AD_PORT_MOVED)) |
1053 | } | 1042 | /* next state */ |
1043 | port->sm_rx_state = AD_RX_PORT_DISABLED; | ||
1054 | // check if new lacpdu arrived | 1044 | // check if new lacpdu arrived |
1055 | else if (lacpdu && ((port->sm_rx_state == AD_RX_EXPIRED) || (port->sm_rx_state == AD_RX_DEFAULTED) || (port->sm_rx_state == AD_RX_CURRENT))) { | 1045 | else if (lacpdu && ((port->sm_rx_state == AD_RX_EXPIRED) || (port->sm_rx_state == AD_RX_DEFAULTED) || (port->sm_rx_state == AD_RX_CURRENT))) { |
1056 | port->sm_rx_timer_counter = 0; // zero timer | 1046 | port->sm_rx_timer_counter = 0; // zero timer |
@@ -1072,13 +1062,16 @@ static void ad_rx_machine(struct lacpdu *lacpdu, struct port *port) | |||
1072 | // if no lacpdu arrived and no timer is on | 1062 | // if no lacpdu arrived and no timer is on |
1073 | switch (port->sm_rx_state) { | 1063 | switch (port->sm_rx_state) { |
1074 | case AD_RX_PORT_DISABLED: | 1064 | case AD_RX_PORT_DISABLED: |
1075 | if (port->sm_vars & AD_PORT_MOVED) { | 1065 | if (port->sm_vars & AD_PORT_MOVED) |
1076 | port->sm_rx_state = AD_RX_INITIALIZE; // next state | 1066 | port->sm_rx_state = AD_RX_INITIALIZE; // next state |
1077 | } else if (port->is_enabled && (port->sm_vars & AD_PORT_LACP_ENABLED)) { | 1067 | else if (port->is_enabled |
1068 | && (port->sm_vars | ||
1069 | & AD_PORT_LACP_ENABLED)) | ||
1078 | port->sm_rx_state = AD_RX_EXPIRED; // next state | 1070 | port->sm_rx_state = AD_RX_EXPIRED; // next state |
1079 | } else if (port->is_enabled && ((port->sm_vars & AD_PORT_LACP_ENABLED) == 0)) { | 1071 | else if (port->is_enabled |
1072 | && ((port->sm_vars | ||
1073 | & AD_PORT_LACP_ENABLED) == 0)) | ||
1080 | port->sm_rx_state = AD_RX_LACP_DISABLED; // next state | 1074 | port->sm_rx_state = AD_RX_LACP_DISABLED; // next state |
1081 | } | ||
1082 | break; | 1075 | break; |
1083 | default: //to silence the compiler | 1076 | default: //to silence the compiler |
1084 | break; | 1077 | break; |
@@ -1094,11 +1087,10 @@ static void ad_rx_machine(struct lacpdu *lacpdu, struct port *port) | |||
1094 | port->sm_rx_state); | 1087 | port->sm_rx_state); |
1095 | switch (port->sm_rx_state) { | 1088 | switch (port->sm_rx_state) { |
1096 | case AD_RX_INITIALIZE: | 1089 | case AD_RX_INITIALIZE: |
1097 | if (!(port->actor_oper_port_key & AD_DUPLEX_KEY_BITS)) { | 1090 | if (!(port->actor_oper_port_key & AD_DUPLEX_KEY_BITS)) |
1098 | port->sm_vars &= ~AD_PORT_LACP_ENABLED; | 1091 | port->sm_vars &= ~AD_PORT_LACP_ENABLED; |
1099 | } else { | 1092 | else |
1100 | port->sm_vars |= AD_PORT_LACP_ENABLED; | 1093 | port->sm_vars |= AD_PORT_LACP_ENABLED; |
1101 | } | ||
1102 | port->sm_vars &= ~AD_PORT_SELECTED; | 1094 | port->sm_vars &= ~AD_PORT_SELECTED; |
1103 | __record_default(port); | 1095 | __record_default(port); |
1104 | port->actor_oper_port_state &= ~AD_STATE_EXPIRED; | 1096 | port->actor_oper_port_state &= ~AD_STATE_EXPIRED; |
@@ -1152,9 +1144,10 @@ static void ad_rx_machine(struct lacpdu *lacpdu, struct port *port) | |||
1152 | // verify that if the aggregator is enabled, the port is enabled too. | 1144 | // verify that if the aggregator is enabled, the port is enabled too. |
1153 | //(because if the link goes down for a short time, the 802.3ad will not | 1145 | //(because if the link goes down for a short time, the 802.3ad will not |
1154 | // catch it, and the port will continue to be disabled) | 1146 | // catch it, and the port will continue to be disabled) |
1155 | if (port->aggregator && port->aggregator->is_active && !__port_is_enabled(port)) { | 1147 | if (port->aggregator |
1148 | && port->aggregator->is_active | ||
1149 | && !__port_is_enabled(port)) | ||
1156 | __enable_port(port); | 1150 | __enable_port(port); |
1157 | } | ||
1158 | break; | 1151 | break; |
1159 | default: //to silence the compiler | 1152 | default: //to silence the compiler |
1160 | break; | 1153 | break; |
@@ -1220,9 +1213,9 @@ static void ad_periodic_machine(struct port *port) | |||
1220 | // If not expired, check if there is some new timeout parameter from the partner state | 1213 | // If not expired, check if there is some new timeout parameter from the partner state |
1221 | switch (port->sm_periodic_state) { | 1214 | switch (port->sm_periodic_state) { |
1222 | case AD_FAST_PERIODIC: | 1215 | case AD_FAST_PERIODIC: |
1223 | if (!(port->partner_oper.port_state & AD_STATE_LACP_TIMEOUT)) { | 1216 | if (!(port->partner_oper.port_state |
1217 | & AD_STATE_LACP_TIMEOUT)) | ||
1224 | port->sm_periodic_state = AD_SLOW_PERIODIC; // next state | 1218 | port->sm_periodic_state = AD_SLOW_PERIODIC; // next state |
1225 | } | ||
1226 | break; | 1219 | break; |
1227 | case AD_SLOW_PERIODIC: | 1220 | case AD_SLOW_PERIODIC: |
1228 | if ((port->partner_oper.port_state & AD_STATE_LACP_TIMEOUT)) { | 1221 | if ((port->partner_oper.port_state & AD_STATE_LACP_TIMEOUT)) { |
@@ -1241,11 +1234,11 @@ static void ad_periodic_machine(struct port *port) | |||
1241 | port->sm_periodic_state = AD_FAST_PERIODIC; // next state | 1234 | port->sm_periodic_state = AD_FAST_PERIODIC; // next state |
1242 | break; | 1235 | break; |
1243 | case AD_PERIODIC_TX: | 1236 | case AD_PERIODIC_TX: |
1244 | if (!(port->partner_oper.port_state & AD_STATE_LACP_TIMEOUT)) { | 1237 | if (!(port->partner_oper.port_state |
1238 | & AD_STATE_LACP_TIMEOUT)) | ||
1245 | port->sm_periodic_state = AD_SLOW_PERIODIC; // next state | 1239 | port->sm_periodic_state = AD_SLOW_PERIODIC; // next state |
1246 | } else { | 1240 | else |
1247 | port->sm_periodic_state = AD_FAST_PERIODIC; // next state | 1241 | port->sm_periodic_state = AD_FAST_PERIODIC; // next state |
1248 | } | ||
1249 | break; | 1242 | break; |
1250 | default: //to silence the compiler | 1243 | default: //to silence the compiler |
1251 | break; | 1244 | break; |
@@ -1291,9 +1284,8 @@ static void ad_port_selection_logic(struct port *port) | |||
1291 | int found = 0; | 1284 | int found = 0; |
1292 | 1285 | ||
1293 | // if the port is already Selected, do nothing | 1286 | // if the port is already Selected, do nothing |
1294 | if (port->sm_vars & AD_PORT_SELECTED) { | 1287 | if (port->sm_vars & AD_PORT_SELECTED) |
1295 | return; | 1288 | return; |
1296 | } | ||
1297 | 1289 | ||
1298 | // if the port is connected to other aggregator, detach it | 1290 | // if the port is connected to other aggregator, detach it |
1299 | if (port->aggregator) { | 1291 | if (port->aggregator) { |
@@ -1321,9 +1313,8 @@ static void ad_port_selection_logic(struct port *port) | |||
1321 | port->actor_port_number, | 1313 | port->actor_port_number, |
1322 | temp_aggregator->aggregator_identifier); | 1314 | temp_aggregator->aggregator_identifier); |
1323 | // if the aggregator is empty, clear its parameters, and set it ready to be attached | 1315 | // if the aggregator is empty, clear its parameters, and set it ready to be attached |
1324 | if (!temp_aggregator->lag_ports) { | 1316 | if (!temp_aggregator->lag_ports) |
1325 | ad_clear_agg(temp_aggregator); | 1317 | ad_clear_agg(temp_aggregator); |
1326 | } | ||
1327 | break; | 1318 | break; |
1328 | } | 1319 | } |
1329 | } | 1320 | } |
@@ -1341,9 +1332,8 @@ static void ad_port_selection_logic(struct port *port) | |||
1341 | 1332 | ||
1342 | // keep a free aggregator for later use(if needed) | 1333 | // keep a free aggregator for later use(if needed) |
1343 | if (!aggregator->lag_ports) { | 1334 | if (!aggregator->lag_ports) { |
1344 | if (!free_aggregator) { | 1335 | if (!free_aggregator) |
1345 | free_aggregator = aggregator; | 1336 | free_aggregator = aggregator; |
1346 | } | ||
1347 | continue; | 1337 | continue; |
1348 | } | 1338 | } |
1349 | // check if current aggregator suits us | 1339 | // check if current aggregator suits us |
@@ -1384,11 +1374,11 @@ static void ad_port_selection_logic(struct port *port) | |||
1384 | 1374 | ||
1385 | // update the new aggregator's parameters | 1375 | // update the new aggregator's parameters |
1386 | // if port was responsed from the end-user | 1376 | // if port was responsed from the end-user |
1387 | if (port->actor_oper_port_key & AD_DUPLEX_KEY_BITS) {// if port is full duplex | 1377 | if (port->actor_oper_port_key & AD_DUPLEX_KEY_BITS) |
1378 | /* if port is full duplex */ | ||
1388 | port->aggregator->is_individual = false; | 1379 | port->aggregator->is_individual = false; |
1389 | } else { | 1380 | else |
1390 | port->aggregator->is_individual = true; | 1381 | port->aggregator->is_individual = true; |
1391 | } | ||
1392 | 1382 | ||
1393 | port->aggregator->actor_admin_aggregator_key = port->actor_admin_port_key; | 1383 | port->aggregator->actor_admin_aggregator_key = port->actor_admin_port_key; |
1394 | port->aggregator->actor_oper_aggregator_key = port->actor_oper_port_key; | 1384 | port->aggregator->actor_oper_aggregator_key = port->actor_oper_port_key; |
@@ -1716,9 +1706,8 @@ static void ad_initialize_port(struct port *port, int lacp_fast) | |||
1716 | port->actor_admin_port_state = AD_STATE_AGGREGATION | AD_STATE_LACP_ACTIVITY; | 1706 | port->actor_admin_port_state = AD_STATE_AGGREGATION | AD_STATE_LACP_ACTIVITY; |
1717 | port->actor_oper_port_state = AD_STATE_AGGREGATION | AD_STATE_LACP_ACTIVITY; | 1707 | port->actor_oper_port_state = AD_STATE_AGGREGATION | AD_STATE_LACP_ACTIVITY; |
1718 | 1708 | ||
1719 | if (lacp_fast) { | 1709 | if (lacp_fast) |
1720 | port->actor_oper_port_state |= AD_STATE_LACP_TIMEOUT; | 1710 | port->actor_oper_port_state |= AD_STATE_LACP_TIMEOUT; |
1721 | } | ||
1722 | 1711 | ||
1723 | memcpy(&port->partner_admin, &tmpl, sizeof(tmpl)); | 1712 | memcpy(&port->partner_admin, &tmpl, sizeof(tmpl)); |
1724 | memcpy(&port->partner_oper, &tmpl, sizeof(tmpl)); | 1713 | memcpy(&port->partner_oper, &tmpl, sizeof(tmpl)); |
@@ -1947,9 +1936,8 @@ int bond_3ad_bind_slave(struct slave *slave) | |||
1947 | port->actor_admin_port_key |= (__get_link_speed(port) << 1); | 1936 | port->actor_admin_port_key |= (__get_link_speed(port) << 1); |
1948 | port->actor_oper_port_key = port->actor_admin_port_key; | 1937 | port->actor_oper_port_key = port->actor_admin_port_key; |
1949 | // if the port is not full duplex, then the port should be not lacp Enabled | 1938 | // if the port is not full duplex, then the port should be not lacp Enabled |
1950 | if (!(port->actor_oper_port_key & AD_DUPLEX_KEY_BITS)) { | 1939 | if (!(port->actor_oper_port_key & AD_DUPLEX_KEY_BITS)) |
1951 | port->sm_vars &= ~AD_PORT_LACP_ENABLED; | 1940 | port->sm_vars &= ~AD_PORT_LACP_ENABLED; |
1952 | } | ||
1953 | // actor system is the bond's system | 1941 | // actor system is the bond's system |
1954 | port->actor_system = BOND_AD_INFO(bond).system.sys_mac_addr; | 1942 | port->actor_system = BOND_AD_INFO(bond).system.sys_mac_addr; |
1955 | // tx timer(to verify that no more than MAX_TX_IN_SECOND lacpdu's are sent in one second) | 1943 | // tx timer(to verify that no more than MAX_TX_IN_SECOND lacpdu's are sent in one second) |
@@ -2021,9 +2009,10 @@ void bond_3ad_unbind_slave(struct slave *slave) | |||
2021 | new_aggregator = __get_first_agg(port); | 2009 | new_aggregator = __get_first_agg(port); |
2022 | for (; new_aggregator; new_aggregator = __get_next_agg(new_aggregator)) { | 2010 | for (; new_aggregator; new_aggregator = __get_next_agg(new_aggregator)) { |
2023 | // if the new aggregator is empty, or it is connected to our port only | 2011 | // if the new aggregator is empty, or it is connected to our port only |
2024 | if (!new_aggregator->lag_ports || ((new_aggregator->lag_ports == port) && !new_aggregator->lag_ports->next_port_in_aggregator)) { | 2012 | if (!new_aggregator->lag_ports |
2013 | || ((new_aggregator->lag_ports == port) | ||
2014 | && !new_aggregator->lag_ports->next_port_in_aggregator)) | ||
2025 | break; | 2015 | break; |
2026 | } | ||
2027 | } | 2016 | } |
2028 | // if new aggregator found, copy the aggregator's parameters | 2017 | // if new aggregator found, copy the aggregator's parameters |
2029 | // and connect the related lag_ports to the new aggregator | 2018 | // and connect the related lag_ports to the new aggregator |
@@ -2061,9 +2050,8 @@ void bond_3ad_unbind_slave(struct slave *slave) | |||
2061 | // clear the aggregator | 2050 | // clear the aggregator |
2062 | ad_clear_agg(aggregator); | 2051 | ad_clear_agg(aggregator); |
2063 | 2052 | ||
2064 | if (select_new_active_agg) { | 2053 | if (select_new_active_agg) |
2065 | ad_agg_selection_logic(__get_first_agg(port)); | 2054 | ad_agg_selection_logic(__get_first_agg(port)); |
2066 | } | ||
2067 | } else { | 2055 | } else { |
2068 | pr_warning("%s: Warning: unbinding aggregator, and could not find a new aggregator for its ports\n", | 2056 | pr_warning("%s: Warning: unbinding aggregator, and could not find a new aggregator for its ports\n", |
2069 | slave->dev->master->name); | 2057 | slave->dev->master->name); |
@@ -2091,11 +2079,10 @@ void bond_3ad_unbind_slave(struct slave *slave) | |||
2091 | prev_port = temp_port, | 2079 | prev_port = temp_port, |
2092 | temp_port = temp_port->next_port_in_aggregator) { | 2080 | temp_port = temp_port->next_port_in_aggregator) { |
2093 | if (temp_port == port) { // the aggregator found - detach the port from this aggregator | 2081 | if (temp_port == port) { // the aggregator found - detach the port from this aggregator |
2094 | if (prev_port) { | 2082 | if (prev_port) |
2095 | prev_port->next_port_in_aggregator = temp_port->next_port_in_aggregator; | 2083 | prev_port->next_port_in_aggregator = temp_port->next_port_in_aggregator; |
2096 | } else { | 2084 | else |
2097 | temp_aggregator->lag_ports = temp_port->next_port_in_aggregator; | 2085 | temp_aggregator->lag_ports = temp_port->next_port_in_aggregator; |
2098 | } | ||
2099 | temp_aggregator->num_of_ports--; | 2086 | temp_aggregator->num_of_ports--; |
2100 | if (temp_aggregator->num_of_ports == 0) { | 2087 | if (temp_aggregator->num_of_ports == 0) { |
2101 | select_new_active_agg = temp_aggregator->is_active; | 2088 | select_new_active_agg = temp_aggregator->is_active; |
@@ -2137,14 +2124,12 @@ void bond_3ad_state_machine_handler(struct work_struct *work) | |||
2137 | 2124 | ||
2138 | read_lock(&bond->lock); | 2125 | read_lock(&bond->lock); |
2139 | 2126 | ||
2140 | if (bond->kill_timers) { | 2127 | if (bond->kill_timers) |
2141 | goto out; | 2128 | goto out; |
2142 | } | ||
2143 | 2129 | ||
2144 | //check if there are any slaves | 2130 | //check if there are any slaves |
2145 | if (bond->slave_cnt == 0) { | 2131 | if (bond->slave_cnt == 0) |
2146 | goto re_arm; | 2132 | goto re_arm; |
2147 | } | ||
2148 | 2133 | ||
2149 | // check if agg_select_timer timer after initialize is timed out | 2134 | // check if agg_select_timer timer after initialize is timed out |
2150 | if (BOND_AD_INFO(bond).agg_select_timer && !(--BOND_AD_INFO(bond).agg_select_timer)) { | 2135 | if (BOND_AD_INFO(bond).agg_select_timer && !(--BOND_AD_INFO(bond).agg_select_timer)) { |
@@ -2177,9 +2162,8 @@ void bond_3ad_state_machine_handler(struct work_struct *work) | |||
2177 | ad_tx_machine(port); | 2162 | ad_tx_machine(port); |
2178 | 2163 | ||
2179 | // turn off the BEGIN bit, since we already handled it | 2164 | // turn off the BEGIN bit, since we already handled it |
2180 | if (port->sm_vars & AD_PORT_BEGIN) { | 2165 | if (port->sm_vars & AD_PORT_BEGIN) |
2181 | port->sm_vars &= ~AD_PORT_BEGIN; | 2166 | port->sm_vars &= ~AD_PORT_BEGIN; |
2182 | } | ||
2183 | } | 2167 | } |
2184 | 2168 | ||
2185 | re_arm: | 2169 | re_arm: |
@@ -2417,9 +2401,8 @@ int bond_3ad_xmit_xor(struct sk_buff *skb, struct net_device *dev) | |||
2417 | */ | 2401 | */ |
2418 | read_lock(&bond->lock); | 2402 | read_lock(&bond->lock); |
2419 | 2403 | ||
2420 | if (!BOND_IS_OK(bond)) { | 2404 | if (!BOND_IS_OK(bond)) |
2421 | goto out; | 2405 | goto out; |
2422 | } | ||
2423 | 2406 | ||
2424 | if (bond_3ad_get_active_agg_info(bond, &ad_info)) { | 2407 | if (bond_3ad_get_active_agg_info(bond, &ad_info)) { |
2425 | pr_debug("%s: Error: bond_3ad_get_active_agg_info failed\n", | 2408 | pr_debug("%s: Error: bond_3ad_get_active_agg_info failed\n", |
@@ -2443,9 +2426,8 @@ int bond_3ad_xmit_xor(struct sk_buff *skb, struct net_device *dev) | |||
2443 | 2426 | ||
2444 | if (agg && (agg->aggregator_identifier == agg_id)) { | 2427 | if (agg && (agg->aggregator_identifier == agg_id)) { |
2445 | slave_agg_no--; | 2428 | slave_agg_no--; |
2446 | if (slave_agg_no < 0) { | 2429 | if (slave_agg_no < 0) |
2447 | break; | 2430 | break; |
2448 | } | ||
2449 | } | 2431 | } |
2450 | } | 2432 | } |
2451 | 2433 | ||
@@ -2461,9 +2443,8 @@ int bond_3ad_xmit_xor(struct sk_buff *skb, struct net_device *dev) | |||
2461 | int slave_agg_id = 0; | 2443 | int slave_agg_id = 0; |
2462 | struct aggregator *agg = SLAVE_AD_INFO(slave).port.aggregator; | 2444 | struct aggregator *agg = SLAVE_AD_INFO(slave).port.aggregator; |
2463 | 2445 | ||
2464 | if (agg) { | 2446 | if (agg) |
2465 | slave_agg_id = agg->aggregator_identifier; | 2447 | slave_agg_id = agg->aggregator_identifier; |
2466 | } | ||
2467 | 2448 | ||
2468 | if (SLAVE_IS_OK(slave) && agg && (slave_agg_id == agg_id)) { | 2449 | if (SLAVE_IS_OK(slave) && agg && (slave_agg_id == agg_id)) { |
2469 | res = bond_dev_queue_xmit(bond, skb, slave->dev); | 2450 | res = bond_dev_queue_xmit(bond, skb, slave->dev); |