Article View: linux.kernel.netdev
Article #20289Re: [PATCH net-next v22 03/15] net: phylink: introduce internal phylink PCS handling
From: Jakub Kicinski
Date: Sat, 21 Nov 2026 23:26
Date: Sat, 21 Nov 2026 23:26
115 lines
12638 bytes
12638 bytes
This is an AI-generated review of your patch. The human sending this
email has considered the AI review valid, or at least plausible.
---
net: phylink: introduce internal phylink PCS handling
This adds an alternative to .mac_select_pcs. The MAC hands phylink a list
of PCS through .fill_available_pcs and .num_possible_pcs, and phylink
picks a PCS by matching the interface against each PCS's
supported_interfaces. A new pcs_interfaces mask in phylink_config marks
the modes that need a dedicated PCS, and phylink_create() widens
pl->supported_interfaces with the supported_interfaces of every listed
PCS.
> diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c
> index f482dc6088102..e8ba906cfba68 100644
> --- a/drivers/net/phy/phylink.c
> +++ b/drivers/net/phy/phylink.c
[ ... ]
> @@ -2096,16 +2220,31 @@ struct phylink *phylink_create(struct phylink_config *config,
> __set_bit(PHYLINK_DISABLE_STOPPED, &pl->phylink_disable_state);
> timer_setup(&pl->link_poll, phylink_fixed_poll, 0);
>
> + /* Fill the PCS list with available PCS from phylink config */
> + ret = phylink_fill_available_pcs(pl, config);
> + if (ret < 0)
> + goto free_pl;
> +
> + /* Link available PCS to phylink */
> + list_for_each_entry(pcs, &pl->pcs_list, list)
> + rcu_assign_pointer(pcs->phylink, pl);
> +
> phy_interface_copy(pl->supported_interfaces,
> pl->config->supported_interfaces);
>
> + /* Update supported interfaces */
> + list_for_each_entry(pcs, &pl->pcs_list, list)
> + phy_interface_or(pl->supported_interfaces,
> + pl->supported_interfaces,
> + pcs->supported_interfaces);
> +
[Severity: Medium]
Can this OR put modes into pl->supported_interfaces that phylink will
never select a PCS for?
The PCS modes are not masked with config->pcs_interfaces. However, the
PCS lookup this patch adds only runs when the interface is in
pcs_interfaces. The check in phylink_validate_mac_and_pcs(),
phylink_inband_caps() and phylink_major_config() is:
} else if (test_bit(state->interface, pl->config->pcs_interfaces)) {
Suppose a listed PCS advertises a mode that is not in pcs_interfaces.
__phylink_validate() accepts that mode after checking only the MAC
capabilities.
SFP interface selection uses the same widened mask. It also ends up in
the SFP PHY's host_interfaces through phylink_sfp_connect_phy():
phy_interface_and(phy->host_interfaces, phylink_sfp_interfaces,
pl->supported_interfaces);
If that mode is then picked, phylink_major_config() skips the PCS list
branch and pcs stays NULL:
pcs_changed = pl->pcs != pcs;
...
if (pcs_changed) {
phylink_pcs_disable(pl->pcs);
...
WRITE_ONCE(pl->pcs, pcs);
}
So the active PCS is disabled and pl->pcs becomes NULL. mac_config() is
then called for a mode the MAC never listed in
config->supported_interfaces. No PCS is programmed for that mode.
The "couldn't find a PCS for %s" error is not printed either, because it
is only reached inside the pcs_interfaces branch.
The Documentation/networking/pcs.rst added later in the series describes
supported_interfaces as holding every MAC mode. It describes
pcs_interfaces as the subset that needs a PCS ("PCS required only for
USXGMII").
Under that model the OR either adds nothing new, or it adds modes outside
pcs_interfaces that never get a PCS. One example is a USXGMII PCS that
also supports 10GBASER, 2500BASEX and 1000BASEX, such as the Airoha PCS
added later in the series.
The airoha user in the series does not hit this, because it copies
supported_interfaces into pcs_interfaces. The final state of the series
still has the unmasked OR in both phylink_create() and
pcs_provider_notify().
Should the OR be limited to config->pcs_interfaces? Alternatively, should
phylink_create() reject a PCS mode that is not in pcs_interfaces?
phylink_create() also does not check that the new fields are consistent:
- It accepts num_possible_pcs with an empty pcs_interfaces. In that case
the listed PCS are never selected.
- It accepts pcs_interfaces together with .mac_select_pcs. In that case
pcs_interfaces is silently ignored.
Would it make sense to reject these combinations here?
Separately, the kernel-doc for @supported_interfaces ("supported by the
MAC/PCS") and @pcs_interfaces ("dedicated PCS is required") in
include/linux/phylink.h does not match how phylink combines the two
masks.
Technical Details
Message-ID:
<20261121232643.1365333-1-kuba@kernel.org>Path:
mbox-mo1.pugleaf.net!news-wdc.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-368523-linux-kernel-netdev=dewy.ruReferences:
<20261117123956.11981-4-ansuelsmth@gmail.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-wdc.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-368523-linux-kernel-netdev=dewy.ru From: kuba@kernel.org (Jakub Kicinski) Newsgroups: linux.kernel.netdev Subject: Re: [PATCH net-next v22 03/15] net: phylink: introduce internal phylink PCS handling Date: Sat, 21 Nov 2026 15:26:43 -0800 Organization: Usenet Network Message-ID: <20261121232643.1365333-1-kuba@kernel.org> References: <20261117123956.11981-4-ansuelsmth@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="3521172"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:G5Yv6oQNQIavR8+HrOR68xfsusE= sha256:vthLpyAamNtc1jx4/deFHFWJrA1w4tnQGw8AnvoB+CI= sha1:IDX57iK56hYbM3eNOgtRqbH96kc= sha256:/opTmCLWEESVHEZqRYereZuPuewk0aBFmcid2BYCY6o= List-ID: <netdev.vger.kernel.org> X-Mailpost-Empty-Hdrs: X-Spam-Level X-Received: from localhost (localhost [127.0.0.1]) by mail.dewy.ru (Postfix) with ESMTP id 27C11115C25; Sun, 22 Nov 2026 02:27:05 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.401 X-Spam-Status: No, score=-3.401 tagged_above=-9999 required=6.31 tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001] autolearn=ham autolearn_force=no X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key) header.d=kernel.org X-Received: from mail.dewy.ru ([127.0.0.1]) by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id rNAoVvm38max; Sun, 22 Nov 2026 02:27:02 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-368523-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org X-Received: from tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114]) by mail.dewy.ru (Postfix) with ESMTPS id D0978115C36; Sun, 22 Nov 2026 02:26:51 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by tor.lore.kernel.org (Postfix) with ESMTP id 5FE3A2DBEB; Sat, 21 Nov 2026 23:26:49 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1795303608; b=gS+DwVp/8EiKI+6aIZIQgvxXAYYU5W/TdXxXLcwux2jP0azd7ZO6bLZbbkG0Tms94ugf DqowmF/qXVOUVDtvtQmg1xwGDOD4LrC/y1/NUqO+vyZZ/yrvajSqG8yjkCbrSC1Iu45kZ zyBnNXBDKiLMnJCQJXwHTc1RBoxb+r/qSg0Icsxf00GzVC/cFl2AbZVX7+RGtcYJPC2zZ EFBgtwWq2DqpazXABTtnsVKFQDXFvLow99Vi2UOj/L+Tm0yZoxEFegbKKtlLIHeiO1vMR nqXHTyLF3gSrwVwjrUiTVSPX3AZ3hk+EdRReEsXm7N0WPV1zXyT9WBafb62DJO6NTHQ== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795303608; h=X-Original-To:Received:Received:DKIM-Signature:From:To:Cc:Subject: Date:Message-ID:X-Mailer:In-Reply-To:References:X-Mailing-List: List-Id:List-Post:List-Help:List-Subscribe:List-Unsubscribe: List-Owner:Precedence:MIME-Version:Content-Transfer-Encoding; bh=fM/qA6/4U7l7719+XpQdyjrMAl2GxPV3Jko7fpcHllc=; b=SH6vRbH0BNTvBc0Gbe6x5EP+aWo2+gGYLmPDPlexfx123RIMtHFy4O4yO04MCFlucQIr mrtt8MOhtSzLNrMbhCofF/vTWsK58H/XbDWfK8NryY/gXMfJZ+RS8YkKbSlRSipt3TEcS p4LYpfD26VadpkZMeM9Bhw9wflBOz055z0huU8PJqoBe3TiAhuqjIECyXDoEPSIu06p+O y9l61h2YUz/MGUBFuXD8LvD5HWFCe+ST2ePJftcOApO5qW3CIxLz29ZZgQc8aYnSM3CYc E8bWkKEihGw/kM/siaAZBujKlId45iQQ7CmQ76wWAoBqM92Kg5kR1wJasDcMTE2oq4g== X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=Igh8pVAZ; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 880C2606A682; Sat, 21 Nov 2026 23:26:48 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=Igh8pVAZ X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795303607; b=MF8xrYXaHroHzA+TIv6pDT3aM3gv+syCVvHtQr8JnLoaUJ3iyFUVDM8Jsd7KVIbRKYKs OGbqW8j5MyoMaGsaQSV+lbmRzWd4yl5DsRrD2DEw/oPTgv8RJtysr6DhPnOF23uAY6aMV lRGur7WXnwTMZ60wNXvO0TeefRECNtUDNFYOqpeafso3wjMWe6Hxb0LJw+pee7X0FXlGz 8u4HFrrbYLilB+HyqiaEtCLnL+pJVjsdtH45Agr0JwpHVl4/eyTINSLApWByf4TgeqmR5 UJdZu7Q/28Jz02SxgqZX8wjSt4N3ow/5QwKdkY/zU5h/taojmWcTMzXC8wAkMs8vd6w== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795303607; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:MIME-Version:Content-Transfer-Encoding; bh=fM/qA6/4U7l7719+XpQdyjrMAl2GxPV3Jko7fpcHllc=; b=oK5BnQptaXWlh4nG8E4wldbJopC20bHN56ufrjJiuTNlY5AQYdNszDHWV3m9tB+i3mAx SG/eqtF1vQqPGfB+si7NHH511Ia58SqWIFxbQ1nNLEIe8ByACj3gkxPZrZk8kB+JkwlmQ Dhvq775a+gkw4BnSmbBO25yLqDN8Jxd6WYWPuGOqTmgBP1RGla+LcPFUrsoQ/w8Vb0Rfn EsGrDCIvVPKdKWWLP4IHSflYbW4qyWMYiwE1F8jMmKCCazkTsj/Stq057273n9OvjydUq ZYoiaoOVCnGhALkAadv1Ni7ajcvQE+BY3q8gvHYseLr4lXb/A2bblCOZhKellwNjQow== X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=Igh8pVAZ; arc=none smtp.remote-ip=100.103.45.18 X-Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A7615606A330; Sat, 21 Nov 2026 23:26:47 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id A3BC71F000CF; Sat, 21 Nov 2026 23:26:46 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795303607; bh=fM/qA6/4U7l7719+XpQdyjrMAl2GxPV3Jko7fpcHllc=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=Igh8pVAZZm5rdiOR9KwRNVyTpTIf0iPk/SmyuhzdzS4PWrLqcA4mf3lAshs0dGXv4 qIEG3zxFmac4IuESiWfOEn+zL0CljFNxEzdokWeoAbHw+8cBg/L1UmXkcVytlSNlZx BM4/D5qEE2lQ8JFXHAn3RiCgB/jCjiH8Eks08ia3CVIJ5AmjiZdul+z14sew2TSeRI u5jwPAPgIu8hOfBv2MfNHUqj4NGh/Rpu8kCiJqPW/wLXxTr1cigP+jVZ0Pk6KWR7Jv RcN/y6ydFTxOWS4aLEJ5lZVhZ6TGB6JiggF7croio+2iH6td/ULJduKBQ/DC+aDrWE ytQdfaAjIOCPA== X-Cc: Jakub Kicinski <kuba@kernel.org>, andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@kernel.org, pabeni@redhat.com, robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org, horms@kernel.org, corbet@lwn.net, skhan@linuxfoundation.org, rdunlap@infradead.org, lorenzo@kernel.org, hkallweit1@gmail.com, linux@armlinux.org.uk, maxime.chevallier@bootlin.com, p.zabel@pengutronix.de, nathan@kernel.org, ndesaulniers@google.com, morbo@google.com, justinstitt@google.com, rmk+kernel@armlinux.org.uk, netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, llvm@lists.linux.dev, zhengping.zhang@airoha.com X-Mailer: git-send-email 2.56.1 X-In-Reply-To: <20261117123956.11981-4-ansuelsmth@gmail.com> X-Mailing-List: netdev@vger.kernel.org X-List-Post: <mailto:netdev@vger.kernel.org> X-List-Help: <mailto:netdev+help@vger.kernel.org> X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org> X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org> X-List-Owner: <mailto:netdev+owner@vger.kernel.org> X-Precedence: list