1 # Copyright (c) 2021 Cisco and/or its affiliates.
2 # Licensed under the Apache License, Version 2.0 (the "License");
3 # you may not use this file except in compliance with the License.
4 # You may obtain a copy of the License at:
6 # http://www.apache.org/licenses/LICENSE-2.0
8 # Unless required by applicable law or agreed to in writing, software
9 # distributed under the License is distributed on an "AS IS" BASIS,
10 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 # See the License for the specific language governing permissions and
12 # limitations under the License.
14 """Constants used in CSIT.
16 "Constant" means a value that keeps its value since initialization. The value
17 does not need to be hard coded here, but can be read from environment variables.
24 def get_str_from_env(env_var_names, default_value):
25 """Attempt to read string from environment variable, return that or default.
27 If environment variable exists, but is empty (and default is not),
28 empty string is returned.
30 Several environment variable names are examined, as CSIT currently supports
31 a mix of naming conventions.
32 Here "several" means there are hard coded prefixes to try,
33 and env_var_names itself can be single name, or a list or a tuple of names.
35 :param env_var_names: Base names of environment variable to attempt to read.
36 :param default_value: Value to return if the env var does not exist.
37 :type env_var_names: str, or list of str, or tuple of str
38 :type default_value: str
39 :returns: The value read, or default value.
42 prefixes = (u"FDIO_CSIT_", u"CSIT_", u"")
43 if not isinstance(env_var_names, (list, tuple)):
44 env_var_names = [env_var_names]
45 for name in env_var_names:
46 for prefix in prefixes:
47 value = os.environ.get(prefix + name, None)
53 def get_int_from_env(env_var_names, default_value):
54 """Attempt to read int from environment variable, return that or default.
56 String value is read, default is returned also if conversion fails.
58 :param env_var_names: Base names of environment variable to attempt to read.
59 :param default_value: Value to return if read or conversion fails.
60 :type env_var_names: str, or list of str, or tuple of str
61 :type default_value: int
62 :returns: The value read, or default value.
65 env_str = get_str_from_env(env_var_names, u"")
72 def get_float_from_env(env_var_names, default_value):
73 """Attempt to read float from environment variable, return that or default.
75 String value is read, default is returned also if conversion fails.
77 :param env_var_names: Base names of environment variable to attempt to read.
78 :param default_value: Value to return if read or conversion fails.
79 :type env_var_names: str, or list of str, or tuple of str
80 :type default_value: float
81 :returns: The value read, or default value.
84 env_str = get_str_from_env(env_var_names, u"")
91 def get_pessimistic_bool_from_env(env_var_names):
92 """Attempt to read bool from environment variable, assume False by default.
94 Conversion is lenient and pessimistic, only few strings are considered true.
96 :param env_var_names: Base names of environment variable to attempt to read.
97 :type env_var_names: str, or list of str, or tuple of str
98 :returns: The value read, or False.
101 env_str = get_str_from_env(env_var_names, u"").lower()
102 return bool(env_str in (u"true", u"yes", u"y", u"1"))
105 def get_optimistic_bool_from_env(env_var_names):
106 """Attempt to read bool from environment variable, assume True by default.
108 Conversion is lenient and optimistic, only few strings are considered false.
110 :param env_var_names: Base names of environment variable to attempt to read.
111 :type env_var_names: str, or list of str, or tuple of str
112 :returns: The value read, or True.
115 env_str = get_str_from_env(env_var_names, u"").lower()
116 return bool(env_str not in (u"false", u"no", u"n", u"0"))
120 """Constants used in CSIT."""
122 # OpenVPP testing directory location at topology nodes
123 REMOTE_FW_DIR = u"/tmp/openvpp-testing"
125 # shell scripts location
126 RESOURCES_LIB_SH = u"resources/libraries/bash"
128 # python scripts location
129 RESOURCES_LIB_PY = u"resources/libraries/python"
131 # shell scripts location
132 RESOURCES_TOOLS = u"resources/tools"
134 # Python API provider location
135 RESOURCES_PAPI_PROVIDER = u"resources/tools/papi/vpp_papi_provider.py"
138 RESOURCES_TPL = u"resources/templates"
140 # vat templates location
141 RESOURCES_TPL_VAT = u"resources/templates/vat"
143 # Kubernetes templates location
144 RESOURCES_TPL_K8S = u"resources/templates/kubernetes"
146 # Container templates location
147 RESOURCES_TPL_CONTAINER = u"resources/templates/container"
149 # VPP Communications Library templates location
150 RESOURCES_TPL_VCL = u"resources/templates/vcl"
152 # VPP Communications Library templates location
153 RESOURCES_TPL_TELEMETRY = u"resources/templates/telemetry"
155 # VPP Communications Library LD_PRELOAD library
156 VCL_LDPRELOAD_LIBRARY = u"/usr/lib/x86_64-linux-gnu/libvcl_ldpreload.so"
158 # OpenVPP VAT binary name
159 VAT_BIN_NAME = u"vpp_api_test"
161 # VPP service unit name
164 # Number of system CPU cores.
167 # Number of vswitch main thread CPU cores.
171 QEMU_BIN_PATH = u"/usr/bin"
173 # QEMU VM kernel image path
174 QEMU_VM_KERNEL = u"/opt/boot/vmlinuz"
176 # QEMU VM kernel initrd path
177 QEMU_VM_KERNEL_INITRD = u"/opt/boot/initrd.img"
179 # QEMU VM nested image path
180 QEMU_VM_IMAGE = u"/var/lib/vm/image.iso"
183 QEMU_VM_DPDK = u"/opt/dpdk-21.02"
185 # Docker container SUT image
186 DOCKER_SUT_IMAGE_UBUNTU = u"csit_sut-ubuntu2004:local"
188 # Docker container arm SUT image
189 DOCKER_SUT_IMAGE_UBUNTU_ARM = u"csit_sut-ubuntu2004:local"
191 # TRex install directory
192 TREX_INSTALL_DIR = u"/opt/trex-core-2.88"
194 # TRex pcap files directory
195 TREX_PCAP_DIR = f"{TREX_INSTALL_DIR}/scripts/avl"
198 TREX_LIMIT_MEMORY = get_int_from_env(u"TREX_LIMIT_MEMORY", 8192)
200 # TRex number of cores
201 TREX_CORE_COUNT = get_int_from_env(u"TREX_CORE_COUNT", 8)
203 # TRex set number of RX/TX descriptors
204 # Set to 0 to use default values
205 TREX_TX_DESCRIPTORS_COUNT = get_int_from_env(
206 u"TREX_TX_DESCRIPTORS_COUNT", 0
208 TREX_RX_DESCRIPTORS_COUNT = get_int_from_env(
209 u"TREX_RX_DESCRIPTORS_COUNT", 0
212 # Trex force start regardless ports state
213 TREX_SEND_FORCE = get_pessimistic_bool_from_env(u"TREX_SEND_FORCE")
215 # TRex extra commandline arguments
216 TREX_EXTRA_CMDLINE = get_str_from_env(
217 u"TREX_EXTRA_CMDLINE", u"--mbuf-factor 32")
219 # graph node variant value
220 GRAPH_NODE_VARIANT = get_str_from_env(
221 u"GRAPH_NODE_VARIANT", u"")
223 # Sysctl kernel.core_pattern
224 KERNEL_CORE_PATTERN = u"/tmp/%p-%u-%g-%s-%t-%h-%e.core"
226 # Core dump directory
227 CORE_DUMP_DIR = u"/tmp"
229 # Perf stat events (comma separated).
230 PERF_STAT_EVENTS = get_str_from_env(
232 u"cpu-clock,context-switches,cpu-migrations,page-faults,"
233 u"cycles,instructions,branches,branch-misses,L1-icache-load-misses")
235 # Equivalent to ~0 used in vpp code
236 BITWISE_NON_ZERO = 0xffffffff
238 # Default path to VPP API socket.
239 SOCKSVR_PATH = u"/run/vpp/api.sock"
241 # Number of trials to execute in MRR test.
242 PERF_TRIAL_MULTIPLICITY = get_int_from_env(u"PERF_TRIAL_MULTIPLICITY", 10)
244 # Duration [s] of one trial in MRR test.
245 PERF_TRIAL_DURATION = get_float_from_env(u"PERF_TRIAL_DURATION", 1.0)
247 # Whether to use latency streams in main search trials.
248 PERF_USE_LATENCY = get_pessimistic_bool_from_env(u"PERF_USE_LATENCY")
250 # Duration of one latency-specific trial in NDRPDR test.
251 PERF_TRIAL_LATENCY_DURATION = get_float_from_env(
252 u"PERF_TRIAL_LATENCY_DURATION", 5.0)
254 # For some testbeds TG takes longer than usual to start sending traffic.
255 # This constant [s] allows longer wait, without affecting
256 # the approximate duration. For example, use 0.098 for AWS.
257 PERF_TRIAL_STL_DELAY = get_float_from_env(u"PERF_TRIAL_STL_DELAY", 0.0)
259 # ASTF usually needs a different value for the delay.
260 PERF_TRIAL_ASTF_DELAY = get_float_from_env(
261 u"PERF_TRIAL_ASTF_DELAY", 0.112
264 # Extended debug (incl. vpp packet trace, linux perf stat, ...).
265 # Full list is available as suite variable (__init__.robot) or is
267 EXTENDED_DEBUG = get_pessimistic_bool_from_env(u"EXTENDED_DEBUG")
269 # UUID string of DUT1 /tmp volume created outside of the
270 # DUT1 docker in case of vpp-device test. ${EMPTY} value means that
271 # /tmp directory is inside the DUT1 docker.
272 DUT1_UUID = get_str_from_env(u"DUT1_UUID", u"")
274 # Default path to VPP API Stats socket.
275 SOCKSTAT_PATH = u"/run/vpp/stats.sock"
277 # Global "kill switch" for CRC checking during runtime.
278 FAIL_ON_CRC_MISMATCH = get_pessimistic_bool_from_env(
279 u"FAIL_ON_CRC_MISMATCH"
282 # Default IP4 prefix length (if not defined in topology file)
283 DEFAULT_IP4_PREFIX_LENGTH = u"24"
285 # Maximum number of interfaces in a data path
286 DATAPATH_INTERFACES_MAX = 100
288 # Mapping from NIC name to its bps limit.
289 NIC_NAME_TO_BPS_LIMIT = {
290 u"Intel-X520-DA2": 10000000000,
291 u"Intel-X553": 10000000000,
292 u"Intel-X710": 10000000000,
293 u"Intel-XL710": 24500000000,
294 u"Intel-XXV710": 24500000000,
295 u"Intel-E810CQ": 100000000000,
296 u"Mellanox-CX556A": 100000000000,
297 u"Amazon-Nitro-50G": 10000000000,
298 u"virtual": 100000000,
301 # Mapping from NIC name to its pps limit.
302 NIC_NAME_TO_PPS_LIMIT = {
303 u"Intel-X520-DA2": 14880952,
304 u"Intel-X553": 14880952,
305 u"Intel-X710": 14880952,
306 u"Intel-XL710": 18750000,
307 u"Intel-XXV710": 18750000,
308 u"Intel-E810CQ": 58500000,
309 # 2n-clx testbeds show duration stretching on high rates,
310 # depending on encapsulation TRex has to generate.
311 # 40 Mpps is still too much for dot1q (~8% stretching).
312 # 36 Mpps is around the maximal VPP throughput (l2patch 4c8t).
313 # Vxlan traffic will still show stretching at 36 Mpps (>12%),
314 # but we do not care about those tests that much.
315 u"Mellanox-CX556A": 36000000, # 148809523,
316 u"Amazon-Nitro-50G": 1200000,
317 u"virtual": 14880952,
320 # Suite file names use codes for NICs.
322 u"Intel-X520-DA2": u"10ge2p1x520",
323 u"Intel-X553": u"10ge2p1x553",
324 u"Intel-X710": u"10ge2p1x710",
325 u"Intel-XL710": u"40ge2p1xl710",
326 u"Intel-XXV710": u"25ge2p1xxv710",
327 u"Intel-E810CQ": u"100ge2p1e810cq",
328 u"Amazon-Nitro-50G": u"50ge1p1ENA",
329 u"Mellanox-CX556A": u"100ge2p1cx556a",
332 # Not each driver is supported by each NIC.
333 NIC_NAME_TO_DRIVER = {
334 u"Intel-X520-DA2": [u"vfio-pci", u"af_xdp"],
335 u"Intel-X553": [u"vfio-pci", u"af_xdp"],
336 u"Intel-X710": [u"vfio-pci", u"avf", u"af_xdp"],
337 u"Intel-XL710": [u"vfio-pci", u"avf", u"af_xdp"],
338 u"Intel-XXV710": [u"vfio-pci", u"avf", u"af_xdp"],
339 u"Intel-E810CQ": [u"vfio-pci", u"avf", u"af_xdp"],
340 u"Amazon-Nitro-50G": [u"vfio-pci"],
341 u"Mellanox-CX556A": [u"rdma-core", u"af_xdp"],
344 # Each driver needs different prugin to work.
345 NIC_DRIVER_TO_PLUGINS = {
346 u"vfio-pci": u"dpdk_plugin.so",
347 u"avf": u"avf_plugin.so",
348 u"rdma-core": u"rdma_plugin.so",
349 u"af_xdp": u"af_xdp_plugin.so",
352 # Tags to differentiate tests for different NIC driver.
353 NIC_DRIVER_TO_TAG = {
354 u"vfio-pci": u"DRV_VFIO_PCI",
356 u"rdma-core": u"DRV_RDMA_CORE",
357 u"af_xdp": u"DRV_AF_XDP",
360 # Suite names have to be different, add prefix.
361 NIC_DRIVER_TO_SUITE_PREFIX = {
364 u"rdma-core": u"rdma-",
365 u"af_xdp": u"af-xdp-",
368 # Number of virtual functions of physical nic.
369 NIC_DRIVER_TO_VFS = {
370 u"vfio-pci": u"nic_vfs}= | 0",
371 u"avf": u"nic_vfs}= | 1",
372 u"rdma-core": u"nic_vfs}= | 0",
373 u"af_xdp": u"nic_vfs}= | 0",
376 # Not each driver is supported by each NIC.
377 DPDK_NIC_NAME_TO_DRIVER = {
378 u"Intel-X520-DA2": [u"vfio-pci"],
379 u"Intel-X553": [u"vfio-pci"],
380 u"Intel-X710": [u"vfio-pci"],
381 u"Intel-XL710": [u"vfio-pci"],
382 u"Intel-XXV710": [u"vfio-pci"],
383 u"Intel-E810CQ": [u"vfio-pci"],
384 u"Amazon-Nitro-50G": [u"vfio-pci"],
385 u"Mellanox-CX556A": [u"mlx5_core"],
388 # Tags to differentiate tests for different NIC driver.
389 DPDK_NIC_DRIVER_TO_TAG = {
390 u"vfio-pci": u"DRV_VFIO_PCI",
391 u"mlx5_core": u"DRV_MLX5_CORE",
394 # Suite names have to be different, add prefix.
395 DPDK_NIC_DRIVER_TO_SUITE_PREFIX = {
397 u"mlx5_core": u"mlx5-",
400 # Some identifiers constructed from suite names
401 # have to be independent of NIC driver used.
402 # In order to remove or reject the NIC driver part,
403 # it is useful to have a list of such prefixes precomputed.
404 FORBIDDEN_SUITE_PREFIX_LIST = [
405 prefix for prefix in NIC_DRIVER_TO_SUITE_PREFIX.values() if prefix
407 FORBIDDEN_SUITE_PREFIX_LIST += [
408 prefix for prefix in DPDK_NIC_DRIVER_TO_SUITE_PREFIX.values() if prefix
411 # TODO CSIT-1481: Crypto HW should be read from topology file instead.
412 NIC_NAME_TO_CRYPTO_HW = {
413 u"Intel-X553": u"HW_C3xxx",
414 u"Intel-X710": u"HW_DH895xcc",
415 u"Intel-XL710": u"HW_DH895xcc",
418 PERF_TYPE_TO_KEYWORD = {
419 u"mrr": u"Traffic should pass with maximum rate",
420 u"ndrpdr": u"Find NDR and PDR intervals using optimized search",
421 u"soak": u"Find critical load using PLRsearch",
424 PERF_TYPE_TO_SUITE_DOC_VER = {
425 u"mrr": u'''fication:* In MaxReceivedRate tests TG sends traffic\\
426 | ... | at line rate and reports total received packets over trial period.\\''',
427 u"ndrpdr": u'''ication:* TG finds and reports throughput NDR (Non Drop\\
428 | ... | Rate) with zero packet loss tolerance and throughput PDR (Partial Drop\\
429 | ... | Rate) with non-zero packet loss tolerance (LT) expressed in percentage\\
430 | ... | of packets transmitted. NDR and PDR are discovered for different\\
431 | ... | Ethernet L2 frame sizes using MLRsearch library.\\''',
432 u"soak": u'''fication:* TG sends traffic at dynamically computed\\
433 | ... | rate as PLRsearch algorithm gathers data and improves its estimate\\
434 | ... | of a rate at which a prescribed small fraction of packets\\
435 | ... | would be lost. After set time, the serarch stops\\
436 | ... | and the algorithm reports its current estimate.\\''',
439 PERF_TYPE_TO_TEMPLATE_DOC_VER = {
440 u"mrr": u'''Measure MaxReceivedRate for ${frame_size}B frames\\
441 | | ... | using burst trials throughput test.\\''',
442 u"ndrpdr": u"Measure NDR and PDR values using MLRsearch algorithm.\\",
443 u"soak": u"Estimate critical rate using PLRsearch algorithm.\\",