Commit Graph

36 Commits

Author SHA1 Message Date
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
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 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 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 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 0e194d4cd7 intf_line: Ensure unique rate counter group indexes
When we have multiple interfaces, we cannot simply use the line->id
as rate counter group index, but should use a combination of interface
id and line id.

Change-Id: I515c1f39285489845f88c3403ebf16835571e154
2022-03-28 12:13:08 +02:00
Harald Welte 620d7d3586 cosmetic: curly braces around multi-line blocks
This reflects our general coding style.

Change-Id: Ibf8ebe4c9fdde2bd66ce6239c8eca833e71fc815
2022-03-28 12:13:08 +02:00
Harald Welte 2819d3fb79 intf_line.c: Make e1d_find_intf_by_usb_serial safe for empty string
Avoid segfault in case the empty string is passed as serial_str.

Change-Id: Ia69912cb714441415d8decd68890d1b97b77132d
2022-03-28 12:13:08 +02:00
Harald Welte 591249a3c2 cosmetic: Remove extra empty newlines from end of intf_line.c
Change-Id: Ie1e193c3d851871c9c96394eb19f5b99c09913f9
2022-03-28 12:13:08 +02:00
Harald Welte f5362e9217 Allow configuration of interfaces/lines via VTY
So far, osmo-e1d automatically opened all compatible icE1usb devices
and all E1 lines on those interfaces.  Let's allow for 'interface' and
'line' configuration in the VTY.  USB devices can be identified by
their serial number string.

If a given device (== E1 interface)  has a VTY configuration, then only
those E1 lines with VTY configuration opened.

For each Line (icE1usb or vpair), the mode (channelized/superchannel)
can also be set via VTY.

Change-Id: I89b57b688b68901f87d9683ab9294772ee747d77
Closes: OS#5400
2022-02-01 17:17:31 +00:00
Harald Welte ef69fd1a63 e1_{intf,line}_new: Allow caller to specify the numeric identifier
This will be used by the upcoming VTY interface changes.

Change-Id: I9ff80831a3e3e3cb6dae178f8b438a9f3f4747df
2022-01-31 19:51:14 +01:00
Harald Welte 3fff68cbf8 cosmetic: Adhere osmocom coding style in for-loops
We either have to bring osmo-e1d in line with other osmocom projects,
or we'd have to disable the linter in jenkins.

Change-Id: I74ab20b22118d471dcdb60d1b9681ab62eb13d51
2022-01-09 23:39:42 +01:00
Harald Welte 8ddb22f8c6 e1d: Add watchdog timer to detect dead lines / USB devices
We just found a bug in icE1usb (likely firmware) which was hard to find
as there was zero notification from osmo-e1d that it actually never
received any data from the icE1usb hardware/firmware anymore.

Change-Id: Id22e4110b9067f50b1818eb12295b2d4eb9cdc12
2021-12-31 17:20:32 +01:00
Harald Welte 31ac0bea55 Evaluate received E and A bits in TS0
Related: OS#4917
Change-Id: I7e1c919518b3418e973b7ae5bedd5a6dd1c2adec
2021-01-05 23:46:02 +01:00
Harald Welte e07bbb5037 Move e1d_find_intf + e1_intf_find_line to intf_line.c
Those are generic helper functions not really related to the ctl
interface.

Change-Id: Ibbda172aa425ca1e4702bacc7e595cd73a52929d
2020-12-20 11:46:19 +01:00
Harald Welte 929a5a7588 e1_line.c: Split multiplex + demultiplex into separate mux_demux.c
The remaining intf_line.c really only manages the data structures.

This is useful for building other programs than osmo-e1d, such as
an upcoming E1 test utility called osmo-e1gen which will also use
the USB interface and icE1usb hardware, but not any of the mux/demux/ctl
code.

Change-Id: I1ceaea85a15e2fae1d2e041173be9d758c6d0b78
2020-12-20 11:45:44 +01:00
Harald Welte 8f3064a2c8 Add per-line rate counter group to count various errors
Change-Id: I766b717843d7cd8ac00d4ce18c38773ac50ec3e6
2020-12-20 11:45:44 +01:00
Harald Welte f99270acf7 implement buffering to chunks in E1->application direction
Existing applications (such as those written for DAHDI) expect to
be reading data in buffer/chunk sizes.  For example OsmoNITB: It
doesn't want to execute an expensive read/recv syscall to receive 11
bytes, if it needs at least 160 bytes.

Change-Id: I807671bc6f2acaef740ce215b8d8abcb5dce2640
2020-07-22 09:40:41 +02:00
Harald Welte 77683c810d cosmetic: create HDLC specific sub-structure within e1_ts
This groups all HDLC-specific members together, in preparation
of adding more fields for other modes.

Change-Id: Ide0577c25836252862153b4f24da550bee013687
2020-07-20 22:37:10 +02:00
Harald Welte 17c80e1f55 actually implement the superchannel mode
In superchannel mode, all 31 TS are grouped together.

There is no way to enable it yet, see next patch.

