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/.
Vadim Yanitskiy gerrit-no-reply at lists.osmocom.orgVadim Yanitskiy has uploaded this change for review. ( https://gerrit.osmocom.org/12582 Change subject: trxcon/trx_if: refactor trx_if_open() ...................................................................... trxcon/trx_if: refactor trx_if_open() Change-Id: I39b24afee2f09d6a6c500cfc26ac45f206589c5c --- M src/host/trxcon/trx_if.c M src/host/trxcon/trx_if.h M src/host/trxcon/trxcon.c 3 files changed, 23 insertions(+), 27 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmocom-bb refs/changes/82/12582/1 diff --git a/src/host/trxcon/trx_if.c b/src/host/trxcon/trx_if.c index 982fb40..108f58b 100644 --- a/src/host/trxcon/trx_if.c +++ b/src/host/trxcon/trx_if.c @@ -626,52 +626,47 @@ return 0; } -/* - * Open/close OsmoTRX connection - */ - -int trx_if_open(struct trx_instance **trx, const char *local_host, - const char *remote_host, uint16_t port) +/* Init TRX interface (TRXC, TRXD sockets and FSM) */ +struct trx_instance *trx_if_open(void *tall_ctx, + const char *local_host, const char *remote_host, uint16_t port) { - struct trx_instance *trx_new; + struct trx_instance *trx; int rc; LOGP(DTRX, LOGL_NOTICE, "Init transceiver interface\n"); /* Try to allocate memory */ - trx_new = talloc_zero(tall_trx_ctx, struct trx_instance); - if (!trx_new) { + trx = talloc_zero(tall_ctx, struct trx_instance); + if (!trx) { LOGP(DTRX, LOGL_ERROR, "Failed to allocate memory\n"); - return -ENOMEM; + return NULL; } /* Initialize CTRL queue */ - INIT_LLIST_HEAD(&trx_new->trx_ctrl_list); + INIT_LLIST_HEAD(&trx->trx_ctrl_list); /* Open sockets */ - rc = trx_udp_open(trx_new, &trx_new->trx_ofd_ctrl, local_host, + rc = trx_udp_open(trx, &trx->trx_ofd_ctrl, local_host, port + 101, remote_host, port + 1, trx_ctrl_read_cb); if (rc < 0) - goto error; + goto udp_error; - rc = trx_udp_open(trx_new, &trx_new->trx_ofd_data, local_host, + rc = trx_udp_open(trx, &trx->trx_ofd_data, local_host, port + 102, remote_host, port + 2, trx_data_rx_cb); if (rc < 0) - goto error; + goto udp_error; /* Allocate a new dedicated state machine */ osmo_fsm_register(&trx_fsm); - trx_new->fsm = osmo_fsm_inst_alloc(&trx_fsm, trx_new, + trx->fsm = osmo_fsm_inst_alloc(&trx_fsm, trx, NULL, LOGL_DEBUG, "trx_interface"); - *trx = trx_new; + return trx; - return 0; - -error: +udp_error: LOGP(DTRX, LOGL_ERROR, "Couldn't establish UDP connection\n"); - talloc_free(trx_new); - return rc; + talloc_free(trx); + return NULL; } /* Flush pending control messages */ diff --git a/src/host/trxcon/trx_if.h b/src/host/trxcon/trx_if.h index d551252..0b3f36f 100644 --- a/src/host/trxcon/trx_if.h +++ b/src/host/trxcon/trx_if.h @@ -52,8 +52,8 @@ int cmd_len; }; -int trx_if_open(struct trx_instance **trx, const char *local_host, - const char *remote_host, uint16_t port); +struct trx_instance *trx_if_open(void *tall_ctx, + const char *local_host, const char *remote_host, uint16_t port); void trx_if_flush_ctrl(struct trx_instance *trx); void trx_if_close(struct trx_instance *trx); diff --git a/src/host/trxcon/trxcon.c b/src/host/trxcon/trxcon.c index 874f893..501d0c7 100644 --- a/src/host/trxcon/trxcon.c +++ b/src/host/trxcon/trxcon.c @@ -284,9 +284,10 @@ goto exit; /* Init transceiver interface */ - rc = trx_if_open(&app_data.trx, - app_data.trx_bind_ip, app_data.trx_remote_ip, app_data.trx_base_port); - if (rc) + app_data.trx = trx_if_open(tall_trx_ctx, + app_data.trx_bind_ip, app_data.trx_remote_ip, + app_data.trx_base_port); + if (!app_data.trx) goto exit; /* Bind L1CTL with TRX and vice versa */ -- To view, visit https://gerrit.osmocom.org/12582 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmocom-bb Gerrit-Branch: master Gerrit-MessageType: newchange Gerrit-Change-Id: I39b24afee2f09d6a6c500cfc26ac45f206589c5c Gerrit-Change-Number: 12582 Gerrit-PatchSet: 1 Gerrit-Owner: Vadim Yanitskiy <axilirator at gmail.com> -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20190116/753fb38f/attachment.htm>