P4C
The P4 Compiler
Loading...
Searching...
No Matches
IXBar Struct Referenceabstract
Inheritance diagram for IXBar:
[legend]

Classes

struct  failure
 
struct  FieldInfo
 
class  FieldManagement
 
struct  KeyInfo
 
struct  Loc
 
struct  Use
 

Public Types

enum  byte_speciality_t {
  NONE , ATCAM_DOUBLE , ATCAM_INDEX , RANGE_LO ,
  RANGE_HI , BYTE_SPECIALITIES
}
 
enum  byte_type_t { NO_BYTE_TYPE , ATCAM , PARTITION_INDEX , RANGE }
 
enum  HashDistDest_t {
  HD_IMMED_LO , HD_IMMED_HI , HD_STATS_ADR , HD_METER_ADR ,
  HD_ACTIONDATA_ADR , HD_PRECOLOR , HD_HASHMOD , HD_DESTS
}
 
enum  parity_status_t { PARITY_NONE , PARITY_ENABLED , PARITY_DISABLED }
 

Public Member Functions

virtual void add_collisions ()=0
 
virtual bool allocTable (const IR::MAU::Table *tbl, const IR::MAU::Table *gw, const PhvInfo &, TableResourceAlloc &, const LayoutOption *, const ActionData::Format::Use *, const attached_entries_t &)=0
 
virtual void dbprint (std::ostream &) const =0
 
virtual void update (const IR::MAU::Table *tbl)
 
virtual void update (const IR::MAU::Table *tbl, const TableResourceAlloc *rsrc)
 
virtual void update (cstring name, const Use &alloc)=0
 
virtual void verify_hash_matrix () const =0
 
- Public Member Functions inherited from P4::IHasDbPrint
void print () const
 

Static Public Member Functions

static IXBarcreate ()
 
static HashDistDest_t dest_location (const IR::Node *node, bool precolor=false)
 
static std::string hash_dist_name (HashDistDest_t dest)
 

Public Attributes

cstring failure_reason
 

Static Public Attributes

static constexpr int LAMB_LINE_SELECT_BITS = 6
 
static constexpr int RAM_LINE_SELECT_BITS = 10
 

Protected Types

typedef std::map< Use::Byte, safe_vector< FieldInfo > > ContByteConversion
 

Protected Member Functions

void create_alloc (ContByteConversion &map_alloc, IXBar::Use &alloc)
 
void create_alloc (ContByteConversion &map_alloc, safe_vector< Use::Byte > &bytes)
 

Static Protected Member Functions

template<class T , int S>
static void add_names (const BFN::Alloc1D< T, S > &n, std::map< cstring, char > &names)
 
template<class T , int R, int C>
static void add_names (const BFN::Alloc2D< T, R, C > &n, std::map< cstring, char > &names)
 
static void add_names (const std::pair< PHV::Container, int > &c, std::map< cstring, char > &names)
 
template<class T >
static void add_names (const T &n, std::map< cstring, char > &names)
 
static void add_names (cstring n, std::map< cstring, char > &names)
 
static void add_names (PHV::Container c, std::map< cstring, char > &names)
 
static void add_use (ContByteConversion &map_alloc, const PHV::Field *field, const PhvInfo &phv, const IR::MAU::Table *ctxt, std::optional< cstring > aliasSourceName, const le_bitrange *bits=nullptr, int flags=0, byte_type_t byte_type=NO_BYTE_TYPE, unsigned extra_align=0, int range_index=0, int pragma_forced_ixbar_group=-1)
 
static void sort_names (std::map< cstring, char > &names)
 
template<class T >
static void write_group (std::ostream &out, const T &grp, std::map< cstring, char > &fields)
 
static void write_one (std::ostream &out, const std::pair< cstring, int > &f, std::map< cstring, char > &fields)
 
static void write_one (std::ostream &out, const std::pair< PHV::Container, int > &f, std::map< cstring, char > &fields)
 
static void write_one (std::ostream &out, cstring n, std::map< cstring, char > &names)
 
static void write_one (std::ostream &out, PHV::Container f, std::map< cstring, char > &fields)
 

Protected Attributes

ordered_map< const IR::MAU::AttachedMemory *, const IXBar::Use & > allocated_attached
 

Member Typedef Documentation

◆ ContByteConversion

The purpose of ContByteConversion is to capture that multiple stretch of fields can be contained within the same container byte. In the add_use function, each FieldInfo object will be created, and linked to a corresponding container byte. Later, in the create_alloc function, these individual FieldInfo object will be used to create at least a single byte, (and maybe more due to overlay issues), that the compiler needs to allocate for an input xbar.

Member Function Documentation

◆ create_alloc()

void IXBar::create_alloc ( ContByteConversion & map_alloc,
safe_vector< Use::Byte > & bytes )
protected

In order to prevent some overlay bugs by the driver, this guarantees that if a table matches on multiple overlaid bits, that these bits appear twice in the match key. One could in theory have a ternary match table that has the following:

key { h1.f1 : ternary; h2.f1 : ternary; }

where if h1.f1 and h2.f1 are never live at the same time, could be that a don't care match is always turned on for at least one of the two fields. This could potentially be a save on logical tables.

However, the driver currently writes the fields in the order in the context JSON, not in the order of write don't care before do care, and in this instance, if these fields were overlaid on the match, could potentially overwrite one of the fields.

Thus currently, the fields have to appear multiple times within the match, and as of right now, also need to appear multiple times on the IXBar. In some cases this might not be true. For ternary table, a single byte in the match must be a single byte in the ixbar. However, for exact match, a byte can be swizzled multiple times, which we take advantage of in an ATCAM match to save room. However the compiler will not do this for multiple appearances of overlaid fields.

Furthermore, each byte is classified by a byte_speciaility_t. Bytes with different specialities themselves will not be overlaid during the allocation process. This management just becomes difficult

◆ dbprint()

virtual void IXBar::dbprint ( std::ostream & ) const
pure virtual

Implements P4::IHasDbPrint.