convert drivers to use ndo_hwtstamp callbacks part 3
Subsystems (6)
cover convert drivers to use ndo_hwtstamp callbacks part 3
This patchset converts the rest of ethernet drivers to use ndo callbacks instead ioctl to configure and report time stamping. The drivers in part 3 originally implemented only SIOCSHWTSTAMP command, but converted to also provide configuration back to users.
Vadim Fedorenko (7):
bnx2x: convert to use ndo_hwtstamp callbacks
net: liquidio: convert to use ndo_hwtstamp callbacks
net: liquidio_vf: convert to use ndo_hwtstamp callbacks
net: octeon: mgmt: convert to use ndo_hwtstamp callbacks
net: thunderx: convert to use ndo_hwtstamp callbacks
net: pch_gbe: convert to use ndo_hwtstamp callbacks
qede: convert to use ndo_hwtstamp callbacks
.../net/ethernet/broadcom/bnx2x/bnx2x_main.c | 53 +++++++++------- .../net/ethernet/cavium/liquidio/lio_main.c | 50 ++++++--------- .../ethernet/cavium/liquidio/lio_vf_main.c | 48 ++++++-------- .../net/ethernet/cavium/octeon/octeon_mgmt.c | 62 ++++++++++--------- .../net/ethernet/cavium/thunder/nicvf_main.c | 45 ++++++++------ .../ethernet/oki-semi/pch_gbe/pch_gbe_main.c | 40 +++++++----- drivers/net/ethernet/qlogic/qede/qede_main.c | 22 +------ drivers/net/ethernet/qlogic/qede/qede_ptp.c | 47 +++++++++----- drivers/net/ethernet/qlogic/qede/qede_ptp.h | 6 +- 9 files changed, 191 insertions(+), 182 deletions(-)
Signature · 1 line
2.47.3
PATCH 1/7 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.
--- .../net/ethernet/broadcom/bnx2x/bnx2x_main.c | 53 +++++++++++-------- 1 file changed, 31 insertions(+), 22 deletions(-)
drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c +31 -22
@@ -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,
@@ -15350,31 +15350,40 @@ 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); 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)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/7 net: liquidio: convert to use ndo_hwtstamp callbacks
In reply to Vadim FedorenkoThe driver implemented SIOCSHWTSTAMP ioctl command only, but there is a way to get configured status. Implement both ndo_hwtstamp_set and ndo_hwtstamp_get callbacks.
--- .../net/ethernet/cavium/liquidio/lio_main.c | 50 ++++++++----------- 1 file changed, 20 insertions(+), 30 deletions(-)
drivers/net/ethernet/cavium/liquidio/lio_main.c +20 -30
@@ -2107,20 +2107,16 @@ liquidio_get_stats64(struct net_device *netdev, lstats->tx_fifo_errors; } -/** -* hwtstamp_ioctl - Handler for SIOCSHWTSTAMP ioctl -* @netdev: network device -* @ifr: interface request -*/ -static int hwtstamp_ioctl (struct net_device *netdev,struct ifreq *ifr) +static int liquidio_hwtstamp_set (struct net_device *netdev, +struct kernel_hwtstamp_config *conf, +struct netlink_ext_ack *extack) { -struct hwtstamp_config conf;struct lio *lio =GET_LIO (netdev); -if (copy_from_user (&conf, ifr->ifr_data,sizeof (conf))) -return -EFAULT ; +if (!lio->oct_dev->ptp_enable) +return -EOPNOTSUPP ; -switch (conf.tx_type) { +switch (conf->tx_type) {case HWTSTAMP_TX_ON :case HWTSTAMP_TX_OFF :break ;
@@ -2128,7 +2124,7 @@ static int hwtstamp_ioctl(struct net_device *netdev, struct ifreq *ifr)return -ERANGE ; } -switch (conf.rx_filter) { +switch (conf->rx_filter) {case HWTSTAMP_FILTER_NONE :break ;case HWTSTAMP_FILTER_ALL :
@@ -2146,39 +2142,32 @@ static int hwtstamp_ioctl(struct net_device *netdev, struct ifreq *ifr)case HWTSTAMP_FILTER_PTP_V2_SYNC :case HWTSTAMP_FILTER_PTP_V2_DELAY_REQ :case HWTSTAMP_FILTER_NTP_ALL : - conf.rx_filter =HWTSTAMP_FILTER_ALL ; + conf->rx_filter =HWTSTAMP_FILTER_ALL ;break ;default :return -ERANGE ; } -if (conf.rx_filter ==HWTSTAMP_FILTER_ALL ) +if (conf->rx_filter ==HWTSTAMP_FILTER_ALL )ifstate_set (lio,LIO_IFSTATE_RX_TIMESTAMP_ENABLED );else ifstate_reset (lio,LIO_IFSTATE_RX_TIMESTAMP_ENABLED ); -return copy_to_user (ifr->ifr_data, &conf,sizeof (conf)) ? -EFAULT :0 ; +return 0 ; } -/** -* liquidio_ioctl - ioctl handler -* @netdev: network device -* @ifr: interface request -* @cmd: command -*/ -static int liquidio_ioctl (struct net_device *netdev,struct ifreq *ifr,int cmd) +static int liquidio_hwtstamp_get (struct net_device *netdev, +struct kernel_hwtstamp_config *conf) {struct lio *lio =GET_LIO (netdev); -switch (cmd) { -case SIOCSHWTSTAMP : -if (lio->oct_dev->ptp_enable) -return hwtstamp_ioctl (netdev, ifr); - fallthrough; -default : -return -EOPNOTSUPP ; - } +/* TX timestamping is technically always on */ + conf->tx_type =HWTSTAMP_TX_ON ; + conf->rx_filter =ifstate_check (lio,LIO_IFSTATE_RX_TIMESTAMP_ENABLED ) ? +HWTSTAMP_FILTER_ALL :HWTSTAMP_FILTER_NONE ; + +return 0 ; }/**
@@ -3227,7 +3216,6 @@ static const struct net_device_ops lionetdevops = { .ndo_vlan_rx_add_vid = liquidio_vlan_rx_add_vid, .ndo_vlan_rx_kill_vid = liquidio_vlan_rx_kill_vid, .ndo_change_mtu = liquidio_change_mtu, - .ndo_eth_ioctl = liquidio_ioctl, .ndo_fix_features = liquidio_fix_features, .ndo_set_features = liquidio_set_features, .ndo_set_vf_mac = liquidio_set_vf_mac,
@@ -3238,6 +3226,8 @@ static const struct net_device_ops lionetdevops = { .ndo_set_vf_link_state = liquidio_set_vf_link_state, .ndo_get_vf_stats = liquidio_get_vf_stats, .ndo_get_port_parent_id = liquidio_get_port_parent_id, + .ndo_hwtstamp_get = liquidio_hwtstamp_get, + .ndo_hwtstamp_set = liquidio_hwtstamp_set, };/**
Signature · 1 line
2.47.3
PATCH 3/7 net: liquidio_vf: convert to use ndo_hwtstamp callbacks
In reply to Vadim FedorenkoThe driver implemented SIOCSHWTSTAMP ioctl command only, but there is a way to get configuration back. Implement both ndo_hwtstamp_set and ndo_hwtstamp_set callbacks.
--- .../ethernet/cavium/liquidio/lio_vf_main.c | 48 ++++++++----------- 1 file changed, 19 insertions(+), 29 deletions(-)
drivers/net/ethernet/cavium/liquidio/lio_vf_main.c +19 -29
@@ -1236,20 +1236,13 @@ liquidio_get_stats64(struct net_device *netdev, lstats->tx_carrier_errors; } -/** -* hwtstamp_ioctl - Handler for SIOCSHWTSTAMP ioctl -* @netdev: network device -* @ifr: interface request -*/ -static int hwtstamp_ioctl (struct net_device *netdev,struct ifreq *ifr) +static int liquidio_hwtstamp_set (struct net_device *netdev, +struct kernel_hwtstamp_config *conf, +struct netlink_ext_ack *extack) {struct lio *lio =GET_LIO (netdev); -struct hwtstamp_config conf; - -if (copy_from_user (&conf, ifr->ifr_data,sizeof (conf))) -return -EFAULT ; -switch (conf.tx_type) { +switch (conf->tx_type) {case HWTSTAMP_TX_ON :case HWTSTAMP_TX_OFF :break ;
@@ -1257,7 +1250,7 @@ static int hwtstamp_ioctl(struct net_device *netdev, struct ifreq *ifr)return -ERANGE ; } -switch (conf.rx_filter) { +switch (conf->rx_filter) {case HWTSTAMP_FILTER_NONE :break ;case HWTSTAMP_FILTER_ALL :
@@ -1275,35 +1268,31 @@ static int hwtstamp_ioctl(struct net_device *netdev, struct ifreq *ifr)case HWTSTAMP_FILTER_PTP_V2_SYNC :case HWTSTAMP_FILTER_PTP_V2_DELAY_REQ :case HWTSTAMP_FILTER_NTP_ALL : - conf.rx_filter =HWTSTAMP_FILTER_ALL ; + conf->rx_filter =HWTSTAMP_FILTER_ALL ;break ;default :return -ERANGE ; } -if (conf.rx_filter ==HWTSTAMP_FILTER_ALL ) +if (conf->rx_filter ==HWTSTAMP_FILTER_ALL )ifstate_set (lio,LIO_IFSTATE_RX_TIMESTAMP_ENABLED );else ifstate_reset (lio,LIO_IFSTATE_RX_TIMESTAMP_ENABLED ); -return copy_to_user (ifr->ifr_data, &conf,sizeof (conf)) ? -EFAULT :0 ; +return 0 ; } -/** -* liquidio_ioctl - ioctl handler -* @netdev: network device -* @ifr: interface request -* @cmd: command -*/ -static int liquidio_ioctl (struct net_device *netdev,struct ifreq *ifr,int cmd) +static int liquidio_hwtstamp_get (struct net_device *netdev, +struct kernel_hwtstamp_config *conf) { -switch (cmd) { -case SIOCSHWTSTAMP : -return hwtstamp_ioctl (netdev, ifr); -default : -return -EOPNOTSUPP ; - } +struct lio *lio =GET_LIO (netdev); + +/* TX timestamping is techically always on */ + conf->tx_type =HWTSTAMP_TX_ON ; + conf->rx_filter =ifstate_check (lio,LIO_IFSTATE_RX_TIMESTAMP_ENABLED ) ? +HWTSTAMP_FILTER_ALL :HWTSTAMP_FILTER_NONE ; +return 0 ; }static void handle_timestamp (struct octeon_device *oct,u32 status,void *buf)
@@ -1881,9 +1870,10 @@ static const struct net_device_ops lionetdevops = { .ndo_vlan_rx_add_vid = liquidio_vlan_rx_add_vid, .ndo_vlan_rx_kill_vid = liquidio_vlan_rx_kill_vid, .ndo_change_mtu = liquidio_change_mtu, - .ndo_eth_ioctl = liquidio_ioctl, .ndo_fix_features = liquidio_fix_features, .ndo_set_features = liquidio_set_features, + .ndo_hwtstamp_get = liquidio_hwtstamp_get, + .ndo_hwtstamp_set = liquidio_hwtstamp_set, };static int lio_nic_info (struct octeon_recv_info *recv_info,void *buf)
Signature · 1 line
2.47.3
PATCH 4/7 net: octeon: mgmt: convert to use ndo_hwtstamp callbacks
In reply to Vadim FedorenkoThe driver implemented SIOCSHWTSTAMP ioctl command only. But it stores timestamping configuration, so it is possible to report it to users. Implement both ndo_hwtstamp_set and ndo_hwtstamp_get callbacks. After this the ndo_eth_ioctl effectively becomes phy_do_ioctl - adjust callback accrodingly.
--- .../net/ethernet/cavium/octeon/octeon_mgmt.c | 62 ++++++++++--------- 1 file changed, 32 insertions(+), 30 deletions(-)
drivers/net/ethernet/cavium/octeon/octeon_mgmt.c +32 -30
@@ -690,19 +690,16 @@ static irqreturn_t octeon_mgmt_interrupt(int cpl, void *dev_id)return IRQ_HANDLED ; } -static int octeon_mgmt_ioctl_hwtstamp (struct net_device *netdev, -struct ifreq *rq,int cmd) +static int octeon_mgmt_hwtstamp_set (struct net_device *netdev, +struct kernel_hwtstamp_config *config, +struct netlink_ext_ack *extack) {struct octeon_mgmt *p =netdev_priv (netdev); -struct hwtstamp_config config; -union cvmx_mio_ptp_clock_cfg ptp;union cvmx_agl_gmx_rxx_frm_ctl rxx_frm_ctl; +union cvmx_mio_ptp_clock_cfg ptp;bool have_hw_timestamps = false; -if (copy_from_user (&config, rq->ifr_data,sizeof (config))) -return -EFAULT ; - -/* Check the status of hardware for tiemstamps */ +/* Check the status of hardware for timestamps */ if (OCTEON_IS_MODEL (OCTEON_CN6XXX )) {/* Get the current state of the PTP clock */ ptp.u64 =cvmx_read_csr (CVMX_MIO_PTP_CLOCK_CFG );
@@ -733,10 +730,12 @@ static int octeon_mgmt_ioctl_hwtstamp(struct net_device *netdev, have_hw_timestamps = true; } -if (!have_hw_timestamps) +if (!have_hw_timestamps) { +NL_SET_ERR_MSG_MOD (extack,"HW doesn't support timestamping" );return -EINVAL ; + } -switch (config.tx_type) { +switch (config->tx_type) {case HWTSTAMP_TX_OFF :case HWTSTAMP_TX_ON :break ;
@@ -744,7 +743,7 @@ static int octeon_mgmt_ioctl_hwtstamp(struct net_device *netdev,return -ERANGE ; } -switch (config.rx_filter) { +switch (config->rx_filter) {case HWTSTAMP_FILTER_NONE : p->has_rx_tstamp = false; rxx_frm_ctl.u64 =cvmx_read_csr (p->agl +AGL_GMX_RX_FRM_CTL );
@@ -766,33 +765,34 @@ static int octeon_mgmt_ioctl_hwtstamp(struct net_device *netdev,case HWTSTAMP_FILTER_PTP_V2_SYNC :case HWTSTAMP_FILTER_PTP_V2_DELAY_REQ :case HWTSTAMP_FILTER_NTP_ALL : - p->has_rx_tstamp = have_hw_timestamps; - config.rx_filter =HWTSTAMP_FILTER_ALL ; -if (p->has_rx_tstamp) { - rxx_frm_ctl.u64 =cvmx_read_csr (p->agl +AGL_GMX_RX_FRM_CTL ); - rxx_frm_ctl.s.ptp_mode =1 ; -cvmx_write_csr (p->agl +AGL_GMX_RX_FRM_CTL , rxx_frm_ctl.u64); - } + p->has_rx_tstamp = true; + config->rx_filter =HWTSTAMP_FILTER_ALL ; + rxx_frm_ctl.u64 =cvmx_read_csr (p->agl +AGL_GMX_RX_FRM_CTL ); + rxx_frm_ctl.s.ptp_mode =1 ; +cvmx_write_csr (p->agl +AGL_GMX_RX_FRM_CTL , rxx_frm_ctl.u64);break ;default :return -ERANGE ; } -if (copy_to_user (rq->ifr_data, &config,sizeof (config))) -return -EFAULT ; -return 0 ; } -static int octeon_mgmt_ioctl (struct net_device *netdev, -struct ifreq *rq,int cmd) +static int octeon_mgmt_hwtstamp_get (struct net_device *netdev, +struct kernel_hwtstamp_config *config) { -switch (cmd) { -case SIOCSHWTSTAMP : -return octeon_mgmt_ioctl_hwtstamp (netdev, rq, cmd); -default : -return phy_do_ioctl (netdev, rq, cmd); - } +struct octeon_mgmt *p =netdev_priv (netdev); + +/* Check the status of hardware for timestamps */ +if (!OCTEON_IS_MODEL (OCTEON_CN6XXX )) +return -EINVAL ; + + config->tx_type =HWTSTAMP_TX_ON ; + config->rx_filter = p->has_rx_tstamp ? +HWTSTAMP_FILTER_ALL : +HWTSTAMP_FILTER_NONE ; + +return 0 ; }static void octeon_mgmt_disable_link (struct octeon_mgmt *p)
@@ -1370,11 +1370,13 @@ static const struct net_device_ops octeon_mgmt_ops = { .ndo_start_xmit = octeon_mgmt_xmit, .ndo_set_rx_mode = octeon_mgmt_set_rx_filtering, .ndo_set_mac_address = octeon_mgmt_set_mac_address, - .ndo_eth_ioctl = octeon_mgmt_ioctl, + .ndo_eth_ioctl = phy_do_ioctl, .ndo_change_mtu = octeon_mgmt_change_mtu, #ifdef CONFIG_NET_POLL_CONTROLLER .ndo_poll_controller = octeon_mgmt_poll_controller, #endif + .ndo_hwtstamp_get = octeon_mgmt_hwtstamp_get, + .ndo_hwtstamp_set = octeon_mgmt_hwtstamp_set, };static int octeon_mgmt_probe (struct platform_device *pdev)
Signature · 1 line
2.47.3
PATCH 5/7 net: thunderx: convert to use ndo_hwtstamp callbacks
In reply to Vadim FedorenkoThe driver implemented SIOCSHWTSTAMP ioctl command only, but it also stores configuration in private data, so it's possible to report it back to users. Implement both ndo_hwtstamp_set and ndo_hwtstamp_get callbacks.
--- .../net/ethernet/cavium/thunder/nicvf_main.c | 45 ++++++++++--------- 1 file changed, 25 insertions(+), 20 deletions(-)
drivers/net/ethernet/cavium/thunder/nicvf_main.c +25 -20
@@ -1899,18 +1899,18 @@ static int nicvf_xdp(struct net_device *netdev, struct netdev_bpf *xdp) } } -static int nicvf_config_hwtstamp (struct net_device *netdev,struct ifreq *ifr) +static int nicvf_hwtstamp_set (struct net_device *netdev, +struct kernel_hwtstamp_config *config, +struct netlink_ext_ack *extack) { -struct hwtstamp_config config;struct nicvf *nic =netdev_priv (netdev); -if (!nic->ptp_clock) +if (!nic->ptp_clock) { +NL_SET_ERR_MSG_MOD (extack,"HW timestamping is not supported" );return -ENODEV ; + } -if (copy_from_user (&config, ifr->ifr_data,sizeof (config))) -return -EFAULT ; - -switch (config.tx_type) { +switch (config->tx_type) {case HWTSTAMP_TX_OFF :case HWTSTAMP_TX_ON :break ;
@@ -1918,7 +1918,7 @@ static int nicvf_config_hwtstamp(struct net_device *netdev, struct ifreq *ifr)return -ERANGE ; } -switch (config.rx_filter) { +switch (config->rx_filter) {case HWTSTAMP_FILTER_NONE : nic->hw_rx_tstamp = false;break ;
@@ -1937,7 +1937,7 @@ static int nicvf_config_hwtstamp(struct net_device *netdev, struct ifreq *ifr)case HWTSTAMP_FILTER_PTP_V2_SYNC :case HWTSTAMP_FILTER_PTP_V2_DELAY_REQ : nic->hw_rx_tstamp = true; - config.rx_filter =HWTSTAMP_FILTER_ALL ; + config->rx_filter =HWTSTAMP_FILTER_ALL ;break ;default :return -ERANGE ;
@@ -1946,20 +1946,24 @@ static int nicvf_config_hwtstamp(struct net_device *netdev, struct ifreq *ifr)if (netif_running (netdev))nicvf_config_hw_rx_tstamp (nic, nic->hw_rx_tstamp); -if (copy_to_user (ifr->ifr_data, &config,sizeof (config))) -return -EFAULT ; -return 0 ; } -static int nicvf_ioctl (struct net_device *netdev,struct ifreq *req,int cmd) +static int nicvf_hwtstamp_get (struct net_device *netdev, +struct kernel_hwtstamp_config *config) { -switch (cmd) { -case SIOCSHWTSTAMP : -return nicvf_config_hwtstamp (netdev, req); -default : -return -EOPNOTSUPP ; - } +struct nicvf *nic =netdev_priv (netdev); + +if (!nic->ptp_clock) +return -ENODEV ; + +/* TX timestamping is technically always on */ + config->tx_type =HWTSTAMP_TX_ON ; + config->rx_filter = nic->hw_rx_tstamp ? +HWTSTAMP_FILTER_ALL : +HWTSTAMP_FILTER_NONE ; + +return 0 ; } static void __nicvf_set_rx_mode_task(u8 mode, struct xcast_addr_list *mc_addrs,
@@ -2081,8 +2085,9 @@ static const struct net_device_ops nicvf_netdev_ops = { .ndo_fix_features = nicvf_fix_features, .ndo_set_features = nicvf_set_features, .ndo_bpf = nicvf_xdp, - .ndo_eth_ioctl = nicvf_ioctl, .ndo_set_rx_mode = nicvf_set_rx_mode, + .ndo_hwtstamp_get = nicvf_hwtstamp_get, + .ndo_hwtstamp_set = nicvf_hwtstamp_set, };static int nicvf_probe (struct pci_dev *pdev,const struct pci_device_id *ent)
Signature · 1 line
2.47.3
PATCH 6/7 net: pch_gbe: convert to use ndo_hwtstamp callbacks
In reply to Vadim FedorenkoThe driver implemented SIOCSHWTSTAMP ioctl command only, but it stores configuration in the private data, so it is possible to report it back to users. Implement both ndo_hwtstamp_set and ndo_hwtstamp_get callbacks. To properly report RX filter type, store it in hwts_rx_en instead of using this field as a simple flag. The logic didn't change because receive path used this field as boolean flag.
--- .../ethernet/oki-semi/pch_gbe/pch_gbe_main.c | 40 +++++++++++-------- 1 file changed, 24 insertions(+), 16 deletions(-)
drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c +24 -16
@@ -198,42 +198,40 @@ pch_tx_timestamp(struct pch_gbe_adapter *adapter, struct sk_buff *skb)pch_ch_event_write (pdev,TX_SNAPSHOT_LOCKED ); } -static int hwtstamp_ioctl (struct net_device *netdev,struct ifreq *ifr,int cmd) +static int pch_gbe_hwtstamp_set (struct net_device *netdev, +struct kernel_hwtstamp_config *cfg, +struct netlink_ext_ack *extack) { -struct hwtstamp_config cfg;struct pch_gbe_adapter *adapter =netdev_priv (netdev);struct pci_dev *pdev;u8 station[20 ]; -if (copy_from_user (&cfg, ifr->ifr_data,sizeof (cfg))) -return -EFAULT ; -/* Get ieee1588's dev information */ pdev = adapter->ptp_pdev; -if (cfg.tx_type !=HWTSTAMP_TX_OFF && cfg.tx_type !=HWTSTAMP_TX_ON ) +if (cfg->tx_type !=HWTSTAMP_TX_OFF && cfg->tx_type !=HWTSTAMP_TX_ON )return -ERANGE ; -switch (cfg.rx_filter) { +switch (cfg->rx_filter) {case HWTSTAMP_FILTER_NONE : adapter->hwts_rx_en =0 ;break ;case HWTSTAMP_FILTER_PTP_V1_L4_SYNC : - adapter->hwts_rx_en =0 ; + adapter->hwts_rx_en = cfg->rx_filter;pch_ch_control_write (pdev,SLAVE_MODE |CAP_MODE0 );break ;case HWTSTAMP_FILTER_PTP_V1_L4_DELAY_REQ : - adapter->hwts_rx_en =1 ; + adapter->hwts_rx_en = cfg->rx_filter;pch_ch_control_write (pdev,MASTER_MODE |CAP_MODE0 );break ;case HWTSTAMP_FILTER_PTP_V2_L4_EVENT : - adapter->hwts_rx_en =1 ; + adapter->hwts_rx_en = cfg->rx_filter;pch_ch_control_write (pdev,V2_MODE |CAP_MODE2 );strcpy (station,PTP_L4_MULTICAST_SA );pch_set_station_address (station, pdev);break ;case HWTSTAMP_FILTER_PTP_V2_L2_EVENT : - adapter->hwts_rx_en =1 ; + adapter->hwts_rx_en = cfg->rx_filter;pch_ch_control_write (pdev,V2_MODE |CAP_MODE2 );strcpy (station,PTP_L2_MULTICAST_SA );pch_set_station_address (station, pdev);
@@ -242,12 +240,23 @@ static int hwtstamp_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd)return -ERANGE ; } - adapter->hwts_tx_en = cfg.tx_type ==HWTSTAMP_TX_ON ; + adapter->hwts_tx_en = cfg->tx_type ==HWTSTAMP_TX_ON ;/* Clear out any old time stamps. */ pch_ch_event_write (pdev,TX_SNAPSHOT_LOCKED |RX_SNAPSHOT_LOCKED ); -return copy_to_user (ifr->ifr_data, &cfg,sizeof (cfg)) ? -EFAULT :0 ; +return 0 ; +} + +static int pch_gbe_hwtstamp_get (struct net_device *netdev, +struct kernel_hwtstamp_config *cfg) +{ +struct pch_gbe_adapter *adapter =netdev_priv (netdev); + + cfg->tx_type = adapter->hwts_tx_en ?HWTSTAMP_TX_ON :HWTSTAMP_TX_OFF ; + cfg->rx_filter = adapter->hwts_rx_en; + +return 0 ; }static inline void pch_gbe_mac_load_mac_addr (struct pch_gbe_hw *hw)
@@ -2234,9 +2243,6 @@ static int pch_gbe_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd)netdev_dbg (netdev,"cmd : 0x%04x\n" , cmd); -if (cmd ==SIOCSHWTSTAMP ) -return hwtstamp_ioctl (netdev, ifr, cmd); -return generic_mii_ioctl (&adapter->mii,if_mii (ifr), cmd,NULL ); }
@@ -2328,6 +2334,8 @@ static const struct net_device_ops pch_gbe_netdev_ops = {#ifdef CONFIG_NET_POLL_CONTROLLER .ndo_poll_controller = pch_gbe_netpoll, #endif + .ndo_hwtstamp_get = pch_gbe_hwtstamp_get, + .ndo_hwtstamp_set = pch_gbe_hwtstamp_set, }; static pci_ers_result_t pch_gbe_io_error_detected(struct pci_dev *pdev,
Signature · 1 line
2.47.3
PATCH 7/7 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.
--- drivers/net/ethernet/qlogic/qede/qede_main.c | 22 +-------- drivers/net/ethernet/qlogic/qede/qede_ptp.c | 47 ++++++++++++++------ drivers/net/ethernet/qlogic/qede/qede_ptp.h | 6 ++- 3 files changed, 40 insertions(+), 35 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 +33 -14
68 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
Re: [PATCH net-next 1/7] bnx2x: convert to use ndo_hwtstamp callbacks
In reply to Vadim FedorenkoQuoted 3 lines · On Fri, 31 Oct 2025 00:46:01 +0000 Vadim Fedorenko <[email protected]>…
The driver implemented SIOCSHWTSTAMP ioctl command only, but at the same time it has configuration stored in a private structure. Implement both
ndo_hwtstamp_setandndo_hwtstamp_getcallback using stored info.
Thank you!
Signature · 3 lines
Köry Maincent, Bootlin Embedded Linux and kernel engineering https://bootlin.com
Re: [PATCH net-next 2/7] net: liquidio: convert to use ndo_hwtstamp callbacks
In reply to Vadim FedorenkoQuoted 3 lines · On Fri, 31 Oct 2025 00:46:02 +0000 Vadim Fedorenko <[email protected]>…
The driver implemented SIOCSHWTSTAMP ioctl command only, but there is a way to get configured status. Implement both
ndo_hwtstamp_setandndo_hwtstamp_getcallbacks.
Thank you!
Signature · 3 lines
Köry Maincent, Bootlin Embedded Linux and kernel engineering https://bootlin.com
Quoted 4 lines · On Fri, 31 Oct 2025 00:46:00 +0000 Vadim Fedorenko <[email protected]>…
This patchset converts the rest of ethernet drivers to use ndo callbacks instead ioctl to configure and report time stamping. The drivers in part 3 originally implemented only SIOCSHWTSTAMP command, but converted to also provide configuration back to users.
For these 3 patches, maybe it is better to split them in two to separate the NDO conversion from the hwtstamp_get support. I will let Jakub with the final word on this.
Quoted 20 lines
Vadim Fedorenko (7):
bnx2x: convert to usendo_hwtstampcallbacks
net: liquidio: convert to usendo_hwtstampcallbacks
net:liquidio_vf: convert to usendo_hwtstampcallbacks
net: octeon: mgmt: convert to usendo_hwtstampcallbacks
net: thunderx: convert to usendo_hwtstampcallbacks
net:pch_gbe: convert to usendo_hwtstampcallbacks
qede: convert to usendo_hwtstampcallbacks.../net/ethernet/broadcom/bnx2x/bnx2x_main.c | 53 +++++++++------- .../net/ethernet/cavium/liquidio/lio_main.c | 50 ++++++--------- .../ethernet/cavium/liquidio/lio_vf_main.c | 48 ++++++-------- .../net/ethernet/cavium/octeon/octeon_mgmt.c | 62 ++++++++++--------- .../net/ethernet/cavium/thunder/nicvf_main.c | 45 ++++++++------ .../ethernet/oki-semi/pch_gbe/pch_gbe_main.c | 40 +++++++----- drivers/net/ethernet/qlogic/qede/qede_main.c | 22 +------ drivers/net/ethernet/qlogic/qede/qede_ptp.c | 47 +++++++++----- drivers/net/ethernet/qlogic/qede/qede_ptp.h | 6 +- 9 files changed, 191 insertions(+), 182 deletions(-)
Signature · 3 lines
Köry Maincent, Bootlin Embedded Linux and kernel engineering https://bootlin.com
Re: [PATCH net-next 4/7] net: octeon: mgmt: convert to use ndo_hwtstamp callbacks
In reply to Vadim FedorenkoQuoted 5 lines · On Fri, 31 Oct 2025 00:46:04 +0000 Vadim Fedorenko <[email protected]>…
The driver implemented SIOCSHWTSTAMP ioctl command only. But it stores timestamping configuration, so it is possible to report it to users. Implement both
ndo_hwtstamp_setandndo_hwtstamp_getcallbacks. After this thendo_eth_ioctleffectively becomesphy_do_ioctl- adjust callback accrodingly.
Thank you!
Signature · 3 lines
Köry Maincent, Bootlin Embedded Linux and kernel engineering https://bootlin.com
Re: [PATCH net-next 4/7] net: octeon: mgmt: convert to use ndo_hwtstamp callbacks
Quoted 8 lines · On Fri, 31 Oct 2025 18:16:53 +0100 Kory Maincent <[email protected]>…
Quoted 5 lines · On Fri, 31 Oct 2025 00:46:04 +0000 Vadim Fedorenko <[email protected]>…
The driver implemented SIOCSHWTSTAMP ioctl command only. But it stores timestamping configuration, so it is possible to report it to users. Implement both
ndo_hwtstamp_setandndo_hwtstamp_getcallbacks. After this thendo_eth_ioctleffectively becomesphy_do_ioctl- adjust callback accrodingly.
nitpick if there is a v2: "accordingly"
Quoted 3 lines
Reviewed-by Kory Maincent <[email protected]>Thank you!
Signature · 3 lines
Köry Maincent, Bootlin Embedded Linux and kernel engineering https://bootlin.com
Re: [PATCH net-next 3/7] net: liquidio_vf: convert to use ndo_hwtstamp callbacks
In reply to Vadim FedorenkoQuoted 3 lines · On Fri, 31 Oct 2025 00:46:03 +0000 Vadim Fedorenko <[email protected]>…
The driver implemented SIOCSHWTSTAMP ioctl command only, but there is a way to get configuration back. Implement both
ndo_hwtstamp_setandndo_hwtstamp_setcallbacks.
Thank you!
Signature · 3 lines
Köry Maincent, Bootlin Embedded Linux and kernel engineering https://bootlin.com
Re: [PATCH net-next 5/7] net: thunderx: convert to use ndo_hwtstamp callbacks
In reply to Vadim FedorenkoQuoted 4 lines · On Fri, 31 Oct 2025 00:46:05 +0000 Vadim Fedorenko <[email protected]>…
The driver implemented SIOCSHWTSTAMP ioctl command only, but it also stores configuration in private data, so it's possible to report it back to users. Implement both
ndo_hwtstamp_setandndo_hwtstamp_getcallbacks.
Thank you!
Signature · 3 lines
Köry Maincent, Bootlin Embedded Linux and kernel engineering https://bootlin.com
Re: [PATCH net-next 6/7] net: pch_gbe: convert to use ndo_hwtstamp callbacks
In reply to Vadim FedorenkoQuoted 40 lines · On Fri, 31 Oct 2025 00:46:06 +0000 Vadim Fedorenko <[email protected]>…
The driver implemented SIOCSHWTSTAMP ioctl command only, but it stores configuration in the private data, so it is possible to report it back to users. Implement both
ndo_hwtstamp_setandndo_hwtstamp_getcallbacks. To properly report RX filter type, store it inhwts_rx_eninstead of using this field as a simple flag. The logic didn't change because receive path used this field as boolean flag.Signed-off-by Vadim Fedorenko <[email protected]>--- .../ethernet/oki-semi/pch_gbe/pch_gbe_main.c | 40 +++++++++++-------- 1 file changed, 24 insertions(+), 16 deletions(-)(quoted diff) +0
-0
b/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.cindexe5a6f59af0b6..4049137abc40100644 ---a/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c+++b/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c@@ -198,42 +198,40 @@pch_tx_timestamp(struct pch_gbe_adapter *adapter, struct sk_buff *skb)pch_ch_event_write(pdev, TX_SNAPSHOT_LOCKED); }-static int
hwtstamp_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd)+static int pch_gbe_hwtstamp_set(structnet_device*netdev,drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c +3
-5+struct kernel_hwtstamp_config *cfg, + struct netlink_ext_ack *extack) { -struct hwtstamp_config cfg; struct pch_gbe_adapter *adapter = netdev_priv(netdev);struct pci_dev *pdev;u8 station[20 ]; -if (copy_from_user (&cfg, ifr->ifr_data,sizeof (cfg))) -return -EFAULT ; -/* Get ieee1588's dev information */ pdev = adapter->ptp_pdev; -if (cfg.tx_type !=HWTSTAMP_TX_OFF && cfg.tx_type !=HWTSTAMP_TX_ON ) + if (cfg->tx_type != HWTSTAMP_TX_OFF && cfg->tx_type !=
HWTSTAMP_TX_ON) return-ERANGE;
drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c pch_tx_timestamp(struct pch_gbe_adapter *adapter, struct sk_buff *skb) · line 220
Quoted 8 lines
drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c +2
-2-switch (cfg.rx_filter) { +switch (cfg->rx_filter) {case HWTSTAMP_FILTER_NONE : adapter->hwts_rx_en =0 ;break ;case HWTSTAMP_FILTER_PTP_V1_L4_SYNC : - adapter->hwts_rx_en =0 ; + adapter->hwts_rx_en = cfg->rx_filter;
It seems there is a functional change here.
Regards,
Signature · 3 lines
Köry Maincent, Bootlin Embedded Linux and kernel engineering https://bootlin.com
Re: [PATCH net-next 7/7] qede: convert to use ndo_hwtstamp callbacks
In reply to Vadim FedorenkoQuoted 3 lines · On Fri, 31 Oct 2025 00:46:07 +0000 Vadim Fedorenko <[email protected]>…
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.
Thank you!
Signature · 3 lines
Köry Maincent, Bootlin Embedded Linux and kernel engineering https://bootlin.com
Quoted 11 lines · On Fri, 31 Oct 2025 18:10:27 +0100 Kory Maincent <[email protected]>…
Quoted 4 lines · On Fri, 31 Oct 2025 00:46:00 +0000 Vadim Fedorenko <[email protected]>…
This patchset converts the rest of ethernet drivers to use ndo callbacks instead ioctl to configure and report time stamping. The drivers in part 3 originally implemented only SIOCSHWTSTAMP command, but converted to also provide configuration back to users.
For these 3 patches, maybe it is better to split them in two to separate the NDO conversion from the
hwtstamp_getsupport. I will let Jakub with the final word on this.
After a review, I found out that the patches are quite straightforward, so it is ok to not split them.
Regards,
Signature · 3 lines
Köry Maincent, Bootlin Embedded Linux and kernel engineering https://bootlin.com
Jakub Kicinski
maintainerRe: [PATCH net-next 6/7] net: pch_gbe: convert to use ndo_hwtstamp callbacks
In reply to Kory MaincentQuoted 7 lines · On Fri, 31 Oct 2025 18:35:25 +0100 Kory Maincent wrote:
drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c pch_tx_timestamp(struct pch_gbe_adapter *adapter, struct sk_buff *skb) · line 220
Quoted 3 lines
drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c +1
-1case HWTSTAMP_FILTER_PTP_V1_L4_SYNC : - adapter->hwts_rx_en =0 ; + adapter->hwts_rx_en = cfg->rx_filter;It seems there is a functional change here.
Quoted 1 line
pch_ch_control_write(pdev, SLAVE_MODE | CAP_MODE0);
Good catch. Looks like SLAVE | MODE0 translates to 0 | 0 so presumably the device doesn't actually support timestamping of V1 L4 SYNC messages? Unclear what to do about this. Maybe let's leave it be? keep the hwts_rx_en = 0; ? Not strictly correct but at least we won't break anything.
Re: [PATCH net-next 6/7] net: pch_gbe: convert to use ndo_hwtstamp callbacks
Quoted 7 lines · Jakub Kicinski
Quoted 6 lines · On Fri, 31 Oct 2025 18:35:25 +0100 Kory Maincent wrote:
Review
Quoted 3 lines
case
HWTSTAMP_FILTER_PTP_V1_L4_SYNC:(quoted diff) +1
-1- adapter->hwts_rx_en = 0; + adapter->hwts_rx_en = cfg->rx_filter;It seems there is a functional change here.
Quoted 7 lines
Quoted 1 line
Quoted 1 line
pch_ch_control_write(pdev, SLAVE_MODE | CAP_MODE0);Good catch. Looks like SLAVE | MODE0 translates to 0 | 0 so presumably the device doesn't actually support timestamping of V1 L4 SYNC messages? Unclear what to do about this. Maybe let's leave it be? keep the
hwts_rx_en= 0; ? Not strictly correct but at least we won't break anything.
Ok, it looked like typo as the function actually does the register
manipulation while it's not doing anything for disabling RX timestamping
which probably means it's enabled by default.
But as the code was added back in 2012, and nobody complained, we should probably keep it as is. I'll send v2 shortly.