fixeria has submitted this change. ( https://gerrit.osmocom.org/c/osmo-bts/+/27557 )
Change subject: osmo-bts-trx: rx_{tchh,tchf}_fn(): use AMR CMI lookup tables
......................................................................
osmo-bts-trx: rx_{tchh,tchf}_fn(): use AMR CMI lookup tables
3GPP TS 45.009 defines that Codec Mode Indications shall be sent
with speech frames having specific TDMA frame numbers of their
*first* bursts, which are defined in tables 3.2.1.3-{1,2,3,4}.
Performance-wise it's batter to have these tables implemented as
arrays, rather then using the 'switch' statement. We can simplify
things even further and have TDMA frame numbers corresponding to
the *last* bursts in them. This eliminates the need of doing an
additional last-to-first mapping, so that bi->fn can be used.
Change-Id: I46def864729c8f9063af201750456771ea5558d5
---
M src/osmo-bts-trx/sched_lchan_tchf.c
M src/osmo-bts-trx/sched_lchan_tchh.c
M src/osmo-bts-trx/sched_utils.h
3 files changed, 20 insertions(+), 12 deletions(-)
Approvals:
laforge: Looks good to me, but someone else must approve
fixeria: Looks good to me, approved
osmith: Looks good to me, but someone else must approve
Jenkins Builder: Verified
diff --git a/src/osmo-bts-trx/sched_lchan_tchf.c b/src/osmo-bts-trx/sched_lchan_tchf.c
index c8ad383..6a9a0f0 100644
--- a/src/osmo-bts-trx/sched_lchan_tchf.c
+++ b/src/osmo-bts-trx/sched_lchan_tchf.c
@@ -131,8 +131,7 @@
* the first FN 4,13,21 defines that CMR is included in frame.
* NOTE: A frame ends 7 FN after start.
*/
- fn_begin = trx_sched_lookup_fn(chan_state, 8);
- amr_is_cmr = !ul_amr_fn_is_cmi(fn_begin);
+ amr_is_cmr = !sched_tchf_ul_amr_cmi_map[bi->fn % 26];
/* The AFS_ONSET frame itself does not result into an RTP frame
* since it only contains a recognition pattern that marks the
diff --git a/src/osmo-bts-trx/sched_lchan_tchh.c b/src/osmo-bts-trx/sched_lchan_tchh.c
index 1778d36..369e35b 100644
--- a/src/osmo-bts-trx/sched_lchan_tchh.c
+++ b/src/osmo-bts-trx/sched_lchan_tchh.c
@@ -165,16 +165,7 @@
break;
}
- /* Calculate the frame number where the block begins. Note that
- * we need to traverse the measurement histort back by 6 bursts,
- * not by 4 bursts. The reason for this is that the burst shift
- * buffer we use for decoding is 6 bursts wide (one SACCH block) but
- * TCH/H blocks are only 4 bursts wide. The decoder functions look
- * at the beginning of the buffer while we shift into it at the end,
- * this means that TCH/H blocks always decoded delayed by two frame
- * number positions late. */
- fn_begin = trx_sched_lookup_fn(chan_state, 6);
- fn_is_cmi = ul_amr_fn_is_cmi(fn_begin);
+ fn_is_cmi = sched_tchh_ul_amr_cmi_map[bi->fn % 26];
/* See comment in function rx_tchf_fn() */
amr = 2;
diff --git a/src/osmo-bts-trx/sched_utils.h b/src/osmo-bts-trx/sched_utils.h
index f76e49b..398083d 100644
--- a/src/osmo-bts-trx/sched_utils.h
+++ b/src/osmo-bts-trx/sched_utils.h
@@ -37,6 +37,24 @@
return 10000 * n_errors / n_bits_total;
}
+/* 3GPP TS 45.009, table 3.2.1.3-{1,3}: AMR on Uplink TCH/F */
+static const uint8_t sched_tchf_ul_amr_cmi_map[26] = {
+ [7] = 1, /* TCH/F: first=0 / last=7 */
+ [16] = 1, /* TCH/F: first=8 / last=16 */
+ [24] = 1, /* TCH/F: first=17 / last=24 */
+};
+
+/* 3GPP TS 45.009, table 3.2.1.3-{2,4}: AMR on Uplink TCH/H */
+static const uint8_t sched_tchh_ul_amr_cmi_map[26] = {
+ [6] = 1, /* TCH/H(0): first=0 / last=6 */
+ [15] = 1, /* TCH/H(0): first=8 / last=15 */
+ [23] = 1, /* TCH/H(0): first=17 / last=23 */
+
+ [7] = 1, /* TCH/H(1): first=1 / last=7 */
+ [16] = 1, /* TCH/H(1): first=9 / last=16 */
+ [24] = 1, /* TCH/H(1): first=18 / last=24 */
+};
+
/*! determine whether an uplink AMR block is CMI according to 3GPP TS 45.009.
* \param[in] fn_begin frame number of the beginning of the block.
* \returns true in case of CMI; false otherwise. */
--
To view, visit https://gerrit.osmocom.org/c/osmo-bts/+/27557
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-Change-Id: I46def864729c8f9063af201750456771ea5558d5
Gerrit-Change-Number: 27557
Gerrit-PatchSet: 2
Gerrit-Owner: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-Reviewer: osmith <osmith(a)sysmocom.de>
Gerrit-MessageType: merged
fixeria has submitted this change. ( https://gerrit.osmocom.org/c/osmo-bts/+/27555 )
Change subject: osmo-bts-trx: rx_{tchf,tchh}_fn(): ensure complete set of bursts
......................................................................
osmo-bts-trx: rx_{tchf,tchh}_fn(): ensure complete set of bursts
The idea of this change is to avoid attempting to decode the burst
buffer unless it's filled up completely. This eliminates expected
decoding errors in the beginning of lchan's lifetime. Moreover
this allows us to be sure that the measurement history is complete,
so that we can abuse it to store TDMA frame numbers later.
Note that even in the absence of NOPE indications (TRXDv0 case)
we can still be sure that the burst mask has no gaps due to lost
bursts, because they are compensated by trx_sched_calc_frame_loss().
Change-Id: I56bebe1374eb803e3c1e9f08dda4da50a074ab0b
---
M src/osmo-bts-trx/sched_lchan_tchf.c
M src/osmo-bts-trx/sched_lchan_tchh.c
2 files changed, 14 insertions(+), 14 deletions(-)
Approvals:
laforge: Looks good to me, but someone else must approve
fixeria: Looks good to me, approved
osmith: Looks good to me, but someone else must approve
Jenkins Builder: Verified
diff --git a/src/osmo-bts-trx/sched_lchan_tchf.c b/src/osmo-bts-trx/sched_lchan_tchf.c
index a689a1f..9a168af 100644
--- a/src/osmo-bts-trx/sched_lchan_tchf.c
+++ b/src/osmo-bts-trx/sched_lchan_tchf.c
@@ -85,7 +85,7 @@
if (bi->bid == 0) {
memcpy(*bursts_p, *bursts_p + 464, 464);
memset(*bursts_p + 464, 0, 464);
- *mask = 0x0;
+ *mask = *mask << 4;
}
/* update mask */
@@ -106,13 +106,13 @@
if (bi->bid != 3)
return 0;
- /* check for complete set of bursts */
- if ((*mask & 0xf) != 0xf) {
- LOGL1SB(DL1P, LOGL_NOTICE, l1ts, bi,
- "Received incomplete frame (%u/%u)\n",
- bi->fn % l1ts->mf_period, l1ts->mf_period);
+ /* fill up the burst buffer so that we have 8 bursts in there */
+ if (OSMO_UNLIKELY((*mask & 0xff) != 0xff)) {
+ LOGL1SB(DL1P, LOGL_DEBUG, l1ts, bi,
+ "UL burst buffer is not filled up: mask=0x%02x != 0xff\n",
+ *mask);
+ return 0; /* TODO: send BFI */
}
- *mask = 0x0;
/* decode
* also shift buffer by 4 bursts for interleaving */
diff --git a/src/osmo-bts-trx/sched_lchan_tchh.c b/src/osmo-bts-trx/sched_lchan_tchh.c
index 6b49974..627291e 100644
--- a/src/osmo-bts-trx/sched_lchan_tchh.c
+++ b/src/osmo-bts-trx/sched_lchan_tchh.c
@@ -92,7 +92,7 @@
memcpy(*bursts_p, *bursts_p + 232, 232);
memcpy(*bursts_p + 232, *bursts_p + 464, 232);
memset(*bursts_p + 464, 0, 232);
- *mask = 0x0;
+ *mask = *mask << 2;
}
/* update mask */
@@ -113,13 +113,13 @@
if (bi->bid != 1)
return 0;
- /* check for complete set of bursts */
- if ((*mask & 0x3) != 0x3) {
- LOGL1SB(DL1P, LOGL_NOTICE, l1ts, bi,
- "Received incomplete frame (%u/%u)\n",
- bi->fn % l1ts->mf_period, l1ts->mf_period);
+ /* fill up the burst buffer so that we have 6 bursts in there */
+ if (OSMO_UNLIKELY((*mask & 0x3f) != 0x3f)) {
+ LOGL1SB(DL1P, LOGL_DEBUG, l1ts, bi,
+ "UL burst buffer is not filled up: mask=0x%02x != 0x3f\n",
+ *mask);
+ return 0; /* TODO: send BFI */
}
- *mask = 0x0;
/* skip decoding of the last 4 bursts of FACCH/H */
if (chan_state->ul_ongoing_facch) {
--
To view, visit https://gerrit.osmocom.org/c/osmo-bts/+/27555
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-Change-Id: I56bebe1374eb803e3c1e9f08dda4da50a074ab0b
Gerrit-Change-Number: 27555
Gerrit-PatchSet: 2
Gerrit-Owner: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: dexter <pmaier(a)sysmocom.de>
Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-Reviewer: osmith <osmith(a)sysmocom.de>
Gerrit-Reviewer: pespin <pespin(a)sysmocom.de>
Gerrit-MessageType: merged
fixeria has submitted this change. ( https://gerrit.osmocom.org/c/osmo-bts/+/27556 )
Change subject: osmo-bts-trx: rx_{tchf,tchh}_fn(): get TDMA FN from meas history
......................................................................
osmo-bts-trx: rx_{tchf,tchh}_fn(): get TDMA FN from meas history
Once we have an Uplink speech or FACCH frame decoded, we need to
hand it over to the upper layers indicating TDMA frame number of
the *first* burst corresponding to the beginning of a block.
Currently we use libosmogsm's gsm0502_fn_remap() API to calculate
the first TDMA frame number from the given last frame number.
This API involves iterating over the pre-calculated offset tables
for different channel and payload types, and thus imposes some
additional CPU cycles. Another downside of the current approach
is that we have to perform such lookups several times for each
decoded L2 frame, e.g. for FACCH on TCH/AHS we do it three times!
In this patch I propose an alternative approach of storing TDMA
frame numbers in the measurement history, together with the
associated samples. This way we can easily get N-th frame number
from there without performing any additional computations, other
than what we already do during the measurement processing.
Change-Id: Id9a2b7b0f1a1ad7cfbbab862faf521e135c90605
---
M include/osmo-bts/scheduler.h
M src/osmo-bts-trx/sched_lchan_tchf.c
M src/osmo-bts-trx/sched_lchan_tchh.c
M src/osmo-bts-trx/scheduler_trx.c
4 files changed, 38 insertions(+), 36 deletions(-)
Approvals:
laforge: Looks good to me, but someone else must approve
fixeria: Looks good to me, approved
osmith: Looks good to me, but someone else must approve
Jenkins Builder: Verified
diff --git a/include/osmo-bts/scheduler.h b/include/osmo-bts/scheduler.h
index f671874..e39315f 100644
--- a/include/osmo-bts/scheduler.h
+++ b/include/osmo-bts/scheduler.h
@@ -80,6 +80,7 @@
/* A set of measurements belonging to one Uplink burst */
struct l1sched_meas_set {
+ uint32_t fn; /* TDMA frame number */
int16_t toa256; /* Timing of Arrival (1/256 of a symbol) */
int16_t ci_cb; /* Carrier-to-Interference (cB) */
float rssi; /* RSSI (dBm) */
@@ -325,3 +326,5 @@
void trx_sched_meas_avg(const struct l1sched_chan_state *chan_state,
struct l1sched_meas_set *avg,
enum sched_meas_avg_mode mode);
+uint32_t trx_sched_lookup_fn(const struct l1sched_chan_state *chan_state,
+ const unsigned int shift);
diff --git a/src/osmo-bts-trx/sched_lchan_tchf.c b/src/osmo-bts-trx/sched_lchan_tchf.c
index 9a168af..c8ad383 100644
--- a/src/osmo-bts-trx/sched_lchan_tchf.c
+++ b/src/osmo-bts-trx/sched_lchan_tchf.c
@@ -131,7 +131,7 @@
* the first FN 4,13,21 defines that CMR is included in frame.
* NOTE: A frame ends 7 FN after start.
*/
- fn_begin = gsm0502_fn_remap(bi->fn, FN_REMAP_TCH_F);
+ fn_begin = trx_sched_lookup_fn(chan_state, 8);
amr_is_cmr = !ul_amr_fn_is_cmi(fn_begin);
/* The AFS_ONSET frame itself does not result into an RTP frame
@@ -209,6 +209,8 @@
/* average measurements of the last N (depends on mode) bursts */
trx_sched_meas_avg(chan_state, &meas_avg, meas_avg_mode);
+ /* meas_avg.fn now contains TDMA frame number of the first burst */
+ fn_begin = meas_avg.fn;
/* Check if the frame is bad */
if (rc < 0) {
@@ -231,7 +233,6 @@
/* FACCH */
if (rc == GSM_MACBLOCK_LEN) {
- fn_begin = gsm0502_fn_remap(bi->fn, FN_REMAP_FACCH_F);
_sched_compose_ph_data_ind(l1ts, fn_begin, bi->chan,
tch_data + amr, GSM_MACBLOCK_LEN,
meas_avg.rssi, meas_avg.toa256,
@@ -300,7 +301,6 @@
/* TCH or BFI */
compose_l1sap:
- fn_begin = gsm0502_fn_remap(bi->fn, FN_REMAP_TCH_F);
return _sched_compose_tch_ind(l1ts, fn_begin, bi->chan, tch_data, rc,
meas_avg.toa256, ber10k, meas_avg.rssi,
meas_avg.ci_cb, is_sub);
diff --git a/src/osmo-bts-trx/sched_lchan_tchh.c b/src/osmo-bts-trx/sched_lchan_tchh.c
index 627291e..1778d36 100644
--- a/src/osmo-bts-trx/sched_lchan_tchh.c
+++ b/src/osmo-bts-trx/sched_lchan_tchh.c
@@ -67,7 +67,6 @@
enum sched_meas_avg_mode meas_avg_mode = SCHED_MEAS_AVG_M_S6N4;
struct l1sched_meas_set meas_avg;
unsigned int fn_begin;
- unsigned int fn_tch_end;
uint16_t ber10k = 0;
uint8_t is_sub = 0;
uint8_t ft;
@@ -127,6 +126,8 @@
/* we have already sent the first BFI when a FACCH/H frame
* was decoded (see below), now send the second one. */
trx_sched_meas_avg(chan_state, &meas_avg, meas_avg_mode);
+ /* meas_avg.fn now contains TDMA frame number of the first burst */
+ fn_begin = meas_avg.fn;
goto bfi;
}
@@ -164,15 +165,15 @@
break;
}
- /* Calculate the frame number where the block begins */
- if (bi->fn % 13 < 4)
- fn_tch_end = GSM_TDMA_FN_SUB(bi->fn, 5);
- else
- fn_tch_end = GSM_TDMA_FN_SUB(bi->fn, 4);
- if (lchan->nr == 0)
- fn_begin = gsm0502_fn_remap(fn_tch_end, FN_REMAP_TCH_H0);
- else
- fn_begin = gsm0502_fn_remap(fn_tch_end, FN_REMAP_TCH_H1);
+ /* Calculate the frame number where the block begins. Note that
+ * we need to traverse the measurement histort back by 6 bursts,
+ * not by 4 bursts. The reason for this is that the burst shift
+ * buffer we use for decoding is 6 bursts wide (one SACCH block) but
+ * TCH/H blocks are only 4 bursts wide. The decoder functions look
+ * at the beginning of the buffer while we shift into it at the end,
+ * this means that TCH/H blocks always decoded delayed by two frame
+ * number positions late. */
+ fn_begin = trx_sched_lookup_fn(chan_state, 6);
fn_is_cmi = ul_amr_fn_is_cmi(fn_begin);
/* See comment in function rx_tchf_fn() */
@@ -243,6 +244,8 @@
/* average measurements of the last N (depends on mode) bursts */
trx_sched_meas_avg(chan_state, &meas_avg, meas_avg_mode);
+ /* meas_avg.fn now contains TDMA frame number of the first burst */
+ fn_begin = meas_avg.fn;
/* Check if the frame is bad */
if (rc < 0) {
@@ -265,10 +268,6 @@
/* FACCH */
if (rc == GSM_MACBLOCK_LEN) {
chan_state->ul_ongoing_facch = 1;
- if (lchan->nr == 0)
- fn_begin = gsm0502_fn_remap(bi->fn, FN_REMAP_FACCH_H0);
- else
- fn_begin = gsm0502_fn_remap(bi->fn, FN_REMAP_FACCH_H1);
/* In order to provide an even stream of measurement reports, here we
* intentionally invalidate RSSI, so that this report gets dropped in
* process_l1sap_meas_data(). The averaged results will still be sent
@@ -329,25 +328,6 @@
compose_l1sap:
/* TCH or BFI */
-
- /* The input to gsm0502_fn_remap() needs to get the frame number we
- * got two bursts ago. The reason for this is that the burst shift
- * buffer we use for decoding is 6 bursts wide (one SACCH block) but
- * TCH/H blocks are only 4 bursts wide. The decoder functions look
- * at the beginning of the buffer while we shift into it at the end,
- * this means that TCH/H blocks always decode delayed by two frame
- * number positions late. To calculatue the ending frame number of
- * the TCH/H we need to subtract 4 or 5 frames if there was a SACCH
- * in between. (Note: this is TCH/H, 4 frames ==> 2 bursts) */
- if (bi->fn % 13 < 4)
- fn_tch_end = GSM_TDMA_FN_SUB(bi->fn, 5);
- else
- fn_tch_end = GSM_TDMA_FN_SUB(bi->fn, 4);
- if (lchan->nr == 0)
- fn_begin = gsm0502_fn_remap(fn_tch_end, FN_REMAP_TCH_H0);
- else
- fn_begin = gsm0502_fn_remap(fn_tch_end, FN_REMAP_TCH_H1);
-
return _sched_compose_tch_ind(l1ts, fn_begin, bi->chan, tch_data, rc,
meas_avg.toa256, ber10k, meas_avg.rssi,
meas_avg.ci_cb, is_sub);
diff --git a/src/osmo-bts-trx/scheduler_trx.c b/src/osmo-bts-trx/scheduler_trx.c
index 6ce5a9a..d772620 100644
--- a/src/osmo-bts-trx/scheduler_trx.c
+++ b/src/osmo-bts-trx/scheduler_trx.c
@@ -623,6 +623,7 @@
unsigned int current = chan_state->meas.current;
chan_state->meas.buf[current] = (struct l1sched_meas_set) {
+ .fn = bi->fn,
.ci_cb = (bi->flags & TRX_BI_F_CI_CB) ? bi->ci_cb : 0,
.toa256 = bi->toa256,
.rssi = bi->rssi,
@@ -669,8 +670,13 @@
ci_cb_sum += set->ci_cb;
}
+ /* First sample contains TDMA frame number of the first burst */
+ pos = (current + hist_size - shift) % hist_size;
+ set = &chan_state->meas.buf[pos];
+
/* Calculate the average for each value */
*avg = (struct l1sched_meas_set) {
+ .fn = set->fn, /* first burst */
.rssi = (rssi_sum / num),
.toa256 = (toa256_sum / num),
.ci_cb = (ci_cb_sum / num),
@@ -682,3 +688,16 @@
chan_state->lchan ? " " : "",
num, shift, avg->rssi, avg->toa256, avg->ci_cb);
}
+
+/* Lookup TDMA frame number of the N-th sample in the history */
+uint32_t trx_sched_lookup_fn(const struct l1sched_chan_state *chan_state,
+ const unsigned int shift)
+{
+ const unsigned int hist_size = ARRAY_SIZE(chan_state->meas.buf);
+ const unsigned int current = chan_state->meas.current;
+ unsigned int pos;
+
+ /* First sample contains TDMA frame number of the first burst */
+ pos = (current + hist_size - shift) % hist_size;
+ return chan_state->meas.buf[pos].fn;
+}
--
To view, visit https://gerrit.osmocom.org/c/osmo-bts/+/27556
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-Change-Id: Id9a2b7b0f1a1ad7cfbbab862faf521e135c90605
Gerrit-Change-Number: 27556
Gerrit-PatchSet: 2
Gerrit-Owner: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: dexter <pmaier(a)sysmocom.de>
Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-Reviewer: osmith <osmith(a)sysmocom.de>
Gerrit-MessageType: merged
fixeria has submitted this change. ( https://gerrit.osmocom.org/c/osmo-bts/+/27554 )
Change subject: osmo-bts-trx: rx_{tchf,tchh}_fn(): shift Rx burst buffer on bid=0
......................................................................
osmo-bts-trx: rx_{tchf,tchh}_fn(): shift Rx burst buffer on bid=0
For both TCH/F and TCH/H, the receive burst buffer needs to be
periodically shifted leftwards due to the nature of block-diagonal
interleaving. Currently we do this on receipt of bid=3 for TCH/F
and bid=1 for TCH/H, right after attempting to decode the buffer.
If for some reason we return early before attempting to decode the
buffer, the content of that buffer might not be shifted and some
bursts might be overwritten. This can be easily avoided by doing
the shifting on receipt of bid=0 for both TCH/H and TCH/F.
Change-Id: I0bd69f5a8f5c665fb5f00c127bc3fe1d91167abb
---
M src/osmo-bts-trx/sched_lchan_tchf.c
M src/osmo-bts-trx/sched_lchan_tchh.c
2 files changed, 6 insertions(+), 7 deletions(-)
Approvals:
laforge: Looks good to me, but someone else must approve
fixeria: Looks good to me, approved
osmith: Looks good to me, but someone else must approve
Jenkins Builder: Verified
diff --git a/src/osmo-bts-trx/sched_lchan_tchf.c b/src/osmo-bts-trx/sched_lchan_tchf.c
index c6c5532..a689a1f 100644
--- a/src/osmo-bts-trx/sched_lchan_tchf.c
+++ b/src/osmo-bts-trx/sched_lchan_tchf.c
@@ -81,8 +81,9 @@
return -ENOMEM;
}
- /* clear burst */
+ /* shift the buffer by 4 bursts leftwards */
if (bi->bid == 0) {
+ memcpy(*bursts_p, *bursts_p + 464, 464);
memset(*bursts_p + 464, 0, 464);
*mask = 0x0;
}
@@ -205,7 +206,6 @@
tch_mode);
return -EINVAL;
}
- memcpy(*bursts_p, *bursts_p + 464, 464);
/* average measurements of the last N (depends on mode) bursts */
trx_sched_meas_avg(chan_state, &meas_avg, meas_avg_mode);
diff --git a/src/osmo-bts-trx/sched_lchan_tchh.c b/src/osmo-bts-trx/sched_lchan_tchh.c
index 3a66321..6b49974 100644
--- a/src/osmo-bts-trx/sched_lchan_tchh.c
+++ b/src/osmo-bts-trx/sched_lchan_tchh.c
@@ -87,8 +87,10 @@
return -ENOMEM;
}
- /* clear burst */
+ /* shift the buffer by 2 bursts leftwards */
if (bi->bid == 0) {
+ memcpy(*bursts_p, *bursts_p + 232, 232);
+ memcpy(*bursts_p + 232, *bursts_p + 464, 232);
memset(*bursts_p + 464, 0, 232);
*mask = 0x0;
}
@@ -122,8 +124,6 @@
/* skip decoding of the last 4 bursts of FACCH/H */
if (chan_state->ul_ongoing_facch) {
chan_state->ul_ongoing_facch = 0;
- memcpy(*bursts_p, *bursts_p + 232, 232);
- memcpy(*bursts_p + 232, *bursts_p + 464, 232);
/* we have already sent the first BFI when a FACCH/H frame
* was decoded (see below), now send the second one. */
trx_sched_meas_avg(chan_state, &meas_avg, meas_avg_mode);
@@ -238,8 +238,7 @@
tch_mode);
return -EINVAL;
}
- memcpy(*bursts_p, *bursts_p + 232, 232);
- memcpy(*bursts_p + 232, *bursts_p + 464, 232);
+
ber10k = compute_ber10k(n_bits_total, n_errors);
/* average measurements of the last N (depends on mode) bursts */
--
To view, visit https://gerrit.osmocom.org/c/osmo-bts/+/27554
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-Change-Id: I0bd69f5a8f5c665fb5f00c127bc3fe1d91167abb
Gerrit-Change-Number: 27554
Gerrit-PatchSet: 2
Gerrit-Owner: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: dexter <pmaier(a)sysmocom.de>
Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-Reviewer: osmith <osmith(a)sysmocom.de>
Gerrit-Reviewer: pespin <pespin(a)sysmocom.de>
Gerrit-MessageType: merged
fixeria has submitted this change. ( https://gerrit.osmocom.org/c/osmo-bts/+/27552 )
Change subject: osmo-bts-trx: rx_tchh_fn(): get rid of chan_state->meas_avg_facch
......................................................................
osmo-bts-trx: rx_tchh_fn(): get rid of chan_state->meas_avg_facch
FACCH/H takes out two speech frames, so we send two BFIs once we
have received it in rx_tchh_fn(). The upper layers responsible
for handling of the Uplink measurements expect a fixed amount of
measurement samples, so currently we do:
* send a FACCH frame with the associated measurememnts (S6N6),
* send the 1st BFI with invalidated measurements (RSSI=0),
* send the 2nd BFI with the stored measurememnts of FACCH.
This is achieved by preserving a copy of the FACCH measurememnts
in chan_state->meas_avg_facch and then using it two bursts later.
The same goal can be achieved a lot easier by sending the associated
measurements with both BFIs as if no FACCH was received:
* send a FACCH frame with invalidated measurememnts (RSSI=0),
* send the 1st BFI with the associated measurememnts (S6N4),
* send the 2nd BFI with the associated measurememnts (S6N4).
This eliminates the need to store anything outside of the existing
measurement history and simplifies the code a lot. Also, this
eliminates the need for using a dedicated averaging mode S6N6.
Varified by running BTS_Tests.TC_meas_res_speech_tchh_facch.
Change-Id: I7902b4709bc3f418174e8373f52e87bb31cdc826
Related: I1ad9fa3815feb2b4da608ab7df716a87ba1f2f91
---
M include/osmo-bts/scheduler.h
M src/osmo-bts-trx/sched_lchan_tchh.c
2 files changed, 7 insertions(+), 32 deletions(-)
Approvals:
laforge: Looks good to me, but someone else must approve
fixeria: Looks good to me, approved
dexter: Looks good to me, but someone else must approve
osmith: Looks good to me, but someone else must approve
Jenkins Builder: Verified
diff --git a/include/osmo-bts/scheduler.h b/include/osmo-bts/scheduler.h
index 2806117..f671874 100644
--- a/include/osmo-bts/scheduler.h
+++ b/include/osmo-bts/scheduler.h
@@ -125,7 +125,6 @@
/* TCH/H */
uint8_t dl_ongoing_facch; /* FACCH/H on downlink */
uint8_t ul_ongoing_facch; /* FACCH/H on uplink */
- struct l1sched_meas_set meas_avg_facch; /* measurement results for last FACCH */
uint8_t dl_facch_bursts; /* number of remaining DL FACCH bursts */
diff --git a/src/osmo-bts-trx/sched_lchan_tchh.c b/src/osmo-bts-trx/sched_lchan_tchh.c
index 4553132..e97adbd 100644
--- a/src/osmo-bts-trx/sched_lchan_tchh.c
+++ b/src/osmo-bts-trx/sched_lchan_tchh.c
@@ -71,7 +71,6 @@
uint16_t ber10k = 0;
uint8_t is_sub = 0;
uint8_t ft;
- bool mask_stolen_tch_block = false;
bool fn_is_cmi;
/* If handover RACH detection is turned on, treat this burst as an Access Burst.
@@ -127,11 +126,7 @@
memcpy(*bursts_p + 232, *bursts_p + 464, 232);
/* we have already sent the first BFI when a FACCH/H frame
* was decoded (see below), now send the second one. */
- memset(&meas_avg, 0, sizeof(meas_avg));
- /* In order to provide an even stream of measurement reports
- * we ask the code below to mask the missing TCH/H block
- * measurement report with the FACCH measurement results. */
- mask_stolen_tch_block = true;
+ trx_sched_meas_avg(chan_state, &meas_avg, meas_avg_mode);
goto bfi;
}
@@ -248,8 +243,6 @@
ber10k = compute_ber10k(n_bits_total, n_errors);
/* average measurements of the last N (depends on mode) bursts */
- if (rc == GSM_MACBLOCK_LEN)
- meas_avg_mode = SCHED_MEAS_AVG_M_S6N6;
trx_sched_meas_avg(chan_state, &meas_avg, meas_avg_mode);
/* Check if the frame is bad */
@@ -277,22 +270,15 @@
fn_begin = gsm0502_fn_remap(bi->fn, FN_REMAP_FACCH_H0);
else
fn_begin = gsm0502_fn_remap(bi->fn, FN_REMAP_FACCH_H1);
+ /* In order to provide an even stream of measurement reports, here we
+ * intentionally invalidate RSSI, so that this report gets dropped in
+ * process_l1sap_meas_data(). The averaged results will still be sent
+ * with the first BFI (see below). */
_sched_compose_ph_data_ind(l1ts, fn_begin, bi->chan,
tch_data + amr, GSM_MACBLOCK_LEN,
- meas_avg.rssi, meas_avg.toa256,
- meas_avg.ci_cb, ber10k,
+ 0, /* intentionally invalidate RSSI */
+ meas_avg.toa256, meas_avg.ci_cb, ber10k,
PRES_INFO_UNKNOWN);
-
- /* Keep a copy of the measurement results of the last FACCH
- * transmission in order to be able to create a replacement
- * measurement result for the one missing TCH block
- * measurement */
- memcpy(&chan_state->meas_avg_facch, &meas_avg, sizeof(meas_avg));
-
- /* Invalidate the current measurement result to prevent the
- * code below from handing up the current measurement a second
- * time. */
- memset(&meas_avg, 0, sizeof(meas_avg));
ber10k = 0;
bfi:
/* A FACCH/H frame replaces two speech frames, so we need to send two BFIs.
@@ -363,16 +349,6 @@
else
fn_begin = gsm0502_fn_remap(fn_tch_end, FN_REMAP_TCH_H1);
- /* A FACCH/H transmission takes out two TCH/H voice blocks and the
- * related measurement results. The first measurement result is handed
- * up directly with the FACCH (see above), the second one needs to be
- * compensated by filling the gap with the measurement result we got
- * from the FACCH transmission. */
- if (mask_stolen_tch_block) {
- memcpy(&meas_avg, &chan_state->meas_avg_facch, sizeof(meas_avg));
- memset(&chan_state->meas_avg_facch, 0, sizeof(meas_avg));
- }
-
return _sched_compose_tch_ind(l1ts, fn_begin, bi->chan, tch_data, rc,
/* FIXME: what should we use for BFI here? */
bfi_flag ? bi->toa256 : meas_avg.toa256, ber10k,
--
To view, visit https://gerrit.osmocom.org/c/osmo-bts/+/27552
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-Change-Id: I7902b4709bc3f418174e8373f52e87bb31cdc826
Gerrit-Change-Number: 27552
Gerrit-PatchSet: 2
Gerrit-Owner: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: dexter <pmaier(a)sysmocom.de>
Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-Reviewer: osmith <osmith(a)sysmocom.de>
Gerrit-Reviewer: pespin <pespin(a)sysmocom.de>
Gerrit-MessageType: merged
fixeria has submitted this change. ( https://gerrit.osmocom.org/c/osmo-bts/+/27553 )
Change subject: osmo-bts-trx: rx_{tchf,tchh}_fn(): also use meas_avg for BFI
......................................................................
osmo-bts-trx: rx_{tchf,tchh}_fn(): also use meas_avg for BFI
In the current implementation of both TCH/F and TCH/H lchans, we
set the 'bfi_flag' to true only if decoding fails. Perhaps this
was not the case when I wrote [1], so using meas_avg might result
in using uninitialized memory. This is not the case anymore.
Pass the *averaged* measurememnts regardless of decoding result.
Change-Id: I23f767364a018d30d04885990adf69b50b2c9738
Related: [1] I2b02b51fea5664f161382a4ddc63dbf14ffc9ac5
---
M src/osmo-bts-trx/sched_lchan_tchf.c
M src/osmo-bts-trx/sched_lchan_tchh.c
2 files changed, 4 insertions(+), 10 deletions(-)
Approvals:
laforge: Looks good to me, but someone else must approve
fixeria: Looks good to me, approved
osmith: Looks good to me, but someone else must approve
Jenkins Builder: Verified
diff --git a/src/osmo-bts-trx/sched_lchan_tchf.c b/src/osmo-bts-trx/sched_lchan_tchf.c
index 0388ec0..c6c5532 100644
--- a/src/osmo-bts-trx/sched_lchan_tchf.c
+++ b/src/osmo-bts-trx/sched_lchan_tchf.c
@@ -302,11 +302,8 @@
compose_l1sap:
fn_begin = gsm0502_fn_remap(bi->fn, FN_REMAP_TCH_F);
return _sched_compose_tch_ind(l1ts, fn_begin, bi->chan, tch_data, rc,
- /* FIXME: what should we use for BFI here? */
- bfi_flag ? bi->toa256 : meas_avg.toa256, ber10k,
- bfi_flag ? bi->rssi : meas_avg.rssi,
- bfi_flag ? bi->ci_cb : meas_avg.ci_cb,
- is_sub);
+ meas_avg.toa256, ber10k, meas_avg.rssi,
+ meas_avg.ci_cb, is_sub);
}
/* common section for generation of TCH bursts (TCH/H and TCH/F).
diff --git a/src/osmo-bts-trx/sched_lchan_tchh.c b/src/osmo-bts-trx/sched_lchan_tchh.c
index e97adbd..3a66321 100644
--- a/src/osmo-bts-trx/sched_lchan_tchh.c
+++ b/src/osmo-bts-trx/sched_lchan_tchh.c
@@ -350,11 +350,8 @@
fn_begin = gsm0502_fn_remap(fn_tch_end, FN_REMAP_TCH_H1);
return _sched_compose_tch_ind(l1ts, fn_begin, bi->chan, tch_data, rc,
- /* FIXME: what should we use for BFI here? */
- bfi_flag ? bi->toa256 : meas_avg.toa256, ber10k,
- bfi_flag ? bi->rssi : meas_avg.rssi,
- bfi_flag ? bi->ci_cb : meas_avg.ci_cb,
- is_sub);
+ meas_avg.toa256, ber10k, meas_avg.rssi,
+ meas_avg.ci_cb, is_sub);
}
/* common section for generation of TCH bursts (TCH/H and TCH/F).
--
To view, visit https://gerrit.osmocom.org/c/osmo-bts/+/27553
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-Change-Id: I23f767364a018d30d04885990adf69b50b2c9738
Gerrit-Change-Number: 27553
Gerrit-PatchSet: 2
Gerrit-Owner: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: dexter <pmaier(a)sysmocom.de>
Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-Reviewer: osmith <osmith(a)sysmocom.de>
Gerrit-Reviewer: pespin <pespin(a)sysmocom.de>
Gerrit-MessageType: merged
fixeria has submitted this change. ( https://gerrit.osmocom.org/c/osmo-bts/+/27551 )
Change subject: osmo-bts-trx: rx_tchh_fn(): indicate BER10k=0 for FACCH BFIs
......................................................................
osmo-bts-trx: rx_tchh_fn(): indicate BER10k=0 for FACCH BFIs
It makes no sense to store BER10k value of an Uplink FACCH frame
in order to indicate it in a BFI later on. Given that these BFIs
are generated artificially, it's fine to indicate BER10k=0.
Change-Id: I24d12892760dca0ad0a5c2abca9fc66523d9e614
Related: I1ad9fa3815feb2b4da608ab7df716a87ba1f2f91
---
M include/osmo-bts/scheduler.h
M src/osmo-bts-trx/sched_lchan_tchh.c
2 files changed, 2 insertions(+), 6 deletions(-)
Approvals:
laforge: Looks good to me, but someone else must approve
fixeria: Looks good to me, approved
osmith: Looks good to me, but someone else must approve
Jenkins Builder: Verified
diff --git a/include/osmo-bts/scheduler.h b/include/osmo-bts/scheduler.h
index 1e1a2d7..2806117 100644
--- a/include/osmo-bts/scheduler.h
+++ b/include/osmo-bts/scheduler.h
@@ -126,7 +126,6 @@
uint8_t dl_ongoing_facch; /* FACCH/H on downlink */
uint8_t ul_ongoing_facch; /* FACCH/H on uplink */
struct l1sched_meas_set meas_avg_facch; /* measurement results for last FACCH */
- uint16_t ber10k_facch; /* bit error rate for last FACCH */
uint8_t dl_facch_bursts; /* number of remaining DL FACCH bursts */
diff --git a/src/osmo-bts-trx/sched_lchan_tchh.c b/src/osmo-bts-trx/sched_lchan_tchh.c
index edbb566..4553132 100644
--- a/src/osmo-bts-trx/sched_lchan_tchh.c
+++ b/src/osmo-bts-trx/sched_lchan_tchh.c
@@ -68,7 +68,7 @@
struct l1sched_meas_set meas_avg;
unsigned int fn_begin;
unsigned int fn_tch_end;
- uint16_t ber10k;
+ uint16_t ber10k = 0;
uint8_t is_sub = 0;
uint8_t ft;
bool mask_stolen_tch_block = false;
@@ -127,7 +127,6 @@
memcpy(*bursts_p + 232, *bursts_p + 464, 232);
/* we have already sent the first BFI when a FACCH/H frame
* was decoded (see below), now send the second one. */
- ber10k = 0;
memset(&meas_avg, 0, sizeof(meas_avg));
/* In order to provide an even stream of measurement reports
* we ask the code below to mask the missing TCH/H block
@@ -289,12 +288,12 @@
* measurement result for the one missing TCH block
* measurement */
memcpy(&chan_state->meas_avg_facch, &meas_avg, sizeof(meas_avg));
- chan_state->ber10k_facch = ber10k;
/* Invalidate the current measurement result to prevent the
* code below from handing up the current measurement a second
* time. */
memset(&meas_avg, 0, sizeof(meas_avg));
+ ber10k = 0;
bfi:
/* A FACCH/H frame replaces two speech frames, so we need to send two BFIs.
* One is sent here, another will be sent two bursts later (see above). */
@@ -371,9 +370,7 @@
* from the FACCH transmission. */
if (mask_stolen_tch_block) {
memcpy(&meas_avg, &chan_state->meas_avg_facch, sizeof(meas_avg));
- ber10k = chan_state->ber10k_facch;
memset(&chan_state->meas_avg_facch, 0, sizeof(meas_avg));
- chan_state->ber10k_facch = 0;
}
return _sched_compose_tch_ind(l1ts, fn_begin, bi->chan, tch_data, rc,
--
To view, visit https://gerrit.osmocom.org/c/osmo-bts/+/27551
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-Change-Id: I24d12892760dca0ad0a5c2abca9fc66523d9e614
Gerrit-Change-Number: 27551
Gerrit-PatchSet: 2
Gerrit-Owner: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: dexter <pmaier(a)sysmocom.de>
Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-Reviewer: osmith <osmith(a)sysmocom.de>
Gerrit-Reviewer: pespin <pespin(a)sysmocom.de>
Gerrit-MessageType: merged