Change in ...osmo-bts[master]: osmo-bts-trx/trx_if.c: add TRXD header version negotiation

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/.

laforge gerrit-no-reply at lists.osmocom.org
Tue Jul 16 04:16:13 UTC 2019


laforge has submitted this change and it was merged. ( https://gerrit.osmocom.org/c/osmo-bts/+/14611 )

Change subject: osmo-bts-trx/trx_if.c: add TRXD header version negotiation
......................................................................

osmo-bts-trx/trx_if.c: add TRXD header version negotiation

This change introduces a new command for TRXD header format
negotiation - SETFORMAT. If the transceiver does not support
the format negotiation, it would reject this command with
'RSP ERR 1'. If the requested version is not supported by
the transceiver, status code of the response message should
indicate a preferred (basically, the latest) version.

The format of SETFORMAT command is the following:

  L1 -> TRX: CMD SETFORMAT VER_REQ
  L1 <- TRX: RSP SETFORMAT VER_RSP VER_REQ

where:

  - VER_REQ is the requested version (suggested by the L1),
  - VER_RSP is either the applied version if matches VER_REQ,
    or a preferred version if VER_REQ is not supported.

If the transceiver indicates VER_RSP different than VER_REQ,
OsmoBTS is supposed to reinitiate the version negotiation
using the suggested VER_RSP. For example:

  L1 -> TRX: CMD SETFORMAT 2
  L1 <- TRX: RSP SETFORMAT 1 2

  L1 -> TRX: CMD SETFORMAT 1
  L1 <- TRX: RSP SETFORMAT 1 1

If no suitable VER_RSP is found, or the VER_REQ is incorrect,
the status code in the response would be -1.

As soon as VER_RSP matches VER_REQ in the response, the process
of negotiation is complete. Changing the header version is
supposed to be done before POWERON.

Change-Id: I8afe950bd1ec2afaf3347ff848ee46e69c4f5011
Related: OS#4006
---
M src/osmo-bts-trx/l1_if.c
M src/osmo-bts-trx/l1_if.h
M src/osmo-bts-trx/trx_if.c
M src/osmo-bts-trx/trx_if.h
4 files changed, 91 insertions(+), 5 deletions(-)

Approvals:
  laforge: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/src/osmo-bts-trx/l1_if.c b/src/osmo-bts-trx/l1_if.c
index e6e384a..9c1dc18 100644
--- a/src/osmo-bts-trx/l1_if.c
+++ b/src/osmo-bts-trx/l1_if.c
@@ -208,6 +208,13 @@
 			l1h->config.bsic_sent = 1;
 		}
 
