session: allow small pacer bursts

Instead of enforcing a "strict" release of data, which relies on
frequent rescheduling of sessions, allow some pacer coalescing, i.e.,
short bursts, that can minimize load on scheduler/session layer and
potentially leverage tso.

Type: improvement

Signed-off-by: Florin Coras <fcoras@cisco.com>
Change-Id: I67e38e5b8dc335bd214113b70c68c27ae92bd6da
diff --git a/src/vppinfra/clib.h b/src/vppinfra/clib.h
index 9474350..22377c6 100644
--- a/src/vppinfra/clib.h
+++ b/src/vppinfra/clib.h
@@ -332,6 +332,14 @@
   _x < _y ? _x : _y;				\
 })
 
+#define clib_clamp(x,lo,hi)			\
+({						\
+  __typeof__ (x) _x = (x);			\
+  __typeof__ (lo) _lo = (lo);			\
+  __typeof__ (hi) _hi = (hi);			\
+  _x < _lo ? _lo : (_x > _hi ? _hi : _x);	\
+})
+
 #define clib_abs(x)				\
 ({						\
   __typeof__ (x) _x = (x);			\