summaryrefslogtreecommitdiff
path: root/lib/odp-util.h
diff options
context:
space:
mode:
authorAndy Zhou <azhou@ovn.org>2017-03-15 18:39:57 -0700
committerAndy Zhou <azhou@ovn.org>2017-04-03 17:51:02 -0700
commit1c2f091b723e26388c41bca73fc183453f6c2ed8 (patch)
tree43360b9a46ad82f6ac4cbeded05e7ba2bc726f18 /lib/odp-util.h
parent091d64c408682be41ac9934d7300f68c67d0fd92 (diff)
downloadopenvswitch-1c2f091b723e26388c41bca73fc183453f6c2ed8.tar.gz
ofproto: Use macros to define DPIF support fields
When adding a new field in the 'struct dpif_backer_support', the corresponding appctl show command should be updated to display the new field. Currently, there is nothing to remind the developer that to update the show command. This can lead to code maintenance issues. Switch to use macros to define those fields. This makes the show command update automatic. Signed-off-by: Andy Zhou <azhou@ovn.org> Acked-by: Joe Stringer <joe@ovn.org>
Diffstat (limited to 'lib/odp-util.h')
-rw-r--r--lib/odp-util.h52
1 files changed, 31 insertions, 21 deletions
diff --git a/lib/odp-util.h b/lib/odp-util.h
index 50fa1d133..ab9be55f0 100644
--- a/lib/odp-util.h
+++ b/lib/odp-util.h
@@ -167,30 +167,40 @@ int odp_flow_from_string(const char *s,
const struct simap *port_names,
struct ofpbuf *, struct ofpbuf *);
+/* ODP_SUPPORT_FIELD(TYPE, FIELD_NAME, FIELD_DESCRIPTION)
+ *
+ * Each 'ODP_SUPPORT_FIELD' defines a member in 'struct odp_support',
+ * and represents support for related OVS_KEY_ATTR_* fields.
+ * They are defined as macros to keep 'dpif_show_support()' in sync
+ * as new fields are added. */
+#define ODP_SUPPORT_FIELDS \
+ /* Maximum number of 802.1q VLAN headers to serialize in a mask. */ \
+ ODP_SUPPORT_FIELD(size_t, max_vlan_headers, "Max VLAN headers") \
+ /* Maximum number of MPLS label stack entries to serialise in a mask. */ \
+ ODP_SUPPORT_FIELD(size_t, max_mpls_depth, "Max MPLS depth") \
+ /* If this is true, then recirculation fields will always be \
+ * serialised. */ \
+ ODP_SUPPORT_FIELD(bool, recirc, "Recirc") \
+ /* If true, serialise the corresponding OVS_KEY_ATTR_CONN_* field. */ \
+ ODP_SUPPORT_FIELD(bool, ct_state, "CT state") \
+ ODP_SUPPORT_FIELD(bool, ct_zone, "CT zone") \
+ ODP_SUPPORT_FIELD(bool, ct_mark, "CT mark") \
+ ODP_SUPPORT_FIELD(bool, ct_label, "CT label") \
+ \
+ /* If true, it means that the datapath supports the NAT bits in \
+ * 'ct_state'. The above 'ct_state' member must be true for this \
+ * to make sense */ \
+ ODP_SUPPORT_FIELD(bool, ct_state_nat, "CT state NAT") \
+ \
+ /* Conntrack original direction tuple matching * supported. */ \
+ ODP_SUPPORT_FIELD(bool, ct_orig_tuple, "CT orig tuple")
+
/* Indicates support for various fields. This defines how flows will be
* serialised. */
struct odp_support {
- /* Maximum number of 802.1q VLAN headers to serialize in a mask. */
- size_t max_vlan_headers;
- /* Maximum number of MPLS label stack entries to serialise in a mask. */
- size_t max_mpls_depth;
-
- /* If this is true, then recirculation fields will always be serialised. */
- bool recirc;
-
- /* If true, serialise the corresponding OVS_KEY_ATTR_CONN_* field. */
- bool ct_state;
- bool ct_zone;
- bool ct_mark;
- bool ct_label;
-
- /* If true, it means that the datapath supports the NAT bits in
- * 'ct_state'. The above 'ct_state' member must be true for this
- * to make sense */
- bool ct_state_nat;
-
- bool ct_orig_tuple; /* Conntrack original direction tuple matching
- * supported. */
+#define ODP_SUPPORT_FIELD(TYPE, NAME, TITLE) TYPE NAME;
+ ODP_SUPPORT_FIELDS
+#undef ODP_SUPPORT_FIELD
};
struct odp_flow_key_parms {