Merge remote-tracking branch 'staging/staging-next'
[deliverable/linux.git] / drivers / staging / rtl8188eu / include / rtw_recv.h
1 /******************************************************************************
2 *
3 * Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved.
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 ******************************************************************************/
15 #ifndef _RTW_RECV_H_
16 #define _RTW_RECV_H_
17
18 #include <osdep_service.h>
19 #include <drv_types.h>
20
21
22 #define NR_RECVFRAME 256
23
24 #define RXFRAME_ALIGN 8
25 #define RXFRAME_ALIGN_SZ (1<<RXFRAME_ALIGN)
26
27 #define MAX_RXFRAME_CNT 512
28 #define MAX_RX_NUMBLKS (32)
29 #define RECVFRAME_HDR_ALIGN 128
30
31 #define SNAP_SIZE sizeof(struct ieee80211_snap_hdr)
32
33 #define MAX_SUBFRAME_COUNT 64
34
35 /* for Rx reordering buffer control */
36 struct recv_reorder_ctrl {
37 struct adapter *padapter;
38 u8 enable;
39 u16 indicate_seq;/* wstart_b, init_value=0xffff */
40 u16 wend_b;
41 u8 wsize_b;
42 struct __queue pending_recvframe_queue;
43 struct timer_list reordering_ctrl_timer;
44 };
45
46 struct stainfo_rxcache {
47 u16 tid_rxseq[16];
48 /*
49 unsigned short tid0_rxseq;
50 unsigned short tid1_rxseq;
51 unsigned short tid2_rxseq;
52 unsigned short tid3_rxseq;
53 unsigned short tid4_rxseq;
54 unsigned short tid5_rxseq;
55 unsigned short tid6_rxseq;
56 unsigned short tid7_rxseq;
57 unsigned short tid8_rxseq;
58 unsigned short tid9_rxseq;
59 unsigned short tid10_rxseq;
60 unsigned short tid11_rxseq;
61 unsigned short tid12_rxseq;
62 unsigned short tid13_rxseq;
63 unsigned short tid14_rxseq;
64 unsigned short tid15_rxseq;
65 */
66 };
67
68 struct signal_stat {
69 u8 update_req; /* used to indicate */
70 u8 avg_val; /* avg of valid elements */
71 u32 total_num; /* num of valid elements */
72 u32 total_val; /* sum of valid elements */
73 };
74 #define MAX_PATH_NUM_92CS 3
75 struct phy_info {
76 u8 RxPWDBAll;
77 u8 SignalQuality; /* in 0-100 index. */
78 u8 RxMIMOSignalQuality[MAX_PATH_NUM_92CS]; /* EVM */
79 u8 RxMIMOSignalStrength[MAX_PATH_NUM_92CS];/* in 0~100 index */
80 s8 RxPower; /* in dBm Translate from PWdB */
81 /* Real power in dBm for this packet, no beautification and aggregation.
82 * Keep this raw info to be used for the other procedures. */
83 s8 recvpower;
84 u8 BTRxRSSIPercentage;
85 u8 SignalStrength; /* in 0-100 index. */
86 u8 RxPwr[MAX_PATH_NUM_92CS];/* per-path's pwdb */
87 u8 RxSNR[MAX_PATH_NUM_92CS];/* per-path's SNR */
88 };
89
90 struct rx_pkt_attrib {
91 u16 pkt_len;
92 u8 physt;
93 u8 drvinfo_sz;
94 u8 shift_sz;
95 u8 hdrlen; /* the WLAN Header Len */
96 u8 to_fr_ds;
97 u8 amsdu;
98 u8 qos;
99 u8 priority;
100 u8 pw_save;
101 u8 mdata;
102 u16 seq_num;
103 u8 frag_num;
104 u8 mfrag;
105 u8 order;
106 u8 privacy; /* in frame_ctrl field */
107 u8 bdecrypted;
108 u8 encrypt; /* when 0 indicate no encrypt. when non-zero,
109 * indicate the encrypt algorith */
110 u8 iv_len;
111 u8 icv_len;
112 u8 crc_err;
113 u8 icv_err;
114
115 u16 eth_type;
116
117 u8 dst[ETH_ALEN];
118 u8 src[ETH_ALEN];
119 u8 ta[ETH_ALEN];
120 u8 ra[ETH_ALEN];
121 u8 bssid[ETH_ALEN];
122
123 u8 ack_policy;
124
125 u8 key_index;
126
127 u8 mcs_rate;
128 u8 rxht;
129 u8 sgi;
130 u8 pkt_rpt_type;
131 u32 MacIDValidEntry[2]; /* 64 bits present 64 entry. */
132
133 struct phy_info phy_info;
134 };
135
136
137 /* These definition is used for Rx packet reordering. */
138 #define SN_LESS(a, b) (((a - b) & 0x800) != 0)
139 #define SN_EQUAL(a, b) (a == b)
140 #define REORDER_WAIT_TIME (50) /* (ms) */
141
142 #define RECVBUFF_ALIGN_SZ 8
143
144 #define RXDESC_SIZE 24
145 #define RXDESC_OFFSET RXDESC_SIZE
146
147 struct recv_stat {
148 __le32 rxdw0;
149 __le32 rxdw1;
150 __le32 rxdw2;
151 __le32 rxdw3;
152 __le32 rxdw4;
153 __le32 rxdw5;
154 };
155
156 #define EOR BIT(30)
157
158 /*
159 accesser of recv_priv: rtw_recv_entry(dispatch / passive level);
160 recv_thread(passive) ; returnpkt(dispatch)
161 ; halt(passive) ;
162
163 using enter_critical section to protect
164 */
165 struct recv_priv {
166 struct __queue free_recv_queue;
167 struct __queue recv_pending_queue;
168 struct __queue uc_swdec_pending_queue;
169 u8 *pallocated_frame_buf;
170 u8 *precv_frame_buf;
171 uint free_recvframe_cnt;
172 struct adapter *adapter;
173 u32 bIsAnyNonBEPkts;
174 u64 rx_bytes;
175 u64 rx_pkts;
176 u64 rx_drop;
177 u64 last_rx_bytes;
178
179 uint ff_hwaddr;
180 u8 rx_pending_cnt;
181
182 struct tasklet_struct irq_prepare_beacon_tasklet;
183 struct tasklet_struct recv_tasklet;
184 struct sk_buff_head free_recv_skb_queue;
185 struct sk_buff_head rx_skb_queue;
186 u8 *pallocated_recv_buf;
187 u8 *precv_buf; /* 4 alignment */
188 struct __queue free_recv_buf_queue;
189 u32 free_recv_buf_queue_cnt;
190 /* For display the phy informatiom */
191 u8 is_signal_dbg; /* for debug */
192 u8 signal_strength_dbg; /* for debug */
193 s8 rssi;
194 s8 rxpwdb;
195 u8 signal_strength;
196 u8 signal_qual;
197 u8 noise;
198 s8 RxRssi[2];
199
200 struct timer_list signal_stat_timer;
201 u32 signal_stat_sampling_interval;
202 struct signal_stat signal_qual_data;
203 struct signal_stat signal_strength_data;
204 };
205
206 #define rtw_set_signal_stat_timer(recvpriv) \
207 mod_timer(&(recvpriv)->signal_stat_timer, jiffies + \
208 msecs_to_jiffies((recvpriv)->signal_stat_sampling_interval))
209
210 struct sta_recv_priv {
211 spinlock_t lock;
212 int option;
213 struct __queue defrag_q; /* keeping the fragment frame until defrag */
214 struct stainfo_rxcache rxcache;
215 };
216
217 struct recv_buf {
218 struct adapter *adapter;
219 struct urb *purb;
220 struct sk_buff *pskb;
221 u8 reuse;
222 };
223
224 /*
225 head ----->
226
227 data ----->
228
229 payload
230
231 tail ----->
232
233
234 end ----->
235
236 len = (unsigned int )(tail - data);
237
238 */
239 struct recv_frame {
240 struct list_head list;
241 struct sk_buff *pkt;
242 struct sk_buff *pkt_newalloc;
243 struct adapter *adapter;
244 struct rx_pkt_attrib attrib;
245 uint len;
246 u8 *rx_head;
247 u8 *rx_data;
248 u8 *rx_tail;
249 u8 *rx_end;
250 struct sta_info *psta;
251 /* for A-MPDU Rx reordering buffer control */
252 struct recv_reorder_ctrl *preorder_ctrl;
253 };
254
255 struct recv_frame *_rtw_alloc_recvframe(struct __queue *pfree_recv_queue);
256 struct recv_frame *rtw_alloc_recvframe(struct __queue *pfree_recv_queue);
257 void rtw_init_recvframe(struct recv_frame *precvframe,
258 struct recv_priv *precvpriv);
259 int rtw_free_recvframe(struct recv_frame *precvframe,
260 struct __queue *pfree_recv_queue);
261 #define rtw_dequeue_recvframe(queue) rtw_alloc_recvframe(queue)
262 int _rtw_enqueue_recvframe(struct recv_frame *precvframe,
263 struct __queue *queue);
264 int rtw_enqueue_recvframe(struct recv_frame *precvframe, struct __queue *queue);
265 void rtw_free_recvframe_queue(struct __queue *pframequeue,
266 struct __queue *pfree_recv_queue);
267 u32 rtw_free_uc_swdec_pending_queue(struct adapter *adapter);
268
269 void rtw_reordering_ctrl_timeout_handler(unsigned long data);
270
271 static inline u8 *get_rxmem(struct recv_frame *precvframe)
272 {
273 /* always return rx_head... */
274 if (precvframe == NULL)
275 return NULL;
276 return precvframe->rx_head;
277 }
278
279 static inline u8 *recvframe_pull(struct recv_frame *precvframe, int sz)
280 {
281 /* rx_data += sz; move rx_data sz bytes hereafter */
282
283 /* used for extract sz bytes from rx_data, update rx_data and return
284 * the updated rx_data to the caller */
285
286 if (precvframe == NULL)
287 return NULL;
288 precvframe->rx_data += sz;
289 if (precvframe->rx_data > precvframe->rx_tail) {
290 precvframe->rx_data -= sz;
291 return NULL;
292 }
293 precvframe->len -= sz;
294 return precvframe->rx_data;
295 }
296
297 static inline u8 *recvframe_put(struct recv_frame *precvframe, int sz)
298 {
299 /* used for append sz bytes from ptr to rx_tail, update rx_tail
300 * and return the updated rx_tail to the caller */
301 /* after putting, rx_tail must be still larger than rx_end. */
302
303 if (precvframe == NULL)
304 return NULL;
305
306 precvframe->rx_tail += sz;
307
308 if (precvframe->rx_tail > precvframe->rx_end) {
309 precvframe->rx_tail -= sz;
310 return NULL;
311 }
312 precvframe->len += sz;
313 return precvframe->rx_tail;
314 }
315
316 static inline u8 *recvframe_pull_tail(struct recv_frame *precvframe, int sz)
317 {
318 /* rmv data from rx_tail (by yitsen) */
319
320 /* used for extract sz bytes from rx_end, update rx_end and return
321 * the updated rx_end to the caller */
322 /* after pulling, rx_end must be still larger than rx_data. */
323
324 if (precvframe == NULL)
325 return NULL;
326 precvframe->rx_tail -= sz;
327 if (precvframe->rx_tail < precvframe->rx_data) {
328 precvframe->rx_tail += sz;
329 return NULL;
330 }
331 precvframe->len -= sz;
332 return precvframe->rx_tail;
333 }
334
335 static inline s32 translate_percentage_to_dbm(u32 sig_stren_index)
336 {
337 s32 power; /* in dBm. */
338
339 /* Translate to dBm (x=0.5y-95). */
340 power = (s32)((sig_stren_index + 1) >> 1);
341 power -= 95;
342
343 return power;
344 }
345
346
347 struct sta_info;
348
349 void _rtw_init_sta_recv_priv(struct sta_recv_priv *psta_recvpriv);
350
351 void mgt_dispatcher(struct adapter *padapter, struct recv_frame *precv_frame);
352
353 #endif
This page took 0.038884 seconds and 5 git commands to generate.