Commit 272c2cf8 authored by Joe Stringer's avatar Joe Stringer Committed by David S. Miller

openvswitch: Use sw_flow_key_range for key ranges.

These minor tidyups make a future patch a little tidier.
Signed-off-by: default avatarJoe Stringer <joestringer@nicira.com>
Acked-by: default avatarPravin B Shelar <pshelar@nicira.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent d29ab6f8
...@@ -357,9 +357,11 @@ int ovs_flow_tbl_flush(struct flow_table *flow_table) ...@@ -357,9 +357,11 @@ int ovs_flow_tbl_flush(struct flow_table *flow_table)
return 0; return 0;
} }
static u32 flow_hash(const struct sw_flow_key *key, int key_start, static u32 flow_hash(const struct sw_flow_key *key,
int key_end) const struct sw_flow_key_range *range)
{ {
int key_start = range->start;
int key_end = range->end;
const u32 *hash_key = (const u32 *)((const u8 *)key + key_start); const u32 *hash_key = (const u32 *)((const u8 *)key + key_start);
int hash_u32s = (key_end - key_start) >> 2; int hash_u32s = (key_end - key_start) >> 2;
...@@ -395,9 +397,9 @@ static bool cmp_key(const struct sw_flow_key *key1, ...@@ -395,9 +397,9 @@ static bool cmp_key(const struct sw_flow_key *key1,
static bool flow_cmp_masked_key(const struct sw_flow *flow, static bool flow_cmp_masked_key(const struct sw_flow *flow,
const struct sw_flow_key *key, const struct sw_flow_key *key,
int key_start, int key_end) const struct sw_flow_key_range *range)
{ {
return cmp_key(&flow->key, key, key_start, key_end); return cmp_key(&flow->key, key, range->start, range->end);
} }
bool ovs_flow_cmp_unmasked_key(const struct sw_flow *flow, bool ovs_flow_cmp_unmasked_key(const struct sw_flow *flow,
...@@ -416,18 +418,15 @@ static struct sw_flow *masked_flow_lookup(struct table_instance *ti, ...@@ -416,18 +418,15 @@ static struct sw_flow *masked_flow_lookup(struct table_instance *ti,
{ {
struct sw_flow *flow; struct sw_flow *flow;
struct hlist_head *head; struct hlist_head *head;
int key_start = mask->range.start;
int key_end = mask->range.end;
u32 hash; u32 hash;
struct sw_flow_key masked_key; struct sw_flow_key masked_key;
ovs_flow_mask_key(&masked_key, unmasked, mask); ovs_flow_mask_key(&masked_key, unmasked, mask);
hash = flow_hash(&masked_key, key_start, key_end); hash = flow_hash(&masked_key, &mask->range);
head = find_bucket(ti, hash); head = find_bucket(ti, hash);
hlist_for_each_entry_rcu(flow, head, hash_node[ti->node_ver]) { hlist_for_each_entry_rcu(flow, head, hash_node[ti->node_ver]) {
if (flow->mask == mask && flow->hash == hash && if (flow->mask == mask && flow->hash == hash &&
flow_cmp_masked_key(flow, &masked_key, flow_cmp_masked_key(flow, &masked_key, &mask->range))
key_start, key_end))
return flow; return flow;
} }
return NULL; return NULL;
...@@ -590,8 +589,7 @@ static void flow_key_insert(struct flow_table *table, struct sw_flow *flow) ...@@ -590,8 +589,7 @@ static void flow_key_insert(struct flow_table *table, struct sw_flow *flow)
struct table_instance *new_ti = NULL; struct table_instance *new_ti = NULL;
struct table_instance *ti; struct table_instance *ti;
flow->hash = flow_hash(&flow->key, flow->mask->range.start, flow->hash = flow_hash(&flow->key, &flow->mask->range);
flow->mask->range.end);
ti = ovsl_dereference(table->ti); ti = ovsl_dereference(table->ti);
table_instance_insert(ti, flow); table_instance_insert(ti, flow);
table->count++; table->count++;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment