From: Ragul Balaji <ragulbaby@gmail.com>
To: linux-wireless@vger.kernel.org
Cc: hjf3108@gmail.com, Ragul Balaji <ragulbaby@gmail.com>,
Arend van Spriel <arend.vanspriel@broadcom.com>,
brcm80211@lists.linux.dev, brcm80211-dev-list.pdl@broadcom.com,
linux-kernel@vger.kernel.org
Subject: [PATCH 08/10] wifi: brcmsmac: move the RTS rate selection to rate.c
Date: Thu, 12 Nov 2026 13:11:35 +0800 [thread overview]
Message-ID: <20261112051142.2797529-9-ragulbaby@gmail.com> (raw)
In-Reply-To: <20261112051142.2797529-1-ragulbaby@gmail.com>
Move the RTS and CTS ratespec selection of
brcms_c_rspec_to_rts_rspec() to rate.c as brcmu_rspec_to_rts_rspec(),
Signed-off-by: Ragul Balaji <ragulbaby@gmail.com>
Signed-off-by: Ho Jie Feng <hjf3108@gmail.com>
---
.../broadcom/brcm80211/brcmsmac/main.c | 62 +++----------------
.../broadcom/brcm80211/brcmsmac/rate.c | 49 +++++++++++++++
.../broadcom/brcm80211/brcmsmac/rate.h | 10 +++
3 files changed, 68 insertions(+), 53 deletions(-)
diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmsmac/main.c b/drivers/net/wireless/broadcom/brcm80211/brcmsmac/main.c
index cd80155a5a..4be0bb085a 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmsmac/main.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmsmac/main.c
@@ -325,13 +325,6 @@ static u8 brcms_fifo_to_ac(u8 fifo)
return fifo_to_ac_mapping[fifo];
}
-static u16 frametype(u32 rspec, u8 mimoframe)
-{
- if (is_mcs_rate(rspec))
- return mimoframe;
- return is_cck_rate(rspec) ? FT_CCK : FT_OFDM;
-}
-
/*
* Detect Card removed.
* Even checking an sbconfig register read will not false trigger when the core
@@ -6164,15 +6157,15 @@ brcms_c_d11hdrs_mac80211(struct brcms_c_info *wlc, struct ieee80211_hw *hw,
txh->MainRates = cpu_to_le16(mainrates);
/* XtraFrameTypes */
- xfts = frametype(rspec[1], wlc->mimoft);
- xfts |= (frametype(rts_rspec[0], wlc->mimoft) << XFTS_RTS_FT_SHIFT);
- xfts |= (frametype(rts_rspec[1], wlc->mimoft) << XFTS_FBRRTS_FT_SHIFT);
+ xfts = brcmu_frametype(rspec[1], wlc->mimoft);
+ xfts |= (brcmu_frametype(rts_rspec[0], wlc->mimoft) << XFTS_RTS_FT_SHIFT);
+ xfts |= (brcmu_frametype(rts_rspec[1], wlc->mimoft) << XFTS_FBRRTS_FT_SHIFT);
xfts |= CHSPEC_CHANNEL(wlc_phy_chanspec_get(wlc->band->pi)) <<
XFTS_CHANNEL_SHIFT;
txh->XtraFrameTypes = cpu_to_le16(xfts);
/* PhyTxControlWord */
- phyctl = frametype(rspec[0], wlc->mimoft);
+ phyctl = brcmu_frametype(rspec[0], wlc->mimoft);
if ((preamble_type[0] == BRCMS_SHORT_PREAMBLE) ||
(preamble_type[0] == BRCMS_GF_PREAMBLE)) {
if (rspec2rate(rspec[0]) != BRCM_RATE_1M)
@@ -6418,48 +6411,11 @@ u32
brcms_c_rspec_to_rts_rspec(struct brcms_c_info *wlc, u32 rspec,
bool use_rspec, u16 mimo_ctlchbw)
{
- u32 rts_rspec = 0;
-
- if (use_rspec)
- /* use frame rate as rts rate */
- rts_rspec = rspec;
- else if (wlc->band->gmode && wlc->protection->_g && !is_cck_rate(rspec))
- /* Use 11Mbps as the g protection RTS target rate and fallback.
- * Use the brcmu_basic_rate() lookup to find the best basic rate
- * under the target in case 11 Mbps is not Basic.
- * 6 and 9 Mbps are not usually selected by rate selection, but
- * even if the OFDM rate we are protecting is 6 or 9 Mbps, 11
- * is more robust.
- */
- rts_rspec = brcmu_basic_rate(wlc->band->basic_rate,
- BRCM_RATE_11M);
- else
- /* calculate RTS rate and fallback rate based on the frame rate
- * RTS must be sent at a basic rate since it is a
- * control frame, sec 9.6 of 802.11 spec
- */
- rts_rspec = brcmu_basic_rate(wlc->band->basic_rate, rspec);
-
- if (BRCMS_PHY_11N_CAP(wlc->band)) {
- /* set rts txbw to correct side band */
- rts_rspec &= ~RSPEC_BW_MASK;
-
- /*
- * if rspec/rspec_fallback is 40MHz, then send RTS on both
- * 20MHz channel (DUP), otherwise send RTS on control channel
- */
- if (rspec_is40mhz(rspec) && !is_cck_rate(rts_rspec))
- rts_rspec |= (PHY_TXC1_BW_40MHZ_DUP << RSPEC_BW_SHIFT);
- else
- rts_rspec |= (mimo_ctlchbw << RSPEC_BW_SHIFT);
-
- /* pick siso/cdd as default for ofdm */
- if (is_ofdm_rate(rts_rspec)) {
- rts_rspec &= ~RSPEC_STF_MASK;
- rts_rspec |= (wlc->stf->ss_opmode << RSPEC_STF_SHIFT);
- }
- }
- return rts_rspec;
+ return brcmu_rspec_to_rts_rspec(wlc->band->phytype,
+ wlc->band->basic_rate,
+ wlc->band->gmode && wlc->protection->_g,
+ wlc->stf->ss_opmode, rspec, use_rspec,
+ mimo_ctlchbw);
}
/* Update beacon listen interval in shared memory */
diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmsmac/rate.c b/drivers/net/wireless/broadcom/brcm80211/brcmsmac/rate.c
index 1c0259139c..fce98dd4d7 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmsmac/rate.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmsmac/rate.c
@@ -903,6 +903,55 @@ brcmu_compute_rtscts_dur(int bandtype, const u8 *basic_rate, bool cts_only,
return dur;
}
+u32
+brcmu_rspec_to_rts_rspec(u16 phytype, const u8 *basic_rate, bool g_prot,
+ u8 ss_opmode, u32 rspec, bool use_rspec,
+ u16 mimo_ctlchbw)
+{
+ u32 rts_rspec = 0;
+
+ if (use_rspec)
+ /* use frame rate as rts rate */
+ rts_rspec = rspec;
+ else if (g_prot && !is_cck_rate(rspec))
+ /* Use 11Mbps as the g protection RTS target rate and fallback.
+ * Use the brcmu_basic_rate() lookup to find the best basic rate
+ * under the target in case 11 Mbps is not Basic.
+ * 6 and 9 Mbps are not usually selected by rate selection, but
+ * even if the OFDM rate we are protecting is 6 or 9 Mbps, 11
+ * is more robust.
+ */
+ rts_rspec = brcmu_basic_rate(basic_rate, BRCM_RATE_11M);
+ else
+ /* calculate RTS rate and fallback rate based on the frame rate
+ * RTS must be sent at a basic rate since it is a
+ * control frame, sec 9.6 of 802.11 spec
+ */
+ rts_rspec = brcmu_basic_rate(basic_rate, rspec);
+
+ if (phytype == PHY_TYPE_N || phytype == PHY_TYPE_LCN ||
+ phytype == PHY_TYPE_SSN) {
+ /* set rts txbw to correct side band */
+ rts_rspec &= ~RSPEC_BW_MASK;
+
+ /*
+ * if rspec/rspec_fallback is 40MHz, then send RTS on both
+ * 20MHz channel (DUP), otherwise send RTS on control channel
+ */
+ if (rspec_is40mhz(rspec) && !is_cck_rate(rts_rspec))
+ rts_rspec |= (PHY_TXC1_BW_40MHZ_DUP << RSPEC_BW_SHIFT);
+ else
+ rts_rspec |= (mimo_ctlchbw << RSPEC_BW_SHIFT);
+
+ /* pick siso/cdd as default for ofdm */
+ if (is_ofdm_rate(rts_rspec)) {
+ rts_rspec &= ~RSPEC_STF_MASK;
+ rts_rspec |= (ss_opmode << RSPEC_STF_SHIFT);
+ }
+ }
+ return rts_rspec;
+}
+
u16 brcmu_phytxctl1_calc(u16 phytype, u32 rspec)
{
u16 phyctl1 = 0;
diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmsmac/rate.h b/drivers/net/wireless/broadcom/brcm80211/brcmsmac/rate.h
index 401fed6939..9f517be0c7 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmsmac/rate.h
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmsmac/rate.h
@@ -212,6 +212,13 @@ static inline bool is_cck_rate(u32 ratespec)
rate == BRCM_RATE_5M5 || rate == BRCM_RATE_11M);
}
+static inline u16 brcmu_frametype(u32 rspec, u8 mimoframe)
+{
+ if (is_mcs_rate(rspec))
+ return mimoframe;
+ return is_cck_rate(rspec) ? FT_CCK : FT_OFDM;
+}
+
static inline bool is_single_stream(u8 mcs)
{
return mcs <= HIGHEST_SINGLE_STREAM_MCS || mcs == 32;
@@ -279,6 +286,9 @@ u16 brcmu_compute_rtscts_dur(int bandtype, const u8 *basic_rate, bool cts_only,
u32 rts_rate, u32 frame_rate,
u8 rts_preamble_type, u8 frame_preamble_type,
uint frame_len, bool ba);
+u32 brcmu_rspec_to_rts_rspec(u16 phytype, const u8 *basic_rate, bool g_prot,
+ u8 ss_opmode, u32 rspec, bool use_rspec,
+ u16 mimo_ctlchbw);
u16 brcmu_phytxctl1_calc(u16 phytype, u32 rspec);
u16 brcmu_calc_lsig_len(u32 ratespec, uint mac_len);
--
2.53.0
next prev parent reply other threads:[~2026-11-12 5:12 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20261112051142.2797529-1-ragulbaby@gmail.com>
2026-11-12 5:11 ` [PATCH 01/10] wifi: brcmsmac: make d11.h self-contained Ragul Balaji
2026-11-12 5:11 ` [PATCH 02/10] wifi: brcm80211: move d11.h to the shared include directory Ragul Balaji
2026-11-12 5:11 ` [PATCH 03/10] wifi: brcmsmac: look up OFDM rates in rate.c Ragul Balaji
2026-11-12 5:11 ` [PATCH 04/10] wifi: brcmsmac: give the rate tables and helpers a brcmu_ prefix Ragul Balaji
2026-11-12 5:11 ` [PATCH 05/10] wifi: brcmsmac: round short-GI L-SIG lengths up to whole symbols Ragul Balaji
2026-11-12 5:11 ` [PATCH 06/10] wifi: brcmsmac: pass the band to the PLCP and frame timing helpers Ragul Balaji
2026-11-12 5:11 ` [PATCH 07/10] wifi: brcmsmac: move the PLCP and frame timing helpers to rate.c Ragul Balaji
2026-11-12 5:11 ` Ragul Balaji [this message]
2026-11-12 5:11 ` [PATCH 09/10] wifi: brcm80211: move the rate helpers of brcmsmac to brcmutil Ragul Balaji
2026-11-12 5:11 ` [PATCH 10/10] wifi: brcm80211: move the channel and rate tables " Ragul Balaji
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261112051142.2797529-9-ragulbaby@gmail.com \
--to=ragulbaby@gmail.com \
--cc=arend.vanspriel@broadcom.com \
--cc=brcm80211-dev-list.pdl@broadcom.com \
--cc=brcm80211@lists.linux.dev \
--cc=hjf3108@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-wireless@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®