blob: d09eab8aacd26a0cb45f858d1c8b441d331094c9 [file] [log] [blame]
control int_metadata_insert(inout parsed_headers_t hdr,
in int_metadata_t int_metadata,
inout standard_metadata_t standard_metadata) {
// this implementation covers only INT instructions 0, 1, 2, 4, 5
action int_set_header_0() {
hdr.int_switch_id.setValid();
hdr.int_switch_id.switch_id = int_metadata.switch_id;
}
action int_set_header_1() {
hdr.int_port_ids.setValid();
hdr.int_port_ids.ingress_port_id =
(bit<16>) standard_metadata.ingress_port;
hdr.int_port_ids.egress_port_id =
(bit<16>) standard_metadata.egress_port;
}
action int_set_header_2() {
hdr.int_hop_latency.setValid();
hdr.int_hop_latency.hop_latency = 0xffffffff;
}
action int_set_header_3() { // Queue ID + Queue occupancy, not supported
hdr.int_q_occupancy.setValid();
hdr.int_q_occupancy.q_id = 0x00;
hdr.int_q_occupancy.q_occupancy = (bit<24>) standard_metadata.deq_qdepth;
}
action int_set_header_4() {
hdr.int_ingress_tstamp.setValid();
hdr.int_ingress_tstamp.ingress_tstamp =
(bit<32>) standard_metadata.ingress_global_timestamp;
}
action int_set_header_5() {
hdr.int_egress_tstamp.setValid();
hdr.int_egress_tstamp.egress_tstamp =
(bit<32>) standard_metadata.egress_global_timestamp;
}
action int_set_header_6() { // Queue ID + Queue congestion status, not supported
hdr.int_q_congestion.setValid();
hdr.int_q_congestion.q_id = 0xff;
hdr.int_q_congestion.q_congestion = 0xffffff;
}
action int_set_header_7() { // Egress port tx utilization, not supported
hdr.int_egress_port_tx_util.setValid();
hdr.int_egress_port_tx_util.egress_port_tx_util = 0xffffffff;
}
action int_set_header_0003_i0() {
}
action int_set_header_0003_i1() {
int_set_header_3();
}
action int_set_header_0003_i2() {
int_set_header_2();
}
action int_set_header_0003_i3() {
int_set_header_3();
int_set_header_2();
}
action int_set_header_0003_i4() {
int_set_header_1();
}
action int_set_header_0003_i5() {
int_set_header_3();
int_set_header_1();
}
action int_set_header_0003_i6() {
int_set_header_2();
int_set_header_1();
}
action int_set_header_0003_i7() {
int_set_header_3();
int_set_header_2();
int_set_header_1();
}
action int_set_header_0003_i8() {
int_set_header_0();
}
action int_set_header_0003_i9() {
int_set_header_3();
int_set_header_0();
}
action int_set_header_0003_i10() {
int_set_header_2();
int_set_header_0();
}
action int_set_header_0003_i11() {
int_set_header_3();
int_set_header_2();
int_set_header_0();
}
action int_set_header_0003_i12() {
int_set_header_1();
int_set_header_0();
}
action int_set_header_0003_i13() {
int_set_header_3();
int_set_header_1();
int_set_header_0();
}
action int_set_header_0003_i14() {
int_set_header_2();
int_set_header_1();
int_set_header_0();
}
action int_set_header_0003_i15() {
int_set_header_3();
int_set_header_2();
int_set_header_1();
int_set_header_0();
}
table int_inst_0003 {
key = {
hdr.int_header.instruction_mask_0003 : exact;
}
actions = {
int_set_header_0003_i0;
int_set_header_0003_i1;
int_set_header_0003_i2;
int_set_header_0003_i3;
int_set_header_0003_i4;
int_set_header_0003_i5;
int_set_header_0003_i6;
int_set_header_0003_i7;
int_set_header_0003_i8;
int_set_header_0003_i9;
int_set_header_0003_i10;
int_set_header_0003_i11;
int_set_header_0003_i12;
int_set_header_0003_i13;
int_set_header_0003_i14;
int_set_header_0003_i15;
}
default_action = int_set_header_0003_i0();
size = 17;
}
action int_set_header_0407_i0() {
}
action int_set_header_0407_i1() {
int_set_header_7();
}
action int_set_header_0407_i2() {
int_set_header_6();
}
action int_set_header_0407_i3() {
int_set_header_7();
int_set_header_6();
}
action int_set_header_0407_i4() {
int_set_header_5();
}
action int_set_header_0407_i5() {
int_set_header_7();
int_set_header_5();
}
action int_set_header_0407_i6() {
int_set_header_6();
int_set_header_5();
}
action int_set_header_0407_i7() {
int_set_header_7();
int_set_header_6();
int_set_header_5();
}
action int_set_header_0407_i8() {
int_set_header_4();
}
action int_set_header_0407_i9() {
int_set_header_7();
int_set_header_4();
}
action int_set_header_0407_i10() {
int_set_header_6();
int_set_header_4();
}
action int_set_header_0407_i11() {
int_set_header_7();
int_set_header_6();
int_set_header_4();
}
action int_set_header_0407_i12() {
int_set_header_5();
int_set_header_4();
}
action int_set_header_0407_i13() {
int_set_header_7();
int_set_header_5();
int_set_header_4();
}
action int_set_header_0407_i14() {
int_set_header_6();
int_set_header_5();
int_set_header_4();
}
action int_set_header_0407_i15() {
int_set_header_7();
int_set_header_6();
int_set_header_5();
int_set_header_4();
}
table int_inst_0407 {
key = {
hdr.int_header.instruction_mask_0407 : exact;
}
actions = {
int_set_header_0407_i0;
int_set_header_0407_i1;
int_set_header_0407_i2;
int_set_header_0407_i3;
int_set_header_0407_i4;
int_set_header_0407_i5;
int_set_header_0407_i6;
int_set_header_0407_i7;
int_set_header_0407_i8;
int_set_header_0407_i9;
int_set_header_0407_i10;
int_set_header_0407_i11;
int_set_header_0407_i12;
int_set_header_0407_i13;
int_set_header_0407_i14;
int_set_header_0407_i15;
}
default_action = int_set_header_0407_i0();
size = 17;
}
apply {
int_inst_0003.apply();
int_inst_0407.apply();
}
}
control int_outer_encap(inout parsed_headers_t hdr,
in int_metadata_t int_metadata) {
action int_update_ipv4() {
hdr.ipv4.total_len = hdr.ipv4.total_len + int_metadata.insert_byte_cnt;
}
action int_update_udp() {
hdr.udp.len = hdr.udp.len + int_metadata.insert_byte_cnt;
hdr.udp.checksum = 0;
}
action int_update_shim() {
hdr.intl4_shim.len = hdr.intl4_shim.len + int_metadata.int_hdr_word_len;
}
apply{
if (hdr.ipv4.isValid()) {
int_update_ipv4();
}
if (hdr.udp.isValid()) {
int_update_udp();
}
if (hdr.intl4_shim.isValid()) {
int_update_shim();
}
}
}
control int_egress(inout parsed_headers_t hdr,
inout int_metadata_t int_metadata,
inout standard_metadata_t standard_metadata) {
action int_transit(bit<32> switch_id) {
int_metadata.switch_id = switch_id;
int_metadata.insert_byte_cnt = (bit<16>) (hdr.int_header.ins_cnt << 2);
int_metadata.int_hdr_word_len = (bit<8>) int_metadata.ins_cnt_tmp;
}
table int_prep {
key = {}
actions = {int_transit;}
}
action int_hop_cnt_increment() {
hdr.int_header.total_hop_cnt = hdr.int_header.total_hop_cnt + 1;
}
action int_hop_cnt_exceeded() {
hdr.int_header.e = 1;
}
apply{
if(hdr.int_header.isValid()) {
if(hdr.int_header.total_hop_cnt != hdr.int_header.max_hop_cnt &&
hdr.int_header.e == 0) {
int_hop_cnt_increment();
int_prep.apply();
int_metadata_insert.apply(hdr, int_metadata, standard_metadata);
int_outer_encap.apply(hdr, int_metadata);
} else {
int_hop_cnt_exceeded();
}
}
}
}