From 6565e478e6868601cdfb81920070ae005d7a8e64 Mon Sep 17 00:00:00 2001 From: Sebastien Boeuf Date: Thu, 9 Apr 2020 22:59:13 +0200 Subject: [PATCH] vhost_user_net: Enable multithreaded multiqueue support By implementing queues_per_thread(), this patch fills the last missing bit to enable multithreaded multiqueue support for the vhost-user-net backend implementation. Signed-off-by: Sebastien Boeuf --- vhost_user_net/src/lib.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/vhost_user_net/src/lib.rs b/vhost_user_net/src/lib.rs index 0430eded0..c4f2da64f 100644 --- a/vhost_user_net/src/lib.rs +++ b/vhost_user_net/src/lib.rs @@ -215,6 +215,7 @@ pub struct VhostUserNetBackend { threads: Vec>, num_queues: usize, queue_size: u16, + queues_per_thread: Vec, } impl VhostUserNetBackend { @@ -228,16 +229,19 @@ impl VhostUserNetBackend { let mut taps = open_tap(ifname, Some(ip_addr), Some(netmask), num_queues / 2) .map_err(Error::OpenTap)?; + let mut queues_per_thread = Vec::new(); let mut threads = Vec::new(); - for tap in taps.drain(..) { + for (i, tap) in taps.drain(..).enumerate() { let thread = Mutex::new(VhostUserNetThread::new(tap)?); threads.push(thread); + queues_per_thread.push(0b11 << (i * 2)); } Ok(VhostUserNetBackend { threads, num_queues, queue_size, + queues_per_thread, }) } } @@ -339,6 +343,10 @@ impl VhostUserBackend for VhostUserNetBackend { Some(3), )) } + + fn queues_per_thread(&self) -> Vec { + self.queues_per_thread.clone() + } } pub struct VhostUserNetBackendConfig<'a> {