From: netdev-bot+sashiko@kernel.org
To: rkannoth@marvell.com
Cc: linux-kernel@vger.kernel.org, netdev@vger.kernel.org,
andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@google.com,
kuba@kernel.org, pabeni@redhat.com, sgoutham@marvell.com,
hkelam@marvell.com
Subject: Re: [PATCH v3 net-next] octeontx2-pf: report port connector type in ethtool link ksettings
Date: Thu, 10 Sep 2026 04:32:43 +0000 [thread overview]
Message-ID: <178901476356.219967.4043623609208931989@kernel.org> (raw)
In-Reply-To: <20260909040621.397255-1-rkannoth@marvell.com>
Thank you for your contribution! Sashiko AI review found 1 potential
issue(s) to consider:
Critical: 0 · High: 0 · Medium: 1 · Low: 0
- [Medium] otx2_get_link_ksettings()
(drivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c:1236)…
--
octeontx2-pf: report port connector type in ethtool link ksettings
otx2_get_link_ksettings() now reads the connector type out of the CGX
firmware shared data (struct cgx_lmac_fwdata_s.port), masks the low eight
bits, checks the result against a list of ethtool PORT_* values and stores
it into cmd->base.port. Unrecognized values become PORT_OTHER.
> diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c
> index 9bee1b91eeaa..a05dee0085a3 100644
> --- a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c
> +++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c
[ ... ]
> @@ -1231,6 +1232,23 @@ static int otx2_get_link_ksettings(struct net_device *netdev,
> OTX2_MODE_SUPPORTED, cmd);
> otx2_get_fec_info(rsp->fwdata.supported_fec,
> OTX2_MODE_SUPPORTED, cmd);
> +
> + port = FIELD_GET(GENMASK(7, 0), rsp->fwdata.port);
> + switch (port) {
> + case PORT_TP:
> + case PORT_AUI:
> + case PORT_MII:
> + case PORT_FIBRE:
> + case PORT_BNC:
> + case PORT_DA:
> + case PORT_NONE:
> + cmd->base.port = port;
> + break;
> + default:
> + cmd->base.port = PORT_OTHER;
> + break;
> + }
[Severity: Medium]
Can this report a wrong connector type when firmware never populated the
field?
PORT_TP is 0x00 in include/uapi/linux/ethtool.h, and the ethtool core
zero-fills the settings before calling into the driver:
net/ethtool/ioctl.c:netif_get_link_ksettings() {
memset(link_ksettings, 0, sizeof(*link_ksettings));
return dev->ethtool_ops->get_link_ksettings(dev, link_ksettings);
}
So a zero firmware word takes the "case PORT_TP:" arm rather than the
default PORT_OTHER arm, and ethtool prints "Port: Twisted Pair" on a
fibre, DAC or backplane board.
Is a zero word possible here? The member was carved out of the previously
reserved (zero-filled) tail of struct cgx_lmac_fwdata_s by commit
49f02e6877d1b, which shrank LMAC_FWDATA_RESERVED_MEM from 1021 to 1018:
drivers/net/ethernet/marvell/octeontx2/af/mbox.h:
u64 mgmt_port:1;
u64 advertised_an:1;
u64 port;
#define LMAC_FWDATA_RESERVED_MEM 1018
u64 reserved[LMAC_FWDATA_RESERVED_MEM];
RVU_FWDATA_VERSION was not bumped at the same time, and
is_rvu_fwdata_valid() in af/rvu.h only compares header_magic and version,
so firmware images that predate the field still pass the ABI gate and hand
back zeros for this word.
Would it make sense to also consult rw_valid from the same struct? It is
the per-LMAC validity flag, and grep shows it is currently only referenced
in mbox.h and rvu_debugfs.c, never by this new consumer. Note also that
the debugfs dumper added alongside the field prints rw_valid, lmac_type,
portm_idx and mgmt_port, but not port.
Separately, does the masking defeat part of the validation? FIELD_GET()
with GENMASK(7, 0) drops bits 63:8 before the switch runs, so firmware
values such as 0x100 or 0x103 are published as PORT_TP and PORT_FIBRE
respectively. mbox.h documents no bitfield layout, mask or reserved-bit
contract for this bare u64, so it isn't clear the upper bits can be
discarded rather than treated as "not a valid connector code".
Related to that, the commit message says:
"Extract only the low 8 bits of the firmware field and validate the
value against the standard ethtool PORT_* definitions before
publishing it to userspace."
Given that neither the unpopulated (zero) case nor invalid values living in
bits 63:8 can be rejected by this check, could the description be made
more precise about what is actually validated?
One more question on the encoding itself: is there an in-tree statement
that fwdata.port uses ethtool PORT_* numbering? The only other firmware
description of a "port" value is struct cgx_lnk_sts.port:8 with
RESP_LINKSTAT_PORT in af/cgx_fw_if.h, and that macro is defined but never
decoded by cgx.c, so the mapping to PORT_TP/PORT_FIBRE/... appears
undocumented here.
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20260909040621.397255-1-rkannoth%40marvell.com
next prev parent reply other threads:[~2026-09-10 4:32 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-09 4:06 Ratheesh Kannoth
2026-09-10 4:32 ` netdev-bot+sashiko [this message]
2026-09-10 9:03 ` Ratheesh Kannoth
2026-09-10 10:41 ` Simon Horman
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=178901476356.219967.4043623609208931989@kernel.org \
--to=netdev-bot+sashiko@kernel.org \
--cc=andrew+netdev@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=hkelam@marvell.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=rkannoth@marvell.com \
--cc=sgoutham@marvell.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
all inboxes | Powered by JetHome®