-
Notifications
You must be signed in to change notification settings - Fork 4
/
display_l4gen.c
executable file
·188 lines (151 loc) · 7.76 KB
/
display_l4gen.c
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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
/*
Copyright(c) 2010-2017 Intel Corporation.
Copyright(c) 2016-2018 Viosoft Corporation.
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in
the documentation and/or other materials provided with the
distribution.
* Neither the name of Intel Corporation nor the names of its
contributors may be used to endorse or promote products derived
from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "display.h"
#include "display_l4gen.h"
#include "stats_l4gen.h"
static struct display_page display_page_l4gen;
static struct display_column *core_col;
static struct display_column *tcp_setup_col;
static struct display_column *udp_setup_col;
static struct display_column *all_setup_col;
static struct display_column *bundles_setup_col;
static struct display_column *tcp_teardown_col;
static struct display_column *tcp_teardown_retx_col;
static struct display_column *udp_teardown_col;
static struct display_column *tcp_expire_col;
static struct display_column *udp_expire_col;
static struct display_column *active_col;
static struct display_column *retx_col;
static void display_l4gen_draw_frame(struct screen_state *state)
{
const uint32_t n_l4gen = stats_get_n_l4gen();
display_page_init(&display_page_l4gen);
struct display_table *core = display_page_add_table(&display_page_l4gen);
struct display_table *setup_rate = display_page_add_table(&display_page_l4gen);
struct display_table *teardown_rate = display_page_add_table(&display_page_l4gen);
struct display_table *expire_rate = display_page_add_table(&display_page_l4gen);
struct display_table *other = display_page_add_table(&display_page_l4gen);
display_table_init(core, "Core");
display_table_init(setup_rate, "Setup rate (flows/s)");
display_table_init(teardown_rate, "Teardown rate (flows/s)");
display_table_init(expire_rate, "Expire rate (flows/s)");
display_table_init(other, "Other");
core_col = display_table_add_col(core);
display_column_init(core_col, "Nb", 4);
tcp_setup_col = display_table_add_col(setup_rate);
display_column_init(tcp_setup_col, "TCP", 10);
udp_setup_col = display_table_add_col(setup_rate);
display_column_init(udp_setup_col, "UDP", 10);
all_setup_col = display_table_add_col(setup_rate);
display_column_init(all_setup_col, "TCP + UDP", 9);
bundles_setup_col = display_table_add_col(setup_rate);
display_column_init(bundles_setup_col, "Bundles", 9);
tcp_teardown_col = display_table_add_col(teardown_rate);
display_column_init(tcp_teardown_col, "TCP w/o reTX", 12);
tcp_teardown_retx_col = display_table_add_col(teardown_rate);
display_column_init(tcp_teardown_retx_col, "TCP w/ reTX", 12);
udp_teardown_col = display_table_add_col(teardown_rate);
display_column_init(udp_teardown_col, "UDP", 12);
tcp_expire_col = display_table_add_col(expire_rate);
display_column_init(tcp_expire_col, "TCP", 10);
udp_expire_col = display_table_add_col(expire_rate);
display_column_init(udp_expire_col, "TCP", 10);
active_col = display_table_add_col(other);
display_column_init(active_col, "Active (#)", 10);
retx_col = display_table_add_col(other);
display_column_init(retx_col, "reTX (/s)", 10);
display_page_draw_frame(&display_page_l4gen, n_l4gen);
for (uint16_t i = 0; i < n_l4gen; ++i) {
struct task_l4_stats *tls = stats_get_l4_stats(i);
display_column_print(core_col, i, "%2u/%1u", tls->lcore_id, tls->task_id);
}
}
static void display_l4gen_draw_stats_line(int row, struct l4_stats_sample *clast, struct l4_stats_sample *cprev)
{
struct l4_stats *last = &clast->stats;
struct l4_stats *prev = &cprev->stats;
uint64_t delta_t = clast->tsc - cprev->tsc;
uint64_t tcp_created = last->tcp_created - prev->tcp_created;
uint64_t udp_created = last->udp_created - prev->udp_created;
uint64_t tcp_finished_no_retransmit = last->tcp_finished_no_retransmit - prev->tcp_finished_no_retransmit;
uint64_t tcp_finished_retransmit = last->tcp_finished_retransmit - prev->tcp_finished_retransmit;
uint64_t tcp_expired = last->tcp_expired - prev->tcp_expired;
uint64_t tcp_retransmits = last->tcp_retransmits - prev->tcp_retransmits;
uint64_t udp_finished = last->udp_finished - prev->udp_finished;
uint64_t udp_expired = last->udp_expired - prev->udp_expired;
uint64_t bundles_created = last->bundles_created - prev->bundles_created;
uint64_t tcp_setup_rate = val_to_rate(tcp_created, delta_t);
uint64_t udp_setup_rate = val_to_rate(udp_created, delta_t);
uint64_t all_setup_rate = val_to_rate(tcp_created + udp_created, delta_t);
uint64_t bundle_setup_rate = val_to_rate(bundles_created, delta_t);
uint64_t tcp_teardown_rate = val_to_rate(tcp_finished_no_retransmit, delta_t);
uint64_t tcp_teardown_retx_rate = val_to_rate(tcp_finished_retransmit, delta_t);
uint64_t udp_teardown_rate = val_to_rate(udp_finished, delta_t);
uint64_t tcp_expire_rate = val_to_rate(tcp_expired, delta_t);
uint64_t udp_expire_rate = val_to_rate(udp_expired, delta_t);
display_column_print(tcp_setup_col, row, "%"PRIu64"", tcp_setup_rate);
display_column_print(udp_setup_col, row, "%"PRIu64"", udp_setup_rate);
display_column_print(all_setup_col, row, "%"PRIu64"", all_setup_rate);
display_column_print(bundles_setup_col, row, "%"PRIu64"", bundle_setup_rate);
display_column_print(tcp_teardown_col, row, "%"PRIu64"", tcp_teardown_rate);
display_column_print(tcp_teardown_retx_col, row, "%"PRIu64"", tcp_teardown_retx_rate);
display_column_print(udp_teardown_col, row, "%"PRIu64"", udp_teardown_rate);
display_column_print(tcp_expire_col, row, "%"PRIu64"", tcp_expire_rate);
display_column_print(udp_expire_col, row, "%"PRIu64"", udp_expire_rate);
uint64_t tot_created = last->tcp_created + last->udp_created;
uint64_t tot_finished = last->tcp_finished_retransmit + last->tcp_finished_no_retransmit +
last->udp_finished + last->udp_expired + last->tcp_expired;
uint64_t active = tot_created - tot_finished;
uint64_t retx = tcp_retransmits;
display_column_print(active_col, row, "%10"PRIu64"", active);
display_column_print(retx_col, row, "%10"PRIu64"", retx);
}
static void display_l4gen_draw_stats(struct screen_state *state)
{
const uint32_t n_l4gen = stats_get_n_l4gen();
for (uint16_t i = 0; i < n_l4gen; ++i) {
struct l4_stats_sample *clast = stats_get_l4_stats_sample(i, 1);
struct l4_stats_sample *cprev = stats_get_l4_stats_sample(i, 0);
display_l4gen_draw_stats_line(i, clast, cprev);
}
}
static int display_l4gen_get_height(void)
{
return stats_get_n_l4gen();
}
static struct display_screen display_screen_l4gen = {
.draw_frame = display_l4gen_draw_frame,
.draw_stats = display_l4gen_draw_stats,
.get_height = display_l4gen_get_height,
.title = "l4gen",
};
struct display_screen *display_l4gen(void)
{
return &display_screen_l4gen;
}