qcacld-3.0: Add support for gtk offload PMO component

Add support for gtk offload in PMO component.

Change-Id: Ia5ea2daf873ad481f51e2d1cf24441a8c1d93476
CRs-Fixed: 2005114
diff --git a/core/hdd/inc/wlan_hdd_main.h b/core/hdd/inc/wlan_hdd_main.h
index fd5914e..5b975b1 100644
--- a/core/hdd/inc/wlan_hdd_main.h
+++ b/core/hdd/inc/wlan_hdd_main.h
@@ -237,11 +237,6 @@
 #define HDD_MOD_EXIT_SSR_MAX_RETRIES 75
 #endif
 
-#ifdef WLAN_FEATURE_GTK_OFFLOAD
-#define GTK_OFFLOAD_ENABLE  0
-#define GTK_OFFLOAD_DISABLE 1
-#endif
-
 #define MAX_USER_COMMAND_SIZE 4096
 
 #define HDD_MIN_TX_POWER (-100) /* minimum tx power */
@@ -651,9 +646,6 @@
 
 	int ft_carrier_on;
 
-#ifdef WLAN_FEATURE_GTK_OFFLOAD
-	tSirGtkOffloadParams gtkOffloadReqParams;
-#endif
 	/*Increment whenever ibss New peer joins and departs the network */
 	int ibss_sta_generation;
 
diff --git a/core/hdd/inc/wlan_hdd_power.h b/core/hdd/inc/wlan_hdd_power.h
index 4d62500..a725c2a 100644
--- a/core/hdd/inc/wlan_hdd_power.h
+++ b/core/hdd/inc/wlan_hdd_power.h
@@ -229,6 +229,19 @@
 void hdd_disable_and_flush_mc_addr_list(hdd_adapter_t *adapter,
 	enum pmo_offload_trigger trigger);
 
+/**
+ * wlan_hdd_cfg80211_update_replay_counter_callback() - replay counter callback
+ * @cb_ctx: Callback context as void* as PMO do not about HDD adapter type
+ * @gtk_rsp_param: Pointer to gtk offload response parameter
+ *
+ * Callback routine called upon receiving of gtk offload rsp from fwr
+ *
+ * Return: none
+ */
+void wlan_hdd_cfg80211_update_replay_counter_callback(
+	void *cb_ctx,
+	struct pmo_gtk_rsp_params *gtk_rsp_param);
+
 int wlan_hdd_cfg80211_suspend_wlan(struct wiphy *wiphy,
 				   struct cfg80211_wowlan *wow);
 
diff --git a/core/hdd/src/wlan_hdd_assoc.c b/core/hdd/src/wlan_hdd_assoc.c
index d9ad767..41d903e 100644
--- a/core/hdd/src/wlan_hdd_assoc.c
+++ b/core/hdd/src/wlan_hdd_assoc.c
@@ -62,6 +62,7 @@
 #include <wlan_logging_sock_svc.h>
 #include <wlan_hdd_object_manager.h>
 #include <cdp_txrx_handle.h>
+#include "wlan_pmo_ucfg_api.h"
 
 /* These are needed to recognize WPA and RSN suite types */
 #define HDD_WPA_OUI_SIZE 4
@@ -1695,14 +1696,7 @@
 	/* Clear saved connection information in HDD */
 	hdd_conn_remove_connect_info(pHddStaCtx);
 	hdd_conn_set_connection_state(pAdapter, eConnectionState_NotConnected);
-#ifdef WLAN_FEATURE_GTK_OFFLOAD
-	if ((QDF_STA_MODE == pAdapter->device_mode) ||
-	    (QDF_P2P_CLIENT_MODE == pAdapter->device_mode)) {
-		memset(&pHddStaCtx->gtkOffloadReqParams, 0,
-		       sizeof(tSirGtkOffloadParams));
-		pHddStaCtx->gtkOffloadReqParams.ulFlags = GTK_OFFLOAD_DISABLE;
-	}
-#endif
+	pmo_ucfg_flush_gtk_offload_req(pAdapter->hdd_vdev);
 
 #ifdef FEATURE_WLAN_TDLS
 	if (eCSR_ROAM_IBSS_LEAVE != roamStatus)
diff --git a/core/hdd/src/wlan_hdd_cfg80211.c b/core/hdd/src/wlan_hdd_cfg80211.c
index bfc4c15..044a424 100644
--- a/core/hdd/src/wlan_hdd_cfg80211.c
+++ b/core/hdd/src/wlan_hdd_cfg80211.c
@@ -104,7 +104,7 @@
 #include <cdp_txrx_cmn.h>
 #include <cdp_txrx_misc.h>
 #include <qca_vendor.h>
-
+#include "wlan_pmo_ucfg_api.h"
 
 #define g_mode_rates_size (12)
 #define a_mode_rates_size (8)
@@ -12997,16 +12997,7 @@
 			}
 		}
 #endif
-#ifdef WLAN_FEATURE_GTK_OFFLOAD
-		/* Initializing gtkOffloadReqParams */
-		if ((QDF_STA_MODE == pAdapter->device_mode) ||
-		    (QDF_P2P_CLIENT_MODE == pAdapter->device_mode)) {
-			memset(&pHddStaCtx->gtkOffloadReqParams, 0,
-			       sizeof(tSirGtkOffloadParams));
-			pHddStaCtx->gtkOffloadReqParams.ulFlags =
-				GTK_OFFLOAD_DISABLE;
-		}
-#endif
+		pmo_ucfg_flush_gtk_offload_req(pAdapter->hdd_vdev);
 		pRoamProfile->csrPersona = pAdapter->device_mode;
 
 		if (operatingChannel) {
@@ -15671,156 +15662,109 @@
 }
 #endif
 
