1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2010-2014 Intel Corporation
9 #include <rte_memory.h>
10 #include <rte_common.h>
11 #include <rte_memzone.h>
19 * - Dump the mapped memory. The python-expect script checks that at
20 * least one line is dumped.
22 * - Check that memory size is different than 0.
24 * - Try to read all memory; it should not segfault.
28 check_mem(const struct rte_memseg_list *msl __rte_unused,
29 const struct rte_memseg *ms, void *arg __rte_unused)
31 volatile uint8_t *mem = (volatile uint8_t *) ms->addr;
32 size_t i, max = ms->len;
34 for (i = 0; i < max; i++, mem++)
40 check_seg_fds(const struct rte_memseg_list *msl, const struct rte_memseg *ms,
41 void *arg __rte_unused)
46 /* skip external segments */
50 /* try segment fd first. we're in a callback, so thread-unsafe */
51 ret = rte_memseg_get_fd_thread_unsafe(ms);
53 /* ENOTSUP means segment is valid, but there is not support for
54 * segment fd API (e.g. on FreeBSD).
58 /* all other errors are treated as failures */
62 /* we're able to get memseg fd - try getting its offset */
63 ret = rte_memseg_get_fd_offset_thread_unsafe(ms, &offset);
79 * dump the mapped memory: the python-expect script checks
80 * that at least one line is dumped
82 printf("Dump memory layout\n");
83 rte_dump_physmem_layout(stdout);
85 /* check that memory size is != 0 */
86 s = rte_eal_get_physmem_size();
88 printf("No memory detected\n");
92 /* try to read memory (should not segfault) */
93 rte_memseg_walk(check_mem, NULL);
95 /* check segment fd support */
96 ret = rte_memseg_walk(check_seg_fds, NULL);
98 printf("Segment fd API is unsupported\n");
99 } else if (ret == -1) {
100 printf("Error getting segment fd's\n");
107 REGISTER_TEST_COMMAND(memory_autotest, test_memory);