2022-11-21 03:04:04

by Sujuan Chen (陈素娟)

[permalink] [raw]
Subject: [PATCH] net: ethernet: mtk_wed: add wcid overwritten support for wed v1

All wed versions should enable wcid overwritten feature,
since the wcid size is controlled by the wlan driver.

Tested-by: Sujuan Chen <[email protected]>
Co-developed-by: Bo Jiao <[email protected]>
Signed-off-by: Bo Jiao <[email protected]>
Signed-off-by: Sujuan Chen <[email protected]>
---
drivers/net/ethernet/mediatek/mtk_wed.c | 9 ++++++---
drivers/net/ethernet/mediatek/mtk_wed_regs.h | 2 ++
include/linux/soc/mediatek/mtk_wed.h | 3 +++
3 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/mediatek/mtk_wed.c b/drivers/net/ethernet/mediatek/mtk_wed.c
index 7d8842378c2b..a20093803e04 100644
--- a/drivers/net/ethernet/mediatek/mtk_wed.c
+++ b/drivers/net/ethernet/mediatek/mtk_wed.c
@@ -526,9 +526,9 @@ mtk_wed_dma_disable(struct mtk_wed_device *dev)
MTK_WED_WPDMA_RX_D_RX_DRV_EN);
wed_clr(dev, MTK_WED_WDMA_GLO_CFG,
MTK_WED_WDMA_GLO_CFG_TX_DDONE_CHK);
-
- mtk_wed_set_512_support(dev, false);
}
+
+ mtk_wed_set_512_support(dev, false);
}

static void
@@ -1290,9 +1290,10 @@ mtk_wed_start(struct mtk_wed_device *dev, u32 irq_mask)
if (mtk_wed_rro_cfg(dev))
return;

- mtk_wed_set_512_support(dev, dev->wlan.wcid_512);
}

+ mtk_wed_set_512_support(dev, dev->wlan.wcid_512);
+
mtk_wed_dma_enable(dev);
dev->running = true;
}
@@ -1338,6 +1339,8 @@ mtk_wed_attach(struct mtk_wed_device *dev)
dev->irq = hw->irq;
dev->wdma_idx = hw->index;
dev->version = hw->version;
+ if (hw->version != 1)
+ dev->rev_id = wed_r32(dev, MTK_WED_REV_ID);

if (hw->eth->dma_dev == hw->eth->dev &&
of_dma_is_coherent(hw->eth->dev->of_node))
diff --git a/drivers/net/ethernet/mediatek/mtk_wed_regs.h b/drivers/net/ethernet/mediatek/mtk_wed_regs.h
index 9e39dace95eb..873d50b9a6e6 100644
--- a/drivers/net/ethernet/mediatek/mtk_wed_regs.h
+++ b/drivers/net/ethernet/mediatek/mtk_wed_regs.h
@@ -20,6 +20,8 @@ struct mtk_wdma_desc {
__le32 info;
} __packed __aligned(4);