-#ifdef WLAN_FEATURE_GTK_OFFLOAD
-/**
- * wlan_hdd_cfg80211_update_replay_counter_callback() - replay counter callback
- * @callbackContext: Callback context
- * @pGtkOffloadGetInfoRsp: Pointer to gtk offload response parameter
- *
- * Callback rountine called upon receiving response for get offload info
- *
- * Return: none
- */
-void wlan_hdd_cfg80211_update_replay_counter_callback(void *callbackContext,
-						tpSirGtkOffloadGetInfoRspParams
-						pGtkOffloadGetInfoRsp)
+void wlan_hdd_cfg80211_update_replay_counter_callback(
+		void *cb_ctx, struct pmo_gtk_rsp_params *gtk_rsp_param)
+
 {
-	hdd_adapter_t *pAdapter = (hdd_adapter_t *) callbackContext;
-	uint8_t tempReplayCounter[8];
-	hdd_station_ctx_t *pHddStaCtx;
+	hdd_adapter_t *pAdapter = (hdd_adapter_t *)cb_ctx;
+	uint8_t temp_replay_counter[8];
+	int i;
+	uint8_t *p;
 
 	ENTER();
 
-	if (NULL == pAdapter) {
+	if (!pAdapter) {
 		hdd_err("HDD adapter is Null");
-		return;
+		goto out;
 	}
 
-	if (NULL == pGtkOffloadGetInfoRsp) {
-		hdd_err("pGtkOffloadGetInfoRsp is Null");
-		return;
+	if (!gtk_rsp_param) {
+		hdd_err("gtk_rsp_param is Null");
+		goto out;
 	}
 
-	if (QDF_STATUS_SUCCESS != pGtkOffloadGetInfoRsp->ulStatus) {
+	if (gtk_rsp_param->status_flag != QDF_STATUS_SUCCESS) {
 		hdd_err("wlan Failed to get replay counter value");
-		return;
+		goto out;
 	}
 
-	pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
-	/* Update replay counter */
-	pHddStaCtx->gtkOffloadReqParams.ullKeyReplayCounter =
-		pGtkOffloadGetInfoRsp->ullKeyReplayCounter;
+	hdd_notice("updated replay counter: %llu from fwr",
+		gtk_rsp_param->replay_counter);
+	/* convert little to big endian since supplicant works on big endian */
+	p = (uint8_t *)&gtk_rsp_param->replay_counter;
+	for (i = 0; i < 8; i++)
+		temp_replay_counter[7 - i] = (uint8_t) p[i];
 
-	{
-		/* changing from little to big endian since supplicant
-		 * works on big endian format
-		 */
-		int i;
-		uint8_t *p =
-			(uint8_t *) &pGtkOffloadGetInfoRsp->ullKeyReplayCounter;
-
-		for (i = 0; i < 8; i++) {
-			tempReplayCounter[7 - i] = (uint8_t) p[i];
-		}
-	}
-
+	hdd_notice("gtk_rsp_param bssid %pM", gtk_rsp_param->bssid.bytes);
 	/* Update replay counter to NL */
 	cfg80211_gtk_rekey_notify(pAdapter->dev,
-				  pGtkOffloadGetInfoRsp->bssid.bytes,
-				  tempReplayCounter, GFP_KERNEL);
+					gtk_rsp_param->bssid.bytes,
+					temp_replay_counter, GFP_KERNEL);
+out:
+	EXIT();
+
 }
 
-/**
- * __wlan_hdd_cfg80211_set_rekey_data() - set rekey data
- * @wiphy: Pointer to wiphy
- * @dev: Pointer to network device
- * @data: Pointer to rekey data
- *
- * This function is used to offload GTK rekeying job to the firmware.
- *
- * Return: 0 for success, non-zero for failure
- */
 static
 int __wlan_hdd_cfg80211_set_rekey_data(struct wiphy *wiphy,
-				       struct net_device *dev,
-				       struct cfg80211_gtk_rekey_data *data)
+		struct net_device *dev,
+		struct cfg80211_gtk_rekey_data *data)
 {
 	hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
-	hdd_context_t *pHddCtx = wiphy_priv(wiphy);
-	hdd_station_ctx_t *pHddStaCtx;
-	tHalHandle hHal;
-	int result;
-	tSirGtkOffloadParams hddGtkOffloadReqParams;
+	int result, i;
+	struct pmo_gtk_req *gtk_req = NULL;
+	hdd_context_t *hdd_ctx =  WLAN_HDD_GET_CTX(pAdapter);
+	uint8_t *buf;
 	QDF_STATUS status = QDF_STATUS_E_FAILURE;
 
 	ENTER();
 
 	if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) {
 		hdd_err("Command not allowed in FTM mode");
-		return -EINVAL;
+		result = -EINVAL;
+		goto out;
 	}
 
 	if (wlan_hdd_validate_session_id(pAdapter->sessionId)) {
 		hdd_err("invalid session id: %d", pAdapter->sessionId);
-		return -EINVAL;
+		result = -EINVAL;
+		goto out;
 	}
 
 	MTRACE(qdf_trace(QDF_MODULE_ID_HDD,
 			 TRACE_CODE_HDD_CFG80211_SET_REKEY_DATA,
 			 pAdapter->sessionId, pAdapter->device_mode));
 
-	result = wlan_hdd_validate_context(pHddCtx);
-
+	result = wlan_hdd_validate_context(hdd_ctx);
 	if (0 != result)
-		return result;
+		goto out;
 
-	pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
-	hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
-	if (NULL == hHal) {
-		hdd_err("HAL context is Null!!!");
-		return -EAGAIN;
+	gtk_req = qdf_mem_malloc(sizeof(*gtk_req));
+	if (!gtk_req) {
+		hdd_err("cannot allocate gtk_req");
+		result = -ENOMEM;
+		goto out;
 	}
 
-	pHddStaCtx->gtkOffloadReqParams.ulFlags = GTK_OFFLOAD_ENABLE;
-	memcpy(pHddStaCtx->gtkOffloadReqParams.aKCK, data->kck,
-	       NL80211_KCK_LEN);
-	memcpy(pHddStaCtx->gtkOffloadReqParams.aKEK, data->kek,
-	       NL80211_KEK_LEN);
-	qdf_copy_macaddr(&pHddStaCtx->gtkOffloadReqParams.bssid,
-			 &pHddStaCtx->conn_info.bssId);
-	{
-		/* changing from big to little endian since driver
-		 * works on little endian format
-		 */
-		uint8_t *p =
-			(uint8_t *) &pHddStaCtx->gtkOffloadReqParams.
-			ullKeyReplayCounter;
-		int i;
+	/* convert big to little endian since driver work on little endian */
+	buf = (uint8_t *)&gtk_req->replay_counter;
+	for (i = 0; i < 8; i++)
+		buf[7 - i] = data->replay_ctr[i];
 
-		for (i = 0; i < 8; i++) {
-			p[7 - i] = data->replay_ctr[i];
-		}
+	hdd_notice("current replay counter: %llu in user space",
+		gtk_req->replay_counter);
+	qdf_mem_copy(gtk_req->kek, data->kek, NL80211_KEK_LEN);
+	qdf_mem_copy(gtk_req->kck, data->kck, NL80211_KCK_LEN);
+	status = pmo_ucfg_cache_gtk_offload_req(pAdapter->hdd_vdev, gtk_req);
+	if (status != QDF_STATUS_SUCCESS) {
+		hdd_err("Failed to cache GTK Offload");
+		result = qdf_status_to_os_return(status);
 	}
-
-	if (true == pHddCtx->hdd_wlan_suspended) {
-		/* if wlan is suspended, enable GTK offload directly from here */
-		memcpy(&hddGtkOffloadReqParams,
-		       &pHddStaCtx->gtkOffloadReqParams,
-		       sizeof(tSirGtkOffloadParams));
-		status =
-			sme_set_gtk_offload(hHal, &hddGtkOffloadReqParams,
-					    pAdapter->sessionId);
-
-		if (QDF_STATUS_SUCCESS != status) {
-			hdd_err("sme_set_gtk_offload failed, status(%d)",
-			       status);
-			return -EINVAL;
-		}
-		hdd_notice("sme_set_gtk_offload successful");
-	} else {
-		hdd_notice("wlan not suspended GTKOffload request is stored");
-	}
+out:
+	if (gtk_req)
+		qdf_mem_free(gtk_req);
 	EXIT();
+
 	return result;
 }
 
@@ -15847,7 +15791,6 @@
 
 	return ret;
 }
-#endif /*WLAN_FEATURE_GTK_OFFLOAD */
 
 /**
  * __wlan_hdd_cfg80211_set_mac_acl() - set access control policy
diff --git a/core/hdd/src/wlan_hdd_cfg80211.h b/core/hdd/src/wlan_hdd_cfg80211.h
index 8b87733..ae20a13 100644
--- a/core/hdd/src/wlan_hdd_cfg80211.h
+++ b/core/hdd/src/wlan_hdd_cfg80211.h
@@ -256,12 +256,7 @@
 int wlan_hdd_cfg80211_send_tdls_discover_req(struct wiphy *wiphy,
 					     struct net_device *dev, u8 *peer);
 #endif
-#ifdef WLAN_FEATURE_GTK_OFFLOAD
-extern void wlan_hdd_cfg80211_update_replay_counter_callback(void
-							     *callbackContext,
-							     tpSirGtkOffloadGetInfoRspParams
-							     pGtkOffloadGetInfoRsp);
-#endif
+
 void *wlan_hdd_change_country_code_cb(void *pAdapter);
 void hdd_select_cbmode(hdd_adapter_t *pAdapter, uint8_t operationChannel,
 		       struct ch_params_s *ch_params);
diff --git a/core/hdd/src/wlan_hdd_power.c b/core/hdd/src/wlan_hdd_power.c
index c57bdf7..2b02168 100644
--- a/core/hdd/src/wlan_hdd_power.c
+++ b/core/hdd/src/wlan_hdd_power.c
@@ -80,7 +80,6 @@
 #include <wlan_logging_sock_svc.h>
 #include "scheduler_api.h"
 #include "cds_utils.h"
-#include "wlan_pmo_ucfg_api.h"
 
 /* Preprocessor definitions and constants */
 #define HDD_SSR_BRING_UP_TIME 30000
@@ -134,87 +133,54 @@
 
 static struct timer_list ssr_timer;
 static bool ssr_timer_started;
+
 /**
- * hdd_conf_gtk_offload() - Configure GTK offload
- * @pAdapter:   pointer to the adapter
- * @fenable:    flag set to enable (1) or disable (0) GTK offload
+ * hdd_enable_gtk_offload() - enable GTK offload
+ * @adapter: pointer to the adapter
  *
- * Central function to enable or disable GTK offload.
+ * Central function to enable GTK offload.
  *
  * Return: nothing
  */
-#ifdef WLAN_FEATURE_GTK_OFFLOAD
-static void hdd_conf_gtk_offload(hdd_adapter_t *pAdapter, bool fenable)
+static void hdd_enable_gtk_offload(hdd_adapter_t *adapter)
 {
-	QDF_STATUS ret;
-	tSirGtkOffloadParams hddGtkOffloadReqParams;
-	hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
+	QDF_STATUS status;
+	status = pmo_ucfg_enable_gtk_offload_in_fwr(adapter->hdd_vdev);
+	if (status != QDF_STATUS_SUCCESS)
+		hdd_info("Failed to enable gtk offload");
+}
 
-	if (fenable) {
-		if ((eConnectionState_Associated ==
-		     pHddStaCtx->conn_info.connState)
-		    && (GTK_OFFLOAD_ENABLE ==
-			pHddStaCtx->gtkOffloadReqParams.ulFlags)) {
-			qdf_mem_copy(&hddGtkOffloadReqParams,
-				     &pHddStaCtx->gtkOffloadReqParams,
-				     sizeof(tSirGtkOffloadParams));
+/**
+ * hdd_disable_gtk_offload() - disable GTK offload
+ * @pAdapter:   pointer to the adapter
+ *
+ * Central function to disable GTK offload.
+ *
+ * Return: nothing
+ */
+static void hdd_disable_gtk_offload(hdd_adapter_t *adapter)
+{
+	struct pmo_gtk_rsp_req gtk_rsp_request;
+	QDF_STATUS status;
 
-			ret = sme_set_gtk_offload(WLAN_HDD_GET_HAL_CTX(pAdapter),
-						  &hddGtkOffloadReqParams,
-						  pAdapter->sessionId);
-			if (QDF_STATUS_SUCCESS != ret) {
-				hdd_err("sme_set_gtk_offload failed, returned %d", ret);
-				return;
-			}
-
-			hdd_notice("sme_set_gtk_offload successfull");
-		}
-
-	} else {
-		if ((eConnectionState_Associated ==
-		     pHddStaCtx->conn_info.connState)
-		    && (qdf_is_macaddr_equal(&pHddStaCtx->gtkOffloadReqParams.bssid,
-			       &pHddStaCtx->conn_info.bssId))
-		    && (GTK_OFFLOAD_ENABLE ==
-			pHddStaCtx->gtkOffloadReqParams.ulFlags)) {
-
-			/* Host driver has previously offloaded GTK rekey  */
-			ret = sme_get_gtk_offload
-				(WLAN_HDD_GET_HAL_CTX(pAdapter),
-				 wlan_hdd_cfg80211_update_replay_counter_callback,
-				 pAdapter, pAdapter->sessionId);
-			if (QDF_STATUS_SUCCESS != ret) {
-				hdd_err("sme_get_gtk_offload failed, returned %d", ret);
-				return;
-			}
-
-			hdd_notice("sme_get_gtk_offload successful");
-
-			/* Sending GTK offload dissable */
-			memcpy(&hddGtkOffloadReqParams,
-			       &pHddStaCtx->gtkOffloadReqParams,
-			       sizeof(tSirGtkOffloadParams));
-			hddGtkOffloadReqParams.ulFlags =
-				GTK_OFFLOAD_DISABLE;
-			ret = sme_set_gtk_offload(WLAN_HDD_GET_HAL_CTX
-						  (pAdapter),
-						  &hddGtkOffloadReqParams,
-						  pAdapter->sessionId);
-			if (QDF_STATUS_SUCCESS != ret) {
-				hdd_err("failed to dissable GTK offload, returned %d",
-					ret);
-				return;
-			}
-			hdd_notice("successfully dissabled GTK offload request to HAL");
-		}
+	/* ensure to get gtk rsp first before disable it*/
+	gtk_rsp_request.callback =
+		wlan_hdd_cfg80211_update_replay_counter_callback;
+	/* Passing as void* as PMO does not know legacy HDD adapter type */
+	gtk_rsp_request.callback_context =
+		(void *)adapter;
+	status = pmo_ucfg_get_gtk_rsp(adapter->hdd_vdev,
+			&gtk_rsp_request);
+	if (status != QDF_STATUS_SUCCESS) {
+		hdd_err("Failed to send get gtk rsp status:%d", status);
+		return;
 	}
-	return;
+	hdd_notice("send get_gtk_rsp successful");
+	status = pmo_ucfg_disable_gtk_offload_in_fwr(adapter->hdd_vdev);
+	if (status != QDF_STATUS_SUCCESS)
+		hdd_info("Failed to disable gtk offload");
+
 }
-#else /* WLAN_FEATURE_GTK_OFFLOAD */
-static void hdd_conf_gtk_offload(hdd_adapter_t *pAdapter, bool fenable)
-{
-}
-#endif /*WLAN_FEATURE_GTK_OFFLOAD */
 
 
 /**
@@ -543,7 +509,7 @@
 	}
 
 	hdd_info("enable offloads");
-	hdd_conf_gtk_offload(adapter, true);
+	hdd_enable_gtk_offload(adapter);
 	hdd_enable_arp_offload(adapter, trigger);
 	hdd_enable_ns_offload(adapter, trigger);
 	hdd_enable_mc_addr_filtering(adapter, trigger);
@@ -569,7 +535,7 @@
 	}
 
 	hdd_info("disable offloads");
-	hdd_conf_gtk_offload(adapter, false);
+	hdd_disable_gtk_offload(adapter);
 	hdd_disable_arp_offload(adapter, trigger);
 	hdd_disable_ns_offload(adapter, trigger);
 	hdd_disable_mc_addr_filtering(adapter, trigger);
diff --git a/core/mac/inc/sir_api.h b/core/mac/inc/sir_api.h
index 8643114..f083465 100644
--- a/core/mac/inc/sir_api.h
+++ b/core/mac/inc/sir_api.h
@@ -3228,34 +3228,6 @@
 	uint8_t major;
 } tSirVersionType;
 
-#ifdef WLAN_FEATURE_GTK_OFFLOAD
-/*---------------------------------------------------------------------------
-* WMA_GTK_OFFLOAD_REQ
-*--------------------------------------------------------------------------*/
-typedef struct {
-	uint32_t ulFlags;       /* optional flags */
-	uint8_t aKCK[16];       /* Key confirmation key */
-	uint8_t aKEK[16];       /* key encryption key */
-	uint64_t ullKeyReplayCounter;   /* replay counter */
-	struct qdf_mac_addr bssid;
-} tSirGtkOffloadParams, *tpSirGtkOffloadParams;
-
-/*---------------------------------------------------------------------------
-* WMA_GTK_OFFLOAD_GETINFO_REQ
-*--------------------------------------------------------------------------*/
-typedef struct {
-	uint16_t mesgType;
-	uint16_t mesgLen;
-
-	uint32_t ulStatus;      /* success or failure */
-	uint64_t ullKeyReplayCounter;   /* current replay counter value */
-	uint32_t ulTotalRekeyCount;     /* total rekey attempts */
-	uint32_t ulGTKRekeyCount;       /* successful GTK rekeys */
-	uint32_t ulIGTKRekeyCount;      /* successful iGTK rekeys */
-	struct qdf_mac_addr bssid;
-} tSirGtkOffloadGetInfoRspParams, *tpSirGtkOffloadGetInfoRspParams;
-#endif /* WLAN_FEATURE_GTK_OFFLOAD */
-
 /**
  * struct sir_wifi_start_log - Structure to store the params sent to start/
  * stop logging
diff --git a/core/sme/inc/sme_api.h b/core/sme/inc/sme_api.h
index 8c5baf9..498de6f 100644
--- a/core/sme/inc/sme_api.h
+++ b/core/sme/inc/sme_api.h
@@ -561,14 +561,6 @@
 QDF_STATUS sme_set_freq_band(tHalHandle hHal, uint8_t sessionId,
 		eCsrBand eBand);
 QDF_STATUS sme_get_freq_band(tHalHandle hHal, eCsrBand *pBand);
-#ifdef WLAN_FEATURE_GTK_OFFLOAD
-QDF_STATUS sme_set_gtk_offload(tHalHandle hal_ctx,
-		tpSirGtkOffloadParams request,
-		uint8_t session_id);
-QDF_STATUS sme_get_gtk_offload(tHalHandle hal_ctx,
-		gtk_offload_get_info_callback callback_routine,
-		void *callback_context, uint8_t session_id);
-#endif /* WLAN_FEATURE_GTK_OFFLOAD */
 uint16_t sme_chn_to_freq(uint8_t chanNum);
 bool sme_is_channel_valid(tHalHandle hHal, uint8_t channel);
 QDF_STATUS sme_set_max_tx_power(tHalHandle hHal, struct qdf_mac_addr pBssid,
diff --git a/core/sme/inc/sme_internal.h b/core/sme/inc/sme_internal.h
index 25971fa..8a2f04b 100644
--- a/core/sme/inc/sme_internal.h
+++ b/core/sme/inc/sme_internal.h
@@ -135,12 +135,6 @@
 	uint8_t cmdStatsIndx;
 } tSelfRecoveryStats;
 
-#ifdef WLAN_FEATURE_GTK_OFFLOAD
-/* GTK Offload Information Callback declaration */
-typedef void (*gtk_offload_get_info_callback)(void *callback_context,
-		tpSirGtkOffloadGetInfoRspParams
-		pGtkOffloadGetInfoRsp);
-#endif
 #ifdef FEATURE_WLAN_SCAN_PNO
 /*Pref netw found Cb declaration*/
 typedef void (*preferred_network_found_ind_cb)(void *callback_context,
@@ -229,12 +223,6 @@
 	void (*pGetTemperatureCb)(int temperature, void *context);
 	uint8_t miracast_value;
 	struct ps_global_info  ps_global_info;
-#ifdef WLAN_FEATURE_GTK_OFFLOAD
-	/* routine to call for GTK Offload Information */
-	gtk_offload_get_info_callback gtk_offload_get_info_cb;
-	/* value to be passed as parameter to routine specified above */
-	void *gtk_offload_get_info_cb_context;
-#endif /* WLAN_FEATURE_GTK_OFFLOAD */
 #ifdef FEATURE_WLAN_SCAN_PNO
 	/* routine to call for Preferred Network Found Indication */
 	preferred_network_found_ind_cb pref_netw_found_cb;
diff --git a/core/sme/src/common/sme_api.c b/core/sme/src/common/sme_api.c
index dd76eb3..0249448 100644
--- a/core/sme/src/common/sme_api.c
+++ b/core/sme/src/common/sme_api.c
@@ -1150,29 +1150,6 @@
 	return 0;
 }
 
-#ifdef WLAN_FEATURE_GTK_OFFLOAD
-static void sme_process_get_gtk_info_rsp(tHalHandle hHal,
-				  tpSirGtkOffloadGetInfoRspParams
-				  pGtkOffloadGetInfoRsp)
-{
-	tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
-
-	if (NULL == pMac) {
-		QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_FATAL,
-			  "%s: pMac is null", __func__);
-		return;
-	}
-	if (pMac->sme.gtk_offload_get_info_cb == NULL) {
-		QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
-			  "%s: HDD callback is null", __func__);
-		return;
-	}
-	pMac->sme.gtk_offload_get_info_cb(
-			pMac->sme.gtk_offload_get_info_cb_context,
-			pGtkOffloadGetInfoRsp);
-}
-#endif
-
 /*--------------------------------------------------------------------------
 
    \fn    - sme_process_ready_to_suspend
@@ -2357,19 +2334,6 @@
 							pMsg->bodyptr);
 		qdf_mem_free(pMsg->bodyptr);
 		break;
-#ifdef WLAN_FEATURE_GTK_OFFLOAD
-	case eWNI_PMC_GTK_OFFLOAD_GETINFO_RSP:
-		MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_RX_WMA_MSG,
-				 NO_SESSION, pMsg->type));
-		if (pMsg->bodyptr) {
-			sme_process_get_gtk_info_rsp(pMac, pMsg->bodyptr);
-			qdf_mem_free(pMsg->bodyptr);
-		} else {
-			sms_log(pMac, LOGE, FL("Empty message for %d"),
-				pMsg->type);
-		}
-		break;
-#endif
 #ifdef FEATURE_WLAN_LPHB
 	/* LPHB timeout indication arrived, send IND to client */
 	case eWNI_SME_LPHB_IND:
