From: Ederson de Souza <ederson.desouza@intel.com>
To: xdp-hints@xdp-project.net
Cc: bpf@vger.kernel.org, Saeed Mahameed <saeedm@mellanox.com>
Subject: [[RFC xdp-hints] 03/16] tools/bpf: Query XDP metadata BTF ID
Date: Mon, 2 Aug 2021 18:03:18 -0700 [thread overview]
Message-ID: <20210803010331.39453-4-ederson.desouza@intel.com> (raw)
In-Reply-To: <20210803010331.39453-1-ederson.desouza@intel.com>
From: Saeed Mahameed <saeedm@mellanox.com>
When dumping bpf net information, also query XDP MD BTF attributes:
$ /usr/local/sbin/bpftool net
xdp:
mlx0(3) md_btf_id(1) md_btf_enabled(0)
tc:
flow_dissector:
Issue: 2114293
Change-Id: Ifef542ecf3defe4204947618c07cc3eac45b39f9
Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
---
tools/bpf/bpftool/netlink_dumper.c | 21 +++++++++++++++++----
tools/include/uapi/linux/if_link.h | 2 ++
2 files changed, 19 insertions(+), 4 deletions(-)
diff --git a/tools/bpf/bpftool/netlink_dumper.c b/tools/bpf/bpftool/netlink_dumper.c
index 5f65140b003b..17807a3312ff 100644
--- a/tools/bpf/bpftool/netlink_dumper.c
+++ b/tools/bpf/bpftool/netlink_dumper.c
@@ -29,23 +29,36 @@ static void xdp_dump_prog_id(struct nlattr **tb, int attr,
static int do_xdp_dump_one(struct nlattr *attr, unsigned int ifindex,
const char *name)
{
+ unsigned char mode = XDP_ATTACHED_NONE;
struct nlattr *tb[IFLA_XDP_MAX + 1];
- unsigned char mode;
+ unsigned char md_btf_enabled = 0;
+ unsigned int md_btf_id = 0;
+ bool attached;
if (libbpf_nla_parse_nested(tb, IFLA_XDP_MAX, attr, NULL) < 0)
return -1;
- if (!tb[IFLA_XDP_ATTACHED])
+ if (!tb[IFLA_XDP_ATTACHED] && !tb[IFLA_XDP_MD_BTF_ID])
return 0;
- mode = libbpf_nla_getattr_u8(tb[IFLA_XDP_ATTACHED]);
- if (mode == XDP_ATTACHED_NONE)
+ if (tb[IFLA_XDP_ATTACHED])
+ mode = libbpf_nla_getattr_u8(tb[IFLA_XDP_ATTACHED]);
+
+ if (tb[IFLA_XDP_MD_BTF_ID]) {
+ md_btf_id = libbpf_nla_getattr_u32(tb[IFLA_XDP_MD_BTF_ID]);
+ md_btf_enabled = libbpf_nla_getattr_u8(tb[IFLA_XDP_MD_BTF_STATE]);
+ }
+
+ attached = (mode != XDP_ATTACHED_NONE);
+ if (!attached && !md_btf_id)
return 0;
NET_START_OBJECT;
if (name)
NET_DUMP_STR("devname", "%s", name);
NET_DUMP_UINT("ifindex", "(%d)", ifindex);
+ NET_DUMP_UINT("md_btf_id", " md_btf_id(%d)", md_btf_id);
+ NET_DUMP_UINT("md_btf_enabled", " md_btf_enabled(%d)", md_btf_enabled);
if (mode == XDP_ATTACHED_MULTI) {
if (json_output) {
diff --git a/tools/include/uapi/linux/if_link.h b/tools/include/uapi/linux/if_link.h
index d208b2af697f..9b45bb3327c2 100644
--- a/tools/include/uapi/linux/if_link.h
+++ b/tools/include/uapi/linux/if_link.h
@@ -992,6 +992,8 @@ enum {
IFLA_XDP_SKB_PROG_ID,
IFLA_XDP_HW_PROG_ID,
IFLA_XDP_EXPECTED_FD,
+ IFLA_XDP_MD_BTF_ID,
+ IFLA_XDP_MD_BTF_STATE,
__IFLA_XDP_MAX,
};
--
2.32.0
next prev parent reply other threads:[~2021-08-03 1:03 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-08-03 1:03 [[RFC xdp-hints] 00/16] XDP hints and AF_XDP support Ederson de Souza
2021-08-03 1:03 ` [[RFC xdp-hints] 01/16] bpf: add btf register/unregister API Ederson de Souza
2021-08-03 1:03 ` [[RFC xdp-hints] 02/16] net/core: XDP metadata BTF netlink API Ederson de Souza
2021-08-03 1:03 ` Ederson de Souza [this message]
2021-08-03 1:03 ` [[RFC xdp-hints] 04/16] tools/bpf: Add xdp set command for md btf Ederson de Souza
2021-08-03 1:03 ` [[RFC xdp-hints] 05/16] igc: Fix race condition in PTP Tx code Ederson de Souza
2021-08-03 1:03 ` [[RFC xdp-hints] 06/16] igc: Retrieve the TX timestamp directly (instead of in a interrupt) Ederson de Souza
2021-08-03 1:03 ` [[RFC xdp-hints] 07/16] igc: Add support for multiple in-flight TX timestamps Ederson de Souza
2021-08-03 1:03 ` [[RFC xdp-hints] 08/16] igc: Use irq safe locks for timestamping Ederson de Souza
2021-08-03 1:03 ` [[RFC xdp-hints] 09/16] net/xdp: Support for generic XDP hints Ederson de Souza
2021-08-03 1:03 ` [[RFC xdp-hints] 10/16] igc: XDP packet RX timestamp Ederson de Souza
2021-08-03 1:03 ` [[RFC xdp-hints] 11/16] igc: XDP packet TX timestamp Ederson de Souza
2021-08-03 1:03 ` [[RFC xdp-hints] 12/16] ethtool,igc: Add "xdp_headroom" driver info Ederson de Souza
2021-08-03 1:03 ` [[RFC xdp-hints] 13/16] libbpf: Helpers to access XDP frame metadata Ederson de Souza
2021-08-06 22:59 ` Andrii Nakryiko
2021-08-19 11:47 ` Toke Høiland-Jørgensen
2021-08-03 1:03 ` [[RFC xdp-hints] 14/16] libbpf: Helpers to access XDP hints based on BTF definitions Ederson de Souza
2021-08-03 1:03 ` [[RFC xdp-hints] 15/16] samples/bpf: XDP hints AF_XDP example Ederson de Souza
2021-08-03 1:03 ` [[RFC xdp-hints] 16/16] samples/bpf: Show XDP hints usage Ederson de Souza
2021-08-06 23:14 ` Andrii Nakryiko
2021-08-03 9:12 ` [[RFC xdp-hints] 00/16] XDP hints and AF_XDP support Alexander Lobakin
2021-08-03 15:23 ` John Fastabend
2021-08-04 15:15 ` Alexander Lobakin
2021-08-04 23:45 ` John Fastabend
2021-08-13 22:04 ` Desouza, Ederson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210803010331.39453-4-ederson.desouza@intel.com \
--to=ederson.desouza@intel.com \
--cc=bpf@vger.kernel.org \
--cc=saeedm@mellanox.com \
--cc=xdp-hints@xdp-project.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.