Commit 0d5bcea9 authored by Joanne Hugé's avatar Joanne Hugé

Add tracemark options to server

parent bba18f1b
......@@ -33,6 +33,7 @@
#include <unistd.h>
#include "common.h"
#include "tracer.h"
#ifdef WITH_XDP
#include <bpf/bpf.h>
......@@ -56,7 +57,9 @@ static ingress_stat_t *stats;
static uint64_t *kernel_latency_hist;
static int use_histogram;
uint64_t post_kernel_timestamp;
static uint64_t post_kernel_timestamp;
static char ts_tracemark_buf[64];
// Sets the interface
static int set_if(void) {
......@@ -176,6 +179,12 @@ void recv_udp_packet() {
struct timespec *stamp =
(struct timespec *)CMSG_DATA(cmsg);
if(params->enable_ts_tracemark) {
sprintf(ts_tracemark_buf, "%" PRIu64, ts_to_uint(*stamp));
tracemark(ts_tracemark_buf);
}
else {
uint64_t kernel_latency =
post_kernel_timestamp - ts_to_uint(*stamp);
kernel_latency /= 1000u;
......@@ -200,6 +209,7 @@ void recv_udp_packet() {
}
}
}
}
for(int i = 0; i < MAX_BUFFER_SIZE; i++)
stats->data[i] = rx_buffer[i];
......
......@@ -7,6 +7,7 @@ typedef struct ingress_param {
char network_if[16];
int use_timestamps;
int enable_ts_tracemark;
int xdp_polling_mode;
uint64_t interval;
......
......@@ -42,6 +42,7 @@ typedef struct thread_param {
int emit_signal;
int enable_diff_ts;
int enable_receive_tracemark;
} thread_param_t;
......@@ -80,6 +81,8 @@ static int64_t min_diff_ts = INT_MAX;
static int64_t max_diff_ts = 0;
static int64_t avg_diff_ts = 0;
static char ts_tracemark_buf[64];
static void help(char *argv[]) {
printf(
"Usage: %s [-f IF -a CPU -p PRIO -i USEC -r USEC] [-b CLIENT_IP] [-d "
......@@ -100,6 +103,8 @@ static void help(char *argv[]) {
" POLL_MODE: 0 for polling, 1 for combination of both\n"
" -X Trace during XDP packet reception\n"
" -T THRESHOLD Enable tracing until THRESHOLD is reached\n"
" -M Send tracemark when packet is received\n"
" -S Send tracemark containing RX SO_TIMESTAMP timestamp\n"
" -v Verbose\n"
"\n",
argv[0]);
......@@ -174,6 +179,11 @@ static void *tsn_thread(void *p) {
clock_gettime(CLOCK_REALTIME, &current);
recv_xdp_cleanup();
if(thread_params.enable_receive_tracemark) {
sprintf(ts_tracemark_buf, "%" PRIu64, ts_to_uint(current));
tracemark(ts_tracemark_buf);
}
if(thread_params.enable_diff_ts) {
uint64_t send_ts = decode(ingress_stats.data);
int64_t diff_us = (((int64_t) ts_to_uint(current)) - ((int64_t)send_ts)) / 1000;
......@@ -293,6 +303,7 @@ int main(int argc, char *argv[]) {
thread_params.emit_signal = 0;
thread_params.affinity_cpu = 0;
thread_params.enable_diff_ts = 0;
thread_params.enable_receive_tracemark = 0;
main_params.refresh_rate = 50000;
main_params.verbose = 0;
main_params.enable_tracing = 0;
......@@ -300,6 +311,7 @@ int main(int argc, char *argv[]) {
enable_histograms = 0;
tsn_task = RECV_PACKET_TASK;
ingress_params.tx_buffer_len = 1024;
ingress_params.enable_ts_tracemark = 0;
// Process bash options
process_options(argc, argv);
......@@ -449,7 +461,7 @@ static void process_options(int argc, char *argv[]) {
int network_if_specified = 0;
for (;;) {
int c = getopt(argc, argv, "a:b:cCd:f:ghi:p:r:tvx:XT:G");
int c = getopt(argc, argv, "a:b:cCd:f:ghi:p:r:tvx:XT:GMS");
if (c == -1) break;
......@@ -511,6 +523,12 @@ static void process_options(int argc, char *argv[]) {
main_params.enable_tracing = 1;
thread_params.latency_threshold = atoi(optarg);
break;
case 'M':
thread_params.enable_receive_tracemark = 1;
break;
case 'S':
ingress_params.enable_ts_tracemark = 1;
break;
}
}
......
......@@ -32,11 +32,14 @@ Usage: $0 [-h] [-I if] [SERVER] | TCPDUMP [TRACE_OPTS]
TRACE_OPTS: -T LATENCY_THRESHOLD [-P TRACER -E XDP_EVENTS]
Trace until latency threshold is met
-T USEC Enable tracing until threshold is met
-Q Enable eth0 IRQ tracing only
-P TRACER Which trace to use when tracing: function, function_graph, wakeup etc...
Default: function
-E EVENTS Specify which events to trace (e.g: "-E "-e net -e irq")
Default: irq, sched, net, napi
-B SIZE Size of the buffer for each CPU in kilobytes
-M Send tracemark when packet is received\n"
-S Send tracemark containing RX SO_TIMESTAMP timestamp\n"
ENDUSAGE
1>&2;
......@@ -53,7 +56,7 @@ tracecmd_events="-e irq -e sched -e net -e napi"
tracecmd_opts=""
cpu=1
while getopts "a:b:cChtx:X:d:i:g:I:T:E:P:B:" opt; do
while getopts "a:b:cChtx:X:d:i:g:I:T:E:P:B:MSQ" opt; do
case "${opt}" in
a )
cpu=${OPTARG}
......@@ -111,6 +114,18 @@ while getopts "a:b:cChtx:X:d:i:g:I:T:E:P:B:" opt; do
use_tracer=1
server_options+=" -T ${OPTARG}"
;;
M )
server_options+=" -M "
;;
S )
server_options+=" -S "
;;
Q )
use_tracer=1
server_options+=" -T 999999"
tracecmd_events=" -e irq_handler_entry "
tracecmd_filter="irq == 56"
;;
* )
usage
;;
......@@ -148,8 +163,15 @@ else
cd $script_dir/../packet-exchange/build;make $make_opts server;cd $script_dir
if [ -n "${use_tracer}" ]; then
if [ -n "${tracecmd_filter}" ]; then
echo "trace-cmd record $tracecmd_opts $tracecmd_events -f \"$tracecmd_filter\" $script_dir/../packet-exchange/build/server $server_options";
trace-cmd record $tracecmd_opts $tracecmd_events -f "$tracecmd_filter" $script_dir/../packet-exchange/build/server $server_options;
else
echo "trace-cmd record $tracecmd_opts $tracecmd_events $script_dir/../packet-exchange/build/server $server_options";
trace-cmd record $tracecmd_opts $tracecmd_events $script_dir/../packet-exchange/build/server $server_options;
fi
elif [ -z "${use_histogram}" ]; then
echo "server $server_options";
$script_dir/../packet-exchange/build/server $server_options;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment