fixeria has uploaded this change for review. ( https://gerrit.osmocom.org/c/libosmocore/+/35171?usp=email )
Change subject: soft_uart: check Rx/Tx state once in osmo_soft_uart_{rx,tx}_ubits()
......................................................................
soft_uart: check Rx/Tx state once in osmo_soft_uart_{rx,tx}_ubits()
Check it once rather than doing this in a loop. Return -EAGAIN if
Rx or Tx is not enabled when calling osmo_soft_uart_{rx,tx}_ubits().
This [theoretically] improves performance by reducing the number of
conditional statements in loops. In the Tx path, this also prevents
calling the .tx_cb() when the transmitter is disabled, so that we
don't loose the application data.
Change-Id: I70f93b3655eb21c2323e451052c40cd305c016c8
Related: OS#4396
---
M src/core/soft_uart.c
M tests/soft_uart/soft_uart_test.c
2 files changed, 31 insertions(+), 6 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/71/35171/1
diff --git a/src/core/soft_uart.c b/src/core/soft_uart.c
index 8d9142b..1d9984b 100644
--- a/src/core/soft_uart.c
+++ b/src/core/soft_uart.c
@@ -111,9 +111,6 @@
/* receive a single bit */
static inline void osmo_uart_rx_bit(struct osmo_soft_uart *suart, const ubit_t bit)
{
- if (!suart->rx.running)
- return;
-
switch (suart->rx.flow_state) {
case SUART_FLOW_ST_IDLE:
if (bit == 0) { /* start bit condition */
@@ -199,6 +196,8 @@
* \returns 0 on success; negative on error. */
int osmo_soft_uart_rx_ubits(struct osmo_soft_uart *suart, const ubit_t *ubits, size_t n_ubits)
{
+ if (!suart->rx.running)
+ return -EAGAIN;
for (size_t i = 0; i < n_ubits; i++)
osmo_uart_rx_bit(suart, ubits[i]);
return 0;
@@ -213,9 +212,6 @@
{
ubit_t tx_bit = 1;
- if (!suart->tx.running)
- return tx_bit;
-
switch (suart->tx.flow_state) {
case SUART_FLOW_ST_IDLE:
if (msg && msgb_length(msg) > 0) { /* if we have pending data */
@@ -290,6 +286,9 @@
if (OSMO_UNLIKELY(n_ubits == 0))
return -EINVAL;
+ if (!suart->tx.running)
+ return -EAGAIN;
+
/* calculate UART frame size for the effective config */
n_frame_bits = 1 + cfg->num_data_bits + cfg->num_stop_bits;
if (cfg->parity_mode != OSMO_SUART_PARITY_NONE)
diff --git a/tests/soft_uart/soft_uart_test.c b/tests/soft_uart/soft_uart_test.c
index 522739a..f1b0b25 100644
--- a/tests/soft_uart/soft_uart_test.c
+++ b/tests/soft_uart/soft_uart_test.c
@@ -256,10 +256,18 @@
{
struct osmo_soft_uart_cfg cfg;
struct osmo_soft_uart *suart;
+ int rc;
suart = osmo_soft_uart_alloc(NULL, __func__, &suart_test_default_cfg);
OSMO_ASSERT(suart != NULL);
+ /* expect -EAGAIN when the transmitter is not enabled */
+ rc = osmo_soft_uart_tx_ubits(suart, NULL, 42);
+ OSMO_ASSERT(rc == -EAGAIN);
+ /* expect -EAGAIN when the receicer is not enabled */
+ rc = osmo_soft_uart_rx_ubits(suart, NULL, 42);
+ OSMO_ASSERT(rc == -EAGAIN);
+
osmo_soft_uart_set_tx(suart, true);
osmo_soft_uart_set_rx(suart, true);
--
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/35171?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: I70f93b3655eb21c2323e451052c40cd305c016c8
Gerrit-Change-Number: 35171
Gerrit-PatchSet: 1
Gerrit-Owner: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-MessageType: newchange
daniel has abandoned this change. ( https://gerrit.osmocom.org/c/libosmocore/+/35163?usp=email )
Change subject: utils: Link with libosmoisdn to avoid undefined references
......................................................................
Abandoned
--
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/35163?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: I9e99231899b269a4ec0faf720aff4dc8d2b74323
Gerrit-Change-Number: 35163
Gerrit-PatchSet: 1
Gerrit-Owner: daniel <dwillmann(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: daniel <dwillmann(a)sysmocom.de>
Gerrit-Reviewer: jolly <andreas(a)eversberg.eu>
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-Reviewer: pespin <pespin(a)sysmocom.de>
Gerrit-CC: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-MessageType: abandon
Attention is currently required from: fixeria, jolly, laforge.
daniel has posted comments on this change. ( https://gerrit.osmocom.org/c/libosmocore/+/35163?usp=email )
Change subject: utils: Link with libosmoisdn to avoid undefined references
......................................................................
Patch Set 1: Code-Review-2
(1 comment)
Patchset:
PS1:
> Running `make -C utils/ V=s` locally: […]
I just tested it again and it links fine now. Not sure what happened before, I'm sure I saw it even after make distclean...
--
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/35163?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: I9e99231899b269a4ec0faf720aff4dc8d2b74323
Gerrit-Change-Number: 35163
Gerrit-PatchSet: 1
Gerrit-Owner: daniel <dwillmann(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: daniel <dwillmann(a)sysmocom.de>
Gerrit-Reviewer: jolly <andreas(a)eversberg.eu>
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-Reviewer: pespin <pespin(a)sysmocom.de>
Gerrit-CC: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Attention: jolly <andreas(a)eversberg.eu>
Gerrit-Attention: laforge <laforge(a)osmocom.org>
Gerrit-Attention: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Comment-Date: Wed, 29 Nov 2023 22:05:46 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Comment-In-Reply-To: laforge <laforge(a)osmocom.org>
Comment-In-Reply-To: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-MessageType: comment
Attention is currently required from: daniel, fixeria, jolly, laforge.
fixeria has posted comments on this change. ( https://gerrit.osmocom.org/c/libosmocore/+/35163?usp=email )
Change subject: utils: Link with libosmoisdn to avoid undefined references
......................................................................
Patch Set 1:
(2 comments)
Commit Message:
https://gerrit.osmocom.org/c/libosmocore/+/35163/comment/ec36a68b_72005910
PS1, Line 10: osmo-arfcn
Weird. osmo-arfcn is not calling any of these functions. It should not depend on LAPDm at all, it's just a very simple "calculator". Perhaps it's the `-no-undefined` in `libosmogsm_la_LDFLAGS` somehow triggering the linker? I am unable to reproduce this when building libosmocore locally.
Patchset:
PS1:
> I think this is wrong. […]
Those symbols are needed for libosmogsm. In `src/gsm/Makefile.am` we list `libosmoisdn.la` as a dependency of `libgsmint.la`, which in turn is a dependency of `libosmogsm.la`. I would expect `libosmoisdn.la` to be an explicit dependency of `libosmogsm.la`, just like the `libosmocore.la`.
--
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/35163?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: I9e99231899b269a4ec0faf720aff4dc8d2b74323
Gerrit-Change-Number: 35163
Gerrit-PatchSet: 1
Gerrit-Owner: daniel <dwillmann(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <axilirator(a)gmail.com>
Gerrit-Reviewer: jolly <andreas(a)eversberg.eu>
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-Reviewer: pespin <pespin(a)sysmocom.de>
Gerrit-CC: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Attention: jolly <andreas(a)eversberg.eu>
Gerrit-Attention: laforge <laforge(a)osmocom.org>
Gerrit-Attention: daniel <dwillmann(a)sysmocom.de>
Gerrit-Attention: fixeria <axilirator(a)gmail.com>
Gerrit-Comment-Date: Wed, 29 Nov 2023 20:55:33 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: laforge <laforge(a)osmocom.org>
Gerrit-MessageType: comment
Attention is currently required from: pespin.
laforge has posted comments on this change. ( https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/35166?usp=email )
Change subject: hnbgw: Allow announcing a different mgw-local IuUP address after MDCX
......................................................................
Patch Set 1: Code-Review+1
--
To view, visit https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/35166?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: osmo-ttcn3-hacks
Gerrit-Branch: master
Gerrit-Change-Id: Ia724e0363a8bab56f5d31e7f7f7a127af584f935
Gerrit-Change-Number: 35166
Gerrit-PatchSet: 1
Gerrit-Owner: pespin <pespin(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-Attention: pespin <pespin(a)sysmocom.de>
Gerrit-Comment-Date: Wed, 29 Nov 2023 20:45:06 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment