From a0b36b3924c7c7033ebecc2ad79f6fcee2b2e66d Mon Sep 17 00:00:00 2001 From: Harry van Haaren Date: Thu, 18 Jul 2019 14:03:05 +0100 Subject: dpif-netdev: Refactor generic implementation This commit refactors the generic implementation. The goal of this refactor is to simplify the code to enable "specialization" of the functions at compile time. Given compile-time optimizations, the compiler is able to unroll loops, and create optimized code sequences due to compile time knowledge of loop-trip counts. In order to enable these compiler optimizations, we must refactor the code to pass the loop-trip counts to functions as compile time constants. This patch allows the number of miniflow-bits set per "unit" in the miniflow to be passed around as a function argument. Note that this patch does NOT yet take advantage of doing so, this is only a refactor to enable it in the next patches. Signed-off-by: Harry van Haaren Tested-by: Malvika Gupta Acked-by: Ilya Maximets Signed-off-by: Ian Stokes --- lib/dpif-netdev-private.h | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'lib/dpif-netdev-private.h') diff --git a/lib/dpif-netdev-private.h b/lib/dpif-netdev-private.h index 555856482..610851a10 100644 --- a/lib/dpif-netdev-private.h +++ b/lib/dpif-netdev-private.h @@ -60,7 +60,7 @@ uint32_t (*dpcls_subtable_lookup_func)(struct dpcls_subtable *subtable, const struct netdev_flow_key *keys[], struct dpcls_rule **rules); -/* Prototype for generic lookup func, using same code path as before. */ +/* Prototype for generic lookup func, using generic scalar code path. */ uint32_t dpcls_subtable_lookup_generic(struct dpcls_subtable *subtable, uint32_t keys_map, @@ -77,12 +77,22 @@ struct dpcls_subtable { uint32_t hit_cnt; /* Number of match hits in subtable in current optimization interval. */ + /* Miniflow fingerprint that the subtable matches on. The miniflow "bits" + * are used to select the actual dpcls lookup implementation at subtable + * creation time. + */ + uint8_t mf_bits_set_unit0; + uint8_t mf_bits_set_unit1; + /* The lookup function to use for this subtable. If there is a known * property of the subtable (eg: only 3 bits of miniflow metadata is * used for the lookup) then this can point at an optimized version of * the lookup function for this particular subtable. */ dpcls_subtable_lookup_func lookup_func; + /* Caches the masks to match a packet to, reducing runtime calculations. */ + uint64_t *mf_masks; + struct netdev_flow_key mask; /* Wildcards for fields (const). */ /* 'mask' must be the last field, additional space is allocated here. */ }; -- cgit v1.2.1