Browse Source

qcacld-3.0: Check the TWT responder capability before enable

TWT responder should be enabled based on the hostapd
configuration and self capability.
But when SAP is started, the TWT concurrency work is
scheduled and its enabling the TWT responder without
checking the hostapd configuration. This causes TWT
responder to be enabled even though the hostapd configuration
disables the responder.

Check the TWT responder configuration from TWT component before
sending enable command for TWT responder

Change-Id: Ia6755299421f00b2a1a69fc2e19fac3d39ab95f6
CRs-Fixed: 3291939
Pragaspathi Thilagaraj 2 years ago
parent
commit
177ccb0f9e

+ 25 - 0
components/umac/twt/core/src/wlan_twt_cfg.c

@@ -159,6 +159,31 @@ wlan_twt_cfg_get_responder(struct wlan_objmgr_psoc *psoc, bool *val)
 	return QDF_STATUS_SUCCESS;
 }
 
+QDF_STATUS
+wlan_twt_cfg_set_responder(struct wlan_objmgr_psoc *psoc, bool val)
+{
+	struct twt_psoc_priv_obj *twt_psoc_obj;
+
+	twt_psoc_obj = wlan_twt_psoc_get_comp_private_obj(psoc);
+	if (!twt_psoc_obj)
+		return QDF_STATUS_E_INVAL;
+
+	twt_psoc_obj->cfg_params.twt_responder = val;
+
+	return QDF_STATUS_SUCCESS;
+}
+
+bool wlan_twt_cfg_is_twt_enabled(struct wlan_objmgr_psoc *psoc)
+{
+	struct twt_psoc_priv_obj *twt_psoc_obj;
+
+	twt_psoc_obj = wlan_twt_psoc_get_comp_private_obj(psoc);
+	if (!twt_psoc_obj)
+		return false;
+
+	return twt_psoc_obj->cfg_params.enable_twt;
+}
+
 QDF_STATUS
 wlan_twt_cfg_get_congestion_timeout(struct wlan_objmgr_psoc *psoc,
 				    uint32_t *val)

+ 8 - 0
components/umac/twt/core/src/wlan_twt_cfg.h

@@ -79,6 +79,14 @@ wlan_twt_cfg_get_responder(struct wlan_objmgr_psoc *psoc, bool *val);
 QDF_STATUS
 wlan_twt_cfg_set_responder(struct wlan_objmgr_psoc *psoc, bool val);
 
+/**
+ * wlan_twt_cfg_is_twt_enabled() - API to check if TWT is enabled
+ * @psoc: Pointer to PSOC object
+ *
+ * Return: True if TWT is enabled else false
+ */
+bool wlan_twt_cfg_is_twt_enabled(struct wlan_objmgr_psoc *psoc);
+
 /**
  * wlan_twt_cfg_get_congestion_timeout() - get congestion timeout
  * @psoc: Pointer to global psoc

+ 32 - 0
components/umac/twt/dispatcher/inc/wlan_twt_cfg_ext_api.h

@@ -66,6 +66,26 @@ QDF_STATUS
 wlan_twt_cfg_get_support_requestor(struct wlan_objmgr_psoc *psoc,
 				   bool *val);
 
+/**
+ * wlan_twt_get_requestor_cfg() - Get requestor TWT configuration
+ * @psoc: Pointer to psoc object
+ * @val: Pointer to value
+ *
+ * Return: QDF_STATUS
+ */
+QDF_STATUS
+wlan_twt_get_requestor_cfg(struct wlan_objmgr_psoc *psoc, bool *val);
+
+/**
+ * wlan_twt_get_responder_cfg() - Get TWT responder configuration
+ * @psoc: Pointer to PSOC object
+ * @val: Pointer to value
+ *
+ * Return: QDF_STATUS
+ */
+QDF_STATUS
+wlan_twt_get_responder_cfg(struct wlan_objmgr_psoc *psoc, bool *val);
+
 #ifdef FEATURE_SET
 /**
  * wlan_twt_get_feature_info() - Get TWT feature set information
@@ -104,5 +124,17 @@ wlan_twt_cfg_get_support_requestor(struct wlan_objmgr_psoc *psoc,
 {
 	return QDF_STATUS_SUCCESS;
 }
+
+static inline QDF_STATUS
+wlan_twt_get_requestor_cfg(struct wlan_objmgr_psoc *psoc, bool *val)
+{
+	return QDF_STATUS_SUCCESS;
+}
+
+static inline QDF_STATUS
+wlan_twt_get_responder_cfg(struct wlan_objmgr_psoc *psoc, bool *val)
+{
+	return QDF_STATUS_SUCCESS;
+}
 #endif
 #endif

+ 29 - 0
components/umac/twt/dispatcher/inc/wlan_twt_ucfg_ext_api.h

@@ -169,6 +169,14 @@ bool ucfg_twt_is_setup_in_progress(struct wlan_objmgr_psoc *psoc,
 				   struct qdf_mac_addr *peer_mac,
 				   uint8_t dialog_id);
 
+/**
+ * ucfg_twt_cfg_is_twt_enabled() - Get if TWT is enabled
+ * @psoc: PSOC pointer
+ *
+ * Return: True if TWT is enabled
+ */
+bool ucfg_twt_cfg_is_twt_enabled(struct wlan_objmgr_psoc *psoc);
+
 /**
  * ucfg_twt_set_command_in_progress() - Set TWT command is in progress
  * @psoc: Pointer to psoc object
@@ -294,6 +302,15 @@ void ucfg_twt_set_work_params(
 void ucfg_twt_get_work_params(struct wlan_objmgr_vdev *vdev,
 			      struct twt_work_params *params,
 			      uint32_t *next_action);
+
+/**
+ * ucfg_twt_cfg_set_responder() - Set TWT responder capability
+ * @psoc: Pointer to global PSOC object
+ * @val: pointer to value to be set
+ *
+ * Return: QDF_STATUS
+ */
+QDF_STATUS ucfg_twt_cfg_set_responder(struct wlan_objmgr_psoc *psoc, bool val);
 #else
 static inline
 QDF_STATUS ucfg_twt_psoc_open(struct wlan_objmgr_psoc *psoc)
