Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

p4c ebpf backend #4578

Open
Arishbiswas opened this issue Mar 30, 2024 · 4 comments
Open

p4c ebpf backend #4578

Arishbiswas opened this issue Mar 30, 2024 · 4 comments
Labels
ebpf Topics related to the eBPF back end question This is a topic requesting clarification.

Comments

@Arishbiswas
Copy link

can anyone share me the source code of p4 that can be translated to ebpf code using ebpf_model.p4 architecture . As i am new to this area and dont have much idea about it, it will be really helpful . Thanks in advance!!

@AdarshRawat1
Copy link
Member

AdarshRawat1 commented Mar 30, 2024

You can try any program from testdata/p4_16_samples/ *_ebpf.p4

@fruffy fruffy added the question This is a topic requesting clarification. label Mar 30, 2024
@fruffy
Copy link
Collaborator

fruffy commented Mar 30, 2024

Correct, the tests are collected here in CMake: https://github.com/p4lang/p4c/blob/main/backends/ebpf/CMakeLists.txt#L178

You can run a test like this:

backends/ebpf/run-ebpf-test.py -t kernel -c "build/p4c-ebpf" /mnt/storage/Projekte/gauntlet/modules/p4c  "$@" testdata/p4_16_samples/action_call_table_ebpf.p4

under the hood this script invokes

p4c/build/p4c-ebpf --Werror -I./p4include --target kernel -o build/tmpfolder/test.c testdata/p4_16_samples/action_call_table_ebpf.p4

Note that you need the appropriate kernel version and the dependencies listed in the eBPF back end in order to make this work.

@fruffy fruffy added the ebpf Topics related to the eBPF back end label Mar 30, 2024
@Arishbiswas
Copy link
Author

thanks for responding
i have one more issue, while trying to run the test-cases for p4tc samples with tc backend then i got the following errors, can you please help me how to resolve it .

/usr/share/p4c/p4include/tc/pna.p4(871): [--Werror=type-error] error: package PNA_NIC
package PNA_NIC<MH, MM>(
^^^^^^^
---- Actual error:
add.p4(113): Cannot unify 'inout' parameter 'hdr' with 'in' parameter 'main_hdr' because they have different directions
inout headers_t hdr, // from main control
^^^
/usr/share/p4c/p4include/tc/pna.p4(867)
in MH main_hdr,
^^^^^^^^
---- Originating from:
add.p4(127): Type of argument 'MainDeparserImpl' (control MainDeparserImpl) does not match type of parameter 'main_deparser' (control MainDeparserT<...>)
MainDeparserImpl()
^^^^^^^^^^^^^^^^^^
add.p4(111)
control MainDeparserImpl(
^^^^^^^^^^^^^^^^
/usr/share/p4c/p4include/tc/pna.p4(874)
MainDeparserT<MH, MM> main_deparser);
^^^^^^^^^^^^^
/usr/share/p4c/p4include/tc/pna.p4(874)
MainDeparserT<MH, MM> main_deparser);
^^^^^^^^^^^^^^^^^^^^^
---- Originating from:
add.p4(128): Constructor invocation '' does not match declaration 'PNA_NIC'
) main;

@fruffy
Copy link
Collaborator

fruffy commented May 2, 2024

You need a different compiler for this. Likely p4c-pna-p4tc instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ebpf Topics related to the eBPF back end question This is a topic requesting clarification.
Projects
None yet
Development

No branches or pull requests

3 participants