mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Ian Campbell <ian.campbell@citrix.com>
To: netdev@vger.kernel.org
Cc: linux-kernel@vger.kernel.org,
	Ian Campbell <ian.campbell@citrix.com>,
	xen-devel@lists.xensource.com
Subject: [PATCH 62/75] xen: netback: convert to SKB paged frag API.
Date: Fri, 19 Aug 2011 14:27:34 +0100	[thread overview]
Message-ID: <1313760467-8598-62-git-send-email-ian.campbell@citrix.com> (raw)
In-Reply-To: <1313760393.5010.356.camel@zakaz.uk.xensource.com>

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Cc: Ian Campbell <ian.campbell@citrix.com>
Cc: xen-devel@lists.xensource.com
Cc: netdev@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
---
 drivers/net/xen-netback/netback.c |   34 +++++++++++++++++++++++-----------
 1 files changed, 23 insertions(+), 11 deletions(-)

diff --git a/drivers/net/xen-netback/netback.c b/drivers/net/xen-netback/netback.c
index fd00f25..3068f67 100644
--- a/drivers/net/xen-netback/netback.c
+++ b/drivers/net/xen-netback/netback.c
@@ -215,6 +215,16 @@ static int get_page_ext(struct page *pg,
 			 sizeof(struct iphdr) + MAX_IPOPTLEN + \
 			 sizeof(struct tcphdr) + MAX_TCP_OPTION_SPACE)
 
