diff --git a/core/hdd/inc/wlan_hdd_main.h b/core/hdd/inc/wlan_hdd_main.h index b981fb806c7a..abf95f3f9e00 100644 --- a/core/hdd/inc/wlan_hdd_main.h +++ b/core/hdd/inc/wlan_hdd_main.h @@ -2227,6 +2227,7 @@ struct hdd_context { #ifdef THERMAL_STATS_SUPPORT bool is_therm_stats_in_progress; #endif + uint64_t bw_vote_time; }; /** diff --git a/core/hdd/src/wlan_hdd_main.c b/core/hdd/src/wlan_hdd_main.c index e172f8fdcc5a..4fb6a4117326 100644 --- a/core/hdd/src/wlan_hdd_main.c +++ b/core/hdd/src/wlan_hdd_main.c @@ -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: /**