Pārlūkot izejas kodu

qcacld-3.0: Refine the extscan stop scan logic

Make the following updates to the extscan stop scan 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: Ie4a693b4a91d728a075cffad3ee368b22d9c5b2a
CRs-Fixed: 2335647
Jeff Johnson 7 gadi atpakaļ
vecāks
revīzija
7272ea7cc0

+ 22 - 55
core/hdd/src/wlan_hdd_ext_scan.c

@@ -3018,13 +3018,6 @@ static uint32_t hdd_extscan_map_usr_drv_config_flags(uint32_t config_flags)
 	return configuration_flags;
 }
 
-/*
- * define short names for the global vendor params
- * used by __wlan_hdd_cfg80211_extscan_start()
- */
-#define PARAM_MAX \
-	QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX
-
 /**
  * __wlan_hdd_cfg80211_extscan_start() - ext scan start
  * @wiphy: Pointer to wireless phy
@@ -3044,7 +3037,7 @@ __wlan_hdd_cfg80211_extscan_start(struct wiphy *wiphy,
 	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[PARAM_MAX + 1];
+	struct nlattr *tb[EXTSCAN_PARAM_MAX + 1];
 	struct hdd_ext_scan_context *context;
 	uint32_t num_buckets;
 	QDF_STATUS status;
@@ -3071,7 +3064,7 @@ __wlan_hdd_cfg80211_extscan_start(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;
@@ -3236,15 +3229,6 @@ int wlan_hdd_cfg80211_extscan_start(struct wiphy *wiphy,
 }
 
 
-/*
- * define short names for the global vendor params
- * used by __wlan_hdd_cfg80211_extscan_stop()
- */
-#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
-
 /**
  * __wlan_hdd_cfg80211_extscan_stop() - ext scan stop
  * @wiphy: Pointer to wireless phy
@@ -3256,18 +3240,17 @@ int wlan_hdd_cfg80211_extscan_start(struct wiphy *wiphy,
  */
 static int
 __wlan_hdd_cfg80211_extscan_stop(struct wiphy *wiphy,
-				   struct wireless_dev *wdev,
-				   const void *data, int data_len)
+				 struct wireless_dev *wdev,
+				 const void *data, int data_len)
 {
-	tpSirExtScanStopReqParams pReqMsg = NULL;
+	struct extscan_stop_req_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[PARAM_MAX + 1];
+	struct nlattr *tb[EXTSCAN_PARAM_MAX + 1];
 	struct hdd_ext_scan_context *context;
 	QDF_STATUS status;
-	uint32_t request_id;
-	int retval;
+	int id, retval;
 	unsigned long rc;
 
 	hdd_enter_dev(dev);
@@ -3285,39 +3268,34 @@ __wlan_hdd_cfg80211_extscan_stop(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;
-	hdd_debug("Req Id %d Session Id %d",
-		pReqMsg->requestId, pReqMsg->sessionId);
+	params.request_id = nla_get_u32(tb[id]);
+	params.vdev_id = adapter->session_id;
+	hdd_debug("Req Id %d Vdev Id %d",
+		  params.request_id, params.vdev_id);
 
 	context = &ext_scan_context;
 	spin_lock(&context->context_lock);
 	INIT_COMPLETION(context->response_event);
-	context->request_id = request_id = pReqMsg->requestId;
+	context->request_id = params.request_id;
 	spin_unlock(&context->context_lock);
 
-	status = sme_ext_scan_stop(hdd_ctx->mac_handle, pReqMsg);
+	status = sme_ext_scan_stop(hdd_ctx->mac_handle, &params);
 	if (!QDF_IS_STATUS_SUCCESS(status)) {
 		hdd_err("sme_ext_scan_stop failed(err=%d)", status);
-		goto fail;
+		return qdf_status_to_os_return(status);
 	}
 
 	/* request was sent -- wait for the response */
@@ -3329,7 +3307,7 @@ __wlan_hdd_cfg80211_extscan_stop(struct wiphy *wiphy,
 		retval = -ETIMEDOUT;
 	} else {
 		spin_lock(&context->context_lock);
-		if (context->request_id == request_id)
+		if (context->request_id == params.request_id)
 			retval = context->response_status;
 		else
 			retval = -EINVAL;
@@ -3337,18 +3315,7 @@ __wlan_hdd_cfg80211_extscan_stop(struct wiphy *wiphy,
 	}
 	hdd_exit();
 	return retval;
-
-fail:
-	qdf_mem_free(pReqMsg);
-	return -EINVAL;
 }
-/*
- * done with short names for the global vendor params
- * used by wlan_hdd_cfg80211_extscan_stop()
- */
-#undef PARAM_MAX
-#undef PARAM_REQUEST_ID
-
 
 /**
  * wlan_hdd_cfg80211_extscan_stop() - stop extscan
@@ -3360,8 +3327,8 @@ fail:
  * Return: 0 on success, negative errno on failure
  */
 int wlan_hdd_cfg80211_extscan_stop(struct wiphy *wiphy,
-				struct wireless_dev *wdev,
-				const void *data, int data_len)
+				   struct wireless_dev *wdev,
+				   const void *data, int data_len)
 {
 	int ret = 0;
 

+ 0 - 5
core/mac/inc/sir_api.h

@@ -4075,11 +4075,6 @@ struct sir_extscan_generic_response {
 	uint32_t status;
 };
 
-typedef struct {
-	uint32_t requestId;
-	uint8_t sessionId;
-} tSirExtScanStopReqParams, *tpSirExtScanStopReqParams;
-
 typedef struct {
 	struct qdf_mac_addr bssid;
 	uint32_t channel;

+ 9 - 2
core/sme/inc/sme_api.h

@@ -1028,8 +1028,15 @@ QDF_STATUS
 sme_ext_scan_start(mac_handle_t mac_handle,
 		   struct wifi_scan_cmd_req_params *params);
 
-QDF_STATUS sme_ext_scan_stop(tHalHandle hHal,
-		tSirExtScanStopReqParams *pStopReq);
+/**
+ * sme_ext_scan_stop() - SME API to issue extscan stop
+ * @mac_handle: Opaque handle to the MAC context
+ * @params: extscan stop structure
+ *
+ * Return: QDF_STATUS
+ */
+QDF_STATUS sme_ext_scan_stop(mac_handle_t mac_handle,
+			     struct extscan_stop_req_params *params);
 
 /**
  * sme_set_bss_hotlist() - SME API to set BSSID hotlist

+ 25 - 24
core/sme/src/common/sme_api.c

@@ -11137,36 +11137,37 @@ sme_ext_scan_start(mac_handle_t mac_handle,
 	return status;
 }
 
-/*
- * sme_ext_scan_stop() -
- * SME API to issue extscan stop
- *
- * hHal
- * pStopReq: extscan stop structure
- * Return QDF_STATUS
- */
-QDF_STATUS sme_ext_scan_stop(tHalHandle hHal, tSirExtScanStopReqParams
-			*pStopReq)
+QDF_STATUS sme_ext_scan_stop(mac_handle_t mac_handle,
+			     struct extscan_stop_req_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_stop_req_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 = pStopReq;
+		message.bodyptr = bodyptr;
 		message.type = WMA_EXTSCAN_STOP_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;
-		sme_release_global_lock(&pMac->sme);
+		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);
+	}
+
+	if (QDF_IS_STATUS_ERROR(status)) {
+		sme_err("failure: %d", status);
+		qdf_mem_free(bodyptr);
 	}
 	return status;
 }

+ 10 - 1
core/wma/inc/wma_internal.h

@@ -368,8 +368,17 @@ void wma_register_extscan_event_handler(tp_wma_handle wma_handle);
 QDF_STATUS wma_start_extscan(tp_wma_handle wma,
 			     struct wifi_scan_cmd_req_params *pstart);
 
+/**
+ * wma_stop_extscan() - stop extscan command to fw.
+ * @wma: wma handle
+ * @params: stop scan command request params
+ *
+ * This function sends stop extscan request to fw.
+ *
+ * Return: QDF Status.
+ */
 QDF_STATUS wma_stop_extscan(tp_wma_handle wma,
-			    tSirExtScanStopReqParams *pstopcmd);
+			    struct extscan_stop_req_params *params);
 
 /**
  * wma_extscan_start_hotlist_monitor() - start hotlist monitor

+ 1 - 2
core/wma/src/wma_main.c

@@ -8186,8 +8186,7 @@ static QDF_STATUS wma_mc_process_msg(struct scheduler_msg *msg)
 		qdf_mem_free(msg->bodyptr);
 		break;
 	case WMA_EXTSCAN_STOP_REQ:
-		wma_stop_extscan(wma_handle,
-				 (tSirExtScanStopReqParams *) msg->bodyptr);
+		wma_stop_extscan(wma_handle, msg->bodyptr);
 		qdf_mem_free(msg->bodyptr);
 		break;
 	case WMA_EXTSCAN_SET_BSSID_HOTLIST_REQ:

+ 5 - 20
core/wma/src/wma_scan_roam.c

@@ -4501,42 +4501,27 @@ QDF_STATUS wma_start_extscan(tp_wma_handle wma,
 	return status;
 }
 
-/**
- * wma_stop_extscan() - stop extscan command to fw.
- * @handle: wma handle
- * @pstopcmd: stop scan command request params
- *
- * This function sends stop extscan request to fw.
- *
- * Return: QDF Status.
- */
 QDF_STATUS wma_stop_extscan(tp_wma_handle wma,
-			    tSirExtScanStopReqParams *pstopcmd)
+			    struct extscan_stop_req_params *params)
 {
-	struct extscan_stop_req_params params = {0};
 	QDF_STATUS status;
 
 	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 = pstopcmd->requestId;
-	params.vdev_id = pstopcmd->sessionId;
-
-	status = wmi_unified_stop_extscan_cmd(wma->wmi_handle,
-						&params);
+	status = wmi_unified_stop_extscan_cmd(wma->wmi_handle, params);
 	if (QDF_IS_STATUS_ERROR(status))
 		return status;
 
-	wma->interfaces[pstopcmd->sessionId].extscan_in_progress = false;
+	wma->interfaces[params->vdev_id].extscan_in_progress = false;
 	WMA_LOGD("Extscan stop request sent successfully for vdev %d",
-		 pstopcmd->sessionId);
+		 params->vdev_id);
 
 	return status;
 }