2010-08-10 15:20:27 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2010 Stefan Lankes, Chair for Operating Systems,
|
|
|
|
* RWTH Aachen University
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
2011-04-13 11:03:34 -07:00
|
|
|
* WITHOUT WARRANTIES OR COND */
|
2010-08-10 15:20:27 +00:00
|
|
|
|
|
|
|
#include <metalsvm/stdio.h>
|
2010-11-26 05:33:02 +00:00
|
|
|
#include <metalsvm/errno.h>
|
2011-03-25 20:28:43 +01:00
|
|
|
#include <metalsvm/processor.h>
|
|
|
|
#include <metalsvm/errno.h>
|
2010-08-10 15:20:27 +00:00
|
|
|
#include <asm/io.h>
|
2011-04-24 07:27:27 -07:00
|
|
|
#include <asm/irqflags.h>
|
2011-05-17 08:13:20 -07:00
|
|
|
#include <asm/irq.h>
|
2011-04-23 00:13:12 -07:00
|
|
|
#ifdef CONFIG_ROCKCREEK
|
2011-04-19 07:17:51 -07:00
|
|
|
#include <asm/RCCE.h>
|
2011-05-17 08:13:20 -07:00
|
|
|
#include <asm/RCCE_lib.h>
|
2011-04-19 07:17:51 -07:00
|
|
|
#include <asm/iRCCE.h>
|
2011-03-26 00:55:20 -07:00
|
|
|
#include <asm/SCC_API.h>
|
2011-04-23 00:13:12 -07:00
|
|
|
#include <asm/icc.h>
|
2011-08-16 03:29:54 -07:00
|
|
|
#include <asm/svm.h>
|
2011-11-07 11:25:54 -08:00
|
|
|
#include <asm/limits.h>
|
2010-08-10 15:20:27 +00:00
|
|
|
|
2011-08-09 14:54:30 -07:00
|
|
|
#define IRQ_STATUS 0xD000
|
|
|
|
#define IRQ_MASK 0xD200
|
|
|
|
#define IRQ_RESET 0xD400
|
|
|
|
#define IRQ_REQUEST 0xD600
|
|
|
|
#define IRQ_CONFIG 0xD800
|
|
|
|
|
2011-10-09 13:04:13 -07:00
|
|
|
#include <net/rckemac.h>
|
2011-06-29 23:00:15 +02:00
|
|
|
|
2011-04-13 11:03:34 -07:00
|
|
|
bootinfo_t* bootinfo = (bootinfo_t*) SCC_BOOTINFO;
|
2011-04-13 07:04:50 -07:00
|
|
|
|
2011-04-05 23:43:44 -07:00
|
|
|
/* PSE bit for Pentium+ equals MPE (message buffer enable) flag in RCK! So, use it to create _PAGE_MPB symbol... */
|
|
|
|
#define _CR4_MPE 0x00000800
|
|
|
|
|
2011-04-24 07:27:27 -07:00
|
|
|
/* maximal number of SCC's cores */
|
|
|
|
#define MAX_SCC_CORES (NUM_ROWS*NUM_COLS*NUM_CORES)
|
|
|
|
|
2011-03-26 00:55:20 -07:00
|
|
|
/*
|
2011-04-05 01:55:02 -07:00
|
|
|
* This is the modified MPB program, which is part of the RCCE distribution (src/mpb.c).
|
|
|
|
*
|
|
|
|
* This function clears the local MPB and resets the test&set register.
|
2011-03-26 00:55:20 -07:00
|
|
|
*/
|
2011-04-05 01:55:02 -07:00
|
|
|
static int scc_clear(void)
|
2011-03-26 00:55:20 -07:00
|
|
|
{
|
|
|
|
int tmp, x, y, z, offset;
|
2011-04-19 07:17:51 -07:00
|
|
|
|
|
|
|
// Initialize API
|
|
|
|
InitAPI(0);
|
2011-04-05 01:55:02 -07:00
|
|
|
|
2011-03-26 00:55:20 -07:00
|
|
|
// Find out who I am...
|
|
|
|
tmp=ReadConfigReg(CRB_OWN+MYTILEID);
|
|
|
|
x=(tmp>>3) & 0x0f; // bits 06:03
|
|
|
|
y=(tmp>>7) & 0x0f; // bits 10:07
|
|
|
|
z=(tmp ) & 0x07; // bits 02:00
|
|
|
|
|
|
|
|
// Allocate Message Passing Buffer
|
|
|
|
t_vcharp MPB;
|
|
|
|
MPBalloc(&MPB, x, y, z, 1);
|
|
|
|
if (!MPB) {
|
|
|
|
kprintf("Unable to allocate MPB for core %d of Tile x=%d, y= %d! Exiting.\n", z, x, y);
|
|
|
|
return 255;
|
|
|
|
}
|
|
|
|
|
|
|
|
// zap own MPB
|
|
|
|
for (offset=0; offset < 0x2000; offset+=8)
|
|
|
|
*(volatile unsigned long long int*)(MPB+offset) = 0;
|
|
|
|
|
|
|
|
// Clear test&set register write. Next read-access will read "1" (lock granted).
|
|
|
|
SetConfigReg(CRB_ADDR(x,y)+((z)?LOCK1:LOCK0), 1);
|
|
|
|
|
2011-04-19 07:17:51 -07:00
|
|
|
// frees Message Passing Buffer
|
|
|
|
MPBunalloc(&MPB);
|
|
|
|
|
2011-03-26 00:55:20 -07:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2011-10-09 13:04:13 -07:00
|
|
|
static inline void icc_mail_check_tag(iRCCE_MAIL_HEADER* mail) {
|
|
|
|
char* recv_buffer;
|
|
|
|
|
|
|
|
if(BUILTIN_EXPECT(!mail, 0))
|
|
|
|
return;
|
|
|
|
|
|
|
|
switch( mail->tag ) {
|
|
|
|
case iRCCE_ANYLENGTH:
|
|
|
|
recv_buffer = (char*)kmalloc( mail->size );
|
|
|
|
iRCCE_irecv(recv_buffer, mail->size, mail->source, NULL);
|
|
|
|
break;
|
|
|
|
case PING_REQ:
|
|
|
|
iRCCE_mail_send(0, PING_RESP, 0, NULL, mail->source);
|
|
|
|
break;
|
2011-11-16 03:12:09 -08:00
|
|
|
case SVM_REQ:
|
2011-10-09 13:04:13 -07:00
|
|
|
svm_emit_page(((size_t*) mail->payload)[1], ((size_t*) mail->payload)[0]);
|
|
|
|
break;
|
2011-11-07 11:25:54 -08:00
|
|
|
case SVM_RESP:
|
|
|
|
break;
|
2011-10-09 13:04:13 -07:00
|
|
|
case NOISE:
|
|
|
|
// kprintf( "XXX " );
|
|
|
|
default:
|
|
|
|
// kprintf( "icc_mail_check_tag: uknown tag id %d\n", mail->tag );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void icc_handler(struct state *s)
|
2011-05-17 08:13:20 -07:00
|
|
|
{
|
|
|
|
// reset appropriate bit in the core configuration register
|
2011-10-09 13:04:13 -07:00
|
|
|
iRCCE_MAIL_HEADER* header = NULL;
|
|
|
|
int tmp, source;
|
|
|
|
uint32_t status_low, status_high, status;
|
2011-10-10 22:03:12 +02:00
|
|
|
static int z = -1;
|
2011-10-09 13:04:13 -07:00
|
|
|
volatile static uint32_t* status_addr;
|
|
|
|
volatile static uint32_t* reset_addr;
|
|
|
|
|
2011-10-10 22:03:12 +02:00
|
|
|
if (z < 0) {
|
|
|
|
z = Z_PID(RC_MY_COREID);
|
|
|
|
status_addr = (volatile uint32_t*) (FPGA_BASE + IRQ_STATUS + RC_MY_COREID * 8);
|
|
|
|
reset_addr = (volatile uint32_t*) (FPGA_BASE + IRQ_RESET + RC_MY_COREID * 8);
|
2011-10-09 13:04:13 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
status_low = status_addr[0];
|
|
|
|
status_high = status_addr[1];
|
2011-05-17 08:13:20 -07:00
|
|
|
|
2011-07-04 13:25:50 -07:00
|
|
|
#ifdef CONFIG_LWIP
|
2011-10-09 13:04:13 -07:00
|
|
|
rckemacif_handler(s, status_low);
|
2011-07-04 13:25:50 -07:00
|
|
|
#endif
|
2011-06-29 23:00:15 +02:00
|
|
|
|
2011-10-09 21:03:31 -07:00
|
|
|
if ((status_low >> 6) || status_high)
|
|
|
|
{
|
|
|
|
/* determine interrupt sources */
|
|
|
|
status = status_low;
|
|
|
|
status >>= 6; // shift emac bits
|
|
|
|
|
|
|
|
for (source=0; status!=0; status >>= 1, ++source) {
|
2011-10-10 22:03:12 +02:00
|
|
|
if (((status & 0x1) != 0) && (RC_RCCEID[source] >= 0))
|
|
|
|
iRCCE_mail_check(RC_RCCEID[source]);
|
2011-10-09 13:04:13 -07:00
|
|
|
}
|
|
|
|
|
2011-10-09 21:03:31 -07:00
|
|
|
for (source=26, status=status_high; status!=0; status >>= 1, ++source) {
|
2011-10-10 22:03:12 +02:00
|
|
|
if (((status & 0x1) != 0) && (RC_RCCEID[source] >= 0))
|
|
|
|
iRCCE_mail_check(RC_RCCEID[source]);
|
2011-10-09 13:04:13 -07:00
|
|
|
}
|
2011-10-09 21:03:31 -07:00
|
|
|
} else iRCCE_mail_check(iRCCE_MAILBOX_ALL);
|
2011-10-09 13:04:13 -07:00
|
|
|
|
2011-05-17 08:13:20 -07:00
|
|
|
tmp=ReadConfigReg(CRB_OWN + (z==0 ? GLCFG0 : GLCFG1));
|
|
|
|
tmp &= ~2;
|
|
|
|
SetConfigReg(CRB_OWN + (z==0 ? GLCFG0 : GLCFG1), tmp);
|
2011-10-09 13:04:13 -07:00
|
|
|
|
|
|
|
/* Reset */
|
|
|
|
if (status_low)
|
|
|
|
reset_addr[0] = status_low;
|
|
|
|
if (status_high)
|
|
|
|
reset_addr[1] = status_high;
|
|
|
|
|
|
|
|
/* empty mail queue */
|
|
|
|
while( iRCCE_mail_recv(&header) == iRCCE_SUCCESS ) {
|
|
|
|
icc_mail_check_tag(header);
|
2011-10-21 14:17:54 -07:00
|
|
|
iRCCE_mail_release(&header);
|
2011-10-09 13:04:13 -07:00
|
|
|
}
|
2011-05-17 08:13:20 -07:00
|
|
|
}
|
|
|
|
|
2011-04-23 00:13:12 -07:00
|
|
|
int icc_init(void)
|
2010-08-10 15:20:27 +00:00
|
|
|
{
|
2011-05-17 08:13:20 -07:00
|
|
|
int i, z, tmp;
|
2011-04-19 07:17:51 -07:00
|
|
|
uint64_t start, end, ticks, freq = 533;
|
2011-08-10 22:44:16 -07:00
|
|
|
uint32_t cr4;
|
2012-09-11 23:50:39 -07:00
|
|
|
uint32_t msg;
|
2011-04-19 07:17:51 -07:00
|
|
|
|
|
|
|
kputs("Initialize Rock Creek!\n");
|
|
|
|
|
|
|
|
/* Enable Messagepassing in CR4 */
|
|
|
|
cr4 = read_cr4();
|
|
|
|
cr4 = cr4 | _CR4_MPE;
|
|
|
|
write_cr4(cr4);
|
2011-03-31 12:50:42 -07:00
|
|
|
|
2011-04-13 07:04:50 -07:00
|
|
|
kprintf("address of the initrd: 0x%x\n", bootinfo->addr);
|
|
|
|
kprintf("size of the initrd: %d\n", bootinfo->size);
|
|
|
|
kprintf("rcce argc = %d\n", bootinfo->argc);
|
|
|
|
for(i=0; i<bootinfo->argc; i++)
|
|
|
|
kprintf("rcce argv[%d] = %s\n", i, bootinfo->argv[i]);
|
|
|
|
|
2011-04-19 07:17:51 -07:00
|
|
|
if (bootinfo->argc >= 3)
|
|
|
|
freq = atoi(bootinfo->argv[2]);
|
|
|
|
|
|
|
|
kputs("Reset SCC!\n");
|
|
|
|
scc_clear();
|
|
|
|
kputs("Wait some time...\n");
|
|
|
|
mb();
|
|
|
|
start = rdtsc();
|
|
|
|
do {
|
|
|
|
mb();
|
|
|
|
end = rdtsc();
|
|
|
|
ticks = end > start ? end - start : start - end;
|
2011-04-19 08:36:58 -07:00
|
|
|
} while(ticks*TIMER_FREQ < 300ULL*freq*1000000ULL);
|
2011-04-19 07:17:51 -07:00
|
|
|
|
2011-04-13 07:04:50 -07:00
|
|
|
if (RCCE_init(&bootinfo->argc, &bootinfo->argv) != RCCE_SUCCESS)
|
2011-03-25 20:28:43 +01:00
|
|
|
return -ENODEV;
|
2011-04-19 07:17:51 -07:00
|
|
|
if (iRCCE_init() != iRCCE_SUCCESS)
|
|
|
|
return -ENODEV;
|
2011-03-25 20:28:43 +01:00
|
|
|
|
2011-04-19 08:36:58 -07:00
|
|
|
// enable additional outputs
|
2011-08-19 00:11:36 -07:00
|
|
|
//RCCE_debug_set(RCCE_DEBUG_ALL);
|
2011-04-19 08:36:58 -07:00
|
|
|
|
2011-10-10 22:03:12 +02:00
|
|
|
kprintf("Got rank %d of %d ranks\n", RCCE_IAM, RCCE_NP);
|
2010-08-10 15:20:27 +00:00
|
|
|
|
2011-04-19 07:17:51 -07:00
|
|
|
RCCE_barrier(&RCCE_COMM_WORLD);
|
|
|
|
|
|
|
|
kputs("RCCE test...\t");
|
2012-09-11 23:50:39 -07:00
|
|
|
if (!RCCE_IAM)
|
2011-04-19 07:17:51 -07:00
|
|
|
msg = 0x4711;
|
2012-09-11 23:50:39 -07:00
|
|
|
if ((RCCE_bcast((char*) &msg, sizeof(msg), 0, RCCE_COMM_WORLD) == RCCE_SUCCESS) && (msg == 0x4711))
|
2011-04-19 07:17:51 -07:00
|
|
|
kprintf("successfull! (0x%x)\n", msg);
|
|
|
|
else
|
|
|
|
kprintf("failed! (0x%x)\n", msg);
|
2011-06-28 07:31:23 +02:00
|
|
|
|
2011-05-17 08:13:20 -07:00
|
|
|
// reset INTR/LINT0 flag
|
2011-10-10 22:03:12 +02:00
|
|
|
z = Z_PID(RC_MY_COREID);
|
2011-05-17 08:13:20 -07:00
|
|
|
tmp=ReadConfigReg(CRB_OWN + (z==0 ? GLCFG0 : GLCFG1));
|
2011-08-23 06:51:25 -07:00
|
|
|
tmp &= ~(1 << GLCFG_XINTR_BIT);
|
2011-05-17 08:13:20 -07:00
|
|
|
SetConfigReg(CRB_OWN + (z==0 ? GLCFG0 : GLCFG1), tmp);
|
|
|
|
|
2011-08-23 06:51:25 -07:00
|
|
|
#if 0
|
|
|
|
// disable L2 cache
|
|
|
|
z = Z_PID(RC_COREID[my_ue]);
|
|
|
|
tmp=ReadConfigReg(CRB_OWN + (z==0 ? L2CFG0 : L2CFG1));
|
|
|
|
tmp |= (1 << L2CFG_WAYDISABLE_BIT);
|
|
|
|
SetConfigReg(CRB_OWN + (z==0 ? L2CFG0 : L2CFG1), tmp);
|
|
|
|
kprintf("set L2CFG to 0x%x\n", (uint32_t) tmp);
|
|
|
|
#endif
|
|
|
|
|
2011-08-27 05:28:03 -07:00
|
|
|
tmp=ReadConfigReg(CRB_OWN + (z==0 ? L2CFG0 : L2CFG1));
|
|
|
|
kputs("In the config registers is the L2 cache ");
|
|
|
|
if (tmp & (1 << L2CFG_WAYDISABLE_BIT))
|
|
|
|
kputs("disabled!\n");
|
|
|
|
else
|
|
|
|
kputs("enabled!\n");
|
|
|
|
|
|
|
|
kputs("In CR0 is caching ");
|
|
|
|
if (read_cr0() & (1 << 30))
|
|
|
|
kputs("disabled!\n");
|
|
|
|
else
|
|
|
|
kputs("enabled!\n");
|
|
|
|
|
|
|
|
kputs("In CR0 is writethrough caching ");
|
|
|
|
if (read_cr0() & (1 << 29))
|
|
|
|
kputs("enabled!\n");
|
|
|
|
else
|
|
|
|
kputs("disabled!\n");
|
|
|
|
|
2011-10-10 22:03:12 +02:00
|
|
|
// set interrupt handler (LINT0)
|
2011-10-09 13:04:13 -07:00
|
|
|
irq_install_handler(124, icc_handler);
|
2011-08-09 14:54:30 -07:00
|
|
|
|
|
|
|
// unmask interrupts
|
2011-10-10 22:03:12 +02:00
|
|
|
volatile uint32_t* irq_mask = (volatile uint32_t*)(FPGA_BASE + IRQ_MASK + RC_COREID[RCCE_IAM]*8);
|
2011-10-10 13:10:50 -07:00
|
|
|
irq_mask[0] = 0x3F;
|
2011-10-09 13:04:13 -07:00
|
|
|
irq_mask[1] = 0x00;
|
2011-08-09 14:54:30 -07:00
|
|
|
|
2011-08-10 00:21:21 -07:00
|
|
|
// set remote interrupts to LINT 0
|
2011-10-10 22:03:12 +02:00
|
|
|
volatile uint32_t* irq_config = (volatile uint32_t*)(FPGA_BASE + IRQ_CONFIG + RC_COREID[RCCE_IAM]*4);
|
2011-10-09 13:04:13 -07:00
|
|
|
irq_config[0] = 0x00;
|
2011-08-10 00:21:21 -07:00
|
|
|
|
2011-10-09 13:04:13 -07:00
|
|
|
kprintf( "irq_mask = 0x%x, 0x%x\n", irq_mask[0], irq_mask[1]);
|
|
|
|
kprintf( "irq_config = 0x%x\n", irq_config[0]);
|
2011-03-25 20:28:43 +01:00
|
|
|
kputs("Now, the SCC is initialized!\n");
|
2010-11-26 05:33:02 +00:00
|
|
|
|
2010-08-10 15:20:27 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2011-05-17 08:13:20 -07:00
|
|
|
int icc_halt(void)
|
|
|
|
{
|
2011-10-09 13:04:13 -07:00
|
|
|
icc_mail_check();
|
2011-10-09 21:03:31 -07:00
|
|
|
//NOP1;
|
2011-08-17 23:32:39 -07:00
|
|
|
|
2011-10-09 21:03:31 -07:00
|
|
|
HALT;
|
2011-05-17 08:13:20 -07:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2011-12-01 05:40:10 -08:00
|
|
|
#define ROUNDS 20000
|
2011-12-14 01:39:55 -08:00
|
|
|
#define CORE_A RC_RCCEID[0] // sender
|
|
|
|
#define CORE_B RC_RCCEID[30] // receiver
|
2011-05-17 08:13:20 -07:00
|
|
|
|
2011-08-10 22:44:16 -07:00
|
|
|
int icc_send_gic_irq(int core_num) {
|
2011-10-10 22:03:12 +02:00
|
|
|
volatile uint32_t* irq_request = (volatile uint32_t*)(FPGA_BASE+IRQ_REQUEST+RC_MY_COREID*8);
|
2011-10-09 13:04:13 -07:00
|
|
|
uint32_t bit_pos;
|
2011-08-16 14:11:26 -07:00
|
|
|
|
2011-10-09 13:04:13 -07:00
|
|
|
if (BUILTIN_EXPECT((core_num < 0) || (core_num > 48), 0))
|
|
|
|
return -EINVAL;
|
|
|
|
|
2011-08-09 14:54:30 -07:00
|
|
|
// determine bit position and set according bit
|
2011-10-09 13:04:13 -07:00
|
|
|
if (RC_COREID[core_num] < 32) {
|
|
|
|
bit_pos = (1 << RC_COREID[core_num]);
|
|
|
|
irq_request[0] = bit_pos;
|
|
|
|
} else {
|
|
|
|
bit_pos = (1 << (RC_COREID[core_num]-32));
|
|
|
|
irq_request[1] = bit_pos;
|
|
|
|
}
|
2011-08-16 14:11:26 -07:00
|
|
|
|
2011-08-01 14:24:46 -07:00
|
|
|
return 0;
|
|
|
|
}
|
2011-05-17 08:13:20 -07:00
|
|
|
|
2011-08-29 01:49:59 -07:00
|
|
|
int icc_mail_ping(void)
|
2011-06-29 12:31:32 -07:00
|
|
|
{
|
2011-04-24 07:27:27 -07:00
|
|
|
uint32_t flags;
|
2011-07-02 09:09:53 -07:00
|
|
|
uint64_t timer = 0;
|
2011-07-01 15:41:41 +02:00
|
|
|
int i;
|
2011-07-23 12:27:08 -07:00
|
|
|
int res;
|
2011-07-01 15:41:41 +02:00
|
|
|
iRCCE_MAIL_HEADER* recv_header = NULL;
|
2011-06-07 12:38:35 +02:00
|
|
|
|
2011-07-23 12:27:08 -07:00
|
|
|
/* leave function if not participating in pingpong */
|
2011-10-10 22:03:12 +02:00
|
|
|
if( (RCCE_IAM != CORE_A) && (RCCE_IAM != CORE_B) ) return -1;
|
2011-07-23 12:27:08 -07:00
|
|
|
|
2011-10-21 14:17:54 -07:00
|
|
|
kprintf( "my rank = %d\n", RCCE_IAM);
|
2011-06-09 04:23:17 -07:00
|
|
|
kprintf( "Hello from mail_ping ... \n" );
|
2011-07-23 12:27:08 -07:00
|
|
|
kprintf( "rounds = %d\n", ROUNDS );
|
|
|
|
|
|
|
|
|
2011-06-08 05:07:22 -07:00
|
|
|
// disable interrupts
|
2011-04-24 07:27:27 -07:00
|
|
|
flags = irq_nested_disable();
|
2011-07-01 15:41:41 +02:00
|
|
|
|
|
|
|
for( i=0; i<ROUNDS+1; ++i ) {
|
2011-07-23 12:27:08 -07:00
|
|
|
/* senders part */
|
2011-10-10 22:03:12 +02:00
|
|
|
if( RCCE_IAM == CORE_A ) {
|
2011-07-01 15:41:41 +02:00
|
|
|
/* send ping request */
|
2011-07-23 12:27:08 -07:00
|
|
|
iRCCE_mail_send(0, PING_REQ, 0, NULL, CORE_B);
|
2011-08-21 11:38:09 -07:00
|
|
|
|
2011-07-01 15:41:41 +02:00
|
|
|
/* wait for response */
|
|
|
|
do {
|
2011-12-14 01:39:55 -08:00
|
|
|
res = iRCCE_mail_check(iRCCE_MAILBOX_ALL); //CORE_B);
|
2011-08-21 11:38:09 -07:00
|
|
|
} while( res != iRCCE_SUCCESS );
|
|
|
|
|
2011-07-01 15:41:41 +02:00
|
|
|
/* release mail */
|
2011-08-28 07:09:04 -07:00
|
|
|
iRCCE_mail_recv(&recv_header);
|
2011-07-01 15:41:41 +02:00
|
|
|
iRCCE_mail_release(&recv_header);
|
|
|
|
}
|
2011-07-23 12:27:08 -07:00
|
|
|
/* receivers part */
|
2011-07-01 15:41:41 +02:00
|
|
|
else {
|
|
|
|
/* wait for request */
|
|
|
|
do {
|
2011-12-14 01:39:55 -08:00
|
|
|
res = iRCCE_mail_check(iRCCE_MAILBOX_ALL); //CORE_A);
|
2011-08-21 11:38:09 -07:00
|
|
|
} while( res != iRCCE_SUCCESS );
|
2011-07-01 15:41:41 +02:00
|
|
|
|
2011-08-28 07:09:04 -07:00
|
|
|
/* check mail */
|
|
|
|
res = iRCCE_mail_recv(&recv_header);
|
|
|
|
icc_mail_check_tag(recv_header);
|
2011-05-31 04:29:20 -07:00
|
|
|
|
2011-07-01 15:41:41 +02:00
|
|
|
/* release mail */
|
|
|
|
iRCCE_mail_release(&recv_header);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* start timer in first round */
|
|
|
|
if( i == 0 ) timer = rdtsc();
|
2011-04-24 07:27:27 -07:00
|
|
|
|
2011-07-01 15:41:41 +02:00
|
|
|
}
|
2011-06-07 12:38:35 +02:00
|
|
|
|
2011-07-01 15:41:41 +02:00
|
|
|
/* stop timer */
|
2011-06-07 12:38:35 +02:00
|
|
|
timer = rdtsc() - timer;
|
2011-04-24 07:27:27 -07:00
|
|
|
|
|
|
|
|
2011-10-10 22:03:12 +02:00
|
|
|
if( RCCE_IAM == CORE_A ) {
|
2011-07-23 12:27:08 -07:00
|
|
|
kprintf( "timer = %ld\n", timer );
|
2011-08-28 07:09:04 -07:00
|
|
|
kprintf( "mail_pingpong needs in average %d ns (%d ticks)!\n",
|
2011-08-29 01:54:59 -07:00
|
|
|
timer*1000/(2*ROUNDS*get_cpu_frequency()), timer/(2*ROUNDS) );
|
2011-06-07 12:38:35 +02:00
|
|
|
}
|
2011-05-17 08:13:20 -07:00
|
|
|
|
2011-04-24 07:27:27 -07:00
|
|
|
irq_nested_enable(flags);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2011-08-29 01:49:59 -07:00
|
|
|
int icc_mail_ping_irq(void)
|
2011-04-24 07:27:27 -07:00
|
|
|
{
|
2011-08-24 04:25:10 -07:00
|
|
|
kprintf( "Hello from mail_ping_irq ... \n" );
|
2011-08-15 09:56:46 -07:00
|
|
|
/* return if not core A */
|
2011-10-10 22:03:12 +02:00
|
|
|
if( RCCE_IAM != CORE_A ) return 0;
|
2011-08-24 04:25:10 -07:00
|
|
|
|
2011-07-02 17:51:25 +02:00
|
|
|
uint32_t flags;
|
2011-07-02 09:09:53 -07:00
|
|
|
uint64_t timer = 0;
|
2011-07-02 17:51:25 +02:00
|
|
|
int i;
|
2011-07-18 01:14:18 -07:00
|
|
|
int res;
|
2011-07-02 17:51:25 +02:00
|
|
|
iRCCE_MAIL_HEADER* recv_header = NULL;
|
|
|
|
|
2011-10-21 14:17:54 -07:00
|
|
|
kprintf( "my rank = %d\n", RCCE_IAM );
|
2011-08-21 11:38:09 -07:00
|
|
|
kprintf( "rem_rank = %d\n", CORE_B );
|
2011-07-23 12:27:08 -07:00
|
|
|
kprintf( "rounds = %d\n", ROUNDS );
|
2011-08-13 17:14:01 -07:00
|
|
|
|
2011-07-02 17:51:25 +02:00
|
|
|
// disable interrupts
|
|
|
|
flags = irq_nested_disable();
|
2011-08-23 14:45:08 -07:00
|
|
|
|
2011-07-02 17:51:25 +02:00
|
|
|
for( i=0; i<ROUNDS+1; ++i ) {
|
2011-07-18 01:14:18 -07:00
|
|
|
/* send ping request */
|
2011-08-21 11:38:09 -07:00
|
|
|
iRCCE_mail_send(0, PING_REQ, 0, NULL, CORE_B);
|
2011-07-18 01:14:18 -07:00
|
|
|
|
|
|
|
/* send interrupt */
|
2011-08-21 11:38:09 -07:00
|
|
|
icc_send_gic_irq(CORE_B);
|
2011-07-18 01:14:18 -07:00
|
|
|
|
|
|
|
/* wait for response */
|
|
|
|
do {
|
2011-08-21 11:38:09 -07:00
|
|
|
res = iRCCE_mail_check(CORE_B);
|
2011-08-13 17:14:01 -07:00
|
|
|
} while( res != iRCCE_SUCCESS );
|
2011-07-18 01:14:18 -07:00
|
|
|
|
2011-08-23 14:45:08 -07:00
|
|
|
iRCCE_mail_recv(&recv_header);
|
2011-07-18 01:14:18 -07:00
|
|
|
iRCCE_mail_release(&recv_header);
|
2011-08-23 14:45:08 -07:00
|
|
|
|
2011-07-02 17:51:25 +02:00
|
|
|
/* start timer in first round */
|
|
|
|
if( i == 0 ) timer = rdtsc();
|
2011-08-13 17:14:01 -07:00
|
|
|
|
2011-07-02 17:51:25 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* stop timer */
|
|
|
|
timer = rdtsc() - timer;
|
|
|
|
|
2011-08-20 07:09:37 -07:00
|
|
|
kprintf( "timer = %d\n", timer );
|
2011-08-27 02:31:30 -07:00
|
|
|
kprintf( "mail_pingpong needs in average %d nsec (%d ticks)!\n",
|
2011-09-02 13:52:42 -07:00
|
|
|
timer*1000/(2*ROUNDS*get_cpu_frequency()), timer/(2*ROUNDS) );
|
2011-07-18 01:14:18 -07:00
|
|
|
|
2011-07-02 17:51:25 +02:00
|
|
|
irq_nested_enable(flags);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2011-11-07 13:01:57 -08:00
|
|
|
int icc_mail_ping_jitter(void)
|
|
|
|
{
|
2011-12-01 05:40:10 -08:00
|
|
|
kprintf( "Hello from jitter_test ... \n" );
|
2011-11-07 13:01:57 -08:00
|
|
|
/* return if not core A */
|
|
|
|
if( RCCE_IAM != CORE_A ) return 0;
|
|
|
|
|
|
|
|
uint32_t flags;
|
|
|
|
uint64_t timer = 0;
|
|
|
|
uint64_t max = 0;
|
|
|
|
uint64_t min = ULONG_MAX;
|
|
|
|
uint64_t sum = 0;
|
|
|
|
|
|
|
|
int i;
|
|
|
|
int res;
|
|
|
|
iRCCE_MAIL_HEADER* recv_header = NULL;
|
|
|
|
|
|
|
|
kprintf( "my_rank = %d\n", RCCE_IAM );
|
|
|
|
kprintf( "rem_rank = %d\n", CORE_B );
|
|
|
|
kprintf( "rounds = %d\n", ROUNDS );
|
|
|
|
|
|
|
|
// disable interrupts
|
|
|
|
flags = irq_nested_disable();
|
|
|
|
|
|
|
|
for( i=0; i<ROUNDS+1; ++i ) {
|
|
|
|
/* start timer */
|
|
|
|
timer = rdtsc();
|
|
|
|
|
|
|
|
/* send ping request */
|
|
|
|
iRCCE_mail_send(0, PING_REQ, 0, NULL, CORE_B);
|
|
|
|
|
|
|
|
/* send interrupt */
|
|
|
|
icc_send_gic_irq(CORE_B);
|
|
|
|
|
|
|
|
/* wait for response */
|
|
|
|
do {
|
|
|
|
res = iRCCE_mail_check(CORE_B);
|
|
|
|
} while( res != iRCCE_SUCCESS );
|
|
|
|
|
|
|
|
iRCCE_mail_recv(&recv_header);
|
|
|
|
iRCCE_mail_release(&recv_header);
|
|
|
|
|
|
|
|
/* stop timer and update eval values */
|
|
|
|
timer = rdtsc() - timer;
|
|
|
|
if( i > 0 ) {
|
|
|
|
max = ( max < timer )? timer : max;
|
|
|
|
min = ( min > timer )? timer : min;
|
|
|
|
sum += timer;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
kprintf( "Average was: %d nsec\n", sum*1000/(2*ROUNDS*533) );
|
|
|
|
kprintf( "Maximum was: %d nsec\n", max*1000/(2*533) );
|
|
|
|
kprintf( "Minimum was: %d nsec\n", min*1000/(2*533) );
|
|
|
|
kprintf( "Jitter was: %d nsec\n", (max-min)*1000/(2*533) );
|
|
|
|
|
|
|
|
irq_nested_enable(flags);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
#undef _IRQ_NOISE_
|
|
|
|
#define NOISE_PRIO 1
|
2011-08-24 04:25:10 -07:00
|
|
|
|
2011-08-29 01:49:59 -07:00
|
|
|
int icc_mail_noise(void) {
|
2011-08-23 14:45:08 -07:00
|
|
|
int i, j, res;
|
2011-07-04 12:27:28 +02:00
|
|
|
int num_ranks = RCCE_num_ues();
|
2011-11-07 13:01:57 -08:00
|
|
|
int count = 0;
|
2011-07-04 12:27:28 +02:00
|
|
|
iRCCE_MAIL_HEADER* recv_mail = NULL;
|
2011-08-25 12:59:32 -07:00
|
|
|
|
2011-11-07 13:01:57 -08:00
|
|
|
/* timer vars */
|
|
|
|
uint64_t timer;
|
|
|
|
uint64_t tmr;
|
|
|
|
uint64_t tmr_send = 0;
|
|
|
|
uint64_t tmr_recv = 0;
|
|
|
|
uint64_t tmr_release = 0;
|
|
|
|
uint64_t tmr_chck = 0;
|
|
|
|
|
|
|
|
kprintf( "my_ue = %d\n", RCCE_IAM );
|
|
|
|
|
2011-07-04 12:27:28 +02:00
|
|
|
// leave function if not participating
|
2011-12-01 05:40:10 -08:00
|
|
|
if( (RCCE_IAM == CORE_A) || (RCCE_IAM == CORE_B) ) {
|
|
|
|
kprintf( "mail_noise: leaving" );
|
|
|
|
return -1;
|
|
|
|
}
|
2011-08-25 12:59:32 -07:00
|
|
|
|
2011-08-24 04:25:10 -07:00
|
|
|
|
2011-10-10 22:03:12 +02:00
|
|
|
kprintf( "Hello from icc_mail_noise: my_ue = %d\n", RCCE_IAM );
|
2011-08-23 14:45:08 -07:00
|
|
|
kprintf( "num_ues = %d\n", num_ranks );
|
2011-11-07 13:01:57 -08:00
|
|
|
|
|
|
|
timer = rdtsc();
|
|
|
|
|
2011-12-01 05:40:10 -08:00
|
|
|
for( i=0; i<40000; ++i ) {
|
2011-08-27 10:13:13 -07:00
|
|
|
if( !(i%1000) ) kprintf( "%d ", i );
|
2011-11-07 13:01:57 -08:00
|
|
|
tmr = rdtsc();
|
|
|
|
iRCCE_mail_check(iRCCE_MAILBOX_ALL);
|
|
|
|
tmr = rdtsc() - tmr;
|
|
|
|
tmr_chck += tmr;
|
|
|
|
|
2011-07-18 01:14:18 -07:00
|
|
|
/* send a mail to each UE */
|
2011-07-04 12:27:28 +02:00
|
|
|
for( j=0; j<num_ranks; ++j ) {
|
2011-12-13 03:39:21 -08:00
|
|
|
if( (j == CORE_A) || (j == CORE_B) ) continue;
|
2011-11-07 13:01:57 -08:00
|
|
|
|
2011-08-21 11:38:09 -07:00
|
|
|
/* send noise mail */
|
2011-11-07 13:01:57 -08:00
|
|
|
tmr = rdtsc();
|
|
|
|
iRCCE_mail_send(0, NOISE, NOISE_PRIO, NULL, j);
|
|
|
|
tmr = rdtsc() - tmr;
|
|
|
|
tmr_send += tmr;
|
|
|
|
|
|
|
|
tmr = rdtsc();
|
|
|
|
res = iRCCE_mail_recv(&recv_mail);
|
|
|
|
tmr = rdtsc() - tmr;
|
|
|
|
tmr_recv += tmr;
|
|
|
|
|
|
|
|
if( res == iRCCE_SUCCESS ) {
|
|
|
|
icc_mail_check_tag(recv_mail);
|
|
|
|
tmr = rdtsc();
|
|
|
|
iRCCE_mail_release(&recv_mail);
|
|
|
|
tmr = rdtsc() - tmr;
|
|
|
|
tmr_release += tmr;
|
|
|
|
count++;
|
|
|
|
}
|
2011-04-24 07:27:27 -07:00
|
|
|
}
|
2011-08-28 07:09:04 -07:00
|
|
|
}
|
2011-04-24 07:27:27 -07:00
|
|
|
|
2011-08-28 07:09:04 -07:00
|
|
|
do {
|
2011-11-07 13:01:57 -08:00
|
|
|
tmr = rdtsc();
|
2011-08-27 23:32:04 -07:00
|
|
|
iRCCE_mail_check(iRCCE_MAILBOX_ALL);
|
2011-11-07 13:01:57 -08:00
|
|
|
tmr = rdtsc() - tmr;
|
|
|
|
tmr_chck += tmr;
|
|
|
|
|
|
|
|
tmr = rdtsc();
|
2011-08-28 07:09:04 -07:00
|
|
|
res = iRCCE_mail_recv(&recv_mail);
|
2011-11-07 13:01:57 -08:00
|
|
|
tmr = rdtsc() - tmr;
|
|
|
|
tmr_recv += tmr;
|
|
|
|
|
|
|
|
if( res == iRCCE_SUCCESS ) {
|
|
|
|
icc_mail_check_tag(recv_mail);
|
|
|
|
tmr = rdtsc();
|
|
|
|
iRCCE_mail_release(&recv_mail);
|
|
|
|
tmr = rdtsc() - tmr;
|
|
|
|
tmr_release += tmr;
|
|
|
|
count++;
|
|
|
|
}
|
2011-08-28 07:09:04 -07:00
|
|
|
} while( res == iRCCE_SUCCESS );
|
2011-08-25 12:59:32 -07:00
|
|
|
|
2011-11-07 13:01:57 -08:00
|
|
|
timer = rdtsc() - timer;
|
|
|
|
|
|
|
|
kprintf( "Count = %d\n", count );
|
|
|
|
|
|
|
|
kprintf( "Time: %d ms\n", timer/(1000*get_cpu_frequency()) );
|
|
|
|
kprintf( "Time in send: %d ms\n", tmr_send/(1000*get_cpu_frequency()) );
|
|
|
|
kprintf( "Time in recv: %d ms\n", tmr_recv/(1000*get_cpu_frequency()) );
|
|
|
|
kprintf( "Time in chck: %d ms\n", tmr_chck/(1000*get_cpu_frequency()) );
|
|
|
|
kprintf( "Time in release: %d ms\n", tmr_release/(1000*get_cpu_frequency()) );
|
|
|
|
|
|
|
|
kprintf( "XXX XXX XXX" );
|
2011-07-04 12:27:28 +02:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2011-08-15 09:56:46 -07:00
|
|
|
/*
|
2011-11-07 11:25:54 -08:00
|
|
|
* Routine to check mailboxes.
|
2011-08-15 09:56:46 -07:00
|
|
|
*/
|
|
|
|
|
2011-10-09 13:04:13 -07:00
|
|
|
void icc_mail_check(void)
|
2011-06-07 12:38:35 +02:00
|
|
|
{
|
2011-11-07 12:24:11 -08:00
|
|
|
iRCCE_MAIL_HEADER* header = NULL;
|
2011-08-13 17:14:01 -07:00
|
|
|
uint32_t flags;
|
2011-08-11 09:02:49 -07:00
|
|
|
|
2011-08-13 17:14:01 -07:00
|
|
|
/* disable interrupts */
|
|
|
|
flags = irq_nested_disable();
|
|
|
|
|
2011-10-09 13:04:13 -07:00
|
|
|
iRCCE_mail_check(iRCCE_MAILBOX_ALL);
|
2011-08-11 09:02:49 -07:00
|
|
|
|
2011-08-13 17:14:01 -07:00
|
|
|
/* empty mail queue */
|
2011-08-24 04:25:10 -07:00
|
|
|
while( iRCCE_mail_recv(&header) == iRCCE_SUCCESS ) {
|
2011-07-18 01:14:18 -07:00
|
|
|
icc_mail_check_tag(header);
|
2011-06-07 12:38:35 +02:00
|
|
|
iRCCE_mail_release( &header );
|
2011-05-17 08:13:20 -07:00
|
|
|
}
|
2011-10-21 14:17:54 -07:00
|
|
|
|
|
|
|
/* enable interrupts */
|
|
|
|
irq_nested_enable(flags);
|
2011-04-23 00:13:12 -07:00
|
|
|
}
|
|
|
|
|
2011-11-21 13:37:15 -08:00
|
|
|
//uint64_t check_ticks = 0;
|
|
|
|
//uint64_t recv_ticks = 0;
|
2011-11-08 07:46:35 -08:00
|
|
|
|
2011-11-07 11:25:54 -08:00
|
|
|
void icc_wait(int tag)
|
|
|
|
{
|
|
|
|
iRCCE_MAIL_HEADER* header = NULL;
|
2011-11-07 12:24:11 -08:00
|
|
|
uint32_t flags;
|
2011-11-21 13:37:15 -08:00
|
|
|
//uint64_t start;
|
2011-11-07 11:25:54 -08:00
|
|
|
|
|
|
|
/* disable interrupts */
|
|
|
|
flags = irq_nested_disable();
|
|
|
|
|
2011-11-07 12:24:11 -08:00
|
|
|
retry:
|
2011-11-21 13:37:15 -08:00
|
|
|
//start = rdtsc();
|
2011-11-07 12:24:11 -08:00
|
|
|
iRCCE_mail_check(iRCCE_MAILBOX_ALL);
|
2011-11-21 13:37:15 -08:00
|
|
|
//check_ticks += rdtsc() - start;
|
2011-11-07 11:25:54 -08:00
|
|
|
|
2011-11-21 13:37:15 -08:00
|
|
|
//start = rdtsc();
|
2011-11-07 12:24:11 -08:00
|
|
|
/* empty mail queue */
|
2011-11-08 07:46:35 -08:00
|
|
|
while(iRCCE_mail_recv(&header) == iRCCE_SUCCESS ) {
|
2011-11-07 12:24:11 -08:00
|
|
|
icc_mail_check_tag(header);
|
|
|
|
if (header->tag == tag) {
|
2011-11-07 11:25:54 -08:00
|
|
|
iRCCE_mail_release( &header );
|
2011-11-07 12:24:11 -08:00
|
|
|
goto out;
|
|
|
|
} else iRCCE_mail_release( &header );
|
|
|
|
}
|
2011-11-21 13:37:15 -08:00
|
|
|
//recv_ticks += rdtsc() - start;
|
2011-11-07 12:24:11 -08:00
|
|
|
|
|
|
|
goto retry;
|
2011-11-07 11:25:54 -08:00
|
|
|
|
2011-11-07 12:24:11 -08:00
|
|
|
out:
|
2011-11-21 13:37:15 -08:00
|
|
|
//recv_ticks += rdtsc() - start;
|
2011-11-07 11:25:54 -08:00
|
|
|
/* enable interrupts */
|
|
|
|
irq_nested_enable(flags);
|
|
|
|
}
|
2010-08-10 15:20:27 +00:00
|
|
|
#endif
|