Message ID | e03a38968b3bca0a51a832bdb0dd9ff1beff314d.1552306908.git.lorenzo@kernel.org (mailing list archive) |
---|---|
State | Superseded |
Delegated to: | Felix Fietkau |
Headers | show |
Series | move skb mapping before configuring txwi | expand |
On Mon, Mar 11, 2019 at 01:35:24PM +0100, Lorenzo Bianconi wrote: > 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: Felix Fietkau <nbd@nbd.name> > Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org> > --- > drivers/net/wireless/mediatek/mt76/dma.c | 3 +++ > drivers/net/wireless/mediatek/mt76/mt76.h | 1 + > drivers/net/wireless/mediatek/mt76/mt76x0/pci.c | 1 + > drivers/net/wireless/mediatek/mt76/mt76x02_txrx.c | 13 +++++-------- > drivers/net/wireless/mediatek/mt76/mt76x2/pci.c | 1 + > 5 files changed, 11 insertions(+), 8 deletions(-) > > diff --git a/drivers/net/wireless/mediatek/mt76/dma.c b/drivers/net/wireless/mediatek/mt76/dma.c > index a66832a02281..14dd6585bab4 100644 > --- a/drivers/net/wireless/mediatek/mt76/dma.c > +++ b/drivers/net/wireless/mediatek/mt76/dma.c > @@ -300,6 +300,9 @@ 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); We need 4 bytes aligned skbs for mt76x02 or we just need header lenght be multiple of 4 ? Stanislaw
On Mar 11, Stanislaw Gruszka wrote: > On Mon, Mar 11, 2019 at 01:35:24PM +0100, Lorenzo Bianconi wrote: > > 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: Felix Fietkau <nbd@nbd.name> > > Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org> > > --- > > drivers/net/wireless/mediatek/mt76/dma.c | 3 +++ > > drivers/net/wireless/mediatek/mt76/mt76.h | 1 + > > drivers/net/wireless/mediatek/mt76/mt76x0/pci.c | 1 + > > drivers/net/wireless/mediatek/mt76/mt76x02_txrx.c | 13 +++++-------- > > drivers/net/wireless/mediatek/mt76/mt76x2/pci.c | 1 + > > 5 files changed, 11 insertions(+), 8 deletions(-) > > > > diff --git a/drivers/net/wireless/mediatek/mt76/dma.c b/drivers/net/wireless/mediatek/mt76/dma.c > > index a66832a02281..14dd6585bab4 100644 > > --- a/drivers/net/wireless/mediatek/mt76/dma.c > > +++ b/drivers/net/wireless/mediatek/mt76/dma.c > > @@ -300,6 +300,9 @@ 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); > > We need 4 bytes aligned skbs for mt76x02 or we just need header > lenght be multiple of 4 ? I think IV/LLC should be 4 byte aligned Regards, Lorenzo > > Stanislaw >
On Mon, Mar 11, 2019 at 03:25:18PM +0100, Lorenzo Bianconi wrote: > On Mar 11, Stanislaw Gruszka wrote: > > On Mon, Mar 11, 2019 at 01:35:24PM +0100, Lorenzo Bianconi wrote: > > > 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: Felix Fietkau <nbd@nbd.name> > > > Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org> > > > --- > > > drivers/net/wireless/mediatek/mt76/dma.c | 3 +++ > > > drivers/net/wireless/mediatek/mt76/mt76.h | 1 + > > > drivers/net/wireless/mediatek/mt76/mt76x0/pci.c | 1 + > > > drivers/net/wireless/mediatek/mt76/mt76x02_txrx.c | 13 +++++-------- > > > drivers/net/wireless/mediatek/mt76/mt76x2/pci.c | 1 + > > > 5 files changed, 11 insertions(+), 8 deletions(-) > > > > > > diff --git a/drivers/net/wireless/mediatek/mt76/dma.c b/drivers/net/wireless/mediatek/mt76/dma.c > > > index a66832a02281..14dd6585bab4 100644 > > > --- a/drivers/net/wireless/mediatek/mt76/dma.c > > > +++ b/drivers/net/wireless/mediatek/mt76/dma.c > > > @@ -300,6 +300,9 @@ 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); > > > > We need 4 bytes aligned skbs for mt76x02 or we just need header > > lenght be multiple of 4 ? > > I think IV/LLC should be 4 byte aligned mt76_insert_hdr_pad() does not change alignment of IV/LLC , it only moves header. I'm not sure what is actually needed (4 bytes alignment or 4 bytes lenght), but I just saw Felix sent 2 mac80211 patches that hopfully do the right thing, so this code after appling mac80211 changes and set TX_NEEDS_ALIGNED4_SKBS can be removed. Stanislaw
> On Mon, Mar 11, 2019 at 03:25:18PM +0100, Lorenzo Bianconi wrote: > > On Mar 11, Stanislaw Gruszka wrote: > > > On Mon, Mar 11, 2019 at 01:35:24PM +0100, Lorenzo Bianconi wrote: > > > > 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: Felix Fietkau <nbd@nbd.name> > > > > Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org> > > > > --- > > > > drivers/net/wireless/mediatek/mt76/dma.c | 3 +++ > > > > drivers/net/wireless/mediatek/mt76/mt76.h | 1 + > > > > drivers/net/wireless/mediatek/mt76/mt76x0/pci.c | 1 + > > > > drivers/net/wireless/mediatek/mt76/mt76x02_txrx.c | 13 +++++-------- > > > > drivers/net/wireless/mediatek/mt76/mt76x2/pci.c | 1 + > > > > 5 files changed, 11 insertions(+), 8 deletions(-) > > > > > > > > diff --git a/drivers/net/wireless/mediatek/mt76/dma.c b/drivers/net/wireless/mediatek/mt76/dma.c > > > > index a66832a02281..14dd6585bab4 100644 > > > > --- a/drivers/net/wireless/mediatek/mt76/dma.c > > > > +++ b/drivers/net/wireless/mediatek/mt76/dma.c > > > > @@ -300,6 +300,9 @@ 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); > > > > > > We need 4 bytes aligned skbs for mt76x02 or we just need header > > > lenght be multiple of 4 ? > > > > I think IV/LLC should be 4 byte aligned > > mt76_insert_hdr_pad() does not change alignment of IV/LLC , it only > moves header. > > I'm not sure what is actually needed (4 bytes alignment or 4 bytes > lenght), but I just saw Felix sent 2 mac80211 patches that hopfully > do the right thing, so this code after appling mac80211 changes > and set TX_NEEDS_ALIGNED4_SKBS can be removed. this is the plan :) Regards, Lorenzo > > Stanislaw >
diff --git a/drivers/net/wireless/mediatek/mt76/dma.c b/drivers/net/wireless/mediatek/mt76/dma.c index a66832a02281..14dd6585bab4 100644 --- a/drivers/net/wireless/mediatek/mt76/dma.c +++ b/drivers/net/wireless/mediatek/mt76/dma.c @@ -300,6 +300,9 @@ 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, diff --git a/drivers/net/wireless/mediatek/mt76/mt76.h b/drivers/net/wireless/mediatek/mt76/mt76.h index 971d968c1b5f..dc505d55409c 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76.h +++ b/drivers/net/wireless/mediatek/mt76/mt76.h @@ -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); diff --git a/drivers/net/wireless/mediatek/mt76/mt76x0/pci.c b/drivers/net/wireless/mediatek/mt76/mt76x0/pci.c index f302162036d0..e07a62246db7 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76x0/pci.c +++ b/drivers/net/wireless/mediatek/mt76/mt76x0/pci.c @@ -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, diff --git a/drivers/net/wireless/mediatek/mt76/mt76x02_txrx.c b/drivers/net/wireless/mediatek/mt76/mt76x02_txrx.c index f574866c7e9d..708f2c65d3fd 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76x02_txrx.c +++ b/drivers/net/wireless/mediatek/mt76/mt76x02_txrx.c @@ -152,23 +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 ret; + 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; - ret = mt76_insert_hdr_pad(skb); - if (ret < 0) - return ret; - if (pid >= MT_PACKET_ID_FIRST) qsel = MT_QSEL_MGMT; diff --git a/drivers/net/wireless/mediatek/mt76/mt76x2/pci.c b/drivers/net/wireless/mediatek/mt76/mt76x2/pci.c index 6274655e1f7e..4747f782417a 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76x2/pci.c +++ b/drivers/net/wireless/mediatek/mt76/mt76x2/pci.c @@ -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,