1 #ifndef _RTL8712_RECV_H_
2 #define _RTL8712_RECV_H_
3 
4 #include "osdep_service.h"
5 #include "drv_types.h"
6 
7 #define NR_RECVBUFF (8)
8 #define NR_PREALLOC_RECV_SKB (8)
9 #define RXDESC_SIZE	24
10 #define RXDESC_OFFSET RXDESC_SIZE
11 #define RECV_BLK_SZ 512
12 #define RECV_BLK_CNT 16
13 #define RECV_BLK_TH RECV_BLK_CNT
14 #define MAX_RECVBUF_SZ (30720) /* 30K */
15 #define RECVBUFF_ALIGN_SZ 512
16 #define RSVD_ROOM_SZ (0)
17 /*These definition is used for Rx packet reordering.*/
18 #define SN_LESS(a, b)		(((a-b) & 0x800) != 0)
19 #define SN_EQUAL(a, b)	(a == b)
20 #define REORDER_WAIT_TIME	30 /* (ms)*/
21 
22 struct recv_stat {
23 	unsigned int rxdw0;
24 	unsigned int rxdw1;
25 	unsigned int rxdw2;
26 	unsigned int rxdw3;
27 	unsigned int rxdw4;
28 	unsigned int rxdw5;
29 };
30 
31 struct phy_cck_rx_status {
32 	/* For CCK rate descriptor. This is a unsigned 8:1 variable.
33 	 * LSB bit present 0.5. And MSB 7 bts present a signed value.
34 	 * Range from -64~+63.5. */
35 	u8	adc_pwdb_X[4];
36 	u8	sq_rpt;
37 	u8	cck_agc_rpt;
38 };
39 
40 struct phy_stat {
41 	unsigned int phydw0;
42 	unsigned int phydw1;
43 	unsigned int phydw2;
44 	unsigned int phydw3;
45 	unsigned int phydw4;
46 	unsigned int phydw5;
47 	unsigned int phydw6;
48 	unsigned int phydw7;
49 };
50 #define PHY_STAT_GAIN_TRSW_SHT 0
51 #define PHY_STAT_PWDB_ALL_SHT 4
52 #define PHY_STAT_CFOSHO_SHT 5
53 #define PHY_STAT_CCK_AGC_RPT_SHT 5
54 #define PHY_STAT_CFOTAIL_SHT 9
55 #define PHY_STAT_RXEVM_SHT 13
56 #define PHY_STAT_RXSNR_SHT 15
57 #define PHY_STAT_PDSNR_SHT 19
58 #define PHY_STAT_CSI_CURRENT_SHT 21
59 #define PHY_STAT_CSI_TARGET_SHT 23
60 #define PHY_STAT_SIGEVM_SHT 25
61 #define PHY_STAT_MAX_EX_PWR_SHT 26
62 
63 union recvstat {
64 	struct recv_stat recv_stat;
65 	unsigned int value[RXDESC_SIZE>>2];
66 };
67 
68 
69 struct recv_buf {
70 	struct list_head list;
71 	spinlock_t recvbuf_lock;
72 	u32	ref_cnt;
73 	struct _adapter  *adapter;
74 	struct urb *purb;
75 	_pkt *pskb;
76 	u8 reuse;
77 	u8  irp_pending;
78 	u32  transfer_len;
79 	uint  len;
80 	u8 *phead;
81 	u8 *pdata;
82 	u8 *ptail;
83 	u8 *pend;
84 	u8 *pbuf;
85 	u8 *pallocated_buf;
86 };
87 
88 /*
89 	head  ----->
90 		data  ----->
91 			payload
92 		tail  ----->
93 	end   ----->
94 	len = (unsigned int )(tail - data);
95 */
96 struct recv_frame_hdr{
97 	struct list_head list;
98 	_pkt	*pkt;
99 	_pkt *pkt_newalloc;
100 	struct _adapter  *adapter;
101 	u8 fragcnt;
102 	struct rx_pkt_attrib attrib;
103 	uint  len;
104 	u8 *rx_head;
105 	u8 *rx_data;
106 	u8 *rx_tail;
107 	u8 *rx_end;
108 	void *precvbuf;
109 	struct sta_info *psta;
110 	/*for A-MPDU Rx reordering buffer control*/
111 	struct recv_reorder_ctrl *preorder_ctrl;
112 };
113 
114 union recv_frame {
115 	union {
116 		struct list_head list;
117 		struct recv_frame_hdr hdr;
118 		addr_t mem[RECVFRAME_HDR_ALIGN>>2];
119 	} u;
120 };
121 
122 int r8712_init_recvbuf(struct _adapter *padapter, struct recv_buf *precvbuf);
123 void r8712_rxcmd_event_hdl(struct _adapter *padapter, void *prxcmdbuf);
124 s32 r8712_signal_scale_mapping(s32 cur_sig);
125 void r8712_reordering_ctrl_timeout_handler(void *pcontext);
126 
127 #endif
128 
129