aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Baldwin <jhb@FreeBSD.org>2021-05-25 23:59:18 +0000
committerJohn Baldwin <jhb@FreeBSD.org>2021-05-25 23:59:18 +0000
commit6663f8a23e7cb60d798c5ffbd9c716b62b204f2a (patch)
tree877a363ddb5353ca7a2f645498249927d6a1b7f2
parent1c8f4b3c9f9e8ca5823d153d3b117246b3d18db4 (diff)
downloadsrc-6663f8a23e7cb60d798c5ffbd9c716b62b204f2a.tar.gz
src-6663f8a23e7cb60d798c5ffbd9c716b62b204f2a.zip
sglist: Add sglist_append_single_mbuf().
This function appends the contents of a single mbuf to an sglist rather than an entire mbuf chain. Reviewed by: gallatin, markj Sponsored by: Netflix Differential Revision: https://reviews.freebsd.org/D30135
-rw-r--r--share/man/man9/Makefile1
-rw-r--r--share/man/man9/sglist.912
-rw-r--r--sys/kern/subr_sglist.c15
-rw-r--r--sys/sys/sglist.h1
4 files changed, 28 insertions, 1 deletions
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
@@ -467,6 +467,21 @@ sglist_append_mbuf(struct sglist *sg, struct mbuf *m0)
}
/*
+ * 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
* page.
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);