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

April 2025

  • 1 participants
  • 1186 discussions
[S] Change in osmocom-bb[master]: trx_toolkit/transceiver: Switch Transceiver ._rx_freq ._tx_freq from ...
by kirr 17 Apr '25

17 Apr '25
kirr has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmocom-bb/+/40084?usp=email ) Change subject: trx_toolkit/transceiver: Switch Transceiver ._rx_freq ._tx_freq from object to int ...................................................................... trx_toolkit/transceiver: Switch Transceiver ._rx_freq ._tx_freq from object to int This are integer fields, assigning C-level type avoids py-related overhead on access and arithmetics. This fields are frequently used by BurstForwarder when checking if src and dst trx frequencies match each other. Change-Id: Ie9fb076837afe8921b7c5f5022bfad41f7a30e48 --- M src/target/trx_toolkit/transceiver.pxd M src/target/trx_toolkit/transceiver.pyx 2 files changed, 9 insertions(+), 9 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmocom-bb refs/changes/84/40084/1 diff --git a/src/target/trx_toolkit/transceiver.pxd b/src/target/trx_toolkit/transceiver.pxd index 562cb34..fa025bb 100644 --- a/src/target/trx_toolkit/transceiver.pxd +++ b/src/target/trx_toolkit/transceiver.pxd @@ -26,8 +26,8 @@ object child_trx_list # TRXList # Actual RX / TX frequencies - object _rx_freq # None if unset - object _tx_freq # None if unset + int _rx_freq # -1 if unset + int _tx_freq # -1 if unset bint rf_muted @@ -47,8 +47,8 @@ list[TxMsg] _tx_queue - cdef get_rx_freq(self, int64_t fn) - cpdef get_tx_freq(self, int64_t fn) + cdef int get_rx_freq(self, int64_t fn) except -1 + cpdef int get_tx_freq(self, int64_t fn) except -1 cdef TxMsg recv_data_msg(self) cdef send_data_msg(self, RxMsg msg) diff --git a/src/target/trx_toolkit/transceiver.pyx b/src/target/trx_toolkit/transceiver.pyx index b28dee8..901a637 100644 --- a/src/target/trx_toolkit/transceiver.pyx +++ b/src/target/trx_toolkit/transceiver.pyx @@ -143,8 +143,8 @@ """ def __cinit__(self): - self._rx_freq = None - self._tx_freq = None + self._rx_freq = -1 + self._tx_freq = -1 self.rf_muted = False self.running = False @@ -206,14 +206,14 @@ @property def ready(self): # Make sure that either both Rx/Tx frequencies are set - if self._rx_freq is None or self._tx_freq is None: + if self._rx_freq < 0 or self._tx_freq < 0: # ... or frequency hopping is in use if self.fh is None: return False return True - cdef get_rx_freq(self, int64_t fn): + cdef int get_rx_freq(self, int64_t fn) except -1: if self.fh is None: return self._rx_freq @@ -221,7 +221,7 @@ (rx_freq, _) = self.fh.resolve(fn) return rx_freq - cpdef get_tx_freq(self, int64_t fn): + cpdef int get_tx_freq(self, int64_t fn) except -1: if self.fh is None: return self._tx_freq -- To view, visit https://gerrit.osmocom.org/c/osmocom-bb/+/40084?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email Gerrit-MessageType: newchange Gerrit-Project: osmocom-bb Gerrit-Branch: master Gerrit-Change-Id: Ie9fb076837afe8921b7c5f5022bfad41f7a30e48 Gerrit-Change-Number: 40084 Gerrit-PatchSet: 1 Gerrit-Owner: kirr <kirr(a)nexedi.com> Gerrit-CC: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-CC: osmith <osmith(a)sysmocom.de> Gerrit-CC: pespin <pespin(a)sysmocom.de>
1 0
0 0
[M] Change in osmocom-bb[master]: trx_toolkit/data_msg: Switch RxMsg .rssi .toa256 .tsc_set .tsc .ci fr...
by kirr 17 Apr '25

17 Apr '25
kirr has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmocom-bb/+/40083?usp=email ) Change subject: trx_toolkit/data_msg: Switch RxMsg .rssi .toa256 .tsc_set .tsc .ci from object to int ...................................................................... trx_toolkit/data_msg: Switch RxMsg .rssi .toa256 .tsc_set .tsc .ci from object to int This are integer fields, assigning C-level type avoids py-related overhead on access and arithmetics. Change-Id: I66abcf26896ab83f94f144941ea2dd64f7a4821f --- M src/target/trx_toolkit/data_msg.pxd M src/target/trx_toolkit/data_msg.pyx M src/target/trx_toolkit/test_data_msg.py 3 files changed, 28 insertions(+), 25 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmocom-bb refs/changes/83/40083/1 diff --git a/src/target/trx_toolkit/data_msg.pxd b/src/target/trx_toolkit/data_msg.pxd index e5c605e..e0acbda 100644 --- a/src/target/trx_toolkit/data_msg.pxd +++ b/src/target/trx_toolkit/data_msg.pxd @@ -70,15 +70,15 @@ cdef class RxMsg(Msg): cdef public array.array burst # array.array[b] | None - cdef public object rssi # int | None - cdef public object toa256 # int | None + cdef public int rssi # RSSI_UNSET - unset + cdef public int toa256 # TOA256_UNSET - unset # Version 0x01 specific cdef public Modulation mod_type # Modulation | None - cdef public object tsc_set # int | None - cdef public object tsc # int | None - cdef public object ci # int | None + cdef public int tsc_set # -1 if unset + cdef public int tsc # -1 if unset + cdef public int ci # CI_UNSET if unset cdef _validate_burst_v0(self) diff --git a/src/target/trx_toolkit/data_msg.pyx b/src/target/trx_toolkit/data_msg.pyx index 1d40726..1e786c1 100644 --- a/src/target/trx_toolkit/data_msg.pyx +++ b/src/target/trx_toolkit/data_msg.pyx @@ -453,10 +453,12 @@ # rxlev2dbm(0..63) gives us [-110..-47], plus -10 dbm for noise cdef int RSSI_MIN = -120 cdef int RSSI_MAX = -47 +cdef int RSSI_UNSET = 0 # Min and max values of int16_t cdef int TOA256_MIN = -32768 -cdef int TOA256_MAX = 32767 +cdef int TOA256_MAX = 32767-1 +cdef int TOA256_UNSET = TOA256_MAX+1 # TSC (Training Sequence Code) range is [0, 7] cdef int TSC_MAX = 7 @@ -464,6 +466,7 @@ # C/I range (in centiBels) cdef int CI_MIN = -1280 cdef int CI_MAX = 1280 +cdef int CI_UNSET = 0x7fff # IDLE frame / nope detection indicator cdef int NOPE_IND = (1 << 7) @@ -474,16 +477,16 @@ ''' Rx (TRX -> L1) message coding API. ''' def __cinit__(self): - self.rssi = None - self.toa256 = None + self.rssi = RSSI_UNSET + self.toa256 = TOA256_UNSET # Version 0x01 specific (default values) self.mod_type = ModGMSK self.nope_ind = False - self.tsc_set = None - self.tsc = None - self.ci = None + self.tsc_set = -1 + self.tsc = -1 + self.ci = CI_UNSET cdef int HDR_LEN(self) except -1: ''' Calculate header length depending on its version. ''' @@ -541,13 +544,13 @@ # Validate common fields Msg._validate(self) - if self.rssi is None: + if self.rssi == RSSI_UNSET: raise ValueError("RSSI is not set") if self.rssi < RSSI_MIN or self.rssi > RSSI_MAX: raise ValueError("RSSI %d is out of range" % self.rssi) - if self.toa256 is None: + if self.toa256 == TOA256_UNSET: raise ValueError("ToA256 is not set") if self.toa256 < TOA256_MIN or self.toa256 > TOA256_MAX: @@ -558,7 +561,7 @@ if type(self.mod_type) is not Modulation: raise ValueError("Unknown Rx modulation type") - if self.tsc_set is None: + if self.tsc_set == -1: raise ValueError("TSC set is not set") if self.mod_type is ModGMSK: @@ -568,7 +571,7 @@ if not (0 <= self.tsc_set < 2): raise ValueError("TSC set %d is out of range" % self.tsc_set) - if self.tsc is None: + if self.tsc == -1: raise ValueError("TSC is not set") if not (0 <= self.tsc <= TSC_MAX): @@ -576,7 +579,7 @@ # Version specific parameters (also present in NOPE.ind) if self.ver >= 0x01: - if self.ci is None: + if self.ci == CI_UNSET: raise ValueError("C/I is not set") if self.ci < CI_MIN or self.ci > CI_MAX: @@ -630,21 +633,21 @@ # Describe the common part result = Msg.desc_hdr(self) - if self.rssi is not None: + if self.rssi != RSSI_UNSET: result += ("rssi=%d " % self.rssi) - if self.toa256 is not None: + if self.toa256 != TOA256_UNSET: result += ("toa256=%d " % self.toa256) if self.ver >= 0x01: if not self.nope_ind: if self.mod_type is not None: result += ("%s " % self.mod_type) - if self.tsc_set is not None: + if self.tsc_set != -1: result += ("set=%u " % self.tsc_set) - if self.tsc is not None: + if self.tsc != -1: result += ("tsc=%u " % self.tsc) - if self.ci is not None: + if self.ci != CI_UNSET: result += ("C/I=%d cB " % self.ci) else: result += "(IDLE / NOPE IND) " @@ -676,8 +679,8 @@ self.nope_ind = (mts & NOPE_IND) > 0 if self.nope_ind: self.mod_type = None - self.tsc_set = None - self.tsc = None + self.tsc_set = -1 + self.tsc = -1 return 0 # TSC: . . . . . X X X diff --git a/src/target/trx_toolkit/test_data_msg.py b/src/target/trx_toolkit/test_data_msg.py index db9a998..8d1d014 100644 --- a/src/target/trx_toolkit/test_data_msg.py +++ b/src/target/trx_toolkit/test_data_msg.py @@ -102,8 +102,8 @@ else: msg.nope_ind = True msg.mod_type = None - msg.tsc_set = None - msg.tsc = None + msg.tsc_set = -1 + msg.tsc = -1 # Encode a given message to bytes msg_enc = msg.gen_msg(legacy) -- To view, visit https://gerrit.osmocom.org/c/osmocom-bb/+/40083?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email Gerrit-MessageType: newchange Gerrit-Project: osmocom-bb Gerrit-Branch: master Gerrit-Change-Id: I66abcf26896ab83f94f144941ea2dd64f7a4821f Gerrit-Change-Number: 40083 Gerrit-PatchSet: 1 Gerrit-Owner: kirr <kirr(a)nexedi.com> Gerrit-CC: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-CC: osmith <osmith(a)sysmocom.de> Gerrit-CC: pespin <pespin(a)sysmocom.de>
1 0
0 0
[S] Change in osmocom-bb[master]: trx_toolkit/data_msg: Disable cyclic GC support for RxMsg
by kirr 17 Apr '25

