2
0
mirror of https://github.com/openvswitch/ovs synced 2025-08-31 14:25:26 +00:00

flow: Add new wildcard functions.

Rename the function flow_wildcards_combine() to flow_wildcards_and().
Add new flow_wildcards_or() and flow_hash_in_wildcards() functions.
These will be useful in a future patch.

Signed-off-by: Ethan Jackson <ethan@nicira.com>
Signed-off-by: Justin Pettit <jpettit@nicira.com>
This commit is contained in:
Ethan Jackson
2013-06-10 22:48:58 -07:00
committed by Justin Pettit
parent 74f74083e6
commit 368eefac37
3 changed files with 53 additions and 10 deletions

View File

@@ -604,13 +604,13 @@ flow_wildcards_is_catchall(const struct flow_wildcards *wc)
return true;
}
/* Initializes 'dst' as the combination of wildcards in 'src1' and 'src2'.
* That is, a bit or a field is wildcarded in 'dst' if it is wildcarded in
* 'src1' or 'src2' or both. */
/* Sets 'dst' as the bitwise AND of wildcards in 'src1' and 'src2'.
* That is, a bit or a field is wildcarded in 'dst' if it is wildcarded
* in 'src1' or 'src2' or both. */
void
flow_wildcards_combine(struct flow_wildcards *dst,
const struct flow_wildcards *src1,
const struct flow_wildcards *src2)
flow_wildcards_and(struct flow_wildcards *dst,
const struct flow_wildcards *src1,
const struct flow_wildcards *src2)
{
uint32_t *dst_u32 = (uint32_t *) &dst->masks;
const uint32_t *src1_u32 = (const uint32_t *) &src1->masks;
@@ -622,6 +622,24 @@ flow_wildcards_combine(struct flow_wildcards *dst,
}
}
/* Sets 'dst' as the bitwise OR of wildcards in 'src1' and 'src2'. That
* is, a bit or a field is wildcarded in 'dst' if it is neither
* wildcarded in 'src1' nor 'src2'. */
void
flow_wildcards_or(struct flow_wildcards *dst,
const struct flow_wildcards *src1,
const struct flow_wildcards *src2)
{
uint32_t *dst_u32 = (uint32_t *) &dst->masks;
const uint32_t *src1_u32 = (const uint32_t *) &src1->masks;
const uint32_t *src2_u32 = (const uint32_t *) &src2->masks;
size_t i;
for (i = 0; i < FLOW_U32S; i++) {
dst_u32[i] = src1_u32[i] | src2_u32[i];
}
}
/* Perform a bitwise OR of miniflow 'src' flow data with the equivalent
* fields in 'dst', storing the result in 'dst'. */
static void
@@ -795,6 +813,24 @@ flow_hash_fields_valid(enum nx_hash_fields fields)
|| fields == NX_HASH_FIELDS_SYMMETRIC_L4;
}
/* Returns a hash value for the bits of 'flow' that are active based on
* 'wc', given 'basis'. */
uint32_t
flow_hash_in_wildcards(const struct flow *flow,
const struct flow_wildcards *wc, uint32_t basis)
{
const uint32_t *wc_u32 = (const uint32_t *) &wc->masks;
const uint32_t *flow_u32 = (const uint32_t *) flow;
uint32_t hash;
size_t i;
hash = basis;
for (i = 0; i < FLOW_U32S; i++) {
hash = mhash_add(hash, flow_u32[i] & wc_u32[i]);
}
return mhash_finish(hash, 4 * FLOW_U32S);
}
/* Sets the VLAN VID that 'flow' matches to 'vid', which is interpreted as an
* OpenFlow 1.0 "dl_vlan" value:
*