forked from Minki/linux
More updates:
* many minstrel improvements, including removal of the old minstrel in favour of minstrel_ht * speed improvements on FQ * support for RX decapsulation (header conversion) offload * RTNL reduction: limit RTNL usage in the wireless stack mostly to where really needed (regulatory not yet) to reduce contention on it * various other small updates -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEH1e1rEeCd0AIMq6MB8qZga/fl8QFAmAR1hoACgkQB8qZga/f l8QPVRAAjbF502gkrM2+VjC31xNrSVtAXn5LIsTHUUee1Kwhhe7VHNqrSYtR+poQ jdtBaaszlnkbBqThvIqD6AvbJgUeFhDB9Jcyynhbaq3wPcDiu7IuJikBzkN2Mhyq bzKu46jFPG6l31ItCKF9mToujlmcJrJVoS5mWJEi3QIWc9B3dwPsznO57tCVznmU 95zkhs6tSwgk9ENpDoulXxvpsnlnIzo8f1z0Lr4h9TbzvwzTEA2+by0hmnBk/vZN wjBJXNVMlimp+lmgVms/gQfuGG6NHtmtatqsu+iKCRbO5AjOlvvql2pjkf5yNZXP GD2LkOcM3DiNP1Mf3pP31du1cFBo7nq+P1/ChekmY1A6/xV3GXFsKofGDCSONu1n E5+X+6MFt1gGHAwh8yxmg2HUjpuq6fApnx656HqlYluXqeCRR0hcv0iJ3j9ApAVJ Qwn6cP1rjCXXHsbOdGQi/Vx0xmUjEzNw3+j9x5nC5+zM82joRKxFMqZA8revxRUj gjkiu6EC4ZWWBzTXY9+qITSgEO8b1y7emBgdKSAQplWDAQnaa8nPGBdQ7QmwPdpV vOSZ6Dd4dMKh8Qk7FWPHxYZJKoDz+i0a8g1m9CogC3TO8hNLRt6D37ffTdoOag2m 648kFBBS4SghKAjH6P4Nf6cfAPHpX/afivnSTpRK691cZ+2pajc= =gIbl -----END PGP SIGNATURE----- Merge tag 'mac80211-next-for-net-next-2021-01-27' of git://git.kernel.org/pub/scm/linux/kernel/git/jberg/mac80211-next Johannes Berg says: ==================== More updates: * many minstrel improvements, including removal of the old minstrel in favour of minstrel_ht * speed improvements on FQ * support for RX decapsulation (header conversion) offload * RTNL reduction: limit RTNL usage in the wireless stack mostly to where really needed (regulatory not yet) to reduce contention on it * tag 'mac80211-next-for-net-next-2021-01-27' of git://git.kernel.org/pub/scm/linux/kernel/git/jberg/mac80211-next: (24 commits) mac80211: minstrel_ht: fix regression in the max_prob_rate fix virt_wifi: fix deadlock on RTNL cfg80211: avoid holding the RTNL when calling the driver cfg80211: change netdev registration/unregistration semantics mac80211: minstrel_ht: fix rounding error in throughput calculation mac80211: minstrel_ht: increase stats update interval mac80211: minstrel_ht: fix max probability rate selection mac80211: minstrel_ht: improve sample rate selection mac80211: minstrel_ht: improve ampdu length estimation mac80211: minstrel_ht: remove old ewma based rate average code mac80211: remove legacy minstrel rate control mac80211: minstrel_ht: add support for OFDM rates on non-HT clients mac80211: minstrel_ht: clean up CCK code mac80211: introduce aql_enable node in debugfs cfg80211: Add phyrate conversion support for extended MCS in 60GHz band cfg80211: add VHT rate entries for MCS-10 and MCS-11 mac80211: reduce peer HE MCS/NSS to own capabilities mac80211: remove NSS number of 160MHz if not support 160MHz for HE mac80211_hwsim: add 6GHz channels mac80211: add LDPC encoding to ieee80211_parse_tx_radiotap ... ==================== Link: https://lore.kernel.org/r/20210127210915.135550-1-johannes@sipsolutions.net Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
commit
5998dd0217
@ -247,7 +247,9 @@ int ath11k_regd_update(struct ath11k *ar, bool init)
|
||||
}
|
||||
|
||||
rtnl_lock();
|
||||
ret = regulatory_set_wiphy_regd_sync_rtnl(ar->hw->wiphy, regd_copy);
|
||||
wiphy_lock(ar->hw->wiphy);
|
||||
ret = regulatory_set_wiphy_regd_sync(ar->hw->wiphy, regd_copy);
|
||||
wiphy_unlock(ar->hw->wiphy);
|
||||
rtnl_unlock();
|
||||
|
||||
kfree(regd_copy);
|
||||
|
@ -3648,7 +3648,7 @@ void ath6kl_cfg80211_vif_cleanup(struct ath6kl_vif *vif)
|
||||
kfree(mc_filter);
|
||||
}
|
||||
|
||||
unregister_netdevice(vif->ndev);
|
||||
cfg80211_unregister_netdevice(vif->ndev);
|
||||
|
||||
ar->num_vif--;
|
||||
}
|
||||
@ -3821,7 +3821,7 @@ struct wireless_dev *ath6kl_interface_add(struct ath6kl *ar, const char *name,
|
||||
|
||||
netdev_set_default_ethtool_ops(ndev, &ath6kl_ethtool_ops);
|
||||
|
||||
if (register_netdevice(ndev))
|
||||
if (cfg80211_register_netdevice(ndev))
|
||||
goto err;
|
||||
|
||||
ar->avail_idx_map &= ~BIT(fw_vif_idx);
|
||||
|
@ -212,11 +212,13 @@ int ath6kl_core_init(struct ath6kl *ar, enum ath6kl_htc_type htc_type)
|
||||
ar->avail_idx_map |= BIT(i);
|
||||
|
||||
rtnl_lock();
|
||||
wiphy_lock(ar->wiphy);
|
||||
|
||||
/* Add an initial station interface */
|
||||
wdev = ath6kl_interface_add(ar, "wlan%d", NET_NAME_ENUM,
|
||||
NL80211_IFTYPE_STATION, 0, INFRA_NETWORK);
|
||||
|
||||
wiphy_unlock(ar->wiphy);
|
||||
rtnl_unlock();
|
||||
|
||||
if (!wdev) {
|
||||
|
@ -1904,7 +1904,9 @@ void ath6kl_stop_txrx(struct ath6kl *ar)
|
||||
spin_unlock_bh(&ar->list_lock);
|
||||
ath6kl_cfg80211_vif_stop(vif, test_bit(WMI_READY, &ar->flag));
|
||||
rtnl_lock();
|
||||
wiphy_lock(ar->wiphy);
|
||||
ath6kl_cfg80211_vif_cleanup(vif);
|
||||
wiphy_unlock(ar->wiphy);
|
||||
rtnl_unlock();
|
||||
spin_lock_bh(&ar->list_lock);
|
||||
}
|
||||
|
@ -2820,7 +2820,9 @@ void wil_p2p_wdev_free(struct wil6210_priv *wil)
|
||||
wil->radio_wdev = wil->main_ndev->ieee80211_ptr;
|
||||
mutex_unlock(&wil->vif_mutex);
|
||||
if (p2p_wdev) {
|
||||
wiphy_lock(wil->wiphy);
|
||||
cfg80211_unregister_wdev(p2p_wdev);
|
||||
wiphy_unlock(wil->wiphy);
|
||||
kfree(p2p_wdev);
|
||||
}
|
||||
}
|
||||
|
@ -424,7 +424,7 @@ int wil_vif_add(struct wil6210_priv *wil, struct wil6210_vif *vif)
|
||||
if (rc)
|
||||
return rc;
|
||||
}
|
||||
rc = register_netdevice(ndev);
|
||||
rc = cfg80211_register_netdevice(ndev);
|
||||
if (rc < 0) {
|
||||
dev_err(&ndev->dev, "Failed to register netdev: %d\n", rc);
|
||||
if (any_active && vif->mid != 0)
|
||||
@ -473,7 +473,9 @@ int wil_if_add(struct wil6210_priv *wil)
|
||||
wil_update_net_queues_bh(wil, vif, NULL, true);
|
||||
|
||||
rtnl_lock();
|
||||
wiphy_lock(wiphy);
|
||||
rc = wil_vif_add(wil, vif);
|
||||
wiphy_unlock(wiphy);
|
||||
rtnl_unlock();
|
||||
if (rc < 0)
|
||||
goto out_wiphy;
|
||||
@ -511,7 +513,7 @@ void wil_vif_remove(struct wil6210_priv *wil, u8 mid)
|
||||
/* during unregister_netdevice cfg80211_leave may perform operations
|
||||
* such as stop AP, disconnect, so we only clear the VIF afterwards
|
||||
*/
|
||||
unregister_netdevice(ndev);
|
||||
cfg80211_unregister_netdevice(ndev);
|
||||
|
||||
if (any_active && vif->mid != 0)
|
||||
wmi_port_delete(wil, vif->mid);
|
||||
@ -543,15 +545,18 @@ void wil_if_remove(struct wil6210_priv *wil)
|
||||
{
|
||||
struct net_device *ndev = wil->main_ndev;
|
||||
struct wireless_dev *wdev = ndev->ieee80211_ptr;
|
||||
struct wiphy *wiphy = wdev->wiphy;
|
||||
|
||||
wil_dbg_misc(wil, "if_remove\n");
|
||||
|
||||
rtnl_lock();
|
||||
wiphy_lock(wiphy);
|
||||
wil_vif_remove(wil, 0);
|
||||
wiphy_unlock(wiphy);
|
||||
rtnl_unlock();
|
||||
|
||||
netif_napi_del(&wil->napi_tx);
|
||||
netif_napi_del(&wil->napi_rx);
|
||||
|
||||
wiphy_unregister(wdev->wiphy);
|
||||
wiphy_unregister(wiphy);
|
||||
}
|
||||
|
@ -473,8 +473,10 @@ static void wil_pcie_remove(struct pci_dev *pdev)
|
||||
|
||||
wil6210_debugfs_remove(wil);
|
||||
rtnl_lock();
|
||||
wiphy_lock(wil->wiphy);
|
||||
wil_p2p_wdev_free(wil);
|
||||
wil_remove_all_additional_vifs(wil);
|
||||
wiphy_unlock(wil->wiphy);
|
||||
rtnl_unlock();
|
||||
wil_if_remove(wil);
|
||||
wil_if_pcie_disable(wil);
|
||||
|
@ -633,7 +633,7 @@ static const struct net_device_ops brcmf_netdev_ops_pri = {
|
||||
.ndo_set_rx_mode = brcmf_netdev_set_multicast_list
|
||||
};
|
||||
|
||||
int brcmf_net_attach(struct brcmf_if *ifp, bool rtnl_locked)
|
||||
int brcmf_net_attach(struct brcmf_if *ifp, bool locked)
|
||||
{
|
||||
struct brcmf_pub *drvr = ifp->drvr;
|
||||
struct net_device *ndev;
|
||||
@ -656,8 +656,8 @@ int brcmf_net_attach(struct brcmf_if *ifp, bool rtnl_locked)
|
||||
INIT_WORK(&ifp->multicast_work, _brcmf_set_multicast_list);
|
||||
INIT_WORK(&ifp->ndoffload_work, _brcmf_update_ndtable);
|
||||
|
||||
if (rtnl_locked)
|
||||
err = register_netdevice(ndev);
|
||||
if (locked)
|
||||
err = cfg80211_register_netdevice(ndev);
|
||||
else
|
||||
err = register_netdev(ndev);
|
||||
if (err != 0) {
|
||||
@ -677,11 +677,11 @@ fail:
|
||||
return -EBADE;
|
||||
}
|
||||
|
||||
void brcmf_net_detach(struct net_device *ndev, bool rtnl_locked)
|
||||
void brcmf_net_detach(struct net_device *ndev, bool locked)
|
||||
{
|
||||
if (ndev->reg_state == NETREG_REGISTERED) {
|
||||
if (rtnl_locked)
|
||||
unregister_netdevice(ndev);
|
||||
if (locked)
|
||||
cfg80211_unregister_netdevice(ndev);
|
||||
else
|
||||
unregister_netdev(ndev);
|
||||
} else {
|
||||
@ -758,7 +758,7 @@ int brcmf_net_mon_attach(struct brcmf_if *ifp)
|
||||
ndev = ifp->ndev;
|
||||
ndev->netdev_ops = &brcmf_netdev_ops_mon;
|
||||
|
||||
err = register_netdevice(ndev);
|
||||
err = cfg80211_register_netdevice(ndev);
|
||||
if (err)
|
||||
bphy_err(drvr, "Failed to register %s device\n", ndev->name);
|
||||
|
||||
@ -909,7 +909,7 @@ struct brcmf_if *brcmf_add_if(struct brcmf_pub *drvr, s32 bsscfgidx, s32 ifidx,
|
||||
}
|
||||
|
||||
static void brcmf_del_if(struct brcmf_pub *drvr, s32 bsscfgidx,
|
||||
bool rtnl_locked)
|
||||
bool locked)
|
||||
{
|
||||
struct brcmf_if *ifp;
|
||||
int ifidx;
|
||||
@ -938,7 +938,7 @@ static void brcmf_del_if(struct brcmf_pub *drvr, s32 bsscfgidx,
|
||||
cancel_work_sync(&ifp->multicast_work);
|
||||
cancel_work_sync(&ifp->ndoffload_work);
|
||||
}
|
||||
brcmf_net_detach(ifp->ndev, rtnl_locked);
|
||||
brcmf_net_detach(ifp->ndev, locked);
|
||||
} else {
|
||||
/* Only p2p device interfaces which get dynamically created
|
||||
* end up here. In this case the p2p module should be informed
|
||||
@ -947,7 +947,7 @@ static void brcmf_del_if(struct brcmf_pub *drvr, s32 bsscfgidx,
|
||||
* serious troublesome side effects. The p2p module will clean
|
||||
* up the ifp if needed.
|
||||
*/
|
||||
brcmf_p2p_ifp_removed(ifp, rtnl_locked);
|
||||
brcmf_p2p_ifp_removed(ifp, locked);
|
||||
kfree(ifp);
|
||||
}
|
||||
|
||||
@ -956,14 +956,14 @@ static void brcmf_del_if(struct brcmf_pub *drvr, s32 bsscfgidx,
|
||||
drvr->if2bss[ifidx] = BRCMF_BSSIDX_INVALID;
|
||||
}
|
||||
|
||||
void brcmf_remove_interface(struct brcmf_if *ifp, bool rtnl_locked)
|
||||
void brcmf_remove_interface(struct brcmf_if *ifp, bool locked)
|
||||
{
|
||||
if (!ifp || WARN_ON(ifp->drvr->iflist[ifp->bsscfgidx] != ifp))
|
||||
return;
|
||||
brcmf_dbg(TRACE, "Enter, bsscfgidx=%d, ifidx=%d\n", ifp->bsscfgidx,
|
||||
ifp->ifidx);
|
||||
brcmf_proto_del_if(ifp->drvr, ifp);
|
||||
brcmf_del_if(ifp->drvr, ifp->bsscfgidx, rtnl_locked);
|
||||
brcmf_del_if(ifp->drvr, ifp->bsscfgidx, locked);
|
||||
}
|
||||
|
||||
static int brcmf_psm_watchdog_notify(struct brcmf_if *ifp,
|
||||
|
@ -201,16 +201,16 @@ int brcmf_netdev_wait_pend8021x(struct brcmf_if *ifp);
|
||||
char *brcmf_ifname(struct brcmf_if *ifp);
|
||||
struct brcmf_if *brcmf_get_ifp(struct brcmf_pub *drvr, int ifidx);
|
||||
void brcmf_configure_arp_nd_offload(struct brcmf_if *ifp, bool enable);
|
||||
int brcmf_net_attach(struct brcmf_if *ifp, bool rtnl_locked);
|
||||
int brcmf_net_attach(struct brcmf_if *ifp, bool locked);
|
||||
struct brcmf_if *brcmf_add_if(struct brcmf_pub *drvr, s32 bsscfgidx, s32 ifidx,
|
||||
bool is_p2pdev, const char *name, u8 *mac_addr);
|
||||
void brcmf_remove_interface(struct brcmf_if *ifp, bool rtnl_locked);
|
||||
void brcmf_remove_interface(struct brcmf_if *ifp, bool locked);
|
||||
void brcmf_txflowblock_if(struct brcmf_if *ifp,
|
||||
enum brcmf_netif_stop_reason reason, bool state);
|
||||
void brcmf_txfinalize(struct brcmf_if *ifp, struct sk_buff *txp, bool success);
|
||||
void brcmf_netif_rx(struct brcmf_if *ifp, struct sk_buff *skb, bool inirq);
|
||||
void brcmf_netif_mon_rx(struct brcmf_if *ifp, struct sk_buff *skb);
|
||||
void brcmf_net_detach(struct net_device *ndev, bool rtnl_locked);
|
||||
void brcmf_net_detach(struct net_device *ndev, bool locked);
|
||||
int brcmf_net_mon_attach(struct brcmf_if *ifp);
|
||||
void brcmf_net_setcarrier(struct brcmf_if *ifp, bool on);
|
||||
int __init brcmf_core_init(void);
|
||||
|
@ -2430,7 +2430,7 @@ int brcmf_p2p_del_vif(struct wiphy *wiphy, struct wireless_dev *wdev)
|
||||
return err;
|
||||
}
|
||||
|
||||
void brcmf_p2p_ifp_removed(struct brcmf_if *ifp, bool rtnl_locked)
|
||||
void brcmf_p2p_ifp_removed(struct brcmf_if *ifp, bool locked)
|
||||
{
|
||||
struct brcmf_cfg80211_info *cfg;
|
||||
struct brcmf_cfg80211_vif *vif;
|
||||
@ -2439,11 +2439,15 @@ void brcmf_p2p_ifp_removed(struct brcmf_if *ifp, bool rtnl_locked)
|
||||
vif = ifp->vif;
|
||||
cfg = wdev_to_cfg(&vif->wdev);
|
||||
cfg->p2p.bss_idx[P2PAPI_BSSCFG_DEVICE].vif = NULL;
|
||||
if (!rtnl_locked)
|
||||
if (locked) {
|
||||
rtnl_lock();
|
||||
cfg80211_unregister_wdev(&vif->wdev);
|
||||
if (!rtnl_locked)
|
||||
wiphy_lock(cfg->wiphy);
|
||||
cfg80211_unregister_wdev(&vif->wdev);
|
||||
wiphy_unlock(cfg->wiphy);
|
||||
rtnl_unlock();
|
||||
} else {
|
||||
cfg80211_unregister_wdev(&vif->wdev);
|
||||
}
|
||||
brcmf_free_vif(vif);
|
||||
}
|
||||
|
||||
|
@ -2143,7 +2143,7 @@ err:
|
||||
|
||||
out_iterate:
|
||||
if (!test)
|
||||
ieee80211_iterate_active_interfaces_rtnl(mvm->hw,
|
||||
ieee80211_iterate_active_interfaces_mtx(mvm->hw,
|
||||
IEEE80211_IFACE_ITER_NORMAL,
|
||||
iwl_mvm_d3_disconnect_iter, keep ? vif : NULL);
|
||||
|
||||
|
@ -260,7 +260,7 @@ int iwl_mvm_init_fw_regd(struct iwl_mvm *mvm)
|
||||
int ret;
|
||||
bool changed;
|
||||
const struct ieee80211_regdomain *r =
|
||||
rtnl_dereference(mvm->hw->wiphy->regd);
|
||||
wiphy_dereference(mvm->hw->wiphy, mvm->hw->wiphy->regd);
|
||||
|
||||
if (!r)
|
||||
return -ENOENT;
|
||||
@ -282,7 +282,7 @@ int iwl_mvm_init_fw_regd(struct iwl_mvm *mvm)
|
||||
|
||||
/* update cfg80211 if the regdomain was changed */
|
||||
if (changed)
|
||||
ret = regulatory_set_wiphy_regd_sync_rtnl(mvm->hw->wiphy, regd);
|
||||
ret = regulatory_set_wiphy_regd_sync(mvm->hw->wiphy, regd);
|
||||
else
|
||||
ret = 0;
|
||||
|
||||
|
@ -545,7 +545,7 @@ int iwl_mvm_init_mcc(struct iwl_mvm *mvm)
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
retval = regulatory_set_wiphy_regd_sync_rtnl(mvm->hw->wiphy, regd);
|
||||
retval = regulatory_set_wiphy_regd_sync(mvm->hw->wiphy, regd);
|
||||
kfree(regd);
|
||||
return retval;
|
||||
}
|
||||
|
@ -311,6 +311,12 @@ static struct net_device *hwsim_mon; /* global monitor netdev */
|
||||
.hw_value = (_freq), \
|
||||
}
|
||||
|
||||
#define CHAN6G(_freq) { \
|
||||
.band = NL80211_BAND_6GHZ, \
|
||||
.center_freq = (_freq), \
|
||||
.hw_value = (_freq), \
|
||||
}
|
||||
|
||||
static const struct ieee80211_channel hwsim_channels_2ghz[] = {
|
||||
CHAN2G(2412), /* Channel 1 */
|
||||
CHAN2G(2417), /* Channel 2 */
|
||||
@ -377,6 +383,68 @@ static const struct ieee80211_channel hwsim_channels_5ghz[] = {
|
||||
CHAN5G(5925), /* Channel 185 */
|
||||
};
|
||||
|
||||
static const struct ieee80211_channel hwsim_channels_6ghz[] = {
|
||||
CHAN6G(5955), /* Channel 1 */
|
||||
CHAN6G(5975), /* Channel 5 */
|
||||
CHAN6G(5995), /* Channel 9 */
|
||||
CHAN6G(6015), /* Channel 13 */
|
||||
CHAN6G(6035), /* Channel 17 */
|
||||
CHAN6G(6055), /* Channel 21 */
|
||||
CHAN6G(6075), /* Channel 25 */
|
||||
CHAN6G(6095), /* Channel 29 */
|
||||
CHAN6G(6115), /* Channel 33 */
|
||||
CHAN6G(6135), /* Channel 37 */
|
||||
CHAN6G(6155), /* Channel 41 */
|
||||
CHAN6G(6175), /* Channel 45 */
|
||||
CHAN6G(6195), /* Channel 49 */
|
||||
CHAN6G(6215), /* Channel 53 */
|
||||
CHAN6G(6235), /* Channel 57 */
|
||||
CHAN6G(6255), /* Channel 61 */
|
||||
CHAN6G(6275), /* Channel 65 */
|
||||
CHAN6G(6295), /* Channel 69 */
|
||||
CHAN6G(6315), /* Channel 73 */
|
||||
CHAN6G(6335), /* Channel 77 */
|
||||
CHAN6G(6355), /* Channel 81 */
|
||||
CHAN6G(6375), /* Channel 85 */
|
||||
CHAN6G(6395), /* Channel 89 */
|
||||
CHAN6G(6415), /* Channel 93 */
|
||||
CHAN6G(6435), /* Channel 97 */
|
||||
CHAN6G(6455), /* Channel 181 */
|
||||
CHAN6G(6475), /* Channel 105 */
|
||||
CHAN6G(6495), /* Channel 109 */
|
||||
CHAN6G(6515), /* Channel 113 */
|
||||
CHAN6G(6535), /* Channel 117 */
|
||||
CHAN6G(6555), /* Channel 121 */
|
||||
CHAN6G(6575), /* Channel 125 */
|
||||
CHAN6G(6595), /* Channel 129 */
|
||||
CHAN6G(6615), /* Channel 133 */
|
||||
CHAN6G(6635), /* Channel 137 */
|
||||
CHAN6G(6655), /* Channel 141 */
|
||||
CHAN6G(6675), /* Channel 145 */
|
||||
CHAN6G(6695), /* Channel 149 */
|
||||
CHAN6G(6715), /* Channel 153 */
|
||||
CHAN6G(6735), /* Channel 157 */
|
||||
CHAN6G(6755), /* Channel 161 */
|
||||
CHAN6G(6775), /* Channel 165 */
|
||||
CHAN6G(6795), /* Channel 169 */
|
||||
CHAN6G(6815), /* Channel 173 */
|
||||
CHAN6G(6835), /* Channel 177 */
|
||||
CHAN6G(6855), /* Channel 181 */
|
||||
CHAN6G(6875), /* Channel 185 */
|
||||
CHAN6G(6895), /* Channel 189 */
|
||||
CHAN6G(6915), /* Channel 193 */
|
||||
CHAN6G(6935), /* Channel 197 */
|
||||
CHAN6G(6955), /* Channel 201 */
|
||||
CHAN6G(6975), /* Channel 205 */
|
||||
CHAN6G(6995), /* Channel 209 */
|
||||
CHAN6G(7015), /* Channel 213 */
|
||||
CHAN6G(7035), /* Channel 217 */
|
||||
CHAN6G(7055), /* Channel 221 */
|
||||
CHAN6G(7075), /* Channel 225 */
|
||||
CHAN6G(7095), /* Channel 229 */
|
||||
CHAN6G(7115), /* Channel 233 */
|
||||
};
|
||||
|
||||
#define NUM_S1G_CHANS_US 51
|
||||
static struct ieee80211_channel hwsim_channels_s1g[NUM_S1G_CHANS_US];
|
||||
|
||||
@ -548,6 +616,7 @@ struct mac80211_hwsim_data {
|
||||
struct ieee80211_supported_band bands[NUM_NL80211_BANDS];
|
||||
struct ieee80211_channel channels_2ghz[ARRAY_SIZE(hwsim_channels_2ghz)];
|
||||
struct ieee80211_channel channels_5ghz[ARRAY_SIZE(hwsim_channels_5ghz)];
|
||||
struct ieee80211_channel channels_6ghz[ARRAY_SIZE(hwsim_channels_6ghz)];
|
||||
struct ieee80211_channel channels_s1g[ARRAY_SIZE(hwsim_channels_s1g)];
|
||||
struct ieee80211_rate rates[ARRAY_SIZE(hwsim_rates)];
|
||||
struct ieee80211_iface_combination if_combination;
|
||||
@ -578,7 +647,8 @@ struct mac80211_hwsim_data {
|
||||
struct ieee80211_channel *channel;
|
||||
unsigned long next_start, start, end;
|
||||
} survey_data[ARRAY_SIZE(hwsim_channels_2ghz) +
|
||||
ARRAY_SIZE(hwsim_channels_5ghz)];
|
||||
ARRAY_SIZE(hwsim_channels_5ghz) +
|
||||
ARRAY_SIZE(hwsim_channels_6ghz)];
|
||||
|
||||
struct ieee80211_channel *channel;
|
||||
u64 beacon_int /* beacon interval in us */;
|
||||
@ -3149,6 +3219,8 @@ static int mac80211_hwsim_new_radio(struct genl_info *info,
|
||||
sizeof(hwsim_channels_2ghz));
|
||||
memcpy(data->channels_5ghz, hwsim_channels_5ghz,
|
||||
sizeof(hwsim_channels_5ghz));
|
||||
memcpy(data->channels_6ghz, hwsim_channels_6ghz,
|
||||
sizeof(hwsim_channels_6ghz));
|
||||
memcpy(data->channels_s1g, hwsim_channels_s1g,
|
||||
sizeof(hwsim_channels_s1g));
|
||||
memcpy(data->rates, hwsim_rates, sizeof(hwsim_rates));
|
||||
|
@ -2097,7 +2097,7 @@ mwifiex_cfg80211_disconnect(struct wiphy *wiphy, struct net_device *dev,
|
||||
struct mwifiex_private *priv = mwifiex_netdev_get_priv(dev);
|
||||
|
||||
if (!mwifiex_stop_bg_scan(priv))
|
||||
cfg80211_sched_scan_stopped_rtnl(priv->wdev.wiphy, 0);
|
||||
cfg80211_sched_scan_stopped_locked(priv->wdev.wiphy, 0);
|
||||
|
||||
if (mwifiex_deauthenticate(priv, NULL))
|
||||
return -EFAULT;
|
||||
@ -2366,7 +2366,7 @@ mwifiex_cfg80211_connect(struct wiphy *wiphy, struct net_device *dev,
|
||||
(int)sme->ssid_len, (char *)sme->ssid, sme->bssid);
|
||||
|
||||
if (!mwifiex_stop_bg_scan(priv))
|
||||
cfg80211_sched_scan_stopped_rtnl(priv->wdev.wiphy, 0);
|
||||
cfg80211_sched_scan_stopped_locked(priv->wdev.wiphy, 0);
|
||||
|
||||
ret = mwifiex_cfg80211_assoc(priv, sme->ssid_len, sme->ssid, sme->bssid,
|
||||
priv->bss_mode, sme->channel, sme, 0);
|
||||
@ -2576,7 +2576,7 @@ mwifiex_cfg80211_scan(struct wiphy *wiphy,
|
||||
priv->scan_block = false;
|
||||
|
||||
if (!mwifiex_stop_bg_scan(priv))
|
||||
cfg80211_sched_scan_stopped_rtnl(priv->wdev.wiphy, 0);
|
||||
cfg80211_sched_scan_stopped_locked(priv->wdev.wiphy, 0);
|
||||
|
||||
user_scan_cfg = kzalloc(sizeof(*user_scan_cfg), GFP_KERNEL);
|
||||
if (!user_scan_cfg)
|
||||
@ -3081,7 +3081,7 @@ struct wireless_dev *mwifiex_add_virtual_intf(struct wiphy *wiphy,
|
||||
mutex_init(&priv->async_mutex);
|
||||
|
||||
/* Register network device */
|
||||
if (register_netdevice(dev)) {
|
||||
if (cfg80211_register_netdevice(dev)) {
|
||||
mwifiex_dbg(adapter, ERROR, "cannot register network device\n");
|
||||
ret = -EFAULT;
|
||||
goto err_reg_netdev;
|
||||
@ -3160,7 +3160,7 @@ int mwifiex_del_virtual_intf(struct wiphy *wiphy, struct wireless_dev *wdev)
|
||||
netif_carrier_off(priv->netdev);
|
||||
|
||||
if (wdev->netdev->reg_state == NETREG_REGISTERED)
|
||||
unregister_netdevice(wdev->netdev);
|
||||
cfg80211_unregister_netdevice(wdev->netdev);
|
||||
|
||||
if (priv->dfs_cac_workqueue) {
|
||||
flush_workqueue(priv->dfs_cac_workqueue);
|
||||
|
@ -598,12 +598,14 @@ static int _mwifiex_fw_dpc(const struct firmware *firmware, void *context)
|
||||
}
|
||||
|
||||
rtnl_lock();
|
||||
wiphy_lock(adapter->wiphy);
|
||||
/* Create station interface by default */
|
||||
wdev = mwifiex_add_virtual_intf(adapter->wiphy, "mlan%d", NET_NAME_ENUM,
|
||||
NL80211_IFTYPE_STATION, NULL);
|
||||
if (IS_ERR(wdev)) {
|
||||
mwifiex_dbg(adapter, ERROR,
|
||||
"cannot create default STA interface\n");
|
||||
wiphy_unlock(adapter->wiphy);
|
||||
rtnl_unlock();
|
||||
goto err_add_intf;
|
||||
}
|
||||
@ -614,6 +616,7 @@ static int _mwifiex_fw_dpc(const struct firmware *firmware, void *context)
|
||||
if (IS_ERR(wdev)) {
|
||||
mwifiex_dbg(adapter, ERROR,
|
||||
"cannot create AP interface\n");
|
||||
wiphy_unlock(adapter->wiphy);
|
||||
rtnl_unlock();
|
||||
goto err_add_intf;
|
||||
}
|
||||
@ -625,10 +628,12 @@ static int _mwifiex_fw_dpc(const struct firmware *firmware, void *context)
|
||||
if (IS_ERR(wdev)) {
|
||||
mwifiex_dbg(adapter, ERROR,
|
||||
"cannot create p2p client interface\n");
|
||||
wiphy_unlock(adapter->wiphy);
|
||||
rtnl_unlock();
|
||||
goto err_add_intf;
|
||||
}
|
||||
}
|
||||
wiphy_unlock(adapter->wiphy);
|
||||
rtnl_unlock();
|
||||
|
||||
mwifiex_drv_get_driver_version(adapter, fmt, sizeof(fmt) - 1);
|
||||
@ -1440,9 +1445,11 @@ static void mwifiex_uninit_sw(struct mwifiex_adapter *adapter)
|
||||
if (!priv)
|
||||
continue;
|
||||
rtnl_lock();
|
||||
wiphy_lock(adapter->wiphy);
|
||||
if (priv->netdev &&
|
||||
priv->wdev.iftype != NL80211_IFTYPE_UNSPECIFIED)
|
||||
mwifiex_del_virtual_intf(adapter->wiphy, &priv->wdev);
|
||||
wiphy_unlock(adapter->wiphy);
|
||||
rtnl_unlock();
|
||||
}
|
||||
|
||||
|
@ -1538,7 +1538,7 @@ static int del_virtual_intf(struct wiphy *wiphy, struct wireless_dev *wdev)
|
||||
wilc_wfi_deinit_mon_interface(wl, true);
|
||||
vif = netdev_priv(wdev->netdev);
|
||||
cfg80211_stop_iface(wiphy, wdev, GFP_KERNEL);
|
||||
unregister_netdevice(vif->ndev);
|
||||
cfg80211_unregister_netdevice(vif->ndev);
|
||||
vif->monitor_flag = 0;
|
||||
|
||||
wilc_set_operation_mode(vif, 0, 0, 0);
|
||||
|
@ -233,7 +233,7 @@ struct net_device *wilc_wfi_init_mon_interface(struct wilc *wl,
|
||||
wl->monitor_dev->netdev_ops = &wilc_wfi_netdev_ops;
|
||||
wl->monitor_dev->needs_free_netdev = true;
|
||||
|
||||
if (register_netdevice(wl->monitor_dev)) {
|
||||
if (cfg80211_register_netdevice(wl->monitor_dev)) {
|
||||
netdev_err(real_dev, "register_netdevice failed\n");
|
||||
free_netdev(wl->monitor_dev);
|
||||
return NULL;
|
||||
@ -251,7 +251,7 @@ void wilc_wfi_deinit_mon_interface(struct wilc *wl, bool rtnl_locked)
|
||||
return;
|
||||
|
||||
if (rtnl_locked)
|
||||
unregister_netdevice(wl->monitor_dev);
|
||||
cfg80211_unregister_netdevice(wl->monitor_dev);
|
||||
else
|
||||
unregister_netdev(wl->monitor_dev);
|
||||
wl->monitor_dev = NULL;
|
||||
|
@ -950,7 +950,7 @@ struct wilc_vif *wilc_netdev_ifc_init(struct wilc *wl, const char *name,
|
||||
vif->priv.dev = ndev;
|
||||
|
||||
if (rtnl_locked)
|
||||
ret = register_netdevice(ndev);
|
||||
ret = cfg80211_register_netdevice(ndev);
|
||||
else
|
||||
ret = register_netdev(ndev);
|
||||
|
||||
|
@ -180,7 +180,7 @@ int qtnf_del_virtual_intf(struct wiphy *wiphy, struct wireless_dev *wdev)
|
||||
cancel_work_sync(&vif->high_pri_tx_work);
|
||||
|
||||
if (netdev->reg_state == NETREG_REGISTERED)
|
||||
unregister_netdevice(netdev);
|
||||
cfg80211_unregister_netdevice(netdev);
|
||||
|
||||
if (qtnf_cmd_send_del_intf(vif))
|
||||
pr_err("VIF%u.%u: failed to delete VIF\n", vif->mac->macid,
|
||||
@ -267,7 +267,7 @@ static struct wireless_dev *qtnf_add_virtual_intf(struct wiphy *wiphy,
|
||||
if (qtnf_hwcap_is_set(&mac->bus->hw_info, QLINK_HW_CAPAB_HW_BRIDGE)) {
|
||||
ret = qtnf_cmd_netdev_changeupper(vif, vif->netdev->ifindex);
|
||||
if (ret) {
|
||||
unregister_netdevice(vif->netdev);
|
||||
cfg80211_unregister_netdevice(vif->netdev);
|
||||
vif->netdev = NULL;
|
||||
goto error_del_vif;
|
||||
}
|
||||
|
@ -492,7 +492,7 @@ int qtnf_core_net_attach(struct qtnf_wmac *mac, struct qtnf_vif *vif,
|
||||
|
||||
SET_NETDEV_DEV(dev, wiphy_dev(wiphy));
|
||||
|
||||
ret = register_netdevice(dev);
|
||||
ret = cfg80211_register_netdevice(dev);
|
||||
if (ret) {
|
||||
free_netdev(dev);
|
||||
vif->netdev = NULL;
|
||||
@ -611,8 +611,9 @@ static int qtnf_core_mac_attach(struct qtnf_bus *bus, unsigned int macid)
|
||||
mac->wiphy_registered = 1;
|
||||
|
||||
rtnl_lock();
|
||||
|
||||
wiphy_lock(priv_to_wiphy(mac));
|
||||
ret = qtnf_core_net_attach(mac, vif, "wlan%d", NET_NAME_ENUM);
|
||||
wiphy_unlock(priv_to_wiphy(mac));
|
||||
rtnl_unlock();
|
||||
|
||||
if (ret) {
|
||||
|
@ -1460,6 +1460,7 @@ int cfg80211_check_station_change(struct wiphy *wiphy,
|
||||
* @RATE_INFO_FLAGS_DMG: 60GHz MCS
|
||||
* @RATE_INFO_FLAGS_HE_MCS: HE MCS information
|
||||
* @RATE_INFO_FLAGS_EDMG: 60GHz MCS in EDMG mode
|
||||
* @RATE_INFO_FLAGS_EXTENDED_SC_DMG: 60GHz extended SC MCS
|
||||
*/
|
||||
enum rate_info_flags {
|
||||
RATE_INFO_FLAGS_MCS = BIT(0),
|
||||
@ -1468,6 +1469,7 @@ enum rate_info_flags {
|
||||
RATE_INFO_FLAGS_DMG = BIT(3),
|
||||
RATE_INFO_FLAGS_HE_MCS = BIT(4),
|
||||
RATE_INFO_FLAGS_EDMG = BIT(5),
|
||||
RATE_INFO_FLAGS_EXTENDED_SC_DMG = BIT(6),
|
||||
};
|
||||
|
||||
/**
|
||||
@ -3630,9 +3632,10 @@ struct mgmt_frame_regs {
|
||||
* All callbacks except where otherwise noted should return 0
|
||||
* on success or a negative error code.
|
||||
*
|
||||
* All operations are currently invoked under rtnl for consistency with the
|
||||
* wireless extensions but this is subject to reevaluation as soon as this
|
||||
* code is used more widely and we have a first user without wext.
|
||||
* All operations are invoked with the wiphy mutex held. The RTNL may be
|
||||
* held in addition (due to wireless extensions) but this cannot be relied
|
||||
* upon except in cases where documented below. Note that due to ordering,
|
||||
* the RTNL also cannot be acquired in any handlers.
|
||||
*
|
||||
* @suspend: wiphy device needs to be suspended. The variable @wow will
|
||||
* be %NULL or contain the enabled Wake-on-Wireless triggers that are
|
||||
@ -3647,11 +3650,14 @@ struct mgmt_frame_regs {
|
||||
* the new netdev in the wiphy's network namespace! Returns the struct
|
||||
* wireless_dev, or an ERR_PTR. For P2P device wdevs, the driver must
|
||||
* also set the address member in the wdev.
|
||||
* This additionally holds the RTNL to be able to do netdev changes.
|
||||
*
|
||||
* @del_virtual_intf: remove the virtual interface
|
||||
* This additionally holds the RTNL to be able to do netdev changes.
|
||||
*
|
||||
* @change_virtual_intf: change type/configuration of virtual interface,
|
||||
* keep the struct wireless_dev's iftype updated.
|
||||
* This additionally holds the RTNL to be able to do netdev changes.
|
||||
*
|
||||
* @add_key: add a key with the given parameters. @mac_addr will be %NULL
|
||||
* when adding a group key.
|
||||
@ -4741,6 +4747,7 @@ struct wiphy_iftype_akm_suites {
|
||||
|
||||
/**
|
||||
* struct wiphy - wireless hardware description
|
||||
* @mtx: mutex for the data (structures) of this device
|
||||
* @reg_notifier: the driver's regulatory notification callback,
|
||||
* note that if your driver uses wiphy_apply_custom_regulatory()
|
||||
* the reg_notifier's request can be passed as NULL
|
||||
@ -4934,6 +4941,8 @@ struct wiphy_iftype_akm_suites {
|
||||
* @sar_capa: SAR control capabilities
|
||||
*/
|
||||
struct wiphy {
|
||||
struct mutex mtx;
|
||||
|
||||
/* assign these fields before you register the wiphy */
|
||||
|
||||
u8 perm_addr[ETH_ALEN];
|
||||
@ -5186,6 +5195,37 @@ static inline struct wiphy *wiphy_new(const struct cfg80211_ops *ops,
|
||||
*/
|
||||
int wiphy_register(struct wiphy *wiphy);
|
||||
|
||||
/* this is a define for better error reporting (file/line) */
|
||||
#define lockdep_assert_wiphy(wiphy) lockdep_assert_held(&(wiphy)->mtx)
|
||||
|
||||
/**
|
||||
* rcu_dereference_wiphy - rcu_dereference with debug checking
|
||||
* @wiphy: the wiphy to check the locking on
|
||||
* @p: The pointer to read, prior to dereferencing
|
||||
*
|
||||
* Do an rcu_dereference(p), but check caller either holds rcu_read_lock()
|
||||
* or RTNL. Note: Please prefer wiphy_dereference() or rcu_dereference().
|
||||
*/
|
||||
#define rcu_dereference_wiphy(wiphy, p) \
|
||||
rcu_dereference_check(p, lockdep_is_held(&wiphy->mtx))
|
||||
|
||||
/**
|
||||
* wiphy_dereference - fetch RCU pointer when updates are prevented by wiphy mtx
|
||||
* @wiphy: the wiphy to check the locking on
|
||||
* @p: The pointer to read, prior to dereferencing
|
||||
*
|
||||
* Return the value of the specified RCU-protected pointer, but omit the
|
||||
* READ_ONCE(), because caller holds the wiphy mutex used for updates.
|
||||
*/
|
||||
#define wiphy_dereference(wiphy, p) \
|
||||
rcu_dereference_protected(p, lockdep_is_held(&wiphy->mtx))
|
||||
|
||||
/**
|
||||
* get_wiphy_regdom - get custom regdomain for the given wiphy
|
||||
* @wiphy: the wiphy to get the regdomain from
|
||||
*/
|
||||
const struct ieee80211_regdomain *get_wiphy_regdom(struct wiphy *wiphy);
|
||||
|
||||
/**
|
||||
* wiphy_unregister - deregister a wiphy from cfg80211
|
||||
*
|
||||
@ -5210,6 +5250,35 @@ struct cfg80211_internal_bss;
|
||||
struct cfg80211_cached_keys;
|
||||
struct cfg80211_cqm_config;
|
||||
|
||||
/**
|
||||
* wiphy_lock - lock the wiphy
|
||||
* @wiphy: the wiphy to lock
|
||||
*
|
||||
* This is mostly exposed so it can be done around registering and
|
||||
* unregistering netdevs that aren't created through cfg80211 calls,
|
||||
* since that requires locking in cfg80211 when the notifiers is
|
||||
* called, but that cannot differentiate which way it's called.
|
||||
*
|
||||
* When cfg80211 ops are called, the wiphy is already locked.
|
||||
*/
|
||||
static inline void wiphy_lock(struct wiphy *wiphy)
|
||||
__acquires(&wiphy->mtx)
|
||||
{
|
||||
mutex_lock(&wiphy->mtx);
|
||||
__acquire(&wiphy->mtx);
|
||||
}
|
||||
|
||||
/**
|
||||
* wiphy_unlock - unlock the wiphy again
|
||||
* @wiphy: the wiphy to unlock
|
||||
*/
|
||||
static inline void wiphy_unlock(struct wiphy *wiphy)
|
||||
__releases(&wiphy->mtx)
|
||||
{
|
||||
__release(&wiphy->mtx);
|
||||
mutex_unlock(&wiphy->mtx);
|
||||
}
|
||||
|
||||
/**
|
||||
* struct wireless_dev - wireless device state
|
||||
*
|
||||
@ -5217,7 +5286,10 @@ struct cfg80211_cqm_config;
|
||||
* that uses the ieee80211_ptr field in struct net_device (this
|
||||
* is intentional so it can be allocated along with the netdev.)
|
||||
* It need not be registered then as netdev registration will
|
||||
* be intercepted by cfg80211 to see the new wireless device.
|
||||
* be intercepted by cfg80211 to see the new wireless device,
|
||||
* however, drivers must lock the wiphy before registering or
|
||||
* unregistering netdevs if they pre-create any netdevs (in ops
|
||||
* called from cfg80211, the wiphy is already locked.)
|
||||
*
|
||||
* For non-netdev uses, it must also be allocated by the driver
|
||||
* in response to the cfg80211 callbacks that require it, as
|
||||
@ -5226,6 +5298,7 @@ struct cfg80211_cqm_config;
|
||||
*
|
||||
* @wiphy: pointer to hardware description
|
||||
* @iftype: interface type
|
||||
* @registered: is this wdev already registered with cfg80211
|
||||
* @list: (private) Used to collect the interfaces
|
||||
* @netdev: (private) Used to reference back to the netdev, may be %NULL
|
||||
* @identifier: (private) Identifier used in nl80211 to identify this
|
||||
@ -5309,7 +5382,7 @@ struct wireless_dev {
|
||||
|
||||
struct mutex mtx;
|
||||
|
||||
bool use_4addr, is_running;
|
||||
bool use_4addr, is_running, registered;
|
||||
|
||||
u8 address[ETH_ALEN] __aligned(sizeof(u16));
|
||||
|
||||
@ -5978,18 +6051,18 @@ int regulatory_set_wiphy_regd(struct wiphy *wiphy,
|
||||
struct ieee80211_regdomain *rd);
|
||||
|
||||
/**
|
||||
* regulatory_set_wiphy_regd_sync_rtnl - set regdom for self-managed drivers
|
||||
* regulatory_set_wiphy_regd_sync - set regdom for self-managed drivers
|
||||
* @wiphy: the wireless device we want to process the regulatory domain on
|
||||
* @rd: the regulatory domain information to use for this wiphy
|
||||
*
|
||||
* This functions requires the RTNL to be held and applies the new regdomain
|
||||
* synchronously to this wiphy. For more details see
|
||||
* regulatory_set_wiphy_regd().
|
||||
* This functions requires the RTNL and the wiphy mutex to be held and
|
||||
* applies the new regdomain synchronously to this wiphy. For more details
|
||||
* see regulatory_set_wiphy_regd().
|
||||
*
|
||||
* Return: 0 on success. -EINVAL, -EPERM
|
||||
*/
|
||||
int regulatory_set_wiphy_regd_sync_rtnl(struct wiphy *wiphy,
|
||||
struct ieee80211_regdomain *rd);
|
||||
int regulatory_set_wiphy_regd_sync(struct wiphy *wiphy,
|
||||
struct ieee80211_regdomain *rd);
|
||||
|
||||
/**
|
||||
* wiphy_apply_custom_regulatory - apply a custom driver regulatory domain
|
||||
@ -6107,7 +6180,7 @@ void cfg80211_sched_scan_results(struct wiphy *wiphy, u64 reqid);
|
||||
void cfg80211_sched_scan_stopped(struct wiphy *wiphy, u64 reqid);
|
||||
|
||||
/**
|
||||
* cfg80211_sched_scan_stopped_rtnl - notify that the scheduled scan has stopped
|
||||
* cfg80211_sched_scan_stopped_locked - notify that the scheduled scan has stopped
|
||||
*
|
||||
* @wiphy: the wiphy on which the scheduled scan stopped
|
||||
* @reqid: identifier for the related scheduled scan request
|
||||
@ -6115,9 +6188,9 @@ void cfg80211_sched_scan_stopped(struct wiphy *wiphy, u64 reqid);
|
||||
* The driver can call this function to inform cfg80211 that the
|
||||
* scheduled scan had to be stopped, for whatever reason. The driver
|
||||
* is then called back via the sched_scan_stop operation when done.
|
||||
* This function should be called with rtnl locked.
|
||||
* This function should be called with the wiphy mutex held.
|
||||
*/
|
||||
void cfg80211_sched_scan_stopped_rtnl(struct wiphy *wiphy, u64 reqid);
|
||||
void cfg80211_sched_scan_stopped_locked(struct wiphy *wiphy, u64 reqid);
|
||||
|
||||
/**
|
||||
* cfg80211_inform_bss_frame_data - inform cfg80211 of a received BSS frame
|
||||
@ -7554,7 +7627,7 @@ bool cfg80211_reg_can_beacon(struct wiphy *wiphy,
|
||||
* also checks if IR-relaxation conditions apply, to allow beaconing under
|
||||
* more permissive conditions.
|
||||
*
|
||||
* Requires the RTNL to be held.
|
||||
* Requires the wiphy mutex to be held.
|
||||
*/
|
||||
bool cfg80211_reg_can_beacon_relax(struct wiphy *wiphy,
|
||||
struct cfg80211_chan_def *chandef,
|
||||
@ -7652,18 +7725,45 @@ u32 cfg80211_calculate_bitrate(struct rate_info *rate);
|
||||
* cfg80211_unregister_wdev - remove the given wdev
|
||||
* @wdev: struct wireless_dev to remove
|
||||
*
|
||||
* Call this function only for wdevs that have no netdev assigned,
|
||||
* e.g. P2P Devices. It removes the device from the list so that
|
||||
* it can no longer be used. It is necessary to call this function
|
||||
* even when cfg80211 requests the removal of the interface by
|
||||
* calling the del_virtual_intf() callback. The function must also
|
||||
* be called when the driver wishes to unregister the wdev, e.g.
|
||||
* when the device is unbound from the driver.
|
||||
* This function removes the device so it can no longer be used. It is necessary
|
||||
* to call this function even when cfg80211 requests the removal of the device
|
||||
* by calling the del_virtual_intf() callback. The function must also be called
|
||||
* when the driver wishes to unregister the wdev, e.g. when the hardware device
|
||||
* is unbound from the driver.
|
||||
*
|
||||
* Requires the RTNL to be held.
|
||||
* Requires the RTNL and wiphy mutex to be held.
|
||||
*/
|
||||
void cfg80211_unregister_wdev(struct wireless_dev *wdev);
|
||||
|
||||
/**
|
||||
* cfg80211_register_netdevice - register the given netdev
|
||||
* @dev: the netdev to register
|
||||
*
|
||||
* Note: In contexts coming from cfg80211 callbacks, you must call this rather
|
||||
* than register_netdevice(), unregister_netdev() is impossible as the RTNL is
|
||||
* held. Otherwise, both register_netdevice() and register_netdev() are usable
|
||||
* instead as well.
|
||||
*
|
||||
* Requires the RTNL and wiphy mutex to be held.
|
||||
*/
|
||||
int cfg80211_register_netdevice(struct net_device *dev);
|
||||
|
||||
/**
|
||||
* cfg80211_unregister_netdevice - unregister the given netdev
|
||||
* @dev: the netdev to register
|
||||
*
|
||||
* Note: In contexts coming from cfg80211 callbacks, you must call this rather
|
||||
* than unregister_netdevice(), unregister_netdev() is impossible as the RTNL
|
||||
* is held. Otherwise, both unregister_netdevice() and unregister_netdev() are
|
||||
* usable instead as well.
|
||||
*
|
||||
* Requires the RTNL and wiphy mutex to be held.
|
||||
*/
|
||||
static inline void cfg80211_unregister_netdevice(struct net_device *dev)
|
||||
{
|
||||
cfg80211_unregister_wdev(dev->ieee80211_ptr);
|
||||
}
|
||||
|
||||
/**
|
||||
* struct cfg80211_ft_event_params - FT Information Elements
|
||||
* @ies: FT IEs
|
||||
|
@ -19,8 +19,6 @@ struct fq_tin;
|
||||
* @flowchain: can be linked to fq_tin's new_flows or old_flows. Used for DRR++
|
||||
* (deficit round robin) based round robin queuing similar to the one
|
||||
* found in net/sched/sch_fq_codel.c
|
||||
* @backlogchain: can be linked to other fq_flow and fq. Used to keep track of
|
||||
* fat flows and efficient head-dropping if packet limit is reached
|
||||
* @queue: sk_buff queue to hold packets
|
||||
* @backlog: number of bytes pending in the queue. The number of packets can be
|
||||
* found in @queue.qlen
|
||||
@ -29,7 +27,6 @@ struct fq_tin;
|
||||
struct fq_flow {
|
||||
struct fq_tin *tin;
|
||||
struct list_head flowchain;
|
||||
struct list_head backlogchain;
|
||||
struct sk_buff_head queue;
|
||||
u32 backlog;
|
||||
int deficit;
|
||||
@ -47,6 +44,8 @@ struct fq_flow {
|
||||
struct fq_tin {
|
||||
struct list_head new_flows;
|
||||
struct list_head old_flows;
|
||||
struct list_head tin_list;
|
||||
struct fq_flow default_flow;
|
||||
u32 backlog_bytes;
|
||||
u32 backlog_packets;
|
||||
u32 overlimit;
|
||||
@ -59,14 +58,14 @@ struct fq_tin {
|
||||
/**
|
||||
* struct fq - main container for fair queuing purposes
|
||||
*
|
||||
* @backlogs: linked to fq_flows. Used to maintain fat flows for efficient
|
||||
* head-dropping when @backlog reaches @limit
|
||||
* @limit: max number of packets that can be queued across all flows
|
||||
* @backlog: number of packets queued across all flows
|
||||
*/
|
||||
struct fq {
|
||||
struct fq_flow *flows;
|
||||
struct list_head backlogs;
|
||||
unsigned long *flows_bitmap;
|
||||
|
||||
struct list_head tin_backlog;
|
||||
spinlock_t lock;
|
||||
u32 flows_cnt;
|
||||
u32 limit;
|
||||
|
@ -11,35 +11,37 @@
|
||||
|
||||
/* functions that are embedded into includer */
|
||||
|
||||
|
||||
static void
|
||||
__fq_adjust_removal(struct fq *fq, struct fq_flow *flow, unsigned int packets,
|
||||
unsigned int bytes, unsigned int truesize)
|
||||
{
|
||||
struct fq_tin *tin = flow->tin;
|
||||
int idx;
|
||||
|
||||
tin->backlog_bytes -= bytes;
|
||||
tin->backlog_packets -= packets;
|
||||
flow->backlog -= bytes;
|
||||
fq->backlog -= packets;
|
||||
fq->memory_usage -= truesize;
|
||||
|
||||
if (flow->backlog)
|
||||
return;
|
||||
|
||||
if (flow == &tin->default_flow) {
|
||||
list_del_init(&tin->tin_list);
|
||||
return;
|
||||
}
|
||||
|
||||
idx = flow - fq->flows;
|
||||
__clear_bit(idx, fq->flows_bitmap);
|
||||
}
|
||||
|
||||
static void fq_adjust_removal(struct fq *fq,
|
||||
struct fq_flow *flow,
|
||||
struct sk_buff *skb)
|
||||
{
|
||||
struct fq_tin *tin = flow->tin;
|
||||
|
||||
tin->backlog_bytes -= skb->len;
|
||||
tin->backlog_packets--;
|
||||
flow->backlog -= skb->len;
|
||||
fq->backlog--;
|
||||
fq->memory_usage -= skb->truesize;
|
||||
}
|
||||
|
||||
static void fq_rejigger_backlog(struct fq *fq, struct fq_flow *flow)
|
||||
{
|
||||
struct fq_flow *i;
|
||||
|
||||
if (flow->backlog == 0) {
|
||||
list_del_init(&flow->backlogchain);
|
||||
} else {
|
||||
i = flow;
|
||||
|
||||
list_for_each_entry_continue(i, &fq->backlogs, backlogchain)
|
||||
if (i->backlog < flow->backlog)
|
||||
break;
|
||||
|
||||
list_move_tail(&flow->backlogchain,
|
||||
&i->backlogchain);
|
||||
}
|
||||
__fq_adjust_removal(fq, flow, 1, skb->len, skb->truesize);
|
||||
}
|
||||
|
||||
static struct sk_buff *fq_flow_dequeue(struct fq *fq,
|
||||
@ -54,11 +56,37 @@ static struct sk_buff *fq_flow_dequeue(struct fq *fq,
|
||||
return NULL;
|
||||
|
||||
fq_adjust_removal(fq, flow, skb);
|
||||
fq_rejigger_backlog(fq, flow);
|
||||
|
||||
return skb;
|
||||
}
|
||||
|
||||
static int fq_flow_drop(struct fq *fq, struct fq_flow *flow,
|
||||
fq_skb_free_t free_func)
|
||||
{
|
||||
unsigned int packets = 0, bytes = 0, truesize = 0;
|
||||
struct fq_tin *tin = flow->tin;
|
||||
struct sk_buff *skb;
|
||||
int pending;
|
||||
|
||||
lockdep_assert_held(&fq->lock);
|
||||
|
||||
pending = min_t(int, 32, skb_queue_len(&flow->queue) / 2);
|
||||
do {
|
||||
skb = __skb_dequeue(&flow->queue);
|
||||
if (!skb)
|
||||
break;
|
||||
|
||||
packets++;
|
||||
bytes += skb->len;
|
||||
truesize += skb->truesize;
|
||||
free_func(fq, tin, flow, skb);
|
||||
} while (packets < pending);
|
||||
|
||||
__fq_adjust_removal(fq, flow, packets, bytes, truesize);
|
||||
|
||||
return packets;
|
||||
}
|
||||
|
||||
static struct sk_buff *fq_tin_dequeue(struct fq *fq,
|
||||
struct fq_tin *tin,
|
||||
fq_tin_dequeue_t dequeue_func)
|
||||
@ -115,8 +143,7 @@ static u32 fq_flow_idx(struct fq *fq, struct sk_buff *skb)
|
||||
|
||||
static struct fq_flow *fq_flow_classify(struct fq *fq,
|
||||
struct fq_tin *tin, u32 idx,
|
||||
struct sk_buff *skb,
|
||||
fq_flow_get_default_t get_default_func)
|
||||
struct sk_buff *skb)
|
||||
{
|
||||
struct fq_flow *flow;
|
||||
|
||||
@ -124,7 +151,7 @@ static struct fq_flow *fq_flow_classify(struct fq *fq,
|
||||
|
||||
flow = &fq->flows[idx];
|
||||
if (flow->tin && flow->tin != tin) {
|
||||
flow = get_default_func(fq, tin, idx, skb);
|
||||
flow = &tin->default_flow;
|
||||
tin->collisions++;
|
||||
fq->collisions++;
|
||||
}
|
||||
@ -135,36 +162,56 @@ static struct fq_flow *fq_flow_classify(struct fq *fq,
|
||||
return flow;
|
||||
}
|
||||
|
||||
static void fq_recalc_backlog(struct fq *fq,
|
||||
struct fq_tin *tin,
|
||||
struct fq_flow *flow)
|
||||
static struct fq_flow *fq_find_fattest_flow(struct fq *fq)
|
||||
{
|
||||
struct fq_flow *i;
|
||||
struct fq_tin *tin;
|
||||
struct fq_flow *flow = NULL;
|
||||
u32 len = 0;
|
||||
int i;
|
||||
|
||||
if (list_empty(&flow->backlogchain))
|
||||
list_add_tail(&flow->backlogchain, &fq->backlogs);
|
||||
for_each_set_bit(i, fq->flows_bitmap, fq->flows_cnt) {
|
||||
struct fq_flow *cur = &fq->flows[i];
|
||||
unsigned int cur_len;
|
||||
|
||||
i = flow;
|
||||
list_for_each_entry_continue_reverse(i, &fq->backlogs,
|
||||
backlogchain)
|
||||
if (i->backlog > flow->backlog)
|
||||
break;
|
||||
cur_len = cur->backlog;
|
||||
if (cur_len <= len)
|
||||
continue;
|
||||
|
||||
list_move(&flow->backlogchain, &i->backlogchain);
|
||||
flow = cur;
|
||||
len = cur_len;
|
||||
}
|
||||
|
||||
list_for_each_entry(tin, &fq->tin_backlog, tin_list) {
|
||||
unsigned int cur_len = tin->default_flow.backlog;
|
||||
|
||||
if (cur_len <= len)
|
||||
continue;
|
||||
|
||||
flow = &tin->default_flow;
|
||||
len = cur_len;
|
||||
}
|
||||
|
||||
return flow;
|
||||
}
|
||||
|
||||
static void fq_tin_enqueue(struct fq *fq,
|
||||
struct fq_tin *tin, u32 idx,
|
||||
struct sk_buff *skb,
|
||||
fq_skb_free_t free_func,
|
||||
fq_flow_get_default_t get_default_func)
|
||||
fq_skb_free_t free_func)
|
||||
{
|
||||
struct fq_flow *flow;
|
||||
bool oom;
|
||||
|
||||
lockdep_assert_held(&fq->lock);
|
||||
|
||||
flow = fq_flow_classify(fq, tin, idx, skb, get_default_func);
|
||||
flow = fq_flow_classify(fq, tin, idx, skb);
|
||||
|
||||
if (!flow->backlog) {
|
||||
if (flow != &tin->default_flow)
|
||||
__set_bit(idx, fq->flows_bitmap);
|
||||
else if (list_empty(&tin->tin_list))
|
||||
list_add(&tin->tin_list, &fq->tin_backlog);
|
||||
}
|
||||
|
||||
flow->tin = tin;
|
||||
flow->backlog += skb->len;
|
||||
@ -173,8 +220,6 @@ static void fq_tin_enqueue(struct fq *fq,
|
||||
fq->memory_usage += skb->truesize;
|
||||
fq->backlog++;
|
||||
|
||||
fq_recalc_backlog(fq, tin, flow);
|
||||
|
||||
if (list_empty(&flow->flowchain)) {
|
||||
flow->deficit = fq->quantum;
|
||||
list_add_tail(&flow->flowchain,
|
||||
@ -184,18 +229,13 @@ static void fq_tin_enqueue(struct fq *fq,
|
||||
__skb_queue_tail(&flow->queue, skb);
|
||||
oom = (fq->memory_usage > fq->memory_limit);
|
||||
while (fq->backlog > fq->limit || oom) {
|
||||
flow = list_first_entry_or_null(&fq->backlogs,
|
||||
struct fq_flow,
|
||||
backlogchain);
|
||||
flow = fq_find_fattest_flow(fq);
|
||||
if (!flow)
|
||||
return;
|
||||
|
||||
skb = fq_flow_dequeue(fq, flow);
|
||||
if (!skb)
|
||||
if (!fq_flow_drop(fq, flow, free_func))
|
||||
return;
|
||||
|
||||
free_func(fq, flow->tin, flow, skb);
|
||||
|
||||
flow->tin->overlimit++;
|
||||
fq->overlimit++;
|
||||
if (oom) {
|
||||
@ -224,8 +264,6 @@ static void fq_flow_filter(struct fq *fq,
|
||||
fq_adjust_removal(fq, flow, skb);
|
||||
free_func(fq, tin, flow, skb);
|
||||
}
|
||||
|
||||
fq_rejigger_backlog(fq, flow);
|
||||
}
|
||||
|
||||
static void fq_tin_filter(struct fq *fq,
|
||||
@ -248,16 +286,18 @@ static void fq_flow_reset(struct fq *fq,
|
||||
struct fq_flow *flow,
|
||||
fq_skb_free_t free_func)
|
||||
{
|
||||
struct fq_tin *tin = flow->tin;
|
||||
struct sk_buff *skb;
|
||||
|
||||
while ((skb = fq_flow_dequeue(fq, flow)))
|
||||
free_func(fq, flow->tin, flow, skb);
|
||||
free_func(fq, tin, flow, skb);
|
||||
|
||||
if (!list_empty(&flow->flowchain))
|
||||
if (!list_empty(&flow->flowchain)) {
|
||||
list_del_init(&flow->flowchain);
|
||||
|
||||
if (!list_empty(&flow->backlogchain))
|
||||
list_del_init(&flow->backlogchain);
|
||||
if (list_empty(&tin->new_flows) &&
|
||||
list_empty(&tin->old_flows))
|
||||
list_del_init(&tin->tin_list);
|
||||
}
|
||||
|
||||
flow->tin = NULL;
|
||||
|
||||
@ -283,6 +323,7 @@ static void fq_tin_reset(struct fq *fq,
|
||||
fq_flow_reset(fq, flow, free_func);
|
||||
}
|
||||
|
||||
WARN_ON_ONCE(!list_empty(&tin->tin_list));
|
||||
WARN_ON_ONCE(tin->backlog_bytes);
|
||||
WARN_ON_ONCE(tin->backlog_packets);
|
||||
}
|
||||
@ -290,7 +331,6 @@ static void fq_tin_reset(struct fq *fq,
|
||||
static void fq_flow_init(struct fq_flow *flow)
|
||||
{
|
||||
INIT_LIST_HEAD(&flow->flowchain);
|
||||
INIT_LIST_HEAD(&flow->backlogchain);
|
||||
__skb_queue_head_init(&flow->queue);
|
||||
}
|
||||
|
||||
@ -298,6 +338,8 @@ static void fq_tin_init(struct fq_tin *tin)
|
||||
{
|
||||
INIT_LIST_HEAD(&tin->new_flows);
|
||||
INIT_LIST_HEAD(&tin->old_flows);
|
||||
INIT_LIST_HEAD(&tin->tin_list);
|
||||
fq_flow_init(&tin->default_flow);
|
||||
}
|
||||
|
||||
static int fq_init(struct fq *fq, int flows_cnt)
|
||||
@ -305,8 +347,8 @@ static int fq_init(struct fq *fq, int flows_cnt)
|
||||
int i;
|
||||
|
||||
memset(fq, 0, sizeof(fq[0]));
|
||||
INIT_LIST_HEAD(&fq->backlogs);
|
||||
spin_lock_init(&fq->lock);
|
||||
INIT_LIST_HEAD(&fq->tin_backlog);
|
||||
fq->flows_cnt = max_t(u32, flows_cnt, 1);
|
||||
fq->quantum = 300;
|
||||
fq->limit = 8192;
|
||||
@ -316,6 +358,14 @@ static int fq_init(struct fq *fq, int flows_cnt)
|
||||
if (!fq->flows)
|
||||
return -ENOMEM;
|
||||
|
||||
fq->flows_bitmap = kcalloc(BITS_TO_LONGS(fq->flows_cnt), sizeof(long),
|
||||
GFP_KERNEL);
|
||||
if (!fq->flows_bitmap) {
|
||||
kvfree(fq->flows);
|
||||
fq->flows = NULL;
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
for (i = 0; i < fq->flows_cnt; i++)
|
||||
fq_flow_init(&fq->flows[i]);
|
||||
|
||||
@ -332,6 +382,9 @@ static void fq_reset(struct fq *fq,
|
||||
|
||||
kvfree(fq->flows);
|
||||
fq->flows = NULL;
|
||||
|
||||
kfree(fq->flows_bitmap);
|
||||
fq->flows_bitmap = NULL;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -1296,6 +1296,8 @@ ieee80211_tx_info_clear_status(struct ieee80211_tx_info *info)
|
||||
* the "0-length PSDU" field included there. The value for it is
|
||||
* in &struct ieee80211_rx_status. Note that if this value isn't
|
||||
* known the frame shouldn't be reported.
|
||||
* @RX_FLAG_8023: the frame has an 802.3 header (decap offload performed by
|
||||
* hardware or driver)
|
||||
*/
|
||||
enum mac80211_rx_flags {
|
||||
RX_FLAG_MMIC_ERROR = BIT(0),
|
||||
@ -1328,6 +1330,7 @@ enum mac80211_rx_flags {
|
||||
RX_FLAG_RADIOTAP_HE_MU = BIT(27),
|
||||
RX_FLAG_RADIOTAP_LSIG = BIT(28),
|
||||
RX_FLAG_NO_PSDU = BIT(29),
|
||||
RX_FLAG_8023 = BIT(30),
|
||||
};
|
||||
|
||||
/**
|
||||
@ -1649,11 +1652,15 @@ enum ieee80211_vif_flags {
|
||||
* The driver supports sending frames passed as 802.3 frames by mac80211.
|
||||
* It must also support sending 802.11 packets for the same interface.
|
||||
* @IEEE80211_OFFLOAD_ENCAP_4ADDR: support 4-address mode encapsulation offload
|
||||
* @IEEE80211_OFFLOAD_DECAP_ENABLED: rx encapsulation offload is enabled
|
||||
* The driver supports passing received 802.11 frames as 802.3 frames to
|
||||
* mac80211.
|
||||
*/
|
||||
|
||||
enum ieee80211_offload_flags {
|
||||
IEEE80211_OFFLOAD_ENCAP_ENABLED = BIT(0),
|
||||
IEEE80211_OFFLOAD_ENCAP_4ADDR = BIT(1),
|
||||
IEEE80211_OFFLOAD_DECAP_ENABLED = BIT(2),
|
||||
};
|
||||
|
||||
/**
|
||||
@ -2389,6 +2396,9 @@ struct ieee80211_txq {
|
||||
* @IEEE80211_HW_SUPPORTS_TX_ENCAP_OFFLOAD: Hardware supports tx encapsulation
|
||||
* offload
|
||||
*
|
||||
* @IEEE80211_HW_SUPPORTS_RX_DECAP_OFFLOAD: Hardware supports rx decapsulation
|
||||
* offload
|
||||
*
|
||||
* @NUM_IEEE80211_HW_FLAGS: number of hardware flags, used for sizing arrays
|
||||
*/
|
||||
enum ieee80211_hw_flags {
|
||||
@ -2442,6 +2452,7 @@ enum ieee80211_hw_flags {
|
||||
IEEE80211_HW_SUPPORTS_ONLY_HE_MULTI_BSSID,
|
||||
IEEE80211_HW_AMPDU_KEYBORDER_SUPPORT,
|
||||
IEEE80211_HW_SUPPORTS_TX_ENCAP_OFFLOAD,
|
||||
IEEE80211_HW_SUPPORTS_RX_DECAP_OFFLOAD,
|
||||
|
||||
/* keep last, obviously */
|
||||
NUM_IEEE80211_HW_FLAGS
|
||||
@ -3881,6 +3892,8 @@ enum ieee80211_reconfig_type {
|
||||
* @sta_set_4addr: Called to notify the driver when a station starts/stops using
|
||||
* 4-address mode
|
||||
* @set_sar_specs: Update the SAR (TX power) settings.
|
||||
* @sta_set_decap_offload: Called to notify the driver when a station is allowed
|
||||
* to use rx decapsulation offload
|
||||
*/
|
||||
struct ieee80211_ops {
|
||||
void (*tx)(struct ieee80211_hw *hw,
|
||||
@ -4198,6 +4211,9 @@ struct ieee80211_ops {
|
||||
struct ieee80211_sta *sta, bool enabled);
|
||||
int (*set_sar_specs)(struct ieee80211_hw *hw,
|
||||
const struct cfg80211_sar_specs *sar);
|
||||
void (*sta_set_decap_offload)(struct ieee80211_hw *hw,
|
||||
struct ieee80211_vif *vif,
|
||||
struct ieee80211_sta *sta, bool enabled);
|
||||
};
|
||||
|
||||
/**
|
||||
@ -5513,7 +5529,7 @@ void ieee80211_iterate_active_interfaces_atomic(struct ieee80211_hw *hw,
|
||||
void *data);
|
||||
|
||||
/**
|
||||
* ieee80211_iterate_active_interfaces_rtnl - iterate active interfaces
|
||||
* ieee80211_iterate_active_interfaces_mtx - iterate active interfaces
|
||||
*
|
||||
* This function iterates over the interfaces associated with a given
|
||||
* hardware that are currently active and calls the callback for them.
|
||||
@ -5524,12 +5540,12 @@ void ieee80211_iterate_active_interfaces_atomic(struct ieee80211_hw *hw,
|
||||
* @iterator: the iterator function to call, cannot sleep
|
||||
* @data: first argument of the iterator function
|
||||
*/
|
||||
void ieee80211_iterate_active_interfaces_rtnl(struct ieee80211_hw *hw,
|
||||
u32 iter_flags,
|
||||
void (*iterator)(void *data,
|
||||
void ieee80211_iterate_active_interfaces_mtx(struct ieee80211_hw *hw,
|
||||
u32 iter_flags,
|
||||
void (*iterator)(void *data,
|
||||
u8 *mac,
|
||||
struct ieee80211_vif *vif),
|
||||
void *data);
|
||||
void *data);
|
||||
|
||||
/**
|
||||
* ieee80211_iterate_stations_atomic - iterate stations
|
||||
|
@ -56,11 +56,9 @@ mac80211-$(CONFIG_PM) += pm.o
|
||||
CFLAGS_trace.o := -I$(src)
|
||||
|
||||
rc80211_minstrel-y := \
|
||||
rc80211_minstrel.o \
|
||||
rc80211_minstrel_ht.o
|
||||
|
||||
rc80211_minstrel-$(CONFIG_MAC80211_DEBUGFS) += \
|
||||
rc80211_minstrel_debugfs.o \
|
||||
rc80211_minstrel_ht_debugfs.o
|
||||
|
||||
mac80211-$(CONFIG_MAC80211_RC_MINSTREL) += $(rc80211_minstrel-y)
|
||||
|
@ -281,6 +281,56 @@ static const struct file_operations aql_txq_limit_ops = {
|
||||
.llseek = default_llseek,
|
||||
};
|
||||
|
||||
static ssize_t aql_enable_read(struct file *file, char __user *user_buf,
|
||||
size_t count, loff_t *ppos)
|
||||
{
|
||||
char buf[3];
|
||||
int len;
|
||||
|
||||
len = scnprintf(buf, sizeof(buf), "%d\n",
|
||||
!static_key_false(&aql_disable.key));
|
||||
|
||||
return simple_read_from_buffer(user_buf, count, ppos, buf, len);
|
||||
}
|
||||
|
||||
static ssize_t aql_enable_write(struct file *file, const char __user *user_buf,
|
||||
size_t count, loff_t *ppos)
|
||||
{
|
||||
bool aql_disabled = static_key_false(&aql_disable.key);
|
||||
char buf[3];
|
||||
size_t len;
|
||||
|
||||
if (count > sizeof(buf))
|
||||
return -EINVAL;
|
||||
|
||||
if (copy_from_user(buf, user_buf, count))
|
||||
return -EFAULT;
|
||||
|
||||
buf[sizeof(buf) - 1] = '\0';
|
||||
len = strlen(buf);
|
||||
if (len > 0 && buf[len - 1] == '\n')
|
||||
buf[len - 1] = 0;
|
||||
|
||||
if (buf[0] == '0' && buf[1] == '\0') {
|
||||
if (!aql_disabled)
|
||||
static_branch_inc(&aql_disable);
|
||||
} else if (buf[0] == '1' && buf[1] == '\0') {
|
||||
if (aql_disabled)
|
||||
static_branch_dec(&aql_disable);
|
||||
} else {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
static const struct file_operations aql_enable_ops = {
|
||||
.write = aql_enable_write,
|
||||
.read = aql_enable_read,
|
||||
.open = simple_open,
|
||||
.llseek = default_llseek,
|
||||
};
|
||||
|
||||
static ssize_t force_tx_status_read(struct file *file,
|
||||
char __user *user_buf,
|
||||
size_t count,
|
||||
@ -405,6 +455,7 @@ static const char *hw_flag_names[] = {
|
||||
FLAG(SUPPORTS_ONLY_HE_MULTI_BSSID),
|
||||
FLAG(AMPDU_KEYBORDER_SUPPORT),
|
||||
FLAG(SUPPORTS_TX_ENCAP_OFFLOAD),
|
||||
FLAG(SUPPORTS_RX_DECAP_OFFLOAD),
|
||||
#undef FLAG
|
||||
};
|
||||
|
||||
@ -568,6 +619,7 @@ void debugfs_hw_add(struct ieee80211_local *local)
|
||||
DEBUGFS_ADD(power);
|
||||
DEBUGFS_ADD(hw_conf);
|
||||
DEBUGFS_ADD_MODE(force_tx_status, 0600);
|
||||
DEBUGFS_ADD_MODE(aql_enable, 0600);
|
||||
|
||||
if (local->ops->wake_tx_queue)
|
||||
DEBUGFS_ADD_MODE(aqm, 0600);
|
||||
|
@ -79,6 +79,7 @@ static const char * const sta_flag_names[] = {
|
||||
FLAG(MPSP_RECIPIENT),
|
||||
FLAG(PS_DELIVER),
|
||||
FLAG(USES_ENCRYPTION),
|
||||
FLAG(DECAP_OFFLOAD),
|
||||
#undef FLAG
|
||||
};
|
||||
|
||||
|
@ -1413,4 +1413,20 @@ static inline void drv_sta_set_4addr(struct ieee80211_local *local,
|
||||
trace_drv_return_void(local);
|
||||
}
|
||||
|
||||
static inline void drv_sta_set_decap_offload(struct ieee80211_local *local,
|
||||
struct ieee80211_sub_if_data *sdata,
|
||||
struct ieee80211_sta *sta,
|
||||
bool enabled)
|
||||
{
|
||||
sdata = get_bss_sdata(sdata);
|
||||
if (!check_sdata_in_driver(sdata))
|
||||
return;
|
||||
|
||||
trace_drv_sta_set_decap_offload(local, sdata, sta, enabled);
|
||||
if (local->ops->sta_set_decap_offload)
|
||||
local->ops->sta_set_decap_offload(&local->hw, &sdata->vif, sta,
|
||||
enabled);
|
||||
trace_drv_return_void(local);
|
||||
}
|
||||
|
||||
#endif /* __MAC80211_DRIVER_OPS */
|
||||
|
@ -52,6 +52,57 @@ ieee80211_update_from_he_6ghz_capa(const struct ieee80211_he_6ghz_capa *he_6ghz_
|
||||
sta->sta.he_6ghz_capa = *he_6ghz_capa;
|
||||
}
|
||||
|
||||
static void ieee80211_he_mcs_disable(__le16 *he_mcs)
|
||||
{
|
||||
u32 i;
|
||||
|
||||
for (i = 0; i < 8; i++)
|
||||
*he_mcs |= cpu_to_le16(IEEE80211_HE_MCS_NOT_SUPPORTED << i * 2);
|
||||
}
|
||||
|
||||
static void ieee80211_he_mcs_intersection(__le16 *he_own_rx, __le16 *he_peer_rx,
|
||||
__le16 *he_own_tx, __le16 *he_peer_tx)
|
||||
{
|
||||
u32 i;
|
||||
u16 own_rx, own_tx, peer_rx, peer_tx;
|
||||
|
||||
for (i = 0; i < 8; i++) {
|
||||
own_rx = le16_to_cpu(*he_own_rx);
|
||||
own_rx = (own_rx >> i * 2) & IEEE80211_HE_MCS_NOT_SUPPORTED;
|
||||
|
||||
own_tx = le16_to_cpu(*he_own_tx);
|
||||
own_tx = (own_tx >> i * 2) & IEEE80211_HE_MCS_NOT_SUPPORTED;
|
||||
|
||||
peer_rx = le16_to_cpu(*he_peer_rx);
|
||||
peer_rx = (peer_rx >> i * 2) & IEEE80211_HE_MCS_NOT_SUPPORTED;
|
||||
|
||||
peer_tx = le16_to_cpu(*he_peer_tx);
|
||||
peer_tx = (peer_tx >> i * 2) & IEEE80211_HE_MCS_NOT_SUPPORTED;
|
||||
|
||||
if (peer_tx != IEEE80211_HE_MCS_NOT_SUPPORTED) {
|
||||
if (own_rx == IEEE80211_HE_MCS_NOT_SUPPORTED)
|
||||
peer_tx = IEEE80211_HE_MCS_NOT_SUPPORTED;
|
||||
else if (own_rx < peer_tx)
|
||||
peer_tx = own_rx;
|
||||
}
|
||||
|
||||
if (peer_rx != IEEE80211_HE_MCS_NOT_SUPPORTED) {
|
||||
if (own_tx == IEEE80211_HE_MCS_NOT_SUPPORTED)
|
||||
peer_rx = IEEE80211_HE_MCS_NOT_SUPPORTED;
|
||||
else if (own_tx < peer_rx)
|
||||
peer_rx = own_tx;
|
||||
}
|
||||
|
||||
*he_peer_rx &=
|
||||
~cpu_to_le16(IEEE80211_HE_MCS_NOT_SUPPORTED << i * 2);
|
||||
*he_peer_rx |= cpu_to_le16(peer_rx << i * 2);
|
||||
|
||||
*he_peer_tx &=
|
||||
~cpu_to_le16(IEEE80211_HE_MCS_NOT_SUPPORTED << i * 2);
|
||||
*he_peer_tx |= cpu_to_le16(peer_tx << i * 2);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
ieee80211_he_cap_ie_to_sta_he_cap(struct ieee80211_sub_if_data *sdata,
|
||||
struct ieee80211_supported_band *sband,
|
||||
@ -60,10 +111,12 @@ ieee80211_he_cap_ie_to_sta_he_cap(struct ieee80211_sub_if_data *sdata,
|
||||
struct sta_info *sta)
|
||||
{
|
||||
struct ieee80211_sta_he_cap *he_cap = &sta->sta.he_cap;
|
||||
struct ieee80211_sta_he_cap own_he_cap = sband->iftype_data->he_cap;
|
||||
struct ieee80211_he_cap_elem *he_cap_ie_elem = (void *)he_cap_ie;
|
||||
u8 he_ppe_size;
|
||||
u8 mcs_nss_size;
|
||||
u8 he_total_size;
|
||||
bool own_160, peer_160, own_80p80, peer_80p80;
|
||||
|
||||
memset(he_cap, 0, sizeof(*he_cap));
|
||||
|
||||
@ -101,6 +154,45 @@ ieee80211_he_cap_ie_to_sta_he_cap(struct ieee80211_sub_if_data *sdata,
|
||||
|
||||
if (sband->band == NL80211_BAND_6GHZ && he_6ghz_capa)
|
||||
ieee80211_update_from_he_6ghz_capa(he_6ghz_capa, sta);
|
||||
|
||||
ieee80211_he_mcs_intersection(&own_he_cap.he_mcs_nss_supp.rx_mcs_80,
|
||||
&he_cap->he_mcs_nss_supp.rx_mcs_80,
|
||||
&own_he_cap.he_mcs_nss_supp.tx_mcs_80,
|
||||
&he_cap->he_mcs_nss_supp.tx_mcs_80);
|
||||
|
||||
own_160 = own_he_cap.he_cap_elem.phy_cap_info[0] &
|
||||
IEEE80211_HE_PHY_CAP0_CHANNEL_WIDTH_SET_160MHZ_IN_5G;
|
||||
peer_160 = he_cap->he_cap_elem.phy_cap_info[0] &
|
||||
IEEE80211_HE_PHY_CAP0_CHANNEL_WIDTH_SET_160MHZ_IN_5G;
|
||||
|
||||
if (peer_160 && own_160) {
|
||||
ieee80211_he_mcs_intersection(&own_he_cap.he_mcs_nss_supp.rx_mcs_160,
|
||||
&he_cap->he_mcs_nss_supp.rx_mcs_160,
|
||||
&own_he_cap.he_mcs_nss_supp.tx_mcs_160,
|
||||
&he_cap->he_mcs_nss_supp.tx_mcs_160);
|
||||
} else if (peer_160 && !own_160) {
|
||||
ieee80211_he_mcs_disable(&he_cap->he_mcs_nss_supp.rx_mcs_160);
|
||||
ieee80211_he_mcs_disable(&he_cap->he_mcs_nss_supp.tx_mcs_160);
|
||||
he_cap->he_cap_elem.phy_cap_info[0] &=
|
||||
~IEEE80211_HE_PHY_CAP0_CHANNEL_WIDTH_SET_160MHZ_IN_5G;
|
||||
}
|
||||
|
||||
own_80p80 = own_he_cap.he_cap_elem.phy_cap_info[0] &
|
||||
IEEE80211_HE_PHY_CAP0_CHANNEL_WIDTH_SET_80PLUS80_MHZ_IN_5G;
|
||||
peer_80p80 = he_cap->he_cap_elem.phy_cap_info[0] &
|
||||
IEEE80211_HE_PHY_CAP0_CHANNEL_WIDTH_SET_80PLUS80_MHZ_IN_5G;
|
||||
|
||||
if (peer_80p80 && own_80p80) {
|
||||
ieee80211_he_mcs_intersection(&own_he_cap.he_mcs_nss_supp.rx_mcs_80p80,
|
||||
&he_cap->he_mcs_nss_supp.rx_mcs_80p80,
|
||||
&own_he_cap.he_mcs_nss_supp.tx_mcs_80p80,
|
||||
&he_cap->he_mcs_nss_supp.tx_mcs_80p80);
|
||||
} else if (peer_80p80 && !own_80p80) {
|
||||
ieee80211_he_mcs_disable(&he_cap->he_mcs_nss_supp.rx_mcs_80p80);
|
||||
ieee80211_he_mcs_disable(&he_cap->he_mcs_nss_supp.tx_mcs_80p80);
|
||||
he_cap->he_cap_elem.phy_cap_info[0] &=
|
||||
~IEEE80211_HE_PHY_CAP0_CHANNEL_WIDTH_SET_80PLUS80_MHZ_IN_5G;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -848,7 +848,6 @@ enum txq_info_flags {
|
||||
*/
|
||||
struct txq_info {
|
||||
struct fq_tin tin;
|
||||
struct fq_flow def_flow;
|
||||
struct codel_vars def_cvars;
|
||||
struct codel_stats cstats;
|
||||
struct sk_buff_head frags;
|
||||
@ -1143,6 +1142,8 @@ enum mac80211_scan_state {
|
||||
SCAN_ABORT,
|
||||
};
|
||||
|
||||
DECLARE_STATIC_KEY_FALSE(aql_disable);
|
||||
|
||||
struct ieee80211_local {
|
||||
/* embed the driver visible part.
|
||||
* don't cast (use the static inlines below), but we keep
|
||||
|
@ -357,11 +357,14 @@ static int ieee80211_open(struct net_device *dev)
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
return ieee80211_do_open(&sdata->wdev, true);
|
||||
wiphy_lock(sdata->local->hw.wiphy);
|
||||
err = ieee80211_do_open(&sdata->wdev, true);
|
||||
wiphy_unlock(sdata->local->hw.wiphy);
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
|
||||
bool going_down)
|
||||
static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata, bool going_down)
|
||||
{
|
||||
struct ieee80211_local *local = sdata->local;
|
||||
unsigned long flags;
|
||||
@ -637,7 +640,9 @@ static int ieee80211_stop(struct net_device *dev)
|
||||
{
|
||||
struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
|
||||
|
||||
wiphy_lock(sdata->local->hw.wiphy);
|
||||
ieee80211_do_stop(sdata, true);
|
||||
wiphy_unlock(sdata->local->hw.wiphy);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -765,7 +770,7 @@ static const struct net_device_ops ieee80211_dataif_8023_ops = {
|
||||
.ndo_get_stats64 = ieee80211_get_stats64,
|
||||
};
|
||||
|
||||
static bool ieee80211_iftype_supports_encap_offload(enum nl80211_iftype iftype)
|
||||
static bool ieee80211_iftype_supports_hdr_offload(enum nl80211_iftype iftype)
|
||||
{
|
||||
switch (iftype) {
|
||||
/* P2P GO and client are mapped to AP/STATION types */
|
||||
@ -785,7 +790,7 @@ static bool ieee80211_set_sdata_offload_flags(struct ieee80211_sub_if_data *sdat
|
||||
flags = sdata->vif.offload_flags;
|
||||
|
||||
if (ieee80211_hw_check(&local->hw, SUPPORTS_TX_ENCAP_OFFLOAD) &&
|
||||
ieee80211_iftype_supports_encap_offload(sdata->vif.type)) {
|
||||
ieee80211_iftype_supports_hdr_offload(sdata->vif.type)) {
|
||||
flags |= IEEE80211_OFFLOAD_ENCAP_ENABLED;
|
||||
|
||||
if (!ieee80211_hw_check(&local->hw, SUPPORTS_TX_FRAG) &&
|
||||
@ -798,10 +803,21 @@ static bool ieee80211_set_sdata_offload_flags(struct ieee80211_sub_if_data *sdat
|
||||
flags &= ~IEEE80211_OFFLOAD_ENCAP_ENABLED;
|
||||
}
|
||||
|
||||
if (ieee80211_hw_check(&local->hw, SUPPORTS_RX_DECAP_OFFLOAD) &&
|
||||
ieee80211_iftype_supports_hdr_offload(sdata->vif.type)) {
|
||||
flags |= IEEE80211_OFFLOAD_DECAP_ENABLED;
|
||||
|
||||
if (local->monitors)
|
||||
flags &= ~IEEE80211_OFFLOAD_DECAP_ENABLED;
|
||||
} else {
|
||||
flags &= ~IEEE80211_OFFLOAD_DECAP_ENABLED;
|
||||
}
|
||||
|
||||
if (sdata->vif.offload_flags == flags)
|
||||
return false;
|
||||
|
||||
sdata->vif.offload_flags = flags;
|
||||
ieee80211_check_fast_rx_iface(sdata);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -819,7 +835,7 @@ static void ieee80211_set_vif_encap_ops(struct ieee80211_sub_if_data *sdata)
|
||||
}
|
||||
|
||||
if (!ieee80211_hw_check(&local->hw, SUPPORTS_TX_ENCAP_OFFLOAD) ||
|
||||
!ieee80211_iftype_supports_encap_offload(bss->vif.type))
|
||||
!ieee80211_iftype_supports_hdr_offload(bss->vif.type))
|
||||
return;
|
||||
|
||||
enabled = bss->vif.offload_flags & IEEE80211_OFFLOAD_ENCAP_ENABLED;
|
||||
@ -1965,7 +1981,7 @@ int ieee80211_if_add(struct ieee80211_local *local, const char *name,
|
||||
ndev->min_mtu = 256;
|
||||
ndev->max_mtu = local->hw.max_mtu;
|
||||
|
||||
ret = register_netdevice(ndev);
|
||||
ret = cfg80211_register_netdevice(ndev);
|
||||
if (ret) {
|
||||
free_netdev(ndev);
|
||||
return ret;
|
||||
@ -1995,10 +2011,9 @@ void ieee80211_if_remove(struct ieee80211_sub_if_data *sdata)
|
||||
|
||||
synchronize_rcu();
|
||||
|
||||
if (sdata->dev) {
|
||||
unregister_netdevice(sdata->dev);
|
||||
} else {
|
||||
cfg80211_unregister_wdev(&sdata->wdev);
|
||||
cfg80211_unregister_wdev(&sdata->wdev);
|
||||
|
||||
if (!sdata->dev) {
|
||||
ieee80211_teardown_sdata(sdata);
|
||||
kfree(sdata);
|
||||
}
|
||||
@ -2047,13 +2062,16 @@ void ieee80211_remove_interfaces(struct ieee80211_local *local)
|
||||
list_add(&sdata->list, &wdev_list);
|
||||
}
|
||||
mutex_unlock(&local->iflist_mtx);
|
||||
|
||||
unregister_netdevice_many(&unreg_list);
|
||||
|
||||
wiphy_lock(local->hw.wiphy);
|
||||
list_for_each_entry_safe(sdata, tmp, &wdev_list, list) {
|
||||
list_del(&sdata->list);
|
||||
cfg80211_unregister_wdev(&sdata->wdev);
|
||||
kfree(sdata);
|
||||
}
|
||||
wiphy_unlock(local->hw.wiphy);
|
||||
}
|
||||
|
||||
static int netdev_notify(struct notifier_block *nb,
|
||||
|
@ -887,7 +887,7 @@ void ieee80211_reenable_keys(struct ieee80211_sub_if_data *sdata)
|
||||
struct ieee80211_key *key;
|
||||
struct ieee80211_sub_if_data *vlan;
|
||||
|
||||
ASSERT_RTNL();
|
||||
lockdep_assert_wiphy(sdata->local->hw.wiphy);
|
||||
|
||||
mutex_lock(&sdata->local->key_mtx);
|
||||
|
||||
@ -924,7 +924,7 @@ void ieee80211_iter_keys(struct ieee80211_hw *hw,
|
||||
struct ieee80211_key *key, *tmp;
|
||||
struct ieee80211_sub_if_data *sdata;
|
||||
|
||||
ASSERT_RTNL();
|
||||
lockdep_assert_wiphy(hw->wiphy);
|
||||
|
||||
mutex_lock(&local->key_mtx);
|
||||
if (vif) {
|
||||
|
@ -261,7 +261,9 @@ static void ieee80211_restart_work(struct work_struct *work)
|
||||
"%s called with hardware scan in progress\n", __func__);
|
||||
|
||||
flush_work(&local->radar_detected_work);
|
||||
/* we might do interface manipulations, so need both */
|
||||
rtnl_lock();
|
||||
wiphy_lock(local->hw.wiphy);
|
||||
list_for_each_entry(sdata, &local->interfaces, list) {
|
||||
/*
|
||||
* XXX: there may be more work for other vif types and even
|
||||
@ -293,6 +295,7 @@ static void ieee80211_restart_work(struct work_struct *work)
|
||||
synchronize_net();
|
||||
|
||||
ieee80211_reconfig(local);
|
||||
wiphy_unlock(local->hw.wiphy);
|
||||
rtnl_unlock();
|
||||
}
|
||||
|
||||
@ -1272,6 +1275,7 @@ int ieee80211_register_hw(struct ieee80211_hw *hw)
|
||||
rate_control_add_debugfs(local);
|
||||
|
||||
rtnl_lock();
|
||||
wiphy_lock(hw->wiphy);
|
||||
|
||||
/* add one default STA interface if supported */
|
||||
if (local->hw.wiphy->interface_modes & BIT(NL80211_IFTYPE_STATION) &&
|
||||
@ -1285,6 +1289,7 @@ int ieee80211_register_hw(struct ieee80211_hw *hw)
|
||||
"Failed to add default virtual iface\n");
|
||||
}
|
||||
|
||||
wiphy_unlock(hw->wiphy);
|
||||
rtnl_unlock();
|
||||
|
||||
#ifdef CONFIG_INET
|
||||
|
@ -1,4 +1,8 @@
|
||||
// SPDX-License-Identifier: GPL-2.0
|
||||
/*
|
||||
* Portions
|
||||
* Copyright (C) 2020-2021 Intel Corporation
|
||||
*/
|
||||
#include <net/mac80211.h>
|
||||
#include <net/rtnetlink.h>
|
||||
|
||||
@ -11,7 +15,7 @@ static void ieee80211_sched_scan_cancel(struct ieee80211_local *local)
|
||||
{
|
||||
if (ieee80211_request_sched_scan_stop(local))
|
||||
return;
|
||||
cfg80211_sched_scan_stopped_rtnl(local->hw.wiphy, 0);
|
||||
cfg80211_sched_scan_stopped_locked(local->hw.wiphy, 0);
|
||||
}
|
||||
|
||||
int __ieee80211_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan)
|
||||
|
@ -1,574 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2008 Felix Fietkau <nbd@openwrt.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* Based on minstrel.c:
|
||||
* Copyright (C) 2005-2007 Derek Smithies <derek@indranet.co.nz>
|
||||
* Sponsored by Indranet Technologies Ltd
|
||||
*
|
||||
* Based on sample.c:
|
||||
* Copyright (c) 2005 John Bicket
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer,
|
||||
* without modification.
|
||||
* 2. Redistributions in binary form must reproduce at minimum a disclaimer
|
||||
* similar to the "NO WARRANTY" disclaimer below ("Disclaimer") and any
|
||||
* redistribution must be conditioned upon including a substantially
|
||||
* similar Disclaimer requirement for further binary redistribution.
|
||||
* 3. Neither the names of the above-listed copyright holders nor the names
|
||||
* of any contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* Alternatively, this software may be distributed under the terms of the
|
||||
* GNU General Public License ("GPL") version 2 as published by the Free
|
||||
* Software Foundation.
|
||||
*
|
||||
* NO WARRANTY
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF NONINFRINGEMENT, MERCHANTIBILITY
|
||||
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
||||
* THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY,
|
||||
* OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||
* IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
||||
* THE POSSIBILITY OF SUCH DAMAGES.
|
||||
*/
|
||||
#include <linux/netdevice.h>
|
||||
#include <linux/types.h>
|
||||
#include <linux/skbuff.h>
|
||||
#include <linux/debugfs.h>
|
||||
#include <linux/random.h>
|
||||
#include <linux/ieee80211.h>
|
||||
#include <linux/slab.h>
|
||||
#include <net/mac80211.h>
|
||||
#include "rate.h"
|
||||
#include "rc80211_minstrel.h"
|
||||
|
||||
#define SAMPLE_TBL(_mi, _idx, _col) \
|
||||
_mi->sample_table[(_idx * SAMPLE_COLUMNS) + _col]
|
||||
|
||||
/* convert mac80211 rate index to local array index */
|
||||
static inline int
|
||||
rix_to_ndx(struct minstrel_sta_info *mi, int rix)
|
||||
{
|
||||
int i = rix;
|
||||
for (i = rix; i >= 0; i--)
|
||||
if (mi->r[i].rix == rix)
|
||||
break;
|
||||
return i;
|
||||
}
|
||||
|
||||
/* return current EMWA throughput */
|
||||
int minstrel_get_tp_avg(struct minstrel_rate *mr, int prob_avg)
|
||||
{
|
||||
int usecs;
|
||||
|
||||
usecs = mr->perfect_tx_time;
|
||||
if (!usecs)
|
||||
usecs = 1000000;
|
||||
|
||||
/* reset thr. below 10% success */
|
||||
if (mr->stats.prob_avg < MINSTREL_FRAC(10, 100))
|
||||
return 0;
|
||||
|
||||
if (prob_avg > MINSTREL_FRAC(90, 100))
|
||||
return MINSTREL_TRUNC(100000 * (MINSTREL_FRAC(90, 100) / usecs));
|
||||
else
|
||||
return MINSTREL_TRUNC(100000 * (prob_avg / usecs));
|
||||
}
|
||||
|
||||
/* find & sort topmost throughput rates */
|
||||
static inline void
|
||||
minstrel_sort_best_tp_rates(struct minstrel_sta_info *mi, int i, u8 *tp_list)
|
||||
{
|
||||
int j;
|
||||
struct minstrel_rate_stats *tmp_mrs;
|
||||
struct minstrel_rate_stats *cur_mrs = &mi->r[i].stats;
|
||||
|
||||
for (j = MAX_THR_RATES; j > 0; --j) {
|
||||
tmp_mrs = &mi->r[tp_list[j - 1]].stats;
|
||||
if (minstrel_get_tp_avg(&mi->r[i], cur_mrs->prob_avg) <=
|
||||
minstrel_get_tp_avg(&mi->r[tp_list[j - 1]], tmp_mrs->prob_avg))
|
||||
break;
|
||||
}
|
||||
|
||||
if (j < MAX_THR_RATES - 1)
|
||||
memmove(&tp_list[j + 1], &tp_list[j], MAX_THR_RATES - (j + 1));
|
||||
if (j < MAX_THR_RATES)
|
||||
tp_list[j] = i;
|
||||
}
|
||||
|
||||
static void
|
||||
minstrel_set_rate(struct minstrel_sta_info *mi, struct ieee80211_sta_rates *ratetbl,
|
||||
int offset, int idx)
|
||||
{
|
||||
struct minstrel_rate *r = &mi->r[idx];
|
||||
|
||||
ratetbl->rate[offset].idx = r->rix;
|
||||
ratetbl->rate[offset].count = r->adjusted_retry_count;
|
||||
ratetbl->rate[offset].count_cts = r->retry_count_cts;
|
||||
ratetbl->rate[offset].count_rts = r->stats.retry_count_rtscts;
|
||||
}
|
||||
|
||||
static void
|
||||
minstrel_update_rates(struct minstrel_priv *mp, struct minstrel_sta_info *mi)
|
||||
{
|
||||
struct ieee80211_sta_rates *ratetbl;
|
||||
int i = 0;
|
||||
|
||||
ratetbl = kzalloc(sizeof(*ratetbl), GFP_ATOMIC);
|
||||
if (!ratetbl)
|
||||
return;
|
||||
|
||||
/* Start with max_tp_rate */
|
||||
minstrel_set_rate(mi, ratetbl, i++, mi->max_tp_rate[0]);
|
||||
|
||||
if (mp->hw->max_rates >= 3) {
|
||||
/* At least 3 tx rates supported, use max_tp_rate2 next */
|
||||
minstrel_set_rate(mi, ratetbl, i++, mi->max_tp_rate[1]);
|
||||
}
|
||||
|
||||
if (mp->hw->max_rates >= 2) {
|
||||
/* At least 2 tx rates supported, use max_prob_rate next */
|
||||
minstrel_set_rate(mi, ratetbl, i++, mi->max_prob_rate);
|
||||
}
|
||||
|
||||
/* Use lowest rate last */
|
||||
ratetbl->rate[i].idx = mi->lowest_rix;
|
||||
ratetbl->rate[i].count = mp->max_retry;
|
||||
ratetbl->rate[i].count_cts = mp->max_retry;
|
||||
ratetbl->rate[i].count_rts = mp->max_retry;
|
||||
|
||||
rate_control_set_rates(mp->hw, mi->sta, ratetbl);
|
||||
}
|
||||
|
||||
/*
|
||||
* Recalculate statistics and counters of a given rate
|
||||
*/
|
||||
void
|
||||
minstrel_calc_rate_stats(struct minstrel_priv *mp,
|
||||
struct minstrel_rate_stats *mrs)
|
||||
{
|
||||
unsigned int cur_prob;
|
||||
|
||||
if (unlikely(mrs->attempts > 0)) {
|
||||
mrs->sample_skipped = 0;
|
||||
cur_prob = MINSTREL_FRAC(mrs->success, mrs->attempts);
|
||||
if (mp->new_avg) {
|
||||
minstrel_filter_avg_add(&mrs->prob_avg,
|
||||
&mrs->prob_avg_1, cur_prob);
|
||||
} else if (unlikely(!mrs->att_hist)) {
|
||||
mrs->prob_avg = cur_prob;
|
||||
} else {
|
||||
/*update exponential weighted moving avarage */
|
||||
mrs->prob_avg = minstrel_ewma(mrs->prob_avg,
|
||||
cur_prob,
|
||||
EWMA_LEVEL);
|
||||
}
|
||||
mrs->att_hist += mrs->attempts;
|
||||
mrs->succ_hist += mrs->success;
|
||||
} else {
|
||||
mrs->sample_skipped++;
|
||||
}
|
||||
|
||||
mrs->last_success = mrs->success;
|
||||
mrs->last_attempts = mrs->attempts;
|
||||
mrs->success = 0;
|
||||
mrs->attempts = 0;
|
||||
}
|
||||
|
||||
static void
|
||||
minstrel_update_stats(struct minstrel_priv *mp, struct minstrel_sta_info *mi)
|
||||
{
|
||||
u8 tmp_tp_rate[MAX_THR_RATES];
|
||||
u8 tmp_prob_rate = 0;
|
||||
int i, tmp_cur_tp, tmp_prob_tp;
|
||||
|
||||
for (i = 0; i < MAX_THR_RATES; i++)
|
||||
tmp_tp_rate[i] = 0;
|
||||
|
||||
for (i = 0; i < mi->n_rates; i++) {
|
||||
struct minstrel_rate *mr = &mi->r[i];
|
||||
struct minstrel_rate_stats *mrs = &mi->r[i].stats;
|
||||
struct minstrel_rate_stats *tmp_mrs = &mi->r[tmp_prob_rate].stats;
|
||||
|
||||
/* Update statistics of success probability per rate */
|
||||
minstrel_calc_rate_stats(mp, mrs);
|
||||
|
||||
/* Sample less often below the 10% chance of success.
|
||||
* Sample less often above the 95% chance of success. */
|
||||
if (mrs->prob_avg > MINSTREL_FRAC(95, 100) ||
|
||||
mrs->prob_avg < MINSTREL_FRAC(10, 100)) {
|
||||
mr->adjusted_retry_count = mrs->retry_count >> 1;
|
||||
if (mr->adjusted_retry_count > 2)
|
||||
mr->adjusted_retry_count = 2;
|
||||
mr->sample_limit = 4;
|
||||
} else {
|
||||
mr->sample_limit = -1;
|
||||
mr->adjusted_retry_count = mrs->retry_count;
|
||||
}
|
||||
if (!mr->adjusted_retry_count)
|
||||
mr->adjusted_retry_count = 2;
|
||||
|
||||
minstrel_sort_best_tp_rates(mi, i, tmp_tp_rate);
|
||||
|
||||
/* To determine the most robust rate (max_prob_rate) used at
|
||||
* 3rd mmr stage we distinct between two cases:
|
||||
* (1) if any success probabilitiy >= 95%, out of those rates
|
||||
* choose the maximum throughput rate as max_prob_rate
|
||||
* (2) if all success probabilities < 95%, the rate with
|
||||
* highest success probability is chosen as max_prob_rate */
|
||||
if (mrs->prob_avg >= MINSTREL_FRAC(95, 100)) {
|
||||
tmp_cur_tp = minstrel_get_tp_avg(mr, mrs->prob_avg);
|
||||
tmp_prob_tp = minstrel_get_tp_avg(&mi->r[tmp_prob_rate],
|
||||
tmp_mrs->prob_avg);
|
||||
if (tmp_cur_tp >= tmp_prob_tp)
|
||||
tmp_prob_rate = i;
|
||||
} else {
|
||||
if (mrs->prob_avg >= tmp_mrs->prob_avg)
|
||||
tmp_prob_rate = i;
|
||||
}
|
||||
}
|
||||
|
||||
/* Assign the new rate set */
|
||||
memcpy(mi->max_tp_rate, tmp_tp_rate, sizeof(mi->max_tp_rate));
|
||||
mi->max_prob_rate = tmp_prob_rate;
|
||||
|
||||
#ifdef CONFIG_MAC80211_DEBUGFS
|
||||
/* use fixed index if set */
|
||||
if (mp->fixed_rate_idx != -1) {
|
||||
mi->max_tp_rate[0] = mp->fixed_rate_idx;
|
||||
mi->max_tp_rate[1] = mp->fixed_rate_idx;
|
||||
mi->max_prob_rate = mp->fixed_rate_idx;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Reset update timer */
|
||||
mi->last_stats_update = jiffies;
|
||||
|
||||
minstrel_update_rates(mp, mi);
|
||||
}
|
||||
|
||||
static void
|
||||
minstrel_tx_status(void *priv, struct ieee80211_supported_band *sband,
|
||||
void *priv_sta, struct ieee80211_tx_status *st)
|
||||
{
|
||||
struct ieee80211_tx_info *info = st->info;
|
||||
struct minstrel_priv *mp = priv;
|
||||
struct minstrel_sta_info *mi = priv_sta;
|
||||
struct ieee80211_tx_rate *ar = info->status.rates;
|
||||
int i, ndx;
|
||||
int success;
|
||||
|
||||
success = !!(info->flags & IEEE80211_TX_STAT_ACK);
|
||||
|
||||
for (i = 0; i < IEEE80211_TX_MAX_RATES; i++) {
|
||||
if (ar[i].idx < 0 || !ar[i].count)
|
||||
break;
|
||||
|
||||
ndx = rix_to_ndx(mi, ar[i].idx);
|
||||
if (ndx < 0)
|
||||
continue;
|
||||
|
||||
mi->r[ndx].stats.attempts += ar[i].count;
|
||||
|
||||
if ((i != IEEE80211_TX_MAX_RATES - 1) && (ar[i + 1].idx < 0))
|
||||
mi->r[ndx].stats.success += success;
|
||||
}
|
||||
|
||||
if (time_after(jiffies, mi->last_stats_update +
|
||||
mp->update_interval / (mp->new_avg ? 2 : 1)))
|
||||
minstrel_update_stats(mp, mi);
|
||||
}
|
||||
|
||||
|
||||
static inline unsigned int
|
||||
minstrel_get_retry_count(struct minstrel_rate *mr,
|
||||
struct ieee80211_tx_info *info)
|
||||
{
|
||||
u8 retry = mr->adjusted_retry_count;
|
||||
|
||||
if (info->control.use_rts)
|
||||
retry = max_t(u8, 2, min(mr->stats.retry_count_rtscts, retry));
|
||||
else if (info->control.use_cts_prot)
|
||||
retry = max_t(u8, 2, min(mr->retry_count_cts, retry));
|
||||
return retry;
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
minstrel_get_next_sample(struct minstrel_sta_info *mi)
|
||||
{
|
||||
unsigned int sample_ndx;
|
||||
sample_ndx = SAMPLE_TBL(mi, mi->sample_row, mi->sample_column);
|
||||
mi->sample_row++;
|
||||
if ((int) mi->sample_row >= mi->n_rates) {
|
||||
mi->sample_row = 0;
|
||||
mi->sample_column++;
|
||||
if (mi->sample_column >= SAMPLE_COLUMNS)
|
||||
mi->sample_column = 0;
|
||||
}
|
||||
return sample_ndx;
|
||||
}
|
||||
|
||||
static void
|
||||
minstrel_get_rate(void *priv, struct ieee80211_sta *sta,
|
||||
void *priv_sta, struct ieee80211_tx_rate_control *txrc)
|
||||
{
|
||||
struct sk_buff *skb = txrc->skb;
|
||||
struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
|
||||
struct minstrel_sta_info *mi = priv_sta;
|
||||
struct minstrel_priv *mp = priv;
|
||||
struct ieee80211_tx_rate *rate = &info->control.rates[0];
|
||||
struct minstrel_rate *msr, *mr;
|
||||
unsigned int ndx;
|
||||
bool mrr_capable;
|
||||
bool prev_sample;
|
||||
int delta;
|
||||
int sampling_ratio;
|
||||
|
||||
/* check multi-rate-retry capabilities & adjust lookaround_rate */
|
||||
mrr_capable = mp->has_mrr &&
|
||||
!txrc->rts &&
|
||||
!txrc->bss_conf->use_cts_prot;
|
||||
if (mrr_capable)
|
||||
sampling_ratio = mp->lookaround_rate_mrr;
|
||||
else
|
||||
sampling_ratio = mp->lookaround_rate;
|
||||
|
||||
/* increase sum packet counter */
|
||||
mi->total_packets++;
|
||||
|
||||
#ifdef CONFIG_MAC80211_DEBUGFS
|
||||
if (mp->fixed_rate_idx != -1)
|
||||
return;
|
||||
#endif
|
||||
|
||||
/* Don't use EAPOL frames for sampling on non-mrr hw */
|
||||
if (mp->hw->max_rates == 1 &&
|
||||
(info->control.flags & IEEE80211_TX_CTRL_PORT_CTRL_PROTO))
|
||||
return;
|
||||
|
||||
delta = (mi->total_packets * sampling_ratio / 100) -
|
||||
mi->sample_packets;
|
||||
|
||||
/* delta < 0: no sampling required */
|
||||
prev_sample = mi->prev_sample;
|
||||
mi->prev_sample = false;
|
||||
if (delta < 0 || (!mrr_capable && prev_sample))
|
||||
return;
|
||||
|
||||
if (mi->total_packets >= 10000) {
|
||||
mi->sample_packets = 0;
|
||||
mi->total_packets = 0;
|
||||
} else if (delta > mi->n_rates * 2) {
|
||||
/* With multi-rate retry, not every planned sample
|
||||
* attempt actually gets used, due to the way the retry
|
||||
* chain is set up - [max_tp,sample,prob,lowest] for
|
||||
* sample_rate < max_tp.
|
||||
*
|
||||
* If there's too much sampling backlog and the link
|
||||
* starts getting worse, minstrel would start bursting
|
||||
* out lots of sampling frames, which would result
|
||||
* in a large throughput loss. */
|
||||
mi->sample_packets += (delta - mi->n_rates * 2);
|
||||
}
|
||||
|
||||
/* get next random rate sample */
|
||||
ndx = minstrel_get_next_sample(mi);
|
||||
msr = &mi->r[ndx];
|
||||
mr = &mi->r[mi->max_tp_rate[0]];
|
||||
|
||||
/* Decide if direct ( 1st mrr stage) or indirect (2nd mrr stage)
|
||||
* rate sampling method should be used.
|
||||
* Respect such rates that are not sampled for 20 interations.
|
||||
*/
|
||||
if (msr->perfect_tx_time < mr->perfect_tx_time ||
|
||||
msr->stats.sample_skipped >= 20) {
|
||||
if (!msr->sample_limit)
|
||||
return;
|
||||
|
||||
mi->sample_packets++;
|
||||
if (msr->sample_limit > 0)
|
||||
msr->sample_limit--;
|
||||
}
|
||||
|
||||
/* If we're not using MRR and the sampling rate already
|
||||
* has a probability of >95%, we shouldn't be attempting
|
||||
* to use it, as this only wastes precious airtime */
|
||||
if (!mrr_capable &&
|
||||
(mi->r[ndx].stats.prob_avg > MINSTREL_FRAC(95, 100)))
|
||||
return;
|
||||
|
||||
mi->prev_sample = true;
|
||||
|
||||
rate->idx = mi->r[ndx].rix;
|
||||
rate->count = minstrel_get_retry_count(&mi->r[ndx], info);
|
||||
info->flags |= IEEE80211_TX_CTL_RATE_CTRL_PROBE;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
calc_rate_durations(enum nl80211_band band,
|
||||
struct minstrel_rate *d,
|
||||
struct ieee80211_rate *rate,
|
||||
struct cfg80211_chan_def *chandef)
|
||||
{
|
||||
int erp = !!(rate->flags & IEEE80211_RATE_ERP_G);
|
||||
int shift = ieee80211_chandef_get_shift(chandef);
|
||||
|
||||
d->perfect_tx_time = ieee80211_frame_duration(band, 1200,
|
||||
DIV_ROUND_UP(rate->bitrate, 1 << shift), erp, 1,
|
||||
shift);
|
||||
d->ack_time = ieee80211_frame_duration(band, 10,
|
||||
DIV_ROUND_UP(rate->bitrate, 1 << shift), erp, 1,
|
||||
shift);
|
||||
}
|
||||
|
||||
static void
|
||||
init_sample_table(struct minstrel_sta_info *mi)
|
||||
{
|
||||
unsigned int i, col, new_idx;
|
||||
u8 rnd[8];
|
||||
|
||||
mi->sample_column = 0;
|
||||
mi->sample_row = 0;
|
||||
memset(mi->sample_table, 0xff, SAMPLE_COLUMNS * mi->n_rates);
|
||||
|
||||
for (col = 0; col < SAMPLE_COLUMNS; col++) {
|
||||
prandom_bytes(rnd, sizeof(rnd));
|
||||
for (i = 0; i < mi->n_rates; i++) {
|
||||
new_idx = (i + rnd[i & 7]) % mi->n_rates;
|
||||
while (SAMPLE_TBL(mi, new_idx, col) != 0xff)
|
||||
new_idx = (new_idx + 1) % mi->n_rates;
|
||||
|
||||
SAMPLE_TBL(mi, new_idx, col) = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
minstrel_rate_init(void *priv, struct ieee80211_supported_band *sband,
|
||||
struct cfg80211_chan_def *chandef,
|
||||
struct ieee80211_sta *sta, void *priv_sta)
|
||||
{
|
||||
struct minstrel_sta_info *mi = priv_sta;
|
||||
struct minstrel_priv *mp = priv;
|
||||
struct ieee80211_rate *ctl_rate;
|
||||
unsigned int i, n = 0;
|
||||
unsigned int t_slot = 9; /* FIXME: get real slot time */
|
||||
u32 rate_flags;
|
||||
|
||||
mi->sta = sta;
|
||||
mi->lowest_rix = rate_lowest_index(sband, sta);
|
||||
ctl_rate = &sband->bitrates[mi->lowest_rix];
|
||||
mi->sp_ack_dur = ieee80211_frame_duration(sband->band, 10,
|
||||
ctl_rate->bitrate,
|
||||
!!(ctl_rate->flags & IEEE80211_RATE_ERP_G), 1,
|
||||
ieee80211_chandef_get_shift(chandef));
|
||||
|
||||
rate_flags = ieee80211_chandef_rate_flags(&mp->hw->conf.chandef);
|
||||
memset(mi->max_tp_rate, 0, sizeof(mi->max_tp_rate));
|
||||
mi->max_prob_rate = 0;
|
||||
|
||||
for (i = 0; i < sband->n_bitrates; i++) {
|
||||
struct minstrel_rate *mr = &mi->r[n];
|
||||
struct minstrel_rate_stats *mrs = &mi->r[n].stats;
|
||||
unsigned int tx_time = 0, tx_time_cts = 0, tx_time_rtscts = 0;
|
||||
unsigned int tx_time_single;
|
||||
unsigned int cw = mp->cw_min;
|
||||
int shift;
|
||||
|
||||
if (!rate_supported(sta, sband->band, i))
|
||||
continue;
|
||||
if ((rate_flags & sband->bitrates[i].flags) != rate_flags)
|
||||
continue;
|
||||
|
||||
n++;
|
||||
memset(mr, 0, sizeof(*mr));
|
||||
memset(mrs, 0, sizeof(*mrs));
|
||||
|
||||
mr->rix = i;
|
||||
shift = ieee80211_chandef_get_shift(chandef);
|
||||
mr->bitrate = DIV_ROUND_UP(sband->bitrates[i].bitrate,
|
||||
(1 << shift) * 5);
|
||||
calc_rate_durations(sband->band, mr, &sband->bitrates[i],
|
||||
chandef);
|
||||
|
||||
/* calculate maximum number of retransmissions before
|
||||
* fallback (based on maximum segment size) */
|
||||
mr->sample_limit = -1;
|
||||
mrs->retry_count = 1;
|
||||
mr->retry_count_cts = 1;
|
||||
mrs->retry_count_rtscts = 1;
|
||||
tx_time = mr->perfect_tx_time + mi->sp_ack_dur;
|
||||
do {
|
||||
/* add one retransmission */
|
||||
tx_time_single = mr->ack_time + mr->perfect_tx_time;
|
||||
|
||||
/* contention window */
|
||||
tx_time_single += (t_slot * cw) >> 1;
|
||||
cw = min((cw << 1) | 1, mp->cw_max);
|
||||
|
||||
tx_time += tx_time_single;
|
||||
tx_time_cts += tx_time_single + mi->sp_ack_dur;
|
||||
tx_time_rtscts += tx_time_single + 2 * mi->sp_ack_dur;
|
||||
if ((tx_time_cts < mp->segment_size) &&
|
||||
(mr->retry_count_cts < mp->max_retry))
|
||||
mr->retry_count_cts++;
|
||||
if ((tx_time_rtscts < mp->segment_size) &&
|
||||
(mrs->retry_count_rtscts < mp->max_retry))
|
||||
mrs->retry_count_rtscts++;
|
||||
} while ((tx_time < mp->segment_size) &&
|
||||
(++mr->stats.retry_count < mp->max_retry));
|
||||
mr->adjusted_retry_count = mrs->retry_count;
|
||||
if (!(sband->bitrates[i].flags & IEEE80211_RATE_ERP_G))
|
||||
mr->retry_count_cts = mrs->retry_count;
|
||||
}
|
||||
|
||||
for (i = n; i < sband->n_bitrates; i++) {
|
||||
struct minstrel_rate *mr = &mi->r[i];
|
||||
mr->rix = -1;
|
||||
}
|
||||
|
||||
mi->n_rates = n;
|
||||
mi->last_stats_update = jiffies;
|
||||
|
||||
init_sample_table(mi);
|
||||
minstrel_update_rates(mp, mi);
|
||||
}
|
||||
|
||||
static u32 minstrel_get_expected_throughput(void *priv_sta)
|
||||
{
|
||||
struct minstrel_sta_info *mi = priv_sta;
|
||||
struct minstrel_rate_stats *tmp_mrs;
|
||||
int idx = mi->max_tp_rate[0];
|
||||
int tmp_cur_tp;
|
||||
|
||||
/* convert pkt per sec in kbps (1200 is the average pkt size used for
|
||||
* computing cur_tp
|
||||
*/
|
||||
tmp_mrs = &mi->r[idx].stats;
|
||||
tmp_cur_tp = minstrel_get_tp_avg(&mi->r[idx], tmp_mrs->prob_avg) * 10;
|
||||
tmp_cur_tp = tmp_cur_tp * 1200 * 8 / 1024;
|
||||
|
||||
return tmp_cur_tp;
|
||||
}
|
||||
|
||||
const struct rate_control_ops mac80211_minstrel = {
|
||||
.tx_status_ext = minstrel_tx_status,
|
||||
.get_rate = minstrel_get_rate,
|
||||
.rate_init = minstrel_rate_init,
|
||||
.get_expected_throughput = minstrel_get_expected_throughput,
|
||||
};
|
@ -1,184 +0,0 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0-only */
|
||||
/*
|
||||
* Copyright (C) 2008 Felix Fietkau <nbd@openwrt.org>
|
||||
*/
|
||||
|
||||
#ifndef __RC_MINSTREL_H
|
||||
#define __RC_MINSTREL_H
|
||||
|
||||
#define EWMA_LEVEL 96 /* ewma weighting factor [/EWMA_DIV] */
|
||||
#define EWMA_DIV 128
|
||||
#define SAMPLE_COLUMNS 10 /* number of columns in sample table */
|
||||
|
||||
/* scaled fraction values */
|
||||
#define MINSTREL_SCALE 12
|
||||
#define MINSTREL_FRAC(val, div) (((val) << MINSTREL_SCALE) / div)
|
||||
#define MINSTREL_TRUNC(val) ((val) >> MINSTREL_SCALE)
|
||||
|
||||
/* number of highest throughput rates to consider*/
|
||||
#define MAX_THR_RATES 4
|
||||
|
||||
/*
|
||||
* Coefficients for moving average with noise filter (period=16),
|
||||
* scaled by 10 bits
|
||||
*
|
||||
* a1 = exp(-pi * sqrt(2) / period)
|
||||
* coeff2 = 2 * a1 * cos(sqrt(2) * 2 * pi / period)
|
||||
* coeff3 = -sqr(a1)
|
||||
* coeff1 = 1 - coeff2 - coeff3
|
||||
*/
|
||||
#define MINSTREL_AVG_COEFF1 (MINSTREL_FRAC(1, 1) - \
|
||||
MINSTREL_AVG_COEFF2 - \
|
||||
MINSTREL_AVG_COEFF3)
|
||||
#define MINSTREL_AVG_COEFF2 0x00001499
|
||||
#define MINSTREL_AVG_COEFF3 -0x0000092e
|
||||
|
||||
/*
|
||||
* Perform EWMA (Exponentially Weighted Moving Average) calculation
|
||||
*/
|
||||
static inline int
|
||||
minstrel_ewma(int old, int new, int weight)
|
||||
{
|
||||
int diff, incr;
|
||||
|
||||
diff = new - old;
|
||||
incr = (EWMA_DIV - weight) * diff / EWMA_DIV;
|
||||
|
||||
return old + incr;
|
||||
}
|
||||
|
||||
static inline int minstrel_filter_avg_add(u16 *prev_1, u16 *prev_2, s32 in)
|
||||
{
|
||||
s32 out_1 = *prev_1;
|
||||
s32 out_2 = *prev_2;
|
||||
s32 val;
|
||||
|
||||
if (!in)
|
||||
in += 1;
|
||||
|
||||
if (!out_1) {
|
||||
val = out_1 = in;
|
||||
goto out;
|
||||
}
|
||||
|
||||
val = MINSTREL_AVG_COEFF1 * in;
|
||||
val += MINSTREL_AVG_COEFF2 * out_1;
|
||||
val += MINSTREL_AVG_COEFF3 * out_2;
|
||||
val >>= MINSTREL_SCALE;
|
||||
|
||||
if (val > 1 << MINSTREL_SCALE)
|
||||
val = 1 << MINSTREL_SCALE;
|
||||
if (val < 0)
|
||||
val = 1;
|
||||
|
||||
out:
|
||||
*prev_2 = out_1;
|
||||
*prev_1 = val;
|
||||
|
||||
return val;
|
||||
}
|
||||
|
||||
struct minstrel_rate_stats {
|
||||
/* current / last sampling period attempts/success counters */
|
||||
u16 attempts, last_attempts;
|
||||
u16 success, last_success;
|
||||
|
||||
/* total attempts/success counters */
|
||||
u32 att_hist, succ_hist;
|
||||
|
||||
/* prob_avg - moving average of prob */
|
||||
u16 prob_avg;
|
||||
u16 prob_avg_1;
|
||||
|
||||
/* maximum retry counts */
|
||||
u8 retry_count;
|
||||
u8 retry_count_rtscts;
|
||||
|
||||
u8 sample_skipped;
|
||||
bool retry_updated;
|
||||
};
|
||||
|
||||
struct minstrel_rate {
|
||||
int bitrate;
|
||||
|
||||
s8 rix;
|
||||
u8 retry_count_cts;
|
||||
u8 adjusted_retry_count;
|
||||
|
||||
unsigned int perfect_tx_time;
|
||||
unsigned int ack_time;
|
||||
|
||||
int sample_limit;
|
||||
|
||||
struct minstrel_rate_stats stats;
|
||||
};
|
||||
|
||||
struct minstrel_sta_info {
|
||||
struct ieee80211_sta *sta;
|
||||
|
||||
unsigned long last_stats_update;
|
||||
unsigned int sp_ack_dur;
|
||||
unsigned int rate_avg;
|
||||
|
||||
unsigned int lowest_rix;
|
||||
|
||||
u8 max_tp_rate[MAX_THR_RATES];
|
||||
u8 max_prob_rate;
|
||||
unsigned int total_packets;
|
||||
unsigned int sample_packets;
|
||||
|
||||
unsigned int sample_row;
|
||||
unsigned int sample_column;
|
||||
|
||||
int n_rates;
|
||||
struct minstrel_rate *r;
|
||||
bool prev_sample;
|
||||
|
||||
/* sampling table */
|
||||
u8 *sample_table;
|
||||
};
|
||||
|
||||
struct minstrel_priv {
|
||||
struct ieee80211_hw *hw;
|
||||
bool has_mrr;
|
||||
bool new_avg;
|
||||
u32 sample_switch;
|
||||
unsigned int cw_min;
|
||||
unsigned int cw_max;
|
||||
unsigned int max_retry;
|
||||
unsigned int segment_size;
|
||||
unsigned int update_interval;
|
||||
unsigned int lookaround_rate;
|
||||
unsigned int lookaround_rate_mrr;
|
||||
|
||||
u8 cck_rates[4];
|
||||
|
||||
#ifdef CONFIG_MAC80211_DEBUGFS
|
||||
/*
|
||||
* enable fixed rate processing per RC
|
||||
* - write static index to debugfs:ieee80211/phyX/rc/fixed_rate_idx
|
||||
* - write -1 to enable RC processing again
|
||||
* - setting will be applied on next update
|
||||
*/
|
||||
u32 fixed_rate_idx;
|
||||
#endif
|
||||
};
|
||||
|
||||
struct minstrel_debugfs_info {
|
||||
size_t len;
|
||||
char buf[];
|
||||
};
|
||||
|
||||
extern const struct rate_control_ops mac80211_minstrel;
|
||||
void minstrel_add_sta_debugfs(void *priv, void *priv_sta, struct dentry *dir);
|
||||
|
||||
/* Recalculate success probabilities and counters for a given rate using EWMA */
|
||||
void minstrel_calc_rate_stats(struct minstrel_priv *mp,
|
||||
struct minstrel_rate_stats *mrs);
|
||||
int minstrel_get_tp_avg(struct minstrel_rate *mr, int prob_avg);
|
||||
|
||||
/* debugfs */
|
||||
int minstrel_stats_open(struct inode *inode, struct file *file);
|
||||
int minstrel_stats_csv_open(struct inode *inode, struct file *file);
|
||||
|
||||
#endif
|
@ -1,172 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2008 Felix Fietkau <nbd@openwrt.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* Based on minstrel.c:
|
||||
* Copyright (C) 2005-2007 Derek Smithies <derek@indranet.co.nz>
|
||||
* Sponsored by Indranet Technologies Ltd
|
||||
*
|
||||
* Based on sample.c:
|
||||
* Copyright (c) 2005 John Bicket
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer,
|
||||
* without modification.
|
||||
* 2. Redistributions in binary form must reproduce at minimum a disclaimer
|
||||
* similar to the "NO WARRANTY" disclaimer below ("Disclaimer") and any
|
||||
* redistribution must be conditioned upon including a substantially
|
||||
* similar Disclaimer requirement for further binary redistribution.
|
||||
* 3. Neither the names of the above-listed copyright holders nor the names
|
||||
* of any contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* Alternatively, this software may be distributed under the terms of the
|
||||
* GNU General Public License ("GPL") version 2 as published by the Free
|
||||
* Software Foundation.
|
||||
*
|
||||
* NO WARRANTY
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF NONINFRINGEMENT, MERCHANTIBILITY
|
||||
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
||||
* THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY,
|
||||
* OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||
* IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
||||
* THE POSSIBILITY OF SUCH DAMAGES.
|
||||
*/
|
||||
#include <linux/netdevice.h>
|
||||
#include <linux/types.h>
|
||||
#include <linux/skbuff.h>
|
||||
#include <linux/debugfs.h>
|
||||
#include <linux/ieee80211.h>
|
||||
#include <linux/slab.h>
|
||||
#include <linux/export.h>
|
||||
#include <net/mac80211.h>
|
||||
#include "rc80211_minstrel.h"
|
||||
|
||||
int
|
||||
minstrel_stats_open(struct inode *inode, struct file *file)
|
||||
{
|
||||
struct minstrel_sta_info *mi = inode->i_private;
|
||||
struct minstrel_debugfs_info *ms;
|
||||
unsigned int i, tp_max, tp_avg, eprob;
|
||||
char *p;
|
||||
|
||||
ms = kmalloc(2048, GFP_KERNEL);
|
||||
if (!ms)
|
||||
return -ENOMEM;
|
||||
|
||||
file->private_data = ms;
|
||||
p = ms->buf;
|
||||
p += sprintf(p, "\n");
|
||||
p += sprintf(p,
|
||||
"best __________rate_________ ____statistics___ ____last_____ ______sum-of________\n");
|
||||
p += sprintf(p,
|
||||
"rate [name idx airtime max_tp] [avg(tp) avg(prob)] [retry|suc|att] [#success | #attempts]\n");
|
||||
|
||||
for (i = 0; i < mi->n_rates; i++) {
|
||||
struct minstrel_rate *mr = &mi->r[i];
|
||||
struct minstrel_rate_stats *mrs = &mi->r[i].stats;
|
||||
|
||||
*(p++) = (i == mi->max_tp_rate[0]) ? 'A' : ' ';
|
||||
*(p++) = (i == mi->max_tp_rate[1]) ? 'B' : ' ';
|
||||
*(p++) = (i == mi->max_tp_rate[2]) ? 'C' : ' ';
|
||||
*(p++) = (i == mi->max_tp_rate[3]) ? 'D' : ' ';
|
||||
*(p++) = (i == mi->max_prob_rate) ? 'P' : ' ';
|
||||
|
||||
p += sprintf(p, " %3u%s ", mr->bitrate / 2,
|
||||
(mr->bitrate & 1 ? ".5" : " "));
|
||||
p += sprintf(p, "%3u ", i);
|
||||
p += sprintf(p, "%6u ", mr->perfect_tx_time);
|
||||
|
||||
tp_max = minstrel_get_tp_avg(mr, MINSTREL_FRAC(100,100));
|
||||
tp_avg = minstrel_get_tp_avg(mr, mrs->prob_avg);
|
||||
eprob = MINSTREL_TRUNC(mrs->prob_avg * 1000);
|
||||
|
||||
p += sprintf(p, "%4u.%1u %4u.%1u %3u.%1u"
|
||||
" %3u %3u %-3u "
|
||||
"%9llu %-9llu\n",
|
||||
tp_max / 10, tp_max % 10,
|
||||
tp_avg / 10, tp_avg % 10,
|
||||
eprob / 10, eprob % 10,
|
||||
mrs->retry_count,
|
||||
mrs->last_success,
|
||||
mrs->last_attempts,
|
||||
(unsigned long long)mrs->succ_hist,
|
||||
(unsigned long long)mrs->att_hist);
|
||||
}
|
||||
p += sprintf(p, "\nTotal packet count:: ideal %d "
|
||||
"lookaround %d\n\n",
|
||||
mi->total_packets - mi->sample_packets,
|
||||
mi->sample_packets);
|
||||
ms->len = p - ms->buf;
|
||||
|
||||
WARN_ON(ms->len + sizeof(*ms) > 2048);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
minstrel_stats_csv_open(struct inode *inode, struct file *file)
|
||||
{
|
||||
struct minstrel_sta_info *mi = inode->i_private;
|
||||
struct minstrel_debugfs_info *ms;
|
||||
unsigned int i, tp_max, tp_avg, eprob;
|
||||
char *p;
|
||||
|
||||
ms = kmalloc(2048, GFP_KERNEL);
|
||||
if (!ms)
|
||||
return -ENOMEM;
|
||||
|
||||
file->private_data = ms;
|
||||
p = ms->buf;
|
||||
|
||||
for (i = 0; i < mi->n_rates; i++) {
|
||||
struct minstrel_rate *mr = &mi->r[i];
|
||||
struct minstrel_rate_stats *mrs = &mi->r[i].stats;
|
||||
|
||||
p += sprintf(p, "%s" ,((i == mi->max_tp_rate[0]) ? "A" : ""));
|
||||
p += sprintf(p, "%s" ,((i == mi->max_tp_rate[1]) ? "B" : ""));
|
||||
p += sprintf(p, "%s" ,((i == mi->max_tp_rate[2]) ? "C" : ""));
|
||||
p += sprintf(p, "%s" ,((i == mi->max_tp_rate[3]) ? "D" : ""));
|
||||
p += sprintf(p, "%s" ,((i == mi->max_prob_rate) ? "P" : ""));
|
||||
|
||||
p += sprintf(p, ",%u%s", mr->bitrate / 2,
|
||||
(mr->bitrate & 1 ? ".5," : ","));
|
||||
p += sprintf(p, "%u,", i);
|
||||
p += sprintf(p, "%u,",mr->perfect_tx_time);
|
||||
|
||||
tp_max = minstrel_get_tp_avg(mr, MINSTREL_FRAC(100,100));
|
||||
tp_avg = minstrel_get_tp_avg(mr, mrs->prob_avg);
|
||||
eprob = MINSTREL_TRUNC(mrs->prob_avg * 1000);
|
||||
|
||||
p += sprintf(p, "%u.%u,%u.%u,%u.%u,%u,%u,%u,"
|
||||
"%llu,%llu,%d,%d\n",
|
||||
tp_max / 10, tp_max % 10,
|
||||
tp_avg / 10, tp_avg % 10,
|
||||
eprob / 10, eprob % 10,
|
||||
mrs->retry_count,
|
||||
mrs->last_success,
|
||||
mrs->last_attempts,
|
||||
(unsigned long long)mrs->succ_hist,
|
||||
(unsigned long long)mrs->att_hist,
|
||||
mi->total_packets - mi->sample_packets,
|
||||
mi->sample_packets);
|
||||
|
||||
}
|
||||
ms->len = p - ms->buf;
|
||||
|
||||
WARN_ON(ms->len + sizeof(*ms) > 2048);
|
||||
|
||||
return 0;
|
||||
}
|
@ -13,7 +13,6 @@
|
||||
#include <net/mac80211.h>
|
||||
#include "rate.h"
|
||||
#include "sta_info.h"
|
||||
#include "rc80211_minstrel.h"
|
||||
#include "rc80211_minstrel_ht.h"
|
||||
|
||||
#define AVG_AMPDU_SIZE 16
|
||||
@ -136,20 +135,16 @@
|
||||
__VHT_GROUP(_streams, _sgi, _bw, \
|
||||
VHT_GROUP_SHIFT(_streams, _sgi, _bw))
|
||||
|
||||
#define CCK_DURATION(_bitrate, _short, _len) \
|
||||
#define CCK_DURATION(_bitrate, _short) \
|
||||
(1000 * (10 /* SIFS */ + \
|
||||
(_short ? 72 + 24 : 144 + 48) + \
|
||||
(8 * (_len + 4) * 10) / (_bitrate)))
|
||||
|
||||
#define CCK_ACK_DURATION(_bitrate, _short) \
|
||||
(CCK_DURATION((_bitrate > 10 ? 20 : 10), false, 60) + \
|
||||
CCK_DURATION(_bitrate, _short, AVG_PKT_SIZE))
|
||||
(8 * (AVG_PKT_SIZE + 4) * 10) / (_bitrate)))
|
||||
|
||||
#define CCK_DURATION_LIST(_short, _s) \
|
||||
CCK_ACK_DURATION(10, _short) >> _s, \
|
||||
CCK_ACK_DURATION(20, _short) >> _s, \
|
||||
CCK_ACK_DURATION(55, _short) >> _s, \
|
||||
CCK_ACK_DURATION(110, _short) >> _s
|
||||
CCK_DURATION(10, _short) >> _s, \
|
||||
CCK_DURATION(20, _short) >> _s, \
|
||||
CCK_DURATION(55, _short) >> _s, \
|
||||
CCK_DURATION(110, _short) >> _s
|
||||
|
||||
#define __CCK_GROUP(_s) \
|
||||
[MINSTREL_CCK_GROUP] = { \
|
||||
@ -163,10 +158,42 @@
|
||||
}
|
||||
|
||||
#define CCK_GROUP_SHIFT \
|
||||
GROUP_SHIFT(CCK_ACK_DURATION(10, false))
|
||||
GROUP_SHIFT(CCK_DURATION(10, false))
|
||||
|
||||
#define CCK_GROUP __CCK_GROUP(CCK_GROUP_SHIFT)
|
||||
|
||||
#define OFDM_DURATION(_bitrate) \
|
||||
(1000 * (16 /* SIFS + signal ext */ + \
|
||||
16 /* T_PREAMBLE */ + \
|
||||
4 /* T_SIGNAL */ + \
|
||||
4 * (((16 + 80 * (AVG_PKT_SIZE + 4) + 6) / \
|
||||
((_bitrate) * 4)))))
|
||||
|
||||
#define OFDM_DURATION_LIST(_s) \
|
||||
OFDM_DURATION(60) >> _s, \
|
||||
OFDM_DURATION(90) >> _s, \
|
||||
OFDM_DURATION(120) >> _s, \
|
||||
OFDM_DURATION(180) >> _s, \
|
||||
OFDM_DURATION(240) >> _s, \
|
||||
OFDM_DURATION(360) >> _s, \
|
||||
OFDM_DURATION(480) >> _s, \
|
||||
OFDM_DURATION(540) >> _s
|
||||
|
||||
#define __OFDM_GROUP(_s) \
|
||||
[MINSTREL_OFDM_GROUP] = { \
|
||||
.streams = 1, \
|
||||
.flags = 0, \
|
||||
.shift = _s, \
|
||||
.duration = { \
|
||||
OFDM_DURATION_LIST(_s), \
|
||||
} \
|
||||
}
|
||||
|
||||
#define OFDM_GROUP_SHIFT \
|
||||
GROUP_SHIFT(OFDM_DURATION(60))
|
||||
|
||||
#define OFDM_GROUP __OFDM_GROUP(OFDM_GROUP_SHIFT)
|
||||
|
||||
|
||||
static bool minstrel_vht_only = true;
|
||||
module_param(minstrel_vht_only, bool, 0644);
|
||||
@ -203,6 +230,7 @@ const struct mcs_group minstrel_mcs_groups[] = {
|
||||
MCS_GROUP(4, 1, BW_40),
|
||||
|
||||
CCK_GROUP,
|
||||
OFDM_GROUP,
|
||||
|
||||
VHT_GROUP(1, 0, BW_20),
|
||||
VHT_GROUP(2, 0, BW_20),
|
||||
@ -235,6 +263,8 @@ const struct mcs_group minstrel_mcs_groups[] = {
|
||||
VHT_GROUP(4, 1, BW_80),
|
||||
};
|
||||
|
||||
const s16 minstrel_cck_bitrates[4] = { 10, 20, 55, 110 };
|
||||
const s16 minstrel_ofdm_bitrates[8] = { 60, 90, 120, 180, 240, 360, 480, 540 };
|
||||
static u8 sample_table[SAMPLE_COLUMNS][MCS_GROUP_RATES] __read_mostly;
|
||||
|
||||
static void
|
||||
@ -279,6 +309,13 @@ minstrel_get_valid_vht_rates(int bw, int nss, __le16 mcs_map)
|
||||
return 0x3ff & ~mask;
|
||||
}
|
||||
|
||||
static bool
|
||||
minstrel_ht_is_legacy_group(int group)
|
||||
{
|
||||
return group == MINSTREL_CCK_GROUP ||
|
||||
group == MINSTREL_OFDM_GROUP;
|
||||
}
|
||||
|
||||
/*
|
||||
* Look up an MCS group index based on mac80211 rate information
|
||||
*/
|
||||
@ -308,21 +345,34 @@ minstrel_ht_get_stats(struct minstrel_priv *mp, struct minstrel_ht_sta *mi,
|
||||
if (rate->flags & IEEE80211_TX_RC_MCS) {
|
||||
group = minstrel_ht_get_group_idx(rate);
|
||||
idx = rate->idx % 8;
|
||||
} else if (rate->flags & IEEE80211_TX_RC_VHT_MCS) {
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (rate->flags & IEEE80211_TX_RC_VHT_MCS) {
|
||||
group = minstrel_vht_get_group_idx(rate);
|
||||
idx = ieee80211_rate_get_vht_mcs(rate);
|
||||
} else {
|
||||
group = MINSTREL_CCK_GROUP;
|
||||
goto out;
|
||||
}
|
||||
|
||||
for (idx = 0; idx < ARRAY_SIZE(mp->cck_rates); idx++)
|
||||
if (rate->idx == mp->cck_rates[idx])
|
||||
break;
|
||||
group = MINSTREL_CCK_GROUP;
|
||||
for (idx = 0; idx < ARRAY_SIZE(mp->cck_rates); idx++) {
|
||||
if (rate->idx != mp->cck_rates[idx])
|
||||
continue;
|
||||
|
||||
/* short preamble */
|
||||
if ((mi->supported[group] & BIT(idx + 4)) &&
|
||||
(rate->flags & IEEE80211_TX_RC_USE_SHORT_PREAMBLE))
|
||||
idx += 4;
|
||||
idx += 4;
|
||||
goto out;
|
||||
}
|
||||
|
||||
group = MINSTREL_OFDM_GROUP;
|
||||
for (idx = 0; idx < ARRAY_SIZE(mp->ofdm_rates[0]); idx++)
|
||||
if (rate->idx == mp->ofdm_rates[mi->band][idx])
|
||||
goto out;
|
||||
|
||||
idx = 0;
|
||||
out:
|
||||
return &mi->groups[group].rates[idx];
|
||||
}
|
||||
|
||||
@ -332,13 +382,37 @@ minstrel_get_ratestats(struct minstrel_ht_sta *mi, int index)
|
||||
return &mi->groups[index / MCS_GROUP_RATES].rates[index % MCS_GROUP_RATES];
|
||||
}
|
||||
|
||||
static inline int minstrel_get_duration(int index)
|
||||
{
|
||||
const struct mcs_group *group = &minstrel_mcs_groups[index / MCS_GROUP_RATES];
|
||||
unsigned int duration = group->duration[index % MCS_GROUP_RATES];
|
||||
|
||||
return duration << group->shift;
|
||||
}
|
||||
|
||||
static unsigned int
|
||||
minstrel_ht_avg_ampdu_len(struct minstrel_ht_sta *mi)
|
||||
{
|
||||
if (!mi->avg_ampdu_len)
|
||||
return AVG_AMPDU_SIZE;
|
||||
int duration;
|
||||
|
||||
return MINSTREL_TRUNC(mi->avg_ampdu_len);
|
||||
if (mi->avg_ampdu_len)
|
||||
return MINSTREL_TRUNC(mi->avg_ampdu_len);
|
||||
|
||||
if (minstrel_ht_is_legacy_group(mi->max_tp_rate[0] / MCS_GROUP_RATES))
|
||||
return 1;
|
||||
|
||||
duration = minstrel_get_duration(mi->max_tp_rate[0]);
|
||||
|
||||
if (duration > 400 * 1000)
|
||||
return 2;
|
||||
|
||||
if (duration > 250 * 1000)
|
||||
return 4;
|
||||
|
||||
if (duration > 150 * 1000)
|
||||
return 8;
|
||||
|
||||
return 16;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -349,15 +423,19 @@ int
|
||||
minstrel_ht_get_tp_avg(struct minstrel_ht_sta *mi, int group, int rate,
|
||||
int prob_avg)
|
||||
{
|
||||
unsigned int nsecs = 0;
|
||||
unsigned int nsecs = 0, overhead = mi->overhead;
|
||||
unsigned int ampdu_len = 1;
|
||||
|
||||
/* do not account throughput if sucess prob is below 10% */
|
||||
if (prob_avg < MINSTREL_FRAC(10, 100))
|
||||
return 0;
|
||||
|
||||
if (group != MINSTREL_CCK_GROUP)
|
||||
nsecs = 1000 * mi->overhead / minstrel_ht_avg_ampdu_len(mi);
|
||||
if (minstrel_ht_is_legacy_group(group))
|
||||
overhead = mi->overhead_legacy;
|
||||
else
|
||||
ampdu_len = minstrel_ht_avg_ampdu_len(mi);
|
||||
|
||||
nsecs = 1000 * overhead / ampdu_len;
|
||||
nsecs += minstrel_mcs_groups[group].duration[rate] <<
|
||||
minstrel_mcs_groups[group].shift;
|
||||
|
||||
@ -367,10 +445,9 @@ minstrel_ht_get_tp_avg(struct minstrel_ht_sta *mi, int group, int rate,
|
||||
* (prob is scaled - see MINSTREL_FRAC above)
|
||||
*/
|
||||
if (prob_avg > MINSTREL_FRAC(90, 100))
|
||||
return MINSTREL_TRUNC(100000 * ((MINSTREL_FRAC(90, 100) * 1000)
|
||||
/ nsecs));
|
||||
else
|
||||
return MINSTREL_TRUNC(100000 * ((prob_avg * 1000) / nsecs));
|
||||
prob_avg = MINSTREL_FRAC(90, 100);
|
||||
|
||||
return MINSTREL_TRUNC(100 * ((prob_avg * 1000000) / nsecs));
|
||||
}
|
||||
|
||||
/*
|
||||
@ -417,12 +494,13 @@ minstrel_ht_sort_best_tp_rates(struct minstrel_ht_sta *mi, u16 index,
|
||||
* Find and set the topmost probability rate per sta and per group
|
||||
*/
|
||||
static void
|
||||
minstrel_ht_set_best_prob_rate(struct minstrel_ht_sta *mi, u16 index)
|
||||
minstrel_ht_set_best_prob_rate(struct minstrel_ht_sta *mi, u16 *dest, u16 index)
|
||||
{
|
||||
struct minstrel_mcs_group_data *mg;
|
||||
struct minstrel_rate_stats *mrs;
|
||||
int tmp_group, tmp_idx, tmp_tp_avg, tmp_prob;
|
||||
int max_tp_group, cur_tp_avg, cur_group, cur_idx;
|
||||
int max_tp_group, max_tp_idx, max_tp_prob;
|
||||
int cur_tp_avg, cur_group, cur_idx;
|
||||
int max_gpr_group, max_gpr_idx;
|
||||
int max_gpr_tp_avg, max_gpr_prob;
|
||||
|
||||
@ -431,16 +509,24 @@ minstrel_ht_set_best_prob_rate(struct minstrel_ht_sta *mi, u16 index)
|
||||
mg = &mi->groups[index / MCS_GROUP_RATES];
|
||||
mrs = &mg->rates[index % MCS_GROUP_RATES];
|
||||
|
||||
tmp_group = mi->max_prob_rate / MCS_GROUP_RATES;
|
||||
tmp_idx = mi->max_prob_rate % MCS_GROUP_RATES;
|
||||
tmp_group = *dest / MCS_GROUP_RATES;
|
||||
tmp_idx = *dest % MCS_GROUP_RATES;
|
||||
tmp_prob = mi->groups[tmp_group].rates[tmp_idx].prob_avg;
|
||||
tmp_tp_avg = minstrel_ht_get_tp_avg(mi, tmp_group, tmp_idx, tmp_prob);
|
||||
|
||||
/* if max_tp_rate[0] is from MCS_GROUP max_prob_rate get selected from
|
||||
* MCS_GROUP as well as CCK_GROUP rates do not allow aggregation */
|
||||
max_tp_group = mi->max_tp_rate[0] / MCS_GROUP_RATES;
|
||||
if((index / MCS_GROUP_RATES == MINSTREL_CCK_GROUP) &&
|
||||
(max_tp_group != MINSTREL_CCK_GROUP))
|
||||
max_tp_idx = mi->max_tp_rate[0] % MCS_GROUP_RATES;
|
||||
max_tp_prob = mi->groups[max_tp_group].rates[max_tp_idx].prob_avg;
|
||||
|
||||
if (minstrel_ht_is_legacy_group(index / MCS_GROUP_RATES) &&
|
||||
!minstrel_ht_is_legacy_group(max_tp_group))
|
||||
return;
|
||||
|
||||
/* skip rates faster than max tp rate with lower prob */
|
||||
if (minstrel_get_duration(mi->max_tp_rate[0]) > minstrel_get_duration(index) &&
|
||||
mrs->prob_avg < max_tp_prob)
|
||||
return;
|
||||
|
||||
max_gpr_group = mg->max_group_prob_rate / MCS_GROUP_RATES;
|
||||
@ -451,7 +537,7 @@ minstrel_ht_set_best_prob_rate(struct minstrel_ht_sta *mi, u16 index)
|
||||
cur_tp_avg = minstrel_ht_get_tp_avg(mi, cur_group, cur_idx,
|
||||
mrs->prob_avg);
|
||||
if (cur_tp_avg > tmp_tp_avg)
|
||||
mi->max_prob_rate = index;
|
||||
*dest = index;
|
||||
|
||||
max_gpr_tp_avg = minstrel_ht_get_tp_avg(mi, max_gpr_group,
|
||||
max_gpr_idx,
|
||||
@ -460,7 +546,7 @@ minstrel_ht_set_best_prob_rate(struct minstrel_ht_sta *mi, u16 index)
|
||||
mg->max_group_prob_rate = index;
|
||||
} else {
|
||||
if (mrs->prob_avg > tmp_prob)
|
||||
mi->max_prob_rate = index;
|
||||
*dest = index;
|
||||
if (mrs->prob_avg > max_gpr_prob)
|
||||
mg->max_group_prob_rate = index;
|
||||
}
|
||||
@ -476,13 +562,13 @@ minstrel_ht_set_best_prob_rate(struct minstrel_ht_sta *mi, u16 index)
|
||||
static void
|
||||
minstrel_ht_assign_best_tp_rates(struct minstrel_ht_sta *mi,
|
||||
u16 tmp_mcs_tp_rate[MAX_THR_RATES],
|
||||
u16 tmp_cck_tp_rate[MAX_THR_RATES])
|
||||
u16 tmp_legacy_tp_rate[MAX_THR_RATES])
|
||||
{
|
||||
unsigned int tmp_group, tmp_idx, tmp_cck_tp, tmp_mcs_tp, tmp_prob;
|
||||
int i;
|
||||
|
||||
tmp_group = tmp_cck_tp_rate[0] / MCS_GROUP_RATES;
|
||||
tmp_idx = tmp_cck_tp_rate[0] % MCS_GROUP_RATES;
|
||||
tmp_group = tmp_legacy_tp_rate[0] / MCS_GROUP_RATES;
|
||||
tmp_idx = tmp_legacy_tp_rate[0] % MCS_GROUP_RATES;
|
||||
tmp_prob = mi->groups[tmp_group].rates[tmp_idx].prob_avg;
|
||||
tmp_cck_tp = minstrel_ht_get_tp_avg(mi, tmp_group, tmp_idx, tmp_prob);
|
||||
|
||||
@ -493,7 +579,7 @@ minstrel_ht_assign_best_tp_rates(struct minstrel_ht_sta *mi,
|
||||
|
||||
if (tmp_cck_tp > tmp_mcs_tp) {
|
||||
for(i = 0; i < MAX_THR_RATES; i++) {
|
||||
minstrel_ht_sort_best_tp_rates(mi, tmp_cck_tp_rate[i],
|
||||
minstrel_ht_sort_best_tp_rates(mi, tmp_legacy_tp_rate[i],
|
||||
tmp_mcs_tp_rate);
|
||||
}
|
||||
}
|
||||
@ -511,6 +597,9 @@ minstrel_ht_prob_rate_reduce_streams(struct minstrel_ht_sta *mi)
|
||||
int tmp_max_streams, group, tmp_idx, tmp_prob;
|
||||
int tmp_tp = 0;
|
||||
|
||||
if (!mi->sta->ht_cap.ht_supported)
|
||||
return;
|
||||
|
||||
tmp_max_streams = minstrel_mcs_groups[mi->max_tp_rate[0] /
|
||||
MCS_GROUP_RATES].streams;
|
||||
for (group = 0; group < ARRAY_SIZE(minstrel_mcs_groups); group++) {
|
||||
@ -531,14 +620,6 @@ minstrel_ht_prob_rate_reduce_streams(struct minstrel_ht_sta *mi)
|
||||
}
|
||||
}
|
||||
|
||||
static inline int
|
||||
minstrel_get_duration(int index)
|
||||
{
|
||||
const struct mcs_group *group = &minstrel_mcs_groups[index / MCS_GROUP_RATES];
|
||||
unsigned int duration = group->duration[index % MCS_GROUP_RATES];
|
||||
return duration << group->shift;
|
||||
}
|
||||
|
||||
static bool
|
||||
minstrel_ht_probe_group(struct minstrel_ht_sta *mi, const struct mcs_group *tp_group,
|
||||
int tp_idx, const struct mcs_group *group)
|
||||
@ -658,6 +739,74 @@ out:
|
||||
mi->sample_mode = MINSTREL_SAMPLE_ACTIVE;
|
||||
}
|
||||
|
||||
static inline int
|
||||
minstrel_ewma(int old, int new, int weight)
|
||||
{
|
||||
int diff, incr;
|
||||
|
||||
diff = new - old;
|
||||
incr = (EWMA_DIV - weight) * diff / EWMA_DIV;
|
||||
|
||||
return old + incr;
|
||||
}
|
||||
|
||||
static inline int minstrel_filter_avg_add(u16 *prev_1, u16 *prev_2, s32 in)
|
||||
{
|
||||
s32 out_1 = *prev_1;
|
||||
s32 out_2 = *prev_2;
|
||||
s32 val;
|
||||
|
||||
if (!in)
|
||||
in += 1;
|
||||
|
||||
if (!out_1) {
|
||||
val = out_1 = in;
|
||||
goto out;
|
||||
}
|
||||
|
||||
val = MINSTREL_AVG_COEFF1 * in;
|
||||
val += MINSTREL_AVG_COEFF2 * out_1;
|
||||
val += MINSTREL_AVG_COEFF3 * out_2;
|
||||
val >>= MINSTREL_SCALE;
|
||||
|
||||
if (val > 1 << MINSTREL_SCALE)
|
||||
val = 1 << MINSTREL_SCALE;
|
||||
if (val < 0)
|
||||
val = 1;
|
||||
|
||||
out:
|
||||
*prev_2 = out_1;
|
||||
*prev_1 = val;
|
||||
|
||||
return val;
|
||||
}
|
||||
|
||||
/*
|
||||
* Recalculate statistics and counters of a given rate
|
||||
*/
|
||||
static void
|
||||
minstrel_ht_calc_rate_stats(struct minstrel_priv *mp,
|
||||
struct minstrel_rate_stats *mrs)
|
||||
{
|
||||
unsigned int cur_prob;
|
||||
|
||||
if (unlikely(mrs->attempts > 0)) {
|
||||
mrs->sample_skipped = 0;
|
||||
cur_prob = MINSTREL_FRAC(mrs->success, mrs->attempts);
|
||||
minstrel_filter_avg_add(&mrs->prob_avg,
|
||||
&mrs->prob_avg_1, cur_prob);
|
||||
mrs->att_hist += mrs->attempts;
|
||||
mrs->succ_hist += mrs->success;
|
||||
} else {
|
||||
mrs->sample_skipped++;
|
||||
}
|
||||
|
||||
mrs->last_success = mrs->success;
|
||||
mrs->last_attempts = mrs->attempts;
|
||||
mrs->success = 0;
|
||||
mrs->attempts = 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Update rate statistics and select new primary rates
|
||||
*
|
||||
@ -675,7 +824,9 @@ minstrel_ht_update_stats(struct minstrel_priv *mp, struct minstrel_ht_sta *mi,
|
||||
struct minstrel_rate_stats *mrs;
|
||||
int group, i, j, cur_prob;
|
||||
u16 tmp_mcs_tp_rate[MAX_THR_RATES], tmp_group_tp_rate[MAX_THR_RATES];
|
||||
u16 tmp_cck_tp_rate[MAX_THR_RATES], index;
|
||||
u16 tmp_legacy_tp_rate[MAX_THR_RATES], tmp_max_prob_rate;
|
||||
u16 index;
|
||||
bool ht_supported = mi->sta->ht_cap.ht_supported;
|
||||
|
||||
mi->sample_mode = MINSTREL_SAMPLE_IDLE;
|
||||
|
||||
@ -704,21 +855,30 @@ minstrel_ht_update_stats(struct minstrel_priv *mp, struct minstrel_ht_sta *mi,
|
||||
mi->sample_count = 0;
|
||||
|
||||
memset(tmp_mcs_tp_rate, 0, sizeof(tmp_mcs_tp_rate));
|
||||
memset(tmp_cck_tp_rate, 0, sizeof(tmp_cck_tp_rate));
|
||||
memset(tmp_legacy_tp_rate, 0, sizeof(tmp_legacy_tp_rate));
|
||||
if (mi->supported[MINSTREL_CCK_GROUP])
|
||||
for (j = 0; j < ARRAY_SIZE(tmp_cck_tp_rate); j++)
|
||||
tmp_cck_tp_rate[j] = MINSTREL_CCK_GROUP * MCS_GROUP_RATES;
|
||||
for (j = 0; j < ARRAY_SIZE(tmp_legacy_tp_rate); j++)
|
||||
tmp_legacy_tp_rate[j] = MINSTREL_CCK_GROUP * MCS_GROUP_RATES;
|
||||
else if (mi->supported[MINSTREL_OFDM_GROUP])
|
||||
for (j = 0; j < ARRAY_SIZE(tmp_legacy_tp_rate); j++)
|
||||
tmp_legacy_tp_rate[j] = MINSTREL_OFDM_GROUP * MCS_GROUP_RATES;
|
||||
|
||||
if (mi->supported[MINSTREL_VHT_GROUP_0])
|
||||
index = MINSTREL_VHT_GROUP_0 * MCS_GROUP_RATES;
|
||||
else
|
||||
else if (ht_supported)
|
||||
index = MINSTREL_HT_GROUP_0 * MCS_GROUP_RATES;
|
||||
else if (mi->supported[MINSTREL_CCK_GROUP])
|
||||
index = MINSTREL_CCK_GROUP * MCS_GROUP_RATES;
|
||||
else
|
||||
index = MINSTREL_OFDM_GROUP * MCS_GROUP_RATES;
|
||||
|
||||
tmp_max_prob_rate = index;
|
||||
for (j = 0; j < ARRAY_SIZE(tmp_mcs_tp_rate); j++)
|
||||
tmp_mcs_tp_rate[j] = index;
|
||||
|
||||
/* Find best rate sets within all MCS groups*/
|
||||
for (group = 0; group < ARRAY_SIZE(minstrel_mcs_groups); group++) {
|
||||
u16 *tp_rate = tmp_mcs_tp_rate;
|
||||
|
||||
mg = &mi->groups[group];
|
||||
if (!mi->supported[group])
|
||||
@ -730,6 +890,9 @@ minstrel_ht_update_stats(struct minstrel_priv *mp, struct minstrel_ht_sta *mi,
|
||||
for(j = 0; j < MAX_THR_RATES; j++)
|
||||
tmp_group_tp_rate[j] = MCS_GROUP_RATES * group;
|
||||
|
||||
if (group == MINSTREL_CCK_GROUP && ht_supported)
|
||||
tp_rate = tmp_legacy_tp_rate;
|
||||
|
||||
for (i = 0; i < MCS_GROUP_RATES; i++) {
|
||||
if (!(mi->supported[group] & BIT(i)))
|
||||
continue;
|
||||
@ -738,27 +901,18 @@ minstrel_ht_update_stats(struct minstrel_priv *mp, struct minstrel_ht_sta *mi,
|
||||
|
||||
mrs = &mg->rates[i];
|
||||
mrs->retry_updated = false;
|
||||
minstrel_calc_rate_stats(mp, mrs);
|
||||
minstrel_ht_calc_rate_stats(mp, mrs);
|
||||
cur_prob = mrs->prob_avg;
|
||||
|
||||
if (minstrel_ht_get_tp_avg(mi, group, i, cur_prob) == 0)
|
||||
continue;
|
||||
|
||||
/* Find max throughput rate set */
|
||||
if (group != MINSTREL_CCK_GROUP) {
|
||||
minstrel_ht_sort_best_tp_rates(mi, index,
|
||||
tmp_mcs_tp_rate);
|
||||
} else if (group == MINSTREL_CCK_GROUP) {
|
||||
minstrel_ht_sort_best_tp_rates(mi, index,
|
||||
tmp_cck_tp_rate);
|
||||
}
|
||||
minstrel_ht_sort_best_tp_rates(mi, index, tp_rate);
|
||||
|
||||
/* Find max throughput rate set within a group */
|
||||
minstrel_ht_sort_best_tp_rates(mi, index,
|
||||
tmp_group_tp_rate);
|
||||
|
||||
/* Find max probability rate per group and global */
|
||||
minstrel_ht_set_best_prob_rate(mi, index);
|
||||
}
|
||||
|
||||
memcpy(mg->max_group_tp_rate, tmp_group_tp_rate,
|
||||
@ -766,16 +920,36 @@ minstrel_ht_update_stats(struct minstrel_priv *mp, struct minstrel_ht_sta *mi,
|
||||
}
|
||||
|
||||
/* Assign new rate set per sta */
|
||||
minstrel_ht_assign_best_tp_rates(mi, tmp_mcs_tp_rate, tmp_cck_tp_rate);
|
||||
minstrel_ht_assign_best_tp_rates(mi, tmp_mcs_tp_rate,
|
||||
tmp_legacy_tp_rate);
|
||||
memcpy(mi->max_tp_rate, tmp_mcs_tp_rate, sizeof(mi->max_tp_rate));
|
||||
|
||||
for (group = 0; group < ARRAY_SIZE(minstrel_mcs_groups); group++) {
|
||||
if (!mi->supported[group])
|
||||
continue;
|
||||
|
||||
mg = &mi->groups[group];
|
||||
mg->max_group_prob_rate = MCS_GROUP_RATES * group;
|
||||
|
||||
for (i = 0; i < MCS_GROUP_RATES; i++) {
|
||||
if (!(mi->supported[group] & BIT(i)))
|
||||
continue;
|
||||
|
||||
index = MCS_GROUP_RATES * group + i;
|
||||
|
||||
/* Find max probability rate per group and global */
|
||||
minstrel_ht_set_best_prob_rate(mi, &tmp_max_prob_rate,
|
||||
index);
|
||||
}
|
||||
}
|
||||
|
||||
mi->max_prob_rate = tmp_max_prob_rate;
|
||||
|
||||
/* Try to increase robustness of max_prob_rate*/
|
||||
minstrel_ht_prob_rate_reduce_streams(mi);
|
||||
|
||||
/* try to sample all available rates during each interval */
|
||||
mi->sample_count *= 8;
|
||||
if (mp->new_avg)
|
||||
mi->sample_count /= 2;
|
||||
/* try to sample half of all available rates during each interval */
|
||||
mi->sample_count *= 4;
|
||||
|
||||
if (sample)
|
||||
minstrel_ht_rate_sample_switch(mp, mi);
|
||||
@ -795,8 +969,11 @@ minstrel_ht_update_stats(struct minstrel_priv *mp, struct minstrel_ht_sta *mi,
|
||||
}
|
||||
|
||||
static bool
|
||||
minstrel_ht_txstat_valid(struct minstrel_priv *mp, struct ieee80211_tx_rate *rate)
|
||||
minstrel_ht_txstat_valid(struct minstrel_priv *mp, struct minstrel_ht_sta *mi,
|
||||
struct ieee80211_tx_rate *rate)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (rate->idx < 0)
|
||||
return false;
|
||||
|
||||
@ -807,10 +984,15 @@ minstrel_ht_txstat_valid(struct minstrel_priv *mp, struct ieee80211_tx_rate *rat
|
||||
rate->flags & IEEE80211_TX_RC_VHT_MCS)
|
||||
return true;
|
||||
|
||||
return rate->idx == mp->cck_rates[0] ||
|
||||
rate->idx == mp->cck_rates[1] ||
|
||||
rate->idx == mp->cck_rates[2] ||
|
||||
rate->idx == mp->cck_rates[3];
|
||||
for (i = 0; i < ARRAY_SIZE(mp->cck_rates); i++)
|
||||
if (rate->idx == mp->cck_rates[i])
|
||||
return true;
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(mp->ofdm_rates[0]); i++)
|
||||
if (rate->idx == mp->ofdm_rates[mi->band][i])
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
static void
|
||||
@ -887,21 +1069,15 @@ minstrel_ht_tx_status(void *priv, struct ieee80211_supported_band *sband,
|
||||
void *priv_sta, struct ieee80211_tx_status *st)
|
||||
{
|
||||
struct ieee80211_tx_info *info = st->info;
|
||||
struct minstrel_ht_sta_priv *msp = priv_sta;
|
||||
struct minstrel_ht_sta *mi = &msp->ht;
|
||||
struct minstrel_ht_sta *mi = priv_sta;
|
||||
struct ieee80211_tx_rate *ar = info->status.rates;
|
||||
struct minstrel_rate_stats *rate, *rate2, *rate_sample = NULL;
|
||||
struct minstrel_priv *mp = priv;
|
||||
u32 update_interval = mp->update_interval / 2;
|
||||
u32 update_interval = mp->update_interval;
|
||||
bool last, update = false;
|
||||
bool sample_status = false;
|
||||
int i;
|
||||
|
||||
if (!msp->is_ht)
|
||||
return mac80211_minstrel.tx_status_ext(priv, sband,
|
||||
&msp->legacy, st);
|
||||
|
||||
|
||||
/* This packet was aggregated but doesn't carry status info */
|
||||
if ((info->flags & IEEE80211_TX_CTL_AMPDU) &&
|
||||
!(info->flags & IEEE80211_TX_STAT_AMPDU))
|
||||
@ -930,10 +1106,10 @@ minstrel_ht_tx_status(void *priv, struct ieee80211_supported_band *sband,
|
||||
if (mi->sample_mode != MINSTREL_SAMPLE_IDLE)
|
||||
rate_sample = minstrel_get_ratestats(mi, mi->sample_rate);
|
||||
|
||||
last = !minstrel_ht_txstat_valid(mp, &ar[0]);
|
||||
last = !minstrel_ht_txstat_valid(mp, mi, &ar[0]);
|
||||
for (i = 0; !last; i++) {
|
||||
last = (i == IEEE80211_TX_MAX_RATES - 1) ||
|
||||
!minstrel_ht_txstat_valid(mp, &ar[i + 1]);
|
||||
!minstrel_ht_txstat_valid(mp, mi, &ar[i + 1]);
|
||||
|
||||
rate = minstrel_ht_get_stats(mp, mi, &ar[i]);
|
||||
if (rate == rate_sample)
|
||||
@ -947,9 +1123,8 @@ minstrel_ht_tx_status(void *priv, struct ieee80211_supported_band *sband,
|
||||
|
||||
switch (mi->sample_mode) {
|
||||
case MINSTREL_SAMPLE_IDLE:
|
||||
if (mp->new_avg &&
|
||||
(mp->hw->max_rates > 1 ||
|
||||
mi->total_packets_cur < SAMPLE_SWITCH_THR))
|
||||
if (mp->hw->max_rates > 1 ||
|
||||
mi->total_packets_cur < SAMPLE_SWITCH_THR)
|
||||
update_interval /= 2;
|
||||
break;
|
||||
|
||||
@ -1031,7 +1206,10 @@ minstrel_calc_retransmit(struct minstrel_priv *mp, struct minstrel_ht_sta *mi,
|
||||
ctime += (t_slot * cw) >> 1;
|
||||
cw = min((cw << 1) | 1, mp->cw_max);
|
||||
|
||||
if (index / MCS_GROUP_RATES != MINSTREL_CCK_GROUP) {
|
||||
if (minstrel_ht_is_legacy_group(index / MCS_GROUP_RATES)) {
|
||||
overhead = mi->overhead_legacy;
|
||||
overhead_rtscts = mi->overhead_legacy_rtscts;
|
||||
} else {
|
||||
overhead = mi->overhead;
|
||||
overhead_rtscts = mi->overhead_rtscts;
|
||||
}
|
||||
@ -1061,7 +1239,8 @@ static void
|
||||
minstrel_ht_set_rate(struct minstrel_priv *mp, struct minstrel_ht_sta *mi,
|
||||
struct ieee80211_sta_rates *ratetbl, int offset, int index)
|
||||
{
|
||||
const struct mcs_group *group = &minstrel_mcs_groups[index / MCS_GROUP_RATES];
|
||||
int group_idx = index / MCS_GROUP_RATES;
|
||||
const struct mcs_group *group = &minstrel_mcs_groups[group_idx];
|
||||
struct minstrel_rate_stats *mrs;
|
||||
u8 idx;
|
||||
u16 flags = group->flags;
|
||||
@ -1080,13 +1259,17 @@ minstrel_ht_set_rate(struct minstrel_priv *mp, struct minstrel_ht_sta *mi,
|
||||
ratetbl->rate[offset].count_rts = mrs->retry_count_rtscts;
|
||||
}
|
||||
|
||||
if (index / MCS_GROUP_RATES == MINSTREL_CCK_GROUP)
|
||||
index %= MCS_GROUP_RATES;
|
||||
if (group_idx == MINSTREL_CCK_GROUP)
|
||||
idx = mp->cck_rates[index % ARRAY_SIZE(mp->cck_rates)];
|
||||
else if (group_idx == MINSTREL_OFDM_GROUP)
|
||||
idx = mp->ofdm_rates[mi->band][index %
|
||||
ARRAY_SIZE(mp->ofdm_rates[0])];
|
||||
else if (flags & IEEE80211_TX_RC_VHT_MCS)
|
||||
idx = ((group->streams - 1) << 4) |
|
||||
((index % MCS_GROUP_RATES) & 0xF);
|
||||
(index & 0xF);
|
||||
else
|
||||
idx = index % MCS_GROUP_RATES + (group->streams - 1) * 8;
|
||||
idx = index + (group->streams - 1) * 8;
|
||||
|
||||
/* enable RTS/CTS if needed:
|
||||
* - if station is in dynamic SMPS (and streams > 1)
|
||||
@ -1224,13 +1407,13 @@ minstrel_get_sample_rate(struct minstrel_priv *mp, struct minstrel_ht_sta *mi)
|
||||
mrs = &mg->rates[sample_idx];
|
||||
sample_idx += sample_group * MCS_GROUP_RATES;
|
||||
|
||||
/* Set tp_rate1, tp_rate2 to the highest / second highest max_tp_rate */
|
||||
tp_rate1 = mi->max_tp_rate[0];
|
||||
|
||||
/* Set tp_rate2 to the second highest max_tp_rate */
|
||||
if (minstrel_get_duration(mi->max_tp_rate[0]) >
|
||||
minstrel_get_duration(mi->max_tp_rate[1])) {
|
||||
tp_rate1 = mi->max_tp_rate[1];
|
||||
tp_rate2 = mi->max_tp_rate[0];
|
||||
} else {
|
||||
tp_rate1 = mi->max_tp_rate[0];
|
||||
tp_rate2 = mi->max_tp_rate[1];
|
||||
}
|
||||
|
||||
@ -1296,16 +1479,12 @@ minstrel_ht_get_rate(void *priv, struct ieee80211_sta *sta, void *priv_sta,
|
||||
const struct mcs_group *sample_group;
|
||||
struct ieee80211_tx_info *info = IEEE80211_SKB_CB(txrc->skb);
|
||||
struct ieee80211_tx_rate *rate = &info->status.rates[0];
|
||||
struct minstrel_ht_sta_priv *msp = priv_sta;
|
||||
struct minstrel_ht_sta *mi = &msp->ht;
|
||||
struct minstrel_ht_sta *mi = priv_sta;
|
||||
struct minstrel_priv *mp = priv;
|
||||
int sample_idx;
|
||||
|
||||
if (!msp->is_ht)
|
||||
return mac80211_minstrel.get_rate(priv, sta, &msp->legacy, txrc);
|
||||
|
||||
if (!(info->flags & IEEE80211_TX_CTL_AMPDU) &&
|
||||
mi->max_prob_rate / MCS_GROUP_RATES != MINSTREL_CCK_GROUP)
|
||||
!minstrel_ht_is_legacy_group(mi->max_prob_rate / MCS_GROUP_RATES))
|
||||
minstrel_aggr_check(sta, txrc->skb);
|
||||
|
||||
info->flags |= mi->tx_flags;
|
||||
@ -1346,6 +1525,9 @@ minstrel_ht_get_rate(void *priv, struct ieee80211_sta *sta, void *priv_sta,
|
||||
if (sample_group == &minstrel_mcs_groups[MINSTREL_CCK_GROUP]) {
|
||||
int idx = sample_idx % ARRAY_SIZE(mp->cck_rates);
|
||||
rate->idx = mp->cck_rates[idx];
|
||||
} else if (sample_group == &minstrel_mcs_groups[MINSTREL_OFDM_GROUP]) {
|
||||
int idx = sample_idx % ARRAY_SIZE(mp->ofdm_rates[0]);
|
||||
rate->idx = mp->ofdm_rates[mi->band][idx];
|
||||
} else if (sample_group->flags & IEEE80211_TX_RC_VHT_MCS) {
|
||||
ieee80211_rate_set_vht(rate, sample_idx % MCS_GROUP_RATES,
|
||||
sample_group->streams);
|
||||
@ -1366,44 +1548,59 @@ minstrel_ht_update_cck(struct minstrel_priv *mp, struct minstrel_ht_sta *mi,
|
||||
if (sband->band != NL80211_BAND_2GHZ)
|
||||
return;
|
||||
|
||||
if (!ieee80211_hw_check(mp->hw, SUPPORTS_HT_CCK_RATES))
|
||||
if (sta->ht_cap.ht_supported &&
|
||||
!ieee80211_hw_check(mp->hw, SUPPORTS_HT_CCK_RATES))
|
||||
return;
|
||||
|
||||
mi->cck_supported = 0;
|
||||
mi->cck_supported_short = 0;
|
||||
for (i = 0; i < 4; i++) {
|
||||
if (!rate_supported(sta, sband->band, mp->cck_rates[i]))
|
||||
if (mp->cck_rates[i] == 0xff ||
|
||||
!rate_supported(sta, sband->band, mp->cck_rates[i]))
|
||||
continue;
|
||||
|
||||
mi->cck_supported |= BIT(i);
|
||||
mi->supported[MINSTREL_CCK_GROUP] |= BIT(i);
|
||||
if (sband->bitrates[i].flags & IEEE80211_RATE_SHORT_PREAMBLE)
|
||||
mi->cck_supported_short |= BIT(i);
|
||||
mi->supported[MINSTREL_CCK_GROUP] |= BIT(i + 4);
|
||||
}
|
||||
}
|
||||
|
||||
mi->supported[MINSTREL_CCK_GROUP] = mi->cck_supported;
|
||||
static void
|
||||
minstrel_ht_update_ofdm(struct minstrel_priv *mp, struct minstrel_ht_sta *mi,
|
||||
struct ieee80211_supported_band *sband,
|
||||
struct ieee80211_sta *sta)
|
||||
{
|
||||
const u8 *rates;
|
||||
int i;
|
||||
|
||||
if (sta->ht_cap.ht_supported)
|
||||
return;
|
||||
|
||||
rates = mp->ofdm_rates[sband->band];
|
||||
for (i = 0; i < ARRAY_SIZE(mp->ofdm_rates[0]); i++) {
|
||||
if (rates[i] == 0xff ||
|
||||
!rate_supported(sta, sband->band, rates[i]))
|
||||
continue;
|
||||
|
||||
mi->supported[MINSTREL_OFDM_GROUP] |= BIT(i);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
minstrel_ht_update_caps(void *priv, struct ieee80211_supported_band *sband,
|
||||
struct cfg80211_chan_def *chandef,
|
||||
struct ieee80211_sta *sta, void *priv_sta)
|
||||
struct ieee80211_sta *sta, void *priv_sta)
|
||||
{
|
||||
struct minstrel_priv *mp = priv;
|
||||
struct minstrel_ht_sta_priv *msp = priv_sta;
|
||||
struct minstrel_ht_sta *mi = &msp->ht;
|
||||
struct minstrel_ht_sta *mi = priv_sta;
|
||||
struct ieee80211_mcs_info *mcs = &sta->ht_cap.mcs;
|
||||
u16 ht_cap = sta->ht_cap.cap;
|
||||
struct ieee80211_sta_vht_cap *vht_cap = &sta->vht_cap;
|
||||
const struct ieee80211_rate *ctl_rate;
|
||||
bool ldpc, erp;
|
||||
int use_vht;
|
||||
int n_supported = 0;
|
||||
int ack_dur;
|
||||
int stbc;
|
||||
int i;
|
||||
bool ldpc;
|
||||
|
||||
/* fall back to the old minstrel for legacy stations */
|
||||
if (!sta->ht_cap.ht_supported)
|
||||
goto use_legacy;
|
||||
|
||||
BUILD_BUG_ON(ARRAY_SIZE(minstrel_mcs_groups) != MINSTREL_GROUPS_NB);
|
||||
|
||||
@ -1412,10 +1609,10 @@ minstrel_ht_update_caps(void *priv, struct ieee80211_supported_band *sband,
|
||||
else
|
||||
use_vht = 0;
|
||||
|
||||
msp->is_ht = true;
|
||||
memset(mi, 0, sizeof(*mi));
|
||||
|
||||
mi->sta = sta;
|
||||
mi->band = sband->band;
|
||||
mi->last_stats_update = jiffies;
|
||||
|
||||
ack_dur = ieee80211_frame_duration(sband->band, 10, 60, 1, 1, 0);
|
||||
@ -1423,6 +1620,14 @@ minstrel_ht_update_caps(void *priv, struct ieee80211_supported_band *sband,
|
||||
mi->overhead += ack_dur;
|
||||
mi->overhead_rtscts = mi->overhead + 2 * ack_dur;
|
||||
|
||||
ctl_rate = &sband->bitrates[rate_lowest_index(sband, sta)];
|
||||
erp = ctl_rate->flags & IEEE80211_RATE_ERP_G;
|
||||
ack_dur = ieee80211_frame_duration(sband->band, 10,
|
||||
ctl_rate->bitrate, erp, 1,
|
||||
ieee80211_chandef_get_shift(chandef));
|
||||
mi->overhead_legacy = ack_dur;
|
||||
mi->overhead_legacy_rtscts = mi->overhead_legacy + 2 * ack_dur;
|
||||
|
||||
mi->avg_ampdu_len = MINSTREL_FRAC(1, 1);
|
||||
|
||||
/* When using MRR, sample more on the first attempt, without delay */
|
||||
@ -1456,10 +1661,8 @@ minstrel_ht_update_caps(void *priv, struct ieee80211_supported_band *sband,
|
||||
int bw, nss;
|
||||
|
||||
mi->supported[i] = 0;
|
||||
if (i == MINSTREL_CCK_GROUP) {
|
||||
minstrel_ht_update_cck(mp, mi, sband, sta);
|
||||
if (minstrel_ht_is_legacy_group(i))
|
||||
continue;
|
||||
}
|
||||
|
||||
if (gflags & IEEE80211_TX_RC_SHORT_GI) {
|
||||
if (gflags & IEEE80211_TX_RC_40_MHZ_WIDTH) {
|
||||
@ -1520,24 +1723,12 @@ minstrel_ht_update_caps(void *priv, struct ieee80211_supported_band *sband,
|
||||
n_supported++;
|
||||
}
|
||||
|
||||
if (!n_supported)
|
||||
goto use_legacy;
|
||||
|
||||
mi->supported[MINSTREL_CCK_GROUP] |= mi->cck_supported_short << 4;
|
||||
minstrel_ht_update_cck(mp, mi, sband, sta);
|
||||
minstrel_ht_update_ofdm(mp, mi, sband, sta);
|
||||
|
||||
/* create an initial rate table with the lowest supported rates */
|
||||
minstrel_ht_update_stats(mp, mi, true);
|
||||
minstrel_ht_update_rates(mp, mi);
|
||||
|
||||
return;
|
||||
|
||||
use_legacy:
|
||||
msp->is_ht = false;
|
||||
memset(&msp->legacy, 0, sizeof(msp->legacy));
|
||||
msp->legacy.r = msp->ratelist;
|
||||
msp->legacy.sample_table = msp->sample_table;
|
||||
return mac80211_minstrel.rate_init(priv, sband, chandef, sta,
|
||||
&msp->legacy);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -1561,7 +1752,7 @@ static void *
|
||||
minstrel_ht_alloc_sta(void *priv, struct ieee80211_sta *sta, gfp_t gfp)
|
||||
{
|
||||
struct ieee80211_supported_band *sband;
|
||||
struct minstrel_ht_sta_priv *msp;
|
||||
struct minstrel_ht_sta *mi;
|
||||
struct minstrel_priv *mp = priv;
|
||||
struct ieee80211_hw *hw = mp->hw;
|
||||
int max_rates = 0;
|
||||
@ -1573,72 +1764,80 @@ minstrel_ht_alloc_sta(void *priv, struct ieee80211_sta *sta, gfp_t gfp)
|
||||
max_rates = sband->n_bitrates;
|
||||
}
|
||||
|
||||
msp = kzalloc(sizeof(*msp), gfp);
|
||||
if (!msp)
|
||||
return NULL;
|
||||
|
||||
msp->ratelist = kcalloc(max_rates, sizeof(struct minstrel_rate), gfp);
|
||||
if (!msp->ratelist)
|
||||
goto error;
|
||||
|
||||
msp->sample_table = kmalloc_array(max_rates, SAMPLE_COLUMNS, gfp);
|
||||
if (!msp->sample_table)
|
||||
goto error1;
|
||||
|
||||
return msp;
|
||||
|
||||
error1:
|
||||
kfree(msp->ratelist);
|
||||
error:
|
||||
kfree(msp);
|
||||
return NULL;
|
||||
return kzalloc(sizeof(*mi), gfp);
|
||||
}
|
||||
|
||||
static void
|
||||
minstrel_ht_free_sta(void *priv, struct ieee80211_sta *sta, void *priv_sta)
|
||||
{
|
||||
struct minstrel_ht_sta_priv *msp = priv_sta;
|
||||
kfree(priv_sta);
|
||||
}
|
||||
|
||||
kfree(msp->sample_table);
|
||||
kfree(msp->ratelist);
|
||||
kfree(msp);
|
||||
static void
|
||||
minstrel_ht_fill_rate_array(u8 *dest, struct ieee80211_supported_band *sband,
|
||||
const s16 *bitrates, int n_rates, u32 rate_flags)
|
||||
{
|
||||
int i, j;
|
||||
|
||||
for (i = 0; i < sband->n_bitrates; i++) {
|
||||
struct ieee80211_rate *rate = &sband->bitrates[i];
|
||||
|
||||
if ((rate_flags & sband->bitrates[i].flags) != rate_flags)
|
||||
continue;
|
||||
|
||||
for (j = 0; j < n_rates; j++) {
|
||||
if (rate->bitrate != bitrates[j])
|
||||
continue;
|
||||
|
||||
dest[j] = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
minstrel_ht_init_cck_rates(struct minstrel_priv *mp)
|
||||
{
|
||||
static const int bitrates[4] = { 10, 20, 55, 110 };
|
||||
static const s16 bitrates[4] = { 10, 20, 55, 110 };
|
||||
struct ieee80211_supported_band *sband;
|
||||
u32 rate_flags = ieee80211_chandef_rate_flags(&mp->hw->conf.chandef);
|
||||
int i, j;
|
||||
|
||||
memset(mp->cck_rates, 0xff, sizeof(mp->cck_rates));
|
||||
sband = mp->hw->wiphy->bands[NL80211_BAND_2GHZ];
|
||||
if (!sband)
|
||||
return;
|
||||
|
||||
for (i = 0; i < sband->n_bitrates; i++) {
|
||||
struct ieee80211_rate *rate = &sband->bitrates[i];
|
||||
BUILD_BUG_ON(ARRAY_SIZE(mp->cck_rates) != ARRAY_SIZE(bitrates));
|
||||
minstrel_ht_fill_rate_array(mp->cck_rates, sband,
|
||||
minstrel_cck_bitrates,
|
||||
ARRAY_SIZE(minstrel_cck_bitrates),
|
||||
rate_flags);
|
||||
}
|
||||
|
||||
if (rate->flags & IEEE80211_RATE_ERP_G)
|
||||
continue;
|
||||
static void
|
||||
minstrel_ht_init_ofdm_rates(struct minstrel_priv *mp, enum nl80211_band band)
|
||||
{
|
||||
static const s16 bitrates[8] = { 60, 90, 120, 180, 240, 360, 480, 540 };
|
||||
struct ieee80211_supported_band *sband;
|
||||
u32 rate_flags = ieee80211_chandef_rate_flags(&mp->hw->conf.chandef);
|
||||
|
||||
if ((rate_flags & sband->bitrates[i].flags) != rate_flags)
|
||||
continue;
|
||||
memset(mp->ofdm_rates[band], 0xff, sizeof(mp->ofdm_rates[band]));
|
||||
sband = mp->hw->wiphy->bands[band];
|
||||
if (!sband)
|
||||
return;
|
||||
|
||||
for (j = 0; j < ARRAY_SIZE(bitrates); j++) {
|
||||
if (rate->bitrate != bitrates[j])
|
||||
continue;
|
||||
|
||||
mp->cck_rates[j] = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
BUILD_BUG_ON(ARRAY_SIZE(mp->ofdm_rates[band]) != ARRAY_SIZE(bitrates));
|
||||
minstrel_ht_fill_rate_array(mp->ofdm_rates[band], sband,
|
||||
minstrel_ofdm_bitrates,
|
||||
ARRAY_SIZE(minstrel_ofdm_bitrates),
|
||||
rate_flags);
|
||||
}
|
||||
|
||||
static void *
|
||||
minstrel_ht_alloc(struct ieee80211_hw *hw)
|
||||
{
|
||||
struct minstrel_priv *mp;
|
||||
int i;
|
||||
|
||||
mp = kzalloc(sizeof(struct minstrel_priv), GFP_ATOMIC);
|
||||
if (!mp)
|
||||
@ -1652,12 +1851,6 @@ minstrel_ht_alloc(struct ieee80211_hw *hw)
|
||||
mp->cw_min = 15;
|
||||
mp->cw_max = 1023;
|
||||
|
||||
/* number of packets (in %) to use for sampling other rates
|
||||
* sample less often for non-mrr packets, because the overhead
|
||||
* is much higher than with mrr */
|
||||
mp->lookaround_rate = 5;
|
||||
mp->lookaround_rate_mrr = 10;
|
||||
|
||||
/* maximum time that the hw is allowed to stay in one MRR segment */
|
||||
mp->segment_size = 6000;
|
||||
|
||||
@ -1672,9 +1865,10 @@ minstrel_ht_alloc(struct ieee80211_hw *hw)
|
||||
|
||||
mp->hw = hw;
|
||||
mp->update_interval = HZ / 10;
|
||||
mp->new_avg = true;
|
||||
|
||||
minstrel_ht_init_cck_rates(mp);
|
||||
for (i = 0; i < ARRAY_SIZE(mp->hw->wiphy->bands); i++)
|
||||
minstrel_ht_init_ofdm_rates(mp, i);
|
||||
|
||||
return mp;
|
||||
}
|
||||
@ -1690,8 +1884,6 @@ static void minstrel_ht_add_debugfs(struct ieee80211_hw *hw, void *priv,
|
||||
&mp->fixed_rate_idx);
|
||||
debugfs_create_u32("sample_switch", S_IRUGO | S_IWUSR, debugfsdir,
|
||||
&mp->sample_switch);
|
||||
debugfs_create_bool("new_avg", S_IRUGO | S_IWUSR, debugfsdir,
|
||||
&mp->new_avg);
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -1703,13 +1895,9 @@ minstrel_ht_free(void *priv)
|
||||
|
||||
static u32 minstrel_ht_get_expected_throughput(void *priv_sta)
|
||||
{
|
||||
struct minstrel_ht_sta_priv *msp = priv_sta;
|
||||
struct minstrel_ht_sta *mi = &msp->ht;
|
||||
struct minstrel_ht_sta *mi = priv_sta;
|
||||
int i, j, prob, tp_avg;
|
||||
|
||||
if (!msp->is_ht)
|
||||
return mac80211_minstrel.get_expected_throughput(priv_sta);
|
||||
|
||||
i = mi->max_tp_rate[0] / MCS_GROUP_RATES;
|
||||
j = mi->max_tp_rate[0] % MCS_GROUP_RATES;
|
||||
prob = mi->groups[i].rates[j].prob_avg;
|
||||
|
@ -6,6 +6,33 @@
|
||||
#ifndef __RC_MINSTREL_HT_H
|
||||
#define __RC_MINSTREL_HT_H
|
||||
|
||||
/* number of highest throughput rates to consider*/
|
||||
#define MAX_THR_RATES 4
|
||||
#define SAMPLE_COLUMNS 10 /* number of columns in sample table */
|
||||
|
||||
/* scaled fraction values */
|
||||
#define MINSTREL_SCALE 12
|
||||
#define MINSTREL_FRAC(val, div) (((val) << MINSTREL_SCALE) / div)
|
||||
#define MINSTREL_TRUNC(val) ((val) >> MINSTREL_SCALE)
|
||||
|
||||
#define EWMA_LEVEL 96 /* ewma weighting factor [/EWMA_DIV] */
|
||||
#define EWMA_DIV 128
|
||||
|
||||
/*
|
||||
* Coefficients for moving average with noise filter (period=16),
|
||||
* scaled by 10 bits
|
||||
*
|
||||
* a1 = exp(-pi * sqrt(2) / period)
|
||||
* coeff2 = 2 * a1 * cos(sqrt(2) * 2 * pi / period)
|
||||
* coeff3 = -sqr(a1)
|
||||
* coeff1 = 1 - coeff2 - coeff3
|
||||
*/
|
||||
#define MINSTREL_AVG_COEFF1 (MINSTREL_FRAC(1, 1) - \
|
||||
MINSTREL_AVG_COEFF2 - \
|
||||
MINSTREL_AVG_COEFF3)
|
||||
#define MINSTREL_AVG_COEFF2 0x00001499
|
||||
#define MINSTREL_AVG_COEFF3 -0x0000092e
|
||||
|
||||
/*
|
||||
* The number of streams can be changed to 2 to reduce code
|
||||
* size and memory footprint.
|
||||
@ -18,17 +45,43 @@
|
||||
MINSTREL_HT_STREAM_GROUPS)
|
||||
#define MINSTREL_VHT_GROUPS_NB (MINSTREL_MAX_STREAMS * \
|
||||
MINSTREL_VHT_STREAM_GROUPS)
|
||||
#define MINSTREL_CCK_GROUPS_NB 1
|
||||
#define MINSTREL_LEGACY_GROUPS_NB 2
|
||||
#define MINSTREL_GROUPS_NB (MINSTREL_HT_GROUPS_NB + \
|
||||
MINSTREL_VHT_GROUPS_NB + \
|
||||
MINSTREL_CCK_GROUPS_NB)
|
||||
MINSTREL_LEGACY_GROUPS_NB)
|
||||
|
||||
#define MINSTREL_HT_GROUP_0 0
|
||||
#define MINSTREL_CCK_GROUP (MINSTREL_HT_GROUP_0 + MINSTREL_HT_GROUPS_NB)
|
||||
#define MINSTREL_VHT_GROUP_0 (MINSTREL_CCK_GROUP + 1)
|
||||
#define MINSTREL_OFDM_GROUP (MINSTREL_CCK_GROUP + 1)
|
||||
#define MINSTREL_VHT_GROUP_0 (MINSTREL_OFDM_GROUP + 1)
|
||||
|
||||
#define MCS_GROUP_RATES 10
|
||||
|
||||
struct minstrel_priv {
|
||||
struct ieee80211_hw *hw;
|
||||
bool has_mrr;
|
||||
u32 sample_switch;
|
||||
unsigned int cw_min;
|
||||
unsigned int cw_max;
|
||||
unsigned int max_retry;
|
||||
unsigned int segment_size;
|
||||
unsigned int update_interval;
|
||||
|
||||
u8 cck_rates[4];
|
||||
u8 ofdm_rates[NUM_NL80211_BANDS][8];
|
||||
|
||||
#ifdef CONFIG_MAC80211_DEBUGFS
|
||||
/*
|
||||
* enable fixed rate processing per RC
|
||||
* - write static index to debugfs:ieee80211/phyX/rc/fixed_rate_idx
|
||||
* - write -1 to enable RC processing again
|
||||
* - setting will be applied on next update
|
||||
*/
|
||||
u32 fixed_rate_idx;
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
struct mcs_group {
|
||||
u16 flags;
|
||||
u8 streams;
|
||||
@ -37,8 +90,30 @@ struct mcs_group {
|
||||
u16 duration[MCS_GROUP_RATES];
|
||||
};
|
||||
|
||||
extern const s16 minstrel_cck_bitrates[4];
|
||||
extern const s16 minstrel_ofdm_bitrates[8];
|
||||
extern const struct mcs_group minstrel_mcs_groups[];
|
||||
|
||||
struct minstrel_rate_stats {
|
||||
/* current / last sampling period attempts/success counters */
|
||||
u16 attempts, last_attempts;
|
||||
u16 success, last_success;
|
||||
|
||||
/* total attempts/success counters */
|
||||
u32 att_hist, succ_hist;
|
||||
|
||||
/* prob_avg - moving average of prob */
|
||||
u16 prob_avg;
|
||||
u16 prob_avg_1;
|
||||
|
||||
/* maximum retry counts */
|
||||
u8 retry_count;
|
||||
u8 retry_count_rtscts;
|
||||
|
||||
u8 sample_skipped;
|
||||
bool retry_updated;
|
||||
};
|
||||
|
||||
struct minstrel_mcs_group_data {
|
||||
u8 index;
|
||||
u8 column;
|
||||
@ -77,6 +152,8 @@ struct minstrel_ht_sta {
|
||||
/* overhead time in usec for each frame */
|
||||
unsigned int overhead;
|
||||
unsigned int overhead_rtscts;
|
||||
unsigned int overhead_legacy;
|
||||
unsigned int overhead_legacy_rtscts;
|
||||
|
||||
unsigned int total_packets_last;
|
||||
unsigned int total_packets_cur;
|
||||
@ -97,8 +174,7 @@ struct minstrel_ht_sta {
|
||||
/* current MCS group to be sampled */
|
||||
u8 sample_group;
|
||||
|
||||
u8 cck_supported;
|
||||
u8 cck_supported_short;
|
||||
u8 band;
|
||||
|
||||
/* Bitfield of supported MCS rates of all groups */
|
||||
u16 supported[MINSTREL_GROUPS_NB];
|
||||
@ -107,16 +183,6 @@ struct minstrel_ht_sta {
|
||||
struct minstrel_mcs_group_data groups[MINSTREL_GROUPS_NB];
|
||||
};
|
||||
|
||||
struct minstrel_ht_sta_priv {
|
||||
union {
|
||||
struct minstrel_ht_sta ht;
|
||||
struct minstrel_sta_info legacy;
|
||||
};
|
||||
void *ratelist;
|
||||
void *sample_table;
|
||||
bool is_ht;
|
||||
};
|
||||
|
||||
void minstrel_ht_add_sta_debugfs(void *priv, void *priv_sta, struct dentry *dir);
|
||||
int minstrel_ht_get_tp_avg(struct minstrel_ht_sta *mi, int group, int rate,
|
||||
int prob_avg);
|
||||
|
@ -9,9 +9,13 @@
|
||||
#include <linux/ieee80211.h>
|
||||
#include <linux/export.h>
|
||||
#include <net/mac80211.h>
|
||||
#include "rc80211_minstrel.h"
|
||||
#include "rc80211_minstrel_ht.h"
|
||||
|
||||
struct minstrel_debugfs_info {
|
||||
size_t len;
|
||||
char buf[];
|
||||
};
|
||||
|
||||
static ssize_t
|
||||
minstrel_stats_read(struct file *file, char __user *buf, size_t len, loff_t *ppos)
|
||||
{
|
||||
@ -52,7 +56,6 @@ minstrel_ht_stats_dump(struct minstrel_ht_sta *mi, int i, char *p)
|
||||
|
||||
for (j = 0; j < MCS_GROUP_RATES; j++) {
|
||||
struct minstrel_rate_stats *mrs = &mi->groups[i].rates[j];
|
||||
static const int bitrates[4] = { 10, 20, 55, 110 };
|
||||
int idx = i * MCS_GROUP_RATES + j;
|
||||
unsigned int duration;
|
||||
|
||||
@ -67,6 +70,9 @@ minstrel_ht_stats_dump(struct minstrel_ht_sta *mi, int i, char *p)
|
||||
p += sprintf(p, "VHT%c0 ", htmode);
|
||||
p += sprintf(p, "%cGI ", gimode);
|
||||
p += sprintf(p, "%d ", mg->streams);
|
||||
} else if (i == MINSTREL_OFDM_GROUP) {
|
||||
p += sprintf(p, "OFDM ");
|
||||
p += sprintf(p, "1 ");
|
||||
} else {
|
||||
p += sprintf(p, "CCK ");
|
||||
p += sprintf(p, "%cP ", j < 4 ? 'L' : 'S');
|
||||
@ -84,7 +90,12 @@ minstrel_ht_stats_dump(struct minstrel_ht_sta *mi, int i, char *p)
|
||||
} else if (gflags & IEEE80211_TX_RC_VHT_MCS) {
|
||||
p += sprintf(p, " MCS%-1u/%1u", j, mg->streams);
|
||||
} else {
|
||||
int r = bitrates[j % 4];
|
||||
int r;
|
||||
|
||||
if (i == MINSTREL_OFDM_GROUP)
|
||||
r = minstrel_ofdm_bitrates[j % 8];
|
||||
else
|
||||
r = minstrel_cck_bitrates[j % 4];
|
||||
|
||||
p += sprintf(p, " %2u.%1uM", r / 10, r % 10);
|
||||
}
|
||||
@ -120,20 +131,11 @@ minstrel_ht_stats_dump(struct minstrel_ht_sta *mi, int i, char *p)
|
||||
static int
|
||||
minstrel_ht_stats_open(struct inode *inode, struct file *file)
|
||||
{
|
||||
struct minstrel_ht_sta_priv *msp = inode->i_private;
|
||||
struct minstrel_ht_sta *mi = &msp->ht;
|
||||
struct minstrel_ht_sta *mi = inode->i_private;
|
||||
struct minstrel_debugfs_info *ms;
|
||||
unsigned int i;
|
||||
int ret;
|
||||
char *p;
|
||||
|
||||
if (!msp->is_ht) {
|
||||
inode->i_private = &msp->legacy;
|
||||
ret = minstrel_stats_open(inode, file);
|
||||
inode->i_private = msp;
|
||||
return ret;
|
||||
}
|
||||
|
||||
ms = kmalloc(32768, GFP_KERNEL);
|
||||
if (!ms)
|
||||
return -ENOMEM;
|
||||
@ -199,7 +201,6 @@ minstrel_ht_stats_csv_dump(struct minstrel_ht_sta *mi, int i, char *p)
|
||||
|
||||
for (j = 0; j < MCS_GROUP_RATES; j++) {
|
||||
struct minstrel_rate_stats *mrs = &mi->groups[i].rates[j];
|
||||
static const int bitrates[4] = { 10, 20, 55, 110 };
|
||||
int idx = i * MCS_GROUP_RATES + j;
|
||||
unsigned int duration;
|
||||
|
||||
@ -214,6 +215,8 @@ minstrel_ht_stats_csv_dump(struct minstrel_ht_sta *mi, int i, char *p)
|
||||
p += sprintf(p, "VHT%c0,", htmode);
|
||||
p += sprintf(p, "%cGI,", gimode);
|
||||
p += sprintf(p, "%d,", mg->streams);
|
||||
} else if (i == MINSTREL_OFDM_GROUP) {
|
||||
p += sprintf(p, "OFDM,,1,");
|
||||
} else {
|
||||
p += sprintf(p, "CCK,");
|
||||
p += sprintf(p, "%cP,", j < 4 ? 'L' : 'S');
|
||||
@ -231,7 +234,13 @@ minstrel_ht_stats_csv_dump(struct minstrel_ht_sta *mi, int i, char *p)
|
||||
} else if (gflags & IEEE80211_TX_RC_VHT_MCS) {
|
||||
p += sprintf(p, ",MCS%-1u/%1u,", j, mg->streams);
|
||||
} else {
|
||||
int r = bitrates[j % 4];
|
||||
int r;
|
||||
|
||||
if (i == MINSTREL_OFDM_GROUP)
|
||||
r = minstrel_ofdm_bitrates[j % 8];
|
||||
else
|
||||
r = minstrel_cck_bitrates[j % 4];
|
||||
|
||||
p += sprintf(p, ",%2u.%1uM,", r / 10, r % 10);
|
||||
}
|
||||
|
||||
@ -270,22 +279,12 @@ minstrel_ht_stats_csv_dump(struct minstrel_ht_sta *mi, int i, char *p)
|
||||
static int
|
||||
minstrel_ht_stats_csv_open(struct inode *inode, struct file *file)
|
||||
{
|
||||
struct minstrel_ht_sta_priv *msp = inode->i_private;
|
||||
struct minstrel_ht_sta *mi = &msp->ht;
|
||||
struct minstrel_ht_sta *mi = inode->i_private;
|
||||
struct minstrel_debugfs_info *ms;
|
||||
unsigned int i;
|
||||
int ret;
|
||||
char *p;
|
||||
|
||||
if (!msp->is_ht) {
|
||||
inode->i_private = &msp->legacy;
|
||||
ret = minstrel_stats_csv_open(inode, file);
|
||||
inode->i_private = msp;
|
||||
return ret;
|
||||
}
|
||||
|
||||
ms = kmalloc(32768, GFP_KERNEL);
|
||||
|
||||
if (!ms)
|
||||
return -ENOMEM;
|
||||
|
||||
@ -316,10 +315,8 @@ static const struct file_operations minstrel_ht_stat_csv_fops = {
|
||||
void
|
||||
minstrel_ht_add_sta_debugfs(void *priv, void *priv_sta, struct dentry *dir)
|
||||
{
|
||||
struct minstrel_ht_sta_priv *msp = priv_sta;
|
||||
|
||||
debugfs_create_file("rc_stats", 0444, dir, msp,
|
||||
debugfs_create_file("rc_stats", 0444, dir, priv_sta,
|
||||
&minstrel_ht_stat_fops);
|
||||
debugfs_create_file("rc_stats_csv", 0444, dir, msp,
|
||||
debugfs_create_file("rc_stats_csv", 0444, dir, priv_sta,
|
||||
&minstrel_ht_stat_csv_fops);
|
||||
}
|
||||
|
@ -4095,7 +4095,9 @@ void ieee80211_check_fast_rx(struct sta_info *sta)
|
||||
.vif_type = sdata->vif.type,
|
||||
.control_port_protocol = sdata->control_port_protocol,
|
||||
}, *old, *new = NULL;
|
||||
bool set_offload = false;
|
||||
bool assign = false;
|
||||
bool offload;
|
||||
|
||||
/* use sparse to check that we don't return without updating */
|
||||
__acquire(check_fast_rx);
|
||||
@ -4208,6 +4210,17 @@ void ieee80211_check_fast_rx(struct sta_info *sta)
|
||||
if (assign)
|
||||
new = kmemdup(&fastrx, sizeof(fastrx), GFP_KERNEL);
|
||||
|
||||
offload = assign &&
|
||||
(sdata->vif.offload_flags & IEEE80211_OFFLOAD_DECAP_ENABLED);
|
||||
|
||||
if (offload)
|
||||
set_offload = !test_and_set_sta_flag(sta, WLAN_STA_DECAP_OFFLOAD);
|
||||
else
|
||||
set_offload = test_and_clear_sta_flag(sta, WLAN_STA_DECAP_OFFLOAD);
|
||||
|
||||
if (set_offload)
|
||||
drv_sta_set_decap_offload(local, sdata, &sta->sta, assign);
|
||||
|
||||
spin_lock_bh(&sta->lock);
|
||||
old = rcu_dereference_protected(sta->fast_rx, true);
|
||||
rcu_assign_pointer(sta->fast_rx, new);
|
||||
@ -4254,6 +4267,104 @@ void ieee80211_check_fast_rx_iface(struct ieee80211_sub_if_data *sdata)
|
||||
mutex_unlock(&local->sta_mtx);
|
||||
}
|
||||
|
||||
static void ieee80211_rx_8023(struct ieee80211_rx_data *rx,
|
||||
struct ieee80211_fast_rx *fast_rx,
|
||||
int orig_len)
|
||||
{
|
||||
struct ieee80211_sta_rx_stats *stats;
|
||||
struct ieee80211_rx_status *status = IEEE80211_SKB_RXCB(rx->skb);
|
||||
struct sta_info *sta = rx->sta;
|
||||
struct sk_buff *skb = rx->skb;
|
||||
void *sa = skb->data + ETH_ALEN;
|
||||
void *da = skb->data;
|
||||
|
||||
stats = &sta->rx_stats;
|
||||
if (fast_rx->uses_rss)
|
||||
stats = this_cpu_ptr(sta->pcpu_rx_stats);
|
||||
|
||||
/* statistics part of ieee80211_rx_h_sta_process() */
|
||||
if (!(status->flag & RX_FLAG_NO_SIGNAL_VAL)) {
|
||||
stats->last_signal = status->signal;
|
||||
if (!fast_rx->uses_rss)
|
||||
ewma_signal_add(&sta->rx_stats_avg.signal,
|
||||
-status->signal);
|
||||
}
|
||||
|
||||
if (status->chains) {
|
||||
int i;
|
||||
|
||||
stats->chains = status->chains;
|
||||
for (i = 0; i < ARRAY_SIZE(status->chain_signal); i++) {
|
||||
int signal = status->chain_signal[i];
|
||||
|
||||
if (!(status->chains & BIT(i)))
|
||||
continue;
|
||||
|
||||
stats->chain_signal_last[i] = signal;
|
||||
if (!fast_rx->uses_rss)
|
||||
ewma_signal_add(&sta->rx_stats_avg.chain_signal[i],
|
||||
-signal);
|
||||
}
|
||||
}
|
||||
/* end of statistics */
|
||||
|
||||
stats->last_rx = jiffies;
|
||||
stats->last_rate = sta_stats_encode_rate(status);
|
||||
|
||||
stats->fragments++;
|
||||
stats->packets++;
|
||||
|
||||
skb->dev = fast_rx->dev;
|
||||
|
||||
dev_sw_netstats_rx_add(fast_rx->dev, skb->len);
|
||||
|
||||
/* The seqno index has the same property as needed
|
||||
* for the rx_msdu field, i.e. it is IEEE80211_NUM_TIDS
|
||||
* for non-QoS-data frames. Here we know it's a data
|
||||
* frame, so count MSDUs.
|
||||
*/
|
||||
u64_stats_update_begin(&stats->syncp);
|
||||
stats->msdu[rx->seqno_idx]++;
|
||||
stats->bytes += orig_len;
|
||||
u64_stats_update_end(&stats->syncp);
|
||||
|
||||
if (fast_rx->internal_forward) {
|
||||
struct sk_buff *xmit_skb = NULL;
|
||||
if (is_multicast_ether_addr(da)) {
|
||||
xmit_skb = skb_copy(skb, GFP_ATOMIC);
|
||||
} else if (!ether_addr_equal(da, sa) &&
|
||||
sta_info_get(rx->sdata, da)) {
|
||||
xmit_skb = skb;
|
||||
skb = NULL;
|
||||
}
|
||||
|
||||
if (xmit_skb) {
|
||||
/*
|
||||
* Send to wireless media and increase priority by 256
|
||||
* to keep the received priority instead of
|
||||
* reclassifying the frame (see cfg80211_classify8021d).
|
||||
*/
|
||||
xmit_skb->priority += 256;
|
||||
xmit_skb->protocol = htons(ETH_P_802_3);
|
||||
skb_reset_network_header(xmit_skb);
|
||||
skb_reset_mac_header(xmit_skb);
|
||||
dev_queue_xmit(xmit_skb);
|
||||
}
|
||||
|
||||
if (!skb)
|
||||
return;
|
||||
}
|
||||
|
||||
/* deliver to local stack */
|
||||
skb->protocol = eth_type_trans(skb, fast_rx->dev);
|
||||
memset(skb->cb, 0, sizeof(skb->cb));
|
||||
if (rx->list)
|
||||
list_add_tail(&skb->list, rx->list);
|
||||
else
|
||||
netif_receive_skb(skb);
|
||||
|
||||
}
|
||||
|
||||
static bool ieee80211_invoke_fast_rx(struct ieee80211_rx_data *rx,
|
||||
struct ieee80211_fast_rx *fast_rx)
|
||||
{
|
||||
@ -4274,9 +4385,6 @@ static bool ieee80211_invoke_fast_rx(struct ieee80211_rx_data *rx,
|
||||
} addrs __aligned(2);
|
||||
struct ieee80211_sta_rx_stats *stats = &sta->rx_stats;
|
||||
|
||||
if (fast_rx->uses_rss)
|
||||
stats = this_cpu_ptr(sta->pcpu_rx_stats);
|
||||
|
||||
/* for parallel-rx, we need to have DUP_VALIDATED, otherwise we write
|
||||
* to a common data structure; drivers can implement that per queue
|
||||
* but we don't have that information in mac80211
|
||||
@ -4350,32 +4458,6 @@ static bool ieee80211_invoke_fast_rx(struct ieee80211_rx_data *rx,
|
||||
pskb_trim(skb, skb->len - fast_rx->icv_len))
|
||||
goto drop;
|
||||
|
||||
/* statistics part of ieee80211_rx_h_sta_process() */
|
||||
if (!(status->flag & RX_FLAG_NO_SIGNAL_VAL)) {
|
||||
stats->last_signal = status->signal;
|
||||
if (!fast_rx->uses_rss)
|
||||
ewma_signal_add(&sta->rx_stats_avg.signal,
|
||||
-status->signal);
|
||||
}
|
||||
|
||||
if (status->chains) {
|
||||
int i;
|
||||
|
||||
stats->chains = status->chains;
|
||||
for (i = 0; i < ARRAY_SIZE(status->chain_signal); i++) {
|
||||
int signal = status->chain_signal[i];
|
||||
|
||||
if (!(status->chains & BIT(i)))
|
||||
continue;
|
||||
|
||||
stats->chain_signal_last[i] = signal;
|
||||
if (!fast_rx->uses_rss)
|
||||
ewma_signal_add(&sta->rx_stats_avg.chain_signal[i],
|
||||
-signal);
|
||||
}
|
||||
}
|
||||
/* end of statistics */
|
||||
|
||||
if (rx->key && !ieee80211_has_protected(hdr->frame_control))
|
||||
goto drop;
|
||||
|
||||
@ -4387,12 +4469,6 @@ static bool ieee80211_invoke_fast_rx(struct ieee80211_rx_data *rx,
|
||||
return true;
|
||||
}
|
||||
|
||||
stats->last_rx = jiffies;
|
||||
stats->last_rate = sta_stats_encode_rate(status);
|
||||
|
||||
stats->fragments++;
|
||||
stats->packets++;
|
||||
|
||||
/* do the header conversion - first grab the addresses */
|
||||
ether_addr_copy(addrs.da, skb->data + fast_rx->da_offs);
|
||||
ether_addr_copy(addrs.sa, skb->data + fast_rx->sa_offs);
|
||||
@ -4401,58 +4477,14 @@ static bool ieee80211_invoke_fast_rx(struct ieee80211_rx_data *rx,
|
||||
/* push the addresses in front */
|
||||
memcpy(skb_push(skb, sizeof(addrs)), &addrs, sizeof(addrs));
|
||||
|
||||
skb->dev = fast_rx->dev;
|
||||
|
||||
dev_sw_netstats_rx_add(fast_rx->dev, skb->len);
|
||||
|
||||
/* The seqno index has the same property as needed
|
||||
* for the rx_msdu field, i.e. it is IEEE80211_NUM_TIDS
|
||||
* for non-QoS-data frames. Here we know it's a data
|
||||
* frame, so count MSDUs.
|
||||
*/
|
||||
u64_stats_update_begin(&stats->syncp);
|
||||
stats->msdu[rx->seqno_idx]++;
|
||||
stats->bytes += orig_len;
|
||||
u64_stats_update_end(&stats->syncp);
|
||||
|
||||
if (fast_rx->internal_forward) {
|
||||
struct sk_buff *xmit_skb = NULL;
|
||||
if (is_multicast_ether_addr(addrs.da)) {
|
||||
xmit_skb = skb_copy(skb, GFP_ATOMIC);
|
||||
} else if (!ether_addr_equal(addrs.da, addrs.sa) &&
|
||||
sta_info_get(rx->sdata, addrs.da)) {
|
||||
xmit_skb = skb;
|
||||
skb = NULL;
|
||||
}
|
||||
|
||||
if (xmit_skb) {
|
||||
/*
|
||||
* Send to wireless media and increase priority by 256
|
||||
* to keep the received priority instead of
|
||||
* reclassifying the frame (see cfg80211_classify8021d).
|
||||
*/
|
||||
xmit_skb->priority += 256;
|
||||
xmit_skb->protocol = htons(ETH_P_802_3);
|
||||
skb_reset_network_header(xmit_skb);
|
||||
skb_reset_mac_header(xmit_skb);
|
||||
dev_queue_xmit(xmit_skb);
|
||||
}
|
||||
|
||||
if (!skb)
|
||||
return true;
|
||||
}
|
||||
|
||||
/* deliver to local stack */
|
||||
skb->protocol = eth_type_trans(skb, fast_rx->dev);
|
||||
memset(skb->cb, 0, sizeof(skb->cb));
|
||||
if (rx->list)
|
||||
list_add_tail(&skb->list, rx->list);
|
||||
else
|
||||
netif_receive_skb(skb);
|
||||
ieee80211_rx_8023(rx, fast_rx, orig_len);
|
||||
|
||||
return true;
|
||||
drop:
|
||||
dev_kfree_skb(skb);
|
||||
if (fast_rx->uses_rss)
|
||||
stats = this_cpu_ptr(sta->pcpu_rx_stats);
|
||||
|
||||
stats->dropped++;
|
||||
return true;
|
||||
}
|
||||
@ -4506,6 +4538,43 @@ static bool ieee80211_prepare_and_rx_handle(struct ieee80211_rx_data *rx,
|
||||
return true;
|
||||
}
|
||||
|
||||
static void __ieee80211_rx_handle_8023(struct ieee80211_hw *hw,
|
||||
struct ieee80211_sta *pubsta,
|
||||
struct sk_buff *skb,
|
||||
struct list_head *list)
|
||||
{
|
||||
struct ieee80211_local *local = hw_to_local(hw);
|
||||
struct ieee80211_fast_rx *fast_rx;
|
||||
struct ieee80211_rx_data rx;
|
||||
|
||||
memset(&rx, 0, sizeof(rx));
|
||||
rx.skb = skb;
|
||||
rx.local = local;
|
||||
rx.list = list;
|
||||
|
||||
I802_DEBUG_INC(local->dot11ReceivedFragmentCount);
|
||||
|
||||
/* drop frame if too short for header */
|
||||
if (skb->len < sizeof(struct ethhdr))
|
||||
goto drop;
|
||||
|
||||
if (!pubsta)
|
||||
goto drop;
|
||||
|
||||
rx.sta = container_of(pubsta, struct sta_info, sta);
|
||||
rx.sdata = rx.sta->sdata;
|
||||
|
||||
fast_rx = rcu_dereference(rx.sta->fast_rx);
|
||||
if (!fast_rx)
|
||||
goto drop;
|
||||
|
||||
ieee80211_rx_8023(&rx, fast_rx, skb->len);
|
||||
return;
|
||||
|
||||
drop:
|
||||
dev_kfree_skb(skb);
|
||||
}
|
||||
|
||||
/*
|
||||
* This is the actual Rx frames handler. as it belongs to Rx path it must
|
||||
* be called with rcu_read_lock protection.
|
||||
@ -4737,13 +4806,17 @@ void ieee80211_rx_list(struct ieee80211_hw *hw, struct ieee80211_sta *pubsta,
|
||||
* if it was previously present.
|
||||
* Also, frames with less than 16 bytes are dropped.
|
||||
*/
|
||||
skb = ieee80211_rx_monitor(local, skb, rate);
|
||||
if (!(status->flag & RX_FLAG_8023))
|
||||
skb = ieee80211_rx_monitor(local, skb, rate);
|
||||
if (skb) {
|
||||
ieee80211_tpt_led_trig_rx(local,
|
||||
((struct ieee80211_hdr *)skb->data)->frame_control,
|
||||
skb->len);
|
||||
|
||||
__ieee80211_rx_handle_packet(hw, pubsta, skb, list);
|
||||
if (status->flag & RX_FLAG_8023)
|
||||
__ieee80211_rx_handle_8023(hw, pubsta, skb, list);
|
||||
else
|
||||
__ieee80211_rx_handle_packet(hw, pubsta, skb, list);
|
||||
}
|
||||
|
||||
kcov_remote_stop();
|
||||
|
@ -71,6 +71,7 @@
|
||||
* until pending frames are delivered
|
||||
* @WLAN_STA_USES_ENCRYPTION: This station was configured for encryption,
|
||||
* so drop all packets without a key later.
|
||||
* @WLAN_STA_DECAP_OFFLOAD: This station uses rx decap offload
|
||||
*
|
||||
* @NUM_WLAN_STA_FLAGS: number of defined flags
|
||||
*/
|
||||
@ -102,6 +103,7 @@ enum ieee80211_sta_info_flags {
|
||||
WLAN_STA_MPSP_RECIPIENT,
|
||||
WLAN_STA_PS_DELIVER,
|
||||
WLAN_STA_USES_ENCRYPTION,
|
||||
WLAN_STA_DECAP_OFFLOAD,
|
||||
|
||||
NUM_WLAN_STA_FLAGS,
|
||||
};
|
||||
|
@ -1927,7 +1927,7 @@ ieee80211_process_tdls_channel_switch(struct ieee80211_sub_if_data *sdata,
|
||||
struct ieee80211_tdls_data *tf = (void *)skb->data;
|
||||
struct wiphy *wiphy = sdata->local->hw.wiphy;
|
||||
|
||||
ASSERT_RTNL();
|
||||
lockdep_assert_wiphy(wiphy);
|
||||
|
||||
/* make sure the driver supports it */
|
||||
if (!(wiphy->features & NL80211_FEATURE_TDLS_CHANNEL_SWITCH))
|
||||
@ -1979,7 +1979,7 @@ void ieee80211_tdls_chsw_work(struct work_struct *wk)
|
||||
struct sk_buff *skb;
|
||||
struct ieee80211_tdls_data *tf;
|
||||
|
||||
rtnl_lock();
|
||||
wiphy_lock(local->hw.wiphy);
|
||||
while ((skb = skb_dequeue(&local->skb_queue_tdls_chsw))) {
|
||||
tf = (struct ieee80211_tdls_data *)skb->data;
|
||||
list_for_each_entry(sdata, &local->interfaces, list) {
|
||||
@ -1994,7 +1994,7 @@ void ieee80211_tdls_chsw_work(struct work_struct *wk)
|
||||
|
||||
kfree_skb(skb);
|
||||
}
|
||||
rtnl_unlock();
|
||||
wiphy_unlock(local->hw.wiphy);
|
||||
}
|
||||
|
||||
void ieee80211_tdls_handle_disconnect(struct ieee80211_sub_if_data *sdata,
|
||||
|
@ -2761,7 +2761,7 @@ DEFINE_EVENT(local_sdata_addr_evt, drv_update_vif_offload,
|
||||
TP_ARGS(local, sdata)
|
||||
);
|
||||
|
||||
TRACE_EVENT(drv_sta_set_4addr,
|
||||
DECLARE_EVENT_CLASS(sta_flag_evt,
|
||||
TP_PROTO(struct ieee80211_local *local,
|
||||
struct ieee80211_sub_if_data *sdata,
|
||||
struct ieee80211_sta *sta, bool enabled),
|
||||
@ -2788,6 +2788,22 @@ TRACE_EVENT(drv_sta_set_4addr,
|
||||
)
|
||||
);
|
||||
|
||||
DEFINE_EVENT(sta_flag_evt, drv_sta_set_4addr,
|
||||
TP_PROTO(struct ieee80211_local *local,
|
||||
struct ieee80211_sub_if_data *sdata,
|
||||
struct ieee80211_sta *sta, bool enabled),
|
||||
|
||||
TP_ARGS(local, sdata, sta, enabled)
|
||||
);
|
||||
|
||||
DEFINE_EVENT(sta_flag_evt, drv_sta_set_decap_offload,
|
||||
TP_PROTO(struct ieee80211_local *local,
|
||||
struct ieee80211_sub_if_data *sdata,
|
||||
struct ieee80211_sta *sta, bool enabled),
|
||||
|
||||
TP_ARGS(local, sdata, sta, enabled)
|
||||
);
|
||||
|
||||
#endif /* !__MAC80211_DRIVER_TRACE || TRACE_HEADER_MULTI_READ */
|
||||
|
||||
#undef TRACE_INCLUDE_PATH
|
||||
|
@ -1309,7 +1309,7 @@ static struct sk_buff *codel_dequeue_func(struct codel_vars *cvars,
|
||||
fq = &local->fq;
|
||||
|
||||
if (cvars == &txqi->def_cvars)
|
||||
flow = &txqi->def_flow;
|
||||
flow = &txqi->tin.default_flow;
|
||||
else
|
||||
flow = &fq->flows[cvars - local->cvars];
|
||||
|
||||
@ -1352,7 +1352,7 @@ static struct sk_buff *fq_tin_dequeue_func(struct fq *fq,
|
||||
cparams = &local->cparams;
|
||||
}
|
||||
|
||||
if (flow == &txqi->def_flow)
|
||||
if (flow == &tin->default_flow)
|
||||
cvars = &txqi->def_cvars;
|
||||
else
|
||||
cvars = &local->cvars[flow - fq->flows];
|
||||
@ -1379,17 +1379,6 @@ static void fq_skb_free_func(struct fq *fq,
|
||||
ieee80211_free_txskb(&local->hw, skb);
|
||||
}
|
||||
|
||||
static struct fq_flow *fq_flow_get_default_func(struct fq *fq,
|
||||
struct fq_tin *tin,
|
||||
int idx,
|
||||
struct sk_buff *skb)
|
||||
{
|
||||
struct txq_info *txqi;
|
||||
|
||||
txqi = container_of(tin, struct txq_info, tin);
|
||||
return &txqi->def_flow;
|
||||
}
|
||||
|
||||
static void ieee80211_txq_enqueue(struct ieee80211_local *local,
|
||||
struct txq_info *txqi,
|
||||
struct sk_buff *skb)
|
||||
@ -1402,8 +1391,7 @@ static void ieee80211_txq_enqueue(struct ieee80211_local *local,
|
||||
|
||||
spin_lock_bh(&fq->lock);
|
||||
fq_tin_enqueue(fq, tin, flow_idx, skb,
|
||||
fq_skb_free_func,
|
||||
fq_flow_get_default_func);
|
||||
fq_skb_free_func);
|
||||
spin_unlock_bh(&fq->lock);
|
||||
}
|
||||
|
||||
@ -1446,7 +1434,6 @@ void ieee80211_txq_init(struct ieee80211_sub_if_data *sdata,
|
||||
struct txq_info *txqi, int tid)
|
||||
{
|
||||
fq_tin_init(&txqi->tin);
|
||||
fq_flow_init(&txqi->def_flow);
|
||||
codel_vars_init(&txqi->def_cvars);
|
||||
codel_stats_init(&txqi->cstats);
|
||||
__skb_queue_head_init(&txqi->frags);
|
||||
@ -2133,6 +2120,10 @@ bool ieee80211_parse_tx_radiotap(struct sk_buff *skb,
|
||||
if (mcs_known & IEEE80211_RADIOTAP_MCS_HAVE_BW &&
|
||||
mcs_bw == IEEE80211_RADIOTAP_MCS_BW_40)
|
||||
rate_flags |= IEEE80211_TX_RC_40_MHZ_WIDTH;
|
||||
|
||||
if (mcs_known & IEEE80211_RADIOTAP_MCS_HAVE_FEC &&
|
||||
mcs_flags & IEEE80211_RADIOTAP_MCS_FEC_LDPC)
|
||||
info->flags |= IEEE80211_TX_CTL_LDPC;
|
||||
break;
|
||||
|
||||
case IEEE80211_RADIOTAP_VHT:
|
||||
@ -3283,8 +3274,7 @@ static bool ieee80211_amsdu_aggregate(struct ieee80211_sub_if_data *sdata,
|
||||
*/
|
||||
|
||||
tin = &txqi->tin;
|
||||
flow = fq_flow_classify(fq, tin, flow_idx, skb,
|
||||
fq_flow_get_default_func);
|
||||
flow = fq_flow_classify(fq, tin, flow_idx, skb);
|
||||
head = skb_peek_tail(&flow->queue);
|
||||
if (!head || skb_is_gso(head))
|
||||
goto out;
|
||||
@ -3351,8 +3341,6 @@ out_recalc:
|
||||
if (head->len != orig_len) {
|
||||
flow->backlog += head->len - orig_len;
|
||||
tin->backlog_bytes += head->len - orig_len;
|
||||
|
||||
fq_recalc_backlog(fq, tin, flow);
|
||||
}
|
||||
out:
|
||||
spin_unlock_bh(&fq->lock);
|
||||
@ -3823,6 +3811,8 @@ void __ieee80211_schedule_txq(struct ieee80211_hw *hw,
|
||||
}
|
||||
EXPORT_SYMBOL(__ieee80211_schedule_txq);
|
||||
|
||||
DEFINE_STATIC_KEY_FALSE(aql_disable);
|
||||
|
||||
bool ieee80211_txq_airtime_check(struct ieee80211_hw *hw,
|
||||
struct ieee80211_txq *txq)
|
||||
{
|
||||
@ -3832,6 +3822,9 @@ bool ieee80211_txq_airtime_check(struct ieee80211_hw *hw,
|
||||
if (!wiphy_ext_feature_isset(local->hw.wiphy, NL80211_EXT_FEATURE_AQL))
|
||||
return true;
|
||||
|
||||
if (static_branch_unlikely(&aql_disable))
|
||||
return true;
|
||||
|
||||
if (!txq->sta)
|
||||
return true;
|
||||
|
||||
|
@ -832,7 +832,7 @@ void ieee80211_iterate_active_interfaces_atomic(
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(ieee80211_iterate_active_interfaces_atomic);
|
||||
|
||||
void ieee80211_iterate_active_interfaces_rtnl(
|
||||
void ieee80211_iterate_active_interfaces_mtx(
|
||||
struct ieee80211_hw *hw, u32 iter_flags,
|
||||
void (*iterator)(void *data, u8 *mac,
|
||||
struct ieee80211_vif *vif),
|
||||
@ -840,12 +840,12 @@ void ieee80211_iterate_active_interfaces_rtnl(
|
||||
{
|
||||
struct ieee80211_local *local = hw_to_local(hw);
|
||||
|
||||
ASSERT_RTNL();
|
||||
lockdep_assert_wiphy(hw->wiphy);
|
||||
|
||||
__iterate_interfaces(local, iter_flags | IEEE80211_IFACE_ITER_ACTIVE,
|
||||
iterator, data);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(ieee80211_iterate_active_interfaces_rtnl);
|
||||
EXPORT_SYMBOL_GPL(ieee80211_iterate_active_interfaces_mtx);
|
||||
|
||||
static void __iterate_stations(struct ieee80211_local *local,
|
||||
void (*iterator)(void *data,
|
||||
@ -2595,7 +2595,7 @@ int ieee80211_reconfig(struct ieee80211_local *local)
|
||||
mutex_unlock(&local->mtx);
|
||||
|
||||
if (sched_scan_stopped)
|
||||
cfg80211_sched_scan_stopped_rtnl(local->hw.wiphy, 0);
|
||||
cfg80211_sched_scan_stopped_locked(local->hw.wiphy, 0);
|
||||
|
||||
wake_up:
|
||||
|
||||
@ -3811,7 +3811,7 @@ void ieee80211_dfs_cac_cancel(struct ieee80211_local *local)
|
||||
struct cfg80211_chan_def chandef;
|
||||
|
||||
/* for interface list, to avoid linking iflist_mtx and chanctx_mtx */
|
||||
ASSERT_RTNL();
|
||||
lockdep_assert_wiphy(local->hw.wiphy);
|
||||
|
||||
mutex_lock(&local->mtx);
|
||||
list_for_each_entry(sdata, &local->interfaces, list) {
|
||||
@ -3851,9 +3851,9 @@ void ieee80211_dfs_radar_detected_work(struct work_struct *work)
|
||||
}
|
||||
mutex_unlock(&local->chanctx_mtx);
|
||||
|
||||
rtnl_lock();
|
||||
wiphy_lock(local->hw.wiphy);
|
||||
ieee80211_dfs_cac_cancel(local);
|
||||
rtnl_unlock();
|
||||
wiphy_unlock(local->hw.wiphy);
|
||||
|
||||
if (num_chanctx > 1)
|
||||
/* XXX: multi-channel is not supported yet */
|
||||
|
@ -484,6 +484,7 @@ enum ieee80211_sta_rx_bandwidth ieee80211_sta_cur_vht_bw(struct sta_info *sta)
|
||||
void ieee80211_sta_set_rx_nss(struct sta_info *sta)
|
||||
{
|
||||
u8 ht_rx_nss = 0, vht_rx_nss = 0, he_rx_nss = 0, rx_nss;
|
||||
bool support_160;
|
||||
|
||||
/* if we received a notification already don't overwrite it */
|
||||
if (sta->sta.rx_nss)
|
||||
@ -514,7 +515,13 @@ void ieee80211_sta_set_rx_nss(struct sta_info *sta)
|
||||
}
|
||||
}
|
||||
|
||||
he_rx_nss = min(rx_mcs_80, rx_mcs_160);
|
||||
support_160 = he_cap->he_cap_elem.phy_cap_info[0] &
|
||||
IEEE80211_HE_PHY_CAP0_CHANNEL_WIDTH_SET_160MHZ_IN_5G;
|
||||
|
||||
if (support_160)
|
||||
he_rx_nss = min(rx_mcs_80, rx_mcs_160);
|
||||
else
|
||||
he_rx_nss = rx_mcs_80;
|
||||
}
|
||||
|
||||
if (sta->sta.ht_cap.ht_supported) {
|
||||
|
@ -1093,7 +1093,7 @@ static bool cfg80211_ir_permissive_chan(struct wiphy *wiphy,
|
||||
struct wireless_dev *wdev;
|
||||
struct cfg80211_registered_device *rdev = wiphy_to_rdev(wiphy);
|
||||
|
||||
ASSERT_RTNL();
|
||||
lockdep_assert_held(&rdev->wiphy.mtx);
|
||||
|
||||
if (!IS_ENABLED(CONFIG_CFG80211_REG_RELAX_NO_IR) ||
|
||||
!(wiphy->regulatory_flags & REGULATORY_ENABLE_RELAX_NO_IR))
|
||||
@ -1216,9 +1216,10 @@ bool cfg80211_reg_can_beacon_relax(struct wiphy *wiphy,
|
||||
struct cfg80211_chan_def *chandef,
|
||||
enum nl80211_iftype iftype)
|
||||
{
|
||||
struct cfg80211_registered_device *rdev = wiphy_to_rdev(wiphy);
|
||||
bool check_no_ir;
|
||||
|
||||
ASSERT_RTNL();
|
||||
lockdep_assert_held(&rdev->wiphy.mtx);
|
||||
|
||||
/*
|
||||
* Under certain conditions suggested by some regulatory bodies a
|
||||
|
@ -222,7 +222,7 @@ static void cfg80211_rfkill_poll(struct rfkill *rfkill, void *data)
|
||||
void cfg80211_stop_p2p_device(struct cfg80211_registered_device *rdev,
|
||||
struct wireless_dev *wdev)
|
||||
{
|
||||
ASSERT_RTNL();
|
||||
lockdep_assert_held(&rdev->wiphy.mtx);
|
||||
|
||||
if (WARN_ON(wdev->iftype != NL80211_IFTYPE_P2P_DEVICE))
|
||||
return;
|
||||
@ -247,7 +247,7 @@ void cfg80211_stop_p2p_device(struct cfg80211_registered_device *rdev,
|
||||
void cfg80211_stop_nan(struct cfg80211_registered_device *rdev,
|
||||
struct wireless_dev *wdev)
|
||||
{
|
||||
ASSERT_RTNL();
|
||||
lockdep_assert_held(&rdev->wiphy.mtx);
|
||||
|
||||
if (WARN_ON(wdev->iftype != NL80211_IFTYPE_NAN))
|
||||
return;
|
||||
@ -273,7 +273,11 @@ void cfg80211_shutdown_all_interfaces(struct wiphy *wiphy)
|
||||
dev_close(wdev->netdev);
|
||||
continue;
|
||||
}
|
||||
|
||||
/* otherwise, check iftype */
|
||||
|
||||
wiphy_lock(wiphy);
|
||||
|
||||
switch (wdev->iftype) {
|
||||
case NL80211_IFTYPE_P2P_DEVICE:
|
||||
cfg80211_stop_p2p_device(rdev, wdev);
|
||||
@ -284,6 +288,8 @@ void cfg80211_shutdown_all_interfaces(struct wiphy *wiphy)
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
wiphy_unlock(wiphy);
|
||||
}
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(cfg80211_shutdown_all_interfaces);
|
||||
@ -318,9 +324,9 @@ static void cfg80211_event_work(struct work_struct *work)
|
||||
rdev = container_of(work, struct cfg80211_registered_device,
|
||||
event_work);
|
||||
|
||||
rtnl_lock();
|
||||
wiphy_lock(&rdev->wiphy);
|
||||
cfg80211_process_rdev_events(rdev);
|
||||
rtnl_unlock();
|
||||
wiphy_unlock(&rdev->wiphy);
|
||||
}
|
||||
|
||||
void cfg80211_destroy_ifaces(struct cfg80211_registered_device *rdev)
|
||||
@ -475,6 +481,7 @@ use_default_name:
|
||||
}
|
||||
}
|
||||
|
||||
mutex_init(&rdev->wiphy.mtx);
|
||||
INIT_LIST_HEAD(&rdev->wiphy.wdev_list);
|
||||
INIT_LIST_HEAD(&rdev->beacon_registrations);
|
||||
spin_lock_init(&rdev->beacon_registrations_lock);
|
||||
@ -1007,15 +1014,16 @@ void wiphy_unregister(struct wiphy *wiphy)
|
||||
|
||||
wait_event(rdev->dev_wait, ({
|
||||
int __count;
|
||||
rtnl_lock();
|
||||
wiphy_lock(&rdev->wiphy);
|
||||
__count = rdev->opencount;
|
||||
rtnl_unlock();
|
||||
wiphy_unlock(&rdev->wiphy);
|
||||
__count == 0; }));
|
||||
|
||||
if (rdev->rfkill)
|
||||
rfkill_unregister(rdev->rfkill);
|
||||
|
||||
rtnl_lock();
|
||||
wiphy_lock(&rdev->wiphy);
|
||||
nl80211_notify_wiphy(rdev, NL80211_CMD_DEL_WIPHY);
|
||||
rdev->wiphy.registered = false;
|
||||
|
||||
@ -1038,6 +1046,7 @@ void wiphy_unregister(struct wiphy *wiphy)
|
||||
cfg80211_rdev_list_generation++;
|
||||
device_del(&rdev->wiphy.dev);
|
||||
|
||||
wiphy_unlock(&rdev->wiphy);
|
||||
rtnl_unlock();
|
||||
|
||||
flush_work(&rdev->scan_done_wk);
|
||||
@ -1070,6 +1079,7 @@ void cfg80211_dev_free(struct cfg80211_registered_device *rdev)
|
||||
}
|
||||
list_for_each_entry_safe(scan, tmp, &rdev->bss_list, list)
|
||||
cfg80211_put_bss(&rdev->wiphy, &scan->pub);
|
||||
mutex_destroy(&rdev->wiphy.mtx);
|
||||
kfree(rdev);
|
||||
}
|
||||
|
||||
@ -1094,19 +1104,28 @@ void cfg80211_cqm_config_free(struct wireless_dev *wdev)
|
||||
wdev->cqm_config = NULL;
|
||||
}
|
||||
|
||||
static void __cfg80211_unregister_wdev(struct wireless_dev *wdev, bool sync)
|
||||
static void _cfg80211_unregister_wdev(struct wireless_dev *wdev,
|
||||
bool unregister_netdev)
|
||||
{
|
||||
struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy);
|
||||
|
||||
ASSERT_RTNL();
|
||||
lockdep_assert_held(&rdev->wiphy.mtx);
|
||||
|
||||
flush_work(&wdev->pmsr_free_wk);
|
||||
|
||||
nl80211_notify_iface(rdev, wdev, NL80211_CMD_DEL_INTERFACE);
|
||||
|
||||
wdev->registered = false;
|
||||
|
||||
if (wdev->netdev) {
|
||||
sysfs_remove_link(&wdev->netdev->dev.kobj, "phy80211");
|
||||
if (unregister_netdev)
|
||||
unregister_netdevice(wdev->netdev);
|
||||
}
|
||||
|
||||
list_del_rcu(&wdev->list);
|
||||
if (sync)
|
||||
synchronize_rcu();
|
||||
synchronize_net();
|
||||
rdev->devlist_generation++;
|
||||
|
||||
cfg80211_mlme_purge_registrations(wdev);
|
||||
@ -1131,14 +1150,23 @@ static void __cfg80211_unregister_wdev(struct wireless_dev *wdev, bool sync)
|
||||
flush_work(&wdev->disconnect_wk);
|
||||
|
||||
cfg80211_cqm_config_free(wdev);
|
||||
|
||||
/*
|
||||
* Ensure that all events have been processed and
|
||||
* freed.
|
||||
*/
|
||||
cfg80211_process_wdev_events(wdev);
|
||||
|
||||
if (WARN_ON(wdev->current_bss)) {
|
||||
cfg80211_unhold_bss(wdev->current_bss);
|
||||
cfg80211_put_bss(wdev->wiphy, &wdev->current_bss->pub);
|
||||
wdev->current_bss = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void cfg80211_unregister_wdev(struct wireless_dev *wdev)
|
||||
{
|
||||
if (WARN_ON(wdev->netdev))
|
||||
return;
|
||||
|
||||
__cfg80211_unregister_wdev(wdev, true);
|
||||
_cfg80211_unregister_wdev(wdev, true);
|
||||
}
|
||||
EXPORT_SYMBOL(cfg80211_unregister_wdev);
|
||||
|
||||
@ -1149,7 +1177,7 @@ static const struct device_type wiphy_type = {
|
||||
void cfg80211_update_iface_num(struct cfg80211_registered_device *rdev,
|
||||
enum nl80211_iftype iftype, int num)
|
||||
{
|
||||
ASSERT_RTNL();
|
||||
lockdep_assert_held(&rdev->wiphy.mtx);
|
||||
|
||||
rdev->num_running_ifaces += num;
|
||||
if (iftype == NL80211_IFTYPE_MONITOR)
|
||||
@ -1162,7 +1190,7 @@ void __cfg80211_leave(struct cfg80211_registered_device *rdev,
|
||||
struct net_device *dev = wdev->netdev;
|
||||
struct cfg80211_sched_scan_request *pos, *tmp;
|
||||
|
||||
ASSERT_RTNL();
|
||||
lockdep_assert_held(&rdev->wiphy.mtx);
|
||||
ASSERT_WDEV_LOCK(wdev);
|
||||
|
||||
cfg80211_pmsr_wdev_down(wdev);
|
||||
@ -1279,6 +1307,9 @@ void cfg80211_init_wdev(struct wireless_dev *wdev)
|
||||
void cfg80211_register_wdev(struct cfg80211_registered_device *rdev,
|
||||
struct wireless_dev *wdev)
|
||||
{
|
||||
ASSERT_RTNL();
|
||||
lockdep_assert_held(&rdev->wiphy.mtx);
|
||||
|
||||
/*
|
||||
* We get here also when the interface changes network namespaces,
|
||||
* as it's registered into the new one, but we don't want it to
|
||||
@ -1290,10 +1321,49 @@ void cfg80211_register_wdev(struct cfg80211_registered_device *rdev,
|
||||
wdev->identifier = ++rdev->wdev_id;
|
||||
list_add_rcu(&wdev->list, &rdev->wiphy.wdev_list);
|
||||
rdev->devlist_generation++;
|
||||
wdev->registered = true;
|
||||
|
||||
nl80211_notify_iface(rdev, wdev, NL80211_CMD_NEW_INTERFACE);
|
||||
}
|
||||
|
||||
int cfg80211_register_netdevice(struct net_device *dev)
|
||||
{
|
||||
struct wireless_dev *wdev = dev->ieee80211_ptr;
|
||||
struct cfg80211_registered_device *rdev;
|
||||
int ret;
|
||||
|
||||
ASSERT_RTNL();
|
||||
|
||||
if (WARN_ON(!wdev))
|
||||
return -EINVAL;
|
||||
|
||||
rdev = wiphy_to_rdev(wdev->wiphy);
|
||||
|
||||
lockdep_assert_held(&rdev->wiphy.mtx);
|
||||
|
||||
/* we'll take care of this */
|
||||
wdev->registered = true;
|
||||
ret = register_netdevice(dev);
|
||||
if (ret)
|
||||
goto out;
|
||||
|
||||
if (sysfs_create_link(&dev->dev.kobj, &rdev->wiphy.dev.kobj,
|
||||
"phy80211")) {
|
||||
pr_err("failed to add phy80211 symlink to netdev!\n");
|
||||
unregister_netdevice(dev);
|
||||
ret = -EINVAL;
|
||||
goto out;
|
||||
}
|
||||
|
||||
cfg80211_register_wdev(rdev, wdev);
|
||||
ret = 0;
|
||||
out:
|
||||
if (ret)
|
||||
wdev->registered = false;
|
||||
return ret;
|
||||
}
|
||||
EXPORT_SYMBOL(cfg80211_register_netdevice);
|
||||
|
||||
static int cfg80211_netdev_notifier_call(struct notifier_block *nb,
|
||||
unsigned long state, void *ptr)
|
||||
{
|
||||
@ -1319,22 +1389,30 @@ static int cfg80211_netdev_notifier_call(struct notifier_block *nb,
|
||||
cfg80211_init_wdev(wdev);
|
||||
break;
|
||||
case NETDEV_REGISTER:
|
||||
/*
|
||||
* NB: cannot take rdev->mtx here because this may be
|
||||
* called within code protected by it when interfaces
|
||||
* are added with nl80211.
|
||||
*/
|
||||
if (sysfs_create_link(&dev->dev.kobj, &rdev->wiphy.dev.kobj,
|
||||
"phy80211")) {
|
||||
pr_err("failed to add phy80211 symlink to netdev!\n");
|
||||
if (!wdev->registered) {
|
||||
wiphy_lock(&rdev->wiphy);
|
||||
cfg80211_register_wdev(rdev, wdev);
|
||||
wiphy_unlock(&rdev->wiphy);
|
||||
}
|
||||
break;
|
||||
case NETDEV_UNREGISTER:
|
||||
/*
|
||||
* It is possible to get NETDEV_UNREGISTER multiple times,
|
||||
* so check wdev->registered.
|
||||
*/
|
||||
if (wdev->registered) {
|
||||
wiphy_lock(&rdev->wiphy);
|
||||
_cfg80211_unregister_wdev(wdev, false);
|
||||
wiphy_unlock(&rdev->wiphy);
|
||||
}
|
||||
|
||||
cfg80211_register_wdev(rdev, wdev);
|
||||
break;
|
||||
case NETDEV_GOING_DOWN:
|
||||
wiphy_lock(&rdev->wiphy);
|
||||
cfg80211_leave(rdev, wdev);
|
||||
wiphy_unlock(&rdev->wiphy);
|
||||
break;
|
||||
case NETDEV_DOWN:
|
||||
wiphy_lock(&rdev->wiphy);
|
||||
cfg80211_update_iface_num(rdev, wdev->iftype, -1);
|
||||
if (rdev->scan_req && rdev->scan_req->wdev == wdev) {
|
||||
if (WARN_ON(!rdev->scan_req->notified &&
|
||||
@ -1351,9 +1429,11 @@ static int cfg80211_netdev_notifier_call(struct notifier_block *nb,
|
||||
}
|
||||
|
||||
rdev->opencount--;
|
||||
wiphy_unlock(&rdev->wiphy);
|
||||
wake_up(&rdev->dev_wait);
|
||||
break;
|
||||
case NETDEV_UP:
|
||||
wiphy_lock(&rdev->wiphy);
|
||||
cfg80211_update_iface_num(rdev, wdev->iftype, 1);
|
||||
wdev_lock(wdev);
|
||||
switch (wdev->iftype) {
|
||||
@ -1400,38 +1480,7 @@ static int cfg80211_netdev_notifier_call(struct notifier_block *nb,
|
||||
/* assume this means it's off */
|
||||
wdev->ps = false;
|
||||
}
|
||||
break;
|
||||
case NETDEV_UNREGISTER:
|
||||
/*
|
||||
* It is possible to get NETDEV_UNREGISTER
|
||||
* multiple times. To detect that, check
|
||||
* that the interface is still on the list
|
||||
* of registered interfaces, and only then
|
||||
* remove and clean it up.
|
||||
*/
|
||||
if (!list_empty(&wdev->list)) {
|
||||
__cfg80211_unregister_wdev(wdev, false);
|
||||
sysfs_remove_link(&dev->dev.kobj, "phy80211");
|
||||
}
|
||||
/*
|
||||
* synchronise (so that we won't find this netdev
|
||||
* from other code any more) and then clear the list
|
||||
* head so that the above code can safely check for
|
||||
* !list_empty() to avoid double-cleanup.
|
||||
*/
|
||||
synchronize_rcu();
|
||||
INIT_LIST_HEAD(&wdev->list);
|
||||
/*
|
||||
* Ensure that all events have been processed and
|
||||
* freed.
|
||||
*/
|
||||
cfg80211_process_wdev_events(wdev);
|
||||
|
||||
if (WARN_ON(wdev->current_bss)) {
|
||||
cfg80211_unhold_bss(wdev->current_bss);
|
||||
cfg80211_put_bss(wdev->wiphy, &wdev->current_bss->pub);
|
||||
wdev->current_bss = NULL;
|
||||
}
|
||||
wiphy_unlock(&rdev->wiphy);
|
||||
break;
|
||||
case NETDEV_PRE_UP:
|
||||
if (!cfg80211_iftype_allowed(wdev->wiphy, wdev->iftype,
|
||||
|
@ -231,7 +231,7 @@ static inline void wdev_unlock(struct wireless_dev *wdev)
|
||||
|
||||
static inline bool cfg80211_has_monitors_only(struct cfg80211_registered_device *rdev)
|
||||
{
|
||||
ASSERT_RTNL();
|
||||
lockdep_assert_held(&rdev->wiphy.mtx);
|
||||
|
||||
return rdev->num_running_ifaces == rdev->num_running_monitor_ifaces &&
|
||||
rdev->num_running_ifaces > 0;
|
||||
|
@ -73,8 +73,6 @@ static ssize_t ht40allow_map_read(struct file *file,
|
||||
if (!buf)
|
||||
return -ENOMEM;
|
||||
|
||||
rtnl_lock();
|
||||
|
||||
for (band = 0; band < NUM_NL80211_BANDS; band++) {
|
||||
sband = wiphy->bands[band];
|
||||
if (!sband)
|
||||
@ -84,8 +82,6 @@ static ssize_t ht40allow_map_read(struct file *file,
|
||||
buf, buf_size, offset);
|
||||
}
|
||||
|
||||
rtnl_unlock();
|
||||
|
||||
r = simple_read_from_buffer(user_buf, count, ppos, buf, offset);
|
||||
|
||||
kfree(buf);
|
||||
|
@ -3,6 +3,7 @@
|
||||
* Some IBSS support code for cfg80211.
|
||||
*
|
||||
* Copyright 2009 Johannes Berg <johannes@sipsolutions.net>
|
||||
* Copyright (C) 2020-2021 Intel Corporation
|
||||
*/
|
||||
|
||||
#include <linux/etherdevice.h>
|
||||
@ -92,7 +93,7 @@ int __cfg80211_join_ibss(struct cfg80211_registered_device *rdev,
|
||||
struct wireless_dev *wdev = dev->ieee80211_ptr;
|
||||
int err;
|
||||
|
||||
ASSERT_RTNL();
|
||||
lockdep_assert_held(&rdev->wiphy.mtx);
|
||||
ASSERT_WDEV_LOCK(wdev);
|
||||
|
||||
if (wdev->ssid_len)
|
||||
|
@ -450,7 +450,7 @@ static void cfg80211_mgmt_registrations_update(struct wireless_dev *wdev)
|
||||
struct cfg80211_mgmt_registration *reg;
|
||||
struct mgmt_frame_regs upd = {};
|
||||
|
||||
ASSERT_RTNL();
|
||||
lockdep_assert_held(&rdev->wiphy.mtx);
|
||||
|
||||
spin_lock_bh(&wdev->mgmt_registrations_lock);
|
||||
if (!wdev->mgmt_registrations_need_update) {
|
||||
@ -492,10 +492,10 @@ void cfg80211_mgmt_registrations_update_wk(struct work_struct *wk)
|
||||
rdev = container_of(wk, struct cfg80211_registered_device,
|
||||
mgmt_registrations_update_wk);
|
||||
|
||||
rtnl_lock();
|
||||
wiphy_lock(&rdev->wiphy);
|
||||
list_for_each_entry(wdev, &rdev->wiphy.wdev_list, list)
|
||||
cfg80211_mgmt_registrations_update(wdev);
|
||||
rtnl_unlock();
|
||||
wiphy_unlock(&rdev->wiphy);
|
||||
}
|
||||
|
||||
int cfg80211_mlme_register_mgmt(struct wireless_dev *wdev, u32 snd_portid,
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -142,12 +142,15 @@ static const struct ieee80211_regdomain *get_cfg80211_regdom(void)
|
||||
/*
|
||||
* Returns the regulatory domain associated with the wiphy.
|
||||
*
|
||||
* Requires either RTNL or RCU protection
|
||||
* Requires any of RTNL, wiphy mutex or RCU protection.
|
||||
*/
|
||||
const struct ieee80211_regdomain *get_wiphy_regdom(struct wiphy *wiphy)
|
||||
{
|
||||
return rcu_dereference_rtnl(wiphy->regd);
|
||||
return rcu_dereference_check(wiphy->regd,
|
||||
lockdep_is_held(&wiphy->mtx) ||
|
||||
lockdep_rtnl_is_held());
|
||||
}
|
||||
EXPORT_SYMBOL(get_wiphy_regdom);
|
||||
|
||||
static const char *reg_dfs_region_str(enum nl80211_dfs_regions dfs_region)
|
||||
{
|
||||
@ -169,7 +172,9 @@ enum nl80211_dfs_regions reg_get_dfs_region(struct wiphy *wiphy)
|
||||
const struct ieee80211_regdomain *regd = NULL;
|
||||
const struct ieee80211_regdomain *wiphy_regd = NULL;
|
||||
|
||||
rcu_read_lock();
|
||||
regd = get_cfg80211_regdom();
|
||||
|
||||
if (!wiphy)
|
||||
goto out;
|
||||
|
||||
@ -186,6 +191,8 @@ enum nl80211_dfs_regions reg_get_dfs_region(struct wiphy *wiphy)
|
||||
reg_dfs_region_str(regd->dfs_region));
|
||||
|
||||
out:
|
||||
rcu_read_unlock();
|
||||
|
||||
return regd->dfs_region;
|
||||
}
|
||||
|
||||
@ -2577,11 +2584,13 @@ void wiphy_apply_custom_regulatory(struct wiphy *wiphy,
|
||||
return;
|
||||
|
||||
rtnl_lock();
|
||||
wiphy_lock(wiphy);
|
||||
|
||||
tmp = get_wiphy_regdom(wiphy);
|
||||
rcu_assign_pointer(wiphy->regd, new_regd);
|
||||
rcu_free_regdom(tmp);
|
||||
|
||||
wiphy_unlock(wiphy);
|
||||
rtnl_unlock();
|
||||
}
|
||||
EXPORT_SYMBOL(wiphy_apply_custom_regulatory);
|
||||
@ -2744,7 +2753,10 @@ reg_process_hint_driver(struct wiphy *wiphy,
|
||||
return REG_REQ_IGNORE;
|
||||
|
||||
tmp = get_wiphy_regdom(wiphy);
|
||||
ASSERT_RTNL();
|
||||
wiphy_lock(wiphy);
|
||||
rcu_assign_pointer(wiphy->regd, regd);
|
||||
wiphy_unlock(wiphy);
|
||||
rcu_free_regdom(tmp);
|
||||
}
|
||||
|
||||
@ -3076,41 +3088,52 @@ static void reg_process_pending_beacon_hints(void)
|
||||
spin_unlock_bh(®_pending_beacons_lock);
|
||||
}
|
||||
|
||||
static void reg_process_self_managed_hints(void)
|
||||
static void reg_process_self_managed_hint(struct wiphy *wiphy)
|
||||
{
|
||||
struct cfg80211_registered_device *rdev;
|
||||
struct wiphy *wiphy;
|
||||
struct cfg80211_registered_device *rdev = wiphy_to_rdev(wiphy);
|
||||
const struct ieee80211_regdomain *tmp;
|
||||
const struct ieee80211_regdomain *regd;
|
||||
enum nl80211_band band;
|
||||
struct regulatory_request request = {};
|
||||
|
||||
ASSERT_RTNL();
|
||||
lockdep_assert_wiphy(wiphy);
|
||||
|
||||
spin_lock(®_requests_lock);
|
||||
regd = rdev->requested_regd;
|
||||
rdev->requested_regd = NULL;
|
||||
spin_unlock(®_requests_lock);
|
||||
|
||||
if (!regd)
|
||||
return;
|
||||
|
||||
tmp = get_wiphy_regdom(wiphy);
|
||||
rcu_assign_pointer(wiphy->regd, regd);
|
||||
rcu_free_regdom(tmp);
|
||||
|
||||
for (band = 0; band < NUM_NL80211_BANDS; band++)
|
||||
handle_band_custom(wiphy, wiphy->bands[band], regd);
|
||||
|
||||
reg_process_ht_flags(wiphy);
|
||||
|
||||
request.wiphy_idx = get_wiphy_idx(wiphy);
|
||||
request.alpha2[0] = regd->alpha2[0];
|
||||
request.alpha2[1] = regd->alpha2[1];
|
||||
request.initiator = NL80211_REGDOM_SET_BY_DRIVER;
|
||||
|
||||
nl80211_send_wiphy_reg_change_event(&request);
|
||||
}
|
||||
|
||||
static void reg_process_self_managed_hints(void)
|
||||
{
|
||||
struct cfg80211_registered_device *rdev;
|
||||
|
||||
ASSERT_RTNL();
|
||||
|
||||
list_for_each_entry(rdev, &cfg80211_rdev_list, list) {
|
||||
wiphy = &rdev->wiphy;
|
||||
|
||||
spin_lock(®_requests_lock);
|
||||
regd = rdev->requested_regd;
|
||||
rdev->requested_regd = NULL;
|
||||
spin_unlock(®_requests_lock);
|
||||
|
||||
if (regd == NULL)
|
||||
continue;
|
||||
|
||||
tmp = get_wiphy_regdom(wiphy);
|
||||
rcu_assign_pointer(wiphy->regd, regd);
|
||||
rcu_free_regdom(tmp);
|
||||
|
||||
for (band = 0; band < NUM_NL80211_BANDS; band++)
|
||||
handle_band_custom(wiphy, wiphy->bands[band], regd);
|
||||
|
||||
reg_process_ht_flags(wiphy);
|
||||
|
||||
request.wiphy_idx = get_wiphy_idx(wiphy);
|
||||
request.alpha2[0] = regd->alpha2[0];
|
||||
request.alpha2[1] = regd->alpha2[1];
|
||||
request.initiator = NL80211_REGDOM_SET_BY_DRIVER;
|
||||
|
||||
nl80211_send_wiphy_reg_change_event(&request);
|
||||
wiphy_lock(&rdev->wiphy);
|
||||
reg_process_self_managed_hint(&rdev->wiphy);
|
||||
wiphy_unlock(&rdev->wiphy);
|
||||
}
|
||||
|
||||
reg_check_channels();
|
||||
@ -3789,14 +3812,21 @@ static int reg_set_rd_driver(const struct ieee80211_regdomain *rd,
|
||||
return -ENODEV;
|
||||
|
||||
if (!driver_request->intersect) {
|
||||
if (request_wiphy->regd)
|
||||
ASSERT_RTNL();
|
||||
wiphy_lock(request_wiphy);
|
||||
if (request_wiphy->regd) {
|
||||
wiphy_unlock(request_wiphy);
|
||||
return -EALREADY;
|
||||
}
|
||||
|
||||
regd = reg_copy_regd(rd);
|
||||
if (IS_ERR(regd))
|
||||
if (IS_ERR(regd)) {
|
||||
wiphy_unlock(request_wiphy);
|
||||
return PTR_ERR(regd);
|
||||
}
|
||||
|
||||
rcu_assign_pointer(request_wiphy->regd, regd);
|
||||
wiphy_unlock(request_wiphy);
|
||||
reset_regdomains(false, rd);
|
||||
return 0;
|
||||
}
|
||||
@ -3978,8 +4008,8 @@ int regulatory_set_wiphy_regd(struct wiphy *wiphy,
|
||||
}
|
||||
EXPORT_SYMBOL(regulatory_set_wiphy_regd);
|
||||
|
||||
int regulatory_set_wiphy_regd_sync_rtnl(struct wiphy *wiphy,
|
||||
struct ieee80211_regdomain *rd)
|
||||
int regulatory_set_wiphy_regd_sync(struct wiphy *wiphy,
|
||||
struct ieee80211_regdomain *rd)
|
||||
{
|
||||
int ret;
|
||||
|
||||
@ -3990,10 +4020,11 @@ int regulatory_set_wiphy_regd_sync_rtnl(struct wiphy *wiphy,
|
||||
return ret;
|
||||
|
||||
/* process the request immediately */
|
||||
reg_process_self_managed_hints();
|
||||
reg_process_self_managed_hint(wiphy);
|
||||
reg_check_channels();
|
||||
return 0;
|
||||
}
|
||||
EXPORT_SYMBOL(regulatory_set_wiphy_regd_sync_rtnl);
|
||||
EXPORT_SYMBOL(regulatory_set_wiphy_regd_sync);
|
||||
|
||||
void wiphy_regulatory_register(struct wiphy *wiphy)
|
||||
{
|
||||
|
@ -63,7 +63,6 @@ unsigned int reg_get_max_bandwidth(const struct ieee80211_regdomain *rd,
|
||||
const struct ieee80211_reg_rule *rule);
|
||||
|
||||
bool reg_last_request_cell_base(void);
|
||||
const struct ieee80211_regdomain *get_wiphy_regdom(struct wiphy *wiphy);
|
||||
|
||||
/**
|
||||
* regulatory_hint_found_beacon - hints a beacon was found on a channel
|
||||
|
@ -918,7 +918,7 @@ void ___cfg80211_scan_done(struct cfg80211_registered_device *rdev,
|
||||
union iwreq_data wrqu;
|
||||
#endif
|
||||
|
||||
ASSERT_RTNL();
|
||||
lockdep_assert_held(&rdev->wiphy.mtx);
|
||||
|
||||
if (rdev->scan_msg) {
|
||||
nl80211_send_scan_msg(rdev, rdev->scan_msg);
|
||||
@ -987,9 +987,9 @@ void __cfg80211_scan_done(struct work_struct *wk)
|
||||
rdev = container_of(wk, struct cfg80211_registered_device,
|
||||
scan_done_wk);
|
||||
|
||||
rtnl_lock();
|
||||
wiphy_lock(&rdev->wiphy);
|
||||
___cfg80211_scan_done(rdev, true);
|
||||
rtnl_unlock();
|
||||
wiphy_unlock(&rdev->wiphy);
|
||||
}
|
||||
|
||||
void cfg80211_scan_done(struct cfg80211_scan_request *request,
|
||||
@ -1022,7 +1022,7 @@ EXPORT_SYMBOL(cfg80211_scan_done);
|
||||
void cfg80211_add_sched_scan_req(struct cfg80211_registered_device *rdev,
|
||||
struct cfg80211_sched_scan_request *req)
|
||||
{
|
||||
ASSERT_RTNL();
|
||||
lockdep_assert_held(&rdev->wiphy.mtx);
|
||||
|
||||
list_add_rcu(&req->list, &rdev->sched_scan_req_list);
|
||||
}
|
||||
@ -1030,7 +1030,7 @@ void cfg80211_add_sched_scan_req(struct cfg80211_registered_device *rdev,
|
||||
static void cfg80211_del_sched_scan_req(struct cfg80211_registered_device *rdev,
|
||||
struct cfg80211_sched_scan_request *req)
|
||||
{
|
||||
ASSERT_RTNL();
|
||||
lockdep_assert_held(&rdev->wiphy.mtx);
|
||||
|
||||
list_del_rcu(&req->list);
|
||||
kfree_rcu(req, rcu_head);
|
||||
@ -1042,7 +1042,7 @@ cfg80211_find_sched_scan_req(struct cfg80211_registered_device *rdev, u64 reqid)
|
||||
struct cfg80211_sched_scan_request *pos;
|
||||
|
||||
list_for_each_entry_rcu(pos, &rdev->sched_scan_req_list, list,
|
||||
lockdep_rtnl_is_held()) {
|
||||
lockdep_is_held(&rdev->wiphy.mtx)) {
|
||||
if (pos->reqid == reqid)
|
||||
return pos;
|
||||
}
|
||||
@ -1090,7 +1090,7 @@ void cfg80211_sched_scan_results_wk(struct work_struct *work)
|
||||
rdev = container_of(work, struct cfg80211_registered_device,
|
||||
sched_scan_res_wk);
|
||||
|
||||
rtnl_lock();
|
||||
wiphy_lock(&rdev->wiphy);
|
||||
list_for_each_entry_safe(req, tmp, &rdev->sched_scan_req_list, list) {
|
||||
if (req->report_results) {
|
||||
req->report_results = false;
|
||||
@ -1105,7 +1105,7 @@ void cfg80211_sched_scan_results_wk(struct work_struct *work)
|
||||
NL80211_CMD_SCHED_SCAN_RESULTS);
|
||||
}
|
||||
}
|
||||
rtnl_unlock();
|
||||
wiphy_unlock(&rdev->wiphy);
|
||||
}
|
||||
|
||||
void cfg80211_sched_scan_results(struct wiphy *wiphy, u64 reqid)
|
||||
@ -1126,23 +1126,23 @@ void cfg80211_sched_scan_results(struct wiphy *wiphy, u64 reqid)
|
||||
}
|
||||
EXPORT_SYMBOL(cfg80211_sched_scan_results);
|
||||
|
||||
void cfg80211_sched_scan_stopped_rtnl(struct wiphy *wiphy, u64 reqid)
|
||||
void cfg80211_sched_scan_stopped_locked(struct wiphy *wiphy, u64 reqid)
|
||||
{
|
||||
struct cfg80211_registered_device *rdev = wiphy_to_rdev(wiphy);
|
||||
|
||||
ASSERT_RTNL();
|
||||
lockdep_assert_held(&wiphy->mtx);
|
||||
|
||||
trace_cfg80211_sched_scan_stopped(wiphy, reqid);
|
||||
|
||||
__cfg80211_stop_sched_scan(rdev, reqid, true);
|
||||
}
|
||||
EXPORT_SYMBOL(cfg80211_sched_scan_stopped_rtnl);
|
||||
EXPORT_SYMBOL(cfg80211_sched_scan_stopped_locked);
|
||||
|
||||
void cfg80211_sched_scan_stopped(struct wiphy *wiphy, u64 reqid)
|
||||
{
|
||||
rtnl_lock();
|
||||
cfg80211_sched_scan_stopped_rtnl(wiphy, reqid);
|
||||
rtnl_unlock();
|
||||
wiphy_lock(wiphy);
|
||||
cfg80211_sched_scan_stopped_locked(wiphy, reqid);
|
||||
wiphy_unlock(wiphy);
|
||||
}
|
||||
EXPORT_SYMBOL(cfg80211_sched_scan_stopped);
|
||||
|
||||
@ -1150,7 +1150,7 @@ int cfg80211_stop_sched_scan_req(struct cfg80211_registered_device *rdev,
|
||||
struct cfg80211_sched_scan_request *req,
|
||||
bool driver_initiated)
|
||||
{
|
||||
ASSERT_RTNL();
|
||||
lockdep_assert_held(&rdev->wiphy.mtx);
|
||||
|
||||
if (!driver_initiated) {
|
||||
int err = rdev_sched_scan_stop(rdev, req->dev, req->reqid);
|
||||
@ -1170,7 +1170,7 @@ int __cfg80211_stop_sched_scan(struct cfg80211_registered_device *rdev,
|
||||
{
|
||||
struct cfg80211_sched_scan_request *sched_scan_req;
|
||||
|
||||
ASSERT_RTNL();
|
||||
lockdep_assert_held(&rdev->wiphy.mtx);
|
||||
|
||||
sched_scan_req = cfg80211_find_sched_scan_req(rdev, reqid);
|
||||
if (!sched_scan_req)
|
||||
@ -2774,6 +2774,8 @@ int cfg80211_wext_siwscan(struct net_device *dev,
|
||||
|
||||
eth_broadcast_addr(creq->bssid);
|
||||
|
||||
wiphy_lock(&rdev->wiphy);
|
||||
|
||||
rdev->scan_req = creq;
|
||||
err = rdev_scan(rdev, creq);
|
||||
if (err) {
|
||||
@ -2785,6 +2787,7 @@ int cfg80211_wext_siwscan(struct net_device *dev,
|
||||
creq = NULL;
|
||||
dev_hold(dev);
|
||||
}
|
||||
wiphy_unlock(&rdev->wiphy);
|
||||
out:
|
||||
kfree(creq);
|
||||
return err;
|
||||
|
@ -67,7 +67,6 @@ static int cfg80211_conn_scan(struct wireless_dev *wdev)
|
||||
struct cfg80211_scan_request *request;
|
||||
int n_channels, err;
|
||||
|
||||
ASSERT_RTNL();
|
||||
ASSERT_WDEV_LOCK(wdev);
|
||||
|
||||
if (rdev->scan_req || rdev->scan_msg)
|
||||
@ -233,7 +232,7 @@ void cfg80211_conn_work(struct work_struct *work)
|
||||
u8 bssid_buf[ETH_ALEN], *bssid = NULL;
|
||||
enum nl80211_timeout_reason treason;
|
||||
|
||||
rtnl_lock();
|
||||
wiphy_lock(&rdev->wiphy);
|
||||
|
||||
list_for_each_entry(wdev, &rdev->wiphy.wdev_list, list) {
|
||||
if (!wdev->netdev)
|
||||
@ -266,7 +265,7 @@ void cfg80211_conn_work(struct work_struct *work)
|
||||
wdev_unlock(wdev);
|
||||
}
|
||||
|
||||
rtnl_unlock();
|
||||
wiphy_unlock(&rdev->wiphy);
|
||||
}
|
||||
|
||||
/* Returned bss is reference counted and must be cleaned up appropriately. */
|
||||
|
@ -5,6 +5,7 @@
|
||||
*
|
||||
* Copyright 2005-2006 Jiri Benc <jbenc@suse.cz>
|
||||
* Copyright 2006 Johannes Berg <johannes@sipsolutions.net>
|
||||
* Copyright (C) 2020-2021 Intel Corporation
|
||||
*/
|
||||
|
||||
#include <linux/device.h>
|
||||
@ -104,6 +105,7 @@ static int wiphy_suspend(struct device *dev)
|
||||
rdev->suspend_at = ktime_get_boottime_seconds();
|
||||
|
||||
rtnl_lock();
|
||||
wiphy_lock(&rdev->wiphy);
|
||||
if (rdev->wiphy.registered) {
|
||||
if (!rdev->wiphy.wowlan_config) {
|
||||
cfg80211_leave_all(rdev);
|
||||
@ -118,6 +120,7 @@ static int wiphy_suspend(struct device *dev)
|
||||
ret = rdev_suspend(rdev, NULL);
|
||||
}
|
||||
}
|
||||
wiphy_unlock(&rdev->wiphy);
|
||||
rtnl_unlock();
|
||||
|
||||
return ret;
|
||||
@ -132,8 +135,10 @@ static int wiphy_resume(struct device *dev)
|
||||
cfg80211_bss_age(rdev, ktime_get_boottime_seconds() - rdev->suspend_at);
|
||||
|
||||
rtnl_lock();
|
||||
wiphy_lock(&rdev->wiphy);
|
||||
if (rdev->wiphy.registered && rdev->ops->resume)
|
||||
ret = rdev_resume(rdev);
|
||||
wiphy_unlock(&rdev->wiphy);
|
||||
rtnl_unlock();
|
||||
|
||||
return ret;
|
||||
|
@ -997,7 +997,7 @@ void cfg80211_process_rdev_events(struct cfg80211_registered_device *rdev)
|
||||
{
|
||||
struct wireless_dev *wdev;
|
||||
|
||||
ASSERT_RTNL();
|
||||
lockdep_assert_held(&rdev->wiphy.mtx);
|
||||
|
||||
list_for_each_entry(wdev, &rdev->wiphy.wdev_list, list)
|
||||
cfg80211_process_wdev_events(wdev);
|
||||
@ -1010,7 +1010,7 @@ int cfg80211_change_iface(struct cfg80211_registered_device *rdev,
|
||||
int err;
|
||||
enum nl80211_iftype otype = dev->ieee80211_ptr->iftype;
|
||||
|
||||
ASSERT_RTNL();
|
||||
lockdep_assert_held(&rdev->wiphy.mtx);
|
||||
|
||||
/* don't support changing VLANs, you just re-create them */
|
||||
if (otype == NL80211_IFTYPE_AP_VLAN)
|
||||
@ -1188,6 +1188,25 @@ static u32 cfg80211_calculate_bitrate_dmg(struct rate_info *rate)
|
||||
return __mcs2bitrate[rate->mcs];
|
||||
}
|
||||
|
||||
static u32 cfg80211_calculate_bitrate_extended_sc_dmg(struct rate_info *rate)
|
||||
{
|
||||
static const u32 __mcs2bitrate[] = {
|
||||
[6 - 6] = 26950, /* MCS 9.1 : 2695.0 mbps */
|
||||
[7 - 6] = 50050, /* MCS 12.1 */
|
||||
[8 - 6] = 53900,
|
||||
[9 - 6] = 57750,
|
||||
[10 - 6] = 63900,
|
||||
[11 - 6] = 75075,
|
||||
[12 - 6] = 80850,
|
||||
};
|
||||
|
||||
/* Extended SC MCS not defined for base MCS below 6 or above 12 */
|
||||
if (WARN_ON_ONCE(rate->mcs < 6 || rate->mcs > 12))
|
||||
return 0;
|
||||
|
||||
return __mcs2bitrate[rate->mcs - 6];
|
||||
}
|
||||
|
||||
static u32 cfg80211_calculate_bitrate_edmg(struct rate_info *rate)
|
||||
{
|
||||
static const u32 __mcs2bitrate[] = {
|
||||
@ -1224,7 +1243,7 @@ static u32 cfg80211_calculate_bitrate_edmg(struct rate_info *rate)
|
||||
|
||||
static u32 cfg80211_calculate_bitrate_vht(struct rate_info *rate)
|
||||
{
|
||||
static const u32 base[4][10] = {
|
||||
static const u32 base[4][12] = {
|
||||
{ 6500000,
|
||||
13000000,
|
||||
19500000,
|
||||
@ -1235,7 +1254,9 @@ static u32 cfg80211_calculate_bitrate_vht(struct rate_info *rate)
|
||||
65000000,
|
||||
78000000,
|
||||
/* not in the spec, but some devices use this: */
|
||||
86500000,
|
||||
86700000,
|
||||
97500000,
|
||||
108300000,
|
||||
},
|
||||
{ 13500000,
|
||||
27000000,
|
||||
@ -1247,6 +1268,8 @@ static u32 cfg80211_calculate_bitrate_vht(struct rate_info *rate)
|
||||
135000000,
|
||||
162000000,
|
||||
180000000,
|
||||
202500000,
|
||||
225000000,
|
||||
},
|
||||
{ 29300000,
|
||||
58500000,
|
||||
@ -1258,6 +1281,8 @@ static u32 cfg80211_calculate_bitrate_vht(struct rate_info *rate)
|
||||
292500000,
|
||||
351000000,
|
||||
390000000,
|
||||
438800000,
|
||||
487500000,
|
||||
},
|
||||
{ 58500000,
|
||||
117000000,
|
||||
@ -1269,12 +1294,14 @@ static u32 cfg80211_calculate_bitrate_vht(struct rate_info *rate)
|
||||
585000000,
|
||||
702000000,
|
||||
780000000,
|
||||
877500000,
|
||||
975000000,
|
||||
},
|
||||
};
|
||||
u32 bitrate;
|
||||
int idx;
|
||||
|
||||
if (rate->mcs > 9)
|
||||
if (rate->mcs > 11)
|
||||
goto warn;
|
||||
|
||||
switch (rate->bw) {
|
||||
@ -1398,6 +1425,8 @@ u32 cfg80211_calculate_bitrate(struct rate_info *rate)
|
||||
return cfg80211_calculate_bitrate_ht(rate);
|
||||
if (rate->flags & RATE_INFO_FLAGS_DMG)
|
||||
return cfg80211_calculate_bitrate_dmg(rate);
|
||||
if (rate->flags & RATE_INFO_FLAGS_EXTENDED_SC_DMG)
|
||||
return cfg80211_calculate_bitrate_extended_sc_dmg(rate);
|
||||
if (rate->flags & RATE_INFO_FLAGS_EDMG)
|
||||
return cfg80211_calculate_bitrate_edmg(rate);
|
||||
if (rate->flags & RATE_INFO_FLAGS_VHT_MCS)
|
||||
|
@ -7,7 +7,7 @@
|
||||
* we directly assign the wireless handlers of wireless interfaces.
|
||||
*
|
||||
* Copyright 2008-2009 Johannes Berg <johannes@sipsolutions.net>
|
||||
* Copyright (C) 2019 Intel Corporation
|
||||
* Copyright (C) 2019-2021 Intel Corporation
|
||||
*/
|
||||
|
||||
#include <linux/export.h>
|
||||
@ -253,17 +253,23 @@ int cfg80211_wext_siwrts(struct net_device *dev,
|
||||
u32 orts = wdev->wiphy->rts_threshold;
|
||||
int err;
|
||||
|
||||
if (rts->disabled || !rts->fixed)
|
||||
wiphy_lock(&rdev->wiphy);
|
||||
if (rts->disabled || !rts->fixed) {
|
||||
wdev->wiphy->rts_threshold = (u32) -1;
|
||||
else if (rts->value < 0)
|
||||
return -EINVAL;
|
||||
else
|
||||
} else if (rts->value < 0) {
|
||||
err = -EINVAL;
|
||||
goto out;
|
||||
} else {
|
||||
wdev->wiphy->rts_threshold = rts->value;
|
||||
}
|
||||
|
||||
err = rdev_set_wiphy_params(rdev, WIPHY_PARAM_RTS_THRESHOLD);
|
||||
|
||||
if (err)
|
||||
wdev->wiphy->rts_threshold = orts;
|
||||
|
||||
out:
|
||||
wiphy_unlock(&rdev->wiphy);
|
||||
return err;
|
||||
}
|
||||
EXPORT_WEXT_HANDLER(cfg80211_wext_siwrts);
|
||||
@ -291,11 +297,13 @@ int cfg80211_wext_siwfrag(struct net_device *dev,
|
||||
u32 ofrag = wdev->wiphy->frag_threshold;
|
||||
int err;
|
||||
|
||||
if (frag->disabled || !frag->fixed)
|
||||
wiphy_lock(&rdev->wiphy);
|
||||
if (frag->disabled || !frag->fixed) {
|
||||
wdev->wiphy->frag_threshold = (u32) -1;
|
||||
else if (frag->value < 256)
|
||||
return -EINVAL;
|
||||
else {
|
||||
} else if (frag->value < 256) {
|
||||
err = -EINVAL;
|
||||
goto out;
|
||||
} else {
|
||||
/* Fragment length must be even, so strip LSB. */
|
||||
wdev->wiphy->frag_threshold = frag->value & ~0x1;
|
||||
}
|
||||
@ -303,6 +311,8 @@ int cfg80211_wext_siwfrag(struct net_device *dev,
|
||||
err = rdev_set_wiphy_params(rdev, WIPHY_PARAM_FRAG_THRESHOLD);
|
||||
if (err)
|
||||
wdev->wiphy->frag_threshold = ofrag;
|
||||
out:
|
||||
wiphy_unlock(&rdev->wiphy);
|
||||
|
||||
return err;
|
||||
}
|
||||
@ -337,6 +347,7 @@ static int cfg80211_wext_siwretry(struct net_device *dev,
|
||||
(retry->flags & IW_RETRY_TYPE) != IW_RETRY_LIMIT)
|
||||
return -EINVAL;
|
||||
|
||||
wiphy_lock(&rdev->wiphy);
|
||||
if (retry->flags & IW_RETRY_LONG) {
|
||||
wdev->wiphy->retry_long = retry->value;
|
||||
changed |= WIPHY_PARAM_RETRY_LONG;
|
||||
@ -355,6 +366,7 @@ static int cfg80211_wext_siwretry(struct net_device *dev,
|
||||
wdev->wiphy->retry_short = oshort;
|
||||
wdev->wiphy->retry_long = olong;
|
||||
}
|
||||
wiphy_unlock(&rdev->wiphy);
|
||||
|
||||
return err;
|
||||
}
|
||||
@ -577,15 +589,18 @@ static int cfg80211_wext_siwencode(struct net_device *dev,
|
||||
!rdev->ops->set_default_key)
|
||||
return -EOPNOTSUPP;
|
||||
|
||||
wiphy_lock(&rdev->wiphy);
|
||||
idx = erq->flags & IW_ENCODE_INDEX;
|
||||
if (idx == 0) {
|
||||
idx = wdev->wext.default_key;
|
||||
if (idx < 0)
|
||||
idx = 0;
|
||||
} else if (idx < 1 || idx > 4)
|
||||
return -EINVAL;
|
||||
else
|
||||
} else if (idx < 1 || idx > 4) {
|
||||
err = -EINVAL;
|
||||
goto out;
|
||||
} else {
|
||||
idx--;
|
||||
}
|
||||
|
||||
if (erq->flags & IW_ENCODE_DISABLED)
|
||||
remove = true;
|
||||
@ -599,22 +614,28 @@ static int cfg80211_wext_siwencode(struct net_device *dev,
|
||||
if (!err)
|
||||
wdev->wext.default_key = idx;
|
||||
wdev_unlock(wdev);
|
||||
return err;
|
||||
goto out;
|
||||
}
|
||||
|
||||
memset(¶ms, 0, sizeof(params));
|
||||
params.key = keybuf;
|
||||
params.key_len = erq->length;
|
||||
if (erq->length == 5)
|
||||
if (erq->length == 5) {
|
||||
params.cipher = WLAN_CIPHER_SUITE_WEP40;
|
||||
else if (erq->length == 13)
|
||||
} else if (erq->length == 13) {
|
||||
params.cipher = WLAN_CIPHER_SUITE_WEP104;
|
||||
else if (!remove)
|
||||
return -EINVAL;
|
||||
} else if (!remove) {
|
||||
err = -EINVAL;
|
||||
goto out;
|
||||
}
|
||||
|
||||
return cfg80211_set_encryption(rdev, dev, false, NULL, remove,
|
||||
wdev->wext.default_key == -1,
|
||||
idx, ¶ms);
|
||||
err = cfg80211_set_encryption(rdev, dev, false, NULL, remove,
|
||||
wdev->wext.default_key == -1,
|
||||
idx, ¶ms);
|
||||
out:
|
||||
wiphy_unlock(&rdev->wiphy);
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
static int cfg80211_wext_siwencodeext(struct net_device *dev,
|
||||
@ -754,38 +775,61 @@ static int cfg80211_wext_siwfreq(struct net_device *dev,
|
||||
struct cfg80211_chan_def chandef = {
|
||||
.width = NL80211_CHAN_WIDTH_20_NOHT,
|
||||
};
|
||||
int freq;
|
||||
int freq, ret;
|
||||
|
||||
wiphy_lock(&rdev->wiphy);
|
||||
|
||||
switch (wdev->iftype) {
|
||||
case NL80211_IFTYPE_STATION:
|
||||
return cfg80211_mgd_wext_siwfreq(dev, info, wextfreq, extra);
|
||||
ret = cfg80211_mgd_wext_siwfreq(dev, info, wextfreq, extra);
|
||||
break;
|
||||
case NL80211_IFTYPE_ADHOC:
|
||||
return cfg80211_ibss_wext_siwfreq(dev, info, wextfreq, extra);
|
||||
ret = cfg80211_ibss_wext_siwfreq(dev, info, wextfreq, extra);
|
||||
break;
|
||||
case NL80211_IFTYPE_MONITOR:
|
||||
freq = cfg80211_wext_freq(wextfreq);
|
||||
if (freq < 0)
|
||||
return freq;
|
||||
if (freq == 0)
|
||||
return -EINVAL;
|
||||
if (freq < 0) {
|
||||
ret = freq;
|
||||
break;
|
||||
}
|
||||
if (freq == 0) {
|
||||
ret = -EINVAL;
|
||||
break;
|
||||
}
|
||||
chandef.center_freq1 = freq;
|
||||
chandef.chan = ieee80211_get_channel(&rdev->wiphy, freq);
|
||||
if (!chandef.chan)
|
||||
return -EINVAL;
|
||||
return cfg80211_set_monitor_channel(rdev, &chandef);
|
||||
if (!chandef.chan) {
|
||||
ret = -EINVAL;
|
||||
break;
|
||||
}
|
||||
ret = cfg80211_set_monitor_channel(rdev, &chandef);
|
||||
break;
|
||||
case NL80211_IFTYPE_MESH_POINT:
|
||||
freq = cfg80211_wext_freq(wextfreq);
|
||||
if (freq < 0)
|
||||
return freq;
|
||||
if (freq == 0)
|
||||
return -EINVAL;
|
||||
if (freq < 0) {
|
||||
ret = freq;
|
||||
break;
|
||||
}
|
||||
if (freq == 0) {
|
||||
ret = -EINVAL;
|
||||
break;
|
||||
}
|
||||
chandef.center_freq1 = freq;
|
||||
chandef.chan = ieee80211_get_channel(&rdev->wiphy, freq);
|
||||
if (!chandef.chan)
|
||||
return -EINVAL;
|
||||
return cfg80211_set_mesh_channel(rdev, wdev, &chandef);
|
||||
if (!chandef.chan) {
|
||||
ret = -EINVAL;
|
||||
break;
|
||||
}
|
||||
ret = cfg80211_set_mesh_channel(rdev, wdev, &chandef);
|
||||
break;
|
||||
default:
|
||||
return -EOPNOTSUPP;
|
||||
ret = -EOPNOTSUPP;
|
||||
break;
|
||||
}
|
||||
|
||||
wiphy_unlock(&rdev->wiphy);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int cfg80211_wext_giwfreq(struct net_device *dev,
|
||||
@ -797,24 +841,35 @@ static int cfg80211_wext_giwfreq(struct net_device *dev,
|
||||
struct cfg80211_chan_def chandef = {};
|
||||
int ret;
|
||||
|
||||
wiphy_lock(&rdev->wiphy);
|
||||
switch (wdev->iftype) {
|
||||
case NL80211_IFTYPE_STATION:
|
||||
return cfg80211_mgd_wext_giwfreq(dev, info, freq, extra);
|
||||
ret = cfg80211_mgd_wext_giwfreq(dev, info, freq, extra);
|
||||
break;
|
||||
case NL80211_IFTYPE_ADHOC:
|
||||
return cfg80211_ibss_wext_giwfreq(dev, info, freq, extra);
|
||||
ret = cfg80211_ibss_wext_giwfreq(dev, info, freq, extra);
|
||||
break;
|
||||
case NL80211_IFTYPE_MONITOR:
|
||||
if (!rdev->ops->get_channel)
|
||||
return -EINVAL;
|
||||
if (!rdev->ops->get_channel) {
|
||||
ret = -EINVAL;
|
||||
break;
|
||||
}
|
||||
|
||||
ret = rdev_get_channel(rdev, wdev, &chandef);
|
||||
if (ret)
|
||||
return ret;
|
||||
break;
|
||||
freq->m = chandef.chan->center_freq;
|
||||
freq->e = 6;
|
||||
return 0;
|
||||
ret = 0;
|
||||
break;
|
||||
default:
|
||||
return -EINVAL;
|
||||
ret = -EINVAL;
|
||||
break;
|
||||
}
|
||||
|
||||
wiphy_unlock(&rdev->wiphy);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int cfg80211_wext_siwtxpower(struct net_device *dev,
|
||||
@ -825,6 +880,7 @@ static int cfg80211_wext_siwtxpower(struct net_device *dev,
|
||||
struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy);
|
||||
enum nl80211_tx_power_setting type;
|
||||
int dbm = 0;
|
||||
int ret;
|
||||
|
||||
if ((data->txpower.flags & IW_TXPOW_TYPE) != IW_TXPOW_DBM)
|
||||
return -EINVAL;
|
||||
@ -866,7 +922,11 @@ static int cfg80211_wext_siwtxpower(struct net_device *dev,
|
||||
return 0;
|
||||
}
|
||||
|
||||
return rdev_set_tx_power(rdev, wdev, type, DBM_TO_MBM(dbm));
|
||||
wiphy_lock(&rdev->wiphy);
|
||||
ret = rdev_set_tx_power(rdev, wdev, type, DBM_TO_MBM(dbm));
|
||||
wiphy_unlock(&rdev->wiphy);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int cfg80211_wext_giwtxpower(struct net_device *dev,
|
||||
@ -885,7 +945,9 @@ static int cfg80211_wext_giwtxpower(struct net_device *dev,
|
||||
if (!rdev->ops->get_tx_power)
|
||||
return -EOPNOTSUPP;
|
||||
|
||||
wiphy_lock(&rdev->wiphy);
|
||||
err = rdev_get_tx_power(rdev, wdev, &val);
|
||||
wiphy_unlock(&rdev->wiphy);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
@ -1125,7 +1187,9 @@ static int cfg80211_wext_siwpower(struct net_device *dev,
|
||||
timeout = wrq->value / 1000;
|
||||
}
|
||||
|
||||
wiphy_lock(&rdev->wiphy);
|
||||
err = rdev_set_power_mgmt(rdev, dev, ps, timeout);
|
||||
wiphy_unlock(&rdev->wiphy);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
@ -1156,7 +1220,7 @@ static int cfg80211_wext_siwrate(struct net_device *dev,
|
||||
struct cfg80211_bitrate_mask mask;
|
||||
u32 fixed, maxrate;
|
||||
struct ieee80211_supported_band *sband;
|
||||
int band, ridx;
|
||||
int band, ridx, ret;
|
||||
bool match = false;
|
||||
|
||||
if (!rdev->ops->set_bitrate_mask)
|
||||
@ -1195,7 +1259,11 @@ static int cfg80211_wext_siwrate(struct net_device *dev,
|
||||
if (!match)
|
||||
return -EINVAL;
|
||||
|
||||
return rdev_set_bitrate_mask(rdev, dev, NULL, &mask);
|
||||
wiphy_lock(&rdev->wiphy);
|
||||
ret = rdev_set_bitrate_mask(rdev, dev, NULL, &mask);
|
||||
wiphy_unlock(&rdev->wiphy);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int cfg80211_wext_giwrate(struct net_device *dev,
|
||||
@ -1224,7 +1292,9 @@ static int cfg80211_wext_giwrate(struct net_device *dev,
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
wiphy_lock(&rdev->wiphy);
|
||||
err = rdev_get_station(rdev, dev, addr, &sinfo);
|
||||
wiphy_unlock(&rdev->wiphy);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
@ -1249,6 +1319,7 @@ static struct iw_statistics *cfg80211_wireless_stats(struct net_device *dev)
|
||||
static struct iw_statistics wstats;
|
||||
static struct station_info sinfo = {};
|
||||
u8 bssid[ETH_ALEN];
|
||||
int ret;
|
||||
|
||||
if (dev->ieee80211_ptr->iftype != NL80211_IFTYPE_STATION)
|
||||
return NULL;
|
||||
@ -1267,7 +1338,11 @@ static struct iw_statistics *cfg80211_wireless_stats(struct net_device *dev)
|
||||
|
||||
memset(&sinfo, 0, sizeof(sinfo));
|
||||
|
||||
if (rdev_get_station(rdev, dev, bssid, &sinfo))
|
||||
wiphy_lock(&rdev->wiphy);
|
||||
ret = rdev_get_station(rdev, dev, bssid, &sinfo);
|
||||
wiphy_unlock(&rdev->wiphy);
|
||||
|
||||
if (ret)
|
||||
return NULL;
|
||||
|
||||
memset(&wstats, 0, sizeof(wstats));
|
||||
@ -1318,15 +1393,24 @@ static int cfg80211_wext_siwap(struct net_device *dev,
|
||||
struct sockaddr *ap_addr, char *extra)
|
||||
{
|
||||
struct wireless_dev *wdev = dev->ieee80211_ptr;
|
||||
struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy);
|
||||
int ret;
|
||||
|
||||
wiphy_lock(&rdev->wiphy);
|
||||
switch (wdev->iftype) {
|
||||
case NL80211_IFTYPE_ADHOC:
|
||||
return cfg80211_ibss_wext_siwap(dev, info, ap_addr, extra);
|
||||
ret = cfg80211_ibss_wext_siwap(dev, info, ap_addr, extra);
|
||||
break;
|
||||
case NL80211_IFTYPE_STATION:
|
||||
return cfg80211_mgd_wext_siwap(dev, info, ap_addr, extra);
|
||||
ret = cfg80211_mgd_wext_siwap(dev, info, ap_addr, extra);
|
||||
break;
|
||||
default:
|
||||
return -EOPNOTSUPP;
|
||||
ret = -EOPNOTSUPP;
|
||||
break;
|
||||
}
|
||||
wiphy_unlock(&rdev->wiphy);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int cfg80211_wext_giwap(struct net_device *dev,
|
||||
@ -1334,15 +1418,24 @@ static int cfg80211_wext_giwap(struct net_device *dev,
|
||||
struct sockaddr *ap_addr, char *extra)
|
||||
{
|
||||
struct wireless_dev *wdev = dev->ieee80211_ptr;
|
||||
struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy);
|
||||
int ret;
|
||||
|
||||
wiphy_lock(&rdev->wiphy);
|
||||
switch (wdev->iftype) {
|
||||
case NL80211_IFTYPE_ADHOC:
|
||||
return cfg80211_ibss_wext_giwap(dev, info, ap_addr, extra);
|
||||
ret = cfg80211_ibss_wext_giwap(dev, info, ap_addr, extra);
|
||||
break;
|
||||
case NL80211_IFTYPE_STATION:
|
||||
return cfg80211_mgd_wext_giwap(dev, info, ap_addr, extra);
|
||||
ret = cfg80211_mgd_wext_giwap(dev, info, ap_addr, extra);
|
||||
break;
|
||||
default:
|
||||
return -EOPNOTSUPP;
|
||||
ret = -EOPNOTSUPP;
|
||||
break;
|
||||
}
|
||||
wiphy_unlock(&rdev->wiphy);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int cfg80211_wext_siwessid(struct net_device *dev,
|
||||
@ -1350,15 +1443,24 @@ static int cfg80211_wext_siwessid(struct net_device *dev,
|
||||
struct iw_point *data, char *ssid)
|
||||
{
|
||||
struct wireless_dev *wdev = dev->ieee80211_ptr;
|
||||
struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy);
|
||||
int ret;
|
||||
|
||||
wiphy_lock(&rdev->wiphy);
|
||||
switch (wdev->iftype) {
|
||||
case NL80211_IFTYPE_ADHOC:
|
||||
return cfg80211_ibss_wext_siwessid(dev, info, data, ssid);
|
||||
ret = cfg80211_ibss_wext_siwessid(dev, info, data, ssid);
|
||||
break;
|
||||
case NL80211_IFTYPE_STATION:
|
||||
return cfg80211_mgd_wext_siwessid(dev, info, data, ssid);
|
||||
ret = cfg80211_mgd_wext_siwessid(dev, info, data, ssid);
|
||||
break;
|
||||
default:
|
||||
return -EOPNOTSUPP;
|
||||
ret = -EOPNOTSUPP;
|
||||
break;
|
||||
}
|
||||
wiphy_unlock(&rdev->wiphy);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int cfg80211_wext_giwessid(struct net_device *dev,
|
||||
@ -1366,18 +1468,27 @@ static int cfg80211_wext_giwessid(struct net_device *dev,
|
||||
struct iw_point *data, char *ssid)
|
||||
{
|
||||
struct wireless_dev *wdev = dev->ieee80211_ptr;
|
||||
struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy);
|
||||
int ret;
|
||||
|
||||
data->flags = 0;
|
||||
data->length = 0;
|
||||
|
||||
wiphy_lock(&rdev->wiphy);
|
||||
switch (wdev->iftype) {
|
||||
case NL80211_IFTYPE_ADHOC:
|
||||
return cfg80211_ibss_wext_giwessid(dev, info, data, ssid);
|
||||
ret = cfg80211_ibss_wext_giwessid(dev, info, data, ssid);
|
||||
break;
|
||||
case NL80211_IFTYPE_STATION:
|
||||
return cfg80211_mgd_wext_giwessid(dev, info, data, ssid);
|
||||
ret = cfg80211_mgd_wext_giwessid(dev, info, data, ssid);
|
||||
break;
|
||||
default:
|
||||
return -EOPNOTSUPP;
|
||||
ret = -EOPNOTSUPP;
|
||||
break;
|
||||
}
|
||||
wiphy_unlock(&rdev->wiphy);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int cfg80211_wext_siwpmksa(struct net_device *dev,
|
||||
@ -1388,6 +1499,7 @@ static int cfg80211_wext_siwpmksa(struct net_device *dev,
|
||||
struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy);
|
||||
struct cfg80211_pmksa cfg_pmksa;
|
||||
struct iw_pmksa *pmksa = (struct iw_pmksa *)extra;
|
||||
int ret;
|
||||
|
||||
memset(&cfg_pmksa, 0, sizeof(struct cfg80211_pmksa));
|
||||
|
||||
@ -1397,28 +1509,39 @@ static int cfg80211_wext_siwpmksa(struct net_device *dev,
|
||||
cfg_pmksa.bssid = pmksa->bssid.sa_data;
|
||||
cfg_pmksa.pmkid = pmksa->pmkid;
|
||||
|
||||
wiphy_lock(&rdev->wiphy);
|
||||
switch (pmksa->cmd) {
|
||||
case IW_PMKSA_ADD:
|
||||
if (!rdev->ops->set_pmksa)
|
||||
return -EOPNOTSUPP;
|
||||
|
||||
return rdev_set_pmksa(rdev, dev, &cfg_pmksa);
|
||||
if (!rdev->ops->set_pmksa) {
|
||||
ret = -EOPNOTSUPP;
|
||||
break;
|
||||
}
|
||||
|
||||
ret = rdev_set_pmksa(rdev, dev, &cfg_pmksa);
|
||||
break;
|
||||
case IW_PMKSA_REMOVE:
|
||||
if (!rdev->ops->del_pmksa)
|
||||
return -EOPNOTSUPP;
|
||||
|
||||
return rdev_del_pmksa(rdev, dev, &cfg_pmksa);
|
||||
if (!rdev->ops->del_pmksa) {
|
||||
ret = -EOPNOTSUPP;
|
||||
break;
|
||||
}
|
||||
|
||||
ret = rdev_del_pmksa(rdev, dev, &cfg_pmksa);
|
||||
break;
|
||||
case IW_PMKSA_FLUSH:
|
||||
if (!rdev->ops->flush_pmksa)
|
||||
return -EOPNOTSUPP;
|
||||
|
||||
return rdev_flush_pmksa(rdev, dev);
|
||||
if (!rdev->ops->flush_pmksa) {
|
||||
ret = -EOPNOTSUPP;
|
||||
break;
|
||||
}
|
||||
|
||||
ret = rdev_flush_pmksa(rdev, dev);
|
||||
break;
|
||||
default:
|
||||
return -EOPNOTSUPP;
|
||||
ret = -EOPNOTSUPP;
|
||||
break;
|
||||
}
|
||||
wiphy_unlock(&rdev->wiphy);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
#define DEFINE_WEXT_COMPAT_STUB(func, type) \
|
||||
|
@ -3,7 +3,7 @@
|
||||
* cfg80211 wext compat for managed mode.
|
||||
*
|
||||
* Copyright 2009 Johannes Berg <johannes@sipsolutions.net>
|
||||
* Copyright (C) 2009 Intel Corporation. All rights reserved.
|
||||
* Copyright (C) 2009, 2020-2021 Intel Corporation.
|
||||
*/
|
||||
|
||||
#include <linux/export.h>
|
||||
@ -379,6 +379,7 @@ int cfg80211_wext_siwmlme(struct net_device *dev,
|
||||
if (mlme->addr.sa_family != ARPHRD_ETHER)
|
||||
return -EINVAL;
|
||||
|
||||
wiphy_lock(&rdev->wiphy);
|
||||
wdev_lock(wdev);
|
||||
switch (mlme->cmd) {
|
||||
case IW_MLME_DEAUTH:
|
||||
@ -390,6 +391,7 @@ int cfg80211_wext_siwmlme(struct net_device *dev,
|
||||
break;
|
||||
}
|
||||
wdev_unlock(wdev);
|
||||
wiphy_unlock(&rdev->wiphy);
|
||||
|
||||
return err;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user