@@ -5974,131 +5938,6 @@
 	return status;
 }
 
-#ifdef WLAN_FEATURE_GTK_OFFLOAD
-/**
- * sme_set_gtk_offload(): API to set GTK offload information.
- * @hHal: The handle returned by mac_open.
- * @sessionId: Session Identifier
- * @pGtkOffload: Pointer to the GTK offload request..
- *
- * Return QDF_STATUS
- */
-QDF_STATUS sme_set_gtk_offload(tHalHandle hHal,
-		tpSirGtkOffloadParams pGtkOffload,
-			       uint8_t sessionId)
-{
-	tpSirGtkOffloadParams request_buf;
-	struct scheduler_msg msg;
-	tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
-	tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
-
-	QDF_TRACE(QDF_MODULE_ID_HDD, QDF_TRACE_LEVEL_INFO,
-		  "%s: KeyReplayCounter: %lld", __func__,
-		  pGtkOffload->ullKeyReplayCounter);
-
-	if (NULL == pSession) {
-		QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
-			  "%s: Session not found ", __func__);
-		return QDF_STATUS_E_FAILURE;
-	}
-
-	request_buf = qdf_mem_malloc(sizeof(*request_buf));
-	if (NULL == request_buf) {
-		QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
-		  FL("Not able to allocate memory for GTK offload request"));
-		return QDF_STATUS_E_NOMEM;
-	}
-
-	qdf_copy_macaddr(&pGtkOffload->bssid,
-			 &pSession->connectedProfile.bssid);
-
-	*request_buf = *pGtkOffload;
-
-	msg.type = WMA_GTK_OFFLOAD_REQ;
-	msg.reserved = 0;
-	msg.bodyptr = request_buf;
-	MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
-			 sessionId, msg.type));
-	if (!QDF_IS_STATUS_SUCCESS
-		    (scheduler_post_msg(QDF_MODULE_ID_WMA, &msg))) {
-		QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
-			FL("Not able to post SIR_HAL_SET_GTK_OFFLOAD message to HAL"));
-		qdf_mem_free(request_buf);
-		return QDF_STATUS_E_FAILURE;
-	}
-
-	return QDF_STATUS_SUCCESS;
-}
-
-/**
- * sme_get_gtk_offload(): API to get GTK offload information
- * @hHal: The handle returned by mac_open.
- * @callback_routine: callback_routine.
- * @sessionId: Session Identifier.
- * callback_context: callback_context.
- *
- * Return QDF_STATUS
- */
-QDF_STATUS sme_get_gtk_offload(tHalHandle hHal,
-			       gtk_offload_get_info_callback callback_routine,
-			       void *callback_context, uint8_t session_id)
-{
-	tpSirGtkOffloadGetInfoRspParams request_buf;
-	struct scheduler_msg msg;
-	tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
-	tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, session_id);
-
-	QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_INFO, "%s: Entered",
-		  __func__);
-
-	if (NULL == pSession) {
-		QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
-			  "%s: Session not found", __func__);
-		return QDF_STATUS_E_FAILURE;
-	}
-
-	request_buf = qdf_mem_malloc(sizeof(*request_buf));
-	if (NULL == request_buf) {
-		QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
-			 FL("Not able to allocate memory for Get GTK offload request"));
-		return QDF_STATUS_E_NOMEM;
-	}
-
-	qdf_copy_macaddr(&request_buf->bssid,
-			 &pSession->connectedProfile.bssid);
-
-	msg.type = WMA_GTK_OFFLOAD_GETINFO_REQ;
-	msg.reserved = 0;
-	msg.bodyptr = request_buf;
-
-	/* Cache the Get GTK Offload callback information */
-	if (NULL != pMac->sme.gtk_offload_get_info_cb) {
-
-		/* Do we need to check if the callback is in use? */
-		/* Because we are not sending the same message again
-		 * when it is pending,
-		 * the only case when the callback is not NULL is that
-		 * the previous message was timed out or failed.
-		 * So, it will be safe to set the callback in this case.
-		 */
-	}
-
-	pMac->sme.gtk_offload_get_info_cb = callback_routine;
-	pMac->sme.gtk_offload_get_info_cb_context = callback_context;
-	MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
-			 session_id, msg.type));
-	if (!QDF_IS_STATUS_SUCCESS
-		    (scheduler_post_msg(QDF_MODULE_ID_WMA, &msg))) {
-		QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
-			  FL("Not able to post WMA_GTK_OFFLOAD_GETINFO_REQ message to WMA"));
-		qdf_mem_free(request_buf);
-		return QDF_STATUS_E_FAILURE;
-	}
-
-	return QDF_STATUS_SUCCESS;
-}
-#endif /* WLAN_FEATURE_GTK_OFFLOAD */
-
 /* ---------------------------------------------------------------------------
     \fn sme_set_keep_alive
     \brief  API to set the Keep Alive feature.
diff --git a/core/wma/inc/wma_internal.h b/core/wma/inc/wma_internal.h
index 96f32cc..76d0052 100644
--- a/core/wma/inc/wma_internal.h
+++ b/core/wma/inc/wma_internal.h
@@ -945,10 +945,6 @@
 
 int wma_csa_offload_handler(void *handle, uint8_t *event, uint32_t len);
 
-#ifdef WLAN_FEATURE_GTK_OFFLOAD
-int wma_gtk_offload_status_event(void *handle, uint8_t *event, uint32_t len);
-#endif
-
 #ifdef FEATURE_OEM_DATA_SUPPORT
 int wma_oem_data_response_handler(void *handle, uint8_t *datap,
 				  uint32_t len);
@@ -1022,15 +1018,6 @@
 
 QDF_STATUS wma_process_mcbc_set_filter_req(tp_wma_handle wma_handle,
 					   tSirRcvFltMcAddrList * mcbc_param);
-#ifdef WLAN_FEATURE_GTK_OFFLOAD
-QDF_STATUS wma_process_gtk_offload_req(tp_wma_handle wma,
-					      tpSirGtkOffloadParams params);
-
-QDF_STATUS wma_process_gtk_offload_getinfo_req(tp_wma_handle wma,
-					       tpSirGtkOffloadGetInfoRspParams
-					       params);
-#endif
-
 QDF_STATUS wma_process_cesium_enable_ind(tp_wma_handle wma);
 
 QDF_STATUS wma_process_get_peer_info_req
diff --git a/core/wma/src/wma_features.c b/core/wma/src/wma_features.c
index de37e84..cbc061d 100644
--- a/core/wma/src/wma_features.c
+++ b/core/wma/src/wma_features.c
@@ -4464,239 +4464,6 @@
 	return QDF_STATUS_SUCCESS;
 }
 
-#ifdef WLAN_FEATURE_GTK_OFFLOAD
-#define GTK_OFFLOAD_ENABLE      0
-#define GTK_OFFLOAD_DISABLE     1
-
-/**
- * wma_gtk_offload_status_event() - GTK offload status event handler
- * @handle: wma handle
- * @event: event buffer
- * @len: buffer length
- *
- * Return: 0 for success or error code
- */
-int wma_gtk_offload_status_event(void *handle, uint8_t *event,
-				 uint32_t len)
-{
-	tp_wma_handle wma = (tp_wma_handle) handle;
-	WMI_GTK_OFFLOAD_STATUS_EVENT_fixed_param *status;
-	WMI_GTK_OFFLOAD_STATUS_EVENTID_param_tlvs *param_buf;
-	tpSirGtkOffloadGetInfoRspParams resp;
-	struct scheduler_msg message;
-	uint8_t *bssid;
-
-	WMA_LOGD("%s Enter", __func__);
-
-	param_buf = (WMI_GTK_OFFLOAD_STATUS_EVENTID_param_tlvs *) event;
-	if (!param_buf) {
-		WMA_LOGE("param_buf is NULL");
-		return -EINVAL;
-	}
-
-	status = (WMI_GTK_OFFLOAD_STATUS_EVENT_fixed_param *) param_buf->fixed_param;
-
-	if (len < sizeof(WMI_GTK_OFFLOAD_STATUS_EVENT_fixed_param)) {
-		WMA_LOGE("Invalid length for GTK status");
-		return -EINVAL;
-	}
-	bssid = wma_find_bssid_by_vdev_id(wma, status->vdev_id);
-	if (!bssid) {
-		WMA_LOGE("invalid bssid for vdev id %d", status->vdev_id);
-		return -ENOENT;
-	}
-
-	resp = qdf_mem_malloc(sizeof(*resp));
-	if (!resp) {
-		WMA_LOGE("%s: Failed to alloc response", __func__);
-		return -ENOMEM;
-	}
-	qdf_mem_zero(resp, sizeof(*resp));
-	resp->mesgType = eWNI_PMC_GTK_OFFLOAD_GETINFO_RSP;
-	resp->mesgLen = sizeof(*resp);
-	resp->ulStatus = QDF_STATUS_SUCCESS;
-	resp->ulTotalRekeyCount = status->refresh_cnt;
-	/* TODO: Is the total rekey count and GTK rekey count same? */
-	resp->ulGTKRekeyCount = status->refresh_cnt;
-
-	qdf_mem_copy(&resp->ullKeyReplayCounter, &status->replay_counter,
-		     GTK_REPLAY_COUNTER_BYTES);
-
-	qdf_mem_copy(resp->bssid.bytes, bssid, IEEE80211_ADDR_LEN);
-
-#ifdef IGTK_OFFLOAD
-	/* TODO: Is the refresh count same for GTK and IGTK? */
-	resp->ulIGTKRekeyCount = status->refresh_cnt;
-#endif /* IGTK_OFFLOAD */
-
-	message.type = eWNI_PMC_GTK_OFFLOAD_GETINFO_RSP;
-	message.bodyptr = (void *)resp;
-	message.bodyval = 0;
-
-	if (scheduler_post_msg(QDF_MODULE_ID_SME, &message)
-	    != QDF_STATUS_SUCCESS) {
-		WMA_LOGE("Failed to post GTK response to SME");
-		qdf_mem_free(resp);
-		return -EINVAL;
-	}
-
-	WMA_LOGD("GTK: got target status with replay counter "
-		 "%02x%02x%02x%02x%02x%02x%02x%02x. vdev %d "
-		 "Refresh GTK %d times exchanges since last set operation",
-		 status->replay_counter[0],
-		 status->replay_counter[1],
-		 status->replay_counter[2],
-		 status->replay_counter[3],
-		 status->replay_counter[4],
-		 status->replay_counter[5],
-		 status->replay_counter[6],
-		 status->replay_counter[7],
-		 status->vdev_id, status->refresh_cnt);
-
-	WMA_LOGD("%s Exit", __func__);
-
-	return 0;
-}
-
-/**
- * wma_send_gtk_offload_req() - send GTK offload command to fw
- * @wma: wma handle
- * @vdev_id: vdev id
- * @params: GTK offload parameters
- *
- * Return: QDF status
- */
-static QDF_STATUS wma_send_gtk_offload_req(tp_wma_handle wma, uint8_t vdev_id,
-					   tpSirGtkOffloadParams params)
-{
-	struct gtk_offload_params offload_params = {0};
-	QDF_STATUS status = QDF_STATUS_SUCCESS;
-	bool enable_offload;
-	uint32_t gtk_offload_opcode;
-
-	WMA_LOGD("%s Enter", __func__);
-
-	/* Request target to enable GTK offload */
-	if (params->ulFlags == GTK_OFFLOAD_ENABLE) {
-		gtk_offload_opcode = GTK_OFFLOAD_ENABLE_OPCODE;
-		wma->wow.gtk_err_enable[vdev_id] = true;
-
-		/* Copy the keys and replay counter */
-		qdf_mem_copy(offload_params.aKCK, params->aKCK,
-			GTK_OFFLOAD_KCK_BYTES);
-		qdf_mem_copy(offload_params.aKEK, params->aKEK,
-			GTK_OFFLOAD_KEK_BYTES);
-		qdf_mem_copy(&offload_params.ullKeyReplayCounter,
-			&params->ullKeyReplayCounter, GTK_REPLAY_COUNTER_BYTES);
-	} else {
-		wma->wow.gtk_err_enable[vdev_id] = false;
-		gtk_offload_opcode = GTK_OFFLOAD_DISABLE_OPCODE;
-	}
-
-	enable_offload = params->ulFlags;
-
-	/* send the wmi command */
-	status = wmi_unified_send_gtk_offload_cmd(wma->wmi_handle,
-					vdev_id, &offload_params,
-					enable_offload,
-					gtk_offload_opcode);
-	if (QDF_IS_STATUS_ERROR(status))
-		goto out;
-
-	WMA_LOGD("VDEVID: %d, GTK_FLAGS: x%x", vdev_id, gtk_offload_opcode);
-out:
-	WMA_LOGD("%s Exit", __func__);
-	return status;
-}
-
-/**
- * wma_process_gtk_offload_req() - process GTK offload req from umac
- * @handle: wma handle
- * @params: GTK offload params
- *
- * Return: QDF status
- */
-QDF_STATUS wma_process_gtk_offload_req(tp_wma_handle wma,
-				       tpSirGtkOffloadParams params)
-{
-	uint8_t vdev_id;
-	QDF_STATUS status = QDF_STATUS_SUCCESS;
-
-	WMA_LOGD("%s Enter", __func__);
-
-	/* Get the vdev id */
-	if (!wma_find_vdev_by_bssid(wma, params->bssid.bytes, &vdev_id)) {
-		WMA_LOGE("vdev handle is invalid for %pM", params->bssid.bytes);
-		status = QDF_STATUS_E_INVAL;
-		goto out;
-	}
-
-	/* Validate vdev id */
-	if (vdev_id >= WMA_MAX_SUPPORTED_BSS) {
-		WMA_LOGE("invalid vdev_id %d for %pM", vdev_id,
-			 params->bssid.bytes);
-		status = QDF_STATUS_E_INVAL;
-		goto out;
-	}
-
-	if ((params->ulFlags == GTK_OFFLOAD_ENABLE) &&
-	    (wma->wow.gtk_err_enable[vdev_id] == true)) {
-		WMA_LOGE("%s GTK Offload already enabled. Disable it first "
-			 "vdev_id %d", __func__, vdev_id);
-		params->ulFlags = GTK_OFFLOAD_DISABLE;
-		status = wma_send_gtk_offload_req(wma, vdev_id, params);
-		if (status != QDF_STATUS_SUCCESS) {
-			WMA_LOGE("%s Failed to disable GTK Offload", __func__);
-			goto out;
-		}
-		WMA_LOGD("%s Enable GTK Offload again with updated inputs",
-			 __func__);
-		params->ulFlags = GTK_OFFLOAD_ENABLE;
-	}
-	status = wma_send_gtk_offload_req(wma, vdev_id, params);
-out:
-	qdf_mem_free(params);
-	WMA_LOGD("%s Exit", __func__);
-	return status;
-}
-
-/**
- * wma_process_gtk_offload_getinfo_req() - send GTK offload cmd to fw
- * @wma: wma handle
- * @params: GTK offload params
- *
- * Return: QDF status
- */
-QDF_STATUS wma_process_gtk_offload_getinfo_req(tp_wma_handle wma,
-				tpSirGtkOffloadGetInfoRspParams params)
-{
-	uint8_t vdev_id;
-	uint64_t offload_req_opcode;
-	QDF_STATUS status = QDF_STATUS_SUCCESS;
-
-	WMA_LOGD("%s Enter", __func__);
-
-	/* Get the vdev id */
-	if (!wma_find_vdev_by_bssid(wma, params->bssid.bytes, &vdev_id)) {
-		WMA_LOGE("vdev handle is invalid for %pM", params->bssid.bytes);
-		status = QDF_STATUS_E_INVAL;
-		goto out;
-	}
-
-	/* Request for GTK offload status */
-	offload_req_opcode = GTK_OFFLOAD_REQUEST_STATUS_OPCODE;
-
-	/* send the wmi command */
-	status = wmi_unified_process_gtk_offload_getinfo_cmd(wma->wmi_handle,
-				 vdev_id, offload_req_opcode);
-
-out:
-	qdf_mem_free(params);
-	WMA_LOGD("%s Exit", __func__);
-	return status;
-}
-#endif /* WLAN_FEATURE_GTK_OFFLOAD */
-
 /**
  * wma_process_cesium_enable_ind() - enables cesium functionality in target
  * @wma: wma handle
diff --git a/core/wma/src/wma_main.c b/core/wma/src/wma_main.c
index e386dbd..6e041d6 100644
--- a/core/wma/src/wma_main.c
+++ b/core/wma/src/wma_main.c
@@ -84,6 +84,7 @@
 #include "wlan_lmac_if_api.h"
 #include "target_if.h"
 #include "wlan_global_lmac_if_api.h"
+#include "target_if_pmo.h"
 
 #include <cdp_txrx_handle.h>
 #define WMA_LOG_COMPLETION_TIMER 10000 /* 10 seconds */
