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

2020-08-07 Thread Hoernchen
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 
 #include 
 #include 
+#include 


 #include 
@@ -47,6 +48,10 @@
 #include "l1_if.h"
 

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

2020-08-07 Thread Hoernchen
Hoernchen has posted comments on this change. ( 
https://gerrit.osmocom.org/c/osmo-bts/+/19030 )

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


Patch Set 6: Code-Review+2


--
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 
Gerrit-Reviewer: Hoernchen 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria 
Gerrit-Reviewer: laforge 
Gerrit-CC: pespin 
Gerrit-Comment-Date: Fri, 07 Aug 2020 18:18:28 +
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment


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

2020-08-06 Thread laforge
laforge has posted comments on this change. ( 
https://gerrit.osmocom.org/c/osmo-bts/+/19030 )

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


Patch Set 5: Code-Review+1


--
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: 5
Gerrit-Owner: fixeria 
Gerrit-Reviewer: Hoernchen 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria 
Gerrit-Reviewer: laforge 
Gerrit-CC: pespin 
Gerrit-Comment-Date: Thu, 06 Aug 2020 16:43:13 +
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment


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

2020-08-02 Thread fixeria
Hello Jenkins Builder,

I'd like you to reexamine a change. Please visit

https://gerrit.osmocom.org/c/osmo-bts/+/19030

to look at the new patch set (#5).

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(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-bts refs/changes/30/19030/5
--
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: 5
Gerrit-Owner: fixeria 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria 
Gerrit-CC: laforge 
Gerrit-CC: pespin 
Gerrit-MessageType: newpatchset


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

2020-08-02 Thread fixeria
Hello Jenkins Builder,

I'd like you to reexamine a change. Please visit

https://gerrit.osmocom.org/c/osmo-bts/+/19030

to look at the new patch set (#4).

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 list of transceivers
of the BTS, calculates the ARFCN corresponding to the received
TDMA frame number and the hopping sequence parametets, and picks
the one with matching expected ARFCN.

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(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-bts refs/changes/30/19030/4
--
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: 4
Gerrit-Owner: fixeria 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria 
Gerrit-CC: laforge 
Gerrit-CC: pespin 
Gerrit-MessageType: newpatchset


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

2020-08-02 Thread fixeria
fixeria has posted comments on this change. ( 
https://gerrit.osmocom.org/c/osmo-bts/+/19030 )

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


Patch Set 3:

This change is ready for review.


--
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: 3
Gerrit-Owner: fixeria 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria 
Gerrit-CC: laforge 
Gerrit-CC: pespin 
Gerrit-Comment-Date: Sun, 02 Aug 2020 14:06:47 +
Gerrit-HasComments: No
Gerrit-Has-Labels: No
Gerrit-MessageType: comment


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

2020-06-28 Thread fixeria
fixeria has uploaded this change for review. ( 
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

Change-Id: I68f4ae09fd0789ad0d8f1c1e17e17dfc4de8e462
Related: OS#4546
---
M include/osmo-bts/scheduler.h
M src/osmo-bts-trx/scheduler_trx.c
M src/osmo-bts-trx/trx_if.c
3 files changed, 78 insertions(+), 2 deletions(-)



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

diff --git a/include/osmo-bts/scheduler.h b/include/osmo-bts/scheduler.h
index e65665f..6f93812 100644
--- a/include/osmo-bts/scheduler.h
+++ b/include/osmo-bts/scheduler.h
@@ -270,6 +270,7 @@
 };

 /*! Handle an UL burst received by PHY */
+int trx_sched_route_burst_ind(struct l1sched_trx *l1t, struct trx_ul_burst_ind 
*bi);
 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/scheduler_trx.c b/src/osmo-bts-trx/scheduler_trx.c
index 8e1ccfa..eecc65e 100644
--- a/src/osmo-bts-trx/scheduler_trx.c
+++ b/src/osmo-bts-trx/scheduler_trx.c
@@ -34,6 +34,7 @@
 #include 
 #include 
 #include 
+#include 


 #include 
@@ -55,6 +56,30 @@
return 0;
 }
 
+/* Find a route (PHY instance) for a given Downlink burst request */
+static struct phy_instance *dlfh_route_br(const struct gsm_bts_trx_ts *ts,
+ const struct trx_dl_burst_req *br)
+{
+   const struct gsm_bts_trx *trx;
+   struct gsm_time time;
+   uint16_t arfcn;
+
+   gsm_fn2gsmtime(, br->fn);
+
+   /* TODO: implement a "cache", so we could avoid frequent lookups */
+   arfcn = gsm0502_hop_seq_gen(, ts->hopping.hsn, ts->hopping.maio,
+   ts->hopping.ma_len, ts->hopping.ma);
+   llist_for_each_entry(trx, >trx->bts->trx_list, list) {
+   if (trx->arfcn == arfcn)
+   return trx->role_bts.l1h;
+   }
+
+   LOGP(DL1C, LOGL_FATAL, "Failed to resolve TDMA fn=%u "
+  "(hsn=%u, maio=%u, ma_len=%u)\n",
+br->fn, ts->hopping.hsn, ts->hopping.maio, ts->hopping.ma_len);
+   return ts->trx->role_bts.l1h; /* fall-back to the current trx */
+}
+
 /* schedule all frames of all TRX for given FN */
 static void trx_sched_fn(struct gsm_bts *bts, const uint32_t fn)
 {
@@ -100,8 +125,14 @@
continue;
}

+   /* resolve PHY instance if freq. hopping is enabled */
+   if (trx->ts[tn].hopping.enabled) {
+   pinst = dlfh_route_br(>ts[tn], );
+   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, );
@@ -127,6 +158,50 @@
}
 }

+/* Find a route (TRX instance) for a given Uplink burst indication */
+static struct gsm_bts_trx *ulfh_route_bi(const struct gsm_bts_trx *src_trx,
+const struct trx_ul_burst_ind *bi)
+{
+   struct gsm_bts_trx *trx;
+   struct gsm_time time;
+   uint16_t arfcn;
+
+   gsm_fn2gsmtime(, bi->fn);
+
+   /* TODO: implement a "cache", so we could avoid frequent lookups */
+   llist_for_each_entry(trx, _trx->bts->trx_list, list) {
+   const struct gsm_bts_trx_ts *ts = >ts[bi->tn];
+   if (!ts->hopping.enabled)
+   continue;
+
+   arfcn = gsm0502_hop_seq_gen(, ts->hopping.hsn, 
ts->hopping.maio,
+   ts->hopping.ma_len, ts->hopping.ma);
+   if (src_trx->arfcn == arfcn)
+   return trx;
+   }
+
+   LOGP(DL1C, LOGL_FATAL, "Failed to find transceiver for an Uplink burst 
fn=%u\n", bi->fn);
+   return (struct gsm_bts_trx *) src_trx; /* fall-back to the originating 
trx */
+}
+
+/* Route a given Uplink burst indication to the scheduler depending on freq. 
hopping state */
+int trx_sched_route_burst_ind(struct l1sched_trx *l1t, struct trx_ul_burst_ind 
*bi)
+{
+   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(l1t->trx, bi);
+   pinst = trx_phy_instance(trx);
+   l1h = pinst->u.osmotrx.hdl;
+
+   return trx_sched_ul_burst(>l1s, bi);
+}
+
 /*! maximum number of 'missed' frame periods we can tolerate of OS doesn't 
schedule us*/
 #define MAX_FN_SKEW