ofproto-dpif-upcall: Add memory usage stats.
[sliver-openvswitch.git] / vswitchd / bridge.c
index f3b03af..3e16134 100644 (file)
@@ -22,6 +22,7 @@
 #include "bfd.h"
 #include "bitmap.h"
 #include "cfm.h"
+#include "connectivity.h"
 #include "coverage.h"
 #include "daemon.h"
 #include "dirs.h"
@@ -41,6 +42,7 @@
 #include "ofproto/bond.h"
 #include "ofproto/ofproto.h"
 #include "poll-loop.h"
+#include "seq.h"
 #include "sha1.h"
 #include "shash.h"
 #include "smap.h"
@@ -155,6 +157,9 @@ static struct ovsdb_idl_txn *daemonize_txn;
 /* Most recently processed IDL sequence number. */
 static unsigned int idl_seqno;
 
+/* Track changes to port connectivity. */
+static uint64_t connectivity_seqno = LLONG_MIN;
+
 /* Each time this timer expires, the bridge fetches interface and mirror
  * statistics and pushes them into the database. */
 #define IFACE_STATS_INTERVAL (5 * 1000) /* In milliseconds. */
@@ -1464,15 +1469,9 @@ iface_create(struct bridge *br, const struct ovsrec_interface *iface_cfg,
     struct port *port;
     int error;
 
-    /* Do the bits that can fail up front.
-     *
-     * It's a bit dangerous to call bridge_run_fast() here as ofproto's
-     * internal datastructures may not be consistent.  Eventually, when port
-     * additions and deletions are cheaper, these calls should be removed. */
-    bridge_run_fast();
+    /* Do the bits that can fail up front. */
     ovs_assert(!iface_lookup(br, iface_cfg->name));
     error = iface_do_create(br, iface_cfg, port_cfg, &ofp_port, &netdev);
-    bridge_run_fast();
     if (error) {
         iface_set_ofport(iface_cfg, OFPP_NONE);
         iface_clear_db_record(iface_cfg);
@@ -2164,12 +2163,19 @@ instant_stats_run(void)
 
     if (!instant_txn) {
         struct bridge *br;
+        uint64_t seq;
 
         if (time_msec() < instant_next_txn) {
             return;
         }
         instant_next_txn = time_msec() + INSTANT_INTERVAL_MSEC;
 
+        seq = seq_read(connectivity_seq_get());
+        if (seq == connectivity_seqno) {
+            return;
+        }
+        connectivity_seqno = seq;
+
         instant_txn = ovsdb_idl_txn_create(idl);
         HMAP_FOR_EACH (br, node, &all_bridges) {
             struct iface *iface;
@@ -2246,31 +2252,6 @@ instant_stats_wait(void)
     }
 }
 \f
-/* Performs periodic activity required by bridges that needs to be done with
- * the least possible latency.
- *
- * It makes sense to call this function a couple of times per poll loop, to
- * provide a significant performance boost on some benchmarks with ofprotos
- * that use the ofproto-dpif implementation. */
-void
-bridge_run_fast(void)
-{
-    struct sset types;
-    const char *type;
-    struct bridge *br;
-
-    sset_init(&types);
-    ofproto_enumerate_types(&types);
-    SSET_FOR_EACH (type, &types) {
-        ofproto_type_run_fast(type);
-    }
-    sset_destroy(&types);
-
-    HMAP_FOR_EACH (br, node, &all_bridges) {
-        ofproto_run_fast(br->ofproto);
-    }
-}
-
 void
 bridge_run(void)
 {
@@ -2472,6 +2453,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);