P4C
The P4 Compiler
Loading...
Searching...
No Matches
BFN Namespace Reference

The namespace encapsulating Barefoot/Intel-specific stuff. More...

Classes

class  ActionArgSetup
 
class  ActionBodySetup
 
class  ActionFunctionSetup
 
struct  ActionProfile
 
struct  ActionSelector
 
class  ActionSynthesisPolicy
 
class  AddAdjustByteCount
 
class  AddHardwareConstrainedFields
 
class  AddIntrinsicMetadata
 
class  AddMetadataFields
 
struct  AddMetadataParserStates
 
class  AddPaddingFields
 
class  AddParserPad
 Add "padding" (additional states/extract fields) to parsers to meet minimum parse depth requirements. More...
 
struct  AddPsaBridgeMetadata
 
class  AddT2naMeta
 
struct  AddTnaBridgeMetadata
 
class  AdjustByteCountSetup
 
class  Alloc1D
 
class  Alloc1Dbase
 
class  Alloc2D
 
class  Alloc2Dbase
 
class  Alloc3D
 
class  Alloc3Dbase
 
class  AlpmImplementation
 Top level PassManager that governs the ALPM implementation. More...
 
struct  AncestorStates
 
class  AnnotateVarbitExtractStates
 
class  AnnotateWithInHash
 Top level PassManager that governs annotation of specific assignment statements with the @in_hash annotation. More...
 
class  ApplyEvaluator
 
class  Architecture
 
class  ArchTranslation
 PassManager that governs the normalization of variations in the architectures. More...
 
class  AsmOutput
 Generate assembly output. More...
 
struct  AssignmentStmtErrorCheck
 
struct  AssignOr
 
class  AttachTables
 
class  Backend
 
class  BackendConstantFolding
 
class  BackendConverter
 
class  BackendStrengthReduction
 
class  BFRuntimeArchHandlerCommon
 
class  BFRuntimeArchHandlerPSA
 
class  BFRuntimeArchHandlerTofino
 
struct  BlockInfo
 
struct  BridgedFieldInfo
 
class  CheckDesignPattern
 Top level PassManager that governs checking for design patterns. More...
 
class  CheckDirectExternsOnTables
 
class  CheckDirectResourceInvocation
 
class  CheckExternInvocationCommon
 
class  CheckExternValidity
 Checks if the emit function call is valid with the TNA constraints. More...
 
class  CheckHeaderAlignment
 
class  CheckPadAssignment
 
class  CheckPhaseZeroExtern
 
class  CheckRegisterActions
 PassManager that checks if the RegisterActions work on proper Registers. More...
 
class  CheckReservedNames
 
class  CheckT2NAExternInvocation
 
class  CheckTableConstEntries
 
class  CheckTNAExternInvocation
 
class  CheckUnimplementedFeatures
 
class  CheckUnsupported
 Check for unsupported features in the backend compiler. More...
 
class  CheckVarbitAccess
 Checks that varbit accesses in pipeline are valid. More...
 
class  CloneConstants
 
class  ClotResourcesLogging
 
class  CollectAlpmInfo
 
struct  CollectBridgedFields
 
class  CollectHardwareConstrainedFields
 
class  CollectIXBarInfo
 
class  CollectPhase0Annotation
 
class  CollectPipelines
 Inspector pass that collects information about all pipelines declared in the Switch. For given pipeline (given by its numeric id), it is possible to extract the pipeline components (e.g. parsers, deparsers and gress control for all gresses and possible ghost gress). More...
 
class  CollectVarbitExtract
 
struct  CollectVariables
 
class  CompileTimeOperations
 Pass that checks for operations that are defined at compile time (Div, Mod). More...
 
class  ControlFlowVisitor
 
class  ConvertMethodCalls
 
class  ConvertPhase0
 
class  ConvertPhase0AssignToExtract
 
class  ConvertSizeOfToConstant
 
class  CopyHeaders
 
struct  CounterExtern
 
struct  DebugInfo
 
class  DesugarVarbitExtract
 Top level PassManager that governs the rewrite of varbit usage. More...
 
class  DetectMultiplePipelines
 
struct  Digest
 The information about a digest instance which is needed to serialize it. More...
 
class  DoAnnotateWithInHash
 
class  DoInitializeMirrorIOSelect
 
class  DoRemoveActionParametersTofino
 
struct  DoRewriteControlAndParserBlocks
 
class  DropPacketWithMirrorEngine
 
class  DropPacketWithMirrorEngine_
 
class  DynamicHashJson
 
struct  DynHash
 The information about a hash instance which is needed to serialize it. More...
 
class  ElimCasts
 Top level PassManager that simplifies complex expression with multiple casts into simpler expression with at most one cast. More...
 
