ofproto: Implement OpenFlow extension to allow control over async messages.
[sliver-openvswitch.git] / include / openflow / nicira-ext.h
index 62180a7..ff95796 100644 (file)
@@ -108,7 +108,14 @@ enum nicira_type {
 
     /* Alternative PACKET_IN message formats. */
     NXT_SET_PACKET_IN_FORMAT = 16, /* Set Packet In format. */
-    NXT_PACKET_IN = 17             /* Nicira Packet In. */
+    NXT_PACKET_IN = 17,            /* Nicira Packet In. */
+
+    /* Are the idle_age and hard_age members in struct nx_flow_stats supported?
+     * If so, the switch does not reply to this message (which consists only of
+     * a "struct nicira_header").  If not, the switch sends an error reply. */
+    NXT_FLOW_AGE = 18,
+
+    NXT_SET_ASYNC_CONFIG = 19,  /* struct nx_async_config. */
 };
 
 /* Header for Nicira vendor stats request and reply messages. */
@@ -283,6 +290,28 @@ enum nx_role {
     NX_ROLE_MASTER,             /* Full access, at most one. */
     NX_ROLE_SLAVE               /* Read-only access. */
 };
+
+/* NXT_SET_ASYNC_CONFIG.
+ *
+ * Sent by a controller, this message configures the asynchronous messages that
+ * the controller wants to receive.  Element 0 in each array specifies messages
+ * of interest when the controller has an "other" or "master" role; element 1,
+ * when the controller has a "slave" role.
+ *
+ * Each array element is a bitmask in which a 0-bit disables receiving a
+ * particular message and a 1-bit enables receiving it.  Each bit controls the
+ * message whose 'reason' corresponds to the bit index.  For example, the bit
+ * with value 1<<2 == 4 in port_status_mask[1] determines whether the
+ * controller will receive OFPT_PORT_STATUS messages with reason OFPPR_MODIFY
+ * (value 2) when the controller has a "slave" role.
+ */
+struct nx_async_config {
+    struct nicira_header nxh;
+    ovs_be32 packet_in_mask[2];    /* Bitmasks of OFPR_* values. */
+    ovs_be32 port_status_mask[2];  /* Bitmasks of OFPRR_* values. */
+    ovs_be32 flow_removed_mask[2]; /* Bitmasks of OFPPR_* values. */
+};
+OFP_ASSERT(sizeof(struct nx_async_config) == 40);
 \f
 /* Nicira vendor flow actions. */
 
@@ -1398,9 +1427,12 @@ OFP_ASSERT(sizeof(struct nx_action_output_reg) == 24);
  *
  * Format: 16-bit integer in network byte order.
  *
- * Masking: Not maskable. */
+ * Masking: Fully maskable, in Open vSwitch 1.6 and later.  Not maskable, in
+ *   earlier versions. */
 #define NXM_OF_TCP_SRC    NXM_HEADER  (0x0000,  9, 2)
+#define NXM_OF_TCP_SRC_W  NXM_HEADER_W(0x0000,  9, 2)
 #define NXM_OF_TCP_DST    NXM_HEADER  (0x0000, 10, 2)
+#define NXM_OF_TCP_DST_W  NXM_HEADER_W(0x0000, 10, 2)
 
 /* The source or destination port in the UDP header.
  *
@@ -1410,9 +1442,12 @@ OFP_ASSERT(sizeof(struct nx_action_output_reg) == 24);
  *
  * Format: 16-bit integer in network byte order.
  *
- * Masking: Not maskable. */
+ * Masking: Fully maskable, in Open vSwitch 1.6 and later.  Not maskable, in
+ *   earlier versions. */
 #define NXM_OF_UDP_SRC    NXM_HEADER  (0x0000, 11, 2)
+#define NXM_OF_UDP_SRC_W  NXM_HEADER_W(0x0000, 11, 2)
 #define NXM_OF_UDP_DST    NXM_HEADER  (0x0000, 12, 2)
+#define NXM_OF_UDP_DST_W  NXM_HEADER_W(0x0000, 12, 2)
 
 /* The type or code in the ICMP header.
  *
@@ -1764,7 +1799,27 @@ struct nx_flow_stats_request {
 OFP_ASSERT(sizeof(struct nx_flow_stats_request) == 32);
 
 /* Body for Nicira vendor stats reply of type NXST_FLOW (analogous to
- * OFPST_FLOW reply). */
+ * OFPST_FLOW reply).
+ *
+ * The values of 'idle_age' and 'hard_age' are only meaningful when talking to
+ * a switch that implements the NXT_FLOW_AGE extension.  Zero means that the
+ * true value is unknown, perhaps because hardware does not track the value.
+ * (Zero is also the value that one should ordinarily expect to see talking to
+ * a switch that does not implement NXT_FLOW_AGE, since those switches zero the
+ * padding bytes that these fields replaced.)  A nonzero value X represents X-1
+ * seconds.  A value of 65535 represents 65534 or more seconds.
+ *
+ * 'idle_age' is the number of seconds that the flow has been idle, that is,
+ * the number of seconds since a packet passed through the flow.  'hard_age' is
+ * the number of seconds since the flow was last modified (e.g. OFPFC_MODIFY or
+ * OFPFC_MODIFY_STRICT).  (The 'duration_*' fields are the elapsed time since
+ * the flow was added, regardless of subsequent modifications.)
+ *
+ * For a flow with an idle or hard timeout, 'idle_age' or 'hard_age',
+ * respectively, will ordinarily be smaller than the timeout, but flow
+ * expiration times are only approximate and so one must be prepared to
+ * tolerate expirations that occur somewhat early or late.
+ */
 struct nx_flow_stats {
     ovs_be16 length;          /* Length of this entry. */
     uint8_t table_id;         /* ID of table flow came from. */
@@ -1777,7 +1832,8 @@ struct nx_flow_stats {
     ovs_be16 idle_timeout;    /* Number of seconds idle before expiration. */
     ovs_be16 hard_timeout;    /* Number of seconds before expiration. */
     ovs_be16 match_len;       /* Length of nx_match. */
-    uint8_t pad2[4];          /* Align to 64 bits. */
+    ovs_be16 idle_age;        /* Seconds since last packet, plus one. */
+    ovs_be16 hard_age;        /* Seconds since last modification, plus one. */
     ovs_be64 cookie;          /* Opaque controller-issued identifier. */
     ovs_be64 packet_count;    /* Number of packets, UINT64_MAX if unknown. */
     ovs_be64 byte_count;      /* Number of bytes, UINT64_MAX if unknown. */