1
2
3
4
5
6
7
8
9
10
11
12
13
14
15#define _RTL8188E_REDESC_C_
16
17#include <osdep_service.h>
18#include <drv_types.h>
19#include <rtl8188e_hal.h>
20
21static void process_rssi(struct adapter *padapter, struct recv_frame *prframe)
22{
23 struct rx_pkt_attrib *pattrib = &prframe->attrib;
24 struct signal_stat *signal_stat = &padapter->recvpriv.signal_strength_data;
25
26 if (signal_stat->update_req) {
27 signal_stat->total_num = 0;
28 signal_stat->total_val = 0;
29 signal_stat->update_req = 0;
30 }
31
32 signal_stat->total_num++;
33 signal_stat->total_val += pattrib->phy_info.SignalStrength;
34 signal_stat->avg_val = signal_stat->total_val / signal_stat->total_num;
35}
36
37static void process_link_qual(struct adapter *padapter,
38 struct recv_frame *prframe)
39{
40 struct rx_pkt_attrib *pattrib;
41 struct signal_stat *signal_stat;
42
43 if (!prframe || !padapter)
44 return;
45
46 pattrib = &prframe->attrib;
47 signal_stat = &padapter->recvpriv.signal_qual_data;
48
49 if (signal_stat->update_req) {
50 signal_stat->total_num = 0;
51 signal_stat->total_val = 0;
52 signal_stat->update_req = 0;
53 }
54
55 signal_stat->total_num++;
56 signal_stat->total_val += pattrib->phy_info.SignalQuality;
57 signal_stat->avg_val = signal_stat->total_val / signal_stat->total_num;
58}
59
60void rtl8188e_process_phy_info(struct adapter *padapter,
61 struct recv_frame *precvframe)
62{
63
64 process_rssi(padapter, precvframe);
65
66 process_link_qual(padapter, precvframe);
67}
68
69void update_recvframe_attrib_88e(struct recv_frame *precvframe,
70 struct recv_stat *prxstat)
71{
72 struct rx_pkt_attrib *pattrib;
73 struct recv_stat report;
74
75 report.rxdw0 = prxstat->rxdw0;
76 report.rxdw1 = prxstat->rxdw1;
77 report.rxdw2 = prxstat->rxdw2;
78 report.rxdw3 = prxstat->rxdw3;
79 report.rxdw4 = prxstat->rxdw4;
80 report.rxdw5 = prxstat->rxdw5;
81
82 pattrib = &precvframe->attrib;
83 memset(pattrib, 0, sizeof(struct rx_pkt_attrib));
84
85 pattrib->crc_err = (u8)((le32_to_cpu(report.rxdw0) >> 14) & 0x1);
86
87
88 pattrib->pkt_rpt_type = (u8)((le32_to_cpu(report.rxdw3) >> 14) & 0x3);
89
90 if (pattrib->pkt_rpt_type == NORMAL_RX) {
91 pattrib->pkt_len = (u16)(le32_to_cpu(report.rxdw0) & 0x00003fff);
92 pattrib->drvinfo_sz = (u8)((le32_to_cpu(report.rxdw0) >> 16) & 0xf) * 8;
93
94 pattrib->physt = (u8)((le32_to_cpu(report.rxdw0) >> 26) & 0x1);
95
96 pattrib->bdecrypted = (le32_to_cpu(report.rxdw0) & BIT(27)) ? 0 : 1;
97 pattrib->encrypt = (u8)((le32_to_cpu(report.rxdw0) >> 20) & 0x7);
98
99 pattrib->qos = (u8)((le32_to_cpu(report.rxdw0) >> 23) & 0x1);
100 pattrib->priority = (u8)((le32_to_cpu(report.rxdw1) >> 8) & 0xf);
101
102 pattrib->amsdu = (u8)((le32_to_cpu(report.rxdw1) >> 13) & 0x1);
103
104 pattrib->seq_num = (u16)(le32_to_cpu(report.rxdw2) & 0x00000fff);
105 pattrib->frag_num = (u8)((le32_to_cpu(report.rxdw2) >> 12) & 0xf);
106 pattrib->mfrag = (u8)((le32_to_cpu(report.rxdw1) >> 27) & 0x1);
107 pattrib->mdata = (u8)((le32_to_cpu(report.rxdw1) >> 26) & 0x1);
108
109 pattrib->mcs_rate = (u8)(le32_to_cpu(report.rxdw3) & 0x3f);
110 pattrib->rxht = (u8)((le32_to_cpu(report.rxdw3) >> 6) & 0x1);
111
112 pattrib->icv_err = (u8)((le32_to_cpu(report.rxdw0) >> 15) & 0x1);
113 pattrib->shift_sz = (u8)((le32_to_cpu(report.rxdw0) >> 24) & 0x3);
114 } else if (pattrib->pkt_rpt_type == TX_REPORT1) {
115 pattrib->pkt_len = TX_RPT1_PKT_LEN;
116 pattrib->drvinfo_sz = 0;
117 } else if (pattrib->pkt_rpt_type == TX_REPORT2) {
118 pattrib->pkt_len = (u16)(le32_to_cpu(report.rxdw0) & 0x3FF);
119 pattrib->drvinfo_sz = 0;
120
121
122
123
124 pattrib->MacIDValidEntry[0] = le32_to_cpu(report.rxdw4);
125 pattrib->MacIDValidEntry[1] = le32_to_cpu(report.rxdw5);
126
127 } else if (pattrib->pkt_rpt_type == HIS_REPORT) {
128 pattrib->pkt_len = (u16)(le32_to_cpu(report.rxdw0) & 0x00003fff);
129 }
130}
131
132
133
134
135
136
137void update_recvframe_phyinfo_88e(struct recv_frame *precvframe,
138 struct phy_stat *pphy_status)
139{
140 struct adapter *padapter = precvframe->adapter;
141 struct rx_pkt_attrib *pattrib = &precvframe->attrib;
142 struct odm_phy_status_info *pPHYInfo = (struct odm_phy_status_info *)(&pattrib->phy_info);
143 u8 *wlanhdr;
144 struct odm_per_pkt_info pkt_info;
145 u8 *sa = NULL;
146 struct sta_priv *pstapriv;
147 struct sta_info *psta;
148
149 pkt_info.bPacketMatchBSSID = false;
150 pkt_info.bPacketToSelf = false;
151 pkt_info.bPacketBeacon = false;
152
153 wlanhdr = precvframe->pkt->data;
154
155 pkt_info.bPacketMatchBSSID = ((!IsFrameTypeCtrl(wlanhdr)) &&
156 !pattrib->icv_err && !pattrib->crc_err &&
157 !memcmp(get_hdr_bssid(wlanhdr),
158 get_bssid(&padapter->mlmepriv), ETH_ALEN));
159
160 pkt_info.bPacketToSelf = pkt_info.bPacketMatchBSSID &&
161 (!memcmp(get_da(wlanhdr),
162 myid(&padapter->eeprompriv), ETH_ALEN));
163
164 pkt_info.bPacketBeacon = pkt_info.bPacketMatchBSSID &&
165 (GetFrameSubType(wlanhdr) == WIFI_BEACON);
166
167 if (pkt_info.bPacketBeacon) {
168 if (check_fwstate(&padapter->mlmepriv, WIFI_STATION_STATE))
169 sa = padapter->mlmepriv.cur_network.network.MacAddress;
170
171 } else {
172 sa = get_sa(wlanhdr);
173 }
174
175 pstapriv = &padapter->stapriv;
176 pkt_info.StationID = 0xFF;
177 psta = rtw_get_stainfo(pstapriv, sa);
178 if (psta)
179 pkt_info.StationID = psta->mac_id;
180 pkt_info.Rate = pattrib->mcs_rate;
181
182 ODM_PhyStatusQuery(&padapter->HalData->odmpriv, pPHYInfo,
183 (u8 *)pphy_status, &(pkt_info));
184
185 precvframe->psta = NULL;
186 if (pkt_info.bPacketMatchBSSID &&
187 (check_fwstate(&padapter->mlmepriv, WIFI_AP_STATE))) {
188 if (psta) {
189 precvframe->psta = psta;
190 rtl8188e_process_phy_info(padapter, precvframe);
191 }
192 } else if (pkt_info.bPacketToSelf || pkt_info.bPacketBeacon) {
193 if (check_fwstate(&padapter->mlmepriv, WIFI_ADHOC_STATE|WIFI_ADHOC_MASTER_STATE)) {
194 if (psta)
195 precvframe->psta = psta;
196 }
197 rtl8188e_process_phy_info(padapter, precvframe);
198 }
199}
200