[dpdk-dev] [PATCH v4] examples/ipsec-secgw: add per core packet stats
Ananyev, Konstantin
konstantin.ananyev at intel.com
Thu May 14 15:47:43 CEST 2020
> Adding per core packet handling stats to analyze traffic distribution
> when multiple cores are engaged.
>
> Since aggregating the packet stats across cores would affect
> performance, keeping the feature disabled using compile time flags.
>
> Signed-off-by: Anoob Joseph <anoobj at marvell.com>
> ---
> v4:
> * Moved print stats routine to control thread
> * Added stats for rx/tx pkts per call
> * Replaced free_pkt(m) with free_pkts(&m, 1)
>
> v3:
> * Added wrapper functions for updating rx, tx & dropped counts
> * Updated free_pkts() so that stats is updated internally
> * Introduced similar free_pkt() function which updates stats and frees the packet
> * Moved all inline functions and macros to ipsec-secgw.h
> * Made STATS_INTERVAL macro to control the interval of the stats update.
> STATS_INTERVAL = 0 would disable the feature.
>
> v2:
> * Added lookup failure cases to drop count
>
> examples/ipsec-secgw/ipsec-secgw.c | 114 ++++++++++++++++++++++++++++-------
> examples/ipsec-secgw/ipsec-secgw.h | 66 ++++++++++++++++++++
> examples/ipsec-secgw/ipsec.c | 20 +++---
> examples/ipsec-secgw/ipsec_process.c | 11 +---
> 4 files changed, 170 insertions(+), 41 deletions(-)
>
> diff --git a/examples/ipsec-secgw/ipsec-secgw.c b/examples/ipsec-secgw/ipsec-secgw.c
> index f777ce2..d2b5b2c 100644
> --- a/examples/ipsec-secgw/ipsec-secgw.c
> +++ b/examples/ipsec-secgw/ipsec-secgw.c
> @@ -47,6 +47,7 @@
> #include <rte_eventdev.h>
> #include <rte_ip.h>
> #include <rte_ip_frag.h>
> +#include <rte_alarm.h>
>
> #include "event_helper.h"
> #include "ipsec.h"
> @@ -287,6 +288,70 @@ adjust_ipv6_pktlen(struct rte_mbuf *m, const struct rte_ipv6_hdr *iph,
> }
> }
>
> +#if (STATS_INTERVAL > 0)
> +
> +/* Print out statistics on packet distribution */
> +static void
> +print_stats_cb(__rte_unused void *param)
> +{
> + uint64_t total_packets_dropped, total_packets_tx, total_packets_rx;
> + float burst_percent, rx_per_call, tx_per_call;
> + unsigned int coreid;
> +
> + total_packets_dropped = 0;
> + total_packets_tx = 0;
> + total_packets_rx = 0;
> +
> + const char clr[] = { 27, '[', '2', 'J', '\0' };
> + const char topLeft[] = { 27, '[', '1', ';', '1', 'H', '\0' };
> +
> + /* Clear screen and move to top left */
> + printf("%s%s", clr, topLeft);
> +
> + printf("\nCore statistics ====================================");
> +
> + for (coreid = 0; coreid < RTE_MAX_LCORE; coreid++) {
> + /* skip disabled cores */
> + if (rte_lcore_is_enabled(coreid) == 0)
> + continue;
> + burst_percent = (float)(core_statistics[coreid].burst_rx * 100)/
> + core_statistics[coreid].rx;
> + rx_per_call = (float)(core_statistics[coreid].rx)/
> + core_statistics[coreid].rx_call;
As a nit - probably better to use double, and check that divisors are not zero.
Apart from that - LGTM.
Acked-by: Konstantin Ananyev <konstantin.ananyev at intel.com>
> + tx_per_call = (float)(core_statistics[coreid].tx)/
> + core_statistics[coreid].tx_call;
> + printf("\nStatistics for core %u ------------------------------"
> + "\nPackets received: %20"PRIu64
> + "\nPackets sent: %24"PRIu64
> + "\nPackets dropped: %21"PRIu64
> + "\nBurst percent: %23.2f"
> + "\nPackets per Rx call: %17.2f"
> + "\nPackets per Tx call: %17.2f",
> + coreid,
> + core_statistics[coreid].rx,
> + core_statistics[coreid].tx,
> + core_statistics[coreid].dropped,
> + burst_percent,
> + rx_per_call,
> + tx_per_call);
> +
> + total_packets_dropped += core_statistics[coreid].dropped;
> + total_packets_tx += core_statistics[coreid].tx;
> + total_packets_rx += core_statistics[coreid].rx;
> + }
> + printf("\nAggregate statistics ==============================="
> + "\nTotal packets received: %14"PRIu64
> + "\nTotal packets sent: %18"PRIu64
> + "\nTotal packets dropped: %15"PRIu64,
> + total_packets_rx,
> + total_packets_tx,
> + total_packets_dropped);
> + printf("\n====================================================\n");
> +
> + rte_eal_alarm_set(STATS_INTERVAL * US_PER_S, print_stats_cb, NULL);
> +}
> +#endif /* STATS_INTERVAL */
> +
More information about the dev
mailing list