xref: /linux/tools/testing/selftests/bpf/progs/update_map_in_htab.c (revision 25768de50b1f2dbb6ea44bd5148a87fe2c9c3688)
1*cb55657cSHou Tao // SPDX-License-Identifier: GPL-2.0
2*cb55657cSHou Tao /* Copyright (C) 2024. Huawei Technologies Co., Ltd */
3*cb55657cSHou Tao #include <linux/bpf.h>
4*cb55657cSHou Tao #include <bpf/bpf_helpers.h>
5*cb55657cSHou Tao 
6*cb55657cSHou Tao struct inner_map_type {
7*cb55657cSHou Tao 	__uint(type, BPF_MAP_TYPE_ARRAY);
8*cb55657cSHou Tao 	__uint(key_size, 4);
9*cb55657cSHou Tao 	__uint(value_size, 4);
10*cb55657cSHou Tao 	__uint(max_entries, 1);
11*cb55657cSHou Tao } inner_map SEC(".maps");
12*cb55657cSHou Tao 
13*cb55657cSHou Tao struct {
14*cb55657cSHou Tao 	__uint(type, BPF_MAP_TYPE_HASH_OF_MAPS);
15*cb55657cSHou Tao 	__type(key, int);
16*cb55657cSHou Tao 	__type(value, int);
17*cb55657cSHou Tao 	__uint(max_entries, 2);
18*cb55657cSHou Tao 	__array(values, struct inner_map_type);
19*cb55657cSHou Tao } outer_htab_map SEC(".maps");
20*cb55657cSHou Tao 
21*cb55657cSHou Tao struct {
22*cb55657cSHou Tao 	__uint(type, BPF_MAP_TYPE_HASH_OF_MAPS);
23*cb55657cSHou Tao 	__uint(map_flags, BPF_F_NO_PREALLOC);
24*cb55657cSHou Tao 	__type(key, int);
25*cb55657cSHou Tao 	__type(value, int);
26*cb55657cSHou Tao 	__uint(max_entries, 2);
27*cb55657cSHou Tao 	__array(values, struct inner_map_type);
28*cb55657cSHou Tao } outer_alloc_htab_map SEC(".maps");
29*cb55657cSHou Tao 
30*cb55657cSHou Tao char _license[] SEC("license") = "GPL";
31