aboutsummaryrefslogtreecommitdiffstats
path: root/net/dccp/ccids
diff options
context:
space:
mode:
Diffstat (limited to 'net/dccp/ccids')
-rw-r--r--net/dccp/ccids/lib/packet_history.c68
-rw-r--r--net/dccp/ccids/lib/tfrc.c31
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 */
58static struct kmem_cache *tfrc_tx_hist_slab; 58static struct kmem_cache *tfrc_tx_hist_slab;
59 59
60int __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
68void 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
60static struct tfrc_tx_hist_entry * 76static 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 */
120static struct kmem_cache *tfrc_rx_hist_slab; 136static struct kmem_cache *tfrc_rx_hist_slab;
121 137
138int __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
146void 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}
318EXPORT_SYMBOL_GPL(tfrc_rx_hist_sample_rtt); 350EXPORT_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
336out_free_tx:
337 kmem_cache_destroy(tfrc_tx_hist_slab);
338 tfrc_tx_hist_slab = NULL;
339out_err:
340 return -ENOBUFS;
341}
342
343void 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);
14MODULE_PARM_DESC(tfrc_debug, "Enable debug messages"); 14MODULE_PARM_DESC(tfrc_debug, "Enable debug messages");
15#endif 15#endif
16 16
17extern int tfrc_tx_packet_history_init(void);
18extern void tfrc_tx_packet_history_exit(void);
19extern int tfrc_rx_packet_history_init(void);
20extern void tfrc_rx_packet_history_exit(void);
21
17extern int dccp_li_init(void); 22extern int dccp_li_init(void);
18extern void dccp_li_exit(void); 23extern void dccp_li_exit(void);
19extern int packet_history_init(void);
20extern void packet_history_exit(void);
21 24
22static int __init tfrc_module_init(void) 25static 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
41out_free_tx_history:
42 tfrc_tx_packet_history_exit();
43out_free_loss_intervals:
44 dccp_li_exit();
45out:
32 return rc; 46 return rc;
33} 47}
34 48
35static void __exit tfrc_module_exit(void) 49static 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