Commit 2ba307c4 authored by Joanne Hugé's avatar Joanne Hugé

Remove poll wake-up for signal emission and XPD

parent 3f5754b5
This diff is collapsed.
...@@ -8,7 +8,6 @@ typedef struct ingress_param { ...@@ -8,7 +8,6 @@ typedef struct ingress_param {
int use_timestamps; int use_timestamps;
int enable_ts_tracemark; int enable_ts_tracemark;
int xdp_polling_mode;
uint64_t interval; uint64_t interval;
size_t tx_buffer_len; size_t tx_buffer_len;
......
...@@ -48,9 +48,6 @@ typedef struct thread_param { ...@@ -48,9 +48,6 @@ typedef struct thread_param {
uint64_t start_ts; uint64_t start_ts;
int poll;
int poll_margin;
} thread_param_t; } thread_param_t;
typedef struct main_params { typedef struct main_params {
...@@ -93,7 +90,7 @@ static char ts_tracemark_buf[64]; ...@@ -93,7 +90,7 @@ static char ts_tracemark_buf[64];
static void help(char *argv[]) { static void help(char *argv[]) {
printf( printf(
"Usage: %s [-f IF -a CPU -p PRIO -i USEC -r USEC] [-b CLIENT_IP] [-d " "Usage: %s [-f IF -a CPU -p PRIO -i USEC -r USEC] [-b CLIENT_IP] [-d "
"BUF_LEN -cgtv] [-T LATENCY_THRESHOLD -G] [-x POLL_MODE -X]\n\n" "BUF_LEN -cgtv] [-T LATENCY_THRESHOLD -G] [-xX]\n\n"
" -h Show help\n" " -h Show help\n"
" -f IF Set the network interface to be used\n" " -f IF Set the network interface to be used\n"
" -a CPU Pin the real time thread to CPU\n" " -a CPU Pin the real time thread to CPU\n"
...@@ -103,13 +100,11 @@ static void help(char *argv[]) { ...@@ -103,13 +100,11 @@ static void help(char *argv[]) {
" -d BUF_LEN Set the length of tx buffer\n" " -d BUF_LEN Set the length of tx buffer\n"
" -c Receive timestamp and emit signal\n" " -c Receive timestamp and emit signal\n"
" -s NS Common start time reference\n" " -s NS Common start time reference\n"
" -P USEC Do polling to wakeup signal thread with specified margin\n"
" -C Receive timestamp and print difference with current time\n" " -C Receive timestamp and print difference with current time\n"
" -b CLIENT_IP Server side RTT\n" " -b CLIENT_IP Server side RTT\n"
" -g Print histograms to sdtout on exit\n" " -g Print histograms to sdtout on exit\n"
" -t Enable timestamps\n" " -t Enable timestamps\n"
" -x POLL_MODE Use AF_XDP sockets\n" " -x Use AF_XDP sockets\n"
" POLL_MODE: 0 for polling, 1 for combination of both\n"
" -X Trace during XDP packet reception\n" " -X Trace during XDP packet reception\n"
" -T THRESHOLD Enable tracing until THRESHOLD is reached\n" " -T THRESHOLD Enable tracing until THRESHOLD is reached\n"
" -M Send tracemark when packet is received\n" " -M Send tracemark when packet is received\n"
...@@ -119,30 +114,13 @@ static void help(char *argv[]) { ...@@ -119,30 +114,13 @@ static void help(char *argv[]) {
argv[0]); argv[0]);
} }
static void poll_wakeup(struct timespec ts, int margin) {
int ret;
struct timespec ts_prev, current;
ts_prev = ts;
substract_ns(&ts_prev, margin * 1000);
ret = clock_nanosleep(CLOCK_REALTIME, TIMER_ABSTIME, &ts_prev, NULL);
if (ret) {
fprintf(stderr, "clock_nanosleep returned error: %d, aborting...\n", ret);
exit(EXIT_FAILURE);
}
do {
clock_gettime(CLOCK_REALTIME, &current);
} while(calcdiff_ns_signed(ts, current) > 1000);
}
static void *emit_signal_thread(void *p) { static void *emit_signal_thread(void *p) {
(void)p; (void)p;
cpu_set_t mask; cpu_set_t mask;
struct timespec current; struct timespec current;
struct timespec previous_emit, previous_ts; struct timespec previous_emit, previous_ts;
int64_t emit_diff, ts_diff; int64_t emit_diff, ts_diff;
int ret;
// Set thread CPU affinity // Set thread CPU affinity
if (thread_params.affinity_cpu) { if (thread_params.affinity_cpu) {
...@@ -157,15 +135,18 @@ static void *emit_signal_thread(void *p) { ...@@ -157,15 +135,18 @@ static void *emit_signal_thread(void *p) {
for (int i = 0;;i++) { for (int i = 0;;i++) {
pthread_cond_wait(&emit_signal_ts_received, &emit_signal_mutex); pthread_cond_wait(&emit_signal_ts_received, &emit_signal_mutex);
clock_gettime(CLOCK_REALTIME, &current);
poll_wakeup(emit_signal_next, thread_params.poll_margin); ret = clock_nanosleep(CLOCK_REALTIME, TIMER_ABSTIME, &emit_signal_next, NULL);
if (ret) {
fprintf(stderr, "clock_nanosleep returned error: %d, aborting...\n", ret);
exit(EXIT_FAILURE);
}
toggle_gpio(); toggle_gpio();
clock_gettime(CLOCK_REALTIME, &current);
// Check if something went wrong // Check if something went wrong
if(i > 0) { if(i > 0) {
clock_gettime(CLOCK_REALTIME, &current);
emit_diff = calcdiff_ns_signed(current, previous_emit); emit_diff = calcdiff_ns_signed(current, previous_emit);
ts_diff = calcdiff_ns_signed(emit_signal_next, previous_ts); ts_diff = calcdiff_ns_signed(emit_signal_next, previous_ts);
if((emit_diff < ((int64_t)thread_params.interval) - ERROR_MARGIN_NS) || if((emit_diff < ((int64_t)thread_params.interval) - ERROR_MARGIN_NS) ||
...@@ -397,8 +378,6 @@ int main(int argc, char *argv[]) { ...@@ -397,8 +378,6 @@ int main(int argc, char *argv[]) {
thread_params.affinity_cpu = 0; thread_params.affinity_cpu = 0;
thread_params.enable_diff_ts = 0; thread_params.enable_diff_ts = 0;
thread_params.enable_receive_tracemark = 0; thread_params.enable_receive_tracemark = 0;
thread_params.poll = 0;
thread_params.poll_margin = 75;
thread_params.start_ts = 0; thread_params.start_ts = 0;
main_params.refresh_rate = 50000; main_params.refresh_rate = 50000;
main_params.verbose = 0; main_params.verbose = 0;
...@@ -557,7 +536,7 @@ static void process_options(int argc, char *argv[]) { ...@@ -557,7 +536,7 @@ static void process_options(int argc, char *argv[]) {
int network_if_specified = 0; int network_if_specified = 0;
for (;;) { for (;;) {
int c = getopt(argc, argv, "a:b:cCs:d:f:ghi:p:r:tvx:XT:GMSP:"); int c = getopt(argc, argv, "a:b:cCs:d:f:ghi:p:r:tvxXT:GMS");
if (c == -1) break; if (c == -1) break;
...@@ -613,7 +592,6 @@ static void process_options(int argc, char *argv[]) { ...@@ -613,7 +592,6 @@ static void process_options(int argc, char *argv[]) {
break; break;
case 'x': case 'x':
tsn_task = XDP_TASK; tsn_task = XDP_TASK;
ingress_params.xdp_polling_mode = atoi(optarg);
break; break;
case 'X': case 'X':
main_params.enable_xdp_tracing = 1; main_params.enable_xdp_tracing = 1;
...@@ -628,10 +606,6 @@ static void process_options(int argc, char *argv[]) { ...@@ -628,10 +606,6 @@ static void process_options(int argc, char *argv[]) {
case 'S': case 'S':
ingress_params.enable_ts_tracemark = 1; ingress_params.enable_ts_tracemark = 1;
break; break;
case 'P':
thread_params.poll = 1;
thread_params.poll_margin = atoi(optarg);
break;
} }
} }
......
...@@ -10,18 +10,14 @@ usage() { ...@@ -10,18 +10,14 @@ usage() {
cat << ENDUSAGE cat << ENDUSAGE
Usage: $0 [-h] [-I if] [SERVER] | TCPDUMP [TRACE_OPTS] Usage: $0 [-h] [-I if] [SERVER] | TCPDUMP [TRACE_OPTS]
-h Show help -h Show help
SERVER: -bct ((-x | -X) POLL) -g INTERVAL -a CPU SERVER: -bctX -g INTERVAL -a CPU
Options passed to the C server program (everything here is optional) Options passed to the C server program (everything here is optional)
-b Send back packets for round trip measurements -b Send back packets for round trip measurements
-c USEC Emit a signal on GPIO at the timestamp given in packet, specify interval -c USEC Emit a signal on GPIO at the timestamp given in packet, specify interval
(to be used with -c option in client program) (to be used with -c option in client program)
-O USEC Do polling to wakeup signal thread with specified margin
-C USEC Measure difference between current time and timestamp sent in tx data -C USEC Measure difference between current time and timestamp sent in tx data
-t Use SO_TIMESTAMPS to see how much time packet spent in kernel -t Use SO_TIMESTAMPS to see how much time packet spent in kernel
-x POLL Use XDP sockets, with a global libbpf installation -X Use XDP sockets, with libbpf located in \$HOME/libbpf folder
-X POLL Use XDP sockets, with libbpf located in \$HOME/libbpf folder
POLL: Polling mode used in server program, 0 to poll with poll function,
1 to do active polling
-s NS Specify a CLOCK_REALTIME timestamp at which client should start -s NS Specify a CLOCK_REALTIME timestamp at which client should start
(to be used with PTP) (interval needs to be specified with -j) (to be used with PTP) (interval needs to be specified with -j)
-j USEC Specify interval (used with -s) -j USEC Specify interval (used with -s)
...@@ -60,7 +56,7 @@ tracecmd_events="-e irq -e sched -e net -e napi" ...@@ -60,7 +56,7 @@ tracecmd_events="-e irq -e sched -e net -e napi"
tracecmd_opts="" tracecmd_opts=""
cpu=1 cpu=1
while getopts "j:a:b:c:C:htx:X:s:d:i:g:I:T:E:P:B:MSQO:" opt; do while getopts "j:a:b:c:C:htx:Xs:d:i:g:I:T:E:P:B:MSQ" opt; do
case "${opt}" in case "${opt}" in
h ) h )
usage usage
...@@ -78,9 +74,6 @@ while getopts "j:a:b:c:C:htx:X:s:d:i:g:I:T:E:P:B:MSQO:" opt; do ...@@ -78,9 +74,6 @@ while getopts "j:a:b:c:C:htx:X:s:d:i:g:I:T:E:P:B:MSQO:" opt; do
c ) c )
server_options+=" -c -i ${OPTARG}" server_options+=" -c -i ${OPTARG}"
;; ;;
O )
server_options+=" -P ${OPTARG} "
;;
C ) C )
server_options+=" -C -i ${OPTARG}" server_options+=" -C -i ${OPTARG}"
;; ;;
...@@ -107,7 +100,7 @@ while getopts "j:a:b:c:C:htx:X:s:d:i:g:I:T:E:P:B:MSQO:" opt; do ...@@ -107,7 +100,7 @@ while getopts "j:a:b:c:C:htx:X:s:d:i:g:I:T:E:P:B:MSQO:" opt; do
interface="${OPTARG}" interface="${OPTARG}"
;; ;;
X ) X )
server_options+=" -x ${OPTARG}" server_options+=" -x "
make_opts=" -e WITH_GIT_XDP=1" make_opts=" -e WITH_GIT_XDP=1"
;; ;;
s ) s )
......
...@@ -4,13 +4,12 @@ script_dir=$(dirname $(realpath $0)) ...@@ -4,13 +4,12 @@ script_dir=$(dirname $(realpath $0))
usage() { usage() {
cat << ENDUSAGE cat << ENDUSAGE
Usage: $0 [-h] [-i USEC -c USEC -t MSEC] [-T] BOARD1_HOSTNAME BOARD2_HOSTNAME Usage: $0 [-h] [-i USEC -c USEC -t MSEC] [-TX] BOARD1_HOSTNAME BOARD2_HOSTNAME
-h Show help -h Show help
-i USEC Specify which interval to use in client -i USEC Specify which interval to use in client
-c USEC Specify which offset to use for the timestamp in the packet -c USEC Specify which offset to use for the timestamp in the packet
-t MSEC Set the start timestamp offset -t MSEC Set the start timestamp offset
-P USEC Do polling to wakeup signal thread with specified margin -X Use XDP
-X POLL_MODE Use XDP with specified poll mode
-T Enable tracing on the boards -T Enable tracing on the boards
BOARD_HOSTNAME Uses /etc/hosts to find the IP address associated to the hostname BOARD_HOSTNAME Uses /etc/hosts to find the IP address associated to the hostname
ENDUSAGE ENDUSAGE
...@@ -23,7 +22,7 @@ interval=1000 ...@@ -23,7 +22,7 @@ interval=1000
server_opts="" server_opts=""
ts_offset=2000 ts_offset=2000
while getopts "hc:i:o:rt:TP:X:" opt; do while getopts "hc:i:o:rt:TX" opt; do
case "${opt}" in case "${opt}" in
h ) h )
usage usage
...@@ -40,11 +39,8 @@ while getopts "hc:i:o:rt:TP:X:" opt; do ...@@ -40,11 +39,8 @@ while getopts "hc:i:o:rt:TP:X:" opt; do
T ) T )
enable_tracing=1 enable_tracing=1
;; ;;
P )
server_opts+=" -P ${OPTARG} "
;;
X ) X )
server_opts+=" -X ${OPTARG} " server_opts+=" -X "
;; ;;
* ) * )
usage usage
......
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