From nobody Mon Oct 9 23:16:21 2023 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4S4FK21rPqz4wgkk; Mon, 9 Oct 2023 23:16:22 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4S4FK213cxz3QqT; Mon, 9 Oct 2023 23:16:22 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1696893382; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=7FISqBxpOOxpptV8GiJYEQJWIf+cjIUhuo7SeXr8QKM=; b=Zjds0CL3di4CDPfyPiwtpSG2EgbhvuUEzxEvYQofGSHjoe9nLc1BLodCG//WA6fP4Vrq1A 1tfO9irXfc6bIrResCOLsX+y+98+xdPg42U9kej7s6jMIfSn6EmGVnIUo0my0Kkkl/N/Dj uBdVwjLFPX3q51SszEBSp0LxSQjdNkOQByvb3uEq7WQF4s6Gt2F5SaNVnglLIArBD3UXR8 i/DPttcYQGRAcvOHgXZvrH/ETCaJr9T3nCbV8OC/FJvHQVCXn7TJbeXATdeT/fQsI4zXCf VGfDJX6zGKWdCLLgv/rw1mK6AnSjR26UgRSWSiQsajvWHybZ4GZAI4TKuUbU3g== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1696893382; a=rsa-sha256; cv=none; b=bG+uYqQSvTpD3QbJMLtD3XS2fvXnqbm6OZ/fvzCSsiMp1UTvVgrBd9dls/pmV1Akv1fCtp hPdquTOCyp7ZHTfryrczLjKymMg3aDYJPCOTPKN2SzJdEntxsHPCurjJk8YrZjaqKFYBSu wEWZZaZseiJw6ayguOuZ6NqrPPocoEyvRaFshXYwT6fnX3/Vg+Y+f5WjLxttTP6iaO+i6A u6xko5+QkHkiAyc2eZE67rgHpqwA4I54Ypm1BugJgJnx4qJ/77b8Waq/IypKye250xXE+t Ez8HJ7pq5lG/YgRen8/k8spYG9/7jyCDldj5LAUh6xhfzU95dN7WHOrGX/P45g== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1696893382; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=7FISqBxpOOxpptV8GiJYEQJWIf+cjIUhuo7SeXr8QKM=; b=yrn26DgVqPnzA7FMY/vqWLYHFkNZoA+kiRTi7ku1GLf56U9DznH7zwslZHTp6pF1RNulUV Rb+OgXW4gf/lX/xgi3NhR8nyb7Q2T42gJudj9GuAtzHQoqFk+e2lKoKR2/qpLFN5+FqFAR zUQhZ5IQ/lebZbzut7Zx2s3ly9O7l3kaB33oK7BBp5+wXsYXAtau5faYr7z1c4iLMRiX93 5jovHWQ4tdJU6obeQVWFSPGM89cqM6fcquhcYj5bXowFZLs3MOlOL2DKMnTUhR3qP23/g9 ASsFZbffvwdplX59VbXfTm38yCXaSvpY/qW+GMCI4Snd/e3nitkjnodsCEkRNw== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4S4FK209Cyzn6; Mon, 9 Oct 2023 23:16:22 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 399NGLO1071572; Mon, 9 Oct 2023 23:16:21 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 399NGLKR071569; Mon, 9 Oct 2023 23:16:21 GMT (envelope-from git) Date: Mon, 9 Oct 2023 23:16:21 GMT Message-Id: <202310092316.399NGLKR071569@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: "Bjoern A. Zeeb" Subject: git: 0b2982dcef77 - releng/14.0 - LinuxKPI: 802.11: fix problem removing sta List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: bz X-Git-Repository: src X-Git-Refname: refs/heads/releng/14.0 X-Git-Reftype: branch X-Git-Commit: 0b2982dcef77584dadf4d6c0eae276c67c67e925 Auto-Submitted: auto-generated The branch releng/14.0 has been updated by bz: URL: https://cgit.FreeBSD.org/src/commit/?id=0b2982dcef77584dadf4d6c0eae276c67c67e925 commit 0b2982dcef77584dadf4d6c0eae276c67c67e925 Author: Bjoern A. Zeeb AuthorDate: 2023-09-30 07:59:48 +0000 Commit: Bjoern A. Zeeb CommitDate: 2023-10-09 23:14:54 +0000 LinuxKPI: 802.11: fix problem removing sta Move the call to lkpi_disassoc() before the state change to IEEE80211_STA_NOTEXIST which will remove the sta (from firmware). Based on a comment it seems that originally we had to do it the other way round. iwlwifi(4) has a check and will silently not remove the sta from the firmware when vif->cfg.assoc is still set (see iwl_mvm_sta_del()). This leads to the LinuxKPI 802.11 code thinking the sta is gone as downward state changes by the mac80211 op (*sta_state)() may not fail. Once we try to assoc with a newly added station later, iwlwifi firmware will run into an assert having two ap_sta set on the same vif. We can observe that problem in iwlwifi(4) having __le32 sta_id = 1 instead of sta_id = 0 in iwl_mvm_sta_cfg_cmd{} on the HCMD. This should fix one of the most seen problems with iwlwifi(4), e.g., when running service netif restart wlan0 or service wpa_supplicant restart wlan0. Sponsored by: The FreeBSD Foundation Approved by: re (gjb) (cherry picked from commit 16e688b2a403a3dbc05de3b9f8a3132838613790) (cherry picked from commit 4e26de26431be8b830ef9d2d2397490b68437ddd) --- sys/compat/linuxkpi/common/src/linux_80211.c | 37 ++++++++++++++-------------- 1 file changed, 18 insertions(+), 19 deletions(-) diff --git a/sys/compat/linuxkpi/common/src/linux_80211.c b/sys/compat/linuxkpi/common/src/linux_80211.c index ac43b1248536..b3ee07a9bab9 100644 --- a/sys/compat/linuxkpi/common/src/linux_80211.c +++ b/sys/compat/linuxkpi/common/src/linux_80211.c @@ -1410,6 +1410,15 @@ _lkpi_sta_assoc_to_down(struct ieee80211vap *vap, enum ieee80211_state nstate, i lkpi_lsta_dump(lsta, ni, __func__, __LINE__); + /* Update bss info (bss_info_changed) (assoc, aid, ..). */ + /* + * We need to do this now, before sta changes to IEEE80211_STA_NOTEXIST + * as otherwise drivers (iwlwifi at least) will silently not remove + * the sta from the firmware and when we will add a new one trigger + * a fw assert. + */ + lkpi_disassoc(sta, vif, lhw); + /* Adjust sta and change state (from NONE) to NOTEXIST. */ KASSERT(lsta != NULL, ("%s: ni %p lsta is NULL\n", __func__, ni)); KASSERT(lsta->state == IEEE80211_STA_NONE, ("%s: lsta %p state not " @@ -1419,15 +1428,8 @@ _lkpi_sta_assoc_to_down(struct ieee80211vap *vap, enum ieee80211_state nstate, i IMPROVE("do we need to undo the chan ctx?"); goto out; } -#if 0 - lsta->added_to_drv = false; /* mo manages. */ -#endif - lkpi_lsta_dump(lsta, ni, __func__, __LINE__); - - /* Update bss info (bss_info_changed) (assoc, aid, ..). */ - /* We need to do this now, can only do after sta is IEEE80211_STA_NOTEXIST. */ - lkpi_disassoc(sta, vif, lhw); + lkpi_lsta_dump(lsta, ni, __func__, __LINE__); /* sta no longer save to use. */ IMPROVE("Any bss_info changes to announce?"); bss_changed = 0; @@ -1869,6 +1871,13 @@ lkpi_sta_run_to_init(struct ieee80211vap *vap, enum ieee80211_state nstate, int lkpi_lsta_dump(lsta, ni, __func__, __LINE__); + /* Update bss info (bss_info_changed) (assoc, aid, ..). */ + /* + * One would expect this to happen when going off AUTHORIZED. + * See comment there; removes the sta from fw. + */ + lkpi_disassoc(sta, vif, lhw); + /* Adjust sta and change state (from NONE) to NOTEXIST. */ KASSERT(lsta != NULL, ("%s: ni %p lsta is NULL\n", __func__, ni)); KASSERT(lsta->state == IEEE80211_STA_NONE, ("%s: lsta %p state not " @@ -1878,18 +1887,8 @@ lkpi_sta_run_to_init(struct ieee80211vap *vap, enum ieee80211_state nstate, int IMPROVE("do we need to undo the chan ctx?"); goto out; } -#if 0 - lsta->added_to_drv = false; /* mo manages. */ -#endif - lkpi_lsta_dump(lsta, ni, __func__, __LINE__); - - /* Update bss info (bss_info_changed) (assoc, aid, ..). */ - /* - * One would expect this to happen when going off AUTHORIZED. - * See comment there; removes the sta from fw. - */ - lkpi_disassoc(sta, vif, lhw); + lkpi_lsta_dump(lsta, ni, __func__, __LINE__); /* sta no longer save to use. */ IMPROVE("Any bss_info changes to announce?"); bss_changed = 0;