1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20#ifndef _RTW_RECV_H_
21#define _RTW_RECV_H_
22
23#include <osdep_service.h>
24#include <drv_types.h>
25
26
27#define NR_RECVFRAME 256
28
29#define RXFRAME_ALIGN 8
30#define RXFRAME_ALIGN_SZ (1<<RXFRAME_ALIGN)
31
32#define MAX_RXFRAME_CNT 512
33#define MAX_RX_NUMBLKS (32)
34#define RECVFRAME_HDR_ALIGN 128
35
36#define SNAP_SIZE sizeof(struct ieee80211_snap_hdr)
37
38#define MAX_SUBFRAME_COUNT 64
39
40
41struct recv_reorder_ctrl {
42 struct adapter *padapter;
43 u8 enable;
44 u16 indicate_seq;
45 u16 wend_b;
46 u8 wsize_b;
47 struct __queue pending_recvframe_queue;
48 struct timer_list reordering_ctrl_timer;
49};
50
51struct stainfo_rxcache {
52 u16 tid_rxseq[16];
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71};
72
73struct smooth_rssi_data {
74 u32 elements[100];
75 u32 index;
76 u32 total_num;
77 u32 total_val;
78};
79
80struct signal_stat {
81 u8 update_req;
82 u8 avg_val;
83 u32 total_num;
84 u32 total_val;
85};
86#define MAX_PATH_NUM_92CS 3
87struct phy_info {
88 u8 RxPWDBAll;
89 u8 SignalQuality;
90 u8 RxMIMOSignalQuality[MAX_PATH_NUM_92CS];
91 u8 RxMIMOSignalStrength[MAX_PATH_NUM_92CS];
92 s8 RxPower;
93
94
95 s8 recvpower;
96 u8 BTRxRSSIPercentage;
97 u8 SignalStrength;
98 u8 RxPwr[MAX_PATH_NUM_92CS];
99 u8 RxSNR[MAX_PATH_NUM_92CS];
100};
101
102struct rx_pkt_attrib {
103 u16 pkt_len;
104 u8 physt;
105 u8 drvinfo_sz;
106 u8 shift_sz;
107 u8 hdrlen;
108 u8 to_fr_ds;
109 u8 amsdu;
110 u8 qos;
111 u8 priority;
112 u8 pw_save;
113 u8 mdata;
114 u16 seq_num;
115 u8 frag_num;
116 u8 mfrag;
117 u8 order;
118 u8 privacy;
119 u8 bdecrypted;
120 u8 encrypt;
121
122 u8 iv_len;
123 u8 icv_len;
124 u8 crc_err;
125 u8 icv_err;
126
127 u16 eth_type;
128
129 u8 dst[ETH_ALEN];
130 u8 src[ETH_ALEN];
131 u8 ta[ETH_ALEN];
132 u8 ra[ETH_ALEN];
133 u8 bssid[ETH_ALEN];
134
135 u8 ack_policy;
136
137 u8 key_index;
138
139 u8 mcs_rate;
140 u8 rxht;
141 u8 sgi;
142 u8 pkt_rpt_type;
143 u32 MacIDValidEntry[2];
144
145 struct phy_info phy_info;
146};
147
148
149
150#define SN_LESS(a, b) (((a - b) & 0x800) != 0)
151#define SN_EQUAL(a, b) (a == b)
152#define REORDER_WAIT_TIME (50)
153
154#define RECVBUFF_ALIGN_SZ 8
155
156#define RXDESC_SIZE 24
157#define RXDESC_OFFSET RXDESC_SIZE
158
159struct recv_stat {
160 __le32 rxdw0;
161 __le32 rxdw1;
162 __le32 rxdw2;
163 __le32 rxdw3;
164 __le32 rxdw4;
165 __le32 rxdw5;
166};
167
168#define EOR BIT(30)
169
170
171
172
173
174
175
176
177struct recv_priv {
178 spinlock_t lock;
179 struct __queue free_recv_queue;
180 struct __queue recv_pending_queue;
181 struct __queue uc_swdec_pending_queue;
182 u8 *pallocated_frame_buf;
183 u8 *precv_frame_buf;
184 uint free_recvframe_cnt;
185 struct adapter *adapter;
186 u32 bIsAnyNonBEPkts;
187 u64 rx_bytes;
188 u64 rx_pkts;
189 u64 rx_drop;
190 u64 last_rx_bytes;
191
192 uint rx_icv_err;
193 uint rx_largepacket_crcerr;
194 uint rx_smallpacket_crcerr;
195 uint rx_middlepacket_crcerr;
196 struct semaphore allrxreturnevt;
197 uint ff_hwaddr;
198 u8 rx_pending_cnt;
199
200 struct tasklet_struct irq_prepare_beacon_tasklet;
201 struct tasklet_struct recv_tasklet;
202 struct sk_buff_head free_recv_skb_queue;
203 struct sk_buff_head rx_skb_queue;
204 u8 *pallocated_recv_buf;
205 u8 *precv_buf;
206 struct __queue free_recv_buf_queue;
207 u32 free_recv_buf_queue_cnt;
208
209 u8 is_signal_dbg;
210 u8 signal_strength_dbg;
211 s8 rssi;
212 s8 rxpwdb;
213 u8 signal_strength;
214 u8 signal_qual;
215 u8 noise;
216 int RxSNRdB[2];
217 s8 RxRssi[2];
218 int FalseAlmCnt_all;
219
220 struct timer_list signal_stat_timer;
221 u32 signal_stat_sampling_interval;
222 struct signal_stat signal_qual_data;
223 struct signal_stat signal_strength_data;
224};
225
226#define rtw_set_signal_stat_timer(recvpriv) \
227 _set_timer(&(recvpriv)->signal_stat_timer, \
228 (recvpriv)->signal_stat_sampling_interval)
229
230struct sta_recv_priv {
231 spinlock_t lock;
232 int option;
233 struct __queue defrag_q;
234 struct stainfo_rxcache rxcache;
235};
236
237struct recv_buf {
238 struct list_head list;
239 spinlock_t recvbuf_lock;
240 u32 ref_cnt;
241 struct adapter *adapter;
242 u8 *pbuf;
243 u8 *pallocated_buf;
244 u32 len;
245 u8 *phead;
246 u8 *pdata;
247 u8 *ptail;
248 u8 *pend;
249 struct urb *purb;
250 dma_addr_t dma_transfer_addr;
251 u32 alloc_sz;
252 u8 irp_pending;
253 int transfer_len;
254 struct sk_buff *pskb;
255 u8 reuse;
256};
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273struct recv_frame {
274 struct list_head list;
275 struct sk_buff *pkt;
276 struct sk_buff *pkt_newalloc;
277 struct adapter *adapter;
278 u8 fragcnt;
279 int frame_tag;
280 struct rx_pkt_attrib attrib;
281 uint len;
282 u8 *rx_head;
283 u8 *rx_data;
284 u8 *rx_tail;
285 u8 *rx_end;
286 void *precvbuf;
287 struct sta_info *psta;
288
289 struct recv_reorder_ctrl *preorder_ctrl;
290};
291
292struct recv_frame *_rtw_alloc_recvframe(struct __queue *pfree_recv_queue);
293struct recv_frame *rtw_alloc_recvframe(struct __queue *pfree_recv_queue);
294void rtw_init_recvframe(struct recv_frame *precvframe,
295 struct recv_priv *precvpriv);
296int rtw_free_recvframe(struct recv_frame *precvframe,
297 struct __queue *pfree_recv_queue);
298#define rtw_dequeue_recvframe(queue) rtw_alloc_recvframe(queue)
299int _rtw_enqueue_recvframe(struct recv_frame *precvframe,
300 struct __queue *queue);
301int rtw_enqueue_recvframe(struct recv_frame *precvframe, struct __queue *queue);
302void rtw_free_recvframe_queue(struct __queue *pframequeue,
303 struct __queue *pfree_recv_queue);
304u32 rtw_free_uc_swdec_pending_queue(struct adapter *adapter);
305int rtw_enqueue_recvbuf_to_head(struct recv_buf *buf, struct __queue *queue);
306int rtw_enqueue_recvbuf(struct recv_buf *precvbuf, struct __queue *queue);
307struct recv_buf *rtw_dequeue_recvbuf(struct __queue *queue);
308
309void rtw_reordering_ctrl_timeout_handler(void *pcontext);
310
311static inline u8 *get_rxmem(struct recv_frame *precvframe)
312{
313
314 if (precvframe == NULL)
315 return NULL;
316 return precvframe->rx_head;
317}
318
319static inline u8 *get_rx_status(struct recv_frame *precvframe)
320{
321 return get_rxmem(precvframe);
322}
323
324static inline u8 *recvframe_push(struct recv_frame *precvframe, int sz)
325{
326
327
328
329
330
331
332
333 if (precvframe == NULL)
334 return NULL;
335 precvframe->rx_data -= sz;
336 if (precvframe->rx_data < precvframe->rx_head) {
337 precvframe->rx_data += sz;
338 return NULL;
339 }
340 precvframe->len += sz;
341 return precvframe->rx_data;
342}
343
344static inline u8 *recvframe_pull(struct recv_frame *precvframe, int sz)
345{
346
347
348
349
350
351 if (precvframe == NULL)
352 return NULL;
353 precvframe->rx_data += sz;
354 if (precvframe->rx_data > precvframe->rx_tail) {
355 precvframe->rx_data -= sz;
356 return NULL;
357 }
358 precvframe->len -= sz;
359 return precvframe->rx_data;
360}
361
362static inline u8 *recvframe_put(struct recv_frame *precvframe, int sz)
363{
364
365
366
367
368 if (precvframe == NULL)
369 return NULL;
370
371 precvframe->rx_tail += sz;
372
373 if (precvframe->rx_tail > precvframe->rx_end) {
374 precvframe->rx_tail -= sz;
375 return NULL;
376 }
377 precvframe->len += sz;
378 return precvframe->rx_tail;
379}
380
381static inline u8 *recvframe_pull_tail(struct recv_frame *precvframe, int sz)
382{
383
384
385
386
387
388
389 if (precvframe == NULL)
390 return NULL;
391 precvframe->rx_tail -= sz;
392 if (precvframe->rx_tail < precvframe->rx_data) {
393 precvframe->rx_tail += sz;
394 return NULL;
395 }
396 precvframe->len -= sz;
397 return precvframe->rx_tail;
398}
399
400static inline s32 translate_percentage_to_dbm(u32 sig_stren_index)
401{
402 s32 power;
403
404
405 power = (s32)((sig_stren_index + 1) >> 1);
406 power -= 95;
407
408 return power;
409}
410
411
412struct sta_info;
413
414void _rtw_init_sta_recv_priv(struct sta_recv_priv *psta_recvpriv);
415
416void mgt_dispatcher(struct adapter *padapter, struct recv_frame *precv_frame);
417
418#endif
419