Commit 58c50ae4 authored by Björn Töpel's avatar Björn Töpel Committed by Alexei Starovoitov

samples/bpf: add -c/--copy -z/--zero-copy flags to xdpsock

The -c/--copy -z/--zero-copy flags enforces either copy or zero-copy
mode.
Signed-off-by: default avatarBjörn Töpel <bjorn.topel@intel.com>
Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
parent 1328dcdd
...@@ -649,6 +649,8 @@ static struct option long_options[] = { ...@@ -649,6 +649,8 @@ static struct option long_options[] = {
{"xdp-skb", no_argument, 0, 'S'}, {"xdp-skb", no_argument, 0, 'S'},
{"xdp-native", no_argument, 0, 'N'}, {"xdp-native", no_argument, 0, 'N'},
{"interval", required_argument, 0, 'n'}, {"interval", required_argument, 0, 'n'},
{"zero-copy", no_argument, 0, 'z'},
{"copy", no_argument, 0, 'c'},
{0, 0, 0, 0} {0, 0, 0, 0}
}; };
...@@ -667,6 +669,8 @@ static void usage(const char *prog) ...@@ -667,6 +669,8 @@ static void usage(const char *prog)
" -S, --xdp-skb=n Use XDP skb-mod\n" " -S, --xdp-skb=n Use XDP skb-mod\n"
" -N, --xdp-native=n Enfore XDP native mode\n" " -N, --xdp-native=n Enfore XDP native mode\n"
" -n, --interval=n Specify statistics update interval (default 1 sec).\n" " -n, --interval=n Specify statistics update interval (default 1 sec).\n"
" -z, --zero-copy Force zero-copy mode.\n"
" -c, --copy Force copy mode.\n"
"\n"; "\n";
fprintf(stderr, str, prog); fprintf(stderr, str, prog);
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
...@@ -679,7 +683,7 @@ static void parse_command_line(int argc, char **argv) ...@@ -679,7 +683,7 @@ static void parse_command_line(int argc, char **argv)
opterr = 0; opterr = 0;
for (;;) { for (;;) {
c = getopt_long(argc, argv, "rtli:q:psSNn:", long_options, c = getopt_long(argc, argv, "rtli:q:psSNn:cz", long_options,
&option_index); &option_index);
if (c == -1) if (c == -1)
break; break;
...@@ -716,6 +720,12 @@ static void parse_command_line(int argc, char **argv) ...@@ -716,6 +720,12 @@ static void parse_command_line(int argc, char **argv)
case 'n': case 'n':
opt_interval = atoi(optarg); opt_interval = atoi(optarg);
break; break;
case 'z':
opt_xdp_bind_flags |= XDP_ZEROCOPY;
break;
case 'c':
opt_xdp_bind_flags |= XDP_COPY;
break;
default: default:
usage(basename(argv[0])); usage(basename(argv[0]));
} }
......
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