From 4a750708bc9b6d76d67d88cd1b7193a9c62fdb9e Mon Sep 17 00:00:00 2001 From: Andy Zhou Date: Thu, 17 Apr 2014 23:40:27 -0700 Subject: [PATCH] ofproto-dpif: Rule lookup starts from table zero for non-recirc datapath Currently, all packet lookup starts from internal table for possible matching of post recirculation rules. This is not necessary for datapath that does not support recirculation. This patch adds the ability to steering rule lookup starting table based on whether datapath supports recirculation. Signed-off-by: Andy Zhou Acked-by: Jarno Rajahalme --- ofproto/bond.c | 2 -- ofproto/ofproto-dpif.c | 45 ++++++++++++++++++++++-------------------- 2 files changed, 24 insertions(+), 23 deletions(-) diff --git a/ofproto/bond.c b/ofproto/bond.c index 6506b36cb..630e535c9 100644 --- a/ofproto/bond.c +++ b/ofproto/bond.c @@ -336,8 +336,6 @@ update_recirc_rules(struct bond *bond) if (slave) { match_init_catchall(&match); match_set_recirc_id(&match, bond->recirc_id); - /* recirc_id -> metadata to speed up look ups. */ - match_set_metadata(&match, htonll(bond->recirc_id)); match_set_dp_hash_masked(&match, i, BOND_MASK); add_pr_rule(bond, &match, slave->ofp_port, diff --git a/ofproto/ofproto-dpif.c b/ofproto/ofproto-dpif.c index 52e47c298..fe02b5101 100644 --- a/ofproto/ofproto-dpif.c +++ b/ofproto/ofproto-dpif.c @@ -3183,13 +3183,33 @@ rule_dpif_get_actions(const struct rule_dpif *rule) return rule_get_actions(&rule->up); } -static uint8_t -rule_dpif_lookup__ (struct ofproto_dpif *ofproto, const struct flow *flow, - struct flow_wildcards *wc, struct rule_dpif **rule) +/* Lookup 'flow' in table 0 of 'ofproto''s classifier. + * If 'wc' is non-null, sets the fields that were relevant as part of + * the lookup. Returns the table_id where a match or miss occurred. + * + * The return value will be zero unless there was a miss and + * OFPTC11_TABLE_MISS_CONTINUE is in effect for the sequence of tables + * where misses occur. */ +uint8_t +rule_dpif_lookup(struct ofproto_dpif *ofproto, struct flow *flow, + struct flow_wildcards *wc, struct rule_dpif **rule) { enum rule_dpif_lookup_verdict verdict; enum ofputil_port_config config = 0; - uint8_t table_id = TBL_INTERNAL; + uint8_t table_id; + + if (ofproto_dpif_get_enable_recirc(ofproto)) { + if (flow->recirc_id == 0) { + if (wc) { + wc->masks.recirc_id = UINT32_MAX; + } + table_id = 0; + } else { + table_id = TBL_INTERNAL; + } + } else { + table_id = 0; + } verdict = rule_dpif_lookup_from_table(ofproto, flow, wc, true, &table_id, rule); @@ -3225,23 +3245,6 @@ rule_dpif_lookup__ (struct ofproto_dpif *ofproto, const struct flow *flow, return table_id; } -/* Lookup 'flow' in table 0 of 'ofproto''s classifier. - * If 'wc' is non-null, sets the fields that were relevant as part of - * the lookup. Returns the table_id where a match or miss occurred. - * - * The return value will be zero unless there was a miss and - * OFPTC11_TABLE_MISS_CONTINUE is in effect for the sequence of tables - * where misses occur. */ -uint8_t -rule_dpif_lookup(struct ofproto_dpif *ofproto, struct flow *flow, - struct flow_wildcards *wc, struct rule_dpif **rule) -{ - /* Set metadata to the value of recirc_id to speed up internal - * rule lookup. */ - flow->metadata = htonll(flow->recirc_id); - return rule_dpif_lookup__(ofproto, flow, wc, rule); -} - static struct rule_dpif * rule_dpif_lookup_in_table(struct ofproto_dpif *ofproto, uint8_t table_id, const struct flow *flow, struct flow_wildcards *wc) -- 2.43.0