diff options
author | Jiong Wang <jiong.wang@netronome.com> | 2018-03-28 17:48:27 -0700 |
---|---|---|
committer | Alexei Starovoitov <ast@kernel.org> | 2018-03-28 19:36:12 -0700 |
commit | 87b10ecdced224dc0def123e1f57bc6c5ac4ac5c (patch) | |
tree | 90de92372966b7fe579d66f6e7b36e9dbd5db6a8 /drivers/net/ethernet/netronome/nfp/bpf/main.h | |
parent | 91ff69e840f91016f464810e8940b99723abb5e8 (diff) | |
download | blackbird-op-linux-87b10ecdced224dc0def123e1f57bc6c5ac4ac5c.tar.gz blackbird-op-linux-87b10ecdced224dc0def123e1f57bc6c5ac4ac5c.zip |
nfp: bpf: detect packet reads could be cached, enable the optimisation
This patch is the front end of this optimisation, it detects and marks
those packet reads that could be cached. Then the optimisation "backend"
will be activated automatically.
Signed-off-by: Jiong Wang <jiong.wang@netronome.com>
Reviewed-by: Jakub Kicinski <jakub.kicinski@netronome.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Diffstat (limited to 'drivers/net/ethernet/netronome/nfp/bpf/main.h')
-rw-r--r-- | drivers/net/ethernet/netronome/nfp/bpf/main.h | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/drivers/net/ethernet/netronome/nfp/bpf/main.h b/drivers/net/ethernet/netronome/nfp/bpf/main.h index 861211e27ea6..c220ac5a734a 100644 --- a/drivers/net/ethernet/netronome/nfp/bpf/main.h +++ b/drivers/net/ethernet/netronome/nfp/bpf/main.h @@ -278,6 +278,36 @@ static inline bool is_mbpf_store(const struct nfp_insn_meta *meta) return (meta->insn.code & ~BPF_SIZE_MASK) == (BPF_STX | BPF_MEM); } +static inline bool is_mbpf_load_pkt(const struct nfp_insn_meta *meta) +{ + return is_mbpf_load(meta) && meta->ptr.type == PTR_TO_PACKET; +} + +static inline bool is_mbpf_store_pkt(const struct nfp_insn_meta *meta) +{ + return is_mbpf_store(meta) && meta->ptr.type == PTR_TO_PACKET; +} + +static inline bool is_mbpf_classic_load(const struct nfp_insn_meta *meta) +{ + u8 code = meta->insn.code; + + return BPF_CLASS(code) == BPF_LD && + (BPF_MODE(code) == BPF_ABS || BPF_MODE(code) == BPF_IND); +} + +static inline bool is_mbpf_classic_store(const struct nfp_insn_meta *meta) +{ + u8 code = meta->insn.code; + + return BPF_CLASS(code) == BPF_ST && BPF_MODE(code) == BPF_MEM; +} + +static inline bool is_mbpf_classic_store_pkt(const struct nfp_insn_meta *meta) +{ + return is_mbpf_classic_store(meta) && meta->ptr.type == PTR_TO_PACKET; +} + /** * struct nfp_prog - nfp BPF program * @bpf: backpointer to the bpf app priv structure |