* [PATCH net-next] net: airoha: configure hw mac address according to the port id
@ 2024-08-19 11:10 Lorenzo Bianconi
2024-08-20 21:43 ` Jacob Keller
2024-08-20 22:33 ` Jakub Kicinski
0 siblings, 2 replies; 3+ messages in thread
From: Lorenzo Bianconi @ 2024-08-19 11:10 UTC (permalink / raw)
To: Felix Fietkau, Sean Wang, Mark Lee, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Matthias Brugger,
AngeloGioacchino Del Regno
Cc: linux-arm-kernel, linux-mediatek, netdev, lorenzo.bianconi83,
Lorenzo Bianconi
GDM1 port on EN7581 SoC is connected to the lan dsa switch.
GDM{2,3,4} can be used as wan port connected to an external
phy module. Configure hw mac address registers according to the port id.
---
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
---
drivers/net/ethernet/mediatek/airoha_eth.c | 33 +++++++++++++++++++++++-------
1 file changed, 26 insertions(+), 7 deletions(-)
diff --git a/drivers/net/ethernet/mediatek/airoha_eth.c b/drivers/net/ethernet/mediatek/airoha_eth.c
index 1fb46db0c1e9..4914565c2fac 100644
--- a/drivers/net/ethernet/mediatek/airoha_eth.c
+++ b/drivers/net/ethernet/mediatek/airoha_eth.c
@@ -67,6 +67,10 @@
#define FE_RST_GDM3_MBI_ARB_MASK BIT(2)
#define FE_RST_CORE_MASK BIT(0)
+#define REG_FE_WAN_MAC_H 0x0030
+#define REG_FE_WAN_MAC_LMIN 0x0034
+#define REG_FE_WAN_MAC_LMAX 0x0038
+
#define REG_FE_LAN_MAC_H 0x0040
#define REG_FE_LAN_MAC_LMIN 0x0044
#define REG_FE_LAN_MAC_LMAX 0x0048
@@ -900,16 +904,31 @@ static void airoha_qdma_irq_disable(struct airoha_qdma *qdma, int index,
airoha_qdma_set_irqmask(qdma, index, mask, 0);
}
-static void airoha_set_macaddr(struct airoha_eth *eth, const u8 *addr)
+static bool airhoa_is_lan_gdm_port(struct airoha_gdm_port *port)
{
- u32 val;
+ /* GDM1 port on EN7581 SoC is connected to the lan dsa switch.
+ * GDM{2,3,4} can be used as wan port connected to an external
+ * phy module.
+ */
+ return port->id == 1;
+}
+
+static void airoha_set_macaddr(struct airoha_gdm_port *port, const u8 *addr)
+{
+ bool is_lan_port = airhoa_is_lan_gdm_port(port);
+ struct airoha_eth *eth = port->qdma->eth;
+ u32 val, reg;
val = (addr[0] << 16) | (addr[1] << 8) | addr[2];
- airoha_fe_wr(eth, REG_FE_LAN_MAC_H, val);
+ reg = is_lan_port ? REG_FE_LAN_MAC_H : REG_FE_WAN_MAC_H;
+ airoha_fe_wr(eth, reg, val);
val = (addr[3] << 16) | (addr[4] << 8) | addr[5];
- airoha_fe_wr(eth, REG_FE_LAN_MAC_LMIN, val);
- airoha_fe_wr(eth, REG_FE_LAN_MAC_LMAX, val);
+ reg = is_lan_port ? REG_FE_LAN_MAC_LMIN : REG_FE_WAN_MAC_LMIN;
+ airoha_fe_wr(eth, reg, val);
+
+ reg = is_lan_port ? REG_FE_LAN_MAC_LMAX : REG_FE_WAN_MAC_LMAX;
+ airoha_fe_wr(eth, reg, val);
}
static void airoha_set_gdm_port_fwd_cfg(struct airoha_eth *eth, u32 addr,
@@ -2340,7 +2359,7 @@ static int airoha_dev_set_macaddr(struct net_device *dev, void *p)
if (err)
return err;
- airoha_set_macaddr(port->qdma->eth, dev->dev_addr);
+ airoha_set_macaddr(port, dev->dev_addr);
return 0;
}
@@ -2349,7 +2368,7 @@ static int airoha_dev_init(struct net_device *dev)
{
struct airoha_gdm_port *port = netdev_priv(dev);
- airoha_set_macaddr(port->qdma->eth, dev->dev_addr);
+ airoha_set_macaddr(port, dev->dev_addr);
return 0;
}
---
base-commit: a99ef548bba01435f19137cf1670861be1c1ee4b
change-id: 20240819-airoha-eth-wan-mac-addr-0463b2bd89aa
prerequisite-change-id: 20240705-for-6-11-bpf-a349efc08df8:v2
Best regards,
--
Lorenzo Bianconi <lorenzo@kernel.org>
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH net-next] net: airoha: configure hw mac address according to the port id
2024-08-19 11:10 [PATCH net-next] net: airoha: configure hw mac address according to the port id Lorenzo Bianconi
@ 2024-08-20 21:43 ` Jacob Keller
2024-08-20 22:33 ` Jakub Kicinski
1 sibling, 0 replies; 3+ messages in thread
From: Jacob Keller @ 2024-08-20 21:43 UTC (permalink / raw)
To: Lorenzo Bianconi, Felix Fietkau, Sean Wang, Mark Lee,
David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Matthias Brugger, AngeloGioacchino Del Regno
Cc: linux-arm-kernel, linux-mediatek, netdev, lorenzo.bianconi83
On 8/19/2024 4:10 AM, Lorenzo Bianconi wrote:
> GDM1 port on EN7581 SoC is connected to the lan dsa switch.
> GDM{2,3,4} can be used as wan port connected to an external
> phy module. Configure hw mac address registers according to the port id.
>
> ---
> Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
> ---
Reviewed-by: Jacob Keller <jacob.e.keller@intel.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH net-next] net: airoha: configure hw mac address according to the port id
2024-08-19 11:10 [PATCH net-next] net: airoha: configure hw mac address according to the port id Lorenzo Bianconi
2024-08-20 21:43 ` Jacob Keller
@ 2024-08-20 22:33 ` Jakub Kicinski
1 sibling, 0 replies; 3+ messages in thread
From: Jakub Kicinski @ 2024-08-20 22:33 UTC (permalink / raw)
To: Lorenzo Bianconi
Cc: Felix Fietkau, Sean Wang, Mark Lee, David S. Miller, Eric Dumazet,
Paolo Abeni, Matthias Brugger, AngeloGioacchino Del Regno,
linux-arm-kernel, linux-mediatek, netdev, lorenzo.bianconi83
On Mon, 19 Aug 2024 13:10:09 +0200 Lorenzo Bianconi wrote:
> GDM1 port on EN7581 SoC is connected to the lan dsa switch.
> GDM{2,3,4} can be used as wan port connected to an external
> phy module. Configure hw mac address registers according to the port id.
>
> ---
> Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
nit: sign-off under ---
> drivers/net/ethernet/mediatek/airoha_eth.c | 33 +++++++++++++++++++++++-------
> 1 file changed, 26 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/net/ethernet/mediatek/airoha_eth.c b/drivers/net/ethernet/mediatek/airoha_eth.c
> index 1fb46db0c1e9..4914565c2fac 100644
> --- a/drivers/net/ethernet/mediatek/airoha_eth.c
> +++ b/drivers/net/ethernet/mediatek/airoha_eth.c
> @@ -67,6 +67,10 @@
> #define FE_RST_GDM3_MBI_ARB_MASK BIT(2)
> #define FE_RST_CORE_MASK BIT(0)
>
> +#define REG_FE_WAN_MAC_H 0x0030
> +#define REG_FE_WAN_MAC_LMIN 0x0034
> +#define REG_FE_WAN_MAC_LMAX 0x0038
> +
> #define REG_FE_LAN_MAC_H 0x0040
> #define REG_FE_LAN_MAC_LMIN 0x0044
> #define REG_FE_LAN_MAC_LMAX 0x0048
Isn't it better to define the base address and offsets?
#define REG_FE_MAC_BASE_WAN 0x0030
#define REG_FE_MAC_BASE_LAN 0x0040
#define REG_FE_MAC_OFF_H 0x00
#define REG_FE_MAC_OFF_LMIN 0x04
#define REG_FE_MAC_OFF_LMAX 0x08
Then you only need to select the base and the rest of the code won't
have conditionals (marginally improving readability)
--
pw-bot: cr
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-08-20 22:33 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-08-19 11:10 [PATCH net-next] net: airoha: configure hw mac address according to the port id Lorenzo Bianconi
2024-08-20 21:43 ` Jacob Keller
2024-08-20 22:33 ` Jakub Kicinski
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).