Commit Graph

216 Commits

Author SHA1 Message Date
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 9408fc3839 support for control endpoint requests to icE1usb to switch Rx/Tx mode
Change-Id: I62f3175a216eb5db0847f4b16c91bc23697a7623
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 a74aaf172c Add support for icE1usb interrupt endpoint error reporting
Related: OS#4674
Change-Id: I5b0bf3cf40c623c17f2e88292e880b545c36b7b6
Depends: osmo-e1-hardware If157fde9d4ca05910b09537e19f37603c6d925f0
2020-12-20 11:29:59 +01:00
Harald Welte 515be330cb usb: Increase number of transfers from 2 to 4
Experimentally this has shown a much lower probability of
USB related overruns/underruns, at least on my system.

Change-Id: I5c73b29462a4870d3c86fd7f46e1574daae6f93f
2020-12-19 18:27:41 +01:00
Harald Welte ba6336c675 vpair: fix writing config file with vpairs configured
prior to this patch, the configured vpair interfaces would not
be saved to the config file on 'write file'.

Change-Id: Iff6551318534a3717c374060082147f17b925a21
2020-12-19 18:27:37 +01:00
Harald Welte e542b30f44 Use OSMO_FD_* instead of deprecated BSC_FD_*
Change-Id: I7d0972705e898fd75cda3e92104c67c56ec166d5
2020-10-18 22:36:34 +02:00
Harald Welte 9e137aff1d make sure a given timeslot can only be opened once (by default)
Align the behavior of osmo-e1d with that of DAHDI:  If a timeslot is
opened once, it cannot be opened again by anyone until it is closed
by the current owner.  This way we'd have the same failure semantics
in DAHDI vs. osmo-e1d, which is very useful in case of misconfiguration
when osmo-bsc + osmo-mgw would "fight" over a timeslot.

Add a osmo_e1dp_client_ts_open_force() function that allows to override
and get back the original behavior.

Closes: OS#4654
Change-Id: Ib25adf827ec41e74de15e0e4fdcfc9bcc9a32e58
2020-09-20 11:55:14 +02:00
Harald Welte ead2e020f0 e1-prbs-test: Add support for osmo-e1d
This allows e1-prbs-test to not only use DAHDI devices, but also
osmo-e1d supported devices

Change-Id: I0e88f2b056db931b0e442567efa9a8d270abb9f2
2020-09-11 13:04:21 +02:00
Harald Welte d5ea3eb9c1 src/ctl.c: Log NOTICE messages whenever client send unexpected requests
Change-Id: Icd47de13ab84b89ce5fb21c24713bae760611d32
2020-09-11 12:56:18 +02:00
Harald Welte 51e12ad603 usb: Don't pass negative length values to e1_line_demux_in()
every so often, the USB transfer completes without data (due to
"unlucky" time alignment between E1 and USB frame clock).  Don't
call the demuxer in that case.

Otherwise the user is confused by error messages like

<0001> intf_line.c:467 (I0:L0) IN ERROR: -4

Change-Id: Ia99f97c2cca44d15a83a54cebe884b343ec44f46
2020-09-01 09:37:33 +02:00
Harald Welte 569726a72f make RAW read buffer size configurable (instead of hard-coded 160)
When opening a timeslot, the client can now specify the (from
application perspective) timeslot read buffer size.  This breaks
ABI, but then we're still at a point where only prototype hardware
exists, so we can get away with it.

Change-Id: I6d603778cce14c5d72fe5f54904905ea7e66d7ff
2020-07-22 09:42:56 +02:00
Harald Welte 79cda368ac add comment about first byte of E1DP_MAGIC
Change-Id: I7b0a59211521ec631512e6cac7a65e2a2172d538
2020-07-22 09:42:56 +02: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 5d5e47ff3b Add new E1DP_CMD_LINE_CONFIG for switching channelized/superchannel
This adds the related code to the server and client side of the CTL
interface to switch a line between CHANNELIZED and SUPERCHANNEL.

Change-Id: I765b5c3bc9e07b2353f8647e8260ff95df3727e6
2020-07-15 10:26:15 +00: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 9fbd4e819e print E1DP Mode as string, not in numeric format
Change-Id: I4d221a45bdd5d85b3ab6eaa35d67683b50bea21f
2020-07-11 13:20:13 +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 80df1a9fb2 usb.c: Fix error introducing Tx underflows
In Change-Id I7d4d4ab39cb3e7e6a7eb8e738a367122eb3fbee2 I inroduced
a bug that would cause e1_usb_xfer_out() to return four bytes too
little, which in turn causes E1 Tx underflows to happen in the device
firmware.

Change-Id: I71675d4de781421286f0d1febedfdb1f7b523c38
2020-07-09 20:57:07 +00:00
Harald Welte c5c5a1e7c5 add missing call to logging_vty_add_cmds() during startup
Otherwise, the usual logging related VTY commands are absent.

Change-Id: I07038dfb204301bb1696ca312b2ec29671b86ae5
2020-07-09 20:57:01 +00:00
Harald Welte 3e5741352e migrate to proper allocated USB Product ID
The 0xe1e1 was a neat hack in the early days, but now 0x6145 has been
allocated within the Openmoko USB VendorID.    The current device
firmware already uses the new ProductID, let's change it here, too.

