vDPA/ifcvf: implement vdpa_config_ops.get_vq_num_min
authorZhu Lingshan <lingshan.zhu@intel.com>
Fri, 2 Feb 2024 16:39:05 +0000 (00:39 +0800)
committerMichael S. Tsirkin <mst@redhat.com>
Tue, 19 Mar 2024 06:45:50 +0000 (02:45 -0400)
IFCVF HW supports operation with vq size less than the max size,
as the spec required.

This commit implements vdpa_config_ops.get_vq_num_min to report
the minimal size of the virtqueues, which gives vDPA framework
a chance to reduce the vring size.

We need at least one descriptor to be functional, but it is better
no less than 64 to meet ceratin performance requirements.
Actually the framework would allocate at least a PAGE for the vq.

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

index 5a4be3a4f939a08dd9f1f697d38253d8e4bac6f9..0f347717021a2eb2d827e11b59e11f9cafb43f5e 100644 (file)
@@ -28,6 +28,7 @@
 #define IFCVF_PCI_MAX_RESOURCE 6
 
 #define IFCVF_LM_BAR                   4
+#define IFCVF_MIN_VQ_SIZE              64
 
 #define IFCVF_ERR(pdev, fmt, ...)      dev_err(&pdev->dev, fmt, ##__VA_ARGS__)
 #define IFCVF_DBG(pdev, fmt, ...)      dev_dbg(&pdev->dev, fmt, ##__VA_ARGS__)
index cd4e9cb020c41f3e67fb4c860e7cf326b90bf07c..80d0a046088589a989072d0f2dbe92339a7e9674 100644 (file)
@@ -456,6 +456,11 @@ static u16 ifcvf_vdpa_get_vq_num_max(struct vdpa_device *vdpa_dev)
        return ifcvf_get_max_vq_size(vf);
 }
 
+static u16 ifcvf_vdpa_get_vq_num_min(struct vdpa_device *vdpa_dev)
+{
+       return IFCVF_MIN_VQ_SIZE;
+}
+
 static int ifcvf_vdpa_get_vq_state(struct vdpa_device *vdpa_dev, u16 qid,
                                   struct vdpa_vq_state *state)
 {
@@ -632,6 +637,7 @@ static const struct vdpa_config_ops ifc_vdpa_ops = {
        .set_status     = ifcvf_vdpa_set_status,
        .reset          = ifcvf_vdpa_reset,
        .get_vq_num_max = ifcvf_vdpa_get_vq_num_max,
+       .get_vq_num_min = ifcvf_vdpa_get_vq_num_min,
        .get_vq_state   = ifcvf_vdpa_get_vq_state,
        .set_vq_state   = ifcvf_vdpa_set_vq_state,
        .set_vq_cb      = ifcvf_vdpa_set_vq_cb,