[OpenWrt-Devel] [PATCH 1/3] b53: add b53_mac_array_to_u64() utility function
Jonas Gorski
jogo at openwrt.org
Tue Mar 10 07:37:33 EDT 2015
On Mon, Mar 2, 2015 at 10:44 AM, Alexandru Ardelean
<ardeleanalex at gmail.com> wrote:
> So, on a powerpc system this works.
>
> static inline u64 b53_mac_array_to_u64(const u8 *u8_arr) {
> u64 mac = 0;
> u8 *cmac = (u8 *)&mac;
> memcpy(&cmac[2], u8_arr, 6);
> return mac;
> }
>
> I've done this approach initially, but there were some concerns afterwards
> regarding endianness.
> On my x86_64 system it looks ok, but I'm hoping you'd validate that this is
> endian-correct and would work on little endian targets.
> And then I'll move this in the port mirroring patch.
Please don't top post.
Hm, looking a the original patch, did you test this in little endian?
the shift looks wrong for there.
Same for the memcpy, you need to copy to cmac[0] in case of little
endian. Maybe it would be easier to just make the source mac u16
aligned, and then use ether_addr_copy().
Jonas
_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel
More information about the openwrt-devel
mailing list