diff options
author | dingtianhong <dingtianhong@huawei.com> | 2013-12-30 02:40:32 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2013-12-31 16:48:30 -0500 |
commit | 8fd90de800a838320406c29587d40fb8167ec48e (patch) | |
tree | 053b57bba06fdf5ed3394dc1009e3967e0450125 /drivers/net/ethernet | |
parent | c466a9b2b329f7d9982c14eedc83a923d3bc711c (diff) |
net: bnx2x: slight optimization of addr compare
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>
Diffstat (limited to 'drivers/net/ethernet')
-rw-r--r-- | drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c | 10 | ||||
-rw-r--r-- | drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.c | 2 | ||||
-rw-r--r-- | drivers/net/ethernet/broadcom/bnx2x/bnx2x_vfpf.c | 2 |
3 files changed, 6 insertions, 8 deletions
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c index 32c92abf5094..babf7b954ae6 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c | |||
@@ -663,7 +663,7 @@ static int bnx2x_check_mac_add(struct bnx2x *bp, | |||
663 | 663 | ||
664 | /* Check if a requested MAC already exists */ | 664 | /* Check if a requested MAC already exists */ |
665 | list_for_each_entry(pos, &o->head, link) | 665 | list_for_each_entry(pos, &o->head, link) |
666 | if (!memcmp(data->mac.mac, pos->u.mac.mac, ETH_ALEN) && | 666 | if (ether_addr_equal(data->mac.mac, pos->u.mac.mac) && |
667 | (data->mac.is_inner_mac == pos->u.mac.is_inner_mac)) | 667 | (data->mac.is_inner_mac == pos->u.mac.is_inner_mac)) |
668 | return -EEXIST; | 668 | return -EEXIST; |
669 | 669 | ||
@@ -696,8 +696,7 @@ static int bnx2x_check_vlan_mac_add(struct bnx2x *bp, | |||
696 | 696 | ||
697 | list_for_each_entry(pos, &o->head, link) | 697 | list_for_each_entry(pos, &o->head, link) |
698 | if ((data->vlan_mac.vlan == pos->u.vlan_mac.vlan) && | 698 | if ((data->vlan_mac.vlan == pos->u.vlan_mac.vlan) && |
699 | (!memcmp(data->vlan_mac.mac, pos->u.vlan_mac.mac, | 699 | ether_addr_equal_unaligned(data->vlan_mac.mac, pos->u.vlan_mac.mac) && |
700 | ETH_ALEN)) && | ||
701 | (data->vlan_mac.is_inner_mac == | 700 | (data->vlan_mac.is_inner_mac == |
702 | pos->u.vlan_mac.is_inner_mac)) | 701 | pos->u.vlan_mac.is_inner_mac)) |
703 | return -EEXIST; | 702 | return -EEXIST; |
@@ -716,7 +715,7 @@ static struct bnx2x_vlan_mac_registry_elem * | |||
716 | DP(BNX2X_MSG_SP, "Checking MAC %pM for DEL command\n", data->mac.mac); | 715 | DP(BNX2X_MSG_SP, "Checking MAC %pM for DEL command\n", data->mac.mac); |
717 | 716 | ||
718 | list_for_each_entry(pos, &o->head, link) | 717 | list_for_each_entry(pos, &o->head, link) |
719 | if ((!memcmp(data->mac.mac, pos->u.mac.mac, ETH_ALEN)) && | 718 | if (ether_addr_equal(data->mac.mac, pos->u.mac.mac) && |
720 | (data->mac.is_inner_mac == pos->u.mac.is_inner_mac)) | 719 | (data->mac.is_inner_mac == pos->u.mac.is_inner_mac)) |
721 | return pos; | 720 | return pos; |
722 | 721 | ||
@@ -751,8 +750,7 @@ static struct bnx2x_vlan_mac_registry_elem * | |||
751 | 750 | ||
752 | list_for_each_entry(pos, &o->head, link) | 751 | list_for_each_entry(pos, &o->head, link) |
753 | if ((data->vlan_mac.vlan == pos->u.vlan_mac.vlan) && | 752 | if ((data->vlan_mac.vlan == pos->u.vlan_mac.vlan) && |
754 | (!memcmp(data->vlan_mac.mac, pos->u.vlan_mac.mac, | 753 | ether_addr_equal_unaligned(data->vlan_mac.mac, pos->u.vlan_mac.mac) && |
755 | ETH_ALEN)) && | ||
756 | (data->vlan_mac.is_inner_mac == | 754 | (data->vlan_mac.is_inner_mac == |
757 | pos->u.vlan_mac.is_inner_mac)) | 755 | pos->u.vlan_mac.is_inner_mac)) |
758 | return pos; | 756 | return pos; |
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.c index 25182765e4be..6fe52d301dfe 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.c +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.c | |||
@@ -3616,7 +3616,7 @@ enum sample_bulletin_result bnx2x_sample_bulletin(struct bnx2x *bp) | |||
3616 | 3616 | ||
3617 | /* the mac address in bulletin board is valid and is new */ | 3617 | /* the mac address in bulletin board is valid and is new */ |
3618 | if (bulletin.valid_bitmap & 1 << MAC_ADDR_VALID && | 3618 | if (bulletin.valid_bitmap & 1 << MAC_ADDR_VALID && |
3619 | memcmp(bulletin.mac, bp->old_bulletin.mac, ETH_ALEN)) { | 3619 | !ether_addr_equal(bulletin.mac, bp->old_bulletin.mac)) { |
3620 | /* update new mac to net device */ | 3620 | /* update new mac to net device */ |
3621 | memcpy(bp->dev->dev_addr, bulletin.mac, ETH_ALEN); | 3621 | memcpy(bp->dev->dev_addr, bulletin.mac, ETH_ALEN); |
3622 | } | 3622 | } |
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_vfpf.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_vfpf.c index 30c7f249203c..e5f7985a372c 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_vfpf.c +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_vfpf.c | |||
@@ -1714,7 +1714,7 @@ static void bnx2x_vf_mbx_set_q_filters(struct bnx2x *bp, | |||
1714 | 1714 | ||
1715 | /* ...and only the mac set by the ndo */ | 1715 | /* ...and only the mac set by the ndo */ |
1716 | if (filters->n_mac_vlan_filters == 1 && | 1716 | if (filters->n_mac_vlan_filters == 1 && |
1717 | memcmp(filters->filters->mac, bulletin->mac, ETH_ALEN)) { | 1717 | !ether_addr_equal(filters->filters->mac, bulletin->mac)) { |
1718 | BNX2X_ERR("VF[%d] requested the addition of a mac address not matching the one configured by set_vf_mac ndo\n", | 1718 | BNX2X_ERR("VF[%d] requested the addition of a mac address not matching the one configured by set_vf_mac ndo\n", |
1719 | vf->abs_vfid); | 1719 | vf->abs_vfid); |
1720 | 1720 | ||