17 Apr '25
kirr has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmocom-bb/+/40085?usp=email ) Change subject: trx_toolkit/data_msg: Disable cyclic GC support for RxMsg ...................................................................... trx_toolkit/data_msg: Disable cyclic GC support for RxMsg Checking profiling turned out that there are frequent PyObject_GC_Track/PyObject_GC_UnTrack for RxMsg because BurstForwarder creates RxMsg often: to forward on received TxMsg burst to N destinations - N RxMsg instances are currently created. Investigating generated data_msg.c code shows that neither Msg, nor TxMsg have Py_TPFLAGS_HAVE_GC flag set, but RxMsg does have it set and does have generated .tp_traverse and .tp_clear routines. Investigating a bit more turns our that if we exclude `array.array burst` from RxMsg definition, all those cyclic-GC related things go away from generated code. So somehow Cython thinks that array.array can have a back pointer to RxMsg and emits GC supporting code due to that. But that is not possible to have a back-pointer from array.array to RxMsg: the only object that array.array references is arraydescr object: https://github.com/cython/cython/blob/e22e99e9/Cython/Includes/cpython/arra… which is plain C struct inside and does not reference other objects at all: https://github.com/cython/cython/blob/e22e99e9/Cython/Includes/cpython/arra… -> So disable cyclic-GC support for RxMsg to avoid associated overhead. Do so for TxMsg and Msg explicitly for symmetry as well. Change-Id: I2c592cec4931db04c29cadfeb97ce5325295d862 --- M src/target/trx_toolkit/data_msg.pxd M src/target/trx_toolkit/data_msg.pyx 2 files changed, 8 insertions(+), 2 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmocom-bb refs/changes/85/40085/1 diff --git a/src/target/trx_toolkit/data_msg.pxd b/src/target/trx_toolkit/data_msg.pxd index e0acbda..2eb6ed3 100644 --- a/src/target/trx_toolkit/data_msg.pxd +++ b/src/target/trx_toolkit/data_msg.pxd @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # cython: language_level=3 -from cython cimport final +from cython cimport final, no_gc # NOTE no_gc means "no cyclic gc", acyclic gc support is still there from cpython cimport array from libc.stdint cimport int8_t, int64_t, uint8_t @@ -19,6 +19,7 @@ cdef Modulation ModGMSK +@no_gc cdef class Msg: cdef readonly int ver cdef readonly int64_t fn # -1 if not valid @@ -58,6 +59,7 @@ @final +@no_gc cdef class TxMsg(Msg): cdef public bytearray burst # | None cdef readonly int pwr # -1 if unset @@ -67,6 +69,7 @@ @final +@no_gc # NOTE by default cython thinks that .burst might participate in cycle cdef class RxMsg(Msg): cdef public array.array burst # array.array[b] | None diff --git a/src/target/trx_toolkit/data_msg.pyx b/src/target/trx_toolkit/data_msg.pyx index 1e786c1..304dbdb 100644 --- a/src/target/trx_toolkit/data_msg.pyx +++ b/src/target/trx_toolkit/data_msg.pyx @@ -19,7 +19,7 @@ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -from cython cimport final +from cython cimport final, no_gc from libc.stdint cimport int16_t, int64_t, uint16_t, uint32_t from cpython cimport array @@ -79,6 +79,7 @@ cdef int KNOWN_VERSION_MAX = 1 # 0, 1 +@no_gc cdef class Msg: ''' TRXD (DATA) message coding API (common part). ''' @@ -318,6 +319,7 @@ cdef int PWR_MAX = 0xff @final +@no_gc cdef class TxMsg(Msg): ''' Tx (L1 -> TRX) message coding API. ''' @@ -473,6 +475,7 @@ @final +@no_gc cdef class RxMsg(Msg): ''' Rx (TRX -> L1) message coding API. ''' -- To view, visit https://gerrit.osmocom.org/c/osmocom-bb/+/40085?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email Gerrit-MessageType: newchange Gerrit-Project: osmocom-bb Gerrit-Branch: master Gerrit-Change-Id: I2c592cec4931db04c29cadfeb97ce5325295d862 Gerrit-Change-Number: 40085 Gerrit-PatchSet: 1 Gerrit-Owner: kirr <kirr(a)nexedi.com> Gerrit-CC: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-CC: osmith <osmith(a)sysmocom.de> Gerrit-CC: pespin <pespin(a)sysmocom.de>
1 0
0 0
[S] Change in osmocom-bb[master]: trx_toolkit/burst_fwd: Reuse RxMsg object
by kirr 17 Apr '25

