wifi: prepare shared code for brcmbmac
v2 cover wifi: prepare shared code for brcmbmac
These patches move brcmsmac's d11 core definitions, its rate, PLCP, frame timing and RTS rate helpers, and its channel and rate tables to the shared brcm80211 directories, so that the brcmbmac driver for the BCM4323x USB adapters, sent separately, can share them instead of copying them:
The last patch moves brcmfmac's USB bootloader definitions to a shared header.
Apart from patch 5, these patches change no behaviour. Compile-tested only for brcmsmac and brcmfmac.
Changelog v2:
- Move brcmfmac changes here too.
Ragul Balaji (11):
wifi: brcmsmac: make d11.h self-contained
wifi: brcm80211: move d11.h to the shared include directory
wifi: brcmsmac: look up OFDM rates in rate.c
wifi: brcmsmac: give the rate tables and helpers a brcmu_ prefix
wifi: brcmsmac: round short-GI L-SIG lengths up to whole symbols
wifi: brcmsmac: pass the band to the PLCP and frame timing helpers
wifi: brcmsmac: move the PLCP and frame timing helpers to rate.c
wifi: brcmsmac: move the RTS rate selection to rate.c
wifi: brcm80211: move the rate helpers of brcmsmac to brcmutil
wifi: brcm80211: move the channel and rate tables of brcmsmac to
brcmutil
wifi: brcm80211: move the USB bootloader definitions to a shared
header
.../broadcom/brcm80211/brcmfmac/usb.c | 68 +-
.../broadcom/brcm80211/brcmsmac/Makefile | 1 -
.../broadcom/brcm80211/brcmsmac/ampdu.c | 34 +-
.../broadcom/brcm80211/brcmsmac/dma.h | 27 -
.../broadcom/brcm80211/brcmsmac/mac80211_if.c | 153 +--
.../broadcom/brcm80211/brcmsmac/mac80211_if.h | 9 +-
.../broadcom/brcm80211/brcmsmac/main.c | 741 ++----------
.../broadcom/brcm80211/brcmsmac/main.h | 26 +-
.../broadcom/brcm80211/brcmsmac/phy/phy_cmn.c | 17 -
.../broadcom/brcm80211/brcmsmac/phy/phy_hal.h | 3 +-
.../broadcom/brcm80211/brcmsmac/pub.h | 35 +-
.../broadcom/brcm80211/brcmsmac/rate.c | 514 --------
.../broadcom/brcm80211/brcmsmac/stf.c | 4 +-
.../broadcom/brcm80211/brcmutil/Makefile | 2 +-
.../broadcom/brcm80211/brcmutil/band.c | 140 +++
.../broadcom/brcm80211/brcmutil/rate.c | 1077 +++++++++++++++++
.../broadcom/brcm80211/include/brcm_usb_rdl.h | 78 ++
.../broadcom/brcm80211/include/brcmu_band.h | 26 +
.../{brcmsmac/rate.h => include/brcmu_rate.h} | 170 ++-
.../brcm80211/{brcmsmac => include}/d11.h | 43 +-
20 files changed, 1637 insertions(+), 1531 deletions(-)
delete mode 100644 drivers/net/wireless/broadcom/brcm80211/brcmsmac/rate.c
create mode 100644 drivers/net/wireless/broadcom/brcm80211/brcmutil/band.c
create mode 100644 drivers/net/wireless/broadcom/brcm80211/brcmutil/rate.c
create mode 100644 drivers/net/wireless/broadcom/brcm80211/include/brcm_usb_rdl.h
create mode 100644 drivers/net/wireless/broadcom/brcm80211/include/brcmu_band.h
rename drivers/net/wireless/broadcom/brcm80211/{brcmsmac/rate.h => include/brcmu_rate.h} (51%)
rename drivers/net/wireless/broadcom/brcm80211/{brcmsmac => include}/d11.h (97%)base-commit: 3c311bf321442d4c4f452a1a08bc9efce242a1f9
Signature · 1 line
2.53.0
PATCH v2 1/11 wifi: brcmsmac: make d11.h self-contained
d11.h includes pub.h and dma.h, but it needs only the two DMA register layouts from dma.h for struct d11regs and nothing from pub.h. Move struct dma32diag and struct dma64regs into d11.h next to the register map that embeds them, and drop both includes.
The TXFID_* masks describe the TxFrameID field of struct d11txh. Define them in d11.h next to the header that carries the field, so that it can be shared with other code.
pub.h and d11.h both define the PHY types of the PhyVersion register, with the same values. Add the ones that only pub.h has, PHY_TYPE_A, PHY_TYPE_G, PHY_TYPE_LP and PHY_TYPE_HT, to d11.h, and drop the list in pub.h.
This prepares d11.h for use outside brcmsmac. No functional change.
--- .../broadcom/brcm80211/brcmsmac/ampdu.c | 1 + .../broadcom/brcm80211/brcmsmac/d11.h | 43 ++++++++++++++++++- .../broadcom/brcm80211/brcmsmac/dma.h | 27 ------------ .../broadcom/brcm80211/brcmsmac/main.h | 11 +---- .../broadcom/brcm80211/brcmsmac/phy/phy_hal.h | 1 + .../broadcom/brcm80211/brcmsmac/pub.h | 10 ----- .../broadcom/brcm80211/brcmsmac/rate.h | 1 + 7 files changed, 45 insertions(+), 49 deletions(-)
drivers/net/wireless/broadcom/brcm80211/brcmsmac/ampdu.c +1 -0
@@ -19,6 +19,7 @@#include "scb.h" #include "phy/phy_hal.h" #include "antsel.h" +#include "dma.h" #include "main.h" #include "ampdu.h" #include "debug.h"
drivers/net/wireless/broadcom/brcm80211/brcmsmac/d11.h +41 -2
63 lines not on this page · raw message
drivers/net/wireless/broadcom/brcm80211/brcmsmac/dma.h +0 -27
@@ -25,33 +25,6 @@#define DMA_TX 1/* TX direction for DMA */ #define DMA_RX 2/* RX direction for DMA */ -/* DMA structure: -* support two DMA engines: 32 bits address or 64 bit addressing -* basic DMA register set is per channel(transmit or receive) -* a pair of channels is defined for convenience -*/ - -/* 32 bits addressing */ - -struct dma32diag {/* diag access */ -u32 fifoaddr;/* diag address */ -u32 fifodatalow;/* low 32bits of data */ -u32 fifodatahigh;/* high 32bits of data */ -u32 pad;/* reserved */ -}; - -/* 64 bits addressing */ - -/* dma registers per channel(xmt or rcv) */ -struct dma64regs { -u32 control;/* enable, et al */ -u32 ptr;/* last descriptor posted to chip */ -u32 addrlow;/* desc ring base address low 32-bits (8K aligned) */ -u32 addrhigh;/* desc ring base address bits 63:32 (8K aligned) */ -u32 status0;/* current descriptor, xmt state */ -u32 status1;/* active descriptor, xmt error */ -}; -/* range param for dma_getnexttxp() and dma_txreclaim */ enum txd_range {DMA_RANGE_ALL =1 ,
drivers/net/wireless/broadcom/brcm80211/brcmsmac/main.h +1 -10
@@ -22,6 +22,7 @@#include <brcmu_utils.h> #include "types.h" #include "d11.h" +#include "pub.h" #include "scb.h" #define INVCHANNEL 255/* invalid channel */
@@ -85,16 +86,6 @@#define BRCMS_IS_MIMO_PREAMBLE (_pre) (((_pre) == BRCMS_GF_PREAMBLE) || \ ((_pre) == BRCMS_MM_PREAMBLE)) -/* TxFrameID */ -/* seq and frag bits: SEQNUM_SHIFT, FRAGNUM_MASK (802.11.h) */ -/* rate epoch bits: TXFID_RATE_SHIFT, TXFID_RATE_MASK ((wlc_rate.c) */ -#define TXFID_QUEUE_MASK 0x0007/* Bits 0-2 */ -#define TXFID_SEQ_MASK 0x7FE0/* Bits 5-15 */ -#define TXFID_SEQ_SHIFT 5/* Number of bit shifts */ -#define TXFID_RATE_PROBE_MASK 0x8000/* Bit 15 for rate probe */ -#define TXFID_RATE_MASK 0x0018/* Mask for bits 3 and 4 */ -#define TXFID_RATE_SHIFT 3/* Shift 3 bits for rate mask */ -/* promote boardrev */ #define BOARDREV_PROMOTABLE 0xFF/* from */ #define BOARDREV_PROMOTED 1/* to */
drivers/net/wireless/broadcom/brcm80211/brcmsmac/phy/phy_hal.h +1 -0
@@ -10,6 +10,7 @@#ifndef _BRCM_PHY_HAL_H_#define _BRCM_PHY_HAL_H_ +#include <linux/bcma/bcma.h> #include <brcmu_utils.h> #include <brcmu_wifi.h> #include <phy_shim.h>
drivers/net/wireless/broadcom/brcm80211/brcmsmac/pub.h +0 -10
@@ -24,16 +24,6 @@#define BRCMS_NUMRATES 16/* max # of rates in a rateset */ -/* phy types */ -#define PHY_TYPE_A 0/* Phy type A */ -#define PHY_TYPE_G 2/* Phy type G */ -#define PHY_TYPE_N 4/* Phy type N */ -#define PHY_TYPE_LP 5/* Phy type Low Power A/B/G */ -#define PHY_TYPE_SSN 6/* Phy type Single Stream N */ -#define PHY_TYPE_LCN 8/* Phy type Single Stream N */ -#define PHY_TYPE_LCNXN 9/* Phy type 2-stream N */ -#define PHY_TYPE_HT 7/* Phy type 3-Stream N */ -/* bw */ #define BRCMS_10_MHZ 10/* 10Mhz nphy channel bandwidth */ #define BRCMS_20_MHZ 20/* 20Mhz nphy channel bandwidth */
drivers/net/wireless/broadcom/brcm80211/brcmsmac/rate.h +1 -0
@@ -19,6 +19,7 @@#include "types.h" #include "d11.h" +#include "pub.h" #include "phy_hal.h" extern const u8 rate_info[];
Signature · 1 line
2.53.0
PATCH v2 2/11 wifi: brcm80211: move d11.h to the shared include directory
In reply to Ragul BalajiMove the header to brcm80211/include, where the other hardware definitions shared between the brcm80211 drivers live, and include it as <d11.h> in brcmsmac.
---
drivers/net/wireless/broadcom/brcm80211/brcmsmac/mac80211_if.c | 2 +-
drivers/net/wireless/broadcom/brcm80211/brcmsmac/main.h | 2 +-
drivers/net/wireless/broadcom/brcm80211/brcmsmac/rate.c | 2 +-
drivers/net/wireless/broadcom/brcm80211/brcmsmac/rate.h | 2 +-
drivers/net/wireless/broadcom/brcm80211/brcmsmac/stf.c | 2 +-
.../net/wireless/broadcom/brcm80211/{brcmsmac => include}/d11.h | 0
6 files changed, 5 insertions(+), 5 deletions(-)
rename drivers/net/wireless/broadcom/brcm80211/{brcmsmac => include}/d11.h (100%)drivers/net/wireless/broadcom/brcm80211/brcmsmac/mac80211_if.c +1 -1
@@ -28,7 +28,7 @@#include <net/mac80211.h> #include <defs.h> #include "phy/phy_int.h" -#include "d11.h" +#include <d11.h> #include "channel.h" #include "scb.h" #include "pub.h"
drivers/net/wireless/broadcom/brcm80211/brcmsmac/main.h +1 -1
@@ -21,7 +21,7 @@#include <brcmu_utils.h> #include "types.h" -#include "d11.h" +#include <d11.h> #include "pub.h" #include "scb.h"
drivers/net/wireless/broadcom/brcm80211/brcmsmac/rate.c +1 -1
@@ -17,7 +17,7 @@#include <brcmu_wifi.h> #include <brcmu_utils.h> -#include "d11.h" +#include <d11.h> #include "pub.h" #include "rate.h"
drivers/net/wireless/broadcom/brcm80211/brcmsmac/rate.h +1 -1
@@ -18,7 +18,7 @@#define _BRCM_RATE_H_#include "types.h" -#include "d11.h" +#include <d11.h> #include "pub.h" #include "phy_hal.h"
drivers/net/wireless/broadcom/brcm80211/brcmsmac/stf.c +1 -1
@@ -17,7 +17,7 @@#include <net/mac80211.h> #include "types.h" -#include "d11.h" +#include <d11.h> #include "rate.h" #include "phy/phy_hal.h" #include "channel.h"
drivers/net/wireless/broadcom/brcm80211/include/d11.h renamed from drivers/net/wireless/broadcom/brcm80211/brcmsmac/d11.h +0 -0
Signature · 1 line
2.53.0
PATCH v2 3/11 wifi: brcmsmac: look up OFDM rates in rate.c
In reply to Ragul BalajiMove the OFDM rate table next to its only user, ofdm_phy2mac_rate(), which leaves rate.c independent of the PHY code. No functional change.
--- .../broadcom/brcm80211/brcmsmac/phy/phy_cmn.c | 17 ----------------- .../broadcom/brcm80211/brcmsmac/phy/phy_hal.h | 2 -- .../broadcom/brcm80211/brcmsmac/rate.c | 19 +++++++++++++++++++ .../broadcom/brcm80211/brcmsmac/rate.h | 7 ------- 4 files changed, 19 insertions(+), 26 deletions(-)
drivers/net/wireless/broadcom/brcm80211/brcmsmac/phy/phy_cmn.c +0 -17
@@ -101,18 +101,6 @@ static const struct chan_info_basic chan_info_all[] = { {216, 5080} }; -static const u8 ofdm_rate_lookup[] = { - -BRCM_RATE_48M , -BRCM_RATE_24M , -BRCM_RATE_12M , -BRCM_RATE_6M , -BRCM_RATE_54M , -BRCM_RATE_36M , -BRCM_RATE_18M , -BRCM_RATE_9M -}; -#define PHY_WREG_LIMIT 24void wlc_phyreg_enter (struct brcms_phy_pub *pih)
@@ -2486,11 +2474,6 @@ u8 wlc_phy_stf_chain_active_get(struct brcms_phy_pub *pih)return active_bitmap; } -const u8 *wlc_phy_get_ofdm_rate_lookup (void ) -{ -return ofdm_rate_lookup; -} -void wlc_phy_ldpc_override_set (struct brcms_phy_pub *ppi,bool ldpc) {return ;
drivers/net/wireless/broadcom/brcm80211/brcmsmac/phy/phy_hal.h +0 -2
@@ -234,8 +234,6 @@ void wlc_phy_ofdm_rateset_war(struct brcms_phy_pub *pih, bool war);void wlc_phy_bf_preempt_enable (struct brcms_phy_pub *pih,bool bf_preempt);void wlc_phy_machwcap_set (struct brcms_phy_pub *ppi,u32 machwcap); -const u8 *wlc_phy_get_ofdm_rate_lookup (void ); -s8 wlc_phy_get_tx_power_offset_by_mcs (struct brcms_phy_pub *ppi,u8 mcs_offset);s8 wlc_phy_get_tx_power_offset (struct brcms_phy_pub *ppi,u8 tbl_offset);
drivers/net/wireless/broadcom/brcm80211/brcmsmac/rate.c +19 -0
@@ -266,6 +266,25 @@ const struct brcms_c_rateset cck_rates = { 0x00, 0x00, 0x00, 0x00, 0x00} }; +static const u8 ofdm_rate_lookup[] = { + +BRCM_RATE_48M , +BRCM_RATE_24M , +BRCM_RATE_12M , +BRCM_RATE_6M , +BRCM_RATE_54M , +BRCM_RATE_36M , +BRCM_RATE_18M , +BRCM_RATE_9M +}; + +/* Convert encoded rate value in plcp header to numerical rates in 500 KHz +* increments */ +static inline u8 ofdm_phy2mac_rate (u8 rlpt) +{ +return ofdm_rate_lookup[rlpt &0x7 ]; +} +/* check if rateset is valid. * if check_brate is true, rateset without a basic rate is considered NOT valid. */
drivers/net/wireless/broadcom/brcm80211/brcmsmac/rate.h +0 -7
@@ -198,13 +198,6 @@ static inline u8 cck_rspec(u8 cck)return cck &RSPEC_RATE_MASK ; } -/* Convert encoded rate value in plcp header to numerical rates in 500 KHz -* increments */ -static inline u8 ofdm_phy2mac_rate (u8 rlpt) -{ -return wlc_phy_get_ofdm_rate_lookup ()[rlpt &0x7 ]; -} -static inline u8 cck_phy2mac_rate (u8 signal) {return signal/5 ;
Signature · 1 line
2.53.0
PATCH v2 4/11 wifi: brcmsmac: give the rate tables and helpers a brcmu_ prefix
In reply to Ragul BalajiPrepare rate.c for move to brcmutil, which exports them. Rename brcms_c_ to brcmu_.
--- .../broadcom/brcm80211/brcmsmac/main.c | 87 +++++++++--------- .../broadcom/brcm80211/brcmsmac/rate.c | 88 +++++++++---------- .../broadcom/brcm80211/brcmsmac/rate.h | 68 +++++++------- 3 files changed, 121 insertions(+), 122 deletions(-)
drivers/net/wireless/broadcom/brcm80211/brcmsmac/main.c +43 -44
@@ -347,7 +347,7 @@ static u8 brcms_fifo_to_ac(u8 fifo)static u8 brcms_basic_rate (struct brcms_c_info *wlc,u32 rspec) {if (is_mcs_rate (rspec)) -return wlc->band->basic_rate[mcs_table[rspec &RSPEC_RATE_MASK ] +return wlc->band->basic_rate[brcmu_mcs_table[rspec &RSPEC_RATE_MASK ] .leg_ofdm];return wlc->band->basic_rate[rspec &RSPEC_RATE_MASK ]; }
@@ -3356,11 +3356,11 @@ static void brcms_c_set_phy_chanspec(struct brcms_c_info *wlc,static void brcms_default_rateset (struct brcms_c_info *wlc,struct brcms_c_rateset *rs) { -brcms_c_rateset_default (rs,NULL , wlc->band->phytype, - wlc->band->bandtype, false,BRCMS_RATE_MASK_FULL , - (bool ) (wlc->pub->_n_enab &SUPPORT_11N ), -brcms_chspec_bw (wlc->default_bss->chanspec), - wlc->stf->txstreams); +brcmu_rateset_default (rs,NULL , wlc->band->phytype, + wlc->band->bandtype, false,BRCMS_RATE_MASK_FULL , + (bool )(wlc->pub->_n_enab &SUPPORT_11N ), +brcms_chspec_bw (wlc->default_bss->chanspec), + wlc->stf->txstreams); }/* derive wlc->band->basic_rate[] table from 'rateset' */
@@ -3491,9 +3491,9 @@ static void brcms_c_bandinit_ordered(struct brcms_c_info *wlc,brcms_default_rateset (wlc, &default_rateset);/* fill in hw_rate */ -brcms_c_rateset_filter (&default_rateset, &wlc->band->hw_rateset, - false,BRCMS_RATES_CCK_OFDM ,BRCMS_RATE_MASK , - (bool ) (wlc->pub->_n_enab &SUPPORT_11N )); +brcmu_rateset_filter (&default_rateset, &wlc->band->hw_rateset, + false,BRCMS_RATES_CCK_OFDM ,BRCMS_RATE_MASK , + (bool )(wlc->pub->_n_enab &SUPPORT_11N ));/* init basic rate lookup */ brcms_c_rate_lookup_init (wlc, &default_rateset);
@@ -3578,8 +3578,8 @@ static void brcms_c_write_rate_shm(struct brcms_c_info *wlc, u8 rate,* for a given rate, the LS-nibble of the PLCP SIGNAL field is * the index into the rate table. */ - phy_rate = rate_info[rate] &BRCMS_RATE_MASK ; - basic_phy_rate = rate_info[basic_rate] &BRCMS_RATE_MASK ; + phy_rate = brcmu_rate_info[rate] &BRCMS_RATE_MASK ; + basic_phy_rate = brcmu_rate_info[basic_rate] &BRCMS_RATE_MASK ; index = phy_rate &0xf ; basic_index = basic_phy_rate &0xf ;
@@ -3601,13 +3601,13 @@ brcms_c_rateset_get_hwrs(struct brcms_c_info *wlc)if (BRCMS_PHY_11N_CAP (wlc->band)) {if (wlc->band->bandtype ==BRCM_BAND_5G ) - rs_dflt = &ofdm_mimo_rates; + rs_dflt = &brcmu_ofdm_mimo_rates;else - rs_dflt = &cck_ofdm_mimo_rates; + rs_dflt = &brcmu_cck_ofdm_mimo_rates; }else if (wlc->band->gmode) - rs_dflt = &cck_ofdm_rates; + rs_dflt = &brcmu_cck_ofdm_rates;else - rs_dflt = &cck_rates; + rs_dflt = &brcmu_cck_rates;return rs_dflt; }
@@ -3621,8 +3621,8 @@ static void brcms_c_set_ratetable(struct brcms_c_info *wlc) rs_dflt =brcms_c_rateset_get_hwrs (wlc); -brcms_c_rateset_copy (rs_dflt, &rs); -brcms_c_rateset_mcs_upd (&rs, wlc->stf->txstreams); +brcmu_rateset_copy (rs_dflt, &rs); +brcmu_rateset_mcs_upd (&rs, wlc->stf->txstreams);/* walk the phy rate table and update SHM basic rate lookup table */ for (i =0 ; i < rs.count; i++) {
@@ -3889,8 +3889,9 @@ static void brcms_c_set_chanspec(struct brcms_c_info *wlc, u16 chanspec)/* Fix the hardware rateset based on bw. * Mainly add MCS32 for 40Mhz, remove MCS 32 for 20Mhz */ -brcms_c_rateset_bw_mcs_filter (&wlc->band->hw_rateset, - wlc->band->mimo_cap_40 ?brcms_chspec_bw (chanspec) :0 ); +brcmu_rateset_bw_mcs_filter (&wlc->band->hw_rateset, + wlc->band->mimo_cap_40 ? +brcms_chspec_bw (chanspec) :0 ); }/* update some mac configuration since chanspec changed */
@@ -4707,10 +4708,10 @@ static void brcms_c_bss_default_init(struct brcms_c_info *wlc) band = wlc->bandstate[OTHERBANDUNIT (wlc)];/* init bss rates to the band specific default rate set */ -brcms_c_rateset_default (&bi->rateset,NULL , band->phytype, - band->bandtype, false,BRCMS_RATE_MASK_FULL , - (bool ) (wlc->pub->_n_enab &SUPPORT_11N ), -brcms_chspec_bw (chanspec), wlc->stf->txstreams); +brcmu_rateset_default (&bi->rateset,NULL , band->phytype, + band->bandtype, false,BRCMS_RATE_MASK_FULL , + (bool )(wlc->pub->_n_enab &SUPPORT_11N ), +brcms_chspec_bw (chanspec), wlc->stf->txstreams);if (wlc->pub->_n_enab &SUPPORT_11N ) bi->flags |=BRCMS_BSS_HT ;
@@ -5202,7 +5203,7 @@ int brcms_c_set_gmode(struct brcms_c_info *wlc, u8 gmode, bool config)switch (gmode) {case GMODE_LEGACY_B : shortslot =BRCMS_SHORTSLOT_OFF ; -brcms_c_rateset_copy (&gphy_legacy_rates, &rs); +brcmu_rateset_copy (&brcmu_gphy_legacy_rates, &rs);break ;
@@ -5235,7 +5236,7 @@ int brcms_c_set_gmode(struct brcms_c_info *wlc, u8 gmode, bool config)/* Use the default 11g rateset */ if (!rs.count) -brcms_c_rateset_copy (&cck_ofdm_rates, &rs); +brcmu_rateset_copy (&brcmu_cck_ofdm_rates, &rs);if (ofdm_basic) {for (i =0 ; i < rs.count; i++) {
@@ -5272,8 +5273,8 @@ int brcms_c_set_nmode(struct brcms_c_info *wlc) wlc->pub->_n_enab =SUPPORT_11N ; wlc->default_bss->flags |=BRCMS_BSS_HT ;/* add the mcs rates to the default and hw ratesets */ -brcms_c_rateset_mcs_build (&wlc->default_bss->rateset, - wlc->stf->txstreams); +brcmu_rateset_mcs_build (&wlc->default_bss->rateset, + wlc->stf->txstreams);for (i =0 ; i < wlc->pub->_nbands; i++)memcpy (wlc->bandstate[i]->hw_rateset.mcs, wlc->default_bss->rateset.mcs,MCSSET_LEN );
@@ -5297,7 +5298,7 @@ brcms_c_set_internal_rateset(struct brcms_c_info *wlc,/* try the current band */ bandunit = wlc->band->bandunit;memcpy (&new, &rs,sizeof (struct brcms_c_rateset )); -if (brcms_c_rate_hwrs_filter_sort_validate +if (brcmu_rate_hwrs_filter_sort_validate (&new, &wlc->bandstate[bandunit]->hw_rateset, true, wlc->stf->txstreams)) goto good;
@@ -5306,11 +5307,9 @@ brcms_c_set_internal_rateset(struct brcms_c_info *wlc,if (brcms_is_mband_unlocked (wlc)) { bandunit =OTHERBANDUNIT (wlc);memcpy (&new, &rs,sizeof (struct brcms_c_rateset )); -if (brcms_c_rate_hwrs_filter_sort_validate (&new, - &wlc-> - bandstate[bandunit]-> - hw_rateset, true, - wlc->stf->txstreams)) +if (brcmu_rate_hwrs_filter_sort_validate (&new, + &wlc->bandstate[bandunit]->hw_rateset, + true, wlc->stf->txstreams)) goto good; }
@@ -5605,7 +5604,7 @@ u16 brcms_b_rate_shm_offset(struct brcms_hardware *wlc_hw, u8 rate)/* for a given rate, the LS-nibble of the PLCP SIGNAL field is * the index into the rate table. */ - phy_rate = rate_info[rate] &BRCMS_RATE_MASK ; + phy_rate = brcmu_rate_info[rate] &BRCMS_RATE_MASK ; index = phy_rate &0xf ;/* Find the SHM pointer to the rate table entry by looking in the
@@ -5979,7 +5978,7 @@ brcms_c_compute_ofdm_plcp(u32 rspec, u32 length, u8 *plcp)* encode rate per 802.11a-1999 sec 17.3.4.1, with lsb * transmitted first */ - rate_signal = rate_info[rate] &BRCMS_RATE_MASK ; + rate_signal = brcmu_rate_info[rate] &BRCMS_RATE_MASK ;memset (plcp,0 ,D11_PHY_HDR_LEN );D11A_PHY_HDR_SRATE ((struct ofdm_phy_hdr *) plcp, rate_signal);
@@ -6079,7 +6078,7 @@ static u16 brcms_c_phytxctl1_calc(struct brcms_c_info *wlc, u32 rspec)/* bw, stf, coding-type is part of rspec_phytxbyte2 returns */ phyctl1 =rspec_phytxbyte2 (rspec);/* set the upper byte of phyctl1 */ - phyctl1 |= (mcs_table[mcs].tx_phy_ctl3 <<8 ); + phyctl1 |= (brcmu_mcs_table[mcs].tx_phy_ctl3 <<8 ); }else if (is_cck_rate (rspec) && !BRCMS_ISLCNPHY (wlc->band) && !BRCMS_ISSSLPNPHY (wlc->band)) {/*
@@ -6092,7 +6091,7 @@ static u16 brcms_c_phytxctl1_calc(struct brcms_c_info *wlc, u32 rspec) }else {/* legacy OFDM/CCK */ s16 phycfg;/* get the phyctl byte from rate phycfg table */ - phycfg =brcms_c_rate_legacy_phyctl (rspec2rate (rspec)); + phycfg =brcmu_rate_legacy_phyctl (rspec2rate (rspec));if (phycfg ==-1 ) {brcms_err (wlc->hw->d11core,"phytxctl1_calc: wrong " "legacy OFDM/CCK rate\n" );
@@ -6983,7 +6982,7 @@ prep_mac80211_status(struct brcms_c_info *wlc, struct d11rxhdr *rxh, plcp = p->data; - rspec =brcms_c_compute_rspec (rxh, plcp); + rspec =brcmu_compute_rspec (rxh, plcp);if (is_mcs_rate (rspec)) { rx_status->rate_idx = rspec &RSPEC_RATE_MASK ; rx_status->encoding =RX_ENC_HT ;
@@ -7157,8 +7156,8 @@ brcms_c_mod_prb_rsp_rate_table(struct brcms_c_info *wlc, uint frame_len) rs_dflt =brcms_c_rateset_get_hwrs (wlc); -brcms_c_rateset_copy (rs_dflt, &rs); -brcms_c_rateset_mcs_upd (&rs, wlc->stf->txstreams); +brcmu_rateset_copy (rs_dflt, &rs); +brcmu_rateset_mcs_upd (&rs, wlc->stf->txstreams);/* * walk the phy rate table and update MAC core SHM
@@ -7949,10 +7948,10 @@ brcms_c_attach(struct brcms_info *wl, struct bcma_device *core, uint unit,brcms_default_rateset (wlc, &wlc->band->defrateset);/* fill in hw_rateset */ -brcms_c_rateset_filter (&wlc->band->defrateset, - &wlc->band->hw_rateset, false, -BRCMS_RATES_CCK_OFDM ,BRCMS_RATE_MASK , - (bool ) (wlc->pub->_n_enab &SUPPORT_11N )); +brcmu_rateset_filter (&wlc->band->defrateset, + &wlc->band->hw_rateset, false, +BRCMS_RATES_CCK_OFDM ,BRCMS_RATE_MASK , + (bool )(wlc->pub->_n_enab &SUPPORT_11N )); }/*
drivers/net/wireless/broadcom/brcm80211/brcmsmac/rate.c +44 -44
235 lines not on this page · raw message
drivers/net/wireless/broadcom/brcm80211/brcmsmac/rate.h +34 -34
121 lines not on this page · raw message
Signature · 1 line
2.53.0
PATCH v2 5/11 wifi: brcmsmac: round short-GI L-SIG lengths up to whole symbols
In reply to Ragul BalajiThe L-SIG length of a mixed-mode frame covers its HT part in 4 us legacy symbols. For a short guard interval, the HT PHY's TXTIME counts the data symbols at the guard-independent bits per symbol, then rounds their 3.6 us each up to 4 us units.
brcms_c_calc_lsig_len() instead divides the bits by the short-GI rate, which rounds the symbols down before scaling them and uses the rounded- up rates of the MCS table, so it can count one symbol less than the frame takes. Count the symbols at the long-GI rate and scale them.
--- drivers/net/wireless/broadcom/brcm80211/brcmsmac/main.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/net/wireless/broadcom/brcm80211/brcmsmac/main.c +5 -3
@@ -7114,9 +7114,8 @@ brcms_c_calc_lsig_len(struct brcms_c_info *wlc, u32 ratespec,* the payload duration calculation matches that * of regular ofdm */ -/* 1000Ndbps = kbps * 4 */ - kNdps =mcs_2_rate (mcs,rspec_is40mhz (ratespec), -rspec_issgi (ratespec)) *4 ; +/* 1000Ndbps = kbps * 4, at the long-GI rate */ + kNdps =mcs_2_rate (mcs,rspec_is40mhz (ratespec), false) *4 ;if (rspec_stc (ratespec) ==0 ) nsyms =
@@ -7129,6 +7128,9 @@ brcms_c_calc_lsig_len(struct brcms_c_info *wlc, u32 ratespec,CEIL ((APHY_SERVICE_NBITS +8 * mac_len +APHY_TAIL_NBITS ) *1000 ,2 * kNdps); +/* short-GI symbols (3.6 us) in 4 us units, rounded up */ +if (rspec_issgi (ratespec)) + nsyms =CEIL (nsyms *9 ,10 );/* (+3) account for HT-SIG(2) and HT-STF(1) */ nsyms += (tot_streams +3 );/*
Signature · 1 line
2.53.0
PATCH v2 6/11 wifi: brcmsmac: pass the band to the PLCP and frame timing helpers
In reply to Ragul BalajiThe functions computing the PLCP headers, frame and response times, RTS/CTS durations, L-SIG lengths and PHY control words take the driver state, but only use the band type, PHY type and basic rate table of the current band from it. Pass those instead and give the functions the brcmu_ prefix, so that they can move to brcmutil for other drivers of the d11 core.
Their error messages lose the device name, and BRCMS_ISLCNPHY() and BRCMS_ISSSLPNPHY() become plain PHY type tests, which they are for the PHY types brcmsmac supports.
--- .../broadcom/brcm80211/brcmsmac/ampdu.c | 31 ++- .../broadcom/brcm80211/brcmsmac/main.c | 249 +++++++++--------- .../broadcom/brcm80211/brcmsmac/main.h | 10 +- 3 files changed, 150 insertions(+), 140 deletions(-)
drivers/net/wireless/broadcom/brcm80211/brcmsmac/ampdu.c +17 -14
@@ -720,14 +720,13 @@ void brcms_c_ampdu_finalize(struct brcms_ampdu_session *session)/* reset the mixed mode header durations */ if (txh->MModeLen) { -u16 mmodelen =brcms_c_calc_lsig_len (wlc, rspec, - session->ampdu_len); +u16 mmodelen =brcmu_calc_lsig_len (rspec, session->ampdu_len); txh->MModeLen =cpu_to_le16 (mmodelen); preamble_type =BRCMS_MM_PREAMBLE ; }if (txh->MModeFbrLen) { -u16 mmfbrlen =brcms_c_calc_lsig_len (wlc, rspec_fallback, - session->ampdu_len); +u16 mmfbrlen =brcmu_calc_lsig_len (rspec_fallback, + session->ampdu_len); txh->MModeFbrLen =cpu_to_le16 (mmfbrlen); fbr_preamble_type =BRCMS_MM_PREAMBLE ; }
@@ -753,17 +752,21 @@ void brcms_c_ampdu_finalize(struct brcms_ampdu_session *session) TXC_PREAMBLE_RTS_FB_SHORT) rts_fbr_preamble_type =BRCMS_SHORT_PREAMBLE ; - durid =brcms_c_compute_rtscts_dur (wlc, use_cts, rts_rspec, - rspec, rts_preamble_type, - preamble_type, - session->ampdu_len, true); + durid =brcmu_compute_rtscts_dur (wlc->band->bandtype, + wlc->band->basic_rate, + use_cts, rts_rspec, + rspec, rts_preamble_type, + preamble_type, + session->ampdu_len, true); rts->duration =cpu_to_le16 (durid); - durid =brcms_c_compute_rtscts_dur (wlc, use_cts, - rts_rspec_fallback, - rspec_fallback, - rts_fbr_preamble_type, - fbr_preamble_type, - session->ampdu_len, true); + durid =brcmu_compute_rtscts_dur (wlc->band->bandtype, + wlc->band->basic_rate, + use_cts, + rts_rspec_fallback, + rspec_fallback, + rts_fbr_preamble_type, + fbr_preamble_type, + session->ampdu_len, true); txh->RTSDurFallback =cpu_to_le16 (durid);/* set TxFesTimeNormal */ txh->TxFesTimeNormal = rts->duration;
drivers/net/wireless/broadcom/brcm80211/brcmsmac/main.c +128 -121
575 lines not on this page · raw message
drivers/net/wireless/broadcom/brcm80211/brcmsmac/main.h +5 -5
@@ -614,13 +614,13 @@ int brcms_b_xmtfifo_sz_get(struct brcms_hardware *wlc_hw, uint fifo,int brcms_c_set_gmode (struct brcms_c_info *wlc,u8 gmode,bool config);void brcms_c_mac_promisc (struct brcms_c_info *wlc,uint filter_flags); -u16 brcms_c_calc_lsig_len (struct brcms_c_info *wlc,u32 ratespec,uint mac_len); +u16 brcmu_calc_lsig_len (u32 ratespec,uint mac_len);u32 brcms_c_rspec_to_rts_rspec (struct brcms_c_info *wlc,u32 rspec,bool use_rspec,u16 mimo_ctlchbw); -u16 brcms_c_compute_rtscts_dur (struct brcms_c_info *wlc,bool cts_only, -u32 rts_rate,u32 frame_rate, -u8 rts_preamble_type,u8 frame_preamble_type, -uint frame_len,bool ba); +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);void brcms_c_inval_dma_pkts (struct brcms_hardware *hw,struct ieee80211_sta *sta,void (*dma_callback_fn));void brcms_c_update_probe_resp (struct brcms_c_info *wlc,bool suspend);
Signature · 1 line
2.53.0
PATCH v2 7/11 wifi: brcmsmac: move the PLCP and frame timing helpers to rate.c
In reply to Ragul BalajiMove the functions computing PLCP headers, frame and response times, RTS/CTS durations, L-SIG lengths and PHY control words, with the basic rate lookup they use, from main.c to rate.c, so that they move to brcmutil with the rate helpers. brcmu_rate_legacy_phyctl() is then only used in rate.c and becomes static.
--- .../broadcom/brcm80211/brcmsmac/main.c | 487 ------------------ .../broadcom/brcm80211/brcmsmac/main.h | 13 - .../broadcom/brcm80211/brcmsmac/rate.c | 471 ++++++++++++++++- .../broadcom/brcm80211/brcmsmac/rate.h | 50 +- 4 files changed, 518 insertions(+), 503 deletions(-)
drivers/net/wireless/broadcom/brcm80211/brcmsmac/main.c +0 -487
@@ -81,31 +81,13 @@#define EDCF_TXOP2USEC (txop) ((txop) << 5)#define EDCF_ECW2CW (exp) ((1 << (exp)) - 1) -#define APHY_SYMBOL_TIME 4 -#define APHY_PREAMBLE_TIME 16 -#define APHY_SIGNAL_TIME 4 -#define APHY_SIFS_TIME 16 -#define APHY_SERVICE_NBITS 16 -#define APHY_TAIL_NBITS 6 -#define BPHY_SIFS_TIME 10 -#define BPHY_PLCP_SHORT_TIME 96 - -#define PREN_PREAMBLE 24 -#define PREN_MM_EXT 12 -#define PREN_PREAMBLE_EXT 4 -#define DOT11_MAC_HDR_LEN 24 -#define DOT11_ACK_LEN 10 -#define DOT11_BA_LEN 4 -#define DOT11_OFDM_SIGNAL_EXTENSION 6#define DOT11_MIN_FRAG_LEN 256#define DOT11_RTS_LEN 16#define DOT11_CTS_LEN 10 -#define DOT11_BA_BITMAP_LEN 128#define DOT11_MAXNUMFRAGS 16#define DOT11_MAX_FRAG_LEN 2346 -#define BPHY_PLCP_TIME 192#define RIFS_11N_TIME 2/* length of the BCN template area */
@@ -343,15 +325,6 @@ static u8 brcms_fifo_to_ac(u8 fifo)return fifo_to_ac_mapping[fifo]; } -/* Find basic rate for a given rate */ -static u8 brcmu_basic_rate (const u8 *basic_rate,u32 rspec) -{ -if (is_mcs_rate (rspec)) -return basic_rate[brcmu_mcs_table[rspec &RSPEC_RATE_MASK ] - .leg_ofdm]; -return basic_rate[rspec &RSPEC_RATE_MASK ]; -} -static u16 frametype (u32 rspec,u8 mimoframe) {if (is_mcs_rate (rspec))
@@ -359,12 +332,6 @@ static u16 frametype(u32 rspec, u8 mimoframe)return is_cck_rate (rspec) ?FT_CCK :FT_OFDM ; } -/* currently the best mechanism for determining SIFS is the band in use */ -static u16 brcmu_get_sifs (int bandtype) -{ -return bandtype ==BRCM_BAND_5G ?APHY_SIFS_TIME :BPHY_SIFS_TIME ; -} -/* * Detect Card removed. * Even checking an sbconfig register read will not false trigger when the core
@@ -566,74 +533,6 @@ static void brcms_b_update_slot_timing(struct brcms_hardware *wlc_hw, } } -/* -* calculate frame duration of a given rate and length, return -* time in usec unit -*/ -static uint brcmu_calc_frame_time (int bandtype,u32 ratespec, -u8 preamble_type,uint mac_len) -{ -uint nsyms, dur =0 , Ndps, kNdps; -uint rate =rspec2rate (ratespec); - -if (rate ==0 ) { -pr_err ("WAR: using rate of 1 mbps\n" ); - rate =BRCM_RATE_1M ; - } - -if (is_mcs_rate (ratespec)) { -uint mcs = ratespec &RSPEC_RATE_MASK ; -int tot_streams =mcs_2_txstreams (mcs) +rspec_stc (ratespec); - - dur =PREN_PREAMBLE + (tot_streams *PREN_PREAMBLE_EXT ); -if (preamble_type ==BRCMS_MM_PREAMBLE ) - dur +=PREN_MM_EXT ; -/* 1000Ndbps = kbps * 4 */ - kNdps =mcs_2_rate (mcs,rspec_is40mhz (ratespec), -rspec_issgi (ratespec)) *4 ; - -if (rspec_stc (ratespec) ==0 ) - nsyms = -CEIL ((APHY_SERVICE_NBITS +8 * mac_len + -APHY_TAIL_NBITS ) *1000 , kNdps); -else -/* STBC needs to have even number of symbols */ - nsyms = -2 * -CEIL ((APHY_SERVICE_NBITS +8 * mac_len + -APHY_TAIL_NBITS ) *1000 ,2 * kNdps); - - dur +=APHY_SYMBOL_TIME * nsyms; -if (bandtype ==BRCM_BAND_2G ) - dur +=DOT11_OFDM_SIGNAL_EXTENSION ; - }else if (is_ofdm_rate (rate)) { - dur =APHY_PREAMBLE_TIME ; - dur +=APHY_SIGNAL_TIME ; -/* Ndbps = Mbps * 4 = rate(500Kbps) * 2 */ - Ndps = rate *2 ; -/* NSyms = CEILING((SERVICE + 8*NBytes + TAIL) / Ndbps) */ - nsyms = -CEIL ((APHY_SERVICE_NBITS +8 * mac_len +APHY_TAIL_NBITS ), - Ndps); - dur +=APHY_SYMBOL_TIME * nsyms; -if (bandtype ==BRCM_BAND_2G ) - dur +=DOT11_OFDM_SIGNAL_EXTENSION ; - }else { -/* -* calc # bits * 2 so factor of 2 in rate (1/2 mbps) -* will divide out -*/ - mac_len = mac_len *8 *2 ; -/* calc ceiling of bits/rate = microseconds of air time */ - dur = (mac_len + rate -1 ) / rate; -if (preamble_type &BRCMS_SHORT_PREAMBLE ) - dur +=BPHY_PLCP_SHORT_TIME ; -else - dur +=BPHY_PLCP_TIME ; - } -return dur; -} -static void brcms_c_write_inits (struct brcms_hardware *wlc_hw,const struct d11init *inits) {
@@ -3361,100 +3260,6 @@ brcms_default_rateset(struct brcms_c_info *wlc, struct brcms_c_rateset *rs) wlc->stf->txstreams); } -/* derive basic_rate[] table 'br' from 'rateset' */ -static void brcmu_rate_lookup_init (u8 *br, -const struct brcms_c_rateset *hw_rateset, -struct brcms_c_rateset *rateset) -{ -u8 rate; -u8 mandatory; -u8 cck_basic =0 ; -u8 ofdm_basic =0 ; -uint i; - -/* incoming rates are in 500kbps units as in 802.11 Supported Rates */ -memset (br,0 ,BRCM_MAXRATE +1 ); - -/* For each basic rate in the rates list, make an entry in the -* best basic lookup. -*/ -for (i =0 ; i < rateset->count; i++) { -/* only make an entry for a basic rate */ -if (!(rateset->rates[i] &BRCMS_RATE_FLAG )) -continue ; - -/* mask off basic bit */ - rate = (rateset->rates[i] &BRCMS_RATE_MASK ); - -if (rate >BRCM_MAXRATE ) { -pr_err ("%s: invalid rate 0x%X in rate set\n" , __func__, - rateset->rates[i]); -continue ; - } - - br[rate] = rate; - } - -/* The rate lookup table now has non-zero entries for each -* basic rate, equal to the basic rate: br[basicN] = basicN -* -* To look up the best basic rate corresponding to any -* particular rate, code can use the basic_rate table -* like this -* -* basic_rate = wlc->band->basic_rate[tx_rate] -* -* Make sure there is a best basic rate entry for -* every rate by walking up the table from low rates -* to high, filling in holes in the lookup table -*/ - -for (i =0 ; i < hw_rateset->count; i++) { - rate = hw_rateset->rates[i]; - -if (br[rate] !=0 ) { -/* This rate is a basic rate. -* Keep track of the best basic rate so far by -* modulation type. -*/ -if (is_ofdm_rate (rate)) - ofdm_basic = rate; -else - cck_basic = rate; - -continue ; - } - -/* This rate is not a basic rate so figure out the -* best basic rate less than this rate and fill in -* the hole in the table -*/ - - br[rate] =is_ofdm_rate (rate) ? ofdm_basic : cck_basic; - -if (br[rate] !=0 ) -continue ; - -if (is_ofdm_rate (rate)) { -/* -* In 11g and 11a, the OFDM mandatory rates -* are 6, 12, and 24 Mbps -*/ -if (rate >=BRCM_RATE_24M ) - mandatory =BRCM_RATE_24M ; -else if (rate >=BRCM_RATE_12M ) - mandatory =BRCM_RATE_12M ; -else - mandatory =BRCM_RATE_6M ; - }else { -/* In 11b, all CCK rates are mandatory 1 - 11 Mbps */ - mandatory = rate; - } - - br[rate] = mandatory; - } -} -static void brcms_c_bandinit_ordered (struct brcms_c_info *wlc,u16 chanspec) {
@@ -5633,48 +5438,6 @@ bcmc_fid_generate(struct brcms_c_info *wlc, struct brcms_bss_cfg *bsscfg,return frameid; } -static uint -brcmu_calc_ack_time (int bandtype,const u8 *basic_rate,u32 rspec, -u8 preamble_type) -{ -uint dur =0 ; - -/* -* Spec 9.6: ack rate is the highest rate in BSSBasicRateSet that -* is less than or equal to the rate of the immediately previous -* frame in the FES -*/ - rspec =brcmu_basic_rate (basic_rate, rspec); -/* ACK frame len == 14 == 2(fc) + 2(dur) + 6(ra) + 4(fcs) */ - dur = -brcmu_calc_frame_time (bandtype, rspec, preamble_type, - (DOT11_ACK_LEN +FCS_LEN )); -return dur; -} - -static uint -brcmu_calc_cts_time (int bandtype,const u8 *basic_rate,u32 rspec, -u8 preamble_type) -{ -return brcmu_calc_ack_time (bandtype, basic_rate, rspec, preamble_type); -} - -static uint -brcmu_calc_ba_time (int bandtype,const u8 *basic_rate,u32 rspec, -u8 preamble_type) -{ -/* -* Spec 9.6: ack rate is the highest rate in BSSBasicRateSet that -* is less than or equal to the rate of the immediately previous -* frame in the FES -*/ - rspec =brcmu_basic_rate (basic_rate, rspec); -/* BA len == 32 == 16(ctl hdr) + 4(ba len) + 8(bitmap) + 4(fcs) */ -return brcmu_calc_frame_time (bandtype, rspec, preamble_type, - (DOT11_BA_LEN +DOT11_BA_BITMAP_LEN + -FCS_LEN )); -} -/* brcms_c_compute_frame_dur() * * Calculate the 802.11 MAC header DUR field for MPDU
@@ -5899,207 +5662,6 @@ mac80211_wlc_set_nrate(struct brcms_c_info *wlc, struct brcms_band *cur_band,return rate; } -/* -* Compute PLCP, but only requires actual rate and length of pkt. -* Rate is given in the driver standard multiple of 500 kbps. -* le is set for 11 Mbps rate if necessary. -* Broken out for PRQ. -*/ - -static void brcmu_cck_plcp_set (int rate_500,uint length,u8 *plcp) -{ -u16 usec =0 ; -u8 le =0 ; - -switch (rate_500) { -case BRCM_RATE_1M : - usec = length <<3 ; -break ; -case BRCM_RATE_2M : - usec = length <<2 ; -break ; -case BRCM_RATE_5M5 : - usec = (length <<4 ) /11 ; -if ((length <<4 ) - (usec *11 ) >0 ) - usec++; -break ; -case BRCM_RATE_11M : - usec = (length <<3 ) /11 ; -if ((length <<3 ) - (usec *11 ) >0 ) { - usec++; -if ((usec *11 ) - (length <<3 ) >=8 ) - le =D11B_PLCP_SIGNAL_LE ; - } -break ; - -default : -pr_err ("%s: unsupported rate %d\n" , __func__, rate_500); - rate_500 =BRCM_RATE_1M ; - usec = length <<3 ; -break ; - } -/* PLCP signal byte */ - plcp[0 ] = rate_500 *5 ;/* r (500kbps) * 5 == r (100kbps) */ -/* PLCP service byte */ - plcp[1 ] = (u8) (le |D11B_PLCP_SIGNAL_LOCKED ); -/* PLCP length u16, little endian */ - plcp[2 ] = usec &0xff ; - plcp[3 ] = (usec >>8 ) &0xff ; -/* PLCP CRC16 */ - plcp[4 ] =0 ; - plcp[5 ] =0 ; -} - -/* Rate: 802.11 rate code, length: PSDU length in octets */ -static void brcmu_compute_mimo_plcp (u32 rspec,uint length,u8 *plcp) -{ -u8 mcs = (u8) (rspec &RSPEC_RATE_MASK ); - plcp[0 ] = mcs; -if (rspec_is40mhz (rspec) || (mcs ==32 )) - plcp[0 ] |=MIMO_PLCP_40MHZ ; -BRCMS_SET_MIMO_PLCP_LEN (plcp, length); - plcp[3 ] =rspec_mimoplcp3 (rspec);/* rspec already holds this byte */ - plcp[3 ] |=0x7 ;/* set smoothing, not sounding ppdu & reserved */ - plcp[4 ] =0 ;/* number of extension spatial streams bit 0 & 1 */ - plcp[5 ] =0 ; -} - -/* Rate: 802.11 rate code, length: PSDU length in octets */ -static void -brcmu_compute_ofdm_plcp (u32 rspec,u32 length,u8 *plcp) -{ -u8 rate_signal; -u32 tmp =0 ; -int rate =rspec2rate (rspec); - -/* -* encode rate per 802.11a-1999 sec 17.3.4.1, with lsb -* transmitted first -*/ - rate_signal = brcmu_rate_info[rate] &BRCMS_RATE_MASK ; -memset (plcp,0 ,D11_PHY_HDR_LEN ); -D11A_PHY_HDR_SRATE ((struct ofdm_phy_hdr *) plcp, rate_signal); - - tmp = (length &0xfff ) <<5 ; - plcp[2 ] |= (tmp >>16 ) &0xff ; - plcp[1 ] |= (tmp >>8 ) &0xff ; - plcp[0 ] |= tmp &0xff ; -} - -/* Rate: 802.11 rate code, length: PSDU length in octets */ -static void brcmu_compute_cck_plcp (u32 rspec,uint length,u8 *plcp) -{ -int rate =rspec2rate (rspec); - -brcmu_cck_plcp_set (rate, length, plcp); -} - -static void -brcmu_compute_plcp (u32 rspec,uint length,u8 *plcp) -{ -if (is_mcs_rate (rspec)) -brcmu_compute_mimo_plcp (rspec, length, plcp); -else if (is_ofdm_rate (rspec)) -brcmu_compute_ofdm_plcp (rspec, length, plcp); -else -brcmu_compute_cck_plcp (rspec, length, plcp); -} - -/* brcmu_compute_rtscts_dur() -* -* Calculate the 802.11 MAC header DUR field for an RTS or CTS frame -* DUR for normal RTS/CTS w/ frame = 3 SIFS + 1 CTS + next frame time + 1 ACK -* DUR for CTS-TO-SELF w/ frame = 2 SIFS + next frame time + 1 ACK -* -* cts cts-to-self or rts/cts -* rts_rate rts or cts rate in unit of 500kbps -* rate next MPDU rate in unit of 500kbps -* frame_len next MPDU frame length in bytes -*/ -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) -{ -u16 dur, sifs; - - sifs =brcmu_get_sifs (bandtype); - -if (!cts_only) { -/* RTS/CTS */ - dur =3 * sifs; - dur += - (u16 )brcmu_calc_cts_time (bandtype, basic_rate, rts_rate, - rts_preamble_type); - }else { -/* CTS-TO-SELF */ - dur =2 * sifs; - } - - dur += - (u16 )brcmu_calc_frame_time (bandtype, frame_rate, - frame_preamble_type, frame_len); -if (ba) - dur += - (u16 )brcmu_calc_ba_time (bandtype, basic_rate, frame_rate, -BRCMS_SHORT_PREAMBLE ); -else - dur += - (u16 )brcmu_calc_ack_time (bandtype, basic_rate, frame_rate, - frame_preamble_type); -return dur; -} - -static u16 brcmu_phytxctl1_calc (u16 phytype,u32 rspec) -{ -u16 phyctl1 =0 ; -u16 bw; - -if (phytype ==PHY_TYPE_LCN ) { - bw =PHY_TXC1_BW_20MHZ ; - }else { - bw =rspec_get_bw (rspec); -/* 10Mhz is not supported yet */ -if (bw <PHY_TXC1_BW_20MHZ ) { -pr_err ("%s: bw %d is not supported yet, set to 20L\n" , - __func__, bw); - bw =PHY_TXC1_BW_20MHZ ; - } - } - -if (is_mcs_rate (rspec)) { -uint mcs = rspec &RSPEC_RATE_MASK ; - -/* bw, stf, coding-type is part of rspec_phytxbyte2 returns */ - phyctl1 =rspec_phytxbyte2 (rspec); -/* set the upper byte of phyctl1 */ - phyctl1 |= (brcmu_mcs_table[mcs].tx_phy_ctl3 <<8 ); - }else if (is_cck_rate (rspec) && phytype !=PHY_TYPE_LCN && - phytype !=PHY_TYPE_SSN ) { -/* -* In CCK mode LPPHY overloads OFDM Modulation bits with CCK -* Data Rate. Eventually MIMOPHY would also be converted to -* this format -*/ -/* 0 = 1Mbps; 1 = 2Mbps; 2 = 5.5Mbps; 3 = 11Mbps */ - phyctl1 = (bw | (rspec_stf (rspec) <<PHY_TXC1_MODE_SHIFT )); - }else {/* legacy OFDM/CCK */ -s16 phycfg; -/* get the phyctl byte from rate phycfg table */ - phycfg =brcmu_rate_legacy_phyctl (rspec2rate (rspec)); -if (phycfg ==-1 ) { -pr_err ("%s: wrong legacy OFDM/CCK rate\n" , __func__); - phycfg =0 ; - } -/* set the upper byte of phyctl1 */ - phyctl1 = - (bw | (phycfg <<8 ) | - (rspec_stf (rspec) <<PHY_TXC1_MODE_SHIFT )); - } -return phyctl1; -} -/* * Add struct d11txh, struct cck_phy_hdr. *
@@ -7100,55 +6662,6 @@ brcms_c_recvctl(struct brcms_c_info *wlc, struct d11rxhdr *rxh,ieee80211_rx_irqsafe (wlc->pub->ieee_hw, p); } -/* calculate frame duration for Mixed-mode L-SIG spoofing, return -* number of bytes goes in the length field -* -* Formula given by HT PHY Spec v 1.13 -* len = 3(nsyms + nstream + 3) - 3 -*/ -u16 -brcmu_calc_lsig_len (u32 ratespec,uint mac_len) -{ -uint nsyms, len =0 , kNdps; - -if (is_mcs_rate (ratespec)) { -uint mcs = ratespec &RSPEC_RATE_MASK ; -int tot_streams = (mcs_2_txstreams (mcs) +1 ) + -rspec_stc (ratespec); - -/* -* the payload duration calculation matches that -* of regular ofdm -*/ -/* 1000Ndbps = kbps * 4, at the long-GI rate */ - kNdps =mcs_2_rate (mcs,rspec_is40mhz (ratespec), false) *4 ; - -if (rspec_stc (ratespec) ==0 ) - nsyms = -CEIL ((APHY_SERVICE_NBITS +8 * mac_len + -APHY_TAIL_NBITS ) *1000 , kNdps); -else -/* STBC needs to have even number of symbols */ - nsyms = -2 * -CEIL ((APHY_SERVICE_NBITS +8 * mac_len + -APHY_TAIL_NBITS ) *1000 ,2 * kNdps); - -/* short-GI symbols (3.6 us) in 4 us units, rounded up */ -if (rspec_issgi (ratespec)) - nsyms =CEIL (nsyms *9 ,10 ); -/* (+3) account for HT-SIG(2) and HT-STF(1) */ - nsyms += (tot_streams +3 ); -/* -* 3 bytes/symbol @ legacy 6Mbps rate -* (-3) excluding service bits and tail bits -*/ - len = (3 * nsyms) -3 ; - } - -return (u16 ) len; -} -static void brcms_c_mod_prb_rsp_rate_table (struct brcms_c_info *wlc,uint frame_len) {
drivers/net/wireless/broadcom/brcm80211/brcmsmac/main.h +0 -13
@@ -78,14 +78,6 @@#define BRCMS_SHORTSLOT_OFF 0/* Turn off short slot */ #define BRCMS_SHORTSLOT_ON 1/* Turn on short slot */ -/* value for short/long and mixmode/greenfield preamble */ -#define BRCMS_LONG_PREAMBLE (0) -#define BRCMS_SHORT_PREAMBLE (1 << 0) -#define BRCMS_GF_PREAMBLE (1 << 1) -#define BRCMS_MM_PREAMBLE (1 << 2) -#define BRCMS_IS_MIMO_PREAMBLE (_pre) (((_pre) == BRCMS_GF_PREAMBLE) || \ - ((_pre) == BRCMS_MM_PREAMBLE)) -/* promote boardrev */ #define BOARDREV_PROMOTABLE 0xFF/* from */ #define BOARDREV_PROMOTED 1/* to */
@@ -614,13 +606,8 @@ int brcms_b_xmtfifo_sz_get(struct brcms_hardware *wlc_hw, uint fifo,int brcms_c_set_gmode (struct brcms_c_info *wlc,u8 gmode,bool config);void brcms_c_mac_promisc (struct brcms_c_info *wlc,uint filter_flags); -u16 brcmu_calc_lsig_len (u32 ratespec,uint mac_len);u32 brcms_c_rspec_to_rts_rspec (struct brcms_c_info *wlc,u32 rspec,bool use_rspec,u16 mimo_ctlchbw); -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);void brcms_c_inval_dma_pkts (struct brcms_hardware *hw,struct ieee80211_sta *sta,void (*dma_callback_fn));void brcms_c_update_probe_resp (struct brcms_c_info *wlc,bool suspend);
drivers/net/wireless/broadcom/brcm80211/brcmsmac/rate.c +470 -1
492 lines not on this page · raw message
drivers/net/wireless/broadcom/brcm80211/brcmsmac/rate.h +48 -2
65 lines not on this page · raw message
Signature · 1 line
2.53.0
PATCH v2 8/11 wifi: brcmsmac: move the RTS rate selection to rate.c
In reply to Ragul BalajiMove the RTS and CTS ratespec selection of brcms_c_rspec_to_rts_rspec() to rate.c as brcmu_rspec_to_rts_rspec(),
--- .../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(-)
drivers/net/wireless/broadcom/brcm80211/brcmsmac/main.c +9 -53
@@ -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 */
drivers/net/wireless/broadcom/brcm80211/brcmsmac/rate.c +49 -0
55 lines not on this page · raw message
drivers/net/wireless/broadcom/brcm80211/brcmsmac/rate.h +10 -0
@@ -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);
Signature · 1 line
2.53.0
PATCH v2 9/11 wifi: brcm80211: move the rate helpers of brcmsmac to brcmutil
In reply to Ragul BalajiMove rate.c to brcmutil in preparation for the new driver.
PHYTYPE_IS() depends on the PHY configuration of brcmsmac, so brcmu_rateset_default() compares the PHY types directly, which is the same for the N and LCN PHYs that brcmsmac attaches. brcmu_ofdm_rates is only used in rate.c and becomes static.
---
.../broadcom/brcm80211/brcmsmac/Makefile | 1 -
.../broadcom/brcm80211/brcmsmac/ampdu.c | 2 +-
.../broadcom/brcm80211/brcmsmac/main.c | 2 +-
.../broadcom/brcm80211/brcmsmac/pub.h | 25 +--
.../broadcom/brcm80211/brcmsmac/stf.c | 2 +-
.../broadcom/brcm80211/brcmutil/Makefile | 2 +-
.../brcm80211/{brcmsmac => brcmutil}/rate.c | 142 +++++++++++-------
.../{brcmsmac/rate.h => include/brcmu_rate.h} | 38 +++--
8 files changed, 118 insertions(+), 96 deletions(-)
rename drivers/net/wireless/broadcom/brcm80211/{brcmsmac => brcmutil}/rate.c (85%)
rename drivers/net/wireless/broadcom/brcm80211/{brcmsmac/rate.h => include/brcmu_rate.h} (89%)drivers/net/wireless/broadcom/brcm80211/brcmsmac/Makefile +0 -1
@@ -29,7 +29,6 @@ brcmsmac-y := \ main.o \ phy_shim.o \ pmu.o \ - rate.o \ stf.o \ aiutils.o \ phy/phy_cmn.o \
drivers/net/wireless/broadcom/brcm80211/brcmsmac/ampdu.c +1 -1
@@ -15,7 +15,7 @@*/ #include <net/mac80211.h> -#include "rate.h" +#include <brcmu_rate.h> #include "scb.h" #include "phy/phy_hal.h" #include "antsel.h"
drivers/net/wireless/broadcom/brcm80211/brcmsmac/main.c +1 -1
@@ -24,7 +24,7 @@#include <brcm_hw_ids.h> #include <aiutils.h> #include <chipcommon.h> -#include "rate.h" +#include <brcmu_rate.h> #include "scb.h" #include "phy/phy_hal.h" #include "channel.h"
drivers/net/wireless/broadcom/brcm80211/brcmsmac/pub.h +1 -24
@@ -19,16 +19,10 @@#include <linux/bcma/bcma.h> #include <brcmu_wifi.h> +#include <brcmu_rate.h> #include "types.h" #include "defs.h" -#define BRCMS_NUMRATES 16/* max # of rates in a rateset */ - -/* bw */ -#define BRCMS_10_MHZ 10/* 10Mhz nphy channel bandwidth */ -#define BRCMS_20_MHZ 20/* 20Mhz nphy channel bandwidth */ -#define BRCMS_40_MHZ 40/* 40Mhz nphy channel bandwidth */ -#define BRCMS_RSSI_MINVAL -200/* Low value, e.g. for forcing roam */ #define BRCMS_RSSI_NO_SIGNAL -91/* NDIS RSSI link quality cutoffs */ #define BRCMS_RSSI_VERY_LOW -80/* Very low quality cutoffs */
@@ -42,10 +36,6 @@*/ #define BRCMS_TXPWR_MAX (127)/* ~32 dBm = 1,500 mW */ -/* rate related definitions */ -#define BRCMS_RATE_FLAG 0x80/* Flag to indicate it is a basic rate */ -#define BRCMS_RATE_MASK 0x7f/* Rate value mask w/o basic rate flag */ -/* legacy rx Antenna diversity for SISO rates */ #define ANT_RX_DIV_FORCE_0 0/* Use antenna 0 */ #define ANT_RX_DIV_FORCE_1 1/* Use antenna 1 */
@@ -89,8 +79,6 @@#define RXBUFSZ PKTBUFSZ -#define MAX_STREAMS_SUPPORTED 4/* max number of streams supported */ -struct brcm_rateset {/* # rates in this set */ u32 count;
@@ -98,14 +86,6 @@ struct brcm_rateset {u8 rates[WL_NUMRATES ]; }; -struct brcms_c_rateset { -uint count;/* number of rates in rates[] */ -/* rates in 500kbps units w/hi bit set if basic */ -u8 rates[BRCMS_NUMRATES ]; -u8 htphy_membership;/* HT PHY Membership */ -u8 mcs[MCSSET_LEN ];/* supported mcs index bit map */ -}; -/* All the HT-specific default advertised capabilities (including AMPDU) * should be grouped here at one place */
@@ -242,9 +222,6 @@ enum wlc_par_id {#define GMODE_LRS 5#define GMODE_MAX 6 -/* MCS values greater than this enable multiple streams */ -#define HIGHEST_SINGLE_STREAM_MCS 7 -#define MAXBANDS 2/* Maximum #of bands */ /* max number of antenna configurations */
drivers/net/wireless/broadcom/brcm80211/brcmsmac/stf.c +1 -1
@@ -18,7 +18,7 @@#include "types.h" #include <d11.h> -#include "rate.h" +#include <brcmu_rate.h> #include "phy/phy_hal.h" #include "channel.h" #include "main.h"
drivers/net/wireless/broadcom/brcm80211/brcmutil/Makefile +1 -1
@@ -7,4 +7,4 @@ ccflags-y := -I $(src)/../include obj-$(CONFIG_BRCMUTIL) += brcmutil.o -brcmutil-objs = utils.o d11.o +brcmutil-objs = utils.o d11.o rate.o
drivers/net/wireless/broadcom/brcm80211/brcmutil/rate.c renamed from drivers/net/wireless/broadcom/brcm80211/brcmsmac/rate.c +84 -58
415 lines not on this page · raw message
drivers/net/wireless/broadcom/brcm80211/include/brcmu_rate.h renamed from drivers/net/wireless/broadcom/brcm80211/brcmsmac/rate.h +29 -9
@@ -14,13 +14,36 @@* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#ifndef _BRCM_RATE_H_ -#define _BRCM_RATE_H_ +#ifndef _BRCMU_RATE_H_ +#define _BRCMU_RATE_H_ -#include "types.h" +#include <linux/types.h> +#include <brcmu_wifi.h> #include <d11.h> -#include "pub.h" -#include "phy_hal.h" + +#define BRCMS_NUMRATES 16/* max # of rates in a rateset */ + +/* bw */ +#define BRCMS_10_MHZ 10/* 10Mhz nphy channel bandwidth */ +#define BRCMS_20_MHZ 20/* 20Mhz nphy channel bandwidth */ +#define BRCMS_40_MHZ 40/* 40Mhz nphy channel bandwidth */ + +/* rate related definitions */ +#define BRCMS_RATE_FLAG 0x80/* Flag to indicate it is a basic rate */ +#define BRCMS_RATE_MASK 0x7f/* Rate value mask w/o basic rate flag */ + +#define MAX_STREAMS_SUPPORTED 4/* max number of streams supported */ + +struct brcms_c_rateset { +uint count;/* number of rates in rates[] */ +/* rates in 500kbps units w/hi bit set if basic */ +u8 rates[BRCMS_NUMRATES ]; +u8 htphy_membership;/* HT PHY Membership */ +u8 mcs[MCSSET_LEN ];/* supported mcs index bit map */ +}; + +/* MCS values greater than this enable multiple streams */ +#define HIGHEST_SINGLE_STREAM_MCS 7/* value for short/long and mixmode/greenfield preamble */ #define BRCMS_LONG_PREAMBLE (0)
@@ -50,10 +73,8 @@ extern const u8 brcmu_rate_info[];extern const struct brcms_c_rateset brcmu_cck_ofdm_mimo_rates;extern const struct brcms_c_rateset brcmu_ofdm_mimo_rates;extern const struct brcms_c_rateset brcmu_cck_ofdm_rates; -extern const struct brcms_c_rateset brcmu_ofdm_rates;extern const struct brcms_c_rateset brcmu_cck_rates;extern const struct brcms_c_rateset brcmu_gphy_legacy_rates; -extern const struct brcms_c_rateset rate_limit_1_2;struct brcms_mcs_info {/* phy rate in kbps [20Mhz] */
@@ -261,7 +282,6 @@ void brcmu_rateset_default(struct brcms_c_rateset *rs_tgt, bool mcsallow, u8 bw, u8 txstreams);void brcmu_rateset_mcs_upd (struct brcms_c_rateset *rs,u8 txstreams); -void brcmu_rateset_mcs_clear (struct brcms_c_rateset *rateset);void brcmu_rateset_mcs_build (struct brcms_c_rateset *rateset,u8 txstreams);void brcmu_rateset_bw_mcs_filter (struct brcms_c_rateset *rateset,u8 bw);
@@ -292,4 +312,4 @@ u32 brcmu_rspec_to_rts_rspec(u16 phytype, const u8 *basic_rate, bool g_prot,u16 brcmu_phytxctl1_calc (u16 phytype,u32 rspec);u16 brcmu_calc_lsig_len (u32 ratespec,uint mac_len); -#endif /* _BRCM_RATE_H_ */ +#endif /* _BRCMU_RATE_H_ */
Signature · 1 line
2.53.0
PATCH v2 10/11 wifi: brcm80211: move the channel and rate tables of brcmsmac to brcmutil
In reply to Ragul BalajiMove the 2.4 and 5 GHz channel tables and the legacy rate table to brcmutil as constant tables, so that other drivers of the d11 core can register the same channels and rates.
Also fixes a bug where multiple instances of brcmsmac share the same channel tables.
Put a copy of the channel tables in struct brcms_info so that changes to one do not affect the rest of the instances.
--- .../broadcom/brcm80211/brcmsmac/mac80211_if.c | 151 ++---------------- .../broadcom/brcm80211/brcmsmac/mac80211_if.h | 9 +- .../broadcom/brcm80211/brcmutil/Makefile | 2 +- .../broadcom/brcm80211/brcmutil/band.c | 140 ++++++++++++++++ .../broadcom/brcm80211/include/brcmu_band.h | 26 +++ 5 files changed, 185 insertions(+), 143 deletions(-) create mode 100644 drivers/net/wireless/broadcom/brcm80211/brcmutil/band.c create mode 100644 drivers/net/wireless/broadcom/brcm80211/include/brcmu_band.h
drivers/net/wireless/broadcom/brcm80211/brcmsmac/mac80211_if.c +14 -137
@@ -49,30 +49,6 @@ FIF_BCN_PRBRESP_PROMISC | \ FIF_PSPOLL) -#define CHAN2GHZ (channel, frequency, chflags) { \ - .band = NL80211_BAND_2GHZ, \ - .center_freq = (frequency), \ - .hw_value = (channel), \ - .flags = chflags, \ - .max_antenna_gain = 0, \ - .max_power = 19, \ -} - -#define CHAN5GHZ (channel, chflags) { \ - .band = NL80211_BAND_5GHZ, \ - .center_freq = 5000 + 5*(channel), \ - .hw_value = (channel), \ - .flags = chflags, \ - .max_antenna_gain = 0, \ - .max_power = 21, \ -} - -#define RATE (rate100m, _flags) { \ - .bitrate = (rate100m), \ - .flags = (_flags), \ - .hw_value = (rate100m / 5), \ -} - struct firmware_hdr { __le32 offset; __le32 len;
@@ -111,117 +87,10 @@ MODULE_DEVICE_TABLE(bcma, brcms_coreid_table);module_param_named (debug, brcm_msg_level, uint,0644 );#endif -static struct ieee80211_channel brcms_2ghz_chantable[] = { -CHAN2GHZ (1 ,2412 ,IEEE80211_CHAN_NO_HT40MINUS ), -CHAN2GHZ (2 ,2417 ,IEEE80211_CHAN_NO_HT40MINUS ), -CHAN2GHZ (3 ,2422 ,IEEE80211_CHAN_NO_HT40MINUS ), -CHAN2GHZ (4 ,2427 ,IEEE80211_CHAN_NO_HT40MINUS ), -CHAN2GHZ (5 ,2432 ,0 ), -CHAN2GHZ (6 ,2437 ,0 ), -CHAN2GHZ (7 ,2442 ,0 ), -CHAN2GHZ (8 ,2447 ,IEEE80211_CHAN_NO_HT40PLUS ), -CHAN2GHZ (9 ,2452 ,IEEE80211_CHAN_NO_HT40PLUS ), -CHAN2GHZ (10 ,2457 ,IEEE80211_CHAN_NO_HT40PLUS ), -CHAN2GHZ (11 ,2462 ,IEEE80211_CHAN_NO_HT40PLUS ), -CHAN2GHZ (12 ,2467 , -IEEE80211_CHAN_NO_IR | -IEEE80211_CHAN_NO_HT40PLUS ), -CHAN2GHZ (13 ,2472 , -IEEE80211_CHAN_NO_IR | -IEEE80211_CHAN_NO_HT40PLUS ), -CHAN2GHZ (14 ,2484 , -IEEE80211_CHAN_NO_IR | -IEEE80211_CHAN_NO_HT40PLUS |IEEE80211_CHAN_NO_HT40MINUS | -IEEE80211_CHAN_NO_OFDM ) -}; - -static struct ieee80211_channel brcms_5ghz_nphy_chantable[] = { -/* UNII-1 */ -CHAN5GHZ (36 ,IEEE80211_CHAN_NO_HT40MINUS ), -CHAN5GHZ (40 ,IEEE80211_CHAN_NO_HT40PLUS ), -CHAN5GHZ (44 ,IEEE80211_CHAN_NO_HT40MINUS ), -CHAN5GHZ (48 ,IEEE80211_CHAN_NO_HT40PLUS ), -/* UNII-2 */ -CHAN5GHZ (52 , -IEEE80211_CHAN_RADAR | -IEEE80211_CHAN_NO_IR |IEEE80211_CHAN_NO_HT40MINUS ), -CHAN5GHZ (56 , -IEEE80211_CHAN_RADAR | -IEEE80211_CHAN_NO_IR |IEEE80211_CHAN_NO_HT40PLUS ), -CHAN5GHZ (60 , -IEEE80211_CHAN_RADAR | -IEEE80211_CHAN_NO_IR |IEEE80211_CHAN_NO_HT40MINUS ), -CHAN5GHZ (64 , -IEEE80211_CHAN_RADAR | -IEEE80211_CHAN_NO_IR |IEEE80211_CHAN_NO_HT40PLUS ), -/* MID */ -CHAN5GHZ (100 , -IEEE80211_CHAN_RADAR | -IEEE80211_CHAN_NO_IR |IEEE80211_CHAN_NO_HT40MINUS ), -CHAN5GHZ (104 , -IEEE80211_CHAN_RADAR | -IEEE80211_CHAN_NO_IR |IEEE80211_CHAN_NO_HT40PLUS ), -CHAN5GHZ (108 , -IEEE80211_CHAN_RADAR | -IEEE80211_CHAN_NO_IR |IEEE80211_CHAN_NO_HT40MINUS ), -CHAN5GHZ (112 , -IEEE80211_CHAN_RADAR | -IEEE80211_CHAN_NO_IR |IEEE80211_CHAN_NO_HT40PLUS ), -CHAN5GHZ (116 , -IEEE80211_CHAN_RADAR | -IEEE80211_CHAN_NO_IR |IEEE80211_CHAN_NO_HT40MINUS ), -CHAN5GHZ (120 , -IEEE80211_CHAN_RADAR | -IEEE80211_CHAN_NO_IR |IEEE80211_CHAN_NO_HT40PLUS ), -CHAN5GHZ (124 , -IEEE80211_CHAN_RADAR | -IEEE80211_CHAN_NO_IR |IEEE80211_CHAN_NO_HT40MINUS ), -CHAN5GHZ (128 , -IEEE80211_CHAN_RADAR | -IEEE80211_CHAN_NO_IR |IEEE80211_CHAN_NO_HT40PLUS ), -CHAN5GHZ (132 , -IEEE80211_CHAN_RADAR | -IEEE80211_CHAN_NO_IR |IEEE80211_CHAN_NO_HT40MINUS ), -CHAN5GHZ (136 , -IEEE80211_CHAN_RADAR | -IEEE80211_CHAN_NO_IR |IEEE80211_CHAN_NO_HT40PLUS ), -CHAN5GHZ (140 , -IEEE80211_CHAN_RADAR | -IEEE80211_CHAN_NO_IR |IEEE80211_CHAN_NO_HT40PLUS | -IEEE80211_CHAN_NO_HT40MINUS ), -/* UNII-3 */ -CHAN5GHZ (149 ,IEEE80211_CHAN_NO_HT40MINUS ), -CHAN5GHZ (153 ,IEEE80211_CHAN_NO_HT40PLUS ), -CHAN5GHZ (157 ,IEEE80211_CHAN_NO_HT40MINUS ), -CHAN5GHZ (161 ,IEEE80211_CHAN_NO_HT40PLUS ), -CHAN5GHZ (165 ,IEEE80211_CHAN_NO_HT40PLUS |IEEE80211_CHAN_NO_HT40MINUS ) -}; - -/* -* The rate table is used for both 2.4G and 5G rates. The -* latter being a subset as it does not support CCK rates. -*/ -static struct ieee80211_rate legacy_ratetable[] = { -RATE (10 ,0 ), -RATE (20 ,IEEE80211_RATE_SHORT_PREAMBLE ), -RATE (55 ,IEEE80211_RATE_SHORT_PREAMBLE ), -RATE (110 ,IEEE80211_RATE_SHORT_PREAMBLE ), -RATE (60 ,0 ), -RATE (90 ,0 ), -RATE (120 ,0 ), -RATE (180 ,0 ), -RATE (240 ,0 ), -RATE (360 ,0 ), -RATE (480 ,0 ), -RATE (540 ,0 ), -}; -static const struct ieee80211_supported_band brcms_band_2GHz_nphy_template = { .band =NL80211_BAND_2GHZ , - .channels = brcms_2ghz_chantable, - .n_channels =ARRAY_SIZE (brcms_2ghz_chantable), - .bitrates = legacy_ratetable, - .n_bitrates =ARRAY_SIZE (legacy_ratetable), + .n_channels =ARRAY_SIZE (brcmu_2ghz_chantable), + .n_bitrates =ARRAY_SIZE (brcmu_legacy_ratetable), .ht_cap = {/* from include/linux/ieee80211.h */ .cap = IEEE80211_HT_CAP_GRN_FLD |
@@ -239,10 +108,8 @@ static const struct ieee80211_supported_band brcms_band_2GHz_nphy_template = {static const struct ieee80211_supported_band brcms_band_5GHz_nphy_template = { .band =NL80211_BAND_5GHZ , - .channels = brcms_5ghz_nphy_chantable, - .n_channels =ARRAY_SIZE (brcms_5ghz_nphy_chantable), - .bitrates = legacy_ratetable +BRCMS_LEGACY_5G_RATE_OFFSET , - .n_bitrates =ARRAY_SIZE (legacy_ratetable) - + .n_channels =ARRAY_SIZE (brcmu_5ghz_nphy_chantable), + .n_bitrates =ARRAY_SIZE (brcmu_legacy_ratetable) -BRCMS_LEGACY_5G_RATE_OFFSET , .ht_cap = { .cap = IEEE80211_HT_CAP_GRN_FLD | IEEE80211_HT_CAP_SGI_20 |
@@ -1056,11 +923,16 @@ static int ieee_hw_rate_init(struct ieee80211_hw *hw) hw->wiphy->bands[NL80211_BAND_2GHZ ] =NULL ; hw->wiphy->bands[NL80211_BAND_5GHZ ] =NULL ; +memcpy (wl->ratetable, brcmu_legacy_ratetable,sizeof (wl->ratetable)); phy_type =brcms_c_get_phy_type (wl->wlc,0 );if (phy_type ==PHY_TYPE_N || phy_type ==PHY_TYPE_LCN ) { band = &wlc->bandstate[BAND_2G_INDEX ]->band; *band = brcms_band_2GHz_nphy_template; +memcpy (wl->chantable_2ghz, brcmu_2ghz_chantable, +sizeof (wl->chantable_2ghz)); + band->channels = wl->chantable_2ghz; + band->bitrates = wl->ratetable;if (phy_type ==PHY_TYPE_LCN ) {/* Single stream */ band->ht_cap.mcs.rx_mask[1 ] =0 ;
@@ -1076,6 +948,11 @@ static int ieee_hw_rate_init(struct ieee80211_hw *hw)if (phy_type ==PHY_TYPE_N || phy_type ==PHY_TYPE_LCN ) { band = &wlc->bandstate[BAND_5G_INDEX ]->band; *band = brcms_band_5GHz_nphy_template; +memcpy (wl->chantable_5ghz, brcmu_5ghz_nphy_chantable, +sizeof (wl->chantable_5ghz)); + band->channels = wl->chantable_5ghz; + band->bitrates = wl->ratetable + +BRCMS_LEGACY_5G_RATE_OFFSET ; hw->wiphy->bands[NL80211_BAND_5GHZ ] = band; }else {return -EPERM ;
drivers/net/wireless/broadcom/brcm80211/brcmsmac/mac80211_if.h +4 -5
@@ -21,14 +21,10 @@#include <linux/interrupt.h> #include <linux/workqueue.h> #include <linux/leds.h> +#include <brcmu_band.h> #include "ucode_loader.h" #include "led.h" -/* -* Starting index for 5G rates in the -* legacy rate table. -*/ -#define BRCMS_LEGACY_5G_RATE_OFFSET 4/* softmac ioctl definitions */ #define BRCMS_SET_SHORTSLOT_OVERRIDE 146
@@ -85,6 +81,9 @@ struct brcms_info {bool mute_tx;struct brcms_led radio_led;struct led_classdev led_dev; +struct ieee80211_channel chantable_2ghz[BRCMU_NUM_2GHZ_CHANNELS ]; +struct ieee80211_channel chantable_5ghz[BRCMU_NUM_5GHZ_CHANNELS ]; +struct ieee80211_rate ratetable[BRCMU_NUM_LEGACY_RATES ]; };/* misc callbacks */
drivers/net/wireless/broadcom/brcm80211/brcmutil/Makefile +1 -1
@@ -7,4 +7,4 @@ ccflags-y := -I $(src)/../include obj-$(CONFIG_BRCMUTIL) += brcmutil.o -brcmutil-objs = utils.o d11.o rate.o +brcmutil-objs = utils.o d11.o rate.o band.o
drivers/net/wireless/broadcom/brcm80211/brcmutil/band.c new file +140 -0
140 lines not on this page · raw message
drivers/net/wireless/broadcom/brcm80211/include/brcmu_band.h new file +26 -0
@@ -0,0 +1,26 @@ +/* SPDX-License-Identifier: ISC */ +/* +* Copyright (c) 2010 Broadcom Corporation +*/ + +#ifndef _BRCMU_BAND_H_ +#define _BRCMU_BAND_H_ + +#include <net/cfg80211.h> + +#define BRCMU_NUM_2GHZ_CHANNELS 14 +#define BRCMU_NUM_5GHZ_CHANNELS 24 +#define BRCMU_NUM_LEGACY_RATES 12 + +/* +* Starting index for 5G rates in the +* legacy rate table. +*/ +#define BRCMS_LEGACY_5G_RATE_OFFSET 4 + +/* Drivers register copies of these, as cfg80211 updates their flags. */ +extern const struct ieee80211_channel brcmu_2ghz_chantable[BRCMU_NUM_2GHZ_CHANNELS ]; +extern const struct ieee80211_channel brcmu_5ghz_nphy_chantable[BRCMU_NUM_5GHZ_CHANNELS ]; +extern const struct ieee80211_rate brcmu_legacy_ratetable[BRCMU_NUM_LEGACY_RATES ]; + +#endif /* _BRCMU_BAND_H_ */
Signature · 1 line
2.53.0
PATCH v2 11/11 wifi: brcm80211: move the USB bootloader definitions to a shared header
In reply to Ragul BalajiThe Broadcom USB bootloader downloads firmware the same way for other USB chips than the FullMAC ones of brcmfmac. Move its commands, states, firmware header and response layouts from brcmfmac's usb.c to a header in the shared include directory, so that other drivers can use them.
--- .../broadcom/brcm80211/brcmfmac/usb.c | 68 +--------------- .../broadcom/brcm80211/include/brcm_usb_rdl.h | 78 +++++++++++++++++++ 2 files changed, 79 insertions(+), 67 deletions(-) create mode 100644 drivers/net/wireless/broadcom/brcm80211/include/brcm_usb_rdl.h
drivers/net/wireless/broadcom/brcm80211/brcmfmac/usb.c +1 -67
@@ -12,6 +12,7 @@#include <brcmu_utils.h> #include <brcm_hw_ids.h> #include <brcmu_wifi.h> +#include <brcm_usb_rdl.h> #include "bus.h" #include "debug.h" #include "firmware.h"
@@ -26,8 +27,6 @@#define BRCMF_USB_RESET_GETVER_SPINWAIT 100/* in unit of ms */ #define BRCMF_USB_RESET_GETVER_LOOP_CNT 10 -#define BRCMF_POSTBOOT_ID 0xA123/* ID to detect if dongle -has boot up */ #define BRCMF_USB_NRXQ 50#define BRCMF_USB_NTXQ 50
@@ -52,71 +51,6 @@ static const struct brcmf_firmware_mapping brcmf_usb_fwnames[] = {BRCMF_FW_ENTRY (CY_CC_4373_CHIP_ID ,0xFFFFFFFF ,4373 ) }; -#define TRX_MAGIC 0x30524448/* "HDR0" */ -#define TRX_MAX_OFFSET 3/* Max number of file offsets */ -#define TRX_UNCOMP_IMAGE 0x20/* Trx holds uncompressed img */ -#define TRX_RDL_CHUNK 1500/* size of each dl transfer */ -#define TRX_OFFSETS_DLFWLEN_IDX 0 - -/* Control messages: bRequest values */ -#define DL_GETSTATE 0/* returns the rdl_state_t struct */ -#define DL_CHECK_CRC 1/* currently unused */ -#define DL_GO 2/* execute downloaded image */ -#define DL_START 3/* initialize dl state */ -#define DL_REBOOT 4/* reboot the device in 2 seconds */ -#define DL_GETVER 5/* returns the bootrom_id_t struct */ -#define DL_GO_PROTECTED 6/* execute the downloaded code and set reset -* event to occur in 2 seconds. It is the -* responsibility of the downloaded code to -* clear this event -*/ -#define DL_EXEC 7/* jump to a supplied address */ -#define DL_RESETCFG 8/* To support single enum on dongle -* - Not used by bootloader -*/ -#define DL_DEFER_RESP_OK 9/* Potentially defer the response to setup -* if resp unavailable -*/ - -/* states */ -#define DL_WAITING 0/* waiting to rx first pkt */ -#define DL_READY 1/* hdr was good, waiting for more of the -* compressed image -*/ -#define DL_BAD_HDR 2/* hdr was corrupted */ -#define DL_BAD_CRC 3/* compressed image was corrupted */ -#define DL_RUNNABLE 4/* download was successful,waiting for go cmd */ -#define DL_START_FAIL 5/* failed to initialize correctly */ -#define DL_NVRAM_TOOBIG 6/* host specified nvram data exceeds DL_NVRAM -* value -*/ -#define DL_IMAGE_TOOBIG 7/* firmware image too big */ - - -struct trx_header_le { -__le32 magic;/* "HDR0" */ -__le32 len;/* Length of file including header */ -__le32 crc32;/* CRC from flag_version to end of file */ -__le32 flag_version;/* 0:15 flags, 16:31 version */ -__le32 offsets[TRX_MAX_OFFSET ];/* Offsets of partitions from start of -* header -*/ -}; - -struct rdl_state_le { -__le32 state; -__le32 bytes; -}; - -struct bootrom_id_le { -__le32 chip;/* Chip id */ -__le32 chiprev;/* Chip rev */ -__le32 ramsize;/* Size of RAM */ -__le32 remapbase;/* Current remap base address */ -__le32 boardtype;/* Type of board */ -__le32 boardrev;/* Board revision */ -}; -struct brcmf_usbdev_info {struct brcmf_usbdev bus_pub;/* MUST BE FIRST */ spinlock_t qlock;
drivers/net/wireless/broadcom/brcm80211/include/brcm_usb_rdl.h new file +78 -0
78 lines not on this page · raw message
Signature · 1 line
2.53.0