Merge branch 'master' of gitlab.ethz.ch:nicosc/master-thesis
This commit is contained in:
commit
f97a41689f
3 changed files with 72 additions and 67 deletions
|
@ -6577,7 +6577,8 @@ Compiler Bug: actions_egress.p4(89): unhandled expression realmain_controller_de
|
|||
|
||||
|
||||
#+END_CENTER
|
||||
*** TODO 2019-07-24: BUG unhandled node: <IfStatement>(471564)
|
||||
*** DONE 2019-07-24: BUG unhandled node: <IfStatement>(471564)
|
||||
CLOSED: [2019-07-24 Wed 23:34]
|
||||
- Removing the call to " delta_udp_from_v6_to_v4()" fixes the
|
||||
problem.
|
||||
- Calling v4sum() only works
|
||||
|
|
|
@ -50,16 +50,43 @@ action delta_prepare()
|
|||
v6sum();
|
||||
}
|
||||
|
||||
action delta_udp_from_v4_to_v6()
|
||||
|
||||
#ifdef _SUME_SWITCH_P4_
|
||||
#define delta_udp_from_v6_to_v4 delta_prepare (); tmp17 = (bit<17>) hdr.udp.checksum + (bit<17>) meta.v4sum; if (tmp17[16:16] == 1) { tmp17 = tmp17 + 1; tmp17[16:16] = 0; } tmp17 = tmp17 + (bit<17>) (0xffff - meta.v6sum); if (tmp17[16:16] == 1) { tmp17 = tmp17 + 1; tmp17[16:16] = 0; } hdr.udp.checksum = (bit<16>) tmp17;
|
||||
#define delta_tcp_from_v6_to_v4 delta_prepare (); tmp17 = (bit<17>) hdr.tcp.checksum + (bit<17>) meta.v4sum; if (tmp17[16:16] == 1) { tmp17 = tmp17 + 1; tmp17[16:16] = 0; } tmp17 = tmp17 + (bit<17>) (0xffff - meta.v6sum); if (tmp17[16:16] == 1) { tmp17 = tmp17 + 1; tmp17[16:16] = 0; } hdr.tcp.checksum = (bit<16>) tmp17;
|
||||
|
||||
#define delta_tcp_from_v4_to_v6 delta_prepare(); tmp17 = (bit<17>) hdr.tcp.checksum + (bit<17>) meta.v6sum; if (tmp17[16:16] == 1) { tmp17 = tmp17 + 1; tmp17[16:16] = 0; } tmp17 = tmp17 + (bit<17>) (0xffff - meta.v4sum); if (tmp17[16:16] == 1) { tmp17 = tmp17 + 1; tmp17[16:16] = 0; } hdr.tcp.checksum = (bit<16>) tmp17;
|
||||
#define delta_udp_from_v4_to_v6 delta_prepare(); tmp17 = (bit<17>) hdr.udp.checksum + (bit<17>) meta.v6sum; if (tmp17[16:16] == 1) { tmp17 = tmp17 + 1; tmp17[16:16] = 0; } tmp17 = tmp17 + (bit<17>) (0xffff - meta.v4sum); if (tmp17[16:16] == 1) { tmp17 = tmp17 + 1; tmp17[16:16] = 0; } hdr.udp.checksum = (bit<16>) tmp17;
|
||||
|
||||
#else
|
||||
action delta_tcp_from_v6_to_v4()
|
||||
{
|
||||
delta_prepare();
|
||||
|
||||
bit<17> tmp = (bit<17>) hdr.udp.checksum + (bit<17>) meta.v6sum;
|
||||
bit<17> tmp = (bit<17>) hdr.tcp.checksum + (bit<17>) meta.v4sum;
|
||||
if (tmp[16:16] == 1) {
|
||||
tmp = tmp + 1;
|
||||
tmp[16:16] = 0;
|
||||
}
|
||||
tmp = tmp + (bit<17>) (0xffff - meta.v4sum);
|
||||
tmp = tmp + (bit<17>) (0xffff - meta.v6sum);
|
||||
if (tmp[16:16] == 1) {
|
||||
tmp = tmp + 1;
|
||||
tmp[16:16] = 0;
|
||||
}
|
||||
|
||||
hdr.tcp.checksum = (bit<16>) tmp;
|
||||
}
|
||||
|
||||
action delta_udp_from_v6_to_v4()
|
||||
{
|
||||
delta_prepare();
|
||||
|
||||
bit<17> tmp = (bit<17>) hdr.udp.checksum + (bit<17>) meta.v4sum;
|
||||
if (tmp[16:16] == 1) {
|
||||
tmp = tmp + 1;
|
||||
tmp[16:16] = 0;
|
||||
}
|
||||
tmp = tmp + (bit<17>) (0xffff - meta.v6sum);
|
||||
if (tmp[16:16] == 1) {
|
||||
tmp = tmp + 1;
|
||||
tmp[16:16] = 0;
|
||||
|
@ -68,9 +95,6 @@ action delta_udp_from_v4_to_v6()
|
|||
hdr.udp.checksum = (bit<16>) tmp;
|
||||
}
|
||||
|
||||
#define delta_udp_from_v6_to_v4 delta_prepare (); tmp17 = (bit<17>) hdr.udp.checksum + (bit<17>) meta.v4sum; if (tmp17[16:16] == 1) { tmp17 = tmp17 + 1; tmp17[16:16] = 0; } tmp17 = tmp17 + (bit<17>) (0xffff - meta.v6sum); if (tmp17[16:16] == 1) { tmp17 = tmp17 + 1; tmp17[16:16] = 0; } hdr.udp.checksum = (bit<16>) tmp17;
|
||||
|
||||
|
||||
action delta_tcp_from_v4_to_v6()
|
||||
{
|
||||
delta_prepare();
|
||||
|
@ -89,24 +113,26 @@ action delta_tcp_from_v4_to_v6()
|
|||
hdr.tcp.checksum = (bit<16>) tmp;
|
||||
}
|
||||
|
||||
action delta_tcp_from_v6_to_v4()
|
||||
action delta_udp_from_v4_to_v6()
|
||||
{
|
||||
delta_prepare();
|
||||
|
||||
bit<17> tmp = (bit<17>) hdr.tcp.checksum + (bit<17>) meta.v4sum;
|
||||
bit<17> tmp = (bit<17>) hdr.udp.checksum + (bit<17>) meta.v6sum;
|
||||
if (tmp[16:16] == 1) {
|
||||
tmp = tmp + 1;
|
||||
tmp[16:16] = 0;
|
||||
}
|
||||
tmp = tmp + (bit<17>) (0xffff - meta.v6sum);
|
||||
tmp = tmp + (bit<17>) (0xffff - meta.v4sum);
|
||||
if (tmp[16:16] == 1) {
|
||||
tmp = tmp + 1;
|
||||
tmp[16:16] = 0;
|
||||
}
|
||||
|
||||
hdr.tcp.checksum = (bit<16>) tmp;
|
||||
hdr.udp.checksum = (bit<16>) tmp;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
action delta_ipv4_from_v6_to_v4()
|
||||
{
|
||||
bit<16> tmp = 0;
|
||||
|
@ -122,34 +148,17 @@ action delta_ipv4_from_v6_to_v4()
|
|||
( ((bit<16>) hdr.ipv4.diff_serv) << 2) +
|
||||
( (bit<16>) hdr.ipv4.ecn);
|
||||
tmp = tmp + shift_tmp;
|
||||
|
||||
// tmp = tmp + (bit<16>) hdr.ipv4.version; /* 4 bit */
|
||||
// tmp = tmp + (bit<16>) hdr.ipv4.ihl; /* 4 bit */
|
||||
// tmp = tmp + (bit<16>) hdr.ipv4.diff_serv; /* 6 bit */
|
||||
// tmp = tmp + (bit<16>) hdr.ipv4.ecn; /* 2 bit */
|
||||
|
||||
|
||||
tmp = tmp + (bit<16>) hdr.ipv4.totalLen; /* 16 bit */
|
||||
|
||||
tmp = tmp + (bit<16>) hdr.ipv4.identification; /* 16 bit */
|
||||
|
||||
shift_tmp = ((bit<16>) (hdr.ipv4.flags) << 13) +
|
||||
((bit<16>) hdr.ipv4.fragOffset);
|
||||
tmp = tmp + shift_tmp;
|
||||
|
||||
// tmp = tmp + (bit<16>) hdr.ipv4.flags; /* 3 bit */
|
||||
// tmp = tmp + (bit<16>) hdr.ipv4.fragOffset; /* 13 bit */
|
||||
|
||||
shift_tmp = ((bit<16>) (hdr.ipv4.ttl) << 8) +
|
||||
((bit<16>) hdr.ipv4.protocol);
|
||||
tmp = tmp + shift_tmp;
|
||||
|
||||
// tmp = tmp + (bit<16>) hdr.ipv4.ttl; /* 8 bit */
|
||||
// tmp = tmp + (bit<16>) hdr.ipv4.protocol; /* 8 bit */
|
||||
|
||||
tmp = tmp + (bit<16>) hdr.ipv4.src_addr[15:0]; /* 16 bit */
|
||||
tmp = tmp + (bit<16>) hdr.ipv4.src_addr[31:16]; /* 16 bit */
|
||||
tmp = tmp + (bit<16>) hdr.ipv4.dst_addr[15:0]; /* 16 bit */
|
||||
tmp = tmp + (bit<16>) hdr.ipv4.src_addr[15:0]; /* 16 bit */
|
||||
tmp = tmp + (bit<16>) hdr.ipv4.src_addr[31:16]; /* 16 bit */
|
||||
tmp = tmp + (bit<16>) hdr.ipv4.dst_addr[15:0]; /* 16 bit */
|
||||
tmp = tmp + (bit<16>) hdr.ipv4.dst_addr[31:16]; /* 16 bit */
|
||||
|
||||
hdr.ipv4.checksum = ~tmp;
|
||||
|
|
|
@ -2,33 +2,10 @@
|
|||
#include <sume_switch.p4>
|
||||
#include "headers.p4"
|
||||
|
||||
/* required for netfpga */
|
||||
#define USE_NICO_DELTA_CHECKSUM 1
|
||||
|
||||
|
||||
// typedef bit<48> EthAddr_t;
|
||||
// header Ethernet_h {
|
||||
// EthAddr_t dstAddr;
|
||||
// EthAddr_t srcAddr;
|
||||
// bit<16> etherType;
|
||||
// }
|
||||
|
||||
//typedef struct headers Parsed_packet;
|
||||
|
||||
#define Parsed_packet headers
|
||||
#define user_metadata_t metadata
|
||||
|
||||
//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?
|
||||
// digest_data, MUST be 256 bits -- not using it
|
||||
struct digest_data_t {
|
||||
bit<256> unused;
|
||||
}
|
||||
|
@ -127,6 +104,7 @@ control RealMain(
|
|||
}
|
||||
|
||||
apply {
|
||||
bit<17> tmp17 = 0;
|
||||
if(hdr.ipv6.isValid()) {
|
||||
if(nat64.apply().hit) { /* generic / static nat64 done */
|
||||
if(hdr.icmp6.isValid()) {
|
||||
|
@ -143,26 +121,43 @@ control RealMain(
|
|||
}
|
||||
|
||||
if(hdr.udp.isValid()) {
|
||||
bit<17> tmp17 = 0;
|
||||
//delta_prepare();
|
||||
//delta_udp_from_v6_to_v4();
|
||||
//stupid();
|
||||
delta_udp_from_v6_to_v4
|
||||
}
|
||||
// if(hdr.tcp.isValid()) {
|
||||
// #ifdef USE_NICO_DELTA_CHECKSUM
|
||||
// delta_tcp_from_v6_to_v4();
|
||||
// #else
|
||||
|
||||
// meta.chk_tcp_v4 = 1;
|
||||
// #endif
|
||||
// }
|
||||
if(hdr.tcp.isValid()) {
|
||||
delta_tcp_from_v6_to_v4
|
||||
}
|
||||
|
||||
v4_networks.apply(); /* apply egress for IPv4 */
|
||||
exit; /* no further v6 processing */
|
||||
|
||||
} else if(hdr.ipv4.isValid()) {
|
||||
if(icmp.apply().hit) {
|
||||
v4_networks.apply();
|
||||
exit;
|
||||
} else if(nat46.apply().hit) {
|
||||
if(hdr.icmp.isValid()) {
|
||||
nat46_icmp_generic();
|
||||
|
||||
if(hdr.icmp.type == ICMP_ECHO_REPLY) {
|
||||
hdr.icmp6.type = ICMP6_ECHO_REPLY;
|
||||
}
|
||||
if(hdr.icmp.type == ICMP_ECHO_REQUEST) {
|
||||
hdr.icmp6.type = ICMP6_ECHO_REQUEST;
|
||||
}
|
||||
}
|
||||
if(hdr.udp.isValid()) {
|
||||
delta_udp_from_v4_to_v6
|
||||
}
|
||||
if(hdr.tcp.isValid()) {
|
||||
delta_tcp_from_v4_to_v6
|
||||
}
|
||||
|
||||
v6_networks.apply();
|
||||
exit;
|
||||
}
|
||||
v4_networks.apply(); /* regular routing, egress */
|
||||
}
|
||||
}
|
||||
|
||||
lookup_table.apply();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue