summaryrefslogtreecommitdiff
path: root/cesar/cp2/cco
diff options
context:
space:
mode:
authorboure2008-05-23 15:30:32 +0000
committerboure2008-05-23 15:30:32 +0000
commit411094256c05955c02527e5f9761711b9f91466d (patch)
treeadf1f4ce4b5f1254d590e4c1c2666f20ea6cefa8 /cesar/cp2/cco
parent160aafad44e8d80028ea203ae0dfa2476493b098 (diff)
function cp_cco_bw_prio_add_conn done tested
git-svn-id: svn+ssh://pessac/svn/cesar/trunk@2088 017c9cb6-072f-447c-8318-d5b54f68fe89
Diffstat (limited to 'cesar/cp2/cco')
-rw-r--r--cesar/cp2/cco/bw/bw_prio_heap.h2
-rw-r--r--cesar/cp2/cco/bw/src/bw_prio_heap.c40
2 files changed, 21 insertions, 21 deletions
diff --git a/cesar/cp2/cco/bw/bw_prio_heap.h b/cesar/cp2/cco/bw/bw_prio_heap.h
index 6bcaea21ed..d61d16fda4 100644
--- a/cesar/cp2/cco/bw/bw_prio_heap.h
+++ b/cesar/cp2/cco/bw/bw_prio_heap.h
@@ -61,7 +61,7 @@ struct cp_cco_bw_prio_heap_t
/**
* first connection of the heap
*/
- list_t *conns;
+ list_t conns;
/**
* Node of the list of heaps
diff --git a/cesar/cp2/cco/bw/src/bw_prio_heap.c b/cesar/cp2/cco/bw/src/bw_prio_heap.c
index a1145692f5..d47bdc5617 100644
--- a/cesar/cp2/cco/bw/src/bw_prio_heap.c
+++ b/cesar/cp2/cco/bw/src/bw_prio_heap.c
@@ -21,6 +21,8 @@
#include "cp2/cco/bw/bw.h"
#include "lib/list.h"
+#include "cp2/inc/context.h"
+#include "cp2/cp.h"
/*
* gets the most prior pending connection return its CID.
* \param ctx the module context.
@@ -71,30 +73,35 @@ cp_cco_bw_prio_heap_get_most_prior_conn (cp_t *ctx){
* add a connection.
* \param ctx the module context.
* \param cid Connection identifier
+ * \param prio priority of the heap
*
*/
void
cp_cco_bw_prio_heap_add_conn (cp_t *ctx, u8 cid, u8 prio){
u16 i; // iterator
- cp_cco_bw_prio_conn_t* new_conn = NULL; // new conn
+ cp_cco_bw_prio_heap_t *heap = NULL;
+ cp_cco_bw_prio_conn_t *new_conn = NULL; // new conn
list_node_t *heap_node;
- list_init_node (heap_node);
+ heap_node = list_begin(&ctx->bw.prio_heap);
- //heap_node = list_begin(ctx->bw.prio_heap);
- //find the heap tha correspond to the prio
+ //find the heap with the matching priority
for(i=0;i<3-prio;i++)
heap_node = list_next(heap_node);
+ // get the heap with the matching priority
+ heap = PARENT_OF(cp_cco_bw_prio_heap_t,node,heap_node);
+
/*Init the new conn*/
new_conn = blk_alloc();
new_conn->cid = cid;
+ list_init_node(&new_conn->node);
- /*find the last conn of the heap*/
-
+ // add the new conn into the list
+ list_push(&heap->conns,&new_conn->node);
// add 1 to the number of conn
- //heap->nb_conn++;
+ heap->nb_conn++;
}
/**
@@ -177,27 +184,20 @@ cp_cco_bw_prio_heap_init(list_t *heap_list)
int i;
cp_cco_bw_prio_heap_t* heap[4];
-
+
for(i=0;i<4;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_insert(heap_list,
- list_begin(heap_list),
- &heap[0]->node);
- list_insert(heap_list,
- &heap[0]->node,
- &heap[1]->node);
- list_insert(heap_list,
- &heap[1]->node,
- &heap[2]->node);
- list_insert(heap_list,
- &heap[2]->node,
- &heap[3]->node);
+ list_push(heap_list,&heap[3]->node);
+ list_push(heap_list,&heap[2]->node);
+ list_push(heap_list,&heap[1]->node);
+ list_push(heap_list,&heap[0]->node);
}