Re: [RFC PATCH 1/6] perf bpf: Add headers for generate bpf bytecode

From: Alexei Starovoitov
Date: Tue May 05 2015 - 18:38:51 EST


On 5/5/15 3:10 AM, He Kuang wrote:
Including bpf instruction macros and register alias.

Signed-off-by: He Kuang <hekuang@xxxxxxxxxx>
---
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/

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/