From ca33faf9ef108d753b8b6367430521ce62cb7425 Mon Sep 17 00:00:00 2001 From: Yuanhan Liu Date: Sat, 1 Apr 2017 15:22:44 +0800 Subject: [PATCH] vhost: introduce API to fetch negotiated features Signed-off-by: Yuanhan Liu Reviewed-by: Maxime Coquelin --- lib/librte_vhost/rte_vhost_version.map | 1 + lib/librte_vhost/rte_virtio_net.h | 12 ++++++++++++ lib/librte_vhost/vhost.c | 13 +++++++++++++ 3 files changed, 26 insertions(+) diff --git a/lib/librte_vhost/rte_vhost_version.map b/lib/librte_vhost/rte_vhost_version.map index 664a5f3812..cec1e9eec5 100644 --- a/lib/librte_vhost/rte_vhost_version.map +++ b/lib/librte_vhost/rte_vhost_version.map @@ -37,5 +37,6 @@ DPDK_17.05 { rte_vhost_driver_set_features; rte_vhost_get_mem_table; rte_vhost_get_mtu; + rte_vhost_get_negotiated_features; } DPDK_16.07; diff --git a/lib/librte_vhost/rte_virtio_net.h b/lib/librte_vhost/rte_virtio_net.h index 788326696f..e3655974f5 100644 --- a/lib/librte_vhost/rte_virtio_net.h +++ b/lib/librte_vhost/rte_virtio_net.h @@ -158,6 +158,18 @@ int rte_vhost_driver_disable_features(const char *path, uint64_t features); */ int rte_vhost_driver_get_features(const char *path, uint64_t *features); +/** + * Get the feature bits after negotiation + * + * @param vid + * Vhost device ID + * @param features + * A pointer to store the queried feature bits + * @return + * 0 on success, -1 on failure + */ +int rte_vhost_get_negotiated_features(int vid, uint64_t *features); + /* Register callbacks. */ int rte_vhost_driver_callback_register(const char *path, struct virtio_net_device_ops const * const ops); diff --git a/lib/librte_vhost/vhost.c b/lib/librte_vhost/vhost.c index 2b41652f70..90b0f67492 100644 --- a/lib/librte_vhost/vhost.c +++ b/lib/librte_vhost/vhost.c @@ -359,6 +359,19 @@ rte_vhost_get_ifname(int vid, char *buf, size_t len) return 0; } +int +rte_vhost_get_negotiated_features(int vid, uint64_t *features) +{ + struct virtio_net *dev; + + dev = get_device(vid); + if (!dev) + return -1; + + *features = dev->features; + return 0; +} + int rte_vhost_get_mem_table(int vid, struct rte_vhost_memory **mem) { -- 2.20.1