net: stmmac: generate software timestamp just before the doorbell
authorJason Xing <kernelxing@tencent.com>
Sat, 10 May 2025 13:48:12 +0000 (21:48 +0800)
committerJakub Kicinski <kuba@kernel.org>
Thu, 15 May 2025 02:32:54 +0000 (19:32 -0700)
Make sure the call of skb_tx_timestamp is as close as possbile to the
doorbell.

The patch also adjusts the order of setting SKBTX_IN_PROGRESS and
generate software timestamp so that without SOF_TIMESTAMPING_OPT_TX_SWHW
being set the software and hardware timestamps will not appear in the
error queue of socket nearly at the same time (Please see __skb_tstamp_tx()).

Signed-off-by: Jason Xing <kernelxing@tencent.com>
Link: https://patch.msgid.link/20250510134812.48199-4-kerneljasonxing@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c

index a19b6f940bf340eef07580e366a2546dcb2d19ef..6612f9f4b9f50b3563610c3f98ef8f97b0dfe352 100644 (file)
@@ -4497,8 +4497,6 @@ static netdev_tx_t stmmac_tso_xmit(struct sk_buff *skb, struct net_device *dev)
        if (priv->sarc_type)
                stmmac_set_desc_sarc(priv, first, priv->sarc_type);
 
-       skb_tx_timestamp(skb);
-
        if (unlikely((skb_shinfo(skb)->tx_flags & SKBTX_HW_TSTAMP) &&
                     priv->hwts_tx_en)) {
                /* declare that device is doing timestamping */
@@ -4531,6 +4529,7 @@ static netdev_tx_t stmmac_tso_xmit(struct sk_buff *skb, struct net_device *dev)
        }
 
        netdev_tx_sent_queue(netdev_get_tx_queue(dev, queue), skb->len);
+       skb_tx_timestamp(skb);
 
        stmmac_flush_tx_descriptors(priv, queue);
        stmmac_tx_timer_arm(priv, queue);
@@ -4774,8 +4773,6 @@ static netdev_tx_t stmmac_xmit(struct sk_buff *skb, struct net_device *dev)
        if (priv->sarc_type)
                stmmac_set_desc_sarc(priv, first, priv->sarc_type);
 
-       skb_tx_timestamp(skb);
-
        /* Ready to fill the first descriptor and set the OWN bit w/o any
         * problems because all the descriptors are actually ready to be
         * passed to the DMA engine.
@@ -4822,7 +4819,7 @@ static netdev_tx_t stmmac_xmit(struct sk_buff *skb, struct net_device *dev)
        netdev_tx_sent_queue(netdev_get_tx_queue(dev, queue), skb->len);
 
        stmmac_enable_dma_transmission(priv, priv->ioaddr, queue);
-
+       skb_tx_timestamp(skb);
        stmmac_flush_tx_descriptors(priv, queue);
        stmmac_tx_timer_arm(priv, queue);