class  EliminateHeaders
 
class  EliminateTuples
 
class  EliminateWidthCasts
 
class  ElimParserValidZeroWrites
 Eliminate unnecessary parser zero-writes to validity bits. More...
 
struct  ElimUnusedMetadataStates
 
class  EnumOn32Bits
 Class that implements a policy suitable for the ConvertEnums pass. More...
 
struct  ErrorOnUnsupportedVarbitUse
 
class  ErrorType
 Barefoot specific error and warning types. More...
 
struct  EvaluateForVar
 
class  EvaluatorPass
 A modified version of P4::EvaluatorPass that uses BFN::TypeChecking. More...
 
struct  ExtractChecksum
 Pass that extracts checksums from deparser. More...
 
class  ExtractDeparser
 Transforms midend deparser IR::BFN::TnaDeparser into backend deparser IR::BFN::Deparser. More...
 
class  ExtractMetadata
 
class  ExtractParser
 Transforms midend parser IR::BFN::TnaParser into backend parser IR::BFN::Parser. More...
 
struct  FieldPacking
 
struct  FindArchitecture
 
struct  FindBridgeMetadataAssignment
 
class  FindDirectExterns
 
class  FindPaddingCandidate
 
class  FixP4Table
 
class  FixupMirrorMetadata
 
class  FixupResubmitMetadata
 
class  FlattenHeader
 Pass that flattened nested struct within a struct. More...
 
class  FoldConstantHashes
 PassManager that substitutes the calls of the get methods of the Hash externs whose inputs are constants with the resulting hash value. More...
 
struct  FrontEndPolicy
 
class  GatewayControlFlow
 
class  GenerateDynamicHashJson
 
class  GenerateTofinoProgram
 
class  GetBackendParser
 Converts frontend parser IR into backend IR. More...
 
class  GetBackendTables
 
struct  GetHeaderStackIndex
 
class  HasTableApply
 
struct  HeaderStackInfo
 Metadata about how header stacks are used in the program. More...
 
class  IdentifyPadRequirements
 Verify parse depth requirements and identify any "pad" required. More...
 
class  IdentifyPovMergeTargets
 Identify POV bits that can be merged. More...
 
class  IgnoreKeyElementTransform
 Auxiliary transformer to avoid processing IR::KeyElement nodes. More...
 
class  InitializeMirrorIOSelect
 Initializes eg_intr_md_for_dprsr.mirror_io_select on devices except Tofino1. More...
 
class  InjectTmpVar
 PassManager which controls injecting of temporary variables to be used instead of nested structures which need to be flattened by FlattenHeader pass. More...
 
class  InsertHashStructExpression
 
class  IsPhase0
 
class  IsSlice
 
class  IsSliceMask
 
class  KeyIsSimple
 
struct  LinearPath
 
class  LoweringType
 
struct  Lpf
 The information about a LPF instance which is needed to serialize it. More...
 
struct  Match
 
class  MergePovBits
 Merge POV bits where a single POV bit could be shared between multiple headers. More...
 
struct  MetadataField
 A helper struct used to construct the metadata remapping tables. More...
 
struct  MeterExtern
 
class  MidEnd
 
class  MidEndLast
 Final midend pass. More...
 
struct  MoveBridgeMetadataAssignment
 
struct  NormalizeNativeProgram
 
class  OptionalToTernaryMatchTypeConverter
 Pass that converts optional match type to ternary. More...
 
class  P4RuntimeStdConverter
 
class  PadFlexibleField
 
class  ParseAnnotations
 
class  ParserEnforceDepthReq
 Enforce parser min/max depth requirements. More...
 
struct  ParserLoopsInfo
 
struct  ParserPragmas
 
class  ParserResourcesLogging
 Class for generating JSON info with parser resources usage for visualization in P4I. More...
 
class  ParseTna
 
struct  PathLinearizer
 
class  PingPongGeneration
 PassManager that adds the ping pong mechanism for ghost thread. More...
 
struct  Pipeline
 
class  PortableSwitchTranslation
 PassManager that governs normalization of PSA architecture. More...
 
struct  PortMetadata
 
class  Pragma
 
class  ProcessBackendPipe
 must be applied to IR::BFN::Pipe More...
 
class  ProcessParde
 
class  ProgramPipelines
 
struct  ProgramStructure
 
struct  PSAArchHandlerBuilder
 The architecture handler builder implementation for PSA. More...
 
struct  PsaBridgeIngressToEgress
 
struct  Register
 The information about a register instance which is needed to serialize it. More...
 
struct  RegisterParam
 The information about a register parameter instance which is needed to serialize it. More...
 
class  RegisterReadWrite
 The pass replaces the Register.read/write() calls with register actions. More...
 
class  RemoveActionParameters
 Top level PassManager that governs moving of action parameters out of the actions (specialized for BFN). More...
 
struct  RemoveExternMethodCallsExcludedByAnnotation
 
class  RemoveSelectBooleans
 
struct  RemoveSetMetadata
 
struct  RemoveZeroVarbitExtract
 
class  RenameP4StartState
 
struct  ResetHeaderStackIndex
 
struct  ResolveHeaderStackIndex
 
class  ResolveSizeOfOperator
 
class  ResourcesLogging
 Class for generating resources.json logfile. More...
 
struct  RestoreParams
 
class  RewriteActionNames
 
class  RewriteActionSelector
 
class  RewriteCastToReinterpretCast
 Pass that converts some of the IR::Casts to ReinterpretCasts. More...
 
class  RewriteConcatToSlices
 Pass that replaces concat ++ operations with multiple operations on slices in the contexts. More...
 
struct  RewriteControlAndParserBlocks
 
class  RewriteFlexibleStruct
 Top level PassManager that governs moving of flexible annotation from structure to its fields. More...
 
struct  RewriteHeader
 
struct  RewriteParserChecksums
 
struct  RewriteParserStatements
 Rewrites frontend parser IR statements to the backend ones. More...
 
class  RewriteParserVerify
 
struct  RewritePathToStartState
 
class  RewriteTypeArguments
 
class  RewriteVarbitTypes
 
class  RewriteVarbitUses
 
class  SaveHashListExpression
 
class  SearchAndReplaceExpr
 
class  SetDefaultSize
 Pass that sets default table size to 512 entries. More...
 
class  SetupActionProperties
 
class  SimpleSwitchTranslation
 PassManager that governs normalization of v1model architecture. More...
 
class  SimplifyEmitArgs
 Top level PassManager that governs simplification of headers and emits. More...
 
class  SimplifyNestedCasts
 Pass that removes nested casts when applicable. More...
 
class  SimplifyOperationBinary
 Pass that moves the cast on binary operation to each operand. More...
 
class  SimplifyRedundantCasts
 Pass that removes some of the redundant casts. More...
 
class  SnapshotFieldFinder
 
class  SnapshotFieldIdTable
 
struct  SnapshotFieldInfo
 
class  SplitAlpm
 Pass that splits ALPM table into pre-classifier TCAM and TCAM. More...
 
class  StrengthReduction
 
class  SymbolType
 Extends P4RuntimeSymbolType for the Tofino extern types. More...
 
struct  T2naArchTranslation
 PassManager that governs normalization of T2NA architecture. More...
 
struct  TnaArchTranslation
 PassManager that governs normalization of TNA architecture. More...
 
struct  TofinoArchHandlerBuilder
 The architecture handler builder implementation for Tofino. More...
 
class  TransformResubmitHeaders
 
struct  TranslatePhase0
 
class  TranslationFirst
 
class  TranslationLast
 
class  TypeChecking
 A TypeChecking pass in BFN namespace that uses the extended TypeInference pass. This should be used in our midend. More...
 
class  TypeInference
 Extended type inference pass from p4c used in barefoot's midend. More...
 
class  UpdatePhase0Header
 
class  UpdatePhase0NodeInParser
 
class  UpdatePovBits
 Merge POV bits. More...
 
struct  ValueSet
 The information about a value set instance which is needed to serialize it. More...
 
struct  Wred
 The information about a Wred instance which is needed to serialize it. More...
 

Typedefs

typedef std::map< const IR::P4Action *, std::vector< const P4::ExternMethod * > > ActionExterns
 
typedef std::unordered_map< const IR::Declaration *, std::unordered_set< const IR::Declaration * > > ActionsByRegister
 
using BitOffsetMap = std::unordered_map<const IR::MethodCallExpression *, unsigned>
 
using BlockInfoMapping = std::multimap<const IR::Node *, BlockInfo>
 
using ChecksumInstrMap = std::unordered_map<cstring, const IR::MethodCallExpression *>
 
using ChecksumOffsetMap = std::unordered_map<cstring, std::unordered_map<cstring, int>>
 
using ChecksumSourceMap = ordered_map<const IR::Member *, const IR::MethodCallExpression *>
 
typedef assoc::map< const IR::Declaration_Instance *, const IR::MAU::AttachedMemory * > DeclarationConversions
 
using DefaultPortMap = std::map<int, std::vector<int>>
 
using ExtractedFieldsMap = ordered_map<const IR::Member *, const IR::BFN::PacketRVal *>
 
using FieldListId = std::tuple<gress_t, unsigned, cstring>
 
using FieldRef = std::pair<cstring, cstring>
 
using HeaderToPad = std::unordered_set<cstring>
 
using HeaderTypeMap = ordered_map<cstring, const IR::Type_Header *>
 
using MetadataMap = ordered_map<cstring, IR::MetadataInfo *>
 
using MirroredFieldList = IR::Vector<IR::Expression>
 
using MirroredFieldLists = std::map<FieldListId, const MirroredFieldList *>
 
using NodeNameMap = ordered_map<const IR::Node *, cstring>
 
using Phase0AnnotMap = std::map<cstring, cstring>
 
typedef std::map< const IR::BFN::TnaParser *, const IR::Type_StructLike * > Phase0CallMap
 
typedef std::unordered_map< const IR::P4Control *, ordered_set< IR::Declaration_Instance * > > RegisterActionsByControl
 
typedef std::unordered_map< const IR::Declaration *, std::unordered_map< const IR::Declaration_Instance *, ordered_set< const IR::Statement * > > > RegisterCallsByAction
 
typedef std::unordered_map< const IR::Declaration *, std::unordered_map< const IR::Declaration_Instance *, IR::MethodCallExpression * > > RegisterExecuteCallByAction
 
using ResubmitExtracts = std::map<unsigned, std::pair<cstring, const ResubmitSources *>>
 
using ResubmitHeaders = std::unordered_set<cstring>
 
using ResubmitSources = IR::Vector<IR::Expression>
 
using SimpleNameMap = std::map<cstring, cstring>
 
typedef assoc::map< const IR::Declaration_Instance *, const IR::MAU::Selector * > StatefulSelectors
 
using TranslationMap = ordered_map<const IR::Node *, const IR::Node *>
 

Enumerations

enum class  Arch { TNA , PSA }
 
enum  ArchBlock_t { PARSER = 0 , MAU , DEPARSER , BLOCK_TYPE }
 

Functions

void add_param (ordered_map< cstring, cstring > &tnaParams, const IR::ParameterList *params, IR::ParameterList *newParams, cstring hdr, size_t index, cstring hdr_type=""_cs, IR::Direction dir=IR::Direction::None)
 
const IR::ParserState * addNewStartState (cstring name, cstring nextState)
 
void addNewStartState (IR::P4Parser *parser, cstring name, cstring nextState)
 
void check_compile_time_constant (const IR::Constant *c, const IR::MethodCallExpression *call, int varbit_field_size, bool zero_ok=false)
 
void collect_diagnostic_checks (BfErrorReporter &reporter, BFN_Options &options)
 Collects error/warning checks from the program.
 
std::vector< const IR::Expression * > convertConcatToList (const IR::Concat *expr)
 
void convertConcatToList (std::vector< const IR::Expression * > &slices, const IR::Concat *expr)
 
const IR::ParserState * convertStartStateToNormalState (const IR::ParserState *state, cstring newName)
 
const IR::ParserState * convertStartStateToNormalState (IR::P4Parser *parser, cstring newName)
 
P4::P4RuntimeAPI convertToStdP4Runtime (const P4::P4RuntimeAPI &p4RuntimeIn)
 
IR::Member * create_member (cstring hdr, cstring member)
 
IR::AssignmentStatement * create_valid_statement (const IR::Type_Header *hdr, const IR::Expression *path, bool value)
 
const IR::Statement * createAdvanceCall (cstring pkt, int bits)
 
const IR::Statement * createExtractCall (cstring pkt, cstring type, cstring hdr)
 
const IR::Statement * createExtractCall (cstring pkt, cstring typeName, IR::Expression *member)
 
const IR::Statement * createExtractCall (cstring pkt, IR::Expression *member)
 
const IR::ParserState * createGeneratedParserState (cstring name, IR::IndexedVector< IR::StatOrDecl > &&statements, const IR::Expression *selectExpression)
 
const IR::ParserState * createGeneratedParserState (cstring name, IR::IndexedVector< IR::StatOrDecl > &&statements, cstring nextState)
 
const IR::Expression * createLookaheadExpr (cstring pkt, int bits)
 
const IR::SelectCase * createSelectCase (unsigned bitWidth, unsigned value, unsigned mask, const IR::ParserState *nextState)
 
const IR::Statement * createSetMetadata (const IR::Expression *dest, cstring header, cstring field)
 
const IR::Statement * createSetMetadata (cstring header, cstring field, int bitWidth, int constant)
 
const IR::Statement * createSetMetadata (cstring param, cstring header, cstring field, int bitWidth, int constant)
 
const IR::Statement * createSetValid (const Util::SourceInfo &si, cstring header, cstring field)
 
const IR::BFN::Pipe * extract_maupipe (const IR::P4Program *, BFN_Options &options)
 
