FreeBSD kernel kern code
subr_sglist.c File Reference
#include <sys/cdefs.h>
#include <sys/param.h>
#include <sys/kernel.h>
#include <sys/bio.h>
#include <sys/malloc.h>
#include <sys/mbuf.h>
#include <sys/proc.h>
#include <sys/sglist.h>
#include <sys/uio.h>
#include <vm/vm.h>
#include <vm/vm_page.h>
#include <vm/pmap.h>
#include <vm/vm_map.h>
#include <sys/ktr.h>
Include dependency graph for subr_sglist.c:

Go to the source code of this file.

Data Structures

struct  sgsave
 

Macros

#define SGLIST_SAVE(sg, sgsave)
 
#define SGLIST_RESTORE(sg, sgsave)
 

Functions

 __FBSDID ("$FreeBSD$")
 
static MALLOC_DEFINE (M_SGLIST, "sglist", "scatter/gather lists")
 
static __inline int _sglist_append_range (struct sglist *sg, struct sglist_seg **ssp, vm_paddr_t paddr, size_t len)
 
static __inline int _sglist_append_buf (struct sglist *sg, void *buf, size_t len, pmap_t pmap, size_t *donep)
 
int sglist_count (void *buf, size_t len)
 
int sglist_count_vmpages (vm_page_t *m, size_t pgoff, size_t len)
 
int sglist_count_mbuf_epg (struct mbuf *m, size_t off, size_t len)
 
struct sglist * sglist_alloc (int nsegs, int mflags)
 
void sglist_free (struct sglist *sg)
 
int sglist_append (struct sglist *sg, void *buf, size_t len)
 
int sglist_append_bio (struct sglist *sg, struct bio *bp)
 
int sglist_append_phys (struct sglist *sg, vm_paddr_t paddr, size_t len)
 
int sglist_append_mbuf_epg (struct sglist *sg, struct mbuf *m, size_t off, size_t len)
 
int sglist_append_mbuf (struct sglist *sg, struct mbuf *m0)
 
int sglist_append_single_mbuf (struct sglist *sg, struct mbuf *m)
 
int sglist_append_vmpages (struct sglist *sg, vm_page_t *m, size_t pgoff, size_t len)
 
int sglist_append_user (struct sglist *sg, void *buf, size_t len, struct thread *td)
 
int sglist_append_sglist (struct sglist *sg, struct sglist *source, size_t offset, size_t length)
 
int sglist_append_uio (struct sglist *sg, struct uio *uio)
 
int sglist_consume_uio (struct sglist *sg, struct uio *uio, size_t resid)
 
struct sglist * sglist_build (void *buf, size_t len, int mflags)
 
struct sglist * sglist_clone (struct sglist *sg, int mflags)
 
size_t sglist_length (struct sglist *sg)
 
int sglist_split (struct sglist *original, struct sglist **head, size_t length, int mflags)
 
int sglist_join (struct sglist *first, struct sglist *second)
 
int sglist_slice (struct sglist *original, struct sglist **slice, size_t offset, size_t length, int mflags)
 

Macro Definition Documentation

◆ SGLIST_RESTORE

#define SGLIST_RESTORE (   sg,
  sgsave 
)
Value:
do { \
(sg)->sg_nseg = (sgsave).sg_nseg; \
if ((sgsave).sg_nseg > 0) \
(sg)->sg_segs[(sgsave).sg_nseg - 1].ss_len = (sgsave).ss_len; \
} while (0)

Definition at line 74 of file subr_sglist.c.

◆ SGLIST_SAVE

#define SGLIST_SAVE (   sg,
  sgsave 
)
Value:
do { \
(sgsave).sg_nseg = (sg)->sg_nseg; \
if ((sgsave).sg_nseg > 0) \
(sgsave).ss_len = (sg)->sg_segs[(sgsave).sg_nseg - 1].ss_len; \
else \
(sgsave).ss_len = 0; \
} while (0)

Definition at line 66 of file subr_sglist.c.

Function Documentation

◆ __FBSDID()

__FBSDID ( "$FreeBSD$"  )

◆ _sglist_append_buf()

static __inline int _sglist_append_buf ( struct sglist *  sg,
void *  buf,
size_t  len,
pmap_t  pmap,
size_t *  donep 
)
static

Definition at line 111 of file subr_sglist.c.

References _sglist_append_range(), and buf.

Referenced by sglist_append(), sglist_append_uio(), sglist_append_user(), and sglist_consume_uio().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _sglist_append_range()

static __inline int _sglist_append_range ( struct sglist *  sg,
struct sglist_seg **  ssp,
vm_paddr_t  paddr,
size_t  len 
)
static

Definition at line 86 of file subr_sglist.c.

Referenced by _sglist_append_buf(), sglist_append_phys(), sglist_append_sglist(), and sglist_append_vmpages().

Here is the caller graph for this function:

◆ MALLOC_DEFINE()

static MALLOC_DEFINE ( M_SGLIST  ,
"sglist"  ,
"scatter/gather lists"   
)
static

◆ sglist_alloc()

struct sglist * sglist_alloc ( int  nsegs,
int  mflags 
)

Definition at line 284 of file subr_sglist.c.

References malloc().

Referenced by sglist_build(), sglist_clone(), sglist_slice(), and sglist_split().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ sglist_append()

int sglist_append ( struct sglist *  sg,
void *  buf,
size_t  len 
)

Definition at line 316 of file subr_sglist.c.

