From: Kory Maincent <kory.maincent@bootlin.com>
To: Vadim Fedorenko <vadim.fedorenko@linux.dev>
Cc: Andrew Lunn <andrew+netdev@lunn.ch>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
netdev@vger.kernel.org, Vladimir Oltean <vladimir.oltean@nxp.com>
Subject: Re: [PATCH net-next v2] ti: netcp: convert to ndo_hwtstamp callbacks
Date: Mon, 3 Nov 2025 21:52:40 +0100 [thread overview]
Message-ID: <20251103215240.7057f8cb@kmaincent-XPS-13-7390> (raw)
In-Reply-To: <20251103172902.3538392-1-vadim.fedorenko@linux.dev>
On Mon, 3 Nov 2025 17:29:02 +0000
Vadim Fedorenko <vadim.fedorenko@linux.dev> wrote:
> Convert TI NetCP driver to use ndo_hwtstamp_get()/ndo_hwtstamp_set()
> callbacks. The logic is slightly changed, because I believe the original
> logic was not really correct. Config reading part is using the very
> first module to get the configuration instead of iterating over all of
> them and keep the last one as the configuration is supposed to be identical
> for all modules. HW timestamp config set path is now trying to configure
> all modules, but in case of error from one module it adds extack
> message. This way the configuration will be as synchronized as possible.
>
> There are only 2 modules using netcp core infrastructure, and both use
> the very same function to configure HW timestamping, so no actual
> difference in behavior is expected.
>
> Signed-off-by: Vadim Fedorenko <vadim.fedorenko@linux.dev>
> ---
> v1 -> v2:
> - avoid changing logic and hiding errors. keep the call failing after
> the first error
> ---
...
> +
> + for_each_module(netcp, intf_modpriv) {
> + module = intf_modpriv->netcp_module;
> + if (!module->hwtstamp_set)
> + continue;
> +
> + err = module->hwtstamp_set(intf_modpriv->module_priv, config,
> + extack);
> + if ((err < 0) && (err != -EOPNOTSUPP)) {
> + NL_SET_ERR_MSG_WEAK_MOD(extack,
> + "At least one module failed
> to setup HW timestamps");
> + ret = err;
> + goto out;
Why don't you use break.
> + }
> + if (err == 0)
> + ret = err;
> + }
> +
> +out:
> + return (ret == 0) ? 0 : err;
> +}
> +
...
> -static int gbe_hwtstamp_set(struct gbe_intf *gbe_intf, struct ifreq *ifr)
> +static int gbe_hwtstamp_set(void *intf_priv, struct kernel_hwtstamp_config
> *cfg,
> + struct netlink_ext_ack *extack)
> {
> - struct gbe_priv *gbe_dev = gbe_intf->gbe_dev;
> - struct cpts *cpts = gbe_dev->cpts;
> - struct hwtstamp_config cfg;
> + struct gbe_intf *gbe_intf = intf_priv;
> + struct gbe_priv *gbe_dev;
> + struct phy_device *phy;
>
> - if (!cpts)
> + gbe_dev = gbe_intf->gbe_dev;
> +
> + if (!gbe_dev->cpts)
> return -EOPNOTSUPP;
>
> - if (copy_from_user(&cfg, ifr->ifr_data, sizeof(cfg)))
> - return -EFAULT;
> + phy = gbe_intf->slave->phy;
> + if (phy_has_hwtstamp(phy))
> + return phy->mii_ts->hwtstamp(phy->mii_ts, cfg, extack);
Sorry to come back to this but the choice of using PHY or MAC timestamping is
done in the core. Putting this here may conflict with the core.
I know this driver has kind of a weird PHYs management through slave
description but we shouldn't let the MAC driver call the PHY hwtstamp ops.
If there is indeed an issue due to the weird development of this driver, people
will write a patch specifically tackling this issue and maybe (by luck)
refactoring this driver.
Anyway, this was not in the driver before, so I think we should not make this
change in this patch.
Regards,
--
Köry Maincent, Bootlin
Embedded Linux and kernel engineering
https://bootlin.com
next prev parent reply other threads:[~2025-11-03 20:52 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-03 17:29 [PATCH net-next v2] ti: netcp: convert to ndo_hwtstamp callbacks Vadim Fedorenko
2025-11-03 20:52 ` Kory Maincent [this message]
2025-11-04 12:15 ` Vadim Fedorenko
2025-11-04 13:39 ` Kory Maincent
2025-11-04 13:59 ` Vadim Fedorenko
2025-11-05 2:00 ` patchwork-bot+netdevbpf
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=20251103215240.7057f8cb@kmaincent-XPS-13-7390 \
--to=kory.maincent@bootlin.com \
--cc=andrew+netdev@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=vadim.fedorenko@linux.dev \
--cc=vladimir.oltean@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