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

host/trxcon/l1ctl.c: implement FBSB expire timer

Change-Id: I27f96cbe951de164fcecaf19f8305db5e5b20229
---
M src/host/trxcon/l1ctl.c
M src/host/trxcon/l1ctl_link.h
2 files changed, 48 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmocom-bb refs/changes/30/6730/1

diff --git a/src/host/trxcon/l1ctl.c b/src/host/trxcon/l1ctl.c
index 3e9732f..3098d9c 100644
--- a/src/host/trxcon/l1ctl.c
+++ b/src/host/trxcon/l1ctl.c
@@ -158,6 +158,10 @@
        /* Ask SCH handler not to send L1CTL_FBSB_CONF anymore */
        l1l->fbsb_conf_sent = 1;
 
+       /* Abort FBSB expire timer */
+       if (osmo_timer_pending(&l1l->fbsb_timer))
+               osmo_timer_del(&l1l->fbsb_timer);
+
        return l1ctl_link_send(l1l, msg);
 }
 
@@ -217,10 +221,45 @@
        return l1ctl_link_send(l1l, msg);
 }
 
+/* FBSB expire timer */
+static void fbsb_timer_cb(void *data)
+{
+       struct l1ctl_link *l1l = (struct l1ctl_link *) data;
+       struct l1ctl_fbsb_conf *conf;
+       struct l1ctl_info_dl *dl;
+       struct msgb *msg;
+       size_t len;
+
+       msg = l1ctl_alloc_msg(L1CTL_FBSB_CONF);
+       if (msg == NULL)
+               return;
+
+       LOGP(DL1C, LOGL_DEBUG, "Send FBSB Conf (result=255, bsic=0)\n");
+
+       /* Compose DL info header */
+       len = sizeof(struct l1ctl_info_dl);
+       dl = (struct l1ctl_info_dl *) msgb_put(msg, len);
+       memset(dl, 0x00, len);
+
+       /* Fill in current ARFCN */
+       dl->band_arfcn = htons(l1l->trx->band_arfcn);
+
+       /* Fill in FBSB payload: BSIC and sync result */
+       conf = (struct l1ctl_fbsb_conf *) msgb_put(msg, sizeof(*conf));
+       conf->result = 255;
+       conf->bsic = 0;
+
+       /* Ask SCH handler not to send L1CTL_FBSB_CONF anymore */
+       l1l->fbsb_conf_sent = 1;
+
+       l1ctl_link_send(l1l, msg);
+}
+
 static int l1ctl_rx_fbsb_req(struct l1ctl_link *l1l, struct msgb *msg)
 {
        struct l1ctl_fbsb_req *fbsb;
        uint16_t band_arfcn;
+       uint16_t timeout;
        int rc = 0;
 
        fbsb = (struct l1ctl_fbsb_req *) msg->l1h;
@@ -232,6 +271,7 @@
        }
 
        band_arfcn = ntohs(fbsb->band_arfcn);
+       timeout = ntohs(fbsb->timeout);
 
        LOGP(DL1C, LOGL_DEBUG, "Recv FBSB Req (%s %d)\n",
                gsm_band_name(gsm_arfcn2band(band_arfcn)),
@@ -257,6 +297,12 @@
        trx_if_cmd_txtune(l1l->trx, band_arfcn);
        trx_if_cmd_poweron(l1l->trx);
 
+       /* Start FBSB expire timer */
+       /* TODO: share FRAME_DURATION_uS=4615 from scheduler.c */
+       l1l->fbsb_timer.data = l1l;
+       l1l->fbsb_timer.cb = fbsb_timer_cb;
+       osmo_timer_schedule(&l1l->fbsb_timer, 0, timeout * 4615);
+
 exit:
        msgb_free(msg);
        return rc;
diff --git a/src/host/trxcon/l1ctl_link.h b/src/host/trxcon/l1ctl_link.h
index b310ee4..f20af93 100644
--- a/src/host/trxcon/l1ctl_link.h
+++ b/src/host/trxcon/l1ctl_link.h
@@ -2,6 +2,7 @@
 
 #include <osmocom/core/write_queue.h>
 #include <osmocom/core/select.h>
+#include <osmocom/core/timer.h>
 #include <osmocom/core/msgb.h>
 #include <osmocom/core/fsm.h>
 
@@ -25,6 +26,7 @@
        struct trx_instance *trx;
 
        /* L1CTL handlers specific */
+       struct osmo_timer_list fbsb_timer;
        uint8_t fbsb_conf_sent;
 };
 

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

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

Reply via email to