References _sglist_append_buf(), buf, SGLIST_RESTORE, and SGLIST_SAVE.

Referenced by sglist_append_bio(), sglist_append_mbuf(), sglist_append_mbuf_epg(), sglist_append_single_mbuf(), and sglist_build().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ sglist_append_bio()

int sglist_append_bio ( struct sglist *  sg,
struct bio *  bp 
)

Definition at line 337 of file subr_sglist.c.

References sglist_append(), and sglist_append_vmpages().

Here is the call graph for this function:

◆ sglist_append_mbuf()

int sglist_append_mbuf ( struct sglist *  sg,
struct mbuf *  m0 
)

Definition at line 441 of file subr_sglist.c.

References sglist_append(), sglist_append_mbuf_epg(), SGLIST_RESTORE, and SGLIST_SAVE.

Here is the call graph for this function:

◆ sglist_append_mbuf_epg()

int sglist_append_mbuf_epg ( struct sglist *  sg,
struct mbuf *  m,
size_t  off,
size_t  len 
)

Definition at line 384 of file subr_sglist.c.

References sglist_append(), and sglist_append_phys().

Referenced by sglist_append_mbuf(), and sglist_append_single_mbuf().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ sglist_append_phys()

int sglist_append_phys ( struct sglist *  sg,
vm_paddr_t  paddr,
size_t  len 
)

Definition at line 354 of file subr_sglist.c.

References _sglist_append_range(), SGLIST_RESTORE, SGLIST_SAVE, and sgsave::ss_len.

Referenced by sglist_append_mbuf_epg().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ sglist_append_sglist()

int sglist_append_sglist ( struct sglist *  sg,
struct sglist *  source,
size_t  offset,
size_t  length 
)

Definition at line 556 of file subr_sglist.c.

References _sglist_append_range(), SGLIST_RESTORE, and SGLIST_SAVE.

Here is the call graph for this function:

◆ sglist_append_single_mbuf()

int sglist_append_single_mbuf ( struct sglist *  sg,
struct mbuf *  m 
)

Definition at line 475 of file subr_sglist.c.

References sglist_append(), and sglist_append_mbuf_epg().

Here is the call graph for this function:

◆ sglist_append_uio()

int sglist_append_uio ( struct sglist *  sg,
struct uio *  uio 
)

Definition at line 599 of file subr_sglist.c.

References _sglist_append_buf(), SGLIST_RESTORE, and SGLIST_SAVE.

Here is the call graph for this function:

◆ sglist_append_user()

int sglist_append_user ( struct sglist *  sg,
void *  buf,
size_t  len,
struct thread *  td 
)

Definition at line 535 of file subr_sglist.c.

References _sglist_append_buf(), buf, SGLIST_RESTORE, and SGLIST_SAVE.

Here is the call graph for this function:

◆ sglist_append_vmpages()

int sglist_append_vmpages ( struct sglist *  sg,
vm_page_t *  m,
size_t  pgoff,
size_t  len 
)

Definition at line 490 of file subr_sglist.c.

References _sglist_append_range(), SGLIST_RESTORE, and SGLIST_SAVE.

Referenced by sglist_append_bio().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ sglist_build()

struct sglist * sglist_build ( void *  buf,
size_t  len,
int  mflags 
)

Definition at line 697 of file subr_sglist.c.

References buf, sglist_alloc(), sglist_append(), sglist_count(), and sglist_free().

Here is the call graph for this function:

◆ sglist_clone()

struct sglist * sglist_clone ( struct sglist *  sg,
int  mflags 
)

Definition at line 720 of file subr_sglist.c.

References sglist_alloc().

Here is the call graph for this function:

◆ sglist_consume_uio()

int sglist_consume_uio ( struct sglist *  sg,
struct uio *  uio,
size_t  resid 
)

Definition at line 647 of file subr_sglist.c.

References _sglist_append_buf().

Here is the call graph for this function:

◆ sglist_count()

int sglist_count ( void *  buf,
size_t  len 
)

Definition at line 172 of file subr_sglist.c.

References buf.

Referenced by sglist_build(), and sglist_count_mbuf_epg().

Here is the caller graph for this function:

◆ sglist_count_mbuf_epg()

int sglist_count_mbuf_epg ( struct mbuf *  m,
size_t  off,
size_t  len 
)

Definition at line 226 of file subr_sglist.c.

References sglist_count().

Here is the call graph for this function:

◆ sglist_count_vmpages()

int sglist_count_vmpages ( vm_page_t *  m,
size_t  pgoff,
size_t  len 
)

Definition at line 201 of file subr_sglist.c.

◆ sglist_free()

void sglist_free ( struct sglist *  sg)

Definition at line 300 of file subr_sglist.c.

References free().

Referenced by sglist_build().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ sglist_join()

int sglist_join ( struct sglist *  first,
struct sglist *  second 
)

Definition at line 847 of file subr_sglist.c.

◆ sglist_length()

size_t sglist_length ( struct sglist *  sg)

Definition at line 740 of file subr_sglist.c.

◆ sglist_slice()

int sglist_slice ( struct sglist *  original,
struct sglist **  slice,
size_t  offset,
size_t  length,
int  mflags 
)

Definition at line 900 of file subr_sglist.c.

References count, and sglist_alloc().

Here is the call graph for this function:

◆ sglist_split()

int sglist_split ( struct sglist *  original,
struct sglist **  head,
size_t  length,
int  mflags 
)

Definition at line 769 of file subr_sglist.c.

References count, and sglist_alloc().

Here is the call graph for this function: