2
0
mirror of https://github.com/openvswitch/ovs synced 2025-08-30 22:05:19 +00:00

flow: Add new flow_wildcards_fold_minimask() function.

This function will be useful in a future commit.

Signed-off-by: Ethan Jackson <ethan@nicira.com>
Co-authored-by: Justin Pettit <jpettit@nicira.com>
Signed-off-by: Justin Pettit <jpettit@nicira.com>
This commit is contained in:
Ethan Jackson
2013-05-09 19:14:20 -07:00
committed by Justin Pettit
parent 910fb1d8b6
commit ad77e3c52a
2 changed files with 32 additions and 14 deletions

View File

@@ -622,6 +622,33 @@ flow_wildcards_combine(struct flow_wildcards *dst,
}
}
/* Perform a bitwise OR of miniflow 'src' flow data with the equivalent
* fields in 'dst', storing the result in 'dst'. */
static void
flow_union_with_miniflow(struct flow *dst, const struct miniflow *src)
{
uint32_t *dst_u32 = (uint32_t *) dst;
int ofs;
int i;
ofs = 0;
for (i = 0; i < MINI_N_MAPS; i++) {
uint32_t map;
for (map = src->map[i]; map; map = zero_rightmost_1bit(map)) {
dst_u32[raw_ctz(map) + i * 32] |= src->values[ofs++];
}
}
}
/* Fold minimask 'mask''s wildcard mask into 'wc's wildcard mask. */
void
flow_wildcards_fold_minimask(struct flow_wildcards *wc,
const struct minimask *mask)
{
flow_union_with_miniflow(&wc->masks, &mask->masks);
}
/* Returns a hash of the wildcards in 'wc'. */
uint32_t
flow_wildcards_hash(const struct flow_wildcards *wc, uint32_t basis)
@@ -1024,20 +1051,8 @@ miniflow_destroy(struct miniflow *flow)
void
miniflow_expand(const struct miniflow *src, struct flow *dst)
{
uint32_t *dst_u32 = (uint32_t *) dst;
int ofs;
int i;
memset(dst_u32, 0, sizeof *dst);
ofs = 0;
for (i = 0; i < MINI_N_MAPS; i++) {
uint32_t map;
for (map = src->map[i]; map; map = zero_rightmost_1bit(map)) {
dst_u32[raw_ctz(map) + i * 32] = src->values[ofs++];
}
}
memset(dst, 0, sizeof *dst);
flow_union_with_miniflow(dst, src);
}
static const uint32_t *