* [PATCH net-next 1/2] ixp4xx_eth: Fall back to random MAC address
@ 2022-07-08 23:55 Linus Walleij
2022-07-08 23:55 ` [PATCH net-next 2/2] ixp4xx_eth: Set MAC address from device tree Linus Walleij
2022-07-09 11:40 ` [PATCH net-next 1/2] ixp4xx_eth: Fall back to random MAC address patchwork-bot+netdevbpf
0 siblings, 2 replies; 3+ messages in thread
From: Linus Walleij @ 2022-07-08 23:55 UTC (permalink / raw)
To: netdev, David S . Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni
Cc: Imre Kaloz, Krzysztof Halasa, Linus Walleij
If the firmware does not provide a MAC address to the driver,
fall back to generating a random MAC address.
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
---
drivers/net/ethernet/xscale/ixp4xx_eth.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/xscale/ixp4xx_eth.c b/drivers/net/ethernet/xscale/ixp4xx_eth.c
index 89770c2e0ffb..a5d1d8d12064 100644
--- a/drivers/net/ethernet/xscale/ixp4xx_eth.c
+++ b/drivers/net/ethernet/xscale/ixp4xx_eth.c
@@ -1487,7 +1487,10 @@ static int ixp4xx_eth_probe(struct platform_device *pdev)
port->plat = plat;
npe_port_tab[NPE_ID(port->id)] = port;
- eth_hw_addr_set(ndev, plat->hwaddr);
+ if (is_valid_ether_addr(plat->hwaddr))
+ eth_hw_addr_set(ndev, plat->hwaddr);
+ else
+ eth_hw_addr_random(ndev);
platform_set_drvdata(pdev, ndev);
--
2.36.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH net-next 2/2] ixp4xx_eth: Set MAC address from device tree
2022-07-08 23:55 [PATCH net-next 1/2] ixp4xx_eth: Fall back to random MAC address Linus Walleij
@ 2022-07-08 23:55 ` Linus Walleij
2022-07-09 11:40 ` [PATCH net-next 1/2] ixp4xx_eth: Fall back to random MAC address patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: Linus Walleij @ 2022-07-08 23:55 UTC (permalink / raw)
To: netdev, David S . Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni
Cc: Imre Kaloz, Krzysztof Halasa, Linus Walleij
If there is a MAC address specified in the device tree, then
use it. This is already perfectly legal to specify in accordance
with the generic ethernet-controller.yaml schema.
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
---
drivers/net/ethernet/xscale/ixp4xx_eth.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/xscale/ixp4xx_eth.c b/drivers/net/ethernet/xscale/ixp4xx_eth.c
index a5d1d8d12064..3591b9edc9a1 100644
--- a/drivers/net/ethernet/xscale/ixp4xx_eth.c
+++ b/drivers/net/ethernet/xscale/ixp4xx_eth.c
@@ -29,6 +29,7 @@
#include <linux/net_tstamp.h>
#include <linux/of.h>
#include <linux/of_mdio.h>
+#include <linux/of_net.h>
#include <linux/phy.h>
#include <linux/platform_device.h>
#include <linux/ptp_classify.h>
@@ -156,7 +157,7 @@ struct eth_plat_info {
u8 phy; /* MII PHY ID, 0 - 31 */
u8 rxq; /* configurable, currently 0 - 31 only */
u8 txreadyq;
- u8 hwaddr[6];
+ u8 hwaddr[ETH_ALEN];
u8 npe; /* NPE instance used by this interface */
bool has_mdio; /* If this instance has an MDIO bus */
};
@@ -1387,6 +1388,7 @@ static struct eth_plat_info *ixp4xx_of_get_platdata(struct device *dev)
struct of_phandle_args npe_spec;
struct device_node *mdio_np;
struct eth_plat_info *plat;
+ u8 mac[ETH_ALEN];
int ret;
plat = devm_kzalloc(dev, sizeof(*plat), GFP_KERNEL);
@@ -1428,6 +1430,12 @@ static struct eth_plat_info *ixp4xx_of_get_platdata(struct device *dev)
}
plat->txreadyq = queue_spec.args[0];
+ ret = of_get_mac_address(np, mac);
+ if (!ret) {
+ dev_info(dev, "Setting macaddr from DT %pM\n", mac);
+ memcpy(plat->hwaddr, mac, ETH_ALEN);
+ }
+
return plat;
}
--
2.36.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH net-next 1/2] ixp4xx_eth: Fall back to random MAC address
2022-07-08 23:55 [PATCH net-next 1/2] ixp4xx_eth: Fall back to random MAC address Linus Walleij
2022-07-08 23:55 ` [PATCH net-next 2/2] ixp4xx_eth: Set MAC address from device tree Linus Walleij
@ 2022-07-09 11:40 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2022-07-09 11:40 UTC (permalink / raw)
To: Linus Walleij; +Cc: netdev, davem, edumazet, kuba, pabeni, kaloz, khalasa
Hello:
This series was applied to netdev/net-next.git (master)
by David S. Miller <davem@davemloft.net>:
On Sat, 9 Jul 2022 01:55:29 +0200 you wrote:
> If the firmware does not provide a MAC address to the driver,
> fall back to generating a random MAC address.
>
> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
> ---
> drivers/net/ethernet/xscale/ixp4xx_eth.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
Here is the summary with links:
- [net-next,1/2] ixp4xx_eth: Fall back to random MAC address
https://git.kernel.org/netdev/net-next/c/b3ba206ce84d
- [net-next,2/2] ixp4xx_eth: Set MAC address from device tree
https://git.kernel.org/netdev/net-next/c/877d4e3cedd1
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-07-09 11:40 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-08 23:55 [PATCH net-next 1/2] ixp4xx_eth: Fall back to random MAC address Linus Walleij
2022-07-08 23:55 ` [PATCH net-next 2/2] ixp4xx_eth: Set MAC address from device tree Linus Walleij
2022-07-09 11:40 ` [PATCH net-next 1/2] ixp4xx_eth: Fall back to random MAC address patchwork-bot+netdevbpf
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.