svn commit: r303811 - in head/sys: net net80211

Hans Petter Selasky hps at selasky.org
Sun Aug 7 08:59:03 UTC 2016


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


More information about the svn-src-head mailing list