Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 21 Aug 2012 09:43:08 -0400
From:      John Baldwin <jhb@freebsd.org>
To:        freebsd-hackers@freebsd.org
Cc:        freebsd-net@freebsd.org, Mitya <mitya@cabletv.dp.ua>
Subject:   Re: Replace bcopy() to update ether_addr
Message-ID:  <201208210943.08341.jhb@freebsd.org>
In-Reply-To: <50324DB4.6080905@cabletv.dp.ua>
References:  <50324DB4.6080905@cabletv.dp.ua>

next in thread | previous in thread | raw e-mail | index | archive | help
On Monday, August 20, 2012 10:46:12 am Mitya wrote:
> Hi.
> I found some overhead code in /src/sys/net/if_ethersubr.c and 
> /src/sys/netgraph/ng_ether.c
> 
> It contains strings, like bcopy(src, dst, ETHER_ADDR_LEN);
> When src and dst are "struct ether_addr*", and ETHER_ADDR_LEN equal 6.
> This code call every time, when we send Ethernet packet.
> On example, on my machine in invoked nearly 20K per second.
> 
> Why we are use bcopy(), to copy only 6 bytes?
> Answer - in some architectures we are can not directly copy unaligned data.
> 
> I propose this solution.
> 
> In file /usr/src/include/net/ethernet.h add this lines:
> 
> static inline void ether_addr_copy(ether_addr* src, ether_addr* dst) {
> #if defined(__i386__) || defined(__amd64__)
>      *dst = *src;
> #else
>      bcopy(src, dst, ETHER_ADDR_LEN);
> #endif
> }

Doesn't '*dst = *src' just work on all platforms?

-- 
John Baldwin



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201208210943.08341.jhb>