diff options
Diffstat (limited to 'net/dccp/ccids/lib')
-rw-r--r-- | net/dccp/ccids/lib/tfrc.c | 8 | ||||
-rw-r--r-- | net/dccp/ccids/lib/tfrc.h | 25 | ||||
-rw-r--r-- | net/dccp/ccids/lib/tfrc_equation.c | 8 |
3 files changed, 19 insertions, 22 deletions
diff --git a/net/dccp/ccids/lib/tfrc.c b/net/dccp/ccids/lib/tfrc.c index d1dfbb8de64c..97ecec0a8e76 100644 --- a/net/dccp/ccids/lib/tfrc.c +++ b/net/dccp/ccids/lib/tfrc.c | |||
@@ -14,14 +14,6 @@ module_param(tfrc_debug, bool, 0444); | |||
14 | MODULE_PARM_DESC(tfrc_debug, "Enable debug messages"); | 14 | MODULE_PARM_DESC(tfrc_debug, "Enable debug messages"); |
15 | #endif | 15 | #endif |
16 | 16 | ||
17 | extern int tfrc_tx_packet_history_init(void); | ||
18 | extern void tfrc_tx_packet_history_exit(void); | ||
19 | extern int tfrc_rx_packet_history_init(void); | ||
20 | extern void tfrc_rx_packet_history_exit(void); | ||
21 | |||
22 | extern int tfrc_li_init(void); | ||
23 | extern void tfrc_li_exit(void); | ||
24 | |||
25 | static int __init tfrc_module_init(void) | 17 | static int __init tfrc_module_init(void) |
26 | { | 18 | { |
27 | int rc = tfrc_li_init(); | 19 | int rc = tfrc_li_init(); |
diff --git a/net/dccp/ccids/lib/tfrc.h b/net/dccp/ccids/lib/tfrc.h index 1fb1187bbf1c..ed9857527acf 100644 --- a/net/dccp/ccids/lib/tfrc.h +++ b/net/dccp/ccids/lib/tfrc.h | |||
@@ -15,7 +15,7 @@ | |||
15 | * (at your option) any later version. | 15 | * (at your option) any later version. |
16 | */ | 16 | */ |
17 | #include <linux/types.h> | 17 | #include <linux/types.h> |
18 | #include <asm/div64.h> | 18 | #include <linux/math64.h> |
19 | #include "../../dccp.h" | 19 | #include "../../dccp.h" |
20 | /* internal includes that this module exports: */ | 20 | /* internal includes that this module exports: */ |
21 | #include "loss_interval.h" | 21 | #include "loss_interval.h" |
@@ -29,21 +29,19 @@ extern int tfrc_debug; | |||
29 | #endif | 29 | #endif |
30 | 30 | ||
31 | /* integer-arithmetic divisions of type (a * 1000000)/b */ | 31 | /* integer-arithmetic divisions of type (a * 1000000)/b */ |
32 | static inline u64 scaled_div(u64 a, u32 b) | 32 | static inline u64 scaled_div(u64 a, u64 b) |
33 | { | 33 | { |
34 | BUG_ON(b==0); | 34 | BUG_ON(b==0); |
35 | a *= 1000000; | 35 | return div64_u64(a * 1000000, b); |
36 | do_div(a, b); | ||
37 | return a; | ||
38 | } | 36 | } |
39 | 37 | ||
40 | static inline u32 scaled_div32(u64 a, u32 b) | 38 | static inline u32 scaled_div32(u64 a, u64 b) |
41 | { | 39 | { |
42 | u64 result = scaled_div(a, b); | 40 | u64 result = scaled_div(a, b); |
43 | 41 | ||
44 | if (result > UINT_MAX) { | 42 | if (result > UINT_MAX) { |
45 | DCCP_CRIT("Overflow: a(%llu)/b(%u) > ~0U", | 43 | DCCP_CRIT("Overflow: %llu/%llu > UINT_MAX", |
46 | (unsigned long long)a, b); | 44 | (unsigned long long)a, (unsigned long long)b); |
47 | return UINT_MAX; | 45 | return UINT_MAX; |
48 | } | 46 | } |
49 | return result; | 47 | return result; |
@@ -58,7 +56,14 @@ static inline u32 tfrc_ewma(const u32 avg, const u32 newval, const u8 weight) | |||
58 | return avg ? (weight * avg + (10 - weight) * newval) / 10 : newval; | 56 | return avg ? (weight * avg + (10 - weight) * newval) / 10 : newval; |
59 | } | 57 | } |
60 | 58 | ||
61 | extern u32 tfrc_calc_x(u16 s, u32 R, u32 p); | 59 | extern u32 tfrc_calc_x(u16 s, u32 R, u32 p); |
62 | extern u32 tfrc_calc_x_reverse_lookup(u32 fvalue); | 60 | extern u32 tfrc_calc_x_reverse_lookup(u32 fvalue); |
63 | 61 | ||
62 | extern int tfrc_tx_packet_history_init(void); | ||
63 | extern void tfrc_tx_packet_history_exit(void); | ||
64 | extern int tfrc_rx_packet_history_init(void); | ||
65 | extern void tfrc_rx_packet_history_exit(void); | ||
66 | |||
67 | extern int tfrc_li_init(void); | ||
68 | extern void tfrc_li_exit(void); | ||
64 | #endif /* _TFRC_H_ */ | 69 | #endif /* _TFRC_H_ */ |
diff --git a/net/dccp/ccids/lib/tfrc_equation.c b/net/dccp/ccids/lib/tfrc_equation.c index e4e64b76c10c..2f20a29cffe4 100644 --- a/net/dccp/ccids/lib/tfrc_equation.c +++ b/net/dccp/ccids/lib/tfrc_equation.c | |||
@@ -661,7 +661,7 @@ u32 tfrc_calc_x(u16 s, u32 R, u32 p) | |||
661 | 661 | ||
662 | EXPORT_SYMBOL_GPL(tfrc_calc_x); | 662 | EXPORT_SYMBOL_GPL(tfrc_calc_x); |
663 | 663 | ||
664 | /* | 664 | /** |
665 | * tfrc_calc_x_reverse_lookup - try to find p given f(p) | 665 | * tfrc_calc_x_reverse_lookup - try to find p given f(p) |
666 | * | 666 | * |
667 | * @fvalue: function value to match, scaled by 1000000 | 667 | * @fvalue: function value to match, scaled by 1000000 |
@@ -676,11 +676,11 @@ u32 tfrc_calc_x_reverse_lookup(u32 fvalue) | |||
676 | 676 | ||
677 | /* Error cases. */ | 677 | /* Error cases. */ |
678 | if (fvalue < tfrc_calc_x_lookup[0][1]) { | 678 | if (fvalue < tfrc_calc_x_lookup[0][1]) { |
679 | DCCP_WARN("fvalue %d smaller than resolution\n", fvalue); | 679 | DCCP_WARN("fvalue %u smaller than resolution\n", fvalue); |
680 | return tfrc_calc_x_lookup[0][1]; | 680 | return TFRC_SMALLEST_P; |
681 | } | 681 | } |
682 | if (fvalue > tfrc_calc_x_lookup[TFRC_CALC_X_ARRSIZE - 1][0]) { | 682 | if (fvalue > tfrc_calc_x_lookup[TFRC_CALC_X_ARRSIZE - 1][0]) { |
683 | DCCP_WARN("fvalue %d exceeds bounds!\n", fvalue); | 683 | DCCP_WARN("fvalue %u exceeds bounds!\n", fvalue); |
684 | return 1000000; | 684 | return 1000000; |
685 | } | 685 | } |
686 | 686 | ||