Change in ...osmo-bts[master]: bts-trx: Move transceiver_available as part of bts-trx private data

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

pespin gerrit-no-reply at lists.osmocom.org
Fri Sep 27 15:22:37 UTC 2019


pespin has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-bts/+/15615


Change subject: bts-trx: Move transceiver_available as part of bts-trx private data
......................................................................

bts-trx: Move transceiver_available as part of bts-trx private data

Change-Id: I35f4697bd33dbe8a4c76c9500b82c16589c701d4
---
M src/osmo-bts-trx/l1_if.c
M src/osmo-bts-trx/l1_if.h
M src/osmo-bts-trx/scheduler_trx.c
M src/osmo-bts-trx/trx_if.c
M src/osmo-bts-trx/trx_if.h
M src/osmo-bts-trx/trx_vty.c
6 files changed, 37 insertions(+), 15 deletions(-)



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

diff --git a/src/osmo-bts-trx/l1_if.c b/src/osmo-bts-trx/l1_if.c
index cd2a03c..fb75116 100644
--- a/src/osmo-bts-trx/l1_if.c
+++ b/src/osmo-bts-trx/l1_if.c
@@ -186,11 +186,28 @@
 int l1if_provision_transceiver_trx(struct trx_l1h *l1h)
 {
 	uint8_t tn;
+	struct phy_link *plink;
+	struct gsm_bts *bts;
+	struct bts_trx_priv *bts_trx;
 	struct phy_instance *pinst = l1h->phy_inst;
-	struct phy_link *plink = pinst->phy_link;
 
-	if (!transceiver_available)
+	/* During setup, pinst may still not be associated to a TRX nr */
+	if (!pinst->trx) {
+		LOGPPHI(pinst, DL1C, LOGL_INFO,
+			"Delaying provision, TRX not yet assigned to phy instance\n");
 		return -EIO;
+	}
+
+	bts = pinst->trx->bts;
+	bts_trx = (struct bts_trx_priv *)bts->model_priv;
+
+	if (!bts_trx->available) {
+		LOGPPHI(pinst, DL1C, LOGL_INFO,
+			"Delaying provision, TRX not yet available\n");
+		return -EIO;
+	}
+
+	plink = pinst->phy_link;
 
 	if (l1h->config.poweron
 	 && l1h->config.tsc_valid
@@ -371,6 +388,7 @@
 /* set bts attributes */
 static uint8_t trx_set_bts(struct gsm_bts *bts, struct tlv_parsed *new_attr)
 {
+	struct bts_trx_priv *bts_trx = (struct bts_trx_priv *)bts->model_priv;
 	struct gsm_bts_trx *trx;
 	uint8_t bsic = bts->bsic;
 
@@ -384,7 +402,7 @@
 			l1if_provision_transceiver_trx(l1h);
 		}
 	}
-	check_transceiver_availability(bts, transceiver_available);
+	check_transceiver_availability(bts, bts_trx->available);
 
 
 	return 0;
diff --git a/src/osmo-bts-trx/l1_if.h b/src/osmo-bts-trx/l1_if.h
index 29bd246..b2eb404 100644
--- a/src/osmo-bts-trx/l1_if.h
+++ b/src/osmo-bts-trx/l1_if.h
@@ -46,6 +46,7 @@
 
 /* gsm_bts->model_priv, specific to osmo-bts-trx */
 struct bts_trx_priv {
+	bool available;
 	struct osmo_trx_clock_state clk_s;
 };
 
diff --git a/src/osmo-bts-trx/scheduler_trx.c b/src/osmo-bts-trx/scheduler_trx.c
index 6c3a8ff..51050fa 100644
--- a/src/osmo-bts-trx/scheduler_trx.c
+++ b/src/osmo-bts-trx/scheduler_trx.c
@@ -1677,7 +1677,7 @@
 
 no_clock:
 	osmo_timerfd_disable(&tcs->fn_timer_ofd);
-	transceiver_available = 0;
+	bts_trx->available = false;
 
 	bts_shutdown(bts, "No clock from osmo-trx");
 
@@ -1724,10 +1724,10 @@
 	clock_gettime(CLOCK_MONOTONIC, &tv_now);
 
 	/* clock becomes valid */
-	if (!transceiver_available) {
+	if (!bts_trx->available) {
 		LOGP(DL1C, LOGL_NOTICE, "initial GSM clock received: fn=%u\n", fn);
 
-		transceiver_available = 1;
+		bts_trx->available = true;
 
 		/* start provisioning transceiver */
 		l1if_provision_transceiver(bts);
diff --git a/src/osmo-bts-trx/trx_if.c b/src/osmo-bts-trx/trx_if.c
index 166cfe6..ccece15 100644
--- a/src/osmo-bts-trx/trx_if.c
+++ b/src/osmo-bts-trx/trx_if.c
@@ -48,8 +48,6 @@
 #include "l1_if.h"
 #include "trx_if.h"
 
-int transceiver_available = 0;
-
 /*
  * socket helper functions
  */
@@ -196,12 +194,14 @@
 static int trx_ctrl_cmd_cb(struct trx_l1h *l1h, int critical, void *cb, const char *cmd,
 	const char *fmt, ...)
 {
+	struct gsm_bts *bts = l1h->phy_inst->trx->bts;
+	struct bts_trx_priv *bts_trx = (struct bts_trx_priv *)bts->model_priv;
 	struct trx_ctrl_msg *tcm;
 	struct trx_ctrl_msg *prev = NULL;
 	va_list ap;
 	int pending;
 
-	if (!transceiver_available &&
+	if (!bts_trx->available &&
 	    !(!strcmp(cmd, "POWEROFF") || !strcmp(cmd, "POWERON"))) {
 		LOGPPHI(l1h->phy_inst, DTRX, LOGL_ERROR, "CTRL %s ignored: No clock from "
 			"transceiver, please fix!\n", cmd);
@@ -1054,6 +1054,8 @@
 int trx_if_send_burst(struct trx_l1h *l1h, uint8_t tn, uint32_t fn, uint8_t pwr,
 	const ubit_t *bits, uint16_t nbits)
 {
+	struct gsm_bts *bts = l1h->phy_inst->trx->bts;
+	struct bts_trx_priv *bts_trx = (struct bts_trx_priv *)bts->model_priv;
 	uint8_t hdr_ver = l1h->config.trxd_hdr_ver_use;
 	uint8_t buf[TRX_DATA_MSG_MAX_LEN];
 
@@ -1090,7 +1092,7 @@
 
 	/* we must be sure that we have clock, and we have sent all control
 	 * data */
-	if (transceiver_available && llist_empty(&l1h->trx_ctrl_list)) {
+	if (bts_trx->available && llist_empty(&l1h->trx_ctrl_list)) {
 		send(l1h->trx_ofd_data.fd, buf, nbits + 6, 0);
 	} else
 		LOGPPHI(l1h->phy_inst, DTRX, LOGL_ERROR, "Ignoring TX data, transceiver offline.\n");
@@ -1225,7 +1227,9 @@
 /*! open the PHY link using TRX protocol */
 int bts_model_phy_link_open(struct phy_link *plink)
 {
-	struct phy_instance *pinst;
+	struct phy_instance *pinst = phy_instance_by_num(plink, 0);
+	struct gsm_bts *bts = pinst->trx->bts;
+	struct bts_trx_priv *bts_trx = (struct bts_trx_priv *)bts->model_priv;
 	int rc;
 
 	phy_link_state_set(plink, PHY_LINK_CONNECTING);
@@ -1248,7 +1252,7 @@
 			goto cleanup;
 	}
 	/* FIXME: is there better way to check/report TRX availability? */
-	transceiver_available = 1;
+	bts_trx->available = true;
 	return 0;
 
 cleanup:
diff --git a/src/osmo-bts-trx/trx_if.h b/src/osmo-bts-trx/trx_if.h
index dda7116..c187441 100644
--- a/src/osmo-bts-trx/trx_if.h
+++ b/src/osmo-bts-trx/trx_if.h
@@ -1,8 +1,6 @@
 #ifndef TRX_IF_H
 #define TRX_IF_H
 
-extern int transceiver_available;
-
 struct trx_l1h;
 
 struct trx_ctrl_msg {
diff --git a/src/osmo-bts-trx/trx_vty.c b/src/osmo-bts-trx/trx_vty.c
index 250d180..d2d0ad2 100644
--- a/src/osmo-bts-trx/trx_vty.c
+++ b/src/osmo-bts-trx/trx_vty.c
@@ -55,10 +55,11 @@
 	SHOW_STR "Display information about transceivers\n")
 {
 	struct gsm_bts *bts = vty_bts;
+	struct bts_trx_priv *bts_trx = (struct bts_trx_priv *)bts->model_priv;
 	struct gsm_bts_trx *trx;
 	struct trx_l1h *l1h;
 
-	if (!transceiver_available) {
+	if (!bts_trx->available) {
 		vty_out(vty, "transceiver is not connected%s", VTY_NEWLINE);
 	} else {
 		vty_out(vty, "transceiver is connected%s", VTY_NEWLINE);

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

Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-Change-Id: I35f4697bd33dbe8a4c76c9500b82c16589c701d4
Gerrit-Change-Number: 15615
Gerrit-PatchSet: 1
Gerrit-Owner: pespin <pespin at sysmocom.de>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20190927/ddaaf549/attachment.htm>


More information about the gerrit-log mailing list