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

July 2023

  • 1 participants
  • 3051 discussions
[M] Change in osmo-trx[master]: ms: rearrange code to allow clean exits
by Hoernchen 10 Jul '23

10 Jul '23
Hoernchen has submitted this change. ( https://gerrit.osmocom.org/c/osmo-trx/+/32954 ) Change subject: ms: rearrange code to allow clean exits ...................................................................... ms: rearrange code to allow clean exits This allows gracefully terminating the application by introducing queue timeouts. Change-Id: I0b8deebc63cf4d936666fd68e1666d1917e89a5d --- M Transceiver52M/ms/bladerf_specific.h M Transceiver52M/ms/itrq.h M Transceiver52M/ms/ms.cpp M Transceiver52M/ms/ms.h M Transceiver52M/ms/ms_rx_lower.cpp M Transceiver52M/ms/ms_upper.cpp M Transceiver52M/ms/ms_upper.h 7 files changed, 97 insertions(+), 39 deletions(-) Approvals: Jenkins Builder: Verified pespin: Looks good to me, but someone else must approve laforge: Looks good to me, but someone else must approve Hoernchen: Looks good to me, approved diff --git a/Transceiver52M/ms/bladerf_specific.h b/Transceiver52M/ms/bladerf_specific.h index 3dc4777..e32d77c 100644 --- a/Transceiver52M/ms/bladerf_specific.h +++ b/Transceiver52M/ms/bladerf_specific.h @@ -192,7 +192,7 @@ struct bladerf_stream *rx_stream; struct bladerf_stream *tx_stream; // using pkt2buf = blade_otw_buffer<2, blade_speed_buffer_type::SS>; - using tx_buf_q_type = spsc_cond<BLADE_NUM_BUFFERS, dev_buf_t *, true, false>; + using tx_buf_q_type = spsc_cond_timeout<BLADE_NUM_BUFFERS, dev_buf_t *, true, false>; const unsigned int rxFullScale, txFullScale; const int rxtxdelay; diff --git a/Transceiver52M/ms/itrq.h b/Transceiver52M/ms/itrq.h index 1d9e217..69ff515 100644 --- a/Transceiver52M/ms/itrq.h +++ b/Transceiver52M/ms/itrq.h @@ -29,7 +29,58 @@ namespace spsc_detail { -template <bool block_read, bool block_write> class spsc_cond_detail { +template <bool block_read, bool block_write> +class spsc_cond_timeout_detail { + std::condition_variable cond_r, cond_w; + std::mutex lr, lw; + std::atomic_int r_flag, w_flag; + const int timeout_ms = 200; + + public: + explicit spsc_cond_timeout_detail() : r_flag(0), w_flag(0) + { + } + + ~spsc_cond_timeout_detail() + { + } + + ssize_t spsc_check_r() + { + std::unique_lock<std::mutex> lk(lr); + if (cond_r.wait_for(lk, std::chrono::milliseconds(timeout_ms), [&] { return r_flag != 0; })) { + r_flag--; + return 1; + } else { + return 0; + } + } + ssize_t spsc_check_w() + { + std::unique_lock<std::mutex> lk(lw); + if (cond_w.wait_for(lk, std::chrono::milliseconds(timeout_ms), [&] { return w_flag != 0; })) { + w_flag--; + return 1; + } else { + return 0; + } + } + void spsc_notify_r() + { + std::unique_lock<std::mutex> lk(lr); + r_flag++; + cond_r.notify_one(); + } + void spsc_notify_w() + { + std::unique_lock<std::mutex> lk(lw); + w_flag++; + cond_w.notify_one(); + } +}; + +template <bool block_read, bool block_write> +class spsc_cond_detail { std::condition_variable cond_r, cond_w; std::mutex lr, lw; std::atomic_int r_flag, w_flag; @@ -74,7 +125,8 @@ }; // originally designed for select loop integration -template <bool block_read, bool block_write> class spsc_efd_detail { +template <bool block_read, bool block_write> +class spsc_efd_detail { int efd_r, efd_w; /* eventfds used to block/notify readers/writers */ public: @@ -191,4 +243,7 @@ template <unsigned int SZ, typename ELEM, bool block_read, bool block_write> class spsc_evfd : public spsc_detail::spsc<SZ, ELEM, block_read, block_write, spsc_detail::spsc_efd_detail> {}; template <unsigned int SZ, typename ELEM, bool block_read, bool block_write> -class spsc_cond : public spsc_detail::spsc<SZ, ELEM, block_read, block_write, spsc_detail::spsc_cond_detail> {}; \ No newline at end of file +class spsc_cond : public spsc_detail::spsc<SZ, ELEM, block_read, block_write, spsc_detail::spsc_cond_detail> {}; +template <unsigned int SZ, typename ELEM, bool block_read, bool block_write> +class spsc_cond_timeout + : public spsc_detail::spsc<SZ, ELEM, block_read, block_write, spsc_detail::spsc_cond_timeout_detail> {}; \ No newline at end of file diff --git a/Transceiver52M/ms/ms.cpp b/Transceiver52M/ms/ms.cpp index 2e91cae..e587c05 100644 --- a/Transceiver52M/ms/ms.cpp +++ b/Transceiver52M/ms/ms.cpp @@ -78,7 +78,7 @@ }; } -void ms_trx::start() +void ms_trx::start_lower_ms() { if (stop_lower_threads_flag) return; diff --git a/Transceiver52M/ms/ms.h b/Transceiver52M/ms/ms.h index efccffc..8ca9b02 100644 --- a/Transceiver52M/ms/ms.h +++ b/Transceiver52M/ms/ms.h @@ -117,7 +117,7 @@ }; }; -using rx_queue_t = spsc_cond<8 * NUM_RXQ_FRAMES, one_burst, true, false>; +using rx_queue_t = spsc_cond_timeout<8 * NUM_RXQ_FRAMES, one_burst, true, false>; enum class SCH_STATE { SEARCHING, FOUND }; @@ -267,7 +267,7 @@ sched_params::target hw_target; single_thread_pool worker_thread; - void start(); + void start_lower_ms(); std::atomic<bool> upper_is_ready; void set_upper_ready(bool is_ready); diff --git a/Transceiver52M/ms/ms_rx_lower.cpp b/Transceiver52M/ms/ms_rx_lower.cpp index 4d6ce18..26ee131 100644 --- a/Transceiver52M/ms/ms_rx_lower.cpp +++ b/Transceiver52M/ms/ms_rx_lower.cpp @@ -142,10 +142,8 @@ memcpy(brst.sch_bits, sch_demod_bits, sizeof(sch_demod_bits)); } - if (upper_is_ready) { // this is blocking, so only submit if there is a reader - only if upper exists! - while (!rxqueue.spsc_push(&brst)) - ; - } + while (upper_is_ready && !rxqueue.spsc_push(&brst)) + ; if (do_auto_gain) maybe_update_gain(brst); diff --git a/Transceiver52M/ms/ms_upper.cpp b/Transceiver52M/ms/ms_upper.cpp index a10d542..4b2f919 100644 --- a/Transceiver52M/ms/ms_upper.cpp +++ b/Transceiver52M/ms/ms_upper.cpp @@ -80,37 +80,16 @@ while (!g_exit_flag) { driveControl(); } - std::cerr << "exit control!" << std::endl; + std::cerr << "exit U control!" << std::endl; }); - msleep(1); thr_tx = std::thread([this] { set_name_aff_sched(sched_params::thread_names::U_TX); while (!g_exit_flag) { driveTx(); } - std::cerr << "exit tx U!" << std::endl; + std::cerr << "exit U tx!" << std::endl; }); - // atomic ensures data is not written to q until loop reads - start_lower_ms(); - - set_name_aff_sched(sched_params::thread_names::U_RX); - while (!g_exit_flag) { - // set_upper_ready(true) needs to happen during cmd handling: - // the main loop is driven by rx, so unless rx is on AND transceiver is on we get stuck.. - driveReceiveFIFO(); - osmo_select_main(1); - - trxcon_phyif_rsp r; - if (cmdq_from_phy.spsc_pop(&r)) { - DBGLG() << "HAVE RESP:" << r.type << std::endl; - trxcon_phyif_handle_rsp(g_trxcon, &r); - } - } - set_upper_ready(false); - std::cerr << "exit rx U!" << std::endl; - mOn = false; - #ifdef LSANDEBUG std::thread([this] { set_name_aff_sched(sched_params::thread_names::LEAKCHECK); @@ -123,9 +102,23 @@ #endif } -void upper_trx::start_lower_ms() +void upper_trx::main_loop() { - ms_trx::start(); + set_name_aff_sched(sched_params::thread_names::U_RX); + set_upper_ready(true); + while (!g_exit_flag) { + driveReceiveFIFO(); + osmo_select_main(1); + + trxcon_phyif_rsp r; + if (cmdq_from_phy.spsc_pop(&r)) { + DBGLG() << "HAVE RESP:" << r.type << std::endl; + trxcon_phyif_handle_rsp(g_trxcon, &r); + } + } + set_upper_ready(false); + std::cerr << "exit U rx!" << std::endl; + mOn = false; } // signalvector is owning despite claiming not to, but we can pretend, too.. @@ -346,7 +339,7 @@ case TRXCON_PHYIF_CMDT_POWERON: if (!mOn) { mOn = true; - set_upper_ready(true); + start_lower_ms(); } break; case TRXCON_PHYIF_CMDT_POWEROFF: @@ -430,7 +423,7 @@ // blocking, will return when global exit is requested trx->start_threads(); - + trx->main_loop(); trx->stop_threads(); trx->stop_upper_threads(); diff --git a/Transceiver52M/ms/ms_upper.h b/Transceiver52M/ms/ms_upper.h index bc9bd14..2362365 100644 --- a/Transceiver52M/ms/ms_upper.h +++ b/Transceiver52M/ms/ms_upper.h @@ -41,7 +41,7 @@ public: void start_threads(); - void start_lower_ms(); + void main_loop(); void stop_upper_threads(); upper_trx(){}; -- To view, visit https://gerrit.osmocom.org/c/osmo-trx/+/32954 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmo-trx Gerrit-Branch: master Gerrit-Change-Id: I0b8deebc63cf4d936666fd68e1666d1917e89a5d Gerrit-Change-Number: 32954 Gerrit-PatchSet: 4 Gerrit-Owner: Hoernchen <ewild(a)sysmocom.de> Gerrit-Reviewer: Hoernchen <ewild(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: laforge <laforge(a)osmocom.org> Gerrit-Reviewer: pespin <pespin(a)sysmocom.de> Gerrit-MessageType: merged
1 0
0 0
[M] Change in osmo-trx[master]: ms: rearrange code to allow clean exits
by Hoernchen 10 Jul '23

10 Jul '23
Hoernchen has posted comments on this change. ( https://gerrit.osmocom.org/c/osmo-trx/+/32954 ) Change subject: ms: rearrange code to allow clean exits ...................................................................... Patch Set 4: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/c/osmo-trx/+/32954 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmo-trx Gerrit-Branch: master Gerrit-Change-Id: I0b8deebc63cf4d936666fd68e1666d1917e89a5d Gerrit-Change-Number: 32954 Gerrit-PatchSet: 4 Gerrit-Owner: Hoernchen <ewild(a)sysmocom.de> Gerrit-Reviewer: Hoernchen <ewild(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: laforge <laforge(a)osmocom.org> Gerrit-Reviewer: pespin <pespin(a)sysmocom.de> Gerrit-Comment-Date: Mon, 10 Jul 2023 10:41:35 +0000 Gerrit-HasComments: No Gerrit-Has-Labels: Yes Gerrit-MessageType: comment
1 0
0 0
[S] Change in osmo-trx[master]: ms: prune common sch acq code
by Hoernchen 10 Jul '23

10 Jul '23
Hoernchen has submitted this change. ( https://gerrit.osmocom.org/c/osmo-trx/+/32953 ) Change subject: ms: prune common sch acq code ...................................................................... ms: prune common sch acq code Change-Id: Ife639a78a4463f992247c19e0177f683db2ae0b7 --- M Transceiver52M/ms/ms_rx_lower.cpp 1 file changed, 11 insertions(+), 4 deletions(-) Approvals: pespin: Looks good to me, but someone else must approve Jenkins Builder: Verified laforge: Looks good to me, but someone else must approve Hoernchen: Looks good to me, approved diff --git a/Transceiver52M/ms/ms_rx_lower.cpp b/Transceiver52M/ms/ms_rx_lower.cpp index 992591e..4d6ce18 100644 --- a/Transceiver52M/ms/ms_rx_lower.cpp +++ b/Transceiver52M/ms/ms_rx_lower.cpp @@ -166,18 +166,16 @@ int start; memset((void *)&sch_acq_buffer[0], 0, sizeof(sch_acq_buffer)); + convert_and_scale(which_out_buffer, which_in_buffer, buf_len * 2, 1.f / float(rxFullScale)); if (is_first_sch_acq) { float max_corr = 0; - convert_and_scale(which_out_buffer, which_in_buffer, buf_len * 2, 1.f / float(rxFullScale)); start = get_sch_buffer_chan_imp_resp(ss, &channel_imp_resp[0], buf_len, &max_corr); - detect_burst(&ss[start], &channel_imp_resp[0], 0, sch_demod_bits); } else { - convert_and_scale(which_out_buffer, which_in_buffer, buf_len * 2, 1.f / float(rxFullScale)); start = get_sch_chan_imp_resp(ss, &channel_imp_resp[0]); start = start < 39 ? start : 39; start = start > -39 ? start : -39; - detect_burst(&ss[start], &channel_imp_resp[0], 0, sch_demod_bits); } + detect_burst(&ss[start], &channel_imp_resp[0], 0, sch_demod_bits); SoftVector bitss(148); for (int i = 0; i < 148; i++) { -- To view, visit https://gerrit.osmocom.org/c/osmo-trx/+/32953 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmo-trx Gerrit-Branch: master Gerrit-Change-Id: Ife639a78a4463f992247c19e0177f683db2ae0b7 Gerrit-Change-Number: 32953 Gerrit-PatchSet: 4 Gerrit-Owner: Hoernchen <ewild(a)sysmocom.de> Gerrit-Reviewer: Hoernchen <ewild(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: laforge <laforge(a)osmocom.org> Gerrit-Reviewer: pespin <pespin(a)sysmocom.de> Gerrit-MessageType: merged
1 0
0 0
[S] Change in osmo-trx[master]: ms: prune common sch acq code
by Hoernchen 10 Jul '23

10 Jul '23
Hoernchen has posted comments on this change. ( https://gerrit.osmocom.org/c/osmo-trx/+/32953 ) Change subject: ms: prune common sch acq code ...................................................................... Patch Set 4: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/c/osmo-trx/+/32953 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmo-trx Gerrit-Branch: master Gerrit-Change-Id: Ife639a78a4463f992247c19e0177f683db2ae0b7 Gerrit-Change-Number: 32953 Gerrit-PatchSet: 4 Gerrit-Owner: Hoernchen <ewild(a)sysmocom.de> Gerrit-Reviewer: Hoernchen <ewild(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: laforge <laforge(a)osmocom.org> Gerrit-Reviewer: pespin <pespin(a)sysmocom.de> Gerrit-Comment-Date: Mon, 10 Jul 2023 10:40:45 +0000 Gerrit-HasComments: No Gerrit-Has-Labels: Yes Gerrit-MessageType: comment
1 0
0 0
[L] Change in osmo-trx[master]: ms: remove syncthing tool
by Hoernchen 10 Jul '23

10 Jul '23
Hoernchen has submitted this change. ( https://gerrit.osmocom.org/c/osmo-trx/+/32952 ) Change subject: ms: remove syncthing tool ...................................................................... ms: remove syncthing tool Only used for testing during the first stages of development. Change-Id: Ie97069a109324b6e96c66a4b24d03f9745b6a52e --- M Transceiver52M/Makefile.am M Transceiver52M/ms/ms.cpp M Transceiver52M/ms/ms.h D Transceiver52M/ms/ms_rx_burst.h D Transceiver52M/ms/ms_rx_burst_test.cpp M Transceiver52M/ms/ms_rx_lower.cpp 6 files changed, 15 insertions(+), 467 deletions(-) Approvals: pespin: Looks good to me, but someone else must approve Jenkins Builder: Verified laforge: Looks good to me, approved diff --git a/Transceiver52M/Makefile.am b/Transceiver52M/Makefile.am index 65c8ebe..681809f 100644 --- a/Transceiver52M/Makefile.am +++ b/Transceiver52M/Makefile.am @@ -100,7 +100,6 @@ ms/ms.h \ ms/bladerf_specific.h \ ms/uhd_specific.h \ - ms/ms_rx_burst.h \ ms/ms_upper.h \ ms/ms_trxcon_if.h \ ms/itrq.h \ @@ -132,15 +131,6 @@ $(UHD_LIBS) \ $(TRXCON_LDADD) osmo_trx_ms_uhd_CPPFLAGS = $(AM_CPPFLAGS) $(UHD_CFLAGS) -DBUILDUHD - -bin_PROGRAMS += osmo-trx-syncthing-uhd -osmo_trx_syncthing_uhd_SOURCES = $(MS_LOWER_SRC) ms/ms_rx_burst_test.cpp -osmo_trx_syncthing_uhd_LDADD = \ - $(builddir)/device/uhd/libdevice.la \ - $(COMMON_LDADD) \ - $(UHD_LIBS) \ - $(TRXCON_LDADD) -osmo_trx_syncthing_uhd_CPPFLAGS = $(AM_CPPFLAGS) $(UHD_CFLAGS) -DSYNCTHINGONLY -DBUILDUHD endif endif @@ -182,15 +172,6 @@ $(BLADE_LIBS) \ $(TRXCON_LDADD) osmo_trx_ms_blade_CPPFLAGS = $(AM_CPPFLAGS) $(BLADE_CFLAGS) -DBUILDBLADE - -bin_PROGRAMS += osmo-trx-syncthing-blade -osmo_trx_syncthing_blade_SOURCES = $(MS_LOWER_SRC) ms/ms_rx_burst_test.cpp -osmo_trx_syncthing_blade_LDADD = \ - $(builddir)/device/bladerf/libdevice.la \ - $(COMMON_LDADD) \ - $(BLADE_LIBS) \ - $(TRXCON_LDADD) -osmo_trx_syncthing_blade_CPPFLAGS = $(AM_CPPFLAGS) $(BLADE_CFLAGS) -DSYNCTHINGONLY -DBUILDBLADE -I../device/ipc endif endif diff --git a/Transceiver52M/ms/ms.cpp b/Transceiver52M/ms/ms.cpp index ca3339b..2e91cae 100644 --- a/Transceiver52M/ms/ms.cpp +++ b/Transceiver52M/ms/ms.cpp @@ -29,16 +29,10 @@ #include <thread> #include <fstream> -#include "sigProcLib.h" - #include "ms.h" -#include "ms_rx_burst.h" -#include "grgsm_vitac/grgsm_vitac.h" extern "C" { #include "sch.h" -#include "convolve.h" -#include "convert.h" } dummylog ms_trx::dummy_log; @@ -52,196 +46,6 @@ template <> std::atomic<bool> ms_trx::base::stop_lower_threads_flag(false); -void tx_test(ms_trx *t, ts_hitter_q_t *q, unsigned int *tsc) -{ - sched_param sch_params; - sch_params.sched_priority = sched_get_priority_max(SCHED_FIFO); - pthread_setschedparam(pthread_self(), SCHED_FIFO, &sch_params); - - auto burst = genRandAccessBurst(0, 4, 0); - scaleVector(*burst, t->txFullScale); - - // float -> int16 - blade_sample_type burst_buf[burst->size()]; - convert_and_scale(burst_buf, burst->begin(), burst->size() * 2, 1); - - while (1) { - GSM::Time target; - while (!q->spsc_pop(&target)) { - q->spsc_prep_pop(); - } - - std::cerr << std::endl << "\x1B[32m hitting " << target.FN() << "\033[0m" << std::endl; - - int timing_advance = 0; - int64_t now_ts; - GSM::Time now_time; - target.incTN(3); // ul dl offset - int target_fn = target.FN(); - int target_tn = target.TN(); - t->timekeeper.get_both(&now_time, &now_ts); - - auto diff_fn = GSM::FNDelta(target_fn, now_time.FN()); - int diff_tn = (target_tn - (int)now_time.TN()) % 8; - auto tosend = GSM::Time(diff_fn, 0); - - if (diff_tn > 0) - tosend.incTN(diff_tn); - else if (diff_tn < 0) - tosend.decTN(-diff_tn); - - // in thory fn equal and tn+3 equal is also a problem... - if (diff_fn < 0 || (diff_fn == 0 && (now_time.TN() - target_tn < 1))) { - std::cerr << "## TX too late?! fn DIFF:" << diff_fn << " tn LOCAL: " << now_time.TN() - << " tn OTHER: " << target_tn << std::endl; - return; - } - - auto check = now_time + tosend; - int64_t send_ts = - now_ts + tosend.FN() * 8 * ONE_TS_BURST_LEN + tosend.TN() * ONE_TS_BURST_LEN - timing_advance; - -#ifdef DBGXX - std::cerr << "## fn DIFF: " << diff_fn << " ## tn DIFF: " << diff_tn << " tn LOCAL: " << now_time.TN() - << " tn OTHER: " << target_tn << " tndiff" << diff_tn << " tosend:" << tosend.FN() << ":" - << tosend.TN() << " calc: " << check.FN() << ":" << check.TN() << " target: " << target.FN() - << ":" << target.TN() << " ts now: " << now_ts << " target ts:" << send_ts << std::endl; -#endif - - unsigned int pad = 4 * 25; - blade_sample_type buf2[burst->size() + pad]; - std::fill(buf2, buf2 + pad, 0); - - memcpy(&buf2[pad], burst_buf, burst->size() * sizeof(blade_sample_type)); - - assert(target.FN() == check.FN()); - assert(target.TN() == check.TN()); - assert(target.FN() % 51 == 21); -#ifdef DBGXX - auto this_offset = offset_start + (offset_ctr++ % offsetrange); - std::cerr << "-- O " << this_offset << std::endl; - send_ts = now_ts - timing_advance + - ((target.FN() * 8 + (int)target.TN()) - (now_time.FN() * 8 + (int)now_time.TN())) * - ONE_TS_BURST_LEN; -#endif - t->submit_burst_ts(buf2, burst->size() + pad, send_ts - pad); -#ifdef DBGXX - signalVector test(burst->size() + pad); - convert_and_scale(test.begin(), buf2, burst->size() * 2 + pad, 1.f / float(scale)); - estim_burst_params ebp; - auto det = detectAnyBurst(test, 0, 4, 4, CorrType::RACH, 40, &ebp); - if (det > 0) - std::cerr << "## Y " << ebp.toa << std::endl; - else - std::cerr << "## NOOOOOOOOO " << ebp.toa << std::endl; -#endif - } -} -#ifdef SYNCTHINGONLY -template <typename A> -auto parsec(std::vector<std::string> &v, A &itr, std::string arg, bool *rv) -{ - if (*itr == arg) { - *rv = true; - return true; - } - return false; -} - -template <typename A, typename B, typename C> -bool parsec(std::vector<std::string> &v, A &itr, std::string arg, B f, C *rv) -{ - if (*itr == arg) { - itr++; - if (itr != v.end()) { - *rv = f(itr->c_str()); - return true; - } - } - return false; -} -template <typename A> -bool parsec(std::vector<std::string> &v, A &itr, std::string arg, int scale, int *rv) -{ - return parsec( - v, itr, arg, [scale](const char *v) -> auto { return atoi(v) * scale; }, rv); -} -template <typename A> -bool parsec(std::vector<std::string> &v, A &itr, std::string arg, int scale, unsigned int *rv) -{ - return parsec( - v, itr, arg, [scale](const char *v) -> auto { return atoi(v) * scale; }, rv); -} - -int main(int argc, char *argv[]) -{ - cpu_set_t cpuset; - - CPU_ZERO(&cpuset); - CPU_SET(2, &cpuset); - - auto rv = pthread_setaffinity_np(pthread_self(), sizeof(cpuset), &cpuset); - if (rv < 0) { - std::cerr << "affinity: errreur! " << std::strerror(errno); - return 0; - } - - unsigned int default_tx_freq(881000 * 1000), default_rx_freq(926000 * 1000); - unsigned int grx = 20, gtx = 20; - bool tx_flag = false; - pthread_setname_np(pthread_self(), "main"); - convolve_init(); - convert_init(); - sigProcLibSetup(); - initvita(); - - int status = 0; - auto trx = new ms_trx(); - trx->do_auto_gain = true; - - std::vector<std::string> args(argv + 1, argv + argc); - for (auto i = args.begin(); i != args.end(); ++i) { - parsec(args, i, "-r", 1000, &default_rx_freq); - parsec(args, i, "-t", 1000, &default_tx_freq); - parsec(args, i, "-gr", 1, &grx); - parsec(args, i, "-gt", 1, &gtx); - parsec(args, i, "-tx", &tx_flag); - } - - std::cerr << "usage: " << argv[0] << " <rxfreq in khz, i.e. 926000> [txfreq in khz, i.e. 881000] [TX]" - << std::endl - << "rx" << (argc == 1 ? " (default) " : " ") << default_rx_freq << "hz, tx " << default_tx_freq - << "hz" << std::endl - << "gain rx " << grx << " gain tx " << gtx << std::endl - << (tx_flag ? "##!!## RACH TX ACTIVE ##!!##" : "-- no rach tx --") << std::endl; - - status = trx->init_dev_and_streams(); - if (status < 0) - return status; - trx->tuneRx(default_rx_freq); - trx->tuneTx(default_tx_freq); - trx->setRxGain(grx); - trx->setTxGain(gtx); - - if (status == 0) { - // FIXME: hacks! needs exit flag for detached threads! - - std::thread(rcv_bursts_test, &trx->rxqueue, &trx->mTSC, trx->rxFullScale).detach(); - if (tx_flag) - std::thread(tx_test, trx, &trx->ts_hitter_q, &trx->mTSC).detach(); - trx->start(); - do { - sleep(1); - } while (1); - - trx->stop_threads(); - } - delete trx; - - return status; -} -#endif - int ms_trx::init_dev_and_streams() { int status = 0; diff --git a/Transceiver52M/ms/ms.h b/Transceiver52M/ms/ms.h index 3b97d1b..efccffc 100644 --- a/Transceiver52M/ms/ms.h +++ b/Transceiver52M/ms/ms.h @@ -251,9 +251,7 @@ // provides bursts to upper rx thread rx_queue_t rxqueue; -#ifdef SYNCTHINGONLY - ts_hitter_q_t ts_hitter_q; -#endif + blade_sample_type *first_sch_buf; blade_sample_type *burst_copy_buffer; diff --git a/Transceiver52M/ms/ms_rx_burst.h b/Transceiver52M/ms/ms_rx_burst.h deleted file mode 100644 index 764a69e..0000000 --- a/Transceiver52M/ms/ms_rx_burst.h +++ /dev/null @@ -1,25 +0,0 @@ -#pragma once -/* - * (C) 2022 by sysmocom s.f.m.c. GmbH <info(a)sysmocom.de> - * All Rights Reserved - * - * Author: Eric Wild <ewild(a)sysmocom.de> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * - */ - -#include "ms.h" - -void rcv_bursts_test(rx_queue_t *q, unsigned int *tsc, int scale); \ No newline at end of file diff --git a/Transceiver52M/ms/ms_rx_burst_test.cpp b/Transceiver52M/ms/ms_rx_burst_test.cpp deleted file mode 100644 index c3ba4ee..0000000 --- a/Transceiver52M/ms/ms_rx_burst_test.cpp +++ /dev/null @@ -1,206 +0,0 @@ -/* - * (C) 2022 by sysmocom s.f.m.c. GmbH <info(a)sysmocom.de> - * All Rights Reserved - * - * Author: Eric Wild <ewild(a)sysmocom.de> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * - */ -#include "ms.h" -#include "sigProcLib.h" -#include "signalVector.h" -#include "grgsm_vitac/grgsm_vitac.h" -extern "C" { -#include "sch.h" -} - -#if !defined(SYNCTHINGONLY) || !defined(NODAMNLOG) -#define DBGLG(...) ms_trx::dummy_log() -#else -#define DBGLG(...) std::cerr -#endif - -#if !defined(SYNCTHINGONLY) -#define DBGLG2(...) ms_trx::dummy_log() -#else -#define DBGLG2(...) std::cerr -#endif - -static bool decode_sch(float *bits, bool update_global_clock) -{ - struct sch_info sch; - ubit_t info[GSM_SCH_INFO_LEN]; - sbit_t data[GSM_SCH_CODED_LEN]; - - float_to_sbit(&bits[3], &data[0], 62, 39); - float_to_sbit(&bits[106], &data[39], 62, 39); - - if (!gsm_sch_decode(info, data)) { - gsm_sch_parse(info, &sch); - - DBGLG() << "SCH : Decoded values" << std::endl; - DBGLG() << " BSIC: " << sch.bsic << std::endl; - DBGLG() << " TSC: " << (sch.bsic & 0x7) << std::endl; - DBGLG() << " T1 : " << sch.t1 << std::endl; - DBGLG() << " T2 : " << sch.t2 << std::endl; - DBGLG() << " T3p : " << sch.t3p << std::endl; - DBGLG() << " FN : " << gsm_sch_to_fn(&sch) << std::endl; - return true; - } - return false; -} - -static void check_rcv_fn(GSM::Time t, bool first, unsigned int &lastfn, unsigned int &fnbm) -{ - if (first && t.TN() == 0) { - lastfn = t.FN(); - fnbm = 1 << 0; - first = false; - } - if (!first && t.FN() != (int)lastfn) { - if (fnbm != 255) - std::cerr << "rx " << lastfn << ":" << fnbm << " " << __builtin_popcount(fnbm) << std::endl; - lastfn = t.FN(); - fnbm = 1 << t.TN(); - } - - fnbm |= 1 << t.TN(); -} - -static void handle_it(one_burst &e, signalVector &burst, unsigned int tsc, int scale) -{ - std::fill(burst.begin(), burst.begin() + burst.size(), 0.0); - const auto is_sch = gsm_sch_check_ts(e.gsmts.TN(), e.gsmts.FN()); - const auto is_fcch = gsm_fcch_check_ts(e.gsmts.TN(), e.gsmts.FN()); - - if (is_fcch) - return; - - if (is_sch) { - char outbin[148]; - convert_and_scale(burst.begin(), e.burst, ONE_TS_BURST_LEN * 2, SAMPLE_SCALE_FACTOR); - std::stringstream dbgout; -#if 0 - { - struct estim_burst_params ebp; - auto rv2 = detectSCHBurst(burst, 4, 4, sch_detect_type::SCH_DETECT_FULL, &ebp); - auto bits = demodAnyBurst(burst, SCH, 4, &ebp); - // clamp_array(bits->begin(), 148, 1.5f); - for (auto &i : *bits) - i = (i > 0 ? 1 : -1); - - auto rv = decode_sch(bits->begin(), false); - dbgout << "U DET@" << (rv2 ? "yes " : " ") << "Timing offset " << ebp.toa - << " symbols, DECODE: " << (rv ? "yes" : "---") << " "; - - delete bits; - } -#endif - { - convert_and_scale(burst.begin(), burst.begin(), ONE_TS_BURST_LEN * 2, 1.f / float(scale)); - - std::complex<float> channel_imp_resp[CHAN_IMP_RESP_LENGTH * d_OSR]; - auto ss = reinterpret_cast<std::complex<float> *>(burst.begin()); - int d_c0_burst_start = get_sch_chan_imp_resp(ss, &channel_imp_resp[0]); - detect_burst(ss, &channel_imp_resp[0], d_c0_burst_start, outbin); - - SoftVector bits; - bits.resize(148); - for (int i = 0; i < 148; i++) { - bits[i] = (!outbin[i]); // < 1 ? -1 : 1; - } - - auto rv = decode_sch(bits.begin(), false); - dbgout << "U SCH@" - << " " << e.gsmts.FN() << ":" << e.gsmts.TN() << " " << d_c0_burst_start - << " DECODE:" << (rv ? "yes" : "---") << std::endl; - } - - DBGLG() << dbgout.str(); - return; - } -#if 1 - convert_and_scale(burst.begin(), e.burst, ONE_TS_BURST_LEN * 2, 1.f / float(scale)); - // std::cerr << "@" << tsc << " " << e.gsmts.FN() << ":" << e.gsmts.TN() << " " << ebp.toa << " " - // << std::endl; - - char outbin[148]; - auto ss = reinterpret_cast<std::complex<float> *>(burst.begin()); - float ncmax, dcmax; - std::complex<float> chan_imp_resp[CHAN_IMP_RESP_LENGTH * d_OSR], chan_imp_resp2[CHAN_IMP_RESP_LENGTH * d_OSR]; - auto normal_burst_start = get_norm_chan_imp_resp(ss, &chan_imp_resp[0], &ncmax, tsc); - auto dummy_burst_start = get_norm_chan_imp_resp(ss, &chan_imp_resp2[0], &dcmax, TS_DUMMY); - auto is_nb = ncmax > dcmax; - - DBGLG() << " U " << (is_nb ? "NB" : "DB") << "@ o nb: " << normal_burst_start << " o db: " << dummy_burst_start - << std::endl; - - if (is_nb) - detect_burst(ss, &chan_imp_resp[0], normal_burst_start, outbin); - else - detect_burst(ss, &chan_imp_resp2[0], dummy_burst_start, outbin); - ; -#ifdef DBGXX - // auto bits = SoftVector(148); - // for (int i = 0; i < 148; i++) - // (bits)[i] = outbin[i] < 1 ? -1 : 1; -#endif -#endif -} - -void rcv_bursts_test(rx_queue_t *q, unsigned int *tsc, int scale) -{ - static bool first = true; - unsigned int lastfn = 0; - unsigned int fnbm = 0; - signalVector burst(ONE_TS_BURST_LEN, 100, 100); - - cpu_set_t cpuset; - - CPU_ZERO(&cpuset); - CPU_SET(1, &cpuset); - - auto rv = pthread_setaffinity_np(pthread_self(), sizeof(cpuset), &cpuset); - if (rv < 0) { - std::cerr << "affinity: errreur! " << std::strerror(errno); - exit(0); - } - - int prio = sched_get_priority_max(SCHED_RR); - struct sched_param param; - param.sched_priority = prio; - rv = sched_setscheduler(0, SCHED_RR, &param); - if (rv < 0) { - std::cerr << "scheduler: errreur! " << std::strerror(errno); - exit(0); - } - - while (1) { - one_burst e; - while (!q->spsc_pop(&e)) { - q->spsc_prep_pop(); - } - - check_rcv_fn(e.gsmts, first, lastfn, fnbm); - - handle_it(e, burst, *tsc, scale); -#ifdef DBGXX - rv = detectSCHBurst(*burst, 4, 4, sch_detect_type::SCH_DETECT_FULL, &ebp); - if (rv > 0) - std::cerr << "#" << e.gsmts.FN() << ":" << e.gsmts.TN() << " " << ebp.toa << std::endl; - sched_yield(); -#endif - } -} \ No newline at end of file diff --git a/Transceiver52M/ms/ms_rx_lower.cpp b/Transceiver52M/ms/ms_rx_lower.cpp index 3a7e6ec..992591e 100644 --- a/Transceiver52M/ms/ms_rx_lower.cpp +++ b/Transceiver52M/ms/ms_rx_lower.cpp @@ -38,13 +38,13 @@ #undef LOG #endif -#if !defined(SYNCTHINGONLY) //|| !defined(NODAMNLOG) +#if !defined(NODAMNLOG) #define DBGLG(...) ms_trx::dummy_log() #else #define DBGLG(...) std::cerr #endif -#if !defined(SYNCTHINGONLY) || !defined(NODAMNLOG) +#if !defined(NODAMNLOG) #define DBGLG2(...) ms_trx::dummy_log() #else #define DBGLG2(...) std::cerr @@ -87,18 +87,6 @@ // global_time_keeper.FN(fn); // global_time_keeper.TN(0); } -#ifdef SYNCTHINGONLY - else { - int t3 = sch.t3p * 10 + 1; - if (t3 == 11) { - // timeslot hitter attempt @ fn 21 in mf - DBGLG2() << "sch @ " << t3 << std::endl; - auto e = GSM::Time(fn, 0); - e += 10; - ts_hitter_q.spsc_push(&e); - } - } -#endif return true; } @@ -153,14 +141,11 @@ handle_sch(false); memcpy(brst.sch_bits, sch_demod_bits, sizeof(sch_demod_bits)); } -#ifndef SYNCTHINGONLY + if (upper_is_ready) { // this is blocking, so only submit if there is a reader - only if upper exists! -#endif while (!rxqueue.spsc_push(&brst)) ; -#ifndef SYNCTHINGONLY } -#endif if (do_auto_gain) maybe_update_gain(brst); -- To view, visit https://gerrit.osmocom.org/c/osmo-trx/+/32952 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmo-trx Gerrit-Branch: master Gerrit-Change-Id: Ie97069a109324b6e96c66a4b24d03f9745b6a52e Gerrit-Change-Number: 32952 Gerrit-PatchSet: 4 Gerrit-Owner: Hoernchen <ewild(a)sysmocom.de> Gerrit-Reviewer: Hoernchen <ewild(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: laforge <laforge(a)osmocom.org> Gerrit-Reviewer: pespin <pespin(a)sysmocom.de> Gerrit-MessageType: merged
1 0
0 0
[M] Change in osmo-mgw[master]: ASCI: Support conference briding with 1..n connections
by pespin 10 Jul '23

10 Jul '23
Attention is currently required from: jolly, laforge, dexter. pespin has posted comments on this change. ( https://gerrit.osmocom.org/c/osmo-mgw/+/33548 ) Change subject: ASCI: Support conference briding with 1..n connections ...................................................................... Patch Set 5: Code-Review+1 -- To view, visit https://gerrit.osmocom.org/c/osmo-mgw/+/33548 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmo-mgw Gerrit-Branch: master Gerrit-Change-Id: Ic99a55ab5a3a6170e940403fadd52697e99f2f3a Gerrit-Change-Number: 33548 Gerrit-PatchSet: 5 Gerrit-Owner: jolly <andreas(a)eversberg.eu> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: dexter <pmaier(a)sysmocom.de> Gerrit-Reviewer: pespin <pespin(a)sysmocom.de> Gerrit-CC: laforge <laforge(a)osmocom.org> Gerrit-Attention: jolly <andreas(a)eversberg.eu> Gerrit-Attention: laforge <laforge(a)osmocom.org> Gerrit-Attention: dexter <pmaier(a)sysmocom.de> Gerrit-Comment-Date: Mon, 10 Jul 2023 10:37:26 +0000 Gerrit-HasComments: No Gerrit-Has-Labels: Yes Gerrit-MessageType: comment
1 0
0 0
[S] Change in osmo-mgw[master]: ASCI: Add new mode for voice group/broadcast call
by pespin 10 Jul '23

10 Jul '23
Attention is currently required from: jolly, dexter. pespin has posted comments on this change. ( https://gerrit.osmocom.org/c/osmo-mgw/+/33546 ) Change subject: ASCI: Add new mode for voice group/broadcast call ...................................................................... Patch Set 3: (1 comment) Commit Message: https://gerrit.osmocom.org/c/osmo-mgw/+/33546/comment/2c077b64_0dc54bd2 PS3, Line 23: connection receives RTP in case of a conference. I'm still not really understanding this paragraph sorry :/ what do you mean by "sending RTP that has been received by multiple receiving connections"? Why only one connection receives the RTP? Do you mean "receive" from the point of view of MGW? so you mean that only one peer endpoint may transmit at a time? -- To view, visit https://gerrit.osmocom.org/c/osmo-mgw/+/33546 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmo-mgw Gerrit-Branch: master Gerrit-Change-Id: I0639c663e119d85bef1010c7aa45e2f133a9daf0 Gerrit-Change-Number: 33546 Gerrit-PatchSet: 3 Gerrit-Owner: jolly <andreas(a)eversberg.eu> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: dexter <pmaier(a)sysmocom.de> Gerrit-Reviewer: laforge <laforge(a)osmocom.org> Gerrit-Reviewer: pespin <pespin(a)sysmocom.de> Gerrit-Attention: jolly <andreas(a)eversberg.eu> Gerrit-Attention: dexter <pmaier(a)sysmocom.de> Gerrit-Comment-Date: Mon, 10 Jul 2023 10:36:05 +0000 Gerrit-HasComments: Yes Gerrit-Has-Labels: No Gerrit-MessageType: comment
1 0
0 0
[L] Change in osmo-trx[master]: ms: rearrange internal trxcon<->phy if
by Hoernchen 10 Jul '23

10 Jul '23
Hoernchen has submitted this change. ( https://gerrit.osmocom.org/c/osmo-trx/+/32951 ) Change subject: ms: rearrange internal trxcon<->phy if ...................................................................... ms: rearrange internal trxcon<->phy if Change-Id: I20aef3844f7699e164fe089358aa7e2325608c85 --- M Transceiver52M/Makefile.am M Transceiver52M/ms/l1ctl_server_cb.cpp M Transceiver52M/ms/ms_rx_lower.cpp A Transceiver52M/ms/ms_trxcon_if.cpp A Transceiver52M/ms/ms_trxcon_if.h M Transceiver52M/ms/ms_upper.cpp M Transceiver52M/ms/ms_upper.h 7 files changed, 213 insertions(+), 172 deletions(-) Approvals: pespin: Looks good to me, but someone else must approve Jenkins Builder: Verified laforge: Looks good to me, approved diff --git a/Transceiver52M/Makefile.am b/Transceiver52M/Makefile.am index 296ff05..65c8ebe 100644 --- a/Transceiver52M/Makefile.am +++ b/Transceiver52M/Makefile.am @@ -82,19 +82,27 @@ $(top_builddir)/osmocom-bb/src/host/trxcon/src/.libs/libl1sched.a \ $(LIBOSMOCODING_LIBS) -MS_SOURCES = \ +MS_LOWER_SRC = \ ms/sch.c \ ms/ms.cpp \ ms/ms_rx_lower.cpp \ grgsm_vitac/grgsm_vitac.cpp \ grgsm_vitac/viterbi_detector.cc +MS_UPPER_SRC = \ + ms/ms_upper.cpp \ + ms/l1ctl_server.c \ + ms/logging.c \ + ms/l1ctl_server_cb.cpp \ + ms/ms_trxcon_if.cpp + noinst_HEADERS += \ ms/ms.h \ ms/bladerf_specific.h \ ms/uhd_specific.h \ ms/ms_rx_burst.h \ ms/ms_upper.h \ + ms/ms_trxcon_if.h \ ms/itrq.h \ ms/sch.h \ ms/threadpool.h \ @@ -117,7 +125,7 @@ if ENABLE_MS_TRX bin_PROGRAMS += osmo-trx-ms-uhd -osmo_trx_ms_uhd_SOURCES = $(MS_SOURCES) ms/ms_upper.cpp ms/l1ctl_server.c ms/logging.c ms/l1ctl_server_cb.cpp +osmo_trx_ms_uhd_SOURCES = $(MS_LOWER_SRC) $(MS_UPPER_SRC) osmo_trx_ms_uhd_LDADD = \ $(builddir)/device/uhd/libdevice.la \ $(COMMON_LDADD) \ @@ -126,7 +134,7 @@ osmo_trx_ms_uhd_CPPFLAGS = $(AM_CPPFLAGS) $(UHD_CFLAGS) -DBUILDUHD bin_PROGRAMS += osmo-trx-syncthing-uhd -osmo_trx_syncthing_uhd_SOURCES = $(MS_SOURCES) ms/ms_rx_burst_test.cpp +osmo_trx_syncthing_uhd_SOURCES = $(MS_LOWER_SRC) ms/ms_rx_burst_test.cpp osmo_trx_syncthing_uhd_LDADD = \ $(builddir)/device/uhd/libdevice.la \ $(COMMON_LDADD) \ @@ -167,7 +175,7 @@ if ENABLE_MS_TRX bin_PROGRAMS += osmo-trx-ms-blade -osmo_trx_ms_blade_SOURCES = $(MS_SOURCES) ms/ms_upper.cpp ms/l1ctl_server.c ms/logging.c ms/l1ctl_server_cb.cpp +osmo_trx_ms_blade_SOURCES = $(MS_LOWER_SRC) $(MS_UPPER_SRC) osmo_trx_ms_blade_LDADD = \ $(builddir)/device/bladerf/libdevice.la \ $(COMMON_LDADD) \ @@ -176,7 +184,7 @@ osmo_trx_ms_blade_CPPFLAGS = $(AM_CPPFLAGS) $(BLADE_CFLAGS) -DBUILDBLADE bin_PROGRAMS += osmo-trx-syncthing-blade -osmo_trx_syncthing_blade_SOURCES = $(MS_SOURCES) ms/ms_rx_burst_test.cpp +osmo_trx_syncthing_blade_SOURCES = $(MS_LOWER_SRC) ms/ms_rx_burst_test.cpp osmo_trx_syncthing_blade_LDADD = \ $(builddir)/device/bladerf/libdevice.la \ $(COMMON_LDADD) \ diff --git a/Transceiver52M/ms/l1ctl_server_cb.cpp b/Transceiver52M/ms/l1ctl_server_cb.cpp index 4121451..42f64ac 100644 --- a/Transceiver52M/ms/l1ctl_server_cb.cpp +++ b/Transceiver52M/ms/l1ctl_server_cb.cpp @@ -24,13 +24,10 @@ #include <osmocom/bb/trxcon/trxcon_fsm.h> #include <osmocom/bb/trxcon/l1ctl_server.h> } +#include "ms_trxcon_if.h" static struct l1ctl_server_cfg server_cfg; static struct l1ctl_server *server = NULL; -namespace trxcon -{ -extern struct trxcon_inst *g_trxcon; -} static int l1ctl_rx_cb(struct l1ctl_client *l1c, struct msgb *msg) { @@ -41,9 +38,9 @@ static void l1ctl_conn_accept_cb(struct l1ctl_client *l1c) { - l1c->log_prefix = talloc_strdup(l1c, trxcon::g_trxcon->log_prefix); - l1c->priv = trxcon::g_trxcon; - trxcon::g_trxcon->l2if = l1c; + l1c->log_prefix = talloc_strdup(l1c, g_trxcon->log_prefix); + l1c->priv = g_trxcon; + g_trxcon->l2if = l1c; } static void l1ctl_conn_close_cb(struct l1ctl_client *l1c) @@ -56,17 +53,13 @@ osmo_fsm_inst_dispatch(trxcon->fi, TRXCON_EV_L2IF_FAILURE, NULL); } -namespace trxcon -{ bool trxc_l1ctl_init(void *tallctx) { /* Start the L1CTL server */ server_cfg = (struct l1ctl_server_cfg){ /* TODO: make path configurable */ - .sock_path = "/tmp/osmocom_l2", - .num_clients_max = 1, - .conn_read_cb = &l1ctl_rx_cb, - .conn_accept_cb = &l1ctl_conn_accept_cb, + .sock_path = "/tmp/osmocom_l2", .num_clients_max = 1, + .conn_read_cb = &l1ctl_rx_cb, .conn_accept_cb = &l1ctl_conn_accept_cb, .conn_close_cb = &l1ctl_conn_close_cb, }; @@ -76,4 +69,3 @@ } return true; } -} // namespace trxcon \ No newline at end of file diff --git a/Transceiver52M/ms/ms_rx_lower.cpp b/Transceiver52M/ms/ms_rx_lower.cpp index dc0d56d..3a7e6ec 100644 --- a/Transceiver52M/ms/ms_rx_lower.cpp +++ b/Transceiver52M/ms/ms_rx_lower.cpp @@ -19,8 +19,6 @@ * */ -#include "sigProcLib.h" -#include "signalVector.h" #include <atomic> #include <cassert> #include <complex> diff --git a/Transceiver52M/ms/ms_trxcon_if.cpp b/Transceiver52M/ms/ms_trxcon_if.cpp new file mode 100644 index 0000000..7de9710 --- /dev/null +++ b/Transceiver52M/ms/ms_trxcon_if.cpp @@ -0,0 +1,78 @@ +/* + * (C) 2023 by sysmocom s.f.m.c. GmbH <info(a)sysmocom.de> + * All Rights Reserved + * + * Author: Eric Wild <ewild(a)sysmocom.de> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ + +#include <atomic> +#include "ms_trxcon_if.h" +extern "C" { +#include <osmocom/bb/trxcon/trxcon.h> +#include <osmocom/bb/trxcon/l1ctl_server.h> +#include <osmocom/core/panic.h> +} + +extern tx_queue_t txq; +extern cmd_queue_t cmdq_to_phy; +extern cmdr_queue_t cmdq_from_phy; +extern std::atomic<bool> g_exit_flag; +// trxcon C call(back) if +extern "C" { +int trxcon_phyif_handle_burst_req(void *phyif, const struct trxcon_phyif_burst_req *br) +{ + if (br->burst_len == 0) // dummy/nope + return 0; + OSMO_ASSERT(br->burst != 0); + + internal_q_tx_buf b(br); + if (!g_exit_flag) + txq.spsc_push(&b); + return 0; +} + +int trxcon_phyif_handle_cmd(void *phyif, const struct trxcon_phyif_cmd *cmd) +{ +#ifdef TXDEBUG + DBGLG() << "TOP C: " << cmd2str(cmd->type) << std::endl; +#endif + if (!g_exit_flag) + cmdq_to_phy.spsc_push(cmd); + // q for resp polling happens in main loop + return 0; +} + +void trxcon_phyif_close(void *phyif) +{ +} + +void trxcon_l1ctl_close(struct trxcon_inst *trxcon) +{ + /* Avoid use-after-free: both *fi and *trxcon are children of + * the L2IF (L1CTL connection), so we need to re-parent *fi + * to NULL before calling l1ctl_client_conn_close(). */ + talloc_steal(NULL, trxcon->fi); + l1ctl_client_conn_close((struct l1ctl_client *)trxcon->l2if); +} + +int trxcon_l1ctl_send(struct trxcon_inst *trxcon, struct msgb *msg) +{ + struct l1ctl_client *l1c = (struct l1ctl_client *)trxcon->l2if; + + return l1ctl_client_send(l1c, msg); +} +} diff --git a/Transceiver52M/ms/ms_trxcon_if.h b/Transceiver52M/ms/ms_trxcon_if.h new file mode 100644 index 0000000..9879d1a --- /dev/null +++ b/Transceiver52M/ms/ms_trxcon_if.h @@ -0,0 +1,42 @@ +#pragma once +/* + * (C) 2023 by sysmocom s.f.m.c. GmbH <info(a)sysmocom.de> + * All Rights Reserved + * + * Author: Eric Wild <ewild(a)sysmocom.de> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ + +#include "ms.h" +extern "C" { +#include <osmocom/bb/trxcon/phyif.h> +} + +extern struct trxcon_inst *g_trxcon; +struct internal_q_tx_buf { + trxcon_phyif_burst_req r; + uint8_t buf[148]; + internal_q_tx_buf() = default; + internal_q_tx_buf(const internal_q_tx_buf &) = delete; + internal_q_tx_buf &operator=(const internal_q_tx_buf &) = default; + internal_q_tx_buf(const struct trxcon_phyif_burst_req *br) : r(*br) + { + memcpy(buf, (void *)br->burst, br->burst_len); + } +}; +using tx_queue_t = spsc_cond<8 * 1, internal_q_tx_buf, true, false>; +using cmd_queue_t = spsc_cond<8 * 1, trxcon_phyif_cmd, true, false>; +using cmdr_queue_t = spsc_cond<8 * 1, trxcon_phyif_rsp, false, false>; diff --git a/Transceiver52M/ms/ms_upper.cpp b/Transceiver52M/ms/ms_upper.cpp index cae1893..a10d542 100644 --- a/Transceiver52M/ms/ms_upper.cpp +++ b/Transceiver52M/ms/ms_upper.cpp @@ -19,6 +19,7 @@ * */ +#include <csignal> #include "sigProcLib.h" #include "ms.h" #include <signalVector.h> @@ -27,70 +28,30 @@ #include <grgsm_vitac/grgsm_vitac.h> extern "C" { -#include <stdio.h> -#include <stdlib.h> -#include <stdint.h> -#include <string.h> -#include <getopt.h> -#include <unistd.h> -#include <signal.h> -#include <errno.h> -#include <time.h> -#include <fenv.h> #include "sch.h" #include "convolve.h" #include "convert.h" +#include <osmocom/gsm/gsm_utils.h> +#include <osmocom/bb/trxcon/trxcon.h> +#include <osmocom/bb/trxcon/trxcon_fsm.h> +#include <osmocom/bb/trxcon/l1ctl_server.h> + +extern void trxc_log_init(void *tallctx); #ifdef LSANDEBUG void __lsan_do_recoverable_leak_check(); #endif } +#include "ms_trxcon_if.h" #include "ms_upper.h" -namespace trxcon -{ -extern "C" { -#include <osmocom/core/fsm.h> -#include <osmocom/core/msgb.h> -#include <osmocom/core/talloc.h> -#include <osmocom/core/signal.h> -#include <osmocom/core/select.h> -#include <osmocom/gsm/gsm_utils.h> - -#include <osmocom/core/logging.h> -#include <osmocom/bb/trxcon/logging.h> - -#include <osmocom/bb/trxcon/trxcon.h> -#include <osmocom/bb/trxcon/trxcon_fsm.h> -#include <osmocom/bb/trxcon/phyif.h> -#include <osmocom/bb/trxcon/l1ctl_server.h> -} -struct trxcon_inst *g_trxcon; -// trx_instance *trxcon_instance; // local handle -struct internal_q_tx_buf { - trxcon_phyif_burst_req r; - uint8_t buf[148]; - internal_q_tx_buf() = default; - internal_q_tx_buf(const internal_q_tx_buf &) = delete; - internal_q_tx_buf &operator=(const internal_q_tx_buf &) = default; - internal_q_tx_buf(const struct trxcon::trxcon_phyif_burst_req *br) : r(*br) - { - memcpy(buf, (void *)br->burst, br->burst_len); - } -}; -using tx_queue_t = spsc_cond<8 * 1, internal_q_tx_buf, true, false>; -using cmd_queue_t = spsc_cond<8 * 1, trxcon_phyif_cmd, true, false>; -using cmdr_queue_t = spsc_cond<8 * 1, trxcon_phyif_rsp, false, false>; -static tx_queue_t txq; -static cmd_queue_t cmdq_to_phy; -static cmdr_queue_t cmdq_from_phy; - extern bool trxc_l1ctl_init(void *tallctx); - -} // namespace trxcon -extern "C" void trxc_log_init(void *tallctx); +struct trxcon_inst *g_trxcon; +tx_queue_t txq; +cmd_queue_t cmdq_to_phy; +cmdr_queue_t cmdq_from_phy; #ifdef LOG #undef LOG @@ -138,12 +99,12 @@ // set_upper_ready(true) needs to happen during cmd handling: // the main loop is driven by rx, so unless rx is on AND transceiver is on we get stuck.. driveReceiveFIFO(); - trxcon::osmo_select_main(1); + osmo_select_main(1); - trxcon::trxcon_phyif_rsp r; - if (trxcon::cmdq_from_phy.spsc_pop(&r)) { + trxcon_phyif_rsp r; + if (cmdq_from_phy.spsc_pop(&r)) { DBGLG() << "HAVE RESP:" << r.type << std::endl; - trxcon_phyif_handle_rsp(trxcon::g_trxcon, &r); + trxcon_phyif_handle_rsp(g_trxcon, &r); } } set_upper_ready(false); @@ -196,9 +157,9 @@ const auto is_sch = gsm_sch_check_ts(wTime.TN(), wTime.FN()); const auto is_fcch = gsm_fcch_check_ts(wTime.TN(), wTime.FN()); - trxcon::trxcon_phyif_rtr_ind i = { static_cast<uint32_t>(wTime.FN()), static_cast<uint8_t>(wTime.TN()) }; - trxcon::trxcon_phyif_rtr_rsp r = {}; - trxcon_phyif_handle_rtr_ind(trxcon::g_trxcon, &i, &r); + trxcon_phyif_rtr_ind i = { static_cast<uint32_t>(wTime.FN()), static_cast<uint8_t>(wTime.TN()) }; + trxcon_phyif_rtr_rsp r = {}; + trxcon_phyif_handle_rtr_ind(g_trxcon, &i, &r); if (!(r.flags & TRXCON_PHYIF_RTR_F_ACTIVE)) return false; @@ -265,28 +226,28 @@ return; if (pullRadioVector(burstTime, RSSI, TOA)) { - trxcon::trxcon_phyif_burst_ind bi; + trxcon_phyif_burst_ind bi; bi.fn = burstTime.FN(); bi.tn = burstTime.TN(); bi.rssi = RSSI; bi.toa256 = TOA; bi.burst = (sbit_t *)demodded_softbits; bi.burst_len = sizeof(demodded_softbits); - trxcon_phyif_handle_burst_ind(trxcon::g_trxcon, &bi); + trxcon_phyif_handle_burst_ind(g_trxcon, &bi); } - struct trxcon::trxcon_phyif_rts_ind rts { + struct trxcon_phyif_rts_ind rts { static_cast<uint32_t>(burstTime.FN()), static_cast<uint8_t>(burstTime.TN()) }; - trxcon_phyif_handle_rts_ind(trxcon::g_trxcon, &rts); + trxcon_phyif_handle_rts_ind(g_trxcon, &rts); } void upper_trx::driveTx() { - trxcon::internal_q_tx_buf e; + internal_q_tx_buf e; static BitVector newBurst(sizeof(e.buf)); - while (!trxcon::txq.spsc_pop(&e)) { - trxcon::txq.spsc_prep_pop(); + while (!txq.spsc_pop(&e)) { + txq.spsc_prep_pop(); } // ensure our tx cb is tickled and can exit @@ -295,7 +256,7 @@ return; } - trxcon::internal_q_tx_buf *burst = &e; + internal_q_tx_buf *burst = &e; #ifdef TXDEBUG DBGLG() << "got burst!" << burst->r.fn << ":" << burst->ts << " current: " << timekeeper.gsmtime().FN() @@ -333,31 +294,31 @@ } #ifdef TXDEBUG -static const char *cmd2str(trxcon::trxcon_phyif_cmd_type c) +static const char *cmd2str(trxcon_phyif_cmd_type c) { switch (c) { - case trxcon::TRXCON_PHYIF_CMDT_RESET: + case TRXCON_PHYIF_CMDT_RESET: return "TRXCON_PHYIF_CMDT_RESET"; - case trxcon::TRXCON_PHYIF_CMDT_POWERON: + case TRXCON_PHYIF_CMDT_POWERON: return "TRXCON_PHYIF_CMDT_POWERON"; - case trxcon::TRXCON_PHYIF_CMDT_POWEROFF: + case TRXCON_PHYIF_CMDT_POWEROFF: return "TRXCON_PHYIF_CMDT_POWEROFF"; - case trxcon::TRXCON_PHYIF_CMDT_MEASURE: + case TRXCON_PHYIF_CMDT_MEASURE: return "TRXCON_PHYIF_CMDT_MEASURE"; - case trxcon::TRXCON_PHYIF_CMDT_SETFREQ_H0: + case TRXCON_PHYIF_CMDT_SETFREQ_H0: return "TRXCON_PHYIF_CMDT_SETFREQ_H0"; - case trxcon::TRXCON_PHYIF_CMDT_SETFREQ_H1: + case TRXCON_PHYIF_CMDT_SETFREQ_H1: return "TRXCON_PHYIF_CMDT_SETFREQ_H1"; - case trxcon::TRXCON_PHYIF_CMDT_SETSLOT: + case TRXCON_PHYIF_CMDT_SETSLOT: return "TRXCON_PHYIF_CMDT_SETSLOT"; - case trxcon::TRXCON_PHYIF_CMDT_SETTA: + case TRXCON_PHYIF_CMDT_SETTA: return "TRXCON_PHYIF_CMDT_SETTA"; default: return "UNKNOWN COMMAND!"; } } -static void print_cmd(trxcon::trxcon_phyif_cmd_type c) +static void print_cmd(trxcon_phyif_cmd_type c) { DBGLG() << cmd2str(c) << std::endl; } @@ -365,10 +326,10 @@ bool upper_trx::driveControl() { - trxcon::trxcon_phyif_rsp r; - trxcon::trxcon_phyif_cmd cmd; - while (!trxcon::cmdq_to_phy.spsc_pop(&cmd)) { - trxcon::cmdq_to_phy.spsc_prep_pop(); + trxcon_phyif_rsp r; + trxcon_phyif_cmd cmd; + while (!cmdq_to_phy.spsc_pop(&cmd)) { + cmdq_to_phy.spsc_prep_pop(); } if (g_exit_flag) @@ -379,87 +340,41 @@ #endif switch (cmd.type) { - case trxcon::TRXCON_PHYIF_CMDT_RESET: + case TRXCON_PHYIF_CMDT_RESET: set_ta(0); break; - case trxcon::TRXCON_PHYIF_CMDT_POWERON: + case TRXCON_PHYIF_CMDT_POWERON: if (!mOn) { mOn = true; set_upper_ready(true); } break; - case trxcon::TRXCON_PHYIF_CMDT_POWEROFF: + case TRXCON_PHYIF_CMDT_POWEROFF: break; - case trxcon::TRXCON_PHYIF_CMDT_MEASURE: - r.type = trxcon::trxcon_phyif_cmd_type::TRXCON_PHYIF_CMDT_MEASURE; + case TRXCON_PHYIF_CMDT_MEASURE: + r.type = trxcon_phyif_cmd_type::TRXCON_PHYIF_CMDT_MEASURE; r.param.measure.band_arfcn = cmd.param.measure.band_arfcn; // FIXME: do we want to measure anything, considering the transceiver just syncs by.. syncing? r.param.measure.dbm = -80; - tuneRx(trxcon::gsm_arfcn2freq10(cmd.param.measure.band_arfcn, 0) * 1000 * 100); - tuneTx(trxcon::gsm_arfcn2freq10(cmd.param.measure.band_arfcn, 1) * 1000 * 100); - trxcon::cmdq_from_phy.spsc_push(&r); + tuneRx(gsm_arfcn2freq10(cmd.param.measure.band_arfcn, 0) * 1000 * 100); + tuneTx(gsm_arfcn2freq10(cmd.param.measure.band_arfcn, 1) * 1000 * 100); + cmdq_from_phy.spsc_push(&r); break; - case trxcon::TRXCON_PHYIF_CMDT_SETFREQ_H0: - tuneRx(trxcon::gsm_arfcn2freq10(cmd.param.setfreq_h0.band_arfcn, 0) * 1000 * 100); - tuneTx(trxcon::gsm_arfcn2freq10(cmd.param.setfreq_h0.band_arfcn, 1) * 1000 * 100); + case TRXCON_PHYIF_CMDT_SETFREQ_H0: + tuneRx(gsm_arfcn2freq10(cmd.param.setfreq_h0.band_arfcn, 0) * 1000 * 100); + tuneTx(gsm_arfcn2freq10(cmd.param.setfreq_h0.band_arfcn, 1) * 1000 * 100); break; - case trxcon::TRXCON_PHYIF_CMDT_SETFREQ_H1: + case TRXCON_PHYIF_CMDT_SETFREQ_H1: break; - case trxcon::TRXCON_PHYIF_CMDT_SETSLOT: + case TRXCON_PHYIF_CMDT_SETSLOT: break; - case trxcon::TRXCON_PHYIF_CMDT_SETTA: + case TRXCON_PHYIF_CMDT_SETTA: set_ta(cmd.param.setta.ta); break; } return false; } -// trxcon C call(back) if -extern "C" { -int trxcon_phyif_handle_burst_req(void *phyif, const struct trxcon::trxcon_phyif_burst_req *br) -{ - if (br->burst_len == 0) // dummy/nope - return 0; - OSMO_ASSERT(br->burst != 0); - - trxcon::internal_q_tx_buf b(br); - if (!g_exit_flag) - trxcon::txq.spsc_push(&b); - return 0; -} - -int trxcon_phyif_handle_cmd(void *phyif, const struct trxcon::trxcon_phyif_cmd *cmd) -{ -#ifdef TXDEBUG - DBGLG() << "TOP C: " << cmd2str(cmd->type) << std::endl; -#endif - if (!g_exit_flag) - trxcon::cmdq_to_phy.spsc_push(cmd); - // q for resp polling happens in main loop - return 0; -} - -void trxcon_phyif_close(void *phyif) -{ -} - -void trxcon_l1ctl_close(struct trxcon::trxcon_inst *trxcon) -{ - /* Avoid use-after-free: both *fi and *trxcon are children of - * the L2IF (L1CTL connection), so we need to re-parent *fi - * to NULL before calling l1ctl_client_conn_close(). */ - talloc_steal(NULL, trxcon->fi); - trxcon::l1ctl_client_conn_close((struct trxcon::l1ctl_client *)trxcon->l2if); -} - -int trxcon_l1ctl_send(struct trxcon::trxcon_inst *trxcon, struct trxcon::msgb *msg) -{ - struct trxcon::l1ctl_client *l1c = (struct trxcon::l1ctl_client *)trxcon->l2if; - - return trxcon::l1ctl_client_send(l1c, msg); -} -} - void sighandler(int sigset) { // we might get a sigpipe in case the l1ctl ud socket disconnects because mobile quits @@ -468,10 +383,10 @@ // we know the flag is atomic and it prevents the trxcon cb handlers from writing // to the queues, so submit some trash to unblock the threads & exit - trxcon::trxcon_phyif_cmd cmd = {}; - trxcon::internal_q_tx_buf b = {}; - trxcon::txq.spsc_push(&b); - trxcon::cmdq_to_phy.spsc_push(&cmd); + trxcon_phyif_cmd cmd = {}; + internal_q_tx_buf b = {}; + txq.spsc_push(&b); + cmdq_to_phy.spsc_push(&cmd); msleep(200); return; @@ -484,13 +399,13 @@ signal(SIGPIPE, sighandler); signal(SIGINT, sighandler); - trxcon::msgb_talloc_ctx_init(tall_trxcon_ctx, 0); + msgb_talloc_ctx_init(tall_trxcon_ctx, 0); trxc_log_init(tall_trxcon_ctx); - trxcon::g_trxcon = trxcon::trxcon_inst_alloc(tall_trxcon_ctx, 0, 0); - trxcon::g_trxcon->gsmtap = nullptr; - trxcon::g_trxcon->phyif = nullptr; - trxcon::g_trxcon->phy_quirks.fbsb_extend_fns = 866; // 4 seconds, known to work. + g_trxcon = trxcon_inst_alloc(tall_trxcon_ctx, 0, 0); + g_trxcon->gsmtap = nullptr; + g_trxcon->phyif = nullptr; + g_trxcon->phy_quirks.fbsb_extend_fns = 866; // 4 seconds, known to work. convolve_init(); convert_init(); @@ -508,7 +423,7 @@ } trx->set_name_aff_sched(sched_params::thread_names::MAIN); - if (!trxcon::trxc_l1ctl_init(tall_trxcon_ctx)) { + if (!trxc_l1ctl_init(tall_trxcon_ctx)) { std::cerr << "Error initializing l1ctl, quitting.." << std::endl; return -1; } diff --git a/Transceiver52M/ms/ms_upper.h b/Transceiver52M/ms/ms_upper.h index fe20f6d..bc9bd14 100644 --- a/Transceiver52M/ms/ms_upper.h +++ b/Transceiver52M/ms/ms_upper.h @@ -24,7 +24,6 @@ #include <arpa/inet.h> #include "GSMCommon.h" -#include "radioClock.h" #include "ms.h" class upper_trx : public ms_trx { -- To view, visit https://gerrit.osmocom.org/c/osmo-trx/+/32951 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmo-trx Gerrit-Branch: master Gerrit-Change-Id: I20aef3844f7699e164fe089358aa7e2325608c85 Gerrit-Change-Number: 32951 Gerrit-PatchSet: 4 Gerrit-Owner: Hoernchen <ewild(a)sysmocom.de> Gerrit-Reviewer: Hoernchen <ewild(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: laforge <laforge(a)osmocom.org> Gerrit-Reviewer: pespin <pespin(a)sysmocom.de> Gerrit-MessageType: merged
1 0
0 0
[S] Change in osmo-trx[master]: ms: pretty tx buf class
by Hoernchen 10 Jul '23

10 Jul '23
Hoernchen has submitted this change. ( https://gerrit.osmocom.org/c/osmo-trx/+/32950 ) Change subject: ms: pretty tx buf class ...................................................................... ms: pretty tx buf class Change-Id: I96c5dd79426a52e7fff2df27bdaa3fae0c69491a --- M Transceiver52M/ms/ms_upper.cpp 1 file changed, 17 insertions(+), 4 deletions(-) Approvals: pespin: Looks good to me, but someone else must approve Jenkins Builder: Verified laforge: Looks good to me, approved diff --git a/Transceiver52M/ms/ms_upper.cpp b/Transceiver52M/ms/ms_upper.cpp index 5b213f7..cae1893 100644 --- a/Transceiver52M/ms/ms_upper.cpp +++ b/Transceiver52M/ms/ms_upper.cpp @@ -72,6 +72,13 @@ struct internal_q_tx_buf { trxcon_phyif_burst_req r; uint8_t buf[148]; + internal_q_tx_buf() = default; + internal_q_tx_buf(const internal_q_tx_buf &) = delete; + internal_q_tx_buf &operator=(const internal_q_tx_buf &) = default; + internal_q_tx_buf(const struct trxcon::trxcon_phyif_burst_req *br) : r(*br) + { + memcpy(buf, (void *)br->burst, br->burst_len); + } }; using tx_queue_t = spsc_cond<8 * 1, internal_q_tx_buf, true, false>; using cmd_queue_t = spsc_cond<8 * 1, trxcon_phyif_cmd, true, false>; @@ -415,10 +422,7 @@ return 0; OSMO_ASSERT(br->burst != 0); - trxcon::internal_q_tx_buf b; - b.r = *br; - memcpy(b.buf, (void *)br->burst, br->burst_len); - + trxcon::internal_q_tx_buf b(br); if (!g_exit_flag) trxcon::txq.spsc_push(&b); return 0; -- To view, visit https://gerrit.osmocom.org/c/osmo-trx/+/32950 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmo-trx Gerrit-Branch: master Gerrit-Change-Id: I96c5dd79426a52e7fff2df27bdaa3fae0c69491a Gerrit-Change-Number: 32950 Gerrit-PatchSet: 4 Gerrit-Owner: Hoernchen <ewild(a)sysmocom.de> Gerrit-Reviewer: Hoernchen <ewild(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: laforge <laforge(a)osmocom.org> Gerrit-Reviewer: pespin <pespin(a)sysmocom.de> Gerrit-MessageType: merged
1 0
0 0
[S] Change in osmo-trx[master]: ms: cache frequency
by Hoernchen 10 Jul '23

10 Jul '23
Hoernchen has submitted this change. ( https://gerrit.osmocom.org/c/osmo-trx/+/32949 ) Change subject: ms: cache frequency ...................................................................... ms: cache frequency Don't waste time setting the same frequency again. Change-Id: Ide9f45130955e1cc66610a50d6fc1cd79f30aca9 --- M Transceiver52M/ms/bladerf_specific.h M Transceiver52M/ms/uhd_specific.h 2 files changed, 29 insertions(+), 2 deletions(-) Approvals: pespin: Looks good to me, but someone else must approve Jenkins Builder: Verified laforge: Looks good to me, approved diff --git a/Transceiver52M/ms/bladerf_specific.h b/Transceiver52M/ms/bladerf_specific.h index ba5c7f1..3dc4777 100644 --- a/Transceiver52M/ms/bladerf_specific.h +++ b/Transceiver52M/ms/bladerf_specific.h @@ -198,6 +198,7 @@ float rxgain, txgain; static std::atomic<bool> stop_lower_threads_flag; + double rxfreq_cache, txfreq_cache; struct ms_trx_config { int tx_freq; @@ -222,7 +223,9 @@ { close_device(); } - blade_hw() : rxFullScale(2047), txFullScale(2047), rxtxdelay(-60), rxgain(30), txgain(30) + blade_hw() + : rxFullScale(2047), txFullScale(2047), rxtxdelay(-60), rxgain(30), txgain(30), rxfreq_cache(0), + txfreq_cache(0) { } @@ -320,15 +323,21 @@ bool tuneTx(double freq, size_t chan = 0) { + if (txfreq_cache == freq) + return true; msleep(15); blade_check(bladerf_set_frequency, dev, BLADERF_CHANNEL_TX(0), (bladerf_frequency)freq); + txfreq_cache = freq; msleep(15); return true; }; bool tuneRx(double freq, size_t chan = 0) { + if (rxfreq_cache == freq) + return true; msleep(15); blade_check(bladerf_set_frequency, dev, BLADERF_CHANNEL_RX(0), (bladerf_frequency)freq); + rxfreq_cache = freq; msleep(15); return true; }; diff --git a/Transceiver52M/ms/uhd_specific.h b/Transceiver52M/ms/uhd_specific.h index c8361e9..5723fd4 100644 --- a/Transceiver52M/ms/uhd_specific.h +++ b/Transceiver52M/ms/uhd_specific.h @@ -78,12 +78,13 @@ const int rxtxdelay; float rxgain, txgain; static std::atomic<bool> stop_lower_threads_flag; + double rxfreq_cache, txfreq_cache; virtual ~uhd_hw() { delete[] one_pkt_buf; } - uhd_hw() : rxFullScale(32767), txFullScale(32767 * 0.3), rxtxdelay(-67) + uhd_hw() : rxFullScale(32767), txFullScale(32767 * 0.3), rxtxdelay(-67), rxfreq_cache(0), txfreq_cache(0) { } @@ -93,15 +94,21 @@ bool tuneTx(double freq, size_t chan = 0) { + if (txfreq_cache == freq) + return true; msleep(25); dev->set_tx_freq(freq, chan); + txfreq_cache = freq; msleep(25); return true; }; bool tuneRx(double freq, size_t chan = 0) { + if (rxfreq_cache == freq) + return true; msleep(25); dev->set_rx_freq(freq, chan); + rxfreq_cache = freq; msleep(25); return true; }; -- To view, visit https://gerrit.osmocom.org/c/osmo-trx/+/32949 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmo-trx Gerrit-Branch: master Gerrit-Change-Id: Ide9f45130955e1cc66610a50d6fc1cd79f30aca9 Gerrit-Change-Number: 32949 Gerrit-PatchSet: 4 Gerrit-Owner: Hoernchen <ewild(a)sysmocom.de> Gerrit-Reviewer: Hoernchen <ewild(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: laforge <laforge(a)osmocom.org> Gerrit-Reviewer: pespin <pespin(a)sysmocom.de> Gerrit-MessageType: merged
1 0
0 0
  • ← Newer
  • 1
  • ...
  • 220
  • 221
  • 222
  • 223
  • 224
  • 225
  • 226
  • ...
  • 306
  • Older →

HyperKitty Powered by HyperKitty version 1.3.12.