Catalli's threaded switch
[sliver-openvswitch.git] / lib / netdev.c
index 24c2a88..00ded43 100644 (file)
@@ -74,7 +74,6 @@ netdev_initialize(void)
 
     if (status < 0) {
         int i;
-
         fatal_signal_add_hook(close_all_netdevs, NULL, NULL, true);
 
         status = 0;
@@ -122,7 +121,7 @@ int
 netdev_register_provider(const struct netdev_class *new_class)
 {
     struct netdev_class *new_provider;
-
+    
     if (shash_find(&netdev_classes, new_class->type)) {
         VLOG_WARN("attempted to register duplicate netdev provider: %s",
                    new_class->type);
@@ -505,6 +504,28 @@ netdev_recv_wait(struct netdev *netdev)
     }
 }
 
+#ifdef THREADED
+/* Attempts to receive and process 'batch' packets from 'netdev'. */
+int
+netdev_dispatch(struct netdev *netdev, int batch, pkt_handler h, u_char *user)
+{
+    int (*dispatch)(struct netdev*, int, pkt_handler, u_char *);
+
+    dispatch = netdev_get_dev(netdev)->netdev_class->dispatch;
+    return dispatch ? dispatch(netdev, batch, h, user) : 0;
+}
+
+/* Returns the file descriptor */
+int
+netdev_get_fd(struct netdev *netdev)
+{
+    int (*get_fd)(struct netdev *);
+
+    get_fd = netdev_get_dev(netdev)->netdev_class->get_fd;
+    return get_fd ? get_fd(netdev) : 0;
+}
+#endif
+
 /* Discards all packets waiting to be received from 'netdev'. */
 int
 netdev_drain(struct netdev *netdev)