From: Liming Sun <lsun@mellanox.com>
To: Andy Shevchenko <andy.shevchenko@gmail.com>
Cc: David Woods <dwoods@mellanox.com>,
Andy Shevchenko <andy@infradead.org>,
Darren Hart <dvhart@infradead.org>,
Vadim Pasternak <vadimp@mellanox.com>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
Platform Driver <platform-driver-x86@vger.kernel.org>
Subject: RE: [PATCH v13] platform/mellanox: Add TmFifo driver for Mellanox BlueField Soc
Date: Fri, 12 Apr 2019 16:15:15 +0000 [thread overview]
Message-ID: <DB6PR05MB32237EF42289A63B53433C14A1280@DB6PR05MB3223.eurprd05.prod.outlook.com> (raw)
In-Reply-To: <CAHp75Vfqi4Z3OrMsgeTJamJ61b7urAGkU2CKng8+Y-HvOGTvBQ@mail.gmail.com>
Thanks Andy. Please see my response below for this email as well.
- Liming
> -----Original Message-----
> From: Andy Shevchenko <andy.shevchenko@gmail.com>
> Sent: Thursday, April 11, 2019 10:13 AM
> To: Liming Sun <lsun@mellanox.com>
> Cc: David Woods <dwoods@mellanox.com>; Andy Shevchenko <andy@infradead.org>; Darren Hart <dvhart@infradead.org>; Vadim
> Pasternak <vadimp@mellanox.com>; Linux Kernel Mailing List <linux-kernel@vger.kernel.org>; Platform Driver <platform-driver-
> x86@vger.kernel.org>
> Subject: Re: [PATCH v13] platform/mellanox: Add TmFifo driver for Mellanox BlueField Soc
>
> On Sun, Apr 7, 2019 at 5:05 AM Liming Sun <lsun@mellanox.com> wrote:
>
> > > > + * mlxbf_tmfifo_msg_hdr - Structure of the TmFifo message header
> > > > + * @type: message type
> > > > + * @len: payload length
> > > > + * @u: 64-bit union data
> > > > + */
> > > > +union mlxbf_tmfifo_msg_hdr {
> > > > + struct {
> > > > + u8 type;
> > > > + __be16 len;
> > > > + u8 unused[5];
> > > > + } __packed;
> > > > + u64 data;
> > >
> > > I'm not sure I understand how you can distinguish which field of union to use?
> > > Isn't here some type missed?
> >
> > Updated the comment in v14.
> >
> > This message header is a union of struct and u64 data.
> > The 'struct' has
> > type and length field which are used to encode & decode the message.
> > The 'data' field is used to read/write the message header from/to the FIFO.
>
> Something fishy here.
>
> You are using a structure of data which you would like to write with
> one call? Perhaps you need to construct this on-the-fly.
Looks like "union causes confusion".
I will update it in v15 to construct it on-the-fly as suggested.
> Moreover, the __be memeber is used in a data which is written as LE.
> This needs more explanation.
Will update the comment for it in v15. Below are some explanation for it.
The 'LE' is for the low-level mmio transport layer. The SoC sends data stream
into the FIFO, the other side read it. The byte-order of the data stream keeps
the same when the other side reads it. The "__be16" is for the driver or
application on both sides to agree on how to decode the 'length'.
For example, the SoC side (little endian) sends a message with
8-byte message header "01 02 03 04 05 06 07 08" into the FIFO. The other
side (assuming big endian host machine using USB bulk transfer) reads the
same byte-stream and try to decode it with the mlxbf_tmfifo_msg_hdr.
Without the "__be16" conversion, the SoC side will think
"type=1, length=0x0302" while the big endian host-side will think
"type=1, length=0x0203".
>
> --
> With Best Regards,
> Andy Shevchenko
next prev parent reply other threads:[~2019-04-12 16:16 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <b143b40446c1870fb8d422b364ead95d54552be9.1527264077.git.lsun@mellanox.com>
2019-01-28 17:28 ` [PATCH v8 0/2] TmFifo platform driver for Mellanox BlueField SoC Liming Sun
2019-01-28 17:28 ` [PATCH v8 1/2] platform/mellanox: Add TmFifo driver for Mellanox BlueField Soc Liming Sun
2019-01-29 22:06 ` Andy Shevchenko
2019-02-13 16:33 ` Liming Sun
2019-01-30 6:24 ` Vadim Pasternak
2019-01-28 17:28 ` [PATCH v8 2/2] dt-bindings: soc: Add TmFifo binding for Mellanox BlueField SoC Liming Sun
2019-02-13 13:27 ` [PATCH v9] platform/mellanox: Add TmFifo driver for Mellanox BlueField Soc Liming Sun
2019-02-13 18:11 ` Andy Shevchenko
2019-02-13 18:34 ` Liming Sun
2019-02-14 16:25 ` Liming Sun
2019-02-28 15:51 ` Liming Sun
2019-02-28 15:51 ` [PATCH v10] " Liming Sun
2019-03-05 15:34 ` Andy Shevchenko
2019-03-06 20:00 ` Liming Sun
2019-03-08 14:44 ` Liming Sun
2019-03-08 14:41 ` [PATCH v11] " Liming Sun
2019-03-26 21:13 ` Liming Sun
2019-03-28 19:56 ` [PATCH v12] " Liming Sun
2019-04-04 19:36 ` [PATCH v13] " Liming Sun
2019-04-05 15:44 ` Andy Shevchenko
2019-04-05 19:10 ` Liming Sun
2019-04-07 2:05 ` Liming Sun
2019-04-11 14:13 ` Andy Shevchenko
2019-04-12 16:15 ` Liming Sun [this message]
2019-04-07 2:03 ` [PATCH v14] " Liming Sun
2019-04-11 14:09 ` Andy Shevchenko
2019-04-12 14:23 ` Liming Sun
2019-04-12 17:30 ` [PATCH v15] " Liming Sun
2019-05-03 13:49 ` [PATCH v16] " Liming Sun
2019-05-06 9:13 ` Andy Shevchenko
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=DB6PR05MB32237EF42289A63B53433C14A1280@DB6PR05MB3223.eurprd05.prod.outlook.com \
--to=lsun@mellanox.com \
--cc=andy.shevchenko@gmail.com \
--cc=andy@infradead.org \
--cc=dvhart@infradead.org \
--cc=dwoods@mellanox.com \
--cc=linux-kernel@vger.kernel.org \
--cc=platform-driver-x86@vger.kernel.org \
--cc=vadimp@mellanox.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).