Skip to content

Commit 81f64e1

Browse files
Zhu Lingshanmstsirkin
authored andcommitted
vDPA: report virtio-block max segments in a request to user space
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 <lingshan.zhu@intel.com> Message-Id: <20240218185606.13509-5-lingshan.zhu@intel.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
1 parent 3a1d33f commit 81f64e1

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
@@ -985,6 +985,20 @@ vdpa_dev_blk_block_size_config_fill(struct sk_buff *msg, u64 features,
985985
return nla_put_u32(msg, VDPA_ATTR_DEV_BLK_CFG_BLK_SIZE, val_u32);
986986
}
987987

988+
static int
989+
vdpa_dev_blk_seg_max_config_fill(struct sk_buff *msg, u64 features,
990+
const struct virtio_blk_config *config)
991+
{
992+
u32 val_u32;
993+
994+
if ((features & BIT_ULL(VIRTIO_BLK_F_SEG_MAX)) == 0)
995+
return 0;
996+
997+
val_u32 = __virtio32_to_cpu(true, config->seg_max);
998+
999+
return nla_put_u32(msg, VDPA_ATTR_DEV_BLK_CFG_SEG_MAX, val_u32);
1000+
}
1001+
9881002
static int vdpa_dev_blk_config_fill(struct vdpa_device *vdev,
9891003
struct sk_buff *msg)
9901004
{
@@ -1008,6 +1022,9 @@ static int vdpa_dev_blk_config_fill(struct vdpa_device *vdev,
10081022
if (vdpa_dev_blk_block_size_config_fill(msg, features_device, &config))
10091023
return -EMSGSIZE;
10101024

1025+
if (vdpa_dev_blk_seg_max_config_fill(msg, features_device, &config))
1026+
return -EMSGSIZE;
1027+
10111028
return 0;
10121029
}
10131030

include/uapi/linux/vdpa.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ enum vdpa_attr {
5959
VDPA_ATTR_DEV_BLK_CFG_CAPACITY, /* u64 */
6060
VDPA_ATTR_DEV_BLK_CFG_SEG_SIZE, /* u32 */
6161
VDPA_ATTR_DEV_BLK_CFG_BLK_SIZE, /* u32 */
62+
VDPA_ATTR_DEV_BLK_CFG_SEG_MAX, /* u32 */
6263

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

0 commit comments

Comments
 (0)