const struct dpif_class dpif_linux_class = {
"system",
- NULL, /* run */
- NULL, /* wait */
dpif_linux_enumerate,
dpif_linux_open,
dpif_linux_close,
dpif_linux_destroy,
+ NULL, /* run */
+ NULL, /* wait */
dpif_linux_get_stats,
dpif_linux_get_drop_frags,
dpif_linux_set_drop_frags,
}
static void
-dp_netdev_run(void)
+dpif_netdev_run(struct dpif *dpif)
{
- struct shash_node *node;
+ struct dp_netdev *dp = get_dp_netdev(dpif);
+ struct dp_netdev_port *port;
struct ofpbuf packet;
ofpbuf_init(&packet, DP_NETDEV_HEADROOM + VLAN_ETH_HEADER_LEN + max_mtu);
- SHASH_FOR_EACH (node, &dp_netdevs) {
- struct dp_netdev *dp = node->data;
- struct dp_netdev_port *port;
-
- LIST_FOR_EACH (port, node, &dp->port_list) {
- int error;
-
- /* Reset packet contents. */
- ofpbuf_clear(&packet);
- ofpbuf_reserve(&packet, DP_NETDEV_HEADROOM);
- error = netdev_recv(port->netdev, &packet);
- if (!error) {
- dp_netdev_port_input(dp, port, &packet);
- } else if (error != EAGAIN && error != EOPNOTSUPP) {
- static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(1, 5);
- VLOG_ERR_RL(&rl, "error receiving data from %s: %s",
- netdev_get_name(port->netdev), strerror(error));
- }
+ LIST_FOR_EACH (port, node, &dp->port_list) {
+ int error;
+
+ /* Reset packet contents. */
+ ofpbuf_clear(&packet);
+ ofpbuf_reserve(&packet, DP_NETDEV_HEADROOM);
+
+ error = netdev_recv(port->netdev, &packet);
+ if (!error) {
+ dp_netdev_port_input(dp, port, &packet);
+ } else if (error != EAGAIN && error != EOPNOTSUPP) {
+ static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(1, 5);
+ VLOG_ERR_RL(&rl, "error receiving data from %s: %s",
+ netdev_get_name(port->netdev), strerror(error));
}
}
ofpbuf_uninit(&packet);
}
static void
-dp_netdev_wait(void)
+dpif_netdev_wait(struct dpif *dpif)
{
- struct shash_node *node;
-
- SHASH_FOR_EACH (node, &dp_netdevs) {
- struct dp_netdev *dp = node->data;
- struct dp_netdev_port *port;
+ struct dp_netdev *dp = get_dp_netdev(dpif);
+ struct dp_netdev_port *port;
- LIST_FOR_EACH (port, node, &dp->port_list) {
- netdev_recv_wait(port->netdev);
- }
+ LIST_FOR_EACH (port, node, &dp->port_list) {
+ netdev_recv_wait(port->netdev);
}
}
-
static void
dp_netdev_strip_vlan(struct ofpbuf *packet)
{
const struct dpif_class dpif_netdev_class = {
"netdev",
- dp_netdev_run,
- dp_netdev_wait,
NULL, /* enumerate */
dpif_netdev_open,
dpif_netdev_close,
dpif_netdev_destroy,
+ dpif_netdev_run,
+ dpif_netdev_wait,
dpif_netdev_get_stats,
dpif_netdev_get_drop_frags,
dpif_netdev_set_drop_frags,
* the type assumed if no type is specified when opening a dpif. */
const char *type;
- /* Performs periodic work needed by dpifs of this class, if any is
- * necessary. */
- void (*run)(void);
-
- /* Arranges for poll_block() to wake up if the "run" member function needs
- * to be called. */
- void (*wait)(void);
-
/* Enumerates the names of all known created datapaths, if possible, into
* 'all_dps'. The caller has already initialized 'all_dps' and other dpif
* classes might already have added names to it.
* the 'close' member function. */
int (*destroy)(struct dpif *dpif);
+ /* Performs periodic work needed by 'dpif', if any is necessary. */
+ void (*run)(struct dpif *dpif);
+
+ /* Arranges for poll_block() to wake up if the "run" member function needs
+ * to be called for 'dpif'. */
+ void (*wait)(struct dpif *dpif);
+
/* Retrieves statistics for 'dpif' into 'stats'. */
int (*get_stats)(const struct dpif *dpif, struct odp_stats *stats);
}
}
-/* Performs periodic work needed by all the various kinds of dpifs.
- *
- * If your program opens any dpifs, it must call both this function and
- * netdev_run() within its main poll loop. */
-void
-dp_run(void)
-{
- struct shash_node *node;
- SHASH_FOR_EACH(node, &dpif_classes) {
- const struct registered_dpif_class *registered_class = node->data;
- if (registered_class->dpif_class->run) {
- registered_class->dpif_class->run();
- }
- }
-}
-
-/* Arranges for poll_block() to wake up when dp_run() needs to be called.
- *
- * If your program opens any dpifs, it must call both this function and
- * netdev_wait() within its main poll loop. */
-void
-dp_wait(void)
-{
- struct shash_node *node;
- SHASH_FOR_EACH(node, &dpif_classes) {
- const struct registered_dpif_class *registered_class = node->data;
- if (registered_class->dpif_class->wait) {
- registered_class->dpif_class->wait();
- }
- }
-}
-
/* Registers a new datapath provider. After successful registration, new
* datapaths of that type can be opened using dpif_open(). */
int
}
}
+/* Performs periodic work needed by 'dpif'. */
+void
+dpif_run(struct dpif *dpif)
+{
+ if (dpif->dpif_class->run) {
+ dpif->dpif_class->run(dpif);
+ }
+}
+
+/* Arranges for poll_block() to wake up when dp_run() needs to be called for
+ * 'dpif'. */
+void
+dpif_wait(struct dpif *dpif)
+{
+ if (dpif->dpif_class->wait) {
+ dpif->dpif_class->wait(dpif);
+ }
+}
+
/* Returns the name of datapath 'dpif' prefixed with the type
* (for use in log messages). */
const char *
struct sset;
struct dpif_class;
-void dp_run(void);
-void dp_wait(void);
-
int dp_register_provider(const struct dpif_class *);
int dp_unregister_provider(const char *type);
void dp_enumerate_types(struct sset *types);
int dpif_create_and_open(const char *name, const char *type, struct dpif **);
void dpif_close(struct dpif *);
+void dpif_run(struct dpif *);
+void dpif_wait(struct dpif *);
+
const char *dpif_name(const struct dpif *);
const char *dpif_base_name(const struct dpif *);
int error;
int i;
+ dpif_run(p->dpif);
+
for (i = 0; i < 50; i++) {
struct dpif_upcall packet;
struct ofbundle *bundle;
struct ofport *ofport;
+ dpif_wait(p->dpif);
HMAP_FOR_EACH (ofport, hmap_node, &p->ports) {
ofport_wait(ofport);
}
VLOG_FATAL("unrecoverable datapath error (%s)", strerror(error));
}
unixctl_server_run(unixctl);
- dp_run();
netdev_run();
ofproto_wait(ofproto);
unixctl_server_wait(unixctl);
- dp_wait();
netdev_wait();
if (exiting) {
poll_immediate_wake();
#include "command-line.h"
#include "compiler.h"
#include "daemon.h"
-#include "dpif.h"
#include "dummy.h"
#include "leak-checker.h"
#include "netdev.h"
}
bridge_run();
unixctl_server_run(unixctl);
- dp_run();
netdev_run();
signal_wait(sighup);
bridge_wait();
unixctl_server_wait(unixctl);
- dp_wait();
netdev_wait();
if (exiting) {
poll_immediate_wake();