lists.osmocom.org
Sign In Sign Up
Manage this list Sign In Sign Up

Keyboard Shortcuts

Thread View

  • j: Next unread message
  • k: Previous unread message
  • j a: Jump to all threads
  • j l: Jump to MailingList overview

gerrit-log

Thread Start a new thread
Download
Threads by month
  • ----- 2026 -----
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2025 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2024 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2023 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2022 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
gerrit-log@lists.osmocom.org

December 2025

  • 1 participants
  • 1175 discussions
[XS] Change in osmo-bts[master]: cosmetic: bts-trx: fix typo in comment
by osmith 15 Dec '25

15 Dec '25
Attention is currently required from: pespin. osmith has posted comments on this change by pespin. ( https://gerrit.osmocom.org/c/osmo-bts/+/41661?usp=email ) Change subject: cosmetic: bts-trx: fix typo in comment ...................................................................... Patch Set 1: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/c/osmo-bts/+/41661?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email Gerrit-MessageType: comment Gerrit-Project: osmo-bts Gerrit-Branch: master Gerrit-Change-Id: Ibe589f4d26899d92560a60751f62bd5e8380835a Gerrit-Change-Number: 41661 Gerrit-PatchSet: 1 Gerrit-Owner: pespin <pespin(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: osmith <osmith(a)sysmocom.de> Gerrit-Attention: pespin <pespin(a)sysmocom.de> Gerrit-Comment-Date: Mon, 15 Dec 2025 11:09:51 +0000 Gerrit-HasComments: No Gerrit-Has-Labels: Yes
1 0
0 0
[M] Change in osmo-bts[master]: bts-trx: define TRXD_MSG_BUF_SIZE as a more realistic lower value
by fixeria 15 Dec '25

15 Dec '25
Attention is currently required from: Hoernchen, laforge, osmith, pespin. fixeria has posted comments on this change by pespin. ( https://gerrit.osmocom.org/c/osmo-bts/+/41660?usp=email ) Change subject: bts-trx: define TRXD_MSG_BUF_SIZE as a more realistic lower value ...................................................................... Patch Set 6: (4 comments) File src/osmo-bts-trx/trx_if.h: https://gerrit.osmocom.org/c/osmo-bts/+/41660/comment/18526a80_411107bd?usp… : PS6, Line 7: NOTE: a legacy transceiver may append two garbage bytes. This is only relevant for Uplink TRXDv0 PDUs, see my suggestion `a)` below. https://gerrit.osmocom.org/c/osmo-bts/+/41660/comment/118684d6_82aa9305?usp… : PS6, Line 16: TRXD_UL_V2HDR_LEN Note that size of optional TDMA Fn is not included here (it is also not included in the original `TRX_UL_V2HDR_LEN` because it's the minimum length). See how `trx_data_handle_pdu_v2()` is returning `TRX_UL_V2HDR_LEN + sizeof(bi->fn)`. See my suggestion `b)` below. https://gerrit.osmocom.org/c/osmo-bts/+/41660/comment/90ef670d_5ce13794?usp… : PS6, Line 17: TRXD_UL_V0HDR_LEN Suggestion `a)`: `TRXD_UL_V0HDR_LEN + 2` to account for two garbage bytes. Suggestion `b)`: `TRXD_UL_V2HDR_LEN + 4` to account for optional TDMA Fn field. File src/osmo-bts-trx/trx_if.h: https://gerrit.osmocom.org/c/osmo-bts/+/41660/comment/5ad31265_0d2f76c5?usp… : PS3, Line 12: TRXD_BURST_SIZE_MAX * TRX_NR_TS > Ack, I'll add some extra bytes for the header. Done -- To view, visit https://gerrit.osmocom.org/c/osmo-bts/+/41660?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email Gerrit-MessageType: comment Gerrit-Project: osmo-bts Gerrit-Branch: master Gerrit-Change-Id: Ic725e26637f8c116cfd5e64ff54d60a1d1bf9b87 Gerrit-Change-Number: 41660 Gerrit-PatchSet: 6 Gerrit-Owner: pespin <pespin(a)sysmocom.de> Gerrit-Reviewer: Hoernchen <ewild(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-Reviewer: laforge <laforge(a)osmocom.org> Gerrit-Reviewer: osmith <osmith(a)sysmocom.de> Gerrit-Attention: osmith <osmith(a)sysmocom.de> Gerrit-Attention: Hoernchen <ewild(a)sysmocom.de> Gerrit-Attention: laforge <laforge(a)osmocom.org> Gerrit-Attention: pespin <pespin(a)sysmocom.de> Gerrit-Comment-Date: Mon, 15 Dec 2025 10:45:29 +0000 Gerrit-HasComments: Yes Gerrit-Has-Labels: No Comment-In-Reply-To: pespin <pespin(a)sysmocom.de> Comment-In-Reply-To: fixeria <vyanitskiy(a)sysmocom.de>
1 0
0 0
[M] Change in osmo-bts[master]: pcu_sock: Use osmo_io
by pespin 15 Dec '25

15 Dec '25
pespin has posted comments on this change by pespin. ( https://gerrit.osmocom.org/c/osmo-bts/+/41662?usp=email ) Change subject: pcu_sock: Use osmo_io ...................................................................... Patch Set 6: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/c/osmo-bts/+/41662?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email Gerrit-MessageType: comment Gerrit-Project: osmo-bts Gerrit-Branch: master Gerrit-Change-Id: Ib708e0790568e368554da264a08d8804c8f95583 Gerrit-Change-Number: 41662 Gerrit-PatchSet: 6 Gerrit-Owner: pespin <pespin(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: laforge <laforge(a)osmocom.org> Gerrit-Reviewer: osmith <osmith(a)sysmocom.de> Gerrit-Reviewer: pespin <pespin(a)sysmocom.de> Gerrit-Comment-Date: Mon, 15 Dec 2025 10:37:33 +0000 Gerrit-HasComments: No Gerrit-Has-Labels: Yes
1 0
0 0
[XS] Change in libosmo-netif[master]: cosmetic: stream_cli: Fix typos in API documentation
by pespin 15 Dec '25

15 Dec '25
Attention is currently required from: fixeria, osmith. pespin has posted comments on this change by pespin. ( https://gerrit.osmocom.org/c/libosmo-netif/+/41651?usp=email ) Change subject: cosmetic: stream_cli: Fix typos in API documentation ...................................................................... Patch Set 2: (1 comment) File src/stream_cli.c: https://gerrit.osmocom.org/c/libosmo-netif/+/41651/comment/86ebf0a3_3ed588c… : PS1, Line 879: socket > nitpick: simply say `the stream client` here to avoid `set the socket type for ... […] Done -- To view, visit https://gerrit.osmocom.org/c/libosmo-netif/+/41651?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email Gerrit-MessageType: comment Gerrit-Project: libosmo-netif Gerrit-Branch: master Gerrit-Change-Id: Icb3c567df9fa287667996af34b652f80f12a816e Gerrit-Change-Number: 41651 Gerrit-PatchSet: 2 Gerrit-Owner: pespin <pespin(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-Reviewer: laforge <laforge(a)osmocom.org> Gerrit-Reviewer: osmith <osmith(a)sysmocom.de> Gerrit-Attention: osmith <osmith(a)sysmocom.de> Gerrit-Attention: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-Comment-Date: Mon, 15 Dec 2025 10:07:48 +0000 Gerrit-HasComments: Yes Gerrit-Has-Labels: No Comment-In-Reply-To: fixeria <vyanitskiy(a)sysmocom.de>
1 0
0 0
[XS] Change in libosmo-netif[master]: stream_srv: srv_link: Set OSMO_SOCK_F_NONBLOCK during socket creation
by pespin 15 Dec '25

15 Dec '25
Attention is currently required from: laforge. Hello Jenkins Builder, laforge, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/c/libosmo-netif/+/41666?usp=email to look at the new patch set (#2). The following approvals got outdated and were removed: Code-Review+1 by laforge Change subject: stream_srv: srv_link: Set OSMO_SOCK_F_NONBLOCK during socket creation ...................................................................... stream_srv: srv_link: Set OSMO_SOCK_F_NONBLOCK during socket creation This should be needed to potentially avoid blocking during accept() call. In practice right now is not needed because osmo_fd/osmo_iofd takes care of setting to non-blocking during registering: * osmo_fd: osmo_fd_register() sets the fd to non-bloking. * osmo_iofd: ** osmo_io_poll: it uses osmo_fd_register() internally, see above ** osmo_io_uring: only set to non-blocking as a side-effect of calling osmo_fd_register() if IOFD_FLAG_NOTIFY_CONNECTED was passed. Since for the srv_link so far always uses an osmo_fd regardless of whether OSMO_STREAM_MODE_* is used, in practice we are saved by osmo_fd_register(). In any case, better pass the flag at socket creation time so it's already applied then, instead of relying on osmo_fd_register() as a side-effect, particularly if in the future we switch the listen socket to be operated over osmo_io_uring. Change-Id: I98a6ef55a0a7289b9eeb7e8062e9afa4d87f51eb --- M src/stream_srv.c 1 file changed, 4 insertions(+), 3 deletions(-) git pull ssh://gerrit.osmocom.org:29418/libosmo-netif refs/changes/66/41666/2 -- To view, visit https://gerrit.osmocom.org/c/libosmo-netif/+/41666?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email Gerrit-MessageType: newpatchset Gerrit-Project: libosmo-netif Gerrit-Branch: master Gerrit-Change-Id: I98a6ef55a0a7289b9eeb7e8062e9afa4d87f51eb Gerrit-Change-Number: 41666 Gerrit-PatchSet: 2 Gerrit-Owner: pespin <pespin(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: laforge <laforge(a)osmocom.org> Gerrit-Attention: laforge <laforge(a)osmocom.org>
1 0
0 0
[XS] Change in libosmo-netif[master]: stream_srv: srv_link: Set OSMO_SOCK_F_NONBLOCK during socket creation
by pespin 15 Dec '25

15 Dec '25
Attention is currently required from: laforge. pespin has posted comments on this change by pespin. ( https://gerrit.osmocom.org/c/libosmo-netif/+/41666?usp=email ) Change subject: stream_srv: srv_link: Set OSMO_SOCK_F_NONBLOCK during socket creation ...................................................................... Patch Set 1: (2 comments) Commit Message: https://gerrit.osmocom.org/c/libosmo-netif/+/41666/comment/2eb66f54_788c648… : PS1, Line 21: safed > saved Done https://gerrit.osmocom.org/c/libosmo-netif/+/41666/comment/f3b4119f_38ac7ea… : PS1, Line 26: specially > 'especially' or maybe better: 'particularly' Done -- To view, visit https://gerrit.osmocom.org/c/libosmo-netif/+/41666?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email Gerrit-MessageType: comment Gerrit-Project: libosmo-netif Gerrit-Branch: master Gerrit-Change-Id: I98a6ef55a0a7289b9eeb7e8062e9afa4d87f51eb Gerrit-Change-Number: 41666 Gerrit-PatchSet: 1 Gerrit-Owner: pespin <pespin(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: laforge <laforge(a)osmocom.org> Gerrit-Attention: laforge <laforge(a)osmocom.org> Gerrit-Comment-Date: Mon, 15 Dec 2025 10:06:06 +0000 Gerrit-HasComments: Yes Gerrit-Has-Labels: No Comment-In-Reply-To: laforge <laforge(a)osmocom.org>
1 0
0 0
[M] Change in osmo-bts[master]: bts-trx: get rid of static variables in trx_if_send_burst()
by pespin 15 Dec '25

15 Dec '25
pespin has submitted this change. ( https://gerrit.osmocom.org/c/osmo-bts/+/41658?usp=email ) Change subject: bts-trx: get rid of static variables in trx_if_send_burst() ...................................................................... bts-trx: get rid of static variables in trx_if_send_burst() Change-Id: I431964d6fe02e53771cc0514ac930348f0a86aa1 Related: OS#1579 --- M src/osmo-bts-trx/l1_if.h M src/osmo-bts-trx/trx_if.c 2 files changed, 28 insertions(+), 22 deletions(-) Approvals: laforge: Looks good to me, but someone else must approve pespin: Looks good to me, approved osmith: Looks good to me, but someone else must approve Jenkins Builder: Verified diff --git a/src/osmo-bts-trx/l1_if.h b/src/osmo-bts-trx/l1_if.h index 7cc82ad..0180499 100644 --- a/src/osmo-bts-trx/l1_if.h +++ b/src/osmo-bts-trx/l1_if.h @@ -126,6 +126,13 @@ /* Whether the l1h->trx_ctrl_list was flushed by the callback handling a received message */ bool flushed_while_in_trx_ctrl_read_cb; + struct { + /* the Tx buffer used by trx_if_send_burst() */ + struct msgb *sndbuf; + /* number of PDUs in the Tx buffer */ + unsigned int sndbuf_num_pdus; + } data; + //struct gsm_bts_trx *trx; struct phy_instance *phy_inst; diff --git a/src/osmo-bts-trx/trx_if.c b/src/osmo-bts-trx/trx_if.c index 8b57aba..5f32360 100644 --- a/src/osmo-bts-trx/trx_if.c +++ b/src/osmo-bts-trx/trx_if.c @@ -1120,9 +1120,8 @@ int trx_if_send_burst(struct trx_l1h *l1h, const struct trx_dl_burst_req *br) { uint8_t pdu_ver = l1h->config.trxd_pdu_ver_use; - static struct msgb *trx_data_last_msg = NULL; - static unsigned int pdu_num = 0; - uint8_t *buf; + struct msgb *sndbuf = NULL; + uint8_t *buf = NULL; int rc; /* Make sure that the PHY is powered on */ @@ -1132,33 +1131,33 @@ return -ENODEV; } - if (!trx_data_last_msg) { - trx_data_last_msg = msgb_alloc(TRXD_MSG_BUF_SIZE, "tx_trxd"); - OSMO_ASSERT(trx_data_last_msg); - buf = msgb_data(trx_data_last_msg); + if (l1h->data.sndbuf == NULL) { + l1h->data.sndbuf = msgb_alloc_c(l1h, TRXD_MSG_BUF_SIZE, "tx_trxd"); + OSMO_ASSERT(l1h->data.sndbuf); } + sndbuf = l1h->data.sndbuf; /* Burst batching breaker */ if (br == NULL) { - if (pdu_num > 0) + if (l1h->data.sndbuf_num_pdus > 0) goto sendall; return -ENOMSG; } - /* l2h holds Pointer to the last encoded PDU */ - trx_data_last_msg->l2h = trx_data_last_msg->tail; + /* l2h points to the last encoded PDU */ + sndbuf->l2h = sndbuf->tail; switch (pdu_ver) { /* Both versions have the same PDU format */ case 0: /* TRXDv0 */ case 1: /* TRXDv1 */ - buf = (uint8_t *)msgb_put(trx_data_last_msg, 6); + buf = (uint8_t *)msgb_put(sndbuf, 6); buf[0] = ((pdu_ver & 0x0f) << 4) | br->tn; osmo_store32be(br->fn, buf + 1); buf[5] = br->att; break; case 2: /* TRXDv2 */ - buf = (uint8_t *)msgb_put(trx_data_last_msg, 8); + buf = (uint8_t *)msgb_put(sndbuf, 8); buf[0] = br->tn; /* BATCH.ind will be unset in the last PDU */ buf[1] = (br->trx_num & 0x3f) | (1 << 7); @@ -1169,9 +1168,9 @@ buf[4] = (uint8_t) br->scpir; buf[5] = buf[6] = buf[7] = 0x00; /* Spare */ /* Some fields are not present in batched PDUs */ - if (pdu_num == 0) { + if (l1h->data.sndbuf_num_pdus == 0) { buf[0] |= (pdu_ver & 0x0f) << 4; - msgb_put_u32(trx_data_last_msg, br->fn); + msgb_put_u32(sndbuf, br->fn); } break; default: @@ -1180,10 +1179,10 @@ } /* copy ubits {0,1} */ - memcpy(msgb_put(trx_data_last_msg, br->burst_len), br->burst, br->burst_len); + memcpy(msgb_put(sndbuf, br->burst_len), br->burst, br->burst_len); /* One more PDU in the buffer */ - pdu_num++; + l1h->data.sndbuf_num_pdus++; /* TRXDv2: wait for the batching breaker */ if (pdu_ver >= 2) @@ -1192,23 +1191,23 @@ sendall: LOGPPHI(l1h->phy_inst, DTRX, LOGL_DEBUG, "Tx TRXDv%u datagram with %u PDU(s)\n", - pdu_ver, pdu_num); + pdu_ver, l1h->data.sndbuf_num_pdus); /* TRXDv2: unset BATCH.ind in the last PDU */ if (pdu_ver >= 2) - trx_data_last_msg->l2h[1] &= ~(1 << 7); + sndbuf->l2h[1] &= ~(1 << 7); - rc = osmo_iofd_write_msgb(l1h->trx_data_iofd, trx_data_last_msg); + rc = osmo_iofd_write_msgb(l1h->trx_data_iofd, sndbuf); if (OSMO_UNLIKELY(rc < 0)) { char errbuf[256]; strerror_r(errno, errbuf, sizeof(errbuf)); LOGPPHI(l1h->phy_inst, DTRX, LOGL_ERROR, "osmo_iofd_write_msgb() failed on TRXD with rc=%d (%s)\n", rc, errbuf); - msgb_free(trx_data_last_msg); + msgb_free(sndbuf); } - trx_data_last_msg = NULL; - pdu_num = 0; + l1h->data.sndbuf = NULL; + l1h->data.sndbuf_num_pdus = 0; return 0; } -- To view, visit https://gerrit.osmocom.org/c/osmo-bts/+/41658?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email Gerrit-MessageType: merged Gerrit-Project: osmo-bts Gerrit-Branch: master Gerrit-Change-Id: I431964d6fe02e53771cc0514ac930348f0a86aa1 Gerrit-Change-Number: 41658 Gerrit-PatchSet: 5 Gerrit-Owner: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: laforge <laforge(a)osmocom.org> Gerrit-Reviewer: osmith <osmith(a)sysmocom.de> Gerrit-Reviewer: pespin <pespin(a)sysmocom.de>
1 0
0 0
[XS] Change in osmo-bts[master]: bts-trx: Set max TRXD buf size to UINT16_MAX
by pespin 15 Dec '25

15 Dec '25
pespin has submitted this change. ( https://gerrit.osmocom.org/c/osmo-bts/+/41648?usp=email ) Change subject: bts-trx: Set max TRXD buf size to UINT16_MAX ...................................................................... bts-trx: Set max TRXD buf size to UINT16_MAX Otherwise trying to allocate a msgb from it fails: """ In file included from /git/osmo-bts/src/osmo-bts-trx/l1_if.h:9, from /git/osmo-bts/src/osmo-bts-trx/trx_if.c:50: /git/osmo-bts/src/osmo-bts-trx/trx_if.c: In function ‘trx_if_send_burst’: /git/osmo-bts/src/osmo-bts-trx/trx_if.h:6:33: error: unsigned conversion from ‘int’ to ‘uint16_t’ {aka ‘short unsigned int’} changes value from 65536’ to ‘0’ [-Werror=overflow] 6 | #define TRXD_MSG_BUF_SIZE 65536 | ^~~~~ /git/osmo-bts/src/osmo-bts-trx/trx_if.c:1126:48: note: in expansion of macro ‘TRXD_MSG_BUF_SIZE’ 1126 | trx_data_last_msg = msgb_alloc(TRXD_MSG_BUF_SIZE, "tx_trxd"); | ^~~~~~~~~~~~~~~~~ """ Simply set it to be within uint16_t range, since anyway IPv4 MTU (IP Total Length field) is 16 bit (value including the IP header length too). In any case, this will need to be trimmed further. Change-Id: I980faea05dee405c974636f41ee723659d9c5229 --- M src/osmo-bts-trx/trx_if.h 1 file changed, 2 insertions(+), 2 deletions(-) Approvals: pespin: Looks good to me, approved osmith: Looks good to me, but someone else must approve laforge: Looks good to me, but someone else must approve Jenkins Builder: Verified diff --git a/src/osmo-bts-trx/trx_if.h b/src/osmo-bts-trx/trx_if.h index 3a22a1b..13c537d 100644 --- a/src/osmo-bts-trx/trx_if.h +++ b/src/osmo-bts-trx/trx_if.h @@ -2,8 +2,8 @@ /* TRXC read/send buffer size */ #define TRXC_MSG_BUF_SIZE 1500 -/* TRXD read/send buffer size (max. lo MTU) */ -#define TRXD_MSG_BUF_SIZE 65536 +/* TRXD read/send buffer size (max. IPv4 MTU) */ +#define TRXD_MSG_BUF_SIZE 65535U struct trx_dl_burst_req; struct trx_l1h; -- To view, visit https://gerrit.osmocom.org/c/osmo-bts/+/41648?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email Gerrit-MessageType: merged Gerrit-Project: osmo-bts Gerrit-Branch: master Gerrit-Change-Id: I980faea05dee405c974636f41ee723659d9c5229 Gerrit-Change-Number: 41648 Gerrit-PatchSet: 3 Gerrit-Owner: pespin <pespin(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-Reviewer: jolly <andreas(a)eversberg.eu> Gerrit-Reviewer: laforge <laforge(a)osmocom.org> Gerrit-Reviewer: osmith <osmith(a)sysmocom.de> Gerrit-Reviewer: pespin <pespin(a)sysmocom.de>
1 0
0 0
[M] Change in osmo-bts[master]: bts-trx: Convert trx clk socket to iofd
by pespin 15 Dec '25

15 Dec '25
pespin has submitted this change. ( https://gerrit.osmocom.org/c/osmo-bts/+/41649?usp=email ) Change subject: bts-trx: Convert trx clk socket to iofd ...................................................................... bts-trx: Convert trx clk socket to iofd Since now the Tx side is driven by the event loop, we can use (and should) OSMO_SOCK_F_NONBLOCK on the socket, avoiding potential blocking of the entire process. Related: OS#1579 Change-Id: Ia33028a657e7d5dee1a4994b8d6ba33ddea892ec --- M include/osmo-bts/phy_link.h M src/osmo-bts-trx/trx_if.c M src/osmo-bts-trx/trx_vty.c 3 files changed, 53 insertions(+), 28 deletions(-) Approvals: laforge: Looks good to me, but someone else must approve osmith: Looks good to me, but someone else must approve pespin: Looks good to me, approved Jenkins Builder: Verified diff --git a/include/osmo-bts/phy_link.h b/include/osmo-bts/phy_link.h index 862ed48..719c329 100644 --- a/include/osmo-bts/phy_link.h +++ b/include/osmo-bts/phy_link.h @@ -3,6 +3,7 @@ #include <stdint.h> #include <stdbool.h> #include <osmocom/core/linuxlist.h> +#include <osmocom/core/osmo_io.h> #include <osmo-bts/scheduler.h> #include <osmo-bts/bts_trx.h> @@ -44,7 +45,7 @@ char *remote_ip; uint16_t base_port_local; uint16_t base_port_remote; - struct osmo_fd trx_ofd_clk; + struct osmo_io_fd *trx_clk_iofd; uint32_t clock_advance; uint32_t rts_advance; bool use_legacy_setbsic; diff --git a/src/osmo-bts-trx/trx_if.c b/src/osmo-bts-trx/trx_if.c index 29f1fd0..e1a08db 100644 --- a/src/osmo-bts-trx/trx_if.c +++ b/src/osmo-bts-trx/trx_if.c @@ -105,34 +105,35 @@ */ /* get clock from clock socket */ -static int trx_clk_read_cb(struct osmo_fd *ofd, unsigned int what) +static void trx_clk_read_cb(struct osmo_io_fd *iofd, int res, struct msgb *msg) { - struct phy_link *plink = ofd->data; + struct phy_link *plink = osmo_iofd_get_data(iofd); struct phy_instance *pinst = phy_instance_by_num(plink, 0); - char buf[TRXC_MSG_BUF_SIZE]; - ssize_t len; + char *buf; uint32_t fn; OSMO_ASSERT(pinst); - len = recv(ofd->fd, buf, sizeof(buf) - 1, 0); - if (len <= 0) { - strerror_r(errno, (char *)buf, sizeof(buf)); + if (res <= 0) { + char errbuf[256]; + strerror_r(errno, errbuf, sizeof(errbuf)); LOGPPHI(pinst, DTRX, LOGL_ERROR, - "recv() failed on TRXD with rc=%zd (%s)\n", len, buf); - return len; + "recv() failed on TRXD with rc=%d (%s)\n", res, errbuf); + goto ret_free_msg; } - buf[len] = '\0'; + + msgb_put_u8(msg, (uint8_t)'\0'); + buf = (char *)msgb_data(msg); if (!!strncmp(buf, "IND CLOCK ", 10)) { LOGPPHI(pinst, DTRX, LOGL_NOTICE, "Unknown message on clock port: %s\n", buf); - return 0; + goto ret_free_msg; } if (sscanf(buf, "IND CLOCK %u", &fn) != 1) { LOGPPHI(pinst, DTRX, LOGL_ERROR, "Unable to parse '%s'\n", buf); - return 0; + goto ret_free_msg; } LOGPPHI(pinst, DTRX, LOGL_INFO, "Clock indication: fn=%u\n", fn); @@ -145,14 +146,20 @@ if (!plink->u.osmotrx.powered) { LOGPPHI(pinst, DTRX, LOGL_NOTICE, "Ignoring CLOCK IND %u, TRX not yet powered on\n", fn); - return 0; + goto ret_free_msg; } /* inform core TRX clock handling code that a FN has been received */ trx_sched_clock(pinst->trx->bts, fn); - return 0; +ret_free_msg: + msgb_free(msg); } +static void trx_clk_write_cb(struct osmo_io_fd *iofd, int res, struct msgb *msg) +{ + /* libosmocore before change-id I0c071a29e508884bac331ada5e510bbfcf440bbf requires write call-back + * even if we don't care about it */ +} /* * TRX ctrl socket @@ -1273,6 +1280,11 @@ return plink->u.osmotrx.base_port_local + (pinst->num << 1) + inc; } +static const struct osmo_io_ops trx_clk_ioops = { + .read_cb = trx_clk_read_cb, + .write_cb = trx_clk_write_cb, +}; + /*! open a TRX interface. creates control + data sockets */ static int trx_if_open(struct trx_l1h *l1h) { @@ -1339,21 +1351,30 @@ int bts_model_phy_link_open(struct phy_link *plink) { struct phy_instance *pinst; - int rc; + char sock_name_buf[OSMO_SOCK_NAME_MAXLEN] = {}; + int fd; phy_link_state_set(plink, PHY_LINK_CONNECTING); /* open the shared/common clock socket */ - rc = trx_udp_open(plink, &plink->u.osmotrx.trx_ofd_clk, - plink->u.osmotrx.local_ip, - plink->u.osmotrx.base_port_local, - plink->u.osmotrx.remote_ip, - plink->u.osmotrx.base_port_remote, - trx_clk_read_cb); - if (rc < 0) { + fd = osmo_sock_init2(AF_UNSPEC, SOCK_DGRAM, IPPROTO_UDP, + plink->u.osmotrx.local_ip, + plink->u.osmotrx.base_port_local, + plink->u.osmotrx.remote_ip, + plink->u.osmotrx.base_port_remote, + OSMO_SOCK_F_BIND | OSMO_SOCK_F_CONNECT | OSMO_SOCK_F_NONBLOCK); + if (fd < 0) { phy_link_state_set(plink, PHY_LINK_SHUTDOWN); return -1; } + osmo_sock_get_name_buf(sock_name_buf, OSMO_SOCK_NAME_MAXLEN, fd); + plink->u.osmotrx.trx_clk_iofd = osmo_iofd_setup(plink, fd, sock_name_buf, + OSMO_IO_FD_MODE_READ_WRITE, + &trx_clk_ioops, plink); + if (!plink->u.osmotrx.trx_clk_iofd) + goto cleanup; + osmo_iofd_set_alloc_info(plink->u.osmotrx.trx_clk_iofd, TRXC_MSG_BUF_SIZE, 0); + osmo_iofd_register(plink->u.osmotrx.trx_clk_iofd, -1); /* open the individual instances with their ctrl+data sockets */ llist_for_each_entry(pinst, &plink->instances, list) { @@ -1373,7 +1394,8 @@ pinst->u.osmotrx.hdl = NULL; } } - trx_udp_close(&plink->u.osmotrx.trx_ofd_clk); + osmo_iofd_free(plink->u.osmotrx.trx_clk_iofd); + plink->u.osmotrx.trx_clk_iofd = NULL; return -1; } @@ -1389,7 +1411,8 @@ } trx_phy_inst_close(pinst); } - trx_udp_close(&plink->u.osmotrx.trx_ofd_clk); + osmo_iofd_free(plink->u.osmotrx.trx_clk_iofd); + plink->u.osmotrx.trx_clk_iofd = NULL; phy_link_state_set(plink, PHY_LINK_SHUTDOWN); return 0; } diff --git a/src/osmo-bts-trx/trx_vty.c b/src/osmo-bts-trx/trx_vty.c index 9056f02..b806dc6 100644 --- a/src/osmo-bts-trx/trx_vty.c +++ b/src/osmo-bts-trx/trx_vty.c @@ -62,10 +62,11 @@ llist_for_each_entry(trx, &g_bts->trx_list, list) { struct phy_instance *pinst = trx_phy_instance(trx); struct phy_link *plink = pinst->phy_link; - char *sname = osmo_sock_get_name(NULL, plink->u.osmotrx.trx_ofd_clk.fd); + const char *sname = plink->u.osmotrx.trx_clk_iofd ? + osmo_iofd_get_name(plink->u.osmotrx.trx_clk_iofd) : + NULL; l1h = pinst->u.osmotrx.hdl; - vty_out(vty, "TRX %d %s%s", trx->nr, sname, VTY_NEWLINE); - talloc_free(sname); + vty_out(vty, "TRX %d %s%s", trx->nr, sname ? sname : "", VTY_NEWLINE); vty_out(vty, " %s%s", trx_if_powered(l1h) ? "poweron":"poweroff", VTY_NEWLINE); -- To view, visit https://gerrit.osmocom.org/c/osmo-bts/+/41649?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email Gerrit-MessageType: merged Gerrit-Project: osmo-bts Gerrit-Branch: master Gerrit-Change-Id: Ia33028a657e7d5dee1a4994b8d6ba33ddea892ec Gerrit-Change-Number: 41649 Gerrit-PatchSet: 3 Gerrit-Owner: pespin <pespin(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-Reviewer: laforge <laforge(a)osmocom.org> Gerrit-Reviewer: osmith <osmith(a)sysmocom.de> Gerrit-Reviewer: pespin <pespin(a)sysmocom.de>
1 0
0 0
[L] Change in osmo-bts[master]: bts-trx: Convert TRXC and TRXD sockets to iofd
by pespin 15 Dec '25

15 Dec '25
pespin has submitted this change. ( https://gerrit.osmocom.org/c/osmo-bts/+/41650?usp=email ) Change subject: bts-trx: Convert TRXC and TRXD sockets to iofd ...................................................................... bts-trx: Convert TRXC and TRXD sockets to iofd Since now the Tx side is driven by the event loop, we can use (and should) OSMO_SOCK_F_NONBLOCK on the socket, avoiding potential blocking of the entire process. We also gain io_uring support for free, which is a really nice feature to have in TRXD. Related: OS#1579 Change-Id: I239f91efad43eabd280caf9f852c3aefbc729eaf --- M src/osmo-bts-trx/l1_if.h M src/osmo-bts-trx/trx_if.c 2 files changed, 155 insertions(+), 124 deletions(-) Approvals: pespin: Looks good to me, approved laforge: Looks good to me, but someone else must approve osmith: Looks good to me, but someone else must approve Jenkins Builder: Verified diff --git a/src/osmo-bts-trx/l1_if.h b/src/osmo-bts-trx/l1_if.h index 84fd4b5..7cc82ad 100644 --- a/src/osmo-bts-trx/l1_if.h +++ b/src/osmo-bts-trx/l1_if.h @@ -2,6 +2,7 @@ #define L1_IF_H_TRX #include <osmocom/core/rate_ctr.h> +#include <osmocom/core/osmo_io.h> #include <osmo-bts/scheduler.h> #include <osmo-bts/phy_link.h> @@ -128,9 +129,9 @@ //struct gsm_bts_trx *trx; struct phy_instance *phy_inst; - struct osmo_fd trx_ofd_ctrl; + struct osmo_io_fd *trx_ctrl_iofd; struct osmo_timer_list trx_ctrl_timer; - struct osmo_fd trx_ofd_data; + struct osmo_io_fd *trx_data_iofd; /* transceiver config */ struct trx_config config; diff --git a/src/osmo-bts-trx/trx_if.c b/src/osmo-bts-trx/trx_if.c index e1a08db..8b57aba 100644 --- a/src/osmo-bts-trx/trx_if.c +++ b/src/osmo-bts-trx/trx_if.c @@ -65,42 +65,6 @@ #endif /* HAVE_SYSTEMTAP */ /* - * socket helper functions - */ - -/*! convenience wrapper to open socket + fill in osmo_fd */ -static int trx_udp_open(void *priv, struct osmo_fd *ofd, const char *host_local, - uint16_t port_local, const char *host_remote, uint16_t port_remote, - int (*cb)(struct osmo_fd *fd, unsigned int what)) -{ - int rc; - - /* Init */ - ofd->fd = -1; - ofd->cb = cb; - ofd->data = priv; - - /* Listen / Binds + Connect */ - rc = osmo_sock_init2_ofd(ofd, AF_UNSPEC, SOCK_DGRAM, IPPROTO_UDP, host_local, port_local, - host_remote, port_remote, OSMO_SOCK_F_BIND | OSMO_SOCK_F_CONNECT); - if (rc < 0) - return rc; - - return 0; -} - -/* close socket + unregister osmo_fd */ -static void trx_udp_close(struct osmo_fd *ofd) -{ - if (ofd->fd >= 0) { - osmo_fd_unregister(ofd); - close(ofd->fd); - ofd->fd = -1; - } -} - - -/* * TRX clock socket */ @@ -169,27 +133,40 @@ static void trx_ctrl_send(struct trx_l1h *l1h) { struct trx_ctrl_msg *tcm; - char buf[TRXC_MSG_BUF_SIZE]; - int len; - ssize_t snd_len; + char *buf; + struct msgb *msg; + int len, rc; /* get first command */ if (llist_empty(&l1h->trx_ctrl_list)) return; tcm = llist_entry(l1h->trx_ctrl_list.next, struct trx_ctrl_msg, list); - len = snprintf(buf, sizeof(buf), "CMD %s%s%s", tcm->cmd, tcm->params_len ? " ":"", tcm->params); - OSMO_ASSERT(len < sizeof(buf)); + msg = msgb_alloc(TRXC_MSG_BUF_SIZE, "trxc_cmd"); + buf = (char *)msgb_data(msg); + len = snprintf(buf, msg->data_len, "CMD %s%s%s", tcm->cmd, tcm->params_len ? " ":"", tcm->params); + OSMO_ASSERT(len < msg->data_len); + msgb_put(msg, len); + + if (!l1h->trx_ctrl_iofd) { + LOGPPHI(l1h->phy_inst, DTRX, LOGL_ERROR, + "TRXC: no socket available to send '%s'\n", buf); + msgb_free(msg); + goto resched; + } LOGPPHI(l1h->phy_inst, DTRX, LOGL_DEBUG, "Sending control '%s'\n", buf); /* send command */ - snd_len = send(l1h->trx_ofd_ctrl.fd, buf, len+1, 0); - if (snd_len <= 0) { - strerror_r(errno, (char *)buf, sizeof(buf)); + rc = osmo_iofd_write_msgb(l1h->trx_ctrl_iofd, msg); + if (rc < 0) { + char errbuf[256]; + strerror_r(errno, errbuf, sizeof(errbuf)); LOGPPHI(l1h->phy_inst, DTRX, LOGL_ERROR, - "send() failed on TRXC with rc=%zd (%s)\n", snd_len, buf); + "osmo_iofd_write_msgb() failed on TRXC with rc=%d (%s)\n", rc, errbuf); + msgb_free(msg); } +resched: /* start timer */ osmo_timer_schedule(&l1h->trx_ctrl_timer, 2, 0); } @@ -217,9 +194,6 @@ /* initialize ctrl queue */ INIT_LLIST_HEAD(&l1h->trx_ctrl_list); - - l1h->trx_ofd_ctrl.fd = -1; - l1h->trx_ofd_data.fd = -1; } /*! Send a new TRX control command. @@ -673,23 +647,24 @@ } /*! Get + parse response from TRX ctrl socket */ -static int trx_ctrl_read_cb(struct osmo_fd *ofd, unsigned int what) +static void trx_ctrl_read_cb(struct osmo_io_fd *iofd, int res, struct msgb *msg) { - struct trx_l1h *l1h = ofd->data; + struct trx_l1h *l1h = osmo_iofd_get_data(iofd); struct phy_instance *pinst = l1h->phy_inst; - char buf[TRXC_MSG_BUF_SIZE]; + const char *buf; struct trx_ctrl_rsp rsp; - int len, rc; + int rc; struct trx_ctrl_msg *tcm; bool flushed; - len = recv(ofd->fd, buf, sizeof(buf) - 1, 0); - if (len <= 0) - return len; - buf[len] = '\0'; + if (res <= 0) + goto ret_free_msg; - if (parse_rsp(buf, len, &rsp) < 0) - return 0; + msgb_put_u8(msg, (uint8_t)'\0'); + buf = (char *)msgb_data(msg); + + if (parse_rsp(buf, res, &rsp) < 0) + goto ret_free_msg; LOGPPHI(l1h->phy_inst, DTRX, LOGL_INFO, "Response message: '%s'\n", buf); @@ -702,13 +677,12 @@ if (l1h->last_acked && cmd_matches_rsp(l1h->last_acked, &rsp)) { LOGPPHI(l1h->phy_inst, DTRX, LOGL_NOTICE, "Discarding duplicated RSP " "from old CMD '%s'\n", buf); - return 0; + goto ret_free_msg; } LOGPPHI(l1h->phy_inst, DTRX, LOGL_NOTICE, "Response message without command\n"); - return -EINVAL; + goto ret_free_msg; } - tcm = llist_entry(l1h->trx_ctrl_list.next, struct trx_ctrl_msg, - list); + tcm = llist_entry(l1h->trx_ctrl_list.next, struct trx_ctrl_msg, list); /* check if response matches command */ if (!cmd_matches_rsp(tcm, &rsp)) { @@ -716,7 +690,7 @@ if (l1h->last_acked && cmd_matches_rsp(l1h->last_acked, &rsp)) { LOGPPHI(l1h->phy_inst, DTRX, LOGL_NOTICE, "Discarding duplicated RSP " "from old CMD '%s'\n", buf); - return 0; + goto ret_free_msg; } LOGPPHI(l1h->phy_inst, DTRX, (tcm->critical) ? LOGL_FATAL : LOGL_NOTICE, "Response message '%s' does not match command " @@ -746,7 +720,7 @@ /* The queue may have been flushed in the trx_ctrl_rx_rsp(): */ if (!llist_empty(&l1h->trx_ctrl_list)) osmo_timer_schedule(&l1h->trx_ctrl_timer, rc, 0); - return 0; + goto ret_free_msg; } if (!flushed) { @@ -760,16 +734,23 @@ /* Send next message waiting in the list: */ trx_ctrl_send(l1h); - - return 0; + msgb_free(msg); + return; rsp_error: bts_shutdown(pinst->trx->bts, "TRX-CTRL-MSG: CRITICAL"); /* keep tcm list, so process is stopped */ - return -EIO; +ret_free_msg: + msgb_free(msg); } +static void trx_ctrl_write_cb(struct osmo_io_fd *iofd, int res, struct msgb *msg) +{ + /* libosmocore before change-id I0c071a29e508884bac331ada5e510bbfcf440bbf requires + * write call-back even if we don't care about it */ +} + /* * TRX burst data socket */ @@ -1019,26 +1000,24 @@ return buf; } -/* TRXD buffer used by Rx/Tx handlers */ -static uint8_t trx_data_buf[TRXD_MSG_BUF_SIZE]; - /* Parse TRXD message from transceiver, compose an UL burst indication. */ -static int trx_data_read_cb(struct osmo_fd *ofd, unsigned int what) +static void trx_data_read_cb(struct osmo_io_fd *iofd, int res, struct msgb *msg) { - const uint8_t *buf = &trx_data_buf[0]; - struct trx_l1h *l1h = ofd->data; + struct trx_l1h *l1h = osmo_iofd_get_data(iofd); + const uint8_t *buf; struct trx_ul_burst_ind bi; ssize_t hdr_len, buf_len; uint8_t pdu_ver; - buf_len = recv(ofd->fd, trx_data_buf, sizeof(trx_data_buf), 0); - if (OSMO_UNLIKELY(buf_len <= 0)) { - strerror_r(errno, (char *) trx_data_buf, sizeof(trx_data_buf)); + if (OSMO_UNLIKELY(res <= 0)) { + char errbuf[256]; + strerror_r(errno, errbuf, sizeof(errbuf)); LOGPPHI(l1h->phy_inst, DTRX, LOGL_ERROR, - "recv() failed on TRXD with rc=%zd (%s)\n", - buf_len, trx_data_buf); - return buf_len; + "recv() failed on TRXD with rc=%d (%s)\n", res, errbuf); + goto ret_msg_free; } + buf = msgb_data(msg); + buf_len = msgb_length(msg); /* Parse PDU version first */ pdu_ver = buf[0] >> 4; @@ -1048,7 +1027,7 @@ LOGPPHI(l1h->phy_inst, DTRX, LOGL_ERROR, "Rx TRXD PDU with unexpected version %u (expected %u)\n", pdu_ver, l1h->config.trxd_pdu_ver_use); - return -EIO; + goto ret_msg_free; } /* We're about to parse the first PDU */ @@ -1064,7 +1043,7 @@ LOGPPHI(l1h->phy_inst, DTRX, LOGL_ERROR, "Rx malformed TRXDv%u PDU: len=%zd < expected %u\n", pdu_ver, buf_len, trx_data_rx_hdr_len[pdu_ver]); - return -EINVAL; + goto ret_msg_free; } /* Parse header depending on the PDU version */ @@ -1085,13 +1064,13 @@ /* Header parsing error */ if (OSMO_UNLIKELY(hdr_len < 0)) - return hdr_len; + goto ret_msg_free; if (OSMO_UNLIKELY(bi.fn >= GSM_TDMA_HYPERFRAME)) { LOGPPHI(l1h->phy_inst, DTRX, LOGL_ERROR, "Rx malformed TRXDv%u PDU: illegal TDMA fn=%u\n", pdu_ver, bi.fn); - return -EINVAL; + goto ret_msg_free; } /* We're done with the header now */ @@ -1103,7 +1082,7 @@ LOGPPHI(l1h->phy_inst, DTRX, LOGL_ERROR, "Rx malformed TRXDv%u PDU: odd burst length=%zd\n", pdu_ver, buf_len); - return -EINVAL; + goto ret_msg_free; } /* We're done with the burst bits now */ @@ -1124,7 +1103,14 @@ TRACE(OSMO_BTS_TRX_UL_DATA_DONE(l1h->phy_inst->trx->nr, bi.tn, bi.fn)); } while (bi.flags & TRX_BI_F_BATCH_IND); - return 0; +ret_msg_free: + msgb_free(msg); +} + +static void trx_data_write_cb(struct osmo_io_fd *iofd, int res, struct msgb *msg) +{ + /* libosmocore before change-id I0c071a29e508884bac331ada5e510bbfcf440bbf requires + * write call-back even if we don't care about it */ } /*! Send burst data for given FN/timeslot to TRX @@ -1134,10 +1120,10 @@ int trx_if_send_burst(struct trx_l1h *l1h, const struct trx_dl_burst_req *br) { uint8_t pdu_ver = l1h->config.trxd_pdu_ver_use; - static uint8_t *buf = &trx_data_buf[0]; - static uint8_t *last_pdu = NULL; + static struct msgb *trx_data_last_msg = NULL; static unsigned int pdu_num = 0; - ssize_t snd_len, buf_len; + uint8_t *buf; + int rc; /* Make sure that the PHY is powered on */ if (OSMO_UNLIKELY(!trx_if_powered(l1h))) { @@ -1146,6 +1132,12 @@ return -ENODEV; } + if (!trx_data_last_msg) { + trx_data_last_msg = msgb_alloc(TRXD_MSG_BUF_SIZE, "tx_trxd"); + OSMO_ASSERT(trx_data_last_msg); + buf = msgb_data(trx_data_last_msg); + } + /* Burst batching breaker */ if (br == NULL) { if (pdu_num > 0) @@ -1153,19 +1145,20 @@ return -ENOMSG; } - /* Pointer to the last encoded PDU */ - last_pdu = &buf[0]; + /* l2h holds Pointer to the last encoded PDU */ + trx_data_last_msg->l2h = trx_data_last_msg->tail; switch (pdu_ver) { /* Both versions have the same PDU format */ case 0: /* TRXDv0 */ case 1: /* TRXDv1 */ + buf = (uint8_t *)msgb_put(trx_data_last_msg, 6); buf[0] = ((pdu_ver & 0x0f) << 4) | br->tn; osmo_store32be(br->fn, buf + 1); buf[5] = br->att; - buf += 6; break; case 2: /* TRXDv2 */ + buf = (uint8_t *)msgb_put(trx_data_last_msg, 8); buf[0] = br->tn; /* BATCH.ind will be unset in the last PDU */ buf[1] = (br->trx_num & 0x3f) | (1 << 7); @@ -1178,10 +1171,8 @@ /* Some fields are not present in batched PDUs */ if (pdu_num == 0) { buf[0] |= (pdu_ver & 0x0f) << 4; - osmo_store32be(br->fn, buf + 8); - buf += 4; + msgb_put_u32(trx_data_last_msg, br->fn); } - buf += 8; break; default: /* Shall not happen */ @@ -1189,8 +1180,7 @@ } /* copy ubits {0,1} */ - memcpy(buf, br->burst, br->burst_len); - buf += br->burst_len; + memcpy(msgb_put(trx_data_last_msg, br->burst_len), br->burst, br->burst_len); /* One more PDU in the buffer */ pdu_num++; @@ -1206,20 +1196,19 @@ /* TRXDv2: unset BATCH.ind in the last PDU */ if (pdu_ver >= 2) - last_pdu[1] &= ~(1 << 7); + trx_data_last_msg->l2h[1] &= ~(1 << 7); - buf_len = buf - &trx_data_buf[0]; - buf = &trx_data_buf[0]; - pdu_num = 0; - - snd_len = send(l1h->trx_ofd_data.fd, trx_data_buf, buf_len, 0); - if (OSMO_UNLIKELY(snd_len <= 0)) { - strerror_r(errno, (char *) trx_data_buf, sizeof(trx_data_buf)); + rc = osmo_iofd_write_msgb(l1h->trx_data_iofd, trx_data_last_msg); + if (OSMO_UNLIKELY(rc < 0)) { + char errbuf[256]; + strerror_r(errno, errbuf, sizeof(errbuf)); LOGPPHI(l1h->phy_inst, DTRX, LOGL_ERROR, - "send() failed on TRXD with rc=%zd (%s)\n", - snd_len, trx_data_buf); - return -2; + "osmo_iofd_write_msgb() failed on TRXD with rc=%d (%s)\n", + rc, errbuf); + msgb_free(trx_data_last_msg); } + trx_data_last_msg = NULL; + pdu_num = 0; return 0; } @@ -1261,8 +1250,10 @@ trx_if_flush(l1h); /* close sockets */ - trx_udp_close(&l1h->trx_ofd_ctrl); - trx_udp_close(&l1h->trx_ofd_data); + osmo_iofd_free(l1h->trx_ctrl_iofd); + l1h->trx_ctrl_iofd = NULL; + osmo_iofd_free(l1h->trx_data_iofd); + l1h->trx_data_iofd = NULL; } /*! compute UDP port number used for TRX protocol */ @@ -1280,6 +1271,16 @@ return plink->u.osmotrx.base_port_local + (pinst->num << 1) + inc; } +static const struct osmo_io_ops trx_ctrl_ioops = { + .read_cb = trx_ctrl_read_cb, + .write_cb = trx_ctrl_write_cb, +}; + +static const struct osmo_io_ops trx_data_ioops = { + .read_cb = trx_data_read_cb, + .write_cb = trx_data_write_cb, +}; + static const struct osmo_io_ops trx_clk_ioops = { .read_cb = trx_clk_read_cb, .write_cb = trx_clk_write_cb, @@ -1290,27 +1291,56 @@ { struct phy_instance *pinst = l1h->phy_inst; struct phy_link *plink = pinst->phy_link; + char sock_name_buf[OSMO_SOCK_NAME_MAXLEN] = {}; int rc; + unsigned int flags = OSMO_SOCK_F_BIND | OSMO_SOCK_F_CONNECT | OSMO_SOCK_F_NONBLOCK; + LOGPPHI(pinst, DTRX, LOGL_NOTICE, "Opening TRXC/TRXD connections to %s\n", plink->u.osmotrx.remote_ip); - /* open sockets */ - rc = trx_udp_open(l1h, &l1h->trx_ofd_ctrl, - plink->u.osmotrx.local_ip, - compute_port(pinst, false, false), - plink->u.osmotrx.remote_ip, - compute_port(pinst, true, false), trx_ctrl_read_cb); + /* open TRXC socket */ + rc = osmo_sock_init2(AF_UNSPEC, SOCK_DGRAM, IPPROTO_UDP, + plink->u.osmotrx.local_ip, + compute_port(pinst, false, false), + plink->u.osmotrx.remote_ip, + compute_port(pinst, true, false), + flags); if (rc < 0) return rc; - rc = trx_udp_open(l1h, &l1h->trx_ofd_data, - plink->u.osmotrx.local_ip, - compute_port(pinst, false, true), - plink->u.osmotrx.remote_ip, - compute_port(pinst, true, true), trx_data_read_cb); - if (rc < 0) - return rc; + osmo_sock_get_name_buf(sock_name_buf, OSMO_SOCK_NAME_MAXLEN, rc); + l1h->trx_ctrl_iofd = osmo_iofd_setup(l1h, rc, sock_name_buf, OSMO_IO_FD_MODE_READ_WRITE, &trx_ctrl_ioops, l1h); + if (!l1h->trx_ctrl_iofd) { + close(rc); + return -ENOMEDIUM; + } + osmo_iofd_set_alloc_info(l1h->trx_ctrl_iofd, TRXC_MSG_BUF_SIZE, 0); + /* open TRXD socket */ + rc = osmo_sock_init2(AF_UNSPEC, SOCK_DGRAM, IPPROTO_UDP, + plink->u.osmotrx.local_ip, + compute_port(pinst, false, true), + plink->u.osmotrx.remote_ip, + compute_port(pinst, true, true), + flags); + if (rc < 0) + goto ret_close_trxc; + osmo_sock_get_name_buf(sock_name_buf, OSMO_SOCK_NAME_MAXLEN, rc); + l1h->trx_data_iofd = osmo_iofd_setup(l1h, rc, sock_name_buf, OSMO_IO_FD_MODE_READ_WRITE, &trx_data_ioops, l1h); + if (!l1h->trx_data_iofd) { + close(rc); + goto ret_close_trxc; + } + osmo_iofd_set_alloc_info(l1h->trx_data_iofd, TRXD_MSG_BUF_SIZE, 0); + + /* register sockets */ + osmo_iofd_register(l1h->trx_ctrl_iofd, -1); + osmo_iofd_register(l1h->trx_data_iofd, -1); return 0; + +ret_close_trxc: + osmo_iofd_free(l1h->trx_ctrl_iofd); + l1h->trx_ctrl_iofd = NULL; + return rc; } /*! close the control + burst data sockets for one phy_instance */ -- To view, visit https://gerrit.osmocom.org/c/osmo-bts/+/41650?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email Gerrit-MessageType: merged Gerrit-Project: osmo-bts Gerrit-Branch: master Gerrit-Change-Id: I239f91efad43eabd280caf9f852c3aefbc729eaf Gerrit-Change-Number: 41650 Gerrit-PatchSet: 6 Gerrit-Owner: pespin <pespin(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-Reviewer: laforge <laforge(a)osmocom.org> Gerrit-Reviewer: osmith <osmith(a)sysmocom.de> Gerrit-Reviewer: pespin <pespin(a)sysmocom.de>
1 0
0 0
  • ← Newer
  • 1
  • ...
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • ...
  • 118
  • Older →

HyperKitty Powered by HyperKitty version 1.3.12.