mirror of
https://github.com/SCST-project/scst.git
synced 2026-05-20 04:01:26 +00:00
git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@4164 d57e44dd-8a1f-0410-8b47-8ef2f437770f
304 lines
8.8 KiB
Diff
304 lines
8.8 KiB
Diff
=== modified file 'include/linux/mm_types.h'
|
|
--- old/include/linux/mm_types.h 2012-03-19 23:46:01 +0000
|
|
+++ new/include/linux/mm_types.h 2012-03-23 21:39:19 +0000
|
|
@@ -149,6 +149,17 @@ struct page {
|
|
*/
|
|
void *shadow;
|
|
#endif
|
|
+
|
|
+#if defined(CONFIG_TCP_ZERO_COPY_TRANSFER_COMPLETION_NOTIFICATION)
|
|
+ /*
|
|
+ * Used to implement support for notification on zero-copy TCP transfer
|
|
+ * completion. It might look as not good to have this field here and
|
|
+ * it's better to have it in struct sk_buff, but it would make the code
|
|
+ * much more complicated and fragile, since all skb then would have to
|
|
+ * contain only pages with the same value in this field.
|
|
+ */
|
|
+ void *net_priv;
|
|
+#endif
|
|
}
|
|
/*
|
|
* The struct page can be forced to be double word aligned so that atomic ops
|
|
|
|
=== modified file 'include/linux/net.h'
|
|
--- old/include/linux/net.h 2012-03-19 23:46:01 +0000
|
|
+++ new/include/linux/net.h 2012-03-23 21:39:19 +0000
|
|
@@ -61,6 +61,7 @@ typedef enum {
|
|
#include <linux/fcntl.h> /* For O_CLOEXEC and O_NONBLOCK */
|
|
#include <linux/kmemcheck.h>
|
|
#include <linux/rcupdate.h>
|
|
+#include <linux/mm.h>
|
|
|
|
struct poll_table_struct;
|
|
struct pipe_inode_info;
|
|
@@ -289,5 +290,44 @@ extern int kernel_sock_shutdown(struct s
|
|
MODULE_ALIAS("net-pf-" __stringify(pf) "-proto-" __stringify(proto) \
|
|
"-type-" __stringify(type))
|
|
|
|
+#if defined(CONFIG_TCP_ZERO_COPY_TRANSFER_COMPLETION_NOTIFICATION)
|
|
+/* Support for notification on zero-copy TCP transfer completion */
|
|
+typedef void (*net_get_page_callback_t)(struct page *page);
|
|
+typedef void (*net_put_page_callback_t)(struct page *page);
|
|
+
|
|
+extern net_get_page_callback_t net_get_page_callback;
|
|
+extern net_put_page_callback_t net_put_page_callback;
|
|
+
|
|
+extern int net_set_get_put_page_callbacks(
|
|
+ net_get_page_callback_t get_callback,
|
|
+ net_put_page_callback_t put_callback);
|
|
+
|
|
+/*
|
|
+ * See comment for net_set_get_put_page_callbacks() why those functions
|
|
+ * don't need any protection.
|
|
+ */
|
|
+static inline void net_get_page(struct page *page)
|
|
+{
|
|
+ if (page->net_priv != 0)
|
|
+ net_get_page_callback(page);
|
|
+ get_page(page);
|
|
+}
|
|
+static inline void net_put_page(struct page *page)
|
|
+{
|
|
+ if (page->net_priv != 0)
|
|
+ net_put_page_callback(page);
|
|
+ put_page(page);
|
|
+}
|
|
+#else
|
|
+static inline void net_get_page(struct page *page)
|
|
+{
|
|
+ get_page(page);
|
|
+}
|
|
+static inline void net_put_page(struct page *page)
|
|
+{
|
|
+ put_page(page);
|
|
+}
|
|
+#endif /* CONFIG_TCP_ZERO_COPY_TRANSFER_COMPLETION_NOTIFICATION */
|
|
+
|
|
#endif /* __KERNEL__ */
|
|
#endif /* _LINUX_NET_H */
|
|
|
|
=== modified file 'include/linux/skbuff.h'
|
|
--- old/include/linux/skbuff.h 2012-03-19 23:46:01 +0000
|
|
+++ new/include/linux/skbuff.h 2012-03-23 21:39:19 +0000
|
|
@@ -1702,7 +1702,7 @@ static inline struct page *skb_frag_page
|
|
*/
|
|
static inline void __skb_frag_ref(skb_frag_t *frag)
|
|
{
|
|
- get_page(skb_frag_page(frag));
|
|
+ net_get_page(skb_frag_page(frag));
|
|
}
|
|
|
|
/**
|
|
@@ -1725,7 +1725,7 @@ static inline void skb_frag_ref(struct s
|
|
*/
|
|
static inline void __skb_frag_unref(skb_frag_t *frag)
|
|
{
|
|
- put_page(skb_frag_page(frag));
|
|
+ net_put_page(skb_frag_page(frag));
|
|
}
|
|
|
|
/**
|
|
|
|
=== modified file 'net/Kconfig'
|
|
--- old/net/Kconfig 2012-03-19 23:46:01 +0000
|
|
+++ new/net/Kconfig 2012-03-23 21:39:19 +0000
|
|
@@ -72,6 +72,18 @@ config INET
|
|
|
|
Short answer: say Y.
|
|
|
|
+config TCP_ZERO_COPY_TRANSFER_COMPLETION_NOTIFICATION
|
|
+ bool "TCP/IP zero-copy transfer completion notification"
|
|
+ depends on INET
|
|
+ default SCST_ISCSI
|
|
+ ---help---
|
|
+ Adds support for sending a notification upon completion of a
|
|
+ zero-copy TCP/IP transfer. This can speed up certain TCP/IP
|
|
+ software. Currently this is only used by the iSCSI target driver
|
|
+ iSCSI-SCST.
|
|
+
|
|
+ If unsure, say N.
|
|
+
|
|
if INET
|
|
source "net/ipv4/Kconfig"
|
|
source "net/ipv6/Kconfig"
|
|
|
|
=== modified file 'net/core/skbuff.c'
|
|
--- old/net/core/skbuff.c 2012-03-19 23:46:01 +0000
|
|
+++ new/net/core/skbuff.c 2012-03-23 21:39:19 +0000
|
|
@@ -77,13 +77,13 @@ static struct kmem_cache *skbuff_fclone_
|
|
static void sock_pipe_buf_release(struct pipe_inode_info *pipe,
|
|
struct pipe_buffer *buf)
|
|
{
|
|
- put_page(buf->page);
|
|
+ net_put_page(buf->page);
|
|
}
|
|
|
|
static void sock_pipe_buf_get(struct pipe_inode_info *pipe,
|
|
struct pipe_buffer *buf)
|
|
{
|
|
- get_page(buf->page);
|
|
+ net_get_page(buf->page);
|
|
}
|
|
|
|
static int sock_pipe_buf_steal(struct pipe_inode_info *pipe,
|
|
@@ -702,7 +702,7 @@ int skb_copy_ubufs(struct sk_buff *skb,
|
|
if (!page) {
|
|
while (head) {
|
|
struct page *next = (struct page *)head->private;
|
|
- put_page(head);
|
|
+ net_put_page(head);
|
|
head = next;
|
|
}
|
|
return -ENOMEM;
|
|
@@ -1542,7 +1542,7 @@ EXPORT_SYMBOL(skb_copy_bits);
|
|
*/
|
|
static void sock_spd_release(struct splice_pipe_desc *spd, unsigned int i)
|
|
{
|
|
- put_page(spd->pages[i]);
|
|
+ net_put_page(spd->pages[i]);
|
|
}
|
|
|
|
static inline struct page *linear_to_page(struct page *page, unsigned int *len,
|
|
@@ -1566,7 +1566,7 @@ new_page:
|
|
off = sk->sk_sndmsg_off;
|
|
mlen = PAGE_SIZE - off;
|
|
if (mlen < 64 && mlen < *len) {
|
|
- put_page(p);
|
|
+ net_put_page(p);
|
|
goto new_page;
|
|
}
|
|
|
|
@@ -1576,7 +1576,7 @@ new_page:
|
|
memcpy(page_address(p) + off, page_address(page) + *offset, *len);
|
|
sk->sk_sndmsg_off += *len;
|
|
*offset = off;
|
|
- get_page(p);
|
|
+ net_get_page(p);
|
|
|
|
return p;
|
|
}
|
|
@@ -1598,7 +1598,7 @@ static inline int spd_fill_page(struct s
|
|
if (!page)
|
|
return 1;
|
|
} else
|
|
- get_page(page);
|
|
+ net_get_page(page);
|
|
|
|
spd->pages[spd->nr_pages] = page;
|
|
spd->partial[spd->nr_pages].len = *len;
|
|
|
|
=== modified file 'net/ipv4/Makefile'
|
|
--- old/net/ipv4/Makefile 2012-03-19 23:46:01 +0000
|
|
+++ new/net/ipv4/Makefile 2012-03-23 21:39:19 +0000
|
|
@@ -50,6 +50,7 @@ obj-$(CONFIG_TCP_CONG_YEAH) += tcp_yeah.
|
|
obj-$(CONFIG_TCP_CONG_ILLINOIS) += tcp_illinois.o
|
|
obj-$(CONFIG_CGROUP_MEM_RES_CTLR_KMEM) += tcp_memcontrol.o
|
|
obj-$(CONFIG_NETLABEL) += cipso_ipv4.o
|
|
+obj-$(CONFIG_TCP_ZERO_COPY_TRANSFER_COMPLETION_NOTIFICATION) += tcp_zero_copy.o
|
|
|
|
obj-$(CONFIG_XFRM) += xfrm4_policy.o xfrm4_state.o xfrm4_input.o \
|
|
xfrm4_output.o
|
|
|
|
=== modified file 'net/ipv4/ip_output.c'
|
|
--- old/net/ipv4/ip_output.c 2012-03-19 23:46:01 +0000
|
|
+++ new/net/ipv4/ip_output.c 2012-03-23 21:39:19 +0000
|
|
@@ -1246,7 +1246,7 @@ ssize_t ip_append_page(struct sock *sk,
|
|
if (skb_can_coalesce(skb, i, page, offset)) {
|
|
skb_frag_size_add(&skb_shinfo(skb)->frags[i-1], len);
|
|
} else if (i < MAX_SKB_FRAGS) {
|
|
- get_page(page);
|
|
+ net_get_page(page);
|
|
skb_fill_page_desc(skb, i, page, offset, len);
|
|
} else {
|
|
err = -EMSGSIZE;
|
|
|
|
=== modified file 'net/ipv4/tcp.c'
|
|
--- old/net/ipv4/tcp.c 2012-03-19 23:46:01 +0000
|
|
+++ new/net/ipv4/tcp.c 2012-03-23 21:39:19 +0000
|
|
@@ -813,7 +813,7 @@ new_segment:
|
|
if (can_coalesce) {
|
|
skb_frag_size_add(&skb_shinfo(skb)->frags[i - 1], copy);
|
|
} else {
|
|
- get_page(page);
|
|
+ net_get_page(page);
|
|
skb_fill_page_desc(skb, i, page, offset, copy);
|
|
}
|
|
|
|
@@ -1025,7 +1025,7 @@ new_segment:
|
|
goto new_segment;
|
|
} else if (page) {
|
|
if (off == PAGE_SIZE) {
|
|
- put_page(page);
|
|
+ net_put_page(page);
|
|
sk->sk_sndmsg_page = page = NULL;
|
|
off = 0;
|
|
}
|
|
@@ -1065,9 +1065,9 @@ new_segment:
|
|
} else {
|
|
skb_fill_page_desc(skb, i, page, off, copy);
|
|
if (sk->sk_sndmsg_page) {
|
|
- get_page(page);
|
|
+ net_get_page(page);
|
|
} else if (off + copy < PAGE_SIZE) {
|
|
- get_page(page);
|
|
+ net_get_page(page);
|
|
sk->sk_sndmsg_page = page;
|
|
}
|
|
}
|
|
|
|
=== added file 'net/ipv4/tcp_zero_copy.c'
|
|
--- old/net/ipv4/tcp_zero_copy.c 1970-01-01 00:00:00 +0000
|
|
+++ new/net/ipv4/tcp_zero_copy.c 2012-03-23 21:39:19 +0000
|
|
@@ -0,0 +1,50 @@
|
|
+/*
|
|
+ * Support routines for TCP zero copy transmit
|
|
+ *
|
|
+ * Created by Vladislav Bolkhovitin
|
|
+ *
|
|
+ * This program is free software; you can redistribute it and/or
|
|
+ * modify it under the terms of the GNU General Public License
|
|
+ * version 2 as published by the Free Software Foundation.
|
|
+ */
|
|
+
|
|
+#include <linux/export.h>
|
|
+#include <linux/skbuff.h>
|
|
+
|
|
+net_get_page_callback_t net_get_page_callback __read_mostly;
|
|
+EXPORT_SYMBOL_GPL(net_get_page_callback);
|
|
+
|
|
+net_put_page_callback_t net_put_page_callback __read_mostly;
|
|
+EXPORT_SYMBOL_GPL(net_put_page_callback);
|
|
+
|
|
+/*
|
|
+ * Caller of this function must ensure that at the moment when it's called
|
|
+ * there are no pages in the system with net_priv field set to non-zero
|
|
+ * value. Hence, this function, as well as net_get_page() and net_put_page(),
|
|
+ * don't need any protection.
|
|
+ */
|
|
+int net_set_get_put_page_callbacks(
|
|
+ net_get_page_callback_t get_callback,
|
|
+ net_put_page_callback_t put_callback)
|
|
+{
|
|
+ int res = 0;
|
|
+
|
|
+ if ((net_get_page_callback != NULL) && (get_callback != NULL) &&
|
|
+ (net_get_page_callback != get_callback)) {
|
|
+ res = -EBUSY;
|
|
+ goto out;
|
|
+ }
|
|
+
|
|
+ if ((net_put_page_callback != NULL) && (put_callback != NULL) &&
|
|
+ (net_put_page_callback != put_callback)) {
|
|
+ res = -EBUSY;
|
|
+ goto out;
|
|
+ }
|
|
+
|
|
+ net_get_page_callback = get_callback;
|
|
+ net_put_page_callback = put_callback;
|
|
+
|
|
+out:
|
|
+ return res;
|
|
+}
|
|
+EXPORT_SYMBOL_GPL(net_set_get_put_page_callbacks);
|
|
|