datapath: Change listing flows to use an iterator concept.
[sliver-openvswitch.git] / include / openvswitch / datapath-protocol.h
index 731a849..730aa22 100644 (file)
 
 #ifndef __aligned_u64
 #define __aligned_u64 __u64 __attribute__((aligned(8)))
+#define __aligned_be64 __be64 __attribute__((aligned(8)))
+#define __aligned_le64 __le64 __attribute__((aligned(8)))
 #endif
 
 #include <linux/if_link.h>
+#include <linux/netlink.h>
 
 #define ODP_MAX 256             /* Maximum number of datapaths. */
 
@@ -84,9 +87,9 @@
 #define ODP_VPORT_QUERY         _IOWR('O', 9, struct odp_port)
 #define ODP_VPORT_LIST          _IOWR('O', 10, struct odp_portvec)
 
-#define ODP_FLOW_GET            _IOWR('O', 13, struct odp_flow)
+#define ODP_FLOW_GET            _IOWR('O', 13, struct odp_flowvec)
 #define ODP_FLOW_PUT            _IOWR('O', 14, struct odp_flow)
-#define ODP_FLOW_LIST           _IOWR('O', 15, struct odp_flowvec)
+#define ODP_FLOW_DUMP           _IOWR('O', 15, struct odp_flow_dump)
 #define ODP_FLOW_FLUSH          _IO('O', 16)
 #define ODP_FLOW_DEL            _IOWR('O', 17, struct odp_flow)
 
@@ -128,7 +131,6 @@ struct odp_stats {
 /* Logical ports. */
 #define ODPP_LOCAL      ((uint16_t)0)
 #define ODPP_NONE       ((uint16_t)-1)
-#define ODPP_NORMAL     ((uint16_t)-2)
 
 /* Listening channels. */
 #define _ODPL_MISS_NR   0       /* Packet missed in flow table. */
@@ -141,10 +143,9 @@ struct odp_stats {
 
 /**
  * struct odp_msg - format of messages read from datapath fd.
- * @type: One of the %_ODPL_* constants.
  * @length: Total length of message, including this header.
+ * @type: One of the %_ODPL_* constants.
  * @port: Port that received the packet embedded in this message.
- * @reserved: Not currently used.  Should be set to 0.
  * @arg: Argument value whose meaning depends on @type.
  *
  * For @type == %_ODPL_MISS_NR, the header is followed by packet data.  The
@@ -161,11 +162,10 @@ struct odp_stats {
  * data.
  */
 struct odp_msg {
-    uint32_t type;
     uint32_t length;
+    uint16_t type;
     uint16_t port;
-    uint16_t reserved;
-    uint32_t arg;
+    __aligned_u64 arg;
 };
 
 /**
@@ -219,7 +219,7 @@ struct odp_flow_stats {
 #define ODP_TCI_PRESENT 0x1000  /* CFI bit */
 
 struct odp_flow_key {
-    ovs_be32 tun_id;            /* Encapsulating tunnel ID. */
+    ovs_be64 tun_id;            /* Encapsulating tunnel ID. */
     ovs_be32 nw_src;            /* IP source address. */
     ovs_be32 nw_dst;            /* IP destination address. */
     uint16_t in_port;           /* Input switch port. */
@@ -237,6 +237,7 @@ struct odp_flow_key {
 
 /* Flags for ODP_FLOW. */
 #define ODPFF_ZERO_TCP_FLAGS (1 << 0) /* Zero the TCP flags. */
+#define ODPFF_EOF            (1 << 1) /* ODP_FLOW_DUMP: end of flow table. */
 
 struct odp_flow {
     struct odp_flow_stats stats;
@@ -262,6 +263,21 @@ struct odp_flowvec {
     uint32_t n_flows;
 };
 
+/* ODP_FLOW_DUMP argument.
+ *
+ * This is used to iterate through the flow table flow-by-flow.  Each
+ * ODP_FLOW_DUMP call either stores a new odp_flow into 'flow' or stores
+ * ODPFF_EOF into flow->flags to indicate that the end of the table has been
+ * reaches, and updates 'state' in-place.
+ *
+ * Before the first call, zero 'state'.  The format of 'state' is otherwise
+ * unspecified.
+ */
+struct odp_flow_dump {
+       struct odp_flow *flow;
+       uint32_t state[2];
+};
+
 /* Action types. */
 enum odp_action_type {
     ODPAT_UNSPEC,