@@ -399,5 +416,17 @@ ucfg_twt_get_work_params(
 		uint32_t *next_action)
 {
 }
+
+static inline
+QDF_STATUS ucfg_twt_cfg_set_responder(struct wlan_objmgr_psoc *psoc, bool val)
+{
+	return QDF_STATUS_SUCCESS;
+}
+
+static inline
+bool ucfg_twt_cfg_is_twt_enabled(struct wlan_objmgr_psoc *psoc)
+{
+	return false;
+}
 #endif
 #endif

+ 12 - 0
components/umac/twt/dispatcher/src/wlan_twt_cfg_ext_api.c

@@ -38,6 +38,18 @@ wlan_twt_cfg_get_support_in_11n(struct wlan_objmgr_psoc *psoc, bool *val)
 	return wlan_twt_cfg_get_support_in_11n_mode(psoc, val);
 }
 
+QDF_STATUS
+wlan_twt_get_requestor_cfg(struct wlan_objmgr_psoc *psoc, bool *val)
+{
+	return wlan_twt_cfg_get_requestor(psoc, val);
+}
+
+QDF_STATUS
+wlan_twt_get_responder_cfg(struct wlan_objmgr_psoc *psoc, bool *val)
+{
+	return wlan_twt_cfg_get_responder(psoc, val);
+}
+
 QDF_STATUS
 wlan_twt_cfg_get_support_requestor(struct wlan_objmgr_psoc *psoc, bool *val)
 {

+ 11 - 0
components/umac/twt/dispatcher/src/wlan_twt_ucfg_ext_api.c

@@ -47,6 +47,12 @@ ucfg_twt_cfg_get_responder(struct wlan_objmgr_psoc *psoc, bool *val)
 	return wlan_twt_cfg_get_responder(psoc, val);
 }
 
