P4C
The P4 Compiler
Loading...
Searching...
No Matches
P4::P4Tools::P4Testgen::Bmv2 Namespace Reference

Inja. More...

Classes

class  AssertsParser
 
class  Bmv2Concolic
 
class  BMv2Constants
 
class  Bmv2TestBackend
 
class  Bmv2TestFramework
 Bmv2TestFramework provides common utility functions for BMv2-style test frameworks. More...
 
class  Bmv2V1ModelActionProfile
 
class  Bmv2V1ModelActionSelector
 
class  Bmv2V1ModelCloneInfo
 
class  Bmv2V1ModelCloneSpec
 
class  Bmv2V1ModelCmdStepper
 
class  BMv2V1ModelCompilerResult
 Extends the CompilerResult with information specific to the V1Model running on BMv2. More...
 
class  Bmv2V1ModelExprStepper
 
class  Bmv2V1ModelMeterValue
 
class  Bmv2V1ModelProgramInfo
 
class  Bmv2V1ModelRegisterValue
 
class  Bmv2V1ModelTableStepper
 
class  Bmv2V1ModelTestgenTarget
 
class  IndexExpression
 
class  IndexMap
 Readable and writable symbolic map, which maps indices to particular values. More...
 
class  Lexer
 
class  MapDirectExterns
 
class  Metadata
 Extracts information from the @testSpec to emit a Metadata test case. More...
 
class  MetadataCollection
 
class  Optional
 
class  PropagateP4RuntimeTranslation
 
class  Protobuf
 Extracts information from the @testSpec to emit a Protobuf test case. More...
 
class  ProtobufIr
 Extracts information from the @testSpec to emit a Protobuf IR test case. More...
 
struct  ProtobufIrTest
 
struct  ProtobufTest
 
class  PTF
 Extracts information from the @testSpec to emit a PTF test case. More...
 
class  Range
 
class  RefersToParser
 
class  STF
 Extracts information from the @testSpec to emit a STF test case. More...
 
class  Token
 

Typedefs

using DirectExternMap = std::map<cstring, const IR::P4Table *>
 
using IdenitifierTypeMap = std::map<cstring, const IR::Type *>
 

Enumerations

enum  bmv2_gress_t { BMV2_INGRESS , BMV2_EGRESS }
 
enum class  Bmv2HashAlgorithm {
  crc32 , crc32_custom , crc16 , crc16_custom ,
  random , identity , csum16 , xor16
}
 

Functions

std::vector< TokencombineTokensToNames (const std::vector< Token > &inputVector)
 
std::vector< TokencombineTokensToNumbers (std::vector< Token > input)
 
std::vector< TokencombineTokensToTableKeys (std::vector< Token > input, cstring tableName)
 
std::pair< std::vector< Token >, size_t > findRightPart (std::vector< Token > tokens, size_t index)
 
const IR::Expression * getIR (std::vector< Token > tokens, const IdenitifierTypeMap &typeMap)
 
bool isSpace (char c) noexcept
 
const IR::Expression * makeConstant (Token input, const IdenitifierTypeMap &typeMap, const IR::Type *leftType)
 Determines the token type according to the table key and generates a symbolic variable for it.
 
const IR::Expression * makeSingleExpr (std::vector< const IR::Expression * > input)
 
std::ostream & operator<< (std::ostream &os, Bmv2HashAlgorithm algo)
 
std::ostream & operator<< (std::ostream &os, const Token::Kind &kind)
 
const IR::Expression * pickBinaryExpr (const Token &token, const IR::Expression *leftL, const IR::Expression *rightL)
 Chose a binary expression that correlates to the token kind.
 
std::vector< TokenremoveComments (const std::vector< Token > &input)
 

Detailed Description

Inja.

Typedef Documentation

◆ DirectExternMap

using P4::P4Tools::P4Testgen::Bmv2::DirectExternMap = std::map<cstring, const IR::P4Table *>

A mapping of the control plane name of extern declarations which are associated with a table. Such an extern is referred to as direct extern. There can only be one extern associated with a table in BMv2. We are using the cstring name and not an IR::Declaration pointer for the mapping because other passes may clone or transform the IR::Declaration node, invalidating this mapping.

◆ IdenitifierTypeMap

using P4::P4Tools::P4Testgen::Bmv2::IdenitifierTypeMap = std::map<cstring, const IR::Type *>

