MCPcopy Create free account
hub / github.com/F-Stack/f-stack / sglist_count

Function sglist_count

freebsd/kern/subr_sglist.c:171–194  ·  view source on GitHub ↗

* Determine the number of scatter/gather list elements needed to * describe a kernel virtual address range. */

Source from the content-addressed store, hash-verified

169 * describe a kernel virtual address range.
170 */
171int
172sglist_count(void *buf, size_t len)
173{
174 vm_offset_t vaddr, vendaddr;
175 vm_paddr_t lastaddr, paddr;
176 int nsegs;
177
178 if (len == 0)
179 return (0);
180
181 vaddr = trunc_page((vm_offset_t)buf);
182 vendaddr = (vm_offset_t)buf + len;
183 nsegs = 1;
184 lastaddr = pmap_kextract(vaddr);
185 vaddr += PAGE_SIZE;
186 while (vaddr < vendaddr) {
187 paddr = pmap_kextract(vaddr);
188 if (lastaddr + PAGE_SIZE != paddr)
189 nsegs++;
190 lastaddr = paddr;
191 vaddr += PAGE_SIZE;
192 }
193 return (nsegs);
194}
195
196/*
197 * Determine the number of scatter/gather list elements needed to

Callers 2

sglist_count_mbuf_epgFunction · 0.85
sglist_buildFunction · 0.85

Calls 1

pmap_kextractFunction · 0.50

Tested by

no test coverage detected