From 9c873c6acb8972dd222b1ab6439e83ed044d9dfc Mon Sep 17 00:00:00 2001 From: Gokul Sivakumar Date: Thu, 7 Sep 2023 14:46:58 -0500 Subject: [PATCH 180/296] brcmfmac: TWT: Update teardown state while handling Teardown All from user When having multiple active TWT sessions with a TWT AP, on receiving a TWT Teardown cmd from userspace with "Teardown All" action, update the state of all active TWT sessions with "Teardown inprogress" state. While handling a TWT Teardown cmd, in the driver TWT session list, skip updating the state of a session to "Teardown inprogress" on one of the following cases. * The "teardown all" session action is not requested by userspace. * The session's flow id is not explcitly requested for teardown. * The session's state is not "setup complete" i.e, it is not already active to teardown. Signed-off-by: Gokul Sivakumar --- .../broadcom/brcm80211/brcmfmac/twt.c | 25 +++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/twt.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/twt.c index 50c0e796fe89..a477f56d05f5 100644 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/twt.c +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/twt.c @@ -1044,8 +1044,29 @@ brcmf_twt_teardown_oper_handler(struct brcmf_if *ifp, struct brcmf_twt_params tw goto exit; } - brcmf_twt_update_session_state(ifp, twt_sess, - BRCMF_TWT_SESS_STATE_TEARDOWN_INPROGRESS); + list_for_each_entry(twt_sess, &ifp->twt_sess_list, list) { + /* Skip updating the state of this session to "Teardown inprogress" + * on one of the following cases + * 1. The "Teardown all" session action is not requested by userspace. + * 2. This session's Flow ID is not explcitly requested for Teardown. + * 3. This session's state is not "setup complete". + * i.e, it is not already active to teardown. + */ + if (!twt_params.teardown_all_twt || + twt_params.flow_id != twt_sess->twt_params.flow_id || + twt_sess->state != BRCMF_TWT_SESS_STATE_SETUP_COMPLETE) + continue; + + ret = brcmf_twt_update_session_state(ifp, twt_sess, + BRCMF_TWT_SESS_STATE_TEARDOWN_INPROGRESS); + if (ret) { + brcmf_err("TWT: Teardown REQ: Failed to update session(%u) with state(%s)", + twt_params.flow_id, + brcmf_twt_session_state_str[BRCMF_TWT_SESS_STATE_TEARDOWN_INPROGRESS]); + goto exit; + } + } + brcmf_dbg(TWT, "TWT: Teardown REQ: Session Teardown In Progress\n" "Flow ID : %u\n" "Broadcast TWT ID : %u\n" -- 2.25.1