1 #ifndef _RTL871X_RECV_H_
2 #define _RTL871X_RECV_H_
4 #include "osdep_service.h"
7 #define NR_RECVFRAME 256
9 #define RXFRAME_ALIGN 8
10 #define RXFRAME_ALIGN_SZ (1 << RXFRAME_ALIGN)
12 #define MAX_SUBFRAME_COUNT 64
14 #define SNAP_SIZE sizeof(struct ieee80211_snap_hdr)
16 /* for Rx reordering buffer control */
17 struct recv_reorder_ctrl
{
18 struct _adapter
*padapter
;
19 u16 indicate_seq
; /* =wstart_b, init_value=0xffff */
22 struct __queue pending_recvframe_queue
;
23 struct timer_list reordering_ctrl_timer
;
26 struct stainfo_rxcache
{
30 #define PHY_RSSI_SLID_WIN_MAX 100
31 #define PHY_LINKQUALITY_SLID_WIN_MAX 20
34 struct smooth_rssi_data
{
35 u32 elements
[100]; /* array to store values */
36 u32 index
; /* index to current array to store */
37 u32 total_num
; /* num of valid elements */
38 u32 total_val
; /* sum of valid elements */
41 struct rx_pkt_attrib
{
52 u8 privacy
; /* in frame_ctrl field */
54 int hdrlen
; /* the WLAN Header Len */
55 int encrypt
; /* 0 no encrypt. != 0 encrypt algorith */
66 u8 tcpchk_valid
; /* 0: invalid, 1: valid */
67 u8 ip_chkrpt
; /* 0: incorrect, 1: correct */
68 u8 tcp_chkrpt
; /* 0: incorrect, 1: correct */
70 s8 rx_mimo_signal_qual
[2];
77 accesser of recv_priv: recv_entry(dispatch / passive level);
78 recv_thread(passive) ; returnpkt(dispatch)
81 using enter_critical section to protect
85 struct __queue free_recv_queue
;
86 struct __queue recv_pending_queue
;
87 u8
*pallocated_frame_buf
;
89 uint free_recvframe_cnt
;
90 struct _adapter
*adapter
;
95 uint rx_largepacket_crcerr
;
96 uint rx_smallpacket_crcerr
;
97 uint rx_middlepacket_crcerr
;
100 struct tasklet_struct recv_tasklet
;
101 struct sk_buff_head free_recv_skb_queue
;
102 struct sk_buff_head rx_skb_queue
;
103 u8
*pallocated_recv_buf
;
104 u8
*precv_buf
; /* 4 alignment */
105 struct __queue free_recv_buf_queue
;
106 u32 free_recv_buf_queue_cnt
;
107 /* For the phy informatiom */
112 struct smooth_rssi_data signal_qual_data
;
113 struct smooth_rssi_data signal_strength_data
;
116 struct sta_recv_priv
{
119 struct __queue defrag_q
; /* keeping the fragment frame until defrag */
120 struct stainfo_rxcache rxcache
;
126 #include "rtl8712_recv.h"
128 /* get a free recv_frame from pfree_recv_queue */
129 union recv_frame
*r8712_alloc_recvframe(struct __queue
*pfree_recv_queue
);
130 int r8712_free_recvframe(union recv_frame
*precvframe
,
131 struct __queue
*pfree_recv_queue
);
132 void r8712_free_recvframe_queue(struct __queue
*pframequeue
,
133 struct __queue
*pfree_recv_queue
);
134 int r8712_wlanhdr_to_ethhdr(union recv_frame
*precvframe
);
135 int recv_func(struct _adapter
*padapter
, void *pcontext
);
137 static inline u8
*get_rxmem(union recv_frame
*precvframe
)
139 /* always return rx_head... */
140 if (precvframe
== NULL
)
142 return precvframe
->u
.hdr
.rx_head
;
145 static inline u8
*get_recvframe_data(union recv_frame
*precvframe
)
147 /* always return rx_data */
148 if (precvframe
== NULL
)
150 return precvframe
->u
.hdr
.rx_data
;
153 static inline u8
*recvframe_pull(union recv_frame
*precvframe
, sint sz
)
155 /* used for extract sz bytes from rx_data, update rx_data and return
156 * the updated rx_data to the caller */
157 if (precvframe
== NULL
)
159 precvframe
->u
.hdr
.rx_data
+= sz
;
160 if (precvframe
->u
.hdr
.rx_data
> precvframe
->u
.hdr
.rx_tail
) {
161 precvframe
->u
.hdr
.rx_data
-= sz
;
164 precvframe
->u
.hdr
.len
-= sz
;
165 return precvframe
->u
.hdr
.rx_data
;
168 static inline u8
*recvframe_put(union recv_frame
*precvframe
, sint sz
)
170 /* used for append sz bytes from ptr to rx_tail, update rx_tail and
171 * return the updated rx_tail to the caller
172 * after putting, rx_tail must be still larger than rx_end. */
173 if (precvframe
== NULL
)
175 precvframe
->u
.hdr
.rx_tail
+= sz
;
176 if (precvframe
->u
.hdr
.rx_tail
> precvframe
->u
.hdr
.rx_end
) {
177 precvframe
->u
.hdr
.rx_tail
-= sz
;
180 precvframe
->u
.hdr
.len
+= sz
;
181 return precvframe
->u
.hdr
.rx_tail
;
184 static inline u8
*recvframe_pull_tail(union recv_frame
*precvframe
, sint sz
)
186 /* rmv data from rx_tail (by yitsen)
187 * used for extract sz bytes from rx_end, update rx_end and return the
188 * updated rx_end to the caller
189 * after pulling, rx_end must be still larger than rx_data. */
190 if (precvframe
== NULL
)
192 precvframe
->u
.hdr
.rx_tail
-= sz
;
193 if (precvframe
->u
.hdr
.rx_tail
< precvframe
->u
.hdr
.rx_data
) {
194 precvframe
->u
.hdr
.rx_tail
+= sz
;
197 precvframe
->u
.hdr
.len
-= sz
;
198 return precvframe
->u
.hdr
.rx_tail
;
203 void _r8712_init_sta_recv_priv(struct sta_recv_priv
*psta_recvpriv
);
204 sint
r8712_recvframe_chkmic(struct _adapter
*adapter
,
205 union recv_frame
*precvframe
);
206 union recv_frame
*r8712_decryptor(struct _adapter
*adapter
,
207 union recv_frame
*precv_frame
);
208 union recv_frame
*r8712_recvframe_chk_defrag(struct _adapter
*adapter
,
209 union recv_frame
*precv_frame
);
210 int r8712_validate_recv_frame(struct _adapter
*adapter
,
211 union recv_frame
*precv_frame
);
212 union recv_frame
*r8712_portctrl(struct _adapter
*adapter
,
213 union recv_frame
*precv_frame
);