Soft Patch Panel
 help / color / mirror / Atom feed
From: x-fn-spp-ml@ntt-tx.co.jp
To: spp@dpdk.org, yasufum.o@gmail.com
Subject: [spp] [PATCH 2/5] shared: remove ringlatency stats functionality
Date: Mon, 22 Jun 2020 10:18:51 +0900	[thread overview]
Message-ID: <20200622011854.8059-3-x-fn-spp-ml@ntt-tx.co.jp> (raw)
In-Reply-To: <20200622011854.8059-1-x-fn-spp-ml@ntt-tx.co.jp>

From: Hideyuki Yamashita <yamashita.hideyuki@ntt-tx.co.jp>

This patch tries to remove ringlatency stats functionality.

Signed-off-by: Hideyuki Yamashita <yamashita.hideyuki@ntt-tx.co.jp>
Signed-off-by: Naoki Takada <ntakada14@gmail.com>
---
 .../secondary/spp_worker_th/cmd_utils.h       |   3 -
 .../secondary/spp_worker_th/latency_stats.c   | 240 ------------------
 .../secondary/spp_worker_th/latency_stats.h   | 167 ------------
 .../secondary/spp_worker_th/port_capability.c |  47 ----
 4 files changed, 457 deletions(-)
 delete mode 100644 src/shared/secondary/spp_worker_th/latency_stats.c
 delete mode 100644 src/shared/secondary/spp_worker_th/latency_stats.h

diff --git a/src/shared/secondary/spp_worker_th/cmd_utils.h b/src/shared/secondary/spp_worker_th/cmd_utils.h
index eda55c6..3c4bec9 100644
--- a/src/shared/secondary/spp_worker_th/cmd_utils.h
+++ b/src/shared/secondary/spp_worker_th/cmd_utils.h
@@ -51,9 +51,6 @@
  */
 #define CLS_DUMMY_ADDR_STR "00:00:00:00:00:01"
 
