vlib api: move wrkr rpc flushing to vlib

Move vlib worker rpc flushing to main worker from memclnt api into vlib.
RPCs are no longer delivered via binary api queues

Type: refactor

Signed-off-by: Florin Coras <fcoras@cisco.com>
Change-Id: I5b8761a57d1f4a1f2220e860cfb2e6b980f46f6d
diff --git a/src/vlib/main.c b/src/vlib/main.c
index 219ed22..6d91db7 100644
--- a/src/vlib/main.c
+++ b/src/vlib/main.c
@@ -1438,12 +1438,6 @@
   return t;
 }
 
-void vl_api_send_pending_rpc_requests (vlib_main_t *) __attribute__ ((weak));
-void
-vl_api_send_pending_rpc_requests (vlib_main_t * vm)
-{
-}
-
 static_always_inline void
 vlib_main_or_worker_loop (vlib_main_t * vm, int is_main)
 {
@@ -1506,7 +1500,7 @@
       if (PREDICT_FALSE (_vec_len (vm->pending_rpc_requests) > 0))
 	{
 	  if (!is_main)
-	    vl_api_send_pending_rpc_requests (vm);
+	    vlib_worker_flush_pending_rpc_requests (vm);
 	}
 
       if (!is_main)
diff --git a/src/vlib/threads.c b/src/vlib/threads.c
index 7e6ac25..b675b88 100644
--- a/src/vlib/threads.c
+++ b/src/vlib/threads.c
@@ -1587,6 +1587,19 @@
 }
 
 void
+vlib_worker_flush_pending_rpc_requests (vlib_main_t *vm)
+{
+  vlib_main_t *vm_global = vlib_get_first_main ();
+
+  ASSERT (vm != vm_global);
+
+  clib_spinlock_lock_if_init (&vm_global->pending_rpc_lock);
+  vec_append (vm_global->pending_rpc_requests, vm->pending_rpc_requests);
+  vec_reset_length (vm->pending_rpc_requests);
+  clib_spinlock_unlock_if_init (&vm_global->pending_rpc_lock);
+}
+
+void
 vlib_worker_thread_fn (void *arg)
 {
   vlib_global_main_t *vgm = vlib_get_global_main ();
diff --git a/src/vlib/threads.h b/src/vlib/threads.h
index 636212c..e5a1f6d 100644
--- a/src/vlib/threads.h
+++ b/src/vlib/threads.h
@@ -174,6 +174,10 @@
  * Wait until each of the workers has been once around the track
  */
 void vlib_worker_wait_one_loop (void);
+/**
+ * Flush worker's pending rpc requests to main thread's rpc queue
+ */
+void vlib_worker_flush_pending_rpc_requests (vlib_main_t *vm);
 
 static_always_inline uword
 vlib_get_thread_index (void)