Skip to content

Commit 36325f3

Browse files
dingtianhongdavem330
authored andcommitted
ipw2x00: slight optimization of addr compare
Use possibly more efficient ether_addr_equal instead of memcmp. Cc: Stanislav Yakovlev <[email protected]> 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 35df538 commit 36325f3

File tree

2 files changed

+22
-22
lines changed

2 files changed

+22
-22
lines changed

drivers/net/wireless/ipw2x00/ipw2200.c

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3012,7 +3012,7 @@ static void ipw_remove_current_network(struct ipw_priv *priv)
30123012
spin_lock_irqsave(&priv->ieee->lock, flags);
30133013
list_for_each_safe(element, safe, &priv->ieee->network_list) {
30143014
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)) {
30163016
list_del(element);
30173017
list_add_tail(&network->list,
30183018
&priv->ieee->network_free_list);
@@ -3921,7 +3921,7 @@ static u8 ipw_add_station(struct ipw_priv *priv, u8 * bssid)
39213921
int i;
39223922

39233923
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)) {
39253925
/* Another node is active in network */
39263926
priv->missed_adhoc_beacons = 0;
39273927
if (!(priv->config & CFG_STATIC_CHANNEL))
@@ -3953,7 +3953,7 @@ static u8 ipw_find_station(struct ipw_priv *priv, u8 * bssid)
39533953
int i;
39543954

39553955
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))
39573957
return i;
39583958

39593959
return IPW_INVALID_STATION;
@@ -5622,7 +5622,7 @@ static int ipw_find_adhoc_network(struct ipw_priv *priv,
56225622
return 0;
56235623
}
56245624

5625-
if (!memcmp(network->bssid, priv->bssid, ETH_ALEN)) {
5625+
if (ether_addr_equal(network->bssid, priv->bssid)) {
56265626
IPW_DEBUG_MERGE("Network '%s (%pM)' excluded "
56275627
"because of the same BSSID match: %pM"
56285628
".\n", print_ssid(ssid, network->ssid,
@@ -5849,7 +5849,7 @@ static int ipw_best_network(struct ipw_priv *priv,
58495849
}
58505850

58515851
if ((priv->config & CFG_STATIC_BSSID) &&
5852-
memcmp(network->bssid, priv->bssid, ETH_ALEN)) {
5852+
!ether_addr_equal(network->bssid, priv->bssid)) {
58535853
IPW_DEBUG_ASSOC("Network '%s (%pM)' excluded "
58545854
"because of BSSID mismatch: %pM.\n",
58555855
print_ssid(ssid, network->ssid,
@@ -6988,7 +6988,7 @@ static int ipw_qos_handle_probe_response(struct ipw_priv *priv,
69886988
}
69896989
if ((priv->status & STATUS_ASSOCIATED) &&
69906990
(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))
69926992
if (network->capability & WLAN_CAPABILITY_IBSS)
69936993
if ((network->ssid_len ==
69946994
priv->assoc_network->ssid_len) &&
@@ -8210,29 +8210,29 @@ static int is_network_packet(struct ipw_priv *priv,
82108210
switch (priv->ieee->iw_mode) {
82118211
case IW_MODE_ADHOC: /* Header: Dest. | Source | BSSID */
82128212
/* 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))
82148214
return 0;
82158215

82168216
/* {broad,multi}cast packets to our BSSID go through */
82178217
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);
82198219

82208220
/* packets to our adapter go through */
8221-
return !memcmp(header->addr1, priv->net_dev->dev_addr,
8222-
ETH_ALEN);
8221+
return ether_addr_equal(header->addr1,
8222+
priv->net_dev->dev_addr);
82238223

82248224
case IW_MODE_INFRA: /* Header: Dest. | BSSID | Source */
82258225
/* 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))
82278227
return 0;
82288228

82298229
/* {broad,multi}cast packets to our BSS go through */
82308230
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);
82328232

82338233
/* packets to our adapter go through */
8234-
return !memcmp(header->addr1, priv->net_dev->dev_addr,
8235-
ETH_ALEN);
8234+
return ether_addr_equal(header->addr1,
8235+
priv->net_dev->dev_addr);
82368236
}
82378237

82388238
return 1;
@@ -8260,7 +8260,7 @@ static int is_duplicate_packet(struct ipw_priv *priv,
82608260
list_for_each(p, &priv->ibss_mac_hash[index]) {
82618261
entry =
82628262
list_entry(p, struct ipw_ibss_seq, list);
8263-
if (!memcmp(entry->mac, mac, ETH_ALEN))
8263+
if (ether_addr_equal(entry->mac, mac))
82648264
break;
82658265
}
82668266
if (p == &priv->ibss_mac_hash[index]) {
@@ -8329,7 +8329,7 @@ static void ipw_handle_mgmt_packet(struct ipw_priv *priv,
83298329
IEEE80211_STYPE_PROBE_RESP) ||
83308330
(WLAN_FC_GET_STYPE(le16_to_cpu(header->frame_ctl)) ==
83318331
IEEE80211_STYPE_BEACON))) {
8332-
if (!memcmp(header->addr3, priv->bssid, ETH_ALEN))
8332+
if (ether_addr_equal(header->addr3, priv->bssid))
83338333
ipw_add_station(priv, header->addr2);
83348334
}
83358335

@@ -9045,7 +9045,7 @@ static int ipw_wx_set_wap(struct net_device *dev,
90459045
}
90469046

90479047
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)) {
90499049
IPW_DEBUG_WX("BSSID set to current BSSID.\n");
90509050
mutex_unlock(&priv->mutex);
90519051
return 0;

drivers/net/wireless/ipw2x00/libipw_rx.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -874,13 +874,13 @@ void libipw_rx_any(struct libipw_device *ieee,
874874
switch (ieee->iw_mode) {
875875
case IW_MODE_ADHOC:
876876
/* 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))
878878
if ((fc & (IEEE80211_FCTL_TODS+IEEE80211_FCTL_FROMDS)) == 0) {
879879
/* promisc: get all */
880880
if (ieee->dev->flags & IFF_PROMISC)
881881
is_packet_for_us = 1;
882882
/* 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))
884884
is_packet_for_us = 1;
885885
/* mcast */
886886
else if (is_multicast_ether_addr(hdr->addr1))
@@ -889,18 +889,18 @@ void libipw_rx_any(struct libipw_device *ieee,
889889
break;
890890
case IW_MODE_INFRA:
891891
/* 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))
893893
if ((fc & (IEEE80211_FCTL_TODS+IEEE80211_FCTL_FROMDS)) == IEEE80211_FCTL_FROMDS) {
894894
/* promisc: get all */
895895
if (ieee->dev->flags & IFF_PROMISC)
896896
is_packet_for_us = 1;
897897
/* 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))
899899
is_packet_for_us = 1;
900900
/* mcast */
901901
else if (is_multicast_ether_addr(hdr->addr1)) {
902902
/* 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))
904904
is_packet_for_us = 1;
905905
}
906906
}

0 commit comments

Comments
 (0)