rule_dpif_is_internal is among the top ten OVS internal functions in recent perf reports. Inline it and some other equally trivial functions.
This change removes rule_is_internal(), since the fact that a table is an internal one is defined within ofproto-dpif, not ofproto. Signed-off-by: Jarno Rajahalme <jrajaha...@nicira.com> --- ofproto/ofproto-dpif.c | 49 +++--------------------------------------- ofproto/ofproto-dpif.h | 48 ++++++++++++++++++++++++++++++++++++----- ofproto/ofproto-provider.h | 51 ++++++++++++++++++++++++-------------------- 3 files changed, 74 insertions(+), 74 deletions(-) diff --git a/ofproto/ofproto-dpif.c b/ofproto/ofproto-dpif.c index 5669cd1..3d23cf5 100644 --- a/ofproto/ofproto-dpif.c +++ b/ofproto/ofproto-dpif.c @@ -73,11 +73,6 @@ VLOG_DEFINE_THIS_MODULE(ofproto_dpif); COVERAGE_DEFINE(ofproto_dpif_expired); COVERAGE_DEFINE(packet_in_overflow); -/* Number of implemented OpenFlow tables. */ -enum { N_TABLES = 255 }; -enum { TBL_INTERNAL = N_TABLES - 1 }; /* Used for internal hidden rules. */ -BUILD_ASSERT_DECL(N_TABLES >= 2 && N_TABLES <= 255); - struct flow_miss; struct rule_dpif { @@ -91,6 +86,9 @@ struct rule_dpif { struct dpif_flow_stats stats OVS_GUARDED; }; +/* rule_cast() depends on this. */ +BUILD_ASSERT_DECL(offsetof(struct rule_dpif, up) == 0); + static void rule_get_stats(struct rule *, uint64_t *packets, uint64_t *bytes, long long int *used); static struct rule_dpif *rule_dpif_cast(const struct rule *); @@ -3142,24 +3140,6 @@ rule_dpif_credit_stats(struct rule_dpif *rule, ovs_mutex_unlock(&rule->stats_mutex); } -bool -rule_dpif_is_fail_open(const struct rule_dpif *rule) -{ - return is_fail_open_rule(&rule->up); -} - -bool -rule_dpif_is_table_miss(const struct rule_dpif *rule) -{ - return rule_is_table_miss(&rule->up); -} - -bool -rule_dpif_is_internal(const struct rule_dpif *rule) -{ - return rule_is_internal(&rule->up); -} - ovs_be64 rule_dpif_get_flow_cookie(const struct rule_dpif *rule) OVS_REQUIRES(rule->up.mutex) @@ -3401,22 +3381,6 @@ choose_miss_rule(enum ofputil_port_config config, struct rule_dpif *miss_rule, } } -void -rule_dpif_ref(struct rule_dpif *rule) -{ - if (rule) { - ofproto_rule_ref(&rule->up); - } -} - -void -rule_dpif_unref(struct rule_dpif *rule) -{ - if (rule) { - ofproto_rule_unref(&rule->up); - } -} - static void complete_operation(struct rule_dpif *rule) OVS_REQUIRES(ofproto_mutex) @@ -4524,13 +4488,6 @@ ofproto_dpif_unixctl_init(void) ofproto_unixctl_dpif_dump_flows, NULL); } - -/* Returns true if 'rule' is an internal rule, false otherwise. */ -bool -rule_is_internal(const struct rule *rule) -{ - return rule->table_id == TBL_INTERNAL; -} /* Linux VLAN device support (e.g. "eth0.10" for VLAN 10.) * diff --git a/ofproto/ofproto-dpif.h b/ofproto/ofproto-dpif.h index 8af6645..f94f33c 100644 --- a/ofproto/ofproto-dpif.h +++ b/ofproto/ofproto-dpif.h @@ -17,6 +17,7 @@ #include <stdint.h> +#include "fail-open.h" #include "hmapx.h" #include "odp-util.h" #include "ofp-util.h" @@ -98,15 +99,16 @@ enum rule_dpif_lookup_verdict rule_dpif_lookup_from_table(struct ofproto_dpif *, struct rule_dpif **rule, bool take_ref); -void rule_dpif_ref(struct rule_dpif *); -void rule_dpif_unref(struct rule_dpif *); +static inline void rule_dpif_ref(struct rule_dpif *); +static inline void rule_dpif_unref(struct rule_dpif *); void rule_dpif_credit_stats(struct rule_dpif *rule , const struct dpif_flow_stats *); -bool rule_dpif_is_fail_open(const struct rule_dpif *); -bool rule_dpif_is_table_miss(const struct rule_dpif *); -bool rule_dpif_is_internal(const struct rule_dpif *); +static inline bool rule_dpif_is_fail_open(const struct rule_dpif *); +static inline bool rule_dpif_is_table_miss(const struct rule_dpif *); +static inline bool rule_dpif_is_internal(const struct rule_dpif *); + uint8_t rule_dpif_get_table(const struct rule_dpif *); struct rule_actions *rule_dpif_get_actions(const struct rule_dpif *); @@ -220,4 +222,40 @@ int ofproto_dpif_add_internal_flow(struct ofproto_dpif *, int ofproto_dpif_delete_internal_flow(struct ofproto_dpif *, struct match *, int priority); +/* Number of implemented OpenFlow tables. */ +enum { N_TABLES = 255 }; +enum { TBL_INTERNAL = N_TABLES - 1 }; /* Used for internal hidden rules. */ +BUILD_ASSERT_DECL(N_TABLES >= 2 && N_TABLES <= 255); + + +static inline void rule_dpif_ref(struct rule_dpif *rule) +{ + if (rule) { + ofproto_rule_ref((struct rule *)rule); + } +} + +static inline void rule_dpif_unref(struct rule_dpif *rule) +{ + if (rule) { + ofproto_rule_unref((struct rule *)rule); + } +} + +static inline bool rule_dpif_is_fail_open(const struct rule_dpif *rule) +{ + return is_fail_open_rule((const struct rule *)rule); +} + +static inline bool rule_dpif_is_table_miss(const struct rule_dpif *rule) +{ + return rule_is_table_miss((const struct rule *)rule); +} + +/* Returns true if 'rule' is an internal rule, false otherwise. */ +static inline bool rule_dpif_is_internal(const struct rule_dpif *rule) +{ + return ((const struct rule *)rule)->table_id == TBL_INTERNAL; +} + #endif /* ofproto-dpif.h */ diff --git a/ofproto/ofproto-provider.h b/ofproto/ofproto-provider.h index 0148fe6..d2be32e 100644 --- a/ofproto/ofproto-provider.h +++ b/ofproto/ofproto-provider.h @@ -406,24 +406,8 @@ struct rule { void ofproto_rule_ref(struct rule *); void ofproto_rule_unref(struct rule *); -static inline struct rule_actions * -rule_get_actions(const struct rule *rule) -{ - return ovsrcu_get(struct rule_actions *, &rule->actions); -} - -/* Returns true if 'rule' is an OpenFlow 1.3 "table-miss" rule, false - * otherwise. - * - * ("Table-miss" rules are special because a packet_in generated through one - * uses OFPR_NO_MATCH as its reason, whereas packet_ins generated by any other - * rule use OFPR_ACTION.) */ -static inline bool -rule_is_table_miss(const struct rule *rule) -{ - return rule->cr.priority == 0 && cls_rule_is_catchall(&rule->cr); -} -bool rule_is_internal(const struct rule *); +static inline struct rule_actions * rule_get_actions(const struct rule *); +static inline bool rule_is_table_miss(const struct rule *); /* A set of actions within a "struct rule". * @@ -475,11 +459,7 @@ extern unsigned ofproto_max_idle; * ofproto-dpif implementation. */ extern size_t n_handlers, n_revalidators; -static inline struct rule * -rule_from_cls_rule(const struct cls_rule *cls_rule) -{ - return cls_rule ? CONTAINER_OF(cls_rule, struct rule, cr) : NULL; -} +static inline struct rule *rule_from_cls_rule(const struct cls_rule *); void ofproto_rule_expire(struct rule *rule, uint8_t reason) OVS_REQUIRES(ofproto_mutex); @@ -1738,4 +1718,29 @@ bool ofproto_delete_flow(struct ofproto *, OVS_EXCLUDED(ofproto_mutex); void ofproto_flush_flows(struct ofproto *); + +static inline struct rule_actions * +rule_get_actions(const struct rule *rule) +{ + return ovsrcu_get(struct rule_actions *, &rule->actions); +} + +/* Returns true if 'rule' is an OpenFlow 1.3 "table-miss" rule, false + * otherwise. + * + * ("Table-miss" rules are special because a packet_in generated through one + * uses OFPR_NO_MATCH as its reason, whereas packet_ins generated by any other + * rule use OFPR_ACTION.) */ +static inline bool +rule_is_table_miss(const struct rule *rule) +{ + return rule->cr.priority == 0 && cls_rule_is_catchall(&rule->cr); +} + +static inline struct rule * +rule_from_cls_rule(const struct cls_rule *cls_rule) +{ + return cls_rule ? CONTAINER_OF(cls_rule, struct rule, cr) : NULL; +} + #endif /* ofproto/ofproto-provider.h */ -- 1.7.10.4 _______________________________________________ dev mailing list dev@openvswitch.org http://openvswitch.org/mailman/listinfo/dev