dexter has uploaded this change for review. (
https://gerrit.osmocom.org/c/osmo-bsc/+/38091?usp=email )
Change subject: pcuif: fix TXT_IND/PCU_VERSION BTS initialization behavior
......................................................................
pcuif: fix TXT_IND/PCU_VERSION BTS initialization behavior
The PCU sends a TXT_IND with the PCU_VERSION as first message after
the socket connection is established. The BSC uses those messages
to trigger some initialization (allocate BTS object inside the
PCU, send SI to the PCU).
Unfortunately the PCU will send the TXT_IND with the PCU_VERSION
always with to BTS 0. The 0 in this case is a hardcoded fake BTS
number (There is no BTS object allocated under this number in the
PCU at this point). However, the BSC will then do the initialization
process for BTS 0, which is incorrect.
Let's fix this design error by introducing a broadcast BTS number,
we then send the TXT_IND with the PCU_VERSION to that broadcast
BTS number. The BSC will then do the initialization for all BTSs with
BSC co located PCU under their correct BTS number.
Related: OS#6507
Change-Id: Ie92f5833a80b06e78c6cec8f03f054e2e2625fad
Depends: osmo-bts.git I5316d3b7cef416eb19bb256f4ccc1468b3efe1c6
Depends: osmo-pcu.git Id01966a1ee52d0f5e465dc2e0eaf85e5b7942f81
Depends: osmo-ttcn3-hacks.git Idce13d55fc5bdbf5b366e3a60d9b46aacfc701a9
Depends: docker-playground.git I15f7150b51047379a557a1f8df6330eca597f2e3
---
M include/osmocom/bsc/pcuif_proto.h
M src/osmo-bsc/pcu_sock.c
2 files changed, 40 insertions(+), 13 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/osmo-bsc refs/changes/91/38091/1
diff --git a/include/osmocom/bsc/pcuif_proto.h b/include/osmocom/bsc/pcuif_proto.h
index 33036c3..f2e7073 100644
--- a/include/osmocom/bsc/pcuif_proto.h
+++ b/include/osmocom/bsc/pcuif_proto.h
@@ -8,7 +8,7 @@
#define PCU_SOCK_DEFAULT "/tmp/pcu_bts"
-#define PCU_IF_VERSION 0x0c
+#define PCU_IF_VERSION 0x0d
#define TXT_MAX_LEN 128
/* msg_type */
@@ -298,6 +298,10 @@
bool confirm;
} __attribute__((packed));
+/* reserved BTS number to indicate that the PCUIF INDICATION is not targeted to a
+ * specific BTS. (commonly used with TXT indications to transfer the PCU version number)
*/
+#define PCU_IF_BTS_NR_BCAST 0xff
+
struct gsm_pcu_if {
/* context based information */
uint8_t msg_type; /* message type */
diff --git a/src/osmo-bsc/pcu_sock.c b/src/osmo-bsc/pcu_sock.c
index 7b1aeae..3cac153 100644
--- a/src/osmo-bsc/pcu_sock.c
+++ b/src/osmo-bsc/pcu_sock.c
@@ -650,24 +650,41 @@
return 0;
}
-static int pcu_rx_txt_ind(struct gsm_bts *bts,
+static int pcu_rx_txt_ind(struct gsm_network *net, struct gsm_bts *bts,
const struct gsm_pcu_if_txt_ind *txt)
{
- int rc;
+ int rc = 0;
switch (txt->type) {
case PCU_VERSION:
- LOG_BTS(bts, DPCU, LOGL_INFO, "OsmoPCU version %s connected\n",
+ LOGP(DPCU, LOGL_INFO, "OsmoPCU version %s connected\n",
txt->text);
- rc = pcu_tx_si_all(bts);
+
+ /* we use the reception of the PCU_VERSION as a trigger to make the PCU available for
+ * all BTSs handled by this process (currently this is exactly one BTS, see FIXME
notes) */
+ llist_for_each_entry(bts, &net->bts_list, list) {
+ if (bsc_co_located_pcu(bts)) {
+ if (pcu_tx_si_all(bts) < 0)
+ rc = -EINVAL;
+ }
+ }
if (rc < 0)
return -EINVAL;
break;
case PCU_OML_ALERT:
- LOG_BTS(bts, DPCU, LOGL_ERROR, "PCU external alarm: %s\n", txt->text);
+ if (bts) {
+ /* The PCU_OML_ALERT is directed to a spcific BTS object */
+ LOG_BTS(bts, DPCU, LOGL_ERROR, "PCU external alarm: %s\n", txt->text);
+ } else {
+ /* The PCU_OML_ALERT is directed to all BTS objects (currently this is exactly one
BTS,
+ * see FIXME notes) */
+ llist_for_each_entry(bts, &net->bts_list, list) {
+ LOG_BTS(bts, DPCU, LOGL_ERROR, "PCU external alarm: %s\n", txt->text);
+ }
+ }
break;
default:
- LOG_BTS(bts, DPCU, LOGL_ERROR, "Unknown TXT_IND type %u received\n",
+ LOGP(DPCU, LOGL_ERROR, "Unknown TXT_IND type %u received\n",
txt->type);
return -EINVAL;
}
@@ -684,25 +701,31 @@
return -EINVAL; \
} \
} while (0)
+
+#define ENSURE_BTS_OBJECT() \
+ if ((bts = gsm_bts_num(net, pcu_prim->bts_nr)) == NULL) { \
+ LOGP(DPCU, LOGL_ERROR, "Received PCU Prim for non-existent BTS %u\n",
pcu_prim->bts_nr); \
+ return -EINVAL; \
+ }
+
static int pcu_rx(struct gsm_network *net, uint8_t msg_type,
struct gsm_pcu_if *pcu_prim, size_t prim_len)
{
int rc = 0;
- struct gsm_bts *bts;
-
- bts = gsm_bts_num(net, pcu_prim->bts_nr);
- if (!bts)
- return -EINVAL;
+ struct gsm_bts *bts = NULL;
switch (msg_type) {
case PCU_IF_MSG_DATA_REQ:
case PCU_IF_MSG_PAG_REQ:
+ ENSURE_BTS_OBJECT();
CHECK_IF_MSG_SIZE(prim_len, pcu_prim->u.data_req);
rc = pcu_rx_data_req(bts, msg_type, &pcu_prim->u.data_req);
break;
case PCU_IF_MSG_TXT_IND:
+ if (pcu_prim->bts_nr != PCU_IF_BTS_NR_BCAST)
+ ENSURE_BTS_OBJECT();
CHECK_IF_MSG_SIZE(prim_len, pcu_prim->u.txt_ind);
- rc = pcu_rx_txt_ind(bts, &pcu_prim->u.txt_ind);
+ rc = pcu_rx_txt_ind(net, bts, &pcu_prim->u.txt_ind);
break;
default:
LOGP(DPCU, LOGL_ERROR, "Received unknown PCU msg type %d\n",
--
To view, visit
https://gerrit.osmocom.org/c/osmo-bsc/+/38091?usp=email
To unsubscribe, or for help writing mail filters, visit
https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: newchange
Gerrit-Project: osmo-bsc
Gerrit-Branch: master
Gerrit-Change-Id: Ie92f5833a80b06e78c6cec8f03f054e2e2625fad
Gerrit-Change-Number: 38091
Gerrit-PatchSet: 1
Gerrit-Owner: dexter <pmaier(a)sysmocom.de>