Change in osmo-pcu[master]: Remove uneeded ms param from alloc_algorithm_func_t func

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/.

pespin gerrit-no-reply at lists.osmocom.org
Thu Feb 25 17:38:47 UTC 2021


pespin has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-pcu/+/23109 )


Change subject: Remove uneeded ms param from alloc_algorithm_func_t func
......................................................................

Remove uneeded ms param from alloc_algorithm_func_t func

Since a while ago, the data architecture was changed so that TBF is
guaranteed to always have a MS object associated. Hence, it makes no
sense to pass the MS object as a separate param as we can take it from
tbf object and makes code less confusing.

Change-Id: Idc0c76cf6f007afa4236480cdad0d8e99dabec5f
---
M src/gprs_pcu.h
M src/gprs_rlcmac.h
M src/gprs_rlcmac_ts_alloc.cpp
M src/tbf.cpp
M tests/alloc/AllocTest.cpp
5 files changed, 17 insertions(+), 27 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-pcu refs/changes/09/23109/1

diff --git a/src/gprs_pcu.h b/src/gprs_pcu.h
index 76e3937..a17144c 100644
--- a/src/gprs_pcu.h
+++ b/src/gprs_pcu.h
@@ -67,7 +67,6 @@
 struct gprs_rlcmac_tbf;
 
 typedef int (*alloc_algorithm_func_t)(struct gprs_rlcmac_bts *bts,
-				      struct GprsMs *ms,
 				      struct gprs_rlcmac_tbf *tbf,
 				      bool single, int8_t use_tbf);
 
