ofp-util: Provide bucket list helper functions
[cascardo/ovs.git] / lib / ofp-util.h
index 86c8461..bc6f7d1 100644 (file)
@@ -271,7 +271,7 @@ struct ofputil_flow_mod {
     struct list list_node;    /* For queuing flow_mods. */
 
     struct match match;
-    unsigned int priority;
+    int priority;
 
     /* Cookie matching.  The flow_mod affects only flows that have cookies that
      * bitwise match 'cookie' bits in positions where 'cookie_mask has 1-bits.
@@ -306,6 +306,7 @@ struct ofputil_flow_mod {
     ofp_port_t out_port;
     uint32_t out_group;
     enum ofputil_flow_mod_flags flags;
+    uint16_t importance;     /* Eviction precedence. */
     struct ofpact *ofpacts;  /* Series of "struct ofpact"s. */
     size_t ofpacts_len;      /* Length of ofpacts, in bytes. */
 
@@ -355,6 +356,7 @@ struct ofputil_flow_stats {
     const struct ofpact *ofpacts;
     size_t ofpacts_len;
     enum ofputil_flow_mod_flags flags;
+    uint16_t importance;        /* Eviction precedence. */
 };
 
 int ofputil_decode_flow_stats_reply(struct ofputil_flow_stats *,
@@ -910,99 +912,6 @@ bool ofputil_frag_handling_from_string(const char *, enum ofp_config_flags *);
 \f
 /* Actions. */
 
-/* The type of an action.
- *
- * For each implemented OFPAT10_* and NXAST_* action type, there is a
- * corresponding constant prefixed with OFPUTIL_, e.g.:
- *
- * OFPUTIL_OFPAT10_OUTPUT
- * OFPUTIL_OFPAT10_SET_VLAN_VID
- * OFPUTIL_OFPAT10_SET_VLAN_PCP
- * OFPUTIL_OFPAT10_STRIP_VLAN
- * OFPUTIL_OFPAT10_SET_DL_SRC
- * OFPUTIL_OFPAT10_SET_DL_DST
- * OFPUTIL_OFPAT10_SET_NW_SRC
- * OFPUTIL_OFPAT10_SET_NW_DST
- * OFPUTIL_OFPAT10_SET_NW_TOS
- * OFPUTIL_OFPAT10_SET_TP_SRC
- * OFPUTIL_OFPAT10_SET_TP_DST
- * OFPUTIL_OFPAT10_ENQUEUE
- * OFPUTIL_NXAST_RESUBMIT
- * OFPUTIL_NXAST_SET_TUNNEL
- * OFPUTIL_NXAST_SET_METADATA
- * OFPUTIL_NXAST_SET_QUEUE
- * OFPUTIL_NXAST_POP_QUEUE
- * OFPUTIL_NXAST_REG_MOVE
- * OFPUTIL_NXAST_REG_LOAD
- * OFPUTIL_NXAST_NOTE
- * OFPUTIL_NXAST_SET_TUNNEL64
- * OFPUTIL_NXAST_MULTIPATH
- * OFPUTIL_NXAST_BUNDLE
- * OFPUTIL_NXAST_BUNDLE_LOAD
- * OFPUTIL_NXAST_RESUBMIT_TABLE
- * OFPUTIL_NXAST_OUTPUT_REG
- * OFPUTIL_NXAST_LEARN
- * OFPUTIL_NXAST_DEC_TTL
- * OFPUTIL_NXAST_FIN_TIMEOUT
- *
- * (The above list helps developers who want to "grep" for these definitions.)
- */
-enum OVS_PACKED_ENUM ofputil_action_code {
-    OFPUTIL_ACTION_INVALID,
-#define OFPAT10_ACTION(ENUM, STRUCT, NAME)             OFPUTIL_##ENUM,
-#define OFPAT11_ACTION(ENUM, STRUCT, EXTENSIBLE, NAME) OFPUTIL_##ENUM,
-#define OFPAT13_ACTION(ENUM, STRUCT, EXTENSIBLE, NAME) OFPUTIL_##ENUM,
-#define NXAST_ACTION(ENUM, STRUCT, EXTENSIBLE, NAME)   OFPUTIL_##ENUM,
-#include "ofp-util.def"
-};
-
-/* The number of values of "enum ofputil_action_code". */
-enum {
-#define OFPAT10_ACTION(ENUM, STRUCT, NAME)             + 1
-#define OFPAT11_ACTION(ENUM, STRUCT, EXTENSIBLE, NAME) + 1
-#define OFPAT13_ACTION(ENUM, STRUCT, EXTENSIBLE, NAME) + 1
-#define NXAST_ACTION(ENUM, STRUCT, EXTENSIBLE, NAME)   + 1
-    OFPUTIL_N_ACTIONS = 1
-#include "ofp-util.def"
-};
-
-int ofputil_action_code_from_name(const char *);
-const char * ofputil_action_name_from_code(enum ofputil_action_code code);
-enum ofputil_action_code ofputil_action_code_from_ofp13_action(
-    enum ofp13_action_type type);
-
-void *ofputil_put_action(enum ofputil_action_code, struct ofpbuf *buf);
-
-/* For each OpenFlow action <ENUM> that has a corresponding action structure
- * struct <STRUCT>, this defines two functions:
- *
- *   void ofputil_init_<ENUM>(struct <STRUCT> *action);
- *
- *     Initializes the parts of 'action' that identify it as having type <ENUM>
- *     and length 'sizeof *action' and zeros the rest.  For actions that have
- *     variable length, the length used and cleared is that of struct <STRUCT>.
- *
- *  struct <STRUCT> *ofputil_put_<ENUM>(struct ofpbuf *buf);
- *
- *     Appends a new 'action', of length 'sizeof(struct <STRUCT>)', to 'buf',
- *     initializes it with ofputil_init_<ENUM>(), and returns it.
- */
-#define OFPAT10_ACTION(ENUM, STRUCT, NAME)              \
-    void ofputil_init_##ENUM(struct STRUCT *);          \
-    struct STRUCT *ofputil_put_##ENUM(struct ofpbuf *);
-#define OFPAT11_ACTION(ENUM, STRUCT, EXTENSIBLE, NAME)  \
-    void ofputil_init_##ENUM(struct STRUCT *);          \
-    struct STRUCT *ofputil_put_##ENUM(struct ofpbuf *);
-#define OFPAT13_ACTION(ENUM, STRUCT, EXTENSIBLE, NAME)  \
-    void ofputil_init_##ENUM(struct STRUCT *);          \
-    struct STRUCT *ofputil_put_##ENUM(struct ofpbuf *);
-#define NXAST_ACTION(ENUM, STRUCT, EXTENSIBLE, NAME)    \
-    void ofputil_init_##ENUM(struct STRUCT *);          \
-    struct STRUCT *ofputil_put_##ENUM(struct ofpbuf *);
-#include "ofp-util.def"
-
-#define OFP_ACTION_ALIGN 8      /* Alignment of ofp_actions. */
-
 bool action_outputs_to_port(const union ofp_action *, ovs_be16 port);
 
 enum ofperr ofputil_pull_actions(struct ofpbuf *, unsigned int actions_len,
@@ -1077,6 +986,7 @@ struct ofputil_bucket {
     uint32_t watch_group;       /* Group whose state affects whether this
                                  * bucket is live. Only required for fast
                                  * failover groups. */
+    uint32_t bucket_id;         /* Bucket Id used to identify bucket*/
     struct ofpact *ofpacts;     /* Series of "struct ofpact"s. */
     size_t ofpacts_len;         /* Length of ofpacts, in bytes. */
 
@@ -1085,9 +995,13 @@ struct ofputil_bucket {
 
 /* Protocol-independent group_mod. */
 struct ofputil_group_mod {
-    uint16_t command;             /* One of OFPGC11_*. */
+    uint16_t command;             /* One of OFPGC15_*. */
     uint8_t type;                 /* One of OFPGT11_*. */
     uint32_t group_id;            /* Group identifier. */
+    uint32_t command_bucket_id;   /* Bucket Id used as part of
+                                   * OFPGC15_INSERT_BUCKET and
+                                   * OFPGC15_REMOVE_BUCKET commands
+                                   * execution.*/
     struct list buckets;          /* Contains "struct ofputil_bucket"s. */
 };
 
@@ -1121,6 +1035,13 @@ struct ofputil_group_desc {
 };
 
 void ofputil_bucket_list_destroy(struct list *buckets);
+void ofputil_bucket_clone_list(struct list *dest, const struct list *src,
+                               const struct ofputil_bucket *);
+struct ofputil_bucket *ofputil_bucket_find(const struct list *,
+                                           uint32_t bucket_id);
+bool ofputil_bucket_check_duplicate_id(const struct list *);
+struct ofputil_bucket *ofputil_bucket_list_front(const struct list *);
+struct ofputil_bucket *ofputil_bucket_list_back(const struct list *);
 
 static inline bool
 ofputil_bucket_has_liveness(const struct ofputil_bucket *bucket)