From 6b478c87f15c59d5c6b1eca58ef331fae9b850cd Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sun, 21 Jul 2019 10:50:26 +0200 Subject: [PATCH] Try fix shifting errors in first block --- doc/plan.org | 23 +++++++++++++++++++++++ p4src/actions_delta_checksum.p4 | 6 +++--- 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/doc/plan.org b/doc/plan.org index aadbbb8..a3f9099 100644 --- a/doc/plan.org +++ b/doc/plan.org @@ -5674,6 +5674,9 @@ Result: no reply, but translated packets seen on h3; wrong IPv4 checksum; tcp checksum is ok -> doing manual calculation to see where diff comes from *** TODO Shifting / compile errors + +v1: wrong parenthesis + #+BEGIN_CENTER p4c --target bmv2 --arch v1model --std p4-16 "../p4src/checksum_diff.p4" -o "/home/p4/master-thesis/p4src" ../p4src/actions_delta_checksum.p4(135): warning: <<: Shifting 16-bit value with 17 @@ -5688,6 +5691,26 @@ p4c --target bmv2 --arch v1model --std p4-16 "../p4src/checksum_diff.p4" -o "/ho Compilation Error #+END_CENTER + +v2: wrong bit width + +#+BEGIN_CENTER +p4c --target bmv2 --arch v1model --std p4-16 "../p4src/checksum_diff.p4" -o "/home/p4/master-thesis/p4src" +../p4src/actions_delta_checksum.p4(135): warning: <<: shifting value with 4 bits by 12 + shift_tmp = (bit<16>) (hdr.ipv4.version << 12) + + ^^^^^^^^^^^^^^^^^^^^^^ +../p4src/actions_delta_checksum.p4(136): warning: <<: shifting value with 4 bits by 8 + (bit<16>) (hdr.ipv4.ihl << 8) + + ^^^^^^^^^^^^^^^^^ +../p4src/actions_delta_checksum.p4(135): warning: <<: shifting value with 4 bits by 12 + shift_tmp = (bit<16>) (hdr.ipv4.version << 12) + + ^^^^^^^^^^^^^^^^^^^^^^ +../p4src/actions_delta_checksum.p4(136): warning: <<: shifting value with 4 bits by 8 + (bit<16>) (hdr.ipv4.ihl << 8) + + ^^^^^^^^^^^^^^^^^ + +#+END_CENTER + ** The NetPFGA saga Problems encountered: - The logfile for a compile run is 10k+ lines diff --git a/p4src/actions_delta_checksum.p4 b/p4src/actions_delta_checksum.p4 index 37d8bf9..999ff8f 100644 --- a/p4src/actions_delta_checksum.p4 +++ b/p4src/actions_delta_checksum.p4 @@ -132,9 +132,9 @@ action delta_ipv4_from_v6_to_v4() Does NOT contain payload! -> can be done manually */ - shift_tmp = (bit<16>) (hdr.ipv4.version << 12) + - (bit<16>) (hdr.ipv4.ihl << 8) + - (bit<16>) (hdr.ipv4.diff_serv << 2) + + shift_tmp = ((bit<16>) hdr.ipv4.version) << 12) + + ((bit<16>) hdr.ipv4.ihl) << 8) + + ((bit<16>) hdr.ipv4.diff_serv) << 2) + ((bit<16>) hdr.ipv4.ecn); tmp = tmp + shift_tmp;