linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Ben Hutchings <bhutchings@solarflare.com>
To: Anton Blanchard <anton@samba.org>
Cc: Dinar Valeev <dvaleev@suse.com>,
	linuxppc-dev@lists.ozlabs.org, Alexander Graf <agraf@suse.de>,
	netdev@vger.kernel.org, Joe Perches <joe@perches.com>,
	Santiago Leon <santil@linux.vnet.ibm.com>
Subject: Re: [PATCH] ibmveth: Fix more little endian issues
Date: Wed, 25 Dec 2013 10:38:28 +0000	[thread overview]
Message-ID: <1387967908.26981.0.camel@deadeye.wl.decadent.org.uk> (raw)
In-Reply-To: <20131224125529.58970f1b@kryten>


On Tue, 2013-12-24 at 12:55 +1100, Anton Blanchard wrote:
> The hypervisor expects MAC addresses passed in registers to be big
> endian u64. Create a helper function called ibmveth_encode_mac_addr
> which does the right thing in both big and little endian.
> 
> We were storing the MAC address in a long in struct ibmveth_adapter.
> It's never used so remove it - we don't need another place in the
> driver where we create endian issues with MAC addresses.
[...]
> @@ -523,10 +523,20 @@ retry:
>  	return rc;
>  }
>  
> +/* The hypervisor expects MAC addresses passed in registers to be
> + * big endian u64.
> + */
> +static __be64 ibmveth_encode_mac_addr(char *mac)
> +{
> +	unsigned long encoded = 0;

u64

> +	memcpy(((char *)&encoded) + 2, mac, ETH_ALEN);
> +	return cpu_to_be64(encoded);
> +}
[...]

So on big-endian systems the byte order of the result will be:

    0 0 mac0 mac1 mac2 mac3 mac4 mac5

and on little-endian systems it's:

    mac5 mac4 mac3 mac2 mac1 mac0 0 0

It seems to me that 'encoded' is actually in big-endian order and this
function returns the address in CPU order.

So are you sure your explanation isn't backwards, because it looks to me
like the driver was already holding the MAC address in big-endian order
and perhaps the hypercall mechanism does a byte-swap when the guest is
little-endian.

Ben.

-- 
Ben Hutchings, Staff Engineer, Solarflare
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.

  reply	other threads:[~2013-12-25 10:44 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 [this message]
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     ` [PATCH] ibmveth: Fix more little endian issues Benjamin Herrenschmidt

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=1387967908.26981.0.camel@deadeye.wl.decadent.org.uk \
    --to=bhutchings@solarflare.com \
    --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).