On Fri, March 14, 2014 9:36 pm, Martin Townsend wrote:
> Hi Phoebe,
>
> To help me review this series and also so I can update my driver could
> you give me some background on endianess in the stack, ie what should be
> little endian, why it should be little endian etc. Sorry for being a
> pain, I'm just trying to get my head around it all :)

The network stack usually deals with headers by pointer-casting the
appropriate offset in the skb to the header struct pointer type that is
currently required, so naturally those header fields will be in the byte
order imposed by the network. For us, that order is little endian, so
everything that might come into direct contact with the network should be
little endian - PAN IDs, short addresses of nodes, EUI addresses of nodes
and some other fields in the security header that aren't used (yet).

Now, since we can't simply cast a pointer and access members of the
resulting struct-pointer, that might seem pointless. It isn't though,
since it at the very least saves us some byteswaps during initial frame
processing and can allow the compiler to optimize the code better - but
more importantly, it will save you a lot of pain thinking about the stack,
since "it's relevant to headers" and "it's in network byte order" are the
same thing. In current mainline, that's not the case, and we even had
fields there with __le annotations that were actually in host byte order.

A driver won't be impacted much by this, since the only time when it
receives data that's not a bytestream and that does come into contact with
the network is during address filter configuration - in that case, just
look to at86r or mrf40 for guidance. There's really not much to change for
these. For HardMAC drivers, it's more complicated, but I'll just assume
that you don't have that.


------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and their
applications. Written by three acclaimed leaders in the field,
this first edition is now available. Download your free book today!
http://p.sf.net/sfu/13534_NeoTech
_______________________________________________
Linux-zigbee-devel mailing list
Linux-zigbee-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-zigbee-devel

Reply via email to