Search Linux Wireless

Re: [PATCH 6/6] ath11k: support GTK rekey offload

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> On Thursday, 9 December 2021 17:05:14 CET Kalle Valo wrote:
>> Isn't ath11k WMI commands and events supposed to be in CPU
>> endian and the firmware automatically translates them if CPU is little
>> or big endian? 
[...]
On Friday, 17 December 2021 12:04:45 CET Carl Huang wrote:
> Both cpu and firmware are supposed to be little endian in ath11k.

I hope this statement is incorrect. But if it isn't:

You cannot limit a non-architecture dependent driver to be only used by little 
endian CPUs. This would be grave bug in ath11k.

If your firmware requires wmi messages and similar things in little endian 
then you have to mark types correctly as big/little endian. E.g. __le32 
instead of u32. And then you have to convert everything manually with 
cpu_to_le32 and so on. See the ath10k code for examples.

Tools like sparse can assist you in your search for problematic places when 
your kernel has the __CHECK_ENDIAN__ related code activated. This is the 
default for kernels >= 4.10.


If Kalle' statement is true that the firmware takes care of endianness 
translation of WMI messages to host endianness, then your code would still be 
questionable:

>> +       /* supplicant expects big-endian replay counter */
>> +       replay_ctr = cpu_to_be64(le64_to_cpup((__le64 
>> *)ev->replay_counter));

Why isn't the firmware taking care of the conversion at that place?

Why are you defining it as `u8 replay_counter[GTK_REPLAY_COUNTER_BYTES];` in 
the struct instead of using `__le64 replay_counter;`?

What ensures that this is value is 64 bit aligned in memory? Wouldn't it be 
more correct to (see above) use

    replay_ctr = cpu_to_be64(get_unaligned_le64(ev->replay_counter));

Kind regards,
	Sven

Attachment: signature.asc
Description: This is a digitally signed message part.


[Index of Archives]     [Linux Host AP]     [ATH6KL]     [Linux Wireless Personal Area Network]     [Linux Bluetooth]     [Wireless Regulations]     [Linux Netdev]     [Kernel Newbies]     [Linux Kernel]     [IDE]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite Hiking]     [MIPS Linux]     [ARM Linux]     [Linux RAID]

  Powered by Linux