dear holger,

i change the patch. also i attached the change that is required for osmo-bts (sysmobts) to work afterwards.

best regards,

andreas

>From ef00603bd626f1ce7986df5dc94e2aa5e3781e11 Mon Sep 17 00:00:00 2001
From: Andreas Eversberg <[email protected]>
Date: Tue, 14 Jan 2014 12:32:35 +0100
Subject: [PATCH] Support for multiple RSL connections with ABIS/ipaccess (BTS
 side)

In order to support multiple TRX, multiple RSL connections can be
establised. e1inp_ipa_bts_rsl_connect() requires an additional parameter
to set the TRX number.

The code was successfully tested with osmobts-trx and UmTRX with two
transceivers.

The user of e1inp_ipa_bts_rsl_connect() and e1inp_line_bind_ops()
(which is osmo-bts) must be upgraded after applying the patch.
---
 include/osmocom/abis/e1_input.h |  3 ++-
 src/input/ipaccess.c            | 16 ++++++++++------
 tests/e1inp_ipa_bts_test.c      |  2 +-
 3 files changed, 13 insertions(+), 8 deletions(-)

diff --git a/include/osmocom/abis/e1_input.h b/include/osmocom/abis/e1_input.h
index 0abf0b8..2a9890c 100644
--- a/include/osmocom/abis/e1_input.h
+++ b/include/osmocom/abis/e1_input.h
@@ -258,7 +258,8 @@ struct subch_mux *e1inp_get_mux(uint8_t e1_nr, uint8_t ts_nr);
 /* on an IPA BTS, the BTS needs to establish the RSL connection much
  * later than the OML connection. */
 int e1inp_ipa_bts_rsl_connect(struct e1inp_line *line,
-			      const char *rem_addr, uint16_t rem_port);
+			      const char *rem_addr, uint16_t rem_port,
+			      uint8_t trx_id);
 
 void e1inp_sign_link_destroy(struct e1inp_sign_link *link);
 int e1inp_line_update(struct e1inp_line *line);
diff --git a/src/input/ipaccess.c b/src/input/ipaccess.c
index 9722b2f..86ddd3a 100644
--- a/src/input/ipaccess.c
+++ b/src/input/ipaccess.c
@@ -838,6 +838,7 @@ static int ipaccess_bts_read_cb(struct ipa_client_conn *link, struct msgb *msg)
 			struct e1inp_sign_link *sign_link;
 			uint8_t *data = msgb_l2(msg);
 			int len = msgb_l2len(msg);
+			struct ipaccess_unit *unit_data;
 
 			LOGP(DLINP, LOGL_NOTICE, "received ID get\n");
 			if (!link->line->ops->sign_link_up) {
@@ -847,7 +848,9 @@ static int ipaccess_bts_read_cb(struct ipa_client_conn *link, struct msgb *msg)
 				ret = -EINVAL;
 				goto err;
 			}
-			rmsg = ipa_bts_id_resp(link->line->ops->cfg.ipa.dev,
+			unit_data = (struct ipaccess_unit *)
+						link->line->ops->cfg.ipa.dev;
+			rmsg = ipa_bts_id_resp(&unit_data[link->ofd->priv_nr-1],
 						data + 1, len - 1);
 			ret = ipaccess_send(link->ofd->fd, rmsg->data,
 						rmsg->len);
@@ -869,7 +872,7 @@ static int ipaccess_bts_read_cb(struct ipa_client_conn *link, struct msgb *msg)
 			}
 			msgb_free(rmsg);
 