Change-Id: Id340b1925471f427deb6cda7eb54e80dfc71faec
2020-07-14 14:40:10 +02:00
Harald Welte 6473bf0fe0 introduce concept of superchannel to data structures
We treat the superchannel as an extra, separate timeslot.  Initially
I thought of simply re-using TS1, but keeping the superchannel
separate ensures that it doesn't inherit any state (like half-sent
HDLC frames) from another timeslot when we switch between the modes
at runtime.

Change-Id: I0aacf251e155de2bb6ad03ffc4181067b22f1c90
2020-07-14 14:40:09 +02:00
Harald Welte 5706083138 _e1_rx_hdlcfs: const-ify input buffer argument
Change-Id: If772487124e26bafea23b451536b3b556d4c088c
2020-07-12 23:47:10 +02:00
Harald Welte 1b75abe5ce Fix HDLC-FCS transmit side
If we are not able to read more packets from the user application,
the recv/read call will return 0 and set errno = EAGAIN.  In this
situation we cannot bail out but still ask the HDLC code to generate
output (sequences of flag octets).  If we fail to do that, we will
transmit all-ones pattern instaed of all-flag octets.

Change-Id: Id3bc76f1956138dcd9cb7b499f7251cd94af1329
2020-07-12 23:47:10 +02:00
Harald Welte 73f248fd74 Use SOCK_STREAM sockets for E1_TS_MODE_RAW
SEQPACKET is great for preserving message boundaries on signaling
channels that use HDLC.  However, its semantics, particularly regarding
truncation, are sub-optimal for RAW slots containing raw user
bitstreams (typically TRAU frames or PCM audio data).

So let's use SOCK_STREAM for RAW and keep SEQPACKET for HDLCFCS.

Closes: OS#4663
Change-Id: I1767ceaa5d2a008db0009b8027667a71c0fdc0f1
2020-07-11 13:21:14 +02:00
Harald Welte f5962496d4 Detect truncated reads on SOCK_SEQPACKET sockets
Related: OS#4663
Change-Id: Ie143d3d56a68fda97cb9f5107a27f9beb043a2a4
2020-07-11 10:33:18 +02:00
Harald Welte 27b271729f Add virtual pair of E1 interfaces
The idea is to generate a pair of virtual E1 interfaces (each with
identical number of lines), where each line A:n is connected to line B:n
of the pair and vice-versa.

This allows to test E1 using applications back to back against each
other, without any physical E1 circuits in between.

Change-Id: If42c959556b17d543762546eb45dd69d25f715f2
2020-06-29 23:10:33 +02:00
Harald Welte 9fc4d5f4e2 actually set the back-pointer from timeslot to line
'struct e1_ts' always had a back-pointer to the line it is part of,
but apparently this was never initialized so far.

Change-Id: I5e6c8189bf5aa4af26d6cd6c6d288a149ed7fa66
2020-06-29 23:10:33 +02:00
Harald Welte bbd39359eb extend logging (log more noteworthy events)
Let's log some more events that might happen.

Change-Id: I37fd290f0f0621fbf6e20e33fa709efc14df94c7
2020-06-29 23:10:31 +02:00
Harald Welte 4b1f06a47f Always log context (interface/line/timeslot) when available
We always want to know as much context as possible.  Which exact
timeslot on which line of which interface ha logged something?

Change-Id: I3d8909b396928ed3c023b8ac47fa9ec72c99e681
2020-06-29 23:09:27 +02:00
Harald Welte c98dbc2ba3 close timeslot socket if read or write returns negative
If the user application has closed the timeslot socket, we will
get error returns from read/write calls, which we must use to clean
up the daemon-side state for this timeslot.

Change-Id: I2e3e5010f36e916b4c8908af91447b3d3661123f
2020-06-29 23:09:25 +02:00
Harald Welte 0f41cb0e06 add e1_line_destroy() / e1_intf_destroy() functions
Change-Id: I5425d22288d7239063d621bddfe81e9cf21f1a5b
2020-06-29 22:12:42 +02:00
Harald Welte b3414ed4cc _e1_line_new(): Initialize timeslot fd to -1
Otherwise we might up ending up doing plenty of unintended close(0)
in _e1d_ts_stop()

Change-Id: I6b88a3ff7d650a0caa242e6ac60d7778564e237c
2020-06-29 22:12:42 +02:00
Harald Welte 9bedf75f2b introduce notion of 'driver'
Change-Id: Ic168e25f2622b397bac2c133ec35f4a0a38f859b
2020-06-29 22:12:42 +02:00
Harald Welte 760097bfb0 change list ordering for list of interfaces / lines
By using llist_add_tail(), we add new elements at the end of the list,
rather than inserting at front.  Among other things, this has the added
benefit that when the VTY prints information on lines, they are printed
in numerically ascending orrder (0,1,2, ...) and not the reverse.

Change-Id: I07a6ba706f855a29b4e33b1a6b008e0d2f11b6f3
2020-06-29 22:12:42 +02:00
Harald Welte 946eaba82b move from printf() debug output to libosmocore logging
Change-Id: I6b652554c472c0fa7d180b533ef1ed4b92b49ab9
2020-06-29 17:19:14 +02:00
Harald Welte 7f08470706 remove code not specific to USB from usb.c to intf_line.c
Change-Id: I7d4d4ab39cb3e7e6a7eb8e738a367122eb3fbee2
2020-06-29 17:19:13 +02:00