P4C
The P4 Compiler
Loading...
Searching...
No Matches
Control Plane API Generation

Namespaces

namespace  P4::ControlPlaneAPI
 TODO(antonin): High level goals of the generator go here!!
 

Functions

P4RuntimeAPI P4::generateP4Runtime (const IR::P4Program *program, cstring arch)
 
P4RuntimeAPI P4::P4RuntimeSerializer::generateP4Runtime (const IR::P4Program *program, cstring arch)
 
static P4RuntimeSerializerP4::P4RuntimeSerializer::get ()
 
void P4::P4RuntimeSerializer::registerArch (const cstring archName, const ControlPlaneAPI::P4RuntimeArchHandlerBuilderIface *builder)
 
static cstring P4::P4RuntimeSerializer::resolveArch (const CompilerOptions &options)
 
void P4::P4RuntimeAPI::serializeEntriesTo (std::ostream *destination, P4RuntimeFormat format) const
 
void P4::P4RuntimeAPI::serializeP4InfoTo (std::ostream *destination, P4RuntimeFormat format) const
 
void P4::P4RuntimeSerializer::serializeP4RuntimeIfRequired (const IR::P4Program *program, const CompilerOptions &options)
 
void P4::P4RuntimeSerializer::serializeP4RuntimeIfRequired (const P4RuntimeAPI &p4Runtime, const CompilerOptions &options)
 
void P4::serializeP4RuntimeIfRequired (const IR::P4Program *program, const CompilerOptions &options)
 

Detailed Description

Function Documentation

◆ generateP4Runtime() [1/2]

P4RuntimeAPI P4::generateP4Runtime ( const IR::P4Program * program,
cstring arch = "v1model"_cs )

◆ generateP4Runtime() [2/2]

P4RuntimeAPI P4::P4RuntimeSerializer::generateP4Runtime ( const IR::P4Program * program,
cstring arch )

Generate a P4Runtime control-plane API for the provided program and architecture.

API generation never fails, but if errors are encountered in the program some constructs may be excluded from the API. In this case, a program error will be reported.

Parameters
programThe program to construct the control-plane API from. All frontend passes must have already run.
Returns
the generated P4Runtime API.

◆ resolveArch()

cstring P4::P4RuntimeSerializer::resolveArch ( const CompilerOptions & options)
static
Returns
architecture name based on provided command-line @options and environment.

◆ serializeEntriesTo()

void P4::P4RuntimeAPI::serializeEntriesTo ( std::ostream * destination,
P4RuntimeFormat format ) const

Serialize the WriteRequest message containing all the table entries to the @destination stream in the requested protobuf serialization @format.

◆ serializeP4InfoTo()

void P4::P4RuntimeAPI::serializeP4InfoTo ( std::ostream * destination,
P4RuntimeFormat format ) const

Serialize this control-plane API to the provided output stream, using the given serialization format.

◆ serializeP4RuntimeIfRequired() [1/3]

void P4::P4RuntimeSerializer::serializeP4RuntimeIfRequired ( const IR::P4Program * program,
const CompilerOptions & options )

A convenience wrapper for P4::generateP4Runtime() which generates the P4RuntimeAPI structure for the provided program and serializes it according to the provided command-line options.

Parameters
programThe program to construct the control-plane API from. All frontend passes must have already run.
optionsThe command-line options used to invoke the compiler.

◆ serializeP4RuntimeIfRequired() [2/3]

void P4::P4RuntimeSerializer::serializeP4RuntimeIfRequired ( const P4RuntimeAPI & p4Runtime,
const CompilerOptions & options )

Serializes an existing P4RuntimeAPI structure generated by P4::generateP4Runtime(), according to the provided command-line options.

Parameters
programThe program to construct the control-plane API from. All frontend passes must have already run.
optionsThe command-line options used to invoke the compiler.

◆ serializeP4RuntimeIfRequired() [3/3]

void P4::serializeP4RuntimeIfRequired ( const IR::P4Program * program,
const CompilerOptions & options )