Signed-off-by: Ethan Jackson <et...@nicira.com> --- ofproto/ofproto-dpif-upcall.c | 17 +++++++++++++++++ ofproto/ofproto-dpif-upcall.h | 2 ++ ofproto/ofproto-dpif.c | 12 ++++++++++++ ofproto/ofproto-provider.h | 6 ++++++ ofproto/ofproto.c | 13 +++++++++++++ ofproto/ofproto.h | 1 + vswitchd/bridge.c | 9 +++++++++ 7 files changed, 60 insertions(+)
diff --git a/ofproto/ofproto-dpif-upcall.c b/ofproto/ofproto-dpif-upcall.c index 8a32c00..08b4e8e 100644 --- a/ofproto/ofproto-dpif-upcall.c +++ b/ofproto/ofproto-dpif-upcall.c @@ -262,6 +262,23 @@ udpif_revalidate(struct udpif *udpif) udpif_drop_key_clear(udpif); } +void +udpif_get_memory_usage(struct udpif *udpif, struct simap *usage) +{ + size_t i; + + simap_increase(usage, "dispatchers", 1); + simap_increase(usage, "flow_dumpers", 1); + + simap_increase(usage, "handlers", n_handlers); + for (i = 0; i < n_handlers; i++) { + struct handler *handler = &udpif->handlers[i]; + ovs_mutex_lock(&handler->mutex); + simap_increase(usage, "handler upcalls", handler->n_upcalls); + ovs_mutex_unlock(&handler->mutex); + } +} + /* Destroys and deallocates 'upcall'. */ static void upcall_destroy(struct upcall *upcall) diff --git a/ofproto/ofproto-dpif-upcall.h b/ofproto/ofproto-dpif-upcall.h index 3ff3e4b..a4d8228 100644 --- a/ofproto/ofproto-dpif-upcall.h +++ b/ofproto/ofproto-dpif-upcall.h @@ -39,6 +39,8 @@ void udpif_destroy(struct udpif *); void udpif_wait(struct udpif *); void udpif_revalidate(struct udpif *); + +void udpif_get_memory_usage(struct udpif *, struct simap *usage); /* udpif figures out how to forward packets, and does forward them, but it * can't set up datapath flows on its own. This interface passes packet diff --git a/ofproto/ofproto-dpif.c b/ofproto/ofproto-dpif.c index e3fbbe8..2659a5b 100644 --- a/ofproto/ofproto-dpif.c +++ b/ofproto/ofproto-dpif.c @@ -1524,6 +1524,17 @@ get_memory_usage(const struct ofproto *ofproto_, struct simap *usage) } static void +type_get_memory_usage(const char *type, struct simap *usage) +{ + struct dpif_backer *backer; + + backer = shash_find_data(&all_dpif_backers, type); + if (backer) { + udpif_get_memory_usage(backer->udpif, usage); + } +} + +static void flush(struct ofproto *ofproto_) { struct ofproto_dpif *ofproto = ofproto_dpif_cast(ofproto_); @@ -6101,6 +6112,7 @@ const struct ofproto_class ofproto_dpif_class = { run, wait, get_memory_usage, + type_get_memory_usage, flush, get_features, get_tables, diff --git a/ofproto/ofproto-provider.h b/ofproto/ofproto-provider.h index f0e10cf..bdd6b42 100644 --- a/ofproto/ofproto-provider.h +++ b/ofproto/ofproto-provider.h @@ -781,6 +781,12 @@ struct ofproto_class { void (*get_memory_usage)(const struct ofproto *ofproto, struct simap *usage); + /* Adds some memory usage statistics for the implementation of 'type' + * into 'usage', for use with memory_report(). + * + * This function is optional. */ + void (*type_get_memory_usage)(const char *type, struct simap *usage); + /* Every "struct rule" in 'ofproto' is about to be deleted, one by one. * This function may prepare for that, for example by clearing state in * advance. It should *not* actually delete any "struct rule"s from diff --git a/ofproto/ofproto.c b/ofproto/ofproto.c index 48feff7..ba40406 100644 --- a/ofproto/ofproto.c +++ b/ofproto/ofproto.c @@ -1593,6 +1593,19 @@ ofproto_get_memory_usage(const struct ofproto *ofproto, struct simap *usage) } void +ofproto_type_get_memory_usage(const char *datapath_type, struct simap *usage) +{ + const struct ofproto_class *class; + + datapath_type = ofproto_normalize_type(datapath_type); + class = ofproto_class_find__(datapath_type); + + if (class->type_get_memory_usage) { + class->type_get_memory_usage(datapath_type, usage); + } +} + +void ofproto_get_ofproto_controller_info(const struct ofproto *ofproto, struct shash *info) { diff --git a/ofproto/ofproto.h b/ofproto/ofproto.h index 0b53a5f..8d599f0 100644 --- a/ofproto/ofproto.h +++ b/ofproto/ofproto.h @@ -171,6 +171,7 @@ void ofproto_wait(struct ofproto *); bool ofproto_is_alive(const struct ofproto *); void ofproto_get_memory_usage(const struct ofproto *, struct simap *); +void ofproto_type_get_memory_usage(const char *datapath_type, struct simap *); /* A port within an OpenFlow switch. * diff --git a/vswitchd/bridge.c b/vswitchd/bridge.c index 8fec72e..c3f1488 100644 --- a/vswitchd/bridge.c +++ b/vswitchd/bridge.c @@ -2522,6 +2522,15 @@ void bridge_get_memory_usage(struct simap *usage) { struct bridge *br; + struct sset types; + const char *type; + + sset_init(&types); + ofproto_enumerate_types(&types); + SSET_FOR_EACH (type, &types) { + ofproto_type_get_memory_usage(type, usage); + } + sset_destroy(&types); HMAP_FOR_EACH (br, node, &all_bridges) { ofproto_get_memory_usage(br->ofproto, usage); -- 1.8.1.2 _______________________________________________ dev mailing list dev@openvswitch.org http://openvswitch.org/mailman/listinfo/dev