diff options
Diffstat (limited to 'wcn6740/qcwcn/wifi_hal/wifi_hal.cpp')
-rw-r--r-- | wcn6740/qcwcn/wifi_hal/wifi_hal.cpp | 316 |
1 files changed, 159 insertions, 157 deletions
diff --git a/wcn6740/qcwcn/wifi_hal/wifi_hal.cpp b/wcn6740/qcwcn/wifi_hal/wifi_hal.cpp index e43b770..9288aed 100644 --- a/wcn6740/qcwcn/wifi_hal/wifi_hal.cpp +++ b/wcn6740/qcwcn/wifi_hal/wifi_hal.cpp @@ -146,11 +146,6 @@ static int wifi_is_nan_ext_cmd_supported(wifi_interface_handle handle); wifi_error wifi_init_tcp_param_change_event_handler(wifi_interface_handle iface); -wifi_error wifi_get_usable_channels(wifi_handle handle, u32 band_mask, - u32 iface_mode_mask, u32 filter_mask, - u32 max_size, u32* size, - wifi_usable_channel* channels); - /* Initialize/Cleanup */ wifi_interface_handle wifi_get_iface_handle(wifi_handle handle, char *name) @@ -807,6 +802,161 @@ cleanup: return ret; } +static u32 get_nl_band_mask(u32 in_mask) +{ + u32 op_mask = 0; + + if (in_mask & WLAN_MAC_2_4_BAND) + op_mask |= BIT(NL80211_BAND_2GHZ); + if (in_mask & WLAN_MAC_5_0_BAND) + op_mask |= BIT(NL80211_BAND_5GHZ); + if (in_mask & WLAN_MAC_6_0_BAND) + op_mask |= BIT(NL80211_BAND_6GHZ); + if (in_mask & WLAN_MAC_60_0_BAND) + op_mask |= BIT(NL80211_BAND_60GHZ); + + return op_mask; +} + +static u32 get_nl_iftype_mode_masks(u32 in_mask) +{ + u32 op_mask = 0; + + if (in_mask & BIT(WIFI_INTERFACE_STA) || + in_mask & BIT(WIFI_INTERFACE_TDLS)) + op_mask |= BIT(NL80211_IFTYPE_STATION); + if (in_mask & BIT(WIFI_INTERFACE_SOFTAP)) + op_mask |= BIT(NL80211_IFTYPE_AP); + if (in_mask & BIT(WIFI_INTERFACE_P2P_CLIENT)) + op_mask |= BIT(NL80211_IFTYPE_P2P_CLIENT); + if (in_mask & BIT(WIFI_INTERFACE_P2P_GO)) + op_mask |= BIT(NL80211_IFTYPE_P2P_GO); + if (in_mask & BIT(WIFI_INTERFACE_NAN)) + op_mask |= BIT(NL80211_IFTYPE_NAN); + + return op_mask; +} + +static u32 get_vendor_filter_mask(u32 in_mask) +{ + u32 op_mask = 0; + + if (in_mask & WIFI_USABLE_CHANNEL_FILTER_CELLULAR_COEXISTENCE) + op_mask |= BIT(QCA_WLAN_VENDOR_FILTER_CELLULAR_COEX); + if (in_mask & WIFI_USABLE_CHANNEL_FILTER_CONCURRENCY) + op_mask |= BIT(QCA_WLAN_VENDOR_FILTER_WLAN_CONCURRENCY); + + return op_mask; +} + +wifi_error wifi_get_usable_channels(wifi_handle handle, u32 band_mask, + u32 iface_mode_mask, u32 filter_mask, + u32 max_size, u32* size, + wifi_usable_channel* channels) +{ + wifi_error ret = WIFI_ERROR_UNKNOWN; + WifihalGeneric *cmd = NULL; + struct nlattr *nl_data = NULL; + hal_info *info = NULL; + u32 band = 0, iface_mask = 0, filter = 0; + + if (!handle) { + ALOGE("%s: Error, wifi_handle NULL", __FUNCTION__); + goto cleanup; + } + + info = getHalInfo(handle); + if (!info || info->num_interfaces < 1) { + ALOGE("%s: Error, wifi_handle NULL or base wlan interface not present", + __FUNCTION__); + goto cleanup; + } + + if (!max_size) { + ALOGE("%s: max channel size is zero", __FUNCTION__); + ret = WIFI_ERROR_INVALID_ARGS; + goto cleanup; + } + + if (!channels) { + ALOGE("%s: user input channel buffer NULL", __FUNCTION__); + ret = WIFI_ERROR_INVALID_ARGS; + goto cleanup; + } + + cmd = new WifihalGeneric(handle, get_requestid(), OUI_QCA, + QCA_NL80211_VENDOR_SUBCMD_USABLE_CHANNELS); + if (cmd == NULL) { + ALOGE("%s: Error, created command NULL", __FUNCTION__); + ret = WIFI_ERROR_OUT_OF_MEMORY; + goto cleanup; + } + + /* Create the NL message. */ + ret = cmd->create(); + if (ret < 0) { + ALOGE("%s: failed to create NL msg due to error: (%d)", + __FUNCTION__, ret); + goto cleanup; + } + + /* Add the vendor specific attributes for the NL command. */ + nl_data = cmd->attr_start(NL80211_ATTR_VENDOR_DATA); + if (!nl_data) { + ALOGE("%s: failed attr_start for VENDOR_DATA due to error", + __FUNCTION__); + ret = WIFI_ERROR_OUT_OF_MEMORY; + goto cleanup; + } + + band = get_nl_band_mask(band_mask); + ret = cmd->put_u32(QCA_WLAN_VENDOR_ATTR_USABLE_CHANNELS_BAND_MASK, + band); + if (ret != WIFI_SUCCESS) { + ALOGE("%s: failed to put vendor data due to error:%d", + __FUNCTION__, ret); + goto cleanup; + } + + iface_mask = get_nl_iftype_mode_masks(iface_mode_mask); + ret = cmd->put_u32(QCA_WLAN_VENDOR_ATTR_USABLE_CHANNELS_IFACE_MODE_MASK, + iface_mask); + if (ret != WIFI_SUCCESS) { + ALOGE("%s: failed to put vendor data due to error:%d", + __FUNCTION__, ret); + goto cleanup; + } + + filter = get_vendor_filter_mask(filter_mask); + ret = cmd->put_u32(QCA_WLAN_VENDOR_ATTR_USABLE_CHANNELS_FILTER_MASK, + filter); + if (ret != WIFI_SUCCESS) { + ALOGE("%s: failed to put vendor data due to error:%d", + __FUNCTION__, ret); + goto cleanup; + } + + cmd->attr_end(nl_data); + + /* Populate the input received from caller/framework. */ + cmd->setMaxSetSize(max_size); + cmd->set_channels_buff(channels); + + /* Send the msg and wait for a response. */ + ret = cmd->requestResponse(); + if (ret != WIFI_SUCCESS) { + ALOGE("%s: Error %d waiting for response.", __FUNCTION__, ret); + goto cleanup; + } + + *size = cmd->get_results_size(); + +cleanup: + if (cmd) + delete cmd; + return ret; +} + /*initialize function pointer table with Qualcomm HAL API*/ wifi_error init_wifi_vendor_hal_func_table(wifi_hal_fn *fn) { if (fn == NULL) { @@ -914,6 +1064,7 @@ wifi_error init_wifi_vendor_hal_func_table(wifi_hal_fn *fn) { fn->wifi_multi_sta_set_use_case = wifi_multi_sta_set_use_case; fn->wifi_set_coex_unsafe_channels = wifi_set_coex_unsafe_channels; fn->wifi_set_dtim_config = wifi_set_dtim_config; + fn->wifi_get_usable_channels = wifi_get_usable_channels; return WIFI_SUCCESS; } @@ -1263,6 +1414,7 @@ unload: } if (info->pkt_stats) free(info->pkt_stats); if (info->rx_aggr_pkts) free(info->rx_aggr_pkts); + if (info->wifihal_ctrl_sock.s) close(info->wifihal_ctrl_sock.s); wifi_logger_ring_buffers_deinit(info); cleanupGscanHandlers(info); cleanupRSSIMonitorHandler(info); @@ -1300,12 +1452,14 @@ static int wifi_update_driver_state(const char *state) { if (fd < 0) { ALOGE("Failed to open driver state control param at %s", WIFI_DRIVER_STATE_CTRL_PARAM); + close(fd); return -1; } len = strlen(state) + 1; if (TEMP_FAILURE_RETRY(write(fd, state, len)) != len) { ALOGE("Failed to write driver state control param at %s", WIFI_DRIVER_STATE_CTRL_PARAM); + close(fd); ret = -1; } close(fd); @@ -3111,158 +3265,6 @@ static int wifi_is_nan_ext_cmd_supported(wifi_interface_handle iface_handle) } } -static u32 get_nl_band_mask(u32 in_mask) -{ - u32 op_mask = 0; - - if (in_mask & WLAN_MAC_2_4_BAND) - op_mask |= BIT(NL80211_BAND_2GHZ); - if (in_mask & WLAN_MAC_5_0_BAND) - op_mask |= BIT(NL80211_BAND_5GHZ); - if (in_mask & WLAN_MAC_6_0_BAND) - op_mask |= BIT(NL80211_BAND_6GHZ); - if (in_mask & WLAN_MAC_60_0_BAND) - op_mask |= BIT(NL80211_BAND_60GHZ); - - return op_mask; -} - -static u32 get_nl_iftype_mode_masks(u32 in_mask) -{ - u32 op_mask = 0; - - if (in_mask & BIT(WIFI_INTERFACE_STA) || - in_mask & BIT(WIFI_INTERFACE_TDLS)) - op_mask |= BIT(NL80211_IFTYPE_STATION); - if (in_mask & BIT(WIFI_INTERFACE_SOFTAP)) - op_mask |= BIT(NL80211_IFTYPE_AP); - if (in_mask & BIT(WIFI_INTERFACE_P2P_CLIENT)) - op_mask |= BIT(NL80211_IFTYPE_P2P_CLIENT); - if (in_mask & BIT(WIFI_INTERFACE_P2P_GO)) - op_mask |= BIT(NL80211_IFTYPE_P2P_GO); - if (in_mask & BIT(WIFI_INTERFACE_NAN)) - op_mask |= BIT(NL80211_IFTYPE_NAN); - - return op_mask; -} - -static u32 get_vendor_filter_mask(u32 in_mask) -{ - u32 op_mask = 0; - - if (in_mask & WIFI_USABLE_CHANNEL_FILTER_CELLULAR_COEXISTENCE) - op_mask |= BIT(QCA_WLAN_VENDOR_FILTER_CELLULAR_COEX); - if (in_mask & WIFI_USABLE_CHANNEL_FILTER_CONCURRENCY) - op_mask |= BIT(QCA_WLAN_VENDOR_FILTER_WLAN_CONCURRENCY); - - return op_mask; -} - -wifi_error wifi_get_usable_channels(wifi_handle handle, u32 band_mask, - u32 iface_mode_mask, u32 filter_mask, - u32 max_size, u32* size, - wifi_usable_channel* channels) -{ - wifi_error ret; - WifihalGeneric *cmd = NULL; - struct nlattr *nl_data; - hal_info *info = NULL; - u32 band = 0, iface_mask = 0, filter = 0; - - if (!handle) { - ALOGE("%s: Error, wifi_handle NULL", __FUNCTION__); - return WIFI_ERROR_UNKNOWN; - } - - info = getHalInfo(handle); - if (!info || info->num_interfaces < 1) { - ALOGE("%s: Error, wifi_handle NULL or base wlan interface not present", - __FUNCTION__); - return WIFI_ERROR_UNKNOWN; - } - - if (!max_size) { - ALOGE("%s: max channel size is zero", __FUNCTION__); - ret = WIFI_ERROR_INVALID_ARGS; - goto cleanup; - } - - if (!channels) { - ALOGE("%s: user input channel buffer NULL", __FUNCTION__); - ret = WIFI_ERROR_INVALID_ARGS; - goto cleanup; - } - - cmd = new WifihalGeneric(handle, get_requestid(), OUI_QCA, - QCA_NL80211_VENDOR_SUBCMD_USABLE_CHANNELS); - if (cmd == NULL) { - ALOGE("%s: Error, created command NULL", __FUNCTION__); - return WIFI_ERROR_OUT_OF_MEMORY; - } - - /* Create the NL message. */ - ret = cmd->create(); - if (ret < 0) { - ALOGE("%s: failed to create NL msg due to error: (%d)", - __FUNCTION__, ret); - goto cleanup; - } - - /* Add the vendor specific attributes for the NL command. */ - nl_data = cmd->attr_start(NL80211_ATTR_VENDOR_DATA); - if (!nl_data) { - ALOGE("%s: failed attr_start for VENDOR_DATA due to error: (%d)", - __FUNCTION__, ret); - goto cleanup; - } - - band = get_nl_band_mask(band_mask); - ret = cmd->put_u32(QCA_WLAN_VENDOR_ATTR_USABLE_CHANNELS_BAND_MASK, - band); - if (ret != WIFI_SUCCESS) { - ALOGE("%s: failed to put vendor data due to error:%d", - __FUNCTION__, ret); - goto cleanup; - } - - iface_mask = get_nl_iftype_mode_masks(iface_mode_mask); - ret = cmd->put_u32(QCA_WLAN_VENDOR_ATTR_USABLE_CHANNELS_IFACE_MODE_MASK, - iface_mask); - if (ret != WIFI_SUCCESS) { - ALOGE("%s: failed to put vendor data due to error:%d", - __FUNCTION__, ret); - goto cleanup; - } - - filter = get_vendor_filter_mask(filter_mask); - ret = cmd->put_u32(QCA_WLAN_VENDOR_ATTR_USABLE_CHANNELS_FILTER_MASK, - filter); - if (ret != WIFI_SUCCESS) { - ALOGE("%s: failed to put vendor data due to error:%d", - __FUNCTION__, ret); - goto cleanup; - } - - cmd->attr_end(nl_data); - - /* Populate the input received from caller/framework. */ - cmd->setMaxSetSize(max_size); - cmd->set_channels_buff(channels); - - /* Send the msg and wait for a response. */ - ret = cmd->requestResponse(); - if (ret != WIFI_SUCCESS) { - ALOGE("%s: Error %d waiting for response.", __FUNCTION__, ret); - goto cleanup; - } - - *size = cmd->get_results_size(); - -cleanup: - delete cmd; - return ret; -} - wifi_error wifi_get_radar_history(wifi_interface_handle handle, radar_history_result *resultBuf, int resultBufSize, int *numResults) { |