Change in osmo-bts[master]: [VAMOS] osmo-bts-trx: rework and split up bts_sched_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/.

fixeria gerrit-no-reply at lists.osmocom.org
Fri May 21 15:15:46 UTC 2021


fixeria has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-bts/+/24323 )


Change subject: [VAMOS] osmo-bts-trx: rework and split up bts_sched_fn()
......................................................................

[VAMOS] osmo-bts-trx: rework and split up bts_sched_fn()

Currently, in bts_sched_fn() we send a Downlink burst to the PHY
immediately after calling the associated logical channel handler.
Together with the obvious performance advantages, this approach
imposes some serious limitations.  The code has already become
quite complex with the introduction of the baseband frequency
hopping, and now it's not possible anymore to extend it further.

TRXD PDU batching, which is essential for VAMOS implementation,
requires us to make the scheduler more flexible at the expense of
increased memory consumption and additional CPU cycles.  This patch
splits up Downlink burst scheduling into 3 main steps:

  1. bts_sched_init_buffers(): initialization of per-TRX Downlink
     burst buffers allocated by phy_instance_create().  For C0/TRX0
     all timeslots are pre-initialized with dummy burst.
  2. bts_sched_fn(): generating burst bits for all active lchans.
  3. bts_sched_flush_buffers(): sending everything to the PHY.

This approach allows us to a) get rid of the ugly tail in bts_sched_fn()
that was responsible for sending dummy bursts on C0/TRX0;  b) implement
the PDU batching and have several variants of bts_sched_flush_buffers()
providing the alternative batching approaches later on;  c) implement
PDU merging for the upcoming shadow transceivers.

Change-Id: Iec78989517865b3275a9784d1042a5ebd1d2815f
Related: SYS#4895, OS#4941
---
M include/osmo-bts/phy_link.h
M src/osmo-bts-trx/scheduler_trx.c
2 files changed, 76 insertions(+), 51 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-bts refs/changes/23/24323/1

