From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 5945EA0526 for ; Thu, 9 Jul 2020 07:30:32 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 513941DA91; Thu, 9 Jul 2020 07:30:32 +0200 (CEST) Received: from dish-sg.nttdocomo.co.jp (dish-sg.nttdocomo.co.jp [202.19.227.74]) by dpdk.org (Postfix) with ESMTP id 7B0921DA91 for ; Thu, 9 Jul 2020 07:30:30 +0200 (CEST) X-dD-Source: Outbound Received: from zssg-mailmd101.ddreams.local (zssg-mailmd900.ddreams.local [10.160.172.63]) by zssg-mailou104.ddreams.local (Postfix) with ESMTP id C044F120122; Thu, 9 Jul 2020 14:30:29 +0900 (JST) Received: from zssg-mailmf103.ddreams.local (zssg-mailmf900.ddreams.local [10.160.172.84]) by zssg-mailmd101.ddreams.local (dDREAMS) with ESMTP id <0QD600PARSMTQIC0@dDREAMS>; Thu, 09 Jul 2020 14:30:29 +0900 (JST) Received: from zssg-mailmf103.ddreams.local (unknown [127.0.0.1]) by zssg-mailmf103.ddreams.local (Postfix) with ESMTP id A57937E603C; Thu, 9 Jul 2020 14:30:29 +0900 (JST) Received: from zssg-mailmf103.ddreams.local (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id A4ACA8E6056; Thu, 9 Jul 2020 14:30:29 +0900 (JST) Received: from localhost (unknown [127.0.0.1]) by IMSVA (Postfix) with SMTP id A2B368E605E; Thu, 9 Jul 2020 14:30:29 +0900 (JST) X-IMSS-HAND-OFF-DIRECTIVE: localhost:10026 Received: from zssg-mailmf103.ddreams.local (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id BD9518E605C; Thu, 9 Jul 2020 14:30:28 +0900 (JST) Received: from davinci.ntt-tx.co.jp (unknown [10.160.183.139]) by zssg-mailmf103.ddreams.local (Postfix) with ESMTP; Thu, 9 Jul 2020 14:30:28 +0900 (JST) From: x-fn-spp-ml@ntt-tx.co.jp To: spp@dpdk.org, yasufum.o@gmail.com Date: Thu, 09 Jul 2020 14:30:23 +0900 Message-id: <20200709053026.21265-3-x-fn-spp-ml@ntt-tx.co.jp> X-Mailer: git-send-email 2.25.1 In-reply-to: <20200622011854.8059-1-x-fn-spp-ml@ntt-tx.co.jp> References: <20200622011854.8059-1-x-fn-spp-ml@ntt-tx.co.jp> MIME-version: 1.0 Content-transfer-encoding: 8bit X-TM-AS-GCONF: 00 Subject: [spp] [PATCH v2 2/5] shared/sec: remove ringlatency stats functionality X-BeenThere: spp@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Soft Patch Panel List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: spp-bounces@dpdk.org Sender: "spp" From: Hideyuki Yamashita This patch tries to remove ringlatency stats functionality. Signed-off-by: Hideyuki Yamashita Signed-off-by: Naoki Takada --- .../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 -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -#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 -#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