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_RXFRAME_CNT 512
13 #define MAX_RX_NUMBLKS (32)
14 #define RECVFRAME_HDR_ALIGN 128
15 #define MAX_SUBFRAME_COUNT 64
17 #define SNAP_SIZE sizeof(struct ieee80211_snap_hdr)
19 /* for Rx reordering buffer control */
20 struct recv_reorder_ctrl
{
21 struct _adapter
*padapter
;
22 u16 indicate_seq
; /* =wstart_b, init_value=0xffff */
25 struct __queue pending_recvframe_queue
;
26 struct timer_list reordering_ctrl_timer
;
29 struct stainfo_rxcache
{
33 #define PHY_RSSI_SLID_WIN_MAX 100
34 #define PHY_LINKQUALITY_SLID_WIN_MAX 20
37 struct smooth_rssi_data
{
38 u32 elements
[100]; /* array to store values */
39 u32 index
; /* index to current array to store */
40 u32 total_num
; /* num of valid elements */
41 u32 total_val
; /* sum of valid elements */
44 struct rx_pkt_attrib
{
55 u8 privacy
; /* in frame_ctrl field */
57 int hdrlen
; /* the WLAN Header Len */
58 int encrypt
; /* 0 no encrypt. != 0 encrypt algorith */
69 u8 tcpchk_valid
; /* 0: invalid, 1: valid */
70 u8 ip_chkrpt
; /* 0: incorrect, 1: correct */
71 u8 tcp_chkrpt
; /* 0: incorrect, 1: correct */
73 s8 rx_mimo_signal_qual
[2];
80 accesser of recv_priv: recv_entry(dispatch / passive level);
81 recv_thread(passive) ; returnpkt(dispatch)
84 using enter_critical section to protect
88 struct semaphore recv_sema
;
89 struct semaphore terminate_recvthread_sema
;
90 struct __queue free_recv_queue
;
91 struct __queue recv_pending_queue
;
92 u8
*pallocated_frame_buf
;
94 uint free_recvframe_cnt
;
95 struct _adapter
*adapter
;
100 uint rx_largepacket_crcerr
;
101 uint rx_smallpacket_crcerr
;
102 uint rx_middlepacket_crcerr
;
103 struct semaphore allrxreturnevt
;
106 struct tasklet_struct recv_tasklet
;
107 struct sk_buff_head free_recv_skb_queue
;
108 struct sk_buff_head rx_skb_queue
;
109 u8
*pallocated_recv_buf
;
110 u8
*precv_buf
; /* 4 alignment */
111 struct __queue free_recv_buf_queue
;
112 u32 free_recv_buf_queue_cnt
;
113 /* For the phy informatiom */
118 struct smooth_rssi_data signal_qual_data
;
119 struct smooth_rssi_data signal_strength_data
;
122 struct sta_recv_priv
{
125 struct __queue defrag_q
; /* keeping the fragment frame until defrag */
126 struct stainfo_rxcache rxcache
;
132 #include "rtl8712_recv.h"
134 /* get a free recv_frame from pfree_recv_queue */
135 union recv_frame
*r8712_alloc_recvframe(struct __queue
*pfree_recv_queue
);
136 union recv_frame
*r8712_dequeue_recvframe(struct __queue
*queue
);
137 int r8712_enqueue_recvframe(union recv_frame
*precvframe
,
138 struct __queue
*queue
);
139 int r8712_free_recvframe(union recv_frame
*precvframe
,
140 struct __queue
*pfree_recv_queue
);
141 void r8712_free_recvframe_queue(struct __queue
*pframequeue
,
142 struct __queue
*pfree_recv_queue
);
143 void r8712_init_recvframe(union recv_frame
*precvframe
,
144 struct recv_priv
*precvpriv
);
145 int r8712_wlanhdr_to_ethhdr(union recv_frame
*precvframe
);
146 int recv_func(struct _adapter
*padapter
, void *pcontext
);
148 static inline u8
*get_rxmem(union recv_frame
*precvframe
)
150 /* always return rx_head... */
151 if (precvframe
== NULL
)
153 return precvframe
->u
.hdr
.rx_head
;
156 static inline u8
*get_rx_status(union recv_frame
*precvframe
)
158 return get_rxmem(precvframe
);
161 static inline u8
*get_recvframe_data(union recv_frame
*precvframe
)
163 /* always return rx_data */
164 if (precvframe
== NULL
)
166 return precvframe
->u
.hdr
.rx_data
;
169 static inline u8
*recvframe_push(union recv_frame
*precvframe
, sint sz
)
171 /* append data before rx_data */
173 /* add data to the start of recv_frame
175 * This function extends the used data area of the recv_frame at the
176 * buffer start. rx_data must be still larger than rx_head, after
180 if (precvframe
== NULL
)
182 precvframe
->u
.hdr
.rx_data
-= sz
;
183 if (precvframe
->u
.hdr
.rx_data
< precvframe
->u
.hdr
.rx_head
) {
184 precvframe
->u
.hdr
.rx_data
+= sz
;
187 precvframe
->u
.hdr
.len
+= sz
;
188 return precvframe
->u
.hdr
.rx_data
;
191 static inline u8
*recvframe_pull(union recv_frame
*precvframe
, sint sz
)
193 /* used for extract sz bytes from rx_data, update rx_data and return
194 * the updated rx_data to the caller */
195 if (precvframe
== NULL
)
197 precvframe
->u
.hdr
.rx_data
+= sz
;
198 if (precvframe
->u
.hdr
.rx_data
> precvframe
->u
.hdr
.rx_tail
) {
199 precvframe
->u
.hdr
.rx_data
-= sz
;
202 precvframe
->u
.hdr
.len
-= sz
;
203 return precvframe
->u
.hdr
.rx_data
;
206 static inline u8
*recvframe_put(union recv_frame
*precvframe
, sint sz
)
208 /* used for append sz bytes from ptr to rx_tail, update rx_tail and
209 * return the updated rx_tail to the caller
210 * after putting, rx_tail must be still larger than rx_end. */
211 unsigned char *prev_rx_tail
;
213 if (precvframe
== NULL
)
215 prev_rx_tail
= precvframe
->u
.hdr
.rx_tail
;
216 precvframe
->u
.hdr
.rx_tail
+= sz
;
217 if (precvframe
->u
.hdr
.rx_tail
> precvframe
->u
.hdr
.rx_end
) {
218 precvframe
->u
.hdr
.rx_tail
-= sz
;
221 precvframe
->u
.hdr
.len
+= sz
;
222 return precvframe
->u
.hdr
.rx_tail
;
225 static inline u8
*recvframe_pull_tail(union recv_frame
*precvframe
, sint sz
)
227 /* rmv data from rx_tail (by yitsen)
228 * used for extract sz bytes from rx_end, update rx_end and return the
229 * updated rx_end to the caller
230 * after pulling, rx_end must be still larger than rx_data. */
231 if (precvframe
== NULL
)
233 precvframe
->u
.hdr
.rx_tail
-= sz
;
234 if (precvframe
->u
.hdr
.rx_tail
< precvframe
->u
.hdr
.rx_data
) {
235 precvframe
->u
.hdr
.rx_tail
+= sz
;
238 precvframe
->u
.hdr
.len
-= sz
;
239 return precvframe
->u
.hdr
.rx_tail
;
242 static inline _buffer
*get_rxbuf_desc(union recv_frame
*precvframe
)
245 if (precvframe
== NULL
)
250 static inline union recv_frame
*rxmem_to_recvframe(u8
*rxmem
)
252 /* due to the design of 2048 bytes alignment of recv_frame, we can
253 * reference the union recv_frame from any given member of recv_frame.
254 * rxmem indicates the any member/address in recv_frame */
255 return (union recv_frame
*)(((addr_t
)rxmem
>> RXFRAME_ALIGN
) <<
259 static inline union recv_frame
*pkt_to_recvframe(_pkt
*pkt
)
262 union recv_frame
*precv_frame
;
264 precv_frame
= rxmem_to_recvframe((unsigned char *)buf_star
);
268 static inline u8
*pkt_to_recvmem(_pkt
*pkt
)
270 /* return the rx_head */
271 union recv_frame
*precv_frame
= pkt_to_recvframe(pkt
);
273 return precv_frame
->u
.hdr
.rx_head
;
276 static inline u8
*pkt_to_recvdata(_pkt
*pkt
)
278 /* return the rx_data */
279 union recv_frame
*precv_frame
= pkt_to_recvframe(pkt
);
281 return precv_frame
->u
.hdr
.rx_data
;
284 static inline sint
get_recvframe_len(union recv_frame
*precvframe
)
286 return precvframe
->u
.hdr
.len
;
291 void _r8712_init_sta_recv_priv(struct sta_recv_priv
*psta_recvpriv
);
292 sint
r8712_recvframe_chkmic(struct _adapter
*adapter
,
293 union recv_frame
*precvframe
);
294 union recv_frame
*r8712_decryptor(struct _adapter
*adapter
,
295 union recv_frame
*precv_frame
);
296 union recv_frame
*r8712_recvframe_chk_defrag(struct _adapter
*adapter
,
297 union recv_frame
*precv_frame
);
298 union recv_frame
*r8712_recvframe_defrag(struct _adapter
*adapter
,
299 struct __queue
*defrag_q
);
300 union recv_frame
*r8712_recvframe_chk_defrag_new(struct _adapter
*adapter
,
301 union recv_frame
*precv_frame
);
302 union recv_frame
*r8712_recvframe_defrag_new(struct _adapter
*adapter
,
303 struct __queue
*defrag_q
,
304 union recv_frame
*precv_frame
);
305 int r8712_recv_decache(union recv_frame
*precv_frame
, u8 bretry
,
306 struct stainfo_rxcache
*prxcache
);
307 int r8712_sta2sta_data_frame(struct _adapter
*adapter
,
308 union recv_frame
*precv_frame
,
309 struct sta_info
**psta
);
310 int r8712_ap2sta_data_frame(struct _adapter
*adapter
,
311 union recv_frame
*precv_frame
,
312 struct sta_info
**psta
);
313 int r8712_sta2ap_data_frame(struct _adapter
*adapter
,
314 union recv_frame
*precv_frame
,
315 struct sta_info
**psta
);
316 int r8712_validate_recv_ctrl_frame(struct _adapter
*adapter
,
317 union recv_frame
*precv_frame
);
318 int r8712_validate_recv_mgnt_frame(struct _adapter
*adapter
,
319 union recv_frame
*precv_frame
);
320 int r8712_validate_recv_data_frame(struct _adapter
*adapter
,
321 union recv_frame
*precv_frame
);
322 int r8712_validate_recv_frame(struct _adapter
*adapter
,
323 union recv_frame
*precv_frame
);
324 union recv_frame
*r8712_portctrl(struct _adapter
*adapter
,
325 union recv_frame
*precv_frame
);
326 void r8712_mgt_dispatcher(struct _adapter
*padapter
, u8
*pframe
, uint len
);
327 int r8712_amsdu_to_msdu(struct _adapter
*padapter
, union recv_frame
*prframe
);