函数逻辑报告

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source Code:kernel\bpf\devmap.c Create Date:2022-07-27 14:39:35
Last Modify:2020-03-12 14:18:49 Copyright©Brick
首页 函数Tree
注解内核,赢得工具下载SCCTEnglish

函数名称:dev_map_init_map

函数原型:static int dev_map_init_map(struct bpf_dtab *dtab, union bpf_attr *attr)

返回类型:int

参数:

类型参数名称
struct bpf_dtab *dtab
union bpf_attr *attr
116  如果 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的反则返回:负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  如果 one of enum bpf_map_type 恒等于BPF_MAP_TYPE_DEVMAP_HASH
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  如果非n_buckets则返回:负EINVAL
136  cost加等于sizeof(structhlist_head)乘n_buckets
137  否则
138  cost加等于max_entries乘*的长度
142  err等于bpf_map_charge_init( & memory, cost)
143  如果err则返回:负EINVAL
146  flush_list等于alloc_percpu(structlist_head)
147  如果非flush_list则转到:free_charge
150  遍历可用CPU(cpu)
151  初始化链表头
153  如果 one of enum bpf_map_type 恒等于BPF_MAP_TYPE_DEVMAP_HASH
154  these are only used for DEVMAP_HASH type maps 等于dev_map_create_hash(n_buckets)
155  如果非 these are only used for DEVMAP_HASH type maps 则转到:free_percpu
158  spin_lock_init( & index_lock)
159  否则
160  DEVMAP type only 等于bpf_map_area_alloc(max_entries * *的长度, numa_node)
163  如果非 DEVMAP type only 则转到:free_percpu
167  返回:0
169  free_percpu :
170  释放内存
171  free_charge :
172  bpf_map_charge_finish( & memory)
173  返回:负ENOMEM
调用者
名称描述
dev_map_alloc