Change in osmo-pcu[master]: ts_alloc: Simplify tfi_find_free logic

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
Tue Nov 9 15:53:39 UTC 2021


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


Change subject: ts_alloc: Simplify tfi_find_free logic
......................................................................

ts_alloc: Simplify tfi_find_free logic

Avoid passing an extra pram which is accessible by GprsMs object already
being passed. Once, the "trx = ms_current_trx(ms)" is moved inside the
tfi_find_free function, it becomes clear that all the logic can be
further simplified.

Change-Id: I733d9bee3fa1dfc647da9f150b30014fbdab7442
---
M src/gprs_rlcmac_ts_alloc.cpp
1 file changed, 6 insertions(+), 10 deletions(-)



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

diff --git a/src/gprs_rlcmac_ts_alloc.cpp b/src/gprs_rlcmac_ts_alloc.cpp
index 5b3b355..c3709c5 100644
--- a/src/gprs_rlcmac_ts_alloc.cpp
+++ b/src/gprs_rlcmac_ts_alloc.cpp
@@ -298,20 +298,21 @@
 /*! Return free TFI
  *
  *  \param[in] bts Pointer to BTS struct
- *  \param[in] trx Optional pointer to TRX struct
  *  \param[in] ms Pointer to MS object
  *  \param[in] dir DL or UL direction
  *  \param[in] use_trx which TRX to use or -1 if it should be selected based on what MS uses
  *  \param[out] trx_no_ TRX number on which TFI was found
  *  \returns negative error code or 0 on success
  */
-static int tfi_find_free(const struct gprs_rlcmac_bts *bts, const gprs_rlcmac_trx *trx, const GprsMs *ms,
+static int tfi_find_free(const struct gprs_rlcmac_bts *bts, const GprsMs *ms,
 			 enum gprs_rlcmac_tbf_direction dir, int8_t use_trx, uint8_t *trx_no_)
 {
+	struct gprs_rlcmac_trx *trx;
 	int tfi;
 	uint8_t trx_no;
 
-	if (trx) {
+	/* If MS is already doing stuff on a TRX, set use_trx to it: */
+	if ((trx = ms_current_trx(ms))) {
 		if (use_trx >= 0 && use_trx != trx->trx_no) {
 			LOGP(DRLCMAC, LOGL_ERROR, "- Requested incompatible TRX %d (current is %d)\n",
 			     use_trx, trx->trx_no);
@@ -320,9 +321,6 @@
 		use_trx = trx->trx_no;
 	}
 
-	if (use_trx == -1 && ms_current_trx(ms))
-		use_trx = ms_current_trx(ms)->trx_no;
-
 	tfi = bts_tfi_find_free(bts, dir, &trx_no, use_trx);
 	if (tfi < 0)
 		return -EBUSY;
@@ -884,18 +882,16 @@
 	reserved_dl_slots = ms_reserved_dl_slots(ms);
 	reserved_ul_slots = ms_reserved_ul_slots(ms);
 	first_common_ts = ms_first_common_ts(ms);
-	trx = ms_current_trx(ms);
 
 	/* Step 2a: Find usable TRX and TFI */
-	tfi = tfi_find_free(bts, trx, ms, tbf->direction, use_trx, &trx_no);
+	tfi = tfi_find_free(bts, ms, tbf->direction, use_trx, &trx_no);
 	if (tfi < 0) {
 		LOGPAL(tbf, "B", single, use_trx, LOGL_NOTICE, "failed to allocate a TFI\n");
 		return tfi;
 	}
 
 	/* Step 2b: Reserve slots on the TRX for the MS */
-	if (!trx)
-		trx = &bts->trx[trx_no];
+	trx = &bts->trx[trx_no];
 
 	if (!reserved_dl_slots || !reserved_ul_slots) {
 		rc = find_multi_slots(trx, ms_ms_class(ms), &reserved_ul_slots, &reserved_dl_slots);

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

Gerrit-Project: osmo-pcu
Gerrit-Branch: master
Gerrit-Change-Id: I733d9bee3fa1dfc647da9f150b30014fbdab7442
Gerrit-Change-Number: 26180
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/20211109/dbc92e0c/attachment.htm>


More information about the gerrit-log mailing list