net80211: introduce (*iv_update_bss)()

Introduce (*iv_update_bss)() with a default implementation to allow
drivers to overload/intercept the time when we swap iv_bss.

This helps firmware based drivers to synchronize state with firmware.
Otherwise, for some state changes, we begin with one ni (and in
LinuxKPI lsta) and try to finish with another ni (and a new lsta
in different state) and may no longer have access to the previous state.
This also saves us from constantly checking for ni changes complicating
code.

No functional changes intended.

Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
X-MFC:		move (*iv_update_bss) to spare area
This commit is contained in:
Bjoern A. Zeeb 2022-03-22 14:46:51 +00:00
parent 453d1a90f8
commit 91b4225aa1
4 changed files with 22 additions and 9 deletions

View File

@ -197,7 +197,7 @@ ieee80211_node_vdetach(struct ieee80211vap *vap)
ieee80211_node_table_reset(&ic->ic_sta, vap);
if (vap->iv_bss != NULL) {
ieee80211_free_node(vap->iv_bss);
vap->iv_bss = NULL;
vap->iv_update_bss(vap, NULL);
}
if (vap->iv_aid_bitmap != NULL) {
IEEE80211_FREE(vap->iv_aid_bitmap, M_80211_NODE);
@ -453,8 +453,7 @@ ieee80211_reset_bss(struct ieee80211vap *vap)
ni = ieee80211_alloc_node(&ic->ic_sta, vap, vap->iv_myaddr);
KASSERT(ni != NULL, ("unable to setup initial BSS node"));
obss = vap->iv_bss;
vap->iv_bss = ieee80211_ref_node(ni);
obss = vap->iv_update_bss(vap, ieee80211_ref_node(ni));
if (obss != NULL) {
copy_bss(ni, obss);
ni->ni_intval = ic->ic_bintval;
@ -846,7 +845,7 @@ ieee80211_sta_join1(struct ieee80211_node *selbs)
/*
* Committed to selbs, setup state.
*/
obss = vap->iv_bss;
obss = vap->iv_update_bss(vap, selbs); /* NB: caller assumed to bump refcnt */
/*
* Check if old+new node have the same address in which
* case we can reassociate when operating in sta mode.
@ -855,7 +854,6 @@ ieee80211_sta_join1(struct ieee80211_node *selbs)
canreassoc = (obss != NULL &&
vap->iv_state == IEEE80211_S_RUN &&
IEEE80211_ADDR_EQ(obss->ni_macaddr, selbs->ni_macaddr));
vap->iv_bss = selbs; /* NB: caller assumed to bump refcnt */
if (obss != NULL) {
struct ieee80211_node_table *nt = obss->ni_table;

View File

@ -249,6 +249,8 @@ static void vap_update_erp_protmode(void *, int);
static void vap_update_preamble(void *, int);
static void vap_update_ht_protmode(void *, int);
static void ieee80211_newstate_cb(void *, int);
static struct ieee80211_node *vap_update_bss(struct ieee80211vap *,
struct ieee80211_node *);
static int
null_raw_xmit(struct ieee80211_node *ni, struct mbuf *m,
@ -394,6 +396,7 @@ ieee80211_proto_vattach(struct ieee80211vap *vap)
vap->iv_update_beacon = null_update_beacon;
vap->iv_deliver_data = ieee80211_deliver_data;
vap->iv_protmode = IEEE80211_PROT_CTSONLY;
vap->iv_update_bss = vap_update_bss;
/* attach support for operating mode */
ic->ic_vattach[vap->iv_opmode](vap);
@ -824,6 +827,17 @@ ieee80211_reset_erp(struct ieee80211com *ic)
/* XXX TODO: schedule a new per-VAP ERP calculation */
}
static struct ieee80211_node *
vap_update_bss(struct ieee80211vap *vap, struct ieee80211_node *ni)
{
struct ieee80211_node *obss;
obss = vap->iv_bss;
vap->iv_bss = ni;
return (obss);
}
/*
* Deferred slot time update.
*

View File

@ -565,6 +565,9 @@ struct ieee80211vap {
/* state machine processing */
int (*iv_newstate)(struct ieee80211vap *,
enum ieee80211_state, int);
struct ieee80211_node * (*iv_update_bss)(struct ieee80211vap *,
struct ieee80211_node *);
/* 802.3 output method for raw frame xmit */
int (*iv_output)(struct ifnet *, struct mbuf *,
const struct sockaddr *, struct route *);

View File

@ -179,8 +179,7 @@ ieee80211_create_wds(struct ieee80211vap *vap, struct ieee80211_channel *chan)
/*
* Committed to new node, setup state.
*/
obss = vap->iv_bss;
vap->iv_bss = ni;
obss = vap->iv_update_bss(vap, ni);
ni->ni_wdsvap = vap;
}
IEEE80211_NODE_UNLOCK(nt);
@ -201,8 +200,7 @@ ieee80211_create_wds(struct ieee80211vap *vap, struct ieee80211_channel *chan)
*/
ni = ieee80211_node_create_wds(vap, vap->iv_des_bssid, chan);
if (ni != NULL) {
obss = vap->iv_bss;
vap->iv_bss = ieee80211_ref_node(ni);
obss = vap->iv_update_bss(vap, ieee80211_ref_node(ni));
ni->ni_flags |= IEEE80211_NODE_AREF;
if (obss != NULL)
ieee80211_free_node(obss);