From nobody Fri Apr 11 21:26:17 2025 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 4ZZ8r96CHpz5shkp; Fri, 11 Apr 2025 21:26:17 +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 "R10" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4ZZ8r942xqz3t7m; Fri, 11 Apr 2025 21:26:17 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1744406777; 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=QfLXD8Mb5D4iVFPqmKfHFxzbkBLgahObJPSm7FKf0rc=; b=TH6glr4edjF2ucotjrQZmX3cFw3mA0+6Ir+OWW3IEqTtMG9BNpwq0OHgWtzR+Ww6zL4WuO vhgPiqSfu9FyMRMgg8bR5BDGbEqYkPnDg7TYdy5K0W2KddFLlbOExsKmCkyAQMTUCMrN33 Dnap0PgOOJkV9HMUllGO+FHggMxOT7XyQpycAyM80F06vfGGGHFXrcymbFXqwtbho2hpbD aTBMSGgiW5RYEX3XH9A017+J8V0+pF99epZGnSyCSburCdc9NCJ5hc2F/TUiZOQKdT+2/g NTE4w7wPd8Q6pk6g14p/2oaqWKTwU6uZ1sVkTjIXOtUUa2I8nCgWW4yxF5nHsw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1744406777; a=rsa-sha256; cv=none; b=wJZ+JMY6XsnyLh74ECRvzPRNno7q3PwbmGY5QtaO8JcniG0Qf5STbRSgwRVuVnAhH+nAWd MmPH78dzmYCw3SE2TExdaX19ctdWaaYgb+NZBcQDQexoiPCz5mLkNjw1uQLRDSv8byEiir PBg4ySt4kgJAb2whzL/necpweX3PJwxM9X6UxICfCi8QJMXxpIphaPiA/9bXa0V+j8B8kr hqCLGgmovZuIKB90sPPlAc4V2cV8ZOu2BqVEi3RsGiin7zb0gQXvotcGdvsJa2ZHUNYwTV PGTnS2opCFiYFBqfLglJ8ebmJ+A7uoJx2wVwVpgAQ6kfVh6g1Ob9Nt7g5zqKZw== 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=1744406777; 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=QfLXD8Mb5D4iVFPqmKfHFxzbkBLgahObJPSm7FKf0rc=; b=g0A8N+bQCGZPlfxTzyFvMAP3M3AmmH4im0kG+TRvgas+hVhoDf9rdQAOhiJNH8UGgq/uCq ZoyT8q60PPRN4oUncXkwGx3ABSQk6Alm3mJoHqAlBjRg3EVR0R5Y640k0Q+3WOBqGrAcRK wZupfExjkRLpGTJctDZ0KOCoUhqTw6OZiurB86XVAbqRhr7Z4hkndJ6NWwR2cM4iuPfSFG JztMqSQFEaiDLMzLvekudy93GcKG2iRpcP04ocwInu3OV37bOS54XkBO8NS6S3B1ByVT0r SXjk8q3QJ/miGdwJKsHyBR493kLKFAWatLeoGUwvL3Fcx517w3WkoN1oH7RJDg== 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 4ZZ8r93SRkzpgw; Fri, 11 Apr 2025 21:26:17 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 53BLQHmw078123; Fri, 11 Apr 2025 21:26:17 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 53BLQHi2078120; Fri, 11 Apr 2025 21:26:17 GMT (envelope-from git) Date: Fri, 11 Apr 2025 21:26:17 GMT Message-Id: <202504112126.53BLQHi2078120@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: 50d826be664e - main - LinuxKPI: 802.11: reduce code duplication introducing lkpi_remove_chanctx() 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: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-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/main X-Git-Reftype: branch X-Git-Commit: 50d826be664ef35065e8c4c4966252f2dfde9cb9 Auto-Submitted: auto-generated The branch main has been updated by bz: URL: https://cgit.FreeBSD.org/src/commit/?id=50d826be664ef35065e8c4c4966252f2dfde9cb9 commit 50d826be664ef35065e8c4c4966252f2dfde9cb9 Author: Bjoern A. Zeeb AuthorDate: 2025-04-05 23:59:00 +0000 Commit: Bjoern A. Zeeb CommitDate: 2025-04-11 21:17:24 +0000 LinuxKPI: 802.11: reduce code duplication introducing lkpi_remove_chanctx() We have the same code three times, so factor it out into its own function to make it easier to maintain. Sponsored by: The FreeBSD Foundation PR: 280546 MFC after: 3 days Tested by: Oleksandr Kryvulia (shuriku shurik.kiev.ua) Tested by: Oleg Nauman (oleg.nauman gmail.com) [rtw88] Differential Revision: https://reviews.freebsd.org/D49734 --- sys/compat/linuxkpi/common/include/net/mac80211.h | 2 +- sys/compat/linuxkpi/common/src/linux_80211.c | 80 ++++++++--------------- 2 files changed, 30 insertions(+), 52 deletions(-) diff --git a/sys/compat/linuxkpi/common/include/net/mac80211.h b/sys/compat/linuxkpi/common/include/net/mac80211.h index 5c155a4c1cc8..95991dd2ac42 100644 --- a/sys/compat/linuxkpi/common/include/net/mac80211.h +++ b/sys/compat/linuxkpi/common/include/net/mac80211.h @@ -839,7 +839,7 @@ struct ieee80211_vif { bool probe_req_reg; uint8_t addr[ETH_ALEN]; struct ieee80211_vif_cfg cfg; - struct ieee80211_chanctx_conf *chanctx_conf; + struct ieee80211_chanctx_conf *chanctx_conf; /* XXX-BZ no longer used anywhere but in linuxkpi 802.11 internally; now in bss_conf per-link? */ struct ieee80211_txq *txq; struct ieee80211_bss_conf bss_conf; struct ieee80211_bss_conf *link_conf[IEEE80211_MLD_MAX_NUM_LINKS]; /* rcu? */ diff --git a/sys/compat/linuxkpi/common/src/linux_80211.c b/sys/compat/linuxkpi/common/src/linux_80211.c index ec1798d2e886..5c50060e3dc0 100644 --- a/sys/compat/linuxkpi/common/src/linux_80211.c +++ b/sys/compat/linuxkpi/common/src/linux_80211.c @@ -1731,6 +1731,31 @@ lkpi_80211_flush_tx(struct lkpi_hw *lhw, struct lkpi_sta *lsta) } } + +static void +lkpi_remove_chanctx(struct ieee80211_hw *hw, struct ieee80211_vif *vif) +{ + /* Take the chan ctx down. */ + if (vif->chanctx_conf != NULL) { + struct lkpi_chanctx *lchanctx; + struct ieee80211_chanctx_conf *chanctx_conf; + + chanctx_conf = vif->chanctx_conf; + /* Remove vif context. */ + lkpi_80211_mo_unassign_vif_chanctx(hw, vif, &vif->bss_conf, &vif->chanctx_conf); + /* NB: vif->chanctx_conf is NULL now. */ + + lkpi_hw_conf_idle(hw, true); + + /* Remove chan ctx. */ + lkpi_80211_mo_remove_chanctx(hw, chanctx_conf); + vif->bss_conf.chanctx_conf = NULL; + lchanctx = CHANCTX_CONF_TO_LCHANCTX(chanctx_conf); + free(lchanctx, M_LKPI80211); + } +} + + /* -------------------------------------------------------------------------- */ static int @@ -1924,6 +1949,7 @@ lkpi_sta_scan_to_auth(struct ieee80211vap *vap, enum ieee80211_state nstate, int ic_printf(vap->iv_ic, "%s:%d: mo_assign_vif_chanctx " "failed: %d\n", __func__, __LINE__, error); lkpi_80211_mo_remove_chanctx(hw, chanctx_conf); + vif->bss_conf.chanctx_conf = NULL; lchanctx = CHANCTX_CONF_TO_LCHANCTX(chanctx_conf); free(lchanctx, M_LKPI80211); goto out; @@ -2157,23 +2183,7 @@ lkpi_sta_auth_to_scan(struct ieee80211vap *vap, enum ieee80211_state nstate, int /* conf_tx */ - /* Take the chan ctx down. */ - if (vif->chanctx_conf != NULL) { - struct lkpi_chanctx *lchanctx; - struct ieee80211_chanctx_conf *chanctx_conf; - - chanctx_conf = vif->chanctx_conf; - /* Remove vif context. */ - lkpi_80211_mo_unassign_vif_chanctx(hw, vif, &vif->bss_conf, &vif->chanctx_conf); - /* NB: vif->chanctx_conf is NULL now. */ - - lkpi_hw_conf_idle(hw, true); - - /* Remove chan ctx. */ - lkpi_80211_mo_remove_chanctx(hw, chanctx_conf); - lchanctx = CHANCTX_CONF_TO_LCHANCTX(chanctx_conf); - free(lchanctx, M_LKPI80211); - } + lkpi_remove_chanctx(hw, vif); out: LKPI_80211_LHW_UNLOCK(lhw); @@ -2501,23 +2511,7 @@ _lkpi_sta_assoc_to_down(struct ieee80211vap *vap, enum ieee80211_state nstate, i /* conf_tx */ - /* Take the chan ctx down. */ - if (vif->chanctx_conf != NULL) { - struct lkpi_chanctx *lchanctx; - struct ieee80211_chanctx_conf *chanctx_conf; - - chanctx_conf = vif->chanctx_conf; - /* Remove vif context. */ - lkpi_80211_mo_unassign_vif_chanctx(hw, vif, &vif->bss_conf, &vif->chanctx_conf); - /* NB: vif->chanctx_conf is NULL now. */ - - lkpi_hw_conf_idle(hw, true); - - /* Remove chan ctx. */ - lkpi_80211_mo_remove_chanctx(hw, chanctx_conf); - lchanctx = CHANCTX_CONF_TO_LCHANCTX(chanctx_conf); - free(lchanctx, M_LKPI80211); - } + lkpi_remove_chanctx(hw, vif); error = EALREADY; out: @@ -3117,23 +3111,7 @@ lkpi_sta_run_to_init(struct ieee80211vap *vap, enum ieee80211_state nstate, int /* conf_tx */ - /* Take the chan ctx down. */ - if (vif->chanctx_conf != NULL) { - struct lkpi_chanctx *lchanctx; - struct ieee80211_chanctx_conf *chanctx_conf; - - chanctx_conf = vif->chanctx_conf; - /* Remove vif context. */ - lkpi_80211_mo_unassign_vif_chanctx(hw, vif, &vif->bss_conf, &vif->chanctx_conf); - /* NB: vif->chanctx_conf is NULL now. */ - - lkpi_hw_conf_idle(hw, true); - - /* Remove chan ctx. */ - lkpi_80211_mo_remove_chanctx(hw, chanctx_conf); - lchanctx = CHANCTX_CONF_TO_LCHANCTX(chanctx_conf); - free(lchanctx, M_LKPI80211); - } + lkpi_remove_chanctx(hw, vif); error = EALREADY; out: