convert drivers to use ndo_hwtstamp callbacks part 4
Subsystems (4)
cover convert drivers to use ndo_hwtstamp callbacks part 4
This patchset is a subset of part 3 patchset to convert bnx2x and qede drviers to use ndo callbacks instead ioctl to configure and report time stamping. These drivers implemented only SIOCSHWTSTAMP command, but converted to also provide configuration back to users. Some logic is changed to avoid reporting configuration which is not in sync with the HW in case of error happened.
Vadim Fedorenko (2):
bnx2x: convert to use ndo_hwtstamp callbacks
qede: convert to use ndo_hwtstamp callbacks
.../net/ethernet/broadcom/bnx2x/bnx2x_main.c | 73 ++++++++++++------- drivers/net/ethernet/qlogic/qede/qede_main.c | 22 +----- drivers/net/ethernet/qlogic/qede/qede_ptp.c | 68 ++++++++++------- drivers/net/ethernet/qlogic/qede/qede_ptp.h | 6 +- 4 files changed, 93 insertions(+), 76 deletions(-)
Signature · 1 line
2.47.3
PATCH 1/2 bnx2x: convert to use ndo_hwtstamp callbacks
The driver implemented SIOCSHWTSTAMP ioctl command only, but at the same time it has configuration stored in a private structure. Implement both ndo_hwtstamp_set and ndo_hwtstamp_get callback using stored info. ndo_hwtstamp_set callback implements a check for unsupported 1-step timestamping. The same check is removed from bnx2x_configure_ptp_filters function as it's not needed anymore. Another call site of bnx2x_configure_ptp_filters has hwtstamp_ioctl_called guard.
--- .../net/ethernet/broadcom/bnx2x/bnx2x_main.c | 73 ++++++++++++------- 1 file changed, 46 insertions(+), 27 deletions(-)
drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c +46 -27
@@ -308,8 +308,11 @@ static int bnx2x_set_storm_rx_mode(struct bnx2x *bp);/**************************************************************************** * General service functions ****************************************************************************/ - -static int bnx2x_hwtstamp_ioctl (struct bnx2x *bp,struct ifreq *ifr); +static int bnx2x_hwtstamp_set (struct net_device *dev, +struct kernel_hwtstamp_config *config, +struct netlink_ext_ack *extack); +static int bnx2x_hwtstamp_get (struct net_device *dev, +struct kernel_hwtstamp_config *config);static void __storm_memset_dma_mapping (struct bnx2x *bp,u32 addr,dma_addr_t mapping)
@@ -12813,14 +12816,9 @@ static int bnx2x_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)if (!netif_running (dev))return -EAGAIN ; -switch (cmd) { -case SIOCSHWTSTAMP : -return bnx2x_hwtstamp_ioctl (bp, ifr); -default : -DP (NETIF_MSG_LINK ,"ioctl: phy id 0x%x, reg 0x%x, val_in 0x%x\n" , - mdio->phy_id, mdio->reg_num, mdio->val_in); -return mdio_mii_ioctl (&bp->mdio, mdio, cmd); - } +DP (NETIF_MSG_LINK ,"ioctl: phy id 0x%x, reg 0x%x, val_in 0x%x\n" , + mdio->phy_id, mdio->reg_num, mdio->val_in); +return mdio_mii_ioctl (&bp->mdio, mdio, cmd); }static int bnx2x_validate_addr (struct net_device *dev)
@@ -13036,6 +13034,8 @@ static const struct net_device_ops bnx2x_netdev_ops = { .ndo_get_phys_port_id = bnx2x_get_phys_port_id, .ndo_set_vf_link_state = bnx2x_set_vf_link_state, .ndo_features_check = bnx2x_features_check, + .ndo_hwtstamp_get = bnx2x_hwtstamp_get, + .ndo_hwtstamp_set = bnx2x_hwtstamp_set, }; static int bnx2x_init_dev(struct bnx2x *bp, struct pci_dev *pdev,
@@ -15285,10 +15285,8 @@ int bnx2x_configure_ptp_filters(struct bnx2x *bp)REG_WR (bp, param,BNX2X_PTP_TX_ON_PARAM_MASK );REG_WR (bp, rule,BNX2X_PTP_TX_ON_RULE_MASK );break ; -case HWTSTAMP_TX_ONESTEP_SYNC : -case HWTSTAMP_TX_ONESTEP_P2P : -BNX2X_ERR ("One-step timestamping is not supported\n" ); -return -ERANGE ; +default : +break ; } param = port ? NIG_REG_P1_LLH_PTP_PARAM_MASK :
@@ -15350,31 +15348,52 @@ int bnx2x_configure_ptp_filters(struct bnx2x *bp)return 0 ; } -static int bnx2x_hwtstamp_ioctl (struct bnx2x *bp,struct ifreq *ifr) +static int bnx2x_hwtstamp_set (struct net_device *dev, +struct kernel_hwtstamp_config *config, +struct netlink_ext_ack *extack) { -struct hwtstamp_config config; +struct bnx2x *bp =netdev_priv (dev);int rc; -DP (BNX2X_MSG_PTP ,"HWTSTAMP IOCTL called\n" ); - -if (copy_from_user (&config, ifr->ifr_data,sizeof (config))) -return -EFAULT ; +DP (BNX2X_MSG_PTP ,"HWTSTAMP SET called\n" );DP (BNX2X_MSG_PTP ,"Requested tx_type: %d, requested rx_filters = %d\n" , - config.tx_type, config.rx_filter); + config->tx_type, config->rx_filter); + +switch (config->tx_type) { +case HWTSTAMP_TX_ONESTEP_SYNC : +case HWTSTAMP_TX_ONESTEP_P2P : +NL_SET_ERR_MSG_MOD (extack, +"One-step timestamping is not supported" ); +return -ERANGE ; +default : +break ; + } bp->hwtstamp_ioctl_called = true; - bp->tx_type = config.tx_type; - bp->rx_filter = config.rx_filter; + bp->tx_type = config->tx_type; + bp->rx_filter = config->rx_filter; rc =bnx2x_configure_ptp_filters (bp); -if (rc) +if (rc) { +NL_SET_ERR_MSG_MOD (extack,"HW configuration failure" );return rc; + } + + config->rx_filter = bp->rx_filter; - config.rx_filter = bp->rx_filter; +return 0 ; +} -return copy_to_user (ifr->ifr_data, &config,sizeof (config)) ? - -EFAULT :0 ; +static int bnx2x_hwtstamp_get (struct net_device *dev, +struct kernel_hwtstamp_config *config) +{ +struct bnx2x *bp =netdev_priv (dev); + + config->rx_filter = bp->rx_filter; + config->tx_type = bp->tx_type; + +return 0 ; }/* Configures HW for PTP */
Signature · 1 line
2.47.3
PATCH 2/2 qede: convert to use ndo_hwtstamp callbacks
In reply to Vadim FedorenkoThe driver implemented SIOCSHWTSTAMP ioctl cmd only, but it stores configuration in private structure, so it can be reported back to users. Implement both ndo_hwtstamp_set and ndo_hwtstamp_set callbacks. ndo_hwtstamp_set implements a check of unsupported 1-step timestamping and qede_ptp_cfg_filters() becomes void as it cannot fail anymore.
--- drivers/net/ethernet/qlogic/qede/qede_main.c | 22 +------ drivers/net/ethernet/qlogic/qede/qede_ptp.c | 68 ++++++++++++-------- drivers/net/ethernet/qlogic/qede/qede_ptp.h | 6 +- 3 files changed, 47 insertions(+), 49 deletions(-)
drivers/net/ethernet/qlogic/qede/qede_main.c +2 -20
@@ -506,25 +506,6 @@ static int qede_set_vf_trust(struct net_device *dev, int vfidx, bool setting) }#endif -static int qede_ioctl (struct net_device *dev,struct ifreq *ifr,int cmd) -{ -struct qede_dev *edev =netdev_priv (dev); - -if (!netif_running (dev)) -return -EAGAIN ; - -switch (cmd) { -case SIOCSHWTSTAMP : -return qede_ptp_hw_ts (edev, ifr); -default : -DP_VERBOSE (edev,QED_MSG_DEBUG , -"default IOCTL cmd 0x%x\n" , cmd); -return -EOPNOTSUPP ; - } - -return 0 ; -} -static void qede_fp_sb_dump (struct qede_dev *edev,struct qede_fastpath *fp) {char *p_sb = (char *)fp->sb_info->sb_virt;
@@ -717,7 +698,6 @@ static const struct net_device_ops qede_netdev_ops = { .ndo_set_mac_address = qede_set_mac_addr, .ndo_validate_addr = eth_validate_addr, .ndo_change_mtu = qede_change_mtu, - .ndo_eth_ioctl = qede_ioctl, .ndo_tx_timeout = qede_tx_timeout, #ifdef CONFIG_QED_SRIOV .ndo_set_vf_mac = qede_set_vf_mac,
@@ -742,6 +722,8 @@ static const struct net_device_ops qede_netdev_ops = {#endif .ndo_xdp_xmit = qede_xdp_transmit, .ndo_setup_tc = qede_setup_tc_offload, + .ndo_hwtstamp_get = qede_hwtstamp_get, + .ndo_hwtstamp_set = qede_hwtstamp_set, };static const struct net_device_ops qede_netdev_vf_ops = {
drivers/net/ethernet/qlogic/qede/qede_ptp.c +40 -28
108 lines not on this page · raw message
drivers/net/ethernet/qlogic/qede/qede_ptp.h +5 -1
@@ -14,7 +14,11 @@void qede_ptp_rx_ts (struct qede_dev *edev,struct sk_buff *skb);void qede_ptp_tx_ts (struct qede_dev *edev,struct sk_buff *skb); -int qede_ptp_hw_ts (struct qede_dev *edev,struct ifreq *req); +int qede_hwtstamp_get (struct net_device *netdev, +struct kernel_hwtstamp_config *config); +int qede_hwtstamp_set (struct net_device *netdev, +struct kernel_hwtstamp_config *config, +struct netlink_ext_ack *extack);void qede_ptp_disable (struct qede_dev *edev);int qede_ptp_enable (struct qede_dev *edev);int qede_ptp_get_ts_info (struct qede_dev *edev,struct kernel_ethtool_ts_info *ts);
Signature · 1 line
2.47.3
Jakub Kicinski
maintainerRe: [PATCH net-next 2/2] qede: convert to use ndo_hwtstamp callbacks
Quoted 5 lines · On Wed, 5 Nov 2025 18:51:33 +0000 Vadim Fedorenko wrote:
The driver implemented SIOCSHWTSTAMP ioctl cmd only, but it stores configuration in private structure, so it can be reported back to users. Implement both
ndo_hwtstamp_setandndo_hwtstamp_setcallbacks.ndo_hwtstamp_setimplements a check of unsupported 1-step timestamping andqede_ptp_cfg_filters()becomes void as it cannot fail anymore.
drivers/net/ethernet/qlogic/qede/qede_ptp.c:289:6: warning: unused variable 'rc' [-Wunused-variable]
289 | int rc;
| ^~
Please consider:
https://github.com/linux-netdev/nipa?tab=readme-ov-file#running-locally
Signature · 1 line
pw-bot: cr
kernel test robot
build botRe: [PATCH net-next 2/2] qede: convert to use ndo_hwtstamp callbacks
In reply to Vadim Fedorenkokernel test robot noticed the following build warnings:
Hi Vadim,
kernel test robot noticed the following build warnings:
[auto build test WARNING on net-next/main]
url: https://github.com/intel-lab-lkp/linux/commits/Vadim-Fedorenko/bnx2x-convert-to-use-ndo_hwtstamp-callbacks/20251106-030837 base: net-next/main patch link: https://lore.kernel.org/r/20251105185133.3542054-3-vadim.fedorenko%40linux.dev patch subject: [PATCH net-next 2/2] qede: convert to use ndo_hwtstamp callbacks config: x86_64-rhel-9.4 (https://download.01.org/0day-ci/archive/20251106/[email protected]/config) compiler: gcc-14 (Debian 14.2.0-19) 14.2.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20251106/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All warnings (new ones prefixed by >>):
drivers/net/ethernet/qlogic/qede/qede_ptp.c: In function 'qede_hwtstamp_set':
>> drivers/net/ethernet/qlogic/qede/qede_ptp.c:289:13: warning: unused variable 'rc' [-Wunused-variable]
289 | int rc;
| ^~vim +/rc +289 drivers/net/ethernet/qlogic/qede/qede_ptp.c
4c55215c05d252 Sudarsana Reddy Kalluru 2017-02-15 282
c704f693a6ea05 Vadim Fedorenko 2025-11-05 283 int qede_hwtstamp_set(struct net_device *netdev,
c704f693a6ea05 Vadim Fedorenko 2025-11-05 284 struct kernel_hwtstamp_config *config,
c704f693a6ea05 Vadim Fedorenko 2025-11-05 285 struct netlink_ext_ack *extack)
4c55215c05d252 Sudarsana Reddy Kalluru 2017-02-15 286 {
c704f693a6ea05 Vadim Fedorenko 2025-11-05 287 struct qede_dev *edev = netdev_priv(netdev);
4c55215c05d252 Sudarsana Reddy Kalluru 2017-02-15 288 struct qede_ptp *ptp;
4c55215c05d252 Sudarsana Reddy Kalluru 2017-02-15 @289 int rc;
4c55215c05d252 Sudarsana Reddy Kalluru 2017-02-15 290
4c55215c05d252 Sudarsana Reddy Kalluru 2017-02-15 291 ptp = edev->ptp;
c704f693a6ea05 Vadim Fedorenko 2025-11-05 292 if (!ptp) {
c704f693a6ea05 Vadim Fedorenko 2025-11-05 293 NL_SET_ERR_MSG_MOD(extack, "HW timestamping is not supported");
4c55215c05d252 Sudarsana Reddy Kalluru 2017-02-15 294 return -EIO;
c704f693a6ea05 Vadim Fedorenko 2025-11-05 295 }
4c55215c05d252 Sudarsana Reddy Kalluru 2017-02-15 296
4c55215c05d252 Sudarsana Reddy Kalluru 2017-02-15 297 DP_VERBOSE(edev, QED_MSG_DEBUG,
c704f693a6ea05 Vadim Fedorenko 2025-11-05 298 "HWTSTAMP SET: Requested tx_type = %d, requested rx_filters = %d\n",
c704f693a6ea05 Vadim Fedorenko 2025-11-05 299 config->tx_type, config->rx_filter);
c704f693a6ea05 Vadim Fedorenko 2025-11-05 300
c704f693a6ea05 Vadim Fedorenko 2025-11-05 301 switch (config->tx_type) {
c704f693a6ea05 Vadim Fedorenko 2025-11-05 302 case HWTSTAMP_TX_ONESTEP_SYNC:
c704f693a6ea05 Vadim Fedorenko 2025-11-05 303 case HWTSTAMP_TX_ONESTEP_P2P:
c704f693a6ea05 Vadim Fedorenko 2025-11-05 304 NL_SET_ERR_MSG_MOD(extack,
c704f693a6ea05 Vadim Fedorenko 2025-11-05 305 "One-step timestamping is not supported");
c704f693a6ea05 Vadim Fedorenko 2025-11-05 306 return -ERANGE;
c704f693a6ea05 Vadim Fedorenko 2025-11-05 307 }
4c55215c05d252 Sudarsana Reddy Kalluru 2017-02-15 308
4c55215c05d252 Sudarsana Reddy Kalluru 2017-02-15 309 ptp->hw_ts_ioctl_called = 1;
c704f693a6ea05 Vadim Fedorenko 2025-11-05 310 ptp->tx_type = config->tx_type;
c704f693a6ea05 Vadim Fedorenko 2025-11-05 311 ptp->rx_filter = config->rx_filter;
4c55215c05d252 Sudarsana Reddy Kalluru 2017-02-15 312
c704f693a6ea05 Vadim Fedorenko 2025-11-05 313 qede_ptp_cfg_filters(edev);
4c55215c05d252 Sudarsana Reddy Kalluru 2017-02-15 314
c704f693a6ea05 Vadim Fedorenko 2025-11-05 315 config->rx_filter = ptp->rx_filter;
4c55215c05d252 Sudarsana Reddy Kalluru 2017-02-15 316
c704f693a6ea05 Vadim Fedorenko 2025-11-05 317 return 0;
c704f693a6ea05 Vadim Fedorenko 2025-11-05 318 }
c704f693a6ea05 Vadim Fedorenko 2025-11-05 319 Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki