Skip to content

Commit

Permalink
Begin of backporting rfmetrics patches from older v5.6.4.2
Browse files Browse the repository at this point in the history
WORK IN PROGRESS
- adding debug printk in phydm_phystatus.c
- updating radio tap headers to add more metrics for each RF path
  • Loading branch information
Romary Sonrier committed Sep 28, 2023
1 parent 51f2c80 commit d8c9aac
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 38 deletions.
56 changes: 43 additions & 13 deletions core/rtw_recv.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
#include <drv_types.h>
#include <hal_data.h>

#define RFMETRICS 1

#if defined(PLATFORM_LINUX) && defined (PLATFORM_WINDOWS)

#error "Shall be Linux or Windows, but not both!\n"
Expand Down Expand Up @@ -3684,6 +3686,10 @@ static sint fill_radiotap_hdr(_adapter *padapter, union recv_frame *precvframe)
if(pHalData->NumTotalRFPath>1) {
tmp_32bit = (1<<IEEE80211_RADIOTAP_ANTENNA) |
(1<<IEEE80211_RADIOTAP_DBM_ANTSIGNAL) |
#if RFMETRICS
(1<<IEEE80211_RADIOTAP_DBM_ANTNOISE) |
(1<<IEEE80211_RADIOTAP_LOCK_QUALITY) |
#endif
(1<<IEEE80211_RADIOTAP_EXT) |
(1<<IEEE80211_RADIOTAP_RADIOTAP_NAMESPACE);
for(i=0; i<pHalData->NumTotalRFPath-1; i++) {
Expand All @@ -3692,7 +3698,13 @@ static sint fill_radiotap_hdr(_adapter *padapter, union recv_frame *precvframe)
}
}
tmp_32bit = (1<<IEEE80211_RADIOTAP_ANTENNA) |
(1<<IEEE80211_RADIOTAP_DBM_ANTSIGNAL);
(1<<IEEE80211_RADIOTAP_DBM_ANTSIGNAL)
#if RFMETRICS
|
(1<<IEEE80211_RADIOTAP_DBM_ANTNOISE)|
(1<<IEEE80211_RADIOTAP_LOCK_QUALITY)
#endif
;
#ifdef CONFIG_RADIOTAP_WITH_RXDESC
tmp_32bit |= (1 << IEEE80211_RADIOTAP_VENDOR_NAMESPACE);
#endif
Expand Down Expand Up @@ -3791,36 +3803,40 @@ static sint fill_radiotap_hdr(_adapter *padapter, union recv_frame *precvframe)
hdr_buf[rt_len] = pattrib->phy_info.recv_signal_power;
rt_len += 1;

#if 0
/* dBm Antenna Noise */
rtap_hdr->it_present |= (1 << IEEE80211_RADIOTAP_DBM_ANTNOISE);
hdr_buf[rt_len] = 0;
rt_len += 1;
#if RFMETRICS
/* dBm Antenna Noise */
rtap_hdr->it_present |= (1 << IEEE80211_RADIOTAP_DBM_ANTNOISE);
hdr_buf[rt_len] = pattrib->phy_info.recv_signal_power - pattrib->phy_info.rx_snr[0]; //UGLY : TDB AVG/MAX of SNR
rt_len += 1;
#else
rt_len++; // alignment
#endif

rt_len++; // alignment

}

/* Signal Quality */
rtap_hdr->it_present |= (1 << IEEE80211_RADIOTAP_LOCK_QUALITY);
tmp_16bit = cpu_to_le16(pattrib->phy_info.signal_quality);
memcpy(&hdr_buf[rt_len], &tmp_16bit, 2);
rt_len += 2;
#if 0
#if RFMETRICS

/* Antenna */
rtap_hdr->it_present |= (1 << IEEE80211_RADIOTAP_ANTENNA);
hdr_buf[rt_len] = pHalData->rf_type;
hdr_buf[rt_len] = pattrib->phy_info.rx_count;
rt_len += 1;

rt_len++; // alignment
#endif
/* RX flags */
rtap_hdr->it_present |= (1 << IEEE80211_RADIOTAP_RX_FLAGS);
#if 0
tmp_16bit = cpu_to_le16(0);
memcpy(ptr, &tmp_16bit, 1);
#endif
#if RFMETRICS
tmp_16bit = pHalData->NumTotalRFPath;
memcpy(&hdr_buf[rt_len], &tmp_16bit, 2);
rt_len += 2;
//printk(KERN_ERR "NumTotalRFPath: %d\n", pHalData->NumTotalRFPath);
#endif

/* MCS information */
if (pattrib->data_rate >= 12 && pattrib->data_rate < 44) {
Expand Down Expand Up @@ -3921,8 +3937,22 @@ static sint fill_radiotap_hdr(_adapter *padapter, union recv_frame *precvframe)

if (pattrib->physt) {
for(i=0; i<pHalData->NumTotalRFPath; i++) {
// IEEE80211_RADIOTAP_DBM_ANTSIGNAL
hdr_buf[rt_len] = pattrib->phy_info.rx_pwr[i];
rt_len ++;
#if RFMETRICS
// IEEE80211_RADIOTAP_DBM_ANTNOISE
hdr_buf[rt_len] = pattrib->phy_info.rx_pwr[i] - pattrib->phy_info.rx_snr[i];
rt_len ++;
// alignment for the following u16 short
rt_len ++; // alignment
// IEEE80211_RADIOTAP_LOCK_QUALITY
tmp_16bit = cpu_to_le16(pattrib->phy_info.rx_mimo_signal_quality[i]);
memcpy(&hdr_buf[rt_len], &tmp_16bit, 2);
rt_len += 2;
// IEEE80211_RADIOTAP_ANTENNA
// hdr_buf[rt_len] = pattrib->phy_info.ant_idx[i];
#endif
hdr_buf[rt_len] = i;
rt_len ++;
}
Expand Down
46 changes: 21 additions & 25 deletions hal/phydm/phydm_phystatus.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
#include "mp_precomp.h"
#include "phydm_precomp.h"

#define RFMETRICS_DBG 0

void
phydm_rx_statistic_cal(
struct PHY_DM_STRUCT *p_phydm,
Expand Down Expand Up @@ -1544,31 +1546,25 @@ phydm_rx_phy_status_jaguar_series_parsing(
phydm_avg_phystatus_index(p_dm, p_phy_info, p_pktinfo);
phydm_rx_statistic_cal(p_dm, p_phy_status, p_pktinfo);
}
/*PHYDM_DBG(p_dm, DBG_ANT_DIV, ("StaID[%d]: antidx_anta = ((%d)), MatchBSSID = ((%d))\n", p_pktinfo->station_id, p_phy_sta_rpt->antidx_anta, p_pktinfo->is_packet_match_bssid));*/


/* dbg_print("p_phy_sta_rpt->antidx_anta = %d, p_phy_sta_rpt->antidx_antb = %d\n",*/
/* p_phy_sta_rpt->antidx_anta, p_phy_sta_rpt->antidx_antb);*/
/* dbg_print("----------------------------\n");*/
/* dbg_print("p_pktinfo->station_id=%d, p_pktinfo->data_rate=0x%x\n",p_pktinfo->station_id, p_pktinfo->data_rate);*/
/* dbg_print("p_phy_sta_rpt->r_RFMOD = %d\n", p_phy_sta_rpt->r_RFMOD);*/
/* dbg_print("p_phy_sta_rpt->gain_trsw[0]=0x%x, p_phy_sta_rpt->gain_trsw[1]=0x%x\n",*/
/* p_phy_sta_rpt->gain_trsw[0],p_phy_sta_rpt->gain_trsw[1]);*/
/* dbg_print("p_phy_sta_rpt->gain_trsw[2]=0x%x, p_phy_sta_rpt->gain_trsw[3]=0x%x\n",*/
/* p_phy_sta_rpt->gain_trsw_cd[0],p_phy_sta_rpt->gain_trsw_cd[1]);*/
/* dbg_print("p_phy_sta_rpt->pwdb_all = 0x%x, p_phy_info->rx_pwdb_all = %d\n", p_phy_sta_rpt->pwdb_all, p_phy_info->rx_pwdb_all);*/
/* dbg_print("p_phy_sta_rpt->cfotail[i] = 0x%x, p_phy_sta_rpt->CFO_tail[i] = 0x%x\n", p_phy_sta_rpt->cfotail[0], p_phy_sta_rpt->cfotail[1]);*/
/* dbg_print("p_phy_sta_rpt->rxevm[0] = %d, p_phy_sta_rpt->rxevm[1] = %d\n", p_phy_sta_rpt->rxevm[0], p_phy_sta_rpt->rxevm[1]);*/
/* dbg_print("p_phy_sta_rpt->rxevm[2] = %d, p_phy_sta_rpt->rxevm[3] = %d\n", p_phy_sta_rpt->rxevm_cd[0], p_phy_sta_rpt->rxevm_cd[1]);*/
/* dbg_print("p_phy_info->rx_mimo_signal_strength[0]=%d, p_phy_info->rx_mimo_signal_strength[1]=%d, rx_pwdb_all=%d\n",*/
/* p_phy_info->rx_mimo_signal_strength[0], p_phy_info->rx_mimo_signal_strength[1], p_phy_info->rx_pwdb_all);*/
/* dbg_print("p_phy_info->rx_mimo_signal_strength[2]=%d, p_phy_info->rx_mimo_signal_strength[3]=%d\n",*/
/* p_phy_info->rx_mimo_signal_strength[2], p_phy_info->rx_mimo_signal_strength[3]);*/
/* dbg_print("ppPhyInfo->rx_mimo_signal_quality[0]=%d, p_phy_info->rx_mimo_signal_quality[1]=%d\n",*/
/* p_phy_info->rx_mimo_signal_quality[0], p_phy_info->rx_mimo_signal_quality[1]);*/
/* dbg_print("ppPhyInfo->rx_mimo_signal_quality[2]=%d, p_phy_info->rx_mimo_signal_quality[3]=%d\n",*/
/* p_phy_info->rx_mimo_signal_quality[2], p_phy_info->rx_mimo_signal_quality[3]);*/

#if RFMETRICS_DBG
PHYDM_DBG(p_dm, DBG_ANT_DIV, ("StaID[%d]: antidx_anta = ((%d)), MatchBSSID = ((%d))\n", p_pktinfo->station_id, p_phy_sta_rpt->antidx_anta, p_pktinfo->is_packet_match_bssid));


dbg_print("p_phy_sta_rpt->antidx_anta = %d, p_phy_sta_rpt->antidx_antb = %d\n", p_phy_sta_rpt->antidx_anta, p_phy_sta_rpt->antidx_antb);
dbg_print("----------------------------\n");
dbg_print("p_pktinfo->station_id=%d, p_pktinfo->data_rate=0x%x\n",p_pktinfo->station_id, p_pktinfo->data_rate);
dbg_print("p_phy_sta_rpt->r_RFMOD = %d\n", p_phy_sta_rpt->r_RFMOD);
dbg_print("p_phy_sta_rpt->gain_trsw[0]=0x%x, p_phy_sta_rpt->gain_trsw[1]=0x%x\n", p_phy_sta_rpt->gain_trsw[0],p_phy_sta_rpt->gain_trsw[1]);
dbg_print("p_phy_sta_rpt->gain_trsw[2]=0x%x, p_phy_sta_rpt->gain_trsw[3]=0x%x\n", p_phy_sta_rpt->gain_trsw_cd[0],p_phy_sta_rpt->gain_trsw_cd[1]);
dbg_print("p_phy_sta_rpt->pwdb_all = 0x%x, p_phy_info->rx_pwdb_all = %d\n", p_phy_sta_rpt->pwdb_all, p_phy_info->rx_pwdb_all);
dbg_print("p_phy_sta_rpt->cfotail[i] = 0x%x, p_phy_sta_rpt->CFO_tail[i] = 0x%x\n", p_phy_sta_rpt->cfotail[0], p_phy_sta_rpt->cfotail[1]);
dbg_print("p_phy_sta_rpt->rxevm[0] = %d, p_phy_sta_rpt->rxevm[1] = %d\n", p_phy_sta_rpt->rxevm[0], p_phy_sta_rpt->rxevm[1]);
dbg_print("p_phy_sta_rpt->rxevm[2] = %d, p_phy_sta_rpt->rxevm[3] = %d\n", p_phy_sta_rpt->rxevm_cd[0], p_phy_sta_rpt->rxevm_cd[1]);
dbg_print("p_phy_info->rx_mimo_signal_strength[0]=%d, p_phy_info->rx_mimo_signal_strength[1]=%d, rx_pwdb_all=%d\n", p_phy_info->rx_mimo_signal_strength[0], p_phy_info->rx_mimo_signal_strength[1], p_phy_info->rx_pwdb_all);
dbg_print("p_phy_info->rx_mimo_signal_strength[2]=%d, p_phy_info->rx_mimo_signal_strength[3]=%d\n", p_phy_info->rx_mimo_signal_strength[2], p_phy_info->rx_mimo_signal_strength[3]);
dbg_print("ppPhyInfo->rx_mimo_signal_quality[0]=%d, p_phy_info->rx_mimo_signal_quality[1]=%d\n", p_phy_info->rx_mimo_signal_quality[0], p_phy_info->rx_mimo_signal_quality[1]);
dbg_print("ppPhyInfo->rx_mimo_signal_quality[2]=%d, p_phy_info->rx_mimo_signal_quality[3]=%d\n", p_phy_info->rx_mimo_signal_quality[2], p_phy_info->rx_mimo_signal_quality[3]);
#endif
}

#endif
Expand Down

0 comments on commit d8c9aac

Please sign in to comment.