Преглед изворни кода

qcacld-3.0: Update sme_encrypt_decrypt_msg()

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_encrypt_decrypt_msg() 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_encrypt_decrypt_msg() 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_encrypt_decrypt_msg().
2) Pass the callback context when invoking the callback function.

Change-Id: I6e8c5405393f4cb732d9874ac07145caf5e95cac
CRs-Fixed: 2000026
Jeff Johnson пре 8 година
родитељ
комит
e8216e8705

+ 4 - 16
core/hdd/src/wlan_hdd_disa.c

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016 The Linux Foundation. All rights reserved.
+ * Copyright (c) 2016-2017 The Linux Foundation. All rights reserved.
  *
  * Permission to use, copy, modify, and/or distribute this software for
  * any purpose with or without fee is hereby granted, provided that the
@@ -366,7 +366,9 @@ static int hdd_encrypt_decrypt_msg(hdd_adapter_t *adapter,
 	spin_unlock(&hdd_context_lock);
 
 	qdf_status = sme_encrypt_decrypt_msg(hdd_ctx->hHal,
-					&encrypt_decrypt_params);
+					     &encrypt_decrypt_params,
+					     hdd_encrypt_decrypt_msg_cb,
+					     hdd_ctx);
 
 	qdf_mem_free(encrypt_decrypt_params.data);
 
