aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net
diff options
context:
space:
mode:
authorHolger Eitzenberger <holger@eitzenberger.org>2008-12-17 22:07:38 -0500
committerDavid S. Miller <davem@davemloft.net>2008-12-17 22:07:38 -0500
commit1055c9aba3b6850245fe3bbb533d4747e7f904bf (patch)
tree083ad0cd7984031d5b82d459052c17065f617ace /drivers/net
parentaa3128199dbe07b5be3382de590c59216f91d3e3 (diff)
bonding: introduce and use port_params structure
It generally helps to handle those values in various places, using it might make the code more readable and gives room for other improvements. The IEEE standard talks about them as "parameter values". Signed-off-by: Holger Eitzenberger <holger@eitzenberger.org> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net')
-rw-r--r--drivers/net/bonding/bond_3ad.c120
-rw-r--r--drivers/net/bonding/bond_3ad.h25
2 files changed, 73 insertions, 72 deletions
diff --git a/drivers/net/bonding/bond_3ad.c b/drivers/net/bonding/bond_3ad.c
index 7a108fa24a6d..d02e852afbd9 100644
--- a/drivers/net/bonding/bond_3ad.c
+++ b/drivers/net/bonding/bond_3ad.c
@@ -486,21 +486,21 @@ static void __record_pdu(struct lacpdu *lacpdu, struct port *port)
486 // validate lacpdu and port 486 // validate lacpdu and port
487 if (lacpdu && port) { 487 if (lacpdu && port) {
488 // record the new parameter values for the partner operational 488 // record the new parameter values for the partner operational
489 port->partner_oper_port_number = ntohs(lacpdu->actor_port); 489 port->partner_oper.port_number = ntohs(lacpdu->actor_port);
490 port->partner_oper_port_priority = ntohs(lacpdu->actor_port_priority); 490 port->partner_oper.port_priority = ntohs(lacpdu->actor_port_priority);
491 port->partner_oper_system = lacpdu->actor_system; 491 port->partner_oper.system = lacpdu->actor_system;
492 port->partner_oper_system_priority = ntohs(lacpdu->actor_system_priority); 492 port->partner_oper.system_priority = ntohs(lacpdu->actor_system_priority);
493 port->partner_oper_key = ntohs(lacpdu->actor_key); 493 port->partner_oper.key = ntohs(lacpdu->actor_key);
494 port->partner_oper_port_state = lacpdu->actor_state; 494 port->partner_oper.port_state = lacpdu->actor_state;
495 495
496 // set actor_oper_port_state.defaulted to FALSE 496 // set actor_oper_port_state.defaulted to FALSE
497 port->actor_oper_port_state &= ~AD_STATE_DEFAULTED; 497 port->actor_oper_port_state &= ~AD_STATE_DEFAULTED;
498 498
499 // set the partner sync. to on if the partner is sync. and the port is matched 499 // set the partner sync. to on if the partner is sync. and the port is matched
500 if ((port->sm_vars & AD_PORT_MATCHED) && (lacpdu->actor_state & AD_STATE_SYNCHRONIZATION)) { 500 if ((port->sm_vars & AD_PORT_MATCHED) && (lacpdu->actor_state & AD_STATE_SYNCHRONIZATION)) {
501 port->partner_oper_port_state |= AD_STATE_SYNCHRONIZATION; 501 port->partner_oper.port_state |= AD_STATE_SYNCHRONIZATION;
502 } else { 502 } else {
503 port->partner_oper_port_state &= ~AD_STATE_SYNCHRONIZATION; 503 port->partner_oper.port_state &= ~AD_STATE_SYNCHRONIZATION;
504 } 504 }
505 } 505 }
506} 506}
@@ -518,12 +518,12 @@ static void __record_default(struct port *port)
518 // validate the port 518 // validate the port
519 if (port) { 519 if (port) {
520 // record the partner admin parameters 520 // record the partner admin parameters
521 port->partner_oper_port_number = port->partner_admin_port_number; 521 port->partner_oper.port_number = port->partner_admin.port_number;
522 port->partner_oper_port_priority = port->partner_admin_port_priority; 522 port->partner_oper.port_priority = port->partner_admin.port_priority;
523 port->partner_oper_system = port->partner_admin_system; 523 port->partner_oper.system = port->partner_admin.system;
524 port->partner_oper_system_priority = port->partner_admin_system_priority; 524 port->partner_oper.system_priority = port->partner_admin.system_priority;
525 port->partner_oper_key = port->partner_admin_key; 525 port->partner_oper.key = port->partner_admin.key;
526 port->partner_oper_port_state = port->partner_admin_port_state; 526 port->partner_oper.port_state = port->partner_admin.port_state;
527 527
528 // set actor_oper_port_state.defaulted to true 528 // set actor_oper_port_state.defaulted to true
529 port->actor_oper_port_state |= AD_STATE_DEFAULTED; 529 port->actor_oper_port_state |= AD_STATE_DEFAULTED;
@@ -548,12 +548,12 @@ static void __update_selected(struct lacpdu *lacpdu, struct port *port)
548 // validate lacpdu and port 548 // validate lacpdu and port
549 if (lacpdu && port) { 549 if (lacpdu && port) {
550 // check if any parameter is different 550 // check if any parameter is different
551 if ((ntohs(lacpdu->actor_port) != port->partner_oper_port_number) || 551 if ((ntohs(lacpdu->actor_port) != port->partner_oper.port_number) ||
552 (ntohs(lacpdu->actor_port_priority) != port->partner_oper_port_priority) || 552 (ntohs(lacpdu->actor_port_priority) != port->partner_oper.port_priority) ||
553 MAC_ADDRESS_COMPARE(&(lacpdu->actor_system), &(port->partner_oper_system)) || 553 MAC_ADDRESS_COMPARE(&(lacpdu->actor_system), &(port->partner_oper.system)) ||
554 (ntohs(lacpdu->actor_system_priority) != port->partner_oper_system_priority) || 554 (ntohs(lacpdu->actor_system_priority) != port->partner_oper.system_priority) ||
555 (ntohs(lacpdu->actor_key) != port->partner_oper_key) || 555 (ntohs(lacpdu->actor_key) != port->partner_oper.key) ||
556 ((lacpdu->actor_state & AD_STATE_AGGREGATION) != (port->partner_oper_port_state & AD_STATE_AGGREGATION)) 556 ((lacpdu->actor_state & AD_STATE_AGGREGATION) != (port->partner_oper.port_state & AD_STATE_AGGREGATION))
557 ) { 557 ) {
558 // update the state machine Selected variable 558 // update the state machine Selected variable
559 port->sm_vars &= ~AD_PORT_SELECTED; 559 port->sm_vars &= ~AD_PORT_SELECTED;
@@ -578,12 +578,12 @@ static void __update_default_selected(struct port *port)
578 // validate the port 578 // validate the port
579 if (port) { 579 if (port) {
580 // check if any parameter is different 580 // check if any parameter is different
581 if ((port->partner_admin_port_number != port->partner_oper_port_number) || 581 if ((port->partner_admin.port_number != port->partner_oper.port_number) ||
582 (port->partner_admin_port_priority != port->partner_oper_port_priority) || 582 (port->partner_admin.port_priority != port->partner_oper.port_priority) ||
583 MAC_ADDRESS_COMPARE(&(port->partner_admin_system), &(port->partner_oper_system)) || 583 MAC_ADDRESS_COMPARE(&(port->partner_admin.system), &(port->partner_oper.system)) ||
584 (port->partner_admin_system_priority != port->partner_oper_system_priority) || 584 (port->partner_admin.system_priority != port->partner_oper.system_priority) ||
585 (port->partner_admin_key != port->partner_oper_key) || 585 (port->partner_admin.key != port->partner_oper.key) ||
586 ((port->partner_admin_port_state & AD_STATE_AGGREGATION) != (port->partner_oper_port_state & AD_STATE_AGGREGATION)) 586 ((port->partner_admin.port_state & AD_STATE_AGGREGATION) != (port->partner_oper.port_state & AD_STATE_AGGREGATION))
587 ) { 587 ) {
588 // update the state machine Selected variable 588 // update the state machine Selected variable
589 port->sm_vars &= ~AD_PORT_SELECTED; 589 port->sm_vars &= ~AD_PORT_SELECTED;
@@ -819,12 +819,12 @@ static inline void __update_lacpdu_from_port(struct port *port)
819 * lacpdu->partner_information_length initialized 819 * lacpdu->partner_information_length initialized
820 */ 820 */
821 821
822 lacpdu->partner_system_priority = htons(port->partner_oper_system_priority); 822 lacpdu->partner_system_priority = htons(port->partner_oper.system_priority);
823 lacpdu->partner_system = port->partner_oper_system; 823 lacpdu->partner_system = port->partner_oper.system;
824 lacpdu->partner_key = htons(port->partner_oper_key); 824 lacpdu->partner_key = htons(port->partner_oper.key);
825 lacpdu->partner_port_priority = htons(port->partner_oper_port_priority); 825 lacpdu->partner_port_priority = htons(port->partner_oper.port_priority);
826 lacpdu->partner_port = htons(port->partner_oper_port_number); 826 lacpdu->partner_port = htons(port->partner_oper.port_number);
827 lacpdu->partner_state = port->partner_oper_port_state; 827 lacpdu->partner_state = port->partner_oper.port_state;
828 828
829 /* lacpdu->reserved_3_2 initialized 829 /* lacpdu->reserved_3_2 initialized
830 * lacpdu->tlv_type_collector_info initialized 830 * lacpdu->tlv_type_collector_info initialized
@@ -973,7 +973,7 @@ static void ad_mux_machine(struct port *port)
973 break; 973 break;
974 case AD_MUX_ATTACHED: 974 case AD_MUX_ATTACHED:
975 // check also if agg_select_timer expired(so the edable port will take place only after this timer) 975 // check also if agg_select_timer expired(so the edable port will take place only after this timer)
976 if ((port->sm_vars & AD_PORT_SELECTED) && (port->partner_oper_port_state & AD_STATE_SYNCHRONIZATION) && !__check_agg_selection_timer(port)) { 976 if ((port->sm_vars & AD_PORT_SELECTED) && (port->partner_oper.port_state & AD_STATE_SYNCHRONIZATION) && !__check_agg_selection_timer(port)) {
977 port->sm_mux_state = AD_MUX_COLLECTING_DISTRIBUTING;// next state 977 port->sm_mux_state = AD_MUX_COLLECTING_DISTRIBUTING;// next state
978 } else if (!(port->sm_vars & AD_PORT_SELECTED) || (port->sm_vars & AD_PORT_STANDBY)) { // if UNSELECTED or STANDBY 978 } else if (!(port->sm_vars & AD_PORT_SELECTED) || (port->sm_vars & AD_PORT_STANDBY)) { // if UNSELECTED or STANDBY
979 port->sm_vars &= ~AD_PORT_READY_N; 979 port->sm_vars &= ~AD_PORT_READY_N;
@@ -985,7 +985,7 @@ static void ad_mux_machine(struct port *port)
985 break; 985 break;
986 case AD_MUX_COLLECTING_DISTRIBUTING: 986 case AD_MUX_COLLECTING_DISTRIBUTING:
987 if (!(port->sm_vars & AD_PORT_SELECTED) || (port->sm_vars & AD_PORT_STANDBY) || 987 if (!(port->sm_vars & AD_PORT_SELECTED) || (port->sm_vars & AD_PORT_STANDBY) ||
988 !(port->partner_oper_port_state & AD_STATE_SYNCHRONIZATION) 988 !(port->partner_oper.port_state & AD_STATE_SYNCHRONIZATION)
989 ) { 989 ) {
990 port->sm_mux_state = AD_MUX_ATTACHED;// next state 990 port->sm_mux_state = AD_MUX_ATTACHED;// next state
991 991
@@ -1129,7 +1129,7 @@ static void ad_rx_machine(struct lacpdu *lacpdu, struct port *port)
1129 case AD_RX_LACP_DISABLED: 1129 case AD_RX_LACP_DISABLED:
1130 port->sm_vars &= ~AD_PORT_SELECTED; 1130 port->sm_vars &= ~AD_PORT_SELECTED;
1131 __record_default(port); 1131 __record_default(port);
1132 port->partner_oper_port_state &= ~AD_STATE_AGGREGATION; 1132 port->partner_oper.port_state &= ~AD_STATE_AGGREGATION;
1133 port->sm_vars |= AD_PORT_MATCHED; 1133 port->sm_vars |= AD_PORT_MATCHED;
1134 port->actor_oper_port_state &= ~AD_STATE_EXPIRED; 1134 port->actor_oper_port_state &= ~AD_STATE_EXPIRED;
1135 break; 1135 break;
@@ -1137,9 +1137,9 @@ static void ad_rx_machine(struct lacpdu *lacpdu, struct port *port)
1137 //Reset of the Synchronization flag. (Standard 43.4.12) 1137 //Reset of the Synchronization flag. (Standard 43.4.12)
1138 //This reset cause to disable this port in the COLLECTING_DISTRIBUTING state of the 1138 //This reset cause to disable this port in the COLLECTING_DISTRIBUTING state of the
1139 //mux machine in case of EXPIRED even if LINK_DOWN didn't arrive for the port. 1139 //mux machine in case of EXPIRED even if LINK_DOWN didn't arrive for the port.
1140 port->partner_oper_port_state &= ~AD_STATE_SYNCHRONIZATION; 1140 port->partner_oper.port_state &= ~AD_STATE_SYNCHRONIZATION;
1141 port->sm_vars &= ~AD_PORT_MATCHED; 1141 port->sm_vars &= ~AD_PORT_MATCHED;
1142 port->partner_oper_port_state |= AD_SHORT_TIMEOUT; 1142 port->partner_oper.port_state |= AD_SHORT_TIMEOUT;
1143 port->sm_rx_timer_counter = __ad_timer_to_ticks(AD_CURRENT_WHILE_TIMER, (u16)(AD_SHORT_TIMEOUT)); 1143 port->sm_rx_timer_counter = __ad_timer_to_ticks(AD_CURRENT_WHILE_TIMER, (u16)(AD_SHORT_TIMEOUT));
1144 port->actor_oper_port_state |= AD_STATE_EXPIRED; 1144 port->actor_oper_port_state |= AD_STATE_EXPIRED;
1145 break; 1145 break;
@@ -1219,7 +1219,7 @@ static void ad_periodic_machine(struct port *port)
1219 1219
1220 // check if port was reinitialized 1220 // check if port was reinitialized
1221 if (((port->sm_vars & AD_PORT_BEGIN) || !(port->sm_vars & AD_PORT_LACP_ENABLED) || !port->is_enabled) || 1221 if (((port->sm_vars & AD_PORT_BEGIN) || !(port->sm_vars & AD_PORT_LACP_ENABLED) || !port->is_enabled) ||
1222 (!(port->actor_oper_port_state & AD_STATE_LACP_ACTIVITY) && !(port->partner_oper_port_state & AD_STATE_LACP_ACTIVITY)) 1222 (!(port->actor_oper_port_state & AD_STATE_LACP_ACTIVITY) && !(port->partner_oper.port_state & AD_STATE_LACP_ACTIVITY))
1223 ) { 1223 ) {
1224 port->sm_periodic_state = AD_NO_PERIODIC; // next state 1224 port->sm_periodic_state = AD_NO_PERIODIC; // next state
1225 } 1225 }
@@ -1233,12 +1233,12 @@ static void ad_periodic_machine(struct port *port)
1233 // If not expired, check if there is some new timeout parameter from the partner state 1233 // If not expired, check if there is some new timeout parameter from the partner state
1234 switch (port->sm_periodic_state) { 1234 switch (port->sm_periodic_state) {
1235 case AD_FAST_PERIODIC: 1235 case AD_FAST_PERIODIC:
1236 if (!(port->partner_oper_port_state & AD_STATE_LACP_TIMEOUT)) { 1236 if (!(port->partner_oper.port_state & AD_STATE_LACP_TIMEOUT)) {
1237 port->sm_periodic_state = AD_SLOW_PERIODIC; // next state 1237 port->sm_periodic_state = AD_SLOW_PERIODIC; // next state
1238 } 1238 }
1239 break; 1239 break;
1240 case AD_SLOW_PERIODIC: 1240 case AD_SLOW_PERIODIC:
1241 if ((port->partner_oper_port_state & AD_STATE_LACP_TIMEOUT)) { 1241 if ((port->partner_oper.port_state & AD_STATE_LACP_TIMEOUT)) {
1242 // stop current timer 1242 // stop current timer
1243 port->sm_periodic_timer_counter = 0; 1243 port->sm_periodic_timer_counter = 0;
1244 port->sm_periodic_state = AD_PERIODIC_TX; // next state 1244 port->sm_periodic_state = AD_PERIODIC_TX; // next state
@@ -1254,7 +1254,7 @@ static void ad_periodic_machine(struct port *port)
1254 port->sm_periodic_state = AD_FAST_PERIODIC; // next state 1254 port->sm_periodic_state = AD_FAST_PERIODIC; // next state
1255 break; 1255 break;
1256 case AD_PERIODIC_TX: 1256 case AD_PERIODIC_TX:
1257 if (!(port->partner_oper_port_state & AD_STATE_LACP_TIMEOUT)) { 1257 if (!(port->partner_oper.port_state & AD_STATE_LACP_TIMEOUT)) {
1258 port->sm_periodic_state = AD_SLOW_PERIODIC; // next state 1258 port->sm_periodic_state = AD_SLOW_PERIODIC; // next state
1259 } else { 1259 } else {
1260 port->sm_periodic_state = AD_FAST_PERIODIC; // next state 1260 port->sm_periodic_state = AD_FAST_PERIODIC; // next state
@@ -1353,11 +1353,11 @@ static void ad_port_selection_logic(struct port *port)
1353 } 1353 }
1354 // check if current aggregator suits us 1354 // check if current aggregator suits us
1355 if (((aggregator->actor_oper_aggregator_key == port->actor_oper_port_key) && // if all parameters match AND 1355 if (((aggregator->actor_oper_aggregator_key == port->actor_oper_port_key) && // if all parameters match AND
1356 !MAC_ADDRESS_COMPARE(&(aggregator->partner_system), &(port->partner_oper_system)) && 1356 !MAC_ADDRESS_COMPARE(&(aggregator->partner_system), &(port->partner_oper.system)) &&
1357 (aggregator->partner_system_priority == port->partner_oper_system_priority) && 1357 (aggregator->partner_system_priority == port->partner_oper.system_priority) &&
1358 (aggregator->partner_oper_aggregator_key == port->partner_oper_key) 1358 (aggregator->partner_oper_aggregator_key == port->partner_oper.key)
1359 ) && 1359 ) &&
1360 ((MAC_ADDRESS_COMPARE(&(port->partner_oper_system), &(null_mac_addr)) && // partner answers 1360 ((MAC_ADDRESS_COMPARE(&(port->partner_oper.system), &(null_mac_addr)) && // partner answers
1361 !aggregator->is_individual) // but is not individual OR 1361 !aggregator->is_individual) // but is not individual OR
1362 ) 1362 )
1363 ) { 1363 ) {
@@ -1393,9 +1393,9 @@ static void ad_port_selection_logic(struct port *port)
1393 1393
1394 port->aggregator->actor_admin_aggregator_key = port->actor_admin_port_key; 1394 port->aggregator->actor_admin_aggregator_key = port->actor_admin_port_key;
1395 port->aggregator->actor_oper_aggregator_key = port->actor_oper_port_key; 1395 port->aggregator->actor_oper_aggregator_key = port->actor_oper_port_key;
1396 port->aggregator->partner_system=port->partner_oper_system; 1396 port->aggregator->partner_system=port->partner_oper.system;
1397 port->aggregator->partner_system_priority = port->partner_oper_system_priority; 1397 port->aggregator->partner_system_priority = port->partner_oper.system_priority;
1398 port->aggregator->partner_oper_aggregator_key = port->partner_oper_key; 1398 port->aggregator->partner_oper_aggregator_key = port->partner_oper.key;
1399 port->aggregator->receive_state = 1; 1399 port->aggregator->receive_state = 1;
1400 port->aggregator->transmit_state = 1; 1400 port->aggregator->transmit_state = 1;
1401 port->aggregator->lag_ports = port; 1401 port->aggregator->lag_ports = port;
@@ -1695,18 +1695,18 @@ static void ad_initialize_port(struct port *port, int lacp_fast)
1695 port->actor_oper_port_state |= AD_STATE_LACP_TIMEOUT; 1695 port->actor_oper_port_state |= AD_STATE_LACP_TIMEOUT;
1696 } 1696 }
1697 1697
1698 port->partner_admin_system = null_mac_addr; 1698 port->partner_admin.system = null_mac_addr;
1699 port->partner_oper_system = null_mac_addr; 1699 port->partner_oper.system = null_mac_addr;
1700 port->partner_admin_system_priority = 0xffff; 1700 port->partner_admin.system_priority = 0xffff;
1701 port->partner_oper_system_priority = 0xffff; 1701 port->partner_oper.system_priority = 0xffff;
1702 port->partner_admin_key = 1; 1702 port->partner_admin.key = 1;
1703 port->partner_oper_key = 1; 1703 port->partner_oper.key = 1;
1704 port->partner_admin_port_number = 1; 1704 port->partner_admin.port_number = 1;
1705 port->partner_oper_port_number = 1; 1705 port->partner_oper.port_number = 1;
1706 port->partner_admin_port_priority = 0xff; 1706 port->partner_admin.port_priority = 0xff;
1707 port->partner_oper_port_priority = 0xff; 1707 port->partner_oper.port_priority = 0xff;
1708 port->partner_admin_port_state = 1; 1708 port->partner_admin.port_state = 1;
1709 port->partner_oper_port_state = 1; 1709 port->partner_oper.port_state = 1;
1710 port->is_enabled = 1; 1710 port->is_enabled = 1;
1711 // ****** private parameters ****** 1711 // ****** private parameters ******
1712 port->sm_vars = 0x3; 1712 port->sm_vars = 0x3;
diff --git a/drivers/net/bonding/bond_3ad.h b/drivers/net/bonding/bond_3ad.h
index a803fe05f63e..d5332cc6deea 100644
--- a/drivers/net/bonding/bond_3ad.h
+++ b/drivers/net/bonding/bond_3ad.h
@@ -199,6 +199,15 @@ typedef struct aggregator {
199 u16 num_of_ports; 199 u16 num_of_ports;
200} aggregator_t; 200} aggregator_t;
201 201
202struct port_params {
203 struct mac_addr system;
204 u16 system_priority;
205 u16 key;
206 u16 port_number;
207 u16 port_priority;
208 u16 port_state;
209};
210
202// port structure(43.4.6 in the 802.3ad standard) 211// port structure(43.4.6 in the 802.3ad standard)
203typedef struct port { 212typedef struct port {
204 u16 actor_port_number; 213 u16 actor_port_number;
@@ -211,18 +220,10 @@ typedef struct port {
211 u16 actor_oper_port_key; 220 u16 actor_oper_port_key;
212 u8 actor_admin_port_state; 221 u8 actor_admin_port_state;
213 u8 actor_oper_port_state; 222 u8 actor_oper_port_state;
214 struct mac_addr partner_admin_system; 223
215 struct mac_addr partner_oper_system; 224 struct port_params partner_admin;
216 u16 partner_admin_system_priority; 225 struct port_params partner_oper;
217 u16 partner_oper_system_priority; 226
218 u16 partner_admin_key;
219 u16 partner_oper_key;
220 u16 partner_admin_port_number;
221 u16 partner_oper_port_number;
222 u16 partner_admin_port_priority;
223 u16 partner_oper_port_priority;
224 u8 partner_admin_port_state;
225 u8 partner_oper_port_state;
226 u16 is_enabled; // BOOLEAN 227 u16 is_enabled; // BOOLEAN
227 // ****** PRIVATE PARAMETERS ****** 228 // ****** PRIVATE PARAMETERS ******
228 u16 sm_vars; // all state machines variables for this port 229 u16 sm_vars; // all state machines variables for this port