+static unsigned long frag_get_pending_idx(skb_frag_t *frag)
+{
+	return (unsigned long)skb_frag_page(frag);
+}
+
+static void frag_set_pending_idx(skb_frag_t *frag, unsigned long pending_idx)
+{
+	__skb_frag_set_page(frag, (void *)pending_idx);
+}
+
 static inline pending_ring_idx_t pending_index(unsigned i)
 {
 	return i & (MAX_PENDING_REQS-1);
@@ -512,7 +522,7 @@ static int netbk_gop_skb(struct sk_buff *skb,
 
 	for (i = 0; i < nr_frags; i++) {
 		netbk_gop_frag_copy(vif, skb, npo,
-				    skb_shinfo(skb)->frags[i].page,
+				    skb_frag_page(&skb_shinfo(skb)->frags[i]),
 				    skb_shinfo(skb)->frags[i].size,
 				    skb_shinfo(skb)->frags[i].page_offset,
 				    &head);
@@ -913,7 +923,7 @@ static struct gnttab_copy *xen_netbk_get_requests(struct xen_netbk *netbk,
 	int i, start;
 
 	/* Skip first skb fragment if it is on same page as header fragment. */
-	start = ((unsigned long)shinfo->frags[0].page == pending_idx);
+	start = (frag_get_pending_idx(&shinfo->frags[0]) == pending_idx);
 
 	for (i = start; i < shinfo->nr_frags; i++, txp++) {
 		struct page *page;
@@ -945,7 +955,7 @@ static struct gnttab_copy *xen_netbk_get_requests(struct xen_netbk *netbk,
 		memcpy(&pending_tx_info[pending_idx].req, txp, sizeof(*txp));
 		xenvif_get(vif);
 		pending_tx_info[pending_idx].vif = vif;
-		frags[i].page = (void *)pending_idx;
+		frag_set_pending_idx(&frags[i], pending_idx);
 	}
 
 	return gop;
@@ -976,13 +986,13 @@ static int xen_netbk_tx_check_gop(struct xen_netbk *netbk,
 	}
 
 	/* Skip first skb fragment if it is on same page as header fragment. */
-	start = ((unsigned long)shinfo->frags[0].page == pending_idx);
+	start = (frag_get_pending_idx(&shinfo->frags[0]) == pending_idx);
 
 	for (i = start; i < nr_frags; i++) {
 		int j, newerr;
 		pending_ring_idx_t index;
 
-		pending_idx = (unsigned long)shinfo->frags[i].page;
+		pending_idx = frag_get_pending_idx(&shinfo->frags[i]);
 
 		/* Check error status: if okay then remember grant handle. */
 		newerr = (++gop)->status;
@@ -1008,7 +1018,7 @@ static int xen_netbk_tx_check_gop(struct xen_netbk *netbk,
 		pending_idx = *((u16 *)skb->data);
 		xen_netbk_idx_release(netbk, pending_idx);
 		for (j = start; j < i; j++) {
-			pending_idx = (unsigned long)shinfo->frags[i].page;
+			pending_idx = frag_get_pending_idx(&shinfo->frags[i]);
 			xen_netbk_idx_release(netbk, pending_idx);
 		}
 
@@ -1029,12 +1039,14 @@ static void xen_netbk_fill_frags(struct xen_netbk *netbk, struct sk_buff *skb)
 	for (i = 0; i < nr_frags; i++) {
 		skb_frag_t *frag = shinfo->frags + i;
 		struct xen_netif_tx_request *txp;
+		struct page *page;
 		unsigned long pending_idx;
 
-		pending_idx = (unsigned long)frag->page;
+		pending_idx = frag_get_pending_idx(frag);
 
 		txp = &netbk->pending_tx_info[pending_idx].req;
-		frag->page = virt_to_page(idx_to_kaddr(netbk, pending_idx));
+		page = virt_to_page(idx_to_kaddr(netbk, pending_idx));
+		__skb_frag_set_page(frag, page);
 		frag->size = txp->size;
 		frag->page_offset = txp->offset;
 
@@ -1349,11 +1361,11 @@ static unsigned xen_netbk_tx_build_gops(struct xen_netbk *netbk)
 		skb_shinfo(skb)->nr_frags = ret;
 		if (data_len < txreq.size) {
 			skb_shinfo(skb)->nr_frags++;
-			skb_shinfo(skb)->frags[0].page =
-				(void *)(unsigned long)pending_idx;
+			frag_set_pending_idx(&skb_shinfo(skb)->frags[0],
+					     pending_idx);
 		} else {
 			/* Discriminate from any valid pending_idx value. */
-			skb_shinfo(skb)->frags[0].page = (void *)~0UL;
+			frag_set_pending_idx(&skb_shinfo(skb)->frags[0], ~0UL);
 		}
 
 		__skb_queue_tail(&netbk->tx_queue, skb);
-- 
1.7.2.5


  parent reply	other threads:[~2011-08-19 13:29 UTC|newest]

Thread overview: 84+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1313760393.5010.356.camel@zakaz.uk.xensource.com>
2011-08-19 13:26 ` [PATCH 01/75] net: add APIs for manipulating skb page fragments Ian Campbell
2011-08-24 18:21   ` Konrad Rzeszutek Wilk
2011-08-24 21:09     ` Ian Campbell
2011-08-24 21:15       ` Konrad Rzeszutek Wilk
2011-08-19 13:26 ` [PATCH 02/75] net: convert core to skb paged frag APIs Ian Campbell
2011-08-19 13:26 ` [PATCH 03/75] net: ipv4: convert to SKB " Ian Campbell
2011-08-19 13:26 ` [PATCH 04/75] net: ipv6: " Ian Campbell
2011-08-19 13:26 ` [PATCH 05/75] net: xfrm: " Ian Campbell
2011-08-19 13:26 ` [PATCH 06/75] atm: convert to SKB paged frag API Ian Campbell
2011-08-19 13:26 ` [PATCH 07/75] IB: amso1100: " Ian Campbell
2011-08-19 13:26 ` [PATCH 08/75] IB: nes: " Ian Campbell
2011-08-19 13:26 ` [PATCH 09/75] IPoIB: " Ian Campbell
2011-08-19 13:26 ` [PATCH 10/75] 3c59x: " Ian Campbell
2011-08-19 13:26 ` [PATCH 11/75] 8139cp: " Ian Campbell
2011-08-19 13:26 ` [PATCH 12/75] acenic: " Ian Campbell
2011-08-19 13:26 ` [PATCH 13/75] atl1c: " Ian Campbell
2011-08-19 13:26 ` [PATCH 14/75] atl1e: " Ian Campbell
2011-08-19 13:26 ` [PATCH 15/75] atlx: " Ian Campbell
2011-08-19 13:26 ` [PATCH 16/75] benet: " Ian Campbell
2011-08-19 13:26 ` [PATCH 17/75] bna: " Ian Campbell
2011-08-19 13:26 ` [PATCH 18/75] bnx2: " Ian Campbell
2011-08-19 13:26 ` [PATCH 19/75] bnx2x: " Ian Campbell
2011-08-19 13:26 ` [PATCH 20/75] cassini: " Ian Campbell
2011-08-19 13:26 ` [PATCH 21/75] chelsio: " Ian Campbell
2011-08-19 13:26 ` [PATCH 22/75] cxgb3: " Ian Campbell
2011-08-19 13:26 ` [PATCH 23/75] cxgb4: " Ian Campbell
2011-08-19 13:26 ` [PATCH 24/75] cxgb4vf: " Ian Campbell
2011-08-19 13:26 ` [PATCH 25/75] intel: " Ian Campbell
2011-08-19 13:26 ` [PATCH 26/75] enic: " Ian Campbell
2011-08-19 13:26 ` [PATCH 27/75] forcedeth: " Ian Campbell
2011-08-19 13:27 ` [PATCH 28/75] gianfar: " Ian Campbell
2011-08-19 13:27 ` [PATCH 29/75] greth: " Ian Campbell
2011-08-19 13:27 ` [PATCH 30/75] ibmveth: " Ian Campbell
2011-08-19 13:27 ` [PATCH 31/75] jme: " Ian Campbell
2011-08-19 13:27 ` [PATCH 32/75] ksz884x: " Ian Campbell
2011-08-19 13:27 ` [PATCH 33/75] macvtap: " Ian Campbell
2011-08-19 13:27 ` [PATCH 34/75] mlx4: " Ian Campbell
2011-08-19 13:27 ` [PATCH 35/75] mv643xx: " Ian Campbell
2011-08-19 13:27 ` [PATCH 36/75] myri10ge: " Ian Campbell
2011-08-19 13:27 ` [PATCH 37/75] netxen: " Ian Campbell
2011-08-19 13:27 ` [PATCH 38/75] niu: " Ian Campbell
2011-08-19 13:27 ` [PATCH 39/75] ns83820: " Ian Campbell
2011-08-19 13:27 ` [PATCH 40/75] pasemi: " Ian Campbell
2011-08-19 13:27 ` [PATCH 41/75] qeth: " Ian Campbell
2011-08-19 13:27 ` [PATCH 42/75] qla3xxx: " Ian Campbell
2011-08-19 13:27 ` [PATCH 43/75] qlcnic: " Ian Campbell
2011-08-19 13:27 ` [PATCH 44/75] qlge: " Ian Campbell
2011-08-19 13:27 ` [PATCH 45/75] r8169: " Ian Campbell
2011-08-19 13:27 ` [PATCH 46/75] s2io: " Ian Campbell
2011-08-19 13:27 ` [PATCH 47/75] sfc: " Ian Campbell
2011-08-19 13:27 ` [PATCH 48/75] skge: " Ian Campbell
2011-08-19 13:27 ` [PATCH 49/75] sky2: " Ian Campbell
2011-08-19 13:27 ` [PATCH 50/75] starfire: " Ian Campbell
2011-08-19 13:27 ` [PATCH 51/75] stmmac: " Ian Campbell
2011-08-19 13:27 ` [PATCH 52/75] sungem: " Ian Campbell
2011-08-19 13:27 ` [PATCH 53/75] sunhme: " Ian Campbell
2011-08-19 13:27 ` [PATCH 54/75] tehuti: " Ian Campbell
2011-08-19 13:27 ` [PATCH 55/75] tg3: " Ian Campbell
2011-08-19 13:27 ` [PATCH 56/75] tsi108: " Ian Campbell
2011-08-19 13:27 ` [PATCH 57/75] typhoon: " Ian Campbell
2011-08-19 13:27 ` [PATCH 58/75] via-velocity: " Ian Campbell
2011-08-19 13:27 ` [PATCH 59/75] virtionet: " Ian Campbell
2011-08-19 13:27 ` [PATCH 60/75] vmxnet3: " Ian Campbell
2011-08-19 13:27 ` [PATCH 61/75] vxge: " Ian Campbell
2011-08-19 13:27 ` Ian Campbell [this message]
2011-08-19 13:27 ` [PATCH 63/75] xen: netfront: " Ian Campbell
2011-08-19 13:27 ` [PATCH 64/75] bnx2fc: " Ian Campbell
2011-08-19 13:27 ` [PATCH 65/75] cxgbi: " Ian Campbell
2011-08-19 13:27 ` [PATCH 66/75] fcoe: " Ian Campbell
2011-08-19 13:27 ` [PATCH 67/75] et131x: " Ian Campbell
2011-08-19 17:59   ` Mark Einon
2011-08-19 13:27 ` [PATCH 68/75] hv: netvsc: " Ian Campbell
2011-08-19 13:37   ` Dan Carpenter
2011-08-19 13:46     ` Ian Campbell
2011-08-19 13:50   ` Ian Campbell
2011-08-24 18:30   ` Konrad Rzeszutek Wilk
2011-08-24 21:10     ` Ian Campbell
2011-08-19 13:27 ` [PATCH 69/75] net: only allow paged fragments with the same destructor to be coalesced Ian Campbell
2011-08-19 13:27 ` [PATCH 70/75] net: add paged frag destructor support to kernel_sendpage Ian Campbell
2011-08-19 13:27 ` [PATCH 71/75] sunrpc: use SKB fragment destructors to delay completion until page is released by network stack Ian Campbell
2011-08-19 13:27 ` [PATCH 72/75] signals: move trace header #include to after all others Ian Campbell
2011-08-19 13:27 ` [PATCH 73/75] net: move skb frag kmap functions to skbuff.h Ian Campbell
2011-08-19 13:27 ` [PATCH 74/75] net: add skb_frag_k(un)map convenience functions Ian Campbell
2011-08-19 13:27 ` [PATCH 75/75] net: return a *const* struct page from skb_frag_page Ian Campbell

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=1313760467-8598-62-git-send-email-ian.campbell@citrix.com \
    --to=ian.campbell@citrix.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=xen-devel@lists.xensource.com \
    /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

all inboxes | Powered by JetHome®