diff options
author | Daniel Borkmann <dborkman@redhat.com> | 2013-05-31 12:11:09 +0200 |
---|---|---|
committer | Daniel Borkmann <dborkman@redhat.com> | 2013-05-31 12:11:09 +0200 |
commit | cacb34f95fb7937e81b1fe8add7b5dca91e3a4c5 (patch) | |
tree | 607d72816c4d810050996f37f2acef583757cd8b /ring.c | |
parent | 0f765f49ac231d99f493f00c0f0986fbeff2615d (diff) |
ring: setup frame structure for v2/v3 in a generic way
Prepare TPACKET_V3 for allowing to transparently setting up the
frame structure such that we do not need to change much in the
netsniff-ng/trafgen code.
Signed-off-by: Daniel Borkmann <dborkman@redhat.com>
Diffstat (limited to 'ring.c')
-rw-r--r-- | ring.c | 11 |
1 files changed, 5 insertions, 6 deletions
@@ -27,18 +27,17 @@ void mmap_ring_generic(int sock, struct ring *ring) panic("Cannot mmap {TX,RX}_RING!\n"); } -void alloc_ring_frames_generic(struct ring *ring) +void alloc_ring_frames_generic(struct ring *ring, int num, size_t size) { int i; - size_t len = ring->layout.tp_frame_nr * sizeof(*ring->frames); + size_t len = num * sizeof(*ring->frames); ring->frames = xmalloc_aligned(len, CO_CACHE_LINE_SIZE); fmemset(ring->frames, 0, len); - for (i = 0; i < ring->layout.tp_frame_nr; ++i) { - ring->frames[i].iov_len = ring->layout.tp_frame_size; - ring->frames[i].iov_base = ring->mm_space + - (i * ring->layout.tp_frame_size); + for (i = 0; i < num; ++i) { + ring->frames[i].iov_len = size; + ring->frames[i].iov_base = ring->mm_space + (i * size); } } |