P4C
The P4 Compiler
Loading...
Searching...
No Matches
P4::EBPF::KernelSamplesTarget Class Reference

#include <target.h>

Inheritance diagram for P4::EBPF::KernelSamplesTarget:
[legend]

Public Member Functions

 KernelSamplesTarget (bool emitTrace=false, cstring name="Linux kernel"_cs)
 
cstring abortReturnCode () const override
 
void annotateTableWithBTF (Util::SourceCodeBuilder *builder, cstring name, cstring keyType, cstring valueType) const
 
cstring dataEnd (cstring base) const override
 
cstring dataLength (cstring base) const override
 
cstring dataOffset (cstring base) const override
 
cstring dropReturnCode () const override
 
void emitCodeSection (Util::SourceCodeBuilder *builder, cstring sectionName) const override
 
void emitIncludes (Util::SourceCodeBuilder *builder) const override
 
void emitLicense (Util::SourceCodeBuilder *builder, cstring license) const override
 
void emitMain (Util::SourceCodeBuilder *builder, cstring functionName, cstring argName) const override
 
void emitMapInMapDecl (Util::SourceCodeBuilder *builder, cstring innerName, TableKind innerTableKind, cstring innerKeyType, cstring innerValueType, unsigned innerSize, cstring outerName, TableKind outerTableKind, cstring outerKeyType, unsigned outerSize) const override
 
void emitPreamble (Util::SourceCodeBuilder *builder) const override
 
void emitResizeBuffer (Util::SourceCodeBuilder *builder, cstring buffer, cstring offsetVar) const override
 
void emitTableDecl (Util::SourceCodeBuilder *builder, cstring tblName, TableKind tableKind, cstring keyType, cstring valueType, unsigned size) const override
 
void emitTableDeclSpinlock (Util::SourceCodeBuilder *builder, cstring tblName, TableKind tableKind, cstring keyType, cstring valueType, unsigned size) const override
 
void emitTableLookup (Util::SourceCodeBuilder *builder, cstring tblName, cstring key, cstring value) const override
 
void emitTableUpdate (Util::SourceCodeBuilder *builder, cstring tblName, cstring key, cstring value) const override
 
void emitTraceMessage (Util::SourceCodeBuilder *builder, const char *format, int argc=0,...) const override
 
void emitUserTableUpdate (Util::SourceCodeBuilder *builder, cstring tblName, cstring key, cstring value) const override
 
cstring forwardReturnCode () const override
 
cstring packetDescriptorType () const override
 
cstring sysMapPath () const override
 
- Public Member Functions inherited from P4::EBPF::Target
virtual void emitTraceMessage (Util::SourceCodeBuilder *builder, const char *format) const
 

Protected Attributes

bool emitTraceMessages
 

Additional Inherited Members

- Public Attributes inherited from P4::EBPF::Target
const cstring name
 
- Protected Member Functions inherited from P4::EBPF::Target
 Target (cstring name)
 

Detailed Description

Represents a target that is compiled within the kernel. source tree samples folder and which attaches to a socket.

Member Function Documentation

◆ abortReturnCode()

cstring P4::EBPF::KernelSamplesTarget::abortReturnCode ( ) const
inlineoverridevirtual

Implements P4::EBPF::Target.

◆ dataEnd()

cstring P4::EBPF::KernelSamplesTarget::dataEnd ( cstring base) const
inlineoverridevirtual

Implements P4::EBPF::Target.

◆ dataLength()

cstring P4::EBPF::KernelSamplesTarget::dataLength ( cstring base) const
inlineoverridevirtual

Implements P4::EBPF::Target.

◆ dataOffset()

cstring P4::EBPF::KernelSamplesTarget::dataOffset ( cstring base) const
inlineoverridevirtual

Implements P4::EBPF::Target.

◆ dropReturnCode()

cstring P4::EBPF::KernelSamplesTarget::dropReturnCode ( ) const
inlineoverridevirtual

Implements P4::EBPF::Target.

◆ emitCodeSection()

void P4::EBPF::KernelSamplesTarget::emitCodeSection ( Util::SourceCodeBuilder * builder,
cstring sectionName ) const
overridevirtual

Implements P4::EBPF::Target.

◆ emitIncludes()

void P4::EBPF::KernelSamplesTarget::emitIncludes ( Util::SourceCodeBuilder * builder) const
overridevirtual

Implements P4::EBPF::Target.

◆ emitLicense()

void P4::EBPF::KernelSamplesTarget::emitLicense ( Util::SourceCodeBuilder * builder,
cstring license ) const
overridevirtual

Implements P4::EBPF::Target.

◆ emitMain()

void P4::EBPF::KernelSamplesTarget::emitMain ( Util::SourceCodeBuilder * builder,
cstring functionName,
cstring argName ) const
overridevirtual

Implements P4::EBPF::Target.

◆ emitMapInMapDecl()

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

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

Reimplemented from P4::EBPF::Target.

◆ emitPreamble()

void P4::EBPF::KernelSamplesTarget::emitPreamble ( Util::SourceCodeBuilder * builder) const
overridevirtual

Reimplemented from P4::EBPF::Target.

◆ emitResizeBuffer()

void P4::EBPF::KernelSamplesTarget::emitResizeBuffer ( Util::SourceCodeBuilder * builder,
cstring buffer,
cstring offsetVar ) const
overridevirtual

Implements P4::EBPF::Target.

◆ emitTableDecl()

void P4::EBPF::KernelSamplesTarget::emitTableDecl ( Util::SourceCodeBuilder * builder,
cstring tblName,
TableKind tableKind,
cstring keyType,
cstring valueType,
unsigned size ) const
overridevirtual

Implements P4::EBPF::Target.

◆ emitTableDeclSpinlock()

void P4::EBPF::KernelSamplesTarget::emitTableDeclSpinlock ( Util::SourceCodeBuilder * builder,
cstring tblName,
TableKind tableKind,
cstring keyType,
cstring valueType,
unsigned size ) const
overridevirtual

Reimplemented from P4::EBPF::Target.

◆ emitTableLookup()

void P4::EBPF::KernelSamplesTarget::emitTableLookup ( Util::SourceCodeBuilder * builder,
cstring tblName,
cstring key,
cstring value ) const
overridevirtual

Implements P4::EBPF::Target.

◆ emitTableUpdate()

void P4::EBPF::KernelSamplesTarget::emitTableUpdate ( Util::SourceCodeBuilder * builder,
cstring tblName,
cstring key,
cstring value ) const
overridevirtual

Implements P4::EBPF::Target.

◆ emitTraceMessage()

void P4::EBPF::KernelSamplesTarget::emitTraceMessage ( Util::SourceCodeBuilder * builder,
const char * format,
int argc = 0,
... ) const
overridevirtual

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 from P4::EBPF::Target.

◆ emitUserTableUpdate()

void P4::EBPF::KernelSamplesTarget::emitUserTableUpdate ( Util::SourceCodeBuilder * builder,
cstring tblName,
cstring key,
cstring value ) const
overridevirtual

Implements P4::EBPF::Target.

◆ forwardReturnCode()

cstring P4::EBPF::KernelSamplesTarget::forwardReturnCode ( ) const
inlineoverridevirtual

Implements P4::EBPF::Target.

◆ packetDescriptorType()

cstring P4::EBPF::KernelSamplesTarget::packetDescriptorType ( ) const
inlineoverridevirtual

Implements P4::EBPF::Target.

◆ sysMapPath()

cstring P4::EBPF::KernelSamplesTarget::sysMapPath ( ) const
inlineoverridevirtual

Implements P4::EBPF::Target.