Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 7 Aug 2016 11:03:23 +0200
From:      Hans Petter Selasky <hps@selasky.org>
To:        Adrian Chadd <adrian@FreeBSD.org>, src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   Re: svn commit: r303811 - in head/sys: net net80211
Message-ID:  <46183559-343f-401b-6471-3822e3383a50@selasky.org>
In-Reply-To: <201608070348.u773mXXt030939@repo.freebsd.org>
References:  <201608070348.u773mXXt030939@repo.freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On 08/07/16 05:48, Adrian Chadd wrote:
> Author: adrian
> Date: Sun Aug  7 03:48:33 2016
> New Revision: 303811
> URL: https://svnweb.freebsd.org/changeset/base/303811
>
> Log:
>   Extract out the various local definitions of ETHER_IS_BROADCAST() and
>   turn them into a shared definition.
>
>   Set M_MCAST/M_BCAST appropriately upon packet reception in net80211, just
>   before they are delivered up to the ethernet stack.
>
>   Submitted by:	rstone
>
> Modified:
>   head/sys/net/ethernet.h
>   head/sys/net/if_ethersubr.c
>   head/sys/net/if_gif.c
>   head/sys/net80211/ieee80211_input.c
>
> Modified: head/sys/net/ethernet.h
> ==============================================================================
> --- head/sys/net/ethernet.h	Sun Aug  7 01:32:37 2016	(r303810)
> +++ head/sys/net/ethernet.h	Sun Aug  7 03:48:33 2016	(r303811)
> @@ -71,6 +71,9 @@ struct ether_addr {
>  } __packed;
>
>  #define	ETHER_IS_MULTICAST(addr) (*(addr) & 0x01) /* is address mcast/bcast? */
> +#define	ETHER_IS_BROADCAST(addr) \
> +	(((addr)[0] & (addr)[1] & (addr)[2] & \
> +	  (addr)[3] & (addr)[4] & (addr)[5]) == 0xff)
>

Hi,

The compiler might be able to produce more optimal code if you use "+" 
instead of "&", because there are instructions on x86, that can add 
multiple variables at the same time. With "&" you need to process every 
one as a single instructions usually I think.

 > +#define	ETHER_IS_BROADCAST(addr) \
 > +	(((addr)[0] + (addr)[1] + (addr)[2] + \
 > +	  (addr)[3] + (addr)[4] + (addr)[5]) == (6*0xff))

--HPS



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?46183559-343f-401b-6471-3822e3383a50>