IR::BFN::Pipe * extractChecksumFromDeparser (const IR::BFN::TnaDeparser *deparser, IR::BFN::Pipe *pipe)
 
template<class T >
const T * findContext (const Visitor::Context *c)
 
void force_link_dump (const IR::Node *n)
 
void generateRuntime (const IR::P4Program *program, const BFN_Options &options)
 
const IR::StructField * get_varbit_structfield (const IR::Member *member)
 
AssignOr getAssignOr (const IR::Expression *lhs, const IR::Expression *rhs)
 
const IR::Type * getBaseType (const IR::Type *type)
 
const IR::Parameter * getContainingParameter (const LinearPath &path, P4::ReferenceMap *refMap)
 
const IR::Declaration_Instance * getDeclInst (const P4::ReferenceMap *refMap, const IR::PathExpression *path)
 
cstring getDefaultPhase0TableKeyName ()
 
std::optional< const IR::ExpressionValue * > getExpressionFromProperty (const IR::P4Table *table, const cstring &propertyName)
 
std::optional< P4::ExternInstancegetExternInstanceFromProperty (const IR::P4Table *table, cstring propertyName, P4::ReferenceMap *refMap, P4::TypeMap *typeMap)
 
std::optional< P4::ExternInstancegetExternInstanceFromPropertyByTypeName (const IR::P4Table *table, cstring propertyName, cstring externTypeName, P4::ReferenceMap *refMap, P4::TypeMap *typeMap, bool *isConstructedInPlace)
 
std::optional< cstringgetExternTypeName (const P4::ExternMethod *extMethod)
 
cstring getTypeName (const IR::Type *type)
 
bool hasAtcamPragma (const IR::P4Table *const table_ptr)
 
bool isCompilerGeneratedType (const IR::Type *type)
 
bool isEgressIntrinsicHeader (const IR::Type *type)
 
bool isHeaderReference (const LinearPath &path, P4::TypeMap *typeMap)
 
bool isHeaderType (const IR::Type *type)
 
bool isIntrinsicMetadataType (const IR::Type *type)
 
bool isMetadataReference (const LinearPath &path, P4::TypeMap *typeMap)
 
bool isMetadataType (const IR::Type *type)
 
bool isPrimitiveFieldReference (const LinearPath &path, P4::TypeMap *typeMap)
 
bool isPrimitiveReference (const LinearPath &path, P4::TypeMap *typeMap)
 
bool isPrimitiveType (const IR::Type *type)
 
bool isSubobjectOfParameter (const LinearPath &path, P4::ReferenceMap *refMap)
 
std::optional< nw_bitrangelookaheadToExtractRange (P4::TypeMap *typeMap, const IR::Expression *expr, int currentBit, bool *partial_hdr_err_proc)
 
std::ostream & operator<< (std::ostream &out, const BFN::MetadataField &m)
 
std::ostream & operator<< (std::ostream &out, const DynamicHashJson &dyn)
 
const IR::BFN::PacketRVal * resolveLookahead (P4::TypeMap *typeMap, const IR::Expression *expr, int currentBit)
 
bool skipFlexibleHeader (const Visitor::Context *, const IR::Type_StructLike *e)
 
bool skipRegisterActionOutput (const Visitor::Context *ctxt, const IR::Expression *)
 
const IR::Expression * stripReinterpret (const IR::Expression *rhs)
 
 TEST (BFNTypeCategories, Types)
 
 TEST (TofinoFieldPacking, CreateExtractionState)
 
 TEST (TofinoFieldPacking, EmptyPackingAlignment)
 
 TEST (TofinoFieldPacking, FieldAlignment)
 
 TEST (TofinoFieldPacking, Fields)
 
 TEST (TofinoFieldPacking, ForEachField)
 
 TEST (TofinoFieldPacking, LargePhase)
 
 TEST (TofinoFieldPacking, Padding)
 
 TEST (TofinoFieldPacking, PaddingAlignment)
 
 TEST (TofinoFieldPacking, ZeroAlignment)
 
 TEST (TofinoFieldPacking, ZeroPadding)
 
 TEST (TofinoPathLinearizer, HeaderStackIndexing)
 
 TEST (TofinoPathLinearizer, MemberExpression)
 
 TEST (TofinoPathLinearizer, NestedMemberExpressions)
 
 TEST (TofinoPathLinearizer, PathExpression)
 
 TEST (TofinoPathLinearizer, RejectNonPathlikeExpressions)
 
 TEST (TofinoPathLinearizer, RejectUnexpectedExpressions)
 
std::string to_lower (std::smatch::const_reference it)
 

Variables

unsigned algoHandle = 0x0
 
