vppinfra: refactor interrupt code

Type: improvement
Change-Id: Ie6987736faf7d8a641762e276775da8ee0c03ea4
Signed-off-by: Damjan Marion <damarion@cisco.com>
diff --git a/src/vlib/main.c b/src/vlib/main.c
index 9d34aa1..219ed22 100644
--- a/src/vlib/main.c
+++ b/src/vlib/main.c
@@ -1471,8 +1471,6 @@
   else
     cpu_time_now = clib_cpu_time_now ();
 
-  nm->pending_interrupts = 0;
-
   /* Pre-allocate expired nodes. */
   if (!nm->polling_threshold_vector_length)
     nm->polling_threshold_vector_length = 10;
@@ -1504,7 +1502,6 @@
   while (1)
     {
       vlib_node_runtime_t *n;
-      u8 pending_interrupts;
 
       if (PREDICT_FALSE (_vec_len (vm->pending_rpc_requests) > 0))
 	{
@@ -1552,19 +1549,14 @@
 				      /* frame */ 0,
 				      cpu_time_now);
 
-      pending_interrupts =
-	__atomic_load_n (&nm->pending_interrupts, __ATOMIC_ACQUIRE);
-
-      if (pending_interrupts)
+      if (clib_interrupt_is_any_pending (nm->pre_input_node_interrupts))
 	{
 	  int int_num = -1;
-	  nm->pending_interrupts = 0;
 
-	  while ((int_num = clib_interrupt_get_next (
+	  while ((int_num = clib_interrupt_get_next_and_clear (
 		    nm->pre_input_node_interrupts, int_num)) != -1)
 	    {
 	      vlib_node_runtime_t *n;
-	      clib_interrupt_clear (nm->pre_input_node_interrupts, int_num);
 	      n = vec_elt_at_index (
 		nm->nodes_by_type[VLIB_NODE_TYPE_PRE_INPUT], int_num);
 	      cpu_time_now = dispatch_node (vm, n, VLIB_NODE_TYPE_PRE_INPUT,
@@ -1584,15 +1576,14 @@
       if (PREDICT_TRUE (is_main && vm->queue_signal_pending == 0))
 	vm->queue_signal_callback (vm);
 
-      if (pending_interrupts)
+      if (clib_interrupt_is_any_pending (nm->input_node_interrupts))
 	{
 	  int int_num = -1;
 
-	  while ((int_num = clib_interrupt_get_next (nm->input_node_interrupts,
-						     int_num)) != -1)
+	  while ((int_num = clib_interrupt_get_next_and_clear (
+		    nm->input_node_interrupts, int_num)) != -1)
 	    {
 	      vlib_node_runtime_t *n;
-	      clib_interrupt_clear (nm->input_node_interrupts, int_num);
 	      n = vec_elt_at_index (nm->nodes_by_type[VLIB_NODE_TYPE_INPUT],
 				    int_num);
 	      cpu_time_now = dispatch_node (vm, n, VLIB_NODE_TYPE_INPUT,