netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next v2 00/12] net: don't write directly to netdev->dev_addr
@ 2021-10-21 13:12 Jakub Kicinski
  2021-10-21 13:12 ` [PATCH net-next v2 01/12] net: xen: use eth_hw_addr_set() Jakub Kicinski
                   ` (12 more replies)
  0 siblings, 13 replies; 17+ messages in thread
From: Jakub Kicinski @ 2021-10-21 13:12 UTC (permalink / raw)
  To: davem; +Cc: netdev, Jakub Kicinski

More conversions, mostly in usb/net.

v2: leave out catc (patch 4)

Jakub Kicinski (12):
  net: xen: use eth_hw_addr_set()
  usb: smsc: use eth_hw_addr_set()
  net: qmi_wwan: use dev_addr_mod()
  net: usb: don't write directly to netdev->dev_addr
  fddi: defxx,defza: use dev_addr_set()
  fddi: skfp: constify and use dev_addr_set()
  net: fjes: constify and use eth_hw_addr_set()
  net: hippi: use dev_addr_set()
  net: s390: constify and use eth_hw_addr_set()
  net: plip: use eth_hw_addr_set()
  net: sb1000,rionet: use eth_hw_addr_set()
  net: hldc_fr: use dev_addr_set()

 drivers/net/fddi/defxx.c            |  6 +++---
 drivers/net/fddi/defza.c            |  2 +-
 drivers/net/fddi/skfp/h/smc.h       |  2 +-
 drivers/net/fddi/skfp/skfddi.c      |  2 +-
 drivers/net/fddi/skfp/smtinit.c     |  4 ++--
 drivers/net/fjes/fjes_hw.c          |  3 ++-
 drivers/net/fjes/fjes_hw.h          |  2 +-
 drivers/net/fjes/fjes_main.c        | 14 ++++++++------
 drivers/net/hippi/rrunner.c         |  6 ++++--
 drivers/net/plip/plip.c             |  8 ++++++--
 drivers/net/rionet.c                | 14 ++++++++------
 drivers/net/sb1000.c                | 12 ++++++++----
 drivers/net/usb/ch9200.c            |  4 +++-
 drivers/net/usb/cx82310_eth.c       |  5 +++--
 drivers/net/usb/kaweth.c            |  3 +--
 drivers/net/usb/mcs7830.c           |  4 +++-
 drivers/net/usb/qmi_wwan.c          |  7 +++++--
 drivers/net/usb/sierra_net.c        |  6 ++++--
 drivers/net/usb/smsc75xx.c          |  6 ++++--
 drivers/net/usb/smsc95xx.c          |  6 ++++--
 drivers/net/usb/sr9700.c            |  4 +++-
 drivers/net/usb/sr9800.c            |  5 +++--
 drivers/net/usb/usbnet.c            |  6 ++++--
 drivers/net/wan/hdlc_fr.c           |  4 +++-
 drivers/net/xen-netback/interface.c |  6 ++++--
 drivers/net/xen-netfront.c          |  4 +++-
 drivers/s390/net/lcs.c              |  2 +-
 drivers/s390/net/qeth_core_main.c   |  4 ++--
 drivers/s390/net/qeth_l2_main.c     |  6 +++---
 drivers/s390/net/qeth_l3_main.c     |  3 +--
 30 files changed, 99 insertions(+), 61 deletions(-)

-- 
2.31.1


^ permalink raw reply	[flat|nested] 17+ messages in thread

* [PATCH net-next v2 01/12] net: xen: use eth_hw_addr_set()
  2021-10-21 13:12 [PATCH net-next v2 00/12] net: don't write directly to netdev->dev_addr Jakub Kicinski
@ 2021-10-21 13:12 ` Jakub Kicinski
  2021-10-23  0:41   ` Boris Ostrovsky
  2021-10-25 10:55   ` Wei Liu
  2021-10-21 13:12 ` [PATCH net-next v2 02/12] usb: smsc: " Jakub Kicinski
                   ` (11 subsequent siblings)
  12 siblings, 2 replies; 17+ messages in thread
From: Jakub Kicinski @ 2021-10-21 13:12 UTC (permalink / raw)
  To: davem
  Cc: netdev, Jakub Kicinski, wei.liu, paul, boris.ostrovsky, jgross,
	sstabellini, xen-devel

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.

Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
CC: wei.liu@kernel.org
CC: paul@xen.org
CC: boris.ostrovsky@oracle.com
CC: jgross@suse.com
CC: sstabellini@kernel.org
CC: xen-devel@lists.xenproject.org
---
 drivers/net/xen-netback/interface.c | 6 ++++--
 drivers/net/xen-netfront.c          | 4 +++-
 2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/drivers/net/xen-netback/interface.c b/drivers/net/xen-netback/interface.c
index c58996c1e230..fe8e21ad8ed9 100644
--- a/drivers/net/xen-netback/interface.c
+++ b/drivers/net/xen-netback/interface.c
@@ -494,6 +494,9 @@ static const struct net_device_ops xenvif_netdev_ops = {
 struct xenvif *xenvif_alloc(struct device *parent, domid_t domid,
 			    unsigned int handle)
 {
+	static const u8 dummy_addr[ETH_ALEN] = {
+		0xfe, 0xff, 0xff, 0xff, 0xff, 0xff,
+	};
 	int err;
 	struct net_device *dev;
 	struct xenvif *vif;
@@ -551,8 +554,7 @@ struct xenvif *xenvif_alloc(struct device *parent, domid_t domid,
 	 * stolen by an Ethernet bridge for STP purposes.
 	 * (FE:FF:FF:FF:FF:FF)
 	 */
-	eth_broadcast_addr(dev->dev_addr);
-	dev->dev_addr[0] &= ~0x01;
+	eth_hw_addr_set(dev, dummy_addr);
 
 	netif_carrier_off(dev);
 
diff --git a/drivers/net/xen-netfront.c b/drivers/net/xen-netfront.c
index e31b98403f31..57437e4b8a94 100644
--- a/drivers/net/xen-netfront.c
+++ b/drivers/net/xen-netfront.c
@@ -2157,6 +2157,7 @@ static int talk_to_netback(struct xenbus_device *dev,
 	unsigned int max_queues = 0;
 	struct netfront_queue *queue = NULL;
 	unsigned int num_queues = 1;
+	u8 addr[ETH_ALEN];
 
 	info->netdev->irq = 0;
 
@@ -2170,11 +2171,12 @@ static int talk_to_netback(struct xenbus_device *dev,
 					"feature-split-event-channels", 0);
 
 	/* Read mac addr. */
-	err = xen_net_read_mac(dev, info->netdev->dev_addr);
+	err = xen_net_read_mac(dev, addr);
 	if (err) {
 		xenbus_dev_fatal(dev, err, "parsing %s/mac", dev->nodename);
 		goto out_unlocked;
 	}
+	eth_hw_addr_set(info->netdev, addr);
 
 	info->netback_has_xdp_headroom = xenbus_read_unsigned(info->xbdev->otherend,
 							      "feature-xdp-headroom", 0);
-- 
2.31.1


^ permalink raw reply	[flat|nested] 17+ messages in thread

* [PATCH net-next v2 02/12] usb: smsc: use eth_hw_addr_set()
  2021-10-21 13:12 [PATCH net-next v2 00/12] net: don't write directly to netdev->dev_addr Jakub Kicinski
  2021-10-21 13:12 ` [PATCH net-next v2 01/12] net: xen: use eth_hw_addr_set() Jakub Kicinski
