diff options
author | dingtianhong <dingtianhong@huawei.com> | 2014-05-12 03:08:43 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2014-05-14 14:09:15 -0400 |
commit | 3fdddd859af235119bdfb09ccc886fe48b97fc72 (patch) | |
tree | 11219c41e24c2d5344308d1a5e5b67aa27adb705 /drivers/net/bonding/bond_3ad.c | |
parent | 86b5d251d5ac4dda51a022b34cb29b4ce65a8cd5 (diff) |
bonding: alloc the structure ad_info dynamically in per slave
The struct ad_slave_info is very huge, and only be used for 802.3ad mode,
so alloc the structure dynamically could save 356 Bits for every slave in
non 802.3ad mode.
Cc: Jay Vosburgh <j.vosburgh@gmail.com>
Cc: Veaceslav Falico <vfalico@gmail.com>
Cc: Andy Gospodarek <andy@greyhouse.net>
Signed-off-by: Ding Tianhong <dingtianhong@huawei.com>
Acked-by: Veaceslav Falico <vfalico@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/bonding/bond_3ad.c')
-rw-r--r-- | drivers/net/bonding/bond_3ad.c | 54 |
1 files changed, 27 insertions, 27 deletions
diff --git a/drivers/net/bonding/bond_3ad.c b/drivers/net/bonding/bond_3ad.c index 9a0d61e0c188..24faddddf11e 100644 --- a/drivers/net/bonding/bond_3ad.c +++ b/drivers/net/bonding/bond_3ad.c | |||
@@ -157,7 +157,7 @@ static inline struct aggregator *__get_first_agg(struct port *port) | |||
157 | 157 | ||
158 | rcu_read_lock(); | 158 | rcu_read_lock(); |
159 | first_slave = bond_first_slave_rcu(bond); | 159 | first_slave = bond_first_slave_rcu(bond); |
160 | agg = first_slave ? &(SLAVE_AD_INFO(first_slave).aggregator) : NULL; | 160 | agg = first_slave ? &(SLAVE_AD_INFO(first_slave)->aggregator) : NULL; |
161 | rcu_read_unlock(); | 161 | rcu_read_unlock(); |
162 | 162 | ||
163 | return agg; | 163 | return agg; |
@@ -241,7 +241,7 @@ static inline int __check_agg_selection_timer(struct port *port) | |||
241 | */ | 241 | */ |
242 | static inline void __get_state_machine_lock(struct port *port) | 242 | static inline void __get_state_machine_lock(struct port *port) |
243 | { | 243 | { |
244 | spin_lock_bh(&(SLAVE_AD_INFO(port->slave).state_machine_lock)); | 244 | spin_lock_bh(&(SLAVE_AD_INFO(port->slave)->state_machine_lock)); |
245 | } | 245 | } |
246 | 246 | ||
247 | /** | 247 | /** |
@@ -250,7 +250,7 @@ static inline void __get_state_machine_lock(struct port *port) | |||
250 | */ | 250 | */ |
251 | static inline void __release_state_machine_lock(struct port *port) | 251 | static inline void __release_state_machine_lock(struct port *port) |
252 | { | 252 | { |
253 | spin_unlock_bh(&(SLAVE_AD_INFO(port->slave).state_machine_lock)); | 253 | spin_unlock_bh(&(SLAVE_AD_INFO(port->slave)->state_machine_lock)); |
254 | } | 254 | } |
255 | 255 | ||
256 | /** | 256 | /** |
@@ -350,7 +350,7 @@ static u8 __get_duplex(struct port *port) | |||
350 | static inline void __initialize_port_locks(struct slave *slave) | 350 | static inline void __initialize_port_locks(struct slave *slave) |
351 | { | 351 | { |
352 | /* make sure it isn't called twice */ | 352 | /* make sure it isn't called twice */ |
353 | spin_lock_init(&(SLAVE_AD_INFO(slave).state_machine_lock)); | 353 | spin_lock_init(&(SLAVE_AD_INFO(slave)->state_machine_lock)); |
354 | } | 354 | } |
355 | 355 | ||
356 | /* Conversions */ | 356 | /* Conversions */ |
@@ -688,8 +688,8 @@ static struct aggregator *__get_active_agg(struct aggregator *aggregator) | |||
688 | struct slave *slave; | 688 | struct slave *slave; |
689 | 689 | ||
690 | bond_for_each_slave_rcu(bond, slave, iter) | 690 | bond_for_each_slave_rcu(bond, slave, iter) |
691 | if (SLAVE_AD_INFO(slave).aggregator.is_active) | 691 | if (SLAVE_AD_INFO(slave)->aggregator.is_active) |
692 | return &(SLAVE_AD_INFO(slave).aggregator); | 692 | return &(SLAVE_AD_INFO(slave)->aggregator); |
693 | 693 | ||
694 | return NULL; | 694 | return NULL; |
695 | } | 695 | } |
@@ -1293,7 +1293,7 @@ static void ad_port_selection_logic(struct port *port) | |||
1293 | } | 1293 | } |
1294 | /* search on all aggregators for a suitable aggregator for this port */ | 1294 | /* search on all aggregators for a suitable aggregator for this port */ |
1295 | bond_for_each_slave(bond, slave, iter) { | 1295 | bond_for_each_slave(bond, slave, iter) { |
1296 | aggregator = &(SLAVE_AD_INFO(slave).aggregator); | 1296 | aggregator = &(SLAVE_AD_INFO(slave)->aggregator); |
1297 | 1297 | ||
1298 | /* keep a free aggregator for later use(if needed) */ | 1298 | /* keep a free aggregator for later use(if needed) */ |
1299 | if (!aggregator->lag_ports) { | 1299 | if (!aggregator->lag_ports) { |
@@ -1504,7 +1504,7 @@ static void ad_agg_selection_logic(struct aggregator *agg) | |||
1504 | best = (active && agg_device_up(active)) ? active : NULL; | 1504 | best = (active && agg_device_up(active)) ? active : NULL; |
1505 | 1505 | ||
1506 | bond_for_each_slave_rcu(bond, slave, iter) { | 1506 | bond_for_each_slave_rcu(bond, slave, iter) { |
1507 | agg = &(SLAVE_AD_INFO(slave).aggregator); | 1507 | agg = &(SLAVE_AD_INFO(slave)->aggregator); |
1508 | 1508 | ||
1509 | agg->is_active = 0; | 1509 | agg->is_active = 0; |
1510 | 1510 | ||
@@ -1549,7 +1549,7 @@ static void ad_agg_selection_logic(struct aggregator *agg) | |||
1549 | best->slave ? best->slave->dev->name : "NULL"); | 1549 | best->slave ? best->slave->dev->name : "NULL"); |
1550 | 1550 | ||
1551 | bond_for_each_slave_rcu(bond, slave, iter) { | 1551 | bond_for_each_slave_rcu(bond, slave, iter) { |
1552 | agg = &(SLAVE_AD_INFO(slave).aggregator); | 1552 | agg = &(SLAVE_AD_INFO(slave)->aggregator); |
1553 | 1553 | ||
1554 | pr_debug("Agg=%d; P=%d; a k=%d; p k=%d; Ind=%d; Act=%d\n", | 1554 | pr_debug("Agg=%d; P=%d; a k=%d; p k=%d; Ind=%d; Act=%d\n", |
1555 | agg->aggregator_identifier, agg->num_of_ports, | 1555 | agg->aggregator_identifier, agg->num_of_ports, |
@@ -1840,16 +1840,16 @@ void bond_3ad_bind_slave(struct slave *slave) | |||
1840 | struct aggregator *aggregator; | 1840 | struct aggregator *aggregator; |
1841 | 1841 | ||
1842 | /* check that the slave has not been initialized yet. */ | 1842 | /* check that the slave has not been initialized yet. */ |
1843 | if (SLAVE_AD_INFO(slave).port.slave != slave) { | 1843 | if (SLAVE_AD_INFO(slave)->port.slave != slave) { |
1844 | 1844 | ||
1845 | /* port initialization */ | 1845 | /* port initialization */ |
1846 | port = &(SLAVE_AD_INFO(slave).port); | 1846 | port = &(SLAVE_AD_INFO(slave)->port); |
1847 | 1847 | ||
1848 | ad_initialize_port(port, bond->params.lacp_fast); | 1848 | ad_initialize_port(port, bond->params.lacp_fast); |
1849 | 1849 | ||
1850 | __initialize_port_locks(slave); | 1850 | __initialize_port_locks(slave); |
1851 | port->slave = slave; | 1851 | port->slave = slave; |
1852 | port->actor_port_number = SLAVE_AD_INFO(slave).id; | 1852 | port->actor_port_number = SLAVE_AD_INFO(slave)->id; |
1853 | /* key is determined according to the link speed, duplex and user key(which | 1853 | /* key is determined according to the link speed, duplex and user key(which |
1854 | * is yet not supported) | 1854 | * is yet not supported) |
1855 | */ | 1855 | */ |
@@ -1874,7 +1874,7 @@ void bond_3ad_bind_slave(struct slave *slave) | |||
1874 | __disable_port(port); | 1874 | __disable_port(port); |
1875 | 1875 | ||
1876 | /* aggregator initialization */ | 1876 | /* aggregator initialization */ |
1877 | aggregator = &(SLAVE_AD_INFO(slave).aggregator); | 1877 | aggregator = &(SLAVE_AD_INFO(slave)->aggregator); |
1878 | 1878 | ||
1879 | ad_initialize_agg(aggregator); | 1879 | ad_initialize_agg(aggregator); |
1880 | 1880 | ||
@@ -1903,8 +1903,8 @@ void bond_3ad_unbind_slave(struct slave *slave) | |||
1903 | struct slave *slave_iter; | 1903 | struct slave *slave_iter; |
1904 | struct list_head *iter; | 1904 | struct list_head *iter; |
1905 | 1905 | ||
1906 | aggregator = &(SLAVE_AD_INFO(slave).aggregator); | 1906 | aggregator = &(SLAVE_AD_INFO(slave)->aggregator); |
1907 | port = &(SLAVE_AD_INFO(slave).port); | 1907 | port = &(SLAVE_AD_INFO(slave)->port); |
1908 | 1908 | ||
1909 | /* if slave is null, the whole port is not initialized */ | 1909 | /* if slave is null, the whole port is not initialized */ |
1910 | if (!port->slave) { | 1910 | if (!port->slave) { |
@@ -1932,7 +1932,7 @@ void bond_3ad_unbind_slave(struct slave *slave) | |||
1932 | (aggregator->lag_ports->next_port_in_aggregator)) { | 1932 | (aggregator->lag_ports->next_port_in_aggregator)) { |
1933 | /* find new aggregator for the related port(s) */ | 1933 | /* find new aggregator for the related port(s) */ |
1934 | bond_for_each_slave(bond, slave_iter, iter) { | 1934 | bond_for_each_slave(bond, slave_iter, iter) { |
1935 | new_aggregator = &(SLAVE_AD_INFO(slave_iter).aggregator); | 1935 | new_aggregator = &(SLAVE_AD_INFO(slave_iter)->aggregator); |
1936 | /* if the new aggregator is empty, or it is | 1936 | /* if the new aggregator is empty, or it is |
1937 | * connected to our port only | 1937 | * connected to our port only |
1938 | */ | 1938 | */ |
@@ -2010,7 +2010,7 @@ void bond_3ad_unbind_slave(struct slave *slave) | |||
2010 | 2010 | ||
2011 | /* find the aggregator that this port is connected to */ | 2011 | /* find the aggregator that this port is connected to */ |
2012 | bond_for_each_slave(bond, slave_iter, iter) { | 2012 | bond_for_each_slave(bond, slave_iter, iter) { |
2013 | temp_aggregator = &(SLAVE_AD_INFO(slave_iter).aggregator); | 2013 | temp_aggregator = &(SLAVE_AD_INFO(slave_iter)->aggregator); |
2014 | prev_port = NULL; | 2014 | prev_port = NULL; |
2015 | /* search the port in the aggregator's related ports */ | 2015 | /* search the port in the aggregator's related ports */ |
2016 | for (temp_port = temp_aggregator->lag_ports; temp_port; | 2016 | for (temp_port = temp_aggregator->lag_ports; temp_port; |
@@ -2076,7 +2076,7 @@ void bond_3ad_state_machine_handler(struct work_struct *work) | |||
2076 | if (BOND_AD_INFO(bond).agg_select_timer && | 2076 | if (BOND_AD_INFO(bond).agg_select_timer && |
2077 | !(--BOND_AD_INFO(bond).agg_select_timer)) { | 2077 | !(--BOND_AD_INFO(bond).agg_select_timer)) { |
2078 | slave = bond_first_slave_rcu(bond); | 2078 | slave = bond_first_slave_rcu(bond); |
2079 | port = slave ? &(SLAVE_AD_INFO(slave).port) : NULL; | 2079 | port = slave ? &(SLAVE_AD_INFO(slave)->port) : NULL; |
2080 | 2080 | ||
2081 | /* select the active aggregator for the bond */ | 2081 | /* select the active aggregator for the bond */ |
2082 | if (port) { | 2082 | if (port) { |
@@ -2094,7 +2094,7 @@ void bond_3ad_state_machine_handler(struct work_struct *work) | |||
2094 | 2094 | ||
2095 | /* for each port run the state machines */ | 2095 | /* for each port run the state machines */ |
2096 | bond_for_each_slave_rcu(bond, slave, iter) { | 2096 | bond_for_each_slave_rcu(bond, slave, iter) { |
2097 | port = &(SLAVE_AD_INFO(slave).port); | 2097 | port = &(SLAVE_AD_INFO(slave)->port); |
2098 | if (!port->slave) { | 2098 | if (!port->slave) { |
2099 | pr_warn_ratelimited("%s: Warning: Found an uninitialized port\n", | 2099 | pr_warn_ratelimited("%s: Warning: Found an uninitialized port\n", |
2100 | bond->dev->name); | 2100 | bond->dev->name); |
@@ -2155,7 +2155,7 @@ static int bond_3ad_rx_indication(struct lacpdu *lacpdu, struct slave *slave, | |||
2155 | 2155 | ||
2156 | if (length >= sizeof(struct lacpdu)) { | 2156 | if (length >= sizeof(struct lacpdu)) { |
2157 | 2157 | ||
2158 | port = &(SLAVE_AD_INFO(slave).port); | 2158 | port = &(SLAVE_AD_INFO(slave)->port); |
2159 | 2159 | ||
2160 | if (!port->slave) { | 2160 | if (!port->slave) { |
2161 | pr_warn_ratelimited("%s: Warning: port of slave %s is uninitialized\n", | 2161 | pr_warn_ratelimited("%s: Warning: port of slave %s is uninitialized\n", |
@@ -2212,7 +2212,7 @@ void bond_3ad_adapter_speed_changed(struct slave *slave) | |||
2212 | { | 2212 | { |
2213 | struct port *port; | 2213 | struct port *port; |
2214 | 2214 | ||
2215 | port = &(SLAVE_AD_INFO(slave).port); | 2215 | port = &(SLAVE_AD_INFO(slave)->port); |
2216 | 2216 | ||
2217 | /* if slave is null, the whole port is not initialized */ | 2217 | /* if slave is null, the whole port is not initialized */ |
2218 | if (!port->slave) { | 2218 | if (!port->slave) { |
@@ -2245,7 +2245,7 @@ void bond_3ad_adapter_duplex_changed(struct slave *slave) | |||
2245 | { | 2245 | { |
2246 | struct port *port; | 2246 | struct port *port; |
2247 | 2247 | ||
2248 | port = &(SLAVE_AD_INFO(slave).port); | 2248 | port = &(SLAVE_AD_INFO(slave)->port); |
2249 | 2249 | ||
2250 | /* if slave is null, the whole port is not initialized */ | 2250 | /* if slave is null, the whole port is not initialized */ |
2251 | if (!port->slave) { | 2251 | if (!port->slave) { |
@@ -2279,7 +2279,7 @@ void bond_3ad_handle_link_change(struct slave *slave, char link) | |||
2279 | { | 2279 | { |
2280 | struct port *port; | 2280 | struct port *port; |
2281 | 2281 | ||
2282 | port = &(SLAVE_AD_INFO(slave).port); | 2282 | port = &(SLAVE_AD_INFO(slave)->port); |
2283 | 2283 | ||
2284 | /* if slave is null, the whole port is not initialized */ | 2284 | /* if slave is null, the whole port is not initialized */ |
2285 | if (!port->slave) { | 2285 | if (!port->slave) { |
@@ -2347,7 +2347,7 @@ int bond_3ad_set_carrier(struct bonding *bond) | |||
2347 | ret = 0; | 2347 | ret = 0; |
2348 | goto out; | 2348 | goto out; |
2349 | } | 2349 | } |
2350 | active = __get_active_agg(&(SLAVE_AD_INFO(first_slave).aggregator)); | 2350 | active = __get_active_agg(&(SLAVE_AD_INFO(first_slave)->aggregator)); |
2351 | if (active) { | 2351 | if (active) { |
2352 | /* are enough slaves available to consider link up? */ | 2352 | /* are enough slaves available to consider link up? */ |
2353 | if (active->num_of_ports < bond->params.min_links) { | 2353 | if (active->num_of_ports < bond->params.min_links) { |
@@ -2384,7 +2384,7 @@ int __bond_3ad_get_active_agg_info(struct bonding *bond, | |||
2384 | struct port *port; | 2384 | struct port *port; |
2385 | 2385 | ||
2386 | bond_for_each_slave_rcu(bond, slave, iter) { | 2386 | bond_for_each_slave_rcu(bond, slave, iter) { |
2387 | port = &(SLAVE_AD_INFO(slave).port); | 2387 | port = &(SLAVE_AD_INFO(slave)->port); |
2388 | if (port->aggregator && port->aggregator->is_active) { | 2388 | if (port->aggregator && port->aggregator->is_active) { |
2389 | aggregator = port->aggregator; | 2389 | aggregator = port->aggregator; |
2390 | break; | 2390 | break; |
@@ -2444,7 +2444,7 @@ int bond_3ad_xmit_xor(struct sk_buff *skb, struct net_device *dev) | |||
2444 | first_ok_slave = NULL; | 2444 | first_ok_slave = NULL; |
2445 | 2445 | ||
2446 | bond_for_each_slave_rcu(bond, slave, iter) { | 2446 | bond_for_each_slave_rcu(bond, slave, iter) { |
2447 | agg = SLAVE_AD_INFO(slave).port.aggregator; | 2447 | agg = SLAVE_AD_INFO(slave)->port.aggregator; |
2448 | if (!agg || agg->aggregator_identifier != agg_id) | 2448 | if (!agg || agg->aggregator_identifier != agg_id) |
2449 | continue; | 2449 | continue; |
2450 | 2450 | ||
@@ -2522,7 +2522,7 @@ void bond_3ad_update_lacp_rate(struct bonding *bond) | |||
2522 | 2522 | ||
2523 | lacp_fast = bond->params.lacp_fast; | 2523 | lacp_fast = bond->params.lacp_fast; |
2524 | bond_for_each_slave(bond, slave, iter) { | 2524 | bond_for_each_slave(bond, slave, iter) { |
2525 | port = &(SLAVE_AD_INFO(slave).port); | 2525 | port = &(SLAVE_AD_INFO(slave)->port); |
2526 | __get_state_machine_lock(port); | 2526 | __get_state_machine_lock(port); |
2527 | if (lacp_fast) | 2527 | if (lacp_fast) |
2528 | port->actor_oper_port_state |= AD_STATE_LACP_TIMEOUT; | 2528 | port->actor_oper_port_state |= AD_STATE_LACP_TIMEOUT; |