Lines Matching +full:channel +full:- +full:11
1 /*-
2 * SPDX-License-Identifier: BSD-2-Clause
5 * Copyright (c) 2002-2009 Sam Leffler, Errno Consulting
64 [IEEE80211_MODE_11A] = "11a",
65 [IEEE80211_MODE_11B] = "11b",
66 [IEEE80211_MODE_11G] = "11g",
73 [IEEE80211_MODE_11NA] = "11na",
74 [IEEE80211_MODE_11NG] = "11ng",
75 [IEEE80211_MODE_VHT_2GHZ] = "11acg",
76 [IEEE80211_MODE_VHT_5GHZ] = "11ac",
118 { 4, { B(2), B(4), B(11), B(22) } };
121 { 12, { B(2), B(4), B(11), B(22), 12, 18, 24, 36, 48, 72, 96, 108 } };
127 * Fill in 802.11 available channel set, mark
129 * a default channel if not already specified.
135 if (ic->ic_sup_rates[m].rs_nrates == 0) \ in ieee80211_chan_init()
136 ic->ic_sup_rates[m] = def; \ in ieee80211_chan_init()
141 KASSERT(0 < ic->ic_nchans && ic->ic_nchans <= IEEE80211_CHAN_MAX, in ieee80211_chan_init()
142 ("invalid number of channels specified: %u", ic->ic_nchans)); in ieee80211_chan_init()
143 memset(ic->ic_chan_avail, 0, sizeof(ic->ic_chan_avail)); in ieee80211_chan_init()
144 memset(ic->ic_modecaps, 0, sizeof(ic->ic_modecaps)); in ieee80211_chan_init()
145 setbit(ic->ic_modecaps, IEEE80211_MODE_AUTO); in ieee80211_chan_init()
146 for (i = 0; i < ic->ic_nchans; i++) { in ieee80211_chan_init()
147 c = &ic->ic_channels[i]; in ieee80211_chan_init()
148 KASSERT(c->ic_flags != 0, ("channel with no flags")); in ieee80211_chan_init()
151 * in IEEE channel #'s if not already calculated. Note this in ieee80211_chan_init()
155 if (c->ic_ieee == 0) in ieee80211_chan_init()
156 c->ic_ieee = ieee80211_mhz2ieee(c->ic_freq,c->ic_flags); in ieee80211_chan_init()
162 if (IEEE80211_IS_CHAN_HT40(c) && c->ic_extieee == 0) in ieee80211_chan_init()
163 c->ic_extieee = ieee80211_mhz2ieee(c->ic_freq + in ieee80211_chan_init()
164 (IEEE80211_IS_CHAN_HT40U(c) ? 20 : -20), in ieee80211_chan_init()
165 c->ic_flags); in ieee80211_chan_init()
175 if (c->ic_maxpower == 0) in ieee80211_chan_init()
176 c->ic_maxpower = 2*c->ic_maxregpower; in ieee80211_chan_init()
177 setbit(ic->ic_chan_avail, c->ic_ieee); in ieee80211_chan_init()
182 setbit(ic->ic_modecaps, IEEE80211_MODE_11A); in ieee80211_chan_init()
184 setbit(ic->ic_modecaps, IEEE80211_MODE_11B); in ieee80211_chan_init()
186 setbit(ic->ic_modecaps, IEEE80211_MODE_11G); in ieee80211_chan_init()
188 setbit(ic->ic_modecaps, IEEE80211_MODE_FH); in ieee80211_chan_init()
190 setbit(ic->ic_modecaps, IEEE80211_MODE_TURBO_A); in ieee80211_chan_init()
192 setbit(ic->ic_modecaps, IEEE80211_MODE_TURBO_G); in ieee80211_chan_init()
194 setbit(ic->ic_modecaps, IEEE80211_MODE_STURBO_A); in ieee80211_chan_init()
196 setbit(ic->ic_modecaps, IEEE80211_MODE_HALF); in ieee80211_chan_init()
198 setbit(ic->ic_modecaps, IEEE80211_MODE_QUARTER); in ieee80211_chan_init()
200 setbit(ic->ic_modecaps, IEEE80211_MODE_11NA); in ieee80211_chan_init()
202 setbit(ic->ic_modecaps, IEEE80211_MODE_11NG); in ieee80211_chan_init()
204 setbit(ic->ic_modecaps, IEEE80211_MODE_VHT_5GHZ); in ieee80211_chan_init()
206 setbit(ic->ic_modecaps, IEEE80211_MODE_VHT_2GHZ); in ieee80211_chan_init()
209 memcpy(ic->ic_chan_active, ic->ic_chan_avail, in ieee80211_chan_init()
210 sizeof(ic->ic_chan_avail)); in ieee80211_chan_init()
212 /* sort channel table to allow lookup optimizations */ in ieee80211_chan_init()
213 ieee80211_sort_channels(ic->ic_channels, ic->ic_nchans); in ieee80211_chan_init()
216 ic->ic_bsschan = IEEE80211_CHAN_ANYC; in ieee80211_chan_init()
217 ic->ic_prevchan = NULL; in ieee80211_chan_init()
218 ic->ic_csa_newchan = NULL; in ieee80211_chan_init()
219 /* arbitrarily pick the first channel */ in ieee80211_chan_init()
220 ic->ic_curchan = &ic->ic_channels[0]; in ieee80211_chan_init()
221 ic->ic_rt = ieee80211_get_ratetable(ic->ic_curchan); in ieee80211_chan_init()
223 /* fillin well-known rate sets if driver has not specified */ in ieee80211_chan_init()
241 if (ic->ic_rxstream == 0) in ieee80211_chan_init()
242 ic->ic_rxstream = 2; in ieee80211_chan_init()
243 if (ic->ic_txstream == 0) in ieee80211_chan_init()
244 ic->ic_txstream = 2; in ieee80211_chan_init()
249 * Set auto mode to reset active channel state and any desired channel. in ieee80211_chan_init()
282 retval = printf("%s: ", ic->ic_name); in ic_printf()
309 sbuf_printf(&sb, "%s%s", sp, ic->ic_name); in sysctl_ieee80211coms()
330 IEEE80211_LOCK_INIT(ic, ic->ic_name); in ieee80211_ifattach()
331 IEEE80211_TX_LOCK_INIT(ic, ic->ic_name); in ieee80211_ifattach()
332 TAILQ_INIT(&ic->ic_vaps); in ieee80211_ifattach()
335 ic->ic_tq = taskqueue_create("ic_taskq", in ieee80211_ifattach()
337 taskqueue_thread_enqueue, &ic->ic_tq); in ieee80211_ifattach()
338 taskqueue_start_threads(&ic->ic_tq, 1, PI_NET, "%s net80211 taskq", in ieee80211_ifattach()
339 ic->ic_name); in ieee80211_ifattach()
340 ic->ic_ierrors = counter_u64_alloc(IEEE80211_M_WAITOK); in ieee80211_ifattach()
341 ic->ic_oerrors = counter_u64_alloc(IEEE80211_M_WAITOK); in ieee80211_ifattach()
343 * Fill in 802.11 available channel set, mark all in ieee80211_ifattach()
345 * channel if not already specified. in ieee80211_ifattach()
349 ic->ic_update_mcast = null_update_mcast; in ieee80211_ifattach()
350 ic->ic_update_promisc = null_update_promisc; in ieee80211_ifattach()
351 ic->ic_update_chw = null_update_chw; in ieee80211_ifattach()
353 ic->ic_hash_key = arc4random(); in ieee80211_ifattach()
354 ic->ic_bintval = IEEE80211_BINTVAL_DEFAULT; in ieee80211_ifattach()
355 ic->ic_lintval = ic->ic_bintval; in ieee80211_ifattach()
356 ic->ic_txpowlimit = IEEE80211_TXPOWER_MAX; in ieee80211_ifattach()
395 if (ic->ic_tq == NULL) in ieee80211_ifdetach()
402 taskqueue_drain(taskqueue_thread, &ic->ic_restart_task); in ieee80211_ifdetach()
408 while ((vap = TAILQ_FIRST(&ic->ic_vaps)) != NULL) { in ieee80211_ifdetach()
429 counter_u64_free(ic->ic_ierrors); in ieee80211_ifdetach()
430 counter_u64_free(ic->ic_oerrors); in ieee80211_ifdetach()
432 taskqueue_free(ic->ic_tq); in ieee80211_ifdetach()
478 if (strcmp(ic->ic_name, name) == 0) in ieee80211_find_com()
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; in default_update_deftxkey()
533 struct ieee80211vap *vap = ifp->if_softc; in ieee80211_get_counter()
534 struct ieee80211com *ic = vap->iv_ic; in ieee80211_get_counter()
540 rv += counter_u64_fetch(ic->ic_oerrors); in ieee80211_get_counter()
543 rv += counter_u64_fetch(ic->ic_ierrors); in ieee80211_get_counter()
566 ifp->if_softc = vap; /* back pointer */ in ieee80211_vap_setup()
567 ifp->if_flags = IFF_SIMPLEX | IFF_BROADCAST | IFF_MULTICAST; in ieee80211_vap_setup()
568 ifp->if_transmit = ieee80211_vap_transmit; in ieee80211_vap_setup()
569 ifp->if_qflush = ieee80211_vap_qflush; in ieee80211_vap_setup()
570 ifp->if_ioctl = ieee80211_ioctl; in ieee80211_vap_setup()
571 ifp->if_init = ieee80211_init; in ieee80211_vap_setup()
572 ifp->if_get_counter = ieee80211_get_counter; in ieee80211_vap_setup()
574 vap->iv_ifp = ifp; in ieee80211_vap_setup()
575 vap->iv_ic = ic; in ieee80211_vap_setup()
576 vap->iv_flags = ic->ic_flags; /* propagate common flags */ in ieee80211_vap_setup()
577 vap->iv_flags_ext = ic->ic_flags_ext; in ieee80211_vap_setup()
578 vap->iv_flags_ven = ic->ic_flags_ven; in ieee80211_vap_setup()
579 vap->iv_caps = ic->ic_caps &~ IEEE80211_C_OPMODE; in ieee80211_vap_setup()
581 /* 11n capabilities - XXX methodize */ in ieee80211_vap_setup()
582 vap->iv_htcaps = ic->ic_htcaps; in ieee80211_vap_setup()
583 vap->iv_htextcaps = ic->ic_htextcaps; in ieee80211_vap_setup()
585 /* 11ac capabilities - XXX methodize */ in ieee80211_vap_setup()
586 vap->iv_vht_cap.vht_cap_info = ic->ic_vht_cap.vht_cap_info; in ieee80211_vap_setup()
587 vap->iv_vhtextcaps = ic->ic_vhtextcaps; in ieee80211_vap_setup()
589 vap->iv_opmode = opmode; in ieee80211_vap_setup()
590 vap->iv_caps |= ieee80211_opcap[opmode]; in ieee80211_vap_setup()
591 IEEE80211_ADDR_COPY(vap->iv_myaddr, ic->ic_macaddr); in ieee80211_vap_setup()
597 * For non-legacy operation the station must associate in ieee80211_vap_setup()
602 IEEE80211_ADDR_COPY(vap->iv_des_bssid, bssid); in ieee80211_vap_setup()
603 vap->iv_flags |= IEEE80211_F_DESBSSID; in ieee80211_vap_setup()
605 vap->iv_flags_ext |= IEEE80211_FEXT_WDSLEGACY; in ieee80211_vap_setup()
611 KASSERT(ic->ic_caps & IEEE80211_C_TDMA, in ieee80211_vap_setup()
612 ("not TDMA capable, ic_caps 0x%x", ic->ic_caps)); in ieee80211_vap_setup()
618 vap->iv_caps |= IEEE80211_C_TDMA; in ieee80211_vap_setup()
625 /* auto-enable s/w beacon miss support */ in ieee80211_vap_setup()
627 vap->iv_flags_ext |= IEEE80211_FEXT_SWBMISS; in ieee80211_vap_setup()
628 /* auto-generated or user supplied MAC address */ in ieee80211_vap_setup()
630 vap->iv_flags_ext |= IEEE80211_FEXT_UNIQMAC; in ieee80211_vap_setup()
635 if (vap->iv_caps & IEEE80211_C_WME) in ieee80211_vap_setup()
636 vap->iv_flags |= IEEE80211_F_WME; in ieee80211_vap_setup()
637 if (vap->iv_caps & IEEE80211_C_BURST) in ieee80211_vap_setup()
638 vap->iv_flags |= IEEE80211_F_BURST; in ieee80211_vap_setup()
640 if (vap->iv_opmode == IEEE80211_M_STA && in ieee80211_vap_setup()
641 (vap->iv_caps & IEEE80211_C_BGSCAN)) in ieee80211_vap_setup()
642 vap->iv_flags |= IEEE80211_F_BGSCAN; in ieee80211_vap_setup()
643 vap->iv_flags |= IEEE80211_F_DOTH; /* XXX no cap, just ena */ in ieee80211_vap_setup()
645 if (vap->iv_opmode == IEEE80211_M_HOSTAP && in ieee80211_vap_setup()
646 (vap->iv_caps & IEEE80211_C_DFS)) in ieee80211_vap_setup()
647 vap->iv_flags_ext |= IEEE80211_FEXT_DFS; in ieee80211_vap_setup()
648 /* NB: only flip on U-APSD for hostap/sta for now */ in ieee80211_vap_setup()
649 if ((vap->iv_opmode == IEEE80211_M_STA) in ieee80211_vap_setup()
650 || (vap->iv_opmode == IEEE80211_M_HOSTAP)) { in ieee80211_vap_setup()
651 if (vap->iv_caps & IEEE80211_C_UAPSD) in ieee80211_vap_setup()
652 vap->iv_flags_ext |= IEEE80211_FEXT_UAPSD; in ieee80211_vap_setup()
655 vap->iv_des_chan = IEEE80211_CHAN_ANYC; /* any channel is ok */ in ieee80211_vap_setup()
656 vap->iv_bmissthreshold = IEEE80211_HWBMISS_DEFAULT; in ieee80211_vap_setup()
657 vap->iv_dtim_period = IEEE80211_DTIM_DEFAULT; in ieee80211_vap_setup()
662 vap->iv_reset = default_reset; in ieee80211_vap_setup()
668 vap->iv_update_deftxkey = default_update_deftxkey; in ieee80211_vap_setup()
698 struct ifnet *ifp = vap->iv_ifp; in ieee80211_vap_attach()
699 struct ieee80211com *ic = vap->iv_ic; in ieee80211_vap_attach()
705 __func__, ieee80211_opmode_name[vap->iv_opmode], in ieee80211_vap_attach()
706 ic->ic_name, vap->iv_flags, vap->iv_flags_ext); in ieee80211_vap_attach()
715 maxrate = ieee80211_media_setup(ic, &vap->iv_media, vap->iv_caps, in ieee80211_vap_attach()
716 vap->iv_opmode == IEEE80211_M_STA, media_change, media_stat); in ieee80211_vap_attach()
719 ifmedia_set(&vap->iv_media, in ieee80211_vap_attach()
722 ifp->if_baudrate = IF_Mbps(maxrate); in ieee80211_vap_attach()
725 IEEE80211_ADDR_COPY(vap->iv_myaddr, IF_LLADDR(ifp)); in ieee80211_vap_attach()
727 vap->iv_output = ifp->if_output; in ieee80211_vap_attach()
728 ifp->if_output = ieee80211_output; in ieee80211_vap_attach()
732 TAILQ_INSERT_TAIL(&ic->ic_vaps, vap, iv_next); in ieee80211_vap_attach()
761 struct ieee80211com *ic = vap->iv_ic; in ieee80211_vap_detach()
762 struct ifnet *ifp = vap->iv_ifp; in ieee80211_vap_detach()
765 CURVNET_SET(ifp->if_vnet); in ieee80211_vap_detach()
768 __func__, ieee80211_opmode_name[vap->iv_opmode], ic->ic_name); in ieee80211_vap_detach()
779 ieee80211_draintask(ic, &vap->iv_nstate_task[i]); in ieee80211_vap_detach()
780 ieee80211_draintask(ic, &vap->iv_swbmiss_task); in ieee80211_vap_detach()
781 ieee80211_draintask(ic, &vap->iv_wme_task); in ieee80211_vap_detach()
782 ieee80211_draintask(ic, &ic->ic_parent_task); in ieee80211_vap_detach()
784 /* XXX band-aid until ifnet handles this for us */ in ieee80211_vap_detach()
785 taskqueue_drain(taskqueue_swi, &ifp->if_linktask); in ieee80211_vap_detach()
788 KASSERT(vap->iv_state == IEEE80211_S_INIT , ("vap still running")); in ieee80211_vap_detach()
789 TAILQ_REMOVE(&ic->ic_vaps, vap, iv_next); in ieee80211_vap_detach()
807 if (vap->iv_ifflags & IFF_PROMISC) in ieee80211_vap_detach()
809 if (vap->iv_ifflags & IFF_ALLMULTI) in ieee80211_vap_detach()
813 ifmedia_removeall(&vap->iv_media); in ieee80211_vap_detach()
842 struct ieee80211com *ic = vap->iv_ic; in ieee80211_promisc()
847 if (++ic->ic_promisc == 1) in ieee80211_promisc()
848 ieee80211_runtask(ic, &ic->ic_promisc_task); in ieee80211_promisc()
850 KASSERT(ic->ic_promisc > 0, ("%s: ic %p not promisc", in ieee80211_promisc()
852 if (--ic->ic_promisc == 0) in ieee80211_promisc()
853 ieee80211_runtask(ic, &ic->ic_promisc_task); in ieee80211_promisc()
864 struct ieee80211com *ic = vap->iv_ic; in ieee80211_allmulti()
869 if (++ic->ic_allmulti == 1) in ieee80211_allmulti()
870 ieee80211_runtask(ic, &ic->ic_mcast_task); in ieee80211_allmulti()
872 KASSERT(ic->ic_allmulti > 0, ("%s: ic %p not allmulti", in ieee80211_allmulti()
874 if (--ic->ic_allmulti == 0) in ieee80211_allmulti()
875 ieee80211_runtask(ic, &ic->ic_mcast_task); in ieee80211_allmulti()
893 TAILQ_FOREACH(vap, &ic->ic_vaps, iv_next) in ieee80211_syncflag_locked()
894 if (vap->iv_flags & flag) { in ieee80211_syncflag_locked()
899 ic->ic_flags |= flag; in ieee80211_syncflag_locked()
901 ic->ic_flags &= ~flag; in ieee80211_syncflag_locked()
907 struct ieee80211com *ic = vap->iv_ic; in ieee80211_syncflag()
911 flag = -flag; in ieee80211_syncflag()
912 vap->iv_flags &= ~flag; in ieee80211_syncflag()
914 vap->iv_flags |= flag; in ieee80211_syncflag()
933 TAILQ_FOREACH(vap, &ic->ic_vaps, iv_next) in ieee80211_syncflag_ht_locked()
934 if (vap->iv_flags_ht & flag) { in ieee80211_syncflag_ht_locked()
939 ic->ic_flags_ht |= flag; in ieee80211_syncflag_ht_locked()
941 ic->ic_flags_ht &= ~flag; in ieee80211_syncflag_ht_locked()
947 struct ieee80211com *ic = vap->iv_ic; in ieee80211_syncflag_ht()
951 flag = -flag; in ieee80211_syncflag_ht()
952 vap->iv_flags_ht &= ~flag; in ieee80211_syncflag_ht()
954 vap->iv_flags_ht |= flag; in ieee80211_syncflag_ht()
973 TAILQ_FOREACH(vap, &ic->ic_vaps, iv_next) in ieee80211_syncflag_vht_locked()
974 if (vap->iv_vht_flags & flag) { in ieee80211_syncflag_vht_locked()
979 ic->ic_vht_flags |= flag; in ieee80211_syncflag_vht_locked()
981 ic->ic_vht_flags &= ~flag; in ieee80211_syncflag_vht_locked()
987 struct ieee80211com *ic = vap->iv_ic; in ieee80211_syncflag_vht()
991 flag = -flag; in ieee80211_syncflag_vht()
992 vap->iv_vht_flags &= ~flag; in ieee80211_syncflag_vht()
994 vap->iv_vht_flags |= flag; in ieee80211_syncflag_vht()
1013 TAILQ_FOREACH(vap, &ic->ic_vaps, iv_next) in ieee80211_syncflag_ext_locked()
1014 if (vap->iv_flags_ext & flag) { in ieee80211_syncflag_ext_locked()
1019 ic->ic_flags_ext |= flag; in ieee80211_syncflag_ext_locked()
1021 ic->ic_flags_ext &= ~flag; in ieee80211_syncflag_ext_locked()
1027 struct ieee80211com *ic = vap->iv_ic; in ieee80211_syncflag_ext()
1031 flag = -flag; in ieee80211_syncflag_ext()
1032 vap->iv_flags_ext &= ~flag; in ieee80211_syncflag_ext()
1034 vap->iv_flags_ext |= flag; in ieee80211_syncflag_ext()
1050 return (freq - 906*10) / 5; in mapgsm()
1056 return 37 + ((freq * 10) + ((freq % 5) == 2 ? 5 : 0) - 49400) / 5; in mappsb()
1060 * Convert MHz frequency to IEEE channel number.
1072 return ((int) freq - 2407) / 5; in ieee80211_mhz2ieee()
1074 return 15 + ((freq - 2512) / 20); in ieee80211_mhz2ieee()
1080 return (freq - 4000) / 5; in ieee80211_mhz2ieee()
1082 return (freq - 5000) / 5; in ieee80211_mhz2ieee()
1089 return ((int) freq - 2407) / 5; in ieee80211_mhz2ieee()
1095 return (freq - 4000) / 5; in ieee80211_mhz2ieee()
1097 return 15 + ((freq - 2512) / 20); in ieee80211_mhz2ieee()
1099 return (freq - 5000) / 5; in ieee80211_mhz2ieee()
1105 * Convert channel to IEEE channel number.
1111 ic_printf(ic, "invalid channel (NULL)\n"); in ieee80211_chan2ieee()
1114 return (c == IEEE80211_CHAN_ANYC ? IEEE80211_CHAN_ANY : c->ic_ieee); in ieee80211_chan2ieee()
1118 * Convert IEEE channel number to MHz frequency.
1131 return 2512 + ((chan-15)*20); in ieee80211_ieee2mhz()
1134 chan -= 37; in ieee80211_ieee2mhz()
1142 if (chan < 14) /* 0-13 */ in ieee80211_ieee2mhz()
1144 if (chan < 27) /* 15-26 */ in ieee80211_ieee2mhz()
1145 return 2512 + ((chan-15)*20); in ieee80211_ieee2mhz()
1155 * IEEE Std 802.11-2012, page 1738, subclause 20.3.15.4: in set_extchan()
1156 * "the secondary channel number shall be 'N + [1,-1] * 4' in set_extchan()
1158 if (c->ic_flags & IEEE80211_CHAN_HT40U) in set_extchan()
1159 c->ic_extieee = c->ic_ieee + 4; in set_extchan()
1160 else if (c->ic_flags & IEEE80211_CHAN_HT40D) in set_extchan()
1161 c->ic_extieee = c->ic_ieee - 4; in set_extchan()
1163 c->ic_extieee = 0; in set_extchan()
1169 * This for now uses a hard-coded list of 80MHz wide channels.
1172 * wide channel we've already decided upon.
1177 * This is all likely very very wrong - both the regulatory code
1179 * available and valid before the VHT80 (and eight for VHT160) channel
1213 printf("%s: TODO VHT80+80 channel (ieee=%d, flags=0x%08x)\n", in set_vht_extchan()
1214 __func__, c->ic_ieee, c->ic_flags); in set_vht_extchan()
1219 if (c->ic_freq >= vht160_chan_ranges[i].freq_start && in set_vht_extchan()
1220 c->ic_freq < vht160_chan_ranges[i].freq_end) { in set_vht_extchan()
1224 c->ic_vht_ch_freq1 = in set_vht_extchan()
1225 ieee80211_mhz2ieee(midpoint, c->ic_flags); in set_vht_extchan()
1226 c->ic_vht_ch_freq2 = 0; in set_vht_extchan()
1229 __func__, c->ic_ieee, c->ic_freq, midpoint, in set_vht_extchan()
1230 c->ic_vht_ch_freq1, c->ic_vht_ch_freq2); in set_vht_extchan()
1240 if (c->ic_freq >= vht80_chan_ranges[i].freq_start && in set_vht_extchan()
1241 c->ic_freq < vht80_chan_ranges[i].freq_end) { in set_vht_extchan()
1245 c->ic_vht_ch_freq1 = in set_vht_extchan()
1246 ieee80211_mhz2ieee(midpoint, c->ic_flags); in set_vht_extchan()
1247 c->ic_vht_ch_freq2 = 0; in set_vht_extchan()
1250 __func__, c->ic_ieee, c->ic_freq, midpoint, in set_vht_extchan()
1251 c->ic_vht_ch_freq1, c->ic_vht_ch_freq2); in set_vht_extchan()
1261 c->ic_vht_ch_freq1 = c->ic_ieee + 2; in set_vht_extchan()
1263 c->ic_vht_ch_freq1 = c->ic_ieee - 2; in set_vht_extchan()
1270 c->ic_vht_ch_freq1 = c->ic_ieee; in set_vht_extchan()
1274 printf("%s: unknown VHT channel type (ieee=%d, flags=0x%08x)\n", in set_vht_extchan()
1275 __func__, c->ic_ieee, c->ic_flags); in set_vht_extchan()
1281 * Return whether the current channel could possibly be a part of
1282 * a VHT80/VHT160 channel.
1327 c->ic_ieee = ieee; in addchan()
1328 c->ic_freq = freq != 0 ? freq : ieee80211_ieee2mhz(ieee, flags); in addchan()
1329 c->ic_maxregpower = maxregpower; in addchan()
1330 c->ic_maxpower = 2 * maxregpower; in addchan()
1331 c->ic_flags = flags; in addchan()
1332 c->ic_vht_ch_freq1 = 0; in addchan()
1333 c->ic_vht_ch_freq2 = 0; in addchan()
1346 KASSERT(*nchans > 0, ("channel list is empty\n")); in copychan_prev()
1357 c[0] = c[-1]; in copychan_prev()
1358 c->ic_flags = flags; in copychan_prev()
1359 c->ic_vht_ch_freq1 = 0; in copychan_prev()
1360 c->ic_vht_ch_freq2 = 0; in copychan_prev()
1368 * XXX VHT-2GHz
1396 * be in channel width order, so the VHT bits are interspersed in getflags_5ghz()
1477 * Add one 20 MHz channel into specified channel list.
1524 if (c->ic_freq == freq && in findchannel()
1525 (c->ic_flags & IEEE80211_CHAN_ALLTURBO) == flags) in findchannel()
1532 * Add 40 MHz channel pair into specified channel list.
1546 * Each entry defines an HT40 channel pair; find the in ieee80211_add_channel_ht40()
1547 * center channel, then the extension channel above. in ieee80211_add_channel_ht40()
1559 error = addchan(chans, maxchans, nchans, cent->ic_ieee, cent->ic_freq, in ieee80211_add_channel_ht40()
1564 error = addchan(chans, maxchans, nchans, extc->ic_ieee, extc->ic_freq, in ieee80211_add_channel_ht40()
1571 * Fetch the center frequency for the primary channel.
1577 return (c->ic_freq); in ieee80211_get_channel_center_freq()
1581 * Fetch the center frequency for the primary BAND channel.
1583 * For 5, 10, 20MHz channels it'll be the normally configured channel
1587 * wide channel, not the centre of the primary channel (that's ic_freq).
1590 * 80MHz channel; the secondary 80MHz channel will be center_freq2().
1597 * VHT - use the pre-calculated centre frequency in ieee80211_get_channel_center_freq1()
1598 * of the given channel. in ieee80211_get_channel_center_freq1()
1601 return (ieee80211_ieee2mhz(c->ic_vht_ch_freq1, c->ic_flags)); in ieee80211_get_channel_center_freq1()
1604 return (c->ic_freq + 10); in ieee80211_get_channel_center_freq1()
1607 return (c->ic_freq - 10); in ieee80211_get_channel_center_freq1()
1610 return (c->ic_freq); in ieee80211_get_channel_center_freq1()
1620 if (IEEE80211_IS_CHAN_VHT(c) && (c->ic_vht_ch_freq2 != 0)) in ieee80211_get_channel_center_freq2()
1621 return (ieee80211_ieee2mhz(c->ic_vht_ch_freq2, c->ic_flags)); in ieee80211_get_channel_center_freq2()
1627 * Adds channels into specified channel list (ieee[] array must be sorted).
1676 * allow a VHT80 channel if the VHT40 combination is in add_chanlist()
1682 * Can't have a "lower" channel if we are the in add_chanlist()
1683 * first channel. in add_chanlist()
1685 * Can't have a "lower" channel if it's below/ in add_chanlist()
1686 * within 20MHz of the first channel. in add_chanlist()
1688 * Can't have a "lower" channel if the channel in add_chanlist()
1692 freq - 20 != in add_chanlist()
1693 ieee80211_ieee2mhz(ieee[i] - 4, flags[j])) in add_chanlist()
1697 * Can't have an "upper" channel if we are in add_chanlist()
1698 * the last channel. in add_chanlist()
1700 * Can't have an "upper" channel be above the in add_chanlist()
1701 * last channel in the list. in add_chanlist()
1703 * Can't have an "upper" channel if the next in add_chanlist()
1704 * channel according to the math isn't 20MHz in add_chanlist()
1705 * away. (Likely for channel 13/14.) in add_chanlist()
1707 if (i == nieee - 1 || in add_chanlist()
1708 ieee[i] + 4 > ieee[nieee - 1] || in add_chanlist()
1747 { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14 }; in ieee80211_add_channels_default_2ghz()
1759 * XXX-BZ with HT and VHT there is no 1:1 mapping anymore. Review all in ieee80211_add_channel_list_5ghz()
1771 * Locate a channel given a frequency+flags. We cache
1773 * channels--as happens with dynamic turbo.
1781 c = ic->ic_prevchan; in ieee80211_find_channel()
1782 if (c != NULL && c->ic_freq == freq && in ieee80211_find_channel()
1783 (c->ic_flags & IEEE80211_CHAN_ALLTURBO) == flags) in ieee80211_find_channel()
1786 return (findchannel(ic->ic_channels, ic->ic_nchans, freq, flags)); in ieee80211_find_channel()
1790 * Locate a channel given a channel number+flags. We cache
1792 * channels--as happens with dynamic turbo.
1801 c = ic->ic_prevchan; in ieee80211_find_channel_byieee()
1802 if (c != NULL && c->ic_ieee == ieee && in ieee80211_find_channel_byieee()
1803 (c->ic_flags & IEEE80211_CHAN_ALLTURBO) == flags) in ieee80211_find_channel_byieee()
1806 for (i = 0; i < ic->ic_nchans; i++) { in ieee80211_find_channel_byieee()
1807 c = &ic->ic_channels[i]; in ieee80211_find_channel_byieee()
1808 if (c->ic_ieee == ieee && in ieee80211_find_channel_byieee()
1809 (c->ic_flags & IEEE80211_CHAN_ALLTURBO) == flags) in ieee80211_find_channel_byieee()
1816 * Lookup a channel suitable for the given rx status.
1818 * This is used to find a channel for a frame (eg beacon, probe
1822 * This is enough for 11bg and 11a (and thus 11ng/11na)
1824 * like. It also doesn't know about legacy-turbog and
1825 * legacy-turbo modes, which some offload NICs actually
1828 * Takes the ic and rxstatus; returns the channel or NULL
1837 struct ieee80211com *ic = vap->iv_ic; in ieee80211_lookup_channel_rxstatus()
1849 if ((rxs->r_flags & IEEE80211_R_FREQ) == 0) in ieee80211_lookup_channel_rxstatus()
1851 if ((rxs->r_flags & IEEE80211_R_IEEE) == 0) in ieee80211_lookup_channel_rxstatus()
1853 if ((rxs->r_flags & IEEE80211_R_BAND) == 0) in ieee80211_lookup_channel_rxstatus()
1858 * ensure we populate the correct channel information in ieee80211_lookup_channel_rxstatus()
1865 switch (rxs->c_band) { in ieee80211_lookup_channel_rxstatus()
1873 if (rxs->c_freq < 3000) { in ieee80211_lookup_channel_rxstatus()
1881 /* Channel lookup */ in ieee80211_lookup_channel_rxstatus()
1882 c = ieee80211_find_channel(ic, rxs->c_freq, flags); in ieee80211_lookup_channel_rxstatus()
1886 __func__, (int) rxs->c_freq, (int) rxs->c_ieee, flags, c); in ieee80211_lookup_channel_rxstatus()
1934 * Setup the media data structures according to the channel and
1957 if (isclr(ic->ic_modecaps, mode)) in ieee80211_media_setup()
1962 rs = &ic->ic_sup_rates[mode]; in ieee80211_media_setup()
1963 for (i = 0; i < rs->rs_nrates; i++) { in ieee80211_media_setup()
1964 rate = rs->rs_rates[i]; in ieee80211_media_setup()
1996 * Add HT/11n media. Note that we do not have enough in ieee80211_media_setup()
2002 if (isclr(ic->ic_modecaps, mode)) in ieee80211_media_setup()
2007 if (isset(ic->ic_modecaps, IEEE80211_MODE_11NA) || in ieee80211_media_setup()
2008 isset(ic->ic_modecaps, IEEE80211_MODE_11NG)) { in ieee80211_media_setup()
2011 i = ic->ic_txstream * 8 - 1; in ieee80211_media_setup()
2012 if ((ic->ic_htcaps & IEEE80211_HTCAP_CHWIDTH40) && in ieee80211_media_setup()
2013 (ic->ic_htcaps & IEEE80211_HTCAP_SHORTGI40)) in ieee80211_media_setup()
2015 else if ((ic->ic_htcaps & IEEE80211_HTCAP_CHWIDTH40)) in ieee80211_media_setup()
2017 else if ((ic->ic_htcaps & IEEE80211_HTCAP_SHORTGI20)) in ieee80211_media_setup()
2027 * XXX-BZ skip "VHT_2GHZ" for now. in ieee80211_media_setup()
2031 if (isclr(ic->ic_modecaps, mode)) in ieee80211_media_setup()
2036 if (isset(ic->ic_modecaps, IEEE80211_MODE_VHT_5GHZ)) { in ieee80211_media_setup()
2050 /* XXX does this work for 11ng basic rates? */ in ieee80211_get_suprates()
2051 return &ic->ic_sup_rates[ieee80211_chan2mode(c)]; in ieee80211_get_suprates()
2059 return &ic->ic_sup_htrates; in ieee80211_get_suphtrates()
2071 if (isclr(ic->ic_modecaps, mode)) in ieee80211_announce()
2074 rs = &ic->ic_sup_rates[mode]; in ieee80211_announce()
2075 for (i = 0; i < rs->rs_nrates; i++) { in ieee80211_announce()
2076 mword = ieee80211_rate2media(ic, rs->rs_rates[i], mode); in ieee80211_announce()
2097 for (i = 0; i < ic->ic_nchans; i++) { in ieee80211_announce_channels()
2098 c = &ic->ic_channels[i]; in ieee80211_announce_channels()
2124 , c->ic_ieee, c->ic_freq, type in ieee80211_announce_channels()
2127 IEEE80211_IS_CHAN_HT40D(c) ? '-' : ' ' in ieee80211_announce_channels()
2128 , c->ic_maxregpower in ieee80211_announce_channels()
2129 , c->ic_minpower / 2, c->ic_minpower & 1 ? 5 : 0 in ieee80211_announce_channels()
2130 , c->ic_maxpower / 2, c->ic_maxpower & 1 ? 5 : 0 in ieee80211_announce_channels()
2138 switch (IFM_MODE(ime->ifm_media)) { in media2mode()
2173 if (ime->ifm_media & IFM_IEEE80211_TURBO) { in media2mode()
2184 /* XXX HT40 +/- */ in media2mode()
2194 struct ieee80211vap *vap = ifp->if_softc; in ieee80211_media_change()
2195 struct ifmedia_entry *ime = vap->iv_media.ifm_cur; in ieee80211_media_change()
2198 if (!media2mode(ime, vap->iv_flags, &newmode)) in ieee80211_media_change()
2200 if (vap->iv_des_mode != newmode) { in ieee80211_media_change()
2201 vap->iv_des_mode = newmode; in ieee80211_media_change()
2209 * from the operating mode and channel state.
2272 struct ieee80211vap *vap = ifp->if_softc; in ieee80211_media_status()
2273 struct ieee80211com *ic = vap->iv_ic; in ieee80211_media_status()
2276 imr->ifm_status = IFM_AVALID; in ieee80211_media_status()
2278 * NB: use the current channel's mode to lock down a xmit in ieee80211_media_status()
2282 if (vap->iv_state == IEEE80211_S_RUN || in ieee80211_media_status()
2283 vap->iv_state == IEEE80211_S_SLEEP) { in ieee80211_media_status()
2284 imr->ifm_status |= IFM_ACTIVE; in ieee80211_media_status()
2285 mode = ieee80211_chan2mode(ic->ic_curchan); in ieee80211_media_status()
2288 imr->ifm_active = media_status(vap->iv_opmode, ic->ic_curchan); in ieee80211_media_status()
2292 if (vap->iv_txparms[mode].ucastrate != IEEE80211_FIXED_RATE_NONE) { in ieee80211_media_status()
2296 imr->ifm_active |= ieee80211_rate2media(ic, in ieee80211_media_status()
2297 vap->iv_txparms[mode].ucastrate, mode); in ieee80211_media_status()
2298 } else if (vap->iv_opmode == IEEE80211_M_STA) { in ieee80211_media_status()
2302 imr->ifm_active |= ieee80211_rate2media(ic, in ieee80211_media_status()
2303 vap->iv_bss->ni_txrate, mode); in ieee80211_media_status()
2305 imr->ifm_active |= IFM_AUTO; in ieee80211_media_status()
2306 if (imr->ifm_status & IFM_ACTIVE) in ieee80211_media_status()
2307 imr->ifm_current = imr->ifm_active; in ieee80211_media_status()
2311 * Set the current phy mode and recalculate the active channel
2313 * select a new default/current channel if the current one is
2320 * Adjust basic rates in 11b/11g supported rate set. in ieee80211_setmode()
2321 * Note that if operating on a hal/quarter rate channel in ieee80211_setmode()
2326 ieee80211_setbasicrates(&ic->ic_sup_rates[mode], mode); in ieee80211_setmode()
2328 ic->ic_curmode = mode; in ieee80211_setmode()
2335 * Return the phy mode for with the specified channel.
2369 printf("%s: cannot map channel to mode; freq %u flags 0x%x\n", in ieee80211_chan2mode()
2370 __func__, chan->ic_freq, chan->ic_flags); in ieee80211_chan2mode()
2403 { 11 | IFM_IEEE80211_11B, IFM_IEEE80211_DS5 }, in ieee80211_rate2media()
2416 { 11 | IFM_IEEE80211_11G, IFM_IEEE80211_DS5 }, in ieee80211_rate2media()
2443 { 11, IFM_IEEE80211_MCS }, in ieee80211_rate2media()
2524 { 11, IFM_IEEE80211_VHT }, in ieee80211_rate2media()
2530 * Check 11ac/11n rates first for match as an MCS. in ieee80211_rate2media()
2573 if (ic != NULL && ic->ic_phytype == IEEE80211_T_FH) in ieee80211_rate2media()
2576 /* NB: hack, 11g matches both 11b+11a rates */ in ieee80211_rate2media()
2594 -1, /* IFM_AUTO */ in ieee80211_media2rate()
2601 11, /* IFM_IEEE80211_DS5 */ in ieee80211_media2rate()
2618 -1, /* IFM_IEEE80211_MCS */ in ieee80211_media2rate()
2619 -1, /* IFM_IEEE80211_VHT */ in ieee80211_media2rate()
2631 a -= b; a -= c; a ^= (c >> 13); \
2632 b -= c; b -= a; b ^= (a << 8); \
2633 c -= a; c -= b; c ^= (b >> 13); \
2634 a -= b; a -= c; a ^= (c >> 12); \
2635 b -= c; b -= a; b ^= (a << 16); \
2636 c -= a; c -= b; c ^= (b >> 5); \
2637 a -= b; a -= c; a ^= (c >> 3); \
2638 b -= c; b -= a; b ^= (a << 10); \
2639 c -= a; c -= b; c ^= (b >> 15); \
2646 uint32_t a = 0x9e3779b9, b = 0x9e3779b9, c = ic->ic_hash_key; in ieee80211_mac_hash()
2695 return (&vap->iv_nw_keys[0] <= key && in ieee80211_is_key_global()
2696 key < &vap->iv_nw_keys[IEEE80211_WEP_NKID]); in ieee80211_is_key_global()
2707 * This is a short-cut for now; eventually we will need in ieee80211_is_key_unicast()