Skip to contentSkip to conversation

bonding: add software timestamping support

PATCH Superseded Hangbin Liu 4 participants 11 messages Mar 29, 2023 – Apr 5, 2023

Subsystems (3)

v1 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 bonding: add software timestamping support

At present, bonding attempts to obtain the timestamp (ts) information of the active slave. However, this feature is only available for mode 1, 5, and 6. For other modes, bonding doesn't even provide support for software timestamping. To address this issue, let's call ethtool_op_get_ts_info when there is no primary active slave. This will enable the use of software timestamping for the bonding interface.

---
 drivers/net/bonding/bond_main.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/net/bonding/bond_main.c +1 -3
index 00646aa315c3..f0856bec59f5 100644
@@ -5709,9 +5709,7 @@ static int bond_ethtool_get_ts_info(struct net_device *bond_dev,
 		}
 	}
 
-	info->so_timestamping = SOF_TIMESTAMPING_RX_SOFTWARE |
-				SOF_TIMESTAMPING_SOFTWARE;
-	info->phc_index = -1;
+	ret = ethtool_op_get_ts_info(bond_dev, info);
 
 out:
 	dev_put(real_dev);
Signature · 1 line
2.38.1
#1 lore raw
Quoted 6 lines · Hangbin Liu

At present, bonding attempts to obtain the timestamp (ts) information of the active slave. However, this feature is only available for mode 1, 5, and 6. For other modes, bonding doesn't even provide support for software timestamping. To address this issue, let's call ethtool_op_get_ts_info when there is no primary active slave. This will enable the use of software timestamping for the bonding interface.

If I'm reading the patch below correctly, the actual functional
change here is to additionally set SOF_TIMESTAMPING_TX_SOFTWARE in so_timestamping for the active-backup, balance-tlb and balance-alb modes (or whenever there's no active slave, but that's less interesting). So, this patch only changes the behavior with regards to transmit timestamping, correct?

I'm not objecting to the patch per se, but the description above
does not appear to correctly describe the change.

	-J
Quoted 19 lines

---
drivers/net/bonding/bond_main.c | 4 +---

1 file changed, 1 insertion(+), 3 deletions(-)
drivers/net/bonding/bond_main.c +1 -3
index 00646aa315c3..f0856bec59f5 100644
@@ -5709,9 +5709,7 @@ static int bond_ethtool_get_ts_info(struct net_device *bond_dev,
 		}
 	}
 
-	info->so_timestamping = SOF_TIMESTAMPING_RX_SOFTWARE |
-				SOF_TIMESTAMPING_SOFTWARE;
-	info->phc_index = -1;
+	ret = ethtool_op_get_ts_info(bond_dev, info);
 

out:

Quoted 4 lines
	dev_put(real_dev);
Signature · 1 line
2.38.1

---
-Jay Vosburgh, [email protected]

#4 lore raw
In reply to Hangbin Liu
Quoted 6 lines · Hangbin Liu

At present, bonding attempts to obtain the timestamp (ts) information of the active slave. However, this feature is only available for mode 1, 5, and 6. For other modes, bonding doesn't even provide support for software timestamping. To address this issue, let's call ethtool_op_get_ts_info when there is no primary active slave. This will enable the use of software timestamping for the bonding interface.

Would it make sense to check if all devices in the bond support SOF_TIMESTAMPING_TX_SOFTWARE before returning it for the bond? Applications might expect that a SW TX timestamp will be always provided if the capability is reported.

Signature · 1 line
Miroslav Lichvar
#5 lore raw
Quoted 8 lines · Miroslav Lichvar
Quoted 6 lines · Hangbin Liu

At present, bonding attempts to obtain the timestamp (ts) information of the active slave. However, this feature is only available for mode 1, 5, and 6. For other modes, bonding doesn't even provide support for software timestamping. To address this issue, let's call ethtool_op_get_ts_info when there is no primary active slave. This will enable the use of software timestamping for the bonding interface.

Quoted 4 lines

Would it make sense to check if all devices in the bond support SOF_TIMESTAMPING_TX_SOFTWARE before returning it for the bond? Applications might expect that a SW TX timestamp will be always provided if the capability is reported.

