Hoernchen has submitted this change. ( 
https://gerrit.osmocom.org/c/osmo-trx/+/32951 )

Change subject: ms: rearrange internal trxcon<->phy if
......................................................................

ms: rearrange internal trxcon<->phy if

Change-Id: I20aef3844f7699e164fe089358aa7e2325608c85
---
M Transceiver52M/Makefile.am
M Transceiver52M/ms/l1ctl_server_cb.cpp
M Transceiver52M/ms/ms_rx_lower.cpp
A Transceiver52M/ms/ms_trxcon_if.cpp
A Transceiver52M/ms/ms_trxcon_if.h
M Transceiver52M/ms/ms_upper.cpp
M Transceiver52M/ms/ms_upper.h
7 files changed, 213 insertions(+), 172 deletions(-)

Approvals:
  pespin: Looks good to me, but someone else must approve
  Jenkins Builder: Verified
  laforge: Looks good to me, approved




diff --git a/Transceiver52M/Makefile.am b/Transceiver52M/Makefile.am
index 296ff05..65c8ebe 100644
--- a/Transceiver52M/Makefile.am
+++ b/Transceiver52M/Makefile.am
@@ -82,19 +82,27 @@
        $(top_builddir)/osmocom-bb/src/host/trxcon/src/.libs/libl1sched.a \
        $(LIBOSMOCODING_LIBS)

-MS_SOURCES = \
+MS_LOWER_SRC = \
        ms/sch.c \
        ms/ms.cpp \
        ms/ms_rx_lower.cpp \
        grgsm_vitac/grgsm_vitac.cpp \
        grgsm_vitac/viterbi_detector.cc

+MS_UPPER_SRC = \
+       ms/ms_upper.cpp \
+       ms/l1ctl_server.c \
+       ms/logging.c \
+       ms/l1ctl_server_cb.cpp \
+       ms/ms_trxcon_if.cpp
+
 noinst_HEADERS += \
        ms/ms.h \
        ms/bladerf_specific.h \
        ms/uhd_specific.h \
        ms/ms_rx_burst.h \
        ms/ms_upper.h \
+       ms/ms_trxcon_if.h \
        ms/itrq.h \
        ms/sch.h \
        ms/threadpool.h \
@@ -117,7 +125,7 @@

 if ENABLE_MS_TRX
 bin_PROGRAMS += osmo-trx-ms-uhd
-osmo_trx_ms_uhd_SOURCES = $(MS_SOURCES) ms/ms_upper.cpp ms/l1ctl_server.c 
ms/logging.c ms/l1ctl_server_cb.cpp
+osmo_trx_ms_uhd_SOURCES = $(MS_LOWER_SRC) $(MS_UPPER_SRC)
 osmo_trx_ms_uhd_LDADD = \
        $(builddir)/device/uhd/libdevice.la \
        $(COMMON_LDADD) \
@@ -126,7 +134,7 @@
 osmo_trx_ms_uhd_CPPFLAGS  = $(AM_CPPFLAGS) $(UHD_CFLAGS) -DBUILDUHD

 bin_PROGRAMS += osmo-trx-syncthing-uhd
-osmo_trx_syncthing_uhd_SOURCES = $(MS_SOURCES) ms/ms_rx_burst_test.cpp
+osmo_trx_syncthing_uhd_SOURCES = $(MS_LOWER_SRC) ms/ms_rx_burst_test.cpp
 osmo_trx_syncthing_uhd_LDADD = \
        $(builddir)/device/uhd/libdevice.la \
        $(COMMON_LDADD) \
@@ -167,7 +175,7 @@

 if ENABLE_MS_TRX
 bin_PROGRAMS += osmo-trx-ms-blade
-osmo_trx_ms_blade_SOURCES = $(MS_SOURCES) ms/ms_upper.cpp ms/l1ctl_server.c 
ms/logging.c ms/l1ctl_server_cb.cpp
+osmo_trx_ms_blade_SOURCES = $(MS_LOWER_SRC) $(MS_UPPER_SRC)
 osmo_trx_ms_blade_LDADD = \
        $(builddir)/device/bladerf/libdevice.la \
        $(COMMON_LDADD) \
@@ -176,7 +184,7 @@
 osmo_trx_ms_blade_CPPFLAGS  = $(AM_CPPFLAGS) $(BLADE_CFLAGS) -DBUILDBLADE

 bin_PROGRAMS += osmo-trx-syncthing-blade
-osmo_trx_syncthing_blade_SOURCES = $(MS_SOURCES) ms/ms_rx_burst_test.cpp
+osmo_trx_syncthing_blade_SOURCES = $(MS_LOWER_SRC) ms/ms_rx_burst_test.cpp
 osmo_trx_syncthing_blade_LDADD =  \
        $(builddir)/device/bladerf/libdevice.la \
        $(COMMON_LDADD) \
diff --git a/Transceiver52M/ms/l1ctl_server_cb.cpp 
b/Transceiver52M/ms/l1ctl_server_cb.cpp
index 4121451..42f64ac 100644
--- a/Transceiver52M/ms/l1ctl_server_cb.cpp
+++ b/Transceiver52M/ms/l1ctl_server_cb.cpp
@@ -24,13 +24,10 @@
 #include <osmocom/bb/trxcon/trxcon_fsm.h>
 #include <osmocom/bb/trxcon/l1ctl_server.h>
 }
+#include "ms_trxcon_if.h"

 static struct l1ctl_server_cfg server_cfg;
 static struct l1ctl_server *server = NULL;
-namespace trxcon
-{
-extern struct trxcon_inst *g_trxcon;
-}

 static int l1ctl_rx_cb(struct l1ctl_client *l1c, struct msgb *msg)
 {
@@ -41,9 +38,9 @@

 static void l1ctl_conn_accept_cb(struct l1ctl_client *l1c)
 {
-       l1c->log_prefix = talloc_strdup(l1c, trxcon::g_trxcon->log_prefix);
-       l1c->priv = trxcon::g_trxcon;
-       trxcon::g_trxcon->l2if = l1c;
+       l1c->log_prefix = talloc_strdup(l1c, g_trxcon->log_prefix);
+       l1c->priv = g_trxcon;
+       g_trxcon->l2if = l1c;
 }

 static void l1ctl_conn_close_cb(struct l1ctl_client *l1c)
@@ -56,17 +53,13 @@
        osmo_fsm_inst_dispatch(trxcon->fi, TRXCON_EV_L2IF_FAILURE, NULL);
 }

-namespace trxcon
-{
 bool trxc_l1ctl_init(void *tallctx)
 {
        /* Start the L1CTL server */
        server_cfg = (struct l1ctl_server_cfg){
                /* TODO: make path configurable */
-               .sock_path = "/tmp/osmocom_l2",
-               .num_clients_max = 1,
-               .conn_read_cb = &l1ctl_rx_cb,
-               .conn_accept_cb = &l1ctl_conn_accept_cb,
+               .sock_path = "/tmp/osmocom_l2",        .num_clients_max = 1,
+               .conn_read_cb = &l1ctl_rx_cb,          .conn_accept_cb = 
&l1ctl_conn_accept_cb,
                .conn_close_cb = &l1ctl_conn_close_cb,
        };

@@ -76,4 +69,3 @@
        }
        return true;
 }
-} // namespace trxcon
\ No newline at end of file
diff --git a/Transceiver52M/ms/ms_rx_lower.cpp 
b/Transceiver52M/ms/ms_rx_lower.cpp
index dc0d56d..3a7e6ec 100644
--- a/Transceiver52M/ms/ms_rx_lower.cpp
+++ b/Transceiver52M/ms/ms_rx_lower.cpp
@@ -19,8 +19,6 @@
  *
  */

-#include "sigProcLib.h"
-#include "signalVector.h"
 #include <atomic>
 #include <cassert>
 #include <complex>
