From owner-freebsd-hackers@FreeBSD.ORG Tue Aug 21 14:52:56 2012 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E9DEB1065676; Tue, 21 Aug 2012 14:52:56 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from bigwig.baldwin.cx (bigknife-pt.tunnel.tserv9.chi1.ipv6.he.net [IPv6:2001:470:1f10:75::2]) by mx1.freebsd.org (Postfix) with ESMTP id C00D58FC0A; Tue, 21 Aug 2012 14:52:56 +0000 (UTC) Received: from jhbbsd.localnet (unknown [209.249.190.124]) by bigwig.baldwin.cx (Postfix) with ESMTPSA id 3D4B9B96C; Tue, 21 Aug 2012 10:52:56 -0400 (EDT) From: John Baldwin To: freebsd-hackers@freebsd.org Date: Tue, 21 Aug 2012 09:43:08 -0400 User-Agent: KMail/1.13.5 (FreeBSD/8.2-CBSD-20110714-p17; KDE/4.5.5; amd64; ; ) References: <50324DB4.6080905@cabletv.dp.ua> In-Reply-To: <50324DB4.6080905@cabletv.dp.ua> MIME-Version: 1.0 Content-Type: Text/Plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <201208210943.08341.jhb@freebsd.org> X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.2.7 (bigwig.baldwin.cx); Tue, 21 Aug 2012 10:52:56 -0400 (EDT) Cc: freebsd-net@freebsd.org, Mitya Subject: Re: Replace bcopy() to update ether_addr X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 21 Aug 2012 14:52:57 -0000 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