support of_bitmap_128_t in core, loci, and pyloxi
diff --git a/c_gen/c_code_gen.py b/c_gen/c_code_gen.py
index df9d9da..798f5a4 100644
--- a/c_gen/c_code_gen.py
+++ b/c_gen/c_code_gen.py
@@ -1007,6 +1007,11 @@
typedef char of_desc_str_t[OF_DESC_STR_LEN];
typedef char of_serial_num_t[OF_SERIAL_NUM_LEN];
+typedef struct of_bitmap_128_s {
+ uint64_t hi;
+ uint64_t lo;
+} of_bitmap_128_t;
+
/* These are types which change across versions. */
typedef uint32_t of_port_no_t;
typedef uint16_t of_fm_cmd_t;
diff --git a/c_gen/c_match.py b/c_gen/c_match.py
index 7353ae7..c62899d 100644
--- a/c_gen/c_match.py
+++ b/c_gen/c_match.py
@@ -1066,6 +1066,15 @@
#define OF_OVERLAP_MAC_ADDR(v1, v2, m1, m2) \\
of_overlap_mac_addr((v1), (v2), (m1), (m2))
+#define OF_MORE_SPECIFIC_BITMAP_128(v1, v2) \\
+ (OF_MORE_SPECIFIC_INT((v1)->lo, (v2)->lo) && OF_MORE_SPECIFIC_INT((v1)->hi, (v2)->hi))
+
+#define OF_RESTRICTED_MATCH_BITMAP_128(v1, v2, mask) \\
+ (OF_RESTRICTED_MATCH_INT((v1)->lo, (v2)->lo, (mask)->lo) && OF_RESTRICTED_MATCH_INT((v1)->hi, (v2)->hi, (mask)->hi))
+
+#define OF_OVERLAP_BITMAP_128(v1, v2, m1, m2) \\
+ (OF_OVERLAP_INT((v1)->lo, (v2)->lo, (m1)->lo, (m2)->lo) && OF_OVERLAP_INT((v1)->hi, (v2)->hi, (m1)->hi, (m2)->hi))
+
/**
* More-specific-than macro for integer types; see above
* @return true if v1 is equal to or more specific than v2
@@ -1136,6 +1145,9 @@
elif entry["m_type"] == "of_mac_addr_t":
comp = "OF_MORE_SPECIFIC_MAC_ADDR"
match_type = "OF_RESTRICTED_MATCH_MAC_ADDR"
+ elif entry["m_type"] == "of_bitmap_128_t":
+ comp = "OF_MORE_SPECIFIC_BITMAP_128"
+ match_type = "OF_RESTRICTED_MATCH_BITMAP_128"
else: # Integer
comp = "OF_MORE_SPECIFIC_INT"
match_type = "OF_RESTRICTED_MATCH_INT"
@@ -1190,6 +1202,8 @@
check = "OF_OVERLAP_IPV6"
elif entry["m_type"] == "of_mac_addr_t":
check = "OF_OVERLAP_MAC_ADDR"
+ elif entry["m_type"] == "of_bitmap_128_t":
+ check = "OF_OVERLAP_BITMAP_128"
else: # Integer
check = "OF_OVERLAP_INT"
m1 = "m1->%s" % key
diff --git a/c_gen/c_test_gen.py b/c_gen/c_test_gen.py
index fab9f96..d237cfe 100644
--- a/c_gen/c_test_gen.py
+++ b/c_gen/c_test_gen.py
@@ -98,6 +98,7 @@
of_match_t="match",
# BSN extensions
of_bsn_vport_q_in_q_t="vport",
+ of_bitmap_128_t="bitmap_128",
)
if m_type.find("of_list_") == 0:
@@ -111,7 +112,7 @@
"of_match_bmap_t", "of_ipv4_t"]
string_types = [ "of_port_name_t", "of_table_name_t",
"of_desc_str_t", "of_serial_num_t", "of_mac_addr_t",
- "of_ipv6_t"]
+ "of_ipv6_t", "of_bitmap_128_t"]
scalar_types = integer_types[:]
scalar_types.extend(string_types)
diff --git a/c_gen/templates/loci_dump.h b/c_gen/templates/loci_dump.h
index c2fd53a..d44832a 100644
--- a/c_gen/templates/loci_dump.h
+++ b/c_gen/templates/loci_dump.h
@@ -94,6 +94,8 @@
int loci_dump_match(loci_writer_f writer, void* cookie, of_match_t *match);
#define LOCI_DUMP_match(writer, cookie, val) loci_dump_match(writer, cookie, &val)
+#define LOCI_DUMP_bitmap_128(writer, cookie, val) writer(cookie, "%" PRIx64 "%" PRIx64, (val).hi, (val).lo)
+
/**
* Generic version for any object
*/
diff --git a/c_gen/templates/loci_show.h b/c_gen/templates/loci_show.h
index 948ee92..0cf9133 100644
--- a/c_gen/templates/loci_show.h
+++ b/c_gen/templates/loci_show.h
@@ -162,6 +162,8 @@
int loci_show_match(loci_writer_f writer, void *cookie, of_match_t *match);
#define LOCI_SHOW_match(writer, cookie, val) loci_show_match(writer, cookie, &val)
+#define LOCI_SHOW_bitmap_128(writer, cookie, val) writer(cookie, "%" PRIx64 "%" PRIx64, (val).hi, (val).lo)
+
/**
* Generic version for any object
*/
diff --git a/c_gen/templates/of_wire_buf.h b/c_gen/templates/of_wire_buf.h
index 8750565..117332c 100644
--- a/c_gen/templates/of_wire_buf.h
+++ b/c_gen/templates/of_wire_buf.h
@@ -876,6 +876,30 @@
#define of_wire_buffer_ipv6_set(buf, offset, addr) \
_wbuf_octets_set(buf, offset, (uint8_t *)&addr, sizeof(of_ipv6_t))
+/**
+ * Get an bitmap_128 address from a wire buffer
+ * @param wbuf The pointer to the wire buffer structure
+ * @param offset Offset in the wire buffer
+ * @param addr Pointer to where to store the bitmap_128 address
+ *
+ * Uses the octets function.
+ */
+
+#define of_wire_buffer_bitmap_128_get(buf, offset, addr) \
+ (of_wire_buffer_u64_get(buf, offset, &addr->hi), of_wire_buffer_u64_get(buf, offset+8, &addr->lo))
+
+/**
+ * Set an bitmap_128 address in a wire buffer
+ * @param wbuf The pointer to the wire buffer structure
+ * @param offset Offset in the wire buffer
+ * @param addr The variable holding bitmap_128 address to store
+ *
+ * Uses the octets function.
+ */
+
+#define of_wire_buffer_bitmap_128_set(buf, offset, addr) \
+ (of_wire_buffer_u64_set(buf, offset, addr.hi), of_wire_buffer_u64_set(buf, offset+8, addr.lo))
+
/* Relocate data from start offset to the end of the buffer to a new position */
static inline void
of_wire_buffer_move_end(of_wire_buffer_t *wbuf, int start_offset, int new_offset)
diff --git a/of_g.py b/of_g.py
index 651ee64..c857e65 100644
--- a/of_g.py
+++ b/of_g.py
@@ -302,14 +302,15 @@
# of_match_v4_t = dict(bytes=-1, to_w="match_v4_hton",
# from_w="match_v4_ntoh",
# short_name="match_v4"),
- of_octets_t = dict(bytes=-1, short_name="octets")
+ of_octets_t = dict(bytes=-1, short_name="octets"),
+ of_bitmap_128_t = dict(bytes=16, short_name="bitmap_128"),
)
of_scalar_types = ["char", "uint8_t", "uint16_t", "uint32_t", "uint64_t",
"of_port_no_t", "of_fm_cmd_t", "of_wc_bmap_t",
"of_match_bmap_t", "of_port_name_t", "of_table_name_t",
"of_desc_str_t", "of_serial_num_t", "of_mac_addr_t",
- "of_ipv6_t", "of_ipv4_t"]
+ "of_ipv6_t", "of_ipv4_t", "of_bitmap_128_t"]
base_object_members = """\
/* The control block for the underlying data buffer */
diff --git a/py_gen/oftype.py b/py_gen/oftype.py
index a6620ab..c378cea 100644
--- a/py_gen/oftype.py
+++ b/py_gen/oftype.py
@@ -101,6 +101,11 @@
pack='%s',
unpack='str(%s.read_all())'),
+ 'of_bitmap_128_t': OFTypeData(
+ init='set()',
+ pack='util.pack_bitmap_128(%s)',
+ unpack="util.unpack_bitmap_128(%s)"),
+
# HACK need the match_v3 length field
'list(of_oxm_t)': OFTypeData(
init='[]',
diff --git a/py_gen/templates/util.py b/py_gen/templates/util.py
index c4de5a3..1566e82 100644
--- a/py_gen/templates/util.py
+++ b/py_gen/templates/util.py
@@ -142,3 +142,23 @@
def pack_list(values):
return "".join([x.pack() for x in values])
+
+MASK64 = (1 << 64) - 1
+
+def pack_bitmap_128(value):
+ x = 0l
+ for y in value:
+ x |= 1 << y
+ return struct.pack("!QQ", (x >> 64) & MASK64, x & MASK64)
+
+def unpack_bitmap_128(reader):
+ hi, lo = reader.read("!QQ")
+ x = (hi << 64) | lo
+ i = 0
+ value = set()
+ while x != 0:
+ if x & 1 == 1:
+ value.add(i)
+ i += 1
+ x >>= 1
+ return value