In my understanding this is a software feature, no need for hardware support. In __sock_tx_timestamp() it will set skb tx_flags when we have SOF_TIMESTAMPING_TX_SOFTWARE flag. Do I understand wrong?

Thanks
Hangbin

#2 lore raw
In reply to Jay Vosburgh
Quoted 9 lines · Jay Vosburgh
Quoted 6 lines · Hangbin Liu

At present, bonding attempts to obtain the timestamp (ts) information of the active slave. However, this feature is only available for mode 1, 5, and 6. For other modes, bonding doesn't even provide support for software timestamping. To address this issue, let's call ethtool_op_get_ts_info when there is no primary active slave. This will enable the use of software timestamping for the bonding interface.

Quoted 3 lines

If I'm reading the patch below correctly, the actual functional
change here is to additionally set SOF_TIMESTAMPING_TX_SOFTWARE in so_timestamping for the active-backup, balance-tlb and balance-alb modes

No. In the description. I said for other modes, bonding doesn't even provide support for software timestamping. So this patch is to address this issue. i.e. add sw timestaming for all bonding modes.

For mode 1,5,6. We will try find the active slave and get it's ts info directly. If there is no ops->get_ts_info, just use sw timestamping.

For other modes, use sw timestamping directly.

This is because some users want to use PTP over bond with other modes. e.g. LACP. They are satisfied with just sw timestamping as it's difficult to support hw timestamping for LACP bonding.

Before this patch, bond mode with 0, 2, 3, 4 only has software-receive.

# ethtool -T bond0
Time stamping parameters for bond0:
Capabilities:
        software-receive
        software-system-clock
PTP Hardware Clock: none
Hardware Transmit Timestamp Modes: none
Hardware Receive Filter Modes: none
# ptp4l -m -S -i bond0
ptp4l[66296.154]: interface 'bond0' does not support requested timestamping mode
failed to create a clock

After this patch:

# ethtool -T bond0
Time stamping parameters for bond0:
Capabilities:
        software-transmit
        software-receive
        software-system-clock
PTP Hardware Clock: none
Hardware Transmit Timestamp Modes: none
Hardware Receive Filter Modes: none
# ptp4l -m -S -i bond0
ptp4l[66952.474]: port 1: INITIALIZING to LISTENING on INIT_COMPLETE
ptp4l[66952.474]: port 0: INITIALIZING to LISTENING on INIT_COMPLETE
ptp4l[66952.474]: port 0: INITIALIZING to LISTENING on INIT_COMPLETE
ptp4l[66981.681]: port 1: LISTENING to MASTER on ANNOUNCE_RECEIPT_TIMEOUT_EXPIRES
ptp4l[66981.681]: selected local clock 007c50.fffe.70cdb6 as best master
ptp4l[66981.682]: port 1: assuming the grand master role

Thanks
Hangbin

maintainer
#6 lore raw
In reply to Hangbin Liu
Quoted 9 lines · On Thu, 30 Mar 2023 11:33:43 +0800 Hangbin Liu wrote:
Quoted 8 lines · Miroslav Lichvar
Quoted 6 lines · Hangbin Liu

At present, bonding attempts to obtain the timestamp (ts) information of the active slave. However, this feature is only available for mode 1, 5, and 6. For other modes, bonding doesn't even provide support for software timestamping. To address this issue, let's call ethtool_op_get_ts_info when there is no primary active slave. This will enable the use of software timestamping for the bonding interface.

Quoted 8 lines
Quoted 4 lines

Would it make sense to check if all devices in the bond support SOF_TIMESTAMPING_TX_SOFTWARE before returning it for the bond? Applications might expect that a SW TX timestamp will be always provided if the capability is reported.

In my understanding this is a software feature, no need for hardware support. In __sock_tx_timestamp() it will set skb tx_flags when we have SOF_TIMESTAMPING_TX_SOFTWARE flag. Do I understand wrong?

Driver needs to call skb_tx_timestamp(), so unlike with Rx there's something to do for the driver.

