From e94b7ea52646ce3901ba31786225f31e7336fa99 Mon Sep 17 00:00:00 2001 From: mercadie Date: Wed, 2 Jun 2010 15:46:27 +0000 Subject: cesar/cp/sta/action/misc: make cp_sta_action_get_average_ble public with options git-svn-id: svn+ssh://pessac/svn/cesar/trunk@7150 017c9cb6-072f-447c-8318-d5b54f68fe89 --- cesar/cp/sta/action/misc.h | 14 +++++++++ cesar/cp/sta/action/src/misc.c | 71 ++++++++++++++++++++++++++++-------------- 2 files changed, 61 insertions(+), 24 deletions(-) (limited to 'cesar') diff --git a/cesar/cp/sta/action/misc.h b/cesar/cp/sta/action/misc.h index 0e03bc32b9..f994ff0cdc 100644 --- a/cesar/cp/sta/action/misc.h +++ b/cesar/cp/sta/action/misc.h @@ -19,6 +19,7 @@ * simple enough to be handled without any remembered state. */ + BEGIN_DECLS /** @@ -86,6 +87,19 @@ cp_sta_action_process_cm_link_stats_req (cp_t *ctx, cp_mme_rx_t *rx_mme); void cp_sta_action_process_cm_sta_cap_req (cp_t *ctx, cp_mme_rx_t *rx_mme); +/** + * Get the average ble value for one station. + * \param ctx control plane context + * \param tei the tei of the distant station + * \param tx if true ble is computed on tx tonemaps, if false on rx tonemaps + * \param fc_format if true the average ble is provided in FC format if + * false it's provided as an integer + * \return the average ble for this station + */ +u8 +cp_sta_action_get_average_ble (cp_t *ctx, cp_tei_t tei, bool tx, + bool fc_format); + void cp_sta_action_process_cc_discover_list_req (cp_t *ctx, cp_mme_rx_t *rx_mme); diff --git a/cesar/cp/sta/action/src/misc.c b/cesar/cp/sta/action/src/misc.c index cd6159e129..f3e43d1198 100644 --- a/cesar/cp/sta/action/src/misc.c +++ b/cesar/cp/sta/action/src/misc.c @@ -511,19 +511,30 @@ cp_sta_action_process_cm_sta_cap_req (cp_t *ctx, cp_mme_rx_t *rx_mme) * \param ctx control plane context * \param sta distant station * \param tmi tonemap index + * \param tx if true tonemap TX are used, if false tonemap RX are used * \return the ble for this station in this tonemap */ static u8 -cp_sta_action_get_ble (cp_t *ctx, sta_t *sta, int tmi) +cp_sta_action_get_ble (cp_t *ctx, sta_t *sta, int tmi, bool tx) { dbg_assert (ctx); if (TONEMAP_INDEX_IS_NEGOTIATED(tmi)) { dbg_assert (sta); - dbg_assert (sta->tx_tonemaps); - dbg_assert (sta->tx_tonemaps->tm[tmi]); - return sta->tx_tonemaps->tm[tmi]->ble; + + if (tx) + { + dbg_assert (sta->tx_tonemaps); + dbg_assert (sta->tx_tonemaps->tm[tmi]); + return sta->tx_tonemaps->tm[tmi]->ble; + } + else + { + dbg_assert (sta->rx_tonemaps); + dbg_assert (sta->rx_tonemaps->tm[tmi]); + return sta->rx_tonemaps->tm[tmi]->ble; + } } else { @@ -533,53 +544,64 @@ cp_sta_action_get_ble (cp_t *ctx, sta_t *sta, int tmi) } } -/** - * Get the average ble value for one station. - * \param ctx control plane context - * \param tei the tei of the distant station - * \return the average ble for this station - */ -static u8 -cp_sta_action_get_average_ble (cp_t *ctx, cp_tei_t tei) +u8 +cp_sta_action_get_average_ble (cp_t *ctx, cp_tei_t tei, bool tx, + bool fc_format) { sta_t *sta = mac_store_sta_get (ctx->mac_store, tei); u8 average_ble; + uint average_ble_uint; if (sta) { - u8 int_nb = sta->tx_tonemaps->intervals->intervals_nb; + tonemaps_t *tm; - if (int_nb) + if (tx) + { + tm = sta->tx_tonemaps; + } + else + { + tm = sta->rx_tonemaps; + } + + if (tm->intervals->intervals_nb) { int i; uint ble_sum = 0; u16 offset_atu; u16 last_offset_atu = 0; - for (i = 0; i < int_nb; i++) + for (i = 0; i < tm->intervals->intervals_nb; i++) { - int tmi = sta->tx_tonemaps->intervals->interval[i].tmi; - offset_atu = - sta->tx_tonemaps->intervals->interval[i].end_offset_atu; + int tmi = tm->intervals->interval[i].tmi; + offset_atu = tm->intervals->interval[i].end_offset_atu; ble_sum += tonemap_ble_mant_2_uf5 (cp_sta_action_get_ble (ctx, sta, - tmi)) + tmi, tx)) * (offset_atu - last_offset_atu); last_offset_atu = offset_atu; } dbg_assert (last_offset_atu); + average_ble_uint = ble_sum / last_offset_atu; - average_ble = - tonemap_ble_uf5_2_mant (ble_sum / last_offset_atu); + if (!fc_format) + average_ble = MIN ((uint)0xFF, (average_ble_uint >> 5)); + else + average_ble = tonemap_ble_uf5_2_mant (average_ble_uint); } else { average_ble = - cp_sta_action_get_ble (ctx, sta, - sta->tx_tonemaps->default_tmi); + cp_sta_action_get_ble (ctx, sta, tm->default_tmi, tx); + + if (!fc_format) + average_ble = + MIN ((uint)0xFF, + (tonemap_ble_mant_2_uf5 (average_ble) >> 5)); } blk_release (sta); @@ -660,7 +682,8 @@ cp_sta_action_process_cc_discover_list_req (cp_t *ctx, cp_mme_rx_t *rx_mme) /** Compute average ble of the sta. */ list.average_ble = - cp_sta_action_get_average_ble (ctx, list.tei); + cp_sta_action_get_average_ble (ctx, list.tei, true, + true); cp_msg_cc_discover_list_cnf_send_station (ctx, tx_mme, &list); -- cgit v1.2.3