Skip to content

Commit

Permalink
Add Fabric Router Config to to Hal
Browse files Browse the repository at this point in the history
- Use hal to get fabric router config addrs in control plane
  • Loading branch information
aliuTT committed Jan 15, 2025
1 parent d408f13 commit 454eea0
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 3 deletions.
11 changes: 8 additions & 3 deletions tt_fabric/control_plane.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@
//
// SPDX-License-Identifier: Apache-2.0

#include "llrt/hal.hpp"
#include "tt_fabric/control_plane.hpp"
#include "tt_metal/hw/inc/wormhole/eth_l1_address_map.h"
#include <queue>

namespace tt::tt_fabric {
static_assert(eth_l1_mem::address_map::FABRIC_ROUTER_CONFIG_SIZE == sizeof(fabric_router_l1_config_t));

// Get the physical chip ids for a mesh
std::unordered_map<chip_id_t, std::vector<CoreCoord>> get_ethernet_cores_grouped_by_connected_chips(chip_id_t chip_id) {
Expand Down Expand Up @@ -469,11 +468,17 @@ void ControlPlane::write_routing_tables_to_chip(mesh_id_t mesh_id, chip_id_t chi
CoreCoord virtual_eth_core =
tt::Cluster::instance().get_virtual_eth_core_from_channel(physical_chip_id, eth_chan);

TT_ASSERT(
tt_metal::hal.get_dev_size(
tt_metal::HalProgrammableCoreType::ACTIVE_ETH, tt_metal::HalL1MemAddrType::FABRIC_ROUTER_CONFIG) ==
sizeof(tt::tt_fabric::fabric_router_l1_config_t),
"ControlPlane: Fabric router config size mismatch");
tt::Cluster::instance().write_core(
(void*)&fabric_router_config,
sizeof(tt::tt_fabric::fabric_router_l1_config_t),
tt_cxy_pair(physical_chip_id, virtual_eth_core),
eth_l1_mem::address_map::FABRIC_ROUTER_CONFIG_BASE,
tt_metal::hal.get_dev_addr(
tt_metal::HalProgrammableCoreType::ACTIVE_ETH, tt_metal::HalL1MemAddrType::FABRIC_ROUTER_CONFIG),
false);
}
}
Expand Down
4 changes: 4 additions & 0 deletions tt_metal/llrt/blackhole/bh_hal_active_eth.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ HalCoreInfoType create_active_eth_mem_map() {
eth_l1_mem::address_map::ERISC_APP_ROUTING_INFO_BASE;
mem_map_bases[static_cast<std::size_t>(HalL1MemAddrType::RETRAIN_COUNT)] =
eth_l1_mem::address_map::RETRAIN_COUNT_ADDR;
mem_map_bases[static_cast<std::size_t>(HalL1MemAddrType::FABRIC_ROUTER_CONFIG)] =
eth_l1_mem::address_map::FABRIC_ROUTER_CONFIG_BASE;

std::vector<std::uint32_t> mem_map_sizes;
mem_map_sizes.resize(static_cast<std::size_t>(HalL1MemAddrType::COUNT));
Expand All @@ -80,6 +82,8 @@ HalCoreInfoType create_active_eth_mem_map() {
mem_map_sizes[static_cast<std::size_t>(HalL1MemAddrType::APP_ROUTING_INFO)] =
eth_l1_mem::address_map::ERISC_APP_ROUTING_INFO_SIZE;
mem_map_sizes[static_cast<std::size_t>(HalL1MemAddrType::RETRAIN_COUNT)] = sizeof(uint32_t);
mem_map_sizes[static_cast<std::size_t>(HalL1MemAddrType::FABRIC_ROUTER_CONFIG)] =
eth_l1_mem::address_map::FABRIC_ROUTER_CONFIG_SIZE;

std::vector<std::vector<HalJitBuildConfig>> processor_classes(NumEthDispatchClasses - 1);
std::vector<HalJitBuildConfig> processor_types(1);
Expand Down
1 change: 1 addition & 0 deletions tt_metal/llrt/hal.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ enum class HalL1MemAddrType : uint8_t {
TILE_HEADER_BUFFER,
APP_ROUTING_INFO,
RETRAIN_COUNT,
FABRIC_ROUTER_CONFIG,
COUNT // Keep this last so it always indicates number of enum options
};

Expand Down
4 changes: 4 additions & 0 deletions tt_metal/llrt/wormhole/wh_hal_active_eth.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ HalCoreInfoType create_active_eth_mem_map() {
eth_l1_mem::address_map::ERISC_APP_ROUTING_INFO_BASE;
mem_map_bases[static_cast<std::size_t>(HalL1MemAddrType::RETRAIN_COUNT)] =
eth_l1_mem::address_map::RETRAIN_COUNT_ADDR;
mem_map_bases[static_cast<std::size_t>(HalL1MemAddrType::FABRIC_ROUTER_CONFIG)] =
eth_l1_mem::address_map::FABRIC_ROUTER_CONFIG_BASE;

std::vector<uint32_t> mem_map_sizes;
mem_map_sizes.resize(static_cast<std::size_t>(HalL1MemAddrType::COUNT));
Expand All @@ -76,6 +78,8 @@ HalCoreInfoType create_active_eth_mem_map() {
mem_map_sizes[static_cast<std::size_t>(HalL1MemAddrType::APP_ROUTING_INFO)] =
eth_l1_mem::address_map::ERISC_APP_ROUTING_INFO_SIZE;
mem_map_sizes[static_cast<std::size_t>(HalL1MemAddrType::RETRAIN_COUNT)] = sizeof(uint32_t);
mem_map_sizes[static_cast<std::size_t>(HalL1MemAddrType::FABRIC_ROUTER_CONFIG)] =
eth_l1_mem::address_map::FABRIC_ROUTER_CONFIG_SIZE;

std::vector<std::vector<HalJitBuildConfig>> processor_classes(NumEthDispatchClasses);
std::vector<HalJitBuildConfig> processor_types(1);
Expand Down

0 comments on commit 454eea0

Please sign in to comment.