enumerate_types,
enumerate_names,
del,
+ NULL, /* type_run */
+ NULL, /* type_run_fast */
+ NULL, /* type_wait */
alloc,
construct,
destruct,
*/
int (*del)(const char *type, const char *name);
+/* ## ------------------------ ## */
+/* ## Top-Level type Functions ## */
+/* ## ------------------------ ## */
+
+ /* Performs any periodic activity required on ofprotos of type
+ * 'type'.
+ *
+ * An ofproto provider may implement it or not, depending on whether
+ * it needs type-level maintenance.
+ *
+ * Returns 0 if successful, otherwise a positive errno value. */
+ int (*type_run)(const char *type);
+
+ /* Performs periodic activity required on ofprotos of type 'type'
+ * that needs to be done with the least possible latency.
+ *
+ * This is run multiple times per main loop. An ofproto provider may
+ * implement it or not, according to whether it provides a performance
+ * boost for that ofproto implementation.
+ *
+ * Returns 0 if successful, otherwise a positive errno value. */
+ int (*type_run_fast)(const char *type);
+
+ /* Causes the poll loop to wake up when a type 'type''s 'run'
+ * function needs to be called, e.g. by calling the timer or fd
+ * waiting functions in poll-loop.h.
+ *
+ * An ofproto provider may implement it or not, depending on whether
+ * it needs type-level maintenance. */
+ void (*type_wait)(const char *type);
+
/* ## --------------------------- ## */
/* ## Top-Level ofproto Functions ## */
/* ## --------------------------- ## */
}
}
+int
+ofproto_type_run(const char *datapath_type)
+{
+ const struct ofproto_class *class;
+ int error;
+
+ datapath_type = ofproto_normalize_type(datapath_type);
+ class = ofproto_class_find__(datapath_type);
+
+ error = class->type_run ? class->type_run(datapath_type) : 0;
+ if (error && error != EAGAIN) {
+ VLOG_ERR_RL(&rl, "%s: type_run failed (%s)",
+ datapath_type, strerror(error));
+ }
+ return error;
+}
+
+int
+ofproto_type_run_fast(const char *datapath_type)
+{
+ const struct ofproto_class *class;
+ int error;
+
+ datapath_type = ofproto_normalize_type(datapath_type);
+ class = ofproto_class_find__(datapath_type);
+
+ error = class->type_run_fast ? class->type_run_fast(datapath_type) : 0;
+ if (error && error != EAGAIN) {
+ VLOG_ERR_RL(&rl, "%s: type_run_fast failed (%s)",
+ datapath_type, strerror(error));
+ }
+ return error;
+}
+
+void
+ofproto_type_wait(const char *datapath_type)
+{
+ const struct ofproto_class *class;
+
+ datapath_type = ofproto_normalize_type(datapath_type);
+ class = ofproto_class_find__(datapath_type);
+
+ if (class->type_wait) {
+ class->type_wait(datapath_type);
+ }
+}
+
int
ofproto_run(struct ofproto *p)
{
void ofproto_init(const struct shash *iface_hints);
+int ofproto_type_run(const char *datapath_type);
+int ofproto_type_run_fast(const char *datapath_type);
+void ofproto_type_wait(const char *datapath_type);
+
int ofproto_create(const char *datapath, const char *datapath_type,
struct ofproto **ofprotop);
void ofproto_destroy(struct ofproto *);
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);
}
static const struct ovsrec_open_vswitch null_cfg;
const struct ovsrec_open_vswitch *cfg;
struct ovsdb_idl_txn *reconf_txn = NULL;
+ struct sset types;
+ const char *type;
bool vlan_splinters_changed;
struct bridge *br;
* returns immediately. */
bridge_init_ofproto(cfg);
+ /* Let each datapath type do the work that it needs to do. */
+ sset_init(&types);
+ ofproto_enumerate_types(&types);
+ SSET_FOR_EACH (type, &types) {
+ ofproto_type_run(type);
+ }
+ sset_destroy(&types);
+
/* Let each bridge do the work that it needs to do. */
HMAP_FOR_EACH (br, node, &all_bridges) {
ofproto_run(br->ofproto);
void
bridge_wait(void)
{
+ struct sset types;
+ const char *type;
+
ovsdb_idl_wait(idl);
if (reconfiguring) {
poll_immediate_wake();
}
+ sset_init(&types);
+ ofproto_enumerate_types(&types);
+ SSET_FOR_EACH (type, &types) {
+ ofproto_type_wait(type);
+ }
+ sset_destroy(&types);
+
if (!hmap_is_empty(&all_bridges)) {
struct bridge *br;