summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVadim Yanitskiy <axilirator@gmail.com>2017-07-12 18:46:56 +0700
committerVadim Yanitskiy <axilirator@gmail.com>2017-10-23 22:05:49 +0330
commit13bff3875802ffd20981675ef13ffa099fc4d321 (patch)
tree5138830db9cc6fd045cf29d5b8ce1552c94b5e2f
parent1d0b3c9f7e31ce1faf3044def61390a516fa3e56 (diff)
host/trxcon/l1ctl.c: handle L1CTL_RACH_REQ
-rw-r--r--src/host/trxcon/l1ctl.c64
-rw-r--r--src/host/trxcon/l1ctl.h1
2 files changed, 65 insertions, 0 deletions
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 @@ int l1ctl_tx_data_ind(struct l1ctl_link *l1l, struct l1ctl_info_dl *data)
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 @@ exit:
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 @@ int l1ctl_rx_cb(struct l1ctl_link *l1l, struct msgb *msg)
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_tx_reset_ind(struct l1ctl_link *l1l, uint8_t type);
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);