diff options
author | dingtianhong <dingtianhong@huawei.com> | 2013-12-26 06:41:23 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2013-12-26 13:31:35 -0500 |
commit | 36325f3a9fabe66b3c2442f63163958f992ff16e (patch) | |
tree | 02ce300a456d2bf01e22b1097c5662b1ac8d4421 | |
parent | 35df5388ac7cd205cc642b28eb90f940c816eaf7 (diff) |
ipw2x00: slight optimization of addr compare
Use possibly more efficient ether_addr_equal
instead of memcmp.
Cc: Stanislav Yakovlev <stas.yakovlev@gmail.com>
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>
-rw-r--r-- | drivers/net/wireless/ipw2x00/ipw2200.c | 34 | ||||
-rw-r--r-- | drivers/net/wireless/ipw2x00/libipw_rx.c | 10 |
2 files changed, 22 insertions, 22 deletions
diff --git a/drivers/net/wireless/ipw2x00/ipw2200.c b/drivers/net/wireless/ipw2x00/ipw2200.c index 9244b3661d34..139326065bd9 100644 --- a/drivers/net/wireless/ipw2x00/ipw2200.c +++ b/drivers/net/wireless/ipw2x00/ipw2200.c | |||
@@ -3012,7 +3012,7 @@ static void ipw_remove_current_network(struct ipw_priv *priv) | |||
3012 | spin_lock_irqsave(&priv->ieee->lock, flags); | 3012 | spin_lock_irqsave(&priv->ieee->lock, flags); |
3013 | list_for_each_safe(element, safe, &priv->ieee->network_list) { | 3013 | list_for_each_safe(element, safe, &priv->ieee->network_list) { |
3014 | network = list_entry(element, struct libipw_network, list); | 3014 | network = list_entry(element, struct libipw_network, list); |
3015 | if (!memcmp(network->bssid, priv->bssid, ETH_ALEN)) { | 3015 | if (ether_addr_equal(network->bssid, priv->bssid)) { |
3016 | list_del(element); | 3016 | list_del(element); |
3017 | list_add_tail(&network->list, | 3017 | list_add_tail(&network->list, |
3018 | &priv->ieee->network_free_list); | 3018 | &priv->ieee->network_free_list); |
@@ -3921,7 +3921,7 @@ static u8 ipw_add_station(struct ipw_priv *priv, u8 * bssid) | |||
3921 | int i; | 3921 | int i; |
3922 | 3922 | ||
3923 | for (i = 0; i < priv->num_stations; i++) { | 3923 | for (i = 0; i < priv->num_stations; i++) { |
3924 | if (!memcmp(priv->stations[i], bssid, ETH_ALEN)) { | 3924 | if (ether_addr_equal(priv->stations[i], bssid)) { |
3925 | /* Another node is active in network */ | 3925 | /* Another node is active in network */ |
3926 | priv->missed_adhoc_beacons = 0; | 3926 | priv->missed_adhoc_beacons = 0; |
3927 | if (!(priv->config & CFG_STATIC_CHANNEL)) | 3927 | if (!(priv->config & CFG_STATIC_CHANNEL)) |
@@ -3953,7 +3953,7 @@ static u8 ipw_find_station(struct ipw_priv *priv, u8 * bssid) | |||
3953 | int i; | 3953 | int i; |
3954 | 3954 | ||
3955 | for (i = 0; i < priv->num_stations; i++) | 3955 | for (i = 0; i < priv->num_stations; i++) |
3956 | if (!memcmp(priv->stations[i], bssid, ETH_ALEN)) | 3956 | if (ether_addr_equal(priv->stations[i], bssid)) |
3957 | return i; | 3957 | return i; |
3958 | 3958 | ||
3959 | return IPW_INVALID_STATION; | 3959 | return IPW_INVALID_STATION; |
@@ -5622,7 +5622,7 @@ static int ipw_find_adhoc_network(struct ipw_priv *priv, | |||
5622 | return 0; | 5622 | return 0; |
5623 | } | 5623 | } |
5624 | 5624 | ||
5625 | if (!memcmp(network->bssid, priv->bssid, ETH_ALEN)) { | 5625 | if (ether_addr_equal(network->bssid, priv->bssid)) { |
5626 | IPW_DEBUG_MERGE("Network '%s (%pM)' excluded " | 5626 | IPW_DEBUG_MERGE("Network '%s (%pM)' excluded " |
5627 | "because of the same BSSID match: %pM" | 5627 | "because of the same BSSID match: %pM" |
5628 | ".\n", print_ssid(ssid, network->ssid, | 5628 | ".\n", print_ssid(ssid, network->ssid, |
@@ -5849,7 +5849,7 @@ static int ipw_best_network(struct ipw_priv *priv, | |||
5849 | } | 5849 | } |
5850 | 5850 | ||
5851 | if ((priv->config & CFG_STATIC_BSSID) && | 5851 | if ((priv->config & CFG_STATIC_BSSID) && |
5852 | memcmp(network->bssid, priv->bssid, ETH_ALEN)) { | 5852 | !ether_addr_equal(network->bssid, priv->bssid)) { |
5853 | IPW_DEBUG_ASSOC("Network '%s (%pM)' excluded " | 5853 | IPW_DEBUG_ASSOC("Network '%s (%pM)' excluded " |
5854 | "because of BSSID mismatch: %pM.\n", | 5854 | "because of BSSID mismatch: %pM.\n", |
5855 | print_ssid(ssid, network->ssid, | 5855 | print_ssid(ssid, network->ssid, |
@@ -6988,7 +6988,7 @@ static int ipw_qos_handle_probe_response(struct ipw_priv *priv, | |||
6988 | } | 6988 | } |
6989 | if ((priv->status & STATUS_ASSOCIATED) && | 6989 | if ((priv->status & STATUS_ASSOCIATED) && |
6990 | (priv->ieee->iw_mode == IW_MODE_ADHOC) && (active_network == 0)) { | 6990 | (priv->ieee->iw_mode == IW_MODE_ADHOC) && (active_network == 0)) { |
6991 | if (memcmp(network->bssid, priv->bssid, ETH_ALEN)) | 6991 | if (!ether_addr_equal(network->bssid, priv->bssid)) |
6992 | if (network->capability & WLAN_CAPABILITY_IBSS) | 6992 | if (network->capability & WLAN_CAPABILITY_IBSS) |
6993 | if ((network->ssid_len == | 6993 | if ((network->ssid_len == |
6994 | priv->assoc_network->ssid_len) && | 6994 | priv->assoc_network->ssid_len) && |
@@ -8210,29 +8210,29 @@ static int is_network_packet(struct ipw_priv *priv, | |||
8210 | switch (priv->ieee->iw_mode) { | 8210 | switch (priv->ieee->iw_mode) { |
8211 | case IW_MODE_ADHOC: /* Header: Dest. | Source | BSSID */ | 8211 | case IW_MODE_ADHOC: /* Header: Dest. | Source | BSSID */ |
8212 | /* packets from our adapter are dropped (echo) */ | 8212 | /* packets from our adapter are dropped (echo) */ |
8213 | if (!memcmp(header->addr2, priv->net_dev->dev_addr, ETH_ALEN)) | 8213 | if (ether_addr_equal(header->addr2, priv->net_dev->dev_addr)) |
8214 | return 0; | 8214 | return 0; |
8215 | 8215 | ||
8216 | /* {broad,multi}cast packets to our BSSID go through */ | 8216 | /* {broad,multi}cast packets to our BSSID go through */ |
8217 | if (is_multicast_ether_addr(header->addr1)) | 8217 | if (is_multicast_ether_addr(header->addr1)) |
8218 | return !memcmp(header->addr3, priv->bssid, ETH_ALEN); | 8218 | return ether_addr_equal(header->addr3, priv->bssid); |
8219 | 8219 | ||
8220 | /* packets to our adapter go through */ | 8220 | /* packets to our adapter go through */ |
8221 | return !memcmp(header->addr1, priv->net_dev->dev_addr, | 8221 | return ether_addr_equal(header->addr1, |
8222 | ETH_ALEN); | 8222 | priv->net_dev->dev_addr); |
8223 | 8223 | ||
8224 | case IW_MODE_INFRA: /* Header: Dest. | BSSID | Source */ | 8224 | case IW_MODE_INFRA: /* Header: Dest. | BSSID | Source */ |
8225 | /* packets from our adapter are dropped (echo) */ | 8225 | /* packets from our adapter are dropped (echo) */ |
8226 | if (!memcmp(header->addr3, priv->net_dev->dev_addr, ETH_ALEN)) | 8226 | if (ether_addr_equal(header->addr3, priv->net_dev->dev_addr)) |
8227 | return 0; | 8227 | return 0; |
8228 | 8228 | ||
8229 | /* {broad,multi}cast packets to our BSS go through */ | 8229 | /* {broad,multi}cast packets to our BSS go through */ |
8230 | if (is_multicast_ether_addr(header->addr1)) | 8230 | if (is_multicast_ether_addr(header->addr1)) |
8231 | return !memcmp(header->addr2, priv->bssid, ETH_ALEN); | 8231 | return ether_addr_equal(header->addr2, priv->bssid); |
8232 | 8232 | ||
8233 | /* packets to our adapter go through */ | 8233 | /* packets to our adapter go through */ |
8234 | return !memcmp(header->addr1, priv->net_dev->dev_addr, | 8234 | return ether_addr_equal(header->addr1, |
8235 | ETH_ALEN); | 8235 | priv->net_dev->dev_addr); |
8236 | } | 8236 | } |
8237 | 8237 | ||
8238 | return 1; | 8238 | return 1; |
@@ -8260,7 +8260,7 @@ static int is_duplicate_packet(struct ipw_priv *priv, | |||
8260 | list_for_each(p, &priv->ibss_mac_hash[index]) { | 8260 | list_for_each(p, &priv->ibss_mac_hash[index]) { |
8261 | entry = | 8261 | entry = |
8262 | list_entry(p, struct ipw_ibss_seq, list); | 8262 | list_entry(p, struct ipw_ibss_seq, list); |
8263 | if (!memcmp(entry->mac, mac, ETH_ALEN)) | 8263 | if (ether_addr_equal(entry->mac, mac)) |
8264 | break; | 8264 | break; |
8265 | } | 8265 | } |
8266 | if (p == &priv->ibss_mac_hash[index]) { | 8266 | if (p == &priv->ibss_mac_hash[index]) { |
@@ -8329,7 +8329,7 @@ static void ipw_handle_mgmt_packet(struct ipw_priv *priv, | |||
8329 | IEEE80211_STYPE_PROBE_RESP) || | 8329 | IEEE80211_STYPE_PROBE_RESP) || |
8330 | (WLAN_FC_GET_STYPE(le16_to_cpu(header->frame_ctl)) == | 8330 | (WLAN_FC_GET_STYPE(le16_to_cpu(header->frame_ctl)) == |
8331 | IEEE80211_STYPE_BEACON))) { | 8331 | IEEE80211_STYPE_BEACON))) { |
8332 | if (!memcmp(header->addr3, priv->bssid, ETH_ALEN)) | 8332 | if (ether_addr_equal(header->addr3, priv->bssid)) |
8333 | ipw_add_station(priv, header->addr2); | 8333 | ipw_add_station(priv, header->addr2); |
8334 | } | 8334 | } |
8335 | 8335 | ||
@@ -9045,7 +9045,7 @@ static int ipw_wx_set_wap(struct net_device *dev, | |||
9045 | } | 9045 | } |
9046 | 9046 | ||
9047 | priv->config |= CFG_STATIC_BSSID; | 9047 | priv->config |= CFG_STATIC_BSSID; |
9048 | if (!memcmp(priv->bssid, wrqu->ap_addr.sa_data, ETH_ALEN)) { | 9048 | if (ether_addr_equal(priv->bssid, wrqu->ap_addr.sa_data)) { |
9049 | IPW_DEBUG_WX("BSSID set to current BSSID.\n"); | 9049 | IPW_DEBUG_WX("BSSID set to current BSSID.\n"); |
9050 | mutex_unlock(&priv->mutex); | 9050 | mutex_unlock(&priv->mutex); |
9051 | return 0; | 9051 | return 0; |
diff --git a/drivers/net/wireless/ipw2x00/libipw_rx.c b/drivers/net/wireless/ipw2x00/libipw_rx.c index 9ffe65931b29..5c6253811c52 100644 --- a/drivers/net/wireless/ipw2x00/libipw_rx.c +++ b/drivers/net/wireless/ipw2x00/libipw_rx.c | |||
@@ -874,13 +874,13 @@ void libipw_rx_any(struct libipw_device *ieee, | |||
874 | switch (ieee->iw_mode) { | 874 | switch (ieee->iw_mode) { |
875 | case IW_MODE_ADHOC: | 875 | case IW_MODE_ADHOC: |
876 | /* our BSS and not from/to DS */ | 876 | /* our BSS and not from/to DS */ |
877 | if (memcmp(hdr->addr3, ieee->bssid, ETH_ALEN) == 0) | 877 | if (ether_addr_equal(hdr->addr3, ieee->bssid)) |
878 | if ((fc & (IEEE80211_FCTL_TODS+IEEE80211_FCTL_FROMDS)) == 0) { | 878 | if ((fc & (IEEE80211_FCTL_TODS+IEEE80211_FCTL_FROMDS)) == 0) { |
879 | /* promisc: get all */ | 879 | /* promisc: get all */ |
880 | if (ieee->dev->flags & IFF_PROMISC) | 880 | if (ieee->dev->flags & IFF_PROMISC) |
881 | is_packet_for_us = 1; | 881 | is_packet_for_us = 1; |
882 | /* to us */ | 882 | /* to us */ |
883 | else if (memcmp(hdr->addr1, ieee->dev->dev_addr, ETH_ALEN) == 0) | 883 | else if (ether_addr_equal(hdr->addr1, ieee->dev->dev_addr)) |
884 | is_packet_for_us = 1; | 884 | is_packet_for_us = 1; |
885 | /* mcast */ | 885 | /* mcast */ |
886 | else if (is_multicast_ether_addr(hdr->addr1)) | 886 | else if (is_multicast_ether_addr(hdr->addr1)) |
@@ -889,18 +889,18 @@ void libipw_rx_any(struct libipw_device *ieee, | |||
889 | break; | 889 | break; |
890 | case IW_MODE_INFRA: | 890 | case IW_MODE_INFRA: |
891 | /* our BSS (== from our AP) and from DS */ | 891 | /* our BSS (== from our AP) and from DS */ |
892 | if (memcmp(hdr->addr2, ieee->bssid, ETH_ALEN) == 0) | 892 | if (ether_addr_equal(hdr->addr2, ieee->bssid)) |
893 | if ((fc & (IEEE80211_FCTL_TODS+IEEE80211_FCTL_FROMDS)) == IEEE80211_FCTL_FROMDS) { | 893 | if ((fc & (IEEE80211_FCTL_TODS+IEEE80211_FCTL_FROMDS)) == IEEE80211_FCTL_FROMDS) { |
894 | /* promisc: get all */ | 894 | /* promisc: get all */ |
895 | if (ieee->dev->flags & IFF_PROMISC) | 895 | if (ieee->dev->flags & IFF_PROMISC) |
896 | is_packet_for_us = 1; | 896 | is_packet_for_us = 1; |
897 | /* to us */ | 897 | /* to us */ |
898 | else if (memcmp(hdr->addr1, ieee->dev->dev_addr, ETH_ALEN) == 0) | 898 | else if (ether_addr_equal(hdr->addr1, ieee->dev->dev_addr)) |
899 | is_packet_for_us = 1; | 899 | is_packet_for_us = 1; |
900 | /* mcast */ | 900 | /* mcast */ |
901 | else if (is_multicast_ether_addr(hdr->addr1)) { | 901 | else if (is_multicast_ether_addr(hdr->addr1)) { |
902 | /* not our own packet bcasted from AP */ | 902 | /* not our own packet bcasted from AP */ |
903 | if (memcmp(hdr->addr3, ieee->dev->dev_addr, ETH_ALEN)) | 903 | if (!ether_addr_equal(hdr->addr3, ieee->dev->dev_addr)) |
904 | is_packet_for_us = 1; | 904 | is_packet_for_us = 1; |
905 | } | 905 | } |
906 | } | 906 | } |