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
diff --git a/core/hdd/src/wlan_hdd_cfg80211.c b/core/hdd/src/wlan_hdd_cfg80211.c
index 08a0c24..317314f 100644
--- a/core/hdd/src/wlan_hdd_cfg80211.c
+++ b/core/hdd/src/wlan_hdd_cfg80211.c
@@ -3288,7 +3288,7 @@
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 @@
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 797f8f1..ddffd04 100644
--- a/core/mac/inc/sir_api.h
+++ b/core/mac/inc/sir_api.h
@@ -87,7 +87,6 @@
/* 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 @@
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 e78977e..f098807 100644
--- a/core/sme/inc/sme_api.h
+++ b/core/sme/inc/sme_api.h
@@ -1253,8 +1253,16 @@
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 1ee2be4..341ece3 100644
--- a/core/sme/src/common/sme_api.c
+++ b/core/sme/src/common/sme_api.c
@@ -10427,38 +10427,37 @@
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 da7cb88..5953d69 100644
--- a/core/wma/inc/wma_internal.h
+++ b/core/wma/inc/wma_internal.h
@@ -486,7 +486,17 @@
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 6e2c80e..fed7239 100644
--- a/core/wma/src/wma_scan_roam.c
+++ b/core/wma/src/wma_scan_roam.c
@@ -4820,37 +4820,17 @@
#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