net: bnx2x: slight optimization of addr compare
authordingtianhong <dingtianhong@huawei.com>
Mon, 30 Dec 2013 07:40:32 +0000 (15:40 +0800)
committerDavid S. Miller <davem@davemloft.net>
Tue, 31 Dec 2013 21:48:30 +0000 (16:48 -0500)
Use the possibly more efficient ether_addr_equal or
ether_addr_equal_unaligned to instead of memcmp.

Cc: Ariel Elior <ariele@broadcom.com>
Cc: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
Signed-off-by: Ding Tianhong <dingtianhong@huawei.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c
drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.c
drivers/net/ethernet/broadcom/bnx2x/bnx2x_vfpf.c

index 32c92abf50949fa1494812ab9d3734a5a2f3db1f..babf7b954ae66c960638bac9f9ac1f0f4c3958dd 100644 (file)
@@ -663,7 +663,7 @@ static int bnx2x_check_mac_add(struct bnx2x *bp,
 
        /* Check if a requested MAC already exists */
        list_for_each_entry(pos, &o->head, link)
-               if (!memcmp(data->mac.mac, pos->u.mac.mac, ETH_ALEN) &&
+               if (ether_addr_equal(data->mac.mac, pos->u.mac.mac) &&
                    (data->mac.is_inner_mac == pos->u.mac.is_inner_mac))
                        return -EEXIST;
 
@@ -696,8 +696,7 @@ static int bnx2x_check_vlan_mac_add(struct bnx2x *bp,
 
        list_for_each_entry(pos, &o->head, link)
                if ((data->vlan_mac.vlan == pos->u.vlan_mac.vlan) &&
-                   (!memcmp(data->vlan_mac.mac, pos->u.vlan_mac.mac,
-                                 ETH_ALEN)) &&
+                   ether_addr_equal_unaligned(data->vlan_mac.mac, pos->u.vlan_mac.mac) &&
                    (data->vlan_mac.is_inner_mac ==
                     pos->u.vlan_mac.is_inner_mac))
                        return -EEXIST;
@@ -716,7 +715,7 @@ static struct bnx2x_vlan_mac_registry_elem *
        DP(BNX2X_MSG_SP, "Checking MAC %pM for DEL command\n", data->mac.mac);
 
        list_for_each_entry(pos, &o->head, link)
-               if ((!memcmp(data->mac.mac, pos->u.mac.mac, ETH_ALEN)) &&
+               if (ether_addr_equal(data->mac.mac, pos->u.mac.mac) &&
                    (data->mac.is_inner_mac == pos->u.mac.is_inner_mac))
                        return pos;
 
@@ -751,8 +750,7 @@ static struct bnx2x_vlan_mac_registry_elem *
 
        list_for_each_entry(pos, &o->head, link)
                if ((data->vlan_mac.vlan == pos->u.vlan_mac.vlan) &&
-                   (!memcmp(data->vlan_mac.mac, pos->u.vlan_mac.mac,
-                            ETH_ALEN)) &&
+                   ether_addr_equal_unaligned(data->vlan_mac.mac, pos->u.vlan_mac.mac) &&
                    (data->vlan_mac.is_inner_mac ==
                     pos->u.vlan_mac.is_inner_mac))
                        return pos;
index 25182765e4be5d3a2c556f9212e2fde5c79b9693..6fe52d301dfe85abf6bb2f6f2837f3af17580e18 100644 (file)
@@ -3616,7 +3616,7 @@ enum sample_bulletin_result bnx2x_sample_bulletin(struct bnx2x *bp)
 
        /* the mac address in bulletin board is valid and is new */
        if (bulletin.valid_bitmap & 1 << MAC_ADDR_VALID &&
-           memcmp(bulletin.mac, bp->old_bulletin.mac, ETH_ALEN)) {
+           !ether_addr_equal(bulletin.mac, bp->old_bulletin.mac)) {
                /* update new mac to net device */
                memcpy(bp->dev->dev_addr, bulletin.mac, ETH_ALEN);
        }
index 30c7f249203cce4cd69bf2078624f431318dc40f..e5f7985a372c5e83dbcc517c2d099f3cca1558b2 100644 (file)
@@ -1714,7 +1714,7 @@ static void bnx2x_vf_mbx_set_q_filters(struct bnx2x *bp,
 
                /* ...and only the mac set by the ndo */
                if (filters->n_mac_vlan_filters == 1 &&
-                   memcmp(filters->filters->mac, bulletin->mac, ETH_ALEN)) {
+                   !ether_addr_equal(filters->filters->mac, bulletin->mac)) {
                        BNX2X_ERR("VF[%d] requested the addition of a mac address not matching the one configured by set_vf_mac ndo\n",
                                  vf->abs_vfid);