Commit 5c437b5d authored by Michael Quigley's avatar Michael Quigley
Browse files

Updated tests, have not run yet.

parent e6867fb4
Pipeline #541 skipped
......@@ -205,6 +205,18 @@ thc_ipc_reply(struct fipc_ring_channel *chnl,
}
EXPORT_SYMBOL(thc_ipc_reply);
int
LIBASYNC_FUNC_ATTR
thc_ipc_reply_with_id(struct fipc_ring_channel *chnl,
uint32_t msg_id,
struct fipc_message *response)
{
thc_set_msg_type(response, msg_type_response);
thc_set_msg_id(response, msg_id);
return fipc_send_msg_end(chnl, response);
}
EXPORT_SYMBOL(thc_ipc_reply_with_id);
int
LIBASYNC_FUNC_ATTR
thc_channel_group_init(struct thc_channel_group* channel_group)
......
......@@ -51,6 +51,11 @@ int thc_ipc_reply(struct fipc_ring_channel *chnl,
struct fipc_message *request,
struct fipc_message *response);
int thc_ipc_reply_with_id(struct fipc_ring_channel *chnl,
uint32_t msg_id,
struct fipc_message *response);
int thc_poll_recv_group(struct thc_channel_group* chan_group,
struct thc_channel_group_item** chan_group_item,
struct fipc_message** out_msg);
......
obj-m += simple/
#obj-m += dispatch/
#obj-m += ctx-switch/
#obj-m += async-msg-benchmarks/
obj-m += dispatch/
obj-m += ctx-switch/
obj-m += async-msg-benchmarks/
......@@ -69,34 +69,34 @@ static inline int send_response(struct fipc_ring_channel *chnl,
{
int ret;
struct fipc_message *response;
/*
* Mark recvd msg slot as available
*/
ret = fipc_recv_msg_end(chnl, recvd_msg);
if (ret) {
pr_err("Error marking msg as recvd");
return ret;
}
/*
* Response
*/
ret = test_fipc_blocking_send_start(chnl, &response);
if (ret) {
if ( ret ) {
pr_err("Error getting send slot");
return ret;
}
THC_MSG_TYPE(response) = msg_type_response;
THC_MSG_ID(response) = THC_MSG_ID(recvd_msg);
set_fn_type(response, type);
response->regs[0] = val;
ret = fipc_send_msg_end(chnl, response);
if (ret) {
ret = thc_ipc_reply(chnl, recvd_msg, response);
if ( ret ) {
pr_err("Error marking message as sent");
return ret;
}
/*
* Mark recvd msg slot as available
*/
ret = fipc_recv_msg_end(chnl, recvd_msg);
if ( ret ) {
pr_err("Error marking msg as recvd");
return ret;
}
return 0;
}
......
......@@ -16,12 +16,10 @@
static unsigned long msg_times[TRANSACTIONS];
static inline int send_and_get_response(
static inline int send_and_get_response_sync(
struct fipc_ring_channel *chan,
struct fipc_message *request,
struct fipc_message **response,
uint32_t msg_id,
bool is_async)
struct fipc_message **response)
{
int ret;
struct fipc_message *resp;
......@@ -37,15 +35,10 @@ static inline int send_and_get_response(
/*
* Try to get the response
*/
if( is_async )
{
ret = thc_ipc_recv(chan, msg_id, &resp);
}
else
{
ret = test_fipc_blocking_recv_start(chan, &resp);
}
if (ret) {
ret = test_fipc_blocking_recv_start(chan, &resp);
if (ret) {
pr_err("failed to get a response, ret = %d\n", ret);
goto fail2;
}
......@@ -128,20 +121,22 @@ static int noinline __used add_nums(struct fipc_ring_channel *chan,
pr_err("Error getting send message, ret = %d\n", ret);
goto fail;
}
if( is_async )
{
msg_id = awe_mapper_create_id();
}
THC_MSG_TYPE(request) = msg_type_request;
THC_MSG_ID(request) = msg_id;
set_fn_type(request, ADD_NUMS);
fipc_set_reg0(request, trans);
fipc_set_reg1(request, res1);
if( is_async )
{
ret = thc_ipc_call(chan, request, &response);
}
else
{
ret = send_and_get_response_sync(chan, request, &response);
}
/*
* Send request, and get response
*/
ret = send_and_get_response(chan, request, &response, msg_id, is_async);
stop_time = test_fipc_stop_stopwatch();
msg_times[trans] = stop_time - start_time;
......@@ -151,7 +146,6 @@ static int noinline __used add_nums(struct fipc_ring_channel *chan,
goto fail;
}
/*
* Maybe check message
*/
......
......@@ -9,7 +9,7 @@
#define LIBFIPC_RPC_TEST_H
#include <libfipc.h>
#include <thc_ipc.h>
enum fn_type {
NULL_INVOCATION,
ADD_CONSTANT,
......@@ -27,18 +27,4 @@ enum fn_type {
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 */
/*
* rpc.h
*
* Internal defs
*
* Copyright: University of Utah
*/
#ifndef LIBFIPC_RPC_TEST_H
#define LIBFIPC_RPC_TEST_H
#include <libfipc.h>
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, uint32_t type)
{
fipc_set_flags(msg, type);
}
#endif /* LIBFIPC_RPC_TEST_H */
......@@ -5,7 +5,6 @@
#include "thc_dispatch_test.h"
#include "thread_fn_util.h"
#include "../test_helpers.h"
#include "rpc.h"
#include <awe_mapper.h>
#include <linux/delay.h>
......@@ -42,11 +41,61 @@ static void check_response(unsigned long lhs,
}
}
static unsigned long add_nums_async(unsigned long lhs, unsigned long rhs, unsigned long msg_id, int fn_type)
static inline int finish_response_check_fn_type_and_reg0(
struct fipc_ring_channel *chnl,
struct fipc_message *response,
uint32_t expected_type,
unsigned long expected_lhs,
unsigned long expected_rhs)
{
int ret;
uint32_t actual_type = get_fn_type(response);
unsigned long actual_reg0 = fipc_get_reg0(response);
unsigned long expected_reg0;
ret = fipc_recv_msg_end(chnl, response);
switch( expected_type )
{
case ADD_2_FN:
expected_reg0 = expected_lhs + expected_rhs;
break;
case ADD_10_FN:
expected_reg0 = expected_lhs + expected_rhs + 10;
break;
default:
printk(KERN_ERR "invalid fn_type %d\n", expected_type);
return -EINVAL;
}
if (ret) {
pr_err("Error finishing receipt of response, ret = %d\n", ret);
return ret;
} else if (actual_type != expected_type) {
pr_err("Unexpected fn type: actual = %u, expected = %u\n",
actual_type, expected_type);
return -EINVAL;
} else if (actual_reg0 != expected_reg0) {
pr_err("Unexpected return value (reg0): actual = 0x%lx, expected = 0x%lx\n",
actual_reg0, expected_reg0);
return -EINVAL;
} else {
return 0;
}
}
static int add_nums_async(struct fipc_ring_channel* channel,
unsigned long lhs,
unsigned long rhs,
int fn_type)
{
struct fipc_message *msg;
struct fipc_message *response;
unsigned long result;
int ret;
if( test_fipc_blocking_send_start(channel, &msg) )
{
printk(KERN_ERR "Error getting send message for add_nums_async.\n");
......@@ -54,22 +103,31 @@ static unsigned long add_nums_async(unsigned long lhs, unsigned long rhs, unsign
set_fn_type(msg, fn_type);
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, msg_id);
fipc_recv_msg_end(channel, response);
result = fipc_get_reg0(response);
return result;
ret = thc_ipc_call(channel, msg, &response);
if ( ret ) {
printk(KERN_ERR "Error getting response, ret = %d\n", ret);
goto fail;
}
return finish_response_check_fn_type_and_reg0(
channel,
response,
fn_type,
lhs,
rhs);
fail:
return ret;
}
static int run_thread1(void* chan)
{
volatile int num_transactions = 0;
volatile int num_transactions = 0;
int print_transactions_threshold = 0;
unsigned long msg_response = 0;
uint32_t id_num;
unsigned long msg_response = 0;
num_responses = 0;
channel = chan;
......@@ -83,30 +141,21 @@ static int run_thread1(void* chan)
}
ASYNC(
id_num = awe_mapper_create_id();
num_transactions++;
volatile int old_trans = num_transactions;
msg_response = add_nums_async(old_trans, 1,(unsigned long) id_num, ADD_2_FN);
check_response(old_trans, 1, msg_response, ADD_2_FN);
msg_response = add_nums_async(channel, num_transactions, 1, ADD_2_FN);
num_responses++;
);
if( (num_transactions) % THD3_INTERVAL == 0 )
{
ASYNC(
id_num = awe_mapper_create_id();
num_transactions++;
volatile int old_trans = num_transactions;
msg_response = add_nums_async(old_trans, 2,(unsigned long) id_num, ADD_10_FN);
check_response(old_trans, 2, msg_response, ADD_10_FN);
msg_response = add_nums_async(channel, num_transactions, 2, ADD_10_FN);
num_responses++;
);
}
ASYNC(
id_num = awe_mapper_create_id();
num_transactions++;
volatile int old_trans = num_transactions;
msg_response = add_nums_async(old_trans, 3,(unsigned long) id_num, ADD_2_FN);
check_response(old_trans, 3, msg_response, ADD_2_FN);
msg_response = add_nums_async(channel, num_transactions, 3, ADD_2_FN);
num_responses++;
);
//msleep(1);
......
......@@ -3,7 +3,6 @@
#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"
......@@ -23,16 +22,14 @@ static int add_2_fn(struct fipc_ring_channel* chan, struct fipc_message* msg)
printk(KERN_ERR "Error getting send message for add_2_fn.\n");
}
fipc_recv_msg_end(chan, msg);
fipc_set_reg0(out_msg,result);
set_fn_type(out_msg, ADD_2_FN);
THC_MSG_TYPE(out_msg) = msg_type_response;
THC_MSG_ID(out_msg) = THC_MSG_ID(msg);
if( fipc_send_msg_end(chan, out_msg) )
if( thc_ipc_reply(chan, msg, out_msg) )
{
printk(KERN_ERR "Error sending message for add_2_fn.\n");
}
fipc_recv_msg_end(chan, msg);
return 0;
}
......@@ -43,32 +40,31 @@ static int add_10_fn(struct fipc_ring_channel* thread1_chan, struct fipc_message
{
struct thc_channel_group_item *thread3_item;
struct fipc_message* thread1_result;
struct fipc_message* thread3_msg;
struct fipc_message* thread3_request;
struct fipc_message* thread3_response;
unsigned long saved_msg_id = thc_get_msg_id(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;
struct fipc_ring_channel* thread3_chan = thread3_item->channel;
if( test_fipc_blocking_send_start(thread3_chan, &thread3_msg) )
if( test_fipc_blocking_send_start(thread3_chan, &thread3_request) )
{
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();
set_fn_type(thread3_request, get_fn_type(msg));
fipc_set_reg0(thread3_request, fipc_get_reg0(msg));
fipc_set_reg1(thread3_request, fipc_get_reg1(msg));
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;
//mark channel 1 message as received and the slot as available
fipc_recv_msg_end(thread1_chan, msg);
send_and_get_response(thread3_chan, thread3_msg, &msg, new_msg_id);
thc_ipc_call(thread3_chan, thread3_request, &thread3_response);
fipc_recv_msg_end(thread3_chan, msg);
if( test_fipc_blocking_send_start(thread1_chan, &thread1_result) )
......@@ -76,13 +72,11 @@ static int add_10_fn(struct fipc_ring_channel* thread1_chan, struct fipc_message
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;
set_fn_type(thread1_result, get_fn_type(thread3_response));
fipc_set_reg0(thread1_result, fipc_get_reg0(thread3_response));
fipc_set_reg1(thread1_result, fipc_get_reg1(thread3_response));
if( fipc_send_msg_end(thread1_chan, thread1_result) )
if( thc_ipc_reply_with_id(thread1_chan, saved_msg_id , thread1_result) )
{
printk(KERN_ERR "Error sending message for add_10_fn.\n");
}
......
......@@ -3,7 +3,6 @@
#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"
......@@ -16,9 +15,9 @@ static struct thc_channel_group* rx_group;
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);
unsigned long msg_id = thc_get_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;
......@@ -29,11 +28,9 @@ static int add_10_fn(struct fipc_ring_channel* chan, struct fipc_message* msg)
printk(KERN_ERR "Error getting send message for add_10_fn.\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) )
if( thc_ipc_reply_with_id(chan, msg_id, out_msg) )
{
printk(KERN_ERR "Error sending message for add_10_fn.\n");
}
......
......@@ -27,26 +27,4 @@ enum fn_type {
/* 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) >> THC_RESERVED_MSG_FLAG_BITS;
}
static inline
void
set_fn_type(struct fipc_message *msg, enum fn_type type)
{
uint32_t flags = fipc_get_flags(msg);
/* ensure type is in range */
type &= (1 << (32 - THC_RESERVED_MSG_FLAG_BITS)) - 1;
/* erase old type */
flags &= ((1 << THC_RESERVED_MSG_FLAG_BITS) - 1);
/* install new type */
flags |= (type << THC_RESERVED_MSG_FLAG_BITS);
fipc_set_flags(msg, flags);
}
#endif /* LIBFIPC_RPC_TEST_H */
......@@ -16,6 +16,7 @@
#include <linux/kernel.h>
#include <linux/sort.h>
#include <libfipc.h>
#include <thc_ipc.h>
#define LCD_MAIN(_CODE) do { \
\
......@@ -272,5 +273,25 @@ static inline unsigned long test_fipc_stop_stopwatch(void)
void test_fipc_dump_time(unsigned long *time, unsigned long num_transactions);
static inline
int
get_fn_type(struct fipc_message *msg)
{
return fipc_get_flags(msg) >> THC_RESERVED_MSG_FLAG_BITS;
}
static inline
void
set_fn_type(struct fipc_message *msg, uint32_t type)
{
uint32_t flags = fipc_get_flags(msg);
/* ensure type is in range */
type &= (1 << (32 - THC_RESERVED_MSG_FLAG_BITS)) - 1;
/* erase old type */
flags &= ((1 << THC_RESERVED_MSG_FLAG_BITS) - 1);
/* install new type */
flags |= (type << THC_RESERVED_MSG_FLAG_BITS);
fipc_set_flags(msg, flags);
}
#endif /* FIPC_KERNEL_TEST_HELPERS_H */
Markdown is supported
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