Commit Graph

216 Commits

Author SHA1 Message Date
Sylvain Munaut 3b3ec3ae3e Add osmo-e1gen to .gitignore
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
Change-Id: I488b7eb2be52b59750ea780e4480923e423a1a66
2022-10-06 10:44:18 +02:00
Sylvain Munaut b7b6057e76 usb: Add support for new GPSDO status field "Accumulated error"
Because we want to handle older firmwares too, we need to excepect
we might get a smaller structure !

(We can't get a larger one since the wLength we send is limited to
the structure we know)

Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
Change-Id: I4222bf22267f8343abf1e97546111ceb1c299846
2022-10-06 10:44:18 +02:00
Oliver Smith 6cd951d714 octoi_srv_fsm: fix implicit fall-through
Found by gcc (Debian 10.2.1-6) 10.2.1 20210110, which fails the build
with --enable-werror because of this.

Change-Id: Ib717df376a4b414f787168c2c632f04f0c51271b
2022-07-12 13:17:23 +02:00
Pau Espin 802943055d Bump version: 0.3.0.72-bb13-dirty → 0.4.0
Change-Id: Ia3b429acd866ab644a9d9a848d69bd9627dcd840
2022-06-29 12:09:55 +02:00
Harald Welte bb131026cd README.md: Fix syntax for hyperlinks
Change-Id: I0648d816dbfa51caac11920bacc16925e179223c
2022-06-18 11:59:44 +02:00
Harald Welte e185b4ee32 update git URLs (git -> https; gitea)
Change-Id: I1700d5d69aa622cde7f832a0e754969ba465a8c7
2022-06-18 11:59:44 +02:00
Harald Welte 61e4d2c4ac e1oip: Make batching-factor and prefill-frame-count configurable
This adds VTY commands at the 'account' level to configure those
settings.  They will only become active on the next [re]connect
of the line.

Change-Id: Ic455ef0ef82867db512e2ffdff24d9dd42d47eeb
2022-05-08 09:40:43 +02:00
Harald Welte d78ddab9ff e1oip: introduce #defines for BATCHING_FACTOR / PREFILL_COUNT
Change-Id: Ia0da9b038312b010bfdf88570733bf1bf004b7a8
2022-05-08 09:19:47 +02:00
Harald Welte 25945a818b octoi: Send ECHO_REQ every 10s and update the related stat_item
As soon as an OCTOI connection gets into ACTIVE state, send a
ECHO_REQ every 10s and compute the RTT at the time of receiving
the response.

Contrary to the initial idea, the stat item contains the RTT (round trip
time) measured in micro-seconds.  Changing this is not a problem as so
far the RTT was always reported as '0', and 0ms == 0us.

Change-Id: Id331319bff1cf6896fee37acc45846a2491ca92d
2022-05-01 11:22:06 +02:00
Harald Welte 18a05ecd7c octoi: only memcpy() if it is present in _octoi_tx_echo()
If the caller specifies zero-length data or a NULL pointer, don't
attempt to call memcpy() on that.

Change-Id: I5f5ed937643162d6ef6ce0cf2908432c007943c1
2022-05-01 11:22:06 +02:00
Harald Welte 0d813b5947 e1oip: Add rate_ctr for rx + tx packet / byte count
This allows to monitor the traffic utilization of each e1oip line.

Change-Id: Ifde6be0b7d3c5767b684cb8fbbc58bbd5cfb0714
2022-05-01 11:22:06 +02:00
Harald Welte 92f9ddc468 e1oip: fix line counter descriptions
The direction is wrong in two counter descriptions

Change-Id: Ia294af4b30eec1b32c4b15892751d360608c8333
2022-04-23 11:00:59 +02:00
Harald Welte e8e62c4b31 octoi: Support setting IP DSCP and socket priority via VTY
Let's allow setting IP DSCP and socket priority via the VTY.

Note that you must still manually add a kernel egress QoS map from
socket priority to IEEE P802.1p PCP (Priority Code Point) like this:

	ip link set dev eth0.7 type vlan egress-qos-map 0:0 1:1 5:5 6:6 7:7

This will create 1:1 mappings for socket priorities 0, 1, 5, 6 and 7 to
the respective IEEE PCP.  A higher PCP typically means higher priority,
where voice is traditionally using "5".

Change-Id: Ic5a6c5a0ec67beb40be4ca95326aca5072a28958
2022-04-21 09:14:42 +02:00
Harald Welte 42d2b80fd5 cosmetic: remove dead code {fifo,rifo}_dump() functions
Change-Id: I8c6fc5fe82bc3a045a9e5d23965ca6d5532d6112
2022-04-20 21:32:20 +02:00
Harald Welte 1e620fb491 e1oip: Add stat items for number of timeslots
This adds "e1oip:e1t_ts_active" and "e1oip:e1o_ts_active" to show
which timeslots are active (i.e. which are transmitting data in the
IP protocol).

Change-Id: I6858e0773a348193bb4839c247294cef5ab4df5f
2022-04-20 21:32:20 +02:00
Harald Welte 916afa4476 octoi: add new counter every time a connection is accepted
This adds a new [rate] counter "e1oip:connect_accepted" that increments
every time the connection is accepted for both server and client role.

The rate is not really interesting, it's more the total absolute
quantity that's interesting.  Plotting the delta will give us spikes
whenever the connection is re-established.

Change-Id: I8baac768289f7e01d943f5205afa824f367a3a61
2022-04-20 21:32:20 +02:00
Harald Welte d13e6a5eb9 octoi: Fix client re-start after clock drift disconnect
We have to issue the OCTOI_CLNT_EV_REQUEST_SERVICE event to the FSM
only after it has switched back to INIT state.

Change-Id: I1d913a8153adaf87b2c3dadcf98382ff0b9fc2fb
2022-04-20 21:32:20 +02:00
Harald Welte c0fbd5a7b8 octoi: Terminate connection on too high RIFO OVERFLOW rates
If we are permanently overflowing the RIFO in IP->E1 direction, the
peer clock is consistently faster than our E1 clock.  There's no smart
way to recover from this. Log an error and disconnect.

This is the opposite situation from the high RIFO UNDERFLOW situation
whose logging + disconnect handling was added in
Ie3fffa1c1c20962b40320c8cc088c140b8d64e77

Change-Id: Iecd294b0174c9a0572df3dad612cb4efbd9cde07
2022-04-20 21:32:20 +02:00
Harald Welte 6e5fc3ecde e1oip: Add rate_ctr for IP->E1 RIFO overflows
This typically happens if the remote IP peer is transmitting at a faster
rate than the E1 side is consuming.  Let's add a way to monitor it.

Change-Id: Ie0e8bb2f5d2ae4256952f6bf69e514d5c2627a76
2022-04-20 21:32:20 +02:00
Harald Welte 52f86b69ed e1oip: Rename e1oip:overflow to e1oip:e1o_overflow
This indicates that this is counting an E1-originated overflow of the
OCTOI transmit FIFO, which should never happen unless your system is too
slow to periodically schedule the related timers in the code.

Change-Id: I0af6a2847c8356b011bcff5cc4f5d909c574ea21
2022-04-20 15:50:33 +02:00
Harald Welte 3f342ee28c octoi: differentiate UNDERRUN from SUBSTITUTED in counters
A real _underrun_ happens if the RIFO is empty (depth == 0)
and should be counted different from a mere frame substition
due to packet loss.

Change-Id: I5448430b09ec10a16decdfd0a4a40850fe2ed1a6
2022-04-20 15:50:32 +02:00
Sylvain Munaut d413cbcb4b octoi: Fix frame_rifo_depth() function
We use the 'correct' math in frame_rifo_depth now so the
count is accurate down to zero.

We need to fixup the logic that drags the 'write pointer'
(last_in_fn) along when reading from an empty FIFO.

We also need proper init (which was missing alltogether
beforehand).

Change-Id: I088f181e74358eb2c96a7aab7a7c875b9276d980
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
2022-04-20 15:48:26 +02:00
Sylvain Munaut ce817ca149 rifo_test: Use a helper function for the rifo init
Because we poke at some of the internals we need to make
sure to maintain the internal state consistent.

Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
Change-Id: I5d9397be391c60f732c89f158d25660e1f32cfac
2022-04-20 15:48:26 +02:00
Harald Welte f226f50d12 rifo_test: print rifo_depth + rifo_frames on every IN/OUT
This shows that rifo_depth is off-by-one for all but the 'empty'
case.  It is intended that 'make check' will fail after this commit,
before the next commit with the fix is introduced.

Change-Id: I1be1889800c83d251d17801f31040c137c06a46d
2022-04-20 15:48:26 +02:00
Harald Welte 30530ff4a7 octoi: Disconnect the link when >= 7500 underruns/s
This situation is the result of the peer clock being continuously
too slow compared to the local clock, leading to RIFO underruns at
[virtually] all of the 8000/s E1 frames.  As the current code doesn't
recover from this, we might as well disconnect and re-start for
recovery.

Change-Id: Ie3fffa1c1c20962b40320c8cc088c140b8d64e77
2022-04-20 14:48:48 +02:00
Sylvain Munaut 8a2e82560c octoi: Simple RX priming / pre-filling
This was not an issue with the original FIFO code, which dynamically
substituted frames and always created the minimal required backlog.

