diff options
author | Stephen Hemminger <shemminger@linux-foundation.org> | 2007-03-25 22:54:23 -0400 |
---|---|---|
committer | David S. Miller <davem@sunset.davemloft.net> | 2007-04-26 01:23:33 -0400 |
commit | 3927f2e8f9afa3424bb51ca81f7abac01ffd0005 (patch) | |
tree | da9e335169572e6c743c084edce6a802f9e667ee /net | |
parent | 9d729f72dca9406025bcfa9c1f660d71d9ef0ff5 (diff) |
[NET]: div64_64 consolidate (rev3)
Here is the current version of the 64 bit divide common code.
Signed-off-by: Stephen Hemminger <shemminger@linux-foundation.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net')
-rw-r--r-- | net/ipv4/tcp_cubic.c | 23 | ||||
-rw-r--r-- | net/ipv4/tcp_yeah.c | 21 | ||||
-rw-r--r-- | net/ipv4/tcp_yeah.h | 1 | ||||
-rw-r--r-- | net/netfilter/xt_connbytes.c | 16 |
4 files changed, 1 insertions, 60 deletions
diff --git a/net/ipv4/tcp_cubic.c b/net/ipv4/tcp_cubic.c index 9a582fb4ef9f..6f08adbda54e 100644 --- a/net/ipv4/tcp_cubic.c +++ b/net/ipv4/tcp_cubic.c | |||
@@ -51,8 +51,6 @@ MODULE_PARM_DESC(bic_scale, "scale (scaled by 1024) value for bic function (bic_ | |||
51 | module_param(tcp_friendliness, int, 0644); | 51 | module_param(tcp_friendliness, int, 0644); |
52 | MODULE_PARM_DESC(tcp_friendliness, "turn on/off tcp friendliness"); | 52 | MODULE_PARM_DESC(tcp_friendliness, "turn on/off tcp friendliness"); |
53 | 53 | ||
54 | #include <asm/div64.h> | ||
55 | |||
56 | /* BIC TCP Parameters */ | 54 | /* BIC TCP Parameters */ |
57 | struct bictcp { | 55 | struct bictcp { |
58 | u32 cnt; /* increase cwnd by 1 after ACKs */ | 56 | u32 cnt; /* increase cwnd by 1 after ACKs */ |
@@ -93,27 +91,6 @@ static void bictcp_init(struct sock *sk) | |||
93 | tcp_sk(sk)->snd_ssthresh = initial_ssthresh; | 91 | tcp_sk(sk)->snd_ssthresh = initial_ssthresh; |
94 | } | 92 | } |
95 | 93 | ||
96 | /* 64bit divisor, dividend and result. dynamic precision */ | ||
97 | static inline u_int64_t div64_64(u_int64_t dividend, u_int64_t divisor) | ||
98 | { | ||
99 | u_int32_t d = divisor; | ||
100 | |||
101 | if (divisor > 0xffffffffULL) { | ||
102 | unsigned int shift = fls(divisor >> 32); | ||
103 | |||
104 | d = divisor >> shift; | ||
105 | dividend >>= shift; | ||
106 | } | ||
107 | |||
108 | /* avoid 64 bit division if possible */ | ||
109 | if (dividend >> 32) | ||
110 | do_div(dividend, d); | ||
111 | else | ||
112 | dividend = (uint32_t) dividend / d; | ||
113 | |||
114 | return dividend; | ||
115 | } | ||
116 | |||
117 | /* | 94 | /* |
118 | * calculate the cubic root of x using Newton-Raphson | 95 | * calculate the cubic root of x using Newton-Raphson |
119 | */ | 96 | */ |
diff --git a/net/ipv4/tcp_yeah.c b/net/ipv4/tcp_yeah.c index 815e020e98fe..18355a2608e1 100644 --- a/net/ipv4/tcp_yeah.c +++ b/net/ipv4/tcp_yeah.c | |||
@@ -73,27 +73,6 @@ static void tcp_yeah_pkts_acked(struct sock *sk, u32 pkts_acked) | |||
73 | yeah->pkts_acked = pkts_acked; | 73 | yeah->pkts_acked = pkts_acked; |
74 | } | 74 | } |
75 | 75 | ||
76 | /* 64bit divisor, dividend and result. dynamic precision */ | ||
77 | static inline u64 div64_64(u64 dividend, u64 divisor) | ||
78 | { | ||
79 | u32 d = divisor; | ||
80 | |||
81 | if (divisor > 0xffffffffULL) { | ||
82 | unsigned int shift = fls(divisor >> 32); | ||
83 | |||
84 | d = divisor >> shift; | ||
85 | dividend >>= shift; | ||
86 | } | ||
87 | |||
88 | /* avoid 64 bit division if possible */ | ||
89 | if (dividend >> 32) | ||
90 | do_div(dividend, d); | ||
91 | else | ||
92 | dividend = (u32) dividend / d; | ||
93 | |||
94 | return dividend; | ||
95 | } | ||
96 | |||
97 | static void tcp_yeah_cong_avoid(struct sock *sk, u32 ack, | 76 | static void tcp_yeah_cong_avoid(struct sock *sk, u32 ack, |
98 | u32 seq_rtt, u32 in_flight, int flag) | 77 | u32 seq_rtt, u32 in_flight, int flag) |
99 | { | 78 | { |
diff --git a/net/ipv4/tcp_yeah.h b/net/ipv4/tcp_yeah.h index b3255dba4e2d..a62d82038fd0 100644 --- a/net/ipv4/tcp_yeah.h +++ b/net/ipv4/tcp_yeah.h | |||
@@ -2,6 +2,7 @@ | |||
2 | #include <linux/module.h> | 2 | #include <linux/module.h> |
3 | #include <linux/skbuff.h> | 3 | #include <linux/skbuff.h> |
4 | #include <linux/inet_diag.h> | 4 | #include <linux/inet_diag.h> |
5 | #include <asm/div64.h> | ||
5 | 6 | ||
6 | #include <net/tcp.h> | 7 | #include <net/tcp.h> |
7 | 8 | ||
diff --git a/net/netfilter/xt_connbytes.c b/net/netfilter/xt_connbytes.c index 5e32dfa2668b..302043bc41b2 100644 --- a/net/netfilter/xt_connbytes.c +++ b/net/netfilter/xt_connbytes.c | |||
@@ -24,22 +24,6 @@ MODULE_AUTHOR("Harald Welte <laforge@netfilter.org>"); | |||
24 | MODULE_DESCRIPTION("iptables match for matching number of pkts/bytes per connection"); | 24 | MODULE_DESCRIPTION("iptables match for matching number of pkts/bytes per connection"); |
25 | MODULE_ALIAS("ipt_connbytes"); | 25 | MODULE_ALIAS("ipt_connbytes"); |
26 | 26 | ||
27 | /* 64bit divisor, dividend and result. dynamic precision */ | ||
28 | static u_int64_t div64_64(u_int64_t dividend, u_int64_t divisor) | ||
29 | { | ||
30 | u_int32_t d = divisor; | ||
31 | |||
32 | if (divisor > 0xffffffffULL) { | ||
33 | unsigned int shift = fls(divisor >> 32); | ||
34 | |||
35 | d = divisor >> shift; | ||
36 | dividend >>= shift; | ||
37 | } | ||
38 | |||
39 | do_div(dividend, d); | ||
40 | return dividend; | ||
41 | } | ||
42 | |||
43 | static int | 27 | static int |
44 | match(const struct sk_buff *skb, | 28 | match(const struct sk_buff *skb, |
45 | const struct net_device *in, | 29 | const struct net_device *in, |