diff --git a/Transceiver52M/ms/ms_trxcon_if.cpp 
b/Transceiver52M/ms/ms_trxcon_if.cpp
new file mode 100644
index 0000000..7de9710
--- /dev/null
+++ b/Transceiver52M/ms/ms_trxcon_if.cpp
@@ -0,0 +1,78 @@
+/*
+ * (C) 2023 by sysmocom s.f.m.c. GmbH <[email protected]>
+ * All Rights Reserved
+ *
+ * Author: Eric Wild <[email protected]>
+ *
+ * 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 <atomic>
+#include "ms_trxcon_if.h"
+extern "C" {
+#include <osmocom/bb/trxcon/trxcon.h>
+#include <osmocom/bb/trxcon/l1ctl_server.h>
+#include <osmocom/core/panic.h>
+}
+
+extern tx_queue_t txq;
+extern cmd_queue_t cmdq_to_phy;
+extern cmdr_queue_t cmdq_from_phy;
+extern std::atomic<bool> g_exit_flag;
+// trxcon C call(back) if
+extern "C" {
+int trxcon_phyif_handle_burst_req(void *phyif, const struct 
trxcon_phyif_burst_req *br)
+{
+       if (br->burst_len == 0) // dummy/nope
+               return 0;
+       OSMO_ASSERT(br->burst != 0);
+
+       internal_q_tx_buf b(br);
+       if (!g_exit_flag)
+               txq.spsc_push(&b);
+       return 0;
+}
+
+int trxcon_phyif_handle_cmd(void *phyif, const struct trxcon_phyif_cmd *cmd)
+{
+#ifdef TXDEBUG
+       DBGLG() << "TOP C: " << cmd2str(cmd->type) << std::endl;
+#endif
+       if (!g_exit_flag)
+               cmdq_to_phy.spsc_push(cmd);
+       // q for resp polling happens in main loop
+       return 0;
+}
+
+void trxcon_phyif_close(void *phyif)
+{
+}
+
+void trxcon_l1ctl_close(struct trxcon_inst *trxcon)
+{
+       /* Avoid use-after-free: both *fi and *trxcon are children of
+        * the L2IF (L1CTL connection), so we need to re-parent *fi
+        * to NULL before calling l1ctl_client_conn_close(). */
+       talloc_steal(NULL, trxcon->fi);
+       l1ctl_client_conn_close((struct l1ctl_client *)trxcon->l2if);
+}
+
+int trxcon_l1ctl_send(struct trxcon_inst *trxcon, struct msgb *msg)
+{
+       struct l1ctl_client *l1c = (struct l1ctl_client *)trxcon->l2if;
+
+       return l1ctl_client_send(l1c, msg);
+}
+}
diff --git a/Transceiver52M/ms/ms_trxcon_if.h b/Transceiver52M/ms/ms_trxcon_if.h
new file mode 100644
index 0000000..9879d1a
--- /dev/null
+++ b/Transceiver52M/ms/ms_trxcon_if.h
@@ -0,0 +1,42 @@
+#pragma once
+/*
+ * (C) 2023 by sysmocom s.f.m.c. GmbH <[email protected]>
+ * All Rights Reserved
+ *
+ * Author: Eric Wild <[email protected]>
+ *
+ * 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 "ms.h"
+extern "C" {
+#include <osmocom/bb/trxcon/phyif.h>
+}
+
+extern struct trxcon_inst *g_trxcon;
+struct internal_q_tx_buf {
+       trxcon_phyif_burst_req r;
+       uint8_t buf[148];
+       internal_q_tx_buf() = default;
+       internal_q_tx_buf(const internal_q_tx_buf &) = delete;
+       internal_q_tx_buf &operator=(const internal_q_tx_buf &) = default;
+       internal_q_tx_buf(const struct trxcon_phyif_burst_req *br) : r(*br)
+       {
+               memcpy(buf, (void *)br->burst, br->burst_len);
+       }
+};
+using tx_queue_t = spsc_cond<8 * 1, internal_q_tx_buf, true, false>;
+using cmd_queue_t = spsc_cond<8 * 1, trxcon_phyif_cmd, true, false>;
+using cmdr_queue_t = spsc_cond<8 * 1, trxcon_phyif_rsp, false, false>;
diff --git a/Transceiver52M/ms/ms_upper.cpp b/Transceiver52M/ms/ms_upper.cpp
index cae1893..a10d542 100644
--- a/Transceiver52M/ms/ms_upper.cpp
+++ b/Transceiver52M/ms/ms_upper.cpp
@@ -19,6 +19,7 @@
  *
  */

+#include <csignal>
 #include "sigProcLib.h"
 #include "ms.h"
 #include <signalVector.h>
@@ -27,70 +28,30 @@
 #include <grgsm_vitac/grgsm_vitac.h>

 extern "C" {
-#include <stdio.h>
-#include <stdlib.h>
-#include <stdint.h>
-#include <string.h>
-#include <getopt.h>
-#include <unistd.h>
-#include <signal.h>
-#include <errno.h>
-#include <time.h>
-#include <fenv.h>

 #include "sch.h"
 #include "convolve.h"
 #include "convert.h"

+#include <osmocom/gsm/gsm_utils.h>
+#include <osmocom/bb/trxcon/trxcon.h>
+#include <osmocom/bb/trxcon/trxcon_fsm.h>
+#include <osmocom/bb/trxcon/l1ctl_server.h>
+
+extern void trxc_log_init(void *tallctx);
 #ifdef LSANDEBUG
 void __lsan_do_recoverable_leak_check();
 #endif
 }

