X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=src%2Fvlib%2Fnode.h;h=67eaea3f0e84df719ef4a30de738382c7604bac2;hb=812b32dd8f637118bf65de2cdff0e95b421a963b;hp=7177bebeffbd94890571539638093c1037addbb8;hpb=04e0bb2ff0f39dab45da01ecdbc7914035a36897;p=vpp.git diff --git a/src/vlib/node.h b/src/vlib/node.h index 7177bebeffb..67eaea3f0e8 100644 --- a/src/vlib/node.h +++ b/src/vlib/node.h @@ -75,11 +75,21 @@ typedef enum VLIB_N_NODE_TYPE, } vlib_node_type_t; +typedef struct _vlib_node_fn_registration +{ + vlib_node_function_t *function; + int priority; + struct _vlib_node_fn_registration *next_registration; +} vlib_node_fn_registration_t; + typedef struct _vlib_node_registration { /* Vector processing function for this node. */ vlib_node_function_t *function; + /* Node function candidate registration with priority */ + vlib_node_fn_registration_t *node_fn_registrations; + /* Node name. */ char *name; @@ -160,6 +170,24 @@ static void __vlib_rm_node_registration_##x (void) \ } \ __VA_ARGS__ vlib_node_registration_t x +#define VLIB_NODE_FN(node) \ +uword CLIB_MARCH_SFX (node##_fn)(); \ +static vlib_node_fn_registration_t \ + CLIB_MARCH_SFX(node##_fn_registration) = \ + { .function = &CLIB_MARCH_SFX (node##_fn), }; \ + \ +static void __clib_constructor \ +CLIB_MARCH_SFX (node##_multiarch_register) (void) \ +{ \ + extern vlib_node_registration_t node; \ + vlib_node_fn_registration_t *r; \ + r = & CLIB_MARCH_SFX (node##_fn_registration); \ + r->priority = CLIB_MARCH_FN_PRIORITY(); \ + r->next_registration = node.node_fn_registrations; \ + node.node_fn_registrations = r; \ +} \ +uword CLIB_CPU_OPTIMIZED CLIB_MARCH_SFX (node##_fn) + #if CLIB_DEBUG > 0 #define VLIB_NODE_FUNCTION_CLONE_TEMPLATE(arch, fn) #define VLIB_NODE_FUNCTION_MULTIARCH_CLONE(fn)