Lines Matching +full:t +full:- +full:phy
1 // SPDX-License-Identifier: ISC
11 if (!txq->sta) in mt76_txq_get_qid()
14 return txq->ac; in mt76_txq_get_qid()
20 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; in mt76_tx_check_agg_ssn()
25 if (!sta || !ieee80211_is_data_qos(hdr->frame_control) || in mt76_tx_check_agg_ssn()
26 !ieee80211_is_data_present(hdr->frame_control)) in mt76_tx_check_agg_ssn()
29 tid = skb->priority & IEEE80211_QOS_CTL_TAG1D_MASK; in mt76_tx_check_agg_ssn()
30 txq = sta->txq[tid]; in mt76_tx_check_agg_ssn()
31 mtxq = (struct mt76_txq *)txq->drv_priv; in mt76_tx_check_agg_ssn()
32 if (!mtxq->aggr) in mt76_tx_check_agg_ssn()
35 mtxq->agg_ssn = le16_to_cpu(hdr->seq_ctrl) + 0x10; in mt76_tx_check_agg_ssn()
41 __acquires(&dev->status_lock) in mt76_tx_status_lock()
44 spin_lock_bh(&dev->status_lock); in mt76_tx_status_lock()
50 __releases(&dev->status_lock) in mt76_tx_status_unlock()
55 spin_unlock_bh(&dev->status_lock); in mt76_tx_status_unlock()
67 wcid = rcu_dereference(dev->wcid[cb->wcid]); in mt76_tx_status_unlock()
70 if (status.sta && (wcid->rate.flags || wcid->rate.legacy)) { in mt76_tx_status_unlock()
71 rs.rate_idx = wcid->rate; in mt76_tx_status_unlock()
80 spin_lock_bh(&dev->rx_lock); in mt76_tx_status_unlock()
82 spin_unlock_bh(&dev->rx_lock); in mt76_tx_status_unlock()
96 flags |= cb->flags; in __mt76_tx_status_skb_done()
97 cb->flags = flags; in __mt76_tx_status_skb_done()
104 info->status.rates[0].count = 0; in __mt76_tx_status_skb_done()
105 info->status.rates[0].idx = -1; in __mt76_tx_status_skb_done()
106 info->flags |= IEEE80211_TX_STAT_ACK; in __mt76_tx_status_skb_done()
124 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; in mt76_tx_status_skb_add()
131 if (!wcid || !rcu_access_pointer(dev->wcid[wcid->idx])) in mt76_tx_status_skb_add()
134 if (info->flags & IEEE80211_TX_CTL_NO_ACK) in mt76_tx_status_skb_add()
137 if (!(info->flags & (IEEE80211_TX_CTL_REQ_TX_STATUS | in mt76_tx_status_skb_add()
139 if (mtk_wed_device_active(&dev->mmio.wed) && in mt76_tx_status_skb_add()
140 ((info->flags & IEEE80211_TX_CTL_HW_80211_ENCAP) || in mt76_tx_status_skb_add()
141 ieee80211_is_data(hdr->frame_control))) in mt76_tx_status_skb_add()
147 spin_lock_bh(&dev->status_lock); in mt76_tx_status_skb_add()
149 pid = idr_alloc(&wcid->pktid, skb, MT_PACKET_ID_FIRST, in mt76_tx_status_skb_add()
156 cb->wcid = wcid->idx; in mt76_tx_status_skb_add()
157 cb->pktid = pid; in mt76_tx_status_skb_add()
159 if (list_empty(&wcid->list)) in mt76_tx_status_skb_add()
160 list_add_tail(&wcid->list, &dev->wcid_list); in mt76_tx_status_skb_add()
163 spin_unlock_bh(&dev->status_lock); in mt76_tx_status_skb_add()
176 lockdep_assert_held(&dev->status_lock); in mt76_tx_status_skb_get()
178 skb = idr_remove(&wcid->pktid, pktid); in mt76_tx_status_skb_get()
183 idr_for_each_entry(&wcid->pktid, skb, id) { in mt76_tx_status_skb_get()
187 if (!(cb->flags & MT_TX_CB_DMA_DONE)) in mt76_tx_status_skb_get()
190 if (time_is_after_jiffies(cb->jiffies + in mt76_tx_status_skb_get()
198 idr_remove(&wcid->pktid, cb->pktid); in mt76_tx_status_skb_get()
204 if (idr_is_empty(&wcid->pktid)) in mt76_tx_status_skb_get()
205 list_del_init(&wcid->list); in mt76_tx_status_skb_get()
218 list_for_each_entry_safe(wcid, tmp, &dev->wcid_list, list) in mt76_tx_status_check()
219 mt76_tx_status_skb_get(dev, wcid, flush ? -1 : 0, &list); in mt76_tx_status_check()
231 if (!wcid || info->tx_time_est) in mt76_tx_check_non_aql()
234 pending = atomic_dec_return(&wcid->non_aql_packets); in mt76_tx_check_non_aql()
236 atomic_cmpxchg(&wcid->non_aql_packets, pending, 0); in mt76_tx_check_non_aql()
253 if (wcid_idx < ARRAY_SIZE(dev->wcid)) in __mt76_tx_complete_skb()
254 wcid = rcu_dereference(dev->wcid[wcid_idx]); in __mt76_tx_complete_skb()
260 struct mt76_phy *phy = hw->priv; in __mt76_tx_complete_skb() local
262 if (skb == phy->test.tx_skb) in __mt76_tx_complete_skb()
263 phy->test.tx_done++; in __mt76_tx_complete_skb()
264 if (phy->test.tx_queued == phy->test.tx_done) in __mt76_tx_complete_skb()
265 wake_up(&dev->tx_wait); in __mt76_tx_complete_skb()
272 if (cb->pktid < MT_PACKET_ID_FIRST) { in __mt76_tx_complete_skb()
277 if (status.sta && (wcid->rate.flags || wcid->rate.legacy)) { in __mt76_tx_complete_skb()
278 rs.rate_idx = wcid->rate; in __mt76_tx_complete_skb()
282 spin_lock_bh(&dev->rx_lock); in __mt76_tx_complete_skb()
284 spin_unlock_bh(&dev->rx_lock); in __mt76_tx_complete_skb()
289 cb->jiffies = jiffies; in __mt76_tx_complete_skb()
299 __mt76_tx_queue_skb(struct mt76_phy *phy, int qid, struct sk_buff *skb, in __mt76_tx_queue_skb() argument
304 struct mt76_queue *q = phy->q_tx[qid]; in __mt76_tx_queue_skb()
305 struct mt76_dev *dev = phy->dev; in __mt76_tx_queue_skb()
310 non_aql = !info->tx_time_est; in __mt76_tx_queue_skb()
311 idx = dev->queue_ops->tx_queue_skb(dev, q, qid, skb, wcid, sta); in __mt76_tx_queue_skb()
315 wcid = (struct mt76_wcid *)sta->drv_priv; in __mt76_tx_queue_skb()
316 q->entry[idx].wcid = wcid->idx; in __mt76_tx_queue_skb()
321 pending = atomic_inc_return(&wcid->non_aql_packets); in __mt76_tx_queue_skb()
329 mt76_tx(struct mt76_phy *phy, struct ieee80211_sta *sta, in mt76_tx() argument
332 struct mt76_dev *dev = phy->dev; in mt76_tx()
334 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; in mt76_tx()
338 if (mt76_testmode_enabled(phy)) { in mt76_tx()
339 ieee80211_free_txskb(phy->hw, skb); in mt76_tx()
348 if ((dev->drv->drv_flags & MT_DRV_HW_MGMT_TXQ) && in mt76_tx()
349 !(info->flags & IEEE80211_TX_CTL_HW_80211_ENCAP) && in mt76_tx()
350 !ieee80211_is_data(hdr->frame_control) && in mt76_tx()
355 if (wcid && !(wcid->tx_info & MT_WCID_TX_INFO_SET)) in mt76_tx()
356 ieee80211_get_tx_rates(info->control.vif, sta, skb, in mt76_tx()
357 info->control.rates, 1); in mt76_tx()
359 info->hw_queue |= FIELD_PREP(MT_TX_HW_QUEUE_PHY, phy->band_idx); in mt76_tx()
360 q = phy->q_tx[qid]; in mt76_tx()
362 spin_lock_bh(&q->lock); in mt76_tx()
363 __mt76_tx_queue_skb(phy, qid, skb, wcid, sta, NULL); in mt76_tx()
364 dev->queue_ops->kick(dev, q); in mt76_tx()
365 spin_unlock_bh(&q->lock); in mt76_tx()
370 mt76_txq_dequeue(struct mt76_phy *phy, struct mt76_txq *mtxq) in mt76_txq_dequeue() argument
376 skb = ieee80211_tx_dequeue(phy->hw, txq); in mt76_txq_dequeue()
381 info->hw_queue |= FIELD_PREP(MT_TX_HW_QUEUE_PHY, phy->band_idx); in mt76_txq_dequeue()
387 mt76_queue_ps_skb(struct mt76_phy *phy, struct ieee80211_sta *sta, in mt76_queue_ps_skb() argument
390 struct mt76_wcid *wcid = (struct mt76_wcid *)sta->drv_priv; in mt76_queue_ps_skb()
393 info->control.flags |= IEEE80211_TX_CTRL_PS_RESPONSE; in mt76_queue_ps_skb()
395 info->flags |= IEEE80211_TX_STATUS_EOSP | in mt76_queue_ps_skb()
399 __mt76_tx_queue_skb(phy, MT_TXQ_PSD, skb, wcid, sta, NULL); in mt76_queue_ps_skb()
408 struct mt76_phy *phy = hw->priv; in mt76_release_buffered_frames() local
409 struct mt76_dev *dev = phy->dev; in mt76_release_buffered_frames()
411 struct mt76_queue *hwq = phy->q_tx[MT_TXQ_PSD]; in mt76_release_buffered_frames()
414 spin_lock_bh(&hwq->lock); in mt76_release_buffered_frames()
416 struct ieee80211_txq *txq = sta->txq[i]; in mt76_release_buffered_frames()
417 struct mt76_txq *mtxq = (struct mt76_txq *)txq->drv_priv; in mt76_release_buffered_frames()
424 skb = mt76_txq_dequeue(phy, mtxq); in mt76_release_buffered_frames()
428 nframes--; in mt76_release_buffered_frames()
430 mt76_queue_ps_skb(phy, sta, last_skb, false); in mt76_release_buffered_frames()
437 mt76_queue_ps_skb(phy, sta, last_skb, true); in mt76_release_buffered_frames()
438 dev->queue_ops->kick(dev, hwq); in mt76_release_buffered_frames()
443 spin_unlock_bh(&hwq->lock); in mt76_release_buffered_frames()
450 return q->stopped || q->blocked || in mt76_txq_stopped()
451 q->queued + MT_TXQ_FREE_THR >= q->ndesc; in mt76_txq_stopped()
455 mt76_txq_send_burst(struct mt76_phy *phy, struct mt76_queue *q, in mt76_txq_send_burst() argument
458 struct mt76_dev *dev = phy->dev; in mt76_txq_send_burst()
467 if (test_bit(MT_WCID_FLAG_PS, &wcid->flags)) in mt76_txq_send_burst()
470 if (atomic_read(&wcid->non_aql_packets) >= MT_MAX_NON_AQL_PKT) in mt76_txq_send_burst()
473 skb = mt76_txq_dequeue(phy, mtxq); in mt76_txq_send_burst()
478 if (!(wcid->tx_info & MT_WCID_TX_INFO_SET)) in mt76_txq_send_burst()
479 ieee80211_get_tx_rates(txq->vif, txq->sta, skb, in mt76_txq_send_burst()
480 info->control.rates, 1); in mt76_txq_send_burst()
482 spin_lock(&q->lock); in mt76_txq_send_burst()
483 idx = __mt76_tx_queue_skb(phy, qid, skb, wcid, txq->sta, &stop); in mt76_txq_send_burst()
484 spin_unlock(&q->lock); in mt76_txq_send_burst()
489 if (test_bit(MT76_RESET, &phy->state)) in mt76_txq_send_burst()
490 return -EBUSY; in mt76_txq_send_burst()
495 skb = mt76_txq_dequeue(phy, mtxq); in mt76_txq_send_burst()
500 if (!(wcid->tx_info & MT_WCID_TX_INFO_SET)) in mt76_txq_send_burst()
501 ieee80211_get_tx_rates(txq->vif, txq->sta, skb, in mt76_txq_send_burst()
502 info->control.rates, 1); in mt76_txq_send_burst()
504 spin_lock(&q->lock); in mt76_txq_send_burst()
505 idx = __mt76_tx_queue_skb(phy, qid, skb, wcid, txq->sta, &stop); in mt76_txq_send_burst()
506 spin_unlock(&q->lock); in mt76_txq_send_burst()
513 spin_lock(&q->lock); in mt76_txq_send_burst()
514 dev->queue_ops->kick(dev, q); in mt76_txq_send_burst()
515 spin_unlock(&q->lock); in mt76_txq_send_burst()
521 mt76_txq_schedule_list(struct mt76_phy *phy, enum mt76_txq_id qid) in mt76_txq_schedule_list() argument
523 struct mt76_queue *q = phy->q_tx[qid]; in mt76_txq_schedule_list()
524 struct mt76_dev *dev = phy->dev; in mt76_txq_schedule_list()
533 if (test_bit(MT76_RESET, &phy->state)) in mt76_txq_schedule_list()
534 return -EBUSY; in mt76_txq_schedule_list()
536 if (dev->queue_ops->tx_cleanup && in mt76_txq_schedule_list()
537 q->queued + 2 * MT_TXQ_FREE_THR >= q->ndesc) { in mt76_txq_schedule_list()
538 dev->queue_ops->tx_cleanup(dev, q, false); in mt76_txq_schedule_list()
541 txq = ieee80211_next_txq(phy->hw, qid); in mt76_txq_schedule_list()
545 mtxq = (struct mt76_txq *)txq->drv_priv; in mt76_txq_schedule_list()
546 wcid = rcu_dereference(dev->wcid[mtxq->wcid]); in mt76_txq_schedule_list()
547 if (!wcid || test_bit(MT_WCID_FLAG_PS, &wcid->flags)) in mt76_txq_schedule_list()
550 if (mtxq->send_bar && mtxq->aggr) { in mt76_txq_schedule_list()
552 struct ieee80211_sta *sta = txq->sta; in mt76_txq_schedule_list()
553 struct ieee80211_vif *vif = txq->vif; in mt76_txq_schedule_list()
554 u16 agg_ssn = mtxq->agg_ssn; in mt76_txq_schedule_list()
555 u8 tid = txq->tid; in mt76_txq_schedule_list()
557 mtxq->send_bar = false; in mt76_txq_schedule_list()
558 ieee80211_send_bar(vif, sta->addr, tid, agg_ssn); in mt76_txq_schedule_list()
562 n_frames = mt76_txq_send_burst(phy, q, mtxq, wcid); in mt76_txq_schedule_list()
564 ieee80211_return_txq(phy->hw, txq, false); in mt76_txq_schedule_list()
575 void mt76_txq_schedule(struct mt76_phy *phy, enum mt76_txq_id qid) in mt76_txq_schedule() argument
586 ieee80211_txq_schedule_start(phy->hw, qid); in mt76_txq_schedule()
587 len = mt76_txq_schedule_list(phy, qid); in mt76_txq_schedule()
588 ieee80211_txq_schedule_end(phy->hw, qid); in mt76_txq_schedule()
596 void mt76_txq_schedule_all(struct mt76_phy *phy) in mt76_txq_schedule_all() argument
601 mt76_txq_schedule(phy, i); in mt76_txq_schedule_all()
607 struct mt76_phy *phy; in mt76_tx_worker_run() local
610 for (i = 0; i < ARRAY_SIZE(dev->phys); i++) { in mt76_tx_worker_run()
611 phy = dev->phys[i]; in mt76_tx_worker_run()
612 if (!phy) in mt76_tx_worker_run()
615 mt76_txq_schedule_all(phy); in mt76_tx_worker_run()
619 for (i = 0; i < ARRAY_SIZE(dev->phys); i++) { in mt76_tx_worker_run()
620 phy = dev->phys[i]; in mt76_tx_worker_run()
621 if (!phy || !phy->test.tx_pending) in mt76_tx_worker_run()
624 mt76_testmode_tx_pending(phy); in mt76_tx_worker_run()
637 void mt76_stop_tx_queues(struct mt76_phy *phy, struct ieee80211_sta *sta, in mt76_stop_tx_queues() argument
642 for (i = 0; i < ARRAY_SIZE(sta->txq); i++) { in mt76_stop_tx_queues()
643 struct ieee80211_txq *txq = sta->txq[i]; in mt76_stop_tx_queues()
650 hwq = phy->q_tx[mt76_txq_get_qid(txq)]; in mt76_stop_tx_queues()
651 mtxq = (struct mt76_txq *)txq->drv_priv; in mt76_stop_tx_queues()
653 spin_lock_bh(&hwq->lock); in mt76_stop_tx_queues()
654 mtxq->send_bar = mtxq->aggr && send_bar; in mt76_stop_tx_queues()
655 spin_unlock_bh(&hwq->lock); in mt76_stop_tx_queues()
662 struct mt76_phy *phy = hw->priv; in mt76_wake_tx_queue() local
663 struct mt76_dev *dev = phy->dev; in mt76_wake_tx_queue()
665 if (!test_bit(MT76_STATE_RUNNING, &phy->state)) in mt76_wake_tx_queue()
668 mt76_worker_schedule(&dev->tx_worker); in mt76_wake_tx_queue()
692 /* First packet of a A-MSDU burst keeps track of the whole burst in mt76_skb_adjust_pad()
697 if (!iter->next) { in mt76_skb_adjust_pad()
698 skb->data_len += pad; in mt76_skb_adjust_pad()
699 skb->len += pad; in mt76_skb_adjust_pad()
705 return -ENOMEM; in mt76_skb_adjust_pad()
716 if (e->skb) in mt76_queue_tx_complete()
717 dev->drv->tx_complete_skb(dev, e); in mt76_queue_tx_complete()
719 spin_lock_bh(&q->lock); in mt76_queue_tx_complete()
720 q->tail = (q->tail + 1) % q->ndesc; in mt76_queue_tx_complete()
721 q->queued--; in mt76_queue_tx_complete()
722 spin_unlock_bh(&q->lock); in mt76_queue_tx_complete()
728 struct mt76_phy *phy = &dev->phy; in __mt76_set_tx_blocked() local
729 struct mt76_queue *q = phy->q_tx[0]; in __mt76_set_tx_blocked()
731 if (blocked == q->blocked) in __mt76_set_tx_blocked()
734 q->blocked = blocked; in __mt76_set_tx_blocked()
736 phy = dev->phys[MT_BAND1]; in __mt76_set_tx_blocked()
737 if (phy) { in __mt76_set_tx_blocked()
738 q = phy->q_tx[0]; in __mt76_set_tx_blocked()
739 q->blocked = blocked; in __mt76_set_tx_blocked()
741 phy = dev->phys[MT_BAND2]; in __mt76_set_tx_blocked()
742 if (phy) { in __mt76_set_tx_blocked()
743 q = phy->q_tx[0]; in __mt76_set_tx_blocked()
744 q->blocked = blocked; in __mt76_set_tx_blocked()
748 mt76_worker_schedule(&dev->tx_worker); in __mt76_set_tx_blocked()
756 spin_lock_bh(&dev->token_lock); in mt76_token_consume()
758 token = idr_alloc(&dev->token, *ptxwi, 0, dev->token_size, GFP_ATOMIC); in mt76_token_consume()
760 dev->token_count++; in mt76_token_consume()
763 if (mtk_wed_device_active(&dev->mmio.wed) && in mt76_token_consume()
764 token >= dev->mmio.wed.wlan.token_start) in mt76_token_consume()
765 dev->wed_token_count++; in mt76_token_consume()
768 if (dev->token_count >= dev->token_size - MT76_TOKEN_FREE_THR) in mt76_token_consume()
771 spin_unlock_bh(&dev->token_lock); in mt76_token_consume()
778 struct mt76_txwi_cache *t, dma_addr_t phys) in mt76_rx_token_consume() argument
782 spin_lock_bh(&dev->rx_token_lock); in mt76_rx_token_consume()
783 token = idr_alloc(&dev->rx_token, t, 0, dev->rx_token_size, in mt76_rx_token_consume()
786 t->ptr = ptr; in mt76_rx_token_consume()
787 t->dma_addr = phys; in mt76_rx_token_consume()
789 spin_unlock_bh(&dev->rx_token_lock); in mt76_rx_token_consume()
800 spin_lock_bh(&dev->token_lock); in mt76_token_release()
802 txwi = idr_remove(&dev->token, token); in mt76_token_release()
804 dev->token_count--; in mt76_token_release()
807 if (mtk_wed_device_active(&dev->mmio.wed) && in mt76_token_release()
808 token >= dev->mmio.wed.wlan.token_start && in mt76_token_release()
809 --dev->wed_token_count == 0) in mt76_token_release()
810 wake_up(&dev->tx_wait); in mt76_token_release()
814 if (dev->token_count < dev->token_size - MT76_TOKEN_FREE_THR && in mt76_token_release()
815 dev->phy.q_tx[0]->blocked) in mt76_token_release()
818 spin_unlock_bh(&dev->token_lock); in mt76_token_release()
827 struct mt76_txwi_cache *t; in mt76_rx_token_release() local
829 spin_lock_bh(&dev->rx_token_lock); in mt76_rx_token_release()
830 t = idr_remove(&dev->rx_token, token); in mt76_rx_token_release()
831 spin_unlock_bh(&dev->rx_token_lock); in mt76_rx_token_release()
833 return t; in mt76_rx_token_release()