Change in osmo-bts[master]: osmo-bts-trx: implement TRXDv2 protocol support

fixeria gerrit-no-reply at lists.osmocom.org
Tue Apr 20 23:05:22 UTC 2021


fixeria has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-bts/+/23833 )


Change subject: osmo-bts-trx: implement TRXDv2 protocol support
......................................................................

osmo-bts-trx: implement TRXDv2 protocol support

Change-Id: I3532a6693bb335043ec390049138308991083e66
Related: SYS#4895, OS#4941, OS#4006
---
M include/osmo-bts/scheduler.h
M src/osmo-bts-trx/trx_if.c
2 files changed, 72 insertions(+), 3 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-bts refs/changes/33/23833/1

diff --git a/include/osmo-bts/scheduler.h b/include/osmo-bts/scheduler.h
index ad6e5c5..e990774 100644
--- a/include/osmo-bts/scheduler.h
+++ b/include/osmo-bts/scheduler.h
@@ -231,12 +231,17 @@
 #define TRX_BI_F_MOD_TYPE	(1 << 1)
 #define TRX_BI_F_TS_INFO	(1 << 2)
 #define TRX_BI_F_CI_CB		(1 << 3)
+#define TRX_BI_F_TRX_NUM	(1 << 4)
 
 /*! UL burst indication with the corresponding meta info */
 struct trx_ul_burst_ind {
 	/* Field presence bitmask (see TRX_BI_F_*) */
 	uint8_t flags;
 
+	/* Used internally by the PDU parser */
+	uint8_t pdu_num;	/*!< Number of this PDU in the packet */
+	bool more_pdus;		/*!< Do we expect more PDUs? */
+
 	/* Mandatory fields */
 	uint32_t fn;		/*!< TDMA frame number */
 	uint8_t tn;		/*!< TDMA time-slot number */
@@ -248,6 +253,7 @@
 	uint8_t tsc_set;	/*!< Training Sequence Set */
 	uint8_t tsc;		/*!< Training Sequence Code */
 	int16_t ci_cb;		/*!< Carrier-to-Interference ratio (in centiBels) */
+	uint8_t trx_num;	/*!< TRX (RF channel) number */
 
 	/*! Burst soft-bits buffer */
 	sbit_t burst[EGPRS_BURST_LEN];
diff --git a/src/osmo-bts-trx/trx_if.c b/src/osmo-bts-trx/trx_if.c
index bd04f5c..61dc3e6 100644
--- a/src/osmo-bts-trx/trx_if.c
+++ b/src/osmo-bts-trx/trx_if.c
@@ -722,6 +722,8 @@
 #define TRX_UL_V0HDR_LEN	(1 + 4 + 1 + 2)
 /* Uplink TRXDv1 header length: additional MTS + C/I */
 #define TRX_UL_V1HDR_LEN	(TRX_UL_V0HDR_LEN + 1 + 2)
+/* Uplink TRXDv2 header length: TDMA TN + TRXN + MTS + RSSI + ToA256 + C/I */
+#define TRX_UL_V2HDR_LEN	1 + 1 + 1 + 1 + 2 + 2
 
 /* Parser for TRXDv0 header (and part of TRXDv1) */
 static inline void trx_data_parse_hdr_v0(struct trx_ul_burst_ind *bi,
@@ -822,6 +824,47 @@
 	return TRX_UL_V1HDR_LEN;
 }
 
+/* Parser for TRXDv2 PDU */
+static int trx_data_parse_pdu_v2(struct phy_instance *phy_inst,
+				 struct trx_ul_burst_ind *bi,
+				 const uint8_t *buf, size_t buf_len)
+{
+	int rc;
+
+	/* TDMA timeslot number (other bits are RFU) */
+	bi->tn = buf[0] & 0x07;
+
+	/* TRX (RF channel) number and BATCH.ind */
+	bi->more_pdus = !!(buf[1] & (1 << 7));
+	bi->trx_num = buf[1] & 0x3f;
+	bi->flags |= TRX_BI_F_TRX_NUM;
+
+	/* MTS (Modulation and Training Sequence) */
+	rc = trx_data_parse_mts(phy_inst, bi, buf[2]);
+	if (rc < 0)
+		return rc;
+
+	bi->rssi = -(int8_t)buf[3];
+	bi->toa256 = (int16_t) osmo_load16be(buf + 6);
+	bi->ci_cb = (int16_t) osmo_load16be(buf + 1);
+	bi->flags |= TRX_BI_F_CI_CB;
+
+	/* TDMA frame number is absent in batched PDUs */
+	if (bi->pdu_num == 0) {
+		if (buf_len < sizeof(bi->fn) + TRX_UL_V2HDR_LEN) {
+			LOGPPHI(phy_inst, DTRX, LOGL_ERROR,
+				"Rx malformed TRXDv2 PDU: not enough bytes "
+				"to parse TDMA frame number\n");
+			return -EINVAL;
+		}
+
+		bi->fn = osmo_load32be(buf + TRX_UL_V2HDR_LEN);
+		return TRX_UL_V2HDR_LEN + sizeof(bi->fn);
+	}
+
+	return TRX_UL_V2HDR_LEN;
+}
+
 /* Parser for burst bits (version independent) */
 static int trx_data_parse_burst(struct trx_ul_burst_ind *bi,
 				const uint8_t *buf, size_t buf_len)
@@ -872,6 +915,10 @@
 	/* Common TDMA parameters */
 	OSMO_STRBUF_PRINTF(sb, "tn=%u fn=%u", bi->tn, bi->fn);
 
+	/* TRX (RF channel number) */
+	if (bi->flags & TRX_BI_F_TRX_NUM)
+		OSMO_STRBUF_PRINTF(sb, " trx_num=%u", bi->trx_num);
+
 	/* RSSI and ToA256 */
 	OSMO_STRBUF_PRINTF(sb, " rssi=%d toa256=%d", bi->rssi, bi->toa256);
 
@@ -911,6 +958,10 @@
 		.hdr_len = TRX_UL_V1HDR_LEN,
 		.parse = &trx_data_parse_pdu_v1,
 	},
