Skip to content

Commit 980f079

Browse files
liuhangbinkuba-moo
authored andcommitted
bonding: add software tx timestamping support
Currently, bonding only obtain the timestamp (ts) information of the active slave, which is available only for modes 1, 5, and 6. For other modes, bonding only has software rx timestamping support. However, some users who use modes such as LACP also want tx timestamp support. To address this issue, let's check the ts information of each slave. If all slaves support tx timestamping, we can enable tx timestamping support for the bond. Add a note that the get_ts_info may be called with RCU, or rtnl or reference on the device in ethtool.h> Suggested-by: Miroslav Lichvar <[email protected]> Signed-off-by: Hangbin Liu <[email protected]> Acked-by: Jay Vosburgh <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent dce46f1 commit 980f079

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

drivers/net/bonding/bond_main.c

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5696,9 +5696,13 @@ static int bond_ethtool_get_ts_info(struct net_device *bond_dev,
56965696
struct ethtool_ts_info *info)
56975697
{
56985698
struct bonding *bond = netdev_priv(bond_dev);
5699+
struct ethtool_ts_info ts_info;
56995700
const struct ethtool_ops *ops;
57005701
struct net_device *real_dev;
5702+
bool sw_tx_support = false;
57015703
struct phy_device *phydev;
5704+
struct list_head *iter;
5705+
struct slave *slave;
57025706
int ret = 0;
57035707

57045708
rcu_read_lock();
@@ -5717,10 +5721,36 @@ static int bond_ethtool_get_ts_info(struct net_device *bond_dev,
57175721
ret = ops->get_ts_info(real_dev, info);
57185722
goto out;
57195723
}
5724+
} else {
5725+
/* Check if all slaves support software tx timestamping */
5726+
rcu_read_lock();
5727+
bond_for_each_slave_rcu(bond, slave, iter) {
5728+
ret = -1;
5729+
ops = slave->dev->ethtool_ops;
5730+
phydev = slave->dev->phydev;
5731+
5732+
if (phy_has_tsinfo(phydev))
5733+
ret = phy_ts_info(phydev, &ts_info);
5734+
else if (ops->get_ts_info)
5735+
ret = ops->get_ts_info(slave->dev, &ts_info);
5736+
5737+
if (!ret && (ts_info.so_timestamping & SOF_TIMESTAMPING_TX_SOFTWARE)) {
5738+
sw_tx_support = true;
5739+
continue;
5740+
}
5741+
5742+
sw_tx_support = false;
5743+
break;
5744+
}
5745+
rcu_read_unlock();
57205746
}
57215747

5748+
ret = 0;
57225749
info->so_timestamping = SOF_TIMESTAMPING_RX_SOFTWARE |
57235750
SOF_TIMESTAMPING_SOFTWARE;
5751+
if (sw_tx_support)
5752+
info->so_timestamping |= SOF_TIMESTAMPING_TX_SOFTWARE;
5753+
57245754
info->phc_index = -1;
57255755

57265756
out:

include/linux/ethtool.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -711,6 +711,7 @@ struct ethtool_mm_stats {
711711
* @get_dump_data: Get dump data.
712712
* @set_dump: Set dump specific flags to the device.
713713
* @get_ts_info: Get the time stamping and PTP hardware clock capabilities.
714+
* It may be called with RCU, or rtnl or reference on the device.
714715
* Drivers supporting transmit time stamps in software should set this to
715716
* ethtool_op_get_ts_info().
716717
* @get_module_info: Get the size and type of the eeprom contained within

0 commit comments

Comments
 (0)