Commit 88b9d8e6 authored by Po-Hao Huang's avatar Po-Hao Huang Committed by Kalle Valo

wifi: rtw88: use struct instead of macros to set TX desc

Remove macros that set TX descriptors. Use struct and
le32_encode_bits() with mask definitions.
Signed-off-by: default avatarPo-Hao Huang <phhuang@realtek.com>
Signed-off-by: default avatarPing-Ke Shih <pkshih@realtek.com>
Signed-off-by: default avatarKalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20230616125540.36877-2-pkshih@realtek.com
parent 67d7f24b
...@@ -1970,15 +1970,17 @@ static void rtw8723d_fill_txdesc_checksum(struct rtw_dev *rtwdev, ...@@ -1970,15 +1970,17 @@ static void rtw8723d_fill_txdesc_checksum(struct rtw_dev *rtwdev,
size_t words = 32 / 2; /* calculate the first 32 bytes (16 words) */ size_t words = 32 / 2; /* calculate the first 32 bytes (16 words) */
__le16 chksum = 0; __le16 chksum = 0;
__le16 *data = (__le16 *)(txdesc); __le16 *data = (__le16 *)(txdesc);
struct rtw_tx_desc *tx_desc = (struct rtw_tx_desc *)txdesc;
SET_TX_DESC_TXDESC_CHECKSUM(txdesc, 0x0000); le32p_replace_bits(&tx_desc->w7, 0, RTW_TX_DESC_W7_TXDESC_CHECKSUM);
while (words--) while (words--)
chksum ^= *data++; chksum ^= *data++;
chksum = ~chksum; chksum = ~chksum;
SET_TX_DESC_TXDESC_CHECKSUM(txdesc, __le16_to_cpu(chksum)); le32p_replace_bits(&tx_desc->w7, __le16_to_cpu(chksum),
RTW_TX_DESC_W7_TXDESC_CHECKSUM);
} }
static struct rtw_chip_ops rtw8723d_ops = { static struct rtw_chip_ops rtw8723d_ops = {
......
...@@ -34,43 +34,52 @@ void rtw_tx_stats(struct rtw_dev *rtwdev, struct ieee80211_vif *vif, ...@@ -34,43 +34,52 @@ void rtw_tx_stats(struct rtw_dev *rtwdev, struct ieee80211_vif *vif,
void rtw_tx_fill_tx_desc(struct rtw_tx_pkt_info *pkt_info, struct sk_buff *skb) void rtw_tx_fill_tx_desc(struct rtw_tx_pkt_info *pkt_info, struct sk_buff *skb)
{ {
__le32 *txdesc = (__le32 *)skb->data; struct rtw_tx_desc *tx_desc = (struct rtw_tx_desc *)skb->data;
SET_TX_DESC_TXPKTSIZE(txdesc, pkt_info->tx_pkt_size); tx_desc->w0 = le32_encode_bits(pkt_info->tx_pkt_size, RTW_TX_DESC_W0_TXPKTSIZE) |
SET_TX_DESC_OFFSET(txdesc, pkt_info->offset); le32_encode_bits(pkt_info->offset, RTW_TX_DESC_W0_OFFSET) |
SET_TX_DESC_PKT_OFFSET(txdesc, pkt_info->pkt_offset); le32_encode_bits(pkt_info->bmc, RTW_TX_DESC_W0_BMC) |
SET_TX_DESC_QSEL(txdesc, pkt_info->qsel); le32_encode_bits(pkt_info->ls, RTW_TX_DESC_W0_LS) |
SET_TX_DESC_BMC(txdesc, pkt_info->bmc); le32_encode_bits(pkt_info->dis_qselseq, RTW_TX_DESC_W0_DISQSELSEQ);
SET_TX_DESC_RATE_ID(txdesc, pkt_info->rate_id);
SET_TX_DESC_DATARATE(txdesc, pkt_info->rate); tx_desc->w1 = le32_encode_bits(pkt_info->qsel, RTW_TX_DESC_W1_QSEL) |
SET_TX_DESC_DISDATAFB(txdesc, pkt_info->dis_rate_fallback); le32_encode_bits(pkt_info->rate_id, RTW_TX_DESC_W1_RATE_ID) |
SET_TX_DESC_USE_RATE(txdesc, pkt_info->use_rate); le32_encode_bits(pkt_info->sec_type, RTW_TX_DESC_W1_SEC_TYPE) |
SET_TX_DESC_SEC_TYPE(txdesc, pkt_info->sec_type); le32_encode_bits(pkt_info->pkt_offset, RTW_TX_DESC_W1_PKT_OFFSET);
SET_TX_DESC_DATA_BW(txdesc, pkt_info->bw);
SET_TX_DESC_SW_SEQ(txdesc, pkt_info->seq); tx_desc->w2 = le32_encode_bits(pkt_info->ampdu_en, RTW_TX_DESC_W2_AGG_EN) |
SET_TX_DESC_MAX_AGG_NUM(txdesc, pkt_info->ampdu_factor); le32_encode_bits(pkt_info->report, RTW_TX_DESC_W2_SPE_RPT) |
SET_TX_DESC_AMPDU_DENSITY(txdesc, pkt_info->ampdu_density); le32_encode_bits(pkt_info->ampdu_density, RTW_TX_DESC_W2_AMPDU_DEN) |
SET_TX_DESC_DATA_STBC(txdesc, pkt_info->stbc); le32_encode_bits(pkt_info->bt_null, RTW_TX_DESC_W2_BT_NULL);
SET_TX_DESC_DATA_LDPC(txdesc, pkt_info->ldpc);
SET_TX_DESC_AGG_EN(txdesc, pkt_info->ampdu_en); tx_desc->w3 = le32_encode_bits(pkt_info->hw_ssn_sel, RTW_TX_DESC_W3_HW_SSN_SEL) |
SET_TX_DESC_LS(txdesc, pkt_info->ls); le32_encode_bits(pkt_info->use_rate, RTW_TX_DESC_W3_USE_RATE) |
SET_TX_DESC_DATA_SHORT(txdesc, pkt_info->short_gi); le32_encode_bits(pkt_info->dis_rate_fallback, RTW_TX_DESC_W3_DISDATAFB) |
SET_TX_DESC_SPE_RPT(txdesc, pkt_info->report); le32_encode_bits(pkt_info->rts, RTW_TX_DESC_W3_USE_RTS) |
SET_TX_DESC_SW_DEFINE(txdesc, pkt_info->sn); le32_encode_bits(pkt_info->nav_use_hdr, RTW_TX_DESC_W3_NAVUSEHDR) |
SET_TX_DESC_USE_RTS(txdesc, pkt_info->rts); le32_encode_bits(pkt_info->ampdu_factor, RTW_TX_DESC_W3_MAX_AGG_NUM);
tx_desc->w4 = le32_encode_bits(pkt_info->rate, RTW_TX_DESC_W4_DATARATE);
tx_desc->w5 = le32_encode_bits(pkt_info->short_gi, RTW_TX_DESC_W5_DATA_SHORT) |
le32_encode_bits(pkt_info->bw, RTW_TX_DESC_W5_DATA_BW) |
le32_encode_bits(pkt_info->ldpc, RTW_TX_DESC_W5_DATA_LDPC) |
le32_encode_bits(pkt_info->stbc, RTW_TX_DESC_W5_DATA_STBC);
tx_desc->w6 = le32_encode_bits(pkt_info->sn, RTW_TX_DESC_W6_SW_DEFINE);
tx_desc->w8 = le32_encode_bits(pkt_info->en_hwseq, RTW_TX_DESC_W8_EN_HWSEQ);
tx_desc->w9 = le32_encode_bits(pkt_info->seq, RTW_TX_DESC_W9_SW_SEQ);
if (pkt_info->rts) { if (pkt_info->rts) {
SET_TX_DESC_RTSRATE(txdesc, DESC_RATE24M); tx_desc->w4 |= le32_encode_bits(DESC_RATE24M, RTW_TX_DESC_W4_RTSRATE);
SET_TX_DESC_DATA_RTS_SHORT(txdesc, 1); tx_desc->w5 |= le32_encode_bits(1, RTW_TX_DESC_W5_DATA_RTS_SHORT);
}
SET_TX_DESC_DISQSELSEQ(txdesc, pkt_info->dis_qselseq);
SET_TX_DESC_EN_HWSEQ(txdesc, pkt_info->en_hwseq);
SET_TX_DESC_HW_SSN_SEL(txdesc, pkt_info->hw_ssn_sel);
SET_TX_DESC_NAVUSEHDR(txdesc, pkt_info->nav_use_hdr);
SET_TX_DESC_BT_NULL(txdesc, pkt_info->bt_null);
if (pkt_info->tim_offset) {
SET_TX_DESC_TIM_EN(txdesc, 1);
SET_TX_DESC_TIM_OFFSET(txdesc, pkt_info->tim_offset);
} }
if (pkt_info->tim_offset)
tx_desc->w9 |= le32_encode_bits(1, RTW_TX_DESC_W9_TIM_EN) |
le32_encode_bits(pkt_info->tim_offset, RTW_TX_DESC_W9_TIM_OFFSET);
} }
EXPORT_SYMBOL(rtw_tx_fill_tx_desc); EXPORT_SYMBOL(rtw_tx_fill_tx_desc);
......
...@@ -9,76 +9,52 @@ ...@@ -9,76 +9,52 @@
#define RTW_TX_PROBE_TIMEOUT msecs_to_jiffies(500) #define RTW_TX_PROBE_TIMEOUT msecs_to_jiffies(500)
#define SET_TX_DESC_TXPKTSIZE(txdesc, value) \ struct rtw_tx_desc {
le32p_replace_bits((__le32 *)(txdesc) + 0x00, value, GENMASK(15, 0)) __le32 w0;
#define SET_TX_DESC_OFFSET(txdesc, value) \ __le32 w1;
le32p_replace_bits((__le32 *)(txdesc) + 0x00, value, GENMASK(23, 16)) __le32 w2;
#define SET_TX_DESC_PKT_OFFSET(txdesc, value) \ __le32 w3;
le32p_replace_bits((__le32 *)(txdesc) + 0x01, value, GENMASK(28, 24)) __le32 w4;
#define SET_TX_DESC_QSEL(txdesc, value) \ __le32 w5;
le32p_replace_bits((__le32 *)(txdesc) + 0x01, value, GENMASK(12, 8)) __le32 w6;
#define SET_TX_DESC_BMC(txdesc, value) \ __le32 w7;
le32p_replace_bits((__le32 *)(txdesc) + 0x00, value, BIT(24)) __le32 w8;
#define SET_TX_DESC_RATE_ID(txdesc, value) \ __le32 w9;
le32p_replace_bits((__le32 *)(txdesc) + 0x01, value, GENMASK(20, 16)) } __packed;
#define SET_TX_DESC_DATARATE(txdesc, value) \
le32p_replace_bits((__le32 *)(txdesc) + 0x04, value, GENMASK(6, 0)) #define RTW_TX_DESC_W0_TXPKTSIZE GENMASK(15, 0)
#define SET_TX_DESC_DISDATAFB(txdesc, value) \ #define RTW_TX_DESC_W0_OFFSET GENMASK(23, 16)
le32p_replace_bits((__le32 *)(txdesc) + 0x03, value, BIT(10)) #define RTW_TX_DESC_W0_BMC BIT(24)
#define SET_TX_DESC_USE_RATE(txdesc, value) \ #define RTW_TX_DESC_W0_LS BIT(26)
le32p_replace_bits((__le32 *)(txdesc) + 0x03, value, BIT(8)) #define RTW_TX_DESC_W0_DISQSELSEQ BIT(31)
#define SET_TX_DESC_SEC_TYPE(txdesc, value) \ #define RTW_TX_DESC_W1_QSEL GENMASK(12, 8)
le32p_replace_bits((__le32 *)(txdesc) + 0x01, value, GENMASK(23, 22)) #define RTW_TX_DESC_W1_RATE_ID GENMASK(20, 16)
#define SET_TX_DESC_DATA_BW(txdesc, value) \ #define RTW_TX_DESC_W1_SEC_TYPE GENMASK(23, 22)
le32p_replace_bits((__le32 *)(txdesc) + 0x05, value, GENMASK(6, 5)) #define RTW_TX_DESC_W1_PKT_OFFSET GENMASK(28, 24)
#define SET_TX_DESC_SW_SEQ(txdesc, value) \ #define RTW_TX_DESC_W2_AGG_EN BIT(12)
le32p_replace_bits((__le32 *)(txdesc) + 0x09, value, GENMASK(23, 12)) #define RTW_TX_DESC_W2_SPE_RPT BIT(19)
#define SET_TX_DESC_TIM_EN(txdesc, value) \ #define RTW_TX_DESC_W2_AMPDU_DEN GENMASK(22, 20)
le32p_replace_bits((__le32 *)(txdesc) + 0x09, value, BIT(7)) #define RTW_TX_DESC_W2_BT_NULL BIT(23)
#define SET_TX_DESC_TIM_OFFSET(txdesc, value) \ #define RTW_TX_DESC_W3_HW_SSN_SEL GENMASK(7, 6)
le32p_replace_bits((__le32 *)(txdesc) + 0x09, value, GENMASK(6, 0)) #define RTW_TX_DESC_W3_USE_RATE BIT(8)
#define SET_TX_DESC_MAX_AGG_NUM(txdesc, value) \ #define RTW_TX_DESC_W3_DISDATAFB BIT(10)
le32p_replace_bits((__le32 *)(txdesc) + 0x03, value, GENMASK(21, 17)) #define RTW_TX_DESC_W3_USE_RTS BIT(12)
#define SET_TX_DESC_USE_RTS(tx_desc, value) \ #define RTW_TX_DESC_W3_NAVUSEHDR BIT(15)
le32p_replace_bits((__le32 *)(txdesc) + 0x03, value, BIT(12)) #define RTW_TX_DESC_W3_MAX_AGG_NUM GENMASK(21, 17)
#define SET_TX_DESC_RTSRATE(txdesc, value) \ #define RTW_TX_DESC_W4_DATARATE GENMASK(6, 0)
le32p_replace_bits((__le32 *)(txdesc) + 0x04, value, GENMASK(28, 24)) #define RTW_TX_DESC_W4_RTSRATE GENMASK(28, 24)
#define SET_TX_DESC_DATA_RTS_SHORT(txdesc, value) \ #define RTW_TX_DESC_W5_DATA_SHORT BIT(4)
le32p_replace_bits((__le32 *)(txdesc) + 0x05, value, BIT(12)) #define RTW_TX_DESC_W5_DATA_BW GENMASK(6, 5)
#define SET_TX_DESC_AMPDU_DENSITY(txdesc, value) \ #define RTW_TX_DESC_W5_DATA_LDPC BIT(7)
le32p_replace_bits((__le32 *)(txdesc) + 0x02, value, GENMASK(22, 20)) #define RTW_TX_DESC_W5_DATA_STBC GENMASK(9, 8)
#define SET_TX_DESC_DATA_STBC(txdesc, value) \ #define RTW_TX_DESC_W5_DATA_RTS_SHORT BIT(12)
le32p_replace_bits((__le32 *)(txdesc) + 0x05, value, GENMASK(9, 8)) #define RTW_TX_DESC_W6_SW_DEFINE GENMASK(11, 0)
#define SET_TX_DESC_DATA_LDPC(txdesc, value) \ #define RTW_TX_DESC_W7_TXDESC_CHECKSUM GENMASK(15, 0)
le32p_replace_bits((__le32 *)(txdesc) + 0x05, value, BIT(7)) #define RTW_TX_DESC_W7_DMA_TXAGG_NUM GENMASK(31, 24)
#define SET_TX_DESC_AGG_EN(txdesc, value) \ #define RTW_TX_DESC_W8_EN_HWSEQ BIT(15)
le32p_replace_bits((__le32 *)(txdesc) + 0x02, value, BIT(12)) #define RTW_TX_DESC_W9_SW_SEQ GENMASK(23, 12)
#define SET_TX_DESC_LS(txdesc, value) \ #define RTW_TX_DESC_W9_TIM_EN BIT(7)
le32p_replace_bits((__le32 *)(txdesc) + 0x00, value, BIT(26)) #define RTW_TX_DESC_W9_TIM_OFFSET GENMASK(6, 0)
#define SET_TX_DESC_DATA_SHORT(txdesc, value) \
le32p_replace_bits((__le32 *)(txdesc) + 0x05, value, BIT(4))
#define SET_TX_DESC_SPE_RPT(tx_desc, value) \
le32p_replace_bits((__le32 *)(txdesc) + 0x02, value, BIT(19))
#define SET_TX_DESC_SW_DEFINE(tx_desc, value) \
le32p_replace_bits((__le32 *)(txdesc) + 0x06, value, GENMASK(11, 0))
#define SET_TX_DESC_DISQSELSEQ(txdesc, value) \
le32p_replace_bits((__le32 *)(txdesc) + 0x00, value, BIT(31))
#define SET_TX_DESC_EN_HWSEQ(txdesc, value) \
le32p_replace_bits((__le32 *)(txdesc) + 0x08, value, BIT(15))
#define SET_TX_DESC_HW_SSN_SEL(txdesc, value) \
le32p_replace_bits((__le32 *)(txdesc) + 0x03, value, GENMASK(7, 6))
#define SET_TX_DESC_NAVUSEHDR(txdesc, value) \
le32p_replace_bits((__le32 *)(txdesc) + 0x03, value, BIT(15))
#define SET_TX_DESC_BT_NULL(txdesc, value) \
le32p_replace_bits((__le32 *)(txdesc) + 0x02, value, BIT(23))
#define SET_TX_DESC_TXDESC_CHECKSUM(txdesc, value) \
le32p_replace_bits((__le32 *)(txdesc) + 0x07, value, GENMASK(15, 0))
#define SET_TX_DESC_DMA_TXAGG_NUM(txdesc, value) \
le32p_replace_bits((__le32 *)(txdesc) + 0x07, value, GENMASK(31, 24))
#define GET_TX_DESC_PKT_OFFSET(txdesc) \
le32_get_bits(*((__le32 *)(txdesc) + 0x01), GENMASK(28, 24))
#define GET_TX_DESC_QSEL(txdesc) \
le32_get_bits(*((__le32 *)(txdesc) + 0x01), GENMASK(12, 8))
enum rtw_tx_desc_queue_select { enum rtw_tx_desc_queue_select {
TX_DESC_QSEL_TID0 = 0, TX_DESC_QSEL_TID0 = 0,
...@@ -140,13 +116,15 @@ void fill_txdesc_checksum_common(u8 *txdesc, size_t words) ...@@ -140,13 +116,15 @@ void fill_txdesc_checksum_common(u8 *txdesc, size_t words)
{ {
__le16 chksum = 0; __le16 chksum = 0;
__le16 *data = (__le16 *)(txdesc); __le16 *data = (__le16 *)(txdesc);
struct rtw_tx_desc *tx_desc = (struct rtw_tx_desc *)txdesc;
SET_TX_DESC_TXDESC_CHECKSUM(txdesc, 0x0000); le32p_replace_bits(&tx_desc->w7, 0, RTW_TX_DESC_W7_TXDESC_CHECKSUM);
while (words--) while (words--)
chksum ^= *data++; chksum ^= *data++;
SET_TX_DESC_TXDESC_CHECKSUM(txdesc, __le16_to_cpu(chksum)); le32p_replace_bits(&tx_desc->w7, __le16_to_cpu(chksum),
RTW_TX_DESC_W7_TXDESC_CHECKSUM);
} }
static inline void rtw_tx_fill_txdesc_checksum(struct rtw_dev *rtwdev, static inline void rtw_tx_fill_txdesc_checksum(struct rtw_dev *rtwdev,
......
...@@ -24,11 +24,12 @@ struct rtw_usb_txcb { ...@@ -24,11 +24,12 @@ struct rtw_usb_txcb {
static void rtw_usb_fill_tx_checksum(struct rtw_usb *rtwusb, static void rtw_usb_fill_tx_checksum(struct rtw_usb *rtwusb,
struct sk_buff *skb, int agg_num) struct sk_buff *skb, int agg_num)
{ {
struct rtw_tx_desc *tx_desc = (struct rtw_tx_desc *)skb->data;
struct rtw_dev *rtwdev = rtwusb->rtwdev; struct rtw_dev *rtwdev = rtwusb->rtwdev;
struct rtw_tx_pkt_info pkt_info; struct rtw_tx_pkt_info pkt_info;
SET_TX_DESC_DMA_TXAGG_NUM(skb->data, agg_num); le32p_replace_bits(&tx_desc->w7, agg_num, RTW_TX_DESC_W7_DMA_TXAGG_NUM);
pkt_info.pkt_offset = GET_TX_DESC_PKT_OFFSET(skb->data); pkt_info.pkt_offset = le32_get_bits(tx_desc->w1, RTW_TX_DESC_W1_PKT_OFFSET);
rtw_tx_fill_txdesc_checksum(rtwdev, &pkt_info, skb->data); rtw_tx_fill_txdesc_checksum(rtwdev, &pkt_info, skb->data);
} }
...@@ -306,11 +307,13 @@ static int rtw_usb_write_port(struct rtw_dev *rtwdev, u8 qsel, struct sk_buff *s ...@@ -306,11 +307,13 @@ static int rtw_usb_write_port(struct rtw_dev *rtwdev, u8 qsel, struct sk_buff *s
static bool rtw_usb_tx_agg_skb(struct rtw_usb *rtwusb, struct sk_buff_head *list) static bool rtw_usb_tx_agg_skb(struct rtw_usb *rtwusb, struct sk_buff_head *list)
{ {
struct rtw_dev *rtwdev = rtwusb->rtwdev; struct rtw_dev *rtwdev = rtwusb->rtwdev;
struct rtw_tx_desc *tx_desc;
struct rtw_usb_txcb *txcb; struct rtw_usb_txcb *txcb;
struct sk_buff *skb_head; struct sk_buff *skb_head;
struct sk_buff *skb_iter; struct sk_buff *skb_iter;
int agg_num = 0; int agg_num = 0;
unsigned int align_next = 0; unsigned int align_next = 0;
u8 qsel;
if (skb_queue_empty(list)) if (skb_queue_empty(list))
return false; return false;
...@@ -363,9 +366,10 @@ static bool rtw_usb_tx_agg_skb(struct rtw_usb *rtwusb, struct sk_buff_head *list ...@@ -363,9 +366,10 @@ static bool rtw_usb_tx_agg_skb(struct rtw_usb *rtwusb, struct sk_buff_head *list
queue: queue:
skb_queue_tail(&txcb->tx_ack_queue, skb_head); skb_queue_tail(&txcb->tx_ack_queue, skb_head);
tx_desc = (struct rtw_tx_desc *)skb_head->data;
qsel = le32_get_bits(tx_desc->w1, RTW_TX_DESC_W1_QSEL);
rtw_usb_write_port(rtwdev, GET_TX_DESC_QSEL(skb_head->data), skb_head, rtw_usb_write_port(rtwdev, qsel, skb_head, rtw_usb_write_port_tx_complete, txcb);
rtw_usb_write_port_tx_complete, txcb);
return true; return true;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment