Lines Matching +full:key +full:- +full:1
1 // SPDX-License-Identifier: GPL-2.0-only
24 map_key_t key; in map_populate() local
29 for (key = 1; key <= num; key++) { in map_populate()
30 err = bpf_map_update_elem(map_fd, &key, value, BPF_NOEXIST); in map_populate()
32 return -1; in map_populate()
48 err = bpf_map__set_type(skel->maps.hashmap1, map_type); in setup()
52 err = bpf_map__set_max_entries(skel->maps.hashmap1, map_sz); in setup()
60 *map_fd = bpf_map__fd(skel->maps.hashmap1); in setup()
77 /* executes bpf program that updates map with key, value */
78 static int prog_run_insert_elem(struct test_map_init *skel, map_key_t key, in prog_run_insert_elem() argument
83 bss = skel->bss; in prog_run_insert_elem()
85 bss->inKey = key; in prog_run_insert_elem()
86 bss->inValue = value; in prog_run_insert_elem()
87 bss->inPid = getpid(); in prog_run_insert_elem()
90 return -1; in prog_run_insert_elem()
110 return -1; in check_values_one_cpu()
115 if (CHECK(nzCnt != 1, "map value", "set for %d CPUs instead of 1!\n", in check_values_one_cpu()
117 return -1; in check_values_one_cpu()
122 /* Add key=1 elem with values set for all CPUs
123 * Delete elem key=1
124 * Run bpf prog that inserts new key=1 elem with value=0x1234
126 * Lookup Key=1 and check value is as expected for all CPUs:
134 map_key_t key; in test_pcpu_map_init() local
136 /* max 1 elem in map so insertion is forced to reuse freed entry */ in test_pcpu_map_init()
137 skel = setup(BPF_MAP_TYPE_PERCPU_HASH, 1, &map_fd, 1); in test_pcpu_map_init()
141 /* delete element so the entry can be re-used*/ in test_pcpu_map_init()
142 key = 1; in test_pcpu_map_init()
143 err = bpf_map_delete_elem(map_fd, &key); in test_pcpu_map_init()
147 /* run bpf prog that inserts new elem, re-using the slot just freed */ in test_pcpu_map_init()
148 err = prog_run_insert_elem(skel, key, TEST_VALUE); in test_pcpu_map_init()
152 /* check that key=1 was re-created by bpf prog */ in test_pcpu_map_init()
153 err = bpf_map_lookup_elem(map_fd, &key, value); in test_pcpu_map_init()
164 /* Add key=1 and key=2 elems with values set for all CPUs
165 * Run bpf prog that inserts new key=3 elem
167 * Lookup Key=1 and check value is as expected for all CPUs
174 map_key_t key; in test_pcpu_lru_map_init() local
183 /* run bpf prog that inserts new key=3 element, re-using LRU slot */ in test_pcpu_lru_map_init()
184 key = 3; in test_pcpu_lru_map_init()
185 err = prog_run_insert_elem(skel, key, TEST_VALUE); in test_pcpu_lru_map_init()
189 /* check that key=3 replaced one of earlier elements */ in test_pcpu_lru_map_init()
190 err = bpf_map_lookup_elem(map_fd, &key, value); in test_pcpu_lru_map_init()
204 if (nr_cpus <= 1) { in test_map_init()
205 printf("%s:SKIP: >1 cpu needed for this test\n", __func__); in test_map_init()