datapath: Change ODP_FLOW_GET to retrieve only a single flow at a time.
[sliver-openvswitch.git] / lib / dpif-linux.c
index 8e584ea..e0619b5 100644 (file)
@@ -365,6 +365,14 @@ dpif_linux_port_query_by_name(const struct dpif *dpif, const char *devname,
     return dpif_linux_port_query__(dpif, 0, devname, dpif_port);
 }
 
+static int
+dpif_linux_get_max_ports(const struct dpif *dpif OVS_UNUSED)
+{
+    /* If the datapath increases its range of supported ports, then it should
+     * start reporting that. */
+    return 1024;
+}
+
 static int
 dpif_linux_flow_flush(struct dpif *dpif_)
 {
@@ -451,12 +459,9 @@ dpif_linux_port_poll_wait(const struct dpif *dpif_)
 }
 
 static int
-dpif_linux_flow_get(const struct dpif *dpif_, struct odp_flow flows[], int n)
+dpif_linux_flow_get(const struct dpif *dpif_, struct odp_flow *flow)
 {
-    struct odp_flowvec fv;
-    fv.flows = flows;
-    fv.n_flows = n;
-    return do_ioctl(dpif_, ODP_FLOW_GET, &fv);
+    return do_ioctl(dpif_, ODP_FLOW_GET, flow);
 }
 
 static int
@@ -645,6 +650,26 @@ dpif_linux_recv_wait(struct dpif *dpif_)
     poll_fd_wait(dpif->fd, POLLIN);
 }
 
+static void
+dpif_linux_recv_purge(struct dpif *dpif_)
+{
+    struct dpif_linux *dpif = dpif_linux_cast(dpif_);
+    int i;
+
+    /* This is somewhat bogus because it assumes that the following macros have
+     * fixed values, but it's going to go away later.  */
+#define DP_N_QUEUES 3
+#define DP_MAX_QUEUE_LEN 100
+    for (i = 0; i < DP_N_QUEUES * DP_MAX_QUEUE_LEN; i++) {
+        /* Reading even 1 byte discards a whole datagram and saves time. */
+        char buffer;
+
+        if (read(dpif->fd, &buffer, 1) != 1) {
+            break;
+        }
+    }
+}
+
 const struct dpif_class dpif_linux_class = {
     "system",
     NULL,
@@ -661,6 +686,7 @@ const struct dpif_class dpif_linux_class = {
     dpif_linux_port_del,
     dpif_linux_port_query_by_number,
     dpif_linux_port_query_by_name,
+    dpif_linux_get_max_ports,
     dpif_linux_port_dump_start,
     dpif_linux_port_dump_next,
     dpif_linux_port_dump_done,
@@ -681,6 +707,7 @@ const struct dpif_class dpif_linux_class = {
     dpif_linux_queue_to_priority,
     dpif_linux_recv,
     dpif_linux_recv_wait,
+    dpif_linux_recv_purge,
 };
 \f
 static int get_openvswitch_major(void);