netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Vadim Fedorenko <vadim.fedorenko@linux.dev>
To: Vladimir Oltean <vladimir.oltean@nxp.com>, netdev@vger.kernel.org
Cc: Bryan Whitehead <bryan.whitehead@microchip.com>,
	Raju Lakkaraju <Raju.Lakkaraju@microchip.com>,
	Vishvambar Panth S <vishvambarpanth.s@microchip.com>,
	UNGLinuxDriver@microchip.com, Andrew Lunn <andrew@lunn.ch>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	Simon Horman <horms@kernel.org>,
	Richard Cochran <richardcochran@gmail.com>
Subject: Re: [PATCH net-next 1/2] net: lan743x: convert to ndo_hwtstamp_set()
Date: Wed, 14 May 2025 22:25:03 +0100	[thread overview]
Message-ID: <68aefcfc-8a3b-49d0-94f9-072ce06a28df@linux.dev> (raw)
In-Reply-To: <20250514151931.1988047-1-vladimir.oltean@nxp.com>

On 14/05/2025 16:19, Vladimir Oltean 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 lan743x driver to the new API, so that
> timestamping configuration can be removed from the ndo_eth_ioctl()
> path completely.
> 
> Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
> ---
>   drivers/net/ethernet/microchip/lan743x_main.c |  3 +-
>   drivers/net/ethernet/microchip/lan743x_ptp.c  | 32 +++++--------------
>   drivers/net/ethernet/microchip/lan743x_ptp.h  |  4 ++-
>   3 files changed, 12 insertions(+), 27 deletions(-)
> 
> diff --git a/drivers/net/ethernet/microchip/lan743x_main.c b/drivers/net/ethernet/microchip/lan743x_main.c
> index 73dfc85fa67e..b01695bf4f55 100644
> --- a/drivers/net/ethernet/microchip/lan743x_main.c
> +++ b/drivers/net/ethernet/microchip/lan743x_main.c
> @@ -3351,8 +3351,6 @@ static int lan743x_netdev_ioctl(struct net_device *netdev,
>   
>   	if (!netif_running(netdev))
>   		return -EINVAL;
> -	if (cmd == SIOCSHWTSTAMP)
> -		return lan743x_ptp_ioctl(netdev, ifr, cmd);
>   
>   	return phylink_mii_ioctl(adapter->phylink, ifr, cmd);
>   }
> @@ -3447,6 +3445,7 @@ static const struct net_device_ops lan743x_netdev_ops = {
>   	.ndo_change_mtu		= lan743x_netdev_change_mtu,
>   	.ndo_get_stats64	= lan743x_netdev_get_stats64,
>   	.ndo_set_mac_address	= lan743x_netdev_set_mac_address,
> +	.ndo_hwtstamp_set	= lan743x_ptp_hwtstamp_set,
>   };
>   
>   static void lan743x_hardware_cleanup(struct lan743x_adapter *adapter)
> diff --git a/drivers/net/ethernet/microchip/lan743x_ptp.c b/drivers/net/ethernet/microchip/lan743x_ptp.c
> index b07f5b099a2b..026d1660fd74 100644
> --- a/drivers/net/ethernet/microchip/lan743x_ptp.c
> +++ b/drivers/net/ethernet/microchip/lan743x_ptp.c
> @@ -1736,23 +1736,14 @@ void lan743x_ptp_tx_timestamp_skb(struct lan743x_adapter *adapter,
>   	lan743x_ptp_tx_ts_complete(adapter);
>   }
>   
> -int lan743x_ptp_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd)
> +int lan743x_ptp_hwtstamp_set(struct net_device *netdev,
> +			     struct kernel_hwtstamp_config *config,
> +			     struct netlink_ext_ack *extack)
>   {
>   	struct lan743x_adapter *adapter = netdev_priv(netdev);
> -	struct hwtstamp_config config;
> -	int ret = 0;
>   	int index;
>   
> -	if (!ifr) {
> -		netif_err(adapter, drv, adapter->netdev,
> -			  "SIOCSHWTSTAMP, ifr == NULL\n");
> -		return -EINVAL;
> -	}
> -
> -	if (copy_from_user(&config, ifr->ifr_data, sizeof(config)))
> -		return -EFAULT;
> -
> -	switch (config.tx_type) {
> +	switch (config->tx_type) {
>   	case HWTSTAMP_TX_OFF:
>   		for (index = 0; index < adapter->used_tx_channels;
>   		     index++)
> @@ -1776,19 +1767,12 @@ int lan743x_ptp_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd)
>   		lan743x_ptp_set_sync_ts_insert(adapter, true);
>   		break;
>   	case HWTSTAMP_TX_ONESTEP_P2P:
> -		ret = -ERANGE;
> -		break;
> +		return -ERANGE;
>   	default:
>   		netif_warn(adapter, drv, adapter->netdev,
> -			   "  tx_type = %d, UNKNOWN\n", config.tx_type);
> -		ret = -EINVAL;
> -		break;
> +			   "  tx_type = %d, UNKNOWN\n", config->tx_type);
> +		return -EINVAL;

nit: can be easily transformed to extack, but I can do it later as a
follow-up

>   	}
>   
> -	ret = lan743x_rx_set_tstamp_mode(adapter, config.rx_filter);
> -
> -	if (!ret)
> -		return copy_to_user(ifr->ifr_data, &config,
> -			sizeof(config)) ? -EFAULT : 0;
> -	return ret;
> +	return lan743x_rx_set_tstamp_mode(adapter, config->rx_filter);
>   }
> diff --git a/drivers/net/ethernet/microchip/lan743x_ptp.h b/drivers/net/ethernet/microchip/lan743x_ptp.h
> index 0d29914cd460..9581a7992ff6 100644
> --- a/drivers/net/ethernet/microchip/lan743x_ptp.h
> +++ b/drivers/net/ethernet/microchip/lan743x_ptp.h
> @@ -52,7 +52,9 @@ void lan743x_ptp_close(struct lan743x_adapter *adapter);
>   void lan743x_ptp_update_latency(struct lan743x_adapter *adapter,
>   				u32 link_speed);
>   
> -int lan743x_ptp_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd);
> +int lan743x_ptp_hwtstamp_set(struct net_device *netdev,
> +			     struct kernel_hwtstamp_config *config,
> +			     struct netlink_ext_ack *extack);
>   
>   #define LAN743X_PTP_NUMBER_OF_TX_TIMESTAMPS (4)
>   

Reviewed-by: Vadim Fedorenko <vadim.fedorenko@linux.dev>

  parent reply	other threads:[~2025-05-14 21:25 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-05-14 15:19 [PATCH net-next 1/2] net: lan743x: convert to ndo_hwtstamp_set() Vladimir Oltean
2025-05-14 15:19 ` [PATCH net-next 2/2] net: lan743x: implement ndo_hwtstamp_get() Vladimir Oltean
2025-05-14 19:00   ` Gerhard Engleder
2025-05-14 21:27   ` Vadim Fedorenko
2025-05-14 18:57 ` [PATCH net-next 1/2] net: lan743x: convert to ndo_hwtstamp_set() Gerhard Engleder
2025-05-14 21:25 ` Vadim Fedorenko [this message]
2025-05-16  1: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=68aefcfc-8a3b-49d0-94f9-072ce06a28df@linux.dev \
    --to=vadim.fedorenko@linux.dev \
    --cc=Raju.Lakkaraju@microchip.com \
    --cc=UNGLinuxDriver@microchip.com \
    --cc=andrew@lunn.ch \
    --cc=bryan.whitehead@microchip.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=horms@kernel.org \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=richardcochran@gmail.com \
    --cc=vishvambarpanth.s@microchip.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).