@ 2021-10-21 13:12 ` Jakub Kicinski
  2021-10-21 13:12 ` [PATCH net-next v2 03/12] net: qmi_wwan: use dev_addr_mod() Jakub Kicinski
                   ` (10 subsequent siblings)
  12 siblings, 0 replies; 17+ messages in thread
From: Jakub Kicinski @ 2021-10-21 13:12 UTC (permalink / raw)
  To: davem
  Cc: netdev, Jakub Kicinski, steve.glendinning, UNGLinuxDriver, linux-usb

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.

Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
CC: steve.glendinning@shawell.net
CC: UNGLinuxDriver@microchip.com
CC: linux-usb@vger.kernel.org
---
 drivers/net/usb/smsc75xx.c | 6 ++++--
 drivers/net/usb/smsc95xx.c | 6 ++++--
 2 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/drivers/net/usb/smsc75xx.c b/drivers/net/usb/smsc75xx.c
index 3b6987bb4fbe..95de452ff4da 100644
--- a/drivers/net/usb/smsc75xx.c
+++ b/drivers/net/usb/smsc75xx.c
@@ -757,6 +757,8 @@ static int smsc75xx_ioctl(struct net_device *netdev, struct ifreq *rq, int cmd)
 
 static void smsc75xx_init_mac_address(struct usbnet *dev)
 {
+	u8 addr[ETH_ALEN];
+
 	/* maybe the boot loader passed the MAC address in devicetree */
 	if (!platform_get_ethdev_address(&dev->udev->dev, dev->net)) {
 		if (is_valid_ether_addr(dev->net->dev_addr)) {
@@ -767,8 +769,8 @@ static void smsc75xx_init_mac_address(struct usbnet *dev)
 	}
 
 	/* try reading mac address from EEPROM */
-	if (smsc75xx_read_eeprom(dev, EEPROM_MAC_OFFSET, ETH_ALEN,
-			dev->net->dev_addr) == 0) {
+	if (smsc75xx_read_eeprom(dev, EEPROM_MAC_OFFSET, ETH_ALEN, addr) == 0) {
+		eth_hw_addr_set(dev->net, addr);
 		if (is_valid_ether_addr(dev->net->dev_addr)) {
 			/* eeprom values are valid so use them */
 			netif_dbg(dev, ifup, dev->net,
diff --git a/drivers/net/usb/smsc95xx.c b/drivers/net/usb/smsc95xx.c
index 21a42a6527dc..20fe4cd8f784 100644
--- a/drivers/net/usb/smsc95xx.c
+++ b/drivers/net/usb/smsc95xx.c
@@ -755,6 +755,8 @@ static int smsc95xx_ioctl(struct net_device *netdev, struct ifreq *rq, int cmd)
 
 static void smsc95xx_init_mac_address(struct usbnet *dev)
 {
+	u8 addr[ETH_ALEN];
+
 	/* maybe the boot loader passed the MAC address in devicetree */
 	if (!platform_get_ethdev_address(&dev->udev->dev, dev->net)) {
 		if (is_valid_ether_addr(dev->net->dev_addr)) {
@@ -765,8 +767,8 @@ static void smsc95xx_init_mac_address(struct usbnet *dev)
 	}
 
 	/* try reading mac address from EEPROM */
-	if (smsc95xx_read_eeprom(dev, EEPROM_MAC_OFFSET, ETH_ALEN,
-			dev->net->dev_addr) == 0) {
+	if (smsc95xx_read_eeprom(dev, EEPROM_MAC_OFFSET, ETH_ALEN, addr) == 0) {
+		eth_hw_addr_set(dev->net, addr);
 		if (is_valid_ether_addr(dev->net->dev_addr)) {
 			/* eeprom values are valid so use them */
 			netif_dbg(dev, ifup, dev->net, "MAC address read from EEPROM\n");
-- 
2.31.1


^ permalink raw reply	[flat|nested] 17+ messages in thread

* [PATCH net-next v2 03/12] net: qmi_wwan: use dev_addr_mod()
  2021-10-21 13:12 [PATCH net-next v2 00/12] net: don't write directly to netdev->dev_addr Jakub Kicinski
  2021-10-21 13:12 ` [PATCH net-next v2 01/12] net: xen: use eth_hw_addr_set() Jakub Kicinski
  2021-10-21 13:12 ` [PATCH net-next v2 02/12] usb: smsc: " Jakub Kicinski
@ 2021-10-21 13:12 ` Jakub Kicinski
  2021-10-21 13:12 ` [PATCH net-next v2 04/12] net: usb: don't write directly to netdev->dev_addr Jakub Kicinski
                   ` (9 subsequent siblings)
  12 siblings, 0 replies; 17+ messages in thread
From: Jakub Kicinski @ 2021-10-21 13:12 UTC (permalink / raw)
  To: davem; +Cc: netdev, Jakub Kicinski, Bjørn Mork, linux-usb

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.

Acked-by: Bjørn Mork <bjorn@mork.no>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
CC: linux-usb@vger.kernel.org
---
 drivers/net/usb/qmi_wwan.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/net/usb/qmi_wwan.c b/drivers/net/usb/qmi_wwan.c
index 33ada2c59952..86b814e99224 100644
--- a/drivers/net/usb/qmi_wwan.c
+++ b/drivers/net/usb/qmi_wwan.c
@@ -835,8 +835,11 @@ static int qmi_wwan_bind(struct usbnet *dev, struct usb_interface *intf)
 
 	/* make MAC addr easily distinguishable from an IP header */
 	if (possibly_iphdr(dev->net->dev_addr)) {
-		dev->net->dev_addr[0] |= 0x02;	/* set local assignment bit */
-		dev->net->dev_addr[0] &= 0xbf;	/* clear "IP" bit */
+		u8 addr = dev->net->dev_addr[0];
+
+		addr |= 0x02;	/* set local assignment bit */
+		addr &= 0xbf;	/* clear "IP" bit */
+		dev_addr_mod(dev->net, 0, &addr, 1);
 	}
 	dev->net->netdev_ops = &qmi_wwan_netdev_ops;
 	dev->net->sysfs_groups[0] = &qmi_wwan_sysfs_attr_group;
-- 
2.31.1


^ permalink raw reply	[flat|nested] 17+ messages in thread

* [PATCH net-next v2 04/12] net: usb: don't write directly to netdev->dev_addr
  2021-10-21 13:12 [PATCH net-next v2 00/12] net: don't write directly to netdev->dev_addr Jakub Kicinski
                   ` (2 preceding siblings ...)
  2021-10-21 13:12 ` [PATCH net-next v2 03/12] net: qmi_wwan: use dev_addr_mod() Jakub Kicinski
