LinuxKPI: 802.11: enable WME support

Most of the WME code has been there disabled for months.  One of the
reasons was that it lead to crashes early on.  It is now understood
that the crashes are independent event and we can enable WME.
Update the code and deal with the calls from net80211 and adjust the
updates to when mac80211 drivers expect them, coherently put it under
LKPI_80211_WME and enable the define locally.

Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
This commit is contained in:
Bjoern A. Zeeb 2022-11-07 12:39:46 +00:00
parent a9a35c9e35
commit 4a67f1df8b
2 changed files with 52 additions and 17 deletions

View File

@ -71,6 +71,7 @@ __FBSDID("$FreeBSD$");
#include <linux/workqueue.h>
#include "linux_80211.h"
#define LKPI_80211_WME
/* #define LKPI_80211_HW_CRYPTO */
static MALLOC_DEFINE(M_LKPI80211, "lkpi80211", "LinuxKPI 80211 compat");
@ -137,6 +138,9 @@ static struct lkpi_sta *lkpi_find_lsta_by_ni(struct lkpi_vif *,
struct ieee80211_node *);
static void lkpi_80211_txq_task(void *, int);
static void lkpi_ieee80211_free_skb_mbuf(void *);
#ifdef LKPI_80211_WME
static int lkpi_wme_update(struct lkpi_hw *, struct ieee80211vap *, bool);
#endif
static void
lkpi_lsta_dump(struct lkpi_sta *lsta, struct ieee80211_node *ni,
@ -1502,6 +1506,10 @@ lkpi_sta_assoc_to_run(struct ieee80211vap *vap, enum ieee80211_state nstate, int
"AUTH: %#x\n", __func__, lsta, lsta->state));
sta = LSTA_TO_STA(lsta);
sta->aid = IEEE80211_NODE_AID(ni);
#ifdef LKPI_80211_WME
if (vap->iv_flags & IEEE80211_F_WME)
sta->wme = true;
#endif
error = lkpi_80211_mo_sta_state(hw, vif, lsta, IEEE80211_STA_ASSOC);
if (error != 0)
goto out;
@ -1510,6 +1518,9 @@ lkpi_sta_assoc_to_run(struct ieee80211vap *vap, enum ieee80211_state nstate, int
/* Update bss info (bss_info_changed) (assoc, aid, ..). */
bss_changed = 0;
#ifdef LKPI_80211_WME
bss_changed |= lkpi_wme_update(lhw, vap, true);
#endif
if (!vif->bss_conf.assoc || vif->bss_conf.aid != IEEE80211_NODE_AID(ni)) {
vif->bss_conf.assoc = true;
vif->bss_conf.aid = IEEE80211_NODE_AID(ni);
@ -2097,13 +2108,11 @@ lkpi_iv_update_bss(struct ieee80211vap *vap, struct ieee80211_node *ni)
return (lvif->iv_update_bss(vap, ni));
}
#ifdef LKPI_80211_WME
static int
lkpi_ic_wme_update(struct ieee80211com *ic)
lkpi_wme_update(struct lkpi_hw *lhw, struct ieee80211vap *vap, bool planned)
{
/* This needs queuing and go at the right moment. */
#ifdef WITH_WME_UPDATE
struct ieee80211vap *vap;
struct lkpi_hw *lhw;
struct ieee80211com *ic;
struct ieee80211_hw *hw;
struct lkpi_vif *lvif;
struct ieee80211_vif *vif;
@ -2113,39 +2122,42 @@ lkpi_ic_wme_update(struct ieee80211com *ic)
enum ieee80211_bss_changed changed;
int error;
uint16_t ac;
#endif
IMPROVE();
KASSERT(WME_NUM_AC == IEEE80211_NUM_ACS, ("%s: WME_NUM_AC %d != "
"IEEE80211_NUM_ACS %d\n", __func__, WME_NUM_AC, IEEE80211_NUM_ACS));
#ifdef WITH_WME_UPDATE
vap = TAILQ_FIRST(&ic->ic_vaps);
if (vap == NULL)
return (0);
/* We should factor this out into per-vap (*wme_update). */
lhw = ic->ic_softc;
if ((vap->iv_flags & IEEE80211_F_WME) == 0)
return (0);
if (lhw->ops->conf_tx == NULL)
return (0);
/* XXX-BZ check amount of hw queues */
hw = LHW_TO_HW(lhw);
lvif = VAP_TO_LVIF(vap);
vif = LVIF_TO_VIF(lvif);
if (!planned && (vap->iv_state != IEEE80211_S_RUN)) {
lhw->update_wme = true;
return (0);
}
lhw->update_wme = false;
ic = lhw->ic;
ieee80211_wme_ic_getparams(ic, &chp);
IEEE80211_LOCK(ic);
for (ac = 0; ac < WME_NUM_AC; ac++)
wmeparr[ac] = chp.cap_wmeParams[ac];
IEEE80211_UNLOCK(ic);
hw = LHW_TO_HW(lhw);
lvif = VAP_TO_LVIF(vap);
vif = LVIF_TO_VIF(lvif);
/* Configure tx queues (conf_tx) & send BSS_CHANGED_QOS. */
LKPI_80211_LHW_LOCK(lhw);
for (ac = 0; ac < IEEE80211_NUM_ACS; ac++) {
struct wmeParams *wmep;
/* XXX-BZ should keep this in lvif? */
wmep = &wmeparr[ac];
bzero(&txqp, sizeof(txqp));
txqp.cw_min = wmep->wmep_logcwmin;
@ -2159,10 +2171,30 @@ lkpi_ic_wme_update(struct ieee80211com *ic)
}
LKPI_80211_LHW_UNLOCK(lhw);
changed = BSS_CHANGED_QOS;
lkpi_80211_mo_bss_info_changed(hw, vif, &vif->bss_conf, changed);
if (!planned)
lkpi_80211_mo_bss_info_changed(hw, vif, &vif->bss_conf, changed);
return (changed);
}
#endif
return (0);
static int
lkpi_ic_wme_update(struct ieee80211com *ic)
{
#ifdef LKPI_80211_WME
struct ieee80211vap *vap;
struct lkpi_hw *lhw;
IMPROVE("Use the per-VAP callback in net80211.");
vap = TAILQ_FIRST(&ic->ic_vaps);
if (vap == NULL)
return (0);
lhw = ic->ic_softc;
lkpi_wme_update(lhw, vap, false);
#endif
return (0); /* unused */
}
static struct ieee80211vap *
@ -3462,7 +3494,9 @@ linuxkpi_ieee80211_ifattach(struct ieee80211_hw *hw)
IEEE80211_C_STA |
IEEE80211_C_MONITOR |
IEEE80211_C_WPA | /* WPA/RSN */
#ifdef LKPI_80211_WME
IEEE80211_C_WME |
#endif
#if 0
IEEE80211_C_PMGT |
#endif

View File

@ -187,6 +187,7 @@ struct lkpi_hw { /* name it mac80211_sc? */
int scan_ie_len; /* Length of common per-band scan IEs. */
bool update_mc;
bool update_wme;
/* Must be last! */
struct ieee80211_hw hw __aligned(CACHE_LINE_SIZE);