lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date:   Fri, 12 Apr 2019 16:15:15 +0000
From:   Liming Sun <lsun@...lanox.com>
To:     Andy Shevchenko <andy.shevchenko@...il.com>
CC:     David Woods <dwoods@...lanox.com>,
        Andy Shevchenko <andy@...radead.org>,
        Darren Hart <dvhart@...radead.org>,
        Vadim Pasternak <vadimp@...lanox.com>,
        Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
        Platform Driver <platform-driver-x86@...r.kernel.org>
Subject: RE: [PATCH v13] platform/mellanox: Add TmFifo driver for Mellanox
 BlueField Soc

Thanks Andy. Please see my response below for this email as well.

- Liming

> -----Original Message-----
> From: Andy Shevchenko <andy.shevchenko@...il.com>
> Sent: Thursday, April 11, 2019 10:13 AM
> To: Liming Sun <lsun@...lanox.com>
> Cc: David Woods <dwoods@...lanox.com>; Andy Shevchenko <andy@...radead.org>; Darren Hart <dvhart@...radead.org>; Vadim
> Pasternak <vadimp@...lanox.com>; Linux Kernel Mailing List <linux-kernel@...r.kernel.org>; Platform Driver <platform-driver-
> x86@...r.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@...lanox.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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