From 4d51aeb5a85d3dfb4804368114f91d9da5b1a08b Mon Sep 17 00:00:00 2001 From: Emmanuel Roullit Date: Tue, 20 Sep 2011 17:12:11 +0200 Subject: [PATCH] Bumped the size of each frame to 16384 bytes to handle Jumbo frames properly. --- src/rx_ring.c | 11 +++++------ src/tx_ring.c | 11 +++++------ 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/src/rx_ring.c b/src/rx_ring.c index f99b7776..1a4f482d 100644 --- a/src/rx_ring.c +++ b/src/rx_ring.c @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include @@ -33,18 +34,16 @@ void destroy_rx_ring(int sock, struct ring *ring) void setup_rx_ring_layout(int sock, struct ring *ring, unsigned int size) { - /* - * FIXME: We currently have 2048 Byte per frame. Frames need to - * fit exactly into blocks. Blocks can only be a multiple of the - * systems page size. What do we do with jumbo frames? - */ memset(&ring->layout, 0, sizeof(ring->layout)); ring->layout.tp_block_size = getpagesize() << 2; - ring->layout.tp_frame_size = TPACKET_ALIGNMENT << 7; + ring->layout.tp_frame_size = TPACKET_ALIGNMENT << 10; ring->layout.tp_block_nr = size / ring->layout.tp_block_size; ring->layout.tp_frame_nr = ring->layout.tp_block_size / ring->layout.tp_frame_size * ring->layout.tp_block_nr; + + assert(ring->layout.tp_block_size >= ring->layout.tp_frame_size); + assert((ring->layout.tp_block_size % ring->layout.tp_frame_size) == 0); } void create_rx_ring(int sock, struct ring *ring) diff --git a/src/tx_ring.c b/src/tx_ring.c index fa9254d2..906b059c 100644 --- a/src/tx_ring.c +++ b/src/tx_ring.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -46,18 +47,16 @@ void destroy_tx_ring(int sock, struct ring *ring) void setup_tx_ring_layout(int sock, struct ring *ring, unsigned int size) { - /* - * FIXME: We currently have 2048 Byte per frame. Frames need to - * fit exactly into blocks. Blocks can only be a multiple of the - * systems page size. What do we do with jumbo frames? - */ memset(&ring->layout, 0, sizeof(ring->layout)); ring->layout.tp_block_size = getpagesize() << 2; - ring->layout.tp_frame_size = TPACKET_ALIGNMENT << 7; + ring->layout.tp_frame_size = TPACKET_ALIGNMENT << 10; ring->layout.tp_block_nr = size / ring->layout.tp_block_size; ring->layout.tp_frame_nr = ring->layout.tp_block_size / ring->layout.tp_frame_size * ring->layout.tp_block_nr; + + assert(ring->layout.tp_block_size >= ring->layout.tp_frame_size); + assert((ring->layout.tp_block_size % ring->layout.tp_frame_size) == 0); } void create_tx_ring(int sock, struct ring *ring) -- 2.11.4.GIT