17 Apr '25
kirr has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmocom-bb/+/40086?usp=email ) Change subject: trx_toolkit/burst_fwd: Reuse RxMsg object ...................................................................... trx_toolkit/burst_fwd: Reuse RxMsg object To forward each received TxMsg BurstForwarder currently creates RxMsg via TxMsg.trans(), then sends created RxMsg to destination trx. Creating RxMsg and convertion TxMsg .burst to RxMsg .burst all show in the profile. -> Optimize the first part of this story: create RxMsg only once and reuse it, by resetting, each time we need to forward a message. This is safe to do as that RxMsg is created by BurstForwarder internally and is not exposed to any upper layer at all. In other words it has strictly controlled lifetime limited by the forwarding activity. Change-Id: Ie0690da0f901f4f19a7e4cf048bdc244a24235b0 --- M src/target/trx_toolkit/burst_fwd.pxd M src/target/trx_toolkit/burst_fwd.pyx M src/target/trx_toolkit/data_msg.pxd M src/target/trx_toolkit/data_msg.pyx 4 files changed, 24 insertions(+), 5 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmocom-bb refs/changes/86/40086/1 diff --git a/src/target/trx_toolkit/burst_fwd.pxd b/src/target/trx_toolkit/burst_fwd.pxd index 486faa1..87ae95d 100644 --- a/src/target/trx_toolkit/burst_fwd.pxd +++ b/src/target/trx_toolkit/burst_fwd.pxd @@ -1,9 +1,10 @@ # cython: language_level=3 -from data_msg cimport TxMsg +from data_msg cimport TxMsg, RxMsg from transceiver cimport Transceiver cdef class BurstForwarder: cdef list[Transceiver] trx_list + cdef RxMsg tx_msg # reused RxMsg to avoid object allocation at every forward_msg cdef forward_msg(self, Transceiver src_trx, TxMsg rx_msg) diff --git a/src/target/trx_toolkit/burst_fwd.pyx b/src/target/trx_toolkit/burst_fwd.pyx index d13f784..db910ad 100644 --- a/src/target/trx_toolkit/burst_fwd.pyx +++ b/src/target/trx_toolkit/burst_fwd.pyx @@ -42,6 +42,7 @@ def __cinit__(self, list trx_list): self.trx_list = trx_list + self.tx_msg = RxMsg() cdef forward_msg(self, Transceiver src_trx, TxMsg rx_msg): # Originating Transceiver may use frequency hopping, @@ -66,5 +67,13 @@ continue # Transform from TxMsg to RxMsg and forward - tx_msg = rx_msg.trans(ver = trx.data_if._hdr_ver) + tx_msg = self.tx_msg # reuse tx_msg object instead of allocating it each time + tx_msg._reset() + tx_msg.fn = rx_msg.fn + tx_msg.tn = rx_msg.tn + tx_msg.ver = trx.data_if._hdr_ver + if rx_msg.burst is not None: + tx_msg.burst = RxMsg._ubit2sbit(rx_msg.burst) + tx_msg.nope_ind = (rx_msg.burst is None) + trx.handle_data_msg(src_trx, rx_msg, tx_msg) diff --git a/src/target/trx_toolkit/data_msg.pxd b/src/target/trx_toolkit/data_msg.pxd index 2eb6ed3..2ddd248 100644 --- a/src/target/trx_toolkit/data_msg.pxd +++ b/src/target/trx_toolkit/data_msg.pxd @@ -31,6 +31,7 @@ cdef int CHDR_LEN() noexcept cdef int HDR_LEN(self) except -1 + cdef _reset(self) cdef append_hdr_to(self, bytearray buf) cdef append_burst_to(self, bytearray buf) cdef parse_hdr(self, bytearray msg) diff --git a/src/target/trx_toolkit/data_msg.pyx b/src/target/trx_toolkit/data_msg.pyx index 304dbdb..07b3d38 100644 --- a/src/target/trx_toolkit/data_msg.pyx +++ b/src/target/trx_toolkit/data_msg.pyx @@ -87,10 +87,15 @@ CHDR_VERSION_MAX = 0b1111 KNOWN_VERSIONS = tuple(range(KNOWN_VERSION_MAX+1)) - def __cinit__(self, int64_t fn = -1, int64_t tn = -1, int ver = 0): + def __init__(self, int64_t fn = -1, int64_t tn = -1, int ver = 0): + self._reset() self.ver = ver self.fn = fn self.tn = tn + cdef _reset(self): + self.ver = 0 + self.fn = -1 + self.tn = -1 self.nope_ind = False @staticmethod @@ -323,7 +328,8 @@ cdef class TxMsg(Msg): ''' Tx (L1 -> TRX) message coding API. ''' - def __cinit__(self): + cdef _reset(self): + Msg._reset(self) self.burst = None self.pwr = -1 @@ -479,7 +485,9 @@ cdef class RxMsg(Msg): ''' Rx (TRX -> L1) message coding API. ''' - def __cinit__(self): + cdef _reset(self): + Msg._reset(self) + self.burst = None self.rssi = RSSI_UNSET self.toa256 = TOA256_UNSET -- To view, visit https://gerrit.osmocom.org/c/osmocom-bb/+/40086?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email Gerrit-MessageType: newchange Gerrit-Project: osmocom-bb Gerrit-Branch: master Gerrit-Change-Id: Ie0690da0f901f4f19a7e4cf048bdc244a24235b0 Gerrit-Change-Number: 40086 Gerrit-PatchSet: 1 Gerrit-Owner: kirr <kirr(a)nexedi.com> Gerrit-CC: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-CC: osmith <osmith(a)sysmocom.de> Gerrit-CC: pespin <pespin(a)sysmocom.de>
1 0
0 0
[XS] Change in osmocom-bb[master]: trx_toolkit/data_msg: Remove burst from *Msg constructor arguments
by kirr 17 Apr '25

17 Apr '25
kirr has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmocom-bb/+/40074?usp=email ) Change subject: trx_toolkit/data_msg: Remove burst from *Msg constructor arguments ...................................................................... trx_toolkit/data_msg: Remove burst from *Msg constructor arguments Grepping through whole codebase does not reveal any place which invokes *Msg(burst=...). Sonn we will add type to burst and it will be different types for TxMsg and RxMsg. Adjust *Msg signature not to accept any burst argument as a preparatory step for that. Change-Id: I189956fdc0591ec64c09d4c7e1e3659dfc630fc0 --- M src/target/trx_toolkit/data_msg.pyx 1 file changed, 2 insertions(+), 2 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmocom-bb refs/changes/74/40074/1 diff --git a/src/target/trx_toolkit/data_msg.pyx b/src/target/trx_toolkit/data_msg.pyx index ccbdd71..4b59fce 100644 --- a/src/target/trx_toolkit/data_msg.pyx +++ b/src/target/trx_toolkit/data_msg.pyx @@ -77,8 +77,8 @@ CHDR_VERSION_MAX = 0b1111 KNOWN_VERSIONS = tuple(range(KNOWN_VERSION_MAX+1)) - def __init__(self, fn = None, tn = None, burst = None, ver = 0): - self.burst = burst # bytes|bytearray for ubit, array[b] for sbit, array[B] for usbit + def __init__(self, fn = None, tn = None, ver = 0): + self.burst = None # bytes|bytearray for ubit, array[b] for sbit, array[B] for usbit self.ver = ver self.fn = fn self.tn = tn -- To view, visit https://gerrit.osmocom.org/c/osmocom-bb/+/40074?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email Gerrit-MessageType: newchange Gerrit-Project: osmocom-bb Gerrit-Branch: master Gerrit-Change-Id: I189956fdc0591ec64c09d4c7e1e3659dfc630fc0 Gerrit-Change-Number: 40074 Gerrit-PatchSet: 1 Gerrit-Owner: kirr <kirr(a)nexedi.com> Gerrit-CC: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-CC: osmith <osmith(a)sysmocom.de> Gerrit-CC: pespin <pespin(a)sysmocom.de>
1 0
0 0
[M] Change in osmocom-bb[master]: trx_toolkit/data_msg: Optimize bit conversions
by kirr 17 Apr '25

