/* * 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. */ /* * node.c: VLIB processing nodes * * Copyright (c) 2008 Eliot Dresselhaus * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the * "Software"), to deal in the Software without restriction, including * without limitation the rights to use, copy, modify, merge, publish, * distribute, sublicense, and/or sell copies of the Software, and to * permit persons to whom the Software is furnished to do so, subject to * the following conditions: * * The above copyright notice and this permission notice shall be * included in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #include #include /* Query node given name. */ vlib_node_t * vlib_get_node_by_name (vlib_main_t * vm, u8 * name) { vlib_node_main_t *nm = &vm->node_main; uword *p; u8 *key = name; if (!clib_mem_is_heap_object (key)) key = format (0, "%s", key); p = hash_get (nm->node_by_name, key); if (key != name) vec_free (key); return p ? vec_elt (nm->nodes, p[0]) : 0; } static void node_set_elog_name (vlib_main_t * vm, uword node_index) { vlib_node_t *n = vlib_get_node (vm, node_index); elog_event_type_t *t; t = vec_elt_at_index (vm->node_call_elog_event_types, node_index); vec_free (t->format); t->format = (char *) format (0, "%v-call: %%d%c", n->name, 0); t = vec_elt_at_index (vm->node_return_elog_event_types, node_index); vec_free (t->format); t->format = (char *) format (0, "%v-return: %%d%c", n->name, 0); n->name_elog_string = elog_string (&vm->elog_main, "%v%c", n->name, 0); } static void vlib_worker_thread_node_rename (u32 node_index) { int i; vlib_main_t *vm; vlib_node_t *n; if (vec_len (vlib_mains) == 1) return; vm = vlib_mains[0]; n = vlib_get_node (vm, node_index); ASSERT (vlib_get_thread_index () == 0); ASSERT (*vlib_worker_threads->wait_at_barrier == 1); for (i = 1; i < vec_len (vlib_mains); i++) { vlib_main_t *vm_worker = vlib_mains[i]; vlib_node_t *n_worker = vlib_get_node (vm_worker, node_index); n_worker->name = n->name; n_worker->name_elog_string = n->name_elog_string; } } void vlib_node_rename (vlib_main_t * vm, u32 node_index, char *fmt, ...) { va_list va; vlib_node_main_t *nm = &vm->node_main; vlib_node_t *n = vlib_get_node (vm, node_index); va_start (va, fmt); hash_unset (nm->node_by_name, n->name); vec_free (n->name); n->name = va_format (0, fmt, &va); va_end (va); hash_set (nm->node_by_name, n->name, n->index); node_set_elog_name (vm, node_index); /* Propagate the change to all worker threads */ vlib_worker_thread_node_rename (node_index); } static void vlib_node_runtime_update (vlib_main_t * vm, u32 node_index, u32 next_index) { vlib_node_main_t *nm = &vm->node_main; vlib_node_runtime_t *r, *s; vlib_node_t *node, *next_node; vlib_next_frame_t *nf; vlib_pending_frame_t *pf; i32 i, j, n_insert; ASSERT (vlib_get_thread_index () == 0); vlib_worker_thread_barrier_sync (vm); node = vec_elt (nm->nodes, node_index); r = vlib_node_get_runtime (vm, node_index); n_insert = vec_len (node->next_nodes) - r->n_next_nodes; if (n_insert > 0) { i = r->next_frame_index + r->n_next_nodes; vec_insert (nm->next_frames, n_insert, i); /* Initialize newly inserted next frames. */ for (j = 0; j < n_insert; j++) vlib_next_frame_init (nm->next_frames + i + j); /* Relocate other next frames at higher indices. */ for (j = 0; j < vec_len (nm->nodes); j++) { s = vlib_node_get_runtime (vm, j); if (j != node_index && s->next_frame_index >= i) s->next_frame_index += n_insert; } /* Pending frames may need to be relocated also. */ vec_foreach (pf, nm->pending_frames) { if (pf->next_frame_index != VLIB_PENDING_FRAME_NO_NEXT_FRAME && pf->next_frame_index >= i) pf->next_frame_index += n_insert; } /* *INDENT-OFF* */ pool_foreach (pf, nm->suspended_process_frames, ({ if (pf->next_frame_index != ~0 && pf->next_frame_index >= i) pf->next_frame_index += n_insert; })); /* *INDENT-ON* */ r->n_next_nodes = vec_len (node->next_nodes); } /* Set frame's node runtime index. */ next_node = vlib_get_node (vm, node->next_nodes[next_index]); nf = nm->next_frames + r->next_frame_index + next_index; nf->node_runtime_index = next_node->runtime_index; vlib_worker_thread_node_runtime_update (); vlib_worker_thread_barrier_release (vm); } uword vlib_node_get_next (vlib_main_t * vm, uword node_index, uword next_node_index) { vlib_node_main_t *nm = &vm->node_main; vlib_node_t *node; uword *p; node = vec_elt (nm->nodes, node_index); /* Runtime has to be initialized. */ ASSERT (nm->flags & VLIB_NODE_MAIN_RUNTIME_STARTED); if ((p = hash_get (node->next_slot_by_node, next_node_index))) { return p[0]; } return (~0); } /* Add next node to given node in given slot. */ uword vlib_node_add_next_with_slot (vlib_main_t * vm, uword node_index, uword next_node_index, uword slot) { vlib_node_main_t *nm = &vm->node_main; vlib_node_t *node, *next; uword *p; node = vec_elt (nm->nodes, node_index); next = vec_elt (nm->nodes, next_node_index); /* Runtime has to be initialized. */ ASSERT (nm->flags & VLIB_NODE_MAIN_RUNTIME_STARTED); if ((p = hash_get (node->next_slot_by_node, next_node_index))) { /* Next already exists: slot must match. */ if (slot != ~0) ASSERT (slot == p[0]); return p[0]; } if (slot == ~0) slot = vec_len (node->next_nodes); vec_validate_init_empty (node->n
# 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.

# Pick up per-platform makefile fragments
$(foreach d,$(SOURCE_PATH_BUILD_DATA_DIRS),	\
  $(eval -include $(d)/platforms/*.mk))

.PHONY: install-deb
install-deb: $(patsubst %,%-find-source,$(ROOT_PACKAGES))
	@$(BUILD_ENV) ;							\
	set -eu$(BUILD_DEBUG) ;						\
	$(MAKE) -C $(MU_BUILD_ROOT_DIR)					\
	    $(patsubst %,%-install,					\
	      $(ROOT_PACKAGES))	|| exit 1;				\
									\
	: generate file manifests ;					\
	find $(INSTALL_PREFIX)$(ARCH)/*/bin -type f -print		\
	  | sed -e 's:.*:../& /usr/bin:'				\
	    > deb/debian/vpp.install ;					\
									\
	: need symbolic links in the lib pkg ; 				\
	find $(INSTALL_PREFIX)$(ARCH)/*/lib* \( -type f -o  -type l \)  \
	  -print | egrep -e '*\.so\.*\.*\.*'				\
	  | sed -e 's:.*:../& /usr/lib/x86_64-linux-gnu:'		\
	    > deb/debian/vpp-lib.install ;				\
									\
	: dev package ;							\
	./scripts/find-dev-contents $(INSTALL_PREFIX)$(ARCH)		\
	 deb/debian/vpp-dev.install ;					\
									\
	: dpdk headers ;						\
	./scripts/find-dpdk-contents $(INSTALL_PREFIX)$(ARCH)		\
	 deb/debian/vpp-dpdk-dev.install ;				\
									\
	: bin package needs startup config ; 				\
	echo ../../vpp/conf/startup.conf /etc/vpp 			\
	   >> deb/debian/vpp.install ;					\
									\
	: and sysctl config ; 						\
	echo ../../vpp/conf/80-vpp.conf /etc/sysctl.d 			\
	   >> deb/debian/vpp.install ;					\
									\
	: dev package needs a couple of additions ;			\
        echo ../build-tool-native/vppapigen/vppapigen /usr/bin		\
           >> deb/debian/vpp-dev.install ;				\
									\
	: generate changelog;						\