kirr has uploaded this change for review.

View Change

trx_toolkit/burst_fwd: Switch BurstForwarder to cdef class

- Put fields into the object struct; fields are now accessed directly
via that C-level struct instead of via __dict__ lookup
- cimport instead of import BurstForwarder at the users
- switch to invoke BurstForwarder.forward_msg via C-level as that function is
the only public function of BurstForwarder and is used only in one
place in Tansceiver.clck_tick . Add corresponding type annotation
there to make that C-calling possible.

Change-Id: I8e5fe20ff5a9a0fbbb8ce82a7776837de1219e13
---
M src/target/trx_toolkit/_fake_trx.pyx
A src/target/trx_toolkit/burst_fwd.pxd
M src/target/trx_toolkit/burst_fwd.pyx
M src/target/trx_toolkit/transceiver.pyx
4 files changed, 13 insertions(+), 6 deletions(-)

git pull ssh://gerrit.osmocom.org:29418/osmocom-bb refs/changes/65/40065/1
diff --git a/src/target/trx_toolkit/_fake_trx.pyx b/src/target/trx_toolkit/_fake_trx.pyx
index e540e14..102a8d1 100644
--- a/src/target/trx_toolkit/_fake_trx.pyx
+++ b/src/target/trx_toolkit/_fake_trx.pyx
@@ -21,7 +21,7 @@
import random
import select

-from burst_fwd import BurstForwarder
+from burst_fwd cimport BurstForwarder
from _clck_gen cimport CLCKGen
from transceiver import Transceiver
from data_msg import Modulation
@@ -401,7 +401,7 @@
# Runner organizes execution of several FakeTRX instances with common clock.
cdef class Runner:
cdef CLCKGen clck_gen
- cdef object burst_fwd # BurstForwarder
+ cdef BurstForwarder burst_fwd
cdef list[Transceiver] trx_list

def __init__(self, clck_gen, trx_list):
diff --git a/src/target/trx_toolkit/burst_fwd.pxd b/src/target/trx_toolkit/burst_fwd.pxd
new file mode 100644
index 0000000..eb3d60b
--- /dev/null
+++ b/src/target/trx_toolkit/burst_fwd.pxd
@@ -0,0 +1,6 @@
+# cython: language_level=3
+
+cdef class BurstForwarder:
+ cdef list trx_list # [] of Transceiver
+
+ cdef forward_msg(self, src_trx, rx_msg)
diff --git a/src/target/trx_toolkit/burst_fwd.pyx b/src/target/trx_toolkit/burst_fwd.pyx
index 36e5095..2c63187 100644
--- a/src/target/trx_toolkit/burst_fwd.pyx
+++ b/src/target/trx_toolkit/burst_fwd.pyx
@@ -21,7 +21,7 @@

import logging as log

-class BurstForwarder:
+cdef class BurstForwarder:
""" Performs burst forwarding between transceivers.

BurstForwarder distributes bursts between the list of given
@@ -40,10 +40,10 @@

"""

- def __init__(self, trx_list):
+ def __cinit__(self, list trx_list):
self.trx_list = trx_list

- def forward_msg(self, src_trx, rx_msg):
+ cdef forward_msg(self, src_trx, 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/transceiver.pyx b/src/target/trx_toolkit/transceiver.pyx
index a11a319..2918d54 100644
--- a/src/target/trx_toolkit/transceiver.pyx
+++ b/src/target/trx_toolkit/transceiver.pyx
@@ -23,6 +23,7 @@

from ctrl_if_trx import CTRLInterfaceTRX
from data_if cimport DATAInterface
+from burst_fwd cimport BurstForwarder
from udp_link cimport UDPLink
from trx_list import TRXList

@@ -295,7 +296,7 @@
# TODO: make legacy mode configurable (via argv?)
self.data_if.send_msg(msg, legacy = True)

- def clck_tick(self, fwd, fn):
+ def clck_tick(self, BurstForwarder fwd, fn):
if not self.running:
return


To view, visit change 40065. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-MessageType: newchange
Gerrit-Project: osmocom-bb
Gerrit-Branch: master
Gerrit-Change-Id: I8e5fe20ff5a9a0fbbb8ce82a7776837de1219e13
Gerrit-Change-Number: 40065
Gerrit-PatchSet: 1
Gerrit-Owner: kirr <kirr@nexedi.com>
Gerrit-CC: fixeria <vyanitskiy@sysmocom.de>
Gerrit-CC: osmith <osmith@sysmocom.de>
Gerrit-CC: pespin <pespin@sysmocom.de>