Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source Code:kernel\bpf\devmap.c Create Date:2022-07-28 13:21:54
Last Modify:2020-03-12 14:18:49 Copyright©Brick
home page Tree
Annotation kernel can get tool activityDownload SCCTChinese

Name:dev_map_init_map

Proto:static int dev_map_init_map(struct bpf_dtab *dtab, union bpf_attr *attr)

Type:int

Parameter:

TypeParameterName
struct bpf_dtab *dtab
union bpf_attr *attr
116  If max number of entries in a map == 0 || size of key in bytes != 4 || size of value in bytes != 4 || BPF_MAP_CREATE related * flags defined above. & ~DEV_CREATE_FLAG_MASK Then Return -EINVAL
123  BPF_MAP_CREATE related * flags defined above. |= Flags for accessing BPF object from program side.
126  bpf_map_init_from_attr( & map, attr)
129  cost = sizeof(structlist_head) * num_possible_cpus()
131  If one of enum bpf_map_type == BPF_MAP_TYPE_DEVMAP_HASH Then
132  n_buckets = undup_pow_of_two - round the given value up to nearest power of two*@n: parameter* round the given value up to the nearest power of two* - the result is undefined when n == 0* - this can be used to initialise global variables from constant data(max_entries)
134  If Not n_buckets Then Return -EINVAL
136  cost += sizeof(structhlist_head) * n_buckets
137  Else
138  cost += max_entries * size of *
142  err = bpf_map_charge_init( & memory, cost)
143  If err Then Return -EINVAL
146  flush_list = alloc_percpu(structlist_head)
147  If Not flush_list Then Go to free_charge
150  for_each_possible_cpu(cpu)
151  Initialization list head
153  If one of enum bpf_map_type == BPF_MAP_TYPE_DEVMAP_HASH Then
154  these are only used for DEVMAP_HASH type maps = dev_map_create_hash(n_buckets)
155  If Not these are only used for DEVMAP_HASH type maps Then Go to free_percpu
158  Process spin lock initialization( & index_lock)
159  Else
160  DEVMAP type only = bpf_map_area_alloc(max_entries * size of * , numa_node)
163  If Not DEVMAP type only Then Go to free_percpu
167  Return 0
169  free_percpu :
170  free previously allocated percpu memory
171  free_charge :
172  bpf_map_charge_finish( & memory)
173  Return -ENOMEM
Caller
NameDescribe
dev_map_alloc