aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorNeels Hofmeyr <neels@hofmeyr.de>2020-11-18 14:34:48 +0100
committerNeels Hofmeyr <neels@hofmeyr.de>2020-11-18 14:50:11 +0100
commit829db22eeb273fe1fedfcd5e1d5e56c6824d53e9 (patch)
treedbe71a66b5b4390f36ad4ddf636313bf1ba81292 /src
parentdad4e7c3f7923be519af7d842f6dba9d94142da2 (diff)
hodec 2: prep: common pick_better_lchan_to_move() function
There are four places deciding which of 2 lchans to move, depending on average db ratings. Upcoming patches will enrich that decision for better handling of dynamic timeslots, so have one common function for these to avoid code dup. Change-Id: I745dc95cf564dd330295cecb4d64dccebf55163f
Diffstat (limited to 'src')
-rw-r--r--src/osmo-bsc/handover_decision_2.c43
1 files changed, 27 insertions, 16 deletions
diff --git a/src/osmo-bsc/handover_decision_2.c b/src/osmo-bsc/handover_decision_2.c
index c818dbbde..7df8bb1fb 100644
--- a/src/osmo-bsc/handover_decision_2.c
+++ b/src/osmo-bsc/handover_decision_2.c
@@ -1362,6 +1362,29 @@ static void on_measurement_report(struct gsm_meas_rep *mr)
}
}
+/* Given two candidates, pick the one that should rather be moved during handover.
+ * Return the better candidate in out-parameters best_cand and best_avg_db.
+ */
+static void pick_better_lchan_to_move(bool want_highest_db,
+ struct ho_candidate **best_cand_p, unsigned int *best_avg_db_p,
+ struct ho_candidate *other_cand, unsigned int other_avg_db)
+{
+ if (!*best_cand_p)
+ goto return_other;
+
+ if (want_highest_db && (*best_avg_db_p < other_avg_db))
+ goto return_other;
+ if (!want_highest_db && (*best_avg_db_p > other_avg_db))
+ goto return_other;
+
+ /* keep the same candidate. */
+ return;
+
+return_other:
+ *best_cand_p = other_cand;
+ *best_avg_db_p = other_avg_db;
+}
+
/*
* Handover/assignment check after timer timeout:
*
@@ -1563,10 +1586,7 @@ next_b1:
is_improved = 0;
LOGPHOCAND(&clist[i], LOGL_DEBUG, "candidate %d: avg=%d best_avg_db=%d\n",
i, avg, best_avg_db);
- if (avg > best_avg_db) {
- best_cand = &clist[i];
- best_avg_db = avg;
- }
+ pick_better_lchan_to_move(true, &best_cand, &best_avg_db, &clist[i], avg);
}
/* perform handover, if there is a candidate */
@@ -1636,10 +1656,7 @@ next_b2:
is_improved = 1;
} else
is_improved = 0;
- if (avg < worst_avg_db) {
- worst_cand = &clist[i];
- worst_avg_db = avg;
- }
+ pick_better_lchan_to_move(false, &worst_cand, &worst_avg_db, &clist[i], avg);
}
}
@@ -1712,10 +1729,7 @@ next_c1:
is_improved = 1;
} else
is_improved = 0;
- if (avg > best_avg_db) {
- best_cand = &clist[i];
- best_avg_db = avg;
- }
+ pick_better_lchan_to_move(true, &best_cand, &best_avg_db, &clist[i], avg);
}
/* perform handover, if there is a candidate */
@@ -1790,10 +1804,7 @@ next_c2:
is_improved = 0;
LOGP(DHODEC, LOGL_DEBUG, "candidate %d: avg=%d worst_avg_db=%d\n", i, avg,
worst_avg_db);
- if (avg < worst_avg_db) {
- worst_cand = &clist[i];
- worst_avg_db = avg;
- }
+ pick_better_lchan_to_move(false, &worst_cand, &worst_avg_db, &clist[i], avg);
}
}