diff --git a/core/hdd/inc/wlan_hdd_twt.h b/core/hdd/inc/wlan_hdd_twt.h index fa09dc161a37..ba009970bcd0 100644 --- a/core/hdd/inc/wlan_hdd_twt.h +++ b/core/hdd/inc/wlan_hdd_twt.h @@ -148,12 +148,22 @@ QDF_STATUS hdd_send_twt_requestor_enable_cmd(struct hdd_context *hdd_ctx); QDF_STATUS hdd_send_twt_responder_enable_cmd(struct hdd_context *hdd_ctx); /** - * hdd_send_twt_disable_cmd() - Send TWT disable command to target + * hdd_send_twt_requestor_disable_cmd() - Send TWT requestor disable command + * to target * @hdd_ctx: HDD Context * * Return: QDF_STATUS */ -QDF_STATUS hdd_send_twt_disable_cmd(struct hdd_context *hdd_ctx); +QDF_STATUS hdd_send_twt_requestor_disable_cmd(struct hdd_context *hdd_ctx); + +/** + * hdd_send_twt_responder_disable_cmd() - Send TWT responder disable command + * to target + * @hdd_ctx: HDD Context + * + * Return: QDF_STATUS + */ +QDF_STATUS hdd_send_twt_responder_disable_cmd(struct hdd_context *hdd_ctx); /** * wlan_hdd_twt_init() - Initialize TWT @@ -248,18 +258,25 @@ static inline void hdd_update_tgt_twt_cap(struct hdd_context *hdd_ctx, static inline QDF_STATUS hdd_send_twt_requestor_enable_cmd(struct hdd_context *hdd_ctx) { - return QDF_STATUS_E_FAILURE; + return QDF_STATUS_E_NOSUPPORT; } static inline QDF_STATUS hdd_send_twt_responder_enable_cmd(struct hdd_context *hdd_ctx) { - return QDF_STATUS_E_FAILURE; + return QDF_STATUS_E_NOSUPPORT; } -static inline QDF_STATUS hdd_send_twt_disable_cmd(struct hdd_context *hdd_ctx) +static inline +QDF_STATUS hdd_send_twt_requestor_disable_cmd(struct hdd_context *hdd_ctx) { - return QDF_STATUS_SUCCESS; + return QDF_STATUS_E_NOSUPPORT; +} + +static inline +QDF_STATUS hdd_send_twt_responder_disable_cmd(struct hdd_context *hdd_ctx) +{ + return QDF_STATUS_E_NOSUPPORT; } static inline void wlan_hdd_twt_init(struct hdd_context *hdd_ctx) diff --git a/core/hdd/src/wlan_hdd_hostapd.c b/core/hdd/src/wlan_hdd_hostapd.c index e56b67b34a4a..d74d56542767 100644 --- a/core/hdd/src/wlan_hdd_hostapd.c +++ b/core/hdd/src/wlan_hdd_hostapd.c @@ -6419,6 +6419,8 @@ wlan_hdd_update_twt_responder(struct hdd_context *hdd_ctx, ucfg_mlme_set_twt_responder(hdd_ctx->psoc, params->twt_responder); if (params->twt_responder) hdd_send_twt_responder_enable_cmd(hdd_ctx); + else + hdd_send_twt_responder_disable_cmd(hdd_ctx); } #else static inline void diff --git a/core/hdd/src/wlan_hdd_twt.c b/core/hdd/src/wlan_hdd_twt.c index 3979ef619b22..e92693e72caf 100644 --- a/core/hdd/src/wlan_hdd_twt.c +++ b/core/hdd/src/wlan_hdd_twt.c @@ -356,7 +356,7 @@ int hdd_test_config_twt_setup_session(struct hdd_adapter *adapter, &congestion_timeout); if (congestion_timeout) { ret = qdf_status_to_os_return( - hdd_send_twt_disable_cmd(adapter->hdd_ctx)); + hdd_send_twt_requestor_disable_cmd(adapter->hdd_ctx)); if (ret) { hdd_err("Failed to disable TWT"); return ret; @@ -1612,7 +1612,7 @@ static int hdd_twt_setup_session(struct hdd_adapter *adapter, if (congestion_timeout) { ret = qdf_status_to_os_return( - hdd_send_twt_disable_cmd(adapter->hdd_ctx)); + hdd_send_twt_requestor_disable_cmd(adapter->hdd_ctx)); if (ret) { hdd_err("Failed to disable TWT"); return ret; @@ -3566,28 +3566,70 @@ QDF_STATUS hdd_send_twt_responder_enable_cmd(struct hdd_context *hdd_ctx) return status; } -QDF_STATUS hdd_send_twt_disable_cmd(struct hdd_context *hdd_ctx) +QDF_STATUS hdd_send_twt_requestor_disable_cmd(struct hdd_context *hdd_ctx) { uint8_t pdev_id = hdd_ctx->pdev->pdev_objmgr.wlan_pdev_id; struct twt_enable_disable_conf twt_en_dis = {0}; - QDF_STATUS status; + QDF_STATUS status = QDF_STATUS_E_FAILURE; - hdd_debug("TWT disable cmd :pdev:%d", pdev_id); + hdd_debug("TWT requestor disable cmd: pdev:%d", pdev_id); - /* One disable should be fine, with extended configuration - * set to false, and extended arguments will be ignored by target - */ + /* Set MLME TWT flag */ + ucfg_mlme_set_twt_requestor_flag(hdd_ctx->psoc, false); + + /* One disable should be fine, with extended configuration + * set to false, and extended arguments will be ignored by target + */ + twt_en_dis.role = WMI_TWT_ROLE_REQUESTOR; hdd_ctx->twt_state = TWT_DISABLE_REQUESTED; twt_en_dis.ext_conf_present = false; + qdf_event_reset(&hdd_ctx->twt_disable_comp_evt); wma_send_twt_disable_cmd(pdev_id, &twt_en_dis); status = qdf_wait_single_event(&hdd_ctx->twt_disable_comp_evt, TWT_DISABLE_COMPLETE_TIMEOUT); if (!QDF_IS_STATUS_SUCCESS(status)) - hdd_warn("TWT Responder disable timedout"); + goto timeout; return status; + +timeout: + hdd_warn("TWT Requestor disable timedout"); + return status; +} + +QDF_STATUS hdd_send_twt_responder_disable_cmd(struct hdd_context *hdd_ctx) +{ + uint8_t pdev_id = hdd_ctx->pdev->pdev_objmgr.wlan_pdev_id; + struct twt_enable_disable_conf twt_en_dis = {0}; + QDF_STATUS status = QDF_STATUS_E_FAILURE; + + hdd_debug("TWT responder disable cmd: pdev:%d", pdev_id); + + /* Set MLME TWT flag */ + ucfg_mlme_set_twt_responder_flag(hdd_ctx->psoc, false); + + /* One disable should be fine, with extended configuration + * set to false, and extended arguments will be ignored by target + */ + twt_en_dis.role = WMI_TWT_ROLE_RESPONDER; + hdd_ctx->twt_state = TWT_DISABLE_REQUESTED; + twt_en_dis.ext_conf_present = false; + qdf_event_reset(&hdd_ctx->twt_disable_comp_evt); + wma_send_twt_disable_cmd(pdev_id, &twt_en_dis); + + status = qdf_wait_single_event(&hdd_ctx->twt_disable_comp_evt, + TWT_DISABLE_COMPLETE_TIMEOUT); + + if (!QDF_IS_STATUS_SUCCESS(status)) + goto timeout; + + return status; + +timeout: + hdd_warn("TWT Responder disable timedout"); + return status; } /**