diff options
author | Stefan Sperling <stsp@cvs.openbsd.org> | 2021-04-29 21:43:48 +0000 |
---|---|---|
committer | Stefan Sperling <stsp@cvs.openbsd.org> | 2021-04-29 21:43:48 +0000 |
commit | c2a9634c559664ca162c372f88639ac41a4de23b (patch) | |
tree | bf4273347179f3ada28e2db1d1d7d2c11ec40a5d /sys/dev/pci | |
parent | 9982cbab78e353b8f5b1a483a35ba771dedf057e (diff) |
Make iwn, iwm, and iwx keep track of beacon parameters at run-time.
- HT protection settings (this was already implemented)
- ERP (11g) protection setting
- short slottime setting
- short preamble setting
- EDCA (QoS) parameters
All of these parameters are communicated in beacons and hardware is
now kept up-to-date with them.
Prompted by a problem report from Christian Ehrhardt regarding ERP.
Tested:
iwn 6205: stsp, Josh Grosse
iwm 7265: trondd
iwm 8265: stsp, Matthias Schmidt
iwm 9260: phessler
iwx ax200: stsp, jmc, gnezdo
Diffstat (limited to 'sys/dev/pci')
-rw-r--r-- | sys/dev/pci/if_iwm.c | 52 | ||||
-rw-r--r-- | sys/dev/pci/if_iwmvar.h | 6 | ||||
-rw-r--r-- | sys/dev/pci/if_iwn.c | 61 | ||||
-rw-r--r-- | sys/dev/pci/if_iwx.c | 52 | ||||
-rw-r--r-- | sys/dev/pci/if_iwxvar.h | 6 |
5 files changed, 122 insertions, 55 deletions
diff --git a/sys/dev/pci/if_iwm.c b/sys/dev/pci/if_iwm.c index 1d7c376ff8c..78294baa6fd 100644 --- a/sys/dev/pci/if_iwm.c +++ b/sys/dev/pci/if_iwm.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_iwm.c,v 1.319 2021/04/25 15:32:21 stsp Exp $ */ +/* $OpenBSD: if_iwm.c,v 1.320 2021/04/29 21:43:47 stsp Exp $ */ /* * Copyright (c) 2014, 2016 genua gmbh <info@genua.de> @@ -328,8 +328,10 @@ void iwm_init_channel_map(struct iwm_softc *, const uint16_t * const, const uint8_t *nvm_channels, int nchan); int iwm_mimo_enabled(struct iwm_softc *); void iwm_setup_ht_rates(struct iwm_softc *); -void iwm_htprot_task(void *); -void iwm_update_htprot(struct ieee80211com *, struct ieee80211_node *); +void iwm_mac_ctxt_task(void *); +void iwm_updateprot(struct ieee80211com *); +void iwm_updateslot(struct ieee80211com *); +void iwm_updateedca(struct ieee80211com *); void iwm_init_reorder_buffer(struct iwm_reorder_buffer *, uint16_t, uint16_t); void iwm_clear_reorder_buffer(struct iwm_softc *, struct iwm_rxba_data *); @@ -3170,7 +3172,7 @@ iwm_sta_rx_agg(struct iwm_softc *sc, struct ieee80211_node *ni, uint8_t tid, } void -iwm_htprot_task(void *arg) +iwm_mac_ctxt_task(void *arg) { struct iwm_softc *sc = arg; struct ieee80211com *ic = &sc->sc_ic; @@ -3183,27 +3185,39 @@ iwm_htprot_task(void *arg) return; } - /* This call updates HT protection based on in->in_ni.ni_htop1. */ err = iwm_mac_ctxt_cmd(sc, in, IWM_FW_CTXT_ACTION_MODIFY, 1); if (err) - printf("%s: could not change HT protection: error %d\n", - DEVNAME(sc), err); + printf("%s: failed to update MAC\n", DEVNAME(sc)); refcnt_rele_wake(&sc->task_refs); splx(s); } -/* - * This function is called by upper layer when HT protection settings in - * beacons have changed. - */ void -iwm_update_htprot(struct ieee80211com *ic, struct ieee80211_node *ni) +iwm_updateprot(struct ieee80211com *ic) +{ + struct iwm_softc *sc = ic->ic_softc; + + if (ic->ic_state == IEEE80211_S_RUN) + iwm_add_task(sc, systq, &sc->mac_ctxt_task); +} + +void +iwm_updateslot(struct ieee80211com *ic) +{ + struct iwm_softc *sc = ic->ic_softc; + + if (ic->ic_state == IEEE80211_S_RUN) + iwm_add_task(sc, systq, &sc->mac_ctxt_task); +} + +void +iwm_updateedca(struct ieee80211com *ic) { struct iwm_softc *sc = ic->ic_softc; - /* assumes that ni == ic->ic_bss */ - iwm_add_task(sc, systq, &sc->htprot_task); + if (ic->ic_state == IEEE80211_S_RUN) + iwm_add_task(sc, systq, &sc->mac_ctxt_task); } void @@ -8026,7 +8040,7 @@ iwm_newstate(struct ieee80211com *ic, enum ieee80211_state nstate, int arg) if (ic->ic_state == IEEE80211_S_RUN) { timeout_del(&sc->sc_calib_to); iwm_del_task(sc, systq, &sc->ba_task); - iwm_del_task(sc, systq, &sc->htprot_task); + iwm_del_task(sc, systq, &sc->mac_ctxt_task); for (i = 0; i < nitems(sc->sc_rxba_data); i++) { struct iwm_rxba_data *rxba = &sc->sc_rxba_data[i]; iwm_clear_reorder_buffer(sc, rxba); @@ -8808,7 +8822,7 @@ iwm_stop(struct ifnet *ifp) task_del(systq, &sc->init_task); iwm_del_task(sc, sc->sc_nswq, &sc->newstate_task); iwm_del_task(sc, systq, &sc->ba_task); - iwm_del_task(sc, systq, &sc->htprot_task); + iwm_del_task(sc, systq, &sc->mac_ctxt_task); KASSERT(sc->task_refs.refs >= 1); refcnt_finalize(&sc->task_refs, "iwmstop"); @@ -10250,7 +10264,7 @@ iwm_attach(struct device *parent, struct device *self, void *aux) task_set(&sc->init_task, iwm_init_task, sc); task_set(&sc->newstate_task, iwm_newstate_task, sc); task_set(&sc->ba_task, iwm_ba_task, sc); - task_set(&sc->htprot_task, iwm_htprot_task, sc); + task_set(&sc->mac_ctxt_task, iwm_mac_ctxt_task, sc); ic->ic_node_alloc = iwm_node_alloc; ic->ic_bgscan_start = iwm_bgscan; @@ -10260,7 +10274,9 @@ iwm_attach(struct device *parent, struct device *self, void *aux) /* Override 802.11 state transition machine. */ sc->sc_newstate = ic->ic_newstate; ic->ic_newstate = iwm_newstate; - ic->ic_update_htprot = iwm_update_htprot; + ic->ic_updateprot = iwm_updateprot; + ic->ic_updateslot = iwm_updateslot; + ic->ic_updateedca = iwm_updateedca; ic->ic_ampdu_rx_start = iwm_ampdu_rx_start; ic->ic_ampdu_rx_stop = iwm_ampdu_rx_stop; #ifdef notyet diff --git a/sys/dev/pci/if_iwmvar.h b/sys/dev/pci/if_iwmvar.h index f40424718a5..05a62582e8a 100644 --- a/sys/dev/pci/if_iwmvar.h +++ b/sys/dev/pci/if_iwmvar.h @@ -1,4 +1,4 @@ -/* $OpenBSD: if_iwmvar.h,v 1.59 2021/04/25 15:32:21 stsp Exp $ */ +/* $OpenBSD: if_iwmvar.h,v 1.60 2021/04/29 21:43:47 stsp Exp $ */ /* * Copyright (c) 2014 genua mbh <info@genua.de> @@ -478,8 +478,8 @@ struct iwm_softc { uint16_t ba_winsize[IWM_MAX_TID_COUNT]; int ba_timeout_val[IWM_MAX_TID_COUNT]; - /* Task for HT protection updates. */ - struct task htprot_task; + /* Task for ERP/HT prot/slot-time/EDCA updates. */ + struct task mac_ctxt_task; bus_space_tag_t sc_st; bus_space_handle_t sc_sh; diff --git a/sys/dev/pci/if_iwn.c b/sys/dev/pci/if_iwn.c index 241fff3d280..a5a78bfcf86 100644 --- a/sys/dev/pci/if_iwn.c +++ b/sys/dev/pci/if_iwn.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_iwn.c,v 1.247 2021/03/22 09:52:49 stsp Exp $ */ +/* $OpenBSD: if_iwn.c,v 1.248 2021/04/29 21:43:47 stsp Exp $ */ /*- * Copyright (c) 2007-2010 Damien Bergamini <damien.bergamini@free.fr> @@ -247,8 +247,9 @@ int iwn_set_key(struct ieee80211com *, struct ieee80211_node *, struct ieee80211_key *); void iwn_delete_key(struct ieee80211com *, struct ieee80211_node *, struct ieee80211_key *); -void iwn_update_htprot(struct ieee80211com *, - struct ieee80211_node *); +void iwn_updateprot(struct ieee80211com *); +void iwn_updateslot(struct ieee80211com *); +void iwn_update_rxon(struct iwn_softc *); int iwn_ampdu_rx_start(struct ieee80211com *, struct ieee80211_node *, uint8_t); void iwn_ampdu_rx_stop(struct ieee80211com *, @@ -540,7 +541,8 @@ iwn_attach(struct device *parent, struct device *self, void *aux) ic->ic_updateedca = iwn_updateedca; ic->ic_set_key = iwn_set_key; ic->ic_delete_key = iwn_delete_key; - ic->ic_update_htprot = iwn_update_htprot; + ic->ic_updateprot = iwn_updateprot; + ic->ic_updateslot = iwn_updateslot; ic->ic_ampdu_rx_start = iwn_ampdu_rx_start; ic->ic_ampdu_rx_stop = iwn_ampdu_rx_stop; ic->ic_ampdu_tx_start = iwn_ampdu_tx_start; @@ -5652,25 +5654,58 @@ iwn_delete_key(struct ieee80211com *ic, struct ieee80211_node *ni, (void)ops->add_node(sc, &node, 1); } -/* - * This function is called by upper layer when HT protection settings in - * beacons have changed. - */ void -iwn_update_htprot(struct ieee80211com *ic, struct ieee80211_node *ni) +iwn_updateprot(struct ieee80211com *ic) { struct iwn_softc *sc = ic->ic_softc; - struct iwn_ops *ops = &sc->ops; enum ieee80211_htprot htprot; - struct iwn_rxon_assoc rxon_assoc; - int s, error; + + if (ic->ic_state != IEEE80211_S_RUN) + return; + + /* Update ERP protection setting. */ + if (ic->ic_flags & IEEE80211_F_USEPROT) + sc->rxon.flags |= htole32(IWN_RXON_TGG_PROT); + else + sc->rxon.flags &= ~htole32(IWN_RXON_TGG_PROT); /* Update HT protection mode setting. */ - htprot = (ni->ni_htop1 & IEEE80211_HTOP1_PROT_MASK) >> + htprot = (ic->ic_bss->ni_htop1 & IEEE80211_HTOP1_PROT_MASK) >> IEEE80211_HTOP1_PROT_SHIFT; sc->rxon.flags &= ~htole32(IWN_RXON_HT_PROTMODE(3)); sc->rxon.flags |= htole32(IWN_RXON_HT_PROTMODE(htprot)); + iwn_update_rxon(sc); +} + +void +iwn_updateslot(struct ieee80211com *ic) +{ + struct iwn_softc *sc = ic->ic_softc; + + if (ic->ic_state != IEEE80211_S_RUN) + return; + + if (ic->ic_flags & IEEE80211_F_SHSLOT) + sc->rxon.flags |= htole32(IWN_RXON_SHSLOT); + else + sc->rxon.flags &= ~htole32(IWN_RXON_SHSLOT); + + if (ic->ic_flags & IEEE80211_F_SHPREAMBLE) + sc->rxon.flags |= htole32(IWN_RXON_SHPREAMBLE); + else + sc->rxon.flags &= ~htole32(IWN_RXON_SHPREAMBLE); + + iwn_update_rxon(sc); +} +void +iwn_update_rxon(struct iwn_softc *sc) +{ + struct ieee80211com *ic = &sc->sc_ic; + struct iwn_ops *ops = &sc->ops; + struct iwn_rxon_assoc rxon_assoc; + int s, error; + /* Update RXON config. */ memset(&rxon_assoc, 0, sizeof(rxon_assoc)); rxon_assoc.flags = sc->rxon.flags; diff --git a/sys/dev/pci/if_iwx.c b/sys/dev/pci/if_iwx.c index 724ab6796ce..2775f725d63 100644 --- a/sys/dev/pci/if_iwx.c +++ b/sys/dev/pci/if_iwx.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_iwx.c,v 1.53 2021/04/25 15:32:21 stsp Exp $ */ +/* $OpenBSD: if_iwx.c,v 1.54 2021/04/29 21:43:47 stsp Exp $ */ /* * Copyright (c) 2014, 2016 genua gmbh <info@genua.de> @@ -300,8 +300,10 @@ void iwx_unprotect_session(struct iwx_softc *, struct iwx_node *); void iwx_init_channel_map(struct iwx_softc *, uint16_t *, uint32_t *, int); void iwx_setup_ht_rates(struct iwx_softc *); int iwx_mimo_enabled(struct iwx_softc *); -void iwx_htprot_task(void *); -void iwx_update_htprot(struct ieee80211com *, struct ieee80211_node *); +void iwx_mac_ctxt_task(void *); +void iwx_updateprot(struct ieee80211com *); +void iwx_updateslot(struct ieee80211com *); +void iwx_updateedca(struct ieee80211com *); void iwx_init_reorder_buffer(struct iwx_reorder_buffer *, uint16_t, uint16_t); void iwx_clear_reorder_buffer(struct iwx_softc *, struct iwx_rxba_data *); @@ -2940,7 +2942,7 @@ iwx_sta_rx_agg(struct iwx_softc *sc, struct ieee80211_node *ni, uint8_t tid, } void -iwx_htprot_task(void *arg) +iwx_mac_ctxt_task(void *arg) { struct iwx_softc *sc = arg; struct ieee80211com *ic = &sc->sc_ic; @@ -2953,27 +2955,39 @@ iwx_htprot_task(void *arg) return; } - /* This call updates HT protection based on in->in_ni.ni_htop1. */ err = iwx_mac_ctxt_cmd(sc, in, IWX_FW_CTXT_ACTION_MODIFY, 1); if (err) - printf("%s: could not change HT protection: error %d\n", - DEVNAME(sc), err); + printf("%s: failed to update MAC\n", DEVNAME(sc)); refcnt_rele_wake(&sc->task_refs); splx(s); } -/* - * This function is called by upper layer when HT protection settings in - * beacons have changed. - */ void -iwx_update_htprot(struct ieee80211com *ic, struct ieee80211_node *ni) +iwx_updateprot(struct ieee80211com *ic) +{ + struct iwx_softc *sc = ic->ic_softc; + + if (ic->ic_state == IEEE80211_S_RUN) + iwx_add_task(sc, systq, &sc->mac_ctxt_task); +} + +void +iwx_updateslot(struct ieee80211com *ic) +{ + struct iwx_softc *sc = ic->ic_softc; + + if (ic->ic_state == IEEE80211_S_RUN) + iwx_add_task(sc, systq, &sc->mac_ctxt_task); +} + +void +iwx_updateedca(struct ieee80211com *ic) { struct iwx_softc *sc = ic->ic_softc; - /* assumes that ni == ic->ic_bss */ - iwx_add_task(sc, systq, &sc->htprot_task); + if (ic->ic_state == IEEE80211_S_RUN) + iwx_add_task(sc, systq, &sc->mac_ctxt_task); } void @@ -6854,7 +6868,7 @@ iwx_newstate(struct ieee80211com *ic, enum ieee80211_state nstate, int arg) if (ic->ic_state == IEEE80211_S_RUN) { iwx_del_task(sc, systq, &sc->ba_task); - iwx_del_task(sc, systq, &sc->htprot_task); + iwx_del_task(sc, systq, &sc->mac_ctxt_task); for (i = 0; i < nitems(sc->sc_rxba_data); i++) { struct iwx_rxba_data *rxba = &sc->sc_rxba_data[i]; iwx_clear_reorder_buffer(sc, rxba); @@ -7426,7 +7440,7 @@ iwx_stop(struct ifnet *ifp) task_del(systq, &sc->init_task); iwx_del_task(sc, sc->sc_nswq, &sc->newstate_task); iwx_del_task(sc, systq, &sc->ba_task); - iwx_del_task(sc, systq, &sc->htprot_task); + iwx_del_task(sc, systq, &sc->mac_ctxt_task); KASSERT(sc->task_refs.refs >= 1); refcnt_finalize(&sc->task_refs, "iwxstop"); @@ -8823,7 +8837,7 @@ iwx_attach(struct device *parent, struct device *self, void *aux) task_set(&sc->init_task, iwx_init_task, sc); task_set(&sc->newstate_task, iwx_newstate_task, sc); task_set(&sc->ba_task, iwx_ba_task, sc); - task_set(&sc->htprot_task, iwx_htprot_task, sc); + task_set(&sc->mac_ctxt_task, iwx_mac_ctxt_task, sc); ic->ic_node_alloc = iwx_node_alloc; ic->ic_bgscan_start = iwx_bgscan; @@ -8833,7 +8847,9 @@ iwx_attach(struct device *parent, struct device *self, void *aux) /* Override 802.11 state transition machine. */ sc->sc_newstate = ic->ic_newstate; ic->ic_newstate = iwx_newstate; - ic->ic_update_htprot = iwx_update_htprot; + ic->ic_updateprot = iwx_updateprot; + ic->ic_updateslot = iwx_updateslot; + ic->ic_updateedca = iwx_updateedca; ic->ic_ampdu_rx_start = iwx_ampdu_rx_start; ic->ic_ampdu_rx_stop = iwx_ampdu_rx_stop; #ifdef notyet diff --git a/sys/dev/pci/if_iwxvar.h b/sys/dev/pci/if_iwxvar.h index 732a1a4f4ef..993528772f7 100644 --- a/sys/dev/pci/if_iwxvar.h +++ b/sys/dev/pci/if_iwxvar.h @@ -1,4 +1,4 @@ -/* $OpenBSD: if_iwxvar.h,v 1.14 2021/04/25 15:32:21 stsp Exp $ */ +/* $OpenBSD: if_iwxvar.h,v 1.15 2021/04/29 21:43:47 stsp Exp $ */ /* * Copyright (c) 2014 genua mbh <info@genua.de> @@ -458,8 +458,8 @@ struct iwx_softc { uint16_t ba_winsize[IWX_MAX_TID_COUNT]; int ba_timeout_val[IWX_MAX_TID_COUNT]; - /* Task for HT protection updates. */ - struct task htprot_task; + /* Task for ERP/HT prot/slot-time/EDCA updates. */ + struct task mac_ctxt_task; bus_space_tag_t sc_st; bus_space_handle_t sc_sh; |