summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorboure2008-07-01 13:51:21 +0000
committerboure2008-07-01 13:51:21 +0000
commit64c74f869cb87ea693bc2b913dd200e1bc049b0b (patch)
tree53427fd2ef43bc637fbb9d05cfda639cfa30b8c1
parent0ee8bcd15d773a52c97eb90843d171e97b7e370e (diff)
modified priority heaps of the connection from dynamic to static
git-svn-id: svn+ssh://pessac/svn/cesar/trunk@2507 017c9cb6-072f-447c-8318-d5b54f68fe89
-rw-r--r--cesar/cp2/cco/bw/bw.h2
-rw-r--r--cesar/cp2/cco/bw/bw_prio_heap.h6
-rw-r--r--cesar/cp2/cco/bw/inc/bw_prio_heap.h34
-rw-r--r--cesar/cp2/cco/bw/src/bw.c60
-rw-r--r--cesar/cp2/cco/bw/src/bw_prio_heap.c159
-rw-r--r--cesar/cp2/cco/bw/test/src/bw_prio_heap_test.c97
6 files changed, 115 insertions, 243 deletions
diff --git a/cesar/cp2/cco/bw/bw.h b/cesar/cp2/cco/bw/bw.h
index 9b3f9b98a7..8243367e1e 100644
--- a/cesar/cp2/cco/bw/bw.h
+++ b/cesar/cp2/cco/bw/bw.h
@@ -91,7 +91,7 @@ struct cp_cco_bw_t
/**
* Priority heap list
*/
- list_t prio_heap;
+ cp_cco_bw_prio_heap_t prio_heap[CP_CCO_BW_NB_PRIORITY_HEAPS];
/**
* Actual schedule
diff --git a/cesar/cp2/cco/bw/bw_prio_heap.h b/cesar/cp2/cco/bw/bw_prio_heap.h
index 6d64372b45..9c22c7a3f6 100644
--- a/cesar/cp2/cco/bw/bw_prio_heap.h
+++ b/cesar/cp2/cco/bw/bw_prio_heap.h
@@ -68,10 +68,6 @@ struct cp_cco_bw_prio_heap_t
*/
list_t conns;
- /**
- * Node of the list of heaps
- */
- list_node_t node;
};
typedef struct cp_cco_bw_prio_heap_t cp_cco_bw_prio_heap_t;
@@ -114,7 +110,7 @@ cp_cco_bw_prio_heap_clear_conn(cp_t *ctx);
* Init function
*/
void
-cp_cco_bw_prio_heap_init(list_t *heap_list);
+cp_cco_bw_prio_heap_init(cp_t *ctx);
/**
* Uninit function
diff --git a/cesar/cp2/cco/bw/inc/bw_prio_heap.h b/cesar/cp2/cco/bw/inc/bw_prio_heap.h
index ecdf0a43e4..c84ca9538f 100644
--- a/cesar/cp2/cco/bw/inc/bw_prio_heap.h
+++ b/cesar/cp2/cco/bw/inc/bw_prio_heap.h
@@ -28,16 +28,6 @@ cp_cco_bw_prio_conn_t*
cp_cco_bw_prio_heap_get_conn(cp_t *ctx, u16 cid);
/**
- * Returns the good priority heap
- * \param ctx Control Plane context
- * \param prio Priority of the heap
- * \return the priority heap
- *
- */
-cp_cco_bw_prio_heap_t *
-cp_cco_bw_prio_heap_get_heap(cp_t *ctx, u8 prio);
-
-/**
* intiate a connection
* \return the initiated connection
*
@@ -53,7 +43,7 @@ cp_cco_bw_prio_heap_init_prio_conn(void);
*
*/
cp_cco_bw_prio_conn_t*
-cp_cco_bw_prio_heap_get_next_conn(cp_cco_bw_prio_heap_t* heap, cp_cco_bw_prio_conn_t *conn);
+cp_cco_bw_prio_heap_get_next_conn(cp_cco_bw_prio_heap_t heap, cp_cco_bw_prio_conn_t *conn);
/**
@@ -63,26 +53,6 @@ cp_cco_bw_prio_heap_get_next_conn(cp_cco_bw_prio_heap_t* heap, cp_cco_bw_prio_co
*
*/
cp_cco_bw_prio_conn_t*
-cp_cco_bw_prio_heap_get_first_conn(cp_cco_bw_prio_heap_t *heap);
-
-
-/**
- * Returns the first heap
- * \return the first heap
- *
- */
-cp_cco_bw_prio_heap_t*
-cp_cco_bw_prio_heap_get_first_heap(cp_t *ctx);
-
-
-/**
- * Returns the next heap
- * \param ctx Control Plane context
- * \param heap Previous heap
- * \return Next heap
- *
- */
-cp_cco_bw_prio_heap_t*
-cp_cco_bw_prio_heap_get_next_heap(cp_t *ctx, cp_cco_bw_prio_heap_t *heap);
+cp_cco_bw_prio_heap_get_first_conn(cp_cco_bw_prio_heap_t heap);
#endif /* cp_cco_bw_prio_heap.h*/
diff --git a/cesar/cp2/cco/bw/src/bw.c b/cesar/cp2/cco/bw/src/bw.c
index 1832a10ce1..52a7ede768 100644
--- a/cesar/cp2/cco/bw/src/bw.c
+++ b/cesar/cp2/cco/bw/src/bw.c
@@ -52,6 +52,8 @@ cp_cco_bw_new_sched (cp_t *ctx)
u16 beacon_period_atu;
+ dbg_assert(ctx);
+
beacon_period_atu = MAC_TCK_TO_ATU(ctx->pwl.bp_avln_ntb[2] - ctx->pwl.bp_avln_ntb[1]);
list_init(&ctx->bw.actual_schedule);
@@ -126,6 +128,8 @@ cp_cco_bw_alloc_sched (cp_t *ctx)
// u16 begin_alloc;
// u16 end_alloc;
+ dbg_assert(ctx);
+
/*Clear the schedule*/
cp_cco_bw_uninit_actual_sched(ctx);
@@ -250,6 +254,9 @@ cp_cco_bw_alloc (cp_t *ctx, cp_conn_t *conn)
/*beacon duration atu*/
u16 beacon_period_atu;
+ dbg_assert(ctx);
+ dbg_assert(conn);
+
/*Init the beacon period with the pwl values*/
beacon_period_atu = MAC_TCK_TO_ATU(ctx->pwl.bp_avln_ntb[2] - ctx->pwl.bp_avln_ntb[1]);
@@ -342,6 +349,7 @@ cp_cco_bw_alloc (cp_t *ctx, cp_conn_t *conn)
void
cp_cco_bw_finalise_sched(cp_t *ctx)
{
+ dbg_assert(ctx);
/*TODO*/
}
@@ -367,6 +375,11 @@ cp_cco_bw_get_alloc_ble(cp_link_ble_interval_t *first_ble,
/*Working BLE*/
cp_link_ble_interval_t ble;
+ dbg_assert(first_ble);
+ dbg_assert(last_ble);
+ dbg_assert(alloc);
+ dbg_assert(next_alloc);
+
/*Actual BLE*/
ble = *first_ble;
@@ -470,6 +483,13 @@ cp_cco_bw_calculation_of_alloc_time(cp_link_ble_interval_t *first_ble,
u16 alloc_left;
cp_link_ble_interval_t *ble;
+ dbg_assert(first_ble);
+ dbg_assert(last_ble);
+ dbg_assert(alloc_st);
+ dbg_assert(alloc_et);
+ dbg_assert(alloc);
+ dbg_assert(next_alloc);
+
if(first_ble->ble >= last_ble->ble)
{
ble = first_ble;
@@ -569,6 +589,10 @@ cp_cco_bw_set_next_free_time_space(cp_t *ctx,
cp_cco_bw_alloc_t **prev_alloc,
cp_cco_bw_alloc_t **next_alloc)
{
+ dbg_assert(ctx);
+ dbg_assert(prev_alloc);
+ dbg_assert(next_alloc);
+
do
{
*prev_alloc = *next_alloc;
@@ -585,9 +609,7 @@ cp_cco_bw_init (cp_t* ctx)
{
dbg_assert(ctx);
- list_init(&ctx->bw.prio_heap);
-
- cp_cco_bw_prio_heap_init(&ctx->bw.prio_heap);
+ cp_cco_bw_prio_heap_init(ctx);
list_init(&ctx->bw.actual_schedule);
list_init(&ctx->bw.finalised_schedule);
@@ -598,8 +620,8 @@ cp_cco_bw_uninit (cp_t* ctx)
{
dbg_assert(ctx);
- cp_cco_bw_prio_heap_t *heap;
cp_cco_bw_alloc_t *conn;
+ u16 nb_heap = 0;
while(!list_empty(&ctx->bw.actual_schedule))
{
@@ -619,25 +641,23 @@ cp_cco_bw_uninit (cp_t* ctx)
blk_release(conn);
}
- while(!list_empty(&ctx->bw.prio_heap))
+ while(nb_heap < CP_CCO_BW_NB_PRIORITY_HEAPS)
{
- heap = PARENT_OF(cp_cco_bw_prio_heap_t, node,list_begin(&ctx->bw.prio_heap));
-
- cp_cco_bw_prio_heap_uninit(&heap->conns);
- list_remove(&ctx->bw.prio_heap, list_begin(&ctx->bw.prio_heap));
-
- blk_release(heap);
+ cp_cco_bw_prio_heap_uninit(&ctx->bw.prio_heap[nb_heap].conns);
+ nb_heap++;
}
+
}
void
cp_cco_bw_alloc_add (cp_t *ctx, cp_cco_bw_alloc_t *alloc)
{
- dbg_assert(alloc);
-
cp_cco_bw_alloc_t *prev_alloc;
cp_cco_bw_alloc_t *next_alloc;
+ dbg_assert(ctx);
+ dbg_assert(alloc);
+
list_init_node(&alloc->node);
prev_alloc = cp_cco_bw_get_first_alloc_actual(ctx);
@@ -688,6 +708,7 @@ void
cp_cco_bw_uninit_actual_sched(cp_t *ctx)
{
dbg_assert(ctx);
+
while(!list_empty(&ctx->bw.actual_schedule))
cp_cco_bw_alloc_remove(ctx,
PARENT_OF(cp_cco_bw_alloc_t,
@@ -701,10 +722,11 @@ cp_cco_bw_uninit_actual_sched(cp_t *ctx)
cp_cco_bw_alloc_t*
cp_cco_bw_alloc_get_first_txop(cp_t *ctx, u16 cid)
{
- dbg_assert(ctx);
cp_cco_bw_alloc_t* alloc;
u16 beacon_period_atu;
+ dbg_assert(ctx);
+
beacon_period_atu = MAC_TCK_TO_ATU(ctx->pwl.bp_avln_ntb[2] - ctx->pwl.bp_avln_ntb[1]);
alloc = PARENT_OF(cp_cco_bw_alloc_t, node,
@@ -725,11 +747,11 @@ cp_cco_bw_alloc_get_first_txop(cp_t *ctx, u16 cid)
cp_cco_bw_alloc_t*
cp_cco_bw_alloc_get_next_txop(cp_t *ctx, cp_cco_bw_alloc_t* alloc)
{
+ cp_cco_bw_alloc_t* next_alloc;
+
dbg_assert(ctx);
dbg_assert(alloc);
- cp_cco_bw_alloc_t* next_alloc;
-
next_alloc = PARENT_OF(cp_cco_bw_alloc_t, node,
list_begin(&ctx->bw.actual_schedule));
@@ -798,6 +820,8 @@ cp_cco_bw_get_next_alloc (cp_t *ctx, cp_cco_bw_alloc_t *prev_alloc)
u16
cp_cco_bw_get_nb_alloc(cp_t *ctx, cp_cco_bw_persistence_t persistence)
{
+ dbg_assert(ctx);
+
return persistence = CP_CCO_BW_PERSISTENCE_PERSISTENT ?
ctx->bw.nb_alloc_pers : ctx->bw.nb_alloc_no_pers;
}
@@ -805,6 +829,8 @@ cp_cco_bw_get_nb_alloc(cp_t *ctx, cp_cco_bw_persistence_t persistence)
cp_cco_bw_alloc_t*
cp_cco_bw_get_first_alloc_actual(cp_t *ctx)
{
+ dbg_assert(ctx);
+
return PARENT_OF(cp_cco_bw_alloc_t,
node,
list_begin(&ctx->bw.actual_schedule));
@@ -813,6 +839,8 @@ cp_cco_bw_get_first_alloc_actual(cp_t *ctx)
cp_cco_bw_alloc_t*
cp_cco_bw_get_next_alloc_actual(cp_cco_bw_alloc_t *alloc)
{
+ dbg_assert(alloc);
+
return PARENT_OF(cp_cco_bw_alloc_t,
node,
list_next(&alloc->node));
diff --git a/cesar/cp2/cco/bw/src/bw_prio_heap.c b/cesar/cp2/cco/bw/src/bw_prio_heap.c
index b545cd5c92..d5260b7064 100644
--- a/cesar/cp2/cco/bw/src/bw_prio_heap.c
+++ b/cesar/cp2/cco/bw/src/bw_prio_heap.c
@@ -29,23 +29,21 @@
cp_cco_bw_prio_conn_t*
cp_cco_bw_prio_heap_get_most_prior_conn (cp_t *ctx)
{
- cp_cco_bw_prio_heap_t* heap;
- cp_cco_bw_prio_conn_t* conn;
-
- heap = cp_cco_bw_prio_heap_get_first_heap(ctx);
+ cp_cco_bw_prio_conn_t* conn = NULL;
+ u16 nb_heap = 0;
/* while still heaps */
- do
+ while(nb_heap < CP_CCO_BW_NB_PRIORITY_HEAPS
+ && !conn)
{
- conn = cp_cco_bw_prio_heap_get_first_conn(heap);
+ conn = cp_cco_bw_prio_heap_get_first_conn(ctx->bw.prio_heap[(CP_CCO_BW_NB_PRIORITY_HEAPS-1) - nb_heap]);
/* while still conn not allocated in the heap */
while(conn && conn->alloc_status)
- conn = cp_cco_bw_prio_heap_get_next_conn(heap, conn);
+ conn = cp_cco_bw_prio_heap_get_next_conn(ctx->bw.prio_heap[(CP_CCO_BW_NB_PRIORITY_HEAPS-1) - nb_heap], conn);
- heap = cp_cco_bw_prio_heap_get_next_heap(ctx, heap);
+ nb_heap ++;
}
- while(heap && !conn);
return conn;
}
@@ -53,12 +51,8 @@ cp_cco_bw_prio_heap_get_most_prior_conn (cp_t *ctx)
void
cp_cco_bw_prio_heap_add_conn (cp_t *ctx, u16 cid, u8 prio)
{
-
- cp_cco_bw_prio_heap_t *heap;
cp_cco_bw_prio_conn_t *conn;
- heap = cp_cco_bw_prio_heap_get_heap(ctx, prio);
-
/* Init the new conn */
conn = cp_cco_bw_prio_heap_init_prio_conn();
@@ -66,42 +60,40 @@ cp_cco_bw_prio_heap_add_conn (cp_t *ctx, u16 cid, u8 prio)
conn->alloc_status = false;
/* add the new conn into the list */
- list_push(&heap->conns,&conn->node);
+ list_push(&ctx->bw.prio_heap[prio].conns,&conn->node);
/* add 1 to the number of conn */
- heap->nb_conn++;
+ ctx->bw.prio_heap[prio].nb_conn++;
}
void
cp_cco_bw_prio_heap_del_conn (cp_t *ctx, u16 cid)
{
- cp_cco_bw_prio_heap_t* heap;
- cp_cco_bw_prio_conn_t* conn;
+ cp_cco_bw_prio_conn_t* conn = NULL;
+ u16 nb_heap = 0;
dbg_assert(ctx);
- heap = cp_cco_bw_prio_heap_get_first_heap(ctx);
-
/* while still heaps */
- do
+ while(nb_heap < CP_CCO_BW_NB_PRIORITY_HEAPS
+ && !conn)
{
/* first connection of the heap */
- conn = cp_cco_bw_prio_heap_get_first_conn(heap);
+ conn = cp_cco_bw_prio_heap_get_first_conn(ctx->bw.prio_heap[nb_heap]);
/* while still conn in the heap */
while(conn
&& conn->cid != cid)
- conn = cp_cco_bw_prio_heap_get_next_conn(heap, conn);
+ conn = cp_cco_bw_prio_heap_get_next_conn(ctx->bw.prio_heap[nb_heap], conn);
if(!conn)
- heap = cp_cco_bw_prio_heap_get_next_heap(ctx, heap);
+ nb_heap++;
}
- while(heap && !conn);
if(conn)
{
- heap->nb_conn--;
- list_remove(&heap->conns,&conn->node);
+ ctx->bw.prio_heap[nb_heap].nb_conn--;
+ list_remove(&ctx->bw.prio_heap[nb_heap].conns,&conn->node);
blk_release(conn);
}
}
@@ -110,102 +102,76 @@ void
cp_cco_bw_prio_heap_clear_conn(cp_t *ctx)
{
cp_cco_bw_prio_conn_t *conn;
- cp_cco_bw_prio_heap_t *heap;
+ u16 nb_heap = 0;
dbg_assert(ctx);
- heap = cp_cco_bw_prio_heap_get_first_heap(ctx);
-
- while(heap)
+ while(nb_heap < CP_CCO_BW_NB_PRIORITY_HEAPS)
{
- conn = cp_cco_bw_prio_heap_get_first_conn(heap);
+ conn = cp_cco_bw_prio_heap_get_first_conn(ctx->bw.prio_heap[nb_heap]);
while(conn)
{
conn->alloc_status = false;
- conn = cp_cco_bw_prio_heap_get_next_conn(heap, conn);
+ conn = cp_cco_bw_prio_heap_get_next_conn(ctx->bw.prio_heap[nb_heap], conn);
}
- heap = cp_cco_bw_prio_heap_get_next_heap(ctx, heap);
+ nb_heap++;
}
}
cp_cco_bw_prio_conn_t*
cp_cco_bw_prio_heap_get_conn(cp_t *ctx, u16 cid)
{
- cp_cco_bw_prio_conn_t *conn;
- cp_cco_bw_prio_heap_t *heap;
+ cp_cco_bw_prio_conn_t *conn = NULL;
+ u16 nb_heap = 0;
dbg_assert(ctx);
- heap = cp_cco_bw_prio_heap_get_first_heap(ctx);
-
- do
+ while(nb_heap < CP_CCO_BW_NB_PRIORITY_HEAPS
+ && !conn)
{
- conn = cp_cco_bw_prio_heap_get_first_conn(heap);
+ conn = cp_cco_bw_prio_heap_get_first_conn(ctx->bw.prio_heap[nb_heap]);
while(conn
&& conn->cid != cid)
- conn = cp_cco_bw_prio_heap_get_next_conn(heap, conn);
+ conn = cp_cco_bw_prio_heap_get_next_conn(ctx->bw.prio_heap[nb_heap], conn);
- heap = cp_cco_bw_prio_heap_get_next_heap(ctx, heap);
+ nb_heap++;
}
- while(heap
- && !conn);
return conn;
}
void
-cp_cco_bw_prio_heap_init(list_t *heap_list)
+cp_cco_bw_prio_heap_init(cp_t *ctx)
{
int i;
- cp_cco_bw_prio_heap_t* heap[4];
-
- for(i=3;i>=0;i--)
+ for(i = 0; i < CP_CCO_BW_NB_PRIORITY_HEAPS ; i++)
{
- heap[i] = blk_alloc();
- heap[i]->table_priority_level = i;
- heap[i]->nb_conn_allocated = 0;
- heap[i]->nb_conn = 0;
- list_init(&heap[i]->conns);
- list_init_node(&heap[i]->node);
- list_push(heap_list,&heap[i]->node);
+ ctx->bw.prio_heap[i].table_priority_level = i;
+ ctx->bw.prio_heap[i].nb_conn_allocated = 0;
+ ctx->bw.prio_heap[i].nb_conn = 0;
+ list_init(&ctx->bw.prio_heap[i].conns);
}
}
void
-cp_cco_bw_prio_heap_uninit(list_t *heap_list)
+cp_cco_bw_prio_heap_uninit(list_t *list)
{
cp_cco_bw_prio_conn_t *rel_conn;
- while(!list_empty(heap_list))
+ while(!list_empty(list))
{
rel_conn = PARENT_OF(cp_cco_bw_prio_conn_t,
node,
- list_begin(heap_list));
- list_remove(heap_list, list_begin(heap_list));
+ list_begin(list));
+
+ list_remove(list, list_begin(list));
blk_release(rel_conn);
}
}
-cp_cco_bw_prio_heap_t *
-cp_cco_bw_prio_heap_get_heap(cp_t *ctx, u8 prio)
-{
- u8 i;
- cp_cco_bw_prio_heap_t *heap = NULL;
-
- dbg_assert(ctx);
-
- heap = cp_cco_bw_prio_heap_get_first_heap(ctx);
-
- /* find the heap with the matching priority */
- for(i=0;i<3-prio;i++)
- heap = cp_cco_bw_prio_heap_get_next_heap(ctx, heap);
-
- return heap;
-}
-
cp_cco_bw_prio_conn_t*
cp_cco_bw_prio_heap_init_prio_conn()
{
@@ -218,60 +184,27 @@ cp_cco_bw_prio_heap_init_prio_conn()
return conn;
}
-
cp_cco_bw_prio_conn_t*
-cp_cco_bw_prio_heap_get_first_conn(cp_cco_bw_prio_heap_t *heap)
+cp_cco_bw_prio_heap_get_first_conn(cp_cco_bw_prio_heap_t heap)
{
cp_cco_bw_prio_conn_t *conn;
- dbg_assert(heap);
-
- if(!list_empty(&heap->conns))
- conn = PARENT_OF(cp_cco_bw_prio_conn_t, node, list_begin(&heap->conns));
+ if(heap.nb_conn)
+ conn = PARENT_OF(cp_cco_bw_prio_conn_t, node, list_begin(&heap.conns));
else
conn = NULL;
return conn;
}
cp_cco_bw_prio_conn_t*
-cp_cco_bw_prio_heap_get_next_conn(cp_cco_bw_prio_heap_t *heap, cp_cco_bw_prio_conn_t *conn)
+cp_cco_bw_prio_heap_get_next_conn(cp_cco_bw_prio_heap_t heap, cp_cco_bw_prio_conn_t *conn)
{
cp_cco_bw_prio_conn_t *next_conn;
- if(&conn->node != list_rbegin(&heap->conns))
+ if(&conn->node != list_rbegin(&heap.conns))
next_conn = PARENT_OF(cp_cco_bw_prio_conn_t, node, list_next(&conn->node));
else
next_conn = NULL;
return next_conn;
}
-
-cp_cco_bw_prio_heap_t*
-cp_cco_bw_prio_heap_get_first_heap(cp_t *ctx)
-{
- cp_cco_bw_prio_heap_t* heap;
-
- if(!list_empty(&ctx->bw.prio_heap))
- heap = PARENT_OF(cp_cco_bw_prio_heap_t,
- node,
- list_begin(&ctx->bw.prio_heap));
- else
- heap = NULL;
-
- return heap;
-}
-
-cp_cco_bw_prio_heap_t*
-cp_cco_bw_prio_heap_get_next_heap(cp_t *ctx, cp_cco_bw_prio_heap_t *heap)
-{
- cp_cco_bw_prio_heap_t *next_heap;
-
- if(&heap->node != list_rbegin(&ctx->bw.prio_heap))
- next_heap = PARENT_OF(cp_cco_bw_prio_heap_t,
- node,
- list_next(&heap->node));
- else
- next_heap = NULL;
-
- return next_heap;
-}
diff --git a/cesar/cp2/cco/bw/test/src/bw_prio_heap_test.c b/cesar/cp2/cco/bw/test/src/bw_prio_heap_test.c
index 70769ab3c3..76089bcc56 100644
--- a/cesar/cp2/cco/bw/test/src/bw_prio_heap_test.c
+++ b/cesar/cp2/cco/bw/test/src/bw_prio_heap_test.c
@@ -43,34 +43,19 @@ void
test_case_bw_prio_heap_init (test_t test, cp_t *cp)
{
- cp_cco_bw_prio_heap_t *heap[4];
-
test_case_begin (test, "Init prio heaps");
cp_pwl_init(cp);
cp_cco_bw_init(cp);
- heap[3] = PARENT_OF(cp_cco_bw_prio_heap_t,
- node,
- list_begin(&cp->bw.prio_heap));
- heap[2] = PARENT_OF(cp_cco_bw_prio_heap_t,
- node,
- list_next(&heap[3]->node));
- heap[1] = PARENT_OF(cp_cco_bw_prio_heap_t,
- node,
- list_next(&heap[2]->node));
- heap[0] = PARENT_OF(cp_cco_bw_prio_heap_t,
- node,
- list_next(&heap[1]->node));
-
test_begin(test,"Init prio heaps"){
- test_fail_if(heap[3]->nb_conn_allocated != 0,
+ test_fail_if(cp->bw.prio_heap[3].nb_conn_allocated != 0,
"There shouldn't be any connection allocated") ;
- test_fail_if(heap[3]->nb_conn != 0,
+ test_fail_if(cp->bw.prio_heap[3].nb_conn != 0,
"There shouldn't be any connection");
- test_fail_if(heap[3]->table_priority_level != 3,
+ test_fail_if(cp->bw.prio_heap[3].table_priority_level != 3,
"The priority is false");
- test_fail_if(heap[1]->table_priority_level != 1,
+ test_fail_if(cp->bw.prio_heap[1].table_priority_level != 1,
"The heaps aren't well linked");
}
test_end;
@@ -81,7 +66,6 @@ test_case_bw_prio_heap_init (test_t test, cp_t *cp)
*
*
*/
-
void
test_case_bw_prio_heap_uninit (test_t test, cp_t *cp)
{
@@ -91,8 +75,6 @@ test_case_bw_prio_heap_uninit (test_t test, cp_t *cp)
cp_cco_bw_uninit(cp);
test_begin(test,"Init prio heaps"){
- test_fail_if(!list_empty(&cp->bw.prio_heap),
- "The list should be empty ");
test_fail_if(!blk_check_memory(),
"Memory allocation pb");
}
@@ -103,26 +85,11 @@ void
test_case_bw_prio_heap_add_conns (test_t test, cp_t *cp)
{
- cp_cco_bw_prio_heap_t *heap[4];
u8 cid[3][4];
u8 prio[4];
int i;
int j;
-
- heap[3] = PARENT_OF(cp_cco_bw_prio_heap_t,
- node,
- list_begin(&cp->bw.prio_heap));
- heap[2] = PARENT_OF(cp_cco_bw_prio_heap_t,
- node,
- list_next(&heap[3]->node));
- heap[1] = PARENT_OF(cp_cco_bw_prio_heap_t,
- node,
- list_next(&heap[2]->node));
- heap[0] = PARENT_OF(cp_cco_bw_prio_heap_t,
- node,
- list_next(&heap[1]->node));
-
test_case_begin (test, "Add connections into prio heaps");
for(i=0;i<4;i++){
@@ -135,13 +102,21 @@ test_case_bw_prio_heap_add_conns (test_t test, cp_t *cp)
cp_cco_bw_prio_heap_add_conn(cp,cid[j][i],prio[i]);
test_begin(test,"add connection into prio heaps"){
- test_fail_if(PARENT_OF(cp_cco_bw_prio_conn_t,node,list_begin(&heap[3]->conns))->cid != 30,
+ test_fail_if(PARENT_OF(cp_cco_bw_prio_conn_t,
+ node,
+ list_begin(&cp->bw.prio_heap[3].conns))->cid != 30,
"failure add : cid prio 3 conn 0");
- test_fail_if(PARENT_OF(cp_cco_bw_prio_conn_t,node,list_next(list_begin(&heap[2]->conns)))->cid != 21,
+ test_fail_if(PARENT_OF(cp_cco_bw_prio_conn_t,
+ node,
+ list_next(list_begin(&cp->bw.prio_heap[2].conns)))->cid != 21,
"failure add :cid prio 2 conn 1");
- test_fail_if(PARENT_OF(cp_cco_bw_prio_conn_t,node,list_next(list_next(list_begin(&heap[1]->conns))))->cid != 12,
+ test_fail_if(PARENT_OF(cp_cco_bw_prio_conn_t,
+ node,
+ list_next(list_next(list_begin(&cp->bw.prio_heap[1].conns))))->cid != 12,
"failure add :cid prio 1 conn 2");
- test_fail_if(PARENT_OF(cp_cco_bw_prio_conn_t,node,list_next(list_next(list_begin(&heap[0]->conns))))->cid != 2,
+ test_fail_if(PARENT_OF(cp_cco_bw_prio_conn_t,
+ node,
+ list_next(list_next(list_begin(&cp->bw.prio_heap[0].conns))))->cid != 2,
"failure add :cid prio 0 conn 2");
}
test_end;
@@ -153,24 +128,8 @@ test_case_bw_prio_heap_del_conns (test_t test)
cp_t cp;
- cp_cco_bw_prio_heap_t *heap[4];
-
test_case_bw_prio_heap_init(test, &cp);
- heap[3] = PARENT_OF(cp_cco_bw_prio_heap_t,
- node,
- list_begin(&cp.bw.prio_heap));
- heap[2] = PARENT_OF(cp_cco_bw_prio_heap_t,
- node,
- list_next(&heap[3]->node));
- heap[1] = PARENT_OF(cp_cco_bw_prio_heap_t,
- node,
- list_next(&heap[2]->node));
- heap[0] = PARENT_OF(cp_cco_bw_prio_heap_t,
- node,
- list_next(&heap[1]->node));
-
-
test_case_bw_prio_heap_add_conns (test, &cp);
test_case_begin (test, "\nDel connections into prio heaps\n\n");
@@ -199,19 +158,19 @@ test_case_bw_prio_heap_del_conns (test_t test)
test_begin(test,"Del connection into prio heaps"){
test_fail_if(PARENT_OF(cp_cco_bw_prio_conn_t,
node,
- list_begin(&heap[3]->conns))->cid != 35,
+ list_begin(&cp.bw.prio_heap[3].conns))->cid != 35,
"failure remove all conn + add 1st");
test_fail_if(PARENT_OF(cp_cco_bw_prio_conn_t,
node,
- list_begin(&heap[2]->conns))->cid !=25,
+ list_begin(&cp.bw.prio_heap[2].conns))->cid !=25,
"failure add 1 remove all");
test_fail_if(PARENT_OF(cp_cco_bw_prio_conn_t,
node,
- list_next(list_next(list_begin(&heap[1]->conns))))->cid != 12,
+ list_next(list_next(list_begin(&cp.bw.prio_heap[1].conns))))->cid != 12,
"failure remove last add last");
test_fail_if(PARENT_OF(cp_cco_bw_prio_conn_t,
node,
- list_next(list_next(list_begin(&heap[0]->conns))))->cid != 0,
+ list_next(list_next(list_begin(&cp.bw.prio_heap[0].conns))))->cid != 0,
"failure remove first add last");
}
test_end;
@@ -224,25 +183,10 @@ test_case_bw_prio_get_most_prior_conn (test_t test)
{
cp_t cp;
- cp_cco_bw_prio_heap_t *heap[4];
-
cp_cco_bw_prio_conn_t* most_prior_conn[5];
test_case_bw_prio_heap_init(test, &cp);
- heap[3] = PARENT_OF(cp_cco_bw_prio_heap_t,
- node,
- list_begin(&cp.bw.prio_heap));
- heap[2] = PARENT_OF(cp_cco_bw_prio_heap_t,
- node,
- list_next(&heap[3]->node));
- heap[1] = PARENT_OF(cp_cco_bw_prio_heap_t,
- node,
- list_next(&heap[2]->node));
- heap[0] = PARENT_OF(cp_cco_bw_prio_heap_t,
- node,
- list_next(&heap[1]->node));
-
test_case_begin(test, "\nGet most prior conn");
most_prior_conn[0] = cp_cco_bw_prio_heap_get_most_prior_conn(&cp);
@@ -336,6 +280,7 @@ test_case_bw_prio_get_conn(test_t test)
{
cp_t cp;
cp_cco_bw_prio_conn_t *conn;
+
test_case_bw_prio_heap_init(test, &cp);
cp_cco_bw_prio_heap_add_conn(&cp,10,0);