From: Benjamin Herrenschmidt <benh@kernel.crashing.org>
To: Joe Perches <joe@perches.com>
Cc: netdev@vger.kernel.org, Dinar Valeev <dvaleev@suse.com>,
linuxppc-dev@lists.ozlabs.org, Alexander Graf <agraf@suse.de>,
Anton Blanchard <anton@samba.org>,
Santiago Leon <santil@linux.vnet.ibm.com>
Subject: Re: [PATCH] ibmveth: Fix more little endian issues
Date: Tue, 24 Dec 2013 15:37:01 +1100 [thread overview]
Message-ID: <1387859821.4373.10.camel@pasglop> (raw)
In-Reply-To: <1387810329.22671.66.camel@joe-AO722>
On Mon, 2013-12-23 at 06:52 -0800, Joe Perches wrote:
> On Mon, 2013-12-23 at 17:38 +1100, Anton Blanchard wrote:
> > The hypervisor expects MAC addresses passed in registers to be big
> > endian u64.
>
> So maybe use __be64 declarations?
>
> > +static unsigned long ibmveth_encode_mac_addr(char *mac)
>
> static __be64 ibmveth_encode_mac_addr(const char *mac)
A register value has no endianness. Only memory content does. Especially
talking of a MAC address which is really a byte stream.... (Yes, our
__beXX types used without a * are borderline, but we've got used to it).
In fact I find the use of
memcpy(((char *)&encoded) + 2, mac, ETH_ALEN);
Really gross :-) Yes it works with the added cpu_to_be64() but in that
specific case, I think it would be nicer to simply load & shift into
position the 6 bytes and avoid the endianness issue completely.
Cheers,
Ben.
prev parent reply other threads:[~2013-12-24 4:37 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-12-23 1:29 [PATCH] ibmveth: Fix more little endian issues Alexander Graf
2013-12-23 6:38 ` Anton Blanchard
2013-12-23 10:17 ` Alexander Graf
2013-12-23 14:52 ` Joe Perches
2013-12-24 1:55 ` Anton Blanchard
2013-12-25 10:38 ` Ben Hutchings
2014-03-05 3:51 ` ibmveth: Fix endian issues with MAC addresses Anton Blanchard
2014-03-06 21:27 ` David Miller
2013-12-24 4:37 ` Benjamin Herrenschmidt [this message]
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=1387859821.4373.10.camel@pasglop \
--to=benh@kernel.crashing.org \
--cc=agraf@suse.de \
--cc=anton@samba.org \
--cc=dvaleev@suse.com \
--cc=joe@perches.com \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=netdev@vger.kernel.org \
--cc=santil@linux.vnet.ibm.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).