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

host/trxcon/l1ctl.c: fix incomplete msg in l1ctl_tx_fbsb_conf()

Previously, all L1CTL_FBSB_CONF messages were sent without
required l1ctl_info_dl header, what caused unpredictable
behavior on higher layers (L2 & L3). Let's fix it.

Change-Id: I8dae597bb4c09df36f80944434ce3624569f2cf8
---
M src/host/trxcon/l1ctl.c
M src/host/trxcon/l1ctl.h
M src/host/trxcon/sched_lchan_handlers.c
3 files changed, 38 insertions(+), 6 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmocom-bb refs/changes/28/6728/1

diff --git a/src/host/trxcon/l1ctl.c b/src/host/trxcon/l1ctl.c
index d5c3b57..9b0d35a 100644
--- a/src/host/trxcon/l1ctl.c
+++ b/src/host/trxcon/l1ctl.c
@@ -126,10 +126,13 @@
        return l1ctl_link_send(l1l, msg);
 }
 
-int l1ctl_tx_fbsb_conf(struct l1ctl_link *l1l, uint8_t result, uint8_t bsic)
+int l1ctl_tx_fbsb_conf(struct l1ctl_link *l1l, uint8_t result,
+       struct l1ctl_info_dl *dl_info, uint8_t bsic)
 {
        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)
@@ -138,6 +141,13 @@
        LOGP(DL1C, LOGL_DEBUG, "Send FBSB Conf (result=%u, bsic=%u)\n",
                result, bsic);
 
+       /* Copy DL info provided by handler */
+       len = sizeof(struct l1ctl_info_dl);
+       dl = (struct l1ctl_info_dl *) msgb_put(msg, len);
+       memcpy(dl, dl_info, len);
+       talloc_free(dl_info);
+
+       /* Fill in FBSB payload: BSIC and sync result */
        conf = (struct l1ctl_fbsb_conf *) msgb_put(msg, sizeof(*conf));
        conf->result = result;
        conf->bsic = bsic;
diff --git a/src/host/trxcon/l1ctl.h b/src/host/trxcon/l1ctl.h
index 165865a..af53b77 100644
--- a/src/host/trxcon/l1ctl.h
+++ b/src/host/trxcon/l1ctl.h
@@ -6,7 +6,8 @@
 #include "l1ctl_link.h"
 #include "l1ctl_proto.h"
 
-int l1ctl_tx_fbsb_conf(struct l1ctl_link *l1l, uint8_t result, uint8_t bsic);
+int l1ctl_tx_fbsb_conf(struct l1ctl_link *l1l, uint8_t result,
+       struct l1ctl_info_dl *dl_info, uint8_t bsic);
 int l1ctl_tx_ccch_mode_conf(struct l1ctl_link *l1l, uint8_t mode);
 int l1ctl_tx_pm_conf(struct l1ctl_link *l1l, uint16_t band_arfcn,
        int dbm, int last);
diff --git a/src/host/trxcon/sched_lchan_handlers.c 
b/src/host/trxcon/sched_lchan_handlers.c
index 49a28ef..64893d7 100644
--- a/src/host/trxcon/sched_lchan_handlers.c
+++ b/src/host/trxcon/sched_lchan_handlers.c
@@ -224,11 +224,32 @@
                return -EINVAL;
        }
 
+       /* We don't need to send L1CTL_FBSB_CONF */
+       if (trx->l1l->fbsb_conf_sent)
+               return 0;
+
        /* Send L1CTL_FBSB_CONF to higher layers */
-       if (!trx->l1l->fbsb_conf_sent) {
-               l1ctl_tx_fbsb_conf(trx->l1l, 0, bsic);
-               trx->bsic = bsic;
-       }
+       struct l1ctl_info_dl *data;
+       data = talloc_zero_size(ts, sizeof(struct l1ctl_info_dl));
+       if (data == NULL)
+               return -ENOMEM;
+
+       /* Fill in some downlink info */
+       data->chan_nr = trx_lchan_desc[chan].chan_nr | ts->index;
+       data->link_id = trx_lchan_desc[chan].link_id;
+       data->band_arfcn = htons(trx->band_arfcn);
+       data->frame_nr = htonl(fn);
+       data->rx_level = -rssi;
+
+       /* FIXME: set proper values */
+       data->num_biterr = 0;
+       data->fire_crc = 0;
+       data->snr = 0;
+
+       l1ctl_tx_fbsb_conf(trx->l1l, 0, data, bsic);
+
+       /* Update BSIC value of trx_instance */
+       trx->bsic = bsic;
 
        return 0;
 }

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

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

Reply via email to