diff --git a/include/osmo-bts/phy_link.h b/include/osmo-bts/phy_link.h
index c4b60f3..bc934ec 100644
--- a/include/osmo-bts/phy_link.h
+++ b/include/osmo-bts/phy_link.h
@@ -113,6 +113,7 @@
 		struct {
 			struct trx_l1h *hdl;
 			bool sw_act_reported;
+			struct trx_dl_burst_req br[TRX_NR_TS];
 		} osmotrx;
 		struct {
 			/* logical transceiver number within one PHY */
diff --git a/src/osmo-bts-trx/scheduler_trx.c b/src/osmo-bts-trx/scheduler_trx.c
index c90a0a3..2a37abb 100644
--- a/src/osmo-bts-trx/scheduler_trx.c
+++ b/src/osmo-bts-trx/scheduler_trx.c
@@ -3,6 +3,7 @@
 /* (C) 2013 by Andreas Eversberg <jolly at eversberg.eu>
  * (C) 2015 by Alexander Chemeris <Alexander.Chemeris at fairwaves.co>
  * (C) 2015-2017 by Harald Welte <laforge at gnumonks.org>
+ * (C) 2020-2021 by sysmocom - s.m.f.c. GmbH <info at sysmocom.de>
  *
  * All Rights Reserved
  *
@@ -92,19 +93,72 @@
 	return NULL;
 }
 
+static void bts_sched_init_buffers(struct gsm_bts *bts, const uint32_t fn)
+{
+	struct gsm_bts_trx *trx;
+	uint8_t tn;
+
+	llist_for_each_entry(trx, &bts->trx_list, list) {
+		struct phy_instance *pinst = trx->pinst;
+		const struct phy_link *plink = pinst->phy_link;
+
+		/* Advance frame number, so the PHY has more time to process bursts */
+		const uint32_t sched_fn = GSM_TDMA_FN_SUM(fn, plink->u.osmotrx.clock_advance);
+
+		for (tn = 0; tn < ARRAY_SIZE(trx->ts); tn++) {
+			struct trx_dl_burst_req *br = &pinst->u.osmotrx.br[tn];
+
+			*br = (struct trx_dl_burst_req) {
+				.trx_num = trx->nr,
+				.fn = sched_fn,
+				.tn = tn,
+			};
+		}
+	}
+
+	/* Initialize all timeslots on C0/TRX0 with dummy burst */
+	for (tn = 0; tn < ARRAY_SIZE(trx->ts); tn++) {
+		struct phy_instance *pinst = bts->c0->pinst;
+		struct trx_dl_burst_req *br = &pinst->u.osmotrx.br[tn];
+
+		memcpy(br->burst, _sched_dummy_burst, GSM_BURST_LEN);
+		br->burst_len = GSM_BURST_LEN;
+	}
+}
+
+static void bts_sched_flush_buffers(struct gsm_bts *bts)
+{
+	const struct gsm_bts_trx *trx;
+	unsigned int tn;
+
+	llist_for_each_entry(trx, &bts->trx_list, list) {
+		const struct phy_instance *pinst = trx->pinst;
+		struct trx_l1h *l1h = pinst->u.osmotrx.hdl;
+
+		for (tn = 0; tn < TRX_NR_TS; tn++) {
+			const struct trx_dl_burst_req *br;
+
+			br = &pinst->u.osmotrx.br[tn];
+			if (!br->burst_len)
+				continue;
+			trx_if_send_burst(l1h, br);
+		}
+	}
+}
+
 /* schedule all frames of all TRX for given FN */
 static void bts_sched_fn(struct gsm_bts *bts, const uint32_t fn)
 {
-	struct trx_dl_burst_req br;
 	struct gsm_bts_trx *trx;
-	uint8_t c0_mask = 0x00;
-	uint32_t sched_fn;
-	uint8_t tn;
+	unsigned int tn;
 
 	/* send time indication */
 	l1if_mph_time_ind(bts, fn);
 
-	/* process every TRX */
+	/* Initialize Downlink burst buffers */
+	bts_sched_init_buffers(bts, fn);
+
+	/* Populate Downlink burst buffers for each TRX/TS */
 	llist_for_each_entry(trx, &bts->trx_list, list) {
 		const struct phy_link *plink = trx->pinst->phy_link;
 		struct trx_l1h *l1h = trx->pinst->u.osmotrx.hdl;
@@ -113,66 +167,36 @@
 		if (!trx_if_powered(l1h))
 			continue;
 
-		/* advance frame number, so the transceiver has more
-		 * time until it must be transmitted. */
-		sched_fn = GSM_TDMA_FN_SUM(fn, plink->u.osmotrx.clock_advance);
-
 		/* process every TS of TRX */
 		for (tn = 0; tn < ARRAY_SIZE(trx->ts); tn++) {
-			const struct phy_instance *pinst = trx->pinst;
-			struct l1sched_ts *l1ts = trx->ts[tn].priv;
+			struct phy_instance *pinst = trx->pinst;
+			struct gsm_bts_trx_ts *ts = &trx->ts[tn];
+			struct l1sched_ts *l1ts = ts->priv;
+			struct trx_dl_burst_req *br;
 
 			/* ready-to-send */
-			_sched_rts(l1ts, GSM_TDMA_FN_SUM(sched_fn, plink->u.osmotrx.rts_advance));
+			_sched_rts(l1ts, GSM_TDMA_FN_SUM(fn, plink->u.osmotrx.clock_advance
+							   + plink->u.osmotrx.rts_advance));
 
-			/* All other parameters to be set by _sched_dl_burst() */
-			br = (struct trx_dl_burst_req) {
-				.fn = sched_fn,
-				.tn = tn,
-			};
-
-			/* get burst for FN */
-			_sched_dl_burst(l1ts, &br);
-			if (br.burst_len == 0) {
-				/* if no bits, send no burst */
-				continue;
-			}
+			/* pre-initialized buffer for the Downlink burst */
+			br = &pinst->u.osmotrx.br[tn];
 
 			/* resolve PHY instance if freq. hopping is enabled */
-			if (trx->ts[tn].hopping.enabled) {
-				pinst = dlfh_route_br(&br, &trx->ts[tn]);
+			if (ts->hopping.enabled) {
+				pinst = dlfh_route_br(br, ts);
 				if (pinst == NULL)
 					continue;
+				/* simply use a different buffer */
+				br = &pinst->u.osmotrx.br[tn];
 			}
 
-			if (pinst->trx == bts->c0) {
-				/* update dummy burst mask for C0 */
-				c0_mask |= (1 << tn);
-				/* ensure no attenuation on C0 */
-				br.att = 0;
-			}
-
-			trx_if_send_burst(pinst->u.osmotrx.hdl, &br);
+			/* get burst for FN */
+			_sched_dl_burst(l1ts, br);
 		}
 	}
 
-	/* send dummy bursts on inactive timeslots of C0 */
-	struct phy_instance *pinst = trx_phy_instance(bts->c0);
-	struct trx_l1h *l1h = pinst->u.osmotrx.hdl;
-	struct phy_link *plink = pinst->phy_link;
-
-	br = (struct trx_dl_burst_req) {
-		.fn = GSM_TDMA_FN_SUM(fn, plink->u.osmotrx.clock_advance),
-		.burst_len = GSM_BURST_LEN,
-	};
-
-	memcpy(br.burst, _sched_dummy_burst, GSM_BURST_LEN);
-
-	for (br.tn = 0; br.tn < TRX_NR_TS; br.tn++) {
-		if (c0_mask & (1 << br.tn))
-			continue;
-		trx_if_send_burst(l1h, &br);
-	}
+	/* Send everything to the PHY */
+	bts_sched_flush_buffers(bts);
 }
 
 /* Find a route (TRX instance) for a given Uplink burst indication */

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

Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-Change-Id: Iec78989517865b3275a9784d1042a5ebd1d2815f
Gerrit-Change-Number: 24323
Gerrit-PatchSet: 1
Gerrit-Owner: fixeria <vyanitskiy at sysmocom.de>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20210521/f357ad78/attachment.htm>


More information about the gerrit-log mailing list