Date: Thu, 25 Jul 2024 19:33:32 GMT From: John Baldwin <jhb@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org Subject: git: 399362bac312 - main - nvmfd: Permit setting the MAXH2CDATA value via -H Message-ID: <202407251933.46PJXWWi042844@gitrepo.freebsd.org>
next in thread | raw e-mail | index | archive | help
The branch main has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=399362bac312d4fa77a3fd918ea002c0782bc315 commit 399362bac312d4fa77a3fd918ea002c0782bc315 Author: John Baldwin <jhb@FreeBSD.org> AuthorDate: 2024-07-25 19:33:15 +0000 Commit: John Baldwin <jhb@FreeBSD.org> CommitDate: 2024-07-25 19:33:15 +0000 nvmfd: Permit setting the MAXH2CDATA value via -H This value is advertised to the remote host for TCP associations and determines the maximum data payload size the remote host is permitted to transmit in a single PDU. Sponsored by: Chelsio Communications --- usr.sbin/nvmfd/discovery.c | 2 +- usr.sbin/nvmfd/internal.h | 1 + usr.sbin/nvmfd/io.c | 2 +- usr.sbin/nvmfd/nvmfd.8 | 10 ++++++++-- usr.sbin/nvmfd/nvmfd.c | 17 ++++++++++++++--- 5 files changed, 25 insertions(+), 7 deletions(-) diff --git a/usr.sbin/nvmfd/discovery.c b/usr.sbin/nvmfd/discovery.c index 1cee8755c65c..2cfe56731d7c 100644 --- a/usr.sbin/nvmfd/discovery.c +++ b/usr.sbin/nvmfd/discovery.c @@ -109,7 +109,7 @@ init_discovery(void) aparams.tcp.pda = 0; aparams.tcp.header_digests = header_digests; aparams.tcp.data_digests = data_digests; - aparams.tcp.maxh2cdata = 256 * 1024; + aparams.tcp.maxh2cdata = maxh2cdata; discovery_na = nvmf_allocate_association(NVMF_TRTYPE_TCP, true, &aparams); if (discovery_na == NULL) diff --git a/usr.sbin/nvmfd/internal.h b/usr.sbin/nvmfd/internal.h index 5ddbc1cf89f0..f70dc78881c6 100644 --- a/usr.sbin/nvmfd/internal.h +++ b/usr.sbin/nvmfd/internal.h @@ -24,6 +24,7 @@ extern bool data_digests; extern bool header_digests; extern bool flow_control_disable; extern bool kernel_io; +extern uint32_t maxh2cdata; /* controller.c */ void controller_handle_admin_commands(struct controller *c, diff --git a/usr.sbin/nvmfd/io.c b/usr.sbin/nvmfd/io.c index 3c25d1944eb8..4407360257a2 100644 --- a/usr.sbin/nvmfd/io.c +++ b/usr.sbin/nvmfd/io.c @@ -57,7 +57,7 @@ init_io(const char *subnqn) aparams.tcp.pda = 0; aparams.tcp.header_digests = header_digests; aparams.tcp.data_digests = data_digests; - aparams.tcp.maxh2cdata = 256 * 1024; + aparams.tcp.maxh2cdata = maxh2cdata; io_na = nvmf_allocate_association(NVMF_TRTYPE_TCP, true, &aparams); if (io_na == NULL) diff --git a/usr.sbin/nvmfd/nvmfd.8 b/usr.sbin/nvmfd/nvmfd.8 index 40b1c0e2ebe0..1076583c417c 100644 --- a/usr.sbin/nvmfd/nvmfd.8 +++ b/usr.sbin/nvmfd/nvmfd.8 @@ -13,12 +13,14 @@ .Nm .Fl K .Op Fl dFGg +.Op Fl H Ar MAXH2CDATA .Op Fl P Ar port .Op Fl p Ar port .Op Fl t Ar transport .Op Fl n Ar subnqn .Nm .Op Fl dFGg +.Op Fl H Ar MAXH2CDATA .Op Fl P Ar port .Op Fl p Ar port .Op Fl t Ar transport @@ -42,6 +44,11 @@ Permit remote hosts to disable SQ flow control. Permit remote hosts to enable PDU data digests for the TCP transport. .It Fl g Permit remote hosts to enable PDU header digests for the TCP transport. +.It Fl H +Set the MAXH2CDATA value advertised to the remote host for the TCP transport. +This value is in bytes and determines the maximum data payload size for +data PDUs sent by the remote host. +The value must be at least 4096 and defaults to 256KiB. .It Fl K Enable kernel mode which hands off incoming I/O controller connections to .Xr nvmft 4 . @@ -121,5 +128,4 @@ should be merged into .Xr ctld 8 . .Pp Additional parameters such as -.Va MAXH2CDATA -and queue sizes should be configurable. +queue sizes should be configurable. diff --git a/usr.sbin/nvmfd/nvmfd.c b/usr.sbin/nvmfd/nvmfd.c index cce7a88706d2..df6f400b40e5 100644 --- a/usr.sbin/nvmfd/nvmfd.c +++ b/usr.sbin/nvmfd/nvmfd.c @@ -18,6 +18,7 @@ #include <libutil.h> #include <netdb.h> #include <signal.h> +#include <stdint.h> #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -29,6 +30,7 @@ bool data_digests = false; bool header_digests = false; bool flow_control_disable = false; bool kernel_io = false; +uint32_t maxh2cdata = 256 * 1024; static const char *subnqn; static volatile bool quit = false; @@ -36,8 +38,8 @@ static volatile bool quit = false; static void usage(void) { - fprintf(stderr, "nvmfd -K [-dFGg] [-P port] [-p port] [-t transport] [-n subnqn]\n" - "nvmfd [-dFGg] [-P port] [-p port] [-t transport] [-n subnqn]\n" + fprintf(stderr, "nvmfd -K [-dFGg] [-H MAXH2CDATA] [-P port] [-p port] [-t transport] [-n subnqn]\n" + "nvmfd [-dFGg] [-H MAXH2CDATA] [-P port] [-p port] [-t transport] [-n subnqn]\n" "\tdevice [device [...]]\n" "\n" "Devices use one of the following syntaxes:\n" @@ -150,6 +152,7 @@ main(int ac, char **av) struct pidfh *pfh; const char *dport, *ioport, *transport; pid_t pid; + uint64_t value; int ch, error, kqfd; bool daemonize; static char nqn[NVMF_NQN_MAX_LEN]; @@ -162,7 +165,7 @@ main(int ac, char **av) ioport = "0"; subnqn = NULL; transport = "tcp"; - while ((ch = getopt(ac, av, "dFgGKn:P:p:t:")) != -1) { + while ((ch = getopt(ac, av, "dFgGH:Kn:P:p:t:")) != -1) { switch (ch) { case 'd': daemonize = false; @@ -176,6 +179,14 @@ main(int ac, char **av) case 'g': header_digests = true; break; + case 'H': + if (expand_number(optarg, &value) != 0) + errx(1, "Invalid MAXH2CDATA value %s", optarg); + if (value < 4096 || value > UINT32_MAX || + value % 4 != 0) + errx(1, "Invalid MAXH2CDATA value %s", optarg); + maxh2cdata = value; + break; case 'K': kernel_io = true; break;
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202407251933.46PJXWWi042844>