All of lore.kernel.org
 help / color / mirror / Atom feed
From: Bin Meng <bmeng.cn@gmail.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v1] net: Update hardware MAC address if it changes in env
Date: Mon, 15 Jun 2015 17:07:03 +0800	[thread overview]
Message-ID: <CAEUhbmXaEUXa+QLe+Ar2HpO_pEash4B27P33q84=0p5qi1Dv0A@mail.gmail.com> (raw)
In-Reply-To: <1427179783-985-1-git-send-email-joe.hershberger@ni.com>

Hi Joe,

On Tue, Mar 24, 2015 at 2:49 PM, Joe Hershberger <joe.hershberger@ni.com> wrote:
> When the ethaddr changes in the env, the hardware should also be updated
> so that MAC filtering will work properly without resetting U-Boot.
>
> Also remove the manual calls to set the hwaddr that was included in a
> few drivers as a result of the framework not doing it.
>
> Reported-by: Michal Simek <michal.simek@xilinx.com>
> Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
>
> ---
>
>  drivers/net/bcm-sf2-eth.c |  6 ------
>  drivers/net/designware.c  |  4 ----
>  drivers/net/macb.c        |  9 ---------
>  net/eth.c                 | 15 +++++++++++++--
>  4 files changed, 13 insertions(+), 21 deletions(-)
>
> diff --git a/drivers/net/bcm-sf2-eth.c b/drivers/net/bcm-sf2-eth.c
> index 5252d49..9ae88d3 100644
> --- a/drivers/net/bcm-sf2-eth.c
> +++ b/drivers/net/bcm-sf2-eth.c
> @@ -154,12 +154,6 @@ static int bcm_sf2_eth_open(struct eth_device *dev, bd_t *bt)
>
>         debug("Enabling BCM SF2 Ethernet.\n");
>
> -       /* Set MAC address from env */
> -       if (bcm_sf2_eth_write_hwaddr(dev) != 0) {
> -               error("%s: MAC set error when opening !\n", __func__);
> -               return -1;
> -       }
> -
>         eth->enable_mac();
>
>         /* enable tx and rx DMA */
> diff --git a/drivers/net/designware.c b/drivers/net/designware.c
> index cc01604..d35236b 100644
> --- a/drivers/net/designware.c
> +++ b/drivers/net/designware.c
> @@ -244,10 +244,6 @@ static int dw_eth_init(struct eth_device *dev, bd_t *bis)
>                 mdelay(100);
>         };
>
> -       /* Soft reset above clears HW address registers.
> -        * So we have to set it here once again */
> -       dw_write_hwaddr(dev);
> -
>         rx_descs_init(dev);
>         tx_descs_init(dev);
>
> diff --git a/drivers/net/macb.c b/drivers/net/macb.c
> index 170ff06..7d5b36b 100644
> --- a/drivers/net/macb.c
> +++ b/drivers/net/macb.c
> @@ -525,7 +525,6 @@ static int macb_phy_init(struct macb_device *macb)
>         return 1;
>  }
>
> -static int macb_write_hwaddr(struct eth_device *dev);
>  static int macb_init(struct eth_device *netdev, bd_t *bd)
>  {
>         struct macb_device *macb = to_macb(netdev);
> @@ -594,14 +593,6 @@ static int macb_init(struct eth_device *netdev, bd_t *bd)
>  #endif /* CONFIG_RMII */
>         }
>
> -       /* update the ethaddr */
> -       if (is_valid_ether_addr(netdev->enetaddr)) {
> -               macb_write_hwaddr(netdev);
> -       } else {
> -               printf("%s: mac address is not valid\n", netdev->name);
> -               return -1;
> -       }
> -
>         if (!macb_phy_init(macb))
>                 return -1;
>
> diff --git a/net/eth.c b/net/eth.c
> index 13b7723..776fd2f 100644
> --- a/net/eth.c
> +++ b/net/eth.c
> @@ -258,13 +258,24 @@ int eth_init(void)
>                 if (device_active(current)) {
>                         uchar env_enetaddr[6];
>                         struct eth_pdata *pdata = current->platdata;
> +                       int enetaddr_changed = 0;
>
>                         /* Sync environment with network device */
>                         if (eth_getenv_enetaddr_by_index("eth", current->seq,
> -                                                        env_enetaddr))
> +                                                        env_enetaddr)) {
> +                               enetaddr_changed = memcmp(pdata->enetaddr,
> +                                       env_enetaddr, 6);
>                                 memcpy(pdata->enetaddr, env_enetaddr, 6);
> -                       else
> +                       } else {
> +                               memset(env_enetaddr, 0, 6);
> +                               enetaddr_changed = memcmp(pdata->enetaddr,
> +                                       env_enetaddr, 6);
>                                 memset(pdata->enetaddr, 0, 6);
> +                       }
> +                       if (enetaddr_changed &&
> +                           eth_get_ops(current)->write_hwaddr) {
> +                               eth_get_ops(current)->write_hwaddr(current);
> +                       }
>
>                         ret = eth_get_ops(current)->start(current);
>                         if (ret >= 0) {
> --

I've created a u-boot.rom for Intel Galileo board and found the
designware ethernet port does not work any more. Git bisect shows that
this commit broke the things. Do you have any idea on what might be
the issue?

Regards,
Bin

  parent reply	other threads:[~2015-06-15  9:07 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
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             ` Bin Meng [this message]
2015-06-15 10:42               ` [U-Boot] [PATCH v1] " 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='CAEUhbmXaEUXa+QLe+Ar2HpO_pEash4B27P33q84=0p5qi1Dv0A@mail.gmail.com' \
    --to=bmeng.cn@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.