7#ifndef TENSTORRENT_MSGQUEUE_H_
8#define TENSTORRENT_MSGQUEUE_H_
14#define NUM_MSG_QUEUES 4
15#define MSG_QUEUE_SIZE 4
16#define MSG_QUEUE_POINTER_WRAP (2 * MSG_QUEUE_SIZE)
17#define REQUEST_MSG_LEN 8
18#define RESPONSE_MSG_LEN 8
20#define MSG_TYPE_INDEX 0
21#define MSG_TYPE_MASK 0xFF
22#define MSG_TYPE_SHIFT 0
24#define MESSAGE_QUEUE_STATUS_MESSAGE_RECOGNIZED 0xff
25#define MESSAGE_QUEUE_STATUS_SCRATCH_ONLY 0xfe
903#define REGISTER_MESSAGE(msg, func) \
904 const STRUCT_SECTION_ITERABLE(msgqueue_handler, registration_for_##msg) = { \
counter_cmd
Counter commands.
Definition msgqueue.h:66
counter_bank
Available counter banks.
Definition msgqueue.h:76
gddr_reset_err
Error codes returned in response data[1] for TT_SMC_MSG_TOGGLE_GDDR_RESET.
Definition msgqueue.h:524
@ COUNTER_CMD_FREEZE
Set the frozen bitmask; frozen counters stop counting.
Definition msgqueue.h:72
@ COUNTER_CMD_GET
Read counter values and status.
Definition msgqueue.h:68
@ COUNTER_CMD_CLEAR
Clear selected counters and their overflow bits.
Definition msgqueue.h:70
@ COUNTER_BANK_THROTTLERS
Throttler counters indexed by aiclk_arb_max.
Definition msgqueue.h:78
@ GDDR_RESET_ERR_MASKED
Definition msgqueue.h:527
@ GDDR_RESET_ERR_HARVESTED
Definition msgqueue.h:526
@ GDDR_RESET_ERR_POWERDOWN
Definition msgqueue.h:530
@ GDDR_RESET_ERR_INVALID_INST
Definition msgqueue.h:525
@ GDDR_RESET_ERR_BIST
Definition msgqueue.h:529
@ GDDR_RESET_ERR_TRAINING
Definition msgqueue.h:528
void process_message_queues(void)
Definition msgqueue.c:344
uint8_t(* msgqueue_request_handler_t)(const union request *req, struct response *rsp)
Definition msgqueue.h:896
int msgqueue_request_push(uint32_t msgqueue_id, const union request *request)
Definition msgqueue.c:124
int msgqueue_response_push(uint32_t msgqueue_id, const struct response *response)
Definition msgqueue.c:164
int msgqueue_request_pop(uint32_t msgqueue_id, union request *request)
Definition msgqueue.c:144
void init_msgqueue(void)
Definition msgqueue.c:448
void msgqueue_register_handler(uint32_t msg_code, msgqueue_request_handler_t handler)
Definition msgqueue.c:354
#define REQUEST_MSG_LEN
Definition msgqueue.h:17
int msgqueue_response_pop(uint32_t msgqueue_id, struct response *response)
Definition msgqueue.c:184
#define RESPONSE_MSG_LEN
Definition msgqueue.h:18
Host request to adjust the AICLK speed.
Definition msgqueue.h:135
uint8_t pad[3]
Three bytes of padding.
Definition msgqueue.h:142
uint8_t command_code
The command code corresponding to TT_SMC_MSG_AICLK_GO_BUSY or TT_SMC_MSG_AICLK_GO_LONG_IDLE.
Definition msgqueue.h:139
Host request to start or stop AICLK frequency sweep.
Definition msgqueue.h:153
uint32_t sweep_low
Low end of sweep range in MHz.
Definition msgqueue.h:163
uint32_t sweep_high
High end of sweep range in MHz.
Definition msgqueue.h:166
uint8_t pad[3]
Three bytes of padding.
Definition msgqueue.h:160
uint8_t command_code
The command code corresponding to TT_SMC_MSG_AISWEEP_START or TT_SMC_MSG_AISWEEP_STOP.
Definition msgqueue.h:157
Host request to change ASIC state.
Definition msgqueue.h:554
uint8_t command_code
The command code corresponding to TT_SMC_MSG_ASIC_STATE0 or TT_SMC_MSG_ASIC_STATE3.
Definition msgqueue.h:560
Host request to confirm SPI flash operation.
Definition msgqueue.h:761
uint32_t challenge_data
Challenge data for confirmation.
Definition msgqueue.h:769
uint8_t pad[3]
Three bytes of padding.
Definition msgqueue.h:766
uint8_t command_code
The command code corresponding to TT_SMC_MSG_CONFIRM_FLASHED_SPI.
Definition msgqueue.h:763
Host request for generic counter operations.
Definition msgqueue.h:97
uint8_t command
The command to execute, of type counter_cmd.
Definition msgqueue.h:105
uint8_t bank_index
For GET: counter index within counter_bank; ignored for CLEAR/FREEZE.
Definition msgqueue.h:111
uint8_t counter_bank
The counter bank to operate on, of type counter_bank.
Definition msgqueue.h:108
uint8_t reserved[1]
Reserved; host must set to zero.
Definition msgqueue.h:114
uint8_t command_code
The command code corresponding to TT_SMC_MSG_COUNTER.
Definition msgqueue.h:99
uint16_t mask
CLEAR (bits to reset) and FREEZE (frozen bitmask)
Definition msgqueue.h:117
uint8_t pad[3]
Three bytes of padding.
Definition msgqueue.h:102
Host request for debug NOC translation.
Definition msgqueue.h:354
uint8_t pcie_instance_override
Set to 1 to use pcie instance from the pcie_instance field, or 0 to get the pcie instance from FW tab...
Definition msgqueue.h:367
uint16_t bad_tensix_cols
Bitmask of bad tensix columns.
Definition msgqueue.h:370
uint8_t skip_eth_hi
hi byte of skip_eth field
Definition msgqueue.h:379
uint8_t enable_translation
Enable or disable NOC translation.
Definition msgqueue.h:359
uint8_t command_code
The command code corresponding to TT_SMC_MSG_DEBUG_NOC_TRANSLATION.
Definition msgqueue.h:356
uint8_t bad_gddr
Instance number of the bad GDDR. 0xFF if all GDDR are good.
Definition msgqueue.h:373
uint8_t pcie_instance
The PCIE instance.
Definition msgqueue.h:362
uint8_t skip_eth_low
low byte of skip_eth field
Definition msgqueue.h:376
Host request to ping DMC.
Definition msgqueue.h:385
uint8_t command_code
The command code corresponding to TT_SMC_MSG_PING_DM.
Definition msgqueue.h:387
uint8_t pad[3]
Three bytes of padding.
Definition msgqueue.h:390
bool legacy_ping
Use legacy ping mode.
Definition msgqueue.h:393
Host request to read or write SPI EEPROM.
Definition msgqueue.h:587
uint8_t buffer_mem_type
Buffer memory type (0 = CSM scratch buffer)
Definition msgqueue.h:594
uint32_t num_bytes
Number of bytes to transfer.
Definition msgqueue.h:603
uint8_t pad[2]
Two bytes of padding.
Definition msgqueue.h:597
uint8_t command_code
The command code corresponding to TT_SMC_MSG_READ_EEPROM or TT_SMC_MSG_WRITE_EEPROM.
Definition msgqueue.h:591
uint32_t csm_addr
CSM buffer address for the data.
Definition msgqueue.h:606
uint32_t spi_address
SPI flash address to read from or write to.
Definition msgqueue.h:600
Host request to lock flash writes.
Definition msgqueue.h:748
uint8_t pad[3]
Three bytes of padding.
Definition msgqueue.h:753
uint8_t command_code
The command code corresponding to TT_SMC_MSG_FLASH_LOCK.
Definition msgqueue.h:750
Host request to unlock flash for writing.
Definition msgqueue.h:713
uint8_t pad[3]
Three bytes of padding.
Definition msgqueue.h:718
uint8_t command_code
The command code corresponding to TT_SMC_MSG_FLASH_UNLOCK.
Definition msgqueue.h:715
Host request to force AICLK to a specific frequency.
Definition msgqueue.h:174
uint8_t command_code
The command code corresponding to TT_SMC_MSG_FORCE_AICLK.
Definition msgqueue.h:176
uint8_t pad[3]
Three bytes of padding.
Definition msgqueue.h:179
uint32_t forced_freq
Frequency to force in MHz, or 0 to disable.
Definition msgqueue.h:182
Host request to force the fan speed.
Definition msgqueue.h:121
uint8_t pad[3]
Three bytes of padding.
Definition msgqueue.h:126
uint8_t command_code
The command code corresponding to TT_SMC_MSG_FORCE_FAN_SPEED.
Definition msgqueue.h:123
uint32_t raw_speed
The raw speed of the fan to set, as a percentage from 0 to 100.
Definition msgqueue.h:129
Host request to force the VDD core voltage.
Definition msgqueue.h:284
uint32_t forced_voltage
The voltage to force in millivolts, or 0 to disable forcing.
Definition msgqueue.h:292
uint8_t command_code
The command code corresponding to TT_SMC_MSG_FORCE_VDD.
Definition msgqueue.h:286
uint8_t pad[3]
Three bytes of padding.
Definition msgqueue.h:289
Host request to toggle GDDR reset.
Definition msgqueue.h:512
uint32_t gddr_inst
GDDR controller instance (0-7)
Definition msgqueue.h:520
uint8_t pad[3]
Three bytes of padding.
Definition msgqueue.h:517
uint8_t command_code
The command code corresponding to TT_SMC_MSG_TOGGLE_GDDR_RESET.
Definition msgqueue.h:514
Host request to get the current AICLK frequency and control mode.
Definition msgqueue.h:193
uint8_t command_code
The command code corresponding to TT_SMC_MSG_GET_AICLK.
Definition msgqueue.h:195
Host request to get frequency curve from voltage.
Definition msgqueue.h:326
uint8_t command_code
The command code corresponding to TT_SMC_MSG_GET_FREQ_CURVE_FROM_VOLTAGE.
Definition msgqueue.h:328
uint32_t input_voltage_mv
The input voltage in mV.
Definition msgqueue.h:334
uint8_t pad[3]
Three bytes of padding.
Definition msgqueue.h:331
Host request to get voltage curve from frequency.
Definition msgqueue.h:340
uint8_t command_code
The command code corresponding to TT_SMC_MSG_GET_VOLTAGE_CURVE_FROM_FREQ.
Definition msgqueue.h:342
uint8_t pad[3]
Three bytes of padding.
Definition msgqueue.h:345
uint32_t input_freq_mhz
The input frequency in MHz.
Definition msgqueue.h:348
Host request to get voltage.
Definition msgqueue.h:266
uint8_t command_code
The command code corresponding to TT_SMC_MSG_GET_VOLTAGE.
Definition msgqueue.h:268
uint8_t pad[3]
Three bytes of padding.
Definition msgqueue.h:271
uint32_t slave_addr
I2C slave address (P0V8_VCORE_ADDR or P0V8_VCOREM_ADDR)
Definition msgqueue.h:274
Host request for I2C message transaction.
Definition msgqueue.h:416
uint8_t num_read_bytes
Number of bytes to read.
Definition msgqueue.h:430
uint8_t write_data[24]
Write data buffer (up to 24 bytes)
Definition msgqueue.h:436
uint8_t i2c_mst_id
I2C master ID.
Definition msgqueue.h:421
uint8_t i2c_slave_address
I2C slave address (7-bit)
Definition msgqueue.h:424
uint8_t num_write_bytes
Number of bytes to write.
Definition msgqueue.h:427
uint8_t command_code
The command code corresponding to TT_SMC_MSG_I2C_MESSAGE.
Definition msgqueue.h:418
uint8_t pad[3]
Three bytes of padding.
Definition msgqueue.h:433
Host request to blink the LED.
Definition msgqueue.h:444
uint8_t command_code
The command code corresponding to TT_SMC_MSG_BLINKY.
Definition msgqueue.h:446
uint8_t is_blinking
Whether LED should be blinking or not. Set to 1 to start continuous blinking, 0 to stop blinking.
Definition msgqueue.h:454
uint8_t pad[3]
Three bytes of padding.
Definition msgqueue.h:449
Definition msgqueue.h:898
msgqueue_request_handler_t handler
Definition msgqueue.h:900
uint32_t msg_type
Definition msgqueue.h:899
Host request to initiate a PCIe DMA transfer.
Definition msgqueue.h:481
uint8_t command_code
The command code corresponding to TT_SMC_MSG_PCIE_DMA_CHIP_TO_HOST_TRANSFER or TT_SMC_MSG_PCIE_DMA_HO...
Definition msgqueue.h:486
uint8_t pad[2]
Two bytes of padding.
Definition msgqueue.h:492
uint8_t completion_data
Completion data written to the MSI completion address.
Definition msgqueue.h:489
uint64_t msi_completion_addr
MSI completion address on the host.
Definition msgqueue.h:504
uint64_t host_addr
Host-side address for the transfer.
Definition msgqueue.h:501
uint64_t chip_addr
Chip-side address for the transfer.
Definition msgqueue.h:498
uint32_t transfer_size_bytes
Transfer size in bytes.
Definition msgqueue.h:495
Host request to adjust the power settings.
Definition msgqueue.h:201
uint16_t reserved
Reserved.
Definition msgqueue.h:237
struct power_setting_rqst::@364260271035044055320364336346370330326342300150 power_settings_array
uint8_t power_flags_valid
The number of bits in the power_flags_bitfield that are valid.
Definition msgqueue.h:206
uint16_t future_use
Future use flags currently not supported.
Definition msgqueue.h:234
uint8_t power_settings_valid
The number of fields that are valid in the power_settings_array.
Definition msgqueue.h:209
uint16_t l2cpu_enable
1 - Enable L2CPU cores 0 - Disable L2CPU cores
Definition msgqueue.h:231
uint8_t command_code
The command code corresponding to TT_SMC_MSG_POWER_SETTING.
Definition msgqueue.h:203
uint16_t tensix_enable
1 - Enable Tensix cores 0 - Disable Tensix cores
Definition msgqueue.h:226
struct power_setting_rqst::@140120167246117267343245340300140063053015126121 power_flags_bitfield
The list of On/Off style power flags SMC supports toggling.
uint16_t mrisc_phy_power
1 - Set MRISC power setting to Phy wakeup 0 - Set MRISC power setting to Phy Powerdown
Definition msgqueue.h:221
uint16_t max_ai_clk
1 - Set AICLK to Busy 0 - Set AICLK to Idle
Definition msgqueue.h:216
Host request to read a process detector.
Definition msgqueue.h:615
uint8_t pad[3]
Three bytes of padding.
Definition msgqueue.h:620
uint8_t command_code
The command code corresponding to TT_SMC_MSG_READ_PD.
Definition msgqueue.h:617
uint32_t delay_chain
Delay chain selection.
Definition msgqueue.h:623
uint32_t sensor_id
Process detector instance ID.
Definition msgqueue.h:626
Host request to read a temperature sensor.
Definition msgqueue.h:569
uint8_t command_code
The command code corresponding to TT_SMC_MSG_READ_TS.
Definition msgqueue.h:571
uint8_t pad[3]
Three bytes of padding.
Definition msgqueue.h:574
uint32_t sensor_id
Temperature sensor instance ID.
Definition msgqueue.h:577
Host request to read a voltage monitor.
Definition msgqueue.h:635
uint8_t pad[3]
Three bytes of padding.
Definition msgqueue.h:640
uint32_t sensor_id
Voltage monitor instance ID.
Definition msgqueue.h:643
uint8_t command_code
The command code corresponding to TT_SMC_MSG_READ_VM.
Definition msgqueue.h:637
Host request to reinitialize Tensix NOC programming and tile configuration.
Definition msgqueue.h:693
uint8_t command_code
The command code corresponding to TT_SMC_MSG_REINIT_TENSIX.
Definition msgqueue.h:695
Host request to report scratch-only status.
Definition msgqueue.h:669
uint8_t command_code
The command code corresponding to TT_SMC_MSG_REPORT_SCRATCH_ONLY.
Definition msgqueue.h:671
Definition msgqueue.h:892
uint32_t data[8]
Definition msgqueue.h:893
Host request to send PCIE MSI.
Definition msgqueue.h:399
uint8_t pad[2]
2 bytes of padding
Definition msgqueue.h:407
uint8_t command_code
The command code corresponding to TT_SMC_MSG_SEND_PCIE_MSI.
Definition msgqueue.h:401
uint8_t pcie_inst
The PCIE instance 0 or 1.
Definition msgqueue.h:404
uint32_t vector_id
MSI vector ID.
Definition msgqueue.h:410
Host request to set the ASIC fmax.
Definition msgqueue.h:677
uint8_t restore_default
Restore the ASIC host fmax to the default value.
Definition msgqueue.h:685
uint32_t asic_fmax
The ASIC host fmax to set in MHz.
Definition msgqueue.h:683
uint8_t pad[3]
Three bytes of padding.
Definition msgqueue.h:681
uint8_t command_code
The command code corresponding to TT_SMC_MSG_SET_ASIC_HOST_FMAX.
Definition msgqueue.h:679
Host request to set the TDP limit.
Definition msgqueue.h:649
uint8_t pad[3]
Three bytes of padding.
Definition msgqueue.h:654
uint32_t tdp_limit
The TDP limit to set in watts.
Definition msgqueue.h:657
uint8_t restore_default
Restore the TDP limit to the default value.
Definition msgqueue.h:660
uint8_t command_code
The command code corresponding to TT_SMC_MSG_SET_TDP_LIMIT.
Definition msgqueue.h:651
Host request to set voltage.
Definition msgqueue.h:249
uint32_t slave_addr
I2C slave address (P0V8_VCORE_ADDR or P0V8_VCOREM_ADDR)
Definition msgqueue.h:257
uint32_t voltage_in_mv
Voltage to set in millivolts.
Definition msgqueue.h:260
uint8_t pad[3]
Three bytes of padding.
Definition msgqueue.h:254
uint8_t command_code
The command code corresponding to TT_SMC_MSG_SET_VOLTAGE.
Definition msgqueue.h:251
Host request to set watchdog timeout.
Definition msgqueue.h:724
uint8_t command_code
The command code corresponding to TT_SMC_MSG_SET_WDT_TIMEOUT.
Definition msgqueue.h:726
uint8_t pad[3]
Three bytes of padding.
Definition msgqueue.h:729
uint32_t timeout_ms
The watchdog timeout value in milliseconds.
Definition msgqueue.h:740
Host request to switch clock scheme.
Definition msgqueue.h:312
uint8_t command_code
The command code corresponding to TT_SMC_MSG_SWITCH_CLK_SCHEME.
Definition msgqueue.h:314
uint32_t scheme
Clock scheme to switch to
Definition msgqueue.h:320
uint8_t pad[3]
Three bytes of padding.
Definition msgqueue.h:317
Host request to switch VOUT control.
Definition msgqueue.h:298
uint8_t pad[3]
Three bytes of padding.
Definition msgqueue.h:303
uint32_t source
VOUT control source.
Definition msgqueue.h:306
uint8_t command_code
The command code corresponding to TT_SMC_MSG_SWITCH_VOUT_CONTROL.
Definition msgqueue.h:300
Host request for test message.
Definition msgqueue.h:460
uint32_t test_value
Test input value that will be incremented in the response.
Definition msgqueue.h:468
uint8_t pad[3]
Three bytes of padding.
Definition msgqueue.h:465
uint8_t command_code
The command code corresponding to TT_SMC_MSG_TEST.
Definition msgqueue.h:462
Host request to toggle Tensix reset.
Definition msgqueue.h:703
uint8_t command_code
The command code corresponding to TT_SMC_MSG_TOGGLE_TENSIX_RESET.
Definition msgqueue.h:705
Host request to trigger a chip reset.
Definition msgqueue.h:540
uint32_t reset_level
Reset level: 0 = ASIC-only reset, 3 = ASIC + M3 (DMC) reset.
Definition msgqueue.h:548
uint8_t command_code
The command code corresponding to TT_SMC_MSG_TRIGGER_RESET.
Definition msgqueue.h:542
uint8_t pad[3]
Three bytes of padding.
Definition msgqueue.h:545
A tenstorrent host request.
Definition msgqueue.h:773
struct force_vdd_rqst force_vdd
A force VDD voltage request.
Definition msgqueue.h:807
struct get_freq_curve_from_voltage_rqst get_freq_curve_from_voltage
A get frequency curve from voltage request.
Definition msgqueue.h:816
struct set_voltage_rqst set_voltage
A set voltage request.
Definition msgqueue.h:801
struct flash_lock_rqst flash_lock
A flash lock request.
Definition msgqueue.h:882
struct test_rqst test
A test request.
Definition msgqueue.h:837
struct dmc_ping_rqst dmc_ping
A dmc ping request.
Definition msgqueue.h:825
struct report_scratch_only_rqst report_scratch_only
A report scratch-only request.
Definition msgqueue.h:870
struct flash_unlock_rqst flash_unlock
A flash unlock request.
Definition msgqueue.h:879
struct gddr_reset_rqst gddr_reset
A GDDR reset request.
Definition msgqueue.h:849
struct counter_rqst counter
A generic counter request.
Definition msgqueue.h:873
struct get_voltage_rqst get_voltage
A get voltage request.
Definition msgqueue.h:804
struct get_voltage_curve_from_freq_rqst get_voltage_curve_from_freq
A get voltage curve from frequency request.
Definition msgqueue.h:819
struct asic_state_rqst asic_state
An ASIC state transition request.
Definition msgqueue.h:843
struct switch_clk_scheme_rqst switch_clk_scheme
A switch clock scheme request.
Definition msgqueue.h:813
struct confirm_flashed_spi_rqst confirm_flashed_spi
A confirm SPI flash request.
Definition msgqueue.h:885
struct aisweep_rqst aisweep
An AICLK sweep start or stop request.
Definition msgqueue.h:789
struct force_fan_speed_rqst force_fan_speed
A force fan speed request.
Definition msgqueue.h:783
uint32_t data[8]
The interpretation of the request as an array of uint32_t entries.
Definition msgqueue.h:775
struct eeprom_rqst eeprom
An EEPROM read or write request.
Definition msgqueue.h:864
struct set_asic_host_fmax_rqst set_asic_host_fmax
A set ASIC host fmax request.
Definition msgqueue.h:867
struct switch_vout_control_rqst switch_vout_control
A switch VOUT control request.
Definition msgqueue.h:810
struct set_wdt_timeout_rqst set_wdt_timeout
A set watchdog timeout request.
Definition msgqueue.h:876
struct set_tdp_limit_rqst set_tdp_limit
A set TDP limit request.
Definition msgqueue.h:861
struct force_aiclk_rqst force_aiclk
A force AICLK frequency request.
Definition msgqueue.h:792
struct pcie_dma_transfer_rqst pcie_dma_transfer
A PCIe DMA transfer request.
Definition msgqueue.h:840
struct i2c_message_rqst i2c_message
An I2C message request.
Definition msgqueue.h:831
struct aiclk_set_speed_rqst aiclk_set_speed
An AICLK set speed request.
Definition msgqueue.h:786
struct read_vm_rqst read_vm
A voltage monitor read request.
Definition msgqueue.h:855
struct trigger_reset_rqst trigger_reset
A trigger reset request.
Definition msgqueue.h:846
struct read_pd_rqst read_pd
A process detector read request.
Definition msgqueue.h:858
uint8_t command_code
The interpretation of the request as just the first byte representing command code.
Definition msgqueue.h:780
struct read_ts_rqst read_ts
A temperature sensor read request.
Definition msgqueue.h:852
struct debug_noc_translation_rqst debug_noc_translation
A debug NOC translation request.
Definition msgqueue.h:822
struct get_aiclk_rqst get_aiclk
A get AICLK frequency request.
Definition msgqueue.h:795
struct power_setting_rqst power_setting
A power setting request.
Definition msgqueue.h:798
struct led_blink_rqst blink
The led blinking request.
Definition msgqueue.h:834
struct send_pcie_msi_rqst send_pci_msi
A Send PCIE MSI request.
Definition msgqueue.h:828