X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=lib%2Fclassifier.h;fp=lib%2Fclassifier.h;h=a89c562fe9dcbbd218c9e9b0c79b36f280c1cf0d;hb=7d78f21c057ff50a823220d809ac38c3d907243c;hp=c3c1c3bd2adef8df2ad0e1e340850cb661506a7a;hpb=8d25251929c8f325bed0fff24192d5a87034b32e;p=sliver-openvswitch.git diff --git a/lib/classifier.h b/lib/classifier.h index c3c1c3bd2..a89c562fe 100644 --- a/lib/classifier.h +++ b/lib/classifier.h @@ -232,79 +232,28 @@ extern "C" { /* Needed only for the lock annotation in struct classifier. */ extern struct ovs_mutex ofproto_mutex; -struct trie_node; -/* Prefix trie for a 'field' */ -struct cls_trie { - const struct mf_field *field; /* Trie field, or NULL. */ - struct trie_node *root; /* NULL if none. */ -}; +/* Classifier internal data structures. */ +struct cls_classifier; +struct cls_subtable; +struct cls_partition; +struct cls_match; enum { - CLS_MAX_INDICES = 3, /* Maximum number of lookup indices per subtable. */ CLS_MAX_TRIES = 3 /* Maximum number of prefix trees per classifier. */ }; /* A flow classifier. */ struct classifier { - int n_rules; /* Total number of rules. */ - uint8_t n_flow_segments; - uint8_t flow_segments[CLS_MAX_INDICES]; /* Flow segment boundaries to use - * for staged lookup. */ - struct hmap subtables; /* Contains "struct cls_subtable"s. */ - struct list subtables_priority; /* Subtables in descending priority order. - */ - struct hmap partitions; /* Contains "struct cls_partition"s. */ struct fat_rwlock rwlock OVS_ACQ_AFTER(ofproto_mutex); - struct cls_trie tries[CLS_MAX_TRIES]; /* Prefix tries. */ - unsigned int n_tries; -}; - -/* A set of rules that all have the same fields wildcarded. */ -struct cls_subtable { - struct hmap_node hmap_node; /* Within struct classifier 'subtables' hmap. - */ - struct list list_node; /* Within classifier 'subtables_priority' list. - */ - struct hmap rules; /* Contains "struct cls_rule"s. */ - struct minimask mask; /* Wildcards for fields. */ - int n_rules; /* Number of rules, including duplicates. */ - unsigned int max_priority; /* Max priority of any rule in the subtable. */ - unsigned int max_count; /* Count of max_priority rules. */ - tag_type tag; /* Tag generated from mask for partitioning. */ - uint8_t n_indices; /* How many indices to use. */ - uint8_t index_ofs[CLS_MAX_INDICES]; /* u32 flow segment boundaries. */ - struct hindex indices[CLS_MAX_INDICES]; /* Staged lookup indices. */ - unsigned int trie_plen[CLS_MAX_TRIES]; /* Trie prefix length in 'mask'. */ + struct cls_classifier *cls; }; -/* Returns true if 'table' is a "catch-all" subtable that will match every - * packet (if there is no higher-priority match). */ -static inline bool -cls_subtable_is_catchall(const struct cls_subtable *subtable) -{ - return minimask_is_catchall(&subtable->mask); -} - -/* A rule in a "struct cls_subtable". */ +/* A rule to be inserted to the classifier. */ struct cls_rule { - struct hmap_node hmap_node; /* Within struct cls_subtable 'rules'. */ - struct list list; /* List of identical, lower-priority rules. */ - struct minimatch match; /* Matching rule. */ - unsigned int priority; /* Larger numbers are higher priorities. */ - struct cls_partition *partition; - struct hindex_node index_nodes[CLS_MAX_INDICES]; /* Within subtable's - * 'indices'. */ -}; - -/* Associates a metadata value (that is, a value of the OpenFlow 1.1+ metadata - * field) with tags for the "cls_subtable"s that contain rules that match that - * metadata value. */ -struct cls_partition { - struct hmap_node hmap_node; /* In struct classifier's 'partitions' hmap. */ - ovs_be64 metadata; /* metadata value for this partition. */ - tag_type tags; /* OR of each flow's cls_subtable tag. */ - struct tag_tracker tracker; /* Tracks the bits in 'tags'. */ + struct minimatch match; /* Matching rule. */ + unsigned int priority; /* Larger numbers are higher priorities. */ + struct cls_match *cls_match; /* NULL if rule is not in a classifier. */ }; void cls_rule_init(struct cls_rule *, const struct match *, @@ -346,6 +295,9 @@ struct cls_rule *classifier_lookup(const struct classifier *cls, const struct flow *, struct flow_wildcards *) OVS_REQ_RDLOCK(cls->rwlock); +struct cls_rule *classifier_lookup_miniflow_first(const struct classifier *cls, + const struct miniflow *) + OVS_REQ_RDLOCK(cls->rwlock); bool classifier_rule_overlaps(const struct classifier *cls, const struct cls_rule *) OVS_REQ_RDLOCK(cls->rwlock); @@ -363,7 +315,7 @@ struct cls_rule *classifier_find_match_exactly(const struct classifier *cls, /* Iteration. */ struct cls_cursor { - const struct classifier *cls; + const struct cls_classifier *cls; const struct cls_subtable *subtable; const struct cls_rule *target; };