From: Heiner Kallweit <hkallweit1@gmail.com>
To: Realtek linux nic maintainers <nic_swsd@realtek.com>,
David Miller <davem@davemloft.net>
Cc: "netdev@vger.kernel.org" <netdev@vger.kernel.org>
Subject: Re: [PATCH net-next] r8169: add random MAC address fallback
Date: Tue, 2 Jul 2019 18:49:14 +0200 [thread overview]
Message-ID: <60c26de4-23bc-a94b-d4a0-1216d8053e1f@gmail.com> (raw)
In-Reply-To: <61a7754f-bdf9-f69a-296d-47353a78c8b4@gmail.com>
On 02.07.2019 08:18, Heiner Kallweit wrote:
>>From 1c8bacf724f1450e5256c68fbff407305faf9cbd Mon Sep 17 00:00:00 2001
>
>
>
Sorry, something went wrong when preparing the commit message. I'll resubmit.
> Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
> ---
> drivers/net/ethernet/realtek/r8169_main.c | 40 +++++++++++++++--------
> 1 file changed, 27 insertions(+), 13 deletions(-)
>
> diff --git a/drivers/net/ethernet/realtek/r8169_main.c b/drivers/net/ethernet/realtek/r8169_main.c
> index 450c74dc1..d6c137b7f 100644
> --- a/drivers/net/ethernet/realtek/r8169_main.c
> +++ b/drivers/net/ethernet/realtek/r8169_main.c
> @@ -6651,13 +6651,36 @@ static int rtl_get_ether_clk(struct rtl8169_private *tp)
> return rc;
> }
>
> +static void rtl_init_mac_address(struct rtl8169_private *tp)
> +{
> + struct net_device *dev = tp->dev;
> + u8 *mac_addr = dev->dev_addr;
> + int rc, i;
> +
> + rc = eth_platform_get_mac_address(tp_to_dev(tp), mac_addr);
> + if (!rc)
> + goto done;
> +
> + rtl_read_mac_address(tp, mac_addr);
> + if (is_valid_ether_addr(mac_addr))
> + goto done;
> +
> + for (i = 0; i < ETH_ALEN; i++)
> + mac_addr[i] = RTL_R8(tp, MAC0 + i);
> + if (is_valid_ether_addr(mac_addr))
> + goto done;
> +
> + eth_hw_addr_random(dev);
> + dev_warn(tp_to_dev(tp), "can't read MAC address, setting random one\n");
> +done:
> + rtl_rar_set(tp, mac_addr);
> +}
> +
> static int rtl_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
> {
> - /* align to u16 for is_valid_ether_addr() */
> - u8 mac_addr[ETH_ALEN] __aligned(2) = {};
> struct rtl8169_private *tp;
> struct net_device *dev;
> - int chipset, region, i;
> + int chipset, region;
> int jumbo_max, rc;
>
> dev = devm_alloc_etherdev(&pdev->dev, sizeof (*tp));
> @@ -6749,16 +6772,7 @@ static int rtl_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
> u64_stats_init(&tp->rx_stats.syncp);
> u64_stats_init(&tp->tx_stats.syncp);
>
> - /* get MAC address */
> - rc = eth_platform_get_mac_address(&pdev->dev, mac_addr);
> - if (rc)
> - rtl_read_mac_address(tp, mac_addr);
> -
> - if (is_valid_ether_addr(mac_addr))
> - rtl_rar_set(tp, mac_addr);
> -
> - for (i = 0; i < ETH_ALEN; i++)
> - dev->dev_addr[i] = RTL_R8(tp, MAC0 + i);
> + rtl_init_mac_address(tp);
>
> dev->ethtool_ops = &rtl8169_ethtool_ops;
>
>
next prev parent reply other threads:[~2019-07-02 16:49 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-07-02 6:18 [PATCH net-next] r8169: add random MAC address fallback Heiner Kallweit
2019-07-02 16:49 ` Heiner Kallweit [this message]
2019-07-02 22:29 ` David Miller
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=60c26de4-23bc-a94b-d4a0-1216d8053e1f@gmail.com \
--to=hkallweit1@gmail.com \
--cc=davem@davemloft.net \
--cc=netdev@vger.kernel.org \
--cc=nic_swsd@realtek.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox