Commit d3239425 authored by Jian Yang's avatar Jian Yang Committed by David S. Miller

selftests: txtimestamp: add flag for timestamp validation tolerance.

The txtimestamp selftest sets a fixed 500us tolerance. This value was
arrived at experimentally. Some platforms have higher variances. Make
this adjustable by adding the following flag:

-t N: tolerance (usec) for timestamp validation.
Signed-off-by: default avatarJian Yang <jianyang@google.com>
Acked-by: default avatarWillem de Bruijn <willemb@google.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 3c2d19cb
...@@ -64,6 +64,7 @@ static int cfg_payload_len = 10; ...@@ -64,6 +64,7 @@ static int cfg_payload_len = 10;
static int cfg_poll_timeout = 100; static int cfg_poll_timeout = 100;
static int cfg_delay_snd; static int cfg_delay_snd;
static int cfg_delay_ack; static int cfg_delay_ack;
static int cfg_delay_tolerance_usec = 500;
static bool cfg_show_payload; static bool cfg_show_payload;
static bool cfg_do_pktinfo; static bool cfg_do_pktinfo;
static bool cfg_busy_poll; static bool cfg_busy_poll;
...@@ -152,11 +153,12 @@ static void validate_key(int tskey, int tstype) ...@@ -152,11 +153,12 @@ static void validate_key(int tskey, int tstype)
static void validate_timestamp(struct timespec *cur, int min_delay) static void validate_timestamp(struct timespec *cur, int min_delay)
{ {
int max_delay = min_delay + 500 /* processing time upper bound */;
int64_t cur64, start64; int64_t cur64, start64;
int max_delay;
cur64 = timespec_to_us64(cur); cur64 = timespec_to_us64(cur);
start64 = timespec_to_us64(&ts_usr); start64 = timespec_to_us64(&ts_usr);
max_delay = min_delay + cfg_delay_tolerance_usec;
if (cur64 < start64 + min_delay || cur64 > start64 + max_delay) { if (cur64 < start64 + min_delay || cur64 > start64 + max_delay) {
fprintf(stderr, "ERROR: %lu us expected between %d and %d\n", fprintf(stderr, "ERROR: %lu us expected between %d and %d\n",
...@@ -683,6 +685,7 @@ static void __attribute__((noreturn)) usage(const char *filepath) ...@@ -683,6 +685,7 @@ static void __attribute__((noreturn)) usage(const char *filepath)
" -r: use raw\n" " -r: use raw\n"
" -R: use raw (IP_HDRINCL)\n" " -R: use raw (IP_HDRINCL)\n"
" -S N: usec to sleep before reading error queue\n" " -S N: usec to sleep before reading error queue\n"
" -t N: tolerance (usec) for timestamp validation\n"
" -u: use udp\n" " -u: use udp\n"
" -v: validate SND delay (usec)\n" " -v: validate SND delay (usec)\n"
" -V: validate ACK delay (usec)\n" " -V: validate ACK delay (usec)\n"
...@@ -697,7 +700,7 @@ static void parse_opt(int argc, char **argv) ...@@ -697,7 +700,7 @@ static void parse_opt(int argc, char **argv)
int c; int c;
while ((c = getopt(argc, argv, while ((c = getopt(argc, argv,
"46bc:CeEFhIl:LnNp:PrRS:uv:V:x")) != -1) { "46bc:CeEFhIl:LnNp:PrRS:t:uv:V:x")) != -1) {
switch (c) { switch (c) {
case '4': case '4':
do_ipv6 = 0; do_ipv6 = 0;
...@@ -760,6 +763,9 @@ static void parse_opt(int argc, char **argv) ...@@ -760,6 +763,9 @@ static void parse_opt(int argc, char **argv)
case 'S': case 'S':
cfg_sleep_usec = strtoul(optarg, NULL, 10); cfg_sleep_usec = strtoul(optarg, NULL, 10);
break; break;
case 't':
cfg_delay_tolerance_usec = strtoul(optarg, NULL, 10);
break;
case 'u': case 'u':
proto_count++; proto_count++;
cfg_proto = SOCK_DGRAM; cfg_proto = SOCK_DGRAM;
......
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