Browse Source

qcacld-3.0: Update sme_get_bpf_offload_capabilities()

A new HDD Request Management framework is being deployed. One of the
requirements of that framework is that every request API must have a
provision for a caller-supplied context, and that caller-supplied
context must be returned to the caller when the callback function is
invoked.

Currently sme_get_bpf_offload_capabilities() is not aligned with that
requirement. There is no provision for a caller-supplied context;
instead the HDD handle which is stored in the MAC context is always
returned.

In order to prepare sme_get_bpf_offload_capabilities() for the HDD
Request Management framework update the curent implementation as
follows:
1) Remove the separate registration and deregistration of the callback
   function pointer, and instead make the callback function and
   callback context parameters to sme_get_bpf_offload_capabilities().
2) Pass the callback context when invoking the callback function.

Change-Id: I3967fdf9b002d961b0ec9a7ea78e7783b47c50a3
CRs-Fixed: 2000024
Jeff Johnson 8 năm trước cách đây
mục cha
commit
a867e0c43c

+ 5 - 3
core/hdd/src/wlan_hdd_cfg80211.c

@@ -6388,8 +6388,8 @@ wlan_hdd_bpf_offload_policy[BPF_MAX + 1] = {
  *
  * Return: None
  */
-void hdd_get_bpf_offload_cb(void *hdd_context,
-			    struct sir_bpf_get_offload *data)
+static void hdd_get_bpf_offload_cb(void *hdd_context,
+				   struct sir_bpf_get_offload *data)
 {
 	hdd_context_t *hdd_ctx = hdd_context;
 	struct hdd_bpf_context *context;
@@ -6490,7 +6490,9 @@ static int hdd_get_bpf_offload(hdd_context_t *hdd_ctx)
 	INIT_COMPLETION(context->completion);
 	spin_unlock(&hdd_context_lock);
 
-	status = sme_get_bpf_offload_capabilities(hdd_ctx->hHal);
+	status = sme_get_bpf_offload_capabilities(hdd_ctx->hHal,
+						  hdd_get_bpf_offload_cb,
+						  hdd_ctx);
 	if (!QDF_IS_STATUS_SUCCESS(status)) {
 		hdd_err("Unable to retrieve BPF caps");
 		return -EINVAL;

+ 0 - 1
core/hdd/src/wlan_hdd_cfg80211.h

@@ -3489,7 +3489,6 @@ int wlan_hdd_disable_dfs_chan_scan(hdd_context_t *hdd_ctx,
 int wlan_hdd_cfg80211_update_band(struct wiphy *wiphy,
 				  eCsrBand eBand);
 
-void hdd_get_bpf_offload_cb(void *hdd_context, struct sir_bpf_get_offload *);
 void hdd_init_bpf_completion(void);
 
 #if defined(CFG80211_DISCONNECTED_V2) || \

+ 0 - 12
core/hdd/src/wlan_hdd_main.c

@@ -8501,14 +8501,6 @@ int hdd_register_cb(hdd_context_t *hdd_ctx)
 	sme_set_rssi_threshold_breached_cb(hdd_ctx->hHal,
 				hdd_rssi_threshold_breached);
 
-	status = sme_bpf_offload_register_callback(hdd_ctx->hHal,
-						   hdd_get_bpf_offload_cb);
-	if (!QDF_IS_STATUS_SUCCESS(status)) {
-		hdd_err("set bpf offload callback failed");
-		ret = -EINVAL;
-		return ret;
-	}
-
 	sme_set_link_layer_stats_ind_cb(hdd_ctx->hHal,
 				wlan_hdd_cfg80211_link_layer_stats_callback);
 
@@ -8545,10 +8537,6 @@ void hdd_deregister_cb(hdd_context_t *hdd_ctx)
 			status);
 
 	sme_reset_link_layer_stats_ind_cb(hdd_ctx->hHal);
-	status = sme_bpf_offload_deregister_callback(hdd_ctx->hHal);
-	if (!QDF_IS_STATUS_SUCCESS(status))
-		hdd_err("De-register bpf offload callback failed: %d",
-			status);
 	sme_reset_rssi_threshold_breached_cb(hdd_ctx->hHal);
 
 	status = cds_deregister_sap_restart_channel_switch_cb();

+ 16 - 5
core/sme/inc/sme_api.h

@@ -1226,12 +1226,23 @@ bool sme_is_sta_smps_allowed(tHalHandle hHal, uint8_t session_id);
 QDF_STATUS sme_add_beacon_filter(tHalHandle hal,
 				uint32_t session_id, uint32_t *ie_map);
 QDF_STATUS sme_remove_beacon_filter(tHalHandle hal, uint32_t session_id);
-QDF_STATUS sme_bpf_offload_register_callback(tHalHandle hal,
-					void (*pbpf_get_offload_cb)(void *,
-					struct sir_bpf_get_offload *));
-QDF_STATUS sme_bpf_offload_deregister_callback(tHalHandle hal);
 
-QDF_STATUS sme_get_bpf_offload_capabilities(tHalHandle hal);
+/**
+ * sme_get_bpf_offload_capabilities() - Get BPF offload capabilities
+ * @hal: Global HAL handle
+ * @callback: Callback function to be called with the result
+ * @context: Opaque context to be used by the caller to associate the
+ *   request with the response
+ *
+ * This function constructs the cds message and fill in message type,
+ * post the same to WDA.
+ *
+ * Return: QDF_STATUS enumeration
+ */
+QDF_STATUS sme_get_bpf_offload_capabilities(tHalHandle hal,
+					    bpf_get_offload_cb callback,
+					    void *context);
+
 QDF_STATUS sme_set_bpf_instructions(tHalHandle hal,
 				struct sir_bpf_set_offload *);
 uint32_t sme_get_wni_dot11_mode(tHalHandle hal);

+ 13 - 3
core/sme/inc/sme_internal.h

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011-2016 The Linux Foundation. All rights reserved.
+ * Copyright (c) 2011-2017 The Linux Foundation. All rights reserved.
  *
  * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
  *
@@ -155,6 +155,16 @@ typedef void (*sme_set_thermal_level_callback)(void *context, u_int8_t level);
 typedef void (*p2p_lo_callback)(void *context, void *event);
 typedef void (*sme_send_oem_data_rsp_msg)(struct oem_data_rsp *);
 
+/**
+ * typedef bpf_get_offload_cb - BPF offload callback signature
+ * @context: Opaque context that the client can use to associate the
+ *    callback with the request
+ * @caps: BPF offload capabilities as reported by firmware
+ */
+struct sir_bpf_get_offload;
+typedef void (*bpf_get_offload_cb)(void *context,
+				   struct sir_bpf_get_offload *caps);
+
 typedef struct tagSmeStruct {
 	eSmeState state;
 	qdf_mutex_t lkSmeGlobalLock;
@@ -245,8 +255,8 @@ typedef struct tagSmeStruct {
 	ocb_callback dcc_stats_event_callback;
 	sme_set_thermal_level_callback set_thermal_level_cb;
 	void *saved_scan_cmd;
-	void (*pbpf_get_offload_cb)(void *context,
-			struct sir_bpf_get_offload *);
+	void *bpf_get_offload_context;
+	bpf_get_offload_cb bpf_get_offload_cb;
 	p2p_lo_callback p2p_lo_event_callback;
 	void *p2p_lo_event_context;
 	sme_send_oem_data_rsp_msg oem_data_rsp_callback;

+ 5 - 71
core/sme/src/common/sme_api.c

@@ -16287,14 +16287,9 @@ void sme_send_disassoc_req_frame(tHalHandle hal, uint8_t session_id,
 			FL("cds_send_mb_message Failed"));
 }
 
-/**
- * sme_get_bpf_offload_capabilities() - Get length for BPF offload
- * @hal: Global HAL handle
- * This function constructs the cds message and fill in message type,
- * post the same to WDA.
- * Return: QDF_STATUS enumeration
- */
-QDF_STATUS sme_get_bpf_offload_capabilities(tHalHandle hal)
+QDF_STATUS sme_get_bpf_offload_capabilities(tHalHandle hal,
+					    bpf_get_offload_cb callback,
+					    void *context)
 {
 	QDF_STATUS          status     = QDF_STATUS_SUCCESS;
 	tpAniSirGlobal      mac_ctx      = PMAC_STRUCT(hal);
@@ -16305,6 +16300,8 @@ QDF_STATUS sme_get_bpf_offload_capabilities(tHalHandle hal)
 	status = sme_acquire_global_lock(&mac_ctx->sme);
 	if (QDF_STATUS_SUCCESS == status) {
 		/* Serialize the req through MC thread */
+		mac_ctx->sme.bpf_get_offload_cb = callback;
+		mac_ctx->sme.bpf_get_offload_context = context;
 		cds_msg.bodyptr = NULL;
 		cds_msg.type = WDA_BPF_GET_CAPABILITIES_REQ;
 		status = scheduler_post_msg(QDF_MODULE_ID_WMA, &cds_msg);
@@ -16380,34 +16377,6 @@ QDF_STATUS sme_set_bpf_instructions(tHalHandle hal,
 	return status;
 }
 
-/**
- * sme_bpf_offload_register_callback() - Register get bpf offload callbacK
- *
- * @hal - MAC global handle
- * @callback_routine - callback routine from HDD
- *
- * This API is invoked by HDD to register its callback in SME
- *
- * Return: QDF_STATUS
- */
-QDF_STATUS sme_bpf_offload_register_callback(tHalHandle hal,
-				void (*pbpf_get_offload_cb)(void *context,
-					struct sir_bpf_get_offload *))
-{
-	QDF_STATUS status   = QDF_STATUS_SUCCESS;
-	tpAniSirGlobal mac  = PMAC_STRUCT(hal);
-
-	status = sme_acquire_global_lock(&mac->sme);
-	if (QDF_IS_STATUS_SUCCESS(status)) {
-		mac->sme.pbpf_get_offload_cb = pbpf_get_offload_cb;
-		sme_release_global_lock(&mac->sme);
-	} else {
-		QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
-			FL("sme_acquire_global_lock failed"));
-	}
-	return status;
-}
-
 /**
  * sme_get_wni_dot11_mode() - return configured wni dot11mode
  * @hal: hal pointer
@@ -16422,41 +16391,6 @@ uint32_t sme_get_wni_dot11_mode(tHalHandle hal)
 		mac_ctx->roam.configParam.uCfgDot11Mode);
 }
 
-/**
- * sme_bpf_offload_deregister_callback() - Register get bpf offload callbacK
- *
- * @h_hal - MAC global handle
- * @callback_routine - callback routine from HDD
- *
- * This API is invoked by HDD to de-register its callback in SME
- *
- * Return: QDF_STATUS Enumeration
- */
-QDF_STATUS sme_bpf_offload_deregister_callback(tHalHandle h_hal)
-{
-	QDF_STATUS status = QDF_STATUS_SUCCESS;
-	tpAniSirGlobal mac;
-
-	if (!h_hal) {
-		QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
-				  FL("hHal is not valid"));
-		return QDF_STATUS_E_INVAL;
-	}
-
-	mac = PMAC_STRUCT(h_hal);
-
-	status = sme_acquire_global_lock(&mac->sme);
-	if (QDF_IS_STATUS_SUCCESS(status)) {
-		mac->sme.pbpf_get_offload_cb = NULL;
-		sme_release_global_lock(&mac->sme);
-	} else {
-		QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
-			FL("sme_acquire_global_lock failed"));
-	}
-	return status;
-}
-
-
 /**
  * sme_create_mon_session() - post message to create PE session for monitormode
  * operation

+ 3 - 2
core/wma/src/wma_features.c

@@ -7927,7 +7927,7 @@ int wma_get_bpf_caps_event_handler(void *handle,
 		WMA_LOGE("%s: Invalid pmac", __func__);
 		return -EINVAL;
 	}
-	if (!pmac->sme.pbpf_get_offload_cb) {
+	if (!pmac->sme.bpf_get_offload_cb) {
 		WMA_LOGE("%s: Callback not registered", __func__);
 		return -EINVAL;
 	}
@@ -7950,7 +7950,8 @@ int wma_get_bpf_caps_event_handler(void *handle,
 	bpf_get_offload->max_bytes_for_bpf_inst);
 
 	WMA_LOGD("%s: sending bpf capabilities event to hdd", __func__);
-	pmac->sme.pbpf_get_offload_cb(pmac->hHdd, bpf_get_offload);
+	pmac->sme.bpf_get_offload_cb(pmac->sme.bpf_get_offload_context,
+				     bpf_get_offload);
 	qdf_mem_free(bpf_get_offload);
 	return 0;
 }