summaryrefslogtreecommitdiff
path: root/wifi/1.6/default/hidl_struct_util.cpp
diff options
context:
space:
mode:
authorPurushottam Kushwaha <quic_pkushwah@quicinc.com>2022-06-28 11:06:42 +0530
committerPurushottam Kushwaha <quic_pkushwah@quicinc.com>2022-07-26 18:17:00 +0530
commita49d7330bf0bc1902703887b3ab7f97aa008825c (patch)
tree95a2feb1fee10168e0b64c882460f6a81760b218 /wifi/1.6/default/hidl_struct_util.cpp
parentaa5def6aa9b8f14fd6e1b4b6619dba35d8295e08 (diff)
Wifi: Add support to query and use driver advertised interface combination
Interface combinations in legacy-hal is predefined with 'WIFI_HAL_INTERFACE_COMBINATIONS' build flag. Netlink interface already provides supported interface combination via 'NL80211_CMD_GET_WIPHY' using attribute 'NL80211_ATTR_INTERFACE_COMBINATIONS' , thus build time dependency to configure interface combination for each target can be removed by querying the combination at runtime. Change-Id: I28f95b048de4b7b1ca49f16c3ef4afe7941bb25e CRs-Fixed: 3230634
Diffstat (limited to 'wifi/1.6/default/hidl_struct_util.cpp')
-rw-r--r--wifi/1.6/default/hidl_struct_util.cpp65
1 files changed, 65 insertions, 0 deletions
diff --git a/wifi/1.6/default/hidl_struct_util.cpp b/wifi/1.6/default/hidl_struct_util.cpp
index 2112b260f3..ff3105dd77 100644
--- a/wifi/1.6/default/hidl_struct_util.cpp
+++ b/wifi/1.6/default/hidl_struct_util.cpp
@@ -2999,6 +2999,71 @@ bool convertLegacyRadioCombinationsMatrixToHidl(
return true;
}
+bool convertLegacyIfaceMaskToIfaceConcurrencyType(
+ u32 mask, std::vector<V1_6::IfaceConcurrencyType>* types) {
+ if (!mask)
+ return false;
+
+#ifndef BIT
+#define BIT(x) (1 << (x))
+#endif
+ if (mask & BIT(WIFI_INTERFACE_TYPE_STA))
+ types->push_back(V1_6::IfaceConcurrencyType::STA);
+ if (mask & BIT(WIFI_INTERFACE_TYPE_AP))
+ types->push_back(V1_6::IfaceConcurrencyType::AP);
+ if (mask & BIT(WIFI_INTERFACE_TYPE_AP_BRIDGED))
+ types->push_back(V1_6::IfaceConcurrencyType::AP_BRIDGED);
+ if (mask & BIT(WIFI_INTERFACE_TYPE_P2P))
+ types->push_back(V1_6::IfaceConcurrencyType::P2P);
+ if (mask & BIT(WIFI_INTERFACE_TYPE_NAN))
+ types->push_back(V1_6::IfaceConcurrencyType::NAN);
+
+ return true;
+}
+
+bool convertLegacyIfaceCombinationsMatrixToChipMode(
+ legacy_hal::wifi_iface_concurrency_matrix* legacy_matrix,
+ V1_6::IWifiChip::ChipMode* chip_mode) {
+ if (!chip_mode || !legacy_matrix) {
+ LOG(ERROR) << "legacy_matrix is null";
+ return false;
+ }
+ *chip_mode = {};
+
+ int num_combinations = legacy_matrix->num_iface_combinations;
+ std::vector<V1_6::IWifiChip::ChipConcurrencyCombination> driver_Combinations_vec;
+ if (!num_combinations) {
+ LOG(ERROR) << "zero iface combinations";
+ return false;
+ }
+
+ for (int i = 0; i < num_combinations; i++) {
+ V1_6::IWifiChip::ChipConcurrencyCombination chipComb;
+ std::vector<V1_6::IWifiChip::ChipConcurrencyCombinationLimit> limits;
+ wifi_iface_combination *comb = &legacy_matrix->iface_combinations[i];
+ if (!comb->num_iface_limits)
+ continue;
+ for (u32 j = 0; j < comb->num_iface_limits; j++) {
+ V1_6::IWifiChip::ChipConcurrencyCombinationLimit chipLimit;
+ chipLimit.maxIfaces = comb->iface_limits[j].max_limit;
+ std::vector<V1_6::IfaceConcurrencyType> types;
+ if (!convertLegacyIfaceMaskToIfaceConcurrencyType(
+ comb->iface_limits[j].iface_mask, &types)) {
+ LOG(ERROR) << "Failed to convert from iface_mask:"
+ << comb->iface_limits[j].iface_mask;
+ return false;
+ }
+ chipLimit.types = hidl_vec(types);
+ limits.push_back(chipLimit);
+ }
+ chipComb.limits = hidl_vec(limits);
+ driver_Combinations_vec.push_back(chipComb);
+ }
+
+ chip_mode->availableCombinations = driver_Combinations_vec;
+ return true;
+}
+
} // namespace hidl_struct_util
} // namespace implementation
} // namespace V1_6