summaryrefslogtreecommitdiffstats
path: root/src/vnet
diff options
context:
space:
mode:
authorDamjan Marion <damarion@cisco.com>2021-03-10 14:35:28 +0100
committerDave Wallace <dwallacelf@gmail.com>2021-03-11 17:30:34 +0000
commita31698bb7401f6e2389c0e805bf280ae52278524 (patch)
tree05d7940ef2e137cf885941f682a0b39402adb424 /src/vnet
parentaa479bb91d0c75b603e6c8828e6fffa0c70c5a0c (diff)
vlib: refactor node function variants
It allows default variant selection from startup.conf Type: improvement Change-Id: Idff95e12dd0c105dab7c905089548b05a6e974e0 Signed-off-by: Damjan Marion <damarion@cisco.com>
Diffstat (limited to 'src/vnet')
-rw-r--r--src/vnet/interface.c36
-rw-r--r--src/vnet/interface.h3
2 files changed, 16 insertions, 23 deletions
diff --git a/src/vnet/interface.c b/src/vnet/interface.c
index 638dc498fb5..13deaccea2d 100644
--- a/src/vnet/interface.c
+++ b/src/vnet/interface.c
@@ -774,7 +774,6 @@ setup_tx_node (vlib_main_t * vm,
{
vlib_node_t *n = vlib_get_node (vm, node_index);
- n->function = dev_class->tx_function;
n->format_trace = dev_class->format_tx_trace;
/// XXX: Update this to use counter structure
@@ -855,7 +854,7 @@ vnet_register_interface (vnet_main_t * vnm,
hw->min_packet_bytes = 0;
vnet_sw_interface_set_mtu (vnm, hw->sw_if_index, 0);
- if (dev_class->tx_function == 0)
+ if (dev_class->tx_function == 0 && dev_class->tx_fn_registrations == 0)
goto no_output_nodes; /* No output/tx nodes to create */
tx_node_name = (char *) format (0, "%v-tx", hw->name);
@@ -911,7 +910,14 @@ vnet_register_interface (vnet_main_t * vnm,
/* *INDENT-ON* */
node = vlib_get_node (vm, hw->tx_node_index);
- node->function = dev_class->tx_function;
+ if (dev_class->tx_fn_registrations)
+ {
+ node->node_fn_registrations = dev_class->tx_fn_registrations;
+ node->function = vlib_node_get_preferred_node_fn_variant (
+ vm, dev_class->tx_fn_registrations);
+ }
+ else
+ node->function = dev_class->tx_function;
node->format_trace = dev_class->format_tx_trace;
/* *INDENT-OFF* */
foreach_vlib_main ({
@@ -1369,25 +1375,13 @@ vnet_interface_init (vlib_main_t * vm)
c->index = vec_len (im->device_classes);
hash_set_mem (im->device_class_by_name, c->name, c->index);
+ /* to avoid confusion, please remove ".tx_function" statement
+ from VNET_DEVICE_CLASS() if using function candidates */
+ ASSERT (c->tx_fn_registrations == 0 || c->tx_function == 0);
+
if (c->tx_fn_registrations)
- {
- vlib_node_fn_registration_t *fnr = c->tx_fn_registrations;
- int priority = -1;
-
- /* to avoid confusion, please remove ".tx_function" statement
- from VNET_DEVICE_CLASS() if using function candidates */
- ASSERT (c->tx_function == 0);
-
- while (fnr)
- {
- if (fnr->priority > priority)
- {
- priority = fnr->priority;
- c->tx_function = fnr->function;
- }
- fnr = fnr->next_registration;
- }
- }
+ c->tx_function = vlib_node_get_preferred_node_fn_variant (
+ vm, c->tx_fn_registrations);
vec_add1 (im->device_classes, c[0]);
c = c->next_class_registration;
diff --git a/src/vnet/interface.h b/src/vnet/interface.h
index 83abea4593e..9c5844257d8 100644
--- a/src/vnet/interface.h
+++ b/src/vnet/interface.h
@@ -326,8 +326,7 @@ static __clib_unused vnet_device_class_t __clib_unused_##x
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->name = CLIB_MARCH_VARIANT_STR; \
+ r->march_variant = CLIB_MARCH_SFX (CLIB_MARCH_VARIANT_TYPE); \
r->next_registration = devclass.tx_fn_registrations; \
devclass.tx_fn_registrations = r; \
} \