2023-08-01 15:59:08

by Vladimir Oltean

[permalink] [raw]
Subject: [PATCH v9 net-next 00/12] Introduce ndo_hwtstamp_get() and ndo_hwtstamp_set()

Based on previous RFCs from Maxim Georgiev:
https://lore.kernel.org/netdev/[email protected]/

this series attempts to introduce new API for the hardware timestamping
control path (SIOCGHWTSTAMP and SIOCSHWTSTAMP handling).

I don't have any board with phylib hardware timestamping, so I would
appreciate testing (especially on lan966x, the most intricate
conversion). I was, however, able to test netdev level timestamping,
because I also have some more unsubmitted conversions in progress:

https://github.com/vladimiroltean/linux/commits/ndo-hwtstamp-v9

I hope that the concerns expressed in the comments of previous series
were addressed, and that Köry Maincent's series:
https://lore.kernel.org/netdev/[email protected]/
can make progress in parallel with the conversion of the rest of drivers.

Maxim Georgiev (5):
net: add NDOs for configuring hardware timestamping
net: add hwtstamping helpers for stackable net devices
net: vlan: convert to ndo_hwtstamp_get() / ndo_hwtstamp_set()
net: macvlan: convert to ndo_hwtstamp_get() / ndo_hwtstamp_set()
net: bonding: convert to ndo_hwtstamp_get() / ndo_hwtstamp_set()

Vladimir Oltean (7):
net: fec: convert to ndo_hwtstamp_get() and ndo_hwtstamp_set()
net: fec: delete fec_ptp_disable_hwts()
net: sparx5: convert to ndo_hwtstamp_get() and ndo_hwtstamp_set()
net: lan966x: convert to ndo_hwtstamp_get() and ndo_hwtstamp_set()
net: transfer rtnl_lock() requirement from
ethtool_set_ethtool_phy_ops() to caller
net: phy: provide phylib stubs for hardware timestamping operations
net: remove phy_has_hwtstamp() -> phy_mii_ioctl() decision from
converted drivers

MAINTAINERS | 1 +
drivers/net/bonding/bond_main.c | 105 ++++++----
drivers/net/ethernet/freescale/fec.h | 6 +-
drivers/net/ethernet/freescale/fec_main.c | 62 +++---
drivers/net/ethernet/freescale/fec_ptp.c | 43 ++--
.../ethernet/microchip/lan966x/lan966x_main.c | 58 +++---
.../ethernet/microchip/lan966x/lan966x_main.h | 12 +-
.../ethernet/microchip/lan966x/lan966x_ptp.c | 34 ++--
.../ethernet/microchip/sparx5/sparx5_main.h | 9 +-
.../ethernet/microchip/sparx5/sparx5_netdev.c | 35 ++--
.../ethernet/microchip/sparx5/sparx5_ptp.c | 24 ++-
drivers/net/macvlan.c | 34 ++--
drivers/net/phy/Makefile | 2 +
drivers/net/phy/phy.c | 34 ++++
drivers/net/phy/phy_device.c | 26 +++
drivers/net/phy/stubs.c | 10 +
include/linux/net_tstamp.h | 30 +++
include/linux/netdevice.h | 25 +++
include/linux/phy.h | 7 +
include/linux/phylib_stubs.h | 68 +++++++
net/8021q/vlan_dev.c | 27 ++-
net/core/dev_ioctl.c | 184 +++++++++++++++++-
net/ethtool/common.c | 3 +-
23 files changed, 630 insertions(+), 209 deletions(-)
create mode 100644 drivers/net/phy/stubs.c
create mode 100644 include/linux/phylib_stubs.h

--
2.34.1



2023-08-01 16:18:04

by Vladimir Oltean

[permalink] [raw]
Subject: [PATCH v9 net-next 07/12] net: fec: delete fec_ptp_disable_hwts()

