net: ena: Introduce total_tx_size field in ena_tx_buffer struct
authorDavid Arinzon <darinzon@amazon.com>
Mon, 1 Jan 2024 19:08:48 +0000 (19:08 +0000)
committerJakub Kicinski <kuba@kernel.org>
Thu, 4 Jan 2024 02:00:57 +0000 (18:00 -0800)
To avoid de-referencing skb or xdp_frame when we poll for TX completion
(where they might not be in the cache), save the total TX packet size in
the ena_tx_buffer object representing the packet.

Also the 'print_once' field's type was changed from u32 to u8 to allow
adding the 'total_tx_size' without changing the total size of the
struct.

Signed-off-by: Shay Agroskin <shayagr@amazon.com>
Signed-off-by: David Arinzon <darinzon@amazon.com>
Link: https://lore.kernel.org/r/20240101190855.18739-5-darinzon@amazon.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/amazon/ena/ena_netdev.c
drivers/net/ethernet/amazon/ena/ena_netdev.h

index b7f300b55fbb94205a1c252527e7426bc63f71f5..3c84259e06f9ac511352e1b71029ccc062c10dcc 100644 (file)
@@ -130,6 +130,7 @@ int ena_xmit_common(struct ena_adapter *adapter,
        u64_stats_update_end(&ring->syncp);
 
        tx_info->tx_descs = nb_hw_desc;
+       tx_info->total_tx_size = bytes;
        tx_info->last_jiffies = jiffies;
        tx_info->print_once = 0;
 
@@ -842,7 +843,7 @@ static int ena_clean_tx_irq(struct ena_ring *tx_ring, u32 budget)
                          "tx_poll: q %d skb %p completed\n", tx_ring->qid,
                          skb);
 
-               tx_bytes += skb->len;
+               tx_bytes += tx_info->total_tx_size;
                dev_kfree_skb(skb);
                tx_pkts++;
                total_done += tx_info->tx_descs;
index 78a4dee5a3c6b9fad1bc4cd3aff70a3b3e3ec3cf..d3fc03f2ff473d14ab59a57e706c2d1400bf9e1c 100644 (file)
@@ -145,12 +145,14 @@ struct ena_tx_buffer {
        /* num of buffers used by this skb */
        u32 num_of_bufs;
 
+       /* Total size of all buffers in bytes */
+       u32 total_tx_size;
 
        /* Indicate if bufs[0] map the linear data of the skb. */
        u8 map_linear_data;
 
        /* Used for detect missing tx packets to limit the number of prints */
-       u32 print_once;
+       u8 print_once;
        /* Save the last jiffies to detect missing tx packets
         *
         * sets to non zero value on ena_start_xmit and set to zero on