Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 539c89cf authored by David S. Miller's avatar David S. Miller
Browse files

Merge branch 'addr_compare'



Ding Tianhong says:

====================
slight optimization of addr compare for some modules

Joe Perches add ether_addr_equal_unaligned to test if
possibly unaligned to u16 Ethernet addresses are equal.

If CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS is set, this uses
the slightly faster generic routine ether_addr_equal,
otherwise this uses memcmp.

So I use the recently added and possibly more efficient
ether_addr_equal_unaligned to instead of memcmp for slight
optimization.

v2: Because a lot of places are already using 16b aligned MAC
    address for both operands, so use the ether_addr_equal to
    instead of ether_addr_equal_unaligned.Thanks for Joe, Alex
    and Antonio's opinions.
    Also remove the patch for bridge.

v3: According Joe's suggestion, the patch
    (net: slight optimization of addr compare for some modules)
    should be broken into several patches, and it will be good
    to review for maintainers. So I will send rest of the patches
    for first step, and next step, I will seperate the netdev patch
    and send them by another patchset for net-next.
    also fix some changelog.

v3.5 Change some style for patch 8 and patch 13. Thanks for
     Sergei's suggestion.
====================

Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents 306d7f79 692e5167
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -52,6 +52,7 @@
#include <asm/io.h>
#include <asm/uaccess.h>
#include <linux/atomic.h>
#include <linux/etherdevice.h>
#include "nicstar.h"
#ifdef CONFIG_ATM_NICSTAR_USE_SUNI
#include "suni.h"
@@ -781,8 +782,7 @@ static int ns_init_card(int i, struct pci_dev *pcidev)
	if (mac[i] == NULL || !mac_pton(mac[i], card->atmdev->esi)) {
		nicstar_read_eprom(card->membase, NICSTAR_EPROM_MAC_ADDR_OFFSET,
				   card->atmdev->esi, 6);
		if (memcmp(card->atmdev->esi, "\x00\x00\x00\x00\x00\x00", 6) ==
		    0) {
		if (ether_addr_equal(card->atmdev->esi, "\x00\x00\x00\x00\x00\x00")) {
			nicstar_read_eprom(card->membase,
					   NICSTAR_EPROM_MAC_ADDR_OFFSET_ALT,
					   card->atmdev->esi, 6);
+1 −2
Original line number Diff line number Diff line
@@ -1354,8 +1354,7 @@ static int nes_addr_resolve_neigh(struct nes_vnic *nesvnic, u32 dst_ip, int arpi
				  neigh->ha, ntohl(rt->rt_gateway));

			if (arpindex >= 0) {
				if (!memcmp(nesadapter->arp_table[arpindex].mac_addr,
					    neigh->ha, ETH_ALEN)) {
				if (ether_addr_equal(nesadapter->arp_table[arpindex].mac_addr, neigh->ha)) {
					/* Mac address same as in nes_arp_table */
					goto out;
				}
+2 −2
Original line number Diff line number Diff line
@@ -1371,7 +1371,7 @@ isdn_net_type_trans(struct sk_buff *skb, struct net_device *dev)
	eth = eth_hdr(skb);

	if (*eth->h_dest & 1) {
		if (memcmp(eth->h_dest, dev->broadcast, ETH_ALEN) == 0)
		if (ether_addr_equal(eth->h_dest, dev->broadcast))
			skb->pkt_type = PACKET_BROADCAST;
		else
			skb->pkt_type = PACKET_MULTICAST;
@@ -1382,7 +1382,7 @@ isdn_net_type_trans(struct sk_buff *skb, struct net_device *dev)
	 */

	else if (dev->flags & (IFF_PROMISC /*| IFF_ALLMULTI*/)) {
		if (memcmp(eth->h_dest, dev->dev_addr, ETH_ALEN))
		if (!ether_addr_equal(eth->h_dest, dev->dev_addr))
			skb->pkt_type = PACKET_OTHERHOST;
	}
	if (ntohs(eth->h_proto) >= ETH_P_802_3_MIN)
+6 −4
Original line number Diff line number Diff line
@@ -179,7 +179,7 @@ static __be16 dvb_net_eth_type_trans(struct sk_buff *skb,
	eth = eth_hdr(skb);

	if (*eth->h_dest & 1) {
		if(memcmp(eth->h_dest,dev->broadcast, ETH_ALEN)==0)
		if(ether_addr_equal(eth->h_dest,dev->broadcast))
			skb->pkt_type=PACKET_BROADCAST;
		else
			skb->pkt_type=PACKET_MULTICAST;
@@ -674,11 +674,13 @@ static void dvb_net_ule( struct net_device *dev, const u8 *buf, size_t buf_len )
					if (priv->rx_mode != RX_MODE_PROMISC) {
						if (priv->ule_skb->data[0] & 0x01) {
							/* multicast or broadcast */
							if (memcmp(priv->ule_skb->data, bc_addr, ETH_ALEN)) {
							if (!ether_addr_equal(priv->ule_skb->data, bc_addr)) {
								/* multicast */
								if (priv->rx_mode == RX_MODE_MULTI) {
									int i;
									for(i = 0; i < priv->multi_num && memcmp(priv->ule_skb->data, priv->multi_macs[i], ETH_ALEN); i++)
									for(i = 0; i < priv->multi_num &&
									    !ether_addr_equal(priv->ule_skb->data,
											      priv->multi_macs[i]); i++)
										;
									if (i == priv->multi_num)
										drop = 1;
@@ -688,7 +690,7 @@ static void dvb_net_ule( struct net_device *dev, const u8 *buf, size_t buf_len )
							}
							/* else: broadcast */
						}
						else if (memcmp(priv->ule_skb->data, dev->dev_addr, ETH_ALEN))
						else if (!ether_addr_equal(priv->ule_skb->data, dev->dev_addr))
							drop = 1;
						/* else: destination address matches the MAC address of our receiver device */
					}
+1 −1
Original line number Diff line number Diff line
@@ -1668,7 +1668,7 @@ pcnet32_probe1(unsigned long ioaddr, int shared, struct pci_dev *pdev)
	for (i = 0; i < ETH_ALEN; i++)
		promaddr[i] = inb(ioaddr + i);

	if (memcmp(promaddr, dev->dev_addr, ETH_ALEN) ||
	if (!ether_addr_equal(promaddr, dev->dev_addr) ||
	    !is_valid_ether_addr(dev->dev_addr)) {
		if (is_valid_ether_addr(promaddr)) {
			if (pcnet32_debug & NETIF_MSG_PROBE) {
Loading