[PATCH] osmo-bts[master]: osmo-bts-trx: add error concealment unit for GSM-FR

2017-12-15 Thread Vadim Yanitskiy
Hello Neels Hofmeyr, Jenkins Builder,

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

https://gerrit.osmocom.org/5214

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

osmo-bts-trx: add error concealment unit for GSM-FR

When a bad voice frame is received, it is replaced by
a silence frame. This may cause unpleasant audio effects.

This change implements a functionality to craft a replacement
frame from the last known good frame using ECU implementation
from libosmocodec. At the moment, only FR is supported.

Depends: libosmocore I06a21f60db01bfe1c2b838f93866fad1d53fdcd1
Change-Id: Iae9e69a9578ae305bca42f834694af96a29084e6
---
M include/osmo-bts/gsm_data_shared.h
M src/osmo-bts-trx/scheduler_trx.c
2 files changed, 20 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-bts refs/changes/14/5214/5

diff --git a/include/osmo-bts/gsm_data_shared.h 
b/include/osmo-bts/gsm_data_shared.h
index a05e4ca..32389e0 100644
--- a/include/osmo-bts/gsm_data_shared.h
+++ b/include/osmo-bts/gsm_data_shared.h
@@ -5,6 +5,7 @@
 #include 
 #include 
 
+#include 
 #include 
 #include 
 #include 
@@ -381,6 +382,9 @@
} ms_power_ctrl;
 
struct msgb *pending_rel_ind_msg;
+
+   /* ECU (Error Correction Unit) state */
+   struct osmo_ecu_state ecu_fr_state;
 #endif
 };
 
diff --git a/src/osmo-bts-trx/scheduler_trx.c b/src/osmo-bts-trx/scheduler_trx.c
index d3928f1..0e9f342 100644
--- a/src/osmo-bts-trx/scheduler_trx.c
+++ b/src/osmo-bts-trx/scheduler_trx.c
@@ -31,6 +31,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -968,6 +969,7 @@
uint8_t tch_data[128]; /* just to be safe */
int rc, amr = 0;
int n_errors, n_bits_total;
+   bool bfi_flag = false;
struct gsm_lchan *lchan =
get_lchan_by_chan_nr(l1t->trx, trx_chan_desc[chan].chan_nr | 
tn);
 
@@ -1058,11 +1060,13 @@
if (rc < 0) {
LOGL1S(DL1P, LOGL_NOTICE, l1t, tn, chan, fn, "Received bad data 
(%u/%u)\n",
fn % l1ts->mf_period, l1ts->mf_period);
+   bfi_flag = true;
goto bfi;
}
if (rc < 4) {
LOGL1S(DL1P, LOGL_NOTICE, l1t, tn, chan, fn, "Received bad data 
(%u/%u) "
"with invalid codec mode %d\n", fn % l1ts->mf_period, 
l1ts->mf_period, rc);
+   bfi_flag = true;
goto bfi;
}
 
@@ -1079,8 +1083,14 @@
case GSM48_CMODE_SPEECH_V1: /* FR */
if (lchan->tch.dtx.ul_sid)
return 0; /* DTXu: pause in progress */
-   memset(tch_data, 0, GSM_FR_BYTES);
-   tch_data[0] = 0xd0;
+
+   /* Perform error correction if possible */
+   rc = osmo_ecu_fr_conceal(&lchan->ecu_fr_state, 
tch_data);
+   if (rc) {
+   memset(tch_data, 0, GSM_FR_BYTES);
+   tch_data[0] = 0xd0;
+   }
+
rc = GSM_FR_BYTES;
break;
case GSM48_CMODE_SPEECH_EFR: /* EFR */
@@ -1108,6 +1118,10 @@
if (rsl_cmode != RSL_CMOD_SPD_SPEECH)
return 0;
 
+   /* Reset ECU with a good frame */
+   if (!bfi_flag && tch_mode == GSM48_CMODE_SPEECH_V1)
+   osmo_ecu_fr_reset(&lchan->ecu_fr_state, tch_data);
+
/* TCH or BFI */
return _sched_compose_tch_ind(l1t, tn, (fn + GSM_HYPERFRAME - 7) % 
GSM_HYPERFRAME, chan,
tch_data, rc);

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

Gerrit-MessageType: newpatchset
Gerrit-Change-Id: Iae9e69a9578ae305bca42f834694af96a29084e6
Gerrit-PatchSet: 5
Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-Owner: dexter 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Neels Hofmeyr 
Gerrit-Reviewer: Vadim Yanitskiy 
Gerrit-Reviewer: dexter 


osmo-bts[master]: osmo-bts-trx: add error concealment unit for GSM-FR

2017-12-15 Thread Vadim Yanitskiy

Patch Set 4:

(1 comment)

Hi @dexter and Harald,

> I have moved at least the bit offsets to libosmocore now.
> See #5385 for that.

Great. Thanks!

> The probelm I see is that since it runs on the BTS it uses
> the RTP bit ordering, but you probably need the GSM bit ordering.

In OsmocomBB I do use the same gsm0503_tch_(fr|hr)_(en|de)code()
like OsmoBTS scheduler does. They all have an undocumented parameter
named 'net_order'. Probably, this is exactly what we are talking about.

> Probably it makes sense if you just take the patch from osmo-bsc and
> add a parameter for the table. If that works for you and the original
> unit-test still passes I could re-test on osmo-bts-trx.

I will try to find this change, thanks for a tip!
Moreover, if you have limited time, I would take care about this change.