+	[2] = { /* TRXDv2 */
+		.hdr_len = TRX_UL_V2HDR_LEN,
+		.parse = &trx_data_parse_pdu_v2,
+	},
 };
 
 /* Parse TRXD message from transceiver, compose an UL burst indication. */
@@ -931,9 +982,6 @@
 		return buf_len;
 	}
 
-	/* Pre-clean (initialize) the flags */
-	bi.flags = 0x00;
-
 	/* Parse PDU version first */
 	pdu_ver = buf[0] >> 4;
 
@@ -947,6 +995,13 @@
 
 	OSMO_ASSERT(trx_data_codec[pdu_ver].parse != NULL);
 
+	/* We're about to parse the first PDU */
+	bi.pdu_num = 0;
+
+loop:
+	/* Reset (initialize) the flags */
+	bi.flags = 0x00;
+
 	/* Make sure that we have enough bytes to parse the header */
 	if (buf_len < trx_data_codec[pdu_ver].hdr_len) {
 		LOGPPHI(l1h->phy_inst, DTRX, LOGL_ERROR,
@@ -987,6 +1042,14 @@
 	/* feed received burst into scheduler code */
 	trx_sched_route_burst_ind(&bi, &l1h->l1s);
 
+	/* Starting from TRXDv2, there can be batched PDUs */
+	if (bi.more_pdus) {
+		buf_len -= bi.burst_len;
+		ptr += bi.burst_len;
+		bi.pdu_num++;
+		goto loop;
+	}
+
 	return 0;
 }
 

-- 
To view, visit https://gerrit.osmocom.org/c/osmo-bts/+/23833
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-Change-Id: I3532a6693bb335043ec390049138308991083e66
Gerrit-Change-Number: 23833
Gerrit-PatchSet: 1
Gerrit-Owner: fixeria <vyanitskiy at sysmocom.de>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20210420/ac70c9b1/attachment.htm>


More information about the gerrit-log mailing list