aboutsummaryrefslogtreecommitdiff
path: root/lib/dpif.c
diff options
context:
space:
mode:
authorBen Pfaff <blp@nicira.com>2012-01-12 17:09:22 -0800
committerBen Pfaff <blp@nicira.com>2012-01-12 17:09:22 -0800
commita12b3eadc64573c132e3630c5602be3c9b7f7156 (patch)
treebbd67b1f66a5418b5c417982d9131eddf68c901e /lib/dpif.c
parent300c69464ca88ca97d4ce842b590ce6ce603201b (diff)
dpif: Simplify the "listen mask" concept.
At one point in the past, there were three separate queues between the kernel module and OVS userspace, each of which corresponded to a Netlink socket (or, before that, to a character device). It made sense to allow each of these to be enabled or disabled separately, hence the "listen mask" concept in the dpif layer. These days, the concept is much less clear-cut. Queuing is no longer on the basis of different classes of packets but instead striped across a collection of sockets based on input port. It doesn't really make sense to enable receiving packets on the basis of the kind of packet anymore. Accordingly, this commit simplifies the "listen_mask" to just a bool that either enables or disables receiving packets. It could be useful to enable or disable receiving packets on a per-vport basis, but the rest of the code isn't ready to make use of that so this commit doesn't generalize this much. Based on this discussion on ovs-dev: http://openvswitch.org/pipermail/dev/2011-October/012044.html Signed-off-by: Ben Pfaff <blp@nicira.com>
Diffstat (limited to 'lib/dpif.c')
-rw-r--r--lib/dpif.c46
1 files changed, 8 insertions, 38 deletions
diff --git a/lib/dpif.c b/lib/dpif.c
index ecafac1a..4edf54e8 100644
--- a/lib/dpif.c
+++ b/lib/dpif.c
@@ -1033,54 +1033,24 @@ dpif_upcall_type_to_string(enum dpif_upcall_type type)
}
}
-static bool OVS_UNUSED
-is_valid_listen_mask(int listen_mask)
-{
- return !(listen_mask & ~((1u << DPIF_UC_MISS) |
- (1u << DPIF_UC_ACTION)));
-}
-
-/* Retrieves 'dpif''s "listen mask" into '*listen_mask'. A 1-bit of value 2**X
- * set in '*listen_mask' indicates that dpif_recv() will receive messages of
- * the type (from "enum dpif_upcall_type") with value X. Returns 0 if
- * successful, otherwise a positive errno value. */
-int
-dpif_recv_get_mask(const struct dpif *dpif, int *listen_mask)
-{
- int error = dpif->dpif_class->recv_get_mask(dpif, listen_mask);
- if (error) {
- *listen_mask = 0;
- }
- assert(is_valid_listen_mask(*listen_mask));
- log_operation(dpif, "recv_get_mask", error);
- return error;
-}
-
-/* Sets 'dpif''s "listen mask" to 'listen_mask'. A 1-bit of value 2**X set in
- * '*listen_mask' requests that dpif_recv() will receive messages of the type
- * (from "enum dpif_upcall_type") with value X. Returns 0 if successful,
- * otherwise a positive errno value.
+/* Enables or disables receiving packets with dpif_recv() on 'dpif'. Returns 0
+ * if successful, otherwise a positive errno value.
*
- * Turning DPIF_UC_ACTION off and then back on may change the Netlink PID
+ * Turning packet receive off and then back on may change the Netlink PID
* assignments returned by dpif_port_get_pid(). If the client does this, it
* must update all of the flows that have OVS_ACTION_ATTR_USERSPACE actions
* using the new PID assignment. */
int
-dpif_recv_set_mask(struct dpif *dpif, int listen_mask)
+dpif_recv_set(struct dpif *dpif, bool enable)
{
- int error;
-
- assert(is_valid_listen_mask(listen_mask));
-
- error = dpif->dpif_class->recv_set_mask(dpif, listen_mask);
- log_operation(dpif, "recv_set_mask", error);
+ int error = dpif->dpif_class->recv_set(dpif, enable);
+ log_operation(dpif, "recv_set", error);
return error;
}
/* Polls for an upcall from 'dpif'. If successful, stores the upcall into
- * '*upcall'. Only upcalls of the types selected with dpif_recv_set_mask()
- * member function will ordinarily be received (but if a message type is
- * enabled and then later disabled, some stragglers might pop up).
+ * '*upcall'. Should only be called if dpif_recv_set() has been used to enable
+ * receiving packets on 'dpif'.
*
* The caller takes ownership of the data that 'upcall' points to.
* 'upcall->key' and 'upcall->actions' (if nonnull) point into data owned by