> AFAIK OsmocomBB also does the re-ordering to RTP as it uses the MNCC
> interface towards external MNCC handlers, and I think the
> bit-ordering/format of the TCH messages there is identical to RTP.

You probably talking about this?

http://git.osmocom.org/osmocom-bb/tree/src/host/layer23/src/common/l1ctl.c#n802
http://git.osmocom.org/osmocom-bb/tree/src/host/layer23/src/common/l1ctl.c#n856

I think the L1CTL implementation is not the best place for doing
bit reordering, so I've moved this to the firmware in my branch.

https://gerrit.osmocom.org/#/c/5214/4/tests/meas/meas_test.c
File tests/meas/meas_test.c:

Line 10: #include 
Is this file related to the change anyhow?
I think such clean up should be done separately.

And do we really need the 'ecu_fr.h' here?


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

Gerrit-MessageType: comment
Gerrit-Change-Id: Iae9e69a9578ae305bca42f834694af96a29084e6
Gerrit-PatchSet: 4
Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-Owner: dexter 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Neels Hofmeyr 
Gerrit-Reviewer: Vadim Yanitskiy 
Gerrit-Reviewer: dexter 
Gerrit-HasComments: Yes


osmo-bts[master]: osmo-bts-trx: add error concealment unit for GSM-FR

2017-12-15 Thread Harald Welte

Patch Set 4:

> I also wanted to move the code for the ecu, but then I realized
 > that in its
 > current form it would not be so helpful. The probelm I see is that
 > since it
 > runs on the BTS it uses the RTP bit ordering, but you probably need
 > the GSM
 > bit ordering.

AFAIK OsmocomBB also does the re-ordering to RTP as it uses the MNCC interface 
towards external MNCC handlers, and I think the bit-ordering/format of the TCH 
messages there is identical to RTP.

In any case, MNCC is identical on the MS and the MSC side.

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

Gerrit-MessageType: comment
Gerrit-Change-Id: Iae9e69a9578ae305bca42f834694af96a29084e6
Gerrit-PatchSet: 4
Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-Owner: dexter 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Neels Hofmeyr 
Gerrit-Reviewer: Vadim Yanitskiy 
Gerrit-Reviewer: dexter 
Gerrit-HasComments: No


osmo-bts[master]: osmo-bts-trx: add error concealment unit for GSM-FR

2017-12-15 Thread dexter

Patch Set 4:

Hello Vadim,

I have moved at least the bit offsets to libosmocore now. See #5385 for that.

I also wanted to move the code for the ecu, but then I realized that in its
current form it would not be so helpful. The probelm I see is that since it
runs on the BTS it uses the RTP bit ordering, but you probably need the GSM
bit ordering. I am not sure how easy it is to fix this, probably we just
have to add a GSM version of the bit offset table und have it parameterizable
which of the two to use.

Probably it makes sense if you just take the patch from osmo-bsc and add a
parameter for the table. If that works for you and the original unit-test still
passes I could re-test on osmo-bts-trx.

best regards.
Philipp

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

Gerrit-MessageType: comment
Gerrit-Change-Id: Iae9e69a9578ae305bca42f834694af96a29084e6
Gerrit-PatchSet: 4
Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-Owner: dexter 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Neels Hofmeyr 
Gerrit-Reviewer: Vadim Yanitskiy 
Gerrit-Reviewer: dexter 
Gerrit-HasComments: No


[PATCH] osmo-bts[master]: osmo-bts-trx: add error concealment unit for GSM-FR

2017-12-15 Thread dexter
Hello Vadim Yanitskiy, Neels Hofmeyr, Jenkins Builder,

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

https://gerrit.osmocom.org/5214

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

osmo-bts-trx: add error concealment unit for GSM-FR

When a bad GSM-FR voice frame is received, the frame replaced
ith a silence frame. This may cause unpleasant audio effects.

Add a functionality (see ecu_fr.c, ecu_fr_conceal() and
ecu_fr_reset() to craft a replacement frame from the last
known good frame.

Add unit test (ecu_fr_test.c)

Integrate into osmo-bts-trx

Depends: libosmocore I1d0a198af0f8dd1f690b5a81f5c9eb92c43aefed

Change-Id: Iae9e69a9578ae305bca42f834694af96a29084e6
---
M configure.ac
M include/osmo-bts/Makefile.am
A include/osmo-bts/ecu_fr.h
M include/osmo-bts/gsm_data_shared.h
M src/common/Makefile.am
A src/common/ecu_fr.c
M src/osmo-bts-trx/scheduler_trx.c
M tests/Makefile.am
A tests/ecu_fr/Makefile.am
A tests/ecu_fr/ecu_fr_test.c
A tests/ecu_fr/ecu_fr_test.ok
M tests/meas/meas_test.c
M tests/testsuite.at
13 files changed, 560 insertions(+), 34 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-bts refs/changes/14/5214/4

diff --git a/configure.ac b/configure.ac
index e3ea9ca..0d1a882 100644
--- a/configure.ac
+++ b/configure.ac
@@ -180,4 +180,5 @@
 tests/tx_power/Makefile
 tests/power/Makefile
 tests/meas/Makefile
+tests/ecu_fr/Makefile
 Makefile)
diff --git a/include/osmo-bts/Makefile.am b/include/osmo-bts/Makefile.am
index a15ce3d..86bcdf1 100644
--- a/include/osmo-bts/Makefile.am
+++ b/include/osmo-bts/Makefile.am
@@ -2,4 +2,4 @@
 oml.h paging.h rsl.h signal.h vty.h amr.h pcu_if.h 
