ofp-util: Add OFPUTIL_P_OF12 and NXFF_OPENFLOW12
[openvswitch] / lib / ofp-util.c
index ecd0551344fc034a79fe5f5903efa21e326d9c15..8f2217f5766e892b499b40ac937711654f25906b 100644 (file)
@@ -104,14 +104,14 @@ static const flow_wildcards_t WC_INVARIANTS = 0
 void
 ofputil_wildcard_from_ofpfw10(uint32_t ofpfw, struct flow_wildcards *wc)
 {
-    BUILD_ASSERT_DECL(FLOW_WC_SEQ == 13);
+    BUILD_ASSERT_DECL(FLOW_WC_SEQ == 14);
 
     /* Initialize most of rule->wc. */
     flow_wildcards_init_catchall(wc);
     wc->wildcards = (OVS_FORCE flow_wildcards_t) ofpfw & WC_INVARIANTS;
 
     /* Wildcard fields that aren't defined by ofp10_match or tun_id. */
-    wc->wildcards |= FWW_ARP_SHA | FWW_ARP_THA | FWW_NW_ECN | FWW_NW_TTL;
+    wc->wildcards |= FWW_NW_ECN | FWW_NW_TTL;
 
     if (ofpfw & OFPFW10_NW_TOS) {
         /* OpenFlow 1.0 defines a TOS wildcard, but it's much later in
@@ -1180,12 +1180,13 @@ ofputil_protocol_from_ofp_version(int version)
 {
     switch (version) {
     case OFP10_VERSION: return OFPUTIL_P_OF10;
+    case OFP12_VERSION: return OFPUTIL_P_OF12;
     default: return 0;
     }
 }
 
-/* Returns the OpenFlow protocol version number (e.g. OFP10_VERSION or
- * OFP11_VERSION) that corresponds to 'protocol'. */
+/* Returns the OpenFlow protocol version number (e.g. OFP10_VERSION,
+ * OFP11_VERSION or OFP12_VERSION) that corresponds to 'protocol'. */
 uint8_t
 ofputil_protocol_to_ofp_version(enum ofputil_protocol protocol)
 {
@@ -1195,6 +1196,8 @@ ofputil_protocol_to_ofp_version(enum ofputil_protocol protocol)
     case OFPUTIL_P_NXM:
     case OFPUTIL_P_NXM_TID:
         return OFP10_VERSION;
+    case OFPUTIL_P_OF12:
+        return OFP12_VERSION;
     }
 
     NOT_REACHED();
@@ -1230,6 +1233,9 @@ ofputil_protocol_set_tid(enum ofputil_protocol protocol, bool enable)
     case OFPUTIL_P_NXM_TID:
         return enable ? OFPUTIL_P_NXM_TID : OFPUTIL_P_NXM;
 
+    case OFPUTIL_P_OF12:
+        return OFPUTIL_P_OF12;
+
     default:
         NOT_REACHED();
     }
@@ -1261,6 +1267,9 @@ ofputil_protocol_set_base(enum ofputil_protocol cur,
     case OFPUTIL_P_NXM_TID:
         return ofputil_protocol_set_tid(OFPUTIL_P_NXM, tid);
 
+    case OFPUTIL_P_OF12:
+        return ofputil_protocol_set_tid(OFPUTIL_P_OF12, tid);
+
     default:
         NOT_REACHED();
     }
@@ -1288,6 +1297,9 @@ ofputil_protocol_to_string(enum ofputil_protocol protocol)
 
     case OFPUTIL_P_OF10_TID:
         return "OpenFlow10+table_id";
+
+    case OFPUTIL_P_OF12:
+        return NULL;
     }
 
     /* Check abbreviations. */
@@ -1463,7 +1475,7 @@ ofputil_usable_protocols(const struct cls_rule *rule)
 {
     const struct flow_wildcards *wc = &rule->wc;
 
-    BUILD_ASSERT_DECL(FLOW_WC_SEQ == 13);
+    BUILD_ASSERT_DECL(FLOW_WC_SEQ == 14);
 
     /* NXM and OF1.1+ supports bitwise matching on ethernet addresses. */
     if (!eth_mask_is_exact(wc->dl_src_mask)
@@ -1481,7 +1493,8 @@ ofputil_usable_protocols(const struct cls_rule *rule)
     }
 
     /* Only NXM supports matching ARP hardware addresses. */
-    if (!(wc->wildcards & FWW_ARP_SHA) || !(wc->wildcards & FWW_ARP_THA)) {
+    if (!eth_addr_is_zero(wc->arp_sha_mask) ||
+        !eth_addr_is_zero(wc->arp_tha_mask)) {
         return OFPUTIL_P_NXM_ANY;
     }
 
@@ -1563,6 +1576,9 @@ ofputil_encode_set_protocol(enum ofputil_protocol current,
         case OFPUTIL_P_OF10:
             return ofputil_encode_nx_set_flow_format(NXFF_OPENFLOW10);
 
+        case OFPUTIL_P_OF12:
+            return ofputil_encode_nx_set_flow_format(NXFF_OPENFLOW12);
+
         case OFPUTIL_P_OF10_TID:
         case OFPUTIL_P_NXM_TID:
             NOT_REACHED();
@@ -1610,6 +1626,9 @@ ofputil_nx_flow_format_to_protocol(enum nx_flow_format flow_format)
     case NXFF_NXM:
         return OFPUTIL_P_NXM;
 
+    case NXFF_OPENFLOW12:
+        return OFPUTIL_P_OF12;
+
     default:
         return 0;
     }
@@ -1632,6 +1651,8 @@ ofputil_nx_flow_format_to_string(enum nx_flow_format flow_format)
         return "openflow10";
     case NXFF_NXM:
         return "nxm";
+    case NXFF_OPENFLOW12:
+        return "openflow12";
     default:
         NOT_REACHED();
     }
@@ -1821,6 +1842,7 @@ ofputil_encode_flow_mod(const struct ofputil_flow_mod *fm,
         nfm->match_len = htons(match_len);
         break;
 
+    case OFPUTIL_P_OF12:
     default:
         NOT_REACHED();
     }
@@ -1983,6 +2005,7 @@ ofputil_encode_flow_stats_request(const struct ofputil_flow_stats_request *fsr,
         break;
     }
 
+    case OFPUTIL_P_OF12:
     default:
         NOT_REACHED();
     }
@@ -2356,6 +2379,7 @@ ofputil_encode_flow_removed(const struct ofputil_flow_removed *fr,
         break;
     }
 
+    case OFPUTIL_P_OF12:
     default:
         NOT_REACHED();
     }
@@ -4109,10 +4133,10 @@ ofputil_normalize_rule(struct cls_rule *rule)
         wc.wildcards |= FWW_NW_TTL;
     }
     if (!(may_match & MAY_ARP_SHA)) {
-        wc.wildcards |= FWW_ARP_SHA;
+        memset(wc.arp_sha_mask, 0, ETH_ADDR_LEN);
     }
     if (!(may_match & MAY_ARP_THA)) {
-        wc.wildcards |= FWW_ARP_THA;
+        memset(wc.arp_tha_mask, 0, ETH_ADDR_LEN);
     }
     if (!(may_match & MAY_IPV6)) {
         wc.ipv6_src_mask = wc.ipv6_dst_mask = in6addr_any;