From nobody Sat Sep 03 23:47:51 2022 X-Original-To: dev-commits-src-main@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 4MKs0R5Kdcz4bw7j; Sat, 3 Sep 2022 23:47:51 +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 4MKs0R4rf7z4NM1; Sat, 3 Sep 2022 23:47:51 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1662248871; 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=tkYNbRWEZJxP8WQ1wMiYixwaNdWXa0pvkOsngWbOO4s=; b=fU83y5NCxzUti+gnWE+t3c5UOiNQZM2rzj/QZUwshqxWOSwNZDiaEN6iG3Os7IKuwIOWCS 4iSTEmv9EK1cxX4G5Y3O4jnxzgXt/rqnQGrg9dFKMdxA+Eekv24tR18CQZF8t1UoAm4UZD q+ftNKn/tX2qcnrsuEl96Y0dQXoYmVfbggNm9mtFuBTX5x2UDBmomj86lWYXKyqiUpkZ7Q Fg/gHEsg7+ybe5Ky4gSR5h+EDZi+TYyWLNLne2E3vpaebPkzDkm2+6jm77SRxRBlZs1zNB MYO+1gtiKQEYvNUG/moPjGFHHtoCPExMwfNGm7YbJ9+gU3mxqwz6eLuklngr3g== 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 4MKs0R3w1hzJY7; Sat, 3 Sep 2022 23:47:51 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 283NlpvQ071024; Sat, 3 Sep 2022 23:47:51 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 283NlpRM071023; Sat, 3 Sep 2022 23:47:51 GMT (envelope-from git) Date: Sat, 3 Sep 2022 23:47:51 GMT Message-Id: <202209032347.283NlpRM071023@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: "Bjoern A. Zeeb" Subject: git: a486fbbd7876 - main - LinuxKPI: 80211: scanning code updates List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@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/main X-Git-Reftype: branch X-Git-Commit: a486fbbd7876bed81d738a32274953c89906edb5 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1662248871; 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=tkYNbRWEZJxP8WQ1wMiYixwaNdWXa0pvkOsngWbOO4s=; b=vW0S/k2iSXdNelv3Lp+AXOnRAWIdFTWpPySM7VWVqGk4dkDc+7uvG84LO33/qgbtXeynnK h5KnFmeel8eCPlYjFuiw70ucDYWsBpc48TJWIUZnWDXoozqN886C6XlpO0e6yChy+cEIEl hoUGfOlCGQjWd4oN0fE1VeaqCOEPXzLkQ0wS/XLsIkFSGT8AM9n+H7rhhmHfXybUarQ1Tl MvzUb/q72kzkN6i418eYVjbVVHV4YiqIsClxzzYQhzZfNlBfoWWAqFAnpVgjxgNu8rr+WO So5QFn8YzPVceZ0SXPypWekknMBxA8rDg0XYHpdykg0Le3/FybBjncDH+Ds1aQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1662248871; a=rsa-sha256; cv=none; b=H7Thn9jG1Q65w4sNEK+XbplLVp2xdSxp95u3kWiHkswhMzgfQmsnqrtDVIwtetXzU/e87A Hnrsa4TSJOIyf+tfV7h437meoxrAfHB0bxJ6VmWkha4Cj2WZCTHCGLmTfE03/p8N4Yudxv ZVSmwvV8ibh4NTmwzVrFt0UYbezLAa0wM4lctuXFUVlRqjAdfuEHIfszCMFiD6qYC4B0C9 v3SP9r7nvekCA1EKYmPxOCXcH5uubh0DhTE5xKcQrDkbVMz/MMBj0/ngq7ttPBDAhIi5Yt T8saGYAsNNQrdx8OVvtCt43H04RkJ+y9JAH6C9jWJwza8wsLdOvfuJqXBmgLJA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by bz: URL: https://cgit.FreeBSD.org/src/commit/?id=a486fbbd7876bed81d738a32274953c89906edb5 commit a486fbbd7876bed81d738a32274953c89906edb5 Author: Bjoern A. Zeeb AuthorDate: 2022-09-03 23:40:51 +0000 Commit: Bjoern A. Zeeb CommitDate: 2022-09-03 23:40:51 +0000 LinuxKPI: 80211: scanning code updates For consistency rename LKPI_SCAN_RUNNING adding a LHW_ prefix. Add a local flag LKPI_LHW_SCAN_HW mirroring the net80211 IEEE80211_FEXT_SCAN_OFFLOAD flag. Slightly simplify the code. Overload (*ic_scan_curchan) and (*ic_scan_mindwell) so that we can call the net80211 implementation in case of software scan but skip it in case of full-offload scans. Also add a bandaid to our (*ic_set_channel) implementation to not siwtch channels if we have an active hw_scan running. Obtained from: bz/wireless-dev Sponsored by: The FreeBSD Foundation (partially) MFC after: 4 days --- sys/compat/linuxkpi/common/src/linux_80211.c | 61 +++++++++++++++++----- sys/compat/linuxkpi/common/src/linux_80211.h | 8 ++- .../linuxkpi/common/src/linux_80211_macops.c | 6 +-- 3 files changed, 57 insertions(+), 18 deletions(-) diff --git a/sys/compat/linuxkpi/common/src/linux_80211.c b/sys/compat/linuxkpi/common/src/linux_80211.c index b4d9997897f8..197973cf5163 100644 --- a/sys/compat/linuxkpi/common/src/linux_80211.c +++ b/sys/compat/linuxkpi/common/src/linux_80211.c @@ -797,7 +797,7 @@ lkpi_stop_hw_scan(struct lkpi_hw *lhw, struct ieee80211_vif *vif) struct ieee80211_hw *hw; int error; - if ((lhw->scan_flags & LKPI_SCAN_RUNNING) == 0) + if ((lhw->scan_flags & LKPI_LHW_SCAN_RUNNING) == 0) return; hw = LHW_TO_HW(lhw); @@ -812,7 +812,7 @@ lkpi_stop_hw_scan(struct lkpi_hw *lhw, struct ieee80211_vif *vif) LKPI_80211_LHW_UNLOCK(lhw); IEEE80211_LOCK(lhw->ic); - if ((lhw->scan_flags & LKPI_SCAN_RUNNING) != 0) + if ((lhw->scan_flags & LKPI_LHW_SCAN_RUNNING) != 0) ic_printf(lhw->ic, "%s: failed to cancel scan: %d (%p, %p)\n", __func__, error, lhw, vif); } @@ -2514,7 +2514,7 @@ lkpi_ic_scan_start(struct ieee80211com *ic) int error; lhw = ic->ic_softc; - if ((lhw->scan_flags & LKPI_SCAN_RUNNING) != 0) { + if ((lhw->scan_flags & LKPI_LHW_SCAN_RUNNING) != 0) { /* A scan is still running. */ return; } @@ -2527,7 +2527,9 @@ lkpi_ic_scan_start(struct ieee80211com *ic) } hw = LHW_TO_HW(lhw); - if ((vap->iv_flags_ext & IEEE80211_FEXT_SCAN_OFFLOAD) == 0) { + if ((lhw->scan_flags & LKPI_LHW_SCAN_HW) == 0) { + /* If hw_scan is cleared clear FEXT_SCAN_OFFLOAD too. */ + vap->iv_flags_ext &= ~IEEE80211_FEXT_SCAN_OFFLOAD; sw_scan: lvif = VAP_TO_LVIF(vap); vif = LVIF_TO_VIF(lvif); @@ -2670,7 +2672,7 @@ sw_scan: * not possible. Fall back to sw scan in that case. */ if (error == 1) { - vap->iv_flags_ext &= ~IEEE80211_FEXT_SCAN_OFFLOAD; + lhw->scan_flags &= ~LKPI_LHW_SCAN_HW; ieee80211_start_scan(vap, IEEE80211_SCAN_ACTIVE | IEEE80211_SCAN_NOPICK | @@ -2692,26 +2694,25 @@ static void lkpi_ic_scan_end(struct ieee80211com *ic) { struct lkpi_hw *lhw; - struct ieee80211_scan_state *ss; - struct ieee80211vap *vap; lhw = ic->ic_softc; - if ((lhw->scan_flags & LKPI_SCAN_RUNNING) == 0) { + if ((lhw->scan_flags & LKPI_LHW_SCAN_RUNNING) == 0) { return; } - ss = ic->ic_scan; - vap = ss->ss_vap; - if (vap->iv_flags_ext & IEEE80211_FEXT_SCAN_OFFLOAD) { - /* Nothing to do. */ - } else { + if ((lhw->scan_flags & LKPI_LHW_SCAN_HW) == 0) { + struct ieee80211_scan_state *ss; + struct ieee80211vap *vap; struct ieee80211_hw *hw; struct lkpi_vif *lvif; struct ieee80211_vif *vif; + ss = ic->ic_scan; + vap = ss->ss_vap; hw = LHW_TO_HW(lhw); lvif = VAP_TO_LVIF(vap); vif = LVIF_TO_VIF(lvif); + lkpi_80211_mo_sw_scan_complete(hw, vif); /* Send PS to stop buffering if n80211 does not for us? */ @@ -2721,6 +2722,27 @@ lkpi_ic_scan_end(struct ieee80211com *ic) } } +static void +lkpi_ic_scan_curchan(struct ieee80211_scan_state *ss, + unsigned long maxdwell) +{ + struct lkpi_hw *lhw; + + lhw = ss->ss_ic->ic_softc; + if ((lhw->scan_flags & LKPI_LHW_SCAN_HW) == 0) + lhw->ic_scan_curchan(ss, maxdwell); +} + +static void +lkpi_ic_scan_mindwell(struct ieee80211_scan_state *ss) +{ + struct lkpi_hw *lhw; + + lhw = ss->ss_ic->ic_softc; + if ((lhw->scan_flags & LKPI_LHW_SCAN_HW) == 0) + lhw->ic_scan_mindwell(ss); +} + static void lkpi_ic_set_channel(struct ieee80211com *ic) { @@ -2736,6 +2758,11 @@ lkpi_ic_set_channel(struct ieee80211com *ic) if (lhw->ops->config == NULL) return; + /* If we have a hw_scan running do not switch channels. */ + if ((lhw->scan_flags & (LKPI_LHW_SCAN_RUNNING|LKPI_LHW_SCAN_HW)) == + (LKPI_LHW_SCAN_RUNNING|LKPI_LHW_SCAN_HW)) + return; + c = ic->ic_curchan; if (c == NULL || c == IEEE80211_CHAN_ANYC) { ic_printf(ic, "%s: c %p ops->config %p\n", __func__, @@ -3482,6 +3509,7 @@ linuxkpi_ieee80211_ifattach(struct ieee80211_hw *hw) * the flag. */ ic->ic_flags_ext |= IEEE80211_FEXT_SCAN_OFFLOAD; + lhw->scan_flags |= LKPI_LHW_SCAN_HW; } #ifdef __notyet__ @@ -3540,6 +3568,11 @@ linuxkpi_ieee80211_ifattach(struct ieee80211_hw *hw) ic->ic_getradiocaps = lkpi_ic_getradiocaps; ic->ic_wme.wme_update = lkpi_ic_wme_update; + lhw->ic_scan_curchan = ic->ic_scan_curchan; + ic->ic_scan_curchan = lkpi_ic_scan_curchan; + lhw->ic_scan_mindwell = ic->ic_scan_mindwell; + ic->ic_scan_mindwell = lkpi_ic_scan_mindwell; + lhw->ic_node_alloc = ic->ic_node_alloc; ic->ic_node_alloc = lkpi_ic_node_alloc; lhw->ic_node_init = ic->ic_node_init; @@ -3781,7 +3814,7 @@ linuxkpi_ieee80211_scan_completed(struct ieee80211_hw *hw, LKPI_80211_LHW_LOCK(lhw); free(lhw->hw_req, M_LKPI80211); lhw->hw_req = NULL; - lhw->scan_flags &= ~LKPI_SCAN_RUNNING; + lhw->scan_flags &= ~LKPI_LHW_SCAN_RUNNING; wakeup(lhw); LKPI_80211_LHW_UNLOCK(lhw); diff --git a/sys/compat/linuxkpi/common/src/linux_80211.h b/sys/compat/linuxkpi/common/src/linux_80211.h index c6958cf834e3..65e78ba0fc08 100644 --- a/sys/compat/linuxkpi/common/src/linux_80211.h +++ b/sys/compat/linuxkpi/common/src/linux_80211.h @@ -144,6 +144,11 @@ struct lkpi_hw { /* name it mac80211_sc? */ struct mtx mtx; + /* Scan functions we overload to handle depending on scan mode. */ + void (*ic_scan_curchan)(struct ieee80211_scan_state *, + unsigned long); + void (*ic_scan_mindwell)(struct ieee80211_scan_state *); + /* Node functions we overload to sync state. */ struct ieee80211_node * (*ic_node_alloc)(struct ieee80211vap *, const uint8_t [IEEE80211_ADDR_LEN]); @@ -153,7 +158,8 @@ struct lkpi_hw { /* name it mac80211_sc? */ #define LKPI_MAC80211_DRV_STARTED 0x00000001 uint32_t sc_flags; -#define LKPI_SCAN_RUNNING 0x00000001 +#define LKPI_LHW_SCAN_RUNNING 0x00000001 +#define LKPI_LHW_SCAN_HW 0x00000002 uint32_t scan_flags; int supbands; /* Number of supported bands. */ diff --git a/sys/compat/linuxkpi/common/src/linux_80211_macops.c b/sys/compat/linuxkpi/common/src/linux_80211_macops.c index 12cffc11481e..547b94be66c2 100644 --- a/sys/compat/linuxkpi/common/src/linux_80211_macops.c +++ b/sys/compat/linuxkpi/common/src/linux_80211_macops.c @@ -205,10 +205,10 @@ lkpi_80211_mo_hw_scan(struct ieee80211_hw *hw, struct ieee80211_vif *vif, goto out; } - lhw->scan_flags |= LKPI_SCAN_RUNNING; + lhw->scan_flags |= LKPI_LHW_SCAN_RUNNING; error = lhw->ops->hw_scan(hw, vif, sr); if (error != 0) - lhw->scan_flags &= ~LKPI_SCAN_RUNNING; + lhw->scan_flags &= ~LKPI_LHW_SCAN_RUNNING; out: return (error); @@ -236,7 +236,7 @@ lkpi_80211_mo_sw_scan_complete(struct ieee80211_hw *hw, struct ieee80211_vif *vi return; lhw->ops->sw_scan_complete(hw, vif); - lhw->scan_flags &= ~LKPI_SCAN_RUNNING; + lhw->scan_flags &= ~LKPI_LHW_SCAN_RUNNING; } void