DPDK patches and discussions
 help / color / mirror / Atom feed
From: "Ananyev, Konstantin" <konstantin.ananyev@intel.com>
To: Anoob Joseph <anoobj@marvell.com>,
	Akhil Goyal <akhil.goyal@nxp.com>,
	"Nicolau, Radu" <radu.nicolau@intel.com>
Cc: Narayana Prasad <pathreya@marvell.com>, "dev@dpdk.org" <dev@dpdk.org>
Subject: Re: [dpdk-dev] [PATCH v4] examples/ipsec-secgw: add per core packet stats
Date: Thu, 14 May 2020 13:47:43 +0000	[thread overview]
Message-ID: <BYAPR11MB3301D9EFB2C0B4CBC048BC459ABC0@BYAPR11MB3301.namprd11.prod.outlook.com> (raw)
In-Reply-To: <1589391919-20388-1-git-send-email-anoobj@marvell.com>


> 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@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@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 */
> +

  reply	other threads:[~2020-05-14 13:47 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-21  4:50 [dpdk-dev] [PATCH] " Anoob Joseph
2020-04-23 13:07 ` [dpdk-dev] [PATCH v2] " Anoob Joseph
2020-04-24 11:14   ` Ananyev, Konstantin
2020-05-02 18:43     ` Anoob Joseph
2020-05-05 10:45       ` Ananyev, Konstantin
2020-05-06 12:47   ` [dpdk-dev] [PATCH v3] " Anoob Joseph
2020-05-07 16:12     ` Ananyev, Konstantin
2020-05-12 12:14       ` Anoob Joseph
2020-05-13 12:42         ` Ananyev, Konstantin
2020-05-14  4:11           ` Anoob Joseph
2020-05-08  8:08     ` Ananyev, Konstantin
2020-05-12 12:16       ` Anoob Joseph
2020-05-13 12:12         ` Ananyev, Konstantin
2020-05-13 17:45     ` [dpdk-dev] [PATCH v4] " Anoob Joseph
2020-05-14 13:47       ` Ananyev, Konstantin [this message]
2020-05-17 14:39         ` Akhil Goyal
2020-05-18  3:42           ` Anoob Joseph
2020-05-18  7:06             ` Akhil Goyal
2020-07-01 19:21               ` Akhil Goyal

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=BYAPR11MB3301D9EFB2C0B4CBC048BC459ABC0@BYAPR11MB3301.namprd11.prod.outlook.com \
    --to=konstantin.ananyev@intel.com \
    --cc=akhil.goyal@nxp.com \
    --cc=anoobj@marvell.com \
    --cc=dev@dpdk.org \
    --cc=pathreya@marvell.com \
    --cc=radu.nicolau@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).