]> git.karo-electronics.de Git - mv-sheeva.git/blob - net/ipv4/tcp_zero_copy.c
Forgot to add net/ipv4/tcp_zero_copy.c from put_page_callback patch
[mv-sheeva.git] / net / ipv4 / tcp_zero_copy.c
1 /*
2  *      Support routines for TCP zero copy transmit
3  *
4  *      Created by Vladislav Bolkhovitin
5  *
6  *      This program is free software; you can redistribute it and/or
7  *      modify it under the terms of the GNU General Public License
8  *      version 2 as published by the Free Software Foundation.
9  */
10
11 #include <linux/skbuff.h>
12
13 net_get_page_callback_t net_get_page_callback __read_mostly;
14 EXPORT_SYMBOL(net_get_page_callback);
15
16 net_put_page_callback_t net_put_page_callback __read_mostly;
17 EXPORT_SYMBOL(net_put_page_callback);
18
19 /*
20  * Caller of this function must ensure that at the moment when it's called
21  * there are no pages in the system with net_priv field set to non-zero
22  * value. Hence, this function, as well as net_get_page() and net_put_page(),
23  * don't need any protection.
24  */
25 int net_set_get_put_page_callbacks(
26         net_get_page_callback_t get_callback,
27         net_put_page_callback_t put_callback)
28 {
29         int res = 0;
30
31         if ((net_get_page_callback != NULL) && (get_callback != NULL) &&
32             (net_get_page_callback != get_callback)) {
33                 res = -EBUSY;
34                 goto out;
35         }
36
37         if ((net_put_page_callback != NULL) && (put_callback != NULL) &&
38             (net_put_page_callback != put_callback)) {
39                 res = -EBUSY;
40                 goto out;
41         }
42
43         net_get_page_callback = get_callback;
44         net_put_page_callback = put_callback;
45
46 out:
47         return res;
48 }
49 EXPORT_SYMBOL(net_set_get_put_page_callbacks);