[ovs-dev] [PATCH] dpcls: Avoid one 8-byte chunk in subtable mask.
antonio.fischetti at intel.com
antonio.fischetti at intel.com
Wed Jan 4 14:41:30 UTC 2017
This patch allows to skip the chunk comprising of dp_hash and in_port
in the subtable mask when the packet is not recirculated. This will
slightly speed up the hash computation as one expensive function call
to hash_add64() can be skipped.
For each new netdev flow we wildcard in_port in the mask, so in the
physical case where dp_hash is also wildcarded, the resulting 8-byte
chunk will not be part of the subtable mask.
The idea behind is that all the packets within a given dpcls will
have the same in_port value and typically dp_hash == 0. So they will
have the same 8-bytes chunk in their {dp_hash, in_port} portion of the
miniflow. This doesn't contribute effectively in spreading hash values
and avoiding collisions.
Signed-off-by: Antonio Fischetti <antonio.fischetti at intel.com>
Signed-off-by: Bhanuprakash Bodireddy <bhanuprakash.bodireddy at intel.com>
Co-authored-by: Bhanuprakash Bodireddy <bhanuprakash.bodireddy at intel.com>
Signed-off-by: Jarno Rajahalme <jarno at ovn.org>
Co-authored-by: Jarno Rajahalme <jarno at ovn.org>
---
lib/dpif-netdev.c | 14 +++++++++++++-
1 file changed, 13 insertions(+), 1 deletion(-)
diff --git a/lib/dpif-netdev.c b/lib/dpif-netdev.c
index 1a47a45..a808f4b 100644
--- a/lib/dpif-netdev.c
+++ b/lib/dpif-netdev.c
@@ -2277,8 +2277,20 @@ dp_netdev_flow_add(struct dp_netdev_pmd_thread *pmd,
struct netdev_flow_key mask;
struct dpcls *cls;
odp_port_t in_port = match->flow.in_port.odp_port;
-
+ uint32_t old_odp_port;
+
+ /* As we select the dpcls based on the port number, each netdev flow
+ * belonging to the same dpcls will have the same odp_port value.
+ * For performance reasons here we wildcard odp_port in the mask. In the
+ * physical case where dp_hash is also wildcarded, the resulting 8-byte
+ * chunk {dp_hash, in_port} will be ignored by netdev_flow_mask_init() and
+ * will not be part of the subtable mask.
+ * This will speed up the hash computation during dpcls_lookup() because
+ * one call to hash_add64() will be skipped. */
+ old_odp_port = match->wc.masks.in_port.odp_port;
+ match->wc.masks.in_port.odp_port = 0;
netdev_flow_mask_init(&mask, match);
+ match->wc.masks.in_port.odp_port = old_odp_port;
/* Make sure wc does not have metadata. */
ovs_assert(!FLOWMAP_HAS_FIELD(&mask.mf.map, metadata)
&& !FLOWMAP_HAS_FIELD(&mask.mf.map, regs));
--
2.4.11
More information about the dev
mailing list