summaryrefslogtreecommitdiffstats
path: root/samples/bpf/xdp_rxq_info_user.c
diff options
context:
space:
mode:
authorJesper Dangaard Brouer <brouer@redhat.com>2018-06-25 16:27:48 +0200
committerDaniel Borkmann <daniel@iogearbox.net>2018-06-28 23:50:20 +0200
commit509fda105ba8f9a1a5c6f8b79e4c7fc50b35c1e3 (patch)
treec71cfab13dad3b8bab03a29004d286dc514daf07 /samples/bpf/xdp_rxq_info_user.c
parent0d25c43ab988766ad52ff2930af3bf47d92c20ac (diff)
downloadlinux-509fda105ba8f9a1a5c6f8b79e4c7fc50b35c1e3.tar.gz
linux-509fda105ba8f9a1a5c6f8b79e4c7fc50b35c1e3.tar.bz2
linux-509fda105ba8f9a1a5c6f8b79e4c7fc50b35c1e3.zip
samples/bpf: xdp_rxq_info action XDP_TX must adjust MAC-addrs
XDP_TX requires also changing the MAC-addrs, else some hardware may drop the TX packet before reaching the wire. This was observed with driver mlx5. If xdp_rxq_info select --action XDP_TX the swapmac functionality is activated. It is also possible to manually enable via cmdline option --swapmac. This is practical if wanting to measure the overhead of writing/updating payload for other action types. Signed-off-by: Jesper Dangaard Brouer <brouer@redhat.com> Signed-off-by: Toke Høiland-Jørgensen <toke@toke.dk> Acked-by: Song Liu <songliubraving@fb.com> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Diffstat (limited to 'samples/bpf/xdp_rxq_info_user.c')
-rw-r--r--samples/bpf/xdp_rxq_info_user.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/samples/bpf/xdp_rxq_info_user.c b/samples/bpf/xdp_rxq_info_user.c
index 435485d4f49e..248a7eab9531 100644
--- a/samples/bpf/xdp_rxq_info_user.c
+++ b/samples/bpf/xdp_rxq_info_user.c
@@ -51,6 +51,7 @@ static const struct option long_options[] = {
{"no-separators", no_argument, NULL, 'z' },
{"action", required_argument, NULL, 'a' },
{"readmem", no_argument, NULL, 'r' },
+ {"swapmac", no_argument, NULL, 'm' },
{0, 0, NULL, 0 }
};
@@ -72,6 +73,7 @@ struct config {
enum cfg_options_flags {
NO_TOUCH = 0x0U,
READ_MEM = 0x1U,
+ SWAP_MAC = 0x2U,
};
#define XDP_ACTION_MAX (XDP_TX + 1)
#define XDP_ACTION_MAX_STRLEN 11
@@ -119,6 +121,8 @@ static char* options2str(enum cfg_options_flags flag)
{
if (flag == NO_TOUCH)
return "no_touch";
+ if (flag & SWAP_MAC)
+ return "swapmac";
if (flag & READ_MEM)
return "read";
fprintf(stderr, "ERR: Unknown config option flags");
@@ -517,6 +521,9 @@ int main(int argc, char **argv)
case 'r':
cfg_options |= READ_MEM;
break;
+ case 'm':
+ cfg_options |= SWAP_MAC;
+ break;
case 'h':
error:
default:
@@ -543,6 +550,10 @@ int main(int argc, char **argv)
}
}
cfg.action = action;
+
+ /* XDP_TX requires changing MAC-addrs, else HW may drop */
+ if (action == XDP_TX)
+ cfg_options |= SWAP_MAC;
cfg.options = cfg_options;
/* Trick to pretty printf with thousands separators use %' */