From dd8e7d0e512425ec05de652a3c71028561e0f40a Mon Sep 17 00:00:00 2001 From: Mohsin Kazmi Date: Mon, 23 Jul 2018 14:45:57 +0200 Subject: Multiversioning: Device (tx) function constructor Change-Id: I39f87ca161c891fb22462a23188982fef7c3243f Signed-off-by: Mohsin Kazmi --- src/vnet/interface.h | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'src/vnet/interface.h') diff --git a/src/vnet/interface.h b/src/vnet/interface.h index d869b0c70a2..e9adfe84cbf 100644 --- a/src/vnet/interface.h +++ b/src/vnet/interface.h @@ -195,6 +195,9 @@ typedef struct _vnet_device_class /* Transmit function. */ vlib_node_function_t *tx_function; + /* Transmit function candidate registration with priority */ + vlib_node_fn_registration_t *tx_fn_registrations; + /* Error strings indexed by error code for this node. */ char **tx_function_error_strings; @@ -265,6 +268,24 @@ static void __vnet_rm_device_class_registration_##x (void) \ } \ __VA_ARGS__ vnet_device_class_t x +#define VNET_DEVICE_CLASS_TX_FN(devclass) \ +uword CLIB_MARCH_SFX (devclass##_tx_fn)(); \ +static vlib_node_fn_registration_t \ + CLIB_MARCH_SFX(devclass##_tx_fn_registration) = \ + { .function = &CLIB_MARCH_SFX (devclass##_tx_fn), }; \ + \ +static void __clib_constructor \ +CLIB_MARCH_SFX (devclass##_tx_fn_multiarch_register) (void) \ +{ \ + extern vnet_device_class_t devclass; \ + vlib_node_fn_registration_t *r; \ + r = &CLIB_MARCH_SFX (devclass##_tx_fn_registration); \ + r->priority = CLIB_MARCH_FN_PRIORITY(); \ + r->next_registration = devclass.tx_fn_registrations; \ + devclass.tx_fn_registrations = r; \ +} \ +uword CLIB_CPU_OPTIMIZED CLIB_MARCH_SFX (devclass##_tx_fn) + #define VLIB_DEVICE_TX_FUNCTION_CLONE_TEMPLATE(arch, fn, tgt) \ uword \ __attribute__ ((flatten)) \ -- cgit 1.2.3-korg