Merge remote-tracking branches 'regulator/topic/88pm800', 'regulator/topic/ab8500...
[cascardo/linux.git] / drivers / staging / rtl8192ee / base.h
1 /******************************************************************************
2  *
3  * Copyright(c) 2009-2010  Realtek Corporation.
4  *
5  * This program is free software; you can redistribute it and/or modify it
6  * under the terms of version 2 of the GNU General Public License as
7  * published by the Free Software Foundation.
8  *
9  * This program is distributed in the hope that it will be useful, but WITHOUT
10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
12  * more details.
13  *
14  * The full GNU General Public License is included in this distribution in the
15  * file called LICENSE.
16  *
17  * Contact Information:
18  * wlanfae <wlanfae@realtek.com>
19  * Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
20  * Hsinchu 300, Taiwan.
21  *
22  * Larry Finger <Larry.Finger@lwfinger.net>
23  *
24  *****************************************************************************/
25
26 #ifndef __RTL_BASE_H__
27 #define __RTL_BASE_H__
28
29 #include "compat.h"
30
31 enum ap_peer {
32         PEER_UNKNOWN = 0,
33         PEER_RTL = 1,
34         PEER_RTL_92SE = 2,
35         PEER_BROAD = 3,
36         PEER_RAL = 4,
37         PEER_ATH = 5,
38         PEER_CISCO = 6,
39         PEER_MARV = 7,
40         PEER_AIRGO = 9,
41         PEER_MAX = 10,
42 };
43
44 #define RTL_DUMMY_OFFSET        0
45 #define RTL_DUMMY_UNIT          8
46 #define RTL_TX_DUMMY_SIZE       (RTL_DUMMY_OFFSET * RTL_DUMMY_UNIT)
47 #define RTL_TX_DESC_SIZE        32
48 #define RTL_TX_HEADER_SIZE      (RTL_TX_DESC_SIZE + RTL_TX_DUMMY_SIZE)
49
50 #define HT_AMSDU_SIZE_4K        3839
51 #define HT_AMSDU_SIZE_8K        7935
52
53 #define MAX_BIT_RATE_40MHZ_MCS15        300     /* Mbps */
54 #define MAX_BIT_RATE_40MHZ_MCS7         150     /* Mbps */
55
56 #define MAX_BIT_RATE_SHORT_GI_2NSS_80MHZ_MCS9   867     /* Mbps */
57 #define MAX_BIT_RATE_SHORT_GI_2NSS_80MHZ_MCS7   650     /* Mbps */
58 #define MAX_BIT_RATE_LONG_GI_2NSS_80MHZ_MCS9    780     /* Mbps */
59 #define MAX_BIT_RATE_LONG_GI_2NSS_80MHZ_MCS7    585     /* Mbps */
60
61 #define MAX_BIT_RATE_SHORT_GI_1NSS_80MHZ_MCS9   434     /* Mbps */
62 #define MAX_BIT_RATE_SHORT_GI_1NSS_80MHZ_MCS7   325     /* Mbps */
63 #define MAX_BIT_RATE_LONG_GI_1NSS_80MHZ_MCS9    390     /* Mbps */
64 #define MAX_BIT_RATE_LONG_GI_1NSS_80MHZ_MCS7    293     /* Mbps */
65
66
67 #define RTL_RATE_COUNT_LEGACY           12
68 #define RTL_CHANNEL_COUNT               14
69
70 #define FRAME_OFFSET_FRAME_CONTROL      0
71 #define FRAME_OFFSET_DURATION           2
72 #define FRAME_OFFSET_ADDRESS1           4
73 #define FRAME_OFFSET_ADDRESS2           10
74 #define FRAME_OFFSET_ADDRESS3           16
75 #define FRAME_OFFSET_SEQUENCE           22
76 #define FRAME_OFFSET_ADDRESS4           24
77
78 #define SET_80211_HDR_FRAME_CONTROL(_hdr, _val)         \
79         WRITEEF2BYTE(_hdr, _val)
80 #define SET_80211_HDR_TYPE_AND_SUBTYPE(_hdr, _val)      \
81         WRITEEF1BYTE(_hdr, _val)
82 #define SET_80211_HDR_PWR_MGNT(_hdr, _val)              \
83         SET_BITS_TO_LE_2BYTE(_hdr, 12, 1, _val)
84 #define SET_80211_HDR_TO_DS(_hdr, _val)                 \
85         SET_BITS_TO_LE_2BYTE(_hdr, 8, 1, _val)
86
87 #define SET_80211_PS_POLL_AID(_hdr, _val)               \
88         (*(u16 *)((u8 *)(_hdr) + 2) = _val)
89 #define SET_80211_PS_POLL_BSSID(_hdr, _val)             \
90         memcpy(((u8 *)(_hdr)) + 4, (u8 *)(_val), ETH_ALEN)
91 #define SET_80211_PS_POLL_TA(_hdr, _val)                \
92         memcpy(((u8 *)(_hdr)) + 10, (u8 *)(_val), ETH_ALEN)
93
94 #define SET_80211_HDR_DURATION(_hdr, _val)      \
95         WRITEEF2BYTE((u8 *)(_hdr)+FRAME_OFFSET_DURATION, _val)
96 #define SET_80211_HDR_ADDRESS1(_hdr, _val)      \
97         CP_MACADDR((u8 *)(_hdr)+FRAME_OFFSET_ADDRESS1, (u8 *)(_val))
98 #define SET_80211_HDR_ADDRESS2(_hdr, _val)      \
99         CP_MACADDR((u8 *)(_hdr)+FRAME_OFFSET_ADDRESS2, (u8 *)(_val))
100 #define SET_80211_HDR_ADDRESS3(_hdr, _val)      \
101         CP_MACADDR((u8 *)(_hdr)+FRAME_OFFSET_ADDRESS3, (u8 *)(_val))
102 #define SET_80211_HDR_FRAGMENT_SEQUENCE(_hdr, _val)  \
103         WRITEEF2BYTE((u8 *)(_hdr)+FRAME_OFFSET_SEQUENCE, _val)
104
105 #define SET_BEACON_PROBE_RSP_TIME_STAMP_LOW(__phdr, __val)      \
106         WRITEEF4BYTE(((u8 *)(__phdr)) + 24, __val)
107 #define SET_BEACON_PROBE_RSP_TIME_STAMP_HIGH(__phdr, __val) \
108         WRITEEF4BYTE(((u8 *)(__phdr)) + 28, __val)
109 #define SET_BEACON_PROBE_RSP_BEACON_INTERVAL(__phdr, __val) \
110         WRITEEF2BYTE(((u8 *)(__phdr)) + 32, __val)
111 #define GET_BEACON_PROBE_RSP_CAPABILITY_INFO(__phdr)            \
112         READEF2BYTE(((u8 *)(__phdr)) + 34)
113 #define SET_BEACON_PROBE_RSP_CAPABILITY_INFO(__phdr, __val) \
114         WRITEEF2BYTE(((u8 *)(__phdr)) + 34, __val)
115 #define MASK_BEACON_PROBE_RSP_CAPABILITY_INFO(__phdr, __val) \
116         SET_BEACON_PROBE_RSP_CAPABILITY_INFO(__phdr, \
117         (GET_BEACON_PROBE_RSP_CAPABILITY_INFO(__phdr) & (~(__val))))
118
119 int rtl92e_init_core(struct ieee80211_hw *hw);
120 void rtl92e_deinit_core(struct ieee80211_hw *hw);
121 void rtl92e_init_rx_config(struct ieee80211_hw *hw);
122 void rtl92e_init_rfkill(struct ieee80211_hw *hw);
123 void rtl92e_deinit_rfkill(struct ieee80211_hw *hw);
124
125 void rtl92e_watch_dog_timer_callback(unsigned long data);
126 void rtl92e_deinit_deferred_work(struct ieee80211_hw *hw);
127
128 bool rtl92e_action_proc(struct ieee80211_hw *hw, struct sk_buff *skb, u8 is_tx);
129 bool rtl92e_tx_mgmt_proc(struct ieee80211_hw *hw, struct sk_buff *skb);
130 u8 rtl92e_is_special_data(struct ieee80211_hw *hw, struct sk_buff *skb,
131                           u8 is_tx);
132 void rtl92e_beacon_statistic(struct ieee80211_hw *hw, struct sk_buff *skb);
133 void rtl92e_watch_dog_timer_callback(unsigned long data);
134 int rtl92e_tx_agg_start(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
135                         struct ieee80211_sta *sta, u16 tid, u16 *ssn);
136 int rtl92e_tx_agg_stop(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
137                        struct ieee80211_sta *sta, u16 tid);
138 int rtl92e_tx_agg_oper(struct ieee80211_hw *hw,
139                        struct ieee80211_sta *sta, u16 tid);
140 int rtl92e_rx_agg_start(struct ieee80211_hw *hw,
141                         struct ieee80211_sta *sta, u16 tid);
142 int rtl92e_rx_agg_stop(struct ieee80211_hw *hw,
143                        struct ieee80211_sta *sta, u16 tid);
144 void rtl92e_watchdog_wq_callback(void *data);
145 void rtl92e_fwevt_wq_callback(void *data);
146
147 void stg_rtl_get_tcb_desc(struct ieee80211_hw *hw,
148                           struct ieee80211_tx_info *info,
149                           struct ieee80211_sta *sta,
150                           struct sk_buff *skb, struct rtl_tcb_desc *tcb_desc);
151
152 int stg_rtl_send_smps_action(struct ieee80211_hw *hw,
153                              struct ieee80211_sta *sta,
154                              enum ieee80211_smps_mode smps);
155 u8 *rtl92e_find_ie(u8 *data, unsigned int len, u8 ie);
156 void rtl92e_recognize_peer(struct ieee80211_hw *hw, u8 *data, unsigned int len);
157 u8 rtl92e_tid_to_ac(struct ieee80211_hw *hw, u8 tid);
158 void rtl92e_easy_concurrent_retrytimer_callback(unsigned long data);
159 extern struct rtl_global_var global_var;
160 int  rtl_core_module_init(void);
161 void  rtl_core_module_exit(void);
162
163 #endif