mirror of
https://github.com/openvswitch/ovs
synced 2025-08-30 22:05:19 +00:00
dpcls: Avoid one 8-byte chunk in subtable mask.
This patch allows to skip the 8-byte chunk comprising of dp_hash and in_port in the subtable mask when dp_hash is wildcarded. 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 typical case where dp_hash is also wildcarded, the resulting 8-byte chunk will not be part of the subtable mask. This manipulation of the mask is possible as the datapath classifier is explicitly selected based on the in_port value, so that all the datapath flows in the selected classifier have an exact match on that in_port value. Given this, it is safe to ignore the in_port value when doing a lookup in the chosen classifier. Signed-off-by: Antonio Fischetti <antonio.fischetti@intel.com> Signed-off-by: Bhanuprakash Bodireddy <bhanuprakash.bodireddy@intel.com> Co-authored-by: Bhanuprakash Bodireddy <bhanuprakash.bodireddy@intel.com> Signed-off-by: Jarno Rajahalme <jarno@ovn.org> Co-authored-by: Jarno Rajahalme <jarno@ovn.org>
This commit is contained in:
@@ -2101,6 +2101,9 @@ dp_netdev_flow_to_dpif_flow(const struct dp_netdev_flow *netdev_flow,
|
||||
};
|
||||
|
||||
miniflow_expand(&netdev_flow->cr.mask->mf, &wc.masks);
|
||||
/* in_port is exact matched, but we have left it out from the mask for
|
||||
* optimnization reasons. Add in_port back to the mask. */
|
||||
wc.masks.in_port.odp_port = ODPP_NONE;
|
||||
|
||||
/* Key */
|
||||
offset = key_buf->size;
|
||||
@@ -2257,9 +2260,23 @@ dp_netdev_flow_add(struct dp_netdev_pmd_thread *pmd,
|
||||
struct dp_netdev_flow *flow;
|
||||
struct netdev_flow_key mask;
|
||||
struct dpcls *cls;
|
||||
|
||||
/* Make sure in_port is exact matched before we read it. */
|
||||
ovs_assert(match->wc.masks.in_port.odp_port == ODPP_NONE);
|
||||
odp_port_t in_port = match->flow.in_port.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 we wildcard odp_port here in the mask. In the
|
||||
* typical case dp_hash is also wildcarded, and 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
|
||||
* there is one less call to hash_add64() in this case. */
|
||||
match->wc.masks.in_port.odp_port = 0;
|
||||
netdev_flow_mask_init(&mask, match);
|
||||
match->wc.masks.in_port.odp_port = ODPP_NONE;
|
||||
|
||||
/* Make sure wc does not have metadata. */
|
||||
ovs_assert(!FLOWMAP_HAS_FIELD(&mask.mf.map, metadata)
|
||||
&& !FLOWMAP_HAS_FIELD(&mask.mf.map, regs));
|
||||
@@ -2277,8 +2294,7 @@ dp_netdev_flow_add(struct dp_netdev_pmd_thread *pmd,
|
||||
|
||||
netdev_flow_key_init_masked(&flow->cr.flow, &match->flow, &mask);
|
||||
|
||||
/* Select dpcls for in_port. Relies on in_port to be exact match */
|
||||
ovs_assert(match->wc.masks.in_port.odp_port == ODPP_NONE);
|
||||
/* Select dpcls for in_port. Relies on in_port to be exact match. */
|
||||
cls = dp_netdev_pmd_find_dpcls(pmd, in_port);
|
||||
dpcls_insert(cls, &flow->cr, &mask);
|
||||
|
||||
|
Reference in New Issue
Block a user