2022-06-08 23:46:35 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0
|
|
|
|
/* Copyright(c) 2007 - 2011 Realtek Corporation. */
|
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
#define _RTL8188E_REDESC_C_
|
|
|
|
|
2022-06-08 23:46:35 +00:00
|
|
|
#include "../include/osdep_service.h"
|
|
|
|
#include "../include/drv_types.h"
|
|
|
|
#include "../include/rtl8188e_hal.h"
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-13 16:35:48 +00:00
|
|
|
static void process_rssi(struct adapter *padapter, struct recv_frame *prframe)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
2014-12-13 16:35:48 +00:00
|
|
|
struct rx_pkt_attrib *pattrib = &prframe->attrib;
|
2013-08-09 03:23:49 +00:00
|
|
|
struct signal_stat *signal_stat = &padapter->recvpriv.signal_strength_data;
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2013-08-09 03:23:49 +00:00
|
|
|
if (signal_stat->update_req) {
|
|
|
|
signal_stat->total_num = 0;
|
|
|
|
signal_stat->total_val = 0;
|
|
|
|
signal_stat->update_req = 0;
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
2013-08-09 03:23:49 +00:00
|
|
|
signal_stat->total_num++;
|
|
|
|
signal_stat->total_val += pattrib->phy_info.SignalStrength;
|
|
|
|
signal_stat->avg_val = signal_stat->total_val / signal_stat->total_num;
|
|
|
|
} /* Process_UI_RSSI_8192C */
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-13 16:35:48 +00:00
|
|
|
static void process_link_qual(struct adapter *padapter, struct recv_frame *prframe)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
2013-05-19 04:28:07 +00:00
|
|
|
struct rx_pkt_attrib *pattrib;
|
2013-08-09 03:23:49 +00:00
|
|
|
struct signal_stat *signal_stat;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2022-06-08 23:46:35 +00:00
|
|
|
if (!prframe || !padapter)
|
2013-05-08 21:45:39 +00:00
|
|
|
return;
|
|
|
|
|
2014-12-13 16:35:48 +00:00
|
|
|
pattrib = &prframe->attrib;
|
2013-05-08 21:45:39 +00:00
|
|
|
signal_stat = &padapter->recvpriv.signal_qual_data;
|
|
|
|
|
2013-05-09 04:04:25 +00:00
|
|
|
if (signal_stat->update_req) {
|
2013-05-08 21:45:39 +00:00
|
|
|
signal_stat->total_num = 0;
|
|
|
|
signal_stat->total_val = 0;
|
|
|
|
signal_stat->update_req = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
signal_stat->total_num++;
|
|
|
|
signal_stat->total_val += pattrib->phy_info.SignalQuality;
|
|
|
|
signal_stat->avg_val = signal_stat->total_val / signal_stat->total_num;
|
|
|
|
}
|
|
|
|
|
2022-06-08 23:46:35 +00:00
|
|
|
static void rtl8188e_process_phy_info(struct adapter *padapter, void *prframe)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
2014-12-13 16:35:48 +00:00
|
|
|
struct recv_frame *precvframe = (struct recv_frame *)prframe;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2013-07-10 18:25:07 +00:00
|
|
|
/* Check RSSI */
|
2013-05-08 21:45:39 +00:00
|
|
|
process_rssi(padapter, precvframe);
|
2013-07-10 18:25:07 +00:00
|
|
|
/* Check EVM */
|
2013-05-08 21:45:39 +00:00
|
|
|
process_link_qual(padapter, precvframe);
|
|
|
|
}
|
|
|
|
|
2014-12-13 16:35:48 +00:00
|
|
|
void update_recvframe_attrib_88e(struct recv_frame *precvframe, struct recv_stat *prxstat)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
2022-06-08 23:46:35 +00:00
|
|
|
struct rx_pkt_attrib *pattrib = &precvframe->attrib;
|
2014-12-13 04:43:35 +00:00
|
|
|
memset(pattrib, 0, sizeof(struct rx_pkt_attrib));
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2022-06-08 23:46:35 +00:00
|
|
|
pattrib->crc_err = (le32_to_cpu(prxstat->rxdw0) >> 14) & 0x1;
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2022-06-08 23:46:35 +00:00
|
|
|
pattrib->pkt_rpt_type = (le32_to_cpu(prxstat->rxdw3) >> 14) & 0x3;
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2022-06-08 23:46:35 +00:00
|
|
|
if (pattrib->pkt_rpt_type == NORMAL_RX) {
|
|
|
|
pattrib->pkt_len = le32_to_cpu(prxstat->rxdw0) & 0x00003fff;
|
|
|
|
pattrib->drvinfo_sz = ((le32_to_cpu(prxstat->rxdw0) >> 16) & 0xf) * 8;
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2022-06-08 23:46:35 +00:00
|
|
|
pattrib->physt = (le32_to_cpu(prxstat->rxdw0) >> 26) & 0x1;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2022-06-08 23:46:35 +00:00
|
|
|
pattrib->bdecrypted = (le32_to_cpu(prxstat->rxdw0) & BIT(27)) ? 0 : 1;
|
|
|
|
pattrib->encrypt = (le32_to_cpu(prxstat->rxdw0) >> 20) & 0x7;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2022-06-08 23:46:35 +00:00
|
|
|
pattrib->qos = (le32_to_cpu(prxstat->rxdw0) >> 23) & 0x1;
|
|
|
|
pattrib->priority = (le32_to_cpu(prxstat->rxdw1) >> 8) & 0xf;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2022-06-08 23:46:35 +00:00
|
|
|
pattrib->amsdu = (le32_to_cpu(prxstat->rxdw1) >> 13) & 0x1;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2022-06-08 23:46:35 +00:00
|
|
|
pattrib->seq_num = le32_to_cpu(prxstat->rxdw2) & 0x00000fff;
|
|
|
|
pattrib->frag_num = (le32_to_cpu(prxstat->rxdw2) >> 12) & 0xf;
|
|
|
|
pattrib->mfrag = (le32_to_cpu(prxstat->rxdw1) >> 27) & 0x1;
|
|
|
|
pattrib->mdata = (le32_to_cpu(prxstat->rxdw1) >> 26) & 0x1;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2022-06-08 23:46:35 +00:00
|
|
|
pattrib->mcs_rate = le32_to_cpu(prxstat->rxdw3) & 0x3f;
|
|
|
|
pattrib->rxht = (le32_to_cpu(prxstat->rxdw3) >> 6) & 0x1;
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2022-06-08 23:46:35 +00:00
|
|
|
pattrib->icv_err = (le32_to_cpu(prxstat->rxdw0) >> 15) & 0x1;
|
|
|
|
pattrib->shift_sz = (le32_to_cpu(prxstat->rxdw0) >> 24) & 0x3;
|
2013-07-10 18:25:07 +00:00
|
|
|
} else if (pattrib->pkt_rpt_type == TX_REPORT1) { /* CCX */
|
2013-05-08 21:45:39 +00:00
|
|
|
pattrib->pkt_len = TX_RPT1_PKT_LEN;
|
2022-06-08 23:46:35 +00:00
|
|
|
} else if (pattrib->pkt_rpt_type == TX_REPORT2) {
|
|
|
|
pattrib->pkt_len = le32_to_cpu(prxstat->rxdw0) & 0x3FF;
|
|
|
|
|
|
|
|
pattrib->MacIDValidEntry[0] = le32_to_cpu(prxstat->rxdw4);
|
|
|
|
pattrib->MacIDValidEntry[1] = le32_to_cpu(prxstat->rxdw5);
|
|
|
|
|
|
|
|
} else if (pattrib->pkt_rpt_type == HIS_REPORT) {
|
|
|
|
pattrib->pkt_len = le32_to_cpu(prxstat->rxdw0) & 0x00003fff;
|
2013-05-19 04:28:07 +00:00
|
|
|
}
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Notice:
|
|
|
|
* Before calling this function,
|
2014-12-13 16:35:48 +00:00
|
|
|
* precvframe->rx_data should be ready!
|
2013-05-08 21:45:39 +00:00
|
|
|
*/
|
2014-12-13 16:35:48 +00:00
|
|
|
void update_recvframe_phyinfo_88e(struct recv_frame *precvframe, struct phy_stat *pphy_status)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
2014-12-13 16:35:48 +00:00
|
|
|
struct adapter *padapter = precvframe->adapter;
|
|
|
|
struct rx_pkt_attrib *pattrib = &precvframe->attrib;
|
2022-06-08 23:46:35 +00:00
|
|
|
struct hal_data_8188e *pHalData = &padapter->haldata;
|
|
|
|
struct phy_info *pPHYInfo = &pattrib->phy_info;
|
|
|
|
u8 *wlanhdr = precvframe->rx_data;
|
2013-07-26 16:20:42 +00:00
|
|
|
struct odm_per_pkt_info pkt_info;
|
2013-10-19 17:45:47 +00:00
|
|
|
u8 *sa = NULL;
|
2013-05-08 21:45:39 +00:00
|
|
|
struct sta_priv *pstapriv;
|
|
|
|
struct sta_info *psta;
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
pkt_info.bPacketMatchBSSID = ((!IsFrameTypeCtrl(wlanhdr)) &&
|
|
|
|
!pattrib->icv_err && !pattrib->crc_err &&
|
2014-12-13 15:38:17 +00:00
|
|
|
!memcmp(get_hdr_bssid(wlanhdr),
|
2013-08-09 03:23:49 +00:00
|
|
|
get_bssid(&padapter->mlmepriv), ETH_ALEN));
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2013-08-09 03:23:49 +00:00
|
|
|
pkt_info.bPacketToSelf = pkt_info.bPacketMatchBSSID &&
|
2014-12-13 15:38:17 +00:00
|
|
|
(!memcmp(get_da(wlanhdr),
|
2013-08-09 03:23:49 +00:00
|
|
|
myid(&padapter->eeprompriv), ETH_ALEN));
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2013-08-09 03:23:49 +00:00
|
|
|
pkt_info.bPacketBeacon = pkt_info.bPacketMatchBSSID &&
|
|
|
|
(GetFrameSubType(wlanhdr) == WIFI_BEACON);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2013-08-09 03:23:49 +00:00
|
|
|
if (pkt_info.bPacketBeacon) {
|
|
|
|
if (check_fwstate(&padapter->mlmepriv, WIFI_STATION_STATE))
|
2013-05-08 21:45:39 +00:00
|
|
|
sa = padapter->mlmepriv.cur_network.network.MacAddress;
|
2013-07-10 18:25:07 +00:00
|
|
|
/* to do Ad-hoc */
|
2013-08-09 03:23:49 +00:00
|
|
|
} else {
|
2013-05-08 21:45:39 +00:00
|
|
|
sa = get_sa(wlanhdr);
|
2013-05-19 04:28:07 +00:00
|
|
|
}
|
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
pstapriv = &padapter->stapriv;
|
|
|
|
pkt_info.StationID = 0xFF;
|
|
|
|
psta = rtw_get_stainfo(pstapriv, sa);
|
|
|
|
if (psta)
|
2013-05-19 04:28:07 +00:00
|
|
|
pkt_info.StationID = psta->mac_id;
|
|
|
|
pkt_info.Rate = pattrib->mcs_rate;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2013-12-31 03:18:17 +00:00
|
|
|
ODM_PhyStatusQuery(&pHalData->odmpriv, pPHYInfo, (u8 *)pphy_status, &(pkt_info), padapter);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-13 16:35:48 +00:00
|
|
|
precvframe->psta = NULL;
|
2013-05-08 21:45:39 +00:00
|
|
|
if (pkt_info.bPacketMatchBSSID &&
|
2013-08-09 03:23:49 +00:00
|
|
|
(check_fwstate(&padapter->mlmepriv, WIFI_AP_STATE))) {
|
|
|
|
if (psta) {
|
2014-12-13 16:35:48 +00:00
|
|
|
precvframe->psta = psta;
|
2013-05-08 21:45:39 +00:00
|
|
|
rtl8188e_process_phy_info(padapter, precvframe);
|
2013-05-19 04:28:07 +00:00
|
|
|
}
|
2013-08-09 03:23:49 +00:00
|
|
|
} else if (pkt_info.bPacketToSelf || pkt_info.bPacketBeacon) {
|
2022-06-08 23:46:35 +00:00
|
|
|
if (check_fwstate(&padapter->mlmepriv, WIFI_ADHOC_STATE | WIFI_ADHOC_MASTER_STATE)) {
|
2013-05-08 21:45:39 +00:00
|
|
|
if (psta)
|
2014-12-13 16:35:48 +00:00
|
|
|
precvframe->psta = psta;
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
2013-05-19 04:28:07 +00:00
|
|
|
rtl8188e_process_phy_info(padapter, precvframe);
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
}
|