unsigned dynHashHandle = 0x0
 
const cstring ExternDynamicHashString = "hash"_cs
 
const cstring ExternPortMetadataUnpackString = "port_metadata_unpack"_cs
 
unsigned fieldListHandle = 0x0
 

Detailed Description

The namespace encapsulating Barefoot/Intel-specific stuff.

Copyright (C) 2024 Intel Corporation

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

SPDX-License-Identifier: Apache-2.0

Copyright (C) 2024 Intel Corporation

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

SPDX-License-Identifier: Apache-2.0 Collect pipelines form program.

Copyright (C) 2024 Intel Corporation

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

SPDX-License-Identifier: Apache-2.0 Detects multiple pipelines in a program

Copyright (C) 2024 Intel Corporation

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

SPDX-License-Identifier: Apache-2.0 Detects program with multiple pipelines.

Copyright (C) 2024 Intel Corporation

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

SPDX-License-Identifier: Apache-2.0 Impact for Large Packets Dropped at Ingress Deparser Description: If the ingress deparser drops a packet it is possible that no learning digest will be generated, and that ingress MAU byte counters and meters are credited with a byte count less than the actual size of the packet. This may happen if the entire packet is not received before the ingress deparser processes it. The exact packet sizes at which this may occur depend on the latency of the ingress pipeline but are on the order of larger than about 7600 bytes for a 400g interface or about 2200 bytes for a 100g interface. Workaround: Do not drop packets at the ingress deparser, instead mirror them to a disabled mirroring session to drop them by the mirror block. This fix applies to Tofino 1 and 2.

Copyright (C) 2024 Intel Corporation

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

SPDX-License-Identifier: Apache-2.0 Detects registers that are used by ingress and ghost, creates a duplicate tables and registers if needed and attaches a ping-pong mechanism onto them.

This file contains implementation of different methods, refer to the header file for more abstract overview to determine what each method should do and is used for.


Class Documentation

◆ BFN::BridgedFieldInfo

struct BFN::BridgedFieldInfo
Class Members
const Expression * refTemplate
const Type * type

◆ BFN::CounterExtern

struct BFN::CounterExtern
template<Arch arch>
struct BFN::CounterExtern< arch >

◆ BFN::Digest

struct BFN::Digest

The information about a digest instance which is needed to serialize it.

Class Members
const IAnnotated * annotations
const cstring name
const P4DataTypeSpec * typeSpec

◆ BFN::DynHash

struct BFN::DynHash

The information about a hash instance which is needed to serialize it.

Class Members
const IAnnotated * annotations
vector< hashField > hashFieldInfo
const int hashWidth
const cstring name
const P4DataTypeSpec * typeSpec

◆ BFN::Match

struct BFN::Match
Class Members
unsigned mask = 0
unsigned value = 0

◆ BFN::MeterExtern

struct BFN::MeterExtern
template<Arch arch>
struct BFN::MeterExtern< arch >

Typedef Documentation

◆ DeclarationConversions

typedef assoc::map<const IR::Declaration_Instance *, const IR::MAU::AttachedMemory *> BFN::DeclarationConversions

The purpose of this code is to translate in each pipeline to Backend structures. At the top of each pipeline, each extern to be used by that pipeline is declared.

At the moment, we only resolve Declaration Instances to create BackendAttached tables. This may need to extend to other features at somepoint, for example Checksums, or other potential parser externs.

Furthermore, there is not always a one-to-one map of Declaration_Instance to BackendAttached table. The two currently known and handled cases are:

  1. An action profile and a action selector share a Declaration_Instance
  2. A stateful selector will also share an instance with an action profile or action selector

These two special cases are handled individually in the code, rather than having a total map for the entire gress. Depending on how complicated cases get, this may have to expanded at somepoint.

Enumeration Type Documentation

◆ Arch

enum class BFN::Arch
strong

We re-use as much code as possible between PSA and TNA. The two architectures have some differences though, in particular regarding naming (of table properties, extern types, parameter names). We define some "traits" for each extern type, templatized by the architecture name (using the Arch enum class defined below), as a convenient way to access architecture-specific names in the unified code.

Function Documentation

◆ addNewStartState()

void BFN::addNewStartState ( IR::P4Parser * parser,
cstring name,
cstring nextState )

Add a new start state to the given parser, with a potentially non-'start' name applied via an @name annotation.

◆ collect_diagnostic_checks()

void BFN::collect_diagnostic_checks ( BfErrorReporter & reporter,
BFN_Options & options )

Collects error/warning checks from the program.

Checks are added by comments containing expect error@OFFSET: "REGEXP" and expect warning@OFFSET: "REGEXP".