+		/* Ask transceiver to use the newest TRXD header version */
+		if (!l1h->config.setformat_sent) {
+			trx_if_cmd_setformat(l1h, TRX_DATA_FORMAT_VER);
+			l1h->config.trxd_hdr_ver_req = TRX_DATA_FORMAT_VER;
+			l1h->config.setformat_sent = 1;
+		}
+
 		if (!l1h->config.poweron_sent) {
 			trx_if_cmd_poweron(l1h);
 			l1h->config.poweron_sent = 1;
@@ -264,6 +271,9 @@
 	llist_for_each_entry(trx, &bts->trx_list, list) {
 		struct phy_instance *pinst = trx_phy_instance(trx);
 		struct trx_l1h *l1h = pinst->u.osmotrx.hdl;
+		l1h->config.trxd_hdr_ver_req = 0;
+		l1h->config.trxd_hdr_ver_use = 0;
+		l1h->config.setformat_sent = 0;
 		l1h->config.arfcn_sent = 0;
 		l1h->config.tsc_sent = 0;
 		l1h->config.bsic_sent = 0;
diff --git a/src/osmo-bts-trx/l1_if.h b/src/osmo-bts-trx/l1_if.h
index 9c95c53..87df951 100644
--- a/src/osmo-bts-trx/l1_if.h
+++ b/src/osmo-bts-trx/l1_if.h
@@ -6,6 +6,10 @@
 #include "trx_if.h"
 
 struct trx_config {
+	uint8_t			trxd_hdr_ver_req; /* requested TRXD header version */
+	uint8_t			trxd_hdr_ver_use; /* actual TRXD header version in use */
+	int			setformat_sent;
+
 	uint8_t			poweron;	/* poweron(1) or poweroff(0) */
 	int			poweron_sent;
 
diff --git a/src/osmo-bts-trx/trx_if.c b/src/osmo-bts-trx/trx_if.c
index e9193ca..3e53fdb 100644
--- a/src/osmo-bts-trx/trx_if.c
+++ b/src/osmo-bts-trx/trx_if.c
@@ -269,6 +269,15 @@
 		return 0;
 }
 
+/*! Send "SETFORMAT" command to TRX: change TRXD header format version */
+int trx_if_cmd_setformat(struct trx_l1h *l1h, uint8_t ver)
+{
+	LOGPPHI(l1h->phy_inst, DTRX, LOGL_INFO,
+		"Requesting TRXD header format version %u\n", ver);
+
+	return trx_ctrl_cmd(l1h, 0, "SETFORMAT", "%u", ver);
+}
+
 /*! Send "SETTSC" command to TRX */
 int trx_if_cmd_settsc(struct trx_l1h *l1h, uint8_t tsc)
 {
@@ -433,6 +442,8 @@
 	   expected that they can return different values */
 	if (strcmp(tcm->cmd, "SETSLOT") == 0 && strcmp(tcm->params, rsp->params))
 		return false;
+	else if (strcmp(tcm->cmd, "SETFORMAT") == 0 && strcmp(tcm->params, rsp->params))
+		return false;
 
 	return true;
 }
@@ -460,11 +471,59 @@
 	return rsp->status == 0 ? 0 : -EINVAL;
 }
 
+/* TRXD header format negotiation handler.
+ *
+ * If the transceiver does not support the format negotiation, it would
+ * reject SETFORMAT with 'RSP ERR 1'. If the requested version is not
+ * supported by the transceiver, status code of the response message
+ * should indicate a preferred (basically, the latest) version.
+ */
+static int trx_ctrl_rx_rsp_setformat(struct trx_l1h *l1h,
+				     struct trx_ctrl_rsp *rsp)
+{
+	/* Old transceivers reject 'SETFORMAT' with 'RSP ERR 1' */
+	if (strcmp(rsp->cmd, "SETFORMAT") != 0) {
+		LOGPPHI(l1h->phy_inst, DTRX, LOGL_NOTICE,
+			"Transceiver rejected the format negotiation command, "
+			"using legacy TRXD header format version (0)\n");
+		l1h->config.trxd_hdr_ver_use = 0;
+		return 0;
+	}
+
+	/* Status shall indicate a proper version supported by the transceiver */
+	if (rsp->status < 0 || rsp->status > l1h->config.trxd_hdr_ver_req) {
+		LOGPPHI(l1h->phy_inst, DTRX, LOGL_ERROR,
+			"Transceiver indicated an out of range "
+			"header format version %d (requested %u)\n",
+			rsp->status, l1h->config.trxd_hdr_ver_req);
+		return -EINVAL;
+	}
+
+	/* Transceiver may suggest a lower version (than requested) */
+	if (rsp->status == l1h->config.trxd_hdr_ver_req) {
+		l1h->config.trxd_hdr_ver_use = rsp->status;
+		LOGPPHI(l1h->phy_inst, DTRX, LOGL_INFO,
+			"Using TRXD header format version %u\n",
+			l1h->config.trxd_hdr_ver_use);
+	} else {
+		LOGPPHI(l1h->phy_inst, DTRX, LOGL_DEBUG,
+			"Transceiver suggests TRXD header version %u (requested %u)\n",
+			rsp->status, l1h->config.trxd_hdr_ver_req);
+		/* Send another SETFORMAT with suggested version */
+		l1h->config.trxd_hdr_ver_req = rsp->status;
+		trx_if_cmd_setformat(l1h, rsp->status);
+	}
+
+	return 0;
+}
+
 /* -EINVAL: unrecoverable error, exit BTS
  * N > 0: try sending originating command again after N seconds
  * 0: Done with response, get originating command out from send queue
  */
-static int trx_ctrl_rx_rsp(struct trx_l1h *l1h, struct trx_ctrl_rsp *rsp, bool critical)
+static int trx_ctrl_rx_rsp(struct trx_l1h *l1h,
+			   struct trx_ctrl_rsp *rsp,
+			   struct trx_ctrl_msg *tcm)
 {
 	struct phy_instance *pinst = l1h->phy_inst;
 
@@ -484,14 +543,18 @@
 		}
 	} else if (strcmp(rsp->cmd, "SETSLOT") == 0) {
 		return trx_ctrl_rx_rsp_setslot(l1h, rsp);
+	/* We may get 'RSP ERR 1' if 'SETFORMAT' is not supported,
+	 * so that's why we should use tcm instead of rsp. */
+	} else if (strcmp(tcm->cmd, "SETFORMAT") == 0) {
+		return trx_ctrl_rx_rsp_setformat(l1h, rsp);
 	}
 
 	if (rsp->status) {
-		LOGPPHI(l1h->phy_inst, DTRX, critical ? LOGL_FATAL : LOGL_NOTICE,
+		LOGPPHI(l1h->phy_inst, DTRX, tcm->critical ? LOGL_FATAL : LOGL_NOTICE,
 			"transceiver rejected TRX command with response: '%s%s%s %d'\n",
 			rsp->cmd, rsp->params[0] != '\0' ? " ":"",
 			rsp->params, rsp->status);
-		if (critical)
+		if (tcm->critical)
 			return -EINVAL;
 	}
 	return 0;
@@ -547,13 +610,16 @@
 			"Response message '%s' does not match command "
 			"message 'CMD %s%s%s'\n",
 			buf, tcm->cmd, tcm->params_len ? " ":"", tcm->params);
