Lines Matching +full:hw +full:- +full:device +full:- +full:address

1 // SPDX-License-Identifier: GPL-2.0-or-later
3 Copyright (C) 2004 - 2009 Ivo van Doorn <IvDoorn@gmail.com>
29 if (tx_info->control.rates[0].flags & IEEE80211_TX_RC_USE_CTS_PROTECT) in rt2x00mac_tx_rts_cts()
34 skb = dev_alloc_skb(data_length + rt2x00dev->hw->extra_tx_headroom); in rt2x00mac_tx_rts_cts()
37 return -ENOMEM; in rt2x00mac_tx_rts_cts()
40 skb_reserve(skb, rt2x00dev->hw->extra_tx_headroom); in rt2x00mac_tx_rts_cts()
47 * RTS frames should be acked, while CTS-to-self frames in rt2x00mac_tx_rts_cts()
52 memcpy(skb->cb, frag_skb->cb, sizeof(skb->cb)); in rt2x00mac_tx_rts_cts()
54 rts_info->control.rates[0].flags &= ~IEEE80211_TX_RC_USE_RTS_CTS; in rt2x00mac_tx_rts_cts()
55 rts_info->control.rates[0].flags &= ~IEEE80211_TX_RC_USE_CTS_PROTECT; in rt2x00mac_tx_rts_cts()
57 if (tx_info->control.rates[0].flags & IEEE80211_TX_RC_USE_CTS_PROTECT) in rt2x00mac_tx_rts_cts()
58 rts_info->flags |= IEEE80211_TX_CTL_NO_ACK; in rt2x00mac_tx_rts_cts()
60 rts_info->flags &= ~IEEE80211_TX_CTL_NO_ACK; in rt2x00mac_tx_rts_cts()
63 rts_info->control.hw_key = NULL; in rt2x00mac_tx_rts_cts()
71 if (tx_info->control.rates[0].flags & IEEE80211_TX_RC_USE_CTS_PROTECT) in rt2x00mac_tx_rts_cts()
72 ieee80211_ctstoself_get(rt2x00dev->hw, tx_info->control.vif, in rt2x00mac_tx_rts_cts()
73 frag_skb->data, data_length, tx_info, in rt2x00mac_tx_rts_cts()
74 (struct ieee80211_cts *)(skb->data)); in rt2x00mac_tx_rts_cts()
76 ieee80211_rts_get(rt2x00dev->hw, tx_info->control.vif, in rt2x00mac_tx_rts_cts()
77 frag_skb->data, data_length, tx_info, in rt2x00mac_tx_rts_cts()
78 (struct ieee80211_rts *)(skb->data)); in rt2x00mac_tx_rts_cts()
89 void rt2x00mac_tx(struct ieee80211_hw *hw, in rt2x00mac_tx() argument
93 struct rt2x00_dev *rt2x00dev = hw->priv; in rt2x00mac_tx()
100 * to remove the device or perhaps suspending it. in rt2x00mac_tx()
104 if (!test_bit(DEVICE_STATE_PRESENT, &rt2x00dev->flags)) in rt2x00mac_tx()
110 if (tx_info->flags & IEEE80211_TX_CTL_SEND_AFTER_DTIM && in rt2x00mac_tx()
128 * either RTS or CTS-to-self frame and handles everything in rt2x00mac_tx()
131 if (!rt2x00dev->ops->hw->set_rts_threshold && in rt2x00mac_tx()
132 (tx_info->control.rates[0].flags & (IEEE80211_TX_RC_USE_RTS_CTS | in rt2x00mac_tx()
139 spin_lock(&queue->tx_lock); in rt2x00mac_tx()
142 spin_unlock(&queue->tx_lock); in rt2x00mac_tx()
151 if (unlikely(rt2x00queue_write_tx_frame(queue, skb, control->sta, false))) in rt2x00mac_tx()
157 ieee80211_free_txskb(hw, skb); in rt2x00mac_tx()
161 int rt2x00mac_start(struct ieee80211_hw *hw) in rt2x00mac_start() argument
163 struct rt2x00_dev *rt2x00dev = hw->priv; in rt2x00mac_start()
165 if (!test_bit(DEVICE_STATE_PRESENT, &rt2x00dev->flags)) in rt2x00mac_start()
168 if (test_bit(DEVICE_STATE_STARTED, &rt2x00dev->flags)) { in rt2x00mac_start()
173 set_bit(DEVICE_STATE_RESET, &rt2x00dev->flags); in rt2x00mac_start()
174 rt2x00dev->ops->lib->pre_reset_hw(rt2x00dev); in rt2x00mac_start()
181 void rt2x00mac_stop(struct ieee80211_hw *hw, bool suspend) in rt2x00mac_stop() argument
183 struct rt2x00_dev *rt2x00dev = hw->priv; in rt2x00mac_stop()
185 if (!test_bit(DEVICE_STATE_PRESENT, &rt2x00dev->flags)) in rt2x00mac_stop()
193 rt2x00mac_reconfig_complete(struct ieee80211_hw *hw, in rt2x00mac_reconfig_complete() argument
196 struct rt2x00_dev *rt2x00dev = hw->priv; in rt2x00mac_reconfig_complete()
199 clear_bit(DEVICE_STATE_RESET, &rt2x00dev->flags); in rt2x00mac_reconfig_complete()
203 int rt2x00mac_add_interface(struct ieee80211_hw *hw, in rt2x00mac_add_interface() argument
206 struct rt2x00_dev *rt2x00dev = hw->priv; in rt2x00mac_add_interface()
208 struct data_queue *queue = rt2x00dev->bcn; in rt2x00mac_add_interface()
214 * the device has disappeared. in rt2x00mac_add_interface()
216 if (!test_bit(DEVICE_STATE_PRESENT, &rt2x00dev->flags) || in rt2x00mac_add_interface()
217 !test_bit(DEVICE_STATE_STARTED, &rt2x00dev->flags)) in rt2x00mac_add_interface()
218 return -ENODEV; in rt2x00mac_add_interface()
226 for (i = 0; i < queue->limit; i++) { in rt2x00mac_add_interface()
227 entry = &queue->entries[i]; in rt2x00mac_add_interface()
228 if (!test_and_set_bit(ENTRY_BCN_ASSIGNED, &entry->flags)) in rt2x00mac_add_interface()
232 if (unlikely(i == queue->limit)) in rt2x00mac_add_interface()
233 return -ENOBUFS; in rt2x00mac_add_interface()
240 if (vif->type == NL80211_IFTYPE_AP) in rt2x00mac_add_interface()
241 rt2x00dev->intf_ap_count++; in rt2x00mac_add_interface()
243 rt2x00dev->intf_sta_count++; in rt2x00mac_add_interface()
245 mutex_init(&intf->beacon_skb_mutex); in rt2x00mac_add_interface()
246 intf->beacon = entry; in rt2x00mac_add_interface()
249 * The MAC address must be configured after the device in rt2x00mac_add_interface()
250 * has been initialized. Otherwise the device can reset in rt2x00mac_add_interface()
252 * The BSSID address must only be configured in AP mode, in rt2x00mac_add_interface()
253 * however we should not send an empty BSSID address for in rt2x00mac_add_interface()
255 * invalid behavior in the device. in rt2x00mac_add_interface()
257 rt2x00lib_config_intf(rt2x00dev, intf, vif->type, in rt2x00mac_add_interface()
258 vif->addr, NULL); in rt2x00mac_add_interface()
265 rt2x00dev->packet_filter = 0; in rt2x00mac_add_interface()
271 void rt2x00mac_remove_interface(struct ieee80211_hw *hw, in rt2x00mac_remove_interface() argument
274 struct rt2x00_dev *rt2x00dev = hw->priv; in rt2x00mac_remove_interface()
279 * either the device has disappeared or when in rt2x00mac_remove_interface()
282 if (!test_bit(DEVICE_STATE_PRESENT, &rt2x00dev->flags) || in rt2x00mac_remove_interface()
283 (vif->type == NL80211_IFTYPE_AP && !rt2x00dev->intf_ap_count) || in rt2x00mac_remove_interface()
284 (vif->type != NL80211_IFTYPE_AP && !rt2x00dev->intf_sta_count)) in rt2x00mac_remove_interface()
287 if (vif->type == NL80211_IFTYPE_AP) in rt2x00mac_remove_interface()
288 rt2x00dev->intf_ap_count--; in rt2x00mac_remove_interface()
290 rt2x00dev->intf_sta_count--; in rt2x00mac_remove_interface()
296 clear_bit(ENTRY_BCN_ASSIGNED, &intf->beacon->flags); in rt2x00mac_remove_interface()
299 * Make sure the bssid and mac address registers in rt2x00mac_remove_interface()
307 int rt2x00mac_config(struct ieee80211_hw *hw, int radio_idx, u32 changed) in rt2x00mac_config() argument
309 struct rt2x00_dev *rt2x00dev = hw->priv; in rt2x00mac_config()
310 struct ieee80211_conf *conf = &hw->conf; in rt2x00mac_config()
314 * to remove the device or perhaps suspending it. in rt2x00mac_config()
316 if (!test_bit(DEVICE_STATE_PRESENT, &rt2x00dev->flags)) in rt2x00mac_config()
326 rt2x00queue_stop_queue(rt2x00dev->rx); in rt2x00mac_config()
329 mutex_lock(&rt2x00dev->conf_mutex); in rt2x00mac_config()
344 rt2x00lib_config_antenna(rt2x00dev, rt2x00dev->default_ant); in rt2x00mac_config()
346 mutex_unlock(&rt2x00dev->conf_mutex); in rt2x00mac_config()
349 rt2x00queue_start_queue(rt2x00dev->rx); in rt2x00mac_config()
355 void rt2x00mac_configure_filter(struct ieee80211_hw *hw, in rt2x00mac_configure_filter() argument
360 struct rt2x00_dev *rt2x00dev = hw->priv; in rt2x00mac_configure_filter()
376 * - Some filters imply different filters to be set. in rt2x00mac_configure_filter()
377 * - Some things we can't filter out at all. in rt2x00mac_configure_filter()
378 * - Multicast filter seems to kill broadcast traffic so never use it. in rt2x00mac_configure_filter()
383 * If the device has a single filter for all control frames, in rt2x00mac_configure_filter()
385 * And if the device has more than one filter for control frames in rt2x00mac_configure_filter()
398 rt2x00dev->packet_filter = *total_flags; in rt2x00mac_configure_filter()
400 rt2x00dev->ops->lib->config_filter(rt2x00dev, *total_flags); in rt2x00mac_configure_filter()
409 if (vif->type != NL80211_IFTYPE_AP && in rt2x00mac_set_tim_iter()
410 vif->type != NL80211_IFTYPE_ADHOC && in rt2x00mac_set_tim_iter()
411 vif->type != NL80211_IFTYPE_MESH_POINT) in rt2x00mac_set_tim_iter()
414 set_bit(DELAYED_UPDATE_BEACON, &intf->delayed_flags); in rt2x00mac_set_tim_iter()
417 int rt2x00mac_set_tim(struct ieee80211_hw *hw, struct ieee80211_sta *sta, in rt2x00mac_set_tim() argument
420 struct rt2x00_dev *rt2x00dev = hw->priv; in rt2x00mac_set_tim()
422 if (!test_bit(DEVICE_STATE_ENABLED_RADIO, &rt2x00dev->flags)) in rt2x00mac_set_tim()
426 rt2x00dev->hw, IEEE80211_IFACE_ITER_RESUME_ALL, in rt2x00mac_set_tim()
430 ieee80211_queue_work(rt2x00dev->hw, &rt2x00dev->intf_work); in rt2x00mac_set_tim()
439 memcpy(crypto->key, in memcpy_tkip()
441 sizeof(crypto->key)); in memcpy_tkip()
444 memcpy(crypto->tx_mic, in memcpy_tkip()
446 sizeof(crypto->tx_mic)); in memcpy_tkip()
449 memcpy(crypto->rx_mic, in memcpy_tkip()
451 sizeof(crypto->rx_mic)); in memcpy_tkip()
454 int rt2x00mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, in rt2x00mac_set_key() argument
458 struct rt2x00_dev *rt2x00dev = hw->priv; in rt2x00mac_set_key()
467 if (!test_bit(DEVICE_STATE_PRESENT, &rt2x00dev->flags)) in rt2x00mac_set_key()
471 if (!rt2x00_has_cap_hw_crypto(rt2x00dev) || (sta && sta->mfp)) in rt2x00mac_set_key()
472 return -EOPNOTSUPP; in rt2x00mac_set_key()
478 if (vif->type == NL80211_IFTYPE_ADHOC && in rt2x00mac_set_key()
479 !(key->flags & IEEE80211_KEY_FLAG_PAIRWISE)) in rt2x00mac_set_key()
480 return -EOPNOTSUPP; in rt2x00mac_set_key()
482 if (key->keylen > 32) in rt2x00mac_set_key()
483 return -ENOSPC; in rt2x00mac_set_key()
490 return -EOPNOTSUPP; in rt2x00mac_set_key()
492 return -EOPNOTSUPP; in rt2x00mac_set_key()
497 crypto.address = sta->addr; in rt2x00mac_set_key()
499 crypto.wcid = sta_priv->wcid; in rt2x00mac_set_key()
501 crypto.address = bcast_addr; in rt2x00mac_set_key()
504 memcpy_tkip(&crypto, &key->key[0], key->keylen); in rt2x00mac_set_key()
506 memcpy(crypto.key, &key->key[0], key->keylen); in rt2x00mac_set_key()
524 key->hw_key_idx = 0; in rt2x00mac_set_key()
526 if (key->flags & IEEE80211_KEY_FLAG_PAIRWISE) in rt2x00mac_set_key()
527 set_key = rt2x00dev->ops->lib->config_pairwise_key; in rt2x00mac_set_key()
529 set_key = rt2x00dev->ops->lib->config_shared_key; in rt2x00mac_set_key()
532 return -EOPNOTSUPP; in rt2x00mac_set_key()
539 void rt2x00mac_sw_scan_start(struct ieee80211_hw *hw, in rt2x00mac_sw_scan_start() argument
543 struct rt2x00_dev *rt2x00dev = hw->priv; in rt2x00mac_sw_scan_start()
544 set_bit(DEVICE_STATE_SCANNING, &rt2x00dev->flags); in rt2x00mac_sw_scan_start()
549 void rt2x00mac_sw_scan_complete(struct ieee80211_hw *hw, in rt2x00mac_sw_scan_complete() argument
552 struct rt2x00_dev *rt2x00dev = hw->priv; in rt2x00mac_sw_scan_complete()
553 clear_bit(DEVICE_STATE_SCANNING, &rt2x00dev->flags); in rt2x00mac_sw_scan_complete()
558 int rt2x00mac_get_stats(struct ieee80211_hw *hw, in rt2x00mac_get_stats() argument
561 struct rt2x00_dev *rt2x00dev = hw->priv; in rt2x00mac_get_stats()
568 memcpy(stats, &rt2x00dev->low_level_stats, sizeof(*stats)); in rt2x00mac_get_stats()
574 void rt2x00mac_bss_info_changed(struct ieee80211_hw *hw, in rt2x00mac_bss_info_changed() argument
579 struct rt2x00_dev *rt2x00dev = hw->priv; in rt2x00mac_bss_info_changed()
584 * to remove the device or perhaps suspending it. in rt2x00mac_bss_info_changed()
586 if (!test_bit(DEVICE_STATE_PRESENT, &rt2x00dev->flags)) in rt2x00mac_bss_info_changed()
593 rt2x00lib_config_intf(rt2x00dev, intf, vif->type, NULL, in rt2x00mac_bss_info_changed()
594 bss_conf->bssid); in rt2x00mac_bss_info_changed()
600 mutex_lock(&intf->beacon_skb_mutex); in rt2x00mac_bss_info_changed()
606 if (test_bit(DEVICE_STATE_RESET, &rt2x00dev->flags) && in rt2x00mac_bss_info_changed()
607 intf->enable_beacon) { in rt2x00mac_bss_info_changed()
608 intf->enable_beacon = false; in rt2x00mac_bss_info_changed()
612 if (!bss_conf->enable_beacon && intf->enable_beacon) { in rt2x00mac_bss_info_changed()
613 rt2x00dev->intf_beaconing--; in rt2x00mac_bss_info_changed()
614 intf->enable_beacon = false; in rt2x00mac_bss_info_changed()
616 if (rt2x00dev->intf_beaconing == 0) { in rt2x00mac_bss_info_changed()
619 * -> stop beacon queue. in rt2x00mac_bss_info_changed()
621 rt2x00queue_stop_queue(rt2x00dev->bcn); in rt2x00mac_bss_info_changed()
629 } else if (bss_conf->enable_beacon && !intf->enable_beacon) { in rt2x00mac_bss_info_changed()
630 rt2x00dev->intf_beaconing++; in rt2x00mac_bss_info_changed()
631 intf->enable_beacon = true; in rt2x00mac_bss_info_changed()
639 if (rt2x00dev->intf_beaconing == 1) { in rt2x00mac_bss_info_changed()
642 * -> start beacon queue. in rt2x00mac_bss_info_changed()
644 rt2x00queue_start_queue(rt2x00dev->bcn); in rt2x00mac_bss_info_changed()
647 mutex_unlock(&intf->beacon_skb_mutex); in rt2x00mac_bss_info_changed()
657 rt2x00dev->link.count = 0; in rt2x00mac_bss_info_changed()
659 if (vif->cfg.assoc) in rt2x00mac_bss_info_changed()
660 rt2x00dev->intf_associated++; in rt2x00mac_bss_info_changed()
662 rt2x00dev->intf_associated--; in rt2x00mac_bss_info_changed()
664 rt2x00leds_led_assoc(rt2x00dev, !!rt2x00dev->intf_associated); in rt2x00mac_bss_info_changed()
678 int rt2x00mac_conf_tx(struct ieee80211_hw *hw, in rt2x00mac_conf_tx() argument
683 struct rt2x00_dev *rt2x00dev = hw->priv; in rt2x00mac_conf_tx()
688 return -EINVAL; in rt2x00mac_conf_tx()
691 * The passed variables are stored as real value ((2^n)-1). in rt2x00mac_conf_tx()
694 if (params->cw_min > 0) in rt2x00mac_conf_tx()
695 queue->cw_min = fls(params->cw_min); in rt2x00mac_conf_tx()
697 queue->cw_min = 5; /* cw_min: 2^5 = 32. */ in rt2x00mac_conf_tx()
699 if (params->cw_max > 0) in rt2x00mac_conf_tx()
700 queue->cw_max = fls(params->cw_max); in rt2x00mac_conf_tx()
702 queue->cw_max = 10; /* cw_min: 2^10 = 1024. */ in rt2x00mac_conf_tx()
704 queue->aifs = params->aifs; in rt2x00mac_conf_tx()
705 queue->txop = params->txop; in rt2x00mac_conf_tx()
708 "Configured TX queue %d - CWmin: %d, CWmax: %d, Aifs: %d, TXop: %d\n", in rt2x00mac_conf_tx()
709 queue_idx, queue->cw_min, queue->cw_max, queue->aifs, in rt2x00mac_conf_tx()
710 queue->txop); in rt2x00mac_conf_tx()
716 void rt2x00mac_rfkill_poll(struct ieee80211_hw *hw) in rt2x00mac_rfkill_poll() argument
718 struct rt2x00_dev *rt2x00dev = hw->priv; in rt2x00mac_rfkill_poll()
719 bool active = !!rt2x00dev->ops->lib->rfkill_poll(rt2x00dev); in rt2x00mac_rfkill_poll()
721 wiphy_rfkill_set_hw_state(hw->wiphy, !active); in rt2x00mac_rfkill_poll()
725 void rt2x00mac_flush(struct ieee80211_hw *hw, struct ieee80211_vif *vif, in rt2x00mac_flush() argument
728 struct rt2x00_dev *rt2x00dev = hw->priv; in rt2x00mac_flush()
731 if (!test_bit(DEVICE_STATE_PRESENT, &rt2x00dev->flags)) in rt2x00mac_flush()
734 set_bit(DEVICE_STATE_FLUSHING, &rt2x00dev->flags); in rt2x00mac_flush()
739 clear_bit(DEVICE_STATE_FLUSHING, &rt2x00dev->flags); in rt2x00mac_flush()
743 int rt2x00mac_set_antenna(struct ieee80211_hw *hw, int radio_idx, in rt2x00mac_set_antenna() argument
746 struct rt2x00_dev *rt2x00dev = hw->priv; in rt2x00mac_set_antenna()
747 struct link_ant *ant = &rt2x00dev->link.ant; in rt2x00mac_set_antenna()
748 struct antenna_setup *def = &rt2x00dev->default_ant; in rt2x00mac_set_antenna()
754 return -EINVAL; in rt2x00mac_set_antenna()
759 if (ant->flags & ANTENNA_TX_DIVERSITY && tx_ant != 3) in rt2x00mac_set_antenna()
760 ant->flags &= ~ANTENNA_TX_DIVERSITY; in rt2x00mac_set_antenna()
761 if (ant->flags & ANTENNA_RX_DIVERSITY && rx_ant != 3) in rt2x00mac_set_antenna()
762 ant->flags &= ~ANTENNA_RX_DIVERSITY; in rt2x00mac_set_antenna()
768 if (tx_ant == 3 && def->tx == ANTENNA_SW_DIVERSITY) { in rt2x00mac_set_antenna()
770 ant->flags |= ANTENNA_TX_DIVERSITY; in rt2x00mac_set_antenna()
773 if (rx_ant == 3 && def->rx == ANTENNA_SW_DIVERSITY) { in rt2x00mac_set_antenna()
775 ant->flags |= ANTENNA_RX_DIVERSITY; in rt2x00mac_set_antenna()
789 int rt2x00mac_get_antenna(struct ieee80211_hw *hw, int radio_idx, in rt2x00mac_get_antenna() argument
792 struct rt2x00_dev *rt2x00dev = hw->priv; in rt2x00mac_get_antenna()
793 struct link_ant *ant = &rt2x00dev->link.ant; in rt2x00mac_get_antenna()
794 struct antenna_setup *active = &rt2x00dev->link.ant.active; in rt2x00mac_get_antenna()
798 if (ant->flags & ANTENNA_TX_DIVERSITY) in rt2x00mac_get_antenna()
801 *tx_ant = active->tx; in rt2x00mac_get_antenna()
803 if (ant->flags & ANTENNA_RX_DIVERSITY) in rt2x00mac_get_antenna()
806 *rx_ant = active->rx; in rt2x00mac_get_antenna()
812 void rt2x00mac_get_ringparam(struct ieee80211_hw *hw, in rt2x00mac_get_ringparam() argument
815 struct rt2x00_dev *rt2x00dev = hw->priv; in rt2x00mac_get_ringparam()
819 *tx += queue->length; in rt2x00mac_get_ringparam()
820 *tx_max += queue->limit; in rt2x00mac_get_ringparam()
823 *rx = rt2x00dev->rx->length; in rt2x00mac_get_ringparam()
824 *rx_max = rt2x00dev->rx->limit; in rt2x00mac_get_ringparam()
828 bool rt2x00mac_tx_frames_pending(struct ieee80211_hw *hw) in rt2x00mac_tx_frames_pending() argument
830 struct rt2x00_dev *rt2x00dev = hw->priv; in rt2x00mac_tx_frames_pending()