Skip to content
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

Merged
merged 2 commits into from
Jun 8, 2023
Merged

Conversation

LorenzoBianconi
Copy link
Contributor

Add features command to xdp-loader in order to dump XDP features supported by the NIC

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
@LorenzoBianconi LorenzoBianconi force-pushed the xdp-loader-features branch 2 times, most recently from 4076c16 to f2dbadb Compare May 24, 2023 16:50
Copy link
Member

@tohojo tohojo left a 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 Show resolved Hide resolved
static struct prog_option features_options[] = {
DEFINE_OPTION("dev", OPT_IFNAME, struct featuresopt, iface,
.positional = true,
.metavar = "[ifname]",
Copy link
Member

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...

.positional = true,
.metavar = "[ifname]",
.required = true,
.help = "Show XDP features for device [ifname]"),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

...also here

xdp-loader/xdp-loader.8 Show resolved Hide resolved
xdp-loader/xdp-loader.c Show resolved Hide resolved
@LorenzoBianconi LorenzoBianconi force-pushed the xdp-loader-features branch 2 times, most recently from 85ed5d4 to bb680e2 Compare June 1, 2023 15:07
Copy link
Member

@tohojo tohojo left a 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...


.SS "NETDEV_XDP_ACT_BASIC"
.PP
XDP feautues set supported by all drivers (XDP_ABORTED, XDP_DROP, XDP_PASS,
Copy link
Member

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)."


.SS "NETDEV_XDP_ACT_REDIRECT"
.PP
The netdev supports XDP_REDIRECT.
Copy link
Member

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."


.SS "NETDEV_XDP_ACT_NDO_XMIT"
.PP
This feature informs if netdev implements ndo_xdp_xmit callback.
Copy link
Member

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."


.SS "NETDEV_XDP_ACT_XSK_ZEROCOPY"
.PP
This feature informs if netdev supports AF_XDP in zero copy mode.
Copy link
Member

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)


.SS "NETDEV_XDP_ACT_HW_OFFLOAD"
.PP
This feature informs if netdev supports XDP hw offloading.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"The networking device supports..."

.SS "NETDEV_XDP_ACT_RX_SG"
.PP
This feature informs if netdev implements non-linear XDP buffer support in the
driver napi callback.
Copy link
Member

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)."

.SS "NETDEV_XDP_ACT_NDO_XMIT_SG"
.PP
This feature informs if netdev implements non-linear XDP buffer support in
ndo_xdp_xmit callback.
Copy link
Member

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."

#else
__unused const void *i = iface;

pr_debug("bpf_xdp_query_opts not supported.\n");
Copy link
Member

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."

{
if ! grep -q xdp_set_features_flag /proc/kallsyms; then
exit "$SKIPPED_TEST"
fi
Copy link
Member

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...


err = bpf_xdp_query(iface->ifindex, 0, &opts);
if (err) {
pr_debug("bpf_xdp_query failed (%d)\n", err);
Copy link
Member

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")

Copy link
Member

@tohojo tohojo left a 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.

{
check_run ip link add dev v0 type veth peer name v1

$XDP_LOADER features "$1" | grep "$2" | grep -q "$3"
Copy link
Member

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...

Copy link
Contributor Author

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

@LorenzoBianconi
Copy link
Contributor Author

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.

@tohojo ack, I will fix it

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"
Copy link
Member

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...

Copy link
Contributor Author

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

Add features command to xdp-loader in order to dump XDP features
supported by the NIC.

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
@tohojo tohojo merged commit 870db97 into xdp-project:master Jun 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants