Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
T
tsn-measures
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
tsn-measures
Commits
2ba307c4
Commit
2ba307c4
authored
Sep 24, 2020
by
Joanne Hugé
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove poll wake-up for signal emission and XPD
parent
3f5754b5
Changes
5
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
316 additions
and
407 deletions
+316
-407
packet-exchange/src/recv_packet.c
packet-exchange/src/recv_packet.c
+298
-351
packet-exchange/src/recv_packet.h
packet-exchange/src/recv_packet.h
+0
-1
packet-exchange/src/server.c
packet-exchange/src/server.c
+10
-36
scripts/run-server
scripts/run-server
+4
-11
scripts/test-board-synchro
scripts/test-board-synchro
+4
-8
No files found.
packet-exchange/src/recv_packet.c
View file @
2ba307c4
This diff is collapsed.
Click to expand it.
packet-exchange/src/recv_packet.h
View file @
2ba307c4
...
...
@@ -8,7 +8,6 @@ typedef struct ingress_param {
int
use_timestamps
;
int
enable_ts_tracemark
;
int
xdp_polling_mode
;
uint64_t
interval
;
size_t
tx_buffer_len
;
...
...
packet-exchange/src/server.c
View file @
2ba307c4
...
...
@@ -48,9 +48,6 @@ typedef struct thread_param {
uint64_t
start_ts
;
int
poll
;
int
poll_margin
;
}
thread_param_t
;
typedef
struct
main_params
{
...
...
@@ -93,7 +90,7 @@ 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 "
"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
"
" -f IF Set the network interface to be used
\n
"
" -a CPU Pin the real time thread to CPU
\n
"
...
...
@@ -103,13 +100,11 @@ static void help(char *argv[]) {
" -d BUF_LEN Set the length of tx buffer
\n
"
" -c Receive timestamp and emit signal
\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
"
" -b CLIENT_IP Server side RTT
\n
"
" -g Print histograms to sdtout on exit
\n
"
" -t Enable timestamps
\n
"
" -x POLL_MODE Use AF_XDP sockets
\n
"
" POLL_MODE: 0 for polling, 1 for combination of both
\n
"
" -x Use AF_XDP sockets
\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
"
...
...
@@ -119,30 +114,13 @@ static void help(char *argv[]) {
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
)
{
(
void
)
p
;
cpu_set_t
mask
;
struct
timespec
current
;
struct
timespec
previous_emit
,
previous_ts
;
int64_t
emit_diff
,
ts_diff
;
int
ret
;
// Set thread CPU affinity
if
(
thread_params
.
affinity_cpu
)
{
...
...
@@ -157,15 +135,18 @@ static void *emit_signal_thread(void *p) {
for
(
int
i
=
0
;;
i
++
)
{
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
();
clock_gettime
(
CLOCK_REALTIME
,
&
current
);
// Check if something went wrong
if
(
i
>
0
)
{
clock_gettime
(
CLOCK_REALTIME
,
&
current
);
emit_diff
=
calcdiff_ns_signed
(
current
,
previous_emit
);
ts_diff
=
calcdiff_ns_signed
(
emit_signal_next
,
previous_ts
);
if
((
emit_diff
<
((
int64_t
)
thread_params
.
interval
)
-
ERROR_MARGIN_NS
)
||
...
...
@@ -397,8 +378,6 @@ int main(int argc, char *argv[]) {
thread_params
.
affinity_cpu
=
0
;
thread_params
.
enable_diff_ts
=
0
;
thread_params
.
enable_receive_tracemark
=
0
;
thread_params
.
poll
=
0
;
thread_params
.
poll_margin
=
75
;
thread_params
.
start_ts
=
0
;
main_params
.
refresh_rate
=
50000
;
main_params
.
verbose
=
0
;
...
...
@@ -557,7 +536,7 @@ static void process_options(int argc, char *argv[]) {
int
network_if_specified
=
0
;
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:tvx
XT:GMS
"
);
if
(
c
==
-
1
)
break
;
...
...
@@ -613,7 +592,6 @@ static void process_options(int argc, char *argv[]) {
break
;
case
'x'
:
tsn_task
=
XDP_TASK
;
ingress_params
.
xdp_polling_mode
=
atoi
(
optarg
);
break
;
case
'X'
:
main_params
.
enable_xdp_tracing
=
1
;
...
...
@@ -628,10 +606,6 @@ static void process_options(int argc, char *argv[]) {
case
'S'
:
ingress_params
.
enable_ts_tracemark
=
1
;
break
;
case
'P'
:
thread_params
.
poll
=
1
;
thread_params
.
poll_margin
=
atoi
(
optarg
);
break
;
}
}
...
...
scripts/run-server
View file @
2ba307c4
...
...
@@ -10,18 +10,14 @@ usage() {
cat
<<
ENDUSAGE
Usage:
$0
[-h] [-I if] [SERVER] | TCPDUMP [TRACE_OPTS]
-h Show help
SERVER: -bct
((-x | -X) POLL)
-g INTERVAL -a CPU
SERVER: -bct
X
-g INTERVAL -a CPU
Options passed to the C server program (everything here is optional)
-b Send back packets for round trip measurements
-c USEC Emit a signal on GPIO at the timestamp given in packet, specify interval
(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
-t Use SO_TIMESTAMPS to see how much time packet spent in kernel
-x POLL Use XDP sockets, with a global libbpf installation
-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
-X Use XDP sockets, with libbpf located in
\$
HOME/libbpf folder
-s NS Specify a CLOCK_REALTIME timestamp at which client should start
(to be used with PTP) (interval needs to be specified with -j)
-j USEC Specify interval (used with -s)
...
...
@@ -60,7 +56,7 @@ tracecmd_events="-e irq -e sched -e net -e napi"
tracecmd_opts
=
""
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:X
s:d:i:g:I:T:E:P:B:MSQ
"
opt
;
do
case
"
${
opt
}
"
in
h
)
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
c
)
server_options+
=
" -c -i
${
OPTARG
}
"
;;
O
)
server_options+
=
" -P
${
OPTARG
}
"
;;
C
)
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
interface
=
"
${
OPTARG
}
"
;;
X
)
server_options+
=
" -x
${
OPTARG
}
"
server_options+
=
" -x "
make_opts
=
" -e WITH_GIT_XDP=1"
;;
s
)
...
...
scripts/test-board-synchro
View file @
2ba307c4
...
...
@@ -4,13 +4,12 @@ script_dir=$(dirname $(realpath $0))
usage
()
{
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] [-T
X
] BOARD1_HOSTNAME BOARD2_HOSTNAME
-h Show help
-i USEC Specify which interval to use in client
-c USEC Specify which offset to use for the timestamp in the packet
-t MSEC Set the start timestamp offset
-P USEC Do polling to wakeup signal thread with specified margin
-X POLL_MODE Use XDP with specified poll mode
-X Use XDP
-T Enable tracing on the boards
BOARD_HOSTNAME Uses /etc/hosts to find the IP address associated to the hostname
ENDUSAGE
...
...
@@ -23,7 +22,7 @@ interval=1000
server_opts
=
""
ts_offset
=
2000
while
getopts
"hc:i:o:rt:T
P:X:
"
opt
;
do
while
getopts
"hc:i:o:rt:T
X
"
opt
;
do
case
"
${
opt
}
"
in
h
)
usage
...
...
@@ -40,11 +39,8 @@ while getopts "hc:i:o:rt:TP:X:" opt; do
T
)
enable_tracing
=
1
;;
P
)
server_opts+
=
" -P
${
OPTARG
}
"
;;
X
)
server_opts+
=
" -X
${
OPTARG
}
"
server_opts+
=
" -X "
;;
*
)
usage
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment