Commit df5432ba authored by James Morris's avatar James Morris Committed by David S. Miller

[NET]: Cosmetic cleanups of jhash code.

- Consistent naming (i.e. jhash_xxx)
- Reduces the 2&1 word variants to call jhash_3words()
- Replaces __inline__ with inline.
parent 43ee0061
......@@ -41,7 +41,7 @@
* of bytes. No alignment or length assumptions are made about
* the input key.
*/
static __inline__ u32 jenkins_hash(void *key, u32 length, u32 initval)
static inline u32 jhash(void *key, u32 length, u32 initval)
{
u32 a, b, c, len;
u8 *k = key;
......@@ -84,7 +84,7 @@ static __inline__ u32 jenkins_hash(void *key, u32 length, u32 initval)
/* A special optimized version that handles 1 or more of u32s.
* The length parameter here is the number of u32s in the key.
*/
static __inline__ u32 hash2(u32 *k, u32 length, u32 initval)
static inline u32 jhash2(u32 *k, u32 length, u32 initval)
{
u32 a, b, c, len;
......@@ -119,8 +119,7 @@ static __inline__ u32 hash2(u32 *k, u32 length, u32 initval)
* NOTE: In partilar the "c += length; __jhash_mix(a,b,c);" normally
* done at the end is not done here.
*/
static __inline__ u32 jenkins_hash_3words(u32 a, u32 b, u32 c,
u32 initval)
static inline u32 jhash_3words(u32 a, u32 b, u32 c, u32 initval)
{
a += JHASH_GOLDEN_RATIO;
b += JHASH_GOLDEN_RATIO;
......@@ -131,31 +130,14 @@ static __inline__ u32 jenkins_hash_3words(u32 a, u32 b, u32 c,
return c;
}
static __inline__ u32 jenkins_hash_2words(u32 a, u32 b, u32 initval)
static inline u32 jhash_2words(u32 a, u32 b, u32 initval)
{
u32 c = 0;
a += JHASH_GOLDEN_RATIO;
b += JHASH_GOLDEN_RATIO;
c += initval;
__jhash_mix(a, b, c);
return c;
return jhash_3words(a, b, 0, initval);
}
static __inline__ u32 jenkins_hash_1word(u32 a, u32 initval)
static inline u32 jhash_1word(u32 a, u32 initval)
{
u32 b = 0;
u32 c = 0;
a += JHASH_GOLDEN_RATIO;
b += JHASH_GOLDEN_RATIO;
c += initval;
__jhash_mix(a, b, c);
return c;
return jhash_3words(a, 0, 0, initval);
}
#endif /* _LINUX_JHASH_H */
......@@ -115,12 +115,10 @@ hash_conntrack(const struct ip_conntrack_tuple *tuple)
#if 0
dump_tuple(tuple);
#endif
return (jenkins_hash_3words(tuple->src.ip,
(tuple->dst.ip ^ tuple->dst.protonum),
(tuple->src.u.all |
(tuple->dst.u.all << 16)),
ip_conntrack_hash_rnd)
% ip_conntrack_htable_size);
return (jhash_3words(tuple->src.ip,
(tuple->dst.ip ^ tuple->dst.protonum),
(tuple->src.u.all | (tuple->dst.u.all << 16)),
ip_conntrack_hash_rnd) % ip_conntrack_htable_size);
}
int
......
......@@ -207,7 +207,7 @@ static int rt_intern_hash(unsigned hash, struct rtable *rth,
static unsigned int rt_hash_code(u32 daddr, u32 saddr, u8 tos)
{
return (jenkins_hash_3words(daddr, saddr, (u32) tos, rt_hash_rnd)
return (jhash_3words(daddr, saddr, (u32) tos, rt_hash_rnd)
& rt_hash_mask);
}
......
......@@ -886,8 +886,7 @@ static __inline__ int tcp_v4_iif(struct sk_buff *skb)
static __inline__ u32 tcp_v4_synq_hash(u32 raddr, u16 rport, u32 rnd)
{
return (jenkins_hash_2words(raddr, (u32) rport, rnd)
& (TCP_SYNQ_HSIZE - 1));
return (jhash_2words(raddr, (u32) rport, rnd) & (TCP_SYNQ_HSIZE - 1));
}
static struct open_request *tcp_v4_search_req(struct tcp_opt *tp,
......
......@@ -390,10 +390,9 @@ __inline__ struct sock *tcp_v6_lookup(struct in6_addr *saddr, u16 sport,
static u32 tcp_v6_synq_hash(struct in6_addr *raddr, u16 rport, u32 rnd)
{
return (jenkins_hash_3words(raddr->s6_addr32[0] ^ raddr->s6_addr32[1],
raddr->s6_addr32[2] ^ raddr->s6_addr32[3],
(u32) rport, rnd)
& (TCP_SYNQ_HSIZE - 1));
return (jhash_3words(raddr->s6_addr32[0] ^ raddr->s6_addr32[1],
raddr->s6_addr32[2] ^ raddr->s6_addr32[3],
(u32) rport, rnd) & (TCP_SYNQ_HSIZE - 1));
}
static struct open_request *tcp_v6_search_req(struct tcp_opt *tp,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment