X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=lib%2Flibrte_latencystats%2Frte_latencystats.c;h=06c62831b41542edc7f09856a81fa936674283fe;hb=292472ba0be75da85dec045a608e8dd162094141;hp=fc9497659165894ad8ff9f9d233808ae8a43d7a5;hpb=03d8f4710030645c138d8b0f74f5168db6954df9;p=dpdk.git diff --git a/lib/librte_latencystats/rte_latencystats.c b/lib/librte_latencystats/rte_latencystats.c index fc94976591..06c62831b4 100644 --- a/lib/librte_latencystats/rte_latencystats.c +++ b/lib/librte_latencystats/rte_latencystats.c @@ -1,5 +1,5 @@ /* SPDX-License-Identifier: BSD-3-Clause - * Copyright(c) 2017 Intel Corporation + * Copyright(c) 2018 Intel Corporation */ #include @@ -7,6 +7,7 @@ #include #include +#include #include #include #include @@ -125,8 +126,11 @@ add_time_stamps(uint16_t pid __rte_unused, for (i = 0; i < nb_pkts; i++) { diff_tsc = now - prev_tsc; timer_tsc += diff_tsc; - if (timer_tsc >= samp_intvl) { + + if ((pkts[i]->ol_flags & PKT_RX_TIMESTAMP) == 0 + && (timer_tsc >= samp_intvl)) { pkts[i]->timestamp = now; + pkts[i]->ol_flags |= PKT_RX_TIMESTAMP; timer_tsc = 0; } prev_tsc = now; @@ -156,7 +160,7 @@ calc_latency(uint16_t pid __rte_unused, now = rte_rdtsc(); for (i = 0; i < nb_pkts; i++) { - if (pkts[i]->timestamp) + if (pkts[i]->ol_flags & PKT_RX_TIMESTAMP) latency[cnt++] = now - pkts[i]->timestamp; } @@ -201,7 +205,6 @@ rte_latencystats_init(uint64_t app_samp_intvl, uint16_t pid; uint16_t qid; struct rxtx_cbs *cbs = NULL; - const uint16_t nb_ports = rte_eth_dev_count(); const char *ptr_strings[NUM_LATENCY_STATS] = {0}; const struct rte_memzone *mz = NULL; const unsigned int flags = 0; @@ -234,7 +237,7 @@ rte_latencystats_init(uint64_t app_samp_intvl, } /** Register Rx/Tx callbacks */ - for (pid = 0; pid < nb_ports; pid++) { + RTE_ETH_FOREACH_DEV(pid) { struct rte_eth_dev_info dev_info; rte_eth_dev_info_get(pid, &dev_info); for (qid = 0; qid < dev_info.nb_rx_queues; qid++) { @@ -266,10 +269,10 @@ rte_latencystats_uninit(void) uint16_t qid; int ret = 0; struct rxtx_cbs *cbs = NULL; - const uint16_t nb_ports = rte_eth_dev_count(); + const struct rte_memzone *mz = NULL; /** De register Rx/Tx callbacks */ - for (pid = 0; pid < nb_ports; pid++) { + RTE_ETH_FOREACH_DEV(pid) { struct rte_eth_dev_info dev_info; rte_eth_dev_info_get(pid, &dev_info); for (qid = 0; qid < dev_info.nb_rx_queues; qid++) { @@ -290,6 +293,11 @@ rte_latencystats_uninit(void) } } + /* free up the memzone */ + mz = rte_memzone_lookup(MZ_RTE_LATENCY_STATS); + if (mz) + rte_memzone_free(mz); + return 0; } @@ -302,8 +310,8 @@ rte_latencystats_get_names(struct rte_metric_name *names, uint16_t size) return NUM_LATENCY_STATS; for (i = 0; i < NUM_LATENCY_STATS; i++) - snprintf(names[i].name, sizeof(names[i].name), - "%s", lat_stats_strings[i].name); + strlcpy(names[i].name, lat_stats_strings[i].name, + sizeof(names[i].name)); return NUM_LATENCY_STATS; }