Remove function, because functions don't compile

This commit is contained in:
Nico Schottelius 2019-07-17 17:37:37 +02:00
parent 87d2db4b5f
commit 831d69fe9c
3 changed files with 142 additions and 69 deletions

View file

@ -5362,8 +5362,65 @@ root@ESPRIMO-P956:~#
[ 488.265605] ixgbe 0000:02:00.0: removed PHC on enp2s0f0
#+END_CENTER
*** DONE 2019-07-16: understood scapy code
CLOSED: [2019-07-16 Tue 11:25]
meta.v6sum = (bit<16>) ((((tmp>>8) & 0xff)|tmp<<8) & 0xffff) ;
*** TODO 2019-07-17: pci-e link speed not enough for 10gbit/s cards: seems ok
This is used to correct endianness!
-> not needed in our case
*** DONE 2019-07-16: Wraptest in P4
CLOSED: [2019-07-16 Tue 12:09]
#+BEGIN_CENTER
mx h3
arp -s 10.0.0.2 00:00:0a:00:00:02
echo V4-OK | socat - TCP:10.0.0.2:2342
#+END_CENTER
Result on the wire of the wraptest:
#+BEGIN_CENTER
10.0.0.3.60106 > 10.0.0.2.2342: Flags [S], cksum 0x0001 (incorrect ->
0xc7f9), seq 3677403557, win 28380, options [mss 9460
,sackOK,TS val 2328087128 ecr 0,nop,wscale 9], length 0
#+END_CENTER
0xffff + 2 = 1
-> as expected
Thus carryover is already implemented. Try to use 16 bit ints
*** DONE 2019-07-16: naive approach
CLOSED: [2019-07-17 Wed 17:29]
Gives off-by-one in udp, sometimes!
10:08:52.626713 IP6 (hlim 64, next-header UDP (17) payload length: 14) 2001:db8:1::a00:1.51345 > 2001:db8::1.2342: [bad udp cks
*** DONE 2019-07-16: get values from P4: v6sum, v4sum and co.
CLOSED: [2019-07-16 Tue 13:15]
- v6sum = 0x9a6b
- v4sum = 0xeadd
- 0x4a8a + 0x9a6b = 0xe4f5 (same as python)
(code: hdr.udp.checksum = 0x4a8a + 0x9a6b)
- hdr.udp.checksum = 0x4a8a + 0x9a6b - 0xeadd;
../p4src/actions_delta_checksum.p4(58): warning: -1512: negative
value with unsigned type
hdr.udp.checksum = 0x4a8a + 0x9a6b - 0xeadd;
Result: 0xfa18!
*** DONE 2019-07-16: debug v3.3: even positive wrap around fails!!
CLOSED: [2019-07-17 Wed 17:29]
- hdr.udp.checksum = 0x91ef + 0x9a6b;
../p4src/actions_delta_checksum.p4(66): warning: 76890: value does not fit in 16 bits
hdr.udp.checksum = 0x91ef + 0x9a6b;
11:52:13.177826 IP6 (hlim 64, next-header UDP (17) payload length: 14)
2001:db8:1::a00:1.50705 > 2001:db8::1.2342: [bad udp cksum 0x2c5a -> 0xfc97!] UDP, length 6
*** DONE 2019-07-17: pci-e link speed not enough for 10gbit/s cards: seems ok
CLOSED: [2019-07-17 Wed 17:29]
eth.nico:
@ -5496,61 +5553,72 @@ Test Complete. Summary Results:
CPU Utilization: local/receiver 31.4% (2.7%u/28.8%s), remote/sender 32.7% (1.2%u/31.5%s)
#+END_CENTER
*** DONE 2019-07-16: understood scapy code
CLOSED: [2019-07-16 Tue 11:25]
meta.v6sum = (bit<16>) ((((tmp>>8) & 0xff)|tmp<<8) & 0xffff) ;
This is used to correct endianness!
-> not needed in our case
*** DONE 2019-07-16: Wraptest in P4
CLOSED: [2019-07-16 Tue 12:09]
*** DONE 2019-07-17: compiler bug when using a function
CLOSED: [2019-07-17 Wed 17:30]
#+BEGIN_CENTER
mx h3
arp -s 10.0.0.2 00:00:0a:00:00:02
echo V4-OK | socat - TCP:10.0.0.2:2342
```p4c --target bmv2 --arch v1model --std p4-16 "../p4src/checksum_diff.p4" -o "/home/p4/master-thesis/p4src"
In file: /home/p4/p4-tools/p4c/backends/bmv2/common/expression.cpp:168
Compiler Bug: ../p4src/actions_delta_checksum.p4(60): ones_complement_sum(hdr.udp.checksum, tmp);: unhandled case
tmp = ones_complement_sum(hdr.udp.checksum, meta.v6sum);
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Compilation Error```
Using the following code:
```/* copied from
https://p4.org/p4-spec/docs/PSA-v1.1.0.html#appendix-internetchecksum-implementation
*/
bit<16> ones_complement_sum(in bit<16> x, in bit<16> y) {
bit<17> ret = (bit<17>) x + (bit<17>) y;
if (ret[16:16] == 1) {
ret = ret + 1;
}
return ret[15:0];
}```
And p4c version:
```p4@ubuntu:~/master-thesis/p4app$ p4c --version
p4c 0.5 (SHA: 5ae30ee)```
#+END_CENTER
*** 2019-07-17: netpfga compiler also does not support function syntax
#+BEGIN_CENTER
make[1]: Entering directory '/home/nico/projects/P4-NetFPGA/contrib-projects/sume-sdnet-switch/projects/minip4/src'
p4c-sdnet -o minip4.sdnet --sdnet_info .sdnet_switch_info.dat minip4_solution.p4
headers.p4(246):syntax error, unexpected IDENTIFIER, expecting (
bit<16> ones_complement_sum
^^^^^^^^^^^^^^^^^^^
error: 1 errors encountered, aborting compilation
Makefile:34: recipe for target 'all' failed
make[1]: *** [all] Error 1
make[1]: Leaving directory '/home/nico/projects/P4-NetFPGA/contrib-projects/sume-sdnet-switch/projects/minip4/src'
Makefile:31: recipe for target 'frontend' failed
make: *** [frontend] Error 2
nico@nsg-System:~/master-thesis/netpfga$
nico@nsg-System:~/master-thesis/netpfga$ p4c-sdnet --version
/opt/Xilinx/SDNet/2018.2/bin/unwrapped/lnx64.o/p4c-fpga
Version 0.0.1
#+END_CENTER
Result on the wire of the wraptest:
Code:
#+BEGIN_CENTER
10.0.0.3.60106 > 10.0.0.2.2342: Flags [S], cksum 0x0001 (incorrect ->
0xc7f9), seq 3677403557, win 28380, options [mss 9460
,sackOK,TS val 2328087128 ecr 0,nop,wscale 9], length 0
/* copied from
https://p4.org/p4-spec/docs/PSA-v1.1.0.html#appendix-internetchecksum-implementation
*/
bit<16> ones_complement_sum(in bit<16> x, in bit<16> y) {
bit<17> ret = (bit<17>) x + (bit<17>) y;
if (ret[16:16] == 1) {
ret = ret + 1;
}
return ret[15:0];
}
#+END_CENTER
0xffff + 2 = 1
-> as expected
Thus carryover is already implemented. Try to use 16 bit ints
*** TODO 2019-07-16: naive approach
Gives off-by-one in udp, sometimes!
10:08:52.626713 IP6 (hlim 64, next-header UDP (17) payload length: 14) 2001:db8:1::a00:1.51345 > 2001:db8::1.2342: [bad udp cks
*** DONE 2019-07-16: get values from P4: v6sum, v4sum and co.
CLOSED: [2019-07-16 Tue 13:15]
- v6sum = 0x9a6b
- v4sum = 0xeadd
- 0x4a8a + 0x9a6b = 0xe4f5 (same as python)
(code: hdr.udp.checksum = 0x4a8a + 0x9a6b)
- hdr.udp.checksum = 0x4a8a + 0x9a6b - 0xeadd;
../p4src/actions_delta_checksum.p4(58): warning: -1512: negative
value with unsigned type
hdr.udp.checksum = 0x4a8a + 0x9a6b - 0xeadd;
Result: 0xfa18!
*** TODO 2019-07-16: debug v3.3: even positive wrap around fails!!
- hdr.udp.checksum = 0x91ef + 0x9a6b;
../p4src/actions_delta_checksum.p4(66): warning: 76890: value does not fit in 16 bits
hdr.udp.checksum = 0x91ef + 0x9a6b;
11:52:13.177826 IP6 (hlim 64, next-header UDP (17) payload length: 14)
2001:db8:1::a00:1.50705 > 2001:db8::1.2342: [bad udp cksum 0x2c5a -> 0xfc97!] UDP, length 6
** The NetPFGA saga
Problems encountered:
- The logfile for a compile run is 10k+ lines

View file

@ -56,17 +56,36 @@ action delta_udp_from_v4_to_v6()
{
delta_prepare();
bit<16> tmp = 0;
tmp = ones_complement_sum(hdr.udp.checksum, meta.v6sum);
hdr.udp.checksum = ones_complement_sum(tmp, 0xffff - meta.v6sum);
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);
if (tmp[16:16] == 1) {
tmp = tmp + 1;
tmp[16:16] = 0;
}
hdr.udp.checksum = tmp;
}
action delta_tcp_from_v4_to_v6()
{
delta_prepare();
bit<16> tmp = 0;
tmp = ones_complement_sum(hdr.tcp.checksum, meta.v6sum);
hdr.tcp.checksum = ones_complement_sum(tmp, 0xffff - meta.v6sum);
bit<17> tmp = (bit<17>) hdr.tcp.checksum + (bit<17>) meta.v6sum;
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.tcp.checksum = tmp;
}
action delta_ipv4_from_v6_to_v4()

View file

@ -238,18 +238,4 @@ struct metadata {
table_t table_id;
}
/* copied from
https://p4.org/p4-spec/docs/PSA-v1.1.0.html#appendix-internetchecksum-implementation
*/
bit<16> ones_complement_sum(in bit<16> x, in bit<16> y) {
bit<17> ret = (bit<17>) x + (bit<17>) y;
if (ret[16:16] == 1) {
ret = ret + 1;
}
return ret[15:0];
}
#endif