55 #define DMA_BURST_SIZE 4
58 #define N_DMA_BUFFERS 2
65 #define END_FLAG_SIZE 4
67 #define END_FLAG 0xFFFFFFFF
99 #define SDP_TIMEOUT 1000
102 #define LENGTH_OF_SDP_HEADER 8
109 #define N_ROUTER_ENTRIES 1024
112 #define INVALID_ROUTER_ENTRY_KEY 0xFFFFFFFF
115 #define INVALID_ROUTER_ENTRY_MASK 0x00000000
118 #define INVALID_ROUTER_ENTRY_ROUTE 0xFF000000
121 #define APP_ID_MASK_FROM_FREE 0x000000FF
124 #define APP_ID_OFFSET_FROM_FREE 24
127 #define N_BASIC_SYSTEM_ROUTER_ENTRIES 1
130 #define N_USABLE_ROUTER_ENTRIES (N_ROUTER_ENTRIES - N_BASIC_SYSTEM_ROUTER_ENTRIES)
137 #define TDMA_WAIT_PERIOD 0
140 #define ROUTER_INITIAL_TIMEOUT 0x4f
143 #define TICK_PERIOD 10
146 #define PKT_QUEUE_SIZE 4096
149 #define ROUTER_TIMEOUT_MAX 0xFF
227 typedef struct data_in_data_items {
242 POSITION_OF_NO_MISSING_SEQ_PACKETS = 2,
243 START_OF_MISSING_MORE = 2,
244 START_OF_MISSING_SEQ_NUMS = 3,
293 uint reinjection_base_mc_key;
299 DATA_SPEED_UP_OUT_PORT = 5,
548 static vcpu_t *
const _sark_virtual_processor_info = (vcpu_t *) SV_VCPU;
573 _sark_virtual_processor_info[sark.virt_cpu].user1 =
transaction_id;
580 return sark_xalloc(sv->sdram_heap, size, 0,
581 ALLOC_LOCK | ALLOC_ID | (sark_vec->app_id << 8));
587 sark_xfree(sv->sdram_heap,
data,
588 ALLOC_LOCK | ALLOC_ID | (sark_vec->app_id << 8));
594 return sark_heap_max(sv->sdram_heap, ALLOC_LOCK);
601 sdp_msg_t *shm_msg = (sdp_msg_t *) sark.vcpu->mbox_ap_msg;
602 sdp_msg_t *msg = sark_msg_get();
604 sark_msg_cpy(msg, shm_msg);
606 sark_shmsg_free(shm_msg);
607 sark.vcpu->mbox_ap_cmd = SHM_IDLE;
637 .cc_tx_not_full =
true
645 .cc_tx_not_full =
true
663 uint cpsr = cpu_fiq_disable();
668 cpu_int_restore(cpsr);
674 cpu_int_restore(cpsr);
691 .route = pkt->
hdr.route
697 if (control.payload) {
716 uint cpsr = cpu_fiq_disable();
727 cpu_int_restore(cpsr);
733 cpu_int_restore(cpsr);
747 static inline void extract_dropped_packet_details(
754 __builtin_popcount(rtr_dump_outputs.
processor);
758 if (rtr_dump_outputs.
link > 0) {
763 __builtin_popcount(rtr_dump_outputs.
link);
793 extract_dropped_packet_details(rtr_dump_outputs);
800 uint cpsr = cpu_fiq_disable();
820 cpu_int_restore(cpsr);
823 extract_dropped_packet_details(rtr_dump_outputs);
831 if (
config->multicast_flag == 1) {
838 if (
config->point_to_point_flag == 1) {
845 if (
config->fixed_route_flag == 1) {
852 if (
config->nearest_neighbour_flag == 1) {
859 "[INFO] Setting reinject mc to %d\n[INFO] Setting reinject pp to %d\n"
860 "[INFO] Setting reinject fr to %d\n[INFO] Setting reinject nn to %d\n",
890 #ifdef DEBUG_REINJECTOR
891 io_printf(IO_BUF,
"[DEBUG] setting router timeouts via sdp\n");
894 msg->cmd_rc = RC_ARG;
914 #ifdef DEBUG_REINJECTOR
915 io_printf(IO_BUF,
"[DEBUG] setting router emergency timeouts via sdp\n");
918 msg->cmd_rc = RC_ARG;
942 "[INFO] Setting reinject mc to %d\n[INFO] Setting reinject pp to %d\n"
943 "[INFO] Setting reinject fr to %d\n[INFO] Setting reinject nn to %d\n",
961 data->router_timeout = control.begin_emergency_wait_time;
962 data->router_emergency_timeout = control.drop_wait_time;
974 data->packet_types_reinjected = 0;
977 for (
int i = 0; i < 4; i++) {
978 data->packet_types_reinjected |= (values_to_check[i] << i);
1001 msg->cmd_rc = RC_OK;
1017 .router_dump =
false
1022 msg->cmd_rc = RC_OK;
1029 uint cpsr = cpu_fiq_disable();
1034 cpu_int_restore(cpsr);
1047 msg->cmd_rc = RC_OK;
1056 switch (msg->cmd_rc) {
1057 #ifdef DEBUG_REINJECTOR
1058 io_printf(IO_BUF,
"[DEBUG] seq %d\n", msg->seq);
1061 #ifdef DEBUG_REINJECTOR
1062 io_printf(IO_BUF,
"[DEBUG] router timeout\n");
1066 #ifdef DEBUG_REINJECTOR
1067 io_printf(IO_BUF,
"[DEBUG] router emergency timeout\n");
1071 #ifdef DEBUG_REINJECTOR
1072 io_printf(IO_BUF,
"[DEBUG] router set packet type\n");
1076 #ifdef DEBUG_REINJECTOR
1077 io_printf(IO_BUF,
"[DEBUG] router get status\n");
1081 #ifdef DEBUG_REINJECTOR
1082 io_printf(IO_BUF,
"[DEBUG] router reset\n");
1086 #ifdef DEBUG_REINJECTOR
1087 io_printf(IO_BUF,
"[DEBUG] router exit\n");
1091 #ifdef DEBUG_REINJECTOR
1092 io_printf(IO_BUF,
"[DEBUG] router clear\n");
1098 msg->cmd_rc = RC_ARG;
1108 .interrupt_enable =
false
1154 rtr_entry_t router_entry;
1159 if (rtr_mc_get(entry_id, &router_entry) &&
1162 rtr_free(entry_id, 1);
1165 #ifdef DEBUG_DATA_IN
1166 io_printf(IO_BUF,
"[DEBUG] max free block is %d\n", rtr_alloc_max());
1173 #ifdef DEBUG_DATA_IN
1174 io_printf(IO_BUF,
"[DEBUG] Wrote %u words\n",
1188 #ifdef DEBUG_DATA_IN
1189 io_printf(IO_BUF,
"[DEBUG] Setting write address to 0x%08x\n",
data);
1200 io_printf(IO_BUF,
"[ERROR] Write address not set when write data received!\n");
1201 rt_error(RTE_SWERR);
1237 "[WARNING] failed to recognise multicast packet key 0x%08x\n",
1250 #ifdef DEBUG_DATA_IN
1251 io_printf(IO_BUF,
"[DEBUG] Writing %u router entries\n", n_entries);
1253 if (n_entries == 0) {
1256 uint start_entry_id = rtr_alloc_id(n_entries, sark_app_id());
1257 if (start_entry_id == 0) {
1259 "[ERROR] Received error with requesting %u router entries.\n",
1261 rt_error(RTE_SWERR);
1264 for (uint idx = 0; idx < n_entries; idx++) {
1270 #ifdef DEBUG_DATA_IN
1273 "[DEBUG] Setting key %08x, mask %08x, route %08x for entry %u\n",
1274 sdram_address[idx].key, sdram_address[idx].
mask,
1275 sdram_address[idx].route, idx + start_entry_id);
1278 if (rtr_mc_set(idx + start_entry_id, sdram_address[idx].key,
1279 sdram_address[idx].
mask, sdram_address[idx].route) != 1) {
1280 io_printf(IO_BUF,
"[WARNING] failed to write router entry %d, "
1281 "with key %08x, mask %08x, route %08x\n",
1282 idx + start_entry_id, sdram_address[idx].key,
1283 sdram_address[idx].
mask, sdram_address[idx].route);
1292 rtr_entry_t router_entry;
1296 (void) rtr_mc_get(entry_id, &router_entry);
1327 #ifdef DEBUG_DATA_IN
1328 io_printf(IO_BUF,
"[INFO] Loading system routes\n");
1342 #ifdef DEBUG_DATA_IN
1343 io_printf(IO_BUF,
"[INFO] Loading application routes\n");
1356 switch (msg->cmd_rc) {
1358 #ifdef DEBUG_DATA_IN
1359 io_printf(IO_BUF,
"[INFO] Saving application router entries from router\n");
1362 msg->cmd_rc = RC_OK;
1366 msg->cmd_rc = RC_OK;
1371 #ifdef DEBUG_DATA_IN
1373 "[WARNING] Already loaded system router; ignoring but replying\n");
1375 msg->cmd_rc = RC_OK;
1380 msg->cmd_rc = RC_OK;
1385 "[WARNING] Received unknown SDP packet in data in speed up port"
1386 " with command id %d\n", msg->cmd_rc);
1387 msg->cmd_rc = RC_ARG;
1402 TX_NOT_FULL_MASK = 0x10000000
1433 uint32_t current_dma_pointer, uint32_t n_elements_to_send,
1434 uint32_t first_packet_key, uint32_t second_packet_key) {
1436 for (uint i = 0; i < n_elements_to_send; i++) {
1443 first_packet_key = second_packet_key;
1461 uint32_t dma_tag,
void *source,
void *destination, uint n_words) {
1469 .length_words = n_words
1480 uint32_t dma_tag, uint32_t offset, uint32_t items_to_read) {
1524 items_read_this_time += 2;
1531 uint32_t next_position_in_store =
1544 key_to_transmit, second_key_to_transmit);
1547 key_to_transmit, second_key_to_transmit);
1566 uint32_t
data[], uint length, uint32_t start_offset) {
1568 i < length; i++, j++) {
1570 #ifdef DEBUG_DATA_OUT
1572 io_printf(IO_BUF,
"[WARNING] Storing bad seq num. %d %d\n",
1590 uint32_t
data[], uint length,
bool first) {
1591 uint32_t start_reading_offset = START_OF_MISSING_MORE;
1594 data[POSITION_OF_NO_MISSING_SEQ_PACKETS];
1596 uint32_t size_of_data =
1613 "[ERROR] Can't allocate SDRAM for missing seq nums\n");
1614 rt_error(RTE_SWERR);
1616 #ifdef DEBUG_DATA_OUT
1617 io_printf(IO_BUF,
"[DEBUG] Activate bacon protocol!\n");
1626 start_reading_offset = START_OF_MISSING_SEQ_NUMS;
1631 data, length, start_reading_offset);
1633 #ifdef DEBUG_DATA_OUT
1635 io_printf(IO_BUF,
"[WARNING] Unable to save missing sequence number\n");
1675 uint32_t left_over_portion =
1707 #ifdef DEBUG_DATA_OUT
1710 "[WARNING] Got some bad seq num here; max is %d, got %d\n",
1727 #ifdef DEBUG_DATA_OUT
1728 io_printf(IO_BUF,
"[INFO] Need to figure what to do here\n");
1750 "[WARNING] received start message with unexpected "
1751 "transaction id %d; mine is %d\n",
1766 uint32_t bytes_to_read_write = message->
length;
1777 bytes_to_read_write /
sizeof(uint);
1791 "[WARNING] received data from a different transaction for "
1792 "start of missing. expected %d got %d\n",
1799 #ifdef DEBUG_DATA_OUT
1800 io_printf(IO_BUF,
"[INFO] forcing start of retransmission packet\n");
1815 "[WARNING] received data from different transaction for "
1816 "more missing; expected %d, got %d\n",
1849 "[WARNING] received data from different transaction for "
1850 "clear; expected %d, got %d\n",
1854 #ifdef DEBUG_DATA_OUT
1855 io_printf(IO_BUF,
"[INFO] data out clear\n");
1860 io_printf(IO_BUF,
"[WARNING] Received unknown SDP packet: %d\n",
1893 io_printf(IO_BUF,
"[ERROR] Invalid DMA callback port: %d\n",
1895 rt_error(RTE_SWERR);
1926 void __real_sark_int(
void *pc);
1929 void __wrap_sark_int(
void *pc) {
1931 if (sark.vcpu->mbox_ap_cmd != SHM_MSG) {
1933 __real_sark_int(pc);
1943 .select = 1 << sark.phys_cpu,
1949 switch ((msg->dest_port & PORT_MASK) >> PORT_SHIFT) {
1952 while (!sark_msg_send(msg, 10)) {
1953 #ifdef DEBUG_REINJECTOR
1954 io_printf(IO_BUF,
"[DEBUG] timeout when sending reinjection reply\n");
1959 case DATA_SPEED_UP_OUT_PORT:
1966 while (!sark_msg_send(msg, 10)) {
1967 #ifdef DEBUG_DATA_IN
1968 io_printf(IO_BUF,
"[DEBUG] timeout when sending speedup ctl reply\n");
1974 io_printf(IO_BUF,
"[WARNING] unexpected port %d\n",
1975 (msg->dest_port & PORT_MASK) >> PORT_SHIFT);
1977 "[INFO] from:%04x:%02x to:%04x:%02x cmd:%04x len:%d iam:%04x\n",
1978 msg->srce_addr, msg->srce_port,
1979 msg->dest_addr, msg->dest_port,
1980 msg->cmd_rc, msg->length,
my_addr);
2024 #ifdef DEBUG_DATA_OUT
2026 "[INFO] new seq key = %d, first data key = %d, transaction id key = %d, "
2027 "end flag key = %d, basic_data_key = %d\n",
2043 .clear_done_int =
true,
2044 .clear_timeout_int =
true,
2045 .clear_write_buffer_int =
true
2051 .clear_done_int =
true
2056 .transfer2_done_interrupt =
true,
2057 .timeout_interrupt =
true,
2058 .crc_error_interrupt =
true,
2059 .tcm_error_interrupt =
true,
2060 .axi_error_interrupt =
true,
2061 .user_abort_interrupt =
true,
2062 .soft_reset_interrupt =
true,
2063 .write_buffer_error_interrupt =
true
2073 "[ERROR] failed to allocate SDRAM for application mc router entries\n");
2074 rt_error(RTE_SWERR);
2105 sark_cpu_state(CPU_STATE_RUN);
2109 rt_error(RTE_SWERR);
2128 .router_dump =
true,
2131 .dma_timeout =
true,
2151 .interrupt_enable =
true,
2152 .periodic_mode =
true,
2156 io_printf(IO_BUF,
"[INFO] extra monitor initialisation complete\n");
@ DMA
DMA processing is lowest priority.
@ SDP
Responding to communications from host is next highest.
callback_priorities
values for the priority for each callback
Data type definitions for SpiNNaker Neuron-modelling.
uint32_t * address_t
A generic pointer to a word.
Common definitions for the non-SCAMP system binaries.
static void initialise_reinjection_mc_api(uint32_t base_mc_key)
sets up the multicast keys for the reinjection multicast API
static uint reinject_clear_mc_key
the multicast key used for clear reinjector queue to all extra monitors
@ CMD_DPRI_SET_ROUTER_EMERGENCY_TIMEOUT
Set the router's wait2 timeout.
@ CMD_DPRI_RESET_COUNTERS
Reset the reinjection counters.
@ CMD_DPRI_SET_ROUTER_TIMEOUT
Set the router's wait1 timeout.
@ CMD_DPRI_GET_STATUS
Get the status of the reinjector.
@ CMD_DPRI_EXIT
Stop doing reinjection.
@ CMD_DPRI_CLEAR
Clear the reinjection queue.
@ CMD_DPRI_SET_PACKET_TYPES
Set what packet types are reinjected.
static uint reinject_emergency_timeout_mc_key
the multicast key used for emergency timeouts to all extra monitors
static uint reinject_timeout_mc_key
the multicast key used for basic timeouts to all extra monitors
#define TRANSACTION_CAP
Flag for cap on transaction id.
static void reflect_sdp_message(sdp_msg_t *msg, uint body_length)
Updates an SDP message so its content (a response to the message) goes back to where the message came...
Data Specification region access API.
static void * data_specification_get_region(uint32_t region, data_specification_metadata_t *ds_regions)
Gets the address of a region.
data_specification_metadata_t * data_specification_get_data_address(void)
Gets the location of the data for this core using the user0 entry of the SARK VCPU structure.
bool data_specification_read_header(data_specification_metadata_t *ds_regions)
Reads the header from the address given and checks if the parameters are of the correct values.
static uint32_t data[ITEMS_PER_DATA_PACKET]
functionality_to_port_num_map
values for port numbers this core will respond to
@ REINJECTION_PORT
Reinjection control messages.
@ DATA_SPEED_UP_IN_PORT
Data Speed Up Inbound messages.
static uint32_t transaction_id
The Data In transaction ID. Used to distinguish streams of packets.
static uint32_t mask
Mask for keys to determine if the key matches the key_space.
The configuration parameters for the application.
uint16_t length
Length (measured from flags field start)
uint32_t data[ITEMS_PER_DATA_PACKET]
User data (272 bytes when no SCP header)
@ ITEMS_PER_DATA_PACKET
How many multicast packets are to be received per SDP packet.
An SDP message with purely data, no SCP header.
static void wait_for_interrupt(void)
Wait for any interrupt to occur.