From 90580eb9912d3fe4cdfd1a50a2c0e04f24afb58e Mon Sep 17 00:00:00 2001 From: boure Date: Wed, 2 Jul 2008 15:50:28 +0000 Subject: Implementation & test allocation of forward and reverse links of a same connection git-svn-id: svn+ssh://pessac/svn/cesar/trunk@2533 017c9cb6-072f-447c-8318-d5b54f68fe89 --- cesar/cp2/cco/bw/bw.h | 2 +- cesar/cp2/cco/bw/src/bw.c | 44 +++++++-- cesar/cp2/cco/bw/test/src/bw_test.c | 183 +++++++++++++++++++++++++++++++++++- 3 files changed, 218 insertions(+), 11 deletions(-) (limited to 'cesar') diff --git a/cesar/cp2/cco/bw/bw.h b/cesar/cp2/cco/bw/bw.h index cd0e240cda..0d9ca02877 100644 --- a/cesar/cp2/cco/bw/bw.h +++ b/cesar/cp2/cco/bw/bw.h @@ -134,7 +134,7 @@ cp_cco_bw_alloc_sched (cp_t *ctx); * */ bool -cp_cco_bw_alloc (cp_t *ctx, cp_conn_t *conn); +cp_cco_bw_alloc (cp_t *ctx, cp_link_t *link, u16 cid); /** * This function will initialise a new schedule. diff --git a/cesar/cp2/cco/bw/src/bw.c b/cesar/cp2/cco/bw/src/bw.c index c606706378..70db7b9086 100644 --- a/cesar/cp2/cco/bw/src/bw.c +++ b/cesar/cp2/cco/bw/src/bw.c @@ -147,15 +147,17 @@ cp_cco_bw_alloc_sched (cp_t *ctx) txop_allocated = 0; - nb_txop = conn->conn_info.cspec.f_qmp->nb_txop; + nb_txop = conn->flink->qmp->nb_txop; + /* Allocation of the Forward link */ while(txop_allocated < nb_txop && no_more_alloc) { txop_allocated++; /*Allocate the connection if possible*/ - no_more_alloc = cp_cco_bw_alloc(ctx, conn); + no_more_alloc = cp_cco_bw_alloc(ctx, conn->flink, + conn->conn_info.cid); /*Change Status if the allocation has been done*/ if(no_more_alloc) @@ -166,12 +168,40 @@ cp_cco_bw_alloc_sched (cp_t *ctx) cp_cco_bw_alloc_remove_cid(ctx, conn->conn_info.cid); } + /* Allocation of the Reverse link */ + if(no_more_alloc) + { + txop_allocated = 0; + + nb_txop = conn->rlink->qmp->nb_txop; + + while(txop_allocated < nb_txop + && no_more_alloc) + { + txop_allocated++; + + /*Allocate the connection if possible*/ + no_more_alloc = cp_cco_bw_alloc(ctx, conn->rlink, + conn->conn_info.cid); + + /*Change Status if the allocation has been done*/ + if(no_more_alloc) + prior_conn->alloc_status = true; + + /*Else delete all the allocation done for this connection*/ + else + cp_cco_bw_alloc_remove_cid(ctx, conn->conn_info.cid); + + } + + } + } } } bool -cp_cco_bw_alloc (cp_t *ctx, cp_conn_t *conn) +cp_cco_bw_alloc (cp_t *ctx, cp_link_t *link, u16 cid) { /* Result returned true if alloc done */ bool result_alloc = false; @@ -215,7 +245,7 @@ cp_cco_bw_alloc (cp_t *ctx, cp_conn_t *conn) u16 beacon_period_atu; dbg_assert(ctx); - dbg_assert(conn); + dbg_assert(link); /*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]); @@ -223,9 +253,9 @@ cp_cco_bw_alloc (cp_t *ctx, cp_conn_t *conn) best_alloc_et = beacon_period_atu; /* get the connection to collect its infos */ - nb_pb = conn->conn_info.cspec.f_qmp->av_nb_pb; + nb_pb = link->qmp->av_nb_pb; actual_ble = PARENT_OF(cp_link_ble_interval_t, node, - list_begin(&conn->flink->list_ble)); + list_begin(&link->list_ble)); /**** Init allocation data ****/ @@ -298,7 +328,7 @@ cp_cco_bw_alloc (cp_t *ctx, cp_conn_t *conn) /*TODO GLID TODO*/ - new_alloc->cid = conn->conn_info.cid; + new_alloc->cid = cid; cp_cco_bw_alloc_add(ctx, new_alloc); } diff --git a/cesar/cp2/cco/bw/test/src/bw_test.c b/cesar/cp2/cco/bw/test/src/bw_test.c index 95616762aa..9327114561 100644 --- a/cesar/cp2/cco/bw/test/src/bw_test.c +++ b/cesar/cp2/cco/bw/test/src/bw_test.c @@ -204,10 +204,63 @@ if(val == 0){\ conn_prio[8]=2;\ conn_prio[9]=3;\ } +#define INIT_TEST_F_AND_R_ALLOC(val)\ +if(val == 0)\ +{\ + nb_ble = 10;\ + \ + ble_value[0] = 90;\ + ble_value[1] = 50;\ + ble_value[2] = 80;\ + ble_value[3] = 120;\ + ble_value[4] = 35;\ + ble_value[5] = 40;\ + ble_value[6] = 25;\ + ble_value[7] = 30;\ + ble_value[8] = 70;\ + ble_value[9] = 160;\ + \ + ble_end_time[0] = 935;\ + ble_end_time[1] = 1195;\ + ble_end_time[2] = 1390;\ + ble_end_time[3] = 1429;\ + ble_end_time[4] = 1785;\ + ble_end_time[5] = 2175;\ + ble_end_time[6] = 3007;\ + ble_end_time[7] = 3735;\ + ble_end_time[8] = 3839;\ + ble_end_time[9] = 3906;\ + \ + link_nb_pb[0][0]=20;\ + link_nb_pb[0][1]=30;\ + link_nb_pb[1][0]=10;\ + link_nb_pb[1][1]=15;\ + link_nb_pb[2][0]=25;\ + link_nb_pb[2][1]=5;\ + link_nb_pb[3][0]=10;\ + link_nb_pb[3][1]=15;\ + link_nb_pb[4][0]=20;\ + link_nb_pb[4][1]=30;\ + \ + link_prio[0][0]=3;\ + link_prio[0][1]=3;\ + link_prio[1][0]=3;\ + link_prio[1][1]=3;\ + link_prio[2][0]=2;\ + link_prio[2][1]=2;\ + link_prio[3][0]=1;\ + link_prio[3][1]=1;\ + link_prio[4][0]=0;\ + link_prio[4][1]=0;\ +\ +} + u16 ble_value[10]; u16 ble_end_time[10]; +u16 link_nb_pb[5][10]; +u16 link_prio[5][10]; u16 conn_nb_pb[10]; u16 conn_prio[10]; u16 nb_pb; @@ -379,8 +432,8 @@ test_case_complete_allocation (test_t test, u8 test_id) { conn[i] = cp_conn_init_conn(&cp); conn[i]->conn_info.cid = (i+1)*100; - conn[i]->conn_info.cspec.f_qmp->av_nb_pb = nb_pb; - conn[i]->conn_info.cspec.f_qmp->nb_txop = 1; + conn[i]->flink->qmp->av_nb_pb = nb_pb; + conn[i]->flink->qmp->nb_txop = 1; cp_conn_add_conn(&cp, conn[i]); /*Init the BLEs*/ @@ -399,7 +452,7 @@ test_case_complete_allocation (test_t test, u8 test_id) test_case_begin(test, "Try to allocate into the Beacon Period"); for(i=0;i<3;i++) - cp_cco_bw_alloc(&cp, cp_conn_get_conn(&cp,(i+1)*100)); + cp_cco_bw_alloc(&cp, cp_conn_get_conn(&cp,(i+1)*100)->flink, (i+1)*100); for(i=0;i<3;i++) alloc_test[i] = cp_cco_bw_alloc_get_first_txop(&cp, (i+1)*100); @@ -711,6 +764,126 @@ test_case_allocate_multiple_txop (test_t test) test_end; } +void +test_case_f_and_r_alloc (test_t test) +{ + cp_t cp; + cp_net_t *avln; + cp_sta_t *sta; + int nb_conn; + int j,i; + + cp_cco_bw_alloc_t *alloc_test[13]; + cp_conn_t *conn[10]; + + cp_pwl_init(&cp); + cp_sta_mgr_init(&cp); + avln = cp_sta_mgr_get_our_avln (&cp); + sta =cp_net_sta_add (&cp, avln, 1, 1); + cp_cco_bw_init(&cp); + cp_conn_mgr_init(&cp); + + /*Init the connections*/ + for(nb_conn = 0 ; nb_conn < 5 ; nb_conn++) + { + conn[nb_conn] = cp_conn_init_conn(&cp); + conn[nb_conn]->conn_info.cid = (nb_conn+1)*10; + + conn[nb_conn]->flink->cinfo->user_priority = link_prio[nb_conn][0]; + conn[nb_conn]->flink->qmp->nb_txop = 1; + conn[nb_conn]->flink->qmp->av_nb_pb = link_nb_pb[nb_conn][0]; + + conn[nb_conn]->rlink->cinfo->user_priority = link_prio[nb_conn][1]; + conn[nb_conn]->rlink->qmp->nb_txop = 1; + conn[nb_conn]->rlink->qmp->av_nb_pb = link_nb_pb[nb_conn][1]; + + cp_conn_add_conn(&cp, conn[nb_conn]); + + /*Init the BLEs*/ + for(j = 0 ; j < nb_ble ; j++) + { + cp_link_push_ble(conn[nb_conn]->flink, ble_value[j], ble_end_time[j]); + cp_link_push_ble(conn[nb_conn]->rlink, ble_value[j], ble_end_time[j]); + } + } + + test_case_begin(test, "Complete Schedule"); + + cp_cco_bw_alloc_sched(&cp); + + alloc_test[0] = cp_cco_bw_get_first_alloc_actual(&cp); + + for(i = 1 ; i < 14 ; i++) + alloc_test[i] = cp_cco_bw_get_next_alloc_actual(alloc_test[i-1]); + + test_begin(test, "Complete Schedule") + { + test_fail_if(alloc_test[4]->st_atu != 819, + "wrong allocation st0"); + test_fail_if(alloc_test[4]->et_atu != 877, + "wrong allocation et0"); + test_fail_if(alloc_test[4]->cid != 20, + "wrong allocation cid"); + test_fail_if(alloc_test[5]->st_atu != 877, + "wrong allocation st"); + test_fail_if(alloc_test[5]->et_atu != 987, + "wrong allocation et"); + test_fail_if(alloc_test[5]->cid != 20, + "wrong allocation cid"); + test_fail_if(alloc_test[6]->st_atu != 1018, + "wrong allocation st"); + test_fail_if(alloc_test[6]->et_atu != 1253, + "wrong allocation et"); + test_fail_if(alloc_test[6]->cid != 30, + "wrong allocation cid"); + test_fail_if(alloc_test[7]->st_atu != 1253, + "wrong allocation st"); + test_fail_if(alloc_test[7]->et_atu != 1429, + "wrong allocation et"); + test_fail_if(alloc_test[7]->cid != 10, + "wrong allocation cid"); + test_fail_if(alloc_test[8]->st_atu != 1429, + "wrong allocation st"); + test_fail_if(alloc_test[8]->et_atu != 1727, + "wrong allocation et"); + test_fail_if(alloc_test[8]->cid != 50, + "wrong allocation cid"); + test_fail_if(alloc_test[9]->st_atu != 1785, + "wrong allocation st"); + test_fail_if(alloc_test[9]->et_atu != 1915, + "wrong allocation et"); + test_fail_if(alloc_test[9]->cid != 40, + "wrong allocation cid"); + test_fail_if(alloc_test[10]->st_atu != 1915, + "wrong allocation st"); + test_fail_if(alloc_test[10]->et_atu != 2110, + "wrong allocation et"); + test_fail_if(alloc_test[10]->cid != 40, + "wrong allocation cid"); + test_fail_if(alloc_test[11]->st_atu != 3007, + "wrong allocation st"); + test_fail_if(alloc_test[11]->et_atu != 3527, + "wrong allocation et"); + test_fail_if(alloc_test[11]->cid != 50, + "wrong allocation cid"); + test_fail_if(alloc_test[12]->st_atu != 3735, + "wrong allocation st"); + test_fail_if(alloc_test[12]->et_atu != 3773, + "wrong allocation et"); + test_fail_if(alloc_test[12]->cid != 30, + "wrong allocation cid"); + test_fail_if(alloc_test[13]->st_atu != 3816, + "wrong allocation st"); + test_fail_if(alloc_test[13]->et_atu != 3896, + "wrong allocation et"); + test_fail_if(alloc_test[13]->cid != 10, + "wrong allocation cid"); + } + test_end; + blk_release(sta); + cp_conn_mgr_uninit(&cp); +} + int main (void){ @@ -733,6 +906,10 @@ main (void){ test_case_complete_schedule (test); + INIT_TEST_F_AND_R_ALLOC(0); + + test_case_f_and_r_alloc (test); + for(i=0;i