Open hesingh opened 2 years ago
The
out.c
file has this code which I don't understand - why is there no struct for hash data in generated code?/* upf_ingress_h.get_hash({meta->upf.gtpu_local_ip}) */ crc16_finalize(ingress_upf_ingress_h_reg);
Implemented algorithm calculate hash based on definition, so it require register variable and input data. Struct for hash data should be generated (as far I remember), but it is not used at all. Each field of data is passed to the crc16_update
function (it can be called multiple times) to update the register value based on input data. Some CRC algorithms after data process transform register value (e.g. by xor with some value), that's why crc16_finalize
function exists, because implementation for CRC16 and CRC32 is the same. See https://github.com/p4lang/p4c/commit/77ddb3e82d6bd4f0e9f9206c7c2b7e9a456eccdc
There are at least two reasons why there is no struct used for hash data in generated code:
I see this commit added code to process
StructExpression
by a backend but no P4 program exists in the commit to test this new processing.
For example see hash-crc16.p4 test P4 program, added by later commit.
This is the P4 program used to test ebpf psa. I am chasing testing of
StructExpression
by using a hash in P4 code.The
out.c
file has this code which I don't understand - why is there no struct for hash data in generated code?I see this commit added code to process
StructExpression
by a backend but no P4 program exists in the commit to test this new processing.https://github.com/p4lang/p4c/commit/c794fb4aa8968f976bb0842b45543fdc5fe9fab1