Author: bz Date: Thu Sep 24 10:57:39 2020 New Revision: 366112 URL: https://svnweb.freebsd.org/changeset/base/366112
Log: Provide MS() and SM() macros for 80211 and wireless drivers. We have (two versions) of MS() and SM() macros which we use throughout the wireless code. Change all but three places (ath_hal, rtwn, and rsu) to the newly provided _IEEE80211_MASKSHIFT() and _IEEE80211_SHIFTMASK() macros. Also change one internal case using both _S and _M instead of just _S away from _M (one of the reasons rtwn and rsu were not changed). This was done semi-mechanically. No functional changes intended. Requested by: gnn (D26091) Reviewed by: adrian (pre line wrap) MFC after: 2 weeks Sponsored by: Rubicon Communications, LLC (d/b/a "Netgate") Differential Revision: https://reviews.freebsd.org/D26539 Modified: head/sys/dev/ath/if_ath_tx.c head/sys/dev/ath/if_ath_tx_ht.c head/sys/dev/bwn/if_bwn.c head/sys/dev/iwn/if_iwn.c head/sys/dev/malo/if_malo.c head/sys/dev/mwl/if_mwl.c head/sys/net80211/ieee80211_freebsd.c head/sys/net80211/ieee80211_ht.c head/sys/net80211/ieee80211_ioctl.c head/sys/net80211/ieee80211_output.c head/sys/net80211/ieee80211_regdomain.c head/sys/net80211/ieee80211_sta.c head/sys/net80211/ieee80211_superg.c head/sys/net80211/ieee80211_var.h head/sys/net80211/ieee80211_vht.c Modified: head/sys/dev/ath/if_ath_tx.c ============================================================================== --- head/sys/dev/ath/if_ath_tx.c Thu Sep 24 10:42:28 2020 (r366111) +++ head/sys/dev/ath/if_ath_tx.c Thu Sep 24 10:57:39 2020 (r366112) @@ -2598,7 +2598,6 @@ ieee80211_is_action(struct ieee80211_frame *wh) return 1; } -#define MS(_v, _f) (((_v) & _f) >> _f##_S) /* * Return an alternate TID for ADDBA request frames. * @@ -2637,11 +2636,10 @@ ath_tx_action_frame_override_queue(struct ath_softc *s /* Extract TID, return it */ baparamset = le16toh(ia->rq_baparamset); - *tid = (int) MS(baparamset, IEEE80211_BAPS_TID); + *tid = (int) _IEEE80211_MASKSHIFT(baparamset, IEEE80211_BAPS_TID); return 1; } -#undef MS /* Per-node software queue operations */ Modified: head/sys/dev/ath/if_ath_tx_ht.c ============================================================================== --- head/sys/dev/ath/if_ath_tx_ht.c Thu Sep 24 10:42:28 2020 (r366111) +++ head/sys/dev/ath/if_ath_tx_ht.c Thu Sep 24 10:57:39 2020 (r366112) @@ -406,7 +406,6 @@ static int ath_compute_num_delims(struct ath_softc *sc, struct ath_buf *first_bf, uint16_t pktlen, int is_first) { -#define MS(_v, _f) (((_v) & _f) >> _f##_S) const HAL_RATE_TABLE *rt = sc->sc_currates; struct ieee80211_node *ni = first_bf->bf_node; struct ieee80211vap *vap = ni->ni_vap; @@ -421,7 +420,8 @@ ath_compute_num_delims(struct ath_softc *sc, struct at /* * Get the advertised density from the node. */ - peer_mpdudensity = MS(ni->ni_htparam, IEEE80211_HTCAP_MPDUDENSITY); + peer_mpdudensity = + _IEEE80211_MASKSHIFT(ni->ni_htparam, IEEE80211_HTCAP_MPDUDENSITY); /* * vap->iv_ampdu_density is a net80211 value, rather than the actual @@ -528,7 +528,6 @@ ath_compute_num_delims(struct ath_softc *sc, struct at __func__, pktlen, minlen, rix, rc, width, half_gi, ndelim); return ndelim; -#undef MS } /* @@ -568,7 +567,6 @@ ath_get_aggr_limit(struct ath_softc *sc, struct ieee80 { struct ieee80211vap *vap = ni->ni_vap; -#define MS(_v, _f) (((_v) & _f) >> _f##_S) int amin = ATH_AGGR_MAXSIZE; int i; @@ -583,8 +581,8 @@ ath_get_aggr_limit(struct ath_softc *sc, struct ieee80 * Check the HTCAP field for the maximum size the node has * negotiated. If it's smaller than what we have, cap it there. */ - amin = MIN(amin, ath_rx_ampdu_to_byte(MS(ni->ni_htparam, - IEEE80211_HTCAP_MAXRXAMPDU))); + amin = MIN(amin, ath_rx_ampdu_to_byte( + _IEEE80211_MASKSHIFT(ni->ni_htparam, IEEE80211_HTCAP_MAXRXAMPDU))); for (i = 0; i < ATH_RC_NUM; i++) { if (bf->bf_state.bfs_rc[i].tries == 0) @@ -598,11 +596,10 @@ ath_get_aggr_limit(struct ath_softc *sc, struct ieee80 __func__, sc->sc_aggr_limit, vap->iv_ampdu_limit, - MS(ni->ni_htparam, IEEE80211_HTCAP_MAXRXAMPDU), + _IEEE80211_MASKSHIFT(ni->ni_htparam, IEEE80211_HTCAP_MAXRXAMPDU), amin); return amin; -#undef MS } /* Modified: head/sys/dev/bwn/if_bwn.c ============================================================================== --- head/sys/dev/bwn/if_bwn.c Thu Sep 24 10:42:28 2020 (r366111) +++ head/sys/dev/bwn/if_bwn.c Thu Sep 24 10:57:39 2020 (r366112) @@ -2122,7 +2122,6 @@ bwn_stop(struct bwn_softc *sc) static void bwn_wme_clear(struct bwn_softc *sc) { -#define MS(_v, _f) (((_v) & _f) >> _f##_S) struct wmeParams *p; unsigned int i; @@ -2137,29 +2136,37 @@ bwn_wme_clear(struct bwn_softc *sc) p->wmep_txopLimit = 0; p->wmep_aifsn = 2; /* XXX FIXME: log2(cwmin) */ - p->wmep_logcwmin = MS(0x0001, WME_PARAM_LOGCWMIN); - p->wmep_logcwmax = MS(0x0001, WME_PARAM_LOGCWMAX); + p->wmep_logcwmin = + _IEEE80211_MASKSHIFT(0x0001, WME_PARAM_LOGCWMIN); + p->wmep_logcwmax = + _IEEE80211_MASKSHIFT(0x0001, WME_PARAM_LOGCWMAX); break; case BWN_WME_VIDEO: p->wmep_txopLimit = 0; p->wmep_aifsn = 2; /* XXX FIXME: log2(cwmin) */ - p->wmep_logcwmin = MS(0x0001, WME_PARAM_LOGCWMIN); - p->wmep_logcwmax = MS(0x0001, WME_PARAM_LOGCWMAX); + p->wmep_logcwmin = + _IEEE80211_MASKSHIFT(0x0001, WME_PARAM_LOGCWMIN); + p->wmep_logcwmax = + _IEEE80211_MASKSHIFT(0x0001, WME_PARAM_LOGCWMAX); break; case BWN_WME_BESTEFFORT: p->wmep_txopLimit = 0; p->wmep_aifsn = 3; /* XXX FIXME: log2(cwmin) */ - p->wmep_logcwmin = MS(0x0001, WME_PARAM_LOGCWMIN); - p->wmep_logcwmax = MS(0x03ff, WME_PARAM_LOGCWMAX); + p->wmep_logcwmin = + _IEEE80211_MASKSHIFT(0x0001, WME_PARAM_LOGCWMIN); + p->wmep_logcwmax = + _IEEE80211_MASKSHIFT(0x03ff, WME_PARAM_LOGCWMAX); break; case BWN_WME_BACKGROUND: p->wmep_txopLimit = 0; p->wmep_aifsn = 7; /* XXX FIXME: log2(cwmin) */ - p->wmep_logcwmin = MS(0x0001, WME_PARAM_LOGCWMIN); - p->wmep_logcwmax = MS(0x03ff, WME_PARAM_LOGCWMAX); + p->wmep_logcwmin = + _IEEE80211_MASKSHIFT(0x0001, WME_PARAM_LOGCWMIN); + p->wmep_logcwmax = + _IEEE80211_MASKSHIFT(0x03ff, WME_PARAM_LOGCWMAX); break; default: KASSERT(0 == 1, ("%s:%d: fail", __func__, __LINE__)); @@ -4612,14 +4619,13 @@ static void bwn_wme_loadparams(struct bwn_mac *mac, const struct wmeParams *p, uint16_t shm_offset) { -#define SM(_v, _f) (((_v) << _f##_S) & _f) struct bwn_softc *sc = mac->mac_sc; uint16_t params[BWN_NR_WMEPARAMS]; int slot, tmp; unsigned int i; slot = BWN_READ_2(mac, BWN_RNG) & - SM(p->wmep_logcwmin, WME_PARAM_LOGCWMIN); + _IEEE80211_SHIFTMASK(p->wmep_logcwmin, WME_PARAM_LOGCWMIN); memset(¶ms, 0, sizeof(params)); @@ -4628,9 +4634,12 @@ bwn_wme_loadparams(struct bwn_mac *mac, p->wmep_logcwmin, p->wmep_logcwmax, p->wmep_aifsn); params[BWN_WMEPARAM_TXOP] = p->wmep_txopLimit * 32; - params[BWN_WMEPARAM_CWMIN] = SM(p->wmep_logcwmin, WME_PARAM_LOGCWMIN); - params[BWN_WMEPARAM_CWMAX] = SM(p->wmep_logcwmax, WME_PARAM_LOGCWMAX); - params[BWN_WMEPARAM_CWCUR] = SM(p->wmep_logcwmin, WME_PARAM_LOGCWMIN); + params[BWN_WMEPARAM_CWMIN] = + _IEEE80211_SHIFTMASK(p->wmep_logcwmin, WME_PARAM_LOGCWMIN); + params[BWN_WMEPARAM_CWMAX] = + _IEEE80211_SHIFTMASK(p->wmep_logcwmax, WME_PARAM_LOGCWMAX); + params[BWN_WMEPARAM_CWCUR] = + _IEEE80211_SHIFTMASK(p->wmep_logcwmin, WME_PARAM_LOGCWMIN); params[BWN_WMEPARAM_AIFS] = p->wmep_aifsn; params[BWN_WMEPARAM_BSLOTS] = slot; params[BWN_WMEPARAM_REGGAP] = slot + p->wmep_aifsn; Modified: head/sys/dev/iwn/if_iwn.c ============================================================================== --- head/sys/dev/iwn/if_iwn.c Thu Sep 24 10:42:28 2020 (r366111) +++ head/sys/dev/iwn/if_iwn.c Thu Sep 24 10:57:39 2020 (r366112) @@ -7442,7 +7442,6 @@ static int iwn_ampdu_rx_start(struct ieee80211_node *ni, struct ieee80211_rx_ampdu *rap, int baparamset, int batimeout, int baseqctl) { -#define MS(_v, _f) (((_v) & _f) >> _f##_S) struct iwn_softc *sc = ni->ni_ic->ic_softc; struct iwn_ops *ops = &sc->ops; struct iwn_node *wn = (void *)ni; @@ -7453,8 +7452,8 @@ iwn_ampdu_rx_start(struct ieee80211_node *ni, struct i DPRINTF(sc, IWN_DEBUG_TRACE, "->Doing %s\n", __func__); - tid = MS(le16toh(baparamset), IEEE80211_BAPS_TID); - ssn = MS(le16toh(baseqctl), IEEE80211_BASEQ_START); + tid = _IEEE80211_MASKSHIFT(le16toh(baparamset), IEEE80211_BAPS_TID); + ssn = _IEEE80211_MASKSHIFT(le16toh(baseqctl), IEEE80211_BASEQ_START); if (wn->id == IWN_ID_UNDEFINED) return (ENOENT); @@ -7471,7 +7470,6 @@ iwn_ampdu_rx_start(struct ieee80211_node *ni, struct i if (error != 0) return error; return sc->sc_ampdu_rx_start(ni, rap, baparamset, batimeout, baseqctl); -#undef MS } /* Modified: head/sys/dev/malo/if_malo.c ============================================================================== --- head/sys/dev/malo/if_malo.c Thu Sep 24 10:42:28 2020 (r366111) +++ head/sys/dev/malo/if_malo.c Thu Sep 24 10:57:39 2020 (r366112) @@ -918,10 +918,6 @@ malo_fix2rate(int fix_rate) return (fix_rate < nitems(rates) ? rates[fix_rate] : 0); } -/* idiomatic shorthands: MS = mask+shift, SM = shift+mask */ -#define MS(v,x) (((v) & x) >> x##_S) -#define SM(v,x) (((v) << x##_S) & x) - /* * Process completed xmit descriptors from the specified queue. */ @@ -962,7 +958,8 @@ malo_tx_processq(struct malo_softc *sc, struct malo_tx status = le32toh(ds->status); if (status & MALO_TXD_STATUS_OK) { uint16_t format = le16toh(ds->format); - uint8_t txant = MS(format, MALO_TXD_ANTENNA); + uint8_t txant =_IEEE80211_MASKSHIFT( + format, MALO_TXD_ANTENNA); sc->malo_stats.mst_ant_tx[txant]++; if (status & MALO_TXD_STATUS_OK_RETRY) Modified: head/sys/dev/mwl/if_mwl.c ============================================================================== --- head/sys/dev/mwl/if_mwl.c Thu Sep 24 10:42:28 2020 (r366111) +++ head/sys/dev/mwl/if_mwl.c Thu Sep 24 10:57:39 2020 (r366112) @@ -83,10 +83,6 @@ __FBSDID("$FreeBSD$"); #include <dev/mwl/if_mwlvar.h> #include <dev/mwl/mwldiag.h> -/* idiomatic shorthands: MS = mask+shift, SM = shift+mask */ -#define MS(v,x) (((v) & x) >> x##_S) -#define SM(v,x) (((v) << x##_S) & x) - static struct ieee80211vap *mwl_vap_create(struct ieee80211com *, const char [IFNAMSIZ], int, enum ieee80211_opmode, int, const uint8_t [IEEE80211_ADDR_LEN], @@ -1231,8 +1227,8 @@ mwl_reset_vap(struct ieee80211vap *vap, int state) vap->iv_opmode == IEEE80211_M_MBSS || vap->iv_opmode == IEEE80211_M_IBSS)) { mwl_setapmode(vap, vap->iv_bss->ni_chan); - mwl_hal_setnprotmode(hvap, - MS(ic->ic_curhtprotmode, IEEE80211_HTINFO_OPMODE)); + mwl_hal_setnprotmode(hvap, _IEEE80211_MASKSHIFT( + ic->ic_curhtprotmode, IEEE80211_HTINFO_OPMODE)); return mwl_beacon_setup(vap); } return 0; @@ -1863,8 +1859,8 @@ mwl_beacon_update(struct ieee80211vap *vap, int item) mwl_updateslot(ic); break; case IEEE80211_BEACON_HTINFO: - mwl_hal_setnprotmode(hvap, - MS(ic->ic_curhtprotmode, IEEE80211_HTINFO_OPMODE)); + mwl_hal_setnprotmode(hvap, _IEEE80211_MASKSHIFT( + ic->ic_curhtprotmode, IEEE80211_HTINFO_OPMODE)); break; case IEEE80211_BEACON_CAPS: case IEEE80211_BEACON_WME: @@ -3045,13 +3041,13 @@ mwl_calcformat(uint8_t rate, const struct ieee80211_no { uint16_t fmt; - fmt = SM(3, EAGLE_TXD_ANTENNA) + fmt = _IEEE80211_SHIFTMASK(3, EAGLE_TXD_ANTENNA) | (IEEE80211_IS_CHAN_HT40D(ni->ni_chan) ? EAGLE_TXD_EXTCHAN_LO : EAGLE_TXD_EXTCHAN_HI); if (rate & IEEE80211_RATE_MCS) { /* HT MCS */ fmt |= EAGLE_TXD_FORMAT_HT /* NB: 0x80 implicitly stripped from ucastrate */ - | SM(rate, EAGLE_TXD_RATE); + | _IEEE80211_SHIFTMASK(rate, EAGLE_TXD_RATE); /* XXX short/long GI may be wrong; re-check */ if (IEEE80211_IS_CHAN_HT40(ni->ni_chan)) { fmt |= EAGLE_TXD_CHW_40 @@ -3064,7 +3060,8 @@ mwl_calcformat(uint8_t rate, const struct ieee80211_no } } else { /* legacy rate */ fmt |= EAGLE_TXD_FORMAT_LEGACY - | SM(mwl_cvtlegacyrate(rate), EAGLE_TXD_RATE) + | _IEEE80211_SHIFTMASK(mwl_cvtlegacyrate(rate), + EAGLE_TXD_RATE) | EAGLE_TXD_CHW_20 /* XXX iv_flags & IEEE80211_F_SHPREAMBLE? */ | (ni->ni_capinfo & IEEE80211_CAPINFO_SHORT_PREAMBLE ? @@ -3365,7 +3362,8 @@ mwl_tx_processq(struct mwl_softc *sc, struct mwl_txq * status = le32toh(ds->Status); if (status & EAGLE_TXD_STATUS_OK) { uint16_t Format = le16toh(ds->Format); - uint8_t txant = MS(Format, EAGLE_TXD_ANTENNA); + uint8_t txant = _IEEE80211_MASKSHIFT(Format, + EAGLE_TXD_ANTENNA); sc->sc_stats.mst_ant_tx[txant]++; if (status & EAGLE_TXD_STATUS_OK_RETRY) @@ -3374,7 +3372,8 @@ mwl_tx_processq(struct mwl_softc *sc, struct mwl_txq * sc->sc_stats.mst_tx_mretries++; if (txq->qnum >= MWL_WME_AC_VO) ic->ic_wme.wme_hipri_traffic++; - ni->ni_txrate = MS(Format, EAGLE_TXD_RATE); + ni->ni_txrate = _IEEE80211_MASKSHIFT(Format, + EAGLE_TXD_RATE); if ((Format & EAGLE_TXD_FORMAT_HT) == 0) { ni->ni_txrate = mwl_cvtlegacyrix( ni->ni_txrate); @@ -3557,7 +3556,8 @@ mwl_recv_action(struct ieee80211_node *ni, const struc mwl_hal_setmimops(sc->sc_mh, ni->ni_macaddr, mps->am_control & IEEE80211_A_HT_MIMOPWRSAVE_ENA, - MS(mps->am_control, IEEE80211_A_HT_MIMOPWRSAVE_MODE)); + _IEEE80211_MASKSHIFT(mps->am_control, + IEEE80211_A_HT_MIMOPWRSAVE_MODE)); return 0; } else return sc->sc_recv_action(ni, wh, frm, efrm); @@ -3660,7 +3660,7 @@ mwl_addba_response(struct ieee80211_node *ni, struct i * we know resources are available because we * pre-allocated one before forming the request. */ - bufsiz = MS(baparamset, IEEE80211_BAPS_BUFSIZ); + bufsiz = _IEEE80211_MASKSHIFT(baparamset, IEEE80211_BAPS_BUFSIZ); if (bufsiz == 0) bufsiz = IEEE80211_AGGR_BAWMAX; error = mwl_hal_bastream_create(MWL_VAP(vap)->mv_hvap, Modified: head/sys/net80211/ieee80211_freebsd.c ============================================================================== --- head/sys/net80211/ieee80211_freebsd.c Thu Sep 24 10:42:28 2020 (r366111) +++ head/sys/net80211/ieee80211_freebsd.c Thu Sep 24 10:57:39 2020 (r366112) @@ -319,7 +319,6 @@ ieee80211_sysctl_vdetach(struct ieee80211vap *vap) } } -#define MS(_v, _f) (((_v) & _f##_M) >> _f##_S) int ieee80211_com_vincref(struct ieee80211vap *vap) { @@ -332,7 +331,8 @@ ieee80211_com_vincref(struct ieee80211vap *vap) return (ENETDOWN); } - if (MS(ostate, IEEE80211_COM_REF) == IEEE80211_COM_REF_MAX) { + if (_IEEE80211_MASKSHIFT(ostate, IEEE80211_COM_REF) == + IEEE80211_COM_REF_MAX) { atomic_subtract_32(&vap->iv_com_state, IEEE80211_COM_REF_ADD); return (EOVERFLOW); } @@ -347,7 +347,7 @@ ieee80211_com_vdecref(struct ieee80211vap *vap) ostate = atomic_fetchadd_32(&vap->iv_com_state, -IEEE80211_COM_REF_ADD); - KASSERT(MS(ostate, IEEE80211_COM_REF) != 0, + KASSERT(_IEEE80211_MASKSHIFT(ostate, IEEE80211_COM_REF) != 0, ("com reference counter underflow")); (void) ostate; @@ -360,10 +360,10 @@ ieee80211_com_vdetach(struct ieee80211vap *vap) sleep_time = msecs_to_ticks(250); atomic_set_32(&vap->iv_com_state, IEEE80211_COM_DETACHED); - while (MS(atomic_load_32(&vap->iv_com_state), IEEE80211_COM_REF) != 0) + while (_IEEE80211_MASKSHIFT(atomic_load_32(&vap->iv_com_state), + IEEE80211_COM_REF) != 0) pause("comref", sleep_time); } -#undef MS int ieee80211_node_dectestref(struct ieee80211_node *ni) Modified: head/sys/net80211/ieee80211_ht.c ============================================================================== --- head/sys/net80211/ieee80211_ht.c Thu Sep 24 10:42:28 2020 (r366111) +++ head/sys/net80211/ieee80211_ht.c Thu Sep 24 10:57:39 2020 (r366112) @@ -54,10 +54,6 @@ __FBSDID("$FreeBSD$"); #include <net80211/ieee80211_action.h> #include <net80211/ieee80211_input.h> -/* define here, used throughout file */ -#define MS(_v, _f) (((_v) & _f) >> _f##_S) -#define SM(_v, _f) (((_v) << _f##_S) & _f) - const struct ieee80211_mcs_rates ieee80211_htrates[IEEE80211_HTRATE_MAXSIZE] = { { 13, 14, 27, 30 }, /* MCS 0 */ { 26, 29, 54, 60 }, /* MCS 1 */ @@ -703,7 +699,7 @@ ampdu_rx_start(struct ieee80211_node *ni, struct ieee8 int baparamset, int batimeout, int baseqctl) { struct ieee80211vap *vap = ni->ni_vap; - int bufsiz = MS(baparamset, IEEE80211_BAPS_BUFSIZ); + int bufsiz = _IEEE80211_MASKSHIFT(baparamset, IEEE80211_BAPS_BUFSIZ); if (rap->rxa_flags & IEEE80211_AGGR_RUNNING) { /* @@ -715,12 +711,12 @@ ampdu_rx_start(struct ieee80211_node *ni, struct ieee8 ieee80211_ampdu_rx_init_rap(ni, rap); rap->rxa_wnd = (bufsiz == 0) ? IEEE80211_AGGR_BAWMAX : min(bufsiz, IEEE80211_AGGR_BAWMAX); - rap->rxa_start = MS(baseqctl, IEEE80211_BASEQ_START); + rap->rxa_start = _IEEE80211_MASKSHIFT(baseqctl, IEEE80211_BASEQ_START); rap->rxa_flags |= IEEE80211_AGGR_RUNNING | IEEE80211_AGGR_XCHGPEND; /* XXX this should be a configuration flag */ if ((vap->iv_htcaps & IEEE80211_HTC_RX_AMSDU_AMPDU) && - (MS(baparamset, IEEE80211_BAPS_AMSDU))) + (_IEEE80211_MASKSHIFT(baparamset, IEEE80211_BAPS_AMSDU))) rap->rxa_flags |= IEEE80211_AGGR_AMSDU; else rap->rxa_flags &= ~IEEE80211_AGGR_AMSDU; @@ -1247,7 +1243,7 @@ ieee80211_recv_bar(struct ieee80211_node *ni, struct m } wh = mtod(m0, struct ieee80211_frame_bar *); /* XXX check basic BAR */ - tid = MS(le16toh(wh->i_ctl), IEEE80211_BAR_TID); + tid = _IEEE80211_MASKSHIFT(le16toh(wh->i_ctl), IEEE80211_BAR_TID); rap = &ni->ni_rx_ampdu[tid]; if ((rap->rxa_flags & IEEE80211_AGGR_XCHGPEND) == 0) { /* @@ -1627,7 +1623,7 @@ void ieee80211_htprot_update(struct ieee80211vap *vap, int protmode) { struct ieee80211com *ic = vap->iv_ic; -#define OPMODE(x) SM(x, IEEE80211_HTINFO_OPMODE) +#define OPMODE(x) _IEEE80211_SHIFTMASK(x, IEEE80211_HTINFO_OPMODE) IEEE80211_LOCK(ic); /* track non-HT station presence */ @@ -1699,11 +1695,12 @@ htinfo_parse(struct ieee80211_node *ni, uint16_t w; ni->ni_htctlchan = htinfo->hi_ctrlchannel; - ni->ni_ht2ndchan = SM(htinfo->hi_byte1, IEEE80211_HTINFO_2NDCHAN); + ni->ni_ht2ndchan = _IEEE80211_SHIFTMASK(htinfo->hi_byte1, + IEEE80211_HTINFO_2NDCHAN); w = le16dec(&htinfo->hi_byte2); - ni->ni_htopmode = SM(w, IEEE80211_HTINFO_OPMODE); + ni->ni_htopmode = _IEEE80211_SHIFTMASK(w, IEEE80211_HTINFO_OPMODE); w = le16dec(&htinfo->hi_byte45); - ni->ni_htstbc = SM(w, IEEE80211_HTINFO_BASIC_STBCMCS); + ni->ni_htstbc = _IEEE80211_SHIFTMASK(w, IEEE80211_HTINFO_BASIC_STBCMCS); } /* @@ -1942,7 +1939,7 @@ ieee80211_vht_get_vhtflags(struct ieee80211_node *ni, if (ni->ni_flags & IEEE80211_NODE_VHT && vap->iv_flags_vht & IEEE80211_FVHT_VHT) { if ((ni->ni_vht_chanwidth == IEEE80211_VHT_CHANWIDTH_160MHZ) && /* XXX 2 means "160MHz and 80+80MHz", 1 means "160MHz" */ - (MS(vap->iv_vhtcaps, + (_IEEE80211_MASKSHIFT(vap->iv_vhtcaps, IEEE80211_VHTCAP_SUPP_CHAN_WIDTH_MASK) >= 1) && (vap->iv_flags_vht & IEEE80211_FVHT_USEVHT160)) { vhtflags = IEEE80211_CHAN_VHT160; @@ -1954,7 +1951,7 @@ ieee80211_vht_get_vhtflags(struct ieee80211_node *ni, } } else if ((ni->ni_vht_chanwidth == IEEE80211_VHT_CHANWIDTH_80P80MHZ) && /* XXX 2 means "160MHz and 80+80MHz" */ - (MS(vap->iv_vhtcaps, + (_IEEE80211_MASKSHIFT(vap->iv_vhtcaps, IEEE80211_VHTCAP_SUPP_CHAN_WIDTH_MASK) == 2) && (vap->iv_flags_vht & IEEE80211_FVHT_USEVHT80P80)) { vhtflags = IEEE80211_CHAN_VHT80P80; @@ -2287,7 +2284,7 @@ ieee80211_addba_request(struct ieee80211_node *ni, /* XXX locking */ tap->txa_token = dialogtoken; tap->txa_flags |= IEEE80211_AGGR_IMMEDIATE; - bufsiz = MS(baparamset, IEEE80211_BAPS_BUFSIZ); + bufsiz = _IEEE80211_MASKSHIFT(baparamset, IEEE80211_BAPS_BUFSIZ); tap->txa_wnd = (bufsiz == 0) ? IEEE80211_AGGR_BAWMAX : min(bufsiz, IEEE80211_AGGR_BAWMAX); addba_start_timeout(tap); @@ -2359,17 +2356,17 @@ ieee80211_addba_response(struct ieee80211_node *ni, /* XXX locking */ addba_stop_timeout(tap); if (status == IEEE80211_STATUS_SUCCESS) { - bufsiz = MS(baparamset, IEEE80211_BAPS_BUFSIZ); + bufsiz = _IEEE80211_MASKSHIFT(baparamset, IEEE80211_BAPS_BUFSIZ); /* XXX override our request? */ tap->txa_wnd = (bufsiz == 0) ? IEEE80211_AGGR_BAWMAX : min(bufsiz, IEEE80211_AGGR_BAWMAX); - tid = MS(baparamset, IEEE80211_BAPS_TID); + tid = _IEEE80211_MASKSHIFT(baparamset, IEEE80211_BAPS_TID); tap->txa_flags |= IEEE80211_AGGR_RUNNING; tap->txa_attempts = 0; /* TODO: this should be a vap flag */ if ((vap->iv_htcaps & IEEE80211_HTC_TX_AMSDU_AMPDU) && (ni->ni_flags & IEEE80211_NODE_AMSDU_TX) && - (MS(baparamset, IEEE80211_BAPS_AMSDU))) + (_IEEE80211_MASKSHIFT(baparamset, IEEE80211_BAPS_AMSDU))) tap->txa_flags |= IEEE80211_AGGR_AMSDU; else tap->txa_flags &= ~IEEE80211_AGGR_AMSDU; @@ -2420,17 +2417,17 @@ ht_recv_action_ba_addba_request(struct ieee80211_node batimeout = le16dec(frm+5); baseqctl = le16dec(frm+7); - tid = MS(baparamset, IEEE80211_BAPS_TID); + tid = _IEEE80211_MASKSHIFT(baparamset, IEEE80211_BAPS_TID); IEEE80211_NOTE(vap, IEEE80211_MSG_ACTION | IEEE80211_MSG_11N, ni, "recv ADDBA request: dialogtoken %u baparamset 0x%x " "(tid %d bufsiz %d) batimeout %d baseqctl %d:%d amsdu %d", dialogtoken, baparamset, - tid, MS(baparamset, IEEE80211_BAPS_BUFSIZ), + tid, _IEEE80211_MASKSHIFT(baparamset, IEEE80211_BAPS_BUFSIZ), batimeout, - MS(baseqctl, IEEE80211_BASEQ_START), - MS(baseqctl, IEEE80211_BASEQ_FRAG), - MS(baparamset, IEEE80211_BAPS_AMSDU)); + _IEEE80211_MASKSHIFT(baseqctl, IEEE80211_BASEQ_START), + _IEEE80211_MASKSHIFT(baseqctl, IEEE80211_BASEQ_FRAG), + _IEEE80211_MASKSHIFT(baparamset, IEEE80211_BAPS_AMSDU)); rap = &ni->ni_rx_ampdu[tid]; @@ -2459,8 +2456,8 @@ ht_recv_action_ba_addba_request(struct ieee80211_node } /* XXX honor rap flags? */ args[2] = IEEE80211_BAPS_POLICY_IMMEDIATE - | SM(tid, IEEE80211_BAPS_TID) - | SM(rap->rxa_wnd, IEEE80211_BAPS_BUFSIZ) + | _IEEE80211_SHIFTMASK(tid, IEEE80211_BAPS_TID) + | _IEEE80211_SHIFTMASK(rap->rxa_wnd, IEEE80211_BAPS_BUFSIZ) ; /* @@ -2495,10 +2492,10 @@ ht_recv_action_ba_addba_response(struct ieee80211_node dialogtoken = frm[2]; code = le16dec(frm+3); baparamset = le16dec(frm+5); - tid = MS(baparamset, IEEE80211_BAPS_TID); - bufsiz = MS(baparamset, IEEE80211_BAPS_BUFSIZ); - policy = MS(baparamset, IEEE80211_BAPS_POLICY); - amsdu = !! MS(baparamset, IEEE80211_BAPS_AMSDU); + tid = _IEEE80211_MASKSHIFT(baparamset, IEEE80211_BAPS_TID); + bufsiz = _IEEE80211_MASKSHIFT(baparamset, IEEE80211_BAPS_BUFSIZ); + policy = _IEEE80211_MASKSHIFT(baparamset, IEEE80211_BAPS_POLICY); + amsdu = !! _IEEE80211_MASKSHIFT(baparamset, IEEE80211_BAPS_AMSDU); batimeout = le16dec(frm+7); tap = &ni->ni_tx_ampdu[tid]; @@ -2572,12 +2569,12 @@ ht_recv_action_ba_delba(struct ieee80211_node *ni, baparamset = le16dec(frm+2); code = le16dec(frm+4); - tid = MS(baparamset, IEEE80211_DELBAPS_TID); + tid = _IEEE80211_MASKSHIFT(baparamset, IEEE80211_DELBAPS_TID); IEEE80211_NOTE(ni->ni_vap, IEEE80211_MSG_ACTION | IEEE80211_MSG_11N, ni, "recv DELBA: baparamset 0x%x (tid %d initiator %d) " "code %d", baparamset, tid, - MS(baparamset, IEEE80211_DELBAPS_INIT), code); + _IEEE80211_MASKSHIFT(baparamset, IEEE80211_DELBAPS_INIT), code); if ((baparamset & IEEE80211_DELBAPS_INIT) == 0) { tap = &ni->ni_tx_ampdu[tid]; @@ -2706,8 +2703,9 @@ ieee80211_ampdu_request(struct ieee80211_node *ni, args[0] = dialogtoken; args[1] = 0; /* NB: status code not used */ args[2] = IEEE80211_BAPS_POLICY_IMMEDIATE - | SM(tid, IEEE80211_BAPS_TID) - | SM(IEEE80211_AGGR_BAWMAX, IEEE80211_BAPS_BUFSIZ) + | _IEEE80211_SHIFTMASK(tid, IEEE80211_BAPS_TID) + | _IEEE80211_SHIFTMASK(IEEE80211_AGGR_BAWMAX, + IEEE80211_BAPS_BUFSIZ) ; /* XXX TODO: this should be a flag, not iv_htcaps */ @@ -2731,8 +2729,8 @@ ieee80211_ampdu_request(struct ieee80211_node *ni, } tokens = dialogtoken; /* allocate token */ /* NB: after calling ic_addba_request so driver can set txa_start */ - args[4] = SM(tap->txa_start, IEEE80211_BASEQ_START) - | SM(0, IEEE80211_BASEQ_FRAG) + args[4] = _IEEE80211_SHIFTMASK(tap->txa_start, IEEE80211_BASEQ_START) + | _IEEE80211_SHIFTMASK(0, IEEE80211_BASEQ_FRAG) ; return ic->ic_send_action(ni, IEEE80211_ACTION_CAT_BA, IEEE80211_ACTION_BA_ADDBA_REQUEST, args); @@ -2951,9 +2949,9 @@ ieee80211_send_bar(struct ieee80211_node *ni, barctl = (tap->txa_flags & IEEE80211_AGGR_IMMEDIATE ? 0 : IEEE80211_BAR_NOACK) | IEEE80211_BAR_COMP - | SM(tid, IEEE80211_BAR_TID) + | _IEEE80211_SHIFTMASK(tid, IEEE80211_BAR_TID) ; - barseqctl = SM(seq, IEEE80211_BAR_SEQ_START); + barseqctl = _IEEE80211_SHIFTMASK(seq, IEEE80211_BAR_SEQ_START); /* NB: known to have proper alignment */ bar->i_ctl = htole16(barctl); bar->i_seq = htole16(barseqctl); @@ -3047,9 +3045,10 @@ ht_send_action_ba_addba(struct ieee80211_node *ni, "send ADDBA %s: dialogtoken %d status %d " "baparamset 0x%x (tid %d amsdu %d) batimeout 0x%x baseqctl 0x%x", (action == IEEE80211_ACTION_BA_ADDBA_REQUEST) ? - "request" : "response", - args[0], args[1], args[2], MS(args[2], IEEE80211_BAPS_TID), - MS(args[2], IEEE80211_BAPS_AMSDU), args[3], args[4]); + "request" : "response", args[0], args[1], args[2], + _IEEE80211_MASKSHIFT(args[2], IEEE80211_BAPS_TID), + _IEEE80211_MASKSHIFT(args[2], IEEE80211_BAPS_AMSDU), + args[3], args[4]); IEEE80211_DPRINTF(vap, IEEE80211_MSG_NODE, "ieee80211_ref_node (%s:%u) %p<%s> refcnt %d\n", __func__, __LINE__, @@ -3092,7 +3091,7 @@ ht_send_action_ba_delba(struct ieee80211_node *ni, uint16_t baparamset; uint8_t *frm; - baparamset = SM(args[0], IEEE80211_DELBAPS_TID) + baparamset = _IEEE80211_SHIFTMASK(args[0], IEEE80211_DELBAPS_TID) | args[1] ; IEEE80211_NOTE(vap, IEEE80211_MSG_ACTION | IEEE80211_MSG_11N, ni, @@ -3244,8 +3243,10 @@ ieee80211_add_htcap_body(uint8_t *frm, struct ieee8021 caps &= ~IEEE80211_HTCAP_CHWIDTH40; /* Start by using the advertised settings */ - rxmax = MS(ni->ni_htparam, IEEE80211_HTCAP_MAXRXAMPDU); - density = MS(ni->ni_htparam, IEEE80211_HTCAP_MPDUDENSITY); + rxmax = _IEEE80211_MASKSHIFT(ni->ni_htparam, + IEEE80211_HTCAP_MAXRXAMPDU); + density = _IEEE80211_MASKSHIFT(ni->ni_htparam, + IEEE80211_HTCAP_MPDUDENSITY); IEEE80211_DPRINTF(vap, IEEE80211_MSG_11N, "%s: advertised rxmax=%d, density=%d, vap rxmax=%d, density=%d\n", @@ -3308,8 +3309,8 @@ ieee80211_add_htcap_body(uint8_t *frm, struct ieee8021 ADDSHORT(frm, caps); /* HT parameters */ - *frm = SM(rxmax, IEEE80211_HTCAP_MAXRXAMPDU) - | SM(density, IEEE80211_HTCAP_MPDUDENSITY) + *frm = _IEEE80211_SHIFTMASK(rxmax, IEEE80211_HTCAP_MAXRXAMPDU) + | _IEEE80211_SHIFTMASK(density, IEEE80211_HTCAP_MPDUDENSITY) ; frm++; @@ -3397,8 +3398,8 @@ ieee80211_add_htcap_body_ch(uint8_t *frm, struct ieee8 ADDSHORT(frm, caps); /* HT parameters */ - *frm = SM(rxmax, IEEE80211_HTCAP_MAXRXAMPDU) - | SM(density, IEEE80211_HTCAP_MPDUDENSITY) + *frm = _IEEE80211_SHIFTMASK(rxmax, IEEE80211_HTCAP_MAXRXAMPDU) + | _IEEE80211_SHIFTMASK(density, IEEE80211_HTCAP_MPDUDENSITY) ; frm++; Modified: head/sys/net80211/ieee80211_ioctl.c ============================================================================== --- head/sys/net80211/ieee80211_ioctl.c Thu Sep 24 10:42:28 2020 (r366111) +++ head/sys/net80211/ieee80211_ioctl.c Thu Sep 24 10:57:39 2020 (r366112) @@ -777,7 +777,6 @@ static int ieee80211_ioctl_get80211(struct ieee80211vap *vap, u_long cmd, struct ieee80211req *ireq) { -#define MS(_v, _f) (((_v) & _f) >> _f##_S) struct ieee80211com *ic = vap->iv_ic; u_int kid, len; uint8_t tmpkey[IEEE80211_KEYBUF_SIZE]; @@ -1035,7 +1034,7 @@ ieee80211_ioctl_get80211(struct ieee80211vap *vap, u_l * XXX TODO: this isn't completely correct, as we've * negotiated the higher of the two. */ - ireq->i_val = MS(vap->iv_bss->ni_htparam, + ireq->i_val = _IEEE80211_MASKSHIFT( vap->iv_bss->ni_htparam, IEEE80211_HTCAP_MAXRXAMPDU); else ireq->i_val = vap->iv_ampdu_limit; @@ -1048,7 +1047,7 @@ ieee80211_ioctl_get80211(struct ieee80211vap *vap, u_l * XXX TODO: this isn't completely correct, as we've * negotiated the higher of the two. */ - ireq->i_val = MS(vap->iv_bss->ni_htparam, + ireq->i_val = _IEEE80211_MASKSHIFT(vap->iv_bss->ni_htparam, IEEE80211_HTCAP_MPDUDENSITY); else ireq->i_val = vap->iv_ampdu_density; @@ -1167,7 +1166,6 @@ ieee80211_ioctl_get80211(struct ieee80211vap *vap, u_l break; } return error; -#undef MS } static int Modified: head/sys/net80211/ieee80211_output.c ============================================================================== --- head/sys/net80211/ieee80211_output.c Thu Sep 24 10:42:28 2020 (r366111) +++ head/sys/net80211/ieee80211_output.c Thu Sep 24 10:57:39 2020 (r366112) @@ -2215,7 +2215,6 @@ static uint8_t * ieee80211_add_wme_param(uint8_t *frm, struct ieee80211_wme_state *wme, int uapsd_enable) { -#define SM(_v, _f) (((_v) << _f##_S) & _f) #define ADDSHORT(frm, v) do { \ le16enc(frm, v); \ frm += 2; \ @@ -2242,17 +2241,18 @@ ieee80211_add_wme_param(uint8_t *frm, struct ieee80211 for (i = 0; i < WME_NUM_AC; i++) { const struct wmeParams *ac = &wme->wme_bssChanParams.cap_wmeParams[i]; - *frm++ = SM(i, WME_PARAM_ACI) - | SM(ac->wmep_acm, WME_PARAM_ACM) - | SM(ac->wmep_aifsn, WME_PARAM_AIFSN) + *frm++ = _IEEE80211_SHIFTMASK(i, WME_PARAM_ACI) + | _IEEE80211_SHIFTMASK(ac->wmep_acm, WME_PARAM_ACM) + | _IEEE80211_SHIFTMASK(ac->wmep_aifsn, WME_PARAM_AIFSN) ; - *frm++ = SM(ac->wmep_logcwmax, WME_PARAM_LOGCWMAX) - | SM(ac->wmep_logcwmin, WME_PARAM_LOGCWMIN) + *frm++ = _IEEE80211_SHIFTMASK(ac->wmep_logcwmax, + WME_PARAM_LOGCWMAX) + | _IEEE80211_SHIFTMASK(ac->wmep_logcwmin, + WME_PARAM_LOGCWMIN) ; ADDSHORT(frm, ac->wmep_txopLimit); } return frm; -#undef SM #undef ADDSHORT } #undef WME_OUI_BYTES Modified: head/sys/net80211/ieee80211_regdomain.c ============================================================================== --- head/sys/net80211/ieee80211_regdomain.c Thu Sep 24 10:42:28 2020 (r366111) +++ head/sys/net80211/ieee80211_regdomain.c Thu Sep 24 10:57:39 2020 (r366112) @@ -151,12 +151,12 @@ ieee80211_init_channels(struct ieee80211com *ic, if (isset(bands, IEEE80211_MODE_VHT_5GHZ)) { cbw_flags |= NET80211_CBW_FLAG_HT40; /* Make sure this is set; or assert? */ cbw_flags |= NET80211_CBW_FLAG_VHT80; -#define MS(_v, _f) (((_v) & _f) >> _f##_S) - if (MS(ic->ic_vhtcaps, IEEE80211_VHTCAP_SUPP_CHAN_WIDTH_MASK) >= 1) + if (_IEEE80211_MASKSHIFT(ic->ic_vhtcaps, + IEEE80211_VHTCAP_SUPP_CHAN_WIDTH_MASK) >= 1) cbw_flags |= NET80211_CBW_FLAG_VHT160; - if (MS(ic->ic_vhtcaps, IEEE80211_VHTCAP_SUPP_CHAN_WIDTH_MASK) == 2) + if (_IEEE80211_MASKSHIFT(ic->ic_vhtcaps, + IEEE80211_VHTCAP_SUPP_CHAN_WIDTH_MASK) == 2) cbw_flags |= NET80211_CBW_FLAG_VHT80P80; -#undef MS ieee80211_add_channel_list_5ghz(chans, IEEE80211_CHAN_MAX, nchans, def_chan_5ghz_band1, nitems(def_chan_5ghz_band1), bands, cbw_flags); Modified: head/sys/net80211/ieee80211_sta.c ============================================================================== --- head/sys/net80211/ieee80211_sta.c Thu Sep 24 10:42:28 2020 (r366111) +++ head/sys/net80211/ieee80211_sta.c Thu Sep 24 10:57:39 2020 (r366112) @@ -1161,7 +1161,6 @@ int ieee80211_parse_wmeparams(struct ieee80211vap *vap, uint8_t *frm, const struct ieee80211_frame *wh, uint8_t *qosinfo) { -#define MS(_v, _f) (((_v) & _f) >> _f##_S) struct ieee80211_wme_state *wme = &vap->iv_ic->ic_wme; u_int len = frm[1], qosinfo_count; int i; @@ -1185,10 +1184,13 @@ ieee80211_parse_wmeparams(struct ieee80211vap *vap, ui struct wmeParams *wmep = &wme->wme_wmeChanParams.cap_wmeParams[i]; /* NB: ACI not used */ - wmep->wmep_acm = MS(frm[0], WME_PARAM_ACM); - wmep->wmep_aifsn = MS(frm[0], WME_PARAM_AIFSN); - wmep->wmep_logcwmin = MS(frm[1], WME_PARAM_LOGCWMIN); - wmep->wmep_logcwmax = MS(frm[1], WME_PARAM_LOGCWMAX); + wmep->wmep_acm = _IEEE80211_MASKSHIFT(frm[0], WME_PARAM_ACM); + wmep->wmep_aifsn = + _IEEE80211_MASKSHIFT(frm[0], WME_PARAM_AIFSN); + wmep->wmep_logcwmin = + _IEEE80211_MASKSHIFT(frm[1], WME_PARAM_LOGCWMIN); + wmep->wmep_logcwmax = + _IEEE80211_MASKSHIFT(frm[1], WME_PARAM_LOGCWMAX); wmep->wmep_txopLimit = le16dec(frm+2); IEEE80211_DPRINTF(vap, IEEE80211_MSG_WME, "%s: WME: %d: acm=%d aifsn=%d logcwmin=%d logcwmax=%d txopLimit=%d\n", @@ -1203,7 +1205,6 @@ ieee80211_parse_wmeparams(struct ieee80211vap *vap, ui } wme->wme_wmeChanParams.cap_info = qosinfo_count; return 1; -#undef MS } /* Modified: head/sys/net80211/ieee80211_superg.c ============================================================================== --- head/sys/net80211/ieee80211_superg.c Thu Sep 24 10:42:28 2020 (r366111) +++ head/sys/net80211/ieee80211_superg.c Thu Sep 24 10:57:39 2020 (r366112) @@ -273,7 +273,6 @@ struct mbuf * ieee80211_ff_decap(struct ieee80211_node *ni, struct mbuf *m) { #define FF_LLC_SIZE (sizeof(struct ether_header) + sizeof(struct llc)) -#define MS(x,f) (((x) & f) >> f##_S) struct ieee80211vap *vap = ni->ni_vap; struct llc *llc; uint32_t ath; @@ -302,7 +301,7 @@ ieee80211_ff_decap(struct ieee80211_node *ni, struct m return m; m_adj(m, FF_LLC_SIZE); m_copydata(m, 0, sizeof(uint32_t), (caddr_t) &ath); - if (MS(ath, ATH_FF_PROTO) != ATH_FF_PROTO_L2TUNNEL) { + if (_IEEE80211_MASKSHIFT(ath, ATH_FF_PROTO) != ATH_FF_PROTO_L2TUNNEL) { IEEE80211_DISCARD_MAC(vap, IEEE80211_MSG_ANY, ni->ni_macaddr, "fast-frame", "unsupport tunnel protocol, header 0x%x", ath); @@ -351,7 +350,6 @@ ieee80211_ff_decap(struct ieee80211_node *ni, struct m } /* XXX verify framelen against mbuf contents */ return n; /* 2nd delivered by caller */ -#undef MS #undef FF_LLC_SIZE } Modified: head/sys/net80211/ieee80211_var.h ============================================================================== --- head/sys/net80211/ieee80211_var.h Thu Sep 24 10:42:28 2020 (r366111) +++ head/sys/net80211/ieee80211_var.h Thu Sep 24 10:57:39 2020 (r366112) @@ -735,9 +735,9 @@ MALLOC_DECLARE(M_80211_VAP); #define IEEE80211_COM_DETACHED 0x00000001 /* ieee80211_ifdetach called */ #define IEEE80211_COM_REF_ADD 0x00000002 /* add / remove reference */ -#define IEEE80211_COM_REF_M 0xfffffffe /* reference counter bits */ +#define IEEE80211_COM_REF 0xfffffffe /* reference counter bits */ #define IEEE80211_COM_REF_S 1 -#define IEEE80211_COM_REF_MAX (IEEE80211_COM_REF_M >> IEEE80211_COM_REF_S) +#define IEEE80211_COM_REF_MAX (IEEE80211_COM_REF >> IEEE80211_COM_REF_S) int ic_printf(struct ieee80211com *, const char *, ...) __printflike(2, 3); void ieee80211_ifattach(struct ieee80211com *); @@ -1012,6 +1012,10 @@ ieee80211_get_node_txpower(struct ieee80211_node *ni) "\13WME\14ACL\15WPA\16RADKEYS\17RADDUMP\20RADIUS\21DOT1XSM\22HWMP" \ "\23POWER\24STATE\25OUTPUT\26SCAN\27AUTH\30ASSOC\31NODE\32ELEMID" \ "\33XRATE\34INPUT\35CRYPTO\36DUPMPKTS\37DEBUG\04011N" + +/* Helper macros unified. */ +#define _IEEE80211_MASKSHIFT(_v, _f) (((_v) & _f) >> _f##_S) +#define _IEEE80211_SHIFTMASK(_v, _f) (((_v) << _f##_S) & _f) #ifdef IEEE80211_DEBUG #define ieee80211_msg(_vap, _m) ((_vap)->iv_debug & (_m)) Modified: head/sys/net80211/ieee80211_vht.c ============================================================================== --- head/sys/net80211/ieee80211_vht.c Thu Sep 24 10:42:28 2020 (r366111) +++ head/sys/net80211/ieee80211_vht.c Thu Sep 24 10:57:39 2020 (r366112) @@ -53,10 +53,6 @@ __FBSDID("$FreeBSD$"); #include <net80211/ieee80211_input.h> #include <net80211/ieee80211_vht.h> -/* define here, used throughout file */ -#define MS(_v, _f) (((_v) & _f) >> _f##_S) -#define SM(_v, _f) (((_v) << _f##_S) & _f) - #define ADDSHORT(frm, v) do { \ frm[0] = (v) & 0xff; \ frm[1] = (v) >> 8; \ @@ -207,9 +203,11 @@ ieee80211_vht_announce(struct ieee80211com *ic) /* Channel width */ ic_printf(ic, "[VHT] Channel Widths: 20MHz, 40MHz, 80MHz"); - if (MS(ic->ic_vhtcaps, IEEE80211_VHTCAP_SUPP_CHAN_WIDTH_MASK) >= 1) + if (_IEEE80211_MASKSHIFT(ic->ic_vhtcaps, + IEEE80211_VHTCAP_SUPP_CHAN_WIDTH_MASK) >= 1) printf(" 160MHz"); - if (MS(ic->ic_vhtcaps, IEEE80211_VHTCAP_SUPP_CHAN_WIDTH_MASK) == 2) + if (_IEEE80211_MASKSHIFT(ic->ic_vhtcaps, + IEEE80211_VHTCAP_SUPP_CHAN_WIDTH_MASK) == 2) printf(" 80+80MHz"); printf("\n"); @@ -376,18 +374,20 @@ ieee80211_vht_get_vhtcap_ie(struct ieee80211_node *ni, */ /* Limit MPDU size to the smaller of the two */ - val2 = val1 = MS(vap->iv_vhtcaps, IEEE80211_VHTCAP_MAX_MPDU_MASK); + val2 = val1 = _IEEE80211_MASKSHIFT(vap->iv_vhtcaps, + IEEE80211_VHTCAP_MAX_MPDU_MASK); if (opmode == 1) { - val2 = MS(ni->ni_vhtcap, IEEE80211_VHTCAP_MAX_MPDU_MASK); + val2 = _IEEE80211_MASKSHIFT(ni->ni_vhtcap, + IEEE80211_VHTCAP_MAX_MPDU_MASK); } val = MIN(val1, val2); - new_vhtcap |= SM(val, IEEE80211_VHTCAP_MAX_MPDU_MASK); + new_vhtcap |= _IEEE80211_SHIFTMASK(val, IEEE80211_VHTCAP_MAX_MPDU_MASK); /* Limit supp channel config */ - val2 = val1 = MS(vap->iv_vhtcaps, + val2 = val1 = _IEEE80211_MASKSHIFT(vap->iv_vhtcaps, IEEE80211_VHTCAP_SUPP_CHAN_WIDTH_MASK); if (opmode == 1) { - val2 = MS(ni->ni_vhtcap, + val2 = _IEEE80211_MASKSHIFT(ni->ni_vhtcap, IEEE80211_VHTCAP_SUPP_CHAN_WIDTH_MASK); } if ((val2 == 2) && @@ -397,31 +397,38 @@ ieee80211_vht_get_vhtcap_ie(struct ieee80211_node *ni, ((vap->iv_flags_vht & IEEE80211_FVHT_USEVHT160) == 0)) val2 = 0; val = MIN(val1, val2); - new_vhtcap |= SM(val, IEEE80211_VHTCAP_SUPP_CHAN_WIDTH_MASK); + new_vhtcap |= _IEEE80211_SHIFTMASK(val, + IEEE80211_VHTCAP_SUPP_CHAN_WIDTH_MASK); /* RX LDPC */ - val2 = val1 = MS(vap->iv_vhtcaps, IEEE80211_VHTCAP_RXLDPC); + val2 = val1 = _IEEE80211_MASKSHIFT(vap->iv_vhtcaps, + IEEE80211_VHTCAP_RXLDPC); if (opmode == 1) { - val2 = MS(ni->ni_vhtcap, IEEE80211_VHTCAP_RXLDPC); + val2 = _IEEE80211_MASKSHIFT(ni->ni_vhtcap, + IEEE80211_VHTCAP_RXLDPC); } val = MIN(val1, val2); - new_vhtcap |= SM(val, IEEE80211_VHTCAP_RXLDPC); + new_vhtcap |= _IEEE80211_SHIFTMASK(val, IEEE80211_VHTCAP_RXLDPC); /* Short-GI 80 */ - val2 = val1 = MS(vap->iv_vhtcaps, IEEE80211_VHTCAP_SHORT_GI_80); + val2 = val1 = _IEEE80211_MASKSHIFT(vap->iv_vhtcaps, + IEEE80211_VHTCAP_SHORT_GI_80); if (opmode == 1) { - val2 = MS(ni->ni_vhtcap, IEEE80211_VHTCAP_SHORT_GI_80); + val2 = _IEEE80211_MASKSHIFT(ni->ni_vhtcap, + IEEE80211_VHTCAP_SHORT_GI_80); } val = MIN(val1, val2); - new_vhtcap |= SM(val, IEEE80211_VHTCAP_SHORT_GI_80); + new_vhtcap |= _IEEE80211_SHIFTMASK(val, IEEE80211_VHTCAP_SHORT_GI_80); /* Short-GI 160 */ - val2 = val1 = MS(vap->iv_vhtcaps, IEEE80211_VHTCAP_SHORT_GI_160); + val2 = val1 = _IEEE80211_MASKSHIFT(vap->iv_vhtcaps, + IEEE80211_VHTCAP_SHORT_GI_160); if (opmode == 1) { - val2 = MS(ni->ni_vhtcap, IEEE80211_VHTCAP_SHORT_GI_160); + val2 = _IEEE80211_MASKSHIFT(ni->ni_vhtcap, + IEEE80211_VHTCAP_SHORT_GI_160); } val = MIN(val1, val2); - new_vhtcap |= SM(val, IEEE80211_VHTCAP_SHORT_GI_160); + new_vhtcap |= _IEEE80211_SHIFTMASK(val, IEEE80211_VHTCAP_SHORT_GI_160); /* * STBC is slightly more complicated. @@ -439,28 +446,32 @@ ieee80211_vht_get_vhtcap_ie(struct ieee80211_node *ni, */ /* TX STBC */ - val2 = val1 = MS(vap->iv_vhtcaps, IEEE80211_VHTCAP_TXSTBC); + val2 = val1 = _IEEE80211_MASKSHIFT(vap->iv_vhtcaps, + IEEE80211_VHTCAP_TXSTBC); if (opmode == 1) { /* STA mode - enable it only if node RXSTBC is non-zero */ - val2 = !! MS(ni->ni_vhtcap, IEEE80211_VHTCAP_RXSTBC_MASK); + val2 = !! _IEEE80211_MASKSHIFT(ni->ni_vhtcap, + IEEE80211_VHTCAP_RXSTBC_MASK); } val = MIN(val1, val2); /* XXX For now, use the 11n config flag */ if ((vap->iv_flags_ht & IEEE80211_FHT_STBC_TX) == 0) val = 0; - new_vhtcap |= SM(val, IEEE80211_VHTCAP_TXSTBC); + new_vhtcap |= _IEEE80211_SHIFTMASK(val, IEEE80211_VHTCAP_TXSTBC); /* RX STBC1..4 */ - val2 = val1 = MS(vap->iv_vhtcaps, IEEE80211_VHTCAP_RXSTBC_MASK); + val2 = val1 = _IEEE80211_MASKSHIFT(vap->iv_vhtcaps, + IEEE80211_VHTCAP_RXSTBC_MASK); if (opmode == 1) { /* STA mode - enable it only if node TXSTBC is non-zero */ - val2 = MS(ni->ni_vhtcap, IEEE80211_VHTCAP_TXSTBC); + val2 = _IEEE80211_MASKSHIFT(ni->ni_vhtcap, + IEEE80211_VHTCAP_TXSTBC); } val = MIN(val1, val2); /* XXX For now, use the 11n config flag */ if ((vap->iv_flags_ht & IEEE80211_FHT_STBC_RX) == 0) val = 0; - new_vhtcap |= SM(val, IEEE80211_VHTCAP_RXSTBC_MASK); + new_vhtcap |= _IEEE80211_SHIFTMASK(val, IEEE80211_VHTCAP_RXSTBC_MASK); /* * Finally - if RXSTBC is 0, then don't enable TXSTBC. @@ -480,115 +491,129 @@ ieee80211_vht_get_vhtcap_ie(struct ieee80211_node *ni, */ /* SU Beamformer capable */ - val2 = val1 = MS(vap->iv_vhtcaps, + val2 = val1 = _IEEE80211_MASKSHIFT(vap->iv_vhtcaps, IEEE80211_VHTCAP_SU_BEAMFORMER_CAPABLE); if (opmode == 1) { - val2 = MS(ni->ni_vhtcap, + val2 = _IEEE80211_MASKSHIFT(ni->ni_vhtcap, IEEE80211_VHTCAP_SU_BEAMFORMER_CAPABLE); } val = MIN(val1, val2); - new_vhtcap |= SM(val, IEEE80211_VHTCAP_SU_BEAMFORMER_CAPABLE); + new_vhtcap |= _IEEE80211_SHIFTMASK(val, + IEEE80211_VHTCAP_SU_BEAMFORMER_CAPABLE); /* SU Beamformee capable */ - val2 = val1 = MS(vap->iv_vhtcaps, + val2 = val1 = _IEEE80211_MASKSHIFT(vap->iv_vhtcaps, IEEE80211_VHTCAP_SU_BEAMFORMEE_CAPABLE); if (opmode == 1) { - val2 = MS(ni->ni_vhtcap, + val2 = _IEEE80211_MASKSHIFT(ni->ni_vhtcap, IEEE80211_VHTCAP_SU_BEAMFORMEE_CAPABLE); } val = MIN(val1, val2); - new_vhtcap |= SM(val, IEEE80211_VHTCAP_SU_BEAMFORMEE_CAPABLE); + new_vhtcap |= _IEEE80211_SHIFTMASK(val, + IEEE80211_VHTCAP_SU_BEAMFORMEE_CAPABLE); /* Beamformee STS capability - only if SU beamformee capable */ - val2 = val1 = MS(vap->iv_vhtcaps, IEEE80211_VHTCAP_BEAMFORMEE_STS_MASK); + val2 = val1 = _IEEE80211_MASKSHIFT(vap->iv_vhtcaps, + IEEE80211_VHTCAP_BEAMFORMEE_STS_MASK); if (opmode == 1) { - val2 = MS(ni->ni_vhtcap, IEEE80211_VHTCAP_BEAMFORMEE_STS_MASK); + val2 = _IEEE80211_MASKSHIFT(ni->ni_vhtcap, + IEEE80211_VHTCAP_BEAMFORMEE_STS_MASK); } *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** _______________________________________________ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"