| 144 | } |
| 145 | |
| 146 | static inline uint64_t |
| 147 | bpf_exec(const struct rte_bpf *bpf, uint64_t reg[EBPF_REG_NUM]) |
| 148 | { |
| 149 | const struct ebpf_insn *ins; |
| 150 | |
| 151 | for (ins = bpf->prm.ins; ; ins++) { |
| 152 | switch (ins->code) { |
| 153 | /* 32 bit ALU IMM operations */ |
| 154 | case (BPF_ALU | BPF_ADD | BPF_K): |
| 155 | BPF_OP_ALU_IMM(reg, ins, +, uint32_t); |
| 156 | break; |
| 157 | case (BPF_ALU | BPF_SUB | BPF_K): |
| 158 | BPF_OP_ALU_IMM(reg, ins, -, uint32_t); |
| 159 | break; |
| 160 | case (BPF_ALU | BPF_AND | BPF_K): |
| 161 | BPF_OP_ALU_IMM(reg, ins, &, uint32_t); |
| 162 | break; |
| 163 | case (BPF_ALU | BPF_OR | BPF_K): |
| 164 | BPF_OP_ALU_IMM(reg, ins, |, uint32_t); |
| 165 | break; |
| 166 | case (BPF_ALU | BPF_LSH | BPF_K): |
| 167 | BPF_OP_ALU_IMM(reg, ins, <<, uint32_t); |
| 168 | break; |
| 169 | case (BPF_ALU | BPF_RSH | BPF_K): |
| 170 | BPF_OP_ALU_IMM(reg, ins, >>, uint32_t); |
| 171 | break; |
| 172 | case (BPF_ALU | BPF_XOR | BPF_K): |
| 173 | BPF_OP_ALU_IMM(reg, ins, ^, uint32_t); |
| 174 | break; |
| 175 | case (BPF_ALU | BPF_MUL | BPF_K): |
| 176 | BPF_OP_ALU_IMM(reg, ins, *, uint32_t); |
| 177 | break; |
| 178 | case (BPF_ALU | BPF_DIV | BPF_K): |
| 179 | BPF_OP_ALU_IMM(reg, ins, /, uint32_t); |
| 180 | break; |
| 181 | case (BPF_ALU | BPF_MOD | BPF_K): |
| 182 | BPF_OP_ALU_IMM(reg, ins, %, uint32_t); |
| 183 | break; |
| 184 | case (BPF_ALU | EBPF_MOV | BPF_K): |
| 185 | EBPF_MOV_ALU_IMM(reg, ins, uint32_t); |
| 186 | break; |
| 187 | /* 32 bit ALU REG operations */ |
| 188 | case (BPF_ALU | BPF_ADD | BPF_X): |
| 189 | BPF_OP_ALU_REG(reg, ins, +, uint32_t); |
| 190 | break; |
| 191 | case (BPF_ALU | BPF_SUB | BPF_X): |
| 192 | BPF_OP_ALU_REG(reg, ins, -, uint32_t); |
| 193 | break; |
| 194 | case (BPF_ALU | BPF_AND | BPF_X): |
| 195 | BPF_OP_ALU_REG(reg, ins, &, uint32_t); |
| 196 | break; |
| 197 | case (BPF_ALU | BPF_OR | BPF_X): |
| 198 | BPF_OP_ALU_REG(reg, ins, |, uint32_t); |
| 199 | break; |
| 200 | case (BPF_ALU | BPF_LSH | BPF_X): |
| 201 | BPF_OP_ALU_REG(reg, ins, <<, uint32_t); |
| 202 | break; |
| 203 | case (BPF_ALU | BPF_RSH | BPF_X): |
no test coverage detected