aboutsummaryrefslogtreecommitdiffstats
path: root/net/ethernet/eth.c
diff options
context:
space:
mode:
authorStephen Hemminger <shemminger@linux-foundation.org>2007-08-25 01:35:44 -0400
committerDavid S. Miller <davem@sunset.davemloft.net>2007-10-10 19:48:26 -0400
commit23f1f4eff85d3d2ec9ed589e3fdcbba59eaa083e (patch)
tree4d095b4f0034af776172bcdbe3e283abd4dd5518 /net/ethernet/eth.c
parentfd21150a0fe10c504160db359a4eb425576f6e7d (diff)
[NET] ethernet: optimize memcpy and memset
The ethernet header management only needs to handle a fixed size address (6 bytes). If the memcpy/memset are changed to be passed a constant length, then compiler can optimize for this case (and if it is smart eliminate string instructions). Signed-off-by: Stephen Hemminger <shemminger@linux-foundation.org> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ethernet/eth.c')
-rw-r--r--net/ethernet/eth.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/net/ethernet/eth.c b/net/ethernet/eth.c
index 12c765715acf..57c592ed0105 100644
--- a/net/ethernet/eth.c
+++ b/net/ethernet/eth.c
@@ -91,10 +91,10 @@ int eth_header(struct sk_buff *skb, struct net_device *dev, unsigned short type,
91 91
92 if (!saddr) 92 if (!saddr)
93 saddr = dev->dev_addr; 93 saddr = dev->dev_addr;
94 memcpy(eth->h_source, saddr, dev->addr_len); 94 memcpy(eth->h_source, saddr, ETH_ALEN);
95 95
96 if (daddr) { 96 if (daddr) {
97 memcpy(eth->h_dest, daddr, dev->addr_len); 97 memcpy(eth->h_dest, daddr, ETH_ALEN);
98 return ETH_HLEN; 98 return ETH_HLEN;
99 } 99 }
100 100
@@ -103,7 +103,7 @@ int eth_header(struct sk_buff *skb, struct net_device *dev, unsigned short type,
103 */ 103 */
104 104
105 if (dev->flags & (IFF_LOOPBACK | IFF_NOARP)) { 105 if (dev->flags & (IFF_LOOPBACK | IFF_NOARP)) {
106 memset(eth->h_dest, 0, dev->addr_len); 106 memset(eth->h_dest, 0, ETH_ALEN);
107 return ETH_HLEN; 107 return ETH_HLEN;
108 } 108 }
109 109
@@ -135,7 +135,7 @@ int eth_rebuild_header(struct sk_buff *skb)
135 "%s: unable to resolve type %X addresses.\n", 135 "%s: unable to resolve type %X addresses.\n",
136 dev->name, (int)eth->h_proto); 136 dev->name, (int)eth->h_proto);
137 137
138 memcpy(eth->h_source, dev->dev_addr, dev->addr_len); 138 memcpy(eth->h_source, dev->dev_addr, ETH_ALEN);
139 break; 139 break;
140 } 140 }
141 141
@@ -233,8 +233,8 @@ int eth_header_cache(struct neighbour *neigh, struct hh_cache *hh)
233 return -1; 233 return -1;
234 234
235 eth->h_proto = type; 235 eth->h_proto = type;
236 memcpy(eth->h_source, dev->dev_addr, dev->addr_len); 236 memcpy(eth->h_source, dev->dev_addr, ETH_ALEN);
237 memcpy(eth->h_dest, neigh->ha, dev->addr_len); 237 memcpy(eth->h_dest, neigh->ha, ETH_ALEN);
238 hh->hh_len = ETH_HLEN; 238 hh->hh_len = ETH_HLEN;
239 return 0; 239 return 0;
240} 240}
@@ -251,7 +251,7 @@ void eth_header_cache_update(struct hh_cache *hh, struct net_device *dev,
251 unsigned char *haddr) 251 unsigned char *haddr)
252{ 252{
253 memcpy(((u8 *) hh->hh_data) + HH_DATA_OFF(sizeof(struct ethhdr)), 253 memcpy(((u8 *) hh->hh_data) + HH_DATA_OFF(sizeof(struct ethhdr)),
254 haddr, dev->addr_len); 254 haddr, ETH_ALEN);
255} 255}
256 256
257/** 257/**
@@ -271,7 +271,7 @@ static int eth_mac_addr(struct net_device *dev, void *p)
271 return -EBUSY; 271 return -EBUSY;
272 if (!is_valid_ether_addr(addr->sa_data)) 272 if (!is_valid_ether_addr(addr->sa_data))
273 return -EADDRNOTAVAIL; 273 return -EADDRNOTAVAIL;
274 memcpy(dev->dev_addr, addr->sa_data, dev->addr_len); 274 memcpy(dev->dev_addr, addr->sa_data, ETH_ALEN);
275 return 0; 275 return 0;
276} 276}
277 277