[PATCH] osmocom-bb[master]: host/trxcon/scheduler: implement RACH handler

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

Harald Welte gerrit-no-reply at lists.osmocom.org
Thu Feb 22 15:32:49 UTC 2018


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

host/trxcon/scheduler: implement RACH handler

Change-Id: I496dd682549570e37e63e7edcfc83a064c13a57f
---
M src/host/trxcon/sched_lchan_desc.c
M src/host/trxcon/sched_lchan_handlers.c
2 files changed, 60 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.osmocom.org:29418/osmocom-bb refs/changes/15/6715/1

diff --git a/src/host/trxcon/sched_lchan_desc.c b/src/host/trxcon/sched_lchan_desc.c
index f82a982..55edb98 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 @@
 	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 e2d8e14..eeb09af 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 @@
 
 	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;
+}

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I496dd682549570e37e63e7edcfc83a064c13a57f
Gerrit-PatchSet: 1
Gerrit-Project: osmocom-bb
Gerrit-Branch: master
Gerrit-Owner: Harald Welte <laforge at gnumonks.org>



More information about the gerrit-log mailing list