1 /******************************************************************************
3 * Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved.
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.
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
14 ******************************************************************************/
18 #include <osdep_service.h>
19 #include <drv_types.h>
22 #define NR_RECVFRAME 256
24 #define RXFRAME_ALIGN 8
25 #define RXFRAME_ALIGN_SZ (1<<RXFRAME_ALIGN)
27 #define MAX_RXFRAME_CNT 512
28 #define MAX_RX_NUMBLKS (32)
29 #define RECVFRAME_HDR_ALIGN 128
31 #define SNAP_SIZE sizeof(struct ieee80211_snap_hdr)
33 #define MAX_SUBFRAME_COUNT 64
35 /* for Rx reordering buffer control */
36 struct recv_reorder_ctrl {
37 struct adapter *padapter;
39 u16 indicate_seq;/* wstart_b, init_value=0xffff */
42 struct __queue pending_recvframe_queue;
43 struct timer_list reordering_ctrl_timer;
46 struct stainfo_rxcache {
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;
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 */
74 #define MAX_PATH_NUM_92CS 3
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. */
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 */
90 struct rx_pkt_attrib {
95 u8 hdrlen; /* the WLAN Header Len */
106 u8 privacy; /* in frame_ctrl field */
108 u8 encrypt; /* when 0 indicate no encrypt. when non-zero,
109 * indicate the encrypt algorithm */
131 u32 MacIDValidEntry[2]; /* 64 bits present 64 entry. */
133 struct phy_info phy_info;
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) */
142 #define RXDESC_SIZE 24
143 #define RXDESC_OFFSET RXDESC_SIZE
155 accesser of recv_priv: rtw_recv_entry(dispatch / passive level);
156 recv_thread(passive) ; returnpkt(dispatch)
159 using enter_critical section to protect
162 struct __queue free_recv_queue;
163 struct __queue recv_pending_queue;
164 struct __queue uc_swdec_pending_queue;
165 void *pallocated_frame_buf;
166 struct adapter *adapter;
173 struct tasklet_struct irq_prepare_beacon_tasklet;
174 struct tasklet_struct recv_tasklet;
175 struct sk_buff_head free_recv_skb_queue;
176 struct sk_buff_head rx_skb_queue;
177 struct recv_buf *precv_buf; /* 4 alignment */
178 struct __queue free_recv_buf_queue;
179 /* For display the phy information */
187 struct timer_list signal_stat_timer;
188 u32 signal_stat_sampling_interval;
189 struct signal_stat signal_qual_data;
190 struct signal_stat signal_strength_data;
193 #define rtw_set_signal_stat_timer(recvpriv) \
194 mod_timer(&(recvpriv)->signal_stat_timer, jiffies + \
195 msecs_to_jiffies((recvpriv)->signal_stat_sampling_interval))
197 struct sta_recv_priv {
200 struct __queue defrag_q; /* keeping the fragment frame until defrag */
201 struct stainfo_rxcache rxcache;
205 struct adapter *adapter;
207 struct sk_buff *pskb;
223 len = (unsigned int )(tail - data);
227 struct list_head list;
229 struct adapter *adapter;
230 struct rx_pkt_attrib attrib;
231 struct sta_info *psta;
232 /* for A-MPDU Rx reordering buffer control */
233 struct recv_reorder_ctrl *preorder_ctrl;
236 struct recv_frame *_rtw_alloc_recvframe(struct __queue *pfree_recv_queue);
237 struct recv_frame *rtw_alloc_recvframe(struct __queue *pfree_recv_queue);
238 void rtw_init_recvframe(struct recv_frame *precvframe,
239 struct recv_priv *precvpriv);
240 int rtw_free_recvframe(struct recv_frame *precvframe,
241 struct __queue *pfree_recv_queue);
242 #define rtw_dequeue_recvframe(queue) rtw_alloc_recvframe(queue)
243 int _rtw_enqueue_recvframe(struct recv_frame *precvframe,
244 struct __queue *queue);
245 int rtw_enqueue_recvframe(struct recv_frame *precvframe, struct __queue *queue);
246 void rtw_free_recvframe_queue(struct __queue *pframequeue,
247 struct __queue *pfree_recv_queue);
248 u32 rtw_free_uc_swdec_pending_queue(struct adapter *adapter);
250 void rtw_reordering_ctrl_timeout_handler(unsigned long data);
252 static inline s32 translate_percentage_to_dbm(u32 sig_stren_index)
254 s32 power; /* in dBm. */
256 /* Translate to dBm (x=0.5y-95). */
257 power = (s32)((sig_stren_index + 1) >> 1);
266 void _rtw_init_sta_recv_priv(struct sta_recv_priv *psta_recvpriv);
268 void mgt_dispatcher(struct adapter *padapter, struct recv_frame *precv_frame);