2 // Copyright (c) 2010-2017 Intel Corporation
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
8 // http://www.apache.org/licenses/LICENSE-2.0
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
20 #include "stats_parser.h"
23 #include "parse_utils.h"
24 #include "handle_lat.h"
25 #include "prox_port_cfg.h"
26 #include "stats_port.h"
27 #include "stats_mempool.h"
28 #include "stats_ring.h"
29 #include "stats_l4gen.h"
30 #include "stats_latency.h"
31 #include "stats_global.h"
32 #include "stats_prio_task.h"
33 #include "stats_irq.h"
35 struct stats_path_str {
37 uint64_t (*func)(int argc, const char *argv[]);
40 static int args_to_core_task(const char *core_str, const char *task_str, uint32_t *lcore_id, uint32_t *task_id)
42 if (parse_list_set(lcore_id, core_str, 1) != 1)
44 *task_id = atoi(task_str);
49 static uint64_t sp_task_idle_cycles(int argc, const char *argv[])
51 struct task_stats_sample *last;
54 if (args_to_core_task(argv[0], argv[1], &c, &t))
56 return stats_get_task_stats_sample(c, t, 1)->tsc;
59 static uint64_t sp_task_rx_packets(int argc, const char *argv[])
61 struct task_stats_sample *last;
64 if (args_to_core_task(argv[0], argv[1], &c, &t))
66 return stats_get_task_stats_sample(c, t, 1)->rx_pkt_count;
69 static uint64_t sp_task_tx_packets(int argc, const char *argv[])
71 struct task_stats_sample *last;
74 if (args_to_core_task(argv[0], argv[1], &c, &t))
76 return stats_get_task_stats_sample(c, t, 1)->tx_pkt_count;
79 static uint64_t sp_task_drop_tx_fail(int argc, const char *argv[])
81 struct task_stats_sample *last;
84 if (args_to_core_task(argv[0], argv[1], &c, &t))
86 return stats_get_task_stats_sample(c, t, 1)->drop_tx_fail;
89 static uint64_t sp_task_drop_tx_fail_prio(int argc, const char *argv[])
91 struct task_stats_sample *last;
94 if (args_to_core_task(argv[0], argv[1], &c, &t))
96 if (stats_get_prio_task_stats_sample_by_core_task(c, t, 1))
97 return stats_get_prio_task_stats_sample_by_core_task(c, t, 1)->drop_tx_fail_prio[atoi(argv[2])];
102 static uint64_t sp_task_rx_prio(int argc, const char *argv[])
104 struct task_stats_sample *last;
107 if (args_to_core_task(argv[0], argv[1], &c, &t))
109 return stats_get_prio_task_stats_sample_by_core_task(c, t, 1)->rx_prio[atoi(argv[2])];
112 static uint64_t sp_task_max_irq(int argc, const char *argv[])
114 struct task_stats_sample *last;
117 if (args_to_core_task(argv[0], argv[1], &c, &t))
119 return get_max_irq_stats_by_core_task(c, t);
122 static uint64_t sp_task_irq(int argc, const char *argv[])
124 struct task_stats_sample *last;
127 if (args_to_core_task(argv[0], argv[1], &c, &t))
129 return get_irq_stats_by_core_task(c, t, atoi(argv[2]));
132 static uint64_t sp_task_drop_discard(int argc, const char *argv[])
134 struct task_stats_sample *last;
137 if (args_to_core_task(argv[0], argv[1], &c, &t))
139 return stats_get_task_stats_sample(c, t, 1)->drop_discard;
142 static uint64_t sp_task_drop_handled(int argc, const char *argv[])
144 struct task_stats_sample *last;
147 if (args_to_core_task(argv[0], argv[1], &c, &t))
149 return stats_get_task_stats_sample(c, t, 1)->drop_handled;
152 static uint64_t sp_task_rx_bytes(int argc, const char *argv[])
157 static uint64_t sp_task_tx_bytes(int argc, const char *argv[])
162 static uint64_t sp_task_tsc(int argc, const char *argv[])
164 struct task_stats_sample *last;
167 if (args_to_core_task(argv[0], argv[1], &c, &t))
169 return stats_get_task_stats_sample(c, t, 1)->tsc;
172 static uint64_t sp_l4gen_created(int argc, const char *argv[])
174 struct l4_stats_sample *clast = NULL;
176 if (atoi(argv[0]) >= stats_get_n_l4gen())
178 clast = stats_get_l4_stats_sample(atoi(argv[0]), 1);
179 return clast->stats.tcp_created + clast->stats.udp_created;
182 static uint64_t sp_l4gen_finished(int argc, const char *argv[])
184 struct l4_stats_sample *clast = NULL;
186 if (atoi(argv[0]) >= stats_get_n_l4gen())
188 clast = stats_get_l4_stats_sample(atoi(argv[0]), 1);
189 return clast->stats.tcp_finished_retransmit + clast->stats.tcp_finished_no_retransmit +
190 clast->stats.udp_finished + clast->stats.udp_expired + clast->stats.tcp_expired;
193 static uint64_t sp_l4gen_expire_tcp(int argc, const char *argv[])
195 struct l4_stats_sample *clast = NULL;
197 if (atoi(argv[0]) >= stats_get_n_l4gen())
199 clast = stats_get_l4_stats_sample(atoi(argv[0]), 1);
200 return clast->stats.tcp_expired;
203 static uint64_t sp_l4gen_expire_udp(int argc, const char *argv[])
205 struct l4_stats_sample *clast = NULL;
207 if (atoi(argv[0]) >= stats_get_n_l4gen())
209 clast = stats_get_l4_stats_sample(atoi(argv[0]), 1);
210 return clast->stats.udp_expired;
213 static uint64_t sp_l4gen_retx(int argc, const char *argv[])
215 struct l4_stats_sample *clast = NULL;
217 if (atoi(argv[0]) >= stats_get_n_l4gen())
219 clast = stats_get_l4_stats_sample(atoi(argv[0]), 1);
220 return clast->stats.tcp_retransmits;
223 static uint64_t sp_l4gen_tsc(int argc, const char *argv[])
225 struct l4_stats_sample *clast = NULL;
227 if (atoi(argv[0]) >= stats_get_n_l4gen())
229 clast = stats_get_l4_stats_sample(atoi(argv[0]), 1);
233 static uint64_t sp_l4gen_torndown_no_retx(int argc, const char *argv[])
235 struct l4_stats_sample *clast = NULL;
237 if (atoi(argv[0]) >= stats_get_n_l4gen())
239 clast = stats_get_l4_stats_sample(atoi(argv[0]), 1);
240 return clast->stats.tcp_finished_no_retransmit;
243 static uint64_t sp_l4gen_torndown_retx(int argc, const char *argv[])
245 struct l4_stats_sample *clast = NULL;
247 if (atoi(argv[0]) >= stats_get_n_l4gen())
249 clast = stats_get_l4_stats_sample(atoi(argv[0]), 1);
250 return clast->stats.tcp_finished_retransmit;
253 static uint64_t sp_l4gen_torndown_udp(int argc, const char *argv[])
255 struct l4_stats_sample *clast = NULL;
257 if (atoi(argv[0]) >= stats_get_n_l4gen())
259 clast = stats_get_l4_stats_sample(atoi(argv[0]), 1);
260 return clast->stats.udp_finished;
263 static uint64_t sp_l4gen_created_tcp(int argc, const char *argv[])
265 struct l4_stats_sample *clast = NULL;
267 if (atoi(argv[0]) >= stats_get_n_l4gen())
269 clast = stats_get_l4_stats_sample(atoi(argv[0]), 1);
270 return clast->stats.tcp_created;
274 static uint64_t sp_l4gen_created_udp(int argc, const char *argv[])
276 struct l4_stats_sample *clast = NULL;
278 if (atoi(argv[0]) >= stats_get_n_l4gen())
280 clast = stats_get_l4_stats_sample(atoi(argv[0]), 1);
281 return clast->stats.udp_created;
284 static uint64_t sp_l4gen_created_all(int argc, const char *argv[])
286 struct l4_stats_sample *clast = NULL;
288 if (atoi(argv[0]) >= stats_get_n_l4gen())
290 clast = stats_get_l4_stats_sample(atoi(argv[0]), 1);
291 return clast->stats.tcp_created + clast->stats.udp_created;
294 static uint64_t sp_l4gen_created_bundles(int argc, const char *argv[])
296 struct l4_stats_sample *clast = NULL;
298 if (atoi(argv[0]) >= stats_get_n_l4gen())
300 clast = stats_get_l4_stats_sample(atoi(argv[0]), 1);
301 return clast->stats.bundles_created;
304 static uint64_t sp_latency_min(int argc, const char *argv[])
306 struct stats_latency *lat_test = NULL;
308 if (atoi(argv[0]) >= stats_get_n_latency())
310 lat_test = stats_latency_get(atoi(argv[0]));
312 if (!lat_test->tot_packets)
315 struct time_unit tu = lat_test->min.time;
316 return time_unit_to_usec(&tu);
319 static uint64_t sp_mem_used(int argc, const char *argv[])
321 struct mempool_stats *ms;
323 if (atoi(argv[0]) > stats_get_n_mempools())
325 ms = stats_get_mempool_stats(atoi(argv[0]));
326 return ms->size - ms->free;
329 static uint64_t sp_mem_free(int argc, const char *argv[])
331 struct mempool_stats *ms;
333 if (atoi(argv[0]) > stats_get_n_mempools())
335 ms = stats_get_mempool_stats(atoi(argv[0]));
339 static uint64_t sp_mem_size(int argc, const char *argv[])
341 struct mempool_stats *ms;
343 if (atoi(argv[0]) > stats_get_n_mempools())
345 ms = stats_get_mempool_stats(atoi(argv[0]));
349 static uint64_t sp_port_no_mbufs(int argc, const char *argv[])
351 uint32_t port_id = atoi(argv[0]);
352 struct port_stats_sample *ps;
354 if (port_id > PROX_MAX_PORTS || !prox_port_cfg[port_id].active)
356 ps = stats_get_port_stats_sample(port_id, 1);
360 static uint64_t sp_port_ierrors(int argc, const char *argv[])
362 uint32_t port_id = atoi(argv[0]);
363 struct port_stats_sample *ps;
365 if (port_id > PROX_MAX_PORTS || !prox_port_cfg[port_id].active)
367 ps = stats_get_port_stats_sample(port_id, 1);
371 static uint64_t sp_port_imissed(int argc, const char *argv[])
373 uint32_t port_id = atoi(argv[0]);
374 struct port_stats_sample *ps;
376 if (port_id > PROX_MAX_PORTS || !prox_port_cfg[port_id].active)
378 ps = stats_get_port_stats_sample(port_id, 1);
382 static uint64_t sp_port_oerrors(int argc, const char *argv[])
384 uint32_t port_id = atoi(argv[0]);
385 struct port_stats_sample *ps;
387 if (port_id > PROX_MAX_PORTS || !prox_port_cfg[port_id].active)
389 ps = stats_get_port_stats_sample(port_id, 1);
393 static uint64_t sp_port_rx_packets(int argc, const char *argv[])
395 uint32_t port_id = atoi(argv[0]);
396 struct port_stats_sample *ps;
398 if (port_id > PROX_MAX_PORTS || !prox_port_cfg[port_id].active)
400 ps = stats_get_port_stats_sample(port_id, 1);
404 static uint64_t sp_port_tx_packets(int argc, const char *argv[])
406 uint32_t port_id = atoi(argv[0]);
407 struct port_stats_sample *ps;
409 if (port_id > PROX_MAX_PORTS || !prox_port_cfg[port_id].active)
411 ps = stats_get_port_stats_sample(port_id, 1);
415 static uint64_t sp_port_rx_bytes(int argc, const char *argv[])
417 uint32_t port_id = atoi(argv[0]);
418 struct port_stats_sample *ps;
420 if (port_id > PROX_MAX_PORTS || !prox_port_cfg[port_id].active)
422 ps = stats_get_port_stats_sample(port_id, 1);
426 static uint64_t sp_port_tx_bytes(int argc, const char *argv[])
428 uint32_t port_id = atoi(argv[0]);
429 struct port_stats_sample *ps;
431 if (port_id > PROX_MAX_PORTS || !prox_port_cfg[port_id].active)
433 ps = stats_get_port_stats_sample(port_id, 1);
437 static uint64_t sp_port_tx_packets_64(int argc, const char *argv[])
439 uint32_t port_id = atoi(argv[0]);
440 struct port_stats_sample *ps;
442 if (port_id > PROX_MAX_PORTS || !prox_port_cfg[port_id].active)
444 ps = stats_get_port_stats_sample(port_id, 1);
445 return ps->tx_pkt_size[PKT_SIZE_64];
448 static uint64_t sp_port_tx_packets_65_127(int argc, const char *argv[])
450 uint32_t port_id = atoi(argv[0]);
451 struct port_stats_sample *ps;
453 if (port_id > PROX_MAX_PORTS || !prox_port_cfg[port_id].active)
455 ps = stats_get_port_stats_sample(port_id, 1);
456 return ps->tx_pkt_size[PKT_SIZE_65];
459 static uint64_t sp_port_tx_packets_128_255(int argc, const char *argv[])
461 uint32_t port_id = atoi(argv[0]);
462 struct port_stats_sample *ps;
464 if (port_id > PROX_MAX_PORTS || !prox_port_cfg[port_id].active)
466 ps = stats_get_port_stats_sample(port_id, 1);
467 return ps->tx_pkt_size[PKT_SIZE_128];
470 static uint64_t sp_port_tx_packets_256_511(int argc, const char *argv[])
472 uint32_t port_id = atoi(argv[0]);
473 struct port_stats_sample *ps;
475 if (port_id > PROX_MAX_PORTS || !prox_port_cfg[port_id].active)
477 ps = stats_get_port_stats_sample(port_id, 1);
478 return ps->tx_pkt_size[PKT_SIZE_256];
481 static uint64_t sp_port_tx_packets_512_1023(int argc, const char *argv[])
483 uint32_t port_id = atoi(argv[0]);
484 struct port_stats_sample *ps;
486 if (port_id > PROX_MAX_PORTS || !prox_port_cfg[port_id].active)
488 ps = stats_get_port_stats_sample(port_id, 1);
489 return ps->tx_pkt_size[PKT_SIZE_512];
492 static uint64_t sp_port_tx_packets_1024_1522(int argc, const char *argv[])
494 uint32_t port_id = atoi(argv[0]);
495 struct port_stats_sample *ps;
497 if (port_id > PROX_MAX_PORTS || !prox_port_cfg[port_id].active)
499 ps = stats_get_port_stats_sample(port_id, 1);
500 return ps->tx_pkt_size[PKT_SIZE_1024];
503 static uint64_t sp_port_tx_packets_1523_max(int argc, const char *argv[])
505 uint32_t port_id = atoi(argv[0]);
506 struct port_stats_sample *ps;
508 if (port_id > PROX_MAX_PORTS || !prox_port_cfg[port_id].active)
510 ps = stats_get_port_stats_sample(port_id, 1);
511 return ps->tx_pkt_size[PKT_SIZE_1522];
514 static uint64_t sp_port_tsc(int argc, const char *argv[])
516 uint32_t port_id = atoi(argv[0]);
517 struct port_stats_sample *ps;
519 if (port_id > PROX_MAX_PORTS || !prox_port_cfg[port_id].active)
521 ps = stats_get_port_stats_sample(port_id, 1);
525 static uint64_t sp_latency_max(int argc, const char *argv[])
527 struct stats_latency *lat_test = NULL;
529 if (atoi(argv[0]) >= stats_get_n_latency())
531 lat_test = stats_latency_get(atoi(argv[0]));
533 if (!lat_test->tot_packets)
536 struct time_unit tu = lat_test->max.time;
537 return time_unit_to_usec(&tu);
540 static uint64_t sp_latency_avg(int argc, const char *argv[])
542 struct stats_latency *lat_test = NULL;
544 if (atoi(argv[0]) >= stats_get_n_latency())
546 lat_test = stats_latency_get(atoi(argv[0]));
548 if (!lat_test->tot_packets)
551 struct time_unit tu = lat_test->avg.time;
552 return time_unit_to_usec(&tu);
555 static uint64_t sp_latency_lost(int argc, const char *argv[])
557 struct stats_latency *lat_test = NULL;
559 if (atoi(argv[0]) >= stats_get_n_latency())
561 lat_test = stats_latency_get(atoi(argv[0]));
563 if (!lat_test->tot_packets)
566 return lat_test->lost_packets;
569 static uint64_t sp_latency_tot_lost(int argc, const char *argv[])
571 struct stats_latency *lat_test = NULL;
573 if (atoi(argv[0]) >= stats_get_n_latency())
575 lat_test = stats_latency_tot_get(atoi(argv[0]));
577 if (!lat_test->tot_packets)
580 return lat_test->lost_packets;
583 static uint64_t sp_latency_total(int argc, const char *argv[])
585 struct stats_latency *lat_test = NULL;
587 if (atoi(argv[0]) >= stats_get_n_latency())
589 lat_test = stats_latency_get(atoi(argv[0]));
591 if (!lat_test->tot_all_packets)
594 return lat_test->tot_all_packets;
597 static uint64_t sp_latency_used(int argc, const char *argv[])
599 struct stats_latency *lat_test = NULL;
601 if (atoi(argv[0]) >= stats_get_n_latency())
603 lat_test = stats_latency_get(atoi(argv[0]));
605 if (!lat_test->tot_all_packets)
608 return lat_test->tot_packets;
611 static uint64_t sp_latency_tot_total(int argc, const char *argv[])
613 struct stats_latency *lat_test = NULL;
615 if (atoi(argv[0]) >= stats_get_n_latency())
617 lat_test = stats_latency_tot_get(atoi(argv[0]));
619 if (!lat_test->tot_all_packets)
622 return lat_test->tot_all_packets;
625 static uint64_t sp_latency_tot_used(int argc, const char *argv[])
627 struct stats_latency *lat_test = NULL;
629 if (atoi(argv[0]) >= stats_get_n_latency())
631 lat_test = stats_latency_tot_get(atoi(argv[0]));
633 if (!lat_test->tot_all_packets)
636 return lat_test->tot_packets;
639 static uint64_t sp_latency_tot_min(int argc, const char *argv[])
641 struct stats_latency *lat_test = NULL;
643 if (atoi(argv[0]) >= stats_get_n_latency())
645 lat_test = stats_latency_tot_get(atoi(argv[0]));
647 if (!lat_test->tot_packets)
650 struct time_unit tu = lat_test->min.time;
651 return time_unit_to_usec(&tu);
654 static uint64_t sp_latency_tot_max(int argc, const char *argv[])
656 struct stats_latency *lat_test = NULL;
658 if (atoi(argv[0]) >= stats_get_n_latency())
660 lat_test = stats_latency_tot_get(atoi(argv[0]));
662 if (!lat_test->tot_packets)
665 struct time_unit tu = lat_test->max.time;
666 return time_unit_to_usec(&tu);
669 static uint64_t sp_latency_tot_avg(int argc, const char *argv[])
671 struct stats_latency *lat_test = NULL;
673 if (atoi(argv[0]) >= stats_get_n_latency())
675 lat_test = stats_latency_tot_get(atoi(argv[0]));
677 if (!lat_test->tot_packets)
680 struct time_unit tu = lat_test->avg.time;
681 return time_unit_to_usec(&tu);
684 static uint64_t sp_latency_stddev(int argc, const char *argv[])
686 struct stats_latency *lat_test = NULL;
688 if (atoi(argv[0]) >= stats_get_n_latency())
690 lat_test = stats_latency_get(atoi(argv[0]));
692 if (!lat_test->tot_packets)
695 struct time_unit tu = lat_test->stddev.time;
696 return time_unit_to_usec(&tu);
699 static uint64_t sp_ring_used(int argc, const char *argv[])
701 struct ring_stats *rs = NULL;
703 if (atoi(argv[0]) >= stats_get_n_rings())
705 rs = stats_get_ring_stats(atoi(argv[0]));
706 return rs->size - rs->free;
709 static uint64_t sp_ring_free(int argc, const char *argv[])
711 struct ring_stats *rs = NULL;
713 if (atoi(argv[0]) >= stats_get_n_rings())
715 rs = stats_get_ring_stats(atoi(argv[0]));
719 static uint64_t sp_ring_size(int argc, const char *argv[])
721 struct ring_stats *rs = NULL;
723 if (atoi(argv[0]) >= stats_get_n_rings())
725 rs = stats_get_ring_stats(atoi(argv[0]));
729 static uint64_t sp_global_host_rx_packets(int argc, const char *argv[])
731 return stats_get_global_stats(1)->host_rx_packets;
734 static uint64_t sp_global_host_tx_packets(int argc, const char *argv[])
736 return stats_get_global_stats(1)->host_tx_packets;
739 static uint64_t sp_global_nics_rx_packets(int argc, const char *argv[])
741 return stats_get_global_stats(1)->nics_rx_packets;
744 static uint64_t sp_global_nics_tx_packets(int argc, const char *argv[])
746 return stats_get_global_stats(1)->nics_tx_packets;
749 static uint64_t sp_global_nics_ierrors(int argc, const char *argv[])
751 return stats_get_global_stats(1)->nics_ierrors;
754 static uint64_t sp_global_nics_imissed(int argc, const char *argv[])
756 return stats_get_global_stats(1)->nics_imissed;
759 static uint64_t sp_global_tsc(int argc, const char *argv[])
761 return stats_get_global_stats(1)->tsc;
764 static uint64_t sp_hz(int argc, const char *argv[])
766 return rte_get_tsc_hz();
769 struct stats_path_str stats_paths[] = {
772 {"global.host.rx.packets", sp_global_host_rx_packets},
773 {"global.host.tx.packets", sp_global_host_tx_packets},
774 {"global.nics.rx.packets", sp_global_nics_rx_packets},
775 {"global.nics.tx.packets", sp_global_nics_tx_packets},
776 {"global.nics.ierrrors", sp_global_nics_ierrors},
777 {"global.nics.imissed", sp_global_nics_imissed},
778 {"global.tsc", sp_global_tsc},
780 {"task.core(#).task(#).idle_cycles", sp_task_idle_cycles},
781 {"task.core(#).task(#).rx.packets", sp_task_rx_packets},
782 {"task.core(#).task(#).tx.packets", sp_task_tx_packets},
783 {"task.core(#).task(#).drop.tx_fail", sp_task_drop_tx_fail},
784 {"task.core(#).task(#).drop.discard", sp_task_drop_discard},
785 {"task.core(#).task(#).drop.handled", sp_task_drop_handled},
786 {"task.core(#).task(#).rx.bytes", sp_task_rx_bytes},
787 {"task.core(#).task(#).tx.bytes", sp_task_tx_bytes},
788 {"task.core(#).task(#).tsc", sp_task_tsc},
789 {"task.core(#).task(#).drop.tx_fail_prio(#)", sp_task_drop_tx_fail_prio},
790 {"task.core(#).task(#).rx_prio(#)", sp_task_rx_prio},
791 {"task.core(#).task(#).max_irq", sp_task_max_irq},
792 {"task.core(#).task(#).irq(#)", sp_task_irq},
794 {"port(#).no_mbufs", sp_port_no_mbufs},
795 {"port(#).ierrors", sp_port_ierrors},
796 {"port(#).imissed", sp_port_imissed},
797 {"port(#).oerrors", sp_port_oerrors},
798 {"port(#).rx.packets", sp_port_rx_packets},
799 {"port(#).tx.packets", sp_port_tx_packets},
800 {"port(#).rx.bytes", sp_port_rx_bytes},
801 {"port(#).tx.bytes", sp_port_tx_bytes},
802 {"port(#).tx.packets_64", sp_port_tx_packets_64},
803 {"port(#).tx.packets_65_127", sp_port_tx_packets_65_127},
804 {"port(#).tx.packets_128_255", sp_port_tx_packets_128_255},
805 {"port(#).tx.packets_256_511", sp_port_tx_packets_256_511},
806 {"port(#).tx.packets_512_1023", sp_port_tx_packets_512_1023},
807 {"port(#).tx.packets_1024_1522", sp_port_tx_packets_1024_1522},
808 {"port(#).tx.packets_1523_max", sp_port_tx_packets_1523_max},
809 {"port(#).tsc", sp_port_tsc},
811 {"mem(#).used", sp_mem_used},
812 {"mem(#).free", sp_mem_free},
813 {"mem(#).size", sp_mem_size},
815 {"latency(#).min", sp_latency_min},
816 {"latency(#).max", sp_latency_max},
817 {"latency(#).avg", sp_latency_avg},
818 {"latency(#).lost", sp_latency_lost},
819 {"latency(#).used", sp_latency_used},
820 {"latency(#).total", sp_latency_total},
821 {"latency(#).tot.min", sp_latency_tot_min},
822 {"latency(#).tot.max", sp_latency_tot_max},
823 {"latency(#).tot.avg", sp_latency_tot_avg},
824 {"latency(#).tot.lost", sp_latency_tot_lost},
825 {"latency(#).tot.used", sp_latency_tot_used},
826 {"latency(#).tot.total", sp_latency_tot_total},
827 {"latency(#).stddev", sp_latency_stddev},
829 {"ring(#).used", sp_ring_used},
830 {"ring(#).free", sp_ring_free},
831 {"ring(#).size", sp_ring_size},
833 {"l4gen(#).created.tcp", sp_l4gen_created_tcp},
834 {"l4gen(#).created.udp", sp_l4gen_created_udp},
835 {"l4gen(#).created.all", sp_l4gen_created_all},
836 {"l4gen(#).created.bundles", sp_l4gen_created_bundles},
837 {"l4gen(#).torndown.no_retx", sp_l4gen_torndown_no_retx},
838 {"l4gen(#).torndown.retx", sp_l4gen_torndown_retx},
839 {"l4gen(#).torndown.udp", sp_l4gen_torndown_udp},
840 {"l4gen(#).expired.tcp", sp_l4gen_expire_tcp},
841 {"l4gen(#).expired.udp", sp_l4gen_expire_udp},
842 {"l4gen(#).created", sp_l4gen_created},
843 {"l4gen(#).finished", sp_l4gen_finished},
844 {"l4gen(#).retx", sp_l4gen_retx},
845 {"l4gen(#).tsc", sp_l4gen_tsc},
848 static int stats_parser_extract_args(char *stats_path, size_t *argc, char **argv)
850 size_t len = strlen(stats_path);
855 for (size_t i = 0; i < len; ++i) {
858 if (stats_path[i] == '(') {
862 else if (stats_path[i] == ')')
864 stats_path[j] = stats_path[i];
868 if (stats_path[i] == ')') {
877 argv[*argc][k++] = stats_path[i];
888 uint64_t stats_parser_get(const char *stats_path)
890 size_t stats_path_len;
892 char stats_path_cpy[128];
894 strncpy(stats_path_cpy, stats_path, sizeof(stats_path_cpy));
895 stats_path_len = strlen(stats_path);
897 size_t max_argc = 16;
899 char argv_data[16][16] = {{0}};
901 const char *argv_c[16];
903 for (size_t i = 0; i < 16; ++i) {
904 argv[i] = argv_data[i];
905 argv_c[i] = argv_data[i];
908 if (stats_parser_extract_args(stats_path_cpy, &argc, argv))
911 for (size_t i = 0; i < sizeof(stats_paths)/sizeof(stats_paths[0]); ++i) {
912 if (strcmp(stats_paths[i].str, stats_path_cpy) == 0) {
913 if (stats_paths[i].func == NULL)
915 return stats_paths[i].func(argc, argv_c);