qcacld-3.0: use more accurate tx/rx packets statistics

Sometimes TX/RX pkt statistics workqueue may be delayed.
The workqueue interval value is pre-defined and is used
for bandwidth vote. If the interval is inaccurate, whole
pkts statistics are not accurate, bus bandwidth vote is
wrong also. This change is aimed to use absolute workqueue
time delay instead of pre-defined value to get accurate
packets per milliseconds result.

Change-Id: I2b730fc36d4b5c42742ed9107d9a7e1f95eb4988
CRs-Fixed: 2976857
This commit is contained in:
Yu Tian 2022-04-19 19:03:04 +08:00 • committed by Madan Koyyalamudi
commit 5f1358deb6
2 changed files with 19 additions and 0 deletions

View file

@ -2227,6 +2227,7 @@ struct hdd_context {
#ifdef THERMAL_STATS_SUPPORT
bool is_therm_stats_in_progress;
#endif
uint64_t bw_vote_time;
};
/**

View file

@ -10533,6 +10533,9 @@ static void __hdd_bus_bw_work_handler(struct hdd_context *hdd_ctx)
uint32_t ipa_tx_packets = 0, ipa_rx_packets = 0;
uint64_t sta_tx_bytes = 0, sap_tx_bytes = 0;
wlan_net_dev_ref_dbgid dbgid = NET_DEV_HOLD_BUS_BW_WORK_HANDLER;
uint64_t diff_us;
uint64_t curr_time_us;
uint32_t bw_interval_us;
if (wlan_hdd_validate_context(hdd_ctx))
goto stop_work;
@ -10540,6 +10543,13 @@ static void __hdd_bus_bw_work_handler(struct hdd_context *hdd_ctx)
if (hdd_ctx->is_wiphy_suspended)
return;
bw_interval_us = hdd_ctx->config->bus_bw_compute_interval * 1000;
curr_time_us = qdf_get_log_timestamp();
diff_us = qdf_log_timestamp_to_usecs(
curr_time_us - hdd_ctx->bw_vote_time);
hdd_ctx->bw_vote_time = curr_time_us;
hdd_for_each_adapter_dev_held_safe(hdd_ctx, adapter, next_adapter,
dbgid) {
/*
@ -10642,6 +10652,12 @@ static void __hdd_bus_bw_work_handler(struct hdd_context *hdd_ctx)
con_sap_adapter->stats.rx_packets += ipa_rx_packets;
}
tx_packets = tx_packets * bw_interval_us;
tx_packets = qdf_do_div(tx_packets, (uint32_t)diff_us);
rx_packets = rx_packets * bw_interval_us;
rx_packets = qdf_do_div(rx_packets, (uint32_t)diff_us);
hdd_pld_request_bus_bandwidth(hdd_ctx, tx_packets, rx_packets);
return;
@ -16080,6 +16096,7 @@ static void __hdd_bus_bw_compute_timer_start(struct hdd_context *hdd_ctx)
{
qdf_periodic_work_start(&hdd_ctx->bus_bw_work,
hdd_ctx->config->bus_bw_compute_interval);
hdd_ctx->bw_vote_time = qdf_get_log_timestamp();
}
void hdd_bus_bw_compute_timer_start(struct hdd_context *hdd_ctx)
@ -16118,6 +16135,7 @@ static void __hdd_bus_bw_compute_timer_stop(struct hdd_context *hdd_ctx)
OL_TXRX_PDEV_ID);
cdp_pdev_reset_bundle_require_flag(cds_get_context(QDF_MODULE_ID_SOC),
OL_TXRX_PDEV_ID);
hdd_ctx->bw_vote_time = 0;
exit:
/**