]> xenbits.xensource.com Git - people/aperard/linux.git/commitdiff
vDPA/ifcvf: implement vdpa_config_ops.get_vq_size
authorZhu Lingshan <lingshan.zhu@intel.com>
Fri, 2 Feb 2024 16:38:58 +0000 (00:38 +0800)
committerMichael S. Tsirkin <mst@redhat.com>
Tue, 19 Mar 2024 06:45:50 +0000 (02:45 -0400)
This commit implements vdpa_ops.get_vq_size to report
the size of a specific virtqueue.

Signed-off-by: Zhu Lingshan <lingshan.zhu@intel.com>
Message-Id: <20240202163905.8834-4-lingshan.zhu@intel.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
drivers/vdpa/ifcvf/ifcvf_base.c
drivers/vdpa/ifcvf/ifcvf_base.h
drivers/vdpa/ifcvf/ifcvf_main.c

index 060f837a4f9f762018fd29d52bcb10c91a9436aa..d78621fdd6210da115aaf8dfc9df1fad9905e032 100644 (file)
@@ -69,10 +69,13 @@ static int ifcvf_read_config_range(struct pci_dev *dev,
        return 0;
 }
 
-static u16 ifcvf_get_vq_size(struct ifcvf_hw *hw, u16 qid)
+u16 ifcvf_get_vq_size(struct ifcvf_hw *hw, u16 qid)
 {
        u16 queue_size;
 
+       if (qid >= hw->nr_vring)
+               return 0;
+
        vp_iowrite16(qid, &hw->common_cfg->queue_select);
        queue_size = vp_ioread16(&hw->common_cfg->queue_size);
 
index b57849c643f611fc271d894eb24075f99a0c6fed..5a4be3a4f939a08dd9f1f697d38253d8e4bac6f9 100644 (file)
@@ -131,4 +131,5 @@ void ifcvf_set_vq_ready(struct ifcvf_hw *hw, u16 qid, bool ready);
 void ifcvf_set_driver_features(struct ifcvf_hw *hw, u64 features);
 u64 ifcvf_get_driver_features(struct ifcvf_hw *hw);
 u16 ifcvf_get_max_vq_size(struct ifcvf_hw *hw);
+u16 ifcvf_get_vq_size(struct ifcvf_hw *hw, u16 qid);
 #endif /* _IFCVF_H_ */
index e98fa8100f3cc796f2f3b543cadd7f9a694313c7..cd4e9cb020c41f3e67fb4c860e7cf326b90bf07c 100644 (file)
@@ -597,6 +597,14 @@ static int ifcvf_vdpa_get_vq_irq(struct vdpa_device *vdpa_dev,
                return -EINVAL;
 }
 
+static u16 ifcvf_vdpa_get_vq_size(struct vdpa_device *vdpa_dev,
+                            u16 qid)
+{
+       struct ifcvf_hw *vf = vdpa_to_vf(vdpa_dev);
+
+       return ifcvf_get_vq_size(vf, qid);
+}
+
 static struct vdpa_notification_area ifcvf_get_vq_notification(struct vdpa_device *vdpa_dev,
                                                               u16 idx)
 {
@@ -632,6 +640,7 @@ static const struct vdpa_config_ops ifc_vdpa_ops = {
        .set_vq_num     = ifcvf_vdpa_set_vq_num,
        .set_vq_address = ifcvf_vdpa_set_vq_address,
        .get_vq_irq     = ifcvf_vdpa_get_vq_irq,
+       .get_vq_size    = ifcvf_vdpa_get_vq_size,
        .kick_vq        = ifcvf_vdpa_kick_vq,
        .get_generation = ifcvf_vdpa_get_generation,
        .get_device_id  = ifcvf_vdpa_get_device_id,