From 4e5c5e4f682a7ca22535e88269d3a451f0b0e6fd Mon Sep 17 00:00:00 2001 From: Pragaspathi Thilagaraj Date: Tue, 2 Feb 2021 18:03:45 +0530 Subject: [PATCH] qcacld-3.0: Reset the stored TWT dialog ID on TWT setup failure Driver doesn't clear the stored dialog id for TWT session when TWT setup returns failure. This causes subsequent TWT sessions to fail. Reset the TWT session state and clear the dialog id for the failed TWT setup to allow the next TWT setup commands. Change-Id: I2f0ccb7a07ef49011b01d7336389d6ce56315fe9 CRs-Fixed: 2865240 --- core/hdd/src/wlan_hdd_twt.c | 12 +++--------- core/sme/src/common/sme_api.c | 30 ++++++++++++++++++++++-------- core/wma/src/wma_twt.c | 3 ++- 3 files changed, 27 insertions(+), 18 deletions(-) diff --git a/core/hdd/src/wlan_hdd_twt.c b/core/hdd/src/wlan_hdd_twt.c index 8604670b7cb4..b0aee95553a5 100644 --- a/core/hdd/src/wlan_hdd_twt.c +++ b/core/hdd/src/wlan_hdd_twt.c @@ -1086,8 +1086,10 @@ hdd_twt_setup_pack_resp_nlmsg(struct sk_buff *reply_skb, return QDF_STATUS_E_FAILURE; } - if (event->params.num_additional_twt_params == 0) + if (event->params.num_additional_twt_params == 0) { + nla_nest_end(reply_skb, config_attr); return QDF_STATUS_SUCCESS; + } response_type = wmi_twt_add_cmd_to_vendor_twt_resp_type(event->additional_params.twt_cmd); if (response_type == -EINVAL) { @@ -1255,14 +1257,6 @@ hdd_twt_add_dialog_comp_cb(struct wlan_objmgr_psoc *psoc, add_dialog_event->params.status, vdev_id, QDF_MAC_ADDR_REF(add_dialog_event->params.peer_macaddr)); hdd_send_twt_setup_response(adapter, add_dialog_event); - - if (add_dialog_event->params.status) - return; - - ucfg_mlme_set_twt_setup_done( - adapter->hdd_ctx->psoc, - (struct qdf_mac_addr *)add_dialog_event->params.peer_macaddr, - add_dialog_event->params.dialog_id, true); } /** diff --git a/core/sme/src/common/sme_api.c b/core/sme/src/common/sme_api.c index 24fdc8a5bd7c..e852c6adb6e5 100644 --- a/core/sme/src/common/sme_api.c +++ b/core/sme/src/common/sme_api.c @@ -2074,7 +2074,8 @@ sme_process_twt_add_dialog_event(struct mac_context *mac, (struct qdf_mac_addr *)add_dialog_event->params.peer_macaddr, add_dialog_event->params.dialog_id, WLAN_TWT_SETUP); if (!is_evt_allowed) { - sme_debug("add dialog event dropped"); + sme_debug("add dialog event dropped for id:%d", + add_dialog_event->params.dialog_id); return; } @@ -2082,17 +2083,29 @@ sme_process_twt_add_dialog_event(struct mac_context *mac, if (callback) callback(mac->psoc, add_dialog_event); - ucfg_mlme_set_twt_session_state( - mac->psoc, - (struct qdf_mac_addr *)add_dialog_event->params.peer_macaddr, - add_dialog_event->params.dialog_id, - WLAN_TWT_SETUP_STATE_ACTIVE); - /* Reset the active TWT command to none */ mlme_set_twt_command_in_progress( mac->psoc, (struct qdf_mac_addr *)add_dialog_event->params.peer_macaddr, add_dialog_event->params.dialog_id, WLAN_TWT_NONE); + + if (add_dialog_event->params.status) { + /* Clear the stored TWT dialog ID as TWT setup failed */ + ucfg_mlme_init_twt_context(mac->psoc, (struct qdf_mac_addr *) + add_dialog_event->params.peer_macaddr, + add_dialog_event->params.dialog_id); + return; + } + + ucfg_mlme_set_twt_setup_done(mac->psoc, (struct qdf_mac_addr *) + add_dialog_event->params.peer_macaddr, + add_dialog_event->params.dialog_id, true); + + ucfg_mlme_set_twt_session_state( + mac->psoc, + (struct qdf_mac_addr *)add_dialog_event->params.peer_macaddr, + add_dialog_event->params.dialog_id, + WLAN_TWT_SETUP_STATE_ACTIVE); } /** @@ -2117,7 +2130,8 @@ sme_process_twt_del_dialog_event(struct mac_context *mac, param->dialog_id != WLAN_ALL_SESSIONS_DIALOG_ID && param->status != WMI_HOST_DEL_TWT_STATUS_ROAMING && param->status != WMI_HOST_DEL_TWT_STATUS_PEER_INIT_TEARDOWN) { - sme_debug("add dialog event dropped"); + sme_debug("Del dialog event dropped for id:%d", + param->dialog_id); return; } diff --git a/core/wma/src/wma_twt.c b/core/wma/src/wma_twt.c index 9cb4602ec166..3b2bdab7ff6e 100644 --- a/core/wma/src/wma_twt.c +++ b/core/wma/src/wma_twt.c @@ -224,7 +224,8 @@ int wma_twt_add_dialog_complete_event_handler(void *handle, return qdf_status_to_os_return(status); } - wma_debug("TWT: Extract TWT add dialog event :%d", status); + wma_debug("TWT: Extract TWT add dialog event id:%d", + add_dialog_event->params.dialog_id); sme_msg.type = eWNI_SME_TWT_ADD_DIALOG_EVENT; sme_msg.bodyptr = add_dialog_event;