Added new interface statistics.
[sliver-openvswitch.git] / include / openflow.h
index 238c571..ba25687 100644 (file)
@@ -68,7 +68,7 @@
 /* The most significant bit being set in the version field indicates an
  * experimental OpenFlow version.  
  */
-#define OFP_VERSION   0x85
+#define OFP_VERSION   0x88
 
 #define OFP_MAX_TABLE_NAME_LEN 32
 #define OFP_MAX_PORT_NAME_LEN  16
@@ -84,10 +84,13 @@ enum ofp_port {
     OFPP_MAX = 0x100,
 
     /* Fake output "ports". */
+    OFPP_IN_PORT    = 0xfff8,  /* Send the packet out the input port.  This 
+                                  virtual port must be explicitly used 
+                                  in order to send back out of the input 
+                                  port. */
     OFPP_TABLE      = 0xfff9,  /* Perform actions in flow table.  
-                                * NB: This can only be the destination
-                                * port for packet-out messages. 
-                                */
+                                  NB: This can only be the destination
+                                  port for packet-out messages. */
     OFPP_NORMAL     = 0xfffa,  /* Process with normal L2/L3 switching. */
     OFPP_FLOOD      = 0xfffb,  /* All physical ports except input port and 
                                   those disabled by STP. */
@@ -132,7 +135,13 @@ OFP_ASSERT(sizeof(struct ofp_header) == 8);
 
 enum ofp_config_flags {
     /* Tells datapath to notify the controller of expired flow entries. */
-    OFPC_SEND_FLOW_EXP = 1 << 0
+    OFPC_SEND_FLOW_EXP = 1 << 0,
+
+    /* Handling of IP fragments. */
+    OFPC_FRAG_NORMAL = 0 << 1,  /* No special handling for fragments. */
+    OFPC_FRAG_DROP = 1 << 1,    /* Drop fragments. */
+    OFPC_FRAG_REASM = 2 << 1,   /* Reassemble (only if OFPC_IP_REASM set). */
+    OFPC_FRAG_MASK = 3 << 1
 };
 
 /* Switch configuration. */
@@ -150,8 +159,9 @@ enum ofp_capabilities {
     OFPC_TABLE_STATS  = 1 << 1, /* Table statistics. */
     OFPC_PORT_STATS   = 1 << 2, /* Port statistics. */
     OFPC_STP          = 1 << 3, /* 802.11d spanning tree. */
-    OFPC_MULTI_PHY_TX = 1 << 4  /* Supports transmitting through multiple
+    OFPC_MULTI_PHY_TX = 1 << 4, /* Supports transmitting through multiple
                                    physical interfaces */
+    OFPC_IP_REASM     = 1 << 5  /* Can reassemble IP fragments. */
 };
 
 /* Flags to indicate behavior of the physical port */
@@ -233,7 +243,7 @@ struct ofp_port_mod {
 OFP_ASSERT(sizeof(struct ofp_port_mod) == 44);
 
 /* Why is this packet being sent to the controller? */
-enum ofp_reason {
+enum ofp_packet_in_reason {
     OFPR_NO_MATCH,          /* No matching flow. */
     OFPR_ACTION             /* Action explicitly output to controller. */
 };
@@ -297,13 +307,13 @@ OFP_ASSERT(sizeof(struct ofp_action) == 8);
 /* Send packet (controller -> datapath). */
 struct ofp_packet_out {
     struct ofp_header header;
-    uint32_t buffer_id;     /* ID assigned by datapath (-1 if none). */
-    uint16_t in_port;       /* Packet's input port (OFPP_NONE if none). */
-    uint16_t out_port;      /* Output port (if buffer_id == -1). */
-    union {
-        struct ofp_action actions[0]; /* buffer_id != -1 */
-        uint8_t data[0];              /* buffer_id == -1 */
-    } u;
+    uint32_t buffer_id;           /* ID assigned by datapath (-1 if none). */
+    uint16_t in_port;             /* Packet's input port (OFPP_NONE if none). */
+    uint16_t n_actions;           /* Number of actions. */
+    struct ofp_action actions[0]; /* Actions. */
+    /* uint8_t data[0]; */        /* Packet data.  The length is inferred 
+                                     from the length field in the header.  
+                                     (Only meaningful if buffer_id == -1.) */
 };
 OFP_ASSERT(sizeof(struct ofp_packet_out) == 16);
 
@@ -356,7 +366,8 @@ struct ofp_match {
 };
 OFP_ASSERT(sizeof(struct ofp_match) == 36);
 
-/* Value used in "max_idle" to indicate that the entry is permanent */
+/* Value used in "idle_timeout" and "hard_timeout" to indicate that the entry
+ * is permanent. */
 #define OFP_FLOW_PERMANENT 0
 
 /* By default, choose a priority in the middle */
@@ -369,23 +380,30 @@ struct ofp_flow_mod {
 
     /* Flow actions. */
     uint16_t command;             /* One of OFPFC_*. */
-    uint16_t max_idle;            /* Idle time before discarding (seconds). */
-    uint32_t buffer_id;           /* Buffered packet to apply to (or -1). */
+    uint16_t idle_timeout;        /* Idle time before discarding (seconds). */
+    uint16_t hard_timeout;        /* Max time before discarding (seconds). */
     uint16_t priority;            /* Priority level of flow entry. */
-    uint8_t pad[2];               /* Align to 32-bits. */
+    uint32_t buffer_id;           /* Buffered packet to apply to (or -1). */
     uint32_t reserved;            /* Reserved for future use. */
     struct ofp_action actions[0]; /* The number of actions is inferred from
                                     the length field in the header. */
 };
 OFP_ASSERT(sizeof(struct ofp_flow_mod) == 60);
 
+/* Why did this flow expire? */
+enum ofp_flow_expired_reason {
+    OFPER_IDLE_TIMEOUT,         /* Flow idle time exceeded idle_timeout. */
+    OFPER_HARD_TIMEOUT          /* Time exceeded hard_timeout. */
+};
+
 /* Flow expiration (datapath -> controller). */
 struct ofp_flow_expired {
     struct ofp_header header;
     struct ofp_match match;   /* Description of fields */
 
     uint16_t priority;        /* Priority level of flow entry. */
-    uint8_t pad[2];           /* Align to 32-bits. */
+    uint8_t reason;           /* One of OFPER_*. */
+    uint8_t pad[1];           /* Align to 32-bits. */
 
     uint32_t duration;        /* Time flow was alive in seconds. */
     uint8_t pad2[4];          /* Align to 64-bits. */
@@ -465,12 +483,14 @@ struct ofp_flow_stats {
     uint32_t duration;        /* Time flow has been alive in seconds. */
     uint16_t priority;        /* Priority of the entry. Only meaningful
                                  when this is not an exact-match entry. */
-    uint16_t max_idle;        /* Number of seconds idle before expiration. */
+    uint16_t idle_timeout;    /* Number of seconds idle before expiration. */
+    uint16_t hard_timeout;    /* Number of seconds before expiration. */
+    uint16_t pad2[3];         /* Pad to 64 bits. */
     uint64_t packet_count;    /* Number of packets in flow. */
     uint64_t byte_count;      /* Number of bytes in flow. */
     struct ofp_action actions[0]; /* Actions. */
 };
-OFP_ASSERT(sizeof(struct ofp_flow_stats) == 64);
+OFP_ASSERT(sizeof(struct ofp_flow_stats) == 72);
 
 /* Body for ofp_stats_request of type OFPST_AGGREGATE. */
 struct ofp_aggregate_stats_request {
@@ -502,14 +522,27 @@ struct ofp_table_stats {
 };
 OFP_ASSERT(sizeof(struct ofp_table_stats) == 56);
 
-/* Statistics about a particular port */
+/* Statistics about a particular port.  If a counter is unsupported, set
+ * the field to all ones. */
 struct ofp_port_stats {
     uint16_t port_no;
-    uint8_t pad[6];          /* Align to 64-bits */
-    uint64_t rx_count;       /* Number of received packets */
-    uint64_t tx_count;       /* Number of transmitted packets */
-    uint64_t drop_count;     /* Number of packets dropped by interface */
-};
-OFP_ASSERT(sizeof(struct ofp_port_stats) == 32);
+    uint8_t pad[6];          /* Align to 64-bits. */
+    uint64_t rx_packets;     /* Number of received packets. */
+    uint64_t tx_packets;     /* Number of transmitted packets. */
+    uint64_t rx_bytes;       /* Number of received bytes. */
+    uint64_t tx_bytes;       /* Number of transmitted bytes. */
+    uint64_t rx_dropped;     /* Number of packets dropped by RX. */ 
+    uint64_t tx_dropped;     /* Number of packets dropped by TX. */ 
+    uint64_t rx_errors;      /* Number of receive errors.  This is a super-set
+                                of receive errors and should be great than or
+                                equal to the sum of al rx_*_err values. */
+    uint64_t tx_errors;      /* Number of transmit errors.  This is a super-set
+                                of transmit errors. */
+    uint64_t rx_frame_err;   /* Number of frame alignment errors. */ 
+    uint64_t rx_over_err;    /* Number of packets with RX overrun. */ 
+    uint64_t rx_crc_err;     /* Number of CRC errors. */ 
+    uint64_t collisions;     /* Number of collisions. */ 
+};
+OFP_ASSERT(sizeof(struct ofp_port_stats) == 104);
 
 #endif /* openflow.h */