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 /trafgen.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 'trafgen.c')
-rw-r--r-- | trafgen.c | 13 |
1 files changed, 2 insertions, 11 deletions
@@ -592,25 +592,16 @@ static void xmit_fastpath_or_die(struct ctx *ctx, int cpu, unsigned long orig_nu uint8_t *out = NULL; unsigned int it = 0; unsigned long num = 1, i = 0; - size_t size; + size_t size = ring_size(ctx->device, ctx->reserve_size); struct ring tx_ring; struct frame_map *hdr; struct timeval start, end, diff; struct packet_dyn *pktd; unsigned long long tx_bytes = 0, tx_packets = 0; - fmemset(&tx_ring, 0, sizeof(tx_ring)); - - size = ring_size(ctx->device, ctx->reserve_size); - set_sock_prio(sock, 512); - set_packet_loss_discard(sock); - setup_tx_ring_layout(sock, &tx_ring, size, ctx->jumbo_support); - create_tx_ring(sock, &tx_ring, ctx->verbose); - mmap_tx_ring(sock, &tx_ring); - alloc_tx_ring_frames(sock, &tx_ring); - bind_tx_ring(sock, &tx_ring, ifindex); + ring_tx_setup(&tx_ring, sock, size, ifindex, ctx->jumbo_support, ctx->verbose); drop_privileges(ctx->enforce, ctx->uid, ctx->gid); |