Maps control plane identifiers to their corresponding IR type. Once we have resolved the tokens in the annotation, we can then lookup the corresponding type.

Function Documentation

◆ combineTokensToNames()

std::vector< Token > P4::P4Tools::P4Testgen::Bmv2::combineTokensToNames ( const std::vector< Token > & inputVector)

Combines successive tokens into variable names. Returns a vector with tokens combined into names. For example, at the input we have a vector of tokens: [a(Text),c(Text),b(text), +(Plus), 1(Number),2(number)] The result will be [acb(Text), +(Plus), 1(Number),2(number)]

◆ combineTokensToNumbers()

std::vector< Token > P4::P4Tools::P4Testgen::Bmv2::combineTokensToNumbers ( std::vector< Token > input)

Combines successive tokens into numbers. For converting boolean or Hex, Octal values to numbers we must first use combineTokensToNames. Returns a vector with tokens combined into numbers. For example, at the input we have a vector of tokens: [a(Text),c(Text),b(text), +(Plus), 1(Number),2(number)] The result will be [a(Text),c(Text),b(text), +(Plus), 12(number)] Other examples : [acb(text), ||(Disjunction), true(text)] -> [acb(text), ||(Disjunction), 1(number)] - This example is possible only after executing combineTokensToNames, since to convert bool values, they must first be collected from text tokens in the combineTokensToNames function [2(Number), 5(number), 5(number), ==(Equal), 0xff(Text)] -> [255(number), ==(Equal), 0xff(Number)] - This example is possible only after executing combineTokensToNames

◆ combineTokensToTableKeys()

std::vector< Token > P4::P4Tools::P4Testgen::Bmv2::combineTokensToTableKeys ( std::vector< Token > input,
cstring tableName )

Convert access tokens or keys into table keys. For converting access tokens or keys to table keys we must first use combineTokensToNames. Returns a vector with tokens converted into table keys. For example, at the input we have a vector of tokens: [key::mask(Text), ==(Equal) , 0(Number)] The result will be [tableName_mask_key(Text), ==(Equal) , 0(Number)] Other examples : [key::prefix_length(Text), ==(Equal) , 0(Number)] -> [tableName_lpm_prefix_key(Text), ==(Equal) , 0(Number)] [key::priority(Text), ==(Equal) , 0(Number)] -> [tableName_priority_key(Text), ==(Equal) , 0(Number)] [Name01(Text), ==(Equal) , 0(Number)] -> [tableName_key_Name01(Text), ==(Equal) , 0(Number)]

◆ findRightPart()

std::pair< std::vector< Token >, size_t > P4::P4Tools::P4Testgen::Bmv2::findRightPart ( std::vector< Token > tokens,
size_t index )

Determines the right side of the expression starting from the original position and returns a slice of tokens related to the right side and the index of the end of the right side. Returning the end index is necessary so that after moving from the end of the right side

◆ getIR()

const IR::Expression * P4::P4Tools::P4Testgen::Bmv2::getIR ( std::vector< Token > tokens,
const IdenitifierTypeMap & typeMap )

Converts a vector of tokens into a single IR:Expression For example, at the input we have a vector of tokens: [key1(Text), ->(Implication), key2(Text), &&(Conjunction), key3(Text)] The result will be an IR::Expression equal to !IRExpression || (IR::Expression && IR::Expression)

◆ makeSingleExpr()

const IR::Expression * P4::P4Tools::P4Testgen::Bmv2::makeSingleExpr ( std::vector< const IR::Expression * > input)

The function combines IR expressions separated by the "or" ,"and" operators and also by the implication which is indicated by "(tmp" ,inside the algorithm, for the convenience of determining the order of expressions. At the output, we get one expression. For example, at the input we have a vector of expressions: [IR::Expression, IR::LOr with name "(tmp", IR::Expression, IR::LAnd, IR::Expression] The result will be an IR::Expression equal to !IRExpression || (IR::Expression && IR::Expression)

◆ removeComments()

std::vector< Token > P4::P4Tools::P4Testgen::Bmv2::removeComments ( const std::vector< Token > & input)

Removes comment lines from the input array. For example, at the input we have a vector of tokens: [//(Comment), CommentText(Text) , (EndString) , 28(Number), .....] -> [28(Number), .....]