summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYasufumi Ogawa <yasufum.o@gmail.com>2019-09-12 19:48:18 +0900
committerYasufumi Ogawa <yasufum.o@gmail.com>2019-10-04 22:06:14 +0900
commita9f6ade5eaf67ba3105b7806967819184b075618 (patch)
tree87e5ddc9744ce7af071e810ecf6cd052f9508657
parent60dea60375559538b5180f34e535cb854972d80e (diff)
downloadspp-a9f6ade5eaf67ba3105b7806967819184b075618.zip
spp-a9f6ade5eaf67ba3105b7806967819184b075618.tar.gz
spp-a9f6ade5eaf67ba3105b7806967819184b075618.tar.xz
shared: rename struct for ring latency stats
Struct `spp_ringlatencystats_ring_latency_stats` is for containing stats as a histgram like data. It is only used in `latency_stats.c` and its header locally, so no need to such a long name. This update is to rename it to `ring_latency_stats_t`. This update also includes revising name of vars and comments. Signed-off-by: Yasufumi Ogawa <yasufum.o@gmail.com>
-rw-r--r--src/shared/secondary/spp_worker_th/latency_stats.c28
-rw-r--r--src/shared/secondary/spp_worker_th/latency_stats.h22
2 files changed, 26 insertions, 24 deletions
diff --git a/src/shared/secondary/spp_worker_th/latency_stats.c b/src/shared/secondary/spp_worker_th/latency_stats.c
index 036a360..0a5e5a7 100644
--- a/src/shared/secondary/spp_worker_th/latency_stats.c
+++ b/src/shared/secondary/spp_worker_th/latency_stats.c
@@ -27,10 +27,9 @@
/** ring latency statistics information */
struct ring_latency_stats_info {
- uint64_t timer_tsc; /**< sampling interval counter */
- uint64_t prev_tsc; /**< previous time */
- struct spp_ringlatencystats_ring_latency_stats stats;
- /**< ring latency statistics list */
+ uint64_t timer_tsc; /**< sampling interval */
+ uint64_t prev_tsc; /**< previous time */
+ struct ring_latency_stats_t stats; /**< list of stats */
};
/** sampling interval */
@@ -133,16 +132,13 @@ sppwk_calc_ring_latency(int ring_id,
if (likely(pkts[i]->timestamp == 0))
continue;
- /* when mbuf::timestamp is not zero */
- /* calculate latency */
+ /* calc latency if mbuf `timestamp` is non-zero. */
latency = (uint64_t)floor((now - pkts[i]->timestamp) /
cycles_per_ns());
- if (likely(latency < SPP_RINGLATENCYSTATS_STATS_SLOT_COUNT-1))
- stats_info->stats.slot[latency]++;
+ if (likely(latency < TOTAL_LATENCY_ENT-1))
+ stats_info->stats.distr[latency]++;
else
- stats_info->stats.slot[
- SPP_RINGLATENCYSTATS_STATS_SLOT_COUNT
- -1]++;
+ stats_info->stats.distr[TOTAL_LATENCY_ENT-1]++;
}
}
@@ -154,12 +150,12 @@ spp_ringlatencystats_get_count(void)
void
spp_ringlatencystats_get_stats(int ring_id,
- struct spp_ringlatencystats_ring_latency_stats *stats)
+ struct ring_latency_stats_t *stats)
{
struct ring_latency_stats_info *stats_info = &g_stats_info[ring_id];
rte_memcpy(stats, &stats_info->stats,
- sizeof(struct spp_ringlatencystats_ring_latency_stats));
+ sizeof(struct ring_latency_stats_t));
}
/* Print statistics of time for packet processing in ring interface */
@@ -172,7 +168,7 @@ print_ring_latency_stats(struct iface_info *if_info)
printf("%s%s", clr, topLeft);
int ring_cnt, stats_cnt;
- struct spp_ringlatencystats_ring_latency_stats stats[RTE_MAX_ETHPORTS];
+ struct ring_latency_stats_t stats[RTE_MAX_ETHPORTS];
memset(&stats, 0x00, sizeof(stats));
printf("RING Latency\n");
@@ -186,14 +182,14 @@ print_ring_latency_stats(struct iface_info *if_info)
}
printf("\n");
- for (stats_cnt = 0; stats_cnt < SPP_RINGLATENCYSTATS_STATS_SLOT_COUNT;
+ for (stats_cnt = 0; stats_cnt < TOTAL_LATENCY_ENT;
stats_cnt++) {
printf("%3dns", stats_cnt);
for (ring_cnt = 0; ring_cnt < RTE_MAX_ETHPORTS; ring_cnt++) {
if (if_info->ring[ring_cnt].iface_type == UNDEF)
continue;
- printf(", 0x%-16lx", stats[ring_cnt].slot[stats_cnt]);
+ printf(", 0x%-16lx", stats[ring_cnt].distr[stats_cnt]);
}
printf("\n");
}
diff --git a/src/shared/secondary/spp_worker_th/latency_stats.h b/src/shared/secondary/spp_worker_th/latency_stats.h
index 4a7abb4..de9ee5d 100644
--- a/src/shared/secondary/spp_worker_th/latency_stats.h
+++ b/src/shared/secondary/spp_worker_th/latency_stats.h
@@ -9,19 +9,25 @@
* @file
* SPP RING latency statistics
*
- * Measure the latency through ring-PMD.
+ * Util functions for measuring latency of ring-PMD.
*/
#include <rte_mbuf.h>
#include "cmd_utils.h"
-/** number of slots to save latency. 0ns~99ns and 100ns over */
-#define SPP_RINGLATENCYSTATS_STATS_SLOT_COUNT 101
+/**
+ * Statistics of latency of ring is counted with histgram like data structure.
+ * To count frequency of each of time in nano sec, this data is implemented as
+ * an array in which frequency counts of 1-100[ns] are contained. If the
+ * latency is larger than 100[ns], it is added to the last entry. It means
+ * this array has 101 entries, 100 entries for 1-100[ns] and 1 entry for over
+ * 100[ns].
+ */
+#define TOTAL_LATENCY_ENT 101
-/** ring latency statistics */
-struct spp_ringlatencystats_ring_latency_stats {
- /** slots to save latency */
- uint64_t slot[SPP_RINGLATENCYSTATS_STATS_SLOT_COUNT];
+/** statistics of latency of ring */
+struct ring_latency_stats_t {
+ uint64_t distr[TOTAL_LATENCY_ENT]; /* distribution of time */
};
@@ -88,7 +94,7 @@ int spp_ringlatencystats_get_count(void);
* The statistics values.
*/
void spp_ringlatencystats_get_stats(int ring_id,
- struct spp_ringlatencystats_ring_latency_stats *stats);
+ struct ring_latency_stats_t *stats);
/* Print statistics of time for packet processing in ring interface */
void print_ring_latency_stats(struct iface_info *if_info);