P4C
The P4 Compiler
Loading...
Searching...
No Matches
Tofino::ActionDataBus Struct Reference

#include <action_data_bus.h>

Inheritance diagram for Tofino::ActionDataBus:
[legend]

Classes

struct  Use
 

Public Member Functions

bool alloc_action_data_bus (const IR::MAU::Table *tbl, const ActionData::Format::Use *use, TableResourceAlloc &alloc) override
 
bool alloc_action_data_bus (const IR::MAU::Table *tbl, const MeterALU::Format::Use *use, TableResourceAlloc &alloc) override
 
void clear () override
 
bool operator!= (ActionDataBus &adb)
 
bool operator== (const ActionDataBus &adb) const
 
void update (const IR::MAU::Table *tbl) override
 
void update (cstring name, const ::ActionDataBus::Use &alloc) override
 
void update (cstring name, const Use::RandomNumberGenerator &rng)
 
void update (cstring name, const Use::ReservedSpace &rs) override
 
- Public Member Functions inherited from ActionDataBus
virtual void update (cstring name, const TableResourceAlloc *alloc, const IR::MAU::Table *tbl)
 
virtual void update (cstring name, const Use &alloc)
 
virtual void update_action_data (cstring name, const TableResourceAlloc *alloc, const IR::MAU::Table *tbl)
 
virtual void update_meter (cstring name, const TableResourceAlloc *alloc, const IR::MAU::Table *tbl)
 

Static Public Attributes

static constexpr int ADB_BYTES = 128
 
static constexpr int ADB_STARTS [ActionData::SLOT_TYPES] = {0, 32, 96}
 
static constexpr int BYTES_PER_RAM = 16
 
static constexpr int CSR_RANGE = 16
 
static constexpr int CSR_SECTION [ActionData::SLOT_TYPES] = {4, 3, 2}
 
static constexpr int IMMED_DIVIDES [ActionData::SLOT_TYPES] = {16, 64, 128}
 
static constexpr int IMMED_SECT = 4
 
static constexpr int OUTPUTS = 32
 
static constexpr int PAIRED_OFFSET = 16
 
static constexpr int RANDOM_NUMBER_GENERATORS = 2
 

Additional Inherited Members

- Public Types inherited from ActionDataBus
enum  loc_alg_t {
  FIND_NORMAL , FIND_LOWER , FIND_FULL , FIND_IMMED_UPPER ,
  FIND_FULL_HALF , FIND_FULL_BYTE
}
 
- Static Public Member Functions inherited from ActionDataBus
static ActionDataBuscreate ()
 
static int getAdbSize ()
 
- Protected Attributes inherited from ActionDataBus
ordered_map< const IR::MAU::AttachedMemory *, const Use & > allocated_attached
 
ordered_map< cstring, const Use & > reduction_or_mapping
 

Detailed Description

Algorithm for the allocation of the action data bus. The action data bus is broken into 3 parts, a BYTE, HALF, and FULL region. The byte and half regions are mutually exclusive, while the full region shares places with the byte and half region. There are 32 outputs for each type of container region. The bytes 0-31 are for the byte region, bytes 32-95 are for the half region, and all 128 bytes are for the full regions. Because actions within the same table are mutually exclusive, FULLs can potentially share locations with BYTES and HALFs on the action data bus.

The version of the algorithm updates the tables that have been previously allocated. It then attempts to allocate the BYTES and HALVES. Then the algorithm checks to see if the regions can be shared, and if not, allocates a separate byte.

The rules for allocation are set by the uArch on section 5.2.5.1/6.2.5.1 on the Action Data Bus. The section is titled Action Output HV Xbar Programming, under the section Action Output HV Xbar(s) in the Section RAM Array. The bytes are broken into 16 byte regions and bytes in particular offsets of the action data table have to be allocated contiguously within these 16 byte regions. The constraints are better detailed over the alloc_bytes, alloc_halves, and alloc_fulls function calls.

For immediate actions, the constraints are detailed in the uArch in section 5.4.4.2/6.4.4.2. The section is titled Immediate Action Data, under Address Distribution, under Match Central. Unlike for action data tables, which are broken up into 8 16 byte muxes, there are only 3 muxes for each immediate section. There is a byte by byte mux between bytes 0-15, a half-word mux between bytes 16-63, and a full word mux between bytes 64-128. These muxes can only have one input per immediate word. Immediate allocation on the action bus occurs on a mod 4 post-shift in match central.

The constraints are similar to action data tables in that regions of the immediate data must be contiguously allocated within a 16 byte region of the action data bus. With immediate action data, the input allocation must be 4 byte contiguous.

Member Function Documentation

◆ alloc_action_data_bus() [1/2]

bool Tofino::ActionDataBus::alloc_action_data_bus ( const IR::MAU::Table * tbl,
const ActionData::Format::Use * use,
TableResourceAlloc & alloc )
overridevirtual

Total allocation of the action data bus for a particular table. Again, based on the current fact that actions are either contained in the immediate or in an action data table, the algorithm performs them separately. Once it can be simultaneous, the algorithm needs to be adapted to handle both at the same time. Based on the current algorithm, hopefully the only change is here.

TODO: When action immediate and action data table can happen simultaneously, change here

Implements ActionDataBus.

◆ alloc_action_data_bus() [2/2]

bool Tofino::ActionDataBus::alloc_action_data_bus ( const IR::MAU::Table * tbl,
const MeterALU::Format::Use * use,
TableResourceAlloc & alloc )
overridevirtual

Implement the action data bus allocation logic here for meter alu output.

Implements ActionDataBus.

◆ clear()

void Tofino::ActionDataBus::clear ( )
overridevirtual

Clears all of the allocation within the ActionDataBus, for the TableSummary

Reimplemented from ActionDataBus.

◆ update() [1/2]

void ActionDataBus::update ( const IR::MAU::Table * tbl)
overridevirtual

Reimplemented from ActionDataBus.

◆ update() [2/2]

void ActionDataBus::update ( cstring name,
const Use::ReservedSpace & rs )
overridevirtual

Implements ActionDataBus.