-		goto rsp_error;
+
+		/* We may get 'RSP ERR 1' for non-critical commands */
+		if (tcm->critical)
+			goto rsp_error;
 	}
 
 	rsp.cb = tcm->cb;
 
 	/* check for response code */
-	rc = trx_ctrl_rx_rsp(l1h, &rsp, tcm->critical);
+	rc = trx_ctrl_rx_rsp(l1h, &rsp, tcm);
 	if (rc == -EINVAL)
 		goto rsp_error;
 
diff --git a/src/osmo-bts-trx/trx_if.h b/src/osmo-bts-trx/trx_if.h
index cdfbd41..dda7116 100644
--- a/src/osmo-bts-trx/trx_if.h
+++ b/src/osmo-bts-trx/trx_if.h
@@ -35,4 +35,10 @@
 	const ubit_t *bits, uint16_t nbits);
 int trx_if_powered(struct trx_l1h *l1h);
 
+/* The latest supported TRXD header format version */
+#define TRX_DATA_FORMAT_VER    1
+
+/* Format negotiation command */
+int trx_if_cmd_setformat(struct trx_l1h *l1h, uint8_t ver);
+
 #endif /* TRX_IF_H */

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

Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-Change-Id: I8afe950bd1ec2afaf3347ff848ee46e69c4f5011
Gerrit-Change-Number: 14611
Gerrit-PatchSet: 9
Gerrit-Owner: fixeria <axilirator at gmail.com>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <axilirator at gmail.com>
Gerrit-Reviewer: laforge <laforge at gnumonks.org>
Gerrit-Reviewer: pespin <pespin at sysmocom.de>
Gerrit-CC: ipse <Alexander.Chemeris at gmail.com>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20190716/102cf6fa/attachment.htm>


More information about the gerrit-log mailing list