summaryrefslogtreecommitdiffstats
path: root/build/external/Makefile
blob: b0e3cee4faa51d2ff3bbfc6722b61bb8172a7ba3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
# 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.

# Scripts require non-POSIX parts of bash
SHELL := /bin/bash

DL_CACHE_DIR = $(HOME)/Downloads
MAKE ?= make
MAKE_ARGS ?= -j
BUILD_DIR        ?= $(CURDIR)/_build
INSTALL_DIR      ?= $(CURDIR)/_install
PKG_VERSION ?= $(shell git describe --abbrev=0 | cut -d- -f1 | cut -dv -f2 | cut -d. -f1,2)
PKG_SUFFIX ?= $(shell git log --oneline v$(PKG_VERSION)-rc0.. . | wc -l)
JOBS := $(if $(shell [ -f /proc/cpuinfo ] && head /proc/cpuinfo),\
	$(shell grep -c ^processor /proc/cpuinfo), 2)

B := $(BUILD_DIR)
I := $(INSTALL_DIR)

ifneq ($(shell which cmake3),)
CMAKE?=cmake3
else
CMAKE?=cmake
endif

include packages.mk
include packages/nasm.mk
include packages/ipsec-mb.mk
include packages/quicly.mk
include packages/dpdk.mk
include packages/rdma-core.mk
include packages/libbpf.mk

.PHONY: clean
clean:
	@rm -rf $(B) $(I)

.PHONY: install
install: dpdk-install rdma-core-install quicly-install libbpf-install

.PHONY: config
config: dpdk-config rdma-core-config

##############################################################################
# .deb packaging
##############################################################################

DEB_VER := $(PKG_VERSION)
DEB_ARCH=$(shell dpkg --print-architecture 2> /dev/null)
DEV_DEB=vpp-ext-deps_$(DEB_VER)-$(PKG_SUFFIX)_$(DEB_ARCH).deb
INSTALLED_VER=$(shell dpkg-query --showformat='$${Version}' --show vpp-ext-deps 2> /dev/null)

.PHONY: build-deb install-deb check-deb

deb/debian/changelog: Makefile
	@echo "vpp-ext-deps ($(DEB_VER)-$(PKG_SUFFIX)) unstable; urgency=low" > $@
	@echo "" >> $@
	@echo "  * Version $(DEB_VER)" >> $@
	@echo "" >> $@
	@echo " -- VPP Dev <vpp-dev@lists.fd.io>  $(shell date -R)" >> $@

$(DEV_DEB): deb/debian/changelog
	@cd deb && dpkg-buildpackage -b -uc -us
	git clean -fdx deb

build-deb: $(DEV_DEB)

install-deb:
ifneq ($(INSTALLED_VER),$(DEB_VER)-$(PKG_SUFFIX))
	@make $(DEV_DEB)
	@sudo dpkg -i $(DEV_DEB)
else
	@echo "=========================================================="
	@echo " Up-to-date vpp-ext-deps package already installed"
	@echo "=========================================================="
endif

check-deb:
ifneq ($(INSTALLED_VER),$(DEB_VER)-$(PKG_SUFFIX))
	@echo "=========================================================="
	@echo " Out of date vpp-ext-deps package installed."
	@echo " Installed: $(INSTALLED_VER)"
	@echo " Needed: $(DEB_VER)-$(PKG_SUFFIX)"
	@echo ""
	@echo " Please upgrade by invoking 'make install-ext-deps'"
	@echo " from the top level directory."
	@echo "=========================================================="
endif

##############################################################################
# .rpm packaging
##############################################################################

RPM_VER := $(PKG_VERSION)
RPM_ARCH=$(shell rpm --eval "%{_arch}" 2> /dev/null)
DEV_RPM=vpp-ext-deps-$(RPM_VER)-$(PKG_SUFFIX).$(RPM_ARCH).rpm
INSTALLED_RPM_VER=$(shell rpm -q --queryformat '%{VERSION}-%{RELEASE}' vpp-ext-deps 2> /dev/null | grep -v "not inst")

.PHONY: build-rpm install-rpm check-rpm

