All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alexander Aring <alex.aring@gmail.com>
To: Marc Kleine-Budde <mkl@pengutronix.de>
Cc: linux-wpan@vger.kernel.org, kernel@pengutronix.de
Subject: Re: [PATCH bluetooth-next 2/3] ieee802154: cleanup ieee802154_be64_to_le64
Date: Wed, 11 Feb 2015 13:36:03 +0100	[thread overview]
Message-ID: <20150211123556.GA7351@omega> (raw)
In-Reply-To: <54DB486E.4080905@pengutronix.de>

On Wed, Feb 11, 2015 at 01:17:50PM +0100, Marc Kleine-Budde wrote:
> On 02/10/2015 11:14 PM, Alexander Aring wrote:
> > This patch cleanups the ieee802154_be64_to_le64 function. This patch
> > removes an unnecessary temporary variable.
> > 
> > Signed-off-by: Alexander Aring <alex.aring@gmail.com>
> > ---
> >  include/net/mac802154.h | 4 +---
> >  1 file changed, 1 insertion(+), 3 deletions(-)
> > 
> > diff --git a/include/net/mac802154.h b/include/net/mac802154.h
> > index 8506478..a4dcefe 100644
> > --- a/include/net/mac802154.h
> > +++ b/include/net/mac802154.h
> > @@ -233,9 +233,7 @@ struct ieee802154_ops {
> >   */
> >  static inline void ieee802154_be64_to_le64(void *le64_dst, const void *be64_src)
> >  {
> > -	__le64 tmp = (__force __le64)swab64p(be64_src);
> > -
> > -	memcpy(le64_dst, &tmp, IEEE802154_EXTENDED_ADDR_LEN);
> > +	*((__le64 *)le64_dst) = (__force __le64)swab64p(be64_src);
> 
> I assume the compiler optimizes the memcpy, due to the constant length
> argument. It the dst always 64 bit aligned?

should be. I can't check this, but dst and src should always 64 bit long.
(Otherwise the programmer do something wrong).

It's just byte swapping a little endian 64 bit value to big endian 64
bit value. Because mac header is little and the most netdev core api
uses big endian. These function are some helper function to transfer
__le64 to __be64. Sometimes the __le64 and __be64 are implementated as
arrays so I do this over some void pointers, like [0].

At [0] you see the assigned MAC PIB extended addr (saved as __le64)
which is set to the netdevice dev_addr array (assumes big endian).

The swab64p is an architecture optimized byte swapping function.

Do you think that this patch will decrease the perfomance of this function?
I know the casts looks a little bit ugly but swab64p isn't made for
"endianness swapping" and assumes u64 as parameter (pointer) and result.

- Alex

[0] http://git.kernel.org/cgit/linux/kernel/git/bluetooth/bluetooth-next.git/tree/net/mac802154/iface.c#n558

  reply	other threads:[~2015-02-11 12:36 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-02-10 22:14 [PATCH bluetooth-next 0/3] ieee802154: small cleanups Alexander Aring
2015-02-10 22:14 ` [PATCH bluetooth-next 1/3] ieee802154: correct ieee802154_is_valid_psdu_len Alexander Aring
2015-02-10 22:14 ` [PATCH bluetooth-next 2/3] ieee802154: cleanup ieee802154_be64_to_le64 Alexander Aring
2015-02-11 12:17   ` Marc Kleine-Budde
2015-02-11 12:36     ` Alexander Aring [this message]
2015-02-11 12:59       ` Phoebe Buckheister
2015-02-11 13:06         ` Alexander Aring
2015-02-11 13:12           ` Alexander Aring
2015-02-10 22:14 ` [PATCH bluetooth-next 3/3] ieee802154: cleanup ieee802154_le64_to_be64 Alexander Aring

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=20150211123556.GA7351@omega \
    --to=alex.aring@gmail.com \
    --cc=kernel@pengutronix.de \
    --cc=linux-wpan@vger.kernel.org \
    --cc=mkl@pengutronix.de \
    /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.