+static int
+vhost_vdpa_get_config(struct virtio_user_dev *dev, uint8_t *data, uint32_t off, uint32_t len)
+{
+ struct vhost_vdpa_data *vdpa_data = dev->backend_data;
+ struct vhost_vdpa_config *config;
+ int ret = 0;
+
+ config = malloc(sizeof(*config) + len);
+ if (!config) {
+ PMD_DRV_LOG(ERR, "Failed to allocate vDPA config data");
+ return -1;
+ }
+
+ config->off = off;
+ config->len = len;
+
+ ret = vhost_vdpa_ioctl(vdpa_data->vhostfd, VHOST_VDPA_GET_CONFIG, config);
+ if (ret) {
+ PMD_DRV_LOG(ERR, "Failed to get vDPA config (offset 0x%x, len 0x%x)", off, len);
+ ret = -1;
+ goto out;
+ }
+
+ memcpy(data, config->buf, len);
+out:
+ free(config);
+
+ return ret;
+}
+
+static int
+vhost_vdpa_set_config(struct virtio_user_dev *dev, const uint8_t *data, uint32_t off, uint32_t len)
+{
+ struct vhost_vdpa_data *vdpa_data = dev->backend_data;
+ struct vhost_vdpa_config *config;
+ int ret = 0;
+
+ config = malloc(sizeof(*config) + len);
+ if (!config) {
+ PMD_DRV_LOG(ERR, "Failed to allocate vDPA config data");
+ return -1;
+ }
+
+ config->off = off;
+ config->len = len;
+
+ memcpy(config->buf, data, len);
+
+ ret = vhost_vdpa_ioctl(vdpa_data->vhostfd, VHOST_VDPA_SET_CONFIG, config);
+ if (ret) {
+ PMD_DRV_LOG(ERR, "Failed to set vDPA config (offset 0x%x, len 0x%x)", off, len);
+ ret = -1;
+ }
+
+ free(config);
+
+ return ret;
+}
+