Linux Kernel
3.7.1
|
#include <linux/string.h>
#include <linux/bug.h>
#include <linux/mm.h>
#include <asm/types.h>
#include <asm/scatterlist.h>
#include <asm/io.h>
Go to the source code of this file.
Data Structures | |
struct | sg_table |
struct | sg_mapping_iter |
Macros | |
#define | SG_MAGIC 0x87654321 |
#define | sg_is_chain(sg) ((sg)->page_link & 0x01) |
#define | sg_is_last(sg) ((sg)->page_link & 0x02) |
#define | sg_chain_ptr(sg) ((struct scatterlist *) ((sg)->page_link & ~0x03)) |
#define | for_each_sg(sglist, sg, nr, __i) for (__i = 0, sg = (sglist); __i < (nr); __i++, sg = sg_next(sg)) |
#define | SG_MAX_SINGLE_ALLOC (PAGE_SIZE / sizeof(struct scatterlist)) |
#define | SG_MITER_ATOMIC (1 << 0) /* use kmap_atomic */ |
#define | SG_MITER_TO_SG (1 << 1) /* flush back to phys on unmap */ |
#define | SG_MITER_FROM_SG (1 << 2) /* nop */ |
Typedefs | |
typedef struct scatterlist *( | sg_alloc_fn )(unsigned int, gfp_t) |
typedef void( | sg_free_fn )(struct scatterlist *, unsigned int) |
#define for_each_sg | ( | sglist, | |
sg, | |||
nr, | |||
__i | |||
) | for (__i = 0, sg = (sglist); __i < (nr); __i++, sg = sg_next(sg)) |
Definition at line 120 of file scatterlist.h.
#define sg_chain_ptr | ( | sg | ) | ((struct scatterlist *) ((sg)->page_link & ~0x03)) |
Definition at line 44 of file scatterlist.h.
Definition at line 42 of file scatterlist.h.
Definition at line 43 of file scatterlist.h.
#define SG_MAGIC 0x87654321 |
Definition at line 35 of file scatterlist.h.
#define SG_MAX_SINGLE_ALLOC (PAGE_SIZE / sizeof(struct scatterlist)) |
Definition at line 232 of file scatterlist.h.
#define SG_MITER_ATOMIC (1 << 0) /* use kmap_atomic */ |
Definition at line 251 of file scatterlist.h.
#define SG_MITER_FROM_SG (1 << 2) /* nop */ |
Definition at line 253 of file scatterlist.h.
Definition at line 252 of file scatterlist.h.
|
read |
Definition at line 210 of file scatterlist.h.
typedef void( sg_free_fn)(struct scatterlist *, unsigned int) |
Definition at line 211 of file scatterlist.h.
int __sg_alloc_table | ( | struct sg_table * | table, |
unsigned int | nents, | ||
unsigned int | max_ents, | ||
gfp_t | gfp_mask, | ||
sg_alloc_fn * | alloc_fn | ||
) |
__sg_alloc_table - Allocate and initialize an sg table with given allocator : The sg table header to use : Number of entries in sg list : The maximum number of entries the allocator returns per call : GFP allocation mask : Allocator to use
Description: This function returns a long. The allocator is defined to return scatterlist chunks of maximum size . Thus if is bigger than , the scatterlists will be chained in units of .
Notes: If this function returns non-0 (eg failure), the caller must call __sg_free_table() to cleanup any leftover allocations.
Definition at line 243 of file scatterlist.c.
void __sg_free_table | ( | struct sg_table * | table, |
unsigned int | max_ents, | ||
sg_free_fn * | free_fn | ||
) |
__sg_free_table - Free a previously mapped sg table : The sg table header to use : The maximum number of entries per single scatterlist : Free function
Description: Free an sg table previously allocated and setup with __sg_alloc_table(). The value must be identical to that previously used with __sg_alloc_table().
Definition at line 176 of file scatterlist.c.
sg_alloc_table - Allocate and initialize an sg table : The sg table header to use : Number of entries in sg list : GFP allocation mask
Description: Allocate and initialize an sg table. If @ is larger than SG_MAX_SINGLE_ALLOC a chained sg table will be setup.
Definition at line 319 of file scatterlist.c.
int sg_alloc_table_from_pages | ( | struct sg_table * | sgt, |
struct page ** | pages, | ||
unsigned int | n_pages, | ||
unsigned long | offset, | ||
unsigned long | size, | ||
gfp_t | gfp_mask | ||
) |
sg_alloc_table_from_pages - Allocate and initialize an sg table from an array of pages : The sg table header to use : Pointer to an array of page pointers : Number of pages in the pages array : Offset from start of the first page to the start of a buffer : Number of valid bytes in the buffer (after offset) : GFP allocation mask
Description: Allocate and initialize an sg table from a list of pages. Contiguous ranges of the pages are squashed into a single scatterlist node. A user may provide an offset at a start and a size of valid data in a buffer specified by the page array. The returned sg table is released by sg_free_table.
Returns: 0 on success, negative error on failure
Definition at line 352 of file scatterlist.c.
size_t sg_copy_from_buffer | ( | struct scatterlist * | sgl, |
unsigned int | nents, | ||
void * | buf, | ||
size_t | buflen | ||
) |
sg_copy_from_buffer - Copy from a linear buffer to an SG list : The SG list : Number of SG entries : Where to copy from : The number of bytes to copy
Returns the number of copied bytes.
Definition at line 572 of file scatterlist.c.
size_t sg_copy_to_buffer | ( | struct scatterlist * | sgl, |
unsigned int | nents, | ||
void * | buf, | ||
size_t | buflen | ||
) |
sg_copy_to_buffer - Copy from an SG list to a linear buffer : The SG list : Number of SG entries : Where to copy to : The number of bytes to copy
Returns the number of copied bytes.
Definition at line 589 of file scatterlist.c.
sg_free_table - Free a previously allocated sg table : The mapped sg table header
Definition at line 218 of file scatterlist.c.
sg_init_one - Initialize a single entry sg list : SG entry : Virtual address for IO : IO length
Definition at line 125 of file scatterlist.c.
void sg_init_table | ( | struct scatterlist * | sgl, |
unsigned int | nents | ||
) |
sg_init_table - Initialize SG table : The SG table : Number of entries in table
Notes: If this is part of a chained sg table, sg_mark_end() should be used only on the last table part.
Definition at line 104 of file scatterlist.c.
|
read |
sg_last - return the last scatterlist entry in a list : First entry in the scatterlist : Number of entries in the scatterlist
Description: Should only be used casually, it (currently) scans the entire list to get the last entry.
Note that the @ pointer passed in need not be the first one, the important bit is that @ denotes the number of entries that exist from
Definition at line 74 of file scatterlist.c.
bool sg_miter_next | ( | struct sg_mapping_iter * | miter | ) |
sg_miter_next - proceed mapping iterator to the next mapping : sg mapping iter to proceed
Description: Proceeds to the next mapping. should have been started using sg_miter_start(). On successful return, ->page, ->addr and ->length point to the current mapping.
Context: Preemption disabled if SG_MITER_ATOMIC. Preemption must stay disabled till is stopped. May sleep if !SG_MITER_ATOMIC.
Returns: true if contains the next mapping. false if end of sg list is reached.
Definition at line 438 of file scatterlist.c.
void sg_miter_start | ( | struct sg_mapping_iter * | miter, |
struct scatterlist * | sgl, | ||
unsigned int | nents, | ||
unsigned int | flags | ||
) |
sg_miter_start - start mapping iteration over a sg list : sg mapping iter to be started : sg list to iterate over : number of sg entries
Description: Starts mapping iterator .
Context: Don't care.
Definition at line 408 of file scatterlist.c.
void sg_miter_stop | ( | struct sg_mapping_iter * | miter | ) |
sg_miter_stop - stop mapping iteration : sg mapping iter to be stopped
Description: Stops mapping iterator . should have been started started using sg_miter_start(). A stopped iteration can be resumed by calling sg_miter_next() on it. This is useful when resources (kmap) need to be released during iteration.
Context: Preemption disabled if the SG_MITER_ATOMIC is set. Don't care otherwise.
Definition at line 489 of file scatterlist.c.
int sg_nents | ( | struct scatterlist * | sg | ) |
sg_nents - return total count of entries in scatterlist : The scatterlist
Description: Allows to know how many entries are in sg, taking into acount chaining as well
Definition at line 50 of file scatterlist.c.
|
read |