2 // Copyright (c) 2010-2018 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.
17 #include "display_irq.h"
18 #include "stats_irq.h"
22 static struct display_page display_page_irq;
23 static struct display_column *stats_irq[IRQ_BUCKETS_COUNT];
24 static struct display_column *stats_max;
25 static struct display_column *core_col;
26 static struct display_column *name_col;
28 static void display_irq_draw_frame(struct screen_state *state)
30 uint32_t n_tasks = stats_get_n_irq_tasks();
31 struct lcore_cfg *lconf = NULL;
32 struct task_args *targ;
36 display_page_init(&display_page_irq);
38 struct display_table *core_name = display_page_add_table(&display_page_irq);
40 display_table_init(core_name, "Core/task");
41 core_col = display_table_add_col(core_name);
42 name_col = display_table_add_col(core_name);
43 display_column_init(core_col, "Nb", 4);
44 display_column_init(name_col, "Name", 5);
46 struct display_table *stats = display_page_add_table(&display_page_irq);
47 if (state->toggle == 0) {
48 display_table_init(stats, "Statistics per second");
51 stats_max = display_table_add_col(stats);
52 snprintf(title, sizeof(title), " MAXIMUM(mic)");
53 display_column_init(stats_max, title, 11);
55 stats_irq[0] = display_table_add_col(stats);
56 if (irq_bucket_maxtime_micro[0] < 1000)
57 snprintf(title, sizeof(title), " %d-%ld mic", 0, irq_bucket_maxtime_micro[0]);
59 snprintf(title, sizeof(title), " %d-%ld ms", 0, irq_bucket_maxtime_micro[0] / 1000);
60 display_column_init(stats_irq[0], title, 9);
61 for (uint i = 1; i < IRQ_BUCKETS_COUNT - 1; ++i) {
62 stats_irq[i] = display_table_add_col(stats);
63 if (irq_bucket_maxtime_micro[i-1] < 1000)
64 snprintf(title, sizeof(title), " %ld-%ld mic", irq_bucket_maxtime_micro[i-1], irq_bucket_maxtime_micro[i]);
66 snprintf(title, sizeof(title), " %ld-%ld ms", irq_bucket_maxtime_micro[i-1] / 1000, irq_bucket_maxtime_micro[i] / 1000);
67 display_column_init(stats_irq[i], title, 9);
69 stats_irq[IRQ_BUCKETS_COUNT - 1] = display_table_add_col(stats);
70 if (irq_bucket_maxtime_micro[IRQ_BUCKETS_COUNT - 2] < 1000)
71 snprintf(title, sizeof(title), " > %ld mic ", irq_bucket_maxtime_micro[IRQ_BUCKETS_COUNT - 2]);
73 snprintf(title, sizeof(title), " > %ld ms ", irq_bucket_maxtime_micro[IRQ_BUCKETS_COUNT - 2] / 1000);
74 display_column_init(stats_irq[IRQ_BUCKETS_COUNT - 1], title, 9);
76 display_table_init(stats, "Total statistics");
79 stats_max = display_table_add_col(stats);
80 snprintf(title, sizeof(title), " MAXIMUM(mic)");
81 display_column_init(stats_max, title, 9);
83 stats_irq[0] = display_table_add_col(stats);
84 if (irq_bucket_maxtime_micro[0] < 1000)
85 snprintf(title, sizeof(title), " %d-%ld ", 0, irq_bucket_maxtime_micro[0]);
87 snprintf(title, sizeof(title), " %d-%ld ms", 0, irq_bucket_maxtime_micro[0] / 1000);
88 display_column_init(stats_irq[0], title, 9);
89 for (uint i = 1; i < IRQ_BUCKETS_COUNT - 1; ++i) {
90 stats_irq[i] = display_table_add_col(stats);
91 if (irq_bucket_maxtime_micro[i-1] < 1000)
92 snprintf(title, sizeof(title), " %ld-%ld ", irq_bucket_maxtime_micro[i-1], irq_bucket_maxtime_micro[i]);
94 snprintf(title, sizeof(title), " %ld-%ld ms", irq_bucket_maxtime_micro[i-1] / 1000, irq_bucket_maxtime_micro[i] / 1000);
95 display_column_init(stats_irq[i], title, 9);
97 stats_irq[IRQ_BUCKETS_COUNT - 1] = display_table_add_col(stats);
98 if (irq_bucket_maxtime_micro[IRQ_BUCKETS_COUNT - 2] < 1000)
99 snprintf(title, sizeof(title), " > %ld ", irq_bucket_maxtime_micro[IRQ_BUCKETS_COUNT - 2]);
101 snprintf(title, sizeof(title), " > %ld ", irq_bucket_maxtime_micro[IRQ_BUCKETS_COUNT - 2] / 1000);
102 display_column_init(stats_irq[IRQ_BUCKETS_COUNT - 1], title, 9);
105 display_page_draw_frame(&display_page_irq, n_tasks);
109 while (core_targ_next(&lconf, &targ, 0) == 0) {
110 if (strcmp(targ->task_init->mode_str, "irq") == 0) {
111 display_column_print_core_task(core_col, count, lconf, targ);
113 display_column_print(name_col, count, "%s", lconf->name);
119 static void display_irq_draw_stats(struct screen_state *state)
121 struct lcore_cfg *lconf = NULL;
122 struct task_args *targ;
123 const uint32_t n_stats_irq = stats_get_n_irq_tasks();
125 if (state->toggle == 0) {
126 for (uint32_t count = 0; count < n_stats_irq; ++count) {
127 struct irq_sample *last = get_irq_sample(count, 1);
128 struct irq_sample *prev = get_irq_sample(count, 0);
130 display_column_print(stats_max, count, "%9lu", (last->max_irq * 1000000L) / rte_get_tsc_hz());
131 for (uint i = 0; i < IRQ_BUCKETS_COUNT; ++i) {
132 display_column_print(stats_irq[i], count, "%9lu", last->irq[i] - prev->irq[i]);
136 for (uint32_t count = 0; count < n_stats_irq; ++count) {
137 display_column_print(stats_max, count, "%9lu", get_max_irq_stats(count));
138 for (uint i = 0; i < IRQ_BUCKETS_COUNT; ++i) {
139 display_column_print(stats_irq[i], count, "%9lu", get_irq_stats(count, i));
145 static int display_irq_get_height(void)
147 return stats_get_n_irq_tasks();
150 static struct display_screen display_screen_irq = {
151 .draw_frame = display_irq_draw_frame,
152 .draw_stats = display_irq_draw_stats,
153 .get_height = display_irq_get_height,
157 struct display_screen *display_irq(void)
159 return &display_screen_irq;