pcuif_proto.h \
 handover.h msg_utils.h tx_power.h control_if.h cbch.h l1sap.h \
 power_control.h scheduler.h scheduler_backend.h phy_link.h \
-dtx_dl_amr_fsm.h
+dtx_dl_amr_fsm.h ecu_fr.h
diff --git a/include/osmo-bts/ecu_fr.h b/include/osmo-bts/ecu_fr.h
new file mode 100644
index 000..3954457
--- /dev/null
+++ b/include/osmo-bts/ecu_fr.h
@@ -0,0 +1,15 @@
+#pragma once
+
+#include 
+#include 
+
+#include 
+
+/* Context information for the full rate ECU states */
+struct ecu_fr_ctx {
+   bool subsequent_lost_frame;
+   uint8_t frame_backup[GSM_FR_BYTES];
+};
+
+void ecu_fr_reset(struct ecu_fr_ctx *ctx, uint8_t *frame);
+void ecu_fr_conceal(struct ecu_fr_ctx *ctx, uint8_t *frame);
diff --git a/include/osmo-bts/gsm_data_shared.h 
b/include/osmo-bts/gsm_data_shared.h
index a05e4ca..37d6e0b 100644
--- a/include/osmo-bts/gsm_data_shared.h
+++ b/include/osmo-bts/gsm_data_shared.h
@@ -19,6 +19,7 @@
 #include 
 
 #include 
+#include 
 
 #ifndef ROLE_BSC
 #include 
@@ -381,6 +382,8 @@
} ms_power_ctrl;
 
struct msgb *pending_rel_ind_msg;
+
+   struct ecu_fr_ctx ecu_fr_ctx;
 #endif
 };
 
diff --git a/src/common/Makefile.am b/src/common/Makefile.am
index 67f3e80..d2d6ec6 100644
--- a/src/common/Makefile.am
+++ b/src/common/Makefile.am
@@ -12,6 +12,6 @@
   load_indication.c pcu_sock.c handover.c msg_utils.c \
   tx_power.c bts_ctrl_commands.c bts_ctrl_lookup.c \
   l1sap.c cbch.c power_control.c main.c phy_link.c \
-  dtx_dl_amr_fsm.c
+  dtx_dl_amr_fsm.c ecu_fr.c
 
 libl1sched_a_SOURCES = scheduler.c
diff --git a/src/common/ecu_fr.c b/src/common/ecu_fr.c
new file mode 100644
index 000..a1e8ef3
--- /dev/null
+++ b/src/common/ecu_fr.c
@@ -0,0 +1,148 @@
+/* (C) 2017 by sysmocom - s.f.m.c. GmbH
+ * All Rights Reserved
+ *
+ * Author: Philipp Maier
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program.  If not, see .
+ *
+ */
+
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/* See also GSM 6.11, chapter 6 Example solution */
+#define GSM610_XMAXC_REDUCE 4
+#define GSM610_XMAXC_LEN 6
+
+/* Reduce the XMAXC field. When the XMAXC field reaches
+ * zero, then the function will return true */
+static bool reduce_xmaxcr(struct bitvec *frame_bitvec, unsigned int index)
+{
+   unsigned int field_index;
+   uint64_t field;
+   bool silent = true;
+
+   field_index = index;
+   field = bitvec_read_field(frame_bitvec, &field_index, GSM610_XMAXC_LEN);
+   if (field > GSM610_XMAXC_REDUCE)
+   field -= GSM610_XMAXC_REDUCE;
+   else
+ 

osmo-bts[master]: osmo-bts-trx: add error concealment unit for GSM-FR

2017-12-13 Thread Harald Welte

Patch Set 3:

> @dexter, just let me know if I can help you with that.

if you have time and want to split it to a library function and propose an 
API+patch, feel free to go ahead.  dexter has many other things on his hand, so 
I'm not sure when he can get back to it.

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

Gerrit-MessageType: comment
Gerrit-Change-Id: Iae9e69a9578ae305bca42f834694af96a29084e6
Gerrit-PatchSet: 3
Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-Owner: dexter 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Neels Hofmeyr 
Gerrit-Reviewer: Vadim Yanitskiy 
Gerrit-Reviewer: dexter 
Gerrit-HasComments: No


osmo-bts[master]: osmo-bts-trx: add error concealment unit for GSM-FR

2017-12-11 Thread Vadim Yanitskiy

Patch Set 3:

Thanks, Harald!

@dexter, just let me know if I can help you with that.

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

Gerrit-MessageType: comment
Gerrit-Change-Id: Iae9e69a9578ae305bca42f834694af96a29084e6
Gerrit-PatchSet: 3
Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-Owner: dexter 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Neels Hofmeyr 
Gerrit-Reviewer: Vadim Yanitskiy 
Gerrit-Reviewer: dexter 
Gerrit-HasComments: No


osmo-bts[master]: osmo-bts-trx: add error concealment unit for GSM-FR

2017-12-11 Thread Harald Welte

Patch Set 3:

I think if Vadim wants to use it on the MS side, then it should go into 
libosmocodec or the like, at elast the ecu_fr.[ch] code.

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

Gerrit-MessageType: comment
Gerrit-Change-Id: Iae9e69a9578ae305bca42f834694af96a29084e6
Gerrit-PatchSet: 3
Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-Owner: dexter 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Neels Hofmeyr 
Gerrit-Reviewer: Vadim Yanitskiy 
Gerrit-Reviewer: dexter 
Gerrit-HasComments: No


osmo-bts[master]: osmo-bts-trx: add error concealment unit for GSM-FR

2017-12-11 Thread Vadim Yanitskiy

Patch Set 3:

> At least I think that would make a lot of sense.
> Also the enumwith the bit offsets could be put in
> a header file so others can use it.

Sure, I am a potential user of this feature for the MS side ;)

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

