nfp: bpf: support arithmetic indirect right shift (BPF_ARSH | BPF_X)
authorJiong Wang <jiong.wang@netronome.com>
Fri, 18 May 2018 19:12:11 +0000 (12:12 -0700)
committerDaniel Borkmann <daniel@iogearbox.net>
Fri, 18 May 2018 19:35:55 +0000 (21:35 +0200)
commitc217abccaaa5e4eeba4aee26f29cdb57c026afc1
tree9472d009cd111dc8b5d6a4cc2f0800aa50adb503
parentf43d0f17fe9a4bb770ab38b36e2b5150d8c3d6cf
nfp: bpf: support arithmetic indirect right shift (BPF_ARSH | BPF_X)

Code logic is similar with arithmetic right shift by constant, and NFP
get indirect shift amount through source A operand of PREV_ALU.

It is possible to fall back to logic right shift if the MSB is known to be
zero from range info, however there is no benefit to do this given logic
indirect right shift use the same number and cycle of instruction sequence.

Suppose the MSB of regX is the bit we want to replicate to fill in all the
vacant positions, and regY contains the shift amount, then we could use
single instruction to set up both.

  [alu, --, regY, OR, regX]

  --
  NOTE: the PREV_ALU result doesn't need to write to any destination
        register.

Signed-off-by: Jiong Wang <jiong.wang@netronome.com>
Reviewed-by: Jakub Kicinski <jakub.kicinski@netronome.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
drivers/net/ethernet/netronome/nfp/bpf/jit.c