From 11e25ee5c879948fb680553390c994a2624f1b24 Mon Sep 17 00:00:00 2001 From: Stefan Lankes Date: Tue, 28 Jun 2011 23:39:40 -0700 Subject: [PATCH 1/6] fix copy/paste failure, Simon has written the mailbox system => fix failure in copyright statement --- arch/x86/scc/iRCCE_mailbox.c | 55 ++++++++++++++++++------------------ 1 file changed, 27 insertions(+), 28 deletions(-) diff --git a/arch/x86/scc/iRCCE_mailbox.c b/arch/x86/scc/iRCCE_mailbox.c index e23bceb1..ae3132cb 100644 --- a/arch/x86/scc/iRCCE_mailbox.c +++ b/arch/x86/scc/iRCCE_mailbox.c @@ -1,31 +1,30 @@ -//****************************************************************************** -// Mailbox system. -//****************************************************************************** -// -// Author: Rob F. Van der Wijngaart -// Intel Corporation -// Date: 008/30/2010 -// -//****************************************************************************** -// -// Copyright 2010 Intel Corporation -// -// 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, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// [2011-05-08] implemented mailbox send/recv routines -// by Simon Pickartz, Chair for Operating Systems, -// RWTH Aachen University -// +/* + * Copyright 2011 Simon Pickartz, 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, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of MetalSVM. + */ + +/* + * Mailbox system + * + * [2011-05-08] implemented mailbox send/recv routines + * by Simon Pickartz, Chair for Operating Systems, + * RWTH Aachen University + */ + #include #include From de216756d1c9d2655748b725261c261d91e60085 Mon Sep 17 00:00:00 2001 From: Stefan Lankes Date: Wed, 29 Jun 2011 12:29:04 -0700 Subject: [PATCH 2/6] move mailbox example to tests.c --- kernel/Makefile | 2 +- kernel/mailbox.c | 42 ------------------------------------------ kernel/main.c | 7 +++---- kernel/tests.c | 12 +++++------- 4 files changed, 9 insertions(+), 54 deletions(-) delete mode 100644 kernel/mailbox.c diff --git a/kernel/Makefile b/kernel/Makefile index f70f6a77..fdddee71 100644 --- a/kernel/Makefile +++ b/kernel/Makefile @@ -1,4 +1,4 @@ -C_source := main.c tasks.c syscall.c tests.c echo.c ping.c init.c mailbox.c +C_source := main.c tasks.c syscall.c tests.c echo.c ping.c init.c MODULE := kernel include $(TOPDIR)/Makefile.inc diff --git a/kernel/mailbox.c b/kernel/mailbox.c deleted file mode 100644 index c790f984..00000000 --- a/kernel/mailbox.c +++ /dev/null @@ -1,42 +0,0 @@ -/* - * 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, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * This file is part of MetalSVM. - */ - -#include -#include -#include -#include -#include -#include -#include -#ifdef CONFIG_ROCKCREEK -#include - -int STDCALL mail_ping(void* arg) { - icc_mail_ping(); - - return 0; -} - -int mailbox_test_init(void) -{ - create_kernel_task(NULL, mail_ping, NULL); - - return 0; -} -#endif diff --git a/kernel/main.c b/kernel/main.c index 91e3c1ea..566ff932 100644 --- a/kernel/main.c +++ b/kernel/main.c @@ -35,7 +35,7 @@ #endif extern int test_init(void); -extern int mailbox_test_init(void); + /* * Note that linker symbols are not variables, they have no memory allocated for * maintaining a value, rather their address is their value. @@ -112,11 +112,10 @@ int main(void) sleep(5); list_root(); -// test_init(); - mailbox_test_init(); + test_init(); per_core(current_task)->status = TASK_IDLE; reschedule(); - while(1); + while(1) { #ifdef CONFIG_ROCKCREEK icc_halt(); diff --git a/kernel/tests.c b/kernel/tests.c index 1fbc7a48..ad600b3e 100644 --- a/kernel/tests.c +++ b/kernel/tests.c @@ -87,13 +87,13 @@ static int STDCALL foo(void* arg) } #ifdef CONFIG_ROCKCREEK -static int STDCALL ping(void* arg) -{ +int STDCALL mail_ping(void* arg) { int i; for(i=0; i<20; i++) { - icc_ping(1); - HALT; + icc_mail_ping(); + //icc_halt(); + udelay(500000); } return 0; @@ -117,8 +117,6 @@ static int STDCALL join_test(void* arg) return 0; } -void ping_send_now(); - int test_init(void) { char* argv[] = {"/bin/tests", NULL}; @@ -131,7 +129,7 @@ int test_init(void) //create_kernel_task(NULL, join_test, NULL); //create_kernel_task(NULL, producer, NULL); //create_kernel_task(NULL, consumer, NULL); - //create_kernel_task(NULL, ping, NULL); + //create_kernel_task(NULL, mail_ping, NULL); //create_user_task(NULL, "/bin/hello", argv); create_user_task(NULL, "/bin/tests", argv); //create_user_task(NULL, "/bin/jacobi", argv); From e1d3ac2ec5e43482f73648823fab67145caae42f Mon Sep 17 00:00:00 2001 From: Stefan Lankes Date: Wed, 29 Jun 2011 12:31:32 -0700 Subject: [PATCH 3/6] remove obsolete code & minor optimizations --- arch/x86/include/asm/icc.h | 7 ++- arch/x86/scc/iRCCE_isend.c | 28 ++------- arch/x86/scc/icc.c | 122 +++---------------------------------- include/metalsvm/tasks.h | 1 - 4 files changed, 17 insertions(+), 141 deletions(-) diff --git a/arch/x86/include/asm/icc.h b/arch/x86/include/asm/icc.h index b02be40e..e2197326 100644 --- a/arch/x86/include/asm/icc.h +++ b/arch/x86/include/asm/icc.h @@ -45,16 +45,17 @@ typedef struct { uint32_t length; } icc_header_t; +/* #define ICC_TYPE_IP (1 << 0) #define ICC_TYPE_SVM (1 << 1) #define ICC_TYPE_PINGREQUEST (1 << 2) #define ICC_TYPE_PINGRESPONSE (1 << 3) +*/ int icc_init(void); -int icc_ping(int ue); -void icc_check(void); -void icc_mail_check(void); int icc_halt(void); +int icc_send_irq(int ue); +void icc_mail_check(void); int icc_mail_ping(void); #endif diff --git a/arch/x86/scc/iRCCE_isend.c b/arch/x86/scc/iRCCE_isend.c index 51cde3eb..042de0ce 100644 --- a/arch/x86/scc/iRCCE_isend.c +++ b/arch/x86/scc/iRCCE_isend.c @@ -34,6 +34,8 @@ // [2010-12-09] added cancel functions for non-blocking send/recv requests // by Carsten Clauss // +// [2011-06-29] added the support of using IPIs +// by Simon Pickartz, Stefan Lankes #include #include @@ -42,27 +44,7 @@ #include #include -static int send_irq(int ue) { - int tmp, x, y, z, addr; - - z = Z_PID(RC_COREID[ue]); - x = X_PID(RC_COREID[ue]); - y = Y_PID(RC_COREID[ue]); - addr = CRB_ADDR(x,y) + (z==0 ? GLCFG0 : GLCFG1); - - // send interrupt to ue - do { - NOP1; - tmp=ReadConfigReg(addr); - } while(tmp & 2); - tmp |= 2; - SetConfigReg(addr, tmp); - - return 0; - - -} - +#include static int iRCCE_push_send_request(iRCCE_SEND_REQUEST *request) { @@ -264,7 +246,7 @@ int iRCCE_isend( 0, privbuf, dest ); NOP8; NOP8; - send_irq( dest ); + icc_send_irq( dest ); return iRCCE_SUCCESS; } // we need an extra isend-call @@ -273,7 +255,7 @@ int iRCCE_isend( 0, NULL, dest ); NOP8; NOP8; - send_irq( dest ); + icc_send_irq( dest ); return iRCCE_isend_general( privbuf, send_size, dest, request ); } diff --git a/arch/x86/scc/icc.c b/arch/x86/scc/icc.c index ca2bd9b4..b2a517b9 100644 --- a/arch/x86/scc/icc.c +++ b/arch/x86/scc/icc.c @@ -160,14 +160,14 @@ int icc_init(void) SetConfigReg(CRB_OWN + (z==0 ? GLCFG0 : GLCFG1), tmp); // set interrupt handler (INTR/LINT0) - //irq_install_handler(124, intr_handler); + irq_install_handler(124, intr_handler); kputs("Now, the SCC is initialized!\n"); return 0; } -static inline int icc_send_irq(int ue) +int icc_send_irq(int ue) { int tmp, x, y, z, addr; @@ -196,60 +196,24 @@ int icc_halt(void) // iRCCE is not thread save => disable interrupts flags = irq_nested_disable(); - if (do_send) + if (do_send) { do_send = (iRCCE_isend_push() == iRCCE_PENDING); - icc_check(); + iRCCE_irecv_push(); + } + icc_mail_check(); irq_nested_enable(flags); } while(do_send); - iRCCE_finalize(); - HALT; return 0; } -static volatile uint64_t ping_start = 0; -static icc_header_t ping_request = {ICC_TYPE_PINGREQUEST, 0, 0}; -static icc_header_t ping_response = {ICC_TYPE_PINGRESPONSE, 0, 0}; - -int icc_ping(int ue) -{ - uint32_t flags; - - if (BUILTIN_EXPECT(ue == my_ue, 0)) - return -EINVAL; - if (BUILTIN_EXPECT((ue < 0) || (ue >= num_ues), 0)) - return -EINVAL; - - while(ping_start) { - NOP8; - } - - ping_start = rdtsc(); - - // iRCCE is not thread save => disable interrupts - flags = irq_nested_disable(); - - iRCCE_isend((char*) &ping_request, sizeof(icc_header_t), ue, NULL); - - // wait some time - NOP8; - - // wake up receiver - icc_send_irq(ue); - - irq_nested_enable(flags); - - return 0; -} - #define MAIL_MSG_SIZE 20 int icc_mail_ping( void ) -{ - +{ uint32_t flags; uint64_t timer; int remote_rank = (my_ue+1)%2; @@ -288,78 +252,9 @@ int icc_mail_ping( void ) kprintf( "Response didn't arrive!\n" ); } - - irq_nested_enable(flags); return 0; - -} - -static void interpret_header(icc_header_t* header, int recv_ue) -{ - //kprintf("Got ICC message %d from %d\n", header->type, recv_ue); - - switch(header->type) - { - case ICC_TYPE_PINGREQUEST: { - - iRCCE_isend((char*) &ping_response, sizeof(icc_header_t), recv_ue, NULL); - - // wait some time - NOP8; - - // wake up remote core - icc_send_irq(recv_ue); - } - break; - case ICC_TYPE_PINGRESPONSE: - kprintf("Receive ping response. Ticks: %d\n", rdtsc()-ping_start); - ping_start = 0; - break; - default: - kprintf("Receive unknown ICC message (%d)\n", header->type); - } -} - -/* - * By entering this function, interrupts are already disables - * => No race by using the static variables - */ -void icc_check(void) -{ - static icc_header_t header[MAX_SCC_CORES]; - static iRCCE_RECV_REQUEST request[MAX_SCC_CORES]; - static int8_t first_call = 1; - int i, ret; - - if (first_call) { - first_call = 0; - - for(i=0; i Date: Thu, 30 Jun 2011 14:16:55 +0200 Subject: [PATCH 4/6] add missing delays --- lwip/src/arch/sys_arch.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lwip/src/arch/sys_arch.c b/lwip/src/arch/sys_arch.c index ca3b15d4..2eef4727 100644 --- a/lwip/src/arch/sys_arch.c +++ b/lwip/src/arch/sys_arch.c @@ -141,6 +141,7 @@ u32_t sys_arch_sem_wait(sys_sem_t *sem, u32_t timeout) err = sem_trywait(&sem->sem); if (err != -1) return err; + udelay(1000); timeout--; } return SYS_ARCH_TIMEOUT; @@ -167,6 +168,7 @@ u32_t sys_arch_mbox_fetch(sys_mbox_t * mbox, void **msg, u32_t timeout) { if (!mailbox_ptr_tryfetch(&mbox->mailbox,msg)) return 0; + udelay(1000); timeout--; } From 86b1d02945943de2b1d0e557befd312185717f48 Mon Sep 17 00:00:00 2001 From: Stefan Lankes Date: Thu, 30 Jun 2011 12:11:58 -0700 Subject: [PATCH 5/6] remove obsolete lines --- arch/x86/include/asm/icc.h | 6 ------ 1 file changed, 6 deletions(-) diff --git a/arch/x86/include/asm/icc.h b/arch/x86/include/asm/icc.h index e2197326..cb806761 100644 --- a/arch/x86/include/asm/icc.h +++ b/arch/x86/include/asm/icc.h @@ -39,12 +39,6 @@ typedef struct { extern bootinfo_t* bootinfo; -typedef struct { - uint8_t type; - uint8_t tag; - uint32_t length; -} icc_header_t; - /* #define ICC_TYPE_IP (1 << 0) #define ICC_TYPE_SVM (1 << 1) From fec9f9cfe11a2b4038b655078cd66aea43306a0e Mon Sep 17 00:00:00 2001 From: Stefan Lankes Date: Thu, 30 Jun 2011 12:26:16 -0700 Subject: [PATCH 6/6] switch back to the ping example - use RAW interface - cut the timer debug messages --- kernel/init.c | 2 +- kernel/ping.c | 4 ---- kernel/tests.c | 6 ++++++ lwip/src/include/lwipopts.h | 2 +- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/kernel/init.c b/kernel/init.c index 17b31c37..2f9b883f 100644 --- a/kernel/init.c +++ b/kernel/init.c @@ -116,7 +116,7 @@ int STDCALL network_task(void* arg) // start echo and ping server echo_init(); - //ping_init(); + ping_init(); while(!done) { #ifdef CONFIG_PCI diff --git a/kernel/ping.c b/kernel/ping.c index 98398300..6d8433a7 100644 --- a/kernel/ping.c +++ b/kernel/ping.c @@ -53,10 +53,6 @@ #include #include -#if LWIP_SOCKET -#define PING_USE_SOCKETS 1 -#endif - #if PING_USE_SOCKETS #include #include diff --git a/kernel/tests.c b/kernel/tests.c index ad600b3e..9ef0a393 100644 --- a/kernel/tests.c +++ b/kernel/tests.c @@ -117,6 +117,8 @@ static int STDCALL join_test(void* arg) return 0; } +void ping_send_now(); + int test_init(void) { char* argv[] = {"/bin/tests", NULL}; @@ -125,6 +127,10 @@ int test_init(void) sem_init(&consuming, 0); mailbox_int32_init(&mbox); +#ifdef CONFIG_LWIP + ping_send_now(); +#endif + create_kernel_task(NULL, foo, "Hello from foo1\n"); //create_kernel_task(NULL, join_test, NULL); //create_kernel_task(NULL, producer, NULL); diff --git a/lwip/src/include/lwipopts.h b/lwip/src/include/lwipopts.h index af8d018c..5ef66a0b 100644 --- a/lwip/src/include/lwipopts.h +++ b/lwip/src/include/lwipopts.h @@ -95,6 +95,6 @@ #define IP_DEBUG LWIP_DBG_OFF #define INET_DEBUG LWIP_DBG_OFF #define NETIF_DEBUG LWIP_DBG_ON -#define TIMERS_DEBUG LWIP_DBG_ON +#define TIMERS_DEBUG LWIP_DBG_OFF #endif