* [PATCH] net: dsa: Inherit dev addr from master
@ 2019-02-22 12:56 Vinod Koul
2019-02-22 14:30 ` Andrew Lunn
0 siblings, 1 reply; 5+ messages in thread
From: Vinod Koul @ 2019-02-22 12:56 UTC (permalink / raw)
To: David S. Miller
Cc: linux-arm-msm, Bjorn Andersson, Xiaofei Shen, Andrew Lunn,
Vivien Didelot, Florian Fainelli, Niklas Cassel, netdev,
Vinod Koul
From: Xiaofei Shen <xiaofeis@codeaurora.org>
When we create slave netdevice, the dev addr is inherited from master
but the master dev addr maybe NULL at that time, so inherit it again
while opening the slave.
Signed-off-by: Xiaofei Shen <xiaofeis@codeaurora.org>
Signed-off-by: Vinod Koul <vkoul@kernel.org>
---
net/dsa/slave.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/net/dsa/slave.c b/net/dsa/slave.c
index 8e64c4e947c6..5f95c538b58c 100644
--- a/net/dsa/slave.c
+++ b/net/dsa/slave.c
@@ -77,7 +77,9 @@ static int dsa_slave_open(struct net_device *dev)
if (!(master->flags & IFF_UP))
return -ENETDOWN;
- if (!ether_addr_equal(dev->dev_addr, master->dev_addr)) {
+ if (!is_valid_ether_addr(dev->dev_addr)) {
+ eth_hw_addr_inherit(dev, master);
+ } else if (!ether_addr_equal(dev->dev_addr, master->dev_addr)) {
err = dev_uc_add(master, dev->dev_addr);
if (err < 0)
goto out;
--
2.20.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] net: dsa: Inherit dev addr from master
2019-02-22 12:56 [PATCH] net: dsa: Inherit dev addr from master Vinod Koul
@ 2019-02-22 14:30 ` Andrew Lunn
2019-02-25 13:13 ` xiaofeis
0 siblings, 1 reply; 5+ messages in thread
From: Andrew Lunn @ 2019-02-22 14:30 UTC (permalink / raw)
To: Vinod Koul
Cc: David S. Miller, linux-arm-msm, Bjorn Andersson, Xiaofei Shen,
Vivien Didelot, Florian Fainelli, Niklas Cassel, netdev
On Fri, Feb 22, 2019 at 06:26:54PM +0530, Vinod Koul wrote:
> From: Xiaofei Shen <xiaofeis@codeaurora.org>
>
> When we create slave netdevice, the dev addr is inherited from master
> but the master dev addr maybe NULL at that time, so inherit it again
> while opening the slave.
Hi Xiaofei, Vinod
Inheriting it twice seems a bit clumsy. Can the first inherit be
removed? Can you change your MAC driver to set its MAC address in
probe?
Andrew
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] net: dsa: Inherit dev addr from master
2019-02-22 14:30 ` Andrew Lunn
@ 2019-02-25 13:13 ` xiaofeis
2019-02-25 13:21 ` Andrew Lunn
0 siblings, 1 reply; 5+ messages in thread
From: xiaofeis @ 2019-02-25 13:13 UTC (permalink / raw)
To: Andrew Lunn
Cc: Vinod Koul, David S. Miller, linux-arm-msm, Bjorn Andersson,
Vivien Didelot, Florian Fainelli, Niklas Cassel, netdev
On 2019-02-22 22:30, Andrew Lunn wrote:
> On Fri, Feb 22, 2019 at 06:26:54PM +0530, Vinod Koul wrote:
>> From: Xiaofei Shen <xiaofeis@codeaurora.org>
>>
>> When we create slave netdevice, the dev addr is inherited from master
>> but the master dev addr maybe NULL at that time, so inherit it again
>> while opening the slave.
>
> Hi Xiaofei, Vinod
>
> Inheriting it twice seems a bit clumsy. Can the first inherit be
> removed? Can you change your MAC driver to set its MAC address in
> probe?
>
> Andrew
Hi Andrew
Some mac driver set its MAC address in probe while some MAC driver do it
in the open function in the kernel.
This patch is checking whether the address is valid firstly, if it
already inherits a valid mac address, it will not inherit again.
I think we can remove the first inherit, but if keep it, we can see
consistent address output by ifconfig -a before open master and slave
interface.
Xiaofeis
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] net: dsa: Inherit dev addr from master
2019-02-25 13:13 ` xiaofeis
@ 2019-02-25 13:21 ` Andrew Lunn
2019-03-27 4:09 ` xiaofeis
0 siblings, 1 reply; 5+ messages in thread
From: Andrew Lunn @ 2019-02-25 13:21 UTC (permalink / raw)
To: xiaofeis
Cc: Vinod Koul, David S. Miller, linux-arm-msm, Bjorn Andersson,
Vivien Didelot, Florian Fainelli, Niklas Cassel, netdev
> I think we can remove the first inherit, but if keep it, we can see
> consistent address output by ifconfig -a before open master and slave
> interface.
True
But it also means we see inconsistent MAC addresses on the master. The
MAC address changes on open.
Maybe it would be better to change your master so it sets its MAC
address during probe? Everything is then consistent all the time.
Andrew
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] net: dsa: Inherit dev addr from master
2019-02-25 13:21 ` Andrew Lunn
@ 2019-03-27 4:09 ` xiaofeis
0 siblings, 0 replies; 5+ messages in thread
From: xiaofeis @ 2019-03-27 4:09 UTC (permalink / raw)
To: Andrew Lunn
Cc: Vinod Koul, David S. Miller, linux-arm-msm, Bjorn Andersson,
Vivien Didelot, Florian Fainelli, Niklas Cassel, netdev
On 2019-02-25 21:21, Andrew Lunn wrote:
>> I think we can remove the first inherit, but if keep it, we can see
>> consistent address output by ifconfig -a before open master and slave
>> interface.
>
> True
>
> But it also means we see inconsistent MAC addresses on the master. The
> MAC address changes on open.
>
> Maybe it would be better to change your master so it sets its MAC
> address during probe? Everything is then consistent all the time.
>
> Andrew
I'm trying to suggest our master driver owner to set MAC address during
probe.
I found in kernel, different driver has different implementation, some
set it in probe, while
some in open. DSA should be generic to work with all these master
drivers. I think this change
can help. Thanks.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2019-03-27 4:09 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-02-22 12:56 [PATCH] net: dsa: Inherit dev addr from master Vinod Koul
2019-02-22 14:30 ` Andrew Lunn
2019-02-25 13:13 ` xiaofeis
2019-02-25 13:21 ` Andrew Lunn
2019-03-27 4:09 ` xiaofeis
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.