This patch mainly adds method in vhost user adapter to communicate enable/disable queues messages with vhost user backend.
Signed-off-by: Jianfeng Tan <jianfeng.tan at intel.com> --- drivers/net/virtio/virtio_user/vhost.h | 4 ++++ drivers/net/virtio/virtio_user/vhost_user.c | 21 +++++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/drivers/net/virtio/virtio_user/vhost.h b/drivers/net/virtio/virtio_user/vhost.h index 5cd3543..fe236a7 100644 --- a/drivers/net/virtio/virtio_user/vhost.h +++ b/drivers/net/virtio/virtio_user/vhost.h @@ -209,8 +209,12 @@ enum { #define VHOST_KERNEL 0 #define VHOST_USER 1 +#define VHOST_USER_F_PROTOCOL_FEATURES 30 +#define VHOST_USER_MQ (1ULL << VHOST_USER_F_PROTOCOL_FEATURES) + int vhost_user_sock(int vhostfd, unsigned long int req, void *arg); int vhost_user_setup(const char *path); +int vhost_user_enable_queue_pair(int vhostfd, unsigned pair_idx, int enable); int vhost_kernel_ioctl(int vhostfd, unsigned long int req, void *arg); int vhost_kernel_setup(const char *path, const char *ifname, int *p_tapfd); diff --git a/drivers/net/virtio/virtio_user/vhost_user.c b/drivers/net/virtio/virtio_user/vhost_user.c index 6fd648c..d8f7996 100644 --- a/drivers/net/virtio/virtio_user/vhost_user.c +++ b/drivers/net/virtio/virtio_user/vhost_user.c @@ -263,6 +263,7 @@ vhost_user_sock(int vhostfd, unsigned long int req, void *arg) case VHOST_USER_SET_VRING_NUM: case VHOST_USER_SET_VRING_BASE: + case VHOST_USER_SET_VRING_ENABLE: memcpy(&msg.payload.state, arg, sizeof(msg.payload.state)); msg.size = sizeof(m.payload.state); break; @@ -373,3 +374,23 @@ vhost_user_setup(const char *path) return fd; } + +int +vhost_user_enable_queue_pair(int vhostfd, unsigned pair_idx, int enable) +{ + int i; + + for (i = 0; i < 2; ++i) { + struct vhost_vring_state state = { + .index = pair_idx * 2 + i, + .num = enable, + }; + + if (vhost_user_sock(vhostfd, + VHOST_USER_SET_VRING_ENABLE, &state)) + return -1; + } + + return 0; + +} -- 2.1.4