Skip to content

Commit c9d989b

Browse files
Zhu Lingshanmstsirkin
authored andcommitted
vDPA: report virtio-block topology info to user space
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 Signed-off-by: Zhu Lingshan <lingshan.zhu@intel.com> Message-Id: <20240218185606.13509-7-lingshan.zhu@intel.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
1 parent 54fb04b commit c9d989b

2 files changed

Lines changed: 36 additions & 0 deletions

File tree

drivers/vdpa/vdpa.c

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1012,6 +1012,35 @@ static int vdpa_dev_blk_mq_config_fill(struct sk_buff *msg, u64 features,
10121012
return nla_put_u16(msg, VDPA_ATTR_DEV_BLK_CFG_NUM_QUEUES, val_u16);
10131013
}
10141014

1015+
static int vdpa_dev_blk_topology_config_fill(struct sk_buff *msg, u64 features,
1016+
const struct virtio_blk_config *config)
1017+
{
1018+
u16 min_io_size;
1019+
u32 opt_io_size;
1020+
1021+
if ((features & BIT_ULL(VIRTIO_BLK_F_TOPOLOGY)) == 0)
1022+
return 0;
1023+
1024+
min_io_size = __virtio16_to_cpu(true, config->min_io_size);
1025+
opt_io_size = __virtio32_to_cpu(true, config->opt_io_size);
1026+
1027+
if (nla_put_u8(msg, VDPA_ATTR_DEV_BLK_CFG_PHY_BLK_EXP,
1028+
config->physical_block_exp))
1029+
return -EMSGSIZE;
1030+
1031+
if (nla_put_u8(msg, VDPA_ATTR_DEV_BLK_CFG_ALIGN_OFFSET,
1032+
config->alignment_offset))
1033+
return -EMSGSIZE;
1034+
1035+
if (nla_put_u16(msg, VDPA_ATTR_DEV_BLK_CFG_MIN_IO_SIZE, min_io_size))
1036+
return -EMSGSIZE;
1037+
1038+
if (nla_put_u32(msg, VDPA_ATTR_DEV_BLK_CFG_OPT_IO_SIZE, opt_io_size))
1039+
return -EMSGSIZE;
1040+
1041+
return 0;
1042+
}
1043+
10151044
static int vdpa_dev_blk_config_fill(struct vdpa_device *vdev,
10161045
struct sk_buff *msg)
10171046
{
@@ -1041,6 +1070,9 @@ static int vdpa_dev_blk_config_fill(struct vdpa_device *vdev,
10411070
if (vdpa_dev_blk_mq_config_fill(msg, features_device, &config))
10421071
return -EMSGSIZE;
10431072

1073+
if (vdpa_dev_blk_topology_config_fill(msg, features_device, &config))
1074+
return -EMSGSIZE;
1075+
10441076
return 0;
10451077
}
10461078

include/uapi/linux/vdpa.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,10 @@ enum vdpa_attr {
6161
VDPA_ATTR_DEV_BLK_CFG_BLK_SIZE, /* u32 */
6262
VDPA_ATTR_DEV_BLK_CFG_SEG_MAX, /* u32 */
6363
VDPA_ATTR_DEV_BLK_CFG_NUM_QUEUES, /* u16 */
64+
VDPA_ATTR_DEV_BLK_CFG_PHY_BLK_EXP, /* u8 */
65+
VDPA_ATTR_DEV_BLK_CFG_ALIGN_OFFSET, /* u8 */
66+
VDPA_ATTR_DEV_BLK_CFG_MIN_IO_SIZE, /* u16 */
67+
VDPA_ATTR_DEV_BLK_CFG_OPT_IO_SIZE, /* u32 */
6468

6569
/* new attributes must be added above here */
6670
VDPA_ATTR_MAX,

0 commit comments

Comments
 (0)