+#include "ms_trxcon_if.h"
 #include "ms_upper.h"

-namespace trxcon
-{
-extern "C" {
-#include <osmocom/core/fsm.h>
-#include <osmocom/core/msgb.h>
-#include <osmocom/core/talloc.h>
-#include <osmocom/core/signal.h>
-#include <osmocom/core/select.h>
-#include <osmocom/gsm/gsm_utils.h>
-
-#include <osmocom/core/logging.h>
-#include <osmocom/bb/trxcon/logging.h>
-
-#include <osmocom/bb/trxcon/trxcon.h>
-#include <osmocom/bb/trxcon/trxcon_fsm.h>
-#include <osmocom/bb/trxcon/phyif.h>
-#include <osmocom/bb/trxcon/l1ctl_server.h>
-}
-struct trxcon_inst *g_trxcon;
-// trx_instance *trxcon_instance; // local handle
-struct internal_q_tx_buf {
-       trxcon_phyif_burst_req r;
-       uint8_t buf[148];
-       internal_q_tx_buf() = default;
-       internal_q_tx_buf(const internal_q_tx_buf &) = delete;
-       internal_q_tx_buf &operator=(const internal_q_tx_buf &) = default;
-       internal_q_tx_buf(const struct trxcon::trxcon_phyif_burst_req *br) : 
r(*br)
-       {
-               memcpy(buf, (void *)br->burst, br->burst_len);
-       }
-};
-using tx_queue_t = spsc_cond<8 * 1, internal_q_tx_buf, true, false>;
-using cmd_queue_t = spsc_cond<8 * 1, trxcon_phyif_cmd, true, false>;
-using cmdr_queue_t = spsc_cond<8 * 1, trxcon_phyif_rsp, false, false>;
-static tx_queue_t txq;
-static cmd_queue_t cmdq_to_phy;
-static cmdr_queue_t cmdq_from_phy;
-
 extern bool trxc_l1ctl_init(void *tallctx);
-
-} // namespace trxcon
-extern "C" void trxc_log_init(void *tallctx);
+struct trxcon_inst *g_trxcon;
+tx_queue_t txq;
+cmd_queue_t cmdq_to_phy;
+cmdr_queue_t cmdq_from_phy;

 #ifdef LOG
 #undef LOG
@@ -138,12 +99,12 @@
                // set_upper_ready(true) needs to happen during cmd handling:
                // the main loop is driven by rx, so unless rx is on AND 
transceiver is on we get stuck..
                driveReceiveFIFO();
-               trxcon::osmo_select_main(1);
+               osmo_select_main(1);

-               trxcon::trxcon_phyif_rsp r;
-               if (trxcon::cmdq_from_phy.spsc_pop(&r)) {
+               trxcon_phyif_rsp r;
+               if (cmdq_from_phy.spsc_pop(&r)) {
                        DBGLG() << "HAVE RESP:" << r.type << std::endl;
-                       trxcon_phyif_handle_rsp(trxcon::g_trxcon, &r);
+                       trxcon_phyif_handle_rsp(g_trxcon, &r);
                }
        }
        set_upper_ready(false);
@@ -196,9 +157,9 @@
        const auto is_sch = gsm_sch_check_ts(wTime.TN(), wTime.FN());
        const auto is_fcch = gsm_fcch_check_ts(wTime.TN(), wTime.FN());

-       trxcon::trxcon_phyif_rtr_ind i = { static_cast<uint32_t>(wTime.FN()), 
static_cast<uint8_t>(wTime.TN()) };
-       trxcon::trxcon_phyif_rtr_rsp r = {};
-       trxcon_phyif_handle_rtr_ind(trxcon::g_trxcon, &i, &r);
+       trxcon_phyif_rtr_ind i = { static_cast<uint32_t>(wTime.FN()), 
static_cast<uint8_t>(wTime.TN()) };
+       trxcon_phyif_rtr_rsp r = {};
+       trxcon_phyif_handle_rtr_ind(g_trxcon, &i, &r);
        if (!(r.flags & TRXCON_PHYIF_RTR_F_ACTIVE))
                return false;

