p4c icon indicating copy to clipboard operation
p4c copied to clipboard

custom extern implementation

Open Arishbiswas opened this issue 1 year ago • 1 comments

how can we add custom extern for psa-ebpf backend. is it possoble to write an (ebpf.c) extern and call it from the p4 program

Arishbiswas avatar Jun 18 '24 05:06 Arishbiswas

@osinstom @tatry

You can add the --extern-file command to the compiler, I would take a look at the https://github.com/p4lang/p4c/blob/main/backends/ebpf/CMakeLists.txt#L256C156-L256C169 ebpf_checksum_extern example.

sudo -E p4c/backends/ebpf/run-ebpf-test.py -t test -c "p4c/build/p4c-ebpf" p4c --extern-file p4c/testdata/extern_modules/extern-checksum-ebpf.c  p4c/testdata/p4_16_samples/ebpf_checksum_extern.p4

should run it.

fruffy avatar Jun 18 '24 12:06 fruffy