aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <holger@moiji-mobile.com>2016-03-15 14:13:06 +0100
committerHolger Hans Peter Freyther <holger@moiji-mobile.com>2016-03-15 16:36:06 +0100
commit297daa209306004149b91c6107db228745e20b96 (patch)
tree0bb4cbc0814ff07d376e56c5647c3a6703cfe0e2
parent8dea0d21ff643a40861fde0d0e131eebb965c066 (diff)
There is no FreeChanCnf and this leads to not knowing when the resource can be allocated again. This is an issue for making it reliable. Stop here and wait for progress.
-rw-r--r--openbsc/configure.ac12
-rw-r--r--openbsc/include/openbsc/mgcp_transcode.h9
-rw-r--r--openbsc/src/libmgcp/Makefile.am3
-rw-r--r--openbsc/src/libmgcp/mgcp_transcode_dsp.c146
4 files changed, 169 insertions, 1 deletions
diff --git a/openbsc/configure.ac b/openbsc/configure.ac
index 24dbc30f7..e76ddd43d 100644
--- a/openbsc/configure.ac
+++ b/openbsc/configure.ac
@@ -73,6 +73,17 @@ fi
AM_CONDITIONAL(BUILD_MGCP_TRANSCODING, test "x$osmo_ac_mgcp_transcoding" = "xyes")
AC_SUBST(osmo_ac_mgcp_transcoding)
+# trau.h
+AC_ARG_ENABLE([dsptranscode],
+ AS_HELP_STRING([--enable-dsptranscode],
+ [Enable DSP transcoding code for sysmoBTS [default=no]]),
+ [enable_dsptranscode="yes"],[enable_dsptranscode="no"])
+AC_MSG_CHECKING([whether to enable sysmoBTS DSP transcoding])
+AC_MSG_RESULT([$enable_dsptranscode])
+AM_CONDITIONAL(BUILD_MGCP_TRANSCODING_DSP, test "x$enable_dsptranscode" = "xyes")
+
+
+
found_libgtp=yes
PKG_CHECK_MODULES(LIBGTP, libgtp >= 0.92, , found_libgtp=no)
@@ -177,6 +188,7 @@ AC_MSG_CHECKING([whether to enable VTY/CTRL tests])
AC_MSG_RESULT([$enable_ext_tests])
AM_CONDITIONAL(ENABLE_EXT_TESTS, test "x$enable_ext_tests" = "xyes")
+
dnl Generate the output
AM_CONFIG_HEADER(bscconfig.h)
diff --git a/openbsc/include/openbsc/mgcp_transcode.h b/openbsc/include/openbsc/mgcp_transcode.h
index 02b039d0e..af5d8e29a 100644
--- a/openbsc/include/openbsc/mgcp_transcode.h
+++ b/openbsc/include/openbsc/mgcp_transcode.h
@@ -1,5 +1,6 @@
/*
- * (C) 2014 by On-Waves
+ * (C) 2014-2016 by On-Waves
+ * (C) 2016 Holger Hans Peter Freyther
* All Rights Reserved
*
* This program is free software; you can redistribute it and/or modify
@@ -89,4 +90,10 @@ int mgcp_transcoding_process_rtp(struct mgcp_endpoint *endp,
char *data, int *len, int buf_size);
int mgcp_transcoding_get_frame_size(void *state_, int nsamples, int dst);
+
+
+#ifdef BUILD_MGCP_TRANSCODING_DSP
+int mgcp_transcoding_dsp_init(void);
+#endif
+
#endif /* OPENBSC_MGCP_TRANSCODE_H */
diff --git a/openbsc/src/libmgcp/Makefile.am b/openbsc/src/libmgcp/Makefile.am
index 4403d6086..6fed8e6fd 100644
--- a/openbsc/src/libmgcp/Makefile.am
+++ b/openbsc/src/libmgcp/Makefile.am
@@ -13,4 +13,7 @@ libmgcp_a_SOURCES = mgcp_protocol.c mgcp_network.c mgcp_vty.c mgcp_osmux.c \
if BUILD_MGCP_TRANSCODING
libmgcp_a_SOURCES += mgcp_transcode.c
+if BUILD_MGCP_TRANSCODING_DSP
+ libmgcp_a_SOURCES += mgcp_transcode_dsp.c
+endif
endif
diff --git a/openbsc/src/libmgcp/mgcp_transcode_dsp.c b/openbsc/src/libmgcp/mgcp_transcode_dsp.c
new file mode 100644
index 000000000..5e47d35ed
--- /dev/null
+++ b/openbsc/src/libmgcp/mgcp_transcode_dsp.c
@@ -0,0 +1,146 @@
+/*
+ * (C) 2016 by Holger Hans Peter Freyther
+ * (C) 2016 by On-Waves
+ * All Rights Reserved
+ *
+ * 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 <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include <openbsc/mgcp.h>
+#include <openbsc/mgcp_internal.h>
+#include <openbsc/mgcp_transcode.h>
+#include <openbsc/debug.h>
+
+#include <osmocom/core/write_queue.h>
+
+#include <sysmocom/femtobts/trau.h>
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <errno.h>
+#include <unistd.h>
+
+static const struct value_string trau_names[] = {
+ { Trau_PrimId_GetCapReq, "Trau_GetCapReq" },
+ { Trau_PrimId_GetCapCnf, "Trau_GetCapCnf" },
+ { Trau_PrimId_AllocChanReq, "Trau_AllocChanReq" },
+ { Trau_PrimId_AllocChanCnf, "Trau_AllocChanCnf" },
+ { Trau_PrimId_FreeChanReq, "Trau_FreeChanReq" },
+ { Trau_PrimId_SetupChanReq, "Trau_SetupChanReq" },
+ { Trau_PrimId_SetupChanCnf, "Trau_SetupChan_Cnf" },
+ { Trau_PrimId_ApplyReq, "Trau_ApplyReq" },
+ { Trau_PrimId_ApplyCnf, "Trau_ApplyCnf" },
+ { 0, NULL },
+};
+
+enum {
+ STATE_NONE,
+ STATE_ALLOCATED,
+ STATE_BROKEN,
+};
+
+struct dsp_transcode_chan {
+ int queue_id;
+ int state;
+ struct llist_head queue;
+};
+
+struct dsp_transcode_mgr {
+ /* FDs for DSP->ARM, ARM->DSP of the trau queue */
+ struct osmo_wqueue trau_a2d;
+ struct osmo_fd trau_d2a;
+
+ /* All the channels for transcoding */
+ struct dsp_transcode_chan chans[TRAU_MAX_CHANNEL];
+};
+
+static struct dsp_transcode_mgr g_dsp;
+
+static int trau_arm2dsp_cb(struct osmo_fd *fd, struct msgb *msg)
+{
+ int rc;
+
+ rc = write(fd->fd, msg->l2h, msgb_l2len(msg));
+ if (rc != msgb_l2len(msg)) {
+ LOGP(DMGCP, LOGL_ERROR,
+ "Failed to write frame to DSP %d/%d%s\n",
+ rc, errno, strerror(errno));
+ return -1;
+ }
+ return 0;
+}
+
+
+static void dispatch_trau(struct dsp_transcode_mgr *mgr, struct Trau_Prim *trau)
+{
+ switch (trau->id) {
+ case Trau_PrimId_AllocChanCnf:
+ break;
+ //case Trau_PrimId_FreeChanCnf:
+ // this doesn't exist but should
+ }
+}
+
+static int trau_dsp2arm_cb(struct osmo_fd *fd, unsigned int what)
+{
+ struct Trau_Prim trau;
+ int rc;
+
+ if (!(what & BSC_FD_READ)) {
+ LOGP(DMGCP, LOGL_ERROR,
+ "Activated for not read: %u\n", what);
+ return -1;
+ }
+
+ rc = read(fd->fd, &trau, sizeof(trua));
+ if (rc != sizeof(trau)) {
+ LOGP(DMGCP, LOGL_ERROR,
+ "Failed to to read trau reply.\n");
+ return -1;
+ }
+
+ dispatch_trau(&g_dsp, &trau);
+ return 0;
+}
+
+int mgcp_transcoding_dsp_init(void)
+{
+ int i;
+
+ memset(&g_dsp, 0, sizeof(g_dsp));
+ for (i = 0; i < ARRAY_SIZE(g_dsp.chans); ++i)
+ INIT_LLIST_HEAD(&g_dsp.chans[i].queue);
+
+ osmo_wqueue_init(&g_dsp.trau_a2d, 20);
+ g_dsp.trau_a2d.bfd.data = &g_dsp;
+ g_dsp.trau_a2d.write_cb = trau_arm2dsp_cb;
+ g_dsp.trau_a2d.bfd.fd = open("/dev/msgq/trau_arm2dsp", O_WRONLY);
+ if (g_dsp.trau_a2d.bfd.fd < 0) {
+ LOGP(DMGCP, LOGL_ERROR, "Failed to open arm2dsp queue: %d/%s\n",
+ g_dsp.trau_a2d.bfd.fd, strerror(errno));
+ return 1;
+ }
+
+ g_dsp.trau_d2a.data = &g_dsp;
+ g_dsp.trau_d2a.cb = trau_dsp2arm_cb;
+ g_dsp.trau_d2a.fd = open("/dev/msgq/trau_dsp2arm", O_RDONLY);
+ if (g_dsp.trau_d2a.fd < 0) {
+ close(g_dsp.trau_a2d.bfd.fd);
+ return 2;
+ }
+
+ return 0;
+}