Messages in this thread | | | Date | Tue, 05 May 2015 15:38:42 -0700 | From | Alexei Starovoitov <> | Subject | Re: [RFC PATCH 1/6] perf bpf: Add headers for generate bpf bytecode |
| |
On 5/5/15 3:10 AM, He Kuang wrote: > Including bpf instruction macros and register alias. > > Signed-off-by: He Kuang <hekuang@huawei.com> > --- > tools/perf/util/bpf-loader.h | 188 +++++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 188 insertions(+) > > diff --git a/tools/perf/util/bpf-loader.h b/tools/perf/util/bpf-loader.h > index baa4404..840f96d 100644 > --- a/tools/perf/util/bpf-loader.h > +++ b/tools/perf/util/bpf-loader.h > @@ -70,4 +70,192 @@ struct bpf_obj { > } elf; > }; > #define obj_elf_valid(o) ((o)->elf.fd >= 0) > + > +/* ALU ops on registers, bpf_add|sub|...: dst_reg += src_reg */ > + > +#define BPF_ALU64_REG(OP, DST, SRC) \ > + ((struct bpf_insn) { \ > + .code = BPF_ALU64 | BPF_OP(OP) | BPF_X, \ > + .dst_reg = DST, \ > + .src_reg = SRC, \ > + .off = 0, \ > + .imm = 0 })
this is massive copy-paste from samples/bpf/libbpf.h let's create a proper library out of it and place into tools/lib/bpf/
| |