1
0
mirror of https://github.com/aircrack-ng/rtl8812au.git synced 2024-11-22 05:14:35 +00:00

ioctl_cfg80211: Add support for standard RSSI notifications

Currently background scanning with wpa_supplicant does not work very
well because rtl8812au does not notify it about changes to RSSI.  To
fix this:

* Implement the cfg80211_ops::set_cqm_rssi_config operation to set the
  parameters for RSSI notifications.
* Add a rtw_cfg80211_cqm_rssi_update() function that calls
  cfg80211_cqm_rssi_notify() if the RSSI has changed significantly
  (based on those parameters).
* When connected in infrastructure mode, call
  rtw_cfg80211_cqm_rssi_update() after processing a beacon and
  updating the RSSI.

Signed-off-by: Ben Hutchings <ben.hutchings@mind.be>
This commit is contained in:
Ben Hutchings 2023-11-02 20:36:13 +01:00
parent 4a983e47da
commit 5b90ddb5cb
3 changed files with 55 additions and 0 deletions

View File

@ -1971,6 +1971,12 @@ unsigned int OnBeacon(_adapter *padapter, union recv_frame *precv_frame)
#if 0 /* move to validate_recv_mgnt_frame */ #if 0 /* move to validate_recv_mgnt_frame */
psta->sta_stats.rx_mgnt_pkts++; psta->sta_stats.rx_mgnt_pkts++;
#endif #endif
#if defined(CONFIG_IOCTL_CFG80211)
rtw_cfg80211_cqm_rssi_update(
padapter,
pmlmepriv->cur_network_scanned->network.Rssi);
#endif
} }
} else if ((pmlmeinfo->state & 0x03) == WIFI_FW_ADHOC_STATE) { } else if ((pmlmeinfo->state & 0x03) == WIFI_FW_ADHOC_STATE) {

View File

@ -4476,6 +4476,47 @@ static int cfg80211_rtw_flush_pmksa(struct wiphy *wiphy,
return 0; return 0;
} }
static int cfg80211_rtw_set_cqm_rssi_config(struct wiphy *wiphy,
struct net_device *ndev,
s32 rssi_thold, u32 rssi_hyst)
{
_adapter *padapter = (_adapter *)rtw_netdev_priv(ndev);
struct rtw_wdev_priv *priv = adapter_wdev_data(padapter);
priv->cqm_rssi_thold = rssi_thold;
priv->cqm_rssi_hyst = rssi_hyst;
priv->cqm_rssi_last = 0;
return 0;
}
void rtw_cfg80211_cqm_rssi_update(_adapter *padapter, s32 rssi)
{
struct rtw_wdev_priv *priv = adapter_wdev_data(padapter);
enum nl80211_cqm_rssi_threshold_event event;
if (priv->cqm_rssi_thold == 0)
return;
if (rssi < priv->cqm_rssi_thold &&
(priv->cqm_rssi_last == 0 ||
rssi < priv->cqm_rssi_last - priv->cqm_rssi_hyst))
event = NL80211_CQM_RSSI_THRESHOLD_EVENT_LOW;
else if (rssi > priv->cqm_rssi_thold &&
(priv->cqm_rssi_last == 0 ||
rssi > priv->cqm_rssi_last + priv->cqm_rssi_hyst))
event = NL80211_CQM_RSSI_THRESHOLD_EVENT_HIGH;
else
return;
priv->cqm_rssi_last = rssi;
cfg80211_cqm_rssi_notify(padapter->pnetdev, event,
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,11,0)
rssi,
#endif
GFP_ATOMIC);
}
#ifdef CONFIG_AP_MODE #ifdef CONFIG_AP_MODE
void rtw_cfg80211_indicate_sta_assoc(_adapter *padapter, u8 *pmgmt_frame, uint frame_len) void rtw_cfg80211_indicate_sta_assoc(_adapter *padapter, u8 *pmgmt_frame, uint frame_len)
{ {
@ -10157,6 +10198,7 @@ static struct cfg80211_ops rtw_cfg80211_ops = {
.set_pmksa = cfg80211_rtw_set_pmksa, .set_pmksa = cfg80211_rtw_set_pmksa,
.del_pmksa = cfg80211_rtw_del_pmksa, .del_pmksa = cfg80211_rtw_del_pmksa,
.flush_pmksa = cfg80211_rtw_flush_pmksa, .flush_pmksa = cfg80211_rtw_flush_pmksa,
.set_cqm_rssi_config = cfg80211_rtw_set_cqm_rssi_config,
#ifdef RTW_VIRTUAL_INT #ifdef RTW_VIRTUAL_INT
.add_virtual_intf = cfg80211_rtw_add_virtual_intf, .add_virtual_intf = cfg80211_rtw_add_virtual_intf,

View File

@ -185,6 +185,11 @@ struct rtw_wdev_priv {
u16 pno_scan_seq_num; u16 pno_scan_seq_num;
#endif #endif
/* Standard RSSI notification parameters */
s32 cqm_rssi_thold;
u32 cqm_rssi_hyst;
s32 cqm_rssi_last;
#ifdef CONFIG_RTW_CFGVEDNOR_RSSIMONITOR #ifdef CONFIG_RTW_CFGVEDNOR_RSSIMONITOR
s8 rssi_monitor_max; s8 rssi_monitor_max;
s8 rssi_monitor_min; s8 rssi_monitor_min;
@ -351,6 +356,8 @@ void rtw_cfg80211_init_rfkill(struct wiphy *wiphy);
void rtw_cfg80211_deinit_rfkill(struct wiphy *wiphy); void rtw_cfg80211_deinit_rfkill(struct wiphy *wiphy);
#endif #endif
void rtw_cfg80211_cqm_rssi_update(_adapter *padapter, s32 rssi);
#if (LINUX_VERSION_CODE < KERNEL_VERSION(3, 4, 0)) && !defined(COMPAT_KERNEL_RELEASE) #if (LINUX_VERSION_CODE < KERNEL_VERSION(3, 4, 0)) && !defined(COMPAT_KERNEL_RELEASE)
#define rtw_cfg80211_rx_mgmt(wdev, freq, sig_dbm, buf, len, gfp) cfg80211_rx_mgmt(wdev_to_ndev(wdev), freq, buf, len, gfp) #define rtw_cfg80211_rx_mgmt(wdev, freq, sig_dbm, buf, len, gfp) cfg80211_rx_mgmt(wdev_to_ndev(wdev), freq, buf, len, gfp)
#elif (LINUX_VERSION_CODE < KERNEL_VERSION(3, 6, 0)) #elif (LINUX_VERSION_CODE < KERNEL_VERSION(3, 6, 0))