net: add new hwtstamp flag HWTSTAMP_FLAG_BONDED_PHC_INDEX
Subsystems (33)
v3 cover net: add new hwtstamp flag HWTSTAMP_FLAG_BONDED_PHC_INDEX
This patchset add a new hwtstamp_config flag HWTSTAMP_FLAG_BONDED_PHC_INDEX. When user want to get bond active interface's PHC, they need to add this flag and aware the PHC index may changed.
v3: Use bitwise test to check the flags validation
v2: rename the flag to HWTSTAMP_FLAG_BONDED_PHC_INDEX
Hangbin Liu (2):
net_tstamp: add new flag HWTSTAMP_FLAG_BONDED_PHC_INDEX
Bonding: force user to add HWTSTAMP_FLAG_BONDED_PHC_INDEX when get/set
HWTSTAMP
drivers/net/bonding/bond_main.c | 33 ++++++++++++------- .../net/dsa/hirschmann/hellcreek_hwtstamp.c | 4 --- drivers/net/dsa/mv88e6xxx/hwtstamp.c | 4 --- drivers/net/ethernet/amd/xgbe/xgbe-drv.c | 3 -- .../net/ethernet/aquantia/atlantic/aq_main.c | 3 -- .../net/ethernet/broadcom/bnx2x/bnx2x_main.c | 5 --- drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.c | 3 -- drivers/net/ethernet/broadcom/tg3.c | 3 -- drivers/net/ethernet/cadence/macb_ptp.c | 4 --- .../net/ethernet/cavium/liquidio/lio_main.c | 3 -- .../ethernet/cavium/liquidio/lio_vf_main.c | 3 -- .../net/ethernet/cavium/octeon/octeon_mgmt.c | 3 -- .../net/ethernet/cavium/thunder/nicvf_main.c | 4 --- drivers/net/ethernet/engleder/tsnep_ptp.c | 3 -- drivers/net/ethernet/freescale/fec_ptp.c | 4 --- drivers/net/ethernet/freescale/gianfar.c | 4 --- drivers/net/ethernet/intel/e1000e/netdev.c | 4 --- drivers/net/ethernet/intel/i40e/i40e_ptp.c | 4 --- drivers/net/ethernet/intel/ice/ice_ptp.c | 4 --- drivers/net/ethernet/intel/igb/igb_ptp.c | 4 --- drivers/net/ethernet/intel/igc/igc_ptp.c | 4 --- drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c | 4 --- .../net/ethernet/marvell/mvpp2/mvpp2_main.c | 3 -- .../ethernet/marvell/octeontx2/nic/otx2_pf.c | 4 --- .../net/ethernet/mellanox/mlx4/en_netdev.c | 4 --- drivers/net/ethernet/microchip/lan743x_ptp.c | 6 ---- drivers/net/ethernet/mscc/ocelot.c | 4 --- .../net/ethernet/neterion/vxge/vxge-main.c | 4 --- .../ethernet/oki-semi/pch_gbe/pch_gbe_main.c | 3 -- drivers/net/ethernet/qlogic/qede/qede_ptp.c | 5 --- drivers/net/ethernet/renesas/ravb_main.c | 4 --- drivers/net/ethernet/sfc/ptp.c | 3 -- .../net/ethernet/stmicro/stmmac/stmmac_main.c | 4 --- drivers/net/ethernet/ti/cpsw_priv.c | 4 --- drivers/net/ethernet/ti/netcp_ethss.c | 4 --- drivers/net/ethernet/xscale/ixp4xx_eth.c | 3 -- drivers/net/phy/dp83640.c | 3 -- drivers/net/phy/mscc/mscc_ptp.c | 3 -- drivers/ptp/ptp_ines.c | 4 --- include/uapi/linux/net_tstamp.h | 16 ++++++++- net/core/dev_ioctl.c | 2 +- 41 files changed, 37 insertions(+), 156 deletions(-)
Signature · 1 line
2.31.1
PATCH v3 1/2 net_tstamp: add new flag HWTSTAMP_FLAG_BONDED_PHC_INDEX
Since commit 94dd016ae538 ("bond: pass get_ts_info and SIOC[SG]HWTSTAMP ioctl to active device") the user could get bond active interface's PHC index directly. But when there is a failover, the bond active interface will change, thus the PHC index is also changed. This may break the user's program if they did not update the PHC timely.
This patch adds a new hwtstamp_config flag HWTSTAMP_FLAG_BONDED_PHC_INDEX. When the user wants to get the bond active interface's PHC, they need to add this flag and be aware the PHC index may be changed.
With the new flag. All flag checks in current drivers are removed. Only the checking in net_hwtstamp_validate() is kept.
---
v3: Use bitwise test to check the flags validation
v2: Keep the flag validation check in net_hwtstamp_validate()
Rename the flag to HWTSTAMP_FLAG_BONDED_PHC_INDEX
--- drivers/net/dsa/hirschmann/hellcreek_hwtstamp.c | 4 ---- drivers/net/dsa/mv88e6xxx/hwtstamp.c | 4 ---- drivers/net/ethernet/amd/xgbe/xgbe-drv.c | 3 --- drivers/net/ethernet/aquantia/atlantic/aq_main.c | 3 --- drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c | 5 ----- drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.c | 3 --- drivers/net/ethernet/broadcom/tg3.c | 3 --- drivers/net/ethernet/cadence/macb_ptp.c | 4 ---- drivers/net/ethernet/cavium/liquidio/lio_main.c | 3 --- .../net/ethernet/cavium/liquidio/lio_vf_main.c | 3 --- drivers/net/ethernet/cavium/octeon/octeon_mgmt.c | 3 --- drivers/net/ethernet/cavium/thunder/nicvf_main.c | 4 ---- drivers/net/ethernet/engleder/tsnep_ptp.c | 3 --- drivers/net/ethernet/freescale/fec_ptp.c | 4 ---- drivers/net/ethernet/freescale/gianfar.c | 4 ---- drivers/net/ethernet/intel/e1000e/netdev.c | 4 ---- drivers/net/ethernet/intel/i40e/i40e_ptp.c | 4 ---- drivers/net/ethernet/intel/ice/ice_ptp.c | 4 ---- drivers/net/ethernet/intel/igb/igb_ptp.c | 4 ---- drivers/net/ethernet/intel/igc/igc_ptp.c | 4 ---- drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c | 4 ---- drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c | 3 --- .../net/ethernet/marvell/octeontx2/nic/otx2_pf.c | 4 ---- drivers/net/ethernet/mellanox/mlx4/en_netdev.c | 4 ---- drivers/net/ethernet/microchip/lan743x_ptp.c | 6 ------ drivers/net/ethernet/mscc/ocelot.c | 4 ---- drivers/net/ethernet/neterion/vxge/vxge-main.c | 4 ---- .../net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c | 3 --- drivers/net/ethernet/qlogic/qede/qede_ptp.c | 5 ----- drivers/net/ethernet/renesas/ravb_main.c | 4 ---- drivers/net/ethernet/sfc/ptp.c | 3 --- .../net/ethernet/stmicro/stmmac/stmmac_main.c | 4 ---- drivers/net/ethernet/ti/cpsw_priv.c | 4 ---- drivers/net/ethernet/ti/netcp_ethss.c | 4 ---- drivers/net/ethernet/xscale/ixp4xx_eth.c | 3 --- drivers/net/phy/dp83640.c | 3 --- drivers/net/phy/mscc/mscc_ptp.c | 3 --- drivers/ptp/ptp_ines.c | 4 ---- include/uapi/linux/net_tstamp.h | 16 +++++++++++++++- net/core/dev_ioctl.c | 2 +- 40 files changed, 16 insertions(+), 144 deletions(-)
drivers/net/dsa/hirschmann/hellcreek_hwtstamp.c +0 -4
@@ -52,10 +52,6 @@ static int hellcreek_set_hwtstamp_config(struct hellcreek *hellcreek, int port,*/ clear_bit_unlock (HELLCREEK_HWTSTAMP_ENABLED , &ps->state); -/* Reserved for future extensions */ -if (config->flags) -return -EINVAL ; -switch (config->tx_type) {case HWTSTAMP_TX_ON : tx_tstamp_enable = true;
drivers/net/dsa/mv88e6xxx/hwtstamp.c +0 -4
@@ -100,10 +100,6 @@ static int mv88e6xxx_set_hwtstamp_config(struct mv88e6xxx_chip *chip, int port,*/ clear_bit_unlock (MV88E6XXX_HWTSTAMP_ENABLED , &ps->state); -/* reserved for future extensions */ -if (config->flags) -return -EINVAL ; -switch (config->tx_type) {case HWTSTAMP_TX_OFF : tstamp_enable = false;
drivers/net/ethernet/amd/xgbe/xgbe-drv.c +0 -3
@@ -1508,9 +1508,6 @@ static int xgbe_set_hwtstamp_settings(struct xgbe_prv_data *pdata,if (copy_from_user (&config, ifreq->ifr_data,sizeof (config)))return -EFAULT ; -if (config.flags) -return -EINVAL ; - mac_tscr =0 ;switch (config.tx_type) {
drivers/net/ethernet/aquantia/atlantic/aq_main.c +0 -3
@@ -231,9 +231,6 @@ static void aq_ndev_set_multicast_settings(struct net_device *ndev)static int aq_ndev_config_hwtstamp (struct aq_nic_s *aq_nic,struct hwtstamp_config *config) { -if (config->flags) -return -EINVAL ; -switch (config->tx_type) {case HWTSTAMP_TX_OFF :case HWTSTAMP_TX_ON :
drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c +0 -5
@@ -15356,11 +15356,6 @@ static int bnx2x_hwtstamp_ioctl(struct bnx2x *bp, struct ifreq *ifr)DP (BNX2X_MSG_PTP ,"Requested tx_type: %d, requested rx_filters = %d\n" , config.tx_type, config.rx_filter); -if (config.flags) { -BNX2X_ERR ("config.flags is reserved for future use\n" ); -return -EINVAL ; - } - bp->hwtstamp_ioctl_called = true; bp->tx_type = config.tx_type; bp->rx_filter = config.rx_filter;
drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.c +0 -3
@@ -417,9 +417,6 @@ int bnxt_hwtstamp_set(struct net_device *dev, struct ifreq *ifr)if (copy_from_user (&stmpconf, ifr->ifr_data,sizeof (stmpconf)))return -EFAULT ; -if (stmpconf.flags) -return -EINVAL ; -if (stmpconf.tx_type !=HWTSTAMP_TX_ON && stmpconf.tx_type !=HWTSTAMP_TX_OFF )return -ERANGE ;
drivers/net/ethernet/broadcom/tg3.c +0 -3
@@ -13806,9 +13806,6 @@ static int tg3_hwtstamp_set(struct net_device *dev, struct ifreq *ifr)if (copy_from_user (&stmpconf, ifr->ifr_data,sizeof (stmpconf)))return -EFAULT ; -if (stmpconf.flags) -return -EINVAL ; -if (stmpconf.tx_type !=HWTSTAMP_TX_ON && stmpconf.tx_type !=HWTSTAMP_TX_OFF )return -ERANGE ;
drivers/net/ethernet/cadence/macb_ptp.c +0 -4
@@ -464,10 +464,6 @@ int gem_set_hwtst(struct net_device *dev, struct ifreq *ifr, int cmd) sizeof(*tstamp_config)))return -EFAULT ; -/* reserved for future extensions */ -if (tstamp_config->flags) -return -EINVAL ; -switch (tstamp_config->tx_type) {case HWTSTAMP_TX_OFF :break ;
drivers/net/ethernet/cavium/liquidio/lio_main.c +0 -3
@@ -2114,9 +2114,6 @@ static int hwtstamp_ioctl(struct net_device *netdev, struct ifreq *ifr)if (copy_from_user (&conf, ifr->ifr_data,sizeof (conf)))return -EFAULT ; -if (conf.flags) -return -EINVAL ; -switch (conf.tx_type) {case HWTSTAMP_TX_ON :case HWTSTAMP_TX_OFF :
drivers/net/ethernet/cavium/liquidio/lio_vf_main.c +0 -3
@@ -1254,9 +1254,6 @@ static int hwtstamp_ioctl(struct net_device *netdev, struct ifreq *ifr)if (copy_from_user (&conf, ifr->ifr_data,sizeof (conf)))return -EFAULT ; -if (conf.flags) -return -EINVAL ; -switch (conf.tx_type) {case HWTSTAMP_TX_ON :case HWTSTAMP_TX_OFF :
drivers/net/ethernet/cavium/octeon/octeon_mgmt.c +0 -3
@@ -702,9 +702,6 @@ static int octeon_mgmt_ioctl_hwtstamp(struct net_device *netdev,if (copy_from_user (&config, rq->ifr_data,sizeof (config)))return -EFAULT ; -if (config.flags)/* reserved for future extensions */ -return -EINVAL ; -/* Check the status of hardware for tiemstamps */ if (OCTEON_IS_MODEL (OCTEON_CN6XXX )) {/* Get the current state of the PTP clock */
drivers/net/ethernet/cavium/thunder/nicvf_main.c +0 -4
@@ -1917,10 +1917,6 @@ static int nicvf_config_hwtstamp(struct net_device *netdev, struct ifreq *ifr)if (copy_from_user (&config, ifr->ifr_data,sizeof (config)))return -EFAULT ; -/* reserved for future extensions */ -if (config.flags) -return -EINVAL ; -switch (config.tx_type) {case HWTSTAMP_TX_OFF :case HWTSTAMP_TX_ON :
drivers/net/ethernet/engleder/tsnep_ptp.c +0 -3
@@ -31,9 +31,6 @@ int tsnep_ptp_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd)if (copy_from_user (&config, ifr->ifr_data,sizeof (config)))return -EFAULT ; -if (config.flags) -return -EINVAL ; -switch (config.tx_type) {case HWTSTAMP_TX_OFF :case HWTSTAMP_TX_ON :
drivers/net/ethernet/freescale/fec_ptp.c +0 -4
@@ -473,10 +473,6 @@ int fec_ptp_set(struct net_device *ndev, struct ifreq *ifr)if (copy_from_user (&config, ifr->ifr_data,sizeof (config)))return -EFAULT ; -/* reserved for future extensions */ -if (config.flags) -return -EINVAL ; -switch (config.tx_type) {case HWTSTAMP_TX_OFF : fep->hwts_tx_en =0 ;
drivers/net/ethernet/freescale/gianfar.c +0 -4
@@ -2076,10 +2076,6 @@ static int gfar_hwtstamp_set(struct net_device *netdev, struct ifreq *ifr)if (copy_from_user (&config, ifr->ifr_data,sizeof (config)))return -EFAULT ; -/* reserved for future extensions */ -if (config.flags) -return -EINVAL ; -switch (config.tx_type) {case HWTSTAMP_TX_OFF : priv->hwts_tx_en =0 ;
drivers/net/ethernet/intel/e1000e/netdev.c +0 -4
@@ -3614,10 +3614,6 @@ static int e1000e_config_hwtstamp(struct e1000_adapter *adapter,if (!(adapter->flags &FLAG_HAS_HW_TIMESTAMP ))return -EINVAL ; -/* flags reserved for future extensions - must be zero */ -if (config->flags) -return -EINVAL ; -switch (config->tx_type) {case HWTSTAMP_TX_OFF : tsync_tx_ctl =0 ;
drivers/net/ethernet/intel/i40e/i40e_ptp.c +0 -4
@@ -1205,10 +1205,6 @@ static int i40e_ptp_set_timestamp_mode(struct i40e_pf *pf,INIT_WORK (&pf->ptp_extts0_work, i40e_ptp_extts0_work); -/* Reserved for future extensions. */ -if (config->flags) -return -EINVAL ; -switch (config->tx_type) {case HWTSTAMP_TX_OFF : pf->ptp_tx = false;
drivers/net/ethernet/intel/ice/ice_ptp.c +0 -4
@@ -1205,10 +1205,6 @@ int ice_ptp_get_ts_config(struct ice_pf *pf, struct ifreq *ifr)static int ice_ptp_set_timestamp_mode (struct ice_pf *pf,struct hwtstamp_config *config) { -/* Reserved for future extensions. */ -if (config->flags) -return -EINVAL ; -switch (config->tx_type) {case HWTSTAMP_TX_OFF :ice_set_tx_tstamp (pf, false);
drivers/net/ethernet/intel/igb/igb_ptp.c +0 -4
@@ -1015,10 +1015,6 @@ static int igb_ptp_set_timestamp_mode(struct igb_adapter *adapter,bool is_l2 = false;u32 regval; -/* reserved for future extensions */ -if (config->flags) -return -EINVAL ; -switch (config->tx_type) {case HWTSTAMP_TX_OFF : tsync_tx_ctl =0 ;
drivers/net/ethernet/intel/igc/igc_ptp.c +0 -4
@@ -560,10 +560,6 @@ static void igc_ptp_enable_tx_timestamp(struct igc_adapter *adapter)static int igc_ptp_set_timestamp_mode (struct igc_adapter *adapter,struct hwtstamp_config *config) { -/* reserved for future extensions */ -if (config->flags) -return -EINVAL ; -switch (config->tx_type) {case HWTSTAMP_TX_OFF :igc_ptp_disable_tx_timestamp (adapter);
drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c +0 -4
@@ -992,10 +992,6 @@ static int ixgbe_ptp_set_timestamp_mode(struct ixgbe_adapter *adapter,bool is_l2 = false;u32 regval; -/* reserved for future extensions */ -if (config->flags) -return -EINVAL ; -switch (config->tx_type) {case HWTSTAMP_TX_OFF : tsync_tx_ctl =0 ;
drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c +0 -3
@@ -5142,9 +5142,6 @@ static int mvpp2_set_ts_config(struct mvpp2_port *port, struct ifreq *ifr)if (copy_from_user (&config, ifr->ifr_data,sizeof (config)))return -EFAULT ; -if (config.flags) -return -EINVAL ; -if (config.tx_type !=HWTSTAMP_TX_OFF && config.tx_type !=HWTSTAMP_TX_ON )return -ERANGE ;
drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c +0 -4
@@ -2002,10 +2002,6 @@ int otx2_config_hwtstamp(struct net_device *netdev, struct ifreq *ifr)if (copy_from_user (&config, ifr->ifr_data,sizeof (config)))return -EFAULT ; -/* reserved for future extensions */ -if (config.flags) -return -EINVAL ; -switch (config.tx_type) {case HWTSTAMP_TX_OFF :otx2_config_hw_tx_tstamp (pfvf, false);
drivers/net/ethernet/mellanox/mlx4/en_netdev.c +0 -4
@@ -2427,10 +2427,6 @@ static int mlx4_en_hwtstamp_set(struct net_device *dev, struct ifreq *ifr)if (copy_from_user (&config, ifr->ifr_data,sizeof (config)))return -EFAULT ; -/* reserved for future extensions */ -if (config.flags) -return -EINVAL ; -/* device doesn't support time stamping */ if (!(mdev->dev->caps.flags2 &MLX4_DEV_CAP_FLAG2_TS ))return -EINVAL ;
drivers/net/ethernet/microchip/lan743x_ptp.c +0 -6
@@ -1305,12 +1305,6 @@ int lan743x_ptp_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd)if (copy_from_user (&config, ifr->ifr_data,sizeof (config)))return -EFAULT ; -if (config.flags) { -netif_warn (adapter, drv, adapter->netdev, -"ignoring hwtstamp_config.flags == 0x%08X, expected 0\n" , - config.flags); - } -switch (config.tx_type) {case HWTSTAMP_TX_OFF : for (index = 0; index < LAN743X_MAX_TX_CHANNELS;
drivers/net/ethernet/mscc/ocelot.c +0 -4
@@ -1602,10 +1602,6 @@ int ocelot_hwstamp_set(struct ocelot *ocelot, int port, struct ifreq *ifr)if (copy_from_user (&cfg, ifr->ifr_data,sizeof (cfg)))return -EFAULT ; -/* reserved for future extensions */ -if (cfg.flags) -return -EINVAL ; -/* Tx type sanity check */ switch (cfg.tx_type) {case HWTSTAMP_TX_ON :
drivers/net/ethernet/neterion/vxge/vxge-main.c +0 -4
@@ -3159,10 +3159,6 @@ static int vxge_hwtstamp_set(struct vxgedev *vdev, void __user *data)if (copy_from_user (&config, data,sizeof (config)))return -EFAULT ; -/* reserved for future extensions */ -if (config.flags) -return -EINVAL ; -/* Transmit HW Timestamp not supported */ switch (config.tx_type) {case HWTSTAMP_TX_OFF :
drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c +0 -3
@@ -210,9 +210,6 @@ static int hwtstamp_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd)if (copy_from_user (&cfg, ifr->ifr_data,sizeof (cfg)))return -EFAULT ; -if (cfg.flags)/* reserved for future extensions */ -return -EINVAL ; -/* Get ieee1588's dev information */ pdev = adapter->ptp_pdev;
drivers/net/ethernet/qlogic/qede/qede_ptp.c +0 -5
@@ -304,11 +304,6 @@ int qede_ptp_hw_ts(struct qede_dev *edev, struct ifreq *ifr)"HWTSTAMP IOCTL: Requested tx_type = %d, requested rx_filters = %d\n" , config.tx_type, config.rx_filter); -if (config.flags) { -DP_ERR (edev,"config.flags is reserved for future use\n" ); -return -EINVAL ; - } - ptp->hw_ts_ioctl_called =1 ; ptp->tx_type = config.tx_type; ptp->rx_filter = config.rx_filter;
drivers/net/ethernet/renesas/ravb_main.c +0 -4
@@ -2221,10 +2221,6 @@ static int ravb_hwtstamp_set(struct net_device *ndev, struct ifreq *req)if (copy_from_user (&config, req->ifr_data,sizeof (config)))return -EFAULT ; -/* Reserved for future extensions */ -if (config.flags) -return -EINVAL ; -switch (config.tx_type) {case HWTSTAMP_TX_OFF : tstamp_tx_ctrl =0 ;
drivers/net/ethernet/sfc/ptp.c +0 -3
@@ -1765,9 +1765,6 @@ static int efx_ptp_ts_init(struct efx_nic *efx, struct hwtstamp_config *init) {int rc; -if (init->flags) -return -EINVAL ; -if ((init->tx_type !=HWTSTAMP_TX_OFF ) && (init->tx_type !=HWTSTAMP_TX_ON ))return -ERANGE ;
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +0 -4
@@ -636,10 +636,6 @@ static int stmmac_hwtstamp_set(struct net_device *dev, struct ifreq *ifr)netdev_dbg (priv->dev,"%s config flags:0x%x, tx_type:0x%x, rx_filter:0x%x\n" , __func__, config.flags, config.tx_type, config.rx_filter); -/* reserved for future extensions */ -if (config.flags) -return -EINVAL ; -if (config.tx_type !=HWTSTAMP_TX_OFF && config.tx_type !=HWTSTAMP_TX_ON )return -ERANGE ;
drivers/net/ethernet/ti/cpsw_priv.c +0 -4
@@ -626,10 +626,6 @@ static int cpsw_hwtstamp_set(struct net_device *dev, struct ifreq *ifr)if (copy_from_user (&cfg, ifr->ifr_data,sizeof (cfg)))return -EFAULT ; -/* reserved for future extensions */ -if (cfg.flags) -return -EINVAL ; -if (cfg.tx_type !=HWTSTAMP_TX_OFF && cfg.tx_type !=HWTSTAMP_TX_ON )return -ERANGE ;
drivers/net/ethernet/ti/netcp_ethss.c +0 -4
@@ -2654,10 +2654,6 @@ static int gbe_hwtstamp_set(struct gbe_intf *gbe_intf, struct ifreq *ifr)if (copy_from_user (&cfg, ifr->ifr_data,sizeof (cfg)))return -EFAULT ; -/* reserved for future extensions */ -if (cfg.flags) -return -EINVAL ; -switch (cfg.tx_type) {case HWTSTAMP_TX_OFF : gbe_dev->tx_ts_enabled =0 ;
drivers/net/ethernet/xscale/ixp4xx_eth.c +0 -3
@@ -382,9 +382,6 @@ static int hwtstamp_set(struct net_device *netdev, struct ifreq *ifr)if (copy_from_user (&cfg, ifr->ifr_data,sizeof (cfg)))return -EFAULT ; -if (cfg.flags)/* reserved for future extensions */ -return -EINVAL ; - ret =ixp46x_ptp_find (&port->timesync_regs, &port->phc_index);if (ret)return ret;
drivers/net/phy/dp83640.c +0 -3
@@ -1235,9 +1235,6 @@ static int dp83640_hwtstamp(struct mii_timestamper *mii_ts, struct ifreq *ifr)if (copy_from_user (&cfg, ifr->ifr_data,sizeof (cfg)))return -EFAULT ; -if (cfg.flags)/* reserved for future extensions */ -return -EINVAL ; -if (cfg.tx_type <0 || cfg.tx_type >HWTSTAMP_TX_ONESTEP_SYNC )return -ERANGE ;
drivers/net/phy/mscc/mscc_ptp.c +0 -3
@@ -1057,9 +1057,6 @@ static int vsc85xx_hwtstamp(struct mii_timestamper *mii_ts, struct ifreq *ifr)if (copy_from_user (&cfg, ifr->ifr_data,sizeof (cfg)))return -EFAULT ; -if (cfg.flags) -return -EINVAL ; -switch (cfg.tx_type) {case HWTSTAMP_TX_ONESTEP_SYNC : one_step = true;
drivers/ptp/ptp_ines.c +0 -4
@@ -338,10 +338,6 @@ static int ines_hwtstamp(struct mii_timestamper *mii_ts, struct ifreq *ifr)if (copy_from_user (&cfg, ifr->ifr_data,sizeof (cfg)))return -EFAULT ; -/* reserved for future extensions */ -if (cfg.flags) -return -EINVAL ; -switch (cfg.tx_type) {case HWTSTAMP_TX_OFF : ts_stat_tx =0 ;
include/uapi/linux/net_tstamp.h +15 -1
@@ -62,7 +62,7 @@ struct so_timestamping {/** * struct hwtstamp_config - %SIOCGHWTSTAMP and %SIOCSHWTSTAMP parameter * -* @flags: no flags defined right now, must be zero for %SIOCSHWTSTAMP +* @flags: one of HWTSTAMP_FLAG_* * @tx_type: one of HWTSTAMP_TX_* * @rx_filter: one of HWTSTAMP_FILTER_* *
@@ -78,6 +78,20 @@ struct hwtstamp_config {int rx_filter; }; +/* possible values for hwtstamp_config->flags */ +enum hwtstamp_flags { +/* +* With this flag, the user could get bond active interface's +* PHC index. Note this PHC index is not stable as when there +* is a failover, the bond active interface will be changed, so +* will be the PHC index. +*/ +HWTSTAMP_FLAG_BONDED_PHC_INDEX = (1 <<0 ), + +HWTSTAMP_FLAG_LAST =HWTSTAMP_FLAG_BONDED_PHC_INDEX , +HWTSTAMP_FLAG_MASK = (HWTSTAMP_FLAG_LAST -1 ) |HWTSTAMP_FLAG_LAST +}; +/* possible values for hwtstamp_config->tx_type */ enum hwtstamp_tx_types {/*
net/core/dev_ioctl.c +1 -1
@@ -192,7 +192,7 @@ static int net_hwtstamp_validate(struct ifreq *ifr)if (copy_from_user (&cfg, ifr->ifr_data,sizeof (cfg)))return -EFAULT ; -if (cfg.flags)/* reserved for future extensions */ +if (cfg.flags & ~HWTSTAMP_FLAG_MASK )return -EINVAL ; tx_type = cfg.tx_type;
Signature · 1 line
2.31.1
Re: [PATCHv3 net-next 1/2] net_tstamp: add new flag HWTSTAMP_FLAG_BONDED_PHC_INDEX
Hi Jakub,
When implement the user space support for this feature. I realized that we can't use the new flag directly as the user space tool needs to have backward compatibility. Because run the new tool with this flag enabled on old kernel will get -EINVAL error. And we also could not use #ifdef directly as HWTSTAMP_FLAG_BONDED_PHC_INDEX is a enum.
Do you think if we could add a #define in linux/net_tstamp.h like
#define HWTSTAMP_FLAGS_SUPPORT 1
So that the user space tool could use it like
#ifdef HWTSTAMP_FLAGS_SUPPORT
cfg->flags = HWTSTAMP_FLAG_BONDED_PHC_INDEX;#endif
Thanks
Hangbin
Quoted 20 lines · Hangbin Liu
Since commit
94dd016ae538("bond: passget_ts_infoand SIOC[SG]HWTSTAMP ioctl to active device") the user could get bond active interface's PHC index directly. But when there is a failover, the bond active interface will change, thus the PHC index is also changed. This may break the user's program if they did not update the PHC timely.This patch adds a new
hwtstamp_configflagHWTSTAMP_FLAG_BONDED_PHC_INDEX. When the user wants to get the bond active interface's PHC, they need to add this flag and be aware the PHC index may be changed.With the new flag. All flag checks in current drivers are removed. Only the checking in
net_hwtstamp_validate()is kept.Suggested-by Jakub Kicinski <[email protected]>Signed-off-by Hangbin Liu <[email protected]>---
v3: Use bitwise test to check the flags validation
v2: Keep the flag validation check innet_hwtstamp_validate()
Rename the flag toHWTSTAMP_FLAG_BONDED_PHC_INDEX
[...]
Quoted 50 lines
include/uapi/linux/net_tstamp.h +15
-1@@ -62,7 +62,7 @@ struct so_timestamping {/** * struct hwtstamp_config - %SIOCGHWTSTAMP and %SIOCSHWTSTAMP parameter * -* @flags: no flags defined right now, must be zero for %SIOCSHWTSTAMP +* @flags: one of HWTSTAMP_FLAG_* * @tx_type: one of HWTSTAMP_TX_* * @rx_filter: one of HWTSTAMP_FILTER_* * @@ -78,6 +78,20 @@ struct hwtstamp_config {int rx_filter; }; +/* possible values for hwtstamp_config->flags */ +enum hwtstamp_flags { +/* +* With this flag, the user could get bond active interface's +* PHC index. Note this PHC index is not stable as when there +* is a failover, the bond active interface will be changed, so +* will be the PHC index. +*/ +HWTSTAMP_FLAG_BONDED_PHC_INDEX = (1 <<0 ), + +HWTSTAMP_FLAG_LAST =HWTSTAMP_FLAG_BONDED_PHC_INDEX , +HWTSTAMP_FLAG_MASK = (HWTSTAMP_FLAG_LAST -1 ) |HWTSTAMP_FLAG_LAST +}; +/* possible values for hwtstamp_config->tx_type */ enum hwtstamp_tx_types {/* net/core/dev_ioctl.c +1
-1@@ -192,7 +192,7 @@ static int net_hwtstamp_validate(struct ifreq *ifr)if (copy_from_user (&cfg, ifr->ifr_data,sizeof (cfg)))return -EFAULT ; -if (cfg.flags)/* reserved for future extensions */ +if (cfg.flags & ~HWTSTAMP_FLAG_MASK )return -EINVAL ; tx_type = cfg.tx_type;Signature · 1 line
2.31.1
Jakub Kicinski
maintainerRe: [PATCHv3 net-next 1/2] net_tstamp: add new flag HWTSTAMP_FLAG_BONDED_PHC_INDEX
Quoted 8 lines · On Tue, 28 Dec 2021 15:01:13 +0800 Hangbin Liu wrote:
When implement the user space support for this feature. I realized that we can't use the new flag directly as the user space tool needs to have backward compatibility. Because run the new tool with this flag enabled on old kernel will get
-EINVALerror. And we also could not use #ifdef directly asHWTSTAMP_FLAG_BONDED_PHC_INDEXis a enum.Do you think if we could add a #define in
linux/net_tstamp.hlike
Quoted 7 lines
#define
HWTSTAMP_FLAGS_SUPPORT1So that the user space tool could use it like
#ifdef HWTSTAMP_FLAGS_SUPPORT cfg->flags = HWTSTAMP_FLAG_BONDED_PHC_INDEX;#endif
We could set it on SIOCGHWTSTAMP to let user space know that it's necessary for a given netdev.
Richard Cochran
maintainerRe: [PATCHv3 net-next 1/2] net_tstamp: add new flag HWTSTAMP_FLAG_BONDED_PHC_INDEX
Quoted 11 lines · Jakub Kicinski
Quoted 10 lines · On Tue, 28 Dec 2021 15:01:13 +0800 Hangbin Liu wrote:
When implement the user space support for this feature. I realized that we can't use the new flag directly as the user space tool needs to have backward compatibility. Because run the new tool with this flag enabled on old kernel will get
-EINVALerror. And we also could not use #ifdef directly asHWTSTAMP_FLAG_BONDED_PHC_INDEXis a enum.Do you think if we could add a #define in
linux/net_tstamp.hlike#define
HWTSTAMP_FLAGS_SUPPORT1
Quoted 8 lines
Quoted 5 lines
So that the user space tool could use it like
#ifdef HWTSTAMP_FLAGS_SUPPORT cfg->flags = HWTSTAMP_FLAG_BONDED_PHC_INDEX;#endif
We could set it on SIOCGHWTSTAMP to let user space know that it's necessary for a given netdev.
What about adding matching #defines into the enum declaration?
enum hwtstamp_flags {
HWTSTAMP_FLAG_BONDED_PHC_INDEX = (1<<0),#define HWTSTAMP_FLAG_BONDED_PHC_INDEX (1<<0)
};
IIRC I have seen this pattern used in the kernel, but ATM I can't find any example :(
Thanks,
Richard
Jakub Kicinski
maintainerRe: [PATCHv3 net-next 1/2] net_tstamp: add new flag HWTSTAMP_FLAG_BONDED_PHC_INDEX
Quoted 21 lines · On Tue, 28 Dec 2021 08:00:50 -0800 Richard Cochran wrote:
Quoted 11 lines · Jakub Kicinski
Quoted 10 lines · On Tue, 28 Dec 2021 15:01:13 +0800 Hangbin Liu wrote:
When implement the user space support for this feature. I realized that we can't use the new flag directly as the user space tool needs to have backward compatibility. Because run the new tool with this flag enabled on old kernel will get
-EINVALerror. And we also could not use #ifdef directly asHWTSTAMP_FLAG_BONDED_PHC_INDEXis a enum.Do you think if we could add a #define in
linux/net_tstamp.hlike#define
HWTSTAMP_FLAGS_SUPPORT1Quoted 8 lines
Quoted 5 lines
So that the user space tool could use it like
#ifdef HWTSTAMP_FLAGS_SUPPORT cfg->flags = HWTSTAMP_FLAG_BONDED_PHC_INDEX;#endif
We could set it on SIOCGHWTSTAMP to let user space know that it's necessary for a given netdev.
Quoted 8 lines
What about adding matching #defines into the enum declaration?
enum hwtstamp_flags { HWTSTAMP_FLAG_BONDED_PHC_INDEX = (1<<0),#define
HWTSTAMP_FLAG_BONDED_PHC_INDEX(1<<0)
};IIRC I have seen this pattern used in the kernel, but ATM I can't find any example :(
That's still just a compile-time fix, if the user space binary is distributed in binary form (distro package) there is no knowing on which kernel versions it will run. I think runtime probing will be necessary.
If we want the define it should be to the enum name:
What about adding matching #defines into the enum declaration?
enum hwtstamp_flags {
HWTSTAMP_FLAG_BONDED_PHC_INDEX = (1<<0),#define HWTSTAMP_FLAG_BONDED_PHC_INDEX HWTSTAMP_FLAG_BONDED_PHC_INDEX };
Examples in include/uapi/linux/rtnetlink.h
Richard Cochran
maintainerRe: [PATCHv3 net-next 1/2] net_tstamp: add new flag HWTSTAMP_FLAG_BONDED_PHC_INDEX
Quoted 1 line · Jakub Kicinski
That's still just a compile-time fix,
I think Hangbin's immediate question was about compilation. linuxptp needs to be able to compile against older system headers.
Quoted 4 lines
if the user space binary
is distributed in binary form (distro package) there is no knowing on which kernel versions it will run. I think runtime probing will be necessary.
Yes, that too.
Quoted 10 lines
If we want the define it should be to the enum name:
What about adding matching #defines into the enum declaration?
enum hwtstamp_flags { HWTSTAMP_FLAG_BONDED_PHC_INDEX = (1<<0),#define
HWTSTAMP_FLAG_BONDED_PHC_INDEXHWTSTAMP_FLAG_BONDED_PHC_INDEX};Examples in
include/uapi/linux/rtnetlink.h
Ha! I knew I saw this somewhere.
Thanks,
Richard
Re: [PATCHv3 net-next 1/2] net_tstamp: add new flag HWTSTAMP_FLAG_BONDED_PHC_INDEX
Quoted 5 lines · Richard Cochran
Quoted 1 line · Jakub Kicinski
That's still just a compile-time fix,
I think Hangbin's immediate question was about compilation. linuxptp needs to be able to compile against older system headers.
Yes. That's what I mean.
Quoted 7 lines
Quoted 5 lines
if the user space binary
is distributed in binary form (distro package) there is no knowing on which kernel versions it will run. I think runtime probing will be necessary.Yes, that too.
Thanks, I will pay attention on this when do user space implementation.
Quoted 5 lines
Quoted 5 lines
If we want the define it should be to the enum name:
What about adding matching #defines into the enum declaration?
Quoted 8 lines
Quoted 6 lines
enum hwtstamp_flags { HWTSTAMP_FLAG_BONDED_PHC_INDEX = (1<<0),#define
HWTSTAMP_FLAG_BONDED_PHC_INDEXHWTSTAMP_FLAG_BONDED_PHC_INDEX};Examples in
include/uapi/linux/rtnetlink.hHa! I knew I saw this somewhere.
Thanks for this hint.
Cheers
Hangbin
PATCH v3 2/2 Bonding: force user to add HWTSTAMP_FLAG_BONDED_PHC_INDEX when get/set HWTSTAMP
In reply to Hangbin LiuWhen there is a failover, the PHC index of bond active interface will be changed. This may break the user space program if the author didn't aware.
By setting this flag, the user should aware that the PHC index get/set by syscall is not stable. And the user space is able to deal with it. Without this flag, the kernel will reject the request forwarding to bonding.
---
v2: change the flag name to HWTSTAMP_FLAG_BONDED_PHC_INDEX
--- drivers/net/bonding/bond_main.c | 33 +++++++++++++++++++++------------ 1 file changed, 21 insertions(+), 12 deletions(-)
drivers/net/bonding/bond_main.c +21 -12
@@ -4094,6 +4094,7 @@ static int bond_eth_ioctl(struct net_device *bond_dev, struct ifreq *ifr, int cmstruct mii_ioctl_data *mii =NULL ;const struct net_device_ops *ops;struct net_device *real_dev; +struct hwtstamp_config cfg;struct ifreq ifrr;int res =0 ;
@@ -4124,21 +4125,29 @@ static int bond_eth_ioctl(struct net_device *bond_dev, struct ifreq *ifr, int cmbreak ;case SIOCSHWTSTAMP :case SIOCGHWTSTAMP : -rcu_read_lock (); - real_dev =bond_option_active_slave_get_rcu (bond); -rcu_read_unlock (); -if (real_dev) { -strscpy_pad (ifrr.ifr_name, real_dev->name,IFNAMSIZ ); - ifrr.ifr_ifru = ifr->ifr_ifru; +if (copy_from_user (&cfg, ifr->ifr_data,sizeof (cfg))) +return -EFAULT ; + +if (cfg.flags &HWTSTAMP_FLAG_BONDED_PHC_INDEX ) { +rcu_read_lock (); + real_dev =bond_option_active_slave_get_rcu (bond); +rcu_read_unlock (); +if (real_dev) { +strscpy_pad (ifrr.ifr_name, real_dev->name,IFNAMSIZ ); + ifrr.ifr_ifru = ifr->ifr_ifru; + + ops = real_dev->netdev_ops; +if (netif_device_present (real_dev) && ops->ndo_eth_ioctl) { + res = ops->ndo_eth_ioctl (real_dev, &ifrr, cmd); - ops = real_dev->netdev_ops; -if (netif_device_present (real_dev) && ops->ndo_eth_ioctl) - res = ops->ndo_eth_ioctl (real_dev, &ifrr, cmd); +if (!res) + ifr->ifr_ifru = ifrr.ifr_ifru; -if (!res) - ifr->ifr_ifru = ifrr.ifr_ifru; +return res; + } + } } -break ; + fallthrough;default : res = -EOPNOTSUPP ; }
Signature · 1 line
2.31.1
This series was applied to netdev/net-next.git (master) by David S. Miller <[email protected]>:
Hello:
This series was applied to netdev/net-next.git (master) by David S. Miller <[email protected]>:
Quoted 8 lines · On Fri, 10 Dec 2021 16:59:57 +0800 you wrote:
This patchset add a new
hwtstamp_configflagHWTSTAMP_FLAG_BONDED_PHC_INDEX. When user want to get bond active interface's PHC, they need to add this flag and aware the PHC index may changed.v3: Use bitwise test to check the flags validation
v2: rename the flag toHWTSTAMP_FLAG_BONDED_PHC_INDEX[...]
Here is the summary with links:
- [PATCHv3,net-next,1/2] net_tstamp: add new flag HWTSTAMP_FLAG_BONDED_PHC_INDEX
https://git.kernel.org/netdev/net-next/c/9c9211a3fc7a - [PATCHv3,net-next,2/2] Bonding: force user to add HWTSTAMP_FLAG_BONDED_PHC_INDEX when get/set HWTSTAMP https://git.kernel.org/netdev/net-next/c/085d61000845
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html