Commit 6d5b5d62 authored by Ping-Ke Shih's avatar Ping-Ke Shih Committed by Kalle Valo

rtw89: pci: support variant of fill_txaddr_info

The txaddr_info is used to fill the DMA address of skb->data. The v1
version can support up to 10 entries, but the maximum size of each entry
is 2047, so it fill more than one entry for large packet, like 3000 bytes.
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/20220318023214.32411-9-pkshih@realtek.com
parent a95bd62e
......@@ -721,6 +721,7 @@ struct rtw89_tx_desc_info {
u8 ampdu_density;
u8 ampdu_num;
bool sec_en;
u8 addr_info_nr;
u8 sec_type;
u8 sec_cam_idx;
u16 data_rate;
......
......@@ -977,6 +977,58 @@ static void rtw89_pci_ops_flush_queues(struct rtw89_dev *rtwdev, u32 queues,
__rtw89_pci_ops_flush_txchs(rtwdev, BIT(RTW89_TXCH_NUM) - 1, drop);
}
u32 rtw89_pci_fill_txaddr_info(struct rtw89_dev *rtwdev,
void *txaddr_info_addr, u32 total_len,
dma_addr_t dma, u8 *add_info_nr)
{
struct rtw89_pci_tx_addr_info_32 *txaddr_info = txaddr_info_addr;
txaddr_info->length = cpu_to_le16(total_len);
txaddr_info->option = cpu_to_le16(RTW89_PCI_ADDR_MSDU_LS |
RTW89_PCI_ADDR_NUM(1));
txaddr_info->dma = cpu_to_le32(dma);
*add_info_nr = 1;
return sizeof(*txaddr_info);
}
EXPORT_SYMBOL(rtw89_pci_fill_txaddr_info);
u32 rtw89_pci_fill_txaddr_info_v1(struct rtw89_dev *rtwdev,
void *txaddr_info_addr, u32 total_len,
dma_addr_t dma, u8 *add_info_nr)
{
struct rtw89_pci_tx_addr_info_32_v1 *txaddr_info = txaddr_info_addr;
u32 remain = total_len;
u32 len;
u16 length_option;
int n;
for (n = 0; n < RTW89_TXADDR_INFO_NR_V1 && remain; n++) {
len = remain >= TXADDR_INFO_LENTHG_V1_MAX ?
TXADDR_INFO_LENTHG_V1_MAX : remain;
remain -= len;
length_option = FIELD_PREP(B_PCIADDR_LEN_V1_MASK, len) |
FIELD_PREP(B_PCIADDR_HIGH_SEL_V1_MASK, 0) |
FIELD_PREP(B_PCIADDR_LS_V1_MASK, remain == 0);
txaddr_info->length_opt = cpu_to_le16(length_option);
txaddr_info->dma_low_lsb = cpu_to_le16(FIELD_GET(GENMASK(15, 0), dma));
txaddr_info->dma_low_msb = cpu_to_le16(FIELD_GET(GENMASK(31, 16), dma));
dma += len;
txaddr_info++;
}
WARN_ONCE(remain, "length overflow remain=%u total_len=%u",
remain, total_len);
*add_info_nr = n;
return n * sizeof(*txaddr_info);
}
EXPORT_SYMBOL(rtw89_pci_fill_txaddr_info_v1);
static int rtw89_pci_txwd_submit(struct rtw89_dev *rtwdev,
struct rtw89_pci_tx_ring *tx_ring,
struct rtw89_pci_tx_wd *txwd,
......@@ -987,7 +1039,7 @@ static int rtw89_pci_txwd_submit(struct rtw89_dev *rtwdev,
struct rtw89_txwd_body *txwd_body;
struct rtw89_txwd_info *txwd_info;
struct rtw89_pci_tx_wp_info *txwp_info;
struct rtw89_pci_tx_addr_info_32 *txaddr_info;
void *txaddr_info_addr;
struct pci_dev *pdev = rtwpci->pdev;
struct sk_buff *skb = tx_req->skb;
struct rtw89_pci_tx_data *tx_data = RTW89_PCI_TX_SKB_CB(skb);
......@@ -1009,7 +1061,6 @@ static int rtw89_pci_txwd_submit(struct rtw89_dev *rtwdev,
tx_data->dma = dma;
txaddr_info_len = sizeof(*txaddr_info);
txwp_len = sizeof(*txwp_info);
txwd_len = sizeof(*txwd_body);
txwd_len += en_wd_info ? sizeof(*txwd_info) : 0;
......@@ -1021,11 +1072,10 @@ static int rtw89_pci_txwd_submit(struct rtw89_dev *rtwdev,
txwp_info->seq3 = 0;
tx_ring->tx_cnt++;
txaddr_info = txwd->vaddr + txwd_len + txwp_len;
txaddr_info->length = cpu_to_le16(skb->len);
txaddr_info->option = cpu_to_le16(RTW89_PCI_ADDR_MSDU_LS |
RTW89_PCI_ADDR_NUM(1));
txaddr_info->dma = cpu_to_le32(dma);
txaddr_info_addr = txwd->vaddr + txwd_len + txwp_len;
txaddr_info_len =
rtw89_chip_fill_txaddr_info(rtwdev, txaddr_info_addr, skb->len,
dma, &desc_info->addr_info_nr);
txwd->len = txwd_len + txwp_len + txaddr_info_len;
......
......@@ -448,6 +448,10 @@ struct rtw89_pci_ch_dma_addr_set {
struct rtw89_pci_info {
const struct rtw89_pci_ch_dma_addr_set *dma_addr_set;
u32 (*fill_txaddr_info)(struct rtw89_dev *rtwdev,
void *txaddr_info_addr, u32 total_len,
dma_addr_t dma, u8 *add_info_nr);
};
struct rtw89_pci_bd_ram {
......@@ -493,6 +497,18 @@ struct rtw89_pci_tx_addr_info_32 {
__le32 dma;
} __packed;
#define RTW89_TXADDR_INFO_NR_V1 10
struct rtw89_pci_tx_addr_info_32_v1 {
__le16 length_opt;
#define B_PCIADDR_LEN_V1_MASK GENMASK(10, 0)
#define B_PCIADDR_HIGH_SEL_V1_MASK GENMASK(14, 11)
#define B_PCIADDR_LS_V1_MASK BIT(15)
#define TXADDR_INFO_LENTHG_V1_MAX ALIGN_DOWN(BIT(11) - 1, 4)
__le16 dma_low_lsb;
__le16 dma_low_msb;
} __packed;
#define RTW89_PCI_RPP_POLLUTED BIT(31)
#define RTW89_PCI_RPP_SEQ GENMASK(30, 16)
#define RTW89_PCI_RPP_TX_STATUS GENMASK(15, 13)
......@@ -698,5 +714,22 @@ struct pci_device_id;
int rtw89_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id);
void rtw89_pci_remove(struct pci_dev *pdev);
u32 rtw89_pci_fill_txaddr_info(struct rtw89_dev *rtwdev,
void *txaddr_info_addr, u32 total_len,
dma_addr_t dma, u8 *add_info_nr);
u32 rtw89_pci_fill_txaddr_info_v1(struct rtw89_dev *rtwdev,
void *txaddr_info_addr, u32 total_len,
dma_addr_t dma, u8 *add_info_nr);
static inline
u32 rtw89_chip_fill_txaddr_info(struct rtw89_dev *rtwdev,
void *txaddr_info_addr, u32 total_len,
dma_addr_t dma, u8 *add_info_nr)
{
const struct rtw89_pci_info *info = rtwdev->pci_info;
return info->fill_txaddr_info(rtwdev, txaddr_info_addr, total_len,
dma, add_info_nr);
}
#endif
......@@ -10,6 +10,8 @@
static const struct rtw89_pci_info rtw8852a_pci_info = {
.dma_addr_set = &rtw89_pci_ch_dma_addr_set,
.fill_txaddr_info = rtw89_pci_fill_txaddr_info,
};
static const struct rtw89_driver_info rtw89_8852ae_info = {
......
......@@ -11,6 +11,8 @@
static const struct rtw89_pci_info rtw8852c_pci_info = {
.dma_addr_set = &rtw89_pci_ch_dma_addr_set_v1,
.fill_txaddr_info = rtw89_pci_fill_txaddr_info_v1,
};
static const struct rtw89_driver_info rtw89_8852ce_info = {
......
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