Subject: Re: [PATCH net-next v2 3/7] amd-xgbe: convert to ndo_hwtstamp callbacks

From: Jacob Keller <[email-masked]>
Date: Wed, 15 Oct 2025 13:23:30 -0700

On 10/15/2025 12:58 PM, Vadim Fedorenko wrote:
> On 15.10.2025 20:47, Jacob Keller wrote:
>>
>>
>> On 10/14/2025 3:42 PM, Vadim Fedorenko wrote:
>>> diff --git a/drivers/net/ethernet/amd/xgbe/xgbe-hwtstamp.c b/drivers/net/ethernet/amd/xgbe/xgbe-hwtstamp.c
>>> index bc52e5ec6420..0127988e10be 100644
>>> --- a/drivers/net/ethernet/amd/xgbe/xgbe-hwtstamp.c
>>> +++ b/drivers/net/ethernet/amd/xgbe/xgbe-hwtstamp.c
>>> @@ -157,26 +157,24 @@ void xgbe_tx_tstamp(struct work_struct *work)
>>>   	spin_unlock_irqrestore(&pdata->tstamp_lock, flags);
>>>   }
>>>   
>>> -int xgbe_get_hwtstamp_settings(struct xgbe_prv_data *pdata, struct ifreq *ifreq)
>>> +int xgbe_get_hwtstamp_settings(struct net_device *netdev,
>>> +			       struct kernel_hwtstamp_config *config)
>>>   {
>>> -	if (copy_to_user(ifreq->ifr_data, &pdata->tstamp_config,
>>> -			 sizeof(pdata->tstamp_config)))
>>> -		return -EFAULT;
>>> +	struct xgbe_prv_data *pdata = netdev_priv(netdev);
>>> +
>>> +	*config = pdata->tstamp_config;
>>>   
>>>   	return 0;
>>>   }
>>>   
>>> -int xgbe_set_hwtstamp_settings(struct xgbe_prv_data *pdata, struct ifreq *ifreq)
>>> +int xgbe_set_hwtstamp_settings(struct net_device *netdev,
>>> +			       struct kernel_hwtstamp_config *config,
>>> +			       struct netlink_ext_ack *extack)
>>>   {
>>> -	struct hwtstamp_config config;
>>> -	unsigned int mac_tscr;
>>> -
>>> -	if (copy_from_user(&config, ifreq->ifr_data, sizeof(config)))
>>> -		return -EFAULT;
>>> -
>>> -	mac_tscr = 0;
>>> +	struct xgbe_prv_data *pdata = netdev_priv(netdev);
>>> +	unsigned int mac_tscr = 0;
>>>   
>>
>> I noticed in this driver you didn't bother to add NL_SET_ERR_MSG calls.
>> Any particular reason?
> 
> The only error here is the -ERANGE which is self-explanatory, so I decided to
> keep the amount of changed lines as low as possible.
> 

Makes sense.

> We might think of adding netlink error message for ERANGE error in
> dev_set_hwtstamp() in case the driver skips setting specific message.

I think this is a good approach. Use a generic message when unset by the
driver.

For the patch:

Reviewed-by: Jacob Keller <[email-masked]>