diff options
Diffstat (limited to 'cmake/config/lib')
| -rw-r--r-- | cmake/config/lib/common.cmake | 58 | ||||
| -rw-r--r-- | cmake/config/lib/crypt.cmake | 41 | ||||
| -rw-r--r-- | cmake/config/lib/frct.cmake | 43 | ||||
| -rw-r--r-- | cmake/config/lib/poa.cmake | 37 | ||||
| -rw-r--r-- | cmake/config/lib/ssm.cmake | 168 |
5 files changed, 347 insertions, 0 deletions
diff --git a/cmake/config/lib/common.cmake b/cmake/config/lib/common.cmake new file mode 100644 index 00000000..ebdc3196 --- /dev/null +++ b/cmake/config/lib/common.cmake @@ -0,0 +1,58 @@ +# Library configuration options for Ouroboros Options affecting libouroboros-common, +# libouroboros-dev and libouroboros-irm as a whole; per-subsystem options sit beside this file + +# Flow limits +set(SYS_MAX_FLOWS 10240 CACHE STRING + "Maximum number of total flows for this system") +set(PROC_MAX_FLOWS 4096 CACHE STRING + "Maximum number of flows in an application") +set(PROC_RES_FDS 64 CACHE STRING + "Number of reserved flow descriptors per application") +set(PROC_MAX_FQUEUES 32 CACHE STRING + "Maximum number of flow sets per application") + +# Threading +if(NOT APPLE) + set(PTHREAD_COND_CLOCK "CLOCK_MONOTONIC" CACHE STRING + "Clock to use for condition variable timing") +else() + set(PTHREAD_COND_CLOCK "CLOCK_REALTIME" CACHE INTERNAL + "Clock to use for condition variable timing") +endif() + +# Timeouts +set(SOCKET_TIMEOUT 500 CACHE STRING + "Default timeout for responses from IPCPs (ms)") + +# QoS settings +set(QOS_DISABLE_CRC TRUE CACHE BOOL + "Ignores ber setting on all QoS cubes") + +include(utils/CPUUtils) +detect_pclmul() +detect_pmull() +if(HAVE_PCLMUL) + message(STATUS "CRC-64/NVMe backend: PCLMUL (x86 SSE4.1+PCLMUL)") +elseif(HAVE_PMULL) + message(STATUS "CRC-64/NVMe backend: PMULL (aarch64 crypto)") +else() + message(STATUS "CRC-64/NVMe backend: byte table (no acceleration)") +endif() + +# Thread pool manager (TPM) debugging +set(TPM_DEBUG_REPORT_INTERVAL 0 CACHE STRING + "Interval at wich the TPM will report long running threads (s), 0 disables") +set(TPM_DEBUG_ABORT_TIMEOUT 0 CACHE STRING + "TPM abort process after a thread reaches this timeout (s), 0 disables") + +# Flow statistics (requires FUSE) +if(HAVE_FUSE) + set(PROC_FLOW_STATS TRUE CACHE BOOL + "Enable flow statistics tracking for application flows") + if(PROC_FLOW_STATS) + message(STATUS "Application flow statistics enabled") + else() + message(STATUS "Application flow statistics disabled") + endif() +endif() + diff --git a/cmake/config/lib/crypt.cmake b/cmake/config/lib/crypt.cmake new file mode 100644 index 00000000..45fdaaed --- /dev/null +++ b/cmake/config/lib/crypt.cmake @@ -0,0 +1,41 @@ +# Encryption configuration for Ouroboros Options for the key schedule and packet protection in +# src/lib/crypt/ + +# Encryption +set(KEY_LEAF_BITS 20 CACHE STRING + "Packets per leaf key as a power of two (2^20 = AEAD-safe default)") +set(KEY_NODE_BITS 6 CACHE STRING + "Leaf keys per node key, power of two (2^6 = 64; leak compartment)") +set(KEY_NODE_COUNT 128 CACHE STRING + "Node keys per batch (N); <= 4096, the 12-bit on-wire node index") +set(KEY_REKEY_WATERMARK 4 CACHE STRING + "Re-key when this many node keys remain; 0 disables the count trigger") +set(KEY_REPLAY_WINDOW 2048 CACHE STRING + "RX replay window in packets; power of two, >= 128") +set(KEY_REKEY_WM_CHECK_BITS 16 CACHE STRING + "Re-key watermark is consulted once per 2^n flow writes") +if(NOT KEY_REPLAY_WINDOW MATCHES "^[0-9]+$") + message(FATAL_ERROR "KEY_REPLAY_WINDOW must be a positive integer") +endif() +math(EXPR _krw_p2 "${KEY_REPLAY_WINDOW} & (${KEY_REPLAY_WINDOW} - 1)") +if(KEY_REPLAY_WINDOW LESS 128 OR NOT _krw_p2 EQUAL 0) + message(FATAL_ERROR "KEY_REPLAY_WINDOW must be a power of two >= 128") +endif() + +# Re-key must finish within its lead window - KEY_REKEY_WATERMARK node keys worth of packets - +# before the batch exhausts and TX fails closed. dev.c only evaluates the watermark once per +# FLOW_WM_CHECK writes, so a lead below ~2x that leaves a high-rate flow no room to complete the +# exchange. Production defaults are vast; this guards under-sized (test) geometries. +if(KEY_REKEY_WATERMARK GREATER 0) + math(EXPR _rk_wm_check "1 << ${KEY_REKEY_WM_CHECK_BITS}") + math(EXPR _rk_lead + "${KEY_REKEY_WATERMARK} << (${KEY_LEAF_BITS} + ${KEY_NODE_BITS})") + math(EXPR _rk_min "2 * ${_rk_wm_check}") + if(_rk_lead LESS _rk_min) + message(WARNING + "Re-key lead is ${_rk_lead} packets vs the watermark check interval " + "${_rk_wm_check}; a high-rate flow may exhaust its key batch before the " + "re-key completes (TX fails closed until it does). Raise KEY_LEAF_BITS, " + "KEY_NODE_BITS, or KEY_REKEY_WATERMARK.") + endif() +endif() diff --git a/cmake/config/lib/frct.cmake b/cmake/config/lib/frct.cmake new file mode 100644 index 00000000..1bd60aa0 --- /dev/null +++ b/cmake/config/lib/frct.cmake @@ -0,0 +1,43 @@ +# FRCT configuration for Ouroboros Options for the flow and retransmission control protocol in +# src/lib/frct.c + +# Delta-t protocol timers (Watson bound: 3*MPL + A + R). +# MPL is reported per IPCP (IPCP_*_MPL); A and R are FRCT-wide. +set(DELTA_T_ACK 1000 CACHE STRING + "Maximum time to acknowledge a packet (ms)") +set(DELTA_T_RTX 32000 CACHE STRING + "Maximum time to retransmit a packet (ms)") + +# FRCT configuration +set(FRCT_REORDER_QUEUE_SIZE 128 CACHE STRING + "Size of the reordering queue, must be a power of 2") +set(FRCT_START_WINDOW 128 CACHE STRING + "Start window, must be a power of 2") +set(FRCT_LINUX_RTT_ESTIMATOR TRUE CACHE BOOL + "Use Linux RTT estimator formula instead of the TCP RFC formula") +set(FRCT_RTO_MDEV_MULTIPLIER 2 CACHE STRING + "Multiplier for deviation term in the RTO: RTO = sRTT + (mdev << X)") +set(FRCT_RTO_INC_FACTOR 0 CACHE STRING + "Divisor for RTO increase after timeout: RTO += RTX >> X, 0: Karn/Partridge") +set(FRCT_RTO_MIN 250 CACHE STRING + "Hard floor for Retransmission Timeout (RTO) for FRCT (us)") +set(FRCT_TICK_TIME 5000 CACHE STRING + "Tick time for FRCT activity (retransmission, acknowledgments) (us)") +set(FRCT_DEBUG_STDOUT FALSE CACHE BOOL + "Print FRCT final counters to stdout at flow teardown") + +# Retransmission (RXM) configuration +set(RXM_MIN_RESOLUTION 20 CACHE STRING + "Minimum retransmission delay (ns), as a power to 2") +set(RXM_WHEEL_MULTIPLIER 4 CACHE STRING + "Factor for retransmission wheel levels as a power to 2") +set(RXM_WHEEL_LEVELS 3 CACHE STRING + "Number of levels in the retransmission wheel") +set(RXM_WHEEL_SLOTS_PER_LEVEL 256 CACHE STRING + "Number of slots per level in the retransmission wheel, must be a power of 2") + +# Acknowledgment wheel configuration +set(ACK_WHEEL_SLOTS 256 CACHE STRING + "Number of slots in the acknowledgment wheel, must be a power of 2") +set(ACK_WHEEL_RESOLUTION 18 CACHE STRING + "Minimum acknowledgment delay (ns), as a power to 2") diff --git a/cmake/config/lib/poa.cmake b/cmake/config/lib/poa.cmake new file mode 100644 index 00000000..c1ca10a8 --- /dev/null +++ b/cmake/config/lib/poa.cmake @@ -0,0 +1,37 @@ +# Flow Point of attachment (poa) configuration for Ouroboros + +set(POA_MGMT_FRAME_SIZE 16384 CACHE STRING + "Maximum size of a flow endpoint management frame, in bytes") + +# Management frames are retried or repeated, so a send never waits long. +set(POA_MGMT_SND_TIMEO 100 CACHE STRING + "Deadline for sending a management frame, in ms") + +# Flows on one PoA share its transmit queue, so congestion avoidance keys its link estimator on the +# PoA and needs a bound on their number. +set(POA_MAX_POAS 16 CACHE STRING + "Maximum number of points of attachment per IPCP") + +# UDP endpoints +set(POA_UDP_MPL 5000 CACHE STRING + "Default maximum packet lifetime for UDP flow endpoints, in ms") +set(POA_UDP4_MTU 1472 CACHE STRING + "Fallback UDP4 endpoint MTU when getsockopt(IP_MTU) is unavailable") +set(POA_UDP6_MTU 1452 CACHE STRING + "Fallback UDP6 endpoint MTU when getsockopt(IPV6_MTU) is unavailable") +set(POA_UDP_RD_BUF 65535 CACHE STRING + "UDP endpoint receive buffer in bytes. Bounds the advertised MTU") + +# Ethernet endpoints +set(POA_ETH_MPL 100 CACHE STRING + "Default maximum packet lifetime for Ethernet flow endpoints, in ms") +set(POA_ETH_QDISC_BYPASS false CACHE BOOL + "Bypass the Qdisc in the kernel when using raw sockets") +set(POA_ETH_SNDBUF 0 CACHE STRING + "Raw socket SO_SNDBUF in bytes (floored to one frame). 0 = kernel default") +set(POA_ETH_RCVBUF 0 CACHE STRING + "Raw socket SO_RCVBUF in bytes. 0 = kernel default") +set(POA_ETH_LO_MTU 9000 CACHE STRING + "Restrict Ethernet flow endpoint MTU over loopback interfaces") +set(POA_ETH_RD_BUF 16384 CACHE STRING + "Cap on the Ethernet endpoint receive buffer and MTU, in bytes") diff --git a/cmake/config/lib/ssm.cmake b/cmake/config/lib/ssm.cmake new file mode 100644 index 00000000..a9ac35c9 --- /dev/null +++ b/cmake/config/lib/ssm.cmake @@ -0,0 +1,168 @@ +# Secure Shared Memory (SSM) pool configuration for Ouroboros This file defines the allocation +# parameters for the secure shared memory pool allocator + +# Shared memory pool naming configuration +set(SSM_PREFIX "ouroboros" CACHE STRING + "Prefix for secure shared memory pools") + +# Pool naming (internal) +set(SSM_GSPP_NAME "/${SSM_PREFIX}.gspp" CACHE INTERNAL + "Name for the Global Shared Packet Pool") +set(SSM_PUP_NAME_FMT "/${SSM_PREFIX}.pup.%d" CACHE INTERNAL + "Format string for Per-User Pool names (uid as argument)") + +# Packet buffer configuration +set(SSM_POOL_NAME "/${SHM_PREFIX}.pool" CACHE INTERNAL + "Name for the main POSIX shared memory pool") +set(SSM_PK_BUFF_HEADSPACE 256 CACHE STRING + "Bytes of headspace to reserve for future headers") +set(SSM_PK_BUFF_TAILSPACE 32 CACHE STRING + "Bytes of tailspace to reserve for future tails") +set(SSM_RBUFF_SIZE 1024 CACHE STRING + "Number of slots in a flow's rbuff ring; must be a power of 2") +set(SSM_RBUFF_TXQ_DELAY 10 CACHE STRING + "Queueing delay a flow's tx ring may hold (ms); 0 is unlimited") +set(SSM_RBUFF_PREFIX "/${SHM_PREFIX}.rbuff." CACHE INTERNAL + "Prefix for rbuff POSIX shared memory filenames") +set(SSM_FLOW_SET_PREFIX "/${SHM_PREFIX}.set." CACHE INTERNAL + "Prefix for the POSIX shared memory flow set") + +# Number of shards per size class for reducing contention +set(SSM_POOL_SHARDS 4 CACHE STRING + "Number of allocator shards per size class") +set(SSM_POOL_RECLAIM_AGE_S 60 CACHE STRING + "Minimum age in seconds before a block is presumed stale and reclaimed") + +# Global Shared Packet Pool (GSPP) - for privileged processes Shared by all processes in 'ouroboros' +# group (~60 MB total) +set(SSM_GSPP_256_BLOCKS 1024 CACHE STRING + "GSPP: Number of 256B blocks") +set(SSM_GSPP_512_BLOCKS 2048 CACHE STRING + "GSPP: Number of 512B blocks") +set(SSM_GSPP_1K_BLOCKS 512 CACHE STRING + "GSPP: Number of 1KB blocks") +set(SSM_GSPP_2K_BLOCKS 384 CACHE STRING + "GSPP: Number of 2KB blocks") +set(SSM_GSPP_4K_BLOCKS 256 CACHE STRING + "GSPP: Number of 4KB blocks") +set(SSM_GSPP_16K_BLOCKS 128 CACHE STRING + "GSPP: Number of 16KB blocks") +set(SSM_GSPP_64K_BLOCKS 64 CACHE STRING + "GSPP: Number of 64KB blocks") +set(SSM_GSPP_256K_BLOCKS 32 CACHE STRING + "GSPP: Number of 256KB blocks") +set(SSM_GSPP_1M_BLOCKS 16 CACHE STRING + "GSPP: Number of 1MB blocks") + +# Per-User Pool (PUP) - for unprivileged applications Each unprivileged app gets its own smaller +# pool (~7.5 MB total) +set(SSM_PUP_256_BLOCKS 512 CACHE STRING + "PUP: Number of 256B blocks") +set(SSM_PUP_512_BLOCKS 512 CACHE STRING + "PUP: Number of 512B blocks") +set(SSM_PUP_1K_BLOCKS 512 CACHE STRING + "PUP: Number of 1KB blocks") +set(SSM_PUP_2K_BLOCKS 512 CACHE STRING + "PUP: Number of 2KB blocks") +set(SSM_PUP_4K_BLOCKS 32 CACHE STRING + "PUP: Number of 4KB blocks") +set(SSM_PUP_16K_BLOCKS 16 CACHE STRING + "PUP: Number of 16KB blocks") +set(SSM_PUP_64K_BLOCKS 8 CACHE STRING + "PUP: Number of 64KB blocks") +set(SSM_PUP_256K_BLOCKS 2 CACHE STRING + "PUP: Number of 256KB blocks") +set(SSM_PUP_1M_BLOCKS 0 CACHE STRING + "PUP: Number of 1MB blocks") + +# Zero classes too small for spb header + HEADSPACE + TAILSPACE + 1 B. +math(EXPR _SSM_MIN_USEFUL_CLASS + "32 + ${SSM_PK_BUFF_HEADSPACE} + ${SSM_PK_BUFF_TAILSPACE}") +foreach(_pair "256:256" "512:512" "1K:1024" "2K:2048") + string(REPLACE ":" ";" _p "${_pair}") + list(GET _p 0 _suffix) + list(GET _p 1 _size) + if(_size LESS _SSM_MIN_USEFUL_CLASS) + set(SSM_GSPP_${_suffix}_BLOCKS 0) + set(SSM_PUP_${_suffix}_BLOCKS 0) + endif() +endforeach() +unset(_SSM_MIN_USEFUL_CLASS) +unset(_p) +unset(_suffix) +unset(_size) + +# SSM pool size calculations +include(utils/HumanReadable) + +math(EXPR SSM_GSPP_TOTAL_SIZE + "(1 << 8) * ${SSM_GSPP_256_BLOCKS} + \ + (1 << 9) * ${SSM_GSPP_512_BLOCKS} + \ + (1 << 10) * ${SSM_GSPP_1K_BLOCKS} + \ + (1 << 11) * ${SSM_GSPP_2K_BLOCKS} + \ + (1 << 12) * ${SSM_GSPP_4K_BLOCKS} + \ + (1 << 14) * ${SSM_GSPP_16K_BLOCKS} + \ + (1 << 16) * ${SSM_GSPP_64K_BLOCKS} + \ + (1 << 18) * ${SSM_GSPP_256K_BLOCKS} + \ + (1 << 20) * ${SSM_GSPP_1M_BLOCKS}") + +set(SSM_GSPP_TOTAL_SIZE ${SSM_GSPP_TOTAL_SIZE} CACHE INTERNAL + "GSPP total size in bytes") + +math(EXPR SSM_PUP_TOTAL_SIZE + "(1 << 8) * ${SSM_PUP_256_BLOCKS} + \ + (1 << 9) * ${SSM_PUP_512_BLOCKS} + \ + (1 << 10) * ${SSM_PUP_1K_BLOCKS} + \ + (1 << 11) * ${SSM_PUP_2K_BLOCKS} + \ + (1 << 12) * ${SSM_PUP_4K_BLOCKS} + \ + (1 << 14) * ${SSM_PUP_16K_BLOCKS} + \ + (1 << 16) * ${SSM_PUP_64K_BLOCKS} + \ + (1 << 18) * ${SSM_PUP_256K_BLOCKS} + \ + (1 << 20) * ${SSM_PUP_1M_BLOCKS}") + +set(SSM_PUP_TOTAL_SIZE ${SSM_PUP_TOTAL_SIZE} CACHE INTERNAL + "PUP total size in bytes") + +set(SSM_POOL_TOTAL_SIZE ${SSM_GSPP_TOTAL_SIZE} CACHE INTERNAL + "Total shared memory pool size in bytes") + +format_bytes_human_readable(${SSM_GSPP_TOTAL_SIZE} SSM_GSPP_SIZE_DISPLAY) +format_bytes_human_readable(${SSM_PUP_TOTAL_SIZE} SSM_PUP_SIZE_DISPLAY) + +message(STATUS "Secure Shared Memory Pool Configuration:") +message(STATUS " Pool prefix: ${SSM_PREFIX}") +message(STATUS " Size classes: " + "256B, 512B, 1KiB, 2KiB, 4KiB, 16KiB, 64KiB, 256KiB, 1MiB") +message(STATUS " Max allocation: 1 MB") +message(STATUS " Shards per class: ${SSM_POOL_SHARDS}") +message(STATUS " GSPP (privileged): ${SSM_GSPP_SIZE_DISPLAY} " + "(${SSM_GSPP_TOTAL_SIZE} bytes)") +message(STATUS " Blocks: ${SSM_GSPP_256_BLOCKS}, ${SSM_GSPP_512_BLOCKS}, " + "${SSM_GSPP_1K_BLOCKS}, ${SSM_GSPP_2K_BLOCKS}, ${SSM_GSPP_4K_BLOCKS}, " + "${SSM_GSPP_16K_BLOCKS}, ${SSM_GSPP_64K_BLOCKS}, ${SSM_GSPP_256K_BLOCKS}, " + "${SSM_GSPP_1M_BLOCKS}") +message(STATUS " PUP (unprivileged): ${SSM_PUP_SIZE_DISPLAY} " + "(${SSM_PUP_TOTAL_SIZE} bytes)") +message(STATUS " Blocks: ${SSM_PUP_256_BLOCKS}, ${SSM_PUP_512_BLOCKS}, " + "${SSM_PUP_1K_BLOCKS}, ${SSM_PUP_2K_BLOCKS}, ${SSM_PUP_4K_BLOCKS}, " + "${SSM_PUP_16K_BLOCKS}, ${SSM_PUP_64K_BLOCKS}, ${SSM_PUP_256K_BLOCKS}, " + "${SSM_PUP_1M_BLOCKS}") + +# FRCT reorder queue must fit in every enabled size class. If RQ_SIZE >= any backing pool, the +# receiver advertises a window the pool cannot back; np1_flow_write fails under load and a single +# dropped fragment wedges the flow. Auto-zeroed classes are skipped. +foreach(_class 256 512 1K 2K) + if(SSM_PUP_${_class}_BLOCKS GREATER 0 + AND NOT FRCT_REORDER_QUEUE_SIZE LESS SSM_PUP_${_class}_BLOCKS) + message(FATAL_ERROR + "FRCT_REORDER_QUEUE_SIZE (${FRCT_REORDER_QUEUE_SIZE}) must be " + "< SSM_PUP_${_class}_BLOCKS (${SSM_PUP_${_class}_BLOCKS}): " + "the FC window cannot exceed the pool that backs OOO stashing.") + endif() + if(SSM_GSPP_${_class}_BLOCKS GREATER 0 + AND NOT FRCT_REORDER_QUEUE_SIZE LESS SSM_GSPP_${_class}_BLOCKS) + message(FATAL_ERROR + "FRCT_REORDER_QUEUE_SIZE (${FRCT_REORDER_QUEUE_SIZE}) must be " + "< SSM_GSPP_${_class}_BLOCKS (${SSM_GSPP_${_class}_BLOCKS}).") + endif() +endforeach() |
