| Function report | 
| 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 activity | Download SCCT | Chinese | 
Name:dev_map_init_map
Proto:static int dev_map_init_map(struct bpf_dtab *dtab, union bpf_attr *attr)
Type:int
Parameter:
| Type | Parameter | Name | 
|---|---|---|
| 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 | 
| 136 | cost += sizeof(structhlist_head) * n_buckets | 
| 137 | Else | 
| 138 | cost += max_entries * size of * | 
| 142 | err = bpf_map_charge_init( & memory, cost) | 
| 146 | flush_list = alloc_percpu(structlist_head) | 
| 147 | If Not flush_list Then Go to free_charge | 
| 150 | for_each_possible_cpu(cpu) | 
| 153 | If one of enum bpf_map_type == BPF_MAP_TYPE_DEVMAP_HASH Then | 
| 155 | If Not these are only used for DEVMAP_HASH type maps Then Go to free_percpu | 
| 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 : | 
| 171 | free_charge : | 
| 172 | bpf_map_charge_finish( & memory) | 
| 173 | Return -ENOMEM | 
| Name | Describe | 
|---|---|
| dev_map_alloc | 
| Source code conversion tool public plug-in interface | X | 
|---|---|
| Support c/c++/esqlc/java Oracle/Informix/Mysql Plug-in can realize: logical Report Code generation and batch code conversion |