cleanup && integrate headers.p4 into minip4

This commit is contained in:
Nico Schottelius 2019-06-03 23:00:32 +02:00
parent 63ec17b9a4
commit 56d2f2ee65
3 changed files with 1 additions and 120 deletions

View file

@ -1,5 +1,6 @@
#include <core.p4> #include <core.p4>
#include <sume_switch.p4> #include <sume_switch.p4>
#include "headers.p4"
/******************************************************************************** /********************************************************************************
* Header * Header

View file

@ -1,119 +0,0 @@
#include <core.p4>
#include <sume_switch.p4>
#include "headers.p4"
/********************************************************************************
* Header
*/
typedef bit<48> EthAddr_t;
header Ethernet_h {
EthAddr_t dstAddr;
EthAddr_t srcAddr;
bit<16> etherType;
}
struct Parsed_packet {
Ethernet_h ethernet;
}
// user defined metadata: can be used to share information between
// TopParser, TopPipe, and TopDeparser
struct user_metadata_t {
bit<8> unused;
}
// digest_data, MUST be 256 bits -- what is this used for?
struct digest_data_t {
bit<256> unused;
}
/********************************************************************************
* Parser
*/
@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) {
state start {
b.extract(p.ethernet);
user_metadata.unused = 0;
digest_data.unused = 0;
transition accept;
}
}
/********************************************************************************
* Main
*/
control TopPipe(inout Parsed_packet p,
inout user_metadata_t user_metadata,
inout digest_data_t digest_data,
inout sume_metadata_t sume_metadata) {
action swap_eth_addresses() {
EthAddr_t temp = p.ethernet.dstAddr;
p.ethernet.dstAddr = p.ethernet.srcAddr;
p.ethernet.srcAddr = temp;
/* set egress port */
sume_metadata.dst_port = sume_metadata.src_port;
}
action send_to_port1() {
sume_metadata.dst_port = 1;
}
action do_nothing() {
EthAddr_t temp = p.ethernet.dstAddr;
}
table lookup_table {
key = {
p.ethernet.dstAddr: exact;
}
actions = {
swap_eth_addresses;
do_nothing;
send_to_port1;
}
size = 64;
// default_action = swap_eth_addresses;
default_action = send_to_port1;
}
apply {
lookup_table.apply();
}
}
/********************************************************************************
* 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);
}
}
/********************************************************************************
* Switch
*/
SimpleSumeSwitch(
TopParser(),
TopPipe(),
TopDeparser()
) main;

View file

@ -13,7 +13,6 @@ parser MyParser(packet_in packet,
inout standard_metadata_t standard_metadata) { inout standard_metadata_t standard_metadata) {
state start { state start {
meta.chk_icmp = 0; meta.chk_icmp = 0;
meta.chk_icmp6 = 0; meta.chk_icmp6 = 0;
meta.chk_icmp6_na_ns = 0; meta.chk_icmp6_na_ns = 0;