summaryrefslogtreecommitdiffstats
path: root/VNFs/DPPD-PROX/display.h
blob: 4b517546b119e2f58bb4d14b3ebb1c4597cb75c4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
/*
// Copyright (c) 2010-2017 Intel Corporation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
*/

#ifndef _DISPLAY_H_
#define _DISPLAY_H_

#include <inttypes.h>
#include <stdarg.h>
#include <stdio.h>

#include "display_latency.h"
#include "stats_cons.h"
#include "clock.h"

struct display_column {
	char title[32];
	int  offset;
	int  width;
	struct display_page *display_page;
};

struct display_table {
	struct display_column cols[16];
	char title[32];
	int n_cols;
	int offset;
	int width;
};

struct display_page {
	struct display_table tables[8];
	int n_tables;
	int width;
};

struct screen_state {
	unsigned chosen_screen;
	unsigned chosen_page;
	int toggle;
	int pps_unit;
};

struct display_screen {
	void (*draw_frame)(struct screen_state *screen_state);
	void (*draw_stats)(struct screen_state *screen_state);
	int (*get_height)(void);
	const char *title;
};

void display_set_pps_unit(int val);

struct lcore_cfg;
struct task_args;

void display_page_draw_frame(const struct display_page *display_page, int height);
int display_column_get_width(const struct display_column *display_column);
void display_column_init(struct display_column *display_column, const char *title, unsigned width);
struct display_column *display_table_add_col(struct display_table *table);
void display_table_init(struct display_table *table, const char *title);
struct display_table *display_page_add_table(struct display_page *display_page);
void display_page_init(struct display_page *display_page);
__attribute__((format(printf, 3, 4))) void display_column_print(const struct display_column *display_column, int row, const char *fmt, ...);
void display_column_print_core_task(const struct display_column *display_column, int row, struct lcore_cfg *lconf, struct task_args *targ);
void display_column_print_number(const struct display_column *display_column, int row, uint64_t number);

char *print_time_unit_err_usec(char *dst, struct time_unit_err *t);
char *print_time_unit_usec(char *dst, struct time_unit *t);
struct port_queue;
struct rte_ring;
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);

void display_init(void);
void display_end(void);
void display_stats(void);
void display_refresh(void);
void display_print(const char *str);
void display_cmd(const char *cmd, int cmd_len, int cursor_pos);
void display_screen(unsigned screen_id);
void toggle_display_screen(void);
void display_page_up(void);
void display_page_down(void);
void display_print_page(void);
void display_lock(void);
void display_unlock(void);

int display_getch(void);

static struct stats_cons display = {
	.init    = display_init,
	.notify  = display_stats,
	.refresh = display_refresh,
	.finish  = display_end,
	.flags   = STATS_CONS_F_ALL,
};

#endif /* _DISPLAY_H_ */