-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
yaml --- r: 111599 b: refs/heads/master c: a40c24a h: refs/heads/master i: 111597: 58b3a98 111595: 69a0e98 111591: 2e5b4dd 111583: 52b50f0 v: v3
- Loading branch information
David S. Miller
committed
Sep 11, 2008
1 parent
b71cd38
commit 24afc36
Showing
4 changed files
with
76 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
--- | ||
refs/heads/master: 271bff7afbb2cbaa81e744006ad2fff1f3e10b1b | ||
refs/heads/master: a40c24a13366e324bc0ff8c3bb107db89312c984 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
/* skb_dma_map.c: DMA mapping helpers for socket buffers. | ||
* | ||
* Copyright (C) David S. Miller <davem@davemloft.net> | ||
*/ | ||
|
||
#include <linux/kernel.h> | ||
#include <linux/module.h> | ||
#include <linux/dma-mapping.h> | ||
#include <linux/skbuff.h> | ||
|
||
int skb_dma_map(struct device *dev, struct sk_buff *skb, | ||
enum dma_data_direction dir) | ||
{ | ||
struct skb_shared_info *sp = skb_shinfo(skb); | ||
dma_addr_t map; | ||
int i; | ||
|
||
map = dma_map_single(dev, skb->data, | ||
skb_headlen(skb), dir); | ||
if (dma_mapping_error(dev, map)) | ||
goto out_err; | ||
|
||
sp->dma_maps[0] = map; | ||
for (i = 0; i < sp->nr_frags; i++) { | ||
skb_frag_t *fp = &sp->frags[i]; | ||
|
||
map = dma_map_page(dev, fp->page, fp->page_offset, | ||
fp->size, dir); | ||
if (dma_mapping_error(dev, map)) | ||
goto unwind; | ||
sp->dma_maps[i + 1] = map; | ||
} | ||
sp->num_dma_maps = i + 1; | ||
|
||
return 0; | ||
|
||
unwind: | ||
while (i-- >= 0) { | ||
skb_frag_t *fp = &sp->frags[i]; | ||
|
||
dma_unmap_page(dev, sp->dma_maps[i + 1], | ||
fp->size, dir); | ||
} | ||
dma_unmap_single(dev, sp->dma_maps[0], | ||
skb_headlen(skb), dir); | ||
out_err: | ||
return -ENOMEM; | ||
} | ||
EXPORT_SYMBOL(skb_dma_map); | ||
|
||
void skb_dma_unmap(struct device *dev, struct sk_buff *skb, | ||
enum dma_data_direction dir) | ||
{ | ||
struct skb_shared_info *sp = skb_shinfo(skb); | ||
int i; | ||
|
||
dma_unmap_single(dev, sp->dma_maps[0], | ||
skb_headlen(skb), dir); | ||
for (i = 0; i < sp->nr_frags; i++) { | ||
skb_frag_t *fp = &sp->frags[i]; | ||
|
||
dma_unmap_page(dev, sp->dma_maps[i + 1], | ||
fp->size, dir); | ||
} | ||
} | ||
EXPORT_SYMBOL(skb_dma_unmap); |