The RIFO can by principle not operate this way, so we really have to
prime / pre-fill it with a number of TDM frames.  That initial fill
level has to be sufficient to cover RTT jitter of the OCTOI link as
well as clock drift between (GPS synced) receiver and transmitter.

Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
Change-Id: I3a4b3846d3dbd1c99989e994ad95e609f2757219
2022-04-19 19:31:18 +02:00
Harald Welte 99161f1423 octoi: Reset FIFO/RIFO when entering ACCEPTED state
For both OCTOI client + server FSM, whenever we enter the ACCEPTED
state (we disconnect), let's reset the RIFO/FIFO state.  This makes
sure no left-over frames from some earlier connection are present,
and also ensures our initial frame number expectations are correct.

Change-Id: I9e721b5dbf22728cb2361ed121d12def7016dcc2
2022-04-19 19:20:48 +02:00
Sylvain Munaut accfded547 OCTOI: Fix the extension of 16b FN from packet to full 32b FN
Only frames withing a certain window are even accepted for processing
the rest is dropped since it could corrupt our state.

Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
Change-Id: I25b2e150d924aa8c714b766cb92e9e23e67cfa4c
2022-04-19 17:59:05 +02:00
Harald Welte f23274d184 e1d: stat_items for the GPS-DO related bits
It is interesting from a monitoring point of view to be able to
correlate the GPSDO state with other performance counters we export.

While each GPS-DO only exists once per icE1usb, we still export the
state per line, to make it easy for external monitoring to have one set
of counters per line.

Change-Id: I1f98610b7c725146a3f016a8737440be5baae858
2022-04-19 17:55:25 +02:00
Harald Welte f7716183a5 octoi: Add new rate-counter for out-of-order packets
Change-Id: Ie97c1efecf8b673620ddc097e0184f8a9c92c3f0
2022-04-19 17:12:42 +02:00
Harald Welte 7fb09b8884 Add rate counters for number of frames muxed/demuxed (E1 side)
Nominally this is of course 8000/s, but this patch should allow us to
verify this in monitoring.  Note that the rate_ctr base of course is
"wrong" as it uses the normal system clock, which is much less precise
than the E1 clock of an icE1usb with GPS-DO.

So it really only helps us to compare Rx against Tx or against other
values/counters derived from the TDM clock.

Change-Id: I40e9fb38561410fbf0902b8a390673690a36ea5e
2022-04-19 15:04:53 +02:00
Harald Welte 0d67df2307 octoi: Update RIFO depth also on dequeue
We updated the RIFO depth on every enqueue, let's also do so on dequeue.
Otherwise the figure might be wrong in case of no further received input
frames.

