1/* @ajax/mesh-abi-host-status: The host status block's first region: uptime, peers, rates, names, isolation, cluster size.
2 *
3 * Part of alpha-c-mesh, a C port of alpha-rust-mesh (README.md says from where). */
4#ifndef MESH_ABI_HOST_STATUS_H
5#define MESH_ABI_HOST_STATUS_H
67#include <stdbool.h>
8#include <stddef.h>
9#include <stdint.h>
1011/* host status block (offsets within it) */
12#define MESH_S_UPTIME_MS 0x00 /* u64 */
13#define MESH_S_EPOCH 0x08 /* u32 = H_EPOCH (blinks) */
14#define MESH_S_SYSTEM 0x0c /* u32 0..N-1, PEER_NONE single */
15#define MESH_S_PEER_STATE 0x10 /* u32 0 single, 1 waiting (no leader this member can reach: no majority), 2 up (a leader with a majority) */
16#define MESH_S_PROGRAMS 0x14 /* u32 non-empty slots */
17#define MESH_S_SMS_TOTAL 0x18 /* u32 */
18#define MESH_S_GREEN 0x1c /* u32 1: meshd's context is a green context */
19#define MESH_S_TASKS_PER_S 0x20 /* f32, all programs, last second */
20#define MESH_S_HEAP_FREE 0x24 /* u32 free view-heap pages */
21#define MESH_S_SMS 0x28 /* u32 SMs of meshd's context */
22#define MESH_S_PEER_RTT_US 0x2c /* f32 */
23/* The lockstep program's progress (its next task arg as meshd computes it,
24 * u64 with carry) and S_LOCK_VIEW, written together under one lock at each of
25 * its completions: a consistent pair (the view itself changes in place). */
26#define MESH_S_LOCK_STEP 0x30 /* u64 */
27#define MESH_S_HTTP_REQUESTS 0x38 /* u32 requests relayed (control + TCP) */
28#define MESH_S_BLINK_US 0x3c /* u32 the last blink, H_BLINK set to cleared */
29#define MESH_S_HOSTNAME 0x40 /* 32 bytes NUL padded */
30#define MESH_S_GPU 0x60 /* 32 bytes */
31#define MESH_S_PROGRAMS_DIR 0x80 /* 64 bytes, --programs DIR */
32#define MESH_S_LAST_HTTP 0xc0 /* 64 bytes, the last request line */
33#define MESH_S_HTTP_ADDR 0x100 /* 64 bytes */
34#define MESH_S_LOCK_VIEW 0x140 /* 32 bytes: the lockstep program's view prefix */
35#define MESH_S_LOCK_NAME 0x160 /* 16 bytes: the lockstep program's name, NUL padded */
36#define MESH_S_RATES 0x170 /* f32 x PROG_SLOTS: tasks/s per slot, last second */
37#define MESH_S_LAST_BLINK_MS 0x1f0 /* u64 uptime ms at the last blink */
38#define MESH_S_ISOLATION 0x1f8 /* u32 ISOLATION_*: how meshd runs the programs (--isolation) */
39/* One CUDA context; a module change blinks every program (the default). */
40#define MESH_ISOLATION_BLINK 0u
41/* The cluster (0x200..): its size, this machine's capabilities, and one */
42/* record per member as this meshd sees it (its own included). */
43#define MESH_S_SYSTEMS 0x200 /* u32 N (1 single) */
44#define MESH_S_LINKED 0x204 /* u32 bit k: system k is linked (JOINed), this one included */
45/* 0x208, 0x20c: unused (this machine's cc and blocks/SM are the header's */
46/* H_CC and H_BLOCKS_PER_SM, which every snapshot carries). */
47#define MESH_S_ARCH 0x210 /* 16 bytes: the host's CPU architecture (aarch64, x86_64) */
48#define MESH_S_LOCK_WAIT_US 0x220 /* f32: mean wait per exchange round for the slowest member, last second */
49#define MESH_S_SESSIONS 0x224 /* u32 cluster sessions that reached UP */
50/* One MPS client process per loaded image under meshd's private MPS daemon:
51 * module changes halt no other program. */
52#define MESH_ISOLATION_MPS 1u
53/* Metal: leases (no resident kernels); a module change halts only its slot. */
54#define MESH_ISOLATION_LEASE 2u
5556/* The Rust const asserts that only involve this package. */
57_Static_assert(MESH_S_LAST_BLINK_MS + 8 <= MESH_S_ISOLATION, "S_LAST_BLINK_MS + 8 <= S_ISOLATION");
58_Static_assert(MESH_S_ISOLATION + 4 <= MESH_S_SYSTEMS, "S_ISOLATION + 4 <= S_SYSTEMS");
59_Static_assert(MESH_S_ARCH + 16 <= MESH_S_LOCK_WAIT_US, "S_ARCH + 16 <= S_LOCK_WAIT_US");
60_Static_assert(MESH_S_LOCK_VIEW + 32 <= MESH_S_LOCK_NAME, "S_LOCK_VIEW + 32 <= S_LOCK_NAME");
61_Static_assert(MESH_S_HTTP_ADDR + 64 <= MESH_S_LOCK_VIEW, "S_HTTP_ADDR + 64 <= S_LOCK_VIEW");
62_Static_assert((MESH_S_LOCK_STEP % 8 == 0), "S_LOCK_STEP.is_multiple_of(8)");
63_Static_assert((MESH_S_LAST_BLINK_MS % 8 == 0), "S_LAST_BLINK_MS.is_multiple_of(8)");
6465#endif