bridge: Refresh STP statistics separately from status
[sliver-openvswitch.git] / ofproto / ofproto.c
index c4ce8a2..3a60328 100644 (file)
@@ -738,7 +738,7 @@ ofproto_set_n_handler_threads(unsigned limit)
     if (limit) {
         n_handler_threads = limit;
     } else {
-        int n_proc = sysconf(_SC_NPROCESSORS_ONLN);
+        int n_proc = count_cpu_cores();
         n_handler_threads = n_proc > 2 ? n_proc - 2 : 1;
     }
 }
@@ -884,6 +884,27 @@ ofproto_port_get_stp_status(struct ofproto *ofproto, ofp_port_t ofp_port,
             ? ofproto->ofproto_class->get_stp_port_status(ofport, s)
             : EOPNOTSUPP);
 }
+
+/* Retrieves STP port statistics of 'ofp_port' on 'ofproto' and stores it in
+ * 's'.  If the 'enabled' member in 's' is false, then the other members
+ * are not meaningful.
+ *
+ * Returns 0 if successful, otherwise a positive errno value.*/
+int
+ofproto_port_get_stp_stats(struct ofproto *ofproto, ofp_port_t ofp_port,
+                           struct ofproto_port_stp_stats *s)
+{
+    struct ofport *ofport = ofproto_get_port(ofproto, ofp_port);
+    if (!ofport) {
+        VLOG_WARN_RL(&rl, "%s: cannot get STP stats on nonexistent "
+                     "port %"PRIu16, ofproto->name, ofp_port);
+        return ENODEV;
+    }
+
+    return (ofproto->ofproto_class->get_stp_port_stats
+            ? ofproto->ofproto_class->get_stp_port_stats(ofport, s)
+            : EOPNOTSUPP);
+}
 \f
 /* Queue DSCP configuration. */