Merge "wifi: Add support for multiple radio stats"

am: c0fbd8fe63

Change-Id: Icca33f2745c8297d1f413e651fbf7506fc0521f6
This commit is contained in:
Roshan Pius 2017-03-14 19:57:45 +00:00 committed by android-build-merger
commit eaf6ed41dd
4 changed files with 50 additions and 36 deletions

View file

@ -706,11 +706,17 @@ bool convertLegacyLinkLayerStatsToHidl(
hidl_stats->iface.wmeVoPktStats.retries = hidl_stats->iface.wmeVoPktStats.retries =
legacy_stats.iface.ac[legacy_hal::WIFI_AC_VO].retries; legacy_stats.iface.ac[legacy_hal::WIFI_AC_VO].retries;
// radio legacy_stats conversion. // radio legacy_stats conversion.
hidl_stats->radio.onTimeInMs = legacy_stats.radio.on_time; std::vector<StaLinkLayerRadioStats> hidl_radios_stats;
hidl_stats->radio.txTimeInMs = legacy_stats.radio.tx_time; for (const auto& legacy_radio_stats : legacy_stats.radios) {
hidl_stats->radio.rxTimeInMs = legacy_stats.radio.rx_time; StaLinkLayerRadioStats hidl_radio_stats;
hidl_stats->radio.onTimeInMsForScan = legacy_stats.radio.on_time_scan; hidl_radio_stats.onTimeInMs = legacy_radio_stats.stats.on_time;
hidl_stats->radio.txTimeInMsPerLevel = legacy_stats.radio_tx_time_per_levels; hidl_radio_stats.txTimeInMs = legacy_radio_stats.stats.tx_time;
hidl_radio_stats.rxTimeInMs = legacy_radio_stats.stats.rx_time;
hidl_radio_stats.onTimeInMsForScan = legacy_radio_stats.stats.on_time_scan;
hidl_radio_stats.txTimeInMsPerLevel = legacy_radio_stats.tx_time_per_levels;
hidl_radios_stats.push_back(hidl_radio_stats);
}
hidl_stats->radios = hidl_radios_stats;
// Timestamp in the HAL wrapper here since it's not provided in the legacy // Timestamp in the HAL wrapper here since it's not provided in the legacy
// HAL API. // HAL API.
hidl_stats->timeStampInMs = uptimeMillis(); hidl_stats->timeStampInMs = uptimeMillis();

View file

@ -601,33 +601,37 @@ std::pair<wifi_error, LinkLayerStats> WifiLegacyHal::getLinkLayerStats() {
LinkLayerStats link_stats{}; LinkLayerStats link_stats{};
LinkLayerStats* link_stats_ptr = &link_stats; LinkLayerStats* link_stats_ptr = &link_stats;
on_link_layer_stats_result_internal_callback = [&link_stats_ptr]( on_link_layer_stats_result_internal_callback =
wifi_request_id /* id */, [&link_stats_ptr](wifi_request_id /* id */,
wifi_iface_stat* iface_stats_ptr, wifi_iface_stat* iface_stats_ptr,
int num_radios, int num_radios,
wifi_radio_stat* radio_stats_ptr) { wifi_radio_stat* radio_stats_ptr) {
if (iface_stats_ptr != nullptr) { if (iface_stats_ptr != nullptr) {
link_stats_ptr->iface = *iface_stats_ptr; link_stats_ptr->iface = *iface_stats_ptr;
link_stats_ptr->iface.num_peers = 0; link_stats_ptr->iface.num_peers = 0;
} else { } else {
LOG(ERROR) << "Invalid iface stats in link layer stats"; LOG(ERROR) << "Invalid iface stats in link layer stats";
} }
if (num_radios == 1 && radio_stats_ptr != nullptr) { if (num_radios <= 0 || radio_stats_ptr == nullptr) {
link_stats_ptr->radio = *radio_stats_ptr; LOG(ERROR) << "Invalid radio stats in link layer stats";
// Copy over the tx level array to the separate vector. return;
if (radio_stats_ptr->num_tx_levels > 0 && }
radio_stats_ptr->tx_time_per_levels != nullptr) { for (int i = 0; i < num_radios; i++) {
link_stats_ptr->radio_tx_time_per_levels.assign( LinkLayerRadioStats radio;
radio_stats_ptr->tx_time_per_levels, radio.stats = radio_stats_ptr[i];
radio_stats_ptr->tx_time_per_levels + // Copy over the tx level array to the separate vector.
radio_stats_ptr->num_tx_levels); if (radio_stats_ptr[i].num_tx_levels > 0 &&
} radio_stats_ptr[i].tx_time_per_levels != nullptr) {
link_stats_ptr->radio.num_tx_levels = 0; radio.tx_time_per_levels.assign(
link_stats_ptr->radio.tx_time_per_levels = nullptr; radio_stats_ptr[i].tx_time_per_levels,
} else { radio_stats_ptr[i].tx_time_per_levels +
LOG(ERROR) << "Invalid radio stats in link layer stats"; radio_stats_ptr[i].num_tx_levels);
} }
}; radio.stats.num_tx_levels = 0;
radio.stats.tx_time_per_levels = nullptr;
link_stats_ptr->radios.push_back(radio);
}
};
wifi_error status = global_func_table_.wifi_get_link_stats( wifi_error status = global_func_table_.wifi_get_link_stats(
0, wlan_interface_handle_, {onSyncLinkLayerStatsResult}); 0, wlan_interface_handle_, {onSyncLinkLayerStatsResult});

View file

@ -49,10 +49,14 @@ struct PacketFilterCapabilities {
// The |wifi_radio_stat.tx_time_per_levels| stats is provided as a pointer in // The |wifi_radio_stat.tx_time_per_levels| stats is provided as a pointer in
// |wifi_radio_stat| structure in the legacy HAL API. Separate that out // |wifi_radio_stat| structure in the legacy HAL API. Separate that out
// into a separate return element to avoid passing pointers around. // into a separate return element to avoid passing pointers around.
struct LinkLayerRadioStats {
wifi_radio_stat stats;
std::vector<uint32_t> tx_time_per_levels;
};
struct LinkLayerStats { struct LinkLayerStats {
wifi_iface_stat iface; wifi_iface_stat iface;
wifi_radio_stat radio; std::vector<LinkLayerRadioStats> radios;
std::vector<uint32_t> radio_tx_time_per_levels;
}; };
#pragma GCC diagnostic pop #pragma GCC diagnostic pop

View file

@ -143,7 +143,7 @@ typedef MacAddress Bssid;
/** /**
* TimeStamp in milliseconds (ms). * TimeStamp in milliseconds (ms).
*/ */
typedef uint32_t TimeStampInMs; typedef uint64_t TimeStampInMs;
/** /**
* TimeStamp in microseconds (us). * TimeStamp in microseconds (us).
@ -478,7 +478,7 @@ struct StaLinkLayerRadioStats {
*/ */
struct StaLinkLayerStats { struct StaLinkLayerStats {
StaLinkLayerIfaceStats iface; StaLinkLayerIfaceStats iface;
StaLinkLayerRadioStats radio; vec<StaLinkLayerRadioStats> radios;
/** /**
* TimeStamp for each stats sample. * TimeStamp for each stats sample.
* This is the absolute milliseconds from boot when these stats were * This is the absolute milliseconds from boot when these stats were