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"
34 #include "prox_compat.h"
36 struct stats_path_str {
38 uint64_t (*func)(int argc, const char *argv[]);
41 static int args_to_core_task(const char *core_str, const char *task_str, uint32_t *lcore_id, uint32_t *task_id)
43 if (parse_list_set(lcore_id, core_str, 1) != 1)
45 *task_id = atoi(task_str);
50 static uint64_t sp_task_idle_cycles(int argc, const char *argv[])
52 struct task_stats_sample *last;
55 if (args_to_core_task(argv[0], argv[1], &c, &t))
57 return stats_get_task_stats_sample(c, t, 1)->tsc;
60 static uint64_t sp_task_rx_packets(int argc, const char *argv[])
62 struct task_stats_sample *last;
65 if (args_to_core_task(argv[0], argv[1], &c, &t))
67 return stats_get_task_stats_sample(c, t, 1)->rx_pkt_count;
70 static uint64_t sp_task_tx_packets(int argc, const char *argv[])
72 struct task_stats_sample *last;
75 if (args_to_core_task(argv[0], argv[1], &c, &t))
77 return stats_get_task_stats_sample(c, t, 1)->tx_pkt_count;
80 static uint64_t sp_task_drop_tx_fail(int argc, const char *argv[])
82 struct task_stats_sample *last;
85 if (args_to_core_task(argv[0], argv[1], &c, &t))
87 return stats_get_task_stats_sample(c, t, 1)->drop_tx_fail;
90 static uint64_t sp_task_drop_tx_fail_prio(int argc, const char *argv[])
92 struct task_stats_sample *last;
95 if (args_to_core_task(argv[0], argv[1], &c, &t))
97 if (stats_get_prio_task_stats_sample_by_core_task(c, t, 1))
98 return stats_get_prio_task_stats_sample_by_core_task(c, t, 1)->drop_tx_fail_prio[atoi(argv[2])];
103 static uint64_t sp_task_rx_prio(int argc, const char *argv[])
105 struct task_stats_sample *last;
108 if (args_to_core_task(argv[0], argv[1], &c, &t))
110 return stats_get_prio_task_stats_sample_by_core_task(c, t, 1)->rx_prio[atoi(argv[2])];
113 static uint64_t sp_task_max_irq(int argc, const char *argv[])
115 struct task_stats_sample *last;
118 if (args_to_core_task(argv[0], argv[1], &c, &t))
120 return get_max_irq_stats_by_core_task(c, t);
123 static uint64_t sp_task_irq(int argc, const char *argv[])
125 struct task_stats_sample *last;
128 if (args_to_core_task(argv[0], argv[1], &c, &t))
130 return get_irq_stats_by_core_task(c, t, atoi(argv[2]));
133 static uint64_t sp_task_drop_discard(int argc, const char *argv[])
135 struct task_stats_sample *last;
138 if (args_to_core_task(argv[0], argv[1], &c, &t))
140 return stats_get_task_stats_sample(c, t, 1)->drop_discard;
143 static uint64_t sp_task_drop_handled(int argc, const char *argv[])
145 struct task_stats_sample *last;
148 if (args_to_core_task(argv[0], argv[1], &c, &t))
150 return stats_get_task_stats_sample(c, t, 1)->drop_handled;
153 static uint64_t sp_task_rx_non_dp(int argc, const char *argv[])
155 struct task_stats_sample *last;
157 if (args_to_core_task(argv[0], argv[1], &c, &t))
159 return stats_get_task_stats_sample(c, t, 1)->rx_non_dp;
162 static uint64_t sp_task_tx_non_dp(int argc, const char *argv[])
164 struct task_stats_sample *last;
166 if (args_to_core_task(argv[0], argv[1], &c, &t))
168 return stats_get_task_stats_sample(c, t, 1)->tx_non_dp;
170 static uint64_t sp_task_rx_bytes(int argc, const char *argv[])
175 static uint64_t sp_task_tx_bytes(int argc, const char *argv[])
180 static uint64_t sp_task_tsc(int argc, const char *argv[])
182 struct task_stats_sample *last;
185 if (args_to_core_task(argv[0], argv[1], &c, &t))
187 return stats_get_task_stats_sample(c, t, 1)->tsc;
190 static uint64_t sp_l4gen_created(int argc, const char *argv[])
192 struct l4_stats_sample *clast = NULL;
194 if (atoi(argv[0]) >= stats_get_n_l4gen())
196 clast = stats_get_l4_stats_sample(atoi(argv[0]), 1);
197 return clast->stats.tcp_created + clast->stats.udp_created;
200 static uint64_t sp_l4gen_finished(int argc, const char *argv[])
202 struct l4_stats_sample *clast = NULL;
204 if (atoi(argv[0]) >= stats_get_n_l4gen())
206 clast = stats_get_l4_stats_sample(atoi(argv[0]), 1);
207 return clast->stats.tcp_finished_retransmit + clast->stats.tcp_finished_no_retransmit +
208 clast->stats.udp_finished + clast->stats.udp_expired + clast->stats.tcp_expired;
211 static uint64_t sp_l4gen_expire_tcp(int argc, const char *argv[])
213 struct l4_stats_sample *clast = NULL;
215 if (atoi(argv[0]) >= stats_get_n_l4gen())
217 clast = stats_get_l4_stats_sample(atoi(argv[0]), 1);
218 return clast->stats.tcp_expired;
221 static uint64_t sp_l4gen_expire_udp(int argc, const char *argv[])
223 struct l4_stats_sample *clast = NULL;
225 if (atoi(argv[0]) >= stats_get_n_l4gen())
227 clast = stats_get_l4_stats_sample(atoi(argv[0]), 1);
228 return clast->stats.udp_expired;
231 static uint64_t sp_l4gen_retx(int argc, const char *argv[])
233 struct l4_stats_sample *clast = NULL;
235 if (atoi(argv[0]) >= stats_get_n_l4gen())
237 clast = stats_get_l4_stats_sample(atoi(argv[0]), 1);
238 return clast->stats.tcp_retransmits;
241 static uint64_t sp_l4gen_tsc(int argc, const char *argv[])
243 struct l4_stats_sample *clast = NULL;
245 if (atoi(argv[0]) >= stats_get_n_l4gen())
247 clast = stats_get_l4_stats_sample(atoi(argv[0]), 1);
251 static uint64_t sp_l4gen_torndown_no_retx(int argc, const char *argv[])
253 struct l4_stats_sample *clast = NULL;
255 if (atoi(argv[0]) >= stats_get_n_l4gen())
257 clast = stats_get_l4_stats_sample(atoi(argv[0]), 1);
258 return clast->stats.tcp_finished_no_retransmit;
261 static uint64_t sp_l4gen_torndown_retx(int argc, const char *argv[])
263 struct l4_stats_sample *clast = NULL;
265 if (atoi(argv[0]) >= stats_get_n_l4gen())
267 clast = stats_get_l4_stats_sample(atoi(argv[0]), 1);
268 return clast->stats.tcp_finished_retransmit;
271 static uint64_t sp_l4gen_torndown_udp(int argc, const char *argv[])
273 struct l4_stats_sample *clast = NULL;
275 if (atoi(argv[0]) >= stats_get_n_l4gen())
277 clast = stats_get_l4_stats_sample(atoi(argv[0]), 1);
278 return clast->stats.udp_finished;
281 static uint64_t sp_l4gen_created_tcp(int argc, const char *argv[])
283 struct l4_stats_sample *clast = NULL;
285 if (atoi(argv[0]) >= stats_get_n_l4gen())
287 clast = stats_get_l4_stats_sample(atoi(argv[0]), 1);
288 return clast->stats.tcp_created;
292 static uint64_t sp_l4gen_created_udp(int argc, const char *argv[])
294 struct l4_stats_sample *clast = NULL;
296 if (atoi(argv[0]) >= stats_get_n_l4gen())
298 clast = stats_get_l4_stats_sample(atoi(argv[0]), 1);
299 return clast->stats.udp_created;
302 static uint64_t sp_l4gen_created_all(int argc, const char *argv[])
304 struct l4_stats_sample *clast = NULL;
306 if (atoi(argv[0]) >= stats_get_n_l4gen())
308 clast = stats_get_l4_stats_sample(atoi(argv[0]), 1);
309 return clast->stats.tcp_created + clast->stats.udp_created;
312 static uint64_t sp_l4gen_created_bundles(int argc, const char *argv[])
314 struct l4_stats_sample *clast = NULL;
316 if (atoi(argv[0]) >= stats_get_n_l4gen())
318 clast = stats_get_l4_stats_sample(atoi(argv[0]), 1);
319 return clast->stats.bundles_created;
322 static uint64_t sp_latency_min(int argc, const char *argv[])
324 struct stats_latency *lat_test = NULL;
326 if (atoi(argv[0]) >= stats_get_n_latency())
328 lat_test = stats_latency_get(atoi(argv[0]));
330 if (!lat_test->tot_packets)
333 struct time_unit tu = lat_test->min.time;
334 return time_unit_to_usec(&tu);
337 static uint64_t sp_mem_used(int argc, const char *argv[])
339 struct mempool_stats *ms;
341 if (atoi(argv[0]) > stats_get_n_mempools())
343 ms = stats_get_mempool_stats(atoi(argv[0]));
344 return ms->size - ms->free;
347 static uint64_t sp_mem_free(int argc, const char *argv[])
349 struct mempool_stats *ms;
351 if (atoi(argv[0]) > stats_get_n_mempools())
353 ms = stats_get_mempool_stats(atoi(argv[0]));
357 static uint64_t sp_mem_size(int argc, const char *argv[])
359 struct mempool_stats *ms;
361 if (atoi(argv[0]) > stats_get_n_mempools())
363 ms = stats_get_mempool_stats(atoi(argv[0]));
367 static uint64_t sp_port_no_mbufs(int argc, const char *argv[])
369 uint32_t port_id = atoi(argv[0]);
370 struct port_stats_sample *ps;
372 if (port_id > PROX_MAX_PORTS || !prox_port_cfg[port_id].active)
374 ps = stats_get_port_stats_sample(port_id, 1);
378 static uint64_t sp_port_ierrors(int argc, const char *argv[])
380 uint32_t port_id = atoi(argv[0]);
381 struct port_stats_sample *ps;
383 if (port_id > PROX_MAX_PORTS || !prox_port_cfg[port_id].active)
385 ps = stats_get_port_stats_sample(port_id, 1);
389 static uint64_t sp_port_imissed(int argc, const char *argv[])
391 uint32_t port_id = atoi(argv[0]);
392 struct port_stats_sample *ps;
394 if (port_id > PROX_MAX_PORTS || !prox_port_cfg[port_id].active)
396 ps = stats_get_port_stats_sample(port_id, 1);
400 static uint64_t sp_port_oerrors(int argc, const char *argv[])
402 uint32_t port_id = atoi(argv[0]);
403 struct port_stats_sample *ps;
405 if (port_id > PROX_MAX_PORTS || !prox_port_cfg[port_id].active)
407 ps = stats_get_port_stats_sample(port_id, 1);
411 static uint64_t sp_port_rx_packets(int argc, const char *argv[])
413 uint32_t port_id = atoi(argv[0]);
414 struct port_stats_sample *ps;
416 if (port_id > PROX_MAX_PORTS || !prox_port_cfg[port_id].active)
418 ps = stats_get_port_stats_sample(port_id, 1);
422 static uint64_t sp_port_tx_packets(int argc, const char *argv[])
424 uint32_t port_id = atoi(argv[0]);
425 struct port_stats_sample *ps;
427 if (port_id > PROX_MAX_PORTS || !prox_port_cfg[port_id].active)
429 ps = stats_get_port_stats_sample(port_id, 1);
433 static uint64_t sp_port_rx_bytes(int argc, const char *argv[])
435 uint32_t port_id = atoi(argv[0]);
436 struct port_stats_sample *ps;
438 if (port_id > PROX_MAX_PORTS || !prox_port_cfg[port_id].active)
440 ps = stats_get_port_stats_sample(port_id, 1);
444 static uint64_t sp_port_tx_bytes(int argc, const char *argv[])
446 uint32_t port_id = atoi(argv[0]);
447 struct port_stats_sample *ps;
449 if (port_id > PROX_MAX_PORTS || !prox_port_cfg[port_id].active)
451 ps = stats_get_port_stats_sample(port_id, 1);
455 static uint64_t sp_port_tx_packets_64(int argc, const char *argv[])
457 uint32_t port_id = atoi(argv[0]);
458 struct port_stats_sample *ps;
460 if (port_id > PROX_MAX_PORTS || !prox_port_cfg[port_id].active)
462 ps = stats_get_port_stats_sample(port_id, 1);
463 return ps->tx_pkt_size[PKT_SIZE_64];
466 static uint64_t sp_port_tx_packets_65_127(int argc, const char *argv[])
468 uint32_t port_id = atoi(argv[0]);
469 struct port_stats_sample *ps;
471 if (port_id > PROX_MAX_PORTS || !prox_port_cfg[port_id].active)
473 ps = stats_get_port_stats_sample(port_id, 1);
474 return ps->tx_pkt_size[PKT_SIZE_65];
477 static uint64_t sp_port_tx_packets_128_255(int argc, const char *argv[])
479 uint32_t port_id = atoi(argv[0]);
480 struct port_stats_sample *ps;
482 if (port_id > PROX_MAX_PORTS || !prox_port_cfg[port_id].active)
484 ps = stats_get_port_stats_sample(port_id, 1);
485 return ps->tx_pkt_size[PKT_SIZE_128];
488 static uint64_t sp_port_tx_packets_256_511(int argc, const char *argv[])
490 uint32_t port_id = atoi(argv[0]);
491 struct port_stats_sample *ps;
493 if (port_id > PROX_MAX_PORTS || !prox_port_cfg[port_id].active)
495 ps = stats_get_port_stats_sample(port_id, 1);
496 return ps->tx_pkt_size[PKT_SIZE_256];
499 static uint64_t sp_port_tx_packets_512_1023(int argc, const char *argv[])
501 uint32_t port_id = atoi(argv[0]);
502 struct port_stats_sample *ps;
504 if (port_id > PROX_MAX_PORTS || !prox_port_cfg[port_id].active)
506 ps = stats_get_port_stats_sample(port_id, 1);
507 return ps->tx_pkt_size[PKT_SIZE_512];
510 static uint64_t sp_port_tx_packets_1024_1522(int argc, const char *argv[])
512 uint32_t port_id = atoi(argv[0]);
513 struct port_stats_sample *ps;
515 if (port_id > PROX_MAX_PORTS || !prox_port_cfg[port_id].active)
517 ps = stats_get_port_stats_sample(port_id, 1);
518 return ps->tx_pkt_size[PKT_SIZE_1024];
521 static uint64_t sp_port_tx_packets_1523_max(int argc, const char *argv[])
523 uint32_t port_id = atoi(argv[0]);
524 struct port_stats_sample *ps;
526 if (port_id > PROX_MAX_PORTS || !prox_port_cfg[port_id].active)
528 ps = stats_get_port_stats_sample(port_id, 1);
529 return ps->tx_pkt_size[PKT_SIZE_1522];
532 static uint64_t sp_port_tsc(int argc, const char *argv[])
534 uint32_t port_id = atoi(argv[0]);
535 struct port_stats_sample *ps;
537 if (port_id > PROX_MAX_PORTS || !prox_port_cfg[port_id].active)
539 ps = stats_get_port_stats_sample(port_id, 1);
543 static uint64_t sp_latency_max(int argc, const char *argv[])
545 struct stats_latency *lat_test = NULL;
547 if (atoi(argv[0]) >= stats_get_n_latency())
549 lat_test = stats_latency_get(atoi(argv[0]));
551 if (!lat_test->tot_packets)
554 struct time_unit tu = lat_test->max.time;
555 return time_unit_to_usec(&tu);
558 static uint64_t sp_latency_avg(int argc, const char *argv[])
560 struct stats_latency *lat_test = NULL;
562 if (atoi(argv[0]) >= stats_get_n_latency())
564 lat_test = stats_latency_get(atoi(argv[0]));
566 if (!lat_test->tot_packets)
569 struct time_unit tu = lat_test->avg.time;
570 return time_unit_to_usec(&tu);
573 static uint64_t sp_latency_lost(int argc, const char *argv[])
575 struct stats_latency *lat_test = NULL;
577 if (atoi(argv[0]) >= stats_get_n_latency())
579 lat_test = stats_latency_get(atoi(argv[0]));
581 if (!lat_test->tot_packets)
584 return lat_test->lost_packets;
587 static uint64_t sp_latency_tot_lost(int argc, const char *argv[])
589 struct stats_latency *lat_test = NULL;
591 if (atoi(argv[0]) >= stats_get_n_latency())
593 lat_test = stats_latency_tot_get(atoi(argv[0]));
595 if (!lat_test->tot_packets)
598 return lat_test->lost_packets;
601 static uint64_t sp_latency_total(int argc, const char *argv[])
603 struct stats_latency *lat_test = NULL;
605 if (atoi(argv[0]) >= stats_get_n_latency())
607 lat_test = stats_latency_get(atoi(argv[0]));
609 if (!lat_test->tot_all_packets)
612 return lat_test->tot_all_packets;
615 static uint64_t sp_latency_used(int argc, const char *argv[])
617 struct stats_latency *lat_test = NULL;
619 if (atoi(argv[0]) >= stats_get_n_latency())
621 lat_test = stats_latency_get(atoi(argv[0]));
623 if (!lat_test->tot_all_packets)
626 return lat_test->tot_packets;
629 static uint64_t sp_latency_tot_total(int argc, const char *argv[])
631 struct stats_latency *lat_test = NULL;
633 if (atoi(argv[0]) >= stats_get_n_latency())
635 lat_test = stats_latency_tot_get(atoi(argv[0]));
637 if (!lat_test->tot_all_packets)
640 return lat_test->tot_all_packets;
643 static uint64_t sp_latency_tot_used(int argc, const char *argv[])
645 struct stats_latency *lat_test = NULL;
647 if (atoi(argv[0]) >= stats_get_n_latency())
649 lat_test = stats_latency_tot_get(atoi(argv[0]));
651 if (!lat_test->tot_all_packets)
654 return lat_test->tot_packets;
657 static uint64_t sp_latency_tot_min(int argc, const char *argv[])
659 struct stats_latency *lat_test = NULL;
661 if (atoi(argv[0]) >= stats_get_n_latency())
663 lat_test = stats_latency_tot_get(atoi(argv[0]));
665 if (!lat_test->tot_packets)
668 struct time_unit tu = lat_test->min.time;
669 return time_unit_to_usec(&tu);
672 static uint64_t sp_latency_tot_max(int argc, const char *argv[])
674 struct stats_latency *lat_test = NULL;
676 if (atoi(argv[0]) >= stats_get_n_latency())
678 lat_test = stats_latency_tot_get(atoi(argv[0]));
680 if (!lat_test->tot_packets)
683 struct time_unit tu = lat_test->max.time;
684 return time_unit_to_usec(&tu);
687 static uint64_t sp_latency_tot_avg(int argc, const char *argv[])
689 struct stats_latency *lat_test = NULL;
691 if (atoi(argv[0]) >= stats_get_n_latency())
693 lat_test = stats_latency_tot_get(atoi(argv[0]));
695 if (!lat_test->tot_packets)
698 struct time_unit tu = lat_test->avg.time;
699 return time_unit_to_usec(&tu);
702 static uint64_t sp_latency_stddev(int argc, const char *argv[])
704 struct stats_latency *lat_test = NULL;
706 if (atoi(argv[0]) >= stats_get_n_latency())
708 lat_test = stats_latency_get(atoi(argv[0]));
710 if (!lat_test->tot_packets)
713 struct time_unit tu = lat_test->stddev.time;
714 return time_unit_to_usec(&tu);
717 static uint64_t sp_ring_used(int argc, const char *argv[])
719 struct ring_stats *rs = NULL;
721 if (atoi(argv[0]) >= stats_get_n_rings())
723 rs = stats_get_ring_stats(atoi(argv[0]));
724 return rs->size - rs->free;
727 static uint64_t sp_ring_free(int argc, const char *argv[])
729 struct ring_stats *rs = NULL;
731 if (atoi(argv[0]) >= stats_get_n_rings())
733 rs = stats_get_ring_stats(atoi(argv[0]));
737 static uint64_t sp_ring_size(int argc, const char *argv[])
739 struct ring_stats *rs = NULL;
741 if (atoi(argv[0]) >= stats_get_n_rings())
743 rs = stats_get_ring_stats(atoi(argv[0]));
747 static uint64_t sp_global_host_rx_packets(int argc, const char *argv[])
749 return stats_get_global_stats(1)->host_rx_packets;
752 static uint64_t sp_global_host_tx_packets(int argc, const char *argv[])
754 return stats_get_global_stats(1)->host_tx_packets;
757 static uint64_t sp_global_nics_rx_packets(int argc, const char *argv[])
759 return stats_get_global_stats(1)->nics_rx_packets;
762 static uint64_t sp_global_nics_tx_packets(int argc, const char *argv[])
764 return stats_get_global_stats(1)->nics_tx_packets;
767 static uint64_t sp_global_nics_ierrors(int argc, const char *argv[])
769 return stats_get_global_stats(1)->nics_ierrors;
772 static uint64_t sp_global_nics_imissed(int argc, const char *argv[])
774 return stats_get_global_stats(1)->nics_imissed;
777 static uint64_t sp_global_tsc(int argc, const char *argv[])
779 return stats_get_global_stats(1)->tsc;
782 static uint64_t sp_hz(int argc, const char *argv[])
784 return rte_get_tsc_hz();
787 struct stats_path_str stats_paths[] = {
790 {"global.host.rx.packets", sp_global_host_rx_packets},
791 {"global.host.tx.packets", sp_global_host_tx_packets},
792 {"global.nics.rx.packets", sp_global_nics_rx_packets},
793 {"global.nics.tx.packets", sp_global_nics_tx_packets},
794 {"global.nics.ierrrors", sp_global_nics_ierrors},
795 {"global.nics.imissed", sp_global_nics_imissed},
796 {"global.tsc", sp_global_tsc},
798 {"task.core(#).task(#).idle_cycles", sp_task_idle_cycles},
799 {"task.core(#).task(#).rx.packets", sp_task_rx_packets},
800 {"task.core(#).task(#).tx.packets", sp_task_tx_packets},
801 {"task.core(#).task(#).drop.tx_fail", sp_task_drop_tx_fail},
802 {"task.core(#).task(#).drop.discard", sp_task_drop_discard},
803 {"task.core(#).task(#).drop.handled", sp_task_drop_handled},
804 {"task.core(#).task(#).rx.bytes", sp_task_rx_bytes},
805 {"task.core(#).task(#).tx.bytes", sp_task_tx_bytes},
806 {"task.core(#).task(#).tsc", sp_task_tsc},
807 {"task.core(#).task(#).drop.tx_fail_prio(#)", sp_task_drop_tx_fail_prio},
808 {"task.core(#).task(#).rx_prio(#)", sp_task_rx_prio},
809 {"task.core(#).task(#).max_irq", sp_task_max_irq},
810 {"task.core(#).task(#).irq(#)", sp_task_irq},
811 {"task.core(#).task(#).rx_non_dp", sp_task_rx_non_dp},
812 {"task.core(#).task(#).tx_non_dp", sp_task_tx_non_dp},
814 {"port(#).no_mbufs", sp_port_no_mbufs},
815 {"port(#).ierrors", sp_port_ierrors},
816 {"port(#).imissed", sp_port_imissed},
817 {"port(#).oerrors", sp_port_oerrors},
818 {"port(#).rx.packets", sp_port_rx_packets},
819 {"port(#).tx.packets", sp_port_tx_packets},
820 {"port(#).rx.bytes", sp_port_rx_bytes},
821 {"port(#).tx.bytes", sp_port_tx_bytes},
822 {"port(#).tx.packets_64", sp_port_tx_packets_64},
823 {"port(#).tx.packets_65_127", sp_port_tx_packets_65_127},
824 {"port(#).tx.packets_128_255", sp_port_tx_packets_128_255},
825 {"port(#).tx.packets_256_511", sp_port_tx_packets_256_511},
826 {"port(#).tx.packets_512_1023", sp_port_tx_packets_512_1023},
827 {"port(#).tx.packets_1024_1522", sp_port_tx_packets_1024_1522},
828 {"port(#).tx.packets_1523_max", sp_port_tx_packets_1523_max},
829 {"port(#).tsc", sp_port_tsc},
831 {"mem(#).used", sp_mem_used},
832 {"mem(#).free", sp_mem_free},
833 {"mem(#).size", sp_mem_size},
835 {"latency(#).min", sp_latency_min},
836 {"latency(#).max", sp_latency_max},
837 {"latency(#).avg", sp_latency_avg},
838 {"latency(#).lost", sp_latency_lost},
839 {"latency(#).used", sp_latency_used},
840 {"latency(#).total", sp_latency_total},
841 {"latency(#).tot.min", sp_latency_tot_min},
842 {"latency(#).tot.max", sp_latency_tot_max},
843 {"latency(#).tot.avg", sp_latency_tot_avg},
844 {"latency(#).tot.lost", sp_latency_tot_lost},
845 {"latency(#).tot.used", sp_latency_tot_used},
846 {"latency(#).tot.total", sp_latency_tot_total},
847 {"latency(#).stddev", sp_latency_stddev},
849 {"ring(#).used", sp_ring_used},
850 {"ring(#).free", sp_ring_free},
851 {"ring(#).size", sp_ring_size},
853 {"l4gen(#).created.tcp", sp_l4gen_created_tcp},
854 {"l4gen(#).created.udp", sp_l4gen_created_udp},
855 {"l4gen(#).created.all", sp_l4gen_created_all},
856 {"l4gen(#).created.bundles", sp_l4gen_created_bundles},
857 {"l4gen(#).torndown.no_retx", sp_l4gen_torndown_no_retx},
858 {"l4gen(#).torndown.retx", sp_l4gen_torndown_retx},
859 {"l4gen(#).torndown.udp", sp_l4gen_torndown_udp},
860 {"l4gen(#).expired.tcp", sp_l4gen_expire_tcp},
861 {"l4gen(#).expired.udp", sp_l4gen_expire_udp},
862 {"l4gen(#).created", sp_l4gen_created},
863 {"l4gen(#).finished", sp_l4gen_finished},
864 {"l4gen(#).retx", sp_l4gen_retx},
865 {"l4gen(#).tsc", sp_l4gen_tsc},
868 static int stats_parser_extract_args(char *stats_path, size_t *argc, char **argv)
870 size_t len = strlen(stats_path);
875 for (size_t i = 0; i < len; ++i) {
878 if (stats_path[i] == '(') {
882 else if (stats_path[i] == ')')
884 stats_path[j] = stats_path[i];
888 if (stats_path[i] == ')') {
897 argv[*argc][k++] = stats_path[i];
908 uint64_t stats_parser_get(const char *stats_path)
910 size_t stats_path_len;
912 char stats_path_cpy[128];
914 prox_strncpy(stats_path_cpy, stats_path, sizeof(stats_path_cpy));
915 stats_path_len = strlen(stats_path);
917 size_t max_argc = 16;
919 char argv_data[16][16] = {{0}};
921 const char *argv_c[16];
923 for (size_t i = 0; i < 16; ++i) {
924 argv[i] = argv_data[i];
925 argv_c[i] = argv_data[i];
928 if (stats_parser_extract_args(stats_path_cpy, &argc, argv))
931 for (size_t i = 0; i < sizeof(stats_paths)/sizeof(stats_paths[0]); ++i) {
932 if (strcmp(stats_paths[i].str, stats_path_cpy) == 0) {
933 if (stats_paths[i].func == NULL)
935 return stats_paths[i].func(argc, argv_c);