Commit 340746398b67 ("net: fec: fix hardware time stamping by external
devices") was overly cautious with calling fec_ptp_disable_hwts() when
cmd == SIOCSHWTSTAMP and use_fec_hwts == false, because use_fec_hwts is
based on a runtime invariant (phy_has_hwtstamp()). Thus, if use_fec_hwts
is false, then fep->hwts_tx_en and fep->hwts_rx_en cannot be changed at
runtime; their values depend on the initial memory allocation, which
already sets them to zeroes.

If the core will ever gain support for switching timestamping layers,
it will arrange for a more organized calling convention and disable
timestamping in the previous layer as a first step. This means that the
code in the FEC driver is not necessary in any case.

The purpose of this change is to arrange the phy_has_hwtstamp() code in
a way in which it can be refactored away into generic logic.

Signed-off-by: Vladimir Oltean <[email protected]>
Reviewed-by: Jacob Keller <[email protected]>
Reviewed-by: Wei Fang <[email protected]>
---
Changes in v8-v9:
- None
Changes in v7:
- Patch is new

drivers/net/ethernet/freescale/fec.h | 1 -
drivers/net/ethernet/freescale/fec_main.c | 5 +----
drivers/net/ethernet/freescale/fec_ptp.c | 12 ------------
3 files changed, 1 insertion(+), 17 deletions(-)

diff --git a/drivers/net/ethernet/freescale/fec.h b/drivers/net/ethernet/freescale/fec.h
index ec64067ca782..110f2e9f3e3f 100644
--- a/drivers/net/ethernet/freescale/fec.h
+++ b/drivers/net/ethernet/freescale/fec.h
@@ -698,7 +698,6 @@ struct fec_enet_private {
void fec_ptp_init(struct platform_device *pdev, int irq_idx);
void fec_ptp_stop(struct platform_device *pdev);
void fec_ptp_start_cyclecounter(struct net_device *ndev);
-void fec_ptp_disable_hwts(struct net_device *ndev);
int fec_ptp_set(struct net_device *ndev, struct kernel_hwtstamp_config *config,
struct netlink_ext_ack *extack);
void fec_ptp_get(struct net_device *ndev, struct kernel_hwtstamp_config *config);
diff --git a/drivers/net/ethernet/freescale/fec_main.c b/drivers/net/ethernet/freescale/fec_main.c
index bbd0cc97905a..6d81fff0227e 100644
--- a/drivers/net/ethernet/freescale/fec_main.c
+++ b/drivers/net/ethernet/freescale/fec_main.c
@@ -3895,11 +3895,8 @@ static int fec_hwtstamp_set(struct net_device *ndev,
struct fec_enet_private *fep = netdev_priv(ndev);
struct phy_device *phydev = ndev->phydev;

- if (phy_has_hwtstamp(phydev)) {
- fec_ptp_disable_hwts(ndev);
-
+ if (phy_has_hwtstamp(phydev))
return phy_mii_ioctl(phydev, config->ifr, SIOCSHWTSTAMP);
- }

if (!netif_running(ndev))
return -EINVAL;
diff --git a/drivers/net/ethernet/freescale/fec_ptp.c b/drivers/net/ethernet/freescale/fec_ptp.c
index befd49b8bd71..181d9bfbee22 100644
--- a/drivers/net/ethernet/freescale/fec_ptp.c
+++ b/drivers/net/ethernet/freescale/fec_ptp.c
@@ -605,18 +605,6 @@ static int fec_ptp_enable(struct ptp_clock_info *ptp,
}
}

-/**
- * fec_ptp_disable_hwts - disable hardware time stamping
- * @ndev: pointer to net_device
- */
-void fec_ptp_disable_hwts(struct net_device *ndev)
-{
- struct fec_enet_private *fep = netdev_priv(ndev);
-
- fep->hwts_tx_en = 0;
- fep->hwts_rx_en = 0;
-}
-
int fec_ptp_set(struct net_device *ndev, struct kernel_hwtstamp_config *config,
struct netlink_ext_ack *extack)
{
--
2.34.1


2023-08-03 03:10:19

by patchwork-bot+netdevbpf

[permalink] [raw]
Subject: Re: [PATCH v9 net-next 00/12] Introduce ndo_hwtstamp_get() and ndo_hwtstamp_set()

Hello:

This series was applied to netdev/net-next.git (main)
by Jakub Kicinski <[email protected]>:

On Tue, 1 Aug 2023 17:28:12 +0300 you wrote:
> Based on previous RFCs from Maxim Georgiev:
> https://lore.kernel.org/netdev/[email protected]/
>
> this series attempts to introduce new API for the hardware timestamping
> control path (SIOCGHWTSTAMP and SIOCSHWTSTAMP handling).
>
> I don't have any board with phylib hardware timestamping, so I would
> appreciate testing (especially on lan966x, the most intricate
> conversion). I was, however, able to test netdev level timestamping,
> because I also have some more unsubmitted conversions in progress:
>
> [...]

Here is the summary with links:
- [v9,net-next,01/12] net: add NDOs for configuring hardware timestamping
https://git.kernel.org/netdev/net-next/c/66f7223039c0
- [v9,net-next,02/12] net: add hwtstamping helpers for stackable net devices
https://git.kernel.org/netdev/net-next/c/e47d01fea663
- [v9,net-next,03/12] net: vlan: convert to ndo_hwtstamp_get() / ndo_hwtstamp_set()
https://git.kernel.org/netdev/net-next/c/65c9fde15a65
- [v9,net-next,04/12] net: macvlan: convert to ndo_hwtstamp_get() / ndo_hwtstamp_set()
https://git.kernel.org/netdev/net-next/c/0bca3f7f9acd
- [v9,net-next,05/12] net: bonding: convert to ndo_hwtstamp_get() / ndo_hwtstamp_set()
https://git.kernel.org/netdev/net-next/c/c0dabeb4c666
- [v9,net-next,06/12] net: fec: convert to ndo_hwtstamp_get() and ndo_hwtstamp_set()
https://git.kernel.org/netdev/net-next/c/ef5eb9c5ce45
- [v9,net-next,07/12] net: fec: delete fec_ptp_disable_hwts()
https://git.kernel.org/netdev/net-next/c/547b006d1922
- [v9,net-next,08/12] net: sparx5: convert to ndo_hwtstamp_get() and ndo_hwtstamp_set()
https://git.kernel.org/netdev/net-next/c/7bdde44463b2
- [v9,net-next,09/12] net: lan966x: convert to ndo_hwtstamp_get() and ndo_hwtstamp_set()
https://git.kernel.org/netdev/net-next/c/54e1ed69c40a
- [v9,net-next,10/12] net: transfer rtnl_lock() requirement from ethtool_set_ethtool_phy_ops() to caller
https://git.kernel.org/netdev/net-next/c/70ef7d87f62a
- [v9,net-next,11/12] net: phy: provide phylib stubs for hardware timestamping operations
https://git.kernel.org/netdev/net-next/c/60495b6622ca
- [v9,net-next,12/12] net: remove phy_has_hwtstamp() -> phy_mii_ioctl() decision from converted drivers
https://git.kernel.org/netdev/net-next/c/fd770e856e22

You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html