wireless: slight optimization of addr compare
authordingtianhong <dingtianhong@huawei.com>
Thu, 26 Dec 2013 11:41:34 +0000 (19:41 +0800)
committerDavid S. Miller <davem@davemloft.net>
Thu, 26 Dec 2013 18:31:35 +0000 (13:31 -0500)
Use possibly more efficient ether_addr_equal or
ether_addr_equal_unaligned instead of memcmp.

Cc: John W. Linville <linville@tuxdriver.com>
Cc: linux-wireless@vger.kernel.org
Cc: netdev@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Weilong Chen <chenweilong@huawei.com>
Signed-off-by: Ding Tianhong <dingtianhong@huawei.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/wireless/adm8211.c
drivers/net/wireless/brcm80211/brcmfmac/p2p.c
drivers/net/wireless/hostap/hostap_80211_rx.c
drivers/net/wireless/prism54/isl_ioctl.c
drivers/net/wireless/ti/wl1251/main.c
drivers/net/wireless/wl3501_cs.c

index cfce83e1f273f0259ee07d072fd8c8f59df8e99a..1d40c69cc4a90419e00d74653b677f8d3618a497 100644 (file)
@@ -1314,7 +1314,7 @@ static void adm8211_bss_info_changed(struct ieee80211_hw *dev,
        if (!(changes & BSS_CHANGED_BSSID))
                return;
 
-       if (memcmp(conf->bssid, priv->bssid, ETH_ALEN)) {
+       if (!ether_addr_equal(conf->bssid, priv->bssid)) {
                adm8211_set_bssid(dev, conf->bssid);
                memcpy(priv->bssid, conf->bssid, ETH_ALEN);
        }
index d3180360725925c40f6e59bf09bdfb28e18a4300..185af8a84c9afa450beb721ecd49e5773eb0484e 100644 (file)
@@ -1243,7 +1243,7 @@ bool brcmf_p2p_scan_finding_common_channel(struct brcmf_cfg80211_info *cfg,
                                            IEEE80211_P2P_ATTR_DEVICE_ID,
                                            p2p_dev_addr, sizeof(p2p_dev_addr));
        if ((err >= 0) &&
-           (!memcmp(p2p_dev_addr, afx_hdl->tx_dst_addr, ETH_ALEN))) {
+           (ether_addr_equal(p2p_dev_addr, afx_hdl->tx_dst_addr))) {
                if (!bi->ctl_ch) {
                        ch.chspec = le16_to_cpu(bi->chanspec);
                        cfg->d11inf.decchspec(&ch);
@@ -1380,8 +1380,7 @@ int brcmf_p2p_notify_action_frame_rx(struct brcmf_if *ifp,
                    (brcmf_p2p_gon_req_collision(p2p, (u8 *)e->addr))) {
                        if (test_bit(BRCMF_P2P_STATUS_FINDING_COMMON_CHANNEL,
                                     &p2p->status) &&
-                           (memcmp(afx_hdl->tx_dst_addr, e->addr,
-                                   ETH_ALEN) == 0)) {
+                           (ether_addr_equal(afx_hdl->tx_dst_addr, e->addr))) {
                                afx_hdl->peer_chan = ch.chnum;
                                brcmf_dbg(INFO, "GON request: Peer found, channel=%d\n",
                                          afx_hdl->peer_chan);
@@ -1865,7 +1864,7 @@ s32 brcmf_p2p_notify_rx_mgmt_p2p_probereq(struct brcmf_if *ifp,
        cfg->d11inf.decchspec(&ch);
 
        if (test_bit(BRCMF_P2P_STATUS_FINDING_COMMON_CHANNEL, &p2p->status) &&
-           (memcmp(afx_hdl->tx_dst_addr, e->addr, ETH_ALEN) == 0)) {
+           (ether_addr_equal(afx_hdl->tx_dst_addr, e->addr))) {
                afx_hdl->peer_chan = ch.chnum;
                brcmf_dbg(INFO, "PROBE REQUEST: Peer found, channel=%d\n",
                          afx_hdl->peer_chan);
index d39e3e24077b1dca873f0ffe0dbce6a221dbaaea..599f30f22841f9e665a485f675ad449d105c448a 100644 (file)
@@ -563,7 +563,7 @@ hostap_rx_frame_wds(local_info_t *local, struct ieee80211_hdr *hdr, u16 fc,
 
        /* Possible WDS frame: either IEEE 802.11 compliant (if FromDS)
         * or own non-standard frame with 4th address after payload */
-       if (memcmp(hdr->addr1, local->dev->dev_addr, ETH_ALEN) != 0 &&
+       if (!ether_addr_equal(hdr->addr1, local->dev->dev_addr) &&
            (hdr->addr1[0] != 0xff || hdr->addr1[1] != 0xff ||
             hdr->addr1[2] != 0xff || hdr->addr1[3] != 0xff ||
             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)
        /* check that the frame is unicast frame to us */
        if ((fc & (IEEE80211_FCTL_TODS | IEEE80211_FCTL_FROMDS)) ==
            IEEE80211_FCTL_TODS &&
-           memcmp(hdr->addr1, dev->dev_addr, ETH_ALEN) == 0 &&
-           memcmp(hdr->addr3, dev->dev_addr, ETH_ALEN) == 0) {
+           ether_addr_equal(hdr->addr1, dev->dev_addr) &&
+           ether_addr_equal(hdr->addr3, dev->dev_addr)) {
                /* ToDS frame with own addr BSSID and DA */
        } else if ((fc & (IEEE80211_FCTL_TODS | IEEE80211_FCTL_FROMDS)) ==
                   IEEE80211_FCTL_FROMDS &&
-                  memcmp(hdr->addr1, dev->dev_addr, ETH_ALEN) == 0) {
+                  ether_addr_equal(hdr->addr1, dev->dev_addr)) {
                /* FromDS frame with own addr as DA */
        } else
                return 0;
index df784fefb8e3e322ca0fc5dd73c127051a08524a..78fa64d3f2232a85a15a8b88f698765f80c9dfc8 100644 (file)
@@ -24,6 +24,7 @@
 #include <linux/if_arp.h>
 #include <linux/slab.h>
 #include <linux/pci.h>
+#include <linux/etherdevice.h>
 
 #include <asm/uaccess.h>
 
@@ -1860,7 +1861,7 @@ prism54_del_mac(struct net_device *ndev, struct iw_request_info *info,
        if (mutex_lock_interruptible(&acl->lock))
                return -ERESTARTSYS;
        list_for_each_entry(entry, &acl->mac_list, _list) {
-               if (memcmp(entry->addr, addr->sa_data, ETH_ALEN) == 0) {
+               if (ether_addr_equal(entry->addr, addr->sa_data)) {
                        list_del(&entry->_list);
                        acl->size--;
                        kfree(entry);
index 3291ffa952736ac9f6ac2784c758db39b498d37c..b8a360b43e76f7a0c96ed855e36d71242e4e3290 100644 (file)
@@ -521,7 +521,7 @@ static int wl1251_op_add_interface(struct ieee80211_hw *hw,
                goto out;
        }
 
-       if (memcmp(wl->mac_addr, vif->addr, ETH_ALEN)) {
+       if (!ether_addr_equal_unaligned(wl->mac_addr, vif->addr)) {
                memcpy(wl->mac_addr, vif->addr, ETH_ALEN);
                SET_IEEE80211_PERM_ADDR(wl->hw, wl->mac_addr);
                ret = wl1251_acx_station_id(wl);
index 38d2089f338a3277d8ff77126f3dd166524f84b8..1477d7f059053049c37ae095f643d1c7b3208840 100644 (file)
@@ -44,6 +44,7 @@
 #include <linux/string.h>
 #include <linux/wireless.h>
 #include <linux/ieee80211.h>
+#include <linux/etherdevice.h>
 
 #include <net/iw_handler.h>
 
@@ -673,8 +674,7 @@ static void wl3501_mgmt_scan_confirm(struct wl3501_card *this, u16 addr)
                                matchflag = 1;
                        if (matchflag) {
                                for (i = 0; i < this->bss_cnt; i++) {
-                                       if (!memcmp(this->bss_set[i].bssid,
-                                                   sig.bssid, ETH_ALEN)) {
+                                       if (ether_addr_equal_unaligned(this->bss_set[i].bssid, sig.bssid)) {
                                                matchflag = 0;
                                                break;
                                        }