#7 lore raw
In reply to Hangbin Liu
Quoted 9 lines · Hangbin Liu
Quoted 8 lines · Miroslav Lichvar
Quoted 6 lines · Hangbin Liu

At present, bonding attempts to obtain the timestamp (ts) information of the active slave. However, this feature is only available for mode 1, 5, and 6. For other modes, bonding doesn't even provide support for software timestamping. To address this issue, let's call ethtool_op_get_ts_info when there is no primary active slave. This will enable the use of software timestamping for the bonding interface.

Quoted 8 lines
Quoted 4 lines

Would it make sense to check if all devices in the bond support SOF_TIMESTAMPING_TX_SOFTWARE before returning it for the bond? Applications might expect that a SW TX timestamp will be always provided if the capability is reported.

In my understanding this is a software feature, no need for hardware support. In __sock_tx_timestamp() it will set skb tx_flags when we have SOF_TIMESTAMPING_TX_SOFTWARE flag. Do I understand wrong?

Right, but the network device driver is required to call
skb_tx_timestamp() in order to record the actual timestamp for the software timestamping case.

Do all drivers that may be members of a bond return
SOF_TIMESTAMPING_TX_SOFTWARE to .get_ts_info and properly call skb_tx_timestamp()? I.e., is this something that needs to be checked, or is it safe to assume it's always true?

If I'm reading things correctly, the answer is no, as one
exception appears to be IPOIB, which doesn't define .get_ts_info that I can find, and does not call skb_tx_timestamp() in ipoib_start_xmit().

	-J

---
-Jay Vosburgh, [email protected]

#3 lore raw
In reply to Hangbin Liu
Quoted 10 lines · Hangbin Liu
Quoted 9 lines · Jay Vosburgh
Quoted 6 lines · Hangbin Liu

At present, bonding attempts to obtain the timestamp (ts) information of the active slave. However, this feature is only available for mode 1, 5, and 6. For other modes, bonding doesn't even provide support for software timestamping. To address this issue, let's call ethtool_op_get_ts_info when there is no primary active slave. This will enable the use of software timestamping for the bonding interface.

Quoted 7 lines
Quoted 3 lines

If I'm reading the patch below correctly, the actual functional
change here is to additionally set SOF_TIMESTAMPING_TX_SOFTWARE in so_timestamping for the active-backup, balance-tlb and balance-alb modes

No. In the description. I said for other modes, bonding doesn't even provide support for software timestamping. So this patch is to address this issue. i.e. add sw timestaming for all bonding modes.

Ok, I think I follow now. It is still adding only TX software
timestamping, as (from your example below) RX was already available.

So, I do think the patch description is imprecise in saying,
"For other modes, bonding doesn't even provide support for software timestamping" as this really refers to specifically TX timestamping.

	-J
Quoted 44 lines

For mode 1,5,6. We will try find the active slave and get it's ts info directly. If there is no ops->get_ts_info, just use sw timestamping.

For other modes, use sw timestamping directly.

This is because some users want to use PTP over bond with other modes. e.g. LACP. They are satisfied with just sw timestamping as it's difficult to support hw timestamping for LACP bonding.

Before this patch, bond mode with 0, 2, 3, 4 only has software-receive.

# ethtool -T bond0
Time stamping parameters for bond0:
Capabilities:
       software-receive
       software-system-clock
PTP Hardware Clock: none
Hardware Transmit Timestamp Modes: none
Hardware Receive Filter Modes: none
# ptp4l -m -S -i bond0
ptp4l[66296.154]: interface 'bond0' does not support requested timestamping mode
failed to create a clock

After this patch:

# ethtool -T bond0
Time stamping parameters for bond0:
Capabilities:
       software-transmit
       software-receive
       software-system-clock
