summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ring.h8
-rw-r--r--ring_rx.c5
-rw-r--r--ring_tx.c5
3 files changed, 10 insertions, 8 deletions
diff --git a/ring.h b/ring.h
index 6517a80..4153b9c 100644
--- a/ring.h
+++ b/ring.h
@@ -145,6 +145,14 @@ static inline void ring_verify_layout(struct ring *ring)
bug_on((ring->layout.tp_block_size % RUNTIME_PAGE_SIZE) != 0);
}
+static inline void shrink_ring_layout_generic(struct ring *ring)
+{
+ ring->layout.tp_block_nr >>= 1;
+ ring->layout.tp_frame_nr = ring->layout.tp_block_size /
+ ring->layout.tp_frame_size *
+ ring->layout.tp_block_nr;
+}
+
static inline void tpacket_hdr_clone(struct tpacket2_hdr *thdrd,
struct tpacket2_hdr *thdrs)
{
diff --git a/ring_rx.c b/ring_rx.c
index 8ddc44b..9c63dbd 100644
--- a/ring_rx.c
+++ b/ring_rx.c
@@ -165,10 +165,7 @@ retry:
layout_size);
if (errno == ENOMEM && ring->layout.tp_block_nr > 1) {
- ring->layout.tp_block_nr >>= 1;
- ring->layout.tp_frame_nr = ring->layout.tp_block_size /
- ring->layout.tp_frame_size *
- ring->layout.tp_block_nr;
+ shrink_ring_layout_generic(ring);
goto retry;
}
if (ret < 0)
diff --git a/ring_tx.c b/ring_tx.c
index aee1307..b8ce446 100644
--- a/ring_tx.c
+++ b/ring_tx.c
@@ -64,10 +64,7 @@ retry:
sizeof(ring->layout));
if (errno == ENOMEM && ring->layout.tp_block_nr > 1) {
- ring->layout.tp_block_nr >>= 1;
- ring->layout.tp_frame_nr = ring->layout.tp_block_size /
- ring->layout.tp_frame_size *
- ring->layout.tp_block_nr;
+ shrink_ring_layout_generic(ring);
goto retry;
}