LCOV - code coverage report
Current view: top level - disco/events - fd_boot_report.h (source / functions) Hit Total Coverage
Test: cov.lcov Lines: 0 3 0.0 %
Date: 2026-10-22 18:10:43 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           0 : #define FD_BOOT_REPORT_JSON_MAX      (262144UL)
      28           0 : #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           0 : #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             :   int   has_health;
     104             : };
     105             : typedef struct fd_boot_report_nvme fd_boot_report_nvme_t;
     106             : 
     107             : struct fd_boot_report_mdraid {
     108             :   char  name[ 33 ];
     109             :   char  level[ 17 ];
     110             :   uchar device_count;
     111             :   int   degraded;
     112             : };
     113             : typedef struct fd_boot_report_mdraid fd_boot_report_mdraid_t;
     114             : 
     115             : struct fd_boot_report_fs {
     116             :   uchar device_idx; /* index into block_devices, 255 if not a local block device */
     117             :   char  fs_type[ 17 ];
     118             :   char  mount_options[ 257 ];
     119             :   ulong capacity_bytes;
     120             :   ulong free_bytes;
     121             : };
     122             : typedef struct fd_boot_report_fs fd_boot_report_fs_t;
     123             : 
     124             : struct fd_boot_report {
     125             :   char  kernel_release[ 66 ];
     126             :   char  kernel_version[ 130 ];
     127             :   char  mitigations[ 32 ][ 33 ];
     128             :   ulong mitigations_cnt;
     129             :   char  distro_id[ 65 ];
     130             :   char  distro_version_id[ 65 ];
     131             :   char  distro_id_like[ 129 ];
     132             :   int   libc_kind;
     133             :   char  libc_version[ 33 ];
     134             :   int   build_machine_target;
     135             :   char  build_extras[ 129 ];
     136             :   int   build_git_dirty;
     137             :   int   compiler;
     138             :   char  compiler_version[ 129 ];
     139             :   ulong build_timestamp_nanos;
     140             :   char  build_features[ 16 ][ 8 ];
     141             :   ulong build_features_cnt;
     142             : 
     143             :   int    cpu_arch;
     144             :   int    cpu_vendor;
     145             :   char   cpu_model_name[ 97 ];
     146             :   ushort cpu_family;
     147             :   ushort cpu_model_id;
     148             :   uchar  cpu_stepping;
     149             :   ulong  cpu_microcode_version;
     150             :   ushort cpu_logical_count;
     151             :   ushort cpu_physical_core_count;
     152             :   uchar  cpu_socket_count;
     153             :   int    smt_active;
     154             :   int    cpufreq_governor;
     155             :   int    cpufreq_driver;
     156             :   int    cpu_energy_perf_preference;
     157             :   int    cpu_idle_driver;
     158             :   char   cpu_max_enabled_cstate[ 17 ];
     159             :   char   cpu_features[ 16 ][ 8 ];
     160             :   ulong  cpu_features_cnt;
     161             : 
     162             :   ulong host_memory_bytes;
     163             :   ulong host_memory_available_bytes;
     164             :   uchar  numa_cpu_to_node[ 1024 ];
     165             :   ulong  numa_cpu_to_node_cnt;
     166             :   ushort isolated_cpus[ 1024 ];
     167             :   ulong  isolated_cpus_cnt;
     168             :   ushort l3_cpu_to_domain[ 1024 ];
     169             :   ulong  l3_cpu_to_domain_cnt;
     170             :   ushort cpu_to_core[ 1024 ];
     171             :   ulong  cpu_to_core_cnt;
     172             :   ushort launch_cpus[ 1024 ];
     173             :   ulong  launch_cpus_cnt;
     174             :   int    cpuset_partition;
     175             :   ushort cpuset_partition_cpus[ 1024 ];
     176             :   ulong  cpuset_partition_cpus_cnt;
     177             :   int    float_pool; /* not encoded; the launchers float floaters, else pin them */
     178             : 
     179             :   fd_boot_report_dimm_t dmi_dimms[ 64 ];
     180             :   ulong                 dmi_dimms_cnt;
     181             : 
     182             :   fd_boot_report_nic_t nic_devices[ 16 ];
     183             :   ulong                nic_devices_cnt;
     184             :   char                 nic_bond_slaves[ 16 ][ 17 ];
     185             :   ulong                nic_bond_slaves_cnt;
     186             :   int                  bond_mode;
     187             :   uchar                bound_nic_idx;
     188             :   uchar                net_bpf_jit_enable;
     189             : 
     190             :   char  dmi_sys_vendor[ 65 ];
     191             :   char  dmi_product_name[ 65 ];
     192             :   char  dmi_bios_version[ 65 ];
     193             :   char  dmi_bios_date[ 17 ];
     194             :   char  dmi_board_vendor[ 65 ];
     195             :   char  dmi_board_name[ 65 ];
     196             :   int   dmi_chassis_type;
     197             :   int   iommu_mode;
     198             :   int   hypervisor_vendor;
     199             : 
     200             :   int   container_type;
     201             :   int   kubernetes_pod;
     202             :   ulong cgroup_memory_limit_bytes;
     203             :   ulong cgroup_memory_high_bytes;
     204             :   ulong cgroup_swap_limit_bytes;
     205             :   uint  cgroup_cpu_quota_millicores;
     206             : 
     207             :   fd_boot_report_block_device_t block_devices[ 24 ];
     208             :   ulong                         block_devices_cnt;
     209             :   fd_boot_report_nvme_t         nvme_devices[ 16 ];
     210             :   ulong                         nvme_devices_cnt;
     211             :   fd_boot_report_mdraid_t       mdraid_arrays[ 16 ];
     212             :   ulong                         mdraid_arrays_cnt;
     213             :   fd_boot_report_fs_t           filesystems[ 8 ];
     214             :   ulong                         filesystems_cnt;
     215             :   uchar                         accounts_fs_idx;
     216             :   uchar                         snapshots_fs_idx;
     217             :   uchar                         log_fs_idx;
     218             :   uchar                         shredb_fs_idx;
     219             :   uchar                         guidb_fs_idx;
     220             : 
     221             :   char   resolved_config_json[ FD_BOOT_REPORT_JSON_MAX ];
     222             :   ulong  resolved_config_json_len;
     223             :   char   user_config_json[ FD_BOOT_REPORT_USER_JSON_MAX ];
     224             :   ulong  user_config_json_len;
     225             :   char   topology_json[ FD_BOOT_REPORT_JSON_MAX ];
     226             :   ulong  topology_json_len;
     227             :   ushort tile_count;
     228             :   ulong  memory_total;
     229             :   ulong  memory_gigantic_pages;
     230             :   ulong  memory_huge_pages;
     231             :   ulong  memory_normal_pages;
     232             :   ulong  process_start_time_nanos;
     233             :   uint   feature_set_id;
     234             : };
     235             : typedef struct fd_boot_report fd_boot_report_t;
     236             : 
     237             : FD_PROTOTYPES_BEGIN
     238             : 
     239             : /* fd_boot_report_collect fills report from the local machine and the
     240             :    boot facts on tile->event.  Must run with full privileges (reads
     241             :    /sys/firmware/dmi entries, NVMe admin ioctls) and before sandboxing.
     242             :    Unreadable machine sources leave zero/unknown values; unset config
     243             :    documents on the tile abort. */
     244             : 
     245             : void
     246             : fd_boot_report_collect( fd_boot_report_t *     report,
     247             :                         fd_topo_t const *      topo,
     248             :                         fd_topo_tile_t const * tile );
     249             : 
     250             : /* fd_boot_report_publish renders topology_json from topo, encodes the
     251             :    event, and pushes it into the event queue with a freshly reserved
     252             :    event id. */
     253             : 
     254             : void
     255             : fd_boot_report_publish( fd_boot_report_t *  report,
     256             :                         fd_topo_t const *   topo,
     257             :                         fd_circq_t *        circq,
     258             :                         fd_event_client_t * client );
     259             : 
     260             : FD_PROTOTYPES_END
     261             : 
     262             : #endif /* HEADER_fd_src_disco_events_fd_boot_report_h */

Generated by: LCOV version 1.14