From c98dd268d17c4faa19dac141f69597096bf0dfa4 Mon Sep 17 00:00:00 2001 Message-Id: In-Reply-To: References: From: Andrea Claudi Date: Mon, 21 Mar 2022 15:03:16 +0100 Subject: [PATCH] vdpa: Support reading device features Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2056827 Upstream Status: iproute2-next.git commit 56eb8bf4 commit 56eb8bf45aa3d509eb119201341d0323ea81ef84 Author: Eli Cohen Date: Sun Mar 13 19:12:19 2022 +0200 vdpa: Support reading device features When showing the available management devices, check if VDPA_ATTR_DEV_SUPPORTED_FEATURES feature is available and print the supported features for a management device. Examples: $ vdpa mgmtdev show auxiliary/mlx5_core.sf.1: supported_classes net max_supported_vqs 257 dev_features CSUM GUEST_CSUM MTU HOST_TSO4 HOST_TSO6 STATUS CTRL_VQ MQ \ CTRL_MAC_ADDR VERSION_1 ACCESS_PLATFORM $ vdpa -jp mgmtdev show { "mgmtdev": { "auxiliary/mlx5_core.sf.1": { "supported_classes": [ "net" ], "max_supported_vqs": 257, "dev_features": [ "CSUM","GUEST_CSUM","MTU","HOST_TSO4","HOST_TSO6","STATUS","CTRL_VQ","MQ",\ "CTRL_MAC_ADDR","VERSION_1","ACCESS_PLATFORM" ] } } } Reviewed-by: Si-Wei Liu Acked-by: Jason Wang Signed-off-by: Eli Cohen Signed-off-by: David Ahern --- vdpa/vdpa.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/vdpa/vdpa.c b/vdpa/vdpa.c index 9985b6ca..3ae1b78f 100644 --- a/vdpa/vdpa.c +++ b/vdpa/vdpa.c @@ -84,6 +84,7 @@ static const enum mnl_attr_data_type vdpa_policy[VDPA_ATTR_MAX + 1] = { [VDPA_ATTR_DEV_MAX_VQ_SIZE] = MNL_TYPE_U16, [VDPA_ATTR_DEV_NEGOTIATED_FEATURES] = MNL_TYPE_U64, [VDPA_ATTR_DEV_MGMTDEV_MAX_VQS] = MNL_TYPE_U32, + [VDPA_ATTR_DEV_SUPPORTED_FEATURES] = MNL_TYPE_U64, }; static int attr_cb(const struct nlattr *attr, void *data) @@ -492,14 +493,14 @@ static void print_features(struct vdpa *vdpa, uint64_t features, bool mgmtdevf, static void pr_out_mgmtdev_show(struct vdpa *vdpa, const struct nlmsghdr *nlh, struct nlattr **tb) { + uint64_t classes = 0; const char *class; unsigned int i; pr_out_handle_start(vdpa, tb); if (tb[VDPA_ATTR_MGMTDEV_SUPPORTED_CLASSES]) { - uint64_t classes = mnl_attr_get_u64(tb[VDPA_ATTR_MGMTDEV_SUPPORTED_CLASSES]); - + classes = mnl_attr_get_u64(tb[VDPA_ATTR_MGMTDEV_SUPPORTED_CLASSES]); pr_out_array_start(vdpa, "supported_classes"); for (i = 1; i < 64; i++) { @@ -520,6 +521,16 @@ static void pr_out_mgmtdev_show(struct vdpa *vdpa, const struct nlmsghdr *nlh, print_uint(PRINT_ANY, "max_supported_vqs", " max_supported_vqs %d", num_vqs); } + if (tb[VDPA_ATTR_DEV_SUPPORTED_FEATURES]) { + uint64_t features; + + features = mnl_attr_get_u64(tb[VDPA_ATTR_DEV_SUPPORTED_FEATURES]); + if (classes & BIT(VIRTIO_ID_NET)) + print_features(vdpa, features, true, VIRTIO_ID_NET); + else + print_features(vdpa, features, true, 0); + } + pr_out_handle_end(vdpa); } -- 2.35.1