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

Commit cd84ff4d authored by Edward Cree's avatar Edward Cree Committed by David S. Miller
Browse files

sfc: Use ether_addr_copy and eth_broadcast_addr



Faster than memcpy/memset on some architectures.

Signed-off-by: default avatarEdward Cree <ecree@solarflare.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 19433646
Loading
Loading
Loading
Loading
+5 −8
Original line number Diff line number Diff line
@@ -162,8 +162,8 @@ static int efx_ef10_get_mac_address(struct efx_nic *efx, u8 *mac_address)
	if (outlen < MC_CMD_GET_MAC_ADDRESSES_OUT_LEN)
		return -EIO;

	memcpy(mac_address,
	       MCDI_PTR(outbuf, GET_MAC_ADDRESSES_OUT_MAC_ADDR_BASE), ETH_ALEN);
	ether_addr_copy(mac_address,
			MCDI_PTR(outbuf, GET_MAC_ADDRESSES_OUT_MAC_ADDR_BASE));
	return 0;
}

@@ -3145,12 +3145,10 @@ static void efx_ef10_filter_sync_rx_mode(struct efx_nic *efx)
		table->dev_uc_count = -1;
	} else {
		table->dev_uc_count = 1 + netdev_uc_count(net_dev);
		memcpy(table->dev_uc_list[0].addr, net_dev->dev_addr,
		       ETH_ALEN);
		ether_addr_copy(table->dev_uc_list[0].addr, net_dev->dev_addr);
		i = 1;
		netdev_for_each_uc_addr(uc, net_dev) {
			memcpy(table->dev_uc_list[i].addr,
			       uc->addr, ETH_ALEN);
			ether_addr_copy(table->dev_uc_list[i].addr, uc->addr);
			i++;
		}
	}
@@ -3162,8 +3160,7 @@ static void efx_ef10_filter_sync_rx_mode(struct efx_nic *efx)
		eth_broadcast_addr(table->dev_mc_list[0].addr);
		i = 1;
		netdev_for_each_mc_addr(mc, net_dev) {
			memcpy(table->dev_mc_list[i].addr,
			       mc->addr, ETH_ALEN);
			ether_addr_copy(table->dev_mc_list[i].addr, mc->addr);
			i++;
		}
	}
+2 −2
Original line number Diff line number Diff line
@@ -1012,7 +1012,7 @@ static int efx_probe_port(struct efx_nic *efx)
		return rc;

	/* Initialise MAC address to permanent address */
	memcpy(efx->net_dev->dev_addr, efx->net_dev->perm_addr, ETH_ALEN);
	ether_addr_copy(efx->net_dev->dev_addr, efx->net_dev->perm_addr);

	return 0;
}
@@ -2120,7 +2120,7 @@ static int efx_set_mac_address(struct net_device *net_dev, void *data)
		return -EADDRNOTAVAIL;
	}

	memcpy(net_dev->dev_addr, new_addr, net_dev->addr_len);
	ether_addr_copy(net_dev->dev_addr, new_addr);
	efx_sriov_mac_address_changed(efx);

	/* Reconfigure the MAC */
+9 −9
Original line number Diff line number Diff line
@@ -727,7 +727,7 @@ static int efx_ethtool_reset(struct net_device *net_dev, u32 *flags)
}

/* MAC address mask including only I/G bit */
static const u8 mac_addr_ig_mask[ETH_ALEN] = { 0x01, 0, 0, 0, 0, 0 };
static const u8 mac_addr_ig_mask[ETH_ALEN] __aligned(2) = {0x01, 0, 0, 0, 0, 0};

#define IP4_ADDR_FULL_MASK	((__force __be32)~0)
#define PORT_FULL_MASK		((__force __be16)~0)
@@ -787,16 +787,16 @@ static int efx_ethtool_get_class_rule(struct efx_nic *efx,
		rule->flow_type = ETHER_FLOW;
		if (spec.match_flags &
		    (EFX_FILTER_MATCH_LOC_MAC | EFX_FILTER_MATCH_LOC_MAC_IG)) {
			memcpy(mac_entry->h_dest, spec.loc_mac, ETH_ALEN);
			ether_addr_copy(mac_entry->h_dest, spec.loc_mac);
			if (spec.match_flags & EFX_FILTER_MATCH_LOC_MAC)
				memset(mac_mask->h_dest, ~0, ETH_ALEN);
				eth_broadcast_addr(mac_mask->h_dest);
			else
				memcpy(mac_mask->h_dest, mac_addr_ig_mask,
				       ETH_ALEN);
				ether_addr_copy(mac_mask->h_dest,
						mac_addr_ig_mask);
		}
		if (spec.match_flags & EFX_FILTER_MATCH_REM_MAC) {
			memcpy(mac_entry->h_source, spec.rem_mac, ETH_ALEN);
			memset(mac_mask->h_source, ~0, ETH_ALEN);
			ether_addr_copy(mac_entry->h_source, spec.rem_mac);
			eth_broadcast_addr(mac_mask->h_source);
		}
		if (spec.match_flags & EFX_FILTER_MATCH_ETHER_TYPE) {
			mac_entry->h_proto = spec.ether_type;
@@ -968,13 +968,13 @@ static int efx_ethtool_set_class_rule(struct efx_nic *efx,
				spec.match_flags |= EFX_FILTER_MATCH_LOC_MAC;
			else
				return -EINVAL;
			memcpy(spec.loc_mac, mac_entry->h_dest, ETH_ALEN);
			ether_addr_copy(spec.loc_mac, mac_entry->h_dest);
		}
		if (!is_zero_ether_addr(mac_mask->h_source)) {
			if (!is_broadcast_ether_addr(mac_mask->h_source))
				return -EINVAL;
			spec.match_flags |= EFX_FILTER_MATCH_REM_MAC;
			memcpy(spec.rem_mac, mac_entry->h_source, ETH_ALEN);
			ether_addr_copy(spec.rem_mac, mac_entry->h_source);
		}
		if (mac_mask->h_proto) {
			if (mac_mask->h_proto != ETHER_TYPE_FULL_MASK)
+1 −1
Original line number Diff line number Diff line
@@ -2183,7 +2183,7 @@ static int falcon_probe_nvconfig(struct efx_nic *efx)
	}

	/* Read the MAC addresses */
	memcpy(efx->net_dev->perm_addr, nvconfig->mac_address[0], ETH_ALEN);
	ether_addr_copy(efx->net_dev->perm_addr, nvconfig->mac_address[0]);

	netif_dbg(efx, probe, efx->net_dev, "PHY is %d phy_id %d\n",
		  efx->phy_type, efx->mdio.prtad);
+1 −1
Original line number Diff line number Diff line
@@ -243,7 +243,7 @@ static inline int efx_filter_set_eth_local(struct efx_filter_spec *spec,
	}
	if (addr != NULL) {
		spec->match_flags |= EFX_FILTER_MATCH_LOC_MAC;
		memcpy(spec->loc_mac, addr, ETH_ALEN);
		ether_addr_copy(spec->loc_mac, addr);
	}
	return 0;
}
Loading