17 Apr '25
kirr has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmocom-bb/+/40076?usp=email ) Change subject: trx_toolkit/data_msg: Optimize bit conversions ...................................................................... trx_toolkit/data_msg: Optimize bit conversions - implement convertions in C (via pyx) directly - add in-place versions - use those in-place versions as needed Change-Id: Ib8237a277f97292cd99dfda44972372d370f0ada --- M src/target/trx_toolkit/data_msg.pxd M src/target/trx_toolkit/data_msg.pyx M src/target/trx_toolkit/test_data_msg.py 3 files changed, 97 insertions(+), 25 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmocom-bb refs/changes/76/40076/1 diff --git a/src/target/trx_toolkit/data_msg.pxd b/src/target/trx_toolkit/data_msg.pxd index cbdca4b..2823b82 100644 --- a/src/target/trx_toolkit/data_msg.pxd +++ b/src/target/trx_toolkit/data_msg.pxd @@ -3,7 +3,7 @@ from cython cimport final from cpython cimport array -from libc.stdint cimport uint8_t +from libc.stdint cimport int8_t, uint8_t cdef class Modulation: cdef int coding # Coding in TRXD header @@ -36,6 +36,24 @@ cdef parse_burst(self, burst) cdef _validate(self) + @staticmethod + cdef void __usbit2sbit(const uint8_t *usbits, Py_ssize_t l, int8_t *sbits) noexcept + @staticmethod + cdef void __sbit2usbit(const int8_t *sbits, Py_ssize_t l, uint8_t *usbits) noexcept + @staticmethod + cdef void __sbit2ubit(const int8_t *sbits, Py_ssize_t l, uint8_t *ubits) noexcept + @staticmethod + cdef void __ubit2sbit(const uint8_t *ubits, Py_ssize_t l, int8_t *sbits) noexcept + + @staticmethod + cdef array.array[int8_t] _usbit2sbit(const uint8_t[::1] usbits) + @staticmethod + cdef array.array[uint8_t] _sbit2usbit(const int8_t[::1] sbits) + @staticmethod + cdef array.array[uint8_t] _sbit2ubit(const int8_t[::1] sbits) + @staticmethod + cdef array.array[int8_t] _ubit2sbit(const uint8_t[::1] ubits) + @final cdef class TxMsg(Msg): diff --git a/src/target/trx_toolkit/data_msg.pyx b/src/target/trx_toolkit/data_msg.pyx index 02194ba..5929b47 100644 --- a/src/target/trx_toolkit/data_msg.pyx +++ b/src/target/trx_toolkit/data_msg.pyx @@ -1,5 +1,6 @@ # -*- coding: utf-8 -*- # cython: language_level=3 +# cython: initializedcheck=False, wraparound=False, boundscheck=False, infer_types=True # TRX Toolkit # DATA interface message definitions and helpers @@ -20,22 +21,25 @@ from cython cimport final +from cpython cimport array +cdef array.array _Bempty = array.array('B', []) +cdef array.array _bempty = array.array('b', []) + +from cpython.bytearray cimport PyByteArray_FromStringAndSize +from cpython.bytearray cimport PyByteArray_AS_STRING, PyByteArray_GET_SIZE +from xpy cimport PyByteArray_Resize + import random import struct import abc from typing import List -from array import array import gsm_shared cdef int GMSK_BURST_LEN = gsm_shared.GMSK_BURST_LEN cdef int EDGE_BURST_LEN = gsm_shared.EDGE_BURST_LEN cdef int GSM_HYPERFRAME = gsm_shared.GSM_HYPERFRAME -# _bu2s converts unsigned byte to signed. -def _bu2s(x): - return struct.unpack('b', struct.pack('B', x))[0] - cdef list[Modulation] _mod_registry = [] cdef class Modulation: def __cinit__(self, int coding, int bl): @@ -145,29 +149,74 @@ return result + @staticmethod - def usbit2sbit(bits): # array[B] -> array[b] + cdef array.array[int8_t] _usbit2sbit(const uint8_t[::1] usbits): # array[B] -> array[b] ''' Convert unsigned soft-bits {254..0} to soft-bits {-127..127}. ''' - return array('b', bits.tobytes().translate(Msg._tab_usbit2sbit)) - _tab_usbit2sbit = array('b', [-127 if (b == 0xff) else 127 - b for b in range(0x100)]) + l = len(usbits) + cdef array.array[int8_t] sbits = array.clone(_bempty, l, zero=False) + Msg.__usbit2sbit(&usbits[0], l, &sbits[0]) + return sbits @staticmethod - def sbit2usbit(bits): # array[b] -> array[B] + cdef array.array[uint8_t] _sbit2usbit(const int8_t[::1] sbits): # array[b] -> array[B] ''' Convert soft-bits {-127..127} to unsigned soft-bits {254..0}. ''' - return array('B', bits.tobytes().translate(Msg._tab_sbit2usbit)) - _tab_sbit2usbit = array('B', [127 - _bu2s(b) for b in range(0x100)]) + l = len(sbits) + cdef array.array[uint8_t] usbits = array.clone(_Bempty, l, zero=False) + Msg.__sbit2usbit(&sbits[0], l, &usbits[0]) + return usbits @staticmethod - def sbit2ubit(bits): # array[b] -> bytearray + cdef array.array[uint8_t] _sbit2ubit(const int8_t[::1] sbits): # array[b] -> array[B] ''' Convert soft-bits {-127..127} to bits {1..0}. ''' - return bytearray(bits).translate(Msg._tab_sbit2ubit) - _tab_sbit2ubit = array('B', [int(_bu2s(b) < 0) for b in range(0x100)]) + l = len(sbits) + cdef array.array[uint8_t] ubits = array.clone(_Bempty, l, zero=False) + Msg.__sbit2ubit(&sbits[0], l, &ubits[0]) + return ubits @staticmethod - def ubit2sbit(bits: bytearray): # -> array[b] + cdef array.array[int8_t] _ubit2sbit(const uint8_t[::1] ubits): # array[B] -> array[b] ''' Convert bits {1..0} to soft-bits {-127..127}. ''' - return array('b', bits.translate(Msg._tab_ubit2sbit)) - _tab_ubit2sbit = array('b', [-127 if b else 127 for b in range(0x100)]) + l = len(ubits) + cdef array.array[int8_t] sbits = array.clone(_bempty, l, zero=False) + Msg.__ubit2sbit(&ubits[0], l, &sbits[0]) + return sbits + + # inplace versions of Xbit2Ybit + @staticmethod + cdef void __usbit2sbit(const uint8_t *usbits, Py_ssize_t l, int8_t *sbits) noexcept: + for i in range(l): + b = usbits[i] + sbits[i] = -127 if (b == 0xff) else 127 - b + + @staticmethod + cdef void __sbit2usbit(const int8_t *sbits, Py_ssize_t l, uint8_t *usbits) noexcept: + for i in range(l): + b = sbits[i] + usbits[i] = 127 - b + + @staticmethod + cdef void __sbit2ubit(const int8_t *sbits, Py_ssize_t l, uint8_t *ubits) noexcept: + for i in range(l): + b = sbits[i] + ubits[i] = 1 if b < 0 else 0 + + @staticmethod + cdef void __ubit2sbit(const uint8_t *ubits, Py_ssize_t l, int8_t *sbits) noexcept: + for i in range(l): + b = ubits[i] + sbits[i] = -127 if b else 127 + + + # for tests (`@staticmethod cpdef` is not supported: github.com/cython/cython/issues/3327) + @staticmethod + def usbit2sbit(usbits): return Msg._usbit2sbit(usbits) + @staticmethod + def sbit2usbit(sbits): return Msg._sbit2usbit(sbits) + @staticmethod + def sbit2ubit(sbits): return Msg._sbit2ubit(sbits) + @staticmethod + def ubit2sbit(ubits): return Msg._ubit2sbit(ubits) cdef _validate(self): @@ -370,7 +419,7 @@ # Convert burst bits if self.burst is not None: - msg.burst = self.ubit2sbit(self.burst) + msg.burst = Msg._ubit2sbit(self.burst) else: msg.nope_ind = True @@ -659,7 +708,10 @@ ''' Generate message specific burst appending it to buf. ''' # Convert soft-bits to unsigned soft-bits - buf.extend( self.sbit2usbit(self.burst) ) # XXX copies; can probably remove them with numpy + l = PyByteArray_GET_SIZE(buf) + PyByteArray_Resize(buf, l+len(self.burst)) + Msg.__sbit2usbit(<int8_t*>self.burst.data.as_chars, len(self.burst), + <uint8_t*>&PyByteArray_AS_STRING(buf)[l]) cdef _parse_burst_v0(self, burst): ''' Parse message specific burst for header version 0. ''' @@ -680,13 +732,13 @@ cdef parse_burst(self, burst): ''' Parse message specific burst. ''' - burst = array('B', burst) + burst = array.array('B', burst) if self.ver == 0x00: burst = self._parse_burst_v0(burst) # Convert unsigned soft-bits to soft-bits - self.burst = self.usbit2sbit(burst) + self.burst = Msg._usbit2sbit(burst) def rand_burst(self, length = None): ''' Generate a random message specific burst. ''' @@ -694,7 +746,7 @@ if length is None: length = self.mod_type.bl - self.burst = array('b', [random.randint(-127, 127) for _ in range(length)]) + self.burst = array.array('b', [random.randint(-127, 127) for _ in range(length)]) def trans(self, ver = None): ''' Transform this message to TxMsg. ''' @@ -705,6 +757,8 @@ # Convert burst bits if self.burst is not None: - msg.burst = self.sbit2ubit(self.burst) + msg.burst = PyByteArray_FromStringAndSize(NULL, len(self.burst)) + Msg.__sbit2ubit(<int8_t*>&self.burst.data.as_chars[0], len(self.burst), + <uint8_t*>PyByteArray_AS_STRING(msg.burst)) return msg diff --git a/src/target/trx_toolkit/test_data_msg.py b/src/target/trx_toolkit/test_data_msg.py index 13a64a6..e6cb906 100644 --- a/src/target/trx_toolkit/test_data_msg.py +++ b/src/target/trx_toolkit/test_data_msg.py @@ -148,7 +148,7 @@ # Test both sbit2ubit() and ubit2sbit() ubits = Msg.sbit2ubit(sbits_ref) - self.assertEqual(ubits, bytearray([1] * 127 + [0] * 128)) + self.assertEqual(ubits, array('B', [1] * 127 + [0] * 128)) sbits = Msg.ubit2sbit(ubits) self.assertEqual(sbits, array('b', [-127] * 127 + [127] * 128)) -- To view, visit https://gerrit.osmocom.org/c/osmocom-bb/+/40076?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email Gerrit-MessageType: newchange Gerrit-Project: osmocom-bb Gerrit-Branch: master Gerrit-Change-Id: Ib8237a277f97292cd99dfda44972372d370f0ada Gerrit-Change-Number: 40076 Gerrit-PatchSet: 1 Gerrit-Owner: kirr <kirr(a)nexedi.com> Gerrit-CC: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-CC: osmith <osmith(a)sysmocom.de> Gerrit-CC: pespin <pespin(a)sysmocom.de>
1 0
0 0
[M] Change in osmocom-bb[master]: trx_toolkit/data_msg: Switch *Msg to cdef classes
by kirr 17 Apr '25

