1
2
3
4
5
6
7#ifndef _RTW_RECV_H_
8#define _RTW_RECV_H_
9
10 #ifdef CONFIG_SINGLE_RECV_BUF
11 #define NR_RECVBUFF (1)
12 #else
13 #define NR_RECVBUFF (8)
14 #endif
15
16 #define NR_PREALLOC_RECV_SKB (8)
17
18#define NR_RECVFRAME 256
19
20#define RXFRAME_ALIGN 8
21#define RXFRAME_ALIGN_SZ (1<<RXFRAME_ALIGN)
22
23#define DRVINFO_SZ 4
24
25#define MAX_RXFRAME_CNT 512
26#define MAX_RX_NUMBLKS (32)
27#define RECVFRAME_HDR_ALIGN 128
28
29
30#define PHY_RSSI_SLID_WIN_MAX 100
31#define PHY_LINKQUALITY_SLID_WIN_MAX 20
32
33
34#define SNAP_SIZE sizeof(struct ieee80211_snap_hdr)
35
36#define RX_MPDU_QUEUE 0
37#define RX_CMD_QUEUE 1
38#define RX_MAX_QUEUE 2
39
40#define MAX_SUBFRAME_COUNT 64
41
42
43struct recv_reorder_ctrl
44{
45 struct adapter *padapter;
46 u8 enable;
47 u16 indicate_seq;
48 u16 wend_b;
49 u8 wsize_b;
50 struct __queue pending_recvframe_queue;
51 _timer reordering_ctrl_timer;
52};
53
54struct stainfo_rxcache {
55 u16 tid_rxseq[16];
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74};
75
76
77struct smooth_rssi_data {
78 u32 elements[100];
79 u32 index;
80 u32 total_num;
81 u32 total_val;
82};
83
84struct signal_stat {
85 u8 update_req;
86 u8 avg_val;
87 u32 total_num;
88 u32 total_val;
89};
90
91struct phy_info {
92 u8 rx_pwd_ba11;
93
94 u8 SignalQuality;
95 s8 rx_mimo_signal_quality[4];
96 u8 RxMIMOEVMdbm[4];
97
98 u8 rx_mimo_signal_strength[4];
99
100 u16 Cfo_short[4];
101 u16 Cfo_tail[4];
102
103 s8 RxPower;
104 s8 RecvSignalPower;
105 u8 bt_rx_rssi_percentage;
106 u8 SignalStrength;
107
108 s8 RxPwr[4];
109 u8 RxSNR[4];
110 u8 BandWidth;
111 u8 btCoexPwrAdjust;
112};
113
114#ifdef DBG_RX_SIGNAL_DISPLAY_RAW_DATA
115struct rx_raw_rssi
116{
117 u8 data_rate;
118 u8 pwdball;
119 s8 pwr_all;
120
121 u8 mimo_signal_strength[4];
122 u8 mimo_signal_quality[4];
123
124 s8 ofdm_pwr[4];
125 u8 ofdm_snr[4];
126
127};
128#endif
129
130struct rx_pkt_attrib {
131 u16 pkt_len;
132 u8 physt;
133 u8 drvinfo_sz;
134 u8 shift_sz;
135 u8 hdrlen;
136 u8 to_fr_ds;
137 u8 amsdu;
138 u8 qos;
139 u8 priority;
140 u8 pw_save;
141 u8 mdata;
142 u16 seq_num;
143 u8 frag_num;
144 u8 mfrag;
145 u8 order;
146 u8 privacy;
147 u8 bdecrypted;
148 u8 encrypt;
149 u8 iv_len;
150 u8 icv_len;
151 u8 crc_err;
152 u8 icv_err;
153
154 u16 eth_type;
155
156 u8 dst[ETH_ALEN];
157 u8 src[ETH_ALEN];
158 u8 ta[ETH_ALEN];
159 u8 ra[ETH_ALEN];
160 u8 bssid[ETH_ALEN];
161
162 u8 ack_policy;
163
164
165 u8 tcpchk_valid;
166 u8 ip_chkrpt;
167 u8 tcp_chkrpt;
168
169 u8 key_index;
170
171 u8 data_rate;
172 u8 sgi;
173 u8 pkt_rpt_type;
174 u32 MacIDValidEntry[2];
175
176
177
178
179
180
181
182
183 struct phy_info phy_info;
184};
185
186
187
188#define SN_LESS(a, b) (((a - b) & 0x800) != 0)
189#define SN_EQUAL(a, b) (a == b)
190
191
192#define REORDER_WAIT_TIME (50)
193
194#define RECVBUFF_ALIGN_SZ 8
195
196#define RXDESC_SIZE 24
197#define RXDESC_OFFSET RXDESC_SIZE
198
199struct recv_stat {
200 __le32 rxdw0;
201 __le32 rxdw1;
202 __le32 rxdw2;
203 __le32 rxdw3;
204#ifndef BUF_DESC_ARCH
205 __le32 rxdw4;
206 __le32 rxdw5;
207#endif
208};
209
210#define EOR BIT(30)
211
212
213
214
215
216
217
218struct recv_priv {
219 _lock lock;
220 struct __queue free_recv_queue;
221 struct __queue recv_pending_queue;
222 struct __queue uc_swdec_pending_queue;
223 u8 *pallocated_frame_buf;
224 u8 *precv_frame_buf;
225 uint free_recvframe_cnt;
226 struct adapter *adapter;
227 u32 bIsAnyNonBEPkts;
228 u64 rx_bytes;
229 u64 rx_pkts;
230 u64 rx_drop;
231 uint rx_icv_err;
232 uint rx_largepacket_crcerr;
233 uint rx_smallpacket_crcerr;
234 uint rx_middlepacket_crcerr;
235
236 struct tasklet_struct irq_prepare_beacon_tasklet;
237 struct tasklet_struct recv_tasklet;
238 struct sk_buff_head free_recv_skb_queue;
239 struct sk_buff_head rx_skb_queue;
240#ifdef CONFIG_RX_INDICATE_QUEUE
241 struct task rx_indicate_tasklet;
242 struct ifqueue rx_indicate_queue;
243#endif
244
245 u8 *pallocated_recv_buf;
246 u8 *precv_buf;
247 struct __queue free_recv_buf_queue;
248 u32 free_recv_buf_queue_cnt;
249
250 struct __queue recv_buf_pending_queue;
251
252
253 u8 is_signal_dbg;
254 u8 signal_strength_dbg;
255
256 u8 signal_strength;
257 u8 signal_qual;
258 s8 rssi;
259 #ifdef DBG_RX_SIGNAL_DISPLAY_RAW_DATA
260 struct rx_raw_rssi raw_rssi_info;
261 #endif
262
263 s16 noise;
264
265
266
267
268
269 _timer signal_stat_timer;
270 u32 signal_stat_sampling_interval;
271
272 struct signal_stat signal_qual_data;
273 struct signal_stat signal_strength_data;
274};
275
276#define rtw_set_signal_stat_timer(recvpriv) _set_timer(&(recvpriv)->signal_stat_timer, (recvpriv)->signal_stat_sampling_interval)
277
278struct sta_recv_priv {
279
280 _lock lock;
281 sint option;
282
283
284 struct __queue defrag_q;
285
286 struct stainfo_rxcache rxcache;
287
288
289
290
291
292};
293
294
295struct recv_buf
296{
297 struct list_head list;
298
299 _lock recvbuf_lock;
300
301 u32 ref_cnt;
302
303 struct adapter *adapter;
304
305 u8 *pbuf;
306 u8 *pallocated_buf;
307
308 u32 len;
309 u8 *phead;
310 u8 *pdata;
311 u8 *ptail;
312 u8 *pend;
313
314 _pkt *pskb;
315 u8 reuse;
316};
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334struct recv_frame_hdr
335{
336 struct list_head list;
337#ifndef CONFIG_BSD_RX_USE_MBUF
338 struct sk_buff *pkt;
339 struct sk_buff *pkt_newalloc;
340#else
341 _pkt *pkt;
342 _pkt *pkt_newalloc;
343#endif
344
345 struct adapter *adapter;
346
347 u8 fragcnt;
348
349 int frame_tag;
350
351 struct rx_pkt_attrib attrib;
352
353 uint len;
354 u8 *rx_head;
355 u8 *rx_data;
356 u8 *rx_tail;
357 u8 *rx_end;
358
359 void *precvbuf;
360
361
362
363 struct sta_info *psta;
364
365
366 struct recv_reorder_ctrl *preorder_ctrl;
367};
368
369
370union recv_frame {
371 union{
372 struct list_head list;
373 struct recv_frame_hdr hdr;
374 uint mem[RECVFRAME_HDR_ALIGN>>2];
375 } u;
376
377
378
379};
380
381enum RX_PACKET_TYPE {
382 NORMAL_RX,
383 TX_REPORT1,
384 TX_REPORT2,
385 HIS_REPORT,
386 C2H_PACKET
387};
388
389extern union recv_frame *_rtw_alloc_recvframe(struct __queue *pfree_recv_queue);
390extern union recv_frame *rtw_alloc_recvframe(struct __queue *pfree_recv_queue);
391extern int rtw_free_recvframe(union recv_frame *precvframe, struct __queue *pfree_recv_queue);
392
393#define rtw_dequeue_recvframe(queue) rtw_alloc_recvframe(queue)
394extern int _rtw_enqueue_recvframe(union recv_frame *precvframe, struct __queue *queue);
395extern int rtw_enqueue_recvframe(union recv_frame *precvframe, struct __queue *queue);
396
397extern void rtw_free_recvframe_queue(struct __queue *pframequeue, struct __queue *pfree_recv_queue);
398u32 rtw_free_uc_swdec_pending_queue(struct adapter *adapter);
399
400sint rtw_enqueue_recvbuf_to_head(struct recv_buf *precvbuf, struct __queue *queue);
401sint rtw_enqueue_recvbuf(struct recv_buf *precvbuf, struct __queue *queue);
402struct recv_buf *rtw_dequeue_recvbuf(struct __queue *queue);
403
404void rtw_reordering_ctrl_timeout_handler(struct timer_list *t);
405
406static inline u8 *get_rxmem(union recv_frame *precvframe)
407{
408
409 if (precvframe == NULL)
410 return NULL;
411
412 return precvframe->u.hdr.rx_head;
413}
414
415static inline u8 *get_recvframe_data(union recv_frame *precvframe)
416{
417
418
419 if (precvframe == NULL)
420 return NULL;
421
422 return precvframe->u.hdr.rx_data;
423
424}
425
426static inline u8 *recvframe_pull(union recv_frame *precvframe, sint sz)
427{
428
429
430
431
432
433 if (precvframe == NULL)
434 return NULL;
435
436
437 precvframe->u.hdr.rx_data += sz;
438
439 if (precvframe->u.hdr.rx_data > precvframe->u.hdr.rx_tail)
440 {
441 precvframe->u.hdr.rx_data -= sz;
442 return NULL;
443 }
444
445 precvframe->u.hdr.len -= sz;
446
447 return precvframe->u.hdr.rx_data;
448
449}
450
451static inline u8 *recvframe_put(union recv_frame *precvframe, sint sz)
452{
453
454
455
456
457 unsigned char * prev_rx_tail;
458
459 if (precvframe == NULL)
460 return NULL;
461
462 prev_rx_tail = precvframe->u.hdr.rx_tail;
463
464 precvframe->u.hdr.rx_tail += sz;
465
466 if (precvframe->u.hdr.rx_tail > precvframe->u.hdr.rx_end)
467 {
468 precvframe->u.hdr.rx_tail = prev_rx_tail;
469 return NULL;
470 }
471
472 precvframe->u.hdr.len += sz;
473
474 return precvframe->u.hdr.rx_tail;
475
476}
477
478
479
480static inline u8 *recvframe_pull_tail(union recv_frame *precvframe, sint sz)
481{
482
483
484
485
486
487 if (precvframe == NULL)
488 return NULL;
489
490 precvframe->u.hdr.rx_tail -= sz;
491
492 if (precvframe->u.hdr.rx_tail < precvframe->u.hdr.rx_data)
493 {
494 precvframe->u.hdr.rx_tail += sz;
495 return NULL;
496 }
497
498 precvframe->u.hdr.len -= sz;
499
500 return precvframe->u.hdr.rx_tail;
501
502}
503
504static inline union recv_frame *rxmem_to_recvframe(u8 *rxmem)
505{
506
507
508
509
510 return (union recv_frame*)(((SIZE_PTR)rxmem >> RXFRAME_ALIGN) << RXFRAME_ALIGN);
511
512}
513
514static inline sint get_recvframe_len(union recv_frame *precvframe)
515{
516 return precvframe->u.hdr.len;
517}
518
519
520static inline s32 translate_percentage_to_dbm(u32 SignalStrengthIndex)
521{
522 s32 SignalPower;
523
524#ifdef CONFIG_SKIP_SIGNAL_SCALE_MAPPING
525
526 SignalPower = SignalStrengthIndex - 100;
527#else
528
529 SignalPower = (s32)((SignalStrengthIndex + 1) >> 1);
530 SignalPower -= 95;
531#endif
532
533 return SignalPower;
534}
535
536
537struct sta_info;
538
539extern void _rtw_init_sta_recv_priv(struct sta_recv_priv *psta_recvpriv);
540
541extern void mgt_dispatcher(struct adapter *padapter, union recv_frame *precv_frame);
542
543#endif
544