From 62e8081e0ac4a4c170bc536303f7a9bd3e91fd7b Mon Sep 17 00:00:00 2001 From: "Luke T. Shumaker" Date: Mon, 7 Oct 2024 17:24:18 -0600 Subject: tidy config --- cmd/srv9p/config/config.h | 47 ++++++++++++++++++++++++++++++++++++++++++++++- cmd/srv9p/main.c | 9 ++++++++- 2 files changed, 54 insertions(+), 2 deletions(-) mode change 120000 => 100644 cmd/srv9p/config/config.h (limited to 'cmd/srv9p') diff --git a/cmd/srv9p/config/config.h b/cmd/srv9p/config/config.h deleted file mode 120000 index 2edbd7b..0000000 --- a/cmd/srv9p/config/config.h +++ /dev/null @@ -1 +0,0 @@ -../../sbc_harness/config/config.h \ No newline at end of file diff --git a/cmd/srv9p/config/config.h b/cmd/srv9p/config/config.h new file mode 100644 index 0000000..ead97e0 --- /dev/null +++ b/cmd/srv9p/config/config.h @@ -0,0 +1,46 @@ +/* config.h - Compile-time configuration for srv9p + * + * Copyright (C) 2024 Luke T. Shumaker + * SPDX-Licence-Identifier: AGPL-3.0-or-later + */ + +#define CONFIG_NETIO_NUM_CONNS 8 + +# define CONFIG_9P_PORT 564 +/** + * This max-msg-size is sized so that a Twrite message can return + * 8KiB of data. + * + * This is the same as the default in Plan 9 4e's lib9p; it has the + * comment that "24" is "ample room for Twrite/Rread header + * (iounit)". In fact, the Twrite header is only 23 bytes + * ("size[4] Twrite[1] tag[2] fid[4] offset[8] count[4]") and the + * Rread header is even shorter at 11 bytes ("size[4] Rread[1] + * tag[2] count[4]"), so "24" appears to be the size of the Twrite + * header rounded up to a nice round number. + * + * In older versions of 9P ("9P1"), the max message size was + * defined as part of the protocol specification rather than + * negotiated. In Plan 9 1e it was (8*1024)+128, and was bumped to + * (8*1024)+160 in 2e and 3e. + */ +#define CONFIG_9P_MAX_MSG_SIZE ((4*1024)+24) +/** + * Maximum host-data-structure size. A message may be larger in + * unmarshaled-host-structures than marshaled-net-bytes due to (1) + * struct padding, (2) nul-terminator byes for strings. + */ +#define CONFIG_9P_MAX_HOSTMSG_SIZE CONFIG_9P_MAX_MSG_SIZE+16 +#define CONFIG_9P_MAX_FIDS 16 +#define CONFIG_9P_MAX_REQS 2 +#define CONFIG_9P_MAX_ERR_SIZE 128 /* 128 is what Plan 9 4e uses */ + +#define CONFIG_COROUTINE_DEFAULT_STACK_SIZE (32*1024) +#define CONFIG_COROUTINE_MEASURE_STACK 1 /* bool */ +#define CONFIG_COROUTINE_PROTECT_STACK 1 /* bool */ +#define CONFIG_COROUTINE_DEBUG 0 /* bool */ +#define CONFIG_COROUTINE_VALGRIND 1 /* bool */ +#define CONFIG_COROUTINE_NUM (1 /* usb_common */ +\ + 1 /* usb_keyboard */ +\ + CONFIG_NETIO_NUM_CONNS /* accept+read */ +\ + (CONFIG_9P_MAX_REQS*CONFIG_NETIO_NUM_CONNS) /* work+write */ ) diff --git a/cmd/srv9p/main.c b/cmd/srv9p/main.c index f62617d..6ed4b79 100644 --- a/cmd/srv9p/main.c +++ b/cmd/srv9p/main.c @@ -7,9 +7,16 @@ #include "static.h" -#define USE_CONFIG_COROUTINE +/* configuration **************************************************************/ + #include "config.h" +#ifndef CONFIG_NETIO_NUM_CONNS +# error config.h must define CONFIG_NETIO_NUM_CONNS +#endif + +/* implementation *************************************************************/ + #define UNUSED(name) /* name __attribute__((unused)) */ static struct static_dir_data root = { -- cgit v1.2.3-2-g168b