diff options
author | Gerrit Renker <gerrit@erg.abdn.ac.uk> | 2007-12-12 09:24:49 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2008-01-28 17:57:15 -0500 |
commit | df8f83fdd6369e1ba85f089fd6fe26bb2ddcb36f (patch) | |
tree | 8ddb2e0b70d5ed99837919ada6664e70c876f119 /net | |
parent | 2aaef4e47fef8a6c0bc7fc5d9d3eea4af290e04c (diff) |
[TFRC]: Put RX/TX initialisation into tfrc.c
This separates RX/TX initialisation and puts all packet history / loss intervals
initialisation into tfrc.c.
The organisation is uniform: slab declaration -> {rx,tx}_init() -> {rx,tx}_exit()
Signed-off-by: Gerrit Renker <gerrit@erg.abdn.ac.uk>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net')
-rw-r--r-- | net/dccp/ccids/lib/packet_history.c | 68 | ||||
-rw-r--r-- | net/dccp/ccids/lib/tfrc.c | 31 |
2 files changed, 55 insertions, 44 deletions
diff --git a/net/dccp/ccids/lib/packet_history.c b/net/dccp/ccids/lib/packet_history.c index af44082f56ea..727b17d3bd0e 100644 --- a/net/dccp/ccids/lib/packet_history.c +++ b/net/dccp/ccids/lib/packet_history.c | |||
@@ -57,6 +57,22 @@ struct tfrc_tx_hist_entry { | |||
57 | */ | 57 | */ |
58 | static struct kmem_cache *tfrc_tx_hist_slab; | 58 | static struct kmem_cache *tfrc_tx_hist_slab; |
59 | 59 | ||
60 | int __init tfrc_tx_packet_history_init(void) | ||
61 | { | ||
62 | tfrc_tx_hist_slab = kmem_cache_create("tfrc_tx_hist", | ||
63 | sizeof(struct tfrc_tx_hist_entry), | ||
64 | 0, SLAB_HWCACHE_ALIGN, NULL); | ||
65 | return tfrc_tx_hist_slab == NULL ? -ENOBUFS : 0; | ||
66 | } | ||
67 | |||
68 | void tfrc_tx_packet_history_exit(void) | ||
69 | { | ||
70 | if (tfrc_tx_hist_slab != NULL) { | ||
71 | kmem_cache_destroy(tfrc_tx_hist_slab); | ||
72 | tfrc_tx_hist_slab = NULL; | ||
73 | } | ||
74 | } | ||
75 | |||
60 | static struct tfrc_tx_hist_entry * | 76 | static struct tfrc_tx_hist_entry * |
61 | tfrc_tx_hist_find_entry(struct tfrc_tx_hist_entry *head, u64 seqno) | 77 | tfrc_tx_hist_find_entry(struct tfrc_tx_hist_entry *head, u64 seqno) |
62 | { | 78 | { |
@@ -119,6 +135,22 @@ EXPORT_SYMBOL_GPL(tfrc_tx_hist_rtt); | |||
119 | */ | 135 | */ |
120 | static struct kmem_cache *tfrc_rx_hist_slab; | 136 | static struct kmem_cache *tfrc_rx_hist_slab; |
121 | 137 | ||
138 | int __init tfrc_rx_packet_history_init(void) | ||
139 | { | ||
140 | tfrc_rx_hist_slab = kmem_cache_create("tfrc_rxh_cache", | ||
141 | sizeof(struct tfrc_rx_hist_entry), | ||
142 | 0, SLAB_HWCACHE_ALIGN, NULL); | ||
143 | return tfrc_rx_hist_slab == NULL ? -ENOBUFS : 0; | ||
144 | } | ||
145 | |||
146 | void tfrc_rx_packet_history_exit(void) | ||
147 | { | ||
148 | if (tfrc_rx_hist_slab != NULL) { | ||
149 | kmem_cache_destroy(tfrc_rx_hist_slab); | ||
150 | tfrc_rx_hist_slab = NULL; | ||
151 | } | ||
152 | } | ||
153 | |||
122 | /** | 154 | /** |
123 | * tfrc_rx_hist_index - index to reach n-th entry after loss_start | 155 | * tfrc_rx_hist_index - index to reach n-th entry after loss_start |
124 | */ | 156 | */ |
@@ -316,39 +348,3 @@ keep_ref_for_next_time: | |||
316 | return sample; | 348 | return sample; |
317 | } | 349 | } |
318 | EXPORT_SYMBOL_GPL(tfrc_rx_hist_sample_rtt); | 350 | EXPORT_SYMBOL_GPL(tfrc_rx_hist_sample_rtt); |
319 | |||
320 | __init int packet_history_init(void) | ||
321 | { | ||
322 | tfrc_tx_hist_slab = kmem_cache_create("tfrc_tx_hist", | ||
323 | sizeof(struct tfrc_tx_hist_entry), 0, | ||
324 | SLAB_HWCACHE_ALIGN, NULL); | ||
325 | if (tfrc_tx_hist_slab == NULL) | ||
326 | goto out_err; | ||
327 | |||
328 | tfrc_rx_hist_slab = kmem_cache_create("tfrc_rx_hist", | ||
329 | sizeof(struct tfrc_rx_hist_entry), 0, | ||
330 | SLAB_HWCACHE_ALIGN, NULL); | ||
331 | if (tfrc_rx_hist_slab == NULL) | ||
332 | goto out_free_tx; | ||
333 | |||
334 | return 0; | ||
335 | |||
336 | out_free_tx: | ||
337 | kmem_cache_destroy(tfrc_tx_hist_slab); | ||
338 | tfrc_tx_hist_slab = NULL; | ||
339 | out_err: | ||
340 | return -ENOBUFS; | ||
341 | } | ||
342 | |||
343 | void packet_history_exit(void) | ||
344 | { | ||
345 | if (tfrc_tx_hist_slab != NULL) { | ||
346 | kmem_cache_destroy(tfrc_tx_hist_slab); | ||
347 | tfrc_tx_hist_slab = NULL; | ||
348 | } | ||
349 | |||
350 | if (tfrc_rx_hist_slab != NULL) { | ||
351 | kmem_cache_destroy(tfrc_rx_hist_slab); | ||
352 | tfrc_rx_hist_slab = NULL; | ||
353 | } | ||
354 | } | ||
diff --git a/net/dccp/ccids/lib/tfrc.c b/net/dccp/ccids/lib/tfrc.c index 3a7a1838a64b..20763fa75d44 100644 --- a/net/dccp/ccids/lib/tfrc.c +++ b/net/dccp/ccids/lib/tfrc.c | |||
@@ -14,27 +14,42 @@ 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 | |||
17 | extern int dccp_li_init(void); | 22 | extern int dccp_li_init(void); |
18 | extern void dccp_li_exit(void); | 23 | extern void dccp_li_exit(void); |
19 | extern int packet_history_init(void); | ||
20 | extern void packet_history_exit(void); | ||
21 | 24 | ||
22 | static int __init tfrc_module_init(void) | 25 | static int __init tfrc_module_init(void) |
23 | { | 26 | { |
24 | int rc = dccp_li_init(); | 27 | int rc = dccp_li_init(); |
25 | 28 | ||
26 | if (rc == 0) { | 29 | if (rc) |
27 | rc = packet_history_init(); | 30 | goto out; |
28 | if (rc != 0) | 31 | |
29 | dccp_li_exit(); | 32 | rc = tfrc_tx_packet_history_init(); |
30 | } | 33 | if (rc) |
34 | goto out_free_loss_intervals; | ||
31 | 35 | ||
36 | rc = tfrc_rx_packet_history_init(); | ||
37 | if (rc) | ||
38 | goto out_free_tx_history; | ||
39 | return 0; | ||
40 | |||
41 | out_free_tx_history: | ||
42 | tfrc_tx_packet_history_exit(); | ||
43 | out_free_loss_intervals: | ||
44 | dccp_li_exit(); | ||
45 | out: | ||
32 | return rc; | 46 | return rc; |
33 | } | 47 | } |
34 | 48 | ||
35 | static void __exit tfrc_module_exit(void) | 49 | static void __exit tfrc_module_exit(void) |
36 | { | 50 | { |
37 | packet_history_exit(); | 51 | tfrc_rx_packet_history_exit(); |
52 | tfrc_tx_packet_history_exit(); | ||
38 | dccp_li_exit(); | 53 | dccp_li_exit(); |
39 | } | 54 | } |
40 | 55 | ||