@@ -265,28 +226,28 @@
                return;

        if (pullRadioVector(burstTime, RSSI, TOA)) {
-               trxcon::trxcon_phyif_burst_ind bi;
+               trxcon_phyif_burst_ind bi;
                bi.fn = burstTime.FN();
                bi.tn = burstTime.TN();
                bi.rssi = RSSI;
                bi.toa256 = TOA;
                bi.burst = (sbit_t *)demodded_softbits;
                bi.burst_len = sizeof(demodded_softbits);
-               trxcon_phyif_handle_burst_ind(trxcon::g_trxcon, &bi);
+               trxcon_phyif_handle_burst_ind(g_trxcon, &bi);
        }

-       struct trxcon::trxcon_phyif_rts_ind rts {
+       struct trxcon_phyif_rts_ind rts {
                static_cast<uint32_t>(burstTime.FN()), 
static_cast<uint8_t>(burstTime.TN())
        };
-       trxcon_phyif_handle_rts_ind(trxcon::g_trxcon, &rts);
+       trxcon_phyif_handle_rts_ind(g_trxcon, &rts);
 }

 void upper_trx::driveTx()
 {
-       trxcon::internal_q_tx_buf e;
+       internal_q_tx_buf e;
        static BitVector newBurst(sizeof(e.buf));
-       while (!trxcon::txq.spsc_pop(&e)) {
-               trxcon::txq.spsc_prep_pop();
+       while (!txq.spsc_pop(&e)) {
+               txq.spsc_prep_pop();
        }

        // ensure our tx cb is tickled and can exit
@@ -295,7 +256,7 @@
                return;
        }

-       trxcon::internal_q_tx_buf *burst = &e;
+       internal_q_tx_buf *burst = &e;

 #ifdef TXDEBUG
        DBGLG() << "got burst!" << burst->r.fn << ":" << burst->ts << " 
current: " << timekeeper.gsmtime().FN()
@@ -333,31 +294,31 @@
 }

 #ifdef TXDEBUG
-static const char *cmd2str(trxcon::trxcon_phyif_cmd_type c)
+static const char *cmd2str(trxcon_phyif_cmd_type c)
 {
        switch (c) {
-       case trxcon::TRXCON_PHYIF_CMDT_RESET:
+       case TRXCON_PHYIF_CMDT_RESET:
                return "TRXCON_PHYIF_CMDT_RESET";
-       case trxcon::TRXCON_PHYIF_CMDT_POWERON:
+       case TRXCON_PHYIF_CMDT_POWERON:
                return "TRXCON_PHYIF_CMDT_POWERON";
-       case trxcon::TRXCON_PHYIF_CMDT_POWEROFF:
+       case TRXCON_PHYIF_CMDT_POWEROFF:
                return "TRXCON_PHYIF_CMDT_POWEROFF";
-       case trxcon::TRXCON_PHYIF_CMDT_MEASURE:
+       case TRXCON_PHYIF_CMDT_MEASURE:
                return "TRXCON_PHYIF_CMDT_MEASURE";
-       case trxcon::TRXCON_PHYIF_CMDT_SETFREQ_H0:
+       case TRXCON_PHYIF_CMDT_SETFREQ_H0:
                return "TRXCON_PHYIF_CMDT_SETFREQ_H0";
-       case trxcon::TRXCON_PHYIF_CMDT_SETFREQ_H1:
+       case TRXCON_PHYIF_CMDT_SETFREQ_H1:
                return "TRXCON_PHYIF_CMDT_SETFREQ_H1";
-       case trxcon::TRXCON_PHYIF_CMDT_SETSLOT:
+       case TRXCON_PHYIF_CMDT_SETSLOT:
                return "TRXCON_PHYIF_CMDT_SETSLOT";
-       case trxcon::TRXCON_PHYIF_CMDT_SETTA:
+       case TRXCON_PHYIF_CMDT_SETTA:
                return "TRXCON_PHYIF_CMDT_SETTA";
        default:
                return "UNKNOWN COMMAND!";
        }
 }

-static void print_cmd(trxcon::trxcon_phyif_cmd_type c)
+static void print_cmd(trxcon_phyif_cmd_type c)
 {
        DBGLG() << cmd2str(c) << std::endl;
 }
