Skip to content

Commit 1c96d54

Browse files
jasowangmstsirkin
authored andcommitted
vdpa: conditionally fill max max queue pair for stats
For the device without multiqueue feature, we will read 0 as max_virtqueue_pairs from the config. So if we fill VDPA_ATTR_DEV_NET_CFG_MAX_VQP with the value we read from the config we will confuse the user. Fixing this by only filling the value when multiqueue is offered by the device so userspace can assume 1 when the attr is not provided. Fixes: 13b00b1("vdpa: Add support for querying vendor statistics") Cc: Eli Cohen <[email protected]> Signed-off-by: Jason Wang <[email protected]> Message-Id: <[email protected]> Signed-off-by: Michael S. Tsirkin <[email protected]> Reviewed-by: Eli Cohen <[email protected]>
1 parent ed843d6 commit 1c96d54

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

drivers/vdpa/vdpa.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -935,7 +935,6 @@ static int vdpa_fill_stats_rec(struct vdpa_device *vdev, struct sk_buff *msg,
935935
{
936936
struct virtio_net_config config = {};
937937
u64 features;
938-
u16 max_vqp;
939938
u8 status;
940939
int err;
941940

@@ -946,15 +945,15 @@ static int vdpa_fill_stats_rec(struct vdpa_device *vdev, struct sk_buff *msg,
946945
}
947946
vdpa_get_config_unlocked(vdev, 0, &config, sizeof(config));
948947

949-
max_vqp = __virtio16_to_cpu(true, config.max_virtqueue_pairs);
950-
if (nla_put_u16(msg, VDPA_ATTR_DEV_NET_CFG_MAX_VQP, max_vqp))
951-
return -EMSGSIZE;
952-
953948
features = vdev->config->get_driver_features(vdev);
954949
if (nla_put_u64_64bit(msg, VDPA_ATTR_DEV_NEGOTIATED_FEATURES,
955950
features, VDPA_ATTR_PAD))
956951
return -EMSGSIZE;
957952

953+
err = vdpa_dev_net_mq_config_fill(msg, features, &config);
954+
if (err)
955+
return err;
956+
958957
if (nla_put_u32(msg, VDPA_ATTR_DEV_QUEUE_INDEX, index))
959958
return -EMSGSIZE;
960959

0 commit comments

Comments
 (0)