Skip to content

Commit 3a1d33f

Browse files
Zhu Lingshanmstsirkin
authored andcommitted
vDPA: report virtio-block block-size to user space
This commit allows reporting the block size of a virtio-block device to user space. Signed-off-by: Zhu Lingshan <lingshan.zhu@intel.com> Message-Id: <20240218185606.13509-4-lingshan.zhu@intel.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
1 parent 330b8ae commit 3a1d33f

2 files changed

Lines changed: 19 additions & 0 deletions

File tree

drivers/vdpa/vdpa.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -970,6 +970,21 @@ vdpa_dev_blk_seg_size_config_fill(struct sk_buff *msg, u64 features,
970970
return nla_put_u32(msg, VDPA_ATTR_DEV_BLK_CFG_SEG_SIZE, val_u32);
971971
}
972972

973+
/* fill the block size*/
974+
static int
975+
vdpa_dev_blk_block_size_config_fill(struct sk_buff *msg, u64 features,
976+
const struct virtio_blk_config *config)
977+
{
978+
u32 val_u32;
979+
980+
if ((features & BIT_ULL(VIRTIO_BLK_F_BLK_SIZE)) == 0)
981+
return 0;
982+
983+
val_u32 = __virtio32_to_cpu(true, config->blk_size);
984+
985+
return nla_put_u32(msg, VDPA_ATTR_DEV_BLK_CFG_BLK_SIZE, val_u32);
986+
}
987+
973988
static int vdpa_dev_blk_config_fill(struct vdpa_device *vdev,
974989
struct sk_buff *msg)
975990
{
@@ -990,6 +1005,9 @@ static int vdpa_dev_blk_config_fill(struct vdpa_device *vdev,
9901005
if (vdpa_dev_blk_seg_size_config_fill(msg, features_device, &config))
9911006
return -EMSGSIZE;
9921007

1008+
if (vdpa_dev_blk_block_size_config_fill(msg, features_device, &config))
1009+
return -EMSGSIZE;
1010+
9931011
return 0;
9941012
}
9951013

include/uapi/linux/vdpa.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ enum vdpa_attr {
5858

5959
VDPA_ATTR_DEV_BLK_CFG_CAPACITY, /* u64 */
6060
VDPA_ATTR_DEV_BLK_CFG_SEG_SIZE, /* u32 */
61+
VDPA_ATTR_DEV_BLK_CFG_BLK_SIZE, /* u32 */
6162

6263
/* new attributes must be added above here */
6364
VDPA_ATTR_MAX,

0 commit comments

Comments
 (0)