From 172bf9e7305596b0c55b662fd1bd16fd6c644ceb Mon Sep 17 00:00:00 2001 From: Andreas Eversberg Date: Thu, 30 May 2013 11:14:31 +0200 Subject: HO: Add function to count currently ongoing handovers to a given BTS In order to keep processing power at BTS at a defined level, the handover decision might want to limit maximum number of slots that require RACH detection. --- include/osmocom/bsc/handover.h | 3 +++ src/libbsc/handover_logic.c | 26 +++++++++++++++++++++++--- 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/include/osmocom/bsc/handover.h b/include/osmocom/bsc/handover.h index bd0d8ad6c..5ba8e1641 100644 --- a/include/osmocom/bsc/handover.h +++ b/include/osmocom/bsc/handover.h @@ -3,6 +3,9 @@ struct gsm_subscriber_connection; +/* Count number of currently ongoing async handovers */ +int bsc_ho_count(struct gsm_bts *bts); + /* Hand over the specified logical channel to the specified new BTS. * This is the main entry point for the actual handover algorithm, * after it has decided it wants to initiate HO to a specific BTS */ diff --git a/src/libbsc/handover_logic.c b/src/libbsc/handover_logic.c index 9cf26af9d..c040c13aa 100644 --- a/src/libbsc/handover_logic.c +++ b/src/libbsc/handover_logic.c @@ -49,6 +49,7 @@ struct bsc_handover { struct osmo_timer_list T3103; uint8_t ho_ref; + int ho_async; }; static LLIST_HEAD(bsc_handovers); @@ -77,6 +78,22 @@ static struct bsc_handover *bsc_ho_by_old_lchan(struct gsm_lchan *old_lchan) return NULL; } +/* Count number of currently ongoing async handovers */ +int bsc_ho_count(struct gsm_bts *bts) +{ + struct bsc_handover *ho; + int count = 0; + + llist_for_each_entry(ho, &bsc_handovers, list) { + if (!ho->ho_async) + continue; + if (ho->new_lchan->bts == bts) + count++; + } + + return count; +} + /* Hand over the specified logical channel to the specified new BTS. * This is the main entry point for the actual handover algorithm, * after it has decided it wants to initiate HO to a specific BTS */ @@ -117,7 +134,10 @@ int bsc_handover_start(struct gsm_lchan *old_lchan, struct gsm_bts *bts) } ho->old_lchan = old_lchan; ho->new_lchan = new_lchan; - ho->ho_ref = ho_ref++; + if (old_lchan->bts != bts) { + ho->ho_ref = ho_ref++; + ho->ho_async = 1; + } /* copy some parameters from old lchan */ memcpy(&new_lchan->encr, &old_lchan->encr, sizeof(new_lchan->encr)); @@ -130,8 +150,8 @@ int bsc_handover_start(struct gsm_lchan *old_lchan, struct gsm_bts *bts) new_lchan->conn->ho_lchan = new_lchan; /* FIXME: do we have a better idea of the timing advance? */ - rc = rsl_chan_activate_lchan(new_lchan, RSL_ACT_INTER_ASYNC, 0, - ho->ho_ref); + rc = rsl_chan_activate_lchan(new_lchan, + (ho->ho_async) ? RSL_ACT_INTER_ASYNC : 0x00, 0, ho->ho_ref); if (rc < 0) { LOGP(DHO, LOGL_ERROR, "could not activate channel\n"); new_lchan->conn->ho_lchan = NULL; -- cgit v1.2.3