OFFSET is the difference between the source line that the comment is on and the line that the compiler is expected to report the error/warning on. It can be omitted together with the '@', in which case it is set to 0, meaning the error/warning is expected on the same line. In case the error/warning has no source line reported, the text NO SOURCE should be written in place of OFFSET, which makes the check not require any source line.

REGEXP is the regular expression for the expected error/warning message.

The expected error/warning messages are EMCAScript regular expressions that messages reported during compilation will be matched against. If the source line number is required, the repored message has to include it. If the reported message has multiple locations, the specified source line can be any of them.

If there is at least one error check in the program, the compiler will return a success return code (0) if each reported error has been matched with one error check and there are no unmatched error checks left at the end of the compilation, otherwise the compiler will report a failure. Warnings are less strict and will cause a failure only if there are unmatched warning checks left at the end of the compilation, but there can be other warnings that are not listed in checks.

Example checks:

  • Check that requires the same source location as the comment: // expect error: "The action increment indexes .* with .* but it also indexes .* with .*\."
  • Check that requires the preceding line as the source location: // expect warning-1: "field list cannot be empty"
  • Check that doesn't require a source location: // expect error@NO SOURCE: "0, "PHV allocation failed"

◆ convertStartStateToNormalState()

const IR::ParserState * BFN::convertStartStateToNormalState ( IR::P4Parser * parser,
cstring newName )

Rename the start state of the given parser and return it. This will leave the parser without a start state, so the caller must create a new one.

◆ convertToStdP4Runtime()

P4::P4RuntimeAPI BFN::convertToStdP4Runtime ( const P4::P4RuntimeAPI & p4RuntimeInput)

Takes a P4Info message generated for a TNA-specific architecture and converts it to a "standard" P4Info message, which can be used with a standard P4Runtime implementation (with no support for TNA-specific extensions). Displays a warning to the user for each extern instance that cannot be converted.

◆ createAdvanceCall()

const IR::Statement * BFN::createAdvanceCall ( cstring pkt,
int bits )
Returns
an advance() call that advances by the given number of bits.

◆ createExtractCall() [1/3]

const IR::Statement * BFN::createExtractCall ( cstring pkt,
cstring type,
cstring hdr )
Returns
an extract() call that extracts the given header.

◆ createExtractCall() [2/3]

const IR::Statement * BFN::createExtractCall ( cstring pkt,
cstring typeName,
IR::Expression * member )
Returns
an extract() call that extracts the given header.

◆ createExtractCall() [3/3]

const IR::Statement * BFN::createExtractCall ( cstring pkt,
IR::Expression * member )
Returns
an extract() call that extracts the given header.

◆ createGeneratedParserState()

const IR::ParserState * BFN::createGeneratedParserState ( cstring name,
IR::IndexedVector< IR::StatOrDecl > && statements,
const IR::Expression * selectExpression )
Returns
a parser state with a name that's distinct from the states in the P4 program and an @name annotation with a '$' prefix. Downstream, we search for certain '$' states and replace them with more generated parser code.

◆ createLookaheadExpr()

const IR::Expression * BFN::createLookaheadExpr ( cstring pkt,
int bits )
Returns
a lookahead expression for the given size of bit<> type.

◆ createSelectCase()

const IR::SelectCase * BFN::createSelectCase ( unsigned bitWidth,
unsigned value,
unsigned mask,
const IR::ParserState * nextState )
Returns
a SelectCase that checks for a constant value with some mask applied.

◆ createSetMetadata() [1/3]

const IR::Statement * BFN::createSetMetadata ( const IR::Expression * dest,
cstring header,
cstring field )
Returns
an assignment statement of the form dest = header.field.

◆ createSetMetadata() [2/3]

const IR::Statement * BFN::createSetMetadata ( cstring header,
cstring field,
int bitWidth,
int constant )
Returns
an assignment statement of the form header.field = constant.

◆ createSetMetadata() [3/3]

const IR::Statement * BFN::createSetMetadata ( cstring param,
cstring header,
cstring field,
int bitWidth,
int constant )
Returns
an assignment statement of the form param.header.field = constant.

◆ createSetValid()

const IR::Statement * BFN::createSetValid ( const Util::SourceInfo & si,
cstring header,
cstring field )
Returns
an assignment statement of the form header.setValid().

◆ generateRuntime()

void BFN::generateRuntime ( const IR::P4Program * program,
const BFN_Options & options )

A convenience wrapper for P4::generateP4Runtime(). This must be called before the translation pass and will generate the correct P4Info message based on the original architecture (v1model, PSA, TNA or JNA).

◆ getContainingParameter()

