qcacld-3.0: Refine the extscan get cached results logic

Make the following updates to the extscan get cached results 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.

Change-Id: I4144aa4cdb9c6d3ddaae30eedaec3096abf95857
CRs-Fixed: 2329405
This commit is contained in:
Jeff Johnson 2018-07-17 08:19:37 -07:00 • committed by nshrivas
commit 2ba600960c
7 changed files with 76 additions and 113 deletions

View file

@ -1728,16 +1728,6 @@ int wlan_hdd_cfg80211_extscan_get_capabilities(struct wiphy *wiphy,
return ret;
}
/*
* define short names for the global vendor params
* used by wlan_hdd_cfg80211_extscan_get_cached_results()
*/
#define PARAM_MAX \
QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX
#define PARAM_REQUEST_ID \
QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID
#define PARAM_FLUSH \
QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_CACHED_SCAN_RESULTS_CONFIG_PARAM_FLUSH
/**
* __wlan_hdd_cfg80211_extscan_get_cached_results() - extscan get cached results
* @wiphy: wiphy pointer
@ -1757,20 +1747,20 @@ int wlan_hdd_cfg80211_extscan_get_capabilities(struct wiphy *wiphy,
*
* Return: 0 on success; error number otherwise.
*/
static int __wlan_hdd_cfg80211_extscan_get_cached_results(struct wiphy *wiphy,
struct wireless_dev
*wdev, const void *data,
int data_len)
static int
__wlan_hdd_cfg80211_extscan_get_cached_results(struct wiphy *wiphy,
struct wireless_dev *wdev,
const void *data,
int data_len)
{
tpSirExtScanGetCachedResultsReqParams pReqMsg = NULL;
struct extscan_cached_result_params params;
struct net_device *dev = wdev->netdev;
struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
struct hdd_context *hdd_ctx = wiphy_priv(wiphy);
struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX +
1];
struct nlattr *tb[EXTSCAN_PARAM_MAX + 1];
struct hdd_ext_scan_context *context;
QDF_STATUS status;
int retval = 0;
int id, retval;
unsigned long rc;
/* ENTER_DEV() intentionally not used in a frequently invoked API */
@ -1788,47 +1778,43 @@ static int __wlan_hdd_cfg80211_extscan_get_cached_results(struct wiphy *wiphy,
hdd_err("extscan not supported");
return -ENOTSUPP;
}
if (wlan_cfg80211_nla_parse(tb, PARAM_MAX, data, data_len,
if (wlan_cfg80211_nla_parse(tb, EXTSCAN_PARAM_MAX, data, data_len,
wlan_hdd_extscan_config_policy)) {
hdd_err("Invalid ATTR");
return -EINVAL;
}
pReqMsg = qdf_mem_malloc(sizeof(*pReqMsg));
if (!pReqMsg) {
hdd_err("qdf_mem_malloc failed");
return -ENOMEM;
}
/* Parse and fetch request Id */
if (!tb[PARAM_REQUEST_ID]) {
id = QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID;
if (!tb[id]) {
hdd_err("attr request id failed");
goto fail;
return -EINVAL;
}
pReqMsg->requestId = nla_get_u32(tb[PARAM_REQUEST_ID]);
pReqMsg->sessionId = adapter->session_id;
params.request_id = nla_get_u32(tb[id]);
params.vdev_id = adapter->session_id;
/* Parse and fetch flush parameter */
if (!tb[PARAM_FLUSH]) {
id = QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_CACHED_SCAN_RESULTS_CONFIG_PARAM_FLUSH;
if (!tb[id]) {
hdd_err("attr flush failed");
goto fail;
return -EINVAL;
}
pReqMsg->flush = nla_get_u8(tb[PARAM_FLUSH]);
hdd_debug("Req Id: %u Session Id: %d Flush: %d",
pReqMsg->requestId, pReqMsg->sessionId, pReqMsg->flush);
params.flush = nla_get_u8(tb[id]);
hdd_debug("Req Id: %u Vdev Id: %d Flush: %d",
params.request_id, params.vdev_id, params.flush);
context = &ext_scan_context;
spin_lock(&context->context_lock);
context->request_id = pReqMsg->requestId;
context->request_id = params.request_id;
context->ignore_cached_results = false;
INIT_COMPLETION(context->response_event);
spin_unlock(&context->context_lock);
status = sme_get_cached_results(hdd_ctx->mac_handle, pReqMsg);
status = sme_get_cached_results(hdd_ctx->mac_handle, &params);
if (!QDF_IS_STATUS_SUCCESS(status)) {
hdd_err("sme_get_cached_results failed(err=%d)", status);
goto fail;
return -EINVAL;
}
rc = wait_for_completion_timeout(&context->response_event,
@ -1845,18 +1831,7 @@ static int __wlan_hdd_cfg80211_extscan_get_cached_results(struct wiphy *wiphy,
spin_unlock(&context->context_lock);
}
return retval;
fail:
qdf_mem_free(pReqMsg);
return -EINVAL;
}
/*
* done with short names for the global vendor params
* used by wlan_hdd_cfg80211_extscan_get_cached_results()
*/
#undef PARAM_MAX
#undef PARAM_REQUEST_ID
#undef PARAM_FLUSH
/**
* wlan_hdd_cfg80211_extscan_get_cached_results() - extscan get cached results

View file

@ -3930,17 +3930,6 @@ struct ext_scan_capabilities_response {
uint32_t max_number_of_black_listed_bssid;
};
typedef struct {
uint32_t requestId;
uint8_t sessionId;
/*
* 1 - return cached results and flush it
* 0 - return cached results and do not flush
*/
bool flush;
} tSirExtScanGetCachedResultsReqParams, *tpSirExtScanGetCachedResultsReqParams;
typedef struct {
uint32_t requestId;
uint32_t status;

View file

@ -1056,9 +1056,16 @@ QDF_STATUS
sme_reset_significant_change(mac_handle_t mac_handle,
struct extscan_capabilities_reset_params *params);
QDF_STATUS sme_get_cached_results(tHalHandle hHal,
tSirExtScanGetCachedResultsReqParams *
pCachedResultsReq);
/**
* sme_get_cached_results() - SME API to get cached results
* @mac_handle: Opaque handle to the MAC context
* @params: extscan get cached results structure
*
* Return: QDF_STATUS
*/
QDF_STATUS
sme_get_cached_results(mac_handle_t mac_handle,
struct extscan_cached_result_params *params);
QDF_STATUS sme_set_epno_list(tHalHandle hal,
struct wifi_epno_params *req_msg);

View file

@ -11425,38 +11425,38 @@ sme_reset_significant_change(mac_handle_t mac_handle,
return status;
}
/*
* sme_get_cached_results() -
* SME API to get cached results
*
* hHal
* pCachedResultsReq: extscan get cached results structure
* Return QDF_STATUS
*/
QDF_STATUS sme_get_cached_results(tHalHandle hHal,
tSirExtScanGetCachedResultsReqParams *
pCachedResultsReq)
QDF_STATUS
sme_get_cached_results(mac_handle_t mac_handle,
struct extscan_cached_result_params *params)
{
QDF_STATUS status = QDF_STATUS_SUCCESS;
QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
QDF_STATUS status;
tpAniSirGlobal mac = MAC_CONTEXT(mac_handle);
struct scheduler_msg message = {0};
struct extscan_cached_result_params *bodyptr;
status = sme_acquire_global_lock(&pMac->sme);
/* 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 = *params;
status = sme_acquire_global_lock(&mac->sme);
if (QDF_IS_STATUS_SUCCESS(status)) {
/* Serialize the req through MC thread */
message.bodyptr = pCachedResultsReq;
message.bodyptr = bodyptr;
message.type = WMA_EXTSCAN_GET_CACHED_RESULTS_REQ;
MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
NO_SESSION, message.type));
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))
status = QDF_STATUS_E_FAILURE;
qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
NO_SESSION, message.type);
status = scheduler_post_message(QDF_MODULE_ID_SME,
QDF_MODULE_ID_WMA,
QDF_MODULE_ID_WMA,
&message);
sme_release_global_lock(&mac->sme);
}
sme_release_global_lock(&pMac->sme);
if (QDF_IS_STATUS_ERROR(status)) {
sme_err("failure: %d", status);
qdf_mem_free(bodyptr);
}
return status;
}

