nfp: bpf: add simple map op cache
authorJakub Kicinski <jakub.kicinski@netronome.com>
Wed, 28 Aug 2019 05:36:29 +0000 (22:36 -0700)
committerDaniel Borkmann <daniel@iogearbox.net>
Fri, 30 Aug 2019 22:49:05 +0000 (00:49 +0200)
commitf24e29099f4faf1969151fb4b857fda16b7c1a72
tree7e459c0444b918afc4470831d67aeef8dbc8dac1
parentbc2796db5a0246acc998cc5ab2e7f8d6e4e4c146
nfp: bpf: add simple map op cache

Each get_next and lookup call requires a round trip to the device.
However, the device is capable of giving us a few entries back,
instead of just one.

In this patch we ask for a small yet reasonable number of entries
(4) on every get_next call, and on subsequent get_next/lookup calls
check this little cache for a hit. The cache is only kept for 250us,
and is invalidated on every operation which may modify the map
(e.g. delete or update call). Note that operations may be performed
simultaneously, so we have to keep track of operations in flight.

Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com>
Reviewed-by: Quentin Monnet <quentin.monnet@netronome.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
drivers/net/ethernet/netronome/nfp/bpf/cmsg.c
drivers/net/ethernet/netronome/nfp/bpf/fw.h
drivers/net/ethernet/netronome/nfp/bpf/main.c
drivers/net/ethernet/netronome/nfp/bpf/main.h
drivers/net/ethernet/netronome/nfp/bpf/offload.c