vDPA: allow userspace query virito-block device
cover vDPA: allow userspace query virito-block device
This series allows the user space applications query vDPA virtio-block device inforamtion.
testing on vdpa_sim_blk, iproute2 output:
sudo ./vdpa/vdpa dev config show -jp vdpa_blk0
{
"config": {
"vdpa_blk0": {
"capacity": 262144,
"segment size": 4096,
"block size": 512,
"max segments in a request": 32,
"num of queues": 1,
"logical blocks per physical block (log2)": 0, "offset of first aligned logical block": 0, "minimum io size": 1,
"optimal io size": 1,
"maximum discard sectors for a segment": 4294967295, "max discard segments in a command": 1, "discard sector alignment": 512,
"max write zeros sectors in a segment": 4294967295, "max write zero segments": 1,
"read only": false,
"flush command support": true
}
}
}
Please help review
Thanks
Zhu Lingshan
Zhu Lingshan (10):
vDPA: report virtio-block capacity to user space
vDPA: report virtio-block max segment size to user space
vDPA: report virtio-block block-size to user space
vDPA: report virtio-block max segments in a request to user space
vDPA: report virtio-block MQ info to user space
vDPA: report virtio-block topology info to user space
vDPA: report virtio-block discarding configuration to user space
vDPA: report virtio-block write zeroes configuration to user space
vDPA: report virtio-block read-only info to user space
vDPA: report virtio-blk flush info to user space
drivers/vdpa/vdpa.c | 212 ++++++++++++++++++++++++++++++++++++++ include/linux/vdpa.h | 1 + include/uapi/linux/vdpa.h | 17 +++ 3 files changed, 230 insertions(+)
Signature · 1 line
2.39.3
PATCH 1/10 vDPA: report virtio-block capacity to user space
This commit allows userspace to query capacity of
a virtio-block device.
--- drivers/vdpa/vdpa.c | 35 +++++++++++++++++++++++++++++++++++ include/linux/vdpa.h | 1 + include/uapi/linux/vdpa.h | 2 ++ 3 files changed, 38 insertions(+)
drivers/vdpa/vdpa.c +35 -0
@@ -944,6 +944,38 @@ static int vdpa_dev_net_config_fill(struct vdpa_device *vdev, struct sk_buff *msreturn vdpa_dev_net_mq_config_fill (msg, features_device, &config); } +static int +vdpa_dev_blk_capacity_config_fill (struct sk_buff *msg, +const struct virtio_blk_config *config) +{ +u64 val_u64; + + val_u64 =__virtio64_to_cpu (true, config->capacity); + +return nla_put_u64_64bit (msg,VDPA_ATTR_DEV_BLK_CFG_CAPACITY , + val_u64,VDPA_ATTR_PAD ); +} + +static int vdpa_dev_blk_config_fill (struct vdpa_device *vdev, +struct sk_buff *msg) +{ +struct virtio_blk_config config = {}; +u64 features_device; + + vdev->config->get_config (vdev,0 , &config,sizeof (config)); + + features_device = vdev->config->get_device_features (vdev); + +if (nla_put_u64_64bit (msg,VDPA_ATTR_DEV_FEATURES , features_device, +VDPA_ATTR_PAD )) +return -EMSGSIZE ; + +if (vdpa_dev_blk_capacity_config_fill (msg, &config)) +return -EMSGSIZE ; + +return 0 ; +} +static int vdpa_dev_config_fill (struct vdpa_device *vdev,struct sk_buff *msg,u32 portid,u32 seq,int flags,struct netlink_ext_ack *extack)
@@ -988,6 +1020,9 @@ vdpa_dev_config_fill(struct vdpa_device *vdev, struct sk_buff *msg, u32 portid,case VIRTIO_ID_NET : err =vdpa_dev_net_config_fill (vdev, msg);break ; +case VIRTIO_ID_BLOCK : + err =vdpa_dev_blk_config_fill (vdev, msg); +break ;default : err = -EOPNOTSUPP ;break ;
include/linux/vdpa.h +1 -0
@@ -7,6 +7,7 @@#include <linux/interrupt.h> #include <linux/vhost_iotlb.h> #include <linux/virtio_net.h> +#include <linux/virtio_blk.h> #include <linux/if_ether.h> /**
include/uapi/linux/vdpa.h +2 -0
@@ -56,6 +56,8 @@ enum vdpa_attr {/* virtio features that are provisioned to the vDPA device */ VDPA_ATTR_DEV_FEATURES ,/* u64 */ +VDPA_ATTR_DEV_BLK_CFG_CAPACITY ,/* u64 */ +/* new attributes must be added above here */ VDPA_ATTR_MAX, };
Signature · 1 line
2.39.3
PATCH 2/10 vDPA: report virtio-block max segment size to user space
In reply to Zhu LingshanThis commit allows reporting the max size of any single segment of virtio-block devices to user space.
--- drivers/vdpa/vdpa.c | 17 +++++++++++++++++ include/uapi/linux/vdpa.h | 1 + 2 files changed, 18 insertions(+)
drivers/vdpa/vdpa.c +17 -0
@@ -956,6 +956,20 @@ vdpa_dev_blk_capacity_config_fill(struct sk_buff *msg, val_u64, VDPA_ATTR_PAD); } +static int +vdpa_dev_blk_seg_size_config_fill (struct sk_buff *msg,u64 features, +const struct virtio_blk_config *config) +{ +u32 val_u32; + +if ((features &BIT_ULL (VIRTIO_BLK_F_SIZE_MAX )) ==0 ) +return 0 ; + + val_u32 =__virtio32_to_cpu (true, config->size_max); + +return nla_put_u32 (msg,VDPA_ATTR_DEV_BLK_CFG_SEG_SIZE , val_u32); +} +static int vdpa_dev_blk_config_fill (struct vdpa_device *vdev,struct sk_buff *msg) {
@@ -973,6 +987,9 @@ static int vdpa_dev_blk_config_fill(struct vdpa_device *vdev,if (vdpa_dev_blk_capacity_config_fill (msg, &config))return -EMSGSIZE ; +if (vdpa_dev_blk_seg_size_config_fill (msg, features_device, &config)) +return -EMSGSIZE ; +return 0 ; }
include/uapi/linux/vdpa.h +1 -0
@@ -57,6 +57,7 @@ enum vdpa_attr {VDPA_ATTR_DEV_FEATURES ,/* u64 */ VDPA_ATTR_DEV_BLK_CFG_CAPACITY ,/* u64 */ +VDPA_ATTR_DEV_BLK_CFG_SEG_SIZE ,/* u32 */ /* new attributes must be added above here */ VDPA_ATTR_MAX,
Signature · 1 line
2.39.3
PATCH 3/10 vDPA: report virtio-block block-size to user space
In reply to Zhu LingshanThis commit allows reporting the block size of a
virtio-block device to user space.
--- drivers/vdpa/vdpa.c | 18 ++++++++++++++++++ include/uapi/linux/vdpa.h | 1 + 2 files changed, 19 insertions(+)
drivers/vdpa/vdpa.c +18 -0
@@ -970,6 +970,21 @@ vdpa_dev_blk_seg_size_config_fill(struct sk_buff *msg, u64 features,return nla_put_u32 (msg,VDPA_ATTR_DEV_BLK_CFG_SEG_SIZE , val_u32); } +/* fill the block size*/ +static int +vdpa_dev_blk_block_size_config_fill (struct sk_buff *msg,u64 features, +const struct virtio_blk_config *config) +{ +u32 val_u32; + +if ((features &BIT_ULL (VIRTIO_BLK_F_BLK_SIZE )) ==0 ) +return 0 ; + + val_u32 =__virtio32_to_cpu (true, config->blk_size); + +return nla_put_u32 (msg,VDPA_ATTR_DEV_BLK_CFG_BLK_SIZE , val_u32); +} +static int vdpa_dev_blk_config_fill (struct vdpa_device *vdev,struct sk_buff *msg) {
@@ -990,6 +1005,9 @@ static int vdpa_dev_blk_config_fill(struct vdpa_device *vdev,if (vdpa_dev_blk_seg_size_config_fill (msg, features_device, &config))return -EMSGSIZE ; +if (vdpa_dev_blk_block_size_config_fill (msg, features_device, &config)) +return -EMSGSIZE ; +return 0 ; }
include/uapi/linux/vdpa.h +1 -0
@@ -58,6 +58,7 @@ enum vdpa_attr {VDPA_ATTR_DEV_BLK_CFG_CAPACITY ,/* u64 */ VDPA_ATTR_DEV_BLK_CFG_SEG_SIZE ,/* u32 */ +VDPA_ATTR_DEV_BLK_CFG_BLK_SIZE ,/* u32 */ /* new attributes must be added above here */ VDPA_ATTR_MAX,
Signature · 1 line
2.39.3
PATCH 4/10 vDPA: report virtio-block max segments in a request to user space
In reply to Zhu LingshanThis commit allows vDPA reporting the maximum number of segments in a request of virtio-block devices to user space.
--- drivers/vdpa/vdpa.c | 17 +++++++++++++++++ include/uapi/linux/vdpa.h | 1 + 2 files changed, 18 insertions(+)
drivers/vdpa/vdpa.c +17 -0
@@ -985,6 +985,20 @@ vdpa_dev_blk_block_size_config_fill(struct sk_buff *msg, u64 features,return nla_put_u32 (msg,VDPA_ATTR_DEV_BLK_CFG_BLK_SIZE , val_u32); } +static int +vdpa_dev_blk_seg_max_config_fill (struct sk_buff *msg,u64 features, +const struct virtio_blk_config *config) +{ +u32 val_u32; + +if ((features &BIT_ULL (VIRTIO_BLK_F_SEG_MAX )) ==0 ) +return 0 ; + + val_u32 =__virtio32_to_cpu (true, config->seg_max); + +return nla_put_u32 (msg,VDPA_ATTR_DEV_BLK_CFG_SEG_MAX , val_u32); +} +static int vdpa_dev_blk_config_fill (struct vdpa_device *vdev,struct sk_buff *msg) {
@@ -1008,6 +1022,9 @@ static int vdpa_dev_blk_config_fill(struct vdpa_device *vdev,if (vdpa_dev_blk_block_size_config_fill (msg, features_device, &config))return -EMSGSIZE ; +if (vdpa_dev_blk_seg_max_config_fill (msg, features_device, &config)) +return -EMSGSIZE ; +return 0 ; }
include/uapi/linux/vdpa.h +1 -0
@@ -59,6 +59,7 @@ enum vdpa_attr {VDPA_ATTR_DEV_BLK_CFG_CAPACITY ,/* u64 */ VDPA_ATTR_DEV_BLK_CFG_SEG_SIZE ,/* u32 */ VDPA_ATTR_DEV_BLK_CFG_BLK_SIZE ,/* u32 */ +VDPA_ATTR_DEV_BLK_CFG_SEG_MAX ,/* u32 */ /* new attributes must be added above here */ VDPA_ATTR_MAX,
Signature · 1 line
2.39.3
PATCH 5/10 vDPA: report virtio-block MQ info to user space
In reply to Zhu LingshanThis commits allows vDPA reporting virtio-block multi-queue configuration to user sapce.
--- drivers/vdpa/vdpa.c | 16 ++++++++++++++++ include/uapi/linux/vdpa.h | 1 + 2 files changed, 17 insertions(+)
drivers/vdpa/vdpa.c +16 -0
@@ -999,6 +999,19 @@ vdpa_dev_blk_seg_max_config_fill(struct sk_buff *msg, u64 features,return nla_put_u32 (msg,VDPA_ATTR_DEV_BLK_CFG_SEG_MAX , val_u32); } +static int vdpa_dev_blk_mq_config_fill (struct sk_buff *msg,u64 features, +const struct virtio_blk_config *config) +{ +u16 val_u16; + +if ((features &BIT_ULL (VIRTIO_BLK_F_MQ )) ==0 ) +return 0 ; + + val_u16 =__virtio16_to_cpu (true, config->num_queues); + +return nla_put_u16 (msg,VDPA_ATTR_DEV_BLK_CFG_NUM_QUEUES , val_u16); +} +static int vdpa_dev_blk_config_fill (struct vdpa_device *vdev,struct sk_buff *msg) {
@@ -1025,6 +1038,9 @@ static int vdpa_dev_blk_config_fill(struct vdpa_device *vdev,if (vdpa_dev_blk_seg_max_config_fill (msg, features_device, &config))return -EMSGSIZE ; +if (vdpa_dev_blk_mq_config_fill (msg, features_device, &config)) +return -EMSGSIZE ; +return 0 ; }
include/uapi/linux/vdpa.h +1 -0
@@ -60,6 +60,7 @@ enum vdpa_attr {VDPA_ATTR_DEV_BLK_CFG_SEG_SIZE ,/* u32 */ VDPA_ATTR_DEV_BLK_CFG_BLK_SIZE ,/* u32 */ VDPA_ATTR_DEV_BLK_CFG_SEG_MAX ,/* u32 */ +VDPA_ATTR_DEV_BLK_CFG_NUM_QUEUES ,/* u16 */ /* new attributes must be added above here */ VDPA_ATTR_MAX,
Signature · 1 line
2.39.3
PATCH 6/10 vDPA: report virtio-block topology info to user space
In reply to Zhu LingshanThis commit allows vDPA reporting topology information of virtio-blk devices to user space, includes:
1) the number of logical blocks per physical block
2) offset of first aligned logical block
3) suggested minimum I/O size in blocks
4) optimal (suggested maximum) I/O size in blocks
--- drivers/vdpa/vdpa.c | 32 ++++++++++++++++++++++++++++++++ include/uapi/linux/vdpa.h | 4 ++++ 2 files changed, 36 insertions(+)
drivers/vdpa/vdpa.c +32 -0
@@ -1012,6 +1012,35 @@ static int vdpa_dev_blk_mq_config_fill(struct sk_buff *msg, u64 features,return nla_put_u16 (msg,VDPA_ATTR_DEV_BLK_CFG_NUM_QUEUES , val_u16); } +static int vdpa_dev_blk_topology_config_fill (struct sk_buff *msg,u64 features, +const struct virtio_blk_config *config) +{ +u16 min_io_size; +u32 opt_io_size; + +if ((features &BIT_ULL (VIRTIO_BLK_F_TOPOLOGY )) ==0 ) +return 0 ; + + min_io_size =__virtio16_to_cpu (true, config->min_io_size); + opt_io_size =__virtio32_to_cpu (true, config->opt_io_size); + +if (nla_put_u8 (msg,VDPA_ATTR_DEV_BLK_CFG_PHY_BLK_EXP , + config->physical_block_exp)) +return -EMSGSIZE ; + +if (nla_put_u8 (msg,VDPA_ATTR_DEV_BLK_CFG_ALIGN_OFFSET , + config->alignment_offset)) +return -EMSGSIZE ; + +if (nla_put_u16 (msg,VDPA_ATTR_DEV_BLK_CFG_MIN_IO_SIZE , min_io_size)) +return -EMSGSIZE ; + +if (nla_put_u32 (msg,VDPA_ATTR_DEV_BLK_CFG_OPT_IO_SIZE , opt_io_size)) +return -EMSGSIZE ; + +return 0 ; +} +static int vdpa_dev_blk_config_fill (struct vdpa_device *vdev,struct sk_buff *msg) {
@@ -1041,6 +1070,9 @@ static int vdpa_dev_blk_config_fill(struct vdpa_device *vdev,if (vdpa_dev_blk_mq_config_fill (msg, features_device, &config))return -EMSGSIZE ; +if (vdpa_dev_blk_topology_config_fill (msg, features_device, &config)) +return -EMSGSIZE ; +return 0 ; }
include/uapi/linux/vdpa.h +4 -0
@@ -61,6 +61,10 @@ enum vdpa_attr {VDPA_ATTR_DEV_BLK_CFG_BLK_SIZE ,/* u32 */ VDPA_ATTR_DEV_BLK_CFG_SEG_MAX ,/* u32 */ VDPA_ATTR_DEV_BLK_CFG_NUM_QUEUES ,/* u16 */ +VDPA_ATTR_DEV_BLK_CFG_PHY_BLK_EXP ,/* u8 */ +VDPA_ATTR_DEV_BLK_CFG_ALIGN_OFFSET ,/* u8 */ +VDPA_ATTR_DEV_BLK_CFG_MIN_IO_SIZE ,/* u16 */ +VDPA_ATTR_DEV_BLK_CFG_OPT_IO_SIZE ,/* u32 */ /* new attributes must be added above here */ VDPA_ATTR_MAX,
Signature · 1 line
2.39.3
PATCH 7/10 vDPA: report virtio-block discarding configuration to user space
In reply to Zhu LingshanThis commit reports virtio-blk discarding configuration to user space,includes:
1) the maximum discard sectors
2) maximum number of discard segments for the block driver to use
3) the alignment for splitting a discarding request
--- drivers/vdpa/vdpa.c | 26 ++++++++++++++++++++++++++ include/uapi/linux/vdpa.h | 3 +++ 2 files changed, 29 insertions(+)
drivers/vdpa/vdpa.c +26 -0
@@ -1041,6 +1041,29 @@ static int vdpa_dev_blk_topology_config_fill(struct sk_buff *msg, u64 features,return 0 ; } +static int vdpa_dev_blk_discard_config_fill (struct sk_buff *msg,u64 features, +const struct virtio_blk_config *config) +{ +u32 val_u32; + +if ((features &BIT_ULL (VIRTIO_BLK_F_DISCARD )) ==0 ) +return 0 ; + + val_u32 =__virtio32_to_cpu (true, config->max_discard_sectors); +if (nla_put_u32 (msg,VDPA_ATTR_DEV_BLK_CFG_MAX_DISCARD_SEC , val_u32)) +return -EMSGSIZE ; + + val_u32 =__virtio32_to_cpu (true, config->max_discard_seg); +if (nla_put_u32 (msg,VDPA_ATTR_DEV_BLK_CFG_MAX_DISCARD_SEG , val_u32)) +return -EMSGSIZE ; + + val_u32 =__virtio32_to_cpu (true, config->discard_sector_alignment); +if (nla_put_u32 (msg,VDPA_ATTR_DEV_BLK_CFG_DISCARD_SEC_ALIGN , val_u32)) +return -EMSGSIZE ; + +return 0 ; +} +static int vdpa_dev_blk_config_fill (struct vdpa_device *vdev,struct sk_buff *msg) {
@@ -1073,6 +1096,9 @@ static int vdpa_dev_blk_config_fill(struct vdpa_device *vdev,if (vdpa_dev_blk_topology_config_fill (msg, features_device, &config))return -EMSGSIZE ; +if (vdpa_dev_blk_discard_config_fill (msg, features_device, &config)) +return -EMSGSIZE ; +return 0 ; }
include/uapi/linux/vdpa.h +3 -0
@@ -65,6 +65,9 @@ enum vdpa_attr {VDPA_ATTR_DEV_BLK_CFG_ALIGN_OFFSET ,/* u8 */ VDPA_ATTR_DEV_BLK_CFG_MIN_IO_SIZE ,/* u16 */ VDPA_ATTR_DEV_BLK_CFG_OPT_IO_SIZE ,/* u32 */ +VDPA_ATTR_DEV_BLK_CFG_MAX_DISCARD_SEC ,/* u32 */ +VDPA_ATTR_DEV_BLK_CFG_MAX_DISCARD_SEG ,/* u32 */ +VDPA_ATTR_DEV_BLK_CFG_DISCARD_SEC_ALIGN ,/* u32 */ /* new attributes must be added above here */ VDPA_ATTR_MAX,
Signature · 1 line
2.39.3
PATCH 8/10 vDPA: report virtio-block write zeroes configuration to user space
In reply to Zhu LingshanThis commits reports write zeroes configuration of virtio-block devices to user space, includes:
1)maximum write zeroes sectors size 2)maximum write zeroes segment number
--- drivers/vdpa/vdpa.c | 23 +++++++++++++++++++++++ include/uapi/linux/vdpa.h | 2 ++ 2 files changed, 25 insertions(+)
drivers/vdpa/vdpa.c +23 -0
@@ -1064,6 +1064,26 @@ static int vdpa_dev_blk_discard_config_fill(struct sk_buff *msg, u64 features,return 0 ; } +static int +vdpa_dev_blk_write_zeroes_config_fill (struct sk_buff *msg,u64 features, +const struct virtio_blk_config *config) +{ +u32 val_u32; + +if ((features &BIT_ULL (VIRTIO_BLK_F_WRITE_ZEROES )) ==0 ) +return 0 ; + + val_u32 =__virtio32_to_cpu (true, config->max_write_zeroes_sectors); +if (nla_put_u32 (msg,VDPA_ATTR_DEV_BLK_CFG_MAX_WRITE_ZEROES_SEC , val_u32)) +return -EMSGSIZE ; + + val_u32 =__virtio32_to_cpu (true, config->max_write_zeroes_seg); +if (nla_put_u32 (msg,VDPA_ATTR_DEV_BLK_CFG_MAX_WRITE_ZEROES_SEG , val_u32)) +return -EMSGSIZE ; + +return 0 ; +} +static int vdpa_dev_blk_config_fill (struct vdpa_device *vdev,struct sk_buff *msg) {
@@ -1099,6 +1119,9 @@ static int vdpa_dev_blk_config_fill(struct vdpa_device *vdev,if (vdpa_dev_blk_discard_config_fill (msg, features_device, &config))return -EMSGSIZE ; +if (vdpa_dev_blk_write_zeroes_config_fill (msg, features_device, &config)) +return -EMSGSIZE ; +return 0 ; }
include/uapi/linux/vdpa.h +2 -0
@@ -68,6 +68,8 @@ enum vdpa_attr {VDPA_ATTR_DEV_BLK_CFG_MAX_DISCARD_SEC ,/* u32 */ VDPA_ATTR_DEV_BLK_CFG_MAX_DISCARD_SEG ,/* u32 */ VDPA_ATTR_DEV_BLK_CFG_DISCARD_SEC_ALIGN ,/* u32 */ +VDPA_ATTR_DEV_BLK_CFG_MAX_WRITE_ZEROES_SEC ,/* u32 */ +VDPA_ATTR_DEV_BLK_CFG_MAX_WRITE_ZEROES_SEG ,/* u32 */ /* new attributes must be added above here */ VDPA_ATTR_MAX,
Signature · 1 line
2.39.3
PATCH 9/10 vDPA: report virtio-block read-only info to user space
In reply to Zhu LingshanThis commit report read-only information of
virtio-blk devices to user space.
--- drivers/vdpa/vdpa.c | 14 ++++++++++++++ include/uapi/linux/vdpa.h | 1 + 2 files changed, 15 insertions(+)
drivers/vdpa/vdpa.c +14 -0
@@ -1084,6 +1084,17 @@ vdpa_dev_blk_write_zeroes_config_fill(struct sk_buff *msg, u64 features,return 0 ; } +static int vdpa_dev_blk_ro_config_fill (struct sk_buff *msg,u64 features) +{ +u8 ro; + + ro = ((features &BIT_ULL (VIRTIO_BLK_F_RO )) ==0 ) ?0 :1 ; +if (nla_put_u8 (msg,VDPA_ATTR_DEV_BLK_CFG_READ_ONLY , ro)) +return -EMSGSIZE ; + +return 0 ; +} +static int vdpa_dev_blk_config_fill (struct vdpa_device *vdev,struct sk_buff *msg) {
@@ -1122,6 +1133,9 @@ static int vdpa_dev_blk_config_fill(struct vdpa_device *vdev,if (vdpa_dev_blk_write_zeroes_config_fill (msg, features_device, &config))return -EMSGSIZE ; +if (vdpa_dev_blk_ro_config_fill (msg, features_device)) +return -EMSGSIZE ; +return 0 ; }
include/uapi/linux/vdpa.h +1 -0
@@ -70,6 +70,7 @@ enum vdpa_attr {VDPA_ATTR_DEV_BLK_CFG_DISCARD_SEC_ALIGN ,/* u32 */ VDPA_ATTR_DEV_BLK_CFG_MAX_WRITE_ZEROES_SEC ,/* u32 */ VDPA_ATTR_DEV_BLK_CFG_MAX_WRITE_ZEROES_SEG ,/* u32 */ +VDPA_ATTR_DEV_BLK_CFG_READ_ONLY ,/* u8 */ /* new attributes must be added above here */ VDPA_ATTR_MAX,
Signature · 1 line
2.39.3
PATCH 10/10 vDPA: report virtio-blk flush info to user space
In reply to Zhu LingshanThis commit reports whether a virtio-blk device
support cache flush command to user space
--- drivers/vdpa/vdpa.c | 14 ++++++++++++++ include/uapi/linux/vdpa.h | 1 + 2 files changed, 15 insertions(+)
drivers/vdpa/vdpa.c +14 -0
@@ -1095,6 +1095,17 @@ static int vdpa_dev_blk_ro_config_fill(struct sk_buff *msg, u64 features)return 0 ; } +static int vdpa_dev_blk_flush_config_fill (struct sk_buff *msg,u64 features) +{ +u8 flush; + + flush = ((features &BIT_ULL (VIRTIO_BLK_F_FLUSH )) ==0 ) ?0 :1 ; +if (nla_put_u8 (msg,VDPA_ATTR_DEV_BLK_CFG_FLUSH , flush)) +return -EMSGSIZE ; + +return 0 ; +} +static int vdpa_dev_blk_config_fill (struct vdpa_device *vdev,struct sk_buff *msg) {
@@ -1136,6 +1147,9 @@ static int vdpa_dev_blk_config_fill(struct vdpa_device *vdev,if (vdpa_dev_blk_ro_config_fill (msg, features_device))return -EMSGSIZE ; +if (vdpa_dev_blk_flush_config_fill (msg, features_device)) +return -EMSGSIZE ; +return 0 ; }
include/uapi/linux/vdpa.h +1 -0
@@ -71,6 +71,7 @@ enum vdpa_attr {VDPA_ATTR_DEV_BLK_CFG_MAX_WRITE_ZEROES_SEC ,/* u32 */ VDPA_ATTR_DEV_BLK_CFG_MAX_WRITE_ZEROES_SEG ,/* u32 */ VDPA_ATTR_DEV_BLK_CFG_READ_ONLY ,/* u8 */ +VDPA_ATTR_DEV_BLK_CFG_FLUSH ,/* u8 */ /* new attributes must be added above here */ VDPA_ATTR_MAX,
Signature · 1 line
2.39.3
Michael S. Tsirkin
maintainerQuoted 28 lines · Zhu Lingshan
This series allows the user space applications query vDPA virtio-block device inforamtion.
testing on
vdpa_sim_blk, iproute2 output:
sudo ./vdpa/vdpa dev config show -jpvdpa_blk0
{
"config": {
"vdpa_blk0": {
"capacity": 262144,
"segment size": 4096,
"block size": 512,
"max segments in a request": 32,
"num of queues": 1,
"logical blocks per physical block (log2)": 0, "offset of first aligned logical block": 0, "minimum io size": 1,
"optimal io size": 1,
"maximum discard sectors for a segment": 4294967295, "max discard segments in a command": 1, "discard sector alignment": 512,
"max write zeros sectors in a segment": 4294967295, "max write zero segments": 1,
"read only": false,
"flush command support": true
}
}
}
Quoted 4 lines
Please help review
Thanks
Zhu Lingshan
It's been in my tree for a while so it will be in the next pull, but going forward Jason I'd like to know what kind of timeline do you have in mind for reviewing vdpa patches?
Quoted 19 lines
Zhu Lingshan (10):
vDPA: report virtio-block capacity to user space
vDPA: report virtio-block max segment size to user space
vDPA: report virtio-block block-size to user space
vDPA: report virtio-block max segments in a request to user space
vDPA: report virtio-block MQ info to user space
vDPA: report virtio-block topology info to user space
vDPA: report virtio-block discarding configuration to user space
vDPA: report virtio-block write zeroes configuration to user space
vDPA: report virtio-block read-only info to user space
vDPA: report virtio-blk flush info to user spacedrivers/vdpa/vdpa.c | 212 ++++++++++++++++++++++++++++++++++++++ include/linux/vdpa.h | 1 + include/uapi/linux/vdpa.h | 17 +++ 3 files changed, 230 insertions(+)Signature · 1 line
2.39.3
Re: [PATCH 02/10] vDPA: report virtio-block max segment size to user space
In reply to Zhu LingshanQuoted 19 lines · Zhu Lingshan
This commit allows reporting the max size of any single segment of virtio-block devices to user space.
Signed-off-by Zhu Lingshan <[email protected]>---
drivers/vdpa/vdpa.c| 17 +++++++++++++++++include/uapi/linux/vdpa.h| 1 +2 files changed, 18 insertions(+)drivers/vdpa/vdpa.c +2
-0@@ -956,6 +956,20 @@ vdpa_dev_blk_capacity_config_fill(struct sk_buff *msg, val_u64, VDPA_ATTR_PAD); } +static int +vdpa_dev_blk_seg_size_config_fill(struct sk_buff *msg, u64 features,
drivers/vdpa/vdpa.c vdpa_dev_blk_capacity_config_fill(struct sk_buff *msg, · line 970
Quoted 10 lines
drivers/vdpa/vdpa.c +10
-0+ const struct virtio_blk_config *config) +{ +u32 val_u32; + +if ((features &BIT_ULL (VIRTIO_BLK_F_SIZE_MAX )) ==0 ) +return 0 ; + + val_u32 =__virtio32_to_cpu (true, config->size_max); + +return nla_put_u32 (msg,VDPA_ATTR_DEV_BLK_CFG_SEG_SIZE , val_u32);
Should we call this VDPA_ATTR_DEV_BLK_CFG_SIZE_MAX ?
Quoted 31 lines
drivers/vdpa/vdpa.c +5
-0+} +static int vdpa_dev_blk_config_fill (struct vdpa_device *vdev,struct sk_buff *msg) {@@ -973,6 +987,9 @@ static int vdpa_dev_blk_config_fill(struct vdpa_device *vdev,if (vdpa_dev_blk_capacity_config_fill (msg, &config))return -EMSGSIZE ; +if (vdpa_dev_blk_seg_size_config_fill (msg, features_device, &config)) +return -EMSGSIZE ; +return 0 ; }include/uapi/linux/vdpa.h +1
-0@@ -57,6 +57,7 @@ enum vdpa_attr {VDPA_ATTR_DEV_FEATURES ,/* u64 */ VDPA_ATTR_DEV_BLK_CFG_CAPACITY ,/* u64 */ +VDPA_ATTR_DEV_BLK_CFG_SEG_SIZE ,/* u32 */ /* new attributes must be added above here */ VDPA_ATTR_MAX,Signature · 1 line
2.39.3
Re: [PATCH 08/10] vDPA: report virtio-block write zeroes configuration to user space
In reply to Zhu LingshanQuoted 25 lines · Zhu Lingshan
This commits reports write zeroes configuration of virtio-block devices to user space, includes:
1)maximum write zeroes sectors size 2)maximum write zeroes segment numberSigned-off-by Zhu Lingshan <[email protected]>---
drivers/vdpa/vdpa.c| 23 +++++++++++++++++++++++include/uapi/linux/vdpa.h| 2 ++2 files changed, 25 insertions(+)drivers/vdpa/vdpa.c +6
-0@@ -1064,6 +1064,26 @@ static int vdpa_dev_blk_discard_config_fill(struct sk_buff *msg, u64 features,return 0 ; } +static int +vdpa_dev_blk_write_zeroes_config_fill (struct sk_buff *msg,u64 features, +const struct virtio_blk_config *config) +{ +u32 val_u32; +
drivers/vdpa/vdpa.c static int vdpa_dev_blk_discard_config_fill(struct sk_buff *msg, u64 features, · line 1082
Quoted 10 lines
drivers/vdpa/vdpa.c +10
-0+if ((features &BIT_ULL (VIRTIO_BLK_F_WRITE_ZEROES )) ==0 ) +return 0 ; + + val_u32 =__virtio32_to_cpu (true, config->max_write_zeroes_sectors); +if (nla_put_u32 (msg,VDPA_ATTR_DEV_BLK_CFG_MAX_WRITE_ZEROES_SEC , val_u32)) +return -EMSGSIZE ; + + val_u32 =__virtio32_to_cpu (true, config->max_write_zeroes_seg); +if (nla_put_u32 (msg,VDPA_ATTR_DEV_BLK_CFG_MAX_WRITE_ZEROES_SEG , val_u32)) +return -EMSGSIZE ;
Should we cover also config->write_zeroes_may_unmap ?
Quoted 34 lines
drivers/vdpa/vdpa.c +7
-0+ +return 0 ; +} +static int vdpa_dev_blk_config_fill (struct vdpa_device *vdev,struct sk_buff *msg) {@@ -1099,6 +1119,9 @@ static int vdpa_dev_blk_config_fill(struct vdpa_device *vdev,if (vdpa_dev_blk_discard_config_fill (msg, features_device, &config))return -EMSGSIZE ; +if (vdpa_dev_blk_write_zeroes_config_fill (msg, features_device, &config)) +return -EMSGSIZE ; +return 0 ; }include/uapi/linux/vdpa.h +2
-0@@ -68,6 +68,8 @@ enum vdpa_attr {VDPA_ATTR_DEV_BLK_CFG_MAX_DISCARD_SEC ,/* u32 */ VDPA_ATTR_DEV_BLK_CFG_MAX_DISCARD_SEG ,/* u32 */ VDPA_ATTR_DEV_BLK_CFG_DISCARD_SEC_ALIGN ,/* u32 */ +VDPA_ATTR_DEV_BLK_CFG_MAX_WRITE_ZEROES_SEC ,/* u32 */ +VDPA_ATTR_DEV_BLK_CFG_MAX_WRITE_ZEROES_SEG ,/* u32 */ /* new attributes must be added above here */ VDPA_ATTR_MAX,Signature · 1 line
2.39.3
Re: [PATCH 09/10] vDPA: report virtio-block read-only info to user space
In reply to Zhu LingshanQuoted 14 lines · Zhu Lingshan
This commit report read-only information of
virtio-blk devices to user space.Signed-off-by Zhu Lingshan <[email protected]>---
drivers/vdpa/vdpa.c| 14 ++++++++++++++include/uapi/linux/vdpa.h| 1 +2 files changed, 15 insertions(+)drivers/vdpa/vdpa.c +0
-0
drivers/vdpa/vdpa.c vdpa_dev_blk_write_zeroes_config_fill(struct sk_buff *msg, u64 features, · line 1092
Quoted 9 lines
drivers/vdpa/vdpa.c +6
-0@@ -1084,6 +1084,17 @@ vdpa_dev_blk_write_zeroes_config_fill(struct sk_buff *msg, u64 features,return 0 ; } +static int vdpa_dev_blk_ro_config_fill (struct sk_buff *msg,u64 features) +{ +u8 ro; + + ro = ((features &BIT_ULL (VIRTIO_BLK_F_RO )) ==0 ) ?0 :1 ; +if (nla_put_u8 (msg,VDPA_ATTR_DEV_BLK_CFG_READ_ONLY , ro))
This is not really related to the config space, what about renaming it to VDPA_ATTR_DEV_BLK_READ_ONLY ?
Also the type, maybe better to use "flag" and set it through nla_put_flag().
Not a strong opinion on that, it just seems a little more consistent to me.
Thanks,
Stefano
Quoted 34 lines
drivers/vdpa/vdpa.c +8
-0+return -EMSGSIZE ; + +return 0 ; +} +static int vdpa_dev_blk_config_fill (struct vdpa_device *vdev,struct sk_buff *msg) {@@ -1122,6 +1133,9 @@ static int vdpa_dev_blk_config_fill(struct vdpa_device *vdev,if (vdpa_dev_blk_write_zeroes_config_fill (msg, features_device, &config))return -EMSGSIZE ; +if (vdpa_dev_blk_ro_config_fill (msg, features_device)) +return -EMSGSIZE ; +return 0 ; }include/uapi/linux/vdpa.h +1
-0@@ -70,6 +70,7 @@ enum vdpa_attr {VDPA_ATTR_DEV_BLK_CFG_DISCARD_SEC_ALIGN ,/* u32 */ VDPA_ATTR_DEV_BLK_CFG_MAX_WRITE_ZEROES_SEC ,/* u32 */ VDPA_ATTR_DEV_BLK_CFG_MAX_WRITE_ZEROES_SEG ,/* u32 */ +VDPA_ATTR_DEV_BLK_CFG_READ_ONLY ,/* u8 */ /* new attributes must be added above here */ VDPA_ATTR_MAX,Signature · 1 line
2.39.3
Re: [PATCH 10/10] vDPA: report virtio-blk flush info to user space
In reply to Zhu LingshanQuoted 14 lines · Zhu Lingshan
This commit reports whether a virtio-blk device
support cache flush command to user spaceSigned-off-by Zhu Lingshan <[email protected]>---
drivers/vdpa/vdpa.c| 14 ++++++++++++++include/uapi/linux/vdpa.h| 1 +2 files changed, 15 insertions(+)drivers/vdpa/vdpa.c +0
-0
drivers/vdpa/vdpa.c static int vdpa_dev_blk_ro_config_fill(struct sk_buff *msg, u64 features) · line 1104
Quoted 10 lines
drivers/vdpa/vdpa.c +7
-0@@ -1095,6 +1095,17 @@ static int vdpa_dev_blk_ro_config_fill(struct sk_buff *msg, u64 features)return 0 ; } +static int vdpa_dev_blk_flush_config_fill (struct sk_buff *msg,u64 features) +{ +u8 flush; + + flush = ((features &BIT_ULL (VIRTIO_BLK_F_FLUSH )) ==0 ) ?0 :1 ; +if (nla_put_u8 (msg,VDPA_ATTR_DEV_BLK_CFG_FLUSH , flush)) +return -EMSGSIZE ;
Ditto about name (VDPA_ATTR_DEV_BLK_FLUSH) and type (flag).
Thanks,
Stefano
Quoted 33 lines
drivers/vdpa/vdpa.c +7
-0+ +return 0 ; +} +static int vdpa_dev_blk_config_fill (struct vdpa_device *vdev,struct sk_buff *msg) {@@ -1136,6 +1147,9 @@ static int vdpa_dev_blk_config_fill(struct vdpa_device *vdev,if (vdpa_dev_blk_ro_config_fill (msg, features_device))return -EMSGSIZE ; +if (vdpa_dev_blk_flush_config_fill (msg, features_device)) +return -EMSGSIZE ; +return 0 ; }include/uapi/linux/vdpa.h +1
-0@@ -71,6 +71,7 @@ enum vdpa_attr {VDPA_ATTR_DEV_BLK_CFG_MAX_WRITE_ZEROES_SEC ,/* u32 */ VDPA_ATTR_DEV_BLK_CFG_MAX_WRITE_ZEROES_SEG ,/* u32 */ VDPA_ATTR_DEV_BLK_CFG_READ_ONLY ,/* u8 */ +VDPA_ATTR_DEV_BLK_CFG_FLUSH ,/* u8 */ /* new attributes must be added above here */ VDPA_ATTR_MAX,Signature · 1 line
2.39.3
Re: [PATCH 01/10] vDPA: report virtio-block capacity to user space
In reply to Zhu LingshanQuoted 9 lines · Zhu Lingshan
This commit allows userspace to query capacity of
a virtio-block device.Signed-off-by Zhu Lingshan <[email protected]>---
drivers/vdpa/vdpa.c | 35 +++++++++++++++++++++++++++++++++++ include/linux/vdpa.h | 1 + include/uapi/linux/vdpa.h | 2 ++ 3 files changed, 38 insertions(+)
Quoted 83 lines
drivers/vdpa/vdpa.c +32
-0@@ -944,6 +944,38 @@ static int vdpa_dev_net_config_fill(struct vdpa_device *vdev, struct sk_buff *msreturn vdpa_dev_net_mq_config_fill (msg, features_device, &config); } +static int +vdpa_dev_blk_capacity_config_fill (struct sk_buff *msg, +const struct virtio_blk_config *config) +{ +u64 val_u64; + + val_u64 =__virtio64_to_cpu (true, config->capacity); + +return nla_put_u64_64bit (msg,VDPA_ATTR_DEV_BLK_CFG_CAPACITY , + val_u64,VDPA_ATTR_PAD ); +} + +static int vdpa_dev_blk_config_fill (struct vdpa_device *vdev, +struct sk_buff *msg) +{ +struct virtio_blk_config config = {}; +u64 features_device; + + vdev->config->get_config (vdev,0 , &config,sizeof (config)); + + features_device = vdev->config->get_device_features (vdev); + +if (nla_put_u64_64bit (msg,VDPA_ATTR_DEV_FEATURES , features_device, +VDPA_ATTR_PAD )) +return -EMSGSIZE ; + +if (vdpa_dev_blk_capacity_config_fill (msg, &config)) +return -EMSGSIZE ; + +return 0 ; +} +static int
vdpa_dev_config_fill(structvdpa_device*vdev, structsk_buff*msg, u32 portid, u32 seq,
int flags, structnetlink_ext_ack*extack)drivers/vdpa/vdpa.c +3
-0@@ -988,6 +1020,9 @@ vdpa_dev_config_fill(struct vdpa_device *vdev, struct sk_buff *msg, u32 portid,case VIRTIO_ID_NET : err =vdpa_dev_net_config_fill (vdev, msg);break ; +case VIRTIO_ID_BLOCK : + err =vdpa_dev_blk_config_fill (vdev, msg); +break ;default : err = -EOPNOTSUPP ;break ;include/linux/vdpa.h +1
-0@@ -7,6 +7,7 @@#include <linux/interrupt.h> #include <linux/vhost_iotlb.h> #include <linux/virtio_net.h> +#include <linux/virtio_blk.h> #include <linux/if_ether.h> /** include/uapi/linux/vdpa.h +2
-0@@ -56,6 +56,8 @@ enum vdpa_attr {/* virtio features that are provisioned to the vDPA device */ VDPA_ATTR_DEV_FEATURES ,/* u64 */ +VDPA_ATTR_DEV_BLK_CFG_CAPACITY ,/* u64 */ +/* new attributes must be added above here */ VDPA_ATTR_MAX, };Signature · 1 line
2.39.3
Re: [PATCH 03/10] vDPA: report virtio-block block-size to user space
In reply to Zhu LingshanQuoted 8 lines · Zhu Lingshan
This commit allows reporting the block size of a
virtio-block device to user space.Signed-off-by Zhu Lingshan <[email protected]>---
drivers/vdpa/vdpa.c| 18 ++++++++++++++++++include/uapi/linux/vdpa.h| 1 +2 files changed, 19 insertions(+)
Quoted 53 lines
drivers/vdpa/vdpa.c +18
-0@@ -970,6 +970,21 @@ vdpa_dev_blk_seg_size_config_fill(struct sk_buff *msg, u64 features,return nla_put_u32 (msg,VDPA_ATTR_DEV_BLK_CFG_SEG_SIZE , val_u32); } +/* fill the block size*/ +static int +vdpa_dev_blk_block_size_config_fill (struct sk_buff *msg,u64 features, +const struct virtio_blk_config *config) +{ +u32 val_u32; + +if ((features &BIT_ULL (VIRTIO_BLK_F_BLK_SIZE )) ==0 ) +return 0 ; + + val_u32 =__virtio32_to_cpu (true, config->blk_size); + +return nla_put_u32 (msg,VDPA_ATTR_DEV_BLK_CFG_BLK_SIZE , val_u32); +} +static int vdpa_dev_blk_config_fill (struct vdpa_device *vdev,struct sk_buff *msg) {@@ -990,6 +1005,9 @@ static int vdpa_dev_blk_config_fill(struct vdpa_device *vdev,if (vdpa_dev_blk_seg_size_config_fill (msg, features_device, &config))return -EMSGSIZE ; +if (vdpa_dev_blk_block_size_config_fill (msg, features_device, &config)) +return -EMSGSIZE ; +return 0 ; }include/uapi/linux/vdpa.h +1
-0@@ -58,6 +58,7 @@ enum vdpa_attr {VDPA_ATTR_DEV_BLK_CFG_CAPACITY ,/* u64 */ VDPA_ATTR_DEV_BLK_CFG_SEG_SIZE ,/* u32 */ +VDPA_ATTR_DEV_BLK_CFG_BLK_SIZE ,/* u32 */ /* new attributes must be added above here */ VDPA_ATTR_MAX,Signature · 1 line
2.39.3
Re: [PATCH 04/10] vDPA: report virtio-block max segments in a request to user space
In reply to Zhu LingshanQuoted 9 lines · Zhu Lingshan
This commit allows vDPA reporting the maximum number of segments in a request of virtio-block devices to user space.
Signed-off-by Zhu Lingshan <[email protected]>---
drivers/vdpa/vdpa.c| 17 +++++++++++++++++include/uapi/linux/vdpa.h| 1 +2 files changed, 18 insertions(+)
Quoted 52 lines
drivers/vdpa/vdpa.c +17
-0@@ -985,6 +985,20 @@ vdpa_dev_blk_block_size_config_fill(struct sk_buff *msg, u64 features,return nla_put_u32 (msg,VDPA_ATTR_DEV_BLK_CFG_BLK_SIZE , val_u32); } +static int +vdpa_dev_blk_seg_max_config_fill (struct sk_buff *msg,u64 features, +const struct virtio_blk_config *config) +{ +u32 val_u32; + +if ((features &BIT_ULL (VIRTIO_BLK_F_SEG_MAX )) ==0 ) +return 0 ; + + val_u32 =__virtio32_to_cpu (true, config->seg_max); + +return nla_put_u32 (msg,VDPA_ATTR_DEV_BLK_CFG_SEG_MAX , val_u32); +} +static int vdpa_dev_blk_config_fill (struct vdpa_device *vdev,struct sk_buff *msg) {@@ -1008,6 +1022,9 @@ static int vdpa_dev_blk_config_fill(struct vdpa_device *vdev,if (vdpa_dev_blk_block_size_config_fill (msg, features_device, &config))return -EMSGSIZE ; +if (vdpa_dev_blk_seg_max_config_fill (msg, features_device, &config)) +return -EMSGSIZE ; +return 0 ; }include/uapi/linux/vdpa.h +1
-0@@ -59,6 +59,7 @@ enum vdpa_attr {VDPA_ATTR_DEV_BLK_CFG_CAPACITY ,/* u64 */ VDPA_ATTR_DEV_BLK_CFG_SEG_SIZE ,/* u32 */ VDPA_ATTR_DEV_BLK_CFG_BLK_SIZE ,/* u32 */ +VDPA_ATTR_DEV_BLK_CFG_SEG_MAX ,/* u32 */ /* new attributes must be added above here */ VDPA_ATTR_MAX,Signature · 1 line
2.39.3
Re: [PATCH 05/10] vDPA: report virtio-block MQ info to user space
In reply to Zhu LingshanQuoted 8 lines · Zhu Lingshan
This commits allows vDPA reporting virtio-block multi-queue configuration to user sapce.
Signed-off-by Zhu Lingshan <[email protected]>---
drivers/vdpa/vdpa.c| 16 ++++++++++++++++include/uapi/linux/vdpa.h| 1 +2 files changed, 17 insertions(+)
Quoted 51 lines
drivers/vdpa/vdpa.c +16
-0@@ -999,6 +999,19 @@ vdpa_dev_blk_seg_max_config_fill(struct sk_buff *msg, u64 features,return nla_put_u32 (msg,VDPA_ATTR_DEV_BLK_CFG_SEG_MAX , val_u32); } +static int vdpa_dev_blk_mq_config_fill (struct sk_buff *msg,u64 features, +const struct virtio_blk_config *config) +{ +u16 val_u16; + +if ((features &BIT_ULL (VIRTIO_BLK_F_MQ )) ==0 ) +return 0 ; + + val_u16 =__virtio16_to_cpu (true, config->num_queues); + +return nla_put_u16 (msg,VDPA_ATTR_DEV_BLK_CFG_NUM_QUEUES , val_u16); +} +static int vdpa_dev_blk_config_fill (struct vdpa_device *vdev,struct sk_buff *msg) {@@ -1025,6 +1038,9 @@ static int vdpa_dev_blk_config_fill(struct vdpa_device *vdev,if (vdpa_dev_blk_seg_max_config_fill (msg, features_device, &config))return -EMSGSIZE ; +if (vdpa_dev_blk_mq_config_fill (msg, features_device, &config)) +return -EMSGSIZE ; +return 0 ; }include/uapi/linux/vdpa.h +1
-0@@ -60,6 +60,7 @@ enum vdpa_attr {VDPA_ATTR_DEV_BLK_CFG_SEG_SIZE ,/* u32 */ VDPA_ATTR_DEV_BLK_CFG_BLK_SIZE ,/* u32 */ VDPA_ATTR_DEV_BLK_CFG_SEG_MAX ,/* u32 */ +VDPA_ATTR_DEV_BLK_CFG_NUM_QUEUES ,/* u16 */ /* new attributes must be added above here */ VDPA_ATTR_MAX,Signature · 1 line
2.39.3
Re: [PATCH 06/10] vDPA: report virtio-block topology info to user space
In reply to Zhu LingshanQuoted 7 lines · Zhu Lingshan
This commit allows vDPA reporting topology information of virtio-blk devices to user space, includes:
1) the number of logical blocks per physical block
2) offset of first aligned logical block
3) suggested minimum I/O size in blocks
4) optimal (suggested maximum) I/O size in blocks
Quoted 5 lines
Signed-off-by Zhu Lingshan <[email protected]>---
drivers/vdpa/vdpa.c| 32 ++++++++++++++++++++++++++++++++include/uapi/linux/vdpa.h| 4 ++++2 files changed, 36 insertions(+)
Quoted 70 lines
drivers/vdpa/vdpa.c +32
-0@@ -1012,6 +1012,35 @@ static int vdpa_dev_blk_mq_config_fill(struct sk_buff *msg, u64 features,return nla_put_u16 (msg,VDPA_ATTR_DEV_BLK_CFG_NUM_QUEUES , val_u16); } +static int vdpa_dev_blk_topology_config_fill (struct sk_buff *msg,u64 features, +const struct virtio_blk_config *config) +{ +u16 min_io_size; +u32 opt_io_size; + +if ((features &BIT_ULL (VIRTIO_BLK_F_TOPOLOGY )) ==0 ) +return 0 ; + + min_io_size =__virtio16_to_cpu (true, config->min_io_size); + opt_io_size =__virtio32_to_cpu (true, config->opt_io_size); + +if (nla_put_u8 (msg,VDPA_ATTR_DEV_BLK_CFG_PHY_BLK_EXP , + config->physical_block_exp)) +return -EMSGSIZE ; + +if (nla_put_u8 (msg,VDPA_ATTR_DEV_BLK_CFG_ALIGN_OFFSET , + config->alignment_offset)) +return -EMSGSIZE ; + +if (nla_put_u16 (msg,VDPA_ATTR_DEV_BLK_CFG_MIN_IO_SIZE , min_io_size)) +return -EMSGSIZE ; + +if (nla_put_u32 (msg,VDPA_ATTR_DEV_BLK_CFG_OPT_IO_SIZE , opt_io_size)) +return -EMSGSIZE ; + +return 0 ; +} +static int vdpa_dev_blk_config_fill (struct vdpa_device *vdev,struct sk_buff *msg) {@@ -1041,6 +1070,9 @@ static int vdpa_dev_blk_config_fill(struct vdpa_device *vdev,if (vdpa_dev_blk_mq_config_fill (msg, features_device, &config))return -EMSGSIZE ; +if (vdpa_dev_blk_topology_config_fill (msg, features_device, &config)) +return -EMSGSIZE ; +return 0 ; }include/uapi/linux/vdpa.h +4
-0@@ -61,6 +61,10 @@ enum vdpa_attr {VDPA_ATTR_DEV_BLK_CFG_BLK_SIZE ,/* u32 */ VDPA_ATTR_DEV_BLK_CFG_SEG_MAX ,/* u32 */ VDPA_ATTR_DEV_BLK_CFG_NUM_QUEUES ,/* u16 */ +VDPA_ATTR_DEV_BLK_CFG_PHY_BLK_EXP ,/* u8 */ +VDPA_ATTR_DEV_BLK_CFG_ALIGN_OFFSET ,/* u8 */ +VDPA_ATTR_DEV_BLK_CFG_MIN_IO_SIZE ,/* u16 */ +VDPA_ATTR_DEV_BLK_CFG_OPT_IO_SIZE ,/* u32 */ /* new attributes must be added above here */ VDPA_ATTR_MAX,Signature · 1 line
2.39.3
Re: [PATCH 07/10] vDPA: report virtio-block discarding configuration to user space
In reply to Zhu LingshanQuoted 11 lines · Zhu Lingshan
This commit reports virtio-blk discarding configuration to user space,includes:
1) the maximum discard sectors
2) maximum number of discard segments for the block driver to use
3) the alignment for splitting a discarding requestSigned-off-by Zhu Lingshan <[email protected]>---
drivers/vdpa/vdpa.c| 26 ++++++++++++++++++++++++++include/uapi/linux/vdpa.h| 3 +++2 files changed, 29 insertions(+)
Quoted 63 lines
drivers/vdpa/vdpa.c +26
-0@@ -1041,6 +1041,29 @@ static int vdpa_dev_blk_topology_config_fill(struct sk_buff *msg, u64 features,return 0 ; } +static int vdpa_dev_blk_discard_config_fill (struct sk_buff *msg,u64 features, +const struct virtio_blk_config *config) +{ +u32 val_u32; + +if ((features &BIT_ULL (VIRTIO_BLK_F_DISCARD )) ==0 ) +return 0 ; + + val_u32 =__virtio32_to_cpu (true, config->max_discard_sectors); +if (nla_put_u32 (msg,VDPA_ATTR_DEV_BLK_CFG_MAX_DISCARD_SEC , val_u32)) +return -EMSGSIZE ; + + val_u32 =__virtio32_to_cpu (true, config->max_discard_seg); +if (nla_put_u32 (msg,VDPA_ATTR_DEV_BLK_CFG_MAX_DISCARD_SEG , val_u32)) +return -EMSGSIZE ; + + val_u32 =__virtio32_to_cpu (true, config->discard_sector_alignment); +if (nla_put_u32 (msg,VDPA_ATTR_DEV_BLK_CFG_DISCARD_SEC_ALIGN , val_u32)) +return -EMSGSIZE ; + +return 0 ; +} +static int vdpa_dev_blk_config_fill (struct vdpa_device *vdev,struct sk_buff *msg) {@@ -1073,6 +1096,9 @@ static int vdpa_dev_blk_config_fill(struct vdpa_device *vdev,if (vdpa_dev_blk_topology_config_fill (msg, features_device, &config))return -EMSGSIZE ; +if (vdpa_dev_blk_discard_config_fill (msg, features_device, &config)) +return -EMSGSIZE ; +return 0 ; }include/uapi/linux/vdpa.h +3
-0@@ -65,6 +65,9 @@ enum vdpa_attr {VDPA_ATTR_DEV_BLK_CFG_ALIGN_OFFSET ,/* u8 */ VDPA_ATTR_DEV_BLK_CFG_MIN_IO_SIZE ,/* u16 */ VDPA_ATTR_DEV_BLK_CFG_OPT_IO_SIZE ,/* u32 */ +VDPA_ATTR_DEV_BLK_CFG_MAX_DISCARD_SEC ,/* u32 */ +VDPA_ATTR_DEV_BLK_CFG_MAX_DISCARD_SEG ,/* u32 */ +VDPA_ATTR_DEV_BLK_CFG_DISCARD_SEC_ALIGN ,/* u32 */ /* new attributes must be added above here */ VDPA_ATTR_MAX,Signature · 1 line
2.39.3
Quoted 28 lines · Zhu Lingshan
This series allows the user space applications query vDPA virtio-block device inforamtion.
testing on
vdpa_sim_blk, iproute2 output:
sudo ./vdpa/vdpa dev config show -jpvdpa_blk0
{
"config": {
"vdpa_blk0": {
"capacity": 262144,
"segment size": 4096,
"block size": 512,
"max segments in a request": 32,
"num of queues": 1,
"logical blocks per physical block (log2)": 0, "offset of first aligned logical block": 0, "minimum io size": 1,
"optimal io size": 1,
"maximum discard sectors for a segment": 4294967295, "max discard segments in a command": 1, "discard sector alignment": 512,
"max write zeros sectors in a segment": 4294967295, "max write zero segments": 1,
"read only": false,
"flush command support": true
}
}
}
Quoted 1 line
Please help review
Thanks for this series, and sorry for the deleay.
I left some comments in the patch, about the virtio-blk config space there are some missing fields:
- virtio_blk_geometry fields
- writeback field
- *secure_erase* fields
- virtio_blk_zoned_characteristics fields
Do you plan to add them later?
Thanks,
Stefano
Michael S. Tsirkin
maintainerRe: [PATCH 08/10] vDPA: report virtio-block write zeroes configuration to user space
In reply to Stefano GarzarellaQuoted 30 lines · Stefano Garzarella
Quoted 29 lines · Zhu Lingshan
This commits reports write zeroes configuration of virtio-block devices to user space, includes:
1)maximum write zeroes sectors size 2)maximum write zeroes segment numberSigned-off-by Zhu Lingshan <[email protected]>---
drivers/vdpa/vdpa.c| 23 +++++++++++++++++++++++include/uapi/linux/vdpa.h| 2 ++2 files changed, 25 insertions(+)drivers/vdpa/vdpa.c +10
-0@@ -1064,6 +1064,26 @@ static int vdpa_dev_blk_discard_config_fill(struct sk_buff *msg, u64 features,return 0 ; } +static int +vdpa_dev_blk_write_zeroes_config_fill (struct sk_buff *msg,u64 features, +const struct virtio_blk_config *config) +{ +u32 val_u32; + +if ((features &BIT_ULL (VIRTIO_BLK_F_WRITE_ZEROES )) ==0 ) +return 0 ; + + val_u32 =__virtio32_to_cpu (true, config->max_write_zeroes_sectors);
Quoted 8 lines
drivers/vdpa/vdpa.c static int vdpa_dev_blk_discard_config_fill(struct sk_buff *msg, u64 features, · line 1082
Quoted 6 lines
drivers/vdpa/vdpa.c +6
-0+if (nla_put_u32 (msg,VDPA_ATTR_DEV_BLK_CFG_MAX_WRITE_ZEROES_SEC , val_u32)) +return -EMSGSIZE ; + + val_u32 =__virtio32_to_cpu (true, config->max_write_zeroes_seg); +if (nla_put_u32 (msg,VDPA_ATTR_DEV_BLK_CFG_MAX_WRITE_ZEROES_SEG , val_u32)) +return -EMSGSIZE ;Should we cover also
config->write_zeroes_may_unmap?
This review came too late I applied the patch. Generally if I don't see any response in about
a week I assume there is not interest.
Quoted 34 lines
Quoted 34 lines
drivers/vdpa/vdpa.c +7
-0+ +return 0 ; +} +static int vdpa_dev_blk_config_fill (struct vdpa_device *vdev,struct sk_buff *msg) {@@ -1099,6 +1119,9 @@ static int vdpa_dev_blk_config_fill(struct vdpa_device *vdev,if (vdpa_dev_blk_discard_config_fill (msg, features_device, &config))return -EMSGSIZE ; +if (vdpa_dev_blk_write_zeroes_config_fill (msg, features_device, &config)) +return -EMSGSIZE ; +return 0 ; }include/uapi/linux/vdpa.h +2
-0@@ -68,6 +68,8 @@ enum vdpa_attr {VDPA_ATTR_DEV_BLK_CFG_MAX_DISCARD_SEC ,/* u32 */ VDPA_ATTR_DEV_BLK_CFG_MAX_DISCARD_SEG ,/* u32 */ VDPA_ATTR_DEV_BLK_CFG_DISCARD_SEC_ALIGN ,/* u32 */ +VDPA_ATTR_DEV_BLK_CFG_MAX_WRITE_ZEROES_SEC ,/* u32 */ +VDPA_ATTR_DEV_BLK_CFG_MAX_WRITE_ZEROES_SEG ,/* u32 */ /* new attributes must be added above here */ VDPA_ATTR_MAX,Signature · 1 line
2.39.3
Re: [PATCH 08/10] vDPA: report virtio-block write zeroes configuration to user space
Quoted 41 lines · Michael S. Tsirkin
Quoted 30 lines · Stefano Garzarella
Quoted 29 lines · Zhu Lingshan
This commits reports write zeroes configuration of virtio-block devices to user space, includes:
1)maximum write zeroes sectors size 2)maximum write zeroes segment numberSigned-off-by Zhu Lingshan <[email protected]>---
drivers/vdpa/vdpa.c| 23 +++++++++++++++++++++++include/uapi/linux/vdpa.h| 2 ++2 files changed, 25 insertions(+)drivers/vdpa/vdpa.c +10
-0@@ -1064,6 +1064,26 @@ static int vdpa_dev_blk_discard_config_fill(struct sk_buff *msg, u64 features,return 0 ; } +static int +vdpa_dev_blk_write_zeroes_config_fill (struct sk_buff *msg,u64 features, +const struct virtio_blk_config *config) +{ +u32 val_u32; + +if ((features &BIT_ULL (VIRTIO_BLK_F_WRITE_ZEROES )) ==0 ) +return 0 ; + + val_u32 =__virtio32_to_cpu (true, config->max_write_zeroes_sectors);Quoted 8 lines
drivers/vdpa/vdpa.c static int vdpa_dev_blk_discard_config_fill(struct sk_buff *msg, u64 features, · line 1082
Quoted 6 lines
drivers/vdpa/vdpa.c +6
-0+if (nla_put_u32 (msg,VDPA_ATTR_DEV_BLK_CFG_MAX_WRITE_ZEROES_SEC , val_u32)) +return -EMSGSIZE ; + + val_u32 =__virtio32_to_cpu (true, config->max_write_zeroes_seg); +if (nla_put_u32 (msg,VDPA_ATTR_DEV_BLK_CFG_MAX_WRITE_ZEROES_SEG , val_u32)) +return -EMSGSIZE ;Should we cover also
config->write_zeroes_may_unmap?
Quoted 3 lines
This review came too late I applied the patch. Generally if I don't see any response in about
a week I assume there is not interest.
Ooops, sorry about that! I should add me as a reviewer for vDPA otherwise lately it's hard for me to monitor patches :-(
BTW, some comments can be resolved with later patches if you think it makes sense to resolve them.
Thanks,
Stefano
Michael S. Tsirkin
maintainerRe: [PATCH 08/10] vDPA: report virtio-block write zeroes configuration to user space
Quoted 46 lines · Stefano Garzarella
Quoted 41 lines · Michael S. Tsirkin
Quoted 30 lines · Stefano Garzarella
Quoted 29 lines · Zhu Lingshan
This commits reports write zeroes configuration of virtio-block devices to user space, includes:
1)maximum write zeroes sectors size 2)maximum write zeroes segment numberSigned-off-by Zhu Lingshan <[email protected]>---
drivers/vdpa/vdpa.c| 23 +++++++++++++++++++++++include/uapi/linux/vdpa.h| 2 ++2 files changed, 25 insertions(+)drivers/vdpa/vdpa.c +10
-0@@ -1064,6 +1064,26 @@ static int vdpa_dev_blk_discard_config_fill(struct sk_buff *msg, u64 features,return 0 ; } +static int +vdpa_dev_blk_write_zeroes_config_fill (struct sk_buff *msg,u64 features, +const struct virtio_blk_config *config) +{ +u32 val_u32; + +if ((features &BIT_ULL (VIRTIO_BLK_F_WRITE_ZEROES )) ==0 ) +return 0 ; + + val_u32 =__virtio32_to_cpu (true, config->max_write_zeroes_sectors);Quoted 8 lines
drivers/vdpa/vdpa.c static int vdpa_dev_blk_discard_config_fill(struct sk_buff *msg, u64 features, · line 1082
Quoted 6 lines
drivers/vdpa/vdpa.c +6
-0+if (nla_put_u32 (msg,VDPA_ATTR_DEV_BLK_CFG_MAX_WRITE_ZEROES_SEC , val_u32)) +return -EMSGSIZE ; + + val_u32 =__virtio32_to_cpu (true, config->max_write_zeroes_seg); +if (nla_put_u32 (msg,VDPA_ATTR_DEV_BLK_CFG_MAX_WRITE_ZEROES_SEG , val_u32)) +return -EMSGSIZE ;Should we cover also
config->write_zeroes_may_unmap?Quoted 3 lines
This review came too late I applied the patch. Generally if I don't see any response in about
a week I assume there is not interest.
Quoted 8 lines
Ooops, sorry about that! I should add me as a reviewer for vDPA otherwise lately it's hard for me to monitor patches :-(
BTW, some comments can be resolved with later patches if you think it makes sense to resolve them.
Thanks,
Stefano
Sure. Once the pressure to merge the patch is gone not everyone will bother though, it might be easier for you to send the patch on top.
Signature · 1 line
MST
Quoted 30 lines · Michael S. Tsirkin
Quoted 28 lines · Zhu Lingshan
This series allows the user space applications query vDPA virtio-block device inforamtion.
testing on
vdpa_sim_blk, iproute2 output:
sudo ./vdpa/vdpa dev config show -jpvdpa_blk0
{
"config": {
"vdpa_blk0": {
"capacity": 262144,
"segment size": 4096,
"block size": 512,
"max segments in a request": 32,
"num of queues": 1,
"logical blocks per physical block (log2)": 0, "offset of first aligned logical block": 0, "minimum io size": 1,
"optimal io size": 1,
"maximum discard sectors for a segment": 4294967295, "max discard segments in a command": 1, "discard sector alignment": 512,
"max write zeros sectors in a segment": 4294967295, "max write zero segments": 1,
"read only": false,
"flush command support": true
}
}
}
Quoted 8 lines
Quoted 4 lines
Please help review
Thanks
Zhu LingshanIt's been in my tree for a while so it will be in the next pull, but going forward Jason I'd like to know what kind of timeline do you have in mind for reviewing vdpa patches?
I think there are some misunderstandings here.
I usually try my best to offer a review.
This series was posted during my vacation, and when I came back after the vacation it was merged into your tree. I'd expect you are fine with the patches.
If that doesn't work, maybe we can start to do something like:
vDPA patches needs my ack before it can be merged
Does it work?
Thanks
Quoted 21 lines
Quoted 20 lines
Zhu Lingshan (10):
vDPA: report virtio-block capacity to user space
vDPA: report virtio-block max segment size to user space
vDPA: report virtio-block block-size to user space
vDPA: report virtio-block max segments in a request to user space
vDPA: report virtio-block MQ info to user space
vDPA: report virtio-block topology info to user space
vDPA: report virtio-block discarding configuration to user space
vDPA: report virtio-block write zeroes configuration to user space
vDPA: report virtio-block read-only info to user space
vDPA: report virtio-blk flush info to user spacedrivers/vdpa/vdpa.c | 212 ++++++++++++++++++++++++++++++++++++++ include/linux/vdpa.h | 1 + include/uapi/linux/vdpa.h | 17 +++ 3 files changed, 230 insertions(+)--
2.39.3
Michael S. Tsirkin
maintainerQuoted 40 lines · Jason Wang
Quoted 30 lines · Michael S. Tsirkin
Quoted 28 lines · Zhu Lingshan
This series allows the user space applications query vDPA virtio-block device inforamtion.
testing on
vdpa_sim_blk, iproute2 output:
sudo ./vdpa/vdpa dev config show -jpvdpa_blk0
{
"config": {
"vdpa_blk0": {
"capacity": 262144,
"segment size": 4096,
"block size": 512,
"max segments in a request": 32,
"num of queues": 1,
"logical blocks per physical block (log2)": 0, "offset of first aligned logical block": 0, "minimum io size": 1,
"optimal io size": 1,
"maximum discard sectors for a segment": 4294967295, "max discard segments in a command": 1, "discard sector alignment": 512,
"max write zeros sectors in a segment": 4294967295, "max write zero segments": 1,
"read only": false,
"flush command support": true
}
}
}Quoted 8 lines
Quoted 4 lines
Please help review
Thanks
Zhu LingshanIt's been in my tree for a while so it will be in the next pull, but going forward Jason I'd like to know what kind of timeline do you have in mind for reviewing vdpa patches?
Quoted 7 lines
I think there are some misunderstandings here.
I usually try my best to offer a review.
This series was posted during my vacation, and when I came back after the vacation it was merged into your tree. I'd expect you are fine with the patches.
Yes.
Quoted 7 lines
If that doesn't work, maybe we can start to do something like:
vDPA patches needs my ack before it can be merged
Does it work?
Thanks
We have redundancy in review, it's not a problem by itself. If you are going on an extended vacation, it's a good idea to make this fact public so people know whether to expect your review.
Quoted 21 lines
Quoted 21 lines
Quoted 20 lines
Zhu Lingshan (10):
vDPA: report virtio-block capacity to user space
vDPA: report virtio-block max segment size to user space
vDPA: report virtio-block block-size to user space
vDPA: report virtio-block max segments in a request to user space
vDPA: report virtio-block MQ info to user space
vDPA: report virtio-block topology info to user space
vDPA: report virtio-block discarding configuration to user space
vDPA: report virtio-block write zeroes configuration to user space
vDPA: report virtio-block read-only info to user space
vDPA: report virtio-blk flush info to user spacedrivers/vdpa/vdpa.c | 212 ++++++++++++++++++++++++++++++++++++++ include/linux/vdpa.h | 1 + include/uapi/linux/vdpa.h | 17 +++ 3 files changed, 230 insertions(+)--
2.39.3
Quoted 39 lines · Stefano Garzarella
Quoted 28 lines · Zhu Lingshan
This series allows the user space applications query vDPA virtio-block device inforamtion.
testing on
vdpa_sim_blk, iproute2 output:
sudo ./vdpa/vdpa dev config show -jpvdpa_blk0
{
"config": {
"vdpa_blk0": {
"capacity": 262144,
"segment size": 4096,
"block size": 512,
"max segments in a request": 32,
"num of queues": 1,
"logical blocks per physical block (log2)": 0, "offset of first aligned logical block": 0, "minimum io size": 1,
"optimal io size": 1,
"maximum discard sectors for a segment": 4294967295, "max discard segments in a command": 1, "discard sector alignment": 512,
"max write zeros sectors in a segment": 4294967295, "max write zero segments": 1,
"read only": false,
"flush command support": true
}
}
}Quoted 1 line
Please help review
Thanks for this series, and sorry for the deleay.
I left some comments in the patch, about the virtio-blk config space there are some missing fields:
-virtio_blk_geometryfields
- writeback field
- *secure_erase* fields
-virtio_blk_zoned_characteristicsfields
Quoted 1 line
Do you plan to add them later?
Yes, I will work on them and will send another series which also addressing your comments for this series
Thanks
Zhu Lingshan
Quoted 5 lines
Thanks,
Stefano
Quoted 42 lines · Lingshan
Quoted 39 lines · Stefano Garzarella
Quoted 28 lines · Zhu Lingshan
This series allows the user space applications query vDPA virtio-block device inforamtion.
testing on
vdpa_sim_blk, iproute2 output:
sudo ./vdpa/vdpa dev config show -jpvdpa_blk0
{
"config": {
"vdpa_blk0": {
"capacity": 262144,
"segment size": 4096,
"block size": 512,
"max segments in a request": 32,
"num of queues": 1,
"logical blocks per physical block (log2)": 0, "offset of first aligned logical block": 0, "minimum io size": 1,
"optimal io size": 1,
"maximum discard sectors for a segment": 4294967295, "max discard segments in a command": 1, "discard sector alignment": 512,
"max write zeros sectors in a segment": 4294967295, "max write zero segments": 1,
"read only": false,
"flush command support": true
}
}
}Quoted 1 line
Please help review
Thanks for this series, and sorry for the deleay.
I left some comments in the patch, about the virtio-blk config space there are some missing fields:
-virtio_blk_geometryfields
- writeback field
- *secure_erase* fields
-virtio_blk_zoned_characteristicsfields
Quoted 3 lines
Quoted 1 line
Do you plan to add them later?
Yes, I will work on them and will send another series which also addressing your comments for this series
Great, thanks for that!
Please put me in CC in the next series.
Stefano
Re: [PATCH 02/10] vDPA: report virtio-block max segment size to user space
In reply to Stefano GarzarellaQuoted 19 lines · Stefano Garzarella
Quoted 18 lines · Zhu Lingshan
This commit allows reporting the max size of any single segment of virtio-block devices to user space.
Signed-off-by Zhu Lingshan <[email protected]>---
drivers/vdpa/vdpa.c | 17 +++++++++++++++++include/uapi/linux/vdpa.h| 1 +2 files changed, 18 insertions(+)drivers/vdpa/vdpa.c +0
-0@@ -956,6 +956,20 @@ vdpa_dev_blk_capacity_config_fill(struct sk_buff *msg, val_u64, VDPA_ATTR_PAD); }
Quoted 14 lines
drivers/vdpa/vdpa.c vdpa_dev_blk_capacity_config_fill(struct sk_buff *msg, · line 970
Quoted 12 lines
drivers/vdpa/vdpa.c +12
-0+static int +vdpa_dev_blk_seg_size_config_fill (struct sk_buff *msg,u64 features, + const struct virtio_blk_config *config) +{ + u32 val_u32; + + if ((features & BIT_ULL(VIRTIO_BLK_F_SIZE_MAX)) == 0) + return 0; + + val_u32 = __virtio32_to_cpu(true, config->size_max); + + return nla_put_u32(msg, VDPA_ATTR_DEV_BLK_CFG_SEG_SIZE, val_u32);Should we call this
VDPA_ATTR_DEV_BLK_CFG_SIZE_MAX?
I have tried this before, but this macro is too long causing a odd format in the header file.
I can change this since you point this out. This is uapi means we should merge the fix during the RC release before 6.9 official.
@MST, does the process work for you?
Quoted 36 lines
Quoted 34 lines
drivers/vdpa/vdpa.c +2
-0+} +static int vdpa_dev_blk_config_fill (struct vdpa_device *vdev, struct sk_buff *msg){
drivers/vdpa/vdpa.c +3
-0@@ -973,6 +987,9 @@ static int vdpa_dev_blk_config_fill(structvdpa_device *vdev, if (vdpa_dev_blk_capacity_config_fill(msg, &config)) return -EMSGSIZE; + if (vdpa_dev_blk_seg_size_config_fill(msg, features_device, &config)) + return -EMSGSIZE; + return 0;}
include/uapi/linux/vdpa.h +0
-0@@ -57,6 +57,7 @@ enum vdpa_attr {VDPA_ATTR_DEV_FEATURES, /* u64 */
VDPA_ATTR_DEV_BLK_CFG_CAPACITY, /* u64 */ + VDPA_ATTR_DEV_BLK_CFG_SEG_SIZE, /* u32 */
/* new attributes must be added above here */
VDPA_ATTR_MAX,Signature · 1 line
2.39.3
Michael S. Tsirkin
maintainerRe: [PATCH 02/10] vDPA: report virtio-block max segment size to user space
Quoted 36 lines · Lingshan
Quoted 19 lines · Stefano Garzarella
Quoted 18 lines · Zhu Lingshan
This commit allows reporting the max size of any single segment of virtio-block devices to user space.
Signed-off-by Zhu Lingshan <[email protected]>---
drivers/vdpa/vdpa.c | 17 +++++++++++++++++include/uapi/linux/vdpa.h| 1 +2 files changed, 18 insertions(+)drivers/vdpa/vdpa.c +0
-0@@ -956,6 +956,20 @@ vdpa_dev_blk_capacity_config_fill(structsk_buff *msg, val_u64, VDPA_ATTR_PAD); }Quoted 14 lines
drivers/vdpa/vdpa.c vdpa_dev_blk_capacity_config_fill(struct sk_buff *msg, · line 970
Quoted 12 lines
drivers/vdpa/vdpa.c +12
-0+static int +vdpa_dev_blk_seg_size_config_fill (struct sk_buff *msg,u64 features, + const struct virtio_blk_config *config) +{ + u32 val_u32; + + if ((features & BIT_ULL(VIRTIO_BLK_F_SIZE_MAX)) == 0) + return 0; + + val_u32 = __virtio32_to_cpu(true, config->size_max); + + return nla_put_u32(msg, VDPA_ATTR_DEV_BLK_CFG_SEG_SIZE, val_u32);Should we call this
VDPA_ATTR_DEV_BLK_CFG_SIZE_MAX?
Quoted 8 lines
I have tried this before, but this macro is too long causing a odd format in the header file.
I can change this since you point this out. This is uapi means we should merge the
fix during the RC release before 6.9 official.@MST, does the process work for you?
I'm fine applying a fixup patch. Yes it's preferable to make changed before the release.
Quoted 36 lines
Quoted 36 lines
Quoted 34 lines
drivers/vdpa/vdpa.c +2
-0+} +static int vdpa_dev_blk_config_fill (struct vdpa_device *vdev, struct sk_buff *msg){
drivers/vdpa/vdpa.c +3
-0@@ -973,6 +987,9 @@ static int vdpa_dev_blk_config_fill(structvdpa_device *vdev, if (vdpa_dev_blk_capacity_config_fill(msg, &config)) return -EMSGSIZE; + if (vdpa_dev_blk_seg_size_config_fill(msg, features_device, &config)) + return -EMSGSIZE; + return 0;}
include/uapi/linux/vdpa.h +0
-0@@ -57,6 +57,7 @@ enum vdpa_attr {VDPA_ATTR_DEV_FEATURES, /* u64 */
VDPA_ATTR_DEV_BLK_CFG_CAPACITY, /* u64 */ + VDPA_ATTR_DEV_BLK_CFG_SEG_SIZE, /* u32 */
/* new attributes must be added above here */
VDPA_ATTR_MAX,Signature · 1 line
2.39.3
Re: [PATCH 09/10] vDPA: report virtio-block read-only info to user space
In reply to Stefano GarzarellaQuoted 30 lines · Stefano Garzarella
Quoted 15 lines · Zhu Lingshan
This commit report read-only information of virtio-blk devices to user space.
Signed-off-by Zhu Lingshan <[email protected]>---
drivers/vdpa/vdpa.c | 14 ++++++++++++++include/uapi/linux/vdpa.h| 1 +2 files changed, 15 insertions(+)drivers/vdpa/vdpa.c +0
-0@@ -1084,6 +1084,17 @@ vdpa_dev_blk_write_zeroes_config_fill(struct sk_buff *msg, u64 features,drivers/vdpa/vdpa.c vdpa_dev_blk_write_zeroes_config_fill(struct · line 1094
Quoted 10 lines
drivers/vdpa/vdpa.c +6
-0return 0; } +static int vdpa_dev_blk_ro_config_fill (struct sk_buff *msg,u64 features) +{ + u8 ro; + + ro = ((features & BIT_ULL(VIRTIO_BLK_F_RO)) == 0) ? 0 : 1; + if (nla_put_u8(msg, VDPA_ATTR_DEV_BLK_CFG_READ_ONLY, ro))This is not really related to the config space, what about renaming it to
VDPA_ATTR_DEV_BLK_READ_ONLY?
Quoted 2 lines
Also the type, maybe better to use "flag" and set it through
nla_put_flag().
Hi Stefano,
I am implementing this change.
In my humble opinion, maybe using a boolean(the u8 above) is better? Because using the flag means we conditionally put a "0" into the attribution, or the attribution does not exist, this is still a bool logic but a little vague.
Thanks
Lingshan
Quoted 44 lines
Not a strong opinion on that, it just seems a little more consistent to me.
Thanks,
StefanoQuoted 35 lines
drivers/vdpa/vdpa.c +5
-0+ return -EMSGSIZE; + + return 0; +} + static int vdpa_dev_blk_config_fill(struct vdpa_device *vdev,struct
sk_buff*msg) {drivers/vdpa/vdpa.c +3
-0@@ -1122,6 +1133,9 @@ static int vdpa_dev_blk_config_fill(structvdpa_device *vdev, if (vdpa_dev_blk_write_zeroes_config_fill(msg, features_device, &config)) return -EMSGSIZE; + if (vdpa_dev_blk_ro_config_fill(msg, features_device)) + return -EMSGSIZE; + return 0; }include/uapi/linux/vdpa.h +0
-0@@ -70,6 +70,7 @@ enum vdpa_attr {VDPA_ATTR_DEV_BLK_CFG_DISCARD_SEC_ALIGN,/* u32 */ VDPA_ATTR_DEV_BLK_CFG_MAX_WRITE_ZEROES_SEC, /* u32 */ VDPA_ATTR_DEV_BLK_CFG_MAX_WRITE_ZEROES_SEG, /* u32 */ + VDPA_ATTR_DEV_BLK_CFG_READ_ONLY, /* u8 */
/* new attributes must be added above here */
VDPA_ATTR_MAX,Signature · 1 line
2.39.3
Re: [PATCH 09/10] vDPA: report virtio-block read-only info to user space
Quoted 33 lines · Lingshan
Quoted 30 lines · Stefano Garzarella
Quoted 15 lines · Zhu Lingshan
This commit report read-only information of virtio-blk devices to user space.
Signed-off-by Zhu Lingshan <[email protected]>---
drivers/vdpa/vdpa.c | 14 ++++++++++++++include/uapi/linux/vdpa.h| 1 +2 files changed, 15 insertions(+)drivers/vdpa/vdpa.c +0
-0@@ -1084,6 +1084,17 @@ vdpa_dev_blk_write_zeroes_config_fill(struct sk_buff *msg, u64 features,drivers/vdpa/vdpa.c line 1094
Quoted 10 lines
drivers/vdpa/vdpa.c +6
-0return 0; } +static int vdpa_dev_blk_ro_config_fill (struct sk_buff *msg,u64 features) +{ + u8 ro; + + ro = ((features & BIT_ULL(VIRTIO_BLK_F_RO)) == 0) ? 0 : 1; + if (nla_put_u8(msg, VDPA_ATTR_DEV_BLK_CFG_READ_ONLY, ro))This is not really related to the config space, what about renaming it to
VDPA_ATTR_DEV_BLK_READ_ONLY?
Quoted 6 lines
Quoted 2 lines
Also the type, maybe better to use "flag" and set it through
nla_put_flag().Hi Stefano,
I am implementing this change.
In my humble opinion, maybe using a boolean(the u8 above) is better?
If boolean is available, I agree that could be better. I did just a fast search when I commented.
BTW, sorry for the late reply, I was on PTO.
Stefano
Quoted 51 lines
Because using the flag means we conditionally put a "0" into the attribution, or the attribution does not exist, this is still a bool logic but a little vague.
Thanks
LingshanQuoted 44 lines
Not a strong opinion on that, it just seems a little more consistent to me.
Thanks,
StefanoQuoted 35 lines
drivers/vdpa/vdpa.c +5
-0+ return -EMSGSIZE; + + return 0; +} + static int vdpa_dev_blk_config_fill(struct vdpa_device *vdev,struct
sk_buff*msg) {drivers/vdpa/vdpa.c +3
-0@@ -1122,6 +1133,9 @@ static int vdpa_dev_blk_config_fill(structvdpa_device *vdev, if (vdpa_dev_blk_write_zeroes_config_fill(msg, features_device, &config)) return -EMSGSIZE; + if (vdpa_dev_blk_ro_config_fill(msg, features_device)) + return -EMSGSIZE; + return 0; }include/uapi/linux/vdpa.h +0
-0@@ -70,6 +70,7 @@ enum vdpa_attr {VDPA_ATTR_DEV_BLK_CFG_DISCARD_SEC_ALIGN,/* u32 */ VDPA_ATTR_DEV_BLK_CFG_MAX_WRITE_ZEROES_SEC, /* u32 */ VDPA_ATTR_DEV_BLK_CFG_MAX_WRITE_ZEROES_SEG, /* u32 */ + VDPA_ATTR_DEV_BLK_CFG_READ_ONLY, /* u8 */
/* new attributes must be added above here */
VDPA_ATTR_MAX,Signature · 1 line
2.39.3