git: 57764d222865 - stable/14 - LinuxKPI: 802.11: reduce code duplication introducing lkpi_remove_chanctx()
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Fri, 18 Apr 2025 14:37:11 UTC
The branch stable/14 has been updated by bz: URL: https://cgit.FreeBSD.org/src/commit/?id=57764d222865c1182dd9bab55fda4e4c012ba56b commit 57764d222865c1182dd9bab55fda4e4c012ba56b Author: Bjoern A. Zeeb <bz@FreeBSD.org> AuthorDate: 2025-04-05 23:59:00 +0000 Commit: Bjoern A. Zeeb <bz@FreeBSD.org> CommitDate: 2025-04-18 14:36:00 +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 Tested by: Oleksandr Kryvulia (shuriku shurik.kiev.ua) Tested by: Oleg Nauman (oleg.nauman gmail.com) [rtw88] Differential Revision: https://reviews.freebsd.org/D49734 (cherry picked from commit 50d826be664ef35065e8c4c4966252f2dfde9cb9) --- 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 3d60404537e2..63a6328ebc74 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: