1 # Copyright (c) 2023 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 # Version for CSIT data model. See docs/model/.
123 MODEL_VERSION = u"1.4.0"
125 # Global off-switch in case JSON export is large or slow.
126 EXPORT_JSON = get_optimistic_bool_from_env(u"EXPORT_JSON")
128 # OpenVPP testing directory location at topology nodes
129 REMOTE_FW_DIR = u"/tmp/openvpp-testing"
131 # shell scripts location
132 RESOURCES_LIB_SH = u"resources/libraries/bash"
134 # python scripts location
135 RESOURCES_LIB_PY = u"resources/libraries/python"
137 # shell scripts location
138 RESOURCES_TOOLS = u"resources/tools"
140 # Python API provider location
141 RESOURCES_PAPI_PROVIDER = u"resources/tools/papi/vpp_papi_provider.py"
144 RESOURCES_TPL = u"resources/templates"
146 # Kubernetes templates location
147 RESOURCES_TPL_K8S = u"resources/templates/kubernetes"
149 # Container templates location
150 RESOURCES_TPL_CONTAINER = u"resources/templates/container"
152 # VPP Communications Library templates location
153 RESOURCES_TPL_VCL = u"resources/templates/vcl"
155 # VPP Communications Library templates location
156 RESOURCES_TPL_TELEMETRY = u"resources/templates/telemetry"
158 # VPP Communications Library LD_PRELOAD library
159 VCL_LDPRELOAD_LIBRARY = u"/usr/lib/x86_64-linux-gnu/libvcl_ldpreload.so"
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-23.07"
185 # Docker container SUT image
186 DOCKER_SUT_IMAGE_UBUNTU = u"csit_sut-ubuntu2204:local"
188 # Docker container arm SUT image
189 DOCKER_SUT_IMAGE_UBUNTU_ARM = u"csit_sut-ubuntu2204:local"
191 # TRex install directory.
192 TREX_INSTALL_DIR = u"/opt/trex-core-3.03"
194 # TRex pcap files directory.
195 TREX_PCAP_DIR = f"{TREX_INSTALL_DIR}/scripts/avl"
198 TREX_LIMIT_MEMORY = get_int_from_env("TREX_LIMIT_MEMORY", 8192)
200 # TRex limit memory in case multiple dual interfaces configurations.
201 TREX_LIMIT_MEMORY_MULTI = get_int_from_env("TREX_LIMIT_MEMORY_MULTI", 16384)
203 # TRex number of cores.
204 TREX_CORE_COUNT = get_int_from_env("TREX_CORE_COUNT", 16)
206 # TRex number of cores in case multiple dual interface configurations.
207 TREX_CORE_COUNT_MULTI = get_int_from_env("TREX_CORE_COUNT_MULTI", 8)
209 # TRex set number of RX/TX descriptors.
210 # Set to 0 to use default values.
211 TREX_TX_DESCRIPTORS_COUNT = get_int_from_env(
212 "TREX_TX_DESCRIPTORS_COUNT", 0
215 TREX_RX_DESCRIPTORS_COUNT = get_int_from_env(
216 "TREX_RX_DESCRIPTORS_COUNT", 0
219 # Trex force start regardless ports state.
220 TREX_SEND_FORCE = get_pessimistic_bool_from_env("TREX_SEND_FORCE")
222 # TRex extra commandline arguments.
223 TREX_EXTRA_CMDLINE = get_str_from_env(
224 "TREX_EXTRA_CMDLINE", "--mbuf-factor 32"
227 # TRex port driver default vfio-pci or set to igb_uio.
228 TREX_PORT_DRIVER = get_str_from_env(
229 "TREX_PORT_DRIVER", "vfio-pci"
232 # Graph node variant value
233 GRAPH_NODE_VARIANT = get_str_from_env(u"GRAPH_NODE_VARIANT", u"")
235 # Default memory page size in case multiple configured in system
236 DEFAULT_HUGEPAGE_SIZE = get_str_from_env(u"DEFAULT_HUGEPAGE_SIZE", u"2M")
238 # Sysctl kernel.core_pattern
239 KERNEL_CORE_PATTERN = u"/tmp/%p-%u-%g-%s-%t-%h-%e.core"
241 # Core dump directory
242 CORE_DUMP_DIR = u"/tmp"
244 # Perf stat events (comma separated).
245 PERF_STAT_EVENTS = get_str_from_env(
247 u"cpu-clock,context-switches,cpu-migrations,page-faults,"
248 u"cycles,instructions,branches,branch-misses,L1-icache-load-misses")
250 # Equivalent to ~0 used in vpp code
251 BITWISE_NON_ZERO = 0xffffffff
253 # Default path to VPP API socket.
254 SOCKSVR_PATH = u"/run/vpp/api.sock"
256 # Default path to VPP CLI socket.
257 SOCKCLI_PATH = u"/run/vpp/cli.sock"
259 # Default path to VPP API Stats socket.
260 SOCKSTAT_PATH = u"/run/vpp/stats.sock"
262 # This MTU value is used to force VPP to fragment 1518B packet into two.
263 MTU_FOR_FRAGMENTATION = 1043
265 # Number of trials to execute in MRR test.
266 PERF_TRIAL_MULTIPLICITY = get_int_from_env(u"PERF_TRIAL_MULTIPLICITY", 10)
268 # Duration [s] of one trial in MRR test.
269 PERF_TRIAL_DURATION = get_float_from_env(u"PERF_TRIAL_DURATION", 1.0)
271 # Whether to use latency streams in main search trials.
272 PERF_USE_LATENCY = get_pessimistic_bool_from_env(u"PERF_USE_LATENCY")
274 # Duration of one latency-specific trial in NDRPDR test.
275 PERF_TRIAL_LATENCY_DURATION = get_float_from_env(
276 u"PERF_TRIAL_LATENCY_DURATION", 5.0)
278 # For some testbeds TG takes longer than usual to start sending traffic.
279 # This constant [s] allows longer wait, without affecting
280 # the approximate duration. For example, use 0.098 for AWS.
281 PERF_TRIAL_STL_DELAY = get_float_from_env(u"PERF_TRIAL_STL_DELAY", 0.0)
283 # ASTF usually needs a different value for the delay.
284 PERF_TRIAL_ASTF_DELAY = get_float_from_env(
285 u"PERF_TRIAL_ASTF_DELAY", 0.112
288 # Number of data frames in TPUT transaction, used both by TCP and UDP.
289 # The value should be 33 to keep historic continuity for UDP TPUT tests,
290 # but we are limited by TRex window of 48 KiB, so for 9000B tests
291 # it means we can send only 5 full data frames in a burst.
292 # https://github.com/cisco-system-traffic-generator/
293 # trex-core/blob/v2.88/src/44bsd/tcp_var.h#L896-L903
294 ASTF_N_DATA_FRAMES = get_int_from_env(u"ASTF_N_DATA_FRAMES", 5)
296 # Extended debug (incl. vpp packet trace, linux perf stat, ...).
297 # Full list is available as suite variable (__init__.robot) or is
299 EXTENDED_DEBUG = get_pessimistic_bool_from_env(u"EXTENDED_DEBUG")
301 # UUID string of DUT1 /tmp volume created outside of the
302 # DUT1 docker in case of vpp-device test. ${EMPTY} value means that
303 # /tmp directory is inside the DUT1 docker.
304 DUT1_UUID = get_str_from_env(u"DUT1_UUID", u"")
306 # Global "kill switch" for CRC checking during runtime.
307 FAIL_ON_CRC_MISMATCH = get_pessimistic_bool_from_env(
308 u"FAIL_ON_CRC_MISMATCH"
311 # Default IP4 prefix length (if not defined in topology file)
312 DEFAULT_IP4_PREFIX_LENGTH = u"24"
314 # Maximum number of interfaces in a data path
315 DATAPATH_INTERFACES_MAX = 100
317 # Mapping from NIC name to its bps limit.
318 NIC_NAME_TO_BPS_LIMIT = {
319 u"Intel-X520-DA2": 10000000000,
320 u"Intel-X710": 10000000000,
321 u"Intel-XL710": 24500000000,
322 u"Intel-XXV710": 24500000000,
323 u"Intel-E810XXV": 24500000000,
324 u"Intel-E822CQ": 24500000000,
325 u"Intel-E810CQ": 100000000000,
326 u"Mellanox-CX556A": 100000000000,
327 u"Mellanox-CX6DX": 100000000000,
328 u"Mellanox-CX7VEAT": 200000000000,
329 u"Amazon-Nitro-50G": 10000000000,
330 u"Amazon-Nitro-100G": 10000000000,
331 u"Amazon-Nitro-200G": 16000000000,
332 u"virtual": 100000000,
335 # Mapping from NIC name to its pps limit.
336 NIC_NAME_TO_PPS_LIMIT = {
337 u"Intel-X520-DA2": 14880952,
338 u"Intel-X710": 14880952,
339 u"Intel-XL710": 18750000,
340 u"Intel-XXV710": 18750000,
341 u"Intel-E810XXV": 29000000,
342 u"Intel-E822CQ": 29000000,
343 u"Intel-E810CQ": 58500000,
344 u"Mellanox-CX556A": 148809523,
345 u"Mellanox-CX6DX": 148809523,
346 u"Mellanox-CX7VEAT": 297619046,
347 u"Amazon-Nitro-50G": 1500000,
348 u"Amazon-Nitro-100G": 3000000,
349 u"Amazon-Nitro-200G": 6000000,
350 u"virtual": 14880952,
353 # Suite file names use codes for NICs.
355 u"Intel-X520-DA2": u"10ge2p1x520",
356 u"Intel-X710": u"10ge2p1x710",
357 u"Intel-XL710": u"40ge2p1xl710",
358 u"Intel-XXV710": u"25ge2p1xxv710",
359 u"Intel-E810XXV": u"25ge2p1e810xxv",
360 u"Intel-E822CQ": u"25ge2p1e822cq",
361 u"Intel-E810CQ": u"100ge2p1e810cq",
362 u"Amazon-Nitro-50G": u"50ge1p1ena",
363 u"Amazon-Nitro-100G": u"100ge1p1ena",
364 u"Amazon-Nitro-200G": u"200ge1p1ena",
365 u"Mellanox-CX556A": u"100ge2p1cx556a",
366 u"Mellanox-CX6DX": u"100ge2p1cx6dx",
367 u"Mellanox-CX7VEAT": u"200ge2p1cx7veat",
370 # Shortened lowercase NIC model name, useful for presentation.
371 NIC_CODE_TO_SHORT_NAME = {
372 u"10ge2p1x520": u"x520",
373 u"10ge2p1x710": u"x710",
374 u"40ge2p1xl710": u"xl710",
375 u"25ge2p1xxv710": u"xxv710",
376 u"25ge2p1e810xxv": u"e810xxv",
377 u"25ge2p1e822cq": u"e822cq",
378 u"100ge2p1e810cq": u"e810cq",
379 u"50ge1p1ena": u"ena",
380 u"100ge1p1ena": u"ena100",
381 u"200ge1p1ena": u"ena200",
382 u"100ge2p1cx556a": u"cx556a",
383 u"100ge2p1cx6dx": u"cx6dx",
384 u"200ge2p1cx7veat": u"cx7veat",
387 # Not each driver is supported by each NIC.
388 NIC_NAME_TO_DRIVER = {
389 u"Intel-X520-DA2": [u"vfio-pci", u"af_xdp"],
390 u"Intel-X710": [u"vfio-pci", u"avf", u"af_xdp"],
391 u"Intel-XL710": [u"vfio-pci", u"avf", u"af_xdp"],
392 u"Intel-XXV710": [u"vfio-pci", u"avf", u"af_xdp"],
393 u"Intel-E810XXV": [u"vfio-pci", u"avf", u"af_xdp"],
394 u"Intel-E822CQ": [u"vfio-pci", u"avf", u"af_xdp"],
395 u"Intel-E810CQ": [u"vfio-pci", u"avf", u"af_xdp"],
396 u"Amazon-Nitro-50G": [u"vfio-pci"],
397 u"Amazon-Nitro-100G": [u"vfio-pci"],
398 u"Amazon-Nitro-200G": [u"vfio-pci"],
399 u"Mellanox-CX556A": [u"rdma-core", u"mlx5_core", u"af_xdp"],
400 u"Mellanox-CX6DX": [u"rdma-core", u"mlx5_core", u"af_xdp"],
401 u"Mellanox-CX7VEAT": [u"rdma-core", u"mlx5_core", u"af_xdp"],
404 # Each driver needs different plugin to work.
405 NIC_DRIVER_TO_PLUGINS = {
406 u"vfio-pci": u"dpdk_plugin.so",
407 u"avf": u"avf_plugin.so",
408 u"rdma-core": u"rdma_plugin.so",
409 u"mlx5_core": u"dpdk_plugin.so",
410 u"af_xdp": u"af_xdp_plugin.so",
413 # Tags to differentiate tests for different NIC driver.
414 NIC_DRIVER_TO_TAG = {
415 u"vfio-pci": u"DRV_VFIO_PCI",
417 u"rdma-core": u"DRV_RDMA_CORE",
418 u"mlx5_core": u"DRV_MLX5_CORE",
419 u"af_xdp": u"DRV_AF_XDP",
422 # Suite names have to be different, add prefix.
423 NIC_DRIVER_TO_SUITE_PREFIX = {
426 u"rdma-core": u"rdma-",
427 u"mlx5_core": u"mlx5-",
428 u"af_xdp": u"af-xdp-",
431 # Number of virtual functions of physical nic.
432 NIC_DRIVER_TO_VFS = {
433 u"vfio-pci": u"nic_vfs}= | 0",
434 u"avf": u"nic_vfs}= | 1",
435 u"rdma-core": u"nic_vfs}= | 0",
436 u"mlx5_core": u"nic_vfs}= | 0",
437 u"af_xdp": u"nic_vfs}= | 0",
440 # Not each driver is supported by each NIC.
441 DPDK_NIC_NAME_TO_DRIVER = {
442 u"Intel-X520-DA2": [u"vfio-pci"],
443 u"Intel-X710": [u"vfio-pci"],
444 u"Intel-XL710": [u"vfio-pci"],
445 u"Intel-XXV710": [u"vfio-pci"],
446 u"Intel-E810XXV": [u"vfio-pci"],
447 u"Intel-E822CQ": [u"vfio-pci"],
448 u"Intel-E810CQ": [u"vfio-pci"],
449 u"Amazon-Nitro-50G": [u"vfio-pci"],
450 u"Amazon-Nitro-100G": [u"vfio-pci"],
451 u"Amazon-Nitro-200G": [u"vfio-pci"],
452 u"Mellanox-CX556A": [u"mlx5_core"],
453 u"Mellanox-CX6DX": [u"mlx5_core"],
454 u"Mellanox-CX7VEAT": [u"mlx5_core"],
457 # Tags to differentiate tests for different NIC driver.
458 DPDK_NIC_DRIVER_TO_TAG = {
459 u"vfio-pci": u"DRV_VFIO_PCI",
460 u"mlx5_core": u"DRV_MLX5_CORE",
463 # Suite names have to be different, add prefix.
464 DPDK_NIC_DRIVER_TO_SUITE_PREFIX = {
466 u"mlx5_core": u"mlx5-",
469 # Some identifiers constructed from suite names
470 # have to be independent of NIC driver used.
471 # In order to remove or reject the NIC driver part,
472 # it is useful to have a list of such prefixes precomputed.
473 FORBIDDEN_SUITE_PREFIX_LIST = [
474 prefix for prefix in NIC_DRIVER_TO_SUITE_PREFIX.values() if prefix
476 FORBIDDEN_SUITE_PREFIX_LIST += [
477 prefix for prefix in DPDK_NIC_DRIVER_TO_SUITE_PREFIX.values() if prefix
480 # TODO CSIT-1481: Crypto HW should be read from topology file instead.
481 NIC_NAME_TO_CRYPTO_HW = {
482 u"Intel-E810CQ": u"HW_4xxx",
483 u"Intel-E822CQ": u"HW_C4xxx",
484 u"Intel-X710": u"HW_DH895xcc",
485 u"Intel-XL710": u"HW_DH895xcc",
488 DEVICE_TYPE_TO_KEYWORD = {
492 PERF_TYPE_TO_KEYWORD = {
493 u"mrr": u"Traffic should pass with maximum rate",
494 u"ndrpdr": u"Find NDR and PDR intervals using optimized search",
495 u"soak": u"Find critical load using PLRsearch",
498 PERF_TYPE_TO_SUITE_DOC_VER = {
499 u"mrr": u'''fication:** In MaxReceivedRate tests TG sends traffic at \\
500 | ... | line rate and reports total received packets over trial period. \\''',
501 u"ndrpdr": u'''rification:** TG finds and reports throughput NDR (Non \\
502 | ... | Drop Rate) with zero packet loss tolerance and throughput PDR \\
503 | ... | (Partial Drop Rate) with non-zero packet loss tolerance (LT) \\
504 | ... | expressed in percentage of packets transmitted. NDR and PDR are \\
505 | ... | discovered for different Ethernet L2 frame sizes using MLRsearch \\
507 u"soak": u'''rification:** TG sends traffic at dynamically computed \\
508 | ... | rate as PLRsearch algorithm gathers data and improves its estimate \\
509 | ... | of a rate at which a prescribed small fraction of packets \\
510 | ... | would be lost. After set time, the serarch stops \\
511 | ... | and the algorithm reports its current estimate. \\''',
514 PERF_TYPE_TO_TEMPLATE_DOC_VER = {
515 u"mrr": u'''Measure MaxReceivedRate for ${frame_size}B frames \\
516 | | ... | using burst trials throughput test. \\''',
517 u"ndrpdr": u"Measure NDR and PDR values using MLRsearch algorithm.",
518 u"soak": u"Estimate critical rate using PLRsearch algorithm. \\",