summaryrefslogtreecommitdiff
path: root/ring_tx.c
diff options
context:
space:
mode:
authorTobias Klauser <tklauser@distanz.ch>2014-05-09 15:46:38 +0200
committerTobias Klauser <tklauser@distanz.ch>2014-05-09 15:46:38 +0200
commit9a40de458b3884d9f526172110392501f075bd87 (patch)
treeff621d506b408a74a0ccea32e5f3f97b5ad0a210 /ring_tx.c
parent61a233a283171832a1ac5d580cf9487f9b7aec0a (diff)
ring: Merge common ring_{rx,tx} initialization into own function
Instead of having to perform the individual steps to initialize a ring and open coding them in multiple places, provide convenience functions to do all at once. This has the nice side effect of allowing to make most of these *_{rx,tx}_ring() functions static in their respective module. Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
Diffstat (limited to 'ring_tx.c')
-rw-r--r--ring_tx.c24
1 files changed, 13 insertions, 11 deletions
diff --git a/ring_tx.c b/ring_tx.c
index 3d69752..27afe8b 100644
--- a/ring_tx.c
+++ b/ring_tx.c
@@ -20,7 +20,7 @@
#include "ring_tx.h"
#include "built_in.h"
-void set_packet_loss_discard(int sock)
+static void set_packet_loss_discard(int sock)
{
int ret, discard = 1;
ret = setsockopt(sock, SOL_PACKET, PACKET_LOSS, (void *) &discard,
@@ -45,8 +45,8 @@ void destroy_tx_ring(int sock, struct ring *ring)
xfree(ring->frames);
}
-void setup_tx_ring_layout(int sock, struct ring *ring, size_t size,
- bool jumbo_support)
+static void setup_tx_ring_layout(int sock, struct ring *ring, size_t size,
+ bool jumbo_support)
{
fmemset(&ring->layout, 0, sizeof(ring->layout));
@@ -68,7 +68,7 @@ void setup_tx_ring_layout(int sock, struct ring *ring, size_t size,
ring_verify_layout(ring);
}
-void create_tx_ring(int sock, struct ring *ring, bool verbose)
+static void create_tx_ring(int sock, struct ring *ring, bool verbose)
{
int ret;
retry:
@@ -95,18 +95,20 @@ retry:
}
}
-void mmap_tx_ring(int sock, struct ring *ring)
-{
- mmap_ring_generic(sock, ring);
-}
-
-void alloc_tx_ring_frames(int sock __maybe_unused, struct ring *ring)
+static void alloc_tx_ring_frames(int sock __maybe_unused, struct ring *ring)
{
alloc_ring_frames_generic(ring, ring->layout.tp_frame_nr,
ring->layout.tp_frame_size);
}
-void bind_tx_ring(int sock, struct ring *ring, int ifindex)
+void ring_tx_setup(struct ring *ring, int sock, size_t size, int ifindex,
+ bool jumbo_support, bool verbose)
{
+ fmemset(ring, 0, sizeof(*ring));
+ set_packet_loss_discard(sock);
+ setup_tx_ring_layout(sock, ring, size, jumbo_support);
+ create_tx_ring(sock, ring, verbose);
+ mmap_ring_generic(sock, ring);
+ alloc_tx_ring_frames(sock, ring);
bind_ring_generic(sock, ring, ifindex, true);
}