wireless: don't write to netdev->dev_addr directly
Subsystems (12)
cover wireless: don't write to netdev->dev_addr directly
Hi!
This series prepares wireless drivers for the future where netdev->dev_addr will be constant and all changes will have to go thru dev_addr_set() and co.
No functional changes intended.
Jakub Kicinski (15):
wireless: use eth_hw_addr_set()
wireless: use eth_hw_addr_set() instead of ether_addr_copy()
wireless: use eth_hw_addr_set() for dev->addr_len cases
wireless: ath6kl: use eth_hw_addr_set()
wireless: wil6210: use eth_hw_addr_set()
wireless: atmel: use eth_hw_addr_set()
wireless: brcmfmac: prepare for const netdev->dev_addr
wireless: cisco: use eth_hw_addr_set()
wireless: ipw2200: prepare for const netdev->dev_addr
wireless: intersil: use eth_hw_addr_set()
wireless: mac80211_hwsim: use eth_hw_addr_set()
wireless: wilc1000: use eth_hw_addr_set()
wireless: ray_cs: use eth_hw_addr_set()
wireless: wl3501_cs: use eth_hw_addr_set()
wireless: zd1201: use eth_hw_addr_set()
drivers/net/wireless/ath/ath6kl/cfg80211.c | 9 ++++--- drivers/net/wireless/ath/wil6210/cfg80211.c | 10 ++++--- drivers/net/wireless/ath/wil6210/main.c | 6 ++--- drivers/net/wireless/ath/wil6210/wil6210.h | 2 +- drivers/net/wireless/ath/wil6210/wmi.c | 2 +- drivers/net/wireless/atmel/atmel.c | 19 ++++++++----- .../broadcom/brcm80211/brcmfmac/core.c | 6 ++--- .../broadcom/brcm80211/brcmfmac/p2p.c | 4 +-- drivers/net/wireless/cisco/airo.c | 27 +++++++++---------- drivers/net/wireless/intel/ipw2x00/ipw2100.c | 4 +-- drivers/net/wireless/intel/ipw2x00/ipw2200.c | 10 +++---- drivers/net/wireless/intel/ipw2x00/ipw2200.h | 2 +- .../net/wireless/intersil/hostap/hostap_hw.c | 5 +++- .../wireless/intersil/hostap/hostap_main.c | 4 +-- drivers/net/wireless/intersil/orinoco/main.c | 2 +- drivers/net/wireless/mac80211_hwsim.c | 7 +++-- drivers/net/wireless/marvell/libertas/cmd.c | 5 ++-- drivers/net/wireless/marvell/libertas/main.c | 4 +-- drivers/net/wireless/marvell/mwifiex/main.c | 2 +- .../net/wireless/marvell/mwifiex/uap_event.c | 3 +-- .../net/wireless/microchip/wilc1000/netdev.c | 13 ++++++--- .../net/wireless/microchip/wilc1000/netdev.h | 3 ++- drivers/net/wireless/quantenna/qtnfmac/core.c | 4 +-- drivers/net/wireless/ray_cs.c | 2 +- drivers/net/wireless/wl3501_cs.c | 3 +-- drivers/net/wireless/zydas/zd1201.c | 9 ++++--- 26 files changed, 92 insertions(+), 75 deletions(-)
Signature · 1 line
2.31.1
PATCH 1/15 wireless: use eth_hw_addr_set()
Convert all WiFi drivers from memcpy(... ETH_ADDR) to eth_hw_addr_set():
@@
expression dev, np;
@@
- memcpy(dev->dev_addr, np, ETH_ALEN)
+ eth_hw_addr_set(dev, np)
--- drivers/net/wireless/ath/ath6kl/cfg80211.c | 2 +- drivers/net/wireless/atmel/atmel.c | 2 +- drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c | 6 +++--- drivers/net/wireless/intel/ipw2x00/ipw2100.c | 4 ++-- drivers/net/wireless/intel/ipw2x00/ipw2200.c | 4 ++-- drivers/net/wireless/intersil/hostap/hostap_main.c | 4 ++-- drivers/net/wireless/intersil/orinoco/main.c | 2 +- drivers/net/wireless/marvell/libertas/cmd.c | 5 ++--- drivers/net/wireless/marvell/libertas/main.c | 4 ++-- drivers/net/wireless/marvell/mwifiex/uap_event.c | 3 +-- drivers/net/wireless/quantenna/qtnfmac/core.c | 2 +- 11 files changed, 18 insertions(+), 20 deletions(-)
drivers/net/wireless/ath/ath6kl/cfg80211.c +1 -1
@@ -3803,7 +3803,7 @@ struct wireless_dev *ath6kl_interface_add(struct ath6kl *ar, const char *name, vif->htcap[NL80211_BAND_2GHZ ].ht_enable = true; vif->htcap[NL80211_BAND_5GHZ ].ht_enable = true; -memcpy (ndev->dev_addr, ar->mac_addr,ETH_ALEN ); +eth_hw_addr_set (ndev, ar->mac_addr);if (fw_vif_idx !=0 ) { ndev->dev_addr[0 ] = (ndev->dev_addr[0 ] ^ (1 << fw_vif_idx)) |0x2 ;
drivers/net/wireless/atmel/atmel.c +1 -1
@@ -3730,7 +3730,7 @@ static int probe_atmel_card(struct net_device *dev) 0x00, 0x04, 0x25, 0x00, 0x00, 0x00 };printk (KERN_ALERT "%s: *** Invalid MAC address. UPGRADE Firmware ****\n" , dev->name); -memcpy (dev->dev_addr, default_mac,ETH_ALEN ); +eth_hw_addr_set (dev, default_mac); } }
drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c +3 -3
@@ -244,7 +244,7 @@ static int brcmf_netdev_set_mac_address(struct net_device *ndev, void *addr) }else {brcmf_dbg (TRACE ,"updated to %pM\n" , sa->sa_data);memcpy (ifp->mac_addr, sa->sa_data,ETH_ALEN ); -memcpy (ifp->ndev->dev_addr, ifp->mac_addr,ETH_ALEN ); +eth_hw_addr_set (ifp->ndev, ifp->mac_addr); }return err; }
@@ -655,7 +655,7 @@ int brcmf_net_attach(struct brcmf_if *ifp, bool locked) ndev->ethtool_ops = &brcmf_ethtool_ops;/* set the mac address & netns */ -memcpy (ndev->dev_addr, ifp->mac_addr,ETH_ALEN ); +eth_hw_addr_set (ndev, ifp->mac_addr);dev_net_set (ndev,wiphy_net (cfg_to_wiphy (drvr->config)));INIT_WORK (&ifp->multicast_work, _brcmf_set_multicast_list);
@@ -830,7 +830,7 @@ static int brcmf_net_p2p_attach(struct brcmf_if *ifp) ndev->netdev_ops = &brcmf_netdev_ops_p2p;/* set the mac address */ -memcpy (ndev->dev_addr, ifp->mac_addr,ETH_ALEN ); +eth_hw_addr_set (ndev, ifp->mac_addr);if (register_netdev (ndev) !=0 ) {bphy_err (drvr,"couldn't register the p2p net device\n" );
drivers/net/wireless/intel/ipw2x00/ipw2100.c +2 -2
@@ -4685,7 +4685,7 @@ static int ipw2100_read_mac_address(struct ipw2100_priv *priv)return -EIO ; } -memcpy (priv->net_dev->dev_addr, addr,ETH_ALEN ); +eth_hw_addr_set (priv->net_dev, addr);IPW_DEBUG_INFO ("card MAC is %pM\n" , priv->net_dev->dev_addr);return 0 ;
@@ -4712,7 +4712,7 @@ static int ipw2100_set_mac_address(struct ipw2100_priv *priv, int batch_mode)if (priv->config &CFG_CUSTOM_MAC ) {memcpy (cmd.host_command_parameters, priv->mac_addr,ETH_ALEN ); -memcpy (priv->net_dev->dev_addr, priv->mac_addr,ETH_ALEN ); +eth_hw_addr_set (priv->net_dev, priv->mac_addr); }else memcpy (cmd.host_command_parameters, priv->net_dev->dev_addr,ETH_ALEN );
drivers/net/wireless/intel/ipw2x00/ipw2200.c +2 -2
@@ -11185,7 +11185,7 @@ static int ipw_up(struct ipw_priv *priv)ipw_init_ordinals (priv);if (!(priv->config &CFG_CUSTOM_MAC ))eeprom_parse_mac (priv, priv->mac_addr); -memcpy (priv->net_dev->dev_addr, priv->mac_addr,ETH_ALEN ); +eth_hw_addr_set (priv->net_dev, priv->mac_addr);ipw_set_geo (priv);
@@ -11542,7 +11542,7 @@ static int ipw_prom_alloc(struct ipw_priv *priv) priv->prom_priv->priv = priv;strcpy (priv->prom_net_dev->name,"rtap%d" ); -memcpy (priv->prom_net_dev->dev_addr, priv->mac_addr,ETH_ALEN ); +eth_hw_addr_set (priv->prom_net_dev, priv->mac_addr); priv->prom_net_dev->type =ARPHRD_IEEE80211_RADIOTAP ; priv->prom_net_dev->netdev_ops = &ipw_prom_netdev_ops;
drivers/net/wireless/intersil/hostap/hostap_main.c +2 -2
@@ -713,9 +713,9 @@ static int prism2_set_mac_address(struct net_device *dev, void *p)read_lock_bh (&local->iface_lock);list_for_each (ptr, &local->hostap_interfaces) { iface = list_entry(ptr, struct hostap_interface, list); -memcpy (iface->dev->dev_addr, addr->sa_data,ETH_ALEN ); +eth_hw_addr_set (iface->dev, addr->sa_data); } -memcpy (local->dev->dev_addr, addr->sa_data,ETH_ALEN ); +eth_hw_addr_set (local->dev, addr->sa_data);read_unlock_bh (&local->iface_lock);return 0 ;
drivers/net/wireless/intersil/orinoco/main.c +1 -1
@@ -2265,7 +2265,7 @@ int orinoco_if_add(struct orinoco_private *priv,netif_carrier_off (dev); -memcpy (dev->dev_addr, wiphy->perm_addr,ETH_ALEN ); +eth_hw_addr_set (dev, wiphy->perm_addr); dev->base_addr = base_addr; dev->irq = irq;
drivers/net/wireless/marvell/libertas/cmd.c +2 -3
@@ -150,10 +150,9 @@ int lbs_update_hw_spec(struct lbs_private *priv)memmove (priv->current_addr, cmd.permanentaddr,ETH_ALEN );if (!priv->copied_hwaddr) { -memcpy (priv->dev->dev_addr, priv->current_addr,ETH_ALEN ); +eth_hw_addr_set (priv->dev, priv->current_addr);if (priv->mesh_dev) -memcpy (priv->mesh_dev->dev_addr, - priv->current_addr,ETH_ALEN ); +eth_hw_addr_set (priv->mesh_dev, priv->current_addr); priv->copied_hwaddr =1 ; }
drivers/net/wireless/marvell/libertas/main.c +2 -2
@@ -302,9 +302,9 @@ int lbs_set_mac_address(struct net_device *dev, void *addr) dev = priv->dev;memcpy (priv->current_addr, phwaddr->sa_data,ETH_ALEN ); -memcpy (dev->dev_addr, phwaddr->sa_data,ETH_ALEN ); +eth_hw_addr_set (dev, phwaddr->sa_data);if (priv->mesh_dev) -memcpy (priv->mesh_dev->dev_addr, phwaddr->sa_data,ETH_ALEN ); +eth_hw_addr_set (priv->mesh_dev, phwaddr->sa_data);return ret; }
drivers/net/wireless/marvell/mwifiex/uap_event.c +1 -2
@@ -197,8 +197,7 @@ int mwifiex_process_uap_event(struct mwifiex_private *priv)mwifiex_dbg (adapter,EVENT ,"AP EVENT: event id: %#x\n" , eventcause); priv->port_open = false; -memcpy (priv->netdev->dev_addr, adapter->event_body +2 , -ETH_ALEN ); +eth_hw_addr_set (priv->netdev, adapter->event_body +2 );if (priv->hist_data)mwifiex_hist_data_reset (priv);mwifiex_check_uap_capabilities (priv, adapter->event_skb);
drivers/net/wireless/quantenna/qtnfmac/core.c +1 -1
@@ -179,7 +179,7 @@ static int qtnf_netdev_set_mac_address(struct net_device *ndev, void *addr) sa->sa_data);if (ret) -memcpy (ndev->dev_addr, old_addr,ETH_ALEN ); +eth_hw_addr_set (ndev, old_addr);return ret; }
Signature · 1 line
2.31.1
Re: [PATCH 01/15] wireless: use eth_hw_addr_set()
Quoted 10 lines · Jakub Kicinski
Convert all WiFi drivers from memcpy(...
ETH_ADDR) toeth_hw_addr_set():@@
expression dev, np;
@@
-memcpy(dev->dev_addr, np, ETH_ALEN)
+eth_hw_addr_set(dev, np)Signed-off-by Jakub Kicinski <[email protected]>
14 patches applied to wireless-drivers-next.git, thanks.
708884e7f7f3 wireless: use eth_hw_addr_set()fcb79f31d906 wireless: use eth_hw_addr_set() instead of ether_addr_copy() 8fac27fbc80e wireless: use eth_hw_addr_set() for dev->addr_len cases f2e2a083be8a ath6kl: use eth_hw_addr_set()c7b6128a8db1 wil6210: use eth_hw_addr_set()251277af9c4f atmel: use eth_hw_addr_set()fba610c5bf70 brcmfmac: prepare for const netdev->dev_addr e3f90395c4f2 airo: use eth_hw_addr_set()d8a416def4c8 ipw2200: prepare for const netdev->dev_addr 2202c2f428e1 hostap: use eth_hw_addr_set()0341ae70ebf0 wilc1000: use eth_hw_addr_set()6dedb2742b7a ray_cs: use eth_hw_addr_set()18774612246d wl3501_cs: use eth_hw_addr_set()2ad96cb5b4f4 zd1201: use eth_hw_addr_set()
Signature · 3 lines
https://patchwork.kernel.org/project/linux-wireless/patch/[email protected]/ https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches
PATCH 2/15 wireless: use eth_hw_addr_set() instead of ether_addr_copy()
In reply to Jakub KicinskiCommit 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.
Convert wireless from ether_addr_copy() to eth_hw_addr_set():
@@
expression dev, np;
@@
- ether_addr_copy(dev->dev_addr, np)
+ eth_hw_addr_set(dev, np)
--- drivers/net/wireless/ath/wil6210/cfg80211.c | 4 ++-- drivers/net/wireless/ath/wil6210/main.c | 6 +++--- drivers/net/wireless/marvell/mwifiex/main.c | 2 +- drivers/net/wireless/quantenna/qtnfmac/core.c | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-)
drivers/net/wireless/ath/wil6210/cfg80211.c +2 -2
@@ -723,9 +723,9 @@ wil_cfg80211_add_iface(struct wiphy *wiphy, const char *name, ndev =vif_to_ndev (vif);ether_addr_copy (ndev->perm_addr, ndev_main->perm_addr);if (is_valid_ether_addr (params->macaddr)) { -ether_addr_copy (ndev->dev_addr, params->macaddr); +eth_hw_addr_set (ndev, params->macaddr); }else { -ether_addr_copy (ndev->dev_addr, ndev_main->perm_addr); +eth_hw_addr_set (ndev, ndev_main->perm_addr); ndev->dev_addr[0 ] = (ndev->dev_addr[0 ] ^ (1 << vif->mid)) |0x2 ;/* locally administered */ }
drivers/net/wireless/ath/wil6210/main.c +3 -3
@@ -1358,7 +1358,7 @@ static int wil_get_bl_info(struct wil6210_priv *wil)ether_addr_copy (ndev->perm_addr, mac);ether_addr_copy (wiphy->perm_addr, mac);if (!is_valid_ether_addr (ndev->dev_addr)) -ether_addr_copy (ndev->dev_addr, mac); +eth_hw_addr_set (ndev, mac);if (rf_status) {/* bad RF cable? */ wil_err(wil, "RF communication error 0x%04x",
@@ -1431,7 +1431,7 @@ static int wil_get_otp_info(struct wil6210_priv *wil)ether_addr_copy (ndev->perm_addr, mac);ether_addr_copy (wiphy->perm_addr, mac);if (!is_valid_ether_addr (ndev->dev_addr)) -ether_addr_copy (ndev->dev_addr, mac); +eth_hw_addr_set (ndev, mac);return 0 ; }
@@ -1609,7 +1609,7 @@ int wil_reset(struct wil6210_priv *wil, bool load_fw)struct net_device *ndev = wil->main_ndev;ether_addr_copy (ndev->perm_addr, mac); -ether_addr_copy (ndev->dev_addr, ndev->perm_addr); +eth_hw_addr_set (ndev, ndev->perm_addr);return 0 ; }
drivers/net/wireless/marvell/mwifiex/main.c +1 -1
@@ -985,7 +985,7 @@ int mwifiex_set_mac_address(struct mwifiex_private *priv,return ret; } -ether_addr_copy (dev->dev_addr, priv->curr_addr); +eth_hw_addr_set (dev, priv->curr_addr);return 0 ; }
drivers/net/wireless/quantenna/qtnfmac/core.c +1 -1
@@ -478,7 +478,7 @@ int qtnf_core_net_attach(struct qtnf_wmac *mac, struct qtnf_vif *vif, dev->needs_free_netdev = true;dev_net_set (dev,wiphy_net (wiphy)); dev->ieee80211_ptr = &vif->wdev; -ether_addr_copy (dev->dev_addr, vif->mac_addr); +eth_hw_addr_set (dev, vif->mac_addr); dev->flags |=IFF_BROADCAST |IFF_MULTICAST ; dev->watchdog_timeo =QTNF_DEF_WDOG_TIMEOUT ; dev->tx_queue_len =100 ;
Signature · 1 line
2.31.1
PATCH 3/15 wireless: use eth_hw_addr_set() for dev->addr_len cases
In reply to Jakub KicinskiConvert all WiFi drivers from memcpy(... dev->addr_len) to eth_hw_addr_set():
@@
expression dev, np;
@@
- memcpy(dev->dev_addr, np, dev->addr_len)
+ eth_hw_addr_set(dev, np)
Manually checked the netdevs are allocated with alloc_etherdev(), so dev->addr_len must be equal to ETH_ALEN.
--- drivers/net/wireless/atmel/atmel.c | 2 +- drivers/net/wireless/zydas/zd1201.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/net/wireless/atmel/atmel.c +1 -1
@@ -1296,7 +1296,7 @@ static int atmel_set_mac_address(struct net_device *dev, void *p) {struct sockaddr *addr = p; -memcpy (dev->dev_addr, addr->sa_data, dev->addr_len); +eth_hw_addr_set (dev, addr->sa_data);return atmel_open (dev); }
drivers/net/wireless/zydas/zd1201.c +1 -1
@@ -857,7 +857,7 @@ static int zd1201_set_mac_address(struct net_device *dev, void *p) addr->sa_data, dev->addr_len, 1);if (err)return err; -memcpy (dev->dev_addr, addr->sa_data, dev->addr_len); +eth_hw_addr_set (dev, addr->sa_data);return zd1201_mac_reset (zd); }
Signature · 1 line
2.31.1
PATCH 4/15 wireless: ath6kl: use eth_hw_addr_set()
In reply to Jakub KicinskiCommit 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.
Do the special encoding on the stack, then copy the address.
---
CC: [email protected]
CC: [email protected]
--- drivers/net/wireless/ath/ath6kl/cfg80211.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
drivers/net/wireless/ath/ath6kl/cfg80211.c +5 -4
@@ -3781,6 +3781,7 @@ struct wireless_dev *ath6kl_interface_add(struct ath6kl *ar, const char *name, {struct net_device *ndev;struct ath6kl_vif *vif; +u8 addr[ETH_ALEN ]; ndev =alloc_netdev (sizeof (*vif), name, name_assign_type, ether_setup);if (!ndev)
@@ -3803,14 +3804,14 @@ struct wireless_dev *ath6kl_interface_add(struct ath6kl *ar, const char *name, vif->htcap[NL80211_BAND_2GHZ ].ht_enable = true; vif->htcap[NL80211_BAND_5GHZ ].ht_enable = true; -eth_hw_addr_set (ndev, ar->mac_addr); +ether_addr_copy (addr, ar->mac_addr);if (fw_vif_idx !=0 ) { - ndev->dev_addr[0 ] = (ndev->dev_addr[0 ] ^ (1 << fw_vif_idx)) | -0x2 ; + addr[0 ] = (addr[0 ] ^ (1 << fw_vif_idx)) |0x2 ;if (test_bit (ATH6KL_FW_CAPABILITY_CUSTOM_MAC_ADDR , ar->fw_capabilities)) - ndev->dev_addr[4 ] ^=0x80 ; + addr[4 ] ^=0x80 ; } +eth_hw_addr_set (ndev, addr);init_netdev (ndev);
Signature · 1 line
2.31.1
PATCH 5/15 wireless: wil6210: use eth_hw_addr_set()
In reply to Jakub KicinskiCommit 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.
Do the special encoding on the stack, then copy the address.
---
CC: [email protected]
CC: [email protected]
CC: [email protected]
CC: [email protected]
--- drivers/net/wireless/ath/wil6210/cfg80211.c | 8 +++++--- drivers/net/wireless/ath/wil6210/wil6210.h | 2 +- drivers/net/wireless/ath/wil6210/wmi.c | 2 +- 3 files changed, 7 insertions(+), 5 deletions(-)
drivers/net/wireless/ath/wil6210/cfg80211.c +5 -3
@@ -725,9 +725,11 @@ wil_cfg80211_add_iface(struct wiphy *wiphy, const char *name,if (is_valid_ether_addr (params->macaddr)) {eth_hw_addr_set (ndev, params->macaddr); }else { -eth_hw_addr_set (ndev, ndev_main->perm_addr); - ndev->dev_addr[0 ] = (ndev->dev_addr[0 ] ^ (1 << vif->mid)) | -0x2 ;/* locally administered */ +u8 addr[ETH_ALEN ]; + +ether_addr_copy (addr, ndev_main->perm_addr); + addr[0 ] = (addr[0 ] ^ (1 << vif->mid)) |0x2 ;/* locally administered */ +eth_hw_addr_set (ndev, addr); } wdev =vif_to_wdev (vif);ether_addr_copy (wdev->address, ndev->dev_addr);
drivers/net/wireless/ath/wil6210/wil6210.h +1 -1
@@ -1341,7 +1341,7 @@ struct wil6210_priv *wil_cfg80211_init(struct device *dev);void wil_cfg80211_deinit (struct wil6210_priv *wil);void wil_p2p_wdev_free (struct wil6210_priv *wil); -int wmi_set_mac_address (struct wil6210_priv *wil,void *addr); +int wmi_set_mac_address (struct wil6210_priv *wil,const void *addr);int wmi_pcp_start (struct wil6210_vif *vif,int bi,u8 wmi_nettype,u8 chan,u8 edmg_chan,u8 hidden_ssid,u8 is_go);int wmi_pcp_stop (struct wil6210_vif *vif);
drivers/net/wireless/ath/wil6210/wmi.c +1 -1
@@ -2097,7 +2097,7 @@ int wmi_echo(struct wil6210_priv *wil) WIL_WMI_CALL_GENERAL_TO_MS); } -int wmi_set_mac_address (struct wil6210_priv *wil,void *addr) +int wmi_set_mac_address (struct wil6210_priv *wil,const void *addr) {struct wil6210_vif *vif =ndev_to_vif (wil->main_ndev);struct wmi_set_mac_address_cmd cmd;
Signature · 1 line
2.31.1
PATCH 6/15 wireless: atmel: use eth_hw_addr_set()
In reply to Jakub KicinskiCommit 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.
Use a buffer on the stack. Note that atmel_get_mib() is a wrapper around atmel_copy_to_host(). For the to device direction we just need to make sure functions respect argument being cost.
---
CC: [email protected]
CC: [email protected]
CC: [email protected]
--- drivers/net/wireless/atmel/atmel.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-)
drivers/net/wireless/atmel/atmel.c +10 -5
@@ -600,7 +600,7 @@ static void atmel_set_mib8(struct atmel_private *priv, u8 type, u8 index,static void atmel_set_mib16 (struct atmel_private *priv,u8 type,u8 index,u16 data);static void atmel_set_mib (struct atmel_private *priv,u8 type,u8 index, -u8 *data,int data_len); +const u8 *data,int data_len);static void atmel_get_mib (struct atmel_private *priv,u8 type,u8 index,u8 *data,int data_len);static void atmel_scan (struct atmel_private *priv,int specific_ssid);
@@ -3669,6 +3669,7 @@ static int probe_atmel_card(struct net_device *dev) {int rc =0 ;struct atmel_private *priv =netdev_priv (dev); +u8 addr[ETH_ALEN ] = {};/* reset pccard */ if (priv->bus_type ==BUS_TYPE_PCCARD )
@@ -3693,7 +3694,9 @@ static int probe_atmel_card(struct net_device *dev)if (i ==0 ) {printk (KERN_ALERT "%s: MAC failed to boot MAC address reader.\n" , dev->name); }else { -atmel_copy_to_host (dev, dev->dev_addr,atmel_read16 (dev,MR2 ),6 ); + +atmel_copy_to_host (dev, addr,atmel_read16 (dev,MR2 ),6 ); +eth_hw_addr_set (dev, addr);/* got address, now squash it again until the network interface is opened */ if (priv->bus_type ==BUS_TYPE_PCCARD )
@@ -3705,7 +3708,8 @@ static int probe_atmel_card(struct net_device *dev)/* Mac address easy in this case. */ priv->card_type =CARD_TYPE_PARALLEL_FLASH ;atmel_write16 (dev,BSR ,1 ); -atmel_copy_to_host (dev, dev->dev_addr,0xc000 ,6 ); +atmel_copy_to_host (dev, addr,0xc000 ,6 ); +eth_hw_addr_set (dev, addr);atmel_write16 (dev,BSR ,0x200 ); rc =1 ; }else {
@@ -3713,7 +3717,8 @@ static int probe_atmel_card(struct net_device *dev)for the Mac Address */ priv->card_type =CARD_TYPE_SPI_FLASH ;if (atmel_wakeup_firmware (priv) ==0 ) { -atmel_get_mib (priv, Mac_Address_Mib_Type,0 , dev->dev_addr,6 ); +atmel_get_mib (priv, Mac_Address_Mib_Type,0 , addr,6 ); +eth_hw_addr_set (dev, addr);/* got address, now squash it again until the network interface is opened */
@@ -4103,7 +4108,7 @@ static void atmel_set_mib16(struct atmel_private *priv, u8 type, u8 index, }static void atmel_set_mib (struct atmel_private *priv,u8 type,u8 index, -u8 *data,int data_len) +const u8 *data,int data_len) {struct get_set_mib m; m.type = type;
Signature · 1 line
2.31.1
PATCH 7/15 wireless: brcmfmac: prepare for const netdev->dev_addr
In reply to Jakub Kicinskinetdev->dev_addr will become const soon. Make sure local variables maintain that qualifier.
---
CC: [email protected]
CC: [email protected]
CC: [email protected]
CC: [email protected]
CC: [email protected]
CC: [email protected]
CC: [email protected]
CC: [email protected]
CC: [email protected]
CC: [email protected]
CC: [email protected]
--- drivers/net/wireless/broadcom/brcm80211/brcmfmac/p2p.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/wireless/broadcom/brcm80211/brcmfmac/p2p.c +2 -2
@@ -2125,7 +2125,7 @@ static int brcmf_p2p_disable_p2p_if(struct brcmf_cfg80211_vif *vif)struct brcmf_cfg80211_info *cfg =wdev_to_cfg (&vif->wdev);struct net_device *pri_ndev =cfg_to_ndev (cfg);struct brcmf_if *ifp =netdev_priv (pri_ndev); -u8 *addr = vif->wdev.netdev->dev_addr; +const u8 *addr = vif->wdev.netdev->dev_addr;return brcmf_fil_iovar_data_set (ifp,"p2p_ifdis" , addr,ETH_ALEN ); }
@@ -2135,7 +2135,7 @@ static int brcmf_p2p_release_p2p_if(struct brcmf_cfg80211_vif *vif)struct brcmf_cfg80211_info *cfg =wdev_to_cfg (&vif->wdev);struct net_device *pri_ndev =cfg_to_ndev (cfg);struct brcmf_if *ifp =netdev_priv (pri_ndev); -u8 *addr = vif->wdev.netdev->dev_addr; +const u8 *addr = vif->wdev.netdev->dev_addr;return brcmf_fil_iovar_data_set (ifp,"p2p_ifdel" , addr,ETH_ALEN ); }
Signature · 1 line
2.31.1
PATCH 8/15 wireless: cisco: use eth_hw_addr_set()
In reply to Jakub KicinskiCommit 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.
Use dev_addr_set() to match the existing logic. setup_card() is always passed netdev->dev_addr, so pass the netdev pointer instead and assign the address using a helper there.
---
CC: [email protected]
CC: [email protected]
CC: [email protected]
CC: [email protected]
--- drivers/net/wireless/cisco/airo.c | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-)
drivers/net/wireless/cisco/airo.c +13 -14
@@ -1109,7 +1109,7 @@ struct airo_info;static int get_dec_u16 (char *buffer,int *start,int limit);static void OUT4500 (struct airo_info *,u16 reg,u16 value);static unsigned short IN4500 (struct airo_info *,u16 reg); -static u16 setup_card (struct airo_info *,u8 *mac,int lock); +static u16 setup_card (struct airo_info *,struct net_device *dev,int lock);static int enable_MAC (struct airo_info *ai,int lock);static void disable_MAC (struct airo_info *ai,int lock);static void enable_interrupts (struct airo_info *);
@@ -2337,9 +2337,9 @@ static int airo_set_mac_address(struct net_device *dev, void *p)disable_MAC (ai,1 );writeConfigRid (ai,1 );enable_MAC (ai,1 ); -memcpy (ai->dev->dev_addr, addr->sa_data, dev->addr_len); +dev_addr_set (ai->dev, addr->sa_data);if (ai->wifidev) -memcpy (ai->wifidev->dev_addr, addr->sa_data, dev->addr_len); +dev_addr_set (ai->wifidev, addr->sa_data);return 0 ; }
@@ -2854,7 +2854,7 @@ static struct net_device *_init_airo_card(unsigned short irq, int port, }if (probe) { -if (setup_card (ai, dev->dev_addr,1 ) !=SUCCESS ) { +if (setup_card (ai, dev,1 ) !=SUCCESS ) {airo_print_err (dev->name,"MAC could not be enabled" ); rc = -EIO ; goto err_out_map;
@@ -2972,7 +2972,7 @@ int reset_airo_card(struct net_device *dev)if (reset_card (dev,1 ))return -1 ; -if (setup_card (ai, dev->dev_addr,1 ) !=SUCCESS ) { +if (setup_card (ai, dev,1 ) !=SUCCESS ) {airo_print_err (dev->name,"MAC could not be enabled" );return -1 ; }
@@ -3817,7 +3817,8 @@ static inline void set_auth_type(struct airo_info *local, int auth_type) local->last_auth = auth_type; } -static int noinline_for_stack airo_readconfig(struct airo_info *ai, u8 *mac, int lock) +static int noinline_for_stack airo_readconfig(struct airo_info *ai, +struct net_device *dev,int lock) {int i, status;/* large variables, so don't inline this function,
@@ -3861,9 +3862,7 @@ static int noinline_for_stack airo_readconfig(struct airo_info *ai, u8 *mac, int }/* Save off the MAC */ -for (i =0 ; i <ETH_ALEN ; i++) { - mac[i] = ai->config.macAddr[i]; - } +eth_hw_addr_set (dev, ai->config.macAddr);/* Check to see if there are any insmod configured rates to add */
@@ -3879,7 +3878,7 @@ static int noinline_for_stack airo_readconfig(struct airo_info *ai, u8 *mac, int } -static u16 setup_card (struct airo_info *ai,u8 *mac,int lock) +static u16 setup_card (struct airo_info *ai,struct net_device *dev,int lock) {Cmd cmd;Resp rsp;
@@ -3925,7 +3924,7 @@ static u16 setup_card(struct airo_info *ai, u8 *mac, int lock)if (lock)up (&ai->sem);if (ai->config.len ==0 ) { - status =airo_readconfig (ai, mac, lock); + status =airo_readconfig (ai, dev, lock);if (status !=SUCCESS )return ERROR ; }
@@ -5654,7 +5653,7 @@ static int __maybe_unused airo_pci_resume(struct device *dev_d)if (prev_state !=PCI_D1 ) {reset_card (dev,0 );mpi_init_descriptors (ai); -setup_card (ai, dev->dev_addr,0 ); +setup_card (ai, dev,0 );clear_bit (FLAG_RADIO_OFF , &ai->flags);clear_bit (FLAG_PENDING_XMIT , &ai->flags); }else {
@@ -7534,7 +7533,7 @@ static int airo_config_commit(struct net_device *dev,readSsidRid (local, &SSID_rid);if (test_bit (FLAG_MPI ,&local->flags)) -setup_card (local, dev->dev_addr,1 ); +setup_card (local, dev,1 );else reset_airo_card (dev);disable_MAC (local,1 );
@@ -8208,7 +8207,7 @@ static int flashrestart(struct airo_info *ai, struct net_device *dev)if (status !=SUCCESS )return status; } - status =setup_card (ai, dev->dev_addr,1 ); + status =setup_card (ai, dev,1 );if (!test_bit (FLAG_MPI ,&ai->flags))for (i =0 ; i <MAX_FIDS ; i++) {
Signature · 1 line
2.31.1
Re: [PATCH 08/15] wireless: cisco: use eth_hw_addr_set()
Quoted 10 lines · Jakub Kicinski
Commit
406f42fa0d3c("net-next: When a bond have a massive amount of VLANs...") introduced a rbtree for faster Ethernet address look up. To maintainnetdev->dev_addrin this tree we need to make all the writes to it got through appropriate helpers.Use
dev_addr_set()to match the existing logic.setup_card()is always passednetdev->dev_addr, so pass the netdev pointer instead and assign the address using a helper there.Signed-off-by Jakub Kicinski <[email protected]>
Sebastian
PATCH 9/15 wireless: ipw2200: prepare for const netdev->dev_addr
In reply to Jakub Kicinskinetdev->dev_addr will be come const soon, constify the argument to command send to avoid compiler warnings.
---
CC: [email protected]
CC: [email protected]
CC: [email protected]
--- drivers/net/wireless/intel/ipw2x00/ipw2200.c | 6 +++--- drivers/net/wireless/intel/ipw2x00/ipw2200.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-)
drivers/net/wireless/intel/ipw2x00/ipw2200.c +3 -3
@@ -199,7 +199,7 @@ static int ipw_queue_tx_reclaim(struct ipw_priv *priv, struct clx2_tx_queue *txq, int qindex);static int ipw_queue_reset (struct ipw_priv *priv); -static int ipw_queue_tx_hcmd (struct ipw_priv *priv,int hcmd,void *buf, +static int ipw_queue_tx_hcmd (struct ipw_priv *priv,int hcmd,const void *buf,int len,int sync);static void ipw_tx_queue_free (struct ipw_priv *);
@@ -2264,7 +2264,7 @@ static int ipw_send_cmd_simple(struct ipw_priv *priv, u8 command) }static int ipw_send_cmd_pdu (struct ipw_priv *priv,u8 command,u8 len, -void *data) +const void *data) {struct host_cmd cmd = { .cmd = command,
@@ -5033,7 +5033,7 @@ static int ipw_queue_tx_reclaim(struct ipw_priv *priv,return used; } -static int ipw_queue_tx_hcmd (struct ipw_priv *priv,int hcmd,void *buf, +static int ipw_queue_tx_hcmd (struct ipw_priv *priv,int hcmd,const void *buf,int len,int sync) {struct clx2_tx_queue *txq = &priv->txq_cmd;
drivers/net/wireless/intel/ipw2x00/ipw2200.h +1 -1
@@ -1945,7 +1945,7 @@ struct host_cmd {u8 cmd;u8 len;u16 reserved; -u32 *param; +const u32 *param; } __packed;/* XXX */ struct cmdlog_host_cmd {
Signature · 1 line
2.31.1
Stanislav Yakovlev
maintainerRe: [PATCH 09/15] wireless: ipw2200: prepare for const netdev->dev_addr
Quoted 5 lines · Jakub Kicinski
netdev->dev_addrwill be come const soon, constify the argument to command send to avoid compiler warnings.Signed-off-by Jakub Kicinski <[email protected]>
Quoted 9 lines
---
CC: [email protected]
CC: [email protected]
CC: [email protected]--- drivers/net/wireless/intel/ipw2x00/ipw2200.c | 6 +++--- drivers/net/wireless/intel/ipw2x00/ipw2200.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-)
Looks fine, thanks!
Stanislav.
PATCH 10/15 wireless: intersil: use eth_hw_addr_set()
In reply to Jakub KicinskiCommit 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.
---
CC: [email protected]
CC: [email protected]
CC: [email protected]
CC: [email protected]
--- drivers/net/wireless/intersil/hostap/hostap_hw.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/net/wireless/intersil/hostap/hostap_hw.c +4 -1
@@ -1403,14 +1403,17 @@ static int prism2_hw_init2(struct net_device *dev, int initial)hfa384x_events_only_cmd (dev);if (initial) { +u8 addr[ETH_ALEN ] = {};struct list_head *ptr; +prism2_check_sta_fw_version (local);if (hfa384x_get_rid (dev,HFA384X_RID_CNFOWNMACADDR , - dev->dev_addr,6 ,1 ) <0 ) { + addr,ETH_ALEN ,1 ) <0 ) {printk ("%s: could not get own MAC address\n" , dev->name); } +eth_hw_addr_set (dev, addr);list_for_each (ptr, &local->hostap_interfaces) { iface = list_entry(ptr, struct hostap_interface, list);eth_hw_addr_inherit (iface->dev, dev);
Signature · 1 line
2.31.1
PATCH 11/15 wireless: mac80211_hwsim: use eth_hw_addr_set()
In reply to Jakub KicinskiCommit 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.
---
CC: [email protected]
CC: [email protected]
CC: [email protected]
--- drivers/net/wireless/mac80211_hwsim.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/net/wireless/mac80211_hwsim.c +5 -2
@@ -3527,13 +3527,16 @@ static const struct net_device_ops hwsim_netdev_ops = {static void hwsim_mon_setup (struct net_device *dev) { +u8 addr[ETH_ALEN ]; + dev->netdev_ops = &hwsim_netdev_ops; dev->needs_free_netdev = true;ether_setup (dev); dev->priv_flags |=IFF_NO_QUEUE ; dev->type =ARPHRD_IEEE80211_RADIOTAP ; -eth_zero_addr (dev->dev_addr); - dev->dev_addr[0 ] =0x12 ; +eth_zero_addr (addr); + addr[0 ] =0x12 ; +eth_hw_addr_set (dev, addr); }static struct mac80211_hwsim_data *get_hwsim_data_ref_from_addr (const u8 *addr)
Signature · 1 line
2.31.1
PATCH 12/15 wireless: wilc1000: use eth_hw_addr_set()
In reply to Jakub KicinskiCommit 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.
---
CC: [email protected]
CC: [email protected]
CC: [email protected]
CC: [email protected]
--- drivers/net/wireless/microchip/wilc1000/netdev.c | 13 +++++++++---- drivers/net/wireless/microchip/wilc1000/netdev.h | 3 ++- 2 files changed, 11 insertions(+), 5 deletions(-)
drivers/net/wireless/microchip/wilc1000/netdev.c +9 -4
@@ -111,7 +111,8 @@ static struct net_device *get_if_handler(struct wilc *wilc, u8 *mac_header)return ndev; } -void wilc_wlan_set_bssid (struct net_device *wilc_netdev,u8 *bssid,u8 mode) +void wilc_wlan_set_bssid (struct net_device *wilc_netdev,const u8 *bssid, +u8 mode) {struct wilc_vif *vif =netdev_priv (wilc_netdev);
@@ -594,10 +595,14 @@ static int wilc_mac_open(struct net_device *ndev)wilc_set_operation_mode (vif,wilc_get_vif_idx (vif), vif->iftype, vif->idx); -if (is_valid_ether_addr (ndev->dev_addr)) +if (is_valid_ether_addr (ndev->dev_addr)) {wilc_set_mac_address (vif, ndev->dev_addr); -else -wilc_get_mac_address (vif, ndev->dev_addr); + }else { +u8 addr[ETH_ALEN ]; + +wilc_get_mac_address (vif, addr); +eth_hw_addr_set (ndev, addr); + }netdev_dbg (ndev,"Mac address: %pM\n" , ndev->dev_addr);if (!is_valid_ether_addr (ndev->dev_addr)) {
drivers/net/wireless/microchip/wilc1000/netdev.h +2 -1
@@ -287,7 +287,8 @@ void wilc_frmw_to_host(struct wilc *wilc, u8 *buff, u32 size, u32 pkt_offset);void wilc_mac_indicate (struct wilc *wilc);void wilc_netdev_cleanup (struct wilc *wilc);void wilc_wfi_mgmt_rx (struct wilc *wilc,u8 *buff,u32 size); -void wilc_wlan_set_bssid (struct net_device *wilc_netdev,u8 *bssid,u8 mode); +void wilc_wlan_set_bssid (struct net_device *wilc_netdev,const u8 *bssid, +u8 mode);struct wilc_vif *wilc_netdev_ifc_init (struct wilc *wl,const char *name,int vif_type,enum nl80211_iftype type,bool rtnl_locked);
Signature · 1 line
2.31.1
PATCH 13/15 wireless: ray_cs: use eth_hw_addr_set()
In reply to Jakub KicinskiCommit 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.
---
CC: [email protected]
CC: [email protected]
--- drivers/net/wireless/ray_cs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/ray_cs.c +1 -1
@@ -791,7 +791,7 @@ static int ray_dev_init(struct net_device *dev)#endif /* RAY_IMMEDIATE_INIT */ /* copy mac and broadcast addresses to linux device */ -memcpy (dev->dev_addr, &local->sparm.b4.a_mac_addr,ADDRLEN ); +eth_hw_addr_set (dev, local->sparm.b4.a_mac_addr);eth_broadcast_addr (dev->broadcast);dev_dbg (&link->dev,"ray_dev_init ending\n" );
Signature · 1 line
2.31.1
PATCH 14/15 wireless: wl3501_cs: use eth_hw_addr_set()
In reply to Jakub KicinskiCommit 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.
---
CC: [email protected]
CC: [email protected]
--- drivers/net/wireless/wl3501_cs.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/net/wireless/wl3501_cs.c +1 -2
@@ -1945,8 +1945,7 @@ static int wl3501_config(struct pcmcia_device *link) goto failed; } -for (i =0 ; i <6 ; i++) - dev->dev_addr[i] = ((char *)&this->mac_addr)[i]; +eth_hw_addr_set (dev, this->mac_addr);/* print probe information */ printk(KERN_INFO "%s: wl3501 @ 0x%3.3x, IRQ %d, "
Signature · 1 line
2.31.1
PATCH 15/15 wireless: zd1201: use eth_hw_addr_set()
In reply to Jakub KicinskiCommit 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.
---
CC: [email protected]
CC: [email protected]
--- drivers/net/wireless/zydas/zd1201.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/net/wireless/zydas/zd1201.c +4 -3
@@ -507,7 +507,7 @@ static int zd1201_getconfig(struct zd1201 *zd, int rid, void *riddata,* byte data[12] * total: 16 */ -static int zd1201_setconfig (struct zd1201 *zd,int rid,void *buf,int len,int wait) +static int zd1201_setconfig (struct zd1201 *zd,int rid,const void *buf,int len,int wait) {int err;unsigned char *request;
@@ -1729,6 +1729,7 @@ static int zd1201_probe(struct usb_interface *interface,int err;short porttype;char buf[IW_ESSID_MAX_SIZE +2 ]; +u8 addr[ETH_ALEN ]; usb =interface_to_usbdev (interface);
@@ -1779,10 +1780,10 @@ static int zd1201_probe(struct usb_interface *interface, dev->watchdog_timeo =ZD1201_TX_TIMEOUT ;strcpy (dev->name,"wlan%d" ); - err =zd1201_getconfig (zd,ZD1201_RID_CNFOWNMACADDR , - dev->dev_addr, dev->addr_len); + err =zd1201_getconfig (zd,ZD1201_RID_CNFOWNMACADDR , addr,ETH_ALEN );if (err) goto err_start; +eth_hw_addr_set (dev, addr);/* Set wildcard essid to match zd->essid */ *(__le16 *)buf =cpu_to_le16 (0 );
Signature · 1 line
2.31.1