Lines Matching +full:mode +full:- +full:flag

1 /*-
2 * SPDX-License-Identifier: BSD-2-Clause
5 * Copyright (c) 2002-2009 Sam Leffler, Errno Consulting
94 static void ieee80211_syncflag_locked(struct ieee80211com *ic, int flag);
95 static void ieee80211_syncflag_ht_locked(struct ieee80211com *ic, int flag);
96 static void ieee80211_syncflag_ext_locked(struct ieee80211com *ic, int flag);
97 static void ieee80211_syncflag_vht_locked(struct ieee80211com *ic, int flag);
119 /* NB: OFDM rates are handled specially based on mode */
135 if (ic->ic_sup_rates[m].rs_nrates == 0) \
136 ic->ic_sup_rates[m] = def; \
141 KASSERT(0 < ic->ic_nchans && ic->ic_nchans <= IEEE80211_CHAN_MAX,
142 ("invalid number of channels specified: %u", ic->ic_nchans));
143 memset(ic->ic_chan_avail, 0, sizeof(ic->ic_chan_avail));
144 memset(ic->ic_modecaps, 0, sizeof(ic->ic_modecaps));
145 setbit(ic->ic_modecaps, IEEE80211_MODE_AUTO);
146 for (i = 0; i < ic->ic_nchans; i++) {
147 c = &ic->ic_channels[i];
148 KASSERT(c->ic_flags != 0, ("channel with no flags"));
155 if (c->ic_ieee == 0)
156 c->ic_ieee = ieee80211_mhz2ieee(c->ic_freq,c->ic_flags);
162 if (IEEE80211_IS_CHAN_HT40(c) && c->ic_extieee == 0)
163 c->ic_extieee = ieee80211_mhz2ieee(c->ic_freq +
164 (IEEE80211_IS_CHAN_HT40U(c) ? 20 : -20),
165 c->ic_flags);
175 if (c->ic_maxpower == 0)
176 c->ic_maxpower = 2*c->ic_maxregpower;
177 setbit(ic->ic_chan_avail, c->ic_ieee);
179 * Identify mode capabilities.
182 setbit(ic->ic_modecaps, IEEE80211_MODE_11A);
184 setbit(ic->ic_modecaps, IEEE80211_MODE_11B);
186 setbit(ic->ic_modecaps, IEEE80211_MODE_11G);
188 setbit(ic->ic_modecaps, IEEE80211_MODE_FH);
190 setbit(ic->ic_modecaps, IEEE80211_MODE_TURBO_A);
192 setbit(ic->ic_modecaps, IEEE80211_MODE_TURBO_G);
194 setbit(ic->ic_modecaps, IEEE80211_MODE_STURBO_A);
196 setbit(ic->ic_modecaps, IEEE80211_MODE_HALF);
198 setbit(ic->ic_modecaps, IEEE80211_MODE_QUARTER);
200 setbit(ic->ic_modecaps, IEEE80211_MODE_11NA);
202 setbit(ic->ic_modecaps, IEEE80211_MODE_11NG);
204 setbit(ic->ic_modecaps, IEEE80211_MODE_VHT_5GHZ);
206 setbit(ic->ic_modecaps, IEEE80211_MODE_VHT_2GHZ);
209 memcpy(ic->ic_chan_active, ic->ic_chan_avail,
210 sizeof(ic->ic_chan_avail));
213 ieee80211_sort_channels(ic->ic_channels, ic->ic_nchans);
216 ic->ic_bsschan = IEEE80211_CHAN_ANYC;
217 ic->ic_prevchan = NULL;
218 ic->ic_csa_newchan = NULL;
220 ic->ic_curchan = &ic->ic_channels[0];
221 ic->ic_rt = ieee80211_get_ratetable(ic->ic_curchan);
223 /* fillin well-known rate sets if driver has not specified */
241 if (ic->ic_rxstream == 0)
242 ic->ic_rxstream = 2;
243 if (ic->ic_txstream == 0)
244 ic->ic_txstream = 2;
249 * Set auto mode to reset active channel state and any desired channel.
266 ic_printf(ic, "need promiscuous mode update callback\n");
282 retval = printf("%s: ", ic->ic_name);
309 sbuf_printf(&sb, "%s%s", sp, ic->ic_name);
330 IEEE80211_LOCK_INIT(ic, ic->ic_name);
331 IEEE80211_TX_LOCK_INIT(ic, ic->ic_name);
332 TAILQ_INIT(&ic->ic_vaps);
335 ic->ic_tq = taskqueue_create("ic_taskq",
337 taskqueue_thread_enqueue, &ic->ic_tq);
338 taskqueue_start_threads(&ic->ic_tq, 1, PI_NET, "%s net80211 taskq",
339 ic->ic_name);
340 ic->ic_ierrors = counter_u64_alloc(IEEE80211_M_WAITOK);
341 ic->ic_oerrors = counter_u64_alloc(IEEE80211_M_WAITOK);
349 ic->ic_update_mcast = null_update_mcast;
350 ic->ic_update_promisc = null_update_promisc;
351 ic->ic_update_chw = null_update_chw;
353 ic->ic_hash_key = arc4random();
354 ic->ic_bintval = IEEE80211_BINTVAL_DEFAULT;
355 ic->ic_lintval = ic->ic_bintval;
356 ic->ic_txpowlimit = IEEE80211_TXPOWER_MAX;
395 if (ic->ic_tq == NULL)
402 taskqueue_drain(taskqueue_thread, &ic->ic_restart_task);
408 while ((vap = TAILQ_FIRST(&ic->ic_vaps)) != NULL) {
429 counter_u64_free(ic->ic_ierrors);
430 counter_u64_free(ic->ic_oerrors);
432 taskqueue_free(ic->ic_tq);
478 if (strcmp(ic->ic_name, name) == 0)
500 * require re-initialization of the 802.11 state machine (e.g
502 * should cause the driver to re-initialize the device. Drivers
524 vap->iv_def_txkey = kid;
533 struct ieee80211vap *vap = ifp->if_softc;
534 struct ieee80211com *ic = vap->iv_ic;
540 rv += counter_u64_fetch(ic->ic_oerrors);
543 rv += counter_u64_fetch(ic->ic_ierrors);
566 ifp->if_softc = vap; /* back pointer */
567 ifp->if_flags = IFF_SIMPLEX | IFF_BROADCAST | IFF_MULTICAST;
568 ifp->if_transmit = ieee80211_vap_transmit;
569 ifp->if_qflush = ieee80211_vap_qflush;
570 ifp->if_ioctl = ieee80211_ioctl;
571 ifp->if_init = ieee80211_init;
572 ifp->if_get_counter = ieee80211_get_counter;
574 vap->iv_ifp = ifp;
575 vap->iv_ic = ic;
576 vap->iv_flags = ic->ic_flags; /* propagate common flags */
577 vap->iv_flags_ext = ic->ic_flags_ext;
578 vap->iv_flags_ven = ic->ic_flags_ven;
579 vap->iv_caps = ic->ic_caps &~ IEEE80211_C_OPMODE;
581 /* 11n capabilities - XXX methodize */
582 vap->iv_htcaps = ic->ic_htcaps;
583 vap->iv_htextcaps = ic->ic_htextcaps;
585 /* 11ac capabilities - XXX methodize */
586 vap->iv_vht_cap.vht_cap_info = ic->ic_vht_cap.vht_cap_info;
587 vap->iv_vhtextcaps = ic->ic_vhtextcaps;
589 vap->iv_opmode = opmode;
590 vap->iv_caps |= ieee80211_opcap[opmode];
591 IEEE80211_ADDR_COPY(vap->iv_myaddr, ic->ic_macaddr);
597 * For non-legacy operation the station must associate
602 IEEE80211_ADDR_COPY(vap->iv_des_bssid, bssid);
603 vap->iv_flags |= IEEE80211_F_DESBSSID;
605 vap->iv_flags_ext |= IEEE80211_FEXT_WDSLEGACY;
611 KASSERT(ic->ic_caps & IEEE80211_C_TDMA,
612 ("not TDMA capable, ic_caps 0x%x", ic->ic_caps));
618 vap->iv_caps |= IEEE80211_C_TDMA;
625 /* auto-enable s/w beacon miss support */
627 vap->iv_flags_ext |= IEEE80211_FEXT_SWBMISS;
628 /* auto-generated or user supplied MAC address */
630 vap->iv_flags_ext |= IEEE80211_FEXT_UNIQMAC;
635 if (vap->iv_caps & IEEE80211_C_WME)
636 vap->iv_flags |= IEEE80211_F_WME;
637 if (vap->iv_caps & IEEE80211_C_BURST)
638 vap->iv_flags |= IEEE80211_F_BURST;
639 /* NB: bg scanning only makes sense for station mode right now */
640 if (vap->iv_opmode == IEEE80211_M_STA &&
641 (vap->iv_caps & IEEE80211_C_BGSCAN))
642 vap->iv_flags |= IEEE80211_F_BGSCAN;
643 vap->iv_flags |= IEEE80211_F_DOTH; /* XXX no cap, just ena */
644 /* NB: DFS support only makes sense for ap mode right now */
645 if (vap->iv_opmode == IEEE80211_M_HOSTAP &&
646 (vap->iv_caps & IEEE80211_C_DFS))
647 vap->iv_flags_ext |= IEEE80211_FEXT_DFS;
648 /* NB: only flip on U-APSD for hostap/sta for now */
649 if ((vap->iv_opmode == IEEE80211_M_STA)
650 || (vap->iv_opmode == IEEE80211_M_HOSTAP)) {
651 if (vap->iv_caps & IEEE80211_C_UAPSD)
652 vap->iv_flags_ext |= IEEE80211_FEXT_UAPSD;
655 vap->iv_des_chan = IEEE80211_CHAN_ANYC; /* any channel is ok */
656 vap->iv_bmissthreshold = IEEE80211_HWBMISS_DEFAULT;
657 vap->iv_dtim_period = IEEE80211_DTIM_DEFAULT;
662 vap->iv_reset = default_reset;
668 vap->iv_update_deftxkey = default_update_deftxkey;
698 struct ifnet *ifp = vap->iv_ifp;
699 struct ieee80211com *ic = vap->iv_ic;
705 __func__, ieee80211_opmode_name[vap->iv_opmode],
706 ic->ic_name, vap->iv_flags, vap->iv_flags_ext);
715 maxrate = ieee80211_media_setup(ic, &vap->iv_media, vap->iv_caps,
716 vap->iv_opmode == IEEE80211_M_STA, media_change, media_stat);
718 /* NB: strip explicit mode; we're actually in autoselect */
719 ifmedia_set(&vap->iv_media,
722 ifp->if_baudrate = IF_Mbps(maxrate);
725 IEEE80211_ADDR_COPY(vap->iv_myaddr, IF_LLADDR(ifp));
727 vap->iv_output = ifp->if_output;
728 ifp->if_output = ieee80211_output;
732 TAILQ_INSERT_TAIL(&ic->ic_vaps, vap, iv_next);
763 struct ieee80211com *ic = vap->iv_ic;
764 struct ifnet *ifp = vap->iv_ifp;
767 CURVNET_SET(ifp->if_vnet);
770 __func__, ieee80211_opmode_name[vap->iv_opmode], ic->ic_name);
781 ieee80211_draintask(ic, &vap->iv_nstate_task[i]);
782 ieee80211_draintask(ic, &vap->iv_swbmiss_task);
783 ieee80211_draintask(ic, &vap->iv_wme_task);
784 ieee80211_draintask(ic, &ic->ic_parent_task);
786 /* XXX band-aid until ifnet handles this for us */
787 taskqueue_drain(taskqueue_swi, &ifp->if_linktask);
790 KASSERT(vap->iv_state == IEEE80211_S_INIT , ("vap still running"));
791 TAILQ_REMOVE(&ic->ic_vaps, vap, iv_next);
811 if (vap->iv_ifflags & IFF_PROMISC)
813 if (vap->iv_ifflags & IFF_ALLMULTI)
817 ifmedia_removeall(&vap->iv_media);
846 struct ieee80211com *ic = vap->iv_ic;
851 if (++ic->ic_promisc == 1)
852 ieee80211_runtask(ic, &ic->ic_promisc_task);
854 KASSERT(ic->ic_promisc > 0, ("%s: ic %p not promisc",
856 if (--ic->ic_promisc == 0)
857 ieee80211_runtask(ic, &ic->ic_promisc_task);
868 struct ieee80211com *ic = vap->iv_ic;
873 if (++ic->ic_allmulti == 1)
874 ieee80211_runtask(ic, &ic->ic_mcast_task);
876 KASSERT(ic->ic_allmulti > 0, ("%s: ic %p not allmulti",
878 if (--ic->ic_allmulti == 0)
879 ieee80211_runtask(ic, &ic->ic_mcast_task);
884 * Synchronize flag bit state in the com structure
889 ieee80211_syncflag_locked(struct ieee80211com *ic, int flag)
897 TAILQ_FOREACH(vap, &ic->ic_vaps, iv_next)
898 if (vap->iv_flags & flag) {
903 ic->ic_flags |= flag;
905 ic->ic_flags &= ~flag;
909 ieee80211_syncflag(struct ieee80211vap *vap, int flag)
911 struct ieee80211com *ic = vap->iv_ic;
914 if (flag < 0) {
915 flag = -flag;
916 vap->iv_flags &= ~flag;
918 vap->iv_flags |= flag;
919 ieee80211_syncflag_locked(ic, flag);
929 ieee80211_syncflag_ht_locked(struct ieee80211com *ic, int flag)
937 TAILQ_FOREACH(vap, &ic->ic_vaps, iv_next)
938 if (vap->iv_flags_ht & flag) {
943 ic->ic_flags_ht |= flag;
945 ic->ic_flags_ht &= ~flag;
949 ieee80211_syncflag_ht(struct ieee80211vap *vap, int flag)
951 struct ieee80211com *ic = vap->iv_ic;
954 if (flag < 0) {
955 flag = -flag;
956 vap->iv_flags_ht &= ~flag;
958 vap->iv_flags_ht |= flag;
959 ieee80211_syncflag_ht_locked(ic, flag);
969 ieee80211_syncflag_vht_locked(struct ieee80211com *ic, int flag)
977 TAILQ_FOREACH(vap, &ic->ic_vaps, iv_next)
978 if (vap->iv_vht_flags & flag) {
983 ic->ic_vht_flags |= flag;
985 ic->ic_vht_flags &= ~flag;
989 ieee80211_syncflag_vht(struct ieee80211vap *vap, int flag)
991 struct ieee80211com *ic = vap->iv_ic;
994 if (flag < 0) {
995 flag = -flag;
996 vap->iv_vht_flags &= ~flag;
998 vap->iv_vht_flags |= flag;
999 ieee80211_syncflag_vht_locked(ic, flag);
1009 ieee80211_syncflag_ext_locked(struct ieee80211com *ic, int flag)
1017 TAILQ_FOREACH(vap, &ic->ic_vaps, iv_next)
1018 if (vap->iv_flags_ext & flag) {
1023 ic->ic_flags_ext |= flag;
1025 ic->ic_flags_ext &= ~flag;
1029 ieee80211_syncflag_ext(struct ieee80211vap *vap, int flag)
1031 struct ieee80211com *ic = vap->iv_ic;
1034 if (flag < 0) {
1035 flag = -flag;
1036 vap->iv_flags_ext &= ~flag;
1038 vap->iv_flags_ext |= flag;
1039 ieee80211_syncflag_ext_locked(ic, flag);
1054 return (freq - 906*10) / 5;
1060 return 37 + ((freq * 10) + ((freq % 5) == 2 ? 5 : 0) - 49400) / 5;
1076 return ((int) freq - 2407) / 5;
1078 return 15 + ((freq - 2512) / 20);
1084 return (freq - 4000) / 5;
1086 return (freq - 5000) / 5;
1093 return ((int) freq - 2407) / 5;
1099 return (freq - 4000) / 5;
1101 return 15 + ((freq - 2512) / 20);
1103 return (freq - 5000) / 5;
1118 return (c == IEEE80211_CHAN_ANYC ? IEEE80211_CHAN_ANY : c->ic_ieee);
1135 return 2512 + ((chan-15)*20);
1138 chan -= 37;
1146 if (chan < 14) /* 0-13 */
1148 if (chan < 27) /* 15-26 */
1149 return 2512 + ((chan-15)*20);
1159 * IEEE Std 802.11-2012, page 1738, subclause 20.3.15.4:
1160 * "the secondary channel number shall be 'N + [1,-1] * 4'
1162 if (c->ic_flags & IEEE80211_CHAN_HT40U)
1163 c->ic_extieee = c->ic_ieee + 4;
1164 else if (c->ic_flags & IEEE80211_CHAN_HT40D)
1165 c->ic_extieee = c->ic_ieee - 4;
1167 c->ic_extieee = 0;
1173 * This for now uses a hard-coded list of 80MHz wide channels.
1181 * This is all likely very very wrong - both the regulatory code
1220 __func__, c->ic_ieee, c->ic_flags);
1225 if (c->ic_freq >= vht160_chan_ranges[i].freq_start &&
1226 c->ic_freq < vht160_chan_ranges[i].freq_end) {
1230 c->ic_vht_ch_freq1 =
1231 ieee80211_mhz2ieee(midpoint, c->ic_flags);
1232 c->ic_vht_ch_freq2 = 0;
1235 __func__, c->ic_ieee, c->ic_freq, midpoint,
1236 c->ic_vht_ch_freq1, c->ic_vht_ch_freq2);
1246 if (c->ic_freq >= vht80_chan_ranges[i].freq_start &&
1247 c->ic_freq < vht80_chan_ranges[i].freq_end) {
1251 c->ic_vht_ch_freq1 =
1252 ieee80211_mhz2ieee(midpoint, c->ic_flags);
1253 c->ic_vht_ch_freq2 = 0;
1256 __func__, c->ic_ieee, c->ic_freq, midpoint,
1257 c->ic_vht_ch_freq1, c->ic_vht_ch_freq2);
1267 c->ic_vht_ch_freq1 = c->ic_ieee + 2;
1269 c->ic_vht_ch_freq1 = c->ic_ieee - 2;
1276 c->ic_vht_ch_freq1 = c->ic_ieee;
1281 __func__, c->ic_ieee, c->ic_flags);
1333 c->ic_ieee = ieee;
1334 c->ic_freq = freq != 0 ? freq : ieee80211_ieee2mhz(ieee, flags);
1335 c->ic_maxregpower = maxregpower;
1336 c->ic_maxpower = 2 * maxregpower;
1337 c->ic_flags = flags;
1338 c->ic_vht_ch_freq1 = 0;
1339 c->ic_vht_ch_freq2 = 0;
1363 c[0] = c[-1];
1364 c->ic_flags = flags;
1365 c->ic_vht_ch_freq1 = 0;
1366 c->ic_vht_ch_freq2 = 0;
1374 * XXX VHT-2GHz
1497 KASSERT(flags[0] != 0, ("%s: no correct mode provided\n", __func__));
1530 if (c->ic_freq == freq &&
1531 (c->ic_flags & IEEE80211_CHAN_ALLTURBO) == flags)
1565 error = addchan(chans, maxchans, nchans, cent->ic_ieee, cent->ic_freq,
1570 error = addchan(chans, maxchans, nchans, extc->ic_ieee, extc->ic_freq,
1583 return (c->ic_freq);
1603 * VHT - use the pre-calculated centre frequency
1607 return (ieee80211_ieee2mhz(c->ic_vht_ch_freq1, c->ic_flags));
1610 return (c->ic_freq + 10);
1613 return (c->ic_freq - 10);
1616 return (c->ic_freq);
1626 if (IEEE80211_IS_CHAN_VHT(c) && (c->ic_vht_ch_freq2 != 0))
1627 return (ieee80211_ieee2mhz(c->ic_vht_ch_freq2, c->ic_flags));
1698 freq - 20 !=
1699 ieee80211_ieee2mhz(ieee[i] - 4, flags[j]))
1713 if (i == nieee - 1 ||
1714 ieee[i] + 4 > ieee[nieee - 1] ||
1743 KASSERT(flags[0] != 0, ("%s: no correct mode provided\n", __func__));
1765 * XXX-BZ with HT and VHT there is no 1:1 mapping anymore. Review all
1771 KASSERT(flags[0] != 0, ("%s: no correct mode provided\n", __func__));
1779 * channels--as happens with dynamic turbo.
1787 c = ic->ic_prevchan;
1788 if (c != NULL && c->ic_freq == freq &&
1789 (c->ic_flags & IEEE80211_CHAN_ALLTURBO) == flags)
1792 return (findchannel(ic->ic_channels, ic->ic_nchans, freq, flags));
1798 * channels--as happens with dynamic turbo.
1807 c = ic->ic_prevchan;
1808 if (c != NULL && c->ic_ieee == ieee &&
1809 (c->ic_flags & IEEE80211_CHAN_ALLTURBO) == flags)
1812 for (i = 0; i < ic->ic_nchans; i++) {
1813 c = &ic->ic_channels[i];
1814 if (c->ic_ieee == ieee &&
1815 (c->ic_flags & IEEE80211_CHAN_ALLTURBO) == flags)
1830 * like. It also doesn't know about legacy-turbog and
1831 * legacy-turbo modes, which some offload NICs actually
1843 struct ieee80211com *ic = vap->iv_ic;
1855 if ((rxs->r_flags & IEEE80211_R_FREQ) == 0)
1857 if ((rxs->r_flags & IEEE80211_R_IEEE) == 0)
1859 if ((rxs->r_flags & IEEE80211_R_BAND) == 0)
1871 switch (rxs->c_band) {
1879 if (rxs->c_freq < 3000) {
1888 c = ieee80211_find_channel(ic, rxs->c_freq, flags);
1892 __func__, (int) rxs->c_freq, (int) rxs->c_ieee, flags, c);
1898 addmedia(struct ifmedia *media, int caps, int addsta, int mode, int mword)
1921 mopt = mopts[mode];
1923 ADD(ic, mword, mopt); /* STA mode has no cap */
1949 enum ieee80211_phymode mode;
1962 for (mode = IEEE80211_MODE_AUTO; mode < IEEE80211_MODE_11NA; mode++) {
1963 if (isclr(ic->ic_modecaps, mode))
1965 addmedia(media, caps, addsta, mode, IFM_AUTO);
1966 if (mode == IEEE80211_MODE_AUTO)
1968 rs = &ic->ic_sup_rates[mode];
1969 for (i = 0; i < rs->rs_nrates; i++) {
1970 rate = rs->rs_rates[i];
1971 mword = ieee80211_rate2media(ic, rate, mode);
1974 addmedia(media, caps, addsta, mode, mword);
2007 for (; mode <= IEEE80211_MODE_11NG; mode++) {
2008 if (isclr(ic->ic_modecaps, mode))
2010 addmedia(media, caps, addsta, mode, IFM_AUTO);
2011 addmedia(media, caps, addsta, mode, IFM_IEEE80211_MCS);
2013 if (isset(ic->ic_modecaps, IEEE80211_MODE_11NA) ||
2014 isset(ic->ic_modecaps, IEEE80211_MODE_11NG)) {
2017 i = ic->ic_txstream * 8 - 1;
2018 if ((ic->ic_htcaps & IEEE80211_HTCAP_CHWIDTH40) &&
2019 (ic->ic_htcaps & IEEE80211_HTCAP_SHORTGI40))
2021 else if ((ic->ic_htcaps & IEEE80211_HTCAP_CHWIDTH40))
2023 else if ((ic->ic_htcaps & IEEE80211_HTCAP_SHORTGI20))
2033 * XXX-BZ skip "VHT_2GHZ" for now.
2035 for (mode = IEEE80211_MODE_VHT_5GHZ; mode <= IEEE80211_MODE_VHT_5GHZ;
2036 mode++) {
2037 if (isclr(ic->ic_modecaps, mode))
2039 addmedia(media, caps, addsta, mode, IFM_AUTO);
2040 addmedia(media, caps, addsta, mode, IFM_IEEE80211_VHT);
2042 if (isset(ic->ic_modecaps, IEEE80211_MODE_VHT_5GHZ)) {
2057 return &ic->ic_sup_rates[ieee80211_chan2mode(c)];
2065 return &ic->ic_sup_htrates;
2072 enum ieee80211_phymode mode;
2076 for (mode = IEEE80211_MODE_AUTO+1; mode < IEEE80211_MODE_11NA; mode++) {
2077 if (isclr(ic->ic_modecaps, mode))
2079 ic_printf(ic, "%s rates: ", ieee80211_phymode_name[mode]);
2080 rs = &ic->ic_sup_rates[mode];
2081 for (i = 0; i < rs->rs_nrates; i++) {
2082 mword = ieee80211_rate2media(ic, rs->rs_rates[i], mode);
2103 for (i = 0; i < ic->ic_nchans; i++) {
2104 c = &ic->ic_channels[i];
2130 , c->ic_ieee, c->ic_freq, type
2133 IEEE80211_IS_CHAN_HT40D(c) ? '-' : ' '
2134 , c->ic_maxregpower
2135 , c->ic_minpower / 2, c->ic_minpower & 1 ? 5 : 0
2136 , c->ic_maxpower / 2, c->ic_maxpower & 1 ? 5 : 0
2142 media2mode(const struct ifmedia_entry *ime, uint32_t flags, uint16_t *mode)
2144 switch (IFM_MODE(ime->ifm_media)) {
2146 *mode = IEEE80211_MODE_11A;
2149 *mode = IEEE80211_MODE_11B;
2152 *mode = IEEE80211_MODE_11G;
2155 *mode = IEEE80211_MODE_FH;
2158 *mode = IEEE80211_MODE_11NA;
2161 *mode = IEEE80211_MODE_11NG;
2164 *mode = IEEE80211_MODE_VHT_2GHZ;
2167 *mode = IEEE80211_MODE_VHT_5GHZ;
2170 *mode = IEEE80211_MODE_AUTO;
2176 * Turbo mode is an ``option''.
2179 if (ime->ifm_media & IFM_IEEE80211_TURBO) {
2180 if (*mode == IEEE80211_MODE_11A) {
2182 *mode = IEEE80211_MODE_TURBO_A;
2184 *mode = IEEE80211_MODE_STURBO_A;
2185 } else if (*mode == IEEE80211_MODE_11G)
2186 *mode = IEEE80211_MODE_TURBO_G;
2190 /* XXX HT40 +/- */
2200 struct ieee80211vap *vap = ifp->if_softc;
2201 struct ifmedia_entry *ime = vap->iv_media.ifm_cur;
2204 if (!media2mode(ime, vap->iv_flags, &newmode))
2206 if (vap->iv_des_mode != newmode) {
2207 vap->iv_des_mode = newmode;
2215 * from the operating mode and channel state.
2278 struct ieee80211vap *vap = ifp->if_softc;
2279 struct ieee80211com *ic = vap->iv_ic;
2280 enum ieee80211_phymode mode;
2282 imr->ifm_status = IFM_AVALID;
2284 * NB: use the current channel's mode to lock down a xmit
2288 if (vap->iv_state == IEEE80211_S_RUN ||
2289 vap->iv_state == IEEE80211_S_SLEEP) {
2290 imr->ifm_status |= IFM_ACTIVE;
2291 mode = ieee80211_chan2mode(ic->ic_curchan);
2293 mode = IEEE80211_MODE_AUTO;
2294 imr->ifm_active = media_status(vap->iv_opmode, ic->ic_curchan);
2298 if (vap->iv_txparms[mode].ucastrate != IEEE80211_FIXED_RATE_NONE) {
2302 imr->ifm_active |= ieee80211_rate2media(ic,
2303 vap->iv_txparms[mode].ucastrate, mode);
2304 } else if (vap->iv_opmode == IEEE80211_M_STA) {
2306 * In station mode report the current transmit rate.
2308 imr->ifm_active |= ieee80211_rate2media(ic,
2309 vap->iv_bss->ni_txrate, mode);
2311 imr->ifm_active |= IFM_AUTO;
2312 if (imr->ifm_status & IFM_ACTIVE)
2313 imr->ifm_current = imr->ifm_active;
2317 * Set the current phy mode and recalculate the active channel
2318 * set based on the available channels for this mode. Also
2320 * inappropriate for this mode.
2323 ieee80211_setmode(struct ieee80211com *ic, enum ieee80211_phymode mode)
2331 if (mode == IEEE80211_MODE_11G || mode == IEEE80211_MODE_11B)
2332 ieee80211_setbasicrates(&ic->ic_sup_rates[mode], mode);
2334 ic->ic_curmode = mode;
2341 * Return the phy mode for with the specified channel.
2375 printf("%s: cannot map channel to mode; freq %u flags 0x%x\n",
2376 __func__, chan->ic_freq, chan->ic_flags);
2381 u_int match; /* rate + mode */
2402 ieee80211_rate2media(struct ieee80211com *ic, int rate, enum ieee80211_phymode mode)
2538 if (mode == IEEE80211_MODE_VHT_5GHZ) {
2545 } else if (mode == IEEE80211_MODE_11NA) {
2552 } else if (mode == IEEE80211_MODE_11NG) {
2562 switch (mode) {
2579 if (ic != NULL && ic->ic_phytype == IEEE80211_T_FH)
2600 -1, /* IFM_AUTO */
2624 -1, /* IFM_IEEE80211_MCS */
2625 -1, /* IFM_IEEE80211_VHT */
2637 a -= b; a -= c; a ^= (c >> 13); \
2638 b -= c; b -= a; b ^= (a << 8); \
2639 c -= a; c -= b; c ^= (b >> 13); \
2640 a -= b; a -= c; a ^= (c >> 12); \
2641 b -= c; b -= a; b ^= (a << 16); \
2642 c -= a; c -= b; c ^= (b >> 5); \
2643 a -= b; a -= c; a ^= (c >> 3); \
2644 b -= c; b -= a; b ^= (a << 10); \
2645 c -= a; c -= b; c ^= (b >> 15); \
2652 uint32_t a = 0x9e3779b9, b = 0x9e3779b9, c = ic->ic_hash_key;
2701 return (&vap->iv_nw_keys[0] <= key &&
2702 key < &vap->iv_nw_keys[IEEE80211_WEP_NKID]);
2713 * This is a short-cut for now; eventually we will need