P4C
The P4 Compiler
Loading...
Searching...
No Matches
P4::EBPF::Target Class Referenceabstract
Inheritance diagram for P4::EBPF::Target:
[legend]

Public Member Functions

virtual cstring abortReturnCode () const =0
 
virtual cstring dataEnd (cstring base) const =0
 
virtual cstring dataLength (cstring base) const =0
 
virtual cstring dataOffset (cstring base) const =0
 
virtual cstring dropReturnCode () const =0
 
virtual void emitCodeSection (Util::SourceCodeBuilder *builder, cstring sectionName) const =0
 
virtual void emitIncludes (Util::SourceCodeBuilder *builder) const =0
 
virtual void emitLicense (Util::SourceCodeBuilder *builder, cstring license) const =0
 
virtual void emitMain (Util::SourceCodeBuilder *builder, cstring functionName, cstring argName) const =0
 
virtual void emitMapInMapDecl (Util::SourceCodeBuilder *builder, cstring innerName, TableKind innerTableKind, cstring innerKeyType, cstring innerValueType, unsigned innerSize, cstring outerName, TableKind outerTableKind, cstring outerKeyType, unsigned outerSize) const
 
virtual void emitPreamble (Util::SourceCodeBuilder *builder) const
 
virtual void emitResizeBuffer (Util::SourceCodeBuilder *builder, cstring buffer, cstring offsetVar) const =0
 
virtual void emitTableDecl (Util::SourceCodeBuilder *builder, cstring tblName, TableKind tableKind, cstring keyType, cstring valueType, unsigned size) const =0
 
virtual void emitTableDeclSpinlock (Util::SourceCodeBuilder *builder, cstring tblName, TableKind tableKind, cstring keyType, cstring valueType, unsigned size) const
 
virtual void emitTableLookup (Util::SourceCodeBuilder *builder, cstring tblName, cstring key, cstring value) const =0
 
virtual void emitTableUpdate (Util::SourceCodeBuilder *builder, cstring tblName, cstring key, cstring value) const =0
 
virtual void emitTraceMessage (Util::SourceCodeBuilder *builder, const char *format) const
 
virtual void emitTraceMessage (Util::SourceCodeBuilder *builder, const char *format, int argc,...) const
 
virtual void emitUserTableUpdate (Util::SourceCodeBuilder *builder, cstring tblName, cstring key, cstring value) const =0
 
virtual cstring forwardReturnCode () const =0
 
virtual cstring packetDescriptorType () const =0
 
virtual cstring sysMapPath () const =0
 

Public Attributes

const cstring name
 

Protected Member Functions

 Target (cstring name)
 

Member Function Documentation

◆ emitMapInMapDecl()

virtual void P4::EBPF::Target::emitMapInMapDecl ( Util::SourceCodeBuilder * builder,
cstring innerName,
TableKind innerTableKind,
cstring innerKeyType,
cstring innerValueType,
unsigned innerSize,
cstring outerName,
TableKind outerTableKind,
cstring outerKeyType,
unsigned outerSize ) const
inlinevirtual

map-in-map requires declaration of both inner and outer map, thus we define them together in a single method.

Reimplemented in P4::EBPF::KernelSamplesTarget.

◆ emitTraceMessage()

void P4::EBPF::Target::emitTraceMessage ( Util::SourceCodeBuilder * builder,
const char * format,
int argc,
... ) const
virtual

Emit trace message which will be printed during packet processing (if enabled).

Parameters
builderActual source code builder.
formatFormat string, interpreted by printk-like function. For more information see documentation for bpf_trace_printk.
argcNumber of variadic arguments. Up to 3 arguments can be passed due to limitation of eBPF.
...Arguments to the format string, they must be C string and valid code in C.

To print variable value: emitTraceMessage(builder, "var=%u", 1, "var_name") To print expression value: emitTraceMessage(builder, "diff=%d", 1, "var1 - var2") To print just message: emitTraceMessage(builder, "Here")

Reimplemented in P4::EBPF::KernelSamplesTarget.