17 Apr '25
kirr has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmocom-bb/+/40075?usp=email ) Change subject: trx_toolkit/data_msg: Switch *Msg to cdef classes ...................................................................... trx_toolkit/data_msg: Switch *Msg to cdef classes - Put fields into the object struct; fields are now accessed directly via that C-level struct instead of via __dict__ lookup - Type .burst explicitly: it is bytearray for TxMsg and array.array[int8_t] for RxMsg(*) - switch to invoke several internal *Msg functions via C-level where appropriate. - cimport instead of import *Msg at the users - type-annotate users appropriately - switch Modulation .bl and .coding to be cdef-only, as the only users of those fields are *Msg classes, and they now access Modulation via C. (*) it was also considered to use either array.array[uint8_t] or uint8_t[::1] memoryview for tx burst. Unfortunately that is not good for performance as converting explicit types, e.g. bytearray, to memoryview on a call is relatively costly, and also because cython generates suboptimal code with lots of overhead when passing/returning arrays. This way we use concrete type bytearray for tx bursts which does not have those problems. For rx burst, we cannot use bytearray because existing semantic requires rx_burst[i] to return signed int8_t, which bytearray does not provide. So we use the least bad array.array[int8_t] for that. Change-Id: Icb63ec0a0d899e352400915bb163a3e2f354c280 --- M src/target/trx_toolkit/_fake_trx.pyx M src/target/trx_toolkit/burst_fwd.pxd M src/target/trx_toolkit/burst_fwd.pyx M src/target/trx_toolkit/data_msg.pxd M src/target/trx_toolkit/data_msg.pyx M src/target/trx_toolkit/transceiver.pxd M src/target/trx_toolkit/transceiver.pyx 7 files changed, 142 insertions(+), 74 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmocom-bb refs/changes/75/40075/1 diff --git a/src/target/trx_toolkit/_fake_trx.pyx b/src/target/trx_toolkit/_fake_trx.pyx index fd12863..5c55486 100644 --- a/src/target/trx_toolkit/_fake_trx.pyx +++ b/src/target/trx_toolkit/_fake_trx.pyx @@ -24,7 +24,7 @@ from burst_fwd cimport BurstForwarder from _clck_gen cimport CLCKGen from transceiver cimport Transceiver -from data_msg cimport Modulation, ModGMSK +from data_msg cimport Modulation, ModGMSK, TxMsg, RxMsg from udp_link cimport _raise_oserr import gsm_shared cdef object TrainingSeqGMSK = gsm_shared.TrainingSeqGMSK @@ -198,7 +198,7 @@ return False - cdef _handle_data_msg_v1(self, src_msg, msg): + cdef _handle_data_msg_v1(self, TxMsg src_msg, RxMsg msg): # C/I (Carrier-to-Interference ratio) msg.ci = self.ci() @@ -218,7 +218,7 @@ # Takes (partially initialized) TRXD Rx message, # simulates RF path parameters (such as RSSI), # and sends towards the L1 - cdef handle_data_msg(self, Transceiver src_trx, src_msg, msg): + cdef handle_data_msg(self, Transceiver src_trx, TxMsg src_msg, RxMsg msg): if self.rf_muted: msg.nope_ind = True elif not msg.nope_ind: diff --git a/src/target/trx_toolkit/burst_fwd.pxd b/src/target/trx_toolkit/burst_fwd.pxd index 43b788c..486faa1 100644 --- a/src/target/trx_toolkit/burst_fwd.pxd +++ b/src/target/trx_toolkit/burst_fwd.pxd @@ -1,8 +1,9 @@ # cython: language_level=3 +from data_msg cimport TxMsg from transceiver cimport Transceiver cdef class BurstForwarder: cdef list[Transceiver] trx_list - cdef forward_msg(self, Transceiver src_trx, rx_msg) + cdef forward_msg(self, Transceiver src_trx, TxMsg rx_msg) diff --git a/src/target/trx_toolkit/burst_fwd.pyx b/src/target/trx_toolkit/burst_fwd.pyx index 4c8a0ef..d13f784 100644 --- a/src/target/trx_toolkit/burst_fwd.pyx +++ b/src/target/trx_toolkit/burst_fwd.pyx @@ -43,7 +43,7 @@ def __cinit__(self, list trx_list): self.trx_list = trx_list - cdef forward_msg(self, Transceiver src_trx, rx_msg): + cdef forward_msg(self, Transceiver src_trx, TxMsg rx_msg): # Originating Transceiver may use frequency hopping, # so let's precalculate its Tx frequency in advance tx_freq = src_trx.get_tx_freq(rx_msg.fn) diff --git a/src/target/trx_toolkit/data_msg.pxd b/src/target/trx_toolkit/data_msg.pxd index a1b2192..cbdca4b 100644 --- a/src/target/trx_toolkit/data_msg.pxd +++ b/src/target/trx_toolkit/data_msg.pxd @@ -1,9 +1,13 @@ # -*- coding: utf-8 -*- # cython: language_level=3 +from cython cimport final +from cpython cimport array +from libc.stdint cimport uint8_t + cdef class Modulation: - cdef readonly int coding # Coding in TRXD header - cdef readonly int bl # Burst length + cdef int coding # Coding in TRXD header + cdef int bl # Burst length @staticmethod cdef Modulation pick(int coding) # -> Modulation | None @@ -13,3 +17,54 @@ cdef Modulation ModGMSK + + +cdef class Msg: + cdef readonly int ver + cdef readonly object fn # int | None + cdef readonly object tn # int | None + cdef public bint nope_ind + + + @staticmethod + cdef int CHDR_LEN() noexcept + cdef int HDR_LEN(self) except -1 + + cdef append_hdr_to(self, bytearray buf) + cdef append_burst_to(self, bytearray buf) + cdef parse_hdr(self, msg) + cdef parse_burst(self, burst) + cdef _validate(self) + + +@final +cdef class TxMsg(Msg): + cdef public bytearray burst # | None + cdef readonly object pwr # int | None + + cpdef validate(self) + + +@final +cdef class RxMsg(Msg): + cdef public array.array burst # array.array[b] | None + + cdef public object rssi # int | None + cdef public object toa256 # int | None + + # Version 0x01 specific + cdef public Modulation mod_type # Modulation | None + + cdef public object tsc_set # int | None + cdef public object tsc # int | None + cdef public object ci # int | None + + + cdef _validate_burst_v0(self) + cdef _validate_burst_v1(self) + cdef validate_burst(self) + cpdef validate(self) + cdef int gen_mts(self) except -1 + + cdef _parse_burst_v0(self, burst) + cdef int parse_mts(self, uint8_t mts) except -1 diff --git a/src/target/trx_toolkit/data_msg.pyx b/src/target/trx_toolkit/data_msg.pyx index 4b59fce..02194ba 100644 --- a/src/target/trx_toolkit/data_msg.pyx +++ b/src/target/trx_toolkit/data_msg.pyx @@ -18,6 +18,8 @@ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. +from cython cimport final + import random import struct import abc @@ -70,39 +72,42 @@ cdef int KNOWN_VERSION_MAX = 1 # 0, 1 -class Msg(abc.ABC): +cdef class Msg: ''' TRXD (DATA) message coding API (common part). ''' # NOTE: up to 16 versions can be encoded CHDR_VERSION_MAX = 0b1111 KNOWN_VERSIONS = tuple(range(KNOWN_VERSION_MAX+1)) - def __init__(self, fn = None, tn = None, ver = 0): - self.burst = None # bytes|bytearray for ubit, array[b] for sbit, array[B] for usbit + def __cinit__(self, fn = -1, tn = -1, int ver = 0): self.ver = ver self.fn = fn self.tn = tn + self.nope_ind = False - @property - def CHDR_LEN(self): + @staticmethod + cdef int CHDR_LEN() noexcept: ''' The common header length. ''' return 1 + 4 # (VER + TN) + FN - @abc.abstractmethod - def append_hdr_to(self, buf): + cdef int HDR_LEN(self) except -1: + raise NotImplementedError + + cdef append_hdr_to(self, bytearray buf): ''' Generate message specific header by appending it to buf. ''' + raise NotImplementedError - @abc.abstractmethod - def parse_hdr(self, hdr): + cdef parse_hdr(self, msg): ''' Parse message specific header. ''' + raise NotImplementedError - @abc.abstractmethod - def append_burst_to(self, buf): + cdef append_burst_to(self, bytearray buf): ''' Generate message specific burst by appending it to buf. ''' + raise NotImplementedError - @abc.abstractmethod - def parse_burst(self, burst): - ''' Parse message specific burst. ''' + cdef parse_burst(self, burst): + ''' Parse message specific burst to burst. ''' + raise NotImplementedError @abc.abstractmethod def rand_burst(self): @@ -165,7 +170,7 @@ _tab_ubit2sbit = array('b', [-127 if b else 127 for b in range(0x100)]) - def validate(self): + cdef _validate(self): ''' Validate the message fields (throws ValueError). ''' if not (0 <= self.ver <= KNOWN_VERSION_MAX): @@ -187,7 +192,7 @@ ''' Generate a TRX DATA message. ''' # Validate all the fields - self.validate() + self._validate() # Allocate an empty byte-array buf = bytearray() @@ -216,7 +221,7 @@ ''' Parse a TRX DATA message. ''' # Make sure we have at least common header - if len(msg) < self.CHDR_LEN: + if len(msg) < Msg.CHDR_LEN(): raise ValueError("Message is to short: missing common header") # Parse the header version first @@ -230,17 +235,17 @@ # Make sure we have the whole header, # including the version specific fields - if len(msg) < self.HDR_LEN: + if len(msg) < self.HDR_LEN(): raise ValueError("Message is to short: missing version specific header") # Specific message part self.parse_hdr(msg) # Copy burst, skipping header - if len(msg) == self.HDR_LEN: + if len(msg) == self.HDR_LEN(): self.burst = None return - msg_burst = memoryview(msg)[self.HDR_LEN:] + msg_burst = memoryview(msg)[self.HDR_LEN():] self.parse_burst(msg_burst) @@ -248,18 +253,19 @@ cdef int PWR_MIN = 0x00 cdef int PWR_MAX = 0xff -class TxMsg(Msg): +@final +cdef class TxMsg(Msg): ''' Tx (L1 -> TRX) message coding API. ''' - # Specific message fields - pwr = None + def __cinit__(self): + self.burst = None + self.pwr = None - @property - def HDR_LEN(self): + cdef int HDR_LEN(self) except -1: ''' Calculate header length depending on its version. ''' # Common header length - length = self.CHDR_LEN + length = Msg.CHDR_LEN() # Message specific header length if self.ver in (0x00, 0x01): @@ -269,11 +275,11 @@ return length - def validate(self): + cpdef validate(self): ''' Validate the message fields (throws ValueError). ''' # Validate common fields - Msg.validate(self) + Msg._validate(self) if self.pwr is None: raise ValueError("Tx Attenuation level is not set") @@ -318,25 +324,25 @@ # Strip useless whitespace and return return result.strip() - def append_hdr_to(self, buf): + cdef append_hdr_to(self, bytearray buf): ''' Generate message specific header by appending it to buf. ''' # Put power buf.append(self.pwr) - def parse_hdr(self, hdr): + cdef parse_hdr(self, hdr): ''' Parse message specific header part. ''' # Parse power level self.pwr = hdr[5] - def append_burst_to(self, buf): + cdef append_burst_to(self, bytearray buf): ''' Generate message specific burst by appending it to buf. ''' # Copy burst 'as is' return buf.extend(self.burst) - def parse_burst(self, burst): + cdef parse_burst(self, burst): ''' Parse message specific burst. ''' length = len(burst) @@ -389,27 +395,28 @@ # IDLE frame / nope detection indicator cdef int NOPE_IND = (1 << 7) -class RxMsg(Msg): + +@final +cdef class RxMsg(Msg): ''' Rx (TRX -> L1) message coding API. ''' - # Specific message fields - rssi = None - toa256 = None + def __cinit__(self): + self.rssi = None + self.toa256 = None - # Version 0x01 specific (default values) - mod_type = ModGMSK - nope_ind = False + # Version 0x01 specific (default values) + self.mod_type = ModGMSK + self.nope_ind = False - tsc_set = None - tsc = None - ci = None + self.tsc_set = None + self.tsc = None + self.ci = None - @property - def HDR_LEN(self): + cdef int HDR_LEN(self) except -1: ''' Calculate header length depending on its version. ''' # Common header length - length = self.CHDR_LEN + length = Msg.CHDR_LEN() # Message specific header length if self.ver == 0x00: @@ -423,7 +430,7 @@ return length - def _validate_burst_v0(self): + cdef _validate_burst_v0(self): # Burst is mandatory if self.burst is None: raise ValueError("Rx burst bits are not set") @@ -432,7 +439,7 @@ if len(self.burst) not in (GMSK_BURST_LEN, EDGE_BURST_LEN): raise ValueError("Rx burst has odd length %u" % len(self.burst)) - def _validate_burst_v1(self): + cdef _validate_burst_v1(self): # Burst is omitted in case of an IDLE / NOPE indication if self.nope_ind and self.burst is None: return @@ -443,10 +450,11 @@ raise ValueError("Rx burst bits are not set") # Burst length depends on modulation type + assert self.mod_type is not None if len(self.burst) != self.mod_type.bl: raise ValueError("Rx burst has odd length %u" % len(self.burst)) - def validate_burst(self): + cdef validate_burst(self): ''' Validate the burst (throws ValueError). ''' if self.ver == 0x00: @@ -454,11 +462,11 @@ elif self.ver >= 0x01: self._validate_burst_v1() - def validate(self): + cpdef validate(self): ''' Validate the message header fields (throws ValueError). ''' # Validate common fields - Msg.validate(self) + Msg._validate(self) if self.rssi is None: raise ValueError("RSSI is not set") @@ -481,10 +489,10 @@ raise ValueError("TSC set is not set") if self.mod_type is ModGMSK: - if self.tsc_set not in range(0, 4): + if not (0 <= self.tsc_set < 4): raise ValueError("TSC set %d is out of range" % self.tsc_set) else: - if self.tsc_set not in range(0, 2): + if not (0 <= self.tsc_set < 2): raise ValueError("TSC set %d is out of range" % self.tsc_set) if self.tsc is None: @@ -571,7 +579,7 @@ # Strip useless whitespace and return return result.strip() - def gen_mts(self): + cdef int gen_mts(self) except -1: ''' Encode Modulation and Training Sequence info. ''' # IDLE / nope indication has no MTS info @@ -582,12 +590,13 @@ mts = self.tsc & 0b111 # MTS: . X X X X . . . + assert self.mod_type is not None mts |= self.mod_type.coding << 3 mts |= self.tsc_set << 3 return mts - def parse_mts(self, mts): + cdef int parse_mts(self, uint8_t mts) except -1: ''' Parse Modulation and Training Sequence info. ''' # IDLE / nope indication has no MTS info @@ -596,7 +605,7 @@ self.mod_type = None self.tsc_set = None self.tsc = None - return + return 0 # TSC: . . . . . X X X self.tsc = mts & 0b111 @@ -612,7 +621,7 @@ self.mod_type = ModGMSK self.tsc_set = mts & 0b11 - def append_hdr_to(self, buf): + cdef append_hdr_to(self, bytearray buf): ''' Generate message specific header by appending it to buf. ''' # Put RSSI @@ -630,7 +639,7 @@ # C/I: Carrier-to-Interference ratio (in centiBels) buf += struct.pack(">h", self.ci) - def parse_hdr(self, hdr): + cdef parse_hdr(self, hdr): ''' Parse message specific header part. ''' # Parse RSSI @@ -646,13 +655,13 @@ # C/I: Carrier-to-Interference ratio (in centiBels) self.ci = struct.unpack(">h", hdr[9:11])[0] - def append_burst_to(self, buf): + cdef append_burst_to(self, bytearray buf): ''' Generate message specific burst appending it to buf. ''' # Convert soft-bits to unsigned soft-bits buf.extend( self.sbit2usbit(self.burst) ) # XXX copies; can probably remove them with numpy - def _parse_burst_v0(self, burst): + cdef _parse_burst_v0(self, burst): ''' Parse message specific burst for header version 0. ''' bl = len(burst) @@ -668,7 +677,7 @@ return burst[:self.mod_type.bl] - def parse_burst(self, burst): + cdef parse_burst(self, burst): ''' Parse message specific burst. ''' burst = array('B', burst) diff --git a/src/target/trx_toolkit/transceiver.pxd b/src/target/trx_toolkit/transceiver.pxd index 74ee982..2fb2fb7 100644 --- a/src/target/trx_toolkit/transceiver.pxd +++ b/src/target/trx_toolkit/transceiver.pxd @@ -1,6 +1,7 @@ # cython: language_level=3 from data_if cimport DATAInterface +from data_msg cimport TxMsg, RxMsg from burst_fwd cimport BurstForwarder from _clck_gen cimport CLCKGen @@ -41,13 +42,13 @@ object ctrl_if # CTRLInterfaceTRX object clck_if # UDPLink - list _tx_queue # [] of TxMsg + list[TxMsg] _tx_queue cdef get_rx_freq(self, fn) cpdef get_tx_freq(self, fn) - cdef recv_data_msg(self) - cdef send_data_msg(self, msg) - cdef handle_data_msg(self, Transceiver src_trx, src_msg, msg) + cdef TxMsg recv_data_msg(self) + cdef send_data_msg(self, RxMsg msg) + cdef handle_data_msg(self, Transceiver src_trx, TxMsg src_msg, RxMsg msg) cdef clck_tick(self, BurstForwarder fwd, fn) diff --git a/src/target/trx_toolkit/transceiver.pyx b/src/target/trx_toolkit/transceiver.pyx index 19bdd09..e852eda 100644 --- a/src/target/trx_toolkit/transceiver.pyx +++ b/src/target/trx_toolkit/transceiver.pyx @@ -274,7 +274,7 @@ log.info("Stopping clock generator") self.clck_gen.stop() - cdef recv_data_msg(self): + cdef TxMsg recv_data_msg(self): # -> TxMsg | None # Read and parse data from socket msg = self.data_if.recv_tx_msg() if not msg: @@ -290,17 +290,19 @@ self._tx_queue.append(msg) return msg - cdef send_data_msg(self, msg): + cdef send_data_msg(self, RxMsg msg): # TODO: make legacy mode configurable (via argv?) self.data_if.send_msg(msg, legacy = True) - cdef handle_data_msg(self, Transceiver src_trx, src_msg, msg): + cdef handle_data_msg(self, Transceiver src_trx, TxMsg src_msg, RxMsg msg): self.send_data_msg(msg) cdef clck_tick(self, BurstForwarder fwd, fn): if not self.running: return + cdef TxMsg msg + drop = [] emit = [] wait = [] -- To view, visit https://gerrit.osmocom.org/c/osmocom-bb/+/40075?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email Gerrit-MessageType: newchange Gerrit-Project: osmocom-bb Gerrit-Branch: master Gerrit-Change-Id: Icb63ec0a0d899e352400915bb163a3e2f354c280 Gerrit-Change-Number: 40075 Gerrit-PatchSet: 1 Gerrit-Owner: kirr <kirr(a)nexedi.com> Gerrit-CC: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-CC: osmith <osmith(a)sysmocom.de> Gerrit-CC: pespin <pespin(a)sysmocom.de>
1 0
0 0
[S] Change in osmocom-bb[master]: trx_toolkit/data_if: Switch DATAInterface to be used via C-level API ...
by kirr 17 Apr '25

