summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorRadu Nicolau <radu.nicolau@intel.com>2020-12-02 11:45:11 +0000
committerRay Kinsella <mdr@ashroe.eu>2021-01-25 10:07:10 +0000
commit5f48784da3ac653b3ff0609469ebf9b99fa34322 (patch)
tree3bfd053ec64b7dc453e13e449d383bafaebbe35f /src
parent9479838d080ce89d764668c2234c89b14a1ad2e4 (diff)
vlib: startup multi-arch variant configuration fix for interfaces
Propagate the multi-arch variant selection to interfaces. Type: fix Signed-off-by: Radu Nicolau <radu.nicolau@intel.com> Change-Id: I99c4a7896f172f0d14d2ded22a27383825529a7d (cherry picked from commit 5a48b3b9d88fa2793793e2bf3db8bf156fe2951f)
Diffstat (limited to 'src')
-rw-r--r--src/vlib/node_init.c22
-rw-r--r--src/vnet/interface.c2
-rw-r--r--src/vnet/interface.h3
-rw-r--r--src/vnet/interface_output.c30
-rw-r--r--src/vppinfra/cpu.h20
5 files changed, 69 insertions, 8 deletions
diff --git a/src/vlib/node_init.c b/src/vlib/node_init.c
index 47d288c6ef0..232eeb35e3c 100644
--- a/src/vlib/node_init.c
+++ b/src/vlib/node_init.c
@@ -40,6 +40,7 @@
#include <sys/types.h>
#include <fcntl.h>
#include <vlib/vlib.h>
+#include <vnet/vnet.h>
typedef struct _vlib_node_march_variant
{
@@ -89,9 +90,9 @@ unformat_vlib_node_variant (unformat_input_t * input, va_list * args)
}
static_always_inline void
-vlib_update_nr_variant_default (vlib_node_registration_t * nr, u8 * variant)
+vlib_update_nr_variant_default (vlib_node_fn_registration_t * fnr,
+ u8 * variant)
{
- vlib_node_fn_registration_t *fnr = nr->node_fn_registrations;
vlib_node_fn_registration_t *p_reg = 0;
vlib_node_fn_registration_t *v_reg = 0;
u32 tmp;
@@ -127,6 +128,8 @@ vlib_early_node_config (vlib_main_t * vm, unformat_input_t * input)
{
clib_error_t *error = 0;
vlib_node_registration_t *nr, **all;
+ vnet_device_class_t *c;
+ vnet_main_t *vnm = vnet_get_main ();
unformat_input_t sub_input;
uword *hash = 0, *p;
u8 *variant = 0;
@@ -161,10 +164,20 @@ vlib_early_node_config (vlib_main_t * vm, unformat_input_t * input)
nr = vm->node_main.node_registrations;
while (nr)
{
- vlib_update_nr_variant_default (nr, variant);
+ vlib_update_nr_variant_default (nr->node_fn_registrations,
+ variant);
nr = nr->next_registration;
}
+ /* also apply it to interfaces */
+ c = vnm->device_class_registrations;
+ while (c)
+ {
+ vlib_update_nr_variant_default (c->tx_fn_registrations,
+ variant);
+ c = c->next_class_registration;
+ }
+
vec_free (variant);
}
}
@@ -192,7 +205,8 @@ vlib_early_node_config (vlib_main_t * vm, unformat_input_t * input)
"please specify a valid node variant");
vec_add1 (variant, 0);
- vlib_update_nr_variant_default (nr, variant);
+ vlib_update_nr_variant_default (nr->node_fn_registrations,
+ variant);
vec_free (variant);
}
diff --git a/src/vnet/interface.c b/src/vnet/interface.c
index 82dc29b3744..8416c356b23 100644
--- a/src/vnet/interface.c
+++ b/src/vnet/interface.c
@@ -807,7 +807,7 @@ vnet_register_interface (vnet_main_t * vnm,
vnet_config_main_t *cm;
u32 hw_index, i;
char *tx_node_name = NULL, *output_node_name = NULL;
- vlib_node_function_t *output_node = vnet_interface_output_node_get ();
+ vlib_node_function_t *output_node = vnet_interface_output_node_get (vm);
pool_get (im->hw_interfaces, hw);
clib_memset (hw, 0, sizeof (*hw));
diff --git a/src/vnet/interface.h b/src/vnet/interface.h
index 71d6a775708..a983b573020 100644
--- a/src/vnet/interface.h
+++ b/src/vnet/interface.h
@@ -326,6 +326,7 @@ CLIB_MARCH_SFX (devclass##_tx_fn_multiarch_register) (void) \
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->next_registration = devclass.tx_fn_registrations; \
devclass.tx_fn_registrations = r; \
} \
@@ -918,7 +919,7 @@ void vnet_pcap_drop_trace_filter_add_del (u32 error_index, int is_add);
int vnet_interface_name_renumber (u32 sw_if_index, u32 new_show_dev_instance);
-vlib_node_function_t *vnet_interface_output_node_get (void);
+vlib_node_function_t *vnet_interface_output_node_get (vlib_main_t * vm);
void vnet_register_format_buffer_opaque_helper
(vnet_buffer_opquae_formatter_t fn);
diff --git a/src/vnet/interface_output.c b/src/vnet/interface_output.c
index 3363f76b722..e79ad451c55 100644
--- a/src/vnet/interface_output.c
+++ b/src/vnet/interface_output.c
@@ -513,9 +513,35 @@ CLIB_MARCH_FN_REGISTRATION (vnet_interface_output_node);
#ifndef CLIB_MARCH_VARIANT
vlib_node_function_t *
-vnet_interface_output_node_get (void)
+vnet_interface_output_node_get (vlib_main_t * vm)
{
- return CLIB_MARCH_FN_POINTER (vnet_interface_output_node);
+ vlib_node_function_t *fn = 0;
+ vlib_node_fn_registration_t *fnr;
+ char *name = 0;
+ vlib_node_t *node = vlib_get_node_by_name (vm, (u8 *) "interface-output");
+ ASSERT (node);
+
+ /* search for the same name */
+ fnr = node->node_fn_registrations;
+ while (fnr)
+ {
+ if (fnr->function == node->function)
+ {
+ name = fnr->name;
+ break;
+ }
+ fnr = fnr->next_registration;
+ }
+
+ if (name)
+ {
+ fn = CLIB_MARCH_FN_POINTER_BY_NAME (vnet_interface_output_node, name);
+ }
+ if (!fn) /* revert to march type selection if search failed */
+ {
+ fn = CLIB_MARCH_FN_POINTER (vnet_interface_output_node);
+ }
+ return fn;
}
#endif /* CLIB_MARCH_VARIANT */
diff --git a/src/vppinfra/cpu.h b/src/vppinfra/cpu.h
index 750b3934df9..8e127fe5480 100644
--- a/src/vppinfra/cpu.h
+++ b/src/vppinfra/cpu.h
@@ -84,9 +84,29 @@ clib_march_select_fn_ptr (clib_march_fn_registration * r)
return rv;
}
+static_always_inline void *
+clib_march_select_fn_ptr_by_name (clib_march_fn_registration * r, char *name)
+{
+ void *rv = 0;
+
+ while (r)
+ {
+ if (strncmp (name, r->name, vec_len (r->name) - 1) == 0)
+ {
+ rv = r->function;
+ break;
+ }
+ r = r->next;
+ }
+ return rv;
+}
+
#define CLIB_MARCH_FN_POINTER(fn) \
clib_march_select_fn_ptr (fn##_march_fn_registrations);
+#define CLIB_MARCH_FN_POINTER_BY_NAME(fn, name) \
+ clib_march_select_fn_ptr_by_name (fn##_march_fn_registrations, name);
+
#define _CLIB_MARCH_FN_REGISTRATION(fn) \
static clib_march_fn_registration \
CLIB_MARCH_SFX(fn##_march_fn_registration) = \