mt76: mmio: move mt76_insert_hdr_pad in mt76_dma_tx_queue_skb
authorLorenzo Bianconi <lorenzo@kernel.org>
Thu, 14 Mar 2019 13:54:10 +0000 (14:54 +0100)
committerFelix Fietkau <nbd@nbd.name>
Wed, 1 May 2019 11:03:55 +0000 (13:03 +0200)
Introduce tx_aligned4_skbs in mt76_driver_ops and move
mt76_insert_hdr_pad in mt76_dma_tx_queue_skb. This is a preliminary
patch in order to unify tx dma mapping for mt76x02 and new chipsets

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
drivers/net/wireless/mediatek/mt76/dma.c
drivers/net/wireless/mediatek/mt76/mt76.h
drivers/net/wireless/mediatek/mt76/mt76x0/pci.c
drivers/net/wireless/mediatek/mt76/mt76x02_txrx.c
drivers/net/wireless/mediatek/mt76/mt76x2/pci.c

index f812406..f8e16f9 100644 (file)
@@ -299,6 +299,9 @@ int mt76_dma_tx_queue_skb(struct mt76_dev *dev, enum mt76_txq_id qid,
        }
 
        skb->prev = skb->next = NULL;
+       if (dev->drv->tx_aligned4_skbs)
+               mt76_insert_hdr_pad(skb);
+
        dma_sync_single_for_cpu(dev->dev, t->dma_addr, sizeof(t->txwi),
                                DMA_TO_DEVICE);
        ret = dev->drv->tx_prepare_skb(dev, &t->txwi, skb, qid, wcid, sta,
index 7a6992e..3788216 100644 (file)
@@ -288,6 +288,7 @@ struct mt76_hw_cap {
 };
 
 struct mt76_driver_ops {
+       bool tx_aligned4_skbs;
        u16 txwi_size;
 
        void (*update_survey)(struct mt76_dev *dev);
index f302162..e07a622 100644 (file)
@@ -164,6 +164,7 @@ mt76x0e_probe(struct pci_dev *pdev, const struct pci_device_id *id)
 {
        static const struct mt76_driver_ops drv_ops = {
                .txwi_size = sizeof(struct mt76x02_txwi),
+               .tx_aligned4_skbs = true,
                .update_survey = mt76x02_update_channel,
                .tx_prepare_skb = mt76x02_tx_prepare_skb,
                .tx_complete_skb = mt76x02_tx_complete_skb,
index 0a3a360..708f2c6 100644 (file)
@@ -152,20 +152,20 @@ int mt76x02_tx_prepare_skb(struct mt76_dev *mdev, void *txwi_ptr,
                           u32 *tx_info)
 {
        struct mt76x02_dev *dev = container_of(mdev, struct mt76x02_dev, mt76);
+       struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
        struct mt76x02_txwi *txwi = txwi_ptr;
-       int qsel = MT_QSEL_EDCA;
-       int pid;
+       int hdrlen, len, pid, qsel = MT_QSEL_EDCA;
 
        if (qid == MT_TXQ_PSD && wcid && wcid->idx < 128)
                mt76x02_mac_wcid_set_drop(dev, wcid->idx, false);
 
-       mt76x02_mac_write_txwi(dev, txwi, skb, wcid, sta, skb->len);
+       hdrlen = ieee80211_hdrlen(hdr->frame_control);
+       len = skb->len - (hdrlen & 2);
+       mt76x02_mac_write_txwi(dev, txwi, skb, wcid, sta, len);
 
        pid = mt76_tx_status_skb_add(mdev, wcid, skb);
        txwi->pktid = pid;
 
-       mt76_insert_hdr_pad(skb);
-
        if (pid >= MT_PACKET_ID_FIRST)
                qsel = MT_QSEL_MGMT;
 
index 6274655..4747f78 100644 (file)
@@ -32,6 +32,7 @@ mt76pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
 {
        static const struct mt76_driver_ops drv_ops = {
                .txwi_size = sizeof(struct mt76x02_txwi),
+               .tx_aligned4_skbs = true,
                .update_survey = mt76x02_update_channel,
                .tx_prepare_skb = mt76x02_tx_prepare_skb,
                .tx_complete_skb = mt76x02_tx_complete_skb,