|
| 1 | +/****************************************************************************** |
| 2 | + * |
| 3 | + * Copyright(c) 2007 - 2011 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 | + * You should have received a copy of the GNU General Public License along with |
| 15 | + * this program; if not, write to the Free Software Foundation, Inc., |
| 16 | + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA |
| 17 | + * |
| 18 | + * |
| 19 | + ******************************************************************************/ |
| 20 | +#define _RTL8188E_REDESC_C_ |
| 21 | + |
| 22 | +#include <osdep_service.h> |
| 23 | +#include <drv_types.h> |
| 24 | +#include <rtl8188e_hal.h> |
| 25 | + |
| 26 | +static void process_rssi(struct adapter *padapter, union recv_frame *prframe) |
| 27 | +{ |
| 28 | + struct rx_pkt_attrib *pattrib = &prframe->u.hdr.attrib; |
| 29 | + struct signal_stat *signal_stat = &padapter->recvpriv.signal_strength_data; |
| 30 | + |
| 31 | + if (signal_stat->update_req) { |
| 32 | + signal_stat->total_num = 0; |
| 33 | + signal_stat->total_val = 0; |
| 34 | + signal_stat->update_req = 0; |
| 35 | + } |
| 36 | + |
| 37 | + signal_stat->total_num++; |
| 38 | + signal_stat->total_val += pattrib->phy_info.SignalStrength; |
| 39 | + signal_stat->avg_val = signal_stat->total_val / signal_stat->total_num; |
| 40 | +} /* Process_UI_RSSI_8192C */ |
| 41 | + |
| 42 | +static void process_link_qual(struct adapter *padapter, union recv_frame *prframe) |
| 43 | +{ |
| 44 | + struct rx_pkt_attrib *pattrib; |
| 45 | + struct signal_stat *signal_stat; |
| 46 | + |
| 47 | + if (prframe == NULL || padapter == NULL) |
| 48 | + return; |
| 49 | + |
| 50 | + pattrib = &prframe->u.hdr.attrib; |
| 51 | + signal_stat = &padapter->recvpriv.signal_qual_data; |
| 52 | + |
| 53 | + if (signal_stat->update_req) { |
| 54 | + signal_stat->total_num = 0; |
| 55 | + signal_stat->total_val = 0; |
| 56 | + signal_stat->update_req = 0; |
| 57 | + } |
| 58 | + |
| 59 | + signal_stat->total_num++; |
| 60 | + signal_stat->total_val += pattrib->phy_info.SignalQuality; |
| 61 | + signal_stat->avg_val = signal_stat->total_val / signal_stat->total_num; |
| 62 | +} |
| 63 | + |
| 64 | +void rtl8188e_process_phy_info(struct adapter *padapter, void *prframe) |
| 65 | +{ |
| 66 | + union recv_frame *precvframe = (union recv_frame *)prframe; |
| 67 | + |
| 68 | + /* Check RSSI */ |
| 69 | + process_rssi(padapter, precvframe); |
| 70 | + /* Check EVM */ |
| 71 | + process_link_qual(padapter, precvframe); |
| 72 | +} |
| 73 | + |
| 74 | +void update_recvframe_attrib_88e(union recv_frame *precvframe, struct recv_stat *prxstat) |
| 75 | +{ |
| 76 | + struct rx_pkt_attrib *pattrib; |
| 77 | + struct recv_stat report; |
| 78 | + |
| 79 | + report.rxdw0 = prxstat->rxdw0; |
| 80 | + report.rxdw1 = prxstat->rxdw1; |
| 81 | + report.rxdw2 = prxstat->rxdw2; |
| 82 | + report.rxdw3 = prxstat->rxdw3; |
| 83 | + report.rxdw4 = prxstat->rxdw4; |
| 84 | + report.rxdw5 = prxstat->rxdw5; |
| 85 | + |
| 86 | + pattrib = &precvframe->u.hdr.attrib; |
| 87 | + _rtw_memset(pattrib, 0, sizeof(struct rx_pkt_attrib)); |
| 88 | + |
| 89 | + pattrib->crc_err = (u8)((le32_to_cpu(report.rxdw0) >> 14) & 0x1);;/* u8)prxreport->crc32; */ |
| 90 | + |
| 91 | + /* update rx report to recv_frame attribute */ |
| 92 | + pattrib->pkt_rpt_type = (u8)((le32_to_cpu(report.rxdw3) >> 14) & 0x3);/* prxreport->rpt_sel; */ |
| 93 | + |
| 94 | + if (pattrib->pkt_rpt_type == NORMAL_RX) { /* Normal rx packet */ |
| 95 | + pattrib->pkt_len = (u16)(le32_to_cpu(report.rxdw0) & 0x00003fff);/* u16)prxreport->pktlen; */ |
| 96 | + pattrib->drvinfo_sz = (u8)((le32_to_cpu(report.rxdw0) >> 16) & 0xf) * 8;/* u8)(prxreport->drvinfosize << 3); */ |
| 97 | + |
| 98 | + pattrib->physt = (u8)((le32_to_cpu(report.rxdw0) >> 26) & 0x1);/* u8)prxreport->physt; */ |
| 99 | + |
| 100 | + pattrib->bdecrypted = (le32_to_cpu(report.rxdw0) & BIT(27)) ? 0 : 1;/* u8)(prxreport->swdec ? 0 : 1); */ |
| 101 | + pattrib->encrypt = (u8)((le32_to_cpu(report.rxdw0) >> 20) & 0x7);/* u8)prxreport->security; */ |
| 102 | + |
| 103 | + pattrib->qos = (u8)((le32_to_cpu(report.rxdw0) >> 23) & 0x1);/* u8)prxreport->qos; */ |
| 104 | + pattrib->priority = (u8)((le32_to_cpu(report.rxdw1) >> 8) & 0xf);/* u8)prxreport->tid; */ |
| 105 | + |
| 106 | + pattrib->amsdu = (u8)((le32_to_cpu(report.rxdw1) >> 13) & 0x1);/* u8)prxreport->amsdu; */ |
| 107 | + |
| 108 | + pattrib->seq_num = (u16)(le32_to_cpu(report.rxdw2) & 0x00000fff);/* u16)prxreport->seq; */ |
| 109 | + pattrib->frag_num = (u8)((le32_to_cpu(report.rxdw2) >> 12) & 0xf);/* u8)prxreport->frag; */ |
| 110 | + pattrib->mfrag = (u8)((le32_to_cpu(report.rxdw1) >> 27) & 0x1);/* u8)prxreport->mf; */ |
| 111 | + pattrib->mdata = (u8)((le32_to_cpu(report.rxdw1) >> 26) & 0x1);/* u8)prxreport->md; */ |
| 112 | + |
| 113 | + pattrib->mcs_rate = (u8)(le32_to_cpu(report.rxdw3) & 0x3f);/* u8)prxreport->rxmcs; */ |
| 114 | + pattrib->rxht = (u8)((le32_to_cpu(report.rxdw3) >> 6) & 0x1);/* u8)prxreport->rxht; */ |
| 115 | + |
| 116 | + pattrib->icv_err = (u8)((le32_to_cpu(report.rxdw0) >> 15) & 0x1);/* u8)prxreport->icverr; */ |
| 117 | + pattrib->shift_sz = (u8)((le32_to_cpu(report.rxdw0) >> 24) & 0x3); |
| 118 | + } else if (pattrib->pkt_rpt_type == TX_REPORT1) { /* CCX */ |
| 119 | + pattrib->pkt_len = TX_RPT1_PKT_LEN; |
| 120 | + pattrib->drvinfo_sz = 0; |
| 121 | + } else if (pattrib->pkt_rpt_type == TX_REPORT2) { /* TX RPT */ |
| 122 | + pattrib->pkt_len = (u16)(le32_to_cpu(report.rxdw0) & 0x3FF);/* Rx length[9:0] */ |
| 123 | + pattrib->drvinfo_sz = 0; |
| 124 | + |
| 125 | + /* */ |
| 126 | + /* Get TX report MAC ID valid. */ |
| 127 | + /* */ |
| 128 | + pattrib->MacIDValidEntry[0] = le32_to_cpu(report.rxdw4); |
| 129 | + pattrib->MacIDValidEntry[1] = le32_to_cpu(report.rxdw5); |
| 130 | + |
| 131 | + } else if (pattrib->pkt_rpt_type == HIS_REPORT) { /* USB HISR RPT */ |
| 132 | + pattrib->pkt_len = (u16)(le32_to_cpu(report.rxdw0) & 0x00003fff);/* u16)prxreport->pktlen; */ |
| 133 | + } |
| 134 | +} |
| 135 | + |
| 136 | +/* |
| 137 | + * Notice: |
| 138 | + * Before calling this function, |
| 139 | + * precvframe->u.hdr.rx_data should be ready! |
| 140 | + */ |
| 141 | +void update_recvframe_phyinfo_88e(union recv_frame *precvframe, struct phy_stat *pphy_status) |
| 142 | +{ |
| 143 | + struct adapter *padapter = precvframe->u.hdr.adapter; |
| 144 | + struct rx_pkt_attrib *pattrib = &precvframe->u.hdr.attrib; |
| 145 | + struct hal_data_8188e *pHalData = GET_HAL_DATA(padapter); |
| 146 | + struct odm_phy_status_info *pPHYInfo = (struct odm_phy_status_info *)(&pattrib->phy_info); |
| 147 | + u8 *wlanhdr; |
| 148 | + struct odm_per_pkt_info pkt_info; |
| 149 | + u8 *sa = NULL; |
| 150 | + struct sta_priv *pstapriv; |
| 151 | + struct sta_info *psta; |
| 152 | + |
| 153 | + pkt_info.bPacketMatchBSSID = false; |
| 154 | + pkt_info.bPacketToSelf = false; |
| 155 | + pkt_info.bPacketBeacon = false; |
| 156 | + |
| 157 | + wlanhdr = get_recvframe_data(precvframe); |
| 158 | + |
| 159 | + pkt_info.bPacketMatchBSSID = ((!IsFrameTypeCtrl(wlanhdr)) && |
| 160 | + !pattrib->icv_err && !pattrib->crc_err && |
| 161 | + _rtw_memcmp(get_hdr_bssid(wlanhdr), |
| 162 | + get_bssid(&padapter->mlmepriv), ETH_ALEN)); |
| 163 | + |
| 164 | + pkt_info.bPacketToSelf = pkt_info.bPacketMatchBSSID && |
| 165 | + (_rtw_memcmp(get_da(wlanhdr), |
| 166 | + myid(&padapter->eeprompriv), ETH_ALEN)); |
| 167 | + |
| 168 | + pkt_info.bPacketBeacon = pkt_info.bPacketMatchBSSID && |
| 169 | + (GetFrameSubType(wlanhdr) == WIFI_BEACON); |
| 170 | + |
| 171 | + if (pkt_info.bPacketBeacon) { |
| 172 | + if (check_fwstate(&padapter->mlmepriv, WIFI_STATION_STATE)) |
| 173 | + sa = padapter->mlmepriv.cur_network.network.MacAddress; |
| 174 | + /* to do Ad-hoc */ |
| 175 | + } else { |
| 176 | + sa = get_sa(wlanhdr); |
| 177 | + } |
| 178 | + |
| 179 | + pstapriv = &padapter->stapriv; |
| 180 | + pkt_info.StationID = 0xFF; |
| 181 | + psta = rtw_get_stainfo(pstapriv, sa); |
| 182 | + if (psta) |
| 183 | + pkt_info.StationID = psta->mac_id; |
| 184 | + pkt_info.Rate = pattrib->mcs_rate; |
| 185 | + |
| 186 | + ODM_PhyStatusQuery(&pHalData->odmpriv, pPHYInfo, (u8 *)pphy_status, &(pkt_info)); |
| 187 | + |
| 188 | + precvframe->u.hdr.psta = NULL; |
| 189 | + if (pkt_info.bPacketMatchBSSID && |
| 190 | + (check_fwstate(&padapter->mlmepriv, WIFI_AP_STATE))) { |
| 191 | + if (psta) { |
| 192 | + precvframe->u.hdr.psta = psta; |
| 193 | + rtl8188e_process_phy_info(padapter, precvframe); |
| 194 | + } |
| 195 | + } else if (pkt_info.bPacketToSelf || pkt_info.bPacketBeacon) { |
| 196 | + if (check_fwstate(&padapter->mlmepriv, WIFI_ADHOC_STATE|WIFI_ADHOC_MASTER_STATE)) { |
| 197 | + if (psta) |
| 198 | + precvframe->u.hdr.psta = psta; |
| 199 | + } |
| 200 | + rtl8188e_process_phy_info(padapter, precvframe); |
| 201 | + } |
| 202 | +} |
0 commit comments