+#define MTK_WED_REV_ID 0x004
+
#define MTK_WED_RESET 0x008
#define MTK_WED_RESET_TX_BM BIT(0)
#define MTK_WED_RESET_TX_FREE_AGENT BIT(4)
diff --git a/include/linux/soc/mediatek/mtk_wed.h b/include/linux/soc/mediatek/mtk_wed.h
index 8294978f4bca..1b1ef57609f7 100644
--- a/include/linux/soc/mediatek/mtk_wed.h
+++ b/include/linux/soc/mediatek/mtk_wed.h
@@ -85,6 +85,9 @@ struct mtk_wed_device {
int irq;
u8 version;

+ /* used by wlan driver */
+ u32 rev_id;
+
struct mtk_wed_ring tx_ring[MTK_WED_TX_QUEUES];
struct mtk_wed_ring rx_ring[MTK_WED_RX_QUEUES];
struct mtk_wed_ring txfree_ring;
--
2.18.0



2022-11-21 10:09:26

by Lorenzo Bianconi

[permalink] [raw]
Subject: Re: [PATCH] net: ethernet: mtk_wed: add wcid overwritten support for wed v1

> All wed versions should enable wcid overwritten feature,
> since the wcid size is controlled by the wlan driver.
>

I guess this patch should be posted to netdev mailing list
([email protected]) since it should go through net-next tree.

Regards,
Lorenzo

> Tested-by: Sujuan Chen <[email protected]>
> Co-developed-by: Bo Jiao <[email protected]>
> Signed-off-by: Bo Jiao <[email protected]>
> Signed-off-by: Sujuan Chen <[email protected]>
> ---
> drivers/net/ethernet/mediatek/mtk_wed.c | 9 ++++++---
> drivers/net/ethernet/mediatek/mtk_wed_regs.h | 2 ++
> include/linux/soc/mediatek/mtk_wed.h | 3 +++
> 3 files changed, 11 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/net/ethernet/mediatek/mtk_wed.c b/drivers/net/ethernet/mediatek/mtk_wed.c
> index 7d8842378c2b..a20093803e04 100644
> --- a/drivers/net/ethernet/mediatek/mtk_wed.c
> +++ b/drivers/net/ethernet/mediatek/mtk_wed.c
> @@ -526,9 +526,9 @@ mtk_wed_dma_disable(struct mtk_wed_device *dev)
> MTK_WED_WPDMA_RX_D_RX_DRV_EN);
> wed_clr(dev, MTK_WED_WDMA_GLO_CFG,
> MTK_WED_WDMA_GLO_CFG_TX_DDONE_CHK);
> -
> - mtk_wed_set_512_support(dev, false);
> }
> +
> + mtk_wed_set_512_support(dev, false);
> }
>
> static void
> @@ -1290,9 +1290,10 @@ mtk_wed_start(struct mtk_wed_device *dev, u32 irq_mask)
> if (mtk_wed_rro_cfg(dev))
> return;
>
> - mtk_wed_set_512_support(dev, dev->wlan.wcid_512);
> }
>
> + mtk_wed_set_512_support(dev, dev->wlan.wcid_512);
> +
> mtk_wed_dma_enable(dev);
> dev->running = true;
> }
> @@ -1338,6 +1339,8 @@ mtk_wed_attach(struct mtk_wed_device *dev)
> dev->irq = hw->irq;
> dev->wdma_idx = hw->index;
> dev->version = hw->version;
> + if (hw->version != 1)
> + dev->rev_id = wed_r32(dev, MTK_WED_REV_ID);
>
> if (hw->eth->dma_dev == hw->eth->dev &&
> of_dma_is_coherent(hw->eth->dev->of_node))
> diff --git a/drivers/net/ethernet/mediatek/mtk_wed_regs.h b/drivers/net/ethernet/mediatek/mtk_wed_regs.h
> index 9e39dace95eb..873d50b9a6e6 100644
> --- a/drivers/net/ethernet/mediatek/mtk_wed_regs.h
> +++ b/drivers/net/ethernet/mediatek/mtk_wed_regs.h
> @@ -20,6 +20,8 @@ struct mtk_wdma_desc {
> __le32 info;
> } __packed __aligned(4);
>
> +#define MTK_WED_REV_ID 0x004
> +
> #define MTK_WED_RESET 0x008
> #define MTK_WED_RESET_TX_BM BIT(0)
> #define MTK_WED_RESET_TX_FREE_AGENT BIT(4)
> diff --git a/include/linux/soc/mediatek/mtk_wed.h b/include/linux/soc/mediatek/mtk_wed.h
> index 8294978f4bca..1b1ef57609f7 100644
> --- a/include/linux/soc/mediatek/mtk_wed.h
> +++ b/include/linux/soc/mediatek/mtk_wed.h
> @@ -85,6 +85,9 @@ struct mtk_wed_device {
> int irq;
> u8 version;
>
> + /* used by wlan driver */
> + u32 rev_id;
> +
> struct mtk_wed_ring tx_ring[MTK_WED_TX_QUEUES];
> struct mtk_wed_ring rx_ring[MTK_WED_RX_QUEUES];
> struct mtk_wed_ring txfree_ring;
> --
> 2.18.0
>


Attachments:
(No filename) (2.93 kB)
signature.asc (235.00 B)
Download all attachments

2022-11-22 10:11:52

by Lorenzo Bianconi

[permalink] [raw]
Subject: Re: [PATCH,RESEND] net: ethernet: mtk_wed: add wcid overwritten support for wed v1

> All wed versions should enable wcid overwritten feature,
> since the wcid size is controlled by the wlan driver.
>
> Tested-by: Sujuan Chen <[email protected]>
> Co-developed-by: Bo Jiao <[email protected]>
> Signed-off-by: Bo Jiao <[email protected]>
> Signed-off-by: Sujuan Chen <[email protected]>
> ---
> drivers/net/ethernet/mediatek/mtk_wed.c | 9 ++++++---
> drivers/net/ethernet/mediatek/mtk_wed_regs.h | 2 ++
> include/linux/soc/mediatek/mtk_wed.h | 3 +++
> 3 files changed, 11 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/net/ethernet/mediatek/mtk_wed.c b/drivers/net/ethernet/mediatek/mtk_wed.c
> index 7d8842378c2b..a20093803e04 100644
> --- a/drivers/net/ethernet/mediatek/mtk_wed.c
> +++ b/drivers/net/ethernet/mediatek/mtk_wed.c
> @@ -526,9 +526,9 @@ mtk_wed_dma_disable(struct mtk_wed_device *dev)
> MTK_WED_WPDMA_RX_D_RX_DRV_EN);
> wed_clr(dev, MTK_WED_WDMA_GLO_CFG,
> MTK_WED_WDMA_GLO_CFG_TX_DDONE_CHK);
> -
> - mtk_wed_set_512_support(dev, false);
> }
> +
> + mtk_wed_set_512_support(dev, false);
> }
>
> static void
> @@ -1290,9 +1290,10 @@ mtk_wed_start(struct mtk_wed_device *dev, u32 irq_mask)
> if (mtk_wed_rro_cfg(dev))
> return;
>
> - mtk_wed_set_512_support(dev, dev->wlan.wcid_512);
> }
>
> + mtk_wed_set_512_support(dev, dev->wlan.wcid_512);
> +
> mtk_wed_dma_enable(dev);
> dev->running = true;
> }
> @@ -1338,6 +1339,8 @@ mtk_wed_attach(struct mtk_wed_device *dev)
> dev->irq = hw->irq;
> dev->wdma_idx = hw->index;
> dev->version = hw->version;
> + if (hw->version != 1)
> + dev->rev_id = wed_r32(dev, MTK_WED_REV_ID);

