diff options
author | Xin Li <delphij@google.com> | 2021-10-07 23:50:44 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2021-10-07 23:50:44 +0000 |
commit | 732fbbcff0b818351efd16f3cf3388f2c2080b23 (patch) | |
tree | e63986e1731bcd7d309d964783171fbf6b0179ce | |
parent | d83838d918cd5c8e23d63649db134cfd74940992 (diff) | |
parent | a95ff0eda62f52072a7751561502e9f776ebd2e9 (diff) | |
download | wlan-732fbbcff0b818351efd16f3cf3388f2c2080b23.tar.gz |
Merge "Merge Android 12"android-s-v2-preview-2android-s-v2-preview-1android-s-v2-beta-2android-s-v2-preview-1
-rw-r--r-- | OWNERS | 3 | ||||
-rw-r--r-- | qcwcn/wifi_hal/llstats.cpp | 35 | ||||
-rw-r--r-- | qcwcn/wifi_hal/llstatscommand.h | 3 | ||||
-rw-r--r-- | qcwcn/wifi_hal/nan_ind.cpp | 5 | ||||
-rw-r--r-- | qcwcn/wifi_hal/wifi_hal.cpp | 18 | ||||
-rw-r--r-- | qcwcn/wifi_hal/wificonfig.cpp | 9 |
6 files changed, 65 insertions, 8 deletions
@@ -1,3 +1,2 @@ etancohen@google.com -kumaranand@google.com -rpius@google.com +arabawy@google.com diff --git a/qcwcn/wifi_hal/llstats.cpp b/qcwcn/wifi_hal/llstats.cpp index 407a6c3..8e827e2 100644 --- a/qcwcn/wifi_hal/llstats.cpp +++ b/qcwcn/wifi_hal/llstats.cpp @@ -54,6 +54,7 @@ LLStatsCommand::LLStatsCommand(wifi_handle handle, int id, u32 vendor_id, u32 su memset(&mHandler, 0,sizeof(mHandler)); mRadioStatsSize = 0; mNumRadios = 0; + mNumRadiosAllocated = 0; } LLStatsCommand::~LLStatsCommand() @@ -863,6 +864,11 @@ wifi_error LLStatsCommand::notifyResponse() /* Indicate stats to framework only if both radio and iface stats * are present */ if (mResultsParams.radio_stat && mResultsParams.iface_stat) { + if (mNumRadios > mNumRadiosAllocated) { + ALOGE("%s: Force reset mNumRadios=%d to allocated=%d", + __FUNCTION__, mNumRadios, mNumRadiosAllocated); + mNumRadios = mNumRadiosAllocated; + } mHandler.on_link_stats_results(mRequestId, mResultsParams.iface_stat, mNumRadios, mResultsParams.radio_stat); @@ -881,6 +887,11 @@ void LLStatsCommand::clearStats() if(mResultsParams.radio_stat) { wifi_radio_stat *radioStat = mResultsParams.radio_stat; + if (mNumRadios > mNumRadiosAllocated) { + ALOGE("%s: Force reset mNumRadios=%d to allocated=%d", + __FUNCTION__, mNumRadios, mNumRadiosAllocated); + mNumRadios = mNumRadiosAllocated; + } for (u8 radio = 0; radio < mNumRadios; radio++) { if (radioStat->tx_time_per_levels) { free(radioStat->tx_time_per_levels); @@ -894,6 +905,7 @@ void LLStatsCommand::clearStats() mResultsParams.radio_stat = NULL; mRadioStatsSize = 0; mNumRadios = 0; + mNumRadiosAllocated = 0; } if(mResultsParams.iface_stat) { @@ -978,6 +990,7 @@ int LLStatsCommand::handleResponse(WifiEvent &reply) + mRadioStatsSize); memset(radioStatsBuf, 0, resultsBufSize); mRadioStatsSize += resultsBufSize; + mNumRadiosAllocated ++; if (tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_NUM_TX_LEVELS]) radioStatsBuf->num_tx_levels = nla_get_u32(tb_vendor[ @@ -1151,10 +1164,19 @@ int LLStatsCommand::handleResponse(WifiEvent &reply) memset(pIfaceStat, 0, resultsBufSize); if(mResultsParams.iface_stat) { - memcpy ( pIfaceStat, mResultsParams.iface_stat, - sizeof(wifi_iface_stat)); - free (mResultsParams.iface_stat); - mResultsParams.iface_stat = pIfaceStat; + if(resultsBufSize >= sizeof(wifi_iface_stat)) { + memcpy ( pIfaceStat, mResultsParams.iface_stat, + sizeof(wifi_iface_stat)); + free (mResultsParams.iface_stat); + mResultsParams.iface_stat = pIfaceStat; + } else { + ALOGE("%s: numPeers = %u, num_rates= %u, " + "either numPeers or num_rates is invalid", + __FUNCTION__,numPeers,num_rates); + status = WIFI_ERROR_UNKNOWN; + free(pIfaceStat); + goto cleanup; + } } wifi_peer_info *pPeerStats; pIfaceStat->num_peers = numPeers; @@ -1166,6 +1188,7 @@ int LLStatsCommand::handleResponse(WifiEvent &reply) status = WIFI_ERROR_INVALID_ARGS; goto cleanup; } + num_rates = 0; for (peerInfo = (struct nlattr *) nla_data(tb_vendor[ QCA_WLAN_VENDOR_ATTR_LL_STATS_PEER_INFO]), rem = nla_len(tb_vendor[ @@ -1177,7 +1200,8 @@ int LLStatsCommand::handleResponse(WifiEvent &reply) QCA_WLAN_VENDOR_ATTR_LL_STATS_MAX+ 1]; pPeerStats = (wifi_peer_info *) ( (u8 *)pIfaceStat->peer_info - + (i++ * sizeof(wifi_peer_info))); + + (i++ * sizeof(wifi_peer_info)) + + (num_rates * sizeof(wifi_rate_stat))); nla_parse(tb2, QCA_WLAN_VENDOR_ATTR_LL_STATS_MAX, (struct nlattr *) nla_data(peerInfo), nla_len(peerInfo), NULL); @@ -1186,6 +1210,7 @@ int LLStatsCommand::handleResponse(WifiEvent &reply) { goto cleanup; } + num_rates += pPeerStats->num_rate; } } diff --git a/qcwcn/wifi_hal/llstatscommand.h b/qcwcn/wifi_hal/llstatscommand.h index 5d4c480..86b9672 100644 --- a/qcwcn/wifi_hal/llstatscommand.h +++ b/qcwcn/wifi_hal/llstatscommand.h @@ -83,7 +83,10 @@ private: u32 mRadioStatsSize; + // mNumRadios is decoded from tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_NUM_RADIOS] + // nNumRadiosAllocated is the actual radio stats received. u8 mNumRadios; + u8 mNumRadiosAllocated; LLStatsCommand(wifi_handle handle, int id, u32 vendor_id, u32 subcmd); diff --git a/qcwcn/wifi_hal/nan_ind.cpp b/qcwcn/wifi_hal/nan_ind.cpp index f661ed3..1fe651d 100644 --- a/qcwcn/wifi_hal/nan_ind.cpp +++ b/qcwcn/wifi_hal/nan_ind.cpp @@ -346,6 +346,11 @@ int NanCommand::getNanMatch(NanMatchInd *event) /* Populate receive discovery attribute from received TLV */ idx = event->num_rx_discovery_attr; + if (idx < 0 || idx >= NAN_MAX_POSTDISCOVERY_LEN) { + ALOGE("NAN_TLV_TYPE_POST_NAN_DISCOVERY_ATTRIBUTE_RECEIVE" + " Incorrect index:%d >= %d", idx, NAN_MAX_POSTDISCOVERY_LEN); + break; + } ret = getNanReceivePostDiscoveryVal(outputTlv.value, outputTlv.length, &event->discovery_attr[idx]); diff --git a/qcwcn/wifi_hal/wifi_hal.cpp b/qcwcn/wifi_hal/wifi_hal.cpp index d64e3b8..f071dfc 100644 --- a/qcwcn/wifi_hal/wifi_hal.cpp +++ b/qcwcn/wifi_hal/wifi_hal.cpp @@ -1879,6 +1879,24 @@ wifi_error wifi_get_ifaces(wifi_handle handle, int *num, { hal_info *info = (hal_info *)handle; + /* In case of dynamic interface add/remove, interface handles need to be + * updated so that, interface specific APIs could be instantiated. + * Reload here to get interfaces which are dynamically added. */ + + if (info->num_interfaces > 0) { + for (int i = 0; i < info->num_interfaces; i++) + free(info->interfaces[i]); + free(info->interfaces); + info->interfaces = NULL; + info->num_interfaces = 0; + } + + wifi_error ret = wifi_init_interfaces(handle); + if (ret != WIFI_SUCCESS) { + ALOGE("Failed to init interfaces while wifi_get_ifaces"); + return ret; + } + *interfaces = (wifi_interface_handle *)info->interfaces; *num = info->num_interfaces; diff --git a/qcwcn/wifi_hal/wificonfig.cpp b/qcwcn/wifi_hal/wificonfig.cpp index 8ab296a..c6ceb9d 100644 --- a/qcwcn/wifi_hal/wificonfig.cpp +++ b/qcwcn/wifi_hal/wificonfig.cpp @@ -360,12 +360,14 @@ wifi_error wifi_select_tx_power_scenario(wifi_interface_handle handle, switch (scenario) { case WIFI_POWER_SCENARIO_VOICE_CALL: - case WIFI_POWER_SCENARIO_ON_HEAD_CELL_OFF: case WIFI_POWER_SCENARIO_ON_BODY_BT: bdf_file = QCA_WLAN_VENDOR_ATTR_SAR_LIMITS_SELECT_BDF0; break; + case WIFI_POWER_SCENARIO_ON_HEAD_CELL_OFF: case WIFI_POWER_SCENARIO_ON_HEAD_CELL_ON: + case WIFI_POWER_SCENARIO_ON_HEAD_HOTSPOT: + case WIFI_POWER_SCENARIO_ON_HEAD_HOTSPOT_MMW: bdf_file = QCA_WLAN_VENDOR_ATTR_SAR_LIMITS_SELECT_BDF1; break; @@ -374,6 +376,11 @@ wifi_error wifi_select_tx_power_scenario(wifi_interface_handle handle, break; case WIFI_POWER_SCENARIO_ON_BODY_CELL_ON: + case WIFI_POWER_SCENARIO_ON_BODY_CELL_ON_BT: + case WIFI_POWER_SCENARIO_ON_BODY_HOTSPOT: + case WIFI_POWER_SCENARIO_ON_BODY_HOTSPOT_BT: + case WIFI_POWER_SCENARIO_ON_BODY_HOTSPOT_MMW: + case WIFI_POWER_SCENARIO_ON_BODY_HOTSPOT_BT_MMW: bdf_file = QCA_WLAN_VENDOR_ATTR_SAR_LIMITS_SELECT_BDF3; break; |