+QDF_STATUS
+ucfg_twt_cfg_set_responder(struct wlan_objmgr_psoc *psoc, bool val)
+{
+	return wlan_twt_cfg_set_responder(psoc, val);
+}
+
 QDF_STATUS
 ucfg_twt_setup_req(struct wlan_objmgr_psoc *psoc,
 		   struct twt_add_dialog_param *params,
@@ -107,6 +113,11 @@ bool ucfg_twt_is_setup_in_progress(struct wlan_objmgr_psoc *psoc,
 	return wlan_twt_is_setup_in_progress(psoc, peer_mac, dialog_id);
 }
 
+bool ucfg_twt_cfg_is_twt_enabled(struct wlan_objmgr_psoc *psoc)
+{
+	return wlan_twt_cfg_is_twt_enabled(psoc);
+}
+
 QDF_STATUS
 ucfg_twt_cfg_get_congestion_timeout(struct wlan_objmgr_psoc *psoc,
 				    uint32_t *val)

+ 29 - 3
core/hdd/src/wlan_hdd_hostapd.c

@@ -114,6 +114,8 @@
 #include "wlan_osif_features.h"
 #include "wlan_pre_cac_ucfg_api.h"
 #include <wlan_dp_ucfg_api.h>
+#include "wlan_twt_ucfg_ext_api.h"
+#include "wlan_twt_ucfg_api.h"
 
 #define ACS_SCAN_EXPIRY_TIMEOUT_S 4
 
@@ -7283,6 +7285,29 @@ hdd_sap_nan_check_and_disable_unsupported_ndi(struct wlan_objmgr_psoc *psoc,
 #if defined(WLAN_SUPPORT_TWT) && \
 	((LINUX_VERSION_CODE >= KERNEL_VERSION(5, 3, 0)) || \
 	  defined(CFG80211_TWT_RESPONDER_SUPPORT))
+#ifdef WLAN_TWT_CONV_SUPPORTED
+static void
+wlan_hdd_update_twt_responder(struct hdd_context *hdd_ctx,
+			      struct cfg80211_ap_settings *params)
+{
+	bool twt_res_svc_cap, enable_twt;
+	uint32_t reason;
+
+	enable_twt = ucfg_twt_cfg_is_twt_enabled(hdd_ctx->psoc);
+	ucfg_twt_get_responder(hdd_ctx->psoc, &twt_res_svc_cap);
+	ucfg_twt_cfg_set_responder(hdd_ctx->psoc,
+				   QDF_MIN(twt_res_svc_cap,
+					   (enable_twt &&
+					    params->twt_responder)));
+	hdd_debug("cfg80211 TWT responder:%d", params->twt_responder);
+	if (enable_twt && params->twt_responder) {
+		hdd_send_twt_responder_enable_cmd(hdd_ctx);
+	} else {
+		reason = HOST_TWT_DISABLE_REASON_NONE;
+		hdd_send_twt_responder_disable_cmd(hdd_ctx, reason);
+	}
+}
+#else
 static void
 wlan_hdd_update_twt_responder(struct hdd_context *hdd_ctx,
 			      struct cfg80211_ap_settings *params)
@@ -7292,9 +7317,9 @@ wlan_hdd_update_twt_responder(struct hdd_context *hdd_ctx,
 
 	enable_twt = ucfg_mlme_is_twt_enabled(hdd_ctx->psoc);
 	ucfg_mlme_get_twt_res_service_cap(hdd_ctx->psoc, &twt_res_svc_cap);
-	ucfg_mlme_set_twt_responder(hdd_ctx->psoc, QDF_MIN(
-					twt_res_svc_cap,
-					(enable_twt && params->twt_responder)));
+	ucfg_mlme_set_twt_responder(hdd_ctx->psoc,
+				    QDF_MIN(twt_res_svc_cap,
+					    (enable_twt && params->twt_responder)));
 	hdd_debug("cfg80211 TWT responder:%d", params->twt_responder);
 	if (enable_twt && params->twt_responder) {
 		hdd_send_twt_responder_enable_cmd(hdd_ctx);
@@ -7303,6 +7328,7 @@ wlan_hdd_update_twt_responder(struct hdd_context *hdd_ctx,
 		hdd_send_twt_responder_disable_cmd(hdd_ctx, reason);
 	}
 }
+#endif
 #else
 static inline void
 wlan_hdd_update_twt_responder(struct hdd_context *hdd_ctx,

+ 11 - 6
core/mac/src/sys/legacy/src/utils/src/parser_api.c

@@ -49,6 +49,7 @@
 #include "wlan_reg_services_api.h"
 #include "wlan_cm_roam_api.h"
 #include "wlan_mlo_mgr_sta.h"
+#include "wlan_twt_cfg_ext_api.h"
 #include <wlan_cmn_ieee80211.h>
 #ifdef WLAN_FEATURE_11BE_MLO
 #include <lim_mlo.h>
@@ -10045,6 +10046,8 @@ QDF_STATUS populate_dot11f_twt_extended_caps(struct mac_context *mac_ctx,
 					     tDot11fIEExtCap *dot11f)
 {
 	struct s_ext_cap *p_ext_cap;
+	bool twt_responder = false;
+	bool twt_requestor = false;
 
 	if (pe_session->opmode == QDF_STA_MODE &&
 	    !pe_session->enable_session_twt_support) {
@@ -10055,15 +10058,17 @@ QDF_STATUS populate_dot11f_twt_extended_caps(struct mac_context *mac_ctx,
 	p_ext_cap = (struct s_ext_cap *)dot11f->bytes;
 	dot11f->present = 1;
 
-	if (pe_session->opmode == QDF_STA_MODE)
+	if (pe_session->opmode == QDF_STA_MODE) {
+		wlan_twt_get_requestor_cfg(mac_ctx->psoc, &twt_requestor);
 		p_ext_cap->twt_requestor_support =
-			mac_ctx->mlme_cfg->he_caps.dot11_he_cap.twt_request &&
-			twt_get_requestor_flag(mac_ctx);
+			twt_requestor && twt_get_requestor_flag(mac_ctx);
+	}
 
-	if (pe_session->opmode == QDF_SAP_MODE)
+	if (pe_session->opmode == QDF_SAP_MODE) {
+		wlan_twt_get_responder_cfg(mac_ctx->psoc, &twt_responder);
 		p_ext_cap->twt_responder_support =
-			mac_ctx->mlme_cfg->he_caps.dot11_he_cap.twt_responder &&
-			twt_get_responder_flag(mac_ctx);
+			twt_responder && twt_get_responder_flag(mac_ctx);
+	}
 
 	dot11f->num_bytes = lim_compute_ext_cap_ie_length(dot11f);
 	if (!dot11f->num_bytes) {