Add qemu 2.4.0
[kvmfornfv.git] / qemu / roms / ipxe / src / drivers / net / ath / ath9k / common.h
1 /*
2  * Copyright (c) 2009-2011 Atheros Communications Inc.
3  *
4  * Modified for iPXE by Scott K Logan <logans@cottsay.net> July 2011
5  * Original from Linux kernel 3.0.1
6  *
7  * Permission to use, copy, modify, and/or distribute this software for any
8  * purpose with or without fee is hereby granted, provided that the above
9  * copyright notice and this permission notice appear in all copies.
10  *
11  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
12  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
13  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
14  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
15  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
16  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
17  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18  */
19
20 FILE_LICENCE ( BSD2 );
21
22 #include "../ath.h"
23
24 #include "hw.h"
25 #include "hw-ops.h"
26
27 /* Common header for Atheros 802.11n base driver cores */
28
29 #define WME_NUM_TID             16
30 #define WME_BA_BMP_SIZE         64
31 #define WME_MAX_BA              WME_BA_BMP_SIZE
32 #define ATH_TID_MAX_BUFS        (2 * WME_MAX_BA)
33
34 #define WME_AC_BE   2
35 #define WME_NUM_AC  1
36
37 #define ATH_RSSI_DUMMY_MARKER   0x127
38 #define ATH_RSSI_LPF_LEN                10
39 #define RSSI_LPF_THRESHOLD              -20
40 #define ATH_RSSI_EP_MULTIPLIER     (1<<7)
41 #define ATH_EP_MUL(x, mul)         ((x) * (mul))
42 #define ATH_RSSI_IN(x)             (ATH_EP_MUL((x), ATH_RSSI_EP_MULTIPLIER))
43 #define ATH_LPF_RSSI(x, y, len) \
44     ((x != ATH_RSSI_DUMMY_MARKER) ? (((x) * ((len) - 1) + (y)) / (len)) : (y))
45 #define ATH_RSSI_LPF(x, y) do {                                         \
46     if ((y) >= RSSI_LPF_THRESHOLD)                                      \
47         x = ATH_LPF_RSSI((x), ATH_RSSI_IN((y)), ATH_RSSI_LPF_LEN);      \
48 } while (0)
49 #define ATH_EP_RND(x, mul)                                              \
50         ((((x)%(mul)) >= ((mul)/2)) ? ((x) + ((mul) - 1)) / (mul) : (x)/(mul))
51
52
53 void ath9k_cmn_update_ichannel(struct ath9k_channel *ichan,
54                                struct net80211_channel *chan);
55 struct ath9k_channel *ath9k_cmn_get_curchannel(struct net80211_device *dev,
56                                                struct ath_hw *ah);
57 void ath9k_cmn_update_txpow(struct ath_hw *ah, u16 cur_txpow,
58                             u16 new_txpow, u16 *txpower);