aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorGerrit Renker <gerrit@erg.abdn.ac.uk>2007-12-06 09:26:38 -0500
committerDavid S. Miller <davem@davemloft.net>2008-01-28 17:56:39 -0500
commitc40616c597bf02a2346cbf2f120283734b436245 (patch)
tree2fb6f82ed8fec01038f4607b489086a8f2a719f9 /net
parentf8b33fdfafea0f909712a55fbb3d83b89f70f3f5 (diff)
[TFRC]: Provide central source file and debug facility
This patch changes the tfrc_lib module in the following manner: (1) a dedicated tfrc source file to call the packet history & loss interval init/exit functions. (2) a dedicated tfrc_pr_debug macro with toggle switch `tfrc_debug'. Commiter note: renamed tfrc_module.c to tfrc.c, and made CONFIG_IP_DCCP_CCID3 select IP_DCCP_TFRC_LIB. Signed-off-by: Gerrit Renker <gerrit@erg.abdn.ac.uk> Signed-off-by: Ian McDonald <ian.mcdonald@jandi.co.nz> 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/Kconfig13
-rw-r--r--net/dccp/ccids/lib/Makefile2
-rw-r--r--net/dccp/ccids/lib/packet_history.c27
-rw-r--r--net/dccp/ccids/lib/packet_history.h3
-rw-r--r--net/dccp/ccids/lib/tfrc.c48
-rw-r--r--net/dccp/ccids/lib/tfrc.h17
6 files changed, 75 insertions, 35 deletions
diff --git a/net/dccp/ccids/Kconfig b/net/dccp/ccids/Kconfig
index 3d7d867a7c4e..12275943eab8 100644
--- a/net/dccp/ccids/Kconfig
+++ b/net/dccp/ccids/Kconfig
@@ -38,6 +38,7 @@ config IP_DCCP_CCID2_DEBUG
38config IP_DCCP_CCID3 38config IP_DCCP_CCID3
39 tristate "CCID3 (TCP-Friendly) (EXPERIMENTAL)" 39 tristate "CCID3 (TCP-Friendly) (EXPERIMENTAL)"
40 def_tristate IP_DCCP 40 def_tristate IP_DCCP
41 select IP_DCCP_TFRC_LIB
41 ---help--- 42 ---help---
42 CCID 3 denotes TCP-Friendly Rate Control (TFRC), an equation-based 43 CCID 3 denotes TCP-Friendly Rate Control (TFRC), an equation-based
43 rate-controlled congestion control mechanism. TFRC is designed to 44 rate-controlled congestion control mechanism. TFRC is designed to
@@ -63,10 +64,6 @@ config IP_DCCP_CCID3
63 64
64 If in doubt, say M. 65 If in doubt, say M.
65 66
66config IP_DCCP_TFRC_LIB
67 depends on IP_DCCP_CCID3
68 def_tristate IP_DCCP_CCID3
69
70config IP_DCCP_CCID3_DEBUG 67config IP_DCCP_CCID3_DEBUG
71 bool "CCID3 debugging messages" 68 bool "CCID3 debugging messages"
72 depends on IP_DCCP_CCID3 69 depends on IP_DCCP_CCID3
@@ -110,5 +107,13 @@ config IP_DCCP_CCID3_RTO
110 is serious network congestion: experimenting with larger values should 107 is serious network congestion: experimenting with larger values should
111 therefore not be performed on WANs. 108 therefore not be performed on WANs.
112 109
110config IP_DCCP_TFRC_LIB
111 tristate
112 default n
113
114config IP_DCCP_TFRC_DEBUG
115 bool
116 depends on IP_DCCP_TFRC_LIB
117 default y if IP_DCCP_CCID3_DEBUG
113 118
114endmenu 119endmenu
diff --git a/net/dccp/ccids/lib/Makefile b/net/dccp/ccids/lib/Makefile
index 5f940a6cbaca..68c93e3d89dc 100644
--- a/net/dccp/ccids/lib/Makefile
+++ b/net/dccp/ccids/lib/Makefile
@@ -1,3 +1,3 @@
1obj-$(CONFIG_IP_DCCP_TFRC_LIB) += dccp_tfrc_lib.o 1obj-$(CONFIG_IP_DCCP_TFRC_LIB) += dccp_tfrc_lib.o
2 2
3dccp_tfrc_lib-y := loss_interval.o packet_history.o tfrc_equation.o 3dccp_tfrc_lib-y := tfrc.o tfrc_equation.o packet_history.o loss_interval.o
diff --git a/net/dccp/ccids/lib/packet_history.c b/net/dccp/ccids/lib/packet_history.c
index 4805de996568..1d4d6ee9be45 100644
--- a/net/dccp/ccids/lib/packet_history.c
+++ b/net/dccp/ccids/lib/packet_history.c
@@ -35,7 +35,6 @@
35 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 35 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
36 */ 36 */
37 37
38#include <linux/module.h>
39#include <linux/string.h> 38#include <linux/string.h>
40#include "packet_history.h" 39#include "packet_history.h"
41 40
@@ -277,39 +276,19 @@ void dccp_rx_hist_purge(struct dccp_rx_hist *hist, struct list_head *list)
277 276
278EXPORT_SYMBOL_GPL(dccp_rx_hist_purge); 277EXPORT_SYMBOL_GPL(dccp_rx_hist_purge);
279 278
280extern int __init dccp_li_init(void); 279__init int packet_history_init(void)
281extern void dccp_li_exit(void);
282
283static __init int packet_history_init(void)
284{ 280{
285 if (dccp_li_init() != 0)
286 goto out;
287
288 tfrc_tx_hist = kmem_cache_create("tfrc_tx_hist", 281 tfrc_tx_hist = kmem_cache_create("tfrc_tx_hist",
289 sizeof(struct tfrc_tx_hist_entry), 0, 282 sizeof(struct tfrc_tx_hist_entry), 0,
290 SLAB_HWCACHE_ALIGN, NULL); 283 SLAB_HWCACHE_ALIGN, NULL);
291 if (tfrc_tx_hist == NULL)
292 goto out_li_exit;
293 284
294 return 0; 285 return tfrc_tx_hist == NULL ? -ENOBUFS : 0;
295out_li_exit:
296 dccp_li_exit();
297out:
298 return -ENOBUFS;
299} 286}
300module_init(packet_history_init);
301 287
302static __exit void packet_history_exit(void) 288void packet_history_exit(void)
303{ 289{
304 if (tfrc_tx_hist != NULL) { 290 if (tfrc_tx_hist != NULL) {
305 kmem_cache_destroy(tfrc_tx_hist); 291 kmem_cache_destroy(tfrc_tx_hist);
306 tfrc_tx_hist = NULL; 292 tfrc_tx_hist = NULL;
307 } 293 }
308 dccp_li_exit();
309} 294}
310module_exit(packet_history_exit);
311
312MODULE_AUTHOR("Ian McDonald <ian.mcdonald@jandi.co.nz>, "
313 "Arnaldo Carvalho de Melo <acme@ghostprotocols.net>");
314MODULE_DESCRIPTION("DCCP TFRC library");
315MODULE_LICENSE("GPL");
diff --git a/net/dccp/ccids/lib/packet_history.h b/net/dccp/ccids/lib/packet_history.h
index 0670f46dd53c..9a2642ed684f 100644
--- a/net/dccp/ccids/lib/packet_history.h
+++ b/net/dccp/ccids/lib/packet_history.h
@@ -39,8 +39,7 @@
39#include <linux/ktime.h> 39#include <linux/ktime.h>
40#include <linux/list.h> 40#include <linux/list.h>
41#include <linux/slab.h> 41#include <linux/slab.h>
42 42#include "tfrc.h"
43#include "../../dccp.h"
44 43
45/* Number of later packets received before one is considered lost */ 44/* Number of later packets received before one is considered lost */
46#define TFRC_RECV_NUM_LATE_LOSS 3 45#define TFRC_RECV_NUM_LATE_LOSS 3
diff --git a/net/dccp/ccids/lib/tfrc.c b/net/dccp/ccids/lib/tfrc.c
new file mode 100644
index 000000000000..3a7a1838a64b
--- /dev/null
+++ b/net/dccp/ccids/lib/tfrc.c
@@ -0,0 +1,48 @@
1/*
2 * TFRC: main module holding the pieces of the TFRC library together
3 *
4 * Copyright (c) 2007 The University of Aberdeen, Scotland, UK
5 * Copyright (c) 2007 Arnaldo Carvalho de Melo <acme@redhat.com>
6 */
7#include <linux/module.h>
8#include <linux/moduleparam.h>
9#include "tfrc.h"
10
11#ifdef CONFIG_IP_DCCP_TFRC_DEBUG
12int tfrc_debug;
13module_param(tfrc_debug, bool, 0444);
14MODULE_PARM_DESC(tfrc_debug, "Enable debug messages");
15#endif
16
17extern int dccp_li_init(void);
18extern void dccp_li_exit(void);
19extern int packet_history_init(void);
20extern void packet_history_exit(void);
21
22static int __init tfrc_module_init(void)
23{
24 int rc = dccp_li_init();
25
26 if (rc == 0) {
27 rc = packet_history_init();
28 if (rc != 0)
29 dccp_li_exit();
30 }
31
32 return rc;
33}
34
35static void __exit tfrc_module_exit(void)
36{
37 packet_history_exit();
38 dccp_li_exit();
39}
40
41module_init(tfrc_module_init);
42module_exit(tfrc_module_exit);
43
44MODULE_AUTHOR("Gerrit Renker <gerrit@erg.abdn.ac.uk>, "
45 "Ian McDonald <ian.mcdonald@jandi.co.nz>, "
46 "Arnaldo Carvalho de Melo <acme@redhat.com>");
47MODULE_DESCRIPTION("DCCP TFRC library");
48MODULE_LICENSE("GPL");
diff --git a/net/dccp/ccids/lib/tfrc.h b/net/dccp/ccids/lib/tfrc.h
index 5a0ba86df183..ab8848c0f8c9 100644
--- a/net/dccp/ccids/lib/tfrc.h
+++ b/net/dccp/ccids/lib/tfrc.h
@@ -3,10 +3,11 @@
3/* 3/*
4 * net/dccp/ccids/lib/tfrc.h 4 * net/dccp/ccids/lib/tfrc.h
5 * 5 *
6 * Copyright (c) 2005 The University of Waikato, Hamilton, New Zealand. 6 * Copyright (c) 2007 The University of Aberdeen, Scotland, UK
7 * Copyright (c) 2005 Ian McDonald <ian.mcdonald@jandi.co.nz> 7 * Copyright (c) 2005-6 The University of Waikato, Hamilton, New Zealand.
8 * Copyright (c) 2005 Arnaldo Carvalho de Melo <acme@conectiva.com.br> 8 * Copyright (c) 2005-6 Ian McDonald <ian.mcdonald@jandi.co.nz>
9 * Copyright (c) 2003 Nils-Erik Mattsson, Joacim Haggmark, Magnus Erixzon 9 * Copyright (c) 2005 Arnaldo Carvalho de Melo <acme@conectiva.com.br>
10 * Copyright (c) 2003 Nils-Erik Mattsson, Joacim Haggmark, Magnus Erixzon
10 * 11 *
11 * This program is free software; you can redistribute it and/or modify 12 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by 13 * it under the terms of the GNU General Public License as published by
@@ -15,6 +16,14 @@
15 */ 16 */
16#include <linux/types.h> 17#include <linux/types.h>
17#include <asm/div64.h> 18#include <asm/div64.h>
19#include "../../dccp.h"
20
21#ifdef CONFIG_IP_DCCP_TFRC_DEBUG
22extern int tfrc_debug;
23#define tfrc_pr_debug(format, a...) DCCP_PR_DEBUG(tfrc_debug, format, ##a)
24#else
25#define tfrc_pr_debug(format, a...)
26#endif
18 27
19/* integer-arithmetic divisions of type (a * 1000000)/b */ 28/* integer-arithmetic divisions of type (a * 1000000)/b */
20static inline u64 scaled_div(u64 a, u32 b) 29static inline u64 scaled_div(u64 a, u32 b)