-int dpif_flow_put(struct dpif *, struct odp_flow_put *);
-int dpif_flow_del(struct dpif *, struct odp_flow *);
-int dpif_flow_get(const struct dpif *, struct odp_flow *);
-int dpif_flow_get_multiple(const struct dpif *, struct odp_flow[], size_t n);
-int dpif_flow_list(const struct dpif *, struct odp_flow[], size_t n,
- size_t *n_out);
-int dpif_flow_list_all(const struct dpif *,
- struct odp_flow **flowsp, size_t *np);
-
-int dpif_execute(struct dpif *, const struct nlattr *actions,
- size_t actions_len, const struct ofpbuf *);
-
-/* Minimum number of bytes of headroom for a packet returned by dpif_recv()
- * member function. This headroom allows "struct odp_msg" to be replaced by
- * "struct ofp_packet_in" without copying the buffer. */
-#define DPIF_RECV_MSG_PADDING \
- ROUND_UP(sizeof(struct ofp_packet_in) - sizeof(struct odp_msg), 8)
-BUILD_ASSERT_DECL(sizeof(struct ofp_packet_in) > sizeof(struct odp_msg));
-BUILD_ASSERT_DECL(DPIF_RECV_MSG_PADDING % 8 == 0);
-
-int dpif_recv_get_mask(const struct dpif *, int *listen_mask);
-int dpif_recv_set_mask(struct dpif *, int listen_mask);
-int dpif_get_sflow_probability(const struct dpif *, uint32_t *probability);
-int dpif_set_sflow_probability(struct dpif *, uint32_t probability);
-int dpif_recv(struct dpif *, struct ofpbuf **);
-int dpif_recv_purge(struct dpif *);
+int dpif_flow_put(struct dpif *, enum dpif_flow_put_flags,
+ const struct nlattr *key, size_t key_len,
+ const struct nlattr *actions, size_t actions_len,
+ struct dpif_flow_stats *);
+int dpif_flow_del(struct dpif *,
+ const struct nlattr *key, size_t key_len,
+ struct dpif_flow_stats *);
+int dpif_flow_get(const struct dpif *,
+ const struct nlattr *key, size_t key_len,
+ struct ofpbuf **actionsp, struct dpif_flow_stats *);
+
+struct dpif_flow_dump {
+ const struct dpif *dpif;
+ int error;
+ void *state;
+};
+void dpif_flow_dump_start(struct dpif_flow_dump *, const struct dpif *);
+bool dpif_flow_dump_next(struct dpif_flow_dump *,
+ const struct nlattr **key, size_t *key_len,
+ const struct nlattr **actions, size_t *actions_len,
+ const struct dpif_flow_stats **);
+int dpif_flow_dump_done(struct dpif_flow_dump *);
+\f
+/* Packet operations. */
+
+int dpif_execute(struct dpif *,
+ const struct nlattr *key, size_t key_len,
+ const struct nlattr *actions, size_t actions_len,
+ const struct ofpbuf *);
+\f
+/* Operation batching interface.
+ *
+ * Some datapaths are faster at performing N operations together than the same
+ * N operations individually, hence an interface for batching.
+ */
+
+enum dpif_op_type {
+ DPIF_OP_FLOW_PUT = 1,
+ DPIF_OP_FLOW_DEL,
+ DPIF_OP_EXECUTE,
+};
+
+struct dpif_flow_put {
+ /* Input. */
+ enum dpif_flow_put_flags flags; /* DPIF_FP_*. */
+ const struct nlattr *key; /* Flow to put. */
+ size_t key_len; /* Length of 'key' in bytes. */
+ const struct nlattr *actions; /* Actions to perform on flow. */
+ size_t actions_len; /* Length of 'actions' in bytes. */
+
+ /* Output. */
+ struct dpif_flow_stats *stats; /* Optional flow statistics. */
+};
+
+struct dpif_flow_del {
+ /* Input. */
+ const struct nlattr *key; /* Flow to delete. */
+ size_t key_len; /* Length of 'key' in bytes. */
+
+ /* Output. */
+ struct dpif_flow_stats *stats; /* Optional flow statistics. */
+};
+
+struct dpif_execute {
+ const struct nlattr *key; /* Partial flow key (only for metadata). */
+ size_t key_len; /* Length of 'key' in bytes. */
+ const struct nlattr *actions; /* Actions to execute on packet. */
+ size_t actions_len; /* Length of 'actions' in bytes. */
+ const struct ofpbuf *packet; /* Packet to execute. */
+};
+
+struct dpif_op {
+ enum dpif_op_type type;
+ int error;
+ union {
+ struct dpif_flow_put flow_put;
+ struct dpif_flow_del flow_del;
+ struct dpif_execute execute;
+ } u;
+};
+
+void dpif_operate(struct dpif *, struct dpif_op **ops, size_t n_ops);
+\f
+/* Upcalls. */
+
+enum dpif_upcall_type {
+ DPIF_UC_MISS, /* Miss in flow table. */
+ DPIF_UC_ACTION, /* OVS_ACTION_ATTR_USERSPACE action. */
+ DPIF_N_UC_TYPES
+};
+
+const char *dpif_upcall_type_to_string(enum dpif_upcall_type);
+
+/* A packet passed up from the datapath to userspace.
+ *
+ * If 'key' or 'actions' is nonnull, then it points into data owned by
+ * 'packet', so their memory cannot be freed separately. (This is hardly a
+ * great way to do things but it works out OK for the dpif providers and
+ * clients that exist so far.)
+ */
+struct dpif_upcall {
+ /* All types. */
+ enum dpif_upcall_type type;
+ struct ofpbuf *packet; /* Packet data. */
+ struct nlattr *key; /* Flow key. */
+ size_t key_len; /* Length of 'key' in bytes. */
+
+ /* DPIF_UC_ACTION only. */
+ uint64_t userdata; /* Argument to OVS_ACTION_ATTR_USERSPACE. */
+};
+
+int dpif_recv_set(struct dpif *, bool enable);
+int dpif_recv(struct dpif *, struct dpif_upcall *, struct ofpbuf *);
+void dpif_recv_purge(struct dpif *);