* [PATCH] PPC: bpf_jit_comp: add SKF_AD_PKTTYPE instruction
@ 2014-10-26 19:23 Denis Kirjanov
2014-10-29 9:21 ` Denis Kirjanov
0 siblings, 1 reply; 6+ messages in thread
From: Denis Kirjanov @ 2014-10-26 19:23 UTC (permalink / raw)
To: netdev; +Cc: linuxppc-dev, Denis Kirjanov, Matt Evans
Cc: Matt Evans <matt@ozlabs.org>
Signed-off-by: Denis Kirjanov <kda@linux-powerpc.org>
---
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(+)
diff --git a/arch/powerpc/include/asm/ppc-opcode.h b/arch/powerpc/include/asm/ppc-opcode.h
index 6f85362..1a52877 100644
--- a/arch/powerpc/include/asm/ppc-opcode.h
+++ b/arch/powerpc/include/asm/ppc-opcode.h
@@ -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
diff --git a/arch/powerpc/net/bpf_jit.h b/arch/powerpc/net/bpf_jit.h
index 9aee27c..c406aa9 100644
--- a/arch/powerpc/net/bpf_jit.h
+++ b/arch/powerpc/net/bpf_jit.h
@@ -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)
diff --git a/arch/powerpc/net/bpf_jit_comp.c b/arch/powerpc/net/bpf_jit_comp.c
index cbae2df..d110e28 100644
--- a/arch/powerpc/net/bpf_jit_comp.c
+++ b/arch/powerpc/net/bpf_jit_comp.c
@@ -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
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] PPC: bpf_jit_comp: add SKF_AD_PKTTYPE instruction
2014-10-26 19:23 [PATCH] PPC: bpf_jit_comp: add SKF_AD_PKTTYPE instruction Denis Kirjanov
@ 2014-10-29 9:21 ` Denis Kirjanov
2014-10-29 17:08 ` Alexei Starovoitov
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Denis Kirjanov @ 2014-10-29 9:21 UTC (permalink / raw)
To: linuxppc-dev; +Cc: Denis Kirjanov, Matt Evans, netdev
Any feedback from PPC folks?
On 10/26/14, Denis Kirjanov <kda@linux-powerpc.org> wrote:
> Cc: Matt Evans <matt@ozlabs.org>
> Signed-off-by: Denis Kirjanov <kda@linux-powerpc.org>
> ---
> 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(+)
>
> diff --git a/arch/powerpc/include/asm/ppc-opcode.h
> b/arch/powerpc/include/asm/ppc-opcode.h
> index 6f85362..1a52877 100644
> --- a/arch/powerpc/include/asm/ppc-opcode.h
> +++ b/arch/powerpc/include/asm/ppc-opcode.h
> @@ -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
> diff --git a/arch/powerpc/net/bpf_jit.h b/arch/powerpc/net/bpf_jit.h
> index 9aee27c..c406aa9 100644
> --- a/arch/powerpc/net/bpf_jit.h
> +++ b/arch/powerpc/net/bpf_jit.h
> @@ -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)
> diff --git a/arch/powerpc/net/bpf_jit_comp.c
> b/arch/powerpc/net/bpf_jit_comp.c
> index cbae2df..d110e28 100644
> --- a/arch/powerpc/net/bpf_jit_comp.c
> +++ b/arch/powerpc/net/bpf_jit_comp.c
> @@ -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
>
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] PPC: bpf_jit_comp: add SKF_AD_PKTTYPE instruction
2014-10-29 9:21 ` Denis Kirjanov
@ 2014-10-29 17:08 ` Alexei Starovoitov
2014-10-30 4:44 ` Michael Ellerman
2014-11-03 15:45 ` Philippe Bergheaud
2 siblings, 0 replies; 6+ messages in thread
From: Alexei Starovoitov @ 2014-10-29 17:08 UTC (permalink / raw)
To: Denis Kirjanov; +Cc: linuxppc-dev, Matt Evans, netdev
On Wed, Oct 29, 2014 at 2:21 AM, Denis Kirjanov <kda@linux-powerpc.org> wrote:
> 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...
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] PPC: bpf_jit_comp: add SKF_AD_PKTTYPE instruction
2014-10-29 9:21 ` Denis Kirjanov
2014-10-29 17:08 ` Alexei Starovoitov
@ 2014-10-30 4:44 ` Michael Ellerman
2014-11-03 15:45 ` Philippe Bergheaud
2 siblings, 0 replies; 6+ messages in thread
From: Michael Ellerman @ 2014-10-30 4:44 UTC (permalink / raw)
To: Denis Kirjanov; +Cc: linuxppc-dev, netdev, Matt Evans
On Wed, 2014-10-29 at 13:21 +0400, Denis Kirjanov wrote:
> 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
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] PPC: bpf_jit_comp: add SKF_AD_PKTTYPE instruction
2014-10-29 9:21 ` Denis Kirjanov
2014-10-29 17:08 ` Alexei Starovoitov
2014-10-30 4:44 ` Michael Ellerman
@ 2014-11-03 15:45 ` Philippe Bergheaud
2014-11-03 18:04 ` Denis Kirjanov
2 siblings, 1 reply; 6+ messages in thread
From: Philippe Bergheaud @ 2014-11-03 15:45 UTC (permalink / raw)
To: Denis Kirjanov; +Cc: linuxppc-dev, netdev, Matt Evans, mpe
Denis Kirjanov wrote:
> 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
> On 10/26/14, Denis Kirjanov <kda@linux-powerpc.org> wrote:
>
>>Cc: Matt Evans <matt@ozlabs.org>
>>Signed-off-by: Denis Kirjanov <kda@linux-powerpc.org>
>>---
>> 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(+)
>>
>>diff --git a/arch/powerpc/include/asm/ppc-opcode.h
>>b/arch/powerpc/include/asm/ppc-opcode.h
>>index 6f85362..1a52877 100644
>>--- a/arch/powerpc/include/asm/ppc-opcode.h
>>+++ b/arch/powerpc/include/asm/ppc-opcode.h
>>@@ -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
>>diff --git a/arch/powerpc/net/bpf_jit.h b/arch/powerpc/net/bpf_jit.h
>>index 9aee27c..c406aa9 100644
>>--- a/arch/powerpc/net/bpf_jit.h
>>+++ b/arch/powerpc/net/bpf_jit.h
>>@@ -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)
>>diff --git a/arch/powerpc/net/bpf_jit_comp.c
>>b/arch/powerpc/net/bpf_jit_comp.c
>>index cbae2df..d110e28 100644
>>--- a/arch/powerpc/net/bpf_jit_comp.c
>>+++ b/arch/powerpc/net/bpf_jit_comp.c
>>@@ -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
>>
>>
>
> _______________________________________________
> Linuxppc-dev mailing list
> Linuxppc-dev@lists.ozlabs.org
> https://lists.ozlabs.org/listinfo/linuxppc-dev
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] PPC: bpf_jit_comp: add SKF_AD_PKTTYPE instruction
2014-11-03 15:45 ` Philippe Bergheaud
@ 2014-11-03 18:04 ` Denis Kirjanov
0 siblings, 0 replies; 6+ messages in thread
From: Denis Kirjanov @ 2014-11-03 18:04 UTC (permalink / raw)
To: Philippe Bergheaud; +Cc: linuxppc-dev, netdev, Matt Evans, mpe
On 11/3/14, Philippe Bergheaud <felix@linux.vnet.ibm.com> wrote:
> Denis Kirjanov wrote:
>> 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
>
> Philippe
>
>> On 10/26/14, Denis Kirjanov <kda@linux-powerpc.org> wrote:
>>
>>>Cc: Matt Evans <matt@ozlabs.org>
>>>Signed-off-by: Denis Kirjanov <kda@linux-powerpc.org>
>>>---
>>> 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(+)
>>>
>>>diff --git a/arch/powerpc/include/asm/ppc-opcode.h
>>>b/arch/powerpc/include/asm/ppc-opcode.h
>>>index 6f85362..1a52877 100644
>>>--- a/arch/powerpc/include/asm/ppc-opcode.h
>>>+++ b/arch/powerpc/include/asm/ppc-opcode.h
>>>@@ -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
>>>diff --git a/arch/powerpc/net/bpf_jit.h b/arch/powerpc/net/bpf_jit.h
>>>index 9aee27c..c406aa9 100644
>>>--- a/arch/powerpc/net/bpf_jit.h
>>>+++ b/arch/powerpc/net/bpf_jit.h
>>>@@ -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)
>>>diff --git a/arch/powerpc/net/bpf_jit_comp.c
>>>b/arch/powerpc/net/bpf_jit_comp.c
>>>index cbae2df..d110e28 100644
>>>--- a/arch/powerpc/net/bpf_jit_comp.c
>>>+++ b/arch/powerpc/net/bpf_jit_comp.c
>>>@@ -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
>>>
>>>
>>
>> _______________________________________________
>> Linuxppc-dev mailing list
>> Linuxppc-dev@lists.ozlabs.org
>> https://lists.ozlabs.org/listinfo/linuxppc-dev
>
>
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2014-11-03 18:04 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-10-26 19:23 [PATCH] PPC: bpf_jit_comp: add SKF_AD_PKTTYPE instruction Denis Kirjanov
2014-10-29 9:21 ` Denis Kirjanov
2014-10-29 17:08 ` Alexei Starovoitov
2014-10-30 4:44 ` Michael Ellerman
2014-11-03 15:45 ` Philippe Bergheaud
2014-11-03 18:04 ` Denis Kirjanov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).