18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause
28c2ecf20Sopenharmony_ci/* Copyright(c) 2018-2019  Realtek Corporation
38c2ecf20Sopenharmony_ci */
48c2ecf20Sopenharmony_ci
58c2ecf20Sopenharmony_ci#include "main.h"
68c2ecf20Sopenharmony_ci#include "tx.h"
78c2ecf20Sopenharmony_ci#include "fw.h"
88c2ecf20Sopenharmony_ci#include "ps.h"
98c2ecf20Sopenharmony_ci#include "debug.h"
108c2ecf20Sopenharmony_ci
118c2ecf20Sopenharmony_cistatic
128c2ecf20Sopenharmony_civoid rtw_tx_stats(struct rtw_dev *rtwdev, struct ieee80211_vif *vif,
138c2ecf20Sopenharmony_ci		  struct sk_buff *skb)
148c2ecf20Sopenharmony_ci{
158c2ecf20Sopenharmony_ci	struct ieee80211_hdr *hdr;
168c2ecf20Sopenharmony_ci	struct rtw_vif *rtwvif;
178c2ecf20Sopenharmony_ci
188c2ecf20Sopenharmony_ci	hdr = (struct ieee80211_hdr *)skb->data;
198c2ecf20Sopenharmony_ci
208c2ecf20Sopenharmony_ci	if (!ieee80211_is_data(hdr->frame_control))
218c2ecf20Sopenharmony_ci		return;
228c2ecf20Sopenharmony_ci
238c2ecf20Sopenharmony_ci	if (!is_broadcast_ether_addr(hdr->addr1) &&
248c2ecf20Sopenharmony_ci	    !is_multicast_ether_addr(hdr->addr1)) {
258c2ecf20Sopenharmony_ci		rtwdev->stats.tx_unicast += skb->len;
268c2ecf20Sopenharmony_ci		rtwdev->stats.tx_cnt++;
278c2ecf20Sopenharmony_ci		if (vif) {
288c2ecf20Sopenharmony_ci			rtwvif = (struct rtw_vif *)vif->drv_priv;
298c2ecf20Sopenharmony_ci			rtwvif->stats.tx_unicast += skb->len;
308c2ecf20Sopenharmony_ci			rtwvif->stats.tx_cnt++;
318c2ecf20Sopenharmony_ci		}
328c2ecf20Sopenharmony_ci	}
338c2ecf20Sopenharmony_ci}
348c2ecf20Sopenharmony_ci
358c2ecf20Sopenharmony_civoid rtw_tx_fill_tx_desc(struct rtw_tx_pkt_info *pkt_info, struct sk_buff *skb)
368c2ecf20Sopenharmony_ci{
378c2ecf20Sopenharmony_ci	__le32 *txdesc = (__le32 *)skb->data;
388c2ecf20Sopenharmony_ci
398c2ecf20Sopenharmony_ci	SET_TX_DESC_TXPKTSIZE(txdesc,  pkt_info->tx_pkt_size);
408c2ecf20Sopenharmony_ci	SET_TX_DESC_OFFSET(txdesc, pkt_info->offset);
418c2ecf20Sopenharmony_ci	SET_TX_DESC_PKT_OFFSET(txdesc, pkt_info->pkt_offset);
428c2ecf20Sopenharmony_ci	SET_TX_DESC_QSEL(txdesc, pkt_info->qsel);
438c2ecf20Sopenharmony_ci	SET_TX_DESC_BMC(txdesc, pkt_info->bmc);
448c2ecf20Sopenharmony_ci	SET_TX_DESC_RATE_ID(txdesc, pkt_info->rate_id);
458c2ecf20Sopenharmony_ci	SET_TX_DESC_DATARATE(txdesc, pkt_info->rate);
468c2ecf20Sopenharmony_ci	SET_TX_DESC_DISDATAFB(txdesc, pkt_info->dis_rate_fallback);
478c2ecf20Sopenharmony_ci	SET_TX_DESC_USE_RATE(txdesc, pkt_info->use_rate);
488c2ecf20Sopenharmony_ci	SET_TX_DESC_SEC_TYPE(txdesc, pkt_info->sec_type);
498c2ecf20Sopenharmony_ci	SET_TX_DESC_DATA_BW(txdesc, pkt_info->bw);
508c2ecf20Sopenharmony_ci	SET_TX_DESC_SW_SEQ(txdesc, pkt_info->seq);
518c2ecf20Sopenharmony_ci	SET_TX_DESC_MAX_AGG_NUM(txdesc, pkt_info->ampdu_factor);
528c2ecf20Sopenharmony_ci	SET_TX_DESC_AMPDU_DENSITY(txdesc, pkt_info->ampdu_density);
538c2ecf20Sopenharmony_ci	SET_TX_DESC_DATA_STBC(txdesc, pkt_info->stbc);
548c2ecf20Sopenharmony_ci	SET_TX_DESC_DATA_LDPC(txdesc, pkt_info->ldpc);
558c2ecf20Sopenharmony_ci	SET_TX_DESC_AGG_EN(txdesc, pkt_info->ampdu_en);
568c2ecf20Sopenharmony_ci	SET_TX_DESC_LS(txdesc, pkt_info->ls);
578c2ecf20Sopenharmony_ci	SET_TX_DESC_DATA_SHORT(txdesc, pkt_info->short_gi);
588c2ecf20Sopenharmony_ci	SET_TX_DESC_SPE_RPT(txdesc, pkt_info->report);
598c2ecf20Sopenharmony_ci	SET_TX_DESC_SW_DEFINE(txdesc, pkt_info->sn);
608c2ecf20Sopenharmony_ci	SET_TX_DESC_USE_RTS(txdesc, pkt_info->rts);
618c2ecf20Sopenharmony_ci	SET_TX_DESC_DISQSELSEQ(txdesc, pkt_info->dis_qselseq);
628c2ecf20Sopenharmony_ci	SET_TX_DESC_EN_HWSEQ(txdesc, pkt_info->en_hwseq);
638c2ecf20Sopenharmony_ci	SET_TX_DESC_HW_SSN_SEL(txdesc, pkt_info->hw_ssn_sel);
648c2ecf20Sopenharmony_ci	SET_TX_DESC_NAVUSEHDR(txdesc, pkt_info->nav_use_hdr);
658c2ecf20Sopenharmony_ci	SET_TX_DESC_BT_NULL(txdesc, pkt_info->bt_null);
668c2ecf20Sopenharmony_ci}
678c2ecf20Sopenharmony_ciEXPORT_SYMBOL(rtw_tx_fill_tx_desc);
688c2ecf20Sopenharmony_ci
698c2ecf20Sopenharmony_cistatic u8 get_tx_ampdu_factor(struct ieee80211_sta *sta)
708c2ecf20Sopenharmony_ci{
718c2ecf20Sopenharmony_ci	u8 exp = sta->ht_cap.ampdu_factor;
728c2ecf20Sopenharmony_ci
738c2ecf20Sopenharmony_ci	/* the least ampdu factor is 8K, and the value in the tx desc is the
748c2ecf20Sopenharmony_ci	 * max aggregation num, which represents val * 2 packets can be
758c2ecf20Sopenharmony_ci	 * aggregated in an AMPDU, so here we should use 8/2=4 as the base
768c2ecf20Sopenharmony_ci	 */
778c2ecf20Sopenharmony_ci	return (BIT(2) << exp) - 1;
788c2ecf20Sopenharmony_ci}
798c2ecf20Sopenharmony_ci
808c2ecf20Sopenharmony_cistatic u8 get_tx_ampdu_density(struct ieee80211_sta *sta)
818c2ecf20Sopenharmony_ci{
828c2ecf20Sopenharmony_ci	return sta->ht_cap.ampdu_density;
838c2ecf20Sopenharmony_ci}
848c2ecf20Sopenharmony_ci
858c2ecf20Sopenharmony_cistatic u8 get_highest_ht_tx_rate(struct rtw_dev *rtwdev,
868c2ecf20Sopenharmony_ci				 struct ieee80211_sta *sta)
878c2ecf20Sopenharmony_ci{
888c2ecf20Sopenharmony_ci	u8 rate;
898c2ecf20Sopenharmony_ci
908c2ecf20Sopenharmony_ci	if (rtwdev->hal.rf_type == RF_2T2R && sta->ht_cap.mcs.rx_mask[1] != 0)
918c2ecf20Sopenharmony_ci		rate = DESC_RATEMCS15;
928c2ecf20Sopenharmony_ci	else
938c2ecf20Sopenharmony_ci		rate = DESC_RATEMCS7;
948c2ecf20Sopenharmony_ci
958c2ecf20Sopenharmony_ci	return rate;
968c2ecf20Sopenharmony_ci}
978c2ecf20Sopenharmony_ci
988c2ecf20Sopenharmony_cistatic u8 get_highest_vht_tx_rate(struct rtw_dev *rtwdev,
998c2ecf20Sopenharmony_ci				  struct ieee80211_sta *sta)
1008c2ecf20Sopenharmony_ci{
1018c2ecf20Sopenharmony_ci	struct rtw_efuse *efuse = &rtwdev->efuse;
1028c2ecf20Sopenharmony_ci	u8 rate;
1038c2ecf20Sopenharmony_ci	u16 tx_mcs_map;
1048c2ecf20Sopenharmony_ci
1058c2ecf20Sopenharmony_ci	tx_mcs_map = le16_to_cpu(sta->vht_cap.vht_mcs.tx_mcs_map);
1068c2ecf20Sopenharmony_ci	if (efuse->hw_cap.nss == 1) {
1078c2ecf20Sopenharmony_ci		switch (tx_mcs_map & 0x3) {
1088c2ecf20Sopenharmony_ci		case IEEE80211_VHT_MCS_SUPPORT_0_7:
1098c2ecf20Sopenharmony_ci			rate = DESC_RATEVHT1SS_MCS7;
1108c2ecf20Sopenharmony_ci			break;
1118c2ecf20Sopenharmony_ci		case IEEE80211_VHT_MCS_SUPPORT_0_8:
1128c2ecf20Sopenharmony_ci			rate = DESC_RATEVHT1SS_MCS8;
1138c2ecf20Sopenharmony_ci			break;
1148c2ecf20Sopenharmony_ci		default:
1158c2ecf20Sopenharmony_ci		case IEEE80211_VHT_MCS_SUPPORT_0_9:
1168c2ecf20Sopenharmony_ci			rate = DESC_RATEVHT1SS_MCS9;
1178c2ecf20Sopenharmony_ci			break;
1188c2ecf20Sopenharmony_ci		}
1198c2ecf20Sopenharmony_ci	} else if (efuse->hw_cap.nss >= 2) {
1208c2ecf20Sopenharmony_ci		switch ((tx_mcs_map & 0xc) >> 2) {
1218c2ecf20Sopenharmony_ci		case IEEE80211_VHT_MCS_SUPPORT_0_7:
1228c2ecf20Sopenharmony_ci			rate = DESC_RATEVHT2SS_MCS7;
1238c2ecf20Sopenharmony_ci			break;
1248c2ecf20Sopenharmony_ci		case IEEE80211_VHT_MCS_SUPPORT_0_8:
1258c2ecf20Sopenharmony_ci			rate = DESC_RATEVHT2SS_MCS8;
1268c2ecf20Sopenharmony_ci			break;
1278c2ecf20Sopenharmony_ci		default:
1288c2ecf20Sopenharmony_ci		case IEEE80211_VHT_MCS_SUPPORT_0_9:
1298c2ecf20Sopenharmony_ci			rate = DESC_RATEVHT2SS_MCS9;
1308c2ecf20Sopenharmony_ci			break;
1318c2ecf20Sopenharmony_ci		}
1328c2ecf20Sopenharmony_ci	} else {
1338c2ecf20Sopenharmony_ci		rate = DESC_RATEVHT1SS_MCS9;
1348c2ecf20Sopenharmony_ci	}
1358c2ecf20Sopenharmony_ci
1368c2ecf20Sopenharmony_ci	return rate;
1378c2ecf20Sopenharmony_ci}
1388c2ecf20Sopenharmony_ci
1398c2ecf20Sopenharmony_cistatic void rtw_tx_report_enable(struct rtw_dev *rtwdev,
1408c2ecf20Sopenharmony_ci				 struct rtw_tx_pkt_info *pkt_info)
1418c2ecf20Sopenharmony_ci{
1428c2ecf20Sopenharmony_ci	struct rtw_tx_report *tx_report = &rtwdev->tx_report;
1438c2ecf20Sopenharmony_ci
1448c2ecf20Sopenharmony_ci	/* [11:8], reserved, fills with zero
1458c2ecf20Sopenharmony_ci	 * [7:2],  tx report sequence number
1468c2ecf20Sopenharmony_ci	 * [1:0],  firmware use, fills with zero
1478c2ecf20Sopenharmony_ci	 */
1488c2ecf20Sopenharmony_ci	pkt_info->sn = (atomic_inc_return(&tx_report->sn) << 2) & 0xfc;
1498c2ecf20Sopenharmony_ci	pkt_info->report = true;
1508c2ecf20Sopenharmony_ci}
1518c2ecf20Sopenharmony_ci
1528c2ecf20Sopenharmony_civoid rtw_tx_report_purge_timer(struct timer_list *t)
1538c2ecf20Sopenharmony_ci{
1548c2ecf20Sopenharmony_ci	struct rtw_dev *rtwdev = from_timer(rtwdev, t, tx_report.purge_timer);
1558c2ecf20Sopenharmony_ci	struct rtw_tx_report *tx_report = &rtwdev->tx_report;
1568c2ecf20Sopenharmony_ci	unsigned long flags;
1578c2ecf20Sopenharmony_ci
1588c2ecf20Sopenharmony_ci	if (skb_queue_len(&tx_report->queue) == 0)
1598c2ecf20Sopenharmony_ci		return;
1608c2ecf20Sopenharmony_ci
1618c2ecf20Sopenharmony_ci	WARN(1, "purge skb(s) not reported by firmware\n");
1628c2ecf20Sopenharmony_ci
1638c2ecf20Sopenharmony_ci	spin_lock_irqsave(&tx_report->q_lock, flags);
1648c2ecf20Sopenharmony_ci	skb_queue_purge(&tx_report->queue);
1658c2ecf20Sopenharmony_ci	spin_unlock_irqrestore(&tx_report->q_lock, flags);
1668c2ecf20Sopenharmony_ci}
1678c2ecf20Sopenharmony_ci
1688c2ecf20Sopenharmony_civoid rtw_tx_report_enqueue(struct rtw_dev *rtwdev, struct sk_buff *skb, u8 sn)
1698c2ecf20Sopenharmony_ci{
1708c2ecf20Sopenharmony_ci	struct rtw_tx_report *tx_report = &rtwdev->tx_report;
1718c2ecf20Sopenharmony_ci	unsigned long flags;
1728c2ecf20Sopenharmony_ci	u8 *drv_data;
1738c2ecf20Sopenharmony_ci
1748c2ecf20Sopenharmony_ci	/* pass sn to tx report handler through driver data */
1758c2ecf20Sopenharmony_ci	drv_data = (u8 *)IEEE80211_SKB_CB(skb)->status.status_driver_data;
1768c2ecf20Sopenharmony_ci	*drv_data = sn;
1778c2ecf20Sopenharmony_ci
1788c2ecf20Sopenharmony_ci	spin_lock_irqsave(&tx_report->q_lock, flags);
1798c2ecf20Sopenharmony_ci	__skb_queue_tail(&tx_report->queue, skb);
1808c2ecf20Sopenharmony_ci	spin_unlock_irqrestore(&tx_report->q_lock, flags);
1818c2ecf20Sopenharmony_ci
1828c2ecf20Sopenharmony_ci	mod_timer(&tx_report->purge_timer, jiffies + RTW_TX_PROBE_TIMEOUT);
1838c2ecf20Sopenharmony_ci}
1848c2ecf20Sopenharmony_ciEXPORT_SYMBOL(rtw_tx_report_enqueue);
1858c2ecf20Sopenharmony_ci
1868c2ecf20Sopenharmony_cistatic void rtw_tx_report_tx_status(struct rtw_dev *rtwdev,
1878c2ecf20Sopenharmony_ci				    struct sk_buff *skb, bool acked)
1888c2ecf20Sopenharmony_ci{
1898c2ecf20Sopenharmony_ci	struct ieee80211_tx_info *info;
1908c2ecf20Sopenharmony_ci
1918c2ecf20Sopenharmony_ci	info = IEEE80211_SKB_CB(skb);
1928c2ecf20Sopenharmony_ci	ieee80211_tx_info_clear_status(info);
1938c2ecf20Sopenharmony_ci	if (acked)
1948c2ecf20Sopenharmony_ci		info->flags |= IEEE80211_TX_STAT_ACK;
1958c2ecf20Sopenharmony_ci	else
1968c2ecf20Sopenharmony_ci		info->flags &= ~IEEE80211_TX_STAT_ACK;
1978c2ecf20Sopenharmony_ci
1988c2ecf20Sopenharmony_ci	ieee80211_tx_status_irqsafe(rtwdev->hw, skb);
1998c2ecf20Sopenharmony_ci}
2008c2ecf20Sopenharmony_ci
2018c2ecf20Sopenharmony_civoid rtw_tx_report_handle(struct rtw_dev *rtwdev, struct sk_buff *skb, int src)
2028c2ecf20Sopenharmony_ci{
2038c2ecf20Sopenharmony_ci	struct rtw_tx_report *tx_report = &rtwdev->tx_report;
2048c2ecf20Sopenharmony_ci	struct rtw_c2h_cmd *c2h;
2058c2ecf20Sopenharmony_ci	struct sk_buff *cur, *tmp;
2068c2ecf20Sopenharmony_ci	unsigned long flags;
2078c2ecf20Sopenharmony_ci	u8 sn, st;
2088c2ecf20Sopenharmony_ci	u8 *n;
2098c2ecf20Sopenharmony_ci
2108c2ecf20Sopenharmony_ci	c2h = get_c2h_from_skb(skb);
2118c2ecf20Sopenharmony_ci
2128c2ecf20Sopenharmony_ci	if (src == C2H_CCX_TX_RPT) {
2138c2ecf20Sopenharmony_ci		sn = GET_CCX_REPORT_SEQNUM_V0(c2h->payload);
2148c2ecf20Sopenharmony_ci		st = GET_CCX_REPORT_STATUS_V0(c2h->payload);
2158c2ecf20Sopenharmony_ci	} else {
2168c2ecf20Sopenharmony_ci		sn = GET_CCX_REPORT_SEQNUM_V1(c2h->payload);
2178c2ecf20Sopenharmony_ci		st = GET_CCX_REPORT_STATUS_V1(c2h->payload);
2188c2ecf20Sopenharmony_ci	}
2198c2ecf20Sopenharmony_ci
2208c2ecf20Sopenharmony_ci	spin_lock_irqsave(&tx_report->q_lock, flags);
2218c2ecf20Sopenharmony_ci	skb_queue_walk_safe(&tx_report->queue, cur, tmp) {
2228c2ecf20Sopenharmony_ci		n = (u8 *)IEEE80211_SKB_CB(cur)->status.status_driver_data;
2238c2ecf20Sopenharmony_ci		if (*n == sn) {
2248c2ecf20Sopenharmony_ci			__skb_unlink(cur, &tx_report->queue);
2258c2ecf20Sopenharmony_ci			rtw_tx_report_tx_status(rtwdev, cur, st == 0);
2268c2ecf20Sopenharmony_ci			break;
2278c2ecf20Sopenharmony_ci		}
2288c2ecf20Sopenharmony_ci	}
2298c2ecf20Sopenharmony_ci	spin_unlock_irqrestore(&tx_report->q_lock, flags);
2308c2ecf20Sopenharmony_ci}
2318c2ecf20Sopenharmony_ci
2328c2ecf20Sopenharmony_cistatic void rtw_tx_pkt_info_update_rate(struct rtw_dev *rtwdev,
2338c2ecf20Sopenharmony_ci					struct rtw_tx_pkt_info *pkt_info,
2348c2ecf20Sopenharmony_ci					struct sk_buff *skb)
2358c2ecf20Sopenharmony_ci{
2368c2ecf20Sopenharmony_ci	if (rtwdev->hal.current_band_type == RTW_BAND_2G) {
2378c2ecf20Sopenharmony_ci		pkt_info->rate_id = RTW_RATEID_B_20M;
2388c2ecf20Sopenharmony_ci		pkt_info->rate = DESC_RATE1M;
2398c2ecf20Sopenharmony_ci	} else {
2408c2ecf20Sopenharmony_ci		pkt_info->rate_id = RTW_RATEID_G;
2418c2ecf20Sopenharmony_ci		pkt_info->rate = DESC_RATE6M;
2428c2ecf20Sopenharmony_ci	}
2438c2ecf20Sopenharmony_ci	pkt_info->use_rate = true;
2448c2ecf20Sopenharmony_ci	pkt_info->dis_rate_fallback = true;
2458c2ecf20Sopenharmony_ci}
2468c2ecf20Sopenharmony_ci
2478c2ecf20Sopenharmony_cistatic void rtw_tx_pkt_info_update_sec(struct rtw_dev *rtwdev,
2488c2ecf20Sopenharmony_ci				       struct rtw_tx_pkt_info *pkt_info,
2498c2ecf20Sopenharmony_ci				       struct sk_buff *skb)
2508c2ecf20Sopenharmony_ci{
2518c2ecf20Sopenharmony_ci	struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
2528c2ecf20Sopenharmony_ci	u8 sec_type = 0;
2538c2ecf20Sopenharmony_ci
2548c2ecf20Sopenharmony_ci	if (info && info->control.hw_key) {
2558c2ecf20Sopenharmony_ci		struct ieee80211_key_conf *key = info->control.hw_key;
2568c2ecf20Sopenharmony_ci
2578c2ecf20Sopenharmony_ci		switch (key->cipher) {
2588c2ecf20Sopenharmony_ci		case WLAN_CIPHER_SUITE_WEP40:
2598c2ecf20Sopenharmony_ci		case WLAN_CIPHER_SUITE_WEP104:
2608c2ecf20Sopenharmony_ci		case WLAN_CIPHER_SUITE_TKIP:
2618c2ecf20Sopenharmony_ci			sec_type = 0x01;
2628c2ecf20Sopenharmony_ci			break;
2638c2ecf20Sopenharmony_ci		case WLAN_CIPHER_SUITE_CCMP:
2648c2ecf20Sopenharmony_ci			sec_type = 0x03;
2658c2ecf20Sopenharmony_ci			break;
2668c2ecf20Sopenharmony_ci		default:
2678c2ecf20Sopenharmony_ci			break;
2688c2ecf20Sopenharmony_ci		}
2698c2ecf20Sopenharmony_ci	}
2708c2ecf20Sopenharmony_ci
2718c2ecf20Sopenharmony_ci	pkt_info->sec_type = sec_type;
2728c2ecf20Sopenharmony_ci}
2738c2ecf20Sopenharmony_ci
2748c2ecf20Sopenharmony_cistatic void rtw_tx_mgmt_pkt_info_update(struct rtw_dev *rtwdev,
2758c2ecf20Sopenharmony_ci					struct rtw_tx_pkt_info *pkt_info,
2768c2ecf20Sopenharmony_ci					struct ieee80211_sta *sta,
2778c2ecf20Sopenharmony_ci					struct sk_buff *skb)
2788c2ecf20Sopenharmony_ci{
2798c2ecf20Sopenharmony_ci	rtw_tx_pkt_info_update_rate(rtwdev, pkt_info, skb);
2808c2ecf20Sopenharmony_ci	pkt_info->dis_qselseq = true;
2818c2ecf20Sopenharmony_ci	pkt_info->en_hwseq = true;
2828c2ecf20Sopenharmony_ci	pkt_info->hw_ssn_sel = 0;
2838c2ecf20Sopenharmony_ci	/* TODO: need to change hw port and hw ssn sel for multiple vifs */
2848c2ecf20Sopenharmony_ci}
2858c2ecf20Sopenharmony_ci
2868c2ecf20Sopenharmony_cistatic void rtw_tx_data_pkt_info_update(struct rtw_dev *rtwdev,
2878c2ecf20Sopenharmony_ci					struct rtw_tx_pkt_info *pkt_info,
2888c2ecf20Sopenharmony_ci					struct ieee80211_sta *sta,
2898c2ecf20Sopenharmony_ci					struct sk_buff *skb)
2908c2ecf20Sopenharmony_ci{
2918c2ecf20Sopenharmony_ci	struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
2928c2ecf20Sopenharmony_ci	struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
2938c2ecf20Sopenharmony_ci	struct rtw_sta_info *si;
2948c2ecf20Sopenharmony_ci	u16 seq;
2958c2ecf20Sopenharmony_ci	u8 ampdu_factor = 0;
2968c2ecf20Sopenharmony_ci	u8 ampdu_density = 0;
2978c2ecf20Sopenharmony_ci	bool ampdu_en = false;
2988c2ecf20Sopenharmony_ci	u8 rate = DESC_RATE6M;
2998c2ecf20Sopenharmony_ci	u8 rate_id = 6;
3008c2ecf20Sopenharmony_ci	u8 bw = RTW_CHANNEL_WIDTH_20;
3018c2ecf20Sopenharmony_ci	bool stbc = false;
3028c2ecf20Sopenharmony_ci	bool ldpc = false;
3038c2ecf20Sopenharmony_ci
3048c2ecf20Sopenharmony_ci	seq = (le16_to_cpu(hdr->seq_ctrl) & IEEE80211_SCTL_SEQ) >> 4;
3058c2ecf20Sopenharmony_ci
3068c2ecf20Sopenharmony_ci	/* for broadcast/multicast, use default values */
3078c2ecf20Sopenharmony_ci	if (!sta)
3088c2ecf20Sopenharmony_ci		goto out;
3098c2ecf20Sopenharmony_ci
3108c2ecf20Sopenharmony_ci	if (info->flags & IEEE80211_TX_CTL_AMPDU) {
3118c2ecf20Sopenharmony_ci		ampdu_en = true;
3128c2ecf20Sopenharmony_ci		ampdu_factor = get_tx_ampdu_factor(sta);
3138c2ecf20Sopenharmony_ci		ampdu_density = get_tx_ampdu_density(sta);
3148c2ecf20Sopenharmony_ci	}
3158c2ecf20Sopenharmony_ci
3168c2ecf20Sopenharmony_ci	if (info->control.use_rts)
3178c2ecf20Sopenharmony_ci		pkt_info->rts = true;
3188c2ecf20Sopenharmony_ci
3198c2ecf20Sopenharmony_ci	if (sta->vht_cap.vht_supported)
3208c2ecf20Sopenharmony_ci		rate = get_highest_vht_tx_rate(rtwdev, sta);
3218c2ecf20Sopenharmony_ci	else if (sta->ht_cap.ht_supported)
3228c2ecf20Sopenharmony_ci		rate = get_highest_ht_tx_rate(rtwdev, sta);
3238c2ecf20Sopenharmony_ci	else if (sta->supp_rates[0] <= 0xf)
3248c2ecf20Sopenharmony_ci		rate = DESC_RATE11M;
3258c2ecf20Sopenharmony_ci	else
3268c2ecf20Sopenharmony_ci		rate = DESC_RATE54M;
3278c2ecf20Sopenharmony_ci
3288c2ecf20Sopenharmony_ci	si = (struct rtw_sta_info *)sta->drv_priv;
3298c2ecf20Sopenharmony_ci
3308c2ecf20Sopenharmony_ci	bw = si->bw_mode;
3318c2ecf20Sopenharmony_ci	rate_id = si->rate_id;
3328c2ecf20Sopenharmony_ci	stbc = si->stbc_en;
3338c2ecf20Sopenharmony_ci	ldpc = si->ldpc_en;
3348c2ecf20Sopenharmony_ci
3358c2ecf20Sopenharmony_ciout:
3368c2ecf20Sopenharmony_ci	pkt_info->seq = seq;
3378c2ecf20Sopenharmony_ci	pkt_info->ampdu_factor = ampdu_factor;
3388c2ecf20Sopenharmony_ci	pkt_info->ampdu_density = ampdu_density;
3398c2ecf20Sopenharmony_ci	pkt_info->ampdu_en = ampdu_en;
3408c2ecf20Sopenharmony_ci	pkt_info->rate = rate;
3418c2ecf20Sopenharmony_ci	pkt_info->rate_id = rate_id;
3428c2ecf20Sopenharmony_ci	pkt_info->bw = bw;
3438c2ecf20Sopenharmony_ci	pkt_info->stbc = stbc;
3448c2ecf20Sopenharmony_ci	pkt_info->ldpc = ldpc;
3458c2ecf20Sopenharmony_ci}
3468c2ecf20Sopenharmony_ci
3478c2ecf20Sopenharmony_civoid rtw_tx_pkt_info_update(struct rtw_dev *rtwdev,
3488c2ecf20Sopenharmony_ci			    struct rtw_tx_pkt_info *pkt_info,
3498c2ecf20Sopenharmony_ci			    struct ieee80211_sta *sta,
3508c2ecf20Sopenharmony_ci			    struct sk_buff *skb)
3518c2ecf20Sopenharmony_ci{
3528c2ecf20Sopenharmony_ci	struct rtw_chip_info *chip = rtwdev->chip;
3538c2ecf20Sopenharmony_ci	struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
3548c2ecf20Sopenharmony_ci	struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
3558c2ecf20Sopenharmony_ci	struct rtw_sta_info *si;
3568c2ecf20Sopenharmony_ci	struct ieee80211_vif *vif = NULL;
3578c2ecf20Sopenharmony_ci	__le16 fc = hdr->frame_control;
3588c2ecf20Sopenharmony_ci	bool bmc;
3598c2ecf20Sopenharmony_ci
3608c2ecf20Sopenharmony_ci	if (sta) {
3618c2ecf20Sopenharmony_ci		si = (struct rtw_sta_info *)sta->drv_priv;
3628c2ecf20Sopenharmony_ci		vif = si->vif;
3638c2ecf20Sopenharmony_ci	}
3648c2ecf20Sopenharmony_ci
3658c2ecf20Sopenharmony_ci	if (ieee80211_is_mgmt(fc) || ieee80211_is_nullfunc(fc))
3668c2ecf20Sopenharmony_ci		rtw_tx_mgmt_pkt_info_update(rtwdev, pkt_info, sta, skb);
3678c2ecf20Sopenharmony_ci	else if (ieee80211_is_data(fc))
3688c2ecf20Sopenharmony_ci		rtw_tx_data_pkt_info_update(rtwdev, pkt_info, sta, skb);
3698c2ecf20Sopenharmony_ci
3708c2ecf20Sopenharmony_ci	bmc = is_broadcast_ether_addr(hdr->addr1) ||
3718c2ecf20Sopenharmony_ci	      is_multicast_ether_addr(hdr->addr1);
3728c2ecf20Sopenharmony_ci
3738c2ecf20Sopenharmony_ci	if (info->flags & IEEE80211_TX_CTL_REQ_TX_STATUS)
3748c2ecf20Sopenharmony_ci		rtw_tx_report_enable(rtwdev, pkt_info);
3758c2ecf20Sopenharmony_ci
3768c2ecf20Sopenharmony_ci	pkt_info->bmc = bmc;
3778c2ecf20Sopenharmony_ci	rtw_tx_pkt_info_update_sec(rtwdev, pkt_info, skb);
3788c2ecf20Sopenharmony_ci	pkt_info->tx_pkt_size = skb->len;
3798c2ecf20Sopenharmony_ci	pkt_info->offset = chip->tx_pkt_desc_sz;
3808c2ecf20Sopenharmony_ci	pkt_info->qsel = skb->priority;
3818c2ecf20Sopenharmony_ci	pkt_info->ls = true;
3828c2ecf20Sopenharmony_ci
3838c2ecf20Sopenharmony_ci	/* maybe merge with tx status ? */
3848c2ecf20Sopenharmony_ci	rtw_tx_stats(rtwdev, vif, skb);
3858c2ecf20Sopenharmony_ci}
3868c2ecf20Sopenharmony_ci
3878c2ecf20Sopenharmony_civoid rtw_tx_rsvd_page_pkt_info_update(struct rtw_dev *rtwdev,
3888c2ecf20Sopenharmony_ci				      struct rtw_tx_pkt_info *pkt_info,
3898c2ecf20Sopenharmony_ci				      struct sk_buff *skb,
3908c2ecf20Sopenharmony_ci				      enum rtw_rsvd_packet_type type)
3918c2ecf20Sopenharmony_ci{
3928c2ecf20Sopenharmony_ci	struct rtw_chip_info *chip = rtwdev->chip;
3938c2ecf20Sopenharmony_ci	struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
3948c2ecf20Sopenharmony_ci	bool bmc;
3958c2ecf20Sopenharmony_ci
3968c2ecf20Sopenharmony_ci	/* A beacon or dummy reserved page packet indicates that it is the first
3978c2ecf20Sopenharmony_ci	 * reserved page, and the qsel of it will be set in each hci.
3988c2ecf20Sopenharmony_ci	 */
3998c2ecf20Sopenharmony_ci	if (type != RSVD_BEACON && type != RSVD_DUMMY)
4008c2ecf20Sopenharmony_ci		pkt_info->qsel = TX_DESC_QSEL_MGMT;
4018c2ecf20Sopenharmony_ci
4028c2ecf20Sopenharmony_ci	rtw_tx_pkt_info_update_rate(rtwdev, pkt_info, skb);
4038c2ecf20Sopenharmony_ci
4048c2ecf20Sopenharmony_ci	bmc = is_broadcast_ether_addr(hdr->addr1) ||
4058c2ecf20Sopenharmony_ci	      is_multicast_ether_addr(hdr->addr1);
4068c2ecf20Sopenharmony_ci	pkt_info->bmc = bmc;
4078c2ecf20Sopenharmony_ci	pkt_info->tx_pkt_size = skb->len;
4088c2ecf20Sopenharmony_ci	pkt_info->offset = chip->tx_pkt_desc_sz;
4098c2ecf20Sopenharmony_ci	pkt_info->ls = true;
4108c2ecf20Sopenharmony_ci	if (type == RSVD_PS_POLL) {
4118c2ecf20Sopenharmony_ci		pkt_info->nav_use_hdr = true;
4128c2ecf20Sopenharmony_ci	} else {
4138c2ecf20Sopenharmony_ci		pkt_info->dis_qselseq = true;
4148c2ecf20Sopenharmony_ci		pkt_info->en_hwseq = true;
4158c2ecf20Sopenharmony_ci		pkt_info->hw_ssn_sel = 0;
4168c2ecf20Sopenharmony_ci	}
4178c2ecf20Sopenharmony_ci	if (type == RSVD_QOS_NULL)
4188c2ecf20Sopenharmony_ci		pkt_info->bt_null = true;
4198c2ecf20Sopenharmony_ci
4208c2ecf20Sopenharmony_ci	rtw_tx_pkt_info_update_sec(rtwdev, pkt_info, skb);
4218c2ecf20Sopenharmony_ci
4228c2ecf20Sopenharmony_ci	/* TODO: need to change hw port and hw ssn sel for multiple vifs */
4238c2ecf20Sopenharmony_ci}
4248c2ecf20Sopenharmony_ci
4258c2ecf20Sopenharmony_cistruct sk_buff *
4268c2ecf20Sopenharmony_cirtw_tx_write_data_rsvd_page_get(struct rtw_dev *rtwdev,
4278c2ecf20Sopenharmony_ci				struct rtw_tx_pkt_info *pkt_info,
4288c2ecf20Sopenharmony_ci				u8 *buf, u32 size)
4298c2ecf20Sopenharmony_ci{
4308c2ecf20Sopenharmony_ci	struct rtw_chip_info *chip = rtwdev->chip;
4318c2ecf20Sopenharmony_ci	struct sk_buff *skb;
4328c2ecf20Sopenharmony_ci	u32 tx_pkt_desc_sz;
4338c2ecf20Sopenharmony_ci	u32 length;
4348c2ecf20Sopenharmony_ci
4358c2ecf20Sopenharmony_ci	tx_pkt_desc_sz = chip->tx_pkt_desc_sz;
4368c2ecf20Sopenharmony_ci	length = size + tx_pkt_desc_sz;
4378c2ecf20Sopenharmony_ci	skb = dev_alloc_skb(length);
4388c2ecf20Sopenharmony_ci	if (!skb) {
4398c2ecf20Sopenharmony_ci		rtw_err(rtwdev, "failed to alloc write data rsvd page skb\n");
4408c2ecf20Sopenharmony_ci		return NULL;
4418c2ecf20Sopenharmony_ci	}
4428c2ecf20Sopenharmony_ci
4438c2ecf20Sopenharmony_ci	skb_reserve(skb, tx_pkt_desc_sz);
4448c2ecf20Sopenharmony_ci	skb_put_data(skb, buf, size);
4458c2ecf20Sopenharmony_ci	rtw_tx_rsvd_page_pkt_info_update(rtwdev, pkt_info, skb, RSVD_BEACON);
4468c2ecf20Sopenharmony_ci
4478c2ecf20Sopenharmony_ci	return skb;
4488c2ecf20Sopenharmony_ci}
4498c2ecf20Sopenharmony_ciEXPORT_SYMBOL(rtw_tx_write_data_rsvd_page_get);
4508c2ecf20Sopenharmony_ci
4518c2ecf20Sopenharmony_cistruct sk_buff *
4528c2ecf20Sopenharmony_cirtw_tx_write_data_h2c_get(struct rtw_dev *rtwdev,
4538c2ecf20Sopenharmony_ci			  struct rtw_tx_pkt_info *pkt_info,
4548c2ecf20Sopenharmony_ci			  u8 *buf, u32 size)
4558c2ecf20Sopenharmony_ci{
4568c2ecf20Sopenharmony_ci	struct rtw_chip_info *chip = rtwdev->chip;
4578c2ecf20Sopenharmony_ci	struct sk_buff *skb;
4588c2ecf20Sopenharmony_ci	u32 tx_pkt_desc_sz;
4598c2ecf20Sopenharmony_ci	u32 length;
4608c2ecf20Sopenharmony_ci
4618c2ecf20Sopenharmony_ci	tx_pkt_desc_sz = chip->tx_pkt_desc_sz;
4628c2ecf20Sopenharmony_ci	length = size + tx_pkt_desc_sz;
4638c2ecf20Sopenharmony_ci	skb = dev_alloc_skb(length);
4648c2ecf20Sopenharmony_ci	if (!skb) {
4658c2ecf20Sopenharmony_ci		rtw_err(rtwdev, "failed to alloc write data h2c skb\n");
4668c2ecf20Sopenharmony_ci		return NULL;
4678c2ecf20Sopenharmony_ci	}
4688c2ecf20Sopenharmony_ci
4698c2ecf20Sopenharmony_ci	skb_reserve(skb, tx_pkt_desc_sz);
4708c2ecf20Sopenharmony_ci	skb_put_data(skb, buf, size);
4718c2ecf20Sopenharmony_ci	pkt_info->tx_pkt_size = size;
4728c2ecf20Sopenharmony_ci
4738c2ecf20Sopenharmony_ci	return skb;
4748c2ecf20Sopenharmony_ci}
4758c2ecf20Sopenharmony_ciEXPORT_SYMBOL(rtw_tx_write_data_h2c_get);
4768c2ecf20Sopenharmony_ci
4778c2ecf20Sopenharmony_civoid rtw_tx(struct rtw_dev *rtwdev,
4788c2ecf20Sopenharmony_ci	    struct ieee80211_tx_control *control,
4798c2ecf20Sopenharmony_ci	    struct sk_buff *skb)
4808c2ecf20Sopenharmony_ci{
4818c2ecf20Sopenharmony_ci	struct rtw_tx_pkt_info pkt_info = {0};
4828c2ecf20Sopenharmony_ci	int ret;
4838c2ecf20Sopenharmony_ci
4848c2ecf20Sopenharmony_ci	rtw_tx_pkt_info_update(rtwdev, &pkt_info, control->sta, skb);
4858c2ecf20Sopenharmony_ci	ret = rtw_hci_tx_write(rtwdev, &pkt_info, skb);
4868c2ecf20Sopenharmony_ci	if (ret) {
4878c2ecf20Sopenharmony_ci		rtw_err(rtwdev, "failed to write TX skb to HCI\n");
4888c2ecf20Sopenharmony_ci		goto out;
4898c2ecf20Sopenharmony_ci	}
4908c2ecf20Sopenharmony_ci
4918c2ecf20Sopenharmony_ci	rtw_hci_tx_kick_off(rtwdev);
4928c2ecf20Sopenharmony_ci
4938c2ecf20Sopenharmony_ci	return;
4948c2ecf20Sopenharmony_ci
4958c2ecf20Sopenharmony_ciout:
4968c2ecf20Sopenharmony_ci	ieee80211_free_txskb(rtwdev->hw, skb);
4978c2ecf20Sopenharmony_ci}
4988c2ecf20Sopenharmony_ci
4998c2ecf20Sopenharmony_cistatic void rtw_txq_check_agg(struct rtw_dev *rtwdev,
5008c2ecf20Sopenharmony_ci			      struct rtw_txq *rtwtxq,
5018c2ecf20Sopenharmony_ci			      struct sk_buff *skb)
5028c2ecf20Sopenharmony_ci{
5038c2ecf20Sopenharmony_ci	struct ieee80211_txq *txq = rtwtxq_to_txq(rtwtxq);
5048c2ecf20Sopenharmony_ci	struct ieee80211_tx_info *info;
5058c2ecf20Sopenharmony_ci	struct rtw_sta_info *si;
5068c2ecf20Sopenharmony_ci
5078c2ecf20Sopenharmony_ci	if (test_bit(RTW_TXQ_AMPDU, &rtwtxq->flags)) {
5088c2ecf20Sopenharmony_ci		info = IEEE80211_SKB_CB(skb);
5098c2ecf20Sopenharmony_ci		info->flags |= IEEE80211_TX_CTL_AMPDU;
5108c2ecf20Sopenharmony_ci		return;
5118c2ecf20Sopenharmony_ci	}
5128c2ecf20Sopenharmony_ci
5138c2ecf20Sopenharmony_ci	if (skb_get_queue_mapping(skb) == IEEE80211_AC_VO)
5148c2ecf20Sopenharmony_ci		return;
5158c2ecf20Sopenharmony_ci
5168c2ecf20Sopenharmony_ci	if (test_bit(RTW_TXQ_BLOCK_BA, &rtwtxq->flags))
5178c2ecf20Sopenharmony_ci		return;
5188c2ecf20Sopenharmony_ci
5198c2ecf20Sopenharmony_ci	if (unlikely(skb->protocol == cpu_to_be16(ETH_P_PAE)))
5208c2ecf20Sopenharmony_ci		return;
5218c2ecf20Sopenharmony_ci
5228c2ecf20Sopenharmony_ci	if (!txq->sta)
5238c2ecf20Sopenharmony_ci		return;
5248c2ecf20Sopenharmony_ci
5258c2ecf20Sopenharmony_ci	si = (struct rtw_sta_info *)txq->sta->drv_priv;
5268c2ecf20Sopenharmony_ci	set_bit(txq->tid, si->tid_ba);
5278c2ecf20Sopenharmony_ci
5288c2ecf20Sopenharmony_ci	ieee80211_queue_work(rtwdev->hw, &rtwdev->ba_work);
5298c2ecf20Sopenharmony_ci}
5308c2ecf20Sopenharmony_ci
5318c2ecf20Sopenharmony_cistatic int rtw_txq_push_skb(struct rtw_dev *rtwdev,
5328c2ecf20Sopenharmony_ci			    struct rtw_txq *rtwtxq,
5338c2ecf20Sopenharmony_ci			    struct sk_buff *skb)
5348c2ecf20Sopenharmony_ci{
5358c2ecf20Sopenharmony_ci	struct ieee80211_txq *txq = rtwtxq_to_txq(rtwtxq);
5368c2ecf20Sopenharmony_ci	struct rtw_tx_pkt_info pkt_info = {0};
5378c2ecf20Sopenharmony_ci	int ret;
5388c2ecf20Sopenharmony_ci
5398c2ecf20Sopenharmony_ci	rtw_txq_check_agg(rtwdev, rtwtxq, skb);
5408c2ecf20Sopenharmony_ci
5418c2ecf20Sopenharmony_ci	rtw_tx_pkt_info_update(rtwdev, &pkt_info, txq->sta, skb);
5428c2ecf20Sopenharmony_ci	ret = rtw_hci_tx_write(rtwdev, &pkt_info, skb);
5438c2ecf20Sopenharmony_ci	if (ret) {
5448c2ecf20Sopenharmony_ci		rtw_err(rtwdev, "failed to write TX skb to HCI\n");
5458c2ecf20Sopenharmony_ci		return ret;
5468c2ecf20Sopenharmony_ci	}
5478c2ecf20Sopenharmony_ci	rtwtxq->last_push = jiffies;
5488c2ecf20Sopenharmony_ci
5498c2ecf20Sopenharmony_ci	return 0;
5508c2ecf20Sopenharmony_ci}
5518c2ecf20Sopenharmony_ci
5528c2ecf20Sopenharmony_cistatic struct sk_buff *rtw_txq_dequeue(struct rtw_dev *rtwdev,
5538c2ecf20Sopenharmony_ci				       struct rtw_txq *rtwtxq)
5548c2ecf20Sopenharmony_ci{
5558c2ecf20Sopenharmony_ci	struct ieee80211_txq *txq = rtwtxq_to_txq(rtwtxq);
5568c2ecf20Sopenharmony_ci	struct sk_buff *skb;
5578c2ecf20Sopenharmony_ci
5588c2ecf20Sopenharmony_ci	skb = ieee80211_tx_dequeue(rtwdev->hw, txq);
5598c2ecf20Sopenharmony_ci	if (!skb)
5608c2ecf20Sopenharmony_ci		return NULL;
5618c2ecf20Sopenharmony_ci
5628c2ecf20Sopenharmony_ci	return skb;
5638c2ecf20Sopenharmony_ci}
5648c2ecf20Sopenharmony_ci
5658c2ecf20Sopenharmony_cistatic void rtw_txq_push(struct rtw_dev *rtwdev,
5668c2ecf20Sopenharmony_ci			 struct rtw_txq *rtwtxq,
5678c2ecf20Sopenharmony_ci			 unsigned long frames)
5688c2ecf20Sopenharmony_ci{
5698c2ecf20Sopenharmony_ci	struct sk_buff *skb;
5708c2ecf20Sopenharmony_ci	int ret;
5718c2ecf20Sopenharmony_ci	int i;
5728c2ecf20Sopenharmony_ci
5738c2ecf20Sopenharmony_ci	rcu_read_lock();
5748c2ecf20Sopenharmony_ci
5758c2ecf20Sopenharmony_ci	for (i = 0; i < frames; i++) {
5768c2ecf20Sopenharmony_ci		skb = rtw_txq_dequeue(rtwdev, rtwtxq);
5778c2ecf20Sopenharmony_ci		if (!skb)
5788c2ecf20Sopenharmony_ci			break;
5798c2ecf20Sopenharmony_ci
5808c2ecf20Sopenharmony_ci		ret = rtw_txq_push_skb(rtwdev, rtwtxq, skb);
5818c2ecf20Sopenharmony_ci		if (ret) {
5828c2ecf20Sopenharmony_ci			rtw_err(rtwdev, "failed to pusk skb, ret %d\n", ret);
5838c2ecf20Sopenharmony_ci			break;
5848c2ecf20Sopenharmony_ci		}
5858c2ecf20Sopenharmony_ci	}
5868c2ecf20Sopenharmony_ci
5878c2ecf20Sopenharmony_ci	rcu_read_unlock();
5888c2ecf20Sopenharmony_ci}
5898c2ecf20Sopenharmony_ci
5908c2ecf20Sopenharmony_civoid rtw_tx_tasklet(struct tasklet_struct *t)
5918c2ecf20Sopenharmony_ci{
5928c2ecf20Sopenharmony_ci	struct rtw_dev *rtwdev = from_tasklet(rtwdev, t, tx_tasklet);
5938c2ecf20Sopenharmony_ci	struct rtw_txq *rtwtxq, *tmp;
5948c2ecf20Sopenharmony_ci
5958c2ecf20Sopenharmony_ci	spin_lock_bh(&rtwdev->txq_lock);
5968c2ecf20Sopenharmony_ci
5978c2ecf20Sopenharmony_ci	list_for_each_entry_safe(rtwtxq, tmp, &rtwdev->txqs, list) {
5988c2ecf20Sopenharmony_ci		struct ieee80211_txq *txq = rtwtxq_to_txq(rtwtxq);
5998c2ecf20Sopenharmony_ci		unsigned long frame_cnt;
6008c2ecf20Sopenharmony_ci		unsigned long byte_cnt;
6018c2ecf20Sopenharmony_ci
6028c2ecf20Sopenharmony_ci		ieee80211_txq_get_depth(txq, &frame_cnt, &byte_cnt);
6038c2ecf20Sopenharmony_ci		rtw_txq_push(rtwdev, rtwtxq, frame_cnt);
6048c2ecf20Sopenharmony_ci
6058c2ecf20Sopenharmony_ci		list_del_init(&rtwtxq->list);
6068c2ecf20Sopenharmony_ci	}
6078c2ecf20Sopenharmony_ci
6088c2ecf20Sopenharmony_ci	rtw_hci_tx_kick_off(rtwdev);
6098c2ecf20Sopenharmony_ci
6108c2ecf20Sopenharmony_ci	spin_unlock_bh(&rtwdev->txq_lock);
6118c2ecf20Sopenharmony_ci}
6128c2ecf20Sopenharmony_ci
6138c2ecf20Sopenharmony_civoid rtw_txq_init(struct rtw_dev *rtwdev, struct ieee80211_txq *txq)
6148c2ecf20Sopenharmony_ci{
6158c2ecf20Sopenharmony_ci	struct rtw_txq *rtwtxq;
6168c2ecf20Sopenharmony_ci
6178c2ecf20Sopenharmony_ci	if (!txq)
6188c2ecf20Sopenharmony_ci		return;
6198c2ecf20Sopenharmony_ci
6208c2ecf20Sopenharmony_ci	rtwtxq = (struct rtw_txq *)txq->drv_priv;
6218c2ecf20Sopenharmony_ci	INIT_LIST_HEAD(&rtwtxq->list);
6228c2ecf20Sopenharmony_ci}
6238c2ecf20Sopenharmony_ci
6248c2ecf20Sopenharmony_civoid rtw_txq_cleanup(struct rtw_dev *rtwdev, struct ieee80211_txq *txq)
6258c2ecf20Sopenharmony_ci{
6268c2ecf20Sopenharmony_ci	struct rtw_txq *rtwtxq;
6278c2ecf20Sopenharmony_ci
6288c2ecf20Sopenharmony_ci	if (!txq)
6298c2ecf20Sopenharmony_ci		return;
6308c2ecf20Sopenharmony_ci
6318c2ecf20Sopenharmony_ci	rtwtxq = (struct rtw_txq *)txq->drv_priv;
6328c2ecf20Sopenharmony_ci	spin_lock_bh(&rtwdev->txq_lock);
6338c2ecf20Sopenharmony_ci	if (!list_empty(&rtwtxq->list))
6348c2ecf20Sopenharmony_ci		list_del_init(&rtwtxq->list);
6358c2ecf20Sopenharmony_ci	spin_unlock_bh(&rtwdev->txq_lock);
6368c2ecf20Sopenharmony_ci}
637