+static int
+ifcvf_set_vring_state(int vid, int vring, int state)
+{
+ struct rte_vdpa_device *vdev;
+ struct internal_list *list;
+ struct ifcvf_internal *internal;
+ struct ifcvf_hw *hw;
+ struct ifcvf_pci_common_cfg *cfg;
+ int ret = 0;
+
+ vdev = rte_vhost_get_vdpa_device(vid);
+ list = find_internal_resource_by_vdev(vdev);
+ if (list == NULL) {
+ DRV_LOG(ERR, "Invalid vDPA device: %p", vdev);
+ return -1;
+ }
+
+ internal = list->internal;
+ if (vring < 0 || vring >= internal->max_queues * 2) {
+ DRV_LOG(ERR, "Vring index %d not correct", vring);
+ return -1;
+ }
+
+ hw = &internal->hw;
+ if (!internal->configured)
+ goto exit;
+
+ cfg = hw->common_cfg;
+ IFCVF_WRITE_REG16(vring, &cfg->queue_select);
+ IFCVF_WRITE_REG16(!!state, &cfg->queue_enable);
+
+ if (!state && hw->vring[vring].enable) {
+ ret = vdpa_disable_vfio_intr(internal);
+ if (ret)
+ return ret;
+ }
+
+ if (state && !hw->vring[vring].enable) {
+ ret = vdpa_enable_vfio_intr(internal, 0);
+ if (ret)
+ return ret;
+ }
+
+exit:
+ hw->vring[vring].enable = !!state;
+ return 0;
+}
+