Re: [PATCH] Bluetooth: qca: fix device-address endianness

From: Johan Hovold
Date: Thu Jan 18 2024 - 03:18:00 EST


On Wed, Jan 17, 2024 at 01:52:08PM -0800, Doug Anderson wrote:
> Hi,
>
> On Wed, Jan 10, 2024 at 12:12 AM Johan Hovold <johan@xxxxxxxxxx> wrote:
> >
> > > > So the first question is whether there actually is any boot firmware out
> > > > there which passes the BD_ADDR in reverse order?
> > >
> > > Yes, (at least) the boot firmware for sc7180-trogdor devices.
> > >
> > > hexdump -C /proc/device-tree/soc\@0/geniqup\@8c0000/serial\@88c000/bluetooth/local-bd-address
> > > 00000000 8c fd f0 40 15 dc
> >
> > Indeed, this should have been LE order.
>
> In case it adds any extra data points, we also do similar with the
> WiFi MAC address and it also seems to be big endian.
>
> lazor-rev9 /proc/device-tree/soc@0/wifi@18800000 # hexdump -C local-mac-address
> 00000000 8c fd f0 3e 3e 86 |...>>.|
> 00000006
>
> lazor-rev9 /proc/device-tree/soc@0/wifi@18800000 # ifconfig wlan0 | grep ether
> ether 8c:fd:f0:3e:3e:86 txqueuelen 1000 (Ethernet)

Yes, wifi and ethernet MAC addresses are always big endian (i.e. on the
wire as well as in UIs).

When the corresponding devicetree property for Bluetooth device
addresses was added, Marcel explicitly requested that the address be
provided in little-endian order:

"I would prefer the boot loader actually providing the BD
Address in the correct byte order as the protocol expects and
not yet another form. The string representation is just for
reference since that is what most people have seen so far."

https://lore.kernel.org/all/41A0C162-4AC5-4969-813D-9E2C7F5D5031@xxxxxxxxxxxx/

and this is also what made it into the binding:

28517c02e1dd ("dt-bindings: net: document Bluetooth bindings in one place")

Perhaps someone should have pushed back at the time to avoid this
(apparent) inconsistency, but this is what we have since 2017.

Johan