Gerrit-MessageType: comment
Gerrit-Change-Id: Iae9e69a9578ae305bca42f834694af96a29084e6
Gerrit-PatchSet: 3
Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-Owner: dexter 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Neels Hofmeyr 
Gerrit-Reviewer: Vadim Yanitskiy 
Gerrit-Reviewer: dexter 
Gerrit-HasComments: No


[PATCH] osmo-bts[master]: osmo-bts-trx: add error concealment unit for GSM-FR

2017-12-10 Thread dexter
Hello Vadim Yanitskiy, Neels Hofmeyr, Jenkins Builder,

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

https://gerrit.osmocom.org/5214

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

osmo-bts-trx: add error concealment unit for GSM-FR

When a bad GSM-FR voice frame is received, the frame replaced
ith a silence frame. This may cause unpleasant audio effects.

Add a functionality (see ecu_fr.c, ecu_fr_conceal() and
ecu_fr_reset() to craft a replacement frame from the last
known good frame.

Add unit test (ecu_fr_test.c)

Integrate into osmo-bts-trx

Change-Id: Iae9e69a9578ae305bca42f834694af96a29084e6
---
M configure.ac
M include/osmo-bts/Makefile.am
A include/osmo-bts/ecu_fr.h
M include/osmo-bts/gsm_data_shared.h
M src/common/Makefile.am
A src/common/ecu_fr.c
M src/osmo-bts-trx/scheduler_trx.c
M tests/Makefile.am
A tests/ecu_fr/Makefile.am
A tests/ecu_fr/ecu_fr_test.c
A tests/ecu_fr/ecu_fr_test.ok
M tests/meas/meas_test.c
M tests/testsuite.at
13 files changed, 827 insertions(+), 34 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-bts refs/changes/14/5214/3

diff --git a/configure.ac b/configure.ac
index e3ea9ca..0d1a882 100644
--- a/configure.ac
+++ b/configure.ac
@@ -180,4 +180,5 @@
 tests/tx_power/Makefile
 tests/power/Makefile
 tests/meas/Makefile
+tests/ecu_fr/Makefile
 Makefile)
diff --git a/include/osmo-bts/Makefile.am b/include/osmo-bts/Makefile.am
index a15ce3d..86bcdf1 100644
--- a/include/osmo-bts/Makefile.am
+++ b/include/osmo-bts/Makefile.am
@@ -2,4 +2,4 @@
 oml.h paging.h rsl.h signal.h vty.h amr.h pcu_if.h 
pcuif_proto.h \
 handover.h msg_utils.h tx_power.h control_if.h cbch.h l1sap.h \
 power_control.h scheduler.h scheduler_backend.h phy_link.h \
-dtx_dl_amr_fsm.h
+dtx_dl_amr_fsm.h ecu_fr.h
diff --git a/include/osmo-bts/ecu_fr.h b/include/osmo-bts/ecu_fr.h
new file mode 100644
index 000..3954457
--- /dev/null
+++ b/include/osmo-bts/ecu_fr.h
@@ -0,0 +1,15 @@
+#pragma once
+
+#include 
+#include 
+
+#include 
+
+/* Context information for the full rate ECU states */
+struct ecu_fr_ctx {
+   bool subsequent_lost_frame;
+   uint8_t frame_backup[GSM_FR_BYTES];
+};
+
+void ecu_fr_reset(struct ecu_fr_ctx *ctx, uint8_t *frame);
+void ecu_fr_conceal(struct ecu_fr_ctx *ctx, uint8_t *frame);
diff --git a/include/osmo-bts/gsm_data_shared.h 
b/include/osmo-bts/gsm_data_shared.h
index a05e4ca..37d6e0b 100644
--- a/include/osmo-bts/gsm_data_shared.h
+++ b/include/osmo-bts/gsm_data_shared.h
@@ -19,6 +19,7 @@
 #include 
 
 #include 
+#include 
 
 #ifndef ROLE_BSC
 #include 
@@ -381,6 +382,8 @@
} ms_power_ctrl;
 
struct msgb *pending_rel_ind_msg;
+
+   struct ecu_fr_ctx ecu_fr_ctx;
 #endif
 };
 
diff --git a/src/common/Makefile.am b/src/common/Makefile.am
index 67f3e80..d2d6ec6 100644
--- a/src/common/Makefile.am
+++ b/src/common/Makefile.am
@@ -12,6 +12,6 @@
   load_indication.c pcu_sock.c handover.c msg_utils.c \
   tx_power.c bts_ctrl_commands.c bts_ctrl_lookup.c \
   l1sap.c cbch.c power_control.c main.c phy_link.c \
-  dtx_dl_amr_fsm.c
+  dtx_dl_amr_fsm.c ecu_fr.c
 
 libl1sched_a_SOURCES = scheduler.c
