Skip to content

Commit

Permalink
eBPF backend: generate P4Runtime files if required (#4113)
Browse files Browse the repository at this point in the history
* eBPF backend: generate P4Runtime files if required

* Disable generation of p4info files for filter model

It is not supported by P4RuntimeSerializer

* Add support for testing P4info files in PTF tests

* Add example P4info files

* Add P4info files for more test cases
  • Loading branch information
tatry authored Sep 12, 2023
1 parent c2460b2 commit 0a0b5aa
Show file tree
Hide file tree
Showing 21 changed files with 2,034 additions and 1 deletion.
7 changes: 7 additions & 0 deletions backends/ebpf/p4c-ebpf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ limitations under the License.
#include <string>

#include "backends/ebpf/version.h"
#include "control-plane/p4RuntimeSerializer.h"
#include "ebpfBackend.h"
#include "ebpfOptions.h"
#include "frontends/common/applyOptionsPragmas.h"
Expand Down Expand Up @@ -71,6 +72,12 @@ void compile(EbpfOptions &options) {
program = frontend.run(options, program);
if (::errorCount() > 0) return;
}

if (!options.arch.isNullOrEmpty() && options.arch != "filter") {
P4::serializeP4RuntimeIfRequired(program, options);
if (::errorCount() > 0) return;
}

EBPF::MidEnd midend;
midend.addDebugHook(hook);
auto toplevel = midend.run(options, program);
Expand Down
Loading

0 comments on commit 0a0b5aa

Please sign in to comment.