+static enum ofperr
+parse_table_mod_eviction_property(struct ofpbuf *property,
+ struct ofputil_table_mod *tm)
+{
+ struct ofp14_table_mod_prop_eviction *ote = property->data;
+
+ if (property->size != sizeof *ote) {
+ return OFPERR_OFPBPC_BAD_LEN;
+ }
+
+ tm->eviction_flags = ntohl(ote->flags);
+ return 0;
+}
+
+/* Given 'config', taken from an OpenFlow 'version' message that specifies
+ * table configuration (a table mod, table stats, or table features message),
+ * returns the table eviction configuration that it specifies.
+ *
+ * Only OpenFlow 1.4 and later specify table eviction configuration this way,
+ * so for other 'version' values this function always returns
+ * OFPUTIL_TABLE_EVICTION_DEFAULT. */
+static enum ofputil_table_eviction
+ofputil_decode_table_eviction(ovs_be32 config, enum ofp_version version)
+{
+ return (version < OFP14_VERSION ? OFPUTIL_TABLE_EVICTION_DEFAULT
+ : config & htonl(OFPTC14_EVICTION) ? OFPUTIL_TABLE_EVICTION_ON
+ : OFPUTIL_TABLE_EVICTION_OFF);
+}
+
+/* Returns a bitmap of OFPTC* values suitable for 'config' fields in various
+ * OpenFlow messages of the given 'version', based on the provided 'miss' and
+ * 'eviction' values. */
+static ovs_be32
+ofputil_encode_table_config(enum ofputil_table_miss miss,
+ enum ofputil_table_eviction eviction,
+ enum ofp_version version)
+{
+ /* See the section "OFPTC_* Table Configuration" in DESIGN.md for more
+ * information on the crazy evolution of this field. */
+ switch (version) {
+ case OFP10_VERSION:
+ /* OpenFlow 1.0 didn't have such a field, any value ought to do. */
+ return htonl(0);
+
+ case OFP11_VERSION:
+ case OFP12_VERSION:
+ /* OpenFlow 1.1 and 1.2 define only OFPTC11_TABLE_MISS_*. */
+ switch (miss) {
+ case OFPUTIL_TABLE_MISS_DEFAULT:
+ /* Really this shouldn't be used for encoding (the caller should
+ * provide a specific value) but I can't imagine that defaulting to
+ * the fall-through case here will hurt. */
+ case OFPUTIL_TABLE_MISS_CONTROLLER:
+ default:
+ return htonl(OFPTC11_TABLE_MISS_CONTROLLER);
+ case OFPUTIL_TABLE_MISS_CONTINUE:
+ return htonl(OFPTC11_TABLE_MISS_CONTINUE);
+ case OFPUTIL_TABLE_MISS_DROP:
+ return htonl(OFPTC11_TABLE_MISS_DROP);
+ }
+ OVS_NOT_REACHED();
+
+ case OFP13_VERSION:
+ /* OpenFlow 1.3 removed OFPTC11_TABLE_MISS_* and didn't define any new
+ * flags, so this is correct. */
+ return htonl(0);
+
+ case OFP14_VERSION:
+ case OFP15_VERSION:
+ /* OpenFlow 1.4 introduced OFPTC14_EVICTION and OFPTC14_VACANCY_EVENTS
+ * and we don't support the latter yet. */
+ return htonl(eviction == OFPUTIL_TABLE_EVICTION_ON
+ ? OFPTC14_EVICTION : 0);
+ }
+
+ OVS_NOT_REACHED();
+}