netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ian Campbell <ian.campbell-Sxgqhf6Nn4DQT0dZR+AlfA@public.gmane.org>
To: netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Cc: "Ian Campbell"
	<ian.campbell-Sxgqhf6Nn4DQT0dZR+AlfA@public.gmane.org>,
	"Eric Dumazet"
	<eric.dumazet-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	"James E.J. Bottomley"
	<JBottomley-bzQdu9zFT3WakBO8gow8eQ@public.gmane.org>,
	"Michał Mirosław"
	<mirq-linux-CoA6ZxLDdyEEUmgCuDUIdw@public.gmane.org>,
	devel-s9riP+hp16TNLxjTenLetw@public.gmane.org,
	"Arnaldo Carvalho de Melo"
	<acme-f8uhVLnGfZaxAyOMLChx1axOck334EZe@public.gmane.org>,
	linux-scsi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	"David S. Miller" <davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org>,
	"Tom Herbert" <therbert-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org>
Subject: [PATCH 73/75] net: move skb frag kmap functions to skbuff.h
Date: Fri, 19 Aug 2011 14:27:45 +0100	[thread overview]
Message-ID: <1313760467-8598-73-git-send-email-ian.campbell@citrix.com> (raw)
In-Reply-To: <1313760393.5010.356.camel-o4Be2W7LfRlXesXXhkcM7miJhflN2719@public.gmane.org>

The usage is open-coded in drivers/scsi/fcoe/fcoe.c and net/appletalk/ddp.c
uses an out-of-directory local include of "../core/kmap_skb.h".

Rename functions k(un)map_skb_frag to skb_frag_k(un)map_atomic to avoid
confusion with shortly to be introduced skb_frag_k(un)map.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Cc: Robert Love <robert.w.love@intel.com>
Cc: "James E.J. Bottomley" <JBottomley@parallels.com>
Cc: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Eric Dumazet <eric.dumazet@gmail.com>
Cc: "Michał Mirosław" <mirq-linux@rere.qmqm.pl>
Cc: Tom Herbert <therbert@google.com>
Cc: devel@open-fcoe.org
Cc: linux-scsi@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Cc: netdev@vger.kernel.org
---
 drivers/scsi/fcoe/fcoe.c |    5 ++---
 include/linux/skbuff.h   |   19 +++++++++++++++++++
 net/appletalk/ddp.c      |    5 ++---
 net/core/kmap_skb.h      |   19 -------------------
 net/core/skbuff.c        |   35 +++++++++++++++++------------------
 5 files changed, 40 insertions(+), 43 deletions(-)
 delete mode 100644 net/core/kmap_skb.h

diff --git a/drivers/scsi/fcoe/fcoe.c b/drivers/scsi/fcoe/fcoe.c
index 3416ab6..857e281 100644
--- a/drivers/scsi/fcoe/fcoe.c
+++ b/drivers/scsi/fcoe/fcoe.c
@@ -1514,8 +1514,7 @@ int fcoe_xmit(struct fc_lport *lport, struct fc_frame *fp)
 			return -ENOMEM;
 		}
 		frag = &skb_shinfo(skb)->frags[skb_shinfo(skb)->nr_frags - 1];
-		cp = kmap_atomic(skb_frag_page(frag), KM_SKB_DATA_SOFTIRQ)
-			+ frag->page_offset;
+		cp = skb_frag_kmap_atomic(frag) + frag->page_offset;
 	} else {
 		cp = (struct fcoe_crc_eof *)skb_put(skb, tlen);
 	}
@@ -1525,7 +1524,7 @@ int fcoe_xmit(struct fc_lport *lport, struct fc_frame *fp)
 	cp->fcoe_crc32 = cpu_to_le32(~crc);
 
 	if (skb_is_nonlinear(skb)) {
-		kunmap_atomic(cp, KM_SKB_DATA_SOFTIRQ);
+		skb_frag_kunmap_atomic(frag);
 		cp = NULL;
 	}
 
diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index 665a881..73d8f7a 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -29,6 +29,7 @@
 #include <linux/rcupdate.h>
 #include <linux/dmaengine.h>
 #include <linux/hrtimer.h>
+#include <linux/highmem.h>
 #include <linux/dma-mapping.h>
 
 /* Don't change this without changing skb_csum_unnecessary! */
@@ -1819,6 +1820,24 @@ static inline void skb_frag_set_page(struct sk_buff *skb, int f,
 	__skb_frag_set_page(&skb_shinfo(skb)->frags[f], page);
 }
 
