fixeria has uploaded this change for review.

View Change

trxcon: support handling of multiple L1CTL client connections

Change-Id: Id92e5b553487e4cf10ea291b487a3ef0c65d72ae
---
M src/host/trxcon/include/osmocom/bb/trxcon/l1ctl_server.h
M src/host/trxcon/include/osmocom/bb/trxcon/trxcon.h
M src/host/trxcon/src/l1ctl_server.c
M src/host/trxcon/src/trx_if.c
M src/host/trxcon/src/trxcon.c
5 files changed, 21 insertions(+), 15 deletions(-)

git pull ssh://gerrit.osmocom.org:29418/osmocom-bb refs/changes/78/28678/1
diff --git a/src/host/trxcon/include/osmocom/bb/trxcon/l1ctl_server.h b/src/host/trxcon/include/osmocom/bb/trxcon/l1ctl_server.h
index d16ca5c..22bf368 100644
--- a/src/host/trxcon/include/osmocom/bb/trxcon/l1ctl_server.h
+++ b/src/host/trxcon/include/osmocom/bb/trxcon/l1ctl_server.h
@@ -23,6 +23,7 @@

struct l1ctl_server {
struct llist_head clients;
+ unsigned int num_clients;
struct osmo_fd ofd;
void *talloc_ctx;

@@ -35,6 +36,7 @@
struct llist_head list;
struct l1ctl_server *server;
struct osmo_wqueue wq;
+ unsigned int index;
void *priv;
};

diff --git a/src/host/trxcon/include/osmocom/bb/trxcon/trxcon.h b/src/host/trxcon/include/osmocom/bb/trxcon/trxcon.h
index 2c28f80..dc2fc33 100644
--- a/src/host/trxcon/include/osmocom/bb/trxcon/trxcon.h
+++ b/src/host/trxcon/include/osmocom/bb/trxcon/trxcon.h
@@ -21,6 +21,7 @@

struct trxcon_inst {
struct osmo_fsm_inst *fi;
+ unsigned int index;

/* The L1 scheduler */
struct l1sched_state *sched;
@@ -33,5 +34,5 @@
bool fbsb_conf_sent;
};

-struct trxcon_inst *trxcon_inst_alloc(void *ctx);
+struct trxcon_inst *trxcon_inst_alloc(void *ctx, unsigned int idx);
void trxcon_inst_free(struct trxcon_inst *trxcon);
diff --git a/src/host/trxcon/src/l1ctl_server.c b/src/host/trxcon/src/l1ctl_server.c
index 7152a53..44cccdf 100644
--- a/src/host/trxcon/src/l1ctl_server.c
+++ b/src/host/trxcon/src/l1ctl_server.c
@@ -120,14 +120,6 @@
return client_fd;
}

- /* TODO: remove this barrier when multi-trxcon support is implemented */
- if (!llist_empty(&server->clients)) {
- LOGP(DL1C, LOGL_NOTICE, "L1CTL client rejected: "
- "we already have an active connection\n");
- close(client_fd);
- return -ENOMEM;
- }
-
client = talloc_zero(server->talloc_ctx, struct l1ctl_client);
if (client == NULL) {
LOGP(DL1C, LOGL_ERROR, "Failed to allocate an L1CTL client\n");
@@ -155,6 +147,7 @@
LOGP(DL1C, LOGL_NOTICE, "L1CTL server got a new connection\n");

llist_add_tail(&client->list, &server->clients);
+ client->index = server->num_clients++;
client->server = server;

if (client->server->conn_accept_cb != NULL)
@@ -201,6 +194,8 @@
osmo_wqueue_clear(&client->wq);

llist_del(&client->list);
+ client->server->num_clients--;
+
talloc_free(client);
}

diff --git a/src/host/trxcon/src/trx_if.c b/src/host/trxcon/src/trx_if.c
index e7327c9..d61eddb 100644
--- a/src/host/trxcon/src/trx_if.c
+++ b/src/host/trxcon/src/trx_if.c
@@ -696,6 +696,7 @@
const char *local_host, const char *remote_host,
uint16_t base_port)
{
+ const unsigned int offset = trxcon->index * 2;
struct trx_instance *trx;
int rc;

@@ -722,13 +723,17 @@
INIT_LLIST_HEAD(&trx->trx_ctrl_list);

/* Open sockets */
- rc = trx_udp_open(trx, &trx->trx_ofd_ctrl, local_host,
- base_port + 101, remote_host, base_port + 1, trx_ctrl_read_cb);
+ rc = trx_udp_open(trx, &trx->trx_ofd_ctrl, /* TRXC */
+ local_host, base_port + 101 + offset,
+ remote_host, base_port + 1 + offset,
+ trx_ctrl_read_cb);
if (rc < 0)
goto udp_error;

- rc = trx_udp_open(trx, &trx->trx_ofd_data, local_host,
- base_port + 102, remote_host, base_port + 2, trx_data_rx_cb);
+ rc = trx_udp_open(trx, &trx->trx_ofd_data, /* TRXD */
+ local_host, base_port + 102 + offset,
+ remote_host, base_port + 2 + offset,
+ trx_data_rx_cb);
if (rc < 0)
goto udp_error;

diff --git a/src/host/trxcon/src/trxcon.c b/src/host/trxcon/src/trxcon.c
index 3b03956..2c9318a 100644
--- a/src/host/trxcon/src/trxcon.c
+++ b/src/host/trxcon/src/trxcon.c
@@ -322,7 +322,7 @@
.event_names = trxcon_fsm_event_names,
};

-struct trxcon_inst *trxcon_inst_alloc(void *ctx)
+struct trxcon_inst *trxcon_inst_alloc(void *ctx, unsigned int index)
{
struct trxcon_inst *trxcon;

@@ -333,6 +333,9 @@
trxcon, LOGL_DEBUG, NULL);
OSMO_ASSERT(trxcon->fi != NULL);

+ osmo_fsm_inst_update_id_f(trxcon->fi, "trxcon-%u", index);
+ trxcon->index = index;
+
/* Init transceiver interface */
trxcon->trx = trx_if_open(trxcon,
app_data.trx_bind_ip,
@@ -376,7 +379,7 @@
{
struct trxcon_inst *trxcon;

- trxcon = trxcon_inst_alloc(l1c);
+ trxcon = trxcon_inst_alloc(l1c, l1c->index);
if (trxcon == NULL) {
l1ctl_client_conn_close(l1c);
return;

To view, visit change 28678. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: osmocom-bb
Gerrit-Branch: master
Gerrit-Change-Id: Id92e5b553487e4cf10ea291b487a3ef0c65d72ae
Gerrit-Change-Number: 28678
Gerrit-PatchSet: 1
Gerrit-Owner: fixeria <vyanitskiy@sysmocom.de>
Gerrit-MessageType: newchange