virtio: fix txq locking

Initialize txq lock only if some txq are shared and check if another
worker is already operating on the txq before processing gro timeouts
in input node.

Type: fix

Change-Id: I89dab6c0e6eb6a7aa621fa1548b0a2c76e6c7581
Signed-off-by: Benoît Ganne <bganne@cisco.com>
diff --git a/src/vppinfra/lock.h b/src/vppinfra/lock.h
index 3cfe11c..470890b 100644
--- a/src/vppinfra/lock.h
+++ b/src/vppinfra/lock.h
@@ -91,6 +91,15 @@
   CLIB_LOCK_DBG (p);
 }
 
+static_always_inline int
+clib_spinlock_trylock (clib_spinlock_t * p)
+{
+  if (PREDICT_FALSE (CLIB_SPINLOCK_IS_LOCKED (p)))
+    return 0;
+  clib_spinlock_lock (p);
+  return 1;
+}
+
 static_always_inline void
 clib_spinlock_lock_if_init (clib_spinlock_t * p)
 {
@@ -98,6 +107,14 @@
     clib_spinlock_lock (p);
 }
 
+static_always_inline int
+clib_spinlock_trylock_if_init (clib_spinlock_t * p)
+{
+  if (PREDICT_FALSE (*p != 0))
+    return clib_spinlock_trylock (p);
+  return 1;
+}
+
 static_always_inline void
 clib_spinlock_unlock (clib_spinlock_t * p)
 {