Add OFPUTIL_P_OF12 and NXFF_OPENFLOW12 for Open Flow 1.2

OFPUTIL_P_OF12_TID and in turn OFPUTIL_P_OF12_ANY is not provided as
OFPUTIL_P_OF12 supports the use of table ids in modify flow messages.

Signed-off-by: Simon Horman <ho...@verge.net.au>

---

v7
* Add dummy OFPUTIL_P_OF12 cases to avoid compiler warnings
  Update tests

v6
* No change

v5
* No change

v4
* No change

v3
* Don't add NXPIF_OPENFLOW12, it doesn't seem to be needed

v2
* No change
---
 include/openflow/nicira-ext.h |  9 +++++----
 lib/ofp-util.c                | 27 +++++++++++++++++++++++++--
 lib/ofp-util.h                |  7 +++++--
 tests/learn.at                |  2 +-
 4 files changed, 36 insertions(+), 9 deletions(-)

diff --git a/include/openflow/nicira-ext.h b/include/openflow/nicira-ext.h
index 1104dbf..d8d2591 100644
--- a/include/openflow/nicira-ext.h
+++ b/include/openflow/nicira-ext.h
@@ -209,8 +209,8 @@ struct nx_flow_mod_table_id {
 OFP_ASSERT(sizeof(struct nx_flow_mod_table_id) == 24);
 
 enum nx_packet_in_format {
-    NXPIF_OPENFLOW10 = 0,       /* Standard OpenFlow 1.0 compatible. */
-    NXPIF_NXM = 1               /* Nicira Extended. */
+    NXPIF_OPENFLOW10 = 0,       /* OpenFlow 1.0 format. */
+    NXPIF_NXM = 1,              /* Nicira Extended. */
 };
 
 /* NXT_SET_PACKET_IN_FORMAT request. */
@@ -1778,8 +1778,9 @@ OFP_ASSERT(sizeof(struct nx_action_output_reg) == 24);
 /* ## --------------------- ## */
 
 enum nx_flow_format {
-    NXFF_OPENFLOW10 = 0,         /* Standard OpenFlow 1.0 compatible. */
-    NXFF_NXM = 2                 /* Nicira extended match. */
+    NXFF_OPENFLOW10 = 0,         /* OpenFlow 1.0 format. */
+    NXFF_NXM = 2,                /* Nicira extended match. */
+    NXFF_OPENFLOW12 = 3          /* OpenFlow 1.2 format. */
 };
 
 /* NXT_SET_FLOW_FORMAT request. */
diff --git a/lib/ofp-util.c b/lib/ofp-util.c
index dcca64c..25cde23 100644
--- a/lib/ofp-util.c
+++ b/lib/ofp-util.c
@@ -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 "OpenFlow12";
     }
 
     /* Check abbreviations. */
@@ -1564,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();
@@ -1611,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;
     }
@@ -1633,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();
     }
@@ -1823,6 +1843,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();
     }
@@ -1985,6 +2006,7 @@ ofputil_encode_flow_stats_request(const struct 
ofputil_flow_stats_request *fsr,
         break;
     }
 
+    case OFPUTIL_P_OF12:
     default:
         NOT_REACHED();
     }
@@ -2358,6 +2380,7 @@ ofputil_encode_flow_removed(const struct 
ofputil_flow_removed *fr,
         break;
     }
 
+    case OFPUTIL_P_OF12:
     default:
         NOT_REACHED();
     }
diff --git a/lib/ofp-util.h b/lib/ofp-util.h
index f7d3307..809f3d6 100644
--- a/lib/ofp-util.h
+++ b/lib/ofp-util.h
@@ -147,11 +147,14 @@ enum ofputil_protocol {
     OFPUTIL_P_NXM_TID  = 1 << 3, /* NXM + flow_mod_table_id extension. */
 #define OFPUTIL_P_NXM_ANY (OFPUTIL_P_NXM | OFPUTIL_P_NXM_TID)
 
+    /* OpenFlow 1.2 */
+    OFPUTIL_P_OF12      = 1 << 4, /* OpenFlow 1.2 flow format. */
+
     /* All protocols. */
-#define OFPUTIL_P_ANY (OFPUTIL_P_OF10_ANY | OFPUTIL_P_NXM_ANY)
+#define OFPUTIL_P_ANY (OFPUTIL_P_OF10_ANY | OFPUTIL_P_NXM_ANY | OFPUTIL_P_OF12)
 
     /* Protocols in which a specific table may be specified in flow_mods. */
-#define OFPUTIL_P_TID (OFPUTIL_P_OF10_TID | OFPUTIL_P_NXM_TID)
+#define OFPUTIL_P_TID (OFPUTIL_P_OF10_TID | OFPUTIL_P_NXM_TID | OFPUTIL_P_OF12)
 };
 
 /* Protocols to use for flow dumps, from most to least preferred. */
diff --git a/tests/learn.at b/tests/learn.at
index da82f51..b527276 100644
--- a/tests/learn.at
+++ b/tests/learn.at
@@ -24,7 +24,7 @@ table=0 actions=learn(table=1,hard_timeout=10, 
NXM_OF_VLAN_TCI[0..11],output:NXM
 table=1 priority=0 actions=flood
 ]])
 AT_CHECK([ovs-ofctl parse-flows flows.txt], [0],
-[[usable protocols: OpenFlow10+table_id,NXM+table_id
+[[usable protocols: OpenFlow10+table_id,NXM+table_id,OpenFlow12
 chosen protocol: OpenFlow10+table_id
 OFPT_FLOW_MOD (xid=0x1): ADD table:255 
actions=learn(table=1,in_port=99,NXM_OF_ETH_DST[]=NXM_OF_ETH_SRC[],load:NXM_OF_IN_PORT[]->NXM_NX_REG1[16..31])
 OFPT_FLOW_MOD (xid=0x2): ADD table:255 
actions=learn(table=1,NXM_OF_VLAN_TCI[0..11],NXM_OF_ETH_DST[]=NXM_OF_ETH_SRC[],output:NXM_OF_IN_PORT[])
-- 
1.7.10.2.484.gcd07cc5

_______________________________________________
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev

Reply via email to