]> git.openfabrics.org - ~emulex/for-vlad/compat.git/commitdiff
compat: add skb_frag_dma_map
authorHauke Mehrtens <hauke@hauke-m.de>
Wed, 31 Aug 2011 22:20:11 +0000 (00:20 +0200)
committerLuis R. Rodriguez <mcgrof@qca.qualcomm.com>
Wed, 31 Aug 2011 22:22:53 +0000 (15:22 -0700)
Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
include/linux/compat-3.2.h

index d10495cc17a68455ab1a0ca9d2566a89555c09f9..009e34104b826e7078a154d421145145a74e69c0 100644 (file)
@@ -5,6 +5,9 @@
 
 #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,2,0))
 
+#include <linux/skbuff.h>
+#include <linux/dma-mapping.h>
+
 /*
  * This is not part of The 2.6.37 kernel yet but we
  * we use it to optimize the backport code we
 
 #define PMSG_IS_AUTO(msg)      (((msg).event & PM_EVENT_AUTO) != 0)
 
+/**
+ * skb_frag_page - retrieve the page refered to by a paged fragment
+ * @frag: the paged fragment
+ *
+ * Returns the &struct page associated with @frag.
+ */
+static inline struct page *skb_frag_page(const skb_frag_t *frag)
+{
+       return frag->page;
+}
+
+/**
+ * skb_frag_dma_map - maps a paged fragment via the DMA API
+ * @device: the device to map the fragment to
+ * @frag: the paged fragment to map
+ * @offset: the offset within the fragment (starting at the
+ *          fragment's own offset)
+ * @size: the number of bytes to map
+ * @direction: the direction of the mapping (%PCI_DMA_*)
+ *
+ * Maps the page associated with @frag to @device.
+ */
+static inline dma_addr_t skb_frag_dma_map(struct device *dev,
+                                         const skb_frag_t *frag,
+                                         size_t offset, size_t size,
+                                         enum dma_data_direction dir)
+{
+       return dma_map_page(dev, skb_frag_page(frag),
+                           frag->page_offset + offset, size, dir);
+}
+
 #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(3,2,0)) */
 
 #endif /* LINUX_3_2_COMPAT_H */