// Copyright 2019 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
library fuchsia.kernel;

using zx;

// The zx library does not include zx_info_kmem_stats_t, so this table is mirroring it.
// See zircon/system/public/zircon/syscalls/object.h for more details.
type MemoryStats = table {
    1: total_bytes uint64;
    2: free_bytes uint64;
    3: wired_bytes uint64;
    4: total_heap_bytes uint64;
    5: free_heap_bytes uint64;
    6: vmo_bytes uint64;
    7: mmu_overhead_bytes uint64;
    8: ipc_bytes uint64;
    9: other_bytes uint64;
};

// Similarly, this table mirrors zx_info_kmem_stats_extended_t.
// See zircon/system/public/zircon/syscalls/object.h for more details.
type MemoryStatsExtended = table {
    1: total_bytes uint64;
    2: free_bytes uint64;
    3: wired_bytes uint64;
    4: total_heap_bytes uint64;
    5: free_heap_bytes uint64;
    6: vmo_bytes uint64;
    7: vmo_pager_total_bytes uint64;
    8: vmo_pager_newest_bytes uint64;
    9: vmo_pager_oldest_bytes uint64;
    10: vmo_discardable_locked_bytes uint64;
    11: vmo_discardable_unlocked_bytes uint64;
    12: mmu_overhead_bytes uint64;
    13: ipc_bytes uint64;
    14: other_bytes uint64;
};

// Similarly, this table mirrors zx_info_kmem_stats_compression_t.
// See zircon/system/public/zircon/syscalls/object.h for more details.
@available(added=16)
type MemoryStatsCompression = table {
    1: uncompressed_storage_bytes uint64;
    2: compressed_storage_bytes uint64;
    3: compressed_fragmentation_bytes uint64;
    4: compression_time zx.Duration;
    5: decompression_time zx.Duration;
    6: total_page_compression_attempts uint64;
    7: failed_page_compression_attempts uint64;
    8: total_page_decompressions uint64;
    9: compressed_page_evictions uint64;
    10: eager_page_compressions uint64;
    11: memory_pressure_page_compressions uint64;
    12: critical_memory_page_compressions uint64;
    13: pages_decompressed_unit_ns uint64;
    14: pages_decompressed_within_log_time array<uint64, 8>;
};

// Similarly, this table mirrors zx_info_cpu_stats_t.
// See zircon/system/public/zircon/syscalls/object.h for more details.
type PerCpuStats = table {
    1: cpu_number uint32;
    2: flags uint32;
    3: idle_time zx.Duration;
    4: reschedules uint64;
    5: context_switches uint64;
    6: irq_preempts uint64;
    7: yields uint64;
    8: ints uint64;
    9: timer_ints uint64;
    10: timers uint64;
    11: page_faults uint64;
    12: exceptions uint64;
    13: syscalls uint64;
    14: reschedule_ipis uint64;
    15: generic_ipis uint64;
};

type CpuStats = struct {
    /// This is the total number of CPUs on the actual device. This may not be the same as the length
    /// of the vector `per_cpu_stats` as it is possible the underlying syscall will not return stats
    /// for all CPUs.
    actual_num_cpus uint64;
    per_cpu_stats vector<PerCpuStats>:<zx.MAX_CPUS, optional>;
};

/// Protocol for providing kernel stats. This is roughly a wrapper around zx_object_get_info for
/// the ZX_INFO_KMEM_STATS, ZX_INFO_KMEM_STATS_EXTENDED and ZX_INFO_CPU_STATS topics, which today
/// require the very powerful 'Root Resource' capability to obtain. Instead of vending out that
/// capability, programs that just want stats should use this service instead. If for some reason
/// the protocol fails to retrieve stats, which will be an un-recoverable error, it will close the
/// channel.
@discoverable(server="platform")
closed protocol Stats {
    strict GetMemoryStats() -> (struct {
        stats MemoryStats;
    });

    strict GetMemoryStatsExtended() -> (struct {
        stats MemoryStatsExtended;
    });

    @available(added=16)
    strict GetMemoryStatsCompression() -> (MemoryStatsCompression);

    strict GetCpuStats() -> (struct {
        stats CpuStats;
    });

    /// Gets the average load as a percentage (0.0 - 100.0) from each CPU over the specified
    /// duration.
    ///
    /// Load is calculated as (100 - %idle), where %idle is the percentage value of idle_time (from
    /// PerCpuStats) over a time duration.
    strict GetCpuLoad(struct {
        duration zx.Duration;
    }) -> (struct {
        per_cpu_load vector<float32>:zx.MAX_CPUS;
    });
};
