1 /******************************************************************************
2 *
3 * Copyright(c) 2007 - 2017 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 *****************************************************************************/
15 #ifndef _RTW_RECV_H_
16 #define _RTW_RECV_H_
17
18 #define RTW_RX_MSDU_ACT_NONE 0
19 #define RTW_RX_MSDU_ACT_INDICATE BIT0
20 #define RTW_RX_MSDU_ACT_FORWARD BIT1
21
22 #ifdef CONFIG_SINGLE_RECV_BUF
23 #define NR_RECVBUFF (1)
24 #else
25 #if defined(CONFIG_GSPI_HCI)
26 #define NR_RECVBUFF (32)
27 #elif defined(CONFIG_SDIO_HCI)
28 #define NR_RECVBUFF (64)
29 #else
30 #define NR_RECVBUFF (64)
31 #endif
32 #endif /* CONFIG_SINGLE_RECV_BUF */
33 #ifdef CONFIG_PREALLOC_RX_SKB_BUFFER
34 #define NR_PREALLOC_RECV_SKB (rtw_rtkm_get_nr_recv_skb()>>1)
35 #else /*!CONFIG_PREALLOC_RX_SKB_BUFFER */
36 #define NR_PREALLOC_RECV_SKB 8
37 #endif /* CONFIG_PREALLOC_RX_SKB_BUFFER */
38
39 #ifdef CONFIG_RTW_NAPI
40 #define RTL_NAPI_WEIGHT (32)
41 #endif
42
43
44 #if defined(CONFIG_RTL8821C) && defined(CONFIG_SDIO_HCI) && defined(CONFIG_RECV_THREAD_MODE)
45 #ifdef NR_RECVBUFF
46 #undef NR_RECVBUFF
47 #define NR_RECVBUFF (32)
48 #endif
49 #endif
50
51 #define NR_RECVFRAME 256
52
53 #define RXFRAME_ALIGN 8
54 #define RXFRAME_ALIGN_SZ (1<<RXFRAME_ALIGN)
55
56 #define DRVINFO_SZ 4 /* unit is 8bytes */
57
58 #define MAX_RXFRAME_CNT 512
59 #define MAX_RX_NUMBLKS (32)
60 #define RECVFRAME_HDR_ALIGN 128
61 #define MAX_CONTINUAL_NORXPACKET_COUNT 4 /* In MAX_CONTINUAL_NORXPACKET_COUNT*2 sec , no rx traffict would issue DELBA*/
62
63 #define PHY_RSSI_SLID_WIN_MAX 100
64 #define PHY_LINKQUALITY_SLID_WIN_MAX 20
65
66
67 #define SNAP_SIZE sizeof(struct ieee80211_snap_hdr)
68
69 #define RX_MPDU_QUEUE 0
70 #define RX_CMD_QUEUE 1
71 #define RX_MAX_QUEUE 2
72
73 #define MAX_SUBFRAME_COUNT 64
74 /* Bridge-Tunnel header (for EtherTypes ETH_P_AARP and ETH_P_IPX) */
75 extern u8 rtw_bridge_tunnel_header[];
76 extern u8 rtw_rfc1042_header[];
77
78 enum addba_rsp_ack_state {
79 RTW_RECV_ACK_OR_TIMEOUT,
80 };
81
82 /* for Rx reordering buffer control */
83 struct recv_reorder_ctrl {
84 _adapter *padapter;
85 u8 tid;
86 u8 enable;
87 u16 indicate_seq;/* =wstart_b, init_value=0xffff */
88 u16 wend_b;
89 u8 wsize_b;
90 u8 ampdu_size;
91 _queue pending_recvframe_queue;
92 _timer reordering_ctrl_timer;
93 u8 bReorderWaiting;
94 unsigned long rec_abba_rsp_ack;
95 };
96
97 struct stainfo_rxcache {
98 u16 tid_rxseq[16];
99 u8 iv[16][8];
100 u8 last_tid;
101 #if 0
102 unsigned short tid0_rxseq;
103 unsigned short tid1_rxseq;
104 unsigned short tid2_rxseq;
105 unsigned short tid3_rxseq;
106 unsigned short tid4_rxseq;
107 unsigned short tid5_rxseq;
108 unsigned short tid6_rxseq;
109 unsigned short tid7_rxseq;
110 unsigned short tid8_rxseq;
111 unsigned short tid9_rxseq;
112 unsigned short tid10_rxseq;
113 unsigned short tid11_rxseq;
114 unsigned short tid12_rxseq;
115 unsigned short tid13_rxseq;
116 unsigned short tid14_rxseq;
117 unsigned short tid15_rxseq;
118 #endif
119 };
120
121
122 struct smooth_rssi_data {
123 u32 elements[100]; /* array to store values */
124 u32 index; /* index to current array to store */
125 u32 total_num; /* num of valid elements */
126 u32 total_val; /* sum of valid elements */
127 };
128
129 struct signal_stat {
130 u8 update_req; /* used to indicate */
131 u8 avg_val; /* avg of valid elements */
132 u32 total_num; /* num of valid elements */
133 u32 total_val; /* sum of valid elements */
134 };
135
136 struct rx_raw_rssi {
137 u8 data_rate;
138 u8 pwdball;
139 s8 pwr_all;
140
141 u8 mimo_signal_strength[4];/* in 0~100 index */
142 u8 mimo_signal_quality[4];
143
144 s8 ofdm_pwr[4];
145 u8 ofdm_snr[4];
146 };
147
148
149 #include "cmn_info/rtw_sta_info.h"
150
151 struct rx_pkt_attrib {
152 u16 pkt_len;
153 u8 physt;
154 u8 drvinfo_sz;
155 u8 shift_sz;
156 u8 hdrlen; /* the WLAN Header Len */
157 u8 to_fr_ds;
158 u8 amsdu;
159 u8 qos;
160 u8 priority;
161 u8 pw_save;
162 u8 mdata;
163 u16 seq_num;
164 u8 frag_num;
165 u8 mfrag;
166 u8 order;
167 u8 privacy; /* in frame_ctrl field */
168 u8 bdecrypted;
169 u8 encrypt; /* when 0 indicate no encrypt. when non-zero, indicate the encrypt algorith */
170 u8 iv_len;
171 u8 icv_len;
172 u8 crc_err;
173 u8 icv_err;
174
175 u8 dst[ETH_ALEN];
176 u8 src[ETH_ALEN];
177 u8 ta[ETH_ALEN];
178 u8 ra[ETH_ALEN];
179 u8 bssid[ETH_ALEN];
180 #ifdef CONFIG_RTW_MESH
181 u8 msa[ETH_ALEN]; /* mesh sa */
182 u8 mda[ETH_ALEN]; /* mesh da */
183 u8 mesh_ctrl_present;
184 u8 mesh_ctrl_len; /* length of mesh control field */
185 #endif
186
187 u8 ack_policy;
188
189 u8 key_index;
190
191 u8 data_rate;
192 u8 ch; /* RX channel */
193 u8 bw;
194 u8 stbc;
195 u8 ldpc;
196 u8 sgi;
197 u8 pkt_rpt_type;
198 u32 MacIDValidEntry[2]; /* 64 bits present 64 entry. */
199 u8 ampdu;
200 u8 ppdu_cnt;
201 u8 ampdu_eof;
202 u32 free_cnt; /* free run counter */
203 struct phydm_phyinfo_struct phy_info;
204 #ifdef CONFIG_WIFI_MONITOR
205 u8 moif[16];
206 #endif
207
208 #ifdef CONFIG_TCP_CSUM_OFFLOAD_RX
209 /* checksum offload realted varaiables */
210 u8 csum_valid; /* Checksum valid, 0: not check, 1: checked */
211 u8 csum_err; /* Checksum Error occurs */
212 #endif /* CONFIG_TCP_CSUM_OFFLOAD_RX */
213 };
214
215 #ifdef CONFIG_RTW_MESH
216 #define RATTRIB_GET_MCTRL_LEN(rattrib) ((rattrib)->mesh_ctrl_len)
217 #else
218 #define RATTRIB_GET_MCTRL_LEN(rattrib) 0
219 #endif
220
221 /* These definition is used for Rx packet reordering. */
222 #define SN_LESS(a, b) (((a-b) & 0x800) != 0)
223 #define SN_EQUAL(a, b) (a == b)
224 /* #define REORDER_WIN_SIZE 128 */
225 /* #define REORDER_ENTRY_NUM 128 */
226 #define REORDER_WAIT_TIME (50) /* (ms) */
227
228 #if defined(CONFIG_PLATFORM_RTK390X) && defined(CONFIG_USB_HCI)
229 #define RECVBUFF_ALIGN_SZ 32
230 #else
231 #define RECVBUFF_ALIGN_SZ 8
232 #endif
233
234 #ifdef CONFIG_TRX_BD_ARCH
235 #define RX_WIFI_INFO_SIZE 24
236 #elif (defined(CONFIG_RTL8192E) || defined(CONFIG_RTL8814A) || defined(CONFIG_RTL8822B)) && defined(CONFIG_PCI_HCI)
237 #define RXBD_SIZE sizeof(struct recv_stat)
238 #endif
239
240 #define RXDESC_SIZE 24
241 #define RXDESC_OFFSET RXDESC_SIZE
242
243 #ifdef CONFIG_TRX_BD_ARCH
244 struct rx_buf_desc {
245 /* RX has exactly one segment */
246 #ifdef CONFIG_64BIT_DMA
247 unsigned int dword[4];
248 #else
249 unsigned int dword[2];
250 #endif
251 };
252
253 struct recv_stat {
254 unsigned int rxdw[8];
255 };
256 #else
257 struct recv_stat {
258 unsigned int rxdw0;
259
260 unsigned int rxdw1;
261
262 #if !((defined(CONFIG_RTL8192E) || defined(CONFIG_RTL8814A) || defined(CONFIG_RTL8822B) || defined(CONFIG_RTL8821C) || defined(CONFIG_RTL8822C)) && defined(CONFIG_PCI_HCI)) /* exclude 8192ee, 8814ae, 8822be, 8821ce */
263 unsigned int rxdw2;
264
265 unsigned int rxdw3;
266 #endif
267
268 #ifndef BUF_DESC_ARCH
269 unsigned int rxdw4;
270
271 unsigned int rxdw5;
272
273 #ifdef CONFIG_PCI_HCI
274 unsigned int rxdw6;
275
276 unsigned int rxdw7;
277 #endif
278 #endif /* if BUF_DESC_ARCH is defined, rx_buf_desc occupy 4 double words */
279 };
280 #endif
281
282 #define EOR BIT(30)
283
284 #ifdef CONFIG_PCI_HCI
285 #define PCI_MAX_RX_QUEUE 1/* MSDU packet queue, Rx Command Queue */
286 #define PCI_MAX_RX_COUNT 128
287 #ifdef CONFIG_TRX_BD_ARCH
288 #define RX_BD_NUM PCI_MAX_RX_COUNT /* alias */
289 #endif
290
291 struct rtw_rx_ring {
292 #ifdef CONFIG_TRX_BD_ARCH
293 struct rx_buf_desc *buf_desc;
294 #else
295 struct recv_stat *desc;
296 #endif
297 dma_addr_t dma;
298 unsigned int idx;
299 struct sk_buff *rx_buf[PCI_MAX_RX_COUNT];
300 };
301 #endif
302
303
304
305 /*
306 accesser of recv_priv: rtw_recv_entry(dispatch / passive level); recv_thread(passive) ; returnpkt(dispatch)
307 ; halt(passive) ;
308
309 using enter_critical section to protect
310 */
311
312 #ifndef DBG_RX_BH_TRACKING
313 #define DBG_RX_BH_TRACKING 0
314 #endif
315
316 struct recv_priv {
317 _lock lock;
318
319 #ifdef CONFIG_RECV_THREAD_MODE
320 _sema recv_sema;
321
322 #endif
323
324 /* _queue blk_strms[MAX_RX_NUMBLKS]; */ /* keeping the block ack frame until return ack */
325 _queue free_recv_queue;
326 _queue recv_pending_queue;
327 _queue uc_swdec_pending_queue;
328
329
330 u8 *pallocated_frame_buf;
331 u8 *precv_frame_buf;
332
333 uint free_recvframe_cnt;
334
335 #if DBG_RX_BH_TRACKING
336 u32 rx_bh_stage;
337 u32 rx_bh_buf_dq_cnt;
338 void *rx_bh_lbuf;
339 void *rx_bh_cbuf;
340 void *rx_bh_cbuf_data;
341 u32 rx_bh_cbuf_dlen;
342 u32 rx_bh_cbuf_pos;
343 void *rx_bh_cframe;
344 #endif
345
346 _adapter *adapter;
347
348 u32 is_any_non_be_pkts;
349
350 u64 rx_bytes;
351 u64 rx_pkts;
352 u64 rx_drop;
353
354 u64 dbg_rx_drop_count;
355 u64 dbg_rx_ampdu_drop_count;
356 u64 dbg_rx_ampdu_forced_indicate_count;
357 u64 dbg_rx_ampdu_loss_count;
358 u64 dbg_rx_dup_mgt_frame_drop_count;
359 u64 dbg_rx_ampdu_window_shift_cnt;
360 u64 dbg_rx_conflic_mac_addr_cnt;
361
362 uint rx_icv_err;
363 uint rx_largepacket_crcerr;
364 uint rx_smallpacket_crcerr;
365 uint rx_middlepacket_crcerr;
366
367 #ifdef CONFIG_USB_HCI
368 /* u8 *pallocated_urb_buf; */
369 _sema allrxreturnevt;
370 uint ff_hwaddr;
371 ATOMIC_T rx_pending_cnt;
372
373 #ifdef CONFIG_USB_INTERRUPT_IN_PIPE
374 #ifdef PLATFORM_LINUX
375 PURB int_in_urb;
376 #endif
377
378 u8 *int_in_buf;
379 #endif /* CONFIG_USB_INTERRUPT_IN_PIPE */
380
381 #endif
382 #if defined(PLATFORM_LINUX) || defined(PLATFORM_FREEBSD)
383 _tasklet irq_prepare_beacon_tasklet;
384 _tasklet recv_tasklet;
385
386 struct sk_buff_head free_recv_skb_queue;
387 struct sk_buff_head rx_skb_queue;
388 #ifdef CONFIG_RTW_NAPI
389 struct sk_buff_head rx_napi_skb_queue;
390 #endif
391 #ifdef CONFIG_RX_INDICATE_QUEUE
392 _tasklet rx_indicate_tasklet;
393 struct ifqueue rx_indicate_queue;
394 #endif /* CONFIG_RX_INDICATE_QUEUE */
395
396 #endif /* defined(PLATFORM_LINUX) || defined(PLATFORM_FREEBSD) */
397
398 u8 *pallocated_recv_buf;
399 u8 *precv_buf; /* 4 alignment */
400 _queue free_recv_buf_queue;
401 u32 free_recv_buf_queue_cnt;
402
403 #if defined(CONFIG_SDIO_HCI) || defined(CONFIG_GSPI_HCI) || defined(CONFIG_USB_HCI)
404 _queue recv_buf_pending_queue;
405 #endif
406
407 #if defined(CONFIG_SDIO_HCI)
408 #ifdef CONFIG_SDIO_RECVBUF_PWAIT
409 struct rtw_pwait_ctx recvbuf_pwait;
410 #endif
411 #ifdef CONFIG_SDIO_RECVBUF_AGGREGATION
412 bool recvbuf_agg;
413 #endif
414 #endif /* CONFIG_SDIO_HCI */
415
416 #ifdef CONFIG_PCI_HCI
417 /* Rx */
418 struct rtw_rx_ring rx_ring[PCI_MAX_RX_QUEUE];
419 int rxringcount; /* size should be PCI_MAX_RX_QUEUE */
420 u32 rxbuffersize;
421 #endif
422
423 /* For display the phy informatiom */
424 u8 is_signal_dbg; /* for debug */
425 u8 signal_strength_dbg; /* for debug */
426
427 u8 signal_strength;
428 u8 signal_qual;
429 s8 rssi; /* translate_percentage_to_dbm(ptarget_wlan->network.PhyInfo.SignalStrength); */
430 struct rx_raw_rssi raw_rssi_info;
431 /* s8 rxpwdb; */
432 /* int RxSNRdB[2]; */
433 /* s8 RxRssi[2]; */
434 /* int FalseAlmCnt_all; */
435
436
437 #ifdef CONFIG_NEW_SIGNAL_STAT_PROCESS
438 _timer signal_stat_timer;
439 u32 signal_stat_sampling_interval;
440 /* u32 signal_stat_converging_constant; */
441 struct signal_stat signal_qual_data;
442 struct signal_stat signal_strength_data;
443 #else /* CONFIG_NEW_SIGNAL_STAT_PROCESS */
444 struct smooth_rssi_data signal_qual_data;
445 struct smooth_rssi_data signal_strength_data;
446 #endif /* CONFIG_NEW_SIGNAL_STAT_PROCESS */
447 u16 sink_udpport, pre_rtp_rxseq, cur_rtp_rxseq;
448
449 BOOLEAN store_law_data_flag;
450 };
451
452 #ifdef CONFIG_SDIO_RECVBUF_AGGREGATION
453 #define recv_buf_agg(recvpriv) recvpriv->recvbuf_agg
454 #ifndef CONFIG_SDIO_RECVBUF_AGGREGATION_EN
455 #define CONFIG_SDIO_RECVBUF_AGGREGATION_EN 1
456 #endif
457 #else
458 #define recv_buf_agg(recvpriv) 0
459 #endif
460
461 #define RX_BH_STG_UNKNOWN 0
462 #define RX_BH_STG_HDL_ENTER 1
463 #define RX_BH_STG_HDL_EXIT 2
464 #define RX_BH_STG_NEW_BUF 3
465 #define RX_BH_STG_NEW_FRAME 4
466 #define RX_BH_STG_NORMAL_RX 5
467 #define RX_BH_STG_NORMAL_RX_END 6
468 #define RX_BH_STG_C2H 7
469 #define RX_BH_STG_C2H_END 8
470
471 #if DBG_RX_BH_TRACKING
472 void rx_bh_tk_set_stage(struct recv_priv *recv, u32 s);
473 void rx_bh_tk_set_buf(struct recv_priv *recv, void *buf, void *data, u32 dlen);
474 void rx_bh_tk_set_buf_pos(struct recv_priv *recv, void *pos);
475 void rx_bh_tk_set_frame(struct recv_priv *recv, void *frame);
476 void dump_rx_bh_tk(void *sel, struct recv_priv *recv);
477 #else
478 #define rx_bh_tk_set_stage(recv, s) do {} while (0)
479 #define rx_bh_tk_set_buf(recv, buf, data, dlen) do {} while (0)
480 #define rx_bh_tk_set_buf_pos(recv, pos) do {} while (0)
481 #define rx_bh_tk_set_frame(recv, frame) do {} while (0)
482 #define dump_rx_bh_tk(sel, recv) do {} while (0)
483 #endif
484
485 #ifdef CONFIG_NEW_SIGNAL_STAT_PROCESS
486 #define rtw_set_signal_stat_timer(recvpriv) _set_timer(&(recvpriv)->signal_stat_timer, (recvpriv)->signal_stat_sampling_interval)
487 #endif /* CONFIG_NEW_SIGNAL_STAT_PROCESS */
488
489 struct sta_recv_priv {
490
491 _lock lock;
492 sint option;
493
494 /* _queue blk_strms[MAX_RX_NUMBLKS]; */
495 _queue defrag_q; /* keeping the fragment frame until defrag */
496
497 struct stainfo_rxcache rxcache;
498 u16 bmc_tid_rxseq[16];
499 u16 nonqos_rxseq;
500 u16 nonqos_bmc_rxseq;
501
502 /* uint sta_rx_bytes; */
503 /* uint sta_rx_pkts; */
504 /* uint sta_rx_fail; */
505
506 };
507
508
509 #define RBUF_TYPE_PREALLOC 0
510 #define RBUF_TYPE_TMP 1
511 #define RBUF_TYPE_PWAIT_ADJ 2
512
513 struct recv_buf {
514 _list list;
515
516 #ifdef PLATFORM_WINDOWS
517 _lock recvbuf_lock;
518 #endif
519
520 #ifdef CONFIG_SDIO_RECVBUF_PWAIT_RUNTIME_ADJUST
521 u8 type;
522 #endif
523
524 u32 ref_cnt;
525
526 PADAPTER adapter;
527
528 u8 *pbuf;
529 u8 *pallocated_buf;
530
531 u32 len;
532 u8 *phead;
533 u8 *pdata;
534 u8 *ptail;
535 u8 *pend;
536
537 #ifdef CONFIG_USB_HCI
538 PURB purb;
539 dma_addr_t dma_transfer_addr; /* (in) dma addr for transfer_buffer */
540 u32 alloc_sz;
541
542 u8 irp_pending;
543 int transfer_len;
544 #endif
545
546 #if defined(PLATFORM_LINUX)
547 _pkt *pskb;
548 #elif defined(PLATFORM_FREEBSD) /* skb solution */
549 struct sk_buff *pskb;
550 #endif
551 };
552
553 #ifdef CONFIG_SDIO_RECVBUF_PWAIT_RUNTIME_ADJUST
554 #define RBUF_IS_PREALLOC(rbuf) ((rbuf)->type == RBUF_TYPE_PREALLOC)
555 #else
556 #define RBUF_IS_PREALLOC(rbuf) 1
557 #endif
558
559 /*
560 head ----->
561
562 data ----->
563
564 payload
565
566 tail ----->
567
568
569 end ----->
570
571 len = (unsigned int )(tail - data);
572
573 */
574 struct recv_frame_hdr {
575 _list list;
576 _pkt *pkt;
577
578 _adapter *adapter;
579
580 u8 fragcnt;
581
582 int frame_tag;
583
584 struct rx_pkt_attrib attrib;
585
586 uint len;
587 u8 *rx_head;
588 u8 *rx_data;
589 u8 *rx_tail;
590 u8 *rx_end;
591
592 void *precvbuf;
593
594
595 /* */
596 struct sta_info *psta;
597
598 /* for A-MPDU Rx reordering buffer control */
599 struct recv_reorder_ctrl *preorder_ctrl;
600
601 #ifdef CONFIG_WAPI_SUPPORT
602 u8 UserPriority;
603 u8 WapiTempPN[16];
604 u8 WapiSrcAddr[6];
605 u8 bWapiCheckPNInDecrypt;
606 u8 bIsWaiPacket;
607 #endif
608
609 };
610
611
612 union recv_frame {
613
614 union {
615 _list list;
616 struct recv_frame_hdr hdr;
617 uint mem[RECVFRAME_HDR_ALIGN >> 2];
618 } u;
619
620 /* uint mem[MAX_RXSZ>>2]; */
621
622 };
623
624 enum rtw_rx_llc_hdl {
625 RTW_RX_LLC_KEEP = 0,
626 RTW_RX_LLC_REMOVE = 1,
627 RTW_RX_LLC_VLAN = 2,
628 };
629
630 bool rtw_rframe_del_wfd_ie(union recv_frame *rframe, u8 ies_offset);
631
632 typedef enum _RX_PACKET_TYPE {
633 NORMAL_RX,/* Normal rx packet */
634 TX_REPORT1,/* CCX */
635 TX_REPORT2,/* TX RPT */
636 HIS_REPORT,/* USB HISR RPT */
637 C2H_PACKET
638 } RX_PACKET_TYPE, *PRX_PACKET_TYPE;
639
640 extern union recv_frame *_rtw_alloc_recvframe(_queue *pfree_recv_queue); /* get a free recv_frame from pfree_recv_queue */
641 extern union recv_frame *rtw_alloc_recvframe(_queue *pfree_recv_queue); /* get a free recv_frame from pfree_recv_queue */
642 extern void rtw_init_recvframe(union recv_frame *precvframe , struct recv_priv *precvpriv);
643 extern int rtw_free_recvframe(union recv_frame *precvframe, _queue *pfree_recv_queue);
644
645 #define rtw_dequeue_recvframe(queue) rtw_alloc_recvframe(queue)
646 extern int _rtw_enqueue_recvframe(union recv_frame *precvframe, _queue *queue);
647 extern int rtw_enqueue_recvframe(union recv_frame *precvframe, _queue *queue);
648
649 extern void rtw_free_recvframe_queue(_queue *pframequeue, _queue *pfree_recv_queue);
650 u32 rtw_free_uc_swdec_pending_queue(_adapter *adapter);
651
652 sint rtw_enqueue_recvbuf_to_head(struct recv_buf *precvbuf, _queue *queue);
653 sint rtw_enqueue_recvbuf(struct recv_buf *precvbuf, _queue *queue);
654 struct recv_buf *rtw_dequeue_recvbuf(_queue *queue);
655
656 void process_pwrbit_data(_adapter *padapter, union recv_frame *precv_frame, struct sta_info *psta);
657 void process_wmmps_data(_adapter *padapter, union recv_frame *precv_frame, struct sta_info *psta);
658
659 #if defined(CONFIG_80211N_HT) && defined(CONFIG_RECV_REORDERING_CTRL)
660 void rtw_reordering_ctrl_timeout_handler(void *pcontext);
661 #endif
662
663 void rx_query_phy_status(union recv_frame *rframe, u8 *phy_stat);
664 int rtw_inc_and_chk_continual_no_rx_packet(struct sta_info *sta, int tid_index);
665 void rtw_reset_continual_no_rx_packet(struct sta_info *sta, int tid_index);
666
667 #ifdef CONFIG_RECV_THREAD_MODE
668 thread_return rtw_recv_thread(thread_context context);
669 #endif
670
get_rxmem(union recv_frame * precvframe)671 __inline static u8 *get_rxmem(union recv_frame *precvframe)
672 {
673 /* always return rx_head... */
674 if (precvframe == NULL)
675 return NULL;
676
677 return precvframe->u.hdr.rx_head;
678 }
679
get_rx_status(union recv_frame * precvframe)680 __inline static u8 *get_rx_status(union recv_frame *precvframe)
681 {
682
683 return get_rxmem(precvframe);
684
685 }
686
get_recvframe_data(union recv_frame * precvframe)687 __inline static u8 *get_recvframe_data(union recv_frame *precvframe)
688 {
689
690 /* alwasy return rx_data */
691 if (precvframe == NULL)
692 return NULL;
693
694 return precvframe->u.hdr.rx_data;
695
696 }
697
recvframe_push(union recv_frame * precvframe,sint sz)698 __inline static u8 *recvframe_push(union recv_frame *precvframe, sint sz)
699 {
700 /* append data before rx_data */
701
702 /* add data to the start of recv_frame
703 *
704 * This function extends the used data area of the recv_frame at the buffer
705 * start. rx_data must be still larger than rx_head, after pushing.
706 */
707
708 if (precvframe == NULL)
709 return NULL;
710
711
712 precvframe->u.hdr.rx_data -= sz ;
713 if (precvframe->u.hdr.rx_data < precvframe->u.hdr.rx_head) {
714 precvframe->u.hdr.rx_data += sz ;
715 return NULL;
716 }
717
718 precvframe->u.hdr.len += sz;
719
720 return precvframe->u.hdr.rx_data;
721
722 }
723
724
recvframe_pull(union recv_frame * precvframe,sint sz)725 __inline static u8 *recvframe_pull(union recv_frame *precvframe, sint sz)
726 {
727 /* rx_data += sz; move rx_data sz bytes hereafter */
728
729 /* used for extract sz bytes from rx_data, update rx_data and return the updated rx_data to the caller */
730
731
732 if (precvframe == NULL)
733 return NULL;
734
735
736 precvframe->u.hdr.rx_data += sz;
737
738 if (precvframe->u.hdr.rx_data > precvframe->u.hdr.rx_tail) {
739 precvframe->u.hdr.rx_data -= sz;
740 return NULL;
741 }
742
743 precvframe->u.hdr.len -= sz;
744
745 return precvframe->u.hdr.rx_data;
746
747 }
748
recvframe_put(union recv_frame * precvframe,sint sz)749 __inline static u8 *recvframe_put(union recv_frame *precvframe, sint sz)
750 {
751 /* rx_tai += sz; move rx_tail sz bytes hereafter */
752
753 /* used for append sz bytes from ptr to rx_tail, update rx_tail and return the updated rx_tail to the caller */
754 /* after putting, rx_tail must be still larger than rx_end. */
755 unsigned char *prev_rx_tail;
756
757 /* RTW_INFO("recvframe_put: len=%d\n", sz); */
758
759 if (precvframe == NULL)
760 return NULL;
761
762 prev_rx_tail = precvframe->u.hdr.rx_tail;
763
764 precvframe->u.hdr.rx_tail += sz;
765
766 if (precvframe->u.hdr.rx_tail > precvframe->u.hdr.rx_end) {
767 precvframe->u.hdr.rx_tail -= sz;
768 return NULL;
769 }
770
771 precvframe->u.hdr.len += sz;
772
773 return precvframe->u.hdr.rx_tail;
774
775 }
776
777
778
recvframe_pull_tail(union recv_frame * precvframe,sint sz)779 __inline static u8 *recvframe_pull_tail(union recv_frame *precvframe, sint sz)
780 {
781 /* rmv data from rx_tail (by yitsen) */
782
783 /* used for extract sz bytes from rx_end, update rx_end and return the updated rx_end to the caller */
784 /* after pulling, rx_end must be still larger than rx_data. */
785
786 if (precvframe == NULL)
787 return NULL;
788
789 precvframe->u.hdr.rx_tail -= sz;
790
791 if (precvframe->u.hdr.rx_tail < precvframe->u.hdr.rx_data) {
792 precvframe->u.hdr.rx_tail += sz;
793 return NULL;
794 }
795
796 precvframe->u.hdr.len -= sz;
797
798 return precvframe->u.hdr.rx_tail;
799
800 }
801
rxmem_to_recvframe(u8 * rxmem)802 __inline static union recv_frame *rxmem_to_recvframe(u8 *rxmem)
803 {
804 /* due to the design of 2048 bytes alignment of recv_frame, we can reference the union recv_frame */
805 /* from any given member of recv_frame. */
806 /* rxmem indicates the any member/address in recv_frame */
807
808 return (union recv_frame *)(((SIZE_PTR)rxmem >> RXFRAME_ALIGN) << RXFRAME_ALIGN);
809
810 }
811
pkt_to_recvframe(_pkt * pkt)812 __inline static union recv_frame *pkt_to_recvframe(_pkt *pkt)
813 {
814
815 u8 *buf_star;
816 union recv_frame *precv_frame;
817 precv_frame = rxmem_to_recvframe((unsigned char *)buf_star);
818
819 return precv_frame;
820 }
821
pkt_to_recvmem(_pkt * pkt)822 __inline static u8 *pkt_to_recvmem(_pkt *pkt)
823 {
824 /* return the rx_head */
825
826 union recv_frame *precv_frame = pkt_to_recvframe(pkt);
827
828 return precv_frame->u.hdr.rx_head;
829
830 }
831
pkt_to_recvdata(_pkt * pkt)832 __inline static u8 *pkt_to_recvdata(_pkt *pkt)
833 {
834 /* return the rx_data */
835
836 union recv_frame *precv_frame = pkt_to_recvframe(pkt);
837
838 return precv_frame->u.hdr.rx_data;
839
840 }
841
842
get_recvframe_len(union recv_frame * precvframe)843 __inline static sint get_recvframe_len(union recv_frame *precvframe)
844 {
845 return precvframe->u.hdr.len;
846 }
847
848
translate_percentage_to_dbm(u32 SignalStrengthIndex)849 __inline static s32 translate_percentage_to_dbm(u32 SignalStrengthIndex)
850 {
851 s32 SignalPower; /* in dBm. */
852
853 /* Translate to dBm (x=y-100) */
854 SignalPower = SignalStrengthIndex - 100;
855 return SignalPower;
856 }
857
858 struct sta_info;
859
860 extern void _rtw_init_sta_recv_priv(struct sta_recv_priv *psta_recvpriv);
861
862 extern void mgt_dispatcher(_adapter *padapter, union recv_frame *precv_frame);
863
864 u8 adapter_allow_bmc_data_rx(_adapter *adapter);
865 s32 pre_recv_entry(union recv_frame *precvframe, u8 *pphy_status);
866 void count_rx_stats(_adapter *padapter, union recv_frame *prframe, struct sta_info *sta);
867
868 #endif
869