aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMax <msuraev@sysmocom.de>2016-09-28 16:25:13 +0200
committerMax <msuraev@sysmocom.de>2016-09-30 16:50:47 +0200
commit7dffd553df0ca48f52d6faca70aa3e9cf2760840 (patch)
treeead12cc877a81d613320fc1f74a5ef319d821f72
parent94fa25295f090cc6190ae7c96df946a3979f05cc (diff)
DTX: move scheduling check inside repeat_last_sid
Note: this also require changes to properly link against libosmocodec - see 2bb65be159dfdabf664fec569b343320301701b0 in libosmocore. Change-Id: I96594cf3aa1013d505bd20069d5bf261d9a2aefb
-rw-r--r--include/osmo-bts/msg_utils.h4
-rw-r--r--src/common/Makefile.am4
-rw-r--r--src/common/msg_utils.c58
-rw-r--r--src/osmo-bts-litecell15/tch.c34
-rw-r--r--src/osmo-bts-sysmo/Makefile.am2
-rw-r--r--src/osmo-bts-sysmo/tch.c34
-rw-r--r--tests/misc/Makefile.am4
7 files changed, 61 insertions, 79 deletions
diff --git a/include/osmo-bts/msg_utils.h b/include/osmo-bts/msg_utils.h
index f03eb438..14c23205 100644
--- a/include/osmo-bts/msg_utils.h
+++ b/include/osmo-bts/msg_utils.h
@@ -6,6 +6,8 @@
#include <osmo-bts/gsm_data.h>
+#include <osmocom/codec/codec.h>
+
#include <stdbool.h>
struct msgb;
@@ -27,7 +29,5 @@ void lchan_set_marker(bool t, struct gsm_lchan *lchan);
void save_last_sid(struct gsm_lchan *lchan, uint8_t *l1_payload, size_t length,
uint32_t fn, bool update);
uint8_t repeat_last_sid(struct gsm_lchan *lchan, uint8_t *dst, uint32_t fn);
-bool dtx_amr_sid_optional(const struct gsm_lchan *lchan, uint32_t fn);
-bool dtx_sched_optional(struct gsm_lchan *lchan, uint32_t fn);
int msg_verify_ipa_structure(struct msgb *msg);
int msg_verify_oml_structure(struct msgb *msg);
diff --git a/src/common/Makefile.am b/src/common/Makefile.am
index fbb65729..856f7412 100644
--- a/src/common/Makefile.am
+++ b/src/common/Makefile.am
@@ -1,6 +1,6 @@
AM_CPPFLAGS = $(all_includes) -I$(top_srcdir)/include -I$(OPENBSC_INCDIR)
-AM_CFLAGS = -Wall $(LIBOSMOCORE_CFLAGS) $(LIBOSMOTRAU_CFLAGS)
-LDADD = $(LIBOSMOCORE_LIBS) $(LIBOSMOTRAU_LIBS)
+AM_CFLAGS = -Wall $(LIBOSMOCORE_CFLAGS) $(LIBOSMOTRAU_CFLAGS) $(LIBOSMOCODEC_CFLAGS)
+LDADD = $(LIBOSMOCORE_LIBS) $(LIBOSMOTRAU_LIBS) $(LIBOSMOCODEC_LIBS)
noinst_LIBRARIES = libbts.a libl1sched.a
libbts_a_SOURCES = gsm_data_shared.c sysinfo.c logging.c abis.c oml.c bts.c \
diff --git a/src/common/msg_utils.c b/src/common/msg_utils.c
index 967b10d9..f5a48a3d 100644
--- a/src/common/msg_utils.c
+++ b/src/common/msg_utils.c
@@ -112,32 +112,13 @@ void save_last_sid(struct gsm_lchan *lchan, uint8_t *l1_payload, size_t length,
memcpy(lchan->tch.last_sid.buf, l1_payload, copy_len);
}
-/* repeat last SID if possible, returns SID length + 1 or 0 */
-/*! \brief Repeat last SID if possible in case of DTX
- * \param[in] lchan Logical channel on which we check scheduling
- * \param[in] dst Buffer to copy last SID into
- * \returns Number of bytes copied + 1 (to accommodate for extra byte with
- * payload type) or 0 if there's nothing to copy
- */
-uint8_t repeat_last_sid(struct gsm_lchan *lchan, uint8_t *dst, uint32_t fn)
-{
- if (lchan->tch.last_sid.len) {
- memcpy(dst, lchan->tch.last_sid.buf, lchan->tch.last_sid.len);
- lchan->tch.last_sid.fn = fn;
- return lchan->tch.last_sid.len + 1;
- }
- LOGP(DL1C, LOGL_NOTICE, "Have to send %s frame on TCH but SID buffer "
- "is empty - sent nothing\n",
- get_value_string(gsm48_chan_mode_names, lchan->tch_mode));
- return 0;
-}
-
/*! \brief Check if enough time has passed since last SID (if any) to repeat it
* \param[in] lchan Logical channel on which we check scheduling
* \param[in] fn Frame Number for which we check scheduling
* \returns true if transmission can be omitted, false otherwise
*/
-bool dtx_amr_sid_optional(const struct gsm_lchan *lchan, uint32_t fn)
+static inline bool dtx_amr_sid_optional(const struct gsm_lchan *lchan,
+ uint32_t fn)
{
/* Compute approx. time delta based on Fn duration */
uint32_t delta = GSM_FN_TO_MS(fn - lchan->tch.last_sid.fn);
@@ -169,7 +150,7 @@ static inline bool fn_chk(const uint8_t *t, uint32_t fn)
* \param[in] fn Frame Number for which we check scheduling
* \returns true if transmission can be omitted, false otherwise
*/
-bool dtx_sched_optional(struct gsm_lchan *lchan, uint32_t fn)
+static inline bool dtx_sched_optional(struct gsm_lchan *lchan, uint32_t fn)
{
/* According to 3GPP TS 45.008 ยง 8.3: */
static const uint8_t f[] = { 52, 53, 54, 55, 56, 57, 58, 59 },
@@ -184,6 +165,39 @@ bool dtx_sched_optional(struct gsm_lchan *lchan, uint32_t fn)
return false;
}
+/* repeat last SID if possible, returns SID length + 1 or 0 */
+/*! \brief Repeat last SID if possible in case of DTX
+ * \param[in] lchan Logical channel on which we check scheduling
+ * \param[in] dst Buffer to copy last SID into
+ * \returns Number of bytes copied + 1 (to accommodate for extra byte with
+ * payload type), 0 if there's nothing to copy
+ */
+uint8_t repeat_last_sid(struct gsm_lchan *lchan, uint8_t *dst, uint32_t fn)
+{
+ /* FIXME: add EFR support */
+ if (lchan->tch_mode == GSM48_CMODE_SPEECH_EFR)
+ return 0;
+
+ if (lchan->tch_mode != GSM48_CMODE_SPEECH_AMR) {
+ if (dtx_sched_optional(lchan, fn))
+ return 0;
+ } else
+ if (dtx_amr_sid_optional(lchan, fn))
+ return 0;
+
+ if (lchan->tch.last_sid.len) {
+ memcpy(dst, lchan->tch.last_sid.buf, lchan->tch.last_sid.len);
+ lchan->tch.last_sid.fn = fn;
+ return lchan->tch.last_sid.len + 1;
+ }
+
+ LOGP(DL1C, LOGL_DEBUG, "Have to send %s frame on TCH but SID buffer "
+ "is empty - sent nothing\n",
+ get_value_string(gsm48_chan_mode_names, lchan->tch_mode));
+
+ return 0;
+}
+
/**
* Return 0 in case the IPA structure is okay and in this
* case the l2h will be set to the beginning of the data.
diff --git a/src/osmo-bts-litecell15/tch.c b/src/osmo-bts-litecell15/tch.c
index bcf981e4..5ec1ee74 100644
--- a/src/osmo-bts-litecell15/tch.c
+++ b/src/osmo-bts-litecell15/tch.c
@@ -35,7 +35,6 @@
#include <osmocom/core/select.h>
#include <osmocom/core/timer.h>
#include <osmocom/core/bits.h>
-#include <osmocom/codec/codec.h>
#include <osmocom/gsm/gsm_utils.h>
#include <osmocom/trau/osmo_ortp.h>
@@ -492,6 +491,7 @@ struct msgb *gen_empty_tch_msg(struct gsm_lchan *lchan, uint32_t fn)
GsmL1_MsgUnitParam_t *msu_param;
uint8_t *payload_type;
uint8_t *l1_payload;
+ int rc;
msg = l1p_msgb_alloc();
if (!msg)
@@ -506,43 +506,27 @@ struct msgb *gen_empty_tch_msg(struct gsm_lchan *lchan, uint32_t fn)
switch (lchan->tch_mode) {
case GSM48_CMODE_SPEECH_AMR:
*payload_type = GsmL1_TchPlType_Amr;
- if (dtx_amr_sid_optional(lchan, fn)) {
- msgb_free(msg);
- return NULL;
- }
- msu_param->u8Size = repeat_last_sid(lchan, l1_payload, fn);
- if (!msu_param->u8Size)
- osmo_amr_rtp_enc(l1_payload, 0, AMR_NO_DATA, AMR_GOOD);
break;
case GSM48_CMODE_SPEECH_V1:
if (lchan->type == GSM_LCHAN_TCH_F)
*payload_type = GsmL1_TchPlType_Fr;
else
*payload_type = GsmL1_TchPlType_Hr;
- /* unlike AMR, FR & HR schedued based on absolute FN value */
- if (dtx_sched_optional(lchan, fn)) {
- msgb_free(msg);
- return NULL;
- }
- msu_param->u8Size = repeat_last_sid(lchan, l1_payload, fn);
- if (!msu_param->u8Size)
- return NULL;
break;
case GSM48_CMODE_SPEECH_EFR:
*payload_type = GsmL1_TchPlType_Efr;
- if (dtx_sched_optional(lchan, fn)) {
- msgb_free(msg);
- return NULL;
- }
- msu_param->u8Size = repeat_last_sid(lchan, l1_payload, fn);
- if (!msu_param->u8Size)
- return NULL;
break;
default:
msgb_free(msg);
- msg = NULL;
- break;
+ return NULL;
+ }
+
+ rc = repeat_last_sid(lchan, l1_payload, fn);
+ if (!rc) {
+ msgb_free(msg);
+ return NULL;
}
+ msu_param->u8Size = rc;
return msg;
}
diff --git a/src/osmo-bts-sysmo/Makefile.am b/src/osmo-bts-sysmo/Makefile.am
index 34f4bb0d..8e39a3a2 100644
--- a/src/osmo-bts-sysmo/Makefile.am
+++ b/src/osmo-bts-sysmo/Makefile.am
@@ -29,7 +29,7 @@ sysmobts_mgr_SOURCES = \
misc/sysmobts_mgr_temp.c \
misc/sysmobts_mgr_calib.c \
eeprom.c
-sysmobts_mgr_LDADD = $(LIBGPS_LIBS) $(LIBOSMOCORE_LIBS) $(LIBOSMOVTY_LIBS) $(LIBOSMOABIS_LIBS) $(LIBOSMOGSM_LIBS) $(LIBOSMOCTRL_LIBS) $(top_builddir)/src/common/libbts.a
+sysmobts_mgr_LDADD = $(LIBGPS_LIBS) $(LIBOSMOCORE_LIBS) $(LIBOSMOVTY_LIBS) $(LIBOSMOABIS_LIBS) $(LIBOSMOGSM_LIBS) $(LIBOSMOCTRL_LIBS) $(top_builddir)/src/common/libbts.a $(COMMON_LDADD)
sysmobts_util_SOURCES = misc/sysmobts_util.c misc/sysmobts_par.c eeprom.c
sysmobts_util_LDADD = $(LIBOSMOCORE_LIBS)
diff --git a/src/osmo-bts-sysmo/tch.c b/src/osmo-bts-sysmo/tch.c
index f3503982..0e4b2dab 100644
--- a/src/osmo-bts-sysmo/tch.c
+++ b/src/osmo-bts-sysmo/tch.c
@@ -32,7 +32,6 @@
#include <osmocom/core/select.h>
#include <osmocom/core/timer.h>
#include <osmocom/core/bits.h>
-#include <osmocom/codec/codec.h>
#include <osmocom/gsm/gsm_utils.h>
#include <osmocom/trau/osmo_ortp.h>
@@ -595,6 +594,7 @@ struct msgb *gen_empty_tch_msg(struct gsm_lchan *lchan, uint32_t fn)
GsmL1_MsgUnitParam_t *msu_param;
uint8_t *payload_type;
uint8_t *l1_payload;
+ int rc;
msg = l1p_msgb_alloc();
if (!msg)
@@ -609,43 +609,27 @@ struct msgb *gen_empty_tch_msg(struct gsm_lchan *lchan, uint32_t fn)
switch (lchan->tch_mode) {
case GSM48_CMODE_SPEECH_AMR:
*payload_type = GsmL1_TchPlType_Amr;
- if (dtx_amr_sid_optional(lchan, fn)) {
- msgb_free(msg);
- return NULL;
- }
- msu_param->u8Size = repeat_last_sid(lchan, l1_payload, fn);
- if (!msu_param->u8Size)
- osmo_amr_rtp_enc(l1_payload, 0, AMR_NO_DATA, AMR_GOOD);
break;
case GSM48_CMODE_SPEECH_V1:
if (lchan->type == GSM_LCHAN_TCH_F)
*payload_type = GsmL1_TchPlType_Fr;
else
*payload_type = GsmL1_TchPlType_Hr;
- /* unlike AMR, FR & HR schedued based on absolute FN value */
- if (dtx_sched_optional(lchan, fn)) {
- msgb_free(msg);
- return NULL;
- }
- msu_param->u8Size = repeat_last_sid(lchan, l1_payload, fn);
- if (!msu_param->u8Size)
- return NULL;
break;
case GSM48_CMODE_SPEECH_EFR:
*payload_type = GsmL1_TchPlType_Efr;
- if (dtx_sched_optional(lchan, fn)) {
- msgb_free(msg);
- return NULL;
- }
- msu_param->u8Size = repeat_last_sid(lchan, l1_payload, fn);
- if (!msu_param->u8Size)
- return NULL;
break;
default:
msgb_free(msg);
- msg = NULL;
- break;
+ return NULL;
+ }
+
+ rc = repeat_last_sid(lchan, l1_payload, fn);
+ if (!rc) {
+ msgb_free(msg);
+ return NULL;
}
+ msu_param->u8Size = rc;
return msg;
}
diff --git a/tests/misc/Makefile.am b/tests/misc/Makefile.am
index f60325b0..d5acb18a 100644
--- a/tests/misc/Makefile.am
+++ b/tests/misc/Makefile.am
@@ -1,6 +1,6 @@
AM_CPPFLAGS = $(all_includes) -I$(top_srcdir)/include -I$(OPENBSC_INCDIR)
-AM_CFLAGS = -Wall $(LIBOSMOCORE_CFLAGS) $(LIBOSMOGSM_CFLAGS)
-LDADD = $(LIBOSMOCORE_LIBS) $(LIBOSMOGSM_LIBS)
+AM_CFLAGS = -Wall $(LIBOSMOCORE_CFLAGS) $(LIBOSMOGSM_CFLAGS) $(LIBOSMOCODEC_CFLAGS)
+LDADD = $(LIBOSMOCORE_LIBS) $(LIBOSMOGSM_LIBS) $(LIBOSMOCODEC_LIBS)
noinst_PROGRAMS = misc_test
EXTRA_DIST = misc_test.ok