@@ -4684,9 +4685,9 @@
 				   WMI_SERVICE_GTK_OFFLOAD)) {
 		status =
 			wmi_unified_register_event_handler(wma_handle->wmi_handle,
-						WMI_GTK_OFFLOAD_STATUS_EVENTID,
-						wma_gtk_offload_status_event,
-						WMA_RX_SERIALIZER_CTX);
+					WMI_GTK_OFFLOAD_STATUS_EVENTID,
+					target_if_pmo_gtk_offload_status_event,
+					WMA_RX_WORK_CTX);
 		if (status) {
 			WMA_LOGE("Failed to register GTK offload event cb");
 			return -EINVAL;
@@ -6562,17 +6563,6 @@
 				(tpSirRcvFltMcAddrList) msg->bodyptr);
 		qdf_mem_free(msg->bodyptr);
 		break;
-#ifdef WLAN_FEATURE_GTK_OFFLOAD
-	case WMA_GTK_OFFLOAD_REQ:
-		wma_process_gtk_offload_req(wma_handle,
-				(tpSirGtkOffloadParams) msg->bodyptr);
-		break;
-
-	case WMA_GTK_OFFLOAD_GETINFO_REQ:
-		wma_process_gtk_offload_getinfo_req(wma_handle,
-				(tpSirGtkOffloadGetInfoRspParams)msg->bodyptr);
-		break;
-#endif /* WLAN_FEATURE_GTK_OFFLOAD */
 	case WMA_ROAM_SCAN_OFFLOAD_REQ:
 		/*
 		 * Main entry point or roaming directives from CSR.