Begin to write defines for netpfga instead of actions

This commit is contained in:
Nico Schottelius 2019-07-24 23:45:40 +02:00
parent a3dd7ee106
commit 5478e9fad7
3 changed files with 31 additions and 56 deletions

View File

@ -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

View File

@ -68,8 +68,28 @@ action delta_udp_from_v4_to_v6()
hdr.udp.checksum = (bit<16>) tmp;
}
#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;
#else
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;
}
hdr.udp.checksum = (bit<16>) tmp;
}
action delta_tcp_from_v4_to_v6()
{
@ -88,6 +108,7 @@ action delta_tcp_from_v4_to_v6()
hdr.tcp.checksum = (bit<16>) tmp;
}
#endif
action delta_tcp_from_v6_to_v4()
{
@ -122,34 +143,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;

View File

@ -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,20 +121,12 @@ 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 */