aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/team
diff options
context:
space:
mode:
authorJiri Pirko <jpirko@redhat.com>2012-06-19 01:54:06 -0400
committerDavid S. Miller <davem@davemloft.net>2012-06-19 18:00:23 -0400
commit596e2024c42159fedf71b3d17fba78eed9b5bf10 (patch)
tree081d68ebece7f30600a8119d87ed8448a1968856 /drivers/net/team
parent5149ee58385bdfef260fb07a89a8ff0913be6b25 (diff)
team: lb: push hash counting into separate function
Also squash hash into one byte Signed-off-by: Jiri Pirko <jpirko@redhat.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/team')
-rw-r--r--drivers/net/team/team_mode_loadbalance.c23
1 files changed, 16 insertions, 7 deletions
diff --git a/drivers/net/team/team_mode_loadbalance.c b/drivers/net/team/team_mode_loadbalance.c
index 6452428a1d6c..a475b1304f9a 100644
--- a/drivers/net/team/team_mode_loadbalance.c
+++ b/drivers/net/team/team_mode_loadbalance.c
@@ -27,18 +27,27 @@ static struct lb_priv *lb_priv(struct team *team)
27 return (struct lb_priv *) &team->mode_priv; 27 return (struct lb_priv *) &team->mode_priv;
28} 28}
29 29
30static bool lb_transmit(struct team *team, struct sk_buff *skb) 30static unsigned char lb_get_skb_hash(struct lb_priv *lb_priv,
31 struct sk_buff *skb)
31{ 32{
32 struct sk_filter *fp; 33 struct sk_filter *fp;
34 uint32_t lhash;
35 unsigned char *c;
36
37 fp = rcu_dereference(lb_priv->fp);
38 if (unlikely(!fp))
39 return 0;
40 lhash = SK_RUN_FILTER(fp, skb);
41 c = (char *) &lhash;
42 return c[0] ^ c[1] ^ c[2] ^ c[3];
43}
44
45static bool lb_transmit(struct team *team, struct sk_buff *skb)
46{
33 struct team_port *port; 47 struct team_port *port;
34 unsigned int hash;
35 int port_index; 48 int port_index;
36 49
37 fp = rcu_dereference(lb_priv(team)->fp); 50 port_index = lb_get_skb_hash(lb_priv(team), skb) % team->en_port_count;
38 if (unlikely(!fp))
39 goto drop;
40 hash = SK_RUN_FILTER(fp, skb);
41 port_index = hash % team->en_port_count;
42 port = team_get_port_by_index_rcu(team, port_index); 51 port = team_get_port_by_index_rcu(team, port_index);
43 if (unlikely(!port)) 52 if (unlikely(!port))
44 goto drop; 53 goto drop;