Commit 5dce8379 authored by Vinicius Costa Gomes's avatar Vinicius Costa Gomes Committed by David S. Miller

selftests/txtimestamp: Add more configurable parameters

Add a way to configure if poll() should wait forever for an event, the
number of packets that should be sent for each and if there should be
any delay between packets.
Signed-off-by: default avatarVinicius Costa Gomes <vinicius.gomes@intel.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 5eb297a9
...@@ -68,9 +68,11 @@ static int cfg_num_pkts = 4; ...@@ -68,9 +68,11 @@ static int cfg_num_pkts = 4;
static int do_ipv4 = 1; static int do_ipv4 = 1;
static int do_ipv6 = 1; static int do_ipv6 = 1;
static int cfg_payload_len = 10; static int cfg_payload_len = 10;
static int cfg_poll_timeout = 100;
static bool cfg_show_payload; static bool cfg_show_payload;
static bool cfg_do_pktinfo; static bool cfg_do_pktinfo;
static bool cfg_loop_nodata; static bool cfg_loop_nodata;
static bool cfg_no_delay;
static uint16_t dest_port = 9000; static uint16_t dest_port = 9000;
static struct sockaddr_in daddr; static struct sockaddr_in daddr;
...@@ -171,7 +173,7 @@ static void __poll(int fd) ...@@ -171,7 +173,7 @@ static void __poll(int fd)
memset(&pollfd, 0, sizeof(pollfd)); memset(&pollfd, 0, sizeof(pollfd));
pollfd.fd = fd; pollfd.fd = fd;
ret = poll(&pollfd, 1, 100); ret = poll(&pollfd, 1, cfg_poll_timeout);
if (ret != 1) if (ret != 1)
error(1, errno, "poll"); error(1, errno, "poll");
} }
...@@ -371,7 +373,8 @@ static void do_test(int family, unsigned int opt) ...@@ -371,7 +373,8 @@ static void do_test(int family, unsigned int opt)
error(1, errno, "send"); error(1, errno, "send");
/* wait for all errors to be queued, else ACKs arrive OOO */ /* wait for all errors to be queued, else ACKs arrive OOO */
usleep(50 * 1000); if (!cfg_no_delay)
usleep(50 * 1000);
__poll(fd); __poll(fd);
...@@ -392,6 +395,9 @@ static void __attribute__((noreturn)) usage(const char *filepath) ...@@ -392,6 +395,9 @@ static void __attribute__((noreturn)) usage(const char *filepath)
" -4: only IPv4\n" " -4: only IPv4\n"
" -6: only IPv6\n" " -6: only IPv6\n"
" -h: show this message\n" " -h: show this message\n"
" -c N: number of packets for each test\n"
" -D: no delay between packets\n"
" -F: poll() waits forever for an event\n"
" -I: request PKTINFO\n" " -I: request PKTINFO\n"
" -l N: send N bytes at a time\n" " -l N: send N bytes at a time\n"
" -n: set no-payload option\n" " -n: set no-payload option\n"
...@@ -409,7 +415,7 @@ static void parse_opt(int argc, char **argv) ...@@ -409,7 +415,7 @@ static void parse_opt(int argc, char **argv)
int proto_count = 0; int proto_count = 0;
char c; char c;
while ((c = getopt(argc, argv, "46hIl:np:rRux")) != -1) { while ((c = getopt(argc, argv, "46c:DFhIl:np:rRux")) != -1) {
switch (c) { switch (c) {
case '4': case '4':
do_ipv6 = 0; do_ipv6 = 0;
...@@ -417,6 +423,15 @@ static void parse_opt(int argc, char **argv) ...@@ -417,6 +423,15 @@ static void parse_opt(int argc, char **argv)
case '6': case '6':
do_ipv4 = 0; do_ipv4 = 0;
break; break;
case 'c':
cfg_num_pkts = strtoul(optarg, NULL, 10);
break;
case 'D':
cfg_no_delay = true;
break;
case 'F':
cfg_poll_timeout = -1;
break;
case 'I': case 'I':
cfg_do_pktinfo = true; cfg_do_pktinfo = true;
break; break;
......
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