staging: rtl8188eu: remove unused members from struct recv_priv
[linux-2.6-microblaze.git] / drivers / staging / rtl8188eu / include / rtw_recv.h
1 /******************************************************************************
2  *
3  * Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved.
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 #include <osdep_service.h>
19 #include <drv_types.h>
20
21
22 #define NR_RECVFRAME 256
23
24 #define RXFRAME_ALIGN   8
25 #define RXFRAME_ALIGN_SZ        (1<<RXFRAME_ALIGN)
26
27 #define MAX_RXFRAME_CNT 512
28 #define MAX_RX_NUMBLKS          (32)
29 #define RECVFRAME_HDR_ALIGN 128
30
31 #define SNAP_SIZE sizeof(struct ieee80211_snap_hdr)
32
33 #define MAX_SUBFRAME_COUNT      64
34
35 /* for Rx reordering buffer control */
36 struct recv_reorder_ctrl {
37         struct adapter  *padapter;
38         u8 enable;
39         u16 indicate_seq;/* wstart_b, init_value=0xffff */
40         u16 wend_b;
41         u8 wsize_b;
42         struct __queue pending_recvframe_queue;
43         struct timer_list reordering_ctrl_timer;
44 };
45
46 struct  stainfo_rxcache {
47         u16     tid_rxseq[16];
48 /*
49         unsigned short  tid0_rxseq;
50         unsigned short  tid1_rxseq;
51         unsigned short  tid2_rxseq;
52         unsigned short  tid3_rxseq;
53         unsigned short  tid4_rxseq;
54         unsigned short  tid5_rxseq;
55         unsigned short  tid6_rxseq;
56         unsigned short  tid7_rxseq;
57         unsigned short  tid8_rxseq;
58         unsigned short  tid9_rxseq;
59         unsigned short  tid10_rxseq;
60         unsigned short  tid11_rxseq;
61         unsigned short  tid12_rxseq;
62         unsigned short  tid13_rxseq;
63         unsigned short  tid14_rxseq;
64         unsigned short  tid15_rxseq;
65 */
66 };
67
68 struct signal_stat {
69         u8      update_req;             /* used to indicate */
70         u8      avg_val;                /* avg of valid elements */
71         u32     total_num;              /* num of valid elements */
72         u32     total_val;              /* sum of valid elements */
73 };
74 #define MAX_PATH_NUM_92CS               3
75 struct phy_info {
76         u8      RxPWDBAll;
77         u8      SignalQuality;   /*  in 0-100 index. */
78         u8      RxMIMOSignalQuality[MAX_PATH_NUM_92CS]; /* EVM */
79         u8      RxMIMOSignalStrength[MAX_PATH_NUM_92CS];/*  in 0~100 index */
80         s8      RxPower; /*  in dBm Translate from PWdB */
81 /*  Real power in dBm for this packet, no beautification and aggregation.
82  * Keep this raw info to be used for the other procedures. */
83         s8      recvpower;
84         u8      BTRxRSSIPercentage;
85         u8      SignalStrength; /*  in 0-100 index. */
86         u8      RxPwr[MAX_PATH_NUM_92CS];/* per-path's pwdb */
87         u8      RxSNR[MAX_PATH_NUM_92CS];/* per-path's SNR */
88 };
89
90 struct rx_pkt_attrib {
91         u16     pkt_len;
92         u8      physt;
93         u8      drvinfo_sz;
94         u8      shift_sz;
95         u8      hdrlen; /* the WLAN Header Len */
96         u8      to_fr_ds;
97         u8      amsdu;
98         u8      qos;
99         u8      priority;
100         u8      pw_save;
101         u8      mdata;
102         u16     seq_num;
103         u8      frag_num;
104         u8      mfrag;
105         u8      order;
106         u8      privacy; /* in frame_ctrl field */
107         u8      bdecrypted;
108         u8      encrypt; /* when 0 indicate no encrypt. when non-zero,
109                           * indicate the encrypt algorith */
110         u8      iv_len;
111         u8      icv_len;
112         u8      crc_err;
113         u8      icv_err;
114
115         u16 eth_type;
116
117         u8      dst[ETH_ALEN];
118         u8      src[ETH_ALEN];
119         u8      ta[ETH_ALEN];
120         u8      ra[ETH_ALEN];
121         u8      bssid[ETH_ALEN];
122
123         u8 ack_policy;
124
125         u8      key_index;
126
127         u8      mcs_rate;
128         u8      rxht;
129         u8      sgi;
130         u8      pkt_rpt_type;
131         u32     MacIDValidEntry[2];     /*  64 bits present 64 entry. */
132
133         struct phy_info phy_info;
134 };
135
136
137 /* These definition is used for Rx packet reordering. */
138 #define SN_LESS(a, b)           (((a - b) & 0x800) != 0)
139 #define SN_EQUAL(a, b)  (a == b)
140 #define REORDER_WAIT_TIME       (50) /*  (ms) */
141
142 #define RXDESC_SIZE     24
143 #define RXDESC_OFFSET RXDESC_SIZE
144
145 struct recv_stat {
146         __le32 rxdw0;
147         __le32 rxdw1;
148         __le32 rxdw2;
149         __le32 rxdw3;
150         __le32 rxdw4;
151         __le32 rxdw5;
152 };
153
154 #define EOR BIT(30)
155
156 /*
157 accesser of recv_priv: rtw_recv_entry(dispatch / passive level);
158 recv_thread(passive) ; returnpkt(dispatch)
159 ; halt(passive) ;
160
161 using enter_critical section to protect
162 */
163 struct recv_priv {
164         struct __queue free_recv_queue;
165         struct __queue recv_pending_queue;
166         struct __queue uc_swdec_pending_queue;
167         void *pallocated_frame_buf;
168         struct adapter  *adapter;
169         u32     bIsAnyNonBEPkts;
170         u64     rx_bytes;
171         u64     rx_pkts;
172         u64     rx_drop;
173         u64     last_rx_bytes;
174
175         struct tasklet_struct irq_prepare_beacon_tasklet;
176         struct tasklet_struct recv_tasklet;
177         struct sk_buff_head free_recv_skb_queue;
178         struct sk_buff_head rx_skb_queue;
179         struct recv_buf *precv_buf;    /*  4 alignment */
180         struct __queue free_recv_buf_queue;
181         /* For display the phy informatiom */
182         s8 rssi;
183         s8 rxpwdb;
184         u8 signal_strength;
185         u8 signal_qual;
186         u8 noise;
187         s8 RxRssi[2];
188
189         struct timer_list signal_stat_timer;
190         u32 signal_stat_sampling_interval;
191         struct signal_stat signal_qual_data;
192         struct signal_stat signal_strength_data;
193 };
194
195 #define rtw_set_signal_stat_timer(recvpriv)                     \
196         mod_timer(&(recvpriv)->signal_stat_timer, jiffies +     \
197                   msecs_to_jiffies((recvpriv)->signal_stat_sampling_interval))
198
199 struct sta_recv_priv {
200         spinlock_t lock;
201         int     option;
202         struct __queue defrag_q; /* keeping the fragment frame until defrag */
203         struct  stainfo_rxcache rxcache;
204 };
205
206 struct recv_buf {
207         struct adapter *adapter;
208         struct urb *purb;
209         struct sk_buff *pskb;
210         u8      reuse;
211 };
212
213 /*
214         head  ----->
215
216                 data  ----->
217
218                         payload
219
220                 tail  ----->
221
222
223         end   ----->
224
225         len = (unsigned int )(tail - data);
226
227 */
228 struct recv_frame {
229         struct list_head list;
230         struct sk_buff   *pkt;
231         struct adapter  *adapter;
232         struct rx_pkt_attrib attrib;
233         uint  len;
234         u8 *rx_head;
235         u8 *rx_data;
236         u8 *rx_tail;
237         u8 *rx_end;
238         struct sta_info *psta;
239         /* for A-MPDU Rx reordering buffer control */
240         struct recv_reorder_ctrl *preorder_ctrl;
241 };
242
243 struct recv_frame *_rtw_alloc_recvframe(struct __queue *pfree_recv_queue);
244 struct recv_frame *rtw_alloc_recvframe(struct __queue *pfree_recv_queue);
245 void rtw_init_recvframe(struct recv_frame *precvframe,
246                         struct recv_priv *precvpriv);
247 int  rtw_free_recvframe(struct recv_frame *precvframe,
248                         struct __queue *pfree_recv_queue);
249 #define rtw_dequeue_recvframe(queue) rtw_alloc_recvframe(queue)
250 int _rtw_enqueue_recvframe(struct recv_frame *precvframe,
251                            struct __queue *queue);
252 int rtw_enqueue_recvframe(struct recv_frame *precvframe, struct __queue *queue);
253 void rtw_free_recvframe_queue(struct __queue *pframequeue,
254                               struct __queue *pfree_recv_queue);
255 u32 rtw_free_uc_swdec_pending_queue(struct adapter *adapter);
256
257 void rtw_reordering_ctrl_timeout_handler(unsigned long data);
258
259 static inline u8 *get_rxmem(struct recv_frame *precvframe)
260 {
261         /* always return rx_head... */
262         if (precvframe == NULL)
263                 return NULL;
264         return precvframe->rx_head;
265 }
266
267 static inline u8 *recvframe_pull(struct recv_frame *precvframe, int sz)
268 {
269         /*  rx_data += sz; move rx_data sz bytes  hereafter */
270
271         /* used for extract sz bytes from rx_data, update rx_data and return
272          * the updated rx_data to the caller */
273
274         if (precvframe == NULL)
275                 return NULL;
276         precvframe->rx_data += sz;
277         if (precvframe->rx_data > precvframe->rx_tail) {
278                 precvframe->rx_data -= sz;
279                 return NULL;
280         }
281         precvframe->len -= sz;
282         return precvframe->rx_data;
283 }
284
285 static inline u8 *recvframe_put(struct recv_frame *precvframe, int sz)
286 {
287         /* used for append sz bytes from ptr to rx_tail, update rx_tail
288          * and return the updated rx_tail to the caller */
289         /* after putting, rx_tail must be still larger than rx_end. */
290
291         if (precvframe == NULL)
292                 return NULL;
293
294         precvframe->rx_tail += sz;
295
296         if (precvframe->rx_tail > precvframe->rx_end) {
297                 precvframe->rx_tail -= sz;
298                 return NULL;
299         }
300         precvframe->len += sz;
301         return precvframe->rx_tail;
302 }
303
304 static inline u8 *recvframe_pull_tail(struct recv_frame *precvframe, int sz)
305 {
306         /*  rmv data from rx_tail (by yitsen) */
307
308         /* used for extract sz bytes from rx_end, update rx_end and return
309          * the updated rx_end to the caller */
310         /* after pulling, rx_end must be still larger than rx_data. */
311
312         if (precvframe == NULL)
313                 return NULL;
314         precvframe->rx_tail -= sz;
315         if (precvframe->rx_tail < precvframe->rx_data) {
316                 precvframe->rx_tail += sz;
317                 return NULL;
318         }
319         precvframe->len -= sz;
320         return precvframe->rx_tail;
321 }
322
323 static inline s32 translate_percentage_to_dbm(u32 sig_stren_index)
324 {
325         s32     power; /*  in dBm. */
326
327         /*  Translate to dBm (x=0.5y-95). */
328         power = (s32)((sig_stren_index + 1) >> 1);
329         power -= 95;
330
331         return power;
332 }
333
334
335 struct sta_info;
336
337 void _rtw_init_sta_recv_priv(struct sta_recv_priv *psta_recvpriv);
338
339 void  mgt_dispatcher(struct adapter *padapter, struct recv_frame *precv_frame);
340
341 #endif