Merge "VNF_Catalogue Codebase"
[samplevnf.git] / VNFs / DPPD-PROX / display.h
1 /*
2 // Copyright (c) 2010-2017 Intel Corporation
3 //
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
7 //
8 //     http://www.apache.org/licenses/LICENSE-2.0
9 //
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.
15 */
16
17 #ifndef _DISPLAY_H_
18 #define _DISPLAY_H_
19
20 #include <inttypes.h>
21 #include <stdarg.h>
22 #include <stdio.h>
23
24 #include "display_latency.h"
25 #include "stats_cons.h"
26 #include "clock.h"
27
28 struct display_column {
29         char title[32];
30         int  offset;
31         int  width;
32         struct display_page *display_page;
33 };
34
35 struct display_table {
36         struct display_column cols[16];
37         char title[32];
38         int n_cols;
39         int offset;
40         int width;
41 };
42
43 struct display_page {
44         struct display_table tables[8];
45         int n_tables;
46         int width;
47 };
48
49 struct screen_state {
50         unsigned chosen_screen;
51         unsigned chosen_page;
52         int toggle;
53         int pps_unit;
54 };
55
56 struct display_screen {
57         void (*draw_frame)(struct screen_state *screen_state);
58         void (*draw_stats)(struct screen_state *screen_state);
59         int (*get_height)(void);
60         const char *title;
61 };
62
63 void display_set_pps_unit(int val);
64
65 struct lcore_cfg;
66 struct task_args;
67
68 void display_page_draw_frame(const struct display_page *display_page, int height);
69 int display_column_get_width(const struct display_column *display_column);
70 void display_column_init(struct display_column *display_column, const char *title, unsigned width);
71 struct display_column *display_table_add_col(struct display_table *table);
72 void display_table_init(struct display_table *table, const char *title);
73 struct display_table *display_page_add_table(struct display_page *display_page);
74 void display_page_init(struct display_page *display_page);
75 __attribute__((format(printf, 3, 4))) void display_column_print(const struct display_column *display_column, int row, const char *fmt, ...);
76 void display_column_print_core_task(const struct display_column *display_column, int row, struct lcore_cfg *lconf, struct task_args *targ);
77 void display_column_print_number(const struct display_column *display_column, int row, uint64_t number);
78
79 char *print_time_unit_err_usec(char *dst, struct time_unit_err *t);
80 char *print_time_unit_usec(char *dst, struct time_unit *t);
81 struct port_queue;
82 struct rte_ring;
83 void display_column_port_ring(const struct display_column *display_column, int row, struct port_queue *ports, int port_count, struct rte_ring **rings, int ring_count);
84
85 void display_init(void);
86 void display_end(void);
87 void display_stats(void);
88 void display_refresh(void);
89 void display_print(const char *str);
90 void display_cmd(const char *cmd, int cmd_len, int cursor_pos);
91 void display_screen(unsigned screen_id);
92 void toggle_display_screen(void);
93 void display_page_up(void);
94 void display_page_down(void);
95 void display_print_page(void);
96 void display_lock(void);
97 void display_unlock(void);
98
99 int display_getch(void);
100
101 static struct stats_cons display = {
102         .init    = display_init,
103         .notify  = display_stats,
104         .refresh = display_refresh,
105         .finish  = display_end,
106         .flags   = STATS_CONS_F_ALL,
107 };
108
109 #endif /* _DISPLAY_H_ */