diff --git a/src/gprs_rlcmac.h b/src/gprs_rlcmac.h
index 69fd6a4..cf95c37 100644
--- a/src/gprs_rlcmac.h
+++ b/src/gprs_rlcmac.h
@@ -104,13 +104,13 @@
 
 extern "C" {
 #endif
-int alloc_algorithm_a(struct gprs_rlcmac_bts *bts, struct GprsMs *ms, struct gprs_rlcmac_tbf *tbf, bool single,
+int alloc_algorithm_a(struct gprs_rlcmac_bts *bts, struct gprs_rlcmac_tbf *tbf, bool single,
 		      int8_t use_trx);
 
-int alloc_algorithm_b(struct gprs_rlcmac_bts *bts, struct GprsMs *ms, struct gprs_rlcmac_tbf *tbf, bool single,
+int alloc_algorithm_b(struct gprs_rlcmac_bts *bts, struct gprs_rlcmac_tbf *tbf, bool single,
 		      int8_t use_trx);
 
-int alloc_algorithm_dynamic(struct gprs_rlcmac_bts *bts, struct GprsMs *ms, struct gprs_rlcmac_tbf *tbf, bool single,
+int alloc_algorithm_dynamic(struct gprs_rlcmac_bts *bts, struct gprs_rlcmac_tbf *tbf, bool single,
 			    int8_t use_trx);
 
 int gprs_rlcmac_paging_request(struct gprs_rlcmac_bts *bts, const struct osmo_mobile_identity *mi, uint16_t pgroup);
diff --git a/src/gprs_rlcmac_ts_alloc.cpp b/src/gprs_rlcmac_ts_alloc.cpp
index 7202423..1dc31f6 100644
--- a/src/gprs_rlcmac_ts_alloc.cpp
+++ b/src/gprs_rlcmac_ts_alloc.cpp
@@ -338,13 +338,12 @@
  * Assign single slot for uplink and downlink
  *
  *  \param[in,out] bts Pointer to BTS struct
- *  \param[in,out] ms_ Pointer to MS object
  *  \param[in,out] tbf_ Pointer to TBF struct
  *  \param[in] single flag indicating if we should force single-slot allocation
  *  \param[in] use_trx which TRX to use or -1 if it should be selected during allocation
  *  \returns negative error code or 0 on success
  */
-int alloc_algorithm_a(struct gprs_rlcmac_bts *bts, GprsMs *ms_, struct gprs_rlcmac_tbf *tbf_, bool single,
+int alloc_algorithm_a(struct gprs_rlcmac_bts *bts, struct gprs_rlcmac_tbf *tbf_, bool single,
 		      int8_t use_trx)
 {
 	struct gprs_rlcmac_pdch *pdch;
@@ -355,7 +354,7 @@
 	int usf = -1;
 	uint8_t mask = 0xff;
 	const char *mask_reason = NULL;
-	const GprsMs *ms = ms_;
+	struct GprsMs *ms = tbf_->ms();
 	const gprs_rlcmac_tbf *tbf = tbf_;
 	gprs_rlcmac_trx *trx = ms_current_trx(ms);
 
@@ -420,7 +419,7 @@
 	tbf_->trx = trx;
 	/* the only one TS is the common TS */
 	tbf_->first_ts = tbf_->first_common_ts = ts;
-	ms_set_reserved_slots(ms_, trx, 1 << ts, 1 << ts);
+	ms_set_reserved_slots(ms, trx, 1 << ts, 1 << ts);
 
 	tbf_->upgrade_to_multislot = 0;
 	bts_do_rate_ctr_inc(bts, CTR_TBF_ALLOC_ALGO_A);
@@ -853,13 +852,12 @@
  * Assign one uplink slot. (With free USF)
  *
  *  \param[in,out] bts Pointer to BTS struct
- *  \param[in,out] ms_ Pointer to MS object
  *  \param[in,out] tbf_ Pointer to TBF struct
  *  \param[in] single flag indicating if we should force single-slot allocation
  *  \param[in] use_trx which TRX to use or -1 if it should be selected during allocation
  *  \returns negative error code or 0 on success
  */
-int alloc_algorithm_b(struct gprs_rlcmac_bts *bts, GprsMs *ms_, struct gprs_rlcmac_tbf *tbf_, bool single,
+int alloc_algorithm_b(struct gprs_rlcmac_bts *bts, struct gprs_rlcmac_tbf *tbf_, bool single,
 		      int8_t use_trx)
 {
 	uint8_t dl_slots;
@@ -873,7 +871,7 @@
 	int usf[8] = {-1, -1, -1, -1, -1, -1, -1, -1};
 	int rc;
 	int tfi;
-	const GprsMs *ms = ms_;
+	struct GprsMs *ms = tbf_->ms();
 	const gprs_rlcmac_tbf *tbf = tbf_;
 	gprs_rlcmac_trx *trx;
 
@@ -881,10 +879,7 @@
 
 	/* Step 1: Get current state from the MS object */
 
-	if (!ms) {
-		LOGP(DRLCMAC, LOGL_ERROR, "MS not set\n");
-		return -EINVAL;
-	}
+	OSMO_ASSERT(ms);
 
 	dl_slots = ms_reserved_dl_slots(ms);
 	ul_slots = ms_reserved_ul_slots(ms);
@@ -958,7 +953,7 @@
 
 	/* Step 4: Update MS and TBF and really allocate the resources */
 
-	update_ms_reserved_slots(trx, ms_, reserved_ul_slots, reserved_dl_slots, ul_slots, dl_slots);
+	update_ms_reserved_slots(trx, ms, reserved_ul_slots, reserved_dl_slots, ul_slots, dl_slots);
 
 	tbf_->trx = trx;
 	tbf_->first_common_ts = first_common_ts;
@@ -983,13 +978,12 @@
  * goal is to provide the highest possible bandwidth per MS.
  *
  *  \param[in,out] bts Pointer to BTS struct
- *  \param[in,out] ms_ Pointer to MS object
  *  \param[in,out] tbf_ Pointer to TBF struct
  *  \param[in] single flag indicating if we should force single-slot allocation
  *  \param[in] use_trx which TRX to use or -1 if it should be selected during allocation
  *  \returns negative error code or 0 on success
  */
-int alloc_algorithm_dynamic(struct gprs_rlcmac_bts *bts, GprsMs *ms_, struct gprs_rlcmac_tbf *tbf_, bool single,
+int alloc_algorithm_dynamic(struct gprs_rlcmac_bts *bts, struct gprs_rlcmac_tbf *tbf_, bool single,
 			    int8_t use_trx)
 {
 	int rc;
@@ -1002,7 +996,7 @@
 	}
 
 	if (!bts->multislot_disabled) {
-		rc = alloc_algorithm_b(bts, ms_, tbf_, single, use_trx);
+		rc = alloc_algorithm_b(bts, tbf_, single, use_trx);
 		if (rc >= 0)
 			return rc;
 
@@ -1011,7 +1005,7 @@
 		bts->multislot_disabled = 1;
 	}
 
-	return alloc_algorithm_a(bts, ms_, tbf_, single, use_trx);
+	return alloc_algorithm_a(bts, tbf_, single, use_trx);
 }
 
 int gprs_alloc_max_dl_slots_per_ms(const struct gprs_rlcmac_bts *bts, uint8_t ms_class)
diff --git a/src/tbf.cpp b/src/tbf.cpp
index 2f58375..5ca34f4 100644
--- a/src/tbf.cpp
+++ b/src/tbf.cpp
@@ -331,7 +331,7 @@
 	LOGP(DTBF, LOGL_DEBUG, "********** DL-TBF update **********\n");
 
 	tbf_unlink_pdch(this);
-	rc = the_pcu->alloc_algorithm(bts, ms(), this, false, -1);
+	rc = the_pcu->alloc_algorithm(bts, this, false, -1);
 	/* if no resource */
 	if (rc < 0) {
 		LOGPTBF(this, LOGL_ERROR, "No resource after update???\n");
@@ -749,7 +749,7 @@
 
 	m_created_ts = time(NULL);
 	/* select algorithm */
-	rc = the_pcu->alloc_algorithm(bts, m_ms, this, single_slot, use_trx);
+	rc = the_pcu->alloc_algorithm(bts, this, single_slot, use_trx);
 	/* if no resource */
 	if (rc < 0) {
 		LOGPTBF(this, LOGL_NOTICE,
diff --git a/tests/alloc/AllocTest.cpp b/tests/alloc/AllocTest.cpp
index d626692..fe803e3 100644
--- a/tests/alloc/AllocTest.cpp
+++ b/tests/alloc/AllocTest.cpp
@@ -423,9 +423,6 @@
 	test_all_alloc_b();
 }
 
-typedef int (*algo_t)(struct gprs_rlcmac_bts *bts, struct GprsMs *ms, struct gprs_rlcmac_tbf *tbf, bool single,
-		      int8_t use_trx);
-
 static char get_dir_char(uint8_t mask, uint8_t tx, uint8_t rx, uint8_t busy)
 {
 	int offs = busy ? 32 : 0;
@@ -640,7 +637,7 @@
 	return counter;
 }
 
-static void test_successive_allocation(algo_t algo, unsigned min_class,
+static void test_successive_allocation(alloc_algorithm_func_t algo, unsigned min_class,
 	unsigned max_class, enum test_mode mode,
 	unsigned expect_num, const char *text)
 {
@@ -674,7 +671,7 @@
 	talloc_free(bts);
 }
 
-static void test_many_connections(algo_t algo, unsigned expect_num,
+static void test_many_connections(alloc_algorithm_func_t algo, unsigned expect_num,
 	const char *text)
 {
 	struct gprs_rlcmac_bts *bts = bts_alloc(the_pcu, 0);

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

Gerrit-Project: osmo-pcu
Gerrit-Branch: master
Gerrit-Change-Id: Idc0c76cf6f007afa4236480cdad0d8e99dabec5f
Gerrit-Change-Number: 23109
Gerrit-PatchSet: 1
Gerrit-Owner: pespin <pespin at sysmocom.de>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20210225/597b403b/attachment.htm>


More information about the gerrit-log mailing list