diff options
author | Zhu Lingshan <lingshan.zhu@intel.com> | 2024-02-02 17:39:01 +0100 |
---|---|---|
committer | Michael S. Tsirkin <mst@redhat.com> | 2024-03-19 07:45:50 +0100 |
commit | f6fa2f7ea07db70d883a9f8944e6119c10934c5f (patch) | |
tree | 34166dc71f30777fc073f9ebe860810f99c2d40e | |
parent | eni_vdpa: implement vdpa_config_ops.get_vq_size (diff) | |
download | linux-f6fa2f7ea07db70d883a9f8944e6119c10934c5f.tar.xz linux-f6fa2f7ea07db70d883a9f8944e6119c10934c5f.zip |
vdpa_sim: implement vdpa_config_ops.get_vq_size for vDPA simulator
This commit implements vdpa_config_ops.get_vq_size for vDPA
simulator, this new interface can help report per vq size.
Signed-off-by: Zhu Lingshan <lingshan.zhu@intel.com>
Message-Id: <20240202163905.8834-7-lingshan.zhu@intel.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
-rw-r--r-- | drivers/vdpa/vdpa_sim/vdpa_sim.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/drivers/vdpa/vdpa_sim/vdpa_sim.c b/drivers/vdpa/vdpa_sim/vdpa_sim.c index 18584ce70bf0..8ffea8430f95 100644 --- a/drivers/vdpa/vdpa_sim/vdpa_sim.c +++ b/drivers/vdpa/vdpa_sim/vdpa_sim.c @@ -311,6 +311,17 @@ static void vdpasim_set_vq_num(struct vdpa_device *vdpa, u16 idx, u32 num) vq->num = num; } +static u16 vdpasim_get_vq_size(struct vdpa_device *vdpa, u16 idx) +{ + struct vdpasim *vdpasim = vdpa_to_sim(vdpa); + struct vdpasim_virtqueue *vq = &vdpasim->vqs[idx]; + + if (vdpasim->status & VIRTIO_CONFIG_S_DRIVER_OK) + return vq->num; + else + return VDPASIM_QUEUE_MAX; +} + static void vdpasim_kick_vq(struct vdpa_device *vdpa, u16 idx) { struct vdpasim *vdpasim = vdpa_to_sim(vdpa); @@ -775,6 +786,7 @@ static const struct vdpa_config_ops vdpasim_config_ops = { .get_driver_features = vdpasim_get_driver_features, .set_config_cb = vdpasim_set_config_cb, .get_vq_num_max = vdpasim_get_vq_num_max, + .get_vq_size = vdpasim_get_vq_size, .get_device_id = vdpasim_get_device_id, .get_vendor_id = vdpasim_get_vendor_id, .get_status = vdpasim_get_status, |