Larry Finger | 364e30e | 2014-03-28 21:37:41 -0500 | [diff] [blame] | 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> |
Larry Finger | c17416e | 2014-03-28 21:37:42 -0500 | [diff] [blame] | 20 | #include <Hal8723APhyCfg.h> |
Larry Finger | 364e30e | 2014-03-28 21:37:41 -0500 | [diff] [blame] | 21 | |
| 22 | #define NR_RECVFRAME 256 |
| 23 | |
| 24 | #define MAX_RXFRAME_CNT 512 |
| 25 | #define MAX_RX_NUMBLKS (32) |
| 26 | #define RECVFRAME_HDR_ALIGN 128 |
| 27 | |
| 28 | #define SNAP_SIZE sizeof(struct ieee80211_snap_hdr) |
| 29 | |
| 30 | #define MAX_SUBFRAME_COUNT 64 |
| 31 | |
| 32 | /* for Rx reordering buffer control */ |
| 33 | struct recv_reorder_ctrl { |
| 34 | struct rtw_adapter *padapter; |
| 35 | u8 enable; |
| 36 | u16 indicate_seq;/* wstart_b, init_value=0xffff */ |
| 37 | u16 wend_b; |
| 38 | u8 wsize_b; |
| 39 | struct rtw_queue pending_recvframe_queue; |
| 40 | struct timer_list reordering_ctrl_timer; |
| 41 | }; |
| 42 | |
| 43 | struct stainfo_rxcache { |
| 44 | u16 tid_rxseq[16]; |
| 45 | /* |
| 46 | unsigned short tid0_rxseq; |
| 47 | unsigned short tid1_rxseq; |
| 48 | unsigned short tid2_rxseq; |
| 49 | unsigned short tid3_rxseq; |
| 50 | unsigned short tid4_rxseq; |
| 51 | unsigned short tid5_rxseq; |
| 52 | unsigned short tid6_rxseq; |
| 53 | unsigned short tid7_rxseq; |
| 54 | unsigned short tid8_rxseq; |
| 55 | unsigned short tid9_rxseq; |
| 56 | unsigned short tid10_rxseq; |
| 57 | unsigned short tid11_rxseq; |
| 58 | unsigned short tid12_rxseq; |
| 59 | unsigned short tid13_rxseq; |
| 60 | unsigned short tid14_rxseq; |
| 61 | unsigned short tid15_rxseq; |
| 62 | */ |
| 63 | }; |
| 64 | |
| 65 | struct smooth_rssi_data { |
| 66 | u32 elements[100]; /* array to store values */ |
| 67 | u32 index; /* index to current array to store */ |
| 68 | u32 total_num; /* num of valid elements */ |
| 69 | u32 total_val; /* sum of valid elements */ |
| 70 | }; |
| 71 | |
| 72 | struct signal_stat { |
| 73 | u8 update_req; /* used to indicate */ |
| 74 | u8 avg_val; /* avg of valid elements */ |
| 75 | u32 total_num; /* num of valid elements */ |
| 76 | u32 total_val; /* sum of valid elements */ |
| 77 | }; |
| 78 | |
Larry Finger | 364e30e | 2014-03-28 21:37:41 -0500 | [diff] [blame] | 79 | struct phy_info { |
| 80 | u8 RxPWDBAll; |
| 81 | u8 SignalQuality; /* in 0-100 index. */ |
Larry Finger | c17416e | 2014-03-28 21:37:42 -0500 | [diff] [blame] | 82 | u8 RxMIMOSignalQuality[RF_PATH_MAX]; /* EVM */ |
| 83 | u8 RxMIMOSignalStrength[RF_PATH_MAX];/* 0~100 */ |
Larry Finger | 364e30e | 2014-03-28 21:37:41 -0500 | [diff] [blame] | 84 | s8 RxPower; /* in dBm Translate from PWdB */ |
| 85 | /* Real power in dBm for this packet, no beautification and aggregation. |
| 86 | * Keep this raw info to be used for the other procedures. |
| 87 | */ |
| 88 | s8 RecvSignalPower; |
| 89 | u8 BTRxRSSIPercentage; |
| 90 | u8 SignalStrength; /* in 0-100 index. */ |
Larry Finger | c17416e | 2014-03-28 21:37:42 -0500 | [diff] [blame] | 91 | u8 RxPwr[RF_PATH_MAX];/* per-path's pwdb */ |
| 92 | u8 RxSNR[RF_PATH_MAX];/* per-path's SNR */ |
Larry Finger | 364e30e | 2014-03-28 21:37:41 -0500 | [diff] [blame] | 93 | }; |
| 94 | |
| 95 | |
| 96 | struct rx_pkt_attrib { |
| 97 | u16 pkt_len; |
| 98 | u8 physt; |
| 99 | u8 drvinfo_sz; |
| 100 | u8 shift_sz; |
| 101 | u8 hdrlen; /* the WLAN Header Len */ |
Larry Finger | 364e30e | 2014-03-28 21:37:41 -0500 | [diff] [blame] | 102 | u8 amsdu; |
| 103 | u8 qos; |
| 104 | u8 priority; |
| 105 | u8 pw_save; |
| 106 | u8 mdata; |
| 107 | u16 seq_num; |
| 108 | u8 frag_num; |
| 109 | u8 mfrag; |
| 110 | u8 order; |
| 111 | u8 privacy; /* in frame_ctrl field */ |
| 112 | u8 bdecrypted; |
| 113 | /* when 0 indicate no encrypt. when non-zero, indicate the algorith */ |
Jes Sorensen | 9e3d6df | 2014-05-21 09:37:34 +0200 | [diff] [blame] | 114 | u32 encrypt; |
Larry Finger | 364e30e | 2014-03-28 21:37:41 -0500 | [diff] [blame] | 115 | u8 iv_len; |
| 116 | u8 icv_len; |
| 117 | u8 crc_err; |
| 118 | u8 icv_err; |
| 119 | |
| 120 | u16 eth_type; |
| 121 | |
| 122 | u8 dst[ETH_ALEN]; |
| 123 | u8 src[ETH_ALEN]; |
| 124 | u8 ta[ETH_ALEN]; |
| 125 | u8 ra[ETH_ALEN]; |
| 126 | u8 bssid[ETH_ALEN]; |
| 127 | |
| 128 | u8 ack_policy; |
| 129 | |
| 130 | u8 tcpchk_valid; /* 0: invalid, 1: valid */ |
| 131 | u8 ip_chkrpt; /* 0: incorrect, 1: correct */ |
| 132 | u8 tcp_chkrpt; /* 0: incorrect, 1: correct */ |
| 133 | u8 key_index; |
| 134 | |
| 135 | u8 mcs_rate; |
| 136 | u8 rxht; |
| 137 | u8 sgi; |
| 138 | u8 pkt_rpt_type; |
| 139 | u32 MacIDValidEntry[2]; /* 64 bits present 64 entry. */ |
| 140 | struct phy_info phy_info; |
| 141 | }; |
| 142 | |
| 143 | /* These definition is used for Rx packet reordering. */ |
| 144 | #define SN_LESS(a, b) (((a-b) & 0x800) != 0) |
| 145 | #define SN_EQUAL(a, b) (a == b) |
| 146 | #define REORDER_WAIT_TIME (50) /* (ms) */ |
| 147 | |
| 148 | #define RECVBUFF_ALIGN_SZ 8 |
| 149 | |
| 150 | #define RXDESC_SIZE 24 |
| 151 | #define RXDESC_OFFSET RXDESC_SIZE |
| 152 | |
| 153 | struct recv_stat { |
Larry Finger | caa90ab | 2014-04-26 18:55:14 +0200 | [diff] [blame] | 154 | __le32 rxdw0; |
| 155 | __le32 rxdw1; |
| 156 | __le32 rxdw2; |
| 157 | __le32 rxdw3; |
| 158 | __le32 rxdw4; |
| 159 | __le32 rxdw5; |
Larry Finger | 364e30e | 2014-03-28 21:37:41 -0500 | [diff] [blame] | 160 | }; |
| 161 | |
| 162 | /* accesser of recv_priv: rtw_recv_entry23a(dispatch / passive level); \ |
| 163 | * recv_thread(passive) ; returnpkt(dispatch) ; halt(passive) ; |
| 164 | * |
| 165 | * using enter_critical section to protect |
| 166 | */ |
| 167 | struct recv_priv { |
| 168 | spinlock_t lock; |
| 169 | |
| 170 | struct rtw_queue free_recv_queue; |
| 171 | struct rtw_queue recv_pending_queue; |
| 172 | struct rtw_queue uc_swdec_pending_queue; |
| 173 | |
Jes Sorensen | fd6d1c1 | 2014-05-09 15:03:55 +0200 | [diff] [blame] | 174 | int free_recvframe_cnt; |
Larry Finger | 364e30e | 2014-03-28 21:37:41 -0500 | [diff] [blame] | 175 | |
| 176 | struct rtw_adapter *adapter; |
| 177 | |
| 178 | u32 bIsAnyNonBEPkts; |
| 179 | u64 rx_bytes; |
| 180 | u64 rx_pkts; |
| 181 | u64 rx_drop; |
| 182 | u64 last_rx_bytes; |
| 183 | |
| 184 | uint rx_icv_err; |
| 185 | uint rx_largepacket_crcerr; |
| 186 | uint rx_smallpacket_crcerr; |
| 187 | uint rx_middlepacket_crcerr; |
| 188 | |
| 189 | /* u8 *pallocated_urb_buf; */ |
Larry Finger | 364e30e | 2014-03-28 21:37:41 -0500 | [diff] [blame] | 190 | u8 rx_pending_cnt; |
| 191 | |
| 192 | struct urb *int_in_urb; |
| 193 | |
| 194 | u8 *int_in_buf; |
| 195 | |
| 196 | struct tasklet_struct irq_prepare_beacon_tasklet; |
| 197 | struct tasklet_struct recv_tasklet; |
| 198 | struct sk_buff_head free_recv_skb_queue; |
| 199 | struct sk_buff_head rx_skb_queue; |
| 200 | u8 *precv_buf; |
Larry Finger | 364e30e | 2014-03-28 21:37:41 -0500 | [diff] [blame] | 201 | |
| 202 | /* For display the phy informatiom */ |
Larry Finger | 364e30e | 2014-03-28 21:37:41 -0500 | [diff] [blame] | 203 | s8 rxpwdb; |
| 204 | u8 signal_strength; |
| 205 | u8 signal_qual; |
| 206 | u8 noise; |
| 207 | int RxSNRdB[2]; |
| 208 | s8 RxRssi[2]; |
| 209 | int FalseAlmCnt_all; |
| 210 | |
| 211 | struct timer_list signal_stat_timer; |
| 212 | u32 signal_stat_sampling_interval; |
| 213 | /* u32 signal_stat_converging_constant; */ |
| 214 | struct signal_stat signal_qual_data; |
| 215 | struct signal_stat signal_strength_data; |
| 216 | }; |
| 217 | |
| 218 | #define rtw_set_signal_stat_timer(recvpriv) \ |
| 219 | mod_timer(&(recvpriv)->signal_stat_timer, jiffies + \ |
| 220 | msecs_to_jiffies((recvpriv)->signal_stat_sampling_interval)) |
| 221 | |
| 222 | struct sta_recv_priv { |
| 223 | spinlock_t lock; |
| 224 | int option; |
| 225 | |
| 226 | /* struct rtw_queue blk_strms[MAX_RX_NUMBLKS]; */ |
| 227 | struct rtw_queue defrag_q; /* keeping the fragment frame until defrag */ |
| 228 | |
| 229 | struct stainfo_rxcache rxcache; |
| 230 | |
| 231 | /* uint sta_rx_bytes; */ |
| 232 | /* uint sta_rx_pkts; */ |
| 233 | /* uint sta_rx_fail; */ |
| 234 | |
| 235 | }; |
| 236 | |
| 237 | |
| 238 | struct recv_buf { |
| 239 | struct list_head list; |
| 240 | |
| 241 | struct rtw_adapter *adapter; |
| 242 | |
| 243 | struct urb *purb; |
| 244 | struct sk_buff *pskb; |
| 245 | }; |
| 246 | |
| 247 | /* head -----> |
| 248 | * |
| 249 | * data -----> |
| 250 | * |
| 251 | * payload |
| 252 | * |
| 253 | * tail -----> |
| 254 | * |
| 255 | * end -----> |
| 256 | * |
| 257 | * len = (unsigned int )(tail - data); |
| 258 | * |
| 259 | */ |
| 260 | struct recv_frame { |
| 261 | struct list_head list; |
| 262 | struct sk_buff *pkt; |
| 263 | |
| 264 | struct rtw_adapter *adapter; |
| 265 | |
| 266 | struct rx_pkt_attrib attrib; |
| 267 | |
| 268 | struct sta_info *psta; |
| 269 | |
| 270 | /* for A-MPDU Rx reordering buffer control */ |
| 271 | struct recv_reorder_ctrl *preorder_ctrl; |
| 272 | }; |
| 273 | |
| 274 | /* get a free recv_frame from pfree_recv_queue */ |
| 275 | struct recv_frame *rtw_alloc_recvframe23a(struct rtw_queue *pfree_recv_queue); |
Jes Sorensen | c5779a0 | 2014-05-09 15:03:58 +0200 | [diff] [blame] | 276 | int rtw_free_recvframe23a(struct recv_frame *precvframe); |
Larry Finger | 364e30e | 2014-03-28 21:37:41 -0500 | [diff] [blame] | 277 | |
| 278 | int rtw_enqueue_recvframe23a(struct recv_frame *precvframe, struct rtw_queue *queue); |
| 279 | |
Larry Finger | 364e30e | 2014-03-28 21:37:41 -0500 | [diff] [blame] | 280 | u32 rtw_free_uc_swdec_pending_queue23a(struct rtw_adapter *adapter); |
| 281 | |
Larry Finger | 364e30e | 2014-03-28 21:37:41 -0500 | [diff] [blame] | 282 | struct recv_buf *rtw_dequeue_recvbuf23a(struct rtw_queue *queue); |
| 283 | |
| 284 | void rtw_reordering_ctrl_timeout_handler23a(unsigned long pcontext); |
| 285 | |
| 286 | static inline s32 translate_percentage_to_dbm(u32 SignalStrengthIndex) |
| 287 | { |
| 288 | s32 SignalPower; /* in dBm. */ |
| 289 | |
| 290 | /* Translate to dBm (x=0.5y-95). */ |
| 291 | SignalPower = (s32)((SignalStrengthIndex + 1) >> 1); |
| 292 | SignalPower -= 95; |
| 293 | |
| 294 | return SignalPower; |
| 295 | } |
| 296 | |
| 297 | |
| 298 | struct sta_info; |
| 299 | |
| 300 | void _rtw_init_sta_recv_priv23a(struct sta_recv_priv *psta_recvpriv); |
| 301 | |
| 302 | void mgt_dispatcher23a(struct rtw_adapter *padapter, |
| 303 | struct recv_frame *precv_frame); |
| 304 | |
| 305 | #endif |