add "stable" parameter to enums
This parameter gives a hint to the backend that the enum members have the same
value in all OpenFlow versions. It's enforced when generating the unified IR.
The stable parameter is added to the BSN port/vlan/vrf stats extensions.
diff --git a/loxi_front_end/parser.py b/loxi_front_end/parser.py
index 4a465f7..fbf476d 100644
--- a/loxi_front_end/parser.py
+++ b/loxi_front_end/parser.py
@@ -68,7 +68,7 @@
s('}') - s(';')
# Enums
-enum_param_name = kw("wire_type") | kw("bitmask") | kw("complete")
+enum_param_name = kw("wire_type") | kw("bitmask") | kw("complete") | kw("stable")
enum_param = P.Group(enum_param_name - s('=') - word)
enum_param_list = P.Forward()
enum_param_list << enum_param + P.Optional(s(',') + P.Optional(enum_param_list))
diff --git a/loxi_ir/unified.py b/loxi_ir/unified.py
index 41b86dc..fa97c87 100644
--- a/loxi_ir/unified.py
+++ b/loxi_ir/unified.py
@@ -98,6 +98,9 @@
self.entries[e.name] = ir.OFEnumEntry(e.name, e.value, copy.copy(e.params))
else:
entry = self.entries[e.name]
+ if v_enum.params.get('stable') == 'True' and e.value != entry.value:
+ raise Exception("Error unifying stable ir enum {} - adding entry {} version {} value {} <-> {}".format(
+ self.name, e.name, version, entry.value, e.value))
for name, value in e.params.items():
if not name in entry.params:
entry.params[name] = value
diff --git a/openflow_input/bsn_port_counter b/openflow_input/bsn_port_counter
index 73ba80e..83cd1c8 100644
--- a/openflow_input/bsn_port_counter
+++ b/openflow_input/bsn_port_counter
@@ -30,7 +30,7 @@
#version 4
-enum ofp_bsn_port_counter(wire_type=uint8_t, complete=False) {
+enum ofp_bsn_port_counter(wire_type=uint8_t, complete=False, stable=True) {
OFP_BSN_PORT_COUNTER_RX_BYTES = 0,
OFP_BSN_PORT_COUNTER_RX_PACKETS_UNICAST = 1,
OFP_BSN_PORT_COUNTER_RX_PACKETS_BROADCAST = 2,
diff --git a/openflow_input/bsn_vlan_counter b/openflow_input/bsn_vlan_counter
index c88d6b7..c5814f4 100644
--- a/openflow_input/bsn_vlan_counter
+++ b/openflow_input/bsn_vlan_counter
@@ -34,7 +34,7 @@
OFP_BSN_VLAN_ALL = 0xffff,
};
-enum of_bsn_vlan_counter(wire_type=uint8_t, complete=False) {
+enum of_bsn_vlan_counter(wire_type=uint8_t, complete=False, stable=True) {
OFP_BSN_VLAN_COUNTER_RX_BYTES = 0,
OFP_BSN_VLAN_COUNTER_RX_PACKETS = 1,
OFP_BSN_VLAN_COUNTER_TX_BYTES = 2,
diff --git a/openflow_input/bsn_vrf_counter b/openflow_input/bsn_vrf_counter
index 5244eab..b638ff7 100644
--- a/openflow_input/bsn_vrf_counter
+++ b/openflow_input/bsn_vrf_counter
@@ -34,7 +34,7 @@
OFP_BSN_VRF_ALL = 0xffffffff,
};
-enum of_bsn_vrf_counter(wire_type=uint8_t, complete=False) {
+enum of_bsn_vrf_counter(wire_type=uint8_t, complete=False, stable=True) {
OFP_BSN_VRF_COUNTER_BYTES = 0,
OFP_BSN_VRF_COUNTER_PACKETS = 1,
};