Lines Matching +full:switch +full:- +full:freq +full:- +full:select
1 /*-
2 * SPDX-License-Identifier: BSD-2-Clause
5 * Copyright (c) 2002-2009 Sam Leffler, Errno Consulting
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()
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()
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()
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()
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()
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()
538 switch (cnt) { 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()
592 switch (opmode) { 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()
1040 mapgsm(u_int freq, u_int flags) in mapgsm() argument
1042 freq *= 10; in mapgsm()
1044 freq += 5; in mapgsm()
1046 freq += 10; in mapgsm()
1048 freq += 20; in mapgsm()
1050 return (freq - 906*10) / 5; in mapgsm()
1054 mappsb(u_int freq, u_int flags) in mappsb() argument
1056 return 37 + ((freq * 10) + ((freq % 5) == 2 ? 5 : 0) - 49400) / 5; in mappsb()
1063 ieee80211_mhz2ieee(u_int freq, u_int flags) in ieee80211_mhz2ieee() argument
1067 return mapgsm(freq, flags); in ieee80211_mhz2ieee()
1069 if (freq == 2484) in ieee80211_mhz2ieee()
1071 if (freq < 2484) in ieee80211_mhz2ieee()
1072 return ((int) freq - 2407) / 5; in ieee80211_mhz2ieee()
1074 return 15 + ((freq - 2512) / 20); in ieee80211_mhz2ieee()
1076 if (freq <= 5000) { in ieee80211_mhz2ieee()
1078 if (IS_FREQ_IN_PSB(freq)) in ieee80211_mhz2ieee()
1079 return mappsb(freq, flags); in ieee80211_mhz2ieee()
1080 return (freq - 4000) / 5; in ieee80211_mhz2ieee()
1082 return (freq - 5000) / 5; in ieee80211_mhz2ieee()
1084 if (freq == 2484) in ieee80211_mhz2ieee()
1086 if (freq < 2484) { in ieee80211_mhz2ieee()
1087 if (907 <= freq && freq <= 922) in ieee80211_mhz2ieee()
1088 return mapgsm(freq, flags); in ieee80211_mhz2ieee()
1089 return ((int) freq - 2407) / 5; in ieee80211_mhz2ieee()
1091 if (freq < 5000) { in ieee80211_mhz2ieee()
1092 if (IS_FREQ_IN_PSB(freq)) in ieee80211_mhz2ieee()
1093 return mappsb(freq, flags); in ieee80211_mhz2ieee()
1094 else if (freq > 4900) 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()
1114 return (c == IEEE80211_CHAN_ANYC ? IEEE80211_CHAN_ANY : c->ic_ieee); in ieee80211_chan2ieee()
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.
1177 * This is all likely very very wrong - both the regulatory code
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()
1228 printf("%s: %d, freq=%d, midpoint=%d, freq1=%d, freq2=%d\n", 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()
1249 printf("%s: %d, freq=%d, midpoint=%d, freq1=%d, freq2=%d\n", 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()
1275 __func__, c->ic_ieee, c->ic_flags); in set_vht_extchan()
1288 is_vht160_valid_freq(uint16_t freq) in is_vht160_valid_freq() argument
1293 if (freq >= vht160_chan_ranges[i].freq_start && in is_vht160_valid_freq()
1294 freq < vht160_chan_ranges[i].freq_end) in is_vht160_valid_freq()
1301 is_vht80_valid_freq(uint16_t freq) in is_vht80_valid_freq() argument
1305 if (freq >= vht80_chan_ranges[i].freq_start && in is_vht80_valid_freq()
1306 freq < vht80_chan_ranges[i].freq_end) in is_vht80_valid_freq()
1314 uint8_t ieee, uint16_t freq, int8_t maxregpower, uint32_t flags) in addchan() argument
1322 printf("%s: %d of %d: ieee=%d, freq=%d, flags=0x%08x\n", in addchan()
1323 __func__, *nchans, maxchans, ieee, freq, flags); in addchan()
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()
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
1484 int *nchans, uint8_t ieee, uint16_t freq, int8_t maxregpower, in ieee80211_add_channel_cbw() argument
1493 error = addchan(chans, maxchans, nchans, ieee, freq, maxregpower, in ieee80211_add_channel_cbw()
1505 int *nchans, uint8_t ieee, uint16_t freq, int8_t maxregpower, in ieee80211_add_channel() argument
1509 return (ieee80211_add_channel_cbw(chans, maxchans, nchans, ieee, freq, in ieee80211_add_channel()
1514 findchannel(struct ieee80211_channel chans[], int nchans, uint16_t freq, in findchannel() argument
1524 if (c->ic_freq == freq && in findchannel()
1525 (c->ic_flags & IEEE80211_CHAN_ALLTURBO) == flags) in findchannel()
1540 uint16_t freq; in ieee80211_add_channel_ht40() local
1543 freq = ieee80211_ieee2mhz(ieee, flags); in ieee80211_add_channel_ht40()
1550 cent = findchannel(chans, *nchans, freq, flags); in ieee80211_add_channel_ht40()
1554 extc = findchannel(chans, *nchans, freq + 20, flags); 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()
1577 return (c->ic_freq); in ieee80211_get_channel_center_freq()
1597 * VHT - use the pre-calculated centre frequency 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()
1634 uint16_t freq; in add_chanlist() local
1639 freq = ieee80211_ieee2mhz(ieee[i], flags[0]); in add_chanlist()
1655 if (! is_vht160_valid_freq(freq)) in add_chanlist()
1669 if (! is_vht80_valid_freq(freq)) in add_chanlist()
1692 freq - 20 != in add_chanlist()
1693 ieee80211_ieee2mhz(ieee[i] - 4, flags[j])) in add_chanlist()
1707 if (i == nieee - 1 || in add_chanlist()
1708 ieee[i] + 4 > ieee[nieee - 1] || in add_chanlist()
1709 freq + 20 != in add_chanlist()
1715 ieee[i], freq, 0, flags[j]); in add_chanlist()
1759 * XXX-BZ with HT and VHT there is no 1:1 mapping anymore. Review all in ieee80211_add_channel_list_5ghz()
1773 * channels--as happens with dynamic turbo.
1776 ieee80211_find_channel(struct ieee80211com *ic, int freq, int flags) in ieee80211_find_channel() argument
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()
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()
1824 * like. It also doesn't know about legacy-turbog and
1825 * legacy-turbo modes, which some offload NICs actually
1837 struct ieee80211com *ic = vap->iv_ic; in ieee80211_lookup_channel_rxstatus()
1845 * Strictly speaking we only use freq for now, 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()
1857 * If the rx status contains a valid ieee/freq, then 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()
1882 c = ieee80211_find_channel(ic, rxs->c_freq, flags); in ieee80211_lookup_channel_rxstatus()
1885 "%s: freq=%d, ieee=%d, flags=0x%08x; c=%p\n", in ieee80211_lookup_channel_rxstatus()
1886 __func__, (int) rxs->c_freq, (int) rxs->c_ieee, flags, c); in ieee80211_lookup_channel_rxstatus()
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()
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()
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()
2096 printf("Chan Freq CW RegPwr MinPwr MaxPwr\n"); in ieee80211_announce_channels()
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()
2217 switch (opmode) { in media_status()
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()
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()
2313 * select a new default/current channel if the current one is
2326 ieee80211_setbasicrates(&ic->ic_sup_rates[mode], mode); in ieee80211_setmode()
2328 ic->ic_curmode = mode; in ieee80211_setmode()
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()
2556 switch (mode) { in ieee80211_rate2media()
2573 if (ic != NULL && ic->ic_phytype == IEEE80211_T_FH) in ieee80211_rate2media()
2594 -1, /* IFM_AUTO */ 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()