diff --git a/arch/x86/scc/icc.c b/arch/x86/scc/icc.c index 40a07199..cd2c3b50 100644 --- a/arch/x86/scc/icc.c +++ b/arch/x86/scc/icc.c @@ -235,30 +235,46 @@ int icc_ping(int ue) int icc_mail_ping( void ) { uint32_t flags; + uint64_t timer; int remote_rank = (my_ue+1)%2; - - kprintf( "#### Hello from icc_mail_ping\n" ); + + if( !my_rank ) { + return 0; + } + // iRCCE is not thread save => disable interrupts flags = irq_nested_disable(); - // send mail - iRCCE_mail_send( 0, my_ue, 0, NULL, remote_rank ); - kprintf( "### Message sent ...\n" ); + // start timer + timer = rdtsc(); - // wait for mail from remote rank + iRCCE_mail_send( 0, 1, 0, NULL, remote_rank ); + kprintf( "Sent pingrequest to %d ...\n", remote_rank ); + + // wait for response iRCCE_MAIL_HEADER* mail; do { iRCCE_mail_recv( &mail ); } while( !mail ); - // show content - iRCCE_mailbox_print_header( mail ); - + // stop timer + timer = rdtsc() - timer; + + if( mail->tag == 2 ) { + kprintf( "Response received in %d ticks!\n", timer ); + } + else { + krpintf( "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); @@ -325,4 +341,20 @@ void icc_check(void) iRCCE_isend_push(); } +void icc_mail_check(void) +{ + iRCCE_MAIL_HEADER* header; + int res; + + // empty mailbox and interpret headers + do { + res = iRCCE_mail_recv( &header ); + if( header->tag == 1 ) { + iRCCE_mail_send( 0, 2, 0, NULL, header->source ); + } + + iRCCE_mail_release( &header ); + } while( res == iRCCE_SUCCESS ); +} + #endif diff --git a/include/metalsvm/tasks.h b/include/metalsvm/tasks.h index 5329fc61..ec6ed665 100644 --- a/include/metalsvm/tasks.h +++ b/include/metalsvm/tasks.h @@ -143,7 +143,8 @@ static inline void check_workqueues(void) uint32_t flags = irq_nested_disable(); #ifdef CONFIG_ROCKCREEK - icc_check(); + //icc_check(); + icc_mail_check(); #endif irq_nested_enable(flags);