Date: Thu, 1 Mar 2018 06:40:08 +0000 (UTC) From: Eitan Adler <eadler@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r330209 - stable/11/sys/dev/iwm Message-ID: <201803010640.w216e81c058632@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: eadler Date: Thu Mar 1 06:40:08 2018 New Revision: 330209 URL: https://svnweb.freebsd.org/changeset/base/330209 Log: MFC r318219: [iwm] Properly implement iwm_wme_update callback function. * Inspired by iwn(4) and Linux iwlwifi. * Read wme parameters into a buffer within struct iwm_vap in iwm_wme_update(). * If we aren't associated yet, the new settings will soon be sent by iwm_mvm_mac_ctxt_changed() during association. * If we are already associated, explicitly call iwm_mvm_mac_ctxt_changed() from iwm_wme_update() to send the new settings to the firmware. * Change iwm_mvm_ac_to_tx_fifo mapping, to fit the freebsd net80211 WME stream class numbering, instead of Linux's enum ieee80211_ac_numbers. Modified: stable/11/sys/dev/iwm/if_iwm.c stable/11/sys/dev/iwm/if_iwm_mac_ctxt.c stable/11/sys/dev/iwm/if_iwm_mac_ctxt.h stable/11/sys/dev/iwm/if_iwmvar.h Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/dev/iwm/if_iwm.c ============================================================================== --- stable/11/sys/dev/iwm/if_iwm.c Thu Mar 1 06:39:44 2018 (r330208) +++ stable/11/sys/dev/iwm/if_iwm.c Thu Mar 1 06:40:08 2018 (r330209) @@ -1532,13 +1532,6 @@ iwm_nic_init(struct iwm_softc *sc) return 0; } -const uint8_t iwm_mvm_ac_to_tx_fifo[] = { - IWM_MVM_TX_FIFO_VO, - IWM_MVM_TX_FIFO_VI, - IWM_MVM_TX_FIFO_BE, - IWM_MVM_TX_FIFO_BK, -}; - static int iwm_enable_txq(struct iwm_softc *sc, int sta_id, int qid, int fifo) { @@ -4242,7 +4235,7 @@ iwm_release(struct iwm_softc *sc, struct iwm_node *in) * from RUN back to SCAN is: * * iwm_mvm_power_mac_disable(sc, in); - * iwm_mvm_mac_ctxt_changed(sc, in); + * iwm_mvm_mac_ctxt_changed(sc, vap); * iwm_mvm_rm_sta(sc, in); * iwm_mvm_update_quotas(sc, NULL); * iwm_mvm_mac_ctxt_changed(sc, in); @@ -4279,7 +4272,7 @@ iwm_release(struct iwm_softc *sc, struct iwm_node *in) iwm_mvm_power_mac_disable(sc, in); - if ((error = iwm_mvm_mac_ctxt_changed(sc, in)) != 0) { + if ((error = iwm_mvm_mac_ctxt_changed(sc, vap)) != 0) { device_printf(sc->sc_dev, "mac ctxt change fail 1 %d\n", error); return error; } @@ -4291,7 +4284,7 @@ iwm_release(struct iwm_softc *sc, struct iwm_node *in) error = iwm_mvm_rm_sta(sc, in); in->in_assoc = 0; iwm_mvm_update_quotas(sc, NULL); - if ((error = iwm_mvm_mac_ctxt_changed(sc, in)) != 0) { + if ((error = iwm_mvm_mac_ctxt_changed(sc, vap)) != 0) { device_printf(sc->sc_dev, "mac ctxt change fail 2 %d\n", error); return error; } @@ -6244,12 +6237,47 @@ iwm_is_valid_ether_addr(uint8_t *addr) } static int -iwm_update_edca(struct ieee80211com *ic) +iwm_wme_update(struct ieee80211com *ic) { +#define IWM_EXP2(x) ((1 << (x)) - 1) /* CWmin = 2^ECWmin - 1 */ struct iwm_softc *sc = ic->ic_softc; + struct ieee80211vap *vap = TAILQ_FIRST(&ic->ic_vaps); + struct iwm_vap *ivp = IWM_VAP(vap); + struct iwm_node *in; + struct wmeParams tmp[WME_NUM_AC]; + int aci, error; - device_printf(sc->sc_dev, "%s: called\n", __func__); + if (vap == NULL) + return (0); + + IEEE80211_LOCK(ic); + for (aci = 0; aci < WME_NUM_AC; aci++) + tmp[aci] = ic->ic_wme.wme_chanParams.cap_wmeParams[aci]; + IEEE80211_UNLOCK(ic); + + IWM_LOCK(sc); + for (aci = 0; aci < WME_NUM_AC; aci++) { + const struct wmeParams *ac = &tmp[aci]; + ivp->queue_params[aci].aifsn = ac->wmep_aifsn; + ivp->queue_params[aci].cw_min = IWM_EXP2(ac->wmep_logcwmin); + ivp->queue_params[aci].cw_max = IWM_EXP2(ac->wmep_logcwmax); + ivp->queue_params[aci].edca_txop = + IEEE80211_TXOP_TO_US(ac->wmep_txopLimit); + } + ivp->have_wme = TRUE; + if (ivp->is_uploaded && vap->iv_bss != NULL) { + in = IWM_NODE(vap->iv_bss); + if (in->in_assoc) { + if ((error = iwm_mvm_mac_ctxt_changed(sc, vap)) != 0) { + device_printf(sc->sc_dev, + "%s: failed to update MAC\n", __func__); + } + } + } + IWM_UNLOCK(sc); + return (0); +#undef IWM_EXP2 } static void @@ -6306,7 +6334,7 @@ iwm_preinit(void *arg) ic->ic_set_channel = iwm_set_channel; ic->ic_scan_curchan = iwm_scan_curchan; ic->ic_scan_mindwell = iwm_scan_mindwell; - ic->ic_wme.wme_update = iwm_update_edca; + ic->ic_wme.wme_update = iwm_wme_update; ic->ic_parent = iwm_parent; ic->ic_transmit = iwm_transmit; iwm_radiotap_attach(sc); @@ -6363,6 +6391,8 @@ iwm_vap_create(struct ieee80211com *ic, const char nam ivp->id = IWM_DEFAULT_MACID; ivp->color = IWM_DEFAULT_COLOR; + + ivp->have_wme = FALSE; ieee80211_ratectl_init(vap); /* Complete setup. */ Modified: stable/11/sys/dev/iwm/if_iwm_mac_ctxt.c ============================================================================== --- stable/11/sys/dev/iwm/if_iwm_mac_ctxt.c Thu Mar 1 06:39:44 2018 (r330208) +++ stable/11/sys/dev/iwm/if_iwm_mac_ctxt.c Thu Mar 1 06:40:08 2018 (r330209) @@ -160,6 +160,13 @@ __FBSDID("$FreeBSD$"); * BEGIN mvm/mac-ctxt.c */ +const uint8_t iwm_mvm_ac_to_tx_fifo[] = { + IWM_MVM_TX_FIFO_BE, + IWM_MVM_TX_FIFO_BK, + IWM_MVM_TX_FIFO_VI, + IWM_MVM_TX_FIFO_VO, +}; + static void iwm_mvm_ack_rates(struct iwm_softc *sc, int is2ghz, int *cck_rates, int *ofdm_rates, struct iwm_node *in) @@ -328,16 +335,19 @@ iwm_mvm_mac_ctxt_cmd_common(struct iwm_softc *sc, stru * cmd->qos_flags |= cpu_to_le32(MAC_QOS_FLG_UPDATE_EDCA) */ - /* XXX TODO: set wme parameters; also handle getting updated wme parameters */ - for (i = 0; i < IWM_AC_NUM+1; i++) { - int txf = i; + for (i = 0; i < WME_NUM_AC; i++) { + uint8_t txf = iwm_mvm_ac_to_tx_fifo[i]; - cmd->ac[txf].cw_min = htole16(0x0f); - cmd->ac[txf].cw_max = htole16(0x3f); - cmd->ac[txf].aifsn = 1; + cmd->ac[txf].cw_min = htole16(ivp->queue_params[i].cw_min); + cmd->ac[txf].cw_max = htole16(ivp->queue_params[i].cw_max); + cmd->ac[txf].edca_txop = + htole16(ivp->queue_params[i].edca_txop); + cmd->ac[txf].aifsn = ivp->queue_params[i].aifsn; cmd->ac[txf].fifos_mask = (1 << txf); - cmd->ac[txf].edca_txop = 0; } + + if (ivp->have_wme) + cmd->qos_flags |= htole32(IWM_MAC_QOS_FLG_UPDATE_EDCA); if (ic->ic_flags & IEEE80211_F_USEPROT) cmd->protection_flags |= htole32(IWM_MAC_PROT_FLG_TGG_PROTECT); Modified: stable/11/sys/dev/iwm/if_iwm_mac_ctxt.h ============================================================================== --- stable/11/sys/dev/iwm/if_iwm_mac_ctxt.h Thu Mar 1 06:39:44 2018 (r330208) +++ stable/11/sys/dev/iwm/if_iwm_mac_ctxt.h Thu Mar 1 06:40:08 2018 (r330209) @@ -106,6 +106,8 @@ #ifndef __IF_IWM_MAC_CTXT_H__ #define __IF_IWM_MAC_CTXT_H__ +extern const uint8_t iwm_mvm_ac_to_tx_fifo[]; + extern int iwm_mvm_mac_ctxt_add(struct iwm_softc *sc, struct ieee80211vap *vap); extern int iwm_mvm_mac_ctxt_changed(struct iwm_softc *sc, struct ieee80211vap *vap); extern int iwm_mvm_mac_ctxt_remove(struct iwm_softc *sc, struct ieee80211vap *vap); Modified: stable/11/sys/dev/iwm/if_iwmvar.h ============================================================================== --- stable/11/sys/dev/iwm/if_iwmvar.h Thu Mar 1 06:39:44 2018 (r330208) +++ stable/11/sys/dev/iwm/if_iwmvar.h Thu Mar 1 06:40:08 2018 (r330209) @@ -377,6 +377,19 @@ struct iwm_vap { uint16_t id; uint16_t color; + + boolean_t have_wme; + /* + * QoS data from net80211, need to store this here + * as net80211 has a separate callback but we need + * to have the data for the MAC context + */ + struct { + uint16_t cw_min; + uint16_t cw_max; + uint16_t edca_txop; + uint8_t aifsn; + } queue_params[WME_NUM_AC]; }; #define IWM_VAP(_vap) ((struct iwm_vap *)(_vap))
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201803010640.w216e81c058632>