bonding updates for net-next-2.6
Subsystems (3)
cover bonding updates for net-next-2.6
Hi Jay,
what follows are some bonding updates to 802.3ad mode. They introduce the port_params struct as part of the port struct, which helps in handling the port parameter values in various places.
Hopefully they are usefull to you.
Thanks.
/holger
PATCH 1/9 bonding: improve elaborate port_state assignment
The previous code was just a funny way of assigning both values (they are both of type u8).
drivers/net/bonding/bond_3ad.c +1 -10
@@ -491,16 +491,7 @@ static void __record_pdu(struct lacpdu * port->partner_oper_system = lacpdu->actor_system; port->partner_oper_system_priority =ntohs (lacpdu->actor_system_priority); port->partner_oper_key =ntohs (lacpdu->actor_key); -// zero partener's lase states - port->partner_oper_port_state =0 ; - port->partner_oper_port_state |= (lacpdu->actor_state &AD_STATE_LACP_ACTIVITY ); - port->partner_oper_port_state |= (lacpdu->actor_state &AD_STATE_LACP_TIMEOUT ); - port->partner_oper_port_state |= (lacpdu->actor_state &AD_STATE_AGGREGATION ); - port->partner_oper_port_state |= (lacpdu->actor_state &AD_STATE_SYNCHRONIZATION ); - port->partner_oper_port_state |= (lacpdu->actor_state &AD_STATE_COLLECTING ); - port->partner_oper_port_state |= (lacpdu->actor_state &AD_STATE_DISTRIBUTING ); - port->partner_oper_port_state |= (lacpdu->actor_state &AD_STATE_DEFAULTED ); - port->partner_oper_port_state |= (lacpdu->actor_state &AD_STATE_EXPIRED ); + port->partner_oper_port_state = lacpdu->actor_state;// set actor_oper_port_state.defaulted to FALSE port->actor_oper_port_state &= ~AD_STATE_DEFAULTED ;
PATCH 2/9 bonding: introduce and use port_params structure
In reply to Holger EitzenbergerIt 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".
drivers/net/bonding/bond_3ad.h +13 -12
@@ -199,6 +199,15 @@ typedef struct aggregator {u16 num_of_ports; } aggregator_t; +struct port_params { +struct mac_addr system; +u16 system_priority; +u16 key; +u16 port_number; +u16 port_priority; +u16 port_state; +}; +// port structure(43.4.6 in the 802.3ad standard) typedef struct port { u16 actor_port_number;
@@ -211,18 +220,10 @@ typedef struct port {u16 actor_oper_port_key;u8 actor_admin_port_state;u8 actor_oper_port_state; -struct mac_addr partner_admin_system; -struct mac_addr partner_oper_system; -u16 partner_admin_system_priority; -u16 partner_oper_system_priority; -u16 partner_admin_key; -u16 partner_oper_key; -u16 partner_admin_port_number; -u16 partner_oper_port_number; -u16 partner_admin_port_priority; -u16 partner_oper_port_priority; -u8 partner_admin_port_state; -u8 partner_oper_port_state; + +struct port_params partner_admin; +struct port_params partner_oper; +u16 is_enabled;// BOOLEAN // ****** PRIVATE PARAMETERS ****** u16 sm_vars;// all state machines variables for this port
drivers/net/bonding/bond_3ad.c +60 -60
223 lines not on this page · raw message
PATCH 3/9 bonding: use port_params in __record_pdu()
In reply to Holger EitzenbergerIt helps in maintaining the various partner information values from the LACPDU. It also removes the pointless comment at the top.
drivers/net/bonding/bond_3ad.c +10 -9
@@ -483,24 +483,25 @@ static u16 __ad_timer_to_ticks(u16 timer*/ static void __record_pdu (struct lacpdu *lacpdu,struct port *port) { -// validate lacpdu and port if (lacpdu && port) { +struct port_params *partner = &port->partner_oper; +// record the new parameter values for the partner operational - port->partner_oper.port_number =ntohs (lacpdu->actor_port); - port->partner_oper.port_priority =ntohs (lacpdu->actor_port_priority); - port->partner_oper.system = lacpdu->actor_system; - port->partner_oper.system_priority =ntohs (lacpdu->actor_system_priority); - port->partner_oper.key =ntohs (lacpdu->actor_key); - port->partner_oper.port_state = lacpdu->actor_state; + partner->port_number =ntohs (lacpdu->actor_port); + partner->port_priority =ntohs (lacpdu->actor_port_priority); + partner->system = lacpdu->actor_system; + partner->system_priority =ntohs (lacpdu->actor_system_priority); + partner->key =ntohs (lacpdu->actor_key); + partner->port_state = lacpdu->actor_state;// set actor_oper_port_state.defaulted to FALSE port->actor_oper_port_state &= ~AD_STATE_DEFAULTED ;// set the partner sync. to on if the partner is sync. and the port is matched if ((port->sm_vars &AD_PORT_MATCHED ) && (lacpdu->actor_state &AD_STATE_SYNCHRONIZATION )) { - port->partner_oper.port_state |=AD_STATE_SYNCHRONIZATION ; + partner->port_state |=AD_STATE_SYNCHRONIZATION ; }else { - port->partner_oper.port_state &= ~AD_STATE_SYNCHRONIZATION ; + partner->port_state &= ~AD_STATE_SYNCHRONIZATION ; } } }
PATCH 4/9 bonding: use plain memcpy in __record_default()
In reply to Holger EitzenbergerAlso remove the pointless comment at the top.
drivers/net/bonding/bond_3ad.c +2 -7
@@ -516,15 +516,10 @@ static void __record_pdu(struct lacpdu **/ static void __record_default (struct port *port) { -// validate the port if (port) {// record the partner admin parameters - port->partner_oper.port_number = port->partner_admin.port_number; - port->partner_oper.port_priority = port->partner_admin.port_priority; - port->partner_oper.system = port->partner_admin.system; - port->partner_oper.system_priority = port->partner_admin.system_priority; - port->partner_oper.key = port->partner_admin.key; - port->partner_oper.port_state = port->partner_admin.port_state; +memcpy (&port->partner_oper, &port->partner_admin, +sizeof (struct port_params ));// set actor_oper_port_state.defaulted to true port->actor_oper_port_state |=AD_STATE_DEFAULTED ;
PATCH 5/9 bonding: init port_params from template
In reply to Holger Eitzenbergerdrivers/net/bonding/bond_3ad.c +11 -12
@@ -1675,6 +1675,14 @@ static void ad_initialize_agg(struct agg*/ static void ad_initialize_port (struct port *port,int lacp_fast) { +static const struct port_params tmpl = { + .system_priority =0xffff , + .key =1 , + .port_number =1 , + .port_priority =0xff , + .port_state =1 , + }; +if (port) { port->actor_port_number =1 ; port->actor_port_priority =0xff ;
@@ -1691,18 +1699,9 @@ static void ad_initialize_port(struct po port->actor_oper_port_state |=AD_STATE_LACP_TIMEOUT ; } - port->partner_admin.system = null_mac_addr; - port->partner_oper.system = null_mac_addr; - port->partner_admin.system_priority =0xffff ; - port->partner_oper.system_priority =0xffff ; - port->partner_admin.key =1 ; - port->partner_oper.key =1 ; - port->partner_admin.port_number =1 ; - port->partner_oper.port_number =1 ; - port->partner_admin.port_priority =0xff ; - port->partner_oper.port_priority =0xff ; - port->partner_admin.port_state =1 ; - port->partner_oper.port_state =1 ; +memcpy (&port->partner_admin, &tmpl,sizeof (tmpl)); +memcpy (&port->partner_oper, &tmpl,sizeof (tmpl)); + port->is_enabled =1 ;// ****** private parameters ****** port->sm_vars =0x3 ;
PATCH 6/9 bonding: remove various function declarations
In reply to Holger EitzenbergerThey are all defined before used, it's therefore ok to remove them.
drivers/net/bonding/bond_3ad.c +0 -28
@@ -95,34 +95,6 @@ static struct mac_addr null_mac_addr = {static u16 ad_ticks_per_sec;static const int ad_delta_in_ticks = (AD_TIMER_INTERVAL *HZ ) /1000 ; -// ================= 3AD api to bonding and kernel code ================== -static u16 __get_link_speed (struct port *port); -static u8 __get_duplex (struct port *port); -static inline void __initialize_port_locks (struct port *port); -//conversions -static u16 __ad_timer_to_ticks (u16 timer_type,u16 Par); - - -// ================= ad code helper functions ================== -//needed by ad_rx_machine(...) -static void __record_pdu (struct lacpdu *lacpdu,struct port *port); -static void __record_default (struct port *port); -static void __update_selected (struct lacpdu *lacpdu,struct port *port); -static void __update_default_selected (struct port *port); -static void __choose_matched (struct lacpdu *lacpdu,struct port *port); -static void __update_ntt (struct lacpdu *lacpdu,struct port *port); - -//needed for ad_mux_machine(..) -static void __attach_bond_to_agg (struct port *port); -static void __detach_bond_from_agg (struct port *port); -static int __agg_ports_are_ready (struct aggregator *aggregator); -static void __set_agg_ports_ready (struct aggregator *aggregator,int val); - -//needed for ad_agg_selection_logic(...) -static u32 __get_agg_bandwidth (struct aggregator *aggregator); -static struct aggregator *__get_active_agg (struct aggregator *aggregator); - -// ================= main 802.3ad protocol functions ================== static int ad_lacpdu_send (struct port *port);static int ad_marker_send (struct port *port,struct bond_marker *marker);
PATCH 7/9 bonding: use port_params in __update_selected()
In reply to Holger Eitzenbergerdrivers/net/bonding/bond_3ad.c +8 -8
@@ -513,16 +513,16 @@ static void __record_default(struct port*/ static void __update_selected (struct lacpdu *lacpdu,struct port *port) { -// validate lacpdu and port if (lacpdu && port) { +const struct port_params *partner = &port->partner_oper; +// check if any parameter is different -if ((ntohs (lacpdu->actor_port) != port->partner_oper.port_number) || - (ntohs (lacpdu->actor_port_priority) != port->partner_oper.port_priority) || -MAC_ADDRESS_COMPARE (&(lacpdu->actor_system), &(port->partner_oper.system)) || - (ntohs (lacpdu->actor_system_priority) != port->partner_oper.system_priority) || - (ntohs (lacpdu->actor_key) != port->partner_oper.key) || - ((lacpdu->actor_state &AD_STATE_AGGREGATION ) != (port->partner_oper.port_state &AD_STATE_AGGREGATION )) - ) { +if (ntohs (lacpdu->actor_port) != partner->port_number + ||ntohs (lacpdu->actor_port_priority) != partner->port_priority + ||MAC_ADDRESS_COMPARE (&lacpdu->actor_system, &partner->system) + ||ntohs (lacpdu->actor_system_priority) != partner->system_priority + ||ntohs (lacpdu->actor_key) != partner->key + || (lacpdu->actor_state &AD_STATE_AGGREGATION ) != (partner->port_state &AD_STATE_AGGREGATION )) {// update the state machine Selected variable port->sm_vars &= ~AD_PORT_SELECTED ; }
PATCH 8/9 bonding: use port_params in __update_default_selected()
In reply to Holger EitzenbergerI also removed some of the unneeded braces in the if condition to improve readability and a little bit of reformatting.
drivers/net/bonding/bond_3ad.c +10 -8
@@ -543,16 +543,18 @@ static void __update_selected(struct lac*/ static void __update_default_selected (struct port *port) { -// validate the port if (port) { +const struct port_params *admin = &port->partner_admin; +const struct port_params *oper = &port->partner_oper; +// check if any parameter is different -if ((port->partner_admin.port_number != port->partner_oper.port_number) || - (port->partner_admin.port_priority != port->partner_oper.port_priority) || -MAC_ADDRESS_COMPARE (&(port->partner_admin.system), &(port->partner_oper.system)) || - (port->partner_admin.system_priority != port->partner_oper.system_priority) || - (port->partner_admin.key != port->partner_oper.key) || - ((port->partner_admin.port_state &AD_STATE_AGGREGATION ) != (port->partner_oper.port_state &AD_STATE_AGGREGATION )) - ) { +if (admin->port_number != oper->port_number + || admin->port_priority != oper->port_priority + ||MAC_ADDRESS_COMPARE (&admin->system, &oper->system) + || admin->system_priority != oper->system_priority + || admin->key != oper->key + || (admin->port_state &AD_STATE_AGGREGATION ) + != (oper->port_state &AD_STATE_AGGREGATION )) {// update the state machine Selected variable port->sm_vars &= ~AD_PORT_SELECTED ; }
PATCH 9/9 bonding: use port_params in __update_lacpdu_from_port
In reply to Holger Eitzenbergerdrivers/net/bonding/bond_3ad.c +7 -6
@@ -769,6 +769,7 @@ static struct aggregator *__get_active_astatic inline void __update_lacpdu_from_port (struct port *port) {struct lacpdu *lacpdu = &port->lacpdu; +const struct port_params *partner = &port->partner_oper;/* update current actual Actor parameters */ /* lacpdu->subtype initialized
@@ -789,12 +790,12 @@ static inline void __update_lacpdu_from_* lacpdu->partner_information_length initialized */ - lacpdu->partner_system_priority =htons (port->partner_oper.system_priority); - lacpdu->partner_system = port->partner_oper.system; - lacpdu->partner_key =htons (port->partner_oper.key); - lacpdu->partner_port_priority =htons (port->partner_oper.port_priority); - lacpdu->partner_port =htons (port->partner_oper.port_number); - lacpdu->partner_state = port->partner_oper.port_state; + lacpdu->partner_system_priority =htons (partner->system_priority); + lacpdu->partner_system = partner->system; + lacpdu->partner_key =htons (partner->key); + lacpdu->partner_port_priority =htons (partner->port_priority); + lacpdu->partner_port =htons (partner->port_number); + lacpdu->partner_state = partner->port_state;/* lacpdu->reserved_3_2 initialized * lacpdu->tlv_type_collector_info initialized
David Miller
maintainerFrom: Holger Eitzenberger <[email protected]>
Date: Wed, 17 Dec 2008 22:28:27 +0100
Quoted 3 lines
what follows are some bonding updates to 802.3ad mode. They introduce the
port_paramsstruct as part of the port struct, which helps in handling the port parameter values in various places.
These cleanups look real nice, applied to net-next-2.6
Thanks Holger.