diff --git a/src/common/ecu_fr.c b/src/common/ecu_fr.c
new file mode 100644
index 000..92228cd
--- /dev/null
+++ b/src/common/ecu_fr.c
@@ -0,0 +1,415 @@
+/* (C) 2017 by sysmocom - s.f.m.c. GmbH
+ * All Rights Reserved
+ *
+ * Author: Philipp Maier
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program.  If not, see .
+ *
+ */
+
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/* See also GSM 6.11, chapter 6 Example solution */
+#define GSM610_XMAXC_REDUCE 4
+#define GSM610_XMAXC_LEN 6
+
+/* See also RFC 3551 Table 3: GSM payload format: */
+enum gsm610_bit_offsets {
+   GSM610_SIGNATURE_0,
+   GSM610_SIGNATURE_1,
+   GSM610_SIGNATURE_2,
+   GSM610_SIGNATURE_3,
+   GSM610_LARC0_0,
+   GSM610_LARC0_1,
+   GSM610_LARC0_2,
+   GSM610_LARC0_3,
+   GSM610_LARC0_4,
+   GSM610_LARC0_5,
+   GSM610_LARC1_0,
+   GSM610_LARC1_1,
+   GSM610_LARC1_2,
+   GSM610_LARC1_3,
+   GSM610_LARC1_4,
+   GSM610_LARC1_5,
+   GSM610_LARC2_0,
+   GSM610_LARC2_1,
+   GSM610_LARC2_2,
+   GSM610

osmo-bts[master]: osmo-bts-trx: add error concealment unit for GSM-FR

2017-12-10 Thread dexter

Patch Set 2:

(15 comments)

> And finally, sorry for a lot of messages, but what if this would be
 > implemented as a part of libosmocodec? Harald?

At least I think that would make a lot of sense. Also the enum with the bit 
offsets could be put in a header file so others can use it.

https://gerrit.osmocom.org/#/c/5214/1//COMMIT_MSG
Commit Message:

Line 10: ith a silence frame. This may cause unpleasant audio effects.
> ith slince?
Done


Line 12: Add a functionality (see ecu_fr.c, ecu_fr_conceal() and
> ideally name the function
Done


Line 13: ecu_fr_reset() to craft a replacement frame from the last
> Add ecu_fr_test.
Done


https://gerrit.osmocom.org/#/c/5214/1/include/osmo-bts/ecu_fr.h
File include/osmo-bts/ecu_fr.h:

Line 19
> (usually no license header in .h files, but a short summary would be nice)
Done


https://gerrit.osmocom.org/#/c/5214/2/include/osmo-bts/ecu_fr.h
File include/osmo-bts/ecu_fr.h:

Line 2: 
> I think, this header should satisfy at least the following dependences itse
Done


https://gerrit.osmocom.org/#/c/5214/1/include/osmo-bts/gsm_data_shared.h
File include/osmo-bts/gsm_data_shared.h:

Line 19: #include 
> (unrelated ws)
Done


https://gerrit.osmocom.org/#/c/5214/1/src/common/ecu_fr.c
File src/common/ecu_fr.c:

Line 1: /* (C) 2017 by sysmocom - s.f.m.c. GmbH
> from Harald's recent comment we should put a dash before s.f.m.c.
Done


Line 303: /* Reduce the XMAXC field. When the XMAXC field reaches
> (almost any API is a "helper function" :) -- just say what it does, same be
Done


Line 364:   goto leave;
> a bit more context, like at least say we failed to unpack an FR frame
Done


Line 377:   }
> semantically it's not an abort, right?
Done


Line 383:   goto leave;
> -1: unreachable code, the goto is not useful anyhow
Done


Line 384:   }
> context
Done


https://gerrit.osmocom.org/#/c/5214/1/src/osmo-bts-trx/scheduler_trx.c
File src/osmo-bts-trx/scheduler_trx.c:

Line 1113:  if (!bfi_flag && tch_mode == GSM48_CMODE_SPEECH_V1)
> if (!bfi_flag...
Done


https://gerrit.osmocom.org/#/c/5214/2/tests/ecu_fr/Makefile.am
File tests/ecu_fr/Makefile.am:

Line 3: LDADD = $(LIBOSMOCORE_LIBS) $(LIBOSMOGSM_LIBS) $(LIBOSMOCODEC_LIBS) 
$(LIBOSMOTRAU_LIBS) $(LIBOSMOABIS_LIBS)
> Both LIBOSMOTRAU and LIBOSMOABIS are not required here...
Done


https://gerrit.osmocom.org/#/c/5214/2/tests/ecu_fr/ecu_fr_test.c
File tests/ecu_fr/ecu_fr_test.c:

PS2, Line 1: #include 
   : #include 
   : #include 
   : #include 
   : #include 
   : #include 
   : #include 
   : #include 
   : #include 
   : #include 
   : #include 
   : 
   : #include 
   : #include 
   : #include 
   : 
   : #include 
   : #include 
   : #include 
   : #include 
   : 
   : #include 
   : #include 
   : #include 
> So many useless includes... The following set would be enough:
I copied from another test and forgot to go through the includes. Thanks.


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

Gerrit-MessageType: comment
Gerrit-Change-Id: Iae9e69a9578ae305bca42f834694af96a29084e6
Gerrit-PatchSet: 2
Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-Owner: dexter 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Neels Hofmeyr 
Gerrit-Reviewer: Vadim Yanitskiy 
Gerrit-Reviewer: dexter 
Gerrit-HasComments: Yes


osmo-bts[master]: osmo-bts-trx: add error concealment unit for GSM-FR

2017-12-08 Thread Vadim Yanitskiy

Patch Set 2:

And finally, sorry for a lot of messages, but what if this would be
implemented as a part of libosmocodec? Harald?

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

Gerrit-MessageType: comment
Gerrit-Change-Id: Iae9e69a9578ae305bca42f834694af96a29084e6
Gerrit-PatchSet: 2
Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-Owner: dexter 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Neels Hofmeyr 
Gerrit-Reviewer: Vadim Yanitskiy 
Gerrit-HasComments: No


osmo-bts[master]: osmo-bts-trx: add error concealment unit for GSM-FR

2017-12-08 Thread Vadim Yanitskiy

Patch Set 2:

(1 comment)

https://gerrit.osmocom.org/#/c/5214/2/include/osmo-bts/ecu_fr.h
File include/osmo-bts/ecu_fr.h:

Line 2: 
I think, this header should satisfy at least the following dependences itself:

#include 
#include 

Regarding to GSM_FR_BYTES, including 'osmo-bts/gsm_data.h'
could cause the cross-header reference there...


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

Gerrit-MessageType: comment
Gerrit-Change-Id: Iae9e69a9578ae305bca42f834694af96a29084e6
Gerrit-PatchSet: 2
Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-Owner: dexter 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Neels Hofmeyr 
Gerrit-Reviewer: Vadim Yanitskiy 
Gerrit-HasComments: Yes


osmo-bts[master]: osmo-bts-trx: add error concealment unit for GSM-FR

2017-12-08 Thread Vadim Yanitskiy

Patch Set 2: Code-Review-1

(1 comment)

Great work, but -1 for some useless includes, CFLAGS and LDADD libs.

https://gerrit.osmocom.org/#/c/5214/2/tests/ecu_fr/Makefile.am
File tests/ecu_fr/Makefile.am:

Line 3: LDADD = $(LIBOSMOCORE_LIBS) $(LIBOSMOGSM_LIBS) $(LIBOSMOCODEC_LIBS) 
$(LIBOSMOTRAU_LIBS) $(LIBOSMOABIS_LIBS)
Both LIBOSMOTRAU and LIBOSMOABIS are not required here...


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

Gerrit-MessageType: comment
Gerrit-Change-Id: Iae9e69a9578ae305bca42f834694af96a29084e6
Gerrit-PatchSet: 2
Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-Owner: dexter 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Neels Hofmeyr 
Gerrit-Reviewer: Vadim Yanitskiy 
Gerrit-HasComments: Yes


osmo-bts[master]: osmo-bts-trx: add error concealment unit for GSM-FR

2017-12-08 Thread Vadim Yanitskiy

Patch Set 2:

(1 comment)

https://gerrit.osmocom.org/#/c/5214/2/tests/ecu_fr/ecu_fr_test.c
File tests/ecu_fr/ecu_fr_test.c:

PS2, Line 1: #include 
   : #include 
   : #include 
   : #include 
   : #include 
   : #include 
   : #include 
   : #include 
   : #include 
   : #include 
   : #include 
   : 
   : #include 
   : #include 
   : #include 
   : 
   : #include 
   : #include 
   : #include 
   : #include 
   : 
   : #include 
   : #include 
   : #include 
So many useless includes... The following set would be enough:

#include 
#include 
#include 

#include 
#include 

#include 
#include 
#include 


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

Gerrit-MessageType: comment
Gerrit-Change-Id: Iae9e69a9578ae305bca42f834694af96a29084e6
Gerrit-PatchSet: 2
Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-Owner: dexter 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Neels Hofmeyr 
Gerrit-Reviewer: Vadim Yanitskiy 
Gerrit-HasComments: Yes


[PATCH] osmo-bts[master]: osmo-bts-trx: add error concealment unit for GSM-FR

2017-12-08 Thread dexter
Hello Neels Hofmeyr, Jenkins Builder,

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

https://gerrit.osmocom.org/5214

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

osmo-bts-trx: add error concealment unit for GSM-FR

When a bad GSM-FR voice frame is received, the frame replaced
ith a silence frame. This may cause unpleasant audio effects.

Add a functionality (see ecu_fr.c, ecu_fr_conceal() and
ecu_fr_reset() to craft a replacement frame from the last
known good frame.

Add unit test (ecu_fr_test.c)

Integrate into osmo-bts-trx

Change-Id: Iae9e69a9578ae305bca42f834694af96a29084e6
---
M configure.ac
M include/osmo-bts/Makefile.am
A include/osmo-bts/ecu_fr.h
M include/osmo-bts/gsm_data_shared.h
M src/common/Makefile.am
A src/common/ecu_fr.c
M src/osmo-bts-trx/scheduler_trx.c
M tests/Makefile.am
A tests/ecu_fr/Makefile.am
A tests/ecu_fr/ecu_fr_test.c
A tests/ecu_fr/ecu_fr_test.ok
M tests/testsuite.at
12 files changed, 818 insertions(+), 5 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-bts refs/changes/14/5214/2

diff --git a/configure.ac b/configure.ac
index e3ea9ca..0d1a882 100644
--- a/configure.ac
+++ b/configure.ac
@@ -180,4 +180,5 @@
 tests/tx_power/Makefile
 tests/power/Makefile
 tests/meas/Makefile
+tests/ecu_fr/Makefile
 Makefile)
diff --git a/include/osmo-bts/Makefile.am b/include/osmo-bts/Makefile.am
index a15ce3d..86bcdf1 100644
--- a/include/osmo-bts/Makefile.am
+++ b/include/osmo-bts/Makefile.am
@@ -2,4 +2,4 @@
 oml.h paging.h rsl.h signal.h vty.h amr.h pcu_if.h 
pcuif_proto.h \
 handover.h msg_utils.h tx_power.h control_if.h cbch.h l1sap.h \
 power_control.h scheduler.h scheduler_backend.h phy_link.h \
-dtx_dl_amr_fsm.h
+dtx_dl_amr_fsm.h ecu_fr.h
diff --git a/include/osmo-bts/ecu_fr.h b/include/osmo-bts/ecu_fr.h
new file mode 100644
index 000..f33f508
--- /dev/null
+++ b/include/osmo-bts/ecu_fr.h
@@ -0,0 +1,10 @@
+#pragma once
+
+/* Context information for the full rate ECU states */
+struct ecu_fr_ctx {
+   bool subsequent_lost_frame;
+   uint8_t frame_backup[GSM_FR_BYTES];
+};
+
+void ecu_fr_reset(struct ecu_fr_ctx *ctx, uint8_t *frame);
+void ecu_fr_conceal(struct ecu_fr_ctx *ctx, uint8_t *frame);
diff --git a/include/osmo-bts/gsm_data_shared.h 
b/include/osmo-bts/gsm_data_shared.h
index a05e4ca..37d6e0b 100644
--- a/include/osmo-bts/gsm_data_shared.h
+++ b/include/osmo-bts/gsm_data_shared.h
@@ -19,6 +19,7 @@
 #include 
 
 #include 
+#include 
 
 #ifndef ROLE_BSC
 #include 
@@ -381,6 +382,8 @@
} ms_power_ctrl;
 
struct msgb *pending_rel_ind_msg;
+
+   struct ecu_fr_ctx ecu_fr_ctx;
 #endif
 };
 
