Change in osmo-bts[master]: osmo-bts-trx/scheduler: implement baseband frequency hopping

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

Hoernchen gerrit-no-reply at lists.osmocom.org
Fri Aug 7 18:18:54 UTC 2020


Hoernchen has submitted this change. ( https://gerrit.osmocom.org/c/osmo-bts/+/19030 )

Change subject: osmo-bts-trx/scheduler: implement baseband frequency hopping
......................................................................

osmo-bts-trx/scheduler: implement baseband frequency hopping

The idea behind the baseband frequency hopping is quite simple: we
have several RF carriers (transceivers) transmitting and receiving
on fixed frequencies (just like in a regular multi-trx setup), and
an additional burst routing layer between the schedulear and the
transceiver interface (TRXD over UDP).

Speaking in terms of the proposed implementation:

  - on Downlink, dlfh_route_br() calculates the ARFCN corresponding
    to the current TDMA frame number according to the hopping sequence
    parametets, and picks the transceiver with matching ARFCN;

  - on Uplink, ulfh_route_bi() iterates over the transceiver list of
    of the BTS, calculating hopping ARFCNs for equivalent timeslots,
    and picks the one with ARFCN matching the received burst.

In order to avoid frequent transceiver lookups on the Downlink path,
dlfh_route_br() maintains a "cache" in the timeslot state structure.
Unfortunately, this "cache" seems to be useless on the Uplink path,
so ulfh_route_bi() always needs to lookup the matching transceiver
for each burst received over the TRXD interface.

It may also happen that the scheduler will be unable to route an
Uplink or Downlink burst, e.g. due to inconsistent / incorrect
hopping sequence parameters received from the BSC, or in case
if a transceiver gets RF-locked by the BTS operator.

Such events are logged as "FATAL" and aditionally signalled by the
following osmo-bts-trx specific rate counters:

  - trx_sched:dl_fh_no_carrier (Downlink), and
  - trx_sched:ul_fh_no_carrier (Uplink).

Change-Id: I68f4ae09fd0789ad0d8f1c1e17e17dfc4de8e462
Related: SYS#4868, OS#4546
---
M include/osmo-bts/gsm_data.h
M include/osmo-bts/scheduler.h
M src/osmo-bts-trx/l1_if.h
M src/osmo-bts-trx/main.c
M src/osmo-bts-trx/scheduler_trx.c
M src/osmo-bts-trx/trx_if.c
6 files changed, 117 insertions(+), 4 deletions(-)

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



diff --git a/include/osmo-bts/gsm_data.h b/include/osmo-bts/gsm_data.h
index 0402f11..6b696b4 100644
--- a/include/osmo-bts/gsm_data.h
+++ b/include/osmo-bts/gsm_data.h
@@ -335,6 +335,9 @@
 		uint8_t ma_len;
 	} hopping;
 
+	/* Transceiver "cache" for frequency hopping */
+	const struct gsm_bts_trx *fh_trx_list[64];
+
 	struct gsm_lchan lchan[TS_MAX_LCHAN];
 };
 
diff --git a/include/osmo-bts/scheduler.h b/include/osmo-bts/scheduler.h
index bc2fb69..47c0e9a 100644
--- a/include/osmo-bts/scheduler.h
+++ b/include/osmo-bts/scheduler.h
@@ -267,6 +267,7 @@
 };
 
 /*! Handle an UL burst received by PHY */
+int trx_sched_route_burst_ind(struct trx_ul_burst_ind *bi, struct l1sched_trx *l1t);
 int trx_sched_ul_burst(struct l1sched_trx *l1t, struct trx_ul_burst_ind *bi);
 
 #endif /* TRX_SCHEDULER_H */
diff --git a/src/osmo-bts-trx/l1_if.h b/src/osmo-bts-trx/l1_if.h
index fb988a6..8c309db 100644
--- a/src/osmo-bts-trx/l1_if.h
+++ b/src/osmo-bts-trx/l1_if.h
@@ -29,6 +29,8 @@
 /* bts-trx specific rate counters */
 enum {
 	BTSTRX_CTR_SCHED_DL_MISS_FN,
+	BTSTRX_CTR_SCHED_DL_FH_NO_CARRIER,
+	BTSTRX_CTR_SCHED_UL_FH_NO_CARRIER,
 };
 
 /*! clock state of a given TRX */
