hi,

while re-basing the osmo-bts-trx code with master,  i saw that the ABIS
code has been replaced by libosmo-abis. libosmo-abis is not capable of
handling multiple RSL connections, so the multi-TRX support is broke
now. the attached patch will add multiple RSL connection support to
libosmo-abis.

regards,

andreas

>From 47ea6212d3b090b4ceba02f4c39ba92c48eefb7f Mon Sep 17 00:00:00 2001
From: Andreas Eversberg <[email protected]>
Date: Tue, 14 Jan 2014 12:32:35 +0100
Subject: [PATCH] Support of multiple RSL connections for 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 tested with osmobts-trx.

The user of e1inp_ipa_bts_rsl_connect() (which is osmo-bts) must be
upgraded after applying the patch.

src/common/oml.c
-       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, 
0);
---
 include/osmocom/abis/e1_input.h |  3 ++-
 src/input/ipaccess.c            | 18 +++++++++++-------
 tests/e1inp_ipa_bts_test.c      |  2 +-
 3 files changed, 14 insertions(+), 9 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..20894e4 100644
--- a/src/input/ipaccess.c
+++ b/src/input/ipaccess.c
@@ -717,7 +717,7 @@ err_line:
 #define IPA_STRING_MAX 64
 
 static struct msgb *
-ipa_bts_id_resp(struct ipaccess_unit *dev, uint8_t *data, int len)
+ipa_bts_id_resp(struct ipaccess_unit *dev, uint8_t *data, int len, int trx_nr)
 {
        struct msgb *nmsg;
        char str[IPA_STRING_MAX];
@@ -738,7 +738,7 @@ ipa_bts_id_resp(struct ipaccess_unit *dev, uint8_t *data, 
int len)
                switch (data[1]) {
                case IPAC_IDTAG_UNIT:
                        snprintf(str, sizeof(str), "%u/%u/%u",
-                               dev->site_id, dev->bts_id, dev->trx_id);
+                               dev->site_id, dev->bts_id, trx_nr);
                        break;
                case IPAC_IDTAG_MACADDR:
                        snprintf(str, sizeof(str),
@@ -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);
+                       int trx_nr = 0;
 
                        LOGP(DLINP, LOGL_NOTICE, "received ID get\n");
                        if (!link->line->ops->sign_link_up) {
@@ -847,8 +848,10 @@ static int ipaccess_bts_read_cb(struct ipa_client_conn 
*link, struct msgb *msg)
                                ret = -EINVAL;
                                goto err;
                        }
+                       if (link->ofd->priv_nr >= E1INP_SIGN_RSL)
+                               trx_nr = link->ofd->priv_nr - E1INP_SIGN_RSL;
                        rmsg = ipa_bts_id_resp(link->line->ops->cfg.ipa.dev,
-                                               data + 1, len - 1);
+                                               data + 1, len - 1, trx_nr);
                        ret = ipaccess_send(link->ofd->fd, rmsg->data,
                                                rmsg->len);
                        if (ret != rmsg->len) {
@@ -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

Reply via email to