P4C
The P4 Compiler
All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Modules Pages
Parser::State::Match Struct Reference

Classes

struct  Clot
 
struct  FieldMapping
 
struct  HdrLenIncStop
 
struct  Save
 
struct  Set
 

Public Types

enum  flags_t { OFFSET = 1 , ROTATE = 2 }
 

Public Member Functions

 Match (int lineno, gress_t, State *n)
 
 Match (int lineno, gress_t, State *s, match_t m, VECTOR(pair_t) &data)
 
std::set< Match * > get_all_preds ()
 
std::set< Match * > get_all_preds_impl (std::set< Match * > &visited)
 
void pass1 (Parser *pa, State *state)
 
void pass2 (Parser *pa, State *state)
 
void unmark_reachable (Parser *, State *state, bitvec &unreach)
 
template<class REGS>
void write_common_row_config (REGS &, Parser *, State *, int, Match *, json::map &)
 
template<class REGS>
void write_config (REGS &, json::vector &)
 
template<class REGS>
void write_config (REGS &, Parser *, State *, Match *, json::map &)
 
template<class EA_REGS>
void write_counter_config (EA_REGS &) const
 
template<>
void write_counter_config (Target::JBay::parser_regs::_memory::_ml_ea_row &ea_row) const
 
template<>
void write_counter_config (Target::Tofino::parser_regs::_memory::_ml_ea_row &ea_row) const
 
template<class REGS>
int write_load_config (REGS &, Parser *, State *, int) const
 
template<>
int write_load_config (Target::JBay::parser_regs &regs, Parser *pa, State *state, int row) const
 
template<>
int write_load_config (Target::Tofino::parser_regs &regs, Parser *pa, State *state, int row) const
 
template<class REGS>
void write_lookup_config (REGS &, State *, int) const
 
template<>
void write_lookup_config (Target::JBay::parser_regs &regs, State *state, int r) const
 
template<>
void write_lookup_config (Target::Tofino::parser_regs &regs, State *state, int row) const
 
template<class REGS>
void write_row_config (REGS &, Parser *, State *, int, Match *, json::map &)
 
template<>
void write_row_config (Target::JBay::parser_regs &regs, Parser *pa, State *state, int row, Match *def, json::map &ctxt_json)
 
template<class REGS>
void write_saves (REGS &regs, Match *def, void *output_map, int &max_off, unsigned &used, int csum_8b, int csum_16b)
 
template<class REGS>
void write_sets (REGS &regs, Match *def, void *output_map, unsigned &used, int csum_8b, int csum_16b)
 

Public Attributes

int buf_req = -1
 
std::vector< Clot * > clots
 
std::vector< Checksumcsum
 
int ctr_imm_amt = 0
 
CounterInit * ctr_instr = nullptr
 
int ctr_ld_src = 0
 
int ctr_load = 0
 
bool ctr_stack_pop = false
 
bool ctr_stack_push = false
 
bool ctr_stack_upd_w_top = false
 
int disable_partial_hdr_err = -1
 
std::vector< FieldMappingfield_mapping
 
bool has_narrow_to_wide_extract = false
 
struct Parser::State::Match::HdrLenIncStop hdr_len_inc_stop
 
int intr_md_bits = 0
 
int lineno
 
MatchKey load
 
match_t match
 
std::vector< const Phv::Ref * > narrow_to_wide_16b_8
 
std::vector< const Phv::Ref * > narrow_to_wide_32b_16
 
std::vector< const Phv::Ref * > narrow_to_wide_32b_8
 
Ref next
 
int offset_inc = 0
 
bool offset_rst = false
 
int partial_hdr_err_proc = -1
 
PriorityUpdate priority
 
int row = -1
 
std::vector< Save * > save
 
std::vector< Set * > set
 
int shift = 0
 
Statestate = nullptr
 
int value_set_handle = -1
 
std::string value_set_name
 
int value_set_size = 0
 

Member Function Documentation

◆ get_all_preds()

std::set< Parser::State::Match * > Parser::State::Match::get_all_preds ( )

Extractor config tracking and register config code Different tofino models have very different ways in which their parser extractors are managed, but all are common in that there are multiple extractions that can happen in parallel in a single parser match tcam row. We manage this by having a target-specific 'output_map' object passed via a void * to target-sepcific write_output_config methods along with an unsigned used mask that tracks which or how many extractors have been used, so as to issue errors for conflicting uses.

The setup_phv_output_map method creates the target specific output_map object that will be passed to subsequent write_output_config calls to deal with each individual extract. Finally, mark_unused_output_map is called to deal with any register setup needed for unused extractors. They're called 'outputs' as the are concerned with outputting PHV values from the parser.

PHV outputs are split into 'saves' and 'sets' which come from different syntax in the asm source. 'saves' copy data from the input buffer into PHVs, while 'sets' write constants into the PHVs. Different targets have different constraints on how flexible they are for saves vs sets, so some want to do saves first and other sets

  • tofino1: do saves first (why? sets seem more constrained, but there's an issue with ganging smaller extractors to write larger PHVs)
  • tofino2: do sets first as some extractors can only do saves

FIXME – should probably refactor this into a more C++ style base class pointer with derived classes for each target. Should move the 'used' mask into that object as well. Alternately, could move the entire setup to mark_unused process into a target specific method.

Member Data Documentation

◆ has_narrow_to_wide_extract

bool Parser::State::Match::has_narrow_to_wide_extract = false

Data for narrow to wide extraction analysis, flag and vector of affected PHV locations