PPC: bpf_jit_comp: add SKF_AD_HATYPE instruction
Subsystems (5)
PATCH 1/1 PPC: bpf_jit_comp: add SKF_AD_HATYPE instruction
Add BPF extension SKF_AD_HATYPE to ppc JIT to check the hw type of the interface
JIT off:
[ 69.106783] test_bpf: #20 LD_HATYPE 48 48 PASS JIT on: [ 64.721757] test_bpf: #20 LD_HATYPE 7 6 PASS
--- arch/powerpc/net/bpf_jit_comp.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)
arch/powerpc/net/bpf_jit_comp.c +16 -0
@@ -412,6 +412,22 @@ static int bpf_jit_build_body(struct bpf_prog *fp, u32 *image,PPC_ANDI (r_A, r_A,PKT_TYPE_MAX );PPC_SRWI (r_A, r_A,5 );break ; +case BPF_ANC |SKF_AD_HATYPE : + BUILD_BUG_ON(FIELD_SIZEOF(struct net_device, type) != 2); +PPC_LD_OFFS (r_scratch1, r_skb, offsetof(struct sk_buff , + dev)); +PPC_CMPDI (r_scratch1,0 ); +if (ctx->pc_ret0 !=-1 ) { +PPC_BCC (COND_EQ , addrs[ctx->pc_ret0]); + }else { +/* Exit, returning 0; first pass hits here. */ +PPC_BCC_SHORT (COND_NE , (ctx->idx*4 )+12 ); +PPC_LI (r_ret,0 ); +PPC_JMP (exit_addr); + } +PPC_LHZ_OFFS (r_A, r_scratch1, + offsetof(struct net_device , type)); +break ;case BPF_ANC |SKF_AD_CPU :#ifdef CONFIG_SMP /*
Signature · 1 line
2.1.0
David Miller
maintainerFrom: Denis Kirjanov <[email protected]>
Date: Thu, 6 Nov 2014 09:02:35 +0300
Quoted 4 lines
Add BPF extension
SKF_AD_HATYPEto ppc JIT to check the hw type of the interfaceJIT off:
Quoted 8 lines
[ 69.106783] test_bpf: #20 LD_HATYPE 48 48 PASS JIT on: [ 64.721757] test_bpf: #20 LD_HATYPE 7 6 PASSCC Alexei Starovoitov<[email protected]>CC Daniel Borkmann<[email protected]>CC Philippe Bergheaud<[email protected]>Signed-off-by Denis Kirjanov <[email protected]>
Can I get some reviews please?
Thanks.
Quoted 24 lines · Denis Kirjanov
Add BPF extension
SKF_AD_HATYPEto ppc JIT to check the hw type of the interfaceJIT off:
[ 69.106783] test_bpf: #20 LD_HATYPE 48 48 PASS JIT on: [ 64.721757] test_bpf: #20 LD_HATYPE 7 6 PASSCC Alexei Starovoitov<[email protected]>CC Daniel Borkmann<[email protected]>CC Philippe Bergheaud<[email protected]>Signed-off-by Denis Kirjanov <[email protected]>--- arch/powerpc/net/bpf_jit_comp.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)arch/powerpc/net/bpf_jit_comp.c +0
-0@@ -412,6 +412,22 @@ static int bpf_jit_build_body(struct bpf_prog *fp, u32 *image,PPC_ANDI (r_A, r_A,PKT_TYPE_MAX );PPC_SRWI (r_A, r_A,5 );break ;
arch/powerpc/net/bpf_jit_comp.c static int bpf_jit_build_body(struct bpf_prog *fp, u32 *image, · line 424
Quoted 10 lines
arch/powerpc/net/bpf_jit_comp.c +10
-0+case BPF_ANC |SKF_AD_HATYPE : + BUILD_BUG_ON(FIELD_SIZEOF(struct net_device, type) != 2); +PPC_LD_OFFS (r_scratch1, r_skb, offsetof(struct sk_buff , + dev)); +PPC_CMPDI (r_scratch1,0 ); +if (ctx->pc_ret0 !=-1 ) { +PPC_BCC (COND_EQ , addrs[ctx->pc_ret0]); + }else { +/* Exit, returning 0; first pass hits here. */ +PPC_BCC_SHORT (COND_NE , (ctx->idx*4 )+12 );
please use canonical formatting ctx->idx * 4 + 12
arch/powerpc/net/bpf_jit_comp.c static int bpf_jit_build_body(struct bpf_prog *fp, u32 *image, · line 429
Quoted 5 lines
arch/powerpc/net/bpf_jit_comp.c +5
-0+PPC_LI (r_ret,0 ); +PPC_JMP (exit_addr); + } +PPC_LHZ_OFFS (r_A, r_scratch1, + offsetof(struct net_device , type));
the whole thing looks like copy paste from 'case ifindex'. Would be nice to handle them together to reduce duplicated code, sine only last load is different.
Also in commit log please do _both_ runs with JIT on. You should see a difference before/after applying this patch.