Sunday 29 September 2013

scatter-gather list in Linux kernel device driver

scatter-gather list in Linux kernel device driver

I am working on a device driver that has access to a scatter-gather list
(sg) element. I am able to extract the data out of it and store it in an
allocated buffer using sg_copy_to_buffer. Now, my idea is to create a new
scatterlist and copy from this buffer into the new scatterlist I create
(ofcourse this is done later) and return this new scatterlist back to the
kernel. (This is for performance metrics, etc.) I tried searching online
for documentation to use scatterlist, etc. but to no avail. What I
typically am doing:
char *buffer = kmalloc (***);
struct scatterlist *sglist = kmalloc (sizeof (struct scatterlist)...);
sg_init_one(sglist, buffer, BUFFER_SIZE);
sg_copy_to_buffer (inp_sglist, inp_sglist_len, buffer);
*** Later ***
sg_copy_from_buffer (sglist, 1, buffer);
Is there a good documentation to help me map my scatterlist to a virtual
buffer? I tried looking at http://lwn.net/Articles/256368/
http://www.linuxjournal.com/article/7104 etc.
Any help or pointers would be appreciated!

No comments:

Post a Comment