Skip to content

Commit

Permalink
fixed l2_switch target (#186)
Browse files Browse the repository at this point in the history
  • Loading branch information
antoninbas authored Sep 6, 2016
1 parent 349aeba commit ff0cdf4
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 21 deletions.
10 changes: 8 additions & 2 deletions targets/l2_switch/l2_switch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,14 @@ class SimpleSwitch : public Switch {
SimpleSwitch()
: input_buffer(1024), output_buffer(128), pre(new McSimplePre()) {
add_component<McSimplePre>(pre);

add_required_field("standard_metadata", "ingress_port");
add_required_field("standard_metadata", "egress_port");
add_required_field("intrinsic_metadata", "mgid");
add_required_field("intrinsic_metadata", "learn_id");

force_arith_header("standard_metadata");
force_arith_header("intrinsic_metadata");
}

int receive(int port_num, const char *buffer, int len) {
Expand Down Expand Up @@ -111,8 +119,6 @@ void SimpleSwitch::pipeline_thread() {
ingress_port);

phv->get_field("standard_metadata.ingress_port").set(ingress_port);
ingress_port = phv->get_field("standard_metadata.ingress_port").get_int();
std::cout << ingress_port << std::endl;

parser->parse(packet.get());
ingress_mau->apply(packet.get());
Expand Down
18 changes: 1 addition & 17 deletions targets/l2_switch/l2_switch.json
Original file line number Diff line number Diff line change
Expand Up @@ -155,22 +155,6 @@
}
],
"primitives": [
{
"op": "modify_field",
"parameters": [
{
"type": "field",
"value": [
"standard_metadata",
"ingress_port"
]
},
{
"type": "hexstr",
"value": "0x101"
}
]
},
{
"op": "modify_field",
"parameters": [
Expand Down Expand Up @@ -348,4 +332,4 @@
]
}
]
}
}
2 changes: 0 additions & 2 deletions targets/l2_switch/l2_switch.p4
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,6 @@ table smac {
}

action forward(port) {
// hack to force BM to enable arithmetic on this field
modify_field(standard_metadata.ingress_port, 257);
modify_field(standard_metadata.egress_port, port);
}

Expand Down
1 change: 1 addition & 0 deletions targets/simple_switch/simple_switch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ SimpleSwitch::SimpleSwitch(int max_port, bool enable_swap)
add_required_field("standard_metadata", "instance_type");
add_required_field("standard_metadata", "egress_spec");
add_required_field("standard_metadata", "clone_spec");
add_required_field("standard_metadata", "egress_port");

force_arith_field("standard_metadata", "ingress_port");
force_arith_field("standard_metadata", "packet_length");
Expand Down

0 comments on commit ff0cdf4

Please sign in to comment.