Skip to content

Commit 692e516

Browse files
dingtianhongdavem330
authored andcommitted
wireless: slight optimization of addr compare
Use possibly more efficient ether_addr_equal or ether_addr_equal_unaligned instead of memcmp. Cc: John W. Linville <[email protected]> Cc: [email protected] Cc: [email protected] Cc: [email protected] Signed-off-by: Weilong Chen <[email protected]> Signed-off-by: Ding Tianhong <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 4f29739 commit 692e516

File tree

6 files changed

+13
-13
lines changed

6 files changed

+13
-13
lines changed

drivers/net/wireless/adm8211.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1314,7 +1314,7 @@ static void adm8211_bss_info_changed(struct ieee80211_hw *dev,
13141314
if (!(changes & BSS_CHANGED_BSSID))
13151315
return;
13161316

1317-
if (memcmp(conf->bssid, priv->bssid, ETH_ALEN)) {
1317+
if (!ether_addr_equal(conf->bssid, priv->bssid)) {
13181318
adm8211_set_bssid(dev, conf->bssid);
13191319
memcpy(priv->bssid, conf->bssid, ETH_ALEN);
13201320
}

drivers/net/wireless/brcm80211/brcmfmac/p2p.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1243,7 +1243,7 @@ bool brcmf_p2p_scan_finding_common_channel(struct brcmf_cfg80211_info *cfg,
12431243
IEEE80211_P2P_ATTR_DEVICE_ID,
12441244
p2p_dev_addr, sizeof(p2p_dev_addr));
12451245
if ((err >= 0) &&
1246-
(!memcmp(p2p_dev_addr, afx_hdl->tx_dst_addr, ETH_ALEN))) {
1246+
(ether_addr_equal(p2p_dev_addr, afx_hdl->tx_dst_addr))) {
12471247
if (!bi->ctl_ch) {
12481248
ch.chspec = le16_to_cpu(bi->chanspec);
12491249
cfg->d11inf.decchspec(&ch);
@@ -1380,8 +1380,7 @@ int brcmf_p2p_notify_action_frame_rx(struct brcmf_if *ifp,
13801380
(brcmf_p2p_gon_req_collision(p2p, (u8 *)e->addr))) {
13811381
if (test_bit(BRCMF_P2P_STATUS_FINDING_COMMON_CHANNEL,
13821382
&p2p->status) &&
1383-
(memcmp(afx_hdl->tx_dst_addr, e->addr,
1384-
ETH_ALEN) == 0)) {
1383+
(ether_addr_equal(afx_hdl->tx_dst_addr, e->addr))) {
13851384
afx_hdl->peer_chan = ch.chnum;
13861385
brcmf_dbg(INFO, "GON request: Peer found, channel=%d\n",
13871386
afx_hdl->peer_chan);
@@ -1865,7 +1864,7 @@ s32 brcmf_p2p_notify_rx_mgmt_p2p_probereq(struct brcmf_if *ifp,
18651864
cfg->d11inf.decchspec(&ch);
18661865

18671866
if (test_bit(BRCMF_P2P_STATUS_FINDING_COMMON_CHANNEL, &p2p->status) &&
1868-
(memcmp(afx_hdl->tx_dst_addr, e->addr, ETH_ALEN) == 0)) {
1867+
(ether_addr_equal(afx_hdl->tx_dst_addr, e->addr))) {
18691868
afx_hdl->peer_chan = ch.chnum;
18701869
brcmf_dbg(INFO, "PROBE REQUEST: Peer found, channel=%d\n",
18711870
afx_hdl->peer_chan);

drivers/net/wireless/hostap/hostap_80211_rx.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -563,7 +563,7 @@ hostap_rx_frame_wds(local_info_t *local, struct ieee80211_hdr *hdr, u16 fc,
563563

564564
/* Possible WDS frame: either IEEE 802.11 compliant (if FromDS)
565565
* or own non-standard frame with 4th address after payload */
566-
if (memcmp(hdr->addr1, local->dev->dev_addr, ETH_ALEN) != 0 &&
566+
if (!ether_addr_equal(hdr->addr1, local->dev->dev_addr) &&
567567
(hdr->addr1[0] != 0xff || hdr->addr1[1] != 0xff ||
568568
hdr->addr1[2] != 0xff || hdr->addr1[3] != 0xff ||
569569
hdr->addr1[4] != 0xff || hdr->addr1[5] != 0xff)) {
@@ -622,12 +622,12 @@ static int hostap_is_eapol_frame(local_info_t *local, struct sk_buff *skb)
622622
/* check that the frame is unicast frame to us */
623623
if ((fc & (IEEE80211_FCTL_TODS | IEEE80211_FCTL_FROMDS)) ==
624624
IEEE80211_FCTL_TODS &&
625-
memcmp(hdr->addr1, dev->dev_addr, ETH_ALEN) == 0 &&
626-
memcmp(hdr->addr3, dev->dev_addr, ETH_ALEN) == 0) {
625+
ether_addr_equal(hdr->addr1, dev->dev_addr) &&
626+
ether_addr_equal(hdr->addr3, dev->dev_addr)) {
627627
/* ToDS frame with own addr BSSID and DA */
628628
} else if ((fc & (IEEE80211_FCTL_TODS | IEEE80211_FCTL_FROMDS)) ==
629629
IEEE80211_FCTL_FROMDS &&
630-
memcmp(hdr->addr1, dev->dev_addr, ETH_ALEN) == 0) {
630+
ether_addr_equal(hdr->addr1, dev->dev_addr)) {
631631
/* FromDS frame with own addr as DA */
632632
} else
633633
return 0;

drivers/net/wireless/prism54/isl_ioctl.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#include <linux/if_arp.h>
2525
#include <linux/slab.h>
2626
#include <linux/pci.h>
27+
#include <linux/etherdevice.h>
2728

2829
#include <asm/uaccess.h>
2930

@@ -1860,7 +1861,7 @@ prism54_del_mac(struct net_device *ndev, struct iw_request_info *info,
18601861
if (mutex_lock_interruptible(&acl->lock))
18611862
return -ERESTARTSYS;
18621863
list_for_each_entry(entry, &acl->mac_list, _list) {
1863-
if (memcmp(entry->addr, addr->sa_data, ETH_ALEN) == 0) {
1864+
if (ether_addr_equal(entry->addr, addr->sa_data)) {
18641865
list_del(&entry->_list);
18651866
acl->size--;
18661867
kfree(entry);

drivers/net/wireless/ti/wl1251/main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -521,7 +521,7 @@ static int wl1251_op_add_interface(struct ieee80211_hw *hw,
521521
goto out;
522522
}
523523

524-
if (memcmp(wl->mac_addr, vif->addr, ETH_ALEN)) {
524+
if (!ether_addr_equal_unaligned(wl->mac_addr, vif->addr)) {
525525
memcpy(wl->mac_addr, vif->addr, ETH_ALEN);
526526
SET_IEEE80211_PERM_ADDR(wl->hw, wl->mac_addr);
527527
ret = wl1251_acx_station_id(wl);

drivers/net/wireless/wl3501_cs.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
#include <linux/string.h>
4545
#include <linux/wireless.h>
4646
#include <linux/ieee80211.h>
47+
#include <linux/etherdevice.h>
4748

4849
#include <net/iw_handler.h>
4950

@@ -673,8 +674,7 @@ static void wl3501_mgmt_scan_confirm(struct wl3501_card *this, u16 addr)
673674
matchflag = 1;
674675
if (matchflag) {
675676
for (i = 0; i < this->bss_cnt; i++) {
676-
if (!memcmp(this->bss_set[i].bssid,
677-
sig.bssid, ETH_ALEN)) {
677+
if (ether_addr_equal_unaligned(this->bss_set[i].bssid, sig.bssid)) {
678678
matchflag = 0;
679679
break;
680680
}

0 commit comments

Comments
 (0)