Skip to content

Commit 330b8ae

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

2 files changed

Lines changed: 18 additions & 0 deletions

File tree

drivers/vdpa/vdpa.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -956,6 +956,20 @@ vdpa_dev_blk_capacity_config_fill(struct sk_buff *msg,
956956
val_u64, VDPA_ATTR_PAD);
957957
}
958958

959+
static int
960+
vdpa_dev_blk_seg_size_config_fill(struct sk_buff *msg, u64 features,
961+
const struct virtio_blk_config *config)
962+
{
963+
u32 val_u32;
964+
965+
if ((features & BIT_ULL(VIRTIO_BLK_F_SIZE_MAX)) == 0)
966+
return 0;
967+
968+
val_u32 = __virtio32_to_cpu(true, config->size_max);
969+
970+
return nla_put_u32(msg, VDPA_ATTR_DEV_BLK_CFG_SEG_SIZE, val_u32);
971+
}
972+
959973
static int vdpa_dev_blk_config_fill(struct vdpa_device *vdev,
960974
struct sk_buff *msg)
961975
{
@@ -973,6 +987,9 @@ static int vdpa_dev_blk_config_fill(struct vdpa_device *vdev,
973987
if (vdpa_dev_blk_capacity_config_fill(msg, &config))
974988
return -EMSGSIZE;
975989

990+
if (vdpa_dev_blk_seg_size_config_fill(msg, features_device, &config))
991+
return -EMSGSIZE;
992+
976993
return 0;
977994
}
978995

include/uapi/linux/vdpa.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ enum vdpa_attr {
5757
VDPA_ATTR_DEV_FEATURES, /* u64 */
5858

5959
VDPA_ATTR_DEV_BLK_CFG_CAPACITY, /* u64 */
60+
VDPA_ATTR_DEV_BLK_CFG_SEG_SIZE, /* u32 */
6061

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

0 commit comments

Comments
 (0)