vhost: allow to enable or disable features
authorHuawei Xie <huawei.xie@intel.com>
Wed, 8 Oct 2014 18:54:51 +0000 (02:54 +0800)
committerThomas Monjalon <thomas.monjalon@6wind.com>
Mon, 13 Oct 2014 17:16:54 +0000 (19:16 +0200)
Signed-off-by: Huawei Xie <huawei.xie@intel.com>
Acked-by: Changchun Ouyang <changchun.ouyang@intel.com>
[Thomas: split patch]

lib/librte_vhost/rte_virtio_net.h
lib/librte_vhost/virtio-net.c

index 73423dd..de2ced6 100644 (file)
@@ -148,6 +148,21 @@ gpa_to_vva(struct virtio_net *dev, uint64_t guest_pa)
        return vhost_va;
 }
 
+/**
+ *  Disable features in feature_mask. Returns 0 on success.
+ */
+int rte_vhost_feature_disable(uint64_t feature_mask);
+
+/**
+ *  Enable features in feature_mask. Returns 0 on success.
+ */
+int rte_vhost_feature_enable(uint64_t feature_mask);
+
+/* Returns currently supported vhost features */
+uint64_t rte_vhost_feature_get(void);
+
+int rte_vhost_enable_guest_notification(struct virtio_net *dev, uint16_t queue_id, int enable);
+
 /* Register vhost driver. dev_name could be different for multiple instance support. */
 int rte_vhost_driver_register(const char *dev_name);
 
index 14e657b..de505c5 100644 (file)
@@ -960,6 +960,37 @@ get_virtio_net_callbacks(void)
        return &vhost_device_ops;
 }
 
+int rte_vhost_enable_guest_notification(struct virtio_net *dev, uint16_t queue_id, int enable)
+{
+       if (enable) {
+               RTE_LOG(ERR, VHOST_CONFIG, "guest notification isn't supported.\n");
+               return -1;
+       }
+
+       dev->virtqueue[queue_id]->used->flags = enable ? 0 : VRING_USED_F_NO_NOTIFY;
+       return 0;
+}
+
+uint64_t rte_vhost_feature_get(void)
+{
+       return VHOST_FEATURES;
+}
+
+int rte_vhost_feature_disable(uint64_t feature_mask)
+{
+       VHOST_FEATURES = VHOST_FEATURES & ~feature_mask;
+       return 0;
+}
+
+int rte_vhost_feature_enable(uint64_t feature_mask)
+{
+       if ((feature_mask & VHOST_SUPPORTED_FEATURES) == feature_mask) {
+               VHOST_FEATURES = VHOST_FEATURES | feature_mask;
+               return 0;
+       }
+       return -1;
+}
+
 /*
  * Register ops so that we can add/remove device to data core.
  */