diff --git a/src/osmo-bts-trx/main.c b/src/osmo-bts-trx/main.c
index e35f6fe..e2d9005 100644
--- a/src/osmo-bts-trx/main.c
+++ b/src/osmo-bts-trx/main.c
@@ -62,8 +62,18 @@
 #include "trx_if.h"
 
 static const struct rate_ctr_desc btstrx_ctr_desc[] = {
-	[BTSTRX_CTR_SCHED_DL_MISS_FN] =	{"trx_clk:sched_dl_miss_fn",
-					 "Downlink frames scheduled later than expected due to missed timerfd event (due to high system load)"},
+	[BTSTRX_CTR_SCHED_DL_MISS_FN] = {
+		"trx_clk:sched_dl_miss_fn",
+		"Downlink frames scheduled later than expected due to missed timerfd event (due to high system load)"
+	},
+	[BTSTRX_CTR_SCHED_DL_FH_NO_CARRIER] = {
+		"trx_sched:dl_fh_no_carrier",
+		"Frequency hopping: no carrier found for a Downlink burst (check hopping parameters)"
+	},
+	[BTSTRX_CTR_SCHED_UL_FH_NO_CARRIER] = {
+		"trx_sched:ul_fh_no_carrier",
+		"Frequency hopping: no carrier found for an Uplink burst (check hopping parameters)"
+	},
 };
 static const struct rate_ctr_group_desc btstrx_ctrg_desc = {
 	"bts-trx",
diff --git a/src/osmo-bts-trx/scheduler_trx.c b/src/osmo-bts-trx/scheduler_trx.c
index e617031..fd68f63 100644
--- a/src/osmo-bts-trx/scheduler_trx.c
+++ b/src/osmo-bts-trx/scheduler_trx.c
@@ -34,6 +34,7 @@
 #include <osmocom/core/timer_compat.h>
 #include <osmocom/core/bits.h>
 #include <osmocom/gsm/a5.h>
+#include <osmocom/gsm/gsm0502.h>
 
 
 #include <osmo-bts/gsm_data.h>
@@ -47,6 +48,10 @@
 #include "l1_if.h"
 #include "trx_if.h"
 
+#define SCHED_FH_PARAMS_FMT "hsn=%u, maio=%u, ma_len=%u"
+#define SCHED_FH_PARAMS_VALS(ts) \
+	(ts)->hopping.hsn, (ts)->hopping.maio, (ts)->hopping.ma_len
+
 /* an IDLE burst returns nothing. on C0 it is replaced by dummy burst */
 int tx_idle_fn(struct l1sched_trx *l1t, enum trx_chan_type chan,
 	       uint8_t bid, struct trx_dl_burst_req *br)
@@ -55,6 +60,39 @@
 	return 0;
 }
 
+/* Find a route (PHY instance) for a given Downlink burst request */
+static struct phy_instance *dlfh_route_br(const struct trx_dl_burst_req *br,
+					  struct gsm_bts_trx_ts *ts)
+{
+	const struct gsm_bts_trx *trx;
+	struct gsm_time time;
+	uint16_t idx;
+
+	gsm_fn2gsmtime(&time, br->fn);
+
+	/* Check the "cache" first, so we eliminate frequent lookups */
+	idx = gsm0502_hop_seq_gen(&time, SCHED_FH_PARAMS_VALS(ts), NULL);
+	if (ts->fh_trx_list[idx] != NULL)
+		return ts->fh_trx_list[idx]->role_bts.l1h;
+
+	/* The "cache" may not be filled yet, lookup the transceiver */
+	llist_for_each_entry(trx, &ts->trx->bts->trx_list, list) {
+		if (trx->arfcn == ts->hopping.ma[idx]) {
+			ts->fh_trx_list[idx] = trx;
+			return trx->role_bts.l1h;
+		}
+	}
+
+	LOGPTRX(ts->trx, DL1C, LOGL_FATAL, "Failed to find the transceiver (RF carrier) "
+		"for a Downlink burst (fn=%u, tn=%u, " SCHED_FH_PARAMS_FMT ")\n",
+		br->fn, br->tn, SCHED_FH_PARAMS_VALS(ts));
+
+	struct bts_trx_priv *priv = (struct bts_trx_priv *) ts->trx->bts->model_priv;
+	rate_ctr_inc(&priv->ctrs->ctr[BTSTRX_CTR_SCHED_DL_FH_NO_CARRIER]);
+
+	return NULL;
+}
+
 /* schedule all frames of all TRX for given FN */
 static void trx_sched_fn(struct gsm_bts *bts, const uint32_t fn)
 {
@@ -100,8 +138,16 @@
 				continue;
 			}
 