@ 2021-10-21 13:12 ` Jakub Kicinski
  2021-10-21 13:12 ` [PATCH net-next v2 05/12] fddi: defxx,defza: use dev_addr_set() Jakub Kicinski
                   ` (8 subsequent siblings)
  12 siblings, 0 replies; 17+ messages in thread
From: Jakub Kicinski @ 2021-10-21 13:12 UTC (permalink / raw)
  To: davem; +Cc: netdev, Jakub Kicinski, oneukum, linux-usb

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.

Manually fix all net/usb drivers without separate maintainers.

v2: catc does DMA to the buffer, leave the conversion to Oliver

Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
CC: oneukum@suse.com
CC: linux-usb@vger.kernel.org
---
 drivers/net/usb/ch9200.c      | 4 +++-
 drivers/net/usb/cx82310_eth.c | 5 +++--
 drivers/net/usb/kaweth.c      | 3 +--
 drivers/net/usb/mcs7830.c     | 4 +++-
 drivers/net/usb/sierra_net.c  | 6 ++++--
 drivers/net/usb/sr9700.c      | 4 +++-
 drivers/net/usb/sr9800.c      | 5 +++--
 drivers/net/usb/usbnet.c      | 6 ++++--
 8 files changed, 24 insertions(+), 13 deletions(-)

diff --git a/drivers/net/usb/ch9200.c b/drivers/net/usb/ch9200.c
index d7f3b70d5477..f69d9b902da0 100644
--- a/drivers/net/usb/ch9200.c
+++ b/drivers/net/usb/ch9200.c
@@ -336,6 +336,7 @@ static int ch9200_bind(struct usbnet *dev, struct usb_interface *intf)
 {
 	int retval = 0;
 	unsigned char data[2];
+	u8 addr[ETH_ALEN];
 
 	retval = usbnet_get_endpoints(dev, intf);
 	if (retval)
@@ -383,7 +384,8 @@ static int ch9200_bind(struct usbnet *dev, struct usb_interface *intf)
 	retval = control_write(dev, REQUEST_WRITE, 0, MAC_REG_CTRL, data, 0x02,
 			       CONTROL_TIMEOUT_MS);
 
-	retval = get_mac_address(dev, dev->net->dev_addr);
+	retval = get_mac_address(dev, addr);
+	eth_hw_addr_set(dev->net, addr);
 
 	return retval;
 }
diff --git a/drivers/net/usb/cx82310_eth.c b/drivers/net/usb/cx82310_eth.c
index c4568a491dc4..79a47e2fd437 100644
--- a/drivers/net/usb/cx82310_eth.c
+++ b/drivers/net/usb/cx82310_eth.c
@@ -146,6 +146,7 @@ static int cx82310_bind(struct usbnet *dev, struct usb_interface *intf)
 	u8 link[3];
 	int timeout = 50;
 	struct cx82310_priv *priv;
+	u8 addr[ETH_ALEN];
 
 	/* avoid ADSL modems - continue only if iProduct is "USB NET CARD" */
 	if (usb_string(udev, udev->descriptor.iProduct, buf, sizeof(buf)) > 0
@@ -202,12 +203,12 @@ static int cx82310_bind(struct usbnet *dev, struct usb_interface *intf)
 		goto err;
 
 	/* get the MAC address */
-	ret = cx82310_cmd(dev, CMD_GET_MAC_ADDR, true, NULL, 0,
-			  dev->net->dev_addr, ETH_ALEN);
+	ret = cx82310_cmd(dev, CMD_GET_MAC_ADDR, true, NULL, 0, addr, ETH_ALEN);
 	if (ret) {
 		netdev_err(dev->net, "unable to read MAC address: %d\n", ret);
 		goto err;
 	}
+	eth_hw_addr_set(dev->net, addr);
 
 	/* start (does not seem to have any effect?) */
 	ret = cx82310_cmd(dev, CMD_START, false, NULL, 0, NULL, 0);
diff --git a/drivers/net/usb/kaweth.c b/drivers/net/usb/kaweth.c
index 144c686b4333..9b2bc1993ece 100644
--- a/drivers/net/usb/kaweth.c
+++ b/drivers/net/usb/kaweth.c
@@ -1044,8 +1044,7 @@ static int kaweth_probe(
 		goto err_all_but_rxbuf;
 
 	memcpy(netdev->broadcast, &bcast_addr, sizeof(bcast_addr));
-	memcpy(netdev->dev_addr, &kaweth->configuration.hw_addr,
-               sizeof(kaweth->configuration.hw_addr));
+	eth_hw_addr_set(netdev, (u8 *)&kaweth->configuration.hw_addr);
 
 	netdev->netdev_ops = &kaweth_netdev_ops;
 	netdev->watchdog_timeo = KAWETH_TX_TIMEOUT;
diff --git a/drivers/net/usb/mcs7830.c b/drivers/net/usb/mcs7830.c
index 5f42db26d200..326cc4e749d8 100644
--- a/drivers/net/usb/mcs7830.c
+++ b/drivers/net/usb/mcs7830.c
@@ -473,17 +473,19 @@ static const struct net_device_ops mcs7830_netdev_ops = {
 static int mcs7830_bind(struct usbnet *dev, struct usb_interface *udev)
 {
 	struct net_device *net = dev->net;
+	u8 addr[ETH_ALEN];
 	int ret;
 	int retry;
 
 	/* Initial startup: Gather MAC address setting from EEPROM */
 	ret = -EINVAL;
 	for (retry = 0; retry < 5 && ret; retry++)
-		ret = mcs7830_hif_get_mac_address(dev, net->dev_addr);
+		ret = mcs7830_hif_get_mac_address(dev, addr);
 	if (ret) {
 		dev_warn(&dev->udev->dev, "Cannot read MAC address\n");
 		goto out;
 	}
+	eth_hw_addr_set(net, addr);
 
 	mcs7830_data_set_multicast(net);
 
diff --git a/drivers/net/usb/sierra_net.c b/drivers/net/usb/sierra_net.c
index 55025202dc4f..bb4cbe8fc846 100644
--- a/drivers/net/usb/sierra_net.c
+++ b/drivers/net/usb/sierra_net.c
@@ -669,6 +669,7 @@ static int sierra_net_bind(struct usbnet *dev, struct usb_interface *intf)
 		0x00, 0x00, SIERRA_NET_HIP_MSYNC_ID, 0x00};
 	static const u8 shdwn_tmplate[sizeof(priv->shdwn_msg)] = {
 		0x00, 0x00, SIERRA_NET_HIP_SHUTD_ID, 0x00};
+	u8 mod[2];
 
 	dev_dbg(&dev->udev->dev, "%s", __func__);
 
@@ -698,8 +699,9 @@ static int sierra_net_bind(struct usbnet *dev, struct usb_interface *intf)
 	dev->net->netdev_ops = &sierra_net_device_ops;
 
 	/* change MAC addr to include, ifacenum, and to be unique */
-	dev->net->dev_addr[ETH_ALEN-2] = atomic_inc_return(&iface_counter);
-	dev->net->dev_addr[ETH_ALEN-1] = ifacenum;
+	mod[0] = atomic_inc_return(&iface_counter);
+	mod[1] = ifacenum;
+	dev_addr_mod(dev->net, ETH_ALEN - 2, mod, 2);
 
 	/* prepare shutdown message template */
 	memcpy(priv->shdwn_msg, shdwn_tmplate, sizeof(priv->shdwn_msg));
diff --git a/drivers/net/usb/sr9700.c b/drivers/net/usb/sr9700.c
index 15209de1849e..b658510cc9a4 100644
--- a/drivers/net/usb/sr9700.c
+++ b/drivers/net/usb/sr9700.c
@@ -320,6 +320,7 @@ static int sr9700_bind(struct usbnet *dev, struct usb_interface *intf)
 {
 	struct net_device *netdev;
 	struct mii_if_info *mii;
+	u8 addr[ETH_ALEN];
 	int ret;
 
 	ret = usbnet_get_endpoints(dev, intf);
@@ -350,11 +351,12 @@ static int sr9700_bind(struct usbnet *dev, struct usb_interface *intf)
 	 * EEPROM automatically to PAR. In case there is no EEPROM externally,
 	 * a default MAC address is stored in PAR for making chip work properly.
 	 */
-	if (sr_read(dev, SR_PAR, ETH_ALEN, netdev->dev_addr) < 0) {
+	if (sr_read(dev, SR_PAR, ETH_ALEN, addr) < 0) {
 		netdev_err(netdev, "Error reading MAC address\n");
 		ret = -ENODEV;
 		goto out;
 	}
+	eth_hw_addr_set(netdev, addr);
 
 	/* power up and reset phy */
 	sr_write_reg(dev, SR_PRR, PRR_PHY_RST);
diff --git a/drivers/net/usb/sr9800.c b/drivers/net/usb/sr9800.c
index 838f4e9e8b58..f5e19f3ef6cd 100644
--- a/drivers/net/usb/sr9800.c
+++ b/drivers/net/usb/sr9800.c
@@ -731,6 +731,7 @@ static int sr9800_bind(struct usbnet *dev, struct usb_interface *intf)
 	struct sr_data *data = (struct sr_data *)&dev->data;
 	u16 led01_mux, led23_mux;
 	int ret, embd_phy;
+	u8 addr[ETH_ALEN];
 	u32 phyid;
 	u16 rx_ctl;
 
@@ -754,12 +755,12 @@ static int sr9800_bind(struct usbnet *dev, struct usb_interface *intf)
 	}
 
 	/* Get the MAC address */
-	ret = sr_read_cmd(dev, SR_CMD_READ_NODE_ID, 0, 0, ETH_ALEN,
-			  dev->net->dev_addr);
+	ret = sr_read_cmd(dev, SR_CMD_READ_NODE_ID, 0, 0, ETH_ALEN, addr);
 	if (ret < 0) {
 		netdev_dbg(dev->net, "Failed to read MAC address: %d\n", ret);
 		return ret;
 	}
+	eth_hw_addr_set(dev->net, addr);
 	netdev_dbg(dev->net, "mac addr : %pM\n", dev->net->dev_addr);
 
 	/* Initialize MII structure */
diff --git a/drivers/net/usb/usbnet.c b/drivers/net/usb/usbnet.c
index 840c1c2ab16a..1797ee5ad566 100644
--- a/drivers/net/usb/usbnet.c
+++ b/drivers/net/usb/usbnet.c
@@ -165,12 +165,13 @@ EXPORT_SYMBOL_GPL(usbnet_get_endpoints);
 
 int usbnet_get_ethernet_addr(struct usbnet *dev, int iMACAddress)
 {
+	u8		addr[ETH_ALEN];
 	int 		tmp = -1, ret;
 	unsigned char	buf [13];
 
 	ret = usb_string(dev->udev, iMACAddress, buf, sizeof buf);
 	if (ret == 12)
-		tmp = hex2bin(dev->net->dev_addr, buf, 6);
+		tmp = hex2bin(addr, buf, 6);
 	if (tmp < 0) {
 		dev_dbg(&dev->udev->dev,
 			"bad MAC string %d fetch, %d\n", iMACAddress, tmp);
@@ -178,6 +179,7 @@ int usbnet_get_ethernet_addr(struct usbnet *dev, int iMACAddress)
 			ret = -EINVAL;
 		return ret;
 	}
+	eth_hw_addr_set(dev->net, addr);
 	return 0;
 }
 EXPORT_SYMBOL_GPL(usbnet_get_ethernet_addr);
@@ -1726,7 +1728,7 @@ usbnet_probe (struct usb_interface *udev, const struct usb_device_id *prod)
 
 	dev->net = net;
 	strscpy(net->name, "usb%d", sizeof(net->name));
-	memcpy (net->dev_addr, node_id, sizeof node_id);
+	eth_hw_addr_set(net, node_id);
 
 	/* rx and tx sides can use different message sizes;
 	 * bind() should set rx_urb_size in that case.
-- 
2.31.1


^ permalink raw reply	[flat|nested] 17+ messages in thread

* [PATCH net-next v2 05/12] fddi: defxx,defza: use dev_addr_set()
  2021-10-21 13:12 [PATCH net-next v2 00/12] net: don't write directly to netdev->dev_addr Jakub Kicinski
                   ` (3 preceding siblings ...)
  2021-10-21 13:12 ` [PATCH net-next v2 04/12] net: usb: don't write directly to netdev->dev_addr Jakub Kicinski
@ 2021-10-21 13:12 ` Jakub Kicinski
  2021-10-21 13:12 ` [PATCH net-next v2 06/12] fddi: skfp: constify and " Jakub Kicinski
                   ` (7 subsequent siblings)
  12 siblings, 0 replies; 17+ messages in thread