Change-Id: I175f0503e7435c362f35bd8083b785197d9d7338
2022-04-19 14:57:20 +02:00
Harald Welte b22bcd2059 Fix stats exporter
We called osmo_stats_vty_add_cmds() but we didn't call
osmo_stats_init(), resulting in the user being able to configure stats
reporting, but osmo-e1d would simply never generate the related UDP
packets :(

With this commit, osmo-e1d starts to generate the related packets.

Change-Id: Ic373d3056d044af797664215b08ba0880675ae53
2022-04-18 19:31:36 +02:00
Harald Welte 6d51f79931 Set rate_ctr_group name for each line
"Counters for each line in e1d 256" is not very useful unless you
know that it's "(intf_nr << 8) | line_nr" and 256 == I1/L0.

Let's set the name string explicitly.

Change-Id: I200e068f1bbc495fb806402877551924beea214e
2022-04-17 12:57:29 +02:00
Harald Welte 973ce5c507 Make use of libosmcoore cpu_sched_vty
osmo-e1d automatically uses SCHED_RR already, but for consistency it
actually makes sense to add this, so people can configure the scheduler
priority and/or the cpu affinity this way.

The existing call to SCHED_RR is left in place for backwards
compatibility.  The new VTY commands can just override that, if needed.

Change-Id: I1b8021e6dc864af6e301fced427e24c8bb21ca2f
2022-04-17 12:57:24 +02:00
Harald Welte 1ed219a191 octo: give rate_ctr / stat_items meaningful identifiers
We don't want useless identifiers like 'E1oIP line 5518' but something
that we can understand, like the user account name, or in absence
of that, at least the IP/port.

Change-Id: Ibd98b9606a1d9d5b76d63be83eb3df9e431ab3ad
2022-04-17 12:16:56 +02:00
Harald Welte db59c3f4b9 OCTOI: re-implement LINE_STAT_E1oIP_E1T_FIFO
There use to be a stat_item for the depth of the E1-terminated FIFO, as
in a FIFO this is very easy to determine.  When we switched to RIFO, it
was lost.  Let's re-introduce it with the approximate depth of the RIFO.

Change-Id: I960cbf196ae930b1b72745b8bfe9c2a21fd53325
2022-04-17 11:37:29 +02:00
Sylvain Munaut 2c0af2fa98 RIFO: Add a test for bounds checking
This tests exactly one frame before and one frame after what
should be accepted to make sure those are rejected

Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
Change-Id: I048e1b8c2b918f7ca4b4327b89bf04430a2838bc
2022-04-14 20:17:14 +00:00
Sylvain Munaut 712d234ca4 RIFO: Fix issue in frame number bounds checking
You can't have a 'min' and 'max' FN because of the wrap
around this needs to be checked "all at once".

Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
Change-Id: Ie9024f84f79b458248786bca2343a1f8bffb9994
2022-04-14 20:16:32 +00:00
Sylvain Munaut d74c51cda2 RIFO: Fix operator precedence issue in the math for bucket_for_fn
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
Change-Id: Iff91cfe93e8c7b53998b1b4dd73684292c105cc8
2022-04-14 20:15:12 +00:00
Sylvain Munaut 1cc564d81a RIFO: Minor typo/comment fixes
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
Change-Id: I9b6181f9136b7963681c472b017d005022d27e6e
2022-04-14 20:13:59 +00:00
Harald Welte 97b15ae397 vty: Print only applicable information during 'show line'
If the line is in channelized mode, only print per-TS information.
If the line is in superchannel mode, only print SC information.

This avoids printing information that is not applicable to the line
mode.

Change-Id: I7b55ae8a5e1d352f90e14342d7f7e82e4848118a
2022-04-10 17:35:15 +02:00
Harald Welte 9f3498681a fix segfault on 'show octoi-server' if no server configured
Change-Id: I23697f858337948555456b71539b9afe8c3730b9
2022-04-10 17:35:13 +02:00
Manawyrm c72f38feac RIFO: add more thorough tests and a vetted test.ok file
This commit adds 2 new tests:
 - too old frames (which should get dropped)
 - already correct frames (which shouldn't be touched)

In addition, every test will now be run twice.
Once at frame number 0 and once very close to the wrap-around of
the internal frame counter in order to observe the behaviour.

Change-Id: I930b4361924b2e8bcb566eb7ee64f36e06bc7745
2022-04-09 13:21:52 +02:00
Manawyrm 480d989d62 RIFO: fix frame_rifo_in check on frame number wrap-around
frame_rifo_in would previously return -ERANGE when a frame was written
which was at the edge of the wrap-around of the frame number (because
the maximum value was already across the boundary)

Also: fixed some typos
Change-Id: I88abfc77543d5c64b01f40944b2914e03e57d08f
2022-04-09 13:21:52 +02:00
Harald Welte 38b1c5d3f0 RIFO (random in, first out) for IP->E1 direction
In the past, we used a FIFO structure (first in, first out) - which
obviously cannot deal with packet re-ordering on the IP side.

This patch introduces a new "RIFO" as a replacement for the FIFO.

The RIFO is able to reconstruct E1 frame ordering by using the
reduced frame number from the TDMoIP messages, at least as long
as the related frame number range is within the current RIFO depth.

Change-Id: I22256870114cb85e4e10932554478be7061e086b
2022-04-09 13:21:49 +02:00
Harald Welte 322fbc4901 add example config files for octoi-server and octoi-client
Change-Id: Ia427eb62bbfecea12c31584996a57cb82aa097a0
2022-04-05 22:00:36 +02:00
Harald Welte e324507676 OCTOI: initial support for E1oIP forwarding
This introduces initial support for operation as OCTOI (Osmocom
Community TDMoIP) server and client operation.

Various features are still absent (user authentication, support for
re-ordered packets), but this version is already able to provide
services to clients with dynamic IP addresses as well as servers.

The bulk of the OCTOI / E1oIP code is implemented as a shared library,
to facilitate the development of other servers and clients in the
future, and also to minimize the impact on the existing osmo-e1d code
base.

More information is available at https://osmocom.org/projects/octoi/wiki

Change-Id: I05f5ff697ca8f7dccdcf89660f12089babfcc92e
2022-03-28 12:26:09 +02:00
Harald Welte 8ec461ebe8 vty.c: Fix re-reading of config file after 'write file'
When writing the timeslot mode, we must write it in lower-case,
as the VTY parser reading the config file only supports that.

Change-Id: Ic60449a0ba64117a5cf5e4a8e76484e9c955f09f
2022-03-28 12:13:08 +02:00
Harald Welte 16403fce90 mux_demux.c: Use %zu for size_t
This avoids compiler warnings on 32bit ARM builds

Change-Id: Ice43fb7c4514d364a3ae305847f28197a4f6cb2d
2022-03-28 12:13:08 +02:00