const IR::Parameter * BFN::getContainingParameter ( const LinearPath & path,
P4::ReferenceMap * refMap )
Returns
the parameter which transitively contains this object if isSubobjectOfParameter() would return true, or nullptr otherwise.

◆ getDeclInst()

const IR::Declaration_Instance * BFN::getDeclInst ( const P4::ReferenceMap * refMap,
const IR::PathExpression * path )

Auxiliary function to get a declaration instance based on a path expression from a reference map.

Parameters
[in]refMapReference map
[in]pathThe path expression
Returns
Returns the declaration if exists, nullptr otherwise.

◆ getExternInstanceFromProperty()

std::optional< P4::ExternInstance > BFN::getExternInstanceFromProperty ( const IR::P4Table * table,
cstring propertyName,
P4::ReferenceMap * refMap,
P4::TypeMap * typeMap )

Helper functions to extract extern instance from table properties. Originally implemented in as part of the control-plane repo.

Returns
an extern instance defined or referenced by the value of table's propertyName property, or std::nullopt if no extern was referenced.

◆ getExternInstanceFromPropertyByTypeName()

std::optional< P4::ExternInstance > BFN::getExternInstanceFromPropertyByTypeName ( const IR::P4Table * table,
cstring propertyName,
cstring externTypeName,
P4::ReferenceMap * refMap,
P4::TypeMap * typeMap,
bool * isConstructedInPlace )

Helper functions to handle list of extern instances from table properties.

◆ isCompilerGeneratedType()

bool BFN::isCompilerGeneratedType ( const IR::Type * type)
Returns
true if the provided type has the @__compiler_generated annotation; the compiler tags types it generates with this annotation.

◆ isHeaderReference()

bool BFN::isHeaderReference ( const LinearPath & path,
P4::TypeMap * typeMap )
Returns
true if the provided LinearPath refers to a header - that is, if it refers to one of:
  • an object of header type (i.e., isHeaderType() returns true; see that function for the full criteria), or
  • a field of primitive type on such an object.

◆ isHeaderType()

bool BFN::isHeaderType ( const IR::Type * type)
Returns
true if the provided type is logically a header type - that is, if it's a header type for which isMetadataType() returns false.

◆ isIntrinsicMetadataType()

bool BFN::isIntrinsicMetadataType ( const IR::Type * type)
Returns
true if the provided type has the @__intrinsic_metadata annotation; the architecture tags types with this annotation if they're intrinsic metadata.

◆ isMetadataReference()

bool BFN::isMetadataReference ( const LinearPath & path,
P4::TypeMap * typeMap )
Returns
true if the provided LinearPath refers to metadata - that is, if it refers to one of:
  • an object of metadata type (i.e., isMetadataType() returns true; see that function for the full criteria), or
  • a field of primitive type on such an object.

◆ isMetadataType()

bool BFN::isMetadataType ( const IR::Type * type)
Returns
true if the provided type is logically a metadata type - that is, if it's:
  • a struct type, or
  • a non-struct type with the annotation @__intrinsic_metadata. The second case is required for TNA, which represents some types which are logically metadata as headers.

◆ isPrimitiveFieldReference()

bool BFN::isPrimitiveFieldReference ( const LinearPath & path,
P4::TypeMap * typeMap )
Returns
true if the provided LinearPath refers to a field of primitive type on some structlike object.

◆ isPrimitiveReference()

bool BFN::isPrimitiveReference ( const LinearPath & path,
P4::TypeMap * typeMap )
Returns
true if the provided LinearPath refers to an object of primitive type - that is, if it refers to one of:
  • a simple object of primitive type, or
  • a field of primitive type on some structlike object.

◆ isPrimitiveType()

bool BFN::isPrimitiveType ( const IR::Type * type)
Returns
true if the provided type is a primitive type, which for the purposes of this function is defined as:
  • a bit<> type, or
  • a Type_InfInt (i.e., a numeric constant of indeterminate width), or
  • a boolean type.

◆ isSubobjectOfParameter()

bool BFN::isSubobjectOfParameter ( const LinearPath & path,
P4::ReferenceMap * refMap )
Returns
true if the provided LinearPath refers to an object which is a subobject of a parameter - that is, if it refers to one of:
  • a parameter directly, or
  • an object which is transitively a subobject of a parameter.

◆ lookaheadToExtractRange()

std::optional< nw_bitrange > BFN::lookaheadToExtractRange ( P4::TypeMap * typeMap,
const IR::Expression * expr,
int currentBit,
bool * partial_hdr_err_proc )

Rewrite an expression that is a lookahead or a member of a lookahead value (inc. slices and stack-parts of lookaheads) to a tuple (type of the extracted expression, corresponding range of bits to be extracted from packet). If the input is not such an expression the result will contain nullptr as the first member of the tuple.