From: Kalle Valo <kvalo@codeaurora.org>
To: Pkshih <pkshih@realtek.com>
Cc: "linux-wireless\@vger.kernel.org"
<linux-wireless@vger.kernel.org>,
"Larry.Finger\@lwfinger.net" <Larry.Finger@lwfinger.net>
Subject: Re: [PATCH 13/14] rtlwifi: access skb->data to get C2H data by macro
Date: Fri, 29 Jun 2018 10:30:08 +0300 [thread overview]
Message-ID: <87sh56f3sv.fsf@codeaurora.org> (raw)
In-Reply-To: <1527732798.8418.7.camel@realtek.com> (pkshih@realtek.com's message of "Thu, 31 May 2018 02:13:35 +0000")
Pkshih <pkshih@realtek.com> writes:
> On Tue, 2018-05-29 at 08:18 +0300, Kalle Valo wrote:
>> <pkshih@realtek.com> writes:
>>=C2=A0
>> > From: Ping-Ke Shih <pkshih@realtek.com>
>> >
>> > The format of C2H data is ID(1 byte) + Length(1 byte) + value, and it =
is
>> > more readable to use macros to access C2H data.
>> >
>> > Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
>>=C2=A0
>> [...]
>>=C2=A0
>> > --- a/drivers/net/wireless/realtek/rtlwifi/wifi.h
>> > +++ b/drivers/net/wireless/realtek/rtlwifi/wifi.h
>> > @@ -177,6 +177,11 @@ enum rtl_c2h_evt_v2 {
>> >=C2=A0=C2=A0 C2H_V2_CCX_RPT =3D 0x0F,
>> >=C2=A0=C2=A0};
>> >=C2=A0=C2=A0
>> > +#define GET_C2H_CMD_ID(c2h) ({u8 *__c2h =3D c2h; __c2h[0]; })
>> > +#define GET_C2H_SEQ(c2h) ({u8 *__c2h =3D c2h; __c2h[1]; })
>> > +#define C2H_DATA_OFFSET 2
>> > +#define GET_C2H_DATA_PTR(c2h) ({u8 *__c2h =3D c2h; &__c2h[C2H_DATA_OF=
FSET]; })
>>=C2=A0
>> These macros are not really pretty, a proper static inline function
>> would be a much better choise. But I'm planning to apply this patch
>> anyway, I don't think it's a blocker but a good idea to cleanup later.
>>=C2=A0
>> And rtlwifi really should get away with this foo[0] and foo[1] style of
>> buffers and switch to proper structs (foo->bar and foo->koo).
>
> Thanks for your review and suggestion.
>
> Because C2H data is little endian order, the struct will look like
> struct foo {
> #ifdef=C2=A0__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.
> Is this a linux convention?
Earlier bitfields were disliked but nowadays they seem to be have become
more acceptable. But I think the preferred way still is something like
this (using u32 and 16 bit fields):
struct foo {
__le32 koobar;
}
#define RTLWIFI_BAR_MASK GENMASK(15, 0)
#define RTLWIFI_KOO_MASK GENMASK(31, 16)
bar =3D FIELD_GET(RTLWIFI_BAR_MASK, __le32_to_cpu(foo->koobar));
koo =3D FIELD_GET(RTLWIFI_KOO_MASK, __le32_to_cpu(foo->koobar));
Of course there can be other good ways to do the same, others can chime
in about those, but this is how I would do it.
--=20
Kalle Valo
next prev parent reply other threads:[~2018-06-29 7:30 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 [this message]
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
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=87sh56f3sv.fsf@codeaurora.org \
--to=kvalo@codeaurora.org \
--cc=Larry.Finger@lwfinger.net \
--cc=linux-wireless@vger.kernel.org \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).