-
Notifications
You must be signed in to change notification settings - Fork 158
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
xdp loader features #324
xdp loader features #324
Conversation
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
4076c16
to
f2dbadb
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few comments. Also, CI is failing, PTAL...
xdp-loader/xdp-loader.c
Outdated
static struct prog_option features_options[] = { | ||
DEFINE_OPTION("dev", OPT_IFNAME, struct featuresopt, iface, | ||
.positional = true, | ||
.metavar = "[ifname]", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be <ifname>
, since the parameter is not optional...
xdp-loader/xdp-loader.c
Outdated
.positional = true, | ||
.metavar = "[ifname]", | ||
.required = true, | ||
.help = "Show XDP features for device [ifname]"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
...also here
85ed5d4
to
bb680e2
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few more nits, mostly UI things...
xdp-loader/xdp-loader.8
Outdated
|
||
.SS "NETDEV_XDP_ACT_BASIC" | ||
.PP | ||
XDP feautues set supported by all drivers (XDP_ABORTED, XDP_DROP, XDP_PASS, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"The networking device has basic support for running XDP programs, and can handle the base set of return codes (XDP_ABORTED, XDP_DROP, XDP_PASS, XDP_TX)."
xdp-loader/xdp-loader.8
Outdated
|
||
.SS "NETDEV_XDP_ACT_REDIRECT" | ||
.PP | ||
The netdev supports XDP_REDIRECT. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"The network device supports handling the XDP_REDIRECT return code. This means packets can be redirected from this device by XDP."
xdp-loader/xdp-loader.8
Outdated
|
||
.SS "NETDEV_XDP_ACT_NDO_XMIT" | ||
.PP | ||
This feature informs if netdev implements ndo_xdp_xmit callback. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"The networking interfaces implements the ndo_xdp_xmit callback. This means packets can be redirected to this device by XDP."
xdp-loader/xdp-loader.8
Outdated
|
||
.SS "NETDEV_XDP_ACT_XSK_ZEROCOPY" | ||
.PP | ||
This feature informs if netdev supports AF_XDP in zero copy mode. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"The networking device supports..." (let's be consistent with the phrasing)
xdp-loader/xdp-loader.8
Outdated
|
||
.SS "NETDEV_XDP_ACT_HW_OFFLOAD" | ||
.PP | ||
This feature informs if netdev supports XDP hw offloading. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"The networking device supports..."
xdp-loader/xdp-loader.8
Outdated
.SS "NETDEV_XDP_ACT_RX_SG" | ||
.PP | ||
This feature informs if netdev implements non-linear XDP buffer support in the | ||
driver napi callback. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"The networking device supports non-linear XDP frames on the receive side. This means XDP can be used with big MTUs on this device (if the XDP program is compiled with fragments support)."
xdp-loader/xdp-loader.8
Outdated
.SS "NETDEV_XDP_ACT_NDO_XMIT_SG" | ||
.PP | ||
This feature informs if netdev implements non-linear XDP buffer support in | ||
ndo_xdp_xmit callback. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"The networking device supports non-linear XDP frames on the transmit side. This means non-linear frames can be redirected to this device."
xdp-loader/xdp-loader.c
Outdated
#else | ||
__unused const void *i = iface; | ||
|
||
pr_debug("bpf_xdp_query_opts not supported.\n"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pr_debug is not printed by default, so this would still give no output by default. Let's make it a pr_warn, and a more friendly message, like: "Cannot display features, because xdp-loader was compiled against an old version of libbpf without support for querying features."
lib/testing/test_runner.sh
Outdated
{ | ||
if ! grep -q xdp_set_features_flag /proc/kallsyms; then | ||
exit "$SKIPPED_TEST" | ||
fi |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's a skip_if_missing_kernel_symbol
method above, let's reuse that...
xdp-loader/xdp-loader.c
Outdated
|
||
err = bpf_xdp_query(iface->ifindex, 0, &opts); | ||
if (err) { | ||
pr_debug("bpf_xdp_query failed (%d)\n", err); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be a pr_warn(). And if possible, we should special-case the error code returned by old kernels and print something friendlier (like "The running kernel doesn't support querying XDP features")
bb680e2
to
d89591b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code LGTM with a small nit in the test script. However, I totally missed that you were editing the man page file directly. That won't work: the man page is generated by the Makefile from README.org
, so the changes have to go into that, and then the man page should be regenerated.
xdp-loader/tests/test-xdp-loader.sh
Outdated
{ | ||
check_run ip link add dev v0 type veth peer name v1 | ||
|
||
$XDP_LOADER features "$1" | grep "$2" | grep -q "$3" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems a bit odd to have the interface name passed in from the caller, since the device is created with a fixed name in the line above; i.e., any other argument than v0
as $1
will fail, so we may as well not have that argument at all...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tohojo ack, I will fix it
@tohojo ack, I will fix it |
d89591b
to
977cb03
Compare
configure
Outdated
@@ -283,6 +283,7 @@ check_libbpf_functions() | |||
check_libbpf_function "bpf_xdp_attach" "(0, 0, 0, NULL)" "" "$LIBBPF_CFLAGS" "$LIBBPF_LDLIBS" | |||
check_libbpf_function "bpf_map__set_autocreate" "(NULL, false)" "" "$LIBBPF_CFLAGS" "$LIBBPF_LDLIBS" | |||
check_libbpf_function "bpf_prog_test_run_opts" "(0, &opts)" "DECLARE_LIBBPF_OPTS(bpf_test_run_opts, opts, .batch_size = 1)" "$LIBBPF_CFLAGS" "$LIBBPF_LDLIBS" | |||
check_libbpf_function "bpf_xdp_query" "(0, &opts)" "DECLARE_LIBBPF_OPTS(bpf_xdp_query_opts, opts, .feature_flags = 1)" "$LIBBPF_CFLAGS" "$LIBBPF_LDLIBS" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The function call here (second argument) is missing the flags argument, so this check always fails...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tohojo ack, I will fix it
977cb03
to
5e669b5
Compare
Add features command to xdp-loader in order to dump XDP features supported by the NIC. Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
5e669b5
to
0f41b89
Compare
Add features command to xdp-loader in order to dump XDP features supported by the NIC