-/* Sampling interval timer for latency evaluation */
-#define SPP_RING_LATENCY_STATS_SAMPLING_INTERVAL 1000000
-
 /**
  * TODO(Yamashita) change type names.
  *  "merge" -> "merger", "forward" -> "forwarder".
diff --git a/src/shared/secondary/spp_worker_th/latency_stats.c b/src/shared/secondary/spp_worker_th/latency_stats.c
deleted file mode 100644
index d43f6a8..0000000
--- a/src/shared/secondary/spp_worker_th/latency_stats.c
+++ /dev/null
@@ -1,240 +0,0 @@
-/* SPDX-License-Identifier: BSD-3-Clause
- * Copyright(c) 2017-2018 Nippon Telegraph and Telephone Corporation
- */
-
-#include <unistd.h>
-#include <sys/types.h>
-#include <stdio.h>
-#include <stddef.h>
-#include <math.h>
-
-#include <rte_mbuf.h>
-#include <rte_log.h>
-#include <rte_cycles.h>
-#include <rte_malloc.h>
-#include <rte_memcpy.h>
-
-#include "latency_stats.h"
-#include "cmd_utils.h"
-#include "port_capability.h"
-#include "../return_codes.h"
-
-#define NS_PER_SEC 1E9
-
-#define RTE_LOGTYPE_SPP_RING_LATENCY_STATS RTE_LOGTYPE_USER1
-
-#ifdef SPP_RINGLATENCYSTATS_ENABLE
-
-/** ring latency statistics information */
-struct ring_latency_stats_info {
-	uint64_t timer_tsc;  /**< sampling interval */
-	uint64_t prev_tsc;   /**< previous time */
-	struct ring_latency_stats_t stats;  /**< list of stats */
-};
-
-/** sampling interval */
-static uint64_t g_samp_intvl;
-
-/** ring latency statistics information instance */
-static struct ring_latency_stats_info *g_stats_info;
-
-/** number of ring latency statistics */
-static uint16_t g_stats_count;
-
-/* clock cycles per nano second */
-static inline uint64_t
-cycles_per_ns(void)
-{
-	return rte_get_timer_hz() / NS_PER_SEC;
-}
-
-/**
- * TODO(Hideyuki Yamashita) This function has a fatal bug in rte_zmalloc()
- * for `g_stats_info` and should be fixed. rte_zmalloc() returns NULL for
- * unknow reason.
- */
-int
-sppwk_init_ring_latency_stats(uint64_t samp_intvl, uint16_t stats_count)
-{
-	/* allocate memory for ring latency statistics information */
-	g_stats_info = rte_zmalloc(
-			"global ring_latency_stats_info",
-			sizeof(struct ring_latency_stats_info) * stats_count,
-			0);
-	if (unlikely(g_stats_info == NULL)) {
-		RTE_LOG(ERR, SPP_RING_LATENCY_STATS, "Cannot allocate memory "
-				"for ring latency stats info\n");
-		return SPPWK_RET_NG;
-	}
-
-	/* store global information for ring latency statistics */
-	g_samp_intvl = samp_intvl * cycles_per_ns();
-	g_stats_count = stats_count;
-
-	RTE_LOG(DEBUG, SPP_RING_LATENCY_STATS,
-			"g_samp_intvl=%lu, g_stats_count=%hu, "
-			"cpns=%lu, NS_PER_SEC=%f\n",
-			g_samp_intvl, g_stats_count,
-			cycles_per_ns(), NS_PER_SEC);
-
-	return SPPWK_RET_OK;
-}
-
-void
-sppwk_clean_ring_latency_stats(void)
-{
-	/* free memory for ring latency statistics information */
-	if (likely(g_stats_info != NULL)) {
-		rte_free(g_stats_info);
-		g_stats_count = 0;
-	}
-}
-
-void
-sppwk_add_ring_latency_time(int ring_id,
-		struct rte_mbuf **pkts, uint16_t nb_pkts)
-{
-	unsigned int i;
-	uint64_t diff_tsc, now;
-	struct ring_latency_stats_info *stats_info = &g_stats_info[ring_id];
-
-	for (i = 0; i < nb_pkts; i++) {
-
-		/* get tsc now */
-		now = rte_rdtsc();
-
-		/* calculate difference from the previous processing time */
-		diff_tsc = now - stats_info->prev_tsc;
-		stats_info->timer_tsc += diff_tsc;
-
-		/* set tsc to mbuf timestamp if it is over sampling interval. */
-		if (unlikely(stats_info->timer_tsc >= g_samp_intvl)) {
-			RTE_LOG(DEBUG, SPP_RING_LATENCY_STATS,
-					"Set timestamp. ring_id=%d, "
-					"pkts_index=%u, timestamp=%lu\n",
-					ring_id, i, now);
-			pkts[i]->timestamp = now;
-			stats_info->timer_tsc = 0;
-		}
-
-		/* update previous tsc */
-		stats_info->prev_tsc = now;
-	}
-}
-
-void
-sppwk_calc_ring_latency(int ring_id,
-		struct rte_mbuf **pkts, uint16_t nb_pkts)
-{
-	unsigned int i;
-	uint64_t now;
-	int64_t latency;
-	struct ring_latency_stats_info *stats_info = &g_stats_info[ring_id];
-
-	now = rte_rdtsc();
-	for (i = 0; i < nb_pkts; i++) {
-		if (likely(pkts[i]->timestamp == 0))
-			continue;
-
-		/* calc latency if mbuf `timestamp` is non-zero. */
-		latency = (uint64_t)floor((now - pkts[i]->timestamp) /
-				cycles_per_ns());
-		if (likely(latency < TOTAL_LATENCY_ENT-1))
-			stats_info->stats.distr[latency]++;
-		else
-			stats_info->stats.distr[TOTAL_LATENCY_ENT-1]++;
-	}
-}
-
-int
-sppwk_get_ring_latency_stats_count(void)
-{
-	return g_stats_count;
-}
-
-void
-sppwk_get_ring_latency_stats(int ring_id,
-		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 ring_latency_stats_t));
-}
-
-/* Print statistics of time for packet processing in ring interface */
-void
-print_ring_latency_stats(struct iface_info *if_info)
-{
-	/* Clear screen and move cursor to top left */
-	const char topLeft[] = { 27, '[', '1', ';', '1', 'H', '\0' };
-	const char clr[] = { 27, '[', '2', 'J', '\0' };
-	printf("%s%s", clr, topLeft);
-
-	int ring_cnt, stats_cnt;
-	struct ring_latency_stats_t stats[RTE_MAX_ETHPORTS];
-	memset(&stats, 0x00, sizeof(stats));
-
-	printf("RING Latency\n");
-	printf(" RING");
-	for (ring_cnt = 0; ring_cnt < RTE_MAX_ETHPORTS; ring_cnt++) {
-		if (if_info->ring[ring_cnt].iface_type == UNDEF)
-			continue;
-
-		sppwk_get_ring_latency_stats(ring_cnt, &stats[ring_cnt]);
-		printf(", %-18d", ring_cnt);
-	}
-	printf("\n");
-
-	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].distr[stats_cnt]);
-		}
-		printf("\n");
-	}
-}
-
-/* Wrapper function for rte_eth_rx_burst() with calc ring latency. */
-uint16_t
-sppwk_eth_ring_stats_rx_burst(uint16_t port_id,
-		enum port_type iface_type,
-		int iface_no,
-		uint16_t queue_id  __attribute__ ((unused)),
-		struct rte_mbuf **rx_pkts, const uint16_t nb_pkts)
-{
-	uint16_t nb_rx;
-
-	nb_rx = rte_eth_rx_burst(port_id, 0, rx_pkts, nb_pkts);
-
-	/* TODO(yasufum) confirm why it returns SPPWK_RET_OK. */
-	if (unlikely(nb_rx == 0))
-		return SPPWK_RET_OK;
-
-	if (iface_type == RING)
-		sppwk_calc_ring_latency(iface_no, rx_pkts, nb_pkts);
-	return nb_rx;
-}
-
-/* Wrapper function for rte_eth_tx_burst() with calc ring latency. */
-uint16_t
-sppwk_eth_ring_stats_tx_burst(uint16_t port_id,
-		enum port_type iface_type,
-		int iface_no,
-		uint16_t queue_id __attribute__ ((unused)),
-		struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
-{
-	uint16_t nb_tx;
-
-	nb_tx = rte_eth_tx_burst(port_id, 0, tx_pkts, nb_pkts);
-
-	if (iface_type == RING)
-		sppwk_add_ring_latency_time(iface_no, tx_pkts, nb_pkts);
-	return nb_tx;
-}
-
-#endif /* SPP_RINGLATENCYSTATS_ENABLE */
diff --git a/src/shared/secondary/spp_worker_th/latency_stats.h b/src/shared/secondary/spp_worker_th/latency_stats.h
deleted file mode 100644
index 1857672..0000000
--- a/src/shared/secondary/spp_worker_th/latency_stats.h
+++ /dev/null
@@ -1,167 +0,0 @@
-/* SPDX-License-Identifier: BSD-3-Clause
- * Copyright(c) 2017-2018 Nippon Telegraph and Telephone Corporation
- */
-
-#ifndef _RINGLATENCYSTATS_H_
-#define _RINGLATENCYSTATS_H_
-
-/**
- * @file
- * SPP RING latency statistics
- *
- * Util functions for measuring latency of ring-PMD.
- */
-
-#include <rte_mbuf.h>
-#include "cmd_utils.h"
-
-/**
- * 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
-
-/** statistics of latency of ring */
-struct ring_latency_stats_t {
-	uint64_t distr[TOTAL_LATENCY_ENT]; /* distribution of time */
-};
-
-
-#ifdef SPP_RINGLATENCYSTATS_ENABLE
-/**
- * initialize ring latency statistics.
- *
- * @param samp_intvl
- *  The interval timer(ns) to refer the counter.
- * @param stats_count
- *  The number of ring to be measured.
- *
- * @retval SPPWK_RET_OK: succeeded.
- * @retval SPPWK_RET_NG: failed.
- */
-int sppwk_init_ring_latency_stats(uint64_t samp_intvl, uint16_t stats_count);
-
-void sppwk_clean_ring_latency_stats(void);
-
-/**
- * add time-stamp to mbuf's member.
- *
- * @note call at enqueue.
- *
- * @param ring_id Ring id.
- * @param pkts Pointer to nb_pkts rte_mbuf containing packets.
- * @param nb_pkts Maximum number of packets to be measured.
- */
-void sppwk_add_ring_latency_time(int ring_id,
-		struct rte_mbuf **pkts, uint16_t nb_pkts);
-
-/**
- * calculate latency of ring.
- *
- * @note call at dequeue.
- *
- * @param ring_id ring id.
- * @param pkts Pointer to nb_pkts to containing packets.
- * @param nb_pkts Max number of packets to be measured.
- */
-void sppwk_calc_ring_latency(int ring_id,
-		struct rte_mbuf **pkts, uint16_t nb_pkts);
-
-/**
- * get number of ring latency statistics.
- *
- * @return sppwk_init_ring_latency_stats's parameter "stats_count"
- */
-int sppwk_get_ring_latency_stats_count(void);
-
-/**
- *get specific ring latency statistics.
- *
- * @param ring_id
- *  The ring id.
- * @param stats
- *  The statistics values.
- */
-void sppwk_get_ring_latency_stats(int ring_id,
-		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);
-
-/**
- * Wrapper function for rte_eth_rx_burst() with ring latency feature.
- *
- * @param[in] port_id Etherdev ID.
- * @param[in] queue_id RX queue ID, but fixed value 0 in SPP.
- * @param[in] rx_pkts Pointers to mbuf should be enough to store nb_pkts.
- * @param nb_pkts Maximum number of RX packets.
- * @return Number of RX packets as number of pointers to mbuf.
- */
-uint16_t sppwk_eth_ring_stats_rx_burst(uint16_t port_id,
-		enum port_type iface_type,
-		int iface_no, uint16_t queue_id,
-		struct rte_mbuf **rx_pkts, const uint16_t nb_pkts);
-
-/**
- * Wrapper function for rte_eth_tx_burst() with ring latency feature.
- *
- * @param port_id Etherdev ID.
- * @param[in] queue_id TX queue ID, but fixed value 0 in SPP.
- * @param[in] tx_pkts Pointers to mbuf should be enough to store nb_pkts.
- * @param nb_pkts Maximum number of TX packets.
- * @return Number of TX packets as number of pointers to mbuf.
- */
-uint16_t sppwk_eth_ring_stats_tx_burst(uint16_t port_id,
-		enum port_type iface_type,
-		int iface_no, uint16_t queue_id,
-		struct rte_mbuf **tx_pkts, uint16_t nb_pkts);
-
-/**
- * Wrapper function for rte_eth_rx_burst() with VLAN and ring latency feature.
- *
- * @param[in] port_id Etherdev ID.
- * @param[in] queue_id RX queue ID, but fixed value 0 in SPP.
- * @param[in] rx_pkts Pointers to mbuf should be enough to store nb_pkts.
- * @param nb_pkts Maximum number of RX packets.
- * @return Number of RX packets as number of pointers to mbuf.
- */
-uint16_t sppwk_eth_vlan_ring_stats_rx_burst(uint16_t port_id,
-		enum port_type iface_type,
-		int iface_no, uint16_t queue_id,
-		struct rte_mbuf **rx_pkts, const uint16_t nb_pkts);
-
-/**
- * Wrapper function for rte_eth_tx_burst() with VLAN and ring latency feature.
- *
- * @param port_id Etherdev ID.
- * @param[in] queue_id TX queue ID, but fixed value 0 in SPP.
- * @param[in] tx_pkts Pointers to mbuf should be enough to store nb_pkts.
- * @param nb_pkts Maximum number of TX packets.
- * @return Number of TX packets as number of pointers to mbuf.
- */
-uint16_t sppwk_eth_vlan_ring_stats_tx_burst(uint16_t port_id,
-		enum port_type iface_type,
-		int iface_no, uint16_t queue_id,
-		struct rte_mbuf **tx_pkts, uint16_t nb_pkts);
-
-#else
-
-#define sppwk_init_ring_latency_stats(arg1, arg2) 0
-#define sppwk_clean_ring_latency_stats()
-#define sppwk_add_ring_latency_time(arg1, arg2, arg3)
-#define sppwk_calc_ring_latency(arg1, arg2, arg3)
-#define sppwk_get_ring_latency_stats_count() 0
-#define sppwk_get_ring_latency_stats(arg1, arg2)
-#define print_ringlatencystats_stats(arg)
-#define sppwk_eth_ring_stats_rx_burst(arg1, arg2, arg3, arg4, arg5, arg6)
-#define sppwk_eth_ring_stats_tx_burst(arg1, arg2, arg3, arg4, arg5, arg6)
-#define sppwk_eth_vlan_ring_stats_rx_burst(arg1, arg2, arg3, arg4, arg5, arg6)
-#define sppwk_eth_vlan_ring_stats_tx_burst(arg1, arg2, arg3, arg4, arg5, arg6)
-
-#endif /* SPP_RINGLATENCYSTATS_ENABLE */
-
-#endif /* _RINGLATENCYSTATS_H_ */
diff --git a/src/shared/secondary/spp_worker_th/port_capability.c b/src/shared/secondary/spp_worker_th/port_capability.c
index 5bd759f..cced906 100644
--- a/src/shared/secondary/spp_worker_th/port_capability.c
+++ b/src/shared/secondary/spp_worker_th/port_capability.c
@@ -11,9 +11,6 @@
 #include "port_capability.h"
 #include "shared/secondary/return_codes.h"
 
-#ifdef SPP_RINGLATENCYSTATS_ENABLE
-#include "latency_stats.h"
-#endif
 
 /**
  * TODO(yasufum) This `port capability` is intended to be used mainly for VLAN
@@ -407,47 +404,3 @@ sppwk_eth_vlan_tx_burst(uint16_t port_id,
 	return rte_eth_tx_burst(port_id, queue_id, tx_pkts, nb_tx);
 }
 
-#ifdef SPP_RINGLATENCYSTATS_ENABLE
-
-/* Wrapper function for rte_eth_rx_burst() with VLAN feature. */
-uint16_t
-sppwk_eth_vlan_ring_stats_rx_burst(uint16_t port_id,
-		enum port_type iface_type, int iface_no,
-		uint16_t queue_id __attribute__ ((unused)),
-		struct rte_mbuf **rx_pkts, const uint16_t nb_pkts)
-{
-	uint16_t nb_rx;
-	nb_rx = rte_eth_rx_burst(port_id, 0, rx_pkts, nb_pkts);
-	if (unlikely(nb_rx == 0))
-		return SPPWK_RET_OK;
-
-	if (iface_type == RING)
-		sppwk_calc_ring_latency(iface_no, rx_pkts, nb_pkts);
-
-	/* Add or delete VLAN tag. */
-	return vlan_operation(port_id, rx_pkts, nb_rx, SPPWK_PORT_DIR_RX);
-}
-
-/* Wrapper function for rte_eth_tx_burst() with VLAN feature. */
-uint16_t
-sppwk_eth_vlan_ring_stats_tx_burst(uint16_t port_id,
-		enum port_type iface_type, int iface_no,
-		uint16_t queue_id __attribute__ ((unused)),
-		struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
-{
-	uint16_t nb_tx;
-
-	/* Add or delete VLAN tag. */
-	nb_tx = vlan_operation(port_id, tx_pkts, nb_pkts, SPPWK_PORT_DIR_TX);
-
-	if (unlikely(nb_tx == 0))
-		return SPPWK_RET_OK;
-
-	if (iface_type == RING) {
-		sppwk_add_ring_latency_time(iface_no, tx_pkts, nb_pkts);
-	}
-
-	return rte_eth_tx_burst(port_id, 0, tx_pkts, nb_tx);
-}
-
-#endif /* SPP_RINGLATENCYSTATS_ENABLE */
-- 
2.17.1


  parent reply	other threads:[~2020-06-22  1:19 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-22  1:18 [spp] [PATCH 0/5] " x-fn-spp-ml
2020-06-22  1:18 ` [spp] [PATCH 1/5] Makefile: " x-fn-spp-ml
2020-06-22  1:18 ` x-fn-spp-ml [this message]
2020-06-22  1:18 ` [spp] [PATCH 3/5] vf: " x-fn-spp-ml
2020-06-22  1:18 ` [spp] [PATCH 4/5] pcap: " x-fn-spp-ml
2020-06-22  1:18 ` [spp] [PATCH 5/5] mirror: " x-fn-spp-ml
2020-06-22  4:57 ` [spp] [PATCH 0/5] " Itsuro ODA
2020-07-02  0:31 ` Yasufumi Ogawa
2020-07-09  4:28   ` Yasufumi Ogawa
2020-07-09  5:30 ` [spp] [PATCH v2 " x-fn-spp-ml
2020-07-10  5:46   ` Yasufumi Ogawa
2020-07-09  5:30 ` [spp] [PATCH v2 1/5] makefile: " x-fn-spp-ml
2020-07-09  5:30 ` [spp] [PATCH v2 2/5] shared/sec: " x-fn-spp-ml
2020-07-09  5:30 ` [spp] [PATCH v2 3/5] spp_pcap: " x-fn-spp-ml
2020-07-09  5:30 ` [spp] [PATCH v2 4/5] spp_vf: " x-fn-spp-ml
2020-07-09  5:30 ` [spp] [PATCH v2 5/5] spp_mirror: " x-fn-spp-ml

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=20200622011854.8059-3-x-fn-spp-ml@ntt-tx.co.jp \
    --to=x-fn-spp-ml@ntt-tx.co.jp \
    --cc=spp@dpdk.org \
    --cc=yasufum.o@gmail.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).