2022-10-21 12:21:29

by Chang, Junxiao

[permalink] [raw]
Subject: [PATCH net-next 2/2] net: stmmac: remove duplicate dma queue channel macros

It doesn't need extra macros for queue 0 & 4. Same macro could
be used for all 8 queues.

Signed-off-by: Junxiao Chang <[email protected]>
---
drivers/net/ethernet/stmicro/stmmac/dwmac4.h | 2 --
drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c | 11 ++++-------
2 files changed, 4 insertions(+), 9 deletions(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac4.h b/drivers/net/ethernet/stmicro/stmmac/dwmac4.h
index 3c1490408a1c3..ccd49346d3b30 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac4.h
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac4.h
@@ -331,8 +331,6 @@ enum power_event {

#define MTL_RXQ_DMA_MAP0 0x00000c30 /* queue 0 to 3 */
#define MTL_RXQ_DMA_MAP1 0x00000c34 /* queue 4 to 7 */
-#define MTL_RXQ_DMA_Q04MDMACH_MASK GENMASK(3, 0)
-#define MTL_RXQ_DMA_Q04MDMACH(x) ((x) << 0)
#define MTL_RXQ_DMA_QXMDMACH_MASK(x) (0xf << 8 * (x))
#define MTL_RXQ_DMA_QXMDMACH(chan, q) ((chan) << (8 * (q)))

diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c b/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c
index c25bfecb4a2df..64b916728bdd4 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c
@@ -219,15 +219,12 @@ static void dwmac4_map_mtl_dma(struct mac_device_info *hw, u32 queue, u32 chan)
else
value = readl(ioaddr + MTL_RXQ_DMA_MAP1);

- if (queue == 0 || queue == 4) {
- value &= ~MTL_RXQ_DMA_Q04MDMACH_MASK;
- value |= MTL_RXQ_DMA_Q04MDMACH(chan);
- } else if (queue > 4) {
- value &= ~MTL_RXQ_DMA_QXMDMACH_MASK(queue - 4);
- value |= MTL_RXQ_DMA_QXMDMACH(chan, queue - 4);
- } else {
+ if (queue < 4) {
value &= ~MTL_RXQ_DMA_QXMDMACH_MASK(queue);
value |= MTL_RXQ_DMA_QXMDMACH(chan, queue);
+ } else {
+ value &= ~MTL_RXQ_DMA_QXMDMACH_MASK(queue - 4);
+ value |= MTL_RXQ_DMA_QXMDMACH(chan, queue - 4);
}

if (queue < 4)
--
2.25.1


2022-10-25 07:33:39

by Wong Vee Khee

[permalink] [raw]
Subject: Re: [PATCH net-next 2/2] net: stmmac: remove duplicate dma queue channel macros

Why not combine with the other ‘if (queue < 4).. else’ in
this function all together?

Regards,
Vee Khee

2022-10-25 07:57:22

by Chang, Junxiao

[permalink] [raw]
Subject: RE: [PATCH net-next 2/2] net: stmmac: remove duplicate dma queue channel macros

Hi Wee Khee,

Good suggestion! ????

I will make related update.

Regards,
Junxiao

-----Original Message-----
From: Wong Vee Khee <[email protected]>
Sent: Tuesday, October 25, 2022 3:11 PM
To: Chang, Junxiao <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH net-next 2/2] net: stmmac: remove duplicate dma queue channel macros

Why not combine with the other ‘if (queue < 4).. else’ in this function all together?

Regards,
Vee Khee