nitpick: since rev_id is valid just for hw->version > 1 and it will be used by
mt76 in the future, you can move it few lines below where we already check
hw->version and get rid of the unnecessary if condition. Something like:

if (hw->version == 1) {
...
} else {
dev->rev_id = wed_r32(dev, MTK_WED_REV_ID);
ret = mtk_wed_wo_init(hw);
}

Regards,
Lorenzo
>
> if (hw->eth->dma_dev == hw->eth->dev &&
> of_dma_is_coherent(hw->eth->dev->of_node))
> diff --git a/drivers/net/ethernet/mediatek/mtk_wed_regs.h b/drivers/net/ethernet/mediatek/mtk_wed_regs.h
> index 9e39dace95eb..873d50b9a6e6 100644
> --- a/drivers/net/ethernet/mediatek/mtk_wed_regs.h
> +++ b/drivers/net/ethernet/mediatek/mtk_wed_regs.h
> @@ -20,6 +20,8 @@ struct mtk_wdma_desc {
> __le32 info;
> } __packed __aligned(4);
>
> +#define MTK_WED_REV_ID 0x004
> +
> #define MTK_WED_RESET 0x008
> #define MTK_WED_RESET_TX_BM BIT(0)
> #define MTK_WED_RESET_TX_FREE_AGENT BIT(4)
> diff --git a/include/linux/soc/mediatek/mtk_wed.h b/include/linux/soc/mediatek/mtk_wed.h
> index 8294978f4bca..1b1ef57609f7 100644
> --- a/include/linux/soc/mediatek/mtk_wed.h
> +++ b/include/linux/soc/mediatek/mtk_wed.h
> @@ -85,6 +85,9 @@ struct mtk_wed_device {
> int irq;
> u8 version;
>
> + /* used by wlan driver */
> + u32 rev_id;
> +
> struct mtk_wed_ring tx_ring[MTK_WED_TX_QUEUES];
> struct mtk_wed_ring rx_ring[MTK_WED_RX_QUEUES];
> struct mtk_wed_ring txfree_ring;
> --
> 2.18.0
>


Attachments:
(No filename) (3.15 kB)
signature.asc (235.00 B)
Download all attachments

2022-11-23 04:02:45

by Sujuan Chen (陈素娟)

[permalink] [raw]
Subject: Re: [PATCH,RESEND] net: ethernet: mtk_wed: add wcid overwritten support for wed v1

On Tue, 2022-11-22 at 10:46 +0100, Lorenzo Bianconi wrote:
> > All wed versions should enable wcid overwritten feature,
> > since the wcid size is controlled by the wlan driver.
> >
> > Tested-by: Sujuan Chen <[email protected]>
> > Co-developed-by: Bo Jiao <[email protected]>
> > Signed-off-by: Bo Jiao <[email protected]>
> > Signed-off-by: Sujuan Chen <[email protected]>
> > ---
> > drivers/net/ethernet/mediatek/mtk_wed.c | 9 ++++++---
> > drivers/net/ethernet/mediatek/mtk_wed_regs.h | 2 ++
> > include/linux/soc/mediatek/mtk_wed.h | 3 +++
> > 3 files changed, 11 insertions(+), 3 deletions(-)
> >
> > diff --git a/drivers/net/ethernet/mediatek/mtk_wed.c
> > b/drivers/net/ethernet/mediatek/mtk_wed.c
> > index 7d8842378c2b..a20093803e04 100644
> > --- a/drivers/net/ethernet/mediatek/mtk_wed.c
> > +++ b/drivers/net/ethernet/mediatek/mtk_wed.c
> > @@ -526,9 +526,9 @@ mtk_wed_dma_disable(struct mtk_wed_device *dev)
> > MTK_WED_WPDMA_RX_D_RX_DRV_EN);
> > wed_clr(dev, MTK_WED_WDMA_GLO_CFG,
> > MTK_WED_WDMA_GLO_CFG_TX_DDONE_CHK);
> > -
> > - mtk_wed_set_512_support(dev, false);
> > }
> > +
> > + mtk_wed_set_512_support(dev, false);
> > }
> >
> > static void
> > @@ -1290,9 +1290,10 @@ mtk_wed_start(struct mtk_wed_device *dev,
> > u32 irq_mask)
> > if (mtk_wed_rro_cfg(dev))
> > return;
> >
> > - mtk_wed_set_512_support(dev, dev->wlan.wcid_512);
> > }
> >
> > + mtk_wed_set_512_support(dev, dev->wlan.wcid_512);
> > +
> > mtk_wed_dma_enable(dev);
> > dev->running = true;
> > }
> > @@ -1338,6 +1339,8 @@ mtk_wed_attach(struct mtk_wed_device *dev)
> > dev->irq = hw->irq;
> > dev->wdma_idx = hw->index;
> > dev->version = hw->version;
> > + if (hw->version != 1)
> > + dev->rev_id = wed_r32(dev, MTK_WED_REV_ID);
>
> nitpick: since rev_id is valid just for hw->version > 1 and it will
> be used by
> mt76 in the future, you can move it few lines below where we already
> check
> hw->version and get rid of the unnecessary if condition. Something
> like:
>
> if (hw->version == 1) {
> ...
> } else {
> dev->rev_id = wed_r32(dev, MTK_WED_REV_ID);
> ret = mtk_wed_wo_init(hw);
> }
>
Ack, I will move it in v2