17 Apr '25
kirr has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmocom-bb/+/40077?usp=email ) Change subject: trx_toolkit/data_if: Switch DATAInterface to be used via C-level API from *.pyx ...................................................................... trx_toolkit/data_if: Switch DATAInterface to be used via C-level API from *.pyx All those function to recv_tx_msg, recv_rx_msg, send_msg etc are on hot data plane code paths. Switching them to C cuts related py overhead from their invocations. Change-Id: I163836040c794dfa4a757aa798e59f90bebcb2b9 --- M src/target/trx_toolkit/_fake_trx.pyx M src/target/trx_toolkit/data_if.pxd M src/target/trx_toolkit/data_if.pyx M src/target/trx_toolkit/transceiver.pyx 4 files changed, 13 insertions(+), 7 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmocom-bb refs/changes/77/40077/1 diff --git a/src/target/trx_toolkit/_fake_trx.pyx b/src/target/trx_toolkit/_fake_trx.pyx index 5c55486..aa56afa 100644 --- a/src/target/trx_toolkit/_fake_trx.pyx +++ b/src/target/trx_toolkit/_fake_trx.pyx @@ -238,7 +238,7 @@ msg.rssi = RSSI_NOISE_DEFAULT msg.ci = CI_NOISE_DEFAULT - self.data_if.send_msg(msg) + self.data_if._send_msg(msg) return # Complete message header diff --git a/src/target/trx_toolkit/data_if.pxd b/src/target/trx_toolkit/data_if.pxd index 564a6cd..23dc49e 100644 --- a/src/target/trx_toolkit/data_if.pxd +++ b/src/target/trx_toolkit/data_if.pxd @@ -1,8 +1,13 @@ # cython: language_level=3 from udp_link cimport UDPLink +from data_msg cimport Msg, TxMsg, RxMsg cdef class DATAInterface(UDPLink): cdef readonly int _hdr_ver + cdef bint match_hdr_ver(self, Msg msg) cdef recv_raw_data(self) + cdef TxMsg recv_tx_msg(self) # -> TxMsg | None + cdef RxMsg recv_rx_msg(self) # -> RxMsg | None + cdef _send_msg(self, Msg msg, bint legacy=*) diff --git a/src/target/trx_toolkit/data_if.pyx b/src/target/trx_toolkit/data_if.pyx index d5e4910..c355666 100644 --- a/src/target/trx_toolkit/data_if.pyx +++ b/src/target/trx_toolkit/data_if.pyx @@ -20,7 +20,6 @@ import logging as log -from data_msg import * cdef class DATAInterface(UDPLink): def __init__(self, *udp_link_args): @@ -46,7 +45,7 @@ # No suitable version found return -1 - def match_hdr_ver(self, msg): + cdef bint match_hdr_ver(self, Msg msg): if msg.ver == self._hdr_ver: return True @@ -59,7 +58,7 @@ cdef recv_raw_data(self): return self.recv(512) - def recv_tx_msg(self): + cdef TxMsg recv_tx_msg(self): # -> TxMsg | None # Read raw data from socket data = self.recv_raw_data() @@ -79,7 +78,7 @@ return msg - def recv_rx_msg(self): + cdef RxMsg recv_rx_msg(self): # -> RxMsg | None # Read raw data from socket data = self.recv_raw_data() @@ -99,7 +98,9 @@ return msg - def send_msg(self, msg, legacy = False): + def send_msg(self, Msg msg, bint legacy = False): + self._send_msg(msg, legacy) + cdef _send_msg(self, Msg msg, bint legacy = False): try: # Validate and encode a TRXD message payload = msg.gen_msg(legacy) diff --git a/src/target/trx_toolkit/transceiver.pyx b/src/target/trx_toolkit/transceiver.pyx index e852eda..2e8a064 100644 --- a/src/target/trx_toolkit/transceiver.pyx +++ b/src/target/trx_toolkit/transceiver.pyx @@ -292,7 +292,7 @@ cdef send_data_msg(self, RxMsg msg): # TODO: make legacy mode configurable (via argv?) - self.data_if.send_msg(msg, legacy = True) + self.data_if._send_msg(msg, legacy = True) cdef handle_data_msg(self, Transceiver src_trx, TxMsg src_msg, RxMsg msg): self.send_data_msg(msg) -- To view, visit https://gerrit.osmocom.org/c/osmocom-bb/+/40077?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email Gerrit-MessageType: newchange Gerrit-Project: osmocom-bb Gerrit-Branch: master Gerrit-Change-Id: I163836040c794dfa4a757aa798e59f90bebcb2b9 Gerrit-Change-Number: 40077 Gerrit-PatchSet: 1 Gerrit-Owner: kirr <kirr(a)nexedi.com> Gerrit-CC: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-CC: osmith <osmith(a)sysmocom.de> Gerrit-CC: pespin <pespin(a)sysmocom.de>
1 0
0 0
[XS] Change in osmocom-bb[master]: trx_toolkit/data_msg: Push checking whether .burst is None from Msg.g...
by kirr 17 Apr '25

