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

host/trxcon: handle L1CTL_FBSB_REQ inside l1ctl.c

Change-Id: I5bcf39a20f1c6d3a2472e5e95725c6bb1c77bf5d
---
M src/host/trxcon/l1ctl.c
M src/host/trxcon/trxcon.c
M src/host/trxcon/trxcon.h
3 files changed, 19 insertions(+), 43 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmocom-bb refs/changes/99/6699/1

diff --git a/src/host/trxcon/l1ctl.c b/src/host/trxcon/l1ctl.c
index 3bcc5cb..4abec77 100644
--- a/src/host/trxcon/l1ctl.c
+++ b/src/host/trxcon/l1ctl.c
@@ -43,6 +43,9 @@
 #include "l1ctl_link.h"
 #include "l1ctl_proto.h"
 
+#include "trx_if.h"
+#include "sched_trx.h"
+
 extern void *tall_trx_ctx;
 extern struct osmo_fsm_inst *trxcon_fsm;
 
@@ -147,7 +150,7 @@
 
 static int l1ctl_rx_fbsb_req(struct l1ctl_link *l1l, struct msgb *msg)
 {
-       struct l1ctl_fbsb_req *fbsb, *fbsb_copy;
+       struct l1ctl_fbsb_req *fbsb;
        uint16_t band_arfcn;
        int rc = 0;
 
@@ -165,19 +168,22 @@
                gsm_band_name(gsm_arfcn2band(band_arfcn)),
                band_arfcn &~ ARFCN_FLAG_MASK);
 
-       /**
-        * We cannot simply pass a pointer to fbsb,
-        * because the memory will be freed.
-        *
-        * TODO: better solution?
-        */
-       fbsb_copy = talloc_memdup(l1l, fbsb, sizeof(struct l1ctl_fbsb_req));
-       if (fbsb_copy == NULL) {
-               rc = -EINVAL;
-               goto exit;
-       }
+       /* Reset L1 */
+       sched_trx_reset(l1l->trx);
 
-       osmo_fsm_inst_dispatch(trxcon_fsm, L1CTL_EVENT_FBSB_REQ, fbsb_copy);
+       /* Configure a single timeslot */
+       if (fbsb->ccch_mode == CCCH_MODE_COMBINED)
+               sched_trx_configure_ts(l1l->trx, 0, GSM_PCHAN_CCCH_SDCCH4);
+       else
+               sched_trx_configure_ts(l1l->trx, 0, GSM_PCHAN_CCCH);
+
+       /* Store current ARFCN */
+       l1l->trx->band_arfcn = band_arfcn;
+
+       /* Tune transceiver to required ARFCN */
+       trx_if_cmd_rxtune(l1l->trx, band_arfcn);
+       trx_if_cmd_txtune(l1l->trx, band_arfcn);
+       trx_if_cmd_poweron(l1l->trx);
 
 exit:
        msgb_free(msg);
diff --git a/src/host/trxcon/trxcon.c b/src/host/trxcon/trxcon.c
index de69db1..9bc98e5 100644
--- a/src/host/trxcon/trxcon.c
+++ b/src/host/trxcon/trxcon.c
@@ -74,31 +74,6 @@
 void *tall_trx_ctx = NULL;
 struct osmo_fsm_inst *trxcon_fsm;
 
-static void trxcon_handle_fbsb_req(struct l1ctl_fbsb_req *req)
-{
-       uint16_t band_arfcn;
-
-       /* Reset L1 */
-       sched_trx_reset(app_data.trx);
-
-       /* Configure a single timeslot */
-       if (req->ccch_mode == CCCH_MODE_COMBINED)
-               sched_trx_configure_ts(app_data.trx, 0, GSM_PCHAN_CCCH_SDCCH4);
-       else
-               sched_trx_configure_ts(app_data.trx, 0, GSM_PCHAN_CCCH);
-
-       /* Store current ARFCN */
-       band_arfcn = ntohs(req->band_arfcn);
-       app_data.trx->band_arfcn = band_arfcn;
-
-       /* Tune transceiver to required ARFCN */
-       trx_if_cmd_rxtune(app_data.trx, band_arfcn);
-       trx_if_cmd_txtune(app_data.trx, band_arfcn);
-       trx_if_cmd_poweron(app_data.trx);
-
-       talloc_free(req);
-}
-
 static void trxcon_fsm_idle_action(struct osmo_fsm_inst *fi,
        uint32_t event, void *data)
 {
@@ -127,9 +102,6 @@
                /* TODO: send proper reset type */
                l1ctl_tx_reset_conf(app_data.l1l, L1CTL_RES_T_BOOT);
                break;
-       case L1CTL_EVENT_FBSB_REQ:
-               trxcon_handle_fbsb_req((struct l1ctl_fbsb_req *) data);
-               break;
        case SCH_EVENT_DATA:
                l1ctl_tx_data_ind(app_data.l1l, (struct l1ctl_info_dl *) data);
        case TRX_EVENT_RSP_ERROR:
@@ -153,7 +125,6 @@
        [TRXCON_STATE_MANAGED] = {
                .in_event_mask = (
                        GEN_MASK(L1CTL_EVENT_DISCONNECT) |
-                       GEN_MASK(L1CTL_EVENT_FBSB_REQ) |
                        GEN_MASK(L1CTL_EVENT_RESET_REQ) |
                        GEN_MASK(TRX_EVENT_RESET_IND) |
                        GEN_MASK(TRX_EVENT_RSP_ERROR) |
diff --git a/src/host/trxcon/trxcon.h b/src/host/trxcon/trxcon.h
index da777a9..7b3a232 100644
--- a/src/host/trxcon/trxcon.h
+++ b/src/host/trxcon/trxcon.h
@@ -11,7 +11,6 @@
        /* L1CTL specific events */
        L1CTL_EVENT_CONNECT,
        L1CTL_EVENT_DISCONNECT,
-       L1CTL_EVENT_FBSB_REQ,
        L1CTL_EVENT_RESET_REQ,
 
        /* TRX specific events */

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I5bcf39a20f1c6d3a2472e5e95725c6bb1c77bf5d
Gerrit-PatchSet: 1
Gerrit-Project: osmocom-bb
Gerrit-Branch: master
Gerrit-Owner: Harald Welte <lafo...@gnumonks.org>

Reply via email to