diff --git a/src/common/Makefile.am b/src/common/Makefile.am
index 67f3e80..d2d6ec6 100644
--- a/src/common/Makefile.am
+++ b/src/common/Makefile.am
@@ -12,6 +12,6 @@
   load_indication.c pcu_sock.c handover.c msg_utils.c \
   tx_power.c bts_ctrl_commands.c bts_ctrl_lookup.c \
   l1sap.c cbch.c power_control.c main.c phy_link.c \
-  dtx_dl_amr_fsm.c
+  dtx_dl_amr_fsm.c ecu_fr.c
 
 libl1sched_a_SOURCES = scheduler.c
diff --git a/src/common/ecu_fr.c b/src/common/ecu_fr.c
new file mode 100644
index 000..92228cd
--- /dev/null
+++ b/src/common/ecu_fr.c
@@ -0,0 +1,415 @@
+/* (C) 2017 by sysmocom - s.f.m.c. GmbH
+ * All Rights Reserved
+ *
+ * Author: Philipp Maier
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program.  If not, see .
+ *
+ */
+
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/* See also GSM 6.11, chapter 6 Example solution */
+#define GSM610_XMAXC_REDUCE 4
+#define GSM610_XMAXC_LEN 6
+
+/* See also RFC 3551 Table 3: GSM payload format: */
+enum gsm610_bit_offsets {
+   GSM610_SIGNATURE_0,
+   GSM610_SIGNATURE_1,
+   GSM610_SIGNATURE_2,
+   GSM610_SIGNATURE_3,
+   GSM610_LARC0_0,
+   GSM610_LARC0_1,
+   GSM610_LARC0_2,
+   GSM610_LARC0_3,
+   GSM610_LARC0_4,
+   GSM610_LARC0_5,
+   GSM610_LARC1_0,
+   GSM610_LARC1_1,
+   GSM610_LARC1_2,
+   GSM610_LARC1_3,
+   GSM610_LARC1_4,
+   GSM610_LARC1_5,
+   GSM610_LARC2_0,
+   GSM610_LARC2_1,
+   GSM610_LARC2_2,
+   GSM610_LARC2_3,
+   GSM610_LARC2_4,
+   GSM610_LARC3_0,
+   GSM610_LARC3_1

osmo-bts[master]: osmo-bts-trx: add error concealment unit for GSM-FR

2017-12-07 Thread Neels Hofmeyr

Patch Set 1: Code-Review-1

(12 comments)

mostly just a bunch of less important cosmetic comments, but one -1 near the end

https://gerrit.osmocom.org/#/c/5214/1//COMMIT_MSG
Commit Message:

Line 10: ith a slince frame. This may cause unpleasant audio effects.
ith slince?


Line 12: Add a function to craft a replacement frame from the last
ideally name the function


Line 13: known good frame.
Add ecu_fr_test.


https://gerrit.osmocom.org/#/c/5214/1/include/osmo-bts/ecu_fr.h
File include/osmo-bts/ecu_fr.h:

Line 19:  */
(usually no license header in .h files, but a short summary would be nice)


https://gerrit.osmocom.org/#/c/5214/1/include/osmo-bts/gsm_data_shared.h
File include/osmo-bts/gsm_data_shared.h:

Line 19: #include 
(unrelated ws)


https://gerrit.osmocom.org/#/c/5214/1/src/common/ecu_fr.c
File src/common/ecu_fr.c:

Line 1: /* (C) 2017 by sysmocom s.f.m.c. GmbH
from Harald's recent comment we should put a dash before s.f.m.c.


Line 303: /* Helper function to reduce the XMAXC field. When the XMAXC field 
reaches
(almost any API is a "helper function" :) -- just say what it does, same below)


Line 364:   LOGP(DL1P, LOGL_ERROR, "Wrong number of bits 
unpacked!\n");
a bit more context, like at least say we failed to unpack an FR frame


Line 377:   goto abort;
semantically it's not an abort, right?


Line 383:   goto abort;
-1: unreachable code, the goto is not useful anyhow


Line 384:   LOGP(DL1P, LOGL_ERROR, "Wrong number of bits 
packed!\n");
context


https://gerrit.osmocom.org/#/c/5214/1/src/osmo-bts-trx/scheduler_trx.c
File src/osmo-bts-trx/scheduler_trx.c:

Line 1113:  if (bfi_flag == false && tch_mode == GSM48_CMODE_SPEECH_V1)
if (!bfi_flag...


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

Gerrit-MessageType: comment
Gerrit-Change-Id: Iae9e69a9578ae305bca42f834694af96a29084e6
Gerrit-PatchSet: 1
Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-Owner: dexter 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Neels Hofmeyr 
Gerrit-HasComments: Yes


[PATCH] osmo-bts[master]: osmo-bts-trx: add error concealment unit for GSM-FR

2017-12-06 Thread dexter

Review at  https://gerrit.osmocom.org/5214

osmo-bts-trx: add error concealment unit for GSM-FR

When a bad GSM-FR voice frame is received, the frame replaced
ith a slince frame. This may cause unpleasant audio effects.

Add a function to craft a replacement frame from the last
known good frame.

Change-Id: Iae9e69a9578ae305bca42f834694af96a29084e6
---
M configure.ac
M include/osmo-bts/Makefile.am
A include/osmo-bts/ecu_fr.h
M include/osmo-bts/gsm_data_shared.h
M src/common/Makefile.am
A src/common/ecu_fr.c
M src/osmo-bts-trx/scheduler_trx.c
M tests/Makefile.am
A tests/ecu_fr/Makefile.am
A tests/ecu_fr/ecu_fr_test.c
A tests/ecu_fr/ecu_fr_test.ok
M tests/testsuite.at
12 files changed, 839 insertions(+), 6 deletions(-)


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

diff --git a/configure.ac b/configure.ac
index e3ea9ca..0d1a882 100644
--- a/configure.ac
+++ b/configure.ac
@@ -180,4 +180,5 @@
 tests/tx_power/Makefile
 tests/power/Makefile
 tests/meas/Makefile
+tests/ecu_fr/Makefile
 Makefile)
diff --git a/include/osmo-bts/Makefile.am b/include/osmo-bts/Makefile.am
index a15ce3d..86bcdf1 100644
--- a/include/osmo-bts/Makefile.am
+++ b/include/osmo-bts/Makefile.am
@@ -2,4 +2,4 @@
 oml.h paging.h rsl.h signal.h vty.h amr.h pcu_if.h 
pcuif_proto.h \
 handover.h msg_utils.h tx_power.h control_if.h cbch.h l1sap.h \
 power_control.h scheduler.h scheduler_backend.h phy_link.h \
-dtx_dl_amr_fsm.h
+dtx_dl_amr_fsm.h ecu_fr.h
diff --git a/include/osmo-bts/ecu_fr.h b/include/osmo-bts/ecu_fr.h
new file mode 100644
index 000..da6281e
--- /dev/null
+++ b/include/osmo-bts/ecu_fr.h
@@ -0,0 +1,30 @@
+/* (C) 2017 by sysmocom s.f.m.c. GmbH
+ * All Rights Reserved
+ *
+ * Author: Philipp Maier
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program.  If not, see .
+ *
+ */
+
+#pragma once
+
+/* Context information for the full rate ECU states */
+struct ecu_fr_ctx {
+   bool subsequent_lost_frame;
+   uint8_t frame_backup[GSM_FR_BYTES];
+};
+
+void ecu_fr_reset(struct ecu_fr_ctx *ctx, uint8_t *frame);
+void ecu_fr_conceal(struct ecu_fr_ctx *ctx, uint8_t *frame);
diff --git a/include/osmo-bts/gsm_data_shared.h 
b/include/osmo-bts/gsm_data_shared.h
index a05e4ca..cfd7709 100644
--- a/include/osmo-bts/gsm_data_shared.h
+++ b/include/osmo-bts/gsm_data_shared.h
@@ -17,8 +17,8 @@
 #include 
 #include 
 #include 
-
 #include 
+#include 
 
 #ifndef ROLE_BSC
 #include 
@@ -381,6 +381,8 @@
} ms_power_ctrl;
 