17 Apr '25
kirr has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmocom-bb/+/40079?usp=email ) Change subject: trx_toolkit/data_msg: Push checking whether .burst is None from Msg.gen_msg to TxMsg/RxMsg .append_burst_to ...................................................................... trx_toolkit/data_msg: Push checking whether .burst is None from Msg.gen_msg to TxMsg/RxMsg .append_burst_to TxMsg and RxMsg have different types for their bursts, so inside Msg functions accessing .burst goes via py-level, while inside TxMsg/RxMsg functions accessing .burst goes via C-level. Change-Id: Ie3d38131db8964c7f134e03a9676b1e0e84be6ae --- M src/target/trx_toolkit/data_msg.pyx 1 file changed, 5 insertions(+), 2 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmocom-bb refs/changes/79/40079/1 diff --git a/src/target/trx_toolkit/data_msg.pyx b/src/target/trx_toolkit/data_msg.pyx index ac3dc49..34f6a12 100644 --- a/src/target/trx_toolkit/data_msg.pyx +++ b/src/target/trx_toolkit/data_msg.pyx @@ -260,8 +260,7 @@ self.append_hdr_to(buf) # Generate burst - if self.burst is not None: - self.append_burst_to(buf) + self.append_burst_to(buf) # This is a rudiment from (legacy) OpenBTS transceiver, # some L1 implementations still expect two dummy bytes. @@ -403,6 +402,8 @@ ''' Generate message specific burst by appending it to buf. ''' # Copy burst 'as is' + if self.burst is None: + return return buf.extend(self.burst) cdef parse_burst(self, bytearray burst): @@ -727,6 +728,8 @@ # Convert soft-bits to unsigned soft-bits l = PyByteArray_GET_SIZE(buf) + if self.burst is None: + return PyByteArray_Resize(buf, l+len(self.burst)) Msg.__sbit2usbit(<int8_t*>self.burst.data.as_chars, len(self.burst), <uint8_t*>&PyByteArray_AS_STRING(buf)[l]) -- To view, visit https://gerrit.osmocom.org/c/osmocom-bb/+/40079?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email Gerrit-MessageType: newchange Gerrit-Project: osmocom-bb Gerrit-Branch: master Gerrit-Change-Id: Ie3d38131db8964c7f134e03a9676b1e0e84be6ae Gerrit-Change-Number: 40079 Gerrit-PatchSet: 1 Gerrit-Owner: kirr <kirr(a)nexedi.com> Gerrit-CC: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-CC: osmith <osmith(a)sysmocom.de> Gerrit-CC: pespin <pespin(a)sysmocom.de>
1 0
0 0
[M] Change in osmocom-bb[master]: trx_toolkit/data_msg: Optimize RxMsg/TxMsg parsing
by kirr 17 Apr '25

