From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by mail.toke.dk (Postfix) with ESMTPS id 4C21686C9A4 for ; Tue, 3 Aug 2021 03:03:56 +0200 (CEST) X-IronPort-AV: E=McAfee;i="6200,9189,10064"; a="211691855" X-IronPort-AV: E=Sophos;i="5.84,290,1620716400"; d="scan'208";a="211691855" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Aug 2021 18:03:49 -0700 X-IronPort-AV: E=Sophos;i="5.84,290,1620716400"; d="scan'208";a="419480109" Received: from ticela-or-032.amr.corp.intel.com (HELO localhost.localdomain) ([10.212.166.34]) by orsmga003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Aug 2021 18:03:48 -0700 From: Ederson de Souza To: xdp-hints@xdp-project.net Subject: [[RFC xdp-hints] 03/16] tools/bpf: Query XDP metadata BTF ID Date: Mon, 2 Aug 2021 18:03:18 -0700 Message-Id: <20210803010331.39453-4-ederson.desouza@intel.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210803010331.39453-1-ederson.desouza@intel.com> References: <20210803010331.39453-1-ederson.desouza@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-ID-Hash: YOA7VTWKIVCUVMEC4MNJVE5V5QGU7S7H X-Message-ID-Hash: YOA7VTWKIVCUVMEC4MNJVE5V5QGU7S7H X-MailFrom: ederson.desouza@intel.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: bpf@vger.kernel.org, Saeed Mahameed X-Mailman-Version: 3.3.4 Precedence: list List-Id: XDP hardware hints design discussion Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Saeed Mahameed 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 --- 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