PPC: bpf_jit_comp: add SKF_AD_PKTTYPE instruction
Subsystems (5)
PATCH 1/1 PPC: bpf_jit_comp: add SKF_AD_PKTTYPE instruction
--- arch/powerpc/include/asm/ppc-opcode.h | 1 + arch/powerpc/net/bpf_jit.h | 7 +++++++ arch/powerpc/net/bpf_jit_comp.c | 5 +++++ 3 files changed, 13 insertions(+)
arch/powerpc/include/asm/ppc-opcode.h +1 -0
@@ -204,6 +204,7 @@#define PPC_INST_ERATSX_DOT 0x7c000127/* Misc instructions for BPF compiler */ +#define PPC_INST_LBZ 0x88000000#define PPC_INST_LD 0xe8000000#define PPC_INST_LHZ 0xa0000000#define PPC_INST_LHBRX 0x7c00062c
arch/powerpc/net/bpf_jit.h +7 -0
@@ -87,6 +87,9 @@ DECLARE_LOAD_FUNC(sk_load_byte_msh);#define PPC_STD (r, base, i) EMIT(PPC_INST_STD | ___PPC_RS(r) | \ ___PPC_RA(base) | ((i) & 0xfffc)) + +#define PPC_LBZ (r, base, i) EMIT(PPC_INST_LBZ | ___PPC_RT(r) | \ + ___PPC_RA(base) | IMM_L(i))#define PPC_LD (r, base, i) EMIT(PPC_INST_LD | ___PPC_RT(r) | \ ___PPC_RA(base) | IMM_L(i))#define PPC_LWZ (r, base, i) EMIT(PPC_INST_LWZ | ___PPC_RT(r) | \
@@ -96,6 +99,10 @@ DECLARE_LOAD_FUNC(sk_load_byte_msh);#define PPC_LHBRX (r, base, b) EMIT(PPC_INST_LHBRX | ___PPC_RT(r) | \ ___PPC_RA(base) | ___PPC_RB(b))/* Convenience helpers for the above with 'far' offsets: */ +#define PPC_LBZ_OFFS (r, base, i) do { if ((i) < 32768) PPC_LBZ(r, base, i); \ + else { PPC_ADDIS(r, base, IMM_HA(i)); \ + PPC_LBZ(r, r, IMM_L(i)); } } while(0) +#define PPC_LD_OFFS (r, base, i) do { if ((i) < 32768) PPC_LD(r, base, i); \ else { PPC_ADDIS(r, base, IMM_HA(i)); \ PPC_LD(r, r, IMM_L(i)); } } while(0)
arch/powerpc/net/bpf_jit_comp.c +5 -0
@@ -407,6 +407,11 @@ static int bpf_jit_build_body(struct bpf_prog *fp, u32 *image,PPC_LHZ_OFFS (r_A, r_skb, offsetof(struct sk_buff , queue_mapping));break ; +case BPF_ANC |SKF_AD_PKTTYPE : +PPC_LBZ_OFFS (r_A, r_skb,PKT_TYPE_OFFSET ()); +PPC_ANDI (r_A, r_A,PKT_TYPE_MAX ); +PPC_SRWI (r_A, r_A,5 ); +break ;case BPF_ANC |SKF_AD_CPU :#ifdef CONFIG_SMP /*
Signature · 1 line
2.1.0
Any feedback from PPC folks?
Quoted 70 lines · Denis Kirjanov
Cc Matt Evans <[email protected]>Signed-off-by Denis Kirjanov <[email protected]>--- arch/powerpc/include/asm/ppc-opcode.h | 1 + arch/powerpc/net/bpf_jit.h | 7 +++++++ arch/powerpc/net/bpf_jit_comp.c | 5 +++++ 3 files changed, 13 insertions(+)arch/powerpc/include/asm/ppc-opcode.h +1
-0@@ -204,6 +204,7 @@#define PPC_INST_ERATSX_DOT 0x7c000127/* Misc instructions for BPF compiler */ +#define PPC_INST_LBZ 0x88000000#define PPC_INST_LD 0xe8000000#define PPC_INST_LHZ 0xa0000000#define PPC_INST_LHBRX 0x7c00062carch/powerpc/net/bpf_jit.h +7
-0@@ -87,6 +87,9 @@ DECLARE_LOAD_FUNC(sk_load_byte_msh);#define PPC_STD (r, base, i) EMIT(PPC_INST_STD | ___PPC_RS(r) | \ ___PPC_RA(base) | ((i) & 0xfffc)) + +#define PPC_LBZ (r, base, i) EMIT(PPC_INST_LBZ | ___PPC_RT(r) | \ + ___PPC_RA(base) | IMM_L(i))#define PPC_LD (r, base, i) EMIT(PPC_INST_LD | ___PPC_RT(r) | \ ___PPC_RA(base) | IMM_L(i))#define PPC_LWZ (r, base, i) EMIT(PPC_INST_LWZ | ___PPC_RT(r) | \@@ -96,6 +99,10 @@ DECLARE_LOAD_FUNC(sk_load_byte_msh);#define PPC_LHBRX (r, base, b) EMIT(PPC_INST_LHBRX | ___PPC_RT(r) | \ ___PPC_RA(base) | ___PPC_RB(b))/* Convenience helpers for the above with 'far' offsets: */ +#define PPC_LBZ_OFFS (r, base, i) do { if ((i) < 32768) PPC_LBZ(r, base, i); \ + else { PPC_ADDIS(r, base, IMM_HA(i)); \ + PPC_LBZ(r, r, IMM_L(i)); } } while(0) +#define PPC_LD_OFFS (r, base, i) do { if ((i) < 32768) PPC_LD(r, base, i); \arch/powerpc/net/bpf_jit.h +0
-0else {PPC_ADDIS (r, base,IMM_HA (i)); \PPC_LD (r, r,IMM_L (i)); } }while (0 )arch/powerpc/net/bpf_jit_comp.c +5
-0@@ -407,6 +407,11 @@ static int bpf_jit_build_body(struct bpf_prog *fp, u32 *image,PPC_LHZ_OFFS (r_A, r_skb, offsetof(struct sk_buff , queue_mapping));break ; +case BPF_ANC |SKF_AD_PKTTYPE : +PPC_LBZ_OFFS (r_A, r_skb,PKT_TYPE_OFFSET ()); +PPC_ANDI (r_A, r_A,PKT_TYPE_MAX ); +PPC_SRWI (r_A, r_A,5 ); +break ;case BPF_ANC |SKF_AD_CPU :#ifdef CONFIG_SMP /*
--
2.1.0
Quoted 1 line · Denis Kirjanov
Any feedback from PPC folks?
not a ppc guy, but looks reasonable to me.
What lib/test_bpf says? Like performance difference before/after for LD_PKTTYPE test...
Michael Ellerman
reviewerQuoted 1 line · Denis Kirjanov
Any feedback from PPC folks?
Hi Denis,
I had a look at this, but I don't know enough about BPF to comment.
Maybe you can explain what a BPF_ANC | SKF_AD_PKTTYPE means and perhaps then we can guess if the code is correct.
I think testing it is the best option :)
cheers
Quoted 1 line · Denis Kirjanov
Any feedback from PPC folks?
I have reviewed the patch and it looks fine to me. I have tested successfuly on ppc64le.
I could not test it on ppc64.
Philippe
Quoted 77 lines · Denis Kirjanov
Quoted 67 lines
Cc Matt Evans <[email protected]>Signed-off-by Denis Kirjanov <[email protected]>---
arch/powerpc/include/asm/ppc-opcode.h | 1 + arch/powerpc/net/bpf_jit.h | 7 +++++++ arch/powerpc/net/bpf_jit_comp.c | 5 +++++ 3 files changed, 13 insertions(+)arch/powerpc/include/asm/ppc-opcode.h +1
-0@@ -204,6 +204,7 @@#define PPC_INST_ERATSX_DOT 0x7c000127/* Misc instructions for BPF compiler */ +#define PPC_INST_LBZ 0x88000000#define PPC_INST_LD 0xe8000000#define PPC_INST_LHZ 0xa0000000#define PPC_INST_LHBRX 0x7c00062carch/powerpc/net/bpf_jit.h +7
-0@@ -87,6 +87,9 @@ DECLARE_LOAD_FUNC(sk_load_byte_msh);#define PPC_STD (r, base, i) EMIT(PPC_INST_STD | ___PPC_RS(r) | \ ___PPC_RA(base) | ((i) & 0xfffc)) + +#define PPC_LBZ (r, base, i) EMIT(PPC_INST_LBZ | ___PPC_RT(r) | \ + ___PPC_RA(base) | IMM_L(i))#define PPC_LD (r, base, i) EMIT(PPC_INST_LD | ___PPC_RT(r) | \ ___PPC_RA(base) | IMM_L(i))#define PPC_LWZ (r, base, i) EMIT(PPC_INST_LWZ | ___PPC_RT(r) | \@@ -96,6 +99,10 @@ DECLARE_LOAD_FUNC(sk_load_byte_msh);#define PPC_LHBRX (r, base, b) EMIT(PPC_INST_LHBRX | ___PPC_RT(r) | \ ___PPC_RA(base) | ___PPC_RB(b))/* Convenience helpers for the above with 'far' offsets: */ +#define PPC_LBZ_OFFS (r, base, i) do { if ((i) < 32768) PPC_LBZ(r, base, i); \ + else { PPC_ADDIS(r, base, IMM_HA(i)); \ + PPC_LBZ(r, r, IMM_L(i)); } } while(0) +#define PPC_LD_OFFS (r, base, i) do { if ((i) < 32768) PPC_LD(r, base, i); \else { PPC_ADDIS(r, base, IMM_HA(i)); \ PPC_LD(r, r, IMM_L(i)); } } while(0)arch/powerpc/net/bpf_jit_comp.c +5
-0@@ -407,6 +407,11 @@ static int bpf_jit_build_body(struct bpf_prog *fp, u32 *image,PPC_LHZ_OFFS (r_A, r_skb, offsetof(struct sk_buff , queue_mapping));break ; +case BPF_ANC |SKF_AD_PKTTYPE : +PPC_LBZ_OFFS (r_A, r_skb,PKT_TYPE_OFFSET ()); +PPC_ANDI (r_A, r_A,PKT_TYPE_MAX ); +PPC_SRWI (r_A, r_A,5 ); +break ;case BPF_ANC |SKF_AD_CPU :#ifdef CONFIG_SMP /*Quoted 4 lines
--
2.1.0_______________________________________________
Linuxppc-dev mailing list
[email protected]
https://lists.ozlabs.org/listinfo/linuxppc-dev
Quoted 6 lines · Philippe Bergheaud
Quoted 1 line · Denis Kirjanov
Any feedback from PPC folks?
I have reviewed the patch and it looks fine to me. I have tested successfuly on ppc64le.
I could not test it on ppc64.
Nice, I've tested it on PPC64be
Quoted 86 lines
Philippe
Quoted 81 lines · Denis Kirjanov
Quoted 69 lines
Cc Matt Evans <[email protected]>Signed-off-by Denis Kirjanov <[email protected]>---
arch/powerpc/include/asm/ppc-opcode.h | 1 + arch/powerpc/net/bpf_jit.h | 7 +++++++ arch/powerpc/net/bpf_jit_comp.c | 5 +++++ 3 files changed, 13 insertions(+)arch/powerpc/include/asm/ppc-opcode.h +1
-0@@ -204,6 +204,7 @@#define PPC_INST_ERATSX_DOT 0x7c000127/* Misc instructions for BPF compiler */ +#define PPC_INST_LBZ 0x88000000#define PPC_INST_LD 0xe8000000#define PPC_INST_LHZ 0xa0000000#define PPC_INST_LHBRX 0x7c00062carch/powerpc/net/bpf_jit.h +7
-0@@ -87,6 +87,9 @@ DECLARE_LOAD_FUNC(sk_load_byte_msh);#define PPC_STD (r, base, i) EMIT(PPC_INST_STD | ___PPC_RS(r) | \ ___PPC_RA(base) | ((i) & 0xfffc)) + +#define PPC_LBZ (r, base, i) EMIT(PPC_INST_LBZ | ___PPC_RT(r) | \ + ___PPC_RA(base) | IMM_L(i))#define PPC_LD (r, base, i) EMIT(PPC_INST_LD | ___PPC_RT(r) | \ ___PPC_RA(base) | IMM_L(i))#define PPC_LWZ (r, base, i) EMIT(PPC_INST_LWZ | ___PPC_RT(r) | \@@ -96,6 +99,10 @@ DECLARE_LOAD_FUNC(sk_load_byte_msh);#define PPC_LHBRX (r, base, b) EMIT(PPC_INST_LHBRX | ___PPC_RT(r) | \ ___PPC_RA(base) | ___PPC_RB(b))/* Convenience helpers for the above with 'far' offsets: */ +#define PPC_LBZ_OFFS (r, base, i) do { if ((i) < 32768) PPC_LBZ(r, base, i); \ + else { PPC_ADDIS(r, base, IMM_HA(i)); \ +PPC_LBZ (r, r,IMM_L (i)); } }while (0 ) +#define
PPC_LD_OFFS(r, base, i)do { if ((i) < 32768)PPC_LD(r, base, i);\ else { PPC_ADDIS(r, base, IMM_HA(i)); \ PPC_LD(r, r, IMM_L(i)); } } while(0)arch/powerpc/net/bpf_jit_comp.c +0
-0@@ -407,6 +407,11 @@ static int bpf_jit_build_body(struct bpf_prog *fp,u32
*image,PPC_LHZ_OFFS(r_A, r_skb, offsetof(struct sk_buff, queue_mapping)); break;arch/powerpc/net/bpf_jit_comp.c +5
-0+case BPF_ANC |SKF_AD_PKTTYPE : +PPC_LBZ_OFFS (r_A, r_skb,PKT_TYPE_OFFSET ()); +PPC_ANDI (r_A, r_A,PKT_TYPE_MAX ); +PPC_SRWI (r_A, r_A,5 ); +break ;case
BPF_ANC|SKF_AD_CPU:Quoted 6 lines
#ifdef CONFIG_SMP /*--
2.1.0_______________________________________________
Linuxppc-dev mailing list
[email protected]
https://lists.ozlabs.org/listinfo/linuxppc-dev