@@ -365,10 +326,10 @@

 bool upper_trx::driveControl()
 {
-       trxcon::trxcon_phyif_rsp r;
-       trxcon::trxcon_phyif_cmd cmd;
-       while (!trxcon::cmdq_to_phy.spsc_pop(&cmd)) {
-               trxcon::cmdq_to_phy.spsc_prep_pop();
+       trxcon_phyif_rsp r;
+       trxcon_phyif_cmd cmd;
+       while (!cmdq_to_phy.spsc_pop(&cmd)) {
+               cmdq_to_phy.spsc_prep_pop();
        }

        if (g_exit_flag)
@@ -379,87 +340,41 @@
 #endif

        switch (cmd.type) {
-       case trxcon::TRXCON_PHYIF_CMDT_RESET:
+       case TRXCON_PHYIF_CMDT_RESET:
                set_ta(0);
                break;
-       case trxcon::TRXCON_PHYIF_CMDT_POWERON:
+       case TRXCON_PHYIF_CMDT_POWERON:
                if (!mOn) {
                        mOn = true;
                        set_upper_ready(true);
                }
                break;
-       case trxcon::TRXCON_PHYIF_CMDT_POWEROFF:
+       case TRXCON_PHYIF_CMDT_POWEROFF:
                break;
-       case trxcon::TRXCON_PHYIF_CMDT_MEASURE:
-               r.type = 
trxcon::trxcon_phyif_cmd_type::TRXCON_PHYIF_CMDT_MEASURE;
+       case TRXCON_PHYIF_CMDT_MEASURE:
+               r.type = trxcon_phyif_cmd_type::TRXCON_PHYIF_CMDT_MEASURE;
                r.param.measure.band_arfcn = cmd.param.measure.band_arfcn;
                // FIXME: do we want to measure anything, considering the 
transceiver just syncs by.. syncing?
                r.param.measure.dbm = -80;
-               tuneRx(trxcon::gsm_arfcn2freq10(cmd.param.measure.band_arfcn, 
0) * 1000 * 100);
-               tuneTx(trxcon::gsm_arfcn2freq10(cmd.param.measure.band_arfcn, 
1) * 1000 * 100);
-               trxcon::cmdq_from_phy.spsc_push(&r);
+               tuneRx(gsm_arfcn2freq10(cmd.param.measure.band_arfcn, 0) * 1000 
* 100);
+               tuneTx(gsm_arfcn2freq10(cmd.param.measure.band_arfcn, 1) * 1000 
* 100);
+               cmdq_from_phy.spsc_push(&r);
                break;
-       case trxcon::TRXCON_PHYIF_CMDT_SETFREQ_H0:
-               
tuneRx(trxcon::gsm_arfcn2freq10(cmd.param.setfreq_h0.band_arfcn, 0) * 1000 * 
100);
-               
tuneTx(trxcon::gsm_arfcn2freq10(cmd.param.setfreq_h0.band_arfcn, 1) * 1000 * 
100);
+       case TRXCON_PHYIF_CMDT_SETFREQ_H0:
+               tuneRx(gsm_arfcn2freq10(cmd.param.setfreq_h0.band_arfcn, 0) * 
1000 * 100);
+               tuneTx(gsm_arfcn2freq10(cmd.param.setfreq_h0.band_arfcn, 1) * 
1000 * 100);
                break;
-       case trxcon::TRXCON_PHYIF_CMDT_SETFREQ_H1:
+       case TRXCON_PHYIF_CMDT_SETFREQ_H1:
                break;
-       case trxcon::TRXCON_PHYIF_CMDT_SETSLOT:
+       case TRXCON_PHYIF_CMDT_SETSLOT:
                break;
-       case trxcon::TRXCON_PHYIF_CMDT_SETTA:
+       case TRXCON_PHYIF_CMDT_SETTA:
                set_ta(cmd.param.setta.ta);
                break;
        }
        return false;
 }

-// trxcon C call(back) if
-extern "C" {
-int trxcon_phyif_handle_burst_req(void *phyif, const struct 
trxcon::trxcon_phyif_burst_req *br)
-{
-       if (br->burst_len == 0) // dummy/nope
-               return 0;
-       OSMO_ASSERT(br->burst != 0);
-
-       trxcon::internal_q_tx_buf b(br);
-       if (!g_exit_flag)
-               trxcon::txq.spsc_push(&b);
-       return 0;
-}
-
-int trxcon_phyif_handle_cmd(void *phyif, const struct trxcon::trxcon_phyif_cmd 
*cmd)
-{
-#ifdef TXDEBUG
-       DBGLG() << "TOP C: " << cmd2str(cmd->type) << std::endl;
-#endif
-       if (!g_exit_flag)
-               trxcon::cmdq_to_phy.spsc_push(cmd);
-       // q for resp polling happens in main loop
-       return 0;
-}
-
-void trxcon_phyif_close(void *phyif)
-{
-}
-
-void trxcon_l1ctl_close(struct trxcon::trxcon_inst *trxcon)
-{
-       /* Avoid use-after-free: both *fi and *trxcon are children of
-        * the L2IF (L1CTL connection), so we need to re-parent *fi
-        * to NULL before calling l1ctl_client_conn_close(). */
-       talloc_steal(NULL, trxcon->fi);
-       trxcon::l1ctl_client_conn_close((struct trxcon::l1ctl_client 
*)trxcon->l2if);
-}
-
-int trxcon_l1ctl_send(struct trxcon::trxcon_inst *trxcon, struct trxcon::msgb 
*msg)
-{
-       struct trxcon::l1ctl_client *l1c = (struct trxcon::l1ctl_client 
*)trxcon->l2if;
-
-       return trxcon::l1ctl_client_send(l1c, msg);
-}
-}
-
 void sighandler(int sigset)
 {
        // we might get a sigpipe in case the l1ctl ud socket disconnects 
because mobile quits
@@ -468,10 +383,10 @@

                // we know the flag is atomic and it prevents the trxcon cb 
handlers from writing
                // to the queues, so submit some trash to unblock the threads & 
exit
-               trxcon::trxcon_phyif_cmd cmd = {};
-               trxcon::internal_q_tx_buf b = {};
-               trxcon::txq.spsc_push(&b);
-               trxcon::cmdq_to_phy.spsc_push(&cmd);
+               trxcon_phyif_cmd cmd = {};
+               internal_q_tx_buf b = {};
+               txq.spsc_push(&b);
+               cmdq_to_phy.spsc_push(&cmd);
                msleep(200);

                return;
@@ -484,13 +399,13 @@
        signal(SIGPIPE, sighandler);
        signal(SIGINT, sighandler);

-       trxcon::msgb_talloc_ctx_init(tall_trxcon_ctx, 0);
+       msgb_talloc_ctx_init(tall_trxcon_ctx, 0);
        trxc_log_init(tall_trxcon_ctx);

-       trxcon::g_trxcon = trxcon::trxcon_inst_alloc(tall_trxcon_ctx, 0, 0);
-       trxcon::g_trxcon->gsmtap = nullptr;
-       trxcon::g_trxcon->phyif = nullptr;
-       trxcon::g_trxcon->phy_quirks.fbsb_extend_fns = 866; // 4 seconds, known 
to work.
+       g_trxcon = trxcon_inst_alloc(tall_trxcon_ctx, 0, 0);
+       g_trxcon->gsmtap = nullptr;
+       g_trxcon->phyif = nullptr;
+       g_trxcon->phy_quirks.fbsb_extend_fns = 866; // 4 seconds, known to work.

        convolve_init();
        convert_init();
@@ -508,7 +423,7 @@
        }
        trx->set_name_aff_sched(sched_params::thread_names::MAIN);

-       if (!trxcon::trxc_l1ctl_init(tall_trxcon_ctx)) {
+       if (!trxc_l1ctl_init(tall_trxcon_ctx)) {
                std::cerr << "Error initializing l1ctl, quitting.." << 
std::endl;
                return -1;
        }
diff --git a/Transceiver52M/ms/ms_upper.h b/Transceiver52M/ms/ms_upper.h
index fe20f6d..bc9bd14 100644
--- a/Transceiver52M/ms/ms_upper.h
+++ b/Transceiver52M/ms/ms_upper.h
@@ -24,7 +24,6 @@
 #include <arpa/inet.h>

 #include "GSMCommon.h"
-#include "radioClock.h"
 #include "ms.h"

 class upper_trx : public ms_trx {

--
To view, visit https://gerrit.osmocom.org/c/osmo-trx/+/32951
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-trx
Gerrit-Branch: master
Gerrit-Change-Id: I20aef3844f7699e164fe089358aa7e2325608c85
Gerrit-Change-Number: 32951
Gerrit-PatchSet: 4
Gerrit-Owner: Hoernchen <[email protected]>
Gerrit-Reviewer: Hoernchen <[email protected]>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <[email protected]>
Gerrit-Reviewer: pespin <[email protected]>
Gerrit-MessageType: merged

Reply via email to