net: enetc: convert to ndo_hwtstamp_get() and ndo_hwtstamp_set()
Subsystems (3)
Vladimir Oltean
maintainerPATCH v2 1/1 net: enetc: convert to ndo_hwtstamp_get() and ndo_hwtstamp_set()
New timestamping API was introduced in commit 66f7223039c0 ("net: add NDOs for configuring hardware timestamping") from kernel v6.6. It is time to convert the ENETC driver to the new API, so that the ndo_eth_ioctl() path can be removed completely.
Move the enetc_hwtstamp_get() and enetc_hwtstamp_set() calls away from enetc_ioctl() to dedicated net_device_ops for the LS1028A PF and VF (NETC v4 does not yet implement enetc_ioctl()), adapt the prototypes and export these symbols (enetc_ioctl() is also exported).
---v1->v2:
- remove shim definitions of enetc_hwtstamp_set() and enetc_hwtstamp_get(), replace them with "return -EOPNOTSUPP" if CONFIG_FSL_ENETC_PTP_CLOCK is not enabled.
- delete unnecessary config->flags = 0 assignment
drivers/net/ethernet/freescale/enetc/enetc.c | 47 +++++++++---------- drivers/net/ethernet/freescale/enetc/enetc.h | 6 +++ .../net/ethernet/freescale/enetc/enetc_pf.c | 2 + .../net/ethernet/freescale/enetc/enetc_vf.c | 2 + 4 files changed, 31 insertions(+), 26 deletions(-)
drivers/net/ethernet/freescale/enetc/enetc.c +21 -26
@@ -3296,16 +3296,17 @@ void enetc_set_features(struct net_device *ndev, netdev_features_t features) }EXPORT_SYMBOL_GPL (enetc_set_features); -static int enetc_hwtstamp_set (struct net_device *ndev,struct ifreq *ifr) +int enetc_hwtstamp_set (struct net_device *ndev, +struct kernel_hwtstamp_config *config, +struct netlink_ext_ack *extack) {struct enetc_ndev_priv *priv =netdev_priv (ndev);int err, new_offloads = priv->active_offloads; -struct hwtstamp_config config; -if (copy_from_user (&config, ifr->ifr_data,sizeof (config))) -return -EFAULT ; +if (!IS_ENABLED (CONFIG_FSL_ENETC_PTP_CLOCK )) +return -EOPNOTSUPP ; -switch (config.tx_type) { +switch (config->tx_type) {case HWTSTAMP_TX_OFF : new_offloads &= ~ENETC_F_TX_TSTAMP_MASK ;break ;
@@ -3324,13 +3325,13 @@ static int enetc_hwtstamp_set(struct net_device *ndev, struct ifreq *ifr)return -ERANGE ; } -switch (config.rx_filter) { +switch (config->rx_filter) {case HWTSTAMP_FILTER_NONE : new_offloads &= ~ENETC_F_RX_TSTAMP ;break ;default : new_offloads |=ENETC_F_RX_TSTAMP ; - config.rx_filter =HWTSTAMP_FILTER_ALL ; + config->rx_filter =HWTSTAMP_FILTER_ALL ; }if ((new_offloads ^ priv->active_offloads) &ENETC_F_RX_TSTAMP ) {
@@ -3343,42 +3344,36 @@ static int enetc_hwtstamp_set(struct net_device *ndev, struct ifreq *ifr) priv->active_offloads = new_offloads; -return copy_to_user (ifr->ifr_data, &config,sizeof (config)) ? - -EFAULT :0 ; +return 0 ; } +EXPORT_SYMBOL_GPL (enetc_hwtstamp_set); -static int enetc_hwtstamp_get (struct net_device *ndev,struct ifreq *ifr) +int enetc_hwtstamp_get (struct net_device *ndev, +struct kernel_hwtstamp_config *config) {struct enetc_ndev_priv *priv =netdev_priv (ndev); -struct hwtstamp_config config; - config.flags =0 ; +if (!IS_ENABLED (CONFIG_FSL_ENETC_PTP_CLOCK )) +return -EOPNOTSUPP ;if (priv->active_offloads &ENETC_F_TX_ONESTEP_SYNC_TSTAMP ) - config.tx_type =HWTSTAMP_TX_ONESTEP_SYNC ; + config->tx_type =HWTSTAMP_TX_ONESTEP_SYNC ;else if (priv->active_offloads &ENETC_F_TX_TSTAMP ) - config.tx_type =HWTSTAMP_TX_ON ; + config->tx_type =HWTSTAMP_TX_ON ;else - config.tx_type =HWTSTAMP_TX_OFF ; + config->tx_type =HWTSTAMP_TX_OFF ; - config.rx_filter = (priv->active_offloads &ENETC_F_RX_TSTAMP ) ? -HWTSTAMP_FILTER_ALL :HWTSTAMP_FILTER_NONE ; + config->rx_filter = (priv->active_offloads &ENETC_F_RX_TSTAMP ) ? +HWTSTAMP_FILTER_ALL :HWTSTAMP_FILTER_NONE ; -return copy_to_user (ifr->ifr_data, &config,sizeof (config)) ? - -EFAULT :0 ; +return 0 ; } +EXPORT_SYMBOL_GPL (enetc_hwtstamp_get);int enetc_ioctl (struct net_device *ndev,struct ifreq *rq,int cmd) {struct enetc_ndev_priv *priv =netdev_priv (ndev); -if (IS_ENABLED (CONFIG_FSL_ENETC_PTP_CLOCK )) { -if (cmd ==SIOCSHWTSTAMP ) -return enetc_hwtstamp_set (ndev, rq); -if (cmd ==SIOCGHWTSTAMP ) -return enetc_hwtstamp_get (ndev, rq); - } -if (!priv->phylink)return -EOPNOTSUPP ;
drivers/net/ethernet/freescale/enetc/enetc.h +6 -0
@@ -518,6 +518,12 @@ int enetc_setup_bpf(struct net_device *ndev, struct netdev_bpf *bpf);int enetc_xdp_xmit (struct net_device *ndev,int num_frames,struct xdp_frame **frames,u32 flags); +int enetc_hwtstamp_get (struct net_device *ndev, +struct kernel_hwtstamp_config *config); +int enetc_hwtstamp_set (struct net_device *ndev, +struct kernel_hwtstamp_config *config, +struct netlink_ext_ack *extack); +/* ethtool */ extern const struct ethtool_ops enetc_pf_ethtool_ops;extern const struct ethtool_ops enetc4_pf_ethtool_ops;
drivers/net/ethernet/freescale/enetc/enetc_pf.c +2 -0
@@ -631,6 +631,8 @@ static const struct net_device_ops enetc_ndev_ops = { .ndo_setup_tc = enetc_pf_setup_tc, .ndo_bpf = enetc_setup_bpf, .ndo_xdp_xmit = enetc_xdp_xmit, + .ndo_hwtstamp_get = enetc_hwtstamp_get, + .ndo_hwtstamp_set = enetc_hwtstamp_set, }; static struct phylink_pcs *
drivers/net/ethernet/freescale/enetc/enetc_vf.c +2 -0
@@ -121,6 +121,8 @@ static const struct net_device_ops enetc_ndev_ops = { .ndo_set_features = enetc_vf_set_features, .ndo_eth_ioctl = enetc_ioctl, .ndo_setup_tc = enetc_vf_setup_tc, + .ndo_hwtstamp_get = enetc_hwtstamp_get, + .ndo_hwtstamp_set = enetc_hwtstamp_set, }; static void enetc_vf_netdev_setup(struct enetc_si *si, struct net_device *ndev,
Signature · 1 line
2.43.0
Quoted 10 lines
New timestamping API was introduced in commit
66f7223039c0("net: add NDOs for configuring hardware timestamping") from kernel v6.6. It is time to convert the ENETC driver to the new API, so that thendo_eth_ioctl()path can be removed completely.Move the
enetc_hwtstamp_get()andenetc_hwtstamp_set()calls away fromenetc_ioctl()to dedicatednet_device_opsfor the LS1028A PF and VF (NETC v4 does not yet implementenetc_ioctl()), adapt the prototypes and export these symbols (enetc_ioctl()is also exported).
Quoted 8 lines
Signed-off-by Vladimir Oltean <[email protected]>---
v1->v2:
- remove shim definitions ofenetc_hwtstamp_set()andenetc_hwtstamp_get(), replace them with "return-EOPNOTSUPP" ifCONFIG_FSL_ENETC_PTP_CLOCKis not enabled.
- delete unnecessaryconfig->flags= 0 assignment
ENETC v4 can add timestamp support based on these two new interfaces, thanks.
This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Quoted 11 lines · On Mon, 12 May 2025 14:24:02 +0300 you wrote:
New timestamping API was introduced in commit
66f7223039c0("net: add NDOs for configuring hardware timestamping") from kernel v6.6. It is time to convert the ENETC driver to the new API, so that thendo_eth_ioctl()path can be removed completely.Move the
enetc_hwtstamp_get()andenetc_hwtstamp_set()calls away fromenetc_ioctl()to dedicatednet_device_opsfor the LS1028A PF and VF (NETC v4 does not yet implementenetc_ioctl()), adapt the prototypes and export these symbols (enetc_ioctl()is also exported).[...]
Here is the summary with links:
- [v2,net-next] net: enetc: convert to ndo_hwtstamp_get() and ndo_hwtstamp_set()
https://git.kernel.org/netdev/net-next/c/51672a6587a0
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html