17 Apr '25
kirr has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmocom-bb/+/40078?usp=email ) Change subject: trx_toolkit/data_msg: Optimize RxMsg/TxMsg parsing ...................................................................... trx_toolkit/data_msg: Optimize RxMsg/TxMsg parsing Thread all calls related in parsing to be done via C-level and with explicit types. Leverage bytearray ability to cut prefix and suffix efficiently. Replace struct.unpack with custom C-level functions to deserialize big-endian integers. Use raw C pointers to access bytearray data to avoid related py-index overhead. Change-Id: I661a414bf5091fa6b872831ba911465a8d073397 --- M src/target/trx_toolkit/data_if.pyx M src/target/trx_toolkit/data_msg.pxd M src/target/trx_toolkit/data_msg.pyx 3 files changed, 69 insertions(+), 32 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmocom-bb refs/changes/78/40078/1 diff --git a/src/target/trx_toolkit/data_if.pyx b/src/target/trx_toolkit/data_if.pyx index c355666..71a1878 100644 --- a/src/target/trx_toolkit/data_if.pyx +++ b/src/target/trx_toolkit/data_if.pyx @@ -65,7 +65,7 @@ # Attempt to parse a TRXD Tx message try: msg = TxMsg() - msg.parse_msg(data) + msg._parse_msg(data) except: log.error("Failed to parse a TRXD Tx message " "from R:%s" % self.desc_remote()) @@ -85,7 +85,7 @@ # Attempt to parse a TRXD Rx message try: msg = RxMsg() - msg.parse_msg(data) + msg._parse_msg(data) except: log.error("Failed to parse a TRXD Rx message " "from R:%s" % self.desc_remote()) diff --git a/src/target/trx_toolkit/data_msg.pxd b/src/target/trx_toolkit/data_msg.pxd index 2823b82..6823397 100644 --- a/src/target/trx_toolkit/data_msg.pxd +++ b/src/target/trx_toolkit/data_msg.pxd @@ -32,8 +32,9 @@ cdef append_hdr_to(self, bytearray buf) cdef append_burst_to(self, bytearray buf) - cdef parse_hdr(self, msg) - cdef parse_burst(self, burst) + cdef parse_hdr(self, bytearray msg) + cdef parse_burst(self, bytearray burst) + cdef int _parse_msg(self, bytearray msg) except -1 cdef _validate(self) @staticmethod @@ -84,5 +85,5 @@ cpdef validate(self) cdef int gen_mts(self) except -1 - cdef _parse_burst_v0(self, burst) + cdef _parse_burst_v0(self, bytearray burst) cdef int parse_mts(self, uint8_t mts) except -1 diff --git a/src/target/trx_toolkit/data_msg.pyx b/src/target/trx_toolkit/data_msg.pyx index 5929b47..ac3dc49 100644 --- a/src/target/trx_toolkit/data_msg.pyx +++ b/src/target/trx_toolkit/data_msg.pyx @@ -20,6 +20,7 @@ # GNU General Public License for more details. from cython cimport final +from libc.stdint cimport int16_t, uint16_t, uint32_t from cpython cimport array cdef array.array _Bempty = array.array('B', []) @@ -101,7 +102,7 @@ ''' Generate message specific header by appending it to buf. ''' raise NotImplementedError - cdef parse_hdr(self, msg): + cdef parse_hdr(self, bytearray msg): ''' Parse message specific header. ''' raise NotImplementedError @@ -109,8 +110,11 @@ ''' Generate message specific burst by appending it to buf. ''' raise NotImplementedError - cdef parse_burst(self, burst): - ''' Parse message specific burst to burst. ''' + cdef parse_burst(self, bytearray burst): + ''' Parse message specific burst to burst. + + burst bytearray can be trimmed in-place to leave only burst data. + ''' raise NotImplementedError @abc.abstractmethod @@ -267,35 +271,43 @@ return buf def parse_msg(self, msg): + if type(msg) is not bytearray: + msg = bytearray(msg) + self._parse_msg(msg) + cdef int _parse_msg(self, bytearray msg) except -1: ''' Parse a TRX DATA message. ''' + cdef uint8_t *msgb = <uint8_t*>PyByteArray_AS_STRING(msg) + cdef Py_ssize_t msgl = len(msg) # Make sure we have at least common header - if len(msg) < Msg.CHDR_LEN(): + if msgl < Msg.CHDR_LEN(): raise ValueError("Message is to short: missing common header") # Parse the header version first - self.ver = (msg[0] >> 4) + self.ver = (msgb[0] >> 4) if not (0 <= self.ver <= KNOWN_VERSION_MAX): raise ValueError("Unknown TRXD header version %d" % self.ver) # Parse TDMA TN and FN - self.tn = (msg[0] & 0x07) - self.fn = struct.unpack(">L", msg[1:5])[0] + self.tn = (msgb[0] & 0x07) + self.fn = _unpack_u32(&msgb[1]) # Make sure we have the whole header, # including the version specific fields - if len(msg) < self.HDR_LEN(): + hlen = self.HDR_LEN() + if msgl < hlen: raise ValueError("Message is to short: missing version specific header") # Specific message part self.parse_hdr(msg) - # Copy burst, skipping header - if len(msg) == self.HDR_LEN(): + # Extract burst, skipping header + # reuse original msg bytearray for burst data + if msgl == hlen: self.burst = None - return - msg_burst = memoryview(msg)[self.HDR_LEN():] - self.parse_burst(msg_burst) + return 0 + del msg[:hlen] # NOTE bytearray handles prefix delete efficiently + self.parse_burst(msg) # Constants @@ -379,8 +391,10 @@ # Put power buf.append(self.pwr) - cdef parse_hdr(self, hdr): + cdef parse_hdr(self, bytearray msg): ''' Parse message specific header part. ''' + cdef uint8_t *hdr = <uint8_t*>PyByteArray_AS_STRING(msg) + # NOTE header lenght is already pre-checked by _parse_msg # Parse power level self.pwr = hdr[5] @@ -391,20 +405,22 @@ # Copy burst 'as is' return buf.extend(self.burst) - cdef parse_burst(self, burst): + cdef parse_burst(self, bytearray burst): ''' Parse message specific burst. ''' + # trim msg down with removing everything besides burst data + # bytearray handles prefix and suffix removal efficiently length = len(burst) # Distinguish between GSM and EDGE if length >= EDGE_BURST_LEN: if length > EDGE_BURST_LEN: - burst = memoryview(burst)[:EDGE_BURST_LEN] + del burst[EDGE_BURST_LEN:] else: if length > GMSK_BURST_LEN: - burst = memoryview(burst)[:GMSK_BURST_LEN] + del burst[GMSK_BURST_LEN:] - self.burst = bytearray(burst) + self.burst = burst def rand_burst(self, length = GMSK_BURST_LEN): ''' Generate a random message specific burst. ''' @@ -688,21 +704,23 @@ # C/I: Carrier-to-Interference ratio (in centiBels) buf += struct.pack(">h", self.ci) - cdef parse_hdr(self, hdr): + cdef parse_hdr(self, bytearray msg): ''' Parse message specific header part. ''' + cdef uint8_t *hdr = <uint8_t*>PyByteArray_AS_STRING(msg) + # NOTE header lenght is already pre-checked by _parse_msg # Parse RSSI self.rssi = -(hdr[5]) # Parse ToA (Time of Arrival) - self.toa256 = struct.unpack(">h", hdr[6:8])[0] + self.toa256 = _unpack_s16(&hdr[6]) if self.ver >= 0x01: # Modulation and Training Sequence info self.parse_mts(hdr[8]) # C/I: Carrier-to-Interference ratio (in centiBels) - self.ci = struct.unpack(">h", hdr[9:11])[0] + self.ci = _unpack_s16(&hdr[9]) cdef append_burst_to(self, bytearray buf): ''' Generate message specific burst appending it to buf. ''' @@ -713,7 +731,8 @@ Msg.__sbit2usbit(<int8_t*>self.burst.data.as_chars, len(self.burst), <uint8_t*>&PyByteArray_AS_STRING(buf)[l]) - cdef _parse_burst_v0(self, burst): + + cdef _parse_burst_v0(self, bytearray burst): ''' Parse message specific burst for header version 0. ''' bl = len(burst) @@ -727,15 +746,13 @@ if self.mod_type is None: raise ValueError("Odd burst length %u" % bl) - return burst[:self.mod_type.bl] + del burst[self.mod_type.bl:] - cdef parse_burst(self, burst): + cdef parse_burst(self, bytearray burst): ''' Parse message specific burst. ''' - burst = array.array('B', burst) - if self.ver == 0x00: - burst = self._parse_burst_v0(burst) + self._parse_burst_v0(burst) # Convert unsigned soft-bits to soft-bits self.burst = Msg._usbit2sbit(burst) @@ -762,3 +779,22 @@ <uint8_t*>PyByteArray_AS_STRING(msg.burst)) return msg + + +# ---- misc ---- + +# _unpack_(u|s)(16|32) deserialize big-endian representation of corresponding integer type from memory pointed by b. + +cdef int16_t _unpack_s16(const uint8_t *b): + cdef uint16_t r = 0 + r |= (<uint16_t>b[0]) << 8 + r |= (<uint16_t>b[1]) << 0 + return <int16_t>r + +cdef uint32_t _unpack_u32(const uint8_t *b): + cdef uint32_t r = 0 + r |= (<uint32_t>b[0]) << 24 + r |= (<uint32_t>b[1]) << 16 + r |= (<uint32_t>b[2]) << 8 + r |= (<uint32_t>b[3]) << 0 + return r -- To view, visit https://gerrit.osmocom.org/c/osmocom-bb/+/40078?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email Gerrit-MessageType: newchange Gerrit-Project: osmocom-bb Gerrit-Branch: master Gerrit-Change-Id: I661a414bf5091fa6b872831ba911465a8d073397 Gerrit-Change-Number: 40078 Gerrit-PatchSet: 1 Gerrit-Owner: kirr <kirr(a)nexedi.com> Gerrit-CC: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-CC: osmith <osmith(a)sysmocom.de> Gerrit-CC: pespin <pespin(a)sysmocom.de>
1 0
0 0
  • ← Newer
  • 1
  • ...
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • ...
  • 119
  • Older →

HyperKitty Powered by HyperKitty version 1.3.12.