From 9d45f33ab9018edbe4340219b24e47c842c041b7 Mon Sep 17 00:00:00 2001 From: Jeff Johnson Date: Tue, 29 Jan 2019 08:42:00 -0800 Subject: [PATCH] qcacld-3.0: Refine the "set scan oui" logic Make the following updates to the "set scan oui" logic: 1) Exclusively use the Unified WMI data structures. 2) Update the HDD<=>SME interface to enforce the contract that SME must not make any assumptions about the buffers provided by HDD. 3) Replace instances of mixed-case identifiers. 4) Document the API definitions, not the implementations. Change-Id: I5df3962fc45395b37b4e566f98b840e37f601d26 CRs-Fixed: 2389640 --- core/hdd/src/wlan_hdd_cfg80211.c | 42 ++++++++++++++------------------ core/mac/inc/sir_api.h | 8 ------ core/sme/inc/sme_api.h | 10 +++++++- core/sme/src/common/sme_api.c | 39 +++++++++++++++-------------- core/wma/inc/wma_internal.h | 12 ++++++++- core/wma/src/wma_scan_roam.c | 28 +++------------------ 6 files changed, 61 insertions(+), 78 deletions(-) diff --git a/core/hdd/src/wlan_hdd_cfg80211.c b/core/hdd/src/wlan_hdd_cfg80211.c index 08a0c247e630..317314f1242b 100644 --- a/core/hdd/src/wlan_hdd_cfg80211.c +++ b/core/hdd/src/wlan_hdd_cfg80211.c @@ -3288,7 +3288,7 @@ __wlan_hdd_cfg80211_set_scanning_mac_oui(struct wiphy *wiphy, const void *data, int data_len) { - tpSirScanMacOui pReqMsg = NULL; + struct scan_mac_oui scan_mac_oui = { {0} }; struct hdd_context *hdd_ctx = wiphy_priv(wiphy); struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI_MAX + 1]; QDF_STATUS status; @@ -3324,45 +3324,39 @@ __wlan_hdd_cfg80211_set_scanning_mac_oui(struct wiphy *wiphy, hdd_err("Invalid ATTR"); return -EINVAL; } - pReqMsg = qdf_mem_malloc(sizeof(*pReqMsg)); - if (!pReqMsg) - return -ENOMEM; if (!tb[QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI]) { hdd_err("attr mac oui failed"); - goto fail; + return -EINVAL; } len = nla_len(tb[QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI]); - if (len != sizeof(pReqMsg->oui)) { + if (len != sizeof(scan_mac_oui.oui)) { hdd_err("attr mac oui invalid size %d expected %zu", - len, sizeof(pReqMsg->oui)); - goto fail; + len, sizeof(scan_mac_oui.oui)); + return -EINVAL; } - nla_memcpy(&pReqMsg->oui[0], + nla_memcpy(scan_mac_oui.oui, tb[QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI], - sizeof(pReqMsg->oui)); + sizeof(scan_mac_oui.oui)); - /* populate pReqMsg for mac addr randomization */ - pReqMsg->vdev_id = adapter->session_id; - pReqMsg->enb_probe_req_sno_randomization = true; + /* populate rest of scan_mac_oui for mac addr randomization */ + scan_mac_oui.vdev_id = adapter->session_id; + scan_mac_oui.enb_probe_req_sno_randomization = true; - hdd_debug("Oui (%02x:%02x:%02x), vdev_id = %d", pReqMsg->oui[0], - pReqMsg->oui[1], pReqMsg->oui[2], pReqMsg->vdev_id); + hdd_debug("Oui (%02x:%02x:%02x), vdev_id = %d", + scan_mac_oui.oui[0], scan_mac_oui.oui[1], + scan_mac_oui.oui[2], scan_mac_oui.vdev_id); - hdd_update_ie_whitelist_attr(&pReqMsg->ie_whitelist, hdd_ctx); + hdd_update_ie_whitelist_attr(&scan_mac_oui.ie_whitelist, hdd_ctx); mac_handle = hdd_ctx->mac_handle; - status = sme_set_scanning_mac_oui(mac_handle, pReqMsg); - if (!QDF_IS_STATUS_SUCCESS(status)) { + status = sme_set_scanning_mac_oui(mac_handle, &scan_mac_oui); + if (!QDF_IS_STATUS_SUCCESS(status)) hdd_err("sme_set_scanning_mac_oui failed(err=%d)", status); - goto fail; - } - return 0; -fail: - qdf_mem_free(pReqMsg); - return -EINVAL; + + return qdf_status_to_os_return(status); } /** diff --git a/core/mac/inc/sir_api.h b/core/mac/inc/sir_api.h index 797f8f194e7d..ddffd0454cc0 100644 --- a/core/mac/inc/sir_api.h +++ b/core/mac/inc/sir_api.h @@ -87,7 +87,6 @@ typedef uint8_t tSirVersionString[SIR_VERSION_STRING_LEN]; /* Periodic Tx pattern offload feature */ #define PERIODIC_TX_PTRN_MAX_SIZE 1536 #define MAXNUM_PERIODIC_TX_PTRNS 6 -#define WIFI_SCANNING_MAC_OUI_LENGTH 3 /* FW response timeout values in milli seconds */ @@ -3580,13 +3579,6 @@ struct rso_cmd_status { bool status; }; -typedef struct { - uint8_t oui[WIFI_SCANNING_MAC_OUI_LENGTH]; - uint32_t vdev_id; - bool enb_probe_req_sno_randomization; - struct probe_req_whitelist_attr ie_whitelist; -} tSirScanMacOui, *tpSirScanMacOui; - enum { SIR_AP_RX_DATA_OFFLOAD = 0x00, SIR_STA_RX_DATA_OFFLOAD = 0x01, diff --git a/core/sme/inc/sme_api.h b/core/sme/inc/sme_api.h index e78977e07a09..f0988078400c 100644 --- a/core/sme/inc/sme_api.h +++ b/core/sme/inc/sme_api.h @@ -1253,8 +1253,16 @@ QDF_STATUS sme_get_temperature(mac_handle_t mac_handle, void *tempContext, void (*pCallbackfn)(int temperature, void *pContext)); + +/** + * sme_set_scanning_mac_oui() - SME API to set scanning mac oui + * @mac_handle: MAC Handle + * @scan_mac_oui: Scanning Mac Oui + * + * Return: QDF_STATUS + */ QDF_STATUS sme_set_scanning_mac_oui(mac_handle_t mac_handle, - tSirScanMacOui *pScanMacOui); + struct scan_mac_oui *scan_mac_oui); #ifdef DHCP_SERVER_OFFLOAD QDF_STATUS sme_set_dhcp_srv_offload(mac_handle_t mac_handle, diff --git a/core/sme/src/common/sme_api.c b/core/sme/src/common/sme_api.c index 1ee2be451b62..341ece33c4c9 100644 --- a/core/sme/src/common/sme_api.c +++ b/core/sme/src/common/sme_api.c @@ -10427,38 +10427,37 @@ QDF_STATUS sme_get_temperature(mac_handle_t mac_handle, return status; } -/* - * sme_set_scanning_mac_oui() - - * SME API to set scanning mac oui - * - * mac_handle - * pScanMacOui: Scanning Mac Oui (input 3 bytes) - * Return QDF_STATUS - */ QDF_STATUS sme_set_scanning_mac_oui(mac_handle_t mac_handle, - tSirScanMacOui *pScanMacOui) + struct scan_mac_oui *scan_mac_oui) { QDF_STATUS status = QDF_STATUS_SUCCESS; - QDF_STATUS qdf_status = QDF_STATUS_SUCCESS; struct mac_context *mac = MAC_CONTEXT(mac_handle); struct scheduler_msg message = {0}; + struct scan_mac_oui *bodyptr; + + /* per contract must make a copy of the params when messaging */ + bodyptr = qdf_mem_malloc(sizeof(*bodyptr)); + if (!bodyptr) + return QDF_STATUS_E_NOMEM; + *bodyptr = *scan_mac_oui; status = sme_acquire_global_lock(&mac->sme); if (QDF_STATUS_SUCCESS == status) { /* Serialize the req through MC thread */ - message.bodyptr = pScanMacOui; + message.bodyptr = bodyptr; message.type = WMA_SET_SCAN_MAC_OUI_REQ; - qdf_status = scheduler_post_message(QDF_MODULE_ID_SME, - QDF_MODULE_ID_WMA, - QDF_MODULE_ID_WMA, - &message); - if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { - QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR, - FL("Msg post Set Scan Mac OUI failed")); - status = QDF_STATUS_E_FAILURE; - } + status = scheduler_post_message(QDF_MODULE_ID_SME, + QDF_MODULE_ID_WMA, + QDF_MODULE_ID_WMA, + &message); sme_release_global_lock(&mac->sme); } + + if (QDF_IS_STATUS_ERROR(status)) { + sme_err("failure: %d", status); + qdf_mem_free(bodyptr); + } + return status; } diff --git a/core/wma/inc/wma_internal.h b/core/wma/inc/wma_internal.h index da7cb88d723e..5953d694f0cd 100644 --- a/core/wma/inc/wma_internal.h +++ b/core/wma/inc/wma_internal.h @@ -486,7 +486,17 @@ wma_reset_passpoint_network_list(tp_wma_handle wma, struct wifi_passpoint_req_param *params); #endif -QDF_STATUS wma_scan_probe_setoui(tp_wma_handle wma, tSirScanMacOui *psetoui); +/** + * wma_scan_probe_setoui() - set scan probe OUI + * @wma: wma handle + * @set_oui: OUI parameters + * + * set scan probe OUI parameters in firmware + * + * Return: QDF status + */ +QDF_STATUS wma_scan_probe_setoui(tp_wma_handle wma, + struct scan_mac_oui *set_oui); void wma_roam_better_ap_handler(tp_wma_handle wma, uint32_t vdev_id); diff --git a/core/wma/src/wma_scan_roam.c b/core/wma/src/wma_scan_roam.c index 6e2c80e0110e..fed723902a4e 100644 --- a/core/wma/src/wma_scan_roam.c +++ b/core/wma/src/wma_scan_roam.c @@ -4820,37 +4820,17 @@ wma_reset_passpoint_network_list(tp_wma_handle wma, #endif -/** - * wma_scan_probe_setoui() - set scan probe OUI - * @wma: wma handle - * @psetoui: OUI parameters - * - * set scan probe OUI parameters in firmware - * - * Return: QDF status - */ -QDF_STATUS wma_scan_probe_setoui(tp_wma_handle wma, tSirScanMacOui *psetoui) +QDF_STATUS wma_scan_probe_setoui(tp_wma_handle wma, + struct scan_mac_oui *set_oui) { - struct scan_mac_oui set_oui; - - qdf_mem_zero(&set_oui, sizeof(struct scan_mac_oui)); - if (!wma || !wma->wmi_handle) { WMA_LOGE("%s: WMA is closed, can not issue cmd", __func__); return QDF_STATUS_E_INVAL; } - qdf_mem_copy(set_oui.oui, psetoui->oui, - WMI_WIFI_SCANNING_MAC_OUI_LENGTH); - - set_oui.vdev_id = psetoui->vdev_id; - set_oui.enb_probe_req_sno_randomization = - psetoui->enb_probe_req_sno_randomization; - set_oui.ie_whitelist = psetoui->ie_whitelist; - - return wmi_unified_scan_probe_setoui_cmd(wma->wmi_handle, - &set_oui); + return wmi_unified_scan_probe_setoui_cmd(wma->wmi_handle, set_oui); } + /** * wma_roam_better_ap_handler() - better ap event handler * @wma: wma handle