bonding updates for net-next-2.6
Subsystems (3)
cover bonding updates for net-next-2.6
Hi Dave,
what follows are some small updates against the bonding code of net-next-2.6, which are hopefully usefull to you.
Thanks.
/holger
PATCH 1/10 802.3ad: make ntt bool
Turn Need-To-Transmit port variable into a bool. There is no functional change.
drivers/net/bonding/bond_3ad.h +1 -1
@@ -215,7 +215,7 @@ typedef struct port {struct mac_addr actor_system;// This parameter is added here although it is not specified in the standard, just for simplification u16 actor_system_priority;// This parameter is added here although it is not specified in the standard, just for simplification u16 actor_port_aggregator_identifier; -u16 ntt;// BOOLEAN +bool ntt;u16 actor_admin_port_key;u16 actor_oper_port_key;u8 actor_admin_port_state;
drivers/net/bonding/bond_3ad.c +12 -10
@@ -629,8 +629,8 @@ static void __update_ntt(struct lacpdu * ((lacpdu->partner_state &AD_STATE_SYNCHRONIZATION ) != (port->actor_oper_port_state &AD_STATE_SYNCHRONIZATION )) || ((lacpdu->partner_state &AD_STATE_AGGREGATION ) != (port->actor_oper_port_state &AD_STATE_AGGREGATION )) ) { - // set ntt to be TRUE - port->ntt = 1; + + port->ntt = true; } } }
@@ -987,7 +987,7 @@ static void ad_mux_machine(struct port *ad_disable_collecting_distributing (port); port->actor_oper_port_state &= ~AD_STATE_COLLECTING ; port->actor_oper_port_state &= ~AD_STATE_DISTRIBUTING ; - port->ntt =1 ; + port->ntt = true;break ;case AD_MUX_WAITING : port->sm_mux_timer_counter =__ad_timer_to_ticks (AD_WAIT_WHILE_TIMER ,0 );
@@ -998,13 +998,13 @@ static void ad_mux_machine(struct port * port->actor_oper_port_state &= ~AD_STATE_COLLECTING ; port->actor_oper_port_state &= ~AD_STATE_DISTRIBUTING ;ad_disable_collecting_distributing (port); - port->ntt =1 ; + port->ntt = true;break ;case AD_MUX_COLLECTING_DISTRIBUTING : port->actor_oper_port_state |=AD_STATE_COLLECTING ; port->actor_oper_port_state |=AD_STATE_DISTRIBUTING ;ad_enable_collecting_distributing (port); - port->ntt =1 ; + port->ntt = true;break ;default ://to silence the compiler break ;
@@ -1163,11 +1163,13 @@ static void ad_tx_machine(struct port *p// check if there is something to send if (port->ntt && (port->sm_vars &AD_PORT_LACP_ENABLED )) {__update_lacpdu_from_port (port); -// send the lacpdu +if (ad_lacpdu_send (port) >=0 ) {pr_debug ("Sent LACPDU on port %d\n" , port->actor_port_number); -// mark ntt as false, so it will not be sent again until demanded - port->ntt =0 ; + +/* mark ntt as false, so it will not be sent again until +demanded */ + port->ntt = false; } }// restart tx timer(to verify that we will not exceed AD_MAX_TX_IN_SECOND
@@ -1250,7 +1252,7 @@ static void ad_periodic_machine(struct p port->sm_periodic_timer_counter =__ad_timer_to_ticks (AD_PERIODIC_TIMER , (u16)(AD_SLOW_PERIODIC_TIME ))-1 ;// decrement 1 tick we lost in the PERIODIC_TX cycle break ;case AD_PERIODIC_TX : - port->ntt =1 ; + port->ntt = true;break ;default ://to silence the compiler break ;
@@ -1664,7 +1666,7 @@ static void ad_initialize_port(struct po port->actor_system = null_mac_addr; port->actor_system_priority =0xffff ; port->actor_port_aggregator_identifier =0 ; - port->ntt =0 ; + port->ntt = false; port->actor_admin_port_key =1 ; port->actor_oper_port_key =1 ; port->actor_admin_port_state =AD_STATE_AGGREGATION |AD_STATE_LACP_ACTIVITY ;
Re: [patch 01/10] 802.3ad: make ntt bool
From: Holger Eitzenberger <[email protected]>
Date: Tue, 23 Dec 2008 23:01:02 +0100
Quoted 4 lines
Turn Need-To-Transmit port variable into a bool. There is no functional change.
Signed-off-by Holger Eitzenberger <[email protected]>
Applied.
PATCH 2/10 802.3ad: turn ports is_enabled into a bool
In reply to Holger EitzenbergerTurn ports is_enabled into a bool. There is no functional change.
drivers/net/bonding/bond_3ad.h +2 -1
@@ -224,7 +224,8 @@ typedef struct port {struct port_params partner_admin;struct port_params partner_oper; -u16 is_enabled;// BOOLEAN +bool is_enabled; +// ****** PRIVATE PARAMETERS ****** u16 sm_vars;// all state machines variables for this port rx_states_t sm_rx_state;// state machine rx state
drivers/net/bonding/bond_3ad.c +3 -3
@@ -1679,7 +1679,7 @@ static void ad_initialize_port(struct pomemcpy (&port->partner_admin, &tmpl,sizeof (tmpl));memcpy (&port->partner_oper, &tmpl,sizeof (tmpl)); - port->is_enabled =1 ; + port->is_enabled = true;// ****** private parameters ****** port->sm_vars =0x3 ; port->sm_rx_state =0 ;
@@ -2308,14 +2308,14 @@ void bond_3ad_handle_link_change(struct// on link down we are zeroing duplex and speed since some of the adaptors(ce1000.lan) report full duplex/speed instead of N/A(duplex) / 0(speed) // on link up we are forcing recheck on the duplex and speed since some of he adaptors(ce1000.lan) report if (link ==BOND_LINK_UP ) { - port->is_enabled =1 ; + port->is_enabled = true; port->actor_admin_port_key &= ~AD_DUPLEX_KEY_BITS ; port->actor_oper_port_key=port->actor_admin_port_key |=__get_duplex (port); port->actor_admin_port_key &= ~AD_SPEED_KEY_BITS ; port->actor_oper_port_key=port->actor_admin_port_key |= (__get_link_speed (port) <<1 ); }else {/* link has failed */ - port->is_enabled =0 ; + port->is_enabled = false; port->actor_admin_port_key &= ~AD_DUPLEX_KEY_BITS ; port->actor_oper_port_key= (port->actor_admin_port_key &= ~AD_SPEED_KEY_BITS ); }
Re: [patch 02/10] 802.3ad: turn ports is_enabled into a bool
From: Holger Eitzenberger <[email protected]>
Date: Tue, 23 Dec 2008 23:01:03 +0100
Quoted 3 lines
Turn ports
is_enabledinto a bool. There is no functional change.Signed-off-by Holger Eitzenberger <[email protected]>
Applied.
PATCH 3/10 802.3ad: turn ports is_individual into a bool
In reply to Holger EitzenbergerTurn ports is_individual into a bool. There is no functional change.
drivers/net/bonding/bond_3ad.c +3 -3
@@ -1359,9 +1359,9 @@ static void ad_port_selection_logic(stru// update the new aggregator's parameters // if port was responsed from the end-user if (port->actor_oper_port_key &AD_DUPLEX_KEY_BITS ) {// if port is full duplex - port->aggregator->is_individual =0 ; + port->aggregator->is_individual = false; }else { - port->aggregator->is_individual =1 ; + port->aggregator->is_individual = true; } port->aggregator->actor_admin_aggregator_key = port->actor_admin_port_key;
@@ -1613,7 +1613,7 @@ static void ad_agg_selection_logic(strucstatic void ad_clear_agg (struct aggregator *aggregator) {if (aggregator) { - aggregator->is_individual =0 ; + aggregator->is_individual = false; aggregator->actor_admin_aggregator_key =0 ; aggregator->actor_oper_aggregator_key =0 ; aggregator->partner_system = null_mac_addr;
drivers/net/bonding/bond_3ad.h +1 -1
@@ -184,7 +184,7 @@ struct port; typedef struct aggregator { struct mac_addr aggregator_mac_address; u16 aggregator_identifier; - u16 is_individual; // BOOLEAN + bool is_individual; u16 actor_admin_aggregator_key; u16 actor_oper_aggregator_key; struct mac_addr partner_system;
Re: [patch 03/10] 802.3ad: turn ports is_individual into a bool
From: Holger Eitzenberger <[email protected]>
Date: Tue, 23 Dec 2008 23:01:04 +0100
Quoted 3 lines
Turn ports
is_individualinto a bool. There is no functional change.Signed-off-by Holger Eitzenberger <[email protected]>
Applied.
PATCH 4/10 802.3ad: remove typedef around ad_system
In reply to Holger EitzenbergerAs typedefs are considered a bad thing most of the time remove the typedef around ad_system.
drivers/net/bonding/bond_3ad.h +3 -3
@@ -244,10 +244,10 @@ typedef struct port { } port_t;// system structure -typedef struct ad_system { +struct ad_system {u16 sys_priority;struct mac_addr sys_mac_addr; -}ad_system_t ; +};#ifdef __ia64__#pragma pack()
@@ -258,7 +258,7 @@ typedef struct ad_system {#define SLAVE_AD_INFO (slave) ((slave)->ad_info)struct ad_bond_info { -ad_system_t system;// 802.3ad system structure +struct ad_system system;/* 802.3ad system structure */ u32 agg_select_timer;// Timer to select aggregator after all adapter's hand shakes u32 agg_select_mode;// Mode of selection of active aggregator(bandwidth/count) int lacp_fast;/* whether fast periodic tx should be
Re: [patch 04/10] 802.3ad: remove typedef around ad_system
From: Holger Eitzenberger <[email protected]>
Date: Tue, 23 Dec 2008 23:01:05 +0100
Quoted 4 lines
As typedefs are considered a bad thing most of the time remove the typedef around
ad_system.Signed-off-by Holger Eitzenberger <[email protected]>
Applied.
PATCH 5/10 802.3ad: initialize ports LACPDU from const initializer
In reply to Holger EitzenbergerSave some text by initializing ports LACPDU from const initializer, then get rid of ad_initialize_lacpdu().
drivers/net/bonding/bond_3ad.c +12 -49
@@ -107,7 +107,6 @@ static void ad_agg_selection_logic(strucstatic void ad_clear_agg (struct aggregator *aggregator);static void ad_initialize_agg (struct aggregator *aggregator);static void ad_initialize_port (struct port *port,int lacp_fast); -static void ad_initialize_lacpdu (struct lacpdu *Lacpdu);static void ad_enable_collecting_distributing (struct port *port);static void ad_disable_collecting_distributing (struct port *port);static void ad_marker_info_received (struct bond_marker *marker_info,struct port *port);
@@ -1659,6 +1658,17 @@ static void ad_initialize_port(struct po .port_priority = 0xff, .port_state = 1, }; +static const struct lacpdu lacpdu = { + .subtype =0x01 , + .version_number =0x01 , + .tlv_type_actor_info =0x01 , + .actor_information_length =0x14 , + .tlv_type_partner_info =0x02 , + .partner_information_length =0x14 , + .tlv_type_collector_info =0x03 , + .collector_information_length =0x10 , + .collector_max_delay =htons (AD_COLLECTOR_MAX_DELAY ), + };if (port) { port->actor_port_number =1 ;
@@ -1695,7 +1705,7 @@ static void ad_initialize_port(struct po port->next_port_in_aggregator =NULL ; port->transaction_id =0 ; -ad_initialize_lacpdu (&(port->lacpdu)); +memcpy (&port->lacpdu, &lacpdu,sizeof (lacpdu)); } }
@@ -1804,53 +1814,6 @@ static void ad_marker_response_received(// DO NOTHING, SINCE WE DECIDED NOT TO IMPLEMENT THIS FEATURE FOR NOW } -/** -* ad_initialize_lacpdu - initialize a given lacpdu structure -* @lacpdu: lacpdu structure to initialize -* -*/ -static void ad_initialize_lacpdu (struct lacpdu *lacpdu) -{ -u16 index; - -// initialize lacpdu data - lacpdu->subtype =0x01 ; - lacpdu->version_number =0x01 ; - lacpdu->tlv_type_actor_info =0x01 ; - lacpdu->actor_information_length =0x14 ; -// lacpdu->actor_system_priority updated on send -// lacpdu->actor_system updated on send -// lacpdu->actor_key updated on send -// lacpdu->actor_port_priority updated on send -// lacpdu->actor_port updated on send -// lacpdu->actor_state updated on send - lacpdu->tlv_type_partner_info =0x02 ; - lacpdu->partner_information_length =0x14 ; -for (index=0 ; index<=2 ; index++) { - lacpdu->reserved_3_1[index]=0 ; - } -// lacpdu->partner_system_priority updated on send -// lacpdu->partner_system updated on send -// lacpdu->partner_key updated on send -// lacpdu->partner_port_priority updated on send -// lacpdu->partner_port updated on send -// lacpdu->partner_state updated on send -for (index=0 ; index<=2 ; index++) { - lacpdu->reserved_3_2[index]=0 ; - } - lacpdu->tlv_type_collector_info =0x03 ; - lacpdu->collector_information_length=0x10 ; - lacpdu->collector_max_delay =htons (AD_COLLECTOR_MAX_DELAY ); -for (index=0 ; index<=11 ; index++) { - lacpdu->reserved_12[index]=0 ; - } - lacpdu->tlv_type_terminator =0x00 ; - lacpdu->terminator_length =0 ; -for (index=0 ; index<=49 ; index++) { - lacpdu->reserved_50[index]=0 ; - } -} -////////////////////////////////////////////////////////////////////////////////////// // ================= AD exported functions to the main bonding code ================== //////////////////////////////////////////////////////////////////////////////////////
Re: [patch 05/10] 802.3ad: initialize ports LACPDU from const initializer
From: Holger Eitzenberger <[email protected]>
Date: Tue, 23 Dec 2008 23:01:06 +0100
Quoted 4 lines
Save some text by initializing ports LACPDU from const initializer, then get rid of
ad_initialize_lacpdu().Signed-off-by Holger Eitzenberger <[email protected]>
Applied.
PATCH 6/10 802.3ad: generalize out mac address initializer
In reply to Holger EitzenbergerGeneralize out mac address initializer for the LACPDU multicast address and use in two places. Remove the now unused AD_MULTICAST_LACPDU_ADDR.
drivers/net/bonding/bond_3ad.c +14 -10
@@ -95,6 +95,8 @@ 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 ; +static const u8 lacpdu_mcast_addr[ETH_ALEN ] =MULTICAST_LACPDU_ADDR ; +// ================= 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);
@@ -824,7 +826,6 @@ static int ad_lacpdu_send(struct port *pstruct sk_buff *skb;struct lacpdu_header *lacpdu_header;int length =sizeof (struct lacpdu_header ); -struct mac_addr lacpdu_multicast_address =AD_MULTICAST_LACPDU_ADDR ; skb =dev_alloc_skb (length);if (!skb) {
@@ -839,10 +840,12 @@ static int ad_lacpdu_send(struct port *p lacpdu_header = (struct lacpdu_header *)skb_put (skb, length); - lacpdu_header->ad_header.destination_address = lacpdu_multicast_address; -/* Note: source addres is set to be the member's PERMANENT address, because we use it -to identify loopback lacpdus in receive. */ - lacpdu_header->ad_header.source_address = *((struct mac_addr *)(slave->perm_hwaddr)); +memcpy (lacpdu_header->ad_header.destination_address.mac_addr_value, + lacpdu_mcast_addr,ETH_ALEN ); +/* Note: source addres is set to be the member's PERMANENT address, +because we use it to identify loopback lacpdus in receive. */ +memcpy (lacpdu_header->ad_header.source_address.mac_addr_value, + slave->perm_hwaddr,ETH_ALEN ); lacpdu_header->ad_header.length_type =PKT_TYPE_LACPDU ; lacpdu_header->lacpdu = port->lacpdu;// struct copy
@@ -866,7 +869,6 @@ static int ad_marker_send(struct port *pstruct sk_buff *skb;struct bond_marker_header *marker_header;int length =sizeof (struct bond_marker_header ); -struct mac_addr lacpdu_multicast_address =AD_MULTICAST_LACPDU_ADDR ; skb =dev_alloc_skb (length +16 );if (!skb) {
@@ -882,10 +884,12 @@ static int ad_marker_send(struct port *p marker_header = (struct bond_marker_header *)skb_put (skb, length); - marker_header->ad_header.destination_address = lacpdu_multicast_address; -/* Note: source addres is set to be the member's PERMANENT address, because we use it -to identify loopback MARKERs in receive. */ - marker_header->ad_header.source_address = *((struct mac_addr *)(slave->perm_hwaddr)); +memcpy (marker_header->ad_header.destination_address.mac_addr_value, + lacpdu_mcast_addr,ETH_ALEN ); +/* Note: source addres is set to be the member's PERMANENT address, +because we use it to identify loopback MARKERs in receive. */ +memcpy (marker_header->ad_header.source_address.mac_addr_value, + slave->perm_hwaddr,ETH_ALEN ); marker_header->ad_header.length_type =PKT_TYPE_LACPDU ; marker_header->marker = *marker;// struct copy
drivers/net/bonding/bond_3ad.h +0 -1
@@ -33,7 +33,6 @@#define AD_TIMER_INTERVAL 100/*msec*/ #define MULTICAST_LACPDU_ADDR {0x01, 0x80, 0xC2, 0x00, 0x00, 0x02} -#define AD_MULTICAST_LACPDU_ADDR {MULTICAST_LACPDU_ADDR}#define AD_LACP_SLOW 0#define AD_LACP_FAST 1
Re: [patch 06/10] 802.3ad: generalize out mac address initializer
From: Holger Eitzenberger <[email protected]>
Date: Tue, 23 Dec 2008 23:01:07 +0100
Quoted 5 lines
Generalize out mac address initializer for the LACPDU multicast address and use in two places. Remove the now unused
AD_MULTICAST_LACPDU_ADDR.Signed-off-by Holger Eitzenberger <[email protected]>
Applied.
PATCH 7/10 802.3ad: use standard ethhdr instead of ad_header
In reply to Holger Eitzenberger802.3ad has its own ethhdr-like structure in the form of an ad_header, which is at the start of both the LACPDU and marker PDU. Both are the same from the struct values, both are packed as well.
It's therefore perfectly fine to replace the ad_header by the ethhdr and to remove its definition.
drivers/net/bonding/bond_3ad.h +2 -8
@@ -105,12 +105,6 @@ typedef enum {#pragma pack(1) -typedef struct ad_header { -struct mac_addr destination_address; -struct mac_addr source_address; -__be16 length_type; -}ad_header_t ; -// Link Aggregation Control Protocol(LACP) data unit structure(43.4.2.2 in the 802.3ad standard) typedef struct lacpdu { u8 subtype; // = LACP(= 0x01)
@@ -143,7 +137,7 @@ typedef struct lacpdu { } lacpdu_t;typedef struct lacpdu_header { -struct ad_header ad_header; +struct ethhdr hdr;struct lacpdu lacpdu; }lacpdu_header_t ;
@@ -164,7 +158,7 @@ typedef struct bond_marker { } bond_marker_t;typedef struct bond_marker_header { -struct ad_header ad_header; +struct ethhdr hdr;struct bond_marker marker; }bond_marker_header_t ;
drivers/net/bonding/bond_3ad.c +6 -10
@@ -840,13 +840,11 @@ static int ad_lacpdu_send(struct port *p lacpdu_header = (struct lacpdu_header *)skb_put (skb, length); -memcpy (lacpdu_header->ad_header.destination_address.mac_addr_value, - lacpdu_mcast_addr,ETH_ALEN ); +memcpy (lacpdu_header->hdr.h_dest, lacpdu_mcast_addr,ETH_ALEN );/* Note: source addres is set to be the member's PERMANENT address, because we use it to identify loopback lacpdus in receive. */ -memcpy (lacpdu_header->ad_header.source_address.mac_addr_value, - slave->perm_hwaddr,ETH_ALEN ); - lacpdu_header->ad_header.length_type =PKT_TYPE_LACPDU ; +memcpy (lacpdu_header->hdr.h_source, slave->perm_hwaddr,ETH_ALEN ); + lacpdu_header->hdr.h_proto =PKT_TYPE_LACPDU ; lacpdu_header->lacpdu = port->lacpdu;// struct copy
@@ -884,13 +882,11 @@ static int ad_marker_send(struct port *p marker_header = (struct bond_marker_header *)skb_put (skb, length); -memcpy (marker_header->ad_header.destination_address.mac_addr_value, - lacpdu_mcast_addr,ETH_ALEN ); +memcpy (marker_header->hdr.h_dest, lacpdu_mcast_addr,ETH_ALEN );/* Note: source addres is set to be the member's PERMANENT address, because we use it to identify loopback MARKERs in receive. */ -memcpy (marker_header->ad_header.source_address.mac_addr_value, - slave->perm_hwaddr,ETH_ALEN ); - marker_header->ad_header.length_type =PKT_TYPE_LACPDU ; +memcpy (marker_header->hdr.h_source, slave->perm_hwaddr,ETH_ALEN ); + marker_header->hdr.h_proto =PKT_TYPE_LACPDU ; marker_header->marker = *marker;// struct copy
Re: [patch 07/10] 802.3ad: use standard ethhdr instead of ad_header
From: Holger Eitzenberger <[email protected]>
Date: Tue, 23 Dec 2008 23:01:08 +0100
Quoted 8 lines
802.3ad has its own ethhdr-like structure in the form of an
ad_header, which is at the start of both the LACPDU and marker PDU. Both are the same from the struct values, both are packed as well.It's therefore perfectly fine to replace the
ad_headerby the ethhdr and to remove its definition.Signed-off-by Holger Eitzenberger <[email protected]>
Applied.
PATCH 8/10 802.3ad: remove public lacpdu_header
In reply to Holger EitzenbergerIt's strictly not necessary to define lacpdu_header in an include file because it's only used in ad_lacpdu_send(). Remove that definition and use an unnamed structure instead just for our purpose. Which also gives a chance to use shorter names which are still descriptive.
As the port is left unmodified it's now const.
Also cleanup that function a bit by removing useless braces around one-liners and turn C++ style comments into C comments.
drivers/net/bonding/bond_3ad.c +13 -12
@@ -98,7 +98,6 @@ static const int ad_delta_in_ticks = (ADstatic const u8 lacpdu_mcast_addr[ETH_ALEN ] =MULTICAST_LACPDU_ADDR ;// ================= 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);static void ad_mux_machine (struct port *port);static void ad_rx_machine (struct lacpdu *lacpdu,struct port *port);
@@ -820,17 +819,19 @@ static inline void __update_lacpdu_from_* Returns: 0 on success * < 0 on error */ -static int ad_lacpdu_send (struct port *port) +static int ad_lacpdu_send (const struct port *port) {struct slave *slave = port->slave;struct sk_buff *skb; -struct lacpdu_header *lacpdu_header; -int length =sizeof (struct lacpdu_header ); +struct { +struct ethhdr hdr; +struct lacpdu lacpdu; + } __packed *pdu; +int len =sizeof (*pdu); - skb =dev_alloc_skb (length); -if (!skb) { + skb =dev_alloc_skb (len); +if (skb ==NULL )return -ENOMEM ; - } skb->dev = slave->dev;skb_reset_mac_header (skb);
@@ -838,15 +839,15 @@ static int ad_lacpdu_send(struct port *p skb->protocol =PKT_TYPE_LACPDU ; skb->priority =TC_PRIO_CONTROL ; - lacpdu_header = (struct lacpdu_header *)skb_put (skb, length); + pdu = (void *)skb_put (skb, len); -memcpy (lacpdu_header->hdr.h_dest, lacpdu_mcast_addr,ETH_ALEN ); +memcpy (pdu->hdr.h_dest, lacpdu_mcast_addr,ETH_ALEN );/* Note: source addres is set to be the member's PERMANENT address, because we use it to identify loopback lacpdus in receive. */ -memcpy (lacpdu_header->hdr.h_source, slave->perm_hwaddr,ETH_ALEN ); - lacpdu_header->hdr.h_proto =PKT_TYPE_LACPDU ; +memcpy (pdu->hdr.h_source, slave->perm_hwaddr,ETH_ALEN ); + pdu->hdr.h_proto =PKT_TYPE_LACPDU ; - lacpdu_header->lacpdu = port->lacpdu;// struct copy +memcpy (&pdu->lacpdu, &port->lacpdu,sizeof (pdu->lacpdu));dev_queue_xmit (skb);
drivers/net/bonding/bond_3ad.h +0 -5
@@ -136,11 +136,6 @@ typedef struct lacpdu {u8 reserved_50[50 ];// = 0 } lacpdu_t; -typedef struct lacpdu_header { -struct ethhdr hdr; -struct lacpdu lacpdu; -}lacpdu_header_t ; -// Marker Protocol Data Unit(PDU) structure(43.5.3.2 in the 802.3ad standard) typedef struct bond_marker { u8 subtype; // = 0x02 (marker PDU)
David Miller
maintainerRe: [patch 08/10] 802.3ad: remove public lacpdu_header
From: Holger Eitzenberger <[email protected]>
Date: Tue, 23 Dec 2008 23:01:09 +0100
drivers/net/bonding/bond_3ad.c static inline void __update_lacpdu_from_ · line 833
Quoted 4 lines
drivers/net/bonding/bond_3ad.c +2
-2- skb =dev_alloc_skb (length); -if (!skb) { + skb =dev_alloc_skb (len); +if (skb ==NULL )
"!skb" is preferred to the long-winded "skb == NULL", so I'm tossing this patch and the rest which touch similar areas.
Please don't mix cleanups and other changes unless you are %100 confident they will pass the most stringent review, otherwise your patches will be rejected unnecessarily.
David Miller
maintainerRe: [patch 08/10] 802.3ad: remove public lacpdu_header
From: David Miller <[email protected]>
Date: Fri, 26 Dec 2008 13:43:49 -0800 (PST)
Quoted 11 lines
From: Holger Eitzenberger <[email protected]>
Date: Tue, 23 Dec 2008 23:01:09 +0100drivers/net/bonding/bond_3ad.c static inline void __update_lacpdu_from_ · line 833
Quoted 4 lines
drivers/net/bonding/bond_3ad.c +2
-2- skb =dev_alloc_skb (length); -if (!skb) { + skb =dev_alloc_skb (len); +if (skb ==NULL )"!skb" is preferred to the long-winded "skb == NULL", so I'm tossing this patch and the rest which touch similar areas.
Also, I want to mention that your C++ comment conversions are not in the proper coding style as well. You are doing:
/* something written here */
instead of the proper:
/* something written * here */
Just FYI...
Re: [patch 08/10] 802.3ad: remove public lacpdu_header
Quoted 11 lines · David Miller
Quoted 8 lines
drivers/net/bonding/bond_3ad.c static inline void __update_lacpdu_from_ · line 833
Quoted 4 lines
drivers/net/bonding/bond_3ad.c +2
-2- skb =dev_alloc_skb (length); -if (!skb) { + skb =dev_alloc_skb (len); +if (skb ==NULL )"!skb" is preferred to the long-winded "skb == NULL", so I'm tossing this patch and the rest which touch similar areas.
Also, I want to mention that your C++ comment conversions are not in the proper coding style as well. You are doing:
As I'm currently offline most of the time I'll resend once I'm back home.
Thanks for your feedback!
/holger
PATCH 9/10 802.3ad: remove public bond_marker_header
In reply to Holger EitzenbergerIt's strictly not necessary to define bond_marker_header in an include file because it's only used in ad_lacpdu_send(). Remove that definition and use an unnamed structure instead just for our purpose. Which also gives a chance to use shorter names which are still descriptive.
As the port and marker are left unmodified I've made them const.
As that function is defined before used I've left out the forward declaration.
Also cleanup that function a bit by removing useless braces around one-liners and turn C++ style comments into C comments.
drivers/net/bonding/bond_3ad.h +0 -5
@@ -152,11 +152,6 @@ typedef struct bond_marker {u8 reserved_90[90 ];// = 0 } bond_marker_t; -typedef struct bond_marker_header { -struct ethhdr hdr; -struct bond_marker marker; -}bond_marker_header_t ; -#pragma pack()struct slave ;
drivers/net/bonding/bond_3ad.c +14 -12
@@ -98,7 +98,6 @@ static const int ad_delta_in_ticks = (ADstatic const u8 lacpdu_mcast_addr[ETH_ALEN ] =MULTICAST_LACPDU_ADDR ;// ================= main 802.3ad protocol functions ================== -static int ad_marker_send (struct port *port,struct bond_marker *marker);static void ad_mux_machine (struct port *port);static void ad_rx_machine (struct lacpdu *lacpdu,struct port *port);static void ad_tx_machine (struct port *port);
@@ -862,17 +861,20 @@ static int ad_lacpdu_send(const struct p* Returns: 0 on success * < 0 on error */ -static int ad_marker_send (struct port *port,struct bond_marker *marker) +static int ad_marker_send (const struct port *port, +const struct bond_marker *marker) {struct slave *slave = port->slave;struct sk_buff *skb; -struct bond_marker_header *marker_header; -int length =sizeof (struct bond_marker_header ); +struct { +struct ethhdr hdr; +struct bond_marker marker; + } __packed *pdu; +int len =sizeof (*pdu); - skb =dev_alloc_skb (length +16 ); -if (!skb) { + skb =dev_alloc_skb (len +16 ); +if (skb ==NULL )return -ENOMEM ; - }skb_reserve (skb,16 );
@@ -881,15 +883,15 @@ static int ad_marker_send(struct port *p skb->network_header = skb->mac_header +ETH_HLEN ; skb->protocol =PKT_TYPE_LACPDU ; - marker_header = (struct bond_marker_header *)skb_put (skb, length); + pdu = (void *)skb_put (skb, len); -memcpy (marker_header->hdr.h_dest, lacpdu_mcast_addr,ETH_ALEN ); +memcpy (pdu->hdr.h_dest, lacpdu_mcast_addr,ETH_ALEN );/* Note: source addres is set to be the member's PERMANENT address, because we use it to identify loopback MARKERs in receive. */ -memcpy (marker_header->hdr.h_source, slave->perm_hwaddr,ETH_ALEN ); - marker_header->hdr.h_proto =PKT_TYPE_LACPDU ; +memcpy (pdu->hdr.h_source, slave->perm_hwaddr,ETH_ALEN ); + pdu->hdr.h_proto =PKT_TYPE_LACPDU ; - marker_header->marker = *marker;// struct copy +memcpy (&pdu->marker, marker,sizeof (pdu->marker));dev_queue_xmit (skb);
PATCH 10/10 802.3ad: cleanup around lacpdu and bond_marker
In reply to Holger EitzenbergerRemove the typedef around lacpdu and bond_marker. Also turn C++ comments into C comments and some more or less pretty printing.
drivers/net/bonding/bond_3ad.h +35 -31
@@ -105,52 +105,56 @@ typedef enum {#pragma pack(1) -// Link Aggregation Control Protocol(LACP) data unit structure(43.4.2.2 in the 802.3ad standard) -typedef struct lacpdu { -u8 subtype;// = LACP(= 0x01) +/* Link Aggregation Control Protocol (LACP) data unit structure +(43.4.2.2 in the 802.3ad standard) */ +struct lacpdu { +u8 subtype;/* LACP(= 0x01) */ u8 version_number; -u8 tlv_type_actor_info;// = actor information(type/length/value) -u8 actor_information_length;// = 20 +u8 tlv_type_actor_info;/* actor information TLV */ +u8 actor_information_length;/* = 20 */ __be16 actor_system_priority;struct mac_addr actor_system;__be16 actor_key;__be16 actor_port_priority;__be16 actor_port;u8 actor_state; -u8 reserved_3_1[3 ];// = 0 -u8 tlv_type_partner_info;// = partner information -u8 partner_information_length;// = 20 +u8 reserved_3_1[3 ];/* = 0 */ +u8 tlv_type_partner_info;/* partner information */ +u8 partner_information_length;/* = 20 */ __be16 partner_system_priority;struct mac_addr partner_system;__be16 partner_key;__be16 partner_port_priority;__be16 partner_port;u8 partner_state; -u8 reserved_3_2[3 ];// = 0 -u8 tlv_type_collector_info;// = collector information -u8 collector_information_length;// = 16 +u8 reserved_3_2[3 ];/* = 0 */ +u8 tlv_type_collector_info;/* collector information */ +u8 collector_information_length;/* = 16 */ __be16 collector_max_delay;u8 reserved_12[12 ]; -u8 tlv_type_terminator;// = terminator -u8 terminator_length;// = 0 -u8 reserved_50[50 ];// = 0 -}lacpdu_t ; - -// Marker Protocol Data Unit(PDU) structure(43.5.3.2 in the 802.3ad standard) -typedef struct bond_marker { -u8 subtype;// = 0x02 (marker PDU) -u8 version_number;// = 0x01 -u8 tlv_type;// = 0x01 (marker information) -// = 0x02 (marker response information) -u8 marker_length;// = 0x16 -u16 requester_port;// The number assigned to the port by the requester -struct mac_addr requester_system;// The requester's system id -u32 requester_transaction_id;// The transaction id allocated by the requester, -u16 pad;// = 0 -u8 tlv_type_terminator;// = 0x00 -u8 terminator_length;// = 0x00 -u8 reserved_90[90 ];// = 0 -}bond_marker_t ; +u8 tlv_type_terminator;/* terminator */ +u8 terminator_length;/* = 0 */ +u8 reserved_50[50 ];/* = 0 */ +}; + +/* Marker Protocol Data Unit (PDU) structure (43.5.3.2 in the 802.3ad +standard) */ +struct bond_marker { +u8 subtype;/* = 0x02 (marker PDU) */ +u8 version_number;/* = 0x01 */ +u8 tlv_type;/* 0x01: marker info, +0x02: marker response info */ +u8 marker_length;/* = 0x16 */ +u16 requester_port;/* number assigned to the port +requester */ +struct mac_addr requester_system;/* he requester's system id */ +u32 requester_transaction_id;/* transaction id allocated by +requester */ +u16 pad;/* = 00 */ +u8 tlv_type_terminator;/* = 0x00 */ +u8 terminator_length;/* = 0x00 */ +u8 reserved_90[90 ];/* = 0 */ +};#pragma pack()