iproute/SOURCES/0019-vdpa-Support-reading-device-features.patch

100 lines
3.4 KiB
Diff
Raw Normal View History

2022-05-10 07:16:50 +00:00
From c98dd268d17c4faa19dac141f69597096bf0dfa4 Mon Sep 17 00:00:00 2001
Message-Id: <c98dd268d17c4faa19dac141f69597096bf0dfa4.1647872200.git.aclaudi@redhat.com>
In-Reply-To: <b30268eda844bdebbb8e5e4f5735e3b1bb666368.1647872200.git.aclaudi@redhat.com>
References: <b30268eda844bdebbb8e5e4f5735e3b1bb666368.1647872200.git.aclaudi@redhat.com>
From: Andrea Claudi <aclaudi@redhat.com>
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 <elic@nvidia.com>
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 <si-wei.liu@oracle.com>
Acked-by: Jason Wang <jasowang@redhat.com>
Signed-off-by: Eli Cohen <elic@nvidia.com>
Signed-off-by: David Ahern <dsahern@kernel.org>
---
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