Merge remote-tracking branch 'staging/staging-next'
[deliverable/linux.git] / drivers / staging / rtl8712 / rtl871x_recv.h
CommitLineData
2865d42c
LF
1#ifndef _RTL871X_RECV_H_
2#define _RTL871X_RECV_H_
3
4#include "osdep_service.h"
5#include "drv_types.h"
6
7#define NR_RECVFRAME 256
8
9#define RXFRAME_ALIGN 8
10#define RXFRAME_ALIGN_SZ (1 << RXFRAME_ALIGN)
11
2865d42c
LF
12#define MAX_SUBFRAME_COUNT 64
13
14#define SNAP_SIZE sizeof(struct ieee80211_snap_hdr)
15
16/* for Rx reordering buffer control */
17struct recv_reorder_ctrl {
18 struct _adapter *padapter;
0593758e 19 u16 indicate_seq; /* =wstart_b, init_value=0xffff */
2865d42c 20 u16 wend_b;
0593758e 21 u8 wsize_b;
2865d42c
LF
22 struct __queue pending_recvframe_queue;
23 struct timer_list reordering_ctrl_timer;
24};
25
26struct stainfo_rxcache {
27 u16 tid_rxseq[16];
28};
29
30#define PHY_RSSI_SLID_WIN_MAX 100
31#define PHY_LINKQUALITY_SLID_WIN_MAX 20
32
33
34struct 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 */
39};
40
41struct rx_pkt_attrib {
42
43 u8 amsdu;
44 u8 order;
45 u8 qos;
46 u8 to_fr_ds;
47 u8 frag_num;
48 u16 seq_num;
49 u8 pw_save;
50 u8 mfrag;
51 u8 mdata;
52 u8 privacy; /* in frame_ctrl field */
53 u8 bdecrypted;
54 int hdrlen; /* the WLAN Header Len */
55 int encrypt; /* 0 no encrypt. != 0 encrypt algorith */
56 int iv_len;
57 int icv_len;
58 int priority;
59 int ack_policy;
60 u8 crc_err;
61 u8 dst[ETH_ALEN];
62 u8 src[ETH_ALEN];
63 u8 ta[ETH_ALEN];
64 u8 ra[ETH_ALEN];
65 u8 bssid[ETH_ALEN];
66 u8 tcpchk_valid; /* 0: invalid, 1: valid */
67 u8 ip_chkrpt; /* 0: incorrect, 1: correct */
68 u8 tcp_chkrpt; /* 0: incorrect, 1: correct */
69 u8 signal_qual;
70 s8 rx_mimo_signal_qual[2];
71 u8 mcs_rate;
72 u8 htc;
73 u8 signal_strength;
74};
75
76/*
77accesser of recv_priv: recv_entry(dispatch / passive level);
78recv_thread(passive) ; returnpkt(dispatch)
79; halt(passive) ;
80
81using enter_critical section to protect
82*/
83struct recv_priv {
84 spinlock_t lock;
2865d42c
LF
85 struct __queue free_recv_queue;
86 struct __queue recv_pending_queue;
87 u8 *pallocated_frame_buf;
88 u8 *precv_frame_buf;
89 uint free_recvframe_cnt;
90 struct _adapter *adapter;
91 uint rx_bytes;
92 uint rx_pkts;
93 uint rx_drop;
94 uint rx_icv_err;
95 uint rx_largepacket_crcerr;
96 uint rx_smallpacket_crcerr;
97 uint rx_middlepacket_crcerr;
2865d42c
LF
98 u8 rx_pending_cnt;
99 uint ff_hwaddr;
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 */
108 s8 rssi;
109 u8 signal;
110 u8 noise;
111 u8 fw_rssi;
112 struct smooth_rssi_data signal_qual_data;
113 struct smooth_rssi_data signal_strength_data;
114};
115
116struct sta_recv_priv {
117 spinlock_t lock;
118 sint option;
119 struct __queue defrag_q; /* keeping the fragment frame until defrag */
120 struct stainfo_rxcache rxcache;
121 uint sta_rx_bytes;
122 uint sta_rx_pkts;
123 uint sta_rx_fail;
124};
125
126#include "rtl8712_recv.h"
127
128/* get a free recv_frame from pfree_recv_queue */
129union recv_frame *r8712_alloc_recvframe(struct __queue *pfree_recv_queue);
2865d42c
LF
130int r8712_free_recvframe(union recv_frame *precvframe,
131 struct __queue *pfree_recv_queue);
132void r8712_free_recvframe_queue(struct __queue *pframequeue,
133 struct __queue *pfree_recv_queue);
2865d42c
LF
134int r8712_wlanhdr_to_ethhdr(union recv_frame *precvframe);
135int recv_func(struct _adapter *padapter, void *pcontext);
136
137static inline u8 *get_rxmem(union recv_frame *precvframe)
138{
139 /* always return rx_head... */
140 if (precvframe == NULL)
141 return NULL;
142 return precvframe->u.hdr.rx_head;
143}
144
2865d42c
LF
145static inline u8 *get_recvframe_data(union recv_frame *precvframe)
146{
147 /* always return rx_data */
148 if (precvframe == NULL)
149 return NULL;
150 return precvframe->u.hdr.rx_data;
151}
152
2865d42c
LF
153static inline u8 *recvframe_pull(union recv_frame *precvframe, sint sz)
154{
155 /* used for extract sz bytes from rx_data, update rx_data and return
bef611a9
RB
156 * the updated rx_data to the caller
157 */
2865d42c
LF
158 if (precvframe == NULL)
159 return NULL;
160 precvframe->u.hdr.rx_data += sz;
161 if (precvframe->u.hdr.rx_data > precvframe->u.hdr.rx_tail) {
162 precvframe->u.hdr.rx_data -= sz;
163 return NULL;
164 }
165 precvframe->u.hdr.len -= sz;
166 return precvframe->u.hdr.rx_data;
167}
168
169static inline u8 *recvframe_put(union recv_frame *precvframe, sint sz)
170{
171 /* used for append sz bytes from ptr to rx_tail, update rx_tail and
172 * return the updated rx_tail to the caller
bef611a9
RB
173 * after putting, rx_tail must be still larger than rx_end.
174 */
2865d42c
LF
175 if (precvframe == NULL)
176 return NULL;
2865d42c
LF
177 precvframe->u.hdr.rx_tail += sz;
178 if (precvframe->u.hdr.rx_tail > precvframe->u.hdr.rx_end) {
179 precvframe->u.hdr.rx_tail -= sz;
180 return NULL;
181 }
182 precvframe->u.hdr.len += sz;
183 return precvframe->u.hdr.rx_tail;
184}
185
186static inline u8 *recvframe_pull_tail(union recv_frame *precvframe, sint sz)
187{
188 /* rmv data from rx_tail (by yitsen)
189 * used for extract sz bytes from rx_end, update rx_end and return the
190 * updated rx_end to the caller
bef611a9
RB
191 * after pulling, rx_end must be still larger than rx_data.
192 */
2865d42c
LF
193 if (precvframe == NULL)
194 return NULL;
195 precvframe->u.hdr.rx_tail -= sz;
196 if (precvframe->u.hdr.rx_tail < precvframe->u.hdr.rx_data) {
197 precvframe->u.hdr.rx_tail += sz;
198 return NULL;
199 }
200 precvframe->u.hdr.len -= sz;
201 return precvframe->u.hdr.rx_tail;
202}
203
2865d42c
LF
204struct sta_info;
205
206void _r8712_init_sta_recv_priv(struct sta_recv_priv *psta_recvpriv);
207sint r8712_recvframe_chkmic(struct _adapter *adapter,
208 union recv_frame *precvframe);
209union recv_frame *r8712_decryptor(struct _adapter *adapter,
210 union recv_frame *precv_frame);
211union recv_frame *r8712_recvframe_chk_defrag(struct _adapter *adapter,
212 union recv_frame *precv_frame);
2865d42c
LF
213int r8712_validate_recv_frame(struct _adapter *adapter,
214 union recv_frame *precv_frame);
215union recv_frame *r8712_portctrl(struct _adapter *adapter,
216 union recv_frame *precv_frame);
2865d42c
LF
217
218#endif
219
This page took 0.492462 seconds and 5 git commands to generate.