Change in osmo-bsc[master]: hodec 2: prep: common pick_better_lchan_to_move() function

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

laforge gerrit-no-reply at lists.osmocom.org
Fri Nov 20 08:56:32 UTC 2020


laforge has submitted this change. ( https://gerrit.osmocom.org/c/osmo-bsc/+/21234 )

Change subject: hodec 2: prep: common pick_better_lchan_to_move() function
......................................................................

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
---
M src/osmo-bsc/handover_decision_2.c
1 file changed, 27 insertions(+), 16 deletions(-)

Approvals:
  pespin: Looks good to me, but someone else must approve
  laforge: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/src/osmo-bsc/handover_decision_2.c b/src/osmo-bsc/handover_decision_2.c
index c818dbb..7df8bb1 100644
--- a/src/osmo-bsc/handover_decision_2.c
+++ b/src/osmo-bsc/handover_decision_2.c
@@ -1362,6 +1362,29 @@
 	}
 }
 
+/* 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 @@
 			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 @@
 				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 @@
 			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 @@
 				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);
 		}
 	}
 

-- 
To view, visit https://gerrit.osmocom.org/c/osmo-bsc/+/21234
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-bsc
Gerrit-Branch: master
Gerrit-Change-Id: I745dc95cf564dd330295cecb4d64dccebf55163f
Gerrit-Change-Number: 21234
Gerrit-PatchSet: 2
Gerrit-Owner: neels <nhofmeyr at sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <laforge at osmocom.org>
Gerrit-Reviewer: pespin <pespin at sysmocom.de>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20201120/03da603f/attachment.htm>


More information about the gerrit-log mailing list