162306a36Sopenharmony_ci/* 262306a36Sopenharmony_ci * Copyright (c) 2009-2011 Atheros Communications Inc. 362306a36Sopenharmony_ci * 462306a36Sopenharmony_ci * Permission to use, copy, modify, and/or distribute this software for any 562306a36Sopenharmony_ci * purpose with or without fee is hereby granted, provided that the above 662306a36Sopenharmony_ci * copyright notice and this permission notice appear in all copies. 762306a36Sopenharmony_ci * 862306a36Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 962306a36Sopenharmony_ci * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 1062306a36Sopenharmony_ci * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 1162306a36Sopenharmony_ci * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 1262306a36Sopenharmony_ci * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 1362306a36Sopenharmony_ci * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 1462306a36Sopenharmony_ci * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 1562306a36Sopenharmony_ci */ 1662306a36Sopenharmony_ci 1762306a36Sopenharmony_ci#include <net/mac80211.h> 1862306a36Sopenharmony_ci 1962306a36Sopenharmony_ci#include "../ath.h" 2062306a36Sopenharmony_ci 2162306a36Sopenharmony_ci#include "hw.h" 2262306a36Sopenharmony_ci#include "hw-ops.h" 2362306a36Sopenharmony_ci 2462306a36Sopenharmony_ci#include "common-init.h" 2562306a36Sopenharmony_ci#include "common-beacon.h" 2662306a36Sopenharmony_ci#include "common-debug.h" 2762306a36Sopenharmony_ci#include "common-spectral.h" 2862306a36Sopenharmony_ci 2962306a36Sopenharmony_ci/* Common header for Atheros 802.11n base driver cores */ 3062306a36Sopenharmony_ci 3162306a36Sopenharmony_ci#define WME_BA_BMP_SIZE 64 3262306a36Sopenharmony_ci#define WME_MAX_BA WME_BA_BMP_SIZE 3362306a36Sopenharmony_ci#define ATH_TID_MAX_BUFS (2 * WME_MAX_BA) 3462306a36Sopenharmony_ci 3562306a36Sopenharmony_ci#define ATH_RSSI_DUMMY_MARKER 127 3662306a36Sopenharmony_ci#define ATH_RSSI_LPF_LEN 10 3762306a36Sopenharmony_ci#define RSSI_LPF_THRESHOLD -20 3862306a36Sopenharmony_ci#define ATH_RSSI_EP_MULTIPLIER (1<<7) 3962306a36Sopenharmony_ci#define ATH_EP_MUL(x, mul) ((x) * (mul)) 4062306a36Sopenharmony_ci#define ATH_RSSI_IN(x) (ATH_EP_MUL((x), ATH_RSSI_EP_MULTIPLIER)) 4162306a36Sopenharmony_ci#define ATH_LPF_RSSI(x, y, len) \ 4262306a36Sopenharmony_ci ((x != ATH_RSSI_DUMMY_MARKER) ? (((x) * ((len) - 1) + (y)) / (len)) : (y)) 4362306a36Sopenharmony_ci#define ATH_RSSI_LPF(x, y) do { \ 4462306a36Sopenharmony_ci if ((y) >= RSSI_LPF_THRESHOLD) \ 4562306a36Sopenharmony_ci x = ATH_LPF_RSSI((x), ATH_RSSI_IN((y)), ATH_RSSI_LPF_LEN); \ 4662306a36Sopenharmony_ci} while (0) 4762306a36Sopenharmony_ci#define ATH_EP_RND(x, mul) \ 4862306a36Sopenharmony_ci (((x) + ((mul)/2)) / (mul)) 4962306a36Sopenharmony_ci 5062306a36Sopenharmony_ci#define IEEE80211_MS_TO_TU(x) (((x) * 1000) / 1024) 5162306a36Sopenharmony_ci 5262306a36Sopenharmony_cistruct ath_beacon_config { 5362306a36Sopenharmony_ci struct ieee80211_vif *main_vif; 5462306a36Sopenharmony_ci int beacon_interval; 5562306a36Sopenharmony_ci u16 dtim_period; 5662306a36Sopenharmony_ci u16 bmiss_timeout; 5762306a36Sopenharmony_ci u8 dtim_count; 5862306a36Sopenharmony_ci u8 enable_beacon; 5962306a36Sopenharmony_ci bool ibss_creator; 6062306a36Sopenharmony_ci u32 nexttbtt; 6162306a36Sopenharmony_ci u32 intval; 6262306a36Sopenharmony_ci}; 6362306a36Sopenharmony_ci 6462306a36Sopenharmony_cibool ath9k_cmn_rx_accept(struct ath_common *common, 6562306a36Sopenharmony_ci struct ieee80211_hdr *hdr, 6662306a36Sopenharmony_ci struct ieee80211_rx_status *rxs, 6762306a36Sopenharmony_ci struct ath_rx_status *rx_stats, 6862306a36Sopenharmony_ci bool *decrypt_error, 6962306a36Sopenharmony_ci unsigned int rxfilter); 7062306a36Sopenharmony_civoid ath9k_cmn_rx_skb_postprocess(struct ath_common *common, 7162306a36Sopenharmony_ci struct sk_buff *skb, 7262306a36Sopenharmony_ci struct ath_rx_status *rx_stats, 7362306a36Sopenharmony_ci struct ieee80211_rx_status *rxs, 7462306a36Sopenharmony_ci bool decrypt_error); 7562306a36Sopenharmony_ciint ath9k_cmn_process_rate(struct ath_common *common, 7662306a36Sopenharmony_ci struct ieee80211_hw *hw, 7762306a36Sopenharmony_ci struct ath_rx_status *rx_stats, 7862306a36Sopenharmony_ci struct ieee80211_rx_status *rxs); 7962306a36Sopenharmony_civoid ath9k_cmn_process_rssi(struct ath_common *common, 8062306a36Sopenharmony_ci struct ieee80211_hw *hw, 8162306a36Sopenharmony_ci struct ath_rx_status *rx_stats, 8262306a36Sopenharmony_ci struct ieee80211_rx_status *rxs); 8362306a36Sopenharmony_ciint ath9k_cmn_get_hw_crypto_keytype(struct sk_buff *skb); 8462306a36Sopenharmony_cistruct ath9k_channel *ath9k_cmn_get_channel(struct ieee80211_hw *hw, 8562306a36Sopenharmony_ci struct ath_hw *ah, 8662306a36Sopenharmony_ci struct cfg80211_chan_def *chandef); 8762306a36Sopenharmony_ciint ath9k_cmn_count_streams(unsigned int chainmask, int max); 8862306a36Sopenharmony_civoid ath9k_cmn_update_txpow(struct ath_hw *ah, u16 cur_txpow, 8962306a36Sopenharmony_ci u16 new_txpow, u16 *txpower); 9062306a36Sopenharmony_civoid ath9k_cmn_init_crypto(struct ath_hw *ah); 91