18c2ecf20Sopenharmony_ci/* 28c2ecf20Sopenharmony_ci * Copyright (c) 2009-2011 Atheros Communications Inc. 38c2ecf20Sopenharmony_ci * 48c2ecf20Sopenharmony_ci * Permission to use, copy, modify, and/or distribute this software for any 58c2ecf20Sopenharmony_ci * purpose with or without fee is hereby granted, provided that the above 68c2ecf20Sopenharmony_ci * copyright notice and this permission notice appear in all copies. 78c2ecf20Sopenharmony_ci * 88c2ecf20Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 98c2ecf20Sopenharmony_ci * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 108c2ecf20Sopenharmony_ci * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 118c2ecf20Sopenharmony_ci * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 128c2ecf20Sopenharmony_ci * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 138c2ecf20Sopenharmony_ci * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 148c2ecf20Sopenharmony_ci * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 158c2ecf20Sopenharmony_ci */ 168c2ecf20Sopenharmony_ci 178c2ecf20Sopenharmony_ci#include <net/mac80211.h> 188c2ecf20Sopenharmony_ci 198c2ecf20Sopenharmony_ci#include "../ath.h" 208c2ecf20Sopenharmony_ci 218c2ecf20Sopenharmony_ci#include "hw.h" 228c2ecf20Sopenharmony_ci#include "hw-ops.h" 238c2ecf20Sopenharmony_ci 248c2ecf20Sopenharmony_ci#include "common-init.h" 258c2ecf20Sopenharmony_ci#include "common-beacon.h" 268c2ecf20Sopenharmony_ci#include "common-debug.h" 278c2ecf20Sopenharmony_ci#include "common-spectral.h" 288c2ecf20Sopenharmony_ci 298c2ecf20Sopenharmony_ci/* Common header for Atheros 802.11n base driver cores */ 308c2ecf20Sopenharmony_ci 318c2ecf20Sopenharmony_ci#define WME_BA_BMP_SIZE 64 328c2ecf20Sopenharmony_ci#define WME_MAX_BA WME_BA_BMP_SIZE 338c2ecf20Sopenharmony_ci#define ATH_TID_MAX_BUFS (2 * WME_MAX_BA) 348c2ecf20Sopenharmony_ci 358c2ecf20Sopenharmony_ci#define ATH_RSSI_DUMMY_MARKER 127 368c2ecf20Sopenharmony_ci#define ATH_RSSI_LPF_LEN 10 378c2ecf20Sopenharmony_ci#define RSSI_LPF_THRESHOLD -20 388c2ecf20Sopenharmony_ci#define ATH_RSSI_EP_MULTIPLIER (1<<7) 398c2ecf20Sopenharmony_ci#define ATH_EP_MUL(x, mul) ((x) * (mul)) 408c2ecf20Sopenharmony_ci#define ATH_RSSI_IN(x) (ATH_EP_MUL((x), ATH_RSSI_EP_MULTIPLIER)) 418c2ecf20Sopenharmony_ci#define ATH_LPF_RSSI(x, y, len) \ 428c2ecf20Sopenharmony_ci ((x != ATH_RSSI_DUMMY_MARKER) ? (((x) * ((len) - 1) + (y)) / (len)) : (y)) 438c2ecf20Sopenharmony_ci#define ATH_RSSI_LPF(x, y) do { \ 448c2ecf20Sopenharmony_ci if ((y) >= RSSI_LPF_THRESHOLD) \ 458c2ecf20Sopenharmony_ci x = ATH_LPF_RSSI((x), ATH_RSSI_IN((y)), ATH_RSSI_LPF_LEN); \ 468c2ecf20Sopenharmony_ci} while (0) 478c2ecf20Sopenharmony_ci#define ATH_EP_RND(x, mul) \ 488c2ecf20Sopenharmony_ci (((x) + ((mul)/2)) / (mul)) 498c2ecf20Sopenharmony_ci 508c2ecf20Sopenharmony_ci#define IEEE80211_MS_TO_TU(x) (((x) * 1000) / 1024) 518c2ecf20Sopenharmony_ci 528c2ecf20Sopenharmony_cistruct ath_beacon_config { 538c2ecf20Sopenharmony_ci struct ieee80211_vif *main_vif; 548c2ecf20Sopenharmony_ci int beacon_interval; 558c2ecf20Sopenharmony_ci u16 dtim_period; 568c2ecf20Sopenharmony_ci u16 bmiss_timeout; 578c2ecf20Sopenharmony_ci u8 dtim_count; 588c2ecf20Sopenharmony_ci u8 enable_beacon; 598c2ecf20Sopenharmony_ci bool ibss_creator; 608c2ecf20Sopenharmony_ci u32 nexttbtt; 618c2ecf20Sopenharmony_ci u32 intval; 628c2ecf20Sopenharmony_ci}; 638c2ecf20Sopenharmony_ci 648c2ecf20Sopenharmony_cibool ath9k_cmn_rx_accept(struct ath_common *common, 658c2ecf20Sopenharmony_ci struct ieee80211_hdr *hdr, 668c2ecf20Sopenharmony_ci struct ieee80211_rx_status *rxs, 678c2ecf20Sopenharmony_ci struct ath_rx_status *rx_stats, 688c2ecf20Sopenharmony_ci bool *decrypt_error, 698c2ecf20Sopenharmony_ci unsigned int rxfilter); 708c2ecf20Sopenharmony_civoid ath9k_cmn_rx_skb_postprocess(struct ath_common *common, 718c2ecf20Sopenharmony_ci struct sk_buff *skb, 728c2ecf20Sopenharmony_ci struct ath_rx_status *rx_stats, 738c2ecf20Sopenharmony_ci struct ieee80211_rx_status *rxs, 748c2ecf20Sopenharmony_ci bool decrypt_error); 758c2ecf20Sopenharmony_ciint ath9k_cmn_process_rate(struct ath_common *common, 768c2ecf20Sopenharmony_ci struct ieee80211_hw *hw, 778c2ecf20Sopenharmony_ci struct ath_rx_status *rx_stats, 788c2ecf20Sopenharmony_ci struct ieee80211_rx_status *rxs); 798c2ecf20Sopenharmony_civoid ath9k_cmn_process_rssi(struct ath_common *common, 808c2ecf20Sopenharmony_ci struct ieee80211_hw *hw, 818c2ecf20Sopenharmony_ci struct ath_rx_status *rx_stats, 828c2ecf20Sopenharmony_ci struct ieee80211_rx_status *rxs); 838c2ecf20Sopenharmony_ciint ath9k_cmn_get_hw_crypto_keytype(struct sk_buff *skb); 848c2ecf20Sopenharmony_cistruct ath9k_channel *ath9k_cmn_get_channel(struct ieee80211_hw *hw, 858c2ecf20Sopenharmony_ci struct ath_hw *ah, 868c2ecf20Sopenharmony_ci struct cfg80211_chan_def *chandef); 878c2ecf20Sopenharmony_ciint ath9k_cmn_count_streams(unsigned int chainmask, int max); 888c2ecf20Sopenharmony_civoid ath9k_cmn_btcoex_bt_stomp(struct ath_common *common, 898c2ecf20Sopenharmony_ci enum ath_stomp_type stomp_type); 908c2ecf20Sopenharmony_civoid ath9k_cmn_update_txpow(struct ath_hw *ah, u16 cur_txpow, 918c2ecf20Sopenharmony_ci u16 new_txpow, u16 *txpower); 928c2ecf20Sopenharmony_civoid ath9k_cmn_init_crypto(struct ath_hw *ah); 93