Commit f7f39703 authored by Michael Quigley's avatar Michael Quigley
Browse files

Updated async tests to use the new thc_channel type. Tests build and run.

parent 30e6c689
......@@ -89,7 +89,8 @@ LIBASYNC_FUNC_ATTR
awe_mapper_create_id(void)
{
awe_table_t *awe_map = get_awe_map();
BUG_ON((awe_map->used_slots >= AWE_TABLE_COUNT) && "Too many slots have been requested.");
BUG_ON(unlikely((awe_map->used_slots >= AWE_TABLE_COUNT) &&
"Too many slots have been requested."));
do
{
......@@ -115,7 +116,7 @@ LIBASYNC_FUNC_ATTR
awe_mapper_remove_id(uint32_t id)
{
awe_table_t *awe_map = get_awe_map();
BUG_ON(id >= AWE_TABLE_COUNT);
BUG_ON(unlikely(id >= AWE_TABLE_COUNT));
if( awe_map->used_slots > 0 )
{
......@@ -136,7 +137,7 @@ LIBASYNC_FUNC_ATTR
awe_mapper_set_id(uint32_t id, void* awe_ptr)
{
awe_table_t *awe_map = get_awe_map();
BUG_ON(id >= AWE_TABLE_COUNT);
BUG_ON(unlikely(id >= AWE_TABLE_COUNT));
(awe_map->awe_list)[id] = awe_ptr;
}
......@@ -150,7 +151,7 @@ LIBASYNC_FUNC_ATTR
awe_mapper_get_awe_ptr(uint32_t id)
{
awe_table_t *awe_map = get_awe_map();
BUG_ON(id >= AWE_TABLE_COUNT);
BUG_ON(unlikely(id >= AWE_TABLE_COUNT));
return (awe_map->awe_list)[id];
}
......@@ -1073,7 +1073,7 @@ LIBASYNC_FUNC_ATTR
THCYieldToIdAndSave(uint32_t id_to, uint32_t id_from) {
awe_t *awe_ptr = (awe_t *)awe_mapper_get_awe_ptr(id_to);
if (PTS() == awe_ptr->pts) {
if ( likely(PTS() == awe_ptr->pts) ) {
CALL_CONT_LAZY_AND_SAVE((void*)&thc_yieldto_with_cont, id_from, (void*)awe_ptr);
}
//NOTE: for multiple threads, the code in the 'else'
......@@ -1091,7 +1091,7 @@ LIBASYNC_FUNC_ATTR
THCYieldToId(uint32_t id_to)
{
awe_t *awe_ptr = (awe_t *)awe_mapper_get_awe_ptr(id_to);
if (PTS() == awe_ptr->pts) {
if ( likely(PTS() == awe_ptr->pts) ) {
CALL_CONT_LAZY((void*)&thc_yieldto_with_cont, (void*)awe_ptr);
}
else {
......@@ -1104,7 +1104,7 @@ EXPORT_SYMBOL(THCYieldToId);
void
LIBASYNC_FUNC_ATTR
THCYieldTo(awe_t *awe_ptr) {
if (PTS() == awe_ptr->pts) {
if ( likely(PTS() == awe_ptr->pts) ) {
CALL_CONT_LAZY((void*)&thc_yieldto_with_cont, (void*)awe_ptr);
} else {
THCSchedule(awe_ptr);
......
......@@ -63,7 +63,7 @@ add_6_nums(unsigned long trans, unsigned long res1, unsigned long res2,
return add_3_nums(trans,res1,res2) + add_3_nums(res3,res4,res5);
}
static inline int send_response(struct fipc_ring_channel *chnl,
static inline int send_response(struct thc_channel *chnl,
struct fipc_message *recvd_msg,
unsigned long val, enum fn_type type)
{
......@@ -74,7 +74,7 @@ static inline int send_response(struct fipc_ring_channel *chnl,
/*
* Mark recvd msg slot as available
*/
ret = fipc_recv_msg_end(chnl, recvd_msg);
ret = fipc_recv_msg_end(thc_channel_to_fipc(chnl), recvd_msg);
if ( ret ) {
pr_err("Error marking msg as recvd");
return ret;
......@@ -82,7 +82,7 @@ static inline int send_response(struct fipc_ring_channel *chnl,
/*
* Response
*/
ret = test_fipc_blocking_send_start(chnl, &response);
ret = test_fipc_blocking_send_start(thc_channel_to_fipc(chnl), &response);
if ( ret ) {
pr_err("Error getting send slot");
return ret;
......@@ -105,18 +105,20 @@ int callee(void *_callee_channel_header)
{
int ret = 0;
unsigned long temp_res;
struct fipc_ring_channel *chan = _callee_channel_header;
struct thc_channel chan;
struct fipc_message *recvd_msg;
unsigned long transaction_id = 0;
enum fn_type type;
thc_channel_init(&chan, (struct fipc_ring_channel *) _callee_channel_header);
for (transaction_id = 0;
transaction_id < TRANSACTIONS*2;
transaction_id++) {
/*
* Try to receive a message
*/
ret = test_fipc_blocking_recv_start(chan, &recvd_msg);
ret = test_fipc_blocking_recv_start(thc_channel_to_fipc(&chan), &recvd_msg);
if (ret) {
pr_err("Error receiving message, ret = %d, exiting...", ret);
goto out;
......@@ -170,7 +172,7 @@ int callee(void *_callee_channel_header)
/*
* Send response back
*/
ret = send_response(chan, recvd_msg, temp_res, type);
ret = send_response(&chan, recvd_msg, temp_res, type);
if (ret) {
pr_err("Error sending response back, ret = %d, exiting...", ret);
goto out;
......
......@@ -17,7 +17,7 @@
static unsigned long msg_times[TRANSACTIONS];
static inline int send_and_get_response_sync(
struct fipc_ring_channel *chan,
struct thc_channel *chan,
struct fipc_message *request,
struct fipc_message **response)
{
......@@ -27,7 +27,7 @@ static inline int send_and_get_response_sync(
/*
* Mark the request as sent
*/
ret = fipc_send_msg_end(chan, request);
ret = fipc_send_msg_end(thc_channel_to_fipc(chan), request);
if (ret) {
pr_err("failed to mark request as sent, ret = %d\n", ret);
goto fail1;
......@@ -36,7 +36,7 @@ static inline int send_and_get_response_sync(
* Try to get the response
*/
ret = test_fipc_blocking_recv_start(chan, &resp);
ret = test_fipc_blocking_recv_start(thc_channel_to_fipc(chan), &resp);
if (ret) {
pr_err("failed to get a response, ret = %d\n", ret);
......@@ -44,7 +44,7 @@ static inline int send_and_get_response_sync(
}
*response = resp;
ret = fipc_recv_msg_end(chan, resp);
ret = fipc_recv_msg_end(thc_channel_to_fipc(chan), resp);
if (ret) {
pr_err("Error finishing receipt of response, ret = %d\n", ret);
return ret;
......@@ -57,13 +57,13 @@ fail1:
return ret;
}
static inline int finish_response_check_fn_type(struct fipc_ring_channel *chnl,
static inline int finish_response_check_fn_type(struct thc_channel *chnl,
struct fipc_message *response,
enum fn_type expected_type)
{
int ret;
enum fn_type actual_type = get_fn_type(response);
ret = fipc_recv_msg_end(chnl, response);
ret = fipc_recv_msg_end(thc_channel_to_fipc(chnl), response);
if (ret) {
pr_err("Error finishing receipt of response, ret = %d\n", ret);
return ret;
......@@ -77,7 +77,7 @@ static inline int finish_response_check_fn_type(struct fipc_ring_channel *chnl,
}
static inline int finish_response_check_fn_type_and_reg0(
struct fipc_ring_channel *chnl,
struct thc_channel *chnl,
struct fipc_message *response,
enum fn_type expected_type,
unsigned long expected_reg0)
......@@ -86,7 +86,7 @@ static inline int finish_response_check_fn_type_and_reg0(
enum fn_type actual_type = get_fn_type(response);
unsigned long actual_reg0 = fipc_get_reg0(response);
ret = fipc_recv_msg_end(chnl, response);
ret = fipc_recv_msg_end(thc_channel_to_fipc(chnl), response);
if (ret) {
pr_err("Error finishing receipt of response, ret = %d\n", ret);
......@@ -106,7 +106,7 @@ static inline int finish_response_check_fn_type_and_reg0(
}
}
static int noinline __used add_nums(struct fipc_ring_channel *chan,
static int noinline __used add_nums(struct thc_channel *chan,
unsigned long trans,
unsigned long res1,
bool is_async)
......@@ -120,7 +120,7 @@ static int noinline __used add_nums(struct fipc_ring_channel *chan,
*/
start_time = test_fipc_start_stopwatch();
ret = test_fipc_blocking_send_start(chan, &request);
ret = test_fipc_blocking_send_start(thc_channel_to_fipc(chan), &request);
if (ret) {
pr_err("Error getting send message, ret = %d\n", ret);
goto fail;
......@@ -165,11 +165,12 @@ fail:
static int msg_test(void* _caller_channel_header, bool is_async)
{
struct fipc_ring_channel *chan = _caller_channel_header;
struct thc_channel chan;
unsigned long transaction_id = 0;
unsigned long start_time, stop_time;
int ret = 0;
thc_channel_init(&chan, (struct fipc_ring_channel*)_caller_channel_header);
thc_init();
preempt_disable();
......@@ -187,7 +188,7 @@ static int msg_test(void* _caller_channel_header, bool is_async)
if( is_async )
{
ASYNC({
ret = add_nums(chan, transaction_id, 1000, is_async);
ret = add_nums(&chan, transaction_id, 1000, is_async);
if (ret) {
pr_err("error doing null invocation, ret = %d\n",
ret);
......@@ -196,7 +197,7 @@ static int msg_test(void* _caller_channel_header, bool is_async)
}
else
{
ret = add_nums(chan, transaction_id, 1000, is_async);
ret = add_nums(&chan, transaction_id, 1000, is_async);
if (ret) {
pr_err("error doing null invocation, ret = %d\n",
ret);
......
......@@ -42,7 +42,8 @@ static int test_ctx_switch(void)
});
ASYNC({
start_time = test_fipc_start_stopwatch();
THCYieldToId(msg_id);
//THCYieldToId(msg_id);
THCYield();
});
});
measurements_arr[i] = end_time - start_time;
......
......@@ -20,6 +20,7 @@ MODULE_LICENSE("GPL");
//channel groups for threads 2 and 3
static struct thc_channel_group group2, group3;
static struct thc_channel_group_item item2to1, item2to3, item3;
static struct thc_channel thc_chan2to1, thc_chan2to3, thc_chan3;
static int setup_and_run_test(void)
{
......@@ -62,13 +63,16 @@ static int setup_and_run_test(void)
goto fail2;
}
item2to1.channel = thread_2_to_1_header;
thc_channel_init(&thc_chan2to1, thread_2_to_1_header);
item2to1.channel = &thc_chan2to1;
thc_channel_group_item_add(&group2, &item2to1);
item2to3.channel = thread_2_to_3_header;
thc_channel_init(&thc_chan2to3, thread_2_to_3_header);
item2to3.channel = &thc_chan2to3;
thc_channel_group_item_add(&group2, &item2to3);
item3.channel = thread3_header;
thc_channel_init(&thc_chan3, thread3_header);
item3.channel = &thc_chan3;
thc_channel_group_item_add(&group3, &item3);
......
......@@ -30,7 +30,7 @@ int thc_dispatch_loop_test(struct thc_channel_group* rx_group, int max_recv_ct)
if( curr_item->dispatch_fn )
{
ASYNC_({
curr_item->dispatch_fn(curr_item->channel, curr_msg);
curr_item->dispatch_fn(curr_item, curr_msg);
},ipc_dispatch);
}
else
......
......@@ -11,12 +11,12 @@
#define BATCH_INTERVAL 100
static struct fipc_ring_channel* channel;
static struct thc_channel channel;
static volatile int num_responses = 0;
static inline int finish_response_check_fn_type_and_reg0(
struct fipc_ring_channel *chnl,
struct thc_channel *chnl,
struct fipc_message *response,
uint32_t expected_type,
unsigned long expected_lhs,
......@@ -27,7 +27,7 @@ static inline int finish_response_check_fn_type_and_reg0(
unsigned long actual_reg0 = fipc_get_reg0(response);
unsigned long expected_reg0;
ret = fipc_recv_msg_end(chnl, response);
ret = fipc_recv_msg_end(thc_channel_to_fipc(chnl), response);
switch( expected_type )
{
......@@ -61,7 +61,7 @@ static inline int finish_response_check_fn_type_and_reg0(
static int add_nums_async(struct fipc_ring_channel* channel,
static int add_nums_async(struct thc_channel* channel,
unsigned long lhs,
unsigned long rhs,
int fn_type)
......@@ -70,7 +70,7 @@ static int add_nums_async(struct fipc_ring_channel* channel,
struct fipc_message *response;
int ret;
if( test_fipc_blocking_send_start(channel, &msg) )
if( test_fipc_blocking_send_start(thc_channel_to_fipc(channel), &msg) )
{
printk(KERN_ERR "Error getting send message for add_nums_async.\n");
}
......@@ -103,7 +103,8 @@ static int run_thread1(void* chan)
int print_transactions_threshold = 0;
unsigned long msg_response = 0;
num_responses = 0;
channel = chan;
thc_channel_init(&channel, (struct fipc_ring_channel*)chan);
thc_init();
DO_FINISH_(thread1_fn,{
......@@ -116,20 +117,20 @@ static int run_thread1(void* chan)
ASYNC(
num_transactions++;
msg_response = add_nums_async(channel, num_transactions, 1, ADD_2_FN);
msg_response = add_nums_async(&channel, num_transactions, 1, ADD_2_FN);
num_responses++;
);
if( (num_transactions) % THD3_INTERVAL == 0 )
{
ASYNC(
num_transactions++;
msg_response = add_nums_async(channel, num_transactions, 2, ADD_10_FN);
msg_response = add_nums_async(&channel, num_transactions, 2, ADD_10_FN);
num_responses++;
);
}
ASYNC(
num_transactions++;
msg_response = add_nums_async(channel, num_transactions, 3, ADD_2_FN);
msg_response = add_nums_async(&channel, num_transactions, 3, ADD_2_FN);
num_responses++;
);
//msleep(1);
......
......@@ -12,15 +12,15 @@
static struct thc_channel_group* rx_group;
//Just returns a value back to thread 1
static int add_2_fn(struct fipc_ring_channel* chan, struct fipc_message* msg)
static int add_2_fn(struct thc_channel* chan, struct fipc_message* msg)
{
unsigned long result = fipc_get_reg0(msg) + fipc_get_reg1(msg);
struct fipc_message* out_msg;
uint32_t request_cookie = thc_get_request_cookie(msg);
fipc_recv_msg_end(chan, msg);
fipc_recv_msg_end(thc_channel_to_fipc(chan), msg);
if( test_fipc_blocking_send_start(chan, &out_msg) )
if( test_fipc_blocking_send_start(thc_channel_to_fipc(chan), &out_msg) )
{
printk(KERN_ERR "Error getting send message for add_2_fn.\n");
}
......@@ -39,14 +39,14 @@ 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)
static int add_10_fn(struct thc_channel* thread1_chan, struct fipc_message* msg)
{
struct thc_channel_group_item *thread3_item;
struct fipc_message* thread1_result;
struct fipc_message* thread3_request;
struct fipc_message* thread3_response;
unsigned long saved_msg_id = thc_get_msg_id(msg);
struct fipc_ring_channel* thread3_chan;
struct thc_channel* thread3_chan;
if( thc_channel_group_item_get(rx_group, 1, &thread3_item) )
{
......@@ -55,7 +55,7 @@ static int add_10_fn(struct fipc_ring_channel* thread1_chan, struct fipc_message
}
thread3_chan = thread3_item->channel;
if( test_fipc_blocking_send_start(thread3_chan, &thread3_request) )
if( test_fipc_blocking_send_start(thc_channel_to_fipc(thread3_chan), &thread3_request) )
{
printk(KERN_ERR "Error getting send message for add_10_fn.\n");
}
......@@ -65,12 +65,12 @@ static int add_10_fn(struct fipc_ring_channel* thread1_chan, struct fipc_message
fipc_set_reg1(thread3_request, fipc_get_reg1(msg));
//mark channel 1 message as received and the slot as available
fipc_recv_msg_end(thread1_chan, msg);
fipc_recv_msg_end(thc_channel_to_fipc(thread1_chan), msg);
thc_ipc_call(thread3_chan, thread3_request, &thread3_response);
fipc_recv_msg_end(thread3_chan, msg);
fipc_recv_msg_end(thc_channel_to_fipc(thread3_chan), msg);
if( test_fipc_blocking_send_start(thread1_chan, &thread1_result) )
if( test_fipc_blocking_send_start(thc_channel_to_fipc(thread1_chan), &thread1_result) )
{
printk(KERN_ERR "Error getting send message for add_10_fn.\n");
}
......@@ -88,8 +88,9 @@ static int add_10_fn(struct fipc_ring_channel* thread1_chan, struct fipc_message
}
static int thread1_dispatch_fn(struct fipc_ring_channel* chan, struct fipc_message* msg)
static int thread1_dispatch_fn(struct thc_channel_group_item* item, struct fipc_message* msg)
{
struct thc_channel* chan = item->channel;
switch( get_fn_type(msg) )
{
case ADD_2_FN:
......
......@@ -13,17 +13,17 @@ static struct thc_channel_group* rx_group;
static int add_10_fn(struct fipc_ring_channel* chan, struct fipc_message* msg)
static int add_10_fn(struct thc_channel* chan, struct fipc_message* msg)
{
unsigned long msg_id = thc_get_msg_id(msg);
unsigned long reg0 = fipc_get_reg0(msg);
unsigned long reg1 = fipc_get_reg1(msg);
unsigned long result = reg0 + reg1 + 10;
struct fipc_message* out_msg;
fipc_recv_msg_end(chan,msg);
fipc_recv_msg_end(thc_channel_to_fipc(chan),msg);
msleep(10);
if( test_fipc_blocking_send_start(chan, &out_msg) )
if( test_fipc_blocking_send_start(thc_channel_to_fipc(chan), &out_msg) )
{
printk(KERN_ERR "Error getting send message for add_10_fn.\n");
}
......@@ -38,8 +38,9 @@ static int add_10_fn(struct fipc_ring_channel* chan, struct fipc_message* msg)
return 0;
}
static int thread2_dispatch_fn(struct fipc_ring_channel* chan, struct fipc_message* msg)
static int thread2_dispatch_fn(struct thc_channel_group_item* item, struct fipc_message* msg)
{
struct thc_channel* chan = item->channel;
switch( get_fn_type(msg) )
{
case ADD_10_FN:
......
......@@ -3,7 +3,7 @@
int send_and_get_response(
struct fipc_ring_channel *chan,
struct thc_channel *chan,
struct fipc_message *request,
struct fipc_message **response,
uint32_t msg_id)
......@@ -14,7 +14,7 @@ int send_and_get_response(
/*
* Mark the request as sent
*/
ret = fipc_send_msg_end(chan, request);
ret = fipc_send_msg_end(thc_channel_to_fipc(chan), request);
if (ret) {
pr_err("failed to mark request as sent, ret = %d\n", ret);
goto fail1;
......
......@@ -13,7 +13,7 @@ int thread2_fn(void* data);
int thread3_fn(void* data);
int send_and_get_response(
struct fipc_ring_channel *chan,
struct thc_channel *chan,
struct fipc_message *request,
struct fipc_message **response,
uint32_t msg_id);
......
......@@ -78,7 +78,7 @@ async_add_nums(struct thc_channel *chan, unsigned long trans,
goto fail;
}
/*
* Set up rpc msg
* Set up rpc ms
*/
set_fn_type(request, ADD_NUMS);
fipc_set_reg0(request, trans);
......
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