[MERGED] osmo-bts[master]: scheduler_trx: Avoid copy+pasting determining CMR from FN

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

Harald Welte gerrit-no-reply at lists.osmocom.org
Sat May 27 08:24:05 UTC 2017


Harald Welte has submitted this change and it was merged.

Change subject: scheduler_trx: Avoid copy+pasting determining CMR from FN
......................................................................


scheduler_trx: Avoid copy+pasting determining CMR from FN

instead, let's introduce a specific function for that.  Also, as this
can be easily determined from the frame number, skip one argument to
tx_tch_common().

Change-Id: Ibbb9b685cf0b6a45339b0874438a500dd6254bc2
---
M src/osmo-bts-trx/scheduler_trx.c
1 file changed, 12 insertions(+), 8 deletions(-)

Approvals:
  Harald Welte: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/src/osmo-bts-trx/scheduler_trx.c b/src/osmo-bts-trx/scheduler_trx.c
index 1ca371d..ae2bba4 100644
--- a/src/osmo-bts-trx/scheduler_trx.c
+++ b/src/osmo-bts-trx/scheduler_trx.c
@@ -347,10 +347,16 @@
 	return bits;
 }
 
+/* determine if the FN is transmitting a CMR (1) or not (0) */
+static inline int fn_is_codec_mode_request(uint32_t fn)
+{
+	return (((fn + 4) % 26) >> 2) & 1;
+}
+
 /* common section for generation of TCH bursts (TCH/H and TCH/F) */
 static void tx_tch_common(struct l1sched_trx *l1t, uint8_t tn, uint32_t fn,
 	enum trx_chan_type chan, uint8_t bid, struct msgb **_msg_tch,
-	struct msgb **_msg_facch, int codec_mode_request)
+	struct msgb **_msg_facch)
 {
 	struct l1sched_ts *l1ts = l1sched_trx_get_ts(l1t, tn);
 	struct msgb *msg1, *msg2, *msg_tch = NULL, *msg_facch = NULL;
@@ -534,7 +540,7 @@
 					l1t->trx->nr, tn);
 				goto free_bad_msg;
 			}
-			if (codec_mode_request && chan_state->dl_ft != ft) {
+			if (fn_is_codec_mode_request(fn) && chan_state->dl_ft != ft) {
 				LOGP(DL1C, LOGL_NOTICE, "%s Codec (FT = %d) "
 					" of RTP cannot be changed now, but in "
 					"next frame. trx=%u ts=%u\n",
@@ -598,8 +604,7 @@
 		goto send_burst;
 	}
 
-	tx_tch_common(l1t, tn, fn, chan, bid, &msg_tch, &msg_facch,
-		(((fn + 4) % 26) >> 2) & 1);
+	tx_tch_common(l1t, tn, fn, chan, bid, &msg_tch, &msg_facch);
 
 	/* BURST BYPASS */
 
@@ -631,7 +636,7 @@
 		 * the first FN 0,8,17 defines that CMR is included in frame.
 		 */
 		gsm0503_tch_afs_encode(*bursts_p, msg_tch->l2h + 2,
-			msgb_l2len(msg_tch) - 2, (((fn + 4) % 26) >> 2) & 1,
+			msgb_l2len(msg_tch) - 2, fn_is_codec_mode_request(fn),
 			chan_state->codec, chan_state->codecs,
 			chan_state->dl_ft,
 			chan_state->dl_cmr);
@@ -682,8 +687,7 @@
 	}
 
 	/* get TCH and/or FACCH */
-	tx_tch_common(l1t, tn, fn, chan, bid, &msg_tch, &msg_facch,
-		(((fn + 4) % 26) >> 2) & 1);
+	tx_tch_common(l1t, tn, fn, chan, bid, &msg_tch, &msg_facch);
 
 	/* check for FACCH alignment */
 	if (msg_facch && ((((fn + 4) % 26) >> 2) & 1)) {
@@ -731,7 +735,7 @@
 		 * in frame, the first FN 0,8,17 or 1,9,18 defines that CMR is
 		 * included in frame. */
 		gsm0503_tch_ahs_encode(*bursts_p, msg_tch->l2h + 2,
-			msgb_l2len(msg_tch) - 2, (((fn + 4) % 26) >> 2) & 1,
+			msgb_l2len(msg_tch) - 2, fn_is_codec_mode_request(fn),
 			chan_state->codec, chan_state->codecs,
 			chan_state->dl_ft,
 			chan_state->dl_cmr);

-- 
To view, visit https://gerrit.osmocom.org/2750
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Ibbb9b685cf0b6a45339b0874438a500dd6254bc2
Gerrit-PatchSet: 2
Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-Owner: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Jenkins Builder



More information about the gerrit-log mailing list