+static inline void *skb_frag_kmap_atomic(const skb_frag_t *frag)
+{
+#ifdef CONFIG_HIGHMEM
+	BUG_ON(in_irq());
+
+	local_bh_disable();
+#endif
+	return kmap_atomic(skb_frag_page(frag), KM_SKB_DATA_SOFTIRQ);
+}
+
+static inline void skb_frag_kunmap_atomic(void *vaddr)
+{
+	kunmap_atomic(vaddr, KM_SKB_DATA_SOFTIRQ);
+#ifdef CONFIG_HIGHMEM
+	local_bh_enable();
+#endif
+}
+
 /**
  * skb_frag_dma_map - maps a paged fragment via the DMA API
  * @device: the device to map the fragment to
diff --git a/net/appletalk/ddp.c b/net/appletalk/ddp.c
index b1fe7c3..4a1b2bc 100644
--- a/net/appletalk/ddp.c
+++ b/net/appletalk/ddp.c
@@ -63,7 +63,6 @@
 #include <net/tcp_states.h>
 #include <net/route.h>
 #include <linux/atalk.h>
-#include "../core/kmap_skb.h"
 
 struct datalink_proto *ddp_dl, *aarp_dl;
 static const struct proto_ops atalk_dgram_ops;
@@ -961,10 +960,10 @@ static unsigned long atalk_sum_skb(const struct sk_buff *skb, int offset,
 
 			if (copy > len)
 				copy = len;
-			vaddr = kmap_skb_frag(frag);
+			vaddr = skb_frag_kmap_atomic(frag);
 			sum = atalk_sum_partial(vaddr + frag->page_offset +
 						  offset - start, copy, sum);
-			kunmap_skb_frag(vaddr);
+			skb_frag_kunmap_atomic(vaddr);
 
 			if (!(len -= copy))
 				return sum;
diff --git a/net/core/kmap_skb.h b/net/core/kmap_skb.h
deleted file mode 100644
index 81e1ed7..0000000
--- a/net/core/kmap_skb.h
+++ /dev/null
@@ -1,19 +0,0 @@
-#include <linux/highmem.h>
-
-static inline void *kmap_skb_frag(const skb_frag_t *frag)
-{
-#ifdef CONFIG_HIGHMEM
-	BUG_ON(in_irq());
-
-	local_bh_disable();
-#endif
-	return kmap_atomic(skb_frag_page(frag), KM_SKB_DATA_SOFTIRQ);
-}
-
-static inline void kunmap_skb_frag(void *vaddr)
-{
-	kunmap_atomic(vaddr, KM_SKB_DATA_SOFTIRQ);
-#ifdef CONFIG_HIGHMEM
-	local_bh_enable();
-#endif
-}
diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index e294c34..d09d312 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -69,8 +69,6 @@
 #include <asm/system.h>
 #include <trace/events/skb.h>
 
-#include "kmap_skb.h"
-
 static struct kmem_cache *skbuff_head_cache __read_mostly;
 static struct kmem_cache *skbuff_fclone_cache __read_mostly;
 
@@ -649,10 +647,10 @@ static int skb_copy_ubufs(struct sk_buff *skb, gfp_t gfp_mask)
 			}
 			return -ENOMEM;
 		}
-		vaddr = kmap_skb_frag(&skb_shinfo(skb)->frags[i]);
+		vaddr = skb_frag_kmap_atomic(&skb_shinfo(skb)->frags[i]);
 		memcpy(page_address(page),
 		       vaddr + f->page_offset, f->size);
-		kunmap_skb_frag(vaddr);
+		skb_frag_kunmap_atomic(vaddr);
 		page->private = (unsigned long)head;
 		head = page;
 	}
@@ -1434,15 +1432,16 @@ int skb_copy_bits(const struct sk_buff *skb, int offset, void *to, int len)
 		end = start + skb_shinfo(skb)->frags[i].size;
 		if ((copy = end - offset) > 0) {
 			u8 *vaddr;
+			skb_frag_t *frag = &skb_shinfo(skb)->frags[i];
 
 			if (copy > len)
 				copy = len;
 
-			vaddr = kmap_skb_frag(&skb_shinfo(skb)->frags[i]);
+			vaddr = skb_frag_kmap_atomic(frag);
 			memcpy(to,
-			       vaddr + skb_shinfo(skb)->frags[i].page_offset+
-			       offset - start, copy);
-			kunmap_skb_frag(vaddr);
+			       vaddr + frag->page_offset + offset - start,
+			       copy);
+			skb_frag_kunmap_atomic(vaddr);
 
 			if ((len -= copy) == 0)
 				return 0;
@@ -1747,10 +1746,10 @@ int skb_store_bits(struct sk_buff *skb, int offset, const void *from, int len)
 			if (copy > len)
 				copy = len;
 
-			vaddr = kmap_skb_frag(frag);
+			vaddr = skb_frag_kmap_atomic(frag);
 			memcpy(vaddr + frag->page_offset + offset - start,
 			       from, copy);
-			kunmap_skb_frag(vaddr);
+			skb_frag_kunmap_atomic(vaddr);
 
 			if ((len -= copy) == 0)
 				return 0;
@@ -1821,10 +1820,10 @@ __wsum skb_checksum(const struct sk_buff *skb, int offset,
 
 			if (copy > len)
 				copy = len;
-			vaddr = kmap_skb_frag(frag);
+			vaddr = skb_frag_kmap_atomic(frag);
 			csum2 = csum_partial(vaddr + frag->page_offset +
 					     offset - start, copy, 0);
-			kunmap_skb_frag(vaddr);
+			skb_frag_kunmap_atomic(vaddr);
 			csum = csum_block_add(csum, csum2, pos);
 			if (!(len -= copy))
 				return csum;
@@ -1896,12 +1895,12 @@ __wsum skb_copy_and_csum_bits(const struct sk_buff *skb, int offset,
 
 			if (copy > len)
 				copy = len;
-			vaddr = kmap_skb_frag(frag);
+			vaddr = skb_frag_kmap_atomic(frag);
 			csum2 = csum_partial_copy_nocheck(vaddr +
 							  frag->page_offset +
 							  offset - start, to,
 							  copy, 0);
-			kunmap_skb_frag(vaddr);
+			skb_frag_kunmap_atomic(vaddr);
 			csum = csum_block_add(csum, csum2, pos);
 			if (!(len -= copy))
 				return csum;
@@ -2422,7 +2421,7 @@ next_skb:
 
 		if (abs_offset < block_limit) {
 			if (!st->frag_data)
-				st->frag_data = kmap_skb_frag(frag);
+				st->frag_data = skb_frag_kmap_atomic(frag);
 
 			*data = (u8 *) st->frag_data + frag->page_offset +
 				(abs_offset - st->stepped_offset);
@@ -2431,7 +2430,7 @@ next_skb:
 		}
 
 		if (st->frag_data) {
-			kunmap_skb_frag(st->frag_data);
+			skb_frag_kunmap_atomic(st->frag_data);
 			st->frag_data = NULL;
 		}
 
@@ -2440,7 +2439,7 @@ next_skb:
 	}
 
 	if (st->frag_data) {
-		kunmap_skb_frag(st->frag_data);
+		skb_frag_kunmap_atomic(st->frag_data);
 		st->frag_data = NULL;
 	}
 
@@ -2468,7 +2467,7 @@ EXPORT_SYMBOL(skb_seq_read);
 void skb_abort_seq_read(struct skb_seq_state *st)
 {
 	if (st->frag_data)
-		kunmap_skb_frag(st->frag_data);
+		skb_frag_kunmap_atomic(st->frag_data);
 }
 EXPORT_SYMBOL(skb_abort_seq_read);
 
-- 
1.7.2.5

_______________________________________________
devel mailing list
devel@open-fcoe.org
https://lists.open-fcoe.org/mailman/listinfo/devel

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

Thread overview: 90+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-08-19 13:26 [PATCH/RFC v3 0/75] enable SKB paged fragment lifetime visibility Ian Campbell
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 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 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 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 ` [PATCH 62/75] xen: netback: " Ian Campbell
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
     [not found] ` <1313760393.5010.356.camel-o4Be2W7LfRlXesXXhkcM7miJhflN2719@public.gmane.org>
2011-08-19 13:26   ` [PATCH 20/75] cassini: " Ian Campbell
2011-08-19 13:27   ` [PATCH 29/75] greth: " Ian Campbell
2011-08-19 13:27   ` [PATCH 40/75] pasemi: " Ian Campbell
2011-08-19 13:27   ` [PATCH 66/75] fcoe: " Ian Campbell
2011-08-19 13:27   ` Ian Campbell [this message]
2011-08-19 13:29   ` [PATCH/RFC v3 0/75] enable SKB paged fragment lifetime visibility David Miller
2011-08-19 13:34     ` David Miller
2011-08-19 13:45       ` Ian Campbell
2011-08-19 14:04       ` David Miller
2011-08-19 14:30         ` Ian Campbell
2011-08-19 13:27 ` [PATCH 67/75] et131x: convert to SKB paged frag API 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 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-73-git-send-email-ian.campbell@citrix.com \
    --to=ian.campbell-sxgqhf6nn4dqt0dzr+alfa@public.gmane.org \
    --cc=JBottomley-bzQdu9zFT3WakBO8gow8eQ@public.gmane.org \
    --cc=acme-f8uhVLnGfZaxAyOMLChx1axOck334EZe@public.gmane.org \
    --cc=davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org \
    --cc=devel-s9riP+hp16TNLxjTenLetw@public.gmane.org \
    --cc=eric.dumazet-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    --cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-scsi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=mirq-linux-CoA6ZxLDdyEEUmgCuDUIdw@public.gmane.org \
    --cc=netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=therbert-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.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).