From 51327ac5f9ffbe74eb32f26697c563b92eadc3ce Mon Sep 17 00:00:00 2001 From: Damjan Marion Date: Wed, 9 Nov 2016 11:59:42 +0100 Subject: devices: create dummy device-input node to keep nexts in sync device-input feature arc requires that all input-nodes have nexts in sync. packet-generator tends to call vlib_node_add_next when new stream is created and that puts nexts out of sync. With this change all input node are siblings of device-input node so call to vlib_node_add_next(...) will install same next to the whole family. Change-Id: I33d79492e5f30f348af19e527f36fe0222c524d7 Signed-off-by: Damjan Marion --- vnet/Makefile.am | 2 +- vnet/vnet/devices/af_packet/node.c | 4 +-- vnet/vnet/devices/devices.c | 67 +++++++++++++++++++++++++++++++++++ vnet/vnet/devices/devices.h | 2 ++ vnet/vnet/devices/dpdk/node.c | 4 +-- vnet/vnet/devices/feature.c | 56 ----------------------------- vnet/vnet/devices/netmap/node.c | 4 +-- vnet/vnet/devices/virtio/vhost-user.c | 4 +-- vnet/vnet/pg/input.c | 3 +- vnet/vnet/pg/stream.c | 4 ++- vnet/vnet/unix/tapcli.c | 4 +-- vnet/vnet/unix/tuntap.c | 4 +-- 12 files changed, 80 insertions(+), 78 deletions(-) create mode 100644 vnet/vnet/devices/devices.c delete mode 100644 vnet/vnet/devices/feature.c diff --git a/vnet/Makefile.am b/vnet/Makefile.am index 185c08a9627..fef928abd35 100644 --- a/vnet/Makefile.am +++ b/vnet/Makefile.am @@ -31,6 +31,7 @@ endif ######################################## libvnet_la_SOURCES += \ vnet/config.c \ + vnet/devices/devices.c \ vnet/handoff.c \ vnet/interface.c \ vnet/interface_cli.c \ @@ -721,7 +722,6 @@ nobase_include_HEADERS += \ ######################################## libvnet_la_SOURCES += \ - vnet/devices/feature.c \ vnet/feature/feature.c \ vnet/feature/registration.c diff --git a/vnet/vnet/devices/af_packet/node.c b/vnet/vnet/devices/af_packet/node.c index 29fdc7142e8..083c5581c2d 100644 --- a/vnet/vnet/devices/af_packet/node.c +++ b/vnet/vnet/devices/af_packet/node.c @@ -283,14 +283,12 @@ af_packet_input_fn (vlib_main_t * vm, vlib_node_runtime_t * node, VLIB_REGISTER_NODE (af_packet_input_node) = { .function = af_packet_input_fn, .name = "af-packet-input", + .sibling_of = "device-input", .format_trace = format_af_packet_input_trace, .type = VLIB_NODE_TYPE_INPUT, .state = VLIB_NODE_STATE_INTERRUPT, .n_errors = AF_PACKET_INPUT_N_ERROR, .error_strings = af_packet_input_error_strings, - - .n_next_nodes = VNET_DEVICE_INPUT_N_NEXT_NODES, - .next_nodes = VNET_DEVICE_INPUT_NEXT_NODES, }; VLIB_NODE_FUNCTION_MULTIARCH (af_packet_input_node, af_packet_input_fn) diff --git a/vnet/vnet/devices/devices.c b/vnet/vnet/devices/devices.c new file mode 100644 index 00000000000..26753305db2 --- /dev/null +++ b/vnet/vnet/devices/devices.c @@ -0,0 +1,67 @@ +/* + * Copyright (c) 2015 Cisco and/or its affiliates. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include + +static uword +device_input_fn (vlib_main_t * vm, vlib_node_runtime_t * node, + vlib_frame_t * frame) +{ + return 0; +} + +/* *INDENT-OFF* */ +VLIB_REGISTER_NODE (device_input_node) = { + .function = device_input_fn, + .name = "device-input", + .type = VLIB_NODE_TYPE_INPUT, + .state = VLIB_NODE_STATE_DISABLED, + .n_next_nodes = VNET_DEVICE_INPUT_N_NEXT_NODES, + .next_nodes = VNET_DEVICE_INPUT_NEXT_NODES, +}; + +VNET_FEATURE_ARC_INIT (device_input, static) = +{ + .arc_name = "device-input", + .start_nodes = VNET_FEATURES ("device-input"), +}; + +VNET_FEATURE_INIT (l2_patch, static) = { + .arc_name = "device-input", + .node_name = "l2-patch", + .runs_before = VNET_FEATURES ("ethernet-input"), +}; + +VNET_FEATURE_INIT (worker_handoff, static) = { + .arc_name = "device-input", + .node_name = "worker-handoff", + .runs_before = VNET_FEATURES ("ethernet-input"), +}; + +VNET_FEATURE_INIT (ethernet_input, static) = { + .arc_name = "device-input", + .node_name = "ethernet-input", + .runs_before = 0, /* not before any other features */ +}; +/* *INDENT-ON* */ + +/* + * fd.io coding-style-patch-verification: ON + * + * Local Variables: + * eval: (c-set-style "gnu") + * End: + */ diff --git a/vnet/vnet/devices/devices.h b/vnet/vnet/devices/devices.h index 9c74dc314fe..b9a8aaa3cbc 100644 --- a/vnet/vnet/devices/devices.h +++ b/vnet/vnet/devices/devices.h @@ -37,6 +37,8 @@ typedef enum [VNET_DEVICE_INPUT_NEXT_MPLS_INPUT] = "mpls-input", \ } +extern vlib_node_registration_t device_input_node; + #endif /* included_vnet_vnet_device_h */ /* diff --git a/vnet/vnet/devices/dpdk/node.c b/vnet/vnet/devices/dpdk/node.c index bd2355b2a6a..02c311863fc 100644 --- a/vnet/vnet/devices/dpdk/node.c +++ b/vnet/vnet/devices/dpdk/node.c @@ -708,6 +708,7 @@ VLIB_REGISTER_NODE (dpdk_input_node) = { .function = dpdk_input, .type = VLIB_NODE_TYPE_INPUT, .name = "dpdk-input", + .sibling_of = "device-input", /* Will be enabled if/when hardware is detected. */ .state = VLIB_NODE_STATE_DISABLED, @@ -717,9 +718,6 @@ VLIB_REGISTER_NODE (dpdk_input_node) = { .n_errors = DPDK_N_ERROR, .error_strings = dpdk_error_strings, - - .n_next_nodes = VNET_DEVICE_INPUT_N_NEXT_NODES, - .next_nodes = VNET_DEVICE_INPUT_NEXT_NODES, }; diff --git a/vnet/vnet/devices/feature.c b/vnet/vnet/devices/feature.c deleted file mode 100644 index 5a31cd64d61..00000000000 --- a/vnet/vnet/devices/feature.c +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (c) 2015 Cisco and/or its affiliates. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at: - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include - -/* *INDENT-OFF* */ -VNET_FEATURE_ARC_INIT (device_input, static) = -{ - .arc_name = "device-input", - .start_nodes = - VNET_FEATURES ( -#if DPDK > 0 - "dpdk-input", -#endif - "vhost-user-input", "af-packet-input", "netmap-input", - "tuntap-rx", "tapcli-rx", "pg-input"), -}; - -VNET_FEATURE_INIT (l2_patch, static) = { - .arc_name = "device-input", - .node_name = "l2-patch", - .runs_before = VNET_FEATURES ("ethernet-input"), -}; - -VNET_FEATURE_INIT (worker_handoff, static) = { - .arc_name = "device-input", - .node_name = "worker-handoff", - .runs_before = VNET_FEATURES ("ethernet-input"), -}; - -VNET_FEATURE_INIT (ethernet_input, static) = { - .arc_name = "device-input", - .node_name = "ethernet-input", - .runs_before = 0, /* not before any other features */ -}; -/* *INDENT-ON* */ - -/* - * fd.io coding-style-patch-verification: ON - * - * Local Variables: - * eval: (c-set-style "gnu") - * End: - */ diff --git a/vnet/vnet/devices/netmap/node.c b/vnet/vnet/devices/netmap/node.c index 54d0aa15c22..b96bada5f37 100644 --- a/vnet/vnet/devices/netmap/node.c +++ b/vnet/vnet/devices/netmap/node.c @@ -294,15 +294,13 @@ netmap_input_fn (vlib_main_t * vm, vlib_node_runtime_t * node, VLIB_REGISTER_NODE (netmap_input_node) = { .function = netmap_input_fn, .name = "netmap-input", + .sibling_of = "device-input", .format_trace = format_netmap_input_trace, .type = VLIB_NODE_TYPE_INPUT, /* default state is INTERRUPT mode, switch to POLLING if worker threads are enabled */ .state = VLIB_NODE_STATE_INTERRUPT, .n_errors = NETMAP_INPUT_N_ERROR, .error_strings = netmap_input_error_strings, - - .n_next_nodes = VNET_DEVICE_INPUT_N_NEXT_NODES, - .next_nodes = VNET_DEVICE_INPUT_NEXT_NODES, }; VLIB_NODE_FUNCTION_MULTIARCH (netmap_input_node, netmap_input_fn) diff --git a/vnet/vnet/devices/virtio/vhost-user.c b/vnet/vnet/devices/virtio/vhost-user.c index d7256e223f0..b9e08a147c1 100644 --- a/vnet/vnet/devices/virtio/vhost-user.c +++ b/vnet/vnet/devices/virtio/vhost-user.c @@ -1719,6 +1719,7 @@ VLIB_REGISTER_NODE (vhost_user_input_node) = { .function = vhost_user_input, .type = VLIB_NODE_TYPE_INPUT, .name = "vhost-user-input", + .sibling_of = "device-input", /* Will be enabled if/when hardware is detected. */ .state = VLIB_NODE_STATE_DISABLED, @@ -1728,9 +1729,6 @@ VLIB_REGISTER_NODE (vhost_user_input_node) = { .n_errors = VHOST_USER_INPUT_FUNC_N_ERROR, .error_strings = vhost_user_input_func_error_strings, - - .n_next_nodes = VNET_DEVICE_INPUT_N_NEXT_NODES, - .next_nodes = VNET_DEVICE_INPUT_NEXT_NODES, }; VLIB_NODE_FUNCTION_MULTIARCH (vhost_user_input_node, vhost_user_input) diff --git a/vnet/vnet/pg/input.c b/vnet/vnet/pg/input.c index 735a85e2416..54687d51190 100644 --- a/vnet/vnet/pg/input.c +++ b/vnet/vnet/pg/input.c @@ -1702,14 +1702,13 @@ pg_input (vlib_main_t * vm, vlib_node_runtime_t * node, vlib_frame_t * frame) VLIB_REGISTER_NODE (pg_input_node) = { .function = pg_input, .name = "pg-input", + .sibling_of = "device-input", .type = VLIB_NODE_TYPE_INPUT, .format_trace = format_pg_input_trace, /* Input node will be left disabled until a stream is active. */ .state = VLIB_NODE_STATE_DISABLED, - .n_next_nodes = VNET_DEVICE_INPUT_N_NEXT_NODES, - .next_nodes = VNET_DEVICE_INPUT_NEXT_NODES, }; /* *INDENT-ON* */ diff --git a/vnet/vnet/pg/stream.c b/vnet/vnet/pg/stream.c index 7c865e13222..4dd71d91ab2 100644 --- a/vnet/vnet/pg/stream.c +++ b/vnet/vnet/pg/stream.c @@ -42,6 +42,7 @@ #include #include #include +#include /* Mark stream active or inactive. */ void @@ -459,7 +460,8 @@ pg_stream_add (pg_main_t * pg, pg_stream_t * s_init) } /* Connect the graph. */ - s->next_index = vlib_node_add_next (vm, pg_input_node.index, s->node_index); + s->next_index = vlib_node_add_next (vm, device_input_node.index, + s->node_index); } void diff --git a/vnet/vnet/unix/tapcli.c b/vnet/vnet/unix/tapcli.c index a255e65032c..d23e6fea64f 100644 --- a/vnet/vnet/unix/tapcli.c +++ b/vnet/vnet/unix/tapcli.c @@ -447,15 +447,13 @@ static char * tapcli_rx_error_strings[] = { VLIB_REGISTER_NODE (tapcli_rx_node, static) = { .function = tapcli_rx, .name = "tapcli-rx", + .sibling_of = "device-input", .type = VLIB_NODE_TYPE_INPUT, .state = VLIB_NODE_STATE_INTERRUPT, .vector_size = 4, .n_errors = TAPCLI_N_ERROR, .error_strings = tapcli_rx_error_strings, .format_trace = format_tapcli_rx_trace, - - .n_next_nodes = VNET_DEVICE_INPUT_N_NEXT_NODES, - .next_nodes = VNET_DEVICE_INPUT_NEXT_NODES, }; diff --git a/vnet/vnet/unix/tuntap.c b/vnet/vnet/unix/tuntap.c index 4eab3913780..dbb6f309045 100644 --- a/vnet/vnet/unix/tuntap.c +++ b/vnet/vnet/unix/tuntap.c @@ -414,14 +414,12 @@ static char * tuntap_rx_error_strings[] = { VLIB_REGISTER_NODE (tuntap_rx_node,static) = { .function = tuntap_rx, .name = "tuntap-rx", + .sibling_of = "device-input", .type = VLIB_NODE_TYPE_INPUT, .state = VLIB_NODE_STATE_INTERRUPT, .vector_size = 4, .n_errors = 1, .error_strings = tuntap_rx_error_strings, - - .n_next_nodes = VNET_DEVICE_INPUT_N_NEXT_NODES, - .next_nodes = VNET_DEVICE_INPUT_NEXT_NODES, }; /** -- cgit 1.2.3-korg