diff options
author | Jarno Rajahalme <jrajahalme@nicira.com> | 2015-06-09 17:00:00 -0700 |
---|---|---|
committer | Jarno Rajahalme <jrajahalme@nicira.com> | 2015-06-10 16:17:47 -0700 |
commit | 2b7b1427c177d28ec63632646ce896eec7f162b6 (patch) | |
tree | 97d4fecd8ca81249fbd5ccf9cb8a03a28571460e /lib/classifier-private.h | |
parent | db5076eee46e5ad4d67dc02b902c9b4aaeb190a4 (diff) | |
download | openvswitch-2b7b1427c177d28ec63632646ce896eec7f162b6.tar.gz |
classifier: Support table versioning
This patch allows classifier rules to become visible and invisible in
specific versions. A 'version' is defined as a positive monotonically
increasing integer, which never wraps around.
The new 'visibility' attribute replaces the prior 'to_be_removed' and
'visible' attributes.
When versioning is not used, the 'version' parameter should be passed
as 'CLS_MIN_VERSION' when creating rules, and 'CLS_MAX_VERSION' when
looking up flows.
This feature enables the support for atomic OpenFlow bundles without
significant performance penalty on 64-bit systems. There is a
performance decrease in 32-bit systems due to 64-bit atomics used.
Signed-off-by: Jarno Rajahalme <jrajahalme@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
Diffstat (limited to 'lib/classifier-private.h')
-rw-r--r-- | lib/classifier-private.h | 52 |
1 files changed, 51 insertions, 1 deletions
diff --git a/lib/classifier-private.h b/lib/classifier-private.h index a7edbe93b..2703b75a7 100644 --- a/lib/classifier-private.h +++ b/lib/classifier-private.h @@ -79,13 +79,63 @@ struct cls_match { * 'indices'. */ /* Accessed by all readers. */ struct cmap_node cmap_node; /* Within struct cls_subtable 'rules'. */ - bool visible; + + /* Controls rule's visibility to lookups. + * + * When 'visibility' is: + * + * > 0 - rule is visible starting from version 'visibility' + * <= 0 - rule is invisible starting from version '-(visibility)' + * + * The minimum version number used in lookups is 1 (== CLS_NO_VERSION), + * which implies that when 'visibility' is: + * + * 1 - rule is visible in all lookup versions + * 0 - rule is invisible in all lookup versions. */ + atomic_llong visibility; + const struct cls_rule *cls_rule; OVSRCU_TYPE(struct cls_conjunction_set *) conj_set; const struct miniflow flow; /* Matching rule. Mask is in the subtable. */ /* 'flow' must be the last field. */ }; +static inline void +cls_match_set_visibility(struct cls_match *rule, long long version) +{ + atomic_store_relaxed(&rule->visibility, version); +} + +static inline bool +cls_match_visible_in_version(const struct cls_match *rule, long long version) +{ + long long visibility; + + /* C11 does not want to access an atomic via a const object pointer. */ + atomic_read_relaxed(&CONST_CAST(struct cls_match *, rule)->visibility, + &visibility); + + if (OVS_LIKELY(visibility > 0)) { + /* Rule is visible starting from version 'visibility'. */ + return version >= visibility; + } else { + /* Rule is invisible starting from version '-visibility'. */ + return version < -visibility; + } +} + +static inline bool +cls_match_is_eventually_invisible(const struct cls_match *rule) +{ + long long visibility; + + /* C11 does not want to access an atomic via a const object pointer. */ + atomic_read_relaxed(&CONST_CAST(struct cls_match *, rule)->visibility, + &visibility); + + return visibility <= 0; +} + /* A longest-prefix match tree. */ struct trie_node { uint32_t prefix; /* Prefix bits for this node, MSB first. */ |