Commit Graph

157 Commits

Author SHA1 Message Date
Pau Espin faedcec65c Bump version: 0.5.0.11-b7c9-dirty → 0.6.0
Change-Id: I8d5e3ffd928fa65bc3d3b43553fcd6774a7812dc
2023-09-12 13:30:07 +02:00
Harald Welte b7c963f209 octoi: Add force-send-all-ts mode
This new mode (can be enabled per account) will force the E1OIP
protocol to always send all timeslots, i.e. not do any of the
suppression of timeslots that do not exhibit any change to the
previous E1 frame.

Change-Id: I6d17d3829b2c1c62e701a1d8c021d93d93593613
2023-08-14 07:54:10 +02:00
Harald Welte f07d38a6eb e1d-ts-pipe: Assert that osmo_fd_register() succeeds
Fixes: CID#307497: Unchecked return value (CHECKED_RETURN)
Change-Id: Ie2abd580e37d7d58c507d12105ec2130fb533ed9
2023-07-18 14:04:14 +02:00
Harald Welte 27cfff6ad0 octoi: Fix missing check of osmo_fsm_register() return value
Fixes: CID#307511: Unchecked return value (CHECKED_RETURN)
Change-Id: Ia474a6c078f1aec3d04be494a888ffe87b199f5a
2023-07-18 14:02:02 +02:00
Harald Welte 3dabaf3636 proto_srv: Fix file descriptor and memory leak in error paths
Fixes: CID#307517
Change-Id: I44e349eee5b0b54843762db8cadd6b9b1758faa4
2023-07-18 14:00:09 +02:00
Harald Welte 06ab6a991f Check return code of fcntl() in several plaaces
Fixes: CID#307539, CID#307533
Change-Id: I46843174eb4699a59421dc3f3b900a3894c67081
2023-07-18 13:57:21 +02:00
Philipp Maier 580bb374ae proto_clnt: use osmo_fd_close to close the socket on connection loss
When the socket is closed due to a connection loss, we currently use
close(). This is not enough since this will not remove the file
descriptor from the select loop. Let's use osmo_fd_close.

Related: OS#5983
Change-Id: I702b944baf2ebbcc84b6a211e245a4a41627bde6
2023-05-02 15:36:20 +02:00
Philipp Maier 9f55c47e7b proto_clnt: close osmo-e1d control socket on connection loss
When osmo-e1d is terminated the socket file descriptor on the client
side will get permanent POLLHUP events. This means that the registered
callback gets called with flags OSMO_FD_READ but the received data will
be of length zero. We must detect this situations and close the file
descriptor on connection loss. Otherwise we would get called over and
over again in an endless loop, resulting in 100% CPU usage.

Related: OS#5983
Change-Id: I3e1a29a9701a9432f58ef7cfedc32c916203017a
2023-04-20 14:38:17 +02:00
Pau Espin 7d2df40c69 Bump version: 0.4.0.26-8aba-dirty → 0.5.0
Change-Id: I178d34a67cba0359b16fe27fa30b2145703a2909
2023-02-07 11:57:43 +01:00
Harald Welte 8aba31092f DAHDI trunkdev support
DAHDI trunkdev is a newly-introduced 'virtual trunk' character device
which is used instead of a real hardware driver. This means that an
application (such as osmo-e1d) can implement a virtual E1 trunk and
receive and transmit E1 frame data which is exposed to DAHDI users
just like the data from a real physical E1 span.

In order to build DAHDI trunkdev support into osmo-e1d, you will need
a special fork of dahdi containing the required support, currently
the laforge/trunkdev branch of the following repository:
	https://gitea.osmocom.org/retronetworking/dahdi-linux

Change-Id: Ib15a7313fcd63e1ed9f2f5b349df967bc4335ec2
2023-02-01 11:24:49 +01:00
Christoph Lauter 632517011d Increasing max FIFO size for feature request 5875, adapting tests
Change-Id: Iae76d87cf436c80c005a2f8fce5a30f74f7e4545
2023-01-26 09:45:45 -07:00
arehbein ad15cf4397 osmo-e1d: Transition to use of 'telnet_init_default'
Related: OS#5809
Change-Id: I68fafc519d7c7ca9788bfcad7be1fadbb208cebe
2022-12-19 22:34:39 +01:00
Harald Welte 20419bdf55 doxygen API documentation for libosmo-e1d
If we actually expect 3rd party applications to use libosmo-e1d to talk
to osmo-e1d, we'd better add some basic documentation on how this API
shall be used.