@@ -408,16 +410,8 @@ static int hdd_encrypt_decrypt_msg(hdd_adapter_t *adapter,
  */
 int hdd_encrypt_decrypt_init(hdd_context_t *hdd_ctx)
 {
-	QDF_STATUS status;
-
 	init_completion(&encrypt_decrypt_msg_context.completion);
 
-	status = sme_encrypt_decrypt_msg_register_callback(hdd_ctx->hHal,
-					hdd_encrypt_decrypt_msg_cb);
-	if (!QDF_IS_STATUS_SUCCESS(status)) {
-		hdd_err("encrypt/decrypt callback failed %d", status);
-		return -EINVAL;
-	}
 	return 0;
 }
 
@@ -430,12 +424,6 @@ int hdd_encrypt_decrypt_init(hdd_context_t *hdd_ctx)
  */
 int hdd_encrypt_decrypt_deinit(hdd_context_t *hdd_ctx)
 {
-	QDF_STATUS status;
-
-	status = sme_encrypt_decrypt_msg_deregister_callback(hdd_ctx->hHal);
-	if (!QDF_IS_STATUS_SUCCESS(status))
-		hdd_err("De-register encrypt/decrypt callback failed: %d",
-			status);
 	return 0;
 }
 

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

@@ -1301,44 +1301,19 @@ QDF_STATUS sme_update_session_param(tHalHandle hal, uint8_t session_id,
 		uint32_t param_type, uint32_t param_val);
 
 #ifdef WLAN_FEATURE_DISA
-/**
- * sme_encrypt_decrypt_msg_register_callback() - Registers
- * encrypt/decrypt message 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_encrypt_decrypt_msg_register_callback(tHalHandle hal,
-		void (*encrypt_decrypt_cb)(void *hdd_context,
-			struct sir_encrypt_decrypt_rsp_params
-					*encrypt_decrypt_rsp_params));
-
-/**
- * sme_encrypt_decrypt_msg_deregister_callback() - Registers
- * encrypt/decrypt message 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_encrypt_decrypt_msg_deregister_callback(tHalHandle h_hal);
-
 /**
  * sme_encrypt_decrypt_msg() - handles encrypt/decrypt mesaage
  * @hal: HAL handle
  * @encrypt_decrypt_params: struct to set encryption/decryption params.
+ * @callback: callback function to be called with the result
+ * @context: Opaque context to be passed to callback function
  *
  * Return: QDF_STATUS enumeration.
  */
 QDF_STATUS sme_encrypt_decrypt_msg(tHalHandle hal,
-	struct encrypt_decrypt_req_params *encrypt_decrypt_params);
+		struct encrypt_decrypt_req_params *encrypt_decrypt_params,
+		sme_encrypt_decrypt_callback callback,
+		void *context);
 #endif
 
 /**

+ 14 - 2
core/sme/inc/sme_internal.h

@@ -165,6 +165,18 @@ struct sir_bpf_get_offload;
 typedef void (*bpf_get_offload_cb)(void *context,
 				   struct sir_bpf_get_offload *caps);
 
+/**
+ * typedef sme_encrypt_decrypt_callback - encrypt/decrypt callback
+ *    signature
+ * @context: Opaque context that the client can use to associate the
+ *    callback with the request
+ * @response: Encrypt/Decrypt response from firmware
+ */
+struct sir_encrypt_decrypt_rsp_params;
+typedef void (*sme_encrypt_decrypt_callback)(
+			void *context,
+			struct sir_encrypt_decrypt_rsp_params *response);
+
 typedef struct tagSmeStruct {
 	eSmeState state;
 	qdf_mutex_t lkSmeGlobalLock;
@@ -260,8 +272,8 @@ typedef struct tagSmeStruct {
 	p2p_lo_callback p2p_lo_event_callback;
 	void *p2p_lo_event_context;
 	sme_send_oem_data_rsp_msg oem_data_rsp_callback;
-	void (*encrypt_decrypt_cb)(void *,
-			struct sir_encrypt_decrypt_rsp_params *);
+	sme_encrypt_decrypt_callback encrypt_decrypt_cb;
+	void *encrypt_decrypt_context;
 	void (*lost_link_info_cb)(void *context,
 			struct sir_lost_link_info *lost_link_info);
 } tSmeStruct, *tpSmeStruct;

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

@@ -16820,7 +16820,9 @@ QDF_STATUS sme_set_sar_power_limits(tHalHandle hal,
  * Return: QDF_STATUS enumeration.
  */
 QDF_STATUS sme_encrypt_decrypt_msg(tHalHandle hal,
-	struct encrypt_decrypt_req_params *encrypt_decrypt_params)
+	struct encrypt_decrypt_req_params *encrypt_decrypt_params,
+	sme_encrypt_decrypt_callback callback,
+	void *context)
 {
 	QDF_STATUS status = QDF_STATUS_SUCCESS;
 	tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
@@ -16850,6 +16852,8 @@ QDF_STATUS sme_encrypt_decrypt_msg(tHalHandle hal,
 	status = sme_acquire_global_lock(&mac_ctx->sme);
 	if (status == QDF_STATUS_SUCCESS) {
 		/* Serialize the req through MC thread */
+		mac_ctx->sme.encrypt_decrypt_cb = callback;
+		mac_ctx->sme.encrypt_decrypt_context = context;
 		cds_msg.bodyptr = params;
 		cds_msg.type = WMA_ENCRYPT_DECRYPT_MSG;
 		status = scheduler_post_msg(QDF_MODULE_ID_WMA, &cds_msg);
@@ -16869,79 +16873,6 @@ QDF_STATUS sme_encrypt_decrypt_msg(tHalHandle hal,
 	return status;
 
 }
-
-/**
- * sme_encrypt_decrypt_msg_register_callback() - Registers
- * encrypt/decrypt message 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_encrypt_decrypt_msg_register_callback(tHalHandle hal,
-		void (*encrypt_decrypt_cb)(void *hdd_context,
-			struct sir_encrypt_decrypt_rsp_params
-				*encrypt_decrypt_rsp_params))
-{
-	QDF_STATUS status   = QDF_STATUS_SUCCESS;
-	tpAniSirGlobal mac;
-
-	if (!hal) {
-		QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
-				  FL("hHal is not valid"));
-		return QDF_STATUS_E_INVAL;
-	}
-
-	mac = PMAC_STRUCT(hal);
-
-	status = sme_acquire_global_lock(&mac->sme);
-	if (QDF_IS_STATUS_SUCCESS(status)) {
-		mac->sme.encrypt_decrypt_cb = encrypt_decrypt_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_encrypt_decrypt_msg_deregister_callback() - Registers
- * encrypt/decrypt message 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_encrypt_decrypt_msg_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.encrypt_decrypt_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;
-}
 #endif
 
 QDF_STATUS sme_set_cts2self_for_p2p_go(tHalHandle hal_handle)

+ 0 - 3
core/wma/inc/wma.h

@@ -507,9 +507,6 @@ static const t_probeTime_dwellTime
 };
 
 typedef void (*txFailIndCallback)(uint8_t *peer_mac, uint8_t seqNo);
-typedef void (*encrypt_decrypt_cb)(struct sir_encrypt_decrypt_rsp_params
-		*encrypt_decrypt_rsp_params);
-
 
 typedef void (*tp_wma_packetdump_cb)(qdf_nbuf_t netbuf,
 			uint8_t status, uint8_t vdev_id, uint8_t type);

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

@@ -8584,7 +8584,8 @@ int wma_encrypt_decrypt_msg_handler(void *handle, uint8_t *data,
 		encrypt_decrypt_rsp_params.data = buf_ptr;
 	}
 
-	pmac->sme.encrypt_decrypt_cb(pmac->hHdd, &encrypt_decrypt_rsp_params);
+	pmac->sme.encrypt_decrypt_cb(pmac->sme.encrypt_decrypt_context,
+				     &encrypt_decrypt_rsp_params);
 
 	return 0;
 }