diff --git a/share/man/man9/Makefile b/share/man/man9/Makefile index da68da16ddf5..4699b1ef0afe 100644 --- a/share/man/man9/Makefile +++ b/share/man/man9/Makefile @@ -1941,6 +1941,7 @@ MLINKS+=sglist.9 sglist_alloc.9 \ sglist.9 sglist_append_mbuf_epg.9 \ sglist.9 sglist_append_phys.9 \ sglist.9 sglist_append_sglist.9 \ + sglist.9 sglist_append_single_mbuf.9 \ sglist.9 sglist_append_uio.9 \ sglist.9 sglist_append_user.9 \ sglist.9 sglist_append_vmpages.9 \ diff --git a/share/man/man9/sglist.9 b/share/man/man9/sglist.9 index b1d781b84d63..408d23573489 100644 --- a/share/man/man9/sglist.9 +++ b/share/man/man9/sglist.9 @@ -26,7 +26,7 @@ .\" .\" $FreeBSD$ .\" -.Dd April 24, 2020 +.Dd May 25, 2021 .Dt SGLIST 9 .Os .Sh NAME @@ -38,6 +38,7 @@ .Nm sglist_append_mbuf_epg, .Nm sglist_append_phys , .Nm sglist_append_sglist , +.Nm sglist_append_single_mbuf , .Nm sglist_append_uio , .Nm sglist_append_user , .Nm sglist_append_vmpages , @@ -74,6 +75,8 @@ .Ft int .Fn sglist_append_sglist "struct sglist *sg" "struct sglist *source" "size_t offset" "size_t len" .Ft int +.Fn sglist_append_single_mbuf "struct sglist *sg" "struct mbuf *m" +.Ft int .Fn sglist_append_uio "struct sglist *sg" "struct uio *uio" .Ft int .Fn sglist_append_user "struct sglist *sg" "void *buf" "size_t len" "struct thread *td" @@ -284,6 +287,13 @@ to the scatter/gather list .Fa sg . .Pp The +.Nm sglist_append_mbuf +function appends the physical address ranges described by a single mbuf +.Fa m +to the scatter/gather list +.Fa sg . +.Pp +The .Nm sglist_append_phys function appends a single physical address range to the scatter/gather list .Fa sg . diff --git a/sys/kern/subr_sglist.c b/sys/kern/subr_sglist.c index 71be45b4231d..7c520fda00f5 100644 --- a/sys/kern/subr_sglist.c +++ b/sys/kern/subr_sglist.c @@ -466,6 +466,21 @@ sglist_append_mbuf(struct sglist *sg, struct mbuf *m0) return (0); } +/* + * Append the segments that describe a single mbuf to a scatter/gather + * list. If there are insufficient segments, then this fails with + * EFBIG. + */ +int +sglist_append_single_mbuf(struct sglist *sg, struct mbuf *m) +{ + if ((m->m_flags & M_EXTPG) != 0) + return (sglist_append_mbuf_epg(sg, m, + mtod(m, vm_offset_t), m->m_len)); + else + return (sglist_append(sg, m->m_data, m->m_len)); +} + /* * Append the segments that describe a buffer spanning an array of VM * pages. The buffer begins at an offset of 'pgoff' in the first diff --git a/sys/sys/sglist.h b/sys/sys/sglist.h index 82a3ac6ed6ac..bf8aa482e3ce 100644 --- a/sys/sys/sglist.h +++ b/sys/sys/sglist.h @@ -94,6 +94,7 @@ int sglist_append_phys(struct sglist *sg, vm_paddr_t paddr, size_t len); int sglist_append_sglist(struct sglist *sg, struct sglist *source, size_t offset, size_t length); +int sglist_append_single_mbuf(struct sglist *sg, struct mbuf *m); int sglist_append_uio(struct sglist *sg, struct uio *uio); int sglist_append_user(struct sglist *sg, void *buf, size_t len, struct thread *td);