aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorMahesh Bandewar <maheshb@google.com>2014-04-22 19:30:15 -0400
committerDavid S. Miller <davem@davemloft.net>2014-04-24 13:04:34 -0400
commitee62e868139b96f73f3d01268ca1c39f7c6f4cd7 (patch)
tree829f2b09fe54476555db2eb400520210e5783a00 /drivers
parent7e65eac8e36f3f4e2553e83249e3d9bdf055456d (diff)
bonding: Changed hashing function to just provide hash
Modified the hash function to return just hash separating from the modulo operation that can be performed by the caller. This is to make way for the tlb mode to use the same hashing policies that are used in the 802.3ad and Xor mode. Change-Id: I276609e87e0ca213c4d1b17b79c5e0b0f3d0dd6f Signed-off-by: Mahesh Bandewar <maheshb@google.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/net/bonding/bond_3ad.c2
-rw-r--r--drivers/net/bonding/bond_main.c10
-rw-r--r--drivers/net/bonding/bonding.h2
3 files changed, 6 insertions, 8 deletions
diff --git a/drivers/net/bonding/bond_3ad.c b/drivers/net/bonding/bond_3ad.c
index b667a51ed215..9a0d61e0c188 100644
--- a/drivers/net/bonding/bond_3ad.c
+++ b/drivers/net/bonding/bond_3ad.c
@@ -2440,7 +2440,7 @@ int bond_3ad_xmit_xor(struct sk_buff *skb, struct net_device *dev)
2440 goto err_free; 2440 goto err_free;
2441 } 2441 }
2442 2442
2443 slave_agg_no = bond_xmit_hash(bond, skb, slaves_in_agg); 2443 slave_agg_no = bond_xmit_hash(bond, skb) % slaves_in_agg;
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) {
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index 69aff72c8957..c7046350c4b5 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -3015,20 +3015,18 @@ static bool bond_flow_dissect(struct bonding *bond, struct sk_buff *skb,
3015 * bond_xmit_hash - generate a hash value based on the xmit policy 3015 * bond_xmit_hash - generate a hash value based on the xmit policy
3016 * @bond: bonding device 3016 * @bond: bonding device
3017 * @skb: buffer to use for headers 3017 * @skb: buffer to use for headers
3018 * @count: modulo value
3019 * 3018 *
3020 * This function will extract the necessary headers from the skb buffer and use 3019 * This function will extract the necessary headers from the skb buffer and use
3021 * them to generate a hash based on the xmit_policy set in the bonding device 3020 * them to generate a hash based on the xmit_policy set in the bonding device
3022 * which will be reduced modulo count before returning.
3023 */ 3021 */
3024int bond_xmit_hash(struct bonding *bond, struct sk_buff *skb, int count) 3022u32 bond_xmit_hash(struct bonding *bond, struct sk_buff *skb)
3025{ 3023{
3026 struct flow_keys flow; 3024 struct flow_keys flow;
3027 u32 hash; 3025 u32 hash;
3028 3026
3029 if (bond->params.xmit_policy == BOND_XMIT_POLICY_LAYER2 || 3027 if (bond->params.xmit_policy == BOND_XMIT_POLICY_LAYER2 ||
3030 !bond_flow_dissect(bond, skb, &flow)) 3028 !bond_flow_dissect(bond, skb, &flow))
3031 return bond_eth_hash(skb) % count; 3029 return bond_eth_hash(skb);
3032 3030
3033 if (bond->params.xmit_policy == BOND_XMIT_POLICY_LAYER23 || 3031 if (bond->params.xmit_policy == BOND_XMIT_POLICY_LAYER23 ||
3034 bond->params.xmit_policy == BOND_XMIT_POLICY_ENCAP23) 3032 bond->params.xmit_policy == BOND_XMIT_POLICY_ENCAP23)
@@ -3039,7 +3037,7 @@ int bond_xmit_hash(struct bonding *bond, struct sk_buff *skb, int count)
3039 hash ^= (hash >> 16); 3037 hash ^= (hash >> 16);
3040 hash ^= (hash >> 8); 3038 hash ^= (hash >> 8);
3041 3039
3042 return hash % count; 3040 return hash;
3043} 3041}
3044 3042
3045/*-------------------------- Device entry points ----------------------------*/ 3043/*-------------------------- Device entry points ----------------------------*/
@@ -3666,7 +3664,7 @@ static int bond_xmit_xor(struct sk_buff *skb, struct net_device *bond_dev)
3666{ 3664{
3667 struct bonding *bond = netdev_priv(bond_dev); 3665 struct bonding *bond = netdev_priv(bond_dev);
3668 3666
3669 bond_xmit_slave_id(bond, skb, bond_xmit_hash(bond, skb, bond->slave_cnt)); 3667 bond_xmit_slave_id(bond, skb, bond_xmit_hash(bond, skb) % bond->slave_cnt);
3670 3668
3671 return NETDEV_TX_OK; 3669 return NETDEV_TX_OK;
3672} 3670}
diff --git a/drivers/net/bonding/bonding.h b/drivers/net/bonding/bonding.h
index b8bdd0acc8f3..c0948ca26389 100644
--- a/drivers/net/bonding/bonding.h
+++ b/drivers/net/bonding/bonding.h
@@ -499,7 +499,7 @@ int bond_sysfs_slave_add(struct slave *slave);
499void bond_sysfs_slave_del(struct slave *slave); 499void bond_sysfs_slave_del(struct slave *slave);
500int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev); 500int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev);
501int bond_release(struct net_device *bond_dev, struct net_device *slave_dev); 501int bond_release(struct net_device *bond_dev, struct net_device *slave_dev);
502int bond_xmit_hash(struct bonding *bond, struct sk_buff *skb, int count); 502u32 bond_xmit_hash(struct bonding *bond, struct sk_buff *skb);
503void bond_select_active_slave(struct bonding *bond); 503void bond_select_active_slave(struct bonding *bond);
504void bond_change_active_slave(struct bonding *bond, struct slave *new_active); 504void bond_change_active_slave(struct bonding *bond, struct slave *new_active);
505void bond_create_debugfs(void); 505void bond_create_debugfs(void);