1a5f7a14bSFrançois Tigeot.\" 2a5f7a14bSFrançois Tigeot.\" Copyright (c) 2009 Advanced Computing Technologies LLC 3a5f7a14bSFrançois Tigeot.\" Written by: John H. Baldwin <jhb@FreeBSD.org> 4a5f7a14bSFrançois Tigeot.\" All rights reserved. 5a5f7a14bSFrançois Tigeot.\" 6a5f7a14bSFrançois Tigeot.\" Redistribution and use in source and binary forms, with or without 7a5f7a14bSFrançois Tigeot.\" modification, are permitted provided that the following conditions 8a5f7a14bSFrançois Tigeot.\" are met: 9a5f7a14bSFrançois Tigeot.\" 1. Redistributions of source code must retain the above copyright 10a5f7a14bSFrançois Tigeot.\" notice, this list of conditions and the following disclaimer. 11a5f7a14bSFrançois Tigeot.\" 2. Redistributions in binary form must reproduce the above copyright 12a5f7a14bSFrançois Tigeot.\" notice, this list of conditions and the following disclaimer in the 13a5f7a14bSFrançois Tigeot.\" documentation and/or other materials provided with the distribution. 14a5f7a14bSFrançois Tigeot.\" 15a5f7a14bSFrançois Tigeot.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 16a5f7a14bSFrançois Tigeot.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17a5f7a14bSFrançois Tigeot.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18a5f7a14bSFrançois Tigeot.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 19a5f7a14bSFrançois Tigeot.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 20a5f7a14bSFrançois Tigeot.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 21a5f7a14bSFrançois Tigeot.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 22a5f7a14bSFrançois Tigeot.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 23a5f7a14bSFrançois Tigeot.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24a5f7a14bSFrançois Tigeot.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25a5f7a14bSFrançois Tigeot.\" SUCH DAMAGE. 26a5f7a14bSFrançois Tigeot.\" 27a5f7a14bSFrançois Tigeot.\" $FreeBSD: src/share/man/man9/sglist.9,v 1.4 2010/07/31 10:01:15 joel Exp $ 28a5f7a14bSFrançois Tigeot.\" 29a5f7a14bSFrançois Tigeot.Dd December 8, 2012 30a5f7a14bSFrançois Tigeot.Dt SGLIST 9 31a5f7a14bSFrançois Tigeot.Os 32a5f7a14bSFrançois Tigeot.Sh NAME 33a5f7a14bSFrançois Tigeot.Nm sglist , 34a5f7a14bSFrançois Tigeot.Nm sglist_alloc , 35a5f7a14bSFrançois Tigeot.Nm sglist_append , 36a5f7a14bSFrançois Tigeot.Nm sglist_append_mbuf , 37a5f7a14bSFrançois Tigeot.Nm sglist_append_phys , 38a5f7a14bSFrançois Tigeot.Nm sglist_append_uio , 39a5f7a14bSFrançois Tigeot.Nm sglist_append_user , 40a5f7a14bSFrançois Tigeot.Nm sglist_build , 41a5f7a14bSFrançois Tigeot.Nm sglist_clone , 42a5f7a14bSFrançois Tigeot.Nm sglist_consume_uio , 43a5f7a14bSFrançois Tigeot.Nm sglist_count , 44a5f7a14bSFrançois Tigeot.Nm sglist_free , 45a5f7a14bSFrançois Tigeot.Nm sglist_hold , 46a5f7a14bSFrançois Tigeot.Nm sglist_init , 47a5f7a14bSFrançois Tigeot.Nm sglist_join , 48a5f7a14bSFrançois Tigeot.Nm sglist_length , 49a5f7a14bSFrançois Tigeot.Nm sglist_reset , 50a5f7a14bSFrançois Tigeot.Nm sglist_slice , 51a5f7a14bSFrançois Tigeot.Nm sglist_split 52a5f7a14bSFrançois Tigeot.Nd manage a scatter/gather list of physical memory addresses 53a5f7a14bSFrançois Tigeot.Sh SYNOPSIS 54a5f7a14bSFrançois Tigeot.In sys/types.h 559b053063SSascha Wildner.In sys/thread.h 56a5f7a14bSFrançois Tigeot.In sys/sglist.h 57a5f7a14bSFrançois Tigeot.Ft struct sglist * 58a5f7a14bSFrançois Tigeot.Fn sglist_alloc "int nsegs" "int mflags" 59a5f7a14bSFrançois Tigeot.Ft int 60a5f7a14bSFrançois Tigeot.Fn sglist_append "struct sglist *sg" "void *buf" "size_t len" 61a5f7a14bSFrançois Tigeot.Ft int 62a5f7a14bSFrançois Tigeot.Fn sglist_append_mbuf "struct sglist *sg" "struct mbuf *m" 63a5f7a14bSFrançois Tigeot.Ft int 64a5f7a14bSFrançois Tigeot.Fn sglist_append_phys "struct sglist *sg" "vm_paddr_t paddr" "size_t len" 65a5f7a14bSFrançois Tigeot.Ft int 66a5f7a14bSFrançois Tigeot.Fn sglist_append_uio "struct sglist *sg" "struct uio *uio" 67a5f7a14bSFrançois Tigeot.Ft int 68a5f7a14bSFrançois Tigeot.Fn sglist_append_user "struct sglist *sg" "void *buf" "size_t len" "struct thread *td" 69a5f7a14bSFrançois Tigeot.Ft struct sglist * 70a5f7a14bSFrançois Tigeot.Fn sglist_build "void *buf" "size_t len" "int mflags" 71a5f7a14bSFrançois Tigeot.Ft struct sglist * 72a5f7a14bSFrançois Tigeot.Fn sglist_clone "struct sglist *sg" "int mflags" 73a5f7a14bSFrançois Tigeot.Ft int 74a5f7a14bSFrançois Tigeot.Fn sglist_consume_uio "struct sglist *sg" "struct uio *uio" "size_t resid" 75a5f7a14bSFrançois Tigeot.Ft int 76a5f7a14bSFrançois Tigeot.Fn sglist_count "void *buf" "size_t len" 77a5f7a14bSFrançois Tigeot.Ft void 78a5f7a14bSFrançois Tigeot.Fn sglist_free "struct sglist *sg" 79a5f7a14bSFrançois Tigeot.Ft struct sglist * 80a5f7a14bSFrançois Tigeot.Fn sglist_hold "struct sglist *sg" 81a5f7a14bSFrançois Tigeot.Ft void 82*46a468d4SSascha Wildner.Fn sglist_init "struct sglist *sg" "u_short maxsegs" "struct sglist_seg *segs" 83a5f7a14bSFrançois Tigeot.Ft int 84a5f7a14bSFrançois Tigeot.Fn sglist_join "struct sglist *first" "struct sglist *second" 85a5f7a14bSFrançois Tigeot.Ft size_t 86a5f7a14bSFrançois Tigeot.Fn sglist_length "struct sglist *sg" 87a5f7a14bSFrançois Tigeot.Ft void 88a5f7a14bSFrançois Tigeot.Fn sglist_reset "struct sglist *sg" 89a5f7a14bSFrançois Tigeot.Ft int 90a5f7a14bSFrançois Tigeot.Fn sglist_slice "struct sglist *original" "struct sglist **slice" "size_t offset" "size_t length" "int mflags" 91a5f7a14bSFrançois Tigeot.Ft int 92a5f7a14bSFrançois Tigeot.Fn sglist_split "struct sglist *original" "struct sglist **head" "size_t length" "int mflags" 93a5f7a14bSFrançois Tigeot.Sh DESCRIPTION 94a5f7a14bSFrançois TigeotThe 95a5f7a14bSFrançois Tigeot.Nm 96a5f7a14bSFrançois TigeotAPI manages physical address ranges. 97a5f7a14bSFrançois TigeotEach list contains one or more elements. 98a5f7a14bSFrançois TigeotEach element contains a starting physical address and a length. 99a5f7a14bSFrançois TigeotScatter/gather lists are read-only while they are shared. 100a5f7a14bSFrançois TigeotIf one wishes to alter an existing scatter/gather list and does not hold the 101a5f7a14bSFrançois Tigeotsole reference to the list, 102a5f7a14bSFrançois Tigeotthen one should create a new list instead of modifying the existing list. 103a5f7a14bSFrançois Tigeot.Pp 104a5f7a14bSFrançois TigeotEach scatter/gather list object contains a reference count. 105a5f7a14bSFrançois TigeotNew lists are created with a single reference. 106a5f7a14bSFrançois TigeotNew references are obtained by calling 107a5f7a14bSFrançois Tigeot.Nm sglist_hold 108a5f7a14bSFrançois Tigeotand are released by calling 109a5f7a14bSFrançois Tigeot.Nm sglist_free . 110a5f7a14bSFrançois Tigeot.Ss Allocating and Initializing Lists 111a5f7a14bSFrançois TigeotEach 112a5f7a14bSFrançois Tigeot.Nm 113a5f7a14bSFrançois Tigeotobject consists of a header structure and a variable-length array of 114a5f7a14bSFrançois Tigeotscatter/gather list elements. 115a5f7a14bSFrançois TigeotThe 116a5f7a14bSFrançois Tigeot.Nm sglist_alloc 117a5f7a14bSFrançois Tigeotfunction allocates a new list that contains a header and 118a5f7a14bSFrançois Tigeot.Fa nsegs 119a5f7a14bSFrançois Tigeotscatter/gather list elements. 120a5f7a14bSFrançois TigeotThe 121a5f7a14bSFrançois Tigeot.Fa mflags 122a5f7a14bSFrançois Tigeotargument can be set to either 123a5f7a14bSFrançois Tigeot.Dv M_NOWAIT 124a5f7a14bSFrançois Tigeotor 125a5f7a14bSFrançois Tigeot.Dv M_WAITOK . 126a5f7a14bSFrançois Tigeot.Pp 127a5f7a14bSFrançois TigeotThe 128a5f7a14bSFrançois Tigeot.Nm sglist_count 129a5f7a14bSFrançois Tigeotfunction returns the number of scatter/gather list elements needed to describe 130a5f7a14bSFrançois Tigeotthe physical address ranges mapped by a single kernel virtual address range. 131a5f7a14bSFrançois TigeotThe kernel virtual address range starts at 132a5f7a14bSFrançois Tigeot.Fa buf 133a5f7a14bSFrançois Tigeotand is 134a5f7a14bSFrançois Tigeot.Fa len 135a5f7a14bSFrançois Tigeotbytes long. 136a5f7a14bSFrançois Tigeot.Pp 137a5f7a14bSFrançois TigeotThe 138a5f7a14bSFrançois Tigeot.Nm sglist_build 139a5f7a14bSFrançois Tigeotfunction allocates a new scatter/gather list object that describes the physical 140a5f7a14bSFrançois Tigeotaddress ranges mapped by a single kernel virtual address range. 141a5f7a14bSFrançois TigeotThe kernel virtual address range starts at 142a5f7a14bSFrançois Tigeot.Fa buf 143a5f7a14bSFrançois Tigeotand is 144a5f7a14bSFrançois Tigeot.Fa len 145a5f7a14bSFrançois Tigeotbytes long. 146a5f7a14bSFrançois TigeotThe 147a5f7a14bSFrançois Tigeot.Fa mflags 148a5f7a14bSFrançois Tigeotargument can be set to either 149a5f7a14bSFrançois Tigeot.Dv M_NOWAIT 150a5f7a14bSFrançois Tigeotor 151a5f7a14bSFrançois Tigeot.Dv M_WAITOK . 152a5f7a14bSFrançois Tigeot.Pp 153a5f7a14bSFrançois TigeotThe 154a5f7a14bSFrançois Tigeot.Nm sglist_clone 155a5f7a14bSFrançois Tigeotfunction returns a copy of an existing scatter/gather list object 156a5f7a14bSFrançois Tigeot.Fa sg . 157a5f7a14bSFrançois TigeotThe 158a5f7a14bSFrançois Tigeot.Fa mflags 159a5f7a14bSFrançois Tigeotargument can be set to either 160a5f7a14bSFrançois Tigeot.Dv M_NOWAIT 161a5f7a14bSFrançois Tigeotor 162a5f7a14bSFrançois Tigeot.Dv M_WAITOK . 163a5f7a14bSFrançois TigeotThis can be used to obtain a private copy of a scatter/gather list before 164a5f7a14bSFrançois Tigeotmodifying it. 165a5f7a14bSFrançois Tigeot.Pp 166a5f7a14bSFrançois TigeotThe 167a5f7a14bSFrançois Tigeot.Nm sglist_init 168a5f7a14bSFrançois Tigeotfunction initializes a scatter/gather list header. 169a5f7a14bSFrançois TigeotThe header is pointed to by 170a5f7a14bSFrançois Tigeot.Fa sg 171a5f7a14bSFrançois Tigeotand is initialized to manage an array of 172a5f7a14bSFrançois Tigeot.Fa maxsegs 173a5f7a14bSFrançois Tigeotscatter/gather list elements pointed to by 174a5f7a14bSFrançois Tigeot.Fa segs . 175a5f7a14bSFrançois TigeotThis can be used to initialize a scatter/gather list header whose storage 176a5f7a14bSFrançois Tigeotis not provided by 177a5f7a14bSFrançois Tigeot.Nm sglist_alloc . 178a5f7a14bSFrançois TigeotIn that case, the caller should not call 179a5f7a14bSFrançois Tigeot.Nm sglist_free 180a5f7a14bSFrançois Tigeotto release its own reference and is responsible for ensuring all other 181a5f7a14bSFrançois Tigeotreferences to the list are dropped before it releases the storage for 182a5f7a14bSFrançois Tigeot.Fa sg 183a5f7a14bSFrançois Tigeotand 184a5f7a14bSFrançois Tigeot.Fa segs . 185a5f7a14bSFrançois Tigeot.Ss Constructing Scatter/Gather Lists 186a5f7a14bSFrançois TigeotThe 187a5f7a14bSFrançois Tigeot.Nm 188a5f7a14bSFrançois TigeotAPI provides several routines for building a scatter/gather list to describe 189a5f7a14bSFrançois Tigeotone or more objects. 190a5f7a14bSFrançois TigeotSpecifically, the 191a5f7a14bSFrançois Tigeot.Nm sglist_append 192a5f7a14bSFrançois Tigeotfamily of routines can be used to append the physical address ranges described 193a5f7a14bSFrançois Tigeotby an object to the end of a scatter/gather list. 194a5f7a14bSFrançois TigeotAll of these routines return 0 on success or an error on failure. 195a5f7a14bSFrançois TigeotIf a request to append an address range to a scatter/gather list fails, 196a5f7a14bSFrançois Tigeotthe scatter/gather list will remain unchanged. 197a5f7a14bSFrançois Tigeot.Pp 198a5f7a14bSFrançois TigeotThe 199a5f7a14bSFrançois Tigeot.Nm sglist_append 200a5f7a14bSFrançois Tigeotfunction appends the physical address ranges described by a single kernel 201a5f7a14bSFrançois Tigeotvirtual address range to the scatter/gather list 202a5f7a14bSFrançois Tigeot.Fa sg . 203a5f7a14bSFrançois TigeotThe kernel virtual address range starts at 204a5f7a14bSFrançois Tigeot.Fa buf 205a5f7a14bSFrançois Tigeotand is 206a5f7a14bSFrançois Tigeot.Fa len 207a5f7a14bSFrançois Tigeotbytes long. 208a5f7a14bSFrançois Tigeot.Pp 209a5f7a14bSFrançois TigeotThe 210a5f7a14bSFrançois Tigeot.Nm sglist_append_mbuf 211a5f7a14bSFrançois Tigeotfunction appends the physical address ranges described by an entire mbuf 212a5f7a14bSFrançois Tigeotchain 213a5f7a14bSFrançois Tigeot.Fa m 214a5f7a14bSFrançois Tigeotto the scatter/gather list 215a5f7a14bSFrançois Tigeot.Fa sg . 216a5f7a14bSFrançois Tigeot.Pp 217a5f7a14bSFrançois TigeotThe 218a5f7a14bSFrançois Tigeot.Nm sglist_append_phys 219a5f7a14bSFrançois Tigeotfunction appends a single physical address range to the scatter/gather list 220a5f7a14bSFrançois Tigeot.Fa sg . 221a5f7a14bSFrançois TigeotThe physical address range starts at 222a5f7a14bSFrançois Tigeot.Fa paddr 223a5f7a14bSFrançois Tigeotand is 224a5f7a14bSFrançois Tigeot.Fa len 225a5f7a14bSFrançois Tigeotbytes long. 226a5f7a14bSFrançois Tigeot.Pp 227a5f7a14bSFrançois TigeotThe 228a5f7a14bSFrançois Tigeot.Nm sglist_append_uio 229a5f7a14bSFrançois Tigeotfunction appends the physical address ranges described by a 230a5f7a14bSFrançois Tigeot.Xr uio 9 231a5f7a14bSFrançois Tigeotobject to the scatter/gather list 232a5f7a14bSFrançois Tigeot.Fa sg . 233a5f7a14bSFrançois TigeotNote that it is the caller's responsibility to ensure that the pages backing 234a5f7a14bSFrançois Tigeotthe I/O request are wired for the lifetime of 235a5f7a14bSFrançois Tigeot.Fa sg . 236a5f7a14bSFrançois TigeotNote also that this routine does not modify 237a5f7a14bSFrançois Tigeot.Fa uio . 238a5f7a14bSFrançois Tigeot.Pp 239a5f7a14bSFrançois TigeotThe 240a5f7a14bSFrançois Tigeot.Nm sglist_append_user 241a5f7a14bSFrançois Tigeotfunction appends the physical address ranges described by a single user 242a5f7a14bSFrançois Tigeotvirtual address range to the scatter/gather list 243a5f7a14bSFrançois Tigeot.Fa sg . 244a5f7a14bSFrançois TigeotThe user virtual address range is relative to the address space of the thread 245a5f7a14bSFrançois Tigeot.Fa td . 246a5f7a14bSFrançois TigeotIt starts at 247a5f7a14bSFrançois Tigeot.Fa buf 248a5f7a14bSFrançois Tigeotand is 249a5f7a14bSFrançois Tigeot.Fa len 250a5f7a14bSFrançois Tigeotbytes long. 251a5f7a14bSFrançois TigeotNote that it is the caller's responsibility to ensure that the pages backing 252a5f7a14bSFrançois Tigeotthe user buffer are wired for the lifetime of 253a5f7a14bSFrançois Tigeot.Fa sg . 254a5f7a14bSFrançois Tigeot.Pp 255a5f7a14bSFrançois TigeotThe 256a5f7a14bSFrançois Tigeot.Nm sglist_consume_uio 257a5f7a14bSFrançois Tigeotfunction is a variation of 258a5f7a14bSFrançois Tigeot.Nm sglist_append_uio . 259a5f7a14bSFrançois TigeotAs with 260a5f7a14bSFrançois Tigeot.Nm sglist_append_uio , 261a5f7a14bSFrançois Tigeotit appends the physical address ranges described by 262a5f7a14bSFrançois Tigeot.Fa uio 263a5f7a14bSFrançois Tigeotto the scatter/gather list 264a5f7a14bSFrançois Tigeot.Fa sg . 265a5f7a14bSFrançois TigeotUnlike 266a5f7a14bSFrançois Tigeot.Nm sglist_append_uio , 267a5f7a14bSFrançois Tigeothowever, 268a5f7a14bSFrançois Tigeot.Nm sglist_consume_uio 269a5f7a14bSFrançois Tigeotmodifies the I/O request to indicate that the appended address ranges have 270a5f7a14bSFrançois Tigeotbeen processed similar to calling 271a5f7a14bSFrançois Tigeot.Xr uiomove 9 . 272a5f7a14bSFrançois TigeotThis routine will only append ranges that describe up to 273a5f7a14bSFrançois Tigeot.Fa resid 274a5f7a14bSFrançois Tigeottotal bytes in length. 275a5f7a14bSFrançois TigeotIf the available segments in the scatter/gather list are exhausted before 276a5f7a14bSFrançois Tigeot.Fa resid 277a5f7a14bSFrançois Tigeotbytes are processed, 278a5f7a14bSFrançois Tigeotthen the 279a5f7a14bSFrançois Tigeot.Fa uio 280a5f7a14bSFrançois Tigeotstructure will be updated to reflect the actual number of bytes processed, 281a5f7a14bSFrançois Tigeotand 282a5f7a14bSFrançois Tigeot.Nm sglist_consume_io 283a5f7a14bSFrançois Tigeotwill return zero to indicate success. 284a5f7a14bSFrançois TigeotIn effect, this function will perform partial reads or writes. 285a5f7a14bSFrançois TigeotThe caller can compare the 286a5f7a14bSFrançois Tigeot.Fa uio_resid 287a5f7a14bSFrançois Tigeotmember of 288a5f7a14bSFrançois Tigeot.Fa uio 289a5f7a14bSFrançois Tigeotbefore and after calling 290a5f7a14bSFrançois Tigeot.Nm sglist_consume_uio 291a5f7a14bSFrançois Tigeotto determine the actual number of bytes processed. 292a5f7a14bSFrançois Tigeot.Ss Manipulating Scatter/Gather Lists 293a5f7a14bSFrançois TigeotThe 294a5f7a14bSFrançois Tigeot.Nm sglist_join 295a5f7a14bSFrançois Tigeotfunction appends physical address ranges from the scatter/gather list 296a5f7a14bSFrançois Tigeot.Fa second 297a5f7a14bSFrançois Tigeotonto 298a5f7a14bSFrançois Tigeot.Fa first 299a5f7a14bSFrançois Tigeotand then resets 300a5f7a14bSFrançois Tigeot.Fa second 301a5f7a14bSFrançois Tigeotto an empty list. 302a5f7a14bSFrançois TigeotIt returns zero on success or an error on failure. 303a5f7a14bSFrançois Tigeot.Pp 304a5f7a14bSFrançois TigeotThe 305a5f7a14bSFrançois Tigeot.Nm sglist_split 306a5f7a14bSFrançois Tigeotfunction splits an existing scatter/gather list into two lists. 307a5f7a14bSFrançois TigeotThe first 308a5f7a14bSFrançois Tigeot.Fa length 309a5f7a14bSFrançois Tigeotbytes described by the list 310a5f7a14bSFrançois Tigeot.Fa original 311a5f7a14bSFrançois Tigeotare moved to a new list 312a5f7a14bSFrançois Tigeot.Fa *head . 313a5f7a14bSFrançois TigeotIf 314a5f7a14bSFrançois Tigeot.Fa original 315a5f7a14bSFrançois Tigeotdescribes a total address range that is smaller than 316a5f7a14bSFrançois Tigeot.Fa length 317a5f7a14bSFrançois Tigeotbytes, 318a5f7a14bSFrançois Tigeotthen all of the address ranges will be moved to the new list at 319a5f7a14bSFrançois Tigeot.Fa *head 320a5f7a14bSFrançois Tigeotand 321a5f7a14bSFrançois Tigeot.Fa original 322a5f7a14bSFrançois Tigeotwill be an empty list. 323a5f7a14bSFrançois TigeotThe caller may supply an existing scatter/gather list in 324a5f7a14bSFrançois Tigeot.Fa *head . 325a5f7a14bSFrançois TigeotIf so, the list must be empty. 326a5f7a14bSFrançois TigeotOtherwise, the caller may set 327a5f7a14bSFrançois Tigeot.Fa *head 328a5f7a14bSFrançois Tigeotto 329a5f7a14bSFrançois Tigeot.Dv NULL 330a5f7a14bSFrançois Tigeotin which case a new scatter/gather list will be allocated. 331a5f7a14bSFrançois TigeotIn that case, 332a5f7a14bSFrançois Tigeot.Fa mflags 333a5f7a14bSFrançois Tigeotmay be set to either 334a5f7a14bSFrançois Tigeot.Dv M_NOWAIT 335a5f7a14bSFrançois Tigeotor 336a5f7a14bSFrançois Tigeot.Dv M_WAITOK . 337a5f7a14bSFrançois TigeotNote that since the 338a5f7a14bSFrançois Tigeot.Fa original 339a5f7a14bSFrançois Tigeotlist is modified by this call, it must be a private list with no other 340a5f7a14bSFrançois Tigeotreferences. 341a5f7a14bSFrançois TigeotThe 342a5f7a14bSFrançois Tigeot.Nm sglist_split 343a5f7a14bSFrançois Tigeotfunction returns zero on success or an error on failure. 344a5f7a14bSFrançois Tigeot.Pp 345a5f7a14bSFrançois TigeotThe 346a5f7a14bSFrançois Tigeot.Nm sglist_slice 347a5f7a14bSFrançois Tigeotfunction generates a new scatter/gather list from a sub-range of an existing 348a5f7a14bSFrançois Tigeotscatter/gather list 349a5f7a14bSFrançois Tigeot.Fa original . 350a5f7a14bSFrançois TigeotThe sub-range to extract is specified by the 351a5f7a14bSFrançois Tigeot.Fa offset 352a5f7a14bSFrançois Tigeotand 353a5f7a14bSFrançois Tigeot.Fa length 354a5f7a14bSFrançois Tigeotparameters. 355a5f7a14bSFrançois TigeotThe new scatter/gather list is stored in 356a5f7a14bSFrançois Tigeot.Fa *slice . 357a5f7a14bSFrançois TigeotAs with 358a5f7a14bSFrançois Tigeot.Fa head 359a5f7a14bSFrançois Tigeotfor 360a5f7a14bSFrançois Tigeot.Nm sglist_join , 361a5f7a14bSFrançois Tigeotthe caller may either provide an empty scatter/gather list, 362a5f7a14bSFrançois Tigeotor it may set 363a5f7a14bSFrançois Tigeot.Fa *slice 364a5f7a14bSFrançois Tigeotto 365a5f7a14bSFrançois Tigeot.Dv NULL 366a5f7a14bSFrançois Tigeotin which case 367a5f7a14bSFrançois Tigeot.Nm sglist_slice 368a5f7a14bSFrançois Tigeotwill allocate a new list subject to 369a5f7a14bSFrançois Tigeot.Fa mflags . 370a5f7a14bSFrançois TigeotUnlike 371a5f7a14bSFrançois Tigeot.Nm sglist_split , 372a5f7a14bSFrançois Tigeot.Nm sglist_slice 373a5f7a14bSFrançois Tigeotdoes not modify 374a5f7a14bSFrançois Tigeot.Fa original 375a5f7a14bSFrançois Tigeotand does not require it to be a private list. 376a5f7a14bSFrançois TigeotThe 377a5f7a14bSFrançois Tigeot.Nm sglist_split 378a5f7a14bSFrançois Tigeotfunction returns zero on success or an error on failure. 379a5f7a14bSFrançois Tigeot.Ss Miscellaneous Routines 380a5f7a14bSFrançois TigeotThe 381a5f7a14bSFrançois Tigeot.Nm sglist_reset 382a5f7a14bSFrançois Tigeotfunction clears the scatter/gather list 383a5f7a14bSFrançois Tigeot.Fa sg 384a5f7a14bSFrançois Tigeotso that it no longer maps any address ranges. 385a5f7a14bSFrançois TigeotThis can allow reuse of a single scatter/gather list object for multiple 386a5f7a14bSFrançois Tigeotrequests. 387a5f7a14bSFrançois Tigeot.Pp 388a5f7a14bSFrançois TigeotThe 389a5f7a14bSFrançois Tigeot.Nm sglist_length 390a5f7a14bSFrançois Tigeotfunction returns the total length of the physical address ranges described 391a5f7a14bSFrançois Tigeotby the scatter/gather list 392a5f7a14bSFrançois Tigeot.Fa sg . 393a5f7a14bSFrançois Tigeot.Sh RETURN VALUES 394a5f7a14bSFrançois TigeotThe 395a5f7a14bSFrançois Tigeot.Nm sglist_alloc , 396a5f7a14bSFrançois Tigeot.Nm sglist_build , 397a5f7a14bSFrançois Tigeotand 398a5f7a14bSFrançois Tigeot.Nm sglist_clone 399a5f7a14bSFrançois Tigeotfunctions return a new scatter/gather list on success or 400a5f7a14bSFrançois Tigeot.Dv NULL 401a5f7a14bSFrançois Tigeoton failure. 402a5f7a14bSFrançois Tigeot.Pp 403a5f7a14bSFrançois TigeotThe 404a5f7a14bSFrançois Tigeot.Nm sglist_append 405a5f7a14bSFrançois Tigeotfamily of functions and the 406a5f7a14bSFrançois Tigeot.Nm sglist_consume_uio , 407a5f7a14bSFrançois Tigeot.Nm sglist_join , 408a5f7a14bSFrançois Tigeot.Nm sglist_slice , 409a5f7a14bSFrançois Tigeotand 410a5f7a14bSFrançois Tigeot.Nm sglist_split 411a5f7a14bSFrançois Tigeotfunctions return zero on success or an error on failure. 412a5f7a14bSFrançois Tigeot.Pp 413a5f7a14bSFrançois TigeotThe 414a5f7a14bSFrançois Tigeot.Nm sglist_count 415a5f7a14bSFrançois Tigeotfunction returns a count of scatter/gather list elements. 416a5f7a14bSFrançois Tigeot.Pp 417a5f7a14bSFrançois TigeotThe 418a5f7a14bSFrançois Tigeot.Nm sglist_length 419a5f7a14bSFrançois Tigeotfunction returns a count of address space described by a scatter/gather list 420a5f7a14bSFrançois Tigeotin bytes. 421a5f7a14bSFrançois Tigeot.Sh ERRORS 422a5f7a14bSFrançois TigeotThe 423a5f7a14bSFrançois Tigeot.Nm sglist_append 424a5f7a14bSFrançois Tigeotfunctions return the following errors on failure: 425a5f7a14bSFrançois Tigeot.Bl -tag -width Er 426a5f7a14bSFrançois Tigeot.It Bq Er EINVAL 427a5f7a14bSFrançois TigeotThe scatter/gather list has zero segments. 428a5f7a14bSFrançois Tigeot.It Bq Er EFBIG 429a5f7a14bSFrançois TigeotThere are not enough available segments in the scatter/gather list to append 430a5f7a14bSFrançois Tigeotthe specified physical address ranges. 431a5f7a14bSFrançois Tigeot.El 432a5f7a14bSFrançois Tigeot.Pp 433a5f7a14bSFrançois TigeotThe 434a5f7a14bSFrançois Tigeot.Nm sglist_consume_uio 435a5f7a14bSFrançois Tigeotfunction returns the following error on failure: 436a5f7a14bSFrançois Tigeot.Bl -tag -width Er 437a5f7a14bSFrançois Tigeot.It Bq Er EINVAL 438a5f7a14bSFrançois TigeotThe scatter/gather list has zero segments. 439a5f7a14bSFrançois Tigeot.El 440a5f7a14bSFrançois Tigeot.Pp 441a5f7a14bSFrançois TigeotThe 442a5f7a14bSFrançois Tigeot.Nm sglist_join 443a5f7a14bSFrançois Tigeotfunction returns the following error on failure: 444a5f7a14bSFrançois Tigeot.Bl -tag -width Er 445a5f7a14bSFrançois Tigeot.It Bq Er EFBIG 446a5f7a14bSFrançois TigeotThere are not enough available segments in the scatter/gather list 447a5f7a14bSFrançois Tigeot.Fa first 448a5f7a14bSFrançois Tigeotto append the physical address ranges from 449a5f7a14bSFrançois Tigeot.Fa second . 450a5f7a14bSFrançois Tigeot.El 451a5f7a14bSFrançois Tigeot.Pp 452a5f7a14bSFrançois TigeotThe 453a5f7a14bSFrançois Tigeot.Nm sglist_slice 454a5f7a14bSFrançois Tigeotfunction returns the following errors on failure: 455a5f7a14bSFrançois Tigeot.Bl -tag -width Er 456a5f7a14bSFrançois Tigeot.It Bq Er EINVAL 457a5f7a14bSFrançois TigeotThe 458a5f7a14bSFrançois Tigeot.Fa original 459a5f7a14bSFrançois Tigeotscatter/gather list does not describe enough address space to cover the 460a5f7a14bSFrançois Tigeotrequested sub-range. 461a5f7a14bSFrançois Tigeot.It Bq Er EINVAL 462a5f7a14bSFrançois TigeotThe caller-supplied scatter/gather list in 463a5f7a14bSFrançois Tigeot.Fa *slice 464a5f7a14bSFrançois Tigeotis not empty. 465a5f7a14bSFrançois Tigeot.It Bq Er ENOMEM 466a5f7a14bSFrançois TigeotAn attempt to allocate a new scatter/gather list with 467a5f7a14bSFrançois Tigeot.Dv M_NOWAIT 468a5f7a14bSFrançois Tigeotset in 469a5f7a14bSFrançois Tigeot.Fa mflags 470a5f7a14bSFrançois Tigeotfailed. 471a5f7a14bSFrançois Tigeot.It Bq Er EFBIG 472a5f7a14bSFrançois TigeotThere are not enough available segments in the caller-supplied scatter/gather 473a5f7a14bSFrançois Tigeotlist in 474a5f7a14bSFrançois Tigeot.Fa *slice 475a5f7a14bSFrançois Tigeotto describe the requested physical address ranges. 476a5f7a14bSFrançois Tigeot.El 477a5f7a14bSFrançois Tigeot.Pp 478a5f7a14bSFrançois TigeotThe 479a5f7a14bSFrançois Tigeot.Nm sglist_split 480a5f7a14bSFrançois Tigeotfunction returns the following errors on failure: 481a5f7a14bSFrançois Tigeot.Bl -tag -width Er 482a5f7a14bSFrançois Tigeot.It Bq Er EDOOFUS 483a5f7a14bSFrançois TigeotThe 484a5f7a14bSFrançois Tigeot.Fa original 485a5f7a14bSFrançois Tigeotscatter/gather list has more than one reference. 486a5f7a14bSFrançois Tigeot.It Bq Er EINVAL 487a5f7a14bSFrançois TigeotThe caller-supplied scatter/gather list in 488a5f7a14bSFrançois Tigeot.Fa *head 489a5f7a14bSFrançois Tigeotis not empty. 490a5f7a14bSFrançois Tigeot.It Bq Er ENOMEM 491a5f7a14bSFrançois TigeotAn attempt to allocate a new scatter/gather list with 492a5f7a14bSFrançois Tigeot.Dv M_NOWAIT 493a5f7a14bSFrançois Tigeotset in 494a5f7a14bSFrançois Tigeot.Fa mflags 495a5f7a14bSFrançois Tigeotfailed. 496a5f7a14bSFrançois Tigeot.It Bq Er EFBIG 497a5f7a14bSFrançois TigeotThere are not enough available segments in the caller-supplied scatter/gather 498a5f7a14bSFrançois Tigeotlist in 499a5f7a14bSFrançois Tigeot.Fa *head 500a5f7a14bSFrançois Tigeotto describe the requested physical address ranges. 501a5f7a14bSFrançois Tigeot.El 502a5f7a14bSFrançois Tigeot.Sh SEE ALSO 503a5f7a14bSFrançois Tigeot.Xr kmalloc 9 , 504a5f7a14bSFrançois Tigeot.Xr mbuf 9 , 505a5f7a14bSFrançois Tigeot.Xr uio 9 506a5f7a14bSFrançois Tigeot.Sh HISTORY 507a5f7a14bSFrançois TigeotThis API was first introduced in 508a5f7a14bSFrançois Tigeot.Fx 8.0 . 509