> Regards,
> Lorenzo
> >
> > if (hw->eth->dma_dev == hw->eth->dev &&
> > of_dma_is_coherent(hw->eth->dev->of_node))
> > diff --git a/drivers/net/ethernet/mediatek/mtk_wed_regs.h
> > b/drivers/net/ethernet/mediatek/mtk_wed_regs.h
> > index 9e39dace95eb..873d50b9a6e6 100644
> > --- a/drivers/net/ethernet/mediatek/mtk_wed_regs.h
> > +++ b/drivers/net/ethernet/mediatek/mtk_wed_regs.h
> > @@ -20,6 +20,8 @@ struct mtk_wdma_desc {
> > __le32 info;
> > } __packed __aligned(4);
> >
> > +#define MTK_WED_REV_ID 0x004
> > +
> > #define MTK_WED_RESET 0x008
> > #define MTK_WED_RESET_TX_BM BIT(0)
> > #define MTK_WED_RESET_TX_FREE_AGENT BIT(4)
> > diff --git a/include/linux/soc/mediatek/mtk_wed.h
> > b/include/linux/soc/mediatek/mtk_wed.h
> > index 8294978f4bca..1b1ef57609f7 100644
> > --- a/include/linux/soc/mediatek/mtk_wed.h
> > +++ b/include/linux/soc/mediatek/mtk_wed.h
> > @@ -85,6 +85,9 @@ struct mtk_wed_device {
> > int irq;
> > u8 version;
> >
> > + /* used by wlan driver */
> > + u32 rev_id;
> > +
> > struct mtk_wed_ring tx_ring[MTK_WED_TX_QUEUES];
> > struct mtk_wed_ring rx_ring[MTK_WED_RX_QUEUES];
> > struct mtk_wed_ring txfree_ring;
> > --
> > 2.18.0
> >