Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

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

Name:array_of_map_gen_lookup

Proto:static u32 array_of_map_gen_lookup(struct bpf_map *map, struct bpf_insn *insn_buf)

Type:u32

Parameter:

TypeParameterName
struct bpf_map *map
struct bpf_insn *insn_buf
1045  array = container_of - cast a member of a structure out to the containing structure*@ptr: the pointer to the member.*@type: the type of the container struct this is embedded in.*@member: the name of the member within the struct.(map, structbpf_array, map)
1046  elem_size = und_up - round up to next specified power of 2*@x: the value to round*@y: multiple to round up to (must be a power of 2)* Rounds @x up to next multiple of @y (which must be a power of 2).* To perform arbitrary rounding up, use roundup() below.(value_size, 8)
1047  insn = insn_buf
1048  ret = BPF_REG_0
1049  map_ptr = BPF_REG_1
1050  index = BPF_REG_2
1052  insn++ = ALU ops on immediates, bpf_add|sub|...: dst_reg += imm32 (BPF_ADD, map_ptr, offsetof(structbpf_array, value))
1053  insn++ = Memory load, dst_reg = *(uint *) (src_reg + off16) (32-bit , ret, index, 0)
1054  If unpriv_array Then
1055  insn++ = Conditional jumps against immediates, if (dst_reg 'op' imm32) goto pc + off16 (BPF_JGE, ret, max_entries, 6)
1056  insn++ = BPF_ALU32_IMM(BPF_AND, ret, index_mask)
1057  Else
1058  insn++ = Conditional jumps against immediates, if (dst_reg 'op' imm32) goto pc + off16 (BPF_JGE, ret, max_entries, 5)
1060  If s_power_of_2() - check if a value is a power of two*@n: the value to check* Determine whether some value is a power of two, where zero is* *not* considered a power of two.* Return: true if @n is a power of 2, otherwise false. Then insn++ = ALU ops on immediates, bpf_add|sub|...: dst_reg += imm32 (BPF_LSH, ret, log2 - log base 2 of 32-bit or a 64-bit unsigned value*@n: parameter* constant-capable log of base 2 calculation* - this can be used to initialise global variables from constant data, hence* the massive ternary operator construction* selects the (elem_size))
1062  Else insn++ = ALU ops on immediates, bpf_add|sub|...: dst_reg += imm32 (BPF_MUL, ret, elem_size)
1064  insn++ = ALU ops on registers, bpf_add|sub|...: dst_reg += src_reg (BPF_ADD, ret, map_ptr)
1065  insn++ = Memory load, dst_reg = *(uint *) (src_reg + off16) (double word (64-bit) , ret, ret, 0)
1066  insn++ = Conditional jumps against immediates, if (dst_reg 'op' imm32) goto pc + off16 (BPF_JEQ, ret, 0, 1)
1067  insn++ = Conditional jumps against immediates, if (dst_reg 'op' imm32) goto pc + off16 (BPF_JA, 0, 0, 1)
1068  insn++ = Short form of mov, dst_reg = imm32 (ret, 0)
1070  Return insn - insn_buf