From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9380B592214 for ; Tue, 8 Sep 2026 17:10:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.168.131 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788887440; cv=none; b=q2XuCPA+OG3bynU5xhgfWCwm7Eej0VIvuL/sIOqEqtgHhdrjNuhu/1Gw7YACaScN3/t6S+ce0Xxmgzzaq/DslosIvNMqD45EI7c+q/C8x/cLvTLv9zCdvSINJiPiZiorEolwLXvEOE6zJlS4mlS+oI2dWUDm3cMCBDq+bVj9oS0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788887440; c=relaxed/simple; bh=0W1QH4oNYlUdeirmNfFD+jmPU+kApot3zeq7C9nGrDE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=g6IBrgMrtOdiEyeqJU+zkkUS6rK/c0R4cX/xJ3oNPKbu3Iu9Q+gY783cIVfNysF4vGO7RDxPOn7b/cxGTOusZWScyaNdXB1jCjdmnIa6Bk05Y66SK+dRQ7QPRFYcA13MIN0semnqlEZytFZKpxueXktEMfd8OlEyKJLNtFL55YE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com; spf=pass smtp.mailfrom=oss.qualcomm.com; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b=exxCjGAj; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=jYU+80em; arc=none smtp.client-ip=205.220.168.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b="exxCjGAj"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="jYU+80em" Received: from pps.filterd (m0279865.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 688FdZ6Z045444 for ; Tue, 8 Sep 2026 17:10:36 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=qcppdkim1; bh= afmJcrxX+TSrqMPN9T48TbSokMooP/JVAehCZMO0dOc=; b=exxCjGAjKeOc0l+4 vjJp8a/qwoXOwO0uwLxyIKlX1DncXm4hgkl5C6QyaIxX/vIO2gcV21tioPQFxxaB ps13iKKaubgG6WNfdv21bLGHwdmzODVd83GpojZGNSfMK3K3UmpEknC94G8lfvHV pRVb0OZAtr7/AE2b3kzI2jg5PhwoSBojX1K4cwahD2Zuutk64Od2cy1Bg2EEUpia p2HBdaq2QNZ97z7vm4WyJZTx1R2bc75bUrcuj3/Z3mwqpDB4QT74Rkjwnv6DLXlA zT0W8UkC74B0C5zjlqnwArH5Sd9VVpZnyqVLuXXZ8YJMMw/txykMmo7q4K4nsd6P HOpQSA== Received: from mail-pg1-f197.google.com (mail-pg1-f197.google.com [209.85.215.197]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4gjg8xsy6f-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Tue, 08 Sep 2026 17:10:36 +0000 (GMT) Received: by mail-pg1-f197.google.com with SMTP id 41be03b00d2f7-cb48f41343aso5193972a12.1 for ; Tue, 08 Sep 2026 10:10:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1788887436; x=1789492236; darn=vger.kernel.org; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:from:to:cc:subject :date:message-id:reply-to:content-type; bh=afmJcrxX+TSrqMPN9T48TbSokMooP/JVAehCZMO0dOc=; b=jYU+80emdVPFrC/ZBA1K7KD14ES+o4V6zepsBzoS9EvThSCQFUhtxyP0/sWHGhLMoh +XOBec4sJmahGyYj2h0PdJRA2mZ71Xgu+N9Ed/2HS/u9viyaZsqb60doadeMvzhhgzGZ tatANjD6duSnS4PeW6w48NK4hYKDAtwMaCl3k4L9XnYr88YSHrmC7q9QZeFhc0io9gGV w0wPZuOiU2Tl0S6edebX01veAyp+rH5G68nBgjp2JDqUqZrdrVlGgtaB+EjBbZMKLDgd dyCrutwW20tlKfGt2pYjMm0RXPMAzlzk2HAMwaTO5JQ5ffOlUsbyNadScXNzmwnq9Gp6 1Irg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788887436; x=1789492236; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=afmJcrxX+TSrqMPN9T48TbSokMooP/JVAehCZMO0dOc=; b=Si5Wx176PdluMKJ911HCPmxmfOjrdroFJTd5vAY2R/hC+EVm4317qEg0IXyn9Z2jqY Darv+HmBiBpX7NPZ3jvCJeEk/ByYYs1Ep0RL75/UZ9MGRiEc3I9dMpUoI1FADZauZFOj HtAPV9qQLyfFdTfkQzvrgZnFcIXCBGZIqEa8G6l0PkBIUI+Du8v/IiFJG8nyNBGiVNVM SJk70Wix77FODZG3H2AmhkgnrM2dRXOAEpeImxJom/nJN18H3dVCkPlT6Q/4iXrNAzU0 YEvtpeq9dhLXSdYa5E7ugvrCSuZ1mMGMzAcm0TjZq400RGBAzQofp7calolxQol9guzH A6lA== X-Forwarded-Encrypted: i=1; AKwUvBx9Dyket3Gi3irIdJadhvEW+KQKz9gzZVgCpkOm6ju0mKYNs70VbFZUYVJGL0Xb9w0vj0vthIU=@vger.kernel.org X-Gm-Message-State: AFuF++k2IenI2ZeWjrHZ5a9VDT8x+9yGtpwfV2mGJFcWzVnxX2BZ9pVB WTu9lyJ6A0RIm0ROXVRbQb82qB21qRN6PwL9rtwwUTc71jHvs3kSx8Z6s106PGPYIlqsn+mvq0O ApTEW8/01zx1Ys3p1QPetmPPqcXp+eZwpAFL00DiMPvZMKqK/ZNqh+666xA== X-Gm-Gg: AYBFou2QD2ObRMQqtmQ0ru4uMZmA/O7GWsI2u6DcZClhDRHfcjYsLx8zyvNR/VmHHUy FgksxJCUtLEhqaxPmlegl31dlh5fQ4lKqEBhAutSwyPG9MscRx4peqvChyfD15wEiWCzkyl8AvZ 9jXHPXaj0aRWYtrQ9Soz6nqjd22BgzE3VP/I3XSnwe3PJgMDtnuwro/rXLg2YA95H/ksd9qA/UN ARDuUxxNBCCpph18d8VWqrtskaS2+ytnuLT0ywcyWgx5H19YZ9LoKNyF7gn7Q7ZEWbeLEdLRBRM 92jdMSyRgtU5v5NY69hvzIB8yfEMU6m4G0ElRqoks/f3g/pSeXCcGPb842s4N7IUvFAGZmDGiOm WSHZx74jxYMOlkL/TAu07Re/spnnADbjUKjjeH+2K0Eet6ooH5gNS0azlG/ajWZzfZsov4dY4vj riC9STXxn9WwjWKS1PJbMTSw== X-Received: by 2002:a05:6300:6406:b0:3da:b8e7:fb18 with SMTP id adf61e73a8af0-3dab8e7fc1amr1119201637.26.1788887435424; Tue, 08 Sep 2026 10:10:35 -0700 (PDT) X-Received: by 2002:a05:6300:6406:b0:3da:b8e7:fb18 with SMTP id adf61e73a8af0-3dab8e7fc1amr1119167637.26.1788887434893; Tue, 08 Sep 2026 10:10:34 -0700 (PDT) Received: from hu-pooventh-blr.qualcomm.com (blr-bdr-fw-01_GlobalNAT_AllZones-Outside.qualcomm.com. [103.229.18.19]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-33450e140d3sm31773675eec.4.2026.09.08.10.10.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Sep 2026 10:10:32 -0700 (PDT) From: Pooventhiran G To: "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman , Johannes Berg Cc: linux-kernel@vger.kernel.org, netdev@vger.kernel.org, linux-wireless@vger.kernel.org, Pooventhiran G Subject: [PATCH RESEND wireless-next 08/18] wifi: mac80211: Add driver_op for SMD substate changes Date: Tue, 8 Sep 2026 22:39:36 +0530 Message-Id: <20260908-smd-v1-8-9fd2d876a1fb@oss.qualcomm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260908-smd-v1-0-9fd2d876a1fb@oss.qualcomm.com> References: <20260908-smd-v1-0-9fd2d876a1fb@oss.qualcomm.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" X-Mailer: b4 0.14.3 Content-Transfer-Encoding: 8bit X-Authority-Analysis: v=2.4 cv=J7GaKgnS c=1 sm=1 tr=0 ts=6aa0418c cx=c_pps a=rz3CxIlbcmazkYymdCej/Q==:117 a=Ou0eQOY4+eZoSc0qltEV5Q==:17 a=IkcTkHD0fZMA:10 a=VdqzKS8jKosA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=Um2Pa8k9VHT-vaBCBUpS:22 a=EUspDBNiAAAA:8 a=uScroKfZLg1nAwDi7sIA:9 a=QEXdDO2ut3YA:10 a=O8hF6Hzn-FEA:10 a=bFCP_H2QrGi7Okbo017w:22 X-Proofpoint-ORIG-GUID: yGo6j52NBHfImLS08iGxSRS1cmcCV7ds X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwOTA4MDE4NSBTYWx0ZWRfX7vAdaJnGJybo Jqrh7ZP2sJoXTt+6mZJAQx054m1vVdoukndBpozt21NHfj585Aa904NEjXGgR3+tcfyK8cMkjLe immWJZa4z2UZGdfGoWkgUQvOVZ5yqFmgB+XpUXzSshJEWjIT9RAJe8hXNWhX5TKHaRI0WconxU+ /VIlaiRqVddUklOhYBbSl3LES7DFZCKzq58Ii1s6v/ufnLCzch4Z+azSi5d71PLeEt6bAHQj3x6 reZTSrjH+cSSe5xbuaA5VNd0gnvZ0/psLlLh5wf6gLE0wwoQx5CG/5ZGEUn7MVUVx6UXkXyfg/t Gua3mX1mRpIl8SQy8F/E3IRvXZCQZiFy4D48b8ClyNElq4KYuyrpHp/6Rr9AxUTzsz2jjaMDrGs HA6toBOxctq8VFCHevYG3u7FkmDlQ73xicY37apnFDKF0ytsjH6WfITYXh5YPTeahyO3eLnjFXp ksuvPPzGqqw7nB6Vxzw== X-Proofpoint-GUID: yGo6j52NBHfImLS08iGxSRS1cmcCV7ds X-Proofpoint-Spam-Info: AW1haW4tMjYwOTA4MDE4NSBTYWx0ZWRfX5D5GGSFCKVvu GBfzpy9Oqlfh/z0iA/iDnehSuoIqxWXh5rPpkSFBJV5X8SRZzvrAJ4yden3icYxYTxLU6KFytEZ VqwWr2wEd/jryLlVxbf6av1swXuM5w0= X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-09-08_03,2026-09-08_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 adultscore=0 suspectscore=0 clxscore=1015 spamscore=0 priorityscore=1501 impostorscore=0 lowpriorityscore=0 phishscore=0 malwarescore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2609080185 During SMD BSS Transition, a non-AP MLD cycles through sub-states 4a, 4b, and 4c that impose different frame-filtering rules on the AP MLD. mac80211 tracks these sub-states in STA flags but has no mechanism to propagate the transitions to the driver, so hardware-level queue gating and frame-filtering cannot follow the SMD state machine. Add a new driver op that mac80211 calls on each sub-state transition. This lets drivers perform the necessary hardware queue and filtering adjustments at each phase of the SMD BSS Transition. Valid transition order: NONE -> PREP (ST preparation completed at the target AP MLD) NONE -> EXEC (ST execution in progress at the current AP MLD) EXEC -> DRAIN (DL drain period started at the current AP MLD) Suggested-by: Rohan Dutta Signed-off-by: Pooventhiran G --- include/net/mac80211.h | 26 +++++++++ net/mac80211/cfg.c | 59 ++++++++++++++----- net/mac80211/driver-ops.c | 24 ++++++++ net/mac80211/driver-ops.h | 6 ++ net/mac80211/sta_info.c | 140 ++++++++++++++++++++++++++++++++++++++++++++++ net/mac80211/sta_info.h | 9 +++ net/mac80211/trace.h | 33 +++++++++++ 7 files changed, 284 insertions(+), 13 deletions(-) diff --git a/include/net/mac80211.h b/include/net/mac80211.h index d8f5e5d8a021..9b5fa6d6281b 100644 --- a/include/net/mac80211.h +++ b/include/net/mac80211.h @@ -4077,6 +4077,24 @@ struct ieee80211_prep_tx_info { int link_id; }; +/** + * enum ieee80211_sta_smd_state - SMD BSS Transition sub-state + * + * Tracks the 802.11bn SMD BSS Transition sub-state (IEEE P802.11bn/D2.0, + * Aug 2026, subclause 11.3.1) for a specific (non-AP MLD, AP MLD) association. + * + * @IEEE80211_STA_SMD_NONE: Plain State 4. No sub-state active. + * @IEEE80211_STA_SMD_PREP: State 4a. STA prepared at the target AP MLD + * @IEEE80211_STA_SMD_EXEC: State 4b. ST execution active at the current AP MLD + * @IEEE80211_STA_SMD_DRAIN: State 4c. DL draining period at the current AP MLD + */ +enum ieee80211_sta_smd_state { + IEEE80211_STA_SMD_NONE, + IEEE80211_STA_SMD_PREP, + IEEE80211_STA_SMD_EXEC, + IEEE80211_STA_SMD_DRAIN, +}; + /** * struct ieee80211_ops - callbacks from mac80211 to the driver * @@ -4743,6 +4761,9 @@ struct ieee80211_prep_tx_info { * @set_eml_op_mode: Configure eMLSR/eMLMR operation mode in the underlay * driver according to the parameter received in the EML Operating mode * notification frame. + * @sta_smd_state: Notifies low level driver about IEEE 802.11bn SMD substate + * transition of a station. It must not fail while transitioning down. + * The callback can sleep. */ struct ieee80211_ops { void (*tx)(struct ieee80211_hw *hw, @@ -5144,6 +5165,11 @@ struct ieee80211_ops { struct ieee80211_vif *vif, struct ieee80211_sta *sta, struct ieee80211_eml_params *eml_params); + int (*sta_smd_state)(struct ieee80211_hw *hw, + struct ieee80211_vif *vif, + struct ieee80211_sta *sta, + enum ieee80211_sta_smd_state old_state, + enum ieee80211_sta_smd_state new_state); }; /** diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c index 69b3ac0b48f3..0ea8b610a771 100644 --- a/net/mac80211/cfg.c +++ b/net/mac80211/cfg.c @@ -2459,7 +2459,9 @@ static int sta_apply_smd_state_flags(struct sta_info *sta, u32 expected_mask = BIT(NL80211_STA_FLAG_SMD_PREP_TARGET) | BIT(NL80211_STA_FLAG_SMD_EXEC_CURRENT) | BIT(NL80211_STA_FLAG_SMD_DL_DRAIN); + enum ieee80211_sta_smd_state new_ss; u32 smd_flags; + int err; if (!(mask & expected_mask)) return 0; @@ -2479,6 +2481,22 @@ static int sta_apply_smd_state_flags(struct sta_info *sta, (smd_exec_current || smd_dl_drain)) return -EINVAL; + if (smd_prep_target) + new_ss = IEEE80211_STA_SMD_PREP; + else if (smd_exec_current) + new_ss = IEEE80211_STA_SMD_EXEC; + else if (smd_dl_drain) + new_ss = IEEE80211_STA_SMD_DRAIN; + else + new_ss = IEEE80211_STA_SMD_NONE; + + if (new_ss == sta->smd_state) + return 0; + + err = sta_info_move_smd_state(sta, new_ss, true); + if (err) + return err; + if (smd_prep_target) { clear_sta_flag(sta, WLAN_STA_SMD_EXEC_CURRENT); clear_sta_flag(sta, WLAN_STA_SMD_DL_DRAIN); @@ -2578,26 +2596,17 @@ static int sta_apply_parameters(struct ieee80211_local *local, sta->sta.spp_amsdu = set & BIT(NL80211_STA_FLAG_SPP_AMSDU); if (mask & BIT(NL80211_STA_FLAG_SMD)) { - if (set & BIT(NL80211_STA_FLAG_SMD)) + if (set & BIT(NL80211_STA_FLAG_SMD)) { set_sta_flag(sta, WLAN_STA_SMD); - else if (test_sta_flag(sta, WLAN_STA_SMD)) + } else if (test_sta_flag(sta, WLAN_STA_SMD)) { + sta_info_reset_smd_state(sta, true); clear_sta_flag(sta, WLAN_STA_SMD); + } } if (params->smd_params.smd_sta) sta->sta.smd_params = params->smd_params; - /* - * SMD BSS Transition sub-states (IEEE P802.11bn/D2.0, Aug 2026, - * subclause 11.3.1). - * Only meaningful for SMD-capable stations (WLAN_STA_SMD set). - */ - if (test_sta_flag(sta, WLAN_STA_SMD)) { - ret = sta_apply_smd_state_flags(sta, mask, set); - if (ret) - return ret; - } - /* mark TDLS channel switch support, if the AP allows it */ if (test_sta_flag(sta, WLAN_STA_TDLS_PEER) && !sdata->deflink.u.mgd.tdls_chan_switch_prohibited && @@ -2699,6 +2708,17 @@ static int sta_apply_parameters(struct ieee80211_local *local, return ret; } + /* + * SMD BSS Transition sub-states (IEEE P802.11bn/D2.0, Aug 2026, + * subclause 11.3.1). + * Only meaningful for SMD-capable stations (WLAN_STA_SMD set). + */ + if (test_sta_flag(sta, WLAN_STA_SMD)) { + ret = sta_apply_smd_state_flags(sta, mask, set); + if (ret) + return ret; + } + /* Mark the STA as MLO if MLD MAC address is available */ if (params->link_sta_params.mld_mac) sta->sta.mlo = true; @@ -2783,6 +2803,19 @@ static int ieee80211_add_station(struct wiphy *wiphy, struct wireless_dev *wdev, */ if (!err && sdata->vif.type == NL80211_IFTYPE_NAN_DATA) ieee80211_nan_update_ndi_carrier(sta->sdata); + + /* + * SMD sub-state was set in sta_apply_parameters() before the station + * was inserted so drv_sta_smd_state() was skipped (WLAN_STA_INSERTED + * was not yet set). Walk the driver step-by-step to the target state. + */ + if (!err && test_sta_flag(sta, WLAN_STA_SMD) && + sta->smd_state != IEEE80211_STA_SMD_NONE) { + err = sta_info_move_drv_smd_state(sta); + if (err) + WARN_ON(__sta_info_destroy(sta)); + } + return err; } diff --git a/net/mac80211/driver-ops.c b/net/mac80211/driver-ops.c index 49753b73aba2..d77a5a80f06e 100644 --- a/net/mac80211/driver-ops.c +++ b/net/mac80211/driver-ops.c @@ -633,3 +633,27 @@ int drv_change_sta_links(struct ieee80211_local *local, return 0; } + +int drv_sta_smd_state(struct ieee80211_local *local, + struct ieee80211_sub_if_data *sdata, + struct ieee80211_sta *sta, + enum ieee80211_sta_smd_state old_state, + enum ieee80211_sta_smd_state new_state) +{ + int ret = 0; + + might_sleep(); + lockdep_assert_wiphy(local->hw.wiphy); + + sdata = get_bss_sdata(sdata); + if (!check_sdata_in_driver(sdata)) + return -EIO; + + trace_drv_sta_smd_state(local, sdata, sta, old_state, new_state); + if (local->ops->sta_smd_state) + ret = local->ops->sta_smd_state(&local->hw, &sdata->vif, + sta, old_state, new_state); + trace_drv_return_int(local, ret); + + return ret; +} diff --git a/net/mac80211/driver-ops.h b/net/mac80211/driver-ops.h index f1c0b87fddd5..ce11a723ec36 100644 --- a/net/mac80211/driver-ops.h +++ b/net/mac80211/driver-ops.h @@ -1814,4 +1814,10 @@ drv_nan_peer_sched_changed(struct ieee80211_local *local, return ret; } +int drv_sta_smd_state(struct ieee80211_local *local, + struct ieee80211_sub_if_data *sdata, + struct ieee80211_sta *sta, + enum ieee80211_sta_smd_state old_state, + enum ieee80211_sta_smd_state new_state); + #endif /* __MAC80211_DRIVER_OPS */ diff --git a/net/mac80211/sta_info.c b/net/mac80211/sta_info.c index fdf00cbf49d8..5aa6f5b481e3 100644 --- a/net/mac80211/sta_info.c +++ b/net/mac80211/sta_info.c @@ -701,6 +701,7 @@ __sta_info_alloc(struct ieee80211_sub_if_data *sdata, ieee80211_init_frag_cache(&sta->frags); sta->sta_state = IEEE80211_STA_NONE; + sta->smd_state = IEEE80211_STA_SMD_NONE; if (sdata->vif.type == NL80211_IFTYPE_MESH_POINT) sta->amsdu_mesh_control = -1; @@ -1527,6 +1528,20 @@ static int _sta_info_move_state(struct sta_info *sta, WARN_ONCE(err, "Driver is not allowed to fail if the sta_state is transitioning down the list: %d\n", err); + + /* revert SMD states if STA has transitioned down */ + if (new_state == IEEE80211_STA_AUTH && + sta->sta_state == IEEE80211_STA_ASSOC) { + if (test_sta_flag(sta, WLAN_STA_SMD) && + sta->smd_state == IEEE80211_STA_SMD_PREP) + sta_info_reset_smd_state(sta, true); + } else if (new_state == IEEE80211_STA_ASSOC && + sta->sta_state == IEEE80211_STA_AUTHORIZED) { + if (test_sta_flag(sta, WLAN_STA_SMD) && + sta->smd_state != IEEE80211_STA_SMD_NONE && + sta->smd_state != IEEE80211_STA_SMD_PREP) + sta_info_reset_smd_state(sta, true); + } } sta->sta_state = new_state; @@ -3883,3 +3898,128 @@ bool ieee80211_link_sta_update_rc_bw(struct ieee80211_link_data *link, return true; } + +int sta_info_move_smd_state(struct sta_info *sta, + enum ieee80211_sta_smd_state new_ss, + bool notify) +{ + enum ieee80211_sta_smd_state old_ss = sta->smd_state; + struct ieee80211_local *local = sta->local; + bool notify_driver; + int err; + + might_sleep(); + + if (old_ss == new_ss) + return 0; + + switch (new_ss) { + case IEEE80211_STA_SMD_NONE: + if (old_ss != IEEE80211_STA_SMD_PREP && + old_ss != IEEE80211_STA_SMD_EXEC && + old_ss != IEEE80211_STA_SMD_DRAIN) + return -EINVAL; + break; + case IEEE80211_STA_SMD_EXEC: + if (old_ss != IEEE80211_STA_SMD_NONE) + return -EINVAL; + break; + case IEEE80211_STA_SMD_DRAIN: + if (old_ss != IEEE80211_STA_SMD_EXEC) + return -EINVAL; + break; + case IEEE80211_STA_SMD_PREP: + if (old_ss != IEEE80211_STA_SMD_NONE) + return -EINVAL; + break; + default: + sdata_err(sta->sdata, "invalid smd state %d", new_ss); + return -EINVAL; + } + + sta_dbg(sta->sdata, "moving STA %pM SMD state %u -> %u\n", + sta->sta.addr, old_ss, new_ss); + + notify_driver = notify && test_sta_flag(sta, WLAN_STA_INSERTED); + + if (new_ss > old_ss && notify_driver) { + err = drv_sta_smd_state(local, sta->sdata, &sta->sta, old_ss, + new_ss); + if (err) + return err; + } + + if (new_ss < old_ss && notify_driver) { + err = drv_sta_smd_state(local, sta->sdata, &sta->sta, old_ss, + new_ss); + /* driver should not fail moving down SMD states */ + WARN_ONCE(err, + "Driver should not fail moving down SMD states: %d\n", + err); + } + + sta->smd_state = new_ss; + + return 0; +} + +void sta_info_reset_smd_state(struct sta_info *sta, bool notify) +{ + if (sta->smd_state == IEEE80211_STA_SMD_NONE) + return; + + /* DRAIN -> NONE, EXEC -> NONE or PREP -> NONE */ + WARN_ON_ONCE(sta_info_move_smd_state(sta, IEEE80211_STA_SMD_NONE, + notify)); + + clear_sta_flag(sta, WLAN_STA_SMD_PREP_TARGET); + clear_sta_flag(sta, WLAN_STA_SMD_EXEC_CURRENT); + clear_sta_flag(sta, WLAN_STA_SMD_DL_DRAIN); +} + +int sta_info_move_drv_smd_state(struct sta_info *sta) +{ + enum ieee80211_sta_smd_state new_ss = sta->smd_state; + struct ieee80211_local *local = sta->local; + int err = 0; + + if (!test_sta_flag(sta, WLAN_STA_INSERTED)) + return 0; + + switch (new_ss) { + case IEEE80211_STA_SMD_PREP: + err = drv_sta_smd_state(local, sta->sdata, &sta->sta, + IEEE80211_STA_SMD_NONE, + IEEE80211_STA_SMD_PREP); + if (err) + goto rollback; + break; + case IEEE80211_STA_SMD_EXEC: + case IEEE80211_STA_SMD_DRAIN: + err = drv_sta_smd_state(local, sta->sdata, &sta->sta, + IEEE80211_STA_SMD_NONE, + IEEE80211_STA_SMD_EXEC); + if (err) + goto rollback; + + if (new_ss == IEEE80211_STA_SMD_DRAIN) + err = drv_sta_smd_state(local, sta->sdata, &sta->sta, + IEEE80211_STA_SMD_EXEC, + IEEE80211_STA_SMD_DRAIN); + break; + default: + return -EINVAL; + } + + if (!err) + return 0; + + /* if EXEC -> DRAIN failed in the driver, notify EXEC -> NONE */ + WARN_ON_ONCE(drv_sta_smd_state(local, sta->sdata, &sta->sta, + IEEE80211_STA_SMD_EXEC, + IEEE80211_STA_SMD_NONE)); + +rollback: + sta_info_reset_smd_state(sta, false); + return err; +} diff --git a/net/mac80211/sta_info.h b/net/mac80211/sta_info.h index 89137b18a862..bdc021675727 100644 --- a/net/mac80211/sta_info.h +++ b/net/mac80211/sta_info.h @@ -721,6 +721,7 @@ struct ieee80211_sta_removed_link_stats { * would be assigned to link[link_id] where link_id is the id assigned * by the AP. * @rem_link_stats: accumulated removed link stats + * @smd_state: Sub-state for STAs in SMD BSS Transition */ struct sta_info { /* General information, mostly static */ @@ -797,6 +798,8 @@ struct sta_info { struct link_sta_info __rcu *link[IEEE80211_MLD_MAX_NUM_LINKS]; struct ieee80211_sta_removed_link_stats rem_link_stats; + enum ieee80211_sta_smd_state smd_state; + /* keep last! */ struct ieee80211_sta sta; }; @@ -1169,4 +1172,10 @@ static inline u32 sta_stats_encode_rate(struct ieee80211_rx_status *s) return r; } +int sta_info_move_smd_state(struct sta_info *sta, + enum ieee80211_sta_smd_state new_ss, + bool notify); +void sta_info_reset_smd_state(struct sta_info *sta, bool notify); +int sta_info_move_drv_smd_state(struct sta_info *sta); + #endif /* STA_INFO_H */ diff --git a/net/mac80211/trace.h b/net/mac80211/trace.h index 562a4964afa3..294a8a44a125 100644 --- a/net/mac80211/trace.h +++ b/net/mac80211/trace.h @@ -3403,6 +3403,39 @@ TRACE_EVENT(drv_nan_peer_sched_changed, ) ); +TRACE_EVENT(drv_sta_smd_state, + TP_PROTO(struct ieee80211_local *local, + struct ieee80211_sub_if_data *sdata, + struct ieee80211_sta *sta, + enum ieee80211_sta_smd_state old_state, + enum ieee80211_sta_smd_state new_state), + + TP_ARGS(local, sdata, sta, old_state, new_state), + + TP_STRUCT__entry( + LOCAL_ENTRY + VIF_ENTRY + STA_ENTRY + __field(u32, old_state) + __field(u32, new_state) + ), + + TP_fast_assign( + LOCAL_ASSIGN; + VIF_ASSIGN; + STA_ASSIGN; + __entry->old_state = old_state; + __entry->new_state = new_state; + ), + + TP_printk( + LOCAL_PR_FMT VIF_PR_FMT STA_PR_FMT + " smd_state: %d->%d", + LOCAL_PR_ARG, VIF_PR_ARG, STA_PR_ARG, + __entry->old_state, __entry->new_state + ) +); + #endif /* !__MAC80211_DRIVER_TRACE || TRACE_HEADER_MULTI_READ */ #undef TRACE_INCLUDE_PATH -- 2.34.1