Change-Id: Ib4a97045bca276fbd3892f801898a436de7dc39b
2022-11-07 14:43:53 +01:00
Harald Welte 5806606ce5 avoid segfault in 'show interface' of absent icE1usb
Don't segfault when processing a "show interfaces" for an interface
that is configured via VTY but not actually attached/found in the
system:

usb.c:693:29: runtime error: member access within null pointer of type 'struct e1_usb_intf_data'

Depends: https://gerrit.osmocom.org/c/osmo-gsm-manuals/+/30019
Depends: https://gerrit.osmocom.org/c/osmo-gsm-manuals/+/30020
Change-Id: I2ce990bb57f6ae4edb3a99a4b7bf26a49f362410
2022-11-05 22:26:07 +01:00
Harald Welte 7f204ac42a osmo-e1d: Add the usual '-V' / '--version' command line argument
Change-Id: Ie2d79c44e580ffa6555f87b969206047ffb7eb6f
2022-11-03 10:18:54 +01:00
Harald Welte 81546e6773 Differentiate between icE1usb and e1-tracer in log/vty output
Now that we support the e1-tracer in addition to icE1usb, let's
differentiate in the log output.

Change-Id: Iea647b12d86c97cfacbc3df43010b9b94f0a97c7
2022-11-02 09:42:04 +01:00
Harald Welte 7533197639 usb.c: Bail out of e1-tracer doesn't accept set_configuration(2)
This likely means it's not an e1-tracer after all, or it's an old
firmware that doesn't yet expose the e1d-compatible USB configuration.

Related: OS#5734
Change-Id: If5a9bc20084d84885d5d97b4f982e94801612d24
2022-11-01 18:24:29 +01:00
Harald Welte cfe7ab300e osmo-e1d-pipe: Add command line option for --force open of timeslot
This exposes the existing capability of force-opening a timeslot via a
command-line argument.

Related: OS#5735
Change-Id: Ieefc89f2e48e9124ae744a587739ff3948110944
2022-11-01 18:09:17 +01:00
Harald Welte 5077657f57 ctl: Prevent clients from opening TS0
This doesn't work, as the mux_demux.c code doesn't pass the TS0 bitstream
to users anyway.  So let's reject clients attempting this.

Change-Id: Idb2d20da7de72dad38ae2fccdd7630677d0f0cc8
2022-11-01 17:01:48 +01:00
Harald Welte 64e1889f99 support for e1-tracer hardware
Recent work on the e1-tracer firmware is introducing a set of USB
descriptors (as configuration 2) that are mostly compatible to how
osmo-e1d talks to icE1usb.

The main difference is that there's only one ISO IN endpoint per USB
interface, and no ISO OUT or ISU FB endpoints.  So we introduce some
minor adjustments here to accommodate that.

Related: OS#5733
Closes: OS#5734
Change-Id: I855e18c0f229bd473123f96303e60ab2de90677f
2022-11-01 17:00:25 +01:00
Sylvain Munaut 56a79f60e1 usb: Claim and set interface alt-setting only for used lines
If a line is not auto-created, there is no point on claiming the
matching interface and even less point setting the alt setting that
will try to use USB isoc bandwith.

With this you can no use only line 1 and not line 0 of a ice1usb
for instance. While previously it would still "enable" line 0 and
then line 1 would fail because on BW issues most of the case.

Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
Change-Id: Iea5d72272f11875e7a32c78b60c188590deda831
2022-10-12 22:18:02 +02:00
Sylvain Munaut 6005fb3ea8 octoi: Prevent segfault on 'show octoi-clients if a client has no line
This can happen if the specified device in the config isn't plugged
in for instance, no line is created ...

Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
Change-Id: I594463591f2945a04ccd708f16788034cc1dfc57
2022-10-12 22:16:12 +02:00
Sylvain Munaut 9d45233337 vty: Add option to disable GPS-DO loop and use manual tuning values
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
Change-Id: I8668fe42e4c399f08696e497887120e501341f5a
2022-10-06 10:44:18 +02:00
Sylvain Munaut a810249f9a usb: Fix ICE1USB_INTF_SET_GPSDO_MODE request parameter
This call takes its argument in wValue rather than as payload

Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
Change-Id: Ibeebe3184a4744bd0cd9f5a19db84c12fab18806
2022-10-06 10:44:18 +02:00
Sylvain Munaut f3e77ceed9 usb: Fix the length field of ICE1USB_INTF_SET_GPSDO_TUNE request
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
Change-Id: Ibf1b1440696902757f4b1c1d9c4d80c1da453a36
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 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
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