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