-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_PSA_1p1.p4
98 lines (77 loc) · 2.96 KB
/
test_PSA_1p1.p4
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#include <core.p4>
#include <psa.p4>
struct empty_metadata_t {
}
typedef bit<48> ethernet_addr_t;
header ethernet_t {
ethernet_addr_t dst_addr;
ethernet_addr_t src_addr;
bit<16> ether_type;
}
header ipv4_t {
bit<8> ver_ihl;
bit<8> diffserv;
bit<16> total_len;
bit<16> identification;
bit<16> flags_offset;
bit<8> ttl;
bit<8> protocol;
bit<16> hdr_checksum;
bit<32> src_addr;
bit<32> dst_addr;
}
struct headers_t {
ethernet_t ethernet;
ipv4_t ipv4;
}
struct local_metadata_t {
}
parser packet_parser(packet_in packet, out headers_t headers, inout local_metadata_t local_metadata, in psa_ingress_parser_input_metadata_t standard_metadata, in empty_metadata_t resub_meta, in empty_metadata_t recirc_meta) {
state start {
transition parse_ethernet;
}
state parse_ethernet {
packet.extract(headers.ethernet);
transition parser_ipv4;
}
state parser_ipv4 {
packet.extract(headers.ipv4);
transition accept;
}
}
control packet_deparser(packet_out packet, out empty_metadata_t clone_i2e_meta, out empty_metadata_t resubmit_meta, out empty_metadata_t normal_meta, inout headers_t headers, in local_metadata_t local_metadata, in psa_ingress_output_metadata_t istd) {
apply {
packet.emit(headers.ethernet);
packet.emit(headers.ipv4);
}
}
control ingress(inout headers_t headers, inout local_metadata_t local_metadata1, in psa_ingress_input_metadata_t standard_metadata, inout psa_ingress_output_metadata_t ostd) {
bit<32> tmp_ip;
bit<48> tmp_mac;
apply {
//ostd.egress_port = (PortId_t) 0; //standard_metadata.ingress_port;
tmp_ip = headers.ipv4.src_addr;
headers.ipv4.src_addr = headers.ipv4.dst_addr;
headers.ipv4.dst_addr = tmp_ip;
tmp_mac = headers.ethernet.src_addr;
headers.ethernet.src_addr = headers.ethernet.dst_addr;
headers.ethernet.dst_addr = tmp_mac;
send_to_port(ostd, (PortId_t) 1);
}
}
control egress(inout headers_t headers, inout local_metadata_t local_metadata, in psa_egress_input_metadata_t istd, inout psa_egress_output_metadata_t ostd) {
apply {
}
}
parser egress_parser(packet_in buffer, out headers_t headers, inout local_metadata_t local_metadata, in psa_egress_parser_input_metadata_t istd, in empty_metadata_t normal_meta, in empty_metadata_t clone_i2e_meta, in empty_metadata_t clone_e2e_meta) {
state start {
transition accept;
}
}
control egress_deparser(packet_out packet, out empty_metadata_t clone_e2e_meta, out empty_metadata_t recirculate_meta, inout headers_t headers, in local_metadata_t local_metadata, in psa_egress_output_metadata_t istd, in psa_egress_deparser_input_metadata_t edstd) {
apply {
}
}
IngressPipeline(packet_parser(), ingress(), packet_deparser()) ip;
EgressPipeline(egress_parser(), egress(), egress_deparser()) ep;
PSA_Switch(ip, PacketReplicationEngine(), ep, BufferingQueueingEngine()) main;