convert net drivers to ndo_hwtstamp API
Subsystems (7)
cover convert net drivers to ndo_hwtstamp API
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. 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.
Vadim Fedorenko (14):
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
octeontx2: convert to ndo_hwtstamp API
mlx4: convert to ndo_hwtstamp API
ionic: convert to ndo_hwtstamp API
net: ravb: convert to ndo_hwtstamp API
net: renesas: rswitch: convert to ndo_hwtstamp API
net: hns3: add hwtstamp_get/hwtstamp_set ops
net: hns3: move hns3pf to use hwtstamp callbacks
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/hisilicon/hns3/hnae3.h | 5 + .../net/ethernet/hisilicon/hns3/hns3_enet.c | 29 ++++ .../hisilicon/hns3/hns3pf/hclge_main.c | 13 +- .../hisilicon/hns3/hns3pf/hclge_ptp.c | 32 ++-- .../hisilicon/hns3/hns3pf/hclge_ptp.h | 9 +- .../marvell/octeontx2/nic/otx2_common.h | 9 +- .../ethernet/marvell/octeontx2/nic/otx2_pf.c | 56 +++---- .../ethernet/marvell/octeontx2/nic/otx2_vf.c | 3 +- .../net/ethernet/mellanox/mlx4/en_netdev.c | 61 +++---- drivers/net/ethernet/mellanox/mlx4/mlx4_en.h | 6 +- .../net/ethernet/pensando/ionic/ionic_lif.c | 17 +- .../net/ethernet/pensando/ionic/ionic_lif.h | 11 +- .../net/ethernet/pensando/ionic/ionic_phc.c | 59 ++++--- drivers/net/ethernet/renesas/ravb_main.c | 61 +++---- drivers/net/ethernet/renesas/rswitch_main.c | 53 +++--- 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 +- 33 files changed, 441 insertions(+), 541 deletions(-)
Signature · 1 line
2.47.3
PATCH 1/14 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 2/14 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 3/14 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 4/14 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 5/14 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