netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jakub Kicinski <kuba@kernel.org>
To: davem@davemloft.net
Cc: netdev@vger.kernel.org, Jakub Kicinski <kuba@kernel.org>,
	claudiu.manoil@nxp.com
Subject: [PATCH net-next 10/12] ethernet: enetc: use eth_hw_addr_set()
Date: Fri, 15 Oct 2021 15:16:50 -0700	[thread overview]
Message-ID: <20211015221652.827253-11-kuba@kernel.org> (raw)
In-Reply-To: <20211015221652.827253-1-kuba@kernel.org>

Commit 406f42fa0d3c ("net-next: When a bond have a massive amount
of VLANs...") introduced a rbtree for faster Ethernet address look
up. To maintain netdev->dev_addr in this tree we need to make all
the writes to it got through appropriate helpers.

Pass a netdev into the helper instead of just the address,
read the address into an array on the stack, then call
eth_hw_addr_set().

Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
CC: claudiu.manoil@nxp.com
---
 drivers/net/ethernet/freescale/enetc/enetc_hw.h | 6 +++++-
 drivers/net/ethernet/freescale/enetc/enetc_pf.c | 2 +-
 drivers/net/ethernet/freescale/enetc/enetc_vf.c | 2 +-
 3 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/freescale/enetc/enetc_hw.h b/drivers/net/ethernet/freescale/enetc/enetc_hw.h
index 0f5f081a5baf..1514e6a4a3ff 100644
--- a/drivers/net/ethernet/freescale/enetc/enetc_hw.h
+++ b/drivers/net/ethernet/freescale/enetc/enetc_hw.h
@@ -635,10 +635,14 @@ struct enetc_cmd_rfse {
 #define ENETC_RFSE_EN	BIT(15)
 #define ENETC_RFSE_MODE_BD	2
 
-static inline void enetc_get_primary_mac_addr(struct enetc_hw *hw, u8 *addr)
+static inline void enetc_load_primary_mac_addr(struct enetc_hw *hw,
+					       struct net_device *ndev)
 {
+	u8 addr[ETH_ALEN] __aligned(4);
+
 	*(u32 *)addr = __raw_readl(hw->reg + ENETC_SIPMAR0);
 	*(u16 *)(addr + 4) = __raw_readw(hw->reg + ENETC_SIPMAR1);
+	eth_hw_addr_set(ndev, addr);
 }
 
 #define ENETC_SI_INT_IDX	0
diff --git a/drivers/net/ethernet/freescale/enetc/enetc_pf.c b/drivers/net/ethernet/freescale/enetc/enetc_pf.c
index 8281dd664f4e..ead2b93bf614 100644
--- a/drivers/net/ethernet/freescale/enetc/enetc_pf.c
+++ b/drivers/net/ethernet/freescale/enetc/enetc_pf.c
@@ -783,7 +783,7 @@ static void enetc_pf_netdev_setup(struct enetc_si *si, struct net_device *ndev,
 	}
 
 	/* pick up primary MAC address from SI */
-	enetc_get_primary_mac_addr(&si->hw, ndev->dev_addr);
+	enetc_load_primary_mac_addr(&si->hw, ndev);
 }
 
 static int enetc_mdio_probe(struct enetc_pf *pf, struct device_node *np)
diff --git a/drivers/net/ethernet/freescale/enetc/enetc_vf.c b/drivers/net/ethernet/freescale/enetc/enetc_vf.c
index df312c9f8243..17924305afa2 100644
--- a/drivers/net/ethernet/freescale/enetc/enetc_vf.c
+++ b/drivers/net/ethernet/freescale/enetc/enetc_vf.c
@@ -135,7 +135,7 @@ static void enetc_vf_netdev_setup(struct enetc_si *si, struct net_device *ndev,
 		ndev->hw_features |= NETIF_F_RXHASH;
 
 	/* pick up primary MAC address from SI */
-	enetc_get_primary_mac_addr(&si->hw, ndev->dev_addr);
+	enetc_load_primary_mac_addr(&si->hw, ndev);
 }
 
 static int enetc_vf_probe(struct pci_dev *pdev,
-- 
2.31.1


  parent reply	other threads:[~2021-10-15 22:17 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-15 22:16 [PATCH net-next 00/12] ethernet: manual netdev->dev_addr conversions (part 1) Jakub Kicinski
2021-10-15 22:16 ` [PATCH net-next 01/12] ethernet: adaptec: use eth_hw_addr_set() Jakub Kicinski
2021-10-15 22:16 ` [PATCH net-next 02/12] ethernet: aeroflex: " Jakub Kicinski
2021-10-15 22:16 ` [PATCH net-next 03/12] ethernet: alteon: " Jakub Kicinski
2021-10-19  7:49   ` jes
2021-10-15 22:16 ` [PATCH net-next 04/12] ethernet: amd: " Jakub Kicinski
2021-10-15 22:16 ` [PATCH net-next 05/12] ethernet: aquantia: " Jakub Kicinski
2021-10-15 22:16 ` [PATCH net-next 06/12] ethernet: bnx2x: " Jakub Kicinski
2021-10-15 22:16 ` [PATCH net-next 07/12] ethernet: bcmgenet: " Jakub Kicinski
2021-10-19 22:02   ` Florian Fainelli
2021-10-15 22:16 ` [PATCH net-next 08/12] ethernet: enic: " Jakub Kicinski
2021-10-15 22:16 ` [PATCH net-next 09/12] ethernet: ec_bhf: " Jakub Kicinski
2021-10-15 22:16 ` Jakub Kicinski [this message]
2021-10-15 22:16 ` [PATCH net-next 11/12] ethernet: ibmveth: use ether_addr_to_u64() Jakub Kicinski
2021-10-15 22:28   ` Tyrel Datwyler
2021-10-15 22:16 ` [PATCH net-next 12/12] ethernet: ixgb: use eth_hw_addr_set() Jakub Kicinski
2021-10-16  8:00 ` [PATCH net-next 00/12] ethernet: manual netdev->dev_addr conversions (part 1) patchwork-bot+netdevbpf

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=20211015221652.827253-11-kuba@kernel.org \
    --to=kuba@kernel.org \
    --cc=claudiu.manoil@nxp.com \
    --cc=davem@davemloft.net \
    --cc=netdev@vger.kernel.org \
    /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;
as well as URLs for NNTP newsgroup(s).