netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Florian Fainelli <f.fainelli@gmail.com>
To: Vladimir Oltean <vladimir.oltean@nxp.com>, netdev@vger.kernel.org
Cc: "David S. Miller" <davem@davemloft.net>,
	"Eric Dumazet" <edumazet@google.com>,
	"Jakub Kicinski" <kuba@kernel.org>,
	"Paolo Abeni" <pabeni@redhat.com>, "Andrew Lunn" <andrew@lunn.ch>,
	"Maxim Georgiev" <glipus@gmail.com>,
	"Horatiu Vultur" <horatiu.vultur@microchip.com>,
	"Köry Maincent" <kory.maincent@bootlin.com>,
	"Maxime Chevallier" <maxime.chevallier@bootlin.com>
Subject: Re: [PATCH net-next 7/7] net: create a netdev notifier for DSA to reject PTP on DSA master
Date: Sun, 2 Apr 2023 06:01:25 -0700	[thread overview]
Message-ID: <355d4dad-c0a5-330f-5cee-37e87bacd449@gmail.com> (raw)
In-Reply-To: <20230402123755.2592507-8-vladimir.oltean@nxp.com>



On 4/2/2023 5:37 AM, Vladimir Oltean wrote:
> The fact that PTP 2-step TX timestamping is broken on DSA switches if
> the master also timestamps the same packets is documented by commit
> f685e609a301 ("net: dsa: Deny PTP on master if switch supports it").
> We attempt to help the users avoid shooting themselves in the foot by
> making DSA reject the timestamping ioctls on an interface that is a DSA
> master, and the switch tree beneath it contains switches which are aware
> of PTP.
> 
> The only problem is that there isn't an established way of intercepting
> ndo_eth_ioctl calls, so DSA creates avoidable burden upon the network
> stack by creating a struct dsa_netdevice_ops with overlaid function
> pointers that are manually checked from the relevant call sites. There
> used to be 2 such dsa_netdevice_ops, but now, ndo_eth_ioctl is the only
> one left.
> 
> There is an ongoing effort to migrate driver-visible hardware timestamping
> control from the ndo_eth_ioctl() based API to a new ndo_hwtstamp_set()
> model, but DSA actively prevents that migration, since dsa_master_ioctl()
> is currently coded to manually call the master's legacy ndo_eth_ioctl(),
> and so, whenever a network device driver would be converted to the new
> API, DSA's restrictions would be circumvented, because any device could
> be used as a DSA master.
> 
> The established way for unrelated modules to react on a net device event
> is via netdevice notifiers. So we create a new notifier which gets
> called whenever there is an attempt to change hardware timestamping
> settings on a device.
> 
> Finally, there is another reason why a netdev notifier will be a good
> idea, besides strictly DSA, and this has to do with PHY timestamping.
> 
> With ndo_eth_ioctl(), all MAC drivers must manually call
> phy_has_hwtstamp() before deciding whether to act upon SIOCSHWTSTAMP,
> otherwise they must pass this ioctl to the PHY driver via
> phy_mii_ioctl().
> 
> With the new ndo_hwtstamp_set() API, it will be desirable to simply not
> make any calls into the MAC device driver when timestamping should be
> performed at the PHY level.
> 
> But there exist drivers, such as the lan966x switch, which need to
> install packet traps for PTP regardless of whether they are the layer
> that provides the hardware timestamps, or the PHY is. That would be
> impossible to support with the new API.
> 
> The proposal there, too, is to introduce a netdev notifier which acts as
> a better cue for switching drivers to add or remove PTP packet traps,
> than ndo_hwtstamp_set(). The one introduced here "almost" works there as
> well, except for the fact that packet traps should only be installed if
> the PHY driver succeeded to enable hardware timestamping, whereas here,
> we need to deny hardware timestamping on the DSA master before it
> actually gets enabled. This is why this notifier is called "PRE_", and
> the notifier that would get used for PHY timestamping and packet traps
> would be called NETDEV_CHANGE_HWTSTAMP. This isn't a new concept, for
> example NETDEV_CHANGEUPPER and NETDEV_PRECHANGEUPPER do the same thing.
> 
> In expectation of future netlink UAPI, we also pass a non-NULL extack
> pointer to the netdev notifier, and we make DSA populate it with an
> informative reason for the rejection. To avoid making it go to waste, we
> make the ioctl-based dev_set_hwtstamp() create a fake extack and print
> the message to the kernel log.
> 
> Link: https://lore.kernel.org/netdev/20230401191215.tvveoi3lkawgg6g4@skbuf/
> Link: https://lore.kernel.org/netdev/20230310164451.ls7bbs6pdzs4m6pw@skbuf/
> Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>

Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
-- 
Florian

  reply	other threads:[~2023-04-02 13:01 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-02 12:37 [PATCH net-next 0/7] Convert dsa_master_ioctl() to netdev notifier Vladimir Oltean
2023-04-02 12:37 ` [PATCH net-next 1/7] net: don't abuse "default" case for unknown ioctl in dev_ifsioc() Vladimir Oltean
2023-04-02 12:46   ` Florian Fainelli
2023-04-02 12:37 ` [PATCH net-next 2/7] net: simplify handling of dsa_ndo_eth_ioctl() return code Vladimir Oltean
2023-04-02 12:47   ` Florian Fainelli
2023-04-02 12:37 ` [PATCH net-next 3/7] net: promote SIOCSHWTSTAMP and SIOCGHWTSTAMP ioctls to dedicated handlers Vladimir Oltean
2023-04-02 12:52   ` Florian Fainelli
2023-04-02 12:53     ` Vladimir Oltean
2023-04-02 12:56       ` Florian Fainelli
2023-04-02 13:01         ` Vladimir Oltean
2023-04-02 13:03           ` Florian Fainelli
2023-04-02 12:37 ` [PATCH net-next 4/7] net: move copy_from_user() out of net_hwtstamp_validate() Vladimir Oltean
2023-04-02 12:52   ` Florian Fainelli
2023-04-02 12:37 ` [PATCH net-next 5/7] net: add struct kernel_hwtstamp_config and make net_hwtstamp_validate() use it Vladimir Oltean
2023-04-02 12:57   ` Florian Fainelli
2023-04-02 12:37 ` [PATCH net-next 6/7] net: dsa: make dsa_port_supports_hwtstamp() construct a fake ifreq Vladimir Oltean
2023-04-02 12:57   ` Florian Fainelli
2023-04-02 12:37 ` [PATCH net-next 7/7] net: create a netdev notifier for DSA to reject PTP on DSA master Vladimir Oltean
2023-04-02 13:01   ` Florian Fainelli [this message]
2023-04-03 15:30   ` Jakub Kicinski
2023-04-03 16:48     ` Vladimir Oltean
2023-04-03  9:20 ` [PATCH net-next 0/7] Convert dsa_master_ioctl() to netdev notifier 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=355d4dad-c0a5-330f-5cee-37e87bacd449@gmail.com \
    --to=f.fainelli@gmail.com \
    --cc=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=glipus@gmail.com \
    --cc=horatiu.vultur@microchip.com \
    --cc=kory.maincent@bootlin.com \
    --cc=kuba@kernel.org \
    --cc=maxime.chevallier@bootlin.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --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;
as well as URLs for NNTP newsgroup(s).