Commit 012a6637 authored by Vikram Narayanan's avatar Vikram Narayanan

test_mods: Nullnet fixes for SMP

parent 947f1065
......@@ -22,9 +22,12 @@ struct lcd_create_ctx **dummy_ctxs;
cptr_t *dummy_lcds;
cptr_t net_chnl;
cptr_t net_chnl_domain_cptr, dummy_chnl_domain_cptr;
int num_lcds = NUM_LCDS;
cptr_t *dummy_chnl_domain_cptrs;
static int num_lcds = NUM_LCDS;
module_param(num_lcds, int, 0);
MODULE_PARM_DESC(num_lcds, "Number of LCDs to launch");
static int boot_main(void)
{
int ret;
......@@ -142,6 +145,8 @@ static int boot_main(void)
goto fail8;
}
msleep_interruptible(3000);
LIBLCD_MSG("starting dummy ethernet...\n");
for (i = 0; i < num_lcds; i++) {
LIBLCD_MSG("Starting LCD %d ", i);
......@@ -150,6 +155,7 @@ static int boot_main(void)
LIBLCD_ERR("failed to start dummy lcd");
goto fail9;
}
msleep_interruptible(3000);
}
/*
* Wait for 4 seconds
......
......@@ -451,6 +451,8 @@ int create_async_channel(void)
xmit_ch_item->xmit_channel = true;
thc_channel_group_item_add(&ch_grp[current_lcd_id], xmit_ch_item);
printk("%s:%d adding chnl: %p to group: %p", __func__, current_lcd_id,
xmit_ch_item, &ch_grp[current_lcd_id]);
return ret;
fail3:
......@@ -462,12 +464,12 @@ fail1:
return ret;
}
struct thc_channel_group_item *ptrs[32];
struct thc_channel_group_item *ptrs[NUM_LCDS][32];
static int idx[NUM_LCDS] = {0};
int create_one_async_channel(struct thc_channel **chnl, cptr_t *tx, cptr_t *rx)
{
int ret;
static int idx = 0;
struct thc_channel_group_item *xmit_ch_item;
#ifdef ONE_SLOT
ret = setup_async_channel_0(tx, rx, chnl);
......@@ -487,7 +489,10 @@ int create_one_async_channel(struct thc_channel **chnl, cptr_t *tx, cptr_t *rx)
thc_channel_group_item_add(&ch_grp[current_lcd_id], xmit_ch_item);
ptrs[idx++%32] = xmit_ch_item;
printk("%s:%d adding chnl: %p to group: %p", __func__, current_lcd_id,
xmit_ch_item, &ch_grp[current_lcd_id]);
ptrs[current_lcd_id][idx[current_lcd_id]++%32] = xmit_ch_item;
return 0;
}
......@@ -1653,11 +1658,11 @@ int cleanup_channel_group(struct fipc_message *request, struct thc_channel *chan
fipc_recv_msg_end(thc_channel_to_fipc(channel), request);
for (i = 0; i < 32; i++) {
if (ptrs[i]) {
thc_channel_group_item_remove(&ch_grp[current_lcd_id], ptrs[i]);
destroy_async_channel(ptrs[i]->channel);
kfree(ptrs[i]);
ptrs[i] = NULL;
if (ptrs[current_lcd_id][i]) {
thc_channel_group_item_remove(&ch_grp[current_lcd_id], ptrs[current_lcd_id][i]);
destroy_async_channel(ptrs[current_lcd_id][i]->channel);
kfree(ptrs[current_lcd_id][i]);
ptrs[current_lcd_id][i] = NULL;
} //if
} //for
......
......@@ -41,7 +41,6 @@ static void main_and_loop(void)
unsigned long long disp_loop_cycles = 0, percent = 0;
#endif
struct fipc_message *msg;
int _local_lcd_id = current_lcd_id;
DO_FINISH(
......@@ -88,9 +87,12 @@ static void main_and_loop(void)
percent = 0;
}
#endif
if (disp_loop_cycles)
LIBLCD_MSG("total_time: %llu | disp_loop %llu | percent %llu",
diff_g, disp_loop_cycles, percent);
if (disp_loop_cycles) {
u64 div = diff_g / disp_loop_cycles;
percent = 100;
LIBLCD_MSG("total_time: %llu | disp_loop %llu | div: %llu percent: %llu",
diff_g, disp_loop_cycles, div, percent/div);
}
start_g = lcd_RDTSC_START();
// reset disp_loop_cycles
disp_loop_cycles = 0;
......@@ -100,7 +102,7 @@ static void main_and_loop(void)
/*
* Do RR async receive
*/
list_for_each_entry(curr_item, &(ch_grp[_local_lcd_id].head), list) {
list_for_each_entry(curr_item, &(ch_grp[current_lcd_id].head), list) {
if (curr_item->xmit_channel) {
ret = fipc_nonblocking_recv_start_if(
thc_channel_to_fipc(
......
......@@ -22,7 +22,15 @@
#include <lcd_config/post_hook.h>
#define NUM_PACKETS (1000000)
#define VMALLOC_SZ (NUM_PACKETS * sizeof(uint64_t))
#define CONFIG_VMALLOC_SHARED_POOL
#ifdef CONFIG_VMALLOC_SHARED_POOL
#define SKB_DATA_POOL_SIZE (256UL << 20)
#define SKB_DATA_POOL_PAGES (SKB_DATA_POOL_SIZE >> PAGE_SHIFT)
#define SKB_DATA_POOL_ORDER ilog2(roundup_pow_of_two(SKB_DATA_POOL_PAGES))
#endif
#define CORRECTION_VALUE 44
//#define NDO_XMIT_TS
......@@ -183,14 +191,12 @@ int pool_pick(void)
__func__, best_diff, best_idx, pools[best_idx].start_idx, pools[best_idx].end_idx);
return best_idx;
}
extern priv_pool_t *skb_pool;
void skb_data_pool_init(void)
{
//pool = priv_pool_init(SKB_DATA_POOL, 10, SKB_DATA_SIZE);
pool_base = base_pools[pools[pool_pick()].start_idx];
pool_size = best_diff * ((1 << pool_order) * PAGE_SIZE);
pool = priv_pool_init(SKB_DATA_POOL, (void*) pool_base, pool_size, 2048);
pool_base = vzalloc(SKB_DATA_POOL_SIZE);
pool_size = SKB_DATA_POOL_SIZE;
skb_pool = pool = priv_pool_init((void*) pool_base, pool_size, 2048, "skb_data_pool");
#ifdef SKBC_PRIVATE_POOL
skbc_pool = priv_pool_init(SKB_CONTAINER_POOL, 10,
......@@ -200,6 +206,8 @@ void skb_data_pool_init(void)
void skb_data_pool_free(void)
{
if (pool_base)
vfree(pool_base);
if (pool)
priv_pool_destroy(pool);
#ifdef SKBC_PRIVATE_POOL
......@@ -1534,8 +1542,8 @@ void setup_device_ops_trampolines(struct net_device_ops_container *netdev_ops_co
ndo_start_xmit_hidden_args->t_handle->hidden_args = ndo_start_xmit_hidden_args;
ndo_start_xmit_hidden_args->struct_container = netdev_ops_container;
ndo_start_xmit_hidden_args->cspace = c_cspace;
ndo_start_xmit_hidden_args->lcds[1].lcd_async_chnl = lcd_channels[1];
ndo_start_xmit_hidden_args->lcds[1].lcd_sync_ep = new_sync_eps[1];
//ndo_start_xmit_hidden_args->lcds[1].lcd_async_chnl = lcd_channels[1];
//ndo_start_xmit_hidden_args->lcds[1].lcd_sync_ep = new_sync_eps[1];
netdev_ops_container->net_device_ops.ndo_start_xmit = LCD_HANDLE_TO_TRAMPOLINE(ndo_start_xmit_hidden_args->t_handle);
ndo_validate_addr_hidden_args = kzalloc(sizeof( *ndo_validate_addr_hidden_args ), GFP_KERNEL);
......@@ -1723,7 +1731,9 @@ void setup(struct net_device *dev, struct trampoline_hidden_args *hidden_args)
struct setup_container *setup_container;
struct net_device_container *net_dev_container;
struct net_device_ops_container *netdev_ops_container;
#ifndef CONFIG_VMALLOC_SHARED_POOL
struct page *p;
#endif
unsigned int pool_ord;
cptr_t pool_cptr;
uint32_t request_cookie;
......@@ -1780,20 +1790,25 @@ void setup(struct net_device *dev, struct trampoline_hidden_args *hidden_args)
goto fail_ipc;
}
p = virt_to_head_page(pool->pool);
#ifdef CONFIG_VMALLOC_SHARED_POOL
ret = lcd_volunteer_vmalloc_mem(__gva((unsigned long)pool->base), SKB_DATA_POOL_SIZE >> PAGE_SHIFT, &pool_cptr);
pool_ord = SKB_DATA_POOL_ORDER;
#else
p = virt_to_head_page(pool->base);
pool_ord = ilog2(roundup_pow_of_two((
pool->total_pages * PAGE_SIZE)
>> PAGE_SHIFT));
ret = lcd_volunteer_pages(p, pool_ord, &pool_cptr);
#endif
if (ret) {
LIBLCD_ERR("volunteer shared data pool");
goto fail_vol;
}
pool_pfn_start = (unsigned long)pool->pool >> PAGE_SHIFT;
pool_pfn_start = (unsigned long)pool->base >> PAGE_SHIFT;
pool_pfn_end = pool_pfn_start + pool->total_pages;
printk("%s, pool pfn start %lu | end %lu\n", __func__,
......@@ -2155,11 +2170,12 @@ int register_child(void)
LIBLCD_ERR("error adding to dispatch loop");
goto fail2;
}
LIBLCD_MSG("%s, child %d registration complete\n",
__func__, lcd_r1());
lcd_channels[lcd_r1()] = chnl;
LIBLCD_MSG("%s, child %d registration complete!\n", __func__, lcd_r1());
printk("%s, chnl: %p lcd_channels[%lu]: %p\n", __func__, chnl, lcd_r1(), lcd_channels[lcd_r1()]);
g_ndo_start_xmit_hidden_args->lcds[lcd_r1()].lcd_async_chnl = lcd_channels[lcd_r1()];
g_ndo_start_xmit_hidden_args->lcds[lcd_r1()].lcd_sync_ep = new_sync_eps[lcd_r1()];
......@@ -2431,6 +2447,7 @@ int prep_channel(struct trampoline_hidden_args *hidden_args, int queue)
if (queue) {
from_sync_end = hidden_args->lcds[queue].lcd_sync_ep;
async_chnl = hidden_args->lcds[queue].lcd_async_chnl;
current->ptstate->queue_mapping = queue;
} else {
from_sync_end = hidden_args->sync_ep;
async_chnl = hidden_args->async_chnl;
......@@ -2735,33 +2752,57 @@ fail_async:
}
#endif /* CONSUME_SKB_NO_HASHING */
int trigger_exit_to_lcd(struct thc_channel *_channel, enum dispatch_t disp)
int trigger_exit_to_lcd(struct thc_channel *_channel)
{
struct fipc_message *_request;
int ret;
int i;
unsigned int request_cookie;
ret = async_msg_blocking_send_start(_channel,
&_request);
ret = async_msg_blocking_send_start(_channel, &_request);
if (ret) {
LIBLCD_ERR("failed to get a send slot");
goto fail_async;
}
async_msg_set_fn_type(_request,
disp);
async_msg_set_fn_type(_request, TRIGGER_EXIT);
/* No need to wait for a response here */
ret = thc_ipc_send_request(_channel,
_request,
&request_cookie);
printk("%s, sending EXIT to %p\n", __func__, _channel);
ret = thc_ipc_send_request(_channel, _request, &request_cookie);
awe_mapper_remove_id(request_cookie);
fail_async:
return ret;
}
int cleanup_channels(struct thc_channel *_channel)
{
struct fipc_message *_request;
int ret;
int i;
unsigned int request_cookie;
for (i = 0; i < NUM_LCDS; i++) {
ret = async_msg_blocking_send_start(lcd_channels[i], &_request);
if (ret) {
LIBLCD_ERR("failed to get a send slot");
goto fail_async;
}
async_msg_set_fn_type(_request, TRIGGER_CLEAN);
/* No need to wait for a response here */
printk("%s, sending CLEANUP to %p\n", __func__,
lcd_channels[i]);
ret = thc_ipc_send_request(lcd_channels[i], _request,
&request_cookie);
awe_mapper_remove_id(request_cookie);
}
// free the pointers
// there is a race if get_stats try to operate on this data at the same time
// but quite unlikely.
if (disp == TRIGGER_CLEAN) {
thread = 0;
for (i = 0; i < NUM_CORES; i++) {
if (ptrs[i]) {
if (ptrs[i]->exited) {
......@@ -2771,15 +2812,7 @@ int trigger_exit_to_lcd(struct thc_channel *_channel, enum dispatch_t disp)
}
}
}
}
if (ret) {
LIBLCD_ERR("thc_ipc send");
goto fail_ipc;
}
awe_mapper_remove_id(request_cookie);
fail_async:
fail_ipc:
return ret;
}
......@@ -35,15 +35,19 @@ extern struct ptstate_t *ptrs[NUM_THREADS];
extern struct rtnl_link_stats64 g_stats;
extern struct thc_channel *xmit_chnl;
extern priv_pool_t *pool;
DEFINE_SPINLOCK(prep_lock);
/*
* setup a new channel for the first time when an application thread
* wishes to send a packet through this interface
*/
int setup_once(struct trampoline_hidden_args *hidden_args, int queue)
int setup_once(struct trampoline_hidden_args *hidden_args)
{
printk("%s, %s:%d lcdenter | skbqueue %d\n", __func__,
current->comm, current->pid, queue);
int queue;
static int count = 0;
printk("%s, %s:%d lcdenter \n", __func__,
current->comm, current->pid);
/* step 1. create lcd env */
lcd_enter();
......@@ -80,7 +84,10 @@ int setup_once(struct trampoline_hidden_args *hidden_args, int queue)
!strncmp(current->comm, "lt-iperf3",
strlen("lt-iperf3"))) {
spin_lock(&prep_lock);
queue = count++ % NUM_LCDS;
prep_channel(hidden_args, queue);
spin_unlock(&prep_lock);
printk("===================================\n");
printk("===== Private Channel created (pid %d) =====\n", current->pid);
printk("===================================\n");
......@@ -167,7 +174,7 @@ int __ndo_start_xmit_inner_async(struct sk_buff *skb, struct net_device *dev, st
fipc_set_reg3(_request,
(unsigned long)
((void*)skb->head - pool->pool));
((void*)skb->head - pool->base));
fipc_set_reg4(_request, skb->end);
fipc_set_reg5(_request, skb->protocol);
......@@ -225,7 +232,7 @@ int __ndo_start_xmit_bare_async(struct sk_buff *skb, struct net_device *dev, str
}
if (unlikely(!current->ptstate)) {
if (setup_once(hidden_args, 0))
if (setup_once(hidden_args))
goto free;
}
......@@ -276,7 +283,7 @@ int __ndo_start_xmit_bare_fipc_nomarshal(struct sk_buff *skb, struct net_device
}
if (unlikely(!current->ptstate)) {
if (setup_once(hidden_args, 0))
if (setup_once(hidden_args))
goto free;
}
......@@ -368,7 +375,7 @@ int ndo_start_xmit_noasync(struct sk_buff *skb, struct net_device *dev, struct t
/* setup once for this thread */
if (unlikely(!current->ptstate)) {
if (setup_once(hidden_args, skb->queue_mapping))
if (setup_once(hidden_args))
goto free;
}
......@@ -393,7 +400,7 @@ int ndo_start_xmit_noasync(struct sk_buff *skb, struct net_device *dev, struct t
fipc_set_reg3(_request,
(unsigned long)
((void*)skb->head - pool->pool));
((void*)skb->head - pool->base));
fipc_set_reg4(_request, skb->end);
fipc_set_reg5(_request, skb->protocol);
......@@ -495,7 +502,7 @@ int ndo_start_xmit_async(struct sk_buff *skb, struct net_device *dev, struct tra
fipc_set_reg3(_request,
(unsigned long)
((void*)skb->head - pool->pool));
((void*)skb->head - pool->base));
fipc_set_reg4(_request, skb->end);
fipc_set_reg5(_request, skb->protocol);
......@@ -557,9 +564,9 @@ int ndo_start_xmit_async_landing(struct sk_buff *first, struct net_device *dev,
{
struct sk_buff *skb = first;
int rc = NETDEV_TX_OK;
static int count = 0;
skb->queue_mapping = (count++) & 0x1;
if (current->ptstate)
skb->queue_mapping = current->ptstate->queue_mapping;
if (!skb->next)
skb->chain_skb = false;
......@@ -569,7 +576,7 @@ int ndo_start_xmit_async_landing(struct sk_buff *first, struct net_device *dev,
/* chain skb */
if (unlikely(!current->ptstate)) {
if (setup_once(hidden_args, 0))
if (setup_once(hidden_args))
goto free;
}
......
......@@ -35,7 +35,8 @@ struct net_info {
};
static LIST_HEAD(net_infos);
extern int trigger_exit_to_lcd(struct thc_channel *_channel, enum dispatch_t);
extern int trigger_exit_to_lcd(struct thc_channel *_channel);
extern int cleanup_channels(struct thc_channel *_channel);
int register_child(void);
......@@ -250,12 +251,12 @@ static void loop(cptr_t register_chnl)
if (unload_lcd || clean_up) {
if (__get_net(&net)) {
if (unload_lcd) {
trigger_exit_to_lcd(net->chnl, TRIGGER_EXIT);
trigger_exit_to_lcd(net->chnl);
unload_lcd ^= unload_lcd;
}
if (clean_up) {
LIBLCD_MSG("cleanup triggered");
trigger_exit_to_lcd(net->chnl, TRIGGER_CLEAN);
cleanup_channels(net->chnl);
clean_up ^= clean_up;
}
}
......
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