master-thesis/p4src/minip4_solution.p4

115 lines
2.4 KiB
Text
Raw Normal View History

2019-07-23 10:21:49 +00:00
#include <core.p4>
#include <sume_switch.p4>
#include "headers.p4"
2019-07-24 10:15:26 +00:00
#define Parsed_packet headers
#define user_metadata_t metadata
2019-07-24 10:01:47 +00:00
// digest_data, MUST be 256 bits -- not using it
2019-07-23 10:21:49 +00:00
struct digest_data_t {
bit<256> unused;
}
/********************************************************************************
* Parser
*/
parser RealParser(
packet_in packet,
out Parsed_packet hdr,
out user_metadata_t meta,
out digest_data_t digest_data,
inout sume_metadata_t standard_metadata) {
state start {
2019-07-24 07:57:16 +00:00
packet.extract(hdr.ethernet);
2019-07-24 10:15:26 +00:00
// meta.unused = 0;
2019-07-24 07:57:16 +00:00
digest_data.unused = 0;
transition accept;
}
}
2019-07-23 10:21:49 +00:00
@Xilinx_MaxPacketRegion(1024)
parser TopParser(
packet_in b,
out Parsed_packet p,
out user_metadata_t user_metadata,
out digest_data_t digest_data,
inout sume_metadata_t sume_metadata) {
RealParser() realparser;
2019-07-24 07:53:13 +00:00
state start {
realparser.apply(b, p, user_metadata, digest_data, sume_metadata);
transition accept;
}
}
2019-07-23 10:22:31 +00:00
/********************************************************************************
* Main
*/
control RealMain(
inout Parsed_packet hdr,
inout user_metadata_t meta,
inout digest_data_t digest_data,
inout sume_metadata_t sume_metadata) {
#include "actions_nat64_generic.p4"
#include "actions_egress.p4"
#include "actions_delta_checksum.p4"
#include "netpfga_dummy.p4"
apply {
bit<17> tmp17 = 0;
/* does not compile without a table - give it a table */
dummy_table_for_netpfga.apply();
/* continue without tables */
#include "netpfga_nat64_stupid_hardcoded.p4"
}
2019-07-25 12:40:20 +00:00
2019-07-23 10:21:49 +00:00
}
control TopPipe(
inout Parsed_packet p,
inout user_metadata_t user_metadata,
inout digest_data_t digest_data,
inout sume_metadata_t sume_metadata) {
RealMain() realmain;
apply {
realmain.apply(p, user_metadata, digest_data, sume_metadata);
}
}
/********************************************************************************
* Deparser
*/
@Xilinx_MaxPacketRegion(1024)
control TopDeparser(
packet_out b,
in Parsed_packet p,
in user_metadata_t user_metadata,
inout digest_data_t digest_data,
inout sume_metadata_t sume_metadata) {
apply {
b.emit(p.ethernet);
}
}
2019-07-23 10:22:31 +00:00
2019-07-23 10:21:49 +00:00
/********************************************************************************
* Switch
*/
SimpleSumeSwitch(
TopParser(),
TopPipe(),
TopDeparser()
) main;