Commit 89829c9e authored by Lorenzo Bianconi's avatar Lorenzo Bianconi Committed by Felix Fietkau

mt76: mt7663: fix DMA unmap length

Fix DMA unmap length for mt7663e devices in mt7615_txp_skb_unmap_hw

Fixes: f40ac0f3 ("mt76: mt7615: introduce mt7663e support")
Co-developed-by: default avatarSean Wang <sean.wang@mediatek.com>
Signed-off-by: default avatarSean Wang <sean.wang@mediatek.com>
Co-developed-by: default avatarSoul Huang <soul.huang@mediatek.com>
Signed-off-by: default avatarSoul Huang <soul.huang@mediatek.com>
Signed-off-by: default avatarLorenzo Bianconi <lorenzo@kernel.org>
parent c0f8055b
...@@ -686,15 +686,18 @@ mt7615_txp_skb_unmap_fw(struct mt76_dev *dev, struct mt7615_fw_txp *txp) ...@@ -686,15 +686,18 @@ mt7615_txp_skb_unmap_fw(struct mt76_dev *dev, struct mt7615_fw_txp *txp)
static void static void
mt7615_txp_skb_unmap_hw(struct mt76_dev *dev, struct mt7615_hw_txp *txp) mt7615_txp_skb_unmap_hw(struct mt76_dev *dev, struct mt7615_hw_txp *txp)
{ {
u32 last_mask;
int i; int i;
last_mask = is_mt7663(dev) ? MT_TXD_LEN_LAST : MT_TXD_LEN_MSDU_LAST;
for (i = 0; i < ARRAY_SIZE(txp->ptr); i++) { for (i = 0; i < ARRAY_SIZE(txp->ptr); i++) {
struct mt7615_txp_ptr *ptr = &txp->ptr[i]; struct mt7615_txp_ptr *ptr = &txp->ptr[i];
bool last; bool last;
u16 len; u16 len;
len = le16_to_cpu(ptr->len0); len = le16_to_cpu(ptr->len0);
last = len & MT_TXD_LEN_MSDU_LAST; last = len & last_mask;
len &= MT_TXD_LEN_MASK; len &= MT_TXD_LEN_MASK;
dma_unmap_single(dev->dev, le32_to_cpu(ptr->buf0), len, dma_unmap_single(dev->dev, le32_to_cpu(ptr->buf0), len,
DMA_TO_DEVICE); DMA_TO_DEVICE);
...@@ -702,7 +705,7 @@ mt7615_txp_skb_unmap_hw(struct mt76_dev *dev, struct mt7615_hw_txp *txp) ...@@ -702,7 +705,7 @@ mt7615_txp_skb_unmap_hw(struct mt76_dev *dev, struct mt7615_hw_txp *txp)
break; break;
len = le16_to_cpu(ptr->len1); len = le16_to_cpu(ptr->len1);
last = len & MT_TXD_LEN_MSDU_LAST; last = len & last_mask;
len &= MT_TXD_LEN_MASK; len &= MT_TXD_LEN_MASK;
dma_unmap_single(dev->dev, le32_to_cpu(ptr->buf1), len, dma_unmap_single(dev->dev, le32_to_cpu(ptr->buf1), len,
DMA_TO_DEVICE); DMA_TO_DEVICE);
...@@ -1105,21 +1108,26 @@ mt7615_write_hw_txp(struct mt7615_dev *dev, struct mt76_tx_info *tx_info, ...@@ -1105,21 +1108,26 @@ mt7615_write_hw_txp(struct mt7615_dev *dev, struct mt76_tx_info *tx_info,
{ {
struct mt7615_hw_txp *txp = txp_ptr; struct mt7615_hw_txp *txp = txp_ptr;
struct mt7615_txp_ptr *ptr = &txp->ptr[0]; struct mt7615_txp_ptr *ptr = &txp->ptr[0];
int nbuf = tx_info->nbuf - 1; int i, nbuf = tx_info->nbuf - 1;
int i; u32 last_mask;
tx_info->buf[0].len = MT_TXD_SIZE + sizeof(*txp); tx_info->buf[0].len = MT_TXD_SIZE + sizeof(*txp);
tx_info->nbuf = 1; tx_info->nbuf = 1;
txp->msdu_id[0] = cpu_to_le16(id | MT_MSDU_ID_VALID); txp->msdu_id[0] = cpu_to_le16(id | MT_MSDU_ID_VALID);
if (is_mt7663(&dev->mt76))
last_mask = MT_TXD_LEN_LAST;
else
last_mask = MT_TXD_LEN_AMSDU_LAST |
MT_TXD_LEN_MSDU_LAST;
for (i = 0; i < nbuf; i++) { for (i = 0; i < nbuf; i++) {
u16 len = tx_info->buf[i + 1].len & MT_TXD_LEN_MASK; u16 len = tx_info->buf[i + 1].len & MT_TXD_LEN_MASK;
u32 addr = tx_info->buf[i + 1].addr; u32 addr = tx_info->buf[i + 1].addr;
if (i == nbuf - 1) if (i == nbuf - 1)
len |= MT_TXD_LEN_MSDU_LAST | len |= last_mask;
MT_TXD_LEN_AMSDU_LAST;
if (i & 1) { if (i & 1) {
ptr->buf1 = cpu_to_le32(addr); ptr->buf1 = cpu_to_le32(addr);
......
...@@ -256,6 +256,8 @@ enum tx_phy_bandwidth { ...@@ -256,6 +256,8 @@ enum tx_phy_bandwidth {
#define MT_TXD_LEN_MASK GENMASK(11, 0) #define MT_TXD_LEN_MASK GENMASK(11, 0)
#define MT_TXD_LEN_MSDU_LAST BIT(14) #define MT_TXD_LEN_MSDU_LAST BIT(14)
#define MT_TXD_LEN_AMSDU_LAST BIT(15) #define MT_TXD_LEN_AMSDU_LAST BIT(15)
/* mt7663 */
#define MT_TXD_LEN_LAST BIT(15)
struct mt7615_txp_ptr { struct mt7615_txp_ptr {
__le32 buf0; __le32 buf0;
......
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