PTP Hardware Clock: none
Hardware Transmit Timestamp Modes: none
Hardware Receive Filter Modes: none
# ptp4l -m -S -i bond0
ptp4l[66952.474]: port 1: INITIALIZING to LISTENING on INIT_COMPLETE
ptp4l[66952.474]: port 0: INITIALIZING to LISTENING on INIT_COMPLETE
ptp4l[66952.474]: port 0: INITIALIZING to LISTENING on INIT_COMPLETE
ptp4l[66981.681]: port 1: LISTENING to MASTER on ANNOUNCE_RECEIPT_TIMEOUT_EXPIRES
ptp4l[66981.681]: selected local clock 007c50.fffe.70cdb6 as best master
ptp4l[66981.682]: port 1: assuming the grand master role
Quoted 2 lines

Thanks
Hangbin

---
-Jay Vosburgh, [email protected]

#8 lore raw
In reply to Jay Vosburgh
Quoted 13 lines · Jay Vosburgh
Quoted 8 lines
Quoted 4 lines

Would it make sense to check if all devices in the bond support SOF_TIMESTAMPING_TX_SOFTWARE before returning it for the bond? Applications might expect that a SW TX timestamp will be always provided if the capability is reported.

In my understanding this is a software feature, no need for hardware support. In __sock_tx_timestamp() it will set skb tx_flags when we have SOF_TIMESTAMPING_TX_SOFTWARE flag. Do I understand wrong?

Right, but the network device driver is required to call
skb_tx_timestamp() in order to record the actual timestamp for the software timestamping case.

Quoted 8 lines

Do all drivers that may be members of a bond return
SOF_TIMESTAMPING_TX_SOFTWARE to .get_ts_info and properly call skb_tx_timestamp()? I.e., is this something that needs to be checked, or is it safe to assume it's always true?

If I'm reading things correctly, the answer is no, as one
exception appears to be IPOIB, which doesn't define .get_ts_info that I CAN Find, and does not call skb_tx_timestamp() in ipoib_start_xmit().

Oh.. I thought it's a software timestamp and all driver's should support it. I didn't expect that Infiniband doesn't support it. Based on this, it seems we can't even assume that all Ethernet drivers will support it, since a private driver may also not call skb_tx_timestamp() during transmit. Even if we check the slaves during ioctl call, we can't expect a later-joined slave to have SW TX timestamp support. It seems that we'll have to drop this feature."

Thanks
Hangbin

#9 lore raw
Quoted 11 lines · Hangbin Liu
Quoted 3 lines · Jay Vosburgh

If I'm reading things correctly, the answer is no, as one
exception appears to be IPOIB, which doesn't define .get_ts_info that I CAN Find, and does not call skb_tx_timestamp() in ipoib_start_xmit().

Oh.. I thought it's a software timestamp and all driver's should support it. I didn't expect that Infiniband doesn't support it. Based on this, it seems we can't even assume that all Ethernet drivers will support it, since a private driver may also not call skb_tx_timestamp() during transmit. Even if we check the slaves during ioctl call, we can't expect a later-joined slave to have SW TX timestamp support. It seems that we'll have to drop this feature."

I'd not see that as a problem. At the time of the ioctl call the information is valid. I think knowing that some timestamps will be missing due to an interface not supporting the feature is a different case than the admin later adding a new interface to the bond and breaking the condition. The application likely already have some expectations after it starts and configures timestamping, e.g. that the RX filter is not changed or TX timestamping disabled.

Signature · 1 line
Miroslav Lichvar
#10 lore raw
Quoted 7 lines · Miroslav Lichvar
Quoted 6 lines

Oh.. I thought it's a software timestamp and all driver's should support it. I didn't expect that Infiniband doesn't support it. Based on this, it seems we can't even assume that all Ethernet drivers will support it, since a private driver may also not call skb_tx_timestamp() during transmit. Even if we check the slaves during ioctl call, we can't expect a later-joined slave to have SW TX timestamp support. It seems that we'll have to drop this feature."

Quoted 7 lines

I'd not see that as a problem. At the time of the ioctl call the information is valid. I think knowing that some timestamps will be missing due to an interface not supporting the feature is a different case than the admin later adding a new interface to the bond and breaking the condition. The application likely already have some expectations after it starts and configures timestamping, e.g. that the RX filter is not changed or TX timestamping disabled.

Thanks, this makes sense to me. I will try this way and post the new patch.

Hangbin