fixeria has uploaded this change for review.
libosmo-trx/ep: make TRXDv2+ PDU batching configurable
Change-Id: I60b8337db4ec8e70d37b2d9c0b75da338386ec47
Related: OS#6672
---
M libosmo-trx/include/osmocom/trx/ep.h
M libosmo-trx/src/trx_ep.c
M tests/libosmo-trx/trx_ep_test.c
M tests/libosmo-trx/trx_ep_test.ok
4 files changed, 57 insertions(+), 4 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/osmo-trx refs/changes/27/43627/1
diff --git a/libosmo-trx/include/osmocom/trx/ep.h b/libosmo-trx/include/osmocom/trx/ep.h
index 9f1e589..26d8154 100644
--- a/libosmo-trx/include/osmocom/trx/ep.h
+++ b/libosmo-trx/include/osmocom/trx/ep.h
@@ -110,6 +110,9 @@
int osmo_trx_ep_set_ctrl_promisc(struct osmo_trx_ep *ep, bool enable);
bool osmo_trx_ep_get_ctrl_promisc(const struct osmo_trx_ep *ep);
+void osmo_trx_ep_set_pdu_batch(struct osmo_trx_ep *ep, bool enable);
+bool osmo_trx_ep_get_pdu_batch(const struct osmo_trx_ep *ep);
+
/*! Per-channel TRXD PDU version in use (set after SETFORMAT negotiation) */
int osmo_trx_ep_set_pdu_ver(struct osmo_trx_ep *ep, unsigned int chan, uint8_t ver);
int osmo_trx_ep_get_pdu_ver(const struct osmo_trx_ep *ep, unsigned int chan);
diff --git a/libosmo-trx/src/trx_ep.c b/libosmo-trx/src/trx_ep.c
index e08e61a..074d4ad 100644
--- a/libosmo-trx/src/trx_ep.c
+++ b/libosmo-trx/src/trx_ep.c
@@ -82,6 +82,9 @@
#define OSMO_TRX_EP_F_PENDING_FREE (1 << 2)
/*! Leave the ctrl socket unconnected, accepting/replying to any peer */
#define OSMO_TRX_EP_F_CTRL_PROMISC (1 << 3)
+/*! Send one datagram per PDU instead of batching a TDMA frame's worth of
+ * BURST.ind/req PDUs into one, even if TRXDv2+ is negotiated */
+#define OSMO_TRX_EP_F_NO_PDU_BATCH (1 << 4)
struct osmo_trx_ep {
uint32_t flags; /* see OSMO_TRX_EP_F_* */
@@ -800,6 +803,26 @@
return ep->flags & OSMO_TRX_EP_F_CTRL_PROMISC;
}
+/*! Enable/disable batching BURST.ind/req PDUs on the data sockets (default:
+ * true): when enabled and TRXDv2 (or higher) is negotiated on a channel, a
+ * TDMA frame's worth of PDUs is accumulated and sent in a single datagram
+ * (see osmo_trx_ep_send_burst_ind()/_req()); when disabled, every PDU is
+ * sent in its own datagram regardless of the negotiated TRXD PDU version,
+ * trading datagram count for latency. May be changed at any time. */
+void osmo_trx_ep_set_pdu_batch(struct osmo_trx_ep *ep, bool enable)
+{
+ if (enable)
+ ep->flags &= ~OSMO_TRX_EP_F_NO_PDU_BATCH;
+ else
+ ep->flags |= OSMO_TRX_EP_F_NO_PDU_BATCH;
+}
+
+/*! Whether batching BURST.ind/req PDUs on the data sockets is enabled */
+bool osmo_trx_ep_get_pdu_batch(const struct osmo_trx_ep *ep)
+{
+ return ~ep->flags & OSMO_TRX_EP_F_NO_PDU_BATCH;
+}
+
/*! Set the name (log prefix) of the given instance, e.g. "phy0" */
int osmo_trx_ep_set_name(struct osmo_trx_ep *ep, const char *fmt, ...)
{
@@ -960,8 +983,8 @@
return rc;
}
- /* TRXDv2 and higher: wait for the batching breaker */
- if (c->pdu_ver >= 2) {
+ /* TRXDv2 and higher: wait for the batching breaker (unless disabled) */
+ if (c->pdu_ver >= 2 && (~ep->flags & OSMO_TRX_EP_F_NO_PDU_BATCH)) {
c->tx_msg = msg;
return 0;
}
@@ -1022,8 +1045,8 @@
return rc;
}
- /* TRXDv2 and higher: wait for the batching breaker */
- if (c->pdu_ver >= 2) {
+ /* TRXDv2 and higher: wait for the batching breaker (unless disabled) */
+ if (c->pdu_ver >= 2 && (~ep->flags & OSMO_TRX_EP_F_NO_PDU_BATCH)) {
c->tx_msg = msg;
return 0;
}
diff --git a/tests/libosmo-trx/trx_ep_test.c b/tests/libosmo-trx/trx_ep_test.c
index cd57ba8..a4227f0 100644
--- a/tests/libosmo-trx/trx_ep_test.c
+++ b/tests/libosmo-trx/trx_ep_test.c
@@ -279,6 +279,18 @@
printf("BURST.req batch breaker\n");
flush_io();
+ printf("=== %s(): BURST.req, TRXDv2 with batching disabled (BTS -> TRX) ===\n", __func__);
+ OSMO_ASSERT(osmo_trx_ep_get_pdu_batch(ep_bts) == true);
+ osmo_trx_ep_set_pdu_batch(ep_bts, false);
+ OSMO_ASSERT(osmo_trx_ep_get_pdu_batch(ep_bts) == false);
+ fill_burst_req(&br, 300000);
+ br.tn = 1;
+ OSMO_ASSERT(osmo_trx_ep_send_burst_req(ep_bts, 0, &br) == 0);
+ /* nothing was accumulated: the breaker has nothing to flush */
+ OSMO_ASSERT(osmo_trx_ep_send_burst_req(ep_bts, 0, NULL) == -ENOMSG);
+ flush_io();
+ osmo_trx_ep_set_pdu_batch(ep_bts, true); /* restore default */
+
printf("=== %s(): BURST.ind batch, TRXDv2 with NOPE (TRX -> BTS) ===\n", __func__);
/* an empty batch cannot be flushed */
OSMO_ASSERT(osmo_trx_ep_send_burst_ind(ep_trx, 0, NULL) == -ENOMSG);
@@ -295,6 +307,17 @@
printf("BURST.ind batch breaker\n");
flush_io();
+ printf("=== %s(): BURST.ind, TRXDv2 with batching disabled (TRX -> BTS) ===\n", __func__);
+ OSMO_ASSERT(osmo_trx_ep_get_pdu_batch(ep_trx) == true);
+ osmo_trx_ep_set_pdu_batch(ep_trx, false);
+ OSMO_ASSERT(osmo_trx_ep_get_pdu_batch(ep_trx) == false);
+ fill_burst_ind(&bi, 300005);
+ OSMO_ASSERT(osmo_trx_ep_send_burst_ind(ep_trx, 0, &bi) == 0);
+ /* nothing was accumulated: the breaker has nothing to flush */
+ OSMO_ASSERT(osmo_trx_ep_send_burst_ind(ep_trx, 0, NULL) == -ENOMSG);
+ flush_io();
+ osmo_trx_ep_set_pdu_batch(ep_trx, true); /* restore default */
+
ep_close_free(ep_trx);
ep_close_free(ep_bts);
}
diff --git a/tests/libosmo-trx/trx_ep_test.ok b/tests/libosmo-trx/trx_ep_test.ok
index eb39457..84de3c7 100644
--- a/tests/libosmo-trx/trx_ep_test.ok
+++ b/tests/libosmo-trx/trx_ep_test.ok
@@ -22,10 +22,14 @@
BURST.req batch breaker
trx: rx_burst_req(chan=0): BURST.req tn=1 fn=200000 att=10 trx_num=0 mod=GMSK set=0 tsc=7 burst_len=148
trx: rx_burst_req(chan=0): BURST.req tn=2 fn=200000 att=10 trx_num=0 mod=GMSK set=0 tsc=7 burst_len=148
+=== test_burst_req_ind(): BURST.req, TRXDv2 with batching disabled (BTS -> TRX) ===
+trx: rx_burst_req(chan=0): BURST.req tn=1 fn=300000 att=10 trx_num=0 mod=GMSK set=0 tsc=7 burst_len=148
=== test_burst_req_ind(): BURST.ind batch, TRXDv2 with NOPE (TRX -> BTS) ===
BURST.ind batch breaker
bts: rx_burst_ind(chan=0): NOPE.ind tn=5 fn=200005 trx_num=0 rssi=-63 toa256=-512 C/I=-150 cB
bts: rx_burst_ind(chan=0): BURST.ind tn=6 fn=200005 trx_num=0 rssi=-63 toa256=-512 C/I=-150 cB mod=GMSK set=0 tsc=7 burst_len=148
+=== test_burst_req_ind(): BURST.ind, TRXDv2 with batching disabled (TRX -> BTS) ===
+bts: rx_burst_ind(chan=0): BURST.ind tn=5 fn=300005 trx_num=0 rssi=-63 toa256=-512 C/I=-150 cB mod=GMSK set=0 tsc=7 burst_len=148
=== test_ctrl_close_flush(do_free=0): starting testcase ===
=== test_ctrl_close_flush(): TRXC CMDs sent right before osmo_trx_ep_close() (BTS -> TRX) ===
bts: closed_cb()
To view, visit change 43627. To unsubscribe, or for help writing mail filters, visit settings.