From: Arnd Bergmann <arnd@arndb.de>
To: "Volodymyr Mytnyk [C]" <vmytnyk@marvell.com>
Cc: Arnd Bergmann <arnd@arndb.de>,
Networking <netdev@vger.kernel.org>,
Taras Chornyi <taras.chornyi@plvision.eu>,
Mickey Rachamim <mickeyr@marvell.com>,
Serhiy Pshyk <serhiy.pshyk@plvision.eu>,
Andrew Lunn <andrew@lunn.ch>,
Geert Uytterhoeven <geert@linux-m68k.org>,
Denis Kirjanov <dkirjanov@suse.de>,
"Taras Chornyi [C]" <tchornyi@marvell.com>,
"David S. Miller" <davem@davemloft.net>,
Jakub Kicinski <kuba@kernel.org>,
"Vadym Kochan [C]" <vkochan@marvell.com>,
Yevhen Orlov <yevhen.orlov@plvision.eu>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH net v3] net: marvell: prestera: fix hw structure laid out
Date: Fri, 5 Nov 2021 17:56:03 +0100 [thread overview]
Message-ID: <CAK8P3a2zsuxZvt3ajzw4u6vpoDbei5xETiB-oCzx5FD4cq=oVQ@mail.gmail.com> (raw)
In-Reply-To: <SJ0PR18MB400959CE08EC6BFB397CAAB3B28D9@SJ0PR18MB4009.namprd18.prod.outlook.com>
On Fri, Nov 5, 2021 at 5:33 PM Volodymyr Mytnyk [C] <vmytnyk@marvell.com> wrote:
> >
> > However, there is still this structure that lacks explicit padding:
> >
> > struct prestera_msg_acl_match {
> > __le32 type;
> > /* there is a four-byte hole on most architectures, but not on
> > x86-32 or m68k */
>
> Checked holes on x86_64 with pahole, and there is no holes. Maybe on some
> other there will be. Will add 4byte member here to make sure. Thx.
That is very strange, as the union has an __le64 member that should be
64-bit aligned on x86_64.
> >
> > struct prestera_msg_event_port_param {
> > union {
> > struct {
> > __le32 mode;
> > __le32 speed;
> > u8 oper;
> > u8 duplex;
> > u8 fc;
> > u8 fec;
> > } mac;
> > struct {
> > __le64 lmode_bmap;
> > u8 mdix;
> > u8 fc;
> > u8 __pad[2];
> > } __packed phy;
> > } __packed;
> > } __packed;
> >
> > There is no need to make the outer aggregates __packed, I would
> > mark only the innermost ones here: mode, speed and lmode_bmap.
> > Same for prestera_msg_port_cap_param and prestera_msg_port_param.
> >
>
> Will add __packed only to innermost ones. Looks like only phy is required to have __packed.
I think you need it on both lmode_bmap and mode/speed
to get a completely unaligned structure. If you mark phy as __packed,
that will implicitly mark lmode_bmap as packed but leave the
four-byte alignment on mode and speed, so the entire structure
is still four-byte aligned.
Arnd
next prev parent reply other threads:[~2021-11-05 16:56 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-04 13:09 [PATCH net v3] net: marvell: prestera: fix hw structure laid out Volodymyr Mytnyk
2021-11-04 13:26 ` Arnd Bergmann
2021-11-05 16:33 ` Volodymyr Mytnyk [C]
2021-11-05 16:56 ` Arnd Bergmann [this message]
2021-11-06 13:03 ` Volodymyr Mytnyk [C]
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='CAK8P3a2zsuxZvt3ajzw4u6vpoDbei5xETiB-oCzx5FD4cq=oVQ@mail.gmail.com' \
--to=arnd@arndb.de \
--cc=andrew@lunn.ch \
--cc=davem@davemloft.net \
--cc=dkirjanov@suse.de \
--cc=geert@linux-m68k.org \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mickeyr@marvell.com \
--cc=netdev@vger.kernel.org \
--cc=serhiy.pshyk@plvision.eu \
--cc=taras.chornyi@plvision.eu \
--cc=tchornyi@marvell.com \
--cc=vkochan@marvell.com \
--cc=vmytnyk@marvell.com \
--cc=yevhen.orlov@plvision.eu \
/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).