Skip to content

Commit

Permalink
nvmfd: Permit setting the MAXH2CDATA value via -H
Browse files Browse the repository at this point in the history
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
  • Loading branch information
bsdjhb committed Jul 25, 2024
1 parent 7f73c04 commit 399362b
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 7 deletions.
2 changes: 1 addition & 1 deletion usr.sbin/nvmfd/discovery.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions usr.sbin/nvmfd/internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion usr.sbin/nvmfd/io.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
10 changes: 8 additions & 2 deletions usr.sbin/nvmfd/nvmfd.8
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 .
Expand Down Expand Up @@ -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.
17 changes: 14 additions & 3 deletions usr.sbin/nvmfd/nvmfd.c
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand All @@ -29,15 +30,16 @@ 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;

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"
Expand Down Expand Up @@ -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];
Expand All @@ -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;
Expand All @@ -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;
Expand Down

0 comments on commit 399362b

Please sign in to comment.