From: Ian Campbell <ian.campbell@citrix.com>
To: "netdev@vger.kernel.org" <netdev@vger.kernel.org>
Cc: Ian Campbell <ian.campbell@citrix.com>
Subject: [PATCH 6/6] net: add opaque struct around skb frag page
Date: Thu, 20 Oct 2011 10:01:49 +0100 [thread overview]
Message-ID: <1319101309-28431-6-git-send-email-ian.campbell@citrix.com> (raw)
In-Reply-To: <1319101275.3385.129.camel@zakaz.uk.xensource.com>
I've split this bit out of the skb frag destructor patch since it helps enforce
the use of the fragment API.
Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
---
include/linux/skbuff.h | 10 ++++++----
net/core/skbuff.c | 6 +++---
2 files changed, 9 insertions(+), 7 deletions(-)
diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index 1ebf1ea..aec73c1 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -140,7 +140,9 @@ struct sk_buff;
typedef struct skb_frag_struct skb_frag_t;
struct skb_frag_struct {
- struct page *page;
+ struct {
+ struct page *p;
+ } page;
#if (BITS_PER_LONG > 32) || (PAGE_SIZE >= 65536)
__u32 page_offset;
__u32 size;
@@ -1175,7 +1177,7 @@ static inline void __skb_fill_page_desc(struct sk_buff *skb, int i,
{
skb_frag_t *frag = &skb_shinfo(skb)->frags[i];
- frag->page = page;
+ frag->page.p = page;
frag->page_offset = off;
skb_frag_size_set(frag, size);
}
@@ -1699,7 +1701,7 @@ static inline void netdev_free_page(struct net_device *dev, struct page *page)
*/
static inline struct page *skb_frag_page(const skb_frag_t *frag)
{
- return frag->page;
+ return frag->page.p;
}
/**
@@ -1785,7 +1787,7 @@ static inline void *skb_frag_address_safe(const skb_frag_t *frag)
*/
static inline void __skb_frag_set_page(skb_frag_t *frag, struct page *page)
{
- frag->page = page;
+ frag->page.p = page;
}
/**
diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index e271040..ca4db40 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -668,14 +668,14 @@ int skb_copy_ubufs(struct sk_buff *skb, gfp_t gfp_mask)
/* skb frags release userspace buffers */
for (i = 0; i < skb_shinfo(skb)->nr_frags; i++)
- put_page(skb_shinfo(skb)->frags[i].page);
+ skb_frag_unref(skb, i);
uarg->callback(uarg);
/* skb frags point to kernel buffers */
for (i = skb_shinfo(skb)->nr_frags; i > 0; i--) {
- skb_shinfo(skb)->frags[i - 1].page_offset = 0;
- skb_shinfo(skb)->frags[i - 1].page = head;
+ __skb_fill_page_desc(skb, i-1, head, 0,
+ skb_shinfo(skb)->frags[i - 1].size);
head = (struct page *)head->private;
}
--
1.7.2.5
next prev parent reply other threads:[~2011-10-20 9:02 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-10-20 9:01 [PATCH 0/6] skb fragment API: convert network drivers (part V, take 2) Ian Campbell
2011-10-20 9:01 ` [PATCH 1/6] mm: add a "struct page_frag" type containing a page, offset and length Ian Campbell
2011-10-20 9:01 ` [PATCH 2/6] mlx4: convert to SKB paged frag API Ian Campbell
2011-10-20 9:01 ` [PATCH 3/6] cxgb4: " Ian Campbell
2011-10-20 9:01 ` [PATCH 4/6] cxgb4vf: " Ian Campbell
2011-10-20 9:01 ` [PATCH 5/6] cxgbi: " Ian Campbell
2011-10-20 9:01 ` Ian Campbell [this message]
2011-10-20 9:23 ` [PATCH 0/6] skb fragment API: convert network drivers (part V, take 2) David Miller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1319101309-28431-6-git-send-email-ian.campbell@citrix.com \
--to=ian.campbell@citrix.com \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).