* [PATCH 1/4] mt76: move mt76x02_insert_hdr_pad in mt76-core module
2019-03-11 12:35 [PATCH 0/4] move skb mapping before configuring txwi Lorenzo Bianconi
@ 2019-03-11 12:35 ` Lorenzo Bianconi
2019-03-11 13:30 ` Stanislaw Gruszka
2019-03-11 12:35 ` [PATCH 2/4] mt76: mmio: move mt76_insert_hdr_pad in mt76_dma_tx_queue_skb Lorenzo Bianconi
` (3 subsequent siblings)
4 siblings, 1 reply; 12+ messages in thread
From: Lorenzo Bianconi @ 2019-03-11 12:35 UTC (permalink / raw)
To: nbd; +Cc: ryder.lee, roychl666, linux-wireless, lorenzo.bianconi
Move mt76x02_insert_hdr_pad in m76-core and rename it in
mt76_insert_hdr_pad in order to be used in mt76_dma_tx_queue_skb.
This is a preliminary patch in order to properly support tx dma
mapping for new chipsets (e.g. mt7615)
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
---
drivers/net/wireless/mediatek/mt76/mt76.h | 15 +++++++++++++++
drivers/net/wireless/mediatek/mt76/mt76x02.h | 1 -
.../net/wireless/mediatek/mt76/mt76x02_txrx.c | 2 +-
.../wireless/mediatek/mt76/mt76x02_usb_core.c | 2 +-
.../net/wireless/mediatek/mt76/mt76x02_util.c | 16 ----------------
5 files changed, 17 insertions(+), 19 deletions(-)
diff --git a/drivers/net/wireless/mediatek/mt76/mt76.h b/drivers/net/wireless/mediatek/mt76/mt76.h
index 57136073e1fa..971d968c1b5f 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76.h
+++ b/drivers/net/wireless/mediatek/mt76/mt76.h
@@ -653,6 +653,21 @@ static inline struct mt76_tx_cb *mt76_tx_skb_cb(struct sk_buff *skb)
return ((void *) IEEE80211_SKB_CB(skb)->status.status_driver_data);
}
+static inline int mt76_insert_hdr_pad(struct sk_buff *skb)
+{
+ int len = ieee80211_get_hdrlen_from_skb(skb);
+
+ if (len % 4 == 0)
+ return 0;
+
+ skb_push(skb, 2);
+ memmove(skb->data, skb->data + 2, len);
+
+ skb->data[len] = 0;
+ skb->data[len + 1] = 0;
+ return 2;
+}
+
void mt76_rx(struct mt76_dev *dev, enum mt76_rxq_id q, struct sk_buff *skb);
void mt76_tx(struct mt76_dev *dev, struct ieee80211_sta *sta,
struct mt76_wcid *wcid, struct sk_buff *skb);
diff --git a/drivers/net/wireless/mediatek/mt76/mt76x02.h b/drivers/net/wireless/mediatek/mt76/mt76x02.h
index 392b96fcb520..53ec8103a268 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76x02.h
+++ b/drivers/net/wireless/mediatek/mt76/mt76x02.h
@@ -163,7 +163,6 @@ void mt76x02_set_tx_ackto(struct mt76x02_dev *dev);
void mt76x02_set_coverage_class(struct ieee80211_hw *hw,
s16 coverage_class);
int mt76x02_set_rts_threshold(struct ieee80211_hw *hw, u32 val);
-int mt76x02_insert_hdr_pad(struct sk_buff *skb);
void mt76x02_remove_hdr_pad(struct sk_buff *skb, int len);
bool mt76x02_tx_status_data(struct mt76_dev *mdev, u8 *update);
void mt76x02_queue_rx_skb(struct mt76_dev *mdev, enum mt76_rxq_id q,
diff --git a/drivers/net/wireless/mediatek/mt76/mt76x02_txrx.c b/drivers/net/wireless/mediatek/mt76/mt76x02_txrx.c
index ce9ace11339d..f574866c7e9d 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76x02_txrx.c
+++ b/drivers/net/wireless/mediatek/mt76/mt76x02_txrx.c
@@ -165,7 +165,7 @@ int mt76x02_tx_prepare_skb(struct mt76_dev *mdev, void *txwi_ptr,
pid = mt76_tx_status_skb_add(mdev, wcid, skb);
txwi->pktid = pid;
- ret = mt76x02_insert_hdr_pad(skb);
+ ret = mt76_insert_hdr_pad(skb);
if (ret < 0)
return ret;
diff --git a/drivers/net/wireless/mediatek/mt76/mt76x02_usb_core.c b/drivers/net/wireless/mediatek/mt76/mt76x02_usb_core.c
index 8ab63255ba6f..6c3fc4cea283 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76x02_usb_core.c
+++ b/drivers/net/wireless/mediatek/mt76/mt76x02_usb_core.c
@@ -82,7 +82,7 @@ int mt76x02u_tx_prepare_skb(struct mt76_dev *mdev, void *data,
enum mt76_qsel qsel;
u32 flags;
- mt76x02_insert_hdr_pad(skb);
+ mt76_insert_hdr_pad(skb);
txwi = (struct mt76x02_txwi *)(skb->data - sizeof(struct mt76x02_txwi));
mt76x02_mac_write_txwi(dev, txwi, skb, wcid, sta, len);
diff --git a/drivers/net/wireless/mediatek/mt76/mt76x02_util.c b/drivers/net/wireless/mediatek/mt76/mt76x02_util.c
index b14a55737829..81d65319d3ea 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76x02_util.c
+++ b/drivers/net/wireless/mediatek/mt76/mt76x02_util.c
@@ -566,22 +566,6 @@ void mt76x02_sta_rate_tbl_update(struct ieee80211_hw *hw,
}
EXPORT_SYMBOL_GPL(mt76x02_sta_rate_tbl_update);
-int mt76x02_insert_hdr_pad(struct sk_buff *skb)
-{
- int len = ieee80211_get_hdrlen_from_skb(skb);
-
- if (len % 4 == 0)
- return 0;
-
- skb_push(skb, 2);
- memmove(skb->data, skb->data + 2, len);
-
- skb->data[len] = 0;
- skb->data[len + 1] = 0;
- return 2;
-}
-EXPORT_SYMBOL_GPL(mt76x02_insert_hdr_pad);
-
void mt76x02_remove_hdr_pad(struct sk_buff *skb, int len)
{
int hdrlen;
--
2.20.1
^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [PATCH 1/4] mt76: move mt76x02_insert_hdr_pad in mt76-core module
2019-03-11 12:35 ` [PATCH 1/4] mt76: move mt76x02_insert_hdr_pad in mt76-core module Lorenzo Bianconi
@ 2019-03-11 13:30 ` Stanislaw Gruszka
2019-03-11 14:02 ` Lorenzo Bianconi
0 siblings, 1 reply; 12+ messages in thread
From: Stanislaw Gruszka @ 2019-03-11 13:30 UTC (permalink / raw)
To: Lorenzo Bianconi
Cc: nbd, ryder.lee, roychl666, linux-wireless, lorenzo.bianconi
On Mon, Mar 11, 2019 at 01:35:23PM +0100, Lorenzo Bianconi wrote:
> +static inline int mt76_insert_hdr_pad(struct sk_buff *skb)
> +{
> + int len = ieee80211_get_hdrlen_from_skb(skb);
> +
> + if (len % 4 == 0)
> + return 0;
> +
> + skb_push(skb, 2);
> + memmove(skb->data, skb->data + 2, len);
> +
> + skb->data[len] = 0;
> + skb->data[len + 1] = 0;
> + return 2;
> +}
<snip>
> @@ -165,7 +165,7 @@ int mt76x02_tx_prepare_skb(struct mt76_dev *mdev, void *txwi_ptr,
> pid = mt76_tx_status_skb_add(mdev, wcid, skb);
> txwi->pktid = pid;
>
> - ret = mt76x02_insert_hdr_pad(skb);
> + ret = mt76_insert_hdr_pad(skb);
> if (ret < 0)
> return ret;
Since you modify this you can make mt76_inser_hdr_pad() return
void since we do not return error any longer.
Stanislaw
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 1/4] mt76: move mt76x02_insert_hdr_pad in mt76-core module
2019-03-11 13:30 ` Stanislaw Gruszka
@ 2019-03-11 14:02 ` Lorenzo Bianconi
0 siblings, 0 replies; 12+ messages in thread
From: Lorenzo Bianconi @ 2019-03-11 14:02 UTC (permalink / raw)
To: Stanislaw Gruszka
Cc: Lorenzo Bianconi, nbd, ryder.lee, roychl666, linux-wireless
[-- Attachment #1: Type: text/plain, Size: 904 bytes --]
> On Mon, Mar 11, 2019 at 01:35:23PM +0100, Lorenzo Bianconi wrote:
> > +static inline int mt76_insert_hdr_pad(struct sk_buff *skb)
> > +{
> > + int len = ieee80211_get_hdrlen_from_skb(skb);
> > +
> > + if (len % 4 == 0)
> > + return 0;
> > +
> > + skb_push(skb, 2);
> > + memmove(skb->data, skb->data + 2, len);
> > +
> > + skb->data[len] = 0;
> > + skb->data[len + 1] = 0;
> > + return 2;
> > +}
> <snip>
> > @@ -165,7 +165,7 @@ int mt76x02_tx_prepare_skb(struct mt76_dev *mdev, void *txwi_ptr,
> > pid = mt76_tx_status_skb_add(mdev, wcid, skb);
> > txwi->pktid = pid;
> >
> > - ret = mt76x02_insert_hdr_pad(skb);
> > + ret = mt76_insert_hdr_pad(skb);
> > if (ret < 0)
> > return ret;
>
> Since you modify this you can make mt76_inser_hdr_pad() return
> void since we do not return error any longer.
ack, will do in v2
Regards,
Lorenzo
>
> Stanislaw
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH 2/4] mt76: mmio: move mt76_insert_hdr_pad in mt76_dma_tx_queue_skb
2019-03-11 12:35 [PATCH 0/4] move skb mapping before configuring txwi Lorenzo Bianconi
2019-03-11 12:35 ` [PATCH 1/4] mt76: move mt76x02_insert_hdr_pad in mt76-core module Lorenzo Bianconi
@ 2019-03-11 12:35 ` Lorenzo Bianconi
2019-03-11 13:39 ` Stanislaw Gruszka
2019-03-11 12:35 ` [PATCH 3/4] mt76: move skb dma mapping before running tx_prepare_skb Lorenzo Bianconi
` (2 subsequent siblings)
4 siblings, 1 reply; 12+ messages in thread
From: Lorenzo Bianconi @ 2019-03-11 12:35 UTC (permalink / raw)
To: nbd; +Cc: ryder.lee, roychl666, linux-wireless, lorenzo.bianconi
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);
+
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,
--
2.20.1
^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [PATCH 2/4] mt76: mmio: move mt76_insert_hdr_pad in mt76_dma_tx_queue_skb
2019-03-11 12:35 ` [PATCH 2/4] mt76: mmio: move mt76_insert_hdr_pad in mt76_dma_tx_queue_skb Lorenzo Bianconi
@ 2019-03-11 13:39 ` Stanislaw Gruszka
2019-03-11 14:25 ` Lorenzo Bianconi
0 siblings, 1 reply; 12+ messages in thread
From: Stanislaw Gruszka @ 2019-03-11 13:39 UTC (permalink / raw)
To: Lorenzo Bianconi
Cc: nbd, ryder.lee, roychl666, linux-wireless, lorenzo.bianconi
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
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 2/4] mt76: mmio: move mt76_insert_hdr_pad in mt76_dma_tx_queue_skb
2019-03-11 13:39 ` Stanislaw Gruszka
@ 2019-03-11 14:25 ` Lorenzo Bianconi
2019-03-11 14:58 ` Stanislaw Gruszka
0 siblings, 1 reply; 12+ messages in thread
From: Lorenzo Bianconi @ 2019-03-11 14:25 UTC (permalink / raw)
To: Stanislaw Gruszka
Cc: Lorenzo Bianconi, nbd, ryder.lee, roychl666, linux-wireless
[-- Attachment #1: Type: text/plain, Size: 1482 bytes --]
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
>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 2/4] mt76: mmio: move mt76_insert_hdr_pad in mt76_dma_tx_queue_skb
2019-03-11 14:25 ` Lorenzo Bianconi
@ 2019-03-11 14:58 ` Stanislaw Gruszka
2019-03-11 15:01 ` Lorenzo Bianconi
0 siblings, 1 reply; 12+ messages in thread
From: Stanislaw Gruszka @ 2019-03-11 14:58 UTC (permalink / raw)
To: Lorenzo Bianconi
Cc: Lorenzo Bianconi, nbd, ryder.lee, roychl666, linux-wireless
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
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 2/4] mt76: mmio: move mt76_insert_hdr_pad in mt76_dma_tx_queue_skb
2019-03-11 14:58 ` Stanislaw Gruszka
@ 2019-03-11 15:01 ` Lorenzo Bianconi
0 siblings, 0 replies; 12+ messages in thread
From: Lorenzo Bianconi @ 2019-03-11 15:01 UTC (permalink / raw)
To: Stanislaw Gruszka
Cc: Lorenzo Bianconi, nbd, ryder.lee, roychl666, linux-wireless
[-- Attachment #1: Type: text/plain, Size: 2052 bytes --]
> 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
>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH 3/4] mt76: move skb dma mapping before running tx_prepare_skb
2019-03-11 12:35 [PATCH 0/4] move skb mapping before configuring txwi Lorenzo Bianconi
2019-03-11 12:35 ` [PATCH 1/4] mt76: move mt76x02_insert_hdr_pad in mt76-core module Lorenzo Bianconi
2019-03-11 12:35 ` [PATCH 2/4] mt76: mmio: move mt76_insert_hdr_pad in mt76_dma_tx_queue_skb Lorenzo Bianconi
@ 2019-03-11 12:35 ` Lorenzo Bianconi
2019-03-11 12:35 ` [PATCH 4/4] mt76: introduce mt76_tx_info data structure Lorenzo Bianconi
2019-03-11 13:17 ` [PATCH 0/4] move skb mapping before configuring txwi Lorenzo Bianconi
4 siblings, 0 replies; 12+ messages in thread
From: Lorenzo Bianconi @ 2019-03-11 12:35 UTC (permalink / raw)
To: nbd; +Cc: ryder.lee, roychl666, linux-wireless, lorenzo.bianconi
Move skb dma mapping before configuring txwi since new chipsets (mt7615)
will need skb dma addresses in order to properly configure txwi
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
---
drivers/net/wireless/mediatek/mt76/dma.c | 29 ++++++++++--------------
1 file changed, 12 insertions(+), 17 deletions(-)
diff --git a/drivers/net/wireless/mediatek/mt76/dma.c b/drivers/net/wireless/mediatek/mt76/dma.c
index 14dd6585bab4..a29b2aa95a51 100644
--- a/drivers/net/wireless/mediatek/mt76/dma.c
+++ b/drivers/net/wireless/mediatek/mt76/dma.c
@@ -287,11 +287,10 @@ mt76_dma_tx_queue_skb(struct mt76_dev *dev, enum mt76_txq_id qid,
struct mt76_queue_entry e;
struct mt76_txwi_cache *t;
struct mt76_queue_buf buf[32];
+ int len, n = 0, ret = -ENOMEM;
struct sk_buff *iter;
dma_addr_t addr;
- int len;
u32 tx_info = 0;
- int n, ret;
t = mt76_get_txwi(dev);
if (!t) {
@@ -303,23 +302,11 @@ mt76_dma_tx_queue_skb(struct mt76_dev *dev, enum mt76_txq_id qid,
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,
- &tx_info);
- dma_sync_single_for_device(dev->dev, t->dma_addr, sizeof(t->txwi),
- DMA_TO_DEVICE);
- if (ret < 0)
- goto free;
-
- len = skb->len - skb->data_len;
+ len = skb_headlen(skb);
addr = dma_map_single(dev->dev, skb->data, len, DMA_TO_DEVICE);
- if (dma_mapping_error(dev->dev, addr)) {
- ret = -ENOMEM;
+ if (dma_mapping_error(dev->dev, addr))
goto free;
- }
- n = 0;
buf[n].addr = t->dma_addr;
buf[n++].len = dev->drv->txwi_size;
buf[n].addr = addr;
@@ -341,10 +328,18 @@ mt76_dma_tx_queue_skb(struct mt76_dev *dev, enum mt76_txq_id qid,
if (q->queued + (n + 1) / 2 >= q->ndesc - 1)
goto unmap;
+ 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,
+ &tx_info);
+ dma_sync_single_for_device(dev->dev, t->dma_addr, sizeof(t->txwi),
+ DMA_TO_DEVICE);
+ if (ret < 0)
+ goto unmap;
+
return mt76_dma_add_buf(dev, q, buf, n, tx_info, skb, t);
unmap:
- ret = -ENOMEM;
for (n--; n > 0; n--)
dma_unmap_single(dev->dev, buf[n].addr, buf[n].len,
DMA_TO_DEVICE);
--
2.20.1
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH 4/4] mt76: introduce mt76_tx_info data structure
2019-03-11 12:35 [PATCH 0/4] move skb mapping before configuring txwi Lorenzo Bianconi
` (2 preceding siblings ...)
2019-03-11 12:35 ` [PATCH 3/4] mt76: move skb dma mapping before running tx_prepare_skb Lorenzo Bianconi
@ 2019-03-11 12:35 ` Lorenzo Bianconi
2019-03-11 13:17 ` [PATCH 0/4] move skb mapping before configuring txwi Lorenzo Bianconi
4 siblings, 0 replies; 12+ messages in thread
From: Lorenzo Bianconi @ 2019-03-11 12:35 UTC (permalink / raw)
To: nbd; +Cc: ryder.lee, roychl666, linux-wireless, lorenzo.bianconi
Add mt76_tx_info as auxiliary data structure to pass values
to tx_prepare_skb pointer. This is a preliminary patch to add
support for new chipsets (e.g. mt7615)
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
---
drivers/net/wireless/mediatek/mt76/dma.c | 27 ++++++++++---------
drivers/net/wireless/mediatek/mt76/mt76.h | 9 ++++++-
.../net/wireless/mediatek/mt76/mt7603/mac.c | 2 +-
.../wireless/mediatek/mt76/mt7603/mt7603.h | 2 +-
drivers/net/wireless/mediatek/mt76/mt76x02.h | 2 +-
.../net/wireless/mediatek/mt76/mt76x02_txrx.c | 8 +++---
.../net/wireless/mediatek/mt76/mt76x02_usb.h | 2 +-
.../wireless/mediatek/mt76/mt76x02_usb_core.c | 2 +-
8 files changed, 31 insertions(+), 23 deletions(-)
diff --git a/drivers/net/wireless/mediatek/mt76/dma.c b/drivers/net/wireless/mediatek/mt76/dma.c
index a29b2aa95a51..e1ff31205b11 100644
--- a/drivers/net/wireless/mediatek/mt76/dma.c
+++ b/drivers/net/wireless/mediatek/mt76/dma.c
@@ -284,13 +284,12 @@ mt76_dma_tx_queue_skb(struct mt76_dev *dev, enum mt76_txq_id qid,
struct ieee80211_sta *sta)
{
struct mt76_queue *q = dev->q_tx[qid].q;
+ struct mt76_tx_info tx_info = {};
+ int len, n = 0, ret = -ENOMEM;
struct mt76_queue_entry e;
struct mt76_txwi_cache *t;
- struct mt76_queue_buf buf[32];
- int len, n = 0, ret = -ENOMEM;
struct sk_buff *iter;
dma_addr_t addr;
- u32 tx_info = 0;
t = mt76_get_txwi(dev);
if (!t) {
@@ -307,13 +306,13 @@ mt76_dma_tx_queue_skb(struct mt76_dev *dev, enum mt76_txq_id qid,
if (dma_mapping_error(dev->dev, addr))
goto free;
- buf[n].addr = t->dma_addr;
- buf[n++].len = dev->drv->txwi_size;
- buf[n].addr = addr;
- buf[n++].len = len;
+ tx_info.buf[n].addr = t->dma_addr;
+ tx_info.buf[n++].len = dev->drv->txwi_size;
+ tx_info.buf[n].addr = addr;
+ tx_info.buf[n++].len = len;
skb_walk_frags(skb, iter) {
- if (n == ARRAY_SIZE(buf))
+ if (n == ARRAY_SIZE(tx_info.buf))
goto unmap;
addr = dma_map_single(dev->dev, iter->data, iter->len,
@@ -321,9 +320,10 @@ mt76_dma_tx_queue_skb(struct mt76_dev *dev, enum mt76_txq_id qid,
if (dma_mapping_error(dev->dev, addr))
goto unmap;
- buf[n].addr = addr;
- buf[n++].len = iter->len;
+ tx_info.buf[n].addr = addr;
+ tx_info.buf[n++].len = iter->len;
}
+ tx_info.nbuf = n;
if (q->queued + (n + 1) / 2 >= q->ndesc - 1)
goto unmap;
@@ -337,12 +337,13 @@ mt76_dma_tx_queue_skb(struct mt76_dev *dev, enum mt76_txq_id qid,
if (ret < 0)
goto unmap;
- return mt76_dma_add_buf(dev, q, buf, n, tx_info, skb, t);
+ return mt76_dma_add_buf(dev, q, tx_info.buf, tx_info.nbuf,
+ tx_info.info, skb, t);
unmap:
for (n--; n > 0; n--)
- dma_unmap_single(dev->dev, buf[n].addr, buf[n].len,
- DMA_TO_DEVICE);
+ dma_unmap_single(dev->dev, tx_info.buf[n].addr,
+ tx_info.buf[n].len, DMA_TO_DEVICE);
free:
e.skb = skb;
diff --git a/drivers/net/wireless/mediatek/mt76/mt76.h b/drivers/net/wireless/mediatek/mt76/mt76.h
index dc505d55409c..9573a283e29f 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76.h
+++ b/drivers/net/wireless/mediatek/mt76/mt76.h
@@ -83,6 +83,12 @@ struct mt76_queue_buf {
int len;
};
+struct mt76_tx_info {
+ struct mt76_queue_buf buf[32];
+ int nbuf;
+ u32 info;
+};
+
struct mt76u_buf {
struct mt76_dev *dev;
struct urb *urb;
@@ -296,7 +302,8 @@ struct mt76_driver_ops {
int (*tx_prepare_skb)(struct mt76_dev *dev, void *txwi_ptr,
struct sk_buff *skb, enum mt76_txq_id qid,
struct mt76_wcid *wcid,
- struct ieee80211_sta *sta, u32 *tx_info);
+ struct ieee80211_sta *sta,
+ struct mt76_tx_info *tx_info);
void (*tx_complete_skb)(struct mt76_dev *dev, enum mt76_txq_id qid,
struct mt76_queue_entry *e);
diff --git a/drivers/net/wireless/mediatek/mt76/mt7603/mac.c b/drivers/net/wireless/mediatek/mt76/mt7603/mac.c
index 1ff4c10b291c..5f800467c628 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7603/mac.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7603/mac.c
@@ -939,7 +939,7 @@ mt7603_mac_write_txwi(struct mt7603_dev *dev, __le32 *txwi,
int mt7603_tx_prepare_skb(struct mt76_dev *mdev, void *txwi_ptr,
struct sk_buff *skb, enum mt76_txq_id qid,
struct mt76_wcid *wcid, struct ieee80211_sta *sta,
- u32 *tx_info)
+ struct mt76_tx_info *tx_info)
{
struct mt7603_dev *dev = container_of(mdev, struct mt7603_dev, mt76);
struct mt7603_sta *msta = container_of(wcid, struct mt7603_sta, wcid);
diff --git a/drivers/net/wireless/mediatek/mt76/mt7603/mt7603.h b/drivers/net/wireless/mediatek/mt76/mt7603/mt7603.h
index 8bd00b97066a..f414ff2a5279 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7603/mt7603.h
+++ b/drivers/net/wireless/mediatek/mt76/mt7603/mt7603.h
@@ -225,7 +225,7 @@ void mt7603_filter_tx(struct mt7603_dev *dev, int idx, bool abort);
int mt7603_tx_prepare_skb(struct mt76_dev *mdev, void *txwi_ptr,
struct sk_buff *skb, enum mt76_txq_id qid,
struct mt76_wcid *wcid, struct ieee80211_sta *sta,
- u32 *tx_info);
+ struct mt76_tx_info *tx_info);
void mt7603_tx_complete_skb(struct mt76_dev *mdev, enum mt76_txq_id qid,
struct mt76_queue_entry *e);
diff --git a/drivers/net/wireless/mediatek/mt76/mt76x02.h b/drivers/net/wireless/mediatek/mt76/mt76x02.h
index 53ec8103a268..cb5792b41d2d 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76x02.h
+++ b/drivers/net/wireless/mediatek/mt76/mt76x02.h
@@ -174,7 +174,7 @@ void mt76x02_tx(struct ieee80211_hw *hw, struct ieee80211_tx_control *control,
int mt76x02_tx_prepare_skb(struct mt76_dev *mdev, void *txwi,
struct sk_buff *skb, enum mt76_txq_id qid,
struct mt76_wcid *wcid, struct ieee80211_sta *sta,
- u32 *tx_info);
+ struct mt76_tx_info *tx_info);
void mt76x02_sw_scan(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
const u8 *mac);
void mt76x02_sw_scan_complete(struct ieee80211_hw *hw,
diff --git a/drivers/net/wireless/mediatek/mt76/mt76x02_txrx.c b/drivers/net/wireless/mediatek/mt76/mt76x02_txrx.c
index 708f2c65d3fd..dd7d04b9b8db 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76x02_txrx.c
+++ b/drivers/net/wireless/mediatek/mt76/mt76x02_txrx.c
@@ -149,7 +149,7 @@ EXPORT_SYMBOL_GPL(mt76x02_tx_status_data);
int mt76x02_tx_prepare_skb(struct mt76_dev *mdev, void *txwi_ptr,
struct sk_buff *skb, enum mt76_txq_id qid,
struct mt76_wcid *wcid, struct ieee80211_sta *sta,
- u32 *tx_info)
+ struct mt76_tx_info *tx_info)
{
struct mt76x02_dev *dev = container_of(mdev, struct mt76x02_dev, mt76);
struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
@@ -169,11 +169,11 @@ int mt76x02_tx_prepare_skb(struct mt76_dev *mdev, void *txwi_ptr,
if (pid >= MT_PACKET_ID_FIRST)
qsel = MT_QSEL_MGMT;
- *tx_info = FIELD_PREP(MT_TXD_INFO_QSEL, qsel) |
- MT_TXD_INFO_80211;
+ tx_info->info = FIELD_PREP(MT_TXD_INFO_QSEL, qsel) |
+ MT_TXD_INFO_80211;
if (!wcid || wcid->hw_key_idx == 0xff || wcid->sw_iv)
- *tx_info |= MT_TXD_INFO_WIV;
+ tx_info->info |= MT_TXD_INFO_WIV;
return 0;
}
diff --git a/drivers/net/wireless/mediatek/mt76/mt76x02_usb.h b/drivers/net/wireless/mediatek/mt76/mt76x02_usb.h
index 98e647c8c7c7..8f98cc6ce094 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76x02_usb.h
+++ b/drivers/net/wireless/mediatek/mt76/mt76x02_usb.h
@@ -28,7 +28,7 @@ int mt76x02u_skb_dma_info(struct sk_buff *skb, int port, u32 flags);
int mt76x02u_tx_prepare_skb(struct mt76_dev *mdev, void *data,
struct sk_buff *skb, enum mt76_txq_id qid,
struct mt76_wcid *wcid, struct ieee80211_sta *sta,
- u32 *tx_info);
+ struct mt76_tx_info *tx_info);
void mt76x02u_tx_complete_skb(struct mt76_dev *mdev, enum mt76_txq_id qid,
struct mt76_queue_entry *e);
#endif /* __MT76x02_USB_H */
diff --git a/drivers/net/wireless/mediatek/mt76/mt76x02_usb_core.c b/drivers/net/wireless/mediatek/mt76/mt76x02_usb_core.c
index 6c3fc4cea283..394dfe5b4a2e 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76x02_usb_core.c
+++ b/drivers/net/wireless/mediatek/mt76/mt76x02_usb_core.c
@@ -74,7 +74,7 @@ int mt76x02u_skb_dma_info(struct sk_buff *skb, int port, u32 flags)
int mt76x02u_tx_prepare_skb(struct mt76_dev *mdev, void *data,
struct sk_buff *skb, enum mt76_txq_id qid,
struct mt76_wcid *wcid, struct ieee80211_sta *sta,
- u32 *tx_info)
+ struct mt76_tx_info *tx_info)
{
struct mt76x02_dev *dev = container_of(mdev, struct mt76x02_dev, mt76);
int pid, len = skb->len, ep = q2ep(mdev->q_tx[qid].q->hw_idx);
--
2.20.1
^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [PATCH 0/4] move skb mapping before configuring txwi
2019-03-11 12:35 [PATCH 0/4] move skb mapping before configuring txwi Lorenzo Bianconi
` (3 preceding siblings ...)
2019-03-11 12:35 ` [PATCH 4/4] mt76: introduce mt76_tx_info data structure Lorenzo Bianconi
@ 2019-03-11 13:17 ` Lorenzo Bianconi
4 siblings, 0 replies; 12+ messages in thread
From: Lorenzo Bianconi @ 2019-03-11 13:17 UTC (permalink / raw)
To: Lorenzo Bianconi; +Cc: nbd, ryder.lee, roychl666, linux-wireless
[-- Attachment #1: Type: text/plain, Size: 1506 bytes --]
> Move skb dma mapping before configuring txwi since new chipsets
> (e.g. mt7615) will need dma addresses to properly configure txwi.
> Introduce temporary tx_aligned4_skbs variable in order to tell mt76 layer
> if it is necessary to align the 802.11 header (it will be removed as soon
> as mac80211 will take care of it)
>
> Lorenzo Bianconi (4):
> mt76: move mt76x02_insert_hdr_pad in mt76-core module
> mt76: mmio: move mt76_insert_hdr_pad in mt76_dma_tx_queue_skb
> mt76: move skb dma mapping before running tx_prepare_skb
> mt76: introduce mt76_tx_info data structure
>
> drivers/net/wireless/mediatek/mt76/dma.c | 55 +++++++++----------
> drivers/net/wireless/mediatek/mt76/mt76.h | 25 ++++++++-
> .../net/wireless/mediatek/mt76/mt7603/mac.c | 2 +-
> .../wireless/mediatek/mt76/mt7603/mt7603.h | 2 +-
> .../net/wireless/mediatek/mt76/mt76x0/pci.c | 1 +
> drivers/net/wireless/mediatek/mt76/mt76x02.h | 3 +-
> .../net/wireless/mediatek/mt76/mt76x02_txrx.c | 21 +++----
> .../net/wireless/mediatek/mt76/mt76x02_usb.h | 2 +-
> .../wireless/mediatek/mt76/mt76x02_usb_core.c | 4 +-
> .../net/wireless/mediatek/mt76/mt76x02_util.c | 16 ------
> .../net/wireless/mediatek/mt76/mt76x2/pci.c | 1 +
> 11 files changed, 68 insertions(+), 64 deletions(-)
I forgot to mention this series is based on:
'introduce mt76_sw_queue data structure'
https://patchwork.kernel.org/cover/10836583/
Regards,
Lorenzo
>
> --
> 2.20.1
>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
^ permalink raw reply [flat|nested] 12+ messages in thread