Commit 1e968964 authored by Michael Quigley's avatar Michael Quigley
Browse files

Finished dispatch test code and got it building with autoconfig. Found minor...

Finished dispatch test code and got it building with autoconfig. Found minor bug in test. Needs to be fixed. I will probably revisit it again tomorrow.
parent 46265f53
......@@ -113,6 +113,7 @@ AC_CONFIG_FILES(
src/tests/Makefile
src/tests/simple/Kbuild
src/tests/dispatch/Kbuild
)
AC_OUTPUT
Subproject commit 6bbedfeab26e1faa4584d78663cba021cd9faf18
Subproject commit 2cef3d068d3ed2da556d775f8571f5c2c6b67d63
......@@ -77,7 +77,6 @@ int thc_ipc_recv(struct fipc_ring_channel *chnl,
}
else if( ret == -EWOULDBLOCK ) //no message, Yield
{
printk(KERN_ERR "yielding\n");
THCYieldAndSave((uint32_t) msg_id);
}
else
......@@ -165,3 +164,22 @@ int thc_channel_group_item_add(struct thc_channel_group* channel_group,
}
EXPORT_SYMBOL(thc_channel_group_item_add);
int thc_channel_group_item_get(struct thc_channel_group* channel_group,
int index,
struct thc_channel_group_item **out_item)
{
int curr_index = 0;
list_for_each_entry((*out_item), &(channel_group->head), list)
{
if( curr_index == index )
{
return 0;
}
curr_index++;
}
return 1;
}
EXPORT_SYMBOL(thc_channel_group_item_get);
......@@ -22,4 +22,8 @@ int thc_channel_group_init(struct thc_channel_group* channel_group);
int thc_channel_group_item_add(struct thc_channel_group* channel_group,
struct thc_channel_group_item* item);
int thc_channel_group_item_get(struct thc_channel_group* channel_group,
int index,
struct thc_channel_group_item **out_item);
#endif
obj-m += simple/
#obj-m += dispatch_loop/
\ No newline at end of file
obj-m += dispatch/
......@@ -2,4 +2,4 @@
# D=install dir (something/lib)
install-tests:
cp $(LIBASYNC_TESTS_KBUILD)/simple/libasync_test_simple.ko $(D)
#cp $(LIBASYNC_TESTS_KBUILD)/dispatch_loop/libfipc_test_dispatch_loop.ko $(D)
cp $(LIBASYNC_TESTS_KBUILD)/dispatch/libfipc_test_dispatch_loop.ko $(D)
# @ASYNC_AUTOCONF_NOTICE@
# Magic line so we can do out-of-source build
src = @abs_top_srcdir@/src/tests/dispatch
obj-m = libfipc_test_dispatch_loop.o
# Paths are relative to simple/ build dir
libfipc_test_dispatch_loop-y += main.o thc_dispatch_test.o thread1_fn.o thread2_fn.o thread3_fn.o thread_fn_util.o
# LIBASYNC_PATH and LIBFIPC_LIB are defined (and exported) in
# src/Makefile.am.
libfipc_test_dispatch_loop-y += ../../$(LIBASYNC_PATH)
libfipc_test_dispatch_loop-y += ../../$(LIBFIPC_LIB)
# Add -DCHECK_MESSAGES to check that message values contain what is expected
ccflags-y += $(CFLAGS) $(AM_CPPFLAGS) $(AM_CFLAGS)
......@@ -3,9 +3,9 @@
#include <linux/module.h>
#include <linux/delay.h>
#include <thc_ipc_types.h>
#include <thc_ipc.h>
#include "../../../fast-ipc-module/src/platform/kernel/tests/test_helpers.h"
#include "rpc.h"
#include "../test_helpers.h"
#include "thread_fn_util.h"
......@@ -68,7 +68,7 @@ static int setup_and_run_test(void)
&thread_2_to_3_header);
if (ret) {
pr_err("Error creating channel, ret = %d\n", ret);
goto failN_i;
goto fail2;
}
......
/*
* rpc.h
*
* Internal defs
*
* Copyright: University of Utah
*/
#ifndef LIBFIPC_RPC_TEST_H
#define LIBFIPC_RPC_TEST_H
#include <libfipc.h>
enum fn_type {
NULL_INVOCATION,
ADD_CONSTANT,
ADD_NUMS,
ADD_3_NUMS,
ADD_4_NUMS,
ADD_5_NUMS,
ADD_6_NUMS
};
/* must be divisible by 6... because I call 6 functions in the callee.c */
#define TRANSACTIONS 60
/* thread main functions */
int callee(void *_callee_channel_header);
int caller(void *_caller_channel_header);
static inline
int
get_fn_type(struct fipc_message *msg)
{
return fipc_get_flags(msg);
}
static inline
void
set_fn_type(struct fipc_message *msg, enum fn_type type)
{
fipc_set_flags(msg, type);
}
#endif /* LIBFIPC_RPC_TEST_H */
......@@ -2,7 +2,7 @@
#include <thc.h>
#include <thcinternal.h>
#include <libfipc.h>
#include <awe-mapper.h>
#include <awe_mapper.h>
#include <linux/types.h>
#include <thc_ipc.h>
......@@ -49,4 +49,4 @@ int thc_dispatch_loop_test(struct thc_channel_group* rx_group, int max_recv_ct)
return 0;
}
EXPORT_SYMBOL(ipc_dispatch_loop);
EXPORT_SYMBOL(thc_dispatch_loop_test);
#ifndef IPC_DISPATCH_H
#define IPC_DISPATCH_H
#ifndef THC_DISPATCH_TEST_H
#define THC_DISPATCH_TEST_H
int ipc_dispatch_loop(struct ttd_ring_channel_group* rx_group, int max_recv_ct);
#include <thc_ipc_types.h>
int thc_dispatch_loop_test(struct thc_channel_group* rx_group, int max_recv_ct);
static inline void ipc_dispatch_print_sp(char* time)
{
unsigned long sp;
asm volatile("mov %%rsp, %0" : "=g"(sp) : :);
printk(KERN_ERR "%s sp: %lx\n", time, sp);
//printk(KERN_ERR "%s sp: %lx\n", time, sp);
}
#endif
......@@ -4,9 +4,12 @@
#include <thcinternal.h>
#include "thc_dispatch_test.h"
#include "thread_fn_util.h"
#include <awe-mapper.h>
#include "../test_helpers.h"
#include "rpc.h"
#include <awe_mapper.h>
#include <linux/delay.h>
#define BATCH_INTERVAL 100
static struct fipc_ring_channel* channel;
......@@ -16,16 +19,16 @@ static unsigned long add_nums_async(unsigned long lhs, unsigned long rhs, unsign
struct fipc_message *msg;
struct fipc_message *response;
unsigned long result;
if( test_ipc_blocking_send_start(channel, &msg) )
if( test_fipc_blocking_send_start(channel, &msg) )
{
printk(KERN_ERR "Error getting send message for add_nums_async.\n");
}
set_fn_type(msg, fn_type);
fipc_set_reg0(lhs);
fipc_set_reg1(rhs);
fipc_set_reg0(msg, lhs);
fipc_set_reg1(msg, rhs);
THC_MSG_ID(msg) = msg_id;
THC_MSG_TYPE(msg) = msg_type_request;
send_and_get_response(channel, msg, &response);
send_and_get_response(channel, msg, &response, msg_id);
fipc_recv_msg_end(channel, response);
result = fipc_get_reg0(response);
printk(KERN_ERR "result is %lu\n", result);
......
#include <thc.h>
#include <libfipc.h>
#include <thcinternal.h>
#include <thc_ipc.h>
#include <thc_ipc_types.h>
#include "rpc.h"
#include "thc_dispatch_test.h"
#include "../test_helpers.h"
#include "thread_fn_util.h"
#include <awe-mapper.h>
#include <awe_mapper.h>
#define THREAD2_FNS_LENGTH 2
static struct thc_channel_group* rx_group;
......@@ -14,7 +18,7 @@ static int add_2_fn(struct fipc_ring_channel* chan, struct fipc_message* msg)
unsigned long result = fipc_get_reg0(msg) + fipc_get_reg1(msg);
struct fipc_message* out_msg;
if( test_ipc_blocking_send_start(chan, &out_msg) )
if( test_fipc_blocking_send_start(chan, &out_msg) )
{
printk(KERN_ERR "Error getting send message for add_2_fn.\n");
}
......@@ -37,30 +41,52 @@ static int add_2_fn(struct fipc_ring_channel* chan, struct fipc_message* msg)
//Receives a value from thread1, then passes it to thread 3 and returns that result to thread 1
static int add_10_fn(struct fipc_ring_channel* thread1_chan, struct fipc_message* msg)
{
struct fipc_ring_channel * thread3_chan = rx_group->chans[1];
struct fipc_message* thread3_msg = get_send_slot(thread3_chan);
struct thc_channel_group_item *thread3_item;
struct fipc_message* thread1_result;
unsigned long saved_msg_id = msg->msg_id;
struct fipc_message* thread3_msg;
fipc_recv_msg_end(thread1_chan, msg);
if( thc_channel_group_item_get(rx_group, 1, &thread3_item) )
{
printk(KERN_ERR "invalid index for group_item_get\n");
return 1;
}
struct fipc_ring_channel * thread3_chan = thread3_item->channel;
if( test_fipc_blocking_send_start(thread3_chan, &thread3_msg) )
{
printk(KERN_ERR "Error getting send message for add_10_fn.\n");
}
unsigned long saved_msg_id = THC_MSG_ID(msg);
unsigned long new_msg_id = awe_mapper_create_id();
transaction_complete(msg);
thread3_msg->fn_type = msg->fn_type;
thread3_msg->reg1 = msg->reg1;
thread3_msg->reg2 = msg->reg2;
thread3_msg->msg_id = new_msg_id;
thread3_msg->msg_type = msg_type_request;
send(thread3_chan,thread3_msg);
msg = async_recv(thread3_chan, new_msg_id);
transaction_complete(msg);
thread1_result = get_send_slot(thread1_chan);
thread1_result->fn_type = msg->fn_type;
thread1_result->reg1 = msg->reg1;
thread1_result->reg2 = msg->reg2;
thread1_result->msg_id = saved_msg_id;
thread1_result->msg_type = msg_type_response;
send(thread1_chan,thread1_result);
set_fn_type(thread3_msg, get_fn_type(msg));
fipc_set_reg0(thread3_msg, fipc_get_reg0(msg));
fipc_set_reg1(thread3_msg, fipc_get_reg1(msg));
THC_MSG_ID(thread3_msg) = new_msg_id;
THC_MSG_TYPE(thread3_msg) = msg_type_request;
send_and_get_response(thread3_chan, thread3_msg, &msg, new_msg_id);
fipc_recv_msg_end(thread3_chan, msg);
if( test_fipc_blocking_send_start(thread1_chan, &thread1_result) )
{
printk(KERN_ERR "Error getting send message for add_10_fn.\n");
}
set_fn_type(thread1_result, get_fn_type(msg));
fipc_set_reg0(thread1_result, fipc_get_reg0(msg));
fipc_set_reg1(thread1_result, fipc_get_reg1(msg));
THC_MSG_ID(thread1_result) = saved_msg_id;
THC_MSG_TYPE(thread1_result) = msg_type_response;
if( fipc_send_msg_end(thread1_chan, thread1_result) )
{
printk(KERN_ERR "Error sending message for add_10_fn.\n");
}
return 0;
}
......@@ -74,17 +100,19 @@ static int thread1_dispatch_fn(struct fipc_ring_channel* chan, struct fipc_messa
case ADD_10_FN:
return add_10_fn(chan, msg);
default:
printk(KERN_ERR "FN: %lu is not a valid function type\n", msg->fn_type);
printk(KERN_ERR "FN: %lu is not a valid function type\n", get_fn_type(msg));
}
return 1;
}
int thread2_fn1(void* group)
int thread2_fn(void* group)
{
struct thc_channel_group_item *thrd1_item;
thc_init();
rx_group = (struct thc_channel_group*)group;
rx_group->chans[0]->dispatch_fn = thread1_dispatch_fn;
ipc_dispatch_loop(rx_group, TRANSACTIONS);
thc_channel_group_item_get(rx_group, 0, &thrd1_item);
thrd1_item->dispatch_fn = thread1_dispatch_fn;
thc_dispatch_loop_test(rx_group, TRANSACTIONS);
thc_done();
return 1;
......
#include <thc.h>
#include <thcinternal.h>
#include <awe-mapper.h>
#include <thc_ipc.h>
#include <thc_ipc_types.h>
#include <libfipc.h>
#include <thcinternal.h>
#include "rpc.h"
#include "../test_helpers.h"
#include "thc_dispatch_test.h"
#include "thread_fn_util.h"
#include <awe_mapper.h>
#include <linux/delay.h>
#define THREAD3_FNS_LENGTH 1
static struct thc_channel_group* rx_group;
static struct fipc_ring_channel* channel;
int thread3_fn(void* channel)
static int add_10_fn(struct fipc_ring_channel* chan, struct fipc_message* msg)
{
unsigned long msg_id =THC_MSG_ID(msg);
unsigned long reg0 = fipc_get_reg0(msg);
unsigned long reg1 = fipc_get_reg1(msg);
fipc_recv_msg_end(chan,msg);
msleep(10);
unsigned long result = reg0 + reg1 + 10;
struct fipc_message* out_msg;
if( test_fipc_blocking_send_start(chan, &out_msg) )
{
printk(KERN_ERR "Error getting send message for add_10_fn.\n");
}
printk(KERN_ERR "got to thread3\n");
fipc_set_reg0(out_msg, result);
THC_MSG_ID(out_msg) = msg_id;
set_fn_type(out_msg, ADD_10_FN);
THC_MSG_TYPE(out_msg) = msg_type_response;
if( fipc_send_msg_end(chan, out_msg) )
{
printk(KERN_ERR "Error sending message for add_10_fn.\n");
}
return 0;
}
static int thread2_dispatch_fn(struct fipc_ring_channel* chan, struct fipc_message* msg)
{
printk(KERN_ERR "in thread 2 dispatch function with message %p\n", msg);
switch( get_fn_type(msg) )
{
case ADD_10_FN:
return add_10_fn(chan, msg);
default:
printk(KERN_ERR "FN: %d is not a valid function type\n", get_fn_type(msg));
}
return 1;
}
int thread3_fn(void* group)
{
struct thc_channel_group_item *thrd2_item;
thc_init();
rx_group = (struct thc_channel_group*)group;
thc_channel_group_item_get(rx_group, 0, &thrd2_item);
thrd2_item->dispatch_fn = thread2_dispatch_fn;
thc_dispatch_loop_test(rx_group, TRANSACTIONS / THD3_INTERVAL);
thc_done();
return 1;
}
#include <thc_ipc.h>
#include "thread_fn_util.h"
static inline int send_and_get_response(
int send_and_get_response(
struct fipc_ring_channel *chan,
struct fipc_message *request,
struct fipc_message **response,
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment