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