View file

@ -412,9 +412,18 @@ QDF_STATUS
wma_extscan_stop_change_monitor(tp_wma_handle wma,
struct extscan_capabilities_reset_params *params);
QDF_STATUS wma_extscan_get_cached_results(tp_wma_handle wma,
tSirExtScanGetCachedResultsReqParams *
pcached_results);
/**
* wma_extscan_get_cached_results() - extscan get cached results
* @wma: wma handle
* @params: cached results parameters
*
* This function send request to fw to get cached results.
*
* Return: QDF status
*/
QDF_STATUS
wma_extscan_get_cached_results(tp_wma_handle wma,
struct extscan_cached_result_params *params);
QDF_STATUS wma_extscan_get_capabilities(tp_wma_handle wma,
tSirGetExtScanCapabilitiesReqParams *

View file

@ -8241,8 +8241,7 @@ static QDF_STATUS wma_mc_process_msg(struct scheduler_msg *msg)
qdf_mem_free(msg->bodyptr);
break;
case WMA_EXTSCAN_GET_CACHED_RESULTS_REQ:
wma_extscan_get_cached_results(wma_handle,
(tSirExtScanGetCachedResultsReqParams *) msg->bodyptr);
wma_extscan_get_cached_results(wma_handle, msg->bodyptr);
qdf_mem_free(msg->bodyptr);
break;
case WMA_EXTSCAN_GET_CAPABILITIES_REQ:

View file

@ -4752,37 +4752,21 @@ QDF_STATUS wma_extscan_stop_change_monitor(tp_wma_handle wma,
params);
}
/**
* wma_extscan_get_cached_results() - extscan get cached results
* @wma: wma handle
* @pcached_results: cached results parameters
*
* This function send request to fw to get cached results.
*
* Return: QDF status
*/
QDF_STATUS wma_extscan_get_cached_results(tp_wma_handle wma,
tSirExtScanGetCachedResultsReqParams *
pcached_results)
QDF_STATUS
wma_extscan_get_cached_results(tp_wma_handle wma,
struct extscan_cached_result_params *params)
{
struct extscan_cached_result_params params = {0};
if (!wma || !wma->wmi_handle) {
WMA_LOGE("%s: WMA is closed, cannot issue cmd", __func__);
return QDF_STATUS_E_INVAL;
}
if (!wmi_service_enabled(wma->wmi_handle,
wmi_service_extscan)) {
if (!wmi_service_enabled(wma->wmi_handle, wmi_service_extscan)) {
WMA_LOGE("%s: extscan not enabled", __func__);
return QDF_STATUS_E_FAILURE;
}
params.request_id = pcached_results->requestId;
params.vdev_id = pcached_results->sessionId;
params.flush = pcached_results->flush;
return wmi_unified_extscan_get_cached_results_cmd(wma->wmi_handle,
&params);
params);
}
/**