ONOS-4175 Implemented BMv2 configuration model parser
Such a model is used to define the way BMv2 should process packets
(i.e. it defines the device ingress/egress pipelines, parser, tables,
actions, etc.) and can be generated (i.e. JSON) by compiling a P4
program using p4c-bm.
Change-Id: Ic08df68bed5a0261cb50b27dc7dbfe9d35e1fb71
diff --git a/drivers/bmv2/src/test/resources/simple_pipeline.json b/drivers/bmv2/src/test/resources/simple_pipeline.json
new file mode 100644
index 0000000..372bdcd
--- /dev/null
+++ b/drivers/bmv2/src/test/resources/simple_pipeline.json
@@ -0,0 +1,505 @@
+{
+ "header_types": [
+ {
+ "name": "standard_metadata_t",
+ "id": 0,
+ "fields": [
+ [
+ "ingress_port",
+ 9
+ ],
+ [
+ "packet_length",
+ 32
+ ],
+ [
+ "egress_spec",
+ 9
+ ],
+ [
+ "egress_port",
+ 9
+ ],
+ [
+ "egress_instance",
+ 32
+ ],
+ [
+ "instance_type",
+ 32
+ ],
+ [
+ "clone_spec",
+ 32
+ ],
+ [
+ "_padding",
+ 5
+ ]
+ ],
+ "length_exp": null,
+ "max_length": null
+ },
+ {
+ "name": "ethernet_t",
+ "id": 1,
+ "fields": [
+ [
+ "dstAddr",
+ 48
+ ],
+ [
+ "srcAddr",
+ 48
+ ],
+ [
+ "etherType",
+ 16
+ ]
+ ],
+ "length_exp": null,
+ "max_length": null
+ },
+ {
+ "name": "intrinsic_metadata_t",
+ "id": 2,
+ "fields": [
+ [
+ "ingress_global_timestamp",
+ 32
+ ],
+ [
+ "lf_field_list",
+ 32
+ ],
+ [
+ "mcast_grp",
+ 16
+ ],
+ [
+ "egress_rid",
+ 16
+ ]
+ ],
+ "length_exp": null,
+ "max_length": null
+ },
+ {
+ "name": "cpu_header_t",
+ "id": 3,
+ "fields": [
+ [
+ "device",
+ 8
+ ],
+ [
+ "reason",
+ 8
+ ]
+ ],
+ "length_exp": null,
+ "max_length": null
+ }
+ ],
+ "headers": [
+ {
+ "name": "standard_metadata",
+ "id": 0,
+ "header_type": "standard_metadata_t",
+ "metadata": true
+ },
+ {
+ "name": "ethernet",
+ "id": 1,
+ "header_type": "ethernet_t",
+ "metadata": false
+ },
+ {
+ "name": "intrinsic_metadata",
+ "id": 2,
+ "header_type": "intrinsic_metadata_t",
+ "metadata": true
+ },
+ {
+ "name": "cpu_header",
+ "id": 3,
+ "header_type": "cpu_header_t",
+ "metadata": false
+ }
+ ],
+ "header_stacks": [],
+ "parsers": [
+ {
+ "name": "parser",
+ "id": 0,
+ "init_state": "start",
+ "parse_states": [
+ {
+ "name": "start",
+ "id": 0,
+ "parser_ops": [],
+ "transition_key": [
+ {
+ "type": "lookahead",
+ "value": [
+ 0,
+ 64
+ ]
+ }
+ ],
+ "transitions": [
+ {
+ "value": "0x0000000000000000",
+ "mask": null,
+ "next_state": "parse_cpu_header"
+ },
+ {
+ "value": "default",
+ "mask": null,
+ "next_state": "parse_ethernet"
+ }
+ ]
+ },
+ {
+ "name": "parse_cpu_header",
+ "id": 1,
+ "parser_ops": [
+ {
+ "op": "extract",
+ "parameters": [
+ {
+ "type": "regular",
+ "value": "cpu_header"
+ }
+ ]
+ }
+ ],
+ "transition_key": [],
+ "transitions": [
+ {
+ "value": "default",
+ "mask": null,
+ "next_state": "parse_ethernet"
+ }
+ ]
+ },
+ {
+ "name": "parse_ethernet",
+ "id": 2,
+ "parser_ops": [
+ {
+ "op": "extract",
+ "parameters": [
+ {
+ "type": "regular",
+ "value": "ethernet"
+ }
+ ]
+ }
+ ],
+ "transition_key": [],
+ "transitions": [
+ {
+ "value": "default",
+ "mask": null,
+ "next_state": null
+ }
+ ]
+ }
+ ]
+ }
+ ],
+ "deparsers": [
+ {
+ "name": "deparser",
+ "id": 0,
+ "order": [
+ "cpu_header",
+ "ethernet"
+ ]
+ }
+ ],
+ "meter_arrays": [],
+ "actions": [
+ {
+ "name": "flood",
+ "id": 0,
+ "runtime_data": [],
+ "primitives": [
+ {
+ "op": "modify_field",
+ "parameters": [
+ {
+ "type": "field",
+ "value": [
+ "intrinsic_metadata",
+ "mcast_grp"
+ ]
+ },
+ {
+ "type": "field",
+ "value": [
+ "standard_metadata",
+ "ingress_port"
+ ]
+ }
+ ]
+ }
+ ]
+ },
+ {
+ "name": "_drop",
+ "id": 1,
+ "runtime_data": [],
+ "primitives": [
+ {
+ "op": "modify_field",
+ "parameters": [
+ {
+ "type": "field",
+ "value": [
+ "standard_metadata",
+ "egress_spec"
+ ]
+ },
+ {
+ "type": "hexstr",
+ "value": "0x1ff"
+ }
+ ]
+ }
+ ]
+ },
+ {
+ "name": "fwd",
+ "id": 2,
+ "runtime_data": [
+ {
+ "name": "port",
+ "bitwidth": 9
+ }
+ ],
+ "primitives": [
+ {
+ "op": "modify_field",
+ "parameters": [
+ {
+ "type": "field",
+ "value": [
+ "standard_metadata",
+ "egress_spec"
+ ]
+ },
+ {
+ "type": "runtime_data",
+ "value": 0
+ }
+ ]
+ }
+ ]
+ },
+ {
+ "name": "send_to_cpu",
+ "id": 3,
+ "runtime_data": [
+ {
+ "name": "device",
+ "bitwidth": 8
+ },
+ {
+ "name": "reason",
+ "bitwidth": 8
+ }
+ ],
+ "primitives": [
+ {
+ "op": "add_header",
+ "parameters": [
+ {
+ "type": "header",
+ "value": "cpu_header"
+ }
+ ]
+ },
+ {
+ "op": "modify_field",
+ "parameters": [
+ {
+ "type": "field",
+ "value": [
+ "cpu_header",
+ "device"
+ ]
+ },
+ {
+ "type": "runtime_data",
+ "value": 0
+ }
+ ]
+ },
+ {
+ "op": "modify_field",
+ "parameters": [
+ {
+ "type": "field",
+ "value": [
+ "cpu_header",
+ "reason"
+ ]
+ },
+ {
+ "type": "runtime_data",
+ "value": 1
+ }
+ ]
+ },
+ {
+ "op": "modify_field",
+ "parameters": [
+ {
+ "type": "field",
+ "value": [
+ "standard_metadata",
+ "egress_spec"
+ ]
+ },
+ {
+ "type": "hexstr",
+ "value": "0xfa"
+ }
+ ]
+ }
+ ]
+ }
+ ],
+ "pipelines": [
+ {
+ "name": "ingress",
+ "id": 0,
+ "init_table": "table0",
+ "tables": [
+ {
+ "name": "table0",
+ "id": 0,
+ "match_type": "ternary",
+ "type": "simple",
+ "max_size": 16384,
+ "with_counters": false,
+ "direct_meters": null,
+ "support_timeout": false,
+ "key": [
+ {
+ "match_type": "ternary",
+ "target": [
+ "standard_metadata",
+ "ingress_port"
+ ],
+ "mask": null
+ },
+ {
+ "match_type": "ternary",
+ "target": [
+ "ethernet",
+ "dstAddr"
+ ],
+ "mask": null
+ },
+ {
+ "match_type": "ternary",
+ "target": [
+ "ethernet",
+ "srcAddr"
+ ],
+ "mask": null
+ },
+ {
+ "match_type": "ternary",
+ "target": [
+ "ethernet",
+ "etherType"
+ ],
+ "mask": null
+ }
+ ],
+ "actions": [
+ "fwd",
+ "flood",
+ "send_to_cpu",
+ "_drop"
+ ],
+ "next_tables": {
+ "fwd": null,
+ "flood": null,
+ "send_to_cpu": null,
+ "_drop": null
+ },
+ "default_action": null
+ }
+ ],
+ "conditionals": []
+ },
+ {
+ "name": "egress",
+ "id": 1,
+ "init_table": null,
+ "tables": [],
+ "conditionals": []
+ }
+ ],
+ "calculations": [],
+ "checksums": [],
+ "learn_lists": [],
+ "field_lists": [],
+ "counter_arrays": [],
+ "register_arrays": [],
+ "force_arith": [
+ [
+ "standard_metadata",
+ "ingress_port"
+ ],
+ [
+ "standard_metadata",
+ "packet_length"
+ ],
+ [
+ "standard_metadata",
+ "egress_spec"
+ ],
+ [
+ "standard_metadata",
+ "egress_port"
+ ],
+ [
+ "standard_metadata",
+ "egress_instance"
+ ],
+ [
+ "standard_metadata",
+ "instance_type"
+ ],
+ [
+ "standard_metadata",
+ "clone_spec"
+ ],
+ [
+ "standard_metadata",
+ "_padding"
+ ],
+ [
+ "intrinsic_metadata",
+ "ingress_global_timestamp"
+ ],
+ [
+ "intrinsic_metadata",
+ "lf_field_list"
+ ],
+ [
+ "intrinsic_metadata",
+ "mcast_grp"
+ ],
+ [
+ "intrinsic_metadata",
+ "egress_rid"
+ ]
+ ]
+}
\ No newline at end of file