Compare commits

...

5 Commits

Author SHA1 Message Date
Christian Bremvåg a3e0c0b6d5
Merge pull request #1122 from bwh-mind/rssi-notif
ioctl_cfg80211: Add support for standard RSSI notifications
2023-11-17 20:11:47 +01:00
Christian Bremvåg d07318ce9a
Merge pull request #1123 from bwh-mind/compat
Kernel compatibility fixes
2023-11-17 20:11:24 +01:00
Ben Hutchings b3f7e7a428 Fix eth_hw_addr_set() definition for compatibility with stable branches
eth_hw_addr_set() was added in Linux 5.15 but has now been backported
to 4.19.291, 5.4.251, and 5.10.188.  This currently results in build
failure for these stable branches.

There's no simple way to test for the addition of this function since
LINUX_VERSION_CODE limits version components to 255.

Work around this by defining an inline function rtw_eth_hw_addr_set()
and a macro eth_hw_addr_set().  This effectively shadows any
backported definition of the eth_hw_addr_set() function without any
conflict.

Signed-off-by: Ben Hutchings <ben.hutchings@mind.be>
2023-11-07 20:52:16 +01:00
Ben Hutchings 8b485b79be Make use of MODULE_IMPORT_NS conditional
Commit 8954f2b8d8 added an unconditional:

    MODULE_IMPORT_NS(VFS_internal_I_am_really_a_filesystem_and_am_NOT_a_driver);

For compatibility with old kernel versions, guard this declaration
with #ifdef MODULE_IMPORT_NS.

This specific symbol namespace is also Android-specific, so the
declaration should also be conditional on building for Android, but
there doesn't seem to be a single preprocessor symbol that indicates
that.

Signed-off-by: Ben Hutchings <ben.hutchings@mind.be>
2023-11-07 20:52:16 +01:00
Ben Hutchings 5b90ddb5cb 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>
2023-11-07 20:52:13 +01:00
5 changed files with 59 additions and 1 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 */
psta->sta_stats.rx_mgnt_pkts++;
#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) {

View File

@ -17,10 +17,11 @@
#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 15, 0))
/* Porting from linux kernel v5.15 48eab831ae8b9f7002a533fa4235eed63ea1f1a3 3f6cffb8604b537e3d7ea040d7f4368689638eaf*/
static inline void eth_hw_addr_set(struct net_device *dev, const u8 *addr)
static inline void rtw_eth_hw_addr_set(struct net_device *dev, const u8 *addr)
{
memcpy(dev->dev_addr, addr, ETH_ALEN);
}
#define eth_hw_addr_set rtw_eth_hw_addr_set
#endif
#endif

View File

@ -4476,6 +4476,47 @@ static int cfg80211_rtw_flush_pmksa(struct wiphy *wiphy,
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
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,
.del_pmksa = cfg80211_rtw_del_pmksa,
.flush_pmksa = cfg80211_rtw_flush_pmksa,
.set_cqm_rssi_config = cfg80211_rtw_set_cqm_rssi_config,
#ifdef RTW_VIRTUAL_INT
.add_virtual_intf = cfg80211_rtw_add_virtual_intf,

View File

@ -185,6 +185,11 @@ struct rtw_wdev_priv {
u16 pno_scan_seq_num;
#endif
/* Standard RSSI notification parameters */
s32 cqm_rssi_thold;
u32 cqm_rssi_hyst;
s32 cqm_rssi_last;
#ifdef CONFIG_RTW_CFGVEDNOR_RSSIMONITOR
s8 rssi_monitor_max;
s8 rssi_monitor_min;
@ -351,6 +356,8 @@ void rtw_cfg80211_init_rfkill(struct wiphy *wiphy);
void rtw_cfg80211_deinit_rfkill(struct wiphy *wiphy);
#endif
void rtw_cfg80211_cqm_rssi_update(_adapter *padapter, s32 rssi);
#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)
#elif (LINUX_VERSION_CODE < KERNEL_VERSION(3, 6, 0))

View File

@ -1640,7 +1640,9 @@ static void __exit rtw_drv_halt(void)
rtw_mstat_dump(RTW_DBGDUMP);
}
#ifdef MODULE_IMPORT_NS
MODULE_IMPORT_NS(VFS_internal_I_am_really_a_filesystem_and_am_NOT_a_driver);
#endif
module_init(rtw_drv_entry);
module_exit(rtw_drv_halt);