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_non_dp(int argc, const char *argv[])
154 struct task_stats_sample *last;
156 if (args_to_core_task(argv[0], argv[1], &c, &t))
158 return stats_get_task_stats_sample(c, t, 1)->rx_non_dp;
161 static uint64_t sp_task_tx_non_dp(int argc, const char *argv[])
163 struct task_stats_sample *last;
165 if (args_to_core_task(argv[0], argv[1], &c, &t))
167 return stats_get_task_stats_sample(c, t, 1)->tx_non_dp;
169 static uint64_t sp_task_rx_bytes(int argc, const char *argv[])
174 static uint64_t sp_task_tx_bytes(int argc, const char *argv[])
179 static uint64_t sp_task_tsc(int argc, const char *argv[])
181 struct task_stats_sample *last;
184 if (args_to_core_task(argv[0], argv[1], &c, &t))
186 return stats_get_task_stats_sample(c, t, 1)->tsc;
189 static uint64_t sp_l4gen_created(int argc, const char *argv[])
191 struct l4_stats_sample *clast = NULL;
193 if (atoi(argv[0]) >= stats_get_n_l4gen())
195 clast = stats_get_l4_stats_sample(atoi(argv[0]), 1);
196 return clast->stats.tcp_created + clast->stats.udp_created;
199 static uint64_t sp_l4gen_finished(int argc, const char *argv[])
201 struct l4_stats_sample *clast = NULL;
203 if (atoi(argv[0]) >= stats_get_n_l4gen())
205 clast = stats_get_l4_stats_sample(atoi(argv[0]), 1);
206 return clast->stats.tcp_finished_retransmit + clast->stats.tcp_finished_no_retransmit +
207 clast->stats.udp_finished + clast->stats.udp_expired + clast->stats.tcp_expired;
210 static uint64_t sp_l4gen_expire_tcp(int argc, const char *argv[])
212 struct l4_stats_sample *clast = NULL;
214 if (atoi(argv[0]) >= stats_get_n_l4gen())
216 clast = stats_get_l4_stats_sample(atoi(argv[0]), 1);
217 return clast->stats.tcp_expired;
220 static uint64_t sp_l4gen_expire_udp(int argc, const char *argv[])
222 struct l4_stats_sample *clast = NULL;
224 if (atoi(argv[0]) >= stats_get_n_l4gen())
226 clast = stats_get_l4_stats_sample(atoi(argv[0]), 1);
227 return clast->stats.udp_expired;
230 static uint64_t sp_l4gen_retx(int argc, const char *argv[])
232 struct l4_stats_sample *clast = NULL;
234 if (atoi(argv[0]) >= stats_get_n_l4gen())
236 clast = stats_get_l4_stats_sample(atoi(argv[0]), 1);
237 return clast->stats.tcp_retransmits;
240 static uint64_t sp_l4gen_tsc(int argc, const char *argv[])
242 struct l4_stats_sample *clast = NULL;
244 if (atoi(argv[0]) >= stats_get_n_l4gen())
246 clast = stats_get_l4_stats_sample(atoi(argv[0]), 1);
250 static uint64_t sp_l4gen_torndown_no_retx(int argc, const char *argv[])
252 struct l4_stats_sample *clast = NULL;
254 if (atoi(argv[0]) >= stats_get_n_l4gen())
256 clast = stats_get_l4_stats_sample(atoi(argv[0]), 1);
257 return clast->stats.tcp_finished_no_retransmit;
260 static uint64_t sp_l4gen_torndown_retx(int argc, const char *argv[])
262 struct l4_stats_sample *clast = NULL;
264 if (atoi(argv[0]) >= stats_get_n_l4gen())
266 clast = stats_get_l4_stats_sample(atoi(argv[0]), 1);
267 return clast->stats.tcp_finished_retransmit;
270 static uint64_t sp_l4gen_torndown_udp(int argc, const char *argv[])
272 struct l4_stats_sample *clast = NULL;
274 if (atoi(argv[0]) >= stats_get_n_l4gen())
276 clast = stats_get_l4_stats_sample(atoi(argv[0]), 1);
277 return clast->stats.udp_finished;
280 static uint64_t sp_l4gen_created_tcp(int argc, const char *argv[])
282 struct l4_stats_sample *clast = NULL;
284 if (atoi(argv[0]) >= stats_get_n_l4gen())
286 clast = stats_get_l4_stats_sample(atoi(argv[0]), 1);
287 return clast->stats.tcp_created;
291 static uint64_t sp_l4gen_created_udp(int argc, const char *argv[])
293 struct l4_stats_sample *clast = NULL;
295 if (atoi(argv[0]) >= stats_get_n_l4gen())
297 clast = stats_get_l4_stats_sample(atoi(argv[0]), 1);
298 return clast->stats.udp_created;
301 static uint64_t sp_l4gen_created_all(int argc, const char *argv[])
303 struct l4_stats_sample *clast = NULL;
305 if (atoi(argv[0]) >= stats_get_n_l4gen())
307 clast = stats_get_l4_stats_sample(atoi(argv[0]), 1);
308 return clast->stats.tcp_created + clast->stats.udp_created;
311 static uint64_t sp_l4gen_created_bundles(int argc, const char *argv[])
313 struct l4_stats_sample *clast = NULL;
315 if (atoi(argv[0]) >= stats_get_n_l4gen())
317 clast = stats_get_l4_stats_sample(atoi(argv[0]), 1);
318 return clast->stats.bundles_created;
321 static uint64_t sp_latency_min(int argc, const char *argv[])
323 struct stats_latency *lat_test = NULL;
325 if (atoi(argv[0]) >= stats_get_n_latency())
327 lat_test = stats_latency_get(atoi(argv[0]));
329 if (!lat_test->tot_packets)
332 struct time_unit tu = lat_test->min.time;
333 return time_unit_to_usec(&tu);
336 static uint64_t sp_mem_used(int argc, const char *argv[])
338 struct mempool_stats *ms;
340 if (atoi(argv[0]) > stats_get_n_mempools())
342 ms = stats_get_mempool_stats(atoi(argv[0]));
343 return ms->size - ms->free;
346 static uint64_t sp_mem_free(int argc, const char *argv[])
348 struct mempool_stats *ms;
350 if (atoi(argv[0]) > stats_get_n_mempools())
352 ms = stats_get_mempool_stats(atoi(argv[0]));
356 static uint64_t sp_mem_size(int argc, const char *argv[])
358 struct mempool_stats *ms;
360 if (atoi(argv[0]) > stats_get_n_mempools())
362 ms = stats_get_mempool_stats(atoi(argv[0]));
366 static uint64_t sp_port_no_mbufs(int argc, const char *argv[])
368 uint32_t port_id = atoi(argv[0]);
369 struct port_stats_sample *ps;
371 if (port_id > PROX_MAX_PORTS || !prox_port_cfg[port_id].active)
373 ps = stats_get_port_stats_sample(port_id, 1);
377 static uint64_t sp_port_ierrors(int argc, const char *argv[])
379 uint32_t port_id = atoi(argv[0]);
380 struct port_stats_sample *ps;
382 if (port_id > PROX_MAX_PORTS || !prox_port_cfg[port_id].active)
384 ps = stats_get_port_stats_sample(port_id, 1);
388 static uint64_t sp_port_imissed(int argc, const char *argv[])
390 uint32_t port_id = atoi(argv[0]);
391 struct port_stats_sample *ps;
393 if (port_id > PROX_MAX_PORTS || !prox_port_cfg[port_id].active)
395 ps = stats_get_port_stats_sample(port_id, 1);
399 static uint64_t sp_port_oerrors(int argc, const char *argv[])
401 uint32_t port_id = atoi(argv[0]);
402 struct port_stats_sample *ps;
404 if (port_id > PROX_MAX_PORTS || !prox_port_cfg[port_id].active)
406 ps = stats_get_port_stats_sample(port_id, 1);
410 static uint64_t sp_port_rx_packets(int argc, const char *argv[])
412 uint32_t port_id = atoi(argv[0]);
413 struct port_stats_sample *ps;
415 if (port_id > PROX_MAX_PORTS || !prox_port_cfg[port_id].active)
417 ps = stats_get_port_stats_sample(port_id, 1);
421 static uint64_t sp_port_tx_packets(int argc, const char *argv[])
423 uint32_t port_id = atoi(argv[0]);
424 struct port_stats_sample *ps;
426 if (port_id > PROX_MAX_PORTS || !prox_port_cfg[port_id].active)
428 ps = stats_get_port_stats_sample(port_id, 1);
432 static uint64_t sp_port_rx_bytes(int argc, const char *argv[])
434 uint32_t port_id = atoi(argv[0]);
435 struct port_stats_sample *ps;
437 if (port_id > PROX_MAX_PORTS || !prox_port_cfg[port_id].active)
439 ps = stats_get_port_stats_sample(port_id, 1);
443 static uint64_t sp_port_tx_bytes(int argc, const char *argv[])
445 uint32_t port_id = atoi(argv[0]);
446 struct port_stats_sample *ps;
448 if (port_id > PROX_MAX_PORTS || !prox_port_cfg[port_id].active)
450 ps = stats_get_port_stats_sample(port_id, 1);
454 static uint64_t sp_port_tx_packets_64(int argc, const char *argv[])
456 uint32_t port_id = atoi(argv[0]);
457 struct port_stats_sample *ps;
459 if (port_id > PROX_MAX_PORTS || !prox_port_cfg[port_id].active)
461 ps = stats_get_port_stats_sample(port_id, 1);
462 return ps->tx_pkt_size[PKT_SIZE_64];
465 static uint64_t sp_port_tx_packets_65_127(int argc, const char *argv[])
467 uint32_t port_id = atoi(argv[0]);
468 struct port_stats_sample *ps;
470 if (port_id > PROX_MAX_PORTS || !prox_port_cfg[port_id].active)
472 ps = stats_get_port_stats_sample(port_id, 1);
473 return ps->tx_pkt_size[PKT_SIZE_65];
476 static uint64_t sp_port_tx_packets_128_255(int argc, const char *argv[])
478 uint32_t port_id = atoi(argv[0]);
479 struct port_stats_sample *ps;
481 if (port_id > PROX_MAX_PORTS || !prox_port_cfg[port_id].active)
483 ps = stats_get_port_stats_sample(port_id, 1);
484 return ps->tx_pkt_size[PKT_SIZE_128];
487 static uint64_t sp_port_tx_packets_256_511(int argc, const char *argv[])
489 uint32_t port_id = atoi(argv[0]);
490 struct port_stats_sample *ps;
492 if (port_id > PROX_MAX_PORTS || !prox_port_cfg[port_id].active)
494 ps = stats_get_port_stats_sample(port_id, 1);
495 return ps->tx_pkt_size[PKT_SIZE_256];
498 static uint64_t sp_port_tx_packets_512_1023(int argc, const char *argv[])
500 uint32_t port_id = atoi(argv[0]);
501 struct port_stats_sample *ps;
503 if (port_id > PROX_MAX_PORTS || !prox_port_cfg[port_id].active)
505 ps = stats_get_port_stats_sample(port_id, 1);
506 return ps->tx_pkt_size[PKT_SIZE_512];
509 static uint64_t sp_port_tx_packets_1024_1522(int argc, const char *argv[])
511 uint32_t port_id = atoi(argv[0]);
512 struct port_stats_sample *ps;
514 if (port_id > PROX_MAX_PORTS || !prox_port_cfg[port_id].active)
516 ps = stats_get_port_stats_sample(port_id, 1);
517 return ps->tx_pkt_size[PKT_SIZE_1024];
520 static uint64_t sp_port_tx_packets_1523_max(int argc, const char *argv[])
522 uint32_t port_id = atoi(argv[0]);
523 struct port_stats_sample *ps;
525 if (port_id > PROX_MAX_PORTS || !prox_port_cfg[port_id].active)
527 ps = stats_get_port_stats_sample(port_id, 1);
528 return ps->tx_pkt_size[PKT_SIZE_1522];
531 static uint64_t sp_port_tsc(int argc, const char *argv[])
533 uint32_t port_id = atoi(argv[0]);
534 struct port_stats_sample *ps;
536 if (port_id > PROX_MAX_PORTS || !prox_port_cfg[port_id].active)
538 ps = stats_get_port_stats_sample(port_id, 1);
542 static uint64_t sp_latency_max(int argc, const char *argv[])
544 struct stats_latency *lat_test = NULL;
546 if (atoi(argv[0]) >= stats_get_n_latency())
548 lat_test = stats_latency_get(atoi(argv[0]));
550 if (!lat_test->tot_packets)
553 struct time_unit tu = lat_test->max.time;
554 return time_unit_to_usec(&tu);
557 static uint64_t sp_latency_avg(int argc, const char *argv[])
559 struct stats_latency *lat_test = NULL;
561 if (atoi(argv[0]) >= stats_get_n_latency())
563 lat_test = stats_latency_get(atoi(argv[0]));
565 if (!lat_test->tot_packets)
568 struct time_unit tu = lat_test->avg.time;
569 return time_unit_to_usec(&tu);
572 static uint64_t sp_latency_lost(int argc, const char *argv[])
574 struct stats_latency *lat_test = NULL;
576 if (atoi(argv[0]) >= stats_get_n_latency())
578 lat_test = stats_latency_get(atoi(argv[0]));
580 if (!lat_test->tot_packets)
583 return lat_test->lost_packets;
586 static uint64_t sp_latency_tot_lost(int argc, const char *argv[])
588 struct stats_latency *lat_test = NULL;
590 if (atoi(argv[0]) >= stats_get_n_latency())
592 lat_test = stats_latency_tot_get(atoi(argv[0]));
594 if (!lat_test->tot_packets)
597 return lat_test->lost_packets;
600 static uint64_t sp_latency_total(int argc, const char *argv[])
602 struct stats_latency *lat_test = NULL;
604 if (atoi(argv[0]) >= stats_get_n_latency())
606 lat_test = stats_latency_get(atoi(argv[0]));
608 if (!lat_test->tot_all_packets)
611 return lat_test->tot_all_packets;
614 static uint64_t sp_latency_used(int argc, const char *argv[])
616 struct stats_latency *lat_test = NULL;
618 if (atoi(argv[0]) >= stats_get_n_latency())
620 lat_test = stats_latency_get(atoi(argv[0]));
622 if (!lat_test->tot_all_packets)
625 return lat_test->tot_packets;
628 static uint64_t sp_latency_tot_total(int argc, const char *argv[])
630 struct stats_latency *lat_test = NULL;
632 if (atoi(argv[0]) >= stats_get_n_latency())
634 lat_test = stats_latency_tot_get(atoi(argv[0]));
636 if (!lat_test->tot_all_packets)
639 return lat_test->tot_all_packets;
642 static uint64_t sp_latency_tot_used(int argc, const char *argv[])
644 struct stats_latency *lat_test = NULL;
646 if (atoi(argv[0]) >= stats_get_n_latency())
648 lat_test = stats_latency_tot_get(atoi(argv[0]));
650 if (!lat_test->tot_all_packets)
653 return lat_test->tot_packets;
656 static uint64_t sp_latency_tot_min(int argc, const char *argv[])
658 struct stats_latency *lat_test = NULL;
660 if (atoi(argv[0]) >= stats_get_n_latency())
662 lat_test = stats_latency_tot_get(atoi(argv[0]));
664 if (!lat_test->tot_packets)
667 struct time_unit tu = lat_test->min.time;
668 return time_unit_to_usec(&tu);
671 static uint64_t sp_latency_tot_max(int argc, const char *argv[])
673 struct stats_latency *lat_test = NULL;
675 if (atoi(argv[0]) >= stats_get_n_latency())
677 lat_test = stats_latency_tot_get(atoi(argv[0]));
679 if (!lat_test->tot_packets)
682 struct time_unit tu = lat_test->max.time;
683 return time_unit_to_usec(&tu);
686 static uint64_t sp_latency_tot_avg(int argc, const char *argv[])
688 struct stats_latency *lat_test = NULL;
690 if (atoi(argv[0]) >= stats_get_n_latency())
692 lat_test = stats_latency_tot_get(atoi(argv[0]));
694 if (!lat_test->tot_packets)
697 struct time_unit tu = lat_test->avg.time;
698 return time_unit_to_usec(&tu);
701 static uint64_t sp_latency_stddev(int argc, const char *argv[])
703 struct stats_latency *lat_test = NULL;
705 if (atoi(argv[0]) >= stats_get_n_latency())
707 lat_test = stats_latency_get(atoi(argv[0]));
709 if (!lat_test->tot_packets)
712 struct time_unit tu = lat_test->stddev.time;
713 return time_unit_to_usec(&tu);
716 static uint64_t sp_ring_used(int argc, const char *argv[])
718 struct ring_stats *rs = NULL;
720 if (atoi(argv[0]) >= stats_get_n_rings())
722 rs = stats_get_ring_stats(atoi(argv[0]));
723 return rs->size - rs->free;
726 static uint64_t sp_ring_free(int argc, const char *argv[])
728 struct ring_stats *rs = NULL;
730 if (atoi(argv[0]) >= stats_get_n_rings())
732 rs = stats_get_ring_stats(atoi(argv[0]));
736 static uint64_t sp_ring_size(int argc, const char *argv[])
738 struct ring_stats *rs = NULL;
740 if (atoi(argv[0]) >= stats_get_n_rings())
742 rs = stats_get_ring_stats(atoi(argv[0]));
746 static uint64_t sp_global_host_rx_packets(int argc, const char *argv[])
748 return stats_get_global_stats(1)->host_rx_packets;
751 static uint64_t sp_global_host_tx_packets(int argc, const char *argv[])
753 return stats_get_global_stats(1)->host_tx_packets;
756 static uint64_t sp_global_nics_rx_packets(int argc, const char *argv[])
758 return stats_get_global_stats(1)->nics_rx_packets;
761 static uint64_t sp_global_nics_tx_packets(int argc, const char *argv[])
763 return stats_get_global_stats(1)->nics_tx_packets;
766 static uint64_t sp_global_nics_ierrors(int argc, const char *argv[])
768 return stats_get_global_stats(1)->nics_ierrors;
771 static uint64_t sp_global_nics_imissed(int argc, const char *argv[])
773 return stats_get_global_stats(1)->nics_imissed;
776 static uint64_t sp_global_tsc(int argc, const char *argv[])
778 return stats_get_global_stats(1)->tsc;
781 static uint64_t sp_hz(int argc, const char *argv[])
783 return rte_get_tsc_hz();
786 struct stats_path_str stats_paths[] = {
789 {"global.host.rx.packets", sp_global_host_rx_packets},
790 {"global.host.tx.packets", sp_global_host_tx_packets},
791 {"global.nics.rx.packets", sp_global_nics_rx_packets},
792 {"global.nics.tx.packets", sp_global_nics_tx_packets},
793 {"global.nics.ierrrors", sp_global_nics_ierrors},
794 {"global.nics.imissed", sp_global_nics_imissed},
795 {"global.tsc", sp_global_tsc},
797 {"task.core(#).task(#).idle_cycles", sp_task_idle_cycles},
798 {"task.core(#).task(#).rx.packets", sp_task_rx_packets},
799 {"task.core(#).task(#).tx.packets", sp_task_tx_packets},
800 {"task.core(#).task(#).drop.tx_fail", sp_task_drop_tx_fail},
801 {"task.core(#).task(#).drop.discard", sp_task_drop_discard},
802 {"task.core(#).task(#).drop.handled", sp_task_drop_handled},
803 {"task.core(#).task(#).rx.bytes", sp_task_rx_bytes},
804 {"task.core(#).task(#).tx.bytes", sp_task_tx_bytes},
805 {"task.core(#).task(#).tsc", sp_task_tsc},
806 {"task.core(#).task(#).drop.tx_fail_prio(#)", sp_task_drop_tx_fail_prio},
807 {"task.core(#).task(#).rx_prio(#)", sp_task_rx_prio},
808 {"task.core(#).task(#).max_irq", sp_task_max_irq},
809 {"task.core(#).task(#).irq(#)", sp_task_irq},
810 {"task.core(#).task(#).rx_non_dp", sp_task_rx_non_dp},
811 {"task.core(#).task(#).tx_non_dp", sp_task_tx_non_dp},
813 {"port(#).no_mbufs", sp_port_no_mbufs},
814 {"port(#).ierrors", sp_port_ierrors},
815 {"port(#).imissed", sp_port_imissed},
816 {"port(#).oerrors", sp_port_oerrors},
817 {"port(#).rx.packets", sp_port_rx_packets},
818 {"port(#).tx.packets", sp_port_tx_packets},
819 {"port(#).rx.bytes", sp_port_rx_bytes},
820 {"port(#).tx.bytes", sp_port_tx_bytes},
821 {"port(#).tx.packets_64", sp_port_tx_packets_64},
822 {"port(#).tx.packets_65_127", sp_port_tx_packets_65_127},
823 {"port(#).tx.packets_128_255", sp_port_tx_packets_128_255},
824 {"port(#).tx.packets_256_511", sp_port_tx_packets_256_511},
825 {"port(#).tx.packets_512_1023", sp_port_tx_packets_512_1023},
826 {"port(#).tx.packets_1024_1522", sp_port_tx_packets_1024_1522},
827 {"port(#).tx.packets_1523_max", sp_port_tx_packets_1523_max},
828 {"port(#).tsc", sp_port_tsc},
830 {"mem(#).used", sp_mem_used},
831 {"mem(#).free", sp_mem_free},
832 {"mem(#).size", sp_mem_size},
834 {"latency(#).min", sp_latency_min},
835 {"latency(#).max", sp_latency_max},
836 {"latency(#).avg", sp_latency_avg},
837 {"latency(#).lost", sp_latency_lost},
838 {"latency(#).used", sp_latency_used},
839 {"latency(#).total", sp_latency_total},
840 {"latency(#).tot.min", sp_latency_tot_min},
841 {"latency(#).tot.max", sp_latency_tot_max},
842 {"latency(#).tot.avg", sp_latency_tot_avg},
843 {"latency(#).tot.lost", sp_latency_tot_lost},
844 {"latency(#).tot.used", sp_latency_tot_used},
845 {"latency(#).tot.total", sp_latency_tot_total},
846 {"latency(#).stddev", sp_latency_stddev},
848 {"ring(#).used", sp_ring_used},
849 {"ring(#).free", sp_ring_free},
850 {"ring(#).size", sp_ring_size},
852 {"l4gen(#).created.tcp", sp_l4gen_created_tcp},
853 {"l4gen(#).created.udp", sp_l4gen_created_udp},
854 {"l4gen(#).created.all", sp_l4gen_created_all},
855 {"l4gen(#).created.bundles", sp_l4gen_created_bundles},
856 {"l4gen(#).torndown.no_retx", sp_l4gen_torndown_no_retx},
857 {"l4gen(#).torndown.retx", sp_l4gen_torndown_retx},
858 {"l4gen(#).torndown.udp", sp_l4gen_torndown_udp},
859 {"l4gen(#).expired.tcp", sp_l4gen_expire_tcp},
860 {"l4gen(#).expired.udp", sp_l4gen_expire_udp},
861 {"l4gen(#).created", sp_l4gen_created},
862 {"l4gen(#).finished", sp_l4gen_finished},
863 {"l4gen(#).retx", sp_l4gen_retx},
864 {"l4gen(#).tsc", sp_l4gen_tsc},
867 static int stats_parser_extract_args(char *stats_path, size_t *argc, char **argv)
869 size_t len = strlen(stats_path);
874 for (size_t i = 0; i < len; ++i) {
877 if (stats_path[i] == '(') {
881 else if (stats_path[i] == ')')
883 stats_path[j] = stats_path[i];
887 if (stats_path[i] == ')') {
896 argv[*argc][k++] = stats_path[i];
907 uint64_t stats_parser_get(const char *stats_path)
909 size_t stats_path_len;
911 char stats_path_cpy[128];
913 strncpy(stats_path_cpy, stats_path, sizeof(stats_path_cpy));
914 stats_path_len = strlen(stats_path);
916 size_t max_argc = 16;
918 char argv_data[16][16] = {{0}};
920 const char *argv_c[16];
922 for (size_t i = 0; i < 16; ++i) {
923 argv[i] = argv_data[i];
924 argv_c[i] = argv_data[i];
927 if (stats_parser_extract_args(stats_path_cpy, &argc, argv))
930 for (size_t i = 0; i < sizeof(stats_paths)/sizeof(stats_paths[0]); ++i) {
931 if (strcmp(stats_paths[i].str, stats_path_cpy) == 0) {
932 if (stats_paths[i].func == NULL)
934 return stats_paths[i].func(argc, argv_c);