+			/* resolve PHY instance if freq. hopping is enabled */
+			if (trx->ts[tn].hopping.enabled) {
+				pinst = dlfh_route_br(&br, &trx->ts[tn]);
+				if (pinst == NULL)
+					continue;
+				l1h = pinst->u.osmotrx.hdl;
+			}
+
 			/* update dummy burst mask for C0 */
-			if (trx == bts->c0)
+			if (pinst->trx == bts->c0)
 				c0_mask |= (1 << tn);
 
 			trx_if_send_burst(l1h, &br);
@@ -127,6 +173,57 @@
 	}
 }
 
+/* Find a route (TRX instance) for a given Uplink burst indication */
+static struct gsm_bts_trx *ulfh_route_bi(const struct trx_ul_burst_ind *bi,
+					 const struct gsm_bts_trx *src_trx)
+{
+	struct gsm_bts_trx *trx;
+	struct gsm_time time;
+	uint16_t arfcn;
+
+	gsm_fn2gsmtime(&time, bi->fn);
+
+	llist_for_each_entry(trx, &src_trx->bts->trx_list, list) {
+		const struct gsm_bts_trx_ts *ts = &trx->ts[bi->tn];
+		if (!ts->hopping.enabled)
+			continue;
+
+		arfcn = gsm0502_hop_seq_gen(&time, SCHED_FH_PARAMS_VALS(ts), ts->hopping.ma);
+		if (src_trx->arfcn == arfcn)
+			return trx;
+	}
+
+	LOGPTRX(src_trx, DL1C, LOGL_DEBUG, "Failed to find the transceiver (RF carrier) "
+		"for an Uplink burst (fn=%u, tn=%u, " SCHED_FH_PARAMS_FMT ")\n",
+		bi->fn, bi->tn, SCHED_FH_PARAMS_VALS(&src_trx->ts[bi->tn]));
+
+	struct bts_trx_priv *priv = (struct bts_trx_priv *) src_trx->bts->model_priv;
+	rate_ctr_inc(&priv->ctrs->ctr[BTSTRX_CTR_SCHED_UL_FH_NO_CARRIER]);
+
+	return NULL;
+}
+
+/* Route a given Uplink burst indication to the scheduler depending on freq. hopping state */
+int trx_sched_route_burst_ind(struct trx_ul_burst_ind *bi, struct l1sched_trx *l1t)
+{
+	const struct phy_instance *pinst;
+	const struct gsm_bts_trx *trx;
+	struct trx_l1h *l1h;
+
+	/* no frequency hopping => nothing to do */
+	if (!l1t->trx->ts[bi->tn].hopping.enabled)
+		return trx_sched_ul_burst(l1t, bi);
+
+	trx = ulfh_route_bi(bi, l1t->trx);
+	if (trx == NULL)
+		return -ENODEV;
+
+	pinst = trx_phy_instance(trx);
+	l1h = pinst->u.osmotrx.hdl;
+
+	return trx_sched_ul_burst(&l1h->l1s, bi);
+}
+
 /*! maximum number of 'missed' frame periods we can tolerate of OS doesn't schedule us*/
 #define MAX_FN_SKEW		50
 /*! maximum number of frame periods we can tolerate without TRX Clock Indication*/
diff --git a/src/osmo-bts-trx/trx_if.c b/src/osmo-bts-trx/trx_if.c
index ad6faad..875487a 100644
--- a/src/osmo-bts-trx/trx_if.c
+++ b/src/osmo-bts-trx/trx_if.c
@@ -1094,7 +1094,7 @@
 		hdr_ver, trx_data_desc_msg(&bi));
 
 	/* feed received burst into scheduler code */
-	trx_sched_ul_burst(&l1h->l1s, &bi);
+	trx_sched_route_burst_ind(&bi, &l1h->l1s);
 
 	return 0;
 }

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

Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-Change-Id: I68f4ae09fd0789ad0d8f1c1e17e17dfc4de8e462
Gerrit-Change-Number: 19030
Gerrit-PatchSet: 6
Gerrit-Owner: fixeria <vyanitskiy at sysmocom.de>
Gerrit-Reviewer: Hoernchen <ewild at sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <vyanitskiy at sysmocom.de>
Gerrit-Reviewer: laforge <laforge at osmocom.org>
Gerrit-CC: pespin <pespin at sysmocom.de>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20200807/1523c558/attachment.htm>


More information about the gerrit-log mailing list