MCPcopy Create free account
hub / github.com/F-Stack/f-stack / rte_latencystats_init

Function rte_latencystats_init

dpdk/lib/latencystats/rte_latencystats.c:224–308  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

222}
223
224int
225rte_latencystats_init(uint64_t app_samp_intvl,
226 rte_latency_stats_flow_type_fn user_cb)
227{
228 unsigned int i;
229 uint16_t pid;
230 uint16_t qid;
231 struct rxtx_cbs *cbs = NULL;
232 const char *ptr_strings[NUM_LATENCY_STATS] = {0};
233 const struct rte_memzone *mz = NULL;
234 const unsigned int flags = 0;
235 int ret;
236
237 if (rte_memzone_lookup(MZ_RTE_LATENCY_STATS))
238 return -EEXIST;
239
240 /** Allocate stats in shared memory fo multi process support */
241 mz = rte_memzone_reserve(MZ_RTE_LATENCY_STATS, sizeof(*glob_stats),
242 rte_socket_id(), flags);
243 if (mz == NULL) {
244 RTE_LOG(ERR, LATENCY_STATS, "Cannot reserve memory: %s:%d\n",
245 __func__, __LINE__);
246 return -ENOMEM;
247 }
248
249 glob_stats = mz->addr;
250 rte_spinlock_init(&glob_stats->lock);
251 samp_intvl = app_samp_intvl * latencystat_cycles_per_ns();
252 next_tsc = rte_rdtsc();
253
254 /** Register latency stats with stats library */
255 for (i = 0; i < NUM_LATENCY_STATS; i++)
256 ptr_strings[i] = lat_stats_strings[i].name;
257
258 latency_stats_index = rte_metrics_reg_names(ptr_strings,
259 NUM_LATENCY_STATS);
260 if (latency_stats_index < 0) {
261 RTE_LOG(DEBUG, LATENCY_STATS,
262 "Failed to register latency stats names\n");
263 return -1;
264 }
265
266 /* Register mbuf field and flag for Rx timestamp */
267 ret = rte_mbuf_dyn_rx_timestamp_register(&timestamp_dynfield_offset,
268 &timestamp_dynflag);
269 if (ret != 0) {
270 RTE_LOG(ERR, LATENCY_STATS,
271 "Cannot register mbuf field/flag for timestamp\n");
272 return -rte_errno;
273 }
274
275 /** Register Rx/Tx callbacks */
276 RTE_ETH_FOREACH_DEV(pid) {
277 struct rte_eth_dev_info dev_info;
278
279 ret = rte_eth_dev_info_get(pid, &dev_info);
280 if (ret != 0) {
281 RTE_LOG(INFO, LATENCY_STATS,

Callers 2

test_latency_initFunction · 0.85
mainFunction · 0.85

Calls 11

rte_memzone_lookupFunction · 0.85
rte_memzone_reserveFunction · 0.85
rte_socket_idFunction · 0.85
rte_spinlock_initFunction · 0.85
rte_metrics_reg_namesFunction · 0.85
rte_eth_dev_info_getFunction · 0.85
rte_eth_add_tx_callbackFunction · 0.85
rte_rdtscFunction · 0.50

Tested by 2

test_latency_initFunction · 0.68
mainFunction · 0.68