blob: b0843d813c22d55db391d26093536fa12808d03d [file] [log] [blame]
// Copyright 2018 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.wlan.stats;
struct Counter {
uint64 count;
string name;
};
struct PacketCounter {
Counter in;
Counter out;
Counter drop;
Counter in_bytes;
Counter out_bytes;
Counter drop_bytes;
};
// LINT.IfChange
struct DispatcherStats {
PacketCounter any_packet;
PacketCounter mgmt_frame;
PacketCounter ctrl_frame;
PacketCounter data_frame;
};
const uint8 RSSI_BINS = 129;
/// RssiStats count the occurrence of the RSSIs.
/// RSSI value r's occurrence is counted in the bin[-r],
/// where r is defined in [-128, 0] in dBm.
struct RssiStats {
// TODO(alexandrew): Change this to array.
vector<uint64>:RSSI_BINS hist;
};
// LINT.IfChange
/// Histogram bucket.
struct HistBucket {
/// Index into a lookup table for each histogram type. The lookup table for each type is
/// described below in the comments for each type.
uint16 bucket_index;
/// The count of samples in the bucket.
uint64 num_samples;
};
/// All histograms have a fixed number of buckets. To save space, each histogram type
/// uses a vector to hold only non-empty buckets (a sparse histogram), with these constants as the
/// max size of each vector.
/// Noise floor values range from -255 to -1 dBm.
const uint8 MAX_NOISE_FLOOR_SAMPLES = 255;
/// Size of RxRateIndexHistogram lookup table (see comments in RxRateIndexHistogram).
const uint8 MAX_RX_RATE_INDEX_SAMPLES = 196;
/// RSSI values range from -255 to -1 dBm.
const uint8 MAX_RSSI_SAMPLES = 255;
/// SNR values range from 0 to 255 dB.
const uint16 MAX_SNR_SAMPLES = 256;
/// Antenna frequency.
enum AntennaFreq : uint8 {
/// 2.4 GHz.
ANTENNA_2_G = 1;
/// 5 GHz.
ANTENNA_5_G = 2;
};
/// Identifier for antenna.
struct AntennaId {
AntennaFreq freq;
/// 0 indexed antenna number of freq.
uint8 index;
};
/// The scope of the histogram, e.g. if the histogram contains data for the entire station, or has
/// data for just a single antenna.
enum HistScope : uint8 {
STATION = 1;
PER_ANTENNA = 2;
};
/// Histogram for noise floor samples.
struct NoiseFloorHistogram {
HistScope hist_scope;
/// If hist_scope is PER_ANTENNA, antenna_id must be provided.
AntennaId? antenna_id;
/// Sparse histogram of noise floor of current channel in dBm. Each sample's bucket_index is an
/// index into this list of dBm values: [-255, -254, ... -1]. For example, if
/// noise_floor_samples contains a HistBucket with bucket_index = 165 and num_samples = 50, that
/// means there were 50 frames counted that had a noise floor of -90 dBm.
vector<HistBucket>:MAX_NOISE_FLOOR_SAMPLES noise_floor_samples;
/// Count of invalid samples encountered, if any.
uint64 invalid_samples = 0;
};
/// Histogram for received data rate.
struct RxRateIndexHistogram {
HistScope hist_scope;
/// If hist_scope is PER_ANTENNA, antenna_id must be provided.
AntennaId? antenna_id;
/// Sparse histogram of count of received frames for each rate. Each sample's bucket_index is an
/// index into this lookup table:
/// 0-3: B-MCS 0-3
/// 4-11: G-MCS 0-7
/// 12-27: N-MCS 0-15 (BW20)
/// 28-43: N-MCS 0-15 (BW40)
/// 44-59: N-MCS 0-15 (BW20:SGI)
/// 60-75: N-MCS 0-15 (BW40:SGI)
/// 76-85: AC-MCS 0-9 (VHT:BW20:NSS1)
/// 86-95: AC-MCS 0-9 (VHT:BW20:NSS2)
/// 96-105: AC-MCS 0-9 (VHT:BW40:NSS1)
/// 106-115: AC-MCS 0-9 (VHT:BW40:NSS2)
/// 116-125: AC-MCS 0-9 (VHT:BW80:NSS1)
/// 126-135: AC-MCS 0-9 (VHT:BW80:NSS2)
/// 136-145: AC-MCS 0-9 (VHT:BW20:NSS1:SGI)
/// 146-155: AC-MCS 0-9 (VHT:BW20:NSS2:SGI)
/// 156-165: AC-MCS 0-9 (VHT:BW40:NSS1:SGI)
/// 166-175: AC-MCS 0-9 (VHT:BW40:NSS2:SGI)
/// 176-185: AC-MCS 0-9 (VHT:BW80:NSS1:SGI)
/// 186-195: AC-MCS 0-9 (VHT:BW80:NSS2:SGI)
///
/// For example, if rx_rate_index_samples contains a HistBucket with bucket_index = 75
/// and num_samples = 50, that means there were 50 frames counted that had a rate corresponding
/// to N-MCS 15 (BW40:SGI).
vector<HistBucket>:MAX_RX_RATE_INDEX_SAMPLES rx_rate_index_samples;
/// Count of invalid samples encountered, if any.
uint64 invalid_samples = 0;
};
/// Histogram for received signal strength indicator (RSSI).
struct RssiHistogram {
HistScope hist_scope;
/// If hist_scope is PER_ANTENNA, antenna_id must be provided.
AntennaId? antenna_id;
/// Sparse histogram of RSSI of AP in dBm. Each sample's bucket_index is an index
/// into this list of dBm values: [-255, -254, ... -1]. For example, if rssi_samples
/// contains a HistBucket with bucket_index = 225 and num_samples = 50, that means
/// there were 50 frames counted that had a signal level of -30 dBm.
vector<HistBucket>:MAX_RSSI_SAMPLES rssi_samples;
/// Count of invalid samples encountered, if any.
uint64 invalid_samples = 0;
};
/// Histogram for signal to noise ratio (SNR).
struct SnrHistogram {
HistScope hist_scope;
/// If hist_scope is PER_ANTENNA, antenna_id must be provided.
AntennaId? antenna_id;
/// Sparse histogram of signal to noise ratio in dB. Each sample's bucket_index is an index
/// into this list of dB values: [0, 1, ... 255]. For example, if snr_samples contains a
/// HistBucket with value = 60 and num_samples = 50, that means there were 50 frames
/// counted that had a SNR of 60 dB.
vector<HistBucket>:MAX_SNR_SAMPLES snr_samples;
/// Count of invalid samples encountered, if any.
uint64 invalid_samples;
};
/// For each histogram type (e.g. RSSI), there can be multiple histograms up to this limit. For
/// example, an interface might have 1 histogram for station-wide RSSI, but also 1 for each of the
/// antennas used by the interface.
const uint8 MAX_HISTOGRAMS_PER_TYPE = 8;
// LINT.ThenChange(//sdk/banjo/fuchsia.hardware.wlanif/wlanif.banjo)
struct ClientMlmeStats {
PacketCounter svc_msg;
PacketCounter data_frame;
PacketCounter mgmt_frame;
PacketCounter tx_frame;
PacketCounter rx_frame;
RssiStats assoc_data_rssi;
RssiStats beacon_rssi;
/// Noise floor histogram(s).
vector<NoiseFloorHistogram>:MAX_HISTOGRAMS_PER_TYPE noise_floor_histograms;
/// Received signal strength indicator (RSSI) histogram(s).
vector<RssiHistogram>:MAX_HISTOGRAMS_PER_TYPE rssi_histograms;
/// Received rate index histogram(s).
vector<RxRateIndexHistogram>:MAX_HISTOGRAMS_PER_TYPE rx_rate_index_histograms;
/// Signal to noise ratio (SNR) histogram(s).
vector<SnrHistogram>:MAX_HISTOGRAMS_PER_TYPE snr_histograms;
};
struct ApMlmeStats {
PacketCounter not_used;
};
// LINT.ThenChange(//src/connectivity/wlan/lib/common/cpp/include/wlan/common/stats.h)
union MlmeStats {
1: ClientMlmeStats client_mlme_stats;
2: ApMlmeStats ap_mlme_stats;
};
struct IfaceStats {
DispatcherStats dispatcher_stats;
MlmeStats? mlme_stats;
};