* [PATCH v2] net: dsa: read mac address from DT for slave device
@ 2019-03-29 5:34 Vinod Koul
2019-04-01 21:57 ` David Miller
0 siblings, 1 reply; 2+ messages in thread
From: Vinod Koul @ 2019-03-29 5:34 UTC (permalink / raw)
To: David S. Miller
Cc: linux-arm-msm, Bjorn Andersson, Xiaofei Shen, Andrew Lunn,
Vivien Didelot, Florian Fainelli, netdev, linux-kernel,
Vinod Koul
From: Xiaofei Shen <xiaofeis@codeaurora.org>
Before creating a slave netdevice, get the mac address from DTS and
apply in case it is valid.
Signed-off-by: Xiaofei Shen <xiaofeis@codeaurora.org>
Signed-off-by: Vinod Koul <vkoul@kernel.org>
---
v2: Rebase on net-next. The binding patch is already merged
include/net/dsa.h | 1 +
net/dsa/dsa2.c | 1 +
net/dsa/slave.c | 5 ++++-
3 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/include/net/dsa.h b/include/net/dsa.h
index ae480bba11f5..0cfc2f828b87 100644
--- a/include/net/dsa.h
+++ b/include/net/dsa.h
@@ -140,6 +140,7 @@ struct dsa_port {
unsigned int index;
const char *name;
const struct dsa_port *cpu_dp;
+ const char *mac;
struct device_node *dn;
unsigned int ageing_time;
u8 stp_state;
diff --git a/net/dsa/dsa2.c b/net/dsa/dsa2.c
index fe0a6197db9c..0e1cce460406 100644
--- a/net/dsa/dsa2.c
+++ b/net/dsa/dsa2.c
@@ -266,6 +266,7 @@ static int dsa_port_setup(struct dsa_port *dp)
return 0;
memset(&dp->devlink_port, 0, sizeof(dp->devlink_port));
+ dp->mac = of_get_mac_address(dp->dn);
switch (dp->type) {
case DSA_PORT_TYPE_CPU:
diff --git a/net/dsa/slave.c b/net/dsa/slave.c
index 093eef6f2599..9e4208140142 100644
--- a/net/dsa/slave.c
+++ b/net/dsa/slave.c
@@ -1378,7 +1378,10 @@ int dsa_slave_create(struct dsa_port *port)
NETIF_F_HW_VLAN_CTAG_FILTER;
slave_dev->hw_features |= NETIF_F_HW_TC;
slave_dev->ethtool_ops = &dsa_slave_ethtool_ops;
- eth_hw_addr_inherit(slave_dev, master);
+ if (port->mac && is_valid_ether_addr(port->mac))
+ ether_addr_copy(slave_dev->dev_addr, port->mac);
+ else
+ eth_hw_addr_inherit(slave_dev, master);
slave_dev->priv_flags |= IFF_NO_QUEUE;
slave_dev->netdev_ops = &dsa_slave_netdev_ops;
slave_dev->min_mtu = 0;
--
2.20.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v2] net: dsa: read mac address from DT for slave device
2019-03-29 5:34 [PATCH v2] net: dsa: read mac address from DT for slave device Vinod Koul
@ 2019-04-01 21:57 ` David Miller
0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2019-04-01 21:57 UTC (permalink / raw)
To: vkoul
Cc: linux-arm-msm, bjorn.andersson, xiaofeis, andrew, vivien.didelot,
f.fainelli, netdev, linux-kernel
From: Vinod Koul <vkoul@kernel.org>
Date: Fri, 29 Mar 2019 11:04:58 +0530
> From: Xiaofei Shen <xiaofeis@codeaurora.org>
>
> Before creating a slave netdevice, get the mac address from DTS and
> apply in case it is valid.
>
> Signed-off-by: Xiaofei Shen <xiaofeis@codeaurora.org>
> Signed-off-by: Vinod Koul <vkoul@kernel.org>
> ---
>
> v2: Rebase on net-next. The binding patch is already merged
Applied.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-04-01 21:58 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-03-29 5:34 [PATCH v2] net: dsa: read mac address from DT for slave device Vinod Koul
2019-04-01 21:57 ` David Miller
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).