/*
- * Copyright (c) 2014, 2015 Nicira, Inc.
+ * Copyright (c) 2014, 2015, 2016 Nicira, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
#ifndef CLASSIFIER_PRIVATE_H
#define CLASSIFIER_PRIVATE_H 1
+#include "ccmap.h"
#include "cmap.h"
#include "flow.h"
#include "hash.h"
unsigned int trie_plen[CLS_MAX_TRIES]; /* Trie prefix length in 'mask'
* (runtime configurable). */
const int ports_mask_len;
- struct cmap indices[CLS_MAX_INDICES]; /* Staged lookup indices. */
+ struct ccmap indices[CLS_MAX_INDICES]; /* Staged lookup indices. */
rcu_trie_ptr ports_trie; /* NULL if none. */
/* These fields are accessed by all readers. */
/* Accessed by readers interested in wildcarding. */
const int priority; /* Larger numbers are higher priorities. */
- struct cmap_node index_nodes[CLS_MAX_INDICES]; /* Within subtable's
- * 'indices'. */
+
/* Accessed by all readers. */
struct cmap_node cmap_node; /* Within struct cls_subtable 'rules'. */
/*
- * Copyright (c) 2009, 2010, 2011, 2012, 2013, 2014, 2015 Nicira, Inc.
+ * Copyright (c) 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016 Nicira, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
& MINIFLOW_GET_BE32(&match->mask->masks, tp_src);
}
-static void
-subtable_replace_head_rule(struct classifier *cls OVS_UNUSED,
- struct cls_subtable *subtable,
- struct cls_match *head, struct cls_match *new,
- uint32_t hash, uint32_t ihash[CLS_MAX_INDICES])
-{
- /* Rule's data is already in the tries. */
-
- for (int i = 0; i < subtable->n_indices; i++) {
- cmap_replace(&subtable->indices[i], &head->index_nodes[i],
- &new->index_nodes[i], ihash[i]);
- }
- cmap_replace(&subtable->rules, &head->cmap_node, &new->cmap_node, hash);
-}
-
/* Inserts 'rule' into 'cls' in 'version'. Until 'rule' is removed from 'cls',
* the caller must not modify or free it.
*
subtable->ports_mask_len);
}
- /* Add new node to segment indices.
- *
- * Readers may find the rule in the indices before the rule is visible
- * in the subtables 'rules' map. This may result in us losing the
- * opportunity to quit lookups earlier, resulting in sub-optimal
- * wildcarding. This will be fixed later by revalidation (always
- * scheduled after flow table changes). */
+ /* Add new node to segment indices. */
for (i = 0; i < subtable->n_indices; i++) {
- cmap_insert(&subtable->indices[i], &new->index_nodes[i], ihash[i]);
+ ccmap_inc(&subtable->indices[i], ihash[i]);
}
n_rules = cmap_insert(&subtable->rules, &new->cmap_node, hash);
} else { /* Equal rules exist in the classifier already. */
/* Replace the existing head in data structures, if rule is the new
* head. */
if (iter == head) {
- subtable_replace_head_rule(cls, subtable, head, new, hash,
- ihash);
+ cmap_replace(&subtable->rules, &head->cmap_node,
+ &new->cmap_node, hash);
}
if (old) {
* replace 'rule' in the data structures. */
next = cls_match_next_protected(rule);
if (next) {
- subtable_replace_head_rule(cls, subtable, rule, next, hash, ihash);
+ cmap_replace(&subtable->rules, &rule->cmap_node, &next->cmap_node,
+ hash);
goto check_priority;
}
/* Remove rule node from indices. */
for (i = 0; i < subtable->n_indices; i++) {
- cmap_remove(&subtable->indices[i], &rule->index_nodes[i], ihash[i]);
+ ccmap_dec(&subtable->indices[i], ihash[i]);
}
n_rules = cmap_remove(&subtable->rules, &rule->cmap_node, hash);
cls->flow_segments[i]);
/* Add an index if it adds mask bits. */
if (!flowmap_is_empty(stage_map)) {
- cmap_init(&subtable->indices[index]);
+ ccmap_init(&subtable->indices[index]);
*CONST_CAST(struct flowmap *, &subtable->index_maps[index])
= stage_map;
index++;
/* Remove the last index, as it has the same fields as the rules
* map. */
--index;
- cmap_destroy(&subtable->indices[index]);
+ ccmap_destroy(&subtable->indices[index]);
}
}
*CONST_CAST(uint8_t *, &subtable->n_indices) = index;
ovs_assert(rculist_is_empty(&subtable->rules_list));
for (i = 0; i < subtable->n_indices; i++) {
- cmap_destroy(&subtable->indices[i]);
+ ccmap_destroy(&subtable->indices[i]);
}
cmap_destroy(&subtable->rules);
ovsrcu_postpone(free, subtable);
subtable->index_maps[i],
&mask_offset, &basis);
- if (!cmap_find(&subtable->indices[i], hash)) {
+ if (!ccmap_find(&subtable->indices[i], hash)) {
goto no_match;
}
}