aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/drivers/net/ethernet/amazon/ena/ena_netdev.h
diff options
context:
space:
mode:
authorDavid Arinzon <darinzon@amazon.com>2023-06-12 12:14:48 +0000
committerJakub Kicinski <kuba@kernel.org>2023-06-15 22:45:47 -0700
commitf7d625adeb7bc6a9ec83d32d9615889969d64484 (patch)
tree6771c7b35455f5bde6a5ee4c43aa9c5627b2dba6 /drivers/net/ethernet/amazon/ena/ena_netdev.h
parentnet: ioctl: Use kernel memory on protocol ioctl callbacks (diff)
downloadwireguard-linux-f7d625adeb7bc6a9ec83d32d9615889969d64484.tar.xz
wireguard-linux-f7d625adeb7bc6a9ec83d32d9615889969d64484.zip
net: ena: Add dynamic recycling mechanism for rx buffers
The current implementation allocates page-sized rx buffers. As traffic may consist of different types and sizes of packets, in various cases, buffers are not fully used. This change (Dynamic RX Buffers - DRB) uses part of the allocated rx page needed for the incoming packet, and returns the rest of the unused page to be used again as an rx buffer for future packets. A threshold of 2K for unused space has been set in order to declare whether the remainder of the page can be reused again as an rx buffer. As a page may be reused, dma_sync_single_for_cpu() is added in order to sync the memory to the CPU side after it was owned by the HW. In addition, when the rx page can no longer be reused, it is being unmapped using dma_page_unmap(), which implicitly syncs and then unmaps the entire page. In case the kernel still handles the skbs pointing to the previous buffers from that rx page, it may access garbage pointers, caused by the implicit sync overwriting them. The implicit dma sync is removed by replacing dma_page_unmap() with dma_unmap_page_attrs() with DMA_ATTR_SKIP_CPU_SYNC flag. The functionality is disabled for XDP traffic to avoid handling several descriptors per packet. Signed-off-by: Arthur Kiyanovski <akiyano@amazon.com> Signed-off-by: Shay Agroskin <shayagr@amazon.com> Signed-off-by: David Arinzon <darinzon@amazon.com> Link: https://lore.kernel.org/r/20230612121448.28829-1-darinzon@amazon.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Diffstat (limited to 'drivers/net/ethernet/amazon/ena/ena_netdev.h')
-rw-r--r--drivers/net/ethernet/amazon/ena/ena_netdev.h4
1 files changed, 4 insertions, 0 deletions
diff --git a/drivers/net/ethernet/amazon/ena/ena_netdev.h b/drivers/net/ethernet/amazon/ena/ena_netdev.h
index 5a0d4ee76172..248b715b4d68 100644
--- a/drivers/net/ethernet/amazon/ena/ena_netdev.h
+++ b/drivers/net/ethernet/amazon/ena/ena_netdev.h
@@ -51,6 +51,8 @@
#define ENA_DEFAULT_RING_SIZE (1024)
#define ENA_MIN_RING_SIZE (256)
+#define ENA_MIN_RX_BUF_SIZE (2048)
+
#define ENA_MIN_NUM_IO_QUEUES (1)
#define ENA_TX_WAKEUP_THRESH (MAX_SKB_FRAGS + 2)
@@ -175,7 +177,9 @@ struct ena_tx_buffer {
struct ena_rx_buffer {
struct sk_buff *skb;
struct page *page;
+ dma_addr_t dma_addr;
u32 page_offset;
+ u32 buf_offset;
struct ena_com_buf ena_buf;
} ____cacheline_aligned;