diff options
author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2007-12-06 09:28:13 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2008-01-28 17:56:41 -0500 |
commit | 34a9e7ea91bb4acb45ae5331e7403304029329b2 (patch) | |
tree | 196c60bbe79f4d480cefa9d141a6096f3450fa75 /net/dccp | |
parent | e9c8b24a6ade50315f3c080799da45ddadf42269 (diff) |
[TFRC]: Make the rx history slab be global
This is in preparation for merging the new rx history code written by Gerrit Renker.
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/dccp')
-rw-r--r-- | net/dccp/ccids/ccid3.c | 35 | ||||
-rw-r--r-- | net/dccp/ccids/lib/packet_history.c | 95 | ||||
-rw-r--r-- | net/dccp/ccids/lib/packet_history.h | 43 |
3 files changed, 60 insertions, 113 deletions
diff --git a/net/dccp/ccids/ccid3.c b/net/dccp/ccids/ccid3.c index 49338370eb04..2ba0a7c470d1 100644 --- a/net/dccp/ccids/ccid3.c +++ b/net/dccp/ccids/ccid3.c | |||
@@ -49,8 +49,6 @@ static int ccid3_debug; | |||
49 | #define ccid3_pr_debug(format, a...) | 49 | #define ccid3_pr_debug(format, a...) |
50 | #endif | 50 | #endif |
51 | 51 | ||
52 | static struct dccp_rx_hist *ccid3_rx_hist; | ||
53 | |||
54 | /* | 52 | /* |
55 | * Transmitter Half-Connection Routines | 53 | * Transmitter Half-Connection Routines |
56 | */ | 54 | */ |
@@ -807,9 +805,9 @@ static int ccid3_hc_rx_detect_loss(struct sock *sk, | |||
807 | } | 805 | } |
808 | 806 | ||
809 | detect_out: | 807 | detect_out: |
810 | dccp_rx_hist_add_packet(ccid3_rx_hist, &hcrx->ccid3hcrx_hist, | 808 | dccp_rx_hist_add_packet(&hcrx->ccid3hcrx_hist, |
811 | &hcrx->ccid3hcrx_li_hist, packet, | 809 | &hcrx->ccid3hcrx_li_hist, packet, |
812 | hcrx->ccid3hcrx_seqno_nonloss); | 810 | hcrx->ccid3hcrx_seqno_nonloss); |
813 | return loss; | 811 | return loss; |
814 | } | 812 | } |
815 | 813 | ||
@@ -852,8 +850,7 @@ static void ccid3_hc_rx_packet_recv(struct sock *sk, struct sk_buff *skb) | |||
852 | return; | 850 | return; |
853 | } | 851 | } |
854 | 852 | ||
855 | packet = dccp_rx_hist_entry_new(ccid3_rx_hist, opt_recv->dccpor_ndp, | 853 | packet = dccp_rx_hist_entry_new(opt_recv->dccpor_ndp, skb, GFP_ATOMIC); |
856 | skb, GFP_ATOMIC); | ||
857 | if (unlikely(packet == NULL)) { | 854 | if (unlikely(packet == NULL)) { |
858 | DCCP_WARN("%s(%p), Not enough mem to add rx packet " | 855 | DCCP_WARN("%s(%p), Not enough mem to add rx packet " |
859 | "to history, consider it lost!\n", dccp_role(sk), sk); | 856 | "to history, consider it lost!\n", dccp_role(sk), sk); |
@@ -936,7 +933,7 @@ static void ccid3_hc_rx_exit(struct sock *sk) | |||
936 | ccid3_hc_rx_set_state(sk, TFRC_RSTATE_TERM); | 933 | ccid3_hc_rx_set_state(sk, TFRC_RSTATE_TERM); |
937 | 934 | ||
938 | /* Empty packet history */ | 935 | /* Empty packet history */ |
939 | dccp_rx_hist_purge(ccid3_rx_hist, &hcrx->ccid3hcrx_hist); | 936 | dccp_rx_hist_purge(&hcrx->ccid3hcrx_hist); |
940 | 937 | ||
941 | /* Empty loss interval history */ | 938 | /* Empty loss interval history */ |
942 | dccp_li_hist_purge(&hcrx->ccid3hcrx_li_hist); | 939 | dccp_li_hist_purge(&hcrx->ccid3hcrx_li_hist); |
@@ -1013,33 +1010,13 @@ MODULE_PARM_DESC(ccid3_debug, "Enable debug messages"); | |||
1013 | 1010 | ||
1014 | static __init int ccid3_module_init(void) | 1011 | static __init int ccid3_module_init(void) |
1015 | { | 1012 | { |
1016 | int rc = -ENOBUFS; | 1013 | return ccid_register(&ccid3); |
1017 | |||
1018 | ccid3_rx_hist = dccp_rx_hist_new("ccid3"); | ||
1019 | if (ccid3_rx_hist == NULL) | ||
1020 | goto out; | ||
1021 | |||
1022 | rc = ccid_register(&ccid3); | ||
1023 | if (rc != 0) | ||
1024 | goto out_free_rx; | ||
1025 | out: | ||
1026 | return rc; | ||
1027 | |||
1028 | out_free_rx: | ||
1029 | dccp_rx_hist_delete(ccid3_rx_hist); | ||
1030 | ccid3_rx_hist = NULL; | ||
1031 | goto out; | ||
1032 | } | 1014 | } |
1033 | module_init(ccid3_module_init); | 1015 | module_init(ccid3_module_init); |
1034 | 1016 | ||
1035 | static __exit void ccid3_module_exit(void) | 1017 | static __exit void ccid3_module_exit(void) |
1036 | { | 1018 | { |
1037 | ccid_unregister(&ccid3); | 1019 | ccid_unregister(&ccid3); |
1038 | |||
1039 | if (ccid3_rx_hist != NULL) { | ||
1040 | dccp_rx_hist_delete(ccid3_rx_hist); | ||
1041 | ccid3_rx_hist = NULL; | ||
1042 | } | ||
1043 | } | 1020 | } |
1044 | module_exit(ccid3_module_exit); | 1021 | module_exit(ccid3_module_exit); |
1045 | 1022 | ||
diff --git a/net/dccp/ccids/lib/packet_history.c b/net/dccp/ccids/lib/packet_history.c index b628714fb2ab..e1ab853c38df 100644 --- a/net/dccp/ccids/lib/packet_history.c +++ b/net/dccp/ccids/lib/packet_history.c | |||
@@ -114,48 +114,33 @@ EXPORT_SYMBOL_GPL(tfrc_tx_hist_rtt); | |||
114 | /* | 114 | /* |
115 | * Receiver History Routines | 115 | * Receiver History Routines |
116 | */ | 116 | */ |
117 | struct dccp_rx_hist *dccp_rx_hist_new(const char *name) | 117 | static struct kmem_cache *tfrc_rx_hist_slab; |
118 | |||
119 | struct dccp_rx_hist_entry *dccp_rx_hist_entry_new(const u32 ndp, | ||
120 | const struct sk_buff *skb, | ||
121 | const gfp_t prio) | ||
118 | { | 122 | { |
119 | struct dccp_rx_hist *hist = kmalloc(sizeof(*hist), GFP_ATOMIC); | 123 | struct dccp_rx_hist_entry *entry = kmem_cache_alloc(tfrc_rx_hist_slab, |
120 | static const char dccp_rx_hist_mask[] = "rx_hist_%s"; | 124 | prio); |
121 | char *slab_name; | ||
122 | |||
123 | if (hist == NULL) | ||
124 | goto out; | ||
125 | |||
126 | slab_name = kmalloc(strlen(name) + sizeof(dccp_rx_hist_mask) - 1, | ||
127 | GFP_ATOMIC); | ||
128 | if (slab_name == NULL) | ||
129 | goto out_free_hist; | ||
130 | |||
131 | sprintf(slab_name, dccp_rx_hist_mask, name); | ||
132 | hist->dccprxh_slab = kmem_cache_create(slab_name, | ||
133 | sizeof(struct dccp_rx_hist_entry), | ||
134 | 0, SLAB_HWCACHE_ALIGN, NULL); | ||
135 | if (hist->dccprxh_slab == NULL) | ||
136 | goto out_free_slab_name; | ||
137 | out: | ||
138 | return hist; | ||
139 | out_free_slab_name: | ||
140 | kfree(slab_name); | ||
141 | out_free_hist: | ||
142 | kfree(hist); | ||
143 | hist = NULL; | ||
144 | goto out; | ||
145 | } | ||
146 | 125 | ||
147 | EXPORT_SYMBOL_GPL(dccp_rx_hist_new); | 126 | if (entry != NULL) { |
127 | const struct dccp_hdr *dh = dccp_hdr(skb); | ||
148 | 128 | ||
149 | void dccp_rx_hist_delete(struct dccp_rx_hist *hist) | 129 | entry->dccphrx_seqno = DCCP_SKB_CB(skb)->dccpd_seq; |
150 | { | 130 | entry->dccphrx_ccval = dh->dccph_ccval; |
151 | const char* name = kmem_cache_name(hist->dccprxh_slab); | 131 | entry->dccphrx_type = dh->dccph_type; |
132 | entry->dccphrx_ndp = ndp; | ||
133 | entry->dccphrx_tstamp = ktime_get_real(); | ||
134 | } | ||
152 | 135 | ||
153 | kmem_cache_destroy(hist->dccprxh_slab); | 136 | return entry; |
154 | kfree(name); | ||
155 | kfree(hist); | ||
156 | } | 137 | } |
138 | EXPORT_SYMBOL_GPL(dccp_rx_hist_entry_new); | ||
157 | 139 | ||
158 | EXPORT_SYMBOL_GPL(dccp_rx_hist_delete); | 140 | static inline void dccp_rx_hist_entry_delete(struct dccp_rx_hist_entry *entry) |
141 | { | ||
142 | kmem_cache_free(tfrc_rx_hist_slab, entry); | ||
143 | } | ||
159 | 144 | ||
160 | int dccp_rx_hist_find_entry(const struct list_head *list, const u64 seq, | 145 | int dccp_rx_hist_find_entry(const struct list_head *list, const u64 seq, |
161 | u8 *ccval) | 146 | u8 *ccval) |
@@ -192,11 +177,10 @@ struct dccp_rx_hist_entry * | |||
192 | 177 | ||
193 | EXPORT_SYMBOL_GPL(dccp_rx_hist_find_data_packet); | 178 | EXPORT_SYMBOL_GPL(dccp_rx_hist_find_data_packet); |
194 | 179 | ||
195 | void dccp_rx_hist_add_packet(struct dccp_rx_hist *hist, | 180 | void dccp_rx_hist_add_packet(struct list_head *rx_list, |
196 | struct list_head *rx_list, | 181 | struct list_head *li_list, |
197 | struct list_head *li_list, | 182 | struct dccp_rx_hist_entry *packet, |
198 | struct dccp_rx_hist_entry *packet, | 183 | u64 nonloss_seqno) |
199 | u64 nonloss_seqno) | ||
200 | { | 184 | { |
201 | struct dccp_rx_hist_entry *entry, *next; | 185 | struct dccp_rx_hist_entry *entry, *next; |
202 | u8 num_later = 0; | 186 | u8 num_later = 0; |
@@ -211,7 +195,7 @@ void dccp_rx_hist_add_packet(struct dccp_rx_hist *hist, | |||
211 | if (after48(nonloss_seqno, | 195 | if (after48(nonloss_seqno, |
212 | entry->dccphrx_seqno)) { | 196 | entry->dccphrx_seqno)) { |
213 | list_del_init(&entry->dccphrx_node); | 197 | list_del_init(&entry->dccphrx_node); |
214 | dccp_rx_hist_entry_delete(hist, entry); | 198 | dccp_rx_hist_entry_delete(entry); |
215 | } | 199 | } |
216 | } else if (dccp_rx_hist_entry_data_packet(entry)) | 200 | } else if (dccp_rx_hist_entry_data_packet(entry)) |
217 | --num_later; | 201 | --num_later; |
@@ -253,7 +237,7 @@ void dccp_rx_hist_add_packet(struct dccp_rx_hist *hist, | |||
253 | break; | 237 | break; |
254 | case 3: | 238 | case 3: |
255 | list_del_init(&entry->dccphrx_node); | 239 | list_del_init(&entry->dccphrx_node); |
256 | dccp_rx_hist_entry_delete(hist, entry); | 240 | dccp_rx_hist_entry_delete(entry); |
257 | break; | 241 | break; |
258 | } | 242 | } |
259 | } else if (dccp_rx_hist_entry_data_packet(entry)) | 243 | } else if (dccp_rx_hist_entry_data_packet(entry)) |
@@ -264,13 +248,13 @@ void dccp_rx_hist_add_packet(struct dccp_rx_hist *hist, | |||
264 | 248 | ||
265 | EXPORT_SYMBOL_GPL(dccp_rx_hist_add_packet); | 249 | EXPORT_SYMBOL_GPL(dccp_rx_hist_add_packet); |
266 | 250 | ||
267 | void dccp_rx_hist_purge(struct dccp_rx_hist *hist, struct list_head *list) | 251 | void dccp_rx_hist_purge(struct list_head *list) |
268 | { | 252 | { |
269 | struct dccp_rx_hist_entry *entry, *next; | 253 | struct dccp_rx_hist_entry *entry, *next; |
270 | 254 | ||
271 | list_for_each_entry_safe(entry, next, list, dccphrx_node) { | 255 | list_for_each_entry_safe(entry, next, list, dccphrx_node) { |
272 | list_del_init(&entry->dccphrx_node); | 256 | list_del_init(&entry->dccphrx_node); |
273 | kmem_cache_free(hist->dccprxh_slab, entry); | 257 | dccp_rx_hist_entry_delete(entry); |
274 | } | 258 | } |
275 | } | 259 | } |
276 | 260 | ||
@@ -281,8 +265,22 @@ __init int packet_history_init(void) | |||
281 | tfrc_tx_hist_slab = kmem_cache_create("tfrc_tx_hist", | 265 | tfrc_tx_hist_slab = kmem_cache_create("tfrc_tx_hist", |
282 | sizeof(struct tfrc_tx_hist_entry), 0, | 266 | sizeof(struct tfrc_tx_hist_entry), 0, |
283 | SLAB_HWCACHE_ALIGN, NULL); | 267 | SLAB_HWCACHE_ALIGN, NULL); |
268 | if (tfrc_tx_hist_slab == NULL) | ||
269 | goto out_err; | ||
284 | 270 | ||
285 | return tfrc_tx_hist_slab == NULL ? -ENOBUFS : 0; | 271 | tfrc_rx_hist_slab = kmem_cache_create("tfrc_rx_hist", |
272 | sizeof(struct dccp_rx_hist_entry), 0, | ||
273 | SLAB_HWCACHE_ALIGN, NULL); | ||
274 | if (tfrc_rx_hist_slab == NULL) | ||
275 | goto out_free_tx; | ||
276 | |||
277 | return 0; | ||
278 | |||
279 | out_free_tx: | ||
280 | kmem_cache_destroy(tfrc_tx_hist_slab); | ||
281 | tfrc_tx_hist_slab = NULL; | ||
282 | out_err: | ||
283 | return -ENOBUFS; | ||
286 | } | 284 | } |
287 | 285 | ||
288 | void packet_history_exit(void) | 286 | void packet_history_exit(void) |
@@ -291,4 +289,9 @@ void packet_history_exit(void) | |||
291 | kmem_cache_destroy(tfrc_tx_hist_slab); | 289 | kmem_cache_destroy(tfrc_tx_hist_slab); |
292 | tfrc_tx_hist_slab = NULL; | 290 | tfrc_tx_hist_slab = NULL; |
293 | } | 291 | } |
292 | |||
293 | if (tfrc_rx_hist_slab != NULL) { | ||
294 | kmem_cache_destroy(tfrc_rx_hist_slab); | ||
295 | tfrc_rx_hist_slab = NULL; | ||
296 | } | ||
294 | } | 297 | } |
diff --git a/net/dccp/ccids/lib/packet_history.h b/net/dccp/ccids/lib/packet_history.h index 9a2642ed684f..34b180b0edaa 100644 --- a/net/dccp/ccids/lib/packet_history.h +++ b/net/dccp/ccids/lib/packet_history.h | |||
@@ -66,34 +66,10 @@ struct dccp_rx_hist_entry { | |||
66 | ktime_t dccphrx_tstamp; | 66 | ktime_t dccphrx_tstamp; |
67 | }; | 67 | }; |
68 | 68 | ||
69 | struct dccp_rx_hist { | 69 | extern struct dccp_rx_hist_entry * |
70 | struct kmem_cache *dccprxh_slab; | 70 | dccp_rx_hist_entry_new(const u32 ndp, |
71 | }; | ||
72 | |||
73 | extern struct dccp_rx_hist *dccp_rx_hist_new(const char *name); | ||
74 | extern void dccp_rx_hist_delete(struct dccp_rx_hist *hist); | ||
75 | |||
76 | static inline struct dccp_rx_hist_entry * | ||
77 | dccp_rx_hist_entry_new(struct dccp_rx_hist *hist, | ||
78 | const u32 ndp, | ||
79 | const struct sk_buff *skb, | 71 | const struct sk_buff *skb, |
80 | const gfp_t prio) | 72 | const gfp_t prio); |
81 | { | ||
82 | struct dccp_rx_hist_entry *entry = kmem_cache_alloc(hist->dccprxh_slab, | ||
83 | prio); | ||
84 | |||
85 | if (entry != NULL) { | ||
86 | const struct dccp_hdr *dh = dccp_hdr(skb); | ||
87 | |||
88 | entry->dccphrx_seqno = DCCP_SKB_CB(skb)->dccpd_seq; | ||
89 | entry->dccphrx_ccval = dh->dccph_ccval; | ||
90 | entry->dccphrx_type = dh->dccph_type; | ||
91 | entry->dccphrx_ndp = ndp; | ||
92 | entry->dccphrx_tstamp = ktime_get_real(); | ||
93 | } | ||
94 | |||
95 | return entry; | ||
96 | } | ||
97 | 73 | ||
98 | static inline struct dccp_rx_hist_entry * | 74 | static inline struct dccp_rx_hist_entry * |
99 | dccp_rx_hist_head(struct list_head *list) | 75 | dccp_rx_hist_head(struct list_head *list) |
@@ -111,21 +87,12 @@ extern int dccp_rx_hist_find_entry(const struct list_head *list, const u64 seq, | |||
111 | extern struct dccp_rx_hist_entry * | 87 | extern struct dccp_rx_hist_entry * |
112 | dccp_rx_hist_find_data_packet(const struct list_head *list); | 88 | dccp_rx_hist_find_data_packet(const struct list_head *list); |
113 | 89 | ||
114 | extern void dccp_rx_hist_add_packet(struct dccp_rx_hist *hist, | 90 | extern void dccp_rx_hist_add_packet(struct list_head *rx_list, |
115 | struct list_head *rx_list, | ||
116 | struct list_head *li_list, | 91 | struct list_head *li_list, |
117 | struct dccp_rx_hist_entry *packet, | 92 | struct dccp_rx_hist_entry *packet, |
118 | u64 nonloss_seqno); | 93 | u64 nonloss_seqno); |
119 | 94 | ||
120 | static inline void dccp_rx_hist_entry_delete(struct dccp_rx_hist *hist, | 95 | extern void dccp_rx_hist_purge(struct list_head *list); |
121 | struct dccp_rx_hist_entry *entry) | ||
122 | { | ||
123 | if (entry != NULL) | ||
124 | kmem_cache_free(hist->dccprxh_slab, entry); | ||
125 | } | ||
126 | |||
127 | extern void dccp_rx_hist_purge(struct dccp_rx_hist *hist, | ||
128 | struct list_head *list); | ||
129 | 96 | ||
130 | static inline int | 97 | static inline int |
131 | dccp_rx_hist_entry_data_packet(const struct dccp_rx_hist_entry *entry) | 98 | dccp_rx_hist_entry_data_packet(const struct dccp_rx_hist_entry *entry) |