From: Jason Xing kernelxing@tencent.com
[ Upstream commit b86bcfee30576b752302c55693fff97242b35dfd ]
As mlx4 has implemented skb_tx_timestamp() in mlx4_en_xmit(), the SOFTWARE flag is surely needed when users are trying to get timestamp information.
Signed-off-by: Jason Xing kernelxing@tencent.com Reviewed-by: Tariq Toukan tariqt@nvidia.com Link: https://patch.msgid.link/20250510093442.79711-1-kerneljasonxing@gmail.com Signed-off-by: Jakub Kicinski kuba@kernel.org Signed-off-by: Sasha Levin sashal@kernel.org ---
Perfect! Now I can see that `skb_tx_timestamp(skb)` is called in the `mlx4_en_xmit()` function, which is the main transmit function. This confirms that the mlx4 driver does implement software timestamping. Now let me compare this to the similar commits to see the pattern: **YES** This commit should be backported to stable kernel trees. **Extensive Explanation:** This commit addresses a clear inconsistency bug where the mlx4 driver implements software timestamping functionality but fails to advertise this capability to userspace through the ethtool timestamping info interface. **Analysis of the fix:** 1. **The Problem**: The mlx4 driver calls `skb_tx_timestamp(skb)` in `mlx4_en_xmit()` at line 1091 of `/drivers/net/ethernet/mellanox/mlx4/en_tx.c`, which means it properly implements software TX timestamping. However, in `mlx4_en_get_ts_info()`, it only advertises hardware timestamping capabilities (`SOF_TIMESTAMPING_TX_HARDWARE`, `SOF_TIMESTAMPING_RX_HARDWARE`, `SOF_TIMESTAMPING_RAW_HARDWARE`) but omits the `SOF_TIMESTAMPING_TX_SOFTWARE` flag. 2. **The Fix**: The change adds a single line `SOF_TIMESTAMPING_TX_SOFTWARE |` to the `info->so_timestamping` field when hardware timestamping is supported, correctly advertising both hardware and software timestamping capabilities. 3. **Impact**: This is a user-facing API correctness issue. Applications checking timestamping capabilities via ethtool would incorrectly believe software timestamping is not supported, even though the driver implements it. **Comparison with similar commits:** - **Similar Commit #1 (YES)**: Also fixed a timestamping bug in mlx4, showing these are important fixes - **Similar Commit #3 (YES)**: Fixed incorrect timestamping capability reporting in mlx5 by removing false software timestamping indication - **Similar Commit #5 (YES)**: Fixed timestamping capabilities reporting using wrong BIT() macro in mlx5 The pattern shows that timestamping capability reporting bugs are consistently considered backport-worthy because they affect user-visible API behavior. **Backport Criteria Assessment:** ✅ **Fixes a user- affecting bug**: Applications cannot detect software timestamping support ✅ **Small, contained change**: Single line addition with no functional logic changes ✅ **No architectural changes**: Only fixes capability reporting ✅ **Low regression risk**: Only adds a missing flag, doesn't change driver behavior ✅ **Clear side effects**: None beyond correctly advertising existing functionality ✅ **Follows stable rules**: Important API correctness fix with minimal risk The fix is identical in nature to Similar Commit #3 (marked YES) but in reverse - where mlx5 removed false software timestamping advertisement, this adds the missing software timestamping advertisement for mlx4 where it's actually implemented.
drivers/net/ethernet/mellanox/mlx4/en_ethtool.c | 1 + 1 file changed, 1 insertion(+)
diff --git a/drivers/net/ethernet/mellanox/mlx4/en_ethtool.c b/drivers/net/ethernet/mellanox/mlx4/en_ethtool.c index cd17a3f4faf83..a68cd3f0304c6 100644 --- a/drivers/net/ethernet/mellanox/mlx4/en_ethtool.c +++ b/drivers/net/ethernet/mellanox/mlx4/en_ethtool.c @@ -1897,6 +1897,7 @@ static int mlx4_en_get_ts_info(struct net_device *dev, if (mdev->dev->caps.flags2 & MLX4_DEV_CAP_FLAG2_TS) { info->so_timestamping |= SOF_TIMESTAMPING_TX_HARDWARE | + SOF_TIMESTAMPING_TX_SOFTWARE | SOF_TIMESTAMPING_RX_HARDWARE | SOF_TIMESTAMPING_RAW_HARDWARE;