Conditionally read fields in dev cfg space
Subsystems (4)
cover Conditionally read fields in dev cfg space
This series intends to read the fields in virtio-net device configuration space conditionally on the feature bits, this means:
MTU exists if VIRTIO_NET_F_MTU is set
MAC exists if VIRTIO_NET_F_NET is set
MQ exists if VIRTIO_NET_F_MQ or VIRTIO_NET_F_RSS is set.
This series report device features to userspace and invokes vdpa_config_ops.get_config() than vdpa_get_config_unlocked() to read the device config spcae, so no raeces in vdpa_set_features_unlocked()
Thanks!
Zhu Lingshan (4):
vDPA: allow userspace to query features of a vDPA device
vDPA: only report driver features if FEATURES_OK is set
vDPA: check VIRTIO_NET_F_RSS for max_virtqueue_paris's presence
vDPA: Conditionally read MTU and MAC in dev cfg space
drivers/vdpa/vdpa.c | 68 ++++++++++++++++++++++++++++++--------- include/uapi/linux/vdpa.h | 4 +++ 2 files changed, 56 insertions(+), 16 deletions(-)
Signature · 1 line
2.31.1
PATCH 1/4 vDPA: allow userspace to query features of a vDPA device
This commit adds a new vDPA netlink attribution VDPA_ATTR_VDPA_DEV_SUPPORTED_FEATURES. Userspace can query features of vDPA devices through this new attr.
This commit invokes vdpa_config_ops.get_config() than vdpa_get_config_unlocked() to read the device config spcae, so no raeces in vdpa_set_features_unlocked()
--- drivers/vdpa/vdpa.c | 19 ++++++++++++++----- include/uapi/linux/vdpa.h | 4 ++++ 2 files changed, 18 insertions(+), 5 deletions(-)
drivers/vdpa/vdpa.c +14 -5
@@ -491,6 +491,8 @@ static int vdpa_mgmtdev_fill(const struct vdpa_mgmt_dev *mdev, struct sk_buff *m err = -EMSGSIZE ; goto msg_err; } + +/* report features of a vDPA management device through VDPA_ATTR_DEV_SUPPORTED_FEATURES */ if (nla_put_u64_64bit (msg,VDPA_ATTR_DEV_SUPPORTED_FEATURES , mdev->supported_features,VDPA_ATTR_PAD )) { err = -EMSGSIZE ;
@@ -815,10 +817,10 @@ static int vdpa_dev_net_mq_config_fill(struct vdpa_device *vdev,static int vdpa_dev_net_config_fill (struct vdpa_device *vdev,struct sk_buff *msg) {struct virtio_net_config config = {}; -u64 features; +u64 features_device, features_driver;u16 val_u16; -vdpa_get_config_unlocked (vdev,0 , &config,sizeof (config)); + vdev->config->get_config (vdev,0 , &config,sizeof (config));if (nla_put (msg,VDPA_ATTR_DEV_NET_CFG_MACADDR ,sizeof (config.mac), config.mac))
@@ -832,12 +834,19 @@ static int vdpa_dev_net_config_fill(struct vdpa_device *vdev, struct sk_buff *msif (nla_put_u16 (msg,VDPA_ATTR_DEV_NET_CFG_MTU , val_u16))return -EMSGSIZE ; - features = vdev->config->get_driver_features (vdev); -if (nla_put_u64_64bit (msg,VDPA_ATTR_DEV_NEGOTIATED_FEATURES , features, + features_driver = vdev->config->get_driver_features (vdev); +if (nla_put_u64_64bit (msg,VDPA_ATTR_DEV_NEGOTIATED_FEATURES , features_driver, +VDPA_ATTR_PAD )) +return -EMSGSIZE ; + + features_device = vdev->config->get_device_features (vdev); + +/* report features of a vDPA device through VDPA_ATTR_VDPA_DEV_SUPPORTED_FEATURES */ +if (nla_put_u64_64bit (msg,VDPA_ATTR_VDPA_DEV_SUPPORTED_FEATURES , features_device,VDPA_ATTR_PAD ))return -EMSGSIZE ; -return vdpa_dev_net_mq_config_fill (vdev, msg, features, &config); +return vdpa_dev_net_mq_config_fill (vdev, msg, features_driver, &config); } static int
include/uapi/linux/vdpa.h +4 -0
@@ -46,12 +46,16 @@ enum vdpa_attr {VDPA_ATTR_DEV_NEGOTIATED_FEATURES ,/* u64 */ VDPA_ATTR_DEV_MGMTDEV_MAX_VQS ,/* u32 */ +/* features of a vDPA management device */ VDPA_ATTR_DEV_SUPPORTED_FEATURES ,/* u64 */ VDPA_ATTR_DEV_QUEUE_INDEX ,/* u32 */ VDPA_ATTR_DEV_VENDOR_ATTR_NAME ,/* string */ VDPA_ATTR_DEV_VENDOR_ATTR_VALUE ,/* u64 */ +/* features of a vDPA device, e.g., /dev/vhost-vdpa0 */ +VDPA_ATTR_VDPA_DEV_SUPPORTED_FEATURES ,/* u64 */ +/* new attributes must be added above here */ VDPA_ATTR_MAX, };
Signature · 1 line
2.31.1
Re: [PATCH 1/4] vDPA: allow userspace to query features of a vDPA device
Quoted 10 lines · Zhu Lingshan
This commit adds a new vDPA netlink attribution
VDPA_ATTR_VDPA_DEV_SUPPORTED_FEATURES. Userspace can query features of vDPA devices through this new attr.This commit invokes
vdpa_config_ops.get_config()thanvdpa_get_config_unlocked()to read the device config spcae, so no raeces invdpa_set_features_unlocked()Signed-off-by Zhu Lingshan <[email protected]>
It's better to share the userspace code as well.
Quoted 10 lines
--- drivers/vdpa/vdpa.c | 19 ++++++++++++++----- include/uapi/linux/vdpa.h | 4 ++++ 2 files changed, 18 insertions(+), 5 deletions(-)drivers/vdpa/vdpa.c +0
-0
drivers/vdpa/vdpa.c static int vdpa_mgmtdev_fill(const struct vdpa_mgmt_dev *mdev, struct sk_buff *m · line 495
Quoted 5 lines
drivers/vdpa/vdpa.c +2
-0@@ -491,6 +491,8 @@ static int vdpa_mgmtdev_fill(const struct vdpa_mgmt_dev *mdev, struct sk_buff *m err = -EMSGSIZE ; goto msg_err; } + +/* report features of a vDPA management device through VDPA_ATTR_DEV_SUPPORTED_FEATURES */
The code explains itself, there's no need for the comment.
Quoted 46 lines
drivers/vdpa/vdpa.c +12
-5if (nla_put_u64_64bit (msg,VDPA_ATTR_DEV_SUPPORTED_FEATURES , mdev->supported_features,VDPA_ATTR_PAD )) { err = -EMSGSIZE ;@@ -815,10 +817,10 @@ static int vdpa_dev_net_mq_config_fill(struct vdpa_device *vdev,static int vdpa_dev_net_config_fill (struct vdpa_device *vdev,struct sk_buff *msg) {struct virtio_net_config config = {}; -u64 features; +u64 features_device, features_driver;u16 val_u16; -vdpa_get_config_unlocked (vdev,0 , &config,sizeof (config)); + vdev->config->get_config (vdev,0 , &config,sizeof (config));if (nla_put (msg,VDPA_ATTR_DEV_NET_CFG_MACADDR ,sizeof (config.mac), config.mac))@@ -832,12 +834,19 @@ static int vdpa_dev_net_config_fill(struct vdpa_device *vdev, struct sk_buff *msif (nla_put_u16 (msg,VDPA_ATTR_DEV_NET_CFG_MTU , val_u16))return -EMSGSIZE ; - features = vdev->config->get_driver_features (vdev); -if (nla_put_u64_64bit (msg,VDPA_ATTR_DEV_NEGOTIATED_FEATURES , features, + features_driver = vdev->config->get_driver_features (vdev); +if (nla_put_u64_64bit (msg,VDPA_ATTR_DEV_NEGOTIATED_FEATURES , features_driver, +VDPA_ATTR_PAD )) +return -EMSGSIZE ; + + features_device = vdev->config->get_device_features (vdev); + +/* report features of a vDPA device through VDPA_ATTR_VDPA_DEV_SUPPORTED_FEATURES */ +if (nla_put_u64_64bit (msg,VDPA_ATTR_VDPA_DEV_SUPPORTED_FEATURES , features_device,VDPA_ATTR_PAD ))return -EMSGSIZE ; -return vdpa_dev_net_mq_config_fill (vdev, msg, features, &config); +return vdpa_dev_net_mq_config_fill (vdev, msg, features_driver, &config); } static intinclude/uapi/linux/vdpa.h +0
-0@@ -46,12 +46,16 @@ enum vdpa_attr { VDPA_ATTR_DEV_NEGOTIATED_FEATURES, /* u64 */
include/uapi/linux/vdpa.h enum vdpa_attr { · line 57
Quoted 10 lines
include/uapi/linux/vdpa.h +3
-0VDPA_ATTR_DEV_MGMTDEV_MAX_VQS ,/* u32 */ +/* features of a vDPA management device */ VDPA_ATTR_DEV_SUPPORTED_FEATURES ,/* u64 */ VDPA_ATTR_DEV_QUEUE_INDEX ,/* u32 */ VDPA_ATTR_DEV_VENDOR_ATTR_NAME ,/* string */ VDPA_ATTR_DEV_VENDOR_ATTR_VALUE ,/* u64 */ +/* features of a vDPA device, e.g., /dev/vhost-vdpa0 */ + VDPA_ATTR_VDPA_DEV_SUPPORTED_FEATURES, /* u64 */
What's the difference between this and VDPA_ATTR_DEV_SUPPORTED_FEATURES?
Thanks
Quoted 7 lines
include/uapi/linux/vdpa.h +1
-1+/* new attributes must be added above here */ VDPA_ATTR_MAX, }; --2.31.1
Re: [PATCH 1/4] vDPA: allow userspace to query features of a vDPA device
Quoted 11 lines · Jason Wang
Quoted 9 lines · Zhu Lingshan
This commit adds a new vDPA netlink attribution
VDPA_ATTR_VDPA_DEV_SUPPORTED_FEATURES. Userspace can query features of vDPA devices through this new attr.This commit invokes
vdpa_config_ops.get_config()thanvdpa_get_config_unlocked()to read the device config spcae, so no raeces invdpa_set_features_unlocked()Signed-off-by Zhu Lingshan <[email protected]>It's better to share the userspace code as well.
OK, will share it in V2.
Quoted 6 lines
Quoted 6 lines
--- drivers/vdpa/vdpa.c | 19 ++++++++++++++----- include/uapi/linux/vdpa.h | 4 ++++ 2 files changed, 18 insertions(+), 5 deletions(-)
Quoted 11 lines
drivers/vdpa/vdpa.c static int vdpa_mgmtdev_fill(const struct vdpa_mgmt_dev *mdev, struct sk_buff *m · line 495
Quoted 10 lines
drivers/vdpa/vdpa.c +2
-0@@ -491,6 +491,8 @@ static int vdpa_mgmtdev_fill(const struct vdpa_mgmt_dev *mdev, struct sk_buff *m err = -EMSGSIZE ; goto msg_err; } + +/* report features of a vDPA management device through VDPA_ATTR_DEV_SUPPORTED_FEATURES */ The code explains itself, there's no need for the comment.
these comments are required in other discussions
Quoted 51 lines
Quoted 51 lines
drivers/vdpa/vdpa.c +12
-5if (nla_put_u64_64bit (msg,VDPA_ATTR_DEV_SUPPORTED_FEATURES , mdev->supported_features,VDPA_ATTR_PAD )) { err = -EMSGSIZE ;@@ -815,10 +817,10 @@ static int vdpa_dev_net_mq_config_fill(struct vdpa_device *vdev,static int vdpa_dev_net_config_fill (struct vdpa_device *vdev,struct sk_buff *msg) {struct virtio_net_config config = {}; -u64 features; +u64 features_device, features_driver;u16 val_u16; -vdpa_get_config_unlocked (vdev,0 , &config,sizeof (config)); + vdev->config->get_config (vdev,0 , &config,sizeof (config));if (nla_put (msg,VDPA_ATTR_DEV_NET_CFG_MACADDR ,sizeof (config.mac), config.mac))@@ -832,12 +834,19 @@ static int vdpa_dev_net_config_fill(struct vdpa_device *vdev, struct sk_buff *msif (nla_put_u16 (msg,VDPA_ATTR_DEV_NET_CFG_MTU , val_u16))return -EMSGSIZE ; - features = vdev->config->get_driver_features (vdev); -if (nla_put_u64_64bit (msg,VDPA_ATTR_DEV_NEGOTIATED_FEATURES , features, + features_driver = vdev->config->get_driver_features (vdev); +if (nla_put_u64_64bit (msg,VDPA_ATTR_DEV_NEGOTIATED_FEATURES , features_driver, +VDPA_ATTR_PAD )) +return -EMSGSIZE ; + + features_device = vdev->config->get_device_features (vdev); + +/* report features of a vDPA device through VDPA_ATTR_VDPA_DEV_SUPPORTED_FEATURES */ +if (nla_put_u64_64bit (msg,VDPA_ATTR_VDPA_DEV_SUPPORTED_FEATURES , features_device,VDPA_ATTR_PAD ))return -EMSGSIZE ; -return vdpa_dev_net_mq_config_fill (vdev, msg, features, &config); +return vdpa_dev_net_mq_config_fill (vdev, msg, features_driver, &config); } static intinclude/uapi/linux/vdpa.h +1
-0@@ -46,12 +46,16 @@ enum vdpa_attr {VDPA_ATTR_DEV_NEGOTIATED_FEATURES ,/* u64 */ VDPA_ATTR_DEV_MGMTDEV_MAX_VQS ,/* u32 */ +/* features of a vDPA management device */ VDPA_ATTR_DEV_SUPPORTED_FEATURES, /* u64 */
Quoted 7 lines
include/uapi/linux/vdpa.h enum vdpa_attr { · line 57
Quoted 6 lines
include/uapi/linux/vdpa.h +2
-0VDPA_ATTR_DEV_QUEUE_INDEX ,/* u32 */ VDPA_ATTR_DEV_VENDOR_ATTR_NAME ,/* string */ VDPA_ATTR_DEV_VENDOR_ATTR_VALUE ,/* u64 */ +/* features of a vDPA device, e.g., /dev/vhost-vdpa0 */ + VDPA_ATTR_VDPA_DEV_SUPPORTED_FEATURES, /* u64 */What's the difference between this and
VDPA_ATTR_DEV_SUPPORTED_FEATURES?
This is to report a vDPA device features, and VDPA_ATTR_DEV_SUPPORTED_FEATURES is used for reporting the management device features, we have a long discussion on this before.
Quoted 10 lines
Thanks
Quoted 7 lines
include/uapi/linux/vdpa.h +1
-1+/* new attributes must be added above here */ VDPA_ATTR_MAX, }; --2.31.1
Re: [PATCH 1/4] vDPA: allow userspace to query features of a vDPA device
Quoted 33 lines · Lingshan
Quoted 11 lines · Jason Wang
Quoted 9 lines · Zhu Lingshan
This commit adds a new vDPA netlink attribution
VDPA_ATTR_VDPA_DEV_SUPPORTED_FEATURES. Userspace can query features of vDPA devices through this new attr.This commit invokes
vdpa_config_ops.get_config()thanvdpa_get_config_unlocked()to read the device config spcae, so no raeces invdpa_set_features_unlocked()Signed-off-by Zhu Lingshan <[email protected]>It's better to share the userspace code as well.
OK, will share it in V2.
Quoted 6 lines
Quoted 6 lines
--- drivers/vdpa/vdpa.c | 19 ++++++++++++++----- include/uapi/linux/vdpa.h | 4 ++++ 2 files changed, 18 insertions(+), 5 deletions(-)Quoted 11 lines
drivers/vdpa/vdpa.c static int vdpa_mgmtdev_fill(const struct vdpa_mgmt_dev *mdev, struct sk_buff *m · line 495
Quoted 10 lines
drivers/vdpa/vdpa.c +2
-0@@ -491,6 +491,8 @@ static int vdpa_mgmtdev_fill(const struct vdpa_mgmt_dev *mdev, struct sk_buff *m err = -EMSGSIZE ; goto msg_err; } + +/* report features of a vDPA management device through VDPA_ATTR_DEV_SUPPORTED_FEATURES */ The code explains itself, there's no need for the comment.
Quoted 1 line
these comments are required in other discussions
I think it's more than sufficient to clarify the semantic where it is defined.
Quoted 55 lines
Quoted 55 lines
Quoted 55 lines
drivers/vdpa/vdpa.c +12
-5if (nla_put_u64_64bit (msg,VDPA_ATTR_DEV_SUPPORTED_FEATURES , mdev->supported_features,VDPA_ATTR_PAD )) { err = -EMSGSIZE ;@@ -815,10 +817,10 @@ static int vdpa_dev_net_mq_config_fill(struct vdpa_device *vdev,static int vdpa_dev_net_config_fill (struct vdpa_device *vdev,struct sk_buff *msg) {struct virtio_net_config config = {}; -u64 features; +u64 features_device, features_driver;u16 val_u16; -vdpa_get_config_unlocked (vdev,0 , &config,sizeof (config)); + vdev->config->get_config (vdev,0 , &config,sizeof (config));if (nla_put (msg,VDPA_ATTR_DEV_NET_CFG_MACADDR ,sizeof (config.mac), config.mac))@@ -832,12 +834,19 @@ static int vdpa_dev_net_config_fill(struct vdpa_device *vdev, struct sk_buff *msif (nla_put_u16 (msg,VDPA_ATTR_DEV_NET_CFG_MTU , val_u16))return -EMSGSIZE ; - features = vdev->config->get_driver_features (vdev); -if (nla_put_u64_64bit (msg,VDPA_ATTR_DEV_NEGOTIATED_FEATURES , features, + features_driver = vdev->config->get_driver_features (vdev); +if (nla_put_u64_64bit (msg,VDPA_ATTR_DEV_NEGOTIATED_FEATURES , features_driver, +VDPA_ATTR_PAD )) +return -EMSGSIZE ; + + features_device = vdev->config->get_device_features (vdev); + +/* report features of a vDPA device through VDPA_ATTR_VDPA_DEV_SUPPORTED_FEATURES */ +if (nla_put_u64_64bit (msg,VDPA_ATTR_VDPA_DEV_SUPPORTED_FEATURES , features_device,VDPA_ATTR_PAD ))return -EMSGSIZE ; -return vdpa_dev_net_mq_config_fill (vdev, msg, features, &config); +return vdpa_dev_net_mq_config_fill (vdev, msg, features_driver, &config); } static intinclude/uapi/linux/vdpa.h +1
-0@@ -46,12 +46,16 @@ enum vdpa_attr {VDPA_ATTR_DEV_NEGOTIATED_FEATURES ,/* u64 */ VDPA_ATTR_DEV_MGMTDEV_MAX_VQS ,/* u32 */ +/* features of a vDPA management device */ VDPA_ATTR_DEV_SUPPORTED_FEATURES ,/* u64 */ VDPA_ATTR_DEV_QUEUE_INDEX ,/* u32 */ VDPA_ATTR_DEV_VENDOR_ATTR_NAME ,/* string */ VDPA_ATTR_DEV_VENDOR_ATTR_VALUE, /* u64 */
Quoted 8 lines
Quoted 3 lines
include/uapi/linux/vdpa.h enum vdpa_attr { · line 57
Quoted 2 lines
include/uapi/linux/vdpa.h +2
-0+/* features of a vDPA device, e.g., /dev/vhost-vdpa0 */ + VDPA_ATTR_VDPA_DEV_SUPPORTED_FEATURES, /* u64 */What's the difference between this and
VDPA_ATTR_DEV_SUPPORTED_FEATURES?This is to report a vDPA device features, and
VDPA_ATTR_DEV_SUPPORTED_FEATURES
is used for reporting the management device features, we have a long discussion
on this before.
Yes, but the comment is not clear in many ways:
" features of a vDPA management device" sounds like features that is out of the scope of the virtio.
And
"/dev/vhost-vdpa0" is not a vDPA device but a vhost-vDPA device.
Thanks
Quoted 11 lines
Quoted 10 lines
Thanks
Quoted 7 lines
include/uapi/linux/vdpa.h +1
-1+/* new attributes must be added above here */ VDPA_ATTR_MAX, }; --2.31.1
_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
Re: [PATCH 1/4] vDPA: allow userspace to query features of a vDPA device
Quoted 32 lines · Jason Wang
Quoted 31 lines · Lingshan
Quoted 11 lines · Jason Wang
Quoted 9 lines · Zhu Lingshan
This commit adds a new vDPA netlink attribution
VDPA_ATTR_VDPA_DEV_SUPPORTED_FEATURES. Userspace can query features of vDPA devices through this new attr.This commit invokes
vdpa_config_ops.get_config()thanvdpa_get_config_unlocked()to read the device config spcae, so no raeces invdpa_set_features_unlocked()Signed-off-by Zhu Lingshan <[email protected]>It's better to share the userspace code as well.
OK, will share it in V2.
Quoted 16 lines
Quoted 10 lines
--- drivers/vdpa/vdpa.c | 19 ++++++++++++++----- include/uapi/linux/vdpa.h | 4 ++++ 2 files changed, 18 insertions(+), 5 deletions(-)drivers/vdpa/vdpa.c +0
-0drivers/vdpa/vdpa.c static int vdpa_mgmtdev_fill(const struct vdpa_mgmt_dev *mdev, struct sk_buff *m · line 495
Quoted 5 lines
drivers/vdpa/vdpa.c +2
-0@@ -491,6 +491,8 @@ static int vdpa_mgmtdev_fill(const struct vdpa_mgmt_dev *mdev, struct sk_buff *m err = -EMSGSIZE ; goto msg_err; } + +/* report features of a vDPA management device through VDPA_ATTR_DEV_SUPPORTED_FEATURES */ The code explains itself, there's no need for the comment.
Quoted 2 lines
Quoted 1 line
these comments are required in other discussions
I think it's more than sufficient to clarify the semantic where it is defined.
OK, then only comments in the header file
Quoted 63 lines
Quoted 55 lines
Quoted 55 lines
Quoted 55 lines
drivers/vdpa/vdpa.c +12
-5if (nla_put_u64_64bit (msg,VDPA_ATTR_DEV_SUPPORTED_FEATURES , mdev->supported_features,VDPA_ATTR_PAD )) { err = -EMSGSIZE ;@@ -815,10 +817,10 @@ static int vdpa_dev_net_mq_config_fill(struct vdpa_device *vdev,static int vdpa_dev_net_config_fill (struct vdpa_device *vdev,struct sk_buff *msg) {struct virtio_net_config config = {}; -u64 features; +u64 features_device, features_driver;u16 val_u16; -vdpa_get_config_unlocked (vdev,0 , &config,sizeof (config)); + vdev->config->get_config (vdev,0 , &config,sizeof (config));if (nla_put (msg,VDPA_ATTR_DEV_NET_CFG_MACADDR ,sizeof (config.mac), config.mac))@@ -832,12 +834,19 @@ static int vdpa_dev_net_config_fill(struct vdpa_device *vdev, struct sk_buff *msif (nla_put_u16 (msg,VDPA_ATTR_DEV_NET_CFG_MTU , val_u16))return -EMSGSIZE ; - features = vdev->config->get_driver_features (vdev); -if (nla_put_u64_64bit (msg,VDPA_ATTR_DEV_NEGOTIATED_FEATURES , features, + features_driver = vdev->config->get_driver_features (vdev); +if (nla_put_u64_64bit (msg,VDPA_ATTR_DEV_NEGOTIATED_FEATURES , features_driver, +VDPA_ATTR_PAD )) +return -EMSGSIZE ; + + features_device = vdev->config->get_device_features (vdev); + +/* report features of a vDPA device through VDPA_ATTR_VDPA_DEV_SUPPORTED_FEATURES */ +if (nla_put_u64_64bit (msg,VDPA_ATTR_VDPA_DEV_SUPPORTED_FEATURES , features_device,VDPA_ATTR_PAD ))return -EMSGSIZE ; -return vdpa_dev_net_mq_config_fill (vdev, msg, features, &config); +return vdpa_dev_net_mq_config_fill (vdev, msg, features_driver, &config); } static intinclude/uapi/linux/vdpa.h +1
-0@@ -46,12 +46,16 @@ enum vdpa_attr {VDPA_ATTR_DEV_NEGOTIATED_FEATURES ,/* u64 */ VDPA_ATTR_DEV_MGMTDEV_MAX_VQS ,/* u32 */ +/* features of a vDPA management device */ VDPA_ATTR_DEV_SUPPORTED_FEATURES ,/* u64 */ VDPA_ATTR_DEV_QUEUE_INDEX ,/* u32 */ VDPA_ATTR_DEV_VENDOR_ATTR_NAME ,/* string */ VDPA_ATTR_DEV_VENDOR_ATTR_VALUE, /* u64 */Quoted 8 lines
Quoted 3 lines
include/uapi/linux/vdpa.h enum vdpa_attr { · line 57
Quoted 2 lines
include/uapi/linux/vdpa.h +2
-0+/* features of a vDPA device, e.g., /dev/vhost-vdpa0 */ + VDPA_ATTR_VDPA_DEV_SUPPORTED_FEATURES, /* u64 */What's the difference between this and
VDPA_ATTR_DEV_SUPPORTED_FEATURES?This is to report a vDPA device features, and
VDPA_ATTR_DEV_SUPPORTED_FEATURES
is used for reporting the management device features, we have a long discussion
on this before.
Quoted 4 lines
Yes, but the comment is not clear in many ways:
" features of a vDPA management device" sounds like features that is out of the scope of the virtio.
I think the term "vDPA device" implies that it is a virtio device. So how about: "virtio features of a vDPA management device"
Quoted 4 lines
And
"
/dev/vhost-vdpa0" is not a vDPA device but a vhost-vDPA device.
will remove this example here.
Thanks
Quoted 12 lines
Thanks
Quoted 9 lines
Quoted 9 lines
Thanks
Quoted 7 lines
include/uapi/linux/vdpa.h +1
-1+/* new attributes must be added above here */ VDPA_ATTR_MAX, }; --2.31.1
Re: [PATCH 1/4] vDPA: allow userspace to query features of a vDPA device
Quoted 102 lines · Lingshan
Quoted 32 lines · Jason Wang
Quoted 31 lines · Lingshan
Quoted 11 lines · Jason Wang
Quoted 9 lines · Zhu Lingshan
This commit adds a new vDPA netlink attribution
VDPA_ATTR_VDPA_DEV_SUPPORTED_FEATURES. Userspace can query features of vDPA devices through this new attr.This commit invokes
vdpa_config_ops.get_config()thanvdpa_get_config_unlocked()to read the device config spcae, so no raeces invdpa_set_features_unlocked()Signed-off-by Zhu Lingshan <[email protected]>It's better to share the userspace code as well.
OK, will share it in V2.
Quoted 16 lines
Quoted 10 lines
--- drivers/vdpa/vdpa.c | 19 ++++++++++++++----- include/uapi/linux/vdpa.h | 4 ++++ 2 files changed, 18 insertions(+), 5 deletions(-)drivers/vdpa/vdpa.c +0
-0drivers/vdpa/vdpa.c static int vdpa_mgmtdev_fill(const struct vdpa_mgmt_dev *mdev, struct sk_buff *m · line 495
Quoted 5 lines
drivers/vdpa/vdpa.c +2
-0@@ -491,6 +491,8 @@ static int vdpa_mgmtdev_fill(const struct vdpa_mgmt_dev *mdev, struct sk_buff *m err = -EMSGSIZE ; goto msg_err; } + +/* report features of a vDPA management device through VDPA_ATTR_DEV_SUPPORTED_FEATURES */ The code explains itself, there's no need for the comment.
Quoted 2 lines
Quoted 1 line
these comments are required in other discussions
I think it's more than sufficient to clarify the semantic where it is defined.
OK, then only comments in the header file
Quoted 63 lines
Quoted 63 lines
Quoted 51 lines
Quoted 51 lines
drivers/vdpa/vdpa.c +12
-5if (nla_put_u64_64bit (msg,VDPA_ATTR_DEV_SUPPORTED_FEATURES , mdev->supported_features,VDPA_ATTR_PAD )) { err = -EMSGSIZE ;@@ -815,10 +817,10 @@ static int vdpa_dev_net_mq_config_fill(struct vdpa_device *vdev,static int vdpa_dev_net_config_fill (struct vdpa_device *vdev,struct sk_buff *msg) {struct virtio_net_config config = {}; -u64 features; +u64 features_device, features_driver;u16 val_u16; -vdpa_get_config_unlocked (vdev,0 , &config,sizeof (config)); + vdev->config->get_config (vdev,0 , &config,sizeof (config));if (nla_put (msg,VDPA_ATTR_DEV_NET_CFG_MACADDR ,sizeof (config.mac), config.mac))@@ -832,12 +834,19 @@ static int vdpa_dev_net_config_fill(struct vdpa_device *vdev, struct sk_buff *msif (nla_put_u16 (msg,VDPA_ATTR_DEV_NET_CFG_MTU , val_u16))return -EMSGSIZE ; - features = vdev->config->get_driver_features (vdev); -if (nla_put_u64_64bit (msg,VDPA_ATTR_DEV_NEGOTIATED_FEATURES , features, + features_driver = vdev->config->get_driver_features (vdev); +if (nla_put_u64_64bit (msg,VDPA_ATTR_DEV_NEGOTIATED_FEATURES , features_driver, +VDPA_ATTR_PAD )) +return -EMSGSIZE ; + + features_device = vdev->config->get_device_features (vdev); + +/* report features of a vDPA device through VDPA_ATTR_VDPA_DEV_SUPPORTED_FEATURES */ +if (nla_put_u64_64bit (msg,VDPA_ATTR_VDPA_DEV_SUPPORTED_FEATURES , features_device,VDPA_ATTR_PAD ))return -EMSGSIZE ; -return vdpa_dev_net_mq_config_fill (vdev, msg, features, &config); +return vdpa_dev_net_mq_config_fill (vdev, msg, features_driver, &config); } static intinclude/uapi/linux/vdpa.h +1
-0@@ -46,12 +46,16 @@ enum vdpa_attr {VDPA_ATTR_DEV_NEGOTIATED_FEATURES ,/* u64 */ VDPA_ATTR_DEV_MGMTDEV_MAX_VQS ,/* u32 */ +/* features of a vDPA management device */ VDPA_ATTR_DEV_SUPPORTED_FEATURES, /* u64 */Quoted 7 lines
include/uapi/linux/vdpa.h enum vdpa_attr { · line 57
Quoted 6 lines
include/uapi/linux/vdpa.h +2
-0VDPA_ATTR_DEV_QUEUE_INDEX ,/* u32 */ VDPA_ATTR_DEV_VENDOR_ATTR_NAME ,/* string */ VDPA_ATTR_DEV_VENDOR_ATTR_VALUE ,/* u64 */ +/* features of a vDPA device, e.g., /dev/vhost-vdpa0 */ + VDPA_ATTR_VDPA_DEV_SUPPORTED_FEATURES, /* u64 */What's the difference between this and
VDPA_ATTR_DEV_SUPPORTED_FEATURES?This is to report a vDPA device features, and
VDPA_ATTR_DEV_SUPPORTED_FEATURES
is used for reporting the management device features, we have a long discussion
on this before.
Quoted 6 lines
Quoted 4 lines
Yes, but the comment is not clear in many ways:
" features of a vDPA management device" sounds like features that is out of the scope of the virtio.
I think the term "vDPA device" implies that it is a virtio device. So how about: "virtio features of a vDPA management device"
Not a native speaker, but how about "virtio features that are supported by the vDPA management device?"
Thanks
Quoted 20 lines
Quoted 4 lines
And
"
/dev/vhost-vdpa0" is not a vDPA device but a vhost-vDPA device.will remove this example here.
Thanks
Quoted 12 lines
Thanks
Quoted 9 lines
Quoted 9 lines
Thanks
Quoted 7 lines
include/uapi/linux/vdpa.h +1
-1+/* new attributes must be added above here */ VDPA_ATTR_MAX, }; --2.31.1
_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
Re: [PATCH 1/4] vDPA: allow userspace to query features of a vDPA device
Quoted 100 lines · Jason Wang
Quoted 99 lines · Lingshan
Quoted 31 lines · Jason Wang
Quoted 30 lines · Lingshan
Quoted 11 lines · Jason Wang
Quoted 9 lines · Zhu Lingshan
This commit adds a new vDPA netlink attribution
VDPA_ATTR_VDPA_DEV_SUPPORTED_FEATURES. Userspace can query features of vDPA devices through this new attr.This commit invokes
vdpa_config_ops.get_config()thanvdpa_get_config_unlocked()to read the device config spcae, so no raeces invdpa_set_features_unlocked()Signed-off-by Zhu Lingshan <[email protected]>It's better to share the userspace code as well.
OK, will share it in V2.
Quoted 16 lines
Quoted 10 lines
--- drivers/vdpa/vdpa.c | 19 ++++++++++++++----- include/uapi/linux/vdpa.h | 4 ++++ 2 files changed, 18 insertions(+), 5 deletions(-)drivers/vdpa/vdpa.c +0
-0drivers/vdpa/vdpa.c static int vdpa_mgmtdev_fill(const struct vdpa_mgmt_dev *mdev, struct sk_buff *m · line 495
Quoted 5 lines
drivers/vdpa/vdpa.c +2
-0@@ -491,6 +491,8 @@ static int vdpa_mgmtdev_fill(const struct vdpa_mgmt_dev *mdev, struct sk_buff *m err = -EMSGSIZE ; goto msg_err; } + +/* report features of a vDPA management device through VDPA_ATTR_DEV_SUPPORTED_FEATURES */ The code explains itself, there's no need for the comment.
Quoted 2 lines
Quoted 1 line
these comments are required in other discussions
I think it's more than sufficient to clarify the semantic where it is defined.
OK, then only comments in the header file
Quoted 62 lines
Quoted 62 lines
Quoted 50 lines
Quoted 50 lines
drivers/vdpa/vdpa.c +12
-5if (nla_put_u64_64bit (msg,VDPA_ATTR_DEV_SUPPORTED_FEATURES , mdev->supported_features,VDPA_ATTR_PAD )) { err = -EMSGSIZE ;@@ -815,10 +817,10 @@ static int vdpa_dev_net_mq_config_fill(struct vdpa_device *vdev,static int vdpa_dev_net_config_fill (struct vdpa_device *vdev,struct sk_buff *msg) {struct virtio_net_config config = {}; -u64 features; +u64 features_device, features_driver;u16 val_u16; -vdpa_get_config_unlocked (vdev,0 , &config,sizeof (config)); + vdev->config->get_config (vdev,0 , &config,sizeof (config));if (nla_put (msg,VDPA_ATTR_DEV_NET_CFG_MACADDR ,sizeof (config.mac), config.mac))@@ -832,12 +834,19 @@ static int vdpa_dev_net_config_fill(struct vdpa_device *vdev, struct sk_buff *msif (nla_put_u16 (msg,VDPA_ATTR_DEV_NET_CFG_MTU , val_u16))return -EMSGSIZE ; - features = vdev->config->get_driver_features (vdev); -if (nla_put_u64_64bit (msg,VDPA_ATTR_DEV_NEGOTIATED_FEATURES , features, + features_driver = vdev->config->get_driver_features (vdev); +if (nla_put_u64_64bit (msg,VDPA_ATTR_DEV_NEGOTIATED_FEATURES , features_driver, +VDPA_ATTR_PAD )) +return -EMSGSIZE ; + + features_device = vdev->config->get_device_features (vdev); + +/* report features of a vDPA device through VDPA_ATTR_VDPA_DEV_SUPPORTED_FEATURES */ +if (nla_put_u64_64bit (msg,VDPA_ATTR_VDPA_DEV_SUPPORTED_FEATURES , features_device,VDPA_ATTR_PAD ))return -EMSGSIZE ; -return vdpa_dev_net_mq_config_fill (vdev, msg, features, &config); +return vdpa_dev_net_mq_config_fill (vdev, msg, features_driver, &config); } static intinclude/uapi/linux/vdpa.h +1
-0@@ -46,12 +46,16 @@ enum vdpa_attr {VDPA_ATTR_DEV_NEGOTIATED_FEATURES ,/* u64 */ VDPA_ATTR_DEV_MGMTDEV_MAX_VQS ,/* u32 */ +/* features of a vDPA management device */ VDPA_ATTR_DEV_SUPPORTED_FEATURES, /* u64 */Quoted 7 lines
include/uapi/linux/vdpa.h enum vdpa_attr { · line 57
Quoted 6 lines
include/uapi/linux/vdpa.h +2
-0VDPA_ATTR_DEV_QUEUE_INDEX ,/* u32 */ VDPA_ATTR_DEV_VENDOR_ATTR_NAME ,/* string */ VDPA_ATTR_DEV_VENDOR_ATTR_VALUE ,/* u64 */ +/* features of a vDPA device, e.g., /dev/vhost-vdpa0 */ + VDPA_ATTR_VDPA_DEV_SUPPORTED_FEATURES, /* u64 */What's the difference between this and
VDPA_ATTR_DEV_SUPPORTED_FEATURES?This is to report a vDPA device features, and
VDPA_ATTR_DEV_SUPPORTED_FEATURES
is used for reporting the management device features, we have a long discussion
on this before.
Quoted 8 lines
Quoted 6 lines
Quoted 4 lines
Yes, but the comment is not clear in many ways:
" features of a vDPA management device" sounds like features that is out of the scope of the virtio.
I think the term "vDPA device" implies that it is a virtio device. So how about: "virtio features of a vDPA management device"
Not a native speaker, but how about "virtio features that are supported by the vDPA management device?"
OK
Quoted 20 lines
Thanks
Quoted 17 lines
Quoted 3 lines
And
"
/dev/vhost-vdpa0" is not a vDPA device but a vhost-vDPA device.will remove this example here.
Thanks
Quoted 11 lines
Thanks
Quoted 9 lines
Quoted 9 lines
Thanks
Quoted 7 lines
include/uapi/linux/vdpa.h +1
-1+/* new attributes must be added above here */ VDPA_ATTR_MAX, }; --2.31.1
PATCH 2/4 vDPA: only report driver features if FEATURES_OK is set
In reply to Zhu Lingshanvdpa_dev_net_config_fill() should only report driver features to userspace after features negotiation is done.
--- drivers/vdpa/vdpa.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-)
drivers/vdpa/vdpa.c +9 -4
@@ -819,6 +819,7 @@ static int vdpa_dev_net_config_fill(struct vdpa_device *vdev, struct sk_buff *msstruct virtio_net_config config = {};u64 features_device, features_driver;u16 val_u16; +u8 status; vdev->config->get_config (vdev,0 , &config,sizeof (config));
@@ -834,10 +835,14 @@ static int vdpa_dev_net_config_fill(struct vdpa_device *vdev, struct sk_buff *msif (nla_put_u16 (msg,VDPA_ATTR_DEV_NET_CFG_MTU , val_u16))return -EMSGSIZE ; - features_driver = vdev->config->get_driver_features (vdev); -if (nla_put_u64_64bit (msg,VDPA_ATTR_DEV_NEGOTIATED_FEATURES , features_driver, -VDPA_ATTR_PAD )) -return -EMSGSIZE ; +/* only read driver features after the feature negotiation is done */ + status = vdev->config->get_status (vdev); +if (status &VIRTIO_CONFIG_S_FEATURES_OK ) { + features_driver = vdev->config->get_driver_features (vdev); +if (nla_put_u64_64bit (msg,VDPA_ATTR_DEV_NEGOTIATED_FEATURES , features_driver, +VDPA_ATTR_PAD )) +return -EMSGSIZE ; + } features_device = vdev->config->get_device_features (vdev);
Signature · 1 line
2.31.1
Re: [PATCH 2/4] vDPA: only report driver features if FEATURES_OK is set
Quoted 22 lines · Zhu Lingshan
vdpa_dev_net_config_fill()should only report driver features to userspace after features negotiation is done.Signed-off-by Zhu Lingshan <[email protected]>--- drivers/vdpa/vdpa.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-)drivers/vdpa/vdpa.c +1
-0@@ -819,6 +819,7 @@ static int vdpa_dev_net_config_fill(struct vdpa_device *vdev, struct sk_buff *msstruct virtio_net_config config = {};u64 features_device, features_driver;u16 val_u16; +u8 status; vdev->config->get_config (vdev,0 , &config,sizeof (config));
drivers/vdpa/vdpa.c static int vdpa_dev_net_config_fill(struct vdpa_device *vdev, struct sk_buff *ms · line 840
Quoted 10 lines
drivers/vdpa/vdpa.c +3
-4@@ -834,10 +835,14 @@ static int vdpa_dev_net_config_fill(struct vdpa_device *vdev, struct sk_buff *msif (nla_put_u16 (msg,VDPA_ATTR_DEV_NET_CFG_MTU , val_u16))return -EMSGSIZE ; - features_driver = vdev->config->get_driver_features (vdev); -if (nla_put_u64_64bit (msg,VDPA_ATTR_DEV_NEGOTIATED_FEATURES , features_driver, -VDPA_ATTR_PAD )) -return -EMSGSIZE ; +/* only read driver features after the feature negotiation is done */ + status = vdev->config->get_status (vdev); +if (status &VIRTIO_CONFIG_S_FEATURES_OK ) {
Any reason this is not checked in its caller as what it used to do before?
Thanks
Quoted 11 lines
drivers/vdpa/vdpa.c +5
-1+ features_driver = vdev->config->get_driver_features (vdev); +if (nla_put_u64_64bit (msg,VDPA_ATTR_DEV_NEGOTIATED_FEATURES , features_driver, +VDPA_ATTR_PAD )) +return -EMSGSIZE ; + } features_device = vdev->config->get_device_features (vdev); --2.31.1
Re: [PATCH 2/4] vDPA: only report driver features if FEATURES_OK is set
Quoted 25 lines · Jason Wang
Quoted 24 lines · Zhu Lingshan
vdpa_dev_net_config_fill()should only report driver features to userspace after features negotiation is done.Signed-off-by Zhu Lingshan <[email protected]>--- drivers/vdpa/vdpa.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-)drivers/vdpa/vdpa.c +1
-0@@ -819,6 +819,7 @@ static int vdpa_dev_net_config_fill(struct vdpa_device *vdev, struct sk_buff *msstruct virtio_net_config config = {};u64 features_device, features_driver;u16 val_u16; +u8 status; vdev->config->get_config (vdev,0 , &config,sizeof (config));@@ -834,10 +835,14 @@ static int vdpa_dev_net_config_fill(struct vdpa_device *vdev, struct sk_buff *msif (nla_put_u16 (msg,VDPA_ATTR_DEV_NET_CFG_MTU , val_u16))return -EMSGSIZE ;
Quoted 8 lines
drivers/vdpa/vdpa.c static int vdpa_dev_net_config_fill(struct vdpa_device *vdev, struct sk_buff *ms · line 840
Quoted 7 lines
drivers/vdpa/vdpa.c +3
-4- features_driver = vdev->config->get_driver_features (vdev); -if (nla_put_u64_64bit (msg,VDPA_ATTR_DEV_NEGOTIATED_FEATURES , features_driver, -VDPA_ATTR_PAD )) -return -EMSGSIZE ; +/* only read driver features after the feature negotiation is done */ + status = vdev->config->get_status (vdev); +if (status &VIRTIO_CONFIG_S_FEATURES_OK ) {Any reason this is not checked in its caller as what it used to do before?
will check the existence of vdev->config->get_status before calling it in V2
Thanks,
Zhu Lingshan
Quoted 14 lines
Thanks
Quoted 11 lines
drivers/vdpa/vdpa.c +5
-1+ features_driver = vdev->config->get_driver_features (vdev); +if (nla_put_u64_64bit (msg,VDPA_ATTR_DEV_NEGOTIATED_FEATURES , features_driver, +VDPA_ATTR_PAD )) +return -EMSGSIZE ; + } features_device = vdev->config->get_device_features (vdev); --2.31.1
Re: [PATCH 2/4] vDPA: only report driver features if FEATURES_OK is set
Quoted 37 lines · Lingshan
Quoted 25 lines · Jason Wang
Quoted 24 lines · Zhu Lingshan
vdpa_dev_net_config_fill()should only report driver features to userspace after features negotiation is done.Signed-off-by Zhu Lingshan <[email protected]>--- drivers/vdpa/vdpa.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-)drivers/vdpa/vdpa.c +1
-0@@ -819,6 +819,7 @@ static int vdpa_dev_net_config_fill(struct vdpa_device *vdev, struct sk_buff *msstruct virtio_net_config config = {};u64 features_device, features_driver;u16 val_u16; +u8 status; vdev->config->get_config (vdev,0 , &config,sizeof (config));@@ -834,10 +835,14 @@ static int vdpa_dev_net_config_fill(struct vdpa_device *vdev, struct sk_buff *msif (nla_put_u16 (msg,VDPA_ATTR_DEV_NET_CFG_MTU , val_u16))return -EMSGSIZE ;Quoted 8 lines
drivers/vdpa/vdpa.c static int vdpa_dev_net_config_fill(struct vdpa_device *vdev, struct sk_buff *ms · line 840
Quoted 7 lines
drivers/vdpa/vdpa.c +3
-4- features_driver = vdev->config->get_driver_features (vdev); -if (nla_put_u64_64bit (msg,VDPA_ATTR_DEV_NEGOTIATED_FEATURES , features_driver, -VDPA_ATTR_PAD )) -return -EMSGSIZE ; +/* only read driver features after the feature negotiation is done */ + status = vdev->config->get_status (vdev); +if (status &VIRTIO_CONFIG_S_FEATURES_OK ) {Any reason this is not checked in its caller as what it used to do before?
Quoted 1 line
will check the existence of
vdev->config->get_statusbefore calling it in V2
Just to clarify, I meant to check FEAUTRES_OK in the caller - vdpa_dev_config_fill() otherwise each type needs to repeat this in their specific codes.
Thanks
Quoted 18 lines
Thanks,
Zhu LingshanQuoted 14 lines
Thanks
Quoted 11 lines
drivers/vdpa/vdpa.c +5
-1+ features_driver = vdev->config->get_driver_features (vdev); +if (nla_put_u64_64bit (msg,VDPA_ATTR_DEV_NEGOTIATED_FEATURES , features_driver, +VDPA_ATTR_PAD )) +return -EMSGSIZE ; + } features_device = vdev->config->get_device_features (vdev); --2.31.1
_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
Re: [PATCH 2/4] vDPA: only report driver features if FEATURES_OK is set
Quoted 37 lines · Jason Wang
Quoted 36 lines · Lingshan
Quoted 33 lines · Jason Wang
Quoted 21 lines · Zhu Lingshan
vdpa_dev_net_config_fill()should only report driver features to userspace after features negotiation is done.Signed-off-by Zhu Lingshan <[email protected]>--- drivers/vdpa/vdpa.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-)drivers/vdpa/vdpa.c +1
-0@@ -819,6 +819,7 @@ static int vdpa_dev_net_config_fill(struct vdpa_device *vdev, struct sk_buff *msstruct virtio_net_config config = {};u64 features_device, features_driver;u16 val_u16; +u8 status; vdev->config->get_config (vdev,0 , &config,sizeof (config));drivers/vdpa/vdpa.c static int vdpa_dev_net_config_fill(struct vdpa_device *vdev, struct sk_buff *ms · line 840
Quoted 10 lines
drivers/vdpa/vdpa.c +3
-4@@ -834,10 +835,14 @@ static int vdpa_dev_net_config_fill(struct vdpa_device *vdev, struct sk_buff *msif (nla_put_u16 (msg,VDPA_ATTR_DEV_NET_CFG_MTU , val_u16))return -EMSGSIZE ; - features_driver = vdev->config->get_driver_features (vdev); -if (nla_put_u64_64bit (msg,VDPA_ATTR_DEV_NEGOTIATED_FEATURES , features_driver, -VDPA_ATTR_PAD )) -return -EMSGSIZE ; +/* only read driver features after the feature negotiation is done */ + status = vdev->config->get_status (vdev); +if (status &VIRTIO_CONFIG_S_FEATURES_OK ) {Any reason this is not checked in its caller as what it used to do before?
Quoted 4 lines
Quoted 1 line
will check the existence of
vdev->config->get_statusbefore calling it in V2Just to clarify, I meant to check
FEAUTRES_OKin the caller -vdpa_dev_config_fill()otherwise each type needs to repeat this in their specific codes.
if we check FEATURES_OK in the caller vdpa_dev_config_fill(), then !FEATURES_OK will block reporting all attributions, for example
the device features and virtio device config space fields in this series and device status. Currently only driver features needs to check FEATURES_OK.
Or did I missed anything?
Thanks
Quoted 18 lines
Thanks
Quoted 15 lines
Thanks,
Zhu LingshanQuoted 13 lines
Thanks
Quoted 11 lines
drivers/vdpa/vdpa.c +5
-1+ features_driver = vdev->config->get_driver_features (vdev); +if (nla_put_u64_64bit (msg,VDPA_ATTR_DEV_NEGOTIATED_FEATURES , features_driver, +VDPA_ATTR_PAD )) +return -EMSGSIZE ; + } features_device = vdev->config->get_device_features (vdev); --2.31.1
Re: [PATCH 2/4] vDPA: only report driver features if FEATURES_OK is set
Quoted 45 lines · Lingshan
Quoted 37 lines · Jason Wang
Quoted 36 lines · Lingshan
Quoted 33 lines · Jason Wang
Quoted 21 lines · Zhu Lingshan
vdpa_dev_net_config_fill()should only report driver features to userspace after features negotiation is done.Signed-off-by Zhu Lingshan <[email protected]>--- drivers/vdpa/vdpa.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-)drivers/vdpa/vdpa.c +1
-0@@ -819,6 +819,7 @@ static int vdpa_dev_net_config_fill(struct vdpa_device *vdev, struct sk_buff *msstruct virtio_net_config config = {};u64 features_device, features_driver;u16 val_u16; +u8 status; vdev->config->get_config (vdev,0 , &config,sizeof (config));drivers/vdpa/vdpa.c static int vdpa_dev_net_config_fill(struct vdpa_device *vdev, struct sk_buff *ms · line 840
Quoted 10 lines
drivers/vdpa/vdpa.c +3
-4@@ -834,10 +835,14 @@ static int vdpa_dev_net_config_fill(struct vdpa_device *vdev, struct sk_buff *msif (nla_put_u16 (msg,VDPA_ATTR_DEV_NET_CFG_MTU , val_u16))return -EMSGSIZE ; - features_driver = vdev->config->get_driver_features (vdev); -if (nla_put_u64_64bit (msg,VDPA_ATTR_DEV_NEGOTIATED_FEATURES , features_driver, -VDPA_ATTR_PAD )) -return -EMSGSIZE ; +/* only read driver features after the feature negotiation is done */ + status = vdev->config->get_status (vdev); +if (status &VIRTIO_CONFIG_S_FEATURES_OK ) {Any reason this is not checked in its caller as what it used to do before?
Quoted 4 lines
Quoted 1 line
will check the existence of
vdev->config->get_statusbefore calling it in V2Just to clarify, I meant to check
FEAUTRES_OKin the caller -vdpa_dev_config_fill()otherwise each type needs to repeat this in their specific codes.
Quoted 6 lines
if we check
FEATURES_OKin the callervdpa_dev_config_fill(), then !FEATURES_OK will block reporting all attributions, for example the device features and virtio device config space fields in this series and device status.
Currently only driver features needs to checkFEATURES_OK. Or did I missed anything?
I don't see much difference, we just move the following part to the caller, it is not the config but the VDPA_ATTR_DEV_NEGOTIATED_FEATURES is blocked.
Thanks
Quoted 21 lines
Thanks
Quoted 18 lines
Thanks
Quoted 15 lines
Thanks,
Zhu LingshanQuoted 13 lines
Thanks
Quoted 11 lines
drivers/vdpa/vdpa.c +5
-1+ features_driver = vdev->config->get_driver_features (vdev); +if (nla_put_u64_64bit (msg,VDPA_ATTR_DEV_NEGOTIATED_FEATURES , features_driver, +VDPA_ATTR_PAD )) +return -EMSGSIZE ; + } features_device = vdev->config->get_device_features (vdev); --2.31.1
_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
Re: [PATCH 2/4] vDPA: only report driver features if FEATURES_OK is set
Quoted 50 lines · Jason Wang
Quoted 43 lines · Lingshan
Quoted 36 lines · Jason Wang
Quoted 35 lines · Lingshan
Quoted 33 lines · Jason Wang
Quoted 21 lines · Zhu Lingshan
vdpa_dev_net_config_fill()should only report driver features to userspace after features negotiation is done.Signed-off-by Zhu Lingshan <[email protected]>--- drivers/vdpa/vdpa.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-)drivers/vdpa/vdpa.c +1
-0@@ -819,6 +819,7 @@ static int vdpa_dev_net_config_fill(struct vdpa_device *vdev, struct sk_buff *msstruct virtio_net_config config = {};u64 features_device, features_driver;u16 val_u16; +u8 status; vdev->config->get_config (vdev,0 , &config,sizeof (config));drivers/vdpa/vdpa.c static int vdpa_dev_net_config_fill(struct vdpa_device *vdev, struct sk_buff *ms · line 840
Quoted 10 lines
drivers/vdpa/vdpa.c +3
-4@@ -834,10 +835,14 @@ static int vdpa_dev_net_config_fill(struct vdpa_device *vdev, struct sk_buff *msif (nla_put_u16 (msg,VDPA_ATTR_DEV_NET_CFG_MTU , val_u16))return -EMSGSIZE ; - features_driver = vdev->config->get_driver_features (vdev); -if (nla_put_u64_64bit (msg,VDPA_ATTR_DEV_NEGOTIATED_FEATURES , features_driver, -VDPA_ATTR_PAD )) -return -EMSGSIZE ; +/* only read driver features after the feature negotiation is done */ + status = vdev->config->get_status (vdev); +if (status &VIRTIO_CONFIG_S_FEATURES_OK ) {Any reason this is not checked in its caller as what it used to do before?
Quoted 4 lines
Quoted 1 line
will check the existence of
vdev->config->get_statusbefore calling it in V2Just to clarify, I meant to check
FEAUTRES_OKin the caller -vdpa_dev_config_fill()otherwise each type needs to repeat this in their specific codes.Quoted 6 lines
if we check
FEATURES_OKin the callervdpa_dev_config_fill(), then !FEATURES_OK will block reporting all attributions, for example the device features and virtio device config space fields in this series and device status.
Currently only driver features needs to checkFEATURES_OK. Or did I missed anything?
Quoted 3 lines
I don't see much difference, we just move the following part to the caller, it is not the config but the
VDPA_ATTR_DEV_NEGOTIATED_FEATURESis blocked.
OK, I get you. V2 will check FEATURES_OK and report driver features in vdpa_dev_config_fill()
Thanks
Zhu Lingshan
Quoted 21 lines
Thanks
Quoted 18 lines
Thanks
Quoted 17 lines
Thanks
Quoted 15 lines
Thanks,
Zhu LingshanQuoted 13 lines
Thanks
Quoted 11 lines
drivers/vdpa/vdpa.c +5
-1+ features_driver = vdev->config->get_driver_features (vdev); +if (nla_put_u64_64bit (msg,VDPA_ATTR_DEV_NEGOTIATED_FEATURES , features_driver, +VDPA_ATTR_PAD )) +return -EMSGSIZE ; + } features_device = vdev->config->get_device_features (vdev); --2.31.1
PATCH 3/4 vDPA: check VIRTIO_NET_F_RSS for max_virtqueue_paris's presence
In reply to Zhu Lingshanvirtio 1.2 spec says:max_virtqueue_pairs only exists if VIRTIO_NET_F_MQ or VIRTIO_NET_F_RSS is set.
So when reporint MQ to userspace, it should check both VIRTIO_NET_F_MQ and VIRTIO_NET_F_RSS.
This commit also fixes:
1) a spase warning by replacing le16_to_cpu with __virtio16_to_cpu.
2) vdpa_dev_net_mq_config_fill() should checks device features for MQ than driver features.
3) struct vdpa_device *vdev is not needed for vdpa_dev_net_mq_config_fill(), unused.
--- drivers/vdpa/vdpa.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)
drivers/vdpa/vdpa.c +6 -5
@@ -801,16 +801,17 @@ static int vdpa_nl_cmd_dev_get_dumpit(struct sk_buff *msg, struct netlink_callbareturn msg->len; } -static int vdpa_dev_net_mq_config_fill (struct vdpa_device *vdev, -struct sk_buff *msg,u64 features, +static int vdpa_dev_net_mq_config_fill (struct sk_buff *msg,u64 features,const struct virtio_net_config *config) {u16 val_u16; -if ((features &BIT_ULL (VIRTIO_NET_F_MQ )) ==0 ) +if ((features &BIT_ULL (VIRTIO_NET_F_MQ )) ==0 && + (features &BIT_ULL (VIRTIO_NET_F_RSS )) ==0 )return 0 ; - val_u16 =le16_to_cpu (config->max_virtqueue_pairs); + val_u16 =__virtio16_to_cpu (true, config->max_virtqueue_pairs); +return nla_put_u16 (msg,VDPA_ATTR_DEV_NET_CFG_MAX_VQP , val_u16); }
@@ -851,7 +852,7 @@ static int vdpa_dev_net_config_fill(struct vdpa_device *vdev, struct sk_buff *ms VDPA_ATTR_PAD))return -EMSGSIZE ; -return vdpa_dev_net_mq_config_fill (vdev, msg, features_driver, &config); +return vdpa_dev_net_mq_config_fill (msg, features_device, &config); } static int
Signature · 1 line
2.31.1
Re: [PATCH 3/4] vDPA: check VIRTIO_NET_F_RSS for max_virtqueue_paris's presence
Quoted 8 lines · Zhu Lingshan
virtio 1.2 spec says:
max_virtqueue_pairsonly exists ifVIRTIO_NET_F_MQorVIRTIO_NET_F_RSSis set.So when reporint MQ to userspace, it should check both
VIRTIO_NET_F_MQandVIRTIO_NET_F_RSS.
Quoted 6 lines
This commit also fixes:
1) a spase warning by replacingle16_to_cpuwith__virtio16_to_cpu.
2)vdpa_dev_net_mq_config_fill()should checks device features for MQ than driver features.
3) structvdpa_device*vdev is not needed forvdpa_dev_net_mq_config_fill(), unused.
Let's do those in separate patches please.
Thanks
Quoted 42 lines
Signed-off-by Zhu Lingshan <[email protected]>--- drivers/vdpa/vdpa.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)drivers/vdpa/vdpa.c +6
-6@@ -801,16 +801,17 @@ static int vdpa_nl_cmd_dev_get_dumpit(struct sk_buff *msg, struct netlink_callbareturn msg->len; } -static int vdpa_dev_net_mq_config_fill (struct vdpa_device *vdev, -struct sk_buff *msg,u64 features, +static int vdpa_dev_net_mq_config_fill (struct sk_buff *msg,u64 features,const struct virtio_net_config *config) {u16 val_u16; -if ((features &BIT_ULL (VIRTIO_NET_F_MQ )) ==0 ) +if ((features &BIT_ULL (VIRTIO_NET_F_MQ )) ==0 && + (features &BIT_ULL (VIRTIO_NET_F_RSS )) ==0 )return 0 ; - val_u16 =le16_to_cpu (config->max_virtqueue_pairs); + val_u16 =__virtio16_to_cpu (true, config->max_virtqueue_pairs); +return nla_put_u16 (msg,VDPA_ATTR_DEV_NET_CFG_MAX_VQP , val_u16); }@@ -851,7 +852,7 @@ static int vdpa_dev_net_config_fill(struct vdpa_device *vdev, struct sk_buff *ms VDPA_ATTR_PAD))return -EMSGSIZE ; -return vdpa_dev_net_mq_config_fill (vdev, msg, features_driver, &config); +return vdpa_dev_net_mq_config_fill (msg, features_device, &config); } static int --
Quoted 2 lines
2.31.1
_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
Re: [PATCH 3/4] vDPA: check VIRTIO_NET_F_RSS for max_virtqueue_paris's presence
Quoted 8 lines · Jason Wang
Quoted 7 lines · Zhu Lingshan
virtio 1.2 spec says:
max_virtqueue_pairsonly exists ifVIRTIO_NET_F_MQorVIRTIO_NET_F_RSSis set.So when reporint MQ to userspace, it should check both
VIRTIO_NET_F_MQandVIRTIO_NET_F_RSS.
Quoted 7 lines
Quoted 6 lines
This commit also fixes:
1) a spase warning by replacingle16_to_cpuwith__virtio16_to_cpu.
2)vdpa_dev_net_mq_config_fill()should checks device features for MQ than driver features.
3) structvdpa_device*vdev is not needed forvdpa_dev_net_mq_config_fill(), unused.Let's do those in separate patches please.
will do, thanks!
Quoted 46 lines
Thanks
Quoted 43 lines
Signed-off-by Zhu Lingshan <[email protected]>--- drivers/vdpa/vdpa.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)drivers/vdpa/vdpa.c +6
-6@@ -801,16 +801,17 @@ static int vdpa_nl_cmd_dev_get_dumpit(struct sk_buff *msg, struct netlink_callbareturn msg->len; } -static int vdpa_dev_net_mq_config_fill (struct vdpa_device *vdev, -struct sk_buff *msg,u64 features, +static int vdpa_dev_net_mq_config_fill (struct sk_buff *msg,u64 features,const struct virtio_net_config *config) {u16 val_u16; -if ((features &BIT_ULL (VIRTIO_NET_F_MQ )) ==0 ) +if ((features &BIT_ULL (VIRTIO_NET_F_MQ )) ==0 && + (features &BIT_ULL (VIRTIO_NET_F_RSS )) ==0 )return 0 ; - val_u16 =le16_to_cpu (config->max_virtqueue_pairs); + val_u16 =__virtio16_to_cpu (true, config->max_virtqueue_pairs); +return nla_put_u16 (msg,VDPA_ATTR_DEV_NET_CFG_MAX_VQP , val_u16); }@@ -851,7 +852,7 @@ static int vdpa_dev_net_config_fill(struct vdpa_device *vdev, struct sk_buff *ms VDPA_ATTR_PAD))return -EMSGSIZE ; -return vdpa_dev_net_mq_config_fill (vdev, msg, features_driver, &config); +return vdpa_dev_net_mq_config_fill (msg, features_device, &config); } static int --2.31.1
PATCH 4/4 vDPA: Conditionally read MTU and MAC in dev cfg space
In reply to Zhu LingshanThe spec says:
mtu only exists if VIRTIO_NET_F_MTU is set The mac address field always exists (though is only valid if VIRTIO_NET_F_MAC is set)
So vdpa_dev_net_config_fill() should read MTU and MAC conditionally on the feature bits.
--- drivers/vdpa/vdpa.c | 37 +++++++++++++++++++++++++++++-------- 1 file changed, 29 insertions(+), 8 deletions(-)
drivers/vdpa/vdpa.c +29 -8
@@ -815,6 +815,29 @@ static int vdpa_dev_net_mq_config_fill(struct sk_buff *msg, u64 features,return nla_put_u16 (msg,VDPA_ATTR_DEV_NET_CFG_MAX_VQP , val_u16); } +static int vdpa_dev_net_mtu_config_fill (struct sk_buff *msg,u64 features, +const struct virtio_net_config *config) +{ +u16 val_u16; + +if ((features &BIT_ULL (VIRTIO_NET_F_MTU )) ==0 ) +return 0 ; + + val_u16 =__virtio16_to_cpu (true, config->mtu); + +return nla_put_u16 (msg,VDPA_ATTR_DEV_NET_CFG_MTU , val_u16); +} + +static int vdpa_dev_net_mac_config_fill (struct sk_buff *msg,u64 features, +const struct virtio_net_config *config) +{ +if ((features &BIT_ULL (VIRTIO_NET_F_MAC )) ==0 ) +return 0 ; + +return nla_put (msg,VDPA_ATTR_DEV_NET_CFG_MACADDR , +sizeof (config->mac), config->mac); +} +static int vdpa_dev_net_config_fill (struct vdpa_device *vdev,struct sk_buff *msg) {struct virtio_net_config config = {};
@@ -824,18 +847,10 @@ static int vdpa_dev_net_config_fill(struct vdpa_device *vdev, struct sk_buff *ms vdev->config->get_config (vdev,0 , &config,sizeof (config)); -if (nla_put (msg,VDPA_ATTR_DEV_NET_CFG_MACADDR ,sizeof (config.mac), - config.mac)) -return -EMSGSIZE ; - val_u16 =__virtio16_to_cpu (true, config.status);if (nla_put_u16 (msg,VDPA_ATTR_DEV_NET_STATUS , val_u16))return -EMSGSIZE ; - val_u16 =__virtio16_to_cpu (true, config.mtu); -if (nla_put_u16 (msg,VDPA_ATTR_DEV_NET_CFG_MTU , val_u16)) -return -EMSGSIZE ; -/* only read driver features after the feature negotiation is done */ status = vdev->config->get_status (vdev);if (status &VIRTIO_CONFIG_S_FEATURES_OK ) {
@@ -852,6 +867,12 @@ static int vdpa_dev_net_config_fill(struct vdpa_device *vdev, struct sk_buff *ms VDPA_ATTR_PAD))return -EMSGSIZE ; +if (vdpa_dev_net_mtu_config_fill (msg, features_device, &config)) +return -EMSGSIZE ; + +if (vdpa_dev_net_mac_config_fill (msg, features_device, &config)) +return -EMSGSIZE ; +return vdpa_dev_net_mq_config_fill (msg, features_device, &config); }
Signature · 1 line
2.31.1
Re: [PATCH 4/4] vDPA: Conditionally read MTU and MAC in dev cfg space
Quoted 10 lines · Zhu Lingshan
The spec says:
mtu only exists ifVIRTIO_NET_F_MTUis set The mac address field always exists (though is only valid ifVIRTIO_NET_F_MACis set)So
vdpa_dev_net_config_fill()should read MTU and MAC conditionally on the feature bits.Signed-off-by Zhu Lingshan <[email protected]>
Quoted 71 lines
--- drivers/vdpa/vdpa.c | 37 +++++++++++++++++++++++++++++-------- 1 file changed, 29 insertions(+), 8 deletions(-)drivers/vdpa/vdpa.c +29
-9@@ -815,6 +815,29 @@ static int vdpa_dev_net_mq_config_fill(struct sk_buff *msg, u64 features,return nla_put_u16 (msg,VDPA_ATTR_DEV_NET_CFG_MAX_VQP , val_u16); } +static int vdpa_dev_net_mtu_config_fill (struct sk_buff *msg,u64 features, +const struct virtio_net_config *config) +{ +u16 val_u16; + +if ((features &BIT_ULL (VIRTIO_NET_F_MTU )) ==0 ) +return 0 ; + + val_u16 =__virtio16_to_cpu (true, config->mtu); + +return nla_put_u16 (msg,VDPA_ATTR_DEV_NET_CFG_MTU , val_u16); +} + +static int vdpa_dev_net_mac_config_fill (struct sk_buff *msg,u64 features, +const struct virtio_net_config *config) +{ +if ((features &BIT_ULL (VIRTIO_NET_F_MAC )) ==0 ) +return 0 ; + +return nla_put (msg,VDPA_ATTR_DEV_NET_CFG_MACADDR , +sizeof (config->mac), config->mac); +} +static int vdpa_dev_net_config_fill (struct vdpa_device *vdev,struct sk_buff *msg) {struct virtio_net_config config = {};@@ -824,18 +847,10 @@ static int vdpa_dev_net_config_fill(struct vdpa_device *vdev, struct sk_buff *ms vdev->config->get_config (vdev,0 , &config,sizeof (config)); -if (nla_put (msg,VDPA_ATTR_DEV_NET_CFG_MACADDR ,sizeof (config.mac), - config.mac)) -return -EMSGSIZE ; - val_u16 =__virtio16_to_cpu (true, config.status);if (nla_put_u16 (msg,VDPA_ATTR_DEV_NET_STATUS , val_u16))return -EMSGSIZE ; - val_u16 =__virtio16_to_cpu (true, config.mtu); -if (nla_put_u16 (msg,VDPA_ATTR_DEV_NET_CFG_MTU , val_u16)) -return -EMSGSIZE ; -/* only read driver features after the feature negotiation is done */ status = vdev->config->get_status (vdev);if (status &VIRTIO_CONFIG_S_FEATURES_OK ) {@@ -852,6 +867,12 @@ static int vdpa_dev_net_config_fill(struct vdpa_device *vdev, struct sk_buff *ms VDPA_ATTR_PAD))return -EMSGSIZE ; +if (vdpa_dev_net_mtu_config_fill (msg, features_device, &config)) +return -EMSGSIZE ; + +if (vdpa_dev_net_mac_config_fill (msg, features_device, &config)) +return -EMSGSIZE ; +return vdpa_dev_net_mq_config_fill (msg, features_device, &config); } --
Quoted 2 lines
2.31.1
_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization