FD.io VPP  v21.06-3-gbb25fbf28
Vector Packet Processing
callback.h File Reference

Callback multiplex scheme For a fully worked-out example, see .../src/vlib/main.[ch] and .../src/plugins/perfmon.c. More...

+ Include dependency graph for callback.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define clib_callback_enable_disable(h, tmp, l, f, enable)
 Add or remove a callback to the specified callback set. More...
 
#define clib_call_callbacks(h, ...)
 call the specified callback set More...
 
#define clib_callback_is_set(h, l, f)
 predicate function says whether the specified function is enabled More...
 

Detailed Description

Callback multiplex scheme For a fully worked-out example, see .../src/vlib/main.[ch] and .../src/plugins/perfmon.c.

Definition in file callback.h.

Macro Definition Documentation

◆ clib_call_callbacks

#define clib_call_callbacks (   h,
  ... 
)
Value:
do { \
/* \
* Note: fp exists to shut up gcc-6, which \
* produces a warning not seen with gcc-7 or 8 \
*/ \
typeof (h) h_ = (h); \
int i; \
for (i = 0; i < vec_len (h_); i++) \
{ \
(h_[i]) (__VA_ARGS__); \
} \
} while (0);

call the specified callback set

Parameters
hthe callback set
varargsadditional callback parameters

Definition at line 67 of file callback.h.

◆ clib_callback_enable_disable

#define clib_callback_enable_disable (   h,
  tmp,
  l,
  f,
  enable 
)
Value:
do { \
void *tmp2; \
clib_spinlock_lock_if_init(&l); \
vec_reset_length(tmp); \
vec_append(tmp, h); \
if (enable) \
vec_add1 (tmp,(void *)f); \
else \
{ \
int i; \
for (i = 0; i < vec_len (tmp); i++) \
if (((void *)tmp[i]) == (void *)f) \
{ \
vec_delete (tmp, 1, i); \
break; \
} \
} \
tmp2 = h; \
CLIB_MEMORY_STORE_BARRIER(); \
h = tmp; \
tmp = tmp2; \
clib_spinlock_unlock_if_init(&l); \
} while(0);

Add or remove a callback to the specified callback set.

Parameters
hhead of the callback vector
tmpvector to build result
lclib_spinlock_t lock to protect the vector, may be 0
ffunction to add or remove
enable1 adds f to the vector, 0 removes f from the vector

Add or remove a callback from the indicated callback vector. Caller must provide locking to prevent > 1 concurrent writer Swaps the head of the callback vector and a tmp vector in one motion, after a write barrier to ensure that the write is atomic.

Definition at line 38 of file callback.h.

◆ clib_callback_is_set

#define clib_callback_is_set (   h,
  l,
  f 
)
Value:
({ \
int _i; \
int _found = 0; \
clib_spinlock_lock_if_init(&l); \
for (_i = 0; _i < vec_len (h); _i++) \
if (((void *)h[_i]) == (void *) f) \
{ \
_found=1; \
break; \
} \
clib_spinlock_unlock_if_init(&l); \
_found; \
})

predicate function says whether the specified function is enabled

Parameters
hthe callback set
lclib_spinlock_t lock to protect the vector, may be 0
fthe function to search for
Returns
1 if the function is enabled, 0 if not

Definition at line 84 of file callback.h.

tmp
u32 * tmp
Definition: interface_output.c:1078
f
vlib_frame_t * f
Definition: interface_output.c:1080
h
h
Definition: flowhash_template.h:372
vec_len
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
Definition: vec_bootstrap.h:142
i
sll srl srl sll sra u16x4 i
Definition: vector_sse42.h:261