Message ID | 20220217123024.33201-5-elic@nvidia.com (mailing list archive) |
---|---|
State | Superseded |
Delegated to: | Netdev Maintainers |
Headers | show |
Series | vdpa tool enhancements | expand |
Context | Check | Description |
---|---|---|
netdev/tree_selection | success | Not a local patch |
在 2022/2/17 下午8:30, Eli Cohen 写道: > 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> > Signed-off-by: Eli Cohen <elic@nvidia.com> > --- > vdpa/include/uapi/linux/vdpa.h | 1 + > vdpa/vdpa.c | 14 +++++++++++++- > 2 files changed, 14 insertions(+), 1 deletion(-) > > diff --git a/vdpa/include/uapi/linux/vdpa.h b/vdpa/include/uapi/linux/vdpa.h > index a3ebf4d4d9b8..96ccbf305d14 100644 > --- a/vdpa/include/uapi/linux/vdpa.h > +++ b/vdpa/include/uapi/linux/vdpa.h > @@ -42,6 +42,7 @@ enum vdpa_attr { > > VDPA_ATTR_DEV_NEGOTIATED_FEATURES, /* u64 */ > VDPA_ATTR_DEV_MGMTDEV_MAX_VQS, /* u32 */ > + VDPA_ATTR_DEV_SUPPORTED_FEATURES, /* u64 */ > > /* new attributes must be added above here */ > VDPA_ATTR_MAX, > diff --git a/vdpa/vdpa.c b/vdpa/vdpa.c > index 78736b1422b6..bdc366880ab9 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) > @@ -494,13 +495,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++) { > @@ -522,6 +524,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); I wonder what happens if we try to read a virtio_blk device consider: static const char * const *dev_to_feature_str[] = { [VIRTIO_ID_NET] = net_feature_strs, }; Thanks > + } > + > pr_out_handle_end(vdpa); > } >
On Mon, Feb 21, 2022 at 12:18:03PM +0800, Jason Wang wrote: > > 在 2022/2/17 下午8:30, Eli Cohen 写道: > > 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> > > Signed-off-by: Eli Cohen <elic@nvidia.com> > > --- > > vdpa/include/uapi/linux/vdpa.h | 1 + > > vdpa/vdpa.c | 14 +++++++++++++- > > 2 files changed, 14 insertions(+), 1 deletion(-) > > > > diff --git a/vdpa/include/uapi/linux/vdpa.h b/vdpa/include/uapi/linux/vdpa.h > > index a3ebf4d4d9b8..96ccbf305d14 100644 > > --- a/vdpa/include/uapi/linux/vdpa.h > > +++ b/vdpa/include/uapi/linux/vdpa.h > > @@ -42,6 +42,7 @@ enum vdpa_attr { > > VDPA_ATTR_DEV_NEGOTIATED_FEATURES, /* u64 */ > > VDPA_ATTR_DEV_MGMTDEV_MAX_VQS, /* u32 */ > > + VDPA_ATTR_DEV_SUPPORTED_FEATURES, /* u64 */ > > /* new attributes must be added above here */ > > VDPA_ATTR_MAX, > > diff --git a/vdpa/vdpa.c b/vdpa/vdpa.c > > index 78736b1422b6..bdc366880ab9 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) > > @@ -494,13 +495,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++) { > > @@ -522,6 +524,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); > > > I wonder what happens if we try to read a virtio_blk device consider: > > static const char * const *dev_to_feature_str[] = { > [VIRTIO_ID_NET] = net_feature_strs, > }; In that case we will print bit_xx for each non general bit. > > Thanks > > > > + } > > + > > pr_out_handle_end(vdpa); > > } >
diff --git a/vdpa/include/uapi/linux/vdpa.h b/vdpa/include/uapi/linux/vdpa.h index a3ebf4d4d9b8..96ccbf305d14 100644 --- a/vdpa/include/uapi/linux/vdpa.h +++ b/vdpa/include/uapi/linux/vdpa.h @@ -42,6 +42,7 @@ enum vdpa_attr { VDPA_ATTR_DEV_NEGOTIATED_FEATURES, /* u64 */ VDPA_ATTR_DEV_MGMTDEV_MAX_VQS, /* u32 */ + VDPA_ATTR_DEV_SUPPORTED_FEATURES, /* u64 */ /* new attributes must be added above here */ VDPA_ATTR_MAX, diff --git a/vdpa/vdpa.c b/vdpa/vdpa.c index 78736b1422b6..bdc366880ab9 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) @@ -494,13 +495,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++) { @@ -522,6 +524,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); }