p4lang/behavioral-model

how to use hash() in packet-io.p4?

KirinR opened this issue · 1 comments

KirinR commented

bit<32> hash_val = hash(0, HashAlgorithm.hash32,{hdr.ethernet.dstAddr,
hdr.ethernet.srcAddr,
hdr.ethernet.etherType,
hdr.ipv4.version,
hdr.ipv4.ihl,
hdr.ipv4.diffserv,
hdr.ipv4.ecn,
hdr.ipv4.totalLen,
hdr.ipv4.identification,
hdr.ipv4.flags,
hdr.ipv4.fragOffset,
hdr.ipv4.ttl,
hdr.ipv4.protocol,
hdr.ipv4.srcAddr,
hdr.ipv4.dstAddr,
hdr.feature.feature0,
hdr.feature.feature1,
hdr.feature.feature2,
hdr.feature.feature3,
hdr.feature.feature4,
hdr.feature.feature5,
hdr.feature.feature6} );

this is not right

KirinR commented

include/packet-io.p4(13): [--Werror=type-error] error: HashAlgorithm.hash32: Invalid enum tag
bit<32> hash_val = hash(0, HashAlgorithm.hash32,{hdr.ethernet.dstAddr,
^^^^^^^^^^^^^^^^^^^^
include/packet-io.p4(13): [--Werror=type-error] error: hash
bit<32> hash_val = hash(0, HashAlgorithm.hash32,{hdr.ethernet.dstAddr,
^
---- Actual error:
include/packet-io.p4(13): : Read-only value used for out/inout parameter 'result'
bit<32> hash_val = hash(0, HashAlgorithm.hash32,{hdr.ethernet.dstAddr,
^
/usr/share/p4c/p4include/v1model.p4(444)
extern void hash<O, T, D, M>(out O result, in HashAlgorithm algo, in T base, in D data, in M max);
^^^^^^
---- Originating from:
/usr/share/p4c/p4include/v1model.p4(444): Function type 'hash' does not match invocation type ''
extern void hash<O, T, D, M>(out O result, in HashAlgorithm algo, in T base, in D data, in M max);
^^^^
include/packet-io.p4(13)
bit<32> hash_val = hash(0, HashAlgorithm.hash32,{hdr.ethernet.dstAddr,
^
make: *** [Makefile:5: build-p4] Error 1