diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-30 03:25:49 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-30 03:25:49 +0000 |
commit | 15c210fff53f4ce7057339a77f93ca955ee5cd46 (patch) | |
tree | 856918348b7a9cf74565389191206fb18f11c6d8 /src/packet_ring.c | |
parent | Adding debian version 2.1.9+dfsg-1. (diff) | |
download | iperf-15c210fff53f4ce7057339a77f93ca955ee5cd46.tar.xz iperf-15c210fff53f4ce7057339a77f93ca955ee5cd46.zip |
Merging upstream version 2.2.0+dfsg.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/packet_ring.c')
-rw-r--r-- | src/packet_ring.c | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/src/packet_ring.c b/src/packet_ring.c index 93e7578..97a25a5 100644 --- a/src/packet_ring.c +++ b/src/packet_ring.c @@ -55,6 +55,11 @@ static int totalpacketringcount = 0; Mutex packetringdebug_mutex; #endif +// +// Initialize a packet ring between a traffic thread and the reporter thread +// Note: enable dequeue events will have the dequeue return null on an event relevant to +// the reporter thread moving to the next ring. This is needed for proper summing +// struct PacketRing * packetring_init (int count, struct Condition *awake_consumer, struct Condition *awake_producer) { assert(awake_consumer != NULL); struct PacketRing *pr = NULL; @@ -78,6 +83,8 @@ struct PacketRing * packetring_init (int count, struct Condition *awake_consumer pr->mutex_enable=1; pr->consumerdone = 0; pr->awaitcounter = 0; + pr->uplevel = HIGH; + pr->downlevel = HIGH; #ifdef HAVE_THREAD_DEBUG Mutex_Lock(&packetringdebug_mutex); totalpacketringcount++; @@ -103,7 +110,7 @@ inline void packetring_enqueue (struct PacketRing *pr, struct ReportStruct *meta { struct timeval now; static struct timeval prev={0, 0}; - gettimeofday( &now, NULL ); + TimeGetNow(now); if (!prev.tv_sec || (TimeDifference(now, prev) > 1.0)) { prev = now; thread_debug( "Not good, traffic's packet ring %p stalled per %p", (void *)pr, (void *)&pr->awake_producer); @@ -127,16 +134,18 @@ inline void packetring_enqueue (struct PacketRing *pr, struct ReportStruct *meta inline struct ReportStruct *packetring_dequeue (struct PacketRing *pr) { struct ReportStruct *packet = NULL; - if (pr->producer == pr->consumer) + if (pr->producer == pr->consumer) { return NULL; - + } int readindex; if ((pr->consumer + 1) == pr->maxcount) readindex = 0; else readindex = (pr->consumer + 1); + packet = (pr->data + readindex); - // advance the consumer pointer last + // See if the dequeue needs to detect an event so the reporter + // can move to the next packet ring pr->consumer = readindex; if (pr->mutex_enable) { // Signal the traffic thread assigned to this ring @@ -152,6 +161,10 @@ inline struct ReportStruct *packetring_dequeue (struct PacketRing *pr) { return packet; } +inline enum edgeLevel toggleLevel(enum edgeLevel level) { + return ((level == HIGH) ? LOW : HIGH); +} + inline void enqueue_ackring (struct PacketRing *pr, struct ReportStruct *metapacket) { packetring_enqueue(pr, metapacket); // Keep the latency low by signaling the consumer thread |