Change-Id: Iea6087ce02c931c796d9c9cae89cdf5b5e0b28c5
2020-07-09 20:54:50 +00:00
Harald Welte b726cf9d5b Bump version: 0.1.0.1-8e1e → 0.1.1
Change-Id: I4544ad93856355b084a6ee8353438a3ec20097c0
2020-07-02 13:44:06 +02:00
Harald Welte e894e5c621 Makefile.am: Don't put LIBS into CFLAGS
this was accidentially introduced in Change-Id I47b6e4efaad52e68e2b50a7993076f3706f86628
and causese build failures on some targets:

libtool: link: gcc -Wall -Wno-unused-result -pthread -I/usr/include/ -I/usr/include/libusb-1.0 -g -O2 -fdebug-prefix-map=/usr/src/packages/BUILD=. -fstack-protector-strong -Wformat -Werror=format-security -Wl,-z -Wl,relro -o .libs/osmo-e1d-pipe e1d-ts-pipe.o  /usr/lib/x86_64-linux-gnu/libosmovty.so /usr/lib/x86_64-linux-gnu/libosmousb.so -ltalloc /usr/lib/x86_64-linux-gnu/libosmocore.so ./.libs/libosmo-e1d.so -pthread
/usr/bin/ld: /usr/lib/x86_64-linux-gnu/libosmousb.so: undefined reference to `libusb_open'

Change-Id: I09fc640847e2701ea13a0afa759e8cc0ed75cab9
2020-07-01 13:07:14 +02:00
Harald Welte df9e44826e Bump version: 0.0.1.2-7731 → 0.1.0
Change-Id: I1a73ef1c6db1e5ccec4fbe29a94a26bce4f5d1a9
2020-07-01 12:29:43 +02:00
Harald Welte 5b482fb4ca debian: Remove dependency to libosmo-abis; remove explicit libosmocore version
Change-Id: Icee48755142a90dac9843c9230a3b23551815fc1
2020-07-01 12:28:30 +02:00
Harald Welte 7731a33372 debian: Fix packaging of libosmo-e1d
dpkg-shlibdeps: error: cannot find library libosmo-e1d.so.0 needed by debian/osmo-e1d/usr/bin/osmo-e1d (ELF format: 'elf32-i386' abi: '0101000300000000'; RPATH: '')
Change-Id: Iaacd17aa69e56b21b925710d63b699c2e7ede12a
2020-07-01 11:13:03 +02:00
Harald Welte cf3ba8fc2a debian/control: Add missing dependency to libusb-1.0-0-dev
Change-Id: I65c4693ea88a0417574258d4df99c6ec1755ee0d
2020-07-01 10:56:45 +02:00
Harald Welte e1145c53e3 add systemd service/unit
Change-Id: I956cd9e7ff378a6372524175a1c83416be45610b
2020-07-01 08:29:39 +00:00
Harald Welte d32bd186a3 debian packaging
Change-Id: Idac376e92f95ab8beef506e9617227f1c7277838
2020-07-01 08:29:39 +00:00
Harald Welte 9c8ee9361f proto*.[ch]: Don't refer to GPL if license is LGPL
while at it, also change from physical address to URL.

Change-Id: I60a25f802a7b4535f7d47bb04b9f36194ea4e290
2020-07-01 08:07:03 +00:00
Harald Welte 6e027c2cb6 add git-version-gen to EXTRA_DIST
Change-Id: I874e7c323e0700c3282cb992dfaf1853bdc3a8c8
2020-06-30 21:46:17 +02:00
Harald Welte 171e7a3a06 add example configurations
Change-Id: I25c28f7a1eeb4deaebba3b2fd593cbbdceb1fa07
2020-06-30 21:40:52 +02:00
Harald Welte de22257ee1 vty: Print actual driver name instead of FIXME
Change-Id: I6f909cc493417f9e156672024f879a7294b4d816
2020-06-30 19:44:09 +02:00
Harald Welte c3cefbb396 Add osmo-e1d-pipe utility
This adds the 'osmo-e1d-pipe' utlility program, which can be
used as a command-line client to open a given E1 timeslot and
connect it to stdin/stdout.  This in turn allows to rediect
file input/output via the shell.

Change-Id: Ib9d55af786c87e15465b8e73493680b35afb5913
2020-06-30 19:44:09 +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 54e9773d34 proto.h: Share default socket path between client and daemon
This way clients and daemon don't have to be manually configured
to use the same default socket path.

Change-Id: Ibc5bc1bc59056ebaf0f6072de0ff08c2f3bb5457
2020-06-29 22:14:05 +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 65b22c0b75 Export _e1d_ts_stop() function inside daemon
Change-Id: If3ceca05d4fdf1e33d926061f30fce6bfa8e0357
2020-06-29 22:12:42 +02:00
Harald Welte 8a9392ff44 ctl.c: Fix off-by-one: FD=0 is a valid file descriptor
It is possible that fd=0 (stdin) is closed in a daemon scenario, and
subsequently fd=0 is reused for other files/sockets.

Change-Id: Id8279f04373e891009224bab34a4d1d886520fea
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