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

host/trxcon/l1ctl.c: include DL frame info in L1CTL_DATA_CONF

The l1ctl_info_dl header is expected to be a part of a
L1CTL_DATA_CONF message, but was missing previously.

Change-Id: Ia8dfaed924fd84395ba9ae539164eaa94f52d30b
---
M src/host/trxcon/l1ctl.c
M src/host/trxcon/l1ctl.h
M src/host/trxcon/sched_lchan_common.c
M src/host/trxcon/sched_lchan_xcch.c
4 files changed, 51 insertions(+), 5 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmocom-bb refs/changes/76/6776/1

diff --git a/src/host/trxcon/l1ctl.c b/src/host/trxcon/l1ctl.c
index 6585084..5303130 100644
--- a/src/host/trxcon/l1ctl.c
+++ b/src/host/trxcon/l1ctl.c
@@ -225,15 +225,26 @@
        return l1ctl_link_send(l1l, msg);
 }
 
-int l1ctl_tx_data_conf(struct l1ctl_link *l1l)
+int l1ctl_tx_data_conf(struct l1ctl_link *l1l,
+       struct l1ctl_info_dl *data, uint8_t msg_type)
 {
+       struct l1ctl_info_dl *dl;
        struct msgb *msg;
+       size_t len;
 
-       msg = l1ctl_alloc_msg(L1CTL_DATA_CONF);
+       if (msg_type != L1CTL_DATA_CONF && msg_type != L1CTL_TRAFFIC_CONF) {
+               LOGP(DL1D, LOGL_ERROR, "Incorrect confirmation type\n");
+               return -EINVAL;
+       }
+
+       msg = l1ctl_alloc_msg(msg_type);
        if (msg == NULL)
                return -ENOMEM;
 
-       LOGP(DL1D, LOGL_DEBUG, "Send Data Conf\n");
+       /* Copy DL frame header from source message */
+       len = sizeof(struct l1ctl_info_dl);
+       dl = (struct l1ctl_info_dl *) msgb_put(msg, len);
+       memcpy(dl, data, len);
 
        return l1ctl_link_send(l1l, msg);
 }
diff --git a/src/host/trxcon/l1ctl.h b/src/host/trxcon/l1ctl.h
index 4f48aaa..91a7f0f 100644
--- a/src/host/trxcon/l1ctl.h
+++ b/src/host/trxcon/l1ctl.h
@@ -20,5 +20,6 @@
 
 int l1ctl_tx_data_ind(struct l1ctl_link *l1l,
        struct l1ctl_info_dl *data, uint8_t msg_type);
+int l1ctl_tx_data_conf(struct l1ctl_link *l1l,
+       struct l1ctl_info_dl *data, uint8_t msg_type);
 int l1ctl_tx_rach_conf(struct l1ctl_link *l1l, uint32_t fn);
-int l1ctl_tx_data_conf(struct l1ctl_link *l1l);
diff --git a/src/host/trxcon/sched_lchan_common.c 
b/src/host/trxcon/sched_lchan_common.c
index 7dad750..5383ef4 100644
--- a/src/host/trxcon/sched_lchan_common.c
+++ b/src/host/trxcon/sched_lchan_common.c
@@ -112,3 +112,34 @@
 
        return 0;
 }
+
+int sched_send_data_conf(struct trx_instance *trx, struct trx_ts *ts,
+       struct trx_lchan_state *lchan, uint32_t fn, size_t l2_len)
+{
+       const struct trx_lchan_desc *lchan_desc;
+       struct l1ctl_info_dl *data;
+       uint8_t conf_type;
+
+       /* Allocate memory */
+       data = talloc_zero(ts, struct l1ctl_info_dl);
+       if (data == NULL)
+               return -ENOMEM;
+
+       /* Set up pointers */
+       lchan_desc = &trx_lchan_desc[lchan->type];
+
+       /* Fill in known downlink info */
+       data->chan_nr = lchan_desc->chan_nr | ts->index;
+       data->link_id = lchan_desc->link_id;
+       data->band_arfcn = htons(trx->band_arfcn);
+       data->frame_nr = htonl(fn);
+
+       /* Choose a confirmation type */
+       conf_type = l2_len == 23 ?
+               L1CTL_DATA_CONF : L1CTL_TRAFFIC_CONF;
+
+       l1ctl_tx_data_conf(trx->l1l, data, conf_type);
+       talloc_free(data);
+
+       return 0;
+}
diff --git a/src/host/trxcon/sched_lchan_xcch.c 
b/src/host/trxcon/sched_lchan_xcch.c
index 62c44f9..dd76d0a 100644
--- a/src/host/trxcon/sched_lchan_xcch.c
+++ b/src/host/trxcon/sched_lchan_xcch.c
@@ -48,6 +48,9 @@
 int sched_send_data_ind(struct trx_instance *trx, struct trx_ts *ts,
        struct trx_lchan_state *lchan, uint8_t *l2, size_t l2_len);
 
+int sched_send_data_conf(struct trx_instance *trx, struct trx_ts *ts,
+       struct trx_lchan_state *lchan, uint32_t fn, size_t l2_len);
+
 int rx_data_fn(struct trx_instance *trx, struct trx_ts *ts,
        struct trx_lchan_state *lchan, uint32_t fn, uint8_t bid,
        sbit_t *bits, int8_t rssi, float toa)
@@ -221,7 +224,7 @@
                *mask = 0x00;
 
                /* Confirm data sending */
-               l1ctl_tx_data_conf(trx->l1l);
+               sched_send_data_conf(trx, ts, lchan, fn, 23);
        }
 
        return 0;

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

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

Reply via email to