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

host/trxcon/l1ctl.c: handle L1CTL_RACH_REQ

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


  git pull ssh://gerrit.osmocom.org:29418/osmocom-bb refs/changes/16/6716/1

diff --git a/src/host/trxcon/l1ctl.c b/src/host/trxcon/l1ctl.c
index beb5734..da69e86 100644
--- a/src/host/trxcon/l1ctl.c
+++ b/src/host/trxcon/l1ctl.c
@@ -187,6 +187,17 @@
        return l1ctl_link_send(l1l, msg);
 }
 
+int l1ctl_tx_rach_conf(struct l1ctl_link *l1l)
+{
+       struct msgb *msg;
+
+       msg = l1ctl_alloc_msg(L1CTL_RACH_CONF);
+       if (msg == NULL)
+               return -ENOMEM;
+
+       return l1ctl_link_send(l1l, msg);
+}
+
 static int l1ctl_rx_fbsb_req(struct l1ctl_link *l1l, struct msgb *msg)
 {
        struct l1ctl_fbsb_req *fbsb;
@@ -355,6 +366,57 @@
        return rc;
 }
 
+static int l1ctl_rx_rach_req(struct l1ctl_link *l1l, struct msgb *msg)
+{
+       struct l1ctl_rach_req *req;
+       struct trx_ts_prim *prim;
+       struct trx_ts *ts;
+       int len, rc = 0;
+
+       req = (struct l1ctl_rach_req *) msg->l1h;
+       len = sizeof(*req);
+       if (msgb_l1len(msg) < len) {
+               LOGP(DL1C, LOGL_ERROR, "MSG too short RACH Req: %d\n", len);
+               rc = -EINVAL;
+               goto exit;
+       }
+
+       /* Convert offset value to host format */
+       req->offset = ntohs(req->offset);
+
+       LOGP(DL1C, LOGL_DEBUG, "Recv RACH Req (offset=%u)\n", req->offset);
+
+       /* FIXME: can we use other than TS0? */
+       ts = sched_trx_find_ts(l1l->trx, 0);
+       if (ts == NULL) {
+               LOGP(DL1C, LOGL_DEBUG, "Couldn't send RACH: "
+                       "TS0 is not active\n");
+               rc = -EINVAL;
+               goto exit;
+       }
+
+       /* Allocate a new primitive */
+       prim = talloc_zero_size(ts, sizeof(struct trx_ts_prim) + len);
+       if (prim == NULL) {
+               LOGP(DL1C, LOGL_ERROR, "Failed to allocate memory\n");
+               rc = -ENOMEM;
+               goto exit;
+       }
+
+       /* Set logical channel of primitive */
+       prim->chan = TRXC_RACH;
+
+       /* Fill in the payload */
+       memcpy(prim->payload, req, len);
+
+       /* Add to TS queue */
+       llist_add_tail(&prim->list, &ts->tx_prims);
+
+exit:
+       msgb_free(msg);
+       return rc;
+}
+
 int l1ctl_rx_cb(struct l1ctl_link *l1l, struct msgb *msg)
 {
        struct l1ctl_hdr *l1h;
@@ -373,6 +435,8 @@
                return l1ctl_rx_echo_req(l1l, msg);
        case L1CTL_CCCH_MODE_REQ:
                return l1ctl_rx_ccch_mode_req(l1l, msg);
+       case L1CTL_RACH_REQ:
+               return l1ctl_rx_rach_req(l1l, msg);
        default:
                LOGP(DL1C, LOGL_ERROR, "Unknown MSG: %u\n", l1h->msg_type);
                msgb_free(msg);
diff --git a/src/host/trxcon/l1ctl.h b/src/host/trxcon/l1ctl.h
index dae75e9..165865a 100644
--- a/src/host/trxcon/l1ctl.h
+++ b/src/host/trxcon/l1ctl.h
@@ -15,3 +15,4 @@
 int l1ctl_rx_cb(struct l1ctl_link *l1l, struct msgb *msg);
 
 int l1ctl_tx_data_ind(struct l1ctl_link *l1l, struct l1ctl_info_dl *ind);
+int l1ctl_tx_rach_conf(struct l1ctl_link *l1l);

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

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

Reply via email to