1 // SPDX-License-Identifier: ISC
2 /* Copyright (C) 2020 MediaTek Inc. */
4 #include "mt76_connac.h"
5 #include "mt76_connac2_mac.h"
8 #define HE_BITS(f) cpu_to_le16(IEEE80211_RADIOTAP_HE_##f)
9 #define HE_PREP(f, m, v) le16_encode_bits(le32_get_bits(v, MT_CRXV_HE_##m),\
10 IEEE80211_RADIOTAP_HE_##f)
12 void mt76_connac_gen_ppe_thresh(u8
*he_ppet
, int nss
)
14 static const u8 ppet16_ppet8_ru3_ru0
[] = { 0x1c, 0xc7, 0x71 };
15 u8 i
, ppet_bits
, ppet_size
, ru_bit_mask
= 0x7; /* HE80 */
17 he_ppet
[0] = FIELD_PREP(IEEE80211_PPE_THRES_NSS_MASK
, nss
- 1) |
18 FIELD_PREP(IEEE80211_PPE_THRES_RU_INDEX_BITMASK_MASK
,
21 ppet_bits
= IEEE80211_PPE_THRES_INFO_PPET_SIZE
*
22 nss
* hweight8(ru_bit_mask
) * 2;
23 ppet_size
= DIV_ROUND_UP(ppet_bits
, 8);
25 for (i
= 0; i
< ppet_size
- 1; i
++)
26 he_ppet
[i
+ 1] = ppet16_ppet8_ru3_ru0
[i
% 3];
28 he_ppet
[i
+ 1] = ppet16_ppet8_ru3_ru0
[i
% 3] &
29 (0xff >> (8 - (ppet_bits
- 1) % 8));
31 EXPORT_SYMBOL_GPL(mt76_connac_gen_ppe_thresh
);
33 int mt76_connac_pm_wake(struct mt76_phy
*phy
, struct mt76_connac_pm
*pm
)
35 struct mt76_dev
*dev
= phy
->dev
;
40 cancel_delayed_work_sync(&pm
->ps_work
);
41 if (!test_bit(MT76_STATE_PM
, &phy
->state
))
47 queue_work(dev
->wq
, &pm
->wake_work
);
48 if (!wait_event_timeout(pm
->wait
,
49 !test_bit(MT76_STATE_PM
, &phy
->state
),
51 ieee80211_wake_queues(phy
->hw
);
57 EXPORT_SYMBOL_GPL(mt76_connac_pm_wake
);
59 void mt76_connac_power_save_sched(struct mt76_phy
*phy
,
60 struct mt76_connac_pm
*pm
)
62 struct mt76_dev
*dev
= phy
->dev
;
73 pm
->last_activity
= jiffies
;
75 if (!test_bit(MT76_STATE_PM
, &phy
->state
)) {
76 cancel_delayed_work(&phy
->mac_work
);
77 queue_delayed_work(dev
->wq
, &pm
->ps_work
, pm
->idle_timeout
);
80 EXPORT_SYMBOL_GPL(mt76_connac_power_save_sched
);
82 void mt76_connac_free_pending_tx_skbs(struct mt76_connac_pm
*pm
,
83 struct mt76_wcid
*wcid
)
87 spin_lock_bh(&pm
->txq_lock
);
88 for (i
= 0; i
< IEEE80211_NUM_ACS
; i
++) {
89 if (wcid
&& pm
->tx_q
[i
].wcid
!= wcid
)
92 dev_kfree_skb(pm
->tx_q
[i
].skb
);
93 pm
->tx_q
[i
].skb
= NULL
;
95 spin_unlock_bh(&pm
->txq_lock
);
97 EXPORT_SYMBOL_GPL(mt76_connac_free_pending_tx_skbs
);
99 void mt76_connac_pm_queue_skb(struct ieee80211_hw
*hw
,
100 struct mt76_connac_pm
*pm
,
101 struct mt76_wcid
*wcid
,
104 int qid
= skb_get_queue_mapping(skb
);
105 struct mt76_phy
*phy
= hw
->priv
;
107 spin_lock_bh(&pm
->txq_lock
);
108 if (!pm
->tx_q
[qid
].skb
) {
109 ieee80211_stop_queues(hw
);
110 pm
->tx_q
[qid
].wcid
= wcid
;
111 pm
->tx_q
[qid
].skb
= skb
;
112 queue_work(phy
->dev
->wq
, &pm
->wake_work
);
116 spin_unlock_bh(&pm
->txq_lock
);
118 EXPORT_SYMBOL_GPL(mt76_connac_pm_queue_skb
);
120 void mt76_connac_pm_dequeue_skbs(struct mt76_phy
*phy
,
121 struct mt76_connac_pm
*pm
)
125 spin_lock_bh(&pm
->txq_lock
);
126 for (i
= 0; i
< IEEE80211_NUM_ACS
; i
++) {
127 struct mt76_wcid
*wcid
= pm
->tx_q
[i
].wcid
;
128 struct ieee80211_sta
*sta
= NULL
;
130 if (!pm
->tx_q
[i
].skb
)
133 if (wcid
&& wcid
->sta
)
134 sta
= container_of((void *)wcid
, struct ieee80211_sta
,
137 mt76_tx(phy
, sta
, wcid
, pm
->tx_q
[i
].skb
);
138 pm
->tx_q
[i
].skb
= NULL
;
140 spin_unlock_bh(&pm
->txq_lock
);
142 mt76_worker_schedule(&phy
->dev
->tx_worker
);
144 EXPORT_SYMBOL_GPL(mt76_connac_pm_dequeue_skbs
);
146 void mt76_connac_tx_complete_skb(struct mt76_dev
*mdev
,
147 struct mt76_queue_entry
*e
)
150 dev_kfree_skb_any(e
->skb
);
155 mt76_tx_complete_skb(mdev
, e
->wcid
, e
->skb
);
157 EXPORT_SYMBOL_GPL(mt76_connac_tx_complete_skb
);
159 void mt76_connac_write_hw_txp(struct mt76_dev
*dev
,
160 struct mt76_tx_info
*tx_info
,
161 void *txp_ptr
, u32 id
)
163 struct mt76_connac_hw_txp
*txp
= txp_ptr
;
164 struct mt76_connac_txp_ptr
*ptr
= &txp
->ptr
[0];
165 int i
, nbuf
= tx_info
->nbuf
- 1;
168 tx_info
->buf
[0].len
= MT_TXD_SIZE
+ sizeof(*txp
);
171 txp
->msdu_id
[0] = cpu_to_le16(id
| MT_MSDU_ID_VALID
);
173 if (is_mt7663(dev
) || is_mt7921(dev
) || is_mt7925(dev
))
174 last_mask
= MT_TXD_LEN_LAST
;
176 last_mask
= MT_TXD_LEN_AMSDU_LAST
|
177 MT_TXD_LEN_MSDU_LAST
;
179 for (i
= 0; i
< nbuf
; i
++) {
180 u16 len
= tx_info
->buf
[i
+ 1].len
& MT_TXD_LEN_MASK
;
181 u32 addr
= tx_info
->buf
[i
+ 1].addr
;
187 ptr
->buf1
= cpu_to_le32(addr
);
188 ptr
->len1
= cpu_to_le16(len
);
191 ptr
->buf0
= cpu_to_le32(addr
);
192 ptr
->len0
= cpu_to_le16(len
);
196 EXPORT_SYMBOL_GPL(mt76_connac_write_hw_txp
);
199 mt76_connac_txp_skb_unmap_fw(struct mt76_dev
*mdev
,
200 struct mt76_connac_fw_txp
*txp
)
202 struct device
*dev
= is_connac_v1(mdev
) ? mdev
->dev
: mdev
->dma_dev
;
205 for (i
= 0; i
< txp
->nbuf
; i
++)
206 dma_unmap_single(dev
, le32_to_cpu(txp
->buf
[i
]),
207 le16_to_cpu(txp
->len
[i
]), DMA_TO_DEVICE
);
211 mt76_connac_txp_skb_unmap_hw(struct mt76_dev
*dev
,
212 struct mt76_connac_hw_txp
*txp
)
217 if (is_mt7663(dev
) || is_mt7921(dev
) || is_mt7925(dev
))
218 last_mask
= MT_TXD_LEN_LAST
;
220 last_mask
= MT_TXD_LEN_MSDU_LAST
;
222 for (i
= 0; i
< ARRAY_SIZE(txp
->ptr
); i
++) {
223 struct mt76_connac_txp_ptr
*ptr
= &txp
->ptr
[i
];
227 len
= le16_to_cpu(ptr
->len0
);
228 last
= len
& last_mask
;
229 len
&= MT_TXD_LEN_MASK
;
230 dma_unmap_single(dev
->dev
, le32_to_cpu(ptr
->buf0
), len
,
235 len
= le16_to_cpu(ptr
->len1
);
236 last
= len
& last_mask
;
237 len
&= MT_TXD_LEN_MASK
;
238 dma_unmap_single(dev
->dev
, le32_to_cpu(ptr
->buf1
), len
,
245 void mt76_connac_txp_skb_unmap(struct mt76_dev
*dev
,
246 struct mt76_txwi_cache
*t
)
248 struct mt76_connac_txp_common
*txp
;
250 txp
= mt76_connac_txwi_to_txp(dev
, t
);
251 if (is_mt76_fw_txp(dev
))
252 mt76_connac_txp_skb_unmap_fw(dev
, &txp
->fw
);
254 mt76_connac_txp_skb_unmap_hw(dev
, &txp
->hw
);
256 EXPORT_SYMBOL_GPL(mt76_connac_txp_skb_unmap
);
258 int mt76_connac_init_tx_queues(struct mt76_phy
*phy
, int idx
, int n_desc
,
259 int ring_base
, void *wed
, u32 flags
)
263 err
= mt76_init_tx_queue(phy
, 0, idx
, n_desc
, ring_base
,
268 for (i
= 1; i
<= MT_TXQ_PSD
; i
++)
269 phy
->q_tx
[i
] = phy
->q_tx
[0];
273 EXPORT_SYMBOL_GPL(mt76_connac_init_tx_queues
);
275 #define __bitrate_mask_check(_mcs, _mode) \
278 for (nss = 0; i < ARRAY_SIZE(mask->control[band]._mcs); i++) { \
279 if (!mask->control[band]._mcs[i]) \
281 if (hweight16(mask->control[band]._mcs[i]) == 1) { \
282 mode = MT_PHY_TYPE_##_mode; \
283 rateidx = ffs(mask->control[band]._mcs[i]) - 1; \
284 if (mode == MT_PHY_TYPE_HT) \
293 u16
mt76_connac2_mac_tx_rate_val(struct mt76_phy
*mphy
,
294 struct ieee80211_vif
*vif
,
295 bool beacon
, bool mcast
)
297 struct mt76_vif
*mvif
= (struct mt76_vif
*)vif
->drv_priv
;
298 struct cfg80211_chan_def
*chandef
= mvif
->ctx
?
299 &mvif
->ctx
->def
: &mphy
->chandef
;
300 u8 nss
= 0, mode
= 0, band
= chandef
->chan
->band
;
301 int rateidx
= 0, mcast_rate
;
306 if (is_mt7921(mphy
->dev
)) {
307 rateidx
= ffs(vif
->bss_conf
.basic_rates
) - 1;
312 struct cfg80211_bitrate_mask
*mask
;
314 mask
= &vif
->bss_conf
.beacon_tx_rate
;
316 __bitrate_mask_check(he_mcs
, HE_SU
);
317 __bitrate_mask_check(vht_mcs
, VHT
);
318 __bitrate_mask_check(ht_mcs
, HT
);
320 if (hweight32(mask
->control
[band
].legacy
) == 1) {
321 rateidx
= ffs(mask
->control
[band
].legacy
) - 1;
326 mcast_rate
= vif
->bss_conf
.mcast_rate
[band
];
327 if (mcast
&& mcast_rate
> 0)
328 rateidx
= mcast_rate
- 1;
330 rateidx
= ffs(vif
->bss_conf
.basic_rates
) - 1;
333 rateidx
= mt76_calculate_default_rate(mphy
, vif
, rateidx
);
335 rateidx
&= GENMASK(7, 0);
337 return FIELD_PREP(MT_TX_RATE_NSS
, nss
) |
338 FIELD_PREP(MT_TX_RATE_IDX
, rateidx
) |
339 FIELD_PREP(MT_TX_RATE_MODE
, mode
);
341 EXPORT_SYMBOL_GPL(mt76_connac2_mac_tx_rate_val
);
344 mt76_connac2_mac_write_txwi_8023(__le32
*txwi
, struct sk_buff
*skb
,
345 struct mt76_wcid
*wcid
)
347 u8 tid
= skb
->priority
& IEEE80211_QOS_CTL_TID_MASK
;
348 u8 fc_type
, fc_stype
;
354 struct ieee80211_sta
*sta
;
356 sta
= container_of((void *)wcid
, struct ieee80211_sta
, drv_priv
);
360 val
= FIELD_PREP(MT_TXD1_HDR_FORMAT
, MT_HDR_FORMAT_802_3
) |
361 FIELD_PREP(MT_TXD1_TID
, tid
);
363 ethertype
= get_unaligned_be16(&skb
->data
[12]);
364 if (ethertype
>= ETH_P_802_3_MIN
)
365 val
|= MT_TXD1_ETH_802_3
;
367 txwi
[1] |= cpu_to_le32(val
);
369 fc_type
= IEEE80211_FTYPE_DATA
>> 2;
370 fc_stype
= wmm
? IEEE80211_STYPE_QOS_DATA
>> 4 : 0;
372 val
= FIELD_PREP(MT_TXD2_FRAME_TYPE
, fc_type
) |
373 FIELD_PREP(MT_TXD2_SUB_TYPE
, fc_stype
);
375 txwi
[2] |= cpu_to_le32(val
);
377 val
= FIELD_PREP(MT_TXD7_TYPE
, fc_type
) |
378 FIELD_PREP(MT_TXD7_SUB_TYPE
, fc_stype
);
380 txwi
[7] |= cpu_to_le32(val
);
384 mt76_connac2_mac_write_txwi_80211(struct mt76_dev
*dev
, __le32
*txwi
,
386 struct ieee80211_key_conf
*key
)
388 struct ieee80211_hdr
*hdr
= (struct ieee80211_hdr
*)skb
->data
;
389 struct ieee80211_mgmt
*mgmt
= (struct ieee80211_mgmt
*)skb
->data
;
390 struct ieee80211_tx_info
*info
= IEEE80211_SKB_CB(skb
);
391 bool multicast
= is_multicast_ether_addr(hdr
->addr1
);
392 u8 tid
= skb
->priority
& IEEE80211_QOS_CTL_TID_MASK
;
393 __le16 fc
= hdr
->frame_control
;
394 __le16 sc
= hdr
->seq_ctrl
;
395 u8 fc_type
, fc_stype
;
398 if (ieee80211_is_action(fc
) &&
399 mgmt
->u
.action
.category
== WLAN_CATEGORY_BACK
&&
400 mgmt
->u
.action
.u
.addba_req
.action_code
== WLAN_ACTION_ADDBA_REQ
) {
401 u16 capab
= le16_to_cpu(mgmt
->u
.action
.u
.addba_req
.capab
);
403 txwi
[5] |= cpu_to_le32(MT_TXD5_ADD_BA
);
404 tid
= (capab
>> 2) & IEEE80211_QOS_CTL_TID_MASK
;
405 } else if (ieee80211_is_back_req(hdr
->frame_control
)) {
406 struct ieee80211_bar
*bar
= (struct ieee80211_bar
*)hdr
;
407 u16 control
= le16_to_cpu(bar
->control
);
409 tid
= FIELD_GET(IEEE80211_BAR_CTRL_TID_INFO_MASK
, control
);
412 val
= FIELD_PREP(MT_TXD1_HDR_FORMAT
, MT_HDR_FORMAT_802_11
) |
413 FIELD_PREP(MT_TXD1_HDR_INFO
,
414 ieee80211_get_hdrlen_from_skb(skb
) / 2) |
415 FIELD_PREP(MT_TXD1_TID
, tid
);
417 txwi
[1] |= cpu_to_le32(val
);
419 fc_type
= (le16_to_cpu(fc
) & IEEE80211_FCTL_FTYPE
) >> 2;
420 fc_stype
= (le16_to_cpu(fc
) & IEEE80211_FCTL_STYPE
) >> 4;
422 val
= FIELD_PREP(MT_TXD2_FRAME_TYPE
, fc_type
) |
423 FIELD_PREP(MT_TXD2_SUB_TYPE
, fc_stype
) |
424 FIELD_PREP(MT_TXD2_MULTICAST
, multicast
);
426 if (key
&& multicast
&& ieee80211_is_robust_mgmt_frame(skb
) &&
427 key
->cipher
== WLAN_CIPHER_SUITE_AES_CMAC
) {
429 txwi
[3] &= ~cpu_to_le32(MT_TXD3_PROTECT_FRAME
);
432 if (!ieee80211_is_data(fc
) || multicast
||
433 info
->flags
& IEEE80211_TX_CTL_USE_MINRATE
)
434 val
|= MT_TXD2_FIX_RATE
;
436 if (ieee80211_has_morefrags(fc
) && ieee80211_is_first_frag(sc
))
437 val
|= FIELD_PREP(MT_TXD2_FRAG
, MT_TX_FRAG_FIRST
);
438 else if (ieee80211_has_morefrags(fc
) && !ieee80211_is_first_frag(sc
))
439 val
|= FIELD_PREP(MT_TXD2_FRAG
, MT_TX_FRAG_MID
);
440 else if (!ieee80211_has_morefrags(fc
) && !ieee80211_is_first_frag(sc
))
441 val
|= FIELD_PREP(MT_TXD2_FRAG
, MT_TX_FRAG_LAST
);
443 txwi
[2] |= cpu_to_le32(val
);
445 if (ieee80211_is_beacon(fc
)) {
446 txwi
[3] &= ~cpu_to_le32(MT_TXD3_SW_POWER_MGMT
);
447 txwi
[3] |= cpu_to_le32(MT_TXD3_REM_TX_COUNT
);
450 if (info
->flags
& IEEE80211_TX_CTL_INJECTED
) {
451 u16 seqno
= le16_to_cpu(sc
);
453 if (ieee80211_is_back_req(hdr
->frame_control
)) {
454 struct ieee80211_bar
*bar
;
456 bar
= (struct ieee80211_bar
*)skb
->data
;
457 seqno
= le16_to_cpu(bar
->start_seq_num
);
460 val
= MT_TXD3_SN_VALID
|
461 FIELD_PREP(MT_TXD3_SEQ
, IEEE80211_SEQ_TO_SN(seqno
));
462 txwi
[3] |= cpu_to_le32(val
);
463 txwi
[7] &= ~cpu_to_le32(MT_TXD7_HW_AMSDU
);
466 if (mt76_is_mmio(dev
)) {
467 val
= FIELD_PREP(MT_TXD7_TYPE
, fc_type
) |
468 FIELD_PREP(MT_TXD7_SUB_TYPE
, fc_stype
);
469 txwi
[7] |= cpu_to_le32(val
);
471 val
= FIELD_PREP(MT_TXD8_L_TYPE
, fc_type
) |
472 FIELD_PREP(MT_TXD8_L_SUB_TYPE
, fc_stype
);
473 txwi
[8] |= cpu_to_le32(val
);
477 void mt76_connac2_mac_write_txwi(struct mt76_dev
*dev
, __le32
*txwi
,
478 struct sk_buff
*skb
, struct mt76_wcid
*wcid
,
479 struct ieee80211_key_conf
*key
, int pid
,
480 enum mt76_txq_id qid
, u32 changed
)
482 struct ieee80211_tx_info
*info
= IEEE80211_SKB_CB(skb
);
483 u8 phy_idx
= (info
->hw_queue
& MT_TX_HW_QUEUE_PHY
) >> 2;
484 struct ieee80211_vif
*vif
= info
->control
.vif
;
485 struct mt76_phy
*mphy
= &dev
->phy
;
486 u8 p_fmt
, q_idx
, omac_idx
= 0, wmm_idx
= 0, band_idx
= 0;
487 u32 val
, sz_txd
= mt76_is_mmio(dev
) ? MT_TXD_SIZE
: MT_SDIO_TXD_SIZE
;
488 bool is_8023
= info
->flags
& IEEE80211_TX_CTL_HW_80211_ENCAP
;
489 bool beacon
= !!(changed
& (BSS_CHANGED_BEACON
|
490 BSS_CHANGED_BEACON_ENABLED
));
491 bool inband_disc
= !!(changed
& (BSS_CHANGED_UNSOL_BCAST_PROBE_RESP
|
492 BSS_CHANGED_FILS_DISCOVERY
));
493 bool amsdu_en
= wcid
->amsdu
;
496 struct mt76_vif
*mvif
= (struct mt76_vif
*)vif
->drv_priv
;
498 omac_idx
= mvif
->omac_idx
;
499 wmm_idx
= mvif
->wmm_idx
;
500 band_idx
= mvif
->band_idx
;
503 if (phy_idx
&& dev
->phys
[MT_BAND1
])
504 mphy
= dev
->phys
[MT_BAND1
];
507 p_fmt
= MT_TX_TYPE_FW
;
508 q_idx
= MT_LMAC_ALTX0
;
510 p_fmt
= MT_TX_TYPE_FW
;
511 q_idx
= MT_LMAC_BCN0
;
512 } else if (qid
>= MT_TXQ_PSD
) {
513 p_fmt
= mt76_is_mmio(dev
) ? MT_TX_TYPE_CT
: MT_TX_TYPE_SF
;
514 q_idx
= MT_LMAC_ALTX0
;
516 p_fmt
= mt76_is_mmio(dev
) ? MT_TX_TYPE_CT
: MT_TX_TYPE_SF
;
517 q_idx
= wmm_idx
* MT76_CONNAC_MAX_WMM_SETS
+
518 mt76_connac_lmac_mapping(skb_get_queue_mapping(skb
));
520 /* mt7915 WA only counts WED path */
521 if (is_mt7915(dev
) && mtk_wed_device_active(&dev
->mmio
.wed
))
522 wcid
->stats
.tx_packets
++;
525 val
= FIELD_PREP(MT_TXD0_TX_BYTES
, skb
->len
+ sz_txd
) |
526 FIELD_PREP(MT_TXD0_PKT_FMT
, p_fmt
) |
527 FIELD_PREP(MT_TXD0_Q_IDX
, q_idx
);
528 txwi
[0] = cpu_to_le32(val
);
530 val
= MT_TXD1_LONG_FORMAT
|
531 FIELD_PREP(MT_TXD1_WLAN_IDX
, wcid
->idx
) |
532 FIELD_PREP(MT_TXD1_OWN_MAC
, omac_idx
);
535 if (phy_idx
|| band_idx
)
538 txwi
[1] = cpu_to_le32(val
);
541 val
= FIELD_PREP(MT_TXD3_REM_TX_COUNT
, 15);
543 val
|= MT_TXD3_SW_POWER_MGMT
;
545 val
|= MT_TXD3_PROTECT_FRAME
;
546 if (info
->flags
& IEEE80211_TX_CTL_NO_ACK
)
547 val
|= MT_TXD3_NO_ACK
;
549 txwi
[3] = cpu_to_le32(val
);
552 val
= FIELD_PREP(MT_TXD5_PID
, pid
);
553 if (pid
>= MT_PACKET_ID_FIRST
) {
554 val
|= MT_TXD5_TX_STATUS_HOST
;
558 txwi
[5] = cpu_to_le32(val
);
560 txwi
[7] = amsdu_en
? cpu_to_le32(MT_TXD7_HW_AMSDU
) : 0;
563 mt76_connac2_mac_write_txwi_8023(txwi
, skb
, wcid
);
565 mt76_connac2_mac_write_txwi_80211(dev
, txwi
, skb
, key
);
567 if (txwi
[2] & cpu_to_le32(MT_TXD2_FIX_RATE
)) {
568 /* Fixed rata is available just for 802.11 txd */
569 struct ieee80211_hdr
*hdr
= (struct ieee80211_hdr
*)skb
->data
;
570 bool multicast
= ieee80211_is_data(hdr
->frame_control
) &&
571 is_multicast_ether_addr(hdr
->addr1
);
572 u16 rate
= mt76_connac2_mac_tx_rate_val(mphy
, vif
, beacon
,
574 u32 val
= MT_TXD6_FIXED_BW
;
576 /* hardware won't add HTC for mgmt/ctrl frame */
577 txwi
[2] |= cpu_to_le32(MT_TXD2_HTC_VLD
);
579 val
|= FIELD_PREP(MT_TXD6_TX_RATE
, rate
);
580 txwi
[6] |= cpu_to_le32(val
);
581 txwi
[3] |= cpu_to_le32(MT_TXD3_BA_DISABLE
);
583 if (!is_mt7921(dev
)) {
584 u8 spe_idx
= mt76_connac_spe_idx(mphy
->antenna_mask
);
587 spe_idx
= 24 + phy_idx
;
588 txwi
[7] |= cpu_to_le32(FIELD_PREP(MT_TXD7_SPE_IDX
, spe_idx
));
591 txwi
[7] &= ~cpu_to_le32(MT_TXD7_HW_AMSDU
);
594 EXPORT_SYMBOL_GPL(mt76_connac2_mac_write_txwi
);
596 bool mt76_connac2_mac_fill_txs(struct mt76_dev
*dev
, struct mt76_wcid
*wcid
,
599 struct mt76_sta_stats
*stats
= &wcid
->stats
;
600 struct ieee80211_supported_band
*sband
;
601 struct mt76_phy
*mphy
;
602 struct rate_info rate
= {};
604 u32 txrate
, txs
, mode
, stbc
;
606 txs
= le32_to_cpu(txs_data
[0]);
608 /* PPDU based reporting */
609 if (mtk_wed_device_active(&dev
->mmio
.wed
) &&
610 FIELD_GET(MT_TXS0_TXS_FORMAT
, txs
) > 1) {
612 le32_get_bits(txs_data
[5], MT_TXS5_MPDU_TX_BYTE
) -
613 le32_get_bits(txs_data
[7], MT_TXS7_MPDU_RETRY_BYTE
);
615 le32_get_bits(txs_data
[6], MT_TXS6_MPDU_FAIL_CNT
);
617 le32_get_bits(txs_data
[7], MT_TXS7_MPDU_RETRY_CNT
);
620 struct ieee80211_sta
*sta
;
623 sta
= container_of((void *)wcid
, struct ieee80211_sta
,
625 tid
= FIELD_GET(MT_TXS0_TID
, txs
);
627 ieee80211_refresh_tx_agg_session_timer(sta
, tid
);
631 txrate
= FIELD_GET(MT_TXS0_TX_RATE
, txs
);
633 rate
.mcs
= FIELD_GET(MT_TX_RATE_IDX
, txrate
);
634 rate
.nss
= FIELD_GET(MT_TX_RATE_NSS
, txrate
) + 1;
635 stbc
= FIELD_GET(MT_TX_RATE_STBC
, txrate
);
637 if (stbc
&& rate
.nss
> 1)
640 if (rate
.nss
- 1 < ARRAY_SIZE(stats
->tx_nss
))
641 stats
->tx_nss
[rate
.nss
- 1]++;
642 if (rate
.mcs
< ARRAY_SIZE(stats
->tx_mcs
))
643 stats
->tx_mcs
[rate
.mcs
]++;
645 mode
= FIELD_GET(MT_TX_RATE_MODE
, txrate
);
647 case MT_PHY_TYPE_CCK
:
650 case MT_PHY_TYPE_OFDM
:
652 if (wcid
->phy_idx
== MT_BAND1
&& dev
->phys
[MT_BAND1
])
653 mphy
= dev
->phys
[MT_BAND1
];
655 if (mphy
->chandef
.chan
->band
== NL80211_BAND_5GHZ
)
656 sband
= &mphy
->sband_5g
.sband
;
657 else if (mphy
->chandef
.chan
->band
== NL80211_BAND_6GHZ
)
658 sband
= &mphy
->sband_6g
.sband
;
660 sband
= &mphy
->sband_2g
.sband
;
662 rate
.mcs
= mt76_get_rate(mphy
->dev
, sband
, rate
.mcs
, cck
);
663 rate
.legacy
= sband
->bitrates
[rate
.mcs
].bitrate
;
666 case MT_PHY_TYPE_HT_GF
:
670 rate
.flags
= RATE_INFO_FLAGS_MCS
;
671 if (wcid
->rate
.flags
& RATE_INFO_FLAGS_SHORT_GI
)
672 rate
.flags
|= RATE_INFO_FLAGS_SHORT_GI
;
674 case MT_PHY_TYPE_VHT
:
678 rate
.flags
= RATE_INFO_FLAGS_VHT_MCS
;
680 case MT_PHY_TYPE_HE_SU
:
681 case MT_PHY_TYPE_HE_EXT_SU
:
682 case MT_PHY_TYPE_HE_TB
:
683 case MT_PHY_TYPE_HE_MU
:
687 rate
.he_gi
= wcid
->rate
.he_gi
;
688 rate
.he_dcm
= FIELD_GET(MT_TX_RATE_DCM
, txrate
);
689 rate
.flags
= RATE_INFO_FLAGS_HE_MCS
;
695 stats
->tx_mode
[mode
]++;
697 switch (FIELD_GET(MT_TXS0_BW
, txs
)) {
698 case IEEE80211_STA_RX_BW_160
:
699 rate
.bw
= RATE_INFO_BW_160
;
702 case IEEE80211_STA_RX_BW_80
:
703 rate
.bw
= RATE_INFO_BW_80
;
706 case IEEE80211_STA_RX_BW_40
:
707 rate
.bw
= RATE_INFO_BW_40
;
711 rate
.bw
= RATE_INFO_BW_20
;
719 EXPORT_SYMBOL_GPL(mt76_connac2_mac_fill_txs
);
721 bool mt76_connac2_mac_add_txs_skb(struct mt76_dev
*dev
, struct mt76_wcid
*wcid
,
722 int pid
, __le32
*txs_data
)
724 struct sk_buff_head list
;
727 if (le32_get_bits(txs_data
[0], MT_TXS0_TXS_FORMAT
) == MT_TXS_PPDU_FMT
)
730 mt76_tx_status_lock(dev
, &list
);
731 skb
= mt76_tx_status_skb_get(dev
, wcid
, pid
, &list
);
733 struct ieee80211_tx_info
*info
= IEEE80211_SKB_CB(skb
);
735 if (!(le32_to_cpu(txs_data
[0]) & MT_TXS0_ACK_ERROR_MASK
))
736 info
->flags
|= IEEE80211_TX_STAT_ACK
;
738 info
->status
.ampdu_len
= 1;
739 info
->status
.ampdu_ack_len
=
740 !!(info
->flags
& IEEE80211_TX_STAT_ACK
);
741 info
->status
.rates
[0].idx
= -1;
743 mt76_connac2_mac_fill_txs(dev
, wcid
, txs_data
);
744 mt76_tx_status_skb_done(dev
, skb
, &list
);
746 mt76_tx_status_unlock(dev
, &list
);
750 EXPORT_SYMBOL_GPL(mt76_connac2_mac_add_txs_skb
);
753 mt76_connac2_mac_decode_he_radiotap_ru(struct mt76_rx_status
*status
,
754 struct ieee80211_radiotap_he
*he
,
760 ru_l
= le32_get_bits(rxv
[0], MT_PRXV_HE_RU_ALLOC_L
);
761 ru_h
= le32_get_bits(rxv
[1], MT_PRXV_HE_RU_ALLOC_H
);
762 ru
= (u8
)(ru_l
| ru_h
<< 4);
764 status
->bw
= RATE_INFO_BW_HE_RU
;
768 status
->he_ru
= NL80211_RATE_INFO_HE_RU_ALLOC_26
;
772 status
->he_ru
= NL80211_RATE_INFO_HE_RU_ALLOC_52
;
776 status
->he_ru
= NL80211_RATE_INFO_HE_RU_ALLOC_106
;
780 status
->he_ru
= NL80211_RATE_INFO_HE_RU_ALLOC_242
;
784 status
->he_ru
= NL80211_RATE_INFO_HE_RU_ALLOC_484
;
788 status
->he_ru
= NL80211_RATE_INFO_HE_RU_ALLOC_996
;
791 status
->he_ru
= NL80211_RATE_INFO_HE_RU_ALLOC_2x996
;
795 he
->data1
|= HE_BITS(DATA1_BW_RU_ALLOC_KNOWN
);
796 he
->data2
|= HE_BITS(DATA2_RU_OFFSET_KNOWN
) |
797 le16_encode_bits(offs
,
798 IEEE80211_RADIOTAP_HE_DATA2_RU_OFFSET
);
802 mt76_connac2_mac_decode_he_mu_radiotap(struct mt76_dev
*dev
, struct sk_buff
*skb
,
805 struct mt76_rx_status
*status
= (struct mt76_rx_status
*)skb
->cb
;
806 static struct ieee80211_radiotap_he_mu mu_known
= {
807 .flags1
= HE_BITS(MU_FLAGS1_SIG_B_MCS_KNOWN
) |
808 HE_BITS(MU_FLAGS1_SIG_B_DCM_KNOWN
) |
809 HE_BITS(MU_FLAGS1_CH1_RU_KNOWN
) |
810 HE_BITS(MU_FLAGS1_SIG_B_SYMS_USERS_KNOWN
),
811 .flags2
= HE_BITS(MU_FLAGS2_BW_FROM_SIG_A_BW_KNOWN
),
813 struct ieee80211_radiotap_he_mu
*he_mu
;
815 if (is_mt7921(dev
)) {
816 mu_known
.flags1
|= HE_BITS(MU_FLAGS1_SIG_B_COMP_KNOWN
);
817 mu_known
.flags2
|= HE_BITS(MU_FLAGS2_PUNC_FROM_SIG_A_BW_KNOWN
);
820 status
->flag
|= RX_FLAG_RADIOTAP_HE_MU
;
822 he_mu
= skb_push(skb
, sizeof(mu_known
));
823 memcpy(he_mu
, &mu_known
, sizeof(mu_known
));
825 #define MU_PREP(f, v) le16_encode_bits(v, IEEE80211_RADIOTAP_HE_MU_##f)
827 he_mu
->flags1
|= MU_PREP(FLAGS1_SIG_B_MCS
, status
->rate_idx
);
829 he_mu
->flags1
|= MU_PREP(FLAGS1_SIG_B_DCM
, status
->he_dcm
);
831 he_mu
->flags2
|= MU_PREP(FLAGS2_BW_FROM_SIG_A_BW
, status
->bw
) |
832 MU_PREP(FLAGS2_SIG_B_SYMS_USERS
,
833 le32_get_bits(rxv
[2], MT_CRXV_HE_NUM_USER
));
835 he_mu
->ru_ch1
[0] = le32_get_bits(rxv
[3], MT_CRXV_HE_RU0
);
837 if (status
->bw
>= RATE_INFO_BW_40
) {
838 he_mu
->flags1
|= HE_BITS(MU_FLAGS1_CH2_RU_KNOWN
);
840 le32_get_bits(rxv
[3], MT_CRXV_HE_RU1
);
843 if (status
->bw
>= RATE_INFO_BW_80
) {
845 le32_get_bits(rxv
[3], MT_CRXV_HE_RU2
);
847 le32_get_bits(rxv
[3], MT_CRXV_HE_RU3
);
851 void mt76_connac2_mac_decode_he_radiotap(struct mt76_dev
*dev
,
853 __le32
*rxv
, u32 mode
)
855 struct mt76_rx_status
*status
= (struct mt76_rx_status
*)skb
->cb
;
856 static const struct ieee80211_radiotap_he known
= {
857 .data1
= HE_BITS(DATA1_DATA_MCS_KNOWN
) |
858 HE_BITS(DATA1_DATA_DCM_KNOWN
) |
859 HE_BITS(DATA1_STBC_KNOWN
) |
860 HE_BITS(DATA1_CODING_KNOWN
) |
861 HE_BITS(DATA1_LDPC_XSYMSEG_KNOWN
) |
862 HE_BITS(DATA1_DOPPLER_KNOWN
) |
863 HE_BITS(DATA1_SPTL_REUSE_KNOWN
) |
864 HE_BITS(DATA1_BSS_COLOR_KNOWN
),
865 .data2
= HE_BITS(DATA2_GI_KNOWN
) |
866 HE_BITS(DATA2_TXBF_KNOWN
) |
867 HE_BITS(DATA2_PE_DISAMBIG_KNOWN
) |
868 HE_BITS(DATA2_TXOP_KNOWN
),
870 u32 ltf_size
= le32_get_bits(rxv
[2], MT_CRXV_HE_LTF_SIZE
) + 1;
871 struct ieee80211_radiotap_he
*he
;
873 status
->flag
|= RX_FLAG_RADIOTAP_HE
;
875 he
= skb_push(skb
, sizeof(known
));
876 memcpy(he
, &known
, sizeof(known
));
878 he
->data3
= HE_PREP(DATA3_BSS_COLOR
, BSS_COLOR
, rxv
[14]) |
879 HE_PREP(DATA3_LDPC_XSYMSEG
, LDPC_EXT_SYM
, rxv
[2]);
880 he
->data4
= HE_PREP(DATA4_SU_MU_SPTL_REUSE
, SR_MASK
, rxv
[11]);
881 he
->data5
= HE_PREP(DATA5_PE_DISAMBIG
, PE_DISAMBIG
, rxv
[2]) |
882 le16_encode_bits(ltf_size
,
883 IEEE80211_RADIOTAP_HE_DATA5_LTF_SIZE
);
884 if (le32_to_cpu(rxv
[0]) & MT_PRXV_TXBF
)
885 he
->data5
|= HE_BITS(DATA5_TXBF
);
886 he
->data6
= HE_PREP(DATA6_TXOP
, TXOP_DUR
, rxv
[14]) |
887 HE_PREP(DATA6_DOPPLER
, DOPPLER
, rxv
[14]);
890 case MT_PHY_TYPE_HE_SU
:
891 he
->data1
|= HE_BITS(DATA1_FORMAT_SU
) |
892 HE_BITS(DATA1_UL_DL_KNOWN
) |
893 HE_BITS(DATA1_BEAM_CHANGE_KNOWN
) |
894 HE_BITS(DATA1_BW_RU_ALLOC_KNOWN
);
896 he
->data3
|= HE_PREP(DATA3_BEAM_CHANGE
, BEAM_CHNG
, rxv
[14]) |
897 HE_PREP(DATA3_UL_DL
, UPLINK
, rxv
[2]);
899 case MT_PHY_TYPE_HE_EXT_SU
:
900 he
->data1
|= HE_BITS(DATA1_FORMAT_EXT_SU
) |
901 HE_BITS(DATA1_UL_DL_KNOWN
) |
902 HE_BITS(DATA1_BW_RU_ALLOC_KNOWN
);
904 he
->data3
|= HE_PREP(DATA3_UL_DL
, UPLINK
, rxv
[2]);
906 case MT_PHY_TYPE_HE_MU
:
907 he
->data1
|= HE_BITS(DATA1_FORMAT_MU
) |
908 HE_BITS(DATA1_UL_DL_KNOWN
);
910 he
->data3
|= HE_PREP(DATA3_UL_DL
, UPLINK
, rxv
[2]);
911 he
->data4
|= HE_PREP(DATA4_MU_STA_ID
, MU_AID
, rxv
[7]);
913 mt76_connac2_mac_decode_he_radiotap_ru(status
, he
, rxv
);
914 mt76_connac2_mac_decode_he_mu_radiotap(dev
, skb
, rxv
);
916 case MT_PHY_TYPE_HE_TB
:
917 he
->data1
|= HE_BITS(DATA1_FORMAT_TRIG
) |
918 HE_BITS(DATA1_SPTL_REUSE2_KNOWN
) |
919 HE_BITS(DATA1_SPTL_REUSE3_KNOWN
) |
920 HE_BITS(DATA1_SPTL_REUSE4_KNOWN
);
922 he
->data4
|= HE_PREP(DATA4_TB_SPTL_REUSE1
, SR_MASK
, rxv
[11]) |
923 HE_PREP(DATA4_TB_SPTL_REUSE2
, SR1_MASK
, rxv
[11]) |
924 HE_PREP(DATA4_TB_SPTL_REUSE3
, SR2_MASK
, rxv
[11]) |
925 HE_PREP(DATA4_TB_SPTL_REUSE4
, SR3_MASK
, rxv
[11]);
927 mt76_connac2_mac_decode_he_radiotap_ru(status
, he
, rxv
);
933 EXPORT_SYMBOL_GPL(mt76_connac2_mac_decode_he_radiotap
);
935 /* The HW does not translate the mac header to 802.3 for mesh point */
936 int mt76_connac2_reverse_frag0_hdr_trans(struct ieee80211_vif
*vif
,
937 struct sk_buff
*skb
, u16 hdr_offset
)
939 struct mt76_rx_status
*status
= (struct mt76_rx_status
*)skb
->cb
;
940 struct ethhdr
*eth_hdr
= (struct ethhdr
*)(skb
->data
+ hdr_offset
);
941 __le32
*rxd
= (__le32
*)skb
->data
;
942 struct ieee80211_sta
*sta
;
943 struct ieee80211_hdr hdr
;
946 if (le32_get_bits(rxd
[3], MT_RXD3_NORMAL_ADDR_TYPE
) !=
950 if (!(le32_to_cpu(rxd
[1]) & MT_RXD1_NORMAL_GROUP_4
))
953 sta
= container_of((void *)status
->wcid
, struct ieee80211_sta
, drv_priv
);
955 /* store the info from RXD and ethhdr to avoid being overridden */
956 frame_control
= le32_get_bits(rxd
[6], MT_RXD6_FRAME_CONTROL
);
957 hdr
.frame_control
= cpu_to_le16(frame_control
);
958 hdr
.seq_ctrl
= cpu_to_le16(le32_get_bits(rxd
[8], MT_RXD8_SEQ_CTRL
));
961 ether_addr_copy(hdr
.addr1
, vif
->addr
);
962 ether_addr_copy(hdr
.addr2
, sta
->addr
);
963 switch (frame_control
& (IEEE80211_FCTL_TODS
|
964 IEEE80211_FCTL_FROMDS
)) {
966 ether_addr_copy(hdr
.addr3
, vif
->bss_conf
.bssid
);
968 case IEEE80211_FCTL_FROMDS
:
969 ether_addr_copy(hdr
.addr3
, eth_hdr
->h_source
);
971 case IEEE80211_FCTL_TODS
:
972 ether_addr_copy(hdr
.addr3
, eth_hdr
->h_dest
);
974 case IEEE80211_FCTL_TODS
| IEEE80211_FCTL_FROMDS
:
975 ether_addr_copy(hdr
.addr3
, eth_hdr
->h_dest
);
976 ether_addr_copy(hdr
.addr4
, eth_hdr
->h_source
);
982 skb_pull(skb
, hdr_offset
+ sizeof(struct ethhdr
) - 2);
983 if (eth_hdr
->h_proto
== cpu_to_be16(ETH_P_AARP
) ||
984 eth_hdr
->h_proto
== cpu_to_be16(ETH_P_IPX
))
985 ether_addr_copy(skb_push(skb
, ETH_ALEN
), bridge_tunnel_header
);
986 else if (be16_to_cpu(eth_hdr
->h_proto
) >= ETH_P_802_3_MIN
)
987 ether_addr_copy(skb_push(skb
, ETH_ALEN
), rfc1042_header
);
991 if (ieee80211_has_order(hdr
.frame_control
))
992 memcpy(skb_push(skb
, IEEE80211_HT_CTL_LEN
), &rxd
[9],
993 IEEE80211_HT_CTL_LEN
);
994 if (ieee80211_is_data_qos(hdr
.frame_control
)) {
997 qos_ctrl
= cpu_to_le16(le32_get_bits(rxd
[8], MT_RXD8_QOS_CTL
));
998 memcpy(skb_push(skb
, IEEE80211_QOS_CTL_LEN
), &qos_ctrl
,
999 IEEE80211_QOS_CTL_LEN
);
1002 if (ieee80211_has_a4(hdr
.frame_control
))
1003 memcpy(skb_push(skb
, sizeof(hdr
)), &hdr
, sizeof(hdr
));
1005 memcpy(skb_push(skb
, sizeof(hdr
) - 6), &hdr
, sizeof(hdr
) - 6);
1009 EXPORT_SYMBOL_GPL(mt76_connac2_reverse_frag0_hdr_trans
);
1011 int mt76_connac2_mac_fill_rx_rate(struct mt76_dev
*dev
,
1012 struct mt76_rx_status
*status
,
1013 struct ieee80211_supported_band
*sband
,
1014 __le32
*rxv
, u8
*mode
)
1017 u8 stbc
, gi
, bw
, dcm
, nss
;
1021 v0
= le32_to_cpu(rxv
[0]);
1022 v2
= le32_to_cpu(rxv
[2]);
1024 idx
= i
= FIELD_GET(MT_PRXV_TX_RATE
, v0
);
1025 nss
= FIELD_GET(MT_PRXV_NSTS
, v0
) + 1;
1027 if (!is_mt7915(dev
)) {
1028 stbc
= FIELD_GET(MT_PRXV_HT_STBC
, v0
);
1029 gi
= FIELD_GET(MT_PRXV_HT_SGI
, v0
);
1030 *mode
= FIELD_GET(MT_PRXV_TX_MODE
, v0
);
1032 dcm
= !!(idx
& MT_PRXV_TX_DCM
);
1034 dcm
= FIELD_GET(MT_PRXV_DCM
, v0
);
1035 bw
= FIELD_GET(MT_PRXV_FRAME_MODE
, v0
);
1037 stbc
= FIELD_GET(MT_CRXV_HT_STBC
, v2
);
1038 gi
= FIELD_GET(MT_CRXV_HT_SHORT_GI
, v2
);
1039 *mode
= FIELD_GET(MT_CRXV_TX_MODE
, v2
);
1040 dcm
= !!(idx
& GENMASK(3, 0) & MT_PRXV_TX_DCM
);
1041 bw
= FIELD_GET(MT_CRXV_FRAME_MODE
, v2
);
1045 case MT_PHY_TYPE_CCK
:
1048 case MT_PHY_TYPE_OFDM
:
1049 i
= mt76_get_rate(dev
, sband
, i
, cck
);
1051 case MT_PHY_TYPE_HT_GF
:
1052 case MT_PHY_TYPE_HT
:
1053 status
->encoding
= RX_ENC_HT
;
1055 status
->enc_flags
|= RX_ENC_FLAG_SHORT_GI
;
1059 case MT_PHY_TYPE_VHT
:
1061 status
->encoding
= RX_ENC_VHT
;
1063 status
->enc_flags
|= RX_ENC_FLAG_SHORT_GI
;
1067 case MT_PHY_TYPE_HE_MU
:
1068 case MT_PHY_TYPE_HE_SU
:
1069 case MT_PHY_TYPE_HE_EXT_SU
:
1070 case MT_PHY_TYPE_HE_TB
:
1072 status
->encoding
= RX_ENC_HE
;
1075 if (gi
<= NL80211_RATE_INFO_HE_GI_3_2
)
1078 status
->he_dcm
= dcm
;
1083 status
->rate_idx
= i
;
1086 case IEEE80211_STA_RX_BW_20
:
1088 case IEEE80211_STA_RX_BW_40
:
1089 if (*mode
& MT_PHY_TYPE_HE_EXT_SU
&&
1090 (idx
& MT_PRXV_TX_ER_SU_106T
)) {
1091 status
->bw
= RATE_INFO_BW_HE_RU
;
1093 NL80211_RATE_INFO_HE_RU_ALLOC_106
;
1095 status
->bw
= RATE_INFO_BW_40
;
1098 case IEEE80211_STA_RX_BW_80
:
1099 status
->bw
= RATE_INFO_BW_80
;
1101 case IEEE80211_STA_RX_BW_160
:
1102 status
->bw
= RATE_INFO_BW_160
;
1108 status
->enc_flags
|= RX_ENC_FLAG_STBC_MASK
* stbc
;
1109 if (*mode
< MT_PHY_TYPE_HE_SU
&& gi
)
1110 status
->enc_flags
|= RX_ENC_FLAG_SHORT_GI
;
1114 EXPORT_SYMBOL_GPL(mt76_connac2_mac_fill_rx_rate
);
1116 void mt76_connac2_tx_check_aggr(struct ieee80211_sta
*sta
, __le32
*txwi
)
1118 struct mt76_wcid
*wcid
;
1123 !(sta
->deflink
.ht_cap
.ht_supported
|| sta
->deflink
.he_cap
.has_he
))
1126 tid
= le32_get_bits(txwi
[1], MT_TXD1_TID
);
1127 if (tid
>= 6) /* skip VO queue */
1130 val
= le32_to_cpu(txwi
[2]);
1131 fc
= FIELD_GET(MT_TXD2_FRAME_TYPE
, val
) << 2 |
1132 FIELD_GET(MT_TXD2_SUB_TYPE
, val
) << 4;
1133 if (unlikely(fc
!= (IEEE80211_FTYPE_DATA
| IEEE80211_STYPE_QOS_DATA
)))
1136 wcid
= (struct mt76_wcid
*)sta
->drv_priv
;
1137 if (!test_and_set_bit(tid
, &wcid
->ampdu_state
))
1138 ieee80211_start_tx_ba_session(sta
, tid
, 0);
1140 EXPORT_SYMBOL_GPL(mt76_connac2_tx_check_aggr
);
1142 void mt76_connac2_txwi_free(struct mt76_dev
*dev
, struct mt76_txwi_cache
*t
,
1143 struct ieee80211_sta
*sta
,
1144 struct list_head
*free_list
)
1146 struct mt76_wcid
*wcid
;
1150 mt76_connac_txp_skb_unmap(dev
, t
);
1154 txwi
= (__le32
*)mt76_get_txwi_ptr(dev
, t
);
1156 wcid
= (struct mt76_wcid
*)sta
->drv_priv
;
1157 wcid_idx
= wcid
->idx
;
1159 wcid_idx
= le32_get_bits(txwi
[1], MT_TXD1_WLAN_IDX
);
1160 wcid
= rcu_dereference(dev
->wcid
[wcid_idx
]);
1162 if (wcid
&& wcid
->sta
) {
1163 sta
= container_of((void *)wcid
, struct ieee80211_sta
,
1165 spin_lock_bh(&dev
->sta_poll_lock
);
1166 if (list_empty(&wcid
->poll_list
))
1167 list_add_tail(&wcid
->poll_list
,
1168 &dev
->sta_poll_list
);
1169 spin_unlock_bh(&dev
->sta_poll_lock
);
1173 if (sta
&& likely(t
->skb
->protocol
!= cpu_to_be16(ETH_P_PAE
)))
1174 mt76_connac2_tx_check_aggr(sta
, txwi
);
1176 __mt76_tx_complete_skb(dev
, wcid_idx
, t
->skb
, free_list
);
1179 mt76_put_txwi(dev
, t
);
1181 EXPORT_SYMBOL_GPL(mt76_connac2_txwi_free
);
1183 void mt76_connac2_tx_token_put(struct mt76_dev
*dev
)
1185 struct mt76_txwi_cache
*txwi
;
1188 spin_lock_bh(&dev
->token_lock
);
1189 idr_for_each_entry(&dev
->token
, txwi
, id
) {
1190 mt76_connac2_txwi_free(dev
, txwi
, NULL
, NULL
);
1193 spin_unlock_bh(&dev
->token_lock
);
1194 idr_destroy(&dev
->token
);
1196 EXPORT_SYMBOL_GPL(mt76_connac2_tx_token_put
);