1db86f07eSLuis R. Rodriguez /* 25b68138eSSujith Manoharan * Copyright (c) 2009-2011 Atheros Communications Inc. 3db86f07eSLuis R. Rodriguez * 4db86f07eSLuis R. Rodriguez * Permission to use, copy, modify, and/or distribute this software for any 5db86f07eSLuis R. Rodriguez * purpose with or without fee is hereby granted, provided that the above 6db86f07eSLuis R. Rodriguez * copyright notice and this permission notice appear in all copies. 7db86f07eSLuis R. Rodriguez * 8db86f07eSLuis R. Rodriguez * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 9db86f07eSLuis R. Rodriguez * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 10db86f07eSLuis R. Rodriguez * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 11db86f07eSLuis R. Rodriguez * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 12db86f07eSLuis R. Rodriguez * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 13db86f07eSLuis R. Rodriguez * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14db86f07eSLuis R. Rodriguez * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15db86f07eSLuis R. Rodriguez */ 16db86f07eSLuis R. Rodriguez 17db86f07eSLuis R. Rodriguez #include <net/mac80211.h> 18db86f07eSLuis R. Rodriguez 19db86f07eSLuis R. Rodriguez #include "../ath.h" 20db86f07eSLuis R. Rodriguez 21db86f07eSLuis R. Rodriguez #include "hw.h" 22d70357d5SLuis R. Rodriguez #include "hw-ops.h" 23db86f07eSLuis R. Rodriguez 2413f71050SOleksij Rempel #include "common-init.h" 25cbbdf2aeSOleksij Rempel #include "common-beacon.h" 26f2c3c952SOleksij Rempel #include "common-debug.h" 2767dc74f1SOleksij Rempel #include "common-spectral.h" 2813f71050SOleksij Rempel 29db86f07eSLuis R. Rodriguez /* Common header for Atheros 802.11n base driver cores */ 30db86f07eSLuis R. Rodriguez 31db86f07eSLuis R. Rodriguez #define WME_BA_BMP_SIZE 64 32db86f07eSLuis R. Rodriguez #define WME_MAX_BA WME_BA_BMP_SIZE 33db86f07eSLuis R. Rodriguez #define ATH_TID_MAX_BUFS (2 * WME_MAX_BA) 34db86f07eSLuis R. Rodriguez 35a3d63cadSFelix Fietkau #define ATH_RSSI_DUMMY_MARKER 127 36db86f07eSLuis R. Rodriguez #define ATH_RSSI_LPF_LEN 10 37db86f07eSLuis R. Rodriguez #define RSSI_LPF_THRESHOLD -20 38db86f07eSLuis R. Rodriguez #define ATH_RSSI_EP_MULTIPLIER (1<<7) 39db86f07eSLuis R. Rodriguez #define ATH_EP_MUL(x, mul) ((x) * (mul)) 40db86f07eSLuis R. Rodriguez #define ATH_RSSI_IN(x) (ATH_EP_MUL((x), ATH_RSSI_EP_MULTIPLIER)) 41db86f07eSLuis R. Rodriguez #define ATH_LPF_RSSI(x, y, len) \ 42db86f07eSLuis R. Rodriguez ((x != ATH_RSSI_DUMMY_MARKER) ? (((x) * ((len) - 1) + (y)) / (len)) : (y)) 43db86f07eSLuis R. Rodriguez #define ATH_RSSI_LPF(x, y) do { \ 44db86f07eSLuis R. Rodriguez if ((y) >= RSSI_LPF_THRESHOLD) \ 45db86f07eSLuis R. Rodriguez x = ATH_LPF_RSSI((x), ATH_RSSI_IN((y)), ATH_RSSI_LPF_LEN); \ 46db86f07eSLuis R. Rodriguez } while (0) 47db86f07eSLuis R. Rodriguez #define ATH_EP_RND(x, mul) \ 484ba910dbSBob Copeland (((x) + ((mul)/2)) / (mul)) 49db86f07eSLuis R. Rodriguez 50c7303263SOleksij Rempel #define IEEE80211_MS_TO_TU(x) (((x) * 1000) / 1024) 51c7303263SOleksij Rempel 52fd0ab793SOleksij Rempel struct ath_beacon_config { 53*cfda2d8eSBenjamin Berg struct ieee80211_vif *main_vif; 54fd0ab793SOleksij Rempel int beacon_interval; 55fd0ab793SOleksij Rempel u16 dtim_period; 56fd0ab793SOleksij Rempel u16 bmiss_timeout; 57fd0ab793SOleksij Rempel u8 dtim_count; 581cf48f22SFelix Fietkau u8 enable_beacon; 59fd0ab793SOleksij Rempel bool ibss_creator; 60a2030b9dSOleksij Rempel u32 nexttbtt; 61a2030b9dSOleksij Rempel u32 intval; 62fd0ab793SOleksij Rempel }; 63fd0ab793SOleksij Rempel 646438696eSOleksij Rempel bool ath9k_cmn_rx_accept(struct ath_common *common, 656438696eSOleksij Rempel struct ieee80211_hdr *hdr, 666438696eSOleksij Rempel struct ieee80211_rx_status *rxs, 676438696eSOleksij Rempel struct ath_rx_status *rx_stats, 686438696eSOleksij Rempel bool *decrypt_error, 696438696eSOleksij Rempel unsigned int rxfilter); 705a078fcbSOleksij Rempel void ath9k_cmn_rx_skb_postprocess(struct ath_common *common, 715a078fcbSOleksij Rempel struct sk_buff *skb, 725a078fcbSOleksij Rempel struct ath_rx_status *rx_stats, 735a078fcbSOleksij Rempel struct ieee80211_rx_status *rxs, 745a078fcbSOleksij Rempel bool decrypt_error); 7512746036SOleksij Rempel int ath9k_cmn_process_rate(struct ath_common *common, 7612746036SOleksij Rempel struct ieee80211_hw *hw, 7712746036SOleksij Rempel struct ath_rx_status *rx_stats, 7812746036SOleksij Rempel struct ieee80211_rx_status *rxs); 7932efb0ccSOleksij Rempel void ath9k_cmn_process_rssi(struct ath_common *common, 8032efb0ccSOleksij Rempel struct ieee80211_hw *hw, 8132efb0ccSOleksij Rempel struct ath_rx_status *rx_stats, 8232efb0ccSOleksij Rempel struct ieee80211_rx_status *rxs); 83fb9987d0SSujith int ath9k_cmn_get_hw_crypto_keytype(struct sk_buff *skb); 842297f1c7SFelix Fietkau struct ath9k_channel *ath9k_cmn_get_channel(struct ieee80211_hw *hw, 852297f1c7SFelix Fietkau struct ath_hw *ah, 860671894fSSimon Wunderlich struct cfg80211_chan_def *chandef); 8761389f3eSSujith int ath9k_cmn_count_streams(unsigned int chainmask, int max); 88d99eeb87SVivek Natarajan void ath9k_cmn_btcoex_bt_stomp(struct ath_common *common, 89d99eeb87SVivek Natarajan enum ath_stomp_type stomp_type); 905048e8c3SRajkumar Manoharan void ath9k_cmn_update_txpow(struct ath_hw *ah, u16 cur_txpow, 915048e8c3SRajkumar Manoharan u16 new_txpow, u16 *txpower); 92f82b4bdeSRajkumar Manoharan void ath9k_cmn_init_crypto(struct ath_hw *ah); 93