]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
net: mana: Set tx_packets to post gso processing packet count
authorShradha Gupta <shradhagupta@linux.microsoft.com>
Tue, 17 Jun 2025 11:33:41 +0000 (04:33 -0700)
committerDavid S. Miller <davem@davemloft.net>
Thu, 19 Jun 2025 22:53:14 +0000 (23:53 +0100)
Allow tx_packets and tx_bytes counter in the driver to represent
the packets transmitted post GSO processing.

Currently they are populated as bigger pre-GSO packets and bytes

Signed-off-by: Shradha Gupta <shradhagupta@linux.microsoft.com>
Reviewed-by: Haiyang Zhang <haiyangz@microsoft.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/microsoft/mana/mana_en.c

index 5aee7bda1504cdb7786bf30f8e5dbb8140ce9122..016fd808ccad4469585bc210d8f1235d8e1ac79e 100644 (file)
@@ -251,10 +251,10 @@ netdev_tx_t mana_start_xmit(struct sk_buff *skb, struct net_device *ndev)
        struct netdev_queue *net_txq;
        struct mana_stats_tx *tx_stats;
        struct gdma_queue *gdma_sq;
+       int err, len, num_gso_seg;
        unsigned int csum_type;
        struct mana_txq *txq;
        struct mana_cq *cq;
-       int err, len;
 
        if (unlikely(!apc->port_is_up))
                goto tx_drop;
@@ -407,6 +407,7 @@ netdev_tx_t mana_start_xmit(struct sk_buff *skb, struct net_device *ndev)
        skb_queue_tail(&txq->pending_skbs, skb);
 
        len = skb->len;
+       num_gso_seg = skb_is_gso(skb) ? skb_shinfo(skb)->gso_segs : 1;
        net_txq = netdev_get_tx_queue(ndev, txq_idx);
 
        err = mana_gd_post_work_request(gdma_sq, &pkg.wqe_req,
@@ -431,10 +432,13 @@ netdev_tx_t mana_start_xmit(struct sk_buff *skb, struct net_device *ndev)
        /* skb may be freed after mana_gd_post_work_request. Do not use it. */
        skb = NULL;
 
+       /* Populated the packet and bytes counters based on post GSO packet
+        * calculations
+        */
        tx_stats = &txq->stats;
        u64_stats_update_begin(&tx_stats->syncp);
-       tx_stats->packets++;
-       tx_stats->bytes += len;
+       tx_stats->packets += num_gso_seg;
+       tx_stats->bytes += len + ((num_gso_seg - 1) * gso_hs);
        u64_stats_update_end(&tx_stats->syncp);
 
 tx_busy: