Browse Source

qcacld-3.0: Send ENABLE_TWT command to the target

Send the WMI_TWT_ENABLE_CMDID command to the target if the target
supports any one mode out of requestor, responder or broadcast mode.

Change-Id: I7ab21fff89e7c88bf951b333d7a923857f2123d6
CRs-Fixed: 2238302
Varun Reddy Yeturu 7 years ago
parent
commit
1b4cbb5065

+ 12 - 0
core/hdd/inc/wlan_hdd_twt.h

@@ -48,6 +48,14 @@ void hdd_twt_print_ini_config(struct hdd_context *hdd_ctx);
 void hdd_update_tgt_twt_cap(struct hdd_context *hdd_ctx,
 			    struct wma_tgt_cfg *cfg);
 
+/**
+ * hdd_send_twt_enable_cmd() - Send TWT enable command to target
+ * @hdd_ctx: HDD Context
+ *
+ * Return: None
+ */
+void hdd_send_twt_enable_cmd(struct hdd_context *hdd_ctx);
+
 #else
 static inline void hdd_twt_print_ini_config(struct hdd_context *hdd_ctx)
 {
@@ -58,5 +66,9 @@ static inline void hdd_update_tgt_twt_cap(struct hdd_context *hdd_ctx,
 {
 }
 
+static inline void hdd_send_twt_enable_cmd(struct hdd_context *hdd_ctx)
+{
+}
+
 #endif
 #endif /* if !defined(WLAN_HDD_TWT_H)*/

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

@@ -2007,6 +2007,7 @@ void hdd_update_tgt_cfg(hdd_handle_t hdd_handle, struct wma_tgt_cfg *cfg)
 		hdd_update_tgt_he_cap(hdd_ctx, cfg);
 	}
 	hdd_update_tgt_twt_cap(hdd_ctx, cfg);
+	hdd_send_twt_enable_cmd(hdd_ctx);
 
 	hdd_update_vdev_nss(hdd_ctx);
 

+ 19 - 0
core/hdd/src/wlan_hdd_twt.c

@@ -27,6 +27,8 @@
 #include "wlan_hdd_main.h"
 #include "wlan_hdd_cfg.h"
 #include "cfg_api.h"
+#include "sme_api.h"
+#include "wma_twt.h"
 
 void hdd_twt_print_ini_config(struct hdd_context *hdd_ctx)
 {
@@ -60,3 +62,20 @@ void hdd_update_tgt_twt_cap(struct hdd_context *hdd_ctx,
 			QDF_MIN(0, hdd_ctx->config->enable_twt));
 }
 
+void hdd_send_twt_enable_cmd(struct hdd_context *hdd_ctx)
+{
+	uint8_t pdev_id = hdd_ctx->hdd_pdev->pdev_objmgr.wlan_pdev_id;
+	uint32_t req_val, resp_val, bcast_val;
+	uint32_t congestion_timeout = hdd_ctx->config->twt_congestion_timeout;
+
+	sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_TWT_REQUESTOR, &req_val);
+	sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_TWT_RESPONDER, &resp_val);
+	sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_BCAST_TWT, &bcast_val);
+
+	hdd_debug("TWT cfg req:%d, responder:%d, bcast:%d, pdev:%d, cong:%d",
+		  req_val, resp_val, bcast_val, pdev_id, congestion_timeout);
+
+	if (req_val || resp_val || bcast_val)
+		wma_send_twt_enable_cmd(pdev_id, congestion_timeout);
+}
+

+ 41 - 0
core/wma/inc/wma_twt.h

@@ -0,0 +1,41 @@
+/*
+ * Copyright (c) 2018 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
+ * above copyright notice and this permission notice appear in all
+ * copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
+ * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
+ * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
+ * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifndef __WMA_TWT_H
+#define __WMA_TWT_H
+
+#include "wma.h"
+
+#ifdef WLAN_FEATURE_TWT
+/**
+ * wma_send_twt_enable_cmd() - Send TWT Enable command to firmware
+ * @pdev_id: pdev id
+ * @congestion_timeout: Timeout value for the TWT congestion timer
+ *
+ * Return: None
+ */
+void wma_send_twt_enable_cmd(uint32_t pdev_id, uint32_t congestion_timeout);
+#else
+static inline void wma_send_twt_enable_cmd(uint32_t pdev_id,
+					   uint32_t congestion_timeout)
+{
+	WMA_LOGD(FL("TWT not supported as WLAN_FEATURE_TWT is disabled"));
+}
+#endif
+
+#endif /* __WMA_HE_H */

+ 41 - 0
core/wma/src/wma_twt.c

@@ -0,0 +1,41 @@
+/*
+ * Copyright (c) 2018 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
+ * above copyright notice and this permission notice appear in all
+ * copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
+ * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
+ * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
+ * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+/**
+ * DOC: wma_twt.c
+ *
+ * WLAN Host Device Driver TWT - Target Wake Time Implementation
+ */
+
+#include "wma_twt.h"
+#include "wmi_unified_twt_api.h"
+
+void wma_send_twt_enable_cmd(uint32_t pdev_id, uint32_t congestion_timeout)
+{
+	t_wma_handle *wma = cds_get_context(QDF_MODULE_ID_WMA);
+	struct wmi_twt_enable_param twt_enable_params = {0};
+	int32_t ret;
+
+	twt_enable_params.pdev_id = pdev_id;
+	twt_enable_params.sta_cong_timer_ms = congestion_timeout;
+	ret = wmi_unified_twt_enable_cmd(wma->wmi_handle, &twt_enable_params);
+
+	if (ret)
+		WMA_LOGE("Failed to enable TWT");
+}
+