diff options
author | Tobias Klauser <tklauser@distanz.ch> | 2014-05-09 15:46:38 +0200 |
---|---|---|
committer | Tobias Klauser <tklauser@distanz.ch> | 2014-05-09 15:46:38 +0200 |
commit | 9a40de458b3884d9f526172110392501f075bd87 (patch) | |
tree | ff621d506b408a74a0ccea32e5f3f97b5ad0a210 /ring_rx.c | |
parent | 61a233a283171832a1ac5d580cf9487f9b7aec0a (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_rx.c')
-rw-r--r-- | ring_rx.c | 23 |
1 files changed, 13 insertions, 10 deletions
@@ -41,8 +41,8 @@ void destroy_rx_ring(int sock, struct ring *ring) panic("Cannot destroy the RX_RING: %s!\n", strerror(errno)); } -void setup_rx_ring_layout(int sock, struct ring *ring, size_t size, - bool jumbo_support, bool v3) +static void setup_rx_ring_layout(int sock, struct ring *ring, size_t size, + bool jumbo_support, bool v3) { fmemset(&ring->layout, 0, sizeof(ring->layout)); @@ -77,7 +77,7 @@ void setup_rx_ring_layout(int sock, struct ring *ring, size_t size, ring_verify_layout(ring); } -void create_rx_ring(int sock, struct ring *ring, bool verbose) +static void create_rx_ring(int sock, struct ring *ring, bool verbose) { int ret; bool v3 = get_sockopt_tpacket(sock) == TPACKET_V3; @@ -111,12 +111,7 @@ retry: } } -void mmap_rx_ring(int sock, struct ring *ring) -{ - mmap_ring_generic(sock, ring); -} - -void alloc_rx_ring_frames(int sock, struct ring *ring) +static void alloc_rx_ring_frames(int sock, struct ring *ring) { int num; size_t size; @@ -133,9 +128,17 @@ void alloc_rx_ring_frames(int sock, struct ring *ring) alloc_ring_frames_generic(ring, num, size); } -void bind_rx_ring(int sock, struct ring *ring, int ifindex) +void ring_rx_setup(struct ring *ring, int sock, size_t size, int ifindex, + struct pollfd *poll, bool v3, bool jumbo_support, + bool verbose) { + fmemset(ring, 0, sizeof(*ring)); + setup_rx_ring_layout(sock, ring, size, jumbo_support, v3); + create_rx_ring(sock, ring, verbose); + mmap_ring_generic(sock, ring); + alloc_rx_ring_frames(sock, ring); bind_ring_generic(sock, ring, ifindex, false); + prepare_polling(sock, poll); } void sock_rx_net_stats(int sock, unsigned long seen) |