From: Claudiu Manoil <claudiu.manoil@nxp.com>
To: Wei Fang <wei.fang@nxp.com>
Cc: dl-S32 <S32@nxp.com>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
Vladimir Oltean <vladimir.oltean@nxp.com>,
Clark Wang <xiaoning.wang@nxp.com>,
Andrew Lunn <andrew+netdev@lunn.ch>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@kernel.org>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Rob Herring <robh@kernel.org>,
Saravana Kannan <saravanak@kernel.org>,
Russell King <linux@armlinux.org.uk>,
"imx@lists.linux.dev" <imx@lists.linux.dev>,
"devicetree@vger.kernel.org" <devicetree@vger.kernel.org>,
"netdev@vger.kernel.org" <netdev@vger.kernel.org>
Subject: RE: [PATCH net-next v2 1/5] net: enetc: Add pseudo-MAC support for ENETCv4 Ports via a fixed-link node
Date: Thu, 15 Oct 2026 13:20:56 +0000 [thread overview]
Message-ID: <GV2PR04MB1174099F6844DBF759BE22E0A969C2@GV2PR04MB11740.eurprd04.prod.outlook.com> (raw)
In-Reply-To: <AS4PR04MB933876A424328F6A6FCFD29C889C2@AS4PR04MB9338.eurprd04.prod.outlook.com>
From: Wei Fang <wei.fang@nxp.com>
Sent: Thursday, October 15, 2026 5:17 AM
[...]
> Subject: RE: [PATCH net-next v2 1/5] net: enetc: Add pseudo-MAC support for
> ENETCv4 Ports via a fixed-link node
>
> > diff --git a/drivers/net/ethernet/freescale/enetc/enetc.h
> > b/drivers/net/ethernet/freescale/enetc/enetc.h
> > index d9e91832a9c1..ed5402f1b73c 100644
> > --- a/drivers/net/ethernet/freescale/enetc/enetc.h
> > +++ b/drivers/net/ethernet/freescale/enetc/enetc.h
> > @@ -500,6 +500,7 @@ struct enetc_ndev_priv {
> >
> > struct clk *ref_clk; /* RGMII/RMII reference clock */
> > u64 sysclk_freq; /* NETC system clock frequency */
> > + struct of_changeset *ppm_ocs; /* pseudo-MAC fixed-link changeset
> */
>
> struct enetc_ndev_priv is shared by both PF and VF, but ppm_ocs is only
> used by PF. Would it be better to move it to struct enetc_pf?
>
Ok, will try this out.
> > };
[...]
> > +static int enetc4_add_ppm_fixed_link(struct enetc_ndev_priv *priv)
> > +{
> > + struct device_node *np = dev_of_node(priv->dev);
> > + struct device_node *fixed_link;
> > + struct of_changeset *ocs;
> > + int speed, err;
> > +
> > + if (!np)
> > + return dev_err_probe(priv->dev, -ENODEV,
> > + "Missing of_node for Pseudo-MAC port\n");
> > +
> > + enetc4_get_pcr_speed(&priv->si->hw, &speed);
> > + speed = enetc_phylink_match_pseudo_mac_speed(speed);
> > +
> > + ocs = kzalloc_obj(*ocs);
> > + if (!ocs)
> > + return -ENOMEM;
> > +
> > + of_changeset_init(ocs);
> > +
> > + fixed_link = of_changeset_create_node(ocs, np, "fixed-link");
> > + if (!fixed_link) {
> > + err = -ENOMEM;
> > + goto err_destroy;
> > + }
> > +
> > + err = of_changeset_add_prop_u32(ocs, fixed_link, "speed", speed);
> > + if (err)
> > + goto err_put_node;
> > +
> > + err = of_changeset_add_prop_bool(ocs, fixed_link, "full-duplex");
> > + if (err)
> > + goto err_put_node;
> > +
> > + err = of_changeset_apply(ocs);
> > + if (err)
> > + goto err_put_node;
> > +
> > + of_node_put(fixed_link);
> > + priv->ppm_ocs = ocs;
> > +
> > + return 0;
> > +
> > +err_put_node:
> > + of_node_put(fixed_link);
> > +err_destroy:
> > + of_changeset_destroy(ocs);
> > + kfree(ocs);
> > +
> > + return dev_err_probe(priv->dev, err,
> > + "Failed to add fixed-link node\n");
> > +}
> > +
> > static int enetc4_link_init(struct enetc_ndev_priv *priv,
> > struct device_node *node)
> > {
> > + bool dynamic = node && of_node_check_flag(node, OF_DYNAMIC);
> > struct enetc_pf *pf = enetc_si_priv(priv->si);
> > struct device *dev = priv->dev;
> > int err;
> >
> > - err = of_get_phy_mode(node, &pf->if_mode);
> > - if (err) {
> > - dev_err(dev, "Failed to get PHY mode\n");
> > - return err;
[...]
> > + if (enetc_is_pseudo_mac(priv->si) && (!node || dynamic)) {
>
> This indicates that the node pointer can be NULL, but
> enetc4_add_ppm_fixed_link() subsequently does not allow node
> to be NULL. This is puzzling.
enetc4_add_ppm_fixed_link() checks dev_of_node(priv->dev) and
if NULL, it returns error and prints following err message:
"Missing of_node for Pseudo-MAC port\n".
Which is fine for the enetc_is_pseudo_mac() case.
One alternative would be to take the common 'else' branch in case of NULL
node for the pseudo-MAC, and let of_get_phy_mode() return with error, but
in that case "Failed to get PHY mode\n" is not a good error indication.
So, nothing to change here, the 'if' branch check for the pseudo-MAC case is
correct as it is.
>
> > + pf->if_mode = PHY_INTERFACE_MODE_INTERNAL;
> > +
> > + err = enetc4_add_ppm_fixed_link(priv);
> > + if (err)
> > + return err;
> > +
> > + /* The fixed-link node was spliced onto dev's own of_node, so
> > + * phylink will find it via dev_fwnode(dev). Use that node for
> > + * the subsequent MDIO/phylink setup below.
> > + */
> > + node = dev_of_node(dev);
>
> Based on the implementation of enetc4_add_ppm_fixed_link(), the
> input parameter dev->of_node cannot be NULL. I'm not familiar
> with the of_changeset_* APIs. Will enetc4_add_ppm_fixed_link()
> update this pointer?
>
Sure, all these functions take 'np' as argument, and 'np' is
dev_of_node(priv->dev), which is the same as dev->of_node.
> > + } else {
> > + err = of_get_phy_mode(node, &pf->if_mode);
> > + if (err) {
> > + dev_err(dev, "Failed to get PHY mode\n");
> > + return err;
> > + }
> > }
> >
> > err = enetc_mdiobus_create(pf, node);
> > if (err) {
> > dev_err(dev, "Failed to create MDIO bus\n");
> > - return err;
> > + goto err_mdiobus_create;
> > }
> >
> > err = enetc_phylink_create(priv, node, &enetc_pl_mac_ops);
next prev parent reply other threads:[~2026-10-15 13:21 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-13 17:12 [PATCH net-next v2 0/5] net: enetc: S32N79 pseudo-MAC (PPM) networking support Claudiu Manoil
2026-10-13 17:12 ` [PATCH net-next v2 1/5] net: enetc: Add pseudo-MAC support for ENETCv4 Ports via a fixed-link node Claudiu Manoil
2026-10-15 2:16 ` Wei Fang
2026-10-15 13:20 ` Claudiu Manoil [this message]
2026-10-15 8:43 ` kernel test robot
2026-10-15 13:26 ` Claudiu Manoil
2026-10-13 17:12 ` [PATCH net-next v2 2/5] net: enetc: Enable probing of version 4.4 devices Claudiu Manoil
2026-10-15 1:42 ` Wei Fang
2026-10-15 13:31 ` Claudiu Manoil
2026-10-13 17:12 ` [PATCH net-next v2 3/5] arm64: dts: s32n79: add NETC IEP18 ECAM node for ENETC PPM ports Claudiu Manoil
2026-10-13 17:12 ` [PATCH net-next v2 4/5] arm64: dts: s32n79-rdb: enable NETC IEP18 Claudiu Manoil
2026-10-13 17:12 ` [PATCH net-next v2 5/5] PCI: Create OF node for NXP ENETC pseudo-MAC functions Claudiu Manoil
2026-10-16 8:15 [PATCH net-next v2 1/5] net: enetc: Add pseudo-MAC support for ENETCv4 Ports via a fixed-link node netdev-bot+sashiko
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=GV2PR04MB1174099F6844DBF759BE22E0A969C2@GV2PR04MB11740.eurprd04.prod.outlook.com \
--to=claudiu.manoil@nxp.com \
--cc=S32@nxp.com \
--cc=andrew+netdev@lunn.ch \
--cc=davem@davemloft.net \
--cc=devicetree@vger.kernel.org \
--cc=edumazet@kernel.org \
--cc=imx@lists.linux.dev \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=robh@kernel.org \
--cc=saravanak@kernel.org \
--cc=vladimir.oltean@nxp.com \
--cc=wei.fang@nxp.com \
--cc=xiaoning.wang@nxp.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®