X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=lib%2Fdpif.h;h=9cd8f6afaad92162fafa35d0652828b90f580be0;hb=61e7deb14330d107464c2ea70ed2a9f2f1d27af6;hp=499ee79177053dca54c53925f86d74099de38aee;hpb=ee75c5460e8a038faf8b17d81facb51cd866b83d;p=sliver-openvswitch.git diff --git a/lib/dpif.h b/lib/dpif.h index 499ee7917..9cd8f6afa 100644 --- a/lib/dpif.h +++ b/lib/dpif.h @@ -35,10 +35,10 @@ * The terms written in quotes below are defined in later sections. * * When a datapath "port" receives a packet, it extracts the headers (the - * "flow"). If the datapath's "flow table" contains a "flow entry" whose flow - * is the same as the packet's, then it executes the "actions" in the flow - * entry and increments the flow's statistics. If there is no matching flow - * entry, the datapath instead appends the packet to an "upcall" queue. + * "flow"). If the datapath's "flow table" contains a "flow entry" matching + * the packet, then it executes the "actions" in the flow entry and increments + * the flow's statistics. If there is no matching flow entry, the datapath + * instead appends the packet to an "upcall" queue. * * * Ports @@ -356,11 +356,19 @@ * thread-safe: they may be called from different threads only on * different dpif objects. * - * - Functions that operate on struct dpif_port_dump or struct - * dpif_flow_dump are conditionally thread-safe with respect to those - * objects. That is, one may dump ports or flows from any number of - * threads at once, but each thread must use its own struct dpif_port_dump - * or dpif_flow_dump. + * - dpif_flow_dump_next() is conditionally thread-safe: It may be called + * from different threads with the same 'struct dpif_flow_dump', but all + * other parameters must be different for each thread. + * + * - dpif_flow_dump_done() is conditionally thread-safe: All threads that + * share the same 'struct dpif_flow_dump' must have finished using it. + * This function must then be called exactly once for a particular + * dpif_flow_dump to finish the corresponding flow dump operation. + * + * - Functions that operate on 'struct dpif_port_dump' are conditionally + * thread-safe with respect to those objects. That is, one may dump ports + * from any number of threads at once, but each thread must use its own + * struct dpif_port_dump. */ #ifndef DPIF_H #define DPIF_H 1 @@ -368,8 +376,10 @@ #include #include #include -#include "openflow/openflow.h" #include "netdev.h" +#include "ofpbuf.h" +#include "openflow/openflow.h" +#include "packets.h" #include "util.h" #ifdef __cplusplus @@ -380,7 +390,6 @@ struct dpif; struct ds; struct flow; struct nlattr; -struct ofpbuf; struct sset; struct dpif_class; @@ -413,9 +422,9 @@ struct dpif_dp_stats { uint64_t n_missed; /* Number of flow table misses. */ uint64_t n_lost; /* Number of misses not sent to userspace. */ uint64_t n_flows; /* Number of flows present. */ - uint64_t n_masks; /* Number of mega flow masks. */ uint64_t n_mask_hit; /* Number of mega flow masks visited for flow table matches. */ + uint32_t n_masks; /* Number of mega flow masks. */ }; int dpif_get_dp_stats(const struct dpif *, struct dpif_dp_stats *); @@ -505,24 +514,19 @@ int dpif_flow_get(const struct dpif *, struct dpif_flow_dump { const struct dpif *dpif; - int error; - void *state; + void *iter; }; -void dpif_flow_dump_start(struct dpif_flow_dump *, const struct dpif *); -bool dpif_flow_dump_next(struct dpif_flow_dump *, +void dpif_flow_dump_state_init(const struct dpif *, void **statep); +int dpif_flow_dump_start(struct dpif_flow_dump *, const struct dpif *); +bool dpif_flow_dump_next(struct dpif_flow_dump *, void *state, const struct nlattr **key, size_t *key_len, const struct nlattr **mask, size_t *mask_len, const struct nlattr **actions, size_t *actions_len, const struct dpif_flow_stats **); +bool dpif_flow_dump_next_may_destroy_keys(struct dpif_flow_dump *dump, + void *state); int dpif_flow_dump_done(struct dpif_flow_dump *); - -/* 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 *, - bool needs_help); +void dpif_flow_dump_state_uninit(const struct dpif *, void *state); /* Operation batching interface. * @@ -561,11 +565,10 @@ struct dpif_flow_del { struct dpif_execute { /* Raw support for execute passed along to the provider. */ - 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 ofpbuf *packet; /* Packet to execute. */ + struct pkt_metadata md; /* Packet metadata. */ /* Some dpif providers do not implement every action. The Linux kernel * datapath, in particular, does not implement ARP field modification. @@ -577,6 +580,8 @@ struct dpif_execute { bool needs_help; }; +int dpif_execute(struct dpif *, struct dpif_execute *); + struct dpif_op { enum dpif_op_type type; int error; @@ -601,15 +606,17 @@ const char *dpif_upcall_type_to_string(enum dpif_upcall_type); /* A packet passed up from the datapath to userspace. * - * If 'key', 'actions', or 'userdata' 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.) + * The 'packet', 'key' and 'userdata' may point into data in a buffer + * provided by the caller, so the buffer should be released only after the + * upcall processing has been finished. + * + * While being processed, the 'packet' may be reallocated, so the packet must + * be separately released with ofpbuf_uninit(). */ struct dpif_upcall { /* All types. */ enum dpif_upcall_type type; - struct ofpbuf *packet; /* Packet data. */ + struct ofpbuf packet; /* Packet data. */ struct nlattr *key; /* Flow key. */ size_t key_len; /* Length of 'key' in bytes. */