]> git.baikalelectronics.ru Git - kernel.git/commit
nfp: bpf: support u16 and u32 multiplications
authorJiong Wang <jiong.wang@netronome.com>
Fri, 6 Jul 2018 22:13:21 +0000 (15:13 -0700)
committerDaniel Borkmann <daniel@iogearbox.net>
Fri, 6 Jul 2018 23:45:31 +0000 (01:45 +0200)
commitbc042fbfc58805c6524119c1340fcdab575b02be
tree04f746d18f5dbdfd6cebee74ecf3f7afd7eedd01
parent1ae1f41fb41011f7732ff95fe52ae34fc18194fc
nfp: bpf: support u16 and u32 multiplications

NFP supports u16 and u32 multiplication. Multiplication is done 8-bits per
step, therefore we need 2 steps for u16 and 4 steps for u32.

We also need one start instruction to initialize the sequence and one or
two instructions to fetch the result depending on either you need the high
halve of u32 multiplication.

For ALU64, if either operand is beyond u32's value range, we reject it. One
thing to note, if the source operand is BPF_K, then we need to check "imm"
field directly, and we'd reject it if it is negative.  Because for ALU64,
"imm" (with s32 type) is expected to be sign extended to s64 which NFP mul
doesn't support. For ALU32, it is fine for "imm" be negative though,
because the result is 32-bits and here is no difference on the low halve
of result for signed/unsigned mul, so we will get correct result.

Signed-off-by: Jiong Wang <jiong.wang@netronome.com>
Reviewed-by: Jakub Kicinski <jakub.kicinski@netronome.com>
Acked-by: Song Liu <songliubraving@fb.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
drivers/net/ethernet/netronome/nfp/bpf/jit.c
drivers/net/ethernet/netronome/nfp/bpf/main.h
drivers/net/ethernet/netronome/nfp/bpf/verifier.c
drivers/net/ethernet/netronome/nfp/nfp_asm.h