Lines Matching +full:hw +full:- +full:channels

1 /*-
2 * Copyright (c) 2020-2024 The FreeBSD Foundation
3 * Copyright (c) 2020-2024 Bjoern A. Zeeb
37 * for these (e.g., struct hw -> struct lkpi_hw, struct sta -> struct lkpi_sta).
39 * We call the internal versions lxxx (e.g., hw -> lhw, sta -> lsta).
82 /* XXX-BZ really want this and others in queue.h */
84 (elm)->field.tqe_next = NULL; \
85 (elm)->field.tqe_prev = NULL; \
88 /* -------------------------------------------------------------------------- */
102 printf("XXX-TODO %s:%d: UNIMPLEMENTED\n", __func__, __LINE__)
104 printf("XXX-TODO %s:%d: TRACEPOINT\n", __func__, __LINE__)
118 /* IEEE 802.11-05/0257r1 */
121 /* IEEE 802.11e Table 20i-UP-to-AC mappings. */
165 if ((ni->ni_flags & IEEE80211_NODE_HT) == 0) in lkpi_sta_sync_ht_from_ni()
168 if (IEEE80211_IS_CHAN_HT(ni->ni_chan) && in lkpi_sta_sync_ht_from_ni()
169 IEEE80211_IS_CHAN_HT40(ni->ni_chan)) in lkpi_sta_sync_ht_from_ni()
170 sta->deflink.bandwidth = IEEE80211_STA_RX_BW_40; in lkpi_sta_sync_ht_from_ni()
172 sta->deflink.ht_cap.ht_supported = true; in lkpi_sta_sync_ht_from_ni()
174 /* htcap->ampdu_params_info */ in lkpi_sta_sync_ht_from_ni()
175 vap = ni->ni_vap; in lkpi_sta_sync_ht_from_ni()
176 …sta->deflink.ht_cap.ampdu_density = _IEEE80211_MASKSHIFT(ni->ni_htparam, IEEE80211_HTCAP_MPDUDENSI… in lkpi_sta_sync_ht_from_ni()
177 if (sta->deflink.ht_cap.ampdu_density > vap->iv_ampdu_density) in lkpi_sta_sync_ht_from_ni()
178 sta->deflink.ht_cap.ampdu_density = vap->iv_ampdu_density; in lkpi_sta_sync_ht_from_ni()
179 …sta->deflink.ht_cap.ampdu_factor = _IEEE80211_MASKSHIFT(ni->ni_htparam, IEEE80211_HTCAP_MAXRXAMPDU… in lkpi_sta_sync_ht_from_ni()
180 if (sta->deflink.ht_cap.ampdu_factor > vap->iv_ampdu_rxmax) in lkpi_sta_sync_ht_from_ni()
181 sta->deflink.ht_cap.ampdu_factor = vap->iv_ampdu_rxmax; in lkpi_sta_sync_ht_from_ni()
183 ie = ni->ni_ies.htcap_ie; in lkpi_sta_sync_ht_from_ni()
189 sta->deflink.ht_cap.cap = htcap->cap_info; in lkpi_sta_sync_ht_from_ni()
190 sta->deflink.ht_cap.mcs = htcap->mcs; in lkpi_sta_sync_ht_from_ni()
193 for (i = 0; i < nitems(htcap->mcs.rx_mask); i++) { in lkpi_sta_sync_ht_from_ni()
194 if (htcap->mcs.rx_mask[i]) in lkpi_sta_sync_ht_from_ni()
200 IMPROVE("sta->wme, sta->deflink.agg.max*"); in lkpi_sta_sync_ht_from_ni()
209 if ((ni->ni_flags & IEEE80211_NODE_VHT) == 0) in lkpi_sta_sync_vht_from_ni()
212 if (IEEE80211_IS_CHAN_VHT(ni->ni_chan)) { in lkpi_sta_sync_vht_from_ni()
214 if (IEEE80211_IS_CHAN_VHT80P80(ni->ni_chan)) { in lkpi_sta_sync_vht_from_ni()
215 sta->deflink.bandwidth = IEEE80211_STA_RX_BW_160; /* XXX? */ in lkpi_sta_sync_vht_from_ni()
218 if (IEEE80211_IS_CHAN_VHT160(ni->ni_chan)) in lkpi_sta_sync_vht_from_ni()
219 sta->deflink.bandwidth = IEEE80211_STA_RX_BW_160; in lkpi_sta_sync_vht_from_ni()
220 else if (IEEE80211_IS_CHAN_VHT80(ni->ni_chan)) in lkpi_sta_sync_vht_from_ni()
221 sta->deflink.bandwidth = IEEE80211_STA_RX_BW_80; in lkpi_sta_sync_vht_from_ni()
241 _f, _l, lsta, ni, &lsta->sta); in lkpi_lsta_dump()
244 printf("\ttxq_task txq len %d mtx\n", mbufq_len(&lsta->txq)); in lkpi_lsta_dump()
246 lsta->kc, lsta->state, lsta->added_to_drv, lsta->in_mgd); in lkpi_lsta_dump()
256 KASSERT(lsta->lsta_entry.tqe_prev != NULL, in lkpi_lsta_remove()
258 lsta, lsta->lsta_entry.tqe_prev, lsta->ni)); in lkpi_lsta_remove()
259 TAILQ_REMOVE(&lvif->lsta_head, lsta, lsta_entry); in lkpi_lsta_remove()
265 struct ieee80211_hw *hw, struct ieee80211_node *ni) in lkpi_lsta_alloc() argument
275 lsta = malloc(sizeof(*lsta) + hw->sta_data_size, M_LKPI80211, in lkpi_lsta_alloc()
280 lsta->added_to_drv = false; in lkpi_lsta_alloc()
281 lsta->state = IEEE80211_STA_NOTEXIST; in lkpi_lsta_alloc()
291 lsta->ni = ni; in lkpi_lsta_alloc()
292 /* The back-pointer "drv_data" to net80211_node let's us get lsta. */ in lkpi_lsta_alloc()
293 ni->ni_drv_data = lsta; in lkpi_lsta_alloc()
299 IEEE80211_ADDR_COPY(sta->addr, mac); in lkpi_lsta_alloc()
302 for (tid = 0; tid < nitems(sta->txq); tid++) { in lkpi_lsta_alloc()
305 /* We are not limiting ourselves to hw.queues here. */ in lkpi_lsta_alloc()
306 ltxq = malloc(sizeof(*ltxq) + hw->txq_data_size, in lkpi_lsta_alloc()
312 if (!ieee80211_hw_check(hw, STA_MMPDU_TXQ)) { in lkpi_lsta_alloc()
316 IMPROVE("AP/if we support non-STA here too"); in lkpi_lsta_alloc()
317 ltxq->txq.ac = IEEE80211_AC_VO; in lkpi_lsta_alloc()
319 ltxq->txq.ac = ieee80211e_up_to_ac[tid & 7]; in lkpi_lsta_alloc()
321 ltxq->seen_dequeue = false; in lkpi_lsta_alloc()
322 ltxq->stopped = false; in lkpi_lsta_alloc()
323 ltxq->txq.vif = vif; in lkpi_lsta_alloc()
324 ltxq->txq.tid = tid; in lkpi_lsta_alloc()
325 ltxq->txq.sta = sta; in lkpi_lsta_alloc()
327 skb_queue_head_init(&ltxq->skbq); in lkpi_lsta_alloc()
329 sta->txq[tid] = &ltxq->txq; in lkpi_lsta_alloc()
336 supband = hw->wiphy->bands[band]; in lkpi_lsta_alloc()
340 for (i = 0; i < supband->n_bitrates; i++) { in lkpi_lsta_alloc()
342 IMPROVE("Further supband->bitrates[i]* checks?"); in lkpi_lsta_alloc()
344 sta->deflink.supp_rates[band] |= BIT(i); in lkpi_lsta_alloc()
348 sta->deflink.smps_mode = IEEE80211_SMPS_OFF; in lkpi_lsta_alloc()
349 sta->deflink.bandwidth = IEEE80211_STA_RX_BW_20; in lkpi_lsta_alloc()
350 sta->deflink.rx_nss = 1; in lkpi_lsta_alloc()
361 sta->deflink.rx_nss = MAX(ht_rx_nss, sta->deflink.rx_nss); in lkpi_lsta_alloc()
362 sta->deflink.rx_nss = MAX(vht_rx_nss, sta->deflink.rx_nss); in lkpi_lsta_alloc()
366 IEEE80211_ADDR_COPY(sta->deflink.addr, sta->addr); in lkpi_lsta_alloc()
367 sta->link[0] = &sta->deflink; in lkpi_lsta_alloc()
368 for (i = 1; i < nitems(sta->link); i++) { in lkpi_lsta_alloc()
374 TASK_INIT(&lsta->txq_task, 0, lkpi_80211_txq_task, lsta); in lkpi_lsta_alloc()
375 mbufq_init(&lsta->txq, IFQ_MAXLEN); in lkpi_lsta_alloc()
376 lsta->txq_ready = true; in lkpi_lsta_alloc()
381 for (; tid >= 0; tid--) { in lkpi_lsta_alloc()
384 ltxq = TXQ_TO_LTXQ(sta->txq[tid]); in lkpi_lsta_alloc()
386 free(sta->txq[tid], M_LKPI80211); in lkpi_lsta_alloc()
397 if (lsta->added_to_drv) in lkpi_lsta_free()
400 __func__, lsta, ni, lsta->added_to_drv); in lkpi_lsta_free()
402 /* XXX-BZ free resources, ... */ in lkpi_lsta_free()
405 /* Drain sta->txq[] */ in lkpi_lsta_free()
408 lsta->txq_ready = false; in lkpi_lsta_free()
412 while (taskqueue_cancel(taskqueue_thread, &lsta->txq_task, NULL) != 0) in lkpi_lsta_free()
413 taskqueue_drain(taskqueue_thread, &lsta->txq_task); in lkpi_lsta_free()
416 m = mbufq_dequeue(&lsta->txq); in lkpi_lsta_free()
420 nim = (struct ieee80211_node *)m->m_pkthdr.rcvif; in lkpi_lsta_free()
424 m = mbufq_dequeue(&lsta->txq); in lkpi_lsta_free()
426 KASSERT(mbufq_empty(&lsta->txq), ("%s: lsta %p has txq len %d != 0\n", in lkpi_lsta_free()
427 __func__, lsta, mbufq_len(&lsta->txq))); in lkpi_lsta_free()
435 lsta->ni = NULL; in lkpi_lsta_free()
436 ni->ni_drv_data = NULL; in lkpi_lsta_free()
459 __func__, c, c->ic_flags); in lkpi_net80211_chan_to_nl80211_band()
466 /* XXX-BZ this is just silly; net80211 is too convoluted. */ in lkpi_nl80211_band_to_net80211_band()
607 * XXX-BZ The net80211 states are "try to ..", the lkpi8011 states are in lkpi_net80211_state_to_sta_state()
636 struct ieee80211_hw *hw; in lkpi_find_lkpi80211_chan() local
637 struct linuxkpi_ieee80211_channel *channels; in lkpi_find_lkpi80211_chan() local
641 hw = LHW_TO_HW(lhw); in lkpi_find_lkpi80211_chan()
643 if (hw->wiphy->bands[band] == NULL) in lkpi_find_lkpi80211_chan()
646 nchans = hw->wiphy->bands[band]->n_channels; in lkpi_find_lkpi80211_chan()
650 channels = hw->wiphy->bands[band]->channels; in lkpi_find_lkpi80211_chan()
652 if (channels[i].hw_value == c->ic_ieee) in lkpi_find_lkpi80211_chan()
653 return (&channels[i]); in lkpi_find_lkpi80211_chan()
668 if (ni != NULL && ni->ni_chan != IEEE80211_CHAN_ANYC)
669 c = ni->ni_chan;
670 else if (ic->ic_bsschan != IEEE80211_CHAN_ANYC)
671 c = ic->ic_bsschan;
672 else if (ic->ic_curchan != IEEE80211_CHAN_ANYC)
673 c = ic->ic_curchan;
678 lhw = ic->ic_softc;
693 struct linuxkpi_ieee80211_channel *channels; in linuxkpi_ieee80211_get_channel() local
696 supband = wiphy->bands[band]; in linuxkpi_ieee80211_get_channel()
697 if (supband == NULL || supband->n_channels == 0) in linuxkpi_ieee80211_get_channel()
700 channels = supband->channels; in linuxkpi_ieee80211_get_channel()
701 for (i = 0; i < supband->n_channels; i++) { in linuxkpi_ieee80211_get_channel()
702 if (channels[i].center_freq == freq) in linuxkpi_ieee80211_get_channel()
703 return (&channels[i]); in linuxkpi_ieee80211_get_channel()
717 struct ieee80211_hw *hw; in _lkpi_iv_key_set_delete() local
725 /* XXX TODO Check (k->wk_flags & IEEE80211_KEY_SWENCRYPT) and don't upload to driver/hw? */ in _lkpi_iv_key_set_delete()
727 ic = vap->iv_ic; in _lkpi_iv_key_set_delete()
728 lhw = ic->ic_softc; in _lkpi_iv_key_set_delete()
729 hw = LHW_TO_HW(lhw); in _lkpi_iv_key_set_delete()
734 kc = malloc(sizeof(*kc) + k->wk_keylen, M_LKPI80211, M_WAITOK | M_ZERO); in _lkpi_iv_key_set_delete()
735 kc->cipher = lkpi_net80211_to_l80211_cipher_suite( in _lkpi_iv_key_set_delete()
736 k->wk_cipher->ic_cipher, k->wk_keylen); in _lkpi_iv_key_set_delete()
737 kc->keyidx = k->wk_keyix; in _lkpi_iv_key_set_delete()
739 kc->hw_key_idx = /* set by hw and needs to be passed for TX */; in _lkpi_iv_key_set_delete()
741 atomic64_set(&kc->tx_pn, k->wk_keytsc); in _lkpi_iv_key_set_delete()
742 kc->keylen = k->wk_keylen; in _lkpi_iv_key_set_delete()
743 memcpy(kc->key, k->wk_key, k->wk_keylen); in _lkpi_iv_key_set_delete()
745 switch (kc->cipher) { in _lkpi_iv_key_set_delete()
747 kc->iv_len = k->wk_cipher->ic_header; in _lkpi_iv_key_set_delete()
748 kc->icv_len = k->wk_cipher->ic_trailer; in _lkpi_iv_key_set_delete()
756 ni = vap->iv_bss; in _lkpi_iv_key_set_delete()
757 sta = ieee80211_find_sta(vif, ni->ni_bssid); in _lkpi_iv_key_set_delete()
762 lsta->kc = kc; in _lkpi_iv_key_set_delete()
765 error = lkpi_80211_mo_set_key(hw, cmd, vif, sta, kc); in _lkpi_iv_key_set_delete()
767 /* XXX-BZ leaking kc currently */ in _lkpi_iv_key_set_delete()
773 kc->keyidx, kc->hw_key_idx, kc->flags); in _lkpi_iv_key_set_delete()
782 /* XXX-BZ one day we should replace this iterating over VIFs, or node list? */ in lkpi_iv_key_delete()
805 if (!memcmp(addr->addr, LLADDR(sdl), sdl->sdl_alen)) in lkpi_ic_update_mcast_copy()
813 INIT_LIST_HEAD(&addr->addr_list); in lkpi_ic_update_mcast_copy()
814 memcpy(addr->addr, LLADDR(sdl), sdl->sdl_alen); in lkpi_ic_update_mcast_copy()
816 list_add(&addr->addr_list, &mc_list->addr_list); in lkpi_ic_update_mcast_copy()
817 mc_list->count++; in lkpi_ic_update_mcast_copy()
822 __func__, __LINE__, mc_list->count, addr->addr, ":"); in lkpi_ic_update_mcast_copy()
832 struct ieee80211_hw *hw; in lkpi_update_mcast_filter() local
840 lhw = ic->ic_softc; in lkpi_update_mcast_filter()
842 if (lhw->ops->prepare_multicast == NULL || in lkpi_update_mcast_filter()
843 lhw->ops->configure_filter == NULL) in lkpi_update_mcast_filter()
846 if (!lhw->update_mc && !force) in lkpi_update_mcast_filter()
852 if (ic->ic_allmulti == 0) { in lkpi_update_mcast_filter()
853 TAILQ_FOREACH(vap, &ic->ic_vaps, iv_next) in lkpi_update_mcast_filter()
854 if_foreach_llmaddr(vap->iv_ifp, in lkpi_update_mcast_filter()
860 hw = LHW_TO_HW(lhw); in lkpi_update_mcast_filter()
861 mc = lkpi_80211_mo_prepare_multicast(hw, &mc_list); in lkpi_update_mcast_filter()
863 * XXX-BZ make sure to get this sorted what is a change, in lkpi_update_mcast_filter()
867 lkpi_80211_mo_configure_filter(hw, changed_flags, &total_flags, mc); in lkpi_update_mcast_filter()
879 mc_list.count--; in lkpi_update_mcast_filter()
900 vif->cfg.assoc, vif->cfg.aid, in lkpi_update_dtim_tsf()
901 vif->bss_conf.beacon_int, vif->bss_conf.dtim_period, in lkpi_update_dtim_tsf()
902 vif->bss_conf.sync_dtim_count, in lkpi_update_dtim_tsf()
903 (uintmax_t)vif->bss_conf.sync_tsf, in lkpi_update_dtim_tsf()
904 vif->bss_conf.sync_device_ts, in lkpi_update_dtim_tsf()
908 if (vif->bss_conf.beacon_int != ni->ni_intval) { in lkpi_update_dtim_tsf()
909 vif->bss_conf.beacon_int = ni->ni_intval; in lkpi_update_dtim_tsf()
911 if (vif->bss_conf.beacon_int < 16) in lkpi_update_dtim_tsf()
912 vif->bss_conf.beacon_int = 16; in lkpi_update_dtim_tsf()
915 if (vif->bss_conf.dtim_period != vap->iv_dtim_period && in lkpi_update_dtim_tsf()
916 vap->iv_dtim_period > 0) { in lkpi_update_dtim_tsf()
917 vif->bss_conf.dtim_period = vap->iv_dtim_period; in lkpi_update_dtim_tsf()
921 vif->bss_conf.sync_dtim_count = vap->iv_dtim_count; in lkpi_update_dtim_tsf()
922 vif->bss_conf.sync_tsf = le64toh(ni->ni_tstamp.tsf); in lkpi_update_dtim_tsf()
923 /* vif->bss_conf.sync_device_ts = set in linuxkpi_ieee80211_rx. */ in lkpi_update_dtim_tsf()
931 vif->cfg.assoc, vif->cfg.aid, in lkpi_update_dtim_tsf()
932 vif->bss_conf.beacon_int, vif->bss_conf.dtim_period, in lkpi_update_dtim_tsf()
933 vif->bss_conf.sync_dtim_count, in lkpi_update_dtim_tsf()
934 (uintmax_t)vif->bss_conf.sync_tsf, in lkpi_update_dtim_tsf()
935 vif->bss_conf.sync_device_ts, in lkpi_update_dtim_tsf()
945 struct ieee80211_hw *hw; in lkpi_stop_hw_scan() local
950 cancel = (lhw->scan_flags & LKPI_LHW_SCAN_RUNNING) != 0; in lkpi_stop_hw_scan()
955 hw = LHW_TO_HW(lhw); in lkpi_stop_hw_scan()
957 IEEE80211_UNLOCK(lhw->ic); in lkpi_stop_hw_scan()
960 lkpi_80211_mo_cancel_hw_scan(hw, vif); in lkpi_stop_hw_scan()
965 if ((lhw->scan_flags & LKPI_LHW_SCAN_RUNNING) != 0) in lkpi_stop_hw_scan()
966 error = msleep(lhw, &lhw->scan_mtx, 0, "lhwscanstop", hz/2); in lkpi_stop_hw_scan()
967 cancel = (lhw->scan_flags & LKPI_LHW_SCAN_RUNNING) != 0; in lkpi_stop_hw_scan()
970 IEEE80211_LOCK(lhw->ic); in lkpi_stop_hw_scan()
973 ic_printf(lhw->ic, "%s: failed to cancel scan: %d (%p, %p)\n", in lkpi_stop_hw_scan()
978 lkpi_hw_conf_idle(struct ieee80211_hw *hw, bool new) in lkpi_hw_conf_idle() argument
984 old = hw->conf.flags & IEEE80211_CONF_IDLE; in lkpi_hw_conf_idle()
988 hw->conf.flags ^= IEEE80211_CONF_IDLE; in lkpi_hw_conf_idle()
989 error = lkpi_80211_mo_config(hw, IEEE80211_CONF_CHANGE_IDLE); in lkpi_hw_conf_idle()
991 lhw = HW_TO_LHW(hw); in lkpi_hw_conf_idle()
992 ic_printf(lhw->ic, "ERROR: %s: config %#0x returned %d\n", in lkpi_hw_conf_idle()
1004 sta->aid = 0; in lkpi_disassoc()
1005 if (vif->cfg.assoc) { in lkpi_disassoc()
1007 lhw->update_mc = true; in lkpi_disassoc()
1008 lkpi_update_mcast_filter(lhw->ic, true); in lkpi_disassoc()
1010 vif->cfg.assoc = false; in lkpi_disassoc()
1011 vif->cfg.aid = 0; in lkpi_disassoc()
1031 lkpi_wake_tx_queues(struct ieee80211_hw *hw, struct ieee80211_sta *sta, in lkpi_wake_tx_queues() argument
1039 for (tid = 0; tid < nitems(sta->txq); tid++) { in lkpi_wake_tx_queues()
1043 if (!ieee80211_hw_check(hw, STA_MMPDU_TXQ)) in lkpi_wake_tx_queues()
1045 } else if (tid >= hw->queues) in lkpi_wake_tx_queues()
1048 if (sta->txq[tid] == NULL) in lkpi_wake_tx_queues()
1051 ltxq = TXQ_TO_LTXQ(sta->txq[tid]); in lkpi_wake_tx_queues()
1052 if (dequeue_seen && !ltxq->seen_dequeue) in lkpi_wake_tx_queues()
1056 ltxq_empty = skb_queue_empty(&ltxq->skbq); in lkpi_wake_tx_queues()
1061 lkpi_80211_mo_wake_tx_queue(hw, sta->txq[tid]); in lkpi_wake_tx_queues()
1066 * On the way down from RUN -> ASSOC -> AUTH we may send a DISASSOC or DEAUTH
1072 * send it. scan_to_auth() would re-enable sending if the lsta would be
1073 * re-used.
1086 lsta->txq_ready = false; in lkpi_80211_flush_tx()
1089 while (taskqueue_cancel(taskqueue_thread, &lsta->txq_task, NULL) != 0) in lkpi_80211_flush_tx()
1090 taskqueue_drain(taskqueue_thread, &lsta->txq_task); in lkpi_80211_flush_tx()
1093 len = mbufq_len(&lsta->txq); in lkpi_80211_flush_tx()
1100 mbufq_concat(&mq, &lsta->txq); in lkpi_80211_flush_tx()
1110 /* -------------------------------------------------------------------------- */
1129 struct ieee80211_hw *hw; in lkpi_sta_scan_to_auth() local
1140 * In here we use vap->iv_bss until lvif->lvif_bss is set. in lkpi_sta_scan_to_auth()
1145 if (vap->iv_bss == NULL) { in lkpi_sta_scan_to_auth()
1146 ic_printf(vap->iv_ic, "%s: no iv_bss for vap %p\n", __func__, vap); in lkpi_sta_scan_to_auth()
1155 ni = ieee80211_ref_node(vap->iv_bss); in lkpi_sta_scan_to_auth()
1156 if (ni->ni_chan == NULL || ni->ni_chan == IEEE80211_CHAN_ANYC) { in lkpi_sta_scan_to_auth()
1157 ic_printf(vap->iv_ic, "%s: no channel set for iv_bss ni %p " in lkpi_sta_scan_to_auth()
1163 lhw = vap->iv_ic->ic_softc; in lkpi_sta_scan_to_auth()
1164 chan = lkpi_find_lkpi80211_chan(lhw, ni->ni_chan); in lkpi_sta_scan_to_auth()
1166 ic_printf(vap->iv_ic, "%s: failed to get LKPI channel from " in lkpi_sta_scan_to_auth()
1172 hw = LHW_TO_HW(lhw); in lkpi_sta_scan_to_auth()
1177 /* XXX-BZ KASSERT later? */ in lkpi_sta_scan_to_auth()
1178 if (lvif->lvif_bss_synched || lvif->lvif_bss != NULL) { in lkpi_sta_scan_to_auth()
1179 ic_printf(vap->iv_ic, "%s:%d: lvif %p vap %p iv_bss %p lvif_bss %p " in lkpi_sta_scan_to_auth()
1180 "lvif_bss->ni %p synched %d\n", __func__, __LINE__, in lkpi_sta_scan_to_auth()
1181 lvif, vap, vap->iv_bss, lvif->lvif_bss, in lkpi_sta_scan_to_auth()
1182 (lvif->lvif_bss != NULL) ? lvif->lvif_bss->ni : NULL, in lkpi_sta_scan_to_auth()
1183 lvif->lvif_bss_synched); in lkpi_sta_scan_to_auth()
1188 IEEE80211_UNLOCK(vap->iv_ic); in lkpi_sta_scan_to_auth()
1192 if (vif->chanctx_conf != NULL) { in lkpi_sta_scan_to_auth()
1193 chanctx_conf = vif->chanctx_conf; in lkpi_sta_scan_to_auth()
1198 lchanctx = malloc(sizeof(*lchanctx) + hw->chanctx_data_size, in lkpi_sta_scan_to_auth()
1200 chanctx_conf = &lchanctx->chanctx_conf; in lkpi_sta_scan_to_auth()
1203 chanctx_conf->rx_chains_dynamic = 1; in lkpi_sta_scan_to_auth()
1204 chanctx_conf->rx_chains_static = 1; in lkpi_sta_scan_to_auth()
1205 chanctx_conf->radar_enabled = in lkpi_sta_scan_to_auth()
1206 (chan->flags & IEEE80211_CHAN_RADAR) ? true : false; in lkpi_sta_scan_to_auth()
1207 chanctx_conf->def.chan = chan; in lkpi_sta_scan_to_auth()
1208 chanctx_conf->def.width = NL80211_CHAN_WIDTH_20_NOHT; in lkpi_sta_scan_to_auth()
1209 chanctx_conf->def.center_freq1 = chan->center_freq; in lkpi_sta_scan_to_auth()
1210 chanctx_conf->def.center_freq2 = 0; in lkpi_sta_scan_to_auth()
1212 KASSERT(ni->ni_chan != NULL && ni->ni_chan != IEEE80211_CHAN_ANYC, in lkpi_sta_scan_to_auth()
1213 ("%s:%d: ni %p ni_chan %p\n", __func__, __LINE__, ni, ni->ni_chan)); in lkpi_sta_scan_to_auth()
1215 if (IEEE80211_IS_CHAN_HT(ni->ni_chan)) { in lkpi_sta_scan_to_auth()
1216 if (IEEE80211_IS_CHAN_HT40(ni->ni_chan)) { in lkpi_sta_scan_to_auth()
1217 chanctx_conf->def.width = NL80211_CHAN_WIDTH_40; in lkpi_sta_scan_to_auth()
1219 chanctx_conf->def.width = NL80211_CHAN_WIDTH_20; in lkpi_sta_scan_to_auth()
1223 if (IEEE80211_IS_CHAN_VHT(ni->ni_chan)) { in lkpi_sta_scan_to_auth()
1225 if (IEEE80211_IS_CHAN_VHT80P80(ni->ni_chan)) { in lkpi_sta_scan_to_auth()
1226 chanctx_conf->def.width = NL80211_CHAN_WIDTH_80P80; in lkpi_sta_scan_to_auth()
1227 chanctx_conf->def.center_freq2 = 0; /* XXX */ in lkpi_sta_scan_to_auth()
1230 if (IEEE80211_IS_CHAN_VHT160(ni->ni_chan)) in lkpi_sta_scan_to_auth()
1231 chanctx_conf->def.width = NL80211_CHAN_WIDTH_160; in lkpi_sta_scan_to_auth()
1232 else if (IEEE80211_IS_CHAN_VHT80(ni->ni_chan)) in lkpi_sta_scan_to_auth()
1233 chanctx_conf->def.width = NL80211_CHAN_WIDTH_80; in lkpi_sta_scan_to_auth()
1237 chanctx_conf->min_def.chan = chan; in lkpi_sta_scan_to_auth()
1238 chanctx_conf->min_def.width = NL80211_CHAN_WIDTH_20_NOHT; in lkpi_sta_scan_to_auth()
1239 chanctx_conf->min_def.center_freq1 = chan->center_freq; in lkpi_sta_scan_to_auth()
1240 chanctx_conf->min_def.center_freq2 = 0; in lkpi_sta_scan_to_auth()
1245 vif->bss_conf.bssid = ni->ni_bssid; in lkpi_sta_scan_to_auth()
1247 vif->bss_conf.txpower = ni->ni_txpower; in lkpi_sta_scan_to_auth()
1249 vif->cfg.idle = false; in lkpi_sta_scan_to_auth()
1252 /* vif->bss_conf.basic_rates ? Where exactly? */ in lkpi_sta_scan_to_auth()
1255 vif->cfg.assoc = false; in lkpi_sta_scan_to_auth()
1256 vif->cfg.aid = 0; in lkpi_sta_scan_to_auth()
1261 if (vif->chanctx_conf != NULL) { in lkpi_sta_scan_to_auth()
1266 lkpi_80211_mo_change_chanctx(hw, chanctx_conf, changed); in lkpi_sta_scan_to_auth()
1268 error = lkpi_80211_mo_add_chanctx(hw, chanctx_conf); in lkpi_sta_scan_to_auth()
1270 vif->bss_conf.chanreq.oper.chan = chanctx_conf->def.chan; in lkpi_sta_scan_to_auth()
1271 vif->bss_conf.chanreq.oper.width = chanctx_conf->def.width; in lkpi_sta_scan_to_auth()
1272 vif->bss_conf.chanreq.oper.center_freq1 = in lkpi_sta_scan_to_auth()
1273 chanctx_conf->def.center_freq1; in lkpi_sta_scan_to_auth()
1275 if (vif->bss_conf.chandef.width == NL80211_CHAN_WIDTH_40) { in lkpi_sta_scan_to_auth()
1277 if (IEEE80211_IS_CHAN_HT40U(ni->ni_chan)) in lkpi_sta_scan_to_auth()
1278 vif->bss_conf.chandef.center_freq1 += 10; in lkpi_sta_scan_to_auth()
1279 else if (IEEE80211_IS_CHAN_HT40D(ni->ni_chan)) in lkpi_sta_scan_to_auth()
1280 vif->bss_conf.chandef.center_freq1 -= 10; in lkpi_sta_scan_to_auth()
1283 vif->bss_conf.chanreq.oper.center_freq2 = in lkpi_sta_scan_to_auth()
1284 chanctx_conf->def.center_freq2; in lkpi_sta_scan_to_auth()
1286 ic_printf(vap->iv_ic, "%s:%d: mo_add_chanctx " in lkpi_sta_scan_to_auth()
1291 vif->bss_conf.chanctx_conf = chanctx_conf; in lkpi_sta_scan_to_auth()
1295 error = lkpi_80211_mo_assign_vif_chanctx(hw, vif, in lkpi_sta_scan_to_auth()
1296 &vif->bss_conf, chanctx_conf); in lkpi_sta_scan_to_auth()
1300 ic_printf(vap->iv_ic, "%s:%d: mo_assign_vif_chanctx " in lkpi_sta_scan_to_auth()
1302 lkpi_80211_mo_remove_chanctx(hw, chanctx_conf); in lkpi_sta_scan_to_auth()
1312 lkpi_80211_mo_bss_info_changed(hw, vif, &vif->bss_conf, bss_changed); in lkpi_sta_scan_to_auth()
1319 KASSERT(ni->ni_drv_data != NULL, ("%s: ni %p ni_drv_data %p\n", in lkpi_sta_scan_to_auth()
1320 __func__, ni, ni->ni_drv_data)); in lkpi_sta_scan_to_auth()
1321 lsta = ni->ni_drv_data; in lkpi_sta_scan_to_auth()
1324 * Make sure in case the sta did not change and we re-add it, in lkpi_sta_scan_to_auth()
1328 lsta->txq_ready = true; in lkpi_sta_scan_to_auth()
1333 TAILQ_INSERT_TAIL(&lvif->lsta_head, lsta, lsta_entry); in lkpi_sta_scan_to_auth()
1338 KASSERT(lsta->state == IEEE80211_STA_NOTEXIST, ("%s: lsta %p state not " in lkpi_sta_scan_to_auth()
1339 "NOTEXIST: %#x\n", __func__, lsta, lsta->state)); in lkpi_sta_scan_to_auth()
1340 error = lkpi_80211_mo_sta_state(hw, vif, lsta, IEEE80211_STA_NONE); in lkpi_sta_scan_to_auth()
1343 ic_printf(vap->iv_ic, "%s:%d: mo_sta_state(NONE) " in lkpi_sta_scan_to_auth()
1348 lsta->added_to_drv = true; /* mo manages. */ in lkpi_sta_scan_to_auth()
1359 * XXX-BZ and by now we know that this does not work on all drivers in lkpi_sta_scan_to_auth()
1362 lkpi_wake_tx_queues(hw, LSTA_TO_STA(lsta), false, false); in lkpi_sta_scan_to_auth()
1368 lkpi_80211_mo_mgd_prepare_tx(hw, vif, &prep_tx_info); in lkpi_sta_scan_to_auth()
1369 lsta->in_mgd = true; in lkpi_sta_scan_to_auth()
1373 * - <twiddle> .. we should end up in "auth_to_assoc" in lkpi_sta_scan_to_auth()
1374 * - event_callback in lkpi_sta_scan_to_auth()
1375 * - update sta_state (NONE to AUTH) in lkpi_sta_scan_to_auth()
1376 * - mgd_complete_tx in lkpi_sta_scan_to_auth()
1381 IEEE80211_LOCK(vap->iv_ic); in lkpi_sta_scan_to_auth()
1384 /* Re-check given (*iv_update_bss) could have happened while we were unlocked. */ in lkpi_sta_scan_to_auth()
1385 if (lvif->lvif_bss_synched || lvif->lvif_bss != NULL || in lkpi_sta_scan_to_auth()
1386 lsta->ni != vap->iv_bss) in lkpi_sta_scan_to_auth()
1387 ic_printf(vap->iv_ic, "%s:%d: lvif %p vap %p iv_bss %p lvif_bss %p " in lkpi_sta_scan_to_auth()
1388 "lvif_bss->ni %p synched %d, ni %p lsta %p\n", __func__, __LINE__, in lkpi_sta_scan_to_auth()
1389 lvif, vap, vap->iv_bss, lvif->lvif_bss, in lkpi_sta_scan_to_auth()
1390 (lvif->lvif_bss != NULL) ? lvif->lvif_bss->ni : NULL, in lkpi_sta_scan_to_auth()
1391 lvif->lvif_bss_synched, ni, lsta); in lkpi_sta_scan_to_auth()
1394 * Reference the "ni" for caching the lsta/ni in lvif->lvif_bss. in lkpi_sta_scan_to_auth()
1395 * Given we cache lsta we use lsta->ni instead of ni here (even though in lkpi_sta_scan_to_auth()
1396 * lsta->ni == ni) to be distinct from the rest of the code where we do in lkpi_sta_scan_to_auth()
1397 * assume that ni == vap->iv_bss which it may or may not be. in lkpi_sta_scan_to_auth()
1403 ieee80211_ref_node(lsta->ni); in lkpi_sta_scan_to_auth()
1404 lvif->lvif_bss = lsta; in lkpi_sta_scan_to_auth()
1405 if (lsta->ni == vap->iv_bss) { in lkpi_sta_scan_to_auth()
1406 lvif->lvif_bss_synched = true; in lkpi_sta_scan_to_auth()
1408 /* Set to un-synched no matter what. */ in lkpi_sta_scan_to_auth()
1409 lvif->lvif_bss_synched = false; in lkpi_sta_scan_to_auth()
1414 * will take the lvif->lvif_bss node down eventually. in lkpi_sta_scan_to_auth()
1415 * What happens with the vap->iv_bss node will entirely be up in lkpi_sta_scan_to_auth()
1426 IEEE80211_LOCK(vap->iv_ic); in lkpi_sta_scan_to_auth()
1441 struct ieee80211_hw *hw; in lkpi_sta_auth_to_scan() local
1450 lhw = vap->iv_ic->ic_softc; in lkpi_sta_auth_to_scan()
1451 hw = LHW_TO_HW(lhw); in lkpi_sta_auth_to_scan()
1457 /* XXX-BZ KASSERT later; state going down so no action. */ in lkpi_sta_auth_to_scan()
1458 if (lvif->lvif_bss == NULL) in lkpi_sta_auth_to_scan()
1459 ic_printf(vap->iv_ic, "%s:%d: lvif %p vap %p iv_bss %p lvif_bss %p " in lkpi_sta_auth_to_scan()
1460 "lvif_bss->ni %p synched %d\n", __func__, __LINE__, in lkpi_sta_auth_to_scan()
1461 lvif, vap, vap->iv_bss, lvif->lvif_bss, in lkpi_sta_auth_to_scan()
1462 (lvif->lvif_bss != NULL) ? lvif->lvif_bss->ni : NULL, in lkpi_sta_auth_to_scan()
1463 lvif->lvif_bss_synched); in lkpi_sta_auth_to_scan()
1466 lsta = lvif->lvif_bss; in lkpi_sta_auth_to_scan()
1468 KASSERT(lsta != NULL && lsta->ni != NULL, ("%s: lsta %p ni %p " in lkpi_sta_auth_to_scan()
1470 lsta, (lsta != NULL) ? lsta->ni : NULL, lvif, vap)); in lkpi_sta_auth_to_scan()
1471 ni = lsta->ni; /* Reference held for lvif_bss. */ in lkpi_sta_auth_to_scan()
1476 IEEE80211_UNLOCK(vap->iv_ic); in lkpi_sta_auth_to_scan()
1480 lkpi_80211_mo_flush(hw, vif, nitems(sta->txq), true); in lkpi_sta_auth_to_scan()
1483 lkpi_wake_tx_queues(hw, sta, false, true); in lkpi_sta_auth_to_scan()
1486 lkpi_80211_mo_flush(hw, vif, nitems(sta->txq), false); in lkpi_sta_auth_to_scan()
1489 if (lsta->in_mgd) { in lkpi_sta_auth_to_scan()
1492 lkpi_80211_mo_mgd_complete_tx(hw, vif, &prep_tx_info); in lkpi_sta_auth_to_scan()
1493 lsta->in_mgd = false; in lkpi_sta_auth_to_scan()
1497 lkpi_80211_mo_sync_rx_queues(hw); in lkpi_sta_auth_to_scan()
1500 lkpi_80211_mo_sta_pre_rcu_remove(hw, vif, sta); in lkpi_sta_auth_to_scan()
1506 KASSERT(lsta->state == IEEE80211_STA_NONE, ("%s: lsta %p state not " in lkpi_sta_auth_to_scan()
1507 "NONE: %#x, nstate %d arg %d\n", __func__, lsta, lsta->state, nstate, arg)); in lkpi_sta_auth_to_scan()
1508 error = lkpi_80211_mo_sta_state(hw, vif, lsta, IEEE80211_STA_NOTEXIST); in lkpi_sta_auth_to_scan()
1511 ic_printf(vap->iv_ic, "%s:%d: mo_sta_state(NOTEXIST) " in lkpi_sta_auth_to_scan()
1516 lsta->added_to_drv = false; /* mo manages. */ in lkpi_sta_auth_to_scan()
1523 lvif->lvif_bss = NULL; in lkpi_sta_auth_to_scan()
1524 lvif->lvif_bss_synched = false; in lkpi_sta_auth_to_scan()
1529 * lvif->lvif_bss. Upon return from this both ni and lsta are invalid in lkpi_sta_auth_to_scan()
1537 if (vif->chanctx_conf != NULL) { in lkpi_sta_auth_to_scan()
1541 chanctx_conf = vif->chanctx_conf; in lkpi_sta_auth_to_scan()
1543 lkpi_80211_mo_unassign_vif_chanctx(hw, vif, &vif->bss_conf, &vif->chanctx_conf); in lkpi_sta_auth_to_scan()
1544 /* NB: vif->chanctx_conf is NULL now. */ in lkpi_sta_auth_to_scan()
1546 lkpi_hw_conf_idle(hw, true); in lkpi_sta_auth_to_scan()
1549 lkpi_80211_mo_remove_chanctx(hw, chanctx_conf); in lkpi_sta_auth_to_scan()
1556 IEEE80211_LOCK(vap->iv_ic); in lkpi_sta_auth_to_scan()
1575 struct ieee80211_hw *hw; in lkpi_sta_auth_to_assoc() local
1582 lhw = vap->iv_ic->ic_softc; in lkpi_sta_auth_to_assoc()
1583 hw = LHW_TO_HW(lhw); in lkpi_sta_auth_to_assoc()
1587 IEEE80211_UNLOCK(vap->iv_ic); in lkpi_sta_auth_to_assoc()
1591 /* XXX-BZ KASSERT later? */ in lkpi_sta_auth_to_assoc()
1592 if (!lvif->lvif_bss_synched || lvif->lvif_bss == NULL) { in lkpi_sta_auth_to_assoc()
1594 ic_printf(vap->iv_ic, "%s:%d: lvif %p vap %p iv_bss %p lvif_bss %p " in lkpi_sta_auth_to_assoc()
1595 "lvif_bss->ni %p synched %d\n", __func__, __LINE__, in lkpi_sta_auth_to_assoc()
1596 lvif, vap, vap->iv_bss, lvif->lvif_bss, in lkpi_sta_auth_to_assoc()
1597 (lvif->lvif_bss != NULL) ? lvif->lvif_bss->ni : NULL, in lkpi_sta_auth_to_assoc()
1598 lvif->lvif_bss_synched); in lkpi_sta_auth_to_assoc()
1604 lsta = lvif->lvif_bss; in lkpi_sta_auth_to_assoc()
1613 KASSERT(lsta->state == IEEE80211_STA_NONE, ("%s: lsta %p state not " in lkpi_sta_auth_to_assoc()
1614 "NONE: %#x\n", __func__, lsta, lsta->state)); in lkpi_sta_auth_to_assoc()
1615 error = lkpi_80211_mo_sta_state(hw, vif, lsta, IEEE80211_STA_AUTH); in lkpi_sta_auth_to_assoc()
1617 ic_printf(vap->iv_ic, "%s:%d: mo_sta_state(AUTH) " in lkpi_sta_auth_to_assoc()
1623 if (lsta->in_mgd) { in lkpi_sta_auth_to_assoc()
1626 lkpi_80211_mo_mgd_complete_tx(hw, vif, &prep_tx_info); in lkpi_sta_auth_to_assoc()
1627 lsta->in_mgd = false; in lkpi_sta_auth_to_assoc()
1633 if (!lsta->in_mgd) { in lkpi_sta_auth_to_assoc()
1636 lkpi_80211_mo_mgd_prepare_tx(hw, vif, &prep_tx_info); in lkpi_sta_auth_to_assoc()
1637 lsta->in_mgd = true; in lkpi_sta_auth_to_assoc()
1641 lkpi_wake_tx_queues(hw, LSTA_TO_STA(lsta), false, true); in lkpi_sta_auth_to_assoc()
1645 * - update sta_state (AUTH to ASSOC) in lkpi_sta_auth_to_assoc()
1646 * - conf_tx [all] in lkpi_sta_auth_to_assoc()
1647 * - bss_info_changed (assoc, aid, ssid, ..) in lkpi_sta_auth_to_assoc()
1648 * - change_chanctx (if needed) in lkpi_sta_auth_to_assoc()
1649 * - event_callback in lkpi_sta_auth_to_assoc()
1650 * - mgd_complete_tx in lkpi_sta_auth_to_assoc()
1655 IEEE80211_LOCK(vap->iv_ic); in lkpi_sta_auth_to_assoc()
1664 struct ieee80211_hw *hw; in lkpi_sta_a_to_a() local
1671 lhw = vap->iv_ic->ic_softc; in lkpi_sta_a_to_a()
1672 hw = LHW_TO_HW(lhw); in lkpi_sta_a_to_a()
1676 IEEE80211_UNLOCK(vap->iv_ic); in lkpi_sta_a_to_a()
1680 /* XXX-BZ KASSERT later? */ in lkpi_sta_a_to_a()
1681 if (!lvif->lvif_bss_synched || lvif->lvif_bss == NULL) { in lkpi_sta_a_to_a()
1683 ic_printf(vap->iv_ic, "%s:%d: lvif %p vap %p iv_bss %p lvif_bss %p " in lkpi_sta_a_to_a()
1684 "lvif_bss->ni %p synched %d\n", __func__, __LINE__, in lkpi_sta_a_to_a()
1685 lvif, vap, vap->iv_bss, lvif->lvif_bss, in lkpi_sta_a_to_a()
1686 (lvif->lvif_bss != NULL) ? lvif->lvif_bss->ni : NULL, in lkpi_sta_a_to_a()
1687 lvif->lvif_bss_synched); in lkpi_sta_a_to_a()
1693 lsta = lvif->lvif_bss; in lkpi_sta_a_to_a()
1702 if (lsta->in_mgd) { in lkpi_sta_a_to_a()
1705 lkpi_80211_mo_mgd_complete_tx(hw, vif, &prep_tx_info); in lkpi_sta_a_to_a()
1706 lsta->in_mgd = false; in lkpi_sta_a_to_a()
1712 if (!lsta->in_mgd) { in lkpi_sta_a_to_a()
1715 lkpi_80211_mo_mgd_prepare_tx(hw, vif, &prep_tx_info); in lkpi_sta_a_to_a()
1716 lsta->in_mgd = true; in lkpi_sta_a_to_a()
1722 IEEE80211_LOCK(vap->iv_ic); in lkpi_sta_a_to_a()
1731 struct ieee80211_hw *hw; in _lkpi_sta_assoc_to_down() local
1741 lhw = vap->iv_ic->ic_softc; in _lkpi_sta_assoc_to_down()
1742 hw = LHW_TO_HW(lhw); in _lkpi_sta_assoc_to_down()
1746 IEEE80211_UNLOCK(vap->iv_ic); in _lkpi_sta_assoc_to_down()
1751 /* XXX-BZ KASSERT later; state going down so no action. */ in _lkpi_sta_assoc_to_down()
1752 if (lvif->lvif_bss == NULL) in _lkpi_sta_assoc_to_down()
1753 ic_printf(vap->iv_ic, "%s:%d: lvif %p vap %p iv_bss %p lvif_bss %p " in _lkpi_sta_assoc_to_down()
1754 "lvif_bss->ni %p synched %d\n", __func__, __LINE__, in _lkpi_sta_assoc_to_down()
1755 lvif, vap, vap->iv_bss, lvif->lvif_bss, in _lkpi_sta_assoc_to_down()
1756 (lvif->lvif_bss != NULL) ? lvif->lvif_bss->ni : NULL, in _lkpi_sta_assoc_to_down()
1757 lvif->lvif_bss_synched); in _lkpi_sta_assoc_to_down()
1759 lsta = lvif->lvif_bss; in _lkpi_sta_assoc_to_down()
1761 KASSERT(lsta != NULL && lsta->ni != NULL, ("%s: lsta %p ni %p " in _lkpi_sta_assoc_to_down()
1763 lsta, (lsta != NULL) ? lsta->ni : NULL, lvif, vap)); in _lkpi_sta_assoc_to_down()
1765 ni = lsta->ni; /* Reference held for lvif_bss. */ in _lkpi_sta_assoc_to_down()
1771 lkpi_80211_mo_flush(hw, vif, nitems(sta->txq), true); in _lkpi_sta_assoc_to_down()
1774 if (ieee80211_hw_check(hw, DEAUTH_NEED_MGD_TX_PREP) && in _lkpi_sta_assoc_to_down()
1775 !lsta->in_mgd) { in _lkpi_sta_assoc_to_down()
1779 lkpi_80211_mo_mgd_prepare_tx(hw, vif, &prep_tx_info); in _lkpi_sta_assoc_to_down()
1780 lsta->in_mgd = true; in _lkpi_sta_assoc_to_down()
1784 IEEE80211_LOCK(vap->iv_ic); in _lkpi_sta_assoc_to_down()
1787 error = lvif->iv_newstate(vap, nstate, arg); in _lkpi_sta_assoc_to_down()
1789 ic_printf(vap->iv_ic, "%s:%d: iv_newstate(%p, %d, %d) " in _lkpi_sta_assoc_to_down()
1794 IEEE80211_UNLOCK(vap->iv_ic); in _lkpi_sta_assoc_to_down()
1804 lkpi_wake_tx_queues(hw, sta, false, true); in _lkpi_sta_assoc_to_down()
1807 lkpi_80211_mo_flush(hw, vif, nitems(sta->txq), false); in _lkpi_sta_assoc_to_down()
1810 if (lsta->in_mgd) { in _lkpi_sta_assoc_to_down()
1814 lkpi_80211_mo_mgd_complete_tx(hw, vif, &prep_tx_info); in _lkpi_sta_assoc_to_down()
1815 lsta->in_mgd = false; in _lkpi_sta_assoc_to_down()
1819 lkpi_80211_mo_sync_rx_queues(hw); in _lkpi_sta_assoc_to_down()
1822 lkpi_80211_mo_sta_pre_rcu_remove(hw, vif, sta); in _lkpi_sta_assoc_to_down()
1828 KASSERT(lsta->state == IEEE80211_STA_AUTH, ("%s: lsta %p state not " in _lkpi_sta_assoc_to_down()
1829 "AUTH: %#x\n", __func__, lsta, lsta->state)); in _lkpi_sta_assoc_to_down()
1830 error = lkpi_80211_mo_sta_state(hw, vif, lsta, IEEE80211_STA_NONE); in _lkpi_sta_assoc_to_down()
1832 ic_printf(vap->iv_ic, "%s:%d: mo_sta_state(NONE) " in _lkpi_sta_assoc_to_down()
1845 KASSERT(lsta->state == IEEE80211_STA_NONE, ("%s: lsta %p state not " in _lkpi_sta_assoc_to_down()
1846 "NONE: %#x, nstate %d arg %d\n", __func__, lsta, lsta->state, nstate, arg)); in _lkpi_sta_assoc_to_down()
1847 error = lkpi_80211_mo_sta_state(hw, vif, lsta, IEEE80211_STA_NOTEXIST); in _lkpi_sta_assoc_to_down()
1850 ic_printf(vap->iv_ic, "%s:%d: mo_sta_state(NOTEXIST) " in _lkpi_sta_assoc_to_down()
1858 vif->bss_conf.qos = 0; in _lkpi_sta_assoc_to_down()
1860 vif->cfg.ssid_len = 0; in _lkpi_sta_assoc_to_down()
1861 memset(vif->cfg.ssid, '\0', sizeof(vif->cfg.ssid)); in _lkpi_sta_assoc_to_down()
1863 lkpi_80211_mo_bss_info_changed(hw, vif, &vif->bss_conf, bss_changed); in _lkpi_sta_assoc_to_down()
1867 lvif->lvif_bss = NULL; in _lkpi_sta_assoc_to_down()
1868 lvif->lvif_bss_synched = false; in _lkpi_sta_assoc_to_down()
1873 * lvif->lvif_bss. Upon return from this both ni and lsta are invalid in _lkpi_sta_assoc_to_down()
1881 if (vif->chanctx_conf != NULL) { in _lkpi_sta_assoc_to_down()
1885 chanctx_conf = vif->chanctx_conf; in _lkpi_sta_assoc_to_down()
1887 lkpi_80211_mo_unassign_vif_chanctx(hw, vif, &vif->bss_conf, &vif->chanctx_conf); in _lkpi_sta_assoc_to_down()
1888 /* NB: vif->chanctx_conf is NULL now. */ in _lkpi_sta_assoc_to_down()
1890 lkpi_hw_conf_idle(hw, true); in _lkpi_sta_assoc_to_down()
1893 lkpi_80211_mo_remove_chanctx(hw, chanctx_conf); in _lkpi_sta_assoc_to_down()
1901 IEEE80211_LOCK(vap->iv_ic); in _lkpi_sta_assoc_to_down()
1943 struct ieee80211_hw *hw; in lkpi_sta_assoc_to_run() local
1953 lhw = vap->iv_ic->ic_softc; in lkpi_sta_assoc_to_run()
1954 hw = LHW_TO_HW(lhw); in lkpi_sta_assoc_to_run()
1958 IEEE80211_UNLOCK(vap->iv_ic); in lkpi_sta_assoc_to_run()
1962 /* XXX-BZ KASSERT later? */ in lkpi_sta_assoc_to_run()
1963 if (!lvif->lvif_bss_synched || lvif->lvif_bss == NULL) { in lkpi_sta_assoc_to_run()
1965 ic_printf(vap->iv_ic, "%s:%d: lvif %p vap %p iv_bss %p lvif_bss %p " in lkpi_sta_assoc_to_run()
1966 "lvif_bss->ni %p synched %d\n", __func__, __LINE__, in lkpi_sta_assoc_to_run()
1967 lvif, vap, vap->iv_bss, lvif->lvif_bss, in lkpi_sta_assoc_to_run()
1968 (lvif->lvif_bss != NULL) ? lvif->lvif_bss->ni : NULL, in lkpi_sta_assoc_to_run()
1969 lvif->lvif_bss_synched); in lkpi_sta_assoc_to_run()
1975 lsta = lvif->lvif_bss; in lkpi_sta_assoc_to_run()
1977 KASSERT(lsta != NULL && lsta->ni != NULL, ("%s: lsta %p ni %p " in lkpi_sta_assoc_to_run()
1979 lsta, (lsta != NULL) ? lsta->ni : NULL, lvif, vap)); in lkpi_sta_assoc_to_run()
1981 ni = lsta->ni; /* Reference held for lvif_bss. */ in lkpi_sta_assoc_to_run()
1988 KASSERT(lsta->state == IEEE80211_STA_AUTH, ("%s: lsta %p state not " in lkpi_sta_assoc_to_run()
1989 "AUTH: %#x\n", __func__, lsta, lsta->state)); in lkpi_sta_assoc_to_run()
1991 sta->aid = IEEE80211_NODE_AID(ni); in lkpi_sta_assoc_to_run()
1993 if (vap->iv_flags & IEEE80211_F_WME) in lkpi_sta_assoc_to_run()
1994 sta->wme = true; in lkpi_sta_assoc_to_run()
1996 error = lkpi_80211_mo_sta_state(hw, vif, lsta, IEEE80211_STA_ASSOC); in lkpi_sta_assoc_to_run()
1998 ic_printf(vap->iv_ic, "%s:%d: mo_sta_state(ASSOC) " in lkpi_sta_assoc_to_run()
2010 if (!vif->cfg.assoc || vif->cfg.aid != IEEE80211_NODE_AID(ni)) { in lkpi_sta_assoc_to_run()
2011 vif->cfg.assoc = true; in lkpi_sta_assoc_to_run()
2012 vif->cfg.aid = IEEE80211_NODE_AID(ni); in lkpi_sta_assoc_to_run()
2016 vif->cfg.ssid_len = ni->ni_esslen; in lkpi_sta_assoc_to_run()
2017 memcpy(vif->cfg.ssid, ni->ni_essid, ni->ni_esslen); in lkpi_sta_assoc_to_run()
2018 if ((vap->iv_flags & IEEE80211_F_SHPREAMBLE) != in lkpi_sta_assoc_to_run()
2019 vif->bss_conf.use_short_preamble) { in lkpi_sta_assoc_to_run()
2020 vif->bss_conf.use_short_preamble ^= 1; in lkpi_sta_assoc_to_run()
2023 if ((vap->iv_flags & IEEE80211_F_SHSLOT) != in lkpi_sta_assoc_to_run()
2024 vif->bss_conf.use_short_slot) { in lkpi_sta_assoc_to_run()
2025 vif->bss_conf.use_short_slot ^= 1; in lkpi_sta_assoc_to_run()
2028 if ((ni->ni_flags & IEEE80211_NODE_QOS) != in lkpi_sta_assoc_to_run()
2029 vif->bss_conf.qos) { in lkpi_sta_assoc_to_run()
2030 vif->bss_conf.qos ^= 1; in lkpi_sta_assoc_to_run()
2036 lkpi_80211_mo_bss_info_changed(hw, vif, &vif->bss_conf, bss_changed); in lkpi_sta_assoc_to_run()
2038 /* - change_chanctx (if needed) in lkpi_sta_assoc_to_run()
2039 * - event_callback in lkpi_sta_assoc_to_run()
2043 if (lsta->in_mgd) { in lkpi_sta_assoc_to_run()
2046 lkpi_80211_mo_mgd_complete_tx(hw, vif, &prep_tx_info); in lkpi_sta_assoc_to_run()
2047 lsta->in_mgd = false; in lkpi_sta_assoc_to_run()
2050 lkpi_hw_conf_idle(hw, false); in lkpi_sta_assoc_to_run()
2054 * - (more packets)? in lkpi_sta_assoc_to_run()
2055 * - set_key in lkpi_sta_assoc_to_run()
2056 * - set_default_unicast_key in lkpi_sta_assoc_to_run()
2057 * - set_key (?) in lkpi_sta_assoc_to_run()
2058 * - ipv6_addr_change (?) in lkpi_sta_assoc_to_run()
2061 lhw->update_mc = true; in lkpi_sta_assoc_to_run()
2062 lkpi_update_mcast_filter(vap->iv_ic, true); in lkpi_sta_assoc_to_run()
2075 KASSERT(lsta->state == IEEE80211_STA_ASSOC, ("%s: lsta %p state not " in lkpi_sta_assoc_to_run()
2076 "ASSOC: %#x\n", __func__, lsta, lsta->state)); in lkpi_sta_assoc_to_run()
2077 error = lkpi_80211_mo_sta_state(hw, vif, lsta, IEEE80211_STA_AUTHORIZED); in lkpi_sta_assoc_to_run()
2080 ic_printf(vap->iv_ic, "%s:%d: mo_sta_state(AUTHORIZED) " in lkpi_sta_assoc_to_run()
2085 /* - drv_config (?) in lkpi_sta_assoc_to_run()
2086 * - bss_info_changed in lkpi_sta_assoc_to_run()
2087 * - set_rekey_data (?) in lkpi_sta_assoc_to_run()
2095 lkpi_80211_mo_bss_info_changed(hw, vif, &vif->bss_conf, bss_changed); in lkpi_sta_assoc_to_run()
2099 IEEE80211_LOCK(vap->iv_ic); in lkpi_sta_assoc_to_run()
2118 struct ieee80211_hw *hw; in lkpi_sta_run_to_assoc() local
2130 lhw = vap->iv_ic->ic_softc; in lkpi_sta_run_to_assoc()
2131 hw = LHW_TO_HW(lhw); in lkpi_sta_run_to_assoc()
2137 /* XXX-BZ KASSERT later; state going down so no action. */ in lkpi_sta_run_to_assoc()
2138 if (lvif->lvif_bss == NULL) in lkpi_sta_run_to_assoc()
2139 ic_printf(vap->iv_ic, "%s:%d: lvif %p vap %p iv_bss %p lvif_bss %p " in lkpi_sta_run_to_assoc()
2140 "lvif_bss->ni %p synched %d\n", __func__, __LINE__, in lkpi_sta_run_to_assoc()
2141 lvif, vap, vap->iv_bss, lvif->lvif_bss, in lkpi_sta_run_to_assoc()
2142 (lvif->lvif_bss != NULL) ? lvif->lvif_bss->ni : NULL, in lkpi_sta_run_to_assoc()
2143 lvif->lvif_bss_synched); in lkpi_sta_run_to_assoc()
2145 lsta = lvif->lvif_bss; in lkpi_sta_run_to_assoc()
2147 KASSERT(lsta != NULL && lsta->ni != NULL, ("%s: lsta %p ni %p " in lkpi_sta_run_to_assoc()
2149 lsta, (lsta != NULL) ? lsta->ni : NULL, lvif, vap)); in lkpi_sta_run_to_assoc()
2151 ni = lsta->ni; /* Reference held for lvif_bss. */ in lkpi_sta_run_to_assoc()
2156 IEEE80211_UNLOCK(vap->iv_ic); in lkpi_sta_run_to_assoc()
2160 lkpi_80211_mo_flush(hw, vif, nitems(sta->txq), true); in lkpi_sta_run_to_assoc()
2163 if (ieee80211_hw_check(hw, DEAUTH_NEED_MGD_TX_PREP) && in lkpi_sta_run_to_assoc()
2164 !lsta->in_mgd) { in lkpi_sta_run_to_assoc()
2168 lkpi_80211_mo_mgd_prepare_tx(hw, vif, &prep_tx_info); in lkpi_sta_run_to_assoc()
2169 lsta->in_mgd = true; in lkpi_sta_run_to_assoc()
2173 IEEE80211_LOCK(vap->iv_ic); in lkpi_sta_run_to_assoc()
2176 error = lvif->iv_newstate(vap, nstate, arg); in lkpi_sta_run_to_assoc()
2178 ic_printf(vap->iv_ic, "%s:%d: iv_newstate(%p, %d, %d) " in lkpi_sta_run_to_assoc()
2183 IEEE80211_UNLOCK(vap->iv_ic); in lkpi_sta_run_to_assoc()
2193 lkpi_wake_tx_queues(hw, sta, false, true); in lkpi_sta_run_to_assoc()
2196 lkpi_80211_mo_flush(hw, vif, nitems(sta->txq), false); in lkpi_sta_run_to_assoc()
2199 if (lsta->in_mgd) { in lkpi_sta_run_to_assoc()
2203 lkpi_80211_mo_mgd_complete_tx(hw, vif, &prep_tx_info); in lkpi_sta_run_to_assoc()
2204 lsta->in_mgd = false; in lkpi_sta_run_to_assoc()
2209 lkpi_80211_mo_sync_rx_queues(hw); in lkpi_sta_run_to_assoc()
2212 lkpi_80211_mo_sta_pre_rcu_remove(hw, vif, sta); in lkpi_sta_run_to_assoc()
2219 KASSERT(lsta->state == IEEE80211_STA_AUTHORIZED, ("%s: lsta %p state not " in lkpi_sta_run_to_assoc()
2220 "AUTHORIZED: %#x\n", __func__, lsta, lsta->state)); in lkpi_sta_run_to_assoc()
2221 error = lkpi_80211_mo_sta_state(hw, vif, lsta, IEEE80211_STA_ASSOC); in lkpi_sta_run_to_assoc()
2223 ic_printf(vap->iv_ic, "%s:%d: mo_sta_state(ASSOC) " in lkpi_sta_run_to_assoc()
2232 KASSERT(lsta->state == IEEE80211_STA_ASSOC, ("%s: lsta %p state not " in lkpi_sta_run_to_assoc()
2233 "ASSOC: %#x\n", __func__, lsta, lsta->state)); in lkpi_sta_run_to_assoc()
2234 error = lkpi_80211_mo_sta_state(hw, vif, lsta, IEEE80211_STA_AUTH); in lkpi_sta_run_to_assoc()
2236 ic_printf(vap->iv_ic, "%s:%d: mo_sta_state(AUTH) " in lkpi_sta_run_to_assoc()
2251 IEEE80211_LOCK(vap->iv_ic); in lkpi_sta_run_to_assoc()
2260 struct ieee80211_hw *hw; in lkpi_sta_run_to_init() local
2270 lhw = vap->iv_ic->ic_softc; in lkpi_sta_run_to_init()
2271 hw = LHW_TO_HW(lhw); in lkpi_sta_run_to_init()
2275 IEEE80211_UNLOCK(vap->iv_ic); in lkpi_sta_run_to_init()
2280 /* XXX-BZ KASSERT later; state going down so no action. */ in lkpi_sta_run_to_init()
2281 if (lvif->lvif_bss == NULL) in lkpi_sta_run_to_init()
2282 ic_printf(vap->iv_ic, "%s:%d: lvif %p vap %p iv_bss %p lvif_bss %p " in lkpi_sta_run_to_init()
2283 "lvif_bss->ni %p synched %d\n", __func__, __LINE__, in lkpi_sta_run_to_init()
2284 lvif, vap, vap->iv_bss, lvif->lvif_bss, in lkpi_sta_run_to_init()
2285 (lvif->lvif_bss != NULL) ? lvif->lvif_bss->ni : NULL, in lkpi_sta_run_to_init()
2286 lvif->lvif_bss_synched); in lkpi_sta_run_to_init()
2288 lsta = lvif->lvif_bss; in lkpi_sta_run_to_init()
2290 KASSERT(lsta != NULL && lsta->ni != NULL, ("%s: lsta %p ni %p " in lkpi_sta_run_to_init()
2292 lsta, (lsta != NULL) ? lsta->ni : NULL, lvif, vap)); in lkpi_sta_run_to_init()
2294 ni = lsta->ni; /* Reference held for lvif_bss. */ in lkpi_sta_run_to_init()
2300 lkpi_80211_mo_flush(hw, vif, nitems(sta->txq), true); in lkpi_sta_run_to_init()
2303 if (ieee80211_hw_check(hw, DEAUTH_NEED_MGD_TX_PREP) && in lkpi_sta_run_to_init()
2304 !lsta->in_mgd) { in lkpi_sta_run_to_init()
2308 lkpi_80211_mo_mgd_prepare_tx(hw, vif, &prep_tx_info); in lkpi_sta_run_to_init()
2309 lsta->in_mgd = true; in lkpi_sta_run_to_init()
2313 IEEE80211_LOCK(vap->iv_ic); in lkpi_sta_run_to_init()
2316 error = lvif->iv_newstate(vap, nstate, arg); in lkpi_sta_run_to_init()
2318 ic_printf(vap->iv_ic, "%s:%d: iv_newstate(%p, %d, %d) " in lkpi_sta_run_to_init()
2323 IEEE80211_UNLOCK(vap->iv_ic); in lkpi_sta_run_to_init()
2333 lkpi_wake_tx_queues(hw, sta, false, true); in lkpi_sta_run_to_init()
2336 lkpi_80211_mo_flush(hw, vif, nitems(sta->txq), false); in lkpi_sta_run_to_init()
2339 if (lsta->in_mgd) { in lkpi_sta_run_to_init()
2343 lkpi_80211_mo_mgd_complete_tx(hw, vif, &prep_tx_info); in lkpi_sta_run_to_init()
2344 lsta->in_mgd = false; in lkpi_sta_run_to_init()
2348 lkpi_80211_mo_sync_rx_queues(hw); in lkpi_sta_run_to_init()
2351 lkpi_80211_mo_sta_pre_rcu_remove(hw, vif, sta); in lkpi_sta_run_to_init()
2357 KASSERT(lsta->state == IEEE80211_STA_AUTHORIZED, ("%s: lsta %p state not " in lkpi_sta_run_to_init()
2358 "AUTHORIZED: %#x\n", __func__, lsta, lsta->state)); in lkpi_sta_run_to_init()
2359 error = lkpi_80211_mo_sta_state(hw, vif, lsta, IEEE80211_STA_ASSOC); in lkpi_sta_run_to_init()
2361 ic_printf(vap->iv_ic, "%s:%d: mo_sta_state(ASSOC) " in lkpi_sta_run_to_init()
2370 KASSERT(lsta->state == IEEE80211_STA_ASSOC, ("%s: lsta %p state not " in lkpi_sta_run_to_init()
2371 "ASSOC: %#x\n", __func__, lsta, lsta->state)); in lkpi_sta_run_to_init()
2372 error = lkpi_80211_mo_sta_state(hw, vif, lsta, IEEE80211_STA_AUTH); in lkpi_sta_run_to_init()
2374 ic_printf(vap->iv_ic, "%s:%d: mo_sta_state(AUTH) " in lkpi_sta_run_to_init()
2383 KASSERT(lsta->state == IEEE80211_STA_AUTH, ("%s: lsta %p state not " in lkpi_sta_run_to_init()
2384 "AUTH: %#x\n", __func__, lsta, lsta->state)); in lkpi_sta_run_to_init()
2385 error = lkpi_80211_mo_sta_state(hw, vif, lsta, IEEE80211_STA_NONE); in lkpi_sta_run_to_init()
2387 ic_printf(vap->iv_ic, "%s:%d: mo_sta_state(NONE) " in lkpi_sta_run_to_init()
2406 * non-removal seems to be (for iwlwifi::mld-mac80211.c cases; in lkpi_sta_run_to_init()
2408 * 1) lkpi_disassoc(): set vif->cfg.assoc = false (aid=0 side effect here) in lkpi_sta_run_to_init()
2409 * 2) call the last sta_state update -> IEEE80211_STA_NOTEXIST in lkpi_sta_run_to_init()
2422 KASSERT(lsta->state == IEEE80211_STA_NONE, ("%s: lsta %p state not " in lkpi_sta_run_to_init()
2423 "NONE: %#x, nstate %d arg %d\n", __func__, lsta, lsta->state, nstate, arg)); in lkpi_sta_run_to_init()
2424 error = lkpi_80211_mo_sta_state(hw, vif, lsta, IEEE80211_STA_NOTEXIST); in lkpi_sta_run_to_init()
2427 ic_printf(vap->iv_ic, "%s:%d: mo_sta_state(NOTEXIST) " in lkpi_sta_run_to_init()
2437 vif->bss_conf.qos = 0; in lkpi_sta_run_to_init()
2439 vif->cfg.ssid_len = 0; in lkpi_sta_run_to_init()
2440 memset(vif->cfg.ssid, '\0', sizeof(vif->cfg.ssid)); in lkpi_sta_run_to_init()
2442 vif->bss_conf.use_short_preamble = false; in lkpi_sta_run_to_init()
2443 vif->bss_conf.qos = false; in lkpi_sta_run_to_init()
2445 lkpi_80211_mo_bss_info_changed(hw, vif, &vif->bss_conf, bss_changed); in lkpi_sta_run_to_init()
2449 lvif->lvif_bss = NULL; in lkpi_sta_run_to_init()
2450 lvif->lvif_bss_synched = false; in lkpi_sta_run_to_init()
2454 * lvif->lvif_bss. Upon return from this both ni and lsta are invalid in lkpi_sta_run_to_init()
2462 if (vif->chanctx_conf != NULL) { in lkpi_sta_run_to_init()
2466 chanctx_conf = vif->chanctx_conf; in lkpi_sta_run_to_init()
2468 lkpi_80211_mo_unassign_vif_chanctx(hw, vif, &vif->bss_conf, &vif->chanctx_conf); in lkpi_sta_run_to_init()
2469 /* NB: vif->chanctx_conf is NULL now. */ in lkpi_sta_run_to_init()
2471 lkpi_hw_conf_idle(hw, true); in lkpi_sta_run_to_init()
2474 lkpi_80211_mo_remove_chanctx(hw, chanctx_conf); in lkpi_sta_run_to_init()
2482 IEEE80211_LOCK(vap->iv_ic); in lkpi_sta_run_to_init()
2509 /* -------------------------------------------------------------------------- */
2563 ic = vap->iv_ic; in lkpi_iv_newstate()
2565 ostate = vap->iv_state; in lkpi_iv_newstate()
2569 ic_printf(vap->iv_ic, "%s:%d: vap %p nstate %#x arg %#x\n", in lkpi_iv_newstate()
2573 if (vap->iv_opmode == IEEE80211_M_STA) { in lkpi_iv_newstate()
2575 lhw = ic->ic_softc; in lkpi_iv_newstate()
2586 ic_printf(vap->iv_ic, "%s: only station mode currently supported: " in lkpi_iv_newstate()
2587 "cap %p iv_opmode %d\n", __func__, vap, vap->iv_opmode); in lkpi_iv_newstate()
2592 for (; s->handler != NULL; s++) { in lkpi_iv_newstate()
2593 if (ostate == s->ostate && nstate == s->nstate) { in lkpi_iv_newstate()
2596 ic_printf(vap->iv_ic, "%s: new state %d (%s) ->" in lkpi_iv_newstate()
2601 error = s->handler(vap, nstate, arg); in lkpi_iv_newstate()
2605 IEEE80211_LOCK_ASSERT(vap->iv_ic); in lkpi_iv_newstate()
2607 if (s->handler == NULL) { in lkpi_iv_newstate()
2609 ic_printf(vap->iv_ic, "%s: unsupported state transition " in lkpi_iv_newstate()
2610 "%d (%s) -> %d (%s)\n", __func__, in lkpi_iv_newstate()
2619 ic_printf(vap->iv_ic, "%s: state transition %d (%s) -> " in lkpi_iv_newstate()
2628 ic_printf(vap->iv_ic, "%s: error %d during state transition " in lkpi_iv_newstate()
2629 "%d (%s) -> %d (%s)\n", __func__, error, in lkpi_iv_newstate()
2637 ic_printf(vap->iv_ic, "%s:%d: vap %p nstate %#x arg %#x " in lkpi_iv_newstate()
2642 return (lvif->iv_newstate(vap, nstate, arg)); in lkpi_iv_newstate()
2645 /* -------------------------------------------------------------------------- */
2649 * net80211::ieee80211_sta_join1() where vap->iv_bss gets replaced by a
2658 IEEE80211_LOCK_ASSERT(vap->iv_ic); in lkpi_iv_update_bss()
2663 lvif->lvif_bss_synched = false; in lkpi_iv_update_bss()
2666 rni = lvif->iv_update_bss(vap, ni); in lkpi_iv_update_bss()
2675 struct ieee80211_hw *hw; in lkpi_wme_update() local
2692 if ((vap->iv_flags & IEEE80211_F_WME) == 0) in lkpi_wme_update()
2695 if (lhw->ops->conf_tx == NULL) in lkpi_wme_update()
2698 if (!planned && (vap->iv_state != IEEE80211_S_RUN)) { in lkpi_wme_update()
2699 lhw->update_wme = true; in lkpi_wme_update()
2702 lhw->update_wme = false; in lkpi_wme_update()
2704 ic = lhw->ic; in lkpi_wme_update()
2711 hw = LHW_TO_HW(lhw); in lkpi_wme_update()
2722 txqp.cw_min = wmep->wmep_logcwmin; in lkpi_wme_update()
2723 txqp.cw_max = wmep->wmep_logcwmax; in lkpi_wme_update()
2724 txqp.txop = wmep->wmep_txopLimit; in lkpi_wme_update()
2725 txqp.aifs = wmep->wmep_aifsn; in lkpi_wme_update()
2726 error = lkpi_80211_mo_conf_tx(hw, vif, /* link_id */0, ac, &txqp); in lkpi_wme_update()
2734 lkpi_80211_mo_bss_info_changed(hw, vif, &vif->bss_conf, changed); in lkpi_wme_update()
2747 IMPROVE("Use the per-VAP callback in net80211."); in lkpi_ic_wme_update()
2748 vap = TAILQ_FIRST(&ic->ic_vaps); in lkpi_ic_wme_update()
2752 lhw = ic->ic_softc; in lkpi_ic_wme_update()
2760 * Change link-layer address on the vif (if the vap is not started/"UP").
2763 * we do use a per-[l]vif event handler to be sure we exist as we
2768 * single-consumer (or needs a list) -- was just too complicated for an
2786 IEEE80211_ADDR_COPY(vif->bss_conf.addr, if_getlladdr(ifp)); in lkpi_vif_iflladdr()
2797 struct ieee80211_hw *hw; in lkpi_ic_vap_create() local
2807 if (!TAILQ_EMPTY(&ic->ic_vaps)) /* 1 so far. Add <n> once this works. */ in lkpi_ic_vap_create()
2810 lhw = ic->ic_softc; in lkpi_ic_vap_create()
2811 hw = LHW_TO_HW(lhw); in lkpi_ic_vap_create()
2814 len += hw->vif_data_size; /* vif->drv_priv */ in lkpi_ic_vap_create()
2817 mtx_init(&lvif->mtx, "lvif", NULL, MTX_DEF); in lkpi_ic_vap_create()
2818 TAILQ_INIT(&lvif->lsta_head); in lkpi_ic_vap_create()
2819 lvif->lvif_bss = NULL; in lkpi_ic_vap_create()
2820 lvif->lvif_bss_synched = false; in lkpi_ic_vap_create()
2824 memcpy(vif->addr, mac, IEEE80211_ADDR_LEN); in lkpi_ic_vap_create()
2825 vif->p2p = false; in lkpi_ic_vap_create()
2826 vif->probe_req_reg = false; in lkpi_ic_vap_create()
2827 vif->type = lkpi_opmode_to_vif_type(opmode); in lkpi_ic_vap_create()
2828 lvif->wdev.iftype = vif->type; in lkpi_ic_vap_create()
2832 /* XXX-BZ hardcoded for now! */ in lkpi_ic_vap_create()
2834 vif->chanctx_conf = NULL; in lkpi_ic_vap_create()
2835 vif->bss_conf.vif = vif; in lkpi_ic_vap_create()
2836 /* vap->iv_myaddr is not set until net80211::vap_setup or vap_attach. */ in lkpi_ic_vap_create()
2837 IEEE80211_ADDR_COPY(vif->bss_conf.addr, mac); in lkpi_ic_vap_create()
2838 lvif->lvif_ifllevent = EVENTHANDLER_REGISTER(iflladdr_event, in lkpi_ic_vap_create()
2840 vif->bss_conf.link_id = 0; /* Non-MLO operation. */ in lkpi_ic_vap_create()
2841 vif->bss_conf.chanreq.oper.width = NL80211_CHAN_WIDTH_20_NOHT; in lkpi_ic_vap_create()
2842 vif->bss_conf.use_short_preamble = false; /* vap->iv_flags IEEE80211_F_SHPREAMBLE */ in lkpi_ic_vap_create()
2843 vif->bss_conf.use_short_slot = false; /* vap->iv_flags IEEE80211_F_SHSLOT */ in lkpi_ic_vap_create()
2844 vif->bss_conf.qos = false; in lkpi_ic_vap_create()
2845 vif->bss_conf.use_cts_prot = false; /* vap->iv_protmode */ in lkpi_ic_vap_create()
2846 vif->bss_conf.ht_operation_mode = IEEE80211_HT_OP_MODE_PROTECTION_NONE; in lkpi_ic_vap_create()
2847 vif->cfg.aid = 0; in lkpi_ic_vap_create()
2848 vif->cfg.assoc = false; in lkpi_ic_vap_create()
2849 vif->cfg.idle = true; in lkpi_ic_vap_create()
2850 vif->cfg.ps = false; in lkpi_ic_vap_create()
2857 vif->bss_conf.bssid = ieee80211broadcastaddr; in lkpi_ic_vap_create()
2860 vif->bss_conf.dtim_period = 0; /* IEEE80211_DTIM_DEFAULT ; must stay 0. */ in lkpi_ic_vap_create()
2861 IEEE80211_ADDR_COPY(vif->bss_conf.bssid, bssid); in lkpi_ic_vap_create()
2862 vif->bss_conf.beacon_int = ic->ic_bintval; in lkpi_ic_vap_create()
2864 if (vif->bss_conf.beacon_int < 16) in lkpi_ic_vap_create()
2865 vif->bss_conf.beacon_int = 16; in lkpi_ic_vap_create()
2869 vif->link_conf[0] = &vif->bss_conf; in lkpi_ic_vap_create()
2870 for (i = 0; i < nitems(vif->link_conf); i++) { in lkpi_ic_vap_create()
2876 if (ieee80211_hw_check(hw, QUEUE_CONTROL)) in lkpi_ic_vap_create()
2877 vif->hw_queue[i] = IEEE80211_INVAL_HW_QUEUE; in lkpi_ic_vap_create()
2878 else if (hw->queues >= IEEE80211_NUM_ACS) in lkpi_ic_vap_create()
2879 vif->hw_queue[i] = i; in lkpi_ic_vap_create()
2881 vif->hw_queue[i] = 0; in lkpi_ic_vap_create()
2884 lvif->hw_queue_stopped[i] = false; in lkpi_ic_vap_create()
2886 vif->cab_queue = IEEE80211_INVAL_HW_QUEUE; in lkpi_ic_vap_create()
2890 error = lkpi_80211_mo_start(hw); in lkpi_ic_vap_create()
2892 ic_printf(ic, "%s: failed to start hw: %d\n", __func__, error); in lkpi_ic_vap_create()
2893 mtx_destroy(&lvif->mtx); in lkpi_ic_vap_create()
2898 error = lkpi_80211_mo_add_interface(hw, vif); in lkpi_ic_vap_create()
2900 IMPROVE(); /* XXX-BZ mo_stop()? */ in lkpi_ic_vap_create()
2902 mtx_destroy(&lvif->mtx); in lkpi_ic_vap_create()
2908 TAILQ_INSERT_TAIL(&lhw->lvif_head, lvif, lvif_entry); in lkpi_ic_vap_create()
2913 lkpi_80211_mo_bss_info_changed(hw, vif, &vif->bss_conf, changed); in lkpi_ic_vap_create()
2916 IMPROVE("Hardcoded values; to fix see 802.11-2016, 9.4.2.29 EDCA Parameter Set element"); in lkpi_ic_vap_create()
2925 error = lkpi_80211_mo_conf_tx(hw, vif, /* link_id */0, ac, &txqp); in lkpi_ic_vap_create()
2932 lkpi_80211_mo_bss_info_changed(hw, vif, &vif->bss_conf, changed); in lkpi_ic_vap_create()
2942 lvif->iv_newstate = vap->iv_newstate; in lkpi_ic_vap_create()
2943 vap->iv_newstate = lkpi_iv_newstate; in lkpi_ic_vap_create()
2944 lvif->iv_update_bss = vap->iv_update_bss; in lkpi_ic_vap_create()
2945 vap->iv_update_bss = lkpi_iv_update_bss; in lkpi_ic_vap_create()
2948 if (lhw->ops->set_key != NULL) { in lkpi_ic_vap_create()
2950 vap->iv_key_set = lkpi_iv_key_set; in lkpi_ic_vap_create()
2951 vap->iv_key_delete = lkpi_iv_key_delete; in lkpi_ic_vap_create()
2965 if (hw->max_listen_interval == 0) in lkpi_ic_vap_create()
2966 hw->max_listen_interval = 7 * (ic->ic_lintval / ic->ic_bintval); in lkpi_ic_vap_create()
2967 hw->conf.listen_interval = hw->max_listen_interval; in lkpi_ic_vap_create()
2968 ic->ic_set_channel(ic); in lkpi_ic_vap_create()
2970 /* XXX-BZ do we need to be able to update these? */ in lkpi_ic_vap_create()
2971 hw->wiphy->frag_threshold = vap->iv_fragthreshold; in lkpi_ic_vap_create()
2972 lkpi_80211_mo_set_frag_threshold(hw, vap->iv_fragthreshold); in lkpi_ic_vap_create()
2973 hw->wiphy->rts_threshold = vap->iv_rtsthreshold; in lkpi_ic_vap_create()
2974 lkpi_80211_mo_set_rts_threshold(hw, vap->iv_rtsthreshold); in lkpi_ic_vap_create()
2982 linuxkpi_ieee80211_unregister_hw(struct ieee80211_hw *hw) in linuxkpi_ieee80211_unregister_hw() argument
2985 wiphy_unregister(hw->wiphy); in linuxkpi_ieee80211_unregister_hw()
2986 linuxkpi_ieee80211_ifdetach(hw); in linuxkpi_ieee80211_unregister_hw()
2992 linuxkpi_ieee80211_restart_hw(struct ieee80211_hw *hw) in linuxkpi_ieee80211_restart_hw() argument
3003 struct ieee80211_hw *hw; in lkpi_ic_vap_delete() local
3009 ic = vap->iv_ic; in lkpi_ic_vap_delete()
3010 lhw = ic->ic_softc; in lkpi_ic_vap_delete()
3011 hw = LHW_TO_HW(lhw); in lkpi_ic_vap_delete()
3013 EVENTHANDLER_DEREGISTER(iflladdr_event, lvif->lvif_ifllevent); in lkpi_ic_vap_delete()
3016 TAILQ_REMOVE(&lhw->lvif_head, lvif, lvif_entry); in lkpi_ic_vap_delete()
3024 lkpi_80211_mo_remove_interface(hw, vif); in lkpi_ic_vap_delete()
3027 lkpi_80211_mo_stop(hw, false); /* XXX SUSPEND */ in lkpi_ic_vap_delete()
3029 mtx_destroy(&lvif->mtx); in lkpi_ic_vap_delete()
3061 struct ieee80211_hw *hw; in lkpi_ic_parent() local
3068 lhw = ic->ic_softc; in lkpi_ic_parent()
3070 hw = LHW_TO_HW(lhw); in lkpi_ic_parent()
3076 if (ic->ic_nrunning > 0) { in lkpi_ic_parent()
3078 error = lkpi_80211_mo_start(hw); in lkpi_ic_parent()
3084 lkpi_80211_mo_stop(hw, false); /* XXX SUSPEND */ in lkpi_ic_parent()
3131 uint32_t band_mask, struct ieee80211vap *vap, struct ieee80211_hw *hw) in lkpi_scan_ies_add() argument
3134 struct linuxkpi_ieee80211_channel *channels; in lkpi_scan_ies_add() local
3141 ic = vap->iv_ic; in lkpi_scan_ies_add()
3146 supband = hw->wiphy->bands[band]; in lkpi_scan_ies_add()
3151 if (supband == NULL || supband->n_channels == 0) in lkpi_scan_ies_add()
3155 channels = supband->channels; in lkpi_scan_ies_add()
3157 for (i = 0; i < supband->n_channels; i++) { in lkpi_scan_ies_add()
3159 if (channels[i].flags & IEEE80211_CHAN_DISABLED) in lkpi_scan_ies_add()
3163 channels[i].center_freq, 0); in lkpi_scan_ies_add()
3178 if ((vap->iv_flags_ht & IEEE80211_FHT_HT) != 0) { in lkpi_scan_ies_add()
3181 c = ieee80211_ht_adjust_channel(ic, ic->ic_curchan, in lkpi_scan_ies_add()
3182 vap->iv_flags_ht); in lkpi_scan_ies_add()
3187 if ((vap->iv_vht_flags & IEEE80211_FVHT_VHT) != 0) { in lkpi_scan_ies_add()
3190 c = ieee80211_ht_adjust_channel(ic, ic->ic_curchan, in lkpi_scan_ies_add()
3191 vap->iv_flags_ht); in lkpi_scan_ies_add()
3193 vap->iv_vht_flags); in lkpi_scan_ies_add()
3198 scan_ies->ies[band] = pb; in lkpi_scan_ies_add()
3199 scan_ies->len[band] = p - pb; in lkpi_scan_ies_add()
3204 if ((vap->iv_flags & IEEE80211_F_WPA1) != 0 && in lkpi_scan_ies_add()
3205 vap->iv_wpa_ie != NULL) { in lkpi_scan_ies_add()
3206 memcpy(p, vap->iv_wpa_ie, 2 + vap->iv_wpa_ie[1]); in lkpi_scan_ies_add()
3207 p += 2 + vap->iv_wpa_ie[1]; in lkpi_scan_ies_add()
3209 if (vap->iv_appie_probereq != NULL) { in lkpi_scan_ies_add()
3210 memcpy(p, vap->iv_appie_probereq->ie_data, in lkpi_scan_ies_add()
3211 vap->iv_appie_probereq->ie_len); in lkpi_scan_ies_add()
3212 p += vap->iv_appie_probereq->ie_len; in lkpi_scan_ies_add()
3214 scan_ies->common_ies = pb; in lkpi_scan_ies_add()
3215 scan_ies->common_ie_len = p - pb; in lkpi_scan_ies_add()
3224 struct ieee80211_hw *hw; in lkpi_ic_scan_start() local
3232 lhw = ic->ic_softc; in lkpi_ic_scan_start()
3234 if ((lhw->scan_flags & LKPI_LHW_SCAN_RUNNING) != 0) { in lkpi_ic_scan_start()
3239 is_hw_scan = (lhw->scan_flags & LKPI_LHW_SCAN_HW) != 0; in lkpi_ic_scan_start()
3242 ss = ic->ic_scan; in lkpi_ic_scan_start()
3243 vap = ss->ss_vap; in lkpi_ic_scan_start()
3244 if (vap->iv_state != IEEE80211_S_SCAN) { in lkpi_ic_scan_start()
3249 hw = LHW_TO_HW(lhw); in lkpi_ic_scan_start()
3252 vap->iv_flags_ext &= ~IEEE80211_FEXT_SCAN_OFFLOAD; in lkpi_ic_scan_start()
3257 if (vap->iv_state == IEEE80211_S_SCAN) in lkpi_ic_scan_start()
3258 lkpi_hw_conf_idle(hw, false); in lkpi_ic_scan_start()
3260 lkpi_80211_mo_sw_scan_start(hw, vif, vif->addr); in lkpi_ic_scan_start()
3279 ssid_count = min(ss->ss_nssid, hw->wiphy->max_scan_ssids); in lkpi_ic_scan_start()
3281 s6ghzlen = 0 * (sizeof(*s6gp)); /* XXX-BZ */ in lkpi_ic_scan_start()
3285 for (i = ss->ss_next; i < ss->ss_last; i++) { in lkpi_ic_scan_start()
3288 ss->ss_chans[ss->ss_next + i]); in lkpi_ic_scan_start()
3292 if (!ieee80211_hw_check(hw, SINGLE_SCAN_ON_ALL_BANDS)) { in lkpi_ic_scan_start()
3300 /* XXX-BZ ath10k does not set this but still does it? &$%^ */ in lkpi_ic_scan_start()
3306 if ((vap->iv_flags & IEEE80211_F_WPA1) != 0 && in lkpi_ic_scan_start()
3307 vap->iv_wpa_ie != NULL) in lkpi_ic_scan_start()
3308 common_ie_len += vap->iv_wpa_ie[1]; in lkpi_ic_scan_start()
3309 if (vap->iv_appie_probereq != NULL) in lkpi_ic_scan_start()
3310 common_ie_len += vap->iv_appie_probereq->ie_len; in lkpi_ic_scan_start()
3313 if (common_ie_len > hw->wiphy->max_scan_ie_len) { in lkpi_ic_scan_start()
3315 "wiphy->max_scan_ie_len %d\n", __func__, in lkpi_ic_scan_start()
3316 common_ie_len, hw->wiphy->max_scan_ie_len); in lkpi_ic_scan_start()
3320 s6ghzlen + chan_len + lhw->supbands * lhw->scan_ie_len + in lkpi_ic_scan_start()
3323 hw_req->req.flags = 0; /* XXX ??? */ in lkpi_ic_scan_start()
3324 /* hw_req->req.wdev */ in lkpi_ic_scan_start()
3325 hw_req->req.wiphy = hw->wiphy; in lkpi_ic_scan_start()
3326 hw_req->req.no_cck = false; /* XXX */ in lkpi_ic_scan_start()
3329 hw_req->req.duration_mandatory = TICKS_2_USEC(ss->ss_mindwell); in lkpi_ic_scan_start()
3330 hw_req->req.duration = TICKS_2_USEC(ss->ss_maxdwell); in lkpi_ic_scan_start()
3333 hw_req->req.flags |= NL80211_SCAN_FLAG_RANDOM_ADDR; in lkpi_ic_scan_start()
3334 memcpy(hw_req->req.mac_addr, xxx, IEEE80211_ADDR_LEN); in lkpi_ic_scan_start()
3335 memset(hw_req->req.mac_addr_mask, 0xxx, IEEE80211_ADDR_LEN); in lkpi_ic_scan_start()
3337 eth_broadcast_addr(hw_req->req.bssid); in lkpi_ic_scan_start()
3339 hw_req->req.n_channels = nchan; in lkpi_ic_scan_start()
3347 c = ss->ss_chans[ss->ss_next + i]; in lkpi_ic_scan_start()
3349 lc->hw_value = c->ic_ieee; in lkpi_ic_scan_start()
3350 lc->center_freq = c->ic_freq; /* XXX */ in lkpi_ic_scan_start()
3351 /* lc->flags */ in lkpi_ic_scan_start()
3352 lc->band = lkpi_net80211_chan_to_nl80211_band(c); in lkpi_ic_scan_start()
3353 lc->max_power = c->ic_maxpower; in lkpi_ic_scan_start()
3354 /* lc-> ... */ in lkpi_ic_scan_start()
3358 hw_req->req.n_ssids = ssid_count; in lkpi_ic_scan_start()
3359 if (hw_req->req.n_ssids > 0) { in lkpi_ic_scan_start()
3361 hw_req->req.ssids = ssids; in lkpi_ic_scan_start()
3363 ssids->ssid_len = ss->ss_ssid[i].len; in lkpi_ic_scan_start()
3364 memcpy(ssids->ssid, ss->ss_ssid[i].ssid, in lkpi_ic_scan_start()
3365 ss->ss_ssid[i].len); in lkpi_ic_scan_start()
3374 hw_req->req.n_6ghz_params = 0; in lkpi_ic_scan_start()
3375 hw_req->req.scan_6ghz_params = NULL; in lkpi_ic_scan_start()
3376 hw_req->req.scan_6ghz = false; /* Weird boolean; not what you think. */ in lkpi_ic_scan_start()
3377 /* s6gp->... */ in lkpi_ic_scan_start()
3380 /* Copy per-band IEs, copy common IEs */ in lkpi_ic_scan_start()
3381 ieend = lkpi_scan_ies_add(ie, &hw_req->ies, band_mask, vap, hw); in lkpi_ic_scan_start()
3382 hw_req->req.ie = ie; in lkpi_ic_scan_start()
3383 hw_req->req.ie_len = ieend - ie; in lkpi_ic_scan_start()
3389 /* Re-check under lock. */ in lkpi_ic_scan_start()
3390 running = (lhw->scan_flags & LKPI_LHW_SCAN_RUNNING) != 0; in lkpi_ic_scan_start()
3392 KASSERT(lhw->hw_req == NULL, ("%s: ic %p lhw %p hw_req %p " in lkpi_ic_scan_start()
3393 "!= NULL\n", __func__, ic, lhw, lhw->hw_req)); in lkpi_ic_scan_start()
3395 lhw->scan_flags |= LKPI_LHW_SCAN_RUNNING; in lkpi_ic_scan_start()
3396 lhw->hw_req = hw_req; in lkpi_ic_scan_start()
3404 error = lkpi_80211_mo_hw_scan(hw, vif, hw_req); in lkpi_ic_scan_start()
3416 * rtw88 can return 1 or -EBUSY without scan_complete in lkpi_ic_scan_start()
3423 if ((lhw->scan_flags & LKPI_LHW_SCAN_RUNNING) != 0) { in lkpi_ic_scan_start()
3424 free(lhw->hw_req, M_LKPI80211); in lkpi_ic_scan_start()
3425 lhw->hw_req = NULL; in lkpi_ic_scan_start()
3426 lhw->scan_flags &= ~LKPI_LHW_SCAN_RUNNING; in lkpi_ic_scan_start()
3431 * XXX-SIGH magic number. in lkpi_ic_scan_start()
3437 lhw->scan_flags &= ~LKPI_LHW_SCAN_HW; in lkpi_ic_scan_start()
3442 * currently not re-enable it? in lkpi_ic_scan_start()
3444 vap->iv_flags_ext &= ~IEEE80211_FEXT_SCAN_OFFLOAD; in lkpi_ic_scan_start()
3450 ss->ss_mindwell ? ss->ss_mindwell : msecs_to_ticks(20), in lkpi_ic_scan_start()
3451 ss->ss_maxdwell ? ss->ss_maxdwell : msecs_to_ticks(200), in lkpi_ic_scan_start()
3452 vap->iv_des_nssid, vap->iv_des_ssid); in lkpi_ic_scan_start()
3468 lhw = ic->ic_softc; in lkpi_ic_scan_end()
3470 if ((lhw->scan_flags & LKPI_LHW_SCAN_RUNNING) == 0) { in lkpi_ic_scan_end()
3474 is_hw_scan = (lhw->scan_flags & LKPI_LHW_SCAN_HW) != 0; in lkpi_ic_scan_end()
3480 struct ieee80211_hw *hw; in lkpi_ic_scan_end() local
3484 ss = ic->ic_scan; in lkpi_ic_scan_end()
3485 vap = ss->ss_vap; in lkpi_ic_scan_end()
3486 hw = LHW_TO_HW(lhw); in lkpi_ic_scan_end()
3490 lkpi_80211_mo_sw_scan_complete(hw, vif); in lkpi_ic_scan_end()
3494 if (vap->iv_state == IEEE80211_S_SCAN) in lkpi_ic_scan_end()
3495 lkpi_hw_conf_idle(hw, true); in lkpi_ic_scan_end()
3506 lhw = ss->ss_ic->ic_softc; in lkpi_ic_scan_curchan()
3508 is_hw_scan = (lhw->scan_flags & LKPI_LHW_SCAN_HW) != 0; in lkpi_ic_scan_curchan()
3511 lhw->ic_scan_curchan(ss, maxdwell); in lkpi_ic_scan_curchan()
3520 lhw = ss->ss_ic->ic_softc; in lkpi_ic_scan_mindwell()
3522 is_hw_scan = (lhw->scan_flags & LKPI_LHW_SCAN_HW) != 0; in lkpi_ic_scan_mindwell()
3525 lhw->ic_scan_mindwell(ss); in lkpi_ic_scan_mindwell()
3532 struct ieee80211_hw *hw; in lkpi_ic_set_channel() local
3538 lhw = ic->ic_softc; in lkpi_ic_set_channel()
3541 if (lhw->ops->config == NULL) in lkpi_ic_set_channel()
3544 /* If we have a hw_scan running do not switch channels. */ in lkpi_ic_set_channel()
3547 (lhw->scan_flags & (LKPI_LHW_SCAN_RUNNING|LKPI_LHW_SCAN_HW)) == in lkpi_ic_set_channel()
3553 c = ic->ic_curchan; in lkpi_ic_set_channel()
3555 ic_printf(ic, "%s: c %p ops->config %p\n", __func__, in lkpi_ic_set_channel()
3556 c, lhw->ops->config); in lkpi_ic_set_channel()
3570 hw = LHW_TO_HW(lhw); in lkpi_ic_set_channel()
3571 cfg80211_chandef_create(&hw->conf.chandef, chan, in lkpi_ic_set_channel()
3573 (ic->ic_htcaps & IEEE80211_HTC_HT) ? 0 : in lkpi_ic_set_channel()
3577 error = lkpi_80211_mo_config(hw, IEEE80211_CONF_CHANGE_CHANNEL); in lkpi_ic_set_channel()
3584 /* Update radiotap channels as well. */ in lkpi_ic_set_channel()
3585 lhw->rtap_tx.wt_chan_freq = htole16(c->ic_freq); in lkpi_ic_set_channel()
3586 lhw->rtap_tx.wt_chan_flags = htole16(c->ic_flags); in lkpi_ic_set_channel()
3587 lhw->rtap_rx.wr_chan_freq = htole16(c->ic_freq); in lkpi_ic_set_channel()
3588 lhw->rtap_rx.wr_chan_flags = htole16(c->ic_flags); in lkpi_ic_set_channel()
3593 if (ieee80211_hw_check(hw, SUPPORTS_PS) && in lkpi_ic_set_channel()
3594 (hw->conf.flags & IEEE80211_CONF_PS) != 0) { in lkpi_ic_set_channel()
3595 hw->conf.flags &= ~IEEE80211_CONF_PS; in lkpi_ic_set_channel()
3596 error = lkpi_80211_mo_config(hw, IEEE80211_CONF_CHANGE_PS); in lkpi_ic_set_channel()
3611 struct ieee80211_hw *hw; in lkpi_ic_node_alloc() local
3614 ic = vap->iv_ic; in lkpi_ic_node_alloc()
3615 lhw = ic->ic_softc; in lkpi_ic_node_alloc()
3617 /* We keep allocations de-coupled so we can deal with the two worlds. */ in lkpi_ic_node_alloc()
3618 if (lhw->ic_node_alloc == NULL) in lkpi_ic_node_alloc()
3621 ni = lhw->ic_node_alloc(vap, mac); in lkpi_ic_node_alloc()
3625 hw = LHW_TO_HW(lhw); in lkpi_ic_node_alloc()
3626 lsta = lkpi_lsta_alloc(vap, mac, hw, ni); in lkpi_ic_node_alloc()
3628 if (lhw->ic_node_free != NULL) in lkpi_ic_node_alloc()
3629 lhw->ic_node_free(ni); in lkpi_ic_node_alloc()
3643 ic = ni->ni_ic; in lkpi_ic_node_init()
3644 lhw = ic->ic_softc; in lkpi_ic_node_init()
3646 if (lhw->ic_node_init != NULL) { in lkpi_ic_node_init()
3647 error = lhw->ic_node_init(ni); in lkpi_ic_node_init()
3652 /* XXX-BZ Sync other state over. */ in lkpi_ic_node_init()
3664 ic = ni->ni_ic; in lkpi_ic_node_cleanup()
3665 lhw = ic->ic_softc; in lkpi_ic_node_cleanup()
3667 /* XXX-BZ remove from driver, ... */ in lkpi_ic_node_cleanup()
3670 if (lhw->ic_node_cleanup != NULL) in lkpi_ic_node_cleanup()
3671 lhw->ic_node_cleanup(ni); in lkpi_ic_node_cleanup()
3681 ic = ni->ni_ic; in lkpi_ic_node_free()
3682 lhw = ic->ic_softc; in lkpi_ic_node_free()
3683 lsta = ni->ni_drv_data; in lkpi_ic_node_free()
3689 * it is the same as lsta->ni. in lkpi_ic_node_free()
3693 if (lhw->ic_node_free != NULL) in lkpi_ic_node_free()
3694 lhw->ic_node_free(ni); in lkpi_ic_node_free()
3703 lsta = ni->ni_drv_data; in lkpi_ic_raw_xmit()
3705 if (!lsta->added_to_drv || !lsta->txq_ready) { in lkpi_ic_raw_xmit()
3716 mbufq_enqueue(&lsta->txq, m); in lkpi_ic_raw_xmit()
3717 taskqueue_enqueue(taskqueue_thread, &lsta->txq_task); in lkpi_ic_raw_xmit()
3723 __func__, __LINE__, lsta, ni, ni->ni_macaddr, ":", in lkpi_ic_raw_xmit()
3724 mbufq_len(&lsta->txq)); in lkpi_ic_raw_xmit()
3741 struct ieee80211_hw *hw; in lkpi_80211_txq_tx_one() local
3756 hexdump(mtod(m, const void *), m->m_len, "RAW TX (plain) ", 0); in lkpi_80211_txq_tx_one()
3759 ni = lsta->ni; in lkpi_80211_txq_tx_one()
3762 /* Encrypt the frame if need be; XXX-BZ info->control.hw_key. */ in lkpi_80211_txq_tx_one()
3764 if (wh->i_fc[1] & IEEE80211_FC1_PROTECTED) { in lkpi_80211_txq_tx_one()
3775 ic = ni->ni_ic; in lkpi_80211_txq_tx_one()
3776 lhw = ic->ic_softc; in lkpi_80211_txq_tx_one()
3777 hw = LHW_TO_HW(lhw); in lkpi_80211_txq_tx_one()
3778 c = ni->ni_chan; in lkpi_80211_txq_tx_one()
3780 if (ieee80211_radiotap_active_vap(ni->ni_vap)) { in lkpi_80211_txq_tx_one()
3783 rtap = &lhw->rtap_tx; in lkpi_80211_txq_tx_one()
3784 rtap->wt_flags = 0; in lkpi_80211_txq_tx_one()
3786 rtap->wt_flags |= IEEE80211_RADIOTAP_F_WEP; in lkpi_80211_txq_tx_one()
3787 if (m->m_flags & M_FRAG) in lkpi_80211_txq_tx_one()
3788 rtap->wt_flags |= IEEE80211_RADIOTAP_F_FRAG; in lkpi_80211_txq_tx_one()
3790 rtap->wt_rate = 0; in lkpi_80211_txq_tx_one()
3792 rtap->wt_chan_freq = htole16(c->ic_freq); in lkpi_80211_txq_tx_one()
3793 rtap->wt_chan_flags = htole16(c->ic_flags); in lkpi_80211_txq_tx_one()
3796 ieee80211_radiotap_tx(ni->ni_vap, m); in lkpi_80211_txq_tx_one()
3800 * net80211 should handle hw->extra_tx_headroom. in lkpi_80211_txq_tx_one()
3802 * XXX-BZ rtw88 asks for too much headroom for ipv6+tcp: in lkpi_80211_txq_tx_one()
3803 * https://lists.freebsd.org/archives/freebsd-transport/2022-February/000012.html in lkpi_80211_txq_tx_one()
3805 skb = dev_alloc_skb(hw->extra_tx_headroom + m->m_pkthdr.len); in lkpi_80211_txq_tx_one()
3812 skb_reserve(skb, hw->extra_tx_headroom); in lkpi_80211_txq_tx_one()
3814 /* XXX-BZ we need a SKB version understanding mbuf. */ in lkpi_80211_txq_tx_one()
3816 skb->m_free_func = lkpi_ieee80211_free_skb_mbuf; in lkpi_80211_txq_tx_one()
3817 skb->m = m; in lkpi_80211_txq_tx_one()
3819 skb_put_data(skb, m->m_data, m->m_pkthdr.len); in lkpi_80211_txq_tx_one()
3821 buf = skb_put(skb, m->m_pkthdr.len); in lkpi_80211_txq_tx_one()
3822 m_copydata(m, 0, m->m_pkthdr.len, buf); in lkpi_80211_txq_tx_one()
3825 m->m_pkthdr.PH_loc.ptr = ni; in lkpi_80211_txq_tx_one()
3827 lvif = VAP_TO_LVIF(ni->ni_vap); in lkpi_80211_txq_tx_one()
3830 hdr = (void *)skb->data; in lkpi_80211_txq_tx_one()
3833 if (!ieee80211_is_data(hdr->frame_control)) { in lkpi_80211_txq_tx_one()
3835 skb->priority = 7; in lkpi_80211_txq_tx_one()
3838 /* Other non-QOS traffic goes to BE. */ in lkpi_80211_txq_tx_one()
3840 skb->priority = 0; in lkpi_80211_txq_tx_one()
3844 skb->priority = tid & IEEE80211_QOS_CTL_TID_MASK; in lkpi_80211_txq_tx_one()
3850 info->flags |= IEEE80211_TX_CTL_REQ_TX_STATUS; in lkpi_80211_txq_tx_one()
3853 c = ic->ic_curchan; in lkpi_80211_txq_tx_one()
3854 info->band = lkpi_net80211_chan_to_nl80211_band(c); in lkpi_80211_txq_tx_one()
3855 info->hw_queue = vif->hw_queue[ac]; in lkpi_80211_txq_tx_one()
3856 if (m->m_flags & M_EAPOL) in lkpi_80211_txq_tx_one()
3857 info->control.flags |= IEEE80211_TX_CTRL_PORT_CTRL_PROTO; in lkpi_80211_txq_tx_one()
3858 info->control.vif = vif; in lkpi_80211_txq_tx_one()
3859 /* XXX-BZ info->control.rates */ in lkpi_80211_txq_tx_one()
3862 info->control.rts_cts_rate_idx= in lkpi_80211_txq_tx_one()
3863 info->control.use_rts= /* RTS */ in lkpi_80211_txq_tx_one()
3864 info->control.use_cts_prot= /* RTS/CTS*/ in lkpi_80211_txq_tx_one()
3870 info->control.hw_key = lsta->kc; in lkpi_80211_txq_tx_one()
3876 if (!ieee80211_is_data_present(hdr->frame_control)) { in lkpi_80211_txq_tx_one()
3877 if (vif->type == NL80211_IFTYPE_STATION && in lkpi_80211_txq_tx_one()
3878 lsta->added_to_drv && in lkpi_80211_txq_tx_one()
3879 sta->txq[IEEE80211_NUM_TIDS] != NULL) in lkpi_80211_txq_tx_one()
3880 ltxq = TXQ_TO_LTXQ(sta->txq[IEEE80211_NUM_TIDS]); in lkpi_80211_txq_tx_one()
3881 } else if (lsta->added_to_drv && in lkpi_80211_txq_tx_one()
3882 sta->txq[skb->priority] != NULL) { in lkpi_80211_txq_tx_one()
3883 ltxq = TXQ_TO_LTXQ(sta->txq[skb->priority]); in lkpi_80211_txq_tx_one()
3892 skb_queue_tail(&ltxq->skbq, skb); in lkpi_80211_txq_tx_one()
3899 curthread->td_tid, (unsigned int)ticks, in lkpi_80211_txq_tx_one()
3900 lsta, sta, ni, ni->ni_macaddr, ":", skb, ltxq, in lkpi_80211_txq_tx_one()
3901 skb_queue_len(&ltxq->skbq), ltxq->txq.ac, in lkpi_80211_txq_tx_one()
3902 ltxq->txq.tid, ac, skb->priority, skb->qmap); in lkpi_80211_txq_tx_one()
3906 lkpi_80211_mo_wake_tx_queue(hw, &ltxq->txq); in lkpi_80211_txq_tx_one()
3915 __func__, __LINE__, lsta, sta, ni, ni->ni_macaddr, ":", in lkpi_80211_txq_tx_one()
3916 skb, ac, skb->priority, skb->qmap); in lkpi_80211_txq_tx_one()
3921 lkpi_80211_mo_tx(hw, &control, skb); in lkpi_80211_txq_tx_one()
3938 __func__, __LINE__, lsta, lsta->ni, lsta->ni->ni_macaddr, ":", in lkpi_80211_txq_task()
3939 pending, mbufq_len(&lsta->txq)); in lkpi_80211_txq_task()
3946 * Do not re-check lsta->txq_ready here; we may have a pending in lkpi_80211_txq_task()
3953 shall_tx = lsta->added_to_drv && lsta->txq_ready; in lkpi_80211_txq_task()
3955 mbufq_concat(&mq, &lsta->txq); in lkpi_80211_txq_task()
3958 * lkpi_lsta_free() will drain the lsta->txq and free the mbufs. in lkpi_80211_txq_task()
3979 ni = (struct ieee80211_node *)m->m_pkthdr.rcvif; in lkpi_ic_transmit()
3991 ic = ni->ni_ic; in lkpi_ic_recv_action()
3992 lhw = ic->ic_softc; in lkpi_ic_recv_action()
3996 return (lhw->ic_recv_action(ni, wh, frm, efrm)); in lkpi_ic_recv_action()
4005 ic = ni->ni_ic; in lkpi_ic_send_action()
4006 lhw = ic->ic_softc; in lkpi_ic_send_action()
4010 return (lhw->ic_send_action(ni, category, action, sa)); in lkpi_ic_send_action()
4020 ic = ni->ni_ic; in lkpi_ic_ampdu_enable()
4021 lhw = ic->ic_softc; in lkpi_ic_ampdu_enable()
4025 return (lhw->ic_ampdu_enable(ni, tap)); in lkpi_ic_ampdu_enable()
4040 struct ieee80211_hw *hw; in lkpi_ic_addba_request() local
4049 ic = ni->ni_ic; in lkpi_ic_addba_request()
4050 lhw = ic->ic_softc; in lkpi_ic_addba_request()
4051 hw = LHW_TO_HW(lhw); in lkpi_ic_addba_request()
4052 vap = ni->ni_vap; in lkpi_ic_addba_request()
4055 lsta = ni->ni_drv_data; in lkpi_ic_addba_request()
4058 if (!lsta->added_to_drv) { in lkpi_ic_addba_request()
4069 params.ssn = tap->txa_start & (IEEE80211_SEQ_RANGE-1); in lkpi_ic_addba_request()
4070 params.tid = tap->txa_tid; in lkpi_ic_addba_request()
4075 error = lkpi_80211_mo_ampdu_action(hw, vif, &params); in lkpi_ic_addba_request()
4084 return (lhw->ic_addba_request(ni, tap, dialogtoken, baparamset, batimeout)); in lkpi_ic_addba_request()
4100 struct ieee80211_hw *hw; in lkpi_ic_addba_response() local
4109 ic = ni->ni_ic; in lkpi_ic_addba_response()
4110 lhw = ic->ic_softc; in lkpi_ic_addba_response()
4111 hw = LHW_TO_HW(lhw); in lkpi_ic_addba_response()
4112 vap = ni->ni_vap; in lkpi_ic_addba_response()
4115 lsta = ni->ni_drv_data; in lkpi_ic_addba_response()
4118 if (!lsta->added_to_drv) { in lkpi_ic_addba_response()
4127 params.buf_size = tap->txa_wnd; in lkpi_ic_addba_response()
4130 params.tid = tap->txa_tid; in lkpi_ic_addba_response()
4131 if ((tap->txa_flags & IEEE80211_AGGR_AMSDU) != 0) in lkpi_ic_addba_response()
4147 params.tid = tap->txa_tid; in lkpi_ic_addba_response()
4153 error = lkpi_80211_mo_ampdu_action(hw, vif, &params); in lkpi_ic_addba_response()
4162 …IMPROVE_HT("who unleashes the TXQ? and when?, do we need to ni->ni_txseqs[tid] = tap->txa_start & … in lkpi_ic_addba_response()
4164 return (lhw->ic_addba_response(ni, tap, status, baparamset, batimeout)); in lkpi_ic_addba_response()
4176 struct ieee80211_hw *hw; in lkpi_ic_addba_stop() local
4185 ic = ni->ni_ic; in lkpi_ic_addba_stop()
4186 lhw = ic->ic_softc; in lkpi_ic_addba_stop()
4187 hw = LHW_TO_HW(lhw); in lkpi_ic_addba_stop()
4188 vap = ni->ni_vap; in lkpi_ic_addba_stop()
4191 lsta = ni->ni_drv_data; in lkpi_ic_addba_stop()
4194 if (!lsta->added_to_drv) { in lkpi_ic_addba_stop()
4207 params.tid = tap->txa_tid; in lkpi_ic_addba_stop()
4212 error = lkpi_80211_mo_ampdu_action(hw, vif, &params); in lkpi_ic_addba_stop()
4224 lhw->ic_addba_stop(ni, tap); in lkpi_ic_addba_stop()
4233 ic = ni->ni_ic; in lkpi_ic_addba_response_timeout()
4234 lhw = ic->ic_softc; in lkpi_ic_addba_response_timeout()
4238 lhw->ic_addba_response_timeout(ni, tap); in lkpi_ic_addba_response_timeout()
4248 ic = ni->ni_ic; in lkpi_ic_bar_response()
4249 lhw = ic->ic_softc; in lkpi_ic_bar_response()
4253 lhw->ic_bar_response(ni, tap, status); in lkpi_ic_bar_response()
4262 struct ieee80211_hw *hw; in lkpi_ic_ampdu_rx_start() local
4271 ic = ni->ni_ic; in lkpi_ic_ampdu_rx_start()
4272 lhw = ic->ic_softc; in lkpi_ic_ampdu_rx_start()
4273 hw = LHW_TO_HW(lhw); in lkpi_ic_ampdu_rx_start()
4274 vap = ni->ni_vap; in lkpi_ic_ampdu_rx_start()
4277 lsta = ni->ni_drv_data; in lkpi_ic_ampdu_rx_start()
4282 if (!lsta->added_to_drv) { in lkpi_ic_ampdu_rx_start()
4285 return (-ENXIO); in lkpi_ic_ampdu_rx_start()
4295 if (hw->max_rx_aggregation_subframes > 0 && in lkpi_ic_ampdu_rx_start()
4296 params.buf_size > hw->max_rx_aggregation_subframes) in lkpi_ic_ampdu_rx_start()
4297 params.buf_size = hw->max_rx_aggregation_subframes; in lkpi_ic_ampdu_rx_start()
4303 if ((vap->iv_htcaps & IEEE80211_HTC_RX_AMSDU_AMPDU) && in lkpi_ic_ampdu_rx_start()
4310 error = lkpi_80211_mo_ampdu_action(hw, vif, &params); in lkpi_ic_ampdu_rx_start()
4318 if (!ieee80211_hw_check(hw, SUPPORTS_REORDERING_BUFFER)) { in lkpi_ic_ampdu_rx_start()
4324 error = lhw->ic_ampdu_rx_start(ni, rap, baparamset, batimeout, baseqctl); in lkpi_ic_ampdu_rx_start()
4333 struct ieee80211_hw *hw; in lkpi_ic_ampdu_rx_stop() local
4343 ic = ni->ni_ic; in lkpi_ic_ampdu_rx_stop()
4344 lhw = ic->ic_softc; in lkpi_ic_ampdu_rx_stop()
4355 if ((rap->rxa_flags & IEEE80211_AGGR_RUNNING) == 0) in lkpi_ic_ampdu_rx_stop()
4358 hw = LHW_TO_HW(lhw); in lkpi_ic_ampdu_rx_stop()
4359 vap = ni->ni_vap; in lkpi_ic_ampdu_rx_stop()
4362 lsta = ni->ni_drv_data; in lkpi_ic_ampdu_rx_stop()
4367 if (&ni->ni_rx_ampdu[tid] == rap) in lkpi_ic_ampdu_rx_stop()
4381 error = lkpi_80211_mo_ampdu_action(hw, vif, &params); in lkpi_ic_ampdu_rx_stop()
4389 lhw->ic_ampdu_rx_stop(ni, rap); in lkpi_ic_ampdu_rx_stop()
4394 lkpi_ic_getradiocaps_ht(struct ieee80211com *ic, struct ieee80211_hw *hw, in lkpi_ic_getradiocaps_ht() argument
4400 ht_cap = &hw->wiphy->bands[band]->ht_cap; in lkpi_ic_getradiocaps_ht()
4401 if (!ht_cap->ht_supported) in lkpi_ic_getradiocaps_ht()
4416 ic->ic_htcaps = IEEE80211_HTC_HT; /* HT operation */ in lkpi_ic_getradiocaps_ht()
4423 ic->ic_htcaps |= ht_cap->cap; in lkpi_ic_getradiocaps_ht()
4426 if (ieee80211_hw_check(hw, AMPDU_AGGREGATION)) in lkpi_ic_getradiocaps_ht()
4427 ic->ic_htcaps |= IEEE80211_HTC_AMPDU; in lkpi_ic_getradiocaps_ht()
4429 if (ieee80211_hw_check(hw, TX_AMSDU)) in lkpi_ic_getradiocaps_ht()
4430 ic->ic_htcaps |= IEEE80211_HTC_AMSDU; in lkpi_ic_getradiocaps_ht()
4431 if (ieee80211_hw_check(hw, SUPPORTS_AMSDU_IN_AMPDU)) in lkpi_ic_getradiocaps_ht()
4432 ic->ic_htcaps |= (IEEE80211_HTC_RX_AMSDU_AMPDU | in lkpi_ic_getradiocaps_ht()
4437 ic->ic_htcaps |= IEEE80211_HTCAP_SMPS_OFF; in lkpi_ic_getradiocaps_ht()
4439 /* Only add HT40 channels if supported. */ in lkpi_ic_getradiocaps_ht()
4440 if ((ic->ic_htcaps & IEEE80211_HTCAP_CHWIDTH40) != 0 && in lkpi_ic_getradiocaps_ht()
4451 struct ieee80211_hw *hw; in lkpi_ic_getradiocaps() local
4452 struct linuxkpi_ieee80211_channel *channels; in lkpi_ic_getradiocaps() local
4456 /* Channels */ in lkpi_ic_getradiocaps()
4457 lhw = ic->ic_softc; in lkpi_ic_getradiocaps()
4458 hw = LHW_TO_HW(lhw); in lkpi_ic_getradiocaps()
4462 if (hw->wiphy->bands[NL80211_BAND_2GHZ] != NULL) in lkpi_ic_getradiocaps()
4463 nchans = hw->wiphy->bands[NL80211_BAND_2GHZ]->n_channels; in lkpi_ic_getradiocaps()
4468 /* XXX-BZ unclear how to check for 11g. */ in lkpi_ic_getradiocaps()
4473 lkpi_ic_getradiocaps_ht(ic, hw, bands, &chan_flags, in lkpi_ic_getradiocaps()
4476 channels = hw->wiphy->bands[NL80211_BAND_2GHZ]->channels; in lkpi_ic_getradiocaps()
4481 if (channels[i].flags & IEEE80211_CHAN_DISABLED) { in lkpi_ic_getradiocaps()
4484 channels[i].hw_value, in lkpi_ic_getradiocaps()
4485 channels[i].center_freq, channels[i].flags); in lkpi_ic_getradiocaps()
4488 if (channels[i].flags & IEEE80211_CHAN_NO_IR) in lkpi_ic_getradiocaps()
4490 if (channels[i].flags & IEEE80211_CHAN_RADAR) in lkpi_ic_getradiocaps()
4492 if (channels[i].flags & IEEE80211_CHAN_NO_160MHZ) in lkpi_ic_getradiocaps()
4494 if (channels[i].flags & IEEE80211_CHAN_NO_80MHZ) in lkpi_ic_getradiocaps()
4497 if (channels[i].flags & IEEE80211_CHAN_NO_HT40) in lkpi_ic_getradiocaps()
4501 channels[i].hw_value, channels[i].center_freq, in lkpi_ic_getradiocaps()
4502 channels[i].max_power, in lkpi_ic_getradiocaps()
4508 __func__, channels[i].hw_value, in lkpi_ic_getradiocaps()
4509 channels[i].center_freq, channels[i].flags, in lkpi_ic_getradiocaps()
4518 if (hw->wiphy->bands[NL80211_BAND_5GHZ] != NULL) in lkpi_ic_getradiocaps()
4519 nchans = hw->wiphy->bands[NL80211_BAND_5GHZ]->n_channels; in lkpi_ic_getradiocaps()
4525 lkpi_ic_getradiocaps_ht(ic, hw, bands, &chan_flags, in lkpi_ic_getradiocaps()
4529 if (hw->wiphy->bands[NL80211_BAND_5GHZ]->vht_cap.vht_supported){ in lkpi_ic_getradiocaps()
4531 ic->ic_flags_ext |= IEEE80211_FEXT_VHT; in lkpi_ic_getradiocaps()
4532 ic->ic_vht_cap.vht_cap_info = in lkpi_ic_getradiocaps()
4533 hw->wiphy->bands[NL80211_BAND_5GHZ]->vht_cap.cap; in lkpi_ic_getradiocaps()
4538 ic->ic_vht_cap.vht_cap_info)) in lkpi_ic_getradiocaps()
4541 ic->ic_vht_cap.vht_cap_info)) in lkpi_ic_getradiocaps()
4546 channels = hw->wiphy->bands[NL80211_BAND_5GHZ]->channels; in lkpi_ic_getradiocaps()
4551 if (channels[i].flags & IEEE80211_CHAN_DISABLED) { in lkpi_ic_getradiocaps()
4554 channels[i].hw_value, in lkpi_ic_getradiocaps()
4555 channels[i].center_freq, channels[i].flags); in lkpi_ic_getradiocaps()
4558 if (channels[i].flags & IEEE80211_CHAN_NO_IR) in lkpi_ic_getradiocaps()
4560 if (channels[i].flags & IEEE80211_CHAN_RADAR) in lkpi_ic_getradiocaps()
4562 if (channels[i].flags & IEEE80211_CHAN_NO_160MHZ) in lkpi_ic_getradiocaps()
4564 if (channels[i].flags & IEEE80211_CHAN_NO_80MHZ) in lkpi_ic_getradiocaps()
4567 if (channels[i].flags & IEEE80211_CHAN_NO_HT40) in lkpi_ic_getradiocaps()
4571 channels[i].hw_value, channels[i].center_freq, in lkpi_ic_getradiocaps()
4572 channels[i].max_power, in lkpi_ic_getradiocaps()
4578 __func__, channels[i].hw_value, in lkpi_ic_getradiocaps()
4579 channels[i].center_freq, channels[i].flags, in lkpi_ic_getradiocaps()
4595 ic->ic_softc = NULL; in lkpi_ieee80211_ifalloc()
4596 ic->ic_name = "linuxkpi"; in lkpi_ieee80211_ifalloc()
4604 struct ieee80211_hw *hw; in linuxkpi_ieee80211_alloc_hw() local
4615 lhw->ops = ops; in linuxkpi_ieee80211_alloc_hw()
4620 sx_init_flags(&lhw->lvif_sx, "lhw-lvif", SX_RECURSE | SX_DUPOK); in linuxkpi_ieee80211_alloc_hw()
4621 TAILQ_INIT(&lhw->lvif_head); in linuxkpi_ieee80211_alloc_hw()
4623 lhw->txq_generation[ac] = 1; in linuxkpi_ieee80211_alloc_hw()
4624 TAILQ_INIT(&lhw->scheduled_txqs[ac]); in linuxkpi_ieee80211_alloc_hw()
4629 TASK_INIT(&lhw->rxq_task, 0, lkpi_80211_lhw_rxq_task, lhw); in linuxkpi_ieee80211_alloc_hw()
4630 mbufq_init(&lhw->rxq, IFQ_MAXLEN); in linuxkpi_ieee80211_alloc_hw()
4631 lhw->rxq_stopped = false; in linuxkpi_ieee80211_alloc_hw()
4634 * XXX-BZ TODO make sure there is a "_null" function to all ops in linuxkpi_ieee80211_alloc_hw()
4637 hw = LHW_TO_HW(lhw); in linuxkpi_ieee80211_alloc_hw()
4638 hw->wiphy = wiphy; in linuxkpi_ieee80211_alloc_hw()
4639 hw->conf.flags |= IEEE80211_CONF_IDLE; in linuxkpi_ieee80211_alloc_hw()
4640 hw->priv = (void *)(lhw + 1); in linuxkpi_ieee80211_alloc_hw()
4643 lhw->ic = lkpi_ieee80211_ifalloc(); in linuxkpi_ieee80211_alloc_hw()
4647 return (hw); in linuxkpi_ieee80211_alloc_hw()
4651 linuxkpi_ieee80211_iffree(struct ieee80211_hw *hw) in linuxkpi_ieee80211_iffree() argument
4656 lhw = HW_TO_LHW(hw); in linuxkpi_ieee80211_iffree()
4657 free(lhw->ic, M_LKPI80211); in linuxkpi_ieee80211_iffree()
4658 lhw->ic = NULL; in linuxkpi_ieee80211_iffree()
4664 lhw->rxq_stopped = true; in linuxkpi_ieee80211_iffree()
4668 while (taskqueue_cancel(taskqueue_thread, &lhw->rxq_task, NULL) != 0) in linuxkpi_ieee80211_iffree()
4669 taskqueue_drain(taskqueue_thread, &lhw->rxq_task); in linuxkpi_ieee80211_iffree()
4672 m = mbufq_dequeue(&lhw->rxq); in linuxkpi_ieee80211_iffree()
4681 ieee80211_free_node(rxni->ni); in linuxkpi_ieee80211_iffree()
4684 m = mbufq_dequeue(&lhw->rxq); in linuxkpi_ieee80211_iffree()
4686 KASSERT(mbufq_empty(&lhw->rxq), ("%s: lhw %p has rxq len %d != 0\n", in linuxkpi_ieee80211_iffree()
4687 __func__, lhw, mbufq_len(&lhw->rxq))); in linuxkpi_ieee80211_iffree()
4694 sx_destroy(&lhw->lvif_sx); in linuxkpi_ieee80211_iffree()
4699 linuxkpi_set_ieee80211_dev(struct ieee80211_hw *hw, char *name) in linuxkpi_set_ieee80211_dev() argument
4704 lhw = HW_TO_LHW(hw); in linuxkpi_set_ieee80211_dev()
4705 ic = lhw->ic; in linuxkpi_set_ieee80211_dev()
4708 ic->ic_softc = lhw; in linuxkpi_set_ieee80211_dev()
4709 ic->ic_name = name; in linuxkpi_set_ieee80211_dev()
4711 /* XXX-BZ do we also need to set wiphy name? */ in linuxkpi_set_ieee80211_dev()
4728 ic = lhw->ic; in lkpi_radiotap_attach()
4730 &lhw->rtap_tx.wt_ihdr, sizeof(lhw->rtap_tx), in lkpi_radiotap_attach()
4732 &lhw->rtap_rx.wr_ihdr, sizeof(lhw->rtap_rx), in lkpi_radiotap_attach()
4737 linuxkpi_ieee80211_ifattach(struct ieee80211_hw *hw) in linuxkpi_ieee80211_ifattach() argument
4743 lhw = HW_TO_LHW(hw); in linuxkpi_ieee80211_ifattach()
4744 ic = lhw->ic; in linuxkpi_ieee80211_ifattach()
4746 /* We do it this late as wiphy->dev should be set for the name. */ in linuxkpi_ieee80211_ifattach()
4747 lhw->workq = alloc_ordered_workqueue(wiphy_name(hw->wiphy), 0); in linuxkpi_ieee80211_ifattach()
4748 if (lhw->workq == NULL) in linuxkpi_ieee80211_ifattach()
4749 return (-EAGAIN); in linuxkpi_ieee80211_ifattach()
4751 /* XXX-BZ figure this out how they count his... */ in linuxkpi_ieee80211_ifattach()
4752 if (!is_zero_ether_addr(hw->wiphy->perm_addr)) { in linuxkpi_ieee80211_ifattach()
4753 IEEE80211_ADDR_COPY(ic->ic_macaddr, in linuxkpi_ieee80211_ifattach()
4754 hw->wiphy->perm_addr); in linuxkpi_ieee80211_ifattach()
4755 } else if (hw->wiphy->n_addresses > 0) { in linuxkpi_ieee80211_ifattach()
4757 IEEE80211_ADDR_COPY(ic->ic_macaddr, in linuxkpi_ieee80211_ifattach()
4758 hw->wiphy->addresses[0].addr); in linuxkpi_ieee80211_ifattach()
4765 ic->ic_headroom = hw->extra_tx_headroom; in linuxkpi_ieee80211_ifattach()
4768 ic->ic_phytype = IEEE80211_T_OFDM; /* not only, but not used */ in linuxkpi_ieee80211_ifattach()
4769 ic->ic_opmode = IEEE80211_M_STA; in linuxkpi_ieee80211_ifattach()
4772 /* XXX-BZ we need to get these from linux80211/drivers and convert. */ in linuxkpi_ieee80211_ifattach()
4773 ic->ic_caps = in linuxkpi_ieee80211_ifattach()
4787 /* Scanning is a different kind of beast to re-work. */ in linuxkpi_ieee80211_ifattach()
4788 ic->ic_caps |= IEEE80211_C_BGSCAN; in linuxkpi_ieee80211_ifattach()
4790 if (lhw->ops->hw_scan) { in linuxkpi_ieee80211_ifattach()
4792 * Advertise full-offload scanning. in linuxkpi_ieee80211_ifattach()
4798 ic->ic_flags_ext |= IEEE80211_FEXT_SCAN_OFFLOAD; in linuxkpi_ieee80211_ifattach()
4799 lhw->scan_flags |= LKPI_LHW_SCAN_HW; in linuxkpi_ieee80211_ifattach()
4806 * XXX-BZ will the count alone do us much good long-term in net80211? in linuxkpi_ieee80211_ifattach()
4808 if (hw->wiphy->available_antennas_rx || in linuxkpi_ieee80211_ifattach()
4809 hw->wiphy->available_antennas_tx) { in linuxkpi_ieee80211_ifattach()
4812 if (lkpi_80211_mo_get_antenna(hw, &txs, &rxs) == 0) { in linuxkpi_ieee80211_ifattach()
4813 ic->ic_rxstream = bitcount32(rxs); in linuxkpi_ieee80211_ifattach()
4814 ic->ic_txstream = bitcount32(txs); in linuxkpi_ieee80211_ifattach()
4818 ic->ic_cryptocaps = 0; in linuxkpi_ieee80211_ifattach()
4820 if (hw->wiphy->n_cipher_suites > 0) { in linuxkpi_ieee80211_ifattach()
4821 for (i = 0; i < hw->wiphy->n_cipher_suites; i++) in linuxkpi_ieee80211_ifattach()
4822 ic->ic_cryptocaps |= lkpi_l80211_to_net80211_cyphers( in linuxkpi_ieee80211_ifattach()
4823 hw->wiphy->cipher_suites[i]); in linuxkpi_ieee80211_ifattach()
4827 lkpi_ic_getradiocaps(ic, IEEE80211_CHAN_MAX, &ic->ic_nchans, in linuxkpi_ieee80211_ifattach()
4828 ic->ic_channels); in linuxkpi_ieee80211_ifattach()
4832 ic->ic_update_mcast = lkpi_ic_update_mcast; in linuxkpi_ieee80211_ifattach()
4833 ic->ic_update_promisc = lkpi_ic_update_promisc; in linuxkpi_ieee80211_ifattach()
4834 ic->ic_update_chw = lkpi_ic_update_chw; in linuxkpi_ieee80211_ifattach()
4835 ic->ic_parent = lkpi_ic_parent; in linuxkpi_ieee80211_ifattach()
4836 ic->ic_scan_start = lkpi_ic_scan_start; in linuxkpi_ieee80211_ifattach()
4837 ic->ic_scan_end = lkpi_ic_scan_end; in linuxkpi_ieee80211_ifattach()
4838 ic->ic_set_channel = lkpi_ic_set_channel; in linuxkpi_ieee80211_ifattach()
4839 ic->ic_transmit = lkpi_ic_transmit; in linuxkpi_ieee80211_ifattach()
4840 ic->ic_raw_xmit = lkpi_ic_raw_xmit; in linuxkpi_ieee80211_ifattach()
4841 ic->ic_vap_create = lkpi_ic_vap_create; in linuxkpi_ieee80211_ifattach()
4842 ic->ic_vap_delete = lkpi_ic_vap_delete; in linuxkpi_ieee80211_ifattach()
4843 ic->ic_getradiocaps = lkpi_ic_getradiocaps; in linuxkpi_ieee80211_ifattach()
4844 ic->ic_wme.wme_update = lkpi_ic_wme_update; in linuxkpi_ieee80211_ifattach()
4846 lhw->ic_scan_curchan = ic->ic_scan_curchan; in linuxkpi_ieee80211_ifattach()
4847 ic->ic_scan_curchan = lkpi_ic_scan_curchan; in linuxkpi_ieee80211_ifattach()
4848 lhw->ic_scan_mindwell = ic->ic_scan_mindwell; in linuxkpi_ieee80211_ifattach()
4849 ic->ic_scan_mindwell = lkpi_ic_scan_mindwell; in linuxkpi_ieee80211_ifattach()
4851 lhw->ic_node_alloc = ic->ic_node_alloc; in linuxkpi_ieee80211_ifattach()
4852 ic->ic_node_alloc = lkpi_ic_node_alloc; in linuxkpi_ieee80211_ifattach()
4853 lhw->ic_node_init = ic->ic_node_init; in linuxkpi_ieee80211_ifattach()
4854 ic->ic_node_init = lkpi_ic_node_init; in linuxkpi_ieee80211_ifattach()
4855 lhw->ic_node_cleanup = ic->ic_node_cleanup; in linuxkpi_ieee80211_ifattach()
4856 ic->ic_node_cleanup = lkpi_ic_node_cleanup; in linuxkpi_ieee80211_ifattach()
4857 lhw->ic_node_free = ic->ic_node_free; in linuxkpi_ieee80211_ifattach()
4858 ic->ic_node_free = lkpi_ic_node_free; in linuxkpi_ieee80211_ifattach()
4865 if (lhw->ops->ampdu_action != NULL) { in linuxkpi_ieee80211_ifattach()
4866 lhw->ic_recv_action = ic->ic_recv_action; in linuxkpi_ieee80211_ifattach()
4867 ic->ic_recv_action = lkpi_ic_recv_action; in linuxkpi_ieee80211_ifattach()
4868 lhw->ic_send_action = ic->ic_send_action; in linuxkpi_ieee80211_ifattach()
4869 ic->ic_send_action = lkpi_ic_send_action; in linuxkpi_ieee80211_ifattach()
4871 lhw->ic_ampdu_enable = ic->ic_ampdu_enable; in linuxkpi_ieee80211_ifattach()
4872 ic->ic_ampdu_enable = lkpi_ic_ampdu_enable; in linuxkpi_ieee80211_ifattach()
4874 lhw->ic_addba_request = ic->ic_addba_request; in linuxkpi_ieee80211_ifattach()
4875 ic->ic_addba_request = lkpi_ic_addba_request; in linuxkpi_ieee80211_ifattach()
4876 lhw->ic_addba_response = ic->ic_addba_response; in linuxkpi_ieee80211_ifattach()
4877 ic->ic_addba_response = lkpi_ic_addba_response; in linuxkpi_ieee80211_ifattach()
4878 lhw->ic_addba_stop = ic->ic_addba_stop; in linuxkpi_ieee80211_ifattach()
4879 ic->ic_addba_stop = lkpi_ic_addba_stop; in linuxkpi_ieee80211_ifattach()
4880 lhw->ic_addba_response_timeout = ic->ic_addba_response_timeout; in linuxkpi_ieee80211_ifattach()
4881 ic->ic_addba_response_timeout = lkpi_ic_addba_response_timeout; in linuxkpi_ieee80211_ifattach()
4883 lhw->ic_bar_response = ic->ic_bar_response; in linuxkpi_ieee80211_ifattach()
4884 ic->ic_bar_response = lkpi_ic_bar_response; in linuxkpi_ieee80211_ifattach()
4886 lhw->ic_ampdu_rx_start = ic->ic_ampdu_rx_start; in linuxkpi_ieee80211_ifattach()
4887 ic->ic_ampdu_rx_start = lkpi_ic_ampdu_rx_start; in linuxkpi_ieee80211_ifattach()
4888 lhw->ic_ampdu_rx_stop = ic->ic_ampdu_rx_stop; in linuxkpi_ieee80211_ifattach()
4889 ic->ic_ampdu_rx_stop = lkpi_ic_ampdu_rx_stop; in linuxkpi_ieee80211_ifattach()
4901 lhw->supbands = lhw->max_rates = 0; in linuxkpi_ieee80211_ifattach()
4904 struct linuxkpi_ieee80211_channel *channels; in linuxkpi_ieee80211_ifattach() local
4906 supband = hw->wiphy->bands[band]; in linuxkpi_ieee80211_ifattach()
4907 if (supband == NULL || supband->n_channels == 0) in linuxkpi_ieee80211_ifattach()
4910 lhw->supbands++; in linuxkpi_ieee80211_ifattach()
4911 lhw->max_rates = max(lhw->max_rates, supband->n_bitrates); in linuxkpi_ieee80211_ifattach()
4914 if (hw->conf.chandef.chan != NULL) in linuxkpi_ieee80211_ifattach()
4917 channels = supband->channels; in linuxkpi_ieee80211_ifattach()
4918 for (i = 0; i < supband->n_channels; i++) { in linuxkpi_ieee80211_ifattach()
4920 if (channels[i].flags & IEEE80211_CHAN_DISABLED) in linuxkpi_ieee80211_ifattach()
4923 cfg80211_chandef_create(&hw->conf.chandef, &channels[i], in linuxkpi_ieee80211_ifattach()
4925 (ic->ic_htcaps & IEEE80211_HTC_HT) ? 0 : in linuxkpi_ieee80211_ifattach()
4932 …IMPROVE("see net80211::ieee80211_chan_init vs. wiphy->bands[].bitrates possibly in lkpi_ic_getradi… in linuxkpi_ieee80211_ifattach()
4935 if (lhw->max_rates > IEEE80211_RATE_MAXSIZE) { in linuxkpi_ieee80211_ifattach()
4937 lhw->max_rates, IEEE80211_RATE_MAXSIZE); in linuxkpi_ieee80211_ifattach()
4938 lhw->max_rates = IEEE80211_RATE_MAXSIZE; in linuxkpi_ieee80211_ifattach()
4943 * DSSS Parameter Set give our per-band IE size. in linuxkpi_ieee80211_ifattach()
4948 lhw->scan_ie_len = 2 + IEEE80211_RATE_SIZE; in linuxkpi_ieee80211_ifattach()
4949 if (lhw->max_rates > IEEE80211_RATE_SIZE) in linuxkpi_ieee80211_ifattach()
4950 lhw->scan_ie_len += 2 + (lhw->max_rates - IEEE80211_RATE_SIZE); in linuxkpi_ieee80211_ifattach()
4952 if (hw->wiphy->features & NL80211_FEATURE_DS_PARAM_SET_IE_IN_PROBES) { in linuxkpi_ieee80211_ifattach()
4958 lhw->scan_ie_len += 2 + 1; in linuxkpi_ieee80211_ifattach()
4962 if ((ic->ic_htcaps & IEEE80211_HTC_HT) != 0) in linuxkpi_ieee80211_ifattach()
4963 lhw->scan_ie_len += sizeof(struct ieee80211_ie_htcap); in linuxkpi_ieee80211_ifattach()
4966 if ((ic->ic_flags_ext & IEEE80211_FEXT_VHT) != 0) in linuxkpi_ieee80211_ifattach()
4967 lhw->scan_ie_len += 2 + sizeof(struct ieee80211_vht_cap); in linuxkpi_ieee80211_ifattach()
4971 if (hw->wiphy->max_scan_ie_len > 0) { in linuxkpi_ieee80211_ifattach()
4972 if (lhw->scan_ie_len > hw->wiphy->max_scan_ie_len) in linuxkpi_ieee80211_ifattach()
4974 hw->wiphy->max_scan_ie_len -= lhw->scan_ie_len; in linuxkpi_ieee80211_ifattach()
4983 return (-EAGAIN); in linuxkpi_ieee80211_ifattach()
4987 linuxkpi_ieee80211_ifdetach(struct ieee80211_hw *hw) in linuxkpi_ieee80211_ifdetach() argument
4992 lhw = HW_TO_LHW(hw); in linuxkpi_ieee80211_ifdetach()
4993 ic = lhw->ic; in linuxkpi_ieee80211_ifdetach()
4998 linuxkpi_ieee80211_iterate_interfaces(struct ieee80211_hw *hw, in linuxkpi_ieee80211_iterate_interfaces() argument
5008 lhw = HW_TO_LHW(hw); in linuxkpi_ieee80211_iterate_interfaces()
5014 ic_printf(lhw->ic, "XXX TODO %s flags(%#x) not yet supported.\n", in linuxkpi_ieee80211_iterate_interfaces()
5024 TAILQ_FOREACH(lvif, &lhw->lvif_head, lvif_entry) { in linuxkpi_ieee80211_iterate_interfaces()
5035 if (active && !lvif->added_to_drv && in linuxkpi_ieee80211_iterate_interfaces()
5043 if (nin_drv && !lvif->added_to_drv) in linuxkpi_ieee80211_iterate_interfaces()
5050 /* XXX-BZ probably should have state in the lvif as well. */ in linuxkpi_ieee80211_iterate_interfaces()
5052 if (!active || (vap->iv_state != IEEE80211_S_INIT)) in linuxkpi_ieee80211_iterate_interfaces()
5053 iterfunc(arg, vif->addr, vif); in linuxkpi_ieee80211_iterate_interfaces()
5060 linuxkpi_ieee80211_iterate_keys(struct ieee80211_hw *hw, in linuxkpi_ieee80211_iterate_keys() argument
5071 linuxkpi_ieee80211_iterate_chan_contexts(struct ieee80211_hw *hw, in linuxkpi_ieee80211_iterate_chan_contexts() argument
5081 KASSERT(hw != NULL && iterfunc != NULL, in linuxkpi_ieee80211_iterate_chan_contexts()
5082 ("%s: hw %p iterfunc %p arg %p\n", __func__, hw, iterfunc, arg)); in linuxkpi_ieee80211_iterate_chan_contexts()
5084 lhw = HW_TO_LHW(hw); in linuxkpi_ieee80211_iterate_chan_contexts()
5089 TAILQ_FOREACH(lvif, &lhw->lvif_head, lvif_entry) { in linuxkpi_ieee80211_iterate_chan_contexts()
5092 if (vif->chanctx_conf == NULL) in linuxkpi_ieee80211_iterate_chan_contexts()
5095 lchanctx = CHANCTX_CONF_TO_LCHANCTX(vif->chanctx_conf); in linuxkpi_ieee80211_iterate_chan_contexts()
5096 if (!lchanctx->added_to_drv) in linuxkpi_ieee80211_iterate_chan_contexts()
5099 iterfunc(hw, &lchanctx->chanctx_conf, arg); in linuxkpi_ieee80211_iterate_chan_contexts()
5105 linuxkpi_ieee80211_iterate_stations_atomic(struct ieee80211_hw *hw, in linuxkpi_ieee80211_iterate_stations_atomic() argument
5113 KASSERT(hw != NULL && iterfunc != NULL, in linuxkpi_ieee80211_iterate_stations_atomic()
5114 ("%s: hw %p iterfunc %p arg %p\n", __func__, hw, iterfunc, arg)); in linuxkpi_ieee80211_iterate_stations_atomic()
5116 lhw = HW_TO_LHW(hw); in linuxkpi_ieee80211_iterate_stations_atomic()
5119 TAILQ_FOREACH(lvif, &lhw->lvif_head, lvif_entry) { in linuxkpi_ieee80211_iterate_stations_atomic()
5122 TAILQ_FOREACH(lsta, &lvif->lsta_head, lsta_entry) { in linuxkpi_ieee80211_iterate_stations_atomic()
5123 if (!lsta->added_to_drv) in linuxkpi_ieee80211_iterate_stations_atomic()
5152 ic = lhw->ic; in linuxkpi_regulatory_set_wiphy_regd_sync()
5154 rd = &ic->ic_regdomain; in linuxkpi_regulatory_set_wiphy_regd_sync()
5155 if (rd->isocc[0] == '\0') { in linuxkpi_regulatory_set_wiphy_regd_sync()
5156 rd->isocc[0] = regd->alpha2[0]; in linuxkpi_regulatory_set_wiphy_regd_sync()
5157 rd->isocc[1] = regd->alpha2[1]; in linuxkpi_regulatory_set_wiphy_regd_sync()
5161 /* XXX-BZ finish the rest. */ in linuxkpi_regulatory_set_wiphy_regd_sync()
5167 linuxkpi_ieee80211_scan_completed(struct ieee80211_hw *hw, in linuxkpi_ieee80211_scan_completed() argument
5174 lhw = wiphy_priv(hw->wiphy); in linuxkpi_ieee80211_scan_completed()
5175 ic = lhw->ic; in linuxkpi_ieee80211_scan_completed()
5176 ss = ic->ic_scan; in linuxkpi_ieee80211_scan_completed()
5178 ieee80211_scan_done(ss->ss_vap); in linuxkpi_ieee80211_scan_completed()
5181 free(lhw->hw_req, M_LKPI80211); in linuxkpi_ieee80211_scan_completed()
5182 lhw->hw_req = NULL; in linuxkpi_ieee80211_scan_completed()
5183 lhw->scan_flags &= ~LKPI_LHW_SCAN_RUNNING; in linuxkpi_ieee80211_scan_completed()
5203 ni = rxni->ni; in lkpi_80211_lhw_rxq_rx_one()
5212 ok = ieee80211_input_mimo_all(lhw->ic, m); in lkpi_80211_lhw_rxq_rx_one()
5218 printf("TRACE-RX: %s: handled frame type %#0x\n", __func__, ok); in lkpi_80211_lhw_rxq_rx_one()
5233 printf("TRACE-RX: %s: lhw %p pending %d mbuf_qlen %d\n", in lkpi_80211_lhw_rxq_task()
5234 __func__, lhw, pending, mbufq_len(&lhw->rxq)); in lkpi_80211_lhw_rxq_task()
5240 mbufq_concat(&mq, &lhw->rxq); in lkpi_80211_lhw_rxq_task()
5252 linuxkpi_ieee80211_rx(struct ieee80211_hw *hw, struct sk_buff *skb, in linuxkpi_ieee80211_rx() argument
5270 if (skb->len < 2) { in linuxkpi_ieee80211_rx()
5280 m = m_get2(skb->len, M_NOWAIT, MT_DATA, M_PKTHDR); in linuxkpi_ieee80211_rx()
5283 m_copyback(m, 0, skb->tail - skb->data, skb->data); in linuxkpi_ieee80211_rx()
5286 offset = m->m_len; in linuxkpi_ieee80211_rx()
5287 for (i = 0; i < shinfo->nr_frags; i++) { in linuxkpi_ieee80211_rx()
5288 m_copyback(m, offset, shinfo->frags[i].size, in linuxkpi_ieee80211_rx()
5289 (uint8_t *)linux_page_address(shinfo->frags[i].page) + in linuxkpi_ieee80211_rx()
5290 shinfo->frags[i].offset); in linuxkpi_ieee80211_rx()
5291 offset += shinfo->frags[i].size; in linuxkpi_ieee80211_rx()
5296 hdr = (void *)skb->data; in linuxkpi_ieee80211_rx()
5297 is_beacon = ieee80211_is_beacon(hdr->frame_control); in linuxkpi_ieee80211_rx()
5304 printf("TRACE-RX: %s: skb %p a/l/d/t-len (%u/%u/%u/%u) " in linuxkpi_ieee80211_rx()
5306 __func__, skb, skb->_alloc_len, skb->len, skb->data_len, in linuxkpi_ieee80211_rx()
5307 skb->truesize, skb->head, skb->data, skb->tail, skb->end, in linuxkpi_ieee80211_rx()
5308 shinfo, shinfo->nr_frags, in linuxkpi_ieee80211_rx()
5309 m, m->m_pkthdr.len, m->m_len, is_beacon ? " beacon" : ""); in linuxkpi_ieee80211_rx()
5312 hexdump(mtod(m, const void *), m->m_len, "RX (raw) ", 0); in linuxkpi_ieee80211_rx()
5316 printf("TRACE-RX: %s: RXCB: %ju %ju %u, %#0x, %u, %#0x, %#0x, " in linuxkpi_ieee80211_rx()
5319 (uintmax_t)rx_status->boottime_ns, in linuxkpi_ieee80211_rx()
5320 (uintmax_t)rx_status->mactime, in linuxkpi_ieee80211_rx()
5321 rx_status->device_timestamp, in linuxkpi_ieee80211_rx()
5322 rx_status->flag, in linuxkpi_ieee80211_rx()
5323 rx_status->freq, in linuxkpi_ieee80211_rx()
5324 rx_status->bw, in linuxkpi_ieee80211_rx()
5325 rx_status->encoding, in linuxkpi_ieee80211_rx()
5326 rx_status->ampdu_reference, in linuxkpi_ieee80211_rx()
5327 rx_status->band, in linuxkpi_ieee80211_rx()
5328 rx_status->chains, in linuxkpi_ieee80211_rx()
5329 rx_status->chain_signal[0], in linuxkpi_ieee80211_rx()
5330 rx_status->chain_signal[1], in linuxkpi_ieee80211_rx()
5331 rx_status->chain_signal[2], in linuxkpi_ieee80211_rx()
5332 rx_status->chain_signal[3], in linuxkpi_ieee80211_rx()
5333 rx_status->signal, in linuxkpi_ieee80211_rx()
5334 rx_status->enc_flags, in linuxkpi_ieee80211_rx()
5335 rx_status->he_dcm, in linuxkpi_ieee80211_rx()
5336 rx_status->he_gi, in linuxkpi_ieee80211_rx()
5337 rx_status->he_ru, in linuxkpi_ieee80211_rx()
5338 rx_status->zero_length_psdu_type, in linuxkpi_ieee80211_rx()
5339 rx_status->nss, in linuxkpi_ieee80211_rx()
5340 rx_status->rate_idx); in linuxkpi_ieee80211_rx()
5346 /* XXX-BZ correct hardcoded rssi and noise floor, how? survey? */ in linuxkpi_ieee80211_rx()
5347 rx_stats.c_nf = -96; in linuxkpi_ieee80211_rx()
5348 if (ieee80211_hw_check(hw, SIGNAL_DBM) && in linuxkpi_ieee80211_rx()
5349 !(rx_status->flag & RX_FLAG_NO_SIGNAL_VAL)) in linuxkpi_ieee80211_rx()
5350 rssi = rx_status->signal; in linuxkpi_ieee80211_rx()
5357 rssi -= rx_stats.c_nf; in linuxkpi_ieee80211_rx()
5361 lkpi_nl80211_band_to_net80211_band(rx_status->band); in linuxkpi_ieee80211_rx()
5363 rx_stats.c_freq = rx_status->freq; in linuxkpi_ieee80211_rx()
5367 /* XXX-BZ dump the FreeBSD version of rx_stats as well! */ in linuxkpi_ieee80211_rx()
5369 lhw = HW_TO_LHW(hw); in linuxkpi_ieee80211_rx()
5370 ic = lhw->ic; in linuxkpi_ieee80211_rx()
5375 counter_u64_add(ic->ic_ierrors, 1); in linuxkpi_ieee80211_rx()
5382 ni = ieee80211_ref_node(lsta->ni); in linuxkpi_ieee80211_rx()
5389 lsta = ni->ni_drv_data; in linuxkpi_ieee80211_rx()
5393 vap = ni->ni_vap; in linuxkpi_ieee80211_rx()
5396 * XXX-BZ can we improve this by looking at the frame hdr in linuxkpi_ieee80211_rx()
5397 * or other meta-data passed up? in linuxkpi_ieee80211_rx()
5399 vap = TAILQ_FIRST(&ic->ic_vaps); in linuxkpi_ieee80211_rx()
5403 printf("TRACE-RX: %s: sta %p lsta %p state %d ni %p vap %p%s\n", in linuxkpi_ieee80211_rx()
5404 __func__, sta, lsta, (lsta != NULL) ? lsta->state : -1, in linuxkpi_ieee80211_rx()
5409 rx_status->device_timestamp > 0 && in linuxkpi_ieee80211_rx()
5410 m->m_pkthdr.len >= sizeof(struct ieee80211_frame)) { in linuxkpi_ieee80211_rx()
5416 if (!IEEE80211_ADDR_EQ(wh->i_addr2, ni->ni_bssid)) in linuxkpi_ieee80211_rx()
5424 vif->bss_conf.sync_device_ts = rx_status->device_timestamp; in linuxkpi_ieee80211_rx()
5433 if (vap != NULL && vap->iv_state > IEEE80211_S_INIT && in linuxkpi_ieee80211_rx()
5437 rtap = &lhw->rtap_rx; in linuxkpi_ieee80211_rx()
5438 rtap->wr_tsft = rx_status->device_timestamp; in linuxkpi_ieee80211_rx()
5439 rtap->wr_flags = 0; in linuxkpi_ieee80211_rx()
5440 if (rx_status->enc_flags & RX_ENC_FLAG_SHORTPRE) in linuxkpi_ieee80211_rx()
5441 rtap->wr_flags |= IEEE80211_RADIOTAP_F_SHORTPRE; in linuxkpi_ieee80211_rx()
5442 if (rx_status->enc_flags & RX_ENC_FLAG_SHORT_GI) in linuxkpi_ieee80211_rx()
5443 rtap->wr_flags |= IEEE80211_RADIOTAP_F_SHORTGI; in linuxkpi_ieee80211_rx()
5445 if (ieee80211_hw_check(hw, RX_INCLUDES_FCS)) in linuxkpi_ieee80211_rx()
5446 rtap->wr_flags |= IEEE80211_RADIOTAP_F_FCS; in linuxkpi_ieee80211_rx()
5448 if (rx_status->flag & RX_FLAG_FAILED_FCS_CRC) in linuxkpi_ieee80211_rx()
5449 rtap->wr_flags |= IEEE80211_RADIOTAP_F_BADFCS; in linuxkpi_ieee80211_rx()
5450 rtap->wr_rate = 0; in linuxkpi_ieee80211_rx()
5452 /* XXX TODO status->encoding / rate_index / bw */ in linuxkpi_ieee80211_rx()
5453 rtap->wr_chan_freq = htole16(rx_stats.c_freq); in linuxkpi_ieee80211_rx()
5454 if (ic->ic_curchan->ic_ieee == rx_stats.c_ieee) in linuxkpi_ieee80211_rx()
5455 rtap->wr_chan_flags = htole16(ic->ic_curchan->ic_flags); in linuxkpi_ieee80211_rx()
5456 rtap->wr_dbm_antsignal = rssi; in linuxkpi_ieee80211_rx()
5457 rtap->wr_dbm_antnoise = rx_stats.c_nf; in linuxkpi_ieee80211_rx()
5460 if (ieee80211_hw_check(hw, RX_INCLUDES_FCS)) in linuxkpi_ieee80211_rx()
5461 m_adj(m, -IEEE80211_CRC_LEN); in linuxkpi_ieee80211_rx()
5475 * Attach meta-information to the mbuf for the deferred RX path. in linuxkpi_ieee80211_rx()
5476 * Currently this is best-effort. Should we need to be hard, in linuxkpi_ieee80211_rx()
5487 rxni->ni = ni; /* We hold a reference. */ in linuxkpi_ieee80211_rx()
5493 if (lhw->rxq_stopped) { in linuxkpi_ieee80211_rx()
5499 mbufq_enqueue(&lhw->rxq, m); in linuxkpi_ieee80211_rx()
5500 taskqueue_enqueue(taskqueue_thread, &lhw->rxq_task); in linuxkpi_ieee80211_rx()
5506 /* The skb is ours so we can free it :-) */ in linuxkpi_ieee80211_rx()
5516 /* Linux seems to assume this is a QOS-Data-Frame */ in linuxkpi_ieee80211_get_tid()
5517 KASSERT(nonqos_ok || ieee80211_is_data_qos(hdr->frame_control), in linuxkpi_ieee80211_get_tid()
5519 hdr->frame_control)); in linuxkpi_ieee80211_get_tid()
5529 /* -------------------------------------------------------------------------- */
5544 wk = list_first_entry_or_null(&lwiphy->wwk_list, struct wiphy_work, entry); in lkpi_wiphy_work()
5551 list_del_init(&wk->entry); in lkpi_wiphy_work()
5554 if (!list_empty(&lwiphy->wwk_list)) in lkpi_wiphy_work()
5559 wk->fn(wiphy, wk); in lkpi_wiphy_work()
5572 /* Do not double-queue. */ in linuxkpi_wiphy_work_queue()
5573 if (list_empty(&wwk->entry)) in linuxkpi_wiphy_work_queue()
5574 list_add_tail(&wwk->entry, &lwiphy->wwk_list); in linuxkpi_wiphy_work_queue()
5582 queue_work(system_wq, &lwiphy->wwk); in linuxkpi_wiphy_work_queue()
5594 if (!list_empty(&wwk->entry)) in linuxkpi_wiphy_work_cancel()
5595 list_del_init(&wwk->entry); in linuxkpi_wiphy_work_cancel()
5608 if (wwk != NULL && list_empty(&wwk->entry)) { in linuxkpi_wiphy_work_flush()
5613 while (!list_empty(&lwiphy->wwk_list)) { in linuxkpi_wiphy_work_flush()
5615 wk = list_first_entry(&lwiphy->wwk_list, struct wiphy_work, in linuxkpi_wiphy_work_flush()
5617 list_del_init(&wk->entry); in linuxkpi_wiphy_work_flush()
5619 wk->fn(wiphy, wk); in linuxkpi_wiphy_work_flush()
5633 wiphy_work_queue(wdwk->wiphy, &wdwk->work); in lkpi_wiphy_delayed_work_timer()
5642 del_timer(&wdwk->timer); in linuxkpi_wiphy_delayed_work_queue()
5643 wiphy_work_queue(wiphy, &wdwk->work); in linuxkpi_wiphy_delayed_work_queue()
5645 wdwk->wiphy = wiphy; in linuxkpi_wiphy_delayed_work_queue()
5646 mod_timer(&wdwk->timer, jiffies + delay); in linuxkpi_wiphy_delayed_work_queue()
5654 del_timer_sync(&wdwk->timer); in linuxkpi_wiphy_delayed_work_cancel()
5655 wiphy_work_cancel(wiphy, &wdwk->work); in linuxkpi_wiphy_delayed_work_cancel()
5658 /* -------------------------------------------------------------------------- */
5669 lwiphy->ops = ops; in linuxkpi_wiphy_new()
5672 INIT_LIST_HEAD(&lwiphy->wwk_list); in linuxkpi_wiphy_new()
5673 INIT_WORK(&lwiphy->wwk, lkpi_wiphy_work); in linuxkpi_wiphy_new()
5677 mutex_init(&wiphy->mtx); in linuxkpi_wiphy_new()
5692 mutex_destroy(&wiphy->mtx); in linuxkpi_wiphy_free()
5734 TAILQ_FOREACH_SAFE(lsta, &lvif->lsta_head, lsta_entry, temp) {
5735 if (lsta->ni == ni) {
5756 TAILQ_FOREACH_SAFE(lsta, &lvif->lsta_head, lsta_entry, temp) { in linuxkpi_ieee80211_find_sta()
5758 if (IEEE80211_ADDR_EQ(sta->addr, peer)) { in linuxkpi_ieee80211_find_sta()
5768 linuxkpi_ieee80211_find_sta_by_ifaddr(struct ieee80211_hw *hw, in linuxkpi_ieee80211_find_sta_by_ifaddr() argument
5777 lhw = wiphy_priv(hw->wiphy); in linuxkpi_ieee80211_find_sta_by_ifaddr()
5781 TAILQ_FOREACH(lvif, &lhw->lvif_head, lvif_entry) { in linuxkpi_ieee80211_find_sta_by_ifaddr()
5783 /* XXX-BZ check our address from the vif. */ in linuxkpi_ieee80211_find_sta_by_ifaddr()
5787 !IEEE80211_ADDR_EQ(vif->addr, ourvifaddr)) in linuxkpi_ieee80211_find_sta_by_ifaddr()
5797 if (!lsta->added_to_drv) in linuxkpi_ieee80211_find_sta_by_ifaddr()
5805 linuxkpi_ieee80211_tx_dequeue(struct ieee80211_hw *hw, in linuxkpi_ieee80211_tx_dequeue() argument
5814 ltxq->seen_dequeue = true; in linuxkpi_ieee80211_tx_dequeue()
5816 if (ltxq->stopped) in linuxkpi_ieee80211_tx_dequeue()
5819 lvif = VIF_TO_LVIF(ltxq->txq.vif); in linuxkpi_ieee80211_tx_dequeue()
5820 if (lvif->hw_queue_stopped[ltxq->txq.ac]) { in linuxkpi_ieee80211_tx_dequeue()
5821 ltxq->stopped = true; in linuxkpi_ieee80211_tx_dequeue()
5825 IMPROVE("hw(TX_FRAG_LIST)"); in linuxkpi_ieee80211_tx_dequeue()
5828 skb = skb_dequeue(&ltxq->skbq); in linuxkpi_ieee80211_tx_dequeue()
5847 skb_queue_walk(&ltxq->skbq, skb) { in linuxkpi_ieee80211_txq_get_depth()
5849 bc += skb->len; in linuxkpi_ieee80211_txq_get_depth()
5869 _lkpi_ieee80211_free_txskb(struct ieee80211_hw *hw, struct sk_buff *skb, in _lkpi_ieee80211_free_txskb() argument
5875 m = skb->m; in _lkpi_ieee80211_free_txskb()
5876 skb->m = NULL; in _lkpi_ieee80211_free_txskb()
5879 ni = m->m_pkthdr.PH_loc.ptr; in _lkpi_ieee80211_free_txskb()
5887 linuxkpi_ieee80211_free_txskb(struct ieee80211_hw *hw, struct sk_buff *skb, in linuxkpi_ieee80211_free_txskb() argument
5891 _lkpi_ieee80211_free_txskb(hw, skb, status); in linuxkpi_ieee80211_free_txskb()
5896 linuxkpi_ieee80211_tx_status_ext(struct ieee80211_hw *hw, in linuxkpi_ieee80211_tx_status_ext() argument
5905 skb = txstat->skb; in linuxkpi_ieee80211_tx_status_ext()
5906 if (skb->m != NULL) { in linuxkpi_ieee80211_tx_status_ext()
5909 m = skb->m; in linuxkpi_ieee80211_tx_status_ext()
5910 ni = m->m_pkthdr.PH_loc.ptr; in linuxkpi_ieee80211_tx_status_ext()
5916 info = txstat->info; in linuxkpi_ieee80211_tx_status_ext()
5917 if (info->flags & IEEE80211_TX_STAT_ACK) { in linuxkpi_ieee80211_tx_status_ext()
5930 old_rate = ni->ni_vap->iv_bss->ni_txrate; in linuxkpi_ieee80211_tx_status_ext()
5932 txs.pktlen = skb->len; in linuxkpi_ieee80211_tx_status_ext()
5934 if (info->status.rates[0].count > 1) { in linuxkpi_ieee80211_tx_status_ext()
5935 txs.long_retries = info->status.rates[0].count - 1; /* 1 + retries in drivers. */ in linuxkpi_ieee80211_tx_status_ext()
5939 /* XXX-BZ convert check .flags for MCS/VHT/.. */ in linuxkpi_ieee80211_tx_status_ext()
5940 txs.final_rate = info->status.rates[0].idx; in linuxkpi_ieee80211_tx_status_ext()
5943 if (info->status.flags & IEEE80211_TX_STATUS_ACK_SIGNAL_VALID) { in linuxkpi_ieee80211_tx_status_ext()
5944 txs.rssi = info->status.ack_signal; /* XXX-BZ CONVERT? */ in linuxkpi_ieee80211_tx_status_ext()
5950 ridx = ieee80211_ratectl_rate(ni->ni_vap->iv_bss, NULL, 0); in linuxkpi_ieee80211_tx_status_ext()
5954 printf("TX-RATE: %s: old %d new %d ridx %d, " in linuxkpi_ieee80211_tx_status_ext()
5956 old_rate, ni->ni_vap->iv_bss->ni_txrate, in linuxkpi_ieee80211_tx_status_ext()
5964 printf("TX-STATUS: %s: hw %p skb %p status %d : flags %#x " in linuxkpi_ieee80211_tx_status_ext()
5970 __func__, hw, skb, status, info->flags, in linuxkpi_ieee80211_tx_status_ext()
5971 info->band, info->hw_queue, info->tx_time_est, in linuxkpi_ieee80211_tx_status_ext()
5972 info->status.rates[0].idx, info->status.rates[0].count, in linuxkpi_ieee80211_tx_status_ext()
5973 info->status.rates[0].flags, in linuxkpi_ieee80211_tx_status_ext()
5974 info->status.rates[1].idx, info->status.rates[1].count, in linuxkpi_ieee80211_tx_status_ext()
5975 info->status.rates[1].flags, in linuxkpi_ieee80211_tx_status_ext()
5976 info->status.rates[2].idx, info->status.rates[2].count, in linuxkpi_ieee80211_tx_status_ext()
5977 info->status.rates[2].flags, in linuxkpi_ieee80211_tx_status_ext()
5978 info->status.rates[3].idx, info->status.rates[3].count, in linuxkpi_ieee80211_tx_status_ext()
5979 info->status.rates[3].flags, in linuxkpi_ieee80211_tx_status_ext()
5980 info->status.ack_signal, info->status.ampdu_ack_len, in linuxkpi_ieee80211_tx_status_ext()
5981 info->status.ampdu_len, info->status.antenna, in linuxkpi_ieee80211_tx_status_ext()
5982 info->status.tx_time, info->status.flags, in linuxkpi_ieee80211_tx_status_ext()
5983 info->status.status_driver_data[0], in linuxkpi_ieee80211_tx_status_ext()
5984 info->status.status_driver_data[1]); in linuxkpi_ieee80211_tx_status_ext()
5987 if (txstat->free_list) { in linuxkpi_ieee80211_tx_status_ext()
5988 _lkpi_ieee80211_free_txskb(hw, skb, status); in linuxkpi_ieee80211_tx_status_ext()
5989 list_add_tail(&skb->list, txstat->free_list); in linuxkpi_ieee80211_tx_status_ext()
5991 linuxkpi_ieee80211_free_txskb(hw, skb, status); in linuxkpi_ieee80211_tx_status_ext()
5996 linuxkpi_ieee80211_tx_status(struct ieee80211_hw *hw, struct sk_buff *skb) in linuxkpi_ieee80211_tx_status() argument
6005 ieee80211_tx_status_ext(hw, &status); in linuxkpi_ieee80211_tx_status()
6027 ni = m->m_pkthdr.PH_loc.ptr; in lkpi_ieee80211_free_skb_mbuf()
6028 m->m_pkthdr.PH_loc.ptr = NULL; in lkpi_ieee80211_free_skb_mbuf()
6035 linuxkpi_ieee80211_queue_delayed_work(struct ieee80211_hw *hw, in linuxkpi_ieee80211_queue_delayed_work() argument
6040 /* Need to make sure hw is in a stable (non-suspended) state. */ in linuxkpi_ieee80211_queue_delayed_work()
6043 lhw = HW_TO_LHW(hw); in linuxkpi_ieee80211_queue_delayed_work()
6044 queue_delayed_work(lhw->workq, w, delay); in linuxkpi_ieee80211_queue_delayed_work()
6048 linuxkpi_ieee80211_queue_work(struct ieee80211_hw *hw, in linuxkpi_ieee80211_queue_work() argument
6053 /* Need to make sure hw is in a stable (non-suspended) state. */ in linuxkpi_ieee80211_queue_work()
6056 lhw = HW_TO_LHW(hw); in linuxkpi_ieee80211_queue_work()
6057 queue_work(lhw->workq, w); in linuxkpi_ieee80211_queue_work()
6061 linuxkpi_ieee80211_probereq_get(struct ieee80211_hw *hw, uint8_t *addr, in linuxkpi_ieee80211_probereq_get() argument
6072 skb = dev_alloc_skb(hw->extra_tx_headroom + len + tailroom); in linuxkpi_ieee80211_probereq_get()
6076 skb_reserve(skb, hw->extra_tx_headroom); in linuxkpi_ieee80211_probereq_get()
6079 wh->i_fc[0] = IEEE80211_FC0_VERSION_0; in linuxkpi_ieee80211_probereq_get()
6080 wh->i_fc[0] |= IEEE80211_FC0_SUBTYPE_PROBE_REQ | IEEE80211_FC0_TYPE_MGT; in linuxkpi_ieee80211_probereq_get()
6081 IEEE80211_ADDR_COPY(wh->i_addr1, ieee80211broadcastaddr); in linuxkpi_ieee80211_probereq_get()
6082 IEEE80211_ADDR_COPY(wh->i_addr2, addr); in linuxkpi_ieee80211_probereq_get()
6083 IEEE80211_ADDR_COPY(wh->i_addr3, ieee80211broadcastaddr); in linuxkpi_ieee80211_probereq_get()
6095 linuxkpi_ieee80211_pspoll_get(struct ieee80211_hw *hw, in linuxkpi_ieee80211_pspoll_get() argument
6104 skb = dev_alloc_skb(hw->extra_tx_headroom + sizeof(*psp)); in linuxkpi_ieee80211_pspoll_get()
6108 skb_reserve(skb, hw->extra_tx_headroom); in linuxkpi_ieee80211_pspoll_get()
6114 psp->i_fc[0] = IEEE80211_FC0_VERSION_0; in linuxkpi_ieee80211_pspoll_get()
6115 psp->i_fc[0] |= IEEE80211_FC0_SUBTYPE_PS_POLL | IEEE80211_FC0_TYPE_CTL; in linuxkpi_ieee80211_pspoll_get()
6116 v = htole16(vif->cfg.aid | 1<<15 | 1<<16); in linuxkpi_ieee80211_pspoll_get()
6117 memcpy(&psp->i_aid, &v, sizeof(v)); in linuxkpi_ieee80211_pspoll_get()
6118 IEEE80211_ADDR_COPY(psp->i_bssid, vap->iv_bss->ni_macaddr); in linuxkpi_ieee80211_pspoll_get()
6119 IEEE80211_ADDR_COPY(psp->i_ta, vif->addr); in linuxkpi_ieee80211_pspoll_get()
6125 linuxkpi_ieee80211_nullfunc_get(struct ieee80211_hw *hw, in linuxkpi_ieee80211_nullfunc_get() argument
6135 skb = dev_alloc_skb(hw->extra_tx_headroom + sizeof(*nullf)); in linuxkpi_ieee80211_nullfunc_get()
6139 skb_reserve(skb, hw->extra_tx_headroom); in linuxkpi_ieee80211_nullfunc_get()
6145 nullf->i_fc[0] = IEEE80211_FC0_VERSION_0; in linuxkpi_ieee80211_nullfunc_get()
6146 nullf->i_fc[0] |= IEEE80211_FC0_SUBTYPE_NODATA | IEEE80211_FC0_TYPE_DATA; in linuxkpi_ieee80211_nullfunc_get()
6147 nullf->i_fc[1] = IEEE80211_FC1_DIR_TODS; in linuxkpi_ieee80211_nullfunc_get()
6149 IEEE80211_ADDR_COPY(nullf->i_addr1, vap->iv_bss->ni_bssid); in linuxkpi_ieee80211_nullfunc_get()
6150 IEEE80211_ADDR_COPY(nullf->i_addr2, vif->addr); in linuxkpi_ieee80211_nullfunc_get()
6151 IEEE80211_ADDR_COPY(nullf->i_addr3, vap->iv_bss->ni_macaddr); in linuxkpi_ieee80211_nullfunc_get()
6162 return (&lvif->wdev); in linuxkpi_ieee80211_vif_to_wdev()
6184 ic_printf(vap->iv_ic, "%s: vif %p vap %p state %s\n", __func__, in linuxkpi_ieee80211_connection_loss()
6185 vif, vap, ieee80211_state_name[vap->iv_state]); in linuxkpi_ieee80211_connection_loss()
6198 ic_printf(vap->iv_ic, "%s: vif %p vap %p state %s\n", __func__, in linuxkpi_ieee80211_beacon_loss()
6199 vif, vap, ieee80211_state_name[vap->iv_state]); in linuxkpi_ieee80211_beacon_loss()
6200 ieee80211_beacon_miss(vap->iv_ic); in linuxkpi_ieee80211_beacon_loss()
6203 /* -------------------------------------------------------------------------- */
6206 linuxkpi_ieee80211_stop_queue(struct ieee80211_hw *hw, int qnum) in linuxkpi_ieee80211_stop_queue() argument
6213 KASSERT(qnum < hw->queues, ("%s: qnum %d >= hw->queues %d, hw %p\n", in linuxkpi_ieee80211_stop_queue()
6214 __func__, qnum, hw->queues, hw)); in linuxkpi_ieee80211_stop_queue()
6216 lhw = wiphy_priv(hw->wiphy); in linuxkpi_ieee80211_stop_queue()
6219 if (hw->queues >= IEEE80211_NUM_ACS) in linuxkpi_ieee80211_stop_queue()
6225 TAILQ_FOREACH(lvif, &lhw->lvif_head, lvif_entry) { in linuxkpi_ieee80211_stop_queue()
6230 if (qnum == vif->hw_queue[ac]) { in linuxkpi_ieee80211_stop_queue()
6236 if (lvif->hw_queue_stopped[ac] && in linuxkpi_ieee80211_stop_queue()
6238 ic_printf(lhw->ic, "%s:%d: lhw %p hw %p " in linuxkpi_ieee80211_stop_queue()
6241 lhw, hw, lvif, vif, ac, qnum); in linuxkpi_ieee80211_stop_queue()
6243 lvif->hw_queue_stopped[ac] = true; in linuxkpi_ieee80211_stop_queue()
6251 linuxkpi_ieee80211_stop_queues(struct ieee80211_hw *hw) in linuxkpi_ieee80211_stop_queues() argument
6256 for (i = 0; i < hw->queues; i++) in linuxkpi_ieee80211_stop_queues()
6257 linuxkpi_ieee80211_stop_queue(hw, i); in linuxkpi_ieee80211_stop_queues()
6262 lkpi_ieee80211_wake_queues(struct ieee80211_hw *hw, int hwq) in lkpi_ieee80211_wake_queues() argument
6270 if (hw->queues >= IEEE80211_NUM_ACS) in lkpi_ieee80211_wake_queues()
6275 lhw = wiphy_priv(hw->wiphy); in lkpi_ieee80211_wake_queues()
6279 TAILQ_FOREACH(lvif, &lhw->lvif_head, lvif_entry) { in lkpi_ieee80211_wake_queues()
6285 if (hwq == vif->hw_queue[ac]) { in lkpi_ieee80211_wake_queues()
6287 /* XXX-BZ what about software scan? */ in lkpi_ieee80211_wake_queues()
6294 if (!lvif->hw_queue_stopped[ac] && in lkpi_ieee80211_wake_queues()
6296 ic_printf(lhw->ic, "%s:%d: lhw %p hw %p " in lkpi_ieee80211_wake_queues()
6299 lhw, hw, lvif, vif, ac); in lkpi_ieee80211_wake_queues()
6301 lvif->hw_queue_stopped[ac] = false; in lkpi_ieee80211_wake_queues()
6304 TAILQ_FOREACH(lsta, &lvif->lsta_head, lsta_entry) { in lkpi_ieee80211_wake_queues()
6308 for (tid = 0; tid < nitems(sta->txq); tid++) { in lkpi_ieee80211_wake_queues()
6311 if (sta->txq[tid] == NULL) in lkpi_ieee80211_wake_queues()
6314 if (sta->txq[tid]->ac != ac) in lkpi_ieee80211_wake_queues()
6317 ltxq = TXQ_TO_LTXQ(sta->txq[tid]); in lkpi_ieee80211_wake_queues()
6318 if (!ltxq->stopped) in lkpi_ieee80211_wake_queues()
6321 ltxq->stopped = false; in lkpi_ieee80211_wake_queues()
6323 /* XXX-BZ see when this explodes with all the locking. taskq? */ in lkpi_ieee80211_wake_queues()
6324 lkpi_80211_mo_wake_tx_queue(hw, sta->txq[tid]); in lkpi_ieee80211_wake_queues()
6335 linuxkpi_ieee80211_wake_queues(struct ieee80211_hw *hw) in linuxkpi_ieee80211_wake_queues() argument
6340 for (i = 0; i < hw->queues; i++) in linuxkpi_ieee80211_wake_queues()
6341 lkpi_ieee80211_wake_queues(hw, i); in linuxkpi_ieee80211_wake_queues()
6345 linuxkpi_ieee80211_wake_queue(struct ieee80211_hw *hw, int qnum) in linuxkpi_ieee80211_wake_queue() argument
6348 KASSERT(qnum < hw->queues, ("%s: qnum %d >= hw->queues %d, hw %p\n", in linuxkpi_ieee80211_wake_queue()
6349 __func__, qnum, hw->queues, hw)); in linuxkpi_ieee80211_wake_queue()
6351 lkpi_ieee80211_wake_queues(hw, qnum); in linuxkpi_ieee80211_wake_queue()
6356 linuxkpi_ieee80211_txq_schedule_start(struct ieee80211_hw *hw, uint8_t ac) in linuxkpi_ieee80211_txq_schedule_start() argument
6360 lhw = HW_TO_LHW(hw); in linuxkpi_ieee80211_txq_schedule_start()
6364 if (++lhw->txq_generation[ac] == 0) in linuxkpi_ieee80211_txq_schedule_start()
6365 lhw->txq_generation[ac]++; in linuxkpi_ieee80211_txq_schedule_start()
6369 linuxkpi_ieee80211_next_txq(struct ieee80211_hw *hw, uint8_t ac) in linuxkpi_ieee80211_next_txq() argument
6375 lhw = HW_TO_LHW(hw); in linuxkpi_ieee80211_next_txq()
6381 if (lhw->txq_generation[ac] == 0) in linuxkpi_ieee80211_next_txq()
6384 ltxq = TAILQ_FIRST(&lhw->scheduled_txqs[ac]); in linuxkpi_ieee80211_next_txq()
6387 if (ltxq->txq_generation == lhw->txq_generation[ac]) in linuxkpi_ieee80211_next_txq()
6390 ltxq->txq_generation = lhw->txq_generation[ac]; in linuxkpi_ieee80211_next_txq()
6391 TAILQ_REMOVE(&lhw->scheduled_txqs[ac], ltxq, txq_entry); in linuxkpi_ieee80211_next_txq()
6392 txq = &ltxq->txq; in linuxkpi_ieee80211_next_txq()
6399 void linuxkpi_ieee80211_schedule_txq(struct ieee80211_hw *hw, in linuxkpi_ieee80211_schedule_txq() argument
6412 ltxq_empty = skb_queue_empty(&ltxq->skbq); in linuxkpi_ieee80211_schedule_txq()
6418 * Make sure we do not double-schedule. We do this by checking tqe_prev, in linuxkpi_ieee80211_schedule_txq()
6422 if (ltxq->txq_entry.tqe_prev != NULL) in linuxkpi_ieee80211_schedule_txq()
6425 lhw = HW_TO_LHW(hw); in linuxkpi_ieee80211_schedule_txq()
6426 TAILQ_INSERT_TAIL(&lhw->scheduled_txqs[txq->ac], ltxq, txq_entry); in linuxkpi_ieee80211_schedule_txq()
6432 linuxkpi_ieee80211_handle_wake_tx_queue(struct ieee80211_hw *hw, in linuxkpi_ieee80211_handle_wake_tx_queue() argument
6440 lhw = HW_TO_LHW(hw); in linuxkpi_ieee80211_handle_wake_tx_queue()
6443 ieee80211_txq_schedule_start(hw, txq->ac); in linuxkpi_ieee80211_handle_wake_tx_queue()
6445 ntxq = ieee80211_next_txq(hw, txq->ac); in linuxkpi_ieee80211_handle_wake_tx_queue()
6450 control.sta = ntxq->sta; in linuxkpi_ieee80211_handle_wake_tx_queue()
6452 skb = linuxkpi_ieee80211_tx_dequeue(hw, ntxq); in linuxkpi_ieee80211_handle_wake_tx_queue()
6455 lkpi_80211_mo_tx(hw, &control, skb); in linuxkpi_ieee80211_handle_wake_tx_queue()
6458 ieee80211_return_txq(hw, ntxq, false); in linuxkpi_ieee80211_handle_wake_tx_queue()
6460 ieee80211_txq_schedule_end(hw, txq->ac); in linuxkpi_ieee80211_handle_wake_tx_queue()
6464 /* -------------------------------------------------------------------------- */
6497 if (lookup->match) in lkpi_cfg80211_get_bss_iterf()
6501 if (lookup->bss == NULL) in lkpi_cfg80211_get_bss_iterf()
6504 if (lookup->privacy != IEEE80211_PRIVACY_ANY) { in lkpi_cfg80211_get_bss_iterf()
6505 /* if (se->se_capinfo & IEEE80211_CAPINFO_PRIVACY) */ in lkpi_cfg80211_get_bss_iterf()
6510 if (lookup->bss_type != IEEE80211_BSS_TYPE_ANY) { in lkpi_cfg80211_get_bss_iterf()
6511 /* if (se->se_capinfo & (IEEE80211_CAPINFO_IBSS|IEEE80211_CAPINFO_ESS)) */ in lkpi_cfg80211_get_bss_iterf()
6516 if (lookup->chan != NULL) { in lkpi_cfg80211_get_bss_iterf()
6519 chan = linuxkpi_ieee80211_get_channel(lookup->wiphy, in lkpi_cfg80211_get_bss_iterf()
6520 se->se_chan->ic_freq); in lkpi_cfg80211_get_bss_iterf()
6521 if (chan == NULL || chan != lookup->chan) in lkpi_cfg80211_get_bss_iterf()
6525 if (lookup->bssid && !IEEE80211_ADDR_EQ(lookup->bssid, se->se_bssid)) in lkpi_cfg80211_get_bss_iterf()
6528 if (lookup->ssid) { in lkpi_cfg80211_get_bss_iterf()
6529 if (lookup->ssid_len != se->se_ssid[1] || in lkpi_cfg80211_get_bss_iterf()
6530 se->se_ssid[1] == 0) in lkpi_cfg80211_get_bss_iterf()
6532 if (memcmp(lookup->ssid, se->se_ssid+2, lookup->ssid_len) != 0) in lkpi_cfg80211_get_bss_iterf()
6536 ielen = se->se_ies.len; in lkpi_cfg80211_get_bss_iterf()
6538 lookup->bss->ies = malloc(sizeof(*lookup->bss->ies) + ielen, in lkpi_cfg80211_get_bss_iterf()
6540 if (lookup->bss->ies == NULL) in lkpi_cfg80211_get_bss_iterf()
6543 lookup->bss->ies->data = (uint8_t *)lookup->bss->ies + sizeof(*lookup->bss->ies); in lkpi_cfg80211_get_bss_iterf()
6544 lookup->bss->ies->len = ielen; in lkpi_cfg80211_get_bss_iterf()
6546 memcpy(lookup->bss->ies->data, se->se_ies.data, ielen); in lkpi_cfg80211_get_bss_iterf()
6548 lookup->match = true; in lkpi_cfg80211_get_bss_iterf()
6566 ic_printf(lhw->ic, "%s: alloc failed.\n", __func__); in linuxkpi_cfg80211_get_bss()
6578 lookup.bss = &lbss->bss; in linuxkpi_cfg80211_get_bss()
6581 vap = TAILQ_FIRST(&lhw->ic->ic_vaps); in linuxkpi_cfg80211_get_bss()
6588 refcount_init(&lbss->refcnt, 1); in linuxkpi_cfg80211_get_bss()
6589 return (&lbss->bss); in linuxkpi_cfg80211_get_bss()
6600 if (refcount_release(&lbss->refcnt)) { in linuxkpi_cfg80211_put_bss()
6601 free(lbss->bss.ies, M_LKPI80211); in linuxkpi_cfg80211_put_bss()
6614 ic = lhw->ic; in linuxkpi_cfg80211_bss_flush()
6621 (lhw->sc_flags & LKPI_MAC80211_DRV_STARTED) == 0) in linuxkpi_cfg80211_bss_flush()
6626 TAILQ_FOREACH(vap, &ic->ic_vaps, iv_next) in linuxkpi_cfg80211_bss_flush()
6631 /* -------------------------------------------------------------------------- */
6634 * hw->conf get initialized/set in various places for us:
6635 * - linuxkpi_ieee80211_alloc_hw(): flags
6636 * - linuxkpi_ieee80211_ifattach(): chandef
6637 * - lkpi_ic_vap_create(): listen_interval
6638 * - lkpi_ic_set_channel(): chandef, flags
6641 int lkpi_80211_update_chandef(struct ieee80211_hw *hw, in lkpi_80211_update_chandef() argument
6649 if (new == NULL || new->def.chan == NULL) in lkpi_80211_update_chandef()
6652 cd = &new->def; in lkpi_80211_update_chandef()
6654 if (cd && cd->chan != hw->conf.chandef.chan) { in lkpi_80211_update_chandef()
6656 hw->conf.chandef = *cd; in lkpi_80211_update_chandef()
6664 error = lkpi_80211_mo_config(hw, changed); in lkpi_80211_update_chandef()
6668 /* -------------------------------------------------------------------------- */