Path: blob/main/sys/contrib/dev/broadcom/brcm80211/brcmsmac/rate.c
178665 views
/*1* Copyright (c) 2010 Broadcom Corporation2*3* Permission to use, copy, modify, and/or distribute this software for any4* purpose with or without fee is hereby granted, provided that the above5* copyright notice and this permission notice appear in all copies.6*7* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES8* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF9* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY10* SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES11* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION12* OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN13* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.14*/1516#include <brcmu_wifi.h>17#include <brcmu_utils.h>1819#include "d11.h"20#include "pub.h"21#include "rate.h"2223/*24* Rate info per rate: It tells whether a rate is ofdm or not and its phy_rate25* value26*/27const u8 rate_info[BRCM_MAXRATE + 1] = {28/* 0 1 2 3 4 5 6 7 8 9 */29/* 0 */ 0x00, 0x00, 0x0a, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00,30/* 10 */ 0x00, 0x37, 0x8b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x8f, 0x00,31/* 20 */ 0x00, 0x00, 0x6e, 0x00, 0x8a, 0x00, 0x00, 0x00, 0x00, 0x00,32/* 30 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x8e, 0x00, 0x00, 0x00,33/* 40 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x89, 0x00,34/* 50 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,35/* 60 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,36/* 70 */ 0x00, 0x00, 0x8d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,37/* 80 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,38/* 90 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x88, 0x00, 0x00, 0x00,39/* 100 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x8c40};4142/* rates are in units of Kbps */43const struct brcms_mcs_info mcs_table[MCS_TABLE_SIZE] = {44/* MCS 0: SS 1, MOD: BPSK, CR 1/2 */45{6500, 13500, CEIL(6500 * 10, 9), CEIL(13500 * 10, 9), 0x00,46BRCM_RATE_6M},47/* MCS 1: SS 1, MOD: QPSK, CR 1/2 */48{13000, 27000, CEIL(13000 * 10, 9), CEIL(27000 * 10, 9), 0x08,49BRCM_RATE_12M},50/* MCS 2: SS 1, MOD: QPSK, CR 3/4 */51{19500, 40500, CEIL(19500 * 10, 9), CEIL(40500 * 10, 9), 0x0A,52BRCM_RATE_18M},53/* MCS 3: SS 1, MOD: 16QAM, CR 1/2 */54{26000, 54000, CEIL(26000 * 10, 9), CEIL(54000 * 10, 9), 0x10,55BRCM_RATE_24M},56/* MCS 4: SS 1, MOD: 16QAM, CR 3/4 */57{39000, 81000, CEIL(39000 * 10, 9), CEIL(81000 * 10, 9), 0x12,58BRCM_RATE_36M},59/* MCS 5: SS 1, MOD: 64QAM, CR 2/3 */60{52000, 108000, CEIL(52000 * 10, 9), CEIL(108000 * 10, 9), 0x19,61BRCM_RATE_48M},62/* MCS 6: SS 1, MOD: 64QAM, CR 3/4 */63{58500, 121500, CEIL(58500 * 10, 9), CEIL(121500 * 10, 9), 0x1A,64BRCM_RATE_54M},65/* MCS 7: SS 1, MOD: 64QAM, CR 5/6 */66{65000, 135000, CEIL(65000 * 10, 9), CEIL(135000 * 10, 9), 0x1C,67BRCM_RATE_54M},68/* MCS 8: SS 2, MOD: BPSK, CR 1/2 */69{13000, 27000, CEIL(13000 * 10, 9), CEIL(27000 * 10, 9), 0x40,70BRCM_RATE_6M},71/* MCS 9: SS 2, MOD: QPSK, CR 1/2 */72{26000, 54000, CEIL(26000 * 10, 9), CEIL(54000 * 10, 9), 0x48,73BRCM_RATE_12M},74/* MCS 10: SS 2, MOD: QPSK, CR 3/4 */75{39000, 81000, CEIL(39000 * 10, 9), CEIL(81000 * 10, 9), 0x4A,76BRCM_RATE_18M},77/* MCS 11: SS 2, MOD: 16QAM, CR 1/2 */78{52000, 108000, CEIL(52000 * 10, 9), CEIL(108000 * 10, 9), 0x50,79BRCM_RATE_24M},80/* MCS 12: SS 2, MOD: 16QAM, CR 3/4 */81{78000, 162000, CEIL(78000 * 10, 9), CEIL(162000 * 10, 9), 0x52,82BRCM_RATE_36M},83/* MCS 13: SS 2, MOD: 64QAM, CR 2/3 */84{104000, 216000, CEIL(104000 * 10, 9), CEIL(216000 * 10, 9), 0x59,85BRCM_RATE_48M},86/* MCS 14: SS 2, MOD: 64QAM, CR 3/4 */87{117000, 243000, CEIL(117000 * 10, 9), CEIL(243000 * 10, 9), 0x5A,88BRCM_RATE_54M},89/* MCS 15: SS 2, MOD: 64QAM, CR 5/6 */90{130000, 270000, CEIL(130000 * 10, 9), CEIL(270000 * 10, 9), 0x5C,91BRCM_RATE_54M},92/* MCS 16: SS 3, MOD: BPSK, CR 1/2 */93{19500, 40500, CEIL(19500 * 10, 9), CEIL(40500 * 10, 9), 0x80,94BRCM_RATE_6M},95/* MCS 17: SS 3, MOD: QPSK, CR 1/2 */96{39000, 81000, CEIL(39000 * 10, 9), CEIL(81000 * 10, 9), 0x88,97BRCM_RATE_12M},98/* MCS 18: SS 3, MOD: QPSK, CR 3/4 */99{58500, 121500, CEIL(58500 * 10, 9), CEIL(121500 * 10, 9), 0x8A,100BRCM_RATE_18M},101/* MCS 19: SS 3, MOD: 16QAM, CR 1/2 */102{78000, 162000, CEIL(78000 * 10, 9), CEIL(162000 * 10, 9), 0x90,103BRCM_RATE_24M},104/* MCS 20: SS 3, MOD: 16QAM, CR 3/4 */105{117000, 243000, CEIL(117000 * 10, 9), CEIL(243000 * 10, 9), 0x92,106BRCM_RATE_36M},107/* MCS 21: SS 3, MOD: 64QAM, CR 2/3 */108{156000, 324000, CEIL(156000 * 10, 9), CEIL(324000 * 10, 9), 0x99,109BRCM_RATE_48M},110/* MCS 22: SS 3, MOD: 64QAM, CR 3/4 */111{175500, 364500, CEIL(175500 * 10, 9), CEIL(364500 * 10, 9), 0x9A,112BRCM_RATE_54M},113/* MCS 23: SS 3, MOD: 64QAM, CR 5/6 */114{195000, 405000, CEIL(195000 * 10, 9), CEIL(405000 * 10, 9), 0x9B,115BRCM_RATE_54M},116/* MCS 24: SS 4, MOD: BPSK, CR 1/2 */117{26000, 54000, CEIL(26000 * 10, 9), CEIL(54000 * 10, 9), 0xC0,118BRCM_RATE_6M},119/* MCS 25: SS 4, MOD: QPSK, CR 1/2 */120{52000, 108000, CEIL(52000 * 10, 9), CEIL(108000 * 10, 9), 0xC8,121BRCM_RATE_12M},122/* MCS 26: SS 4, MOD: QPSK, CR 3/4 */123{78000, 162000, CEIL(78000 * 10, 9), CEIL(162000 * 10, 9), 0xCA,124BRCM_RATE_18M},125/* MCS 27: SS 4, MOD: 16QAM, CR 1/2 */126{104000, 216000, CEIL(104000 * 10, 9), CEIL(216000 * 10, 9), 0xD0,127BRCM_RATE_24M},128/* MCS 28: SS 4, MOD: 16QAM, CR 3/4 */129{156000, 324000, CEIL(156000 * 10, 9), CEIL(324000 * 10, 9), 0xD2,130BRCM_RATE_36M},131/* MCS 29: SS 4, MOD: 64QAM, CR 2/3 */132{208000, 432000, CEIL(208000 * 10, 9), CEIL(432000 * 10, 9), 0xD9,133BRCM_RATE_48M},134/* MCS 30: SS 4, MOD: 64QAM, CR 3/4 */135{234000, 486000, CEIL(234000 * 10, 9), CEIL(486000 * 10, 9), 0xDA,136BRCM_RATE_54M},137/* MCS 31: SS 4, MOD: 64QAM, CR 5/6 */138{260000, 540000, CEIL(260000 * 10, 9), CEIL(540000 * 10, 9), 0xDB,139BRCM_RATE_54M},140/* MCS 32: SS 1, MOD: BPSK, CR 1/2 */141{0, 6000, 0, CEIL(6000 * 10, 9), 0x00, BRCM_RATE_6M},142};143144/*145* phycfg for legacy OFDM frames: code rate, modulation scheme, spatial streams146* Number of spatial streams: always 1 other fields: refer to table 78 of147* section 17.3.2.2 of the original .11a standard148*/149struct legacy_phycfg {150u32 rate_ofdm; /* ofdm mac rate */151/* phy ctl byte 3, code rate, modulation type, # of streams */152u8 tx_phy_ctl3;153};154155/* Number of legacy_rate_cfg entries in the table */156#define LEGACY_PHYCFG_TABLE_SIZE 12157158/*159* In CCK mode LPPHY overloads OFDM Modulation bits with CCK Data Rate160* Eventually MIMOPHY would also be converted to this format161* 0 = 1Mbps; 1 = 2Mbps; 2 = 5.5Mbps; 3 = 11Mbps162*/163static const struct164legacy_phycfg legacy_phycfg_table[LEGACY_PHYCFG_TABLE_SIZE] = {165{BRCM_RATE_1M, 0x00}, /* CCK 1Mbps, data rate 0 */166{BRCM_RATE_2M, 0x08}, /* CCK 2Mbps, data rate 1 */167{BRCM_RATE_5M5, 0x10}, /* CCK 5.5Mbps, data rate 2 */168{BRCM_RATE_11M, 0x18}, /* CCK 11Mbps, data rate 3 */169/* OFDM 6Mbps, code rate 1/2, BPSK, 1 spatial stream */170{BRCM_RATE_6M, 0x00},171/* OFDM 9Mbps, code rate 3/4, BPSK, 1 spatial stream */172{BRCM_RATE_9M, 0x02},173/* OFDM 12Mbps, code rate 1/2, QPSK, 1 spatial stream */174{BRCM_RATE_12M, 0x08},175/* OFDM 18Mbps, code rate 3/4, QPSK, 1 spatial stream */176{BRCM_RATE_18M, 0x0A},177/* OFDM 24Mbps, code rate 1/2, 16-QAM, 1 spatial stream */178{BRCM_RATE_24M, 0x10},179/* OFDM 36Mbps, code rate 3/4, 16-QAM, 1 spatial stream */180{BRCM_RATE_36M, 0x12},181/* OFDM 48Mbps, code rate 2/3, 64-QAM, 1 spatial stream */182{BRCM_RATE_48M, 0x19},183/* OFDM 54Mbps, code rate 3/4, 64-QAM, 1 spatial stream */184{BRCM_RATE_54M, 0x1A},185};186187/* Hardware rates (also encodes default basic rates) */188189const struct brcms_c_rateset cck_ofdm_mimo_rates = {19012,191/* 1b, 2b, 5.5b, 6, 9, 11b, 12, 18, 24, 36, 48, */192{ 0x82, 0x84, 0x8b, 0x0c, 0x12, 0x96, 0x18, 0x24, 0x30, 0x48, 0x60,193/* 54 Mbps */1940x6c},1950x00,196{ 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,1970x00, 0x00, 0x00, 0x00, 0x00}198};199200const struct brcms_c_rateset ofdm_mimo_rates = {2018,202/* 6b, 9, 12b, 18, 24b, 36, 48, 54 Mbps */203{ 0x8c, 0x12, 0x98, 0x24, 0xb0, 0x48, 0x60, 0x6c},2040x00,205{ 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,2060x00, 0x00, 0x00, 0x00, 0x00}207};208209/* Default ratesets that include MCS32 for 40BW channels */210static const struct brcms_c_rateset cck_ofdm_40bw_mimo_rates = {21112,212/* 1b, 2b, 5.5b, 6, 9, 11b, 12, 18, 24, 36, 48 */213{ 0x82, 0x84, 0x8b, 0x0c, 0x12, 0x96, 0x18, 0x24, 0x30, 0x48, 0x60,214/* 54 Mbps */2150x6c},2160x00,217{ 0xff, 0xff, 0xff, 0xff, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,2180x00, 0x00, 0x00, 0x00, 0x00}219};220221static const struct brcms_c_rateset ofdm_40bw_mimo_rates = {2228,223/* 6b, 9, 12b, 18, 24b, 36, 48, 54 Mbps */224{ 0x8c, 0x12, 0x98, 0x24, 0xb0, 0x48, 0x60, 0x6c},2250x00,226{ 0xff, 0xff, 0xff, 0xff, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,2270x00, 0x00, 0x00, 0x00, 0x00}228};229230const struct brcms_c_rateset cck_ofdm_rates = {23112,232/* 1b, 2b, 5.5b, 6, 9, 11b, 12, 18, 24, 36, 48,*/233{ 0x82, 0x84, 0x8b, 0x0c, 0x12, 0x96, 0x18, 0x24, 0x30, 0x48, 0x60,234/*54 Mbps */2350x6c},2360x00,237{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,2380x00, 0x00, 0x00, 0x00, 0x00}239};240241const struct brcms_c_rateset gphy_legacy_rates = {2424,243/* 1b, 2b, 5.5b, 11b Mbps */244{ 0x82, 0x84, 0x8b, 0x96},2450x00,246{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,2470x00, 0x00, 0x00, 0x00, 0x00}248};249250const struct brcms_c_rateset ofdm_rates = {2518,252/* 6b, 9, 12b, 18, 24b, 36, 48, 54 Mbps */253{ 0x8c, 0x12, 0x98, 0x24, 0xb0, 0x48, 0x60, 0x6c},2540x00,255{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,2560x00, 0x00, 0x00, 0x00, 0x00}257};258259const struct brcms_c_rateset cck_rates = {2604,261/* 1b, 2b, 5.5, 11 Mbps */262{ 0x82, 0x84, 0x0b, 0x16},2630x00,264{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,2650x00, 0x00, 0x00, 0x00, 0x00}266};267268/* check if rateset is valid.269* if check_brate is true, rateset without a basic rate is considered NOT valid.270*/271static bool brcms_c_rateset_valid(struct brcms_c_rateset *rs, bool check_brate)272{273uint idx;274275if (!rs->count)276return false;277278if (!check_brate)279return true;280281/* error if no basic rates */282for (idx = 0; idx < rs->count; idx++) {283if (rs->rates[idx] & BRCMS_RATE_FLAG)284return true;285}286return false;287}288289void brcms_c_rateset_mcs_upd(struct brcms_c_rateset *rs, u8 txstreams)290{291int i;292for (i = txstreams; i < MAX_STREAMS_SUPPORTED; i++)293rs->mcs[i] = 0;294}295296/*297* filter based on hardware rateset, and sort filtered rateset with basic298* bit(s) preserved, and check if resulting rateset is valid.299*/300bool301brcms_c_rate_hwrs_filter_sort_validate(struct brcms_c_rateset *rs,302const struct brcms_c_rateset *hw_rs,303bool check_brate, u8 txstreams)304{305u8 rateset[BRCM_MAXRATE + 1];306u8 r;307uint count;308uint i;309310memset(rateset, 0, sizeof(rateset));311count = rs->count;312313for (i = 0; i < count; i++) {314/* mask off "basic rate" bit, BRCMS_RATE_FLAG */315r = (int)rs->rates[i] & BRCMS_RATE_MASK;316if ((r > BRCM_MAXRATE) || (rate_info[r] == 0))317continue;318rateset[r] = rs->rates[i]; /* preserve basic bit! */319}320321/* fill out the rates in order, looking at only supported rates */322count = 0;323for (i = 0; i < hw_rs->count; i++) {324r = hw_rs->rates[i] & BRCMS_RATE_MASK;325if (rateset[r])326rs->rates[count++] = rateset[r];327}328329rs->count = count;330331/* only set the mcs rate bit if the equivalent hw mcs bit is set */332for (i = 0; i < MCSSET_LEN; i++)333rs->mcs[i] = (rs->mcs[i] & hw_rs->mcs[i]);334335if (brcms_c_rateset_valid(rs, check_brate))336return true;337else338return false;339}340341/* calculate the rate of a rx'd frame and return it as a ratespec */342u32 brcms_c_compute_rspec(struct d11rxhdr *rxh, u8 *plcp)343{344int phy_type;345u32 rspec = PHY_TXC1_BW_20MHZ << RSPEC_BW_SHIFT;346347phy_type =348((rxh->RxChan & RXS_CHAN_PHYTYPE_MASK) >> RXS_CHAN_PHYTYPE_SHIFT);349350if ((phy_type == PHY_TYPE_N) || (phy_type == PHY_TYPE_SSN) ||351(phy_type == PHY_TYPE_LCN) || (phy_type == PHY_TYPE_HT)) {352switch (rxh->PhyRxStatus_0 & PRXS0_FT_MASK) {353case PRXS0_CCK:354rspec =355cck_phy2mac_rate(356((struct cck_phy_hdr *) plcp)->signal);357break;358case PRXS0_OFDM:359rspec =360ofdm_phy2mac_rate(361((struct ofdm_phy_hdr *) plcp)->rlpt[0]);362break;363case PRXS0_PREN:364rspec = (plcp[0] & MIMO_PLCP_MCS_MASK) | RSPEC_MIMORATE;365if (plcp[0] & MIMO_PLCP_40MHZ) {366/* indicate rspec is for 40 MHz mode */367rspec &= ~RSPEC_BW_MASK;368rspec |= (PHY_TXC1_BW_40MHZ << RSPEC_BW_SHIFT);369}370break;371case PRXS0_STDN:372/* fallthru */373default:374/* not supported, error condition */375break;376}377if (plcp3_issgi(plcp[3]))378rspec |= RSPEC_SHORT_GI;379} else380if ((phy_type == PHY_TYPE_A) || (rxh->PhyRxStatus_0 & PRXS0_OFDM))381rspec = ofdm_phy2mac_rate(382((struct ofdm_phy_hdr *) plcp)->rlpt[0]);383else384rspec = cck_phy2mac_rate(385((struct cck_phy_hdr *) plcp)->signal);386387return rspec;388}389390/* copy rateset src to dst as-is (no masking or sorting) */391void brcms_c_rateset_copy(const struct brcms_c_rateset *src,392struct brcms_c_rateset *dst)393{394memcpy(dst, src, sizeof(struct brcms_c_rateset));395}396397/*398* Copy and selectively filter one rateset to another.399* 'basic_only' means only copy basic rates.400* 'rates' indicates cck (11b) and ofdm rates combinations.401* - 0: cck and ofdm402* - 1: cck only403* - 2: ofdm only404* 'xmask' is the copy mask (typically 0x7f or 0xff).405*/406void407brcms_c_rateset_filter(struct brcms_c_rateset *src, struct brcms_c_rateset *dst,408bool basic_only, u8 rates, uint xmask, bool mcsallow)409{410uint i;411uint r;412uint count;413414count = 0;415for (i = 0; i < src->count; i++) {416r = src->rates[i];417if (basic_only && !(r & BRCMS_RATE_FLAG))418continue;419if (rates == BRCMS_RATES_CCK &&420is_ofdm_rate((r & BRCMS_RATE_MASK)))421continue;422if (rates == BRCMS_RATES_OFDM &&423is_cck_rate((r & BRCMS_RATE_MASK)))424continue;425dst->rates[count++] = r & xmask;426}427dst->count = count;428dst->htphy_membership = src->htphy_membership;429430if (mcsallow && rates != BRCMS_RATES_CCK)431memcpy(&dst->mcs[0], &src->mcs[0], MCSSET_LEN);432else433brcms_c_rateset_mcs_clear(dst);434}435436/* select rateset for a given phy_type and bandtype and filter it, sort it437* and fill rs_tgt with result438*/439void440brcms_c_rateset_default(struct brcms_c_rateset *rs_tgt,441const struct brcms_c_rateset *rs_hw,442uint phy_type, int bandtype, bool cck_only,443uint rate_mask, bool mcsallow, u8 bw, u8 txstreams)444{445const struct brcms_c_rateset *rs_dflt;446struct brcms_c_rateset rs_sel;447if ((PHYTYPE_IS(phy_type, PHY_TYPE_HT)) ||448(PHYTYPE_IS(phy_type, PHY_TYPE_N)) ||449(PHYTYPE_IS(phy_type, PHY_TYPE_LCN)) ||450(PHYTYPE_IS(phy_type, PHY_TYPE_SSN))) {451if (bandtype == BRCM_BAND_5G)452rs_dflt = (bw == BRCMS_20_MHZ ?453&ofdm_mimo_rates : &ofdm_40bw_mimo_rates);454else455rs_dflt = (bw == BRCMS_20_MHZ ?456&cck_ofdm_mimo_rates :457&cck_ofdm_40bw_mimo_rates);458} else if (PHYTYPE_IS(phy_type, PHY_TYPE_LP)) {459rs_dflt = (bandtype == BRCM_BAND_5G) ?460&ofdm_rates : &cck_ofdm_rates;461} else if (PHYTYPE_IS(phy_type, PHY_TYPE_A)) {462rs_dflt = &ofdm_rates;463} else if (PHYTYPE_IS(phy_type, PHY_TYPE_G)) {464rs_dflt = &cck_ofdm_rates;465} else {466/* should not happen, error condition */467rs_dflt = &cck_rates; /* force cck */468}469470/* if hw rateset is not supplied, assign selected rateset to it */471if (!rs_hw)472rs_hw = rs_dflt;473474brcms_c_rateset_copy(rs_dflt, &rs_sel);475brcms_c_rateset_mcs_upd(&rs_sel, txstreams);476brcms_c_rateset_filter(&rs_sel, rs_tgt, false,477cck_only ? BRCMS_RATES_CCK : BRCMS_RATES_CCK_OFDM,478rate_mask, mcsallow);479brcms_c_rate_hwrs_filter_sort_validate(rs_tgt, rs_hw, false,480mcsallow ? txstreams : 1);481}482483s16 brcms_c_rate_legacy_phyctl(uint rate)484{485uint i;486for (i = 0; i < LEGACY_PHYCFG_TABLE_SIZE; i++)487if (rate == legacy_phycfg_table[i].rate_ofdm)488return legacy_phycfg_table[i].tx_phy_ctl3;489490return -1;491}492493void brcms_c_rateset_mcs_clear(struct brcms_c_rateset *rateset)494{495uint i;496for (i = 0; i < MCSSET_LEN; i++)497rateset->mcs[i] = 0;498}499500void brcms_c_rateset_mcs_build(struct brcms_c_rateset *rateset, u8 txstreams)501{502memcpy(&rateset->mcs[0], &cck_ofdm_mimo_rates.mcs[0], MCSSET_LEN);503brcms_c_rateset_mcs_upd(rateset, txstreams);504}505506/* Based on bandwidth passed, allow/disallow MCS 32 in the rateset */507void brcms_c_rateset_bw_mcs_filter(struct brcms_c_rateset *rateset, u8 bw)508{509if (bw == BRCMS_40_MHZ)510setbit(rateset->mcs, 32);511else512clrbit(rateset->mcs, 32);513}514515516