[3/3] net/ifc: fix used ring update

Message ID 20190415075625.109948-4-xiao.w.wang@intel.com (mailing list archive)
State Accepted, archived
Delegated to: Ferruh Yigit
Headers
Series net/ifc: SW relay improvement and fix |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK

Commit Message

Xiao Wang April 15, 2019, 7:56 a.m. UTC
  The vring relay thread is created after HW datapath start and is
canceled before HW datapath stop, so we need to take care of the
ring update when the relay thread is not on duty.

Fixes: 4bb531e152d3 ("net/ifc: support SW assisted VDPA live migration")

Signed-off-by: Xiao Wang <xiao.w.wang@intel.com>
---
 drivers/net/ifc/ifcvf_vdpa.c | 7 +++++++
 1 file changed, 7 insertions(+)
  

Patch

diff --git a/drivers/net/ifc/ifcvf_vdpa.c b/drivers/net/ifc/ifcvf_vdpa.c
index 9e729ff72..e59084034 100644
--- a/drivers/net/ifc/ifcvf_vdpa.c
+++ b/drivers/net/ifc/ifcvf_vdpa.c
@@ -81,6 +81,8 @@  static struct internal_list_head internal_list =
 
 static pthread_mutex_t internal_list_lock = PTHREAD_MUTEX_INITIALIZER;
 
+static void update_used_ring(struct ifcvf_internal *internal, uint16_t qid);
+
 static struct internal_list *
 find_internal_resource_by_did(int did)
 {
@@ -666,6 +668,10 @@  m_ifcvf_stop(struct ifcvf_internal *internal)
 	ifcvf_stop_hw(hw);
 
 	for (i = 0; i < hw->nr_vring; i++) {
+		/* synchronize remaining new used entries if any */
+		if ((i & 1) == 0)
+			update_used_ring(internal, i);
+
 		rte_vhost_get_vhost_vring(vid, i, &vq);
 		len = IFCVF_USED_RING_LEN(vq.size);
 		rte_vhost_log_used_vring(vid, i, 0, len);
@@ -735,6 +741,7 @@  vring_relay(void *arg)
 			DRV_LOG(ERR, "epoll add error: %s", strerror(errno));
 			return NULL;
 		}
+		update_used_ring(internal, qid);
 	}
 
 	/* start relay with a first kick */