From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796082473; b=GCTa8zmj3PUlT5/eMzl0WQT2qKhfBKLxyxlmgxfSQ8Z6abezBQJQdDsp2GkrrfgvHk2T txLjg52mj/6tj7jb7p9ZU6nY96AurgZ5Ok9Ac/PIzY6Cjoeg06VB7ce3m+/IRyjSdxZkE nSdJ+2i1nwPK3fgzGW3HulF/Yp2QneexJGzlArFFSEUQdAJpukNFGGC1s+4+I8jXkXnWb EfoZO61enwogx9KEcDBad2KAJ0/U/TRZ9Fh6RfG4gK8s6RwsFxjqtiZJhvvB0tWWvTAQF 26hFejEoEOetCDY6Uhm4an0lSRGqi6H0DhlRT+TSwT3MQrcGguSAgFv32eIBbJ1v3Fw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796082473; h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID: In-Reply-To:References:X-sashiko-severity:Content-Type: Content-Transfer-Encoding:MIME-Version; bh=jyKKxd1maa3F9Oi1WBVTuWcwZabBuobyC5JUKTTjgEs=; b=Pg+wdsobpnFfoGH4ttLIsqRc8FP6qnMx6It6sToCWHVUagYtMBUjX3cZQ9c9HNpMgrYr cVh7QV49yCYeKvlA6f2rMUa8l5B6HnoDuqQ2/BDEFJUJmLnW8GNSXt6WpAvtDAz7Qqh1J +HybfW/brMOp0+VDfIHQRB1tFVJ+8rhU39HxQSqc/hpcd8RRvILrVAMUgMyNo2U3DmBBr Bfzs2cPrWv8xzwj/TevfA+EUfC2qg4B4L/G4cjD4VfVSQBHLpyY57mrrcM857Hvn93y50 qHlwcDhR/05ZcKxwjFIBWovgpToitvzb1s4A4dO0wdk1BeIovKuDMzsfC70T9xN70YQ== 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=dmlQxSPJ; arc=none smtp.remote-ip=100.103.45.18 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 B6C7F606A32E; Mon, 30 Nov 2026 23:47:53 +0000 (UTC) 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=dmlQxSPJ Received: by smtp.kernel.org (Postfix) with ESMTPSA id C7A941F00927; Mon, 30 Nov 2026 23:47:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796082473; bh=jyKKxd1maa3F9Oi1WBVTuWcwZabBuobyC5JUKTTjgEs=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=dmlQxSPJNhwqAl0DkLsbfVgTRfFCaH6VVPf8Lf9t4wYvYk2sApzDcvEIh4m+8HPEk OlZ1k1A0rKDuZ/9up6WAps+LtWf3mRDoiV+38HewePL00LYjF/dPsg731D+R9uTUTv 6YDc8PhyH6MEQmVtQWtv1Xxig2XB9A6/PN/frjeGg26O53mHZQBKBDNHkbGGwjELqF aYYAPCxUEPyn4Ei0RhtYpoaWDiI/WrKl3df4WvBcjtEwJz6uPgNoWgDGpY0ZKbAdNJ /yB/w0ce9johMI9E0SgIajzzHykFO3jQZuZ5XnGrSTxZ5N3St6RgXgh36wGyyoHZSL hwFw0Q6M4X9Uw== Subject: Re: [PATCH net-next v23 10/15] net: Document PCS subsystem From: netdev-bot+sashiko@kernel.org To: ansuelsmth@gmail.com Cc: andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com, robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org, willemb@google.com, 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-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, llvm@lists.linux.dev, zhengping.zhang@airoha.com Date: Mon, 30 Nov 2026 23:47:51 +0000 Message-ID: <179608247135.3146.5515172354102212593@kernel.org> In-Reply-To: <20261129230558.612526-11-ansuelsmth@gmail.com> References: <20261129230558.612526-11-ansuelsmth@gmail.com> X-sashiko-severity: Medium Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit X-Mailing-List: netdev@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Thank you for your contribution! Sashiko AI review found 5 potential issue(s) to consider. Critical: 0 · High: 0 · Medium: 2 · Low: 3 If you believe none of the issues are legitimate, please reply to each issue of Medium severity or higher and explain why the AI is wrong. If any of them are legitimate and you plan to respin, please let patchwork know by including "pw-bot: cr" as a separate line at the end of your reply (one such reply per series is enough). - [Medium] The consumer example in Documentation/networking/pcs.rst (mac_setup_phylink, lines ~137-147) sets config->num_possible_pcs =… - [Medium] pcs.rst (lines 72-73) says ``supported_interfaces`` "describes all interface modes supported by the MAC, whereas ``pcs_interfaces``… - [Low] pcs.rst (lines 68-70) says "A PCS is considered eligible when the requested interface mode is present in both ``pcs_interfaces`` in… - [Low] The 'Late PCS registration handling' section of pcs.rst misdescribes the implementation in several places, and some cross-… - [Low] pcs.rst line 165 says "Ownership of PCS is held by phylink." Read as a lifetime statement, this contradicts the implementation and the… -- net: Document PCS subsystem This commit adds Documentation/networking/pcs.rst. It documents the new PCS subsystem, the fwnode producer/consumer API and how phylink handles late PCS registration. It also updates the sfp-phylink migration guide to use num_possible_pcs and fill_available_pcs instead of mac_select_pcs. > diff --git a/Documentation/networking/pcs.rst b/Documentation/networking/pcs.rst > new file mode 100644 > index 0000000000000..03b7de73a1065 > --- /dev/null > +++ b/Documentation/networking/pcs.rst > @@ -0,0 +1,257 @@ [ ... ] > +A PCS is considered eligible when the requested interface mode is present > +in both ``pcs_interfaces`` in :c:struct:`phylink_config` struct and > +``supported_interfaces`` in :c:struct:`phylink_pcs` struct. [Severity: Low] Is this eligibility rule complete? phylink_validate_pcs_interface() in drivers/net/phy/phylink.c treats an empty PCS mask as a wildcard: if (phy_interface_empty(pcs->supported_interfaces)) return 0; phylink_parse_supported_interfaces() also skips the AND in that case: if (!phy_interface_empty(pcs->supported_interfaces)) phy_interface_and(pcs_interfaces, pcs_interfaces, pcs->supported_interfaces); So a provider that leaves supported_interfaces empty gets selected for every mode in pcs_interfaces, not for none of them. Could this paragraph, and maybe the struct phylink_pcs kernel-doc, mention the empty-mask behaviour? > +``supported_interfaces`` describes all interface modes supported by the MAC, > +whereas ``pcs_interfaces`` identifies the subset that require PCS selection. [Severity: Medium] Does this match how phylink builds pl->supported_interfaces? The previous paragraph names supported_interfaces in struct phylink_pcs. The kernel-doc in include/linux/phylink.h describes that field as the modes "supported by this PCS", not by the MAC. The model also seems to be the opposite of what the code expects. phylink_parse_supported_interfaces() assumes PCS-only modes are absent from config->supported_interfaces: phy_interface_copy(pl->supported_interfaces, pl->config->supported_interfaces); /* * Only add PCS-supported modes that phylink will select a PCS for. * Otherwise, phylink may accept a PCS-only mode and configure it without * a PCS. */ phylink_sfp_module_insert() only defers when the module's interfaces miss pl->supported_interfaces: if (!caps->may_have_phy && !bitmap_intersects(caps->interfaces, pl->supported_interfaces, PHY_INTERFACE_MODE_MAX) && bitmap_intersects(caps->interfaces, pl->config->pcs_interfaces, PHY_INTERFACE_MODE_MAX)) return -EAGAIN; This paragraph makes pcs_interfaces a subset of config->supported_interfaces, and the mac_setup_phylink() example below sets USXGMII in both masks. In that case USXGMII is always in pl->supported_interfaces. Wouldn't that mean three things? - The -EAGAIN deferral and the sfp_upstream_retry_module() retry described in the late registration section can never trigger. - phylink_validate_mac_and_pcs() accepts USXGMII without a PCS. - phylink_major_config() then fails with "couldn't find a PCS". Step 13 of sfp-phylink.rst still tells readers to fill supported_interfaces with what "your MAC and all PCS associated with this MAC are capable of", which points the same way. [ ... ] > + // Parse possible PCS and fill num_possible_pcs > + config->num_possible_pcs = fwnode_phylink_pcs_count(dev_fwnode(&netdev->dev)); > + config->fill_available_pcs = mac_fill_available_pcs; > + > + __set_bit(PHY_INTERFACE_MODE_INTERNAL, config->supported_interfaces); > + __set_bit(PHY_INTERFACE_MODE_SGMII, config->supported_interfaces); > + __set_bit(PHY_INTERFACE_MODE_1000BASEX, config->supported_interfaces); > + __set_bit(PHY_INTERFACE_MODE_USXGMII, config->supported_interfaces); > + > + // PCS required only for USXGMII > + __set_bit(PHY_INTERFACE_MODE_USXGMII, config->pcs_interfaces); > + > + phylink = phylink_create(config, //... [Severity: Medium] What happens with this example when fwnode_phylink_pcs_count() returns 0? That happens when the node has no pcs-handle. It also always happens with CONFIG_FWNODE_PCS=n, where the stub is: static inline unsigned int fwnode_phylink_pcs_count(struct fwnode_handle *fwnode) { return 0; } fill_available_pcs and pcs_interfaces are still set unconditionally, so phylink_create() rejects the configuration: if (has_pcs_interfaces != has_pcs_callback || has_pcs_interfaces != has_pcs_count) { dev_err(config->dev, "phylink: error: pcs_interfaces, num_possible_pcs and fill_available_pcs must be set together\n"); return ERR_PTR(-EINVAL); } A driver that copies this example would then fail to probe, even for SGMII, 1000BASE-X and INTERNAL, which the example says need no PCS. PHYLINK does not select FWNODE_PCS. Should the example set the PCS fields only when the count is non-zero? Should the text say that all three fields must be left unset when no PCS is described? The example also takes the fwnode from &netdev->dev. It doesn't say that the netdev needs an fwnode assigned, so a count of 0 is more likely. Step 12 in sfp-phylink.rst only asks for num_possible_pcs and fill_available_pcs. Could it also mention pcs_interfaces? Following that step alone hits the same -EINVAL. [ ... ] > +The ``fill_available_pcs`` callback is called on :c:func:`phylink_create` > +and on provider notification and can be called multiple times. > +It's used to compose the available PCS list at the time of calling and > +will be called again when a PCS provider is released or a new one is attached. > +Ownership of PCS is held by phylink. [Severity: Low] Is the last sentence accurate? The fwnode_pcs_add_provider() kernel-doc in include/linux/pcs/pcs-provider.h, which this page renders in its API Reference, says the opposite: * A PCS object belongs to one provider and must remain valid until that * provider is removed. phylink never allocates, refcounts or frees struct phylink_pcs. phylink_add_pcs() only links the PCS into pl->pcs_list and sets pcs->phylink. fwnode_pcs_free_provider() only unlinks provider_list. If the intent is that phylink tracks which instance a PCS is attached to, could the sentence say that? As written, a provider author could free the PCS before fwnode_pcs_del_provider() runs, which would leave a dangling pointer in pl->pcs_list. [ ... ] > +Late PCS registration handling > +------------------------------ > + > +It's possible that a PCS becomes available after the MAC finished probing. > +Contrary to the usual producer/consumer implementation, when a PCS is not > +registered and can't be found, the fwnode parser helper returns ``-ENODEV`` > +instead of ``-EPROBE_DEFER``. [ ... ] > +The PCS fwnode implementation provides a notifier to which each phylink > +instance with a non-empty ``pcs_interfaces`` in :c:type:`phylink_config` > +registers. When a new PCS provider is registered, the notifier is called > +triggering the :c:func:`pcs_provider_notify` function. > + > +On receiving a PCS provider event, :c:func:`pcs_provider_notify` will > +reprase the available PCS by calling the ``fill_available_pcs`` callback > +and update the internal PCS list for the phylink instance with both the > +removed and the newly available PCS and a phylink major config is forced. [ ... ] > +In an SFP scenario, with no currently usable interface, phylink defers module > +insertion with ``-EAGAIN`` if the module supports an interface listed in > +``pcs_interfaces`` and the SFP socket waits with its transmitter disabled. > +After phylink adds a PCS to its list and refreshes its interface mask, it > +calls ``sfp_upstream_retry_module()`` and if there is usable interface, > +the SFP the module insertion is retried. [Severity: Low] A few statements in this section don't seem to match the implementation. fwnode_phylink_pcs_parse() doesn't return -ENODEV for an unregistered PCS. It skips those references and returns the number it found. It returns -ENODEV only when pcs-handle is absent, and the !CONFIG_FWNODE_PCS stub returns -EOPNOTSUPP. Was fwnode_pcs_get() the helper meant here? A major config isn't forced on every provider event. phylink_pcs_changed() only forces one when a major config was already pending or had failed: if (!test_bit(PHYLINK_DISABLE_STOPPED, &pl->phylink_disable_state) && (pl->force_major_config || pl->major_config_failed)) { pl->force_major_config = true; pl->link_failed = true; } During init it only marks PCS_STATE_INIT_PENDING, so adding a PCS to a working link doesn't trigger a reconfiguration. The SFP deferral in phylink_sfp_module_insert() also requires !caps->may_have_phy, so modules that may carry a PHY are never deferred. Should that condition be mentioned here? Some cross-references won't resolve: - pcs_provider_notify() is a static function in phylink.c, and no kernel-doc directive pulls it in. - In step 12 of sfp-phylink.rst, num_possible_pcs and fill_available_pcs are members of struct phylink_config, so the :c:var: and :c:func: roles won't resolve them. There are also some typos: - "reprase" should be "reparse". - "the SFP the module insertion is retried" has a doubled "the". - There are doubled spaces in "helper function" and "for that". -- Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261129230558.612526-1-ansuelsmth%40gmail.com