All of lore.kernel.org
 help / color / mirror / Atom feed
From: Joe Hershberger <joe.hershberger@gmail.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] Setting up MAC address for eth drivers
Date: Tue, 17 Mar 2015 10:56:16 -0500	[thread overview]
Message-ID: <CANr=Z=aXdNcdL9uDg-GGQr-iKGaj1HSpV3murbucomJ=unV8tw@mail.gmail.com> (raw)
In-Reply-To: <BN1BFFO11OLC0024545758C93CF90357153E2070@BN1BFFO11OLC002.protection.gbl>

Hi Michal,

On Fri, Mar 13, 2015 at 7:25 AM, Michal Simek <michal.simek@xilinx.com>
wrote:
>
> Hi,
>
> I have a question regarding setting mac address for drivers.
> Drivers setting up write_hwaddr via eth_write_hwaddr via eth_initialize
> which is called from common/board_r.c.

This is because on at least ARM kernels, the MAC is passed via the MAC's
filter registers. Because of this, we need to write hwaddr even before the
MAC is started.

> But then there are some drivers(macb, designware, altera_tse) which also
calls
> mac setup from dev->init which has side effect for example when you setup
CONFIG_ENV_OVERWRITE
> and change mac address you can directly use it.

This is probably a work-around for a shortcoming of the net/eth.c not
calling write_hwaddr() when the env MAC changes. It already updates the
registers used by the network stack, so presumably if those MACs are
filtering incoming traffic based on the register as expected, changing the
MAC after boot without rewriting that register would cause all traffic to
not be returned.

> It also means if there is intention to call hwaddr from dev->init
> that for the first packet mac address is setup twice - in eth core init
> and then before every driver use.

The design of the network stack assumes the MAC is started each time a
network operation is requested and stopped when done.

As for the setting of the hwaddr, we should check if it changed.

> I am asking this question because I would like to know the right flow
> for eth mac setup.
> If it is
> set ethaddr xx....
> saveenv
> reset
> eth with new mac
>
> or if
> set ethaddr
> eth with new mac
> should work
>
> The second approach looks reasonable when ethaddr is not set at all
> but then at least our driver needs to be fixed to support this feature.

I think the second should work ideally, but we need to add a call to
eth_init() if the "ethaddr" in the env changes and set it again if so. We
should also remove the calls from the drivers you identified since the
framework will now do it.

Cheers,
-Joe

  parent reply	other threads:[~2015-03-17 15:56 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-13 12:25 [U-Boot] Setting up MAC address for eth drivers Michal Simek
2015-03-17 10:16 ` Michal Simek
2015-03-17 15:56 ` Joe Hershberger [this message]
2015-03-17 16:57   ` Michal Simek
2015-03-17 17:21     ` Joe Hershberger
2015-03-17 17:47       ` Michal Simek
2015-03-23 20:22         ` Simon Glass
2015-03-24  6:49           ` [U-Boot] [PATCH v1] net: Update hardware MAC address if it changes in env Joe Hershberger
2015-03-24  6:54             ` Joe Hershberger
2015-03-24  7:41             ` [U-Boot] [PATCH v2] " Joe Hershberger
2015-03-30 18:08               ` Joe Hershberger
2015-03-31 11:41                 ` Michal Simek
2015-04-21 23:21                   ` Joe Hershberger
2015-06-15  9:07             ` [U-Boot] [PATCH v1] " Bin Meng
2015-06-15 10:42               ` Bin Meng

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CANr=Z=aXdNcdL9uDg-GGQr-iKGaj1HSpV3murbucomJ=unV8tw@mail.gmail.com' \
    --to=joe.hershberger@gmail.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.