struct msgb *pending_rel_ind_msg;
+
+   struct ecu_fr_ctx ecu_fr_ctx;
 #endif
 };
 
diff --git a/src/common/Makefile.am b/src/common/Makefile.am
index 67f3e80..d2d6ec6 100644
--- a/src/common/Makefile.am
+++ b/src/common/Makefile.am
@@ -12,6 +12,6 @@
   load_indication.c pcu_sock.c handover.c msg_utils.c \
   tx_power.c bts_ctrl_commands.c bts_ctrl_lookup.c \
   l1sap.c cbch.c power_control.c main.c phy_link.c \
-  dtx_dl_amr_fsm.c
+  dtx_dl_amr_fsm.c ecu_fr.c
 
 libl1sched_a_SOURCES = scheduler.c
diff --git a/src/common/ecu_fr.c b/src/common/ecu_fr.c
new file mode 100644
index 000..fb5840d
--- /dev/null
+++ b/src/common/ecu_fr.c
@@ -0,0 +1,416 @@
+/* (C) 2017 by sysmocom s.f.m.c. GmbH
+ * All Rights Reserved
+ *
+ * Author: Philipp Maier
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program.  If not, see .
+ *
+ */
+
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/* See also GSM 6.11, chapter 6 Example solution */
+#define GSM610_XMAXC_REDUCE 4
+#define GSM610_XMAXC_LEN 6
+
+/* See also RFC 3551 Table 3: GSM payload format: */
+enum gsm610_bit_offs