convert net drivers to ndo_hwtstamp API part 1
Subsystems (8)
v2 cover convert net drivers to ndo_hwtstamp API part 1
This is part 1 of patchset to convert drivers which support HW timestamping to use .ndo_hwtstamp_get()/.ndo_hwtstamp_set() callbacks. The new API uses netlink to communicate with user-space and have some test coverage. Part 2 will contain another 6 patches from v1 of the series.
There are some drivers left with old ioctl interface after this series:
- mlx5 driver be shortly converted by nVidia folks
- TI netcp ethss driver which needs separate series which I'll post after this one.
v1 -> v2:
- split series into 2 to avoid spamming a lot of maintainers
Vadim Fedorenko (7):
net: ti: am65-cpsw: move hw timestamping to ndo callback
ti: icssg: convert to ndo_hwtstamp API
amd-xgbe: convert to ndo_hwtstamp callbacks
net: atlantic: convert to ndo_hwtstamp API
cxgb4: convert to ndo_hwtstamp API
tsnep: convert to ndo_hwtstatmp API
funeth: convert to ndo_hwtstamp API
drivers/net/ethernet/amd/xgbe/xgbe-drv.c | 24 +-- drivers/net/ethernet/amd/xgbe/xgbe-hwtstamp.c | 28 ++-- drivers/net/ethernet/amd/xgbe/xgbe.h | 11 +- .../net/ethernet/aquantia/atlantic/aq_main.c | 66 ++------ .../net/ethernet/aquantia/atlantic/aq_ptp.c | 6 +- .../net/ethernet/aquantia/atlantic/aq_ptp.h | 8 +- drivers/net/ethernet/chelsio/cxgb4/cxgb4.h | 2 +- .../net/ethernet/chelsio/cxgb4/cxgb4_main.c | 154 +++++++++--------- drivers/net/ethernet/engleder/tsnep.h | 8 +- drivers/net/ethernet/engleder/tsnep_main.c | 14 +- drivers/net/ethernet/engleder/tsnep_ptp.c | 88 +++++----- drivers/net/ethernet/fungible/funeth/funeth.h | 4 +- .../ethernet/fungible/funeth/funeth_main.c | 40 ++--- drivers/net/ethernet/ti/am65-cpsw-nuss.c | 44 +++-- drivers/net/ethernet/ti/icssg/icssg_common.c | 47 ++---- drivers/net/ethernet/ti/icssg/icssg_prueth.c | 4 +- drivers/net/ethernet/ti/icssg/icssg_prueth.h | 6 +- .../net/ethernet/ti/icssg/icssg_prueth_sr1.c | 4 +- 18 files changed, 235 insertions(+), 323 deletions(-)
Signature · 1 line
2.47.3
PATCH v2 1/7 net: ti: am65-cpsw: move hw timestamping to ndo callback
Migrate driver to new API for HW timestamping.
--- drivers/net/ethernet/ti/am65-cpsw-nuss.c | 44 +++++++++++------------- 1 file changed, 20 insertions(+), 24 deletions(-)
drivers/net/ethernet/ti/am65-cpsw-nuss.c +20 -24
@@ -1788,28 +1788,28 @@ static int am65_cpsw_nuss_ndo_slave_set_mac_address(struct net_device *ndev, }static int am65_cpsw_nuss_hwtstamp_set (struct net_device *ndev, -struct ifreq *ifr) +struct kernel_hwtstamp_config *cfg, +struct netlink_ext_ack *extack) {struct am65_cpsw_port *port =am65_ndev_to_port (ndev);u32 ts_ctrl, seq_id, ts_ctrl_ltype2, ts_vlan_ltype; -struct hwtstamp_config cfg; -if (!IS_ENABLED (CONFIG_TI_K3_AM65_CPTS )) +if (!IS_ENABLED (CONFIG_TI_K3_AM65_CPTS )) { +NL_SET_ERR_MSG (extack,"Time stamping is not supported" );return -EOPNOTSUPP ; - -if (copy_from_user (&cfg, ifr->ifr_data,sizeof (cfg))) -return -EFAULT ; + }/* TX HW timestamp */ -switch (cfg.tx_type) { +switch (cfg->tx_type) {case HWTSTAMP_TX_OFF :case HWTSTAMP_TX_ON :break ;default : +NL_SET_ERR_MSG (extack,"TX mode is not supported" );return -ERANGE ; } -switch (cfg.rx_filter) { +switch (cfg->rx_filter) {case HWTSTAMP_FILTER_NONE : port->rx_ts_enabled = false;break ;
@@ -1826,17 +1826,19 @@ static int am65_cpsw_nuss_hwtstamp_set(struct net_device *ndev,case HWTSTAMP_FILTER_PTP_V2_SYNC :case HWTSTAMP_FILTER_PTP_V2_DELAY_REQ : port->rx_ts_enabled = true; - cfg.rx_filter =HWTSTAMP_FILTER_PTP_V2_EVENT |HWTSTAMP_FILTER_PTP_V1_L4_EVENT ; + cfg->rx_filter =HWTSTAMP_FILTER_PTP_V2_EVENT |HWTSTAMP_FILTER_PTP_V1_L4_EVENT ;break ;case HWTSTAMP_FILTER_ALL :case HWTSTAMP_FILTER_SOME :case HWTSTAMP_FILTER_NTP_ALL : +NL_SET_ERR_MSG (extack,"RX filter is not supported" );return -EOPNOTSUPP ;default : +NL_SET_ERR_MSG (extack,"RX filter is not supported" );return -ERANGE ; } - port->tx_ts_enabled = (cfg.tx_type ==HWTSTAMP_TX_ON ); + port->tx_ts_enabled = (cfg->tx_type ==HWTSTAMP_TX_ON );/* cfg TX timestamp */ seq_id = (AM65_CPSW_TS_SEQ_ID_OFFSET <<
@@ -1872,25 +1874,24 @@ static int am65_cpsw_nuss_hwtstamp_set(struct net_device *ndev, AM65_CPSW_PORTN_REG_TS_CTL_LTYPE2);writel (ts_ctrl, port->port_base +AM65_CPSW_PORTN_REG_TS_CTL ); -return copy_to_user (ifr->ifr_data, &cfg,sizeof (cfg)) ? -EFAULT :0 ; +return 0 ; }static int am65_cpsw_nuss_hwtstamp_get (struct net_device *ndev, -struct ifreq *ifr) +struct kernel_hwtstamp_config *cfg) {struct am65_cpsw_port *port =am65_ndev_to_port (ndev); -struct hwtstamp_config cfg;if (!IS_ENABLED (CONFIG_TI_K3_AM65_CPTS ))return -EOPNOTSUPP ; - cfg.flags =0 ; - cfg.tx_type = port->tx_ts_enabled ? + cfg->flags =0 ; + cfg->tx_type = port->tx_ts_enabled ?HWTSTAMP_TX_ON :HWTSTAMP_TX_OFF ; - cfg.rx_filter = port->rx_ts_enabled ?HWTSTAMP_FILTER_PTP_V2_EVENT | + cfg->rx_filter = port->rx_ts_enabled ?HWTSTAMP_FILTER_PTP_V2_EVENT |HWTSTAMP_FILTER_PTP_V1_L4_EVENT :HWTSTAMP_FILTER_NONE ; -return copy_to_user (ifr->ifr_data, &cfg,sizeof (cfg)) ? -EFAULT :0 ; +return 0 ; } static int am65_cpsw_nuss_ndo_slave_ioctl(struct net_device *ndev,
@@ -1901,13 +1902,6 @@ static int am65_cpsw_nuss_ndo_slave_ioctl(struct net_device *ndev,if (!netif_running (ndev))return -EINVAL ; -switch (cmd) { -case SIOCSHWTSTAMP : -return am65_cpsw_nuss_hwtstamp_set (ndev, req); -case SIOCGHWTSTAMP : -return am65_cpsw_nuss_hwtstamp_get (ndev, req); - } -return phylink_mii_ioctl (port->slave.phylink, req, cmd); }
@@ -1991,6 +1985,8 @@ static const struct net_device_ops am65_cpsw_nuss_netdev_ops = { .ndo_set_tx_maxrate = am65_cpsw_qos_ndo_tx_p0_set_maxrate, .ndo_bpf = am65_cpsw_ndo_bpf, .ndo_xdp_xmit = am65_cpsw_ndo_xdp_xmit, + .ndo_hwtstamp_get = am65_cpsw_nuss_hwtstamp_get, + .ndo_hwtstamp_set = am65_cpsw_nuss_hwtstamp_set, };static void am65_cpsw_disable_phy (struct phy *phy)
Signature · 1 line
2.47.3
PATCH v2 2/7 ti: icssg: convert to ndo_hwtstamp API
In reply to Vadim FedorenkoConvert driver to use .ndo_hwtstamp_get()/.ndo_hwtstamp_set() API. .ndo_eth_ioctl() implementation becomes pure phy_do_ioctl(), remove it from common module, remove exported symbol and replace ndo callback.
--- drivers/net/ethernet/ti/icssg/icssg_common.c | 47 ++++++------------- drivers/net/ethernet/ti/icssg/icssg_prueth.c | 4 +- drivers/net/ethernet/ti/icssg/icssg_prueth.h | 6 ++- .../net/ethernet/ti/icssg/icssg_prueth_sr1.c | 4 +- 4 files changed, 26 insertions(+), 35 deletions(-)
drivers/net/ethernet/ti/icssg/icssg_common.c +15 -32
@@ -1223,15 +1223,13 @@ void icssg_ndo_tx_timeout(struct net_device *ndev, unsigned int txqueue) }EXPORT_SYMBOL_GPL (icssg_ndo_tx_timeout); -static int emac_set_ts_config (struct net_device *ndev,struct ifreq *ifr) +int icssg_ndo_set_ts_config (struct net_device *ndev, +struct kernel_hwtstamp_config *config, +struct netlink_ext_ack *extack) {struct prueth_emac *emac =netdev_priv (ndev); -struct hwtstamp_config config; -if (copy_from_user (&config, ifr->ifr_data,sizeof (config))) -return -EFAULT ; - -switch (config.tx_type) { +switch (config->tx_type) {case HWTSTAMP_TX_OFF : emac->tx_ts_enabled =0 ;break ;
@@ -1242,7 +1240,7 @@ static int emac_set_ts_config(struct net_device *ndev, struct ifreq *ifr)return -ERANGE ; } -switch (config.rx_filter) { +switch (config->rx_filter) {case HWTSTAMP_FILTER_NONE : emac->rx_ts_enabled =0 ;break ;
@@ -1262,43 +1260,28 @@ static int emac_set_ts_config(struct net_device *ndev, struct ifreq *ifr)case HWTSTAMP_FILTER_PTP_V2_DELAY_REQ :case HWTSTAMP_FILTER_NTP_ALL : emac->rx_ts_enabled =1 ; - config.rx_filter =HWTSTAMP_FILTER_ALL ; + config->rx_filter =HWTSTAMP_FILTER_ALL ;break ;default :return -ERANGE ; } -return copy_to_user (ifr->ifr_data, &config,sizeof (config)) ? - -EFAULT :0 ; +return 0 ; } +EXPORT_SYMBOL_GPL (icssg_ndo_set_ts_config); -static int emac_get_ts_config (struct net_device *ndev,struct ifreq *ifr) +int icssg_ndo_get_ts_config (struct net_device *ndev, +struct kernel_hwtstamp_config *config) {struct prueth_emac *emac =netdev_priv (ndev); -struct hwtstamp_config config; - - config.flags =0 ; - config.tx_type = emac->tx_ts_enabled ?HWTSTAMP_TX_ON :HWTSTAMP_TX_OFF ; - config.rx_filter = emac->rx_ts_enabled ?HWTSTAMP_FILTER_ALL :HWTSTAMP_FILTER_NONE ; - -return copy_to_user (ifr->ifr_data, &config,sizeof (config)) ? - -EFAULT :0 ; -} -int icssg_ndo_ioctl (struct net_device *ndev,struct ifreq *ifr,int cmd) -{ -switch (cmd) { -case SIOCGHWTSTAMP : -return emac_get_ts_config (ndev, ifr); -case SIOCSHWTSTAMP : -return emac_set_ts_config (ndev, ifr); -default : -break ; - } + config->flags =0 ; + config->tx_type = emac->tx_ts_enabled ?HWTSTAMP_TX_ON :HWTSTAMP_TX_OFF ; + config->rx_filter = emac->rx_ts_enabled ?HWTSTAMP_FILTER_ALL :HWTSTAMP_FILTER_NONE ; -return phy_do_ioctl (ndev, ifr, cmd); +return 0 ; } -EXPORT_SYMBOL_GPL (icssg_ndo_ioctl); +EXPORT_SYMBOL_GPL (icssg_ndo_get_ts_config);void icssg_ndo_get_stats64 (struct net_device *ndev,struct rtnl_link_stats64 *stats)
drivers/net/ethernet/ti/icssg/icssg_prueth.c +3 -1
@@ -1168,7 +1168,7 @@ static const struct net_device_ops emac_netdev_ops = { .ndo_validate_addr = eth_validate_addr, .ndo_tx_timeout = icssg_ndo_tx_timeout, .ndo_set_rx_mode = emac_ndo_set_rx_mode, - .ndo_eth_ioctl = icssg_ndo_ioctl, + .ndo_eth_ioctl = phy_do_ioctl, .ndo_get_stats64 = icssg_ndo_get_stats64, .ndo_get_phys_port_name = icssg_ndo_get_phys_port_name, .ndo_fix_features = emac_ndo_fix_features,
@@ -1176,6 +1176,8 @@ static const struct net_device_ops emac_netdev_ops = { .ndo_vlan_rx_kill_vid = emac_ndo_vlan_rx_del_vid, .ndo_bpf = emac_ndo_bpf, .ndo_xdp_xmit = emac_xdp_xmit, + .ndo_hwtstamp_get = icssg_ndo_get_ts_config, + .ndo_hwtstamp_set = icssg_ndo_set_ts_config, }; static int prueth_netdev_init(struct prueth *prueth,
drivers/net/ethernet/ti/icssg/icssg_prueth.h +5 -1
@@ -479,7 +479,11 @@ void prueth_reset_tx_chan(struct prueth_emac *emac, int ch_num,void prueth_reset_rx_chan (struct prueth_rx_chn *chn,int num_flows,bool disable);void icssg_ndo_tx_timeout (struct net_device *ndev,unsigned int txqueue); -int icssg_ndo_ioctl (struct net_device *ndev,struct ifreq *ifr,int cmd); +int icssg_ndo_get_ts_config (struct net_device *ndev, +struct kernel_hwtstamp_config *config); +int icssg_ndo_set_ts_config (struct net_device *ndev, +struct kernel_hwtstamp_config *config, +struct netlink_ext_ack *extack);void icssg_ndo_get_stats64 (struct net_device *ndev,struct rtnl_link_stats64 *stats); int icssg_ndo_get_phys_port_name(struct net_device *ndev, char *name,
drivers/net/ethernet/ti/icssg/icssg_prueth_sr1.c +3 -1
@@ -747,9 +747,11 @@ static const struct net_device_ops emac_netdev_ops = { .ndo_validate_addr = eth_validate_addr, .ndo_tx_timeout = icssg_ndo_tx_timeout, .ndo_set_rx_mode = emac_ndo_set_rx_mode_sr1, - .ndo_eth_ioctl = icssg_ndo_ioctl, + .ndo_eth_ioctl = phy_do_ioctl, .ndo_get_stats64 = icssg_ndo_get_stats64, .ndo_get_phys_port_name = icssg_ndo_get_phys_port_name, + .ndo_hwtstamp_get = icssg_ndo_get_ts_config, + .ndo_hwtstamp_set = icssg_ndo_set_ts_config, }; static int prueth_netdev_init(struct prueth *prueth,
Signature · 1 line
2.47.3
PATCH v2 3/7 amd-xgbe: convert to ndo_hwtstamp callbacks
In reply to Vadim FedorenkoConvert driver to use .ndo_hwtstamp_get()/.ndo_hwtstamp_set() callbacks. .ndo_eth_ioctl() becomes empty function, remove it.
--- drivers/net/ethernet/amd/xgbe/xgbe-drv.c | 24 ++-------------- drivers/net/ethernet/amd/xgbe/xgbe-hwtstamp.c | 28 +++++++++---------- drivers/net/ethernet/amd/xgbe/xgbe.h | 11 ++++---- 3 files changed, 21 insertions(+), 42 deletions(-)
drivers/net/ethernet/amd/xgbe/xgbe-drv.c +2 -22
@@ -1755,27 +1755,6 @@ static int xgbe_set_mac_address(struct net_device *netdev, void *addr)return 0 ; } -static int xgbe_ioctl (struct net_device *netdev,struct ifreq *ifreq,int cmd) -{ -struct xgbe_prv_data *pdata =netdev_priv (netdev); -int ret; - -switch (cmd) { -case SIOCGHWTSTAMP : - ret =xgbe_get_hwtstamp_settings (pdata, ifreq); -break ; - -case SIOCSHWTSTAMP : - ret =xgbe_set_hwtstamp_settings (pdata, ifreq); -break ; - -default : - ret = -EOPNOTSUPP ; - } - -return ret; -} -static int xgbe_change_mtu (struct net_device *netdev,int mtu) {struct xgbe_prv_data *pdata =netdev_priv (netdev);
@@ -2021,7 +2000,6 @@ static const struct net_device_ops xgbe_netdev_ops = { .ndo_set_rx_mode = xgbe_set_rx_mode, .ndo_set_mac_address = xgbe_set_mac_address, .ndo_validate_addr = eth_validate_addr, - .ndo_eth_ioctl = xgbe_ioctl, .ndo_change_mtu = xgbe_change_mtu, .ndo_tx_timeout = xgbe_tx_timeout, .ndo_get_stats64 = xgbe_get_stats64,
@@ -2034,6 +2012,8 @@ static const struct net_device_ops xgbe_netdev_ops = { .ndo_fix_features = xgbe_fix_features, .ndo_set_features = xgbe_set_features, .ndo_features_check = xgbe_features_check, + .ndo_hwtstamp_get = xgbe_get_hwtstamp_settings, + .ndo_hwtstamp_set = xgbe_set_hwtstamp_settings, };const struct net_device_ops *xgbe_get_netdev_ops (void )
drivers/net/ethernet/amd/xgbe/xgbe-hwtstamp.c +13 -15
@@ -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 ; -switch (config.tx_type) { +switch (config->tx_type) {case HWTSTAMP_TX_OFF :break ;
@@ -188,7 +186,7 @@ int xgbe_set_hwtstamp_settings(struct xgbe_prv_data *pdata, struct ifreq *ifreq)return -ERANGE ; } -switch (config.rx_filter) { +switch (config->rx_filter) {case HWTSTAMP_FILTER_NONE :break ;
@@ -290,7 +288,7 @@ int xgbe_set_hwtstamp_settings(struct xgbe_prv_data *pdata, struct ifreq *ifreq)xgbe_config_tstamp (pdata, mac_tscr); -memcpy (&pdata->tstamp_config, &config,sizeof (config)); + pdata->tstamp_config = *config;return 0 ; }
drivers/net/ethernet/amd/xgbe/xgbe.h +6 -5
@@ -1146,7 +1146,7 @@ struct xgbe_prv_data {spinlock_t tstamp_lock;struct ptp_clock_info ptp_clock_info;struct ptp_clock *ptp_clock; -struct hwtstamp_config tstamp_config; +struct kernel_hwtstamp_config tstamp_config;unsigned int tstamp_addend;struct work_struct tx_tstamp_work;struct sk_buff *tx_tstamp_skb;
@@ -1307,10 +1307,11 @@ void xgbe_update_tstamp_addend(struct xgbe_prv_data *pdata,void xgbe_set_tstamp_time (struct xgbe_prv_data *pdata,unsigned int sec,unsigned int nsec);void xgbe_tx_tstamp (struct work_struct *work); -int xgbe_get_hwtstamp_settings (struct xgbe_prv_data *pdata, -struct ifreq *ifreq); -int xgbe_set_hwtstamp_settings (struct xgbe_prv_data *pdata, -struct ifreq *ifreq); +int xgbe_get_hwtstamp_settings (struct net_device *netdev, +struct kernel_hwtstamp_config *config); +int xgbe_set_hwtstamp_settings (struct net_device *netdev, +struct kernel_hwtstamp_config *config, +struct netlink_ext_ack *extack);void xgbe_prep_tx_tstamp (struct xgbe_prv_data *pdata,struct sk_buff *skb,struct xgbe_packet_data *packet);
Signature · 1 line
2.47.3
PATCH v2 4/7 net: atlantic: convert to ndo_hwtstamp API
In reply to Vadim FedorenkoConvert driver to .ndo_hwtstamp_get()/.ndo_hwtstamp_set() callbacks. .ndo_eth_ioctl() becomes empty so remove it. Also simplify code with no functional changes.
--- .../net/ethernet/aquantia/atlantic/aq_main.c | 66 +++++-------------- .../net/ethernet/aquantia/atlantic/aq_ptp.c | 6 +- .../net/ethernet/aquantia/atlantic/aq_ptp.h | 8 +-- 3 files changed, 22 insertions(+), 58 deletions(-)
drivers/net/ethernet/aquantia/atlantic/aq_main.c +15 -51
@@ -258,10 +258,15 @@ static void aq_ndev_set_multicast_settings(struct net_device *ndev) (void )aq_nic_set_multicast_list (aq_nic, ndev); } -#if IS_REACHABLE (CONFIG_PTP_1588_CLOCK ) -static int aq_ndev_config_hwtstamp (struct aq_nic_s *aq_nic, -struct hwtstamp_config *config) +static int aq_ndev_hwtstamp_set (struct net_device *netdev, +struct kernel_hwtstamp_config *config, +struct netlink_ext_ack *extack) { +struct aq_nic_s *aq_nic =netdev_priv (netdev); + +if (!IS_REACHABLE (CONFIG_PTP_1588_CLOCK ) || !aq_nic->aq_ptp) +return -EOPNOTSUPP ; +switch (config->tx_type) {case HWTSTAMP_TX_OFF :case HWTSTAMP_TX_ON :
@@ -290,59 +295,17 @@ static int aq_ndev_config_hwtstamp(struct aq_nic_s *aq_nic,return aq_ptp_hwtstamp_config_set (aq_nic->aq_ptp, config); } -#endif - -static int aq_ndev_hwtstamp_set (struct aq_nic_s *aq_nic,struct ifreq *ifr) -{ -struct hwtstamp_config config; -#if IS_REACHABLE (CONFIG_PTP_1588_CLOCK ) -int ret_val; -#endif - -if (!aq_nic->aq_ptp) -return -EOPNOTSUPP ; - -if (copy_from_user (&config, ifr->ifr_data,sizeof (config))) -return -EFAULT ; -#if IS_REACHABLE (CONFIG_PTP_1588_CLOCK ) - ret_val =aq_ndev_config_hwtstamp (aq_nic, &config); -if (ret_val) -return ret_val; -#endif - -return copy_to_user (ifr->ifr_data, &config,sizeof (config)) ? - -EFAULT :0 ; -} -#if IS_REACHABLE (CONFIG_PTP_1588_CLOCK ) -static int aq_ndev_hwtstamp_get (struct aq_nic_s *aq_nic,struct ifreq *ifr) +static int aq_ndev_hwtstamp_get (struct net_device *netdev, +struct kernel_hwtstamp_config *config) { -struct hwtstamp_config config; +struct aq_nic_s *aq_nic =netdev_priv (netdev);if (!aq_nic->aq_ptp)return -EOPNOTSUPP ; -aq_ptp_hwtstamp_config_get (aq_nic->aq_ptp, &config); -return copy_to_user (ifr->ifr_data, &config,sizeof (config)) ? - -EFAULT :0 ; -} -#endif - -static int aq_ndev_ioctl (struct net_device *netdev,struct ifreq *ifr,int cmd) -{ -struct aq_nic_s *aq_nic =netdev_priv (netdev); - -switch (cmd) { -case SIOCSHWTSTAMP : -return aq_ndev_hwtstamp_set (aq_nic, ifr); - -#if IS_REACHABLE (CONFIG_PTP_1588_CLOCK ) -case SIOCGHWTSTAMP : -return aq_ndev_hwtstamp_get (aq_nic, ifr); -#endif - } - -return -EOPNOTSUPP ; +aq_ptp_hwtstamp_config_get (aq_nic->aq_ptp, config); +return 0 ; } static int aq_ndo_vlan_rx_add_vid(struct net_device *ndev, __be16 proto,
@@ -500,12 +463,13 @@ static const struct net_device_ops aq_ndev_ops = { .ndo_set_mac_address = aq_ndev_set_mac_address, .ndo_set_features = aq_ndev_set_features, .ndo_fix_features = aq_ndev_fix_features, - .ndo_eth_ioctl = aq_ndev_ioctl, .ndo_vlan_rx_add_vid = aq_ndo_vlan_rx_add_vid, .ndo_vlan_rx_kill_vid = aq_ndo_vlan_rx_kill_vid, .ndo_setup_tc = aq_ndo_setup_tc, .ndo_bpf = aq_xdp, .ndo_xdp_xmit = aq_xdp_xmit, + .ndo_hwtstamp_get = aq_ndev_hwtstamp_get, + .ndo_hwtstamp_set = aq_ndev_hwtstamp_set, };static int __init aq_ndev_init_module (void )
drivers/net/ethernet/aquantia/atlantic/aq_ptp.c +3 -3
@@ -51,7 +51,7 @@ struct ptp_tx_timeout {struct aq_ptp_s {struct aq_nic_s *aq_nic; -struct hwtstamp_config hwtstamp_config; +struct kernel_hwtstamp_config hwtstamp_config;spinlock_t ptp_lock;spinlock_t ptp_ring_lock;struct ptp_clock *ptp_clock;
@@ -567,7 +567,7 @@ static void aq_ptp_rx_hwtstamp(struct aq_ptp_s *aq_ptp, struct skb_shared_hwtsta }void aq_ptp_hwtstamp_config_get (struct aq_ptp_s *aq_ptp, -struct hwtstamp_config *config) +struct kernel_hwtstamp_config *config) { *config = aq_ptp->hwtstamp_config; }
@@ -588,7 +588,7 @@ static void aq_ptp_prepare_filters(struct aq_ptp_s *aq_ptp) }int aq_ptp_hwtstamp_config_set (struct aq_ptp_s *aq_ptp, -struct hwtstamp_config *config) +struct kernel_hwtstamp_config *config) {struct aq_nic_s *aq_nic = aq_ptp->aq_nic;const struct aq_hw_ops *hw_ops;
drivers/net/ethernet/aquantia/atlantic/aq_ptp.h +4 -4
@@ -60,9 +60,9 @@ void aq_ptp_tx_hwtstamp(struct aq_nic_s *aq_nic, u64 timestamp);/* Must be to check available of PTP before call */ void aq_ptp_hwtstamp_config_get (struct aq_ptp_s *aq_ptp, -struct hwtstamp_config *config); +struct kernel_hwtstamp_config *config);int aq_ptp_hwtstamp_config_set (struct aq_ptp_s *aq_ptp, -struct hwtstamp_config *config); +struct kernel_hwtstamp_config *config);/* Return either ring is belong to PTP or not*/ bool aq_ptp_ring (struct aq_nic_s *aq_nic,struct aq_ring_s *ring);
@@ -130,9 +130,9 @@ static inline int aq_ptp_xmit(struct aq_nic_s *aq_nic, struct sk_buff *skb)static inline void aq_ptp_tx_hwtstamp (struct aq_nic_s *aq_nic,u64 timestamp) {}static inline void aq_ptp_hwtstamp_config_get (struct aq_ptp_s *aq_ptp, -struct hwtstamp_config *config) {} +struct kernel_hwtstamp_config *config) {}static inline int aq_ptp_hwtstamp_config_set (struct aq_ptp_s *aq_ptp, -struct hwtstamp_config *config) +struct kernel_hwtstamp_config *config) {return 0 ; }
Signature · 1 line
2.47.3
PATCH v2 5/7 cxgb4: convert to ndo_hwtstamp API
In reply to Vadim FedorenkoConvert to use .ndo_hwtstamp_get()/.ndo_hwtstamp_set() callbacks.
Though I'm not quite sure it worked properly before the conversion.
--- drivers/net/ethernet/chelsio/cxgb4/cxgb4.h | 2 +- .../net/ethernet/chelsio/cxgb4/cxgb4_main.c | 154 +++++++++--------- 2 files changed, 79 insertions(+), 77 deletions(-)
drivers/net/ethernet/chelsio/cxgb4/cxgb4.h +1 -1
@@ -674,7 +674,7 @@ struct port_info {struct cxgb_fcoe fcoe;#endif /* CONFIG_CHELSIO_T4_FCOE */ bool rxtstamp;/* Enable TS */ -struct hwtstamp_config tstamp_config; +struct kernel_hwtstamp_config tstamp_config;bool ptp_enable;struct sched_table *sched_tbl;u32 eth_flags;
drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c +78 -76
177 lines not on this page · raw message
Signature · 1 line
2.47.3
PATCH v2 6/7 tsnep: convert to ndo_hwtstatmp API
In reply to Vadim FedorenkoConvert to .ndo_hwtstamp_get()/.ndo_hwtstamp_set() callbacks. After conversions the rest of tsnep_netdev_ioctl() becomes pure phy_do_ioctl_running(), so remove tsnep_netdev_ioctl() and replace it with phy_do_ioctl_running() in .ndo_eth_ioctl.
--- drivers/net/ethernet/engleder/tsnep.h | 8 +- drivers/net/ethernet/engleder/tsnep_main.c | 14 +--- drivers/net/ethernet/engleder/tsnep_ptp.c | 88 +++++++++++----------- 3 files changed, 51 insertions(+), 59 deletions(-)
drivers/net/ethernet/engleder/tsnep.h +6 -2
@@ -176,7 +176,7 @@ struct tsnep_adapter {struct tsnep_gcl gcl[2 ];int next_gcl; -struct hwtstamp_config hwtstamp_config; +struct kernel_hwtstamp_config hwtstamp_config;struct ptp_clock *ptp_clock;struct ptp_clock_info ptp_clock_info;/* ptp clock lock */
@@ -203,7 +203,11 @@ extern const struct ethtool_ops tsnep_ethtool_ops;int tsnep_ptp_init (struct tsnep_adapter *adapter);void tsnep_ptp_cleanup (struct tsnep_adapter *adapter); -int tsnep_ptp_ioctl (struct net_device *netdev,struct ifreq *ifr,int cmd); +int tsnep_ptp_hwtstamp_get (struct net_device *netdev, +struct kernel_hwtstamp_config *config); +int tsnep_ptp_hwtstamp_set (struct net_device *netdev, +struct kernel_hwtstamp_config *config, +struct netlink_ext_ack *extack);int tsnep_tc_init (struct tsnep_adapter *adapter);void tsnep_tc_cleanup (struct tsnep_adapter *adapter);
drivers/net/ethernet/engleder/tsnep_main.c +3 -11
@@ -2168,16 +2168,6 @@ static netdev_tx_t tsnep_netdev_xmit_frame(struct sk_buff *skb,return tsnep_xmit_frame_ring (skb, &adapter->tx[queue_mapping]); } -static int tsnep_netdev_ioctl (struct net_device *netdev,struct ifreq *ifr, -int cmd) -{ -if (!netif_running (netdev)) -return -EINVAL ; -if (cmd ==SIOCSHWTSTAMP || cmd ==SIOCGHWTSTAMP ) -return tsnep_ptp_ioctl (netdev, ifr, cmd); -return phy_mii_ioctl (netdev->phydev, ifr, cmd); -} -static void tsnep_netdev_set_multicast (struct net_device *netdev) {struct tsnep_adapter *adapter =netdev_priv (netdev);
@@ -2384,7 +2374,7 @@ static const struct net_device_ops tsnep_netdev_ops = { .ndo_open = tsnep_netdev_open, .ndo_stop = tsnep_netdev_close, .ndo_start_xmit = tsnep_netdev_xmit_frame, - .ndo_eth_ioctl = tsnep_netdev_ioctl, + .ndo_eth_ioctl = phy_do_ioctl_running, .ndo_set_rx_mode = tsnep_netdev_set_multicast, .ndo_get_stats64 = tsnep_netdev_get_stats64, .ndo_set_mac_address = tsnep_netdev_set_mac_address,
@@ -2394,6 +2384,8 @@ static const struct net_device_ops tsnep_netdev_ops = { .ndo_bpf = tsnep_netdev_bpf, .ndo_xdp_xmit = tsnep_netdev_xdp_xmit, .ndo_xsk_wakeup = tsnep_netdev_xsk_wakeup, + .ndo_hwtstamp_get = tsnep_ptp_hwtstamp_get, + .ndo_hwtstamp_set = tsnep_ptp_hwtstamp_set, };static int tsnep_mac_init (struct tsnep_adapter *adapter)
drivers/net/ethernet/engleder/tsnep_ptp.c +42 -46
99 lines not on this page · raw message
Signature · 1 line
2.47.3
PATCH v2 7/7 funeth: convert to ndo_hwtstamp API
In reply to Vadim FedorenkoConvert driver to use .ndo_hwtstamp_get()/.ndo_hwtstamp_set() callbacks. .ndo_eth_ioctl() implementation becomes empty, remove it.
--- drivers/net/ethernet/fungible/funeth/funeth.h | 4 +- .../ethernet/fungible/funeth/funeth_main.c | 40 +++++++------------ 2 files changed, 16 insertions(+), 28 deletions(-)
drivers/net/ethernet/fungible/funeth/funeth.h +2 -2
@@ -4,7 +4,7 @@#define _FUNETH_H#include <uapi/linux/if_ether.h> -#include <uapi/linux/net_tstamp.h> +#include <linux/net_tstamp.h> #include <linux/mutex.h> #include <linux/seqlock.h> #include <linux/xarray.h>
@@ -121,7 +121,7 @@ struct funeth_priv {u8 rx_coal_usec;u8 rx_coal_count; -struct hwtstamp_config hwtstamp_cfg; +struct kernel_hwtstamp_config hwtstamp_cfg;/* cumulative queue stats from earlier queue instances */ u64 tx_packets;
drivers/net/ethernet/fungible/funeth/funeth_main.c +14 -26
@@ -1014,26 +1014,25 @@ static int fun_get_port_attributes(struct net_device *netdev)return 0 ; } -static int fun_hwtstamp_get (struct net_device *dev,struct ifreq *ifr) +static int fun_hwtstamp_get (struct net_device *dev, +struct kernel_hwtstamp_config *config) {const struct funeth_priv *fp =netdev_priv (dev); -return copy_to_user (ifr->ifr_data, &fp->hwtstamp_cfg, -sizeof (fp->hwtstamp_cfg)) ? -EFAULT :0 ; + *config = fp->hwtstamp_cfg; +return 0 ; } -static int fun_hwtstamp_set (struct net_device *dev,struct ifreq *ifr) +static int fun_hwtstamp_set (struct net_device *dev, +struct kernel_hwtstamp_config *config, +struct netlink_ext_ack *extack) {struct funeth_priv *fp =netdev_priv (dev); -struct hwtstamp_config cfg; - -if (copy_from_user (&cfg, ifr->ifr_data,sizeof (cfg))) -return -EFAULT ;/* no TX HW timestamps */ - cfg.tx_type =HWTSTAMP_TX_OFF ; + config->tx_type =HWTSTAMP_TX_OFF ; -switch (cfg.rx_filter) { +switch (config->rx_filter) {case HWTSTAMP_FILTER_NONE :break ;case HWTSTAMP_FILTER_ALL :
@@ -1051,26 +1050,14 @@ static int fun_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 : - cfg.rx_filter =HWTSTAMP_FILTER_ALL ; + config->rx_filter =HWTSTAMP_FILTER_ALL ;break ;default :return -ERANGE ; } - fp->hwtstamp_cfg = cfg; -return copy_to_user (ifr->ifr_data, &cfg,sizeof (cfg)) ? -EFAULT :0 ; -} - -static int fun_ioctl (struct net_device *dev,struct ifreq *ifr,int cmd) -{ -switch (cmd) { -case SIOCSHWTSTAMP : -return fun_hwtstamp_set (dev, ifr); -case SIOCGHWTSTAMP : -return fun_hwtstamp_get (dev, ifr); -default : -return -EOPNOTSUPP ; - } + fp->hwtstamp_cfg = *config; +return 0 ; }/* Prepare the queues for XDP. */
@@ -1340,7 +1327,6 @@ static const struct net_device_ops fun_netdev_ops = { .ndo_change_mtu = fun_change_mtu, .ndo_set_mac_address = fun_set_macaddr, .ndo_validate_addr = eth_validate_addr, - .ndo_eth_ioctl = fun_ioctl, .ndo_uninit = fun_uninit, .ndo_bpf = fun_xdp, .ndo_xdp_xmit = fun_xdp_xmit_frames,
@@ -1348,6 +1334,8 @@ static const struct net_device_ops fun_netdev_ops = { .ndo_set_vf_vlan = fun_set_vf_vlan, .ndo_set_vf_rate = fun_set_vf_rate, .ndo_get_vf_config = fun_get_vf_config, + .ndo_hwtstamp_get = fun_hwtstamp_get, + .ndo_hwtstamp_set = fun_hwtstamp_set, };#define GSO_ENCAP_FLAGS (NETIF_F_GSO_GRE | NETIF_F_GSO_IPXIP4 | \
Signature · 1 line
2.47.3
Simon Horman
reviewerRe: [PATCH net-next v2 6/7] tsnep: convert to ndo_hwtstatmp API
In reply to Vadim FedorenkoQuoted 6 lines · Vadim Fedorenko
Convert to .ndo_hwtstamp_get()/.ndo_hwtstamp_set() callbacks. After conversions the rest of
tsnep_netdev_ioctl()becomes purephy_do_ioctl_running(), so removetsnep_netdev_ioctl()and replace it withphy_do_ioctl_running()in .ndo_eth_ioctl.Signed-off-by Vadim Fedorenko <[email protected]>
...
Quoted 42 lines
drivers/net/ethernet/engleder/tsnep_ptp.c +2
-30@@ -19,57 +19,53 @@ void tsnep_get_system_time(struct tsnep_adapter *adapter, u64 *time) *time = (((u64 )high) <<32 ) | ((u64 )low); } -int tsnep_ptp_ioctl (struct net_device *netdev,struct ifreq *ifr,int cmd) +int tsnep_ptp_hwtstamp_get (struct net_device *netdev, +struct kernel_hwtstamp_config *config) {struct tsnep_adapter *adapter =netdev_priv (netdev); -struct hwtstamp_config config; - -if (!ifr) -return -EINVAL ; - -if (cmd ==SIOCSHWTSTAMP ) { -if (copy_from_user (&config, ifr->ifr_data,sizeof (config))) -return -EFAULT ; - -switch (config.tx_type) { -case HWTSTAMP_TX_OFF : -case HWTSTAMP_TX_ON : -break ; -default : -return -ERANGE ; - } - -switch (config.rx_filter) { -case HWTSTAMP_FILTER_NONE : -break ; -case HWTSTAMP_FILTER_ALL : -case HWTSTAMP_FILTER_PTP_V1_L4_EVENT : -case HWTSTAMP_FILTER_PTP_V1_L4_SYNC : -case HWTSTAMP_FILTER_PTP_V1_L4_DELAY_REQ : -case HWTSTAMP_FILTER_PTP_V2_L4_EVENT : -case HWTSTAMP_FILTER_PTP_V2_L4_SYNC : -case HWTSTAMP_FILTER_PTP_V2_L4_DELAY_REQ : -case HWTSTAMP_FILTER_PTP_V2_L2_EVENT : -case HWTSTAMP_FILTER_PTP_V2_L2_SYNC :
drivers/net/ethernet/engleder/tsnep_ptp.c void tsnep_get_system_time(struct tsnep_adapter *adapter, u64 *time) · line 63
Quoted 10 lines
drivers/net/ethernet/engleder/tsnep_ptp.c +0
-10-case HWTSTAMP_FILTER_PTP_V2_L2_DELAY_REQ : -case HWTSTAMP_FILTER_PTP_V2_EVENT : -case HWTSTAMP_FILTER_PTP_V2_SYNC : -case HWTSTAMP_FILTER_PTP_V2_DELAY_REQ : -case HWTSTAMP_FILTER_NTP_ALL : - config.rx_filter =HWTSTAMP_FILTER_ALL ; -break ; -default : -return -ERANGE ; - }
Hi Vadim,
I'm probably missing something obvious, but it's not clear to me why removing the inner switch statements above is ok. Or, perhaps more to the point, it seems inconsistent with other patches in this series.
OTOH, I do see why dropping the outer if conditions makes sense.
Quoted 7 lines
drivers/net/ethernet/engleder/tsnep_ptp.c +4
-3- -memcpy (&adapter->hwtstamp_config, &config, -sizeof (adapter->hwtstamp_config)); + + *config = adapter->hwtstamp_config; +return 0 ; +}
...
Simon Horman
reviewerRe: [PATCH net-next v2 5/7] cxgb4: convert to ndo_hwtstamp API
In reply to Vadim FedorenkoQuoted 5 lines · Vadim Fedorenko
Convert to use .ndo_hwtstamp_get()/.ndo_hwtstamp_set() callbacks.
Though I'm not quite sure it worked properly before the conversion.
Signed-off-by Vadim Fedorenko <[email protected]>
Hi Vadim,
There is quite a lot of change here. Probably it's not worth "fixing" the current code before migrating it. But I think it would be worth expanding a bit on the statement about not being sure it worked?
...
Re: [PATCH net-next v2 5/7] cxgb4: convert to ndo_hwtstamp API
Quoted 5 lines · Simon Horman
Quoted 4 lines · Vadim Fedorenko
Convert to use .ndo_hwtstamp_get()/.ndo_hwtstamp_set() callbacks.
Though I'm not quite sure it worked properly before the conversion.
Quoted 7 lines
Quoted 1 line
Signed-off-by Vadim Fedorenko <[email protected]>Hi Vadim,
There is quite a lot of change here. Probably it's not worth "fixing" the current code before migrating it. But I think it would be worth expanding a bit on the statement about not being sure it worked?
Hi Simon!
Well, let me try to explain the statement about not being sure it worked. The original code was copying new configuration into netdev's private structure before validating that the values are acceptable by the hardware. In case of error, the driver was not restoring original values, and after the call:
ioctl(SIOCSHWTSTAMP, <unsupported_config>) = -ERANGE
the driver would have configuration which could not be reapplied and not synced to the actual hardware config:
ioctl(SIOCGHWTSTAMP) = <unsupported_config>
The logic change in the patch is to just keep original configuration in case of -ERANGE error. Otherwise the logic is not changed.
Re: [PATCH net-next v2 6/7] tsnep: convert to ndo_hwtstatmp API
In reply to Simon HormanQuoted 65 lines · Simon Horman
Quoted 6 lines · Vadim Fedorenko
Convert to .ndo_hwtstamp_get()/.ndo_hwtstamp_set() callbacks. After conversions the rest of
tsnep_netdev_ioctl()becomes purephy_do_ioctl_running(), so removetsnep_netdev_ioctl()and replace it withphy_do_ioctl_running()in .ndo_eth_ioctl.Signed-off-by Vadim Fedorenko <[email protected]>...
Quoted 42 lines
drivers/net/ethernet/engleder/tsnep_ptp.c +2
-30@@ -19,57 +19,53 @@ void tsnep_get_system_time(struct tsnep_adapter *adapter, u64 *time) *time = (((u64 )high) <<32 ) | ((u64 )low); } -int tsnep_ptp_ioctl (struct net_device *netdev,struct ifreq *ifr,int cmd) +int tsnep_ptp_hwtstamp_get (struct net_device *netdev, +struct kernel_hwtstamp_config *config) {struct tsnep_adapter *adapter =netdev_priv (netdev); -struct hwtstamp_config config; - -if (!ifr) -return -EINVAL ; - -if (cmd ==SIOCSHWTSTAMP ) { -if (copy_from_user (&config, ifr->ifr_data,sizeof (config))) -return -EFAULT ; - -switch (config.tx_type) { -case HWTSTAMP_TX_OFF : -case HWTSTAMP_TX_ON : -break ; -default : -return -ERANGE ; - } - -switch (config.rx_filter) { -case HWTSTAMP_FILTER_NONE : -break ; -case HWTSTAMP_FILTER_ALL : -case HWTSTAMP_FILTER_PTP_V1_L4_EVENT : -case HWTSTAMP_FILTER_PTP_V1_L4_SYNC : -case HWTSTAMP_FILTER_PTP_V1_L4_DELAY_REQ : -case HWTSTAMP_FILTER_PTP_V2_L4_EVENT : -case HWTSTAMP_FILTER_PTP_V2_L4_SYNC : -case HWTSTAMP_FILTER_PTP_V2_L4_DELAY_REQ : -case HWTSTAMP_FILTER_PTP_V2_L2_EVENT : -case HWTSTAMP_FILTER_PTP_V2_L2_SYNC :drivers/net/ethernet/engleder/tsnep_ptp.c void tsnep_get_system_time(struct tsnep_adapter *adapter, u64 *time) · line 63
Quoted 10 lines
drivers/net/ethernet/engleder/tsnep_ptp.c +0
-10-case HWTSTAMP_FILTER_PTP_V2_L2_DELAY_REQ : -case HWTSTAMP_FILTER_PTP_V2_EVENT : -case HWTSTAMP_FILTER_PTP_V2_SYNC : -case HWTSTAMP_FILTER_PTP_V2_DELAY_REQ : -case HWTSTAMP_FILTER_NTP_ALL : - config.rx_filter =HWTSTAMP_FILTER_ALL ; -break ; -default : -return -ERANGE ; - }Hi Vadim,
Quoted 5 lines
I'm probably missing something obvious, but it's not clear to me why removing the inner switch statements above is ok. Or, perhaps more to the point, it seems inconsistent with other patches in this series.
OTOH, I do see why dropping the outer if conditions makes sense.
I believe it's just a question for git diff. It replaces originaltsnep_ptp_ioctl() function with get() callback. The only thing that new function does is copying actual config into reply.
The switch statement goes to set() callback where the logic is kept as is. Original tsnep_ptp_ioctl() was serving both get and set operations, but the logic was applied to set operation only.
Quoted 10 lines
Quoted 8 lines
drivers/net/ethernet/engleder/tsnep_ptp.c +4
-3- -memcpy (&adapter->hwtstamp_config, &config, -sizeof (adapter->hwtstamp_config)); + + *config = adapter->hwtstamp_config; +return 0 ; +}...
Simon Horman
reviewerRe: [PATCH net-next v2 5/7] cxgb4: convert to ndo_hwtstamp API
In reply to Vadim FedorenkoQuoted 24 lines · Vadim Fedorenko
Quoted 5 lines · Simon Horman
Quoted 4 lines · Vadim Fedorenko
Convert to use .ndo_hwtstamp_get()/.ndo_hwtstamp_set() callbacks.
Though I'm not quite sure it worked properly before the conversion.
Quoted 7 lines
Quoted 1 line
Signed-off-by Vadim Fedorenko <[email protected]>Hi Vadim,
There is quite a lot of change here. Probably it's not worth "fixing" the current code before migrating it. But I think it would be worth expanding a bit on the statement about not being sure it worked?
Hi Simon!
Well, let me try to explain the statement about not being sure it worked. The original code was copying new configuration into netdev's private structure before validating that the values are acceptable by the hardware. In case of error, the driver was not restoring original values, and after the call:
ioctl(SIOCSHWTSTAMP, <unsupported_config>)=-ERANGE
Quoted 7 lines
the driver would have configuration which could not be reapplied and not synced to the actual hardware config:
ioctl(SIOCGHWTSTAMP) = <
unsupported_config>The logic change in the patch is to just keep original configuration in case of
-ERANGEerror. Otherwise the logic is not changed.
Thanks Vadim,
I see that now and it makes sense to me.
I do think it would be worth mentioning in the patch description.
Re: [PATCH net-next v2 6/7] tsnep: convert to ndo_hwtstatmp API
In reply to Vadim FedorenkoQuoted 2 lines · Vadim Fedorenko
Quoted 1 line · Simon Horman
On Tue, Oct 14, 2025 at 10:42:15PM +0000, Vadim Fedorenko wrote:
...
Quoted 8 lines
Quoted 7 lines
Hi Vadim,
I'm probably missing something obvious, but it's not clear to me why removing the inner switch statements above is ok. Or, perhaps more to the point, it seems inconsistent with other patches in this series.
OTOH, I do see why dropping the outer if conditions makes sense.
Quoted 7 lines
I believe it's just a question for git diff. It replaces original
tsnep_ptp_ioctl()function withget()callback. The only thing that new function does is copying actual config into reply.The switch statement goes to
set()callback where the logic is kept as is. Originaltsnep_ptp_ioctl()was serving both get and set operations, but the logic was applied to set operation only.
Thanks, silly me. I see that now.
Re: [PATCH net-next v2 1/7] net: ti: am65-cpsw: move hw timestamping to ndo callback
In reply to Vadim FedorenkoQuoted 3 lines · Vadim Fedorenko
Migrate driver to new API for HW timestamping.
Signed-off-by Vadim Fedorenko <[email protected]>
Re: [PATCH net-next v2 2/7] ti: icssg: convert to ndo_hwtstamp API
In reply to Vadim FedorenkoQuoted 5 lines · Vadim Fedorenko
Convert driver to use .ndo_hwtstamp_get()/.ndo_hwtstamp_set() API. .ndo_eth_ioctl() implementation becomes pure
phy_do_ioctl(), remove it from common module, remove exported symbol and replace ndo callback.Signed-off-by Vadim Fedorenko <[email protected]>
Re: [PATCH net-next v2 3/7] amd-xgbe: convert to ndo_hwtstamp callbacks
In reply to Vadim FedorenkoQuoted 4 lines · Vadim Fedorenko
Convert driver to use .ndo_hwtstamp_get()/.ndo_hwtstamp_set() callbacks. .ndo_eth_ioctl() becomes empty function, remove it.
Signed-off-by Vadim Fedorenko <[email protected]>
Re: [PATCH net-next v2 4/7] net: atlantic: convert to ndo_hwtstamp API
In reply to Vadim FedorenkoQuoted 5 lines · Vadim Fedorenko
Convert driver to .ndo_hwtstamp_get()/.ndo_hwtstamp_set() callbacks. .ndo_eth_ioctl() becomes empty so remove it. Also simplify code with no functional changes.
Signed-off-by Vadim Fedorenko <[email protected]>
Re: [PATCH net-next v2 7/7] funeth: convert to ndo_hwtstamp API
In reply to Vadim FedorenkoQuoted 4 lines · Vadim Fedorenko
Convert driver to use .ndo_hwtstamp_get()/.ndo_hwtstamp_set() callbacks. .ndo_eth_ioctl() implementation becomes empty, remove it.
Signed-off-by Vadim Fedorenko <[email protected]>
Re: [PATCH net-next v2 1/7] net: ti: am65-cpsw: move hw timestamping to ndo callback
In reply to Vadim FedorenkoQuoted 30 lines · Vadim Fedorenko
Migrate driver to new API for HW timestamping.
Signed-off-by Vadim Fedorenko <[email protected]>--- drivers/net/ethernet/ti/am65-cpsw-nuss.c | 44 +++++++++++------------- 1 file changed, 20 insertions(+), 24 deletions(-)drivers/net/ethernet/ti/am65-cpsw-nuss.c +4
-6@@ -1788,28 +1788,28 @@ static int am65_cpsw_nuss_ndo_slave_set_mac_address(struct net_device *ndev, }static int am65_cpsw_nuss_hwtstamp_set (struct net_device *ndev, -struct ifreq *ifr) +struct kernel_hwtstamp_config *cfg, +struct netlink_ext_ack *extack) {struct am65_cpsw_port *port =am65_ndev_to_port (ndev);u32 ts_ctrl, seq_id, ts_ctrl_ltype2, ts_vlan_ltype; -struct hwtstamp_config cfg; -if (!IS_ENABLED (CONFIG_TI_K3_AM65_CPTS )) +if (!IS_ENABLED (CONFIG_TI_K3_AM65_CPTS )) { +NL_SET_ERR_MSG (extack,"Time stamping is not supported" );return -EOPNOTSUPP ; - -if (copy_from_user (&cfg, ifr->ifr_data,sizeof (cfg))) -return -EFAULT ;
drivers/net/ethernet/ti/am65-cpsw-nuss.c static int am65_cpsw_nuss_ndo_slave_set_mac_address(struct net_device *ndev, · line 1808
Quoted 10 lines
drivers/net/ethernet/ti/am65-cpsw-nuss.c +3
-1+ }/* TX HW timestamp */ -switch (cfg.tx_type) { +switch (cfg->tx_type) {case HWTSTAMP_TX_OFF :case HWTSTAMP_TX_ON :break ;default : +NL_SET_ERR_MSG (extack,"TX mode is not supported" );
We could use NL_ST_ERR_MSG_MOD_FMT and format the particular invalid type here, but not certain how helpful that would be in practice. Perhaps the unsupported filter type is obvious from context of sending the invalid netlink command?
Either way, the conversion looks quite straight forward.
Re: [PATCH net-next v2 2/7] ti: icssg: convert to ndo_hwtstamp API
In reply to Vadim FedorenkoQuoted 6 lines · Vadim Fedorenko
Convert driver to use .ndo_hwtstamp_get()/.ndo_hwtstamp_set() API. .ndo_eth_ioctl() implementation becomes pure
phy_do_ioctl(), remove it from common module, remove exported symbol and replace ndo callback.Signed-off-by Vadim Fedorenko <[email protected]>---
Re: [PATCH net-next v2 3/7] amd-xgbe: convert to ndo_hwtstamp callbacks
In reply to Vadim FedorenkoQuoted 27 lines · Vadim Fedorenko
drivers/net/ethernet/amd/xgbe/xgbe-hwtstamp.c +8
-5@@ -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) {
drivers/net/ethernet/amd/xgbe/xgbe-hwtstamp.c void xgbe_tx_tstamp(struct work_struct *work) · line 176
Quoted 10 lines
drivers/net/ethernet/amd/xgbe/xgbe-hwtstamp.c +2
-7-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?
Re: [PATCH net-next v2 4/7] net: atlantic: convert to ndo_hwtstamp API
In reply to Vadim FedorenkoQuoted 6 lines · Vadim Fedorenko
Convert driver to .ndo_hwtstamp_get()/.ndo_hwtstamp_set() callbacks. .ndo_eth_ioctl() becomes empty so remove it. Also simplify code with no functional changes.
Signed-off-by Vadim Fedorenko <[email protected]>---
Re: [PATCH net-next v2 3/7] amd-xgbe: convert to ndo_hwtstamp callbacks
In reply to Jacob KellerQuoted 35 lines · Jacob Keller
Quoted 32 lines · Vadim Fedorenko
drivers/net/ethernet/amd/xgbe/xgbe-hwtstamp.c +8
-10@@ -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 ;
Quoted 8 lines
drivers/net/ethernet/amd/xgbe/xgbe-hwtstamp.c void xgbe_tx_tstamp(struct work_struct *work) · line 176
Quoted 5 lines
drivers/net/ethernet/amd/xgbe/xgbe-hwtstamp.c +2
-2- - 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_MSGcalls. 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.
We might think of adding netlink error message for ERANGE error in dev_set_hwtstamp() in case the driver skips setting specific message.
Re: [PATCH net-next v2 5/7] cxgb4: convert to ndo_hwtstamp API
In reply to Simon HormanQuoted 30 lines · Simon Horman
Quoted 29 lines · Vadim Fedorenko
Quoted 5 lines · Simon Horman
Quoted 4 lines · Vadim Fedorenko
Convert to use .ndo_hwtstamp_get()/.ndo_hwtstamp_set() callbacks.
Though I'm not quite sure it worked properly before the conversion.
Quoted 7 lines
Quoted 1 line
Signed-off-by Vadim Fedorenko <[email protected]>Hi Vadim,
There is quite a lot of change here. Probably it's not worth "fixing" the current code before migrating it. But I think it would be worth expanding a bit on the statement about not being sure it worked?
Hi Simon!
Well, let me try to explain the statement about not being sure it worked. The original code was copying new configuration into netdev's private structure before validating that the values are acceptable by the hardware. In case of error, the driver was not restoring original values, and after the call:
ioctl(SIOCSHWTSTAMP, <unsupported_config>)=-ERANGEthe driver would have configuration which could not be reapplied and not synced to the actual hardware config:
ioctl(SIOCGHWTSTAMP) = <
unsupported_config>
Quoted 7 lines
Quoted 2 lines
The logic change in the patch is to just keep original configuration in case of
-ERANGEerror. Otherwise the logic is not changed.Thanks Vadim,
I see that now and it makes sense to me.
I do think it would be worth mentioning in the patch description.
Fair point, I'll update commit message for v3.
Re: [PATCH net-next v2 5/7] cxgb4: convert to ndo_hwtstamp API
In reply to Vadim FedorenkoQuoted 24 lines · Vadim Fedorenko
Quoted 5 lines · Simon Horman
Quoted 4 lines · Vadim Fedorenko
Convert to use .ndo_hwtstamp_get()/.ndo_hwtstamp_set() callbacks.
Though I'm not quite sure it worked properly before the conversion.
Quoted 7 lines
Quoted 1 line
Signed-off-by Vadim Fedorenko <[email protected]>Hi Vadim,
There is quite a lot of change here. Probably it's not worth "fixing" the current code before migrating it. But I think it would be worth expanding a bit on the statement about not being sure it worked?
Hi Simon!
Well, let me try to explain the statement about not being sure it worked. The original code was copying new configuration into netdev's private structure before validating that the values are acceptable by the hardware. In case of error, the driver was not restoring original values, and after the call:
ioctl(SIOCSHWTSTAMP, <unsupported_config>)=-ERANGE
Quoted 9 lines
the driver would have configuration which could not be reapplied and not synced to the actual hardware config:
ioctl(SIOCGHWTSTAMP) = <
unsupported_config>The logic change in the patch is to just keep original configuration in case of
-ERANGEerror. Otherwise the logic is not changed.
Makes sense. It isn't entirely clear if that could cause an actual problem since the flags the driver uses appear to be set after validation (ptp_enable and the call to cxgb4_ptprx_timstamping) .. But having stale data there seems like it could lead to trouble and is worth cleaning up.
Re: [PATCH net-next v2 7/7] funeth: convert to ndo_hwtstamp API
In reply to Vadim FedorenkoQuoted 5 lines · Vadim Fedorenko
Convert driver to use .ndo_hwtstamp_get()/.ndo_hwtstamp_set() callbacks. .ndo_eth_ioctl() implementation becomes empty, remove it.
Signed-off-by Vadim Fedorenko <[email protected]>---
Jacob Keller
Reviewed-byRe: [PATCH net-next v2 3/7] amd-xgbe: convert to ndo_hwtstamp callbacks
In reply to Vadim FedorenkoQuoted 45 lines · Vadim Fedorenko
Quoted 35 lines · Jacob Keller
Quoted 32 lines · Vadim Fedorenko
drivers/net/ethernet/amd/xgbe/xgbe-hwtstamp.c +8
-10@@ -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 ;Quoted 8 lines
drivers/net/ethernet/amd/xgbe/xgbe-hwtstamp.c void xgbe_tx_tstamp(struct work_struct *work) · line 176
Quoted 5 lines
drivers/net/ethernet/amd/xgbe/xgbe-hwtstamp.c +2
-2- - 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_MSGcalls. Any particular reason?
Quoted 3 lines
The only error here is the
-ERANGEwhich is self-explanatory, so I decided to keep the amount of changed lines as low as possible.
Makes sense.
Quoted 2 lines
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:
Simon Horman
reviewerRe: [PATCH net-next v2 5/7] cxgb4: convert to ndo_hwtstamp API
In reply to Vadim FedorenkoQuoted 34 lines · Vadim Fedorenko
Quoted 33 lines · Simon Horman
Quoted 31 lines · Vadim Fedorenko
Quoted 5 lines · Simon Horman
Quoted 4 lines · Vadim Fedorenko
Convert to use .ndo_hwtstamp_get()/.ndo_hwtstamp_set() callbacks.
Though I'm not quite sure it worked properly before the conversion.
Quoted 7 lines
Quoted 1 line
Signed-off-by Vadim Fedorenko <[email protected]>Hi Vadim,
There is quite a lot of change here. Probably it's not worth "fixing" the current code before migrating it. But I think it would be worth expanding a bit on the statement about not being sure it worked?
Hi Simon!
Well, let me try to explain the statement about not being sure it worked. The original code was copying new configuration into netdev's private structure before validating that the values are acceptable by the hardware. In case of error, the driver was not restoring original values, and after the call:
ioctl(SIOCSHWTSTAMP, <unsupported_config>)=-ERANGEthe driver would have configuration which could not be reapplied and not synced to the actual hardware config:
ioctl(SIOCGHWTSTAMP) = <
unsupported_config>The logic change in the patch is to just keep original configuration in case of
-ERANGEerror. Otherwise the logic is not changed.
Quoted 6 lines
Quoted 4 lines
Thanks Vadim,
I see that now and it makes sense to me.
I do think it would be worth mentioning in the patch description.Fair point, I'll update commit message for v3.
Thanks, much appreciated.