All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrew Lunn <andrew@lunn.ch>
To: David Miller <davem@davemloft.net>
Cc: volodymyr.bendiuga@gmail.com,
	vivien.didelot@savoirfairelinux.com, f.fainelli@gmail.com,
	netdev@vger.kernel.org
Subject: Re: [PATCH repost net-next] dsa: mv88e6xxx: Optimise atu_get
Date: Wed, 4 Jan 2017 22:19:57 +0100	[thread overview]
Message-ID: <20170104211957.GD4229@lunn.ch> (raw)
In-Reply-To: <20170104.161103.175830630875484681.davem@davemloft.net>

On Wed, Jan 04, 2017 at 04:11:03PM -0500, David Miller wrote:
> From: Andrew Lunn <andrew@lunn.ch>
> Date: Wed,  4 Jan 2017 19:56:24 +0100
> 
> > +static inline u64 ether_addr_to_u64(const u8 *addr)
> > +{
> > +	u64 u = 0;
> > +	int i;
> > +
> > +	for (i = 0; i < ETH_ALEN; i++)
> > +		u = u << 8 | addr[i];
> > +
> > +	return u;
> > +}
>  ...
> > +static inline void u64_to_ether_addr(u64 u, u8 *addr)
> > +{
> > +	int i;
> > +
> > +	for (i = ETH_ALEN - 1; i >= 0; i--) {
> > +		addr[i] = u & 0xff;
> > +		u = u >> 8;
> > +	}
> > +}
> 
> I think these two routines behave differently on big vs little
> endian.  And I doubt this was your intention.

I don't have a big endian system to test on.

I tried to avoid the usual pitfalls. I don't cast a collection of
bytes to a u64, which i know has no chance of working. Accessing a MAC
address as a byte array should be endian safe. The shift operation
should also be endian safe.

What exactly do you think will behave differently?

     Andrew

  reply	other threads:[~2017-01-04 21:20 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-04 18:56 [PATCH repost net-next] dsa: mv88e6xxx: Optimise atu_get Andrew Lunn
2017-01-04 21:11 ` David Miller
2017-01-04 21:19   ` Andrew Lunn [this message]
2017-01-04 21:27     ` Florian Fainelli
2017-01-04 21:27     ` David Miller
2017-01-04 21:45       ` Andrew Lunn

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170104211957.GD4229@lunn.ch \
    --to=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=f.fainelli@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=vivien.didelot@savoirfairelinux.com \
    --cc=volodymyr.bendiuga@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.