-			sign_link = link->line->ops->sign_link_up(msg,
+			sign_link = link->line->ops->sign_link_up(unit_data,
 					link->line,
 					link->ofd->priv_nr);
 			if (sign_link == NULL) {
@@ -885,7 +888,7 @@ static int ipaccess_bts_read_cb(struct ipa_client_conn *link, struct msgb *msg)
 	} else if (link->port == IPA_TCP_PORT_OML)
 		e1i_ts = &link->line->ts[0];
 	else if (link->port == IPA_TCP_PORT_RSL)
-		e1i_ts = &link->line->ts[1];
+		e1i_ts = &link->line->ts[link->ofd->priv_nr-1];
 
 	OSMO_ASSERT(e1i_ts != NULL);
 
@@ -1016,13 +1019,14 @@ static int ipaccess_line_update(struct e1inp_line *line)
 }
 
 int e1inp_ipa_bts_rsl_connect(struct e1inp_line *line,
-			      const char *rem_addr, uint16_t rem_port)
+			      const char *rem_addr, uint16_t rem_port,
+			      uint8_t trx_id)
 {
 	struct ipa_client_conn *rsl_link;
 
 	rsl_link = ipa_client_conn_create(tall_ipa_ctx,
-					  &line->ts[E1INP_SIGN_RSL-1],
-					  E1INP_SIGN_RSL,
+					  &line->ts[E1INP_SIGN_RSL+trx_id-1],
+					  E1INP_SIGN_RSL+trx_id,
 					  rem_addr, rem_port,
 					  ipaccess_bts_updown_cb,
 					  ipaccess_bts_read_cb,
diff --git a/tests/e1inp_ipa_bts_test.c b/tests/e1inp_ipa_bts_test.c
index 02a4cb3..a43dba3 100644
--- a/tests/e1inp_ipa_bts_test.c
+++ b/tests/e1inp_ipa_bts_test.c
@@ -70,7 +70,7 @@ sign_link_up(void *unit, struct e1inp_line *line, enum e1inp_sign_type type)
 			/* Now we can send OML messages to the BSC. */
 			bts_state = BTS_TEST_OML_SIGN_LINK_UP;
 		}
-		e1inp_ipa_bts_rsl_connect(line, "127.0.0.1", IPA_TCP_PORT_RSL);
+		e1inp_ipa_bts_rsl_connect(line, "127.0.0.1", IPA_TCP_PORT_RSL, 0);
 		break;
 	case E1INP_SIGN_RSL:
 		LOGP(DBTSTEST, LOGL_NOTICE, "RSL link up request received.\n");
-- 
1.8.1.5

>From 92addc94f1d7820d6cf8175ea5f28596f4b8ebce Mon Sep 17 00:00:00 2001
From: Andreas Eversberg <[email protected]>
Date: Mon, 20 Jan 2014 13:08:21 +0100
Subject: [PATCH] ABIS: Support for multiple RSL connections

---
 include/osmo-bts/abis.h   |  2 +-
 src/common/abis.c         | 57 ++++++++++++++++++++++++++++++++++-------------
 src/common/oml.c          |  7 +++---
 src/osmo-bts-sysmo/main.c |  2 +-
 4 files changed, 47 insertions(+), 21 deletions(-)

diff --git a/include/osmo-bts/abis.h b/include/osmo-bts/abis.h
index fb0fbd7..ceda736 100644
--- a/include/osmo-bts/abis.h
+++ b/include/osmo-bts/abis.h
@@ -17,7 +17,7 @@ enum {
 };
 
 struct e1inp_line *abis_open(struct gsm_bts *bts, const char *dst_host,
-			     const char *model_name);
+			     const char *model_name, int num_trx);
 
 
 int abis_oml_sendmsg(struct msgb *msg);
diff --git a/src/common/abis.c b/src/common/abis.c
index 37e82f3..4c4699d 100644
--- a/src/common/abis.c
+++ b/src/common/abis.c
@@ -34,6 +34,7 @@
 #include <osmocom/core/timer.h>
 #include <osmocom/core/msgb.h>
 #include <osmocom/core/signal.h>
+#include <osmocom/core/talloc.h>
 #include <osmocom/abis/abis.h>
 #include <osmocom/abis/e1_input.h>
 #include <osmocom/abis/ipaccess.h>
