From: Daniel Golle <daniel@makrotopia.org>
To: Andrew Lunn <andrew@lunn.ch>
Cc: Hauke Mehrtens <hauke@hauke-m.de>,
Vladimir Oltean <olteanv@gmail.com>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Philipp Zabel <p.zabel@pengutronix.de>,
Russell King <linux@armlinux.org.uk>,
linux-kernel@vger.kernel.org, netdev@vger.kernel.org,
Andreas Schirm <andreas.schirm@siemens.com>,
Lukas Stockmann <lukas.stockmann@siemens.com>,
Alexander Sverdlin <alexander.sverdlin@siemens.com>,
Peter Christen <peter.christen@siemens.com>,
Avinash Jayaraman <ajayaraman@maxlinear.com>,
Bing tao Xu <bxu@maxlinear.com>, Liang Xu <lxu@maxlinear.com>,
Juraj Povazanec <jpovazanec@maxlinear.com>,
"Fanni (Fang-Yi) Chan" <fchan@maxlinear.com>,
"Benny (Ying-Tsan) Weng" <yweng@maxlinear.com>,
"Livia M. Rosu" <lrosu@maxlinear.com>,
John Crispin <john@phrozen.org>
Subject: Re: [PATCH net-next v3 7/8] net: dsa: lantiq_gswip: store switch API version in priv
Date: Thu, 21 Aug 2025 11:50:30 +0100 [thread overview]
Message-ID: <aKb59jMfDIJIK0KP@pidgin.makrotopia.org> (raw)
In-Reply-To: <58d31b56-8145-419e-b7be-1fd48cfeda88@lunn.ch>
On Thu, Aug 21, 2025 at 04:58:23AM +0200, Andrew Lunn wrote:
> > > + priv->version = le16_to_cpu((__le16 __force)version);
> >
> > I've researched this a bit more and came to the conclusion that while the
> > above works fine because all Lantiq SoCs with built-in switch are
> > big-endian machines it is still wrong.
> > I base this conclusion on the fact that when dealing with more recent
> > MDIO-connected switches (MaxLinear GSW1xx series) the host endian doesn't
> > play a role in the driver -- when dealing with 16-bit values on the MDIO
> > bus, the bus abstraction takes care of converting from/to host endianess.
>
> I agree that all MDIO bus registers are host endian, 16 bit. The shift
> register in the hardware is responsible for putting the bits on the
> wire in the correct order for MDIO.
>
> > Hence I believe this should simply be a swab16() which will always result
> > in the version being in the right byte order to use comparative operators
> > in a meaningful way.
>
> How is this described in the datasheet? And is version special, or do
> all registers need swapping?
The (anyway public) datasheets I have access to don't describe the VERSION
register at all. In the existing precompiler macros, however, you can see
that most-significant and least-significant byte are swapped. REV is
more significant than MOD:
#define GSWIP_VERSION 0x013
#define GSWIP_VERSION_REV_SHIFT 0
#define GSWIP_VERSION_REV_MASK GENMASK(7, 0)
#define GSWIP_VERSION_MOD_SHIFT 8
#define GSWIP_VERSION_MOD_MASK GENMASK(15, 8)
#define GSWIP_VERSION_2_0 0x100
#define GSWIP_VERSION_2_1 0x021
#define GSWIP_VERSION_2_2 0x122
#define GSWIP_VERSION_2_2_ETC 0x022
Now I'd like to add
#define GSWIP_VERSION_2_3 0x023
and then have a simple way to make features available starting from a
GSWIP_VERSION. Now in order for GSWIP_VERSION_2_3 to be greater than
GSWIP_VERSION_2_2, and GSWIP_VERSION_2_1 to be greater than
GSWIP_VERSION_2_0, the bytes need to be swapped.
I don't think the vendor even considered any specific order of the two
bytes but just defines them as separate 8-bit fields, considering it a
16-bit unsigned integer is my interpretation which came from the need for
comparability.
next prev parent reply other threads:[~2025-08-21 10:50 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-20 1:54 [PATCH net-next v3 0/8] net: dsa: lantiq_gswip: prepare for supporting new features Daniel Golle
2025-08-20 1:54 ` [PATCH net-next v3 1/8] net: dsa: lantiq_gswip: deduplicate dsa_switch_ops Daniel Golle
2025-08-20 1:54 ` [PATCH net-next v3 2/8] net: dsa: lantiq_gswip: prepare for more CPU port options Daniel Golle
2025-08-20 1:54 ` [PATCH net-next v3 3/8] net: dsa: lantiq_gswip: move definitions to header Daniel Golle
2025-08-20 1:55 ` [PATCH net-next v3 4/8] net: dsa: lantiq_gswip: introduce bitmap for MII ports Daniel Golle
2025-08-20 1:55 ` [PATCH net-next v3 5/8] net: dsa: lantiq_gswip: load model-specific microcode Daniel Golle
2025-08-20 1:55 ` [PATCH net-next v3 6/8] net: dsa: lantiq_gswip: make DSA tag protocol model-specific Daniel Golle
2025-08-20 1:55 ` [PATCH net-next v3 7/8] net: dsa: lantiq_gswip: store switch API version in priv Daniel Golle
2025-08-20 23:57 ` Daniel Golle
2025-08-21 2:58 ` Andrew Lunn
2025-08-21 10:50 ` Daniel Golle [this message]
2025-08-21 14:15 ` Andrew Lunn
2025-08-20 1:56 ` [PATCH net-next v3 8/8] net: dsa: lantiq_gswip: add support for SWAPI version 2.3 Daniel Golle
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=aKb59jMfDIJIK0KP@pidgin.makrotopia.org \
--to=daniel@makrotopia.org \
--cc=ajayaraman@maxlinear.com \
--cc=alexander.sverdlin@siemens.com \
--cc=andreas.schirm@siemens.com \
--cc=andrew@lunn.ch \
--cc=bxu@maxlinear.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=fchan@maxlinear.com \
--cc=hauke@hauke-m.de \
--cc=john@phrozen.org \
--cc=jpovazanec@maxlinear.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=lrosu@maxlinear.com \
--cc=lukas.stockmann@siemens.com \
--cc=lxu@maxlinear.com \
--cc=netdev@vger.kernel.org \
--cc=olteanv@gmail.com \
--cc=p.zabel@pengutronix.de \
--cc=pabeni@redhat.com \
--cc=peter.christen@siemens.com \
--cc=yweng@maxlinear.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.