/* * Copyright (c) 2010 Broadcom Corporation * * Permission to use, copy, modify, and/or distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #include <brcmu_wifi.h> #include <brcmu_utils.h> #include "d11.h" #include "pub.h" #include "rate.h" /* * Rate info per rate: It tells whether a rate is ofdm or not and its phy_rate * value */ const u8 rate_info[BRCM_MAXRATE + 1] = …; /* rates are in units of Kbps */ const struct brcms_mcs_info mcs_table[MCS_TABLE_SIZE] = …; /* * phycfg for legacy OFDM frames: code rate, modulation scheme, spatial streams * Number of spatial streams: always 1 other fields: refer to table 78 of * section 17.3.2.2 of the original .11a standard */ struct legacy_phycfg { … }; /* Number of legacy_rate_cfg entries in the table */ #define LEGACY_PHYCFG_TABLE_SIZE … /* * 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 */ static const struct legacy_phycfg legacy_phycfg_table[LEGACY_PHYCFG_TABLE_SIZE] = …; /* Hardware rates (also encodes default basic rates) */ const struct brcms_c_rateset cck_ofdm_mimo_rates = …; const struct brcms_c_rateset ofdm_mimo_rates = …; /* Default ratesets that include MCS32 for 40BW channels */ static const struct brcms_c_rateset cck_ofdm_40bw_mimo_rates = …; static const struct brcms_c_rateset ofdm_40bw_mimo_rates = …; const struct brcms_c_rateset cck_ofdm_rates = …; const struct brcms_c_rateset gphy_legacy_rates = …; const struct brcms_c_rateset ofdm_rates = …; const struct brcms_c_rateset cck_rates = …; /* check if rateset is valid. * if check_brate is true, rateset without a basic rate is considered NOT valid. */ static bool brcms_c_rateset_valid(struct brcms_c_rateset *rs, bool check_brate) { … } void brcms_c_rateset_mcs_upd(struct brcms_c_rateset *rs, u8 txstreams) { … } /* * filter based on hardware rateset, and sort filtered rateset with basic * bit(s) preserved, and check if resulting rateset is valid. */ bool brcms_c_rate_hwrs_filter_sort_validate(struct brcms_c_rateset *rs, const struct brcms_c_rateset *hw_rs, bool check_brate, u8 txstreams) { … } /* calculate the rate of a rx'd frame and return it as a ratespec */ u32 brcms_c_compute_rspec(struct d11rxhdr *rxh, u8 *plcp) { … } /* copy rateset src to dst as-is (no masking or sorting) */ void brcms_c_rateset_copy(const struct brcms_c_rateset *src, struct brcms_c_rateset *dst) { … } /* * Copy and selectively filter one rateset to another. * 'basic_only' means only copy basic rates. * 'rates' indicates cck (11b) and ofdm rates combinations. * - 0: cck and ofdm * - 1: cck only * - 2: ofdm only * 'xmask' is the copy mask (typically 0x7f or 0xff). */ void brcms_c_rateset_filter(struct brcms_c_rateset *src, struct brcms_c_rateset *dst, bool basic_only, u8 rates, uint xmask, bool mcsallow) { … } /* select rateset for a given phy_type and bandtype and filter it, sort it * and fill rs_tgt with result */ void brcms_c_rateset_default(struct brcms_c_rateset *rs_tgt, const struct brcms_c_rateset *rs_hw, uint phy_type, int bandtype, bool cck_only, uint rate_mask, bool mcsallow, u8 bw, u8 txstreams) { … } s16 brcms_c_rate_legacy_phyctl(uint rate) { … } void brcms_c_rateset_mcs_clear(struct brcms_c_rateset *rateset) { … } void brcms_c_rateset_mcs_build(struct brcms_c_rateset *rateset, u8 txstreams) { … } /* Based on bandwidth passed, allow/disallow MCS 32 in the rateset */ void brcms_c_rateset_bw_mcs_filter(struct brcms_c_rateset *rateset, u8 bw) { … }