@@ -68,6 +69,8 @@ static struct e1inp_sign_link *sign_link_up(void *unit, struct e1inp_line *line,
 					    enum e1inp_sign_type type)
 {
 	struct e1inp_sign_link *sign_link = NULL;
+	struct gsm_bts_trx *trx;
+	uint8_t trx_id;
 
 	switch (type) {
 	case E1INP_SIGN_OML:
@@ -79,17 +82,22 @@ static struct e1inp_sign_link *sign_link_up(void *unit, struct e1inp_line *line,
 		sign_link->trx = g_bts->c0;
 		bts_link_estab(g_bts);
 		break;
-	case E1INP_SIGN_RSL:
-		LOGP(DABIS, LOGL_INFO, "RSL Signalling link up\n");
-		e1inp_ts_config_sign(&line->ts[E1INP_SIGN_RSL-1], line);
-		sign_link = g_bts->c0->rsl_link =
-			e1inp_sign_link_create(&line->ts[E1INP_SIGN_RSL-1],
-						E1INP_SIGN_RSL, NULL, 0, 0);
-		/* FIXME: This assumes there is only one TRX! */
-		sign_link->trx = g_bts->c0;
-		trx_link_estab(sign_link->trx);
-		break;
 	default:
+		trx_id = type - E1INP_SIGN_RSL;
+		LOGP(DABIS, LOGL_INFO, "RSL Signalling link for TRX %d up\n",
+			trx_id);
+		trx = gsm_bts_trx_num(g_bts, trx_id);
+		if (!trx) {
+			LOGP(DABIS, LOGL_ERROR, "TRX ID %d does not exits\n",
+				trx_id);
+			break;
+		}
+		e1inp_ts_config_sign(&line->ts[type-1], line);
+		sign_link = trx->rsl_link =
+			e1inp_sign_link_create(&line->ts[type-1],
+						E1INP_SIGN_RSL, NULL, 0, 0);
+		sign_link->trx = trx;
+		trx_link_estab(trx);
 		break;
 	}
 
@@ -98,12 +106,16 @@ static struct e1inp_sign_link *sign_link_up(void *unit, struct e1inp_line *line,
 
 static void sign_link_down(struct e1inp_line *line)
 {
+	struct gsm_bts_trx *trx;
+
 	LOGP(DABIS, LOGL_ERROR, "Signalling link down\n");
 
-	if (g_bts->c0->rsl_link) {
-		e1inp_sign_link_destroy(g_bts->c0->rsl_link);
-		g_bts->c0->rsl_link = NULL;
-		trx_link_estab(g_bts->c0);
+	llist_for_each_entry(trx, &g_bts->trx_list, list) {
+		if (trx->rsl_link) {
+			e1inp_sign_link_destroy(trx->rsl_link);
+			trx->rsl_link = NULL;
+			trx_link_estab(trx);
+		}
 	}
 
 	if (g_bts->oml_link)
@@ -212,7 +224,6 @@ static struct e1inp_line_ops line_ops = {
 	.cfg = {
 		.ipa = {
 			.role	= E1INP_LINE_R_BTS,
-			.dev	= &bts_dev_info,
 		},
 	},
 	.sign_link_up	= sign_link_up,
@@ -224,9 +235,11 @@ static struct e1inp_line_ops line_ops = {
  * global initialization as well as the actual opening of the A-bis link
  * */
 struct e1inp_line *abis_open(struct gsm_bts *bts, const char *dst_host,
-			     const char *model_name)
+			     const char *model_name, int num_trx)
 {
 	struct e1inp_line *line;
+	struct ipaccess_unit *units;
+	int i;
 
 	g_bts = bts;
 
@@ -236,6 +249,13 @@ struct e1inp_line *abis_open(struct gsm_bts *bts, const char *dst_host,
 
 	osmo_signal_register_handler(SS_L_INPUT, &inp_s_cbfn, bts);
 
+	/* allocate list of ipaccess dev info (OML and each RSL connection) */
+	units = talloc_zero_array(tall_bts_ctx, struct ipaccess_unit,
+	        num_trx+1);
+	if (!units)
+		return NULL;
+	line_ops.cfg.ipa.dev = units;
+
 	/* patch in various data from VTY and othe sources */
 	line_ops.cfg.ipa.addr = dst_host;
 	get_mac_addr("eth0", bts_dev_info.mac_addr);
@@ -250,6 +270,11 @@ struct e1inp_line *abis_open(struct gsm_bts *bts, const char *dst_host,
 	if (!line)
 		return NULL;
 	e1inp_line_bind_ops(line, &line_ops);
+	memcpy(&units[0], &bts_dev_info, sizeof(*units));
+	for (i = 0; i < num_trx; i++) {
+		memcpy(&units[i+1], &bts_dev_info, sizeof(*units));
+		units[i+1].trx_id = i;
+	}
 
 	/* This is what currently starts both the outbound OML and RSL
 	 * connections, which is wrong.
diff --git a/src/common/oml.c b/src/common/oml.c
index bf174b5..acde230 100644
--- a/src/common/oml.c
+++ b/src/common/oml.c
@@ -1018,10 +1018,11 @@ static int rx_oml_ipa_rsl_connect(struct gsm_bts_trx *trx, struct msgb *msg,
 	}
 
 	in.s_addr = htonl(ip);
-	LOGP(DOML, LOGL_INFO, "Rx IPA RSL CONNECT IP=%s PORT=%u STREAM=0x%02x\n", 
-		inet_ntoa(in), port, stream_id);
+	LOGP(DOML, LOGL_INFO, "Rx IPA RSL CONNECT TRX=%d IP=%s PORT=%u "
+		"STREAM=0x%02x\n", trx->nr, inet_ntoa(in), port, stream_id);
 
-	rc = e1inp_ipa_bts_rsl_connect(oml_link->ts->line, inet_ntoa(in), port);
+	rc = e1inp_ipa_bts_rsl_connect(oml_link->ts->line, inet_ntoa(in), port,
+		trx->nr);
 	if (rc < 0) {
 		LOGP(DOML, LOGL_ERROR, "Error in abis_open(RSL): %d\n", rc);
 		return oml_fom_ack_nack(msg, NM_NACK_CANT_PERFORM);
diff --git a/src/osmo-bts-sysmo/main.c b/src/osmo-bts-sysmo/main.c
index 74ee47f..f85748f 100644
--- a/src/osmo-bts-sysmo/main.c
+++ b/src/osmo-bts-sysmo/main.c
@@ -365,7 +365,7 @@ int main(int argc, char **argv)
 		exit(1);
 	}
 
-	line = abis_open(bts, btsb->bsc_oml_host, "sysmoBTS");
+	line = abis_open(bts, btsb->bsc_oml_host, "sysmoBTS", 1);
 	if (!line) {
 		fprintf(stderr, "unable to connect to BSC\n");
 		exit(1);
-- 
1.8.1.5

Reply via email to