summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVadim Yanitskiy <axilirator@gmail.com>2017-07-14 01:38:48 +0700
committerVadim Yanitskiy <axilirator@gmail.com>2017-10-23 22:05:49 +0330
commit1d0b3c9f7e31ce1faf3044def61390a516fa3e56 (patch)
tree76b94a73b212c27c8322f8daf099daddebf46b7b
parenta2be625b4f90b3d85a97abdf1b93a72bf868716b (diff)
host/trxcon/scheduler: implement RACH handler
-rw-r--r--src/host/trxcon/sched_lchan_desc.c5
-rw-r--r--src/host/trxcon/sched_lchan_handlers.c56
2 files changed, 60 insertions, 1 deletions
diff --git a/src/host/trxcon/sched_lchan_desc.c b/src/host/trxcon/sched_lchan_desc.c
index f82a982d..55edb989 100644
--- a/src/host/trxcon/sched_lchan_desc.c
+++ b/src/host/trxcon/sched_lchan_desc.c
@@ -33,7 +33,6 @@
#define tx_pdtch_fn NULL
#define tx_tchf_fn NULL
#define tx_tchh_fn NULL
-#define tx_rach_fn NULL
#define rx_pdtch_fn NULL
#define rx_tchf_fn NULL
@@ -48,6 +47,10 @@ int rx_sch_fn(struct trx_instance *trx, struct trx_ts *ts,
uint32_t fn, enum trx_lchan_type chan, uint8_t bid,
sbit_t *bits, uint16_t nbits, int8_t rssi, float toa);
+int tx_rach_fn(struct trx_instance *trx, struct trx_ts *ts,
+ uint32_t fn, enum trx_lchan_type chan,
+ uint8_t bid, uint16_t *nbits);
+
const struct trx_lchan_desc trx_lchan_desc[_TRX_CHAN_MAX] = {
{
TRXC_IDLE, "IDLE",
diff --git a/src/host/trxcon/sched_lchan_handlers.c b/src/host/trxcon/sched_lchan_handlers.c
index e2d8e14d..eeb09af3 100644
--- a/src/host/trxcon/sched_lchan_handlers.c
+++ b/src/host/trxcon/sched_lchan_handlers.c
@@ -29,6 +29,7 @@
#include <arpa/inet.h>
+#include <osmocom/core/linuxlist.h>
#include <osmocom/core/logging.h>
#include <osmocom/core/bits.h>
#include <osmocom/core/msgb.h>
@@ -231,3 +232,58 @@ int rx_sch_fn(struct trx_instance *trx, struct trx_ts *ts,
return 0;
}
+
+/* 41-bit RACH synchronization sequence */
+static ubit_t rach_synch_seq[] = {
+ 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 1, 1, 1, 1,
+ 1, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0,
+ 1, 0, 1, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0,
+};
+
+/* Obtain a to-be-transmitted RACH burst */
+int tx_rach_fn(struct trx_instance *trx, struct trx_ts *ts,
+ uint32_t fn, enum trx_lchan_type chan,
+ uint8_t bid, uint16_t *nbits)
+{
+ struct trx_ts_prim *prim;
+ struct l1ctl_rach_req *req;
+ uint8_t burst[GSM_BURST_LEN];
+ uint8_t payload[36];
+ int rc;
+
+ /* Get a message from TX queue */
+ prim = llist_entry(ts->tx_prims.next, struct trx_ts_prim, list);
+ req = (struct l1ctl_rach_req *) prim->payload;
+
+ /* Delay RACH sending according to offset value */
+ if (req->offset-- > 0)
+ return 0;
+
+ /* Encode payload */
+ rc = gsm0503_rach_encode(payload, &req->ra, trx->bsic);
+ if (rc) {
+ LOGP(DSCH, LOGL_ERROR, "Could not encode RACH burst\n");
+ return rc;
+ }
+
+ /* Compose RACH burst */
+ memset(burst, 0, 8); /* TB */
+ memcpy(burst + 8, rach_synch_seq, 41); /* sync seq */
+ memcpy(burst + 49, payload, 36); /* payload */
+ memset(burst + 85, 0, 63); /* TB + GP */
+
+ LOGP(DSCH, LOGL_DEBUG, "Transmitting RACH fn=%u\n", fn);
+
+ /* Send burst to transceiver */
+ rc = trx_if_tx_burst(trx, ts->index, fn, 10, burst);
+ if (rc) {
+ LOGP(DSCH, LOGL_ERROR, "Could not send burst to transceiver\n");
+ return rc;
+ }
+
+ /* Remove primitive from queue and free memory */
+ llist_del(&prim->list);
+ talloc_free(prim);
+
+ return 0;
+}