From: Jakub Kicinski @ 2021-10-21 13:12 UTC (permalink / raw)
  To: davem; +Cc: netdev, Jakub Kicinski, Maciej W . Rozycki

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.

Acked-by: Maciej W. Rozycki <macro@orcam.me.uk>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
 drivers/net/fddi/defxx.c | 6 +++---
 drivers/net/fddi/defza.c | 2 +-
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/net/fddi/defxx.c b/drivers/net/fddi/defxx.c
index 5810e8473789..b584ffe38ad6 100644
--- a/drivers/net/fddi/defxx.c
+++ b/drivers/net/fddi/defxx.c
@@ -1117,7 +1117,7 @@ static int dfx_driver_init(struct net_device *dev, const char *print_name,
 	 *       dfx_ctl_set_mac_address.
 	 */
 
-	memcpy(dev->dev_addr, bp->factory_mac_addr, FDDI_K_ALEN);
+	dev_addr_set(dev, bp->factory_mac_addr);
 	if (dfx_bus_tc)
 		board_name = "DEFTA";
 	if (dfx_bus_eisa)
@@ -1474,7 +1474,7 @@ static int dfx_open(struct net_device *dev)
 	 *		 address.
 	 */
 
-	memcpy(dev->dev_addr, bp->factory_mac_addr, FDDI_K_ALEN);
+	dev_addr_set(dev, bp->factory_mac_addr);
 
 	/* Clear local unicast/multicast address tables and counts */
 
@@ -2379,7 +2379,7 @@ static int dfx_ctl_set_mac_address(struct net_device *dev, void *addr)
 
 	/* Copy unicast address to driver-maintained structs and update count */
 
-	memcpy(dev->dev_addr, p_sockaddr->sa_data, FDDI_K_ALEN);	/* update device struct */
+	dev_addr_set(dev, p_sockaddr->sa_data);				/* update device struct */
 	memcpy(&bp->uc_table[0], p_sockaddr->sa_data, FDDI_K_ALEN);	/* update driver struct */
 	bp->uc_count = 1;
 
diff --git a/drivers/net/fddi/defza.c b/drivers/net/fddi/defza.c
index 0de2c4552f5e..3a6b08eb5e1b 100644
--- a/drivers/net/fddi/defza.c
+++ b/drivers/net/fddi/defza.c
@@ -1380,7 +1380,7 @@ static int fza_probe(struct device *bdev)
 		goto err_out_irq;
 
 	fza_reads(&init->hw_addr, &hw_addr, sizeof(hw_addr));
-	memcpy(dev->dev_addr, &hw_addr, FDDI_K_ALEN);
+	dev_addr_set(dev, &hw_addr);
 
 	fza_reads(&init->rom_rev, &rom_rev, sizeof(rom_rev));
 	fza_reads(&init->fw_rev, &fw_rev, sizeof(fw_rev));
-- 
2.31.1


^ permalink raw reply	[flat|nested] 17+ messages in thread

* [PATCH net-next v2 06/12] fddi: skfp: constify and use dev_addr_set()
  2021-10-21 13:12 [PATCH net-next v2 00/12] net: don't write directly to netdev->dev_addr Jakub Kicinski
                   ` (4 preceding siblings ...)
  2021-10-21 13:12 ` [PATCH net-next v2 05/12] fddi: defxx,defza: use dev_addr_set() Jakub Kicinski
@ 2021-10-21 13:12 ` Jakub Kicinski
  2021-10-21 13:12 ` [PATCH net-next v2 07/12] net: fjes: constify and use eth_hw_addr_set() Jakub Kicinski
                   ` (6 subsequent siblings)
  12 siblings, 0 replies; 17+ messages in thread
From: Jakub Kicinski @ 2021-10-21 13:12 UTC (permalink / raw)
  To: davem; +Cc: netdev, Jakub Kicinski

Get it ready for constant netdev->dev_addr.

Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
 drivers/net/fddi/skfp/h/smc.h   | 2 +-
 drivers/net/fddi/skfp/skfddi.c  | 2 +-
 drivers/net/fddi/skfp/smtinit.c | 4 ++--
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/net/fddi/skfp/h/smc.h b/drivers/net/fddi/skfp/h/smc.h
index 3814a2ff64ae..b0e6ce0d893e 100644
--- a/drivers/net/fddi/skfp/h/smc.h
+++ b/drivers/net/fddi/skfp/h/smc.h
@@ -470,7 +470,7 @@ void card_stop(struct s_smc *smc);
 void init_board(struct s_smc *smc, u_char *mac_addr);
 int init_fplus(struct s_smc *smc);
 void init_plc(struct s_smc *smc);
-int init_smt(struct s_smc *smc, u_char *mac_addr);
+int init_smt(struct s_smc *smc, const u_char *mac_addr);
 void mac1_irq(struct s_smc *smc, u_short stu, u_short stl);
 void mac2_irq(struct s_smc *smc, u_short code_s2u, u_short code_s2l);
 void mac3_irq(struct s_smc *smc, u_short code_s3u, u_short code_s3l);
diff --git a/drivers/net/fddi/skfp/skfddi.c b/drivers/net/fddi/skfp/skfddi.c
index 652cb174302e..2b6a607ac0b7 100644
--- a/drivers/net/fddi/skfp/skfddi.c
+++ b/drivers/net/fddi/skfp/skfddi.c
@@ -925,7 +925,7 @@ static int skfp_ctl_set_mac_address(struct net_device *dev, void *addr)
 	unsigned long Flags;
 
 
-	memcpy(dev->dev_addr, p_sockaddr->sa_data, FDDI_K_ALEN);
+	dev_addr_set(dev, p_sockaddr->sa_data);
 	spin_lock_irqsave(&bp->DriverLock, Flags);
 	ResetAdapter(smc);
 	spin_unlock_irqrestore(&bp->DriverLock, Flags);
diff --git a/drivers/net/fddi/skfp/smtinit.c b/drivers/net/fddi/skfp/smtinit.c
index c9898c83fe30..8b172c195685 100644
--- a/drivers/net/fddi/skfp/smtinit.c
+++ b/drivers/net/fddi/skfp/smtinit.c
@@ -19,7 +19,7 @@
 #include "h/fddi.h"
 #include "h/smc.h"
 
-void init_fddi_driver(struct s_smc *smc, u_char *mac_addr);
+void init_fddi_driver(struct s_smc *smc, const u_char *mac_addr);
 
 /* define global debug variable */
 #if defined(DEBUG) && !defined(DEBUG_BRD)
@@ -57,7 +57,7 @@ static void set_oem_spec_val(struct s_smc *smc)
 /*
  * Init SMT
  */
-int init_smt(struct s_smc *smc, u_char *mac_addr)
+int init_smt(struct s_smc *smc, const u_char *mac_addr)
 /* u_char *mac_addr;	canonical address or NULL */
 {
 	int	p ;
-- 
2.31.1


^ permalink raw reply	[flat|nested] 17+ messages in thread

* [PATCH net-next v2 07/12] net: fjes: constify and use eth_hw_addr_set()
  2021-10-21 13:12 [PATCH net-next v2 00/12] net: don't write directly to netdev->dev_addr Jakub Kicinski
                   ` (5 preceding siblings ...)
  2021-10-21 13:12 ` [PATCH net-next v2 06/12] fddi: skfp: constify and " Jakub Kicinski
@ 2021-10-21 13:12 ` Jakub Kicinski
  2021-10-21 13:12 ` [PATCH net-next v2 08/12] net: hippi: use dev_addr_set() Jakub Kicinski
                   ` (5 subsequent siblings)
  12 siblings, 0 replies; 17+ messages in thread
From: Jakub Kicinski @ 2021-10-21 13:12 UTC (permalink / raw)
  To: davem; +Cc: netdev, Jakub Kicinski

Get it ready for constant netdev->dev_addr.

Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
 drivers/net/fjes/fjes_hw.c   |  3 ++-
 drivers/net/fjes/fjes_hw.h   |  2 +-
 drivers/net/fjes/fjes_main.c | 14 ++++++++------
 3 files changed, 11 insertions(+), 8 deletions(-)

diff --git a/drivers/net/fjes/fjes_hw.c b/drivers/net/fjes/fjes_hw.c
index 065bb0a40b1d..704e949484d0 100644
--- a/drivers/net/fjes/fjes_hw.c
+++ b/drivers/net/fjes/fjes_hw.c
@@ -137,7 +137,8 @@ static void fjes_hw_free_epbuf(struct epbuf_handler *epbh)
 	epbh->ring = NULL;
 }
 
-void fjes_hw_setup_epbuf(struct epbuf_handler *epbh, u8 *mac_addr, u32 mtu)
+void fjes_hw_setup_epbuf(struct epbuf_handler *epbh, const u8 *mac_addr,
+			 u32 mtu)
 {
 	union ep_buffer_info *info = epbh->info;
 	u16 vlan_id[EP_BUFFER_SUPPORT_VLAN_MAX];
diff --git a/drivers/net/fjes/fjes_hw.h b/drivers/net/fjes/fjes_hw.h
index b4608ea2a2d5..997c7b37a402 100644
--- a/drivers/net/fjes/fjes_hw.h
+++ b/drivers/net/fjes/fjes_hw.h
@@ -330,7 +330,7 @@ int fjes_hw_register_buff_addr(struct fjes_hw *, int,
 int fjes_hw_unregister_buff_addr(struct fjes_hw *, int);
 void fjes_hw_init_command_registers(struct fjes_hw *,
 				    struct fjes_device_command_param *);
-void fjes_hw_setup_epbuf(struct epbuf_handler *, u8 *, u32);
+void fjes_hw_setup_epbuf(struct epbuf_handler *, const u8 *, u32);
 int fjes_hw_raise_interrupt(struct fjes_hw *, int, enum REG_ICTL_MASK);
 void fjes_hw_set_irqmask(struct fjes_hw *, enum REG_ICTL_MASK, bool);
 u32 fjes_hw_capture_interrupt_status(struct fjes_hw *);
diff --git a/drivers/net/fjes/fjes_main.c b/drivers/net/fjes/fjes_main.c
index 185c8a398681..b06c17ac8d4e 100644
--- a/drivers/net/fjes/fjes_main.c
+++ b/drivers/net/fjes/fjes_main.c
@@ -1203,6 +1203,7 @@ static int fjes_probe(struct platform_device *plat_dev)
 	struct net_device *netdev;
 	struct resource *res;
 	struct fjes_hw *hw;
+	u8 addr[ETH_ALEN];
 	int err;
 
 	err = -ENOMEM;
@@ -1266,12 +1267,13 @@ static int fjes_probe(struct platform_device *plat_dev)
 		goto err_free_control_wq;
 
 	/* setup MAC address (02:00:00:00:00:[epid])*/
-	netdev->dev_addr[0] = 2;
-	netdev->dev_addr[1] = 0;
-	netdev->dev_addr[2] = 0;
-	netdev->dev_addr[3] = 0;
-	netdev->dev_addr[4] = 0;
-	netdev->dev_addr[5] = hw->my_epid; /* EPID */
+	addr[0] = 2;
+	addr[1] = 0;
+	addr[2] = 0;
+	addr[3] = 0;
+	addr[4] = 0;
+	addr[5] = hw->my_epid; /* EPID */
+	eth_hw_addr_set(netdev, addr);
 
 	err = register_netdev(netdev);
 	if (err)
-- 
2.31.1


^ permalink raw reply	[flat|nested] 17+ messages in thread

* [PATCH net-next v2 08/12] net: hippi: use dev_addr_set()
  2021-10-21 13:12 [PATCH net-next v2 00/12] net: don't write directly to netdev->dev_addr Jakub Kicinski
                   ` (6 preceding siblings ...)
  2021-10-21 13:12 ` [PATCH net-next v2 07/12] net: fjes: constify and use eth_hw_addr_set() Jakub Kicinski
@ 2021-10-21 13:12 ` Jakub Kicinski
  2021-10-21 13:12 ` [PATCH net-next v2 09/12] net: s390: constify and use eth_hw_addr_set() Jakub Kicinski
                   ` (4 subsequent siblings)
  12 siblings, 0 replies; 17+ messages in thread
From: Jakub Kicinski @ 2021-10-21 13:12 UTC (permalink / raw)
  To: davem; +Cc: netdev, Jakub Kicinski, jes, linux-hippi

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.

Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
CC: jes@trained-monkey.org
CC: linux-hippi@sunsite.dk
---
 drivers/net/hippi/rrunner.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/net/hippi/rrunner.c b/drivers/net/hippi/rrunner.c
index 7661dbb31162..16105292b140 100644
--- a/drivers/net/hippi/rrunner.c
+++ b/drivers/net/hippi/rrunner.c
@@ -502,6 +502,7 @@ static unsigned int write_eeprom(struct rr_private *rrpriv,
 
 static int rr_init(struct net_device *dev)
 {
+	u8 addr[HIPPI_ALEN] __aligned(4);
 	struct rr_private *rrpriv;
 	struct rr_regs __iomem *regs;
 	u32 sram_size, rev;
@@ -537,10 +538,11 @@ static int rr_init(struct net_device *dev)
 	 * other method I've seen.  -VAL
 	 */
 
-	*(__be16 *)(dev->dev_addr) =
+	*(__be16 *)(addr) =
 	  htons(rr_read_eeprom_word(rrpriv, offsetof(struct eeprom, manf.BoardULA)));
-	*(__be32 *)(dev->dev_addr+2) =
+	*(__be32 *)(addr+2) =
 	  htonl(rr_read_eeprom_word(rrpriv, offsetof(struct eeprom, manf.BoardULA[4])));
+	dev_addr_set(dev, addr);
 
 	printk("  MAC: %pM\n", dev->dev_addr);
 
-- 
2.31.1


^ permalink raw reply	[flat|nested] 17+ messages in thread

* [PATCH net-next v2 09/12] net: s390: constify and use eth_hw_addr_set()
  2021-10-21 13:12 [PATCH net-next v2 00/12] net: don't write directly to netdev->dev_addr Jakub Kicinski
                   ` (7 preceding siblings ...)
  2021-10-21 13:12 ` [PATCH net-next v2 08/12] net: hippi: use dev_addr_set() Jakub Kicinski
@ 2021-10-21 13:12 ` Jakub Kicinski
  2021-10-21 13:12 ` [PATCH net-next v2 10/12] net: plip: " Jakub Kicinski
                   ` (3 subsequent siblings)
  12 siblings, 0 replies; 17+ messages in thread
From: Jakub Kicinski @ 2021-10-21 13:12 UTC (permalink / raw)
  To: davem
  Cc: netdev, Jakub Kicinski, Julian Wiedmann, kgraul, hca, gor,
	borntraeger, linux-s390

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.

Make sure local references to netdev->dev_addr are constant.

Acked-by: Julian Wiedmann <jwi@linux.ibm.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
CC: kgraul@linux.ibm.com
CC: hca@linux.ibm.com
CC: gor@linux.ibm.com
CC: borntraeger@de.ibm.com
CC: linux-s390@vger.kernel.org
---
 drivers/s390/net/lcs.c            | 2 +-
 drivers/s390/net/qeth_core_main.c | 4 ++--
 drivers/s390/net/qeth_l2_main.c   | 6 +++---
 drivers/s390/net/qeth_l3_main.c   | 3 +--
 4 files changed, 7 insertions(+), 8 deletions(-)

diff --git a/drivers/s390/net/lcs.c b/drivers/s390/net/lcs.c
index c18fd48e02b6..2a6479740600 100644
--- a/drivers/s390/net/lcs.c
+++ b/drivers/s390/net/lcs.c
@@ -2162,7 +2162,7 @@ lcs_new_device(struct ccwgroup_device *ccwgdev)
 	card->dev->ml_priv = card;
 	card->dev->netdev_ops = &lcs_netdev_ops;
 	card->dev->dev_port = card->portno;
-	memcpy(card->dev->dev_addr, card->mac, LCS_MAC_LENGTH);
+	eth_hw_addr_set(card->dev, card->mac);
 #ifdef CONFIG_IP_MULTICAST
 	if (!lcs_check_multicast_support(card))
 		card->dev->netdev_ops = &lcs_mc_netdev_ops;
diff --git a/drivers/s390/net/qeth_core_main.c b/drivers/s390/net/qeth_core_main.c
index e9807d2996a9..15999a816054 100644
--- a/drivers/s390/net/qeth_core_main.c
+++ b/drivers/s390/net/qeth_core_main.c
@@ -4375,7 +4375,7 @@ static int qeth_setadpparms_change_macaddr_cb(struct qeth_card *card,
 	    !(adp_cmd->hdr.flags & QETH_SETADP_FLAGS_VIRTUAL_MAC))
 		return -EADDRNOTAVAIL;
 
-	ether_addr_copy(card->dev->dev_addr, adp_cmd->data.change_addr.addr);
+	eth_hw_addr_set(card->dev, adp_cmd->data.change_addr.addr);
 	return 0;
 }
 
@@ -5046,7 +5046,7 @@ int qeth_vm_request_mac(struct qeth_card *card)
 		QETH_CARD_TEXT(card, 2, "badmac");
 		QETH_CARD_HEX(card, 2, response->mac, ETH_ALEN);
 	} else {
-		ether_addr_copy(card->dev->dev_addr, response->mac);
+		eth_hw_addr_set(card->dev, response->mac);
 	}
 
 out:
diff --git a/drivers/s390/net/qeth_l2_main.c b/drivers/s390/net/qeth_l2_main.c
index dc6c00768d91..5b6187f2d9d6 100644
--- a/drivers/s390/net/qeth_l2_main.c
+++ b/drivers/s390/net/qeth_l2_main.c
@@ -71,7 +71,7 @@ static int qeth_l2_send_setdelmac_cb(struct qeth_card *card,
 	return qeth_l2_setdelmac_makerc(card, cmd->hdr.return_code);
 }
 
-static int qeth_l2_send_setdelmac(struct qeth_card *card, __u8 *mac,
+static int qeth_l2_send_setdelmac(struct qeth_card *card, const __u8 *mac,
 			   enum qeth_ipa_cmds ipacmd)
 {
 	struct qeth_ipa_cmd *cmd;
@@ -88,7 +88,7 @@ static int qeth_l2_send_setdelmac(struct qeth_card *card, __u8 *mac,
 	return qeth_send_ipa_cmd(card, iob, qeth_l2_send_setdelmac_cb, NULL);
 }
 
-static int qeth_l2_send_setmac(struct qeth_card *card, __u8 *mac)
+static int qeth_l2_send_setmac(struct qeth_card *card, const __u8 *mac)
 {
 	int rc;
 
@@ -377,7 +377,7 @@ static int qeth_l2_set_mac_address(struct net_device *dev, void *p)
 	if (rc)
 		return rc;
 	ether_addr_copy(old_addr, dev->dev_addr);
-	ether_addr_copy(dev->dev_addr, addr->sa_data);
+	eth_hw_addr_set(dev, addr->sa_data);
 
 	if (card->info.dev_addr_is_registered)
 		qeth_l2_remove_mac(card, old_addr);
diff --git a/drivers/s390/net/qeth_l3_main.c b/drivers/s390/net/qeth_l3_main.c
index 6fd3e288f059..e6e921310211 100644
--- a/drivers/s390/net/qeth_l3_main.c
+++ b/drivers/s390/net/qeth_l3_main.c
@@ -913,8 +913,7 @@ static int qeth_l3_iqd_read_initial_mac_cb(struct qeth_card *card,
 	if (!is_valid_ether_addr(cmd->data.create_destroy_addr.mac_addr))
 		return -EADDRNOTAVAIL;
 
-	ether_addr_copy(card->dev->dev_addr,
-			cmd->data.create_destroy_addr.mac_addr);
+	eth_hw_addr_set(card->dev, cmd->data.create_destroy_addr.mac_addr);
 	return 0;
 }
 
-- 
2.31.1


^ permalink raw reply	[flat|nested] 17+ messages in thread

* [PATCH net-next v2 10/12] net: plip: use eth_hw_addr_set()
  2021-10-21 13:12 [PATCH net-next v2 00/12] net: don't write directly to netdev->dev_addr Jakub Kicinski
                   ` (8 preceding siblings ...)
  2021-10-21 13:12 ` [PATCH net-next v2 09/12] net: s390: constify and use eth_hw_addr_set() Jakub Kicinski
@ 2021-10-21 13:12 ` Jakub Kicinski
  2021-10-21 13:12 ` [PATCH net-next v2 11/12] net: sb1000,rionet: " Jakub Kicinski
                   ` (2 subsequent siblings)
  12 siblings, 0 replies; 17+ messages in thread
From: Jakub Kicinski @ 2021-10-21 13:12 UTC (permalink / raw)
  To: davem; +Cc: netdev, Jakub Kicinski

Get it ready for constant netdev->dev_addr.

Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
 drivers/net/plip/plip.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/net/plip/plip.c b/drivers/net/plip/plip.c
index 82d609401711..0d491b4d6667 100644
--- a/drivers/net/plip/plip.c
+++ b/drivers/net/plip/plip.c
@@ -284,12 +284,16 @@ static const struct net_device_ops plip_netdev_ops = {
 static void
 plip_init_netdev(struct net_device *dev)
 {
+	static const u8 addr_init[ETH_ALEN] = {
+		0xfc, 0xfc, 0xfc,
+		0xfc, 0xfc, 0xfc,
+	};
 	struct net_local *nl = netdev_priv(dev);
 
 	/* Then, override parts of it */
 	dev->tx_queue_len 	 = 10;
 	dev->flags	         = IFF_POINTOPOINT|IFF_NOARP;
-	memset(dev->dev_addr, 0xfc, ETH_ALEN);
+	eth_hw_addr_set(dev, addr_init);
 
 	dev->netdev_ops		 = &plip_netdev_ops;
 	dev->header_ops          = &plip_header_ops;
@@ -1109,7 +1113,7 @@ plip_open(struct net_device *dev)
 		   plip_init_dev(). */
 		const struct in_ifaddr *ifa = rcu_dereference(in_dev->ifa_list);
 		if (ifa != NULL) {
-			memcpy(dev->dev_addr+2, &ifa->ifa_local, 4);
+			dev_addr_mod(dev, 2, &ifa->ifa_local, 4);
 		}
 	}
 
-- 
2.31.1


^ permalink raw reply	[flat|nested] 17+ messages in thread

* [PATCH net-next v2 11/12] net: sb1000,rionet: use eth_hw_addr_set()
  2021-10-21 13:12 [PATCH net-next v2 00/12] net: don't write directly to netdev->dev_addr Jakub Kicinski
                   ` (9 preceding siblings ...)
  2021-10-21 13:12 ` [PATCH net-next v2 10/12] net: plip: " Jakub Kicinski
@ 2021-10-21 13:12 ` Jakub Kicinski
  2021-10-21 13:12 ` [PATCH net-next v2 12/12] net: hldc_fr: use dev_addr_set() Jakub Kicinski
  2021-10-22 17:20 ` [PATCH net-next v2 00/12] net: don't write directly to netdev->dev_addr patchwork-bot+netdevbpf
  12 siblings, 0 replies; 17+ messages in thread
From: Jakub Kicinski @ 2021-10-21 13:12 UTC (permalink / raw)
  To: davem; +Cc: netdev, Jakub Kicinski

Get these two oldies ready for constant netdev->dev_addr.

Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
 drivers/net/rionet.c | 14 ++++++++------
 drivers/net/sb1000.c | 12 ++++++++----
 2 files changed, 16 insertions(+), 10 deletions(-)

diff --git a/drivers/net/rionet.c b/drivers/net/rionet.c
index 2056d6ad04b5..1a95f3beb784 100644
--- a/drivers/net/rionet.c
+++ b/drivers/net/rionet.c
@@ -482,6 +482,7 @@ static int rionet_setup_netdev(struct rio_mport *mport, struct net_device *ndev)
 {
 	int rc = 0;
 	struct rionet_private *rnet;
+	u8 addr[ETH_ALEN];
 	u16 device_id;
 	const size_t rionet_active_bytes = sizeof(void *) *
 				RIO_MAX_ROUTE_ENTRIES(mport->sys_size);
@@ -501,12 +502,13 @@ static int rionet_setup_netdev(struct rio_mport *mport, struct net_device *ndev)
 
 	/* Set the default MAC address */
 	device_id = rio_local_get_device_id(mport);
-	ndev->dev_addr[0] = 0x00;
-	ndev->dev_addr[1] = 0x01;
-	ndev->dev_addr[2] = 0x00;
-	ndev->dev_addr[3] = 0x01;
-	ndev->dev_addr[4] = device_id >> 8;
-	ndev->dev_addr[5] = device_id & 0xff;
+	addr[0] = 0x00;
+	addr[1] = 0x01;
+	addr[2] = 0x00;
+	addr[3] = 0x01;
+	addr[4] = device_id >> 8;
+	addr[5] = device_id & 0xff;
+	eth_hw_addr_set(ndev, addr);
 
 	ndev->netdev_ops = &rionet_netdev_ops;
 	ndev->mtu = RIONET_MAX_MTU;
diff --git a/drivers/net/sb1000.c b/drivers/net/sb1000.c
index f01c9db01b16..57a6d598467b 100644
--- a/drivers/net/sb1000.c
+++ b/drivers/net/sb1000.c
@@ -149,6 +149,7 @@ sb1000_probe_one(struct pnp_dev *pdev, const struct pnp_device_id *id)
 	unsigned short ioaddr[2], irq;
 	unsigned int serial_number;
 	int error = -ENODEV;
+	u8 addr[ETH_ALEN];
 
 	if (pnp_device_attach(pdev) < 0)
 		return -ENODEV;
@@ -203,10 +204,13 @@ sb1000_probe_one(struct pnp_dev *pdev, const struct pnp_device_id *id)
 	dev->netdev_ops	= &sb1000_netdev_ops;
 
 	/* hardware address is 0:0:serial_number */
-	dev->dev_addr[2]	= serial_number >> 24 & 0xff;
-	dev->dev_addr[3]	= serial_number >> 16 & 0xff;
-	dev->dev_addr[4]	= serial_number >>  8 & 0xff;
-	dev->dev_addr[5]	= serial_number >>  0 & 0xff;
+	addr[0] = 0;
+	addr[1] = 0;
+	addr[2]	= serial_number >> 24 & 0xff;
+	addr[3]	= serial_number >> 16 & 0xff;
+	addr[4]	= serial_number >>  8 & 0xff;
+	addr[5]	= serial_number >>  0 & 0xff;
+	eth_hw_addr_set(dev, addr);
 
 	pnp_set_drvdata(pdev, dev);
 
-- 
2.31.1


^ permalink raw reply	[flat|nested] 17+ messages in thread

* [PATCH net-next v2 12/12] net: hldc_fr: use dev_addr_set()
  2021-10-21 13:12 [PATCH net-next v2 00/12] net: don't write directly to netdev->dev_addr Jakub Kicinski
                   ` (10 preceding siblings ...)
  2021-10-21 13:12 ` [PATCH net-next v2 11/12] net: sb1000,rionet: " Jakub Kicinski
@ 2021-10-21 13:12 ` Jakub Kicinski
  2021-10-22  6:22   ` Krzysztof Hałasa
  2021-10-22 17:20 ` [PATCH net-next v2 00/12] net: don't write directly to netdev->dev_addr patchwork-bot+netdevbpf
  12 siblings, 1 reply; 17+ messages in thread
From: Jakub Kicinski @ 2021-10-21 13:12 UTC (permalink / raw)
  To: davem; +Cc: netdev, Jakub Kicinski, khc

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.

Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
CC: khc@pm.waw.pl
---
 drivers/net/wan/hdlc_fr.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/net/wan/hdlc_fr.c b/drivers/net/wan/hdlc_fr.c
index 7637edce443e..81e72bc1891f 100644
--- a/drivers/net/wan/hdlc_fr.c
+++ b/drivers/net/wan/hdlc_fr.c
@@ -1093,7 +1093,9 @@ static int fr_add_pvc(struct net_device *frad, unsigned int dlci, int type)
 		dev->priv_flags &= ~IFF_TX_SKB_SHARING;
 		eth_hw_addr_random(dev);
 	} else {
-		*(__be16 *)dev->dev_addr = htons(dlci);
+		__be16 addr = htons(dlci);
+
+		dev_addr_set(dev, (u8 *)&addr);
 		dlci_to_q922(dev->broadcast, dlci);
 	}
 	dev->netdev_ops = &pvc_ops;
-- 
2.31.1


^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH net-next v2 12/12] net: hldc_fr: use dev_addr_set()
  2021-10-21 13:12 ` [PATCH net-next v2 12/12] net: hldc_fr: use dev_addr_set() Jakub Kicinski
@ 2021-10-22  6:22   ` Krzysztof Hałasa
  0 siblings, 0 replies; 17+ messages in thread
From: Krzysztof Hałasa @ 2021-10-22  6:22 UTC (permalink / raw)
  To: Jakub Kicinski; +Cc: davem, netdev

Jakub Kicinski <kuba@kernel.org> writes:

> 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.
>
> Signed-off-by: Jakub Kicinski <kuba@kernel.org>

Acked-by: Krzysztof Hałasa <khalasa@piap.pl>

> --- a/drivers/net/wan/hdlc_fr.c
> +++ b/drivers/net/wan/hdlc_fr.c
> @@ -1093,7 +1093,9 @@ static int fr_add_pvc(struct net_device *frad, unsigned int dlci, int type)
>  		dev->priv_flags &= ~IFF_TX_SKB_SHARING;
>  		eth_hw_addr_random(dev);
>  	} else {
> -		*(__be16 *)dev->dev_addr = htons(dlci);
> +		__be16 addr = htons(dlci);
> +
> +		dev_addr_set(dev, (u8 *)&addr);
>  		dlci_to_q922(dev->broadcast, dlci);
>  	}
>  	dev->netdev_ops = &pvc_ops;

-- 
Krzysztof "Chris" Hałasa

Sieć Badawcza Łukasiewicz
Przemysłowy Instytut Automatyki i Pomiarów PIAP
Al. Jerozolimskie 202, 02-486 Warszawa

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH net-next v2 00/12] net: don't write directly to netdev->dev_addr
  2021-10-21 13:12 [PATCH net-next v2 00/12] net: don't write directly to netdev->dev_addr Jakub Kicinski
                   ` (11 preceding siblings ...)
  2021-10-21 13:12 ` [PATCH net-next v2 12/12] net: hldc_fr: use dev_addr_set() Jakub Kicinski
@ 2021-10-22 17:20 ` patchwork-bot+netdevbpf
  12 siblings, 0 replies; 17+ messages in thread
From: patchwork-bot+netdevbpf @ 2021-10-22 17:20 UTC (permalink / raw)
  To: Jakub Kicinski; +Cc: davem, netdev

Hello:

This series was applied to netdev/net-next.git (master)
by Jakub Kicinski <kuba@kernel.org>:

On Thu, 21 Oct 2021 06:12:02 -0700 you wrote:
> More conversions, mostly in usb/net.
> 
> v2: leave out catc (patch 4)
> 
> Jakub Kicinski (12):
>   net: xen: use eth_hw_addr_set()
>   usb: smsc: use eth_hw_addr_set()
>   net: qmi_wwan: use dev_addr_mod()
>   net: usb: don't write directly to netdev->dev_addr
>   fddi: defxx,defza: use dev_addr_set()
>   fddi: skfp: constify and use dev_addr_set()
>   net: fjes: constify and use eth_hw_addr_set()
>   net: hippi: use dev_addr_set()
>   net: s390: constify and use eth_hw_addr_set()
>   net: plip: use eth_hw_addr_set()
>   net: sb1000,rionet: use eth_hw_addr_set()
>   net: hldc_fr: use dev_addr_set()
> 
> [...]

Here is the summary with links:
  - [net-next,v2,01/12] net: xen: use eth_hw_addr_set()
    https://git.kernel.org/netdev/net-next/c/93772114413e
  - [net-next,v2,02/12] usb: smsc: use eth_hw_addr_set()
    https://git.kernel.org/netdev/net-next/c/a7021af707a3
  - [net-next,v2,03/12] net: qmi_wwan: use dev_addr_mod()
    https://git.kernel.org/netdev/net-next/c/18867486fea3
  - [net-next,v2,04/12] net: usb: don't write directly to netdev->dev_addr
    https://git.kernel.org/netdev/net-next/c/2674e7ea22ba
  - [net-next,v2,05/12] fddi: defxx,defza: use dev_addr_set()
    https://git.kernel.org/netdev/net-next/c/1e9258c389ee
  - [net-next,v2,06/12] fddi: skfp: constify and use dev_addr_set()
    https://git.kernel.org/netdev/net-next/c/2e0566aeb9ff
  - [net-next,v2,07/12] net: fjes: constify and use eth_hw_addr_set()
    https://git.kernel.org/netdev/net-next/c/ed088907563d
  - [net-next,v2,08/12] net: hippi: use dev_addr_set()
    https://git.kernel.org/netdev/net-next/c/5ed5b1912a81
  - [net-next,v2,09/12] net: s390: constify and use eth_hw_addr_set()
    https://git.kernel.org/netdev/net-next/c/978bb0ae8b83
  - [net-next,v2,10/12] net: plip: use eth_hw_addr_set()
    https://git.kernel.org/netdev/net-next/c/7996acffd7cc
  - [net-next,v2,11/12] net: sb1000,rionet: use eth_hw_addr_set()
    https://git.kernel.org/netdev/net-next/c/5f07da89bcd0
  - [net-next,v2,12/12] net: hldc_fr: use dev_addr_set()
    https://git.kernel.org/netdev/net-next/c/65a4fbbf2263

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH net-next v2 01/12] net: xen: use eth_hw_addr_set()
  2021-10-21 13:12 ` [PATCH net-next v2 01/12] net: xen: use eth_hw_addr_set() Jakub Kicinski
@ 2021-10-23  0:41   ` Boris Ostrovsky
  2021-10-25 10:55   ` Wei Liu
  1 sibling, 0 replies; 17+ messages in thread
From: Boris Ostrovsky @ 2021-10-23  0:41 UTC (permalink / raw)
  To: Jakub Kicinski, davem
  Cc: netdev, wei.liu, paul, jgross, sstabellini, xen-devel


On 10/21/21 9:12 AM, Jakub Kicinski wrote:
> 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.
>
> Signed-off-by: Jakub Kicinski <kuba@kernel.org>



Reviewed-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>


^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH net-next v2 01/12] net: xen: use eth_hw_addr_set()
  2021-10-21 13:12 ` [PATCH net-next v2 01/12] net: xen: use eth_hw_addr_set() Jakub Kicinski
  2021-10-23  0:41   ` Boris Ostrovsky
@ 2021-10-25 10:55   ` Wei Liu
  1 sibling, 0 replies; 17+ messages in thread
From: Wei Liu @ 2021-10-25 10:55 UTC (permalink / raw)
  To: Jakub Kicinski
  Cc: davem, netdev, wei.liu, paul, boris.ostrovsky, jgross,
	sstabellini, xen-devel

On Thu, Oct 21, 2021 at 06:12:03AM -0700, Jakub Kicinski wrote:
> 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.
> 
> Signed-off-by: Jakub Kicinski <kuba@kernel.org>

Acked-by: Wei Liu <wl@xen.org>

^ permalink raw reply	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2021-10-25 10:56 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-21 13:12 [PATCH net-next v2 00/12] net: don't write directly to netdev->dev_addr Jakub Kicinski
2021-10-21 13:12 ` [PATCH net-next v2 01/12] net: xen: use eth_hw_addr_set() Jakub Kicinski
2021-10-23  0:41   ` Boris Ostrovsky
2021-10-25 10:55   ` Wei Liu
2021-10-21 13:12 ` [PATCH net-next v2 02/12] usb: smsc: " Jakub Kicinski
2021-10-21 13:12 ` [PATCH net-next v2 03/12] net: qmi_wwan: use dev_addr_mod() Jakub Kicinski
2021-10-21 13:12 ` [PATCH net-next v2 04/12] net: usb: don't write directly to netdev->dev_addr Jakub Kicinski
2021-10-21 13:12 ` [PATCH net-next v2 05/12] fddi: defxx,defza: use dev_addr_set() Jakub Kicinski
2021-10-21 13:12 ` [PATCH net-next v2 06/12] fddi: skfp: constify and " Jakub Kicinski
2021-10-21 13:12 ` [PATCH net-next v2 07/12] net: fjes: constify and use eth_hw_addr_set() Jakub Kicinski
2021-10-21 13:12 ` [PATCH net-next v2 08/12] net: hippi: use dev_addr_set() Jakub Kicinski
2021-10-21 13:12 ` [PATCH net-next v2 09/12] net: s390: constify and use eth_hw_addr_set() Jakub Kicinski
2021-10-21 13:12 ` [PATCH net-next v2 10/12] net: plip: " Jakub Kicinski
2021-10-21 13:12 ` [PATCH net-next v2 11/12] net: sb1000,rionet: " Jakub Kicinski
2021-10-21 13:12 ` [PATCH net-next v2 12/12] net: hldc_fr: use dev_addr_set() Jakub Kicinski
2021-10-22  6:22   ` Krzysztof Hałasa
2021-10-22 17:20 ` [PATCH net-next v2 00/12] net: don't write directly to netdev->dev_addr patchwork-bot+netdevbpf

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).