X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=lib%2Flibrte_latencystats%2Frte_latencystats.c;h=98e018939ecbc6ced3c8612c8d2a33511525b236;hb=a09f61159ad0f4449a61c6325eb5bda4be1bb5cd;hp=1fdec68e352beed1a1cf22c9ef3f02b1508d2e91;hpb=8224b9d682d436c3d9f5f448e9f8a19fb872ed40;p=dpdk.git diff --git a/lib/librte_latencystats/rte_latencystats.c b/lib/librte_latencystats/rte_latencystats.c index 1fdec68e35..98e018939e 100644 --- a/lib/librte_latencystats/rte_latencystats.c +++ b/lib/librte_latencystats/rte_latencystats.c @@ -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; } @@ -204,6 +208,7 @@ rte_latencystats_init(uint64_t app_samp_intvl, const char *ptr_strings[NUM_LATENCY_STATS] = {0}; const struct rte_memzone *mz = NULL; const unsigned int flags = 0; + int ret; if (rte_memzone_lookup(MZ_RTE_LATENCY_STATS)) return -EEXIST; @@ -235,7 +240,16 @@ rte_latencystats_init(uint64_t app_samp_intvl, /** Register Rx/Tx callbacks */ RTE_ETH_FOREACH_DEV(pid) { struct rte_eth_dev_info dev_info; - rte_eth_dev_info_get(pid, &dev_info); + + ret = rte_eth_dev_info_get(pid, &dev_info); + if (ret != 0) { + RTE_LOG(INFO, LATENCY_STATS, + "Error during getting device (port %u) info: %s\n", + pid, strerror(-ret)); + + continue; + } + for (qid = 0; qid < dev_info.nb_rx_queues; qid++) { cbs = &rx_cbs[pid][qid]; cbs->cb = rte_eth_add_first_rx_callback(pid, qid, @@ -270,7 +284,16 @@ rte_latencystats_uninit(void) /** De register Rx/Tx callbacks */ RTE_ETH_FOREACH_DEV(pid) { struct rte_eth_dev_info dev_info; - rte_eth_dev_info_get(pid, &dev_info); + + ret = rte_eth_dev_info_get(pid, &dev_info); + if (ret != 0) { + RTE_LOG(INFO, LATENCY_STATS, + "Error during getting device (port %u) info: %s\n", + pid, strerror(-ret)); + + continue; + } + for (qid = 0; qid < dev_info.nb_rx_queues; qid++) { cbs = &rx_cbs[pid][qid]; ret = rte_eth_remove_rx_callback(pid, qid, cbs->cb); @@ -306,8 +329,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; }