From nobody Wed Feb 26 19:31:37 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 4Z34N94CxLz5nkpF; Wed, 26 Feb 2025 19:31:37 +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 4Z34N92Jvlz3d5D; Wed, 26 Feb 2025 19:31:37 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1740598297; 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=LsSksQ71Y3HlsrbETlsU9vXGA7Xtq2YuMWurMeHrZxE=; b=nXpwwI0iNAeEyI5+Bml8ko4DaaKBZJP5uSbDcvYn33nUVyTSW8lQn1E5ey0+AVxbw4W/QT 7UjzGYYrJ3ecDGuWNT1+xeNxeZYC5DKEXSqhvCFskuKYwkPreW0wvLXYDLaJPyNFMwVaa0 rBRUS4gv4uYxbU5Z/KHiR8zIAnVovwYnB+mIUj7Ar9ahzMOIK3v7i+5E2iyUr3J6b5/pOE xKk6QI6y9NBg+BtAXDhxsquzGAfq+RZlVC/aP1iC/hDZQ4uLrQfpmOibNsqhsvIA5R1OmN kylBJiEwQsL5f9itC/y//qLw65zLlQQqK6BOQp3nyc1OYWc14bNGrwmS4ji2HA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1740598297; a=rsa-sha256; cv=none; b=LWoxzXgD+F5CR1KU/yAoIGZH2ljObI6EOnlvyEX4ePSifjnICFJF9S+FdAts9u/7Jcrk86 XLpgr7r7IYx/tcJ5k+yMUWLFXasYB6C0UKisOvt5UREAoojKPqjverYEzZarS91SIIfC7o Zvi7rqc+H7iygEl7cM60NWqlWRYOAQu24fIzVCPUfjmR10LyflhC0OwB/SXnovLTnxlB7H wY+KUZFgrsJykXLtTXEDN657o4KRSPjHi5f6dQO/8oM0ucVcSFToydBtA9Y2IKYjv92GwH Qk9kVGJPp9OxVQmoVbwSVfYHxWo++WWTmCc57+cgQx3UjRZWtLRyBUj69YQLbg== 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=1740598297; 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=LsSksQ71Y3HlsrbETlsU9vXGA7Xtq2YuMWurMeHrZxE=; b=j3YKytMPJrLa8VkvD/jXb4oYNmvNKqbVAu5KwGXHFVB8AyEtsl+Zz/CsIV8+9GzvMAp2gb nRxZSq5X6RV3O0eyVDOTVcnmIx7t2809SYjrazDv7adMqhO+SuQDUe/mVEJuERhCz8G/ko ZJt35+Z1Dcikk94DM3CpDqsHxpCvaZTN39kqSxw/oovEkQqO3/LvK7z6ynU/G4r2RuH+hx ex8s9XSZq6dY56nRSnlMB5rmX1jW8U2wownnAJdbFQXaxDiOjKqrb7k94OSjRVFmgyCp9Q 2/uWyCe7zgiIR5QOGxIp+jQ4OeTVNrDtNSAymWfNsVO+wVmS3IBZ9ciceaO7zg== 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 4Z34N91fRVz1P2F; Wed, 26 Feb 2025 19:31:37 +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 51QJVbJ8017547; Wed, 26 Feb 2025 19:31:37 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 51QJVbih017544; Wed, 26 Feb 2025 19:31:37 GMT (envelope-from git) Date: Wed, 26 Feb 2025 19:31:37 GMT Message-Id: <202502261931.51QJVbih017544@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Adrian Chadd Subject: git: 46de4d9fc21d - main - net80211: change ieee80211_ratectl_rate() to not return a rix 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: adrian X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 46de4d9fc21dfd8945e95135f607ba4fdfdf3d78 Auto-Submitted: auto-generated The branch main has been updated by adrian: URL: https://cgit.FreeBSD.org/src/commit/?id=46de4d9fc21dfd8945e95135f607ba4fdfdf3d78 commit 46de4d9fc21dfd8945e95135f607ba4fdfdf3d78 Author: Adrian Chadd AuthorDate: 2025-01-12 15:48:59 +0000 Commit: Adrian Chadd CommitDate: 2025-02-26 19:29:36 +0000 net80211: change ieee80211_ratectl_rate() to not return a rix There are only a few places where the returned rix is used: * linuxkpi - logging * bwi/bwn - used for finding a fallback rate to choose, which honestly should be returned by the ratectl API * iwm - building the rateset to program into firmware Everyone else uses the dot11rate value in ni->ni_txnode. This is a precursor for VHT and later rate support; where currently there aren't rate tables in ieee80211_phy.c for VHT and later rates. Although it's likely doable to add tables for VHT, 11ax and MU-OFDMA (HE) rates are sufficiently larger/different to just not fit in the current scheme without more refactoring. Differential Revision: https://reviews.freebsd.org/D48603 Reviewed by: bz, thj --- sys/compat/linuxkpi/common/src/linux_80211.c | 7 +++--- sys/dev/bwi/if_bwi.c | 13 ++++------- sys/dev/bwn/if_bwn.c | 12 ++++------- sys/dev/iwm/if_iwm.c | 32 ++++++++++++++++++++++------ sys/net80211/ieee80211_ratectl.h | 4 ++-- 5 files changed, 39 insertions(+), 29 deletions(-) diff --git a/sys/compat/linuxkpi/common/src/linux_80211.c b/sys/compat/linuxkpi/common/src/linux_80211.c index 72227378b097..14c7bab163b6 100644 --- a/sys/compat/linuxkpi/common/src/linux_80211.c +++ b/sys/compat/linuxkpi/common/src/linux_80211.c @@ -6921,7 +6921,6 @@ linuxkpi_ieee80211_tx_status_ext(struct ieee80211_hw *hw, } if (ni != NULL) { - int ridx __unused; #ifdef LINUXKPI_DEBUG_80211 int old_rate; @@ -6946,15 +6945,15 @@ linuxkpi_ieee80211_tx_status_ext(struct ieee80211_hw *hw, IMPROVE("only update of rate matches but that requires us to get a proper rate"); ieee80211_ratectl_tx_complete(ni, &txs); - ridx = ieee80211_ratectl_rate(ni->ni_vap->iv_bss, NULL, 0); + ieee80211_ratectl_rate(ni->ni_vap->iv_bss, NULL, 0); #ifdef LINUXKPI_DEBUG_80211 if (linuxkpi_debug_80211 & D80211_TRACE_TX) { - printf("TX-RATE: %s: old %d new %d ridx %d, " + printf("TX-RATE: %s: old %d new %d " "long_retries %d\n", __func__, old_rate, ieee80211_node_get_txrate_dot11rate(ni->ni_vap->iv_bss), - ridx, txs.long_retries); + txs.long_retries); } #endif } diff --git a/sys/dev/bwi/if_bwi.c b/sys/dev/bwi/if_bwi.c index 079dac73ea43..1087ca813d65 100644 --- a/sys/dev/bwi/if_bwi.c +++ b/sys/dev/bwi/if_bwi.c @@ -2916,7 +2916,7 @@ bwi_encap(struct bwi_softc *sc, int idx, struct mbuf *m, uint32_t mac_ctrl; uint16_t phy_ctrl; bus_addr_t paddr; - int type, ismcast, pkt_len, error, rix; + int type, ismcast, pkt_len, error; #if 0 const uint8_t *p; int i; @@ -2943,15 +2943,10 @@ bwi_encap(struct bwi_softc *sc, int idx, struct mbuf *m, } else if (tp->ucastrate != IEEE80211_FIXED_RATE_NONE) { rate = rate_fb = tp->ucastrate; } else { - rix = ieee80211_ratectl_rate(ni, NULL, pkt_len); + ieee80211_ratectl_rate(ni, NULL, pkt_len); rate = ieee80211_node_get_txrate_dot11rate(ni); - - if (rix > 0) { - rate_fb = ni->ni_rates.rs_rates[rix-1] & - IEEE80211_RATE_VAL; - } else { - rate_fb = rate; - } + /* TODO: assign rate_fb the previous rate, if available */ + rate_fb = rate; } tb->tb_rate[0] = rate; tb->tb_rate[1] = rate_fb; diff --git a/sys/dev/bwn/if_bwn.c b/sys/dev/bwn/if_bwn.c index 571482afda70..38bf6f5d31a3 100644 --- a/sys/dev/bwn/if_bwn.c +++ b/sys/dev/bwn/if_bwn.c @@ -6394,7 +6394,7 @@ bwn_set_txhdr(struct bwn_mac *mac, struct ieee80211_node *ni, uint8_t *prot_ptr; unsigned int len; uint32_t macctl = 0; - int rts_rate, rts_rate_fb, ismcast, isshort, rix, type; + int rts_rate, rts_rate_fb, ismcast, isshort, type; uint16_t phyctl = 0; uint8_t rate, rate_fb; int fill_phy_ctl1 = 0; @@ -6420,14 +6420,10 @@ bwn_set_txhdr(struct bwn_mac *mac, struct ieee80211_node *ni, else if (tp->ucastrate != IEEE80211_FIXED_RATE_NONE) rate = rate_fb = tp->ucastrate; else { - rix = ieee80211_ratectl_rate(ni, NULL, 0); + ieee80211_ratectl_rate(ni, NULL, 0); rate = ieee80211_node_get_txrate_dot11rate(ni); - - if (rix > 0) - rate_fb = ni->ni_rates.rs_rates[rix - 1] & - IEEE80211_RATE_VAL; - else - rate_fb = rate; + /* TODO: assign rate_fb the previous rate, if available */ + rate_fb = rate; } sc->sc_tx_rate = rate; diff --git a/sys/dev/iwm/if_iwm.c b/sys/dev/iwm/if_iwm.c index bfe8c3635c7c..1e9090310ece 100644 --- a/sys/dev/iwm/if_iwm.c +++ b/sys/dev/iwm/if_iwm.c @@ -3502,11 +3502,11 @@ iwm_rx_tx_cmd_single(struct iwm_softc *sc, struct iwm_rx_packet *pkt, if (rate_matched) { ieee80211_ratectl_tx_complete(ni, txs); - int rix = ieee80211_ratectl_rate(vap->iv_bss, NULL, 0); + ieee80211_ratectl_rate(vap->iv_bss, NULL, 0); new_rate = ieee80211_node_get_txrate_dot11rate(vap->iv_bss); if (new_rate != 0 && new_rate != cur_rate) { struct iwm_node *in = IWM_NODE(vap->iv_bss); - iwm_setrates(sc, in, rix); + iwm_setrates(sc, in, new_rate); iwm_send_lq_cmd(sc, &in->in_lq, FALSE); } } @@ -4270,7 +4270,7 @@ iwm_rate2ridx(struct iwm_softc *sc, uint8_t rate) static void -iwm_setrates(struct iwm_softc *sc, struct iwm_node *in, int rix) +iwm_setrates(struct iwm_softc *sc, struct iwm_node *in, int dot11rate) { struct ieee80211_node *ni = &in->in_ni; struct iwm_lq_cmd *lq = &in->in_lq; @@ -4278,8 +4278,27 @@ iwm_setrates(struct iwm_softc *sc, struct iwm_node *in, int rix) int nrates = rs->rs_nrates; int i, ridx, tab = 0; // int txant = 0; + int rix; - KASSERT(rix >= 0 && rix < nrates, ("invalid rix")); + /* + * Look up the rate index for the given legacy rate from + * the rs_rates table. Default to the lowest rate if it's + * not found (which is obviously hugely problematic.) + */ + rix = -1; + for (i = 0; i < nrates; i++) { + int rate = rs->rs_rates[i] & IEEE80211_RATE_VAL; + if (rate == dot11rate) { + rix = i; + break; + } + } + if (rix < 0) { + device_printf(sc->sc_dev, + "%s: failed to lookup dot11rate (%d)\n", + __func__, dot11rate); + rix = 0; + } if (nrates > nitems(lq->rs_table)) { device_printf(sc->sc_dev, @@ -4559,8 +4578,9 @@ iwm_newstate(struct ieee80211vap *vap, enum ieee80211_state nstate, int arg) iwm_enable_beacon_filter(sc, ivp); iwm_power_update_mac(sc); iwm_update_quotas(sc, ivp); - int rix = ieee80211_ratectl_rate(&in->in_ni, NULL, 0); - iwm_setrates(sc, in, rix); + ieee80211_ratectl_rate(&in->in_ni, NULL, 0); + iwm_setrates(sc, in, + ieee80211_node_get_txrate_dot11rate(&in->in_ni)); if ((error = iwm_send_lq_cmd(sc, &in->in_lq, TRUE)) != 0) { device_printf(sc->sc_dev, diff --git a/sys/net80211/ieee80211_ratectl.h b/sys/net80211/ieee80211_ratectl.h index 2eae34763ed4..0e5beb5185cb 100644 --- a/sys/net80211/ieee80211_ratectl.h +++ b/sys/net80211/ieee80211_ratectl.h @@ -127,12 +127,12 @@ ieee80211_ratectl_node_deinit(struct ieee80211_node *ni) vap->iv_rate->ir_node_deinit(ni); } -static int __inline +static void __inline ieee80211_ratectl_rate(struct ieee80211_node *ni, void *arg, uint32_t iarg) { const struct ieee80211vap *vap = ni->ni_vap; - return vap->iv_rate->ir_rate(ni, arg, iarg); + vap->iv_rate->ir_rate(ni, arg, iarg); } static __inline void