From nobody Fri Oct 6 14:25:14 2023 X-Original-To: dev-commits-src-all@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 4S29gb3yRVz4wgWH; Fri, 6 Oct 2023 14:25:15 +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 4S29gb1D72z3R10; Fri, 6 Oct 2023 14:25:15 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1696602315; 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=xvCHp0SFl5eCXdwdbZtQJJqvrg2lEbneH4EkX3jGB28=; b=j59w7T/+H+e7It3QZrDLaNx+eupvxIqtrS6MLVPgAJAV3pqfofNSPSZf7Zkenv5FmzQFBC spDj9oqPLxHoK3OB/x+q2qtdIoGEk9n+8beFazGXNgIqs2LryibhAM0w6dsHIZXNx+WZCm WFL045LQXHhc8MDSLopFw9pehlsdecYEAA2xUoReWxy1cGu5+EFCAGW008tXi5jVCACGIk A6Z+Tz4GHT6KriL1UMNDP6OK/bggDZWfMvm19dsKKY1HCzOr9IhrEW9JYY4ej2buZhy83C w6edcEmdNybjjslLVBBefcVPbqSB1BSdm7CHuDBwbn8sEW2UPOMD3J9yLiWaxg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1696602315; a=rsa-sha256; cv=none; b=EAV4rqdBhdS8Vr3xpYaDOfMnk9fkUJ340JiPzbDeQ79VWv0Zmi7w1JErtgA82QWpj/9roP 60c7iklGbipqRxzTbohV3PStfLUkfPst2fGqoONuey3tZjy17ZuseKfSoPIrF3EKdLxk12 qXGo7xF4UnaAP4hmqn9SzvkKrfVw3W+nkYo8Bv8Ycylw75xzFOq60gl9DNt+yaJLMsCC1D eOIBVawIbEXIcDa3VTYX8pIH+puDthBqkXABSaa76pW8Q7+X6QDEsqrtxgyBu9aH8D4dzj +Tvcmr9v2ZdqTdeuxY7ntORL6c2nStxlyr/nD55UdqCT6T3UuuaPOZOsZafnxQ== 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=1696602315; 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=xvCHp0SFl5eCXdwdbZtQJJqvrg2lEbneH4EkX3jGB28=; b=Z9e1SZQbfg/seW7FPQaHv4zJnDm0PNbO8aoq7+tY+Ef4vl+e3MVkQLP1W3ve+iN2gcN2Ad jM/URBn1MSS7sCKLBQ5n7G6beYh0OaQ+g5kq2Hdc+nSlj1imr6PVPowmK2e2glZInXpqGW 85WJu7/0U2vvcWQ06Zw/Z0j4LwXNH4TDLEm39I/4nTX4qabybDxeD/BLCNg4N6+0n7qmZD T1JLIvwr9vOWoIlFFZRt9VoFlojpbGCzJqO8GhnwqWfCeWVuCKuAdP3T1A1EmCyHIDPGqh u5HBp2SX1dmmsKryaXFvsWUO+hkSGAnHx3thpSrkWsvq/rLfQthTbVYA4Tr34Q== 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 4S29gb0LHbzrXK; Fri, 6 Oct 2023 14:25:15 +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 396EPE00093507; Fri, 6 Oct 2023 14:25:14 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 396EPE7D093504; Fri, 6 Oct 2023 14:25:14 GMT (envelope-from git) Date: Fri, 6 Oct 2023 14:25:14 GMT Message-Id: <202310061425.396EPE7D093504@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: 4e26de26431b - stable/14 - LinuxKPI: 802.11: fix problem removing sta List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@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/stable/14 X-Git-Reftype: branch X-Git-Commit: 4e26de26431be8b830ef9d2d2397490b68437ddd Auto-Submitted: auto-generated The branch stable/14 has been updated by bz: URL: https://cgit.FreeBSD.org/src/commit/?id=4e26de26431be8b830ef9d2d2397490b68437ddd commit 4e26de26431be8b830ef9d2d2397490b68437ddd Author: Bjoern A. Zeeb AuthorDate: 2023-09-30 07:59:48 +0000 Commit: Bjoern A. Zeeb CommitDate: 2023-10-06 12:47:40 +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 (cherry picked from commit 16e688b2a403a3dbc05de3b9f8a3132838613790) --- 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 d2f67230a812..9f5f5bef7f27 100644 --- a/sys/compat/linuxkpi/common/src/linux_80211.c +++ b/sys/compat/linuxkpi/common/src/linux_80211.c @@ -1426,6 +1426,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 " @@ -1435,15 +1444,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; @@ -1887,6 +1889,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 " @@ -1896,18 +1905,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;