LCOV - code coverage report
Current view: top level - disco/events - fd_boot_report.h (source / functions) Hit Total Coverage
Test: cov.lcov Lines: 3 3 100.0 %
Date: 2026-09-17 04:28:31 Functions: 0 0 -

          Line data    Source code
       1             : #ifndef HEADER_fd_src_disco_events_fd_boot_report_h
       2             : #define HEADER_fd_src_disco_events_fd_boot_report_h
       3             : 
       4             : /* fd_boot_report collects and publishes the boot telemetry event
       5             :    (schema id 10, schema/boot.json).  The event is a wide fingerprint
       6             :    of the host taken once at process start: collection runs in the
       7             :    event tile's privileged_init (root, pre-sandbox, full /proc, /sys
       8             :    and device access), and the encoded event is pushed into the event
       9             :    queue in unprivileged_init, to be delivered whenever the client
      10             :    connects.
      11             : 
      12             :    The schema is variable-length so the generator emits no C struct or
      13             :    serializer for it; the struct below, the collector, and the
      14             :    protobuf encoder are maintained by hand against schema/boot.json.
      15             :    Field numbers in the encoder are the 1-based positions of fields in
      16             :    the schema file; enum values are the 1-based positions of variants.
      17             : 
      18             :    Facts only knowable to the boot process travel on the topology:
      19             :    config-derived paths and the bound interface are tile config fields,
      20             :    and the rendered config documents are filled into fd_topo_t by the
      21             :    app during topology construction. */
      22             : 
      23             : #include "fd_circq.h"
      24             : #include "fd_event_client.h"
      25             : #include "../topo/fd_topo.h"
      26             : 
      27          18 : #define FD_BOOT_REPORT_JSON_MAX      (262144UL)
      28          15 : #define FD_BOOT_REPORT_USER_JSON_MAX (131072UL)
      29             : 
      30             : FD_STATIC_ASSERT( sizeof(((fd_topo_t *)0)->resolved_config_json)==FD_BOOT_REPORT_JSON_MAX,      boot_report_resolved_json_sz );
      31             : FD_STATIC_ASSERT( sizeof(((fd_topo_t *)0)->user_config_json)    ==FD_BOOT_REPORT_USER_JSON_MAX, boot_report_user_json_sz );
      32             : 
      33             : /* Conservative bound on the encoded size of a boot event (all strings
      34             :    at max_len, all arrays full).  Dominated by the two JSON dumps. */
      35             : 
      36          12 : #define FD_EVENT_BOOT_BUF_MAX (2UL*FD_BOOT_REPORT_JSON_MAX+FD_BOOT_REPORT_USER_JSON_MAX+131072UL)
      37             : 
      38             : struct fd_boot_report_dimm {
      39             :   ulong size_bytes;
      40             :   char  mem_type[ 9 ];
      41             :   ulong speed_mts;
      42             :   ulong rated_speed_mts;
      43             :   char  manufacturer[ 33 ];
      44             :   char  part_number[ 33 ];
      45             : };
      46             : typedef struct fd_boot_report_dimm fd_boot_report_dimm_t;
      47             : 
      48             : struct fd_boot_report_nic {
      49             :   char   name[ 17 ];
      50             :   char   driver[ 33 ];
      51             :   char   driver_version[ 65 ];
      52             :   char   firmware_version[ 65 ];
      53             :   uchar  pcie_current_link_width;
      54             :   uchar  pcie_max_link_width;
      55             :   char   pcie_current_link_speed[ 17 ];
      56             :   char   pcie_max_link_speed[ 17 ];
      57             :   char   bus_info[ 33 ];
      58             :   ushort pci_device_id;
      59             :   ushort pci_vendor_id;
      60             :   ushort pci_subsystem_vendor_id;
      61             :   ushort pci_subsystem_device_id;
      62             :   ulong  numa_node;
      63             :   ulong  mtu;
      64             :   ulong  link_speed_mbps;
      65             :   int    carrier;
      66             :   int    promiscuous;
      67             :   ushort channels_current;
      68             :   ushort channels_max;
      69             :   ulong  rx_ring_size;
      70             :   ulong  tx_ring_size;
      71             :   ulong  rx_ring_max;
      72             :   ulong  tx_ring_max;
      73             :   char   offloads[ 64 ][ 36 ];
      74             :   ulong  offloads_cnt;
      75             :   int    rss_flow_hash_udp4;
      76             :   ulong  coalesce_rx_usecs;
      77             :   int    coalesce_adaptive_rx;
      78             :   char   rss_hash_func[ 17 ];
      79             :   ulong  ntuple_rule_count;
      80             :   int    is_bond_master;
      81             : };
      82             : typedef struct fd_boot_report_nic fd_boot_report_nic_t;
      83             : 
      84             : struct fd_boot_report_block_device {
      85             :   char  name[ 65 ];
      86             :   char  model[ 49 ];
      87             :   ulong capacity_bytes;
      88             :   int   rotational;
      89             :   char  transport[ 17 ];
      90             :   char  scheduler[ 17 ];
      91             : };
      92             : typedef struct fd_boot_report_block_device fd_boot_report_block_device_t;
      93             : 
      94             : struct fd_boot_report_nvme {
      95             :   uchar device_idx;
      96             :   char  firmware_rev[ 33 ];
      97             :   uchar critical_warning;
      98             :   uchar available_spare_pct;
      99             :   uchar percentage_used;
     100             :   ulong media_errors;
     101             :   uchar numa_node;
     102             :   ulong namespace_size_bytes;
     103             : };
     104             : typedef struct fd_boot_report_nvme fd_boot_report_nvme_t;
     105             : 
     106             : struct fd_boot_report_mdraid {
     107             :   char  name[ 33 ];
     108             :   char  level[ 17 ];
     109             :   uchar device_count;
     110             :   int   degraded;
     111             : };
     112             : typedef struct fd_boot_report_mdraid fd_boot_report_mdraid_t;
     113             : 
     114             : struct fd_boot_report_fs {
     115             :   uchar device_idx; /* index into block_devices, 255 if not a local block device */
     116             :   char  fs_type[ 17 ];
     117             :   char  mount_options[ 257 ];
     118             :   ulong capacity_bytes;
     119             :   ulong free_bytes;
     120             : };
     121             : typedef struct fd_boot_report_fs fd_boot_report_fs_t;
     122             : 
     123             : struct fd_boot_report {
     124             :   char  kernel_release[ 66 ];
     125             :   char  kernel_version[ 130 ];
     126             :   char  mitigations[ 32 ][ 33 ];
     127             :   ulong mitigations_cnt;
     128             :   char  distro_id[ 65 ];
     129             :   char  distro_version_id[ 65 ];
     130             :   char  distro_id_like[ 129 ];
     131             :   int   libc_kind;
     132             :   char  libc_version[ 33 ];
     133             :   int   build_machine_target;
     134             :   char  build_extras[ 129 ];
     135             :   int   build_git_dirty;
     136             :   int   compiler;
     137             :   char  compiler_version[ 129 ];
     138             :   ulong build_timestamp_nanos;
     139             :   char  build_features[ 16 ][ 8 ];
     140             :   ulong build_features_cnt;
     141             : 
     142             :   int    cpu_arch;
     143             :   int    cpu_vendor;
     144             :   char   cpu_model_name[ 97 ];
     145             :   ushort cpu_family;
     146             :   ushort cpu_model_id;
     147             :   uchar  cpu_stepping;
     148             :   ulong  cpu_microcode_version;
     149             :   ushort cpu_logical_count;
     150             :   ushort cpu_physical_core_count;
     151             :   uchar  cpu_socket_count;
     152             :   int    smt_active;
     153             :   int    cpufreq_governor;
     154             :   int    cpufreq_driver;
     155             :   int    cpu_energy_perf_preference;
     156             :   int    cpu_idle_driver;
     157             :   char   cpu_max_enabled_cstate[ 17 ];
     158             : 
     159             :   ulong host_memory_bytes;
     160             :   ulong host_memory_available_bytes;
     161             :   uchar  numa_cpu_to_node[ 1024 ];
     162             :   ulong  numa_cpu_to_node_cnt;
     163             :   ushort isolated_cpus[ 1024 ];
     164             :   ulong  isolated_cpus_cnt;
     165             : 
     166             :   fd_boot_report_dimm_t dmi_dimms[ 64 ];
     167             :   ulong                 dmi_dimms_cnt;
     168             : 
     169             :   fd_boot_report_nic_t nic_devices[ 16 ];
     170             :   ulong                nic_devices_cnt;
     171             :   char                 nic_bond_slaves[ 16 ][ 17 ];
     172             :   ulong                nic_bond_slaves_cnt;
     173             :   int                  bond_mode;
     174             :   uchar                bound_nic_idx;
     175             :   uchar                net_bpf_jit_enable;
     176             : 
     177             :   char  dmi_sys_vendor[ 65 ];
     178             :   char  dmi_product_name[ 65 ];
     179             :   char  dmi_bios_version[ 65 ];
     180             :   char  dmi_bios_date[ 17 ];
     181             :   char  dmi_board_vendor[ 65 ];
     182             :   char  dmi_board_name[ 65 ];
     183             :   int   dmi_chassis_type;
     184             :   int   iommu_mode;
     185             :   int   hypervisor_vendor;
     186             : 
     187             :   int   container_type;
     188             :   int   kubernetes_pod;
     189             :   ulong cgroup_memory_limit_bytes;
     190             :   ulong cgroup_memory_high_bytes;
     191             :   ulong cgroup_swap_limit_bytes;
     192             :   uint  cgroup_cpu_quota_millicores;
     193             : 
     194             :   fd_boot_report_block_device_t block_devices[ 24 ];
     195             :   ulong                         block_devices_cnt;
     196             :   fd_boot_report_nvme_t         nvme_devices[ 16 ];
     197             :   ulong                         nvme_devices_cnt;
     198             :   fd_boot_report_mdraid_t       mdraid_arrays[ 16 ];
     199             :   ulong                         mdraid_arrays_cnt;
     200             :   fd_boot_report_fs_t           filesystems[ 8 ];
     201             :   ulong                         filesystems_cnt;
     202             :   uchar                         accounts_fs_idx;
     203             :   uchar                         snapshots_fs_idx;
     204             :   uchar                         log_fs_idx;
     205             :   uchar                         shredb_fs_idx;
     206             :   uchar                         guidb_fs_idx;
     207             : 
     208             :   char   resolved_config_json[ FD_BOOT_REPORT_JSON_MAX ];
     209             :   ulong  resolved_config_json_len;
     210             :   char   user_config_json[ FD_BOOT_REPORT_USER_JSON_MAX ];
     211             :   ulong  user_config_json_len;
     212             :   char   topology_json[ FD_BOOT_REPORT_JSON_MAX ];
     213             :   ulong  topology_json_len;
     214             :   ushort tile_count;
     215             :   ulong  memory_total;
     216             :   ulong  memory_gigantic_pages;
     217             :   ulong  memory_huge_pages;
     218             :   ulong  memory_normal_pages;
     219             :   ulong  process_start_time_nanos;
     220             :   uint   feature_set_id;
     221             : };
     222             : typedef struct fd_boot_report fd_boot_report_t;
     223             : 
     224             : FD_PROTOTYPES_BEGIN
     225             : 
     226             : /* fd_boot_report_collect fills report from the local machine and the
     227             :    boot facts on tile->event.  Must run with full privileges (reads
     228             :    /sys/firmware/dmi entries, NVMe admin ioctls) and before sandboxing.
     229             :    Unreadable machine sources leave zero/unknown values; unset config
     230             :    documents on the tile abort. */
     231             : 
     232             : void
     233             : fd_boot_report_collect( fd_boot_report_t *     report,
     234             :                         fd_topo_t const *      topo,
     235             :                         fd_topo_tile_t const * tile );
     236             : 
     237             : /* fd_boot_report_publish renders topology_json from topo, encodes the
     238             :    event, and pushes it into the event queue with a freshly reserved
     239             :    event id. */
     240             : 
     241             : void
     242             : fd_boot_report_publish( fd_boot_report_t *  report,
     243             :                         fd_topo_t const *   topo,
     244             :                         fd_circq_t *        circq,
     245             :                         fd_event_client_t * client );
     246             : 
     247             : FD_PROTOTYPES_END
     248             : 
     249             : #endif /* HEADER_fd_src_disco_events_fd_boot_report_h */

Generated by: LCOV version 1.14