All of lore.kernel.org
 help / color / mirror / Atom feed
From: Larry Finger <Larry.Finger@lwfinger.net>
To: Kalle Valo <kvalo@codeaurora.org>, Felix Fietkau <nbd@nbd.name>
Cc: Pkshih <pkshih@realtek.com>,
	"linux-wireless@vger.kernel.org" <linux-wireless@vger.kernel.org>
Subject: Re: [PATCH 13/14] rtlwifi: access skb->data to get C2H data by macro
Date: Tue, 3 Jul 2018 10:28:25 -0500	[thread overview]
Message-ID: <2eb770f9-2242-2234-b853-d53b0198fda4@lwfinger.net> (raw)
In-Reply-To: <87po04r3hk.fsf@kamboji.qca.qualcomm.com>

On 07/03/2018 05:57 AM, Kalle Valo wrote:
> Felix Fietkau <nbd@nbd.name> writes:
> 
>> On 2018-07-03 08:14, Kalle Valo wrote:
>>> Pkshih <pkshih@realtek.com> writes:
>>>
>>>> On Fri, 2018-06-29 at 10:30 +0300, Kalle Valo wrote:
>>>>> Pkshih <pkshih@realtek.com> writes:
>>>>>
>>>>>> On Tue, 2018-05-29 at 08:18 +0300, Kalle Valo wrote:
>>>>>>> <pkshih@realtek.com> writes:
>>>>>>>   
>>>>>>
>>>>>> Because C2H data is little endian order, the struct will look like
>>>>>> struct foo {
>>>>>> #ifdef __LITTLE_ENDIAN
>>>>>>   	u8 bar:4;
>>>>>>   	u8 koo:4;
>>>>>> #else
>>>>>>   	u8 koo:4;
>>>>>>   	u8 bar:4;
>>>>>> #endif
>>>>>> }
>>>>>
>>>>> With u8 you don't need endian check, right? I would assume that with
>>>>> both little and big endian bar and koo would be in the same place.
>>>>
>>>> I think u8 with bitfield would be different between little and big endian
>>>> machines.
>>>
>>> To me that does not make any sense, I have never heard about bit
>>> endianness any of the devices I have worked on.
>>
>> Unfortunately, the order in which these fields are laid out is different
>> between big and little endian, even when only dealing with u8.
> 
> Oh, didn't know that. Can you give some examples about endian problems
> with u8 bitfields? Still not getting it. Not that it matters, just
> curious.
> 
>> That alone is a strong reason to avoid bitfields entirely for anything
>> shared between the host and something else.
> 
> Very good to know, thanks.

Kalle,

By now, I think you understand that not only the byte order is different between 
BE and LE, but the bit order within a byte is different as well. In the normal 
situation where only byte-sized quantities are involved, then there need not be 
any concern. If you need to mask part of the byte, the mask itself will be in 
the correct endianess.

To me, the main advantage of using using bitfield notation is that the compiler 
does the work of generating the masks needed to extract a portion of the byte. I 
consider that to be slightly less likely to have errors that relying on the 
programmer to generate the mask. A secondary benefit is that the bitfield 
notation is self documenting.

Larry

  parent reply	other threads:[~2018-07-03 15:28 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-18  9:29 [PATCH 00/14] rtlwifi: remove duplicate C2H handlers pkshih
2018-05-18  9:29 ` [PATCH 01/14] rtlwifi: support accurate nullfunc frame tx ack report pkshih
2018-05-29  7:18   ` [01/14] " Kalle Valo
2018-05-18  9:29 ` [PATCH 02/14] rtlwifi: remove CONNECTION_MONITOR flag pkshih
2018-05-18  9:29 ` [PATCH 03/14] rtlwifi: remove duplicate rx_packet_type definition pkshih
2018-05-18  9:29 ` [PATCH 04/14] rtlwifi: rename register-based C2H command IDs to V0 pkshih
2018-05-18  9:29 ` [PATCH 05/14] rtlwifi: remove duplicate C2H definition pkshih
2018-05-18  9:29 ` [PATCH 06/14] rtlwifi: remove unused fw C2H command ID pkshih
2018-05-18  9:30 ` [PATCH 07/14] rtlwifi: remove dummy hal_op rx_command_packet from rtl8188ee and rtl8723ae pkshih
2018-05-18  9:30 ` [PATCH 08/14] rtlwifi: Add hal_op c2h_ra_report_handler for special process pkshih
2018-05-18  9:30 ` [PATCH 09/14] rtlwifi: remove duplicate C2H handler pkshih
2018-05-18  9:30 ` [PATCH 10/14] rtlwifi: remove hal_op rx_command_packet pkshih
2018-05-18  9:30 ` [PATCH 11/14] rtlwifi: remove hal_op c2h_content_parsing pkshih
2018-05-18  9:30 ` [PATCH 12/14] rtlwifi: use sk_buff to queue C2H commands pkshih
2018-05-18  9:30 ` [PATCH 13/14] rtlwifi: access skb->data to get C2H data by macro pkshih
2018-05-29  5:18   ` Kalle Valo
2018-05-31  2:13     ` Pkshih
2018-06-29  7:30       ` Kalle Valo
2018-07-03  6:03         ` Pkshih
2018-07-03  6:14           ` Kalle Valo
2018-07-03  8:32             ` Felix Fietkau
2018-07-03 10:57               ` Kalle Valo
2018-07-03 11:01                 ` Felix Fietkau
2018-07-03 15:28                 ` Larry Finger [this message]
2018-05-18  9:30 ` [PATCH 14/14] rtlwifi: fix btmpinfo timeout while processing C2H_BT_INFO pkshih

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=2eb770f9-2242-2234-b853-d53b0198fda4@lwfinger.net \
    --to=larry.finger@lwfinger.net \
    --cc=kvalo@codeaurora.org \
    --cc=linux-wireless@vger.kernel.org \
    --cc=nbd@nbd.name \
    --cc=pkshih@realtek.com \
    /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.