From: Tariq Toukan <ttoukan.linux@gmail.com>
To: "Vadim Fedorenko" <vadim.fedorenko@linux.dev>,
"Jian Shen" <shenjian15@huawei.com>,
"Salil Mehta" <salil.mehta@huawei.com>,
"Jijie Shao" <shaojijie@huawei.com>,
"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>,
"Sunil Goutham" <sgoutham@marvell.com>,
"Geetha sowjanya" <gakula@marvell.com>,
"Subbaraya Sundeep" <sbhatta@marvell.com>,
"Bharat Bhushan" <bbhushan2@marvell.com>,
"Tariq Toukan" <tariqt@nvidia.com>,
"Brett Creeley" <brett.creeley@amd.com>,
"Niklas Söderlund" <niklas.soderlund@ragnatech.se>,
"Paul Barker" <paul@pbarker.dev>,
"Yoshihiro Shimoda" <yoshihiro.shimoda.uh@renesas.com>
Cc: linux-renesas-soc@vger.kernel.org,
Richard Cochran <richardcochran@gmail.com>,
Russell King <linux@armlinux.org.uk>,
Vladimir Oltean <vladimir.oltean@nxp.com>,
Simon Horman <horms@kernel.org>,
Jacob Keller <jacob.e.keller@intel.com>,
netdev@vger.kernel.org
Subject: Re: [PATCH net-next v2 2/6] mlx4: convert to ndo_hwtstamp API
Date: Mon, 20 Oct 2025 13:11:17 +0300 [thread overview]
Message-ID: <75c45f72-a0bf-4b72-8ba2-5b4c8073f21d@gmail.com> (raw)
In-Reply-To: <20251017182128.895687-3-vadim.fedorenko@linux.dev>
On 17/10/2025 21:21, Vadim Fedorenko wrote:
> Convert driver to use .ndo_hwtstamp_get()/.ndo_hwtstamp_set() callbacks.
> mlx4_en_ioctl() becomes empty, remove it.
>
> Reviewed-by: Jacob Keller <jacob.e.keller@intel.com>
> Signed-off-by: Vadim Fedorenko <vadim.fedorenko@linux.dev>
> ---
> .../net/ethernet/mellanox/mlx4/en_netdev.c | 61 ++++++++-----------
> drivers/net/ethernet/mellanox/mlx4/mlx4_en.h | 6 +-
> 2 files changed, 28 insertions(+), 39 deletions(-)
>
> diff --git a/drivers/net/ethernet/mellanox/mlx4/en_netdev.c b/drivers/net/ethernet/mellanox/mlx4/en_netdev.c
> index 308b4458e0d4..514f29f241c3 100644
> --- a/drivers/net/ethernet/mellanox/mlx4/en_netdev.c
> +++ b/drivers/net/ethernet/mellanox/mlx4/en_netdev.c
> @@ -2420,21 +2420,21 @@ static int mlx4_en_change_mtu(struct net_device *dev, int new_mtu)
> return 0;
> }
>
> -static int mlx4_en_hwtstamp_set(struct net_device *dev, struct ifreq *ifr)
> +static int mlx4_en_hwtstamp_set(struct net_device *dev,
> + struct kernel_hwtstamp_config *config,
> + struct netlink_ext_ack *extack)
> {
> struct mlx4_en_priv *priv = netdev_priv(dev);
> struct mlx4_en_dev *mdev = priv->mdev;
> - struct hwtstamp_config config;
> -
> - if (copy_from_user(&config, ifr->ifr_data, sizeof(config)))
> - return -EFAULT;
>
> /* device doesn't support time stamping */
> - if (!(mdev->dev->caps.flags2 & MLX4_DEV_CAP_FLAG2_TS))
> + if (!(mdev->dev->caps.flags2 & MLX4_DEV_CAP_FLAG2_TS)) {
> + NL_SET_ERR_MSG(extack, "device doesn't support time stamping");
Encouraged to add more extack messages, for error flows below.
WDYT?
> return -EINVAL;
> + }
>
> /* TX HW timestamp */
> - switch (config.tx_type) {
> + switch (config->tx_type) {
> case HWTSTAMP_TX_OFF:
> case HWTSTAMP_TX_ON:
> break;
> @@ -2443,7 +2443,7 @@ static int mlx4_en_hwtstamp_set(struct net_device *dev, struct ifreq *ifr)
> }
>
> /* RX HW timestamp */
> - switch (config.rx_filter) {
> + switch (config->rx_filter) {
> case HWTSTAMP_FILTER_NONE:
> break;
> case HWTSTAMP_FILTER_ALL:
> @@ -2461,39 +2461,27 @@ static int mlx4_en_hwtstamp_set(struct net_device *dev, struct ifreq *ifr)
> case HWTSTAMP_FILTER_PTP_V2_SYNC:
> case HWTSTAMP_FILTER_PTP_V2_DELAY_REQ:
> case HWTSTAMP_FILTER_NTP_ALL:
> - config.rx_filter = HWTSTAMP_FILTER_ALL;
> + config->rx_filter = HWTSTAMP_FILTER_ALL;
> break;
> default:
> return -ERANGE;
> }
>
> if (mlx4_en_reset_config(dev, config, dev->features)) {
> - config.tx_type = HWTSTAMP_TX_OFF;
> - config.rx_filter = HWTSTAMP_FILTER_NONE;
> + config->tx_type = HWTSTAMP_TX_OFF;
> + config->rx_filter = HWTSTAMP_FILTER_NONE;
> }
>
> - return copy_to_user(ifr->ifr_data, &config,
> - sizeof(config)) ? -EFAULT : 0;
> + return 0;
> }
>
> -static int mlx4_en_hwtstamp_get(struct net_device *dev, struct ifreq *ifr)
> +static int mlx4_en_hwtstamp_get(struct net_device *dev,
> + struct kernel_hwtstamp_config *config)
> {
> struct mlx4_en_priv *priv = netdev_priv(dev);
>
> - return copy_to_user(ifr->ifr_data, &priv->hwtstamp_config,
> - sizeof(priv->hwtstamp_config)) ? -EFAULT : 0;
> -}
> -
> -static int mlx4_en_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
> -{
> - switch (cmd) {
> - case SIOCSHWTSTAMP:
> - return mlx4_en_hwtstamp_set(dev, ifr);
> - case SIOCGHWTSTAMP:
> - return mlx4_en_hwtstamp_get(dev, ifr);
> - default:
> - return -EOPNOTSUPP;
> - }
> + *config = priv->hwtstamp_config;
> + return 0;
> }
>
> static netdev_features_t mlx4_en_fix_features(struct net_device *netdev,
> @@ -2560,7 +2548,7 @@ static int mlx4_en_set_features(struct net_device *netdev,
> }
>
> if (reset) {
> - ret = mlx4_en_reset_config(netdev, priv->hwtstamp_config,
> + ret = mlx4_en_reset_config(netdev, &priv->hwtstamp_config,
> features);
> if (ret)
> return ret;
> @@ -2844,7 +2832,6 @@ static const struct net_device_ops mlx4_netdev_ops = {
> .ndo_set_mac_address = mlx4_en_set_mac,
> .ndo_validate_addr = eth_validate_addr,
> .ndo_change_mtu = mlx4_en_change_mtu,
> - .ndo_eth_ioctl = mlx4_en_ioctl,
> .ndo_tx_timeout = mlx4_en_tx_timeout,
> .ndo_vlan_rx_add_vid = mlx4_en_vlan_rx_add_vid,
> .ndo_vlan_rx_kill_vid = mlx4_en_vlan_rx_kill_vid,
> @@ -2858,6 +2845,8 @@ static const struct net_device_ops mlx4_netdev_ops = {
> .ndo_features_check = mlx4_en_features_check,
> .ndo_set_tx_maxrate = mlx4_en_set_tx_maxrate,
> .ndo_bpf = mlx4_xdp,
> + .ndo_hwtstamp_get = mlx4_en_hwtstamp_get,
> + .ndo_hwtstamp_set = mlx4_en_hwtstamp_set,
> };
>
> static const struct net_device_ops mlx4_netdev_ops_master = {
> @@ -3512,7 +3501,7 @@ int mlx4_en_init_netdev(struct mlx4_en_dev *mdev, int port,
> }
>
> int mlx4_en_reset_config(struct net_device *dev,
> - struct hwtstamp_config ts_config,
> + struct kernel_hwtstamp_config *ts_config,
> netdev_features_t features)
> {
> struct mlx4_en_priv *priv = netdev_priv(dev);
> @@ -3522,8 +3511,8 @@ int mlx4_en_reset_config(struct net_device *dev,
> int port_up = 0;
> int err = 0;
>
> - if (priv->hwtstamp_config.tx_type == ts_config.tx_type &&
> - priv->hwtstamp_config.rx_filter == ts_config.rx_filter &&
> + if (priv->hwtstamp_config.tx_type == ts_config->tx_type &&
> + priv->hwtstamp_config.rx_filter == ts_config->rx_filter &&
> !DEV_FEATURE_CHANGED(dev, features, NETIF_F_HW_VLAN_CTAG_RX) &&
> !DEV_FEATURE_CHANGED(dev, features, NETIF_F_RXFCS))
> return 0; /* Nothing to change */
> @@ -3542,7 +3531,7 @@ int mlx4_en_reset_config(struct net_device *dev,
> mutex_lock(&mdev->state_lock);
>
> memcpy(&new_prof, priv->prof, sizeof(struct mlx4_en_port_profile));
> - memcpy(&new_prof.hwtstamp_config, &ts_config, sizeof(ts_config));
> + memcpy(&new_prof.hwtstamp_config, ts_config, sizeof(*ts_config));
>
> err = mlx4_en_try_alloc_resources(priv, tmp, &new_prof, true);
> if (err)
> @@ -3560,7 +3549,7 @@ int mlx4_en_reset_config(struct net_device *dev,
> dev->features |= NETIF_F_HW_VLAN_CTAG_RX;
> else
> dev->features &= ~NETIF_F_HW_VLAN_CTAG_RX;
> - } else if (ts_config.rx_filter == HWTSTAMP_FILTER_NONE) {
> + } else if (ts_config->rx_filter == HWTSTAMP_FILTER_NONE) {
> /* RX time-stamping is OFF, update the RX vlan offload
> * to the latest wanted state
> */
> @@ -3581,7 +3570,7 @@ int mlx4_en_reset_config(struct net_device *dev,
> * Regardless of the caller's choice,
> * Turn Off RX vlan offload in case of time-stamping is ON
> */
> - if (ts_config.rx_filter != HWTSTAMP_FILTER_NONE) {
> + if (ts_config->rx_filter != HWTSTAMP_FILTER_NONE) {
> if (dev->features & NETIF_F_HW_VLAN_CTAG_RX)
> en_warn(priv, "Turning off RX vlan offload since RX time-stamping is ON\n");
> dev->features &= ~NETIF_F_HW_VLAN_CTAG_RX;
> diff --git a/drivers/net/ethernet/mellanox/mlx4/mlx4_en.h b/drivers/net/ethernet/mellanox/mlx4/mlx4_en.h
> index ad0d91a75184..aab97694f86b 100644
> --- a/drivers/net/ethernet/mellanox/mlx4/mlx4_en.h
> +++ b/drivers/net/ethernet/mellanox/mlx4/mlx4_en.h
> @@ -388,7 +388,7 @@ struct mlx4_en_port_profile {
> u8 num_up;
> int rss_rings;
> int inline_thold;
> - struct hwtstamp_config hwtstamp_config;
> + struct kernel_hwtstamp_config hwtstamp_config;
> };
>
> struct mlx4_en_profile {
> @@ -612,7 +612,7 @@ struct mlx4_en_priv {
> bool wol;
> struct device *ddev;
> struct hlist_head mac_hash[MLX4_EN_MAC_HASH_SIZE];
> - struct hwtstamp_config hwtstamp_config;
> + struct kernel_hwtstamp_config hwtstamp_config;
> u32 counter_index;
>
> #ifdef CONFIG_MLX4_EN_DCB
> @@ -780,7 +780,7 @@ void mlx4_en_ptp_overflow_check(struct mlx4_en_dev *mdev);
>
> int mlx4_en_moderation_update(struct mlx4_en_priv *priv);
> int mlx4_en_reset_config(struct net_device *dev,
> - struct hwtstamp_config ts_config,
> + struct kernel_hwtstamp_config *ts_config,
> netdev_features_t new_features);
> void mlx4_en_update_pfc_stats_bitmap(struct mlx4_dev *dev,
> struct mlx4_en_stats_bitmap *stats_bitmap,
next prev parent reply other threads:[~2025-10-20 10:11 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-17 18:21 [PATCH net-next v2 0/6] convert net drivers to ndo_hwtstamp API part 2 Vadim Fedorenko
2025-10-17 18:21 ` [PATCH net-next v2 1/6] octeontx2: convert to ndo_hwtstamp API Vadim Fedorenko
2025-10-21 1:45 ` Jakub Kicinski
2025-10-17 18:21 ` [PATCH net-next v2 2/6] mlx4: " Vadim Fedorenko
2025-10-20 10:11 ` Tariq Toukan [this message]
2025-10-20 10:15 ` Vadim Fedorenko
2025-10-17 18:21 ` [PATCH net-next v2 3/6] ionic: " Vadim Fedorenko
2025-10-17 18:21 ` [PATCH net-next v2 4/6] net: ravb: " Vadim Fedorenko
2025-10-17 18:21 ` [PATCH net-next v2 5/6] net: renesas: rswitch: " Vadim Fedorenko
2025-10-17 18:21 ` [PATCH net-next v2 6/6] net: hns3: add hwtstamp_get/hwtstamp_set ops Vadim Fedorenko
2025-10-20 2:00 ` Jijie Shao
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=75c45f72-a0bf-4b72-8ba2-5b4c8073f21d@gmail.com \
--to=ttoukan.linux@gmail.com \
--cc=andrew+netdev@lunn.ch \
--cc=bbhushan2@marvell.com \
--cc=brett.creeley@amd.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=gakula@marvell.com \
--cc=horms@kernel.org \
--cc=jacob.e.keller@intel.com \
--cc=kuba@kernel.org \
--cc=linux-renesas-soc@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=netdev@vger.kernel.org \
--cc=niklas.soderlund@ragnatech.se \
--cc=pabeni@redhat.com \
--cc=paul@pbarker.dev \
--cc=richardcochran@gmail.com \
--cc=salil.mehta@huawei.com \
--cc=sbhatta@marvell.com \
--cc=sgoutham@marvell.com \
--cc=shaojijie@huawei.com \
--cc=shenjian15@huawei.com \
--cc=tariqt@nvidia.com \
--cc=vadim.fedorenko@linux.dev \
--cc=vladimir.oltean@nxp.com \
--cc=yoshihiro.shimoda.uh@renesas.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).