Ethernet: Add and use ether_<type>_addr globals
Subsystems (21)
cover Ethernet: Add and use ether_<type>_addr globals
There are many local static and non-static arrays that are used for Ethernet broadcast address output or comparison.
Centralize the array into a single separate file and remove the local arrays.
Joe Perches (12):
ethernet: Add generic ether_<foo>_addr addresses
treewide/net: Rename eth_stp_addr to ether_stp_addr
net: mac80211: Use global ether_broadcast_addr
bridge: netfilter: Use the new global ether_<foo>_addr arrays
net: atm: Use ether_broadcast_addr
wireless: Convert simple uses of a static const Ethernet broadcast address
brcmfmac: Convert ALLFFMAC to ether_broadcast_addr
iwlegacy: Remove EXPORT_SYMBOL(il_bcast_addr) and use ether_broadcast_addr
iwlwifi: Remove local iwl_bcast_addr and use ether_broadcast_addr
mvpp2: Use ether_broadcast_addr instead of a local array
qlogic: Convert local bcast_addr to global ether_broadcast_addr
ethernet: Use ether_zero_addr instead of local statics
drivers/net/dsa/lan9303-core.c | 4 ++-- drivers/net/ethernet/broadcom/b44.c | 5 ++--- drivers/net/ethernet/freescale/gianfar.c | 3 +-- drivers/net/ethernet/marvell/mvpp2.c | 4 +--- drivers/net/ethernet/qlogic/netxen/netxen_nic_hw.c | 5 +---- drivers/net/ethernet/qlogic/qlcnic/qlcnic_hw.c | 6 ++---- .../net/ethernet/qlogic/qlcnic/qlcnic_sriov_common.c | 6 ++---- drivers/net/wireless/admtek/adm8211.c | 3 +-- drivers/net/wireless/ath/carl9170/mac.c | 4 +--- drivers/net/wireless/broadcom/b43/main.c | 3 +-- .../net/wireless/broadcom/brcm80211/brcmfmac/common.c | 2 -- .../net/wireless/broadcom/brcm80211/brcmfmac/common.h | 2 -- .../wireless/broadcom/brcm80211/brcmfmac/flowring.c | 8 ++++---- drivers/net/wireless/intel/iwlegacy/3945-mac.c | 2 +- drivers/net/wireless/intel/iwlegacy/4965-mac.c | 2 +- drivers/net/wireless/intel/iwlegacy/common.c | 3 --- drivers/net/wireless/intel/iwlegacy/common.h | 1 - drivers/net/wireless/intel/iwlwifi/dvm/dev.h | 1 - drivers/net/wireless/intel/iwlwifi/dvm/scan.c | 2 +- drivers/net/wireless/intel/iwlwifi/dvm/sta.c | 4 +--- drivers/net/wireless/marvell/mwifiex/cfg80211.c | 3 +-- drivers/net/wireless/realtek/rtlwifi/core.c | 5 ++--- drivers/net/wireless/rndis_wlan.c | 6 +----- drivers/net/wireless/ti/wl1251/main.c | 5 +---- drivers/net/wireless/ti/wlcore/main.c | 5 +---- include/linux/etherdevice.h | 13 +++++++++---- net/atm/lec.c | 12 +++++------- net/bridge/br_device.c | 4 ++-- net/bridge/netfilter/ebt_stp.c | 6 ++---- net/ethernet/Makefile | 2 +- net/ethernet/ether_addrs.c | 19 +++++++++++++++++++ net/mac80211/iface.c | 5 +---- net/mac80211/key.c | 6 ++---- net/mac80211/mesh_hwmp.c | 19 ++++++++++--------- net/mac80211/mesh_pathtbl.c | 8 ++++---- 35 files changed, 83 insertions(+), 105 deletions(-) create mode 100644 net/ethernet/ether_addrs.c
Signature · 1 line
2.15.0
PATCH 1/12 ethernet: Add generic ether_<foo>_addr addresses
Treewide there are ~60 declarations of Ethernet broadcast or zero address use as a 6 byte array that are later used as either an output for vsprintf extension %pM or as a source array to copy or compare.
Create const globals for these uses with EXPORT_SYMBOL for modules.
Miscellanea:
o Rename and move static const eth_reservd_addr_base from etherdevice.h to this new ether_addrs.c file so it is no longer oddly declared as static const in a .h file
--- include/linux/etherdevice.h | 12 ++++++++---- net/ethernet/Makefile | 2 +- net/ethernet/ether_addrs.c | 19 +++++++++++++++++++ 3 files changed, 28 insertions(+), 5 deletions(-) create mode 100644 net/ethernet/ether_addrs.c
include/linux/etherdevice.h +8 -4
@@ -63,10 +63,14 @@ struct sk_buff **eth_gro_receive(struct sk_buff **head, struct sk_buff *skb);int eth_gro_complete (struct sk_buff *skb,int nhoff); +/* Generic Ethernet addresses */ +extern const u8 ether_broadcast_addr[ETH_ALEN ];/* all 0xff */ +extern const u8 ether_zero_addr[ETH_ALEN ];/* all zeros */ +/* Reserved Ethernet Addresses per IEEE 802.1Q */ -static const u8 eth_reserved_addr_base[ETH_ALEN ]__aligned(2) = -{0x01 ,0x80 ,0xc2 ,0x00 ,0x00 ,0x00 }; -#define eth_stp_addr eth_reserved_addr_base +extern const u8 ether_reserved_addr_base[ETH_ALEN ]; + +#define eth_stp_addr ether_reserved_addr_base/** * is_link_local_ether_addr - Determine if given Ethernet address is link-local
@@ -80,7 +84,7 @@ static const u8 eth_reserved_addr_base[ETH_ALEN] __aligned(2) =static inline bool is_link_local_ether_addr (const u8 *addr) {__be16 *a = (__be16 *)addr; -static const __be16 *b = (const __be16 *)eth_reserved_addr_base; +static const __be16 *b = (const __be16 *)ether_reserved_addr_base;static const __be16 m =cpu_to_be16 (0xfff0 );#if defined(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS )
net/ethernet/Makefile +1 -1
@@ -2,4 +2,4 @@ # Makefile for the Linux Ethernet layer. # -obj-y += eth.o +obj-y += eth.o ether_addrs.o
net/ethernet/ether_addrs.c new file +19 -0
@@ -0,0 +1,19 @@ +// SPDX-License-Identifier: GPL-2.0 +/* Various const global Ethernet addresses */ + +#include <linux/etherdevice.h> + +const u8 ether_broadcast_addr[ETH_ALEN ]__aligned(2) = { +0xff ,0xff ,0xff ,0xff ,0xff ,0xff +}; +EXPORT_SYMBOL (ether_broadcast_addr); + +const u8 ether_zero_addr[ETH_ALEN ]__aligned(2) = { +0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 +}; +EXPORT_SYMBOL (ether_zero_addr); + +const u8 ether_reserved_addr_base[ETH_ALEN ]__aligned(2) = { +0x01 ,0x80 ,0xc2 ,0x00 ,0x00 ,0x00 +}; +EXPORT_SYMBOL (ether_reserved_addr_base);
Signature · 1 line
2.15.0
PATCH 2/12 treewide/net: Rename eth_stp_addr to ether_stp_addr
In reply to Joe Percheseth_stp_addr is not in the same form as the other global ether_<foo>_addr addresses like ether_broadcast_addr.
Convert it treewide.
Miscellanea:
o Add comment to the ether_stp_addr define to show it's for spanning-tree
--- drivers/net/dsa/lan9303-core.c | 4 ++-- include/linux/etherdevice.h | 3 ++- net/bridge/br_device.c | 4 ++-- 3 files changed, 6 insertions(+), 5 deletions(-)
drivers/net/dsa/lan9303-core.c +2 -2
@@ -789,7 +789,7 @@ static int lan9303_separate_ports(struct lan9303 *chip) {int ret; -lan9303_alr_del_port (chip, eth_stp_addr,0 ); +lan9303_alr_del_port (chip, ether_stp_addr,0 ); ret = lan9303_write_switch_reg(chip, LAN9303_SWE_PORT_MIRROR, LAN9303_SWE_PORT_MIRROR_SNIFFER_PORT0 | LAN9303_SWE_PORT_MIRROR_MIRRORED_PORT1 |
@@ -814,7 +814,7 @@ static void lan9303_bridge_ports(struct lan9303 *chip)lan9303_write_switch_reg (chip,LAN9303_SWE_PORT_STATE , chip->swe_port_state); -lan9303_alr_add_port (chip, eth_stp_addr,0 , true); +lan9303_alr_add_port (chip, ether_stp_addr,0 , true); }static void lan9303_handle_reset (struct lan9303 *chip)
include/linux/etherdevice.h +2 -1
@@ -70,7 +70,8 @@ extern const u8 ether_zero_addr[ETH_ALEN]; /* all zeros *//* Reserved Ethernet Addresses per IEEE 802.1Q */ extern const u8 ether_reserved_addr_base[ETH_ALEN ]; -#define eth_stp_addr ether_reserved_addr_base +/* Ethernet bridge - spanning tree protocol */ +#define ether_stp_addr ether_reserved_addr_base/** * is_link_local_ether_addr - Determine if given Ethernet address is link-local
net/bridge/br_device.c +2 -2
@@ -1,4 +1,4 @@ -/* +gg/* * Device handling code * Linux ethernet bridge *
@@ -431,7 +431,7 @@ void br_dev_setup(struct net_device *dev) br->bridge_id.prio[0 ] =0x80 ; br->bridge_id.prio[1 ] =0x00 ; -ether_addr_copy (br->group_addr, eth_stp_addr); +ether_addr_copy (br->group_addr, ether_stp_addr); br->stp_enabled =BR_NO_STP ; br->group_fwd_mask =BR_GROUPFWD_DEFAULT ;
Signature · 1 line
2.15.0
Andrew Lunn
maintainerRe: [PATCH 02/12] treewide/net: Rename eth_stp_addr to ether_stp_addr
net/bridge/br_device.c line 1
Quoted 5 lines · Joe Perches
net/bridge/br_device.c +1
-1@@ -1,4 +1,4 @@ -/* +gg/*
Hi Joe
This does not look good.
Andrew
Re: [PATCH 02/12] treewide/net: Rename eth_stp_addr to ether_stp_addr
Quoted 10 lines · Andrew Lunn
net/bridge/br_device.c line 1
Quoted 5 lines · Joe Perches
net/bridge/br_device.c +1
-1@@ -1,4 +1,4 @@ -/* +gg/* Hi Joe
This does not look good.
Definitely agree with that. apologies for not noticing.
It's emacs editing nonsense like a superfluous :wq for vim
PATCH v2 1/1 treewide/net: Rename eth_stp_addr to ether_stp_addr
In reply to Andrew Lunneth_stp_addr is not in the same form as the other global ether_<foo>_addr addresses like ether_broadcast_addr.
Convert it treewide.
Miscellanea:
o Add comment to the ether_stp_addr define to show it's for spanning-tree
---
V2: Remove gg from initial comment (bad editing)
drivers/net/dsa/lan9303-core.c | 4 ++-- include/linux/etherdevice.h | 3 ++- net/bridge/br_device.c | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-)
drivers/net/dsa/lan9303-core.c +2 -2
@@ -789,7 +789,7 @@ static int lan9303_separate_ports(struct lan9303 *chip) {int ret; -lan9303_alr_del_port (chip, eth_stp_addr,0 ); +lan9303_alr_del_port (chip, ether_stp_addr,0 ); ret = lan9303_write_switch_reg(chip, LAN9303_SWE_PORT_MIRROR, LAN9303_SWE_PORT_MIRROR_SNIFFER_PORT0 | LAN9303_SWE_PORT_MIRROR_MIRRORED_PORT1 |
@@ -814,7 +814,7 @@ static void lan9303_bridge_ports(struct lan9303 *chip)lan9303_write_switch_reg (chip,LAN9303_SWE_PORT_STATE , chip->swe_port_state); -lan9303_alr_add_port (chip, eth_stp_addr,0 , true); +lan9303_alr_add_port (chip, ether_stp_addr,0 , true); }static void lan9303_handle_reset (struct lan9303 *chip)
include/linux/etherdevice.h +2 -1
@@ -70,7 +70,8 @@ extern const u8 ether_zero_addr[ETH_ALEN]; /* all zeros *//* Reserved Ethernet Addresses per IEEE 802.1Q */ extern const u8 ether_reserved_addr_base[ETH_ALEN ]; -#define eth_stp_addr ether_reserved_addr_base +/* Ethernet bridge - spanning tree protocol */ +#define ether_stp_addr ether_reserved_addr_base/** * is_link_local_ether_addr - Determine if given Ethernet address is link-local
net/bridge/br_device.c +1 -1
@@ -431,7 +431,7 @@ void br_dev_setup(struct net_device *dev) br->bridge_id.prio[0 ] =0x80 ; br->bridge_id.prio[1 ] =0x00 ; -ether_addr_copy (br->group_addr, eth_stp_addr); +ether_addr_copy (br->group_addr, ether_stp_addr); br->stp_enabled =BR_NO_STP ; br->group_fwd_mask =BR_GROUPFWD_DEFAULT ;
Signature · 1 line
2.15.0
David Miller
maintainerRe: [PATCH V2] treewide/net: Rename eth_stp_addr to ether_stp_addr
From: Joe Perches <[email protected]>
Date: Sat, 31 Mar 2018 11:34:06 -0700
Quoted 5 lines
eth_stp_addris not in the same form as the other global ether_<foo>_addr addresses likeether_broadcast_addr.Convert it treewide.
Quoted 8 lines
Miscellanea:
o Add comment to the
ether_stp_addrdefine to show it's for spanning-treeSigned-off-by Joe Perches <[email protected]>---
V2: Remove gg from initial comment (bad editing)
Joe this was part of a larger series.
Please repost the entire series when you fix a patch contained in that series, not just the patch that is changing.
Thank you.
kbuild test robot
build botRe: [PATCH 02/12] treewide/net: Rename eth_stp_addr to ether_stp_addr
In reply to Joe PerchesI love your patch! Yet something to improve:
Hi Joe,
I love your patch! Yet something to improve:
[auto build test ERROR on wireless-drivers-next/master]
[also build test ERROR on v4.16-rc7 next-20180329]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
url: https://github.com/0day-ci/linux/commits/Joe-Perches/Ethernet-Add-and-use-ether_-type-_addr-globals/20180401-072030 base: https://git.kernel.org/pub/scm/linux/kernel/git/kvalo/wireless-drivers-next.git master config: i386-randconfig-x009-201813 (attached as .config) compiler: gcc-7 (Debian 7.3.0-1) 7.3.0 reproduce: # save the attached .config to linux build tree make ARCH=i386
All errors (new ones prefixed by >>):
In file included from include/linux/kernel.h:6:0,
from net//bridge/br_device.c:14:
>> /usr/lib/gcc/x86_64-linux-gnu/7/include/stdarg.h:40:1: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'typedef'
typedef __builtin_va_list __gnuc_va_list;
^~~~~~~
In file included from include/linux/kernel.h:6:0,
from net//bridge/br_device.c:14:
>> /usr/lib/gcc/x86_64-linux-gnu/7/include/stdarg.h:99:9: error: unknown type name '__gnuc_va_list'
typedef __gnuc_va_list va_list;
^~~~~~~~~~~~~~---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
PATCH 3/12 net: mac80211: Use global ether_broadcast_addr
In reply to Joe PerchesRemove statics and use the new global ether_broadcast_addr instead to save some overall object code size.
--- net/mac80211/iface.c | 5 +---- net/mac80211/key.c | 6 ++---- net/mac80211/mesh_hwmp.c | 19 ++++++++++--------- net/mac80211/mesh_pathtbl.c | 8 ++++---- 4 files changed, 17 insertions(+), 21 deletions(-)
net/mac80211/iface.c +1 -4
@@ -1387,9 +1387,6 @@ static void ieee80211_recalc_smps_work(struct work_struct *work)static void ieee80211_setup_sdata (struct ieee80211_sub_if_data *sdata,enum nl80211_iftype type) { -static const u8 bssid_wildcard[ETH_ALEN ] = {0xff ,0xff ,0xff , -0xff ,0xff ,0xff }; -/* clear type-dependent union */ memset (&sdata->u,0 ,sizeof (sdata->u));
@@ -1442,7 +1439,7 @@ static void ieee80211_setup_sdata(struct ieee80211_sub_if_data *sdata,ieee80211_sta_setup_sdata (sdata);break ;case NL80211_IFTYPE_OCB : - sdata->vif.bss_conf.bssid = bssid_wildcard; + sdata->vif.bss_conf.bssid = ether_broadcast_addr;ieee80211_ocb_setup_sdata (sdata);break ;case NL80211_IFTYPE_ADHOC :
net/mac80211/key.c +2 -4
@@ -53,8 +53,6 @@* remove the key which waits for an RCU grace period. */ -static const u8 bcast_addr[ETH_ALEN ] = {0xFF ,0xFF ,0xFF ,0xFF ,0xFF ,0xFF }; -static void assert_key_lock (struct ieee80211_local *local) {lockdep_assert_held (&local->key_mtx);
@@ -196,7 +194,7 @@ static int ieee80211_key_enable_hw_accel(struct ieee80211_key *key)sdata_err (sdata,"failed to set key (%d, %pM) to hardware (%d)\n" , key->conf.keyidx, - sta ? sta->sta.addr : bcast_addr, ret); + sta ? sta->sta.addr : ether_broadcast_addr, ret); out_unsupported:switch (key->conf.cipher) {
@@ -253,7 +251,7 @@ static void ieee80211_key_disable_hw_accel(struct ieee80211_key *key)sdata_err (sdata,"failed to remove key (%d, %pM) from hardware (%d)\n" , key->conf.keyidx, - sta ? sta->sta.addr : bcast_addr, ret); + sta ? sta->sta.addr : ether_broadcast_addr, ret); key->flags &= ~KEY_FLAG_UPLOADED_TO_HARDWARE ; }
net/mac80211/mesh_hwmp.c +10 -9
@@ -97,8 +97,6 @@ enum mpath_frame_type {MPATH_RANN }; -static const u8 broadcast_addr[ETH_ALEN ] = {0xff ,0xff ,0xff ,0xff ,0xff ,0xff }; - static int mesh_path_sel_frame_tx(enum mpath_frame_type action, u8 flags, const u8 *orig_addr, u32 orig_sn, u8 target_flags, const u8 *target,
@@ -645,7 +643,7 @@ static void hwmp_preq_frame_process(struct ieee80211_sub_if_data *sdata, preq_id =PREQ_IE_PREQ_ID (preq_elem); hopcount =PREQ_IE_HOPCOUNT (preq_elem) +1 ; da = (mpath && mpath->is_root) ? - mpath->rann_snd_addr : broadcast_addr; + mpath->rann_snd_addr : ether_broadcast_addr;if (flags &IEEE80211_PREQ_PROACTIVE_PREP_FLAG ) { target_addr =PREQ_IE_TARGET_ADDR (preq_elem);
@@ -779,7 +777,7 @@ static void hwmp_perr_frame_process(struct ieee80211_sub_if_data *sdata, goto endperr;mesh_path_error_tx (sdata, ttl, target_addr, target_sn, target_rcode, - broadcast_addr); + ether_broadcast_addr); }else spin_unlock_bh (&mpath->state_lock); }
@@ -877,7 +875,8 @@ static void hwmp_rann_frame_process(struct ieee80211_sub_if_data *sdata,if (ifmsh->mshcfg.dot11MeshForwarding) {mesh_path_sel_frame_tx (MPATH_RANN , flags, orig_addr, - orig_sn,0 ,NULL ,0 , broadcast_addr, + orig_sn,0 ,NULL ,0 , + ether_broadcast_addr, hopcount, ttl, interval, new_metric,0 , sdata); }
@@ -1080,7 +1079,7 @@ void mesh_path_start_discovery(struct ieee80211_sub_if_data *sdata) target_flags &= ~IEEE80211_PREQ_TO_FLAG ;spin_unlock_bh (&mpath->state_lock); - da = (mpath->is_root) ? mpath->rann_snd_addr : broadcast_addr; + da = (mpath->is_root) ? mpath->rann_snd_addr : ether_broadcast_addr;mesh_path_sel_frame_tx (MPATH_PREQ ,0 , sdata->vif.addr, ifmsh->sn, target_flags, mpath->dst, mpath->sn, da,0 , ttl, lifetime,0 , ifmsh->preq_id++, sdata);
@@ -1244,7 +1243,8 @@ void mesh_path_tx_root_frame(struct ieee80211_sub_if_data *sdata)switch (ifmsh->mshcfg.dot11MeshHWMPRootMode) {case IEEE80211_PROACTIVE_RANN :mesh_path_sel_frame_tx (MPATH_RANN , flags, sdata->vif.addr, - ++ifmsh->sn,0 ,NULL ,0 , broadcast_addr, + ++ifmsh->sn,0 ,NULL ,0 , + ether_broadcast_addr,0 , ifmsh->mshcfg.element_ttl, interval,0 ,0 , sdata);break ;
@@ -1257,8 +1257,9 @@ void mesh_path_tx_root_frame(struct ieee80211_sub_if_data *sdata)IEEE80211_PREQ_USN_FLAG ;mesh_path_sel_frame_tx (MPATH_PREQ , flags, sdata->vif.addr, ++ifmsh->sn, target_flags, - (u8 *) broadcast_addr,0 , broadcast_addr, -0 , ifmsh->mshcfg.element_ttl, interval, + ether_broadcast_addr,0 , + ether_broadcast_addr,0 , + ifmsh->mshcfg.element_ttl, interval,0 , ifmsh->preq_id++, sdata);break ;default :
net/mac80211/mesh_pathtbl.c +4 -4
@@ -501,7 +501,6 @@ void mesh_plink_broken(struct sta_info *sta) {struct ieee80211_sub_if_data *sdata = sta->sdata;struct mesh_table *tbl = sdata->u.mesh.mesh_paths; -static const u8 bcast[ETH_ALEN ] = {0xff ,0xff ,0xff ,0xff ,0xff ,0xff };struct mesh_path *mpath;struct rhashtable_iter iter;int ret;
@@ -525,9 +524,10 @@ void mesh_plink_broken(struct sta_info *sta) ++mpath->sn;spin_unlock_bh (&mpath->state_lock);mesh_path_error_tx (sdata, - sdata->u.mesh.mshcfg.element_ttl, - mpath->dst, mpath->sn, -WLAN_REASON_MESH_PATH_DEST_UNREACHABLE , bcast); + sdata->u.mesh.mshcfg.element_ttl, + mpath->dst, mpath->sn, +WLAN_REASON_MESH_PATH_DEST_UNREACHABLE , + ether_broadcast_addr); } }rhashtable_walk_stop (&iter);
Signature · 1 line
2.15.0
PATCH 4/12 bridge: netfilter: Use the new global ether_<foo>_addr arrays
In reply to Joe PerchesRemove the local consts and use the new globals.
--- net/bridge/netfilter/ebt_stp.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
net/bridge/netfilter/ebt_stp.c +2 -4
@@ -153,8 +153,6 @@ ebt_stp_mt(const struct sk_buff *skb, struct xt_action_param *par)static int ebt_stp_mt_check (const struct xt_mtchk_param *par) {const struct ebt_stp_info *info = par->matchinfo; -const u8 bridge_ula[6 ] = {0x01 ,0x80 ,0xc2 ,0x00 ,0x00 ,0x00 }; -const u8 msk[6 ] = {0xff ,0xff ,0xff ,0xff ,0xff ,0xff };const struct ebt_entry *e = par->entryinfo; if (info->bitmask & ~EBT_STP_MASK || info->invflags & ~EBT_STP_MASK ||
@@ -162,8 +160,8 @@ static int ebt_stp_mt_check(const struct xt_mtchk_param *par)return -EINVAL ;/* Make sure the match only receives stp frames */ if (!par->nft_compat && - (!ether_addr_equal (e->destmac, bridge_ula) || - !ether_addr_equal (e->destmsk, msk) || + (!ether_addr_equal (e->destmac, ether_stp_addr) || + !ether_addr_equal (e->destmsk, ether_broadcast_addr) || !(e->bitmask &EBT_DESTMAC )))return -EINVAL ;
Signature · 1 line
2.15.0
Pablo Neira Ayuso
maintainerRe: [PATCH 04/12] bridge: netfilter: Use the new global ether_<foo>_addr arrays
Hi Joe,
Quoted 1 line · Joe Perches
Remove the local consts and use the new globals.
This one is already upstream:
I can see you're using is_broadcast_ether_addr(e->destmsk) in this new version, we would need an incremental version.
Thanks.
Quoted 32 lines
Signed-off-by Joe Perches <[email protected]>--- net/bridge/netfilter/ebt_stp.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)net/bridge/netfilter/ebt_stp.c +2
-4@@ -153,8 +153,6 @@ ebt_stp_mt(const struct sk_buff *skb, struct xt_action_param *par)static int ebt_stp_mt_check (const struct xt_mtchk_param *par) {const struct ebt_stp_info *info = par->matchinfo; -const u8 bridge_ula[6 ] = {0x01 ,0x80 ,0xc2 ,0x00 ,0x00 ,0x00 }; -const u8 msk[6 ] = {0xff ,0xff ,0xff ,0xff ,0xff ,0xff };const struct ebt_entry *e = par->entryinfo; if (info->bitmask & ~EBT_STP_MASK || info->invflags & ~EBT_STP_MASK ||@@ -162,8 +160,8 @@ static int ebt_stp_mt_check(const struct xt_mtchk_param *par)return -EINVAL ;/* Make sure the match only receives stp frames */ if (!par->nft_compat && - (!ether_addr_equal (e->destmac, bridge_ula) || - !ether_addr_equal (e->destmsk, msk) || + (!ether_addr_equal (e->destmac, ether_stp_addr) || + !ether_addr_equal (e->destmsk, ether_broadcast_addr) || !(e->bitmask &EBT_DESTMAC )))return -EINVAL ;Signature · 1 line
2.15.0
Re: [PATCH 04/12] bridge: netfilter: Use the new global ether_<foo>_addr arrays
Quoted 1 line · Pablo Neira Ayuso
Hi Joe,
Hi Pablo.
Quoted 9 lines · Joe Perches
Quoted 1 line
Remove the local consts and use the new globals.
This one is already upstream:
I can see you're using
is_broadcast_ether_addr(e->destmsk)in this new version, we would need an incremental version.
No worries. I did it against next-20180329
and that other commit wasn't there.
PATCH 5/12 net: atm: Use ether_broadcast_addr
In reply to Joe PerchesUse the new global instead of a local static to reduce object code size a tiny bit.
--- net/atm/lec.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-)
net/atm/lec.c +5 -7
@@ -116,8 +116,6 @@ static struct lane2_ops lane2_ops = { .associate_indicator = NULL /* spec 3.1.5 */ }; -static unsigned char bus_mac[ETH_ALEN ] = {0xff ,0xff ,0xff ,0xff ,0xff ,0xff }; -/* Device structures */ static struct net_device *dev_lec[MAX_LEC_ITF ];
@@ -1726,7 +1724,7 @@ static struct atm_vcc *lec_arp_resolve(struct lec_priv *priv,case 1 :return priv->mcast_vcc;case 2 :/* LANE2 wants arp for multicast addresses */ -if (ether_addr_equal (mac_to_find, bus_mac)) +if (ether_addr_equal (mac_to_find, ether_broadcast_addr))return priv->mcast_vcc;break ;default :
@@ -1954,7 +1952,7 @@ lec_vcc_added(struct lec_priv *priv, const struct atmlec_ioc *ioc_data,if (ioc_data->receive ==2 ) {pr_debug ("LEC_ARP: Attaching mcast forward\n" );#if 0 - entry =lec_arp_find (priv, bus_mac); + entry =lec_arp_find (priv, ether_broadcast_addr);if (!entry) {pr_info ("LEC_ARP: Multicast entry not found!\n" ); goto out;
@@ -1963,7 +1961,7 @@ lec_vcc_added(struct lec_priv *priv, const struct atmlec_ioc *ioc_data, entry->recv_vcc = vcc; entry->old_recv_push = old_push;#endif - entry =make_entry (priv, bus_mac); + entry =make_entry (priv, ether_broadcast_addr);if (entry ==NULL ) goto out;del_timer (&entry->timer);
@@ -1988,7 +1986,7 @@ lec_vcc_added(struct lec_priv *priv, const struct atmlec_ioc *ioc_data, ioc_data->atm_addr[14 ], ioc_data->atm_addr[15 ], ioc_data->atm_addr[16 ], ioc_data->atm_addr[17 ], ioc_data->atm_addr[18], ioc_data->atm_addr[19]); - entry =make_entry (priv, bus_mac); + entry =make_entry (priv, ether_broadcast_addr);if (entry ==NULL ) goto out;memcpy (entry->atm_addr, ioc_data->atm_addr,ATM_ESA_LEN );
@@ -2071,7 +2069,7 @@ lec_vcc_added(struct lec_priv *priv, const struct atmlec_ioc *ioc_data,* Not found, snatch address from first data packet that arrives * from this vcc */ - entry =make_entry (priv, bus_mac); + entry =make_entry (priv, ether_broadcast_addr);if (!entry) goto out; entry->vcc = vcc;
Signature · 1 line
2.15.0
PATCH 6/12 wireless: Convert simple uses of a static const Ethernet broadcast address
In reply to Joe PerchesUse the new ether_broadcast_addr global instead to save some object code.
--- drivers/net/wireless/admtek/adm8211.c | 3 +-- drivers/net/wireless/ath/carl9170/mac.c | 4 +--- drivers/net/wireless/broadcom/b43/main.c | 3 +-- drivers/net/wireless/marvell/mwifiex/cfg80211.c | 3 +-- drivers/net/wireless/realtek/rtlwifi/core.c | 5 ++--- drivers/net/wireless/rndis_wlan.c | 6 +----- drivers/net/wireless/ti/wl1251/main.c | 5 +---- drivers/net/wireless/ti/wlcore/main.c | 5 +---- 8 files changed, 9 insertions(+), 25 deletions(-)
drivers/net/wireless/admtek/adm8211.c +1 -2
@@ -1354,7 +1354,6 @@ static void adm8211_configure_filter(struct ieee80211_hw *dev, unsigned int *total_flags, u64 multicast) { -static const u8 bcast[ETH_ALEN ] = {0xFF ,0xFF ,0xFF ,0xFF ,0xFF ,0xFF };struct adm8211_priv *priv = dev->priv;unsigned int new_flags;u32 mc_filter[2 ];
@@ -1385,7 +1384,7 @@ static void adm8211_configure_filter(struct ieee80211_hw *dev,__clear_bit (IEEE80211_HW_RX_INCLUDES_FCS , dev->flags);if (*total_flags &FIF_BCN_PRBRESP_PROMISC ) -adm8211_set_bssid (dev, bcast); +adm8211_set_bssid (dev, ether_broadcast_addr);else adm8211_set_bssid (dev, priv->bssid);
drivers/net/wireless/ath/carl9170/mac.c +1 -3
@@ -476,10 +476,8 @@ int carl9170_upload_key(struct ar9170 *ar, const u8 id, const u8 *mac, const int keylen) {struct carl9170_set_key_cmd key = { }; -static const u8 bcast[ETH_ALEN ] = { -0xff ,0xff ,0xff ,0xff ,0xff ,0xff }; - mac = mac ? : bcast; + mac = mac ? : ether_broadcast_addr; key.user =cpu_to_le16 (id); key.keyId =cpu_to_le16 (keyidx);
drivers/net/wireless/broadcom/b43/main.c +1 -2
@@ -4185,7 +4185,6 @@ static int b43_op_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,u8 algorithm;u8 index;int err; -static const u8 bcast_addr[ETH_ALEN ] = {0xff ,0xff ,0xff ,0xff ,0xff ,0xff };if (modparam_nohwcrypt)return -ENOSPC ;/* User disabled HW-crypto */
@@ -4293,7 +4292,7 @@ static int b43_op_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,b43dbg (wl,"%s hardware based encryption for keyidx: %d, " "mac: %pM\n" , cmd ==SET_KEY ?"Using" :"Disabling" , key->keyidx, - sta ? sta->addr : bcast_addr); + sta ? sta->addr : ether_broadcast_addr);b43_dump_keymemory (dev); }mutex_unlock (&wl->mutex);
drivers/net/wireless/marvell/mwifiex/cfg80211.c +1 -2
@@ -174,7 +174,6 @@ mwifiex_cfg80211_del_key(struct wiphy *wiphy, struct net_device *netdev,static int mwifiex_form_mgmt_frame (struct sk_buff *skb,const u8 *buf,size_t len) { -u8 addr[ETH_ALEN ] = {0xFF ,0xFF ,0xFF ,0xFF ,0xFF ,0xFF };u16 pkt_len;u32 tx_control =0 , pkt_type =PKT_TYPE_MGMT ;
@@ -191,7 +190,7 @@ mwifiex_form_mgmt_frame(struct sk_buff *skb, const u8 *buf, size_t len)/* Add packet data and address4 */ skb_put_data (skb, buf,sizeof (struct ieee80211_hdr_3addr )); -skb_put_data (skb, addr,ETH_ALEN ); +skb_put_data (skb, ether_broadcast_addr,ETH_ALEN );skb_put_data (skb, buf +sizeof (struct ieee80211_hdr_3addr ), len -sizeof (struct ieee80211_hdr_3addr ));
drivers/net/wireless/realtek/rtlwifi/core.c +2 -3
@@ -1527,7 +1527,6 @@ static int rtl_op_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,bool wep_only = false;int err =0 ;u8 mac_addr[ETH_ALEN ]; -u8 bcast_addr[ETH_ALEN ] = {0xff ,0xff ,0xff ,0xff ,0xff ,0xff }; rtlpriv->btcoexist.btc_info.in_4way = false;
@@ -1544,7 +1543,7 @@ static int rtl_op_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,RT_TRACE (rtlpriv,COMP_SEC ,DBG_DMESG ,"%s hardware based encryption for keyidx: %d, mac: %pM\n" , cmd ==SET_KEY ?"Using" :"Disabling" , key->keyidx, - sta ? sta->addr : bcast_addr); + sta ? sta->addr : ether_broadcast_addr); rtlpriv->sec.being_setkey = true;rtl_ips_nic_on (hw);mutex_lock (&rtlpriv->locks.conf_mutex);
@@ -1649,7 +1648,7 @@ static int rtl_op_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,memcpy (rtlpriv->sec.key_buf[key_idx], key->key, key->keylen); rtlpriv->sec.key_len[key_idx] = key->keylen; -memcpy (mac_addr, bcast_addr,ETH_ALEN ); +memcpy (mac_addr, ether_broadcast_addr,ETH_ALEN ); }else {/* pairwise key */ RT_TRACE (rtlpriv,COMP_SEC ,DBG_DMESG ,"set pairwise key\n" );
drivers/net/wireless/rndis_wlan.c +1 -5
@@ -1021,11 +1021,7 @@ static int set_bssid(struct usbnet *usbdev, const u8 *bssid)static int clear_bssid (struct usbnet *usbdev) { -static const u8 broadcast_mac[ETH_ALEN ] = { -0xff ,0xff ,0xff ,0xff ,0xff ,0xff - }; - -return set_bssid (usbdev, broadcast_mac); +return set_bssid (usbdev, ether_broadcast_addr); }static int get_bssid (struct usbnet *usbdev,u8 bssid[ETH_ALEN ])
drivers/net/wireless/ti/wl1251/main.c +1 -4
@@ -887,9 +887,6 @@ static int wl1251_op_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,const u8 *addr;int ret; -static const u8 bcast_addr[ETH_ALEN ] = - {0xff ,0xff ,0xff ,0xff ,0xff ,0xff }; -wl1251_debug (DEBUG_MAC80211 ,"mac80211 set key" ); wl_cmd =kzalloc (sizeof (*wl_cmd),GFP_KERNEL );
@@ -898,7 +895,7 @@ static int wl1251_op_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, goto out; } - addr = sta ? sta->addr : bcast_addr; + addr = sta ? sta->addr : ether_broadcast_addr;wl1251_debug (DEBUG_CRYPT ,"CMD: 0x%x" , cmd);wl1251_dump (DEBUG_CRYPT ,"ADDR: " , addr,ETH_ALEN );
drivers/net/wireless/ti/wlcore/main.c +1 -4
@@ -3392,11 +3392,8 @@ static int wl1271_set_key(struct wl1271 *wl, struct wl12xx_vif *wlvif,return ret; }else {const u8 *addr; -static const u8 bcast_addr[ETH_ALEN ] = { -0xff ,0xff ,0xff ,0xff ,0xff ,0xff - }; - addr = sta ? sta->addr : bcast_addr; + addr = sta ? sta->addr : ether_broadcast_addr;if (is_zero_ether_addr (addr)) {/* We dont support TX only encryption */
Signature · 1 line
2.15.0
Pkshih
maintainerRe: [PATCH 06/12] wireless: Convert simple uses of a static const Ethernet broadcast address
Quoted 38 lines · Joe Perches
Use the new
ether_broadcast_addrglobal instead to save some object code.Signed-off-by Joe Perches <[email protected]>---
?drivers/net/wireless/admtek/adm8211.c???????????| 3 +-- ?drivers/net/wireless/ath/carl9170/mac.c?????????| 4 +--- ?drivers/net/wireless/broadcom/b43/main.c????????| 3 +-- ?drivers/net/wireless/marvell/mwifiex/cfg80211.c | 3 +-- ?drivers/net/wireless/realtek/rtlwifi/core.c?????| 5 ++--- ?drivers/net/wireless/rndis_wlan.c???????????????| 6 +----- ?drivers/net/wireless/ti/wl1251/main.c???????????| 5 +---- ?drivers/net/wireless/ti/wlcore/main.c???????????| 5 +----?8 files changed, 9 insertions(+), 25 deletions(-)
?
drivers/net/wireless/realtek/rtlwifi/core.c +0
-1@@ -1527,7 +1527,6 @@ static int rtl_op_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, ? bool wep_only = false; ? int err = 0; ? u8 mac_addr[ETH_ALEN]; -u8 bcast_addr[ETH_ALEN ] = {0xff ,0xff ,0xff ,0xff ,0xff ,0xff };?
?rtlpriv->btcoexist.btc_info.in_4way= false;
?drivers/net/wireless/realtek/rtlwifi/core.c +1
-1@@ -1544,7 +1543,7 @@ static int rtl_op_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, ? RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG, ? ?"%s hardware based encryption for keyidx: %d, mac: %pM\n", ? ??cmd == SET_KEY ? "Using" : "Disabling", key->keyidx, - ??sta ? sta->addr : bcast_addr); + ??sta ? sta->addr : ether_broadcast_addr); ? rtlpriv->sec.being_setkey = true; ? rtl_ips_nic_on(hw); ? mutex_lock(&rtlpriv->locks.conf_mutex);
drivers/net/wireless/realtek/rtlwifi/core.c static int rtl_op_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, · line 1651
Quoted 5 lines
drivers/net/wireless/realtek/rtlwifi/core.c +1
-1@@ -1649,7 +1648,7 @@ static int rtl_op_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, ? memcpy(rtlpriv->sec.key_buf[key_idx], ? ???????key->key, key->keylen); ? rtlpriv->sec.key_len[key_idx] = key->keylen; -memcpy (mac_addr, bcast_addr,ETH_ALEN ); +memcpy (mac_addr, ether_broadcast_addr,ETH_ALEN );
Use?ether_addr_copy(mac_addr, ether_broadcast_addr) ?
Quoted 3 lines
? } else { /* pairwise key */
? RT_TRACE(rtlpriv,COMP_SEC,DBG_DMESG,
? ?"set pairwise key\n");
Re: [PATCH 06/12] wireless: Convert simple uses of a static const Ethernet broadcast address
Quoted 2 lines · Pkshih
Quoted 1 line · Joe Perches
Use the new
ether_broadcast_addrglobal instead to save some object code.
[]
Quoted 1 line
Review
Quoted 1 line
(quoted diff) +0
-0
[]
Quoted 8 lines
drivers/net/wireless/realtek/rtlwifi/core.c static int rtl_op_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, · line 1651
Quoted 6 lines
drivers/net/wireless/realtek/rtlwifi/core.c +1
-1@@ -1649,7 +1648,7 @@ static int rtl_op_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,memcpy (rtlpriv->sec.key_buf[key_idx], key->key, key->keylen); rtlpriv->sec.key_len[key_idx] = key->keylen; -memcpy (mac_addr, bcast_addr,ETH_ALEN ); +memcpy (mac_addr, ether_broadcast_addr,ETH_ALEN );Use
ether_addr_copy(mac_addr, ether_broadcast_addr)?
This should use eth_broadcast_addr(mac_addr) instead.
There are similar conversion still possible in the tree. One day.
Re: [PATCH 06/12] wireless: Convert simple uses of a static const Ethernet broadcast address
In reply to Joe PerchesQuoted 13 lines · Joe Perches
Use the new
ether_broadcast_addrglobal instead to save some object code.Signed-off-by Joe Perches <[email protected]>--- drivers/net/wireless/admtek/adm8211.c | 3 +-- drivers/net/wireless/ath/carl9170/mac.c | 4 +--- drivers/net/wireless/broadcom/b43/main.c | 3 +-- drivers/net/wireless/marvell/mwifiex/cfg80211.c | 3 +-- drivers/net/wireless/realtek/rtlwifi/core.c | 5 ++--- drivers/net/wireless/rndis_wlan.c | 6 +----- drivers/net/wireless/ti/wl1251/main.c | 5 +---- drivers/net/wireless/ti/wlcore/main.c | 5 +---- 8 files changed, 9 insertions(+), 25 deletions(-)
It would be really helpful if you could CLEARLY document in the patches (or in the cover letter but then you need to cc all parties) to what tree the patches are meant for. Otherwise I, and other maintainers as well, need to waste time trying to guess what's your plan.
I will now drop the four wireless patches from my queue. So if you want to me to take them please resubmit.
Signature · 1 line
Kalle Valo
Re: [PATCH 06/12] wireless: Convert simple uses of a static const Ethernet broadcast address
Quoted 16 lines · Kalle Valo
Quoted 13 lines · Joe Perches
Use the new
ether_broadcast_addrglobal instead to save some object code.Signed-off-by Joe Perches <[email protected]>--- drivers/net/wireless/admtek/adm8211.c | 3 +-- drivers/net/wireless/ath/carl9170/mac.c | 4 +--- drivers/net/wireless/broadcom/b43/main.c | 3 +-- drivers/net/wireless/marvell/mwifiex/cfg80211.c | 3 +-- drivers/net/wireless/realtek/rtlwifi/core.c | 5 ++--- drivers/net/wireless/rndis_wlan.c | 6 +----- drivers/net/wireless/ti/wl1251/main.c | 5 +---- drivers/net/wireless/ti/wlcore/main.c | 5 +---- 8 files changed, 9 insertions(+), 25 deletions(-)
Quoted 4 lines
It would be really helpful if you could CLEARLY document in the patches (or in the cover letter but then you need to cc all parties) to what tree the patches are meant for. Otherwise I, and other maintainers as well, need to waste time trying to guess what's your plan.
Forgot to mention that for me the best approach is to have the tree name in subject, just like Dave and Linus both recommend:
[PATCH 06/12 wireless-drivers-next] wireless: Convert simple uses of a static const Ethernet broadcast address
This way I can immeaditely see from patchwork to which tree the patch should go which helps tremendously. And if the tree name is too long you can always shorten it to w-d and w-d-next.
Signature · 1 line
Kalle Valo
PATCH 7/12 brcmfmac: Convert ALLFFMAC to ether_broadcast_addr
In reply to Joe PerchesRemove the local ALLFFMAC extern array and use the new global instead.
Miscellanea:
o Convert char *mac to const char *mac as it can't be modified
--- drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c | 2 -- drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.h | 2 -- drivers/net/wireless/broadcom/brcm80211/brcmfmac/flowring.c | 8 ++++---- 3 files changed, 4 insertions(+), 8 deletions(-)
drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c +0 -2
@@ -36,8 +36,6 @@ MODULE_AUTHOR("Broadcom Corporation");MODULE_DESCRIPTION ("Broadcom 802.11 wireless LAN fullmac driver." );MODULE_LICENSE ("Dual BSD/GPL" ); -const u8 ALLFFMAC [ETH_ALEN ] = {0xff ,0xff ,0xff ,0xff ,0xff ,0xff }; -#define BRCMF_DEFAULT_SCAN_CHANNEL_TIME 40#define BRCMF_DEFAULT_SCAN_UNASSOC_TIME 40
drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.h +0 -2
@@ -19,8 +19,6 @@#include <linux/platform_data/brcmfmac.h> #include "fwil_types.h" -extern const u8 ALLFFMAC [ETH_ALEN ]; -#define BRCMF_FW_ALTPATH_LEN 256/* Definitions for the module global and device specific settings are defined
drivers/net/wireless/broadcom/brcm80211/brcmfmac/flowring.c +4 -4
@@ -73,13 +73,13 @@ u32 brcmf_flowring_lookup(struct brcmf_flowring *flow, u8 da[ETH_ALEN],bool found;bool sta;u8 fifo; -u8 *mac; +const u8 *mac; fifo = brcmf_flowring_prio2fifo[prio]; sta = (flow->addr_mode[ifidx] ==ADDR_INDIRECT ); mac = da;if ((!sta) && (is_multicast_ether_addr (da))) { - mac = (u8 *)ALLFFMAC ; + mac = ether_broadcast_addr; fifo =0 ; } if ((sta) && (flow->tdls_active) &&
@@ -118,13 +118,13 @@ u32 brcmf_flowring_create(struct brcmf_flowring *flow, u8 da[ETH_ALEN],bool found;u8 fifo;bool sta; -u8 *mac; +const u8 *mac; fifo = brcmf_flowring_prio2fifo[prio]; sta = (flow->addr_mode[ifidx] ==ADDR_INDIRECT ); mac = da;if ((!sta) && (is_multicast_ether_addr (da))) { - mac = (u8 *)ALLFFMAC ; + mac = ether_broadcast_addr; fifo =0 ; } if ((sta) && (flow->tdls_active) &&
Signature · 1 line
2.15.0
Re: [PATCH 07/12] brcmfmac: Convert ALLFFMAC to ether_broadcast_addr
Quoted 1 line · Joe Perches
Remove the local ALLFFMAC extern array and use the new global instead.
I stumbled upon this one couple of weeks ago. I moved the definition to flowring.c although I considered for a moment to pick up the task you took here valiantly.
Quoted 3 lines
Miscellanea:
o Convert char *mac to const char *mac as it can't be modified
The real reason is off course that your new global is const and thus mac variable need to be const as well to avoid compiler warning.
I have to agree with Kalle regarding the upstream logistics, but for what it is worth...
Quoted 6 lines
Signed-off-by Joe Perches <[email protected]>--- drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c | 2 -- drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.h | 2 -- drivers/net/wireless/broadcom/brcm80211/brcmfmac/flowring.c | 8 ++++---- 3 files changed, 4 insertions(+), 8 deletions(-)
PATCH 8/12 iwlegacy: Remove EXPORT_SYMBOL(il_bcast_addr) and use ether_broadcast_addr
In reply to Joe PerchesRemove the local array and use the new global instead to save some small amount of object code.
--- drivers/net/wireless/intel/iwlegacy/3945-mac.c | 2 +- drivers/net/wireless/intel/iwlegacy/4965-mac.c | 2 +- drivers/net/wireless/intel/iwlegacy/common.c | 3 --- drivers/net/wireless/intel/iwlegacy/common.h | 1 - 4 files changed, 2 insertions(+), 6 deletions(-)
drivers/net/wireless/intel/iwlegacy/3945-mac.c +1 -1
@@ -2352,7 +2352,7 @@ il3945_alloc_bcast_station(struct il_priv *il)u8 sta_id;spin_lock_irqsave (&il->sta_lock, flags); - sta_id =il_prep_station (il, il_bcast_addr, false,NULL ); + sta_id =il_prep_station (il, ether_broadcast_addr, false,NULL );if (sta_id ==IL_INVALID_STATION ) {IL_ERR ("Unable to prepare broadcast station\n" );spin_unlock_irqrestore (&il->sta_lock, flags);
drivers/net/wireless/intel/iwlegacy/4965-mac.c +1 -1
@@ -3536,7 +3536,7 @@ il4965_alloc_bcast_station(struct il_priv *il)u8 sta_id;spin_lock_irqsave (&il->sta_lock, flags); - sta_id =il_prep_station (il, il_bcast_addr, false,NULL ); + sta_id =il_prep_station (il, ether_broadcast_addr, false,NULL );if (sta_id ==IL_INVALID_STATION ) {IL_ERR ("Unable to prepare broadcast station\n" );spin_unlock_irqrestore (&il->sta_lock, flags);
drivers/net/wireless/intel/iwlegacy/common.c +0 -3
@@ -3378,9 +3378,6 @@ MODULE_PARM_DESC(bt_coex_active, "enable wifi/bluetooth co-exist");u32 il_debug_level;EXPORT_SYMBOL (il_debug_level); -const u8 il_bcast_addr[ETH_ALEN ] = {0xFF ,0xFF ,0xFF ,0xFF ,0xFF ,0xFF }; -EXPORT_SYMBOL (il_bcast_addr); -#define MAX_BIT_RATE_40_MHZ 150/* Mbps */ #define MAX_BIT_RATE_20_MHZ 72/* Mbps */ static void
drivers/net/wireless/intel/iwlegacy/common.h +0 -1
@@ -860,7 +860,6 @@ struct il_hw_params {* ****************************************************************************/ void il4965_update_chain_flags (struct il_priv *il); -extern const u8 il_bcast_addr[ETH_ALEN ];int il_queue_space (const struct il_queue *q);static inline int il_queue_used (const struct il_queue *q,int i)
Signature · 1 line
2.15.0
PATCH 9/12 iwlwifi: Remove local iwl_bcast_addr and use ether_broadcast_addr
In reply to Joe PerchesUse the new global to save a little bit of object code.
--- drivers/net/wireless/intel/iwlwifi/dvm/dev.h | 1 - drivers/net/wireless/intel/iwlwifi/dvm/scan.c | 2 +- drivers/net/wireless/intel/iwlwifi/dvm/sta.c | 4 +--- 3 files changed, 2 insertions(+), 5 deletions(-)
drivers/net/wireless/intel/iwlwifi/dvm/dev.h +0 -1
@@ -271,7 +271,6 @@ struct iwl_sensitivity_ranges {* ****************************************************************************/ void iwl_update_chain_flags (struct iwl_priv *priv); -extern const u8 iwl_bcast_addr[ETH_ALEN ];#define IWL_OPERATION_MODE_AUTO 0#define IWL_OPERATION_MODE_HT_ONLY 1
drivers/net/wireless/intel/iwlwifi/dvm/scan.c +1 -1
@@ -871,7 +871,7 @@ static int iwlagn_request_scan(struct iwl_priv *priv, struct ieee80211_vif *vif)/* use bcast addr, will not be transmitted but must be valid */ cmd_len =iwl_fill_probe_req ( (struct ieee80211_mgmt *)scan->data, - iwl_bcast_addr,NULL ,0 , + ether_broadcast_addr,NULL ,0 ,NULL ,0 , scan_cmd_size -sizeof (*scan));break ;
drivers/net/wireless/intel/iwlwifi/dvm/sta.c +1 -3
@@ -32,8 +32,6 @@#include "dev.h" #include "agn.h" -const u8 iwl_bcast_addr[ETH_ALEN ] = {0xFF ,0xFF ,0xFF ,0xFF ,0xFF ,0xFF }; -static int iwl_sta_ucode_activate (struct iwl_priv *priv,u8 sta_id) {lockdep_assert_held (&priv->sta_lock);
@@ -1287,7 +1285,7 @@ int iwlagn_alloc_bcast_station(struct iwl_priv *priv,u8 sta_id;spin_lock_bh (&priv->sta_lock); - sta_id =iwl_prep_station (priv, ctx, iwl_bcast_addr, false,NULL ); + sta_id =iwl_prep_station (priv, ctx, ether_broadcast_addr, false,NULL );if (sta_id ==IWL_INVALID_STATION ) {IWL_ERR (priv,"Unable to prepare broadcast station\n" );spin_unlock_bh (&priv->sta_lock);
Signature · 1 line
2.15.0
Re: [PATCH 09/12] iwlwifi: Remove local iwl_bcast_addr and use ether_broadcast_addr
Quoted 4 lines · Joe Perches
Use the new global to save a little bit of object code.
Signed-off-by Joe Perches <[email protected]>---
I took this one to our internal tree and it will be applied as part of our normal upstreaming process.
Thanks!
--
Luca.
Re: [PATCH 09/12] iwlwifi: Remove local iwl_bcast_addr and use ether_broadcast_addr
Quoted 8 lines · Luciano Coelho
Quoted 4 lines · Joe Perches
Use the new global to save a little bit of object code.
Signed-off-by Joe Perches <[email protected]>---
I took this one to our internal tree and it will be applied as part of our normal upstreaming process.
It seems that the patch to etherdevice.h never got applied upstream, so I'm actually dropping this patch.
Please resend if it becomes relevant again.
--
Cheers,
Luca.
PATCH 10/12 mvpp2: Use ether_broadcast_addr instead of a local array
In reply to Joe PerchesSave a small bit of object code by using the new global instead.
--- drivers/net/ethernet/marvell/mvpp2.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/net/ethernet/marvell/mvpp2.c +1 -3
@@ -7345,11 +7345,9 @@ static int mvpp2_open(struct net_device *dev) {struct mvpp2_port *port =netdev_priv (dev);struct mvpp2 *priv = port->priv; -unsigned char mac_bcast[ETH_ALEN ] = { -0xff ,0xff ,0xff ,0xff ,0xff ,0xff };int err; - err =mvpp2_prs_mac_da_accept (port, mac_bcast, true); + err =mvpp2_prs_mac_da_accept (port, ether_broadcast_addr, true);if (err) {netdev_err (dev,"mvpp2_prs_mac_da_accept BC failed\n" );return err;
Signature · 1 line
2.15.0
PATCH 11/12 qlogic: Convert local bcast_addr to global ether_broadcast_addr
In reply to Joe PerchesUse the new global instead of local statics to save a bit of object code.
--- drivers/net/ethernet/qlogic/netxen/netxen_nic_hw.c | 5 +---- drivers/net/ethernet/qlogic/qlcnic/qlcnic_hw.c | 6 ++---- drivers/net/ethernet/qlogic/qlcnic/qlcnic_sriov_common.c | 6 ++---- 3 files changed, 5 insertions(+), 12 deletions(-)
drivers/net/ethernet/qlogic/netxen/netxen_nic_hw.c +1 -4
@@ -668,9 +668,6 @@ static void netxen_p3_nic_set_multi(struct net_device *netdev) {struct netxen_adapter *adapter =netdev_priv (netdev);struct netdev_hw_addr *ha; -static const u8 bcast_addr[ETH_ALEN ] = { -0xff ,0xff ,0xff ,0xff ,0xff ,0xff - };u32 mode =VPORT_MISS_MODE_DROP ;LIST_HEAD (del_list);struct list_head *head;
@@ -682,7 +679,7 @@ static void netxen_p3_nic_set_multi(struct net_device *netdev)list_splice_tail_init (&adapter->mac_list, &del_list);nx_p3_nic_add_mac (adapter, adapter->mac_addr, &del_list); -nx_p3_nic_add_mac (adapter, bcast_addr, &del_list); +nx_p3_nic_add_mac (adapter, ether_broadcast_addr, &del_list);if (netdev->flags &IFF_PROMISC ) { mode =VPORT_MISS_MODE_ACCEPT_ALL ;
drivers/net/ethernet/qlogic/qlcnic/qlcnic_hw.c +2 -4
@@ -542,9 +542,6 @@ static void __qlcnic_set_multi(struct net_device *netdev, u16 vlan)struct qlcnic_adapter *adapter =netdev_priv (netdev);struct qlcnic_hardware_context *ahw = adapter->ahw;struct netdev_hw_addr *ha; -static const u8 bcast_addr[ETH_ALEN ] = { -0xff ,0xff ,0xff ,0xff ,0xff ,0xff - };u32 mode =VPORT_MISS_MODE_DROP ;if (!test_bit (__QLCNIC_FW_ATTACHED, &adapter->state))
@@ -552,7 +549,8 @@ static void __qlcnic_set_multi(struct net_device *netdev, u16 vlan)qlcnic_nic_add_mac (adapter, adapter->mac_addr, vlan,QLCNIC_UNICAST_MAC ); -qlcnic_nic_add_mac (adapter, bcast_addr, vlan,QLCNIC_BROADCAST_MAC ); +qlcnic_nic_add_mac (adapter, ether_broadcast_addr, vlan, +QLCNIC_BROADCAST_MAC );if (netdev->flags &IFF_PROMISC ) {if (!(adapter->flags &QLCNIC_PROMISC_DISABLED ))
drivers/net/ethernet/qlogic/qlcnic/qlcnic_sriov_common.c +2 -4
@@ -1546,9 +1546,6 @@ void qlcnic_sriov_vf_set_multi(struct net_device *netdev) {struct qlcnic_adapter *adapter =netdev_priv (netdev);struct qlcnic_hardware_context *ahw = adapter->ahw; -static const u8 bcast_addr[ETH_ALEN ] = { -0xff ,0xff ,0xff ,0xff ,0xff ,0xff - };struct netdev_hw_addr *ha;u32 mode =VPORT_MISS_MODE_DROP ;
@@ -1562,7 +1559,8 @@ void qlcnic_sriov_vf_set_multi(struct net_device *netdev) (netdev_mc_count(netdev) > ahw->max_mc_count)) { mode = VPORT_MISS_MODE_ACCEPT_MULTI; } else { -qlcnic_vf_add_mc_list (netdev, bcast_addr,QLCNIC_BROADCAST_MAC ); +qlcnic_vf_add_mc_list (netdev, ether_broadcast_addr, +QLCNIC_BROADCAST_MAC );if (!netdev_mc_empty (netdev)) {qlcnic_flush_mcast_mac (adapter);netdev_for_each_mc_addr (ha, netdev)
Signature · 1 line
2.15.0
PATCH 12/12 ethernet: Use ether_zero_addr instead of local statics
In reply to Joe PerchesThis saves a small amount of object code.
Miscellanea:
o __b44_cam_write now use const u8 *data instead of unsigned char * to avoid compiler warnings as it doesn't modify data
--- drivers/net/ethernet/broadcom/b44.c | 5 ++--- drivers/net/ethernet/freescale/gianfar.c | 3 +-- 2 files changed, 3 insertions(+), 5 deletions(-)
drivers/net/ethernet/broadcom/b44.c +2 -3
@@ -220,7 +220,7 @@ static inline void __b44_cam_read(struct b44 *bp, unsigned char *data, int index data[1 ] = (val >>0 ) &0xFF ; } -static inline void __b44_cam_write (struct b44 *bp,unsigned char *data,int index) +static inline void __b44_cam_write (struct b44 *bp,const u8 *data,int index) {u32 val;
@@ -1744,7 +1744,6 @@ static void __b44_set_rx_mode(struct net_device *dev) val |=RXCONFIG_PROMISC ;bw32 (bp,B44_RXCONFIG , val); }else { -unsigned char zero[6 ] = {0 ,0 ,0 ,0 ,0 ,0 };int i =1 ;__b44_set_mac_addr (bp);
@@ -1756,7 +1755,7 @@ static void __b44_set_rx_mode(struct net_device *dev) i =__b44_load_mcast (bp, dev);for (; i <64 ; i++) -__b44_cam_write (bp, zero, i); +__b44_cam_write (bp, ether_zero_addr, i);bw32 (bp,B44_RXCONFIG , val); val =br32 (bp,B44_CAM_CTRL );
drivers/net/ethernet/freescale/gianfar.c +1 -2
@@ -3501,10 +3501,9 @@ static void gfar_set_multi(struct net_device *dev)static void gfar_clear_exact_match (struct net_device *dev) {int idx; -static const u8 zero_arr[ETH_ALEN ] = {0 ,0 ,0 ,0 ,0 ,0 };for (idx =1 ; idx <GFAR_EM_NUM +1 ; idx++) -gfar_set_mac_for_addr (dev, idx, zero_arr); +gfar_set_mac_for_addr (dev, idx, ether_zero_addr); }/* Set the appropriate hash bit for the given addr */
Signature · 1 line
2.15.0
Quoted 5 lines · Joe Perches
There are many local static and non-static arrays that are used for Ethernet broadcast address output or comparison.
Centralize the array into a single separate file and remove the local arrays.
I suspect that for many targets and configurations, the local arrays might actually be smaller than exporting a global. You have to factor in not just the .text size, but the fact that referencing an exported symbol needs a .reloc entry as well, which also eats up some space (at least when the code is being built as module).
In my opinion, your series probably causes more bloat in common configurations instead of reducing it.
You're also touching several places that could easily use eth_broadcast_addr and eth_zero_addr. I think making those changes would be more productive than what you did in this series.
- Felix
Quoted 9 lines · Felix Fietkau
Quoted 5 lines · Joe Perches
There are many local static and non-static arrays that are used for Ethernet broadcast address output or comparison.
Centralize the array into a single separate file and remove the local arrays.
I suspect that for many targets and configurations, the local arrays might actually be smaller than exporting a global.
I tried x86-64 allnoconfig and defconfig.
Those both did not increase vmlinux size.
The defconfig actually got smaller, but that might have been some object alignment oddity.
Quoted 4 lines
You have to factor in
not just the .text size, but the fact that referencing an exported symbol needs a .reloc entry as well, which also eats up some space (at least when the code is being built as module).
Thanks, the modules I built got smaller.
Quoted 6 lines
In my opinion, your series probably causes more bloat in common configurations instead of reducing it.
You're also touching several places that could easily use
eth_broadcast_addrandeth_zero_addr. I think making those changes would be more productive than what you did in this series.
Doubtful. AFAIK: possible unaligned addresses.
Quoted 6 lines · Joe Perches
Quoted 4 lines
You have to factor in
not just the .text size, but the fact that referencing an exported symbol needs a .reloc entry as well, which also eats up some space (at least when the code is being built as module).Thanks, the modules I built got smaller.
Please post some numbers to show this. By the way, on other architectures the numbers will probably be different, especially on ARM/MIPS.
Quoted 8 lines
Quoted 6 lines
In my opinion, your series probably causes more bloat in common configurations instead of reducing it.
You're also touching several places that could easily use
eth_broadcast_addrandeth_zero_addr. I think making those changes would be more productive than what you did in this series.Doubtful. AFAIK: possible unaligned addresses.
Those two are just memset calls, alignment does not matter.
- Felix