$(DEV_RPM): Makefile rpm/vpp-ext-deps.spec
	@rpmbuild -bb \
	  --define "_topdir $(CURDIR)/rpm" \
	  --define "_version $(RPM_VER)" \
	  --define "_release $(PKG_SUFFIX)" \
	  $(CURDIR)/rpm/vpp-ext-deps.spec
	mv rpm/RPMS/$(RPM_ARCH)/*.rpm .
	@git clean -fdx rpm

build-rpm: $(DEV_RPM)

install-rpm:
ifneq ($(INSTALLED_RPM_VER),$(RPM_VER)-$(PKG_SUFFIX))
	@$(MAKE) $(DEV_RPM)
	sudo rpm -e vpp-ext-deps || true
	sudo rpm -Uih --force $(DEV_RPM)
else
	@echo "=========================================================="
	@echo " Up-to-date vpp-ext-deps package already installed"
	@echo "=========================================================="
endif

check-rpm:
ifneq ($(INSTALLED_RPM_VER),$(RPM_VER)-$(PKG_SUFFIX))
	@echo "=========================================================="
	@echo " Out of date vpp-ext-deps package installed."
	@echo " Installed: $(INSTALLED_RPM_VER)"
	@echo " Needed: $(RPM_VER)-$(PKG_SUFFIX)"
	@echo ""
	@echo " Please upgrade by invoking 'make install-ext-deps'"
	@echo " from the top level directory."
	@echo "=========================================================="
endif

##############################################################################
# ebuild support
##############################################################################

.PHONY: ebuild-build ebuild-install

ebuild-build:
ifeq ($(INSTALLED_VER)$(INSTALLED_RPM_VER),)
	@echo "=========================================================="
	@echo "Building vpp-ext-deps from source. Consider installing"
	@echo "development package by invoking 'make install-ext-deps'"
	@echo "from the top level directory"
	@echo "=========================================================="
	make config
else
ifneq ($(INSTALLED_VER),)
	make check-deb
endif
ifneq ($(INSTALLED_RPM_VER),)
	make check-rpm
endif
endif

ebuild-install:
ifeq ($(INSTALLED_VER)$(INSTALLED_RPM_VER),)
	make install
endif
>/* *INDENT-ON* */ } static void ip6_ll_prefix_to_fib (const ip6_ll_prefix_t * ilp, fib_prefix_t * fp) { fp->fp_proto = FIB_PROTOCOL_IP6; fp->fp_len = 128; fp->fp_addr.ip6 = ilp->ilp_addr; } fib_node_index_t ip6_ll_table_entry_update (const ip6_ll_prefix_t * ilp, fib_route_path_flags_t flags) { fib_node_index_t ip6_ll_entry_index; fib_route_path_t *rpaths, rpath = { .frp_flags = flags, .frp_sw_if_index = ilp->ilp_sw_if_index, .frp_proto = DPO_PROTO_IP6, }; fib_prefix_t fp; vec_validate (ip6_ll_table.ilt_fibs, ilp->ilp_sw_if_index); if (0 == ip6_ll_fib_get (ilp->ilp_sw_if_index)) { ip6_ll_fib_create (ilp->ilp_sw_if_index); } rpaths = NULL; vec_add1 (rpaths, rpath); ip6_ll_prefix_to_fib (ilp, &fp); ip6_ll_entry_index = fib_table_entry_update (ip6_ll_fib_get (ilp->ilp_sw_if_index), &fp, FIB_SOURCE_IP6_ND, (flags & FIB_ROUTE_PATH_LOCAL ? FIB_ENTRY_FLAG_LOCAL : FIB_ENTRY_FLAG_NONE), rpaths); vec_free (rpaths); return (ip6_ll_entry_index); } void ip6_ll_table_entry_delete (const ip6_ll_prefix_t * ilp) { fib_node_index_t ip6_ll_entry_index; u32 fib_index; ip6_ll_entry_index = ip6_ll_table_lookup_exact_match (ilp); if (FIB_NODE_INDEX_INVALID != ip6_ll_entry_index) fib_table_entry_delete_index (ip6_ll_entry_index, FIB_SOURCE_IP6_ND); /* * if there are no ND sourced prefixes left, then we can clean up this FIB */ fib_index = ip6_ll_fib_get (ilp->ilp_sw_if_index); if (0 == fib_table_get_num_entries (fib_index, FIB_PROTOCOL_IP6, FIB_SOURCE_IP6_ND)) { fib_table_unlock (fib_index, FIB_PROTOCOL_IP6, FIB_SOURCE_IP6_ND); ip6_ll_table.ilt_fibs[ilp->ilp_sw_if_index] = 0; } } static void ip6_ll_table_show_one (vlib_main_t * vm, ip6_ll_prefix_t * ilp, int detail) { vlib_cli_output (vm, "%U", format_fib_entry, ip6_ll_table_lookup (ilp), (detail ? FIB_ENTRY_FORMAT_DETAIL2 : FIB_ENTRY_FORMAT_DETAIL)); } typedef struct ip6_ll_show_ctx_t_ { fib_node_index_t *entries; } ip6_ll_show_ctx_t; static fib_table_walk_rc_t ip6_ll_table_show_walk (fib_node_index_t fib_entry_index, void *arg) { ip6_ll_show_ctx_t *ctx = arg; vec_add1 (ctx->entries, fib_entry_index); return (FIB_TABLE_WALK_CONTINUE); } static void ip6_ll_table_show_all (vlib_main_t * vm, u32 fib_index) { fib_node_index_t *fib_entry_index; ip6_ll_show_ctx_t ctx = { .entries = NULL, }; fib_table_walk (fib_index, FIB_PROTOCOL_IP6, ip6_ll_table_show_walk, &ctx); vec_sort_with_function (ctx.entries, fib_entry_cmp_for_sort); vec_foreach (fib_entry_index, ctx.entries) { vlib_cli_output (vm, "%U", format_fib_entry, *fib_entry_index, FIB_ENTRY_FORMAT_BRIEF); } vec_free (ctx.entries); } typedef struct { u32 fib_index; u64 count_by_prefix_length[129]; } count_routes_in_fib_at_prefix_length_arg_t; static void count_routes_in_fib_at_prefix_length (BVT (clib_bihash_kv) * kvp, void *arg) { count_routes_in_fib_at_prefix_length_arg_t *ap = arg; int mask_width; if ((kvp->key[2] >> 32) != ap->fib_index) return; mask_width = kvp->key[2] & 0xFF; ap->count_by_prefix_length[mask_width]++; } static clib_error_t * ip6_ll_show_fib (vlib_main_t * vm, unformat_input_t * input, vlib_cli_command_t * cmd) { count_routes_in_fib_at_prefix_length_arg_t _ca, *ca = &_ca; ip6_main_t *im6 = &ip6_main; fib_table_t *fib_table; int verbose, matching; ip6_address_t matching_address; u32 mask_len = 128; u32 sw_if_index = ~0; int detail = 0; vnet_main_t *vnm = vnet_get_main (); u32 fib_index; verbose = 1; matching = 0; while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) { if (unformat (input, "brief") || unformat (input, "summary") || unformat (input, "sum")) verbose = 0; else if (unformat (input, "detail") || unformat (input, "det")) detail = 1; else if (unformat (input, "%U/%d", unformat_ip6_address, &matching_address, &mask_len)) matching = 1; else if (unformat (input, "%U", unformat_ip6_address, &matching_address)) matching = 1; else if (unformat (input, "%U", unformat_vnet_sw_interface, vnm, &sw_if_index)) ; else break; } vec_foreach_index (sw_if_index, ip6_ll_table.ilt_fibs) { fib_source_t source; u8 *s = NULL; fib_index = ip6_ll_table.ilt_fibs[sw_if_index]; if (0 == fib_index) continue; fib_table = fib_table_get (fib_index, FIB_PROTOCOL_IP6); if (!(fib_table->ft_flags & FIB_TABLE_FLAG_IP6_LL)) continue; s = format (s, "%U, fib_index:%d, locks:[", format_fib_table_name, fib_index, FIB_PROTOCOL_IP6, fib_index); FOR_EACH_FIB_SOURCE (source) { if (0 != fib_table->ft_locks[source]) { s = format (s, "%U:%d, ", format_fib_source, source, fib_table->ft_locks[source]); } } s = format (s, "]"); vlib_cli_output (vm, "%v", s); vec_free (s); /* Show summary? */ if (!verbose) { BVT (clib_bihash) * h = &im6->ip6_table[IP6_FIB_TABLE_NON_FWDING].ip6_hash; int len; vlib_cli_output (vm, "%=20s%=16s", "Prefix length", "Count"); clib_memset (ca, 0, sizeof (*ca)); ca->fib_index = fib_index; BV (clib_bihash_foreach_key_value_pair) (h, count_routes_in_fib_at_prefix_length, ca); for (len = 128; len >= 0; len--) { if (ca->count_by_prefix_length[len]) vlib_cli_output (vm, "%=20d%=16lld", len, ca->count_by_prefix_length[len]); } continue; } if (!matching) { ip6_ll_table_show_all (vm, fib_index); } else { if (~0 == sw_if_index) { vlib_cli_output (vm, "specify the interface"); } else { ip6_ll_prefix_t ilp = { .ilp_addr = matching_address, .ilp_sw_if_index = sw_if_index, }; ip6_ll_table_show_one (vm, &ilp, detail); } } }; return 0; } /* *INDENT-OFF* */ VLIB_CLI_COMMAND (ip6_show_fib_command, static) = { .path = "show ip6-ll", .short_help = "show ip6-ll [summary] [interface] [<ip6-addr>[/<width>]] [detail]", .function = ip6_ll_show_fib, }; /* *INDENT-ON* */ static clib_error_t * ip6_ll_module_init (vlib_main_t * vm) { clib_error_t *error; error = vlib_call_init_function (vm, ip6_lookup_init); return (error); } VLIB_INIT_FUNCTION (ip6_ll_module_